Skip to content

Commit

Permalink
fix: Avoid processRoomAbandonment callback from erroring when Busin…
Browse files Browse the repository at this point in the history
…ess Hours config is missing for day (#33058)
  • Loading branch information
KevLehman committed Aug 16, 2024
1 parent 338c39b commit 5f2dd9e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/gentle-bugs-think.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": patch
---

Prevent `processRoomAbandonment` callback from erroring out when a room was inactive during a day Business Hours was not configured for.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -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) {
Expand Down

0 comments on commit 5f2dd9e

Please sign in to comment.