mirror of
https://github.com/mattermost/focalboard.git
synced 2025-01-26 18:48:15 +02:00
chore(format): update coding style
This commit is contained in:
parent
5609d9e9ce
commit
2b4e03eed6
@ -513,7 +513,7 @@ func (a *API) handleExport(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
func filterOrphanBlocks(blocks []model.Block) (ret []model.Block) {
|
func filterOrphanBlocks(blocks []model.Block) (ret []model.Block) {
|
||||||
queue := make([]model.Block, 0)
|
queue := make([]model.Block, 0)
|
||||||
var childrenOfBlockWithID = make(map[string]*[]model.Block)
|
childrenOfBlockWithID := make(map[string]*[]model.Block)
|
||||||
|
|
||||||
// Build the trees from nodes
|
// Build the trees from nodes
|
||||||
for _, block := range blocks {
|
for _, block := range blocks {
|
||||||
|
@ -16,7 +16,7 @@ func (a *App) GetSession(token string) (*model.Session, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// IsValidReadToken validates the read token for a block
|
// IsValidReadToken validates the read token for a block
|
||||||
func (a *App) IsValidReadToken(blockID string, readToken string) (bool, error) {
|
func (a *App) IsValidReadToken(blockID, readToken string) (bool, error) {
|
||||||
return a.auth.IsValidReadToken(blockID, readToken)
|
return a.auth.IsValidReadToken(blockID, readToken)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,7 +57,7 @@ func (a *App) GetUser(ID string) (*model.User, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Login create a new user session if the authentication data is valid
|
// Login create a new user session if the authentication data is valid
|
||||||
func (a *App) Login(username string, email string, password string, mfaToken string) (string, error) {
|
func (a *App) Login(username, email, password, mfaToken string) (string, error) {
|
||||||
var user *model.User
|
var user *model.User
|
||||||
if username != "" {
|
if username != "" {
|
||||||
var err error
|
var err error
|
||||||
@ -99,7 +99,7 @@ func (a *App) Login(username string, email string, password string, mfaToken str
|
|||||||
}
|
}
|
||||||
|
|
||||||
// RegisterUser create a new user if the provided data is valid
|
// RegisterUser create a new user if the provided data is valid
|
||||||
func (a *App) RegisterUser(username string, email string, password string) error {
|
func (a *App) RegisterUser(username, email, password string) error {
|
||||||
var user *model.User
|
var user *model.User
|
||||||
if username != "" {
|
if username != "" {
|
||||||
var err error
|
var err error
|
||||||
@ -144,7 +144,7 @@ func (a *App) RegisterUser(username string, email string, password string) error
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) UpdateUserPassword(username string, password string) error {
|
func (a *App) UpdateUserPassword(username, password string) error {
|
||||||
err := a.store.UpdateUserPassword(username, auth.HashPassword(password))
|
err := a.store.UpdateUserPassword(username, auth.HashPassword(password))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -153,7 +153,7 @@ func (a *App) UpdateUserPassword(username string, password string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) ChangePassword(userID string, oldPassword string, newPassword string) error {
|
func (a *App) ChangePassword(userID, oldPassword, newPassword string) error {
|
||||||
var user *model.User
|
var user *model.User
|
||||||
if userID != "" {
|
if userID != "" {
|
||||||
var err error
|
var err error
|
||||||
|
@ -4,7 +4,7 @@ import (
|
|||||||
"github.com/mattermost/focalboard/server/model"
|
"github.com/mattermost/focalboard/server/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (a *App) GetBlocks(parentID string, blockType string) ([]model.Block, error) {
|
func (a *App) GetBlocks(parentID, blockType string) ([]model.Block, error) {
|
||||||
if len(blockType) > 0 && len(parentID) > 0 {
|
if len(blockType) > 0 && len(parentID) > 0 {
|
||||||
return a.store.GetBlocksWithParentAndType(parentID, blockType)
|
return a.store.GetBlocksWithParentAndType(parentID, blockType)
|
||||||
}
|
}
|
||||||
@ -67,7 +67,7 @@ func (a *App) GetAllBlocks() ([]model.Block, error) {
|
|||||||
return a.store.GetAllBlocks()
|
return a.store.GetAllBlocks()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) DeleteBlock(blockID string, modifiedBy string) error {
|
func (a *App) DeleteBlock(blockID, modifiedBy string) error {
|
||||||
blockIDsToNotify := []string{blockID}
|
blockIDsToNotify := []string{blockID}
|
||||||
parentID, err := a.GetParentID(blockID)
|
parentID, err := a.GetParentID(blockID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -38,7 +38,7 @@ func (a *Auth) GetSession(token string) (*model.Session, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// IsValidReadToken validates the read token for a block
|
// IsValidReadToken validates the read token for a block
|
||||||
func (a *Auth) IsValidReadToken(blockID string, readToken string) (bool, error) {
|
func (a *Auth) IsValidReadToken(blockID, readToken string) (bool, error) {
|
||||||
rootID, err := a.store.GetRootID(blockID)
|
rootID, err := a.store.GetRootID(blockID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
|
@ -63,7 +63,7 @@ type Client struct {
|
|||||||
HttpHeader map[string]string
|
HttpHeader map[string]string
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewClient(url string, sessionToken string) *Client {
|
func NewClient(url, sessionToken string) *Client {
|
||||||
url = strings.TrimRight(url, "/")
|
url = strings.TrimRight(url, "/")
|
||||||
headers := map[string]string{
|
headers := map[string]string{
|
||||||
"X-Requested-With": "XMLHttpRequest",
|
"X-Requested-With": "XMLHttpRequest",
|
||||||
@ -72,11 +72,11 @@ func NewClient(url string, sessionToken string) *Client {
|
|||||||
return &Client{url, url + API_URL_SUFFIX, &http.Client{}, headers}
|
return &Client{url, url + API_URL_SUFFIX, &http.Client{}, headers}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) DoApiGet(url string, etag string) (*http.Response, error) {
|
func (c *Client) DoApiGet(url, etag string) (*http.Response, error) {
|
||||||
return c.DoApiRequest(http.MethodGet, c.ApiUrl+url, "", etag)
|
return c.DoApiRequest(http.MethodGet, c.ApiUrl+url, "", etag)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) DoApiPost(url string, data string) (*http.Response, error) {
|
func (c *Client) DoApiPost(url, data string) (*http.Response, error) {
|
||||||
return c.DoApiRequest(http.MethodPost, c.ApiUrl+url, data, "")
|
return c.DoApiRequest(http.MethodPost, c.ApiUrl+url, data, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,7 +84,7 @@ func (c *Client) doApiPostBytes(url string, data []byte) (*http.Response, error)
|
|||||||
return c.doApiRequestBytes(http.MethodPost, c.ApiUrl+url, data, "")
|
return c.doApiRequestBytes(http.MethodPost, c.ApiUrl+url, data, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) DoApiPut(url string, data string) (*http.Response, error) {
|
func (c *Client) DoApiPut(url, data string) (*http.Response, error) {
|
||||||
return c.DoApiRequest(http.MethodPut, c.ApiUrl+url, data, "")
|
return c.DoApiRequest(http.MethodPut, c.ApiUrl+url, data, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,7 +179,6 @@ func TestDeleteBlock(t *testing.T) {
|
|||||||
blockIDs[i] = b.ID
|
blockIDs[i] = b.ID
|
||||||
}
|
}
|
||||||
require.Contains(t, blockIDs, blockID)
|
require.Contains(t, blockIDs, blockID)
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("Delete a block", func(t *testing.T) {
|
t.Run("Delete a block", func(t *testing.T) {
|
||||||
|
@ -159,7 +159,7 @@ func main() {
|
|||||||
|
|
||||||
// StartServer starts the server
|
// StartServer starts the server
|
||||||
//export StartServer
|
//export StartServer
|
||||||
func StartServer(webPath *C.char, port int, singleUserToken *C.char, dbConfigString *C.char) {
|
func StartServer(webPath *C.char, port int, singleUserToken, dbConfigString *C.char) {
|
||||||
startServer(
|
startServer(
|
||||||
C.GoString(webPath),
|
C.GoString(webPath),
|
||||||
port,
|
port,
|
||||||
@ -174,7 +174,7 @@ func StopServer() {
|
|||||||
stopServer()
|
stopServer()
|
||||||
}
|
}
|
||||||
|
|
||||||
func startServer(webPath string, port int, singleUserToken string, dbConfigString string) {
|
func startServer(webPath string, port int, singleUserToken, dbConfigString string) {
|
||||||
logInfo()
|
logInfo()
|
||||||
|
|
||||||
if pServer != nil {
|
if pServer != nil {
|
||||||
|
@ -9,8 +9,10 @@ var versions = []string{
|
|||||||
"0.5.0",
|
"0.5.0",
|
||||||
}
|
}
|
||||||
|
|
||||||
var CurrentVersion string = versions[0]
|
var (
|
||||||
var BuildNumber string
|
CurrentVersion string = versions[0]
|
||||||
var BuildDate string
|
BuildNumber string
|
||||||
var BuildHash string
|
BuildDate string
|
||||||
var Edition string
|
BuildHash string
|
||||||
|
Edition string
|
||||||
|
)
|
||||||
|
@ -2,9 +2,7 @@ package auth
|
|||||||
|
|
||||||
import "regexp"
|
import "regexp"
|
||||||
|
|
||||||
var (
|
var emailRegex = regexp.MustCompile("^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$")
|
||||||
emailRegex = regexp.MustCompile("^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$")
|
|
||||||
)
|
|
||||||
|
|
||||||
// IsEmailValid checks if the email provided passes the required structure and length.
|
// IsEmailValid checks if the email provided passes the required structure and length.
|
||||||
func IsEmailValid(e string) bool {
|
func IsEmailValid(e string) bool {
|
||||||
|
@ -38,7 +38,7 @@ func HashPassword(password string) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ComparePassword compares the hash
|
// ComparePassword compares the hash
|
||||||
func ComparePassword(hash string, password string) bool {
|
func ComparePassword(hash, password string) bool {
|
||||||
if len(password) == 0 || len(hash) == 0 {
|
if len(password) == 0 || len(hash) == 0 {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ func (s *SQLStore) latestsBlocksSubquery() sq.SelectBuilder {
|
|||||||
Where(sq.Eq{"delete_at": 0})
|
Where(sq.Eq{"delete_at": 0})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SQLStore) GetBlocksWithParentAndType(parentID string, blockType string) ([]model.Block, error) {
|
func (s *SQLStore) GetBlocksWithParentAndType(parentID, blockType string) ([]model.Block, error) {
|
||||||
query := s.getQueryBuilder().
|
query := s.getQueryBuilder().
|
||||||
Select(
|
Select(
|
||||||
"id",
|
"id",
|
||||||
@ -218,7 +218,7 @@ func (s *SQLStore) GetAllBlocks() ([]model.Block, error) {
|
|||||||
func blocksFromRows(rows *sql.Rows) ([]model.Block, error) {
|
func blocksFromRows(rows *sql.Rows) ([]model.Block, error) {
|
||||||
defer rows.Close()
|
defer rows.Close()
|
||||||
|
|
||||||
var results = []model.Block{}
|
results := []model.Block{}
|
||||||
|
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
var block model.Block
|
var block model.Block
|
||||||
@ -341,7 +341,7 @@ func (s *SQLStore) InsertBlock(block model.Block) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SQLStore) DeleteBlock(blockID string, modifiedBy string) error {
|
func (s *SQLStore) DeleteBlock(blockID, modifiedBy string) error {
|
||||||
now := time.Now().Unix()
|
now := time.Now().Unix()
|
||||||
query := s.getQueryBuilder().Insert("blocks").
|
query := s.getQueryBuilder().Insert("blocks").
|
||||||
Columns(
|
Columns(
|
||||||
|
@ -26,7 +26,7 @@ func (s *SQLStore) GetSystemSettings() (map[string]string, error) {
|
|||||||
return results, nil
|
return results, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SQLStore) SetSystemSetting(id string, value string) error {
|
func (s *SQLStore) SetSystemSetting(id, value string) error {
|
||||||
query := s.getQueryBuilder().Insert("system_settings").Columns("id", "value").Values(id, value)
|
query := s.getQueryBuilder().Insert("system_settings").Columns("id", "value").Values(id, value)
|
||||||
|
|
||||||
_, err := query.Exec()
|
_, err := query.Exec()
|
||||||
|
@ -109,7 +109,7 @@ func (s *SQLStore) UpdateUser(user *model.User) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SQLStore) UpdateUserPassword(username string, password string) error {
|
func (s *SQLStore) UpdateUserPassword(username, password string) error {
|
||||||
now := time.Now().Unix()
|
now := time.Now().Unix()
|
||||||
|
|
||||||
query := s.getQueryBuilder().Update("users").
|
query := s.getQueryBuilder().Update("users").
|
||||||
@ -134,7 +134,7 @@ func (s *SQLStore) UpdateUserPassword(username string, password string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SQLStore) UpdateUserPasswordByID(userID string, password string) error {
|
func (s *SQLStore) UpdateUserPasswordByID(userID, password string) error {
|
||||||
now := time.Now().Unix()
|
now := time.Now().Unix()
|
||||||
|
|
||||||
query := s.getQueryBuilder().Update("users").
|
query := s.getQueryBuilder().Update("users").
|
||||||
|
@ -5,7 +5,7 @@ import "github.com/mattermost/focalboard/server/model"
|
|||||||
|
|
||||||
// Store represents the abstraction of the data storage.
|
// Store represents the abstraction of the data storage.
|
||||||
type Store interface {
|
type Store interface {
|
||||||
GetBlocksWithParentAndType(parentID string, blockType string) ([]model.Block, error)
|
GetBlocksWithParentAndType(parentID, blockType string) ([]model.Block, error)
|
||||||
GetBlocksWithParent(parentID string) ([]model.Block, error)
|
GetBlocksWithParent(parentID string) ([]model.Block, error)
|
||||||
GetBlocksWithType(blockType string) ([]model.Block, error)
|
GetBlocksWithType(blockType string) ([]model.Block, error)
|
||||||
GetSubTree2(blockID string) ([]model.Block, error)
|
GetSubTree2(blockID string) ([]model.Block, error)
|
||||||
@ -14,12 +14,12 @@ type Store interface {
|
|||||||
GetRootID(blockID string) (string, error)
|
GetRootID(blockID string) (string, error)
|
||||||
GetParentID(blockID string) (string, error)
|
GetParentID(blockID string) (string, error)
|
||||||
InsertBlock(block model.Block) error
|
InsertBlock(block model.Block) error
|
||||||
DeleteBlock(blockID string, modifiedBy string) error
|
DeleteBlock(blockID, modifiedBy string) error
|
||||||
|
|
||||||
Shutdown() error
|
Shutdown() error
|
||||||
|
|
||||||
GetSystemSettings() (map[string]string, error)
|
GetSystemSettings() (map[string]string, error)
|
||||||
SetSystemSetting(key string, value string) error
|
SetSystemSetting(key, value string) error
|
||||||
|
|
||||||
GetRegisteredUserCount() (int, error)
|
GetRegisteredUserCount() (int, error)
|
||||||
GetUserById(userID string) (*model.User, error)
|
GetUserById(userID string) (*model.User, error)
|
||||||
@ -27,8 +27,8 @@ type Store interface {
|
|||||||
GetUserByUsername(username string) (*model.User, error)
|
GetUserByUsername(username string) (*model.User, error)
|
||||||
CreateUser(user *model.User) error
|
CreateUser(user *model.User) error
|
||||||
UpdateUser(user *model.User) error
|
UpdateUser(user *model.User) error
|
||||||
UpdateUserPassword(username string, password string) error
|
UpdateUserPassword(username, password string) error
|
||||||
UpdateUserPasswordByID(userID string, password string) error
|
UpdateUserPasswordByID(userID, password string) error
|
||||||
|
|
||||||
GetActiveUserCount(updatedSecondsAgo int64) (int, error)
|
GetActiveUserCount(updatedSecondsAgo int64) (int, error)
|
||||||
GetSession(token string, expireTime int64) (*model.Session, error)
|
GetSession(token string, expireTime int64) (*model.Session, error)
|
||||||
|
@ -81,7 +81,7 @@ func (ts *Service) sendTelemetry(event string, properties map[string]interface{}
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ts *Service) initRudder(endpoint string, rudderKey string) {
|
func (ts *Service) initRudder(endpoint, rudderKey string) {
|
||||||
if ts.rudderClient == nil {
|
if ts.rudderClient == nil {
|
||||||
config := rudder.Config{}
|
config := rudder.Config{}
|
||||||
config.Logger = rudder.StdLogger(ts.log)
|
config.Logger = rudder.StdLogger(ts.log)
|
||||||
|
@ -29,7 +29,7 @@ type Server struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewServer creates a new instance of the webserver.
|
// NewServer creates a new instance of the webserver.
|
||||||
func NewServer(rootPath string, port int, ssl bool, localOnly bool) *Server {
|
func NewServer(rootPath string, port int, ssl, localOnly bool) *Server {
|
||||||
r := mux.NewRouter()
|
r := mux.NewRouter()
|
||||||
|
|
||||||
var addr string
|
var addr string
|
||||||
|
@ -146,7 +146,7 @@ func (ws *Server) isValidSessionToken(token string) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ws *Server) authenticateListener(wsSession *websocketSession, token string, readToken string) {
|
func (ws *Server) authenticateListener(wsSession *websocketSession, token, readToken string) {
|
||||||
// Authenticate session
|
// Authenticate session
|
||||||
isValidSession := ws.isValidSessionToken(token)
|
isValidSession := ws.isValidSessionToken(token)
|
||||||
if !isValidSession {
|
if !isValidSession {
|
||||||
@ -267,7 +267,7 @@ func (ws *Server) getListeners(blockID string) []*websocket.Conn {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// BroadcastBlockDelete broadcasts delete messages to clients
|
// BroadcastBlockDelete broadcasts delete messages to clients
|
||||||
func (ws *Server) BroadcastBlockDelete(blockID string, parentID string) {
|
func (ws *Server) BroadcastBlockDelete(blockID, parentID string) {
|
||||||
now := time.Now().Unix()
|
now := time.Now().Unix()
|
||||||
block := model.Block{}
|
block := model.Block{}
|
||||||
block.ID = blockID
|
block.ID = blockID
|
||||||
|
Loading…
x
Reference in New Issue
Block a user