From 5b57f84dcbb93b6c2c290c268b0f108a92d0bdb9 Mon Sep 17 00:00:00 2001 From: user Date: Fri, 8 Mar 2024 10:42:23 +0300 Subject: [PATCH] dev@locazia: fix uploading content. make encrypted content generation --- app/api/routes/_blockchain.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/app/api/routes/_blockchain.py b/app/api/routes/_blockchain.py index 6a1bb76..d482326 100644 --- a/app/api/routes/_blockchain.py +++ b/app/api/routes/_blockchain.py @@ -12,6 +12,7 @@ from app.core._config import PROJECT_HOST from app.core.logger import make_log from app.core._utils.resolve_content import resolve_content from app.core.content.utils import create_metadata_for_item +from app.core._crypto.content import create_encrypted_content from app.core.models.node_storage import StoredContent @@ -50,13 +51,16 @@ async def s_api_v1_blockchain_send_new_content_message(request): await ton_connect.restore_connection() assert ton_connect.connected, "No connected wallet" - encrypted_content_cid, err = resolve_content(request.json['content']) + decrypted_content_cid, err = resolve_content(request.json['content']) assert not err, f"Invalid content CID" - encrypted_content = request.ctx.db_session.query(StoredContent).filter( - StoredContent.hash == encrypted_content_cid.content_hash_b58 + decrypted_content = request.ctx.db_session.query(StoredContent).filter( + StoredContent.hash == decrypted_content_cid.content_hash_b58 ).first() - assert encrypted_content, "No content locally found" - assert encrypted_content.type == "local/content_bin", "Invalid content type" + assert decrypted_content, "No content locally found" + assert decrypted_content.type == "local/content_bin", "Invalid content type" + + encrypted_content = await create_encrypted_content(request.ctx.db_session, decrypted_content) + encrypted_content_cid = encrypted_content.cid if request.json['image']: image_content_cid, err = resolve_content(request.json['image'])