diff --git a/server/api/review/[revid]/reply.post.ts b/server/api/review/[revid]/reply.post.ts index b3a1d7f..51c7d98 100644 --- a/server/api/review/[revid]/reply.post.ts +++ b/server/api/review/[revid]/reply.post.ts @@ -36,10 +36,18 @@ export default eventHandler(async (ev) => { whichChapter: replyingTo.whichChapter, datePosted: new Date(), }); - let nrs = await newReply.save(); + const { _id } = await newReply.save(); + const nrs = (await Review.findOne({ _id }) + .populate("author", "username _id blocked") + .exec())!; replyingTo.replies.push(nrs._id); await replyingTo.save(); const story = await Story.findById(replyingTo.leftOn); + if (!story) { + throw createError({ + statusCode: 404, + }); + } return { back: `/story/${replyingTo.leftOn}/${ story!.chapters.findIndex((x) => x.id === nrs.whichChapter) + 1