Add option to trim UUIDs in skip segments endpoint

This commit is contained in:
Ajay
2025-01-18 02:09:46 -05:00
parent 06f83cd8d4
commit be9d97ae2b
3 changed files with 7 additions and 4 deletions

View File

@@ -150,7 +150,7 @@ async function getSegmentsByVideoID(req: Request, videoID: VideoID, categories:
}
async function getSegmentsByHash(req: Request, hashedVideoIDPrefix: VideoIDHash, categories: Category[],
actionTypes: ActionType[], requiredSegments: SegmentUUID[], service: Service): Promise<SBRecord<VideoID, VideoData>> {
actionTypes: ActionType[], trimUUIDs: number, requiredSegments: SegmentUUID[], service: Service): Promise<SBRecord<VideoID, VideoData>> {
const cache: SegmentCache = { shadowHiddenSegmentIPs: {} };
const segments: SBRecord<VideoID, VideoData> = {};
@@ -188,7 +188,7 @@ async function getSegmentsByHash(req: Request, hashedVideoIDPrefix: VideoIDHash,
category: segment.category,
actionType: segment.actionType,
segment: segment.segment,
UUID: segment.UUID,
UUID: trimUUIDs ? segment.UUID.substring(0, trimUUIDs) as SegmentUUID : segment.UUID,
videoDuration: segment.videoDuration,
locked: segment.locked,
votes: segment.votes,

View File

@@ -17,10 +17,10 @@ export async function getSkipSegmentsByHash(req: Request, res: Response): Promis
if (parseResult.errors.length > 0) {
return res.status(400).send(parseResult.errors);
}
const { categories, actionTypes, requiredSegments, service } = parseResult;
const { categories, actionTypes, trimUUIDs, requiredSegments, service } = parseResult;
// Get all video id's that match hash prefix
const segments = await getSegmentsByHash(req, hashPrefix, categories, actionTypes, requiredSegments, service);
const segments = await getSegmentsByHash(req, hashPrefix, categories, actionTypes, trimUUIDs, requiredSegments, service);
try {
await getEtag("skipSegmentsHash", hashPrefix, service)