summaryrefslogtreecommitdiffstats
path: root/models/org_team.go
diff options
context:
space:
mode:
author6543 <6543@obermui.de>2020-04-07 23:52:01 +0200
committerGitHub <noreply@github.com>2020-04-07 22:52:01 +0100
commit71979d9663d8e43b772c37f2a79af5b8911df661 (patch)
treebfdd683d60759f9f274144fea1265537d1ea396c /models/org_team.go
parentd00ebf445bac3ee70616032e3fc89781cac3000c (diff)
downloadgitea-71979d9663d8e43b772c37f2a79af5b8911df661.tar.gz
gitea-71979d9663d8e43b772c37f2a79af5b8911df661.zip
Automatically remove Watches, Assignments, etc if user loses access due to being removed as collaborator or from a team (#10997)
* remove a user from being assigned to any issue/PR if (s)he is removed as a collaborator * fix gender specific comment * do not remove users that still have access to the repo if they are a member of a team that can access the repo * add context to errors * updates * incorporate review fixes * Update models/repo_collaboration.go Co-Authored-By: 6543 <6543@obermui.de> * Update models/repo_collaboration.go Co-Authored-By: 6543 <6543@obermui.de> * Fix Rebase Relict * Fix & Impruve * use xorm builder * all in one session * generalize reconsiderIssueAssignees * Only Unwatch if have no access anymore * prepare for reuse * Same things if remove User from Team * fix lint * let mysql take time to react * add description * CI.restart() * CI.restart() Co-authored-by: Lanre Adelowo <yo@lanre.wtf> Co-authored-by: techknowlogick <matti@mdranta.net> Co-authored-by: Lauris BH <lauris@nix.lv>
Diffstat (limited to 'models/org_team.go')
-rw-r--r--models/org_team.go13
1 files changed, 3 insertions, 10 deletions
diff --git a/models/org_team.go b/models/org_team.go
index 82c27b2c06..a3f1eb92a2 100644
--- a/models/org_team.go
+++ b/models/org_team.go
@@ -917,19 +917,12 @@ func removeTeamMember(e *xorm.Session, team *Team, userID int64) error {
}
// Remove watches from now unaccessible
- has, err := hasAccess(e, userID, repo)
- if err != nil {
+ if err := repo.reconsiderWatches(e, userID); err != nil {
return err
- } else if has {
- continue
}
- if err = watchRepo(e, userID, repo.ID, false); err != nil {
- return err
- }
-
- // Remove all IssueWatches a user has subscribed to in the repositories
- if err := removeIssueWatchersByRepoID(e, userID, repo.ID); err != nil {
+ // Remove issue assignments from now unaccessible
+ if err := repo.reconsiderIssueAssignees(e, userID); err != nil {
return err
}
}