mirror of
https://github.com/miniflux/v2.git
synced 2025-08-11 17:51:01 +00:00
feat(integration)!: remove Pocket integration
BREAKING CHANGE: Pocket will no longer be available after July 8, 2025. https://support.mozilla.org/en-US/kb/future-of-pocket#w_when-is-pocket-shutting-down
This commit is contained in:
parent
70b513b8db
commit
e9c1e90b81
41 changed files with 105 additions and 710 deletions
|
@ -44,9 +44,6 @@ type IntegrationForm struct {
|
|||
EspialTags string
|
||||
ReadwiseEnabled bool
|
||||
ReadwiseAPIKey string
|
||||
PocketEnabled bool
|
||||
PocketAccessToken string
|
||||
PocketConsumerKey string
|
||||
TelegramBotEnabled bool
|
||||
TelegramBotToken string
|
||||
TelegramBotChatID string
|
||||
|
@ -160,9 +157,6 @@ func (i IntegrationForm) Merge(integration *model.Integration) {
|
|||
integration.EspialTags = i.EspialTags
|
||||
integration.ReadwiseEnabled = i.ReadwiseEnabled
|
||||
integration.ReadwiseAPIKey = i.ReadwiseAPIKey
|
||||
integration.PocketEnabled = i.PocketEnabled
|
||||
integration.PocketAccessToken = i.PocketAccessToken
|
||||
integration.PocketConsumerKey = i.PocketConsumerKey
|
||||
integration.TelegramBotEnabled = i.TelegramBotEnabled
|
||||
integration.TelegramBotToken = i.TelegramBotToken
|
||||
integration.TelegramBotChatID = i.TelegramBotChatID
|
||||
|
@ -278,9 +272,6 @@ func NewIntegrationForm(r *http.Request) *IntegrationForm {
|
|||
EspialTags: r.FormValue("espial_tags"),
|
||||
ReadwiseEnabled: r.FormValue("readwise_enabled") == "1",
|
||||
ReadwiseAPIKey: r.FormValue("readwise_api_key"),
|
||||
PocketEnabled: r.FormValue("pocket_enabled") == "1",
|
||||
PocketAccessToken: r.FormValue("pocket_access_token"),
|
||||
PocketConsumerKey: r.FormValue("pocket_consumer_key"),
|
||||
TelegramBotEnabled: r.FormValue("telegram_bot_enabled") == "1",
|
||||
TelegramBotToken: r.FormValue("telegram_bot_token"),
|
||||
TelegramBotChatID: r.FormValue("telegram_bot_chat_id"),
|
||||
|
|
|
@ -1,90 +0,0 @@
|
|||
// SPDX-FileCopyrightText: Copyright The Miniflux Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package ui // import "miniflux.app/v2/internal/ui"
|
||||
|
||||
import (
|
||||
"log/slog"
|
||||
"net/http"
|
||||
|
||||
"miniflux.app/v2/internal/config"
|
||||
"miniflux.app/v2/internal/http/request"
|
||||
"miniflux.app/v2/internal/http/response/html"
|
||||
"miniflux.app/v2/internal/http/route"
|
||||
"miniflux.app/v2/internal/integration/pocket"
|
||||
"miniflux.app/v2/internal/locale"
|
||||
"miniflux.app/v2/internal/ui/session"
|
||||
)
|
||||
|
||||
func (h *handler) pocketAuthorize(w http.ResponseWriter, r *http.Request) {
|
||||
printer := locale.NewPrinter(request.UserLanguage(r))
|
||||
user, err := h.store.UserByID(request.UserID(r))
|
||||
if err != nil {
|
||||
html.ServerError(w, r, err)
|
||||
return
|
||||
}
|
||||
|
||||
integration, err := h.store.Integration(user.ID)
|
||||
if err != nil {
|
||||
html.ServerError(w, r, err)
|
||||
return
|
||||
}
|
||||
|
||||
sess := session.New(h.store, request.SessionID(r))
|
||||
connector := pocket.NewConnector(config.Opts.PocketConsumerKey(integration.PocketConsumerKey))
|
||||
redirectURL := config.Opts.RootURL() + route.Path(h.router, "pocketCallback")
|
||||
requestToken, err := connector.RequestToken(redirectURL)
|
||||
if err != nil {
|
||||
slog.Warn("Pocket authorization request failed",
|
||||
slog.Any("user_id", user.ID),
|
||||
slog.Any("error", err),
|
||||
)
|
||||
sess.NewFlashErrorMessage(printer.Print("error.pocket_request_token"))
|
||||
html.Redirect(w, r, route.Path(h.router, "integrations"))
|
||||
return
|
||||
}
|
||||
|
||||
sess.SetPocketRequestToken(requestToken)
|
||||
html.Redirect(w, r, connector.AuthorizationURL(requestToken, redirectURL))
|
||||
}
|
||||
|
||||
func (h *handler) pocketCallback(w http.ResponseWriter, r *http.Request) {
|
||||
printer := locale.NewPrinter(request.UserLanguage(r))
|
||||
sess := session.New(h.store, request.SessionID(r))
|
||||
|
||||
user, err := h.store.UserByID(request.UserID(r))
|
||||
if err != nil {
|
||||
html.ServerError(w, r, err)
|
||||
return
|
||||
}
|
||||
|
||||
integration, err := h.store.Integration(user.ID)
|
||||
if err != nil {
|
||||
html.ServerError(w, r, err)
|
||||
return
|
||||
}
|
||||
|
||||
connector := pocket.NewConnector(config.Opts.PocketConsumerKey(integration.PocketConsumerKey))
|
||||
accessToken, err := connector.AccessToken(request.PocketRequestToken(r))
|
||||
if err != nil {
|
||||
slog.Warn("Unable to get Pocket access token",
|
||||
slog.Any("user_id", user.ID),
|
||||
slog.Any("error", err),
|
||||
)
|
||||
sess.NewFlashErrorMessage(printer.Print("error.pocket_access_token"))
|
||||
html.Redirect(w, r, route.Path(h.router, "integrations"))
|
||||
return
|
||||
}
|
||||
|
||||
sess.SetPocketRequestToken("")
|
||||
integration.PocketAccessToken = accessToken
|
||||
|
||||
err = h.store.UpdateIntegration(integration)
|
||||
if err != nil {
|
||||
html.ServerError(w, r, err)
|
||||
return
|
||||
}
|
||||
|
||||
sess.NewFlashMessage(printer.Print("alert.pocket_linked"))
|
||||
html.Redirect(w, r, route.Path(h.router, "integrations"))
|
||||
}
|
|
@ -6,7 +6,6 @@ package ui // import "miniflux.app/v2/internal/ui"
|
|||
import (
|
||||
"net/http"
|
||||
|
||||
"miniflux.app/v2/internal/config"
|
||||
"miniflux.app/v2/internal/http/request"
|
||||
"miniflux.app/v2/internal/http/response/html"
|
||||
"miniflux.app/v2/internal/ui/form"
|
||||
|
@ -58,9 +57,6 @@ func (h *handler) showIntegrationPage(w http.ResponseWriter, r *http.Request) {
|
|||
EspialTags: integration.EspialTags,
|
||||
ReadwiseEnabled: integration.ReadwiseEnabled,
|
||||
ReadwiseAPIKey: integration.ReadwiseAPIKey,
|
||||
PocketEnabled: integration.PocketEnabled,
|
||||
PocketAccessToken: integration.PocketAccessToken,
|
||||
PocketConsumerKey: integration.PocketConsumerKey,
|
||||
TelegramBotEnabled: integration.TelegramBotEnabled,
|
||||
TelegramBotToken: integration.TelegramBotToken,
|
||||
TelegramBotChatID: integration.TelegramBotChatID,
|
||||
|
@ -149,7 +145,6 @@ func (h *handler) showIntegrationPage(w http.ResponseWriter, r *http.Request) {
|
|||
view.Set("user", user)
|
||||
view.Set("countUnread", h.store.CountUnreadEntries(user.ID))
|
||||
view.Set("countErrorFeeds", h.store.CountUserFeedsWithErrors(user.ID))
|
||||
view.Set("hasPocketConsumerKeyConfigured", config.Opts.PocketConsumerKey("") != "")
|
||||
|
||||
html.OK(w, r, view.Render("integrations"))
|
||||
}
|
||||
|
|
|
@ -126,7 +126,6 @@ func (m *middleware) handleAppSession(next http.Handler) http.Handler {
|
|||
ctx = context.WithValue(ctx, request.FlashErrorMessageContextKey, session.Data.FlashErrorMessage)
|
||||
ctx = context.WithValue(ctx, request.UserLanguageContextKey, session.Data.Language)
|
||||
ctx = context.WithValue(ctx, request.UserThemeContextKey, session.Data.Theme)
|
||||
ctx = context.WithValue(ctx, request.PocketRequestTokenContextKey, session.Data.PocketRequestToken)
|
||||
ctx = context.WithValue(ctx, request.LastForceRefreshContextKey, session.Data.LastForceRefresh)
|
||||
ctx = context.WithValue(ctx, request.WebAuthnDataContextKey, session.Data.WebAuthnSessionData)
|
||||
next.ServeHTTP(w, r.WithContext(ctx))
|
||||
|
|
|
@ -69,11 +69,6 @@ func (s *Session) SetTheme(theme string) {
|
|||
s.store.UpdateAppSessionField(s.sessionID, "theme", theme)
|
||||
}
|
||||
|
||||
// SetPocketRequestToken updates Pocket Request Token.
|
||||
func (s *Session) SetPocketRequestToken(requestToken string) {
|
||||
s.store.UpdateAppSessionField(s.sessionID, "pocket_request_token", requestToken)
|
||||
}
|
||||
|
||||
func (s *Session) SetWebAuthnSessionData(sessionData *model.WebAuthnSession) {
|
||||
s.store.UpdateAppSessionObjectField(s.sessionID, "webauthn_session_data", sessionData)
|
||||
}
|
||||
|
|
|
@ -126,8 +126,6 @@ func Serve(router *mux.Router, store *storage.Storage, pool *worker.Pool) {
|
|||
uiRouter.HandleFunc("/settings", handler.updateSettings).Name("updateSettings").Methods(http.MethodPost)
|
||||
uiRouter.HandleFunc("/integrations", handler.showIntegrationPage).Name("integrations").Methods(http.MethodGet)
|
||||
uiRouter.HandleFunc("/integration", handler.updateIntegration).Name("updateIntegration").Methods(http.MethodPost)
|
||||
uiRouter.HandleFunc("/integration/pocket/authorize", handler.pocketAuthorize).Name("pocketAuthorize").Methods(http.MethodGet)
|
||||
uiRouter.HandleFunc("/integration/pocket/callback", handler.pocketCallback).Name("pocketCallback").Methods(http.MethodGet)
|
||||
uiRouter.HandleFunc("/about", handler.showAboutPage).Name("about").Methods(http.MethodGet)
|
||||
|
||||
// Session pages.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue