From 1a469dc31b4dc65789441da8d2a329094dbd5361 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: Sat, 22 Nov 2025 20:31:06 -0500 Subject: [PATCH] update activity actions to return paths/links with a repo's group --- models/activities/action.go | 21 ++++++++++++++++++--- modules/templates/util_misc.go | 1 + 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/models/activities/action.go b/models/activities/action.go index 8e589eda88..cd968e8e98 100644 --- a/models/activities/action.go +++ b/models/activities/action.go @@ -267,6 +267,14 @@ func (a *Action) GetRepoName(ctx context.Context) string { return a.Repo.Name } +func (a *Action) GetRepoGroup(ctx context.Context) string { + _ = a.LoadRepo(ctx) + if a.Repo == nil || a.Repo.GroupID == 0 { + return "" + } + return strconv.FormatInt(a.Repo.GroupID, 10) +} + // ShortRepoName returns the name of the action repository // trimmed to max 33 chars. func (a *Action) ShortRepoName(ctx context.Context) string { @@ -275,19 +283,26 @@ func (a *Action) ShortRepoName(ctx context.Context) string { // GetRepoPath returns the virtual path to the action repository. func (a *Action) GetRepoPath(ctx context.Context) string { - return path.Join(a.GetRepoUserName(ctx), a.GetRepoName(ctx)) + return path.Join(a.GetRepoUserName(ctx), a.GetRepoGroup(ctx), a.GetRepoName(ctx)) } // ShortRepoPath returns the virtual path to the action repository // trimmed to max 20 + 1 + 33 chars. func (a *Action) ShortRepoPath(ctx context.Context) string { - return path.Join(a.ShortRepoUserName(ctx), a.ShortRepoName(ctx)) + return path.Join(a.ShortRepoUserName(ctx), a.makeGroupSegment(ctx), a.GetRepoGroup(ctx), a.ShortRepoName(ctx)) } // GetRepoLink returns relative link to action repository. func (a *Action) GetRepoLink(ctx context.Context) string { // path.Join will skip empty strings - return path.Join(setting.AppSubURL, "/", url.PathEscape(a.GetRepoUserName(ctx)), url.PathEscape(a.GetRepoName(ctx))) + return path.Join(setting.AppSubURL, "/", url.PathEscape(a.GetRepoUserName(ctx)), a.makeGroupSegment(ctx), a.GetRepoGroup(ctx), url.PathEscape(a.GetRepoName(ctx))) +} + +func (a *Action) makeGroupSegment(ctx context.Context) string { + if a.GetRepoGroup(ctx) != "" { + return "group" + } + return "" } // GetRepoAbsoluteLink returns the absolute link to action repository. diff --git a/modules/templates/util_misc.go b/modules/templates/util_misc.go index fb523fd53a..b2f7e564f7 100644 --- a/modules/templates/util_misc.go +++ b/modules/templates/util_misc.go @@ -63,6 +63,7 @@ type Actioner interface { GetActUserName(ctx context.Context) string GetRepoUserName(ctx context.Context) string GetRepoName(ctx context.Context) string + GetRepoGroup(ctx context.Context) string GetRepoPath(ctx context.Context) string GetRepoLink(ctx context.Context) string GetBranch() string