aboutsummaryrefslogtreecommitdiffstats
path: root/services/user
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2024-11-27 13:12:26 -0800
committerGitHub <noreply@github.com>2024-11-27 21:12:26 +0000
commitf62f68cbdda07ae6933b4804bc757f35dc92d134 (patch)
tree6709319ec99caa6b22ed7d409f77ad17323f7808 /services/user
parent5a50b271e71b5e8bb7bdef149e07dcd2b0db3e3a (diff)
downloadgitea-f62f68cbdda07ae6933b4804bc757f35dc92d134.tar.gz
gitea-f62f68cbdda07ae6933b4804bc757f35dc92d134.zip
Move team related functions to service layer (#32537)
There are still some functions under `models` after last big refactor about `models`. This change will move all team related functions to service layer with no code change.
Diffstat (limited to 'services/user')
-rw-r--r--services/user/user.go2
-rw-r--r--services/user/user_test.go3
2 files changed, 3 insertions, 2 deletions
diff --git a/services/user/user.go b/services/user/user.go
index 7855dbb78b..7bde642412 100644
--- a/services/user/user.go
+++ b/services/user/user.go
@@ -188,7 +188,7 @@ func DeleteUser(ctx context.Context, u *user_model.User, purge bool) error {
break
}
for _, org := range orgs {
- if err := models.RemoveOrgUser(ctx, org, u); err != nil {
+ if err := org_service.RemoveOrgUser(ctx, org, u); err != nil {
if organization.IsErrLastOrgOwner(err) {
err = org_service.DeleteOrganization(ctx, org, true)
if err != nil {
diff --git a/services/user/user_test.go b/services/user/user_test.go
index efcbc669c8..c668b005c5 100644
--- a/services/user/user_test.go
+++ b/services/user/user_test.go
@@ -18,6 +18,7 @@ import (
user_model "code.gitea.io/gitea/models/user"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/timeutil"
+ org_service "code.gitea.io/gitea/services/org"
"github.com/stretchr/testify/assert"
)
@@ -44,7 +45,7 @@ func TestDeleteUser(t *testing.T) {
assert.NoError(t, db.GetEngine(db.DefaultContext).Find(&orgUsers, &organization.OrgUser{UID: userID}))
for _, orgUser := range orgUsers {
org := unittest.AssertExistsAndLoadBean(t, &organization.Organization{ID: orgUser.OrgID})
- if err := models.RemoveOrgUser(db.DefaultContext, org, user); err != nil {
+ if err := org_service.RemoveOrgUser(db.DefaultContext, org, user); err != nil {
assert.True(t, organization.IsErrLastOrgOwner(err))
return
}