mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-08 12:37:00 +03:00
@@ -5,6 +5,7 @@ const db = databases.db;
|
||||
const privateDB = databases.privateDB;
|
||||
const YouTubeAPI = require('../utils/youtubeAPI.js');
|
||||
const logger = require('../utils/logger.js');
|
||||
const getSubmissionUUID = require('../utils/getSubmissionUUID.js');
|
||||
const request = require('request');
|
||||
const isoDurations = require('iso8601-duration');
|
||||
const fetch = require('node-fetch');
|
||||
@@ -201,8 +202,7 @@ async function autoModerateSubmission(submission) {
|
||||
startTime = parseFloat(segments[i].segment[0]);
|
||||
endTime = parseFloat(segments[i].segment[1]);
|
||||
|
||||
let UUID = getHash("v2-categories" + submission.videoID + startTime +
|
||||
endTime + segments[i].category + submission.userID, 1);
|
||||
const UUID = getSubmissionUUID(submission.videoID, segments[i].category, submission.userID, startTime, endTime);
|
||||
// Send to Discord
|
||||
// Note, if this is too spammy. Consider sending all the segments as one Webhook
|
||||
sendWebhooksNB(submission.userID, submission.videoID, UUID, startTime, endTime, segments[i].category, nbPredictions.probabilities[predictionIdx], data);
|
||||
@@ -400,8 +400,7 @@ module.exports = async function postSkipSegments(req, res) {
|
||||
//this can just be a hash of the data
|
||||
//it's better than generating an actual UUID like what was used before
|
||||
//also better for duplication checking
|
||||
let UUID = getHash("v2-categories" + videoID + segmentInfo.segment[0] +
|
||||
segmentInfo.segment[1] + segmentInfo.category + userID, 1);
|
||||
const UUID = getSubmissionUUID(videoID, segmentInfo.category, userID, segmentInfo.segment[0], segmentInfo.segment[1]);
|
||||
|
||||
try {
|
||||
db.prepare('run', "INSERT INTO sponsorTimes " +
|
||||
|
||||
7
src/utils/getSubmissionUUID.js
Normal file
7
src/utils/getSubmissionUUID.js
Normal file
@@ -0,0 +1,7 @@
|
||||
const getHash = require('./getHash.js');
|
||||
|
||||
module.exports = function getSubmissionUUID(videoID, category, userID,
|
||||
startTime, endTime) {
|
||||
return getHash('v2-categories' + videoID + startTime + endTime + category +
|
||||
userID, 1);
|
||||
};
|
||||
8
test/cases/getSubmissionUUID.js
Normal file
8
test/cases/getSubmissionUUID.js
Normal file
@@ -0,0 +1,8 @@
|
||||
const getSubmissionUUID = require('../../src/utils/getSubmissionUUID.js');
|
||||
const assert = require('assert');
|
||||
|
||||
describe('getSubmissionUUID', () => {
|
||||
it('Should return the hashed value', () => {
|
||||
assert.equal(getSubmissionUUID('video001', 'sponsor', 'testuser001', 13.33337, 42.000001), '1d33d7016aa6482849019bd906d75c08fe6b815e64e823146df35f66c35612dd');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user