|
|
|
|
@ -2,6 +2,7 @@ import { Meteor } from 'meteor/meteor'; |
|
|
|
|
import { Tracker } from 'meteor/tracker'; |
|
|
|
|
|
|
|
|
|
import { hasPermission } from '../../../../../app/authorization/client'; |
|
|
|
|
import { settings } from '../../../../../app/settings/client'; |
|
|
|
|
import { APIClient } from '../../../../../app/utils/client'; |
|
|
|
|
import { CannedResponse } from '../collections/CannedResponse'; |
|
|
|
|
import { cannedResponsesStreamer } from '../streamer'; |
|
|
|
|
@ -19,19 +20,25 @@ Meteor.startup(() => { |
|
|
|
|
if (!Meteor.userId()) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
if (hasPermission('view-canned-responses')) { |
|
|
|
|
const { responses } = await APIClient.v1.get('canned-responses.get'); |
|
|
|
|
responses.forEach((response) => CannedResponse.insert(response)); |
|
|
|
|
if (!settings.get('Canned_Responses_Enable')) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
if (!hasPermission('view-canned-responses')) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
try { |
|
|
|
|
cannedResponsesStreamer.on('canned-responses', (response, options) => { |
|
|
|
|
const { agentsId } = options || {}; |
|
|
|
|
if (agentsId && Array.isArray(agentsId) && !agentsId.includes(Meteor.userId())) { |
|
|
|
|
if (Array.isArray(agentsId) && !agentsId.includes(Meteor.userId())) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
events[response.type](response); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
const { responses } = await APIClient.v1.get('canned-responses.get'); |
|
|
|
|
responses.forEach((response) => CannedResponse.insert(response)); |
|
|
|
|
c.stop(); |
|
|
|
|
} catch (error) { |
|
|
|
|
console.log(error); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|