fix: Use FORCE_REFRESH_INTERVAL config for category refresh

This commit is contained in:
bo0tzz 2024-04-19 15:31:49 +02:00 committed by Frédéric Guillot
parent 771f9d2b5f
commit 2caabbe939

View file

@ -8,6 +8,7 @@ import (
"net/http" "net/http"
"time" "time"
"miniflux.app/v2/internal/config"
"miniflux.app/v2/internal/http/request" "miniflux.app/v2/internal/http/request"
"miniflux.app/v2/internal/http/response/html" "miniflux.app/v2/internal/http/response/html"
"miniflux.app/v2/internal/http/route" "miniflux.app/v2/internal/http/route"
@ -32,8 +33,9 @@ func (h *handler) refreshCategory(w http.ResponseWriter, r *http.Request) int64
sess := session.New(h.store, request.SessionID(r)) sess := session.New(h.store, request.SessionID(r))
// Avoid accidental and excessive refreshes. // Avoid accidental and excessive refreshes.
if time.Now().UTC().Unix()-request.LastForceRefresh(r) < 1800 { if time.Now().UTC().Unix()-request.LastForceRefresh(r) < int64(config.Opts.ForceRefreshInterval())*60 {
sess.NewFlashErrorMessage(printer.Print("alert.too_many_feeds_refresh")) time := config.Opts.ForceRefreshInterval()
sess.NewFlashErrorMessage(printer.Plural("alert.too_many_feeds_refresh", time, time))
} else { } else {
// We allow the end-user to force refresh all its feeds in this category // We allow the end-user to force refresh all its feeds in this category
// without taking into consideration the number of errors. // without taking into consideration the number of errors.