summaryrefslogtreecommitdiffstats
path: root/api
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2015-10-23 08:34:57 -0400
committerChristopher Speller <crspeller@gmail.com>2015-10-23 08:34:57 -0400
commitc8edad29c1a1c86fe3ac20ab4da8cc99f038c2a6 (patch)
tree4ab3c63173c52f71a98925c478ca00be4df0225c /api
parent8db383d2e33520fcf4318f27d905418abdbc28da (diff)
parenta431ba2c22918412d90d00c37fb89f6841f47eb8 (diff)
downloadchat-c8edad29c1a1c86fe3ac20ab4da8cc99f038c2a6.tar.gz
chat-c8edad29c1a1c86fe3ac20ab4da8cc99f038c2a6.tar.bz2
chat-c8edad29c1a1c86fe3ac20ab4da8cc99f038c2a6.zip
Merge pull request #1149 from mattermost/plt-808
PLT-808 Fix deleting channels breaking the webhook UI
Diffstat (limited to 'api')
-rw-r--r--api/channel.go27
1 files changed, 27 insertions, 0 deletions
diff --git a/api/channel.go b/api/channel.go
index 9c7ac053b..a8c8505e9 100644
--- a/api/channel.go
+++ b/api/channel.go
@@ -508,6 +508,8 @@ func deleteChannel(c *Context, w http.ResponseWriter, r *http.Request) {
sc := Srv.Store.Channel().Get(id)
scm := Srv.Store.Channel().GetMember(id, c.Session.UserId)
uc := Srv.Store.User().Get(c.Session.UserId)
+ ihc := Srv.Store.Webhook().GetIncomingByChannel(id)
+ ohc := Srv.Store.Webhook().GetOutgoingByChannel(id)
if cresult := <-sc; cresult.Err != nil {
c.Err = cresult.Err
@@ -518,10 +520,18 @@ func deleteChannel(c *Context, w http.ResponseWriter, r *http.Request) {
} else if scmresult := <-scm; scmresult.Err != nil {
c.Err = scmresult.Err
return
+ } else if ihcresult := <-ihc; ihcresult.Err != nil {
+ c.Err = ihcresult.Err
+ return
+ } else if ohcresult := <-ohc; ohcresult.Err != nil {
+ c.Err = ohcresult.Err
+ return
} else {
channel := cresult.Data.(*model.Channel)
user := uresult.Data.(*model.User)
channelMember := scmresult.Data.(model.ChannelMember)
+ incomingHooks := ihcresult.Data.([]*model.IncomingWebhook)
+ outgoingHooks := ohcresult.Data.([]*model.OutgoingWebhook)
if !c.HasPermissionsToTeam(channel.TeamId, "deleteChannel") {
return
@@ -545,6 +555,23 @@ func deleteChannel(c *Context, w http.ResponseWriter, r *http.Request) {
return
}
+ now := model.GetMillis()
+ for _, hook := range incomingHooks {
+ go func() {
+ if result := <-Srv.Store.Webhook().DeleteIncoming(hook.Id, now); result.Err != nil {
+ l4g.Error("Encountered error deleting incoming webhook, id=" + hook.Id)
+ }
+ }()
+ }
+
+ for _, hook := range outgoingHooks {
+ go func() {
+ if result := <-Srv.Store.Webhook().DeleteOutgoing(hook.Id, now); result.Err != nil {
+ l4g.Error("Encountered error deleting outgoing webhook, id=" + hook.Id)
+ }
+ }()
+ }
+
if dresult := <-Srv.Store.Channel().Delete(channel.Id, model.GetMillis()); dresult.Err != nil {
c.Err = dresult.Err
return