check unit types on action and notification creation
This commit is contained in:
parent
cab5121608
commit
a1fdf48d32
|
|
@ -120,6 +120,14 @@ func createOrUpdateIssueNotifications(e Engine, issue *Issue, notificationAuthor
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, watch := range watches {
|
for _, watch := range watches {
|
||||||
|
issue.Repo.Units = nil
|
||||||
|
if issue.IsPull && !issue.Repo.CheckUnitUser(watch.UserID, false, UnitTypePullRequests) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if !issue.IsPull && !issue.Repo.CheckUnitUser(watch.UserID, false, UnitTypeIssues) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
if err := notifyUser(watch.UserID); err != nil {
|
if err := notifyUser(watch.UserID); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -109,6 +109,23 @@ func notifyWatchers(e Engine, act *Action) error {
|
||||||
|
|
||||||
act.ID = 0
|
act.ID = 0
|
||||||
act.UserID = watches[i].UserID
|
act.UserID = watches[i].UserID
|
||||||
|
act.Repo.Units = nil
|
||||||
|
|
||||||
|
switch act.OpType {
|
||||||
|
case ActionCommitRepo, ActionPushTag, ActionDeleteTag, ActionDeleteBranch:
|
||||||
|
if !act.Repo.CheckUnitUser(act.UserID, false, UnitTypeCode) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
case ActionCreateIssue, ActionCommentIssue, ActionCloseIssue, ActionReopenIssue:
|
||||||
|
if !act.Repo.CheckUnitUser(act.UserID, false, UnitTypeIssues) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
case ActionCreatePullRequest, ActionMergePullRequest, ActionClosePullRequest, ActionReopenPullRequest:
|
||||||
|
if !act.Repo.CheckUnitUser(act.UserID, false, UnitTypePullRequests) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if _, err = e.InsertOne(act); err != nil {
|
if _, err = e.InsertOne(act); err != nil {
|
||||||
return fmt.Errorf("insert new action: %v", err)
|
return fmt.Errorf("insert new action: %v", err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user