Skip to content

Commit 68bb39c

Browse files
committed
Merge branch 'master' of https://github.com/ajayyy/SponsorBlockServer into test-helpers
2 parents 3c6803f + 9dd8b28 commit 68bb39c

File tree

5 files changed

+11
-9
lines changed

5 files changed

+11
-9
lines changed

src/routes/getBranding.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export async function getVideoBranding(res: Response, videoID: VideoID, service:
2626
"all",
2727
`SELECT "titles"."title", "titles"."original", "titleVotes"."votes", "titleVotes"."locked", "titleVotes"."shadowHidden", "titles"."UUID", "titles"."videoID", "titles"."hashedVideoID", "titleVotes"."verification", "titles"."userID"
2828
FROM "titles" JOIN "titleVotes" ON "titles"."UUID" = "titleVotes"."UUID"
29-
WHERE "titles"."videoID" = ? AND "titles"."service" = ? AND "titleVotes"."votes" > -2`,
29+
WHERE "titles"."videoID" = ? AND "titles"."service" = ? AND "titleVotes"."votes" > -1`,
3030
[videoID, service],
3131
{ useReplica: true }
3232
) as Promise<TitleDBResult[]>;
@@ -35,7 +35,8 @@ export async function getVideoBranding(res: Response, videoID: VideoID, service:
3535
"all",
3636
`SELECT "thumbnailTimestamps"."timestamp", "thumbnails"."original", "thumbnailVotes"."votes", "thumbnailVotes"."locked", "thumbnailVotes"."shadowHidden", "thumbnails"."UUID", "thumbnails"."videoID", "thumbnails"."hashedVideoID", "thumbnails"."userID"
3737
FROM "thumbnails" LEFT JOIN "thumbnailVotes" ON "thumbnails"."UUID" = "thumbnailVotes"."UUID" LEFT JOIN "thumbnailTimestamps" ON "thumbnails"."UUID" = "thumbnailTimestamps"."UUID"
38-
WHERE "thumbnails"."videoID" = ? AND "thumbnails"."service" = ? AND "thumbnailVotes"."votes" > -2`,
38+
WHERE "thumbnails"."videoID" = ? AND "thumbnails"."service" = ? AND "thumbnailVotes"."votes" > -2
39+
ORDER BY "thumbnails"."timeSubmitted" ASC`,
3940
[videoID, service],
4041
{ useReplica: true }
4142
) as Promise<ThumbnailDBResult[]>;
@@ -99,7 +100,8 @@ export async function getVideoBrandingByHash(videoHashPrefix: VideoIDHash, servi
99100
"all",
100101
`SELECT "thumbnailTimestamps"."timestamp", "thumbnails"."original", "thumbnailVotes"."votes", "thumbnailVotes"."locked", "thumbnailVotes"."shadowHidden", "thumbnails"."UUID", "thumbnails"."videoID", "thumbnails"."hashedVideoID"
101102
FROM "thumbnails" LEFT JOIN "thumbnailVotes" ON "thumbnails"."UUID" = "thumbnailVotes"."UUID" LEFT JOIN "thumbnailTimestamps" ON "thumbnails"."UUID" = "thumbnailTimestamps"."UUID"
102-
WHERE "thumbnails"."hashedVideoID" LIKE ? AND "thumbnails"."service" = ? AND "thumbnailVotes"."votes" > -2`,
103+
WHERE "thumbnails"."hashedVideoID" LIKE ? AND "thumbnails"."service" = ? AND "thumbnailVotes"."votes" > -2
104+
ORDER BY "thumbnails"."timeSubmitted" ASC`,
103105
[`${videoHashPrefix}%`, service],
104106
{ useReplica: true }
105107
) as Promise<ThumbnailDBResult[]>;
@@ -182,7 +184,7 @@ async function filterAndSortBranding(videoID: VideoID, returnUserID: boolean, db
182184
.sort((a, b) => b.votes - a.votes)
183185
.sort((a, b) => +b.locked - +a.locked) as TitleResult[];
184186

185-
const thumbnails = shuffleArray(dbThumbnails.filter(await shouldKeepThumbnails))
187+
const thumbnails = dbThumbnails.filter(await shouldKeepThumbnails)
186188
.sort((a, b) => +a.original - +b.original)
187189
.sort((a, b) => b.votes - a.votes)
188190
.sort((a, b) => b.locked - a.locked)

src/routes/postSkipSegments.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ async function checkUserActiveWarning(userID: HashedUserID): Promise<CheckResult
179179

180180
return {
181181
pass: false,
182-
errorMessage: defaultMessage + (warnings[0]?.reason?.length > 0 ? `\n\nWarning reason: '${warnings[0].reason}'` : ""),
182+
errorMessage: defaultMessage + (warnings[0]?.reason?.length > 0 ? `\n\nTip message: '${warnings[0].reason}'` : ""),
183183
errorCode: 403
184184
};
185185
}

src/routes/postWarning.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export async function postWarning(req: Request, res: Response): Promise<Response
6262
"run", 'UPDATE "warnings" SET "enabled" = 1, "reason" = ? WHERE "userID" = ? AND "issueTime" = ?',
6363
[reason, userID, previousWarning.issueTime]
6464
);
65-
resultStatus = "re-enabled";
65+
resultStatus = "re-enabled for";
6666
} else {
6767
return res.sendStatus(409);
6868
}
@@ -93,7 +93,7 @@ export async function postWarning(req: Request, res: Response): Promise<Response
9393
}
9494

9595
return res.status(200).json({
96-
message: `Warning ${resultStatus} user '${userID}'.`,
96+
message: `Tip ${resultStatus} user '${userID}'.`,
9797
});
9898
} catch (e) {
9999
Logger.error(e as string);

src/routes/voteOnSponsorTime.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ export async function vote(ip: IPAddress, UUID: SegmentUUID, paramUserID: UserID
384384
lock.unlock();
385385
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. " +
386386
"Could you please send a message in Discord or Matrix so we can further help you?" +
387-
`${(warningReason.length > 0 ? ` Warning reason: '${warningReason}'` : "")}` };
387+
`${(warningReason.length > 0 ? ` Tip message: '${warningReason}'` : "")}` };
388388
}
389389

390390
// we can return out of the function early if the user is banned after warning checks

test/cases/postSkipSegmentsWarnings.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ describe("postSkipSegments Warnings", () => {
6363
const expected = "Submission rejected due to a tip from a moderator. This means that we noticed you were making some common mistakes"
6464
+ " that are not malicious, and we just want to clarify the rules. "
6565
+ "Could you please send a message in discord.gg/SponsorBlock or matrix.to/#/#sponsor:ajay.app so we can further help you? "
66-
+ `Your userID is ${warnUser01Hash}.\n\nWarning reason: '${reason}'`;
66+
+ `Your userID is ${warnUser01Hash}.\n\nTip message: '${reason}'`;
6767

6868
assert.strictEqual(errorMessage, expected);
6969
done();

0 commit comments

Comments
 (0)