Skip to content

SPIKE - DO NOT MERGE: Added updates and announcements preference toggle#28643

Draft
troyciesco wants to merge 1 commit into
mainfrom
NY-1314_email-updates-and-announcements
Draft

SPIKE - DO NOT MERGE: Added updates and announcements preference toggle#28643
troyciesco wants to merge 1 commit into
mainfrom
NY-1314_email-updates-and-announcements

Conversation

@troyciesco

Copy link
Copy Markdown
Contributor

closes NY-1314

TK

NOTE: can't merge as is, it has some migrations and is missing i18n

@coderabbitai

coderabbitai Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 4311bf3c-ad3a-46f6-aff7-511a4a078e54

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch NY-1314_email-updates-and-announcements

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
@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 854343e

Command Status Duration Result
nx run ghost:test:ci:e2e ❌ Failed 30s View ↗
nx run ghost:test:ci:legacy ✅ Succeeded 2m 14s View ↗
nx build @tryghost/sodo-search ✅ Succeeded <1s View ↗
nx build @tryghost/signup-form ✅ Succeeded <1s View ↗
nx build @tryghost/announcement-bar ✅ Succeeded <1s View ↗
nx build @tryghost/comments-ui ✅ Succeeded <1s View ↗
nx build @tryghost/admin-toolbar ✅ Succeeded <1s View ↗
nx build @tryghost/activitypub ✅ Succeeded 1s View ↗
Additional runs (7) ✅ Succeeded ... View ↗

💡 Dealing with memory or CPU issues? See memory and CPU details with the resource usage add-on ↗.


☁️ Nx Cloud last updated this comment at 2026-06-17 20:39:13 UTC

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
apps/portal/src/actions.js (1)

562-568: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Handle empty newsletter arrays as valid updates.

Line 562 and Line 566 treat newsletters as truthy/falsy, so newsletters: [] is ignored. That makes a valid “unsubscribe from all newsletters” update a no-op.

Proposed fix
-        const {newsletters, enableCommentNotifications, enableUpdatesAndAnnouncements} = data;
-        if (!newsletters && enableCommentNotifications === undefined && enableUpdatesAndAnnouncements === undefined) {
+        const {newsletters, enableCommentNotifications, enableUpdatesAndAnnouncements} = data;
+        const hasNewsletters = newsletters !== undefined;
+        if (!hasNewsletters && enableCommentNotifications === undefined && enableUpdatesAndAnnouncements === undefined) {
             return {};
         }
         const updateData = {};
-        if (newsletters) {
+        if (hasNewsletters) {
             updateData.newsletters = newsletters;
         }

Also applies to: 572-574

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/portal/src/actions.js` around lines 562 - 568, The condition at line 562
and the check at line 566 treat empty arrays as falsy, which prevents empty
newsletter arrays from being processed as valid unsubscribe operations. Replace
the falsy/truthy checks for newsletters with explicit checks against undefined
(using !== undefined) in both the early return condition and the updateData
assignment block. Apply the same fix to the similar newsletter-related checks
mentioned at lines 572-574 to ensure all empty array scenarios are handled
correctly.
🧹 Nitpick comments (1)
ghost/core/core/server/services/mail/ghost-mailer.js (1)

78-81: Clarify header merge intent for maintainability.

The current implementation allows message.headers to override the Sender header since the spread occurs after Sender: addresses.from. If Sender should always be preserved, consider reversing the order:

headers: {
    ...message.headers,
    Sender: addresses.from
}

Current callers (e.g., member welcome emails) only set List-Unsubscribe headers, so no override occurs in practice. However, making the intent explicit prevents accidental Sender overrides in future code.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@ghost/core/core/server/services/mail/ghost-mailer.js` around lines 78 - 81,
The header merge in the ghost-mailer.js file currently sets Sender first and
then spreads message.headers, which allows message.headers to accidentally
override the Sender value. Reverse the order of the spread and the Sender
property in the headers object so that Sender: addresses.from comes after the
spread operator, ensuring the Sender header is always preserved and preventing
unintended overrides by future callers.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@apps/portal/src/actions.js`:
- Around line 562-568: The condition at line 562 and the check at line 566 treat
empty arrays as falsy, which prevents empty newsletter arrays from being
processed as valid unsubscribe operations. Replace the falsy/truthy checks for
newsletters with explicit checks against undefined (using !== undefined) in both
the early return condition and the updateData assignment block. Apply the same
fix to the similar newsletter-related checks mentioned at lines 572-574 to
ensure all empty array scenarios are handled correctly.

---

Nitpick comments:
In `@ghost/core/core/server/services/mail/ghost-mailer.js`:
- Around line 78-81: The header merge in the ghost-mailer.js file currently sets
Sender first and then spreads message.headers, which allows message.headers to
accidentally override the Sender value. Reverse the order of the spread and the
Sender property in the headers object so that Sender: addresses.from comes after
the spread operator, ensuring the Sender header is always preserved and
preventing unintended overrides by future callers.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 5f2c9ba4-4ceb-4e6d-bdf7-5de42632eae1

📥 Commits

Reviewing files that changed from the base of the PR and between 5bb4b45 and 0b55d48.

⛔ Files ignored due to path filters (9)
  • ghost/core/test/e2e-api/admin/__snapshots__/comments.test.js.snap is excluded by !**/*.snap
  • ghost/core/test/e2e-api/admin/__snapshots__/member-commenting.test.js.snap is excluded by !**/*.snap
  • ghost/core/test/e2e-api/admin/__snapshots__/members-edit-subscriptions.test.js.snap is excluded by !**/*.snap
  • ghost/core/test/e2e-api/admin/__snapshots__/members-newsletters.test.js.snap is excluded by !**/*.snap
  • ghost/core/test/e2e-api/admin/__snapshots__/members.test.js.snap is excluded by !**/*.snap
  • ghost/core/test/e2e-api/members/__snapshots__/middleware.test.js.snap is excluded by !**/*.snap
  • ghost/core/test/e2e-api/members/__snapshots__/webhooks.test.js.snap is excluded by !**/*.snap
  • ghost/core/test/e2e-server/__snapshots__/click-tracking.test.js.snap is excluded by !**/*.snap
  • ghost/core/test/e2e-webhooks/__snapshots__/members.test.js.snap is excluded by !**/*.snap
📒 Files selected for processing (28)
  • apps/portal/src/actions.js
  • apps/portal/src/app.js
  • apps/portal/src/components/common/newsletter-management.js
  • apps/portal/src/components/pages/account-email-page.js
  • apps/portal/src/components/pages/unsubscribe-page.js
  • apps/portal/src/utils/api.js
  • ghost/core/core/frontend/services/routing/controllers/unsubscribe.js
  • ghost/core/core/server/api/endpoints/utils/serializers/output/members.js
  • ghost/core/core/server/data/migrations/versions/6.46/2026-06-16-19-42-38-add-enable-updates-and-announcements-to-members.js
  • ghost/core/core/server/data/schema/schema.js
  • ghost/core/core/server/models/member.js
  • ghost/core/core/server/services/automations/poll.ts
  • ghost/core/core/server/services/mail/ghost-mailer.js
  • ghost/core/core/server/services/member-welcome-emails/email-templates/wrapper.hbs
  • ghost/core/core/server/services/member-welcome-emails/member-welcome-email-renderer.js
  • ghost/core/core/server/services/member-welcome-emails/service.js
  • ghost/core/core/server/services/members/members-api/repositories/member-repository.js
  • ghost/core/core/server/services/members/middleware.js
  • ghost/core/core/server/services/members/utils.js
  • ghost/core/core/server/services/settings-helpers/settings-helpers.js
  • ghost/core/test/e2e-api/members/middleware.test.js
  • ghost/core/test/e2e-frontend/members.test.js
  • ghost/core/test/integration/services/member-welcome-emails.test.js
  • ghost/core/test/unit/server/data/schema/integrity.test.js
  • ghost/core/test/unit/server/services/automations/poll.test.ts
  • ghost/core/test/unit/server/services/member-welcome-emails/member-welcome-email-renderer.test.js
  • ghost/core/test/unit/server/services/members/utils.test.js
  • ghost/core/test/unit/server/services/settings-helpers/settings-helpers.test.js

Comment thread ghost/core/core/server/services/automations/poll.ts Outdated
Comment thread ghost/core/core/server/services/settings-helpers/settings-helpers.js Outdated
<p>{t('Occasional updates from {siteTitle}', {siteTitle: site?.title})}</p>
</div>
<div style={{display: 'flex', alignItems: 'center'}}>
<Switch id="updates-and-announcements" onToggle={handleToggle} checked={isChecked} dataTestId="switch-input" />

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

question: Should we disable this while the value is changing?

Comment thread ghost/core/core/server/services/mail/ghost-mailer.js Outdated
Comment thread ghost/core/core/server/services/member-welcome-emails/service.js
@troyciesco troyciesco force-pushed the NY-1314_email-updates-and-announcements branch 2 times, most recently from 1cab587 to 23104b5 Compare June 17, 2026 17:18
@troyciesco troyciesco changed the base branch from main to NY-1314_enable-updates-announcements-migration June 17, 2026 17:18
@troyciesco troyciesco removed the migration [pull request] Includes migration for review label Jun 17, 2026
@TryGhost TryGhost deleted a comment from github-actions Bot Jun 17, 2026
@troyciesco troyciesco force-pushed the NY-1314_enable-updates-announcements-migration branch from f13e585 to 6b3e937 Compare June 17, 2026 18:03
@troyciesco troyciesco force-pushed the NY-1314_email-updates-and-announcements branch from 23104b5 to 42004f6 Compare June 17, 2026 18:29
Base automatically changed from NY-1314_enable-updates-announcements-migration to main June 17, 2026 20:19
@troyciesco troyciesco force-pushed the NY-1314_email-updates-and-announcements branch from 42004f6 to 854343e Compare June 17, 2026 20:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants