From 830565787a8775405ee7fdf6ca06cfb881329f5a Mon Sep 17 00:00:00 2001 From: Hazel K Date: Wed, 9 Oct 2024 23:41:26 -0400 Subject: [PATCH 1/4] docs: fix command to generate new migration --- CONTRIBUTING.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a50b550b3a..755602ca34 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -529,7 +529,8 @@ enumの列挙の内容の削除は、その値をもつレコードを全て削 ### Migration作成方法 packages/backendで: ```sh -pnpm dlx typeorm migration:generate -d ormconfig.js -o +pnpm run build +pnpm dlx typeorm migration:generate -d ormconfig.js -o migration/ ``` - 生成後、ファイルをmigration下に移してください From a39f5c92b468d3dca5ec505ebd752a2023023ddc Mon Sep 17 00:00:00 2001 From: Hazelnoot Date: Fri, 11 Oct 2024 10:21:32 -0400 Subject: [PATCH 2/4] add missing `rejectReports` field to `show-instance` response --- .../backend/src/core/entities/InstanceEntityService.ts | 1 + .../src/models/json-schema/federation-instance.ts | 5 +++++ packages/misskey-js/src/autogen/types.ts | 9 +++++++++ 3 files changed, 15 insertions(+) diff --git a/packages/backend/src/core/entities/InstanceEntityService.ts b/packages/backend/src/core/entities/InstanceEntityService.ts index 7695e6dfa7..3863cf5666 100644 --- a/packages/backend/src/core/entities/InstanceEntityService.ts +++ b/packages/backend/src/core/entities/InstanceEntityService.ts @@ -57,6 +57,7 @@ export class InstanceEntityService { infoUpdatedAt: instance.infoUpdatedAt ? instance.infoUpdatedAt.toISOString() : null, latestRequestReceivedAt: instance.latestRequestReceivedAt ? instance.latestRequestReceivedAt.toISOString() : null, isNSFW: instance.isNSFW, + rejectReports: instance.rejectReports, moderationNote: iAmModerator ? instance.moderationNote : null, }; } diff --git a/packages/backend/src/models/json-schema/federation-instance.ts b/packages/backend/src/models/json-schema/federation-instance.ts index 062dba9bad..7960e748e9 100644 --- a/packages/backend/src/models/json-schema/federation-instance.ts +++ b/packages/backend/src/models/json-schema/federation-instance.ts @@ -121,6 +121,11 @@ export const packedFederationInstanceSchema = { optional: false, nullable: false, }, + rejectReports: { + type: 'boolean', + optional: false, + nullable: false, + }, moderationNote: { type: 'string', optional: true, nullable: true, diff --git a/packages/misskey-js/src/autogen/types.ts b/packages/misskey-js/src/autogen/types.ts index 94b77efb66..0453fd0a36 100644 --- a/packages/misskey-js/src/autogen/types.ts +++ b/packages/misskey-js/src/autogen/types.ts @@ -4772,6 +4772,7 @@ export type components = { /** Format: date-time */ latestRequestReceivedAt: string | null; isNSFW: boolean; + rejectReports: boolean; moderationNote?: string | null; }; GalleryPost: { @@ -15366,6 +15367,10 @@ export type operations = { untilId?: string; /** @default 10 */ limit?: number; + /** @default false */ + includeFollower?: boolean; + /** @default true */ + includeFollowee?: boolean; }; }; }; @@ -15425,6 +15430,10 @@ export type operations = { untilId?: string; /** @default 10 */ limit?: number; + /** @default false */ + includeFollower?: boolean; + /** @default true */ + includeFollowee?: boolean; }; }; }; From a1375c8ab72eb93ecd3554a4745243481932fd15 Mon Sep 17 00:00:00 2001 From: Hazelnoot Date: Sat, 12 Oct 2024 00:29:40 -0400 Subject: [PATCH 3/4] prevent usernames from overflowing the reactions hover-list --- .../src/components/MkReactionsViewer.details.vue | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/frontend/src/components/MkReactionsViewer.details.vue b/packages/frontend/src/components/MkReactionsViewer.details.vue index 60118fadd2..efca61a035 100644 --- a/packages/frontend/src/components/MkReactionsViewer.details.vue +++ b/packages/frontend/src/components/MkReactionsViewer.details.vue @@ -13,7 +13,7 @@ SPDX-License-Identifier: AGPL-3.0-only
- +
+{{ count - 10 }}
@@ -98,4 +98,11 @@ function getReactionName(reaction: string): string { .more { padding-top: 4px; } + +.username { + text-overflow: ellipsis; + white-space: nowrap; + min-width: 0; + overflow: hidden; +} From 06bd29f2093cee6c1c0efd02e08c17088415e3ef Mon Sep 17 00:00:00 2001 From: dakkar Date: Sat, 12 Oct 2024 10:43:28 +0100 Subject: [PATCH 4/4] try to avoid `insert` races in `FederatedInstanceService` Despite the cache, different processes can race to insert a row for the same remote host. This is particularly apparent in our unit tests, with `test/unit/activitypub.ts` randomly failing. This is a (somewhat clumsy) attempt at working around that race: trap the "duplicate key value" error, and fetch the record. Tests pass, with or without values in the cache. --- .../src/core/FederatedInstanceService.ts | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/packages/backend/src/core/FederatedInstanceService.ts b/packages/backend/src/core/FederatedInstanceService.ts index 7aeeb78178..7ec565557c 100644 --- a/packages/backend/src/core/FederatedInstanceService.ts +++ b/packages/backend/src/core/FederatedInstanceService.ts @@ -12,6 +12,8 @@ import { IdService } from '@/core/IdService.js'; import { DI } from '@/di-symbols.js'; import { UtilityService } from '@/core/UtilityService.js'; import { bindThis } from '@/decorators.js'; +import { QueryFailedError } from 'typeorm'; +import { isDuplicateKeyValueError } from '@/misc/is-duplicate-key-value-error.js'; @Injectable() export class FederatedInstanceService implements OnApplicationShutdown { @@ -56,11 +58,24 @@ export class FederatedInstanceService implements OnApplicationShutdown { const index = await this.instancesRepository.findOneBy({ host }); if (index == null) { - const i = await this.instancesRepository.insertOne({ - id: this.idService.gen(), - host, - firstRetrievedAt: new Date(), - }); + let i; + try { + i = await this.instancesRepository.insertOne({ + id: this.idService.gen(), + host, + firstRetrievedAt: new Date(), + }); + } catch (e: unknown) { + if (e instanceof QueryFailedError) { + if (isDuplicateKeyValueError(e)) { + i = await this.instancesRepository.findOneBy({ host }); + } + } + + if (i == null) { + throw e; + } + } this.federatedInstanceCache.set(host, i); return i;