integration.go 5.3 KB

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