From 7e300734d860d3f37672499da738aa2f7217c180 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=98=99=E2=97=A6=20The=20Tablet=20=E2=9D=80=20GamerGirla?= =?UTF-8?q?ndCo=20=E2=97=A6=E2=9D=A7?= Date: Sat, 9 Dec 2023 17:20:13 -0500 Subject: [PATCH] refactor(api/utils): switch to if...else if for each check --- lib/server/middlewareButNotReally/storyCheck.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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