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) {
|
||||
|
@ -86,8 +86,9 @@ export class ApNoteService {
|
|||
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