integration.go 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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. GoogleReaderEnabled bool
  22. GoogleReaderUsername string
  23. GoogleReaderPassword string
  24. WallabagEnabled bool
  25. WallabagURL string
  26. WallabagClientID string
  27. WallabagClientSecret string
  28. WallabagUsername string
  29. WallabagPassword string
  30. NunuxKeeperEnabled bool
  31. NunuxKeeperURL string
  32. NunuxKeeperAPIKey string
  33. EspialEnabled bool
  34. EspialURL string
  35. EspialAPIKey string
  36. EspialTags string
  37. PocketEnabled bool
  38. PocketAccessToken string
  39. PocketConsumerKey string
  40. TelegramBotEnabled bool
  41. TelegramBotToken string
  42. TelegramBotChatID string
  43. }
  44. // Merge copy form values to the model.
  45. func (i IntegrationForm) Merge(integration *model.Integration) {
  46. integration.PinboardEnabled = i.PinboardEnabled
  47. integration.PinboardToken = i.PinboardToken
  48. integration.PinboardTags = i.PinboardTags
  49. integration.PinboardMarkAsUnread = i.PinboardMarkAsUnread
  50. integration.InstapaperEnabled = i.InstapaperEnabled
  51. integration.InstapaperUsername = i.InstapaperUsername
  52. integration.InstapaperPassword = i.InstapaperPassword
  53. integration.FeverEnabled = i.FeverEnabled
  54. integration.FeverUsername = i.FeverUsername
  55. integration.GoogleReaderEnabled = i.GoogleReaderEnabled
  56. integration.GoogleReaderUsername = i.GoogleReaderUsername
  57. integration.WallabagEnabled = i.WallabagEnabled
  58. integration.WallabagURL = i.WallabagURL
  59. integration.WallabagClientID = i.WallabagClientID
  60. integration.WallabagClientSecret = i.WallabagClientSecret
  61. integration.WallabagUsername = i.WallabagUsername
  62. integration.WallabagPassword = i.WallabagPassword
  63. integration.NunuxKeeperEnabled = i.NunuxKeeperEnabled
  64. integration.NunuxKeeperURL = i.NunuxKeeperURL
  65. integration.NunuxKeeperAPIKey = i.NunuxKeeperAPIKey
  66. integration.EspialEnabled = i.EspialEnabled
  67. integration.EspialURL = i.EspialURL
  68. integration.EspialAPIKey = i.EspialAPIKey
  69. integration.EspialTags = i.EspialTags
  70. integration.PocketEnabled = i.PocketEnabled
  71. integration.PocketAccessToken = i.PocketAccessToken
  72. integration.PocketConsumerKey = i.PocketConsumerKey
  73. integration.TelegramBotEnabled = i.TelegramBotEnabled
  74. integration.TelegramBotToken = i.TelegramBotToken
  75. integration.TelegramBotChatID = i.TelegramBotChatID
  76. }
  77. // NewIntegrationForm returns a new IntegrationForm.
  78. func NewIntegrationForm(r *http.Request) *IntegrationForm {
  79. return &IntegrationForm{
  80. PinboardEnabled: r.FormValue("pinboard_enabled") == "1",
  81. PinboardToken: r.FormValue("pinboard_token"),
  82. PinboardTags: r.FormValue("pinboard_tags"),
  83. PinboardMarkAsUnread: r.FormValue("pinboard_mark_as_unread") == "1",
  84. InstapaperEnabled: r.FormValue("instapaper_enabled") == "1",
  85. InstapaperUsername: r.FormValue("instapaper_username"),
  86. InstapaperPassword: r.FormValue("instapaper_password"),
  87. FeverEnabled: r.FormValue("fever_enabled") == "1",
  88. FeverUsername: r.FormValue("fever_username"),
  89. FeverPassword: r.FormValue("fever_password"),
  90. GoogleReaderEnabled: r.FormValue("googlereader_enabled") == "1",
  91. GoogleReaderUsername: r.FormValue("googlereader_username"),
  92. GoogleReaderPassword: r.FormValue("googlereader_password"),
  93. WallabagEnabled: r.FormValue("wallabag_enabled") == "1",
  94. WallabagURL: r.FormValue("wallabag_url"),
  95. WallabagClientID: r.FormValue("wallabag_client_id"),
  96. WallabagClientSecret: r.FormValue("wallabag_client_secret"),
  97. WallabagUsername: r.FormValue("wallabag_username"),
  98. WallabagPassword: r.FormValue("wallabag_password"),
  99. NunuxKeeperEnabled: r.FormValue("nunux_keeper_enabled") == "1",
  100. NunuxKeeperURL: r.FormValue("nunux_keeper_url"),
  101. NunuxKeeperAPIKey: r.FormValue("nunux_keeper_api_key"),
  102. EspialEnabled: r.FormValue("espial_enabled") == "1",
  103. EspialURL: r.FormValue("espial_url"),
  104. EspialAPIKey: r.FormValue("espial_api_key"),
  105. EspialTags: r.FormValue("espial_tags"),
  106. PocketEnabled: r.FormValue("pocket_enabled") == "1",
  107. PocketAccessToken: r.FormValue("pocket_access_token"),
  108. PocketConsumerKey: r.FormValue("pocket_consumer_key"),
  109. TelegramBotEnabled: r.FormValue("telegram_bot_enabled") == "1",
  110. TelegramBotToken: r.FormValue("telegram_bot_token"),
  111. TelegramBotChatID: r.FormValue("telegram_bot_chat_id"),
  112. }
  113. }