Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/routes/getVideoLabel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import { ActionType, Category, DBSegment, Service, VideoID, VideoIDHash } from "../types/segments.model";
import { Logger } from "../utils/logger";
import { QueryCacher } from "../utils/queryCacher";
import { getEtag } from "../middleware/etag";
import { getService } from "../utils/getService";

interface FullVideoSegment {
Expand Down Expand Up @@ -122,7 +123,7 @@
return {
segments: transformDBSegments(choices),
hasStartSegment
}

Check warning on line 126 in src/routes/getVideoLabel.ts

View workflow job for this annotation

GitHub Actions / Lint with ESLint and build

Missing semicolon
}
// if locked, only choose from locked
const locked = choices.filter((segment) => segment.locked);
Expand Down Expand Up @@ -166,6 +167,10 @@
return false;
}

await getEtag("videoLabel", (videoID as string), service)
.then(etag => res.set("ETag", etag))
.catch(() => null);

if (hasStartSegment) {
return segmentData;
} else {
Expand Down
7 changes: 7 additions & 0 deletions src/routes/getVideoLabelByHash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { hashPrefixTester } from "../utils/hashPrefixTester";
import { getLabelsByHash } from "./getVideoLabel";
import { Request, Response } from "express";
import { VideoIDHash, Service } from "../types/segments.model";
import { getEtag } from "../middleware/etag";
import { getService } from "../utils/getService";

export async function getVideoLabelsByHash(req: Request, res: Response): Promise<Response> {
Expand All @@ -25,5 +26,11 @@ export async function getVideoLabelsByHash(req: Request, res: Response): Promise
segments: data.segments,
hasStartSegment: data.hasStartSegment
}));


const hashKey = hashPrefix.length === 4 ? "videoLabelHash" : "videoLabelsLargerHash";
await getEtag(hashKey, hashPrefix, service)
.then(etag => res.set("ETag", etag))
.catch(() => null);
return res.status(output.length === 0 ? 404 : 200).json(output);
}
Loading