diff options
author | David Svantesson <davidsvantesson@gmail.com> | 2019-10-15 02:55:21 +0200 |
---|---|---|
committer | zeripath <art27@cantab.net> | 2019-10-15 01:55:21 +0100 |
commit | 8ad26976114c4fed6269a40e52632d065167bd20 (patch) | |
tree | b6c13ca7d7390ce8fd28354287c3b0b4ef3cb291 /models/repo_collaboration.go | |
parent | 733c898a907b23fa9e0c1bf108be5c5d9f9f7eb0 (diff) | |
download | gitea-8ad26976114c4fed6269a40e52632d065167bd20.tar.gz gitea-8ad26976114c4fed6269a40e52632d065167bd20.zip |
Recalculate repository access only for specific user (#8481)
* Recalculate repository access only for specific user
Signed-off-by: David Svantesson <davidsvantesson@gmail.com>
* Handle user repositories as well, and only add access if minimum mode
* Need to get repo owner to check if organization
Diffstat (limited to 'models/repo_collaboration.go')
-rw-r--r-- | models/repo_collaboration.go | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/models/repo_collaboration.go b/models/repo_collaboration.go index 40ddf6a28c..3d6447c196 100644 --- a/models/repo_collaboration.go +++ b/models/repo_collaboration.go @@ -41,12 +41,7 @@ func (repo *Repository) AddCollaborator(u *User) error { return err } - if repo.Owner.IsOrganization() { - err = repo.recalculateTeamAccesses(sess, 0) - } else { - err = repo.recalculateAccesses(sess) - } - if err != nil { + if err = repo.recalculateUserAccess(sess, u.ID); err != nil { return fmt.Errorf("recalculateAccesses 'team=%v': %v", repo.Owner.IsOrganization(), err) } @@ -89,6 +84,18 @@ func (repo *Repository) GetCollaborators() ([]*Collaborator, error) { return repo.getCollaborators(x) } +func (repo *Repository) getCollaboration(e Engine, uid int64) (*Collaboration, error) { + collaboration := &Collaboration{ + RepoID: repo.ID, + UserID: uid, + } + has, err := e.Get(collaboration) + if !has { + collaboration = nil + } + return collaboration, err +} + func (repo *Repository) isCollaborator(e Engine, userID int64) (bool, error) { return e.Get(&Collaboration{RepoID: repo.ID, UserID: userID}) } |