diff options
author | Joram Wilander <jwawilander@gmail.com> | 2016-04-27 16:05:39 -0400 |
---|---|---|
committer | Harrison Healey <harrisonmhealey@gmail.com> | 2016-04-27 16:05:39 -0400 |
commit | 7695cbd1b4a62b1cc7c31b16f70309a287296385 (patch) | |
tree | 15a7f35bb56f0c72a9c13192380d795a48339d48 /api/channel.go | |
parent | ada513a0146cfb570e3614f9b26c0465de3a1d94 (diff) | |
download | chat-7695cbd1b4a62b1cc7c31b16f70309a287296385.tar.gz chat-7695cbd1b4a62b1cc7c31b16f70309a287296385.tar.bz2 chat-7695cbd1b4a62b1cc7c31b16f70309a287296385.zip |
Add websocket event and cache invalidation for deleting channels (#2807)
Diffstat (limited to 'api/channel.go')
-rw-r--r-- | api/channel.go | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/api/channel.go b/api/channel.go index d47109045..4b0e99b20 100644 --- a/api/channel.go +++ b/api/channel.go @@ -687,14 +687,20 @@ func deleteChannel(c *Context, w http.ResponseWriter, r *http.Request) { c.LogAudit("name=" + channel.Name) - post := &model.Post{ChannelId: channel.Id, Message: fmt.Sprintf( - c.T("api.channel.delete_channel.archived"), - user.Username)} - if _, err := CreatePost(c, post, false); err != nil { - l4g.Error(utils.T("api.channel.delete_channel.failed_post.error"), err) - c.Err = model.NewLocAppError("deleteChannel", "api.channel.delete_channel.failed_send.app_error", nil, "") - return - } + go func() { + InvalidateCacheForChannel(channel.Id) + message := model.NewMessage(c.TeamId, channel.Id, c.Session.UserId, model.ACTION_CHANNEL_DELETED) + PublishAndForget(message) + + post := &model.Post{ + ChannelId: channel.Id, + Message: fmt.Sprintf(c.T("api.channel.delete_channel.archived"), user.Username), + Type: model.POST_CHANNEL_DELETED, + } + if _, err := CreatePost(c, post, false); err != nil { + l4g.Error(utils.T("api.channel.delete_channel.failed_post.error"), err) + } + }() result := make(map[string]string) result["id"] = channel.Id |