From 1ebf19825bc735424f7278a3c749f83d24ab80f1 Mon Sep 17 00:00:00 2001 From: Elias Nahum Date: Thu, 12 Apr 2018 10:12:59 -0300 Subject: Fix mute channel when not a member and adding unit tests (#8609) --- app/channel.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'app/channel.go') diff --git a/app/channel.go b/app/channel.go index 40f21c3a9..7c14538f4 100644 --- a/app/channel.go +++ b/app/channel.go @@ -1491,7 +1491,13 @@ func (a *App) GetDirectChannel(userId1, userId2 string) (*model.Channel, *model. } func (a *App) ToggleMuteChannel(channelId string, userId string) *model.ChannelMember { - member := (<-a.Srv.Store.Channel().GetMember(channelId, userId)).Data.(*model.ChannelMember) + result := <-a.Srv.Store.Channel().GetMember(channelId, userId) + + if result.Err != nil { + return nil + } + + member := result.Data.(*model.ChannelMember) if member.NotifyProps[model.MARK_UNREAD_NOTIFY_PROP] == model.CHANNEL_NOTIFY_MENTION { member.NotifyProps[model.MARK_UNREAD_NOTIFY_PROP] = model.CHANNEL_MARK_UNREAD_ALL -- cgit v1.2.3-1-g7c22