summaryrefslogtreecommitdiffstats
path: root/models/repo_collaboration.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2022-06-12 23:51:54 +0800
committerGitHub <noreply@github.com>2022-06-12 23:51:54 +0800
commit110fc57cbcf293c19ed7017d8ea528b4bbbd7396 (patch)
treeb36eb2ee0e3f8417a35ad095e25880b778ded0ba /models/repo_collaboration.go
parenta9dc9b06e4a4106ec8315fe7b2922efa440ca199 (diff)
downloadgitea-110fc57cbcf293c19ed7017d8ea528b4bbbd7396.tar.gz
gitea-110fc57cbcf293c19ed7017d8ea528b4bbbd7396.zip
Move some code into models/git (#19879)
* Move access and repo permission to models/perm/access * fix test * Move some git related files into sub package models/git * Fix build * fix git test * move lfs to sub package * move more git related functions to models/git * Move functions sequence * Some improvements per @KN4CK3R and @delvh
Diffstat (limited to 'models/repo_collaboration.go')
-rw-r--r--models/repo_collaboration.go22
1 files changed, 0 insertions, 22 deletions
diff --git a/models/repo_collaboration.go b/models/repo_collaboration.go
index 8cbd836a42..7d43115b23 100644
--- a/models/repo_collaboration.go
+++ b/models/repo_collaboration.go
@@ -10,11 +10,9 @@ import (
"fmt"
"code.gitea.io/gitea/models/db"
- "code.gitea.io/gitea/models/organization"
"code.gitea.io/gitea/models/perm"
access_model "code.gitea.io/gitea/models/perm/access"
repo_model "code.gitea.io/gitea/models/repo"
- "code.gitea.io/gitea/models/unit"
user_model "code.gitea.io/gitea/models/user"
"xorm.io/builder"
@@ -120,23 +118,3 @@ func reconsiderWatches(ctx context.Context, repo *repo_model.Repository, uid int
// Remove all IssueWatches a user has subscribed to in the repository
return removeIssueWatchersByRepoID(ctx, uid, repo.ID)
}
-
-// IsOwnerMemberCollaborator checks if a provided user is the owner, a collaborator or a member of a team in a repository
-func IsOwnerMemberCollaborator(repo *repo_model.Repository, userID int64) (bool, error) {
- if repo.OwnerID == userID {
- return true, nil
- }
- teamMember, err := db.GetEngine(db.DefaultContext).Join("INNER", "team_repo", "team_repo.team_id = team_user.team_id").
- Join("INNER", "team_unit", "team_unit.team_id = team_user.team_id").
- Where("team_repo.repo_id = ?", repo.ID).
- And("team_unit.`type` = ?", unit.TypeCode).
- And("team_user.uid = ?", userID).Table("team_user").Exist(&organization.TeamUser{})
- if err != nil {
- return false, err
- }
- if teamMember {
- return true, nil
- }
-
- return db.GetEngine(db.DefaultContext).Get(&repo_model.Collaboration{RepoID: repo.ID, UserID: userID})
-}