@@ -15,7 +15,6 @@ import (
15
15
asymkey_model "code.gitea.io/gitea/models/asymkey"
16
16
"code.gitea.io/gitea/models/db"
17
17
repo_model "code.gitea.io/gitea/models/repo"
18
- "code.gitea.io/gitea/models/unit"
19
18
user_model "code.gitea.io/gitea/models/user"
20
19
"code.gitea.io/gitea/modules/setting"
21
20
"code.gitea.io/gitea/modules/structs"
@@ -30,109 +29,6 @@ func GetOrganizationCount(ctx context.Context, u *user_model.User) (int64, error
30
29
Count (new (OrgUser ))
31
30
}
32
31
33
- // GetRepositoryIDs returns repositories IDs where user owned and has unittypes
34
- // Caller shall check that units is not globally disabled
35
- func GetRepositoryIDs (u * user_model.User , units ... unit.Type ) ([]int64 , error ) {
36
- var ids []int64
37
-
38
- sess := db .GetEngine (db .DefaultContext ).Table ("repository" ).Cols ("repository.id" )
39
-
40
- if len (units ) > 0 {
41
- sess = sess .Join ("INNER" , "repo_unit" , "repository.id = repo_unit.repo_id" )
42
- sess = sess .In ("repo_unit.type" , units )
43
- }
44
-
45
- return ids , sess .Where ("owner_id = ?" , u .ID ).Find (& ids )
46
- }
47
-
48
- // GetActiveRepositoryIDs returns non-archived repositories IDs where user owned and has unittypes
49
- // Caller shall check that units is not globally disabled
50
- func GetActiveRepositoryIDs (u * user_model.User , units ... unit.Type ) ([]int64 , error ) {
51
- var ids []int64
52
-
53
- sess := db .GetEngine (db .DefaultContext ).Table ("repository" ).Cols ("repository.id" )
54
-
55
- if len (units ) > 0 {
56
- sess = sess .Join ("INNER" , "repo_unit" , "repository.id = repo_unit.repo_id" )
57
- sess = sess .In ("repo_unit.type" , units )
58
- }
59
-
60
- sess .Where (builder.Eq {"is_archived" : false })
61
-
62
- return ids , sess .Where ("owner_id = ?" , u .ID ).GroupBy ("repository.id" ).Find (& ids )
63
- }
64
-
65
- // GetOrgRepositoryIDs returns repositories IDs where user's team owned and has unittypes
66
- // Caller shall check that units is not globally disabled
67
- func GetOrgRepositoryIDs (u * user_model.User , units ... unit.Type ) ([]int64 , error ) {
68
- var ids []int64
69
-
70
- if err := db .GetEngine (db .DefaultContext ).Table ("repository" ).
71
- Cols ("repository.id" ).
72
- Join ("INNER" , "team_user" , "repository.owner_id = team_user.org_id" ).
73
- Join ("INNER" , "team_repo" , "(? != ? and repository.is_private != ?) OR (team_user.team_id = team_repo.team_id AND repository.id = team_repo.repo_id)" , true , u .IsRestricted , true ).
74
- Where ("team_user.uid = ?" , u .ID ).
75
- GroupBy ("repository.id" ).Find (& ids ); err != nil {
76
- return nil , err
77
- }
78
-
79
- if len (units ) > 0 {
80
- return FilterOutRepoIdsWithoutUnitAccess (u , ids , units ... )
81
- }
82
-
83
- return ids , nil
84
- }
85
-
86
- // GetActiveOrgRepositoryIDs returns non-archived repositories IDs where user's team owned and has unittypes
87
- // Caller shall check that units is not globally disabled
88
- func GetActiveOrgRepositoryIDs (u * user_model.User , units ... unit.Type ) ([]int64 , error ) {
89
- var ids []int64
90
-
91
- if err := db .GetEngine (db .DefaultContext ).Table ("repository" ).
92
- Cols ("repository.id" ).
93
- Join ("INNER" , "team_user" , "repository.owner_id = team_user.org_id" ).
94
- Join ("INNER" , "team_repo" , "(? != ? and repository.is_private != ?) OR (team_user.team_id = team_repo.team_id AND repository.id = team_repo.repo_id)" , true , u .IsRestricted , true ).
95
- Where ("team_user.uid = ?" , u .ID ).
96
- Where (builder.Eq {"is_archived" : false }).
97
- GroupBy ("repository.id" ).Find (& ids ); err != nil {
98
- return nil , err
99
- }
100
-
101
- if len (units ) > 0 {
102
- return FilterOutRepoIdsWithoutUnitAccess (u , ids , units ... )
103
- }
104
-
105
- return ids , nil
106
- }
107
-
108
- // GetAccessRepoIDs returns all repositories IDs where user's or user is a team member organizations
109
- // Caller shall check that units is not globally disabled
110
- func GetAccessRepoIDs (u * user_model.User , units ... unit.Type ) ([]int64 , error ) {
111
- ids , err := GetRepositoryIDs (u , units ... )
112
- if err != nil {
113
- return nil , err
114
- }
115
- ids2 , err := GetOrgRepositoryIDs (u , units ... )
116
- if err != nil {
117
- return nil , err
118
- }
119
- return append (ids , ids2 ... ), nil
120
- }
121
-
122
- // GetActiveAccessRepoIDs returns all non-archived repositories IDs where user's or user is a team member organizations
123
- // Caller shall check that units is not globally disabled
124
- func GetActiveAccessRepoIDs (u * user_model.User , units ... unit.Type ) ([]int64 , error ) {
125
- ids , err := GetActiveRepositoryIDs (u , units ... )
126
- if err != nil {
127
- return nil , err
128
- }
129
- ids2 , err := GetActiveOrgRepositoryIDs (u , units ... )
130
- if err != nil {
131
- return nil , err
132
- }
133
- return append (ids , ids2 ... ), nil
134
- }
135
-
136
32
// deleteBeans deletes all given beans, beans should contain delete conditions.
137
33
func deleteBeans (e db.Engine , beans ... interface {}) (err error ) {
138
34
for i := range beans {
0 commit comments