integration.go 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. // SPDX-FileCopyrightText: Copyright The Miniflux Authors. All rights reserved.
  2. // SPDX-License-Identifier: Apache-2.0
  3. package form // import "miniflux.app/ui/form"
  4. import (
  5. "net/http"
  6. "miniflux.app/model"
  7. )
  8. // IntegrationForm represents user integration settings form.
  9. type IntegrationForm struct {
  10. PinboardEnabled bool
  11. PinboardToken string
  12. PinboardTags string
  13. PinboardMarkAsUnread bool
  14. InstapaperEnabled bool
  15. InstapaperUsername string
  16. InstapaperPassword string
  17. FeverEnabled bool
  18. FeverUsername string
  19. FeverPassword string
  20. GoogleReaderEnabled bool
  21. GoogleReaderUsername string
  22. GoogleReaderPassword string
  23. WallabagEnabled bool
  24. WallabagOnlyURL bool
  25. WallabagURL string
  26. WallabagClientID string
  27. WallabagClientSecret string
  28. WallabagUsername string
  29. WallabagPassword string
  30. NotionEnabled bool
  31. NotionPageID string
  32. NotionToken string
  33. NunuxKeeperEnabled bool
  34. NunuxKeeperURL string
  35. NunuxKeeperAPIKey string
  36. EspialEnabled bool
  37. EspialURL string
  38. EspialAPIKey string
  39. EspialTags string
  40. ReadwiseEnabled bool
  41. ReadwiseAPIKey string
  42. PocketEnabled bool
  43. PocketAccessToken string
  44. PocketConsumerKey string
  45. TelegramBotEnabled bool
  46. TelegramBotToken string
  47. TelegramBotChatID string
  48. LinkdingEnabled bool
  49. LinkdingURL string
  50. LinkdingAPIKey string
  51. LinkdingTags string
  52. LinkdingMarkAsUnread bool
  53. MatrixBotEnabled bool
  54. MatrixBotUser string
  55. MatrixBotPassword string
  56. MatrixBotURL string
  57. MatrixBotChatID string
  58. AppriseEnabled bool
  59. AppriseURL string
  60. AppriseServicesURL string
  61. }
  62. // Merge copy form values to the model.
  63. func (i IntegrationForm) Merge(integration *model.Integration) {
  64. integration.PinboardEnabled = i.PinboardEnabled
  65. integration.PinboardToken = i.PinboardToken
  66. integration.PinboardTags = i.PinboardTags
  67. integration.PinboardMarkAsUnread = i.PinboardMarkAsUnread
  68. integration.InstapaperEnabled = i.InstapaperEnabled
  69. integration.InstapaperUsername = i.InstapaperUsername
  70. integration.InstapaperPassword = i.InstapaperPassword
  71. integration.FeverEnabled = i.FeverEnabled
  72. integration.FeverUsername = i.FeverUsername
  73. integration.GoogleReaderEnabled = i.GoogleReaderEnabled
  74. integration.GoogleReaderUsername = i.GoogleReaderUsername
  75. integration.WallabagEnabled = i.WallabagEnabled
  76. integration.WallabagOnlyURL = i.WallabagOnlyURL
  77. integration.WallabagURL = i.WallabagURL
  78. integration.WallabagClientID = i.WallabagClientID
  79. integration.WallabagClientSecret = i.WallabagClientSecret
  80. integration.WallabagUsername = i.WallabagUsername
  81. integration.WallabagPassword = i.WallabagPassword
  82. integration.NotionEnabled = i.NotionEnabled
  83. integration.NotionPageID = i.NotionPageID
  84. integration.NotionToken = i.NotionToken
  85. integration.NunuxKeeperEnabled = i.NunuxKeeperEnabled
  86. integration.NunuxKeeperURL = i.NunuxKeeperURL
  87. integration.NunuxKeeperAPIKey = i.NunuxKeeperAPIKey
  88. integration.EspialEnabled = i.EspialEnabled
  89. integration.EspialURL = i.EspialURL
  90. integration.EspialAPIKey = i.EspialAPIKey
  91. integration.EspialTags = i.EspialTags
  92. integration.ReadwiseEnabled = i.ReadwiseEnabled
  93. integration.ReadwiseAPIKey = i.ReadwiseAPIKey
  94. integration.PocketEnabled = i.PocketEnabled
  95. integration.PocketAccessToken = i.PocketAccessToken
  96. integration.PocketConsumerKey = i.PocketConsumerKey
  97. integration.TelegramBotEnabled = i.TelegramBotEnabled
  98. integration.TelegramBotToken = i.TelegramBotToken
  99. integration.TelegramBotChatID = i.TelegramBotChatID
  100. integration.LinkdingEnabled = i.LinkdingEnabled
  101. integration.LinkdingURL = i.LinkdingURL
  102. integration.LinkdingAPIKey = i.LinkdingAPIKey
  103. integration.LinkdingTags = i.LinkdingTags
  104. integration.LinkdingMarkAsUnread = i.LinkdingMarkAsUnread
  105. integration.MatrixBotEnabled = i.MatrixBotEnabled
  106. integration.MatrixBotUser = i.MatrixBotUser
  107. integration.MatrixBotPassword = i.MatrixBotPassword
  108. integration.MatrixBotURL = i.MatrixBotURL
  109. integration.MatrixBotChatID = i.MatrixBotChatID
  110. integration.AppriseEnabled = i.AppriseEnabled
  111. integration.AppriseServicesURL = i.AppriseServicesURL
  112. integration.AppriseURL = i.AppriseURL
  113. }
  114. // NewIntegrationForm returns a new IntegrationForm.
  115. func NewIntegrationForm(r *http.Request) *IntegrationForm {
  116. return &IntegrationForm{
  117. PinboardEnabled: r.FormValue("pinboard_enabled") == "1",
  118. PinboardToken: r.FormValue("pinboard_token"),
  119. PinboardTags: r.FormValue("pinboard_tags"),
  120. PinboardMarkAsUnread: r.FormValue("pinboard_mark_as_unread") == "1",
  121. InstapaperEnabled: r.FormValue("instapaper_enabled") == "1",
  122. InstapaperUsername: r.FormValue("instapaper_username"),
  123. InstapaperPassword: r.FormValue("instapaper_password"),
  124. FeverEnabled: r.FormValue("fever_enabled") == "1",
  125. FeverUsername: r.FormValue("fever_username"),
  126. FeverPassword: r.FormValue("fever_password"),
  127. GoogleReaderEnabled: r.FormValue("googlereader_enabled") == "1",
  128. GoogleReaderUsername: r.FormValue("googlereader_username"),
  129. GoogleReaderPassword: r.FormValue("googlereader_password"),
  130. WallabagEnabled: r.FormValue("wallabag_enabled") == "1",
  131. WallabagOnlyURL: r.FormValue("wallabag_only_url") == "1",
  132. WallabagURL: r.FormValue("wallabag_url"),
  133. WallabagClientID: r.FormValue("wallabag_client_id"),
  134. WallabagClientSecret: r.FormValue("wallabag_client_secret"),
  135. WallabagUsername: r.FormValue("wallabag_username"),
  136. WallabagPassword: r.FormValue("wallabag_password"),
  137. NotionEnabled: r.FormValue("notion_enabled") == "1",
  138. NotionPageID: r.FormValue("notion_page_id"),
  139. NotionToken: r.FormValue("notion_token"),
  140. NunuxKeeperEnabled: r.FormValue("nunux_keeper_enabled") == "1",
  141. NunuxKeeperURL: r.FormValue("nunux_keeper_url"),
  142. NunuxKeeperAPIKey: r.FormValue("nunux_keeper_api_key"),
  143. EspialEnabled: r.FormValue("espial_enabled") == "1",
  144. EspialURL: r.FormValue("espial_url"),
  145. EspialAPIKey: r.FormValue("espial_api_key"),
  146. EspialTags: r.FormValue("espial_tags"),
  147. ReadwiseEnabled: r.FormValue("readwise_enabled") == "1",
  148. ReadwiseAPIKey: r.FormValue("readwise_api_key"),
  149. PocketEnabled: r.FormValue("pocket_enabled") == "1",
  150. PocketAccessToken: r.FormValue("pocket_access_token"),
  151. PocketConsumerKey: r.FormValue("pocket_consumer_key"),
  152. TelegramBotEnabled: r.FormValue("telegram_bot_enabled") == "1",
  153. TelegramBotToken: r.FormValue("telegram_bot_token"),
  154. TelegramBotChatID: r.FormValue("telegram_bot_chat_id"),
  155. LinkdingEnabled: r.FormValue("linkding_enabled") == "1",
  156. LinkdingURL: r.FormValue("linkding_url"),
  157. LinkdingAPIKey: r.FormValue("linkding_api_key"),
  158. LinkdingTags: r.FormValue("linkding_tags"),
  159. LinkdingMarkAsUnread: r.FormValue("linkding_mark_as_unread") == "1",
  160. MatrixBotEnabled: r.FormValue("matrix_bot_enabled") == "1",
  161. MatrixBotUser: r.FormValue("matrix_bot_user"),
  162. MatrixBotPassword: r.FormValue("matrix_bot_password"),
  163. MatrixBotURL: r.FormValue("matrix_bot_url"),
  164. MatrixBotChatID: r.FormValue("matrix_bot_chat_id"),
  165. AppriseEnabled: r.FormValue("apprise_enabled") == "1",
  166. AppriseURL: r.FormValue("apprise_url"),
  167. AppriseServicesURL: r.FormValue("apprise_services_url"),
  168. }
  169. }