[MM-23727] Make channel validation consistent on the server (#14230)
* MM-23727 Ensure user ids not allowed in channel name: MM-23727 Move channel name validation to model level * MM-23727 Update wording
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
036f9384b4
Коммит
7bc630a600
@@ -144,10 +144,6 @@ func (a *App) CreateChannelWithUser(channel *model.Channel, userId string) (*mod
|
||||
return nil, model.NewAppError("CreateChannelWithUser", "api.channel.create_channel.direct_channel.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
if strings.Index(channel.Name, "__") > 0 {
|
||||
return nil, model.NewAppError("CreateChannelWithUser", "api.channel.create_channel.invalid_character.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
if len(channel.TeamId) == 0 {
|
||||
return nil, model.NewAppError("CreateChannelWithUser", "app.channel.create_channel.no_team_id.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
@@ -464,14 +460,6 @@ func (a *App) GetGroupChannel(userIds []string) (*model.Channel, *model.AppError
|
||||
|
||||
// UpdateChannel updates a given channel by its Id. It also publishes the CHANNEL_UPDATED event.
|
||||
func (a *App) UpdateChannel(channel *model.Channel) (*model.Channel, *model.AppError) {
|
||||
userIds := strings.Split(channel.Name, "__")
|
||||
if channel.Type != model.CHANNEL_DIRECT &&
|
||||
len(userIds) == 2 &&
|
||||
model.IsValidId(userIds[0]) &&
|
||||
model.IsValidId(userIds[1]) {
|
||||
return nil, model.NewAppError("UpdateChannel", "api.channel.update_channel.invalid_character.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
_, err := a.Srv().Store.Channel().Update(channel)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
Ссылка в новой задаче
Block a user