integration.go 17 KB

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