FIX: Ensure valid json (#39)
* Build EVENT message with json.dumps instead of string interpolation Ensures outbound Nostr messages are valid JSON and safely escaped by constructing the payload as Python objects and serializing with json.dumps * improve logs * remove log causing check failure
This commit is contained in:
parent
02af516903
commit
e66f997853
1 changed files with 6 additions and 2 deletions
|
|
@ -111,10 +111,14 @@ class NostrRouter:
|
|||
# this reconstructs the original response from the relay
|
||||
# reconstruct original subscription id
|
||||
s_original = self.original_subscription_ids[s]
|
||||
event_to_forward = f"""["EVENT", "{s_original}", {event_json}]"""
|
||||
event_to_forward = json.dumps(
|
||||
["EVENT", s_original, json.loads(event_json)]
|
||||
)
|
||||
await self.websocket.send_text(event_to_forward)
|
||||
except Exception as e:
|
||||
logger.debug(e) # there are 2900 errors here
|
||||
logger.warning(
|
||||
f"[NOSTRCLIENT] Error in _handle_received_subscription_events: {e}"
|
||||
)
|
||||
|
||||
def _handle_notices(self):
|
||||
while len(NostrRouter.received_subscription_notices):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue