diff --git a/src/database.ts b/src/database.ts index c24650b..7d9478b 100644 --- a/src/database.ts +++ b/src/database.ts @@ -350,6 +350,10 @@ export async function checkMarkedDeletions(): Promise { }); for (const pnid of pnids) { - await pnid.scrub(); + try { + await pnid.scrub(); + } catch (error) { + LOG_ERROR(`Failed to scrub PNID ${pnid.pid}: ${error}`); + } } } diff --git a/src/models/pnid.ts b/src/models/pnid.ts index e12a802..142de96 100644 --- a/src/models/pnid.ts +++ b/src/models/pnid.ts @@ -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 { diff --git a/src/services/grpc/account/v2/delete-account.ts b/src/services/grpc/account/v2/delete-account.ts index c4fa924..e4c80cc 100644 --- a/src/services/grpc/account/v2/delete-account.ts +++ b/src/services/grpc/account/v2/delete-account.ts @@ -24,8 +24,6 @@ export async function deleteAccount(request: DeleteAccountRequest): Promise