integration.go 18 KB

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