refactor(api/utils): switch to if...else if for each check
This commit is contained in:
parent
b979b52978
commit
7e300734d8
@ -9,15 +9,17 @@ export default async function (
|
|||||||
idx: number,
|
idx: number,
|
||||||
) {
|
) {
|
||||||
let ret: any = {};
|
let ret: any = {};
|
||||||
if (story.ficmas != null) {
|
if (!story) {
|
||||||
|
ret.statusCode = 404;
|
||||||
|
ret.message = messages[404];
|
||||||
|
} else if (story.ficmas != null) {
|
||||||
if (isFicmasHidden(story)) {
|
if (isFicmasHidden(story)) {
|
||||||
ret = {
|
ret = {
|
||||||
statusCode: 423,
|
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.`,
|
message: `TOP SECRET! This story is part of an ongoing challenge. You'll be able to read it after the challenge's reveal date.`,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
} else if (
|
||||||
if (
|
|
||||||
story.chapters[idx]?.hidden &&
|
story.chapters[idx]?.hidden &&
|
||||||
event.context.currentUser?._id !== story.author._id &&
|
event.context.currentUser?._id !== story.author._id &&
|
||||||
!event.context.currentUser?.profile.isAdmin
|
!event.context.currentUser?.profile.isAdmin
|
||||||
|
Loading…
Reference in New Issue
Block a user