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"
|
|
|
|
|
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 0ad78aed65745521c0bb45790c9ea91b6c316c44.
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 23:47:49 +02:00
|
|
|
mmModel "github.com/mattermost/mattermost-server/v6/model"
|
2021-10-22 12:48:53 +02:00
|
|
|
"github.com/mattermost/mattermost-server/v6/shared/mlog"
|
|
|
|
)
|
|
|
|
|
2022-04-14 00:10:53 +02:00
|
|
|
func (s *SQLStore) AddUpdateCategoryBoard(userID string, categoryID string, blockID string) error {
|
2022-04-20 17:21:53 +02:00
|
|
|
if s.dbType == model.SqliteDBType {
|
|
|
|
return s.addUpdateCategoryBoard(s.db, userID, categoryID, blockID)
|
|
|
|
}
|
|
|
|
tx, txErr := s.db.BeginTx(context.Background(), nil)
|
|
|
|
if txErr != nil {
|
|
|
|
return txErr
|
|
|
|
}
|
|
|
|
err := s.addUpdateCategoryBoard(tx, userID, categoryID, blockID)
|
|
|
|
if err != nil {
|
|
|
|
if rollbackErr := tx.Rollback(); rollbackErr != nil {
|
|
|
|
s.logger.Error("transaction rollback error", mlog.Err(rollbackErr), mlog.String("methodName", "AddUpdateCategoryBoard"))
|
|
|
|
}
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
if err := tx.Commit(); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
2022-03-22 15:24:34 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
|
|
|
}
|
|
|
|
|
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 0ad78aed65745521c0bb45790c9ea91b6c316c44.
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 23:47:49 +02:00
|
|
|
func (s *SQLStore) GetBlockHistoryDescendants(boardID string, opts model.QueryBlockHistoryOptions) ([]model.Block, error) {
|
|
|
|
return s.getBlockHistoryDescendants(s.db, boardID, opts)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-06-15 12:17:44 +02:00
|
|
|
func (s *SQLStore) GetBlocksByIDs(ids []string) ([]model.Block, error) {
|
|
|
|
return s.getBlocksByIDs(s.db, ids)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
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-04-08 19:31:28 +02:00
|
|
|
func (s *SQLStore) GetBoardHistory(boardID string, opts model.QueryBoardHistoryOptions) ([]*model.Board, error) {
|
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 0ad78aed65745521c0bb45790c9ea91b6c316c44.
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 23:47:49 +02:00
|
|
|
return s.getBoardHistory(s.db, boardID, opts)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-03-29 10:17:19 +02:00
|
|
|
func (s *SQLStore) GetBoardMemberHistory(boardID string, userID string, limit uint64) ([]*model.BoardMemberHistoryEntry, error) {
|
|
|
|
return s.getBoardMemberHistory(s.db, boardID, userID, limit)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
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-06-15 12:17:44 +02:00
|
|
|
func (s *SQLStore) GetCardLimitTimestamp() (int64, error) {
|
|
|
|
return s.getCardLimitTimestamp(s.db)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
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-06-15 12:17:44 +02:00
|
|
|
func (s *SQLStore) GetCloudLimits() (*mmModel.ProductLimits, error) {
|
|
|
|
return s.getCloudLimits(s.db)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-06-13 10:05:42 +02:00
|
|
|
func (s *SQLStore) GetFileInfo(id string) (*mmModel.FileInfo, error) {
|
|
|
|
return s.getFileInfo(s.db, id)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
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 0ad78aed65745521c0bb45790c9ea91b6c316c44.
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 23:47:49 +02:00
|
|
|
func (s *SQLStore) GetLicense() *mmModel.License {
|
|
|
|
return s.getLicense(s.db)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
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) 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-23 11:51:48 +01:00
|
|
|
func (s *SQLStore) GetTemplateBoards(teamID string, userID string) ([]*model.Board, error) {
|
|
|
|
return s.getTemplateBoards(s.db, teamID, userID)
|
2021-10-22 12:48:53 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-06-15 12:17:44 +02:00
|
|
|
func (s *SQLStore) GetUsedCardsCount() (int, error) {
|
|
|
|
return s.getUsedCardsCount(s.db)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
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-04-14 00:10:53 +02:00
|
|
|
func (s *SQLStore) GetUserCategoryBoards(userID string, teamID string) ([]model.CategoryBoards, error) {
|
|
|
|
return s.getUserCategoryBoards(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)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-04-25 20:58:08 +02:00
|
|
|
func (s *SQLStore) RunDataRetention(globalRetentionDate int64, batchSize int64) (int64, error) {
|
|
|
|
if s.dbType == model.SqliteDBType {
|
|
|
|
return s.runDataRetention(s.db, globalRetentionDate, batchSize)
|
|
|
|
}
|
|
|
|
tx, txErr := s.db.BeginTx(context.Background(), nil)
|
|
|
|
if txErr != nil {
|
|
|
|
return 0, txErr
|
|
|
|
}
|
|
|
|
result, err := s.runDataRetention(tx, globalRetentionDate, batchSize)
|
|
|
|
if err != nil {
|
|
|
|
if rollbackErr := tx.Rollback(); rollbackErr != nil {
|
|
|
|
s.logger.Error("transaction rollback error", mlog.Err(rollbackErr), mlog.String("methodName", "RunDataRetention"))
|
|
|
|
}
|
|
|
|
return 0, err
|
|
|
|
}
|
|
|
|
|
|
|
|
if err := tx.Commit(); err != nil {
|
|
|
|
return 0, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return result, nil
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-06-13 10:05:42 +02:00
|
|
|
func (s *SQLStore) SaveFileInfo(fileInfo *mmModel.FileInfo) error {
|
|
|
|
return s.saveFileInfo(s.db, fileInfo)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-03-22 15:24:34 +01:00
|
|
|
func (s *SQLStore) SaveMember(bm *model.BoardMember) (*model.BoardMember, error) {
|
|
|
|
return s.saveMember(s.db, bm)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-04-20 01:43:40 +02:00
|
|
|
func (s *SQLStore) SearchBoardsForUser(term string, userID string) ([]*model.Board, error) {
|
2022-04-19 06:57:14 +02:00
|
|
|
return s.searchBoardsForUser(s.db, term, userID)
|
2022-03-22 15:24:34 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-06-29 14:35:24 +02:00
|
|
|
func (s *SQLStore) SendMessage(message string, postType string, receipts []string) error {
|
|
|
|
return s.sendMessage(s.db, message, postType, receipts)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
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-04-08 19:31:28 +02:00
|
|
|
func (s *SQLStore) UndeleteBoard(boardID string, modifiedBy string) error {
|
|
|
|
if s.dbType == model.SqliteDBType {
|
|
|
|
return s.undeleteBoard(s.db, boardID, modifiedBy)
|
|
|
|
}
|
|
|
|
tx, txErr := s.db.BeginTx(context.Background(), nil)
|
|
|
|
if txErr != nil {
|
|
|
|
return txErr
|
|
|
|
}
|
|
|
|
err := s.undeleteBoard(tx, boardID, modifiedBy)
|
|
|
|
if err != nil {
|
|
|
|
if rollbackErr := tx.Rollback(); rollbackErr != nil {
|
|
|
|
s.logger.Error("transaction rollback error", mlog.Err(rollbackErr), mlog.String("methodName", "UndeleteBoard"))
|
|
|
|
}
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
if err := tx.Commit(); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-06-15 12:17:44 +02:00
|
|
|
func (s *SQLStore) UpdateCardLimitTimestamp(cardLimit int) (int64, error) {
|
|
|
|
return s.updateCardLimitTimestamp(s.db, cardLimit)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
|
|
|
}
|