1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-08-26 18:21:01 +00:00

Refactor HTTP Client and LocalizedError packages

This commit is contained in:
Frédéric Guillot 2023-10-21 19:50:29 -07:00
parent 120aabfbce
commit 14e25ab9fe
104 changed files with 1277 additions and 10672 deletions

View file

@ -9,6 +9,7 @@ import (
"miniflux.app/v2/internal/http/request"
"miniflux.app/v2/internal/http/response/html"
"miniflux.app/v2/internal/http/route"
"miniflux.app/v2/internal/locale"
"miniflux.app/v2/internal/model"
"miniflux.app/v2/internal/ui/form"
"miniflux.app/v2/internal/ui/session"
@ -32,14 +33,14 @@ func (h *handler) saveAPIKey(w http.ResponseWriter, r *http.Request) {
view.Set("countUnread", h.store.CountUnreadEntries(user.ID))
view.Set("countErrorFeeds", h.store.CountUserFeedsWithErrors(user.ID))
if err := apiKeyForm.Validate(); err != nil {
view.Set("errorMessage", err.Error())
if validationErr := apiKeyForm.Validate(); validationErr != nil {
view.Set("errorMessage", validationErr.Translate(user.Language))
html.OK(w, r, view.Render("create_api_key"))
return
}
if h.store.APIKeyExists(user.ID, apiKeyForm.Description) {
view.Set("errorMessage", "error.api_key_already_exists")
view.Set("errorMessage", locale.NewLocalizedError("error.api_key_already_exists").Translate(user.Language))
html.OK(w, r, view.Render("create_api_key"))
return
}