2023-06-19 23:42:47 +02:00
|
|
|
// SPDX-FileCopyrightText: Copyright The Miniflux Authors. All rights reserved.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0
|
2017-12-03 04:32:14 +01:00
|
|
|
|
2023-08-11 04:46:45 +02:00
|
|
|
package storage // import "miniflux.app/v2/internal/storage"
|
2017-12-03 04:32:14 +01:00
|
|
|
|
|
|
|
import (
|
|
|
|
"database/sql"
|
|
|
|
"fmt"
|
|
|
|
|
2022-01-03 04:45:12 +01:00
|
|
|
"golang.org/x/crypto/bcrypt"
|
2023-08-11 04:46:45 +02:00
|
|
|
"miniflux.app/v2/internal/model"
|
2017-12-03 04:32:14 +01:00
|
|
|
)
|
|
|
|
|
2022-01-03 05:12:29 +01:00
|
|
|
// HasDuplicateFeverUsername checks if another user have the same Fever username.
|
2017-12-29 23:38:43 +01:00
|
|
|
func (s *Storage) HasDuplicateFeverUsername(userID int64, feverUsername string) bool {
|
2019-10-30 06:48:07 +01:00
|
|
|
query := `SELECT true FROM integrations WHERE user_id != $1 AND fever_username=$2`
|
|
|
|
var result bool
|
2017-12-29 23:38:43 +01:00
|
|
|
s.db.QueryRow(query, userID, feverUsername).Scan(&result)
|
2019-10-30 06:48:07 +01:00
|
|
|
return result
|
2017-12-29 23:38:43 +01:00
|
|
|
}
|
|
|
|
|
2022-01-03 05:12:29 +01:00
|
|
|
// HasDuplicateGoogleReaderUsername checks if another user have the same Google Reader username.
|
2022-01-03 04:45:12 +01:00
|
|
|
func (s *Storage) HasDuplicateGoogleReaderUsername(userID int64, googleReaderUsername string) bool {
|
|
|
|
query := `SELECT true FROM integrations WHERE user_id != $1 AND googlereader_username=$2`
|
|
|
|
var result bool
|
|
|
|
s.db.QueryRow(query, userID, googleReaderUsername).Scan(&result)
|
|
|
|
return result
|
|
|
|
}
|
|
|
|
|
2017-12-04 02:44:27 +01:00
|
|
|
// UserByFeverToken returns a user by using the Fever API token.
|
|
|
|
func (s *Storage) UserByFeverToken(token string) (*model.User, error) {
|
|
|
|
query := `
|
|
|
|
SELECT
|
2023-10-15 05:11:17 +02:00
|
|
|
users.id, users.username, users.is_admin, users.timezone
|
2022-01-03 05:12:29 +01:00
|
|
|
FROM
|
|
|
|
users
|
|
|
|
LEFT JOIN
|
|
|
|
integrations ON integrations.user_id=users.id
|
2019-10-30 06:48:07 +01:00
|
|
|
WHERE
|
|
|
|
integrations.fever_enabled='t' AND lower(integrations.fever_token)=lower($1)
|
2017-12-04 02:44:27 +01:00
|
|
|
`
|
|
|
|
|
|
|
|
var user model.User
|
2023-10-15 05:11:17 +02:00
|
|
|
err := s.db.QueryRow(query, token).Scan(&user.ID, &user.Username, &user.IsAdmin, &user.Timezone)
|
2017-12-04 02:44:27 +01:00
|
|
|
switch {
|
|
|
|
case err == sql.ErrNoRows:
|
|
|
|
return nil, nil
|
|
|
|
case err != nil:
|
2022-01-03 05:12:29 +01:00
|
|
|
return nil, fmt.Errorf("store: unable to fetch user: %v", err)
|
2019-10-30 06:48:07 +01:00
|
|
|
default:
|
|
|
|
return &user, nil
|
2017-12-04 02:44:27 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-03 05:12:29 +01:00
|
|
|
// GoogleReaderUserCheckPassword validates the Google Reader hashed password.
|
2022-01-03 04:45:12 +01:00
|
|
|
func (s *Storage) GoogleReaderUserCheckPassword(username, password string) error {
|
|
|
|
var hash string
|
|
|
|
|
|
|
|
query := `
|
|
|
|
SELECT
|
|
|
|
googlereader_password
|
2022-01-03 05:12:29 +01:00
|
|
|
FROM
|
|
|
|
integrations
|
2022-01-03 04:45:12 +01:00
|
|
|
WHERE
|
|
|
|
integrations.googlereader_enabled='t' AND integrations.googlereader_username=$1
|
|
|
|
`
|
|
|
|
|
|
|
|
err := s.db.QueryRow(query, username).Scan(&hash)
|
|
|
|
if err == sql.ErrNoRows {
|
|
|
|
return fmt.Errorf(`store: unable to find this user: %s`, username)
|
|
|
|
} else if err != nil {
|
|
|
|
return fmt.Errorf(`store: unable to fetch user: %v`, err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if err := bcrypt.CompareHashAndPassword([]byte(hash), []byte(password)); err != nil {
|
|
|
|
return fmt.Errorf(`store: invalid password for "%s" (%v)`, username, err)
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2022-01-03 05:12:29 +01:00
|
|
|
// GoogleReaderUserGetIntegration returns part of the Google Reader parts of the integration struct.
|
2022-01-03 04:45:12 +01:00
|
|
|
func (s *Storage) GoogleReaderUserGetIntegration(username string) (*model.Integration, error) {
|
|
|
|
var integration model.Integration
|
|
|
|
|
|
|
|
query := `
|
|
|
|
SELECT
|
|
|
|
user_id,
|
|
|
|
googlereader_enabled,
|
|
|
|
googlereader_username,
|
|
|
|
googlereader_password
|
2022-01-03 05:12:29 +01:00
|
|
|
FROM
|
|
|
|
integrations
|
2022-01-03 04:45:12 +01:00
|
|
|
WHERE
|
|
|
|
integrations.googlereader_enabled='t' AND integrations.googlereader_username=$1
|
|
|
|
`
|
|
|
|
|
|
|
|
err := s.db.QueryRow(query, username).Scan(&integration.UserID, &integration.GoogleReaderEnabled, &integration.GoogleReaderUsername, &integration.GoogleReaderPassword)
|
|
|
|
if err == sql.ErrNoRows {
|
|
|
|
return &integration, fmt.Errorf(`store: unable to find this user: %s`, username)
|
|
|
|
} else if err != nil {
|
|
|
|
return &integration, fmt.Errorf(`store: unable to fetch user: %v`, err)
|
|
|
|
}
|
|
|
|
|
|
|
|
return &integration, nil
|
|
|
|
}
|
|
|
|
|
2017-12-03 04:32:14 +01:00
|
|
|
// Integration returns user integration settings.
|
|
|
|
func (s *Storage) Integration(userID int64) (*model.Integration, error) {
|
2019-10-30 06:48:07 +01:00
|
|
|
query := `
|
|
|
|
SELECT
|
2017-12-03 04:32:14 +01:00
|
|
|
user_id,
|
|
|
|
pinboard_enabled,
|
|
|
|
pinboard_token,
|
|
|
|
pinboard_tags,
|
2017-12-03 06:12:03 +01:00
|
|
|
pinboard_mark_as_unread,
|
|
|
|
instapaper_enabled,
|
|
|
|
instapaper_username,
|
2017-12-04 02:44:27 +01:00
|
|
|
instapaper_password,
|
|
|
|
fever_enabled,
|
|
|
|
fever_username,
|
2017-12-19 05:52:46 +01:00
|
|
|
fever_token,
|
2022-01-03 04:45:12 +01:00
|
|
|
googlereader_enabled,
|
|
|
|
googlereader_username,
|
|
|
|
googlereader_password,
|
2017-12-19 05:52:46 +01:00
|
|
|
wallabag_enabled,
|
2022-09-19 01:52:28 +02:00
|
|
|
wallabag_only_url,
|
2017-12-19 05:52:46 +01:00
|
|
|
wallabag_url,
|
|
|
|
wallabag_client_id,
|
|
|
|
wallabag_client_secret,
|
|
|
|
wallabag_username,
|
2018-02-25 20:49:08 +01:00
|
|
|
wallabag_password,
|
2023-07-08 00:20:14 +02:00
|
|
|
notion_enabled,
|
|
|
|
notion_token,
|
|
|
|
notion_page_id,
|
2018-02-25 20:49:08 +01:00
|
|
|
nunux_keeper_enabled,
|
|
|
|
nunux_keeper_url,
|
2018-05-20 22:31:56 +02:00
|
|
|
nunux_keeper_api_key,
|
2022-04-21 04:44:47 +02:00
|
|
|
espial_enabled,
|
|
|
|
espial_url,
|
|
|
|
espial_api_key,
|
|
|
|
espial_tags,
|
2023-07-28 05:51:44 +02:00
|
|
|
readwise_enabled,
|
|
|
|
readwise_api_key,
|
2018-05-20 22:31:56 +02:00
|
|
|
pocket_enabled,
|
|
|
|
pocket_access_token,
|
2021-09-08 05:04:22 +02:00
|
|
|
pocket_consumer_key,
|
|
|
|
telegram_bot_enabled,
|
|
|
|
telegram_bot_token,
|
2022-05-23 17:53:06 +02:00
|
|
|
telegram_bot_chat_id,
|
2023-09-10 20:22:32 +02:00
|
|
|
telegram_bot_topic_id,
|
|
|
|
telegram_bot_disable_web_page_preview,
|
|
|
|
telegram_bot_disable_notification,
|
2023-09-28 05:02:22 +02:00
|
|
|
telegram_bot_disable_buttons,
|
2022-05-23 17:53:06 +02:00
|
|
|
linkding_enabled,
|
|
|
|
linkding_url,
|
2022-10-14 17:18:44 +02:00
|
|
|
linkding_api_key,
|
2023-05-21 16:29:51 +02:00
|
|
|
linkding_tags,
|
2023-06-24 17:08:58 +02:00
|
|
|
linkding_mark_as_unread,
|
2022-10-14 17:18:44 +02:00
|
|
|
matrix_bot_enabled,
|
|
|
|
matrix_bot_user,
|
|
|
|
matrix_bot_password,
|
|
|
|
matrix_bot_url,
|
2023-08-01 05:55:17 +02:00
|
|
|
matrix_bot_chat_id,
|
|
|
|
apprise_enabled,
|
|
|
|
apprise_url,
|
2023-08-13 21:48:29 +02:00
|
|
|
apprise_services_url,
|
|
|
|
shiori_enabled,
|
|
|
|
shiori_url,
|
|
|
|
shiori_username,
|
2023-08-13 23:30:57 +02:00
|
|
|
shiori_password,
|
|
|
|
shaarli_enabled,
|
|
|
|
shaarli_url,
|
2023-09-09 07:45:17 +02:00
|
|
|
shaarli_api_secret,
|
|
|
|
webhook_enabled,
|
|
|
|
webhook_url,
|
|
|
|
webhook_secret
|
2019-10-30 06:48:07 +01:00
|
|
|
FROM
|
|
|
|
integrations
|
|
|
|
WHERE
|
|
|
|
user_id=$1
|
2017-12-03 04:32:14 +01:00
|
|
|
`
|
|
|
|
var integration model.Integration
|
|
|
|
err := s.db.QueryRow(query, userID).Scan(
|
|
|
|
&integration.UserID,
|
|
|
|
&integration.PinboardEnabled,
|
|
|
|
&integration.PinboardToken,
|
|
|
|
&integration.PinboardTags,
|
|
|
|
&integration.PinboardMarkAsUnread,
|
2017-12-03 06:12:03 +01:00
|
|
|
&integration.InstapaperEnabled,
|
|
|
|
&integration.InstapaperUsername,
|
|
|
|
&integration.InstapaperPassword,
|
2017-12-04 02:44:27 +01:00
|
|
|
&integration.FeverEnabled,
|
|
|
|
&integration.FeverUsername,
|
|
|
|
&integration.FeverToken,
|
2022-01-03 04:45:12 +01:00
|
|
|
&integration.GoogleReaderEnabled,
|
|
|
|
&integration.GoogleReaderUsername,
|
|
|
|
&integration.GoogleReaderPassword,
|
2017-12-19 05:52:46 +01:00
|
|
|
&integration.WallabagEnabled,
|
2022-09-19 01:52:28 +02:00
|
|
|
&integration.WallabagOnlyURL,
|
2017-12-19 05:52:46 +01:00
|
|
|
&integration.WallabagURL,
|
|
|
|
&integration.WallabagClientID,
|
|
|
|
&integration.WallabagClientSecret,
|
|
|
|
&integration.WallabagUsername,
|
|
|
|
&integration.WallabagPassword,
|
2023-07-08 00:20:14 +02:00
|
|
|
&integration.NotionEnabled,
|
|
|
|
&integration.NotionToken,
|
|
|
|
&integration.NotionPageID,
|
2018-02-25 20:49:08 +01:00
|
|
|
&integration.NunuxKeeperEnabled,
|
|
|
|
&integration.NunuxKeeperURL,
|
|
|
|
&integration.NunuxKeeperAPIKey,
|
2022-04-21 04:44:47 +02:00
|
|
|
&integration.EspialEnabled,
|
|
|
|
&integration.EspialURL,
|
|
|
|
&integration.EspialAPIKey,
|
|
|
|
&integration.EspialTags,
|
2023-07-28 05:51:44 +02:00
|
|
|
&integration.ReadwiseEnabled,
|
|
|
|
&integration.ReadwiseAPIKey,
|
2018-05-20 22:31:56 +02:00
|
|
|
&integration.PocketEnabled,
|
|
|
|
&integration.PocketAccessToken,
|
|
|
|
&integration.PocketConsumerKey,
|
2021-09-08 05:04:22 +02:00
|
|
|
&integration.TelegramBotEnabled,
|
|
|
|
&integration.TelegramBotToken,
|
|
|
|
&integration.TelegramBotChatID,
|
2023-09-10 20:22:32 +02:00
|
|
|
&integration.TelegramBotTopicID,
|
|
|
|
&integration.TelegramBotDisableWebPagePreview,
|
|
|
|
&integration.TelegramBotDisableNotification,
|
2023-09-28 05:02:22 +02:00
|
|
|
&integration.TelegramBotDisableButtons,
|
2022-05-23 17:53:06 +02:00
|
|
|
&integration.LinkdingEnabled,
|
|
|
|
&integration.LinkdingURL,
|
|
|
|
&integration.LinkdingAPIKey,
|
2023-05-21 16:29:51 +02:00
|
|
|
&integration.LinkdingTags,
|
2023-06-24 17:08:58 +02:00
|
|
|
&integration.LinkdingMarkAsUnread,
|
2022-10-14 17:18:44 +02:00
|
|
|
&integration.MatrixBotEnabled,
|
|
|
|
&integration.MatrixBotUser,
|
|
|
|
&integration.MatrixBotPassword,
|
|
|
|
&integration.MatrixBotURL,
|
|
|
|
&integration.MatrixBotChatID,
|
2023-08-01 05:55:17 +02:00
|
|
|
&integration.AppriseEnabled,
|
|
|
|
&integration.AppriseURL,
|
|
|
|
&integration.AppriseServicesURL,
|
2023-08-13 21:48:29 +02:00
|
|
|
&integration.ShioriEnabled,
|
|
|
|
&integration.ShioriURL,
|
|
|
|
&integration.ShioriUsername,
|
|
|
|
&integration.ShioriPassword,
|
2023-08-13 23:30:57 +02:00
|
|
|
&integration.ShaarliEnabled,
|
|
|
|
&integration.ShaarliURL,
|
|
|
|
&integration.ShaarliAPISecret,
|
2023-09-09 07:45:17 +02:00
|
|
|
&integration.WebhookEnabled,
|
|
|
|
&integration.WebhookURL,
|
|
|
|
&integration.WebhookSecret,
|
2017-12-03 04:32:14 +01:00
|
|
|
)
|
|
|
|
switch {
|
|
|
|
case err == sql.ErrNoRows:
|
2017-12-16 03:55:57 +01:00
|
|
|
return &integration, nil
|
2017-12-03 04:32:14 +01:00
|
|
|
case err != nil:
|
2019-10-30 06:48:07 +01:00
|
|
|
return &integration, fmt.Errorf(`store: unable to fetch integration row: %v`, err)
|
|
|
|
default:
|
|
|
|
return &integration, nil
|
2017-12-03 04:32:14 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// UpdateIntegration saves user integration settings.
|
|
|
|
func (s *Storage) UpdateIntegration(integration *model.Integration) error {
|
2023-07-11 05:59:49 +02:00
|
|
|
query := `
|
2019-10-30 06:48:07 +01:00
|
|
|
UPDATE
|
|
|
|
integrations
|
|
|
|
SET
|
2017-12-03 04:32:14 +01:00
|
|
|
pinboard_enabled=$1,
|
|
|
|
pinboard_token=$2,
|
|
|
|
pinboard_tags=$3,
|
2017-12-03 06:12:03 +01:00
|
|
|
pinboard_mark_as_unread=$4,
|
|
|
|
instapaper_enabled=$5,
|
|
|
|
instapaper_username=$6,
|
2017-12-04 02:44:27 +01:00
|
|
|
instapaper_password=$7,
|
|
|
|
fever_enabled=$8,
|
|
|
|
fever_username=$9,
|
2020-10-07 06:22:24 +02:00
|
|
|
fever_token=$10,
|
|
|
|
wallabag_enabled=$11,
|
2022-09-19 01:52:28 +02:00
|
|
|
wallabag_only_url=$12,
|
|
|
|
wallabag_url=$13,
|
|
|
|
wallabag_client_id=$14,
|
|
|
|
wallabag_client_secret=$15,
|
|
|
|
wallabag_username=$16,
|
|
|
|
wallabag_password=$17,
|
|
|
|
nunux_keeper_enabled=$18,
|
|
|
|
nunux_keeper_url=$19,
|
|
|
|
nunux_keeper_api_key=$20,
|
|
|
|
pocket_enabled=$21,
|
|
|
|
pocket_access_token=$22,
|
|
|
|
pocket_consumer_key=$23,
|
|
|
|
googlereader_enabled=$24,
|
|
|
|
googlereader_username=$25,
|
|
|
|
googlereader_password=$26,
|
|
|
|
telegram_bot_enabled=$27,
|
|
|
|
telegram_bot_token=$28,
|
|
|
|
telegram_bot_chat_id=$29,
|
2023-09-10 20:22:32 +02:00
|
|
|
telegram_bot_topic_id=$30,
|
|
|
|
telegram_bot_disable_web_page_preview=$31,
|
|
|
|
telegram_bot_disable_notification=$32,
|
2023-09-28 05:02:22 +02:00
|
|
|
telegram_bot_disable_buttons=$33,
|
|
|
|
espial_enabled=$34,
|
|
|
|
espial_url=$35,
|
|
|
|
espial_api_key=$36,
|
|
|
|
espial_tags=$37,
|
|
|
|
linkding_enabled=$38,
|
|
|
|
linkding_url=$39,
|
|
|
|
linkding_api_key=$40,
|
|
|
|
linkding_tags=$41,
|
|
|
|
linkding_mark_as_unread=$42,
|
|
|
|
matrix_bot_enabled=$43,
|
|
|
|
matrix_bot_user=$44,
|
|
|
|
matrix_bot_password=$45,
|
|
|
|
matrix_bot_url=$46,
|
|
|
|
matrix_bot_chat_id=$47,
|
|
|
|
notion_enabled=$48,
|
|
|
|
notion_token=$49,
|
|
|
|
notion_page_id=$50,
|
|
|
|
readwise_enabled=$51,
|
|
|
|
readwise_api_key=$52,
|
|
|
|
apprise_enabled=$53,
|
|
|
|
apprise_url=$54,
|
|
|
|
apprise_services_url=$55,
|
|
|
|
shiori_enabled=$56,
|
|
|
|
shiori_url=$57,
|
|
|
|
shiori_username=$58,
|
|
|
|
shiori_password=$59,
|
|
|
|
shaarli_enabled=$60,
|
|
|
|
shaarli_url=$61,
|
|
|
|
shaarli_api_secret=$62,
|
|
|
|
webhook_enabled=$63,
|
|
|
|
webhook_url=$64,
|
|
|
|
webhook_secret=$65
|
2019-10-30 06:48:07 +01:00
|
|
|
WHERE
|
2023-09-28 05:02:22 +02:00
|
|
|
user_id=$66
|
2017-12-03 04:32:14 +01:00
|
|
|
`
|
2023-07-11 05:59:49 +02:00
|
|
|
_, err := s.db.Exec(
|
|
|
|
query,
|
|
|
|
integration.PinboardEnabled,
|
|
|
|
integration.PinboardToken,
|
|
|
|
integration.PinboardTags,
|
|
|
|
integration.PinboardMarkAsUnread,
|
|
|
|
integration.InstapaperEnabled,
|
|
|
|
integration.InstapaperUsername,
|
|
|
|
integration.InstapaperPassword,
|
|
|
|
integration.FeverEnabled,
|
|
|
|
integration.FeverUsername,
|
|
|
|
integration.FeverToken,
|
|
|
|
integration.WallabagEnabled,
|
|
|
|
integration.WallabagOnlyURL,
|
|
|
|
integration.WallabagURL,
|
|
|
|
integration.WallabagClientID,
|
|
|
|
integration.WallabagClientSecret,
|
|
|
|
integration.WallabagUsername,
|
|
|
|
integration.WallabagPassword,
|
|
|
|
integration.NunuxKeeperEnabled,
|
|
|
|
integration.NunuxKeeperURL,
|
|
|
|
integration.NunuxKeeperAPIKey,
|
|
|
|
integration.PocketEnabled,
|
|
|
|
integration.PocketAccessToken,
|
|
|
|
integration.PocketConsumerKey,
|
|
|
|
integration.GoogleReaderEnabled,
|
|
|
|
integration.GoogleReaderUsername,
|
|
|
|
integration.GoogleReaderPassword,
|
|
|
|
integration.TelegramBotEnabled,
|
|
|
|
integration.TelegramBotToken,
|
|
|
|
integration.TelegramBotChatID,
|
2023-09-10 20:22:32 +02:00
|
|
|
integration.TelegramBotTopicID,
|
|
|
|
integration.TelegramBotDisableWebPagePreview,
|
|
|
|
integration.TelegramBotDisableNotification,
|
2023-09-28 05:02:22 +02:00
|
|
|
integration.TelegramBotDisableButtons,
|
2023-07-11 05:59:49 +02:00
|
|
|
integration.EspialEnabled,
|
|
|
|
integration.EspialURL,
|
|
|
|
integration.EspialAPIKey,
|
|
|
|
integration.EspialTags,
|
|
|
|
integration.LinkdingEnabled,
|
|
|
|
integration.LinkdingURL,
|
|
|
|
integration.LinkdingAPIKey,
|
|
|
|
integration.LinkdingTags,
|
|
|
|
integration.LinkdingMarkAsUnread,
|
|
|
|
integration.MatrixBotEnabled,
|
|
|
|
integration.MatrixBotUser,
|
|
|
|
integration.MatrixBotPassword,
|
|
|
|
integration.MatrixBotURL,
|
|
|
|
integration.MatrixBotChatID,
|
|
|
|
integration.NotionEnabled,
|
|
|
|
integration.NotionToken,
|
|
|
|
integration.NotionPageID,
|
2023-07-28 05:51:44 +02:00
|
|
|
integration.ReadwiseEnabled,
|
|
|
|
integration.ReadwiseAPIKey,
|
2023-08-01 05:55:17 +02:00
|
|
|
integration.AppriseEnabled,
|
|
|
|
integration.AppriseURL,
|
|
|
|
integration.AppriseServicesURL,
|
2023-08-13 21:48:29 +02:00
|
|
|
integration.ShioriEnabled,
|
|
|
|
integration.ShioriURL,
|
|
|
|
integration.ShioriUsername,
|
|
|
|
integration.ShioriPassword,
|
2023-08-13 23:30:57 +02:00
|
|
|
integration.ShaarliEnabled,
|
|
|
|
integration.ShaarliURL,
|
|
|
|
integration.ShaarliAPISecret,
|
2023-09-09 07:45:17 +02:00
|
|
|
integration.WebhookEnabled,
|
|
|
|
integration.WebhookURL,
|
|
|
|
integration.WebhookSecret,
|
2023-07-11 05:59:49 +02:00
|
|
|
integration.UserID,
|
|
|
|
)
|
2017-12-03 04:32:14 +01:00
|
|
|
|
|
|
|
if err != nil {
|
2023-08-13 21:48:29 +02:00
|
|
|
return fmt.Errorf(`store: unable to update integration record: %v`, err)
|
2017-12-03 04:32:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2018-04-30 02:43:40 +02:00
|
|
|
// HasSaveEntry returns true if the given user can save articles to third-parties.
|
|
|
|
func (s *Storage) HasSaveEntry(userID int64) (result bool) {
|
|
|
|
query := `
|
2019-10-30 06:48:07 +01:00
|
|
|
SELECT
|
|
|
|
true
|
|
|
|
FROM
|
|
|
|
integrations
|
|
|
|
WHERE
|
|
|
|
user_id=$1
|
|
|
|
AND
|
2023-08-13 21:48:29 +02:00
|
|
|
(
|
|
|
|
pinboard_enabled='t' OR
|
|
|
|
instapaper_enabled='t' OR
|
|
|
|
wallabag_enabled='t' OR
|
|
|
|
notion_enabled='t' OR
|
|
|
|
nunux_keeper_enabled='t' OR
|
|
|
|
espial_enabled='t' OR
|
|
|
|
readwise_enabled='t' OR
|
|
|
|
pocket_enabled='t' OR
|
|
|
|
linkding_enabled='t' OR
|
|
|
|
apprise_enabled='t' OR
|
2023-08-13 23:30:57 +02:00
|
|
|
shiori_enabled='t' OR
|
2023-09-11 02:47:05 +02:00
|
|
|
shaarli_enabled='t' OR
|
|
|
|
webhook_enabled='t'
|
2023-08-13 21:48:29 +02:00
|
|
|
)
|
2018-04-30 02:43:40 +02:00
|
|
|
`
|
|
|
|
if err := s.db.QueryRow(query, userID).Scan(&result); err != nil {
|
|
|
|
result = false
|
|
|
|
}
|
|
|
|
|
|
|
|
return result
|
|
|
|
}
|