From e4ed3103480c7ca1ff7e3dd7c14eefe8444ecf54 Mon Sep 17 00:00:00 2001 From: Azavax <21226881+azavaxhuman@users.noreply.github.com> Date: Sun, 20 Jul 2025 11:54:12 +0330 Subject: [PATCH] Update inbound.go --- web/controller/inbound.go | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/web/controller/inbound.go b/web/controller/inbound.go index 592a4bd0..a89f224f 100644 --- a/web/controller/inbound.go +++ b/web/controller/inbound.go @@ -339,3 +339,28 @@ func (a *InboundController) delDepletedClients(c *gin.Context) { func (a *InboundController) onlines(c *gin.Context) { jsonObj(c, a.inboundService.GetOnlineClients(), nil) } + +func (a *InboundController) updateClientTraffic(c *gin.Context) { + email := c.Param("email") + + // Define the request structure for traffic update + type TrafficUpdateRequest struct { + Upload int64 `json:"upload"` + Download int64 `json:"download"` + } + + var request TrafficUpdateRequest + err := c.ShouldBindJSON(&request) + if err != nil { + jsonMsg(c, I18nWeb(c, "pages.inbounds.toasts.inboundUpdateSuccess"), err) + return + } + + err = a.inboundService.UpdateClientTrafficByEmail(email, request.Upload, request.Download) + if err != nil { + jsonMsg(c, I18nWeb(c, "somethingWentWrong"), err) + return + } + + jsonMsg(c, I18nWeb(c, "pages.inbounds.toasts.inboundClientUpdateSuccess"), nil) +}