diff options
author | David Svantesson <davidsvantesson@gmail.com> | 2019-10-25 16:46:37 +0200 |
---|---|---|
committer | Lunny Xiao <xiaolunwen@gmail.com> | 2019-10-25 22:46:37 +0800 |
commit | 6aa3f8bc29cb1ed3a1b165cbf526079a751c8c71 (patch) | |
tree | d18aafe7855f9d21fb0d8d7104e7ac7b4aba72b2 /models/issue_user.go | |
parent | c34e58fc008d53a5ec92cadadab2b13fb4e0ae94 (diff) | |
download | gitea-6aa3f8bc29cb1ed3a1b165cbf526079a751c8c71.tar.gz gitea-6aa3f8bc29cb1ed3a1b165cbf526079a751c8c71.zip |
Mail assignee when issue/pull request is assigned (#8546)
* Send email to assigned user
* Only send mail if enabled
* Mail also when assigned through API
* Need to refactor functions from models to issue service
* Refer to issue index rather than ID
* Disable email notifications completly at initalization if global disable
* Check of user enbled mail shall be in mail notification function only
* Initialize notifications from routers init function.
* Use the assigned comment when sending assigned mail
* Refactor so that assignees always added as separate step when new issue/pr.
* Check error from AddAssignees
* Check if user can be assiged to issue or pull request
* Missing return
* Refactor of CanBeAssigned check.
CanBeAssigned shall have same check as UI.
* Clarify function names (toggle rather than update/change), and clean up.
* Fix review comments.
* Flash error if assignees was not added when creating issue/pr
* Generate error if assignee users doesn't exist
Diffstat (limited to 'models/issue_user.go')
-rw-r--r-- | models/issue_user.go | 38 |
1 files changed, 0 insertions, 38 deletions
diff --git a/models/issue_user.go b/models/issue_user.go index 6974a4d3cc..67a118fe57 100644 --- a/models/issue_user.go +++ b/models/issue_user.go @@ -6,8 +6,6 @@ package models import ( "fmt" - - "xorm.io/xorm" ) // IssueUser represents an issue-user relation. @@ -51,42 +49,6 @@ func newIssueUsers(e Engine, repo *Repository, issue *Issue) error { return nil } -func updateIssueAssignee(e *xorm.Session, issue *Issue, assigneeID int64) (removed bool, err error) { - - // Check if the user exists - assignee, err := getUserByID(e, assigneeID) - if err != nil { - return false, err - } - - // Check if the submitted user is already assigne, if yes delete him otherwise add him - var i int - for i = 0; i < len(issue.Assignees); i++ { - if issue.Assignees[i].ID == assigneeID { - break - } - } - - assigneeIn := IssueAssignees{AssigneeID: assigneeID, IssueID: issue.ID} - - toBeDeleted := i < len(issue.Assignees) - if toBeDeleted { - issue.Assignees = append(issue.Assignees[:i], issue.Assignees[i:]...) - _, err = e.Delete(assigneeIn) - if err != nil { - return toBeDeleted, err - } - } else { - issue.Assignees = append(issue.Assignees, assignee) - _, err = e.Insert(assigneeIn) - if err != nil { - return toBeDeleted, err - } - } - - return toBeDeleted, nil -} - // UpdateIssueUserByRead updates issue-user relation for reading. func UpdateIssueUserByRead(uid, issueID int64) error { _, err := x.Exec("UPDATE `issue_user` SET is_read=? WHERE uid=? AND issue_id=?", true, uid, issueID) |