mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-10 13:37:01 +03:00
Added new shadowHidden variable that only lets it get sent out to submitters.
This commit is contained in:
20
index.js
20
index.js
@@ -37,7 +37,9 @@ app.get('/api/getVideoSponsorTimes', function (req, res) {
|
||||
let votes = []
|
||||
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);
|
||||
|
||||
for (let i = 0; i < rows.length; i++) {
|
||||
@@ -46,6 +48,22 @@ app.get('/api/getVideoSponsorTimes', function (req, res) {
|
||||
//too untrustworthy, just ignore it
|
||||
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([]);
|
||||
|
||||
let index = sponsorTimes.length - 1;
|
||||
|
||||
Reference in New Issue
Block a user