summaryrefslogtreecommitdiffstats
path: root/api4/context.go
diff options
context:
space:
mode:
authorSaturnino Abril <saturnino.abril@gmail.com>2017-04-22 21:52:03 +0900
committerHarrison Healey <harrisonmhealey@gmail.com>2017-04-22 08:52:03 -0400
commitecb10ed62fdff179e34f82b0ff2569da8390f4ad (patch)
treee2405ed87a31cca42275b98a76e1312c0a1867eb /api4/context.go
parente62afeace04e2abd23fa78a0a54e0a5d2e17e0b7 (diff)
downloadchat-ecb10ed62fdff179e34f82b0ff2569da8390f4ad.tar.gz
chat-ecb10ed62fdff179e34f82b0ff2569da8390f4ad.tar.bz2
chat-ecb10ed62fdff179e34f82b0ff2569da8390f4ad.zip
APIv4 DELETE /users/{user_id}/posts/{post_id}/reactions/name (#6117)
* APIv4 DELETE /users/{user_id}/posts/{post_id}/reactions/name * updated v3 deleteReaction endpoint * update parameter of app.DeleteReactionForPost() * update utils.IsValidAlphaNum, add utils.IsValidAlphaNumHyphenUnderscore, and add related tests
Diffstat (limited to 'api4/context.go')
-rw-r--r--api4/context.go16
1 files changed, 14 insertions, 2 deletions
diff --git a/api4/context.go b/api4/context.go
index f492f2b99..c7fba4f5f 100644
--- a/api4/context.go
+++ b/api4/context.go
@@ -468,7 +468,7 @@ func (c *Context) RequireCategory() *Context {
return c
}
- if !model.IsValidAlphaNum(c.Params.Category, true) {
+ if !model.IsValidAlphaNumHyphenUnderscore(c.Params.Category, true) {
c.SetInvalidUrlParam("category")
}
@@ -492,13 +492,25 @@ func (c *Context) RequirePreferenceName() *Context {
return c
}
- if !model.IsValidAlphaNum(c.Params.PreferenceName, true) {
+ if !model.IsValidAlphaNumHyphenUnderscore(c.Params.PreferenceName, true) {
c.SetInvalidUrlParam("preference_name")
}
return c
}
+func (c *Context) RequireEmojiName() *Context {
+ if c.Err != nil {
+ return c
+ }
+
+ if len(c.Params.EmojiName) == 0 || len(c.Params.EmojiName) > 64 || !model.IsValidAlphaNumHyphenUnderscore(c.Params.EmojiName, false) {
+ c.SetInvalidUrlParam("emoji_name")
+ }
+
+ return c
+}
+
func (c *Context) RequireHookId() *Context {
if c.Err != nil {
return c