purchase notify, fix preview
This commit is contained in:
parent
21a83cf5b8
commit
4d15211344
|
|
@ -169,7 +169,7 @@ async def t_inline_query_node_content(query: types.InlineQuery, memory=None, use
|
|||
content_list.append(
|
||||
types.InlineQueryResultCachedAudio(
|
||||
id=f"NC_{content.id}_{int(datetime.now().timestamp() // 60)}",
|
||||
audio_file_id=decrypted_content.meta.get('telegram_file_cache_preview', decrypted_content.meta['telegram_file_cache']),
|
||||
audio_file_id=decrypted_content.meta['telegram_file_cache_preview'],
|
||||
title=title,
|
||||
performer=performer,
|
||||
caption=hashtags_str + user.translated('p_playerContext_preview'),
|
||||
|
|
@ -194,7 +194,7 @@ async def t_inline_query_node_content(query: types.InlineQuery, memory=None, use
|
|||
content_list.append(
|
||||
types.InlineQueryResultCachedVideo(
|
||||
id=f"NC_{content.id}_{int(datetime.now().timestamp() // 60)}",
|
||||
video_file_id=decrypted_content.meta.get('telegram_file_cache_preview', decrypted_content.meta['telegram_file_cache']),
|
||||
video_file_id=decrypted_content.meta['telegram_file_cache_preview'],
|
||||
title=title,
|
||||
caption=hashtags_str + user.translated('p_playerContext_preview'),
|
||||
parse_mode='html',
|
||||
|
|
|
|||
|
|
@ -47,12 +47,28 @@ async def indexer_loop(memory, platform_found: bool, seqno: int) -> [bool, int]:
|
|||
if not licensed_content:
|
||||
make_log("Indexer", f"Licensed content not found: {new_license.content_id}", level="error")
|
||||
|
||||
content_metadata = licensed_content.metadata_json(session)
|
||||
assert content_metadata, "No content metadata found"
|
||||
|
||||
try:
|
||||
user = new_license.user
|
||||
if user.telegram_id and licensed_content:
|
||||
await (Wrapped_CBotChat(memory._client_telegram_bot, chat_id=user.telegram_id, user=user, db_session=session)).send_content(
|
||||
session, licensed_content
|
||||
)
|
||||
|
||||
for wallet_owner_connection in session.query(WalletConnection).filter_by(wallet_address=licensed_content.owner_address).all():
|
||||
wallet_owner_user = wallet_owner_connection.user
|
||||
if wallet_owner_user.telegram_id:
|
||||
wallet_owner_bot = Wrapped_CBotChat(memory._client_telegram_bot, chat_id=wallet_owner_user.telegram_id, user=wallet_owner_user, db_session=session)
|
||||
await wallet_owner_bot.send_message(
|
||||
user.translated('p_licenseWasBought').format(
|
||||
username=user.front_format(),
|
||||
nft_address=f'"{new_license.onchain_address}"',
|
||||
content_title=content_metadata.get('name', 'Unknown'),
|
||||
),
|
||||
message_type='notification',
|
||||
)
|
||||
except BaseException as e:
|
||||
make_log("IndexerSendNewLicense", f"Error: {e}" + '\n' + traceback.format_exc(), level="error")
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import json
|
||||
from base58 import b58decode
|
||||
from sqlalchemy import Column, BigInteger, Integer, String, ForeignKey, DateTime, JSON, Boolean
|
||||
from sqlalchemy.orm import relationship
|
||||
|
|
@ -139,6 +140,13 @@ class StoredContent(AlchemyBase, AudioContentMixin):
|
|||
"created": spec_field_created,
|
||||
"updated": spec_field_updated,
|
||||
}
|
||||
|
||||
def metadata_json(self, db_session):
|
||||
metadata_cid = self.meta.get('metadata_cid')
|
||||
if metadata_cid:
|
||||
metadata_content = StoredContent.from_cid(db_session, metadata_cid)
|
||||
with open(metadata_content.filepath, 'r') as f:
|
||||
return json.loads(f.read())
|
||||
|
||||
@classmethod
|
||||
def from_cid(cls, db_session, content_id):
|
||||
|
|
|
|||
Loading…
Reference in New Issue