1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-08-01 17:38:37 +00:00

Refactor Batch Builder and prevent accidental and excessive refreshes from the web ui

This commit is contained in:
Frédéric Guillot 2023-10-20 15:12:02 -07:00
parent 95ee1c423b
commit 4cc99881d8
32 changed files with 251 additions and 176 deletions

View file

@ -3,7 +3,10 @@
package request // import "miniflux.app/v2/internal/http/request"
import "net/http"
import (
"net/http"
"strconv"
)
// ContextKey represents a context key.
type ContextKey int
@ -24,6 +27,7 @@ const (
FlashMessageContextKey
FlashErrorMessageContextKey
PocketRequestTokenContextKey
LastForceRefreshContextKey
ClientIPContextKey
GoogleReaderToken
)
@ -114,6 +118,16 @@ func PocketRequestToken(r *http.Request) string {
return getContextStringValue(r, PocketRequestTokenContextKey)
}
// LastForceRefresh returns the last force refresh timestamp.
func LastForceRefresh(r *http.Request) int64 {
jsonStringValue := getContextStringValue(r, LastForceRefreshContextKey)
timestamp, err := strconv.ParseInt(jsonStringValue, 10, 64)
if err != nil {
return 0
}
return timestamp
}
// ClientIP returns the client IP address stored in the context.
func ClientIP(r *http.Request) string {
return getContextStringValue(r, ClientIPContextKey)