Files
talk/src/core/server/cron/index.ts
T
Wyatt JohnsonandGitHub efea0e8e1c [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
2019-09-05 07:02:26 +00:00

41 lines
1.2 KiB
TypeScript

import { Db } from "mongodb";
import { Config } from "coral-server/config";
import { MailerQueue } from "coral-server/queue/tasks/mailer";
import { JWTSigningConfig } from "coral-server/services/jwt";
import TenantCache from "coral-server/services/tenant/cache";
import { registerAccountDeletion } from "./accountDeletion";
import { registerNotificationDigesting } from "./notificationDigesting";
export interface ScheduledJobGroups {
accountDeletion: ReturnType<typeof registerAccountDeletion>;
notificationDigesting: ReturnType<typeof registerNotificationDigesting>;
}
interface Options {
mongo: Db;
config: Config;
mailerQueue: MailerQueue;
signingConfig: JWTSigningConfig;
tenantCache: TenantCache;
}
export default function startScheduledTasks(
options: Options
): ScheduledJobGroups {
const tasks: ScheduledJobGroups = {
accountDeletion: registerAccountDeletion(options),
notificationDigesting: registerNotificationDigesting(options),
};
for (const { name, schedulers } of Object.values(tasks)) {
for (const scheduler of schedulers) {
scheduler.job.start();
scheduler.log.debug({ jobGroupName: name }, "now started job scheduling");
}
}
return tasks;
}