From b4f85508d3533d6aa37cd9d3b37ecaeed8527cdb Mon Sep 17 00:00:00 2001 From: somebodywashere <68244480+somebodywashere@users.noreply.github.com> Date: Tue, 19 Dec 2023 22:08:46 +0300 Subject: [PATCH] Preparations for tgbot additions --- web/service/inbound.go | 26 ++++++++++++++++++++++++++ web/service/tgbot.go | 1 + 2 files changed, 27 insertions(+) diff --git a/web/service/inbound.go b/web/service/inbound.go index 01d4eb57..bb4fe3c9 100644 --- a/web/service/inbound.go +++ b/web/service/inbound.go @@ -1184,6 +1184,32 @@ func (s *InboundService) SetClientTelegramUserID(trafficId int, tgId string) err return nil } +func (s *InboundService) checkIsEnabledByEmail(clientEmail string) (bool, error) { + _, inbound, err := s.GetClientInboundByEmail(clientEmail) + if err != nil { + return false, err + } + if inbound == nil { + return false, common.NewError("Inbound Not Found For Email:", clientEmail) + } + + clients, err := s.GetClients(inbound) + if err != nil { + return false, err + } + + isEnable := false + + for _, client := range clients { + if client.Email == clientEmail { + isEnable = client.Enable + break + } + } + + return isEnable, err +} + func (s *InboundService) ToggleClientEnableByEmail(clientEmail string) (bool, error) { _, inbound, err := s.GetClientInboundByEmail(clientEmail) if err != nil { diff --git a/web/service/tgbot.go b/web/service/tgbot.go index 0847e418..d77e2e71 100644 --- a/web/service/tgbot.go +++ b/web/service/tgbot.go @@ -672,6 +672,7 @@ func (t *Tgbot) asnwerCallback(callbackQuery *telego.CallbackQuery, isAdmin bool t.searchClient(chatId, email, callbackQuery.Message.MessageID) } else { t.sendCallbackAnswerTgBot(callbackQuery.ID, t.I18nBot("tgbot.answers.errorOperation")) + logger.Error(err) } } return