fix: prevent client updated_at from resetting when parent inbound is updated
Some checks failed
Release 3X-UI / build (386) (push) Has been cancelled
Release 3X-UI / build (amd64) (push) Has been cancelled
Release 3X-UI / build (arm64) (push) Has been cancelled
Release 3X-UI / build (armv5) (push) Has been cancelled
Release 3X-UI / build (armv6) (push) Has been cancelled
Release 3X-UI / build (armv7) (push) Has been cancelled
Release 3X-UI / build (s390x) (push) Has been cancelled

This commit is contained in:
Ali Golzar 2025-09-02 02:27:44 +03:30 committed by Ali Golzar
parent 4a0914cb1e
commit ed2a0a0bcf

View file

@ -349,6 +349,7 @@ func (s *InboundService) UpdateInbound(inbound *model.Inbound) (*model.Inbound,
var oldSettings map[string]any var oldSettings map[string]any
_ = json.Unmarshal([]byte(oldInbound.Settings), &oldSettings) _ = json.Unmarshal([]byte(oldInbound.Settings), &oldSettings)
emailToCreated := map[string]int64{} emailToCreated := map[string]int64{}
emailToUpdated := map[string]int64{}
if oldSettings != nil { if oldSettings != nil {
if oc, ok := oldSettings["clients"].([]any); ok { if oc, ok := oldSettings["clients"].([]any); ok {
for _, it := range oc { for _, it := range oc {
@ -360,6 +361,12 @@ func (s *InboundService) UpdateInbound(inbound *model.Inbound) (*model.Inbound,
case int64: case int64:
emailToCreated[email] = v emailToCreated[email] = v
} }
switch v := m["updated_at"].(type) {
case float64:
emailToUpdated[email] = int64(v)
case int64:
emailToUpdated[email] = v
}
} }
} }
} }
@ -379,7 +386,12 @@ func (s *InboundService) UpdateInbound(inbound *model.Inbound) (*model.Inbound,
m["created_at"] = now m["created_at"] = now
} }
} }
m["updated_at"] = now // Preserve client's updated_at if present; do not bump on parent inbound update
if _, hasUpdated := m["updated_at"]; !hasUpdated {
if v, ok4 := emailToUpdated[email]; ok4 && v > 0 {
m["updated_at"] = v
}
}
nSlice[i] = m nSlice[i] = m
} }
} }