Regression: Fix Default Business hour overriding other Business Hours (#24288)

Co-authored-by: Kevin Aleman <kevin.aleman@rocket.chat>
pull/24254/head^2
Murtaza Patrawala 3 years ago committed by GitHub
parent 1b44f2d33e
commit e1059c1364
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 19
      ee/app/livechat-enterprise/server/business-hour/Multiple.ts

@ -175,16 +175,21 @@ export class MultipleBusinessHoursBehavior extends AbstractBusinessHourBehavior
{ projection: { _id: 1, businessHourId: 1 } },
).toArray();
if (departmentsWithActiveBH.length) {
const activeBusinessHoursForAgent = departmentsWithActiveBH.map(({ businessHourId }) => businessHourId);
await this.UsersRepository.openAgentBusinessHoursByBusinessHourIdsAndAgentId(activeBusinessHoursForAgent, agentId);
if (!departmentsWithActiveBH.length) {
bhLogger.debug(
`Business hour status recheck passed for agentId: ${agentId}. Found following business hours to be active:`,
activeBusinessHoursForAgent,
`Business hour status recheck failed for agentId: ${agentId}. No opened business hour found for any of the departments connected to the agent`,
);
return true;
return false;
}
const activeBusinessHoursForAgent = departmentsWithActiveBH.map(({ businessHourId }) => businessHourId);
await this.UsersRepository.openAgentBusinessHoursByBusinessHourIdsAndAgentId(activeBusinessHoursForAgent, agentId);
bhLogger.debug(
`Business hour status recheck passed for agentId: ${agentId}. Found following business hours to be active:`,
activeBusinessHoursForAgent,
);
return true;
}
// check if default businessHour is active

Loading…
Cancel
Save