integration.go 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. // Copyright 2017 Frédéric Guillot. All rights reserved.
  2. // Use of this source code is governed by the Apache 2.0
  3. // license that can be found in the LICENSE file.
  4. package form
  5. import (
  6. "net/http"
  7. "github.com/miniflux/miniflux/model"
  8. )
  9. // IntegrationForm represents user integration settings form.
  10. type IntegrationForm struct {
  11. PinboardEnabled bool
  12. PinboardToken string
  13. PinboardTags string
  14. PinboardMarkAsUnread bool
  15. InstapaperEnabled bool
  16. InstapaperUsername string
  17. InstapaperPassword string
  18. FeverEnabled bool
  19. FeverUsername string
  20. FeverPassword string
  21. }
  22. // Merge copy form values to the model.
  23. func (i IntegrationForm) Merge(integration *model.Integration) {
  24. integration.PinboardEnabled = i.PinboardEnabled
  25. integration.PinboardToken = i.PinboardToken
  26. integration.PinboardTags = i.PinboardTags
  27. integration.PinboardMarkAsUnread = i.PinboardMarkAsUnread
  28. integration.InstapaperEnabled = i.InstapaperEnabled
  29. integration.InstapaperUsername = i.InstapaperUsername
  30. integration.InstapaperPassword = i.InstapaperPassword
  31. integration.FeverEnabled = i.FeverEnabled
  32. integration.FeverUsername = i.FeverUsername
  33. integration.FeverPassword = i.FeverPassword
  34. }
  35. // NewIntegrationForm returns a new AuthForm.
  36. func NewIntegrationForm(r *http.Request) *IntegrationForm {
  37. return &IntegrationForm{
  38. PinboardEnabled: r.FormValue("pinboard_enabled") == "1",
  39. PinboardToken: r.FormValue("pinboard_token"),
  40. PinboardTags: r.FormValue("pinboard_tags"),
  41. PinboardMarkAsUnread: r.FormValue("pinboard_mark_as_unread") == "1",
  42. InstapaperEnabled: r.FormValue("instapaper_enabled") == "1",
  43. InstapaperUsername: r.FormValue("instapaper_username"),
  44. InstapaperPassword: r.FormValue("instapaper_password"),
  45. FeverEnabled: r.FormValue("fever_enabled") == "1",
  46. FeverUsername: r.FormValue("fever_username"),
  47. FeverPassword: r.FormValue("fever_password"),
  48. }
  49. }