feat: notify new customer
This commit is contained in:
parent
7c6feca831
commit
098cb5adf5
1 changed files with 12 additions and 4 deletions
16
services.py
16
services.py
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue