08db4fed61
* API WIP * WIP * Finished changes * Fixed colors: * Don't enforce charset adn collation in migration, pick from database DSN * Added MySQL query * Updated mocks * Added tests * Lint fixes * Fixed typo and removed unsed style * Checked in a snapshot * Updated snapshot * Updated Cypress test * Updated Cypress test * Updated Cypress test * Fixed review comments * Fixed tests * Added default collation for MySQL * Added documentation for ensuring correct database collation * Updated migrations * Fixed a bug with collation * Fixed lint errors * Used correct collation * debugging * Updating css * Minor UI changes * USe inbuilt default collation * Used only charset for mysql * Fixed linter issue: * Added migration for matching collation * Reverted local config changes * Reverted local config changes * Handled the case of personal server running on MySQL * WIP * Now running collation matching migration onlyt for plugins * Minor optimization * Multiple review fixes * Added group by clause to primary query * Supported for subpacth Co-authored-by: Asaad Mahmood <asaadmahmood@users.noreply.github.com>
67 lines
1.7 KiB
Go
67 lines
1.7 KiB
Go
package app
|
|
|
|
import (
|
|
"database/sql"
|
|
"errors"
|
|
|
|
"github.com/mattermost/focalboard/server/model"
|
|
"github.com/mattermost/focalboard/server/utils"
|
|
|
|
"github.com/mattermost/mattermost-server/v6/shared/mlog"
|
|
)
|
|
|
|
func (a *App) GetRootWorkspace() (*model.Workspace, error) {
|
|
workspaceID := "0"
|
|
workspace, _ := a.store.GetWorkspace(workspaceID)
|
|
if workspace == nil {
|
|
workspace = &model.Workspace{
|
|
ID: workspaceID,
|
|
SignupToken: utils.CreateGUID(),
|
|
}
|
|
err := a.store.UpsertWorkspaceSignupToken(*workspace)
|
|
if err != nil {
|
|
a.logger.Fatal("Unable to initialize workspace", mlog.Err(err))
|
|
return nil, err
|
|
}
|
|
workspace, err = a.store.GetWorkspace(workspaceID)
|
|
if err != nil {
|
|
a.logger.Fatal("Unable to get initialized workspace", mlog.Err(err))
|
|
return nil, err
|
|
}
|
|
|
|
a.logger.Info("initialized workspace")
|
|
}
|
|
|
|
return workspace, nil
|
|
}
|
|
|
|
func (a *App) GetWorkspace(id string) (*model.Workspace, error) {
|
|
workspace, err := a.store.GetWorkspace(id)
|
|
if errors.Is(err, sql.ErrNoRows) {
|
|
return nil, nil
|
|
}
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return workspace, nil
|
|
}
|
|
|
|
func (a *App) DoesUserHaveWorkspaceAccess(userID string, workspaceID string) bool {
|
|
return a.auth.DoesUserHaveWorkspaceAccess(userID, workspaceID)
|
|
}
|
|
|
|
func (a *App) UpsertWorkspaceSettings(workspace model.Workspace) error {
|
|
return a.store.UpsertWorkspaceSettings(workspace)
|
|
}
|
|
|
|
func (a *App) UpsertWorkspaceSignupToken(workspace model.Workspace) error {
|
|
return a.store.UpsertWorkspaceSignupToken(workspace)
|
|
}
|
|
|
|
func (a *App) GetWorkspaceCount() (int64, error) {
|
|
return a.store.GetWorkspaceCount()
|
|
}
|
|
|
|
func (a *App) GetUserWorkspaces(userID string) ([]model.UserWorkspace, error) {
|
|
return a.store.GetUserWorkspaces(userID)
|
|
}
|