diff options
author | JoramWilander <jwawilander@gmail.com> | 2015-06-17 12:07:35 -0400 |
---|---|---|
committer | JoramWilander <jwawilander@gmail.com> | 2015-06-17 12:07:35 -0400 |
commit | 799215ee2278b162d4e113c498424fdda817e83b (patch) | |
tree | cff7f204fe24e9bcac2058823160031a575cdd80 /api/post.go | |
parent | 5a8f8397167cec8cba29b70bb7dbdda9ba0265f7 (diff) | |
download | chat-799215ee2278b162d4e113c498424fdda817e83b.tar.gz chat-799215ee2278b162d4e113c498424fdda817e83b.tar.bz2 chat-799215ee2278b162d4e113c498424fdda817e83b.zip |
move valet feature switch to DB from config
Diffstat (limited to 'api/post.go')
-rw-r--r-- | api/post.go | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/api/post.go b/api/post.go index 36607c231..6f500286f 100644 --- a/api/post.go +++ b/api/post.go @@ -58,11 +58,7 @@ func createPost(c *Context, w http.ResponseWriter, r *http.Request) { } func createValetPost(c *Context, w http.ResponseWriter, r *http.Request) { - if !utils.Cfg.TeamSettings.AllowValet { - c.Err = model.NewAppError("createValetPost", "The valet feature is currently turned off. Please contact your system administrator for details.", "") - c.Err.StatusCode = http.StatusNotImplemented - return - } + tchan := Srv.Store.Team().Get(c.Session.TeamId) post := model.PostFromJson(r.Body) if post == nil { @@ -70,13 +66,25 @@ func createValetPost(c *Context, w http.ResponseWriter, r *http.Request) { return } - // Any one with access to the team can post as valet to any open channel cchan := Srv.Store.Channel().CheckOpenChannelPermissions(c.Session.TeamId, post.ChannelId) + // Any one with access to the team can post as valet to any open channel if !c.HasPermissionsToChannel(cchan, "createValetPost") { return } + // Make sure this team has the valet feature enabled + if tResult := <-tchan; tResult.Err != nil { + c.Err = model.NewAppError("createValetPost", "Could not find the team for this session, team_id="+c.Session.TeamId, "") + return + } else { + if !tResult.Data.(*model.Team).AllowValet { + c.Err = model.NewAppError("createValetPost", "The valet feature is currently turned off. Please contact your team administrator for details.", "") + c.Err.StatusCode = http.StatusNotImplemented + return + } + } + if rp, err := CreateValetPost(c, post); err != nil { c.Err = err |