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

feat(googlereader): avoid SQL query to fetch username in streamItemContentsHandler

This commit is contained in:
Frédéric Guillot 2025-05-04 20:31:12 -07:00
parent 8d821dfc3b
commit 3de9629a49
4 changed files with 20 additions and 14 deletions

View file

@ -16,6 +16,7 @@ type ContextKey int
// List of context keys.
const (
UserIDContextKey ContextKey = iota
UserNameContextKey
UserTimezoneContextKey
IsAdminUserContextKey
IsAuthenticatedContextKey
@ -64,6 +65,15 @@ func UserID(r *http.Request) int64 {
return getContextInt64Value(r, UserIDContextKey)
}
// UserName returns the username of the logged user.
func UserName(r *http.Request) string {
value := getContextStringValue(r, UserNameContextKey)
if value == "" {
value = "unknown"
}
return value
}
// UserTimezone returns the timezone used by the logged user.
func UserTimezone(r *http.Request) string {
value := getContextStringValue(r, UserTimezoneContextKey)