summaryrefslogtreecommitdiffstats
path: root/api/webhook.go
diff options
context:
space:
mode:
authorDavid Lu <david.lu@hotmail.com>2016-05-27 08:35:55 -0700
committerCorey Hulen <corey@hulen.com>2016-05-27 08:35:55 -0700
commit0d0734ac9845ef32c55ebf4c3185ba85065c5940 (patch)
treeaaaf2522d8cacbf06fce4aee0d89aac1f1d9ec19 /api/webhook.go
parent1e7805b79025823fba4479ffaa354e9c756d6622 (diff)
downloadchat-0d0734ac9845ef32c55ebf4c3185ba85065c5940.tar.gz
chat-0d0734ac9845ef32c55ebf4c3185ba85065c5940.tar.bz2
chat-0d0734ac9845ef32c55ebf4c3185ba85065c5940.zip
Added duplicated trigger validation (#3124)
Diffstat (limited to 'api/webhook.go')
-rw-r--r--api/webhook.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/api/webhook.go b/api/webhook.go
index 11456d69e..676fd2cbc 100644
--- a/api/webhook.go
+++ b/api/webhook.go
@@ -214,6 +214,23 @@ func createOutgoingHook(c *Context, w http.ResponseWriter, r *http.Request) {
return
}
+ if result := <-Srv.Store.Webhook().GetOutgoingByTeam(c.TeamId); result.Err != nil {
+ c.Err = result.Err
+ return
+ } else {
+ allHooks := result.Data.([]*model.OutgoingWebhook)
+
+ for _, existingOutHook := range allHooks {
+ urlIntersect := utils.StringArrayIntersection(existingOutHook.CallbackURLs, hook.CallbackURLs)
+ triggerIntersect := utils.StringArrayIntersection(existingOutHook.TriggerWords, hook.TriggerWords)
+
+ if existingOutHook.ChannelId == hook.ChannelId && len(urlIntersect) != 0 && len(triggerIntersect) != 0 {
+ c.Err = model.NewLocAppError("createOutgoingHook", "api.webhook.create_outgoing.intersect.app_error", nil, "")
+ return
+ }
+ }
+ }
+
if result := <-Srv.Store.Webhook().SaveOutgoing(hook); result.Err != nil {
c.Err = result.Err
return