complete group notifications
- notify group members when a new member accepts an invitation - notify all group members when a member leaves or is removed - notify ex-member when they are removed
This commit is contained in:
@ -133,21 +133,27 @@ class GroupMemberInvitation(models.Model):
|
||||
with transaction.atomic():
|
||||
BookwyrmGroupMember.from_request(self)
|
||||
|
||||
# let the other members know about it
|
||||
model = apps.get_model("bookwyrm.Notification", require_ready=True)
|
||||
# tell the group owner
|
||||
model.objects.create(
|
||||
user=self.group.user,
|
||||
related_user=self.user,
|
||||
related_group=self.group,
|
||||
notification_type="ACCEPT",
|
||||
)
|
||||
|
||||
# let the other members know about it
|
||||
for membership in self.group.memberships.all():
|
||||
member = membership.user
|
||||
if member != self.user:
|
||||
if member != self.user and member != self.group.user:
|
||||
model.objects.create(
|
||||
user=member,
|
||||
related_user=self.user,
|
||||
related_group=self.group,
|
||||
notification_type="ACCEPT",
|
||||
notification_type="JOIN",
|
||||
)
|
||||
|
||||
def reject(self):
|
||||
"""generate a Reject for this membership request"""
|
||||
|
||||
self.delete()
|
||||
|
||||
# TODO: send notification
|
@ -7,7 +7,7 @@ from . import Boost, Favorite, ImportJob, Report, Status, User
|
||||
|
||||
NotificationType = models.TextChoices(
|
||||
"NotificationType",
|
||||
"FAVORITE REPLY MENTION TAG FOLLOW FOLLOW_REQUEST BOOST IMPORT ADD REPORT INVITE ACCEPT",
|
||||
"FAVORITE REPLY MENTION TAG FOLLOW FOLLOW_REQUEST BOOST IMPORT ADD REPORT INVITE ACCEPT JOIN LEAVE REMOVE",
|
||||
)
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user