diff --git a/service/telegram_service/common/update/0_init.go b/service/telegram_service/common/update/0_init.go
index fe63bec..9f5e783 100644
--- a/service/telegram_service/common/update/0_init.go
+++ b/service/telegram_service/common/update/0_init.go
@@ -41,6 +41,7 @@ func NewUpdateHandler(ipc *types.InternalProviderControl) *UpdateHandler {
// TODO: вызывается только после обновлений
//go handler.broadcastBotUpdated()
//go handler.sendNewSupportContactNotification()
+ go handler.broadcastCommentsFeatureUpdate()
return handler
}
@@ -122,3 +123,47 @@ func (s *UpdateHandler) sendNewSupportContactNotification() {
logrus.Infof("sendNewSupportContactNotification: отправлено %d пользователям", len(users))
}
+
+// broadcastCommentsFeatureUpdate уведомляет всех пользователей о новой функции комментариев.
+func (s *UpdateHandler) broadcastCommentsFeatureUpdate() {
+ ctx := context.Background()
+ bot := s.ipc.TGBotClient.Bot()
+
+ users, _, err := s.ipc.Database.User.GetUsersListDB(ctx, typescore.ListDbOptions{})
+ if err != nil {
+ logrus.Errorf("broadcastCommentsFeatureUpdate: GetUsersListDB err=%v", err)
+ return
+ }
+
+ text := "🆕 Что нового в системе согласований\n\n" +
+ "Мы обновили работу с комментариями - теперь заявка стала похожа на общий чат:\n\n" +
+ "💬 Комментарии видят все участники\n" +
+ "Инициатор, согласующий, доп. согласующие, исполнители и наблюдатели теперь получают комментарии друг друга и могут сразу ответить.\n\n" +
+ "📋 Кнопка «Посмотреть все комментарии» в каждой карточке\n" +
+ "На карточке заявки сразу видно, сколько комментариев уже оставлено - можно открыть полную историю в один клик.\n\n" +
+ "Нажмите кнопку ниже, чтобы перезапустить бота:"
+
+ keyboard := tgbotapi.NewInlineKeyboardMarkup(
+ tgbotapi.NewInlineKeyboardRow(
+ tgbotapi.NewInlineKeyboardButtonData("🚀 Перезапустить бота", "restart_bot"),
+ ),
+ )
+
+ sent := 0
+ for _, user := range users {
+ if user.TelegramID == nil {
+ continue
+ }
+ msg := tgbotapi.NewMessage(*user.TelegramID, text)
+ msg.ParseMode = "HTML"
+ msg.ReplyMarkup = keyboard
+ if _, err := bot.Send(msg); err != nil {
+ logrus.Warnf("broadcastCommentsFeatureUpdate: Send to telegramID=%d err=%v", *user.TelegramID, err)
+ continue
+ }
+ sent++
+ time.Sleep(50 * time.Millisecond)
+ }
+
+ logrus.Infof("broadcastCommentsFeatureUpdate: отправлено %d из %d пользователям", sent, len(users))
+}