From 2bbae8c5f5c17c65d40c85145eedf1551aec9e88 Mon Sep 17 00:00:00 2001 From: Blade Barringer Date: Fri, 8 Apr 2016 17:14:14 -0500 Subject: [PATCH] refactor: Simplify flag_report_email load --- config.json.example | 2 +- website/src/controllers/api-v2/groups.js | 14 +++----------- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/config.json.example b/config.json.example index 0e27196638..6aeb8ac74a 100644 --- a/config.json.example +++ b/config.json.example @@ -29,7 +29,7 @@ "MWS_KEY": "", "MWS_SECRET": "" }, - "FLAG_REPORT_EMAIL": ["email@mod.com"], + "FLAG_REPORT_EMAIL": "email@mod.com,email2@mod.com", "EMAIL_SERVER": { "url": "http://example.com", "authUser": "user", diff --git a/website/src/controllers/api-v2/groups.js b/website/src/controllers/api-v2/groups.js index 75b4226872..e117aa40ad 100644 --- a/website/src/controllers/api-v2/groups.js +++ b/website/src/controllers/api-v2/groups.js @@ -31,6 +31,8 @@ var partyFields = api.partyFields = 'profile preferences stats achievements part var nameFields = 'profile.name'; var challengeFields = '_id name'; var guildPopulate = {path: 'members', select: nameFields, options: {limit: 15} }; +const FLAG_REPORT_EMAILS = nconf.get('FLAG_REPORT_EMAIL').split(',').map(email => {return {email, canSend: true}}); + /** * For parties, we want a lot of member details so we can show their avatars in the header. For guilds, we want very * limited fields - and only a sampling of the members, beacuse they can be in the thousands @@ -366,18 +368,8 @@ api.flagChatMessage = function(req, res, next){ 'chat.$.flagCount': message.flagCount, }}, function(err) { if (err) return next(err); - var addressesToSendTo = nconf.get('FLAG_REPORT_EMAIL'); - addressesToSendTo = (typeof addressesToSendTo == 'string') ? JSON.parse(addressesToSendTo) : addressesToSendTo; - if(Array.isArray(addressesToSendTo)){ - addressesToSendTo = addressesToSendTo.map(function(email){ - return {email: email, canSend: true} - }); - }else{ - addressesToSendTo = {email: addressesToSendTo} - } - - utils.txnEmail(addressesToSendTo, 'flag-report-to-mods', [ + utils.txnEmail(FLAG_REPORT_EMAILS, 'flag-report-to-mods', [ {name: "MESSAGE_TIME", content: (new Date(message.timestamp)).toString()}, {name: "MESSAGE_TEXT", content: message.text},