summaryrefslogtreecommitdiffstats
path: root/store/sql_webhook_store.go
diff options
context:
space:
mode:
authorChris <ccbrown112@gmail.com>2017-07-31 08:52:45 -0700
committerHarrison Healey <harrisonmhealey@gmail.com>2017-07-31 11:52:45 -0400
commit72f61ab96aabf65c162c8d94b5b843b5108ee1a9 (patch)
treec80d7158613663a0b3f584a1736ef1cbff72d160 /store/sql_webhook_store.go
parent0f786a42d3289df9b4f5bdb4bddb0ecb07631608 (diff)
downloadchat-72f61ab96aabf65c162c8d94b5b843b5108ee1a9.tar.gz
chat-72f61ab96aabf65c162c8d94b5b843b5108ee1a9.tar.bz2
chat-72f61ab96aabf65c162c8d94b5b843b5108ee1a9.zip
make cli team / channel delete operations also delete webhooks and slash commands (#7028)
Diffstat (limited to 'store/sql_webhook_store.go')
-rw-r--r--store/sql_webhook_store.go44
1 files changed, 44 insertions, 0 deletions
diff --git a/store/sql_webhook_store.go b/store/sql_webhook_store.go
index d59d7e03a..56c1b1643 100644
--- a/store/sql_webhook_store.go
+++ b/store/sql_webhook_store.go
@@ -186,6 +186,8 @@ func (s SqlWebhookStore) DeleteIncoming(webhookId string, time int64) StoreChann
result.Err = model.NewLocAppError("SqlWebhookStore.DeleteIncoming", "store.sql_webhooks.delete_incoming.app_error", nil, "id="+webhookId+", err="+err.Error())
}
+ s.InvalidateWebhookCache(webhookId)
+
storeChannel <- result
close(storeChannel)
}()
@@ -204,6 +206,28 @@ func (s SqlWebhookStore) PermanentDeleteIncomingByUser(userId string) StoreChann
result.Err = model.NewLocAppError("SqlWebhookStore.DeleteIncomingByUser", "store.sql_webhooks.permanent_delete_incoming_by_user.app_error", nil, "id="+userId+", err="+err.Error())
}
+ ClearWebhookCaches()
+
+ storeChannel <- result
+ close(storeChannel)
+ }()
+
+ return storeChannel
+}
+
+func (s SqlWebhookStore) PermanentDeleteIncomingByChannel(channelId string) StoreChannel {
+ storeChannel := make(StoreChannel, 1)
+
+ go func() {
+ result := StoreResult{}
+
+ _, err := s.GetMaster().Exec("DELETE FROM IncomingWebhooks WHERE ChannelId = :ChannelId", map[string]interface{}{"ChannelId": channelId})
+ if err != nil {
+ result.Err = model.NewLocAppError("SqlWebhookStore.DeleteIncomingByChannel", "store.sql_webhooks.permanent_delete_incoming_by_channel.app_error", nil, "id="+channelId+", err="+err.Error())
+ }
+
+ ClearWebhookCaches()
+
storeChannel <- result
close(storeChannel)
}()
@@ -442,6 +466,26 @@ func (s SqlWebhookStore) PermanentDeleteOutgoingByUser(userId string) StoreChann
return storeChannel
}
+func (s SqlWebhookStore) PermanentDeleteOutgoingByChannel(channelId string) StoreChannel {
+ storeChannel := make(StoreChannel, 1)
+
+ go func() {
+ result := StoreResult{}
+
+ _, err := s.GetMaster().Exec("DELETE FROM OutgoingWebhooks WHERE ChannelId = :ChannelId", map[string]interface{}{"ChannelId": channelId})
+ if err != nil {
+ result.Err = model.NewLocAppError("SqlWebhookStore.DeleteOutgoingByChannel", "store.sql_webhooks.permanent_delete_outgoing_by_channel.app_error", nil, "id="+channelId+", err="+err.Error())
+ }
+
+ ClearWebhookCaches()
+
+ storeChannel <- result
+ close(storeChannel)
+ }()
+
+ return storeChannel
+}
+
func (s SqlWebhookStore) UpdateOutgoing(hook *model.OutgoingWebhook) StoreChannel {
storeChannel := make(StoreChannel, 1)