feat: notify new customer

This commit is contained in:
Vlad Stan 2023-03-27 18:09:19 +03:00
parent 7c6feca831
commit 098cb5adf5

View file

@ -255,10 +255,7 @@ async def _handle_incoming_dms(
):
customer = await get_customer(merchant.id, event.pubkey)
if not customer:
await create_customer(
merchant.id, Customer(merchant_id=merchant.id, public_key=event.pubkey)
)
await nostr_client.subscribe_to_user_profile(event.pubkey, 0)
await _handle_new_customer(event, merchant)
dm_reply = await _handle_dirrect_message(
merchant.id,
@ -335,6 +332,17 @@ async def _handle_new_order(order: PartialOrder) -> Optional[str]:
return None
async def _handle_new_customer(event, merchant):
await create_customer(
merchant.id, Customer(merchant_id=merchant.id, public_key=event.pubkey)
)
await nostr_client.subscribe_to_user_profile(event.pubkey, 0)
await websocketUpdater(
merchant.id,
json.dumps({"type": "new-customer"}),
)
async def _handle_customer_profile_update(event: NostrEvent):
try:
profile = json.loads(event.content)