From 9045c0d09be1ec728cbaba4be3733d96d6cc963f Mon Sep 17 00:00:00 2001 From: Kevin Aleman Date: Tue, 21 Nov 2023 13:22:49 -0600 Subject: [PATCH] regression: `saveGuest` triggering app events for invalid visitor ids (#31037) --- apps/meteor/app/livechat/server/lib/LivechatTyped.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/apps/meteor/app/livechat/server/lib/LivechatTyped.ts b/apps/meteor/app/livechat/server/lib/LivechatTyped.ts index 27c99d4e100..e9fdfe7050e 100644 --- a/apps/meteor/app/livechat/server/lib/LivechatTyped.ts +++ b/apps/meteor/app/livechat/server/lib/LivechatTyped.ts @@ -1343,6 +1343,12 @@ class LivechatClass { async saveGuest(guestData: Pick & { email?: string; phone?: string }, userId: string) { const { _id, name, email, phone, livechatData = {} } = guestData; + + const visitor = await LivechatVisitors.findOneById(_id, { projection: { _id: 1 } }); + if (!visitor) { + throw new Error('error-invalid-visitor'); + } + this.logger.debug({ msg: 'Saving guest', guestData }); const updateData: { name?: string | undefined;