API: subid to getClientTraffics
Some checks are pending
Release 3X-UI / build (386) (push) Waiting to run
Release 3X-UI / build (amd64) (push) Waiting to run
Release 3X-UI / build (arm64) (push) Waiting to run
Release 3X-UI / build (armv5) (push) Waiting to run
Release 3X-UI / build (armv6) (push) Waiting to run
Release 3X-UI / build (armv7) (push) Waiting to run
Release 3X-UI / build (s390x) (push) Waiting to run
Release 3X-UI / Build for Windows (push) Waiting to run

/getClientTraffics/:email
/getClientTrafficsById/:id
This commit is contained in:
mhsanaei 2025-09-17 01:29:22 +02:00
parent 22afa50901
commit 299572a4c2
No known key found for this signature in database
GPG key ID: D875CD086CF668A0
2 changed files with 3 additions and 1 deletions

View file

@ -1951,8 +1951,8 @@ func (s *InboundService) GetClientTrafficByEmail(email string) (traffic *xray.Cl
return nil, err return nil, err
} }
if t != nil && client != nil { if t != nil && client != nil {
// Ensure enable mirrors the client's current enable flag in settings
t.Enable = client.Enable t.Enable = client.Enable
t.SubId = client.SubID
return t, nil return t, nil
} }
return nil, nil return nil, nil
@ -1993,6 +1993,7 @@ func (s *InboundService) GetClientTrafficByID(id string) ([]xray.ClientTraffic,
for i := range traffics { for i := range traffics {
if ct, client, e := s.GetClientByEmail(traffics[i].Email); e == nil && ct != nil && client != nil { if ct, client, e := s.GetClientByEmail(traffics[i].Email); e == nil && ct != nil && client != nil {
traffics[i].Enable = client.Enable traffics[i].Enable = client.Enable
traffics[i].SubId = client.SubID
} }
} }
return traffics, err return traffics, err

View file

@ -5,6 +5,7 @@ type ClientTraffic struct {
InboundId int `json:"inboundId" form:"inboundId"` InboundId int `json:"inboundId" form:"inboundId"`
Enable bool `json:"enable" form:"enable"` Enable bool `json:"enable" form:"enable"`
Email string `json:"email" form:"email" gorm:"unique"` Email string `json:"email" form:"email" gorm:"unique"`
SubId string `json:"subId" form:"subId" gorm:"-"`
Up int64 `json:"up" form:"up"` Up int64 `json:"up" form:"up"`
Down int64 `json:"down" form:"down"` Down int64 `json:"down" form:"down"`
AllTime int64 `json:"allTime" form:"allTime"` AllTime int64 `json:"allTime" form:"allTime"`