Skip to content

Commit 59b71ea

Browse files
committed
omni
1 parent cecac0e commit 59b71ea

2 files changed

Lines changed: 21 additions & 0 deletions

File tree

src/agent.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,10 @@ export default (): void => {
140140

141141
b.on('getRoutingConfig', async () => {
142142
const agent = rand(agents);
143+
144+
if (!agent) {
145+
return;
146+
}
143147
await agent.getRoutingConfig();
144148
const { departments } = (await agent.getAgentDepartments()) || {
145149
departments: [],
@@ -151,11 +155,17 @@ export default (): void => {
151155

152156
b.on('getQueuedInquiries', async () => {
153157
const agent = rand(agents);
158+
if (!agent) {
159+
return;
160+
}
154161
await agent.getQueuedInquiries();
155162
});
156163

157164
b.on('takeInquiry', async () => {
158165
const agent = rand(agents);
166+
if (!agent) {
167+
return;
168+
}
159169
const response = await agent.getQueuedInquiries();
160170
if (!response?.inquiries) {
161171
return;
@@ -170,6 +180,10 @@ export default (): void => {
170180
}
171181

172182
const processedInquiry = rand(inquiries);
183+
184+
if (!processedInquiry) {
185+
return;
186+
}
173187
try {
174188
// Re-fetch inquiry
175189
await agent.getInquiry(processedInquiry._id);
@@ -186,6 +200,9 @@ export default (): void => {
186200

187201
b.on('message', async () => {
188202
const agent = rand(agents);
203+
if (!agent) {
204+
return;
205+
}
189206
const sub = agent.getRandomLivechatSubscription();
190207

191208
if (!sub) {

src/profile.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ export default (): void => {
2626
async function getLoggedInClient() {
2727
const client = rand(clients);
2828

29+
if (!client) {
30+
throw new Error('No logged in client found');
31+
}
32+
2933
if (client.status === 'logging') {
3034
throw new AlreadyLoggingError();
3135
}

0 commit comments

Comments
 (0)