[next] Comment Moderation Actions (#2068)

* fix: renamed snake case to camel case

* fix: changed case for mutators

* fix: renamed all snake case to camel case for db

* feat: added support for comment revisions + split comment actions

* fix: updated tests

* feat: implemented CommentModerationAction

* fix: fixed case issues

* feat: enabled WeakMap for wordList processsing

* chore: npm audit
This commit is contained in:
Wyatt Johnson
2018-11-21 17:42:47 +01:00
committed by Kiwi
parent 13147c4ba4
commit 21e1a5cbef
66 changed files with 2323 additions and 2224 deletions
+23 -78
View File
@@ -55,8 +55,8 @@ const createJobProcessor = (options: MailProcessorOptions) => {
if (err) {
logger.error(
{
job_id: job.id,
job_name: JOB_NAME,
jobID: job.id,
jobName: JOB_NAME,
err,
},
"job data did not match expected schema"
@@ -67,52 +67,32 @@ const createJobProcessor = (options: MailProcessorOptions) => {
// Pull the data out of the validated model.
const { message, tenantID } = value;
const log = logger.child({
jobID: job.id,
jobName: JOB_NAME,
tenantID,
});
// Get the referenced tenant so we know who to send it from.
const tenant = await tenantCache.retrieveByID(tenantID);
if (!tenant) {
logger.error(
{
job_id: job.id,
job_name: JOB_NAME,
tenant_id: tenantID,
},
"referenced tenant was not found"
);
log.error("referenced tenant was not found");
return;
}
if (!tenant.email.enabled) {
logger.error(
{
job_id: job.id,
job_name: JOB_NAME,
tenant_id: tenantID,
},
"not sending email, it was disabled"
);
log.error("not sending email, it was disabled");
return;
}
if (!tenant.email.smtpURI) {
logger.error(
{
job_id: job.id,
job_name: JOB_NAME,
tenant_id: tenantID,
},
"email was enabled but the smtpURI configuration was missing"
);
log.error("email was enabled but the smtpURI configuration was missing");
return;
}
if (!tenant.email.fromAddress) {
// TODO: possibly have fallback email address?
logger.error(
{
job_id: job.id,
job_name: JOB_NAME,
tenant_id: tenantID,
},
log.error(
"email was enabled but the fromAddress configuration was missing"
);
return;
@@ -126,33 +106,12 @@ const createJobProcessor = (options: MailProcessorOptions) => {
// Set the transport back into the cache.
cache.set(tenantID, transport);
logger.debug(
{
job_id: job.id,
job_name: JOB_NAME,
tenant_id: tenantID,
},
"transport was not cached"
);
log.debug("transport was not cached");
} else {
logger.debug(
{
job_id: job.id,
job_name: JOB_NAME,
tenant_id: tenantID,
},
"transport was cached"
);
log.debug("transport was cached");
}
logger.debug(
{
job_id: job.id,
job_name: JOB_NAME,
tenant_id: tenantID,
},
"starting to send the email"
);
log.debug("starting to send the email");
// Send the mail message.
await transport.sendMail({
@@ -162,14 +121,7 @@ const createJobProcessor = (options: MailProcessorOptions) => {
from: tenant.email.fromAddress,
});
logger.debug(
{
job_id: job.id,
job_name: JOB_NAME,
tenant_id: tenantID,
},
"sent the email"
);
log.debug("sent the email");
};
};
@@ -203,29 +155,22 @@ export class Mailer {
public async add({ template, ...rest }: MailerInput) {
const { tenantID } = rest;
const log = logger.child({
jobName: JOB_NAME,
tenantID,
});
// All email templates require the tenant in order to insert the footer, so
// load it from the tenant cache here.
const tenant = await this.tenantCache.retrieveByID(tenantID);
if (!tenant) {
logger.error(
{
job_name: JOB_NAME,
tenant_id: tenantID,
},
"referenced tenant was not found"
);
log.error("referenced tenant was not found");
// TODO: (wyattjoh) maybe throw an error here?
return;
}
if (!tenant.email.enabled) {
logger.error(
{
job_name: JOB_NAME,
tenant_id: tenantID,
},
"not adding email, it was disabled"
);
log.error("not adding email, it was disabled");
// TODO: (wyattjoh) maybe throw an error here?
return;
}