fix: add automatic this.save() calls to pnid.scrub/markForDeletion

This commit is contained in:
Jonathan Barrow 2026-05-12 11:44:14 -04:00
parent eef5b0b4af
commit f1262bf64a
No known key found for this signature in database
GPG Key ID: 2A7DAA6DED5A77E5
4 changed files with 4 additions and 4 deletions

View File

@ -264,6 +264,8 @@ PNIDSchema.method('markForDeletion', async function markForDeletion() {
LOG_ERROR(`ERROR UPDATING SUBSCRIPTION FOR USER ${this.username} (${subscriptionID}). ${error}`);
}
}
await this.save();
});
PNIDSchema.method('scrub', async function scrub() {
@ -362,6 +364,8 @@ PNIDSchema.method('scrub', async function scrub() {
this.connections.stripe.tier_level = 0;
this.connections.stripe.tier_name = '';
this.connections.stripe.latest_webhook_timestamp = 0;
await this.save();
});
PNIDSchema.method('hasPermission', function hasPermission(flag: PNIDPermissionFlag): boolean {

View File

@ -24,8 +24,6 @@ export async function deleteAccount(request: DeleteAccountRequest): Promise<Dele
await pnid.markForDeletion();
}
await pnid.save();
await sendPNIDDeletedEmail(email, pnid.username);
if (request.bypassGracePeriod) {

View File

@ -18,7 +18,6 @@ export async function deleteAccount(request: DeleteAccountRequest): Promise<Dele
const email = pnid.email.address;
await pnid.markForDeletion();
await pnid.save();
await sendPNIDDeletedEmail(email, pnid.username);
} catch (error) {

View File

@ -581,7 +581,6 @@ router.post('/@me/deletion', async (request: express.Request, response: express.
const email = pnid.email.address;
await pnid.markForDeletion();
await pnid.save();
try {
await sendPNIDDeletedEmail(email, pnid.username);