Skip to content

Gift links (spike): tokenized single-post unlock links - #28625

Closed
jonatansberg wants to merge 36 commits into
mainfrom
gift-links-spike
Closed

jonatansberg wants to merge 36 commits into
mainfrom
gift-links-spike

Conversation

@jonatansberg

Copy link
Copy Markdown
Member

Gift links (spike)

Tokenized single-post unlock links that let a publisher share a paid/members-only post so anonymous readers get full access to that one post — without an account.

⚠️ Draft / spike. Opened for review and discussion, not merge-ready. Gated behind the giftLinks labs flag (off by default). See the open items below.

How it works

  • URL shape: <siteUrl>/g/<slug>/?key=TOKEN. A dedicated /g/ path prefix (not a ?gift= param on the canonical URL) gives Fastly a clean path-based cache-bypass boundary; GiftLinksRouter is modelled on PreviewRouter.
  • Access grant: site-level middleware resolves the ?key= token; the /g/ controller verifies the slug matches the token's post, then renders via the standard entry pipeline with a content-only grant. Invalid / missing / mismatched tokens 301 to the canonical URL with no-store (and never leak the real slug).
  • Reader-side: core ships no default UI. A post rendered via a valid gift link exposes a documented @gift ({post_id}) template context so theme authors build their own callout. @gift is set only on the verified render path — never on redirects, 404s, or canonical routes.
  • Admin: gift_links table + model + migrations + permissions; admin API (browse / ensure / reset / reset-all); editor post-settings-menu inline control (copy / usage / reset-confirm) and a posts-list context-menu action; React danger-zone "reset all" toggle.
  • Counting: gift reads are counted with bot-UA filtering and a per-post gift_seen cookie as a distinct-client proxy.

Test coverage

Unit + integration + e2e (API and frontend) for the service, middleware, gating, routing, and the @gift contract (including a regression test that @gift never leaks onto error renders).

Known open items (from review — not yet addressed)

A /code-review pass plus an adversarial Codex review surfaced several items still to triage before this leaves spike status, notably:

  • Token leaks into analytics: ghost-stats sends location.href, so the ?key= token reaches analytics payloads (Codex finding).
  • /g/ route shadowing: a routes.yaml collection permalinked under /g/ can self-redirect into a loop (no reserved-prefix validation).
  • countGiftRead secure-cookie throw on https sites behind a proxy that doesn't forward X-Forwarded-Proto → reads never counted.
  • Clipboard copy in the Ember surfaces writes after an awaited POST → fails silently in Safari/Firefox; context-menu task lacks error handling.
  • Super Editor excluded from the gift-links permission everywhere (likely accidental).
  • Reset endpoint enforces post-eligibility, contradicting its own "still resettable when ineligible" design note.
  • Bot UA regex matches unanchored substrings (e.g. "CUBOT" devices) → real reads dropped.
  • Dead React-side code (unused apps/posts utils, admin-x-framework hooks, shade giftLinkSlot) and Ember URL/eligibility duplication to clean up.

jonatansberg and others added 30 commits May 29, 2026 10:57
ref https://linear.app/ghost/project/gift-post-links-for-publishers-1959ff241de0/overview

- first slice of gift post links: a tokenized always-on link letting anyone read a single gated post/page with no account; this lays only the foundation behind the private `giftLinks` labs flag, with no functional behavior yet
- adds a `gift_links` child table (1:many on posts, <=1 active row/post) + `GiftLink` model and a `Post.hasMany` relation kept out of the default relationships set, so links are managed lazily and never auto-loaded or auto-saved with a post
- adds `manage:gift_link` (Administrator/Editor) and `resetAll:gift_link` (Administrator) permissions via fixtures + migration; Owner inherits all permissions automatically, so the site-wide reset-all is correctly tighter than per-post manage
- omits `created_by` deliberately - Ghost lints against it on new tables; the action log is the general mechanism for recording who did what
- places `gift_links` in the exporter BACKUP_TABLES (token-bearing, excluded from default content export), mirroring the `gifts` table

Co-Authored-By: Claude Opus 4.8 <[email protected]>
ref https://linear.app/ghost/project/gift-post-links-for-publishers-1959ff241de0/overview

- second slice of gift post links: the lifecycle service behind the `giftLinks` flag, with no admin/reader surface yet
- `ensure` is idempotent (returns the active link or creates one) and `reset` mints a fresh token while retaining history; both lock the post row inside a transaction so there is at most one active link per post even on first create, since MySQL has no partial unique index
- `resetAll` is a single bulk UPDATE backing the future site-wide danger-zone action
- the post-row lock fetch uses `status: 'all'` so the service is eligibility-agnostic - eligibility (gated/published) is enforced at the API layer, not here; without this the Post model's default published-only filter would make ensure/reset throw for any non-published post under a normal admin context
- tokens are 192-bit base64url (crypto.randomBytes) so they are opaque and infeasible to guess
- wired into boot via a singleton wrapper mirroring the comments/recommendations services

Co-Authored-By: Claude Opus 4.8 <[email protected]>
ref https://linear.app/ghost/project/gift-post-links-for-publishers-1959ff241de0/overview

- third slice of gift post links: a standalone `gift_links` admin API resource keyed by the post/page id, so one controller covers posts and pages without duplicating under /posts and /pages; all routes gated by the `giftLinks` flag
- read/ensure/reset require the `manage:gift_link` permission (Admin/Editor) and reset_all requires `resetAll:gift_link` (Admin only; Owner inherits), so the site-wide kill switch is deliberately tighter than per-post management
- ensure/reset enforce eligibility (published + non-public => 422 otherwise); read only requires the post to exist so a publisher can still inspect or reset a link on a post that later became ineligible
- the API returns the token and counters but not a URL: the admin already holds each post's canonical url and composes the share link client-side, which keeps the serializer off the url-service (whose in-memory map isn't populated in admin-only contexts)
- added the gift_link permissions to the test fixtures too (the e2e DB seeds from them), bumping the migration-test permission count and the fixture relation count accordingly

Co-Authored-By: Claude Opus 4.8 <[email protected]>
ref https://linear.app/ghost/project/gift-post-links-for-publishers-1959ff241de0/overview

- fourth slice (part 1) of gift post links: an anonymous visitor at /{slug}/?gift=TOKEN now reads the full gated post/page, with no account and forwarding allowed
- a frontend middleware resolves the token to a content-only, request-scoped grant (res.locals.giftLink) that forPost applies only when the token's post id matches the rendered post; it is never a synthetic member, and the grant is not injectable over the public/admin API (context is built server-side)
- member-only gated blocks are revealed and non-member CTAs hidden under a gift, threaded through stripGatedBlocks/checkGatedBlockAccess (backward-compatible)
- caching correctness on Pro is treated as first-order: any ?gift= request is no-store at the HTTP layer (mirrors /p/ previews) and noindex + no-referrer; crucially the posts-public internal response cache (which sits behind Fastly, so the param bypass can't protect it) now keys by the gift post id, so an unlocked response can never be served to an anonymous reader from a shared cache - reset stays instant because the token is re-validated against the DB every request
- adversarial review (two independent passes) caught the internal-cache poisoning vector; both the fix and the grant scoping are covered by unit tests, plus an e2e-frontend test proving anon paywalled / valid token unlocked + no-store + noindex / invalid token paywalled

Co-Authored-By: Claude Opus 4.8 <[email protected]>
ref https://linear.app/ghost/project/gift-post-links-for-publishers-1959ff241de0/overview

- fourth slice (part 2) of gift post links: each valid human gift read bumps redeemed_count + last_redeemed_at, giving publishers a leak signal (a link being read far more than expected = forwarded/leaked)
- counted in the entry controller only when the rendered post is the gift's own post; the counter write is fire-and-forget (and wrapped) so read-counting never blocks or breaks rendering
- bot filtering deliberately matches `bot`/specific fetcher tokens, not bare brand names: social-app in-app browsers are real humans whose UAs carry the brand (Twitter/LinkedInApp/FBAN/WhatsApp), and gift links spread mainly through those apps - matching bare brands would drop the dominant human channel (caught in review)
- de-dup uses a per-post cookie (gift_seen_<post_id>, value = token) scoped to the full request path including any subdirectory, so reading several gifted posts can't collide and subdir installs de-dupe correctly (both caught in review); Secure on HTTPS, HttpOnly, only ever set on the no-store gift response so it can't poison a shared cache

Co-Authored-By: Claude Opus 4.8 <[email protected]>
ref https://linear.app/ghost/project/gift-post-links-for-publishers-1959ff241de0/overview

- fifth slice of gift post links: a gift reader now sees a conversion callout below the unlocked post inviting them to subscribe (anonymous) or upgrade (logged-in free member)
- rendered through the {{content}} helper, like the existing paywall CTA, so it needs zero theme changes and is overridable via partials/gift-callout.hbs; the resolved gift link is exposed to templates as @gift and the callout only renders on the gift's own post (guards against showing it on related/public posts in the same render)
- copy is context-aware via @member and uses {{t}} for theme translation; exact placement/visual is left to design - the engineering commitment is the mechanism
- covered by content-helper unit tests (renders for the gift post, not for other posts / non-gift reads, upgrade vs subscribe CTA) and an e2e-frontend assertion that the callout appears for a gift reader and not for a normal anonymous visitor

Co-Authored-By: Claude Opus 4.8 <[email protected]>
ref https://linear.app/ghost/project/gift-post-links-for-publishers-1959ff241de0/overview

- foundation for the gift-links admin UI (slice 6): typed admin-x-framework hooks the admin surfaces consume
- useGiftLinkForPost (GET read, non-creating), useEnsureGiftLink (POST create-or-get, fired on copy), useResetGiftLink (PUT reset), useResetAllGiftLinks (PUT site-wide reset for the danger zone)
- read-invalidating mutations so copy/reset refresh the displayed link + count; exposed via the framework's ./api/* package export so each surface imports them directly
- UI components that consume these (PostShareModal, posts-list context menu, editor settings panel, danger-zone action) are deliberately not in this commit: they need browser verification in a running dev environment

Co-Authored-By: Claude Opus 4.8 <[email protected]>
ref https://linear.app/ghost/project/gift-post-links-for-publishers-1959ff241de0/overview

- first gift-links admin UI surface (slice 6): a flag-gated "Reset all gift links" action in Settings -> Advanced -> Danger zone, mirroring the existing reset-auth pattern (confirm modal -> useResetAllGiftLinks -> success toast with the count)
- site-wide reset is intentionally the only gift-links action in the danger zone (Owner/Admin territory); the API already enforces resetAll:gift_link, so the UI just gates visibility on the giftLinks labs flag
- fires the gift_link_reset_all instrumentation event (slice 7) on success
- verified with a Playwright acceptance test (mock API + headless Chromium, no Ghost backend needed): toggles the flag, clicks through the confirm modal, asserts the PUT /gift_links/reset_all/ call and the "Reset 3 gift links" toast; full danger-zone suite stays green
- also pins the reset-all hook payload type to null to match the danger-zone call convention

Co-Authored-By: Claude Opus 4.8 <[email protected]>
ref https://linear.app/ghost/project/gift-post-links-for-publishers-1959ff241de0/overview

- primary gift-links admin surface (slice 6): a "Gift this post" section in the post share modal to copy the link, see how many distinct readers have opened it (a leak signal), and reset it
- keeps the shade PostShareModal presentational by adding an optional giftLinkSlot prop; the data and actions live in apps/posts via a GiftLinkSection component using the admin-x-framework hooks, gated on the giftLinks labs flag
- copy is the idempotent ensure (reuses the active link or mints one on first copy), builds ${post.url}?gift=${token}&utm_campaign=gift-link, and copies to the clipboard; reset mints a fresh token
- instrumentation (slice 7): gift_link_surface_viewed on open, gift_link_copied on copy, gift_link_reset on reset, via a posts trackEvent util
- verified by a pure URL-builder unit test and a GiftLinkSection component test (copy ensures+copies the right URL+tracks; existing link reused without re-create; reset; count display; surface-viewed); typechecks across shade -> posts

Co-Authored-By: Claude Opus 4.8 <[email protected]>
ref https://linear.app/ghost/project/gift-post-links-for-publishers-1959ff241de0/overview

- addresses findings from the adversarial + Codex review of the gift-links admin UI
- role-gate the share-modal gift section on Owner/Administrator/Editor (manage:gift_link): Authors/Contributors can reach their own posts' analytics, so flag-gating alone would 403 them on open
- eligibility-gate the section on published + non-public posts to match the API, so the controls never appear on a post that would 422
- copy now always calls the idempotent ensure so it returns the current server token, never a stale one from the read query mid-reset
- consistent gift_link_reset_all instrumentation prop ({surface:'danger-zone'}) and danger-zone search keywords for "gift links"
- re-verified: GiftLinkSection unit/component tests green; danger-zone "Reset all gift links" Playwright acceptance test still green

Co-Authored-By: Claude Opus 4.8 <[email protected]>
ref https://linear.app/ghost/project/gift-post-links-for-publishers-1959ff241de0/overview

- fast-copy gift-link action in the posts/pages list context menu (Ember), mirroring the existing "Copy link to post" pattern
- shown only for a single published, gated (non-public) post/page and only to Owner/Administrator/Editor (manage:gift_link), gated on the giftLinks labs flag
- the task hits the idempotent ensure endpoint (POST /gift_links/:id/), builds ${post.url}?gift=${token}&utm_campaign=gift-link, copies it, and fires the gift_link_copied instrumentation event (slice 7)
- verified via eslint + ember-template-lint; Ember browser verification (ember exam) was not run in this environment

Co-Authored-By: Claude Opus 4.8 <[email protected]>
ref https://linear.app/ghost/project/gift-post-links-for-publishers-1959ff241de0/overview

- final gift-links admin surface (slice 6): a "Copy gift link" action in the editor's post settings menu, next to the post URL
- shown only for a published, gated (non-public) post/page and only to Owner/Administrator/Editor (manage:gift_link), gated on the giftLinks labs flag
- hits the idempotent ensure endpoint (POST /gift_links/:id/), builds ${post.url}?gift=${token}&utm_campaign=gift-link, copies it, and fires the gift_link_copied instrumentation event (slice 7); full copy/count/reset remain available in the post share modal
- verified via eslint + ember-template-lint; Ember browser verification (ember exam) was not run in this environment

Co-Authored-By: Claude Opus 4.8 <[email protected]>
ref https://linear.app/ghost/project/gift-post-links-for-publishers-1959ff241de0/overview

- the editor post-settings menu and posts-list context-menu gift actions never appeared because the admin `feature` service only exposes explicitly-declared labs flags and `giftLinks` was missing; both Ember surfaces read `this.feature.giftLinks`, so neither rendered. Register it with `@feature('giftLinks')` like the other flags
- the share-modal "Copy gift link" silently did nothing because the posts app runs in an embedded admin iframe that lacks the clipboard-write permission, so `navigator.clipboard.writeText` rejects. Add a copy helper with a textarea+execCommand fallback (mirroring shade's own share-modal copy) and use it in GiftLinkSection
- covered by unit tests for the clipboard fallback (async API used when available; execCommand fallback when the API is missing or rejects)

Co-Authored-By: Claude Opus 4.8 <[email protected]>
The share-modal "Copy gift link" action never reached the clipboard: the
ensure/reset mutation hooks invalidate GiftLinksResponseType, but that
dataType was missing from the Ember state-bridge's emberDataTypeMapping, so
the invalidation threw and rejected the mutation before the copy ran. Mapped
it to null (gift links only exist in React admin), which unblocks the copy,
reset, and reset-all hooks alike.

The editor PSM "Copy gift link" button used a non-existent CSS class and a
button variant that doesn't size icons, so the link glyph rendered at full
size. Switched to the established gh-btn-icon pattern used by the other PSM
buttons.

Corrected the copy-to-clipboard helper's comment: the fallback guards against
non-secure contexts where navigator.clipboard is undefined, not an iframe.

Both verified in the browser: copy lands the gift URL on the clipboard and the
PSM button renders correctly.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
The gift-link conversion callout was an unstyled full-width block dumped at
the end of the post body. Rebuilt it as a self-contained, dismissible card
toast — centered along the bottom of the viewport on desktop and full-width
along the bottom on mobile — with scoped styles so it renders consistently on
any theme (themes ship no CSS for it).

Dismissal is a CSS-only checkbox toggle (no inline script — an inline <script>
in a content-helper partial recurses the renderer); the hidden toggle stays
keyboard-focusable with a visible focus ring. Load-bearing layout uses
!important and logical properties (RTL-aware), and the CTA uses a callout-
unique class so a theme's own .gh-btn can't override it. The accent colour
drives the CTA and links via a CSS custom property.

Verified in the browser (render, centering, dismiss) and via unit +
e2e-frontend tests.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Reduced the card padding and vertical rhythm for a tighter feel, and removed
the "Already have an account? Sign in" line — the site already surfaces plenty
of sign-in entry points. Also dropped the now-unused small-text styles.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
The reader callout was shown to anyone viewing a post via a gift link,
including signed-in members (who got an "Upgrade your account" variant).
Members already have account-level sign-in/upgrade entry points, so the
popover was just noise for them. Gated the injection on logged-out readers
only and collapsed the now-unreachable member branch out of the template.

Verified live: a signed-in member opening the gift link gets the full post
with no callout in the DOM; anonymous readers still get it.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
The post-analytics Share button now opens a dropdown (Copy link, gift link,
social shares) instead of the full share modal. The gift entry reads "Generate
gift link" until one exists, then "Copy gift link"; clicking it idempotently
ensures and copies the link. Once a link exists, a cog opens a manage modal
with the full URL, open count, and reset action.

Removed the old in-modal GiftLinkSection (and its test); the count/reset now
live in the manage modal.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
The editor PSM gift control was a prominent full-width button under the post
URL. Moved it directly below the Post access setting (the thing that governs
its availability) and reduced it to a subtle blue text link that reads
"Generate gift link" until one exists, then "Copy gift link", briefly flipping
to "Link copied" on click. Added a URL preview and a Reset action beneath it,
backed by a load-on-show fetch of the existing link.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Updated the reader callout to "This paid post was shared with you" / "You can
read it in full today. Subscribe to go further.", and added a secondary
"Sign in" button alongside "Subscribe" for readers who already have an account.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
The full gift URL was a single non-breaking line, which (via CSS grid's
min-content sizing) blew the dialog past its max width and pushed Copy/Reset
outside the card. Switched the URL to wrap (break-all) in a stacked layout, so
it stays within the card and the changing token tail remains visible after a
reset.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Made the whole link box click-to-copy, with the Copy control reduced to a
top-right affordance that flips to "Copied". Rewrote the modal text in Ghost's
voice: dropped the em dash and the formal "invalidates … can no longer be
opened" phrasing in favour of "Resetting turns off this link and creates a new
one."

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Switched the copy box from a stacked layout to a floated Copy affordance so it
sits in line with the first line of the URL (top-right) and the link wraps
around and beneath it, keeping the box compact and tidy.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Shade's DialogContent ships no built-in close button, so added a top-right X
(DialogClose) mirroring the muted-to-foreground close style used by shade's
ShareModal. Closes on click, Escape, or outside-press.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Replaced the bare copy link + preview with a fuller, on-brand control: a
"Gift link to paid post" label, the link shown as a plain copyable link (chain
icon, not a text field), an open count, and an inline Reset to Cancel/Confirm
flow warning "Current link will stop working". Gave the link an input-height
box and matched the surrounding form-group spacing and type sizes so it keeps
the same label-to-control rhythm as the other sidebar fields.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Reduced the gift link's min-height from a full input height to 30px so it keeps
an input-like rhythm without feeling overly spaced.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Gave the no-link state the same "Gift link to paid post" title as the active
state and replaced the bare blue link with a small outline "Generate gift link"
button mirroring the modal's reset button, so the two states feel consistent.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Replaced the heavy outline generate button with a light text link, retitled the
section to "Gift link", and added the modal's microcopy ("Anyone with this link
can read the full post. No account needed.") to both the empty and active
states. Aligned the count and reset row on a shared baseline so they no longer
sit at different heights.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Reworded the gift link helper text to "Anyone with access to this link can view
the full post" (contextually "page" in the editor sidebar via post.displayName),
and matched the manage modal's description to it.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Nudged the spacing so the link sits evenly between the microcopy and the
count/reset row: a little more room above the link (9px) and less below (6px).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
jonatansberg added a commit that referenced this pull request Jun 16, 2026
ref https://linear.app/ghost/issue/BER-3726

- first slice of the gift-links feature, carved from spike #28625
- adds the gift_links table + model + per-post/reset-all permissions and the
  off-by-default `giftLinks` labs flag
- per-post manage: Admin/Editor/Super Editor/Author (Authors limited to their
  own posts, enforced in the API slice); reset-all: Admin only
- inert: no runtime behaviour until later slices wire up the service, API,
  reader route and admin UI
jonatansberg added a commit that referenced this pull request Jun 16, 2026
ref https://linear.app/ghost/issue/BER-3727

- GiftLinksService (token generation, ensure/reset/resetAll/getActiveByToken) + boot init
- admin API: browse/ensure/reset/reset-all endpoints, output serializer, routes
- reset works on posts that later became ineligible (rotate a leaked link)
- per-post actions piggyback on post-edit permission, so Authors can manage gift
  links only for their own posts; Owner/Admin/Editor/Super Editor manage any
- slice 2 of 4 carving up spike #28625; stacked on BER-3726
jonatansberg added a commit that referenced this pull request Jun 16, 2026
ref https://linear.app/ghost/issue/BER-3728

- /g/<slug>/?key=TOKEN router + controller, token-resolving middleware,
  cache bypass, posts-public cache key, and the documented @gift template
  context (no default reader UI; theme authors opt in via {{#if @gift}})
- content gating honours a gift access grant; bot-filtered, cookie-deduped
  read counting
- fixes: no self-redirect loop under /g/ collections; real errors surface
  instead of 301-to-paywall; bot UA matching no longer false-positives real
  devices; read counting works behind TLS-terminating proxies and dedupes
  across sessions
- slice 3 of 4 carving up spike #28625; stacked on BER-3727
jonatansberg added a commit that referenced this pull request Jun 16, 2026
ref https://linear.app/ghost/issue/BER-3729

- editor: post-settings-menu inline gift-link control (copy / usage /
  reset-confirm) and a posts-list context-menu copy action
- settings: "reset all gift links" in the danger zone
- shared app/utils/gift-link.js for the URL builder + eligibility (no more
  duplicated/drifting copies); clipboard reports real success/failure;
  context-menu surfaces API errors instead of freezing
- eligibility covers Owner/Admin/Editor/Super Editor/Author (Authors limited
  to their own posts server-side), matching the API permission grant
- dropped the dead React modal leftovers; kept only useResetAllGiftLinks
- slice 4 of 4 carving up spike #28625; stacked on BER-3728
jonatansberg added a commit that referenced this pull request Jun 16, 2026
ref https://linear.app/ghost/issue/BER-3726

- first slice of the gift-links feature, carved from spike #28625
- adds the gift_links table + model + per-post/reset-all permissions and the
  off-by-default `giftLinks` labs flag
- per-post manage: Admin/Editor/Super Editor/Author (Authors limited to their
  own posts, enforced in the API slice); reset-all: Admin only
- inert: no runtime behaviour until later slices wire up the service, API,
  reader route and admin UI
jonatansberg added a commit that referenced this pull request Jun 17, 2026
ref https://linear.app/ghost/issue/BER-3727

- GiftLinksService (token generation, ensure/reset/resetAll/getActiveByToken) + boot init
- admin API: browse/ensure/reset/reset-all endpoints, output serializer, routes
- reset works on posts that later became ineligible (rotate a leaked link)
- per-post actions piggyback on post-edit permission, so Authors can manage gift
  links only for their own posts; Owner/Admin/Editor/Super Editor manage any
- slice 2 of 4 carving up spike #28625; stacked on BER-3726
jonatansberg added a commit that referenced this pull request Jun 17, 2026
ref https://linear.app/ghost/issue/BER-3728

- /g/<slug>/?key=TOKEN router + controller, token-resolving middleware,
  cache bypass, posts-public cache key, and the documented @gift template
  context (no default reader UI; theme authors opt in via {{#if @gift}})
- content gating honours a gift access grant; bot-filtered, cookie-deduped
  read counting
- fixes: no self-redirect loop under /g/ collections; real errors surface
  instead of 301-to-paywall; bot UA matching no longer false-positives real
  devices; read counting works behind TLS-terminating proxies and dedupes
  across sessions
- slice 3 of 4 carving up spike #28625; stacked on BER-3727
jonatansberg added a commit that referenced this pull request Jun 17, 2026
ref https://linear.app/ghost/issue/BER-3729

- editor: post-settings-menu inline gift-link control (copy / usage /
  reset-confirm) and a posts-list context-menu copy action
- settings: "reset all gift links" in the danger zone
- shared app/utils/gift-link.js for the URL builder + eligibility (no more
  duplicated/drifting copies); clipboard reports real success/failure;
  context-menu surfaces API errors instead of freezing
- eligibility covers Owner/Admin/Editor/Super Editor/Author (Authors limited
  to their own posts server-side), matching the API permission grant
- dropped the dead React modal leftovers; kept only useResetAllGiftLinks
- slice 4 of 4 carving up spike #28625; stacked on BER-3728
jonatansberg added a commit that referenced this pull request Jun 17, 2026
ref https://linear.app/ghost/issue/BER-3727

- GiftLinksService (token generation, ensure/reset/resetAll/getActiveByToken) + boot init
- admin API: browse/ensure/reset/reset-all endpoints, output serializer, routes
- reset works on posts that later became ineligible (rotate a leaked link)
- per-post actions piggyback on post-edit permission, so Authors can manage gift
  links only for their own posts; Owner/Admin/Editor/Super Editor manage any
- slice 2 of 4 carving up spike #28625; stacked on BER-3726
jonatansberg added a commit that referenced this pull request Jun 17, 2026
ref https://linear.app/ghost/issue/BER-3728

- /g/<slug>/?key=TOKEN router + controller, token-resolving middleware,
  cache bypass, posts-public cache key, and the documented @gift template
  context (no default reader UI; theme authors opt in via {{#if @gift}})
- content gating honours a gift access grant; bot-filtered, cookie-deduped
  read counting
- fixes: no self-redirect loop under /g/ collections; real errors surface
  instead of 301-to-paywall; bot UA matching no longer false-positives real
  devices; read counting works behind TLS-terminating proxies and dedupes
  across sessions
- slice 3 of 4 carving up spike #28625; stacked on BER-3727
jonatansberg added a commit that referenced this pull request Jun 17, 2026
ref https://linear.app/ghost/issue/BER-3729

- editor: post-settings-menu inline gift-link control (copy / usage /
  reset-confirm) and a posts-list context-menu copy action
- settings: "reset all gift links" in the danger zone
- shared app/utils/gift-link.js for the URL builder + eligibility (no more
  duplicated/drifting copies); clipboard reports real success/failure;
  context-menu surfaces API errors instead of freezing
- eligibility covers Owner/Admin/Editor/Super Editor/Author (Authors limited
  to their own posts server-side), matching the API permission grant
- dropped the dead React modal leftovers; kept only useResetAllGiftLinks
- slice 4 of 4 carving up spike #28625; stacked on BER-3728
jonatansberg added a commit that referenced this pull request Jun 17, 2026
ref https://linear.app/ghost/issue/BER-3728

- /g/<slug>/?key=TOKEN router + controller, token-resolving middleware,
  cache bypass, posts-public cache key, and the documented @gift template
  context (no default reader UI; theme authors opt in via {{#if @gift}})
- content gating honours a gift access grant; bot-filtered, cookie-deduped
  read counting
- fixes: no self-redirect loop under /g/ collections; real errors surface
  instead of 301-to-paywall; bot UA matching no longer false-positives real
  devices; read counting works behind TLS-terminating proxies and dedupes
  across sessions
- slice 3 of 4 carving up spike #28625; stacked on BER-3727
jonatansberg added a commit that referenced this pull request Jun 17, 2026
ref https://linear.app/ghost/issue/BER-3729

- editor: post-settings-menu inline gift-link control (copy / usage /
  reset-confirm) and a posts-list context-menu copy action
- settings: "reset all gift links" in the danger zone
- shared app/utils/gift-link.js for the URL builder + eligibility (no more
  duplicated/drifting copies); clipboard reports real success/failure;
  context-menu surfaces API errors instead of freezing
- eligibility covers Owner/Admin/Editor/Super Editor/Author (Authors limited
  to their own posts server-side), matching the API permission grant
- dropped the dead React modal leftovers; kept only useResetAllGiftLinks
- slice 4 of 4 carving up spike #28625; stacked on BER-3728
jonatansberg added a commit that referenced this pull request Jun 17, 2026
ref https://linear.app/ghost/issue/BER-3727

- GiftLinksService (token generation, ensure/reset/resetAll/getActiveByToken) + boot init
- admin API: browse/ensure/reset/reset-all endpoints, output serializer, routes
- reset works on posts that later became ineligible (rotate a leaked link)
- per-post actions piggyback on post-edit permission, so Authors can manage gift
  links only for their own posts; Owner/Admin/Editor/Super Editor manage any
- slice 2 of 4 carving up spike #28625; stacked on BER-3726
jonatansberg added a commit that referenced this pull request Jun 17, 2026
ref https://linear.app/ghost/issue/BER-3728

- /g/<slug>/?key=TOKEN router + controller, token-resolving middleware,
  cache bypass, posts-public cache key, and the documented @gift template
  context (no default reader UI; theme authors opt in via {{#if @gift}})
- content gating honours a gift access grant; bot-filtered, cookie-deduped
  read counting
- fixes: no self-redirect loop under /g/ collections; real errors surface
  instead of 301-to-paywall; bot UA matching no longer false-positives real
  devices; read counting works behind TLS-terminating proxies and dedupes
  across sessions
- slice 3 of 4 carving up spike #28625; stacked on BER-3727
jonatansberg added a commit that referenced this pull request Jun 17, 2026
ref https://linear.app/ghost/issue/BER-3729

- editor: post-settings-menu inline gift-link control (copy / usage /
  reset-confirm) and a posts-list context-menu copy action
- settings: "reset all gift links" in the danger zone
- shared app/utils/gift-link.js for the URL builder + eligibility (no more
  duplicated/drifting copies); clipboard reports real success/failure;
  context-menu surfaces API errors instead of freezing
- eligibility covers Owner/Admin/Editor/Super Editor/Author (Authors limited
  to their own posts server-side), matching the API permission grant
- dropped the dead React modal leftovers; kept only useResetAllGiftLinks
- slice 4 of 4 carving up spike #28625; stacked on BER-3728
jonatansberg added a commit that referenced this pull request Jun 17, 2026
ref https://linear.app/ghost/issue/BER-3728

- /g/<slug>/?key=TOKEN router + controller, token-resolving middleware,
  cache bypass, posts-public cache key, and the documented @gift template
  context (no default reader UI; theme authors opt in via {{#if @gift}})
- content gating honours a gift access grant; bot-filtered, cookie-deduped
  read counting
- fixes: no self-redirect loop under /g/ collections; real errors surface
  instead of 301-to-paywall; bot UA matching no longer false-positives real
  devices; read counting works behind TLS-terminating proxies and dedupes
  across sessions
- slice 3 of 4 carving up spike #28625; stacked on BER-3727
jonatansberg added a commit that referenced this pull request Jun 17, 2026
ref https://linear.app/ghost/issue/BER-3729

- editor: post-settings-menu inline gift-link control (copy / usage /
  reset-confirm) and a posts-list context-menu copy action
- settings: "reset all gift links" in the danger zone
- shared app/utils/gift-link.js for the URL builder + eligibility (no more
  duplicated/drifting copies); clipboard reports real success/failure;
  context-menu surfaces API errors instead of freezing
- eligibility covers Owner/Admin/Editor/Super Editor/Author (Authors limited
  to their own posts server-side), matching the API permission grant
- dropped the dead React modal leftovers; kept only useResetAllGiftLinks
- slice 4 of 4 carving up spike #28625; stacked on BER-3728
jonatansberg added a commit that referenced this pull request Jun 17, 2026
ref https://linear.app/ghost/issue/BER-3728

- /g/<slug>/?key=TOKEN router + controller, token-resolving middleware,
  cache bypass, posts-public cache key, and the documented @gift template
  context (no default reader UI; theme authors opt in via {{#if @gift}})
- content gating honours a gift access grant; bot-filtered, cookie-deduped
  read counting
- fixes: no self-redirect loop under /g/ collections; real errors surface
  instead of 301-to-paywall; bot UA matching no longer false-positives real
  devices; read counting works behind TLS-terminating proxies and dedupes
  across sessions
- slice 3 of 4 carving up spike #28625; stacked on BER-3727
jonatansberg added a commit that referenced this pull request Jun 17, 2026
ref https://linear.app/ghost/issue/BER-3729

- editor: post-settings-menu inline gift-link control (copy / usage /
  reset-confirm) and a posts-list context-menu copy action
- settings: "reset all gift links" in the danger zone
- shared app/utils/gift-link.js for the URL builder + eligibility (no more
  duplicated/drifting copies); clipboard reports real success/failure;
  context-menu surfaces API errors instead of freezing
- eligibility covers Owner/Admin/Editor/Super Editor/Author (Authors limited
  to their own posts server-side), matching the API permission grant
- dropped the dead React modal leftovers; kept only useResetAllGiftLinks
- slice 4 of 4 carving up spike #28625; stacked on BER-3728
weylandswart pushed a commit that referenced this pull request Jun 17, 2026
ref https://linear.app/ghost/issue/BER-3727

- GiftLinksService (token generation, ensure/reset/resetAll/getActiveByToken) + boot init
- admin API: browse/ensure/reset/reset-all endpoints, output serializer, routes
- reset works on posts that later became ineligible (rotate a leaked link)
- per-post actions piggyback on post-edit permission, so Authors can manage gift
  links only for their own posts; Owner/Admin/Editor/Super Editor manage any
- slice 2 of 4 carving up spike #28625; stacked on BER-3726
weylandswart pushed a commit that referenced this pull request Jun 17, 2026
ref https://linear.app/ghost/issue/BER-3728

- /g/<slug>/?key=TOKEN router + controller, token-resolving middleware,
  cache bypass, posts-public cache key, and the documented @gift template
  context (no default reader UI; theme authors opt in via {{#if @gift}})
- content gating honours a gift access grant; bot-filtered, cookie-deduped
  read counting
- fixes: no self-redirect loop under /g/ collections; real errors surface
  instead of 301-to-paywall; bot UA matching no longer false-positives real
  devices; read counting works behind TLS-terminating proxies and dedupes
  across sessions
- slice 3 of 4 carving up spike #28625; stacked on BER-3727
weylandswart pushed a commit that referenced this pull request Jun 17, 2026
ref https://linear.app/ghost/issue/BER-3729

- editor: post-settings-menu inline gift-link control (copy / usage /
  reset-confirm) and a posts-list context-menu copy action
- settings: "reset all gift links" in the danger zone
- shared app/utils/gift-link.js for the URL builder + eligibility (no more
  duplicated/drifting copies); clipboard reports real success/failure;
  context-menu surfaces API errors instead of freezing
- eligibility covers Owner/Admin/Editor/Super Editor/Author (Authors limited
  to their own posts server-side), matching the API permission grant
- dropped the dead React modal leftovers; kept only useResetAllGiftLinks
- slice 4 of 4 carving up spike #28625; stacked on BER-3728
jonatansberg added a commit that referenced this pull request Jun 17, 2026
ref https://linear.app/ghost/issue/BER-3729

- editor: post-settings-menu inline gift-link control (copy / usage /
  reset-confirm) and a posts-list context-menu copy action
- settings: "reset all gift links" in the danger zone
- shared app/utils/gift-link.js for the URL builder + eligibility (no more
  duplicated/drifting copies); clipboard reports real success/failure;
  context-menu surfaces API errors instead of freezing
- eligibility covers Owner/Admin/Editor/Super Editor/Author (Authors limited
  to their own posts server-side), matching the API permission grant
- dropped the dead React modal leftovers; kept only useResetAllGiftLinks
- slice 4 of 4 carving up spike #28625; stacked on BER-3728
jonatansberg added a commit that referenced this pull request Jun 17, 2026
ref https://linear.app/ghost/issue/BER-3729

- editor: post-settings-menu inline gift-link control (copy / usage /
  reset-confirm) and a posts-list context-menu copy action
- settings: "reset all gift links" in the danger zone
- shared app/utils/gift-link.js for the URL builder + eligibility (no more
  duplicated/drifting copies); clipboard reports real success/failure;
  context-menu surfaces API errors instead of freezing
- eligibility covers Owner/Admin/Editor/Super Editor/Author (Authors limited
  to their own posts server-side), matching the API permission grant
- dropped the dead React modal leftovers; kept only useResetAllGiftLinks
- slice 4 of 4 carving up spike #28625; stacked on BER-3728
jonatansberg added a commit that referenced this pull request Jun 18, 2026
ref https://linear.app/ghost/issue/BER-3728

- /g/<slug>/?key=TOKEN router + controller, token-resolving middleware,
  cache bypass, posts-public cache key, and the documented @gift template
  context (no default reader UI; theme authors opt in via {{#if @gift}})
- content gating honours a gift access grant; bot-filtered, cookie-deduped
  read counting
- consumes the #28693 gift-links service (getPostByToken / recordRedemption);
  service reached via the frontend proxy seam, not a direct require
- fixes: no self-redirect loop under /g/ collections; real errors surface
  instead of 301-to-paywall; bot UA matching no longer false-positives real
  devices; read counting works behind TLS-terminating proxies and dedupes
  across sessions
- slice 3 of 4 carving up spike #28625; stacked on the gift-links redesign (#28693)
jonatansberg added a commit that referenced this pull request Jun 18, 2026
ref https://linear.app/ghost/issue/BER-3729

- editor: post-settings-menu inline gift-link control (copy / usage /
  reset-confirm) and a posts-list context-menu copy action
- settings: "revoke all gift links" in the danger zone
- shared app/utils/gift-link.js for the URL builder + eligibility (no more
  duplicated/drifting copies); clipboard reports real success/failure;
  context-menu surfaces API errors instead of freezing
- eligibility covers Owner/Admin/Editor/Super Editor/Author (Authors limited
  to their own posts server-side), matching the API permission grant
- consumes the #28693 admin API: copy/reissue via PUT/POST
  /{posts,pages}/:id/gift_link; danger zone via PUT /gift_links/revoke_all
  (renamed from reset_all, response {meta:{count}})
- slice 4 of 4 carving up spike #28625; stacked on the reader slice (BER-3728)
  on top of the gift-links redesign (#28693)
jonatansberg added a commit that referenced this pull request Jun 22, 2026
ref https://linear.app/ghost/issue/BER-3728

- /g/<slug>/?key=TOKEN router + controller, token-resolving middleware,
  cache bypass, posts-public cache key, and the documented @gift template
  context (no default reader UI; theme authors opt in via {{#if @gift}})
- content gating honours a gift access grant; bot-filtered, cookie-deduped
  read counting
- consumes the #28693 gift-links service (getPostByToken / recordRedemption);
  service reached via the frontend proxy seam, not a direct require
- fixes: no self-redirect loop under /g/ collections; real errors surface
  instead of 301-to-paywall; bot UA matching no longer false-positives real
  devices; read counting works behind TLS-terminating proxies and dedupes
  across sessions
- slice 3 of 4 carving up spike #28625; stacked on the gift-links redesign (#28693)
jonatansberg added a commit that referenced this pull request Jun 22, 2026
ref https://linear.app/ghost/issue/BER-3729

- editor: post-settings-menu inline gift-link control (copy / usage /
  reset-confirm) and a posts-list context-menu copy action
- settings: "revoke all gift links" in the danger zone
- shared app/utils/gift-link.js for the URL builder + eligibility (no more
  duplicated/drifting copies); clipboard reports real success/failure;
  context-menu surfaces API errors instead of freezing
- eligibility covers Owner/Admin/Editor/Super Editor/Author (Authors limited
  to their own posts server-side), matching the API permission grant
- consumes the #28693 admin API: copy/reissue via PUT/POST
  /{posts,pages}/:id/gift_link; danger zone via PUT /gift_links/revoke_all
  (renamed from reset_all, response {meta:{count}})
- slice 4 of 4 carving up spike #28625; stacked on the reader slice (BER-3728)
  on top of the gift-links redesign (#28693)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

migration [pull request] Includes migration for review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant