2022-03-13 12:40:47 -04:00
|
|
|
// Copyright 2022 The Gitea Authors. All rights reserved.
|
2022-11-27 13:20:29 -05:00
|
|
|
// SPDX-License-Identifier: MIT
|
2022-03-13 12:40:47 -04:00
|
|
|
|
|
|
|
package feed
|
|
|
|
|
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
|
2022-08-24 22:31:57 -04:00
|
|
|
activities_model "code.gitea.io/gitea/models/activities"
|
2022-03-13 12:40:47 -04:00
|
|
|
repo_model "code.gitea.io/gitea/models/repo"
|
2024-02-27 02:12:22 -05:00
|
|
|
"code.gitea.io/gitea/services/context"
|
2024-11-29 12:53:49 -05:00
|
|
|
feed_service "code.gitea.io/gitea/services/feed"
|
2022-03-13 12:40:47 -04:00
|
|
|
|
|
|
|
"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) {
|
2024-11-29 12:53:49 -05:00
|
|
|
actions, _, err := feed_service.GetFeeds(ctx, activities_model.GetFeedsOptions{
|
2022-03-13 12:40:47 -04:00
|
|
|
RequestedRepo: repo,
|
2022-03-22 03:03:22 -04:00
|
|
|
Actor: ctx.Doer,
|
2022-03-13 12:40:47 -04:00
|
|
|
IncludePrivate: true,
|
|
|
|
Date: ctx.FormString("date"),
|
|
|
|
})
|
|
|
|
if err != nil {
|
|
|
|
ctx.ServerError("GetFeeds", err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
feed := &feeds.Feed{
|
2024-02-14 16:48:45 -05:00
|
|
|
Title: ctx.Locale.TrString("home.feed_of", repo.FullName()),
|
2022-03-13 12:40:47 -04:00
|
|
|
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)
|
|
|
|
}
|