From 181d980e485362bccd3ca0f8936034bd1a7683a2 Mon Sep 17 00:00:00 2001 From: user Date: Sat, 1 Mar 2025 10:33:00 +0300 Subject: [PATCH] fixes --- app/api/__init__.py | 3 ++- app/api/routes/content.py | 4 ++++ app/core/background/indexer_service.py | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/api/__init__.py b/app/api/__init__.py index d46ed6c..43ab01d 100644 --- a/app/api/__init__.py +++ b/app/api/__init__.py @@ -21,7 +21,7 @@ from app.api.routes.progressive_storage import s_api_v1_5_storage_get, s_api_v1_ from app.api.routes.account import s_api_v1_account_get from app.api.routes._blockchain import s_api_v1_blockchain_send_new_content_message, \ s_api_v1_blockchain_send_purchase_content_message -from app.api.routes.content import s_api_v1_content_list, s_api_v1_content_view, s_api_v1_content_friendly_list +from app.api.routes.content import s_api_v1_content_list, s_api_v1_content_view, s_api_v1_content_friendly_list, s_api_v1_5_content_list from app.api.routes.tonconnect import s_api_v1_tonconnect_new, s_api_v1_tonconnect_logout @@ -55,6 +55,7 @@ app.add_route(s_api_v1_blockchain_send_purchase_content_message, "/api/v1/blockc app.add_route(s_api_v1_content_list, "/api/v1/content.list", methods=["GET", "OPTIONS"]) app.add_route(s_api_v1_content_view, "/api/v1/content.view/", methods=["GET", "OPTIONS"]) app.add_route(s_api_v1_content_friendly_list, "/api/v1/content.friendlyList", methods=["GET", "OPTIONS"]) +app.add_route(s_api_v1_5_content_list, "/api/v1.5/content.list", methods=["GET", "OPTIONS"]) @app.exception(BaseException) diff --git a/app/api/routes/content.py b/app/api/routes/content.py index ed7d29c..9c6c5da 100644 --- a/app/api/routes/content.py +++ b/app/api/routes/content.py @@ -167,6 +167,10 @@ async def s_api_v1_content_friendly_list(request): for content in request.ctx.db_session.query(StoredContent).filter( StoredContent.type == 'onchain/content' ).all(): + if not content.meta.get('metadata_cid'): + make_log("Content", f"Content {content.cid.serialize_v2()} has no metadata", level='warning') + continue + metadata_content = StoredContent.from_cid(request.ctx.db_session, content.meta.get('metadata_cid')) with open(metadata_content.filepath, 'r') as f: metadata = json.loads(f.read()) diff --git a/app/core/background/indexer_service.py b/app/core/background/indexer_service.py index f6dfb0a..6f2224a 100644 --- a/app/core/background/indexer_service.py +++ b/app/core/background/indexer_service.py @@ -41,7 +41,7 @@ async def indexer_loop(memory, platform_found: bool, seqno: int) -> [bool, int]: assert result['stack'][1][0] == 'num', f"get second element is not num" usdt_per_ton = (int(result['stack'][0][1], 16) * 1e3) / int(result['stack'][1][1], 16) ton_per_star = 0.014 / usdt_per_ton - await ServiceConfig(session).set('live_tonPerStar', [ton_per_star, datetime.utcnow().timestamp()]) + ServiceConfig(session).set('live_tonPerStar', [ton_per_star, datetime.utcnow().timestamp()]) make_log("TON_Daemon", f"TON per STAR price: {ton_per_star}", level="DEBUG") except BaseException as e: make_log("TON_Daemon", f"Error while saving TON per STAR price: {e}" + '\n' + traceback.format_exc(), level="ERROR")