diff options
author | Jesús Espino <jespinog@gmail.com> | 2018-10-02 19:33:52 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-02 19:33:52 +0200 |
commit | 2945e8a2b0ce9306bb049e65eb2410038e0fa18c (patch) | |
tree | cee7c4edc0a947496caec9bf9e6b84b09231d926 /app/channel.go | |
parent | c82a84ed765bd9c4d601b93201d93af92f6ee742 (diff) | |
download | chat-2945e8a2b0ce9306bb049e65eb2410038e0fa18c.tar.gz chat-2945e8a2b0ce9306bb049e65eb2410038e0fa18c.tar.bz2 chat-2945e8a2b0ce9306bb049e65eb2410038e0fa18c.zip |
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
Diffstat (limited to 'app/channel.go')
-rw-r--r-- | app/channel.go | 8 |
1 files changed, 8 insertions, 0 deletions
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 |