diff options
author | Győrvári Gábor <scr34m@gmail.com> | 2017-06-23 15:43:37 +0200 |
---|---|---|
committer | Lunny Xiao <xiaolunwen@gmail.com> | 2017-06-23 21:43:37 +0800 |
commit | f2afed3098973eb70ecf61c7e3bf7203bf3f592a (patch) | |
tree | 04b62b92a0efb24c26e711478010f9f46b7b973c /models/issue.go | |
parent | 09cb9991458dd56e2ac5df22b82ead563dbaa50f (diff) | |
download | gitea-f2afed3098973eb70ecf61c7e3bf7203bf3f592a.tar.gz gitea-f2afed3098973eb70ecf61c7e3bf7203bf3f592a.zip |
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
Diffstat (limited to 'models/issue.go')
-rw-r--r-- | models/issue.go | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/models/issue.go b/models/issue.go index 0989e3e195..e2e53b06fa 100644 --- a/models/issue.go +++ b/models/issue.go @@ -131,6 +131,22 @@ func (issue *Issue) loadPoster(e Engine) (err error) { return } +func (issue *Issue) loadAssignee(e Engine) (err error) { + if issue.Assignee == nil { + issue.Assignee, err = getUserByID(e, issue.AssigneeID) + if err != nil { + issue.AssigneeID = -1 + issue.Assignee = NewGhostUser() + if !IsErrUserNotExist(err) { + return fmt.Errorf("getUserByID.(assignee) [%d]: %v", issue.AssigneeID, err) + } + err = nil + return + } + } + return +} + func (issue *Issue) loadAttributes(e Engine) (err error) { if err = issue.loadRepo(e); err != nil { return @@ -151,11 +167,8 @@ func (issue *Issue) loadAttributes(e Engine) (err error) { } } - if issue.Assignee == nil && issue.AssigneeID > 0 { - issue.Assignee, err = getUserByID(e, issue.AssigneeID) - if err != nil { - return fmt.Errorf("getUserByID.(assignee) [%d]: %v", issue.AssigneeID, err) - } + if err = issue.loadAssignee(e); err != nil { + return } if issue.IsPull && issue.PullRequest == nil { |