Merge pull request #336 from PretendoNetwork/chore/automatic-scrub-save
Some checks failed
Build and Publish Docker Image / Build and Publish Docker Image (amd64) (push) Has been cancelled
Build and Publish Docker Image / Build and Publish Docker Image (arm64) (push) Has been cancelled

Fix automatic PNID scrubbing
This commit is contained in:
Jonathan Barrow
2026-05-12 11:56:55 -04:00
committed by GitHub
5 changed files with 9 additions and 5 deletions

View File

@@ -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}`);
}
}
}

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);