dev@locazia: fix uploading content. make encrypted content generation

This commit is contained in:
user 2024-03-08 10:42:23 +03:00
parent 6d66546332
commit 5b57f84dcb
1 changed files with 9 additions and 5 deletions

View File

@ -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'])