summaryrefslogtreecommitdiffstats
path: root/api/command.go
diff options
context:
space:
mode:
authorJoramWilander <jwawilander@gmail.com>2015-06-17 12:07:35 -0400
committerJoramWilander <jwawilander@gmail.com>2015-06-17 12:07:35 -0400
commit799215ee2278b162d4e113c498424fdda817e83b (patch)
treecff7f204fe24e9bcac2058823160031a575cdd80 /api/command.go
parent5a8f8397167cec8cba29b70bb7dbdda9ba0265f7 (diff)
downloadchat-799215ee2278b162d4e113c498424fdda817e83b.tar.gz
chat-799215ee2278b162d4e113c498424fdda817e83b.tar.bz2
chat-799215ee2278b162d4e113c498424fdda817e83b.zip
move valet feature switch to DB from config
Diffstat (limited to 'api/command.go')
-rw-r--r--api/command.go20
1 files changed, 17 insertions, 3 deletions
diff --git a/api/command.go b/api/command.go
index 449483bbf..94d2d8f60 100644
--- a/api/command.go
+++ b/api/command.go
@@ -25,9 +25,7 @@ func InitCommand(r *mux.Router) {
l4g.Debug("Initializing command api routes")
r.Handle("/command", ApiUserRequired(command)).Methods("POST")
- if utils.Cfg.TeamSettings.AllowValet {
- commands = append(commands, echoCommand)
- }
+ commands = append(commands, echoCommand)
hub.Start()
}
@@ -59,6 +57,8 @@ func checkCommand(c *Context, command *model.Command) bool {
return false
}
+ tchan := Srv.Store.Team().Get(c.Session.TeamId)
+
if len(command.ChannelId) > 0 {
cchan := Srv.Store.Channel().CheckPermissionsTo(c.Session.TeamId, command.ChannelId, c.Session.UserId)
@@ -67,7 +67,21 @@ func checkCommand(c *Context, command *model.Command) bool {
}
}
+ allowValet := false
+ if tResult := <-tchan; tResult.Err != nil {
+ c.Err = model.NewAppError("checkCommand", "Could not find the team for this session, team_id="+c.Session.TeamId, "")
+ return false
+ } else {
+ allowValet = tResult.Data.(*model.Team).AllowValet
+ }
+
+ var ec commandHandler
+ ec = echoCommand
for _, v := range commands {
+ if !allowValet && &v == &ec {
+ continue
+ }
+
if v(c, command) {
return true
} else if c.Err != nil {