diff --git a/app/api/routes/content.py b/app/api/routes/content.py index 3b19c62..9c93737 100644 --- a/app/api/routes/content.py +++ b/app/api/routes/content.py @@ -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 + ( diff --git a/docker-compose.yml b/docker-compose.yml index dbe0334..bde202d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -80,20 +80,20 @@ services: maria_db: condition: service_healthy - convert_process: - build: - context: . - dockerfile: Dockerfile - command: python -m app convert_process - env_file: - - .env - links: - - maria_db - volumes: - - /Storage/logs:/app/logs - - /Storage/storedContent:/app/data - - /var/run/docker.sock:/var/run/docker.sock - depends_on: - maria_db: - condition: service_healthy + # convert_process: + # build: + # context: . + # dockerfile: Dockerfile + # command: python -m app convert_process + # env_file: + # - .env + # links: + # - maria_db + # volumes: + # - /Storage/logs:/app/logs + # - /Storage/storedContent:/app/data + # - /var/run/docker.sock:/var/run/docker.sock + # depends_on: + # maria_db: + # condition: service_healthy