🐛 Fixed paid members on other tiers receiving gated newsletter content#28315
Draft
9larsons wants to merge 1 commit into
Draft
🐛 Fixed paid members on other tiers receiving gated newsletter content#283159larsons wants to merge 1 commit into
9larsons wants to merge 1 commit into
Conversation
fixes #27893 ref #25046 - the website gated tier-restricted posts correctly, but newsletters only understood a free/paid split, so any paying member received the full members-only content regardless of which tier the post was restricted to - extracted getPostAccessFilter() so web (checkPostAccess) and email derive "who can read this post" from a single source and can't drift apart - getSegments() now splits a tier-restricted post into an access segment and its complement; renderBody() paywalls any segment lacking post access rather than keying off status:free; batch sending loads the post's tiers relation - paid/members posts reduce to the existing behaviour
Contributor
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #27893
Fixes https://linear.app/ghost/issue/ONC-1725
Related: #25046 · Forum: paid tier without post access still has access
Problem
When a post's visibility is restricted to specific tiers, the website correctly gates the content — a paying member on a tier not included in the post sees the public preview and paywall. Email newsletters did not honor this: the sending pipeline only understood a free/paid split, so any paying member received the full members-only content in their inbox, regardless of which tier they were on.
This contradicts the documented behavior that post access settings determine how members see content "on your site, or in their inbox as an email newsletter."
Cause
The email pipeline reasoned only about
status:freevsstatus:-free:getSegments()returned a hardcoded free/paid pair and never produced tier-based segments.renderBody()applied the paywall only to thestatus:freesegment — so every paying member, on any tier, got the full body.tiersrelation wasn't even loaded during batch sending.Change
getPostAccessFilter(post)incontent-gating.js;checkPostAccess(web) now delegates to it, so web and email derive "who can read this post" the same way.getSegments()now splits a tier-restricted post into an access segment (members on an allowed tier → full content) and its complement (everyone else → preview + paywall). Reduces to the existing behavior forpaid/membersposts.renderBody()paywalls any segment lacking post access, instead of keying offstatus:free. Per-blockdata-gh-segment(free/paid) card visibility remains keyed on free/paid status, independent of tier access.tiers.Behavior
Post restricted to Tier A, sent to all members:
paidandmembersposts are unchanged.Tests
getPostAccessFilteracross visibilities;getSegmentstier (2-cell and 3-cell) cases;renderBodypaywalls the no-access tier segment, not the access one.Known follow-up (not in this PR)
The email preheader/excerpt still regenerates from gated HTML only for the
status:freesegment, so a wrong-tier paid member sees members-only text in the preview text (the body is correctly gated). Same free/paid-vs-tier assumption, in#getEmailPreheader(); tracked for a separate change.