loading up the forgejo repo on tangled to test page performance
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge pull request 'fix: don't show truncated comments in RSS/Atom feeds' (#5653) from gusted/forgejo-truncated-comment-rss into forgejo

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/5653
Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org>

+52
+12
routers/web/feed/convert.go
··· 13 13 "strings" 14 14 15 15 activities_model "code.gitea.io/gitea/models/activities" 16 + issues_model "code.gitea.io/gitea/models/issues" 16 17 repo_model "code.gitea.io/gitea/models/repo" 18 + "code.gitea.io/gitea/modules/log" 17 19 "code.gitea.io/gitea/modules/markup" 18 20 "code.gitea.io/gitea/modules/markup/markdown" 19 21 "code.gitea.io/gitea/modules/setting" ··· 232 234 case activities_model.ActionCommentIssue, activities_model.ActionApprovePullRequest, activities_model.ActionRejectPullRequest, activities_model.ActionCommentPull: 233 235 desc = act.GetIssueTitle(ctx) 234 236 comment := act.GetIssueInfos()[1] 237 + if strings.HasSuffix(comment, "…") { 238 + // Comment was truncated get the full content from the database. 239 + // This truncation is done in `NotifyCreateIssueComment`. 240 + commentModel, err := issues_model.GetCommentByID(ctx, act.CommentID) 241 + if err != nil { 242 + log.Error("Couldn't get comment[%d] for RSS feed: %v", act.CommentID, err) 243 + } else { 244 + comment = commentModel.Content 245 + } 246 + } 235 247 if len(comment) != 0 { 236 248 desc += "\n\n" + string(renderMarkdown(ctx, act, comment)) 237 249 }
+23
tests/integration/api_feed_user_test.go
··· 16 16 ) 17 17 18 18 func TestFeed(t *testing.T) { 19 + defer tests.AddFixtures("tests/integration/fixtures/TestFeed/")() 19 20 defer tests.PrepareTestEnv(t)() 20 21 21 22 t.Run("User", func(t *testing.T) { ··· 42 43 43 44 t.Run("Repo", func(t *testing.T) { 44 45 t.Run("Normal", func(t *testing.T) { 46 + t.Run("Atom", func(t *testing.T) { 47 + defer tests.PrintCurrentTest(t)() 48 + 49 + req := NewRequest(t, "GET", "/user2/repo1.atom") 50 + resp := MakeRequest(t, req, http.StatusOK) 51 + 52 + data := resp.Body.String() 53 + assert.Contains(t, data, `<feed xmlns="http://www.w3.org/2005/Atom"`) 54 + assert.Contains(t, data, "This is a very long text, so lets scream together: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") 55 + }) 56 + t.Run("RSS", func(t *testing.T) { 57 + defer tests.PrintCurrentTest(t)() 58 + 59 + req := NewRequest(t, "GET", "/user2/repo1.rss") 60 + resp := MakeRequest(t, req, http.StatusOK) 61 + 62 + data := resp.Body.String() 63 + assert.Contains(t, data, `<rss version="2.0"`) 64 + assert.Contains(t, data, "This is a very long text, so lets scream together: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") 65 + }) 66 + }) 67 + t.Run("Branch", func(t *testing.T) { 45 68 t.Run("Atom", func(t *testing.T) { 46 69 defer tests.PrintCurrentTest(t)() 47 70
+9
tests/integration/fixtures/TestFeed/action.yml
··· 1 + - id: 1001 2 + user_id: 2 3 + op_type: 10 # close issue 4 + act_user_id: 2 5 + comment_id: 1001 6 + repo_id: 1 # public 7 + is_private: false 8 + created_unix: 1680454039 9 + content: '1|This is a very long text, so lets scream together: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa…'
+8
tests/integration/fixtures/TestFeed/comment.yml
··· 1 + - 2 + id: 1001 3 + type: 0 # comment 4 + poster_id: 2 5 + issue_id: 1 # in repo_id 1 6 + content: "This is a very long text, so lets scream together: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" 7 + created_unix: 1729602027 8 + updated_unix: 1729602027