aboutsummaryrefslogtreecommitdiff
path: root/internal/http/request/context.go
diff options
context:
space:
mode:
authorGravatar Frédéric Guillot <f@miniflux.net> 2023-10-20 15:12:02 -0700
committerGravatar Frédéric Guillot <f@miniflux.net> 2023-10-20 16:07:18 -0700
commit4cc99881d870495ef35dcbb44d351e4b3c01f401 (patch)
tree46c1408d9a8eba7fdf7633201902e18c6094e579 /internal/http/request/context.go
parent95ee1c423b1157a967fb2024aa86bd395ead23f8 (diff)
downloadv2-4cc99881d870495ef35dcbb44d351e4b3c01f401.tar.gz
v2-4cc99881d870495ef35dcbb44d351e4b3c01f401.tar.zst
v2-4cc99881d870495ef35dcbb44d351e4b3c01f401.zip
Refactor Batch Builder and prevent accidental and excessive refreshes from the web ui
Diffstat (limited to 'internal/http/request/context.go')
-rw-r--r--internal/http/request/context.go16
1 files changed, 15 insertions, 1 deletions
diff --git a/internal/http/request/context.go b/internal/http/request/context.go
index 7fb50685..9a0acbf4 100644
--- a/internal/http/request/context.go
+++ b/internal/http/request/context.go
@@ -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)