|
@ -4,6 +4,12 @@ |
|
|
|
|
|
|
|
|
import { Request, Response, NextFunction, RequestHandler } from "express"; |
|
|
import { Request, Response, NextFunction, RequestHandler } from "express"; |
|
|
|
|
|
|
|
|
|
|
|
import { IBroadcastShow } from "../models/broadcast-show.js"; |
|
|
|
|
|
import { IEpisode } from "../models/episode.js"; |
|
|
|
|
|
|
|
|
|
|
|
import { BroadcastShowService } from "./broadcast-show.js"; |
|
|
|
|
|
import { EpisodeService } from "./episode.js"; |
|
|
|
|
|
|
|
|
import { DtpPlatform, DtpService } from "../../lib/dtplib.js"; |
|
|
import { DtpPlatform, DtpService } from "../../lib/dtplib.js"; |
|
|
|
|
|
|
|
|
export class SidebarService extends DtpService { |
|
|
export class SidebarService extends DtpService { |
|
@ -19,15 +25,30 @@ export class SidebarService extends DtpService { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
middleware(): RequestHandler { |
|
|
middleware(): RequestHandler { |
|
|
|
|
|
const showService = this.getService<BroadcastShowService>("broadcastShow"); |
|
|
|
|
|
const episodeService = this.getService<EpisodeService>("episode"); |
|
|
return async ( |
|
|
return async ( |
|
|
_req: Request, |
|
|
_req: Request, |
|
|
_res: Response, |
|
|
res: Response, |
|
|
next: NextFunction |
|
|
next: NextFunction |
|
|
): Promise<void> => { |
|
|
): Promise<void> => { |
|
|
|
|
|
res.locals.sidebar = res.locals.sidebar || {}; |
|
|
try { |
|
|
try { |
|
|
/* |
|
|
const showExclusions: Array<IBroadcastShow> = []; |
|
|
* Populate sidebar content here |
|
|
const episodeExclusions: Array<IEpisode> = []; |
|
|
*/ |
|
|
|
|
|
|
|
|
if (res.locals.show) { |
|
|
|
|
|
showExclusions.push(res.locals.show); |
|
|
|
|
|
} |
|
|
|
|
|
if (res.locals.episode) { |
|
|
|
|
|
episodeExclusions.push(res.locals.episode); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
res.locals.sidebar.recommendations = { |
|
|
|
|
|
shows: await showService.getRecommended(3, showExclusions), |
|
|
|
|
|
episodes: await episodeService.getRecommended(3, episodeExclusions), |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
return next(); |
|
|
return next(); |
|
|
} catch (error) { |
|
|
} catch (error) { |
|
|
this.log.error("Failed to populate sidebar content", { error }); |
|
|
this.log.error("Failed to populate sidebar content", { error }); |
|
|