Throttle email notifications upon updating document frequently (#4026)

* feat: add needed columns for throttling notifs

* feat: update model

* feat: deliver only one notif in a 12 hour window

* fix: address review comments

* prevent retry if notification update fails
* fix type compatibility instead of circumventing it
* add index for emailedAt

* fix: add metadata attr to EmailProps

* chore: decouple metadata from EmailProps

* chore: add test

* chore: revert sending metadata in props
This commit is contained in:
Apoorv Mishra
2022-09-07 16:51:30 +05:30
committed by GitHub
parent e4023d87e2
commit 1e39b564fe
7 changed files with 264 additions and 17 deletions

View File

@@ -7,7 +7,7 @@ type Props = {
};
export default class EmailTask extends BaseTask<Props> {
public async perform({ templateName, props }: Props) {
public async perform({ templateName, props, ...metadata }: Props) {
const EmailClass = emails[templateName];
if (!EmailClass) {
throw new Error(
@@ -15,7 +15,7 @@ export default class EmailTask extends BaseTask<Props> {
);
}
const email = new EmailClass(props);
const email = new EmailClass(props, metadata);
return email.send();
}
}