Skip to content

Commit f2afed3

Browse files
scr34mlunny
authored andcommitted
Enable assignee e-mail notification (#2003)
* Enable assignee e-mail notification * Check assignee and doer to avoid self made comment notifications. * Assignee not always defined * New method to avoid error when assignee deleted * Assignee empty check
1 parent 09cb999 commit f2afed3

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

models/issue.go

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,22 @@ func (issue *Issue) loadPoster(e Engine) (err error) {
131131
return
132132
}
133133

134+
func (issue *Issue) loadAssignee(e Engine) (err error) {
135+
if issue.Assignee == nil {
136+
issue.Assignee, err = getUserByID(e, issue.AssigneeID)
137+
if err != nil {
138+
issue.AssigneeID = -1
139+
issue.Assignee = NewGhostUser()
140+
if !IsErrUserNotExist(err) {
141+
return fmt.Errorf("getUserByID.(assignee) [%d]: %v", issue.AssigneeID, err)
142+
}
143+
err = nil
144+
return
145+
}
146+
}
147+
return
148+
}
149+
134150
func (issue *Issue) loadAttributes(e Engine) (err error) {
135151
if err = issue.loadRepo(e); err != nil {
136152
return
@@ -151,11 +167,8 @@ func (issue *Issue) loadAttributes(e Engine) (err error) {
151167
}
152168
}
153169

154-
if issue.Assignee == nil && issue.AssigneeID > 0 {
155-
issue.Assignee, err = getUserByID(e, issue.AssigneeID)
156-
if err != nil {
157-
return fmt.Errorf("getUserByID.(assignee) [%d]: %v", issue.AssigneeID, err)
158-
}
170+
if err = issue.loadAssignee(e); err != nil {
171+
return
159172
}
160173

161174
if issue.IsPull && issue.PullRequest == nil {

models/issue_mail.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ func mailIssueCommentToParticipants(issue *Issue, doer *User, comment *Comment,
4242
participants = append(participants, issue.Poster)
4343
}
4444

45+
// Assignee must receive any communications
46+
if issue.Assignee != nil && issue.AssigneeID > 0 && issue.AssigneeID != doer.ID {
47+
participants = append(participants, issue.Assignee)
48+
}
49+
4550
tos := make([]string, 0, len(watchers)) // List of email addresses.
4651
names := make([]string, 0, len(watchers))
4752
for i := range watchers {

0 commit comments

Comments
 (0)