From ea605cf48c45a03abd37ee32492bab60ad361e51 Mon Sep 17 00:00:00 2001 From: pablohashescobar Date: Mon, 3 Jul 2023 17:28:09 +0530 Subject: [PATCH] dev: update issue notifications --- apiserver/plane/bgtasks/issue_activites_task.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/apiserver/plane/bgtasks/issue_activites_task.py b/apiserver/plane/bgtasks/issue_activites_task.py index f14d8ddc8..78be2ae06 100644 --- a/apiserver/plane/bgtasks/issue_activites_task.py +++ b/apiserver/plane/bgtasks/issue_activites_task.py @@ -22,6 +22,7 @@ from plane.db.models import ( Module, IssueSubscriber, Notification, + IssueAssignee, ) from plane.api.serializers import IssueActivitySerializer, IssueFlatSerializer @@ -960,6 +961,12 @@ def issue_activity( actor = User.objects.get(pk=actor_id) project = Project.objects.get(pk=project_id) + # add the user to issue subscriber + try: + _ = IssueSubscriber.objects.create(issue_id=issue_id, subscriber=actor) + except Exception as e: + pass + ACTIVITY_MAPPER = { "issue.activity.created": create_issue_activity, "issue.activity.updated": update_issue_activity, @@ -1013,12 +1020,20 @@ def issue_activity( # Create Notifications bulk_notifications = [] - issue_subscribers = ( + issue_subscribers = list( IssueSubscriber.objects.filter(project=project, issue_id=issue_id) .exclude(subscriber_id=actor_id) .values_list("subscriber", flat=True) ) + issue_assignees = list( + IssueAssignee.objects.filter(project=project, issue_id=issue_id) + .exclude(assignee_id=actor_id) + .values_list("assignee", flat=True) + ) + + issue_subscribers = issue_subscribers + issue_assignees + issue = Issue.objects.get(project=project, pk=issue_id) for subscriber in issue_subscribers: for issue_activity in issue_activities_created: