Этот коммит содержится в:
Chris
2017-09-06 17:12:54 -05:00
коммит произвёл GitHub
родитель b84bd21089
Коммит 1adfd0e9be
178 изменённых файлов: 2919 добавлений и 2806 удалений

Просмотреть файл

@@ -170,7 +170,7 @@ func createChannelCmdF(cmd *cobra.Command, args []string) error {
CreatorId: "",
}
if _, err := app.CreateChannel(channel, false); err != nil {
if _, err := app.Global().CreateChannel(channel, false); err != nil {
return err
}
@@ -208,7 +208,7 @@ func removeUserFromChannel(channel *model.Channel, user *model.User, userArg str
CommandPrintErrorln("Can't find user '" + userArg + "'")
return
}
if err := app.RemoveUserFromChannel(user.Id, "", channel); err != nil {
if err := app.Global().RemoveUserFromChannel(user.Id, "", channel); err != nil {
CommandPrintErrorln("Unable to remove '" + userArg + "' from " + channel.Name + ". Error: " + err.Error())
}
}
@@ -244,7 +244,7 @@ func addUserToChannel(channel *model.Channel, user *model.User, userArg string)
CommandPrintErrorln("Can't find user '" + userArg + "'")
return
}
if _, err := app.AddUserToChannel(user, channel); err != nil {
if _, err := app.Global().AddUserToChannel(user, channel); err != nil {
CommandPrintErrorln("Unable to add '" + userArg + "' from " + channel.Name + ". Error: " + err.Error())
}
}
@@ -264,7 +264,7 @@ func archiveChannelsCmdF(cmd *cobra.Command, args []string) error {
CommandPrintErrorln("Unable to find channel '" + args[i] + "'")
continue
}
if result := <-app.Srv.Store.Channel().Delete(channel.Id, model.GetMillis()); result.Err != nil {
if result := <-app.Global().Srv.Store.Channel().Delete(channel.Id, model.GetMillis()); result.Err != nil {
CommandPrintErrorln("Unable to archive channel '" + channel.Name + "' error: " + result.Err.Error())
}
}
@@ -308,7 +308,7 @@ func deleteChannelsCmdF(cmd *cobra.Command, args []string) error {
}
func deleteChannel(channel *model.Channel) *model.AppError {
return app.PermanentDeleteChannel(channel)
return app.Global().PermanentDeleteChannel(channel)
}
func moveChannelsCmdF(cmd *cobra.Command, args []string) error {
@@ -344,30 +344,30 @@ func moveChannelsCmdF(cmd *cobra.Command, args []string) error {
func moveChannel(team *model.Team, channel *model.Channel) *model.AppError {
oldTeamId := channel.TeamId
if err := app.MoveChannel(team, channel); err != nil {
if err := app.Global().MoveChannel(team, channel); err != nil {
return err
}
if incomingWebhooks, err := app.GetIncomingWebhooksForTeamPage(oldTeamId, 0, 10000000); err != nil {
if incomingWebhooks, err := app.Global().GetIncomingWebhooksForTeamPage(oldTeamId, 0, 10000000); err != nil {
return err
} else {
for _, webhook := range incomingWebhooks {
if webhook.ChannelId == channel.Id {
webhook.TeamId = team.Id
if result := <-app.Srv.Store.Webhook().UpdateIncoming(webhook); result.Err != nil {
if result := <-app.Global().Srv.Store.Webhook().UpdateIncoming(webhook); result.Err != nil {
CommandPrintErrorln("Failed to move incoming webhook '" + webhook.Id + "' to new team.")
}
}
}
}
if outgoingWebhooks, err := app.GetOutgoingWebhooksForTeamPage(oldTeamId, 0, 10000000); err != nil {
if outgoingWebhooks, err := app.Global().GetOutgoingWebhooksForTeamPage(oldTeamId, 0, 10000000); err != nil {
return err
} else {
for _, webhook := range outgoingWebhooks {
if webhook.ChannelId == channel.Id {
webhook.TeamId = team.Id
if result := <-app.Srv.Store.Webhook().UpdateOutgoing(webhook); result.Err != nil {
if result := <-app.Global().Srv.Store.Webhook().UpdateOutgoing(webhook); result.Err != nil {
CommandPrintErrorln("Failed to move outgoing webhook '" + webhook.Id + "' to new team.")
}
}
@@ -396,7 +396,7 @@ func listChannelsCmdF(cmd *cobra.Command, args []string) error {
CommandPrintErrorln("Unable to find team '" + args[i] + "'")
continue
}
if result := <-app.Srv.Store.Channel().GetAll(team.Id); result.Err != nil {
if result := <-app.Global().Srv.Store.Channel().GetAll(team.Id); result.Err != nil {
CommandPrintErrorln("Unable to list channels for '" + args[i] + "'")
} else {
channels := result.Data.([]*model.Channel)
@@ -433,7 +433,7 @@ func restoreChannelsCmdF(cmd *cobra.Command, args []string) error {
CommandPrintErrorln("Unable to find channel '" + args[i] + "'")
continue
}
if result := <-app.Srv.Store.Channel().SetDeleteAt(channel.Id, 0, model.GetMillis()); result.Err != nil {
if result := <-app.Global().Srv.Store.Channel().SetDeleteAt(channel.Id, 0, model.GetMillis()); result.Err != nil {
CommandPrintErrorln("Unable to restore channel '" + args[i] + "'")
}
}
@@ -475,7 +475,7 @@ func modifyChannelCmdF(cmd *cobra.Command, args []string) error {
channel.Type = model.CHANNEL_PRIVATE
}
if _, err := app.UpdateChannel(channel); err != nil {
if _, err := app.Global().UpdateChannel(channel); err != nil {
return errors.New("Failed to update channel '" + args[0] + "' - " + err.Error())
}

Просмотреть файл

@@ -42,7 +42,7 @@ func getChannelFromChannelArg(channelArg string) *model.Channel {
return nil
}
if result := <-app.Srv.Store.Channel().GetByNameIncludeDeleted(team.Id, channelPart, true); result.Err == nil {
if result := <-app.Global().Srv.Store.Channel().GetByNameIncludeDeleted(team.Id, channelPart, true); result.Err == nil {
channel = result.Data.(*model.Channel)
} else {
fmt.Println(result.Err.Error())
@@ -50,7 +50,7 @@ func getChannelFromChannelArg(channelArg string) *model.Channel {
}
if channel == nil {
if result := <-app.Srv.Store.Channel().Get(channelPart, true); result.Err == nil {
if result := <-app.Global().Srv.Store.Channel().Get(channelPart, true); result.Err == nil {
channel = result.Data.(*model.Channel)
}
}

Просмотреть файл

@@ -5,10 +5,11 @@ package main
import (
"encoding/json"
"errors"
"os"
"github.com/mattermost/platform/model"
"github.com/mattermost/platform/utils"
"github.com/spf13/cobra"
"os"
)
var configCmd = &cobra.Command{

Просмотреть файл

@@ -7,6 +7,7 @@ import (
"os"
"fmt"
"github.com/mattermost/platform/app"
"github.com/spf13/cobra"
)
@@ -70,7 +71,7 @@ func slackImportCmdF(cmd *cobra.Command, args []string) error {
CommandPrettyPrintln("Running Slack Import. This may take a long time for large teams or teams with many messages.")
app.SlackImport(fileReader, fileInfo.Size(), team.Id)
app.Global().SlackImport(fileReader, fileInfo.Size(), team.Id)
CommandPrettyPrintln("Finished Slack Import.")
@@ -120,7 +121,7 @@ func bulkImportCmdF(cmd *cobra.Command, args []string) error {
CommandPrettyPrintln("")
if err, lineNumber := app.BulkImport(fileReader, !apply, workers); err != nil {
if err, lineNumber := app.Global().BulkImport(fileReader, !apply, workers); err != nil {
CommandPrettyPrintln(err.Error())
if lineNumber != 0 {
CommandPrettyPrintln(fmt.Sprintf("Error occurred on data file line %v", lineNumber))

Просмотреть файл

@@ -28,10 +28,10 @@ func initDBCommandContext(configFileLocation string) error {
utils.ConfigureCmdLineLog()
app.NewServer()
app.InitStores()
app.Global().NewServer()
app.Global().InitStores()
if model.BuildEnterpriseReady == "true" {
app.LoadLicense()
app.Global().LoadLicense()
}
return nil

Просмотреть файл

@@ -42,7 +42,7 @@ func uploadLicenseCmdF(cmd *cobra.Command, args []string) error {
return err
}
if _, err := app.SaveLicense(fileBytes); err != nil {
if _, err := app.Global().SaveLicense(fileBytes); err != nil {
return err
}

Просмотреть файл

@@ -79,7 +79,7 @@ func resetCmdF(cmd *cobra.Command, args []string) error {
}
}
app.Srv.Store.DropAllTables()
app.Global().Srv.Store.DropAllTables()
CommandPrettyPrintln("Database sucessfully reset")
return nil

Просмотреть файл

@@ -52,7 +52,7 @@ func makeSystemAdminCmdF(cmd *cobra.Command, args []string) error {
return errors.New("Unable to find user '" + args[i] + "'")
}
if _, err := app.UpdateUserRoles(user.Id, "system_admin system_user"); err != nil {
if _, err := app.Global().UpdateUserRoles(user.Id, "system_admin system_user"); err != nil {
return err
}
}
@@ -75,7 +75,7 @@ func makeMemberCmdF(cmd *cobra.Command, args []string) error {
return errors.New("Unable to find user '" + args[i] + "'")
}
if _, err := app.UpdateUserRoles(user.Id, "system_user"); err != nil {
if _, err := app.Global().UpdateUserRoles(user.Id, "system_user"); err != nil {
return err
}
}

Просмотреть файл

@@ -71,18 +71,18 @@ func runServer(configFileLocation string) {
l4g.Error("Problem with file storage settings: " + err.Error())
}
app.NewServer()
app.InitStores()
app.Global().NewServer()
app.Global().InitStores()
api.InitRouter()
wsapi.InitRouter()
api4.InitApi(false)
api.InitApi()
app.InitPlugins()
app.Global().InitPlugins()
wsapi.InitApi()
web.InitWeb()
if model.BuildEnterpriseReady == "true" {
app.LoadLicense()
app.Global().LoadLicense()
}
if !utils.IsLicensed() && len(utils.Cfg.SqlSettings.DataSourceReplicas) > 1 {
@@ -98,7 +98,7 @@ func runServer(configFileLocation string) {
resetStatuses()
app.StartServer()
app.Global().StartServer()
// If we allow testing then listen for manual testing URL hits
if utils.Cfg.ServiceSettings.EnableTesting {
@@ -118,7 +118,7 @@ func runServer(configFileLocation string) {
}
if einterfaces.GetClusterInterface() != nil {
app.RegisterAllClusterMessageHandlers()
app.Global().RegisterAllClusterMessageHandlers()
einterfaces.GetClusterInterface().StartInterNodeCommunication()
}
@@ -132,7 +132,7 @@ func runServer(configFileLocation string) {
}
}
jobs.Srv.Store = app.Srv.Store
jobs.Srv.Store = app.Global().Srv.Store
if *utils.Cfg.JobSettings.RunJobs {
jobs.Srv.StartWorkers()
}
@@ -157,7 +157,7 @@ func runServer(configFileLocation string) {
jobs.Srv.StopSchedulers()
jobs.Srv.StopWorkers()
app.StopServer()
app.Global().StopServer()
}
func runSecurityJob() {
@@ -181,20 +181,20 @@ func runCommandWebhookCleanupJob() {
}
func resetStatuses() {
if result := <-app.Srv.Store.Status().ResetAll(); result.Err != nil {
if result := <-app.Global().Srv.Store.Status().ResetAll(); result.Err != nil {
l4g.Error(utils.T("mattermost.reset_status.error"), result.Err.Error())
}
}
func setDiagnosticId() {
if result := <-app.Srv.Store.System().Get(); result.Err == nil {
if result := <-app.Global().Srv.Store.System().Get(); result.Err == nil {
props := result.Data.(model.StringMap)
id := props[model.SYSTEM_DIAGNOSTIC_ID]
if len(id) == 0 {
id = model.NewId()
systemId := &model.System{Name: model.SYSTEM_DIAGNOSTIC_ID, Value: id}
<-app.Srv.Store.System().Save(systemId)
<-app.Global().Srv.Store.System().Save(systemId)
}
utils.CfgDiagnosticId = id
@@ -202,19 +202,19 @@ func setDiagnosticId() {
}
func doSecurity() {
app.DoSecurityUpdateCheck()
app.Global().DoSecurityUpdateCheck()
}
func doDiagnostics() {
if *utils.Cfg.LogSettings.EnableDiagnostics {
app.SendDailyDiagnostics()
app.Global().SendDailyDiagnostics()
}
}
func doTokenCleanup() {
app.Srv.Store.Token().Cleanup()
app.Global().Srv.Store.Token().Cleanup()
}
func doCommandWebhookCleanup() {
app.Srv.Store.CommandWebhook().Cleanup()
app.Global().Srv.Store.CommandWebhook().Cleanup()
}

Просмотреть файл

@@ -94,7 +94,7 @@ func createTeamCmdF(cmd *cobra.Command, args []string) error {
Type: teamType,
}
if _, err := app.CreateTeam(team); err != nil {
if _, err := app.Global().CreateTeam(team); err != nil {
return errors.New("Team creation failed: " + err.Error())
}
@@ -128,7 +128,7 @@ func removeUserFromTeam(team *model.Team, user *model.User, userArg string) {
CommandPrintErrorln("Can't find user '" + userArg + "'")
return
}
if err := app.LeaveTeam(team, user); err != nil {
if err := app.Global().LeaveTeam(team, user); err != nil {
CommandPrintErrorln("Unable to remove '" + userArg + "' from " + team.Name + ". Error: " + err.Error())
}
}
@@ -160,7 +160,7 @@ func addUserToTeam(team *model.Team, user *model.User, userArg string) {
CommandPrintErrorln("Can't find user '" + userArg + "'")
return
}
if err := app.JoinUserToTeam(team, user, ""); err != nil {
if err := app.Global().JoinUserToTeam(team, user, ""); err != nil {
CommandPrintErrorln("Unable to add '" + userArg + "' to " + team.Name)
}
}
@@ -207,5 +207,5 @@ func deleteTeamsCmdF(cmd *cobra.Command, args []string) error {
}
func deleteTeam(team *model.Team) *model.AppError {
return app.PermanentDeleteTeam(team)
return app.Global().PermanentDeleteTeam(team)
}

Просмотреть файл

@@ -18,12 +18,12 @@ func getTeamsFromTeamArgs(teamArgs []string) []*model.Team {
func getTeamFromTeamArg(teamArg string) *model.Team {
var team *model.Team
if result := <-app.Srv.Store.Team().GetByName(teamArg); result.Err == nil {
if result := <-app.Global().Srv.Store.Team().GetByName(teamArg); result.Err == nil {
team = result.Data.(*model.Team)
}
if team == nil {
if result := <-app.Srv.Store.Team().Get(teamArg); result.Err == nil {
if result := <-app.Global().Srv.Store.Team().Get(teamArg); result.Err == nil {
team = result.Data.(*model.Team)
}
}

Просмотреть файл

@@ -9,14 +9,15 @@ import (
"os"
"os/exec"
"os/signal"
"syscall"
"github.com/mattermost/platform/api"
"github.com/mattermost/platform/api4"
"github.com/mattermost/platform/app"
"github.com/mattermost/platform/utils"
"github.com/mattermost/platform/wsapi"
"github.com/spf13/cobra"
"os/signal"
"syscall"
)
var testCmd = &cobra.Command{
@@ -56,9 +57,9 @@ func webClientTestsCmdF(cmd *cobra.Command, args []string) error {
api.InitApi()
wsapi.InitApi()
setupClientTests()
app.StartServer()
app.Global().StartServer()
runWebClientTests()
app.StopServer()
app.Global().StopServer()
return nil
}
@@ -75,13 +76,13 @@ func serverForWebClientTestsCmdF(cmd *cobra.Command, args []string) error {
api.InitApi()
wsapi.InitApi()
setupClientTests()
app.StartServer()
app.Global().StartServer()
c := make(chan os.Signal)
signal.Notify(c, os.Interrupt, syscall.SIGINT, syscall.SIGTERM)
<-c
app.StopServer()
app.Global().StopServer()
return nil
}

Просмотреть файл

@@ -188,7 +188,7 @@ func changeUserActiveStatus(user *model.User, userArg string, activate bool) err
if user.IsLDAPUser() {
return errors.New("You can not modify the activation status of AD/LDAP accounts. Please modify through the AD/LDAP server.")
}
if _, err := app.UpdateActive(user, activate); err != nil {
if _, err := app.Global().UpdateActive(user, activate); err != nil {
return fmt.Errorf("Unable to change activation status of user: %v", userArg)
}
@@ -241,13 +241,13 @@ func userCreateCmdF(cmd *cobra.Command, args []string) error {
Locale: locale,
}
ruser, err := app.CreateUser(user)
ruser, err := app.Global().CreateUser(user)
if err != nil {
return errors.New("Unable to create user. Error: " + err.Error())
}
if systemAdmin {
app.UpdateUserRoles(ruser.Id, "system_user system_admin")
app.Global().UpdateUserRoles(ruser.Id, "system_user system_admin")
}
CommandPrettyPrintln("Created User")
@@ -310,7 +310,7 @@ func resetUserPasswordCmdF(cmd *cobra.Command, args []string) error {
}
password := args[1]
if result := <-app.Srv.Store.User().UpdatePassword(user.Id, model.HashPassword(password)); result.Err != nil {
if result := <-app.Global().Srv.Store.User().UpdatePassword(user.Id, model.HashPassword(password)); result.Err != nil {
return result.Err
}
@@ -373,7 +373,7 @@ func deleteUserCmdF(cmd *cobra.Command, args []string) error {
return errors.New("Unable to find user '" + args[i] + "'")
}
if err := app.PermanentDeleteUser(user); err != nil {
if err := app.Global().PermanentDeleteUser(user); err != nil {
return err
}
}
@@ -406,7 +406,7 @@ func deleteAllUsersCommandF(cmd *cobra.Command, args []string) error {
}
}
if err := app.PermanentDeleteAllUsers(); err != nil {
if err := app.Global().PermanentDeleteAllUsers(); err != nil {
return err
}
@@ -473,7 +473,7 @@ func verifyUserCmdF(cmd *cobra.Command, args []string) error {
CommandPrintErrorln("Unable to find user '" + args[i] + "'")
continue
}
if cresult := <-app.Srv.Store.User().VerifyEmail(user.Id); cresult.Err != nil {
if cresult := <-app.Global().Srv.Store.User().VerifyEmail(user.Id); cresult.Err != nil {
CommandPrintErrorln("Unable to verify '" + args[i] + "' email. Error: " + cresult.Err.Error())
}
}

Просмотреть файл

@@ -18,18 +18,18 @@ func getUsersFromUserArgs(userArgs []string) []*model.User {
func getUserFromUserArg(userArg string) *model.User {
var user *model.User
if result := <-app.Srv.Store.User().GetByEmail(userArg); result.Err == nil {
if result := <-app.Global().Srv.Store.User().GetByEmail(userArg); result.Err == nil {
user = result.Data.(*model.User)
}
if user == nil {
if result := <-app.Srv.Store.User().GetByUsername(userArg); result.Err == nil {
if result := <-app.Global().Srv.Store.User().GetByUsername(userArg); result.Err == nil {
user = result.Data.(*model.User)
}
}
if user == nil {
if result := <-app.Srv.Store.User().Get(userArg); result.Err == nil {
if result := <-app.Global().Srv.Store.User().Get(userArg); result.Err == nil {
user = result.Data.(*model.User)
}
}

Просмотреть файл

@@ -31,5 +31,5 @@ func printVersion() {
CommandPrintln("Build Date: " + model.BuildDate)
CommandPrintln("Build Hash: " + model.BuildHash)
CommandPrintln("Build Enterprise Ready: " + model.BuildEnterpriseReady)
CommandPrintln("DB Version: " + app.Srv.Store.(*store.LayeredStore).DatabaseLayer.GetCurrentSchemaVersion())
CommandPrintln("DB Version: " + app.Global().Srv.Store.(*store.LayeredStore).DatabaseLayer.GetCurrentSchemaVersion())
}