diff --git a/app/api/routes/_blockchain.py b/app/api/routes/_blockchain.py index f7062ab..0bfb1d2 100644 --- a/app/api/routes/_blockchain.py +++ b/app/api/routes/_blockchain.py @@ -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.type == "local/content_bin", "Invalid content type" - image_content_cid, err = resolve_content(request.json['image']) - assert not err, f"Invalid image CID" - image_content = request.ctx.db_session.query(StoredContent).filter( - StoredContent.hash == image_content_cid.content_hash_b58 - ).first() - assert image_content, "No image locally found" + if request.json['image']: + image_content_cid, err = resolve_content(request.json['image']) + assert not err, f"Invalid image CID" + image_content = request.ctx.db_session.query(StoredContent).filter( + StoredContent.hash == image_content_cid.content_hash_b58 + ).first() + assert image_content, "No image locally found" + else: + image_content_cid = None + image_content = None metadata_content = await create_metadata_for_item( request.ctx.db_session, @@ -114,7 +118,7 @@ async def s_api_v1_blockchain_send_new_content_message(request): .store_ref( begin_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()) .end_cell() )