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 3 additions and 2 deletions
Showing only changes of commit 23d4e9893e - Show all commits

View File

@ -77,12 +77,13 @@ func checkCaptcha(b *bot, update *echotron.Update) error {
message := update.Message
sender := message.From
store := tongo.NewStore[db.User](Client)
d := db.GetDatabase()
chatStore := tongo.NewStore[db.Chat](Client)
// d := db.GetDatabase()
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
defer cancel()
if user, err := store.GetOne(ctx, tongo.E("user_id", sender.ID), tongo.E("chat_id", message.Chat.ID)); err == nil { //d.GetUser(ctx, db.User{UserId: sender.ID, ChatId: message.Chat.ID}); err == nil {
if message.Chat.IsForum {
chat, err := d.GetChat(ctx, message.Chat.ID)
chat, err := chatStore.GetOne(ctx, tongo.E("chat_id", message.Chat.ID))
if err != nil {
return err
}