fix indexer

This commit is contained in:
user 2025-03-05 04:20:12 +03:00
parent ec484af8c4
commit 3514588ac2
1 changed files with 27 additions and 26 deletions

View File

@ -217,33 +217,34 @@ async def indexer_loop(memory, platform_found: bool, seqno: int) -> [bool, int]:
encrypted_stored_content.user_id = user_wallet_connection.user_id encrypted_stored_content.user_id = user_wallet_connection.user_id
user = user_wallet_connection.user user = user_wallet_connection.user
user_uploader_wrapper = Wrapped_CBotChat(memory._telegram_bot, chat_id=user.telegram_id, user=user, db_session=session) if user:
await user_uploader_wrapper.send_message( user_uploader_wrapper = Wrapped_CBotChat(memory._telegram_bot, chat_id=user.telegram_id, user=user, db_session=session)
user.translated('p_contentWasIndexed').format( await user_uploader_wrapper.send_message(
item_address=item_address.to_string(1, 1, 1), user.translated('p_contentWasIndexed').format(
item_index=item_index, item_address=item_address.to_string(1, 1, 1),
), item_index=item_index,
message_type='notification', ),
reply_markup=get_inline_keyboard([ message_type='notification',
[{ reply_markup=get_inline_keyboard([
'text': user.translated('viewTrackAsClient_button'), [{
'url': f"https://t.me/{CLIENT_TELEGRAM_BOT_USERNAME}?start=C{encrypted_stored_content.cid.serialize_v2()}" 'text': user.translated('viewTrackAsClient_button'),
}], 'url': f"https://t.me/{CLIENT_TELEGRAM_BOT_USERNAME}?start=C{encrypted_stored_content.cid.serialize_v2()}"
]) }],
) ])
)
try: try:
for hint_message in session.query(KnownTelegramMessage).filter( for hint_message in session.query(KnownTelegramMessage).filter(
and_( and_(
KnownTelegramMessage.chat_id == user.telegram_id, KnownTelegramMessage.chat_id == user.telegram_id,
KnownTelegramMessage.type == 'hint', KnownTelegramMessage.type == 'hint',
cast(KnownTelegramMessage.meta['encrypted_content_hash'], String) == encrypted_stored_content.hash, cast(KnownTelegramMessage.meta['encrypted_content_hash'], String) == encrypted_stored_content.hash,
KnownTelegramMessage.deleted == False KnownTelegramMessage.deleted == False
) )
).all(): ).all():
await user_uploader_wrapper.delete_message(hint_message.message_id) await user_uploader_wrapper.delete_message(hint_message.message_id)
except BaseException as e: except BaseException as e:
make_log("Indexer", f"Error while deleting hint messages: {e}" + '\n' + traceback.format_exc(), level="error") make_log("Indexer", f"Error while deleting hint messages: {e}" + '\n' + traceback.format_exc(), level="error")
elif encrypted_stored_content.type.startswith('onchain') and encrypted_stored_content.onchain_index == item_index: elif encrypted_stored_content.type.startswith('onchain') and encrypted_stored_content.onchain_index == item_index:
encrypted_stored_content.type = "onchain/content" + ("_unknown" if (encrypted_stored_content.key_id is None) else "") encrypted_stored_content.type = "onchain/content" + ("_unknown" if (encrypted_stored_content.key_id is None) else "")
encrypted_stored_content.owner_address = item_owner_address.to_string(1, 1, 1) encrypted_stored_content.owner_address = item_owner_address.to_string(1, 1, 1)