Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // Copyright 2022 The Gitea Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package feed
  5. import (
  6. "time"
  7. "code.gitea.io/gitea/models"
  8. repo_model "code.gitea.io/gitea/models/repo"
  9. "code.gitea.io/gitea/modules/context"
  10. "github.com/gorilla/feeds"
  11. )
  12. // ShowRepoFeed shows user activity on the repo as RSS / Atom feed
  13. func ShowRepoFeed(ctx *context.Context, repo *repo_model.Repository, formatType string) {
  14. actions, err := models.GetFeeds(ctx, models.GetFeedsOptions{
  15. RequestedRepo: repo,
  16. Actor: ctx.User,
  17. IncludePrivate: true,
  18. Date: ctx.FormString("date"),
  19. })
  20. if err != nil {
  21. ctx.ServerError("GetFeeds", err)
  22. return
  23. }
  24. feed := &feeds.Feed{
  25. Title: ctx.Tr("home.feed_of", repo.FullName()),
  26. Link: &feeds.Link{Href: repo.HTMLURL()},
  27. Description: repo.Description,
  28. Created: time.Now(),
  29. }
  30. feed.Items, err = feedActionsToFeedItems(ctx, actions)
  31. if err != nil {
  32. ctx.ServerError("convert feed", err)
  33. return
  34. }
  35. writeFeed(ctx, feed, formatType)
  36. }