aboutsummaryrefslogtreecommitdiffstats
path: root/walrss
diff options
context:
space:
mode:
authorAKP <abi@tdpain.net>2025-02-10 22:19:24 +0000
committerAKP <abi@tdpain.net>2025-02-10 22:19:24 +0000
commit83a0816f8cc90f3f00d2c4918d959c37da915347 (patch)
treee992058c61e93e058d9987aca0b284a60417f175 /walrss
parent53b85e8fab165b45b71f61014642190443f1b487 (diff)
Do not update feed item index when sending test emails
Previously this caused items to be missed from the main, scheduled emails.
Diffstat (limited to 'walrss')
-rw-r--r--walrss/internal/http/testEmail.go2
-rw-r--r--walrss/internal/rss/processor.go9
2 files changed, 6 insertions, 5 deletions
diff --git a/walrss/internal/http/testEmail.go b/walrss/internal/http/testEmail.go
index 86c3e60..9e8a676 100644
--- a/walrss/internal/http/testEmail.go
+++ b/walrss/internal/http/testEmail.go
@@ -33,7 +33,7 @@ func (s *Server) sendTestEmail(ctx *fiber.Ctx) error {
var err error
go func() {
- err = rss.ProcessUserFeed(s.state, user, status)
+ err = rss.ProcessUserFeed(s.state, user, status, true)
}()
for statusAddition := range status {
diff --git a/walrss/internal/rss/processor.go b/walrss/internal/rss/processor.go
index 7d1258a..9dc7ff7 100644
--- a/walrss/internal/rss/processor.go
+++ b/walrss/internal/rss/processor.go
@@ -67,7 +67,7 @@ func ProcessFeeds(st *state.State, day db.SendDay, hour int) error {
}
for _, ur := range u {
- if err := ProcessUserFeed(st, ur, nil); err != nil {
+ if err := ProcessUserFeed(st, ur, nil, false); err != nil {
log.Warn().Err(err).Str("user", ur.ID).Msg("could not process feeds for user")
}
}
@@ -82,7 +82,7 @@ func reportProgress(channel chan string, msg string) {
channel <- msg
}
-func ProcessUserFeed(st *state.State, user *db.User, progressChannel chan string) error {
+func ProcessUserFeed(st *state.State, user *db.User, progressChannel chan string, isTest bool) error {
defer func() {
if progressChannel == nil {
return
@@ -132,8 +132,9 @@ func ProcessUserFeed(st *state.State, user *db.User, progressChannel chan string
pf.Items = ffcRes.filtered
- // add new items to DB cache
- {
+ // add new items to DB cache when we're not testing. if we're testing, adding known items to the cache will
+ // stop them from appearing in any scheduled emails later on.
+ if !isTest {
var newItems []*db.FeedItem
for _, i := range ffcRes.new {
newItems = append(newItems, &db.FeedItem{