diff options
author | Joram Wilander <jwawilander@gmail.com> | 2017-02-17 10:31:21 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-17 10:31:21 -0500 |
commit | 91fe8bb2c0d520f13269b2eadc2717a5ec4eea1c (patch) | |
tree | 088fc7015274975c4f1494a5b5afe72af84b6966 /api4/context.go | |
parent | 4e7dbc3bb0e93bafa684594b19c5648dc030ee17 (diff) | |
download | chat-91fe8bb2c0d520f13269b2eadc2717a5ec4eea1c.tar.gz chat-91fe8bb2c0d520f13269b2eadc2717a5ec4eea1c.tar.bz2 chat-91fe8bb2c0d520f13269b2eadc2717a5ec4eea1c.zip |
Implement upload and get file endpoints for APIv4 (#5396)
* Implement POST /files endpoint for APIv4
* Implement GET /files/{file_id} endpoint for APIv4
Diffstat (limited to 'api4/context.go')
-rw-r--r-- | api4/context.go | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/api4/context.go b/api4/context.go index 6a844795f..d272e8049 100644 --- a/api4/context.go +++ b/api4/context.go @@ -382,12 +382,24 @@ func (c *Context) RequirePostId() *Context { return c } +func (c *Context) RequireFileId() *Context { + if c.Err != nil { + return c + } + + if len(c.Params.FileId) != 26 { + c.SetInvalidUrlParam("file_id") + } + + return c +} + func (c *Context) RequireTeamName() *Context { if c.Err != nil { return c } - if !model.IsValidTeamName(c.Params.TeamName){ + if !model.IsValidTeamName(c.Params.TeamName) { c.SetInvalidUrlParam("team_name") } @@ -401,7 +413,7 @@ func (c *Context) RequireChannelName() *Context { if !model.IsValidChannelIdentifier(c.Params.ChannelName) { c.SetInvalidUrlParam("channel_name") - } + } return c } @@ -417,5 +429,3 @@ func (c *Context) RequireEmail() *Context { return c } - - |