|
@ -12,6 +12,7 @@ import { WebController, WebError } from "../../../lib/dtplib.js"; |
|
|
import { ImageService } from "../../services/image.js"; |
|
|
import { ImageService } from "../../services/image.js"; |
|
|
import { UserService } from "../../services/user.js"; |
|
|
import { UserService } from "../../services/user.js"; |
|
|
import { BroadcastShowService } from "app/services/broadcast-show.js"; |
|
|
import { BroadcastShowService } from "app/services/broadcast-show.js"; |
|
|
|
|
|
import { EpisodeService } from "app/services/episode.js"; |
|
|
|
|
|
|
|
|
export function populateAccountByEmail( |
|
|
export function populateAccountByEmail( |
|
|
controller: WebController |
|
|
controller: WebController |
|
@ -94,6 +95,33 @@ export function populateBroadcastShow( |
|
|
}; |
|
|
}; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export function populateEpisode(controller: WebController): RequestHandler { |
|
|
|
|
|
const episodeService = controller.getService<EpisodeService>("episode"); |
|
|
|
|
|
return async function ( |
|
|
|
|
|
_req: Request, |
|
|
|
|
|
res: Response, |
|
|
|
|
|
next: NextFunction, |
|
|
|
|
|
episodeId?: string |
|
|
|
|
|
): Promise<void> { |
|
|
|
|
|
assert(episodeId, "Episode ID is required"); |
|
|
|
|
|
try { |
|
|
|
|
|
res.locals.show = await episodeService.getById( |
|
|
|
|
|
Types.ObjectId.createFromHexString(episodeId) |
|
|
|
|
|
); |
|
|
|
|
|
if (!res.locals.show) { |
|
|
|
|
|
throw new WebError(404, "Broadcast show not found"); |
|
|
|
|
|
} |
|
|
|
|
|
return next(); |
|
|
|
|
|
} catch (error) { |
|
|
|
|
|
controller.log.error("failed to populate episode ID", { |
|
|
|
|
|
episodeId, |
|
|
|
|
|
error, |
|
|
|
|
|
}); |
|
|
|
|
|
return next(error); |
|
|
|
|
|
} |
|
|
|
|
|
}; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
export function populateImageId(controller: WebController): RequestHandler { |
|
|
export function populateImageId(controller: WebController): RequestHandler { |
|
|
const imageService = |
|
|
const imageService = |
|
|
controller.platform.components.getService<ImageService>("image"); |
|
|
controller.platform.components.getService<ImageService>("image"); |
|
|