fix: add extra checks (#21)
* fix: add extra checks * fix: remove redundant try-catch
This commit is contained in:
parent
6f5e9e3458
commit
e841183c10
1 changed files with 33 additions and 23 deletions
10
router.py
10
router.py
|
|
@ -89,13 +89,21 @@ class NostrRouter:
|
|||
|
||||
|
||||
async def _handle_received_subscription_eosenotices(self, s):
|
||||
try:
|
||||
if s not in self.original_subscription_ids:
|
||||
return
|
||||
s_original = self.original_subscription_ids[s]
|
||||
event_to_forward = ["EOSE", s_original]
|
||||
del NostrRouter.received_subscription_eosenotices[s]
|
||||
|
||||
await self.websocket.send_text(json.dumps(event_to_forward))
|
||||
except Exception as e:
|
||||
logger.debug(e)
|
||||
|
||||
async def _handle_received_subscription_events(self, s):
|
||||
try:
|
||||
if s not in NostrRouter.received_subscription_events:
|
||||
return
|
||||
while len(NostrRouter.received_subscription_events[s]):
|
||||
my_event = NostrRouter.received_subscription_events[s].pop(0)
|
||||
# event.to_message() does not include the subscription ID, we have to add it manually
|
||||
|
|
@ -114,6 +122,8 @@ class NostrRouter:
|
|||
s_original = self.original_subscription_ids[s]
|
||||
event_to_forward = ["EVENT", s_original, event_json]
|
||||
await self.websocket.send_text(json.dumps(event_to_forward))
|
||||
except Exception as e:
|
||||
logger.debug(e)
|
||||
|
||||
def _handle_notices(self):
|
||||
while len(NostrRouter.received_subscription_notices):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue