This commit is contained in:
Azavax 2025-07-19 10:59:39 +03:30
parent 011e0f309a
commit 2383049bf2
2 changed files with 27 additions and 1 deletions

View file

@ -47,6 +47,7 @@ func (a *APIController) initRouter(g *gin.RouterGroup) {
{"POST", "/resetAllClientTraffics/:id", a.inboundController.resetAllClientTraffics}, {"POST", "/resetAllClientTraffics/:id", a.inboundController.resetAllClientTraffics},
{"POST", "/delDepletedClients/:id", a.inboundController.delDepletedClients}, {"POST", "/delDepletedClients/:id", a.inboundController.delDepletedClients},
{"POST", "/onlines", a.inboundController.onlines}, {"POST", "/onlines", a.inboundController.onlines},
{"POST", "/updateClientTraffic/:email", a.inboundController.updateClientTraffic},
} }
for _, route := range inboundRoutes { for _, route := range inboundRoutes {
@ -56,4 +57,4 @@ func (a *APIController) initRouter(g *gin.RouterGroup) {
func (a *APIController) createBackup(c *gin.Context) { func (a *APIController) createBackup(c *gin.Context) {
a.Tgbot.SendBackupToAdmins() a.Tgbot.SendBackupToAdmins()
} }

View file

@ -339,3 +339,28 @@ func (a *InboundController) delDepletedClients(c *gin.Context) {
func (a *InboundController) onlines(c *gin.Context) { func (a *InboundController) onlines(c *gin.Context) {
jsonObj(c, a.inboundService.GetOnlineClients(), nil) 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)
}