focalboard/server/services/store/sqlstore/public_methods.go
Chen-I Lim c3a4921ac3
GetBoardMetadata API (#2569)
* wip

* Added data migration for populating categories

* wip

* Added data migration for populating categories

* Store WIP

* migration WIP

* category CRUD APIs complete

* category block API WIP

* block category update API done

* Fetcehed data into store

* Started displayting sidebar data

* sidebar WIP

* Dashboard - basic changes

* Sidebar dashboard btn and board switcher UI only

* Sidebar dashboard btn and board switcher UI only

* create category dialog WIP

* Create category webapp side done

* Integrated move card to other category

* board to block

* Disabled dashboard route for now as we'll implement it in phase 2

* WIP

* Added logic to open last board/view on per team level

* Add workspace to teams and boards migrations (#1986)

* Add workspace to teams and boards migrations

* Update json annotations on board models

* boards search dialog WIP

* Seach dialog WIP

* Implemented opening boiard from search results

* Boards switcher styliung

* Handled update category WS event

* Template support

* personal server support and styling fixes

* test fix WIP

* Fixed a bug causing boards to not be moved correctly beteen categories

* Fixed webapp tests

* fix

* Store changes (#2011)

* Permissions phase 1 - Websocket updates (#2014)

* Store changes

* Websockets changes

* Permissions phase 1 - Permissions service (#2015)

* Store changes

* Websockets changes

* Permissions service

* Api and app updates (#2016)

* Store changes

* Websockets changes

* Permissions service

* New API and App changes

* Delete and Patch boards and blocks endpoints

* Used correct variable

* Webapp changes WIP

* Open correct team URL

* Fixed get block API

* Used React context for workspace users

* WIP

* On load navigation sorted out

* WIP

* Nav fix

* categories WS broadcast

* Used real search API

* Fixed unfurl ppreview

* set active team in sidebar

* IMplemented navigation on changing team in sidebar

* Misc fixes

* close rows inside transaction (#2045)

* update syntax for mysql (#2044)

* Upadted mutator for new patchBlock API

* Updated patchBlock API to use new URL

* Listeining to correct event in plugin mode

* Implemented WS messages for category operations:

* Fix duplicated build tags on Makefile

* Sidebar enhancements

* Add missing prefix to SQLite migration and fix flaky tests

* Sidebar boards menu enhancement

* Fix board page interactions (#2144)

* Fix patch board card properties error

* Fix board interactions

* Fix insert blocks interactions

* Fix app tests (#2104)

* Add json1 tag to vscode launch (#2157)

* Fix add, delete and update boards and add board patch generation (#2146)

* Fix update boards and add board patch generation

* Make add board and add template work, as well as deleting a board

* Update the state on board deletion

* Delete unused variable

* Fix bad parenthesis

* Fix board creation inside plugin, options were coming null due websocket message serialization

* update property type mutators to use boards API (#2168)

* Add permissions modal (#2196)

* Initial integration

* Permissions modal, websocket updates and API tests implemented

* Avoid updating/removing user if there is only one admin left

* Fix duplicates on board search

* Adds integration test

* Addressing PR review comments

Co-authored-by: Jesús Espino <jespinog@gmail.com>

* Merge

* I'm able to compile now

* Some fixes around tests execution

* Fixing migrations

* Fixing migrations order

* WIP

* Fixing some other compilation problems on tests

* Some typescript tests fixed

* Fixing javascript tests

* Fixing compilation

* Fixing some problems to create boards

* Load the templates on initial load

* Improvements over initial team templates import

* Adding new fields in the database

* Working on adding duplicate board api

* Removing RootID concept entirely

* Improving a bit the subscriptions

* Fixing store tests for notificationHints

* Fixing more tests

* fixing tests

* Fixing tests

* Fixing tests

* Fixing some small bugs related to templates

* Fixing registration link generation/regeneration

* Fixing cypress tests

* Adding store tests for duplicateBoard and duplicateBlock

* Addressing some TODO comments

* Making the export api simpler

* Add redirect component for old workspace urls

* Removing Dashboard code

* Delete only the built-in templates on update

* fixing tests

* Adding users autocompletion

* Updating snapshots

* Fixing bad merge

* fix panic when creating new card in notifysubscriptions (#2352)

* fix lint errors (#2353)

* fix lint errors

* fix panic when creating new card in notifysubscriptions (#2352)

* fix lint errors

* fix unit test

* Revert "fix unit test"

This reverts commit 0ad78aed65.

Co-authored-by: Doug Lauder <wiggin77@warpmail.net>

* fix sql syntax error for SearchUsersByTeam (#2357)

* Fix mentions delivery (#2358)

* fix sql syntax error for SearchUsersByTeam

* fix mentions delivery

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>

* update api for octoClient calls, pass correct variables to mutator (#2359)

* Fixing tests after merge

* Fix sidebar context menu UI issue (#2399)

* Fix notification diff for text blocks (#2386)

* fix notification diff for text blocks; fix various linter errors.

* fix URLs to cards

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>

* Permissions branch: Fix card links (#2391)

* fix notification diff for text blocks; fix various linter errors.

* fix URLs to cards

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>

* Fixing sqlite tests

* Fixing server tests

* Update migrations to create global templates. (#2397)

* fix duplicate templates

* revert migrate.go

* update UI for empty templates

* implement updating built-in templates as global (teamId = 0)

* handle error if board not found

* update unit test

* fix more tests

* Update blocks_test.go

Fix merge issue

* fix migration sql error (#2414)

* Fixing frontend tests

* Set target team ID when using a global template (#2419)

* Fix some server tests

* Fixing onboarding creation

* Permissions branch: Fix unit tests and CI errors (part 1) (#2425)

* Fixing some small memory leaks (#2400)

* Fixing some small memory leaks

* fixing tests

* passing the tags to all test targets

* Increasing the timeout of the tests

* Fix some type checkings

* Permissions branch: Fixes all the linter errors (#2429)

* fix linter errors

* Reestructuring the router and splitting in more subcomponents (#2403)

* Reestructuring the router and splitting in more subcomponents

* Removing console.log calls

* Removing unneeded selector

* Addressing PR comment

* Fix redirection to one team when you load directly the boards home path

* Using properly the lastTeamID to redirect the user if needed

* don't allow last admin change/deleted (#2416)

* don't allow last admin change/deleted

* update for i18-extract

* fixed en.json

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Co-authored-by: Harshil Sharma <harshilsharma63@gmail.com>

* Splitting BoardPage component into simpler/smaller components (#2435)

* Splitting BoardPage component into simpler/smaller components

* Removing unneeded import

* Replace go migrate with morph permissions (#2424)

* merge origin/replace-go-migrate-with-morph

* run go mod tidy on mattermost-plugin and increase test timeout

* fix merge issue temprorarily

* remove some debug changes

* fixing the linter

* Allow always team 0 (global) templates fetch (#2472)

* Fix problem with viewId 0 in the URL (#2473)

* Migrate from binddata to goembed (#2471)

* Adding join logic to the board switcher (#2434)

* Adding join logic to the board switcher

* Using already existing client function and removing the joinBoard one

* Adding support for autojoin based on url

* Fixing frontend tests

* fix webapp compile error, missing enableSharedBoards (#2501)

* Fixing duplication on postgres

* Adding back views to the sidebar (#2494)

* Fix #2507. Update Swagger comments (#2508)

* Fix the flash of the template selector on board/team switch (#2490)

* Fix the flash of the template selector on board/team switch

* More fixes specially around error handling

* Fixing the bot badge (#2487)

* simplifying a bit the team store sync between channels and focalboard (#2481)

* Fix menu tests (#2528)

* fix failing menu tests

* fix lint error

* Added keyboard shortcut for boards switcher (#2407)

* Added keyboard shortcut for boards switcher

* Fixed a type error

* Added some inline comments

* Fixed lint

* Fixed bug with scroll jumping when the card is opened: (#2477)

- avoid remounting of `ScrollingComponent` for each render of `Kanban` component
  - property `autoFocus` set to false for `CalculationOptions` because it triggers `blur` even for the button in Jest tests and closes the menu
  - snapshots for tests with `CalculationOptions` updated

* Adding the frontend support for permissions and applying it to a big part of the interface. (#2536)

* Initial work on permissions gates

* Applying permissions gates in more places

* Adding more checks to the interface

* Adding more permissions gates and keeping the store up to date

* fixing some tests

* Fixing some more tests

* Fixing another test

* Fixing all tests and adding some more

* Adding no-permission snapshot tests

* Addressing PR review comments

* Fixing invert behavior

* Permissions branch:  No sqlstore calls after app shutdown (#2530)

* fix webapp compile error, missing enableSharedBoards

* refactor app init wip

* - ensure all block change notifications are finished before shutting down app
- fix unit tests for mysql (insert_at only has 1 second resolution!)

* adjust logging

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>

* Fixed migrations to allow upgrading from previous version (#2535)

* Added mechanism to check if schema migration is needed

* WIP

* WIP

* WIP

* WIP

* Fixed migration

* Fixed for SQLite

* minor cleaniup

* Deleted old schema migration table after running migrations

* Removed a debug log

* Fixed a bug where the code always tried to delete a table which may or may not exist

* Show properly the user avatar in the ShareBoard component (#2542)

* Fixing the last CI problems from the permissions-branch (#2541)

* Fix history ordering

* Giving some times to avoid possible race conditions

* Empty

* Reverting accidental change in the config.json

* Optimizing table view (#2540)

* Optimizing table view

* Reducing the amount of rendering for tables

* Some other performance improvements

* Improve the activeView updates

* Some extra simplifications

* Another small improvement

* Fixing tests

* Fixing linter errors

* Reducing a bit the amount of dependency with big objects in the store

* Small simplification

* Removing Commenter role from the user role selector (#2561)

* Shareboard cleanup (#2550)

* Initial work on permissions gates

* Applying permissions gates in more places

* Adding more checks to the interface

* Adding more permissions gates and keeping the store up to date

* fixing some tests

* Fixing some more tests

* Fixing another test

* Fixing all tests and adding some more

* Adding no-permission snapshot tests

* Addressing PR review comments

* cleanup some shareboard settings

* remove unused property, fix for user items being displayed for non admin

* revert change, allow users to show

Co-authored-by: Jesús Espino <jespinog@gmail.com>
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>

* GetBoardMetadata API

* Integration tests. WIP

* getBoardHistory

* Working integration test

* Fix ordering, add store tests

* Fix: Update board_history update_at on patch

* sqltests

* Fix unmarshall delete boards_history

* testGetBlockMetadata with delete and undelete

* Handle board not found

* Fixing comments and cards with the new optimizations in the store (#2560)

* Fixing property creation (#2563)

* Cleanup

* Fix user selection in table view (#2565)

* Fixing focus new row in table view (#2567)

* Permissions branch: Fix sqlite table lock (CI) (#2568)

* fix sqlite table lock

* remove test db on teardown

* revert .gitignore

* fix goimport on migration code

* fix typo

* more linter fixes

* clean up tmp db for sqlstore tests

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>

* Fixing snapshots

* Remove debug log

* Return metadata for deleted boards

* Migrating center panel to functional component (#2562)

* Migrating center panel to functional component

* Fixing some tests

* Fixing another test

* Fixing linter errors

* Fixing types errors

* Fixing linter error

* Fixing cypress tests

* Fixing the last cypress test

* Simpliying a bit the code

* Making property insertion more robust

* Updating checkbox test

* License check

* Cleanup and update Swagger docs

* Merge from main

* Fix bad merge

* Fix Linux-app build break

* do mod tidy

* Fix server lint

* Require credentials (not only read token)

* Add missing defer CloseRows

* do mod tidy

Co-authored-by: Harshil Sharma <harshilsharma63@gmail.com>
Co-authored-by: Miguel de la Cruz <miguel@mcrx.me>
Co-authored-by: Scott Bishel <scott.bishel@mattermost.com>
Co-authored-by: Jesús Espino <jespinog@gmail.com>
Co-authored-by: Doug Lauder <wiggin77@warpmail.net>
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Co-authored-by: Harshil Sharma <18575143+harshilsharma63@users.noreply.github.com>
Co-authored-by: Ibrahim Serdar Acikgoz <serdaracikgoz86@gmail.com>
Co-authored-by: kamre <eremchenko@gmail.com>
2022-03-29 14:47:49 -07:00

748 lines
20 KiB
Go

// 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"
"time"
"github.com/mattermost/focalboard/server/model"
mmModel "github.com/mattermost/mattermost-server/v6/model"
"github.com/mattermost/mattermost-server/v6/shared/mlog"
)
func (s *SQLStore) AddUpdateCategoryBlock(userID string, categoryID string, blockID string) error {
return s.addUpdateCategoryBlock(s.db, userID, categoryID, blockID)
}
func (s *SQLStore) CleanUpSessions(expireTime int64) error {
return s.cleanUpSessions(s.db, expireTime)
}
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)
}
func (s *SQLStore) CreateSession(session *model.Session) error {
return s.createSession(s.db, session)
}
func (s *SQLStore) CreateSubscription(sub *model.Subscription) (*model.Subscription, error) {
return s.createSubscription(s.db, sub)
}
func (s *SQLStore) CreateUser(user *model.User) error {
return s.createUser(s.db, user)
}
func (s *SQLStore) DeleteBlock(blockID string, modifiedBy string) error {
if s.dbType == model.SqliteDBType {
return s.deleteBlock(s.db, blockID, modifiedBy)
}
tx, txErr := s.db.BeginTx(context.Background(), nil)
if txErr != nil {
return txErr
}
err := s.deleteBlock(tx, blockID, modifiedBy)
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
}
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)
}
func (s *SQLStore) DeleteSession(sessionID string) error {
return s.deleteSession(s.db, sessionID)
}
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
}
func (s *SQLStore) GetActiveUserCount(updatedSecondsAgo int64) (int, error) {
return s.getActiveUserCount(s.db, updatedSecondsAgo)
}
func (s *SQLStore) GetAllTeams() ([]*model.Team, error) {
return s.getAllTeams(s.db)
}
func (s *SQLStore) GetBlock(blockID string) (*model.Block, error) {
return s.getBlock(s.db, blockID)
}
func (s *SQLStore) GetBlockCountsByType() (map[string]int64, error) {
return s.getBlockCountsByType(s.db)
}
func (s *SQLStore) GetBlockHistory(blockID string, opts model.QueryBlockHistoryOptions) ([]model.Block, error) {
return s.getBlockHistory(s.db, blockID, opts)
}
func (s *SQLStore) GetBlockHistoryDescendants(boardID string, opts model.QueryBlockHistoryOptions) ([]model.Block, error) {
return s.getBlockHistoryDescendants(s.db, boardID, opts)
}
func (s *SQLStore) GetBlocksForBoard(boardID string) ([]model.Block, error) {
return s.getBlocksForBoard(s.db, boardID)
}
func (s *SQLStore) GetBlocksWithBoardID(boardID string) ([]model.Block, error) {
return s.getBlocksWithBoardID(s.db, boardID)
}
func (s *SQLStore) GetBlocksWithParent(boardID string, parentID string) ([]model.Block, error) {
return s.getBlocksWithParent(s.db, boardID, parentID)
}
func (s *SQLStore) GetBlocksWithParentAndType(boardID string, parentID string, blockType string) ([]model.Block, error) {
return s.getBlocksWithParentAndType(s.db, boardID, parentID, blockType)
}
func (s *SQLStore) GetBlocksWithType(boardID string, blockType string) ([]model.Block, error) {
return s.getBlocksWithType(s.db, boardID, blockType)
}
func (s *SQLStore) GetBoard(id string) (*model.Board, error) {
return s.getBoard(s.db, id)
}
func (s *SQLStore) GetBoardAndCard(block *model.Block) (*model.Board, *model.Block, error) {
return s.getBoardAndCard(s.db, block)
}
func (s *SQLStore) GetBoardAndCardByID(blockID string) (*model.Board, *model.Block, error) {
return s.getBoardAndCardByID(s.db, blockID)
}
func (s *SQLStore) GetBoardHistory(boardID string, opts model.QueryBlockHistoryOptions) ([]*model.Board, error) {
return s.getBoardHistory(s.db, boardID, opts)
}
func (s *SQLStore) GetBoardMemberHistory(boardID string, userID string, limit uint64) ([]*model.BoardMemberHistoryEntry, error) {
return s.getBoardMemberHistory(s.db, boardID, userID, limit)
}
func (s *SQLStore) GetBoardsForUserAndTeam(userID string, teamID string) ([]*model.Board, error) {
return s.getBoardsForUserAndTeam(s.db, userID, teamID)
}
func (s *SQLStore) GetCategory(id string) (*model.Category, error) {
return s.getCategory(s.db, id)
}
func (s *SQLStore) GetLicense() *mmModel.License {
return s.getLicense(s.db)
}
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)
}
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)
}
func (s *SQLStore) GetSession(token string, expireTime int64) (*model.Session, error) {
return s.getSession(s.db, token, expireTime)
}
func (s *SQLStore) GetSharing(rootID string) (*model.Sharing, error) {
return s.getSharing(s.db, rootID)
}
func (s *SQLStore) GetSubTree2(boardID string, blockID string, opts model.QuerySubtreeOptions) ([]model.Block, error) {
return s.getSubTree2(s.db, boardID, blockID, opts)
}
func (s *SQLStore) GetSubTree3(boardID string, blockID string, opts model.QuerySubtreeOptions) ([]model.Block, error) {
return s.getSubTree3(s.db, boardID, blockID, opts)
}
func (s *SQLStore) GetSubscribersCountForBlock(blockID string) (int, error) {
return s.getSubscribersCountForBlock(s.db, blockID)
}
func (s *SQLStore) GetSubscribersForBlock(blockID string) ([]*model.Subscriber, error) {
return s.getSubscribersForBlock(s.db, blockID)
}
func (s *SQLStore) GetSubscription(blockID string, subscriberID string) (*model.Subscription, error) {
return s.getSubscription(s.db, blockID, subscriberID)
}
func (s *SQLStore) GetSubscriptions(subscriberID string) ([]*model.Subscription, error) {
return s.getSubscriptions(s.db, subscriberID)
}
func (s *SQLStore) GetSystemSetting(key string) (string, error) {
return s.getSystemSetting(s.db, key)
}
func (s *SQLStore) GetSystemSettings() (map[string]string, error) {
return s.getSystemSettings(s.db)
}
func (s *SQLStore) GetTeam(ID string) (*model.Team, error) {
return s.getTeam(s.db, ID)
}
func (s *SQLStore) GetTeamCount() (int64, error) {
return s.getTeamCount(s.db)
}
func (s *SQLStore) GetTeamsForUser(userID string) ([]*model.Team, error) {
return s.getTeamsForUser(s.db, userID)
}
func (s *SQLStore) GetTemplateBoards(teamID string) ([]*model.Board, error) {
return s.getTemplateBoards(s.db, teamID)
}
func (s *SQLStore) GetUserByEmail(email string) (*model.User, error) {
return s.getUserByEmail(s.db, email)
}
func (s *SQLStore) GetUserByID(userID string) (*model.User, error) {
return s.getUserByID(s.db, userID)
}
func (s *SQLStore) GetUserByUsername(username string) (*model.User, error) {
return s.getUserByUsername(s.db, username)
}
func (s *SQLStore) GetUserCategoryBlocks(userID string, teamID string) ([]model.CategoryBlocks, error) {
return s.getUserCategoryBlocks(s.db, userID, teamID)
}
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)
}
tx, txErr := s.db.BeginTx(context.Background(), nil)
if txErr != nil {
return txErr
}
err := s.insertBlock(tx, block, userID)
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
}
func (s *SQLStore) InsertBlocks(blocks []model.Block, userID string) error {
if s.dbType == model.SqliteDBType {
return s.insertBlocks(s.db, blocks, userID)
}
tx, txErr := s.db.BeginTx(context.Background(), nil)
if txErr != nil {
return txErr
}
err := s.insertBlocks(tx, blocks, userID)
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
}
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)
}
tx, txErr := s.db.BeginTx(context.Background(), nil)
if txErr != nil {
return txErr
}
err := s.patchBlock(tx, blockID, blockPatch, userID)
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
}
func (s *SQLStore) PatchBlocks(blockPatches *model.BlockPatchBatch, userID string) error {
if s.dbType == model.SqliteDBType {
return s.patchBlocks(s.db, blockPatches, userID)
}
tx, txErr := s.db.BeginTx(context.Background(), nil)
if txErr != nil {
return txErr
}
err := s.patchBlocks(tx, blockPatches, userID)
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
}
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
}
func (s *SQLStore) PatchUserProps(userID string, patch model.UserPropPatch) error {
return s.patchUserProps(s.db, userID, patch)
}
func (s *SQLStore) RefreshSession(session *model.Session) error {
return s.refreshSession(s.db, session)
}
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)
}
func (s *SQLStore) SetSystemSetting(key string, value string) error {
return s.setSystemSetting(s.db, key, value)
}
func (s *SQLStore) UndeleteBlock(blockID string, modifiedBy string) error {
if s.dbType == model.SqliteDBType {
return s.undeleteBlock(s.db, blockID, modifiedBy)
}
tx, txErr := s.db.BeginTx(context.Background(), nil)
if txErr != nil {
return txErr
}
err := s.undeleteBlock(tx, blockID, modifiedBy)
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
}
func (s *SQLStore) UpdateCategory(category model.Category) error {
return s.updateCategory(s.db, category)
}
func (s *SQLStore) UpdateSession(session *model.Session) error {
return s.updateSession(s.db, session)
}
func (s *SQLStore) UpdateSubscribersNotifiedAt(blockID string, notifiedAt int64) error {
return s.updateSubscribersNotifiedAt(s.db, blockID, notifiedAt)
}
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)
}
func (s *SQLStore) UpsertNotificationHint(hint *model.NotificationHint, notificationFreq time.Duration) (*model.NotificationHint, error) {
return s.upsertNotificationHint(s.db, hint, notificationFreq)
}
func (s *SQLStore) UpsertSharing(sharing model.Sharing) error {
return s.upsertSharing(s.db, sharing)
}
func (s *SQLStore) UpsertTeamSettings(team model.Team) error {
return s.upsertTeamSettings(s.db, team)
}
func (s *SQLStore) UpsertTeamSignupToken(team model.Team) error {
return s.upsertTeamSignupToken(s.db, team)
}