diff --git a/app/core/background/license_service.py b/app/core/background/license_service.py index 7291024..f27c63e 100644 --- a/app/core/background/license_service.py +++ b/app/core/background/license_service.py @@ -64,21 +64,25 @@ async def license_index_loop(memory, platform_found: bool, seqno: int) -> [bool, chat_wrap = Wrapped_CBotChat(CLIENT_TELEGRAM_API_KEY, chat_id=user.telegram_id, db_session=session, user=user) content = session.query(StoredContent).filter_by(id=action.content_id).first() + edited_ = False if (datetime.now() - action.created) > timedelta(minutes=5): if action.telegram_message_id: await chat_wrap.delete_message(action.telegram_message_id) make_log("LicenseIndex", f"Action timeout: {action.id}", level="info") action.status = 'canceled' + edited_ = True else: user_wallet_address = user.wallet_address(session) user_content = session.query(UserContent).filter_by(content_id=action.content_id, status='active', owner_address=user_wallet_address).first() if user_content: make_log("LicenseIndex", f"User already has content: {user_content.content_id}", level="info") action.status = 'success' + edited_ = True - session.commit() - await chat_wrap.send_content(session, content) + if edited_: + session.commit() + await chat_wrap.send_content(session, content) except BaseException as e: make_log("LicenseIndex", f"Error: {e}" + '\n' + traceback.format_exc(), level="error")