purchase notify, fix preview
This commit is contained in:
1 parent
21a83cf5b8
commit
4d15211344
3 files changed
+26
-2
No files matched your search
@@ -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):
|
||||
|
||||
Reference in new issue
Block a user