diff --git a/pkg/i18n/lang/en.json b/pkg/i18n/lang/en.json index 91591b7e6..0645eda32 100644 --- a/pkg/i18n/lang/en.json +++ b/pkg/i18n/lang/en.json @@ -79,7 +79,9 @@ "subject_to_assignee": "You have been assigned to \"%[1]s\" (%[2]s)", "message_to_assignee": "%[1]s has assigned you to \"%[2]s\".", "subject_to_others": "\"%[1]s\" (%[2]s) has been assigned to %[3]s", - "message_to_others": "%[1]s has assigned this task to %[2]s." + "message_to_others": "%[1]s has assigned this task to %[2]s.", + "subject_to_others_self": "\"%[1]s\" (%[2]s) has been assigned by %[3]s to themselves", + "message_to_others_self": "%[1]s has assigned this task to themselves." }, "deleted": { "subject": "\"%[1]s\" (%[2]s) has been deleted", diff --git a/pkg/models/notifications.go b/pkg/models/notifications.go index bf7c17d9f..bf61df46a 100644 --- a/pkg/models/notifications.go +++ b/pkg/models/notifications.go @@ -142,6 +142,14 @@ func (n *TaskAssignedNotification) ToMail(lang string) *notifications.Mail { Action(i18n.T(lang, "notifications.common.actions.open_task"), n.Task.GetFrontendURL()) } + // Check if the doer assigned the task to themselves + if n.Doer.ID == n.Assignee.ID { + return notifications.NewMail(). + Subject(i18n.T(lang, "notifications.task.assigned.subject_to_others_self", n.Task.Title, n.Task.GetFullIdentifier(), n.Doer.GetName())). + Line(i18n.T(lang, "notifications.task.assigned.message_to_others_self", n.Doer.GetName())). + Action(i18n.T(lang, "notifications.common.actions.open_task"), n.Task.GetFrontendURL()) + } + return notifications.NewMail(). Subject(i18n.T(lang, "notifications.task.assigned.subject_to_others", n.Task.Title, n.Task.GetFullIdentifier(), n.Assignee.GetName())). Line(i18n.T(lang, "notifications.task.assigned.message_to_others", n.Doer.GetName(), n.Assignee.GetName())).