add 80% tempVIP

- move isUserTempVIP to own file
- reduce allSegmentDuration instead of forEach
- don't return decreaseVotes from autoModerator
- completely skip autoModCheck if VIP
This commit is contained in:
Michael C
2022-03-31 16:43:10 -04:00
parent 76cc603a3f
commit d02d78f325
3 changed files with 43 additions and 37 deletions

View File

@@ -0,0 +1,19 @@
import redis from "../utils/redis";
import { tempVIPKey } from "../utils/redisKeys";
import { HashedUserID } from "../types/user.model";
import { YouTubeAPI } from "../utils/youtubeApi";
import { APIVideoInfo } from "../types/youtubeApi.model";
import { VideoID } from "../types/segments.model";
import { config } from "../config";
function getYouTubeVideoInfo(videoID: VideoID, ignoreCache = false): Promise<APIVideoInfo> {
return config.newLeafURLs ? YouTubeAPI.listVideos(videoID, ignoreCache) : null;
}
export const isUserTempVIP = async (hashedUserID: HashedUserID, videoID: VideoID): Promise<boolean> => {
const apiVideoInfo = await getYouTubeVideoInfo(videoID);
const channelID = apiVideoInfo?.data?.authorId;
const { err, reply } = await redis.getAsync(tempVIPKey(hashedUserID));
return err || !reply ? false : (reply == channelID);
};