Migration to Tongo, new logic for user storage #3

Merged
nefrace merged 19 commits from tongo into master 2023-09-10 13:10:33 +03:00
1 changed files with 5 additions and 1 deletions
Showing only changes of commit 7ac170ce04 - Show all commits

View File

@ -51,10 +51,14 @@ func TaskNotifyUsers(b *echotron.API) {
text := fmt.Sprintf("*[%s](tg://user?id=%d)*, напоминаю, что тебе необходимо пройти капчу\\!", EscapeText(echotron.MarkdownV2, user.FirstName), user.Id)
store.ReplaceItem(ctx, *user, false)
chat, err := chatStore.GetOne(ctx, tongo.E("chat_id", user.ChatId))
topic := 0
if err != nil {
log.Printf("Can't get chat from user: %s", err)
return
} else {
topic = int(chat.TopicId)
}
res, err := b.SendMessage(text, user.ChatId, &echotron.MessageOptions{MessageThreadID: int(chat.TopicId), ParseMode: echotron.MarkdownV2})
res, err := b.SendMessage(text, user.ChatId, &echotron.MessageOptions{MessageThreadID: topic, ParseMode: echotron.MarkdownV2})
if err != nil {
log.Printf("Can't send notification to user: %s", err)
}