This commit is contained in:
user committed 2024-04-05 21:50:06 +03:00
1 parent e63e040692
commit 6405baf251
3 files changed
+38 -33

No files matched your search

+1 -1
View File
@@ -58,7 +58,7 @@ async def license_index_loop(memory, platform_found: bool, seqno: int) -> [bool,
chat_wrap = Wrapped_CBotChat(CLIENT_TELEGRAM_API_KEY, chat_id=user.telegram_id, db_session=session, user=user)
content = session.query(StoredContent).filter_by(id=action.content_id).first()
if (datetime.now() - action.updated) > timedelta(minutes=5):
if (datetime.now() - action.created) > timedelta(minutes=5):
if action.telegram_message_id:
await chat_wrap.delete_message(action.telegram_message_id)
+36 -31
View File
@@ -28,40 +28,45 @@ class WalletMixin:
have_next_page = True
for nft_item in nfts_list:
item_address = Address(nft_item['address']).to_string(1, 1, 1)
owner_address = Address(nft_item['owner_address']).to_string(1, 1, 1)
user_content = db_session.query(UserContent).filter(
UserContent.onchain_address == item_address
).first()
if user_content:
continue
try:
nft_content = nft_item['content']['uri']
except KeyError:
nft_content = None
make_log(self, f"Scanning onchain NFT: {nft_item}", level='info')
item_address = Address(nft_item['address']).to_string(1, 1, 1)
owner_address = Address(nft_item['owner_address']).to_string(1, 1, 1)
user_content = UserContent(
type='nft/unknown',
onchain_address=item_address,
owner_address=owner_address,
code_hash=nft_item['code_hash'],
data_hash=nft_item['data_hash'],
updated=datetime.fromtimestamp(0),
content_id=None, # not resolved yet
created=datetime.now(),
meta={
'metadata_uri': nft_content,
},
user_id=self.id,
wallet_connection_id=self.wallet_connection(db_session).id,
status="active"
)
db_session.add(user_content)
db_session.commit()
user_content = db_session.query(UserContent).filter(
UserContent.onchain_address == item_address
).first()
if user_content:
continue
make_log(self, f"New onchain NFT found: {item_address}", level='info')
try:
nft_content = nft_item['content']['uri']
except KeyError:
nft_content = None
user_content = UserContent(
type='nft/unknown',
onchain_address=item_address,
owner_address=owner_address,
code_hash=nft_item['code_hash'],
data_hash=nft_item['data_hash'],
updated=datetime.fromtimestamp(0),
content_id=None, # not resolved yet
created=datetime.now(),
meta={
'metadata_uri': nft_content,
},
user_id=self.id,
wallet_connection_id=self.wallet_connection(db_session).id,
status="active"
)
db_session.add(user_content)
db_session.commit()
make_log(self, f"New onchain NFT found: {item_address}", level='info')
except BaseException as e:
make_log(self, f"Error while scanning onchain NFT: {e}", level='error')
continue
async def get_user_content(self, db_session, limit=100, offset=0):
try: