mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-07 03:57:06 +03:00
Merge branch 'master' of https://github.com/ajayyy/SponsorBlockServer into test-helpers
This commit is contained in:
@@ -26,7 +26,7 @@ export async function getVideoBranding(res: Response, videoID: VideoID, service:
|
|||||||
"all",
|
"all",
|
||||||
`SELECT "titles"."title", "titles"."original", "titleVotes"."votes", "titleVotes"."locked", "titleVotes"."shadowHidden", "titles"."UUID", "titles"."videoID", "titles"."hashedVideoID", "titleVotes"."verification", "titles"."userID"
|
`SELECT "titles"."title", "titles"."original", "titleVotes"."votes", "titleVotes"."locked", "titleVotes"."shadowHidden", "titles"."UUID", "titles"."videoID", "titles"."hashedVideoID", "titleVotes"."verification", "titles"."userID"
|
||||||
FROM "titles" JOIN "titleVotes" ON "titles"."UUID" = "titleVotes"."UUID"
|
FROM "titles" JOIN "titleVotes" ON "titles"."UUID" = "titleVotes"."UUID"
|
||||||
WHERE "titles"."videoID" = ? AND "titles"."service" = ? AND "titleVotes"."votes" > -2`,
|
WHERE "titles"."videoID" = ? AND "titles"."service" = ? AND "titleVotes"."votes" > -1`,
|
||||||
[videoID, service],
|
[videoID, service],
|
||||||
{ useReplica: true }
|
{ useReplica: true }
|
||||||
) as Promise<TitleDBResult[]>;
|
) as Promise<TitleDBResult[]>;
|
||||||
@@ -35,7 +35,8 @@ export async function getVideoBranding(res: Response, videoID: VideoID, service:
|
|||||||
"all",
|
"all",
|
||||||
`SELECT "thumbnailTimestamps"."timestamp", "thumbnails"."original", "thumbnailVotes"."votes", "thumbnailVotes"."locked", "thumbnailVotes"."shadowHidden", "thumbnails"."UUID", "thumbnails"."videoID", "thumbnails"."hashedVideoID", "thumbnails"."userID"
|
`SELECT "thumbnailTimestamps"."timestamp", "thumbnails"."original", "thumbnailVotes"."votes", "thumbnailVotes"."locked", "thumbnailVotes"."shadowHidden", "thumbnails"."UUID", "thumbnails"."videoID", "thumbnails"."hashedVideoID", "thumbnails"."userID"
|
||||||
FROM "thumbnails" LEFT JOIN "thumbnailVotes" ON "thumbnails"."UUID" = "thumbnailVotes"."UUID" LEFT JOIN "thumbnailTimestamps" ON "thumbnails"."UUID" = "thumbnailTimestamps"."UUID"
|
FROM "thumbnails" LEFT JOIN "thumbnailVotes" ON "thumbnails"."UUID" = "thumbnailVotes"."UUID" LEFT JOIN "thumbnailTimestamps" ON "thumbnails"."UUID" = "thumbnailTimestamps"."UUID"
|
||||||
WHERE "thumbnails"."videoID" = ? AND "thumbnails"."service" = ? AND "thumbnailVotes"."votes" > -2`,
|
WHERE "thumbnails"."videoID" = ? AND "thumbnails"."service" = ? AND "thumbnailVotes"."votes" > -2
|
||||||
|
ORDER BY "thumbnails"."timeSubmitted" ASC`,
|
||||||
[videoID, service],
|
[videoID, service],
|
||||||
{ useReplica: true }
|
{ useReplica: true }
|
||||||
) as Promise<ThumbnailDBResult[]>;
|
) as Promise<ThumbnailDBResult[]>;
|
||||||
@@ -99,7 +100,8 @@ export async function getVideoBrandingByHash(videoHashPrefix: VideoIDHash, servi
|
|||||||
"all",
|
"all",
|
||||||
`SELECT "thumbnailTimestamps"."timestamp", "thumbnails"."original", "thumbnailVotes"."votes", "thumbnailVotes"."locked", "thumbnailVotes"."shadowHidden", "thumbnails"."UUID", "thumbnails"."videoID", "thumbnails"."hashedVideoID"
|
`SELECT "thumbnailTimestamps"."timestamp", "thumbnails"."original", "thumbnailVotes"."votes", "thumbnailVotes"."locked", "thumbnailVotes"."shadowHidden", "thumbnails"."UUID", "thumbnails"."videoID", "thumbnails"."hashedVideoID"
|
||||||
FROM "thumbnails" LEFT JOIN "thumbnailVotes" ON "thumbnails"."UUID" = "thumbnailVotes"."UUID" LEFT JOIN "thumbnailTimestamps" ON "thumbnails"."UUID" = "thumbnailTimestamps"."UUID"
|
FROM "thumbnails" LEFT JOIN "thumbnailVotes" ON "thumbnails"."UUID" = "thumbnailVotes"."UUID" LEFT JOIN "thumbnailTimestamps" ON "thumbnails"."UUID" = "thumbnailTimestamps"."UUID"
|
||||||
WHERE "thumbnails"."hashedVideoID" LIKE ? AND "thumbnails"."service" = ? AND "thumbnailVotes"."votes" > -2`,
|
WHERE "thumbnails"."hashedVideoID" LIKE ? AND "thumbnails"."service" = ? AND "thumbnailVotes"."votes" > -2
|
||||||
|
ORDER BY "thumbnails"."timeSubmitted" ASC`,
|
||||||
[`${videoHashPrefix}%`, service],
|
[`${videoHashPrefix}%`, service],
|
||||||
{ useReplica: true }
|
{ useReplica: true }
|
||||||
) as Promise<ThumbnailDBResult[]>;
|
) as Promise<ThumbnailDBResult[]>;
|
||||||
@@ -182,7 +184,7 @@ async function filterAndSortBranding(videoID: VideoID, returnUserID: boolean, db
|
|||||||
.sort((a, b) => b.votes - a.votes)
|
.sort((a, b) => b.votes - a.votes)
|
||||||
.sort((a, b) => +b.locked - +a.locked) as TitleResult[];
|
.sort((a, b) => +b.locked - +a.locked) as TitleResult[];
|
||||||
|
|
||||||
const thumbnails = shuffleArray(dbThumbnails.filter(await shouldKeepThumbnails))
|
const thumbnails = dbThumbnails.filter(await shouldKeepThumbnails)
|
||||||
.sort((a, b) => +a.original - +b.original)
|
.sort((a, b) => +a.original - +b.original)
|
||||||
.sort((a, b) => b.votes - a.votes)
|
.sort((a, b) => b.votes - a.votes)
|
||||||
.sort((a, b) => b.locked - a.locked)
|
.sort((a, b) => b.locked - a.locked)
|
||||||
|
|||||||
@@ -179,7 +179,7 @@ async function checkUserActiveWarning(userID: HashedUserID): Promise<CheckResult
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
pass: false,
|
pass: false,
|
||||||
errorMessage: defaultMessage + (warnings[0]?.reason?.length > 0 ? `\n\nWarning reason: '${warnings[0].reason}'` : ""),
|
errorMessage: defaultMessage + (warnings[0]?.reason?.length > 0 ? `\n\nTip message: '${warnings[0].reason}'` : ""),
|
||||||
errorCode: 403
|
errorCode: 403
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ export async function postWarning(req: Request, res: Response): Promise<Response
|
|||||||
"run", 'UPDATE "warnings" SET "enabled" = 1, "reason" = ? WHERE "userID" = ? AND "issueTime" = ?',
|
"run", 'UPDATE "warnings" SET "enabled" = 1, "reason" = ? WHERE "userID" = ? AND "issueTime" = ?',
|
||||||
[reason, userID, previousWarning.issueTime]
|
[reason, userID, previousWarning.issueTime]
|
||||||
);
|
);
|
||||||
resultStatus = "re-enabled";
|
resultStatus = "re-enabled for";
|
||||||
} else {
|
} else {
|
||||||
return res.sendStatus(409);
|
return res.sendStatus(409);
|
||||||
}
|
}
|
||||||
@@ -93,7 +93,7 @@ export async function postWarning(req: Request, res: Response): Promise<Response
|
|||||||
}
|
}
|
||||||
|
|
||||||
return res.status(200).json({
|
return res.status(200).json({
|
||||||
message: `Warning ${resultStatus} user '${userID}'.`,
|
message: `Tip ${resultStatus} user '${userID}'.`,
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
Logger.error(e as string);
|
Logger.error(e as string);
|
||||||
|
|||||||
@@ -384,7 +384,7 @@ export async function vote(ip: IPAddress, UUID: SegmentUUID, paramUserID: UserID
|
|||||||
lock.unlock();
|
lock.unlock();
|
||||||
return { status: 403, message: "Vote rejected due to a tip from a moderator. This means that we noticed you were making some common mistakes that are not malicious, and we just want to clarify the rules. " +
|
return { status: 403, message: "Vote rejected due to a tip from a moderator. This means that we noticed you were making some common mistakes that are not malicious, and we just want to clarify the rules. " +
|
||||||
"Could you please send a message in Discord or Matrix so we can further help you?" +
|
"Could you please send a message in Discord or Matrix so we can further help you?" +
|
||||||
`${(warningReason.length > 0 ? ` Warning reason: '${warningReason}'` : "")}` };
|
`${(warningReason.length > 0 ? ` Tip message: '${warningReason}'` : "")}` };
|
||||||
}
|
}
|
||||||
|
|
||||||
// we can return out of the function early if the user is banned after warning checks
|
// we can return out of the function early if the user is banned after warning checks
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ describe("postSkipSegments Warnings", () => {
|
|||||||
const expected = "Submission rejected due to a tip from a moderator. This means that we noticed you were making some common mistakes"
|
const expected = "Submission rejected due to a tip from a moderator. This means that we noticed you were making some common mistakes"
|
||||||
+ " that are not malicious, and we just want to clarify the rules. "
|
+ " that are not malicious, and we just want to clarify the rules. "
|
||||||
+ "Could you please send a message in discord.gg/SponsorBlock or matrix.to/#/#sponsor:ajay.app so we can further help you? "
|
+ "Could you please send a message in discord.gg/SponsorBlock or matrix.to/#/#sponsor:ajay.app so we can further help you? "
|
||||||
+ `Your userID is ${warnUser01Hash}.\n\nWarning reason: '${reason}'`;
|
+ `Your userID is ${warnUser01Hash}.\n\nTip message: '${reason}'`;
|
||||||
|
|
||||||
assert.strictEqual(errorMessage, expected);
|
assert.strictEqual(errorMessage, expected);
|
||||||
done();
|
done();
|
||||||
|
|||||||
Reference in New Issue
Block a user