diff --git a/pkg/models/listeners.go b/pkg/models/listeners.go index 98dbb14a4..2a9dc2fed 100644 --- a/pkg/models/listeners.go +++ b/pkg/models/listeners.go @@ -300,6 +300,7 @@ func (s *SendTaskAssignedNotification) Handle(msg *message.Message) (err error) Doer: event.Doer, Task: &task, Assignee: event.Assignee, + Target: subscriber.User, } err = notifications.Notify(subscriber.User, n) if err != nil { diff --git a/pkg/models/notifications.go b/pkg/models/notifications.go index 23aad69aa..bdbde921a 100644 --- a/pkg/models/notifications.go +++ b/pkg/models/notifications.go @@ -111,10 +111,18 @@ type TaskAssignedNotification struct { Doer *user.User `json:"doer"` Task *Task `json:"task"` Assignee *user.User `json:"assignee"` + Target *user.User `json:"-"` } // ToMail returns the mail notification for TaskAssignedNotification func (n *TaskAssignedNotification) ToMail() *notifications.Mail { + if n.Target.ID == n.Assignee.ID { + return notifications.NewMail(). + Subject("You have been assigned to "+n.Task.Title+"("+n.Task.GetFullIdentifier()+")"). + Line(n.Doer.GetName()+" has assigned you to "+n.Task.Title+"."). + Action("View Task", n.Task.GetFrontendURL()) + } + return notifications.NewMail(). Subject(n.Task.Title+"("+n.Task.GetFullIdentifier()+")"+" has been assigned to "+n.Assignee.GetName()). Line(n.Doer.GetName()+" has assigned this task to "+n.Assignee.GetName()+".").