diff options
author | 赵智超 <1012112796@qq.com> | 2020-04-07 00:33:34 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-06 19:33:34 +0300 |
commit | ef89e75d0eb232e98ca7a7ef278b8681c7f4fe50 (patch) | |
tree | c7b17df4d92441f2ce8420dbf8aa79aee47a3c13 /models/notification.go | |
parent | 88c14326b1a5d9216d5f6905dcbe44e43efdb5b3 (diff) | |
download | gitea-ef89e75d0eb232e98ca7a7ef278b8681c7f4fe50.tar.gz gitea-ef89e75d0eb232e98ca7a7ef278b8681c7f4fe50.zip |
add request review from specific reviewers feature in pull request (#10756)
* add request review feature in pull request
add a way to notify specific reviewers to review like github , by add or delet a special type
review . The acton is is similar to Assign , so many code reuse the function and items of
Assignee, but the meaning and result is different.
The Permission style is is similar to github, that only writer can add a review request from Reviewers,
but the poster can recall and remove a review request after a reviwer has revied even if he don't have
Write Premission. only manager , the poster and reviewer of a request review can remove it.
The reviewers can be requested to review contain all readers for private repo , for public, contain
all writers and watchers.
The offical Review Request will block merge if Reject can block it.
an other change: add ui otify for Assignees.
Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
Co-authored-by: Lauris BH <lauris@nix.lv>
Signed-off-by: a1012112796 <1012112796@qq.com>
* new change
* add placeholder string
* do some changes follow #10238 to add review requests num on lists also
change icon for review requests to eye
Co-authored-by: Lauris BH <lauris@nix.lv>
Diffstat (limited to 'models/notification.go')
-rw-r--r-- | models/notification.go | 77 |
1 files changed, 43 insertions, 34 deletions
diff --git a/models/notification.go b/models/notification.go index 0cee8616ca..8d74ac129f 100644 --- a/models/notification.go +++ b/models/notification.go @@ -118,64 +118,73 @@ func GetNotifications(opts FindNotificationOptions) (NotificationList, error) { // CreateOrUpdateIssueNotifications creates an issue notification // for each watcher, or updates it if already exists -func CreateOrUpdateIssueNotifications(issueID, commentID int64, notificationAuthorID int64) error { +// receiverID > 0 just send to reciver, else send to all watcher +func CreateOrUpdateIssueNotifications(issueID, commentID, notificationAuthorID, receiverID int64) error { sess := x.NewSession() defer sess.Close() if err := sess.Begin(); err != nil { return err } - if err := createOrUpdateIssueNotifications(sess, issueID, commentID, notificationAuthorID); err != nil { + if err := createOrUpdateIssueNotifications(sess, issueID, commentID, notificationAuthorID, receiverID); err != nil { return err } return sess.Commit() } -func createOrUpdateIssueNotifications(e Engine, issueID, commentID int64, notificationAuthorID int64) error { +func createOrUpdateIssueNotifications(e Engine, issueID, commentID, notificationAuthorID, receiverID int64) error { // init - toNotify := make(map[int64]struct{}, 32) + var toNotify map[int64]struct{} notifications, err := getNotificationsByIssueID(e, issueID) + if err != nil { return err } + issue, err := getIssueByID(e, issueID) if err != nil { return err } - issueWatches, err := getIssueWatchersIDs(e, issueID, true) - if err != nil { - return err - } - for _, id := range issueWatches { - toNotify[id] = struct{}{} - } + if receiverID > 0 { + toNotify = make(map[int64]struct{}, 1) + toNotify[receiverID] = struct{}{} + } else { + toNotify = make(map[int64]struct{}, 32) + issueWatches, err := getIssueWatchersIDs(e, issueID, true) + if err != nil { + return err + } + for _, id := range issueWatches { + toNotify[id] = struct{}{} + } - repoWatches, err := getRepoWatchersIDs(e, issue.RepoID) - if err != nil { - return err - } - for _, id := range repoWatches { - toNotify[id] = struct{}{} - } - issueParticipants, err := issue.getParticipantIDsByIssue(e) - if err != nil { - return err - } - for _, id := range issueParticipants { - toNotify[id] = struct{}{} - } + repoWatches, err := getRepoWatchersIDs(e, issue.RepoID) + if err != nil { + return err + } + for _, id := range repoWatches { + toNotify[id] = struct{}{} + } + issueParticipants, err := issue.getParticipantIDsByIssue(e) + if err != nil { + return err + } + for _, id := range issueParticipants { + toNotify[id] = struct{}{} + } - // dont notify user who cause notification - delete(toNotify, notificationAuthorID) - // explicit unwatch on issue - issueUnWatches, err := getIssueWatchersIDs(e, issueID, false) - if err != nil { - return err - } - for _, id := range issueUnWatches { - delete(toNotify, id) + // dont notify user who cause notification + delete(toNotify, notificationAuthorID) + // explicit unwatch on issue + issueUnWatches, err := getIssueWatchersIDs(e, issueID, false) + if err != nil { + return err + } + for _, id := range issueUnWatches { + delete(toNotify, id) + } } err = issue.loadRepo(e) |