diff options
| author | MeiMei <30769358+mei23@users.noreply.github.com> | 2019-09-27 04:58:28 +0900 |
|---|---|---|
| committer | syuilo <Syuilotan@yahoo.co.jp> | 2019-09-27 04:58:28 +0900 |
| commit | e14509574d534a74fcebf9515146b028bbdec153 (patch) | |
| tree | c49aa610bb703ce9b7903059235e69fec3eead11 /src/remote/activitypub/resolver.ts | |
| parent | Use mk-frac (diff) | |
| download | misskey-e14509574d534a74fcebf9515146b028bbdec153.tar.gz misskey-e14509574d534a74fcebf9515146b028bbdec153.tar.bz2 misskey-e14509574d534a74fcebf9515146b028bbdec153.zip | |
AP featured collectionの修正 / Collection Activityの対応 / typeの修正など (#5460)
* resolver type / fix updateFeatured
* type ApObject
* fix strange type
* AP Activity
* Collection Activityが失敗したらとりあえず無視
Diffstat (limited to 'src/remote/activitypub/resolver.ts')
| -rw-r--r-- | src/remote/activitypub/resolver.ts | 26 |
1 files changed, 7 insertions, 19 deletions
diff --git a/src/remote/activitypub/resolver.ts b/src/remote/activitypub/resolver.ts index d656c1c5e5..5b82244536 100644 --- a/src/remote/activitypub/resolver.ts +++ b/src/remote/activitypub/resolver.ts @@ -1,5 +1,5 @@ import * as request from 'request-promise-native'; -import { IObject } from './type'; +import { IObject, isCollectionOrOrderedCollection, ICollection, IOrderedCollection } from './type'; import config from '../../config'; export default class Resolver { @@ -14,31 +14,19 @@ export default class Resolver { return Array.from(this.history); } - public async resolveCollection(value: any) { + public async resolveCollection(value: string | IObject): Promise<ICollection | IOrderedCollection> { const collection = typeof value === 'string' ? await this.resolve(value) : value; - switch (collection.type) { - case 'Collection': { - collection.objects = collection.items; - break; - } - - case 'OrderedCollection': { - collection.objects = collection.orderedItems; - break; - } - - default: { - throw new Error(`unknown collection type: ${collection.type}`); - } + if (isCollectionOrOrderedCollection(collection)) { + return collection; + } else { + throw new Error(`unknown collection type: ${collection.type}`); } - - return collection; } - public async resolve(value: any): Promise<IObject> { + public async resolve(value: string | IObject): Promise<IObject> { if (value == null) { throw new Error('resolvee is null (or undefined)'); } |