From 2945e8a2b0ce9306bb049e65eb2410038e0fa18c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Espino?= Date: Tue, 2 Oct 2018 19:33:52 +0200 Subject: MM-10699: Disallow renaming direct and group message channels (#9518) * MM-10699: Disallow renaming direct and group message channels * Replacing errors.New with errors.Wrapf --- app/channel.go | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'app/channel.go') diff --git a/app/channel.go b/app/channel.go index 30fc2c1b6..54b589175 100644 --- a/app/channel.go +++ b/app/channel.go @@ -163,6 +163,14 @@ func (a *App) CreateChannelWithUser(channel *model.Channel, userId string) (*mod // RenameChannel is used to rename the channel Name and the DisplayName fields func (a *App) RenameChannel(channel *model.Channel, newChannelName string, newDisplayName string) (*model.Channel, *model.AppError) { + if channel.Type == model.CHANNEL_DIRECT { + return nil, model.NewAppError("RenameChannel", "api.channel.rename_channel.cant_rename_direct_messages.app_error", nil, "", http.StatusBadRequest) + } + + if channel.Type == model.CHANNEL_GROUP { + return nil, model.NewAppError("RenameChannel", "api.channel.rename_channel.cant_rename_group_messages.app_error", nil, "", http.StatusBadRequest) + } + channel.Name = newChannelName if newDisplayName != "" { channel.DisplayName = newDisplayName -- cgit v1.2.3-1-g7c22