summaryrefslogtreecommitdiffstats
path: root/api4/context.go
diff options
context:
space:
mode:
Diffstat (limited to 'api4/context.go')
-rw-r--r--api4/context.go27
1 files changed, 24 insertions, 3 deletions
diff --git a/api4/context.go b/api4/context.go
index 484a6432f..847a8d55f 100644
--- a/api4/context.go
+++ b/api4/context.go
@@ -1,4 +1,4 @@
-// Copyright (c) 2017 Mattermost, Inc. All Rights Reserved.
+// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
package api4
@@ -242,8 +242,7 @@ func (c *Context) IsSystemAdmin() bool {
func (c *Context) SessionRequired() {
if len(c.Session.UserId) == 0 {
- c.Err = model.NewLocAppError("", "api.context.session_expired.app_error", nil, "UserRequired")
- c.Err.StatusCode = http.StatusUnauthorized
+ c.Err = model.NewAppError("", "api.context.session_expired.app_error", nil, "UserRequired", http.StatusUnauthorized)
return
}
}
@@ -406,6 +405,17 @@ func (c *Context) RequireReportId() *Context {
return c
}
+func (c *Context) RequireEmojiId() *Context {
+ if c.Err != nil {
+ return c
+ }
+
+ if len(c.Params.EmojiId) != 26 {
+ c.SetInvalidUrlParam("emoji_id")
+ }
+ return c
+}
+
func (c *Context) RequireTeamName() *Context {
if c.Err != nil {
return c
@@ -477,3 +487,14 @@ func (c *Context) RequireHookId() *Context {
return c
}
+
+func (c *Context) RequireCommandId() *Context {
+ if c.Err != nil {
+ return c
+ }
+
+ if len(c.Params.CommandId) != 26 {
+ c.SetInvalidUrlParam("command_id")
+ }
+ return c
+}