Built motion from commit 1ea47bf4.|2.6.34
[motion2.git] / server / services / ami / trigger / integration / sugarcrm.js
index 95cbb88..d78472c 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x6c0f=['uniqueid','recordingURL','The\x20User\x20ID\x20is:','calleridname','calleridnum','The\x20Enduser\x20ID\x20is:','Inbound','Ticket\x20created!','The\x20Ticket\x20ID\x20is:','version','charAt','%s/#bwc/index.php?module=Calls&action=EditView&record=%s','Displaying\x20ticket\x20to\x20agent\x20in\x20a\x20new\x20tab...','trigger:browser:url','catch','error','outbound','recordingFormat','none','destcalleridname','destcalleridnum','Fields','Outbound','contacts','%s/index.php?action=ajaxui#ajaxUILoc=index.php%3Fmodule%3DCalls%26action%3DEditView%26record%3D%s','[OUTBOUND]','user:%s','unmanaged','lastevent','toUpperCase','users','lodash','request-promise','bluebird','md5','util','ioredis','./util','../../../../config/environment','../../../../config/logger','sugarcrm','redis','localhost','socket.io-emitter','POST','emit','info','Creating\x20new\x20ticket...','getString','assigned_user_id','created_by','description','date_start','toISOString','slice','duration_hours','duration_minutes','parent_id','parent_type','Contacts','parent_name','name','direction','length','variableName','push','idField','JSON','stringify','Calls','format','apiKey','toString','base64','get_server_info','Employees','INSTR\x20(\x20users.user_name,\x20\x22%s\x22)\x20>\x200','user_name','then','find','entry_list','name_value_list','value','resolve','Agent\x20not\x20found,\x20using\x20the\x20admin\x20account!','user_id','Agent\x20not\x20available,\x20using\x20the\x20admin\x20account!','Searching\x20enduser\x20with\x20phone','get_entry_list','contacts.phone_home\x20=\x20\x22%s\x22','phone_home','Enduser\x20found!','Enduser\x20not\x20found,\x20creating\x20a\x20new\x20enduser!','set_entry','<unknown>','Caller\x20-\x20%s','Enduser\x20created.','debug','[HTTP]','merge','map','forEach','type','string','nameField','customField','toLowerCase','content','custom_fields','Variable','login','username','password','PLAIN','xCALLY\x20Motion\x20integration','set_relationship','queue','remoteUri','stripTrailingSlash','serverUrl','uri','%s/service/v4_1/rest.php','[QUEUE]','Recording\x20is\x20enabled!','%s/api/voice/recordings/%s/downloads?type=uniqueid&token=%s'];(function(_0x3371f6,_0x4ec66f){var _0x1ba130=function(_0x5aa350){while(--_0x5aa350){_0x3371f6['push'](_0x3371f6['shift']());}};_0x1ba130(++_0x4ec66f);}(_0x6c0f,0x119));var _0xf6c0=function(_0x20b278,_0x1ff931){_0x20b278=_0x20b278-0x0;var _0x441a43=_0x6c0f[_0x20b278];return _0x441a43;};'use strict';var _=require(_0xf6c0('0x0'));var rp=require(_0xf6c0('0x1'));var BPromise=require(_0xf6c0('0x2'));var md5=require(_0xf6c0('0x3'));var util=require(_0xf6c0('0x4'));var Redis=require(_0xf6c0('0x5'));var intUtil=require(_0xf6c0('0x6'));var config=require(_0xf6c0('0x7'));var logger=require(_0xf6c0('0x8'))(_0xf6c0('0x9'));config['redis']=_['defaults'](config[_0xf6c0('0xa')],{'host':_0xf6c0('0xb'),'port':0x18eb});var io=require(_0xf6c0('0xc'))(new Redis(config['redis']));var def={'method':_0xf6c0('0xd'),'json':!![]};function emit(_0x51cd40,_0x361fce,_0x5f35cb){io['to'](_0x51cd40)[_0xf6c0('0xe')](_0x361fce,_0x5f35cb);}function getTicket(_0x5b2440,_0x176119,_0x1af16f,_0x5ea17c,_0x44e822,_0x17d2ac,_0x141938,_0x1d701a){logger[_0xf6c0('0xf')](_0xf6c0('0x10'));var _0x20d767=new Date();var _0x2794ae=[{'name':'name','value':intUtil[_0xf6c0('0x11')](_0x5ea17c['Subjects'],_0x44e822,'\x20')},{'name':_0xf6c0('0x12'),'value':_0x176119['id']},{'name':_0xf6c0('0x13'),'value':_0x176119['id']},{'name':_0xf6c0('0x14'),'value':intUtil[_0xf6c0('0x11')](_0x5ea17c['Descriptions'],_0x44e822,'\x0a')},{'name':_0xf6c0('0x15'),'value':_0x20d767[_0xf6c0('0x16')]()[_0xf6c0('0x17')](0x0,0x13)['replace']('T','\x20')},{'name':_0xf6c0('0x18'),'value':'0'},{'name':_0xf6c0('0x19'),'value':'15'},{'name':_0xf6c0('0x1a'),'value':_0x1af16f['id']},{'name':_0xf6c0('0x1b'),'value':_0xf6c0('0x1c')},{'name':_0xf6c0('0x1d'),'value':_0x1af16f[_0xf6c0('0x1e')]},{'name':_0xf6c0('0x1f'),'value':_0x1d701a}];if(_0x17d2ac[_0xf6c0('0x20')]){_['forEach'](_0x17d2ac,function(_0x262a23){if(_0x44e822[_0x262a23[_0xf6c0('0x21')]]){_0x2794ae[_0xf6c0('0x22')]({'name':_0x262a23[_0xf6c0('0x23')],'value':_0x44e822[_0x262a23[_0xf6c0('0x21')]]});}});}return request({'form':{'method':'set_entry','input_type':'JSON','response_type':_0xf6c0('0x24'),'rest_data':JSON[_0xf6c0('0x25')]({'session':_0x141938['id'],'module_name':_0xf6c0('0x26'),'name_value_list':_0x2794ae})}});}function getAuth(_0x1f97bb){return util[_0xf6c0('0x27')]('Basic\x20%s',new Buffer(_0x1f97bb[_0xf6c0('0x28')]+':X')[_0xf6c0('0x29')](_0xf6c0('0x2a')));}function getServerInfo(_0xbe90ed){return request({'form':{'method':_0xf6c0('0x2b'),'input_type':'JSON','response_type':'JSON','rest_data':JSON[_0xf6c0('0x25')]({'session':_0xbe90ed['id']})}});}function getUser(_0x559a22,_0x4fdb55,_0x1a30a6){if(!_['isNil'](_0x4fdb55)){logger[_0xf6c0('0xf')]('Getting\x20agent\x20with\x20name',_0x4fdb55);return request({'form':{'method':'get_entry_list','input_type':_0xf6c0('0x24'),'response_type':_0xf6c0('0x24'),'rest_data':JSON['stringify']({'session':_0x1a30a6['id'],'module_name':_0xf6c0('0x2c'),'query':util['format'](_0xf6c0('0x2d'),_0x4fdb55),'order_by':'','offset':'0','select_fields':['id',_0xf6c0('0x1e'),_0xf6c0('0x2e')],'link_name_to_fields_array':[],'max_results':-0x1,'deleted':'0'})}})[_0xf6c0('0x2f')](function(_0x29489b){if(_0x29489b['entry_list'][_0xf6c0('0x20')]){var _0x3ef968=_[_0xf6c0('0x30')](_0x29489b[_0xf6c0('0x31')],function(_0x3b0921){return _0x3b0921[_0xf6c0('0x32')][_0xf6c0('0x2e')][_0xf6c0('0x33')]===_0x4fdb55;});if(_0x3ef968){logger[_0xf6c0('0xf')]('Agent\x20found!');return BPromise[_0xf6c0('0x34')]({'id':_0x3ef968[_0xf6c0('0x32')]['id'][_0xf6c0('0x33')],'name':_0x3ef968['name_value_list'][_0xf6c0('0x1e')][_0xf6c0('0x33')]});}}logger[_0xf6c0('0xf')](_0xf6c0('0x35'));return BPromise[_0xf6c0('0x34')]({'id':_0x1a30a6['name_value_list'][_0xf6c0('0x36')]['value'],'name':_0x1a30a6[_0xf6c0('0x32')][_0xf6c0('0x2e')][_0xf6c0('0x33')]});});}else{logger[_0xf6c0('0xf')](_0xf6c0('0x37'));return BPromise[_0xf6c0('0x34')]({'id':_0x1a30a6['name_value_list'][_0xf6c0('0x36')]['value'],'name':_0x1a30a6['name_value_list'][_0xf6c0('0x2e')][_0xf6c0('0x33')]});}}function getEndUser(_0x233082,_0x5eddf6,_0x4c65f1,_0x4520a6){logger[_0xf6c0('0xf')](_0xf6c0('0x38'),_0x4c65f1);return request({'form':{'method':_0xf6c0('0x39'),'input_type':_0xf6c0('0x24'),'response_type':'JSON','rest_data':JSON['stringify']({'session':_0x4520a6['id'],'module_name':'Contacts','query':util[_0xf6c0('0x27')](_0xf6c0('0x3a'),_0x4c65f1),'order_by':'','offset':'0','select_fields':['id',_0xf6c0('0x1e'),_0xf6c0('0x3b')],'link_name_to_fields_array':[],'max_results':-0x1,'deleted':'0'})}})[_0xf6c0('0x2f')](function(_0xe57cbd){if(_0xe57cbd[_0xf6c0('0x31')][_0xf6c0('0x20')]){var _0x2db8b1=_[_0xf6c0('0x30')](_0xe57cbd['entry_list'],function(_0x186ef9){return _0x186ef9[_0xf6c0('0x32')]['phone_home'][_0xf6c0('0x33')]===_0x4c65f1;});if(_0x2db8b1){logger[_0xf6c0('0xf')](_0xf6c0('0x3c'));return BPromise[_0xf6c0('0x34')]({'id':_0x2db8b1[_0xf6c0('0x32')]['id'][_0xf6c0('0x33')],'name':_0x2db8b1[_0xf6c0('0x32')][_0xf6c0('0x1e')]['value'],'phone':_0x2db8b1[_0xf6c0('0x32')][_0xf6c0('0x3b')][_0xf6c0('0x33')]});}}else{logger[_0xf6c0('0xf')](_0xf6c0('0x3d'));return request({'form':{'method':_0xf6c0('0x3e'),'input_type':'JSON','response_type':_0xf6c0('0x24'),'rest_data':JSON[_0xf6c0('0x25')]({'session':_0x4520a6['id'],'module_name':_0xf6c0('0x1c'),'name_value_list':[{'name':'first_name','value':_0x5eddf6!==_0xf6c0('0x3f')?_0x5eddf6:util['format'](_0xf6c0('0x40'),_0x4c65f1)},{'name':_0xf6c0('0x3b'),'value':_0x4c65f1}]})}})[_0xf6c0('0x2f')](function(_0x211f0a){logger[_0xf6c0('0xf')](_0xf6c0('0x41'));return BPromise[_0xf6c0('0x34')]({'id':_0x211f0a['id'],'name':_0x211f0a[_0xf6c0('0x31')]['first_name']['value'],'phone':_0x211f0a[_0xf6c0('0x31')][_0xf6c0('0x3b')][_0xf6c0('0x33')]});});}});}function request(_0xb21a2f){logger[_0xf6c0('0x42')](_0xf6c0('0x43'),JSON[_0xf6c0('0x25')](_0xb21a2f));return rp(_[_0xf6c0('0x44')](def,_0xb21a2f));}function getTags(_0xc929f,_0x5b1d08){var _0x4b454c=[];if(_0xc929f&&_0xc929f[_0xf6c0('0x20')]>0x0){_0x4b454c=_[_0xf6c0('0x45')](_0xc929f,_0x5b1d08);}return _0x4b454c;}function getCustomFields(_0x4e8ee1,_0x1f89b8){var _0x4879d8=[];var _0x18fe7b={'custom_fields':[]};if(_0x4e8ee1[_0xf6c0('0x20')]>0x0){_[_0xf6c0('0x46')](_0x4e8ee1,function(_0x532fc2){if(_0x532fc2[_0xf6c0('0x47')]===_0xf6c0('0x48')&&_0x532fc2[_0xf6c0('0x49')]&&!_0x532fc2[_0xf6c0('0x4a')]){_0x18fe7b[_0x532fc2[_0xf6c0('0x49')][_0xf6c0('0x4b')]()]=_0x532fc2[_0xf6c0('0x4c')][_0xf6c0('0x29')]();}else if(_0x532fc2[_0xf6c0('0x47')]===_0xf6c0('0x48')&&_0x532fc2[_0xf6c0('0x23')]&&_0x532fc2[_0xf6c0('0x4a')]){_0x18fe7b[_0xf6c0('0x4d')][_0xf6c0('0x22')]({'id':_0x532fc2[_0xf6c0('0x23')],'value':_0x532fc2[_0xf6c0('0x4c')][_0xf6c0('0x29')]()});}else if(_0x532fc2['type']==='variable'&&_0x532fc2[_0xf6c0('0x21')]&&_0x532fc2[_0xf6c0('0x23')]&&_0x532fc2[_0xf6c0('0x4a')]){_0x1f89b8[_0x532fc2['variableName']]&&_0x18fe7b[_0xf6c0('0x4d')][_0xf6c0('0x22')]({'id':_0x532fc2[_0xf6c0('0x23')],'value':_0x1f89b8[_0x532fc2[_0xf6c0('0x21')]][_0xf6c0('0x29')]()});}else if(_0x532fc2[_0xf6c0('0x47')]==='customVariable'&&_0x532fc2[_0xf6c0('0x4e')]&&_0x532fc2[_0xf6c0('0x4e')][_0xf6c0('0x1e')]&&_0x532fc2[_0xf6c0('0x23')]&&_0x532fc2[_0xf6c0('0x4a')]){_0x1f89b8[_0x532fc2[_0xf6c0('0x4e')][_0xf6c0('0x1e')][_0xf6c0('0x4b')]()]&&_0x18fe7b[_0xf6c0('0x4d')][_0xf6c0('0x22')]({'id':_0x532fc2[_0xf6c0('0x23')],'value':_0x1f89b8[_0x532fc2[_0xf6c0('0x4e')][_0xf6c0('0x1e')][_0xf6c0('0x4b')]()][_0xf6c0('0x29')]()});}});}return _0x18fe7b;}function getConnection(_0x75c3f5){return request({'method':'POST','form':{'method':_0xf6c0('0x4f'),'input_type':_0xf6c0('0x24'),'response_type':_0xf6c0('0x24'),'rest_data':JSON[_0xf6c0('0x25')]({'user_auth':{'user_name':_0x75c3f5[_0xf6c0('0x50')],'password':_0x75c3f5[_0xf6c0('0x51')],'encryption':_0xf6c0('0x52')},'application':_0xf6c0('0x53')})}})[_0xf6c0('0x2f')](function(_0x1302c9){var _0x5450d3=_0x1302c9;if(_0x5450d3['id']){def['sessionID']=_0x5450d3['id'];return BPromise[_0xf6c0('0x34')](_0x5450d3);}else{throw new Error(util[_0xf6c0('0x27')]('Account\x20%d\x20is\x20not\x20valid',_0x75c3f5['id']));}});}function setRelationship(_0x46b4ae,_0x2c746e,_0x5cfa1f,_0x15146e){return request({'form':{'method':_0xf6c0('0x54'),'input_type':_0xf6c0('0x24'),'response_type':_0xf6c0('0x24'),'rest_data':JSON[_0xf6c0('0x25')]({'session':_0x46b4ae['id'],'module_name':_0xf6c0('0x26'),'module_id':_0x5cfa1f['id'],'link_field_name':_0x15146e,'related_ids':[_0x2c746e['id']],'name_value_list':[],'delete':0x0})}});}exports[_0xf6c0('0x55')]=function(_0x52a3bd,_0x1a4744,_0x4012ad,_0x580c22,_0x5e2176,_0x352f56){var _0xd79247,_0x40d0c7,_0x141d65,_0x552bef;_0x352f56[_0xf6c0('0x56')]=intUtil[_0xf6c0('0x57')](_0x352f56[_0xf6c0('0x56')]);_0x352f56[_0xf6c0('0x58')]=intUtil[_0xf6c0('0x57')](_0x352f56[_0xf6c0('0x58')]);def[_0xf6c0('0x59')]=util[_0xf6c0('0x27')](_0xf6c0('0x5a'),_0x352f56[_0xf6c0('0x56')]);if(_0x5e2176&&_0x5e2176['monitor_format']){logger['info'](_0xf6c0('0x5b'),_0xf6c0('0x5c'));_0x1a4744['recordingURL']=util['format'](_0xf6c0('0x5d'),_0x352f56[_0xf6c0('0x58')],_0x1a4744[_0xf6c0('0x5e')],md5(_0x1a4744[_0xf6c0('0x5e')]));}else{_0x1a4744[_0xf6c0('0x5f')]='';}return getConnection(_0x352f56)[_0xf6c0('0x2f')](function(_0x53f2a5){_0x552bef=_0x53f2a5;return getUser(_0x352f56,_0x580c22[_0xf6c0('0x1e')],_0x552bef);})[_0xf6c0('0x2f')](function(_0x198dcf){_0xd79247=_0x198dcf;logger['info'](_0xf6c0('0x60'),_0xd79247['id']);return getEndUser(_0x352f56,_0x1a4744[_0xf6c0('0x61')],_0x1a4744[_0xf6c0('0x62')],_0x552bef);})['then'](function(_0x4c80ec){_0x40d0c7=_0x4c80ec;logger[_0xf6c0('0xf')](_0xf6c0('0x63'),_0x40d0c7['id']);return getTicket(_0x352f56,_0xd79247,_0x40d0c7,_0x4012ad,_0x1a4744,_0x4012ad['Fields'],_0x552bef,_0xf6c0('0x64'));})[_0xf6c0('0x2f')](function(_0x44bdf1){_0x141d65=_0x44bdf1;logger[_0xf6c0('0xf')](_0xf6c0('0x65'));logger['info'](_0xf6c0('0x66'),_0x141d65['id']);return setRelationship(_0x552bef,_0xd79247,_0x141d65,'users');})[_0xf6c0('0x2f')](function(){return setRelationship(_0x552bef,_0x40d0c7,_0x141d65,'contacts');})['then'](function(){return getServerInfo(_0x552bef);})['then'](function(_0x4277e0){var _0x2c9443=parseInt(_0x4277e0[_0xf6c0('0x67')][_0xf6c0('0x68')](0x0));var _0x133ca2=util[_0xf6c0('0x27')]('%s/index.php?action=ajaxui#ajaxUILoc=index.php%3Fmodule%3DCalls%26action%3DEditView%26record%3D%s',_0x352f56[_0xf6c0('0x56')],_0x141d65['id']);if(_0x2c9443>0x6){_0x133ca2=util['format'](_0xf6c0('0x69'),_0x352f56[_0xf6c0('0x56')],_0x141d65['id']);}logger[_0xf6c0('0xf')](_0xf6c0('0x5b'),_0xf6c0('0x6a'));emit(util[_0xf6c0('0x27')]('user:%s',_0x580c22['name']),_0xf6c0('0x6b'),{'uri':_0x133ca2});})[_0xf6c0('0x6c')](function(_0x53119a){logger[_0xf6c0('0x6d')](_0xf6c0('0x5b'),JSON[_0xf6c0('0x25')](_0x53119a));});};exports[_0xf6c0('0x6e')]=function(_0x5bd482,_0x56b448,_0xfbf28d,_0x4a4b86,_0x33af28,_0x32a6e0,_0x43c869){var _0x31dfa1,_0x453dd4,_0x2f3b38,_0x51aad2;_0x32a6e0[_0xf6c0('0x56')]=intUtil[_0xf6c0('0x57')](_0x32a6e0[_0xf6c0('0x56')]);_0x32a6e0[_0xf6c0('0x58')]=intUtil[_0xf6c0('0x57')](_0x32a6e0[_0xf6c0('0x58')]);def[_0xf6c0('0x59')]=util[_0xf6c0('0x27')]('%s/service/v4_1/rest.php',_0x32a6e0[_0xf6c0('0x56')]);if(_0x43c869&&_0x43c869[_0xf6c0('0x6f')]&&_0x43c869[_0xf6c0('0x6f')]!==_0xf6c0('0x70')){logger[_0xf6c0('0xf')]('[OUTBOUND]','Recording\x20is\x20enabled!');_0x56b448[_0xf6c0('0x5f')]=util[_0xf6c0('0x27')](_0xf6c0('0x5d'),_0x32a6e0[_0xf6c0('0x58')],_0x56b448['uniqueid'],md5(_0x56b448['uniqueid']));}return getConnection(_0x32a6e0)['then'](function(_0x31382c){_0x51aad2=_0x31382c;return getUser(_0x32a6e0,_0x4a4b86['name'],_0x51aad2);})[_0xf6c0('0x2f')](function(_0x4681ee){_0x31dfa1=_0x4681ee;logger[_0xf6c0('0xf')](_0xf6c0('0x60'),_0x31dfa1['id']);return getEndUser(_0x32a6e0,_0x56b448[_0xf6c0('0x71')],_0x56b448[_0xf6c0('0x72')],_0x51aad2);})[_0xf6c0('0x2f')](function(_0x4fc538){_0x453dd4=_0x4fc538;logger['info'](_0xf6c0('0x63'),_0x453dd4['id']);return getTicket(_0x32a6e0,_0x31dfa1,_0x453dd4,_0xfbf28d,_0x56b448,_0xfbf28d[_0xf6c0('0x73')],_0x51aad2,_0xf6c0('0x74'));})[_0xf6c0('0x2f')](function(_0x3974cd){_0x2f3b38=_0x3974cd;logger[_0xf6c0('0xf')](_0xf6c0('0x65'));logger[_0xf6c0('0xf')](_0xf6c0('0x66'),_0x2f3b38['id']);return setRelationship(_0x51aad2,_0x31dfa1,_0x2f3b38,'users');})[_0xf6c0('0x2f')](function(){return setRelationship(_0x51aad2,_0x453dd4,_0x2f3b38,_0xf6c0('0x75'));})[_0xf6c0('0x2f')](function(){return getServerInfo(_0x51aad2);})[_0xf6c0('0x2f')](function(_0x48e7db){var _0x17eed5=parseInt(_0x48e7db[_0xf6c0('0x67')]['charAt'](0x0));var _0x1b46a3=util['format'](_0xf6c0('0x76'),_0x32a6e0[_0xf6c0('0x56')],_0x2f3b38['id']);if(_0x17eed5>0x6){_0x1b46a3=util[_0xf6c0('0x27')](_0xf6c0('0x69'),_0x32a6e0['remoteUri'],_0x2f3b38['id']);}logger[_0xf6c0('0xf')](_0xf6c0('0x77'),_0xf6c0('0x6a'));emit(util['format'](_0xf6c0('0x78'),_0x4a4b86[_0xf6c0('0x1e')]),_0xf6c0('0x6b'),{'uri':_0x1b46a3});})['catch'](function(_0x42ac0c){logger['error'](_0xf6c0('0x77'),JSON['stringify'](_0x42ac0c));});};exports[_0xf6c0('0x79')]=function(_0x515bf3,_0x5c3562,_0x469ada,_0x135dc4,_0x8d9a7,_0x2ebb20){var _0x5de335,_0x1612f7,_0x3f735a,_0x53f75a;_0x2ebb20[_0xf6c0('0x56')]=intUtil[_0xf6c0('0x57')](_0x2ebb20[_0xf6c0('0x56')]);_0x2ebb20[_0xf6c0('0x58')]=intUtil[_0xf6c0('0x57')](_0x2ebb20['serverUrl']);def[_0xf6c0('0x59')]=util[_0xf6c0('0x27')](_0xf6c0('0x5a'),_0x2ebb20['remoteUri']);if(_0x8d9a7&&_0x8d9a7['monitor_format']){logger[_0xf6c0('0xf')]('['+_0x5c3562[_0xf6c0('0x7a')][_0xf6c0('0x7b')]()+']',_0xf6c0('0x5c'));_0x5c3562[_0xf6c0('0x5f')]=util[_0xf6c0('0x27')](_0xf6c0('0x5d'),_0x2ebb20['serverUrl'],_0x5c3562[_0xf6c0('0x5e')],md5(_0x5c3562['uniqueid']));}else{_0x5c3562[_0xf6c0('0x5f')]='';}return getConnection(_0x2ebb20)[_0xf6c0('0x2f')](function(_0x5a82b1){_0x53f75a=_0x5a82b1;if(!_['isNil'](_0x135dc4)){return getUser(_0x2ebb20,_0x135dc4['name'],_0x53f75a);}else{return getUser(_0x2ebb20,null,_0x53f75a);}})[_0xf6c0('0x2f')](function(_0x580895){_0x5de335=_0x580895;logger[_0xf6c0('0xf')](_0xf6c0('0x60'),_0x5de335['id']);return getEndUser(_0x2ebb20,_0x5c3562[_0xf6c0('0x61')],_0x5c3562[_0xf6c0('0x62')],_0x53f75a);})['then'](function(_0x20ec58){_0x1612f7=_0x20ec58;logger['info'](_0xf6c0('0x63'),_0x1612f7['id']);return getTicket(_0x2ebb20,_0x5de335,_0x1612f7,_0x469ada,_0x5c3562,_0x469ada[_0xf6c0('0x73')],_0x53f75a,_0xf6c0('0x64'));})['then'](function(_0xa92781){_0x3f735a=_0xa92781;logger[_0xf6c0('0xf')](_0xf6c0('0x65'));logger[_0xf6c0('0xf')](_0xf6c0('0x66'),_0x3f735a['id']);return setRelationship(_0x53f75a,_0x5de335,_0x3f735a,_0xf6c0('0x7c'));})[_0xf6c0('0x2f')](function(){return setRelationship(_0x53f75a,_0x1612f7,_0x3f735a,_0xf6c0('0x75'));})[_0xf6c0('0x2f')](function(){return getServerInfo(_0x53f75a);})['catch'](function(_0x6431eb){logger['error']('['+_0x5c3562[_0xf6c0('0x7a')][_0xf6c0('0x7b')]()+']',JSON['stringify'](_0x6431eb));});};
\ No newline at end of file
+var _0xf379=['Displaying\x20ticket\x20to\x20agent\x20in\x20a\x20new\x20tab...','trigger:browser:url','catch','error','outbound','none','The\x20User\x20ID\x20is:','destcalleridname','destcalleridnum','Outbound','Ticket\x20created!','contacts','%s/index.php?action=ajaxui#ajaxUILoc=index.php%3Fmodule%3DCalls%26action%3DEditView%26record%3D%s','[OUTBOUND]','user:%s','unmanaged','%s/service/v4_1/rest.php','lastevent','toUpperCase','Fields','lodash','request-promise','bluebird','md5','util','ioredis','../../../../config/environment','../../../../config/logger','sugarcrm','redis','defaults','localhost','POST','emit','info','Creating\x20new\x20ticket...','name','getString','Subjects','assigned_user_id','created_by','description','Descriptions','toISOString','slice','replace','duration_hours','duration_minutes','parent_id','parent_type','Contacts','parent_name','direction','length','forEach','variableName','set_entry','JSON','stringify','Calls','Basic\x20%s','apiKey','toString','base64','get_server_info','isNil','Employees','format','INSTR\x20(\x20users.user_name,\x20\x22%s\x22)\x20>\x200','user_name','name_value_list','Agent\x20found!','value','Agent\x20not\x20found,\x20using\x20the\x20admin\x20account!','resolve','user_id','Agent\x20not\x20available,\x20using\x20the\x20admin\x20account!','Searching\x20enduser\x20with\x20phone','get_entry_list','contacts.phone_home\x20=\x20\x22%s\x22','phone_home','then','entry_list','Enduser\x20found!','Enduser\x20not\x20found,\x20creating\x20a\x20new\x20enduser!','first_name','<unknown>','Caller\x20-\x20%s','Enduser\x20created.','debug','[HTTP]','map','type','nameField','customField','toLowerCase','content','string','idField','custom_fields','variable','push','customVariable','Variable','login','username','password','PLAIN','xCALLY\x20Motion\x20integration','set_relationship','remoteUri','stripTrailingSlash','serverUrl','uri','monitor_format','[QUEUE]','Recording\x20is\x20enabled!','recordingURL','%s/api/voice/recordings/%s/downloads?type=uniqueid&token=%s','uniqueid','calleridname','calleridnum','The\x20Enduser\x20ID\x20is:','The\x20Ticket\x20ID\x20is:','users','charAt','%s/#bwc/index.php?module=Calls&action=EditView&record=%s'];(function(_0xc973f8,_0x1759ec){var _0x5cd9d5=function(_0x582522){while(--_0x582522){_0xc973f8['push'](_0xc973f8['shift']());}};_0x5cd9d5(++_0x1759ec);}(_0xf379,0x191));var _0x9f37=function(_0x241644,_0x2289a2){_0x241644=_0x241644-0x0;var _0x25c77c=_0xf379[_0x241644];return _0x25c77c;};'use strict';var _=require(_0x9f37('0x0'));var rp=require(_0x9f37('0x1'));var BPromise=require(_0x9f37('0x2'));var md5=require(_0x9f37('0x3'));var util=require(_0x9f37('0x4'));var Redis=require(_0x9f37('0x5'));var intUtil=require('./util');var config=require(_0x9f37('0x6'));var logger=require(_0x9f37('0x7'))(_0x9f37('0x8'));config[_0x9f37('0x9')]=_[_0x9f37('0xa')](config[_0x9f37('0x9')],{'host':_0x9f37('0xb'),'port':0x18eb});var io=require('socket.io-emitter')(new Redis(config['redis']));var def={'method':_0x9f37('0xc'),'json':!![]};function emit(_0x20b4a9,_0x158f6c,_0xc1c7){io['to'](_0x20b4a9)[_0x9f37('0xd')](_0x158f6c,_0xc1c7);}function getTicket(_0x1e5dda,_0x2db993,_0x27265d,_0x4e7bce,_0x5db4b4,_0x1a8b82,_0x245485,_0x1d0e30){logger[_0x9f37('0xe')](_0x9f37('0xf'));var _0x56b5ff=new Date();var _0x5a4c8c=[{'name':_0x9f37('0x10'),'value':intUtil[_0x9f37('0x11')](_0x4e7bce[_0x9f37('0x12')],_0x5db4b4,'\x20')},{'name':_0x9f37('0x13'),'value':_0x2db993['id']},{'name':_0x9f37('0x14'),'value':_0x2db993['id']},{'name':_0x9f37('0x15'),'value':intUtil[_0x9f37('0x11')](_0x4e7bce[_0x9f37('0x16')],_0x5db4b4,'\x0a')},{'name':'date_start','value':_0x56b5ff[_0x9f37('0x17')]()[_0x9f37('0x18')](0x0,0x13)[_0x9f37('0x19')]('T','\x20')},{'name':_0x9f37('0x1a'),'value':'0'},{'name':_0x9f37('0x1b'),'value':'15'},{'name':_0x9f37('0x1c'),'value':_0x27265d['id']},{'name':_0x9f37('0x1d'),'value':_0x9f37('0x1e')},{'name':_0x9f37('0x1f'),'value':_0x27265d[_0x9f37('0x10')]},{'name':_0x9f37('0x20'),'value':_0x1d0e30}];if(_0x1a8b82[_0x9f37('0x21')]){_[_0x9f37('0x22')](_0x1a8b82,function(_0x582702){if(_0x5db4b4[_0x582702[_0x9f37('0x23')]]){_0x5a4c8c['push']({'name':_0x582702['idField'],'value':_0x5db4b4[_0x582702[_0x9f37('0x23')]]});}});}return request({'form':{'method':_0x9f37('0x24'),'input_type':_0x9f37('0x25'),'response_type':_0x9f37('0x25'),'rest_data':JSON[_0x9f37('0x26')]({'session':_0x245485['id'],'module_name':_0x9f37('0x27'),'name_value_list':_0x5a4c8c})}});}function getAuth(_0x55493b){return util['format'](_0x9f37('0x28'),new Buffer(_0x55493b[_0x9f37('0x29')]+':X')[_0x9f37('0x2a')](_0x9f37('0x2b')));}function getServerInfo(_0x136f6c){return request({'form':{'method':_0x9f37('0x2c'),'input_type':_0x9f37('0x25'),'response_type':'JSON','rest_data':JSON['stringify']({'session':_0x136f6c['id']})}});}function getUser(_0x2ba4dc,_0x318337,_0x3cfbae){if(!_[_0x9f37('0x2d')](_0x318337)){logger[_0x9f37('0xe')]('Getting\x20agent\x20with\x20name',_0x318337);return request({'form':{'method':'get_entry_list','input_type':'JSON','response_type':_0x9f37('0x25'),'rest_data':JSON[_0x9f37('0x26')]({'session':_0x3cfbae['id'],'module_name':_0x9f37('0x2e'),'query':util[_0x9f37('0x2f')](_0x9f37('0x30'),_0x318337),'order_by':'','offset':'0','select_fields':['id',_0x9f37('0x10'),_0x9f37('0x31')],'link_name_to_fields_array':[],'max_results':-0x1,'deleted':'0'})}})['then'](function(_0x525e8b){if(_0x525e8b['entry_list'][_0x9f37('0x21')]){var _0x3f0e0e=_['find'](_0x525e8b['entry_list'],function(_0x5825a3){return _0x5825a3[_0x9f37('0x32')][_0x9f37('0x31')]['value']===_0x318337;});if(_0x3f0e0e){logger['info'](_0x9f37('0x33'));return BPromise['resolve']({'id':_0x3f0e0e[_0x9f37('0x32')]['id'][_0x9f37('0x34')],'name':_0x3f0e0e[_0x9f37('0x32')][_0x9f37('0x10')][_0x9f37('0x34')]});}}logger[_0x9f37('0xe')](_0x9f37('0x35'));return BPromise[_0x9f37('0x36')]({'id':_0x3cfbae[_0x9f37('0x32')][_0x9f37('0x37')]['value'],'name':_0x3cfbae[_0x9f37('0x32')]['user_name'][_0x9f37('0x34')]});});}else{logger['info'](_0x9f37('0x38'));return BPromise[_0x9f37('0x36')]({'id':_0x3cfbae[_0x9f37('0x32')]['user_id'][_0x9f37('0x34')],'name':_0x3cfbae['name_value_list'][_0x9f37('0x31')]['value']});}}function getEndUser(_0x31dbd8,_0xc7cad7,_0x437997,_0xc19bad){logger[_0x9f37('0xe')](_0x9f37('0x39'),_0x437997);return request({'form':{'method':_0x9f37('0x3a'),'input_type':_0x9f37('0x25'),'response_type':_0x9f37('0x25'),'rest_data':JSON[_0x9f37('0x26')]({'session':_0xc19bad['id'],'module_name':_0x9f37('0x1e'),'query':util[_0x9f37('0x2f')](_0x9f37('0x3b'),_0x437997),'order_by':'','offset':'0','select_fields':['id',_0x9f37('0x10'),_0x9f37('0x3c')],'link_name_to_fields_array':[],'max_results':-0x1,'deleted':'0'})}})[_0x9f37('0x3d')](function(_0x2543a5){if(_0x2543a5['entry_list'][_0x9f37('0x21')]){var _0x2ec78d=_['find'](_0x2543a5[_0x9f37('0x3e')],function(_0x33d77e){return _0x33d77e[_0x9f37('0x32')][_0x9f37('0x3c')][_0x9f37('0x34')]===_0x437997;});if(_0x2ec78d){logger[_0x9f37('0xe')](_0x9f37('0x3f'));return BPromise['resolve']({'id':_0x2ec78d[_0x9f37('0x32')]['id'][_0x9f37('0x34')],'name':_0x2ec78d[_0x9f37('0x32')][_0x9f37('0x10')]['value'],'phone':_0x2ec78d['name_value_list']['phone_home'][_0x9f37('0x34')]});}}else{logger['info'](_0x9f37('0x40'));return request({'form':{'method':'set_entry','input_type':_0x9f37('0x25'),'response_type':_0x9f37('0x25'),'rest_data':JSON['stringify']({'session':_0xc19bad['id'],'module_name':'Contacts','name_value_list':[{'name':_0x9f37('0x41'),'value':_0xc7cad7!==_0x9f37('0x42')?_0xc7cad7:util['format'](_0x9f37('0x43'),_0x437997)},{'name':'phone_home','value':_0x437997}]})}})[_0x9f37('0x3d')](function(_0x35186a){logger['info'](_0x9f37('0x44'));return BPromise['resolve']({'id':_0x35186a['id'],'name':_0x35186a[_0x9f37('0x3e')][_0x9f37('0x41')]['value'],'phone':_0x35186a[_0x9f37('0x3e')][_0x9f37('0x3c')][_0x9f37('0x34')]});});}});}function request(_0x4c3f3b){logger[_0x9f37('0x45')](_0x9f37('0x46'),JSON[_0x9f37('0x26')](_0x4c3f3b));return rp(_['merge'](def,_0x4c3f3b));}function getTags(_0x24163c,_0x7be407){var _0x46bfa2=[];if(_0x24163c&&_0x24163c[_0x9f37('0x21')]>0x0){_0x46bfa2=_[_0x9f37('0x47')](_0x24163c,_0x7be407);}return _0x46bfa2;}function getCustomFields(_0x761afc,_0x5094e8){var _0x518ee=[];var _0x566cfa={'custom_fields':[]};if(_0x761afc[_0x9f37('0x21')]>0x0){_[_0x9f37('0x22')](_0x761afc,function(_0x50680d){if(_0x50680d[_0x9f37('0x48')]==='string'&&_0x50680d[_0x9f37('0x49')]&&!_0x50680d[_0x9f37('0x4a')]){_0x566cfa[_0x50680d[_0x9f37('0x49')][_0x9f37('0x4b')]()]=_0x50680d[_0x9f37('0x4c')][_0x9f37('0x2a')]();}else if(_0x50680d['type']===_0x9f37('0x4d')&&_0x50680d[_0x9f37('0x4e')]&&_0x50680d[_0x9f37('0x4a')]){_0x566cfa[_0x9f37('0x4f')]['push']({'id':_0x50680d[_0x9f37('0x4e')],'value':_0x50680d[_0x9f37('0x4c')][_0x9f37('0x2a')]()});}else if(_0x50680d['type']===_0x9f37('0x50')&&_0x50680d['variableName']&&_0x50680d[_0x9f37('0x4e')]&&_0x50680d['customField']){_0x5094e8[_0x50680d[_0x9f37('0x23')]]&&_0x566cfa['custom_fields'][_0x9f37('0x51')]({'id':_0x50680d[_0x9f37('0x4e')],'value':_0x5094e8[_0x50680d[_0x9f37('0x23')]][_0x9f37('0x2a')]()});}else if(_0x50680d[_0x9f37('0x48')]===_0x9f37('0x52')&&_0x50680d[_0x9f37('0x53')]&&_0x50680d['Variable'][_0x9f37('0x10')]&&_0x50680d[_0x9f37('0x4e')]&&_0x50680d['customField']){_0x5094e8[_0x50680d[_0x9f37('0x53')]['name'][_0x9f37('0x4b')]()]&&_0x566cfa['custom_fields'][_0x9f37('0x51')]({'id':_0x50680d[_0x9f37('0x4e')],'value':_0x5094e8[_0x50680d[_0x9f37('0x53')][_0x9f37('0x10')]['toLowerCase']()][_0x9f37('0x2a')]()});}});}return _0x566cfa;}function getConnection(_0x36dcbe){return request({'method':_0x9f37('0xc'),'form':{'method':_0x9f37('0x54'),'input_type':_0x9f37('0x25'),'response_type':_0x9f37('0x25'),'rest_data':JSON['stringify']({'user_auth':{'user_name':_0x36dcbe[_0x9f37('0x55')],'password':_0x36dcbe[_0x9f37('0x56')],'encryption':_0x9f37('0x57')},'application':_0x9f37('0x58')})}})['then'](function(_0x5d1179){var _0x33fb34=_0x5d1179;if(_0x33fb34['id']){def['sessionID']=_0x33fb34['id'];return BPromise[_0x9f37('0x36')](_0x33fb34);}else{throw new Error(util[_0x9f37('0x2f')]('Account\x20%d\x20is\x20not\x20valid',_0x36dcbe['id']));}});}function setRelationship(_0x370d66,_0x261dc2,_0x1301fa,_0x58ef11){return request({'form':{'method':_0x9f37('0x59'),'input_type':_0x9f37('0x25'),'response_type':'JSON','rest_data':JSON[_0x9f37('0x26')]({'session':_0x370d66['id'],'module_name':_0x9f37('0x27'),'module_id':_0x1301fa['id'],'link_field_name':_0x58ef11,'related_ids':[_0x261dc2['id']],'name_value_list':[],'delete':0x0})}});}exports['queue']=function(_0x24f0ef,_0x29205f,_0x5ba5a4,_0x41052c,_0x278e67,_0x54dbb9){var _0x29b4c0,_0x104fe2,_0x2b0b30,_0x56567;_0x54dbb9[_0x9f37('0x5a')]=intUtil[_0x9f37('0x5b')](_0x54dbb9[_0x9f37('0x5a')]);_0x54dbb9['serverUrl']=intUtil[_0x9f37('0x5b')](_0x54dbb9[_0x9f37('0x5c')]);def[_0x9f37('0x5d')]=util[_0x9f37('0x2f')]('%s/service/v4_1/rest.php',_0x54dbb9['remoteUri']);if(_0x278e67&&_0x278e67[_0x9f37('0x5e')]){logger[_0x9f37('0xe')](_0x9f37('0x5f'),_0x9f37('0x60'));_0x29205f[_0x9f37('0x61')]=util['format'](_0x9f37('0x62'),_0x54dbb9['serverUrl'],_0x29205f[_0x9f37('0x63')],md5(_0x29205f[_0x9f37('0x63')]));}else{_0x29205f[_0x9f37('0x61')]='';}return getConnection(_0x54dbb9)[_0x9f37('0x3d')](function(_0x13358a){_0x56567=_0x13358a;return getUser(_0x54dbb9,_0x41052c[_0x9f37('0x10')],_0x56567);})[_0x9f37('0x3d')](function(_0x4a3e4c){_0x29b4c0=_0x4a3e4c;logger[_0x9f37('0xe')]('The\x20User\x20ID\x20is:',_0x29b4c0['id']);return getEndUser(_0x54dbb9,_0x29205f[_0x9f37('0x64')],_0x29205f[_0x9f37('0x65')],_0x56567);})[_0x9f37('0x3d')](function(_0x2e6d25){_0x104fe2=_0x2e6d25;logger[_0x9f37('0xe')](_0x9f37('0x66'),_0x104fe2['id']);return getTicket(_0x54dbb9,_0x29b4c0,_0x104fe2,_0x5ba5a4,_0x29205f,_0x5ba5a4['Fields'],_0x56567,'Inbound');})['then'](function(_0x455806){_0x2b0b30=_0x455806;logger[_0x9f37('0xe')]('Ticket\x20created!');logger[_0x9f37('0xe')](_0x9f37('0x67'),_0x2b0b30['id']);return setRelationship(_0x56567,_0x29b4c0,_0x2b0b30,_0x9f37('0x68'));})['then'](function(){return setRelationship(_0x56567,_0x104fe2,_0x2b0b30,'contacts');})[_0x9f37('0x3d')](function(){return getServerInfo(_0x56567);})[_0x9f37('0x3d')](function(_0x35c36c){var _0x16bc9d=parseInt(_0x35c36c['version'][_0x9f37('0x69')](0x0));var _0x1b9f3f=util['format']('%s/index.php?action=ajaxui#ajaxUILoc=index.php%3Fmodule%3DCalls%26action%3DEditView%26record%3D%s',_0x54dbb9[_0x9f37('0x5a')],_0x2b0b30['id']);if(_0x16bc9d>0x6){_0x1b9f3f=util[_0x9f37('0x2f')](_0x9f37('0x6a'),_0x54dbb9[_0x9f37('0x5a')],_0x2b0b30['id']);}logger['info']('[QUEUE]',_0x9f37('0x6b'));emit(util['format']('user:%s',_0x41052c[_0x9f37('0x10')]),_0x9f37('0x6c'),{'uri':_0x1b9f3f});})[_0x9f37('0x6d')](function(_0x350764){logger[_0x9f37('0x6e')](_0x9f37('0x5f'),JSON[_0x9f37('0x26')](_0x350764));});};exports[_0x9f37('0x6f')]=function(_0x4a50de,_0x3c207a,_0x44c0c8,_0x1820b2,_0x14ea41,_0x3c152c,_0x6849c9){var _0x1708ef,_0xcfeea0,_0x5ae37f,_0x4ddf86;_0x3c152c[_0x9f37('0x5a')]=intUtil[_0x9f37('0x5b')](_0x3c152c[_0x9f37('0x5a')]);_0x3c152c[_0x9f37('0x5c')]=intUtil['stripTrailingSlash'](_0x3c152c[_0x9f37('0x5c')]);def[_0x9f37('0x5d')]=util[_0x9f37('0x2f')]('%s/service/v4_1/rest.php',_0x3c152c[_0x9f37('0x5a')]);if(_0x6849c9&&_0x6849c9['recordingFormat']&&_0x6849c9['recordingFormat']!==_0x9f37('0x70')){logger[_0x9f37('0xe')]('[OUTBOUND]','Recording\x20is\x20enabled!');_0x3c207a[_0x9f37('0x61')]=util[_0x9f37('0x2f')](_0x9f37('0x62'),_0x3c152c[_0x9f37('0x5c')],_0x3c207a['uniqueid'],md5(_0x3c207a[_0x9f37('0x63')]));}return getConnection(_0x3c152c)[_0x9f37('0x3d')](function(_0x3ce2bd){_0x4ddf86=_0x3ce2bd;return getUser(_0x3c152c,_0x1820b2['name'],_0x4ddf86);})[_0x9f37('0x3d')](function(_0x27da46){_0x1708ef=_0x27da46;logger[_0x9f37('0xe')](_0x9f37('0x71'),_0x1708ef['id']);return getEndUser(_0x3c152c,_0x3c207a[_0x9f37('0x72')],_0x3c207a[_0x9f37('0x73')],_0x4ddf86);})[_0x9f37('0x3d')](function(_0x2a71f2){_0xcfeea0=_0x2a71f2;logger['info'](_0x9f37('0x66'),_0xcfeea0['id']);return getTicket(_0x3c152c,_0x1708ef,_0xcfeea0,_0x44c0c8,_0x3c207a,_0x44c0c8['Fields'],_0x4ddf86,_0x9f37('0x74'));})[_0x9f37('0x3d')](function(_0x369a9f){_0x5ae37f=_0x369a9f;logger[_0x9f37('0xe')](_0x9f37('0x75'));logger['info'](_0x9f37('0x67'),_0x5ae37f['id']);return setRelationship(_0x4ddf86,_0x1708ef,_0x5ae37f,_0x9f37('0x68'));})[_0x9f37('0x3d')](function(){return setRelationship(_0x4ddf86,_0xcfeea0,_0x5ae37f,_0x9f37('0x76'));})[_0x9f37('0x3d')](function(){return getServerInfo(_0x4ddf86);})[_0x9f37('0x3d')](function(_0x442f9a){var _0x4a7822=parseInt(_0x442f9a['version']['charAt'](0x0));var _0x3e3b7b=util[_0x9f37('0x2f')](_0x9f37('0x77'),_0x3c152c['remoteUri'],_0x5ae37f['id']);if(_0x4a7822>0x6){_0x3e3b7b=util[_0x9f37('0x2f')]('%s/#bwc/index.php?module=Calls&action=EditView&record=%s',_0x3c152c[_0x9f37('0x5a')],_0x5ae37f['id']);}logger[_0x9f37('0xe')](_0x9f37('0x78'),_0x9f37('0x6b'));emit(util[_0x9f37('0x2f')](_0x9f37('0x79'),_0x1820b2[_0x9f37('0x10')]),_0x9f37('0x6c'),{'uri':_0x3e3b7b});})[_0x9f37('0x6d')](function(_0xfdc7bb){logger['error']('[OUTBOUND]',JSON[_0x9f37('0x26')](_0xfdc7bb));});};exports[_0x9f37('0x7a')]=function(_0x22cc8d,_0x14a6e2,_0x47b3fa,_0x5bba02,_0x440606,_0x19091f){var _0x3674f3,_0x415bbb,_0x2a89f4,_0x298c93;_0x19091f[_0x9f37('0x5a')]=intUtil['stripTrailingSlash'](_0x19091f[_0x9f37('0x5a')]);_0x19091f[_0x9f37('0x5c')]=intUtil[_0x9f37('0x5b')](_0x19091f[_0x9f37('0x5c')]);def[_0x9f37('0x5d')]=util[_0x9f37('0x2f')](_0x9f37('0x7b'),_0x19091f[_0x9f37('0x5a')]);if(_0x440606&&_0x440606[_0x9f37('0x5e')]){logger['info']('['+_0x14a6e2[_0x9f37('0x7c')][_0x9f37('0x7d')]()+']',_0x9f37('0x60'));_0x14a6e2[_0x9f37('0x61')]=util[_0x9f37('0x2f')](_0x9f37('0x62'),_0x19091f[_0x9f37('0x5c')],_0x14a6e2[_0x9f37('0x63')],md5(_0x14a6e2['uniqueid']));}else{_0x14a6e2[_0x9f37('0x61')]='';}return getConnection(_0x19091f)[_0x9f37('0x3d')](function(_0x5be38c){_0x298c93=_0x5be38c;if(!_[_0x9f37('0x2d')](_0x5bba02)){return getUser(_0x19091f,_0x5bba02[_0x9f37('0x10')],_0x298c93);}else{return getUser(_0x19091f,null,_0x298c93);}})[_0x9f37('0x3d')](function(_0x362cbf){_0x3674f3=_0x362cbf;logger[_0x9f37('0xe')](_0x9f37('0x71'),_0x3674f3['id']);return getEndUser(_0x19091f,_0x14a6e2[_0x9f37('0x64')],_0x14a6e2[_0x9f37('0x65')],_0x298c93);})[_0x9f37('0x3d')](function(_0x11df78){_0x415bbb=_0x11df78;logger[_0x9f37('0xe')](_0x9f37('0x66'),_0x415bbb['id']);return getTicket(_0x19091f,_0x3674f3,_0x415bbb,_0x47b3fa,_0x14a6e2,_0x47b3fa[_0x9f37('0x7e')],_0x298c93,'Inbound');})['then'](function(_0x993f62){_0x2a89f4=_0x993f62;logger[_0x9f37('0xe')](_0x9f37('0x75'));logger[_0x9f37('0xe')](_0x9f37('0x67'),_0x2a89f4['id']);return setRelationship(_0x298c93,_0x3674f3,_0x2a89f4,_0x9f37('0x68'));})[_0x9f37('0x3d')](function(){return setRelationship(_0x298c93,_0x415bbb,_0x2a89f4,_0x9f37('0x76'));})[_0x9f37('0x3d')](function(){return getServerInfo(_0x298c93);})[_0x9f37('0x6d')](function(_0x5c9e30){logger[_0x9f37('0x6e')]('['+_0x14a6e2[_0x9f37('0x7c')][_0x9f37('0x7d')]()+']',JSON['stringify'](_0x5c9e30));});};
\ No newline at end of file