chore: restrict email notifications for removed users (#6100)
This commit is contained in:
parent
05d3e3ae45
commit
1420b7e7d3
3 changed files with 26 additions and 8 deletions
|
|
@ -62,6 +62,10 @@ class NotificationViewSet(BaseViewSet, BasePaginator):
|
|||
Notification.objects.filter(
|
||||
workspace__slug=slug, receiver_id=request.user.id
|
||||
)
|
||||
.filter(
|
||||
project__project_projectmember__member=request.user,
|
||||
project__project_projectmember__is_active=True,
|
||||
)
|
||||
.filter(entity_name="issue")
|
||||
.annotate(is_inbox_issue=Exists(intake_issue))
|
||||
.annotate(is_intake_issue=Exists(intake_issue))
|
||||
|
|
|
|||
|
|
@ -353,6 +353,7 @@ class ExportWorkspaceUserActivityEndpoint(BaseAPIView):
|
|||
workspace__slug=slug,
|
||||
created_at__date=request.data.get("date"),
|
||||
project__project_projectmember__member=request.user,
|
||||
project__project_projectmember__is_active=True,
|
||||
actor_id=user_id,
|
||||
).select_related("actor", "workspace", "issue", "project")[:10000]
|
||||
|
||||
|
|
|
|||
|
|
@ -16,8 +16,9 @@ from plane.db.models import (
|
|||
IssueComment,
|
||||
IssueActivity,
|
||||
UserNotificationPreference,
|
||||
ProjectMember
|
||||
ProjectMember,
|
||||
)
|
||||
from django.db.models import Subquery
|
||||
|
||||
# Third Party imports
|
||||
from celery import shared_task
|
||||
|
|
@ -95,7 +96,8 @@ def extract_mentions_as_subscribers(project_id, issue_id, mentions):
|
|||
).exists()
|
||||
and not Issue.objects.filter(
|
||||
project_id=project_id, pk=issue_id, created_by_id=mention_id
|
||||
).exists() and ProjectMember.objects.filter(
|
||||
).exists()
|
||||
and ProjectMember.objects.filter(
|
||||
project_id=project_id, member_id=mention_id, is_active=True
|
||||
).exists()
|
||||
):
|
||||
|
|
@ -242,14 +244,19 @@ def notifications(
|
|||
2. From the latest set of mentions, extract the users which are not a subscribers & make them subscribers
|
||||
"""
|
||||
|
||||
# get the list of active project members
|
||||
project_members = ProjectMember.objects.filter(
|
||||
project_id=project_id, is_active=True
|
||||
).values_list("member_id", flat=True)
|
||||
|
||||
# Get new mentions from the newer instance
|
||||
new_mentions = get_new_mentions(
|
||||
requested_instance=requested_data, current_instance=current_instance
|
||||
)
|
||||
new_mentions = list(ProjectMember.objects.filter(
|
||||
project_id=project_id, member_id__in=new_mentions, is_active=True
|
||||
).values_list("member_id", flat=True))
|
||||
new_mentions = [str(member_id) for member_id in new_mentions]
|
||||
|
||||
new_mentions = [
|
||||
str(mention) for mention in new_mentions if mention in new_mentions
|
||||
]
|
||||
removed_mention = get_removed_mentions(
|
||||
requested_instance=requested_data, current_instance=current_instance
|
||||
)
|
||||
|
|
@ -293,7 +300,11 @@ def notifications(
|
|||
|
||||
# ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- #
|
||||
issue_subscribers = list(
|
||||
IssueSubscriber.objects.filter(project_id=project_id, issue_id=issue_id, project__project_projectmember__is_active=True,)
|
||||
IssueSubscriber.objects.filter(
|
||||
project_id=project_id,
|
||||
issue_id=issue_id,
|
||||
subscriber__in=Subquery(project_members),
|
||||
)
|
||||
.exclude(
|
||||
subscriber_id__in=list(new_mentions + comment_mentions + [actor_id])
|
||||
)
|
||||
|
|
@ -314,7 +325,9 @@ def notifications(
|
|||
project = Project.objects.get(pk=project_id)
|
||||
|
||||
issue_assignees = IssueAssignee.objects.filter(
|
||||
issue_id=issue_id, project_id=project_id
|
||||
issue_id=issue_id,
|
||||
project_id=project_id,
|
||||
assignee__in=Subquery(project_members),
|
||||
).values_list("assignee", flat=True)
|
||||
|
||||
issue_subscribers = list(set(issue_subscribers) - {uuid.UUID(actor_id)})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue