-
Notifications
You must be signed in to change notification settings - Fork 11.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[REGRESSION] Omnichannel visitor forward was applying wrong restricti…
…ons (#17826) * return empty object if there is no callback * Improve department forward restrictions
- Loading branch information
1 parent
3173431
commit 6b48d21
Showing
2 changed files
with
10 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 6 additions & 5 deletions
11
ee/app/livechat-enterprise/server/hooks/onLoadForwardDepartmentRestrictions.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,18 @@ | ||
import { callbacks } from '../../../../../app/callbacks'; | ||
import { LivechatDepartment } from '../../../../../app/models/server'; | ||
|
||
callbacks.add('livechat.onLoadForwardDepartmentRestrictions', (departmentId) => { | ||
callbacks.add('livechat.onLoadForwardDepartmentRestrictions', (options = {}) => { | ||
const { departmentId } = options; | ||
if (!departmentId) { | ||
return {}; | ||
return options; | ||
} | ||
const department = LivechatDepartment.findOneById(departmentId, { fields: { departmentsAllowedToForward: 1 } }); | ||
if (!department) { | ||
return {}; | ||
return options; | ||
} | ||
const { departmentsAllowedToForward } = department; | ||
if (!departmentsAllowedToForward) { | ||
return {}; | ||
return options; | ||
} | ||
return { _id: { $in: departmentsAllowedToForward } }; | ||
return Object.assign({ restrictions: { _id: { $in: departmentsAllowedToForward } } }, options); | ||
}, callbacks.priority.MEDIUM, 'livechat-on-load-forward-department-restrictions'); |