integration.go 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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 // import "miniflux.app/ui/form"
  5. import (
  6. "net/http"
  7. "miniflux.app/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. WallabagEnabled bool
  22. WallabagURL string
  23. WallabagClientID string
  24. WallabagClientSecret string
  25. WallabagUsername string
  26. WallabagPassword string
  27. NunuxKeeperEnabled bool
  28. NunuxKeeperURL string
  29. NunuxKeeperAPIKey string
  30. PocketEnabled bool
  31. PocketAccessToken string
  32. PocketConsumerKey string
  33. TelegramBotEnabled bool
  34. TelegramBotToken string
  35. TelegramBotChatID string
  36. }
  37. // Merge copy form values to the model.
  38. func (i IntegrationForm) Merge(integration *model.Integration) {
  39. integration.PinboardEnabled = i.PinboardEnabled
  40. integration.PinboardToken = i.PinboardToken
  41. integration.PinboardTags = i.PinboardTags
  42. integration.PinboardMarkAsUnread = i.PinboardMarkAsUnread
  43. integration.InstapaperEnabled = i.InstapaperEnabled
  44. integration.InstapaperUsername = i.InstapaperUsername
  45. integration.InstapaperPassword = i.InstapaperPassword
  46. integration.FeverEnabled = i.FeverEnabled
  47. integration.FeverUsername = i.FeverUsername
  48. integration.WallabagEnabled = i.WallabagEnabled
  49. integration.WallabagURL = i.WallabagURL
  50. integration.WallabagClientID = i.WallabagClientID
  51. integration.WallabagClientSecret = i.WallabagClientSecret
  52. integration.WallabagUsername = i.WallabagUsername
  53. integration.WallabagPassword = i.WallabagPassword
  54. integration.NunuxKeeperEnabled = i.NunuxKeeperEnabled
  55. integration.NunuxKeeperURL = i.NunuxKeeperURL
  56. integration.NunuxKeeperAPIKey = i.NunuxKeeperAPIKey
  57. integration.PocketEnabled = i.PocketEnabled
  58. integration.PocketAccessToken = i.PocketAccessToken
  59. integration.PocketConsumerKey = i.PocketConsumerKey
  60. integration.TelegramBotEnabled = i.TelegramBotEnabled
  61. integration.TelegramBotToken = i.TelegramBotToken
  62. integration.TelegramBotChatID = i.TelegramBotChatID
  63. }
  64. // NewIntegrationForm returns a new AuthForm.
  65. func NewIntegrationForm(r *http.Request) *IntegrationForm {
  66. return &IntegrationForm{
  67. PinboardEnabled: r.FormValue("pinboard_enabled") == "1",
  68. PinboardToken: r.FormValue("pinboard_token"),
  69. PinboardTags: r.FormValue("pinboard_tags"),
  70. PinboardMarkAsUnread: r.FormValue("pinboard_mark_as_unread") == "1",
  71. InstapaperEnabled: r.FormValue("instapaper_enabled") == "1",
  72. InstapaperUsername: r.FormValue("instapaper_username"),
  73. InstapaperPassword: r.FormValue("instapaper_password"),
  74. FeverEnabled: r.FormValue("fever_enabled") == "1",
  75. FeverUsername: r.FormValue("fever_username"),
  76. FeverPassword: r.FormValue("fever_password"),
  77. WallabagEnabled: r.FormValue("wallabag_enabled") == "1",
  78. WallabagURL: r.FormValue("wallabag_url"),
  79. WallabagClientID: r.FormValue("wallabag_client_id"),
  80. WallabagClientSecret: r.FormValue("wallabag_client_secret"),
  81. WallabagUsername: r.FormValue("wallabag_username"),
  82. WallabagPassword: r.FormValue("wallabag_password"),
  83. NunuxKeeperEnabled: r.FormValue("nunux_keeper_enabled") == "1",
  84. NunuxKeeperURL: r.FormValue("nunux_keeper_url"),
  85. NunuxKeeperAPIKey: r.FormValue("nunux_keeper_api_key"),
  86. PocketEnabled: r.FormValue("pocket_enabled") == "1",
  87. PocketAccessToken: r.FormValue("pocket_access_token"),
  88. PocketConsumerKey: r.FormValue("pocket_consumer_key"),
  89. TelegramBotEnabled: r.FormValue("telegram_bot_enabled") == "1",
  90. TelegramBotToken: r.FormValue("telegram_bot_token"),
  91. TelegramBotChatID: r.FormValue("telegram_bot_chat_id"),
  92. }
  93. }