mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-08-16 16:20:59 +00:00
fix(client): honor keepTraffic when deleting a client that is attached to inbounds
Delete, DeleteByEmail and BulkDelete all pass keepTraffic to their final cleanup transaction, but each called the per-inbound delete helper with a hardcoded false. That helper purges the client's traffic, IP and stat rows before the gated cleanup runs, so keepTraffic=true still destroyed all traffic history for any client actually attached to an inbound (the pinned test only covered a record with no inbound mappings). Thread the caller's keepTraffic through to the per-inbound helper at all three call sites.
This commit is contained in:
@@ -510,7 +510,7 @@ func (s *ClientService) Delete(inboundSvc *InboundService, id int, keepTraffic b
|
||||
if existing.Email == "" {
|
||||
continue
|
||||
}
|
||||
nr, delErr := s.DelInboundClientByEmail(inboundSvc, ibId, existing.Email, false, true)
|
||||
nr, delErr := s.DelInboundClientByEmail(inboundSvc, ibId, existing.Email, keepTraffic, true)
|
||||
if delErr != nil {
|
||||
// The client is already absent from this inbound (data drift or a
|
||||
// retried delete). Skip it — deletion stays idempotent.
|
||||
@@ -678,7 +678,7 @@ func (s *ClientService) DeleteByEmail(inboundSvc *InboundService, email string,
|
||||
needRestart := false
|
||||
var delErrs []error
|
||||
for _, ibId := range inboundIds {
|
||||
nr, delErr := s.DelInboundClientByEmail(inboundSvc, ibId, email, false, true)
|
||||
nr, delErr := s.DelInboundClientByEmail(inboundSvc, ibId, email, keepTraffic, true)
|
||||
if delErr != nil {
|
||||
if errors.Is(delErr, ErrClientNotInInbound) {
|
||||
continue
|
||||
|
||||
Reference in New Issue
Block a user