Skip to content
Snippets Groups Projects
Unverified Commit 9e1b9ad6 authored by dionisio-bot[bot]'s avatar dionisio-bot[bot] Committed by GitHub
Browse files

fix: Avoid `processRoomAbandonment` callback from erroring when Business Hours...

fix: Avoid `processRoomAbandonment` callback from erroring when Business Hours config is missing for day (#33084)

Co-authored-by: default avatarKevin Aleman <11577696+KevLehman@users.noreply.github.com>
parent 6bcbc02e
Branches backport-6.11.2-33133
No related tags found
No related merge requests found
---
"@rocket.chat/meteor": patch
---
Prevent `processRoomAbandonment` callback from erroring out when a room was inactive during a day Business Hours was not configured for.
......@@ -43,7 +43,8 @@ const getSecondsSinceLastAgentResponse = async (room: IOmnichannelRoom, agentLas
officeDays = (await businessHourManager.getBusinessHour())?.workHours.reduce(parseDays, {});
}
if (!officeDays) {
// Empty object we assume invalid config
if (!officeDays || !Object.keys(officeDays).length) {
return getSecondsWhenOfficeHoursIsDisabled(room, agentLastMessage);
}
......@@ -55,6 +56,11 @@ const getSecondsSinceLastAgentResponse = async (room: IOmnichannelRoom, agentLas
for (let index = 0; index <= daysOfInactivity; index++) {
const today = inactivityDay.clone().format('dddd');
const officeDay = officeDays[today];
// Config doesnt have data for this day, we skip day
if (!officeDay) {
inactivityDay.add(1, 'days');
continue;
}
const startTodaysOfficeHour = moment(`${officeDay.start.day}:${officeDay.start.time}`, 'dddd:HH:mm').add(index, 'days');
const endTodaysOfficeHour = moment(`${officeDay.finish.day}:${officeDay.finish.time}`, 'dddd:HH:mm').add(index, 'days');
if (officeDays[today].open) {
......
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