diff --git a/lib/server/middlewareButNotReally/storyCheck.ts b/lib/server/middlewareButNotReally/storyCheck.ts index cb42b0a..0b4eb4d 100644 --- a/lib/server/middlewareButNotReally/storyCheck.ts +++ b/lib/server/middlewareButNotReally/storyCheck.ts @@ -9,15 +9,17 @@ export default async function ( idx: number, ) { let ret: any = {}; - if (story.ficmas != null) { + if (!story) { + ret.statusCode = 404; + ret.message = messages[404]; + } else if (story.ficmas != null) { if (isFicmasHidden(story)) { ret = { statusCode: 423, message: `TOP SECRET! This story is part of an ongoing challenge. You'll be able to read it after the challenge's reveal date.`, }; } - } - if ( + } else if ( story.chapters[idx]?.hidden && event.context.currentUser?._id !== story.author._id && !event.context.currentUser?.profile.isAdmin