From a88747a0c40a07acdd55a1025bca7282a6299a97 Mon Sep 17 00:00:00 2001 From: jedi Date: Fri, 26 Apr 2024 01:22:08 +0200 Subject: [PATCH] stash --- core/mail/notifications.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/core/mail/notifications.py b/core/mail/notifications.py index f41f816..36120aa 100644 --- a/core/mail/notifications.py +++ b/core/mail/notifications.py @@ -3,21 +3,22 @@ from channels.layers import get_channel_layer class NotificationDispatcher: channel_layer = None - channel_name = None + room_group_name = "general" def __init__(self): - self.channel_layer = get_channel_layer() + self.channel_layer = get_channel_layer('default') if not self.channel_layer: raise Exception("Could not get channel layer") async def run_forever(self): # Infinite loop to continuously listen for messages print("Listening for messages...") - self.channel_name = await self.channel_layer.new_channel() - print("Channel name:", self.channel_name) + channel_name = await self.channel_layer.new_channel() + await self.channel_layer.group_add(self.room_group_name, channel_name) + print("Channel name:", channel_name) while True: # Blocking receive to get the message from the channel layer - message = await self.channel_layer.receive(self.channel_name) + message = await self.channel_layer.receive(channel_name) if message: # Process the received message