refactor {group,inbox}-chatReporter variables

This commit is contained in:
negue
2018-12-06 23:55:18 +01:00
parent b912a83f22
commit 1c17b415f0
3 changed files with 75 additions and 33 deletions

View File

@@ -6,7 +6,7 @@ import {
BadRequest,
NotFound,
} from '../errors';
import { getGroupUrl, sendTxn } from '../email';
import { sendTxn } from '../email';
import slack from '../slack';
import { model as Group } from '../../models/group';
import { chatModel as Chat } from '../../models/message';
@@ -50,16 +50,12 @@ export default class GroupChatReporter extends ChatReporter {
}
async notify (group, message, userComment, automatedComment = '') {
await super.notify(group, message);
const groupUrl = getGroupUrl(group);
sendTxn(FLAG_REPORT_EMAILS, 'flag-report-to-mods-with-comments', this.emailVariables.concat([
{name: 'GROUP_NAME', content: group.name},
{name: 'GROUP_TYPE', content: group.type},
{name: 'GROUP_ID', content: group._id},
{name: 'GROUP_URL', content: groupUrl},
let emailVariables = await this.getMessageVariables(group, message);
emailVariables = emailVariables.concat([
{name: 'REPORTER_COMMENT', content: userComment || ''},
]));
]);
sendTxn(FLAG_REPORT_EMAILS, 'flag-report-to-mods-with-comments', emailVariables);
slack.sendFlagNotification({
authorEmail: this.authorEmail,