temp disable converter, add invoice_link

This commit is contained in:
user 2025-02-26 17:49:18 +03:00
parent 37a2f18bb2
commit 35b3e2db77
2 changed files with 36 additions and 17 deletions

View File

@ -1,10 +1,12 @@
from sanic import response from sanic import response
from aiogram import Bot, types
from app.core.logger import make_log from app.core.logger import make_log
from app.core.models.node_storage import StoredContent from app.core.models.node_storage import StoredContent
from app.core.models.keys import KnownKey from app.core.models.keys import KnownKey
from app.core.models.content.user_content import UserContent from app.core.models.content.user_content import UserContent
from app.core._config import CLIENT_TELEGRAM_API_KEY
import json import json
import uuid
async def s_api_v1_content_list(request): 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['key_hash'] = known_key.seed_hash
opts['have_licenses'] = [] opts['have_licenses'] = []
opts['invoice_url'] = None
have_access = False have_access = False
if request.ctx.user: 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', or bool(request.ctx.db_session.query(UserContent).filter_by(owner_address=user_wallet_address, status='active',
content_id=content['encrypted_content'].id).first()) 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 = { display_options = {
'content_url': content['decrypted_content'].web_url + ( 'content_url': content['decrypted_content'].web_url + (

View File

@ -80,20 +80,20 @@ services:
maria_db: maria_db:
condition: service_healthy condition: service_healthy
convert_process: # convert_process:
build: # build:
context: . # context: .
dockerfile: Dockerfile # dockerfile: Dockerfile
command: python -m app convert_process # command: python -m app convert_process
env_file: # env_file:
- .env # - .env
links: # links:
- maria_db # - maria_db
volumes: # volumes:
- /Storage/logs:/app/logs # - /Storage/logs:/app/logs
- /Storage/storedContent:/app/data # - /Storage/storedContent:/app/data
- /var/run/docker.sock:/var/run/docker.sock # - /var/run/docker.sock:/var/run/docker.sock
depends_on: # depends_on:
maria_db: # maria_db:
condition: service_healthy # condition: service_healthy