fix(email): resolve recipient language from the queue row's event_id, not just email_data
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.
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user