diff --git a/apps/meteor/app/livechat/server/lib/contacts/createContact.ts b/apps/meteor/app/livechat/server/lib/contacts/createContact.ts index efdcacdbf4ad..98cf238d9b5e 100644 --- a/apps/meteor/app/livechat/server/lib/contacts/createContact.ts +++ b/apps/meteor/app/livechat/server/lib/contacts/createContact.ts @@ -15,6 +15,7 @@ export type CreateContactParams = { contactManager?: string; channels?: ILivechatContactChannel[]; importIds?: string[]; + shouldValidateCustomFields?: boolean; }; export async function createContact({ @@ -27,13 +28,15 @@ export async function createContact({ channels = [], unknown, importIds, + shouldValidateCustomFields = true, }: CreateContactParams): Promise { if (contactManager) { await validateContactManager(contactManager); } - const allowedCustomFields = await getAllowedCustomFields(); - const customFields = validateCustomFields(allowedCustomFields, receivedCustomFields); + const customFields = shouldValidateCustomFields + ? validateCustomFields(await getAllowedCustomFields(), receivedCustomFields) + : receivedCustomFields; return LivechatContacts.insertContact({ name, diff --git a/apps/meteor/app/livechat/server/lib/contacts/mapVisitorToContact.spec.ts b/apps/meteor/app/livechat/server/lib/contacts/mapVisitorToContact.spec.ts index 3f4d74430280..c8c15fe0d0d9 100644 --- a/apps/meteor/app/livechat/server/lib/contacts/mapVisitorToContact.spec.ts +++ b/apps/meteor/app/livechat/server/lib/contacts/mapVisitorToContact.spec.ts @@ -53,6 +53,7 @@ const dataMap: [Partial, IOmnichannelSource, CreateContactPara }, ], customFields: undefined, + shouldValidateCustomFields: false, contactManager: 'manager1', }, ], @@ -87,6 +88,7 @@ const dataMap: [Partial, IOmnichannelSource, CreateContactPara }, ], customFields: undefined, + shouldValidateCustomFields: false, contactManager: undefined, }, ], @@ -130,6 +132,7 @@ const dataMap: [Partial, IOmnichannelSource, CreateContactPara }, ], customFields: undefined, + shouldValidateCustomFields: false, lastChat: { _id: 'last-chat-id', ts: testDate, @@ -175,6 +178,7 @@ const dataMap: [Partial, IOmnichannelSource, CreateContactPara customFields: { customFieldId: 'customFieldValue', }, + shouldValidateCustomFields: false, contactManager: undefined, }, ], diff --git a/apps/meteor/app/livechat/server/lib/contacts/mapVisitorToContact.ts b/apps/meteor/app/livechat/server/lib/contacts/mapVisitorToContact.ts index a35d41e9beca..6478fd1911f8 100644 --- a/apps/meteor/app/livechat/server/lib/contacts/mapVisitorToContact.ts +++ b/apps/meteor/app/livechat/server/lib/contacts/mapVisitorToContact.ts @@ -33,6 +33,7 @@ export async function mapVisitorToContact(visitor: ILivechatVisitor, source: IOm ignoreAdditionalFields: true, ignoreValidationErrors: true, }), + shouldValidateCustomFields: false, lastChat: visitor.lastChat, contactManager: visitor.contactManager?.username && (await getContactManagerIdByUsername(visitor.contactManager.username)), };