integration.go 4.3 KB

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