Built motion from commit b51cdcb3f2cb46634587ce1d55ea1b8f32dacea6. Version 3.0.0...
[motion-next.git] / server / services / ami / trigger / index.js
1 const a1134_0x3de1=['custom:agentcalled','syncCustomEvent','toLowerCase','isNil','routeId','../../../config/logger','custom:queuecallerabandon','AllConditions','custom:agentconnect','sugarcrmAccounts','uri','accounts','lodash','account','format','custom:dialbegin','queue','user:%s','query','data1','html','undefined','Actions','channel','template\x20not\x20found','custom:closedinteraction','action','exports','search','url','salesforceAccounts','parse','checkTrigger','length','interaction','event','./cmContact','syncAgentDial','contactmanager','600','voiceQueues','custom:agentnoanswer','every','checkTriggers','script','custom:rejectmessage','data5','buildUri','custom:incomingmessage','lastevent','some','data3','winapp','upperFirst','urlforward','value','merge','800','render','custom:timeout','data4','voiceExtensions','freshdeskAccounts','name','motionbar','ChatWebsiteId','servicenowAccounts','templates','custom:acceptmessage','operator','trigger:%s:%s','custom:agentnosuchnumber','custom:newinteraction','triggers','deskAccounts','stringify','popup','data6','./integration','uriLocation','../ami','zendeskAccounts','./script','interface','dynamics365Accounts','emit','agents','exec','vtigerAccounts','winArguments','trigger:%s','util','prototype','../../../rediscache','membername','field','jscripty','TemplateId','custom:dialend','./urlforward','AccountId','trigger','info','custom:agentreject','data2','custom:dialconnect','custom:outgoingmessage','bind','custom:agentbusy','freshsalesAccounts'];(function(_0x3a0ebf,_0x3de193){const _0x3c472d=function(_0x53c4ad){while(--_0x53c4ad){_0x3a0ebf['push'](_0x3a0ebf['shift']());}};_0x3c472d(++_0x3de193);}(a1134_0x3de1,0x1c7));const a1134_0x3c47=function(_0x3a0ebf,_0x3de193){_0x3a0ebf=_0x3a0ebf-0x0;let _0x3c472d=a1134_0x3de1[_0x3a0ebf];return _0x3c472d;};const _0x304377=a1134_0x3c47;'use strict';const util=require(_0x304377('0x4c')),_=require(_0x304377('0x6b')),url=require(_0x304377('0xe')),Mustache=require('mustache'),urlforward=require(_0x304377('0x54')),integration=require(_0x304377('0x3f')),cmContact=require(_0x304377('0x15')),script=require(_0x304377('0x43')),logger=require(_0x304377('0x64'))(_0x304377('0x56')),ami=require(_0x304377('0x41')),{getSocket}=require(_0x304377('0x4e')),io=getSocket(),operators={'equals':function(_0x53c4ad,_0x3e6ae8){return _0x53c4ad==_0x3e6ae8;},'not_equals':function(_0x7781e9,_0x138a26){return _0x7781e9!=_0x138a26;}},barAndWebActions=[_0x304377('0x3d'),_0x304377('0xe'),_0x304377('0x25')];function Trigger(_0x14dc10){const _0x505ade=_0x304377;this[_0x505ade('0x3a')]=_0x14dc10[_0x505ade('0x3a')],this[_0x505ade('0x47')]=_0x14dc10['agents'],this['voiceQueues']=_0x14dc10[_0x505ade('0x19')],this[_0x505ade('0x34')]=_0x14dc10['templates'],this['voiceExtensions']=_0x14dc10['voiceExtensions'],this[_0x505ade('0x42')]=_0x14dc10[_0x505ade('0x42')],this[_0x505ade('0x2f')]=_0x14dc10[_0x505ade('0x2f')],this[_0x505ade('0xf')]=_0x14dc10[_0x505ade('0xf')],this[_0x505ade('0x68')]=_0x14dc10[_0x505ade('0x68')],this['zohoAccounts']=_0x14dc10['zohoAccounts'],this[_0x505ade('0x3b')]=_0x14dc10[_0x505ade('0x3b')],this[_0x505ade('0x49')]=_0x14dc10['vtigerAccounts'],this[_0x505ade('0x33')]=_0x14dc10['servicenowAccounts'],this[_0x505ade('0x45')]=_0x14dc10[_0x505ade('0x45')],this[_0x505ade('0x5e')]=_0x14dc10[_0x505ade('0x5e')],this[_0x505ade('0x6a')]={'zendesk':this[_0x505ade('0x42')],'salesforce':this['salesforceAccounts'],'freshdesk':this[_0x505ade('0x2f')],'sugarcrm':this[_0x505ade('0x68')],'zoho':this['zohoAccounts'],'desk':this[_0x505ade('0x3b')],'vtiger':this[_0x505ade('0x49')],'dynamics365':this[_0x505ade('0x45')],'freshsales':this['freshsalesAccounts'],'servicenow':this[_0x505ade('0x33')]},ami['on'](_0x505ade('0x5f'),this[_0x505ade('0x60')][_0x505ade('0x5c')](this)),ami['on'](_0x505ade('0x67'),this[_0x505ade('0x60')]['bind'](this)),ami['on']('custom:agentringnoanswer',this['syncCustomEvent'][_0x505ade('0x5c')](this)),ami['on']('custom:agentcomplete',this[_0x505ade('0x60')]['bind'](this)),ami['on'](_0x505ade('0x38'),this[_0x505ade('0x60')][_0x505ade('0x5c')](this)),ami['on'](_0x505ade('0x1a'),this[_0x505ade('0x60')][_0x505ade('0x5c')](this)),ami['on'](_0x505ade('0x5d'),this[_0x505ade('0x60')][_0x505ade('0x5c')](this)),ami['on']('custom:agentcongestion',this[_0x505ade('0x60')]['bind'](this)),ami['on'](_0x505ade('0x58'),this[_0x505ade('0x60')][_0x505ade('0x5c')](this)),ami['on'](_0x505ade('0x65'),this['syncCustomEvent'][_0x505ade('0x5c')](this)),ami['on'](_0x505ade('0x2c'),this[_0x505ade('0x60')][_0x505ade('0x5c')](this)),ami['on'](_0x505ade('0x0'),this['syncAgentDial'][_0x505ade('0x5c')](this)),ami['on'](_0x505ade('0x5a'),this[_0x505ade('0x16')][_0x505ade('0x5c')](this)),ami['on'](_0x505ade('0x53'),this[_0x505ade('0x16')][_0x505ade('0x5c')](this)),ami['on'](_0x505ade('0x39'),this[_0x505ade('0x60')][_0x505ade('0x5c')](this)),ami['on'](_0x505ade('0xa'),this[_0x505ade('0x60')][_0x505ade('0x5c')](this)),ami['on'](_0x505ade('0x21'),this[_0x505ade('0x60')][_0x505ade('0x5c')](this)),ami['on'](_0x505ade('0x5b'),this[_0x505ade('0x60')][_0x505ade('0x5c')](this)),ami['on'](_0x505ade('0x35'),this[_0x505ade('0x60')][_0x505ade('0x5c')](this)),ami['on'](_0x505ade('0x1e'),this[_0x505ade('0x60')][_0x505ade('0x5c')](this));}Trigger[_0x304377('0x4d')][_0x304377('0x46')]=function(_0x1d9f2c,_0x4c06d3,_0x5d42e5){const _0x5388d7=_0x304377;logger[_0x5388d7('0x57')](_0x1d9f2c,_0x4c06d3,JSON[_0x5388d7('0x3c')](_0x5d42e5)),io['to'](_0x1d9f2c)[_0x5388d7('0x46')](_0x4c06d3,_0x5d42e5);},Trigger['prototype'][_0x304377('0x60')]=function(_0x9c71d5){const _0x3ed90b=_0x304377,_0x548588=_['clone'](_0x9c71d5);this[_0x3ed90b('0x1c')](_0x548588);},Trigger[_0x304377('0x4d')]['syncAgentDial']=function(_0x108fa9){const _0x27edab=_0x304377;this[_0x27edab('0x47')][_0x108fa9[_0x27edab('0x44')]]&&this[_0x27edab('0x60')](_0x108fa9);},Trigger['prototype']['checkTriggers']=function(_0x3c2027){const _0x4fa5a4=_0x304377;let _0x2cbc78;for(const _0xdfe713 in this[_0x4fa5a4('0x3a')]){if(typeof this[_0x4fa5a4('0x3a')][_0xdfe713]!==_0x4fa5a4('0x6')){if(this[_0x4fa5a4('0x3a')][_0xdfe713]['status']){_0x2cbc78=this['checkTrigger'](this[_0x4fa5a4('0x3a')][_0xdfe713],_0x3c2027);if(_0x2cbc78){_[_0x4fa5a4('0x29')](_0x3c2027,_0x3c2027['variables']);for(let _0x5beff9=0x0,_0x10a0eb;_0x5beff9<this[_0x4fa5a4('0x3a')][_0xdfe713][_0x4fa5a4('0x7')][_0x4fa5a4('0x12')];_0x5beff9+=0x1){_0x10a0eb=this[_0x4fa5a4('0x3a')][_0xdfe713][_0x4fa5a4('0x7')][_0x5beff9];if(this[_0x4fa5a4('0x47')][_0x3c2027[_0x4fa5a4('0x44')]])switch(_0x10a0eb[_0x4fa5a4('0xb')][_0x4fa5a4('0x61')]()){case'contactmanager':break;case _0x4fa5a4('0x31'):case'browser':{const _0x334ca2={};switch(barAndWebActions[_0x10a0eb[_0x4fa5a4('0x4')]]){case _0x4fa5a4('0x3d'):_0x334ca2[_0x4fa5a4('0x52')]=_0x10a0eb[_0x4fa5a4('0x59')],_0x334ca2[_0x4fa5a4('0x5')]=this[_0x4fa5a4('0x34')][_0x10a0eb[_0x4fa5a4('0x59')]]?Mustache['render'](this[_0x4fa5a4('0x34')][_0x10a0eb['data2']][_0x4fa5a4('0x5')],_0x3c2027):_0x4fa5a4('0x9');break;case'url':_0x334ca2[_0x4fa5a4('0x69')]=this[_0x4fa5a4('0x20')](_0x10a0eb[_0x4fa5a4('0x59')],_0x3c2027,_[_0x4fa5a4('0x62')](_0x10a0eb[_0x4fa5a4('0x24')])?!![]:parseInt(_0x10a0eb['data3'],0xa));_[_0x4fa5a4('0x62')](_0x10a0eb[_0x4fa5a4('0x2d')])?_0x334ca2['location']='0':(_0x334ca2[_0x4fa5a4('0x40')]=_0x10a0eb[_0x4fa5a4('0x2d')],_0x334ca2['windowWidth']=_['isNil'](_0x10a0eb[_0x4fa5a4('0x1f')])?_0x4fa5a4('0x2a'):_0x10a0eb['data5'],_0x334ca2['windowHeight']=_['isNil'](_0x10a0eb[_0x4fa5a4('0x3e')])?_0x4fa5a4('0x18'):_0x10a0eb[_0x4fa5a4('0x3e')]);break;case _0x4fa5a4('0x25'):_0x334ca2['winApplication']=_0x10a0eb[_0x4fa5a4('0x59')]?Mustache[_0x4fa5a4('0x2b')](_0x10a0eb[_0x4fa5a4('0x59')],_0x3c2027):'',_0x334ca2[_0x4fa5a4('0x4a')]=_0x10a0eb[_0x4fa5a4('0x24')]?Mustache['render'](_0x10a0eb[_0x4fa5a4('0x24')],_0x3c2027):'';break;}this[_0x4fa5a4('0x46')](util[_0x4fa5a4('0x6d')]('user:%s',this['agents'][_0x3c2027[_0x4fa5a4('0x44')]][_0x4fa5a4('0x30')]),util[_0x4fa5a4('0x6d')](_0x4fa5a4('0x37'),_0x10a0eb['action'][_0x4fa5a4('0x61')](),barAndWebActions[_0x10a0eb['data1']]),_['merge'](_0x334ca2,_0x3c2027));break;}case _0x4fa5a4('0x51'):this[_0x4fa5a4('0x46')](util['format'](_0x4fa5a4('0x2'),this['agents'][_0x3c2027[_0x4fa5a4('0x44')]][_0x4fa5a4('0x30')]),util[_0x4fa5a4('0x6d')](_0x4fa5a4('0x4b'),_0x10a0eb['action'][_0x4fa5a4('0x61')]()),_[_0x4fa5a4('0x29')]({'ProjectId':parseInt(_0x10a0eb[_0x4fa5a4('0x4')],0xa)},_0x3c2027));break;default:this['emit'](util[_0x4fa5a4('0x6d')]('user:%s',this[_0x4fa5a4('0x47')][_0x3c2027['interface']][_0x4fa5a4('0x30')]),util['format'](_0x4fa5a4('0x4b'),_0x10a0eb['action'][_0x4fa5a4('0x61')]()),_['merge']({},_0x10a0eb,_0x3c2027));}switch(_0x10a0eb[_0x4fa5a4('0xb')][_0x4fa5a4('0x61')]()){case _0x4fa5a4('0x17'):cmContact[_0x4fa5a4('0x48')](this[_0x4fa5a4('0x47')][_0x3c2027[_0x4fa5a4('0x44')]],this[_0x4fa5a4('0x3a')][_0xdfe713],_0x10a0eb,_0x3c2027);break;case'integration':integration['exec'](_0x10a0eb,_0x3c2027,this[_0x4fa5a4('0x6a')],this[_0x4fa5a4('0x47')][_0x3c2027[_0x4fa5a4('0x44')]],this[_0x4fa5a4('0x19')][_0x3c2027[_0x4fa5a4('0x1')]],this[_0x4fa5a4('0x2e')][_0x3c2027[_0x4fa5a4('0x63')]]);break;case _0x4fa5a4('0x27'):urlforward[_0x4fa5a4('0x48')](_0x10a0eb,_0x3c2027);break;case _0x4fa5a4('0x1d'):script[_0x4fa5a4('0x48')](_0x10a0eb,_0x3c2027);break;}}}}}}},Trigger[_0x304377('0x4d')][_0x304377('0x20')]=function(_0x2cef1d,_0x39dac9,_0x4294a2){const _0x6033f2=_0x304377,_0xbace1c=url[_0x6033f2('0x10')](Mustache['render'](_0x2cef1d,_0x39dac9),!![]);_0x4294a2&&_[_0x6033f2('0x29')](_0xbace1c[_0x6033f2('0x3')],_0x39dac9);delete _0xbace1c[_0x6033f2('0xd')];let _0x472449=url[_0x6033f2('0x6d')](_0xbace1c);return _0x472449=_0x472449['replace'](/\/\?/g,'?'),_0x472449;},Trigger[_0x304377('0x4d')][_0x304377('0x11')]=function(_0x2938af,_0x24354e){const _0x3fb896=_0x304377;let _0x42cc04=!![],_0x5635ec=!![];return _0x2938af[_0x3fb896('0x66')][_0x3fb896('0x12')]&&(_0x42cc04=_[_0x3fb896('0x1b')](_0x2938af[_0x3fb896('0x66')],this['checkConditions'](_0x24354e,_0x2938af[_0x3fb896('0x8')]))),_0x2938af['AnyConditions']['length']&&(_0x5635ec=_[_0x3fb896('0x23')](_0x2938af['AnyConditions'],this['checkConditions'](_0x24354e,_0x2938af[_0x3fb896('0x8')]))),_0x42cc04&&_0x5635ec;},Trigger['prototype']['checkConditions']=function(_0x588bd5,_0x5723c2){return function(_0x26330a){const _0x43e313=a1134_0x3c47;switch(_0x26330a[_0x43e313('0x50')]){case _0x43e313('0x6c'):if(_0x588bd5[_0x43e313('0x8')]===_0x5723c2)return _0x5723c2==='chat'?_0x588bd5[_0x43e313('0x32')]?operators[_0x26330a[_0x43e313('0x36')]](Number(_0x26330a[_0x43e313('0x28')]),_0x588bd5[_0x43e313('0x32')]):![]:_0x588bd5[_[_0x43e313('0x26')](_0x5723c2)+_0x43e313('0x55')]?operators[_0x26330a['operator']](Number(_0x26330a[_0x43e313('0x28')]),_0x588bd5[_[_0x43e313('0x26')](_0x5723c2)+_0x43e313('0x55')]):![];break;case _0x43e313('0x13'):case'message':if(_0x588bd5[_0x43e313('0x8')]===_0x5723c2)return _0x588bd5['event']?operators[_0x26330a[_0x43e313('0x36')]](_0x26330a[_0x43e313('0x28')],_0x588bd5[_0x43e313('0x14')]):![];break;case _0x43e313('0x1'):return _0x588bd5[_0x43e313('0x1')]?operators[_0x26330a[_0x43e313('0x36')]](_0x26330a[_0x43e313('0x28')],_0x588bd5[_0x43e313('0x1')]):![];case'agent':return _0x588bd5[_0x43e313('0x4f')]?operators[_0x26330a[_0x43e313('0x36')]](_0x26330a[_0x43e313('0x28')],_0x588bd5[_0x43e313('0x4f')]):![];case _0x43e313('0x22'):return _0x588bd5[_0x43e313('0x22')]?operators[_0x26330a['operator']](_0x26330a[_0x43e313('0x28')],_0x588bd5['lastevent']):![];case _0x43e313('0x63'):return _0x588bd5[_0x43e313('0x63')]?operators[_0x26330a[_0x43e313('0x36')]](_0x26330a[_0x43e313('0x28')],_0x588bd5[_0x43e313('0x63')]):![];}return![];};},module[_0x304377('0xc')]=Trigger;