Skip to content

Commit

Permalink
feat: separate get notification group name logic from base_notification
Browse files Browse the repository at this point in the history
  • Loading branch information
helllllllder committed Oct 25, 2024
1 parent b1faad0 commit 80ee4f3
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions chats/apps/rooms/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,15 +224,18 @@ def send_to_queue(self):
self.user = None
self.save()

def base_notification(self, content, action):
group_name = f"queue_{self.queue.pk}"
def get_notification_group(self):
if self.user:
permission = self.get_permission(self.user)
group_name = (
group_name if permission is None else f"permission_{permission.pk}"
)
if permission is not None:
return f"permission_{permission.pk}"
self.send_to_queue()

return f"queue_{self.queue.pk}"

def base_notification(self, content, action):
group_name = self.get_notification_group()

send_channels_group(
group_name=group_name,
call_type="notify",
Expand Down

0 comments on commit 80ee4f3

Please sign in to comment.