summaryrefslogtreecommitdiffstats
path: root/routers/web/feed/repo.go
diff options
context:
space:
mode:
authorDaniel Baumann <daniel@debian.org>2024-10-18 20:33:49 +0200
committerDaniel Baumann <daniel@debian.org>2024-12-12 23:57:56 +0100
commite68b9d00a6e05b3a941f63ffb696f91e554ac5ec (patch)
tree97775d6c13b0f416af55314eb6a89ef792474615 /routers/web/feed/repo.go
parentInitial commit. (diff)
downloadforgejo-e68b9d00a6e05b3a941f63ffb696f91e554ac5ec.tar.xz
forgejo-e68b9d00a6e05b3a941f63ffb696f91e554ac5ec.zip
Adding upstream version 9.0.3.
Signed-off-by: Daniel Baumann <daniel@debian.org>
Diffstat (limited to 'routers/web/feed/repo.go')
-rw-r--r--routers/web/feed/repo.go44
1 files changed, 44 insertions, 0 deletions
diff --git a/routers/web/feed/repo.go b/routers/web/feed/repo.go
new file mode 100644
index 0000000..a0033c7
--- /dev/null
+++ b/routers/web/feed/repo.go
@@ -0,0 +1,44 @@
+// Copyright 2022 The Gitea Authors. All rights reserved.
+// SPDX-License-Identifier: MIT
+
+package feed
+
+import (
+ "time"
+
+ activities_model "code.gitea.io/gitea/models/activities"
+ repo_model "code.gitea.io/gitea/models/repo"
+ "code.gitea.io/gitea/services/context"
+
+ "github.com/gorilla/feeds"
+)
+
+// ShowRepoFeed shows user activity on the repo as RSS / Atom feed
+func ShowRepoFeed(ctx *context.Context, repo *repo_model.Repository, formatType string) {
+ actions, _, err := activities_model.GetFeeds(ctx, activities_model.GetFeedsOptions{
+ OnlyPerformedByActor: true,
+ RequestedRepo: repo,
+ Actor: ctx.Doer,
+ IncludePrivate: true,
+ Date: ctx.FormString("date"),
+ })
+ if err != nil {
+ ctx.ServerError("GetFeeds", err)
+ return
+ }
+
+ feed := &feeds.Feed{
+ Title: ctx.Locale.TrString("home.feed_of", repo.FullName()),
+ Link: &feeds.Link{Href: repo.HTMLURL()},
+ Description: repo.Description,
+ Created: time.Now(),
+ }
+
+ feed.Items, err = feedActionsToFeedItems(ctx, actions)
+ if err != nil {
+ ctx.ServerError("convert feed", err)
+ return
+ }
+
+ writeFeed(ctx, feed, formatType)
+}