mirror of
https://github.com/kokonect-link/cherrypick
synced 2024-10-31 23:31:48 +09:00
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>
This commit is contained in:
parent
c47a0f78ff
commit
83d0f819be
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user