fix(backend): Atomically mark remote account deletions
Some checks failed
Lint / pnpm_install (pull_request) Successful in 1m52s
Publish Docker image / Build (pull_request) Successful in 4m32s
Test (federation) / test (22.11.0) (pull_request) Failing after 1m36s
Test (production install and build) / production (22.11.0) (pull_request) Successful in 1m4s
Test (backend) / unit (22.11.0) (pull_request) Successful in 8m47s
Test (backend) / e2e (22.11.0) (pull_request) Successful in 11m43s
Lint / lint (backend) (pull_request) Successful in 2m24s
Lint / lint (frontend) (pull_request) Successful in 2m12s
Lint / lint (frontend-embed) (pull_request) Successful in 2m14s
Lint / lint (frontend-shared) (pull_request) Successful in 2m21s
Lint / lint (misskey-bubble-game) (pull_request) Successful in 2m28s
Lint / lint (misskey-js) (pull_request) Successful in 2m19s
Lint / lint (sw) (pull_request) Successful in 2m25s
Lint / lint (misskey-reversi) (pull_request) Successful in 2m42s
Lint / typecheck (misskey-js) (pull_request) Successful in 1m38s
Lint / typecheck (sw) (pull_request) Successful in 1m58s
Lint / typecheck (backend) (pull_request) Successful in 2m40s

Signed-off-by: eternal-flame-AD <yume@yumechi.jp>
This commit is contained in:
ゆめ 2024-11-19 21:07:02 -06:00
parent 416d71002a
commit 2ae03cd1e3
No known key found for this signature in database
4 changed files with 78 additions and 10 deletions

View file

@ -0,0 +1,59 @@
name: Test (federation)
on:
push:
branches:
- master
- develop
paths:
- packages/backend/**
- packages/misskey-js/**
- .forgejo/workflows/test-federation.yml
pull_request:
paths:
- packages/backend/**
- packages/misskey-js/**
- .forgejo/workflows/test-federation.yml
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [22.11.0]
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Install pnpm
uses: pnpm/action-setup@v4
- name: Install FFmpeg
uses: https://github.com/FedericoCarboni/setup-ffmpeg@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4.0.3
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'
- name: Build Misskey
run: |
corepack enable && corepack prepare
pnpm i --frozen-lockfile
pnpm build
- name: Setup
run: |
cd packages/backend/test-federation
bash ./setup.sh
sudo chmod 644 ./certificates/*.test.key
- name: Start servers
# https://github.com/docker/compose/issues/1294#issuecomment-374847206
run: |
cd packages/backend/test-federation
docker compose up -d --scale tester=0
- name: Test
run: |
cd packages/backend/test-federation
docker compose run --no-deps tester
- name: Stop servers
run: |
cd packages/backend/test-federation
docker compose down

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}`;
}
const user = await this.usersRepository.findOneBy({ id: actor.id });
if (user == null) {
return 'skip: actor not found';
} else if (user.isDeleted) {
if (!(await this.usersRepository.update({ id: actor.id, isDeleted: false }, { isDeleted: true })).affected) {
return 'skip: already deleted';
}
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}`;

View file

@ -557,7 +557,7 @@ export class ApPersonService implements OnModuleInit {
if (moving) updates.movedAt = new Date();
// Update user
await this.usersRepository.update(exist.id, updates);
await this.usersRepository.update({ id: exist.id, isDeleted: false }, updates);
if (person.publicKey) {
await this.userPublickeysRepository.update({ userId: exist.id }, {
@ -662,7 +662,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;