2023-06-19 17:42:47 -04:00
|
|
|
// SPDX-FileCopyrightText: Copyright The Miniflux Authors. All rights reserved.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0
|
2017-12-02 22:32:14 -05:00
|
|
|
|
2023-08-10 22:46:45 -04:00
|
|
|
package form // import "miniflux.app/v2/internal/ui/form"
|
2017-12-02 22:32:14 -05:00
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
|
2023-08-10 22:46:45 -04:00
|
|
|
"miniflux.app/v2/internal/model"
|
2017-12-02 22:32:14 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
// IntegrationForm represents user integration settings form.
|
|
|
|
type IntegrationForm struct {
|
|
|
|
PinboardEnabled bool
|
|
|
|
PinboardToken string
|
|
|
|
PinboardTags string
|
|
|
|
PinboardMarkAsUnread bool
|
2017-12-03 00:12:03 -05:00
|
|
|
InstapaperEnabled bool
|
|
|
|
InstapaperUsername string
|
|
|
|
InstapaperPassword string
|
2017-12-03 20:44:27 -05:00
|
|
|
FeverEnabled bool
|
|
|
|
FeverUsername string
|
|
|
|
FeverPassword string
|
2022-01-02 22:45:12 -05:00
|
|
|
GoogleReaderEnabled bool
|
|
|
|
GoogleReaderUsername string
|
|
|
|
GoogleReaderPassword string
|
2017-12-18 23:52:46 -05:00
|
|
|
WallabagEnabled bool
|
2022-09-18 19:52:28 -04:00
|
|
|
WallabagOnlyURL bool
|
2017-12-18 23:52:46 -05:00
|
|
|
WallabagURL string
|
|
|
|
WallabagClientID string
|
|
|
|
WallabagClientSecret string
|
|
|
|
WallabagUsername string
|
|
|
|
WallabagPassword string
|
2023-07-07 18:20:14 -04:00
|
|
|
NotionEnabled bool
|
|
|
|
NotionPageID string
|
|
|
|
NotionToken string
|
2018-02-25 14:49:08 -05:00
|
|
|
NunuxKeeperEnabled bool
|
|
|
|
NunuxKeeperURL string
|
|
|
|
NunuxKeeperAPIKey string
|
2022-04-20 22:44:47 -04:00
|
|
|
EspialEnabled bool
|
|
|
|
EspialURL string
|
|
|
|
EspialAPIKey string
|
|
|
|
EspialTags string
|
2023-07-27 23:51:44 -04:00
|
|
|
ReadwiseEnabled bool
|
|
|
|
ReadwiseAPIKey string
|
2018-05-20 16:31:56 -04:00
|
|
|
PocketEnabled bool
|
|
|
|
PocketAccessToken string
|
|
|
|
PocketConsumerKey string
|
2021-09-07 23:04:22 -04:00
|
|
|
TelegramBotEnabled bool
|
|
|
|
TelegramBotToken string
|
|
|
|
TelegramBotChatID string
|
2022-05-23 11:53:06 -04:00
|
|
|
LinkdingEnabled bool
|
|
|
|
LinkdingURL string
|
|
|
|
LinkdingAPIKey string
|
2023-05-21 10:29:51 -04:00
|
|
|
LinkdingTags string
|
2023-06-24 11:08:58 -04:00
|
|
|
LinkdingMarkAsUnread bool
|
2022-10-14 11:18:44 -04:00
|
|
|
MatrixBotEnabled bool
|
|
|
|
MatrixBotUser string
|
|
|
|
MatrixBotPassword string
|
|
|
|
MatrixBotURL string
|
|
|
|
MatrixBotChatID string
|
2023-07-31 23:55:17 -04:00
|
|
|
AppriseEnabled bool
|
|
|
|
AppriseURL string
|
|
|
|
AppriseServicesURL string
|
2023-08-13 15:48:29 -04:00
|
|
|
ShioriEnabled bool
|
|
|
|
ShioriURL string
|
|
|
|
ShioriUsername string
|
|
|
|
ShioriPassword string
|
2023-08-13 17:30:57 -04:00
|
|
|
ShaarliEnabled bool
|
|
|
|
ShaarliURL string
|
|
|
|
ShaarliAPISecret string
|
2017-12-02 22:32:14 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// Merge copy form values to the model.
|
|
|
|
func (i IntegrationForm) Merge(integration *model.Integration) {
|
|
|
|
integration.PinboardEnabled = i.PinboardEnabled
|
|
|
|
integration.PinboardToken = i.PinboardToken
|
|
|
|
integration.PinboardTags = i.PinboardTags
|
|
|
|
integration.PinboardMarkAsUnread = i.PinboardMarkAsUnread
|
2017-12-03 00:12:03 -05:00
|
|
|
integration.InstapaperEnabled = i.InstapaperEnabled
|
|
|
|
integration.InstapaperUsername = i.InstapaperUsername
|
|
|
|
integration.InstapaperPassword = i.InstapaperPassword
|
2017-12-03 20:44:27 -05:00
|
|
|
integration.FeverEnabled = i.FeverEnabled
|
|
|
|
integration.FeverUsername = i.FeverUsername
|
2022-01-02 22:45:12 -05:00
|
|
|
integration.GoogleReaderEnabled = i.GoogleReaderEnabled
|
|
|
|
integration.GoogleReaderUsername = i.GoogleReaderUsername
|
2017-12-18 23:52:46 -05:00
|
|
|
integration.WallabagEnabled = i.WallabagEnabled
|
2022-09-18 19:52:28 -04:00
|
|
|
integration.WallabagOnlyURL = i.WallabagOnlyURL
|
2017-12-18 23:52:46 -05:00
|
|
|
integration.WallabagURL = i.WallabagURL
|
|
|
|
integration.WallabagClientID = i.WallabagClientID
|
|
|
|
integration.WallabagClientSecret = i.WallabagClientSecret
|
|
|
|
integration.WallabagUsername = i.WallabagUsername
|
|
|
|
integration.WallabagPassword = i.WallabagPassword
|
2023-07-07 18:20:14 -04:00
|
|
|
integration.NotionEnabled = i.NotionEnabled
|
|
|
|
integration.NotionPageID = i.NotionPageID
|
|
|
|
integration.NotionToken = i.NotionToken
|
2018-02-25 14:49:08 -05:00
|
|
|
integration.NunuxKeeperEnabled = i.NunuxKeeperEnabled
|
|
|
|
integration.NunuxKeeperURL = i.NunuxKeeperURL
|
|
|
|
integration.NunuxKeeperAPIKey = i.NunuxKeeperAPIKey
|
2022-04-20 22:44:47 -04:00
|
|
|
integration.EspialEnabled = i.EspialEnabled
|
|
|
|
integration.EspialURL = i.EspialURL
|
|
|
|
integration.EspialAPIKey = i.EspialAPIKey
|
|
|
|
integration.EspialTags = i.EspialTags
|
2023-07-27 23:51:44 -04:00
|
|
|
integration.ReadwiseEnabled = i.ReadwiseEnabled
|
|
|
|
integration.ReadwiseAPIKey = i.ReadwiseAPIKey
|
2018-05-20 16:31:56 -04:00
|
|
|
integration.PocketEnabled = i.PocketEnabled
|
|
|
|
integration.PocketAccessToken = i.PocketAccessToken
|
|
|
|
integration.PocketConsumerKey = i.PocketConsumerKey
|
2021-09-07 23:04:22 -04:00
|
|
|
integration.TelegramBotEnabled = i.TelegramBotEnabled
|
|
|
|
integration.TelegramBotToken = i.TelegramBotToken
|
|
|
|
integration.TelegramBotChatID = i.TelegramBotChatID
|
2022-05-23 11:53:06 -04:00
|
|
|
integration.LinkdingEnabled = i.LinkdingEnabled
|
|
|
|
integration.LinkdingURL = i.LinkdingURL
|
|
|
|
integration.LinkdingAPIKey = i.LinkdingAPIKey
|
2023-05-21 10:29:51 -04:00
|
|
|
integration.LinkdingTags = i.LinkdingTags
|
2023-06-24 11:08:58 -04:00
|
|
|
integration.LinkdingMarkAsUnread = i.LinkdingMarkAsUnread
|
2022-10-14 11:18:44 -04:00
|
|
|
integration.MatrixBotEnabled = i.MatrixBotEnabled
|
|
|
|
integration.MatrixBotUser = i.MatrixBotUser
|
|
|
|
integration.MatrixBotPassword = i.MatrixBotPassword
|
|
|
|
integration.MatrixBotURL = i.MatrixBotURL
|
|
|
|
integration.MatrixBotChatID = i.MatrixBotChatID
|
2023-07-31 23:55:17 -04:00
|
|
|
integration.AppriseEnabled = i.AppriseEnabled
|
|
|
|
integration.AppriseServicesURL = i.AppriseServicesURL
|
|
|
|
integration.AppriseURL = i.AppriseURL
|
2023-08-13 15:48:29 -04:00
|
|
|
integration.ShioriEnabled = i.ShioriEnabled
|
|
|
|
integration.ShioriURL = i.ShioriURL
|
|
|
|
integration.ShioriUsername = i.ShioriUsername
|
|
|
|
integration.ShioriPassword = i.ShioriPassword
|
2023-08-13 17:30:57 -04:00
|
|
|
integration.ShaarliEnabled = i.ShaarliEnabled
|
|
|
|
integration.ShaarliURL = i.ShaarliURL
|
|
|
|
integration.ShaarliAPISecret = i.ShaarliAPISecret
|
2017-12-02 22:32:14 -05:00
|
|
|
}
|
|
|
|
|
2022-01-02 22:45:12 -05:00
|
|
|
// NewIntegrationForm returns a new IntegrationForm.
|
2017-12-02 22:32:14 -05:00
|
|
|
func NewIntegrationForm(r *http.Request) *IntegrationForm {
|
|
|
|
return &IntegrationForm{
|
|
|
|
PinboardEnabled: r.FormValue("pinboard_enabled") == "1",
|
|
|
|
PinboardToken: r.FormValue("pinboard_token"),
|
|
|
|
PinboardTags: r.FormValue("pinboard_tags"),
|
|
|
|
PinboardMarkAsUnread: r.FormValue("pinboard_mark_as_unread") == "1",
|
2017-12-03 00:12:03 -05:00
|
|
|
InstapaperEnabled: r.FormValue("instapaper_enabled") == "1",
|
|
|
|
InstapaperUsername: r.FormValue("instapaper_username"),
|
|
|
|
InstapaperPassword: r.FormValue("instapaper_password"),
|
2017-12-03 20:44:27 -05:00
|
|
|
FeverEnabled: r.FormValue("fever_enabled") == "1",
|
|
|
|
FeverUsername: r.FormValue("fever_username"),
|
|
|
|
FeverPassword: r.FormValue("fever_password"),
|
2022-01-02 22:45:12 -05:00
|
|
|
GoogleReaderEnabled: r.FormValue("googlereader_enabled") == "1",
|
|
|
|
GoogleReaderUsername: r.FormValue("googlereader_username"),
|
|
|
|
GoogleReaderPassword: r.FormValue("googlereader_password"),
|
2017-12-18 23:52:46 -05:00
|
|
|
WallabagEnabled: r.FormValue("wallabag_enabled") == "1",
|
2022-09-18 19:52:28 -04:00
|
|
|
WallabagOnlyURL: r.FormValue("wallabag_only_url") == "1",
|
2017-12-18 23:52:46 -05:00
|
|
|
WallabagURL: r.FormValue("wallabag_url"),
|
|
|
|
WallabagClientID: r.FormValue("wallabag_client_id"),
|
|
|
|
WallabagClientSecret: r.FormValue("wallabag_client_secret"),
|
|
|
|
WallabagUsername: r.FormValue("wallabag_username"),
|
|
|
|
WallabagPassword: r.FormValue("wallabag_password"),
|
2023-07-07 18:20:14 -04:00
|
|
|
NotionEnabled: r.FormValue("notion_enabled") == "1",
|
|
|
|
NotionPageID: r.FormValue("notion_page_id"),
|
|
|
|
NotionToken: r.FormValue("notion_token"),
|
2018-02-25 14:49:08 -05:00
|
|
|
NunuxKeeperEnabled: r.FormValue("nunux_keeper_enabled") == "1",
|
|
|
|
NunuxKeeperURL: r.FormValue("nunux_keeper_url"),
|
|
|
|
NunuxKeeperAPIKey: r.FormValue("nunux_keeper_api_key"),
|
2022-04-20 22:44:47 -04:00
|
|
|
EspialEnabled: r.FormValue("espial_enabled") == "1",
|
|
|
|
EspialURL: r.FormValue("espial_url"),
|
|
|
|
EspialAPIKey: r.FormValue("espial_api_key"),
|
|
|
|
EspialTags: r.FormValue("espial_tags"),
|
2023-07-27 23:51:44 -04:00
|
|
|
ReadwiseEnabled: r.FormValue("readwise_enabled") == "1",
|
|
|
|
ReadwiseAPIKey: r.FormValue("readwise_api_key"),
|
2018-05-20 16:31:56 -04:00
|
|
|
PocketEnabled: r.FormValue("pocket_enabled") == "1",
|
|
|
|
PocketAccessToken: r.FormValue("pocket_access_token"),
|
|
|
|
PocketConsumerKey: r.FormValue("pocket_consumer_key"),
|
2021-09-07 23:04:22 -04:00
|
|
|
TelegramBotEnabled: r.FormValue("telegram_bot_enabled") == "1",
|
|
|
|
TelegramBotToken: r.FormValue("telegram_bot_token"),
|
|
|
|
TelegramBotChatID: r.FormValue("telegram_bot_chat_id"),
|
2022-05-23 11:53:06 -04:00
|
|
|
LinkdingEnabled: r.FormValue("linkding_enabled") == "1",
|
|
|
|
LinkdingURL: r.FormValue("linkding_url"),
|
|
|
|
LinkdingAPIKey: r.FormValue("linkding_api_key"),
|
2023-05-21 10:29:51 -04:00
|
|
|
LinkdingTags: r.FormValue("linkding_tags"),
|
2023-06-24 11:08:58 -04:00
|
|
|
LinkdingMarkAsUnread: r.FormValue("linkding_mark_as_unread") == "1",
|
2022-10-14 11:18:44 -04:00
|
|
|
MatrixBotEnabled: r.FormValue("matrix_bot_enabled") == "1",
|
|
|
|
MatrixBotUser: r.FormValue("matrix_bot_user"),
|
|
|
|
MatrixBotPassword: r.FormValue("matrix_bot_password"),
|
|
|
|
MatrixBotURL: r.FormValue("matrix_bot_url"),
|
|
|
|
MatrixBotChatID: r.FormValue("matrix_bot_chat_id"),
|
2023-07-31 23:55:17 -04:00
|
|
|
AppriseEnabled: r.FormValue("apprise_enabled") == "1",
|
|
|
|
AppriseURL: r.FormValue("apprise_url"),
|
|
|
|
AppriseServicesURL: r.FormValue("apprise_services_url"),
|
2023-08-13 15:48:29 -04:00
|
|
|
ShioriEnabled: r.FormValue("shiori_enabled") == "1",
|
|
|
|
ShioriURL: r.FormValue("shiori_url"),
|
|
|
|
ShioriUsername: r.FormValue("shiori_username"),
|
|
|
|
ShioriPassword: r.FormValue("shiori_password"),
|
2023-08-13 17:30:57 -04:00
|
|
|
ShaarliEnabled: r.FormValue("shaarli_enabled") == "1",
|
|
|
|
ShaarliURL: r.FormValue("shaarli_url"),
|
|
|
|
ShaarliAPISecret: r.FormValue("shaarli_api_secret"),
|
2017-12-02 22:32:14 -05:00
|
|
|
}
|
|
|
|
}
|