Add endpoints for rating endpoint (dislikes)

https://github.com/ajayyy/SponsorBlock/issues/1039
This commit is contained in:
Ajay Ramachandran
2021-11-14 23:09:12 -05:00
parent 7590047c6d
commit bc6db0d109
17 changed files with 415 additions and 14 deletions

View File

@@ -15,6 +15,6 @@ export function getIP(req: Request): IPAddress {
case "X-Real-IP":
return req.headers["x-real-ip"] as IPAddress;
default:
return req.connection.remoteAddress as IPAddress;
return (req.connection?.remoteAddress || req.socket?.remoteAddress) as IPAddress;
}
}

View File

@@ -16,3 +16,10 @@ export function skipSegmentsHashKey(hashedVideoIDPrefix: VideoIDHash, service: S
export function reputationKey(userID: UserID): string {
return `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}`;
}