2021-10-22 12:48:53 +02:00
|
|
|
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
|
|
// See LICENSE.txt for license information.
|
|
|
|
|
|
|
|
// Code generated by "make generate" from the Store interface
|
|
|
|
// DO NOT EDIT
|
|
|
|
|
|
|
|
// To add a public method, create an entry in the Store interface,
|
|
|
|
// prefix it with a @withTransaction comment if you need it to be
|
|
|
|
// transactional and then add a private method in the store itself
|
|
|
|
// with db sq.BaseRunner as the first parameter before running `make
|
|
|
|
// generate`
|
|
|
|
|
|
|
|
package sqlstore
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2021-12-10 16:46:37 +01:00
|
|
|
"time"
|
2021-10-22 12:48:53 +02:00
|
|
|
|
|
|
|
"github.com/mattermost/focalboard/server/model"
|
|
|
|
|
|
|
|
"github.com/mattermost/mattermost-server/v6/shared/mlog"
|
|
|
|
)
|
|
|
|
|
2022-03-22 15:24:34 +01:00
|
|
|
func (s *SQLStore) AddUpdateCategoryBlock(userID string, categoryID string, blockID string) error {
|
|
|
|
return s.addUpdateCategoryBlock(s.db, userID, categoryID, blockID)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2021-10-22 12:48:53 +02:00
|
|
|
func (s *SQLStore) CleanUpSessions(expireTime int64) error {
|
|
|
|
return s.cleanUpSessions(s.db, expireTime)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-03-22 15:24:34 +01:00
|
|
|
func (s *SQLStore) CreateBoardsAndBlocks(bab *model.BoardsAndBlocks, userID string) (*model.BoardsAndBlocks, error) {
|
|
|
|
if s.dbType == model.SqliteDBType {
|
|
|
|
return s.createBoardsAndBlocks(s.db, bab, userID)
|
|
|
|
}
|
|
|
|
tx, txErr := s.db.BeginTx(context.Background(), nil)
|
|
|
|
if txErr != nil {
|
|
|
|
return nil, txErr
|
|
|
|
}
|
|
|
|
result, err := s.createBoardsAndBlocks(tx, bab, userID)
|
|
|
|
if err != nil {
|
|
|
|
if rollbackErr := tx.Rollback(); rollbackErr != nil {
|
|
|
|
s.logger.Error("transaction rollback error", mlog.Err(rollbackErr), mlog.String("methodName", "CreateBoardsAndBlocks"))
|
|
|
|
}
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
if err := tx.Commit(); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return result, nil
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *SQLStore) CreateBoardsAndBlocksWithAdmin(bab *model.BoardsAndBlocks, userID string) (*model.BoardsAndBlocks, []*model.BoardMember, error) {
|
|
|
|
if s.dbType == model.SqliteDBType {
|
|
|
|
return s.createBoardsAndBlocksWithAdmin(s.db, bab, userID)
|
|
|
|
}
|
|
|
|
tx, txErr := s.db.BeginTx(context.Background(), nil)
|
|
|
|
if txErr != nil {
|
|
|
|
return nil, nil, txErr
|
|
|
|
}
|
|
|
|
result, resultVar1, err := s.createBoardsAndBlocksWithAdmin(tx, bab, userID)
|
|
|
|
if err != nil {
|
|
|
|
if rollbackErr := tx.Rollback(); rollbackErr != nil {
|
|
|
|
s.logger.Error("transaction rollback error", mlog.Err(rollbackErr), mlog.String("methodName", "CreateBoardsAndBlocksWithAdmin"))
|
|
|
|
}
|
|
|
|
return nil, nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
if err := tx.Commit(); err != nil {
|
|
|
|
return nil, nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return result, resultVar1, nil
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *SQLStore) CreateCategory(category model.Category) error {
|
|
|
|
return s.createCategory(s.db, category)
|
2022-02-28 12:28:16 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2021-10-22 12:48:53 +02:00
|
|
|
func (s *SQLStore) CreateSession(session *model.Session) error {
|
|
|
|
return s.createSession(s.db, session)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-03-22 15:24:34 +01:00
|
|
|
func (s *SQLStore) CreateSubscription(sub *model.Subscription) (*model.Subscription, error) {
|
|
|
|
return s.createSubscription(s.db, sub)
|
2021-12-10 16:46:37 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2021-10-22 12:48:53 +02:00
|
|
|
func (s *SQLStore) CreateUser(user *model.User) error {
|
|
|
|
return s.createUser(s.db, user)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-03-22 15:24:34 +01:00
|
|
|
func (s *SQLStore) DeleteBlock(blockID string, modifiedBy string) error {
|
|
|
|
if s.dbType == model.SqliteDBType {
|
|
|
|
return s.deleteBlock(s.db, blockID, modifiedBy)
|
2022-02-22 22:30:47 +01:00
|
|
|
}
|
2021-10-22 12:48:53 +02:00
|
|
|
tx, txErr := s.db.BeginTx(context.Background(), nil)
|
|
|
|
if txErr != nil {
|
|
|
|
return txErr
|
|
|
|
}
|
2022-03-22 15:24:34 +01:00
|
|
|
err := s.deleteBlock(tx, blockID, modifiedBy)
|
2021-10-22 12:48:53 +02:00
|
|
|
if err != nil {
|
|
|
|
if rollbackErr := tx.Rollback(); rollbackErr != nil {
|
|
|
|
s.logger.Error("transaction rollback error", mlog.Err(rollbackErr), mlog.String("methodName", "DeleteBlock"))
|
|
|
|
}
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
if err := tx.Commit(); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-03-22 15:24:34 +01:00
|
|
|
func (s *SQLStore) DeleteBoard(boardID string, userID string) error {
|
|
|
|
if s.dbType == model.SqliteDBType {
|
|
|
|
return s.deleteBoard(s.db, boardID, userID)
|
|
|
|
}
|
|
|
|
tx, txErr := s.db.BeginTx(context.Background(), nil)
|
|
|
|
if txErr != nil {
|
|
|
|
return txErr
|
|
|
|
}
|
|
|
|
err := s.deleteBoard(tx, boardID, userID)
|
|
|
|
if err != nil {
|
|
|
|
if rollbackErr := tx.Rollback(); rollbackErr != nil {
|
|
|
|
s.logger.Error("transaction rollback error", mlog.Err(rollbackErr), mlog.String("methodName", "DeleteBoard"))
|
|
|
|
}
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
if err := tx.Commit(); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *SQLStore) DeleteBoardsAndBlocks(dbab *model.DeleteBoardsAndBlocks, userID string) error {
|
|
|
|
if s.dbType == model.SqliteDBType {
|
|
|
|
return s.deleteBoardsAndBlocks(s.db, dbab, userID)
|
|
|
|
}
|
|
|
|
tx, txErr := s.db.BeginTx(context.Background(), nil)
|
|
|
|
if txErr != nil {
|
|
|
|
return txErr
|
|
|
|
}
|
|
|
|
err := s.deleteBoardsAndBlocks(tx, dbab, userID)
|
|
|
|
if err != nil {
|
|
|
|
if rollbackErr := tx.Rollback(); rollbackErr != nil {
|
|
|
|
s.logger.Error("transaction rollback error", mlog.Err(rollbackErr), mlog.String("methodName", "DeleteBoardsAndBlocks"))
|
|
|
|
}
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
if err := tx.Commit(); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *SQLStore) DeleteCategory(categoryID string, userID string, teamID string) error {
|
|
|
|
return s.deleteCategory(s.db, categoryID, userID, teamID)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *SQLStore) DeleteMember(boardID string, userID string) error {
|
|
|
|
return s.deleteMember(s.db, boardID, userID)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *SQLStore) DeleteNotificationHint(blockID string) error {
|
|
|
|
return s.deleteNotificationHint(s.db, blockID)
|
2021-12-10 16:46:37 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2021-10-22 12:48:53 +02:00
|
|
|
func (s *SQLStore) DeleteSession(sessionID string) error {
|
|
|
|
return s.deleteSession(s.db, sessionID)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-03-22 15:24:34 +01:00
|
|
|
func (s *SQLStore) DeleteSubscription(blockID string, subscriberID string) error {
|
|
|
|
return s.deleteSubscription(s.db, blockID, subscriberID)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *SQLStore) DuplicateBlock(boardID string, blockID string, userID string, asTemplate bool) ([]model.Block, error) {
|
|
|
|
if s.dbType == model.SqliteDBType {
|
|
|
|
return s.duplicateBlock(s.db, boardID, blockID, userID, asTemplate)
|
|
|
|
}
|
|
|
|
tx, txErr := s.db.BeginTx(context.Background(), nil)
|
|
|
|
if txErr != nil {
|
|
|
|
return nil, txErr
|
|
|
|
}
|
|
|
|
result, err := s.duplicateBlock(tx, boardID, blockID, userID, asTemplate)
|
|
|
|
if err != nil {
|
|
|
|
if rollbackErr := tx.Rollback(); rollbackErr != nil {
|
|
|
|
s.logger.Error("transaction rollback error", mlog.Err(rollbackErr), mlog.String("methodName", "DuplicateBlock"))
|
|
|
|
}
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
if err := tx.Commit(); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return result, nil
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *SQLStore) DuplicateBoard(boardID string, userID string, toTeam string, asTemplate bool) (*model.BoardsAndBlocks, []*model.BoardMember, error) {
|
|
|
|
if s.dbType == model.SqliteDBType {
|
|
|
|
return s.duplicateBoard(s.db, boardID, userID, toTeam, asTemplate)
|
|
|
|
}
|
|
|
|
tx, txErr := s.db.BeginTx(context.Background(), nil)
|
|
|
|
if txErr != nil {
|
|
|
|
return nil, nil, txErr
|
|
|
|
}
|
|
|
|
result, resultVar1, err := s.duplicateBoard(tx, boardID, userID, toTeam, asTemplate)
|
|
|
|
if err != nil {
|
|
|
|
if rollbackErr := tx.Rollback(); rollbackErr != nil {
|
|
|
|
s.logger.Error("transaction rollback error", mlog.Err(rollbackErr), mlog.String("methodName", "DuplicateBoard"))
|
|
|
|
}
|
|
|
|
return nil, nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
if err := tx.Commit(); err != nil {
|
|
|
|
return nil, nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return result, resultVar1, nil
|
2021-12-10 16:46:37 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2021-10-22 12:48:53 +02:00
|
|
|
func (s *SQLStore) GetActiveUserCount(updatedSecondsAgo int64) (int, error) {
|
|
|
|
return s.getActiveUserCount(s.db, updatedSecondsAgo)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-03-22 15:24:34 +01:00
|
|
|
func (s *SQLStore) GetAllTeams() ([]*model.Team, error) {
|
|
|
|
return s.getAllTeams(s.db)
|
2021-10-22 12:48:53 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-03-22 15:24:34 +01:00
|
|
|
func (s *SQLStore) GetBlock(blockID string) (*model.Block, error) {
|
|
|
|
return s.getBlock(s.db, blockID)
|
2021-10-22 12:48:53 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *SQLStore) GetBlockCountsByType() (map[string]int64, error) {
|
|
|
|
return s.getBlockCountsByType(s.db)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-03-22 15:24:34 +01:00
|
|
|
func (s *SQLStore) GetBlockHistory(blockID string, opts model.QueryBlockHistoryOptions) ([]model.Block, error) {
|
|
|
|
return s.getBlockHistory(s.db, blockID, opts)
|
2021-12-10 16:46:37 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-03-22 15:24:34 +01:00
|
|
|
func (s *SQLStore) GetBlocksForBoard(boardID string) ([]model.Block, error) {
|
|
|
|
return s.getBlocksForBoard(s.db, boardID)
|
2021-10-22 12:48:53 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-03-22 15:24:34 +01:00
|
|
|
func (s *SQLStore) GetBlocksWithBoardID(boardID string) ([]model.Block, error) {
|
|
|
|
return s.getBlocksWithBoardID(s.db, boardID)
|
2021-10-22 12:48:53 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-03-22 15:24:34 +01:00
|
|
|
func (s *SQLStore) GetBlocksWithParent(boardID string, parentID string) ([]model.Block, error) {
|
|
|
|
return s.getBlocksWithParent(s.db, boardID, parentID)
|
2021-10-22 12:48:53 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-03-22 15:24:34 +01:00
|
|
|
func (s *SQLStore) GetBlocksWithParentAndType(boardID string, parentID string, blockType string) ([]model.Block, error) {
|
|
|
|
return s.getBlocksWithParentAndType(s.db, boardID, parentID, blockType)
|
2021-10-22 12:48:53 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-03-22 15:24:34 +01:00
|
|
|
func (s *SQLStore) GetBlocksWithType(boardID string, blockType string) ([]model.Block, error) {
|
|
|
|
return s.getBlocksWithType(s.db, boardID, blockType)
|
2021-12-10 16:46:37 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-03-22 15:24:34 +01:00
|
|
|
func (s *SQLStore) GetBoard(id string) (*model.Board, error) {
|
|
|
|
return s.getBoard(s.db, id)
|
2021-12-10 16:46:37 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-03-22 15:24:34 +01:00
|
|
|
func (s *SQLStore) GetBoardAndCard(block *model.Block) (*model.Board, *model.Block, error) {
|
|
|
|
return s.getBoardAndCard(s.db, block)
|
2022-02-02 19:25:06 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-03-22 15:24:34 +01:00
|
|
|
func (s *SQLStore) GetBoardAndCardByID(blockID string) (*model.Board, *model.Block, error) {
|
|
|
|
return s.getBoardAndCardByID(s.db, blockID)
|
2021-12-10 16:46:37 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-03-22 15:24:34 +01:00
|
|
|
func (s *SQLStore) GetBoardsForUserAndTeam(userID string, teamID string) ([]*model.Board, error) {
|
|
|
|
return s.getBoardsForUserAndTeam(s.db, userID, teamID)
|
2021-12-10 16:46:37 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-03-22 15:24:34 +01:00
|
|
|
func (s *SQLStore) GetCategory(id string) (*model.Category, error) {
|
|
|
|
return s.getCategory(s.db, id)
|
2021-10-22 12:48:53 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-03-22 15:24:34 +01:00
|
|
|
func (s *SQLStore) GetMemberForBoard(boardID string, userID string) (*model.BoardMember, error) {
|
|
|
|
return s.getMemberForBoard(s.db, boardID, userID)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *SQLStore) GetMembersForBoard(boardID string) ([]*model.BoardMember, error) {
|
|
|
|
return s.getMembersForBoard(s.db, boardID)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *SQLStore) GetMembersForUser(userID string) ([]*model.BoardMember, error) {
|
|
|
|
return s.getMembersForUser(s.db, userID)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *SQLStore) GetNextNotificationHint(remove bool) (*model.NotificationHint, error) {
|
|
|
|
return s.getNextNotificationHint(s.db, remove)
|
2021-10-22 12:48:53 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-03-22 15:24:34 +01:00
|
|
|
func (s *SQLStore) GetNotificationHint(blockID string) (*model.NotificationHint, error) {
|
|
|
|
return s.getNotificationHint(s.db, blockID)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *SQLStore) GetRegisteredUserCount() (int, error) {
|
|
|
|
return s.getRegisteredUserCount(s.db)
|
2021-10-22 12:48:53 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *SQLStore) GetSession(token string, expireTime int64) (*model.Session, error) {
|
|
|
|
return s.getSession(s.db, token, expireTime)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-03-22 15:24:34 +01:00
|
|
|
func (s *SQLStore) GetSharing(rootID string) (*model.Sharing, error) {
|
|
|
|
return s.getSharing(s.db, rootID)
|
2021-10-22 12:48:53 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-03-22 15:24:34 +01:00
|
|
|
func (s *SQLStore) GetSubTree2(boardID string, blockID string, opts model.QuerySubtreeOptions) ([]model.Block, error) {
|
|
|
|
return s.getSubTree2(s.db, boardID, blockID, opts)
|
2021-12-10 16:46:37 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-03-22 15:24:34 +01:00
|
|
|
func (s *SQLStore) GetSubTree3(boardID string, blockID string, opts model.QuerySubtreeOptions) ([]model.Block, error) {
|
|
|
|
return s.getSubTree3(s.db, boardID, blockID, opts)
|
2021-10-22 12:48:53 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-03-22 15:24:34 +01:00
|
|
|
func (s *SQLStore) GetSubscribersCountForBlock(blockID string) (int, error) {
|
|
|
|
return s.getSubscribersCountForBlock(s.db, blockID)
|
2021-12-10 16:46:37 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-03-22 15:24:34 +01:00
|
|
|
func (s *SQLStore) GetSubscribersForBlock(blockID string) ([]*model.Subscriber, error) {
|
|
|
|
return s.getSubscribersForBlock(s.db, blockID)
|
2021-12-10 16:46:37 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-03-22 15:24:34 +01:00
|
|
|
func (s *SQLStore) GetSubscription(blockID string, subscriberID string) (*model.Subscription, error) {
|
|
|
|
return s.getSubscription(s.db, blockID, subscriberID)
|
2021-12-10 16:46:37 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-03-22 15:24:34 +01:00
|
|
|
func (s *SQLStore) GetSubscriptions(subscriberID string) ([]*model.Subscription, error) {
|
|
|
|
return s.getSubscriptions(s.db, subscriberID)
|
2021-10-22 12:48:53 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2021-11-11 17:01:43 +01:00
|
|
|
func (s *SQLStore) GetSystemSetting(key string) (string, error) {
|
|
|
|
return s.getSystemSetting(s.db, key)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2021-10-22 12:48:53 +02:00
|
|
|
func (s *SQLStore) GetSystemSettings() (map[string]string, error) {
|
|
|
|
return s.getSystemSettings(s.db)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-03-22 15:24:34 +01:00
|
|
|
func (s *SQLStore) GetTeam(ID string) (*model.Team, error) {
|
|
|
|
return s.getTeam(s.db, ID)
|
2021-10-22 12:48:53 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-03-22 15:24:34 +01:00
|
|
|
func (s *SQLStore) GetTeamCount() (int64, error) {
|
|
|
|
return s.getTeamCount(s.db)
|
2021-10-22 12:48:53 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-03-22 15:24:34 +01:00
|
|
|
func (s *SQLStore) GetTeamsForUser(userID string) ([]*model.Team, error) {
|
|
|
|
return s.getTeamsForUser(s.db, userID)
|
2021-10-22 12:48:53 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-03-22 15:24:34 +01:00
|
|
|
func (s *SQLStore) GetTemplateBoards(teamID string) ([]*model.Board, error) {
|
|
|
|
return s.getTemplateBoards(s.db, teamID)
|
2021-10-22 12:48:53 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-03-22 15:24:34 +01:00
|
|
|
func (s *SQLStore) GetUserByEmail(email string) (*model.User, error) {
|
|
|
|
return s.getUserByEmail(s.db, email)
|
2021-10-22 12:48:53 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-03-22 15:24:34 +01:00
|
|
|
func (s *SQLStore) GetUserByID(userID string) (*model.User, error) {
|
|
|
|
return s.getUserByID(s.db, userID)
|
2021-10-22 12:48:53 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-03-22 15:24:34 +01:00
|
|
|
func (s *SQLStore) GetUserByUsername(username string) (*model.User, error) {
|
|
|
|
return s.getUserByUsername(s.db, username)
|
2021-10-22 12:48:53 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-03-22 15:24:34 +01:00
|
|
|
func (s *SQLStore) GetUserCategoryBlocks(userID string, teamID string) ([]model.CategoryBlocks, error) {
|
|
|
|
return s.getUserCategoryBlocks(s.db, userID, teamID)
|
2021-10-22 12:48:53 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-03-22 15:24:34 +01:00
|
|
|
func (s *SQLStore) GetUsersByTeam(teamID string) ([]*model.User, error) {
|
|
|
|
return s.getUsersByTeam(s.db, teamID)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *SQLStore) InsertBlock(block *model.Block, userID string) error {
|
|
|
|
if s.dbType == model.SqliteDBType {
|
|
|
|
return s.insertBlock(s.db, block, userID)
|
2022-02-22 22:30:47 +01:00
|
|
|
}
|
2021-10-22 12:48:53 +02:00
|
|
|
tx, txErr := s.db.BeginTx(context.Background(), nil)
|
|
|
|
if txErr != nil {
|
|
|
|
return txErr
|
|
|
|
}
|
2022-03-22 15:24:34 +01:00
|
|
|
err := s.insertBlock(tx, block, userID)
|
2021-10-22 12:48:53 +02:00
|
|
|
if err != nil {
|
|
|
|
if rollbackErr := tx.Rollback(); rollbackErr != nil {
|
|
|
|
s.logger.Error("transaction rollback error", mlog.Err(rollbackErr), mlog.String("methodName", "InsertBlock"))
|
|
|
|
}
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
if err := tx.Commit(); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-03-22 15:24:34 +01:00
|
|
|
func (s *SQLStore) InsertBlocks(blocks []model.Block, userID string) error {
|
|
|
|
if s.dbType == model.SqliteDBType {
|
|
|
|
return s.insertBlocks(s.db, blocks, userID)
|
2022-02-22 22:30:47 +01:00
|
|
|
}
|
2021-12-10 15:17:00 +01:00
|
|
|
tx, txErr := s.db.BeginTx(context.Background(), nil)
|
|
|
|
if txErr != nil {
|
|
|
|
return txErr
|
|
|
|
}
|
2022-03-22 15:24:34 +01:00
|
|
|
err := s.insertBlocks(tx, blocks, userID)
|
2021-12-10 15:17:00 +01:00
|
|
|
if err != nil {
|
|
|
|
if rollbackErr := tx.Rollback(); rollbackErr != nil {
|
|
|
|
s.logger.Error("transaction rollback error", mlog.Err(rollbackErr), mlog.String("methodName", "InsertBlocks"))
|
|
|
|
}
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
if err := tx.Commit(); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-03-22 15:24:34 +01:00
|
|
|
func (s *SQLStore) InsertBoard(board *model.Board, userID string) (*model.Board, error) {
|
|
|
|
return s.insertBoard(s.db, board, userID)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *SQLStore) InsertBoardWithAdmin(board *model.Board, userID string) (*model.Board, *model.BoardMember, error) {
|
|
|
|
if s.dbType == model.SqliteDBType {
|
|
|
|
return s.insertBoardWithAdmin(s.db, board, userID)
|
|
|
|
}
|
|
|
|
tx, txErr := s.db.BeginTx(context.Background(), nil)
|
|
|
|
if txErr != nil {
|
|
|
|
return nil, nil, txErr
|
|
|
|
}
|
|
|
|
result, resultVar1, err := s.insertBoardWithAdmin(tx, board, userID)
|
|
|
|
if err != nil {
|
|
|
|
if rollbackErr := tx.Rollback(); rollbackErr != nil {
|
|
|
|
s.logger.Error("transaction rollback error", mlog.Err(rollbackErr), mlog.String("methodName", "InsertBoardWithAdmin"))
|
|
|
|
}
|
|
|
|
return nil, nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
if err := tx.Commit(); err != nil {
|
|
|
|
return nil, nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return result, resultVar1, nil
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *SQLStore) PatchBlock(blockID string, blockPatch *model.BlockPatch, userID string) error {
|
|
|
|
if s.dbType == model.SqliteDBType {
|
|
|
|
return s.patchBlock(s.db, blockID, blockPatch, userID)
|
2022-02-22 22:30:47 +01:00
|
|
|
}
|
2021-10-22 12:48:53 +02:00
|
|
|
tx, txErr := s.db.BeginTx(context.Background(), nil)
|
|
|
|
if txErr != nil {
|
|
|
|
return txErr
|
|
|
|
}
|
2022-03-22 15:24:34 +01:00
|
|
|
err := s.patchBlock(tx, blockID, blockPatch, userID)
|
2021-10-22 12:48:53 +02:00
|
|
|
if err != nil {
|
|
|
|
if rollbackErr := tx.Rollback(); rollbackErr != nil {
|
|
|
|
s.logger.Error("transaction rollback error", mlog.Err(rollbackErr), mlog.String("methodName", "PatchBlock"))
|
|
|
|
}
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
if err := tx.Commit(); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-03-22 15:24:34 +01:00
|
|
|
func (s *SQLStore) PatchBlocks(blockPatches *model.BlockPatchBatch, userID string) error {
|
|
|
|
if s.dbType == model.SqliteDBType {
|
|
|
|
return s.patchBlocks(s.db, blockPatches, userID)
|
2022-02-22 22:30:47 +01:00
|
|
|
}
|
2021-12-10 15:17:00 +01:00
|
|
|
tx, txErr := s.db.BeginTx(context.Background(), nil)
|
|
|
|
if txErr != nil {
|
|
|
|
return txErr
|
|
|
|
}
|
2022-03-22 15:24:34 +01:00
|
|
|
err := s.patchBlocks(tx, blockPatches, userID)
|
2021-12-10 15:17:00 +01:00
|
|
|
if err != nil {
|
|
|
|
if rollbackErr := tx.Rollback(); rollbackErr != nil {
|
|
|
|
s.logger.Error("transaction rollback error", mlog.Err(rollbackErr), mlog.String("methodName", "PatchBlocks"))
|
|
|
|
}
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
if err := tx.Commit(); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-03-22 15:24:34 +01:00
|
|
|
func (s *SQLStore) PatchBoard(boardID string, boardPatch *model.BoardPatch, userID string) (*model.Board, error) {
|
|
|
|
if s.dbType == model.SqliteDBType {
|
|
|
|
return s.patchBoard(s.db, boardID, boardPatch, userID)
|
|
|
|
}
|
|
|
|
tx, txErr := s.db.BeginTx(context.Background(), nil)
|
|
|
|
if txErr != nil {
|
|
|
|
return nil, txErr
|
|
|
|
}
|
|
|
|
result, err := s.patchBoard(tx, boardID, boardPatch, userID)
|
|
|
|
if err != nil {
|
|
|
|
if rollbackErr := tx.Rollback(); rollbackErr != nil {
|
|
|
|
s.logger.Error("transaction rollback error", mlog.Err(rollbackErr), mlog.String("methodName", "PatchBoard"))
|
|
|
|
}
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
if err := tx.Commit(); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return result, nil
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *SQLStore) PatchBoardsAndBlocks(pbab *model.PatchBoardsAndBlocks, userID string) (*model.BoardsAndBlocks, error) {
|
|
|
|
if s.dbType == model.SqliteDBType {
|
|
|
|
return s.patchBoardsAndBlocks(s.db, pbab, userID)
|
|
|
|
}
|
|
|
|
tx, txErr := s.db.BeginTx(context.Background(), nil)
|
|
|
|
if txErr != nil {
|
|
|
|
return nil, txErr
|
|
|
|
}
|
|
|
|
result, err := s.patchBoardsAndBlocks(tx, pbab, userID)
|
|
|
|
if err != nil {
|
|
|
|
if rollbackErr := tx.Rollback(); rollbackErr != nil {
|
|
|
|
s.logger.Error("transaction rollback error", mlog.Err(rollbackErr), mlog.String("methodName", "PatchBoardsAndBlocks"))
|
|
|
|
}
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
if err := tx.Commit(); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return result, nil
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-02-28 12:28:16 +01:00
|
|
|
func (s *SQLStore) PatchUserProps(userID string, patch model.UserPropPatch) error {
|
|
|
|
return s.patchUserProps(s.db, userID, patch)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2021-10-22 12:48:53 +02:00
|
|
|
func (s *SQLStore) RefreshSession(session *model.Session) error {
|
|
|
|
return s.refreshSession(s.db, session)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-03-22 15:24:34 +01:00
|
|
|
func (s *SQLStore) RemoveDefaultTemplates(boards []*model.Board) error {
|
|
|
|
return s.removeDefaultTemplates(s.db, boards)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *SQLStore) SaveMember(bm *model.BoardMember) (*model.BoardMember, error) {
|
|
|
|
return s.saveMember(s.db, bm)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *SQLStore) SearchBoardsForUserAndTeam(term string, userID string, teamID string) ([]*model.Board, error) {
|
|
|
|
return s.searchBoardsForUserAndTeam(s.db, term, userID, teamID)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *SQLStore) SearchUsersByTeam(teamID string, searchQuery string) ([]*model.User, error) {
|
|
|
|
return s.searchUsersByTeam(s.db, teamID, searchQuery)
|
2022-02-02 19:25:06 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2021-10-22 12:48:53 +02:00
|
|
|
func (s *SQLStore) SetSystemSetting(key string, value string) error {
|
|
|
|
return s.setSystemSetting(s.db, key, value)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-03-22 15:24:34 +01:00
|
|
|
func (s *SQLStore) UndeleteBlock(blockID string, modifiedBy string) error {
|
|
|
|
if s.dbType == model.SqliteDBType {
|
|
|
|
return s.undeleteBlock(s.db, blockID, modifiedBy)
|
|
|
|
}
|
2022-02-22 18:42:49 +01:00
|
|
|
tx, txErr := s.db.BeginTx(context.Background(), nil)
|
|
|
|
if txErr != nil {
|
|
|
|
return txErr
|
|
|
|
}
|
2022-03-22 15:24:34 +01:00
|
|
|
err := s.undeleteBlock(tx, blockID, modifiedBy)
|
2022-02-22 18:42:49 +01:00
|
|
|
if err != nil {
|
|
|
|
if rollbackErr := tx.Rollback(); rollbackErr != nil {
|
|
|
|
s.logger.Error("transaction rollback error", mlog.Err(rollbackErr), mlog.String("methodName", "UndeleteBlock"))
|
|
|
|
}
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
if err := tx.Commit(); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-03-22 15:24:34 +01:00
|
|
|
func (s *SQLStore) UpdateCategory(category model.Category) error {
|
|
|
|
return s.updateCategory(s.db, category)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2021-10-22 12:48:53 +02:00
|
|
|
func (s *SQLStore) UpdateSession(session *model.Session) error {
|
|
|
|
return s.updateSession(s.db, session)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-03-22 15:24:34 +01:00
|
|
|
func (s *SQLStore) UpdateSubscribersNotifiedAt(blockID string, notifiedAt int64) error {
|
|
|
|
return s.updateSubscribersNotifiedAt(s.db, blockID, notifiedAt)
|
2021-12-10 16:46:37 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2021-10-22 12:48:53 +02:00
|
|
|
func (s *SQLStore) UpdateUser(user *model.User) error {
|
|
|
|
return s.updateUser(s.db, user)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *SQLStore) UpdateUserPassword(username string, password string) error {
|
|
|
|
return s.updateUserPassword(s.db, username, password)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *SQLStore) UpdateUserPasswordByID(userID string, password string) error {
|
|
|
|
return s.updateUserPasswordByID(s.db, userID, password)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2021-12-10 16:46:37 +01:00
|
|
|
func (s *SQLStore) UpsertNotificationHint(hint *model.NotificationHint, notificationFreq time.Duration) (*model.NotificationHint, error) {
|
|
|
|
return s.upsertNotificationHint(s.db, hint, notificationFreq)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-03-22 15:24:34 +01:00
|
|
|
func (s *SQLStore) UpsertSharing(sharing model.Sharing) error {
|
|
|
|
return s.upsertSharing(s.db, sharing)
|
2021-10-22 12:48:53 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-03-22 15:24:34 +01:00
|
|
|
func (s *SQLStore) UpsertTeamSettings(team model.Team) error {
|
|
|
|
return s.upsertTeamSettings(s.db, team)
|
2021-10-22 12:48:53 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-03-22 15:24:34 +01:00
|
|
|
func (s *SQLStore) UpsertTeamSignupToken(team model.Team) error {
|
|
|
|
return s.upsertTeamSignupToken(s.db, team)
|
2021-10-22 12:48:53 +02:00
|
|
|
|
|
|
|
}
|