Skip to content

Commit

Permalink
getRoomMessages
Browse files Browse the repository at this point in the history
  • Loading branch information
KevLehman committed Oct 12, 2023
1 parent 6d7b756 commit 7a0e2fc
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 23 deletions.
2 changes: 1 addition & 1 deletion apps/meteor/app/apps/server/bridges/livechat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ export class AppLivechatBridge extends LivechatBridge {
throw new Error('Could not get the message converter to process livechat room messages');
}

const livechatMessages = await Livechat.getRoomMessages({ rid: roomId });
const livechatMessages = await LivechatTyped.getRoomMessages({ rid: roomId });

return Promise.all(livechatMessages.map((message) => messageConverter.convertMessage(message) as Promise<IAppsEngineMesage>));
}
Expand Down
22 changes: 0 additions & 22 deletions apps/meteor/app/livechat/server/lib/Livechat.js
Original file line number Diff line number Diff line change
Expand Up @@ -766,28 +766,6 @@ export const Livechat = {
});
},

async getRoomMessages({ rid }) {
check(rid, String);

const room = await Rooms.findOneById(rid, { projection: { t: 1 } });
if (room?.t !== 'l') {
throw new Meteor.Error('invalid-room');
}

const ignoredMessageTypes = [
'livechat_navigation_history',
'livechat_transcript_history',
'command',
'livechat-close',
'livechat-started',
'livechat_video_call',
];

return Messages.findVisibleByRoomIdNotContainingTypes(rid, ignoredMessageTypes, {
sort: { ts: 1 },
}).toArray();
},

async requestTranscript({ rid, email, subject, user }) {
check(rid, String);
check(email, String);
Expand Down
20 changes: 20 additions & 0 deletions apps/meteor/app/livechat/server/lib/LivechatTyped.ts
Original file line number Diff line number Diff line change
Expand Up @@ -873,6 +873,26 @@ class LivechatClass {
});
});
}

async getRoomMessages({ rid }: { rid: string }) {
const room = await Rooms.findOneById(rid, { projection: { t: 1 } });
if (room?.t !== 'l') {
throw new Meteor.Error('invalid-room');
}

const ignoredMessageTypes: MessageTypesValues[] = [
'livechat_navigation_history',
'livechat_transcript_history',
'command',
'livechat-close',
'livechat-started',
'livechat_video_call',
];

return Messages.findVisibleByRoomIdNotContainingTypes(rid, ignoredMessageTypes, {
sort: { ts: 1 },
}).toArray();
}
}

export const Livechat = new LivechatClass();

0 comments on commit 7a0e2fc

Please sign in to comment.