Merge branch 'master' into voteOnSponsorTime

This commit is contained in:
Ajay Ramachandran
2022-02-10 23:00:51 -05:00
committed by GitHub
11 changed files with 108 additions and 44 deletions

View File

@@ -56,15 +56,11 @@ function getYouTubeVideoInfo(videoID: VideoID, ignoreCache = false): Promise<API
}
const isUserTempVIP = async (nonAnonUserID: HashedUserID, videoID: VideoID): Promise<boolean> => {
// fetch videoInfo from cache
const apiVideoInfo = await getYouTubeVideoInfo(videoID);
// get channelID or fallback to invalid channelID (<> are invalid URL characters and & is not a valid ChannelID character)
const channelID = apiVideoInfo?.data?.authorId ?? "<INVALID_CHANNEL_ID_&&&&&>";
const channelID = apiVideoInfo?.data?.authorId;
const { err, reply } = await redis.getAsync(tempVIPKey(nonAnonUserID));
// return false if error, reply mismatch or reply is not length 21 and not in testing mode
return err ? false :
(config.mode === "test") ? reply == channelID
: (reply?.length === 21 && reply == channelID);
return err || !reply ? false : (reply == channelID);
};
const videoDurationChanged = (segmentDuration: number, APIDuration: number) => (APIDuration > 0 && Math.abs(segmentDuration - APIDuration) > 2);