integration.go 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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. MatrixBotEnabled bool
  48. MatrixBotUser string
  49. MatrixBotPassword string
  50. MatrixBotURL string
  51. MatrixBotChatID string
  52. }
  53. // Merge copy form values to the model.
  54. func (i IntegrationForm) Merge(integration *model.Integration) {
  55. integration.PinboardEnabled = i.PinboardEnabled
  56. integration.PinboardToken = i.PinboardToken
  57. integration.PinboardTags = i.PinboardTags
  58. integration.PinboardMarkAsUnread = i.PinboardMarkAsUnread
  59. integration.InstapaperEnabled = i.InstapaperEnabled
  60. integration.InstapaperUsername = i.InstapaperUsername
  61. integration.InstapaperPassword = i.InstapaperPassword
  62. integration.FeverEnabled = i.FeverEnabled
  63. integration.FeverUsername = i.FeverUsername
  64. integration.GoogleReaderEnabled = i.GoogleReaderEnabled
  65. integration.GoogleReaderUsername = i.GoogleReaderUsername
  66. integration.WallabagEnabled = i.WallabagEnabled
  67. integration.WallabagOnlyURL = i.WallabagOnlyURL
  68. integration.WallabagURL = i.WallabagURL
  69. integration.WallabagClientID = i.WallabagClientID
  70. integration.WallabagClientSecret = i.WallabagClientSecret
  71. integration.WallabagUsername = i.WallabagUsername
  72. integration.WallabagPassword = i.WallabagPassword
  73. integration.NunuxKeeperEnabled = i.NunuxKeeperEnabled
  74. integration.NunuxKeeperURL = i.NunuxKeeperURL
  75. integration.NunuxKeeperAPIKey = i.NunuxKeeperAPIKey
  76. integration.EspialEnabled = i.EspialEnabled
  77. integration.EspialURL = i.EspialURL
  78. integration.EspialAPIKey = i.EspialAPIKey
  79. integration.EspialTags = i.EspialTags
  80. integration.PocketEnabled = i.PocketEnabled
  81. integration.PocketAccessToken = i.PocketAccessToken
  82. integration.PocketConsumerKey = i.PocketConsumerKey
  83. integration.TelegramBotEnabled = i.TelegramBotEnabled
  84. integration.TelegramBotToken = i.TelegramBotToken
  85. integration.TelegramBotChatID = i.TelegramBotChatID
  86. integration.LinkdingEnabled = i.LinkdingEnabled
  87. integration.LinkdingURL = i.LinkdingURL
  88. integration.LinkdingAPIKey = i.LinkdingAPIKey
  89. integration.MatrixBotEnabled = i.MatrixBotEnabled
  90. integration.MatrixBotUser = i.MatrixBotUser
  91. integration.MatrixBotPassword = i.MatrixBotPassword
  92. integration.MatrixBotURL = i.MatrixBotURL
  93. integration.MatrixBotChatID = i.MatrixBotChatID
  94. }
  95. // NewIntegrationForm returns a new IntegrationForm.
  96. func NewIntegrationForm(r *http.Request) *IntegrationForm {
  97. return &IntegrationForm{
  98. PinboardEnabled: r.FormValue("pinboard_enabled") == "1",
  99. PinboardToken: r.FormValue("pinboard_token"),
  100. PinboardTags: r.FormValue("pinboard_tags"),
  101. PinboardMarkAsUnread: r.FormValue("pinboard_mark_as_unread") == "1",
  102. InstapaperEnabled: r.FormValue("instapaper_enabled") == "1",
  103. InstapaperUsername: r.FormValue("instapaper_username"),
  104. InstapaperPassword: r.FormValue("instapaper_password"),
  105. FeverEnabled: r.FormValue("fever_enabled") == "1",
  106. FeverUsername: r.FormValue("fever_username"),
  107. FeverPassword: r.FormValue("fever_password"),
  108. GoogleReaderEnabled: r.FormValue("googlereader_enabled") == "1",
  109. GoogleReaderUsername: r.FormValue("googlereader_username"),
  110. GoogleReaderPassword: r.FormValue("googlereader_password"),
  111. WallabagEnabled: r.FormValue("wallabag_enabled") == "1",
  112. WallabagOnlyURL: r.FormValue("wallabag_only_url") == "1",
  113. WallabagURL: r.FormValue("wallabag_url"),
  114. WallabagClientID: r.FormValue("wallabag_client_id"),
  115. WallabagClientSecret: r.FormValue("wallabag_client_secret"),
  116. WallabagUsername: r.FormValue("wallabag_username"),
  117. WallabagPassword: r.FormValue("wallabag_password"),
  118. NunuxKeeperEnabled: r.FormValue("nunux_keeper_enabled") == "1",
  119. NunuxKeeperURL: r.FormValue("nunux_keeper_url"),
  120. NunuxKeeperAPIKey: r.FormValue("nunux_keeper_api_key"),
  121. EspialEnabled: r.FormValue("espial_enabled") == "1",
  122. EspialURL: r.FormValue("espial_url"),
  123. EspialAPIKey: r.FormValue("espial_api_key"),
  124. EspialTags: r.FormValue("espial_tags"),
  125. PocketEnabled: r.FormValue("pocket_enabled") == "1",
  126. PocketAccessToken: r.FormValue("pocket_access_token"),
  127. PocketConsumerKey: r.FormValue("pocket_consumer_key"),
  128. TelegramBotEnabled: r.FormValue("telegram_bot_enabled") == "1",
  129. TelegramBotToken: r.FormValue("telegram_bot_token"),
  130. TelegramBotChatID: r.FormValue("telegram_bot_chat_id"),
  131. LinkdingEnabled: r.FormValue("linkding_enabled") == "1",
  132. LinkdingURL: r.FormValue("linkding_url"),
  133. LinkdingAPIKey: r.FormValue("linkding_api_key"),
  134. MatrixBotEnabled: r.FormValue("matrix_bot_enabled") == "1",
  135. MatrixBotUser: r.FormValue("matrix_bot_user"),
  136. MatrixBotPassword: r.FormValue("matrix_bot_password"),
  137. MatrixBotURL: r.FormValue("matrix_bot_url"),
  138. MatrixBotChatID: r.FormValue("matrix_bot_chat_id"),
  139. }
  140. }