mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-25 17:08:35 +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 isBanned = await checkBanStatus(hashedUserID, hashedIP);
|
||||
|
||||
if (!await canVote(hashedUserID)) {
|
||||
res.status(200).send("OK");
|
||||
const permission = await canVote(hashedUserID);
|
||||
if (!permission.canSubmit) {
|
||||
res.status(403).send(permission.reason);
|
||||
return;
|
||||
}
|
||||
|
||||
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 isBanned = await checkBanStatus(hashedUserID, hashedIP);
|
||||
|
||||
if (!await canVote(hashedUserID)) {
|
||||
res.status(200).send("OK");
|
||||
const permission = await canVote(hashedUserID);
|
||||
if (!permission.canSubmit) {
|
||||
res.status(403).send(permission.reason);
|
||||
return;
|
||||
}
|
||||
|
||||
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 userID = await getHashCache(paramUserID + UUID);
|
||||
|
||||
if (!await canVote(nonAnonUserID)) {
|
||||
return { status: 200 };
|
||||
const permission = await canVote(nonAnonUserID);
|
||||
if (!permission.canSubmit) {
|
||||
return {
|
||||
status: 403,
|
||||
message: permission.reason
|
||||
};
|
||||
}
|
||||
|
||||
//hash the ip 5000 times so no one can get it from the database
|
||||
|
||||
Reference in New Issue
Block a user