focalboard/server/services/store/store.go

130 lines
5.2 KiB
Go
Raw Normal View History

//go:generate mockgen --build_flags=--mod=mod -destination=mockstore/mockstore.go -package mockstore . Store
//go:generate go run ./generators/main.go
2020-10-16 19:20:43 +02:00
package store
import (
"errors"
"fmt"
"time"
"github.com/mattermost/focalboard/server/model"
)
2020-10-16 19:20:43 +02:00
2021-03-26 19:01:54 +01:00
// Conainer represents a container in a store
// Using a struct to make extending this easier in the future.
2021-03-26 19:01:54 +01:00
type Container struct {
WorkspaceID string
}
// Store represents the abstraction of the data storage.
2020-10-16 19:20:43 +02:00
type Store interface {
2021-03-26 19:01:54 +01:00
GetBlocksWithParentAndType(c Container, parentID string, blockType string) ([]model.Block, error)
GetBlocksWithParent(c Container, parentID string) ([]model.Block, error)
GetBlocksWithRootID(c Container, rootID string) ([]model.Block, error)
2021-03-26 19:01:54 +01:00
GetBlocksWithType(c Container, blockType string) ([]model.Block, error)
GetSubTree2(c Container, blockID string, opts model.QuerySubtreeOptions) ([]model.Block, error)
GetSubTree3(c Container, blockID string, opts model.QuerySubtreeOptions) ([]model.Block, error)
2021-03-26 19:01:54 +01:00
GetAllBlocks(c Container) ([]model.Block, error)
GetRootID(c Container, blockID string) (string, error)
GetParentID(c Container, blockID string) (string, error)
// @withTransaction
InsertBlock(c Container, block *model.Block, userID string) error
// @withTransaction
InsertBlocks(c Container, blocks []model.Block, userID string) error
// @withTransaction
2021-03-26 19:01:54 +01:00
DeleteBlock(c Container, blockID string, modifiedBy string) error
// @withTransaction
UndeleteBlock(c Container, blockID string, modifiedBy string) error
GetBlockCountsByType() (map[string]int64, error)
GetBlock(c Container, blockID string) (*model.Block, error)
// @withTransaction
PatchBlock(c Container, blockID string, blockPatch *model.BlockPatch, userID string) error
GetBlockHistory(c Container, blockID string, opts model.QueryBlockHistoryOptions) ([]model.Block, error)
GetBoardAndCardByID(c Container, blockID string) (board *model.Block, card *model.Block, err error)
GetBoardAndCard(c Container, block *model.Block) (board *model.Block, card *model.Block, err error)
// @withTransaction
PatchBlocks(c Container, blockPatches *model.BlockPatchBatch, userID string) error
2021-01-13 00:35:30 +01:00
Shutdown() error
2021-01-13 00:35:30 +01:00
GetSystemSetting(key string) (string, error)
GetSystemSettings() (map[string]string, error)
2021-03-21 09:28:26 +01:00
SetSystemSetting(key, value string) error
2021-01-13 00:35:30 +01:00
2021-01-27 18:22:33 +01:00
GetRegisteredUserCount() (int, error)
GetUserByID(userID string) (*model.User, error)
2020-11-06 16:46:35 +01:00
GetUserByEmail(email string) (*model.User, error)
GetUserByUsername(username string) (*model.User, error)
CreateUser(user *model.User) error
UpdateUser(user *model.User) error
2021-03-21 09:28:26 +01:00
UpdateUserPassword(username, password string) error
UpdateUserPasswordByID(userID, password string) error
GetUsersByWorkspace(workspaceID string) ([]*model.User, error)
Merge Onboarding feature branch into main (#2406) * Persistent user config (#2133) * Added user config API * Add unit tests * lint fix * Fixed webapp tests * Fixed webapp tests * Updated props in store after updating * Minor fixes * Removed redundent data from audit logs * Onboarding Tour (#2287) * Created private board * Roughly displayed tour * Synced with Dhama's changes * WIP * Trying to add GIF * Added 3 tour steps * WIP * WIP * WIP * checked in missed file * Synced with feature branch * WIp * Adde skip tour option * Fixed image loading for on-prem * Made tour work on presonal server: * Adde missed file * Adding telemetry * Adding telemetry * Added tour tip telemetry * Fixed pulsating dot styling for personal server * reverted personal config * Added reset tour button * Displayed share tour tip of feature is enabled * Lint fixes * Fixed webapp tests * Fixed webapp tests * Completed webapp tests * Completed webapp tests * Webapp lint fixes * Added server tests * Testing cypress skip tour fix * Fixed Cypress tests * Added share board tour step * Added share board tour step * webapp lint fixes * Updated logic to pick welcome board * Updated tests: * lint fixes * Updating UI changes * Fixed a bug causing card tour to re-appear * FIxed minor issue * FIxed bug where card tour didn't start in clickingh on card * Fixed tests * Make update user props use string instead of interface * Fixed a value type * Updating gif size * Updating resolution breakpoint * Updating tutorial tip * Updating view selector * Refactored tour components * Misc fixes * minor refactoring * GH-2258: allow date range to overflow (#2268) * allow date range to overflow * Fixed issue with date overflowing into neighbouring column Co-authored-by: Harshil Sharma <harshilsharma63@gmail.com> Co-authored-by: Mattermod <mattermod@users.noreply.github.com> * Update readme with accurate Linux standalone app build instructions (#2351) * Bump follow-redirects from 1.14.7 to 1.14.8 in /experiments/webext (#2339) Bumps [follow-redirects](https://github.com/follow-redirects/follow-redirects) from 1.14.7 to 1.14.8. - [Release notes](https://github.com/follow-redirects/follow-redirects/releases) - [Commits](https://github.com/follow-redirects/follow-redirects/compare/v1.14.7...v1.14.8) --- updated-dependencies: - dependency-name: follow-redirects dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Switch component style fixed: selector specificity increased by adding additional class. (#2179) * Adding sever side undelete endpoint (#2222) * Adding sever side undelete endpoint * Removing long lines golangci-lint errors * Fixing linter errors * Fixing a test problem * Fixing tests Co-authored-by: Mattermod <mattermod@users.noreply.github.com> * Removing transactions from sqlite backend (#2361) * Removing transactions from sqlite backend * Skipping tests in sqlite because the lack of transactions * Generating the mocks * Fixing golangci-lint * Fixing problem opening the tour tooltip on card open * Fixing texts missmatch * Adding the Product Tour entry in the user settings menu * Fixing some tests * Fixing tests Co-authored-by: Asaad Mahmood <asaadmahmood@users.noreply.github.com> Co-authored-by: Scott Bishel <scott.bishel@mattermost.com> Co-authored-by: Mattermod <mattermod@users.noreply.github.com> Co-authored-by: Doug Lauder <wiggin77@warpmail.net> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: kamre <eremchenko@gmail.com> Co-authored-by: Jesús Espino <jespinog@gmail.com> * Restored package json * Restored package json Co-authored-by: Asaad Mahmood <asaadmahmood@users.noreply.github.com> Co-authored-by: Scott Bishel <scott.bishel@mattermost.com> Co-authored-by: Mattermod <mattermod@users.noreply.github.com> Co-authored-by: Doug Lauder <wiggin77@warpmail.net> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: kamre <eremchenko@gmail.com> Co-authored-by: Jesús Espino <jespinog@gmail.com>
2022-02-28 12:28:16 +01:00
PatchUserProps(userID string, patch model.UserPropPatch) error
2021-01-13 00:35:30 +01:00
2021-01-27 19:01:24 +01:00
GetActiveUserCount(updatedSecondsAgo int64) (int, error)
2020-12-07 17:04:35 +01:00
GetSession(token string, expireTime int64) (*model.Session, error)
2020-12-02 21:12:14 +01:00
CreateSession(session *model.Session) error
RefreshSession(session *model.Session) error
UpdateSession(session *model.Session) error
DeleteSession(sessionID string) error
2020-12-07 17:04:35 +01:00
CleanUpSessions(expireTime int64) error
2021-01-13 00:35:30 +01:00
2021-03-26 19:01:54 +01:00
UpsertSharing(c Container, sharing model.Sharing) error
GetSharing(c Container, rootID string) (*model.Sharing, error)
2021-01-14 01:56:01 +01:00
UpsertWorkspaceSignupToken(workspace model.Workspace) error
UpsertWorkspaceSettings(workspace model.Workspace) error
GetWorkspace(ID string) (*model.Workspace, error)
HasWorkspaceAccess(userID string, workspaceID string) (bool, error)
GetWorkspaceCount() (int64, error)
GetUserWorkspaces(userID string) ([]model.UserWorkspace, error)
Merge Onboarding feature branch into main (#2406) * Persistent user config (#2133) * Added user config API * Add unit tests * lint fix * Fixed webapp tests * Fixed webapp tests * Updated props in store after updating * Minor fixes * Removed redundent data from audit logs * Onboarding Tour (#2287) * Created private board * Roughly displayed tour * Synced with Dhama's changes * WIP * Trying to add GIF * Added 3 tour steps * WIP * WIP * WIP * checked in missed file * Synced with feature branch * WIp * Adde skip tour option * Fixed image loading for on-prem * Made tour work on presonal server: * Adde missed file * Adding telemetry * Adding telemetry * Added tour tip telemetry * Fixed pulsating dot styling for personal server * reverted personal config * Added reset tour button * Displayed share tour tip of feature is enabled * Lint fixes * Fixed webapp tests * Fixed webapp tests * Completed webapp tests * Completed webapp tests * Webapp lint fixes * Added server tests * Testing cypress skip tour fix * Fixed Cypress tests * Added share board tour step * Added share board tour step * webapp lint fixes * Updated logic to pick welcome board * Updated tests: * lint fixes * Updating UI changes * Fixed a bug causing card tour to re-appear * FIxed minor issue * FIxed bug where card tour didn't start in clickingh on card * Fixed tests * Make update user props use string instead of interface * Fixed a value type * Updating gif size * Updating resolution breakpoint * Updating tutorial tip * Updating view selector * Refactored tour components * Misc fixes * minor refactoring * GH-2258: allow date range to overflow (#2268) * allow date range to overflow * Fixed issue with date overflowing into neighbouring column Co-authored-by: Harshil Sharma <harshilsharma63@gmail.com> Co-authored-by: Mattermod <mattermod@users.noreply.github.com> * Update readme with accurate Linux standalone app build instructions (#2351) * Bump follow-redirects from 1.14.7 to 1.14.8 in /experiments/webext (#2339) Bumps [follow-redirects](https://github.com/follow-redirects/follow-redirects) from 1.14.7 to 1.14.8. - [Release notes](https://github.com/follow-redirects/follow-redirects/releases) - [Commits](https://github.com/follow-redirects/follow-redirects/compare/v1.14.7...v1.14.8) --- updated-dependencies: - dependency-name: follow-redirects dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Switch component style fixed: selector specificity increased by adding additional class. (#2179) * Adding sever side undelete endpoint (#2222) * Adding sever side undelete endpoint * Removing long lines golangci-lint errors * Fixing linter errors * Fixing a test problem * Fixing tests Co-authored-by: Mattermod <mattermod@users.noreply.github.com> * Removing transactions from sqlite backend (#2361) * Removing transactions from sqlite backend * Skipping tests in sqlite because the lack of transactions * Generating the mocks * Fixing golangci-lint * Fixing problem opening the tour tooltip on card open * Fixing texts missmatch * Adding the Product Tour entry in the user settings menu * Fixing some tests * Fixing tests Co-authored-by: Asaad Mahmood <asaadmahmood@users.noreply.github.com> Co-authored-by: Scott Bishel <scott.bishel@mattermost.com> Co-authored-by: Mattermod <mattermod@users.noreply.github.com> Co-authored-by: Doug Lauder <wiggin77@warpmail.net> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: kamre <eremchenko@gmail.com> Co-authored-by: Jesús Espino <jespinog@gmail.com> * Restored package json * Restored package json Co-authored-by: Asaad Mahmood <asaadmahmood@users.noreply.github.com> Co-authored-by: Scott Bishel <scott.bishel@mattermost.com> Co-authored-by: Mattermod <mattermod@users.noreply.github.com> Co-authored-by: Doug Lauder <wiggin77@warpmail.net> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: kamre <eremchenko@gmail.com> Co-authored-by: Jesús Espino <jespinog@gmail.com>
2022-02-28 12:28:16 +01:00
CreatePrivateWorkspace(userID string) (string, error)
CreateSubscription(c Container, sub *model.Subscription) (*model.Subscription, error)
DeleteSubscription(c Container, blockID string, subscriberID string) error
GetSubscription(c Container, blockID string, subscriberID string) (*model.Subscription, error)
GetSubscriptions(c Container, subscriberID string) ([]*model.Subscription, error)
GetSubscribersForBlock(c Container, blockID string) ([]*model.Subscriber, error)
GetSubscribersCountForBlock(c Container, blockID string) (int, error)
UpdateSubscribersNotifiedAt(c Container, blockID string, notifiedAt int64) error
UpsertNotificationHint(hint *model.NotificationHint, notificationFreq time.Duration) (*model.NotificationHint, error)
DeleteNotificationHint(c Container, blockID string) error
GetNotificationHint(c Container, blockID string) (*model.NotificationHint, error)
GetNextNotificationHint(remove bool) (*model.NotificationHint, error)
RemoveDefaultTemplates(blocks []model.Block) error
GetDefaultTemplateBlocks() ([]model.Block, error)
DBType() string
IsErrNotFound(err error) bool
}
// ErrNotFound is an error type that can be returned by store APIs when a query unexpectedly fetches no records.
type ErrNotFound struct {
resource string
}
// NewErrNotFound creates a new ErrNotFound instance.
func NewErrNotFound(resource string) *ErrNotFound {
return &ErrNotFound{
resource: resource,
}
}
func (nf *ErrNotFound) Error() string {
return fmt.Sprintf("{%s} not found", nf.resource)
}
// IsErrNotFound returns true if `err` is or wraps a ErrNotFound.
func IsErrNotFound(err error) bool {
if err == nil {
return false
}
var nf *ErrNotFound
return errors.As(err, &nf)
2020-10-16 19:20:43 +02:00
}