diff --git a/ghost/collections/src/CollectionsService.ts b/ghost/collections/src/CollectionsService.ts index 2889b9cf1a..1242356d33 100644 --- a/ghost/collections/src/CollectionsService.ts +++ b/ghost/collections/src/CollectionsService.ts @@ -560,12 +560,20 @@ export class CollectionsService { }); } - async getById(id: string, options?: {transaction: Knex.Transaction}): Promise { - return await this.collectionsRepository.getById(id, options); + async getById(id: string, options?: {transaction: Knex.Transaction}): Promise { + const collection = await this.collectionsRepository.getById(id, options); + if (!collection) { + return null; + } + return this.toDTO(collection); } - async getBySlug(slug: string, options?: {transaction: Knex.Transaction}): Promise { - return await this.collectionsRepository.getBySlug(slug, options); + async getBySlug(slug: string, options?: {transaction: Knex.Transaction}): Promise { + const collection = await this.collectionsRepository.getBySlug(slug, options); + if (!collection) { + return null; + } + return this.toDTO(collection); } // eslint-disable-next-line @typescript-eslint/no-explicit-any @@ -605,7 +613,7 @@ export class CollectionsService { } async destroy(id: string): Promise { - const collection = await this.getById(id); + const collection = await this.collectionsRepository.getById(id); if (collection) { if (collection.deletable === false) { diff --git a/ghost/posts-service/lib/PostsService.js b/ghost/posts-service/lib/PostsService.js index 97e5ffa841..3c758133cd 100644 --- a/ghost/posts-service/lib/PostsService.js +++ b/ghost/posts-service/lib/PostsService.js @@ -56,7 +56,7 @@ class PostsService { }); } - const postIds = collection.posts; + const postIds = collection.posts.map(post => post.id); if (postIds.length !== 0) { options.filter = `id:[${postIds.join(',')}]+type:post`;