aboutsummaryrefslogtreecommitdiffstats
path: root/models/repo_collaboration.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2022-08-25 10:31:57 +0800
committerGitHub <noreply@github.com>2022-08-25 10:31:57 +0800
commit1d8543e7db58d7c4973758e47f005c4d8bd7d7a3 (patch)
treeb60c99e2dfd69ccb998f8a0829d98d7cadcf0d6b /models/repo_collaboration.go
parent4a4bfafa238bf48851f8c11fa3701bd42b912475 (diff)
downloadgitea-1d8543e7db58d7c4973758e47f005c4d8bd7d7a3.tar.gz
gitea-1d8543e7db58d7c4973758e47f005c4d8bd7d7a3.zip
Move some files into models' sub packages (#20262)
* Move some files into models' sub packages * Move functions * merge main branch * Fix check * fix check * Fix some tests * Fix lint * Fix lint * Revert lint changes * Fix error comments * Fix lint Co-authored-by: 6543 <6543@obermui.de>
Diffstat (limited to 'models/repo_collaboration.go')
-rw-r--r--models/repo_collaboration.go37
1 files changed, 0 insertions, 37 deletions
diff --git a/models/repo_collaboration.go b/models/repo_collaboration.go
index c8866421bd..05df2f29aa 100644
--- a/models/repo_collaboration.go
+++ b/models/repo_collaboration.go
@@ -11,7 +11,6 @@ import (
"code.gitea.io/gitea/models/db"
issues_model "code.gitea.io/gitea/models/issues"
- "code.gitea.io/gitea/models/perm"
access_model "code.gitea.io/gitea/models/perm/access"
repo_model "code.gitea.io/gitea/models/repo"
user_model "code.gitea.io/gitea/models/user"
@@ -19,42 +18,6 @@ import (
"xorm.io/builder"
)
-func addCollaborator(ctx context.Context, repo *repo_model.Repository, u *user_model.User) error {
- collaboration := &repo_model.Collaboration{
- RepoID: repo.ID,
- UserID: u.ID,
- }
-
- has, err := db.GetByBean(ctx, collaboration)
- if err != nil {
- return err
- } else if has {
- return nil
- }
- collaboration.Mode = perm.AccessModeWrite
-
- if err = db.Insert(ctx, collaboration); err != nil {
- return err
- }
-
- return access_model.RecalculateUserAccess(ctx, repo, u.ID)
-}
-
-// AddCollaborator adds new collaboration to a repository with default access mode.
-func AddCollaborator(repo *repo_model.Repository, u *user_model.User) error {
- ctx, committer, err := db.TxContext()
- if err != nil {
- return err
- }
- defer committer.Close()
-
- if err := addCollaborator(ctx, repo, u); err != nil {
- return err
- }
-
- return committer.Commit()
-}
-
// DeleteCollaboration removes collaboration relation between the user and repository.
func DeleteCollaboration(repo *repo_model.Repository, uid int64) (err error) {
collaboration := &repo_model.Collaboration{