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/command_mute.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'app/command_mute.go') diff --git a/app/command_mute.go b/app/command_mute.go index fdc698cd9..d3a2fa5f7 100644 --- a/app/command_mute.go +++ b/app/command_mute.go @@ -40,7 +40,7 @@ func (me *MuteProvider) DoCommand(a *App, args *model.CommandArgs, message strin var noChannelErr *model.AppError if channel, noChannelErr = a.GetChannel(args.ChannelId); noChannelErr != nil { - return &model.CommandResponse{Text: args.T("api.command_mute.error", map[string]interface{}{"Channel": channel.DisplayName}), ResponseType: model.COMMAND_RESPONSE_TYPE_EPHEMERAL} + return &model.CommandResponse{Text: args.T("api.command_mute.no_channel.error"), ResponseType: model.COMMAND_RESPONSE_TYPE_EPHEMERAL} } channelName := "" @@ -63,6 +63,9 @@ func (me *MuteProvider) DoCommand(a *App, args *model.CommandArgs, message strin } channelMember := a.ToggleMuteChannel(channel.Id, args.UserId) + if channelMember == nil { + return &model.CommandResponse{Text: args.T("api.command_mute.not_member.error", map[string]interface{}{"Channel": channelName}), ResponseType: model.COMMAND_RESPONSE_TYPE_EPHEMERAL} + } // Invalidate cache to allow cache lookups while sending notifications a.Srv.Store.Channel().InvalidateCacheForChannelMembersNotifyProps(channel.Id) -- cgit v1.2.3-1-g7c22