send email when admin unflags post (#7580)

* send email when admin unflags post

* Improved email acquisition code, minor changes to sent email

* Refactor getGoupUrl into its own method

* added unit test for getGroupUrl

* improved test and getGroupUrl
This commit is contained in:
Shervin Sarain
2016-06-08 05:22:33 +02:00
committed by Blade Barringer
parent 00491670e0
commit 8490b481f6
3 changed files with 65 additions and 25 deletions

View File

@@ -1,5 +1,6 @@
import { createTransport } from 'nodemailer';
import nconf from 'nconf';
import { TAVERN_ID } from '../../models/group';
import { encrypt } from './encryption';
import request from 'request';
import logger from './logger';
@@ -64,6 +65,19 @@ export function getUserInfo (user, fields = []) {
return info;
}
export function getGroupUrl (group) {
let groupUrl;
if (group._id === TAVERN_ID) {
groupUrl = '/#/options/groups/tavern';
} else if (group.type === 'guild') {
groupUrl = `/#/options/groups/guilds/${group._id}`;
} else if (group.type === 'party') {
groupUrl = 'party';
}
return groupUrl;
}
// Send a transactional email using Mandrill through the external email server
export function sendTxn (mailingInfoArray, emailType, variables, personalVariables) {
mailingInfoArray = Array.isArray(mailingInfoArray) ? mailingInfoArray : [mailingInfoArray];