Fix unchecked request when saving channel (#21043)

Этот коммит содержится в:
Tim Scheuermann
2022-11-07 11:28:31 +01:00
коммит произвёл GitHub
родитель d855916c6e
Коммит 033bdd6f1a
2 изменённых файлов: 4 добавлений и 2 удалений

Просмотреть файл

@@ -687,7 +687,9 @@ func (s SqlChannelStore) saveChannelT(transaction *sqlxTxWrapper, channel *model
(:Id, :CreateAt, :UpdateAt, :DeleteAt, :TeamId, :Type, :DisplayName, :Name, :Header, :Purpose, :LastPostAt, :TotalMsgCount, :ExtraUpdateAt, :CreatorId, :SchemeId, :GroupConstrained, :Shared, :TotalMsgCountRoot, :LastRootPostAt)`, channel); err != nil {
if IsUniqueConstraintError(err, []string{"Name", "channels_name_teamid_key"}) {
dupChannel := model.Channel{}
s.GetMasterX().Get(&dupChannel, "SELECT * FROM Channels WHERE TeamId = ? AND Name = ?", channel.TeamId, channel.Name)
if serr := s.GetMasterX().Get(&dupChannel, "SELECT * FROM Channels WHERE TeamId = ? AND Name = ?", channel.TeamId, channel.Name); serr != nil {
return nil, errors.Wrapf(serr, "error while retrieving existing channel %s", channel.Name) // do not return this as a *store.ErrConflict as it would be treated as a recoverable error
}
return &dupChannel, store.NewErrConflict("Channel", err, "id="+channel.Id)
}
return nil, errors.Wrapf(err, "save_channel: id=%s", channel.Id)