mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-12-23 13:13:12 +02: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
1 changed files with 5 additions and 4 deletions
|
@ -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 a new issue