Skip to content

Commit

Permalink
デッドロック解消の試み
Browse files Browse the repository at this point in the history
  • Loading branch information
syuilo committed Mar 1, 2025
1 parent 55b997d commit 266141f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
11 changes: 2 additions & 9 deletions packages/backend/src/core/activitypub/ApInboxService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -507,19 +507,12 @@ export class ApInboxService {
return `skip: delete actor ${actor.uri} !== ${uri}`;
}

const user = await this.usersRepository.findOneBy({ id: actor.id });
if (user == null) {
return 'skip: actor not found';
} else if (user.isDeleted) {
return 'skip: already deleted';
if (!(await this.usersRepository.update({ id: actor.id, isDeleted: false }, { isDeleted: true })).affected) {
return 'skip: already deleted or actor not found';
}

const job = await this.queueService.createDeleteAccountJob(actor);

await this.usersRepository.update(actor.id, {
isDeleted: true,
});

this.globalEventService.publishInternalEvent('remoteUserUpdated', { id: actor.id });

return `ok: queued ${job.name} ${job.id}`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,9 @@ export class ApPersonService implements OnModuleInit {
if (moving) updates.movedAt = new Date();

// Update user
await this.usersRepository.update(exist.id, updates);
if (!(await this.usersRepository.update({ id: exist.id, isDeleted: false }, updates)).affected) {
return 'skip';
}

if (person.publicKey) {
await this.userPublickeysRepository.update({ userId: exist.id }, {
Expand Down Expand Up @@ -699,7 +701,7 @@ export class ApPersonService implements OnModuleInit {

@bindThis
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 (!user.featured) return;

Expand Down

0 comments on commit 266141f

Please sign in to comment.