From ef9326bcbb461b4f3265f75a9f738e67e58b88d1 Mon Sep 17 00:00:00 2001 From: Joram Wilander Date: Mon, 19 Jun 2017 13:55:47 -0400 Subject: Move integrations over to redux and v4 (#6679) --- api4/webhook.go | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'api4') diff --git a/api4/webhook.go b/api4/webhook.go index 6602c7a26..668636932 100644 --- a/api4/webhook.go +++ b/api4/webhook.go @@ -71,7 +71,7 @@ func updateIncomingHook(c *Context, w http.ResponseWriter, r *http.Request) { return } - hookID := c.Params.HookId + hookId := c.Params.HookId updatedHook := model.IncomingWebhookFromJson(r.Body) if updatedHook == nil { @@ -81,12 +81,16 @@ func updateIncomingHook(c *Context, w http.ResponseWriter, r *http.Request) { c.LogAudit("attempt") - oldHook, err := app.GetIncomingWebhook(hookID) + oldHook, err := app.GetIncomingWebhook(hookId) if err != nil { c.Err = err return } + if updatedHook.TeamId == "" { + updatedHook.TeamId = oldHook.TeamId + } + if updatedHook.TeamId != oldHook.TeamId { c.Err = model.NewAppError("updateIncomingHook", "api.webhook.team_mismatch.app_error", nil, "user_id="+c.Session.UserId, http.StatusBadRequest) return @@ -161,13 +165,13 @@ func getIncomingHook(c *Context, w http.ResponseWriter, r *http.Request) { return } - hookID := c.Params.HookId + hookId := c.Params.HookId var err *model.AppError var hook *model.IncomingWebhook var channel *model.Channel - if hook, err = app.GetIncomingWebhook(hookID); err != nil { + if hook, err = app.GetIncomingWebhook(hookId); err != nil { c.Err = err return } else { @@ -195,13 +199,13 @@ func deleteIncomingHook(c *Context, w http.ResponseWriter, r *http.Request) { return } - hookID := c.Params.HookId + hookId := c.Params.HookId var err *model.AppError var hook *model.IncomingWebhook var channel *model.Channel - if hook, err = app.GetIncomingWebhook(hookID); err != nil { + if hook, err = app.GetIncomingWebhook(hookId); err != nil { c.Err = err return } else { @@ -217,7 +221,7 @@ func deleteIncomingHook(c *Context, w http.ResponseWriter, r *http.Request) { c.SetPermissionError(model.PERMISSION_MANAGE_WEBHOOKS) return } else { - if err = app.DeleteIncomingWebhook(hookID); err != nil { + if err = app.DeleteIncomingWebhook(hookId); err != nil { c.Err = err return } -- cgit v1.2.3-1-g7c22