mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-20 06:28:24 +03:00
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:
19
src/utils/isUserTempVIP.ts
Normal file
19
src/utils/isUserTempVIP.ts
Normal 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);
|
||||
};
|
||||
Reference in New Issue
Block a user