Skip to content

Commit

Permalink
[REGRESSION] Omnichannel visitor forward was applying wrong restricti…
Browse files Browse the repository at this point in the history
…ons (#17826)

* return empty object if there is no callback

* Improve department forward restrictions
  • Loading branch information
MarcosSpessatto authored and sampaiodiego committed Jun 10, 2020
1 parent 3173431 commit 6b48d21
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ Meteor.methods({
throw new Meteor.Error('error-invalid-user', 'Invalid user', { method: 'livechat:getDepartmentForwardRestrictions' });
}

return callbacks.run('livechat.onLoadForwardDepartmentRestrictions', departmentId);
const options = callbacks.run('livechat.onLoadForwardDepartmentRestrictions', { departmentId });
const { restrictions } = options;

return restrictions;
},
});
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');

0 comments on commit 6b48d21

Please sign in to comment.