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)
|
customer = await get_customer(merchant.id, event.pubkey)
|
||||||
if not customer:
|
if not customer:
|
||||||
await create_customer(
|
await _handle_new_customer(event, merchant)
|
||||||
merchant.id, Customer(merchant_id=merchant.id, public_key=event.pubkey)
|
|
||||||
)
|
|
||||||
await nostr_client.subscribe_to_user_profile(event.pubkey, 0)
|
|
||||||
|
|
||||||
dm_reply = await _handle_dirrect_message(
|
dm_reply = await _handle_dirrect_message(
|
||||||
merchant.id,
|
merchant.id,
|
||||||
|
|
@ -335,6 +332,17 @@ async def _handle_new_order(order: PartialOrder) -> Optional[str]:
|
||||||
return None
|
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):
|
async def _handle_customer_profile_update(event: NostrEvent):
|
||||||
try:
|
try:
|
||||||
profile = json.loads(event.content)
|
profile = json.loads(event.content)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue