From 3f138d5d3b330f1a29166caa64e12358114dd00b Mon Sep 17 00:00:00 2001 From: Roman Dyakov Date: Mon, 15 Apr 2024 05:34:09 +0300 Subject: [PATCH] Saving data fix --- social/utils/telegram_groups.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/social/utils/telegram_groups.py b/social/utils/telegram_groups.py index 6888925..51a985e 100644 --- a/social/utils/telegram_groups.py +++ b/social/utils/telegram_groups.py @@ -40,7 +40,8 @@ def approve_telegram_group(update: Update): logger.error("Telegram group not validated (secret=%s, group=%s)", text, group) return text = text.removeprefix('/validate').removeprefix('@ViribusSocialBot').strip() - db.session.query(CreateGroupRequest).where(CreateGroupRequest.secret_key == text).update( - {CreateGroupRequest.mapped_group_id: group.id} - ) + request = db.session.query(CreateGroupRequest).where(CreateGroupRequest.secret_key == text).one_or_none() + request.mapped_group_id=group.id + group.owner_id = request.owner_id + db.session.commit() logger.info("Telegram group %d validated (secret=%s)", group.id, text)