diff options
author | Ruzette Tanyag <ruzette@users.noreply.github.com> | 2017-02-28 04:14:16 -0500 |
---|---|---|
committer | George Goldberg <george@gberg.me> | 2017-02-28 09:14:16 +0000 |
commit | cef5028cbeed93b6493f6d1f379afe4ca85535c8 (patch) | |
tree | 6424b7878b372c6457845f933d7406c971399f79 /api4/context.go | |
parent | 758402311a97a053a5276049db6dce4f8f8dcfbc (diff) | |
download | chat-cef5028cbeed93b6493f6d1f379afe4ca85535c8.tar.gz chat-cef5028cbeed93b6493f6d1f379afe4ca85535c8.tar.bz2 chat-cef5028cbeed93b6493f6d1f379afe4ca85535c8.zip |
Implemented preferences endpoints for apiv4 (#5531)
* implemented preferences endpoints for apiv4
* added user id in preferences endpoints
Diffstat (limited to 'api4/context.go')
-rw-r--r-- | api4/context.go | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/api4/context.go b/api4/context.go index f0d8b0c5c..c30a975f2 100644 --- a/api4/context.go +++ b/api4/context.go @@ -431,3 +431,27 @@ func (c *Context) RequireEmail() *Context { return c } + +func (c *Context) RequireCategory() *Context { + if c.Err != nil { + return c + } + + if !model.IsValidAlphaNum(c.Params.Category, true) { + c.SetInvalidUrlParam("category") + } + + return c +} + +func (c *Context) RequirePreferenceName() *Context { + if c.Err != nil { + return c + } + + if !model.IsValidAlphaNum(c.Params.PreferenceName, true) { + c.SetInvalidUrlParam("preference_name") + } + + return c +} |