From 652ce10e2246a7b7a9e699f9aa005999b40f69b4 Mon Sep 17 00:00:00 2001 From: Matteo Pagliazzi Date: Mon, 22 Dec 2014 19:48:03 +0100 Subject: [PATCH] feat(flag-chat): start implemnting email --- config.json.example | 1 + src/controllers/groups.js | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/config.json.example b/config.json.example index 74e2f0822c..e34d187838 100644 --- a/config.json.example +++ b/config.json.example @@ -21,6 +21,7 @@ "NEW_RELIC_APPLICATION_ID":"NEW_RELIC_APPLICATION_ID", "NEW_RELIC_API_KEY":"NEW_RELIC_API_KEY", "GA_ID": "GA_ID", + "FLAG_REPORT_EMAIL": "email@mod.com", "EMAIL_SERVER": { "url": "http://example.com", "authUser": "user", diff --git a/src/controllers/groups.js b/src/controllers/groups.js index 49ef84771f..9cc4d7119d 100644 --- a/src/controllers/groups.js +++ b/src/controllers/groups.js @@ -7,10 +7,12 @@ function clone(a) { var _ = require('lodash'); var nconf = require('nconf'); var async = require('async'); +var utils = require('./../utils'); var shared = require('habitrpg-shared'); var User = require('./../models/user').model; var Group = require('./../models/group').model; var Challenge = require('./../models/challenge').model; +var isProd = nconf.get('NODE_ENV') === 'production'; var api = module.exports; /* @@ -281,6 +283,27 @@ api.flagChatMessage = function(req, res, next){ group.markModified('chat'); group.save(function(err,_saved){ if(err) return next(err); + if (isProd){ + utils.txnEmail({email: nconf.get('FLAG_REPORT_EMAIL')}, 'flag-report-to-mods', [ + {name: "MESSAGE_TIME", content: message.timestamp}, + {name: "MESSAGE_TEXT", content: message.text}, + + {name: "REPORTER_USERNAME", content: null}, + {name: "REPORTER_UUID", content: null}, + {name: "REPORTER_EMAIL", content: null}, + {name: "REPORTER_MODAL_URL", content: null}, + + {name: "AUTHOR_USERNAME", content: null}, + {name: "AUTHOR_UUID", content: null}, + {name: "AUTHOR_EMAIL", content: null}, + {name: "AUTHOR_MODAL_URL", content: null}, + + {name: "GROUP_NAME", content: null}, + {name: "GROUP_TYPE", content: null}, + {name: "GROUP_ID", content: null}, + {name: "GROUP_URL", content: null}, + ]); + } return res.send(204); }); }