NoticeManager: thats better

This commit is contained in:
AdrienLSH 2024-04-28 08:03:34 +02:00
parent 743988c883
commit 9fea10fc91

View File

@ -18,7 +18,7 @@ class NoticeManager:
unsend_notices = NoticeModel.objects.filter(user=consumer.user)
for notice in unsend_notices:
self.notify_user(consumer.user, json_data=notice.data)
consumer.send(notice.data)
notice.delete()
def remove(self, consumer: NoticeConsumer):
@ -29,9 +29,9 @@ class NoticeManager:
if consumer.user == user:
return consumer
def notify_user(self, user: User, data: dict = None, json_data: str = None):
def notify_user(self, user: User, data: dict):
consumer = self.get_consumer_by_user(user)
data_str: str = json.dumps(data) if json_data is None else json_data
data_str: str = json.dumps(data)
if consumer:
consumer.send(data_str)
else: