@@ -10,7 +10,10 @@ import { DatabaseService } from '~/processors/database/database.service'
1010import { ConfigsService } from '../../configs/configs.service'
1111import { AI_PROMPTS } from '../ai.prompts'
1212import { AiService } from '../ai.service'
13- import { isGlobalArticleVisible } from '../ai-article-visibility.util'
13+ import {
14+ type ArticleViewer ,
15+ isArticleVisibleToViewer ,
16+ } from '../ai-article-visibility.util'
1417import type { GenerationUsage } from '../ai-generation-metrics/ai-generation-metrics.types'
1518import {
1619 emptyUsage ,
@@ -71,7 +74,10 @@ export class AiSummaryAdapter implements MultilangAdapter<
7174 }
7275 }
7376
74- async resolveArticleDetailed ( articleId : string ) : Promise < {
77+ async resolveArticleDetailed (
78+ articleId : string ,
79+ viewer : ArticleViewer = { } ,
80+ ) : Promise < {
7581 article : ArticleForSummary
7682 sourceLang : string
7783 type : CollectionRefTypes . Post | CollectionRefTypes . Note
@@ -86,9 +92,7 @@ export class AiSummaryAdapter implements MultilangAdapter<
8692 ) {
8793 throw createAppException ( AppErrorCode . CONTENT_NOT_FOUND_CANT_PROCESS )
8894 }
89- // Never expose summaries for draft / password-protected / future-dated
90- // content. Public endpoints and background tasks both flow through here.
91- if ( ! isGlobalArticleVisible ( article ) ) {
95+ if ( ! isArticleVisibleToViewer ( article , viewer ) ) {
9296 throw createAppException ( AppErrorCode . CONTENT_NOT_FOUND_CANT_PROCESS )
9397 }
9498 const doc = article . document as { title : string ; text : string }
@@ -103,8 +107,12 @@ export class AiSummaryAdapter implements MultilangAdapter<
103107
104108 async resolveArticle (
105109 refId : string ,
110+ viewer ?: ArticleViewer ,
106111 ) : Promise < MultilangResolvedArticle < ArticleForSummary > > {
107- const { article, sourceLang } = await this . resolveArticleDetailed ( refId )
112+ const { article, sourceLang } = await this . resolveArticleDetailed (
113+ refId ,
114+ viewer ,
115+ )
108116 return { article, text : article . text , sourceLang }
109117 }
110118
0 commit comments