Skip to content

Commit

Permalink
Enable channel janitor for survey events on all tasks being cancelled
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenhand committed Jun 11, 2024
1 parent ff37270 commit 43ee818
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions functions/taskrouterListeners/janitorListener.private.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,18 +160,17 @@ export const handleEvent = async (context: Context<EnvVars>, event: EventFields)

console.log(`===== Executing JanitorListener for event: ${eventType} =====`);

const taskAttributes = JSON.parse(taskAttributesString || '{}');
const { channelSid, conversationSid } = taskAttributes;

if (taskChannelUniqueName === 'survey' && (!conversationSid || eventType !== TASK_CANCELED)) {
if (taskChannelUniqueName === 'survey' && eventType !== TASK_CANCELED) {
console.log(
'Survey tasks are only handled by the channel janitor if they are cancelled events for conversations tasks - skipping this one.',
'Survey tasks are only handled by the channel janitor on task cancelled events skipping this one.',
eventType,
conversationSid,
);
return;
}

const taskAttributes = JSON.parse(taskAttributesString || '{}');
const { channelSid, conversationSid } = taskAttributes;

if (isCleanupBotCapture(eventType, taskAttributes)) {
await wait(3000); // wait 3 seconds just in case some bot message is pending

Expand Down

0 comments on commit 43ee818

Please sign in to comment.