diff options
author | Ruzette Tanyag <ruzette@users.noreply.github.com> | 2017-02-08 05:00:16 -0500 |
---|---|---|
committer | Joram Wilander <jwawilander@gmail.com> | 2017-02-08 02:00:16 -0800 |
commit | 0162d8ad08815b9b833fc651c7e185eab48cbbb2 (patch) | |
tree | 384c0032d766ad4a017a8a232590709134df8462 /api4/context.go | |
parent | 5462f0119edb788428f90fc61c8651e4a8cd9ad1 (diff) | |
download | chat-0162d8ad08815b9b833fc651c7e185eab48cbbb2.tar.gz chat-0162d8ad08815b9b833fc651c7e185eab48cbbb2.tar.bz2 chat-0162d8ad08815b9b833fc651c7e185eab48cbbb2.zip |
Implement GET `/users/username/{username}` endpoint for APIv4 (#5310)
* added get user by username endpoint
* added get user by username unit test and driver
* changed username length to 22 characters max
* changed Params to UserName to Username
* reorganized get user by username and get user by email formatting in model/client4
Diffstat (limited to 'api4/context.go')
-rw-r--r-- | api4/context.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/api4/context.go b/api4/context.go index 7ad6f30b4..6a22b4103 100644 --- a/api4/context.go +++ b/api4/context.go @@ -359,6 +359,22 @@ func (c *Context) RequireChannelId() *Context { return c } +func (c *Context) RequireUsername() *Context { + if c.Err != nil { + return c + } + + if len(c.Params.Username) < 3 { + c.SetInvalidUrlParam("username") + } + + if len(c.Params.Username) > 22 { + c.SetInvalidUrlParam("username") + } + + return c +} + func (c *Context) RequireEmail() *Context { if c.Err != nil { return c @@ -371,3 +387,4 @@ func (c *Context) RequireEmail() *Context { return c } + |