Files
outline/server/queues/tasks/EmailTask.ts
T
Tom Moor 42959d66db chore: Add cron task partitioning (#10736)
* wip

* Implementation complete

* tidying

* test

* Address feedback

* Remove duplicative retry logic from UpdateDocumentsPopularityScoreTask.
Now that we're split across many runs this is not neccessary

* Refactor to subclass, config to instance

* Refactor BaseTask to named export

* fix: Missing partition

* tsc

* Feedback
2025-11-27 16:57:52 +01:00

23 lines
652 B
TypeScript

import emails from "@server/emails/templates";
import { BaseTask } from "./base/BaseTask";
type Props = {
templateName: string;
props: Record<string, any>;
};
export default class EmailTask extends BaseTask<Props> {
public async perform({ templateName, props, ...metadata }: Props) {
const EmailClass = emails[templateName];
if (!EmailClass) {
throw new Error(
`Email task "${templateName}" template does not exist. Check the file name matches the class name.`
);
}
// @ts-expect-error We won't instantiate an abstract class
const email = new EmailClass(props, metadata);
return email.send();
}
}