From a89f8336d6c15e431ad888da98267f024aab5ea0 Mon Sep 17 00:00:00 2001 From: romanskijdev Date: Thu, 6 Aug 2026 15:47:53 +0300 Subject: [PATCH] Added permissions for web panel approvals getting --- core/lib/external/tgkit/client.go | 4 +- .../handlers/approval/handle_files.go | 2 +- .../handlers/approval/handler.go | 56 ++++++++----------- 3 files changed, 28 insertions(+), 34 deletions(-) diff --git a/core/lib/external/tgkit/client.go b/core/lib/external/tgkit/client.go index 24cb708..77df83c 100644 --- a/core/lib/external/tgkit/client.go +++ b/core/lib/external/tgkit/client.go @@ -341,7 +341,9 @@ func (c *Client) Request(cfg tgbotapi.Chattable) (*tgbotapi.APIResponse, error) // заданном proxyCfg реально оборачиваем транспорт в CustomAPIProxyTransport. func buildHTTPClient(proxyCfg *ProxyConfig, timeout time.Duration) (*http.Client, error) { baseTransport := &http.Transport{ - TLSClientConfig: &tls.Config{InsecureSkipVerify: false}, + MaxIdleConns: 100, // Увеличиваем общий пул + MaxIdleConnsPerHost: 100, // Увеличиваем пул для api.telegram.org / прокси + TLSClientConfig: &tls.Config{InsecureSkipVerify: false}, } var finalTransport http.RoundTripper = baseTransport diff --git a/service/telegram_service/handlers/approval/handle_files.go b/service/telegram_service/handlers/approval/handle_files.go index c9fa7e4..b245768 100644 --- a/service/telegram_service/handlers/approval/handle_files.go +++ b/service/telegram_service/handlers/approval/handle_files.go @@ -247,7 +247,7 @@ func (h *Handler) HandleAttachSubmit(bot *tgbotapi.BotAPI, cq *tgbotapi.Callback // Уведомляем всех участников с отправкой самих файлов медиагруппами fileDesc := fmt.Sprintf("%d файл(ов)", savedCount) - h.notifyAllParticipantsAboutFile(bot, approvalID, user, fileDesc) + go h.notifyAllParticipantsAboutFile(bot, approvalID, user, fileDesc) } // HandleAttachClear — очистить список файлов diff --git a/service/telegram_service/handlers/approval/handler.go b/service/telegram_service/handlers/approval/handler.go index ab9cd0f..d70bb20 100644 --- a/service/telegram_service/handlers/approval/handler.go +++ b/service/telegram_service/handlers/approval/handler.go @@ -435,10 +435,12 @@ func (h *Handler) performActualRevoke( commentKeyboard := keyboard.BuildCommentNotificationKeyboard(approvalID, commentsCount) notify := func(chatID int64, text string) { - msg := tgbotapi.NewMessage(chatID, text) - msg.ParseMode = "HTML" - msg.ReplyMarkup = commentKeyboard - bot.Send(msg) //nolint:errcheck + go func() { + msg := tgbotapi.NewMessage(chatID, text) + msg.ParseMode = "HTML" + msg.ReplyMarkup = commentKeyboard + bot.Send(msg) //nolint:errcheck + }() } // Инициатор (если не сам отзывал) @@ -694,41 +696,31 @@ func (h *Handler) HandleViewFilesCallback(bot *tgbotapi.BotAPI, cq *tgbotapi.Cal return } - //cardButton := tgkit.NewInlineKeyboard(). - // Row(tgkit.Btn("📋 Показать заявку", fmt.Sprintf("appr_show_card:%d", approvalID))). - // Build() - caption := fmt.Sprintf("📎 Файлы к заявке #%d (%d шт.):", approvalID, len(files)) for i, f := range files { if f.FileBase64 == nil || f.FileName == nil { continue } - data, err := base64.StdEncoding.DecodeString(*f.FileBase64) - if err != nil { - logrus.Errorf("HandleViewFilesCallback: decode err=%v", err) - continue - } - doc := tgbotapi.NewDocument(chatID, tgbotapi.FileBytes{ - Name: *f.FileName, - Bytes: data, - }) - doc.ParseMode = "HTML" - //isLast := i == len(files)-1 - - // Подпись — на первом файле, чтобы сразу было видно к какой заявке относится - if i == 0 { - doc.Caption = caption - } - //// Кнопка возврата к карточке — на последнем файле - //if isLast { - // doc.ReplyMarkup = cardButton - //} - - if _, err := bot.Send(doc); err != nil { - logrus.Errorf("HandleViewFilesCallback: Send err=%v", err) - } + go func(fileBase64 string, fileName string, isFirst bool) { + data, err := base64.StdEncoding.DecodeString(fileBase64) + if err != nil { + logrus.Errorf("HandleViewFilesCallback: decode err=%v", err) + return + } + doc := tgbotapi.NewDocument(chatID, tgbotapi.FileBytes{ + Name: fileName, + Bytes: data, + }) + doc.ParseMode = "HTML" + if isFirst { + doc.Caption = caption + } + if _, err := bot.Send(doc); err != nil { + logrus.Errorf("HandleViewFilesCallback: Send err=%v", err) + } + }(*f.FileBase64, *f.FileName, i == 0) } } -- 2.43.0