mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2024-11-10 01:02:30 +01:00
Add server-side ads check for dearrow submissions
This commit is contained in:
parent
ec1e6d63a4
commit
ee9ed6af1f
1 changed files with 12 additions and 1 deletions
|
@ -36,7 +36,7 @@ interface ExistingVote {
|
|||
}
|
||||
|
||||
export async function postBranding(req: Request, res: Response) {
|
||||
const { videoID, userID, title, thumbnail, autoLock, downvote } = req.body as BrandingSubmission;
|
||||
const { videoID, userID, title, thumbnail, autoLock, downvote, videoDuration } = req.body as BrandingSubmission;
|
||||
const service = getService(req.body.service);
|
||||
|
||||
if (!videoID || !userID || userID.length < 30 || !service
|
||||
|
@ -55,6 +55,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 (videoDuration && await checkForWrongVideoDuration(videoID, videoDuration)) {
|
||||
res.status(403).send("YouTube is currently testing a new anti-adblock technique called server-side ad-injection. This causes skips and submissions to be offset by the duration of the ad. It seems that you are affected by this A/B test, so until a fix is developed, we cannot accept submissions from your device due to them potentially being inaccurate.");
|
||||
}
|
||||
|
||||
const lock = await acquireLock(`postBranding:${videoID}.${hashedUserID}`);
|
||||
if (!lock.status) {
|
||||
res.status(429).send("Vote already in progress");
|
||||
|
@ -325,4 +329,11 @@ async function sendWebhooks(videoID: VideoID, UUID: BrandingUUID) {
|
|||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function checkForWrongVideoDuration(videoID: VideoID, duration: number): Promise<boolean> {
|
||||
const apiVideoDetails = await getVideoDetails(videoID, true);
|
||||
const apiDuration = apiVideoDetails?.duration;
|
||||
|
||||
return apiDuration && apiDuration > 2 && duration && duration > 2 && Math.abs(apiDuration - duration) > 3;
|
||||
}
|
Loading…
Reference in a new issue