miniflux-v2/ui/form/integration.go

150 lines
6.1 KiB
Go
Raw Normal View History

2017-12-03 04:32:14 +01:00
// Copyright 2017 Frédéric Guillot. All rights reserved.
// Use of this source code is governed by the Apache 2.0
// license that can be found in the LICENSE file.
2018-08-25 06:51:50 +02:00
package form // import "miniflux.app/ui/form"
2017-12-03 04:32:14 +01:00
import (
"net/http"
2018-08-25 06:51:50 +02:00
"miniflux.app/model"
2017-12-03 04:32:14 +01:00
)
// IntegrationForm represents user integration settings form.
type IntegrationForm struct {
PinboardEnabled bool
PinboardToken string
PinboardTags string
PinboardMarkAsUnread bool
2017-12-03 06:12:03 +01:00
InstapaperEnabled bool
InstapaperUsername string
InstapaperPassword string
2017-12-04 02:44:27 +01:00
FeverEnabled bool
FeverUsername string
FeverPassword string
GoogleReaderEnabled bool
GoogleReaderUsername string
GoogleReaderPassword string
2017-12-19 05:52:46 +01:00
WallabagEnabled bool
WallabagOnlyURL bool
2017-12-19 05:52:46 +01:00
WallabagURL string
WallabagClientID string
WallabagClientSecret string
WallabagUsername string
WallabagPassword string
2018-02-25 20:49:08 +01:00
NunuxKeeperEnabled bool
NunuxKeeperURL string
NunuxKeeperAPIKey string
2022-04-21 04:44:47 +02:00
EspialEnabled bool
EspialURL string
EspialAPIKey string
EspialTags string
2018-05-20 22:31:56 +02:00
PocketEnabled bool
PocketAccessToken string
PocketConsumerKey string
2021-09-08 05:04:22 +02:00
TelegramBotEnabled bool
TelegramBotToken string
TelegramBotChatID string
2022-05-23 17:53:06 +02:00
LinkdingEnabled bool
LinkdingURL string
LinkdingAPIKey string
LinkdingTags string
2022-10-14 17:18:44 +02:00
MatrixBotEnabled bool
MatrixBotUser string
MatrixBotPassword string
MatrixBotURL string
MatrixBotChatID string
2017-12-03 04:32:14 +01: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 06:12:03 +01:00
integration.InstapaperEnabled = i.InstapaperEnabled
integration.InstapaperUsername = i.InstapaperUsername
integration.InstapaperPassword = i.InstapaperPassword
2017-12-04 02:44:27 +01:00
integration.FeverEnabled = i.FeverEnabled
integration.FeverUsername = i.FeverUsername
integration.GoogleReaderEnabled = i.GoogleReaderEnabled
integration.GoogleReaderUsername = i.GoogleReaderUsername
2017-12-19 05:52:46 +01:00
integration.WallabagEnabled = i.WallabagEnabled
integration.WallabagOnlyURL = i.WallabagOnlyURL
2017-12-19 05:52:46 +01:00
integration.WallabagURL = i.WallabagURL
integration.WallabagClientID = i.WallabagClientID
integration.WallabagClientSecret = i.WallabagClientSecret
integration.WallabagUsername = i.WallabagUsername
integration.WallabagPassword = i.WallabagPassword
2018-02-25 20:49:08 +01:00
integration.NunuxKeeperEnabled = i.NunuxKeeperEnabled
integration.NunuxKeeperURL = i.NunuxKeeperURL
integration.NunuxKeeperAPIKey = i.NunuxKeeperAPIKey
2022-04-21 04:44:47 +02:00
integration.EspialEnabled = i.EspialEnabled
integration.EspialURL = i.EspialURL
integration.EspialAPIKey = i.EspialAPIKey
integration.EspialTags = i.EspialTags
2018-05-20 22:31:56 +02:00
integration.PocketEnabled = i.PocketEnabled
integration.PocketAccessToken = i.PocketAccessToken
integration.PocketConsumerKey = i.PocketConsumerKey
2021-09-08 05:04:22 +02:00
integration.TelegramBotEnabled = i.TelegramBotEnabled
integration.TelegramBotToken = i.TelegramBotToken
integration.TelegramBotChatID = i.TelegramBotChatID
2022-05-23 17:53:06 +02:00
integration.LinkdingEnabled = i.LinkdingEnabled
integration.LinkdingURL = i.LinkdingURL
integration.LinkdingAPIKey = i.LinkdingAPIKey
integration.LinkdingTags = i.LinkdingTags
2022-10-14 17:18:44 +02:00
integration.MatrixBotEnabled = i.MatrixBotEnabled
integration.MatrixBotUser = i.MatrixBotUser
integration.MatrixBotPassword = i.MatrixBotPassword
integration.MatrixBotURL = i.MatrixBotURL
integration.MatrixBotChatID = i.MatrixBotChatID
2017-12-03 04:32:14 +01:00
}
// NewIntegrationForm returns a new IntegrationForm.
2017-12-03 04:32:14 +01: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 06:12:03 +01:00
InstapaperEnabled: r.FormValue("instapaper_enabled") == "1",
InstapaperUsername: r.FormValue("instapaper_username"),
InstapaperPassword: r.FormValue("instapaper_password"),
2017-12-04 02:44:27 +01:00
FeverEnabled: r.FormValue("fever_enabled") == "1",
FeverUsername: r.FormValue("fever_username"),
FeverPassword: r.FormValue("fever_password"),
GoogleReaderEnabled: r.FormValue("googlereader_enabled") == "1",
GoogleReaderUsername: r.FormValue("googlereader_username"),
GoogleReaderPassword: r.FormValue("googlereader_password"),
2017-12-19 05:52:46 +01:00
WallabagEnabled: r.FormValue("wallabag_enabled") == "1",
WallabagOnlyURL: r.FormValue("wallabag_only_url") == "1",
2017-12-19 05:52:46 +01: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"),
2018-02-25 20:49:08 +01:00
NunuxKeeperEnabled: r.FormValue("nunux_keeper_enabled") == "1",
NunuxKeeperURL: r.FormValue("nunux_keeper_url"),
NunuxKeeperAPIKey: r.FormValue("nunux_keeper_api_key"),
2022-04-21 04:44:47 +02:00
EspialEnabled: r.FormValue("espial_enabled") == "1",
EspialURL: r.FormValue("espial_url"),
EspialAPIKey: r.FormValue("espial_api_key"),
EspialTags: r.FormValue("espial_tags"),
2018-05-20 22:31:56 +02:00
PocketEnabled: r.FormValue("pocket_enabled") == "1",
PocketAccessToken: r.FormValue("pocket_access_token"),
PocketConsumerKey: r.FormValue("pocket_consumer_key"),
2021-09-08 05:04:22 +02:00
TelegramBotEnabled: r.FormValue("telegram_bot_enabled") == "1",
TelegramBotToken: r.FormValue("telegram_bot_token"),
TelegramBotChatID: r.FormValue("telegram_bot_chat_id"),
2022-05-23 17:53:06 +02:00
LinkdingEnabled: r.FormValue("linkding_enabled") == "1",
LinkdingURL: r.FormValue("linkding_url"),
LinkdingAPIKey: r.FormValue("linkding_api_key"),
LinkdingTags: r.FormValue("linkding_tags"),
2022-10-14 17:18:44 +02: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"),
2017-12-03 04:32:14 +01:00
}
}