summaryrefslogtreecommitdiffstats
path: root/app/channel.go
diff options
context:
space:
mode:
authorJoram Wilander <jwawilander@gmail.com>2017-01-27 14:07:34 -0500
committerGitHub <noreply@github.com>2017-01-27 14:07:34 -0500
commit097289f8e473c799ee752aa56e08f605110f5217 (patch)
tree424cd42d691b28d1c08852dc02a69d69f2b70a65 /app/channel.go
parent8eab04e944b3874f1fc4985344cbccec84c6002a (diff)
downloadchat-097289f8e473c799ee752aa56e08f605110f5217.tar.gz
chat-097289f8e473c799ee752aa56e08f605110f5217.tar.bz2
chat-097289f8e473c799ee752aa56e08f605110f5217.zip
Merge 3.6.2 into master (#5211)
* Add webhook cache * Add channel by name cache * Fxing profiles in channels cache * Fix merge
Diffstat (limited to 'app/channel.go')
-rw-r--r--app/channel.go19
1 files changed, 10 insertions, 9 deletions
diff --git a/app/channel.go b/app/channel.go
index 1844e3177..c9199f829 100644
--- a/app/channel.go
+++ b/app/channel.go
@@ -88,7 +88,7 @@ func CreateDefaultChannels(teamId string) ([]*model.Channel, *model.AppError) {
func JoinDefaultChannels(teamId string, user *model.User, channelRole string) *model.AppError {
var err *model.AppError = nil
- if result := <-Srv.Store.Channel().GetByName(teamId, "town-square"); result.Err != nil {
+ if result := <-Srv.Store.Channel().GetByName(teamId, "town-square", true); result.Err != nil {
err = result.Err
} else {
cm := &model.ChannelMember{ChannelId: result.Data.(*model.Channel).Id, UserId: user.Id,
@@ -105,14 +105,14 @@ func JoinDefaultChannels(teamId string, user *model.User, channelRole string) *m
UserId: user.Id,
}
- InvalidateCacheForChannel(result.Data.(*model.Channel).Id)
+ InvalidateCacheForChannelMembers(result.Data.(*model.Channel).Id)
if _, err := CreatePost(post, teamId, false); err != nil {
l4g.Error(utils.T("api.channel.post_user_add_remove_message_and_forget.error"), err)
}
}
- if result := <-Srv.Store.Channel().GetByName(teamId, "off-topic"); result.Err != nil {
+ if result := <-Srv.Store.Channel().GetByName(teamId, "off-topic", true); result.Err != nil {
err = result.Err
} else {
cm := &model.ChannelMember{ChannelId: result.Data.(*model.Channel).Id, UserId: user.Id,
@@ -129,7 +129,7 @@ func JoinDefaultChannels(teamId string, user *model.User, channelRole string) *m
UserId: user.Id,
}
- InvalidateCacheForChannel(result.Data.(*model.Channel).Id)
+ InvalidateCacheForChannelMembers(result.Data.(*model.Channel).Id)
if _, err := CreatePost(post, teamId, false); err != nil {
l4g.Error(utils.T("api.channel.post_user_add_remove_message_and_forget.error"), err)
@@ -195,7 +195,7 @@ func UpdateChannel(channel *model.Channel) (*model.Channel, *model.AppError) {
if result := <-Srv.Store.Channel().Update(channel); result.Err != nil {
return nil, result.Err
} else {
- InvalidateCacheForChannel(channel.Id)
+ InvalidateCacheForChannel(channel)
return channel, nil
}
}
@@ -287,6 +287,7 @@ func DeleteChannel(channel *model.Channel, userId string) *model.AppError {
if result := <-Srv.Store.Webhook().DeleteIncoming(hook.Id, now); result.Err != nil {
l4g.Error(utils.T("api.channel.delete_channel.incoming_webhook.error"), hook.Id)
}
+ InvalidateCacheForWebhook(hook.Id)
}
for _, hook := range outgoingHooks {
@@ -298,7 +299,7 @@ func DeleteChannel(channel *model.Channel, userId string) *model.AppError {
if dresult := <-Srv.Store.Channel().Delete(channel.Id, model.GetMillis()); dresult.Err != nil {
return dresult.Err
}
- InvalidateCacheForChannel(channel.Id)
+ InvalidateCacheForChannel(channel)
message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_CHANNEL_DELETED, channel.TeamId, "", "", nil)
message.Add("channel_id", channel.Id)
@@ -351,7 +352,7 @@ func AddUserToChannel(user *model.User, channel *model.Channel) (*model.ChannelM
}
InvalidateCacheForUser(user.Id)
- InvalidateCacheForChannel(channel.Id)
+ InvalidateCacheForChannelMembers(channel.Id)
message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_USER_ADDED, "", channel.Id, "", nil)
message.Add("user_id", user.Id)
@@ -508,7 +509,7 @@ func GetChannel(channelId string) (*model.Channel, *model.AppError) {
}
func GetChannelByName(channelName, teamId string) (*model.Channel, *model.AppError) {
- if result := <-Srv.Store.Channel().GetByName(teamId, channelName); result.Err != nil {
+ if result := <-Srv.Store.Channel().GetByName(teamId, channelName, true); result.Err != nil {
return nil, result.Err
} else {
return result.Data.(*model.Channel), nil
@@ -650,7 +651,7 @@ func RemoveUserFromChannel(userIdToRemove string, removerUserId string, channel
}
InvalidateCacheForUser(userIdToRemove)
- InvalidateCacheForChannel(channel.Id)
+ InvalidateCacheForChannelMembers(channel.Id)
message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_USER_REMOVED, "", channel.Id, "", nil)
message.Add("user_id", userIdToRemove)