Built motion from commit 775e2a94.|2.6.3
[motion2.git] / server / services / ami / trigger / integration / salesforce.js
index d886422..5f35422 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x7f8b=['endUserType','contact','lead','WhoId','account','WhatId','ticketType','Case','ContactId','AccountId','leadId','info','Association\x20between\x20Case\x20and\x20Lead\x20skipped','sobject','create','isNil','validateEmail','User','find','length','Agent\x20%s\x20found.','resolve','Name','identity','then','user_id','Agent\x20%s\x20not\x20found.\x20Switch\x20to\x20the\x20admin\x20account.','display_name','Searching\x20enduser\x20with\x20phone\x20%s.\x20Serching\x20method\x20used\x20%s.','moduleSearch','contact_lead','cloneDeep','additionalSearchContact','$or','Contact','additionalSearchLead','account_contact_lead','additionalSearchAccount','merge','execute','Lead','Account','Phone','attributes','Enduser\x20(%s)\x20with\x20phone\x20%s\x20found','moduleCreate','<unknown>','format','Caller\x20-\x20%s','Enduser\x20with\x20phone\x20%s.\x20Creating\x20method\x20used\x20%s.','LastName','Company','No\x20Company','upperFirst','string','picklist','type','idField','content','toString','variableName','customVariable','Variable','name','toLowerCase','password','concat','securityToken','remoteUri','https://login.salesforce.com','clientId','clientSecret','login','Connection\x20established.','queue','serverUrl','stripTrailingSlash','monitor_format','recordingURL','%s/api/voice/recordings/%s/downloads?type=uniqueid&token=%s','uniqueid','email','calleridnum','[QUEUE]\x20Ticket\x20%s\x20created','[QUEUE]\x20Displaying\x20ticket\x20%s\x20to\x20agent\x20%s.\x20Integration\x20account\x20type\x20%s.','integrationTab','trigger:salesforce:display','trigger:browser:url','instanceUrl','error','[QUEUE]\x20Salesforce\x20account\x20type\x20not\x20recognized.','catch','[QUEUE]','outbound','recordingFormat','[OUTBOUND]','Recording\x20is\x20enabled!','destcalleridname','Fields','[OUTBOUND]\x20Ticket\x20%s\x20created.','[OUTBOUND]\x20Displaying\x20ticket\x20%s\x20to\x20agent\x20%s.\x20Integration\x20account\x20type\x20%s.','user:%s','newTab','%s/%s/e','Salesforce\x20account\x20type\x20not\x20recognized','calleridname','lastevent','toUpperCase',']\x20Ticket\x20%s\x20created.',']\x20Integration\x20account\x20type\x20%s.','lodash','request-promise','moment','bluebird','jsforce','util','./util','../../../../config/logger','salesforce','redis','localhost','socket.io-emitter','emit','assign','getString','Subjects','Descriptions','Task','IsReminderSet','IsRecurrence'];(function(_0x167cc1,_0x56ef5a){var _0x10bc4b=function(_0xd6a255){while(--_0xd6a255){_0x167cc1['push'](_0x167cc1['shift']());}};_0x10bc4b(++_0x56ef5a);}(_0x7f8b,0xf0));var _0xb7f8=function(_0x3ea913,_0x255df2){_0x3ea913=_0x3ea913-0x0;var _0x2b4f28=_0x7f8b[_0x3ea913];return _0x2b4f28;};'use strict';var _=require(_0xb7f8('0x0'));var rp=require(_0xb7f8('0x1'));var moment=require(_0xb7f8('0x2'));var BPromise=require(_0xb7f8('0x3'));var md5=require('md5');var jsforce=require(_0xb7f8('0x4'));var util=require(_0xb7f8('0x5'));var Redis=require('ioredis');var intUtil=require(_0xb7f8('0x6'));var config=require('../../../../config/environment');var logger=require(_0xb7f8('0x7'))(_0xb7f8('0x8'));config[_0xb7f8('0x9')]=_['defaults'](config[_0xb7f8('0x9')],{'host':_0xb7f8('0xa'),'port':0x18eb});var io=require(_0xb7f8('0xb'))(new Redis(config['redis']));function emit(_0x3cf7e8,_0x1e2e20,_0x580c12){io['to'](_0x3cf7e8)[_0xb7f8('0xc')](_0x1e2e20,_0x580c12);}function getTicket(_0x4a1a5f,_0x252b5b,_0x588b27,_0xefac9d,_0x80e7a,_0x390cda,_0x2c14fb,_0x1a0ac1){var _0x2b2559=Object[_0xb7f8('0xd')]({},{'OwnerId':_0x252b5b['id'],'Subject':intUtil[_0xb7f8('0xe')](_0xefac9d[_0xb7f8('0xf')],_0x80e7a,'\x20'),'Description':intUtil[_0xb7f8('0xe')](_0xefac9d[_0xb7f8('0x10')],_0x80e7a,'\x0a')},getCustomFields(_0x390cda,_0x80e7a));if(_0x588b27){if(_0xefac9d['ticketType']===_0xb7f8('0x11')){_0x2b2559['ActivityDate']=moment['utc']();_0x2b2559[_0xb7f8('0x12')]=![];_0x2b2559[_0xb7f8('0x13')]=![];if(_0x588b27[_0xb7f8('0x14')]===_0xb7f8('0x15')||_0x588b27[_0xb7f8('0x14')]===_0xb7f8('0x16')){_0x2b2559[_0xb7f8('0x17')]=_0x588b27['id'];}else if(_0x588b27[_0xb7f8('0x14')]===_0xb7f8('0x18')){_0x2b2559[_0xb7f8('0x19')]=_0x588b27['id'];}}else if(_0xefac9d[_0xb7f8('0x1a')]===_0xb7f8('0x1b')){if(_0x588b27['endUserType']===_0xb7f8('0x15')){_0x2b2559[_0xb7f8('0x1c')]=_0x588b27['id'];}else if(_0x588b27['endUserType']===_0xb7f8('0x18')){_0x2b2559[_0xb7f8('0x1d')]=_0x588b27['id'];}else if(_0x588b27[_0xb7f8('0x14')]===_0xb7f8('0x16')&&_0xefac9d['leadId']){_0x2b2559[_0xefac9d[_0xb7f8('0x1e')]]=_0x588b27['id'];}else{logger[_0xb7f8('0x1f')](_0xb7f8('0x20'));}}}return _0x2c14fb[_0xb7f8('0x21')](_0xefac9d['ticketType'])[_0xb7f8('0x22')](_0x2b2559);}function getUser(_0x35e4e1,_0x2729cb,_0x4eed94){if(!_[_0xb7f8('0x23')](_0x2729cb)&&intUtil[_0xb7f8('0x24')](_0x2729cb)){var _0xc8f737={'Email':_0x2729cb};var _0x568d9b={'Id':!![],'Username':!![],'Name':!![],'Email':!![]};return _0x4eed94[_0xb7f8('0x21')](_0xb7f8('0x25'))[_0xb7f8('0x26')](_0xc8f737,_0x568d9b)['execute']()['then'](function(_0x31d83f){if(_0x31d83f[_0xb7f8('0x27')]){var _0x42eb73=_['find'](_0x31d83f,function(_0x561d73){return _0x561d73['Email']===_0x2729cb;});if(_0x42eb73){logger['info'](_0xb7f8('0x28'),_0x2729cb);return BPromise[_0xb7f8('0x29')]({'id':_0x42eb73['Id'],'name':_0x42eb73[_0xb7f8('0x2a')]});}}else{logger[_0xb7f8('0x1f')]('Agent\x20%s\x20not\x20found.\x20Switch\x20to\x20the\x20admin\x20account.',_0x2729cb);return _0x4eed94[_0xb7f8('0x2b')]()[_0xb7f8('0x2c')](function(_0x27251d){return BPromise[_0xb7f8('0x29')]({'id':_0x27251d[_0xb7f8('0x2d')],'name':_0x27251d['display_name']});});}});}else{logger[_0xb7f8('0x1f')](_0xb7f8('0x2e'),_0x2729cb);return _0x4eed94['identity']()[_0xb7f8('0x2c')](function(_0x578b25){return BPromise['resolve']({'id':_0x578b25[_0xb7f8('0x2d')],'name':_0x578b25[_0xb7f8('0x2f')]});});}}function getEndUser(_0x4cba06,_0x50e55d,_0x1bc156,_0x146901,_0x8c9b67){var _0x25c331={'$or':{'Phone':_0x146901}};var _0x27b8f6={'Id':!![],'Name':!![],'Phone':!![]};return BPromise[_0xb7f8('0x29')]()[_0xb7f8('0x2c')](function(){logger['info'](_0xb7f8('0x30'),_0x146901,_0x50e55d[_0xb7f8('0x31')]);switch(_0x50e55d[_0xb7f8('0x31')]){case _0xb7f8('0x32'):var _0x5b39ef=_[_0xb7f8('0x33')](_0x25c331);if(_0x50e55d[_0xb7f8('0x34')]){var _0x48a675={};_0x48a675[_0x50e55d['additionalSearchContact']]=_0x146901;_['merge'](_0x5b39ef[_0xb7f8('0x35')],_0x48a675);}return _0x8c9b67[_0xb7f8('0x21')](_0xb7f8('0x36'))[_0xb7f8('0x26')](_0x5b39ef,_0x27b8f6)['execute']()[_0xb7f8('0x2c')](function(_0x421ade){if(_0x421ade&&_0x421ade['length']){return _0x421ade;}else{var _0x3461ba=_[_0xb7f8('0x33')](_0x25c331);if(_0x50e55d['additionalSearchLead']){var _0x5ee217={};_0x5ee217[_0x50e55d[_0xb7f8('0x37')]]=_0x146901;_['merge'](_0x3461ba[_0xb7f8('0x35')],_0x5ee217);}return _0x8c9b67[_0xb7f8('0x21')]('Lead')['find'](_0x3461ba,_0x27b8f6);}});case _0xb7f8('0x38'):var _0x424a9e=_['cloneDeep'](_0x25c331);if(_0x50e55d[_0xb7f8('0x39')]){var _0x48a675={};_0x48a675[_0x50e55d[_0xb7f8('0x39')]]=_0x146901;_[_0xb7f8('0x3a')](_0x424a9e[_0xb7f8('0x35')],_0x48a675);}return _0x8c9b67[_0xb7f8('0x21')]('Account')['find'](_0x424a9e,_0x27b8f6)[_0xb7f8('0x3b')]()[_0xb7f8('0x2c')](function(_0x596680){if(_0x596680&&_0x596680['length']){return _0x596680;}else{var _0x797f80=_[_0xb7f8('0x33')](_0x25c331);if(_0x50e55d[_0xb7f8('0x34')]){var _0x141274={};_0x141274[_0x50e55d[_0xb7f8('0x34')]]=_0x146901;_[_0xb7f8('0x3a')](_0x797f80['$or'],_0x141274);}return _0x8c9b67[_0xb7f8('0x21')]('Contact')[_0xb7f8('0x26')](_0x797f80,_0x27b8f6)['then'](function(_0x42b6ed){if(_0x42b6ed&&_0x42b6ed['length']){return _0x42b6ed;}else{var _0x3d1f58=_['cloneDeep'](_0x25c331);if(_0x50e55d['additionalSearchLead']){var _0x280df7={};_0x280df7[_0x50e55d[_0xb7f8('0x37')]]=_0x146901;_[_0xb7f8('0x3a')](_0x3d1f58[_0xb7f8('0x35')],_0x280df7);}return _0x8c9b67['sobject']('Lead')[_0xb7f8('0x26')](_0x3d1f58,_0x27b8f6);}});}});case _0xb7f8('0x15'):var _0x5b39ef=_[_0xb7f8('0x33')](_0x25c331);if(_0x50e55d[_0xb7f8('0x34')]){var _0x48a675={};_0x48a675[_0x50e55d[_0xb7f8('0x34')]]=_0x146901;_[_0xb7f8('0x3a')](_0x5b39ef['$or'],_0x48a675);}return _0x8c9b67['sobject'](_0xb7f8('0x36'))[_0xb7f8('0x26')](_0x5b39ef,_0x27b8f6)[_0xb7f8('0x3b')]();case _0xb7f8('0x16'):var _0x1844f4=_[_0xb7f8('0x33')](_0x25c331);if(_0x50e55d['additionalSearchLead']){var _0x48a675={};_0x48a675[_0x50e55d['additionalSearchLead']]=_0x146901;_['merge'](_0x1844f4[_0xb7f8('0x35')],_0x48a675);}return _0x8c9b67[_0xb7f8('0x21')](_0xb7f8('0x3c'))[_0xb7f8('0x26')](_0x1844f4,_0x27b8f6);case'account':var _0x424a9e=_[_0xb7f8('0x33')](_0x25c331);if(_0x50e55d[_0xb7f8('0x39')]){var _0x48a675={};_0x48a675[_0x50e55d['additionalSearchAccount']]=_0x146901;_[_0xb7f8('0x3a')](_0x424a9e['$or'],_0x48a675);}return _0x8c9b67['sobject'](_0xb7f8('0x3d'))[_0xb7f8('0x26')](_0x424a9e,_0x27b8f6);default:return null;}})[_0xb7f8('0x2c')](function(_0x2af952){if(_0x2af952&&_0x2af952[_0xb7f8('0x27')]){var _0x4bf179=_['first'](_0x2af952);if(_0x4bf179){return BPromise[_0xb7f8('0x29')]({'id':_0x4bf179['Id'],'name':_0x4bf179[_0xb7f8('0x2a')],'phone':_0x4bf179[_0xb7f8('0x3e')],'endUserType':_0x4bf179[_0xb7f8('0x3f')]['type']['toLowerCase']()});}}})[_0xb7f8('0x2c')](function(_0x5f3a15){if(_0x5f3a15){logger[_0xb7f8('0x1f')](_0xb7f8('0x40'),_0x5f3a15['endUserType'],_0x146901);return BPromise[_0xb7f8('0x29')](_0x5f3a15);}else{logger[_0xb7f8('0x1f')]('Enduser\x20with\x20phone\x20%s\x20not\x20found',_0x146901);var _0x1ee49a={'Phone':_0x146901};if(_0x50e55d[_0xb7f8('0x41')]){if(_0x50e55d[_0xb7f8('0x41')]===_0xb7f8('0x15')){logger[_0xb7f8('0x1f')]('Enduser\x20with\x20phone\x20%s.\x20Creating\x20method\x20used\x20%s.',_0x146901,_0x50e55d[_0xb7f8('0x41')]);_0x1ee49a['LastName']=_0x1bc156!==_0xb7f8('0x42')?_0x1bc156:util[_0xb7f8('0x43')](_0xb7f8('0x44'),_0x146901);}else if(_0x50e55d[_0xb7f8('0x41')]===_0xb7f8('0x16')){logger['info'](_0xb7f8('0x45'),_0x146901,_0x50e55d['moduleCreate']);_0x1ee49a[_0xb7f8('0x46')]=_0x1bc156!==_0xb7f8('0x42')?_0x1bc156:util['format'](_0xb7f8('0x44'),_0x146901);_0x1ee49a[_0xb7f8('0x47')]=_0xb7f8('0x48');}else if(_0x50e55d[_0xb7f8('0x41')]===_0xb7f8('0x18')){logger[_0xb7f8('0x1f')](_0xb7f8('0x45'),_0x146901,_0x50e55d[_0xb7f8('0x41')]);_0x1ee49a['Name']=_0x1bc156!=='<unknown>'?_0x1bc156:util['format']('Caller\x20-\x20%s',_0x146901);}else{return null;}}return _0x8c9b67['sobject'](_[_0xb7f8('0x49')](_0x50e55d[_0xb7f8('0x41')]))[_0xb7f8('0x22')](_0x1ee49a)['then'](function(_0x52a01c){return BPromise[_0xb7f8('0x29')]({'id':_0x52a01c['id'],'endUserType':_0x50e55d['moduleCreate']});});}});}function getCustomFields(_0x15f78f,_0x22e4d4){var _0x2c349b={};if(_0x15f78f[_0xb7f8('0x27')]>0x0){_['forEach'](_0x15f78f,function(_0x2d0e47){if(_['includes']([_0xb7f8('0x4a'),_0xb7f8('0x4b')],_0x2d0e47[_0xb7f8('0x4c')])&&_0x2d0e47[_0xb7f8('0x4d')]){_0x2c349b[_0x2d0e47[_0xb7f8('0x4d')]]=_0x2d0e47[_0xb7f8('0x4e')][_0xb7f8('0x4f')]();}else if(_0x2d0e47[_0xb7f8('0x4c')]==='variable'&&_0x2d0e47[_0xb7f8('0x50')]&&_0x2d0e47['idField']){_0x22e4d4[_0x2d0e47[_0xb7f8('0x50')]]&&(_0x2c349b[_0x2d0e47[_0xb7f8('0x4d')]]=_0x22e4d4[_0x2d0e47[_0xb7f8('0x50')]][_0xb7f8('0x4f')]());}else if(_0x2d0e47[_0xb7f8('0x4c')]===_0xb7f8('0x51')&&_0x2d0e47[_0xb7f8('0x52')]&&_0x2d0e47[_0xb7f8('0x52')]['name']&&_0x2d0e47[_0xb7f8('0x4d')]){_0x22e4d4[_0x2d0e47[_0xb7f8('0x52')][_0xb7f8('0x53')][_0xb7f8('0x54')]()]&&(_0x2c349b[_0x2d0e47[_0xb7f8('0x4d')]]=_0x22e4d4[_0x2d0e47[_0xb7f8('0x52')][_0xb7f8('0x53')][_0xb7f8('0x54')]()]['toString']());}});}return _0x2c349b;}function getConnection(_0x3097ff){var _0xc7f078=_0x3097ff[_0xb7f8('0x55')][_0xb7f8('0x56')](_0x3097ff[_0xb7f8('0x57')]);var _0x5326c8=new jsforce['Connection']({'oauth2':{'loginUrl':_0x3097ff[_0xb7f8('0x58')]||_0xb7f8('0x59'),'clientId':_0x3097ff[_0xb7f8('0x5a')],'clientSecret':_0x3097ff[_0xb7f8('0x5b')]}});return _0x5326c8[_0xb7f8('0x5c')](_0x3097ff['username'],_0xc7f078)[_0xb7f8('0x2c')](function(){logger[_0xb7f8('0x1f')](_0xb7f8('0x5d'));return _0x5326c8;});}exports[_0xb7f8('0x5e')]=function(_0x194588,_0x24f082,_0x283715,_0xbb53ad,_0x92eac3,_0x32bfe6){var _0x214774,_0xe8c16f,_0x445141,_0x4f2c11;_0x32bfe6[_0xb7f8('0x5f')]=intUtil[_0xb7f8('0x60')](_0x32bfe6[_0xb7f8('0x5f')]);_0x32bfe6['remoteUri']=intUtil[_0xb7f8('0x60')](_0x32bfe6[_0xb7f8('0x58')]);if(_0x92eac3&&_0x92eac3[_0xb7f8('0x61')]){logger[_0xb7f8('0x1f')]('[QUEUE]','Recording\x20is\x20enabled!');_0x24f082[_0xb7f8('0x62')]=util[_0xb7f8('0x43')](_0xb7f8('0x63'),_0x32bfe6[_0xb7f8('0x5f')],_0x24f082[_0xb7f8('0x64')],md5(_0x24f082[_0xb7f8('0x64')]));}else{_0x24f082[_0xb7f8('0x62')]='';}return getConnection(_0x32bfe6)[_0xb7f8('0x2c')](function(_0x1b7e70){_0x4f2c11=_0x1b7e70;return getUser(_0x32bfe6,_0xbb53ad[_0xb7f8('0x65')],_0x4f2c11);})['then'](function(_0x41ed24){_0x214774=_0x41ed24;return getEndUser(_0x32bfe6,_0x283715,_0x24f082['calleridname'],_0x24f082[_0xb7f8('0x66')],_0x4f2c11);})[_0xb7f8('0x2c')](function(_0x5ab70d){_0xe8c16f=_0x5ab70d;return getTicket(_0x32bfe6,_0x214774,_0xe8c16f,_0x283715,_0x24f082,_0x283715['Fields'],_0x4f2c11,'queue');})[_0xb7f8('0x2c')](function(_0x17e5aa){_0x445141=_0x17e5aa;logger[_0xb7f8('0x1f')](_0xb7f8('0x67'),_0x445141['id']);logger['info'](_0xb7f8('0x68'),_0x445141['id'],_0xbb53ad[_0xb7f8('0x53')],_0x32bfe6[_0xb7f8('0x4c')]);switch(_0x32bfe6[_0xb7f8('0x4c')]){case _0xb7f8('0x69'):emit(util[_0xb7f8('0x43')]('user:%s',_0xbb53ad[_0xb7f8('0x53')]),_0xb7f8('0x6a'),{'recordId':_0x445141['id']});break;case'newTab':emit(util[_0xb7f8('0x43')]('user:%s',_0xbb53ad[_0xb7f8('0x53')]),_0xb7f8('0x6b'),{'uri':util[_0xb7f8('0x43')]('%s/%s/e',_0x4f2c11[_0xb7f8('0x6c')],_0x445141['id'])});break;default:logger[_0xb7f8('0x6d')](_0xb7f8('0x6e'));}})[_0xb7f8('0x6f')](function(_0x47f0c1){logger['error'](_0xb7f8('0x70'),_0x47f0c1);});};exports[_0xb7f8('0x71')]=function(_0x269283,_0x332063,_0x55e6d0,_0x51699e,_0x164941,_0x3f0d08,_0x403e42){var _0x1e3d23,_0x5eabf5,_0x18a2e0,_0x358a20;_0x3f0d08['serverUrl']=intUtil[_0xb7f8('0x60')](_0x3f0d08['serverUrl']);_0x3f0d08[_0xb7f8('0x58')]=intUtil[_0xb7f8('0x60')](_0x3f0d08['remoteUri']);if(_0x403e42&&_0x403e42[_0xb7f8('0x72')]&&_0x403e42[_0xb7f8('0x72')]!=='none'){logger['info'](_0xb7f8('0x73'),_0xb7f8('0x74'));_0x332063[_0xb7f8('0x62')]=util[_0xb7f8('0x43')](_0xb7f8('0x63'),_0x3f0d08[_0xb7f8('0x5f')],_0x332063[_0xb7f8('0x64')],md5(_0x332063[_0xb7f8('0x64')]));}return getConnection(_0x3f0d08)[_0xb7f8('0x2c')](function(_0x2068f2){_0x358a20=_0x2068f2;return getUser(_0x3f0d08,_0x51699e[_0xb7f8('0x65')],_0x358a20);})[_0xb7f8('0x2c')](function(_0x197098){_0x1e3d23=_0x197098;return getEndUser(_0x3f0d08,_0x55e6d0,_0x332063[_0xb7f8('0x75')],_0x332063['destcalleridnum'],_0x358a20);})[_0xb7f8('0x2c')](function(_0x4ae85f){_0x5eabf5=_0x4ae85f;return getTicket(_0x3f0d08,_0x1e3d23,_0x5eabf5,_0x55e6d0,_0x332063,_0x55e6d0[_0xb7f8('0x76')],_0x358a20,_0xb7f8('0x71'));})[_0xb7f8('0x2c')](function(_0x207e54){_0x18a2e0=_0x207e54;logger['info'](_0xb7f8('0x77'),_0x18a2e0['id']);logger[_0xb7f8('0x1f')](_0xb7f8('0x78'),_0x18a2e0['id'],_0x51699e[_0xb7f8('0x53')],_0x3f0d08[_0xb7f8('0x4c')]);switch(_0x3f0d08[_0xb7f8('0x4c')]){case'integrationTab':emit(util['format'](_0xb7f8('0x79'),_0x51699e[_0xb7f8('0x53')]),_0xb7f8('0x6a'),{'recordId':_0x18a2e0['id']});break;case _0xb7f8('0x7a'):emit(util[_0xb7f8('0x43')]('user:%s',_0x51699e[_0xb7f8('0x53')]),_0xb7f8('0x6b'),{'uri':util[_0xb7f8('0x43')](_0xb7f8('0x7b'),_0x358a20[_0xb7f8('0x6c')],_0x18a2e0['id'])});break;default:logger['error']('[OUTBOUND]',_0xb7f8('0x7c'));}})[_0xb7f8('0x6f')](function(_0x5c7db3){logger[_0xb7f8('0x6d')](_0xb7f8('0x73'),_0x5c7db3);});};exports['unmanaged']=function(_0x47fb58,_0x4bd0ef,_0x49a3bc,_0x2e4ab7,_0x13024e,_0x1d80a2){var _0x2c311b,_0x439256,_0x41859e,_0x41d913;_0x1d80a2['serverUrl']=intUtil['stripTrailingSlash'](_0x1d80a2[_0xb7f8('0x5f')]);_0x1d80a2['remoteUri']=intUtil[_0xb7f8('0x60')](_0x1d80a2[_0xb7f8('0x58')]);if(_0x13024e&&_0x13024e['monitor_format']){logger[_0xb7f8('0x1f')]('['+_0x4bd0ef['lastevent']['toUpperCase']()+']',_0xb7f8('0x74'));_0x4bd0ef[_0xb7f8('0x62')]=util[_0xb7f8('0x43')]('%s/api/voice/recordings/%s/downloads?type=uniqueid&token=%s',_0x1d80a2[_0xb7f8('0x5f')],_0x4bd0ef[_0xb7f8('0x64')],md5(_0x4bd0ef['uniqueid']));}else{_0x4bd0ef[_0xb7f8('0x62')]='';}return getConnection(_0x1d80a2)['then'](function(_0x28b523){_0x41d913=_0x28b523;if(!_[_0xb7f8('0x23')](_0x2e4ab7)){return getUser(_0x1d80a2,_0x2e4ab7[_0xb7f8('0x53')],_0x41d913);}else{return getUser(_0x1d80a2,null,_0x41d913);}})[_0xb7f8('0x2c')](function(_0x3932c7){_0x2c311b=_0x3932c7;return getEndUser(_0x1d80a2,_0x49a3bc,_0x4bd0ef[_0xb7f8('0x7d')],_0x4bd0ef['calleridnum'],_0x41d913);})[_0xb7f8('0x2c')](function(_0x2986bd){_0x439256=_0x2986bd;return getTicket(_0x1d80a2,_0x2c311b,_0x439256,_0x49a3bc,_0x4bd0ef,_0x49a3bc[_0xb7f8('0x76')],_0x41d913);})[_0xb7f8('0x2c')](function(_0x534ecd){_0x41859e=_0x534ecd;logger[_0xb7f8('0x1f')]('['+_0x4bd0ef[_0xb7f8('0x7e')][_0xb7f8('0x7f')]()+_0xb7f8('0x80'),_0x41859e['id']);logger['info']('['+_0x4bd0ef[_0xb7f8('0x7e')]['toUpperCase']()+_0xb7f8('0x81'),_0x1d80a2[_0xb7f8('0x4c')]);})[_0xb7f8('0x6f')](function(_0x2b1682){logger[_0xb7f8('0x6d')]('['+_0x4bd0ef[_0xb7f8('0x7e')][_0xb7f8('0x7f')]()+']',_0x2b1682);});};
\ No newline at end of file
+var _0xcbc7=['redis','defaults','socket.io-emitter','emit','getString','Subjects','Descriptions','Task','ActivityDate','IsReminderSet','IsRecurrence','endUserType','contact','lead','WhoId','account','WhatId','ticketType','Case','ContactId','AccountId','leadId','info','Association\x20between\x20Case\x20and\x20Lead\x20skipped','sobject','create','isNil','validateEmail','find','execute','Email','Agent\x20%s\x20found.','resolve','identity','then','user_id','display_name','Agent\x20%s\x20not\x20found.\x20Switch\x20to\x20the\x20admin\x20account.','Searching\x20enduser\x20with\x20phone\x20%s.\x20Serching\x20method\x20used\x20%s.','moduleSearch','contact_lead','cloneDeep','additionalSearchContact','merge','$or','Contact','length','additionalSearchLead','Lead','account_contact_lead','additionalSearchAccount','Account','first','Phone','attributes','toLowerCase','Enduser\x20(%s)\x20with\x20phone\x20%s\x20found','Enduser\x20with\x20phone\x20%s\x20not\x20found','moduleCreate','Enduser\x20with\x20phone\x20%s.\x20Creating\x20method\x20used\x20%s.','<unknown>','format','Caller\x20-\x20%s','LastName','No\x20Company','upperFirst','includes','string','type','idField','toString','variableName','customVariable','name','Variable','securityToken','remoteUri','https://login.salesforce.com','clientId','username','queue','serverUrl','stripTrailingSlash','monitor_format','[QUEUE]','Recording\x20is\x20enabled!','recordingURL','%s/api/voice/recordings/%s/downloads?type=uniqueid&token=%s','uniqueid','calleridname','calleridnum','[QUEUE]\x20Ticket\x20%s\x20created','[QUEUE]\x20Displaying\x20ticket\x20%s\x20to\x20agent\x20%s.\x20Integration\x20account\x20type\x20%s.','integrationTab','user:%s','trigger:salesforce:display','newTab','instanceUrl','error','[QUEUE]\x20Salesforce\x20account\x20type\x20not\x20recognized.','catch','recordingFormat','none','destcalleridnum','Fields','outbound','[OUTBOUND]\x20Ticket\x20%s\x20created.','[OUTBOUND]\x20Displaying\x20ticket\x20%s\x20to\x20agent\x20%s.\x20Integration\x20account\x20type\x20%s.','trigger:browser:url','[OUTBOUND]','Salesforce\x20account\x20type\x20not\x20recognized','unmanaged','lastevent','toUpperCase',']\x20Integration\x20account\x20type\x20%s.','lodash','request-promise','moment','bluebird','md5','jsforce','util','ioredis','../../../../config/environment','../../../../config/logger','salesforce'];(function(_0x2bfd4f,_0x1bbf2c){var _0x341849=function(_0x4c246e){while(--_0x4c246e){_0x2bfd4f['push'](_0x2bfd4f['shift']());}};_0x341849(++_0x1bbf2c);}(_0xcbc7,0xf1));var _0x7cbc=function(_0x293023,_0x4ac622){_0x293023=_0x293023-0x0;var _0x49751d=_0xcbc7[_0x293023];return _0x49751d;};'use strict';var _=require(_0x7cbc('0x0'));var rp=require(_0x7cbc('0x1'));var moment=require(_0x7cbc('0x2'));var BPromise=require(_0x7cbc('0x3'));var md5=require(_0x7cbc('0x4'));var jsforce=require(_0x7cbc('0x5'));var util=require(_0x7cbc('0x6'));var Redis=require(_0x7cbc('0x7'));var intUtil=require('./util');var config=require(_0x7cbc('0x8'));var logger=require(_0x7cbc('0x9'))(_0x7cbc('0xa'));config[_0x7cbc('0xb')]=_[_0x7cbc('0xc')](config[_0x7cbc('0xb')],{'host':'localhost','port':0x18eb});var io=require(_0x7cbc('0xd'))(new Redis(config[_0x7cbc('0xb')]));function emit(_0x410873,_0x55f27e,_0x262a26){io['to'](_0x410873)[_0x7cbc('0xe')](_0x55f27e,_0x262a26);}function getTicket(_0xbf7549,_0x1112d5,_0x3a0198,_0x436384,_0x216fb2,_0x10e541,_0x39ebdb,_0x122031){var _0x204fff=Object['assign']({},{'OwnerId':_0x1112d5['id'],'Subject':intUtil[_0x7cbc('0xf')](_0x436384[_0x7cbc('0x10')],_0x216fb2,'\x20'),'Description':intUtil['getString'](_0x436384[_0x7cbc('0x11')],_0x216fb2,'\x0a')},getCustomFields(_0x10e541,_0x216fb2));if(_0x3a0198){if(_0x436384['ticketType']===_0x7cbc('0x12')){_0x204fff[_0x7cbc('0x13')]=moment['utc']();_0x204fff[_0x7cbc('0x14')]=![];_0x204fff[_0x7cbc('0x15')]=![];if(_0x3a0198[_0x7cbc('0x16')]===_0x7cbc('0x17')||_0x3a0198['endUserType']===_0x7cbc('0x18')){_0x204fff[_0x7cbc('0x19')]=_0x3a0198['id'];}else if(_0x3a0198[_0x7cbc('0x16')]===_0x7cbc('0x1a')){_0x204fff[_0x7cbc('0x1b')]=_0x3a0198['id'];}}else if(_0x436384[_0x7cbc('0x1c')]===_0x7cbc('0x1d')){if(_0x3a0198[_0x7cbc('0x16')]==='contact'){_0x204fff[_0x7cbc('0x1e')]=_0x3a0198['id'];}else if(_0x3a0198[_0x7cbc('0x16')]===_0x7cbc('0x1a')){_0x204fff[_0x7cbc('0x1f')]=_0x3a0198['id'];}else if(_0x3a0198[_0x7cbc('0x16')]===_0x7cbc('0x18')&&_0x436384[_0x7cbc('0x20')]){_0x204fff[_0x436384[_0x7cbc('0x20')]]=_0x3a0198['id'];}else{logger[_0x7cbc('0x21')](_0x7cbc('0x22'));}}}return _0x39ebdb[_0x7cbc('0x23')](_0x436384[_0x7cbc('0x1c')])[_0x7cbc('0x24')](_0x204fff);}function getUser(_0x78f2f5,_0x53cf39,_0xb99859){if(!_[_0x7cbc('0x25')](_0x53cf39)&&intUtil[_0x7cbc('0x26')](_0x53cf39)){var _0x1e010f={'Email':_0x53cf39};var _0x122ce6={'Id':!![],'Username':!![],'Name':!![],'Email':!![]};return _0xb99859[_0x7cbc('0x23')]('User')[_0x7cbc('0x27')](_0x1e010f,_0x122ce6)[_0x7cbc('0x28')]()['then'](function(_0x50a85a){if(_0x50a85a['length']){var _0x4d2b98=_[_0x7cbc('0x27')](_0x50a85a,function(_0x57b467){return _0x57b467[_0x7cbc('0x29')]===_0x53cf39;});if(_0x4d2b98){logger[_0x7cbc('0x21')](_0x7cbc('0x2a'),_0x53cf39);return BPromise[_0x7cbc('0x2b')]({'id':_0x4d2b98['Id'],'name':_0x4d2b98['Name']});}}else{logger['info']('Agent\x20%s\x20not\x20found.\x20Switch\x20to\x20the\x20admin\x20account.',_0x53cf39);return _0xb99859[_0x7cbc('0x2c')]()[_0x7cbc('0x2d')](function(_0x320183){return BPromise[_0x7cbc('0x2b')]({'id':_0x320183[_0x7cbc('0x2e')],'name':_0x320183[_0x7cbc('0x2f')]});});}});}else{logger[_0x7cbc('0x21')](_0x7cbc('0x30'),_0x53cf39);return _0xb99859[_0x7cbc('0x2c')]()[_0x7cbc('0x2d')](function(_0x39e99d){return BPromise['resolve']({'id':_0x39e99d[_0x7cbc('0x2e')],'name':_0x39e99d[_0x7cbc('0x2f')]});});}}function getEndUser(_0x4c8230,_0x3c1653,_0x11b54c,_0x38b868,_0x386975){var _0x57dfb3={'$or':{'Phone':_0x38b868}};var _0x4a2ced={'Id':!![],'Name':!![],'Phone':!![]};return BPromise[_0x7cbc('0x2b')]()['then'](function(){logger['info'](_0x7cbc('0x31'),_0x38b868,_0x3c1653[_0x7cbc('0x32')]);switch(_0x3c1653[_0x7cbc('0x32')]){case _0x7cbc('0x33'):var _0x54febe=_[_0x7cbc('0x34')](_0x57dfb3);if(_0x3c1653['additionalSearchContact']){var _0x57f39e={};_0x57f39e[_0x3c1653[_0x7cbc('0x35')]]=_0x38b868;_[_0x7cbc('0x36')](_0x54febe[_0x7cbc('0x37')],_0x57f39e);}return _0x386975[_0x7cbc('0x23')](_0x7cbc('0x38'))['find'](_0x54febe,_0x4a2ced)[_0x7cbc('0x28')]()[_0x7cbc('0x2d')](function(_0x261208){if(_0x261208&&_0x261208[_0x7cbc('0x39')]){return _0x261208;}else{var _0x1c43cb=_[_0x7cbc('0x34')](_0x57dfb3);if(_0x3c1653[_0x7cbc('0x3a')]){var _0x5dbd7f={};_0x5dbd7f[_0x3c1653[_0x7cbc('0x3a')]]=_0x38b868;_[_0x7cbc('0x36')](_0x1c43cb[_0x7cbc('0x37')],_0x5dbd7f);}return _0x386975[_0x7cbc('0x23')](_0x7cbc('0x3b'))[_0x7cbc('0x27')](_0x1c43cb,_0x4a2ced);}});case _0x7cbc('0x3c'):var _0x31f9f4=_[_0x7cbc('0x34')](_0x57dfb3);if(_0x3c1653['additionalSearchAccount']){var _0x57f39e={};_0x57f39e[_0x3c1653[_0x7cbc('0x3d')]]=_0x38b868;_[_0x7cbc('0x36')](_0x31f9f4[_0x7cbc('0x37')],_0x57f39e);}return _0x386975[_0x7cbc('0x23')](_0x7cbc('0x3e'))['find'](_0x31f9f4,_0x4a2ced)[_0x7cbc('0x28')]()['then'](function(_0x35aa6b){if(_0x35aa6b&&_0x35aa6b['length']){return _0x35aa6b;}else{var _0x2d3d95=_['cloneDeep'](_0x57dfb3);if(_0x3c1653['additionalSearchContact']){var _0x27942f={};_0x27942f[_0x3c1653[_0x7cbc('0x35')]]=_0x38b868;_['merge'](_0x2d3d95[_0x7cbc('0x37')],_0x27942f);}return _0x386975[_0x7cbc('0x23')](_0x7cbc('0x38'))[_0x7cbc('0x27')](_0x2d3d95,_0x4a2ced)[_0x7cbc('0x2d')](function(_0x4f2cf0){if(_0x4f2cf0&&_0x4f2cf0[_0x7cbc('0x39')]){return _0x4f2cf0;}else{var _0x332dac=_[_0x7cbc('0x34')](_0x57dfb3);if(_0x3c1653[_0x7cbc('0x3a')]){var _0x940aa4={};_0x940aa4[_0x3c1653[_0x7cbc('0x3a')]]=_0x38b868;_[_0x7cbc('0x36')](_0x332dac[_0x7cbc('0x37')],_0x940aa4);}return _0x386975[_0x7cbc('0x23')]('Lead')[_0x7cbc('0x27')](_0x332dac,_0x4a2ced);}});}});case _0x7cbc('0x17'):var _0x54febe=_[_0x7cbc('0x34')](_0x57dfb3);if(_0x3c1653['additionalSearchContact']){var _0x57f39e={};_0x57f39e[_0x3c1653[_0x7cbc('0x35')]]=_0x38b868;_[_0x7cbc('0x36')](_0x54febe[_0x7cbc('0x37')],_0x57f39e);}return _0x386975[_0x7cbc('0x23')](_0x7cbc('0x38'))[_0x7cbc('0x27')](_0x54febe,_0x4a2ced)[_0x7cbc('0x28')]();case'lead':var _0x4d7a28=_[_0x7cbc('0x34')](_0x57dfb3);if(_0x3c1653[_0x7cbc('0x3a')]){var _0x57f39e={};_0x57f39e[_0x3c1653[_0x7cbc('0x3a')]]=_0x38b868;_[_0x7cbc('0x36')](_0x4d7a28[_0x7cbc('0x37')],_0x57f39e);}return _0x386975[_0x7cbc('0x23')](_0x7cbc('0x3b'))['find'](_0x4d7a28,_0x4a2ced);case _0x7cbc('0x1a'):var _0x31f9f4=_[_0x7cbc('0x34')](_0x57dfb3);if(_0x3c1653[_0x7cbc('0x3d')]){var _0x57f39e={};_0x57f39e[_0x3c1653[_0x7cbc('0x3d')]]=_0x38b868;_[_0x7cbc('0x36')](_0x31f9f4[_0x7cbc('0x37')],_0x57f39e);}return _0x386975[_0x7cbc('0x23')]('Account')[_0x7cbc('0x27')](_0x31f9f4,_0x4a2ced);default:return null;}})[_0x7cbc('0x2d')](function(_0x3ceda4){if(_0x3ceda4&&_0x3ceda4['length']){var _0x47f47e=_[_0x7cbc('0x3f')](_0x3ceda4);if(_0x47f47e){return BPromise[_0x7cbc('0x2b')]({'id':_0x47f47e['Id'],'name':_0x47f47e['Name'],'phone':_0x47f47e[_0x7cbc('0x40')],'endUserType':_0x47f47e[_0x7cbc('0x41')]['type'][_0x7cbc('0x42')]()});}}})['then'](function(_0x58dec5){if(_0x58dec5){logger[_0x7cbc('0x21')](_0x7cbc('0x43'),_0x58dec5[_0x7cbc('0x16')],_0x38b868);return BPromise[_0x7cbc('0x2b')](_0x58dec5);}else{logger['info'](_0x7cbc('0x44'),_0x38b868);var _0x1f154d={'Phone':_0x38b868};if(_0x3c1653[_0x7cbc('0x45')]){if(_0x3c1653['moduleCreate']===_0x7cbc('0x17')){logger[_0x7cbc('0x21')](_0x7cbc('0x46'),_0x38b868,_0x3c1653[_0x7cbc('0x45')]);_0x1f154d['LastName']=_0x11b54c!==_0x7cbc('0x47')?_0x11b54c:util[_0x7cbc('0x48')](_0x7cbc('0x49'),_0x38b868);}else if(_0x3c1653[_0x7cbc('0x45')]===_0x7cbc('0x18')){logger['info']('Enduser\x20with\x20phone\x20%s.\x20Creating\x20method\x20used\x20%s.',_0x38b868,_0x3c1653['moduleCreate']);_0x1f154d[_0x7cbc('0x4a')]=_0x11b54c!==_0x7cbc('0x47')?_0x11b54c:util[_0x7cbc('0x48')](_0x7cbc('0x49'),_0x38b868);_0x1f154d['Company']=_0x7cbc('0x4b');}else if(_0x3c1653[_0x7cbc('0x45')]===_0x7cbc('0x1a')){logger['info'](_0x7cbc('0x46'),_0x38b868,_0x3c1653[_0x7cbc('0x45')]);_0x1f154d['Name']=_0x11b54c!==_0x7cbc('0x47')?_0x11b54c:util[_0x7cbc('0x48')](_0x7cbc('0x49'),_0x38b868);}else{return null;}}return _0x386975[_0x7cbc('0x23')](_[_0x7cbc('0x4c')](_0x3c1653['moduleCreate']))[_0x7cbc('0x24')](_0x1f154d)[_0x7cbc('0x2d')](function(_0x3fa959){return BPromise[_0x7cbc('0x2b')]({'id':_0x3fa959['id'],'endUserType':_0x3c1653[_0x7cbc('0x45')]});});}});}function getCustomFields(_0x57ac12,_0x13efd4){var _0x331466={};if(_0x57ac12[_0x7cbc('0x39')]>0x0){_['forEach'](_0x57ac12,function(_0x409d50){if(_[_0x7cbc('0x4d')]([_0x7cbc('0x4e'),'picklist'],_0x409d50[_0x7cbc('0x4f')])&&_0x409d50[_0x7cbc('0x50')]){_0x331466[_0x409d50[_0x7cbc('0x50')]]=_0x409d50['content'][_0x7cbc('0x51')]();}else if(_0x409d50[_0x7cbc('0x4f')]==='variable'&&_0x409d50['variableName']&&_0x409d50['idField']){_0x13efd4[_0x409d50['variableName']]&&(_0x331466[_0x409d50[_0x7cbc('0x50')]]=_0x13efd4[_0x409d50[_0x7cbc('0x52')]]['toString']());}else if(_0x409d50['type']===_0x7cbc('0x53')&&_0x409d50['Variable']&&_0x409d50['Variable'][_0x7cbc('0x54')]&&_0x409d50[_0x7cbc('0x50')]){_0x13efd4[_0x409d50[_0x7cbc('0x55')][_0x7cbc('0x54')][_0x7cbc('0x42')]()]&&(_0x331466[_0x409d50[_0x7cbc('0x50')]]=_0x13efd4[_0x409d50[_0x7cbc('0x55')][_0x7cbc('0x54')][_0x7cbc('0x42')]()]['toString']());}});}return _0x331466;}function getConnection(_0x108077){var _0x11973a=_0x108077['password']['concat'](_0x108077[_0x7cbc('0x56')]);var _0x109bfb=new jsforce['Connection']({'oauth2':{'loginUrl':_0x108077[_0x7cbc('0x57')]||_0x7cbc('0x58'),'clientId':_0x108077[_0x7cbc('0x59')],'clientSecret':_0x108077['clientSecret']}});return _0x109bfb['login'](_0x108077[_0x7cbc('0x5a')],_0x11973a)[_0x7cbc('0x2d')](function(){logger['info']('Connection\x20established.');return _0x109bfb;});}exports[_0x7cbc('0x5b')]=function(_0x413769,_0x5712da,_0x5b6d7b,_0x3fbb21,_0x50e802,_0x304adc){var _0x11806d,_0x15b893,_0x485b1d,_0x5c6144;_0x304adc[_0x7cbc('0x5c')]=intUtil['stripTrailingSlash'](_0x304adc[_0x7cbc('0x5c')]);_0x304adc[_0x7cbc('0x57')]=intUtil[_0x7cbc('0x5d')](_0x304adc[_0x7cbc('0x57')]);if(_0x50e802&&_0x50e802[_0x7cbc('0x5e')]){logger[_0x7cbc('0x21')](_0x7cbc('0x5f'),_0x7cbc('0x60'));_0x5712da[_0x7cbc('0x61')]=util[_0x7cbc('0x48')](_0x7cbc('0x62'),_0x304adc[_0x7cbc('0x5c')],_0x5712da[_0x7cbc('0x63')],md5(_0x5712da['uniqueid']));}else{_0x5712da[_0x7cbc('0x61')]='';}return getConnection(_0x304adc)[_0x7cbc('0x2d')](function(_0x11cef1){_0x5c6144=_0x11cef1;return getUser(_0x304adc,_0x3fbb21['email'],_0x5c6144);})[_0x7cbc('0x2d')](function(_0x42d18f){_0x11806d=_0x42d18f;return getEndUser(_0x304adc,_0x5b6d7b,_0x5712da[_0x7cbc('0x64')],_0x5712da[_0x7cbc('0x65')],_0x5c6144);})[_0x7cbc('0x2d')](function(_0x1dc62f){_0x15b893=_0x1dc62f;return getTicket(_0x304adc,_0x11806d,_0x15b893,_0x5b6d7b,_0x5712da,_0x5b6d7b['Fields'],_0x5c6144,_0x7cbc('0x5b'));})[_0x7cbc('0x2d')](function(_0x500669){_0x485b1d=_0x500669;logger[_0x7cbc('0x21')](_0x7cbc('0x66'),_0x485b1d['id']);logger[_0x7cbc('0x21')](_0x7cbc('0x67'),_0x485b1d['id'],_0x3fbb21[_0x7cbc('0x54')],_0x304adc[_0x7cbc('0x4f')]);switch(_0x304adc[_0x7cbc('0x4f')]){case _0x7cbc('0x68'):emit(util[_0x7cbc('0x48')](_0x7cbc('0x69'),_0x3fbb21[_0x7cbc('0x54')]),_0x7cbc('0x6a'),{'recordId':_0x485b1d['id']});break;case _0x7cbc('0x6b'):emit(util[_0x7cbc('0x48')](_0x7cbc('0x69'),_0x3fbb21[_0x7cbc('0x54')]),'trigger:browser:url',{'uri':util[_0x7cbc('0x48')]('%s/%s/e',_0x5c6144[_0x7cbc('0x6c')],_0x485b1d['id'])});break;default:logger[_0x7cbc('0x6d')](_0x7cbc('0x6e'));}})[_0x7cbc('0x6f')](function(_0x3d2fce){logger[_0x7cbc('0x6d')](_0x7cbc('0x5f'),_0x3d2fce);});};exports['outbound']=function(_0x4da098,_0x541630,_0xecea25,_0x3ebec9,_0x3f9f14,_0x552b20,_0x1f6311){var _0x24d51b,_0xfb75de,_0x3cd2b7,_0x30d104;_0x552b20[_0x7cbc('0x5c')]=intUtil[_0x7cbc('0x5d')](_0x552b20[_0x7cbc('0x5c')]);_0x552b20[_0x7cbc('0x57')]=intUtil[_0x7cbc('0x5d')](_0x552b20[_0x7cbc('0x57')]);if(_0x1f6311&&_0x1f6311[_0x7cbc('0x70')]&&_0x1f6311[_0x7cbc('0x70')]!==_0x7cbc('0x71')){logger['info']('[OUTBOUND]',_0x7cbc('0x60'));_0x541630[_0x7cbc('0x61')]=util[_0x7cbc('0x48')](_0x7cbc('0x62'),_0x552b20['serverUrl'],_0x541630[_0x7cbc('0x63')],md5(_0x541630[_0x7cbc('0x63')]));}return getConnection(_0x552b20)[_0x7cbc('0x2d')](function(_0x21678f){_0x30d104=_0x21678f;return getUser(_0x552b20,_0x3ebec9['email'],_0x30d104);})[_0x7cbc('0x2d')](function(_0x68218c){_0x24d51b=_0x68218c;return getEndUser(_0x552b20,_0xecea25,_0x541630['destcalleridname'],_0x541630[_0x7cbc('0x72')],_0x30d104);})['then'](function(_0x349e82){_0xfb75de=_0x349e82;return getTicket(_0x552b20,_0x24d51b,_0xfb75de,_0xecea25,_0x541630,_0xecea25[_0x7cbc('0x73')],_0x30d104,_0x7cbc('0x74'));})[_0x7cbc('0x2d')](function(_0x5ebd97){_0x3cd2b7=_0x5ebd97;logger[_0x7cbc('0x21')](_0x7cbc('0x75'),_0x3cd2b7['id']);logger[_0x7cbc('0x21')](_0x7cbc('0x76'),_0x3cd2b7['id'],_0x3ebec9['name'],_0x552b20[_0x7cbc('0x4f')]);switch(_0x552b20[_0x7cbc('0x4f')]){case _0x7cbc('0x68'):emit(util[_0x7cbc('0x48')]('user:%s',_0x3ebec9[_0x7cbc('0x54')]),_0x7cbc('0x6a'),{'recordId':_0x3cd2b7['id']});break;case _0x7cbc('0x6b'):emit(util['format']('user:%s',_0x3ebec9[_0x7cbc('0x54')]),_0x7cbc('0x77'),{'uri':util[_0x7cbc('0x48')]('%s/%s/e',_0x30d104[_0x7cbc('0x6c')],_0x3cd2b7['id'])});break;default:logger[_0x7cbc('0x6d')](_0x7cbc('0x78'),_0x7cbc('0x79'));}})[_0x7cbc('0x6f')](function(_0x5e9ebb){logger[_0x7cbc('0x6d')](_0x7cbc('0x78'),_0x5e9ebb);});};exports[_0x7cbc('0x7a')]=function(_0x5cfe36,_0x4a8ec2,_0x57345f,_0x5c6dca,_0x2924b2,_0x485bcb){var _0xe518cd,_0x31558d,_0x46194f,_0x29ba35;_0x485bcb['serverUrl']=intUtil[_0x7cbc('0x5d')](_0x485bcb[_0x7cbc('0x5c')]);_0x485bcb['remoteUri']=intUtil[_0x7cbc('0x5d')](_0x485bcb[_0x7cbc('0x57')]);if(_0x2924b2&&_0x2924b2[_0x7cbc('0x5e')]){logger['info']('['+_0x4a8ec2[_0x7cbc('0x7b')][_0x7cbc('0x7c')]()+']',_0x7cbc('0x60'));_0x4a8ec2[_0x7cbc('0x61')]=util[_0x7cbc('0x48')](_0x7cbc('0x62'),_0x485bcb[_0x7cbc('0x5c')],_0x4a8ec2[_0x7cbc('0x63')],md5(_0x4a8ec2[_0x7cbc('0x63')]));}else{_0x4a8ec2[_0x7cbc('0x61')]='';}return getConnection(_0x485bcb)['then'](function(_0x253872){_0x29ba35=_0x253872;if(!_['isNil'](_0x5c6dca)){return getUser(_0x485bcb,_0x5c6dca[_0x7cbc('0x54')],_0x29ba35);}else{return getUser(_0x485bcb,null,_0x29ba35);}})[_0x7cbc('0x2d')](function(_0x4d402d){_0xe518cd=_0x4d402d;return getEndUser(_0x485bcb,_0x57345f,_0x4a8ec2[_0x7cbc('0x64')],_0x4a8ec2[_0x7cbc('0x65')],_0x29ba35);})[_0x7cbc('0x2d')](function(_0x2ba7e7){_0x31558d=_0x2ba7e7;return getTicket(_0x485bcb,_0xe518cd,_0x31558d,_0x57345f,_0x4a8ec2,_0x57345f[_0x7cbc('0x73')],_0x29ba35);})[_0x7cbc('0x2d')](function(_0x474431){_0x46194f=_0x474431;logger[_0x7cbc('0x21')]('['+_0x4a8ec2[_0x7cbc('0x7b')]['toUpperCase']()+']\x20Ticket\x20%s\x20created.',_0x46194f['id']);logger[_0x7cbc('0x21')]('['+_0x4a8ec2[_0x7cbc('0x7b')]['toUpperCase']()+_0x7cbc('0x7d'),_0x485bcb['type']);})[_0x7cbc('0x6f')](function(_0x518ad8){logger[_0x7cbc('0x6d')]('['+_0x4a8ec2['lastevent'][_0x7cbc('0x7c')]()+']',_0x518ad8);});};
\ No newline at end of file