0
0
mirror of https://github.com/go-gitea/gitea.git synced 2026-05-09 22:51:50 +02:00

add function to find teams a user is part of within a group

This commit is contained in:
☙◦ The Tablet ❀ GamerGirlandCo ◦❧ 2025-11-30 15:43:17 -05:00
parent 09f0464384
commit 83d982cc38
No known key found for this signature in database
GPG Key ID: 924A5F6AF051E87C

View File

@ -59,7 +59,7 @@ func HasTeamGroup(ctx context.Context, orgID, teamID, groupID int64) bool {
// AddTeamGroup adds a group to a team
func AddTeamGroup(ctx context.Context, orgID, teamID, groupID int64, access perm.AccessMode, canCreateIn bool) error {
if access <= perm.AccessModeWrite {
if access < perm.AccessModeWrite {
canCreateIn = false
}
_, err := db.GetEngine(ctx).Insert(&RepoGroupTeam{
@ -113,6 +113,15 @@ func FindGroupTeams(ctx context.Context, groupID int64) (gteams []*RepoGroupTeam
Find(&gteams)
}
func FindUserGroupTeams(ctx context.Context, groupID int64, userID int64) (gteams []*RepoGroupTeam, err error) {
return gteams, db.GetEngine(ctx).
Where("group_id=?", groupID).
And("team_user.uid = ?", userID).
Table("repo_group_team").
Join("INNER", "team_user", "team_user.team_id = repo_group_team.team_id").
Find(&gteams)
}
func FindGroupTeamByTeamID(ctx context.Context, groupID, teamID int64) (gteam *RepoGroupTeam, err error) {
gteam = new(RepoGroupTeam)
has, err := db.GetEngine(ctx).