add user history to discord notification on segment reporting

This commit is contained in:
Joe-Dowd
2020-04-28 05:04:51 +01:00
parent fd397de6b4
commit cfa80be4c7

View File

@@ -86,7 +86,11 @@ module.exports = async function voteOnSponsorTime(req, res) {
// Send discord message
if (type != 1) {
// 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);
@@ -96,9 +100,11 @@ module.exports = async function voteOnSponsorTime(req, res) {
id: submissionInfoRow.videoID
}, function (err, data) {
if (err || data.items.length === 0) {
console.log('pre-err');
err && console.log(err);
return;
}
console.log('presend' + submissionInfoRow.count);
request.post(config.discordReportChannelWebhookURL, {
json: {
@@ -107,12 +113,15 @@ module.exports = async function voteOnSponsorTime(req, res) {
"url": "https://www.youtube.com/watch?v=" + submissionInfoRow.videoID +
"&t=" + (submissionInfoRow.startTime.toFixed(0) - 2),
"description": "**" + row.votes + " Votes Prior | " + (row.votes + incrementAmount - oldIncrementAmount) + " Votes Now | " + row.views +
" Views**\n\nSubmission ID: " + UUID +
"\n\nSubmitted by: " + submissionInfoRow.userID + "\n\nTimestamp: " +
" Views**\n\n**Submission ID:** " + UUID
+ "\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),
"color": 10813440,
"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": {
"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);
} catch (err) {
console.error(err);
res.status(400).json({error: 'Think of something to return'});
}
}