From 92b0f917d69662514e465369e6012ebff922bea8 Mon Sep 17 00:00:00 2001 From: James Robinson Date: Sat, 29 Aug 2020 22:01:13 -0500 Subject: [PATCH 01/15] fix username variable in setUsername --- src/routes/setUsername.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/routes/setUsername.js b/src/routes/setUsername.js index 989e712..e5b2865 100644 --- a/src/routes/setUsername.js +++ b/src/routes/setUsername.js @@ -12,7 +12,7 @@ module.exports = function setUsername(req, res) { let adminUserIDInput = req.query.adminUserID; - if (userID == undefined || userName == undefined || userID === "undefined" || username.length > 50) { + if (userID == undefined || userName == undefined || userID === "undefined" || userName.length > 50) { //invalid request res.sendStatus(400); return; From e46444f3b9aad0a2e989731fd2213cd54da6522d Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Sun, 30 Aug 2020 00:22:21 -0400 Subject: [PATCH 02/15] Added option to use new user counter --- src/app.js | 3 ++ src/middleware/userCounter.js | 11 ++++++ src/routes/getTotalStats.js | 68 +++++++++++++++++++++-------------- 3 files changed, 55 insertions(+), 27 deletions(-) create mode 100644 src/middleware/userCounter.js diff --git a/src/app.js b/src/app.js index 1ce1674..c70115d 100644 --- a/src/app.js +++ b/src/app.js @@ -6,6 +6,7 @@ var config = require('./config.js'); // Middleware var corsMiddleware = require('./middleware/cors.js'); var loggerMiddleware = require('./middleware/logger.js'); +const userCounter = require('./middleware/userCounter.js'); // Routes var getSkipSegments = require('./routes/getSkipSegments.js').endpoint; @@ -31,6 +32,8 @@ app.use(corsMiddleware); app.use(loggerMiddleware); app.use(express.json()) +if (config.userCounterURL) app.use(userCounter); + // Setup pretty JSON if (config.mode === "development") app.set('json spaces', 2); diff --git a/src/middleware/userCounter.js b/src/middleware/userCounter.js new file mode 100644 index 0000000..183e1b4 --- /dev/null +++ b/src/middleware/userCounter.js @@ -0,0 +1,11 @@ +var request = require('request'); + +var config = require('../config.js'); +var getIP = require('../utils/getIP.js'); +const getHash = require('../utils/getHash.js'); + +module.exports = function userCounter(req, res, next) { + request.post(config.userCounterURL + "/api/v1/addIP?hashedIP=" + getHash(getIP(req), 1)); + + next(); +} \ No newline at end of file diff --git a/src/routes/getTotalStats.js b/src/routes/getTotalStats.js index 43be0b1..ba521e3 100644 --- a/src/routes/getTotalStats.js +++ b/src/routes/getTotalStats.js @@ -1,11 +1,15 @@ -var db = require('../databases/databases.js').db; -var request = require('request'); +const db = require('../databases/databases.js').db; +const request = require('request'); +const config = require('../config.js'); // A cache of the number of chrome web store users -var chromeUsersCache = null; -var firefoxUsersCache = null; -var lastUserCountCheck = 0; +let chromeUsersCache = null; +let firefoxUsersCache = null; +// By the privacy friendly user counter +let apiUsersCache = null; + +let lastUserCountCheck = 0; module.exports = function getTotalStats (req, res) { let row = db.prepare('get', "SELECT COUNT(DISTINCT userID) as userCount, COUNT(*) as totalSubmissions, " + @@ -16,6 +20,7 @@ module.exports = function getTotalStats (req, res) { res.send({ userCount: row.userCount, activeUsers: chromeUsersCache + firefoxUsersCache, + apiUsers: apiUsersCache, viewCount: row.viewCount, totalSubmissions: row.totalSubmissions, minutesSaved: row.minutesSaved @@ -26,28 +31,37 @@ module.exports = function getTotalStats (req, res) { if (now - lastUserCountCheck > 5000000) { lastUserCountCheck = now; - // Get total users - request.get("https://addons.mozilla.org/api/v3/addons/addon/sponsorblock/", function (err, firefoxResponse, body) { - try { - firefoxUsersCache = parseInt(JSON.parse(body).average_daily_users); - - request.get("https://chrome.google.com/webstore/detail/sponsorblock-for-youtube/mnjggcdmjocbbbhaepdhchncahnbgone", function(err, chromeResponse, body) { - if (body !== undefined) { - try { - chromeUsersCache = parseInt(body.match(/(?<=\)/)[0].replace(",", "")); - } catch (error) { - // Re-check later - lastUserCountCheck = 0; - } - } else { - lastUserCountCheck = 0; - } - }); - } catch (error) { - // Re-check later - lastUserCountCheck = 0; - } - }); + updateExtensionUsers(); } } +} + +function updateExtensionUsers() { + if (config.userCounterURL) { + request.get(config.userCounterURL + "/api/v1/userCount", (err, response, body) => { + apiUsersCache = JSON.parse(body).userCount; + }); + } + + request.get("https://addons.mozilla.org/api/v3/addons/addon/sponsorblock/", function (err, firefoxResponse, body) { + try { + firefoxUsersCache = parseInt(JSON.parse(body).average_daily_users); + + request.get("https://chrome.google.com/webstore/detail/sponsorblock-for-youtube/mnjggcdmjocbbbhaepdhchncahnbgone", function(err, chromeResponse, body) { + if (body !== undefined) { + try { + chromeUsersCache = parseInt(body.match(/(?<=\)/)[0].replace(",", "")); + } catch (error) { + // Re-check later + lastUserCountCheck = 0; + } + } else { + lastUserCountCheck = 0; + } + }); + } catch (error) { + // Re-check later + lastUserCountCheck = 0; + } + }); } \ No newline at end of file From 89ee0afd619e3047082687175fe26d82ebe6e327 Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Sun, 30 Aug 2020 11:17:26 -0400 Subject: [PATCH 03/15] Only accept new user count if higher + add to example config --- config.json.example | 1 + src/routes/getTotalStats.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/config.json.example b/config.json.example index 22971d9..57fa901 100644 --- a/config.json.example +++ b/config.json.example @@ -8,6 +8,7 @@ "discordReportChannelWebhookURL": null, //URL from discord if you would like notifications when someone makes a report [optional] "discordFirstTimeSubmissionsWebhookURL": null, //URL from discord if you would like notifications when someone makes a first time submission [optional] "discordCompletelyIncorrectReportWebhookURL": null, //URL from discord if you would like notifications when someone reports a submission as completely incorrect [optional] + "userCounterURL": null, // For user counting. URL to instance of https://github.com/ajayyy/PrivacyUserCount "proxySubmission": null, // Base url to proxy submissions to persist // e.g. https://sponsor.ajay.app (no trailing slash) "behindProxy": "X-Forwarded-For", //Options: "X-Forwarded-For", "Cloudflare", "X-Real-IP", anything else will mean it is not behind a proxy. True defaults to "X-Forwarded-For" "db": "./databases/sponsorTimes.db", diff --git a/src/routes/getTotalStats.js b/src/routes/getTotalStats.js index ba521e3..103617a 100644 --- a/src/routes/getTotalStats.js +++ b/src/routes/getTotalStats.js @@ -39,7 +39,7 @@ module.exports = function getTotalStats (req, res) { function updateExtensionUsers() { if (config.userCounterURL) { request.get(config.userCounterURL + "/api/v1/userCount", (err, response, body) => { - apiUsersCache = JSON.parse(body).userCount; + apiUsersCache = Math.max(apiUsersCache, JSON.parse(body).userCount); }); } From 9ea98b2e2b74675b2b396fb4419816567e740b8a Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Sun, 30 Aug 2020 11:33:44 -0400 Subject: [PATCH 04/15] Fix all submissions being sent to first time submissions channel --- src/routes/postSkipSegments.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/routes/postSkipSegments.js b/src/routes/postSkipSegments.js index f007b6f..1af0721 100644 --- a/src/routes/postSkipSegments.js +++ b/src/routes/postSkipSegments.js @@ -63,7 +63,7 @@ function sendWebhooks(userID, videoID, UUID, segmentInfo) { // If it is a first time submission // Then send a notification to discord - if (config.discordFirstTimeSubmissionsWebhookURL === null) return; + if (config.discordFirstTimeSubmissionsWebhookURL === null || userSubmissionCountRow.submissionCount <= 1) return; request.post(config.discordFirstTimeSubmissionsWebhookURL, { json: { "embeds": [{ From 168229e6020b1519c1c1ca892c1d2015d3f6aa56 Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Sun, 30 Aug 2020 11:55:19 -0400 Subject: [PATCH 05/15] Fixed first time submissions webhook only sending for non first time submissions --- src/routes/postSkipSegments.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/routes/postSkipSegments.js b/src/routes/postSkipSegments.js index 1af0721..799711f 100644 --- a/src/routes/postSkipSegments.js +++ b/src/routes/postSkipSegments.js @@ -63,7 +63,7 @@ function sendWebhooks(userID, videoID, UUID, segmentInfo) { // If it is a first time submission // Then send a notification to discord - if (config.discordFirstTimeSubmissionsWebhookURL === null || userSubmissionCountRow.submissionCount <= 1) return; + if (config.discordFirstTimeSubmissionsWebhookURL === null || userSubmissionCountRow.submissionCount > 1) return; request.post(config.discordFirstTimeSubmissionsWebhookURL, { json: { "embeds": [{ From fd81096f6389622ec824d4638eb8d82c6d4a9db0 Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Mon, 31 Aug 2020 14:03:12 -0400 Subject: [PATCH 06/15] Allow all VIP to ban --- src/routes/shadowBanUser.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/routes/shadowBanUser.js b/src/routes/shadowBanUser.js index ba5052e..3617a94 100644 --- a/src/routes/shadowBanUser.js +++ b/src/routes/shadowBanUser.js @@ -1,5 +1,3 @@ -var config = require('../config.js'); - var databases = require('../databases/databases.js'); var db = databases.db; var privateDB = databases.privateDB; @@ -30,7 +28,8 @@ module.exports = async function shadowBanUser(req, res) { //hash the userID adminUserIDInput = getHash(adminUserIDInput); - if (adminUserIDInput !== config.adminUserID) { + let isVIP = db.prepare("get", "SELECT count(*) as userCount FROM vipUsers WHERE userID = ?", [adminUserIDInput]).userCount > 0; + if (!isVIP) { //not authorized res.sendStatus(403); return; From b0dc79d071e7d0417ceb74db9a687c4b89bd5b8d Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Mon, 31 Aug 2020 22:17:24 -0400 Subject: [PATCH 07/15] Send max of API users or extension users --- src/routes/getTotalStats.js | 38 +++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/src/routes/getTotalStats.js b/src/routes/getTotalStats.js index d2be079..6d3841e 100644 --- a/src/routes/getTotalStats.js +++ b/src/routes/getTotalStats.js @@ -12,28 +12,30 @@ let apiUsersCache = null; let lastUserCountCheck = 0; module.exports = function getTotalStats (req, res) { - let row = db.prepare('get', "SELECT COUNT(DISTINCT userID) as userCount, COUNT(*) as totalSubmissions, " + + let row = db.prepare('get', "SELECT COUNT(DISTINCT userID) as userCount, COUNT(*) as totalSubmissions, " + "SUM(views) as viewCount, SUM((endTime - startTime) / 60 * views) as minutesSaved FROM sponsorTimes WHERE shadowHidden != 1 AND votes >= 0", []); - if (row !== undefined) { - //send this result - res.send({ - userCount: row.userCount, - activeUsers: chromeUsersCache + firefoxUsersCache, - apiUsers: apiUsersCache, - viewCount: row.viewCount, - totalSubmissions: row.totalSubmissions, - minutesSaved: row.minutesSaved - }); + if (row !== undefined) { + let extensionUsers = chromeUsersCache + firefoxUsersCache; - // Check if the cache should be updated (every ~14 hours) - let now = Date.now(); - if (now - lastUserCountCheck > 5000000) { - lastUserCountCheck = now; + //send this result + res.send({ + userCount: row.userCount, + activeUsers: extensionUsers, + apiUsers: Math.max(apiUsersCache, extensionUsers), + viewCount: row.viewCount, + totalSubmissions: row.totalSubmissions, + minutesSaved: row.minutesSaved + }); - updateExtensionUsers(); - } - } + // Check if the cache should be updated (every ~14 hours) + let now = Date.now(); + if (now - lastUserCountCheck > 5000000) { + lastUserCountCheck = now; + + updateExtensionUsers(); + } + } } function updateExtensionUsers() { From a053d87bd2d43d2c45504375217e7505ecd24b42 Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Thu, 3 Sep 2020 12:04:49 -0400 Subject: [PATCH 08/15] Catch user counter errors --- src/middleware/userCounter.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/middleware/userCounter.js b/src/middleware/userCounter.js index 183e1b4..85be545 100644 --- a/src/middleware/userCounter.js +++ b/src/middleware/userCounter.js @@ -1,11 +1,16 @@ var request = require('request'); -var config = require('../config.js'); -var getIP = require('../utils/getIP.js'); +const config = require('../config.js'); +const getIP = require('../utils/getIP.js'); const getHash = require('../utils/getHash.js'); +const logger = require('../utils/logger.js'); module.exports = function userCounter(req, res, next) { - request.post(config.userCounterURL + "/api/v1/addIP?hashedIP=" + getHash(getIP(req), 1)); + try { + request.post(config.userCounterURL + "/api/v1/addIP?hashedIP=" + getHash(getIP(req), 1)); + } catch(e) { + logger.debug("Failing to connect to user counter at: " + config.userCounterURL); + } next(); } \ No newline at end of file From 9bcecae9a2291380907e06c73c95bb3628413264 Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Sun, 6 Sep 2020 13:35:14 -0400 Subject: [PATCH 09/15] Made report by submitter work for VIPs --- src/utils/webhookUtils.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/utils/webhookUtils.js b/src/utils/webhookUtils.js index 6da1d62..9b1e0e7 100644 --- a/src/utils/webhookUtils.js +++ b/src/utils/webhookUtils.js @@ -17,10 +17,10 @@ function getVoteAuthorRaw(submissionCount, isVIP, isOwnSubmission) { function getVoteAuthor(submissionCount, isVIP, isOwnSubmission) { if (submissionCount === 0) { return "Report by New User"; - } else if (isVIP) { - return "Report by VIP User"; } else if (isOwnSubmission) { return "Report by Submitter"; + } else if (isVIP) { + return "Report by VIP User"; } return ""; From cb386b7f8d07f0abcecac2ee4517cc7ea3b803e8 Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Mon, 7 Sep 2020 10:23:51 -0400 Subject: [PATCH 10/15] Don't fail when YouTube API fails --- src/routes/postSkipSegments.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/routes/postSkipSegments.js b/src/routes/postSkipSegments.js index 799711f..91ae71e 100644 --- a/src/routes/postSkipSegments.js +++ b/src/routes/postSkipSegments.js @@ -115,7 +115,7 @@ async function autoModerateSubmission(submission, callback) { }); if (err) { - return "Couldn't get video information."; + return false; } else { // Check to see if video exists if (data.pageInfo.totalResults === 0) { From dec0971c14e3308d786626a8355eb1b9e5a7e4b1 Mon Sep 17 00:00:00 2001 From: Nanobyte Date: Wed, 9 Sep 2020 16:40:13 +0200 Subject: [PATCH 11/15] Adding check to only allow a list of categories --- config.json.example | 3 ++- src/routes/postSkipSegments.js | 5 +++++ src/routes/voteOnSponsorTime.js | 5 +++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/config.json.example b/config.json.example index befb39e..337c317 100644 --- a/config.json.example +++ b/config.json.example @@ -19,5 +19,6 @@ "privateDBSchema": "./databases/_private.db.sql", "mode": "development", "readOnly": false, - "webhooks": [] + "webhooks": [], + "categoryList": ["sponsor", "intro", "outro", "interaction", "selfpromo", "music_offtopic"] // List of supported categories any other category will be rejected } diff --git a/src/routes/postSkipSegments.js b/src/routes/postSkipSegments.js index 91ae71e..40a1b5f 100644 --- a/src/routes/postSkipSegments.js +++ b/src/routes/postSkipSegments.js @@ -194,6 +194,11 @@ module.exports = async function postSkipSegments(req, res) { res.sendStatus(400); return; } + + if (!config.categoryList.includes(segments[i].category)) { + res.status("400").send("Category doesn't exist."); + return; + } let startTime = parseFloat(segments[i].segment[0]); let endTime = parseFloat(segments[i].segment[1]); diff --git a/src/routes/voteOnSponsorTime.js b/src/routes/voteOnSponsorTime.js index f3be68b..7fe4f18 100644 --- a/src/routes/voteOnSponsorTime.js +++ b/src/routes/voteOnSponsorTime.js @@ -150,6 +150,11 @@ function categoryVote(UUID, userID, isVIP, category, hashedIP, res) { res.status("400").send("Submission doesn't exist."); return; } + + if (!config.categoryList.includes(category)) { + res.status("400").send("Category doesn't exist."); + return; + } let timeSubmitted = Date.now(); From 6485fd0f88a061b4770804410cf3d73a490f7ff1 Mon Sep 17 00:00:00 2001 From: Nanobyte Date: Wed, 9 Sep 2020 18:57:47 +0200 Subject: [PATCH 12/15] Update test.json --- test.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test.json b/test.json index 503aa5d..0c67e5c 100644 --- a/test.json +++ b/test.json @@ -46,5 +46,6 @@ "vote.down" ] } - ] + ], + "categoryList": ["sponsor", "intro", "outro", "interaction", "selfpromo", "music_offtopic"] } From a068e194e9a6df9b998c23e551401ddce0878260 Mon Sep 17 00:00:00 2001 From: Joe Dowd Date: Wed, 9 Sep 2020 21:57:59 +0100 Subject: [PATCH 13/15] added test for change category --- test/cases/voteOnSponsorTime.js | 43 +++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/test/cases/voteOnSponsorTime.js b/test/cases/voteOnSponsorTime.js index bcbca78..615eefb 100644 --- a/test/cases/voteOnSponsorTime.js +++ b/test/cases/voteOnSponsorTime.js @@ -22,6 +22,8 @@ describe('voteOnSponsorTime', () => { db.exec(startOfQuery + "('voter-submitter2', 1, 11, 2, 'vote-uuid-11', '" + getHash("randomID4") + "', 0, 50, 'sponsor', 0)"); db.exec(startOfQuery + "('own-submission-video', 1, 11, 500, 'own-submission-uuid', '"+ getHash('own-submission-id') +"', 0, 50, 'sponsor', 0)"); db.exec(startOfQuery + "('not-own-submission-video', 1, 11, 500, 'not-own-submission-uuid', '"+ getHash('somebody-else-id') +"', 0, 50, 'sponsor', 0)"); + db.exec(startOfQuery + "('incorrect-category', 1, 11, 500, 'incorrect-category', '"+ getHash('somebody-else-id') +"', 0, 50, 'sponsor', 0)"); + db.exec(startOfQuery + "('incorrect-category-change', 1, 11, 500, 'incorrect-category-change', '"+ getHash('somebody-else-id') +"', 0, 50, 'sponsor', 0)"); db.exec("INSERT INTO vipUsers (userID) VALUES ('" + getHash("VIPUser") + "')"); privateDB.exec("INSERT INTO shadowBannedUsers (userID) VALUES ('" + getHash("randomID4") + "')"); @@ -207,6 +209,24 @@ describe('voteOnSponsorTime', () => { }); }); + it('Should not able to change to an invalid category', (done) => { + request.get(utils.getbaseURL() + + "/api/voteOnSponsorTime?userID=randomID2&UUID=incorrect-category&category=fakecategory", null, + (err, res, body) => { + if (err) done(err); + else if (res.statusCode === 400) { + let row = db.prepare('get', "SELECT category FROM sponsorTimes WHERE UUID = ?", ["incorrect-category"]); + if (row.category === "sponsor") { + done() + } else { + done("Vote did not succeed. Submission went from sponsor to " + row.category); + } + } else { + done("Status code was " + res.statusCode); + } + }); + }); + it('Should be able to change your vote for a category and it should immediately change (for now)', (done) => { request.get(utils.getbaseURL() + "/api/voteOnSponsorTime?userID=randomID2&UUID=vote-uuid-4&category=outro", null, @@ -225,6 +245,29 @@ describe('voteOnSponsorTime', () => { }); }); + + it('Should not be able to change your vote to an invalid category', (done) => { + const vote = (inputCat, assertCat, callback) => { + request.get(utils.getbaseURL() + + "/api/voteOnSponsorTime?userID=randomID2&UUID=incorrect-category-change&category="+inputCat, null, + (err) => { + if (err) done(err); + else{ + let row = db.prepare('get', "SELECT category FROM sponsorTimes WHERE UUID = ?", ["incorrect-category-change"]); + if (row.category === assertCat) { + callback(); + } else { + done("Vote did not succeed. Submission went from sponsor to " + row.category); + } + } + }); + }; + vote("sponsor", "sponsor", () => { + vote("fakeCategory", "sponsor", done); + }); + }); + + it('VIP should be able to vote for a category and it should immediately change', (done) => { request.get(utils.getbaseURL() + "/api/voteOnSponsorTime?userID=VIPUser&UUID=vote-uuid-5&category=outro", null, From 548061ff13a2ec388692af75eea62b14d1bc8221 Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Wed, 9 Sep 2020 21:32:47 -0400 Subject: [PATCH 14/15] Add error message for 400 errors --- src/routes/postSkipSegments.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/routes/postSkipSegments.js b/src/routes/postSkipSegments.js index 91ae71e..e219f71 100644 --- a/src/routes/postSkipSegments.js +++ b/src/routes/postSkipSegments.js @@ -177,7 +177,7 @@ module.exports = async function postSkipSegments(req, res) { //check if all correct inputs are here and the length is 1 second or more if (videoID == undefined || userID == undefined || segments == undefined || segments.length < 1) { //invalid request - res.sendStatus(400); + res.sendStatus(400).send("Parameters are not valid"); return; } @@ -191,7 +191,7 @@ module.exports = async function postSkipSegments(req, res) { for (let i = 0; i < segments.length; i++) { if (segments[i] === undefined || segments[i].segment === undefined || segments[i].category === undefined) { //invalid request - res.sendStatus(400); + res.sendStatus(400).send("One of your segments are invalid"); return; } @@ -201,7 +201,7 @@ module.exports = async function postSkipSegments(req, res) { if (isNaN(startTime) || isNaN(endTime) || startTime === Infinity || endTime === Infinity || startTime < 0 || startTime >= endTime) { //invalid request - res.sendStatus(400); + res.sendStatus(400).send("One of your segments times are invalid (too short, startTime before endTime, etc.)"); return; } From 4baf13f82c8eeb745ab3fc7dbd381fed35ac5aac Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Fri, 11 Sep 2020 16:35:12 -0400 Subject: [PATCH 15/15] Fix error messages in postSkipSegments --- src/routes/postSkipSegments.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/routes/postSkipSegments.js b/src/routes/postSkipSegments.js index e219f71..5132cd8 100644 --- a/src/routes/postSkipSegments.js +++ b/src/routes/postSkipSegments.js @@ -177,7 +177,7 @@ module.exports = async function postSkipSegments(req, res) { //check if all correct inputs are here and the length is 1 second or more if (videoID == undefined || userID == undefined || segments == undefined || segments.length < 1) { //invalid request - res.sendStatus(400).send("Parameters are not valid"); + res.status(400).send("Parameters are not valid"); return; } @@ -191,7 +191,7 @@ module.exports = async function postSkipSegments(req, res) { for (let i = 0; i < segments.length; i++) { if (segments[i] === undefined || segments[i].segment === undefined || segments[i].category === undefined) { //invalid request - res.sendStatus(400).send("One of your segments are invalid"); + res.status(400).send("One of your segments are invalid"); return; } @@ -201,7 +201,7 @@ module.exports = async function postSkipSegments(req, res) { if (isNaN(startTime) || isNaN(endTime) || startTime === Infinity || endTime === Infinity || startTime < 0 || startTime >= endTime) { //invalid request - res.sendStatus(400).send("One of your segments times are invalid (too short, startTime before endTime, etc.)"); + res.status(400).send("One of your segments times are invalid (too short, startTime before endTime, etc.)"); return; }