From 4ebf9746905c845ee3874f87478d7450391680d8 Mon Sep 17 00:00:00 2001 From: Chris Date: Fri, 2 Mar 2018 10:49:18 -0600 Subject: remove `go Publish(...)` idiom (#8373) --- app/channel.go | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) (limited to 'app/channel.go') diff --git a/app/channel.go b/app/channel.go index 8ac1f421c..131e242fb 100644 --- a/app/channel.go +++ b/app/channel.go @@ -545,7 +545,6 @@ func (a *App) DeleteChannel(channel *model.Channel, userId string) *model.AppErr message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_CHANNEL_DELETED, channel.TeamId, "", "", nil) message.Add("channel_id", channel.Id) - a.Publish(message) } @@ -1166,17 +1165,13 @@ func (a *App) removeUserFromChannel(userIdToRemove string, removerUserId string, message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_USER_REMOVED, "", channel.Id, "", nil) message.Add("user_id", userIdToRemove) message.Add("remover_id", removerUserId) - a.Go(func() { - a.Publish(message) - }) + a.Publish(message) // because the removed user no longer belongs to the channel we need to send a separate websocket event userMsg := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_USER_REMOVED, "", "", userIdToRemove, nil) userMsg.Add("channel_id", channel.Id) userMsg.Add("remover_id", removerUserId) - a.Go(func() { - a.Publish(userMsg) - }) + a.Publish(userMsg) return nil } @@ -1246,9 +1241,7 @@ func (a *App) UpdateChannelLastViewedAt(channelIds []string, userId string) *mod for _, channelId := range channelIds { message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_CHANNEL_VIEWED, "", "", userId, nil) message.Add("channel_id", channelId) - a.Go(func() { - a.Publish(message) - }) + a.Publish(message) } } @@ -1325,9 +1318,7 @@ func (a *App) ViewChannel(view *model.ChannelView, userId string, clearPushNotif if *a.Config().ServiceSettings.EnableChannelViewedMessages && model.IsValidId(view.ChannelId) { message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_CHANNEL_VIEWED, "", "", userId, nil) message.Add("channel_id", view.ChannelId) - a.Go(func() { - a.Publish(message) - }) + a.Publish(message) } return times, nil -- cgit v1.2.3-1-g7c22 From 09713ff4eadd3d706df45cb69f096b66c5b283fd Mon Sep 17 00:00:00 2001 From: Philippe GRANET Date: Wed, 7 Mar 2018 14:00:35 +0100 Subject: Add addedUser IDs to render correctly in client based on teammate name display setting (#8400) See PLT-7776 on mattermost-webapp: https://github.com/mattermost/mattermost-webapp/pull/353 --- app/channel.go | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'app/channel.go') diff --git a/app/channel.go b/app/channel.go index 131e242fb..edece8c98 100644 --- a/app/channel.go +++ b/app/channel.go @@ -1092,7 +1092,9 @@ func (a *App) PostAddToChannelMessage(user *model.User, addedUser *model.User, c UserId: user.Id, RootId: postRootId, Props: model.StringInterface{ + "userId": user.Id, "username": user.Username, + "addedUserId": addedUser.Id, "addedUsername": addedUser.Username, }, } @@ -1112,7 +1114,9 @@ func (a *App) postAddToTeamMessage(user *model.User, addedUser *model.User, chan UserId: user.Id, RootId: postRootId, Props: model.StringInterface{ + "userId": user.Id, "username": user.Username, + "addedUserId": addedUser.Id, "addedUsername": addedUser.Username, }, } @@ -1131,6 +1135,7 @@ func (a *App) postRemoveFromChannelMessage(removerUserId string, removedUser *mo Type: model.POST_REMOVE_FROM_CHANNEL, UserId: removerUserId, Props: model.StringInterface{ + "removedUserId": removedUser.Id, "removedUsername": removedUser.Username, }, } -- cgit v1.2.3-1-g7c22 From d448a6bef30339a63b7c118b8b2deb44cdb79d8e Mon Sep 17 00:00:00 2001 From: Jonathan Date: Wed, 7 Mar 2018 10:54:51 -0500 Subject: XYZ-87: GlobalRelay DM Exports do not Include Channel Name (#8275) * Adding ChannelMemberHistory table records when DM channels are created. This ensures that both participants in a DM are shown in compliance export, even if only one of them typed anything * Direct/Group Message channels now get pretty display names for the purpose of compliance exports * Fixed string formatting in t.Fatal calls * Changed uses of ChannelMemberHistory over to ChannelMemberHistoryResult in tests. This should have been done as a part of the work in XYZ-110, but seems to have been missed in this branch for some reason --- app/channel.go | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'app/channel.go') diff --git a/app/channel.go b/app/channel.go index edece8c98..76147a508 100644 --- a/app/channel.go +++ b/app/channel.go @@ -225,6 +225,14 @@ func (a *App) createDirectChannel(userId string, otherUserId string) (*model.Cha } } else { channel := result.Data.(*model.Channel) + + if result := <-a.Srv.Store.ChannelMemberHistory().LogJoinEvent(userId, channel.Id, model.GetMillis()); result.Err != nil { + l4g.Warn("Failed to update ChannelMemberHistory table %v", result.Err) + } + if result := <-a.Srv.Store.ChannelMemberHistory().LogJoinEvent(otherUserId, channel.Id, model.GetMillis()); result.Err != nil { + l4g.Warn("Failed to update ChannelMemberHistory table %v", result.Err) + } + return channel, nil } } @@ -1426,7 +1434,16 @@ func (a *App) GetDirectChannel(userId1, userId2 string) (*model.Channel, *model. } a.InvalidateCacheForUser(userId1) a.InvalidateCacheForUser(userId2) - return result.Data.(*model.Channel), nil + + channel := result.Data.(*model.Channel) + if result := <-a.Srv.Store.ChannelMemberHistory().LogJoinEvent(userId1, channel.Id, model.GetMillis()); result.Err != nil { + l4g.Warn("Failed to update ChannelMemberHistory table %v", result.Err) + } + if result := <-a.Srv.Store.ChannelMemberHistory().LogJoinEvent(userId2, channel.Id, model.GetMillis()); result.Err != nil { + l4g.Warn("Failed to update ChannelMemberHistory table %v", result.Err) + } + + return channel, nil } else if result.Err != nil { return nil, model.NewAppError("GetOrCreateDMChannel", "web.incoming_webhook.channel.app_error", nil, "err="+result.Err.Message, result.Err.StatusCode) } -- cgit v1.2.3-1-g7c22 From e8943936c51450540a4f2e8e7a2f3a2af90d14db Mon Sep 17 00:00:00 2001 From: Chris Date: Wed, 7 Mar 2018 12:36:40 -0600 Subject: general cleanup (#8387) --- app/channel.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'app/channel.go') diff --git a/app/channel.go b/app/channel.go index 76147a508..4e294abbb 100644 --- a/app/channel.go +++ b/app/channel.go @@ -377,7 +377,7 @@ func (a *App) postChannelPrivacyMessage(user *model.User, channel *model.Channel })[channel.Type] post := &model.Post{ ChannelId: channel.Id, - Message: fmt.Sprintf(utils.T("api.channel.change_channel_privacy." + privacy)), + Message: utils.T("api.channel.change_channel_privacy." + privacy), Type: model.POST_CHANGE_CHANNEL_PRIVACY, UserId: user.Id, Props: model.StringInterface{ @@ -1062,7 +1062,7 @@ func (a *App) LeaveChannel(channelId string, userId string) *model.AppError { return err } - if channel.Name == model.DEFAULT_CHANNEL && *a.Config().ServiceSettings.ExperimentalEnableDefaultChannelLeaveJoinMessages == false { + if channel.Name == model.DEFAULT_CHANNEL && !*a.Config().ServiceSettings.ExperimentalEnableDefaultChannelLeaveJoinMessages { return nil } -- cgit v1.2.3-1-g7c22