mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-11 22:17:14 +03:00
add user history to discord notification on segment reporting
This commit is contained in:
@@ -86,7 +86,11 @@ module.exports = async function voteOnSponsorTime(req, res) {
|
|||||||
// Send discord message
|
// Send discord message
|
||||||
if (type != 1) {
|
if (type != 1) {
|
||||||
// Get video ID
|
// Get video ID
|
||||||
let submissionInfoRow = db.prepare("SELECT videoID, userID, startTime, endTime FROM sponsorTimes WHERE UUID = ?").get(UUID);
|
let submissionInfoRow = db.prepare("SELECT s.videoID, s.userID, s.startTime, s.endTime, u.userName, "+
|
||||||
|
"(select count(1) from sponsorTimes where userID = s.userID) count, "+
|
||||||
|
"(select count(1) from sponsorTimes where userID = s.userID and votes <= -2) disregarded "+
|
||||||
|
"FROM sponsorTimes s inner join userNames u on s.userID = u.userID where s.UUID=?"
|
||||||
|
).get(UUID);
|
||||||
|
|
||||||
let userSubmissionCountRow = db.prepare("SELECT count(*) as submissionCount FROM sponsorTimes WHERE userID = ?").get(nonAnonUserID);
|
let userSubmissionCountRow = db.prepare("SELECT count(*) as submissionCount FROM sponsorTimes WHERE userID = ?").get(nonAnonUserID);
|
||||||
|
|
||||||
@@ -96,9 +100,11 @@ module.exports = async function voteOnSponsorTime(req, res) {
|
|||||||
id: submissionInfoRow.videoID
|
id: submissionInfoRow.videoID
|
||||||
}, function (err, data) {
|
}, function (err, data) {
|
||||||
if (err || data.items.length === 0) {
|
if (err || data.items.length === 0) {
|
||||||
|
console.log('pre-err');
|
||||||
err && console.log(err);
|
err && console.log(err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
console.log('presend' + submissionInfoRow.count);
|
||||||
|
|
||||||
request.post(config.discordReportChannelWebhookURL, {
|
request.post(config.discordReportChannelWebhookURL, {
|
||||||
json: {
|
json: {
|
||||||
@@ -107,12 +113,15 @@ module.exports = async function voteOnSponsorTime(req, res) {
|
|||||||
"url": "https://www.youtube.com/watch?v=" + submissionInfoRow.videoID +
|
"url": "https://www.youtube.com/watch?v=" + submissionInfoRow.videoID +
|
||||||
"&t=" + (submissionInfoRow.startTime.toFixed(0) - 2),
|
"&t=" + (submissionInfoRow.startTime.toFixed(0) - 2),
|
||||||
"description": "**" + row.votes + " Votes Prior | " + (row.votes + incrementAmount - oldIncrementAmount) + " Votes Now | " + row.views +
|
"description": "**" + row.votes + " Votes Prior | " + (row.votes + incrementAmount - oldIncrementAmount) + " Votes Now | " + row.views +
|
||||||
" Views**\n\nSubmission ID: " + UUID +
|
" Views**\n\n**Submission ID:** " + UUID
|
||||||
"\n\nSubmitted by: " + submissionInfoRow.userID + "\n\nTimestamp: " +
|
+ "\n\n**Submitted by:** "+submissionInfoRow.userName+"\n " + submissionInfoRow.userID
|
||||||
|
+ "\n\n**Total User Submissions:** "+submissionInfoRow.count
|
||||||
|
+ "\n**Disregarded User Submissions:** "+submissionInfoRow.disregarded
|
||||||
|
+"\n\n**Timestamp:** " +
|
||||||
getFormattedTime(submissionInfoRow.startTime) + " to " + getFormattedTime(submissionInfoRow.endTime),
|
getFormattedTime(submissionInfoRow.startTime) + " to " + getFormattedTime(submissionInfoRow.endTime),
|
||||||
"color": 10813440,
|
"color": 10813440,
|
||||||
"author": {
|
"author": {
|
||||||
"name": userSubmissionCountRow.submissionCount === 0 ? "Report by New User" : (vipRow.userCount !== 0 ? "Report by VIP User" : "")
|
"name": userSubmissionCountRow.submissionCount === 0 ? "Report by New User" : (vipRow.userCount !== 0 && "Report by VIP User")
|
||||||
},
|
},
|
||||||
"thumbnail": {
|
"thumbnail": {
|
||||||
"url": data.items[0].snippet.thumbnails.maxres ? data.items[0].snippet.thumbnails.maxres.url : "",
|
"url": data.items[0].snippet.thumbnails.maxres ? data.items[0].snippet.thumbnails.maxres.url : "",
|
||||||
@@ -167,5 +176,6 @@ module.exports = async function voteOnSponsorTime(req, res) {
|
|||||||
res.sendStatus(200);
|
res.sendStatus(200);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
|
res.status(400).json({error: 'Think of something to return'});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user