mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-26 17:38:28 +03:00
Fix can vote checks
This commit is contained in:
@@ -56,8 +56,10 @@ export async function postBranding(req: Request, res: Response) {
|
|||||||
const hashedIP = await getHashCache(getIP(req) + config.globalSalt as IPAddress);
|
const hashedIP = await getHashCache(getIP(req) + config.globalSalt as IPAddress);
|
||||||
const isBanned = await checkBanStatus(hashedUserID, hashedIP);
|
const isBanned = await checkBanStatus(hashedUserID, hashedIP);
|
||||||
|
|
||||||
if (!await canVote(hashedUserID)) {
|
const permission = await canVote(hashedUserID);
|
||||||
res.status(200).send("OK");
|
if (!permission.canSubmit) {
|
||||||
|
res.status(403).send(permission.reason);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (videoDuration && thumbnail && await checkForWrongVideoDuration(videoID, videoDuration)) {
|
if (videoDuration && thumbnail && await checkForWrongVideoDuration(videoID, videoDuration)) {
|
||||||
|
|||||||
@@ -42,8 +42,10 @@ export async function postCasual(req: Request, res: Response) {
|
|||||||
const hashedIP = await getHashCache(getIP(req) + config.globalSalt as IPAddress);
|
const hashedIP = await getHashCache(getIP(req) + config.globalSalt as IPAddress);
|
||||||
const isBanned = await checkBanStatus(hashedUserID, hashedIP);
|
const isBanned = await checkBanStatus(hashedUserID, hashedIP);
|
||||||
|
|
||||||
if (!await canVote(hashedUserID)) {
|
const permission = await canVote(hashedUserID);
|
||||||
res.status(200).send("OK");
|
if (!permission.canSubmit) {
|
||||||
|
res.status(403).send(permission.reason);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const lock = await acquireLock(`postCasual:${videoID}.${hashedUserID}`);
|
const lock = await acquireLock(`postCasual:${videoID}.${hashedUserID}`);
|
||||||
|
|||||||
@@ -343,8 +343,12 @@ export async function vote(ip: IPAddress, UUID: SegmentUUID, paramUserID: UserID
|
|||||||
const nonAnonUserID = await getHashCache(paramUserID);
|
const nonAnonUserID = await getHashCache(paramUserID);
|
||||||
const userID = await getHashCache(paramUserID + UUID);
|
const userID = await getHashCache(paramUserID + UUID);
|
||||||
|
|
||||||
if (!await canVote(nonAnonUserID)) {
|
const permission = await canVote(nonAnonUserID);
|
||||||
return { status: 200 };
|
if (!permission.canSubmit) {
|
||||||
|
return {
|
||||||
|
status: 403,
|
||||||
|
message: permission.reason
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
//hash the ip 5000 times so no one can get it from the database
|
//hash the ip 5000 times so no one can get it from the database
|
||||||
|
|||||||
Reference in New Issue
Block a user