summaryrefslogtreecommitdiffstats
path: root/api
diff options
context:
space:
mode:
Diffstat (limited to 'api')
-rw-r--r--api/command.go40
-rw-r--r--api/command_logout.go3
-rw-r--r--api/command_logout_test.go3
-rw-r--r--api/file.go2
4 files changed, 31 insertions, 17 deletions
diff --git a/api/command.go b/api/command.go
index bebe6629c..99fd05d7a 100644
--- a/api/command.go
+++ b/api/command.go
@@ -69,16 +69,18 @@ func listCommands(c *Context, w http.ResponseWriter, r *http.Request) {
}
}
- if result := <-Srv.Store.Command().GetByTeam(c.Session.TeamId); result.Err != nil {
- c.Err = result.Err
- return
- } else {
- teamCmds := result.Data.([]*model.Command)
- for _, cmd := range teamCmds {
- if cmd.AutoComplete && !seen[cmd.Id] {
- cmd.Sanitize()
- seen[cmd.Trigger] = true
- commands = append(commands, cmd)
+ if *utils.Cfg.ServiceSettings.EnableCommands {
+ if result := <-Srv.Store.Command().GetByTeam(c.Session.TeamId); result.Err != nil {
+ c.Err = result.Err
+ return
+ } else {
+ teamCmds := result.Data.([]*model.Command)
+ for _, cmd := range teamCmds {
+ if cmd.AutoComplete && !seen[cmd.Id] {
+ cmd.Sanitize()
+ seen[cmd.Trigger] = true
+ commands = append(commands, cmd)
+ }
}
}
}
@@ -111,9 +113,16 @@ func executeCommand(c *Context, w http.ResponseWriter, r *http.Request) {
if provider != nil {
response := provider.DoCommand(c, channelId, message)
- handleResponse(c, w, response, channelId, provider.GetCommand(c))
+ handleResponse(c, w, response, channelId, provider.GetCommand(c), true)
return
} else {
+
+ if !*utils.Cfg.ServiceSettings.EnableCommands {
+ c.Err = model.NewLocAppError("executeCommand", "api.command.disabled.app_error", nil, "")
+ c.Err.StatusCode = http.StatusNotImplemented
+ return
+ }
+
chanChan := Srv.Store.Channel().Get(channelId)
teamChan := Srv.Store.Team().Get(c.Session.TeamId)
userChan := Srv.Store.User().Get(c.Session.UserId)
@@ -193,7 +202,7 @@ func executeCommand(c *Context, w http.ResponseWriter, r *http.Request) {
if response == nil {
c.Err = model.NewLocAppError("command", "api.command.execute_command.failed_empty.app_error", map[string]interface{}{"Trigger": trigger}, "")
} else {
- handleResponse(c, w, response, channelId, cmd)
+ handleResponse(c, w, response, channelId, cmd, false)
}
} else {
body, _ := ioutil.ReadAll(resp.Body)
@@ -211,11 +220,14 @@ func executeCommand(c *Context, w http.ResponseWriter, r *http.Request) {
c.Err = model.NewLocAppError("command", "api.command.execute_command.not_found.app_error", map[string]interface{}{"Trigger": trigger}, "")
}
-func handleResponse(c *Context, w http.ResponseWriter, response *model.CommandResponse, channelId string, cmd *model.Command) {
+func handleResponse(c *Context, w http.ResponseWriter, response *model.CommandResponse, channelId string, cmd *model.Command, builtIn bool) {
post := &model.Post{}
post.ChannelId = channelId
- post.AddProp("from_webhook", "true")
+
+ if !builtIn {
+ post.AddProp("from_webhook", "true")
+ }
if utils.Cfg.ServiceSettings.EnablePostUsernameOverride {
if len(cmd.Username) != 0 {
diff --git a/api/command_logout.go b/api/command_logout.go
index fb69b4f85..912093162 100644
--- a/api/command_logout.go
+++ b/api/command_logout.go
@@ -33,5 +33,6 @@ func (me *LogoutProvider) GetCommand(c *Context) *model.Command {
}
func (me *LogoutProvider) DoCommand(c *Context, channelId string, message string) *model.CommandResponse {
- return &model.CommandResponse{GotoLocation: "/logout", ResponseType: model.COMMAND_RESPONSE_TYPE_EPHEMERAL, Text: c.T("api.command_logout.success_message")}
+
+ return &model.CommandResponse{GotoLocation: c.GetTeamURL() + "/logout", ResponseType: model.COMMAND_RESPONSE_TYPE_EPHEMERAL, Text: c.T("api.command_logout.success_message")}
}
diff --git a/api/command_logout_test.go b/api/command_logout_test.go
index 86979316b..eee7520a8 100644
--- a/api/command_logout_test.go
+++ b/api/command_logout_test.go
@@ -4,6 +4,7 @@
package api
import (
+ "strings"
"testing"
"github.com/mattermost/platform/model"
@@ -26,7 +27,7 @@ func TestLogoutTestCommand(t *testing.T) {
channel1 = Client.Must(Client.CreateChannel(channel1)).Data.(*model.Channel)
rs1 := Client.Must(Client.Command(channel1.Id, "/logout", false)).Data.(*model.CommandResponse)
- if rs1.GotoLocation != "/logout" {
+ if !strings.HasSuffix(rs1.GotoLocation, "logout") {
t.Fatal("failed to logout")
}
}
diff --git a/api/file.go b/api/file.go
index 5c983ea55..0011afd5b 100644
--- a/api/file.go
+++ b/api/file.go
@@ -52,7 +52,7 @@ const (
RotatedCCWMirrored = 7
RotatedCW = 8
- MaxImageSize = 4096 * 2160 // 4k resolution
+ MaxImageSize = 6048 * 4032 // 24 megapixels, roughly 36MB as a raw image
)
var fileInfoCache *utils.Cache = utils.NewLru(1000)