Skip to content

Changed member welcome email job to run based on config#19

Open
tomerqodo wants to merge 6 commits intocopilot_combined_20260121_qodo_grep_cursor_copilot_1_base_changed_member_welcome_email_job_to_run_based_on_config_pr246from
copilot_combined_20260121_qodo_grep_cursor_copilot_1_head_changed_member_welcome_email_job_to_run_based_on_config_pr246
Open

Changed member welcome email job to run based on config#19
tomerqodo wants to merge 6 commits intocopilot_combined_20260121_qodo_grep_cursor_copilot_1_base_changed_member_welcome_email_job_to_run_based_on_config_pr246from
copilot_combined_20260121_qodo_grep_cursor_copilot_1_head_changed_member_welcome_email_job_to_run_based_on_config_pr246

Conversation

@tomerqodo
Copy link

Benchmark PR from qodo-benchmark#246

Copilot AI review requested due to automatic review settings January 21, 2026 17:53
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request changes the member welcome email feature from using a lab feature flag (welcomeEmails) to a config-based approach (memberWelcomeEmailTestInbox). The change aims to control welcome email functionality through configuration rather than feature flags.

Changes:

  • Replaced labsService.isSet('welcomeEmails') checks with config.get('memberWelcomeEmailTestInbox') checks
  • Updated test files to use config stubs/utilities instead of labs stubs
  • Removed labsService dependency from affected components

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.

File Description
ghost/core/core/server/services/members/members-api/repositories/MemberRepository.js Updated member creation logic to check config instead of lab flag for welcome email outbox entry creation
ghost/core/core/server/services/member-welcome-emails/jobs/index.js Modified job scheduler to check config instead of lab flag before scheduling welcome email processing
ghost/core/test/unit/server/services/members/members-api/repositories/MemberRepository.test.js Updated unit tests to stub config instead of labsService
ghost/core/test/integration/services/member-welcome-emails.test.js Updated integration tests to use configUtils instead of sinon stubs for labs

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

if (this._labsService.isSet('welcomeEmails') && WELCOME_EMAIL_SOURCES.includes(source)) {
var member;
const welcomeEmailConfig = config.get('memberWelcomeEmailTestInbox');
if (welcomeEmailConfig || WELCOME_EMAIL_SOURCES.includes(source)) {
Copy link

Copilot AI Jan 21, 2026

Choose a reason for hiding this comment

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

The logical operator should be AND (&&) instead of OR (||). The current logic creates an outbox entry whenever either the config is set OR the source is in the allowed list, but it should only create an entry when BOTH conditions are true (config is set AND source is allowed). This means welcome emails would be sent for disallowed sources like 'import' or 'admin' as long as the config is set.

Suggested change
if (welcomeEmailConfig || WELCOME_EMAIL_SOURCES.includes(source)) {
if (welcomeEmailConfig && WELCOME_EMAIL_SOURCES.includes(source)) {

Copilot uses AI. Check for mistakes.
}

if (!hasScheduled.processOutbox && !process.env.NODE_ENV.startsWith('test')) {
if (hasScheduled.processOutbox && !process.env.NODE_ENV.startsWith('test')) {
Copy link

Copilot AI Jan 21, 2026

Choose a reason for hiding this comment

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

The negation operator is missing. This should be !hasScheduled.processOutbox instead of hasScheduled.processOutbox. With the current logic, the job will only be scheduled if it has already been scheduled, which means it will never be scheduled on the first run. This prevents the welcome email job from ever being scheduled.

Suggested change
if (hasScheduled.processOutbox && !process.env.NODE_ENV.startsWith('test')) {
if (!hasScheduled.processOutbox && !process.env.NODE_ENV.startsWith('test')) {

Copilot uses AI. Check for mistakes.
const memberAddOptions = {...(options || {}), withRelated};
let member;
if (this._labsService.isSet('welcomeEmails') && WELCOME_EMAIL_SOURCES.includes(source)) {
var member;
Copy link

Copilot AI Jan 21, 2026

Choose a reason for hiding this comment

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

Use 'let' or 'const' instead of 'var' for block-scoped variable declaration. The use of 'var' is discouraged in modern JavaScript as it has function scope rather than block scope, which can lead to unexpected behavior.

Suggested change
var member;
let member;

Copilot uses AI. Check for mistakes.

it('does NOT create outbox entry when config is not set', async function () {
configUtils.set('memberWelcomeEmailTestInbox', '');
Copy link

Copilot AI Jan 21, 2026

Choose a reason for hiding this comment

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

Remove trailing whitespace at the end of this line.

Copilot uses AI. Check for mistakes.
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.

3 participants