Unverified Commit 10c5a927 authored by Chris's avatar Chris Committed by GitHub

more global config ref cleanup (#7802)

parent b0c18ece
......@@ -189,7 +189,7 @@ func downloadComplianceReport(c *Context, w http.ResponseWriter, r *http.Request
return
}
reportBytes, err := app.GetComplianceFile(job)
reportBytes, err := c.App.GetComplianceFile(job)
if err != nil {
c.Err = err
return
......
......@@ -332,5 +332,5 @@ func getPublicLink(c *Context, w http.ResponseWriter, r *http.Request) {
return
}
w.Write([]byte(model.StringToJson(app.GeneratePublicLinkV3(c.GetSiteURLHeader(), info))))
w.Write([]byte(model.StringToJson(c.App.GeneratePublicLinkV3(c.GetSiteURLHeader(), info))))
}
......@@ -8,7 +8,6 @@ import (
l4g "github.com/alecthomas/log4go"
"github.com/mattermost/mattermost-server/app"
"github.com/mattermost/mattermost-server/model"
"github.com/mattermost/mattermost-server/utils"
)
......@@ -21,7 +20,7 @@ func (api *API) InitStatus() {
}
func getStatusesHttp(c *Context, w http.ResponseWriter, r *http.Request) {
statusMap := model.StatusMapToInterfaceMap(app.GetAllStatuses())
statusMap := model.StatusMapToInterfaceMap(c.App.GetAllStatuses())
w.Write([]byte(model.StringInterfaceToJson(statusMap)))
}
......
......@@ -689,19 +689,20 @@ func s3New(endpoint, accessKey, secretKey string, secure bool, signV2 bool, regi
return s3.NewWithCredentials(endpoint, creds, secure, region)
}
func cleanupTestFile(info *model.FileInfo) error {
if *utils.Cfg.FileSettings.DriverName == model.IMAGE_DRIVER_S3 {
endpoint := utils.Cfg.FileSettings.AmazonS3Endpoint
accessKey := utils.Cfg.FileSettings.AmazonS3AccessKeyId
secretKey := utils.Cfg.FileSettings.AmazonS3SecretAccessKey
secure := *utils.Cfg.FileSettings.AmazonS3SSL
signV2 := *utils.Cfg.FileSettings.AmazonS3SignV2
region := utils.Cfg.FileSettings.AmazonS3Region
func (me *TestHelper) cleanupTestFile(info *model.FileInfo) error {
cfg := me.App.Config()
if *cfg.FileSettings.DriverName == model.IMAGE_DRIVER_S3 {
endpoint := cfg.FileSettings.AmazonS3Endpoint
accessKey := cfg.FileSettings.AmazonS3AccessKeyId
secretKey := cfg.FileSettings.AmazonS3SecretAccessKey
secure := *cfg.FileSettings.AmazonS3SSL
signV2 := *cfg.FileSettings.AmazonS3SignV2
region := cfg.FileSettings.AmazonS3Region
s3Clnt, err := s3New(endpoint, accessKey, secretKey, secure, signV2, region)
if err != nil {
return err
}
bucket := utils.Cfg.FileSettings.AmazonS3Bucket
bucket := cfg.FileSettings.AmazonS3Bucket
if err := s3Clnt.RemoveObject(bucket, info.Path); err != nil {
return err
}
......@@ -717,19 +718,19 @@ func cleanupTestFile(info *model.FileInfo) error {
return err
}
}
} else if *utils.Cfg.FileSettings.DriverName == model.IMAGE_DRIVER_LOCAL {
if err := os.Remove(utils.Cfg.FileSettings.Directory + info.Path); err != nil {
} else if *cfg.FileSettings.DriverName == model.IMAGE_DRIVER_LOCAL {
if err := os.Remove(cfg.FileSettings.Directory + info.Path); err != nil {
return err
}
if info.ThumbnailPath != "" {
if err := os.Remove(utils.Cfg.FileSettings.Directory + info.ThumbnailPath); err != nil {
if err := os.Remove(cfg.FileSettings.Directory + info.ThumbnailPath); err != nil {
return err
}
}
if info.PreviewPath != "" {
if err := os.Remove(utils.Cfg.FileSettings.Directory + info.PreviewPath); err != nil {
if err := os.Remove(cfg.FileSettings.Directory + info.PreviewPath); err != nil {
return err
}
}
......
......@@ -8,7 +8,6 @@ import (
"strconv"
l4g "github.com/alecthomas/log4go"
"github.com/mattermost/mattermost-server/app"
"github.com/mattermost/mattermost-server/model"
"github.com/mattermost/mattermost-server/utils"
"github.com/mssola/user_agent"
......@@ -100,7 +99,7 @@ func downloadComplianceReport(c *Context, w http.ResponseWriter, r *http.Request
return
}
reportBytes, err := app.GetComplianceFile(job)
reportBytes, err := c.App.GetComplianceFile(job)
if err != nil {
c.Err = err
return
......
......@@ -201,7 +201,7 @@ func getFileLink(c *Context, w http.ResponseWriter, r *http.Request) {
}
resp := make(map[string]string)
resp["link"] = app.GeneratePublicLink(c.GetSiteURLHeader(), info)
resp["link"] = c.App.GeneratePublicLink(c.GetSiteURLHeader(), info)
w.Write([]byte(model.MapToJson(resp)))
}
......
......@@ -10,7 +10,6 @@ import (
"testing"
"time"
"github.com/mattermost/mattermost-server/app"
"github.com/mattermost/mattermost-server/model"
"github.com/mattermost/mattermost-server/store"
)
......@@ -94,7 +93,7 @@ func TestUploadFile(t *testing.T) {
// Wait a bit for files to ready
time.Sleep(2 * time.Second)
if err := cleanupTestFile(info); err != nil {
if err := th.cleanupTestFile(info); err != nil {
t.Fatal(err)
}
......@@ -363,7 +362,7 @@ func TestGetFileLink(t *testing.T) {
if result := <-th.App.Srv.Store.FileInfo().Get(fileId); result.Err != nil {
t.Fatal(result.Err)
} else {
cleanupTestFile(result.Data.(*model.FileInfo))
th.cleanupTestFile(result.Data.(*model.FileInfo))
}
}
......@@ -520,7 +519,7 @@ func TestGetPublicFile(t *testing.T) {
result := <-th.App.Srv.Store.FileInfo().Get(fileId)
info := result.Data.(*model.FileInfo)
link := app.GeneratePublicLink(Client.Url, info)
link := th.App.GeneratePublicLink(Client.Url, info)
// Wait a bit for files to ready
time.Sleep(2 * time.Second)
......@@ -551,9 +550,9 @@ func TestGetPublicFile(t *testing.T) {
t.Fatal("should've failed to get image with public link after salt changed")
}
if err := cleanupTestFile(store.Must(th.App.Srv.Store.FileInfo().Get(fileId)).(*model.FileInfo)); err != nil {
if err := th.cleanupTestFile(store.Must(th.App.Srv.Store.FileInfo().Get(fileId)).(*model.FileInfo)); err != nil {
t.Fatal(err)
}
cleanupTestFile(info)
th.cleanupTestFile(info)
}
......@@ -841,7 +841,7 @@ func TestGetProfileImage(t *testing.T) {
CheckNoError(t, resp)
info := &model.FileInfo{Path: "/users/" + user.Id + "/profile.png"}
if err := cleanupTestFile(info); err != nil {
if err := th.cleanupTestFile(info); err != nil {
t.Fatal(err)
}
}
......@@ -2089,7 +2089,7 @@ func TestSetProfileImage(t *testing.T) {
assert.True(t, buser.LastPictureUpdate < ruser.LastPictureUpdate, "Picture should have updated for user")
info := &model.FileInfo{Path: "users/" + user.Id + "/profile.png"}
if err := cleanupTestFile(info); err != nil {
if err := th.cleanupTestFile(info); err != nil {
t.Fatal(err)
}
}
......@@ -2381,11 +2381,9 @@ func TestDisableUserAccessToken(t *testing.T) {
testDescription := "test token"
enableUserAccessTokens := *utils.Cfg.ServiceSettings.EnableUserAccessTokens
defer func() {
*utils.Cfg.ServiceSettings.EnableUserAccessTokens = enableUserAccessTokens
}()
*utils.Cfg.ServiceSettings.EnableUserAccessTokens = true
enableUserAccessTokens := *th.App.Config().ServiceSettings.EnableUserAccessTokens
defer th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableUserAccessTokens = enableUserAccessTokens })
*th.App.Config().ServiceSettings.EnableUserAccessTokens = true
th.App.UpdateUserRoles(th.BasicUser.Id, model.ROLE_SYSTEM_USER.Id+" "+model.ROLE_SYSTEM_USER_ACCESS_TOKEN.Id, false)
token, resp := Client.CreateUserAccessToken(th.BasicUser.Id, testDescription)
......@@ -2428,11 +2426,9 @@ func TestEnableUserAccessToken(t *testing.T) {
testDescription := "test token"
enableUserAccessTokens := *utils.Cfg.ServiceSettings.EnableUserAccessTokens
defer func() {
*utils.Cfg.ServiceSettings.EnableUserAccessTokens = enableUserAccessTokens
}()
*utils.Cfg.ServiceSettings.EnableUserAccessTokens = true
enableUserAccessTokens := *th.App.Config().ServiceSettings.EnableUserAccessTokens
defer th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableUserAccessTokens = enableUserAccessTokens })
*th.App.Config().ServiceSettings.EnableUserAccessTokens = true
th.App.UpdateUserRoles(th.BasicUser.Id, model.ROLE_SYSTEM_USER.Id+" "+model.ROLE_SYSTEM_USER_ACCESS_TOKEN.Id, false)
token, resp := Client.CreateUserAccessToken(th.BasicUser.Id, testDescription)
......
......@@ -18,7 +18,7 @@ import (
type CommandProvider interface {
GetTrigger() string
GetCommand(T goi18n.TranslateFunc) *model.Command
GetCommand(a *App, T goi18n.TranslateFunc) *model.Command
DoCommand(a *App, args *model.CommandArgs, message string) *model.CommandResponse
}
......@@ -65,11 +65,13 @@ func (a *App) ListAutocompleteCommands(teamId string, T goi18n.TranslateFunc) ([
commands := make([]*model.Command, 0, 32)
seen := make(map[string]bool)
for _, value := range commandProviders {
cpy := *value.GetCommand(T)
if cpy.AutoComplete && !seen[cpy.Id] {
cpy.Sanitize()
seen[cpy.Trigger] = true
commands = append(commands, &cpy)
if cmd := value.GetCommand(a, T); cmd != nil {
cpy := *cmd
if cpy.AutoComplete && !seen[cpy.Id] {
cpy.Sanitize()
seen[cpy.Trigger] = true
commands = append(commands, &cpy)
}
}
}
......@@ -107,11 +109,13 @@ func (a *App) ListAllCommands(teamId string, T goi18n.TranslateFunc) ([]*model.C
commands := make([]*model.Command, 0, 32)
seen := make(map[string]bool)
for _, value := range commandProviders {
cpy := *value.GetCommand(T)
if cpy.AutoComplete && !seen[cpy.Id] {
cpy.Sanitize()
seen[cpy.Trigger] = true
commands = append(commands, &cpy)
if cmd := value.GetCommand(a, T); cmd != nil {
cpy := *cmd
if cpy.AutoComplete && !seen[cpy.Id] {
cpy.Sanitize()
seen[cpy.Trigger] = true
commands = append(commands, &cpy)
}
}
}
......@@ -141,94 +145,96 @@ func (a *App) ExecuteCommand(args *model.CommandArgs) (*model.CommandResponse, *
provider := GetCommandProvider(trigger)
if provider != nil {
response := provider.DoCommand(a, args, message)
return a.HandleCommandResponse(provider.GetCommand(args.T), args, response, true)
} else {
if !*a.Config().ServiceSettings.EnableCommands {
return nil, model.NewAppError("ExecuteCommand", "api.command.disabled.app_error", nil, "", http.StatusNotImplemented)
if cmd := provider.GetCommand(a, args.T); cmd != nil {
response := provider.DoCommand(a, args, message)
return a.HandleCommandResponse(cmd, args, response, true)
}
}
chanChan := a.Srv.Store.Channel().Get(args.ChannelId, true)
teamChan := a.Srv.Store.Team().Get(args.TeamId)
userChan := a.Srv.Store.User().Get(args.UserId)
if !*a.Config().ServiceSettings.EnableCommands {
return nil, model.NewAppError("ExecuteCommand", "api.command.disabled.app_error", nil, "", http.StatusNotImplemented)
}
if result := <-a.Srv.Store.Command().GetByTeam(args.TeamId); result.Err != nil {
return nil, result.Err
} else {
chanChan := a.Srv.Store.Channel().Get(args.ChannelId, true)
teamChan := a.Srv.Store.Team().Get(args.TeamId)
userChan := a.Srv.Store.User().Get(args.UserId)
var team *model.Team
if tr := <-teamChan; tr.Err != nil {
return nil, tr.Err
} else {
team = tr.Data.(*model.Team)
}
if result := <-a.Srv.Store.Command().GetByTeam(args.TeamId); result.Err != nil {
return nil, result.Err
} else {
var user *model.User
if ur := <-userChan; ur.Err != nil {
return nil, ur.Err
} else {
user = ur.Data.(*model.User)
}
var team *model.Team
if tr := <-teamChan; tr.Err != nil {
return nil, tr.Err
} else {
team = tr.Data.(*model.Team)
}
var channel *model.Channel
if cr := <-chanChan; cr.Err != nil {
return nil, cr.Err
} else {
channel = cr.Data.(*model.Channel)
}
var user *model.User
if ur := <-userChan; ur.Err != nil {
return nil, ur.Err
} else {
user = ur.Data.(*model.User)
}
teamCmds := result.Data.([]*model.Command)
for _, cmd := range teamCmds {
if trigger == cmd.Trigger {
l4g.Debug(fmt.Sprintf(utils.T("api.command.execute_command.debug"), trigger, args.UserId))
var channel *model.Channel
if cr := <-chanChan; cr.Err != nil {
return nil, cr.Err
} else {
channel = cr.Data.(*model.Channel)
}
p := url.Values{}
p.Set("token", cmd.Token)
teamCmds := result.Data.([]*model.Command)
for _, cmd := range teamCmds {
if trigger == cmd.Trigger {
l4g.Debug(fmt.Sprintf(utils.T("api.command.execute_command.debug"), trigger, args.UserId))
p.Set("team_id", cmd.TeamId)
p.Set("team_domain", team.Name)
p := url.Values{}
p.Set("token", cmd.Token)
p.Set("channel_id", args.ChannelId)
p.Set("channel_name", channel.Name)
p.Set("team_id", cmd.TeamId)
p.Set("team_domain", team.Name)
p.Set("user_id", args.UserId)
p.Set("user_name", user.Username)
p.Set("channel_id", args.ChannelId)
p.Set("channel_name", channel.Name)
p.Set("command", "/"+trigger)
p.Set("text", message)
p.Set("user_id", args.UserId)
p.Set("user_name", user.Username)
if hook, err := a.CreateCommandWebhook(cmd.Id, args); err != nil {
return nil, model.NewAppError("command", "api.command.execute_command.failed.app_error", map[string]interface{}{"Trigger": trigger}, err.Error(), http.StatusInternalServerError)
} else {
p.Set("response_url", args.SiteURL+"/hooks/commands/"+hook.Id)
}
p.Set("command", "/"+trigger)
p.Set("text", message)
method := "POST"
if cmd.Method == model.COMMAND_METHOD_GET {
method = "GET"
}
if hook, err := a.CreateCommandWebhook(cmd.Id, args); err != nil {
return nil, model.NewAppError("command", "api.command.execute_command.failed.app_error", map[string]interface{}{"Trigger": trigger}, err.Error(), http.StatusInternalServerError)
} else {
p.Set("response_url", args.SiteURL+"/hooks/commands/"+hook.Id)
}
req, _ := http.NewRequest(method, cmd.URL, strings.NewReader(p.Encode()))
req.Header.Set("Accept", "application/json")
if cmd.Method == model.COMMAND_METHOD_POST {
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
}
method := "POST"
if cmd.Method == model.COMMAND_METHOD_GET {
method = "GET"
}
if resp, err := utils.HttpClient(false).Do(req); err != nil {
return nil, model.NewAppError("command", "api.command.execute_command.failed.app_error", map[string]interface{}{"Trigger": trigger}, err.Error(), http.StatusInternalServerError)
} else {
if resp.StatusCode == http.StatusOK {
response := model.CommandResponseFromHTTPBody(resp.Header.Get("Content-Type"), resp.Body)
if response == nil {
return nil, model.NewAppError("command", "api.command.execute_command.failed_empty.app_error", map[string]interface{}{"Trigger": trigger}, "", http.StatusInternalServerError)
} else {
return a.HandleCommandResponse(cmd, args, response, false)
}
req, _ := http.NewRequest(method, cmd.URL, strings.NewReader(p.Encode()))
req.Header.Set("Accept", "application/json")
if cmd.Method == model.COMMAND_METHOD_POST {
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
}
if resp, err := utils.HttpClient(false).Do(req); err != nil {
return nil, model.NewAppError("command", "api.command.execute_command.failed.app_error", map[string]interface{}{"Trigger": trigger}, err.Error(), http.StatusInternalServerError)
} else {
if resp.StatusCode == http.StatusOK {
response := model.CommandResponseFromHTTPBody(resp.Header.Get("Content-Type"), resp.Body)
if response == nil {
return nil, model.NewAppError("command", "api.command.execute_command.failed_empty.app_error", map[string]interface{}{"Trigger": trigger}, "", http.StatusInternalServerError)
} else {
defer resp.Body.Close()
body, _ := ioutil.ReadAll(resp.Body)
return nil, model.NewAppError("command", "api.command.execute_command.failed_resp.app_error", map[string]interface{}{"Trigger": trigger, "Status": resp.Status}, string(body), http.StatusInternalServerError)
return a.HandleCommandResponse(cmd, args, response, false)
}
} else {
defer resp.Body.Close()
body, _ := ioutil.ReadAll(resp.Body)
return nil, model.NewAppError("command", "api.command.execute_command.failed_resp.app_error", map[string]interface{}{"Trigger": trigger, "Status": resp.Status}, string(body), http.StatusInternalServerError)
}
}
}
......@@ -293,8 +299,8 @@ func (a *App) CreateCommand(cmd *model.Command) (*model.Command, *model.AppError
}
}
for _, builtInProvider := range commandProviders {
builtInCommand := *builtInProvider.GetCommand(utils.T)
if cmd.Trigger == builtInCommand.Trigger {
builtInCommand := builtInProvider.GetCommand(a, utils.T)
if builtInCommand != nil && cmd.Trigger == builtInCommand.Trigger {
return nil, model.NewAppError("CreateCommand", "api.command.duplicate_trigger.app_error", nil, "", http.StatusBadRequest)
}
}
......
......@@ -23,7 +23,7 @@ func (me *AwayProvider) GetTrigger() string {
return CMD_AWAY
}
func (me *AwayProvider) GetCommand(T goi18n.TranslateFunc) *model.Command {
func (me *AwayProvider) GetCommand(a *App, T goi18n.TranslateFunc) *model.Command {
return &model.Command{
Trigger: CMD_AWAY,
AutoComplete: true,
......
......@@ -24,7 +24,7 @@ func (me *HeaderProvider) GetTrigger() string {
return CMD_HEADER
}
func (me *HeaderProvider) GetCommand(T goi18n.TranslateFunc) *model.Command {
func (me *HeaderProvider) GetCommand(a *App, T goi18n.TranslateFunc) *model.Command {
return &model.Command{
Trigger: CMD_HEADER,
AutoComplete: true,
......
......@@ -23,7 +23,7 @@ func (me *PurposeProvider) GetTrigger() string {
return CMD_PURPOSE
}
func (me *PurposeProvider) GetCommand(T goi18n.TranslateFunc) *model.Command {
func (me *PurposeProvider) GetCommand(a *App, T goi18n.TranslateFunc) *model.Command {
return &model.Command{
Trigger: CMD_PURPOSE,
AutoComplete: true,
......
......@@ -23,7 +23,7 @@ func (me *RenameProvider) GetTrigger() string {
return CMD_RENAME
}
func (me *RenameProvider) GetCommand(T goi18n.TranslateFunc) *model.Command {
func (me *RenameProvider) GetCommand(a *App, T goi18n.TranslateFunc) *model.Command {
return &model.Command{
Trigger: CMD_RENAME,
AutoComplete: true,
......
......@@ -25,7 +25,7 @@ func (me *CodeProvider) GetTrigger() string {
return CMD_CODE
}
func (me *CodeProvider) GetCommand(T goi18n.TranslateFunc) *model.Command {
func (me *CodeProvider) GetCommand(a *App, T goi18n.TranslateFunc) *model.Command {
return &model.Command{
Trigger: CMD_CODE,
AutoComplete: true,
......
......@@ -23,7 +23,7 @@ func (me *DndProvider) GetTrigger() string {
return CMD_DND
}
func (me *DndProvider) GetCommand(T goi18n.TranslateFunc) *model.Command {
func (me *DndProvider) GetCommand(a *App, T goi18n.TranslateFunc) *model.Command {
return &model.Command{
Trigger: CMD_DND,
AutoComplete: true,
......
......@@ -30,7 +30,7 @@ func (me *EchoProvider) GetTrigger() string {
return CMD_ECHO
}
func (me *EchoProvider) GetCommand(T goi18n.TranslateFunc) *model.Command {
func (me *EchoProvider) GetCommand(a *App, T goi18n.TranslateFunc) *model.Command {
return &model.Command{
Trigger: CMD_ECHO,
AutoComplete: true,
......
......@@ -34,7 +34,7 @@ func (me *CollapseProvider) GetTrigger() string {
return CMD_COLLAPSE
}
func (me *ExpandProvider) GetCommand(T goi18n.TranslateFunc) *model.Command {
func (me *ExpandProvider) GetCommand(a *App, T goi18n.TranslateFunc) *model.Command {
return &model.Command{
Trigger: CMD_EXPAND,
AutoComplete: true,
......@@ -43,7 +43,7 @@ func (me *ExpandProvider) GetCommand(T goi18n.TranslateFunc) *model.Command {
}
}
func (me *CollapseProvider) GetCommand(T goi18n.TranslateFunc) *model.Command {
func (me *CollapseProvider) GetCommand(a *App, T goi18n.TranslateFunc) *model.Command {
return &model.Command{
Trigger: CMD_COLLAPSE,
AutoComplete: true,
......
......@@ -23,7 +23,7 @@ func (h *HelpProvider) GetTrigger() string {
return CMD_HELP
}
func (h *HelpProvider) GetCommand(T goi18n.TranslateFunc) *model.Command {
func (h *HelpProvider) GetCommand(a *App, T goi18n.TranslateFunc) *model.Command {
return &model.Command{
Trigger: CMD_HELP,
AutoComplete: true,
......
......@@ -8,7 +8,6 @@ import (
l4g "github.com/alecthomas/log4go"
"github.com/mattermost/mattermost-server/model"
"github.com/mattermost/mattermost-server/utils"
goi18n "github.com/nicksnyder/go-i18n/i18n"
)
......@@ -27,9 +26,9 @@ func (me *InvitePeopleProvider) GetTrigger() string {
return CMD_INVITE_PEOPLE
}
func (me *InvitePeopleProvider) GetCommand(T goi18n.TranslateFunc) *model.Command {
func (me *InvitePeopleProvider) GetCommand(a *App, T goi18n.TranslateFunc) *model.Command {
autoComplete := true
if !utils.Cfg.EmailSettings.SendEmailNotifications || !utils.Cfg.TeamSettings.EnableUserCreation {
if !a.Config().EmailSettings.SendEmailNotifications || !a.Config().TeamSettings.EnableUserCreation {
autoComplete = false
}
return &model.Command{
......
......@@ -23,7 +23,7 @@ func (me *JoinProvider) GetTrigger() string {
return CMD_JOIN
}
func (me *JoinProvider) GetCommand(T goi18n.TranslateFunc) *model.Command {
func (me *JoinProvider) GetCommand(a *App, T goi18n.TranslateFunc) *model.Command {
return &model.Command{
Trigger: CMD_JOIN,
AutoComplete: true,
......
......@@ -23,7 +23,7 @@ func (me *LeaveProvider) GetTrigger() string {
return CMD_LEAVE
}
func (me *LeaveProvider) GetCommand(T goi18n.TranslateFunc) *model.Command {
func (me *LeaveProvider) GetCommand(a *App, T goi18n.TranslateFunc) *model.Command {
return &model.Command{
Trigger: CMD_LEAVE,
AutoComplete: true,
......
......@@ -66,16 +66,17 @@ type LoadTestProvider struct {
}
func init() {
if !utils.Cfg.ServiceSettings.EnableTesting {
RegisterCommandProvider(&LoadTestProvider{})
}
RegisterCommandProvider(&LoadTestProvider{})
}
func (me *LoadTestProvider) GetTrigger() string {
return CMD_TEST
}
func (me *LoadTestProvider) GetCommand(T goi18n.TranslateFunc) *model.Command {
func (me *LoadTestProvider) GetCommand(a *App, T goi18n.TranslateFunc) *model.Command {
if !a.Config().ServiceSettings.EnableTesting {
return nil
}
return &model.Command{
Trigger: CMD_TEST,
AutoComplete: false,
......
......@@ -23,7 +23,7 @@ func (me *LogoutProvider) GetTrigger() string {
return CMD_LOGOUT
}
func (me *LogoutProvider) GetCommand(T goi18n.TranslateFunc) *model.Command {
func (me *LogoutProvider) GetCommand(a *App, T goi18n.TranslateFunc) *model.Command {
return &model.Command{
Trigger: CMD_LOGOUT,
AutoComplete: true,
......
......@@ -23,7 +23,7 @@ func (me *MeProvider) GetTrigger() string {
return CMD_ME
}
func (me *MeProvider) GetCommand(T goi18n.TranslateFunc) *model.Command {
func (me *MeProvider) GetCommand(a *App, T goi18n.TranslateFunc) *model.Command {
return &model.Command{
Trigger: CMD_ME,
AutoComplete: true,
......
......@@ -26,7 +26,7 @@ func (me *msgProvider) GetTrigger() string {
return CMD_MSG
}
func (me *msgProvider) GetCommand(T goi18n.TranslateFunc) *model.Command {
func (me *msgProvider) GetCommand(a *App, T goi18n.TranslateFunc) *model.Command {
return &model.Command{
Trigger: CMD_MSG,
AutoComplete: true,
......
......@@ -23,7 +23,7 @@ func (me *OfflineProvider) GetTrigger() string {
return CMD_OFFLINE
}
func (me *OfflineProvider) GetCommand(T goi18n.TranslateFunc) *model.Command {
func (me *OfflineProvider) GetCommand(a *App, T goi18n.TranslateFunc) *model.Command {
return &model.Command{
Trigger: CMD_OFFLINE,
AutoComplete: true,
......
......@@ -23,7 +23,7 @@ func (me *OnlineProvider) GetTrigger() string {
return CMD_ONLINE
}
func (me *OnlineProvider) GetCommand(T goi18n.TranslateFunc) *model.Command {
func (me *OnlineProvider) GetCommand(a *App, T goi18n.TranslateFunc) *model.Command {
return &model.Command{
Trigger: CMD_ONLINE,