[CORL-498, CORL-495, CORL-539, CORL-496, CORL-494] Email Notifications Support & Framework (#2498)

* chore: renamed old templates

* feat: initial notifications support

* feat: email enhancements

* fix: linting

* feat: initial digesting beheviour

* feat: added notification configuration

* feat: added unsubscribe routes

* fix: fixed failing snapshots/tests bc random ids

* feat: adjusted the save beheviour, added tests

* feat: added tests

* feat: added staff replies

* feat: renamed E-Mail to Email

* feat: enhanced cron processing

* fix: linting + updating tests

* feat: enhanced cron context

* fix: added staff replies back in
This commit is contained in:
Wyatt Johnson
2019-09-05 07:02:26 +00:00
committed by GitHub
parent 0fad1070a6
commit efea0e8e1c
111 changed files with 3439 additions and 382 deletions
+12 -5
View File
@@ -2,15 +2,15 @@ import Queue from "bull";
import { Db } from "mongodb";
import { Config } from "coral-server/config";
import { createMailerTask, MailerQueue } from "coral-server/queue/tasks/mailer";
import {
createScraperTask,
ScraperQueue,
} from "coral-server/queue/tasks/scraper";
import { I18n } from "coral-server/services/i18n";
import { JWTSigningConfig } from "coral-server/services/jwt";
import { createRedisClient } from "coral-server/services/redis";
import TenantCache from "coral-server/services/tenant/cache";
import { createMailerTask, MailerQueue } from "./tasks/mailer";
import { createNotifierTask, NotifierQueue } from "./tasks/notifier";
import { createScraperTask, ScraperQueue } from "./tasks/scraper";
const createQueueOptions = async (
config: Config
): Promise<Queue.QueueOptions> => {
@@ -46,11 +46,13 @@ export interface QueueOptions {
config: Config;
tenantCache: TenantCache;
i18n: I18n;
signingConfig: JWTSigningConfig;
}
export interface TaskQueue {
mailer: MailerQueue;
scraper: ScraperQueue;
notifier: NotifierQueue;
}
export async function createQueue(options: QueueOptions): Promise<TaskQueue> {
@@ -61,10 +63,15 @@ export async function createQueue(options: QueueOptions): Promise<TaskQueue> {
// Attach process functions to the various tasks in the queue.
const mailer = createMailerTask(queueOptions, options);
const scraper = createScraperTask(queueOptions, options);
const notifier = createNotifierTask(queueOptions, {
mailerQueue: mailer,
...options,
});
// Return the tasks + client.
return {
mailer,
scraper,
notifier,
};
}