From 3c6a843bf8bb6755c2806e0cb3559afbc59c54a9 Mon Sep 17 00:00:00 2001 From: Disha Date: Thu, 14 Sep 2023 09:29:39 +0530 Subject: [PATCH] added transalation key for room not served error and fixed minor bugs --- .../livechat/server/hooks/verificationCheck.ts | 2 +- .../hooks/handleNextAgentPreferredEvents.ts | 2 +- .../server/lib/AutoTransferChatScheduler.ts | 2 +- .../packages/rocketchat-i18n/i18n/en.i18n.json | 1 + .../services/omnichannel-verification/service.ts | 16 +++++++++------- .../src/types/IOmnichannelVerification.ts | 2 +- 6 files changed, 14 insertions(+), 11 deletions(-) diff --git a/apps/meteor/app/livechat/server/hooks/verificationCheck.ts b/apps/meteor/app/livechat/server/hooks/verificationCheck.ts index a6af9c07b369..89b5dd9d79ba 100644 --- a/apps/meteor/app/livechat/server/hooks/verificationCheck.ts +++ b/apps/meteor/app/livechat/server/hooks/verificationCheck.ts @@ -60,7 +60,7 @@ callbacks.add( settings.get('Livechat_automate_verification_process') && room.servedBy?.username === settings.get('Livechat_verificaion_bot_assign') ) { - await OmnichannelVerification.trasferChatAfterVerificationProcess(room._id); + await OmnichannelVerification.transferChatAfterVerificationProcess(room._id); } break; } diff --git a/apps/meteor/ee/app/livechat-enterprise/server/hooks/handleNextAgentPreferredEvents.ts b/apps/meteor/ee/app/livechat-enterprise/server/hooks/handleNextAgentPreferredEvents.ts index 92bc2af3eada..43aaa088bbd8 100644 --- a/apps/meteor/ee/app/livechat-enterprise/server/hooks/handleNextAgentPreferredEvents.ts +++ b/apps/meteor/ee/app/livechat-enterprise/server/hooks/handleNextAgentPreferredEvents.ts @@ -88,7 +88,7 @@ callbacks.add( if (settings.get('Livechat_automate_verification_process')) { const bot = await Users.findOneByUsername(settings.get('Livechat_verificaion_bot_assign')); const agentId = bot?._id; - const username = bot?.username || 'ROCKETCAT'; + const username = bot?.username || 'rocket.cat'; const agent = { agentId, username }; return agent; } diff --git a/apps/meteor/ee/app/livechat-enterprise/server/lib/AutoTransferChatScheduler.ts b/apps/meteor/ee/app/livechat-enterprise/server/lib/AutoTransferChatScheduler.ts index 7e52cc266c04..fc128357a4cc 100644 --- a/apps/meteor/ee/app/livechat-enterprise/server/lib/AutoTransferChatScheduler.ts +++ b/apps/meteor/ee/app/livechat-enterprise/server/lib/AutoTransferChatScheduler.ts @@ -79,7 +79,7 @@ class AutoTransferChatSchedulerClass { departmentId: 1, }); if (!room?.open || !room?.servedBy?._id) { - throw new Error('Room is not open or is not being served by an agent'); + throw new Error('error-room-not-opened-or-serviced'); } const { diff --git a/apps/meteor/packages/rocketchat-i18n/i18n/en.i18n.json b/apps/meteor/packages/rocketchat-i18n/i18n/en.i18n.json index 768629a8b811..85cec84dfbc7 100644 --- a/apps/meteor/packages/rocketchat-i18n/i18n/en.i18n.json +++ b/apps/meteor/packages/rocketchat-i18n/i18n/en.i18n.json @@ -2059,6 +2059,7 @@ "error-room-onHold": "Error! Room is On Hold", "error-room-is-already-on-hold": "Error! Room is already On Hold", "error-room-not-on-hold": "Error! Room is not On Hold", + "error-room-not-opened-or-serviced": "Error! Room is not open or is not being served by an agent", "error-selected-agent-room-agent-are-same": "The selected agent and the room agent are the same", "error-starring-message": "Message could not be stared", "error-tags-must-be-assigned-before-closing-chat": "Tag(s) must be assigned before closing the chat", diff --git a/apps/meteor/server/services/omnichannel-verification/service.ts b/apps/meteor/server/services/omnichannel-verification/service.ts index 637982a51f9b..80faad71827c 100644 --- a/apps/meteor/server/services/omnichannel-verification/service.ts +++ b/apps/meteor/server/services/omnichannel-verification/service.ts @@ -323,17 +323,19 @@ export class OmnichannelVerification extends ServiceClassInternal implements IOm } } - async trasferChatAfterVerificationProcess(roomId: IRoom['_id']): Promise { + async transferChatAfterVerificationProcess(roomId: IRoom['_id']): Promise { try { const room = await LivechatRooms.findOneById(roomId, { - _id: 1, - v: 1, - servedBy: 1, - open: 1, - departmentId: 1, + projection: { + _id: 1, + v: 1, + servedBy: 1, + open: 1, + departmentId: 1, + }, }); if (!room?.open || !room?.servedBy?._id) { - throw new Error('Room is not open or is not being served by an agent'); + throw new Error('error-room-not-opened-or-serviced'); } const { departmentId, diff --git a/packages/core-services/src/types/IOmnichannelVerification.ts b/packages/core-services/src/types/IOmnichannelVerification.ts index 4a79ed06823f..321f2d21381a 100644 --- a/packages/core-services/src/types/IOmnichannelVerification.ts +++ b/packages/core-services/src/types/IOmnichannelVerification.ts @@ -12,5 +12,5 @@ export interface IOmnichannelVerification extends IServiceClass { setVisitorEmail(room: IOmnichannelRoom, email: string): Promise; sendVerificationCodeToVisitor(visitorId: string, room: IOmnichannelGenericRoom): Promise; createLivechatMessage(room: IOmnichannelRoom, text: string): Promise; - trasferChatAfterVerificationProcess(roomId: IRoom['_id']): Promise; + transferChatAfterVerificationProcess(roomId: IRoom['_id']): Promise; }