referral sales
This commit is contained in:
1 parent
7baac11834
commit
7448023642
5 files changed
+48
-20
No files matched your search
@@ -14,6 +14,7 @@ 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.content.user_content import UserContent
|
||||
from app.core.models.node_storage import StoredContent
|
||||
from app.core.models._telegram import Wrapped_CBotChat
|
||||
from app.core._keyboards import get_inline_keyboard
|
||||
@@ -120,8 +121,8 @@ async def s_api_v1_blockchain_send_new_content_message(request):
|
||||
begin_cell()
|
||||
.store_ref(
|
||||
begin_cell()
|
||||
.store_coins(int(30000000))
|
||||
.store_coins(int(30000000))
|
||||
.store_coins(int(0))
|
||||
.store_coins(int(0))
|
||||
.store_coins(int(request.json['price']))
|
||||
.end_cell()
|
||||
)
|
||||
@@ -163,14 +164,23 @@ async def s_api_v1_blockchain_send_purchase_content_message(request):
|
||||
assert field_key in request.json, f"No {field_key} provided"
|
||||
assert field_value(request.json[field_key]), f"Invalid {field_key} provided"
|
||||
|
||||
r_content = StoredContent.from_cid(request.ctx.db_session, request.json['content_address'])
|
||||
license_exist = request.ctx.db_session.query(UserContent).filter_by(
|
||||
onchain_address=request.json['content_address'],
|
||||
).first()
|
||||
if license_exist:
|
||||
r_content = StoredContent.from_cid(request.ctx.db_session, license_exist.content.cid.serialize_v2())
|
||||
else:
|
||||
r_content = StoredContent.from_cid(request.ctx.db_session, request.json['content_address'])
|
||||
|
||||
content = r_content.open_content(request.ctx.db_session)
|
||||
|
||||
licenses_cost = content['encrypted_content'].json_format()['license']
|
||||
assert request.json['license_type'] in licenses_cost
|
||||
|
||||
return response.json({
|
||||
'address': content['encrypted_content'].json_format()['item_address'],
|
||||
'address': (
|
||||
license_exist.onchain_address if license_exist else content['encrypted_content'].json_format()['item_address']
|
||||
),
|
||||
'amount': str(int(licenses_cost['resale']['price'])),
|
||||
'payload': b64encode((
|
||||
begin_cell()
|
||||
|
||||
@@ -37,6 +37,13 @@ async def s_api_v1_content_list(request):
|
||||
|
||||
async def s_api_v1_content_view(request, content_address: str):
|
||||
# content_address can be CID or TON address
|
||||
|
||||
license_exist = request.ctx.db_session.query(UserContent).filter_by(
|
||||
onchain_address=content_address,
|
||||
).first()
|
||||
if license_exist:
|
||||
content_address = license_exist.content.cid.serialize_v2()
|
||||
|
||||
r_content = StoredContent.from_cid(request.ctx.db_session, content_address)
|
||||
content = r_content.open_content(request.ctx.db_session)
|
||||
|
||||
|
||||
Reference in new issue
Block a user