dev@locazia: fix cover upload

This commit is contained in:
user 2024-03-08 02:57:41 +03:00
parent c7506547ab
commit 7c5bdb3bb6
1 changed files with 11 additions and 7 deletions

View File

@ -55,12 +55,16 @@ async def s_api_v1_blockchain_send_new_content_message(request):
assert encrypted_content, "No content locally found" assert encrypted_content, "No content locally found"
assert encrypted_content.type == "local/content_bin", "Invalid content type" assert encrypted_content.type == "local/content_bin", "Invalid content type"
if request.json['image']:
image_content_cid, err = resolve_content(request.json['image']) image_content_cid, err = resolve_content(request.json['image'])
assert not err, f"Invalid image CID" assert not err, f"Invalid image CID"
image_content = request.ctx.db_session.query(StoredContent).filter( image_content = request.ctx.db_session.query(StoredContent).filter(
StoredContent.hash == image_content_cid.content_hash_b58 StoredContent.hash == image_content_cid.content_hash_b58
).first() ).first()
assert image_content, "No image locally found" assert image_content, "No image locally found"
else:
image_content_cid = None
image_content = None
metadata_content = await create_metadata_for_item( metadata_content = await create_metadata_for_item(
request.ctx.db_session, request.ctx.db_session,
@ -114,7 +118,7 @@ async def s_api_v1_blockchain_send_new_content_message(request):
.store_ref( .store_ref(
begin_cell() begin_cell()
.store_ref(begin_cell().store_bytes(f"{encrypted_content_cid.serialize_v1()}".encode()).end_cell()) .store_ref(begin_cell().store_bytes(f"{encrypted_content_cid.serialize_v1()}".encode()).end_cell())
.store_ref(begin_cell().store_bytes(f"{image_content_cid.serialize_v1()}".encode()).end_cell()) .store_ref(begin_cell().store_bytes(f"{image_content_cid.serialize_v1() if image_content_cid else ''}".encode()).end_cell())
.store_ref(begin_cell().store_bytes(f"{metadata_content.serialize_v1()}".encode()).end_cell()) .store_ref(begin_cell().store_bytes(f"{metadata_content.serialize_v1()}".encode()).end_cell())
.end_cell() .end_cell()
) )