summaryrefslogtreecommitdiffstats
path: root/store/sql_webhook_store.go
diff options
context:
space:
mode:
authorJoramWilander <jwawilander@gmail.com>2015-10-22 14:27:47 -0400
committerJoramWilander <jwawilander@gmail.com>2015-10-22 14:27:47 -0400
commita431ba2c22918412d90d00c37fb89f6841f47eb8 (patch)
treea97206298923b7c9972b6c7bfdbf8d6caf7edae4 /store/sql_webhook_store.go
parent46f448899bf715fa2b557562a6a01d80ca4fc6b4 (diff)
downloadchat-a431ba2c22918412d90d00c37fb89f6841f47eb8.tar.gz
chat-a431ba2c22918412d90d00c37fb89f6841f47eb8.tar.bz2
chat-a431ba2c22918412d90d00c37fb89f6841f47eb8.zip
Delete webhooks when the associated channel gets deleted
Diffstat (limited to 'store/sql_webhook_store.go')
-rw-r--r--store/sql_webhook_store.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/store/sql_webhook_store.go b/store/sql_webhook_store.go
index 1910984f0..c758e2339 100644
--- a/store/sql_webhook_store.go
+++ b/store/sql_webhook_store.go
@@ -137,6 +137,27 @@ func (s SqlWebhookStore) GetIncomingByUser(userId string) StoreChannel {
return storeChannel
}
+func (s SqlWebhookStore) GetIncomingByChannel(channelId string) StoreChannel {
+ storeChannel := make(StoreChannel)
+
+ go func() {
+ result := StoreResult{}
+
+ var webhooks []*model.IncomingWebhook
+
+ if _, err := s.GetReplica().Select(&webhooks, "SELECT * FROM IncomingWebhooks WHERE ChannelId = :ChannelId AND DeleteAt = 0", map[string]interface{}{"ChannelId": channelId}); err != nil {
+ result.Err = model.NewAppError("SqlWebhookStore.GetIncomingByChannel", "We couldn't get the webhooks", "channelId="+channelId+", err="+err.Error())
+ }
+
+ result.Data = webhooks
+
+ storeChannel <- result
+ close(storeChannel)
+ }()
+
+ return storeChannel
+}
+
func (s SqlWebhookStore) SaveOutgoing(webhook *model.OutgoingWebhook) StoreChannel {
storeChannel := make(StoreChannel)