integration.go 18 KB

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