mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-11-18 19:15:03 +03:00
fix(clients): restore depleted clients on renewal and prioritize operator writes (#6987)
Restore usable clients when renewed, avoid duplicate reset updates, and prioritize operator writes in the serialized traffic writer. Preserve manual disables and keep every inbound consistent after traffic resets.
This commit is contained in:
committed by
GitHub
parent
e4935be861
commit
dbb6212988
@@ -782,6 +782,12 @@ func (s *ClientService) update(inboundSvc *InboundService, id int, updated model
|
||||
updated.Secret = existing.Secret
|
||||
}
|
||||
|
||||
// A client the quota loop switched off comes back on when this update
|
||||
// restores a usable window, as BulkAdjust already does on a renewal (#5619).
|
||||
if !updated.Enable && s.renewalReenables(existing.Email, updated.TotalGB, updated.ExpiryTime) {
|
||||
updated.Enable = true
|
||||
}
|
||||
|
||||
if updated.Email != existing.Email {
|
||||
var collisionCount int64
|
||||
if err := database.GetDB().Model(&model.ClientRecord{}).
|
||||
@@ -936,6 +942,15 @@ func (s *ClientService) update(inboundSvc *InboundService, id int, updated model
|
||||
}).Error; err != nil {
|
||||
return needRestart, err
|
||||
}
|
||||
// No inbound left, so UpdateClientStat never runs; re-assert the
|
||||
// enforcement row's off switch here or a re-enabled client stays off.
|
||||
if merged.Enable {
|
||||
if err := database.GetDB().Model(xray.ClientTraffic{}).
|
||||
Where("email = ?", existing.Email).
|
||||
UpdateColumn("enable", true).Error; err != nil {
|
||||
return needRestart, err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
reverseStr := ""
|
||||
|
||||
Reference in New Issue
Block a user