Fix can vote checks

This commit is contained in:
Ajay
2025-04-07 00:57:08 -04:00
parent 550339db41
commit b7794b57d0
3 changed files with 14 additions and 6 deletions

View File

@@ -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)) {

View File

@@ -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}`);

View File

@@ -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