Skip to content

Commit a3bb701

Browse files
committed
fix(core): tease premium article bodies when lexical content is missing
1 parent 5ab154f commit a3bb701

2 files changed

Lines changed: 19 additions & 10 deletions

File tree

apps/core/src/modules/article-body/article-body.service.ts

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@ import {
1212
TranslationService,
1313
} from '~/processors/helper/helper.translation.service'
1414
import {
15-
renderTeaserText,
16-
resolveEffectivePreviewBlocks,
17-
truncateLexicalContent,
15+
getPublicContent,
16+
getPublicText,
1817
} from '~/processors/helper/lexical-truncate.util'
1918

2019
import type { ArticleBodyItem } from './article-body.schema'
@@ -56,15 +55,11 @@ function isNotePubliclyListed(note: NoteRow) {
5655
}
5756

5857
function applyPaywallTeaser(doc: BodyDoc): BodyDoc {
59-
const previewBlocks = resolveEffectivePreviewBlocks(
60-
doc.content,
61-
doc.meta?.paywall?.previewBlocks,
62-
)
63-
const content = truncateLexicalContent(doc.content, previewBlocks)
58+
const source = { ...doc, isPremium: true }
6459
return {
6560
...doc,
66-
content,
67-
text: renderTeaserText(content),
61+
content: getPublicContent(source),
62+
text: getPublicText(source),
6863
}
6964
}
7065

apps/core/test/src/modules/article-body/article-body.service.spec.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,20 @@ describe('ArticleBodyService.streamBodies', () => {
179179
})
180180
})
181181

182+
it('teases a premium post with no lexical body as an empty locked line', async () => {
183+
const { service } = createService({
184+
entitled: false,
185+
posts: [makePost({ isPremium: true, content: null, text: 'hidden' })],
186+
})
187+
const lines = await collect(service, [{ id: postId, kind: 'post' }])
188+
expect(lines[0]).toMatchObject({
189+
content: null,
190+
isPremium: true,
191+
locked: true,
192+
text: '',
193+
})
194+
})
195+
182196
it('returns the full premium body when the reader is entitled', async () => {
183197
const { service } = createService({
184198
entitled: true,

0 commit comments

Comments
 (0)