Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/MHSanaei/3x-ui.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAzavax <21226881+azavaxhuman@users.noreply.github.com>2025-07-23 00:43:48 +0300
committerGitHub <noreply@github.com>2025-07-23 00:43:48 +0300
commitb1ab156e42ed0e68b49e89df45d44b6ad0ea02ff (patch)
treee4ffb3297e38afaf54e625065ab2886b25f5fc1c /web/service
parentfa45bf87de469f9e7f79c90b4381de5b9e4f58d2 (diff)
Endpoint for updating client traffic by email (#3259)
* Update api.go * Update inbound.go * Update inbound.go
Diffstat (limited to 'web/service')
-rw-r--r--web/service/inbound.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/web/service/inbound.go b/web/service/inbound.go
index f2646dbb..66e1a420 100644
--- a/web/service/inbound.go
+++ b/web/service/inbound.go
@@ -1785,6 +1785,21 @@ func (s *InboundService) GetClientTrafficByEmail(email string) (traffic *xray.Cl
return nil, nil
}
+func (s *InboundService) UpdateClientTrafficByEmail(email string, upload int64, download int64) error {
+ db := database.GetDB()
+
+ result := db.Model(xray.ClientTraffic{}).
+ Where("email = ?", email).
+ Updates(map[string]any{"up": upload, "down": download})
+
+ err := result.Error
+ if err != nil {
+ logger.Warningf("Error updating ClientTraffic with email %s: %v", email, err)
+ return err
+ }
+ return nil
+}
+
func (s *InboundService) GetClientTrafficByID(id string) ([]xray.ClientTraffic, error) {
db := database.GetDB()
var traffics []xray.ClientTraffic