diff --git a/ghost/recommendations/src/IncomingRecommendationService.ts b/ghost/recommendations/src/IncomingRecommendationService.ts index d5c56e27ad..d6fde78958 100644 --- a/ghost/recommendations/src/IncomingRecommendationService.ts +++ b/ghost/recommendations/src/IncomingRecommendationService.ts @@ -97,10 +97,8 @@ export class IncomingRecommendationService { const url = new URL(mention.source.toString().replace(/\/.well-known\/recommendations\.json$/, '')); // Check if we are also recommending this URL - const existing = await this.#recommendationService.countRecommendations({ - filter: `url:~'${url}'` - }); - const recommendingBack = existing > 0; + const existing = await this.#recommendationService.readRecommendationByUrl(url); + const recommendingBack = !!existing; return { title: mention.sourceTitle, diff --git a/ghost/recommendations/src/RecommendationService.ts b/ghost/recommendations/src/RecommendationService.ts index 44c9831dc3..4783c62bb3 100644 --- a/ghost/recommendations/src/RecommendationService.ts +++ b/ghost/recommendations/src/RecommendationService.ts @@ -183,4 +183,13 @@ export class RecommendationService { const subscribeEvent = SubscribeEvent.create({recommendationId: id, memberId}); await this.subscribeEventRepository.save(subscribeEvent); } + + async readRecommendationByUrl(url: URL): Promise { + const recommendation = await this.repository.getByUrl(url); + + if (!recommendation) { + return null; + } + return recommendation.plain; + } }