[MM-52955] Fix panic for not found posts (#23561)

Этот коммит содержится в:
Ben Schumacher
2023-06-05 10:00:06 +02:00
коммит произвёл GitHub
родитель c94e8c2134
Коммит 9a55280d7a
2 изменённых файлов: 15 добавлений и 0 удалений

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

@@ -41,6 +41,11 @@ func (s *SqlReactionStore) Save(reaction *model.Reaction) (re *model.Reaction, e
if err != nil {
return nil, errors.Wrap(err, "failed while getting channelId from Posts")
}
if len(channelIds) == 0 {
return nil, store.NewErrNotFound("Post", reaction.PostId)
}
reaction.ChannelId = channelIds[0]
}
err = s.saveReactionAndUpdatePost(transaction, reaction)