Skip to content

Gift links: data foundation, model, permissions & labs flag - #28626

Merged
jonatansberg merged 1 commit into
mainfrom
ber-3726-gift-links-data-foundation
Jun 16, 2026
Merged

jonatansberg merged 1 commit into
mainfrom
ber-3726-gift-links-data-foundation

Conversation

@jonatansberg

Copy link
Copy Markdown
Member

Adds the data foundation for gift links: the gift_links table, GiftLink model, exporter wiring, and the manage/reset-all permissions (Administrator/Editor/Super Editor manage; Administrator-only reset-all). Also registers the off-by-default giftLinks labs flag plus its dev-experiments toggle.

Inert: no runtime behaviour until later slices wire up the service, API, reader route and admin UI. This is slice 1 of 4 carving up spike PR #28625.

ref https://linear.app/ghost/issue/BER-3726

@coderabbitai

coderabbitai Bot commented Jun 16, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: ad5ecb4a-e4b7-43ff-b043-ecc9c49c3822

📥 Commits

Reviewing files that changed from the base of the PR and between 35dfc0a and 4ba013d.

⛔ Files ignored due to path filters (1)
  • ghost/core/test/e2e-api/admin/__snapshots__/config.test.js.snap is excluded by !**/*.snap
📒 Files selected for processing (15)
  • apps/admin-x-settings/src/components/settings/advanced/labs/private-features.tsx
  • ghost/core/core/server/data/exporter/table-lists.js
  • ghost/core/core/server/data/migrations/versions/6.46/2026-05-29-08-35-51-add-gift-links-table.js
  • ghost/core/core/server/data/migrations/versions/6.46/2026-05-29-08-35-56-add-gift-links-permissions.js
  • ghost/core/core/server/data/schema/fixtures/fixtures.json
  • ghost/core/core/server/data/schema/schema.js
  • ghost/core/core/server/models/gift-link.js
  • ghost/core/core/server/models/index.js
  • ghost/core/core/server/models/post.js
  • ghost/core/core/shared/labs.js
  • ghost/core/test/integration/exporter/exporter.test.js
  • ghost/core/test/integration/migrations/migration.test.js
  • ghost/core/test/unit/server/data/schema/fixtures/fixture-manager.test.js
  • ghost/core/test/unit/server/data/schema/integrity.test.js
  • ghost/core/test/utils/fixtures/fixtures.json

Walkthrough

A new gift_links database table is introduced via schema definition, an addTable migration, and a permissions migration that grants manage access to Administrator, Editor, Super Editor, and Author roles, and resetAll access to Administrator only. A GiftLink Bookshelf model is created with row defaults and a belongsTo Post relation; a hasMany gift_links accessor is added to the Post model. The giftLinks flag is registered in the private labs feature list and in the admin Labs UI. The gift_links table is added to BACKUP_TABLES. Permission fixtures, test integrity hashes, fixture counts, exporter expectations, and migration test assertions are all updated accordingly.

Suggested labels

preview

Suggested reviewers

  • mike182uk
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main changes: adding data foundation, model, permissions, and labs flag for gift links feature.
Description check ✅ Passed The description is directly related to the changeset, detailing the data foundation additions, permissions structure, labs flag registration, and explicitly stating this is inert code pending later implementation slices.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ber-3726-gift-links-data-foundation

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added the migration [pull request] Includes migration for review label Jun 16, 2026
@github-actions

Copy link
Copy Markdown
Contributor

It looks like this PR contains a migration 👀
Here's the checklist for reviewing migrations:

General requirements

  • ⚠️ Tested performance on staging database servers, as performance on local machines is not comparable to a production environment
  • Satisfies idempotency requirement (both up() and down())
  • Does not reference models
  • Filename is in the correct format (and correctly ordered)
  • Targets the next minor version
  • All code paths have appropriate log messages
  • Uses the correct utils
  • Contains a minimal changeset
  • Does not mix DDL/DML operations
  • Tested in MySQL and SQLite

Schema changes

  • Both schema change and related migration have been implemented
  • For index changes: has been performance tested for large tables
  • For new tables/columns: fields use the appropriate predefined field lengths
  • For new tables/columns: field names follow the appropriate conventions
  • Does not drop a non-alpha table outside of a major version

Data changes

  • Mass updates/inserts are batched appropriately
  • Does not loop over large tables/datasets
  • Defends against missing or invalid data
  • For settings updates: follows the appropriate guidelines

@nx-cloud

nx-cloud Bot commented Jun 16, 2026 •

Copy link
Copy Markdown

🤖 Nx Cloud AI Fix

Ensure the fix-ci command is configured to always run in your CI pipeline to get automatic fixes in future runs. For more information, please see https://nx.dev/ci/features/self-healing-ci


View your CI Pipeline Execution ↗ for commit 9ed7a1d

Command Status Duration Result
nx run @tryghost/admin-x-settings:test:acceptance ✅ Succeeded 10m 11s View ↗
nx run ghost:test:ci:integration:no-coverage ✅ Succeeded 1m 50s View ↗
nx run ghost:test:ci:integration ✅ Succeeded 1m 5s View ↗
nx run ghost:test:ci:e2e:no-coverage ✅ Succeeded 3m 51s View ↗
nx run ghost:test:ci:e2e ✅ Succeeded 3m 40s View ↗
nx run ghost:test:ci:legacy ✅ Succeeded 2m 15s View ↗
nx build @tryghost/announcement-bar ✅ Succeeded <1s View ↗
nx build @tryghost/activitypub ✅ Succeeded 3s View ↗
Additional runs (11) ✅ Succeeded ... View ↗

💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗


☁️ Nx Cloud last updated this comment at 2026-06-16 14:52:45 UTC

@jonatansberg jonatansberg left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a missing API snapshot that needs to be updated, otherwise the test will continue to fail.

@jonatansberg
jonatansberg force-pushed the ber-3726-gift-links-data-foundation branch from 9a064db to 9ed7a1d Compare June 16, 2026 14:30
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
jonatansberg marked this pull request as ready for review June 16, 2026 14:38
@jonatansberg
jonatansberg force-pushed the ber-3726-gift-links-data-foundation branch from 9ed7a1d to 4ba013d Compare June 16, 2026 14:39
@jonatansberg

Copy link
Copy Markdown
Member Author

The missing API snapshot is fixed — giftLinks: true is now in test/e2e-api/admin/config.test.js.snap (the new labs flag belongs to this foundation slice, so the snapshot update lives here too). pnpm test:single test/e2e-api/admin/config.test.js is green.

@jonatansberg
jonatansberg enabled auto-merge (rebase) June 16, 2026 14:54
@jonatansberg
jonatansberg merged commit 79c2a83 into main Jun 16, 2026
49 checks passed
@jonatansberg
jonatansberg deleted the ber-3726-gift-links-data-foundation branch June 16, 2026 14:59
Comment on lines +4 to +17
// Per-post create/read/reset — Admin/Editor/Super Editor/Author (Owner inherits all
// permissions). Authors are limited to their own posts; that ownership check lives in
// the gift_links API endpoint, not in the role grant.
addPermissionWithRoles({
name: 'Manage gift links',
action: 'manage',
object: 'gift_link'
}, [
'Administrator',
'Editor',
'Super Editor',
'Author'
]),
// Site-wide reset-all — Admin only (Owner inherits all permissions), tighter than per-post

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Would these comments make sense to duplicate in the fixtures.json file as that's closer to the "source of truth" for our permissions?

assertHavePermission(permissions, 'Delete posts', ['Administrator', 'Editor', 'Author', 'Contributor', 'Admin Integration', 'Super Editor']);
assertHavePermission(permissions, 'Publish posts', ['Administrator', 'Editor', 'Admin Integration', 'Scheduler Integration', 'Super Editor']);
assertHavePermission(permissions, 'Flush gift reminders', ['Scheduler Integration']);
assertHavePermission(permissions, 'Manage gift links', ['Administrator', 'Editor', 'Author', 'Super Editor']);

@kevinansfield kevinansfield Jun 16, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocker: Should Admin integrations have access to gift links so there is programmatic access/management?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a ticket for us to track this

jonatansberg added a commit that referenced this pull request Jun 17, 2026
ref https://linear.app/ghost/issue/BER-3739/admin-integration-access-to-gift-links

- fast-follow to the merged gift-links data foundation (#28626), addressing
  Kevin's review question about programmatic access/management
- grants Admin Integration the same per-post `manage` permission Editors and
  Authors already have, so gift links can be created/reset over the Admin API;
  the endpoint's own edit.post ownership check still applies (integrations hold
  post:all, so they pass it)
- the site-wide `resetAll` kill switch stays Administrator-only — a leaked
  integration key should not be able to nuke every active gift link at once
- migration lands in the same 6.46 cycle as the foundation; fixtures + integrity
  hash + permission-count tests updated to match
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.

3 participants