feat: Ability to overwrite locale on contact level with locale key on data

This commit is contained in:
Dries Augustyns
2025-12-25 17:37:25 +01:00
parent fa9e9de032
commit 76155232a3
4 changed files with 45 additions and 4 deletions
+11 -1
View File
@@ -214,11 +214,21 @@ export class Contacts {
// Fetch project to get language preference
const project = await ContactService.getProjectByContactId(contactId);
// Get contact-level locale (overrides project language)
const contactLocale =
contact.data &&
typeof contact.data === 'object' &&
!Array.isArray(contact.data) &&
'locale' in contact.data &&
typeof contact.data.locale === 'string'
? contact.data.locale
: null;
return res.status(200).json({
id: contact.id,
email: contact.email,
subscribed: contact.subscribed,
language: project?.language || 'en',
language: contactLocale || project?.language || 'en',
});
}