temp disable converter, add invoice_link
This commit is contained in:
1 parent
37a2f18bb2
commit
35b3e2db77
2 files changed
+36
-17
No files matched your search
@@ -1,10 +1,12 @@
|
||||
from sanic import response
|
||||
|
||||
from aiogram import Bot, types
|
||||
from app.core.logger import make_log
|
||||
from app.core.models.node_storage import StoredContent
|
||||
from app.core.models.keys import KnownKey
|
||||
from app.core.models.content.user_content import UserContent
|
||||
from app.core._config import CLIENT_TELEGRAM_API_KEY
|
||||
import json
|
||||
import uuid
|
||||
|
||||
|
||||
async def s_api_v1_content_list(request):
|
||||
@@ -43,6 +45,7 @@ async def s_api_v1_content_view(request, content_address: str):
|
||||
opts['key_hash'] = known_key.seed_hash
|
||||
|
||||
opts['have_licenses'] = []
|
||||
opts['invoice_url'] = None
|
||||
|
||||
have_access = False
|
||||
if request.ctx.user:
|
||||
@@ -52,6 +55,22 @@ async def s_api_v1_content_view(request, content_address: str):
|
||||
or bool(request.ctx.db_session.query(UserContent).filter_by(owner_address=user_wallet_address, status='active',
|
||||
content_id=content['encrypted_content'].id).first())
|
||||
)
|
||||
if not have_access:
|
||||
try:
|
||||
invoice_id = uuid.uuid4().hex
|
||||
opts['invoice_url'] = (
|
||||
await Bot(token=CLIENT_TELEGRAM_API_KEY).create_invoice_link(
|
||||
description='You will receive NFT with lifetime access to content',
|
||||
payload=f"access_{invoice_id}",
|
||||
title='Lifetime access to content',
|
||||
currency='XTR',
|
||||
prices=[
|
||||
types.LabeledPrice(label='Lifetime access', amount=1)
|
||||
]
|
||||
)
|
||||
)
|
||||
except BaseException as e:
|
||||
make_log("Content", f"Can't create invoice link: {e}", level='warning')
|
||||
|
||||
display_options = {
|
||||
'content_url': content['decrypted_content'].web_url + (
|
||||
|
||||
Reference in new issue
Block a user