mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-05-14 05:52:43 +00:00
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>
This commit is contained in:
parent
88c14326b1
commit
ef89e75d0e
24 changed files with 714 additions and 67 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue