Refactor account deletion process and improve invitation functionalities
The account deletion process has been refactored to send account deletion emails from the AccountWebhooksService instead of from the deletePersonalAccount service. This has resulted in the addition of the AccountWebhooksService and modification of the seeds.sql file to trigger a webhook after account deletion. Along with this, the account invitation functionalities within the accountInvitations service have been considerably enhanced, making it much clearer and easier to use.
This commit is contained in:
@@ -22,6 +22,12 @@ export class DatabaseWebhookRouterService {
|
||||
return this.handleSubscriptionsWebhook(payload);
|
||||
}
|
||||
|
||||
case 'accounts': {
|
||||
const payload = body as RecordChange<typeof body.table>;
|
||||
|
||||
return this.handleAccountsWebhook(payload);
|
||||
}
|
||||
|
||||
default: {
|
||||
const logger = await getLogger();
|
||||
|
||||
@@ -55,4 +61,16 @@ export class DatabaseWebhookRouterService {
|
||||
return service.handleSubscriptionDeletedWebhook(body.old_record);
|
||||
}
|
||||
}
|
||||
|
||||
private async handleAccountsWebhook(body: RecordChange<'accounts'>) {
|
||||
const { AccountWebhooksService } = await import(
|
||||
'@kit/team-accounts/webhooks'
|
||||
);
|
||||
|
||||
const service = new AccountWebhooksService();
|
||||
|
||||
if (body.type === 'DELETE' && body.old_record) {
|
||||
return service.handleAccountDeletedWebhook(body.old_record);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user