aboutsummaryrefslogtreecommitdiff
path: root/server/ui/controller/integrations.go
diff options
context:
space:
mode:
authorGravatar Frédéric Guillot <fred@miniflux.net> 2018-01-02 22:04:48 -0800
committerGravatar Frédéric Guillot <fred@miniflux.net> 2018-01-02 22:04:48 -0800
commit320d1b016747ba4501da9417d9ce5f99368a5768 (patch)
tree1054d96afde6022951b76cc4a09b78e1e3f05058 /server/ui/controller/integrations.go
parentc39f2e1a8d2de6d412bcc673d29eb0f7a2d1f5f7 (diff)
downloadv2-320d1b016747ba4501da9417d9ce5f99368a5768.tar.gz
v2-320d1b016747ba4501da9417d9ce5f99368a5768.tar.zst
v2-320d1b016747ba4501da9417d9ce5f99368a5768.zip
Refactor packages to have more idiomatic code base
Diffstat (limited to 'server/ui/controller/integrations.go')
-rw-r--r--server/ui/controller/integrations.go84
1 files changed, 0 insertions, 84 deletions
diff --git a/server/ui/controller/integrations.go b/server/ui/controller/integrations.go
deleted file mode 100644
index 9ff4baa4..00000000
--- a/server/ui/controller/integrations.go
+++ /dev/null
@@ -1,84 +0,0 @@
-// 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 controller
-
-import (
- "crypto/md5"
- "fmt"
-
- "github.com/miniflux/miniflux/server/core"
- "github.com/miniflux/miniflux/server/ui/form"
-)
-
-// ShowIntegrations renders the page with all external integrations.
-func (c *Controller) ShowIntegrations(ctx *core.Context, request *core.Request, response *core.Response) {
- user := ctx.LoggedUser()
- integration, err := c.store.Integration(user.ID)
- if err != nil {
- response.HTML().ServerError(err)
- return
- }
-
- args, err := c.getCommonTemplateArgs(ctx)
- if err != nil {
- response.HTML().ServerError(err)
- return
- }
-
- response.HTML().Render("integrations", args.Merge(tplParams{
- "menu": "settings",
- "form": form.IntegrationForm{
- PinboardEnabled: integration.PinboardEnabled,
- PinboardToken: integration.PinboardToken,
- PinboardTags: integration.PinboardTags,
- PinboardMarkAsUnread: integration.PinboardMarkAsUnread,
- InstapaperEnabled: integration.InstapaperEnabled,
- InstapaperUsername: integration.InstapaperUsername,
- InstapaperPassword: integration.InstapaperPassword,
- FeverEnabled: integration.FeverEnabled,
- FeverUsername: integration.FeverUsername,
- FeverPassword: integration.FeverPassword,
- WallabagEnabled: integration.WallabagEnabled,
- WallabagURL: integration.WallabagURL,
- WallabagClientID: integration.WallabagClientID,
- WallabagClientSecret: integration.WallabagClientSecret,
- WallabagUsername: integration.WallabagUsername,
- WallabagPassword: integration.WallabagPassword,
- },
- }))
-}
-
-// UpdateIntegration updates integration settings.
-func (c *Controller) UpdateIntegration(ctx *core.Context, request *core.Request, response *core.Response) {
- user := ctx.LoggedUser()
- integration, err := c.store.Integration(user.ID)
- if err != nil {
- response.HTML().ServerError(err)
- return
- }
-
- integrationForm := form.NewIntegrationForm(request.Request())
- integrationForm.Merge(integration)
-
- if integration.FeverUsername != "" && c.store.HasDuplicateFeverUsername(user.ID, integration.FeverUsername) {
- ctx.SetFlashErrorMessage(ctx.Translate("There is already someone else with the same Fever username!"))
- response.Redirect(ctx.Route("integrations"))
- return
- }
-
- 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)
- return
- }
-
- response.Redirect(ctx.Route("integrations"))
-}