From 6eace8894a4ec818dbc729372de28fe766c4d8be Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 24 Sep 2022 08:41:27 +0900 Subject: [PATCH] fixes --- packages/backend/src/core/chart/charts/test-grouped.ts | 2 +- .../backend/src/core/chart/charts/test-intersection.ts | 2 +- packages/backend/src/core/chart/charts/test-unique.ts | 2 +- packages/backend/src/core/chart/charts/test.ts | 2 +- .../backend/src/core/entities/GalleryLikeEntityService.ts | 2 +- .../backend/src/core/remote/activitypub/ApInboxService.ts | 8 ++++++-- .../src/core/remote/activitypub/ApRendererService.ts | 2 +- .../src/core/remote/activitypub/ApResolverService.ts | 8 ++++---- packages/backend/src/core/remote/activitypub/type.ts | 3 ++- packages/backend/src/server/api/endpoints.ts | 4 ++-- 10 files changed, 20 insertions(+), 15 deletions(-) diff --git a/packages/backend/src/core/chart/charts/test-grouped.ts b/packages/backend/src/core/chart/charts/test-grouped.ts index 500e85f9f..bc215f394 100644 --- a/packages/backend/src/core/chart/charts/test-grouped.ts +++ b/packages/backend/src/core/chart/charts/test-grouped.ts @@ -20,7 +20,7 @@ export default class TestGroupedChart extends Chart { private db: DataSource, private appLockService: AppLockService, - private logger: Logger, + logger: Logger, ) { super(db, (k) => appLockService.getChartInsertLock(k), logger, name, schema, true); } diff --git a/packages/backend/src/core/chart/charts/test-intersection.ts b/packages/backend/src/core/chart/charts/test-intersection.ts index ff63e9976..a074a7dde 100644 --- a/packages/backend/src/core/chart/charts/test-intersection.ts +++ b/packages/backend/src/core/chart/charts/test-intersection.ts @@ -18,7 +18,7 @@ export default class TestIntersectionChart extends Chart { private db: DataSource, private appLockService: AppLockService, - private logger: Logger, + logger: Logger, ) { super(db, (k) => appLockService.getChartInsertLock(k), logger, name, schema); } diff --git a/packages/backend/src/core/chart/charts/test-unique.ts b/packages/backend/src/core/chart/charts/test-unique.ts index 3be4b0df2..4d3e2f240 100644 --- a/packages/backend/src/core/chart/charts/test-unique.ts +++ b/packages/backend/src/core/chart/charts/test-unique.ts @@ -18,7 +18,7 @@ export default class TestUniqueChart extends Chart { private db: DataSource, private appLockService: AppLockService, - private logger: Logger, + logger: Logger, ) { super(db, (k) => appLockService.getChartInsertLock(k), logger, name, schema); } diff --git a/packages/backend/src/core/chart/charts/test.ts b/packages/backend/src/core/chart/charts/test.ts index 89f64c4c1..72caf79e0 100644 --- a/packages/backend/src/core/chart/charts/test.ts +++ b/packages/backend/src/core/chart/charts/test.ts @@ -20,7 +20,7 @@ export default class TestChart extends Chart { private db: DataSource, private appLockService: AppLockService, - private logger: Logger, + logger: Logger, ) { super(db, (k) => appLockService.getChartInsertLock(k), logger, name, schema); } diff --git a/packages/backend/src/core/entities/GalleryLikeEntityService.ts b/packages/backend/src/core/entities/GalleryLikeEntityService.ts index bf7c2b7f8..7e599113c 100644 --- a/packages/backend/src/core/entities/GalleryLikeEntityService.ts +++ b/packages/backend/src/core/entities/GalleryLikeEntityService.ts @@ -1,6 +1,6 @@ import { Inject, Injectable } from '@nestjs/common'; import { DI } from '@/di-symbols.js'; -import type { GalleryPosts, GalleryLikesRepository } from '@/models/index.js'; +import type { GalleryLikesRepository } from '@/models/index.js'; import { awaitAll } from '@/misc/prelude/await-all.js'; import type { Packed } from '@/misc/schema.js'; import type { } from '@/models/entities/Blocking.js'; diff --git a/packages/backend/src/core/remote/activitypub/ApInboxService.ts b/packages/backend/src/core/remote/activitypub/ApInboxService.ts index 7525aa8d4..baeeb1ad3 100644 --- a/packages/backend/src/core/remote/activitypub/ApInboxService.ts +++ b/packages/backend/src/core/remote/activitypub/ApInboxService.ts @@ -295,8 +295,9 @@ export class ApInboxService { let renote; try { renote = await this.apNoteService.resolveNote(targetUri); + if (renote == null) throw new Error('announce target is null'); } catch (err) { - // 対象が4xxならスキップ + // 対象が4xxならスキップ if (err instanceof StatusError) { if (err.isClientError) { this.logger.warn(`Ignored announce target ${targetUri} - ${err.statusCode}`); @@ -308,7 +309,10 @@ export class ApInboxService { throw err; } - if (!await this.noteEntityService.isVisibleForMe(renote, actor.id)) return 'skip: invalid actor for this activity'; + if (!await this.noteEntityService.isVisibleForMe(renote, actor.id)) { + this.logger.warn('skip: invalid actor for this activity'); + return; + } this.logger.info(`Creating the (Re)Note: ${uri}`); diff --git a/packages/backend/src/core/remote/activitypub/ApRendererService.ts b/packages/backend/src/core/remote/activitypub/ApRendererService.ts index cf10c83f3..a401b7424 100644 --- a/packages/backend/src/core/remote/activitypub/ApRendererService.ts +++ b/packages/backend/src/core/remote/activitypub/ApRendererService.ts @@ -243,7 +243,7 @@ export class ApRendererService { }; } - public async renderLike(noteReaction: NoteReaction, note: Note) { + public async renderLike(noteReaction: NoteReaction, note: { uri: string | null }) { const reaction = noteReaction.reaction; const object = { diff --git a/packages/backend/src/core/remote/activitypub/ApResolverService.ts b/packages/backend/src/core/remote/activitypub/ApResolverService.ts index e2d6a7737..fe57c82cc 100644 --- a/packages/backend/src/core/remote/activitypub/ApResolverService.ts +++ b/packages/backend/src/core/remote/activitypub/ApResolverService.ts @@ -156,8 +156,8 @@ export class Resolver { return this.notesRepository.findOneByOrFail({ id: parsed.id }) .then(note => { if (parsed.rest === 'activity') { - // this refers to the create activity and not the note itself - return this.apRendererService.renderActivity(this.apRendererService.renderCreate(this.apRendererService.renderNote(note))); + // this refers to the create activity and not the note itself + return this.apRendererService.renderActivity(this.apRendererService.renderCreate(this.apRendererService.renderNote(note), note)); } else { return this.apRendererService.renderNote(note); } @@ -174,7 +174,7 @@ export class Resolver { .then(([note, poll]) => this.apRendererService.renderQuestion({ id: note.userId }, note, poll)); case 'likes': return this.noteReactionsRepository.findOneByOrFail({ id: parsed.id }).then(reaction => - this.apRendererService.renderActivity(this.apRendererService.renderLike(reaction, { uri: null }))); + this.apRendererService.renderActivity(this.apRendererService.renderLike(reaction, { uri: null }))!); case 'follows': // rest should be if (parsed.rest == null || !/^\w+$/.test(parsed.rest)) throw new Error('resolveLocal: invalid follow URI'); @@ -184,7 +184,7 @@ export class Resolver { ) .then(([follower, followee]) => this.apRendererService.renderActivity(this.apRendererService.renderFollow(follower, followee, url))); default: - throw new Error(`resolveLocal: type ${type} unhandled`); + throw new Error(`resolveLocal: type ${parsed.type} unhandled`); } } } diff --git a/packages/backend/src/core/remote/activitypub/type.ts b/packages/backend/src/core/remote/activitypub/type.ts index de7eb0ed8..dcc5110aa 100644 --- a/packages/backend/src/core/remote/activitypub/type.ts +++ b/packages/backend/src/core/remote/activitypub/type.ts @@ -111,8 +111,9 @@ export interface IPost extends IObject { mediaType: string; }; _misskey_quote?: string; + _misskey_content?: string; quoteUrl?: string; - _misskey_talk: boolean; + _misskey_talk?: boolean; } export interface IQuestion extends IObject { diff --git a/packages/backend/src/server/api/endpoints.ts b/packages/backend/src/server/api/endpoints.ts index a05bb5a7e..b2ab36e07 100644 --- a/packages/backend/src/server/api/endpoints.ts +++ b/packages/backend/src/server/api/endpoints.ts @@ -725,10 +725,10 @@ export interface IEndpoint { params: Schema; } -const endpoints: IEndpoint[] = eps.map(([name, ep]) => { +const endpoints: IEndpoint[] = (eps as [string, any]).map(([name, ep]) => { return { name: name, - meta: ep.meta || {}, + meta: ep.meta ?? {}, params: ep.paramDef, }; });