first push

This commit is contained in:
2026-01-18 11:45:53 +03:30
commit 6bcd71d9ec
702 changed files with 272997 additions and 0 deletions

25
notification/notify.py Normal file
View File

@@ -0,0 +1,25 @@
from asgiref.sync import async_to_sync
from channels.layers import get_channel_layer
@classmethod
def notify_ws_clients(self, message):
"""
Inform client there is a new message.
"""
notification = {
"type": "recieve_group_message",
"message": "{}".format(message),
}
channel_layer = get_channel_layer()
print("user.id {}".format(self.user.id))
print("user.id {}".format(self.recipient.id))
async_to_sync(channel_layer.group_send)("{}".format(self.user.id), notification)
async_to_sync(channel_layer.group_send)(
"{}".format(self.recipient.id), notification
)