mirror of
https://github.com/PretendoNetwork/account.git
synced 2026-08-26 12:55:48 -05:00
Merge pull request #336 from PretendoNetwork/chore/automatic-scrub-save
Fix automatic PNID scrubbing
This commit is contained in:
@@ -350,6 +350,10 @@ export async function checkMarkedDeletions(): Promise<void> {
|
||||
});
|
||||
|
||||
for (const pnid of pnids) {
|
||||
await pnid.scrub();
|
||||
try {
|
||||
await pnid.scrub();
|
||||
} catch (error) {
|
||||
LOG_ERROR(`Failed to scrub PNID ${pnid.pid}: ${error}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user