summaryrefslogtreecommitdiffstats
path: root/app/command_mute.go
diff options
context:
space:
mode:
authorElias Nahum <nahumhbl@gmail.com>2018-04-12 10:12:59 -0300
committerJoram Wilander <jwawilander@gmail.com>2018-04-12 09:12:59 -0400
commit1ebf19825bc735424f7278a3c749f83d24ab80f1 (patch)
treeb94801594bd06588e997e2138586be81d5190d83 /app/command_mute.go
parent2d0fef4d943198014913069d2b79a73f2e3a7d9a (diff)
downloadchat-1ebf19825bc735424f7278a3c749f83d24ab80f1.tar.gz
chat-1ebf19825bc735424f7278a3c749f83d24ab80f1.tar.bz2
chat-1ebf19825bc735424f7278a3c749f83d24ab80f1.zip
Fix mute channel when not a member and adding unit tests (#8609)
Diffstat (limited to 'app/command_mute.go')
-rw-r--r--app/command_mute.go5
1 files changed, 4 insertions, 1 deletions
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)