dev@locazia: implement message_types and clean trash
This commit is contained in:
1 parent
01d56dae42
commit
dae4a6f123
10 files changed
+118
-31
No files matched your search
@@ -12,12 +12,14 @@ from app.core._utils.send_status import send_status
|
||||
from app.core.logger import make_log
|
||||
from app.core.models.node_storage import StoredContent
|
||||
from app.core.models.wallet_connection import WalletConnection
|
||||
from app.core._keyboards import get_inline_keyboard
|
||||
from app.core.models._telegram import Wrapped_CBotChat
|
||||
from app.core.storage import db_session
|
||||
import os
|
||||
import traceback
|
||||
|
||||
|
||||
async def indexer_loop(platform_found: bool, seqno: int) -> [bool, int]:
|
||||
async def indexer_loop(memory, platform_found: bool, seqno: int) -> [bool, int]:
|
||||
if not platform_found:
|
||||
platform_state = await toncenter.get_account(platform.address.to_string(1, 1, 1))
|
||||
if not platform_state.get('code'):
|
||||
@@ -120,14 +122,29 @@ async def indexer_loop(platform_found: bool, seqno: int) -> [bool, int]:
|
||||
and encrypted_stored_content.onchain_index != item_index
|
||||
if not is_duplicate:
|
||||
if encrypted_stored_content.type.startswith('local'):
|
||||
encrypted_stored_content.type = "onchain/content" + (
|
||||
"_unknown" if not (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.onchain_index = item_index
|
||||
encrypted_stored_content.owner_address = item_owner_address.to_string(1, 1, 1)
|
||||
user = None
|
||||
if user_wallet_connection:
|
||||
encrypted_stored_content.user_id = user_wallet_connection.user_id
|
||||
user = user_wallet_connection.user
|
||||
|
||||
await (Wrapped_CBotChat(memory._telegram_bot, chat_id=user.telegram_id)).send_message(
|
||||
user.translated('p_contentWasIndexed').format(
|
||||
item_address=item_address.to_string(1, 1, 1),
|
||||
item_index=item_index,
|
||||
),
|
||||
message_type='notification',
|
||||
reply_markup=get_inline_keyboard([
|
||||
[{
|
||||
'text': user.translated('home_button'),
|
||||
'callback_data': 'home'
|
||||
}]
|
||||
])
|
||||
)
|
||||
elif encrypted_stored_content.type.startswith('onchain') and encrypted_stored_content.onchain_index == item_index:
|
||||
encrypted_stored_content.type = "onchain/content" + ("_unknown" if not (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)
|
||||
if user_wallet_connection:
|
||||
encrypted_stored_content.user_id = user_wallet_connection.user_id
|
||||
@@ -168,13 +185,13 @@ async def indexer_loop(platform_found: bool, seqno: int) -> [bool, int]:
|
||||
return platform_found, seqno
|
||||
|
||||
|
||||
async def main_fn():
|
||||
async def main_fn(memory, ):
|
||||
make_log("Indexer", "Service started", level="info")
|
||||
platform_found = False
|
||||
seqno = 0
|
||||
while True:
|
||||
try:
|
||||
platform_found, seqno = await indexer_loop(platform_found, seqno)
|
||||
platform_found, seqno = await indexer_loop(memory, platform_found, seqno)
|
||||
except BaseException as e:
|
||||
make_log("Indexer", f"Error: {e}" + '\n' + traceback.format_exc(), level="error")
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ async def get_sw_seqno():
|
||||
return sw_seqno_value
|
||||
|
||||
|
||||
async def main_fn():
|
||||
async def main_fn(memory):
|
||||
make_log("TON", f"Service started, SW = {service_wallet.address.to_string(1, 1, 1)}", level="info")
|
||||
sw_seqno_value = await get_sw_seqno()
|
||||
make_log("TON", f"Service wallet run seqno method: {sw_seqno_value}", level="info")
|
||||
|
||||
@@ -8,7 +8,7 @@ async def uploader_loop():
|
||||
pass
|
||||
|
||||
|
||||
async def main_fn():
|
||||
async def main_fn(memory):
|
||||
make_log("Uploader", "Service started", level="info")
|
||||
seqno = 0
|
||||
while True:
|
||||
|
||||
Reference in new issue
Block a user