Skip to content

Commit

Permalink
[WEB-2776] fix: restrict notifications (#6081)
Browse files Browse the repository at this point in the history
* chore: restrict notifications

* chore: handled the issue filter duplicates

---------

Co-authored-by: gurusainath <gurusainath007@gmail.com>
  • Loading branch information
NarayanBavisetti and gurusainath authored Nov 22, 2024
1 parent 6ef6282 commit 42d6078
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
9 changes: 8 additions & 1 deletion apiserver/plane/bgtasks/notification_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
IssueComment,
IssueActivity,
UserNotificationPreference,
ProjectMember
)

# Third Party imports
Expand Down Expand Up @@ -94,6 +95,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(
project_id=project_id, member_id=mention_id, is_active=True
).exists()
):
project = Project.objects.get(pk=project_id)
Expand Down Expand Up @@ -243,6 +246,10 @@ def notifications(
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]
removed_mention = get_removed_mentions(
requested_instance=requested_data, current_instance=current_instance
)
Expand Down Expand Up @@ -286,7 +293,7 @@ def notifications(

# ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- #
issue_subscribers = list(
IssueSubscriber.objects.filter(project_id=project_id, issue_id=issue_id)
IssueSubscriber.objects.filter(project_id=project_id, issue_id=issue_id, project__project_projectmember__is_active=True,)
.exclude(
subscriber_id__in=list(new_mentions + comment_mentions + [actor_id])
)
Expand Down
1 change: 1 addition & 0 deletions apiserver/plane/utils/issue_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ def filter_labels(params, issue_filter, method, prefix=""):
and params.get("labels") != "null"
):
issue_filter[f"{prefix}labels__in"] = params.get("labels")
issue_filter[f"{prefix}label_issue__deleted_at__isnull"] = True
return issue_filter


Expand Down

0 comments on commit 42d6078

Please sign in to comment.