From 10559fd68e77eb00f3dd79366fcbb7880321e6b8 Mon Sep 17 00:00:00 2001 From: Luca <102960244+Luca-Timo@users.noreply.github.com> Date: Thu, 25 Jun 2026 19:50:08 +0200 Subject: [PATCH] fix(email): resolve recipient language from the queue row's event_id, not just email_data MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Language priority is event.language → customer preferred_language → app default → … → en, but it was keyed on email_data.eventId, which only queueEmail injects. Direct email_queue inserts (e.g. the gallery-publish "notify customer" path) set the event_id COLUMN but not email_data.eventId, so those mails skipped event.language and fell through to the default — e.g. a gallery-ready mail in EN while the same event's pre-event reminder (sent via queueEmail) was DE. The processor now backfills emailData.eventId from the authoritative event_id column before rendering, so every send path resolves language from the event consistently. --- backend/src/services/emailProcessor.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/backend/src/services/emailProcessor.js b/backend/src/services/emailProcessor.js index 42a454aa..65be426d 100644 --- a/backend/src/services/emailProcessor.js +++ b/backend/src/services/emailProcessor.js @@ -860,10 +860,19 @@ async function processEmailQueue({ ignoreSchedule = false, limit = 10, onlyId = for (const email of pendingEmails) { try { - const emailData = typeof email.email_data === 'string' + const emailData = typeof email.email_data === 'string' ? JSON.parse(email.email_data || '{}') : email.email_data || {}; - + + // Language is resolved from emailData.eventId (event.language is the top + // priority). queueEmail injects it, but direct email_queue inserts (e.g. + // the gallery-publish notification) only set the event_id COLUMN — so + // backfill from the authoritative column so every send path resolves the + // recipient language from the event consistently. + if (emailData.eventId == null && email.event_id != null) { + emailData.eventId = email.event_id; + } + const sendResult = await sendTemplateEmail( email.recipient_email, email.email_type,