refactor(server/utils): add chapter index parameter to storyCheck function
				
					
				
			This commit is contained in:
		
							parent
							
								
									653d5c5f32
								
							
						
					
					
						commit
						22816477eb
					
				| @ -6,9 +6,9 @@ import { messages } from "../constants"; | |||||||
| export default async function ( | export default async function ( | ||||||
| 	event: H3Event<EventHandlerRequest>, | 	event: H3Event<EventHandlerRequest>, | ||||||
| 	story: IStory, | 	story: IStory, | ||||||
|  | 	idx: number, | ||||||
| ) { | ) { | ||||||
| 	let ret: any = {}; | 	let ret: any = {}; | ||||||
| 	let num: number = event.context.chapterIndex; |  | ||||||
| 	if (story.ficmas != null) { | 	if (story.ficmas != null) { | ||||||
| 		if (isFicmasHidden(story)) { | 		if (isFicmasHidden(story)) { | ||||||
| 			ret = { | 			ret = { | ||||||
| @ -18,9 +18,9 @@ export default async function ( | |||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 	if ( | 	if ( | ||||||
| 		story.chapters[num]?.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 | ||||||
| 	) { | 	) { | ||||||
| 		ret.statusCode = 403; | 		ret.statusCode = 403; | ||||||
| 		ret.message = messages[403]; | 		ret.message = messages[403]; | ||||||
|  | |||||||
| @ -2,7 +2,7 @@ import queryStory from "~/lib/server/dbHelpers/storyQuerier"; | |||||||
| import storyCheck from "~/lib/server/middlewareButNotReally/storyCheck"; | import storyCheck from "~/lib/server/middlewareButNotReally/storyCheck"; | ||||||
| export default eventHandler(async (ev) => { | export default eventHandler(async (ev) => { | ||||||
| 	const story = await queryStory(ev); | 	const story = await queryStory(ev); | ||||||
| 	let chrs = await storyCheck(ev, story); | 	let chrs = await storyCheck(ev, story, 0); | ||||||
| 	if (chrs != null) { | 	if (chrs != null) { | ||||||
| 		throw createError(chrs); | 		throw createError(chrs); | ||||||
| 	} | 	} | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user