From ca5492b65f45c7db8a9cfb767b0b48aa6cf6fe24 Mon Sep 17 00:00:00 2001
From: tobi <31960611+tsmethurst@users.noreply.github.com>
Date: Mon, 10 Jul 2023 17:05:59 +0200
Subject: [bugfix] Tidy up rss feed serving; don't error on empty feed (#1970)
* [bugfix] Tidy up rss feed serving; don't error on empty feed
* fall back to account creation time as rss feed update time
* return feed early when account has no eligible statuses
---
internal/processing/account/rss_test.go | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
(limited to 'internal/processing/account/rss_test.go')
diff --git a/internal/processing/account/rss_test.go b/internal/processing/account/rss_test.go
index 1a0bb9788..80f86211f 100644
--- a/internal/processing/account/rss_test.go
+++ b/internal/processing/account/rss_test.go
@@ -55,6 +55,34 @@ func (suite *GetRSSTestSuite) TestGetAccountRSSZork() {
suite.Equal("\n \n Posts from @the_mighty_zork@localhost:8080\n http://localhost:8080/@the_mighty_zork\n Posts from @the_mighty_zork@localhost:8080\n Wed, 20 Oct 2021 10:40:37 +0000\n Wed, 20 Oct 2021 10:40:37 +0000\n \n http://localhost:8080/fileserver/01F8MH1H7YV1Z7D2C8K2730QBF/avatar/small/01F8MH58A357CV5K7R7TJMSH6S.jpg\n Avatar for @the_mighty_zork@localhost:8080\n http://localhost:8080/@the_mighty_zork\n \n - \n introduction post\n http://localhost:8080/@the_mighty_zork/statuses/01F8MHAMCHF6Y650WCRSCP4WMY\n @the_mighty_zork@localhost:8080 made a new post: "hello everyone!"\n \n @the_mighty_zork@localhost:8080\n http://localhost:8080/@the_mighty_zork/statuses/01F8MHAMCHF6Y650WCRSCP4WMY\n Wed, 20 Oct 2021 10:40:37 +0000\n http://localhost:8080/@the_mighty_zork/feed.rss\n
\n \n", feed)
}
+func (suite *GetRSSTestSuite) TestGetAccountRSSZorkNoPosts() {
+ ctx := context.Background()
+
+ // Get all of zork's posts.
+ statuses, err := suite.db.GetAccountStatuses(ctx, suite.testAccounts["local_account_1"].ID, 0, false, false, "", "", false, false)
+ if err != nil {
+ suite.FailNow(err.Error())
+ }
+
+ // Now delete them! Hahaha!
+ for _, status := range statuses {
+ if err := suite.db.DeleteStatusByID(ctx, status.ID); err != nil {
+ suite.FailNow(err.Error())
+ }
+ }
+
+ getFeed, lastModified, err := suite.accountProcessor.GetRSSFeedForUsername(ctx, "the_mighty_zork")
+ suite.NoError(err)
+ suite.Empty(lastModified)
+
+ feed, err := getFeed()
+ suite.NoError(err)
+
+ fmt.Println(feed)
+
+ suite.Equal("\n \n Posts from @the_mighty_zork@localhost:8080\n http://localhost:8080/@the_mighty_zork\n Posts from @the_mighty_zork@localhost:8080\n Fri, 20 May 2022 11:09:18 +0000\n Fri, 20 May 2022 11:09:18 +0000\n \n http://localhost:8080/fileserver/01F8MH1H7YV1Z7D2C8K2730QBF/avatar/small/01F8MH58A357CV5K7R7TJMSH6S.jpg\n Avatar for @the_mighty_zork@localhost:8080\n http://localhost:8080/@the_mighty_zork\n \n \n", feed)
+}
+
func TestGetRSSTestSuite(t *testing.T) {
suite.Run(t, new(GetRSSTestSuite))
}
--
cgit v1.2.3