diff options
Diffstat (limited to 'modules/repository/collaborator.go')
-rw-r--r-- | modules/repository/collaborator.go | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/modules/repository/collaborator.go b/modules/repository/collaborator.go index ebe14e3a4c..f71c58fbdf 100644 --- a/modules/repository/collaborator.go +++ b/modules/repository/collaborator.go @@ -16,6 +16,14 @@ import ( ) func AddCollaborator(ctx context.Context, repo *repo_model.Repository, u *user_model.User) error { + if err := repo.LoadOwner(ctx); err != nil { + return err + } + + if user_model.IsUserBlockedBy(ctx, u, repo.OwnerID) || user_model.IsUserBlockedBy(ctx, repo.Owner, u.ID) { + return user_model.ErrBlockedUser + } + return db.WithTx(ctx, func(ctx context.Context) error { has, err := db.Exist[repo_model.Collaboration](ctx, builder.Eq{ "repo_id": repo.ID, |