aboutsummaryrefslogtreecommitdiffhomepage
path: root/ui/form/integration.go
blob: 77e0295ff56520a8b87eb2f9fe6c6f7a9cde8527 (plain)
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
// 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.

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

import (
	"net/http"

	"miniflux.app/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
	WallabagEnabled      bool
	WallabagURL          string
	WallabagClientID     string
	WallabagClientSecret string
	WallabagUsername     string
	WallabagPassword     string
	NunuxKeeperEnabled   bool
	NunuxKeeperURL       string
	NunuxKeeperAPIKey    string
	PocketEnabled        bool
	PocketAccessToken    string
	PocketConsumerKey    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.FeverPassword = i.FeverPassword
	integration.WallabagEnabled = i.WallabagEnabled
	integration.WallabagURL = i.WallabagURL
	integration.WallabagClientID = i.WallabagClientID
	integration.WallabagClientSecret = i.WallabagClientSecret
	integration.WallabagUsername = i.WallabagUsername
	integration.WallabagPassword = i.WallabagPassword
	integration.NunuxKeeperEnabled = i.NunuxKeeperEnabled
	integration.NunuxKeeperURL = i.NunuxKeeperURL
	integration.NunuxKeeperAPIKey = i.NunuxKeeperAPIKey
	integration.PocketEnabled = i.PocketEnabled
	integration.PocketAccessToken = i.PocketAccessToken
	integration.PocketConsumerKey = i.PocketConsumerKey
}

// NewIntegrationForm returns a new AuthForm.
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"),
		WallabagEnabled:      r.FormValue("wallabag_enabled") == "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"),
		NunuxKeeperEnabled:   r.FormValue("nunux_keeper_enabled") == "1",
		NunuxKeeperURL:       r.FormValue("nunux_keeper_url"),
		NunuxKeeperAPIKey:    r.FormValue("nunux_keeper_api_key"),
		PocketEnabled:        r.FormValue("pocket_enabled") == "1",
		PocketAccessToken:    r.FormValue("pocket_access_token"),
		PocketConsumerKey:    r.FormValue("pocket_consumer_key"),
	}
}