From 00afde49a53301c1b67dc3e08ed73c8f0e1f3ac4 Mon Sep 17 00:00:00 2001 From: user Date: Wed, 5 Feb 2025 13:57:19 +0300 Subject: [PATCH] hashtag notify fixes --- app/core/background/indexer_service.py | 27 ++++++++++--------- app/core/models/_telegram/templates/player.py | 2 +- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/app/core/background/indexer_service.py b/app/core/background/indexer_service.py index 60967e5..9095f5d 100644 --- a/app/core/background/indexer_service.py +++ b/app/core/background/indexer_service.py @@ -57,18 +57,21 @@ async def indexer_loop(memory, platform_found: bool, seqno: int) -> [bool, int]: session, licensed_content ) - for wallet_owner_connection in session.query(WalletConnection).filter_by(wallet_address=licensed_content.owner_address).order_by(desc(WalletConnection.id)).first(): - wallet_owner_user = wallet_owner_connection.user - if wallet_owner_user.telegram_id: - wallet_owner_bot = Wrapped_CBotChat(memory._client_telegram_bot, chat_id=wallet_owner_user.telegram_id, user=wallet_owner_user, db_session=session) - await wallet_owner_bot.send_message( - user.translated('p_licenseWasBought').format( - username=user.front_format(), - nft_address=f'"https://tonviewer.com/{new_license.onchain_address}"', - content_title=content_metadata.get('name', 'Unknown'), - ), - message_type='notification', - ) + wallet_owner_connection = session.query(WalletConnection).filter_by( + wallet_address=licensed_content.owner_address, + invalidated=False + ).order_by(desc(WalletConnection.id)).first() + wallet_owner_user = wallet_owner_connection.user + if wallet_owner_user.telegram_id: + wallet_owner_bot = Wrapped_CBotChat(memory._client_telegram_bot, chat_id=wallet_owner_user.telegram_id, user=wallet_owner_user, db_session=session) + await wallet_owner_bot.send_message( + user.translated('p_licenseWasBought').format( + username=user.front_format(), + nft_address=f'"https://tonviewer.com/{new_license.onchain_address}"', + content_title=content_metadata.get('name', 'Unknown'), + ), + message_type='notification', + ) except BaseException as e: make_log("IndexerSendNewLicense", f"Error: {e}" + '\n' + traceback.format_exc(), level="error") diff --git a/app/core/models/_telegram/templates/player.py b/app/core/models/_telegram/templates/player.py index eaed78e..ef4c863 100644 --- a/app/core/models/_telegram/templates/player.py +++ b/app/core/models/_telegram/templates/player.py @@ -128,7 +128,7 @@ class PlayerTemplates: inline_keyboard_array = [] extra_buttons = [] else: - text = ' '.join([f"#{_h}" for _h in content_metadata_json.get('hashtags', [])]).strip() + text = content_metadata_json.get('description').strip() user_wallet_address = self.user.wallet_address(self.db_session) have_access = (