Don't crash if failed to get ip from db

This commit is contained in:
Ajay Ramachandran
2021-08-31 12:10:23 -04:00
parent d99ffdabd7
commit 9849fba97a

View File

@@ -31,14 +31,14 @@ async function prepareCategorySegments(req: Request, videoID: VideoID, category:
}
//if this isn't their ip, don't send it to them
return cache.shadowHiddenSegmentIPs[videoID][segment.timeSubmitted].some((shadowHiddenSegment) => {
return cache.shadowHiddenSegmentIPs[videoID][segment.timeSubmitted]?.some((shadowHiddenSegment) => {
if (cache.userHashedIP === undefined) {
//hash the IP only if it's strictly necessary
cache.userHashedIP = getHash((getIP(req) + config.globalSalt) as IPAddress);
}
return shadowHiddenSegment.hashedIP === cache.userHashedIP;
});
}) ?? false;
}));
const filteredSegments = segments.filter((_, index) => shouldFilter[index]);