aboutsummaryrefslogtreecommitdiff
path: root/internal/ui/form/integration.go
blob: 5a332f28b3fc1faca4d9d6c0e1aab38f10132052 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
// SPDX-FileCopyrightText: Copyright The Miniflux Authors. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

package form // import "miniflux.app/v2/internal/ui/form"

import (
	"net/http"

	"miniflux.app/v2/internal/model"
)

// IntegrationForm represents user integration settings form.
type IntegrationForm struct {
	PinboardEnabled      bool
	PinboardToken        string
	PinboardTags         string
	PinboardMarkAsUnread bool
	InstapaperEnabled    bool
	InstapaperUsername   string
	InstapaperPassword   string
	FeverEnabled         bool
	FeverUsername        string
	FeverPassword        string
	GoogleReaderEnabled  bool
	GoogleReaderUsername string
	GoogleReaderPassword string
	WallabagEnabled      bool
	WallabagOnlyURL      bool
	WallabagURL          string
	WallabagClientID     string
	WallabagClientSecret string
	WallabagUsername     string
	WallabagPassword     string
	NotionEnabled        bool
	NotionPageID         string
	NotionToken          string
	NunuxKeeperEnabled   bool
	NunuxKeeperURL       string
	NunuxKeeperAPIKey    string
	EspialEnabled        bool
	EspialURL            string
	EspialAPIKey         string
	EspialTags           string
	ReadwiseEnabled      bool
	ReadwiseAPIKey       string
	PocketEnabled        bool
	PocketAccessToken    string
	PocketConsumerKey    string
	TelegramBotEnabled   bool
	TelegramBotToken     string
	TelegramBotChatID    string
	LinkdingEnabled      bool
	LinkdingURL          string
	LinkdingAPIKey       string
	LinkdingTags         string
	LinkdingMarkAsUnread bool
	MatrixBotEnabled     bool
	MatrixBotUser        string
	MatrixBotPassword    string
	MatrixBotURL         string
	MatrixBotChatID      string
	AppriseEnabled       bool
	AppriseURL           string
	AppriseServicesURL   string
	ShioriEnabled        bool
	ShioriURL            string
	ShioriUsername       string
	ShioriPassword       string
}

// 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
	integration.InstapaperEnabled = i.InstapaperEnabled
	integration.InstapaperUsername = i.InstapaperUsername
	integration.InstapaperPassword = i.InstapaperPassword
	integration.FeverEnabled = i.FeverEnabled
	integration.FeverUsername = i.FeverUsername
	integration.GoogleReaderEnabled = i.GoogleReaderEnabled
	integration.GoogleReaderUsername = i.GoogleReaderUsername
	integration.WallabagEnabled = i.WallabagEnabled
	integration.WallabagOnlyURL = i.WallabagOnlyURL
	integration.WallabagURL = i.WallabagURL
	integration.WallabagClientID = i.WallabagClientID
	integration.WallabagClientSecret = i.WallabagClientSecret
	integration.WallabagUsername = i.WallabagUsername
	integration.WallabagPassword = i.WallabagPassword
	integration.NotionEnabled = i.NotionEnabled
	integration.NotionPageID = i.NotionPageID
	integration.NotionToken = i.NotionToken
	integration.NunuxKeeperEnabled = i.NunuxKeeperEnabled
	integration.NunuxKeeperURL = i.NunuxKeeperURL
	integration.NunuxKeeperAPIKey = i.NunuxKeeperAPIKey
	integration.EspialEnabled = i.EspialEnabled
	integration.EspialURL = i.EspialURL
	integration.EspialAPIKey = i.EspialAPIKey
	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
	integration.LinkdingEnabled = i.LinkdingEnabled
	integration.LinkdingURL = i.LinkdingURL
	integration.LinkdingAPIKey = i.LinkdingAPIKey
	integration.LinkdingTags = i.LinkdingTags
	integration.LinkdingMarkAsUnread = i.LinkdingMarkAsUnread
	integration.MatrixBotEnabled = i.MatrixBotEnabled
	integration.MatrixBotUser = i.MatrixBotUser
	integration.MatrixBotPassword = i.MatrixBotPassword
	integration.MatrixBotURL = i.MatrixBotURL
	integration.MatrixBotChatID = i.MatrixBotChatID
	integration.AppriseEnabled = i.AppriseEnabled
	integration.AppriseServicesURL = i.AppriseServicesURL
	integration.AppriseURL = i.AppriseURL
	integration.ShioriEnabled = i.ShioriEnabled
	integration.ShioriURL = i.ShioriURL
	integration.ShioriUsername = i.ShioriUsername
	integration.ShioriPassword = i.ShioriPassword
}

// NewIntegrationForm returns a new IntegrationForm.
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",
		InstapaperEnabled:    r.FormValue("instapaper_enabled") == "1",
		InstapaperUsername:   r.FormValue("instapaper_username"),
		InstapaperPassword:   r.FormValue("instapaper_password"),
		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"),
		WallabagEnabled:      r.FormValue("wallabag_enabled") == "1",
		WallabagOnlyURL:      r.FormValue("wallabag_only_url") == "1",
		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"),
		NotionEnabled:        r.FormValue("notion_enabled") == "1",
		NotionPageID:         r.FormValue("notion_page_id"),
		NotionToken:          r.FormValue("notion_token"),
		NunuxKeeperEnabled:   r.FormValue("nunux_keeper_enabled") == "1",
		NunuxKeeperURL:       r.FormValue("nunux_keeper_url"),
		NunuxKeeperAPIKey:    r.FormValue("nunux_keeper_api_key"),
		EspialEnabled:        r.FormValue("espial_enabled") == "1",
		EspialURL:            r.FormValue("espial_url"),
		EspialAPIKey:         r.FormValue("espial_api_key"),
		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"),
		LinkdingEnabled:      r.FormValue("linkding_enabled") == "1",
		LinkdingURL:          r.FormValue("linkding_url"),
		LinkdingAPIKey:       r.FormValue("linkding_api_key"),
		LinkdingTags:         r.FormValue("linkding_tags"),
		LinkdingMarkAsUnread: r.FormValue("linkding_mark_as_unread") == "1",
		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"),
		AppriseEnabled:       r.FormValue("apprise_enabled") == "1",
		AppriseURL:           r.FormValue("apprise_url"),
		AppriseServicesURL:   r.FormValue("apprise_services_url"),
		ShioriEnabled:        r.FormValue("shiori_enabled") == "1",
		ShioriURL:            r.FormValue("shiori_url"),
		ShioriUsername:       r.FormValue("shiori_username"),
		ShioriPassword:       r.FormValue("shiori_password"),
	}
}