mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-06 11:36:58 +03:00
36 lines
1.5 KiB
TypeScript
36 lines
1.5 KiB
TypeScript
import { Service, VideoID, VideoIDHash } from "../types/segments.model";
|
|
import { HashedUserID, UserID } from "../types/user.model";
|
|
import { HashedValue } from "../types/hash.model";
|
|
import { Logger } from "./logger";
|
|
|
|
export const skipSegmentsKey = (videoID: VideoID, service: Service): string =>
|
|
`segments.v3.${service}.videoID.${videoID}`;
|
|
|
|
export const skipSegmentGroupsKey = (videoID: VideoID, service: Service): string =>
|
|
`segments.groups.v2.${service}.videoID.${videoID}`;
|
|
|
|
export function skipSegmentsHashKey(hashedVideoIDPrefix: VideoIDHash, service: Service): string {
|
|
hashedVideoIDPrefix = hashedVideoIDPrefix.substring(0, 4) as VideoIDHash;
|
|
if (hashedVideoIDPrefix.length !== 4) Logger.warn(`Redis skip segment hash-prefix key is not length 4! ${hashedVideoIDPrefix}`);
|
|
|
|
return `segments.v3.${service}.${hashedVideoIDPrefix}`;
|
|
}
|
|
|
|
export const reputationKey = (userID: UserID): string =>
|
|
`reputation.user.${userID}`;
|
|
|
|
export function ratingHashKey(hashPrefix: VideoIDHash, service: Service): string {
|
|
hashPrefix = hashPrefix.substring(0, 4) as VideoIDHash;
|
|
if (hashPrefix.length !== 4) Logger.warn(`Redis rating hash-prefix key is not length 4! ${hashPrefix}`);
|
|
|
|
return `rating.${service}.${hashPrefix}`;
|
|
}
|
|
|
|
export function shaHashKey(singleIter: HashedValue): string {
|
|
if (singleIter.length !== 64) Logger.warn(`Redis sha.hash key is not length 64! ${singleIter}`);
|
|
|
|
return `sha.hash.${singleIter}`;
|
|
}
|
|
|
|
export const tempVIPKey = (userID: HashedUserID): string =>
|
|
`vip.temp.${userID}`; |