Added gift subscription notification columns to users table#27304
Added gift subscription notification columns to users table#27304
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughAdded two migration files that add 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
It looks like this PR contains a migration 👀 General requirements
Schema changes
Data changes
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@ghost/core/core/server/data/schema/schema.js`:
- Around line 185-186: The new schema fields
gift_subscription_purchase_notification and
gift_subscription_redemption_notification were added but not wired into user
notification behavior; update ghost/core/core/server/models/user.js by adding
these two keys to the user defaults block (alongside the other notification
defaults) and add recipient-filter branches in the recipient filtering logic
where filter strings are built (the code that appends "+...:true") to include
checks for gift_subscription_purchase_notification and
gift_subscription_redemption_notification so opt-outs are respected when
selecting recipients. Ensure you reference the existing default names and the
same "+...:true" filter pattern used for other notification types.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: acbb45a0-8165-4f22-812a-58a979b6837c
📒 Files selected for processing (4)
ghost/core/core/server/data/migrations/versions/6.28/2026-04-09-13-25-36-add-gift-subscription-purchase-notification-column.jsghost/core/core/server/data/migrations/versions/6.28/2026-04-09-13-25-51-add-gift-subscription-redemption-notification-column.jsghost/core/core/server/data/schema/schema.jsghost/core/test/unit/server/data/schema/integrity.test.js
| gift_subscription_purchase_notification: {type: 'boolean', nullable: false, defaultTo: true}, | ||
| gift_subscription_redemption_notification: {type: 'boolean', nullable: false, defaultTo: true}, |
There was a problem hiding this comment.
Wire the new notification columns into user notification behavior.
Line 185 and Line 186 add persisted preferences, but ghost/core/core/server/models/user.js (defaults at Line 61-Line 76, filter logic at Line 500-Line 516) does not yet include these fields. As-is, gift notification opt-outs may not be enforced when recipients are selected.
Suggested follow-up (outside this file)
// ghost/core/core/server/models/user.js (defaults)
defaults: function defaults() {
return {
...
donation_notifications: true,
+ gift_subscription_purchase_notification: true,
+ gift_subscription_redemption_notification: true
};
}Also add corresponding recipient-filter branches for the gift notification event types in ghost/core/core/server/models/user.js where filter += '+...:true' is built.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@ghost/core/core/server/data/schema/schema.js` around lines 185 - 186, The new
schema fields gift_subscription_purchase_notification and
gift_subscription_redemption_notification were added but not wired into user
notification behavior; update ghost/core/core/server/models/user.js by adding
these two keys to the user defaults block (alongside the other notification
defaults) and add recipient-filter branches in the recipient filtering logic
where filter strings are built (the code that appends "+...:true") to include
checks for gift_subscription_purchase_notification and
gift_subscription_redemption_notification so opt-outs are respected when
selecting recipients. Ensure you reference the existing default names and the
same "+...:true" filter pattern used for other notification types.
There was a problem hiding this comment.
Implementation will be done in a follow up PR
There was a problem hiding this comment.
@mike182uk, understood! Would you like me to open a GitHub issue to track wiring gift_subscription_purchase_notification and gift_subscription_redemption_notification into ghost/core/core/server/models/user.js (defaults block and recipient-filter logic) so it's not forgotten?
🧠 Learnings used
Learnt from: rob-ghost
Repo: TryGhost/Ghost PR: 25791
File: ghost/core/core/server/api/endpoints/member-comment-ban.js:64-68
Timestamp: 2026-01-08T10:26:38.700Z
Learning: In the Ghost API, endpoints rely on the serialization layer to prepare frame.data[docName] as a non-empty array before query() executes. Endpoints access frame.data[docName][0] directly (e.g., frame.data.comment_bans[0], frame.data.members[0], frame.data.posts[0]) without per-endpoint validation. This pattern is common across API endpoints. When maintaining or creating endpoints, avoid duplicating validation for frame.data[docName] and ensure the serializer guarantees the shape and non-emptiness. If you add a new endpoint that uses this frame.data[docName], follow the same assumption and avoid redundant checks unless there's a documented exception.
Learnt from: rob-ghost
Repo: TryGhost/Ghost PR: 26219
File: ghost/core/test/e2e-api/members-comments/comments.test.js:939-983
Timestamp: 2026-02-04T15:58:09.124Z
Learning: In Ghost core tests and code that interact with the Ghost comments API, count.replies is a backward-compatible alias for count.total_replies (all descendants via parent_id) and does not represent direct replies. The new field count.direct_replies returns tree-native direct reply counts. Reviewers should verify any code paths, tests, or API surface areas that rely on count.replies are preserved for compatibility, and consider updating or adding tests to cover count.direct_replies for direct counts. When updating or adding tests, ensure behavior is documented and that any assertions reflect the distinction between total (including descendants) and direct reply counts to avoid regressions in API consumer expectations.
Learnt from: sagzy
Repo: TryGhost/Ghost PR: 26995
File: ghost/core/core/server/data/schema/schema.js:1207-1207
Timestamp: 2026-03-31T21:52:45.344Z
Learning: In the Ghost (TryGhost/Ghost) schema, tier records stored in the `products` table are not deletable; they can only be archived. Therefore, for foreign key columns that reference `products.id` (e.g., `tier_id` in tables like `gifts`/`subscriptions`), do not require or flag an explicit `cascadeDelete`/cascade-delete policy. Omitting cascade delete for these `products.id` references is intentional and correct—only flag cascade-related issues for actual deletable parent entities.
Learnt from: vershwal
Repo: TryGhost/Ghost PR: 27290
File: ghost/core/package.json:76-77
Timestamp: 2026-04-09T09:44:26.783Z
Learning: In the TryGhost/Ghost monorepo, treat `tryghost/admin-api-schema` as the single abstraction layer over AJV version differences. Do not raise code review findings for AJV-internal error field changes (e.g., `dataPath` → `instancePath` between AJV v6 and v8) when evaluating Ghost consumer code. The consumer-facing error contract for this package (`ValidationError` with `message`, `property`, `errorDetails`) is expected to remain stable, and Ghost wrapper code should not inspect raw AJV error objects—so review should focus on the stable `ValidationError` shape rather than AJV internals.
E2E Tests FailedTo view the Playwright test report locally, run: REPORT_DIR=$(mktemp -d) && gh run download 24192969177 -n playwright-report -D "$REPORT_DIR" && npx playwright show-report "$REPORT_DIR" |
cd3a9a2 to
ff8dae9
Compare
sagzy
left a comment
There was a problem hiding this comment.
LGTM. The migration PR is doing a bit more than usual, but feels fairly safe as it's a new setting
ref https://linear.app/ghost/issue/BER-3523 Added gift subscription notification columns to the `users` table so a user can configure if they want to recieve these notifications
ff8dae9 to
49501b5
Compare
|



ref https://linear.app/ghost/issue/BER-3523
Added gift subscription notification columns to the
userstable so a user can configure if they want to receive notifications for gift subscription related actions (purchase, redemption)