integration.go 18 KB

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