mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2024-11-10 09:07:47 +01:00
Added new shadowHidden variable that only lets it get sent out to submitters.
This commit is contained in:
parent
4ceb7f3b47
commit
49af7dd65d
3 changed files with 28 additions and 6 deletions
|
@ -1,4 +1,7 @@
|
||||||
BEGIN TRANSACTION;
|
BEGIN TRANSACTION;
|
||||||
|
CREATE TABLE IF NOT EXISTS "shadowBannedUsers" (
|
||||||
|
"userID" TEXT NOT NULL
|
||||||
|
);
|
||||||
CREATE TABLE IF NOT EXISTS "votes" (
|
CREATE TABLE IF NOT EXISTS "votes" (
|
||||||
"UUID" TEXT NOT NULL,
|
"UUID" TEXT NOT NULL,
|
||||||
"userID" INTEGER NOT NULL,
|
"userID" INTEGER NOT NULL,
|
||||||
|
|
|
@ -1,8 +1,4 @@
|
||||||
BEGIN TRANSACTION;
|
BEGIN TRANSACTION;
|
||||||
CREATE TABLE IF NOT EXISTS "userNames" (
|
|
||||||
"userID" TEXT NOT NULL,
|
|
||||||
"userName" TEXT NOT NULL
|
|
||||||
);
|
|
||||||
CREATE TABLE IF NOT EXISTS "sponsorTimes" (
|
CREATE TABLE IF NOT EXISTS "sponsorTimes" (
|
||||||
"videoID" TEXT NOT NULL,
|
"videoID" TEXT NOT NULL,
|
||||||
"startTime" REAL NOT NULL,
|
"startTime" REAL NOT NULL,
|
||||||
|
@ -11,6 +7,11 @@ CREATE TABLE IF NOT EXISTS "sponsorTimes" (
|
||||||
"UUID" TEXT NOT NULL UNIQUE,
|
"UUID" TEXT NOT NULL UNIQUE,
|
||||||
"userID" TEXT NOT NULL,
|
"userID" TEXT NOT NULL,
|
||||||
"timeSubmitted" INTEGER NOT NULL,
|
"timeSubmitted" INTEGER NOT NULL,
|
||||||
"views" INTEGER NOT NULL
|
"views" INTEGER NOT NULL,
|
||||||
|
"shadowHidden" INTEGER NOT NULL
|
||||||
|
);
|
||||||
|
CREATE TABLE IF NOT EXISTS "userNames" (
|
||||||
|
"userID" TEXT NOT NULL,
|
||||||
|
"userName" TEXT NOT NULL
|
||||||
);
|
);
|
||||||
COMMIT;
|
COMMIT;
|
||||||
|
|
20
index.js
20
index.js
|
@ -37,7 +37,9 @@ app.get('/api/getVideoSponsorTimes', function (req, res) {
|
||||||
let votes = []
|
let votes = []
|
||||||
let UUIDs = [];
|
let UUIDs = [];
|
||||||
|
|
||||||
db.prepare("SELECT startTime, endTime, votes, UUID FROM sponsorTimes WHERE videoID = ? ORDER BY startTime").all(videoID, function(err, rows) {
|
let hashedIP = getHash(getIP(req) + globalSalt);
|
||||||
|
|
||||||
|
db.prepare("SELECT startTime, endTime, votes, UUID, shadowHidden FROM sponsorTimes WHERE videoID = ? ORDER BY startTime").all(videoID, async function(err, rows) {
|
||||||
if (err) console.log(err);
|
if (err) console.log(err);
|
||||||
|
|
||||||
for (let i = 0; i < rows.length; i++) {
|
for (let i = 0; i < rows.length; i++) {
|
||||||
|
@ -46,6 +48,22 @@ app.get('/api/getVideoSponsorTimes', function (req, res) {
|
||||||
//too untrustworthy, just ignore it
|
//too untrustworthy, just ignore it
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//check if shadowHidden
|
||||||
|
//this means it is hidden to everyone but the original ip that submitted it
|
||||||
|
if (rows[i].shadowHidden == 1) {
|
||||||
|
//get the ip
|
||||||
|
//await the callback
|
||||||
|
let result = await new Promise((resolve, reject) => {
|
||||||
|
privateDB.prepare("SELECT hashedIP FROM sponsorTimes WHERE videoID = ?").all(videoID, (err, rows) => resolve({err, rows}));
|
||||||
|
});
|
||||||
|
|
||||||
|
if (result.rows.length == 0 || !result.rows.includes({hashedIP})) {
|
||||||
|
//this isn't their ip, don't send it to them
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
sponsorTimes.push([]);
|
sponsorTimes.push([]);
|
||||||
|
|
||||||
let index = sponsorTimes.length - 1;
|
let index = sponsorTimes.length - 1;
|
||||||
|
|
Loading…
Reference in a new issue