diff options
| author | Kisaragi <48310258+KisaragiEffective@users.noreply.github.com> | 2023-04-14 16:27:55 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-04-14 16:27:55 +0900 |
| commit | 83d0f819be4d20a5e6917da528e01fd3bee34e3d (patch) | |
| tree | a0dcf63a995303f9c1e9a1016468456747ef35fc | |
| parent | fix(client): cat ears are clipped in MkReactionsViewer (#10445) (diff) | |
| download | sharkey-83d0f819be4d20a5e6917da528e01fd3bee34e3d.tar.gz sharkey-83d0f819be4d20a5e6917da528e01fd3bee34e3d.tar.bz2 sharkey-83d0f819be4d20a5e6917da528e01fd3bee34e3d.zip | |
refactor(backend): validateNoteの引数の型を強くし、anyを除去 (#10325)
* refactor(backend): validateNoteの引数の型を推論する
* fix(backend): アサーションの内容から推論してエラーの内容を期待されるであろう式へと変更する
* refactor
Co-authored-by: Acid-Chicken <root@acid-chicken.com>
---------
Co-authored-by: tamaina <tamaina@hotmail.co.jp>
Co-authored-by: Acid-Chicken <root@acid-chicken.com>
| -rw-r--r-- | packages/backend/src/core/activitypub/models/ApNoteService.ts | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/packages/backend/src/core/activitypub/models/ApNoteService.ts b/packages/backend/src/core/activitypub/models/ApNoteService.ts index 5ca5f6e843..5bbb036e03 100644 --- a/packages/backend/src/core/activitypub/models/ApNoteService.ts +++ b/packages/backend/src/core/activitypub/models/ApNoteService.ts @@ -71,7 +71,7 @@ export class ApNoteService { } @bindThis - public validateNote(object: any, uri: string) { + public validateNote(object: IObject, uri: string) { const expectHost = this.utilityService.extractDbHost(uri); if (object == null) { @@ -85,9 +85,10 @@ export class ApNoteService { if (object.id && this.utilityService.extractDbHost(object.id) !== expectHost) { return new Error(`invalid Note: id has different host. expected: ${expectHost}, actual: ${this.utilityService.extractDbHost(object.id)}`); } - - if (object.attributedTo && this.utilityService.extractDbHost(getOneApId(object.attributedTo)) !== expectHost) { - return new Error(`invalid Note: attributedTo has different host. expected: ${expectHost}, actual: ${this.utilityService.extractDbHost(object.attributedTo)}`); + + const actualHost = object.attributedTo && this.utilityService.extractDbHost(getOneApId(object.attributedTo)); + if (object.attributedTo && actualHost !== expectHost) { + return new Error(`invalid Note: attributedTo has different host. expected: ${expectHost}, actual: ${actualHost}`); } return null; |