Skip to content
This repository has been archived by the owner on May 20, 2024. It is now read-only.

Commit

Permalink
Only add new users to pending app conversations
Browse files Browse the repository at this point in the history
  • Loading branch information
nicksellen committed Jul 25, 2023
1 parent b0b127e commit cc200e1
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions karrot/applications/receivers.py
Expand Up @@ -39,14 +39,15 @@ def group_member_added(sender, instance, created, **kwargs):
group = instance.group
user = instance.user

for application in group.application_set.all():
conversation = Conversation.objects.get_for_target(application)
conversation.join(user)

# If users join the group by another way (e.g. invitations), withdraw their application
for application in group.application_set.filter(user=user, status=ApplicationStatus.PENDING.value):
application.withdraw()

# Joining all the existing pending application conversations
for application in group.application_set.filter(status=ApplicationStatus.PENDING.value):
conversation = Conversation.objects.get_for_target(application)
conversation.join(user)


@receiver(pre_delete, sender=GroupMembership)
def group_member_removed(sender, instance, **kwargs):
Expand Down

0 comments on commit cc200e1

Please sign in to comment.