summaryrefslogtreecommitdiff
path: root/packages/backend/src/queue
diff options
context:
space:
mode:
authorHazelnoot <acomputerdog@gmail.com>2025-05-11 00:07:21 -0400
committerHazelnoot <acomputerdog@gmail.com>2025-05-12 21:38:11 -0400
commitfdf67f6fc759f0d049011c20263a977b6d507a28 (patch)
treef84dff3f2a332808dd1307a99033ba8f3fc4d9b6 /packages/backend/src/queue
parentadd more manual steps to process account deletion in smaller chunks (diff)
downloadsharkey-fdf67f6fc759f0d049011c20263a977b6d507a28.tar.gz
sharkey-fdf67f6fc759f0d049011c20263a977b6d507a28.tar.bz2
sharkey-fdf67f6fc759f0d049011c20263a977b6d507a28.zip
don't sent account deletion notice until after it actually completes
Diffstat (limited to 'packages/backend/src/queue')
-rw-r--r--packages/backend/src/queue/processors/DeleteAccountProcessorService.ts40
1 files changed, 29 insertions, 11 deletions
diff --git a/packages/backend/src/queue/processors/DeleteAccountProcessorService.ts b/packages/backend/src/queue/processors/DeleteAccountProcessorService.ts
index f7643a3beb..1591946b18 100644
--- a/packages/backend/src/queue/processors/DeleteAccountProcessorService.ts
+++ b/packages/backend/src/queue/processors/DeleteAccountProcessorService.ts
@@ -353,20 +353,38 @@ export class DeleteAccountProcessorService {
this.logger.succ('All AP logs deleted');
}
- { // Send email notification
- const profile = await this.userProfilesRepository.findOneByOrFail({ userId: user.id });
- if (profile.email && profile.emailVerified) {
- this.emailService.sendEmail(profile.email, 'Account deleted',
- 'Your account has been deleted.',
- 'Your account has been deleted.');
+ // Do this BEFORE deleting the account!
+ const profile = await this.userProfilesRepository.findOneByOrFail({ userId: user.id });
+
+ { // Delete the actual account
+ await this.userIpsRepository.delete({
+ userId: user.id,
+ });
+
+ await this.signinsRepository.delete({
+ userId: user.id,
+ });
+
+ // soft指定されている場合は物理削除しない
+ if (job.data.soft) {
+ // nop
+ } else {
+ await this.usersRepository.delete(user.id);
}
+
+ this.logger.succ('Account data deleted');
}
- // soft指定されている場合は物理削除しない
- if (job.data.soft) {
- // nop
- } else {
- await this.usersRepository.delete(job.data.user.id);
+ { // Send email notification
+ if (profile.email && profile.emailVerified) {
+ try {
+ await this.emailService.sendEmail(profile.email, 'Account deleted',
+ 'Your account has been deleted.',
+ 'Your account has been deleted.');
+ } catch (e) {
+ this.logger.warn('Failed to send account deletion message:', { e });
+ }
+ }
}
return 'Account deleted';