fix: add orders to direct_messages table

This commit is contained in:
Vlad Stan 2023-03-24 16:55:23 +02:00
parent b0890b8ebb
commit c583af3c33
2 changed files with 11 additions and 11 deletions

View file

@ -78,7 +78,7 @@ def order_from_json(s: str) -> Tuple[Optional[Any], Optional[str]]:
try:
order = json.loads(s)
return (
(order, None) if (type(order) is dict) and "items" in order else (None, s)
(order, s) if (type(order) is dict) and "items" in order else (None, s)
)
except ValueError:
return None, s

View file

@ -272,13 +272,6 @@ async def _handle_dirrect_message(
) -> Optional[str]:
order, text_msg = order_from_json(msg)
try:
if order:
order["public_key"] = from_pubkey
order["merchant_public_key"] = merchant_public_key
order["event_id"] = event_id
order["event_created_at"] = event_created_at
return await _handle_new_order(PartialOrder(**order))
else:
dm = PartialDirectMessage(
event_id=event_id,
event_created_at=event_created_at,
@ -287,6 +280,13 @@ async def _handle_dirrect_message(
incoming=True,
)
await create_direct_message(merchant_id, dm)
if order:
order["public_key"] = from_pubkey
order["merchant_public_key"] = merchant_public_key
order["event_id"] = event_id
order["event_created_at"] = event_created_at
return await _handle_new_order(PartialOrder(**order))
return None
except Exception as ex:
logger.warning(ex)