Skip to content

Commit

Permalink
Added UUID to the report - old logic, idk how or when it got removed.
Browse files Browse the repository at this point in the history
  • Loading branch information
409H committed Jul 2, 2019
1 parent c32b6d8 commit 2807628
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
9 changes: 7 additions & 2 deletions src/routes/v1/postReport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,24 @@ 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 &&
req.body &&
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({
Expand All @@ -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({
Expand Down

0 comments on commit 2807628

Please sign in to comment.