From 28076284519aaa2ec1bec662c40db7dde14e73a2 Mon Sep 17 00:00:00 2001 From: 409H <409H@users.noreply.github.com> Date: Tue, 2 Jul 2019 17:30:33 +0100 Subject: [PATCH] Added UUID to the report - old logic, idk how or when it got removed. --- package-lock.json | 2 +- package.json | 1 + src/routes/v1/postReport.ts | 9 +++++++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index c7f5a39..2852066 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7993,7 +7993,7 @@ }, "utf8": { "version": "2.1.1", - "resolved": "https://registry.npmjs.org/utf8/-/utf8-2.1.1.tgz", + "resolved": "http://registry.npmjs.org/utf8/-/utf8-2.1.1.tgz", "integrity": "sha1-LgHbAvfY0JRPdxBPFgnrDDBM92g=" } } diff --git a/package.json b/package.json index 089936c..a358802 100644 --- a/package.json +++ b/package.json @@ -71,6 +71,7 @@ "request": "2.88.0", "sqlite3": "^4.0.4", "typescript": "3.1.6", + "uuid": "^3.3.2", "web3": "1.0.0-beta.36", "web3-utils": "^1.0.0-beta.55" }, diff --git a/src/routes/v1/postReport.ts b/src/routes/v1/postReport.ts index 2071f7d..99dc9e1 100644 --- a/src/routes/v1/postReport.ts +++ b/src/routes/v1/postReport.ts @@ -2,8 +2,10 @@ import config from '../../utils/config'; import * as captcha from '../../utils/gcaptcha'; import * as slack from '../../utils/slack'; import { Request, Response } from 'express'; +const uuidv1 = require('uuid/v1'); export default async (req: Request, res: Response) => { + const strReportId = uuidv1(); if ( config.apiKeys.Google_Captcha && config.apiKeys.Slack_Webhook && @@ -11,11 +13,13 @@ export default async (req: Request, res: Response) => { req.body.args && req.body.args.captcha ) { + req.body.args.report_id = strReportId; const isValidCaptcha = await captcha.verifyResponse(req.body.args.captcha); if (isValidCaptcha) { slack.sendReport(req.body); res.json({ - success: true + success: true, + report_id: strReportId }); } else { res.json({ @@ -26,7 +30,8 @@ export default async (req: Request, res: Response) => { } else if (config.apiKeys.Slack_Webhook && req.body && req.body.args && req.body.args.captcha) { slack.sendReport(req.body); res.json({ - success: true + success: true, + report_id: strReportId }); } else { res.json({