From 8713c235e9ca34891f5f3607fa62f2052f3ba8da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=98=99=E2=97=A6=20The=20Tablet=20=E2=9D=80=20GamerGirla?= =?UTF-8?q?ndCo=20=E2=97=A6=E2=9D=A7?= Date: Sun, 30 Nov 2025 15:43:17 -0500 Subject: [PATCH] add function to find teams a user is part of within a group --- models/group/group_team.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/models/group/group_team.go b/models/group/group_team.go index 102e567b3b..1e9804f2cb 100644 --- a/models/group/group_team.go +++ b/models/group/group_team.go @@ -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(>eams) } +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(>eams) +} + func FindGroupTeamByTeamID(ctx context.Context, groupID, teamID int64) (gteam *RepoGroupTeam, err error) { gteam = new(RepoGroupTeam) has, err := db.GetEngine(ctx).