diff options
author | 2017-12-03 17:44:27 -0800 | |
---|---|---|
committer | 2017-12-03 17:44:27 -0800 | |
commit | bc20e0884b3ca051ae77e1bb6e2de11419d36d4d (patch) | |
tree | 993ff7aad2b98d5fe71b2decde7b36c4dd99d184 /server/ui | |
parent | ae62e543d3a1173cd39f1910cb67c95a56a7a6a4 (diff) |
Add Fever API
Diffstat (limited to 'server/ui')
-rw-r--r-- | server/ui/controller/integrations.go | 11 | ||||
-rw-r--r-- | server/ui/form/integration.go | 9 |
2 files changed, 20 insertions, 0 deletions
diff --git a/server/ui/controller/integrations.go b/server/ui/controller/integrations.go index a3e545e..ceac09a 100644 --- a/server/ui/controller/integrations.go +++ b/server/ui/controller/integrations.go @@ -5,7 +5,9 @@ package controller import ( + "crypto/md5" "errors" + "fmt" "github.com/miniflux/miniflux2/integration" "github.com/miniflux/miniflux2/model" @@ -38,6 +40,9 @@ func (c *Controller) ShowIntegrations(ctx *core.Context, request *core.Request, InstapaperEnabled: integration.InstapaperEnabled, InstapaperUsername: integration.InstapaperUsername, InstapaperPassword: integration.InstapaperPassword, + FeverEnabled: integration.FeverEnabled, + FeverUsername: integration.FeverUsername, + FeverPassword: integration.FeverPassword, }, })) } @@ -54,6 +59,12 @@ func (c *Controller) UpdateIntegration(ctx *core.Context, request *core.Request, integrationForm := form.NewIntegrationForm(request.Request()) integrationForm.Merge(integration) + if integration.FeverEnabled { + integration.FeverToken = fmt.Sprintf("%x", md5.Sum([]byte(integration.FeverUsername+":"+integration.FeverPassword))) + } else { + integration.FeverToken = "" + } + err = c.store.UpdateIntegration(integration) if err != nil { response.HTML().ServerError(err) diff --git a/server/ui/form/integration.go b/server/ui/form/integration.go index be54e23..bd32403 100644 --- a/server/ui/form/integration.go +++ b/server/ui/form/integration.go @@ -19,6 +19,9 @@ type IntegrationForm struct { InstapaperEnabled bool InstapaperUsername string InstapaperPassword string + FeverEnabled bool + FeverUsername string + FeverPassword string } // Merge copy form values to the model. @@ -30,6 +33,9 @@ func (i IntegrationForm) Merge(integration *model.Integration) { integration.InstapaperEnabled = i.InstapaperEnabled integration.InstapaperUsername = i.InstapaperUsername integration.InstapaperPassword = i.InstapaperPassword + integration.FeverEnabled = i.FeverEnabled + integration.FeverUsername = i.FeverUsername + integration.FeverPassword = i.FeverPassword } // NewIntegrationForm returns a new AuthForm. @@ -42,5 +48,8 @@ func NewIntegrationForm(r *http.Request) *IntegrationForm { 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"), } } |