From 2df9fcce971ef1a9920f5aace1306523d416cf4a Mon Sep 17 00:00:00 2001 From: Murtaza Patrawala <34130764+murtaza98@users.noreply.github.com> Date: Mon, 3 Jan 2022 21:20:59 +0530 Subject: [PATCH] [FIX] Omnichannel enabled setting not working when creating rooms (#24067) * Fix omnichannel enabled setting not working when creating rooms * Revert changes to translation file * Apply suggestions from code review --- app/livechat/server/lib/Livechat.js | 3 +++ app/settings/server/CachedSettings.ts | 1 + 2 files changed, 4 insertions(+) diff --git a/app/livechat/server/lib/Livechat.js b/app/livechat/server/lib/Livechat.js index 8624924c210..f57127cd58f 100644 --- a/app/livechat/server/lib/Livechat.js +++ b/app/livechat/server/lib/Livechat.js @@ -156,6 +156,9 @@ export const Livechat = { }, async getRoom(guest, message, roomInfo, agent, extraData) { + if (!this.enabled()) { + throw new Meteor.Error('error-omnichannel-is-disabled'); + } Livechat.logger.debug(`Attempting to find or create a room for visitor ${guest._id}`); let room = LivechatRooms.findOneById(message.rid); let newRoom = false; diff --git a/app/settings/server/CachedSettings.ts b/app/settings/server/CachedSettings.ts index 538487cc3ed..814003dc4d6 100644 --- a/app/settings/server/CachedSettings.ts +++ b/app/settings/server/CachedSettings.ts @@ -220,6 +220,7 @@ export class CachedSettings * Gets the current value of the setting * @remarks * - In development mode if you are trying to get the value of a setting that is not defined, it will give an warning, in theory it makes sense, there no reason to do that + * - The setting's value will be cached in memory so it won't call the DB every time you fetch a particular setting * @param _id - The setting id * @returns {SettingValue} - The current value of the setting */