diff --git a/README.md b/README.md index e907e420..73743f56 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,7 @@ xray panel supporting multi-protocol, **Multi-lang (English,Farsi,Chinese)** | `POST` | `"/del/:id"` | Delete Inbound | | `POST` | `"/update/:id"` | Update Inbound | | `POST` | `"/addClient/"` | Add Client to inbound | -| `POST` | `"/delClient/:email"` | Delete Client | +| `POST` | `"/:id/delClient/:clientId"` | Delete Client by UID/Password as clientId | | `POST` | `"/updateClient/:index"` | Update Client | | `POST` | `"/:id/resetClientTraffic/:email"` | Reset Client's Traffic | | `POST` | `"/resetAllTraffics"` | Reset traffics of all inbounds | diff --git a/config/version b/config/version index 7f207341..e6d5cb83 100644 --- a/config/version +++ b/config/version @@ -1 +1 @@ -1.0.1 \ No newline at end of file +1.0.2 \ No newline at end of file diff --git a/web/service/inbound.go b/web/service/inbound.go index a8fba2b4..b0bba9e0 100644 --- a/web/service/inbound.go +++ b/web/service/inbound.go @@ -686,7 +686,7 @@ func (s *InboundService) GetClientTrafficTgBot(tguname string) ([]*xray.ClientTr return traffics, err } -func (s *InboundService) GetClientTrafficByEmail(email string) (traffic []*xray.ClientTraffic, err error) { +func (s *InboundService) GetClientTrafficByEmail(email string) (traffic *xray.ClientTraffic, err error) { db := database.GetDB() var traffics []*xray.ClientTraffic @@ -697,7 +697,7 @@ func (s *InboundService) GetClientTrafficByEmail(email string) (traffic []*xray. return nil, err } } - return traffics, err + return traffics[0], err } func (s *InboundService) SearchClientTraffic(query string) (traffic *xray.ClientTraffic, err error) { diff --git a/web/service/tgbot.go b/web/service/tgbot.go index b40e0e29..4703c0ca 100644 --- a/web/service/tgbot.go +++ b/web/service/tgbot.go @@ -404,38 +404,36 @@ func (t *Tgbot) getClientUsage(chatId int64, tgUserName string) { } func (t *Tgbot) searchClient(chatId int64, email string) { - traffics, err := t.inboundService.GetClientTrafficByEmail(email) + traffic, err := t.inboundService.GetClientTrafficByEmail(email) if err != nil { logger.Warning(err) msg := "❌ Something went wrong!" t.SendMsgToTgbot(chatId, msg) return } - if len(traffics) == 0 { + if traffic == nil { msg := "No result!" t.SendMsgToTgbot(chatId, msg) return } - for _, traffic := range traffics { - expiryTime := "" - if traffic.ExpiryTime == 0 { - expiryTime = "♾Unlimited" - } else if traffic.ExpiryTime < 0 { - expiryTime = fmt.Sprintf("%d days", traffic.ExpiryTime/-86400000) - } else { - expiryTime = time.Unix((traffic.ExpiryTime / 1000), 0).Format("2006-01-02 15:04:05") - } - total := "" - if traffic.Total == 0 { - total = "♾Unlimited" - } else { - total = common.FormatTraffic((traffic.Total)) - } - output := fmt.Sprintf("💡 Active: %t\r\n📧 Email: %s\r\n🔼 Upload↑: %s\r\n🔽 Download↓: %s\r\n🔄 Total: %s / %s\r\n📅 Expire in: %s\r\n", - traffic.Enable, traffic.Email, common.FormatTraffic(traffic.Up), common.FormatTraffic(traffic.Down), common.FormatTraffic((traffic.Up + traffic.Down)), - total, expiryTime) - t.SendMsgToTgbot(chatId, output) + expiryTime := "" + if traffic.ExpiryTime == 0 { + expiryTime = "♾Unlimited" + } else if traffic.ExpiryTime < 0 { + expiryTime = fmt.Sprintf("%d days", traffic.ExpiryTime/-86400000) + } else { + expiryTime = time.Unix((traffic.ExpiryTime / 1000), 0).Format("2006-01-02 15:04:05") } + total := "" + if traffic.Total == 0 { + total = "♾Unlimited" + } else { + total = common.FormatTraffic((traffic.Total)) + } + output := fmt.Sprintf("💡 Active: %t\r\n📧 Email: %s\r\n🔼 Upload↑: %s\r\n🔽 Download↓: %s\r\n🔄 Total: %s / %s\r\n📅 Expire in: %s\r\n", + traffic.Enable, traffic.Email, common.FormatTraffic(traffic.Up), common.FormatTraffic(traffic.Down), common.FormatTraffic((traffic.Up + traffic.Down)), + total, expiryTime) + t.SendMsgToTgbot(chatId, output) } func (t *Tgbot) searchInbound(chatId int64, remark string) {