-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable assignee e-mail notification #2003
Conversation
It seems it's difficult to add a test for it. |
I would like to close this PR and create new one, because the doer.ID check is missing so assignee receive self comments too. Or I could simply push the fix in this PR? |
Just to push. |
One more mistake, because assignee is not mandatory it maybe empty, issue.Assignee != nil check enough or issue.AssigneID != 0 or better to use GetUserByID()? |
models/issue_mail.go
Outdated
@@ -42,6 +42,11 @@ func mailIssueCommentToParticipants(issue *Issue, doer *User, comment *Comment, | |||
participants = append(participants, issue.Poster) | |||
} | |||
|
|||
// Assignee must receive any communications | |||
if issue.AssigneeID != doer.ID { | |||
participants = append(participants, issue.Assignee) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assignee maybe not load?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only when no assignee defined, so sanity check with GetUserByID() pushed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have not checked too deeply but if there is error in issue loadAttributes
, it would probably continue and leave issue.Assignee as nil. I would suggest adding additional check for && issue.Assignee != nil
to be on safe side just in case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check against nil added with latest commit.
models/issue_mail.go
Outdated
@@ -42,6 +42,15 @@ func mailIssueCommentToParticipants(issue *Issue, doer *User, comment *Comment, | |||
participants = append(participants, issue.Poster) | |||
} | |||
|
|||
// Assignee must receive any communications | |||
if issue.AssigneeID != doer.ID { | |||
to, err := GetUserByID(issue.AssigneeID) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if the assignee has been deleted? GetUserByID(issue.AssigneeID)
will return an error, but we would want to use a ghost user in this case.
Maybe we should add an Issue.loadAssignee(..)
method similar to Issue.loadPoster(..)
. This would also save us from loading the assignee if the assignee has already been loaded.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Commited the loadAssignee() method.
LGTM |
LGTM |
@ethantkoenig needs your approval |
Assignee right now doesn't get any notifications when new comment or when got a new issue.