diff --git a/internal/reader/handler/handler.go b/internal/reader/handler/handler.go index 9f36dc21102..6b720a288ad 100644 --- a/internal/reader/handler/handler.go +++ b/internal/reader/handler/handler.go @@ -216,6 +216,7 @@ func RefreshFeed(store *storage.Storage, userID, feedID int64, forceRefresh bool } weeklyEntryCount := 0 + newTTL := 0 if config.Opts.PollingScheduler() == model.SchedulerEntryFrequency { var weeklyCountErr error weeklyEntryCount, weeklyCountErr = store.WeeklyFeedEntryCount(userID, feedID) @@ -225,7 +226,15 @@ func RefreshFeed(store *storage.Storage, userID, feedID int64, forceRefresh bool } originalFeed.CheckedNow() - originalFeed.ScheduleNextCheck(weeklyEntryCount, 0) + defer func() { + originalFeed.ScheduleNextCheck(weeklyEntryCount, newTTL) + slog.Debug("Updating next check date based on TTL", + slog.Int64("user_id", userID), + slog.Int64("feed_id", feedID), + slog.Time("new_next_check_at", originalFeed.NextCheckAt), + slog.Int("ttl", newTTL), + ) + }() requestBuilder := fetcher.NewRequestBuilder() requestBuilder.WithUsernameAndPassword(originalFeed.Username, originalFeed.Password) @@ -279,13 +288,7 @@ func RefreshFeed(store *storage.Storage, userID, feedID int64, forceRefresh bool } // If the feed has a TTL defined, we use it to make sure we don't check it too often. - originalFeed.ScheduleNextCheck(weeklyEntryCount, updatedFeed.TTL) - slog.Debug("Updating next check date based on TTL", - slog.Int64("user_id", userID), - slog.Int64("feed_id", feedID), - slog.Time("new_next_check_at", originalFeed.NextCheckAt), - slog.Int("ttl", updatedFeed.TTL), - ) + newTTL = updatedFeed.TTL originalFeed.Entries = updatedFeed.Entries processor.ProcessFeedEntries(store, originalFeed, user, forceRefresh)