forked from github/plane
fix: uuid error when cycle and module updates (#1585)
This commit is contained in:
parent
34123681cf
commit
5e625ab132
@ -1028,21 +1028,26 @@ def issue_activity(
|
|||||||
actor = User.objects.get(pk=actor_id)
|
actor = User.objects.get(pk=actor_id)
|
||||||
project = Project.objects.get(pk=project_id)
|
project = Project.objects.get(pk=project_id)
|
||||||
|
|
||||||
|
if type not in [
|
||||||
|
"cycle.activity.created",
|
||||||
|
"cycle.activity.deleted",
|
||||||
|
"module.activity.created",
|
||||||
|
"module.activity.deleted",
|
||||||
|
]:
|
||||||
|
issue = Issue.objects.filter(pk=issue_id, project_id=project_id).first()
|
||||||
|
|
||||||
issue = Issue.objects.filter(pk=issue_id, project_id=project_id).first()
|
if issue is not None:
|
||||||
|
issue.updated_at = timezone.now()
|
||||||
|
issue.save(update_fields=["updated_at"])
|
||||||
|
|
||||||
if issue is not None:
|
if subscriber:
|
||||||
issue.updated_at = timezone.now()
|
# add the user to issue subscriber
|
||||||
issue.save(update_fields=["updated_at"])
|
try:
|
||||||
|
_ = IssueSubscriber.objects.get_or_create(
|
||||||
if subscriber:
|
issue_id=issue_id, subscriber=actor
|
||||||
# add the user to issue subscriber
|
)
|
||||||
try:
|
except Exception as e:
|
||||||
_ = IssueSubscriber.objects.get_or_create(
|
pass
|
||||||
issue_id=issue_id, subscriber=actor
|
|
||||||
)
|
|
||||||
except Exception as e:
|
|
||||||
pass
|
|
||||||
|
|
||||||
ACTIVITY_MAPPER = {
|
ACTIVITY_MAPPER = {
|
||||||
"issue.activity.created": create_issue_activity,
|
"issue.activity.created": create_issue_activity,
|
||||||
@ -1094,67 +1099,79 @@ def issue_activity(
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
capture_exception(e)
|
capture_exception(e)
|
||||||
|
|
||||||
# Create Notifications
|
if type not in [
|
||||||
bulk_notifications = []
|
"cycle.activity.created",
|
||||||
|
"cycle.activity.deleted",
|
||||||
|
"module.activity.created",
|
||||||
|
"module.activity.deleted",
|
||||||
|
]:
|
||||||
|
# Create Notifications
|
||||||
|
bulk_notifications = []
|
||||||
|
|
||||||
issue_subscribers = list(
|
issue_subscribers = list(
|
||||||
IssueSubscriber.objects.filter(project=project, issue_id=issue_id)
|
IssueSubscriber.objects.filter(project=project, issue_id=issue_id)
|
||||||
.exclude(subscriber_id=actor_id)
|
.exclude(subscriber_id=actor_id)
|
||||||
.values_list("subscriber", flat=True)
|
.values_list("subscriber", flat=True)
|
||||||
)
|
)
|
||||||
|
|
||||||
issue_assignees = list(
|
issue_assignees = list(
|
||||||
IssueAssignee.objects.filter(project=project, issue_id=issue_id)
|
IssueAssignee.objects.filter(project=project, issue_id=issue_id)
|
||||||
.exclude(assignee_id=actor_id)
|
.exclude(assignee_id=actor_id)
|
||||||
.values_list("assignee", flat=True)
|
.values_list("assignee", flat=True)
|
||||||
)
|
)
|
||||||
|
|
||||||
issue_subscribers = issue_subscribers + issue_assignees
|
issue_subscribers = issue_subscribers + issue_assignees
|
||||||
|
|
||||||
issue = Issue.objects.filter(pk=issue_id, project_id=project_id).first()
|
issue = Issue.objects.filter(pk=issue_id, project_id=project_id).first()
|
||||||
|
|
||||||
# Add bot filtering
|
# Add bot filtering
|
||||||
if issue is not None and issue.created_by_id is not None and not issue.created_by.is_bot:
|
if (
|
||||||
issue_subscribers = issue_subscribers + [issue.created_by_id]
|
issue is not None
|
||||||
|
and issue.created_by_id is not None
|
||||||
|
and not issue.created_by.is_bot
|
||||||
|
):
|
||||||
|
issue_subscribers = issue_subscribers + [issue.created_by_id]
|
||||||
|
|
||||||
for subscriber in issue_subscribers:
|
for subscriber in issue_subscribers:
|
||||||
for issue_activity in issue_activities_created:
|
for issue_activity in issue_activities_created:
|
||||||
bulk_notifications.append(
|
bulk_notifications.append(
|
||||||
Notification(
|
Notification(
|
||||||
workspace=project.workspace,
|
workspace=project.workspace,
|
||||||
sender="in_app:issue_activities",
|
sender="in_app:issue_activities",
|
||||||
triggered_by_id=actor_id,
|
triggered_by_id=actor_id,
|
||||||
receiver_id=subscriber,
|
receiver_id=subscriber,
|
||||||
entity_identifier=issue_id,
|
entity_identifier=issue_id,
|
||||||
entity_name="issue",
|
entity_name="issue",
|
||||||
project=project,
|
project=project,
|
||||||
title=issue_activity.comment,
|
title=issue_activity.comment,
|
||||||
data={
|
data={
|
||||||
"issue": {
|
"issue": {
|
||||||
"id": str(issue_id),
|
"id": str(issue_id),
|
||||||
"name": str(issue.name),
|
"name": str(issue.name),
|
||||||
"identifier": str(project.identifier),
|
"identifier": str(project.identifier),
|
||||||
"sequence_id": issue.sequence_id,
|
"sequence_id": issue.sequence_id,
|
||||||
"state_name": issue.state.name,
|
"state_name": issue.state.name,
|
||||||
"state_group": issue.state.group,
|
"state_group": issue.state.group,
|
||||||
|
},
|
||||||
|
"issue_activity": {
|
||||||
|
"id": str(issue_activity.id),
|
||||||
|
"verb": str(issue_activity.verb),
|
||||||
|
"field": str(issue_activity.field),
|
||||||
|
"actor": str(issue_activity.actor_id),
|
||||||
|
"new_value": str(issue_activity.new_value),
|
||||||
|
"old_value": str(issue_activity.old_value),
|
||||||
|
"issue_comment": str(
|
||||||
|
issue_activity.issue_comment.comment_stripped
|
||||||
|
if issue_activity.issue_comment is not None
|
||||||
|
else ""
|
||||||
|
),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
"issue_activity": {
|
)
|
||||||
"id": str(issue_activity.id),
|
|
||||||
"verb": str(issue_activity.verb),
|
|
||||||
"field": str(issue_activity.field),
|
|
||||||
"actor": str(issue_activity.actor_id),
|
|
||||||
"new_value": str(issue_activity.new_value),
|
|
||||||
"old_value": str(issue_activity.old_value),
|
|
||||||
"issue_comment": str(
|
|
||||||
issue_activity.issue_comment.comment_stripped if issue_activity.issue_comment is not None else ""
|
|
||||||
),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
)
|
)
|
||||||
)
|
|
||||||
|
|
||||||
# Bulk create notifications
|
# Bulk create notifications
|
||||||
Notification.objects.bulk_create(bulk_notifications, batch_size=100)
|
Notification.objects.bulk_create(bulk_notifications, batch_size=100)
|
||||||
|
|
||||||
return
|
return
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
Loading…
Reference in New Issue
Block a user