From 02787f75ef194474d23c94cf5ac8a34a5f9a19d0 Mon Sep 17 00:00:00 2001 From: Hazelnoot Date: Mon, 26 May 2025 11:22:18 -0400 Subject: [PATCH] add JSDocs to resolveCollectionItems --- .../src/core/activitypub/ApResolverService.ts | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/packages/backend/src/core/activitypub/ApResolverService.ts b/packages/backend/src/core/activitypub/ApResolverService.ts index 74050f456b..8312294a1f 100644 --- a/packages/backend/src/core/activitypub/ApResolverService.ts +++ b/packages/backend/src/core/activitypub/ApResolverService.ts @@ -79,12 +79,21 @@ export class Resolver { } } + /** + * Recursively resolves items from a collection. + * Stops when reaching the resolution limit or an optional item limit - whichever is lower. + * This method supports Collection, OrderedCollection, and individual pages of either type. + * Malformed collections (mixing Ordered and un-Ordered types) are also supported. + * @param collection Collection to resolve from - can be a URL or object of any supported collection type. + * @param limit Maximum number of items to resolve. If null or undefined (default), then items will be resolved until reaching the recursion limit. + * @param allowAnonymousItems If true, collection items can be anonymous (lack an ID). If false (default), then an error is thrown when reaching an item without ID. + */ @bindThis - public async resolveCollectionItems(value: string | IObject, limit?: number, allowAnonymousItems?: boolean): Promise { + public async resolveCollectionItems(collection: string | IObject, limit?: number | null, allowAnonymousItems?: boolean): Promise { const items: IObjectWithId[] = []; - const collection = await this.resolveCollection(value); - await this.resolveCollectionItemsTo(collection, limit, allowAnonymousItems, collection.id, items); + const collectionObj = await this.resolveCollection(collection); + await this.resolveCollectionItemsTo(collectionObj, limit ?? undefined, allowAnonymousItems, collectionObj.id, items); return items; }