integration.go 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697
  1. // SPDX-FileCopyrightText: Copyright The Miniflux Authors. All rights reserved.
  2. // SPDX-License-Identifier: Apache-2.0
  3. package storage // import "miniflux.app/v2/internal/storage"
  4. import (
  5. "database/sql"
  6. "errors"
  7. "fmt"
  8. "golang.org/x/crypto/bcrypt"
  9. "miniflux.app/v2/internal/model"
  10. )
  11. // HasDuplicateFeverUsername checks if another user have the same Fever username.
  12. func (s *Storage) HasDuplicateFeverUsername(userID int64, feverUsername string) bool {
  13. query := `SELECT true FROM integrations WHERE user_id != $1 AND fever_username=$2 LIMIT 1`
  14. var result bool
  15. s.db.QueryRow(query, userID, feverUsername).Scan(&result)
  16. return result
  17. }
  18. // HasDuplicateGoogleReaderUsername checks if another user have the same Google Reader username.
  19. func (s *Storage) HasDuplicateGoogleReaderUsername(userID int64, googleReaderUsername string) bool {
  20. query := `SELECT true FROM integrations WHERE user_id != $1 AND googlereader_username=$2 LIMIT 1`
  21. var result bool
  22. s.db.QueryRow(query, userID, googleReaderUsername).Scan(&result)
  23. return result
  24. }
  25. // UserByFeverToken returns a user by using the Fever API token.
  26. func (s *Storage) UserByFeverToken(token string) (*model.User, error) {
  27. query := `
  28. SELECT
  29. users.id, users.username, users.is_admin, users.timezone
  30. FROM
  31. users
  32. LEFT JOIN
  33. integrations ON integrations.user_id=users.id
  34. WHERE
  35. integrations.fever_enabled='t' AND
  36. sha256(convert_to(lower(integrations.fever_token), 'UTF8')) = sha256(convert_to(lower($1), 'UTF8'))
  37. `
  38. var user model.User
  39. err := s.db.QueryRow(query, token).Scan(&user.ID, &user.Username, &user.IsAdmin, &user.Timezone)
  40. switch {
  41. case errors.Is(err, sql.ErrNoRows):
  42. return nil, nil
  43. case err != nil:
  44. return nil, fmt.Errorf("store: unable to fetch user: %v", err)
  45. default:
  46. return &user, nil
  47. }
  48. }
  49. // GoogleReaderUserCheckPassword validates the Google Reader hashed password.
  50. func (s *Storage) GoogleReaderUserCheckPassword(username, password string) error {
  51. var hash string
  52. query := `
  53. SELECT
  54. googlereader_password
  55. FROM
  56. integrations
  57. WHERE
  58. integrations.googlereader_enabled='t' AND integrations.googlereader_username=$1 AND integrations.googlereader_password <> ''
  59. `
  60. err := s.db.QueryRow(query, username).Scan(&hash)
  61. if errors.Is(err, sql.ErrNoRows) {
  62. return fmt.Errorf(`store: unable to find this user: %s`, username)
  63. } else if err != nil {
  64. return fmt.Errorf(`store: unable to fetch user: %v`, err)
  65. }
  66. if err := bcrypt.CompareHashAndPassword([]byte(hash), []byte(password)); err != nil {
  67. return fmt.Errorf(`store: invalid password for "%s" (%v)`, username, err)
  68. }
  69. return nil
  70. }
  71. // GoogleReaderUserGetIntegration returns part of the Google Reader parts of the integration struct.
  72. func (s *Storage) GoogleReaderUserGetIntegration(username string) (*model.Integration, error) {
  73. var integration model.Integration
  74. query := `
  75. SELECT
  76. user_id,
  77. googlereader_enabled,
  78. googlereader_username,
  79. googlereader_password
  80. FROM
  81. integrations
  82. WHERE
  83. integrations.googlereader_enabled='t' AND integrations.googlereader_username=$1 AND integrations.googlereader_password <> ''
  84. `
  85. err := s.db.QueryRow(query, username).Scan(&integration.UserID, &integration.GoogleReaderEnabled, &integration.GoogleReaderUsername, &integration.GoogleReaderPassword)
  86. if errors.Is(err, sql.ErrNoRows) {
  87. return &integration, fmt.Errorf(`store: unable to find this user: %s`, username)
  88. } else if err != nil {
  89. return &integration, fmt.Errorf(`store: unable to fetch user: %v`, err)
  90. }
  91. return &integration, nil
  92. }
  93. // Integration returns user integration settings.
  94. func (s *Storage) Integration(userID int64) (*model.Integration, error) {
  95. query := `
  96. SELECT
  97. user_id,
  98. pinboard_enabled,
  99. pinboard_token,
  100. pinboard_tags,
  101. pinboard_mark_as_unread,
  102. instapaper_enabled,
  103. instapaper_username,
  104. instapaper_password,
  105. fever_enabled,
  106. fever_username,
  107. fever_token,
  108. googlereader_enabled,
  109. googlereader_username,
  110. googlereader_password,
  111. wallabag_enabled,
  112. wallabag_only_url,
  113. wallabag_url,
  114. wallabag_client_id,
  115. wallabag_client_secret,
  116. wallabag_username,
  117. wallabag_password,
  118. wallabag_tags,
  119. notion_enabled,
  120. notion_token,
  121. notion_page_id,
  122. nunux_keeper_enabled,
  123. nunux_keeper_url,
  124. nunux_keeper_api_key,
  125. espial_enabled,
  126. espial_url,
  127. espial_api_key,
  128. espial_tags,
  129. readwise_enabled,
  130. readwise_api_key,
  131. telegram_bot_enabled,
  132. telegram_bot_token,
  133. telegram_bot_chat_id,
  134. telegram_bot_topic_id,
  135. telegram_bot_disable_web_page_preview,
  136. telegram_bot_disable_notification,
  137. telegram_bot_disable_buttons,
  138. linkace_enabled,
  139. linkace_url,
  140. linkace_api_key,
  141. linkace_tags,
  142. linkace_is_private,
  143. linkace_check_disabled,
  144. linkding_enabled,
  145. linkding_url,
  146. linkding_api_key,
  147. linkding_tags,
  148. linkding_mark_as_unread,
  149. linkwarden_enabled,
  150. linkwarden_url,
  151. linkwarden_api_key,
  152. linkwarden_collection_id,
  153. matrix_bot_enabled,
  154. matrix_bot_user,
  155. matrix_bot_password,
  156. matrix_bot_url,
  157. matrix_bot_chat_id,
  158. apprise_enabled,
  159. apprise_url,
  160. apprise_services_url,
  161. readeck_enabled,
  162. readeck_url,
  163. readeck_api_key,
  164. readeck_labels,
  165. readeck_only_url,
  166. readeck_push_enabled,
  167. shiori_enabled,
  168. shiori_url,
  169. shiori_username,
  170. shiori_password,
  171. shaarli_enabled,
  172. shaarli_url,
  173. shaarli_api_secret,
  174. webhook_enabled,
  175. webhook_url,
  176. webhook_secret,
  177. rssbridge_enabled,
  178. rssbridge_url,
  179. omnivore_enabled,
  180. omnivore_api_key,
  181. omnivore_url,
  182. raindrop_enabled,
  183. raindrop_token,
  184. raindrop_collection_id,
  185. raindrop_tags,
  186. betula_enabled,
  187. betula_url,
  188. betula_token,
  189. ntfy_enabled,
  190. ntfy_topic,
  191. ntfy_url,
  192. ntfy_api_token,
  193. ntfy_username,
  194. ntfy_password,
  195. ntfy_icon_url,
  196. ntfy_internal_links,
  197. cubox_enabled,
  198. cubox_api_link,
  199. discord_enabled,
  200. discord_webhook_link,
  201. slack_enabled,
  202. slack_webhook_link,
  203. pushover_enabled,
  204. pushover_user,
  205. pushover_token,
  206. pushover_device,
  207. pushover_prefix,
  208. rssbridge_token,
  209. karakeep_enabled,
  210. karakeep_api_key,
  211. karakeep_url,
  212. karakeep_tags,
  213. linktaco_enabled,
  214. linktaco_api_token,
  215. linktaco_org_slug,
  216. linktaco_tags,
  217. linktaco_visibility,
  218. archiveorg_enabled,
  219. gotify_enabled,
  220. gotify_url,
  221. gotify_token,
  222. gotify_priority
  223. FROM
  224. integrations
  225. WHERE
  226. user_id=$1
  227. `
  228. var integration model.Integration
  229. err := s.db.QueryRow(query, userID).Scan(
  230. &integration.UserID,
  231. &integration.PinboardEnabled,
  232. &integration.PinboardToken,
  233. &integration.PinboardTags,
  234. &integration.PinboardMarkAsUnread,
  235. &integration.InstapaperEnabled,
  236. &integration.InstapaperUsername,
  237. &integration.InstapaperPassword,
  238. &integration.FeverEnabled,
  239. &integration.FeverUsername,
  240. &integration.FeverToken,
  241. &integration.GoogleReaderEnabled,
  242. &integration.GoogleReaderUsername,
  243. &integration.GoogleReaderPassword,
  244. &integration.WallabagEnabled,
  245. &integration.WallabagOnlyURL,
  246. &integration.WallabagURL,
  247. &integration.WallabagClientID,
  248. &integration.WallabagClientSecret,
  249. &integration.WallabagUsername,
  250. &integration.WallabagPassword,
  251. &integration.WallabagTags,
  252. &integration.NotionEnabled,
  253. &integration.NotionToken,
  254. &integration.NotionPageID,
  255. &integration.NunuxKeeperEnabled,
  256. &integration.NunuxKeeperURL,
  257. &integration.NunuxKeeperAPIKey,
  258. &integration.EspialEnabled,
  259. &integration.EspialURL,
  260. &integration.EspialAPIKey,
  261. &integration.EspialTags,
  262. &integration.ReadwiseEnabled,
  263. &integration.ReadwiseAPIKey,
  264. &integration.TelegramBotEnabled,
  265. &integration.TelegramBotToken,
  266. &integration.TelegramBotChatID,
  267. &integration.TelegramBotTopicID,
  268. &integration.TelegramBotDisableWebPagePreview,
  269. &integration.TelegramBotDisableNotification,
  270. &integration.TelegramBotDisableButtons,
  271. &integration.LinkAceEnabled,
  272. &integration.LinkAceURL,
  273. &integration.LinkAceAPIKey,
  274. &integration.LinkAceTags,
  275. &integration.LinkAcePrivate,
  276. &integration.LinkAceCheckDisabled,
  277. &integration.LinkdingEnabled,
  278. &integration.LinkdingURL,
  279. &integration.LinkdingAPIKey,
  280. &integration.LinkdingTags,
  281. &integration.LinkdingMarkAsUnread,
  282. &integration.LinkwardenEnabled,
  283. &integration.LinkwardenURL,
  284. &integration.LinkwardenAPIKey,
  285. &integration.LinkwardenCollectionID,
  286. &integration.MatrixBotEnabled,
  287. &integration.MatrixBotUser,
  288. &integration.MatrixBotPassword,
  289. &integration.MatrixBotURL,
  290. &integration.MatrixBotChatID,
  291. &integration.AppriseEnabled,
  292. &integration.AppriseURL,
  293. &integration.AppriseServicesURL,
  294. &integration.ReadeckEnabled,
  295. &integration.ReadeckURL,
  296. &integration.ReadeckAPIKey,
  297. &integration.ReadeckLabels,
  298. &integration.ReadeckOnlyURL,
  299. &integration.ReadeckPushEnabled,
  300. &integration.ShioriEnabled,
  301. &integration.ShioriURL,
  302. &integration.ShioriUsername,
  303. &integration.ShioriPassword,
  304. &integration.ShaarliEnabled,
  305. &integration.ShaarliURL,
  306. &integration.ShaarliAPISecret,
  307. &integration.WebhookEnabled,
  308. &integration.WebhookURL,
  309. &integration.WebhookSecret,
  310. &integration.RSSBridgeEnabled,
  311. &integration.RSSBridgeURL,
  312. &integration.OmnivoreEnabled,
  313. &integration.OmnivoreAPIKey,
  314. &integration.OmnivoreURL,
  315. &integration.RaindropEnabled,
  316. &integration.RaindropToken,
  317. &integration.RaindropCollectionID,
  318. &integration.RaindropTags,
  319. &integration.BetulaEnabled,
  320. &integration.BetulaURL,
  321. &integration.BetulaToken,
  322. &integration.NtfyEnabled,
  323. &integration.NtfyTopic,
  324. &integration.NtfyURL,
  325. &integration.NtfyAPIToken,
  326. &integration.NtfyUsername,
  327. &integration.NtfyPassword,
  328. &integration.NtfyIconURL,
  329. &integration.NtfyInternalLinks,
  330. &integration.CuboxEnabled,
  331. &integration.CuboxAPILink,
  332. &integration.DiscordEnabled,
  333. &integration.DiscordWebhookLink,
  334. &integration.SlackEnabled,
  335. &integration.SlackWebhookLink,
  336. &integration.PushoverEnabled,
  337. &integration.PushoverUser,
  338. &integration.PushoverToken,
  339. &integration.PushoverDevice,
  340. &integration.PushoverPrefix,
  341. &integration.RSSBridgeToken,
  342. &integration.KarakeepEnabled,
  343. &integration.KarakeepAPIKey,
  344. &integration.KarakeepURL,
  345. &integration.KarakeepTags,
  346. &integration.LinktacoEnabled,
  347. &integration.LinktacoAPIToken,
  348. &integration.LinktacoOrgSlug,
  349. &integration.LinktacoTags,
  350. &integration.LinktacoVisibility,
  351. &integration.ArchiveorgEnabled,
  352. &integration.GotifyEnabled,
  353. &integration.GotifyURL,
  354. &integration.GotifyToken,
  355. &integration.GotifyPriority,
  356. )
  357. switch {
  358. case errors.Is(err, sql.ErrNoRows):
  359. return &integration, nil
  360. case err != nil:
  361. return &integration, fmt.Errorf(`store: unable to fetch integration row: %v`, err)
  362. default:
  363. return &integration, nil
  364. }
  365. }
  366. // UpdateIntegration saves user integration settings.
  367. func (s *Storage) UpdateIntegration(integration *model.Integration) error {
  368. query := `
  369. UPDATE
  370. integrations
  371. SET
  372. pinboard_enabled=$1,
  373. pinboard_token=$2,
  374. pinboard_tags=$3,
  375. pinboard_mark_as_unread=$4,
  376. instapaper_enabled=$5,
  377. instapaper_username=$6,
  378. instapaper_password=$7,
  379. fever_enabled=$8,
  380. fever_username=$9,
  381. fever_token=$10,
  382. wallabag_enabled=$11,
  383. wallabag_only_url=$12,
  384. wallabag_url=$13,
  385. wallabag_client_id=$14,
  386. wallabag_client_secret=$15,
  387. wallabag_username=$16,
  388. wallabag_password=$17,
  389. wallabag_tags=$18,
  390. nunux_keeper_enabled=$19,
  391. nunux_keeper_url=$20,
  392. nunux_keeper_api_key=$21,
  393. googlereader_enabled=$22,
  394. googlereader_username=$23,
  395. googlereader_password=$24,
  396. telegram_bot_enabled=$25,
  397. telegram_bot_token=$26,
  398. telegram_bot_chat_id=$27,
  399. telegram_bot_topic_id=$28,
  400. telegram_bot_disable_web_page_preview=$29,
  401. telegram_bot_disable_notification=$30,
  402. telegram_bot_disable_buttons=$31,
  403. espial_enabled=$32,
  404. espial_url=$33,
  405. espial_api_key=$34,
  406. espial_tags=$35,
  407. linkace_enabled=$36,
  408. linkace_url=$37,
  409. linkace_api_key=$38,
  410. linkace_tags=$39,
  411. linkace_is_private=$40,
  412. linkace_check_disabled=$41,
  413. linkding_enabled=$42,
  414. linkding_url=$43,
  415. linkding_api_key=$44,
  416. linkding_tags=$45,
  417. linkding_mark_as_unread=$46,
  418. matrix_bot_enabled=$47,
  419. matrix_bot_user=$48,
  420. matrix_bot_password=$49,
  421. matrix_bot_url=$50,
  422. matrix_bot_chat_id=$51,
  423. notion_enabled=$52,
  424. notion_token=$53,
  425. notion_page_id=$54,
  426. readwise_enabled=$55,
  427. readwise_api_key=$56,
  428. apprise_enabled=$57,
  429. apprise_url=$58,
  430. apprise_services_url=$59,
  431. readeck_enabled=$60,
  432. readeck_url=$61,
  433. readeck_api_key=$62,
  434. readeck_labels=$63,
  435. readeck_only_url=$64,
  436. shiori_enabled=$65,
  437. shiori_url=$66,
  438. shiori_username=$67,
  439. shiori_password=$68,
  440. shaarli_enabled=$69,
  441. shaarli_url=$70,
  442. shaarli_api_secret=$71,
  443. webhook_enabled=$72,
  444. webhook_url=$73,
  445. webhook_secret=$74,
  446. rssbridge_enabled=$75,
  447. rssbridge_url=$76,
  448. omnivore_enabled=$77,
  449. omnivore_api_key=$78,
  450. omnivore_url=$79,
  451. linkwarden_enabled=$80,
  452. linkwarden_url=$81,
  453. linkwarden_api_key=$82,
  454. raindrop_enabled=$83,
  455. raindrop_token=$84,
  456. raindrop_collection_id=$85,
  457. raindrop_tags=$86,
  458. betula_enabled=$87,
  459. betula_url=$88,
  460. betula_token=$89,
  461. ntfy_enabled=$90,
  462. ntfy_topic=$91,
  463. ntfy_url=$92,
  464. ntfy_api_token=$93,
  465. ntfy_username=$94,
  466. ntfy_password=$95,
  467. ntfy_icon_url=$96,
  468. ntfy_internal_links=$97,
  469. cubox_enabled=$98,
  470. cubox_api_link=$99,
  471. discord_enabled=$100,
  472. discord_webhook_link=$101,
  473. slack_enabled=$102,
  474. slack_webhook_link=$103,
  475. pushover_enabled=$104,
  476. pushover_user=$105,
  477. pushover_token=$106,
  478. pushover_device=$107,
  479. pushover_prefix=$108,
  480. rssbridge_token=$109,
  481. karakeep_enabled=$110,
  482. karakeep_api_key=$111,
  483. karakeep_url=$112,
  484. karakeep_tags=$113,
  485. linktaco_enabled=$114,
  486. linktaco_api_token=$115,
  487. linktaco_org_slug=$116,
  488. linktaco_tags=$117,
  489. linktaco_visibility=$118,
  490. archiveorg_enabled=$119,
  491. linkwarden_collection_id=$120,
  492. readeck_push_enabled=$121,
  493. gotify_enabled=$122,
  494. gotify_url=$123,
  495. gotify_token=$124,
  496. gotify_priority=$125
  497. WHERE
  498. user_id=$126
  499. `
  500. _, err := s.db.Exec(
  501. query,
  502. integration.PinboardEnabled,
  503. integration.PinboardToken,
  504. integration.PinboardTags,
  505. integration.PinboardMarkAsUnread,
  506. integration.InstapaperEnabled,
  507. integration.InstapaperUsername,
  508. integration.InstapaperPassword,
  509. integration.FeverEnabled,
  510. integration.FeverUsername,
  511. integration.FeverToken,
  512. integration.WallabagEnabled,
  513. integration.WallabagOnlyURL,
  514. integration.WallabagURL,
  515. integration.WallabagClientID,
  516. integration.WallabagClientSecret,
  517. integration.WallabagUsername,
  518. integration.WallabagPassword,
  519. integration.WallabagTags,
  520. integration.NunuxKeeperEnabled,
  521. integration.NunuxKeeperURL,
  522. integration.NunuxKeeperAPIKey,
  523. integration.GoogleReaderEnabled,
  524. integration.GoogleReaderUsername,
  525. integration.GoogleReaderPassword,
  526. integration.TelegramBotEnabled,
  527. integration.TelegramBotToken,
  528. integration.TelegramBotChatID,
  529. integration.TelegramBotTopicID,
  530. integration.TelegramBotDisableWebPagePreview,
  531. integration.TelegramBotDisableNotification,
  532. integration.TelegramBotDisableButtons,
  533. integration.EspialEnabled,
  534. integration.EspialURL,
  535. integration.EspialAPIKey,
  536. integration.EspialTags,
  537. integration.LinkAceEnabled,
  538. integration.LinkAceURL,
  539. integration.LinkAceAPIKey,
  540. integration.LinkAceTags,
  541. integration.LinkAcePrivate,
  542. integration.LinkAceCheckDisabled,
  543. integration.LinkdingEnabled,
  544. integration.LinkdingURL,
  545. integration.LinkdingAPIKey,
  546. integration.LinkdingTags,
  547. integration.LinkdingMarkAsUnread,
  548. integration.MatrixBotEnabled,
  549. integration.MatrixBotUser,
  550. integration.MatrixBotPassword,
  551. integration.MatrixBotURL,
  552. integration.MatrixBotChatID,
  553. integration.NotionEnabled,
  554. integration.NotionToken,
  555. integration.NotionPageID,
  556. integration.ReadwiseEnabled,
  557. integration.ReadwiseAPIKey,
  558. integration.AppriseEnabled,
  559. integration.AppriseURL,
  560. integration.AppriseServicesURL,
  561. integration.ReadeckEnabled,
  562. integration.ReadeckURL,
  563. integration.ReadeckAPIKey,
  564. integration.ReadeckLabels,
  565. integration.ReadeckOnlyURL,
  566. integration.ShioriEnabled,
  567. integration.ShioriURL,
  568. integration.ShioriUsername,
  569. integration.ShioriPassword,
  570. integration.ShaarliEnabled,
  571. integration.ShaarliURL,
  572. integration.ShaarliAPISecret,
  573. integration.WebhookEnabled,
  574. integration.WebhookURL,
  575. integration.WebhookSecret,
  576. integration.RSSBridgeEnabled,
  577. integration.RSSBridgeURL,
  578. integration.OmnivoreEnabled,
  579. integration.OmnivoreAPIKey,
  580. integration.OmnivoreURL,
  581. integration.LinkwardenEnabled,
  582. integration.LinkwardenURL,
  583. integration.LinkwardenAPIKey,
  584. integration.RaindropEnabled,
  585. integration.RaindropToken,
  586. integration.RaindropCollectionID,
  587. integration.RaindropTags,
  588. integration.BetulaEnabled,
  589. integration.BetulaURL,
  590. integration.BetulaToken,
  591. integration.NtfyEnabled,
  592. integration.NtfyTopic,
  593. integration.NtfyURL,
  594. integration.NtfyAPIToken,
  595. integration.NtfyUsername,
  596. integration.NtfyPassword,
  597. integration.NtfyIconURL,
  598. integration.NtfyInternalLinks,
  599. integration.CuboxEnabled,
  600. integration.CuboxAPILink,
  601. integration.DiscordEnabled,
  602. integration.DiscordWebhookLink,
  603. integration.SlackEnabled,
  604. integration.SlackWebhookLink,
  605. integration.PushoverEnabled,
  606. integration.PushoverUser,
  607. integration.PushoverToken,
  608. integration.PushoverDevice,
  609. integration.PushoverPrefix,
  610. integration.RSSBridgeToken,
  611. integration.KarakeepEnabled,
  612. integration.KarakeepAPIKey,
  613. integration.KarakeepURL,
  614. integration.KarakeepTags,
  615. integration.LinktacoEnabled,
  616. integration.LinktacoAPIToken,
  617. integration.LinktacoOrgSlug,
  618. integration.LinktacoTags,
  619. integration.LinktacoVisibility,
  620. integration.ArchiveorgEnabled,
  621. integration.LinkwardenCollectionID,
  622. integration.ReadeckPushEnabled,
  623. integration.GotifyEnabled,
  624. integration.GotifyURL,
  625. integration.GotifyToken,
  626. integration.GotifyPriority,
  627. integration.UserID,
  628. )
  629. if err != nil {
  630. return fmt.Errorf(`store: unable to update integration record: %v`, err)
  631. }
  632. return nil
  633. }
  634. // HasSaveEntry returns true if the given user can save articles to third-parties.
  635. func (s *Storage) HasSaveEntry(userID int64) (result bool) {
  636. query := `
  637. SELECT
  638. true
  639. FROM
  640. integrations
  641. WHERE
  642. user_id=$1
  643. AND
  644. (
  645. pinboard_enabled='t' OR
  646. instapaper_enabled='t' OR
  647. wallabag_enabled='t' OR
  648. notion_enabled='t' OR
  649. nunux_keeper_enabled='t' OR
  650. espial_enabled='t' OR
  651. readwise_enabled='t' OR
  652. linkace_enabled='t' OR
  653. linkding_enabled='t' OR
  654. linktaco_enabled='t' OR
  655. linkwarden_enabled='t' OR
  656. apprise_enabled='t' OR
  657. shiori_enabled='t' OR
  658. readeck_enabled='t' OR
  659. shaarli_enabled='t' OR
  660. webhook_enabled='t' OR
  661. omnivore_enabled='t' OR
  662. karakeep_enabled='t' OR
  663. raindrop_enabled='t' OR
  664. betula_enabled='t' OR
  665. cubox_enabled='t' OR
  666. discord_enabled='t' OR
  667. slack_enabled='t' OR
  668. archiveorg_enabled='t'
  669. )
  670. `
  671. if err := s.db.QueryRow(query, userID).Scan(&result); err != nil {
  672. result = false
  673. }
  674. return result
  675. }