Displayed error message for already used channel name (#24860)

* WIP

* Displayed existing channel name error

* refactoring
This commit is contained in:
Harshil Sharma
2023-10-10 17:41:49 +05:30
committed by GitHub
parent f18002a8d6
commit 06765b1f44
7 changed files with 72 additions and 8 deletions
+3
View File
@@ -697,6 +697,9 @@ func (a *App) UpdateChannel(c request.CTX, channel *model.Channel) (*model.Chann
var invErr *store.ErrInvalidInput
switch {
case errors.As(err, &invErr):
if invErr.Entity == "Channel" && invErr.Field == "Name" {
return nil, model.NewAppError("UpdateChannel", store.ChannelExistsError, nil, "", http.StatusBadRequest).Wrap(err)
}
return nil, model.NewAppError("UpdateChannel", "app.channel.update.bad_id", nil, "", http.StatusBadRequest).Wrap(err)
case errors.As(err, &appErr):
return nil, appErr