From 297b4e0c2a2deb83eb32581a60c18f4475e1fc0c Mon Sep 17 00:00:00 2001 From: Murtaza Patrawala <34130764+murtaza98@users.noreply.github.com> Date: Wed, 28 Jul 2021 00:37:43 +0530 Subject: [PATCH] [FIX] Support ID param on createVisitor method (#22772) * FIX createVisitor not supporting id param * Fix build * Apply suggestions for code review Co-authored-by: Kevin Aleman --- app/apps/server/bridges/livechat.ts | 1 + app/livechat/server/lib/Livechat.js | 4 +++- server/features/EmailInbox/EmailInbox_Incoming.ts | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/apps/server/bridges/livechat.ts b/app/apps/server/bridges/livechat.ts index 89abca53362..0ae171c3912 100644 --- a/app/apps/server/bridges/livechat.ts +++ b/app/apps/server/bridges/livechat.ts @@ -127,6 +127,7 @@ export class AppLivechatBridge extends LivechatBridge { email: '', connectionData: undefined, phone: {}, + id: visitor.id, }; if (visitor.visitorEmails && visitor.visitorEmails.length) { diff --git a/app/livechat/server/lib/Livechat.js b/app/livechat/server/lib/Livechat.js index 9f4b2800a5f..04f08efacd4 100644 --- a/app/livechat/server/lib/Livechat.js +++ b/app/livechat/server/lib/Livechat.js @@ -221,8 +221,9 @@ export const Livechat = { return true; }, - registerGuest({ token, name, email, department, phone, username, connectionData } = {}) { + registerGuest({ id, token, name, email, department, phone, username, connectionData } = {}) { check(token, String); + check(id, Match.Maybe(String)); let userId; const updateUser = { @@ -264,6 +265,7 @@ export const Livechat = { const userData = { username, ts: new Date(), + ...id && { _id: id }, }; if (settings.get('Livechat_Allow_collect_and_store_HTTP_header_informations')) { diff --git a/server/features/EmailInbox/EmailInbox_Incoming.ts b/server/features/EmailInbox/EmailInbox_Incoming.ts index d7927f06db3..7ceaff1921a 100644 --- a/server/features/EmailInbox/EmailInbox_Incoming.ts +++ b/server/features/EmailInbox/EmailInbox_Incoming.ts @@ -43,6 +43,7 @@ function getGuestByEmail(email: string, name: string, department?: string): any phone: undefined, username: undefined, connectionData: undefined, + id: undefined, }); const newGuest = LivechatVisitors.findOneById(userId, {});