Skip to content
Snippets Groups Projects
Unverified Commit f0025d4d authored by Douglas Gubert's avatar Douglas Gubert Committed by GitHub
Browse files

fix: Livechat message fetching method in LivechatBridge (#30000)

parent cbad71ba
No related branches found
No related tags found
No related merge requests found
---
'@rocket.chat/meteor': patch
---
Fixed message fetching method in LivechatBridge for Apps
...@@ -6,7 +6,7 @@ import type { ...@@ -6,7 +6,7 @@ import type {
ILivechatTransferData, ILivechatTransferData,
IDepartment, IDepartment,
} from '@rocket.chat/apps-engine/definition/livechat'; } from '@rocket.chat/apps-engine/definition/livechat';
import type { IMessage } from '@rocket.chat/apps-engine/definition/messages'; import type { IMessage as IAppsEngineMesage } from '@rocket.chat/apps-engine/definition/messages';
import type { IUser } from '@rocket.chat/apps-engine/definition/users'; import type { IUser } from '@rocket.chat/apps-engine/definition/users';
import { LivechatBridge } from '@rocket.chat/apps-engine/server/bridges/LivechatBridge'; import { LivechatBridge } from '@rocket.chat/apps-engine/server/bridges/LivechatBridge';
import type { SelectedAgent } from '@rocket.chat/core-typings'; import type { SelectedAgent } from '@rocket.chat/core-typings';
...@@ -280,7 +280,7 @@ export class AppLivechatBridge extends LivechatBridge { ...@@ -280,7 +280,7 @@ export class AppLivechatBridge extends LivechatBridge {
return Promise.all((await LivechatDepartment.findEnabledWithAgents().toArray()).map(boundConverter)); return Promise.all((await LivechatDepartment.findEnabledWithAgents().toArray()).map(boundConverter));
} }
protected async _fetchLivechatRoomMessages(appId: string, roomId: string): Promise<Array<IMessage>> { protected async _fetchLivechatRoomMessages(appId: string, roomId: string): Promise<Array<IAppsEngineMesage>> {
this.orch.debugLog(`The App ${appId} is getting the transcript for livechat room ${roomId}.`); this.orch.debugLog(`The App ${appId} is getting the transcript for livechat room ${roomId}.`);
const messageConverter = this.orch.getConverters()?.get('messages'); const messageConverter = this.orch.getConverters()?.get('messages');
...@@ -288,9 +288,9 @@ export class AppLivechatBridge extends LivechatBridge { ...@@ -288,9 +288,9 @@ export class AppLivechatBridge extends LivechatBridge {
throw new Error('Could not get the message converter to process livechat room messages'); throw new Error('Could not get the message converter to process livechat room messages');
} }
const boundMessageConverter = messageConverter.convertMessage.bind(messageConverter); const livechatMessages = await Livechat.getRoomMessages({ rid: roomId });
return (await Livechat.getRoomMessages({ rid: roomId })).map(boundMessageConverter); return Promise.all(livechatMessages.map((message) => messageConverter.convertMessage(message) as Promise<IAppsEngineMesage>));
} }
protected async setCustomFields( protected async setCustomFields(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment