The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/packages/rocketchat-ui/lib/fireEvent.js

35 lines
1004 B

window.fireGlobalEvent = (eventName, params) => {
window.dispatchEvent(new CustomEvent(eventName, {detail: params}));
if (RocketChat.settings.get('Iframe_Integration_send_enable') === true) {
parent.postMessage({
eventName: eventName,
data: params
}, RocketChat.settings.get('Iframe_Integration_send_target_origin'));
}
};
window.addEventListener('message', (e) => {
if (RocketChat.settings.get('Iframe_Integration_receive_enable') !== true) {
return;
}
if (typeof e.data !== 'object' || typeof e.data.externalCommand !== 'string') {
return;
}
let origins = RocketChat.settings.get('Iframe_Integration_receive_origin');
if (origins !== '*' && origins.split(',').indexOf(e.origin) === -1) {
return console.error('Origin not allowed', e.origin);
}
switch (e.data.externalCommand) {
case 'go':
if (typeof e.data.path !== 'string' || e.data.path.trim().length === 0) {
return console.error('`path` not defined');
}
FlowRouter.go(e.data.path);
break;
}
});