From 05910ba464b41b93d65c3188c203a64b77c6a3d2 Mon Sep 17 00:00:00 2001 From: Benjamin Arias Date: Wed, 23 Nov 2022 17:24:47 +0100 Subject: [PATCH] =?UTF-8?q?Ajoute=20un=20nickname=20par=20d=C3=A9fault=20p?= =?UTF-8?q?our=20les=20retours=20utilisateur=20sans=20email=20(#2396)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix: Ajoute un nickname par défaut --- server/source/functions/send-crisp-message.ts | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/server/source/functions/send-crisp-message.ts b/server/source/functions/send-crisp-message.ts index cedacd682..01147e6e7 100644 --- a/server/source/functions/send-crisp-message.ts +++ b/server/source/functions/send-crisp-message.ts @@ -29,9 +29,9 @@ type SendMessageParamsType = { } type ConversationMetaType = { - email: string + email?: string subject: string - nickname: string + nickname?: string } type CrispType = { @@ -68,11 +68,21 @@ export const sendCrispMessage = async (body: BodyType) => { const { session_id: sessionId } = result - await CrispClient.website.updateConversationMetas(WEBSITE_ID, sessionId, { - email, - nickname: email, + const metas: ConversationMetaType = { subject, - }) + nickname: 'Utilisateur inconnu (email non renseigné)', // Default value if no email + } + + if (email) { + metas.email = email + metas.nickname = email + } + + await CrispClient.website.updateConversationMetas( + WEBSITE_ID, + sessionId, + metas + ) CrispClient.website.sendMessageInConversation( WEBSITE_ID,