Compare commits

...

1 commit

Author SHA1 Message Date
9f1d7907e4
fix(backend): Atomically mark remote account deletions
All checks were successful
Test (production install and build) / production (22.11.0) (pull_request) Successful in 1m1s
Test (backend) / unit (22.11.0) (pull_request) Successful in 8m28s
Lint / pnpm_install (push) Successful in 1m20s
Publish Docker image / Build (push) Successful in 4m31s
Test (backend) / e2e (22.11.0) (pull_request) Successful in 11m30s
Test (production install and build) / production (22.11.0) (push) Successful in 1m3s
Lint / lint (backend) (pull_request) Successful in 2m8s
Test (backend) / unit (22.11.0) (push) Successful in 7m50s
Lint / lint (frontend) (pull_request) Successful in 2m17s
Lint / lint (frontend-embed) (pull_request) Successful in 2m19s
Lint / lint (frontend-shared) (pull_request) Successful in 2m23s
Test (backend) / e2e (22.11.0) (push) Successful in 11m41s
Lint / lint (misskey-bubble-game) (pull_request) Successful in 2m36s
Lint / lint (misskey-js) (pull_request) Successful in 2m31s
Lint / lint (misskey-reversi) (pull_request) Successful in 2m41s
Lint / lint (sw) (pull_request) Successful in 2m41s
Lint / typecheck (backend) (pull_request) Successful in 2m12s
Lint / typecheck (misskey-js) (pull_request) Successful in 2m1s
Lint / typecheck (sw) (pull_request) Successful in 2m2s
Lint / lint (backend) (push) Successful in 2m32s
Lint / lint (frontend) (push) Successful in 2m53s
Lint / lint (frontend-embed) (push) Successful in 2m39s
Lint / lint (frontend-shared) (push) Successful in 2m41s
Lint / lint (misskey-bubble-game) (push) Successful in 2m41s
Lint / lint (misskey-js) (push) Successful in 2m39s
Lint / lint (misskey-reversi) (push) Successful in 2m41s
Lint / typecheck (backend) (push) Successful in 2m15s
Lint / lint (sw) (push) Successful in 2m36s
Lint / typecheck (misskey-js) (push) Successful in 1m40s
Lint / typecheck (sw) (push) Successful in 1m29s
Signed-off-by: eternal-flame-AD <yume@yumechi.jp>
2024-11-19 21:49:10 -06:00
3 changed files with 19 additions and 10 deletions

View file

@ -0,0 +1,16 @@
/*
* SPDX-FileCopyrightText: syuilo and misskey-project and yumechi
* SPDX-License-Identifier: AGPL-3.0-only
*/
export class IndexUserDeleted1732071810971 {
name = 'IndexUserDeleted1732071810971'
async up(queryRunner) {
await queryRunner.query(`CREATE INDEX IF NOT EXISTS "IDX_199b79e682bdc5ba946f491686" ON "user" ("isDeleted")`);
}
async down(queryRunner) {
await queryRunner.query(`DROP INDEX IF EXISTS "IDX_199b79e682bdc5ba946f491686"`);
}
}

View file

@ -509,19 +509,12 @@ export class ApInboxService {
return `skip: delete actor ${actor.uri} !== ${uri}`; return `skip: delete actor ${actor.uri} !== ${uri}`;
} }
const user = await this.usersRepository.findOneBy({ id: actor.id }); if (!(await this.usersRepository.update({ id: actor.id, isDeleted: false }, { isDeleted: true })).affected) {
if (user == null) {
return 'skip: actor not found';
} else if (user.isDeleted) {
return 'skip: already deleted'; return 'skip: already deleted';
} }
const job = await this.queueService.createDeleteAccountJob(actor); const job = await this.queueService.createDeleteAccountJob(actor);
await this.usersRepository.update(actor.id, {
isDeleted: true,
});
this.globalEventService.publishInternalEvent('remoteUserUpdated', { id: actor.id }); this.globalEventService.publishInternalEvent('remoteUserUpdated', { id: actor.id });
return `ok: queued ${job.name} ${job.id}`; return `ok: queued ${job.name} ${job.id}`;

View file

@ -557,7 +557,7 @@ export class ApPersonService implements OnModuleInit {
if (moving) updates.movedAt = new Date(); if (moving) updates.movedAt = new Date();
// Update user // Update user
await this.usersRepository.update(exist.id, updates); await this.usersRepository.update({ id: exist.id, isDeleted: false }, updates);
if (person.publicKey) { if (person.publicKey) {
await this.userPublickeysRepository.update({ userId: exist.id }, { await this.userPublickeysRepository.update({ userId: exist.id }, {
@ -662,7 +662,7 @@ export class ApPersonService implements OnModuleInit {
@bindThis @bindThis
public async updateFeatured(userId: MiUser['id'], resolver?: Resolver): Promise<void> { public async updateFeatured(userId: MiUser['id'], resolver?: Resolver): Promise<void> {
const user = await this.usersRepository.findOneByOrFail({ id: userId }); const user = await this.usersRepository.findOneByOrFail({ id: userId, isDeleted: false });
if (!this.userEntityService.isRemoteUser(user)) return; if (!this.userEntityService.isRemoteUser(user)) return;
if (!user.featured) return; if (!user.featured) return;