Built motion from commit d5e4af8c.|2.6.23
[motion2.git] / server / services / ami / trigger / integration / freshsales.js
index 0d932fe..a2795da 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x02f4=['GET','/api/selector/owners','users','length','info','Admin\x20found:','adminId','Requested\x20Resource\x20not\x20Found','error','toUpperCase','message','headers','agentEmail','Getting\x20user\x20with\x20email','userEmail','userId','User\x20found:','adminEmail','catch','/api/contacts/filters','then','filters','forEach','name','Getting\x20contact\x20list','/api/contacts/view/','Searching\x20contact\x20with\x20phone','contactNumber','contacts','work_number','mobile_number','endUserId','Contact\x20found:','Contact\x20created:','POST','/api/contacts','format','Contact\x20not\x20found,\x20creating\x20a\x20new\x20contact','contact','Creating\x20new\x20task','/api/tasks','getString','Descriptions','YYYY-MM-DDTHH:mm:ss','ticketId','Task\x20created:','user:%s','emit','trigger:browser:url','Token\x20token=','apiKey','remoteUri','stripTrailingSlash','serverUrl','username','toLowerCase','destcalleridnum','callDirection','queue','abandoned','outbound','email','uniqueid','monitor_format','Recording\x20is\x20enabled!','recordingURL','recordingFormat','none','[OUTBOUND]','Displaying\x20task\x20in\x20a\x20new\x20tab...',']\x20Error\x20running\x20Freshsales\x20integration','inspect','lodash','md5','util','moment','./util','../../../../config/logger','freshsales','redis','defaults','localhost'];(function(_0x138f59,_0x1b53fb){var _0x3d114d=function(_0x1f9461){while(--_0x1f9461){_0x138f59['push'](_0x138f59['shift']());}};_0x3d114d(++_0x1b53fb);}(_0x02f4,0x13e));var _0x402f=function(_0x19950b,_0x53d0d7){_0x19950b=_0x19950b-0x0;var _0x3c6b41=_0x02f4[_0x19950b];return _0x3c6b41;};'use strict';var _=require(_0x402f('0x0'));var rp=require('request-promise');var md5=require(_0x402f('0x1'));var util=require(_0x402f('0x2'));var moment=require(_0x402f('0x3'));var Promise=require('bluebird');var Redis=require('ioredis');var intUtil=require(_0x402f('0x4'));var config=require('../../../../config/environment');var logger=require(_0x402f('0x5'))(_0x402f('0x6'));config[_0x402f('0x7')]=_[_0x402f('0x8')](config[_0x402f('0x7')],{'host':_0x402f('0x9'),'port':0x18eb});var io=require('socket.io-emitter')(new Redis(config[_0x402f('0x7')]));function getAdminId(_0x4e2002,_0x183603,_0xbb195b,_0xf0b337){return new Promise(function(_0x5e0dde,_0x287141){var _0x258718=![];var _0x4b21c3={'method':_0x402f('0xa'),'uri':_0xf0b337+_0x402f('0xb'),'json':!![]};_0x4b21c3['headers']=_0xbb195b;logger['info']('Getting\x20admin\x20information');return rp(_0x4b21c3)['then'](function(_0x5cb2e0){if(_0x5cb2e0){var _0x2e5cb9=_0x5cb2e0[_0x402f('0xc')];var _0x566bf8=null;for(_0x566bf8=0x0;_0x566bf8<_0x2e5cb9[_0x402f('0xd')];_0x566bf8++){if(_0x2e5cb9[_0x566bf8]['email']===_0x4e2002['adminEmail']){_0x4e2002['adminId']=_0x2e5cb9[_0x566bf8]['id'];_0x258718=!![];}}if(_0x258718){logger[_0x402f('0xe')](_0x402f('0xf'),_0x4e2002[_0x402f('0x10')]);_0x5e0dde(_0x4e2002);}else{_0x287141({'statusCode':0x194,'message':_0x402f('0x11')});}}else{_0x287141({'statusCode':0x194,'message':_0x402f('0x11')});}})['catch'](function(_0x50f992){logger[_0x402f('0x12')]('['+[_0x183603[_0x402f('0x13')]()]+']',_0x50f992[_0x402f('0x14')]);_0x287141(_0x50f992);});});}function getUser(_0x3545a3,_0x47bdbb,_0x4d75c7){return function(_0x1cbc78){return new Promise(function(_0x3120fc,_0x41e3a9){var _0x162a1d={'method':_0x402f('0xa'),'uri':_0x4d75c7+_0x402f('0xb'),'json':!![]};_0x162a1d[_0x402f('0x15')]=_0x47bdbb;logger[_0x402f('0xe')]('Getting\x20user\x20list');return rp(_0x162a1d)['then'](function(_0x21afa0){if(_0x21afa0){var _0x51e312=_0x21afa0[_0x402f('0xc')];var _0x24d2e9=![];var _0x79de37=null;if(_0x1cbc78[_0x402f('0x16')]!==null){logger[_0x402f('0xe')](_0x402f('0x17'),_0x1cbc78[_0x402f('0x16')]);_0x1cbc78[_0x402f('0x18')]=_0x1cbc78[_0x402f('0x16')];for(_0x79de37=0x0;_0x79de37<_0x51e312[_0x402f('0xd')];_0x79de37++){if(_0x51e312[_0x79de37]['email']===_0x1cbc78[_0x402f('0x16')]){_0x24d2e9=!![];_0x1cbc78[_0x402f('0x19')]=_0x51e312[_0x79de37]['id'];logger[_0x402f('0xe')](_0x402f('0x1a'),_0x1cbc78['userId']);}}}if(!_0x24d2e9){logger[_0x402f('0xe')]('Admin\x20selected');_0x1cbc78['userEmail']=_0x1cbc78[_0x402f('0x1b')];_0x1cbc78[_0x402f('0x19')]=_0x1cbc78[_0x402f('0x10')];_0x24d2e9=!![];}if(_0x24d2e9){_0x3120fc(_0x1cbc78);}else{_0x41e3a9({'statusCode':0x194,'message':_0x402f('0x11')});}}else{_0x41e3a9({'statusCode':0x194,'message':_0x402f('0x11')});}})[_0x402f('0x1c')](function(_0x427fd2){logger[_0x402f('0x12')]('['+[_0x3545a3[_0x402f('0x13')]()]+']',_0x427fd2[_0x402f('0x14')]);_0x41e3a9(_0x427fd2);});});};}function getEndUser(_0x372340,_0x4fef19,_0x5cec14){return function(_0x1fe122){return new Promise(function(_0x1a1112,_0x551fbb){var _0x3e2f7c=0x0;var _0x29df2a={'method':_0x402f('0xa'),'uri':_0x5cec14+_0x402f('0x1d'),'json':!![]};_0x29df2a['headers']=_0x4fef19;logger[_0x402f('0xe')]('Getting\x20contacts\x20filter');return rp(_0x29df2a)[_0x402f('0x1e')](function(_0x2fa1c0){_0x2fa1c0[_0x402f('0x1f')][_0x402f('0x20')](function(_0x354f8f){if(_0x354f8f[_0x402f('0x21')]==='All\x20Contacts'){_0x3e2f7c=_0x354f8f['id'];}});})['then'](function(){logger[_0x402f('0xe')](_0x402f('0x22'));var _0x119a2e={'method':_0x402f('0xa'),'uri':_0x5cec14+_0x402f('0x23')+_0x3e2f7c,'json':!![]};_0x119a2e[_0x402f('0x15')]=_0x4fef19;return rp(_0x119a2e);})[_0x402f('0x1e')](function(_0x3f367b){logger[_0x402f('0xe')](_0x402f('0x24'),_0x1fe122[_0x402f('0x25')]);if(_0x3f367b['contacts'][_0x402f('0xd')]>0x0){var _0x506ff5=_['find'](_0x3f367b[_0x402f('0x26')],function(_0x364439){if(_0x364439[_0x402f('0x27')]===_0x1fe122['contactNumber']||_0x364439[_0x402f('0x28')]===_0x1fe122[_0x402f('0x25')]){return _0x364439;}});if(_0x506ff5){_0x1fe122[_0x402f('0x29')]=_0x506ff5['id'];logger[_0x402f('0xe')](_0x402f('0x2a'),_0x1fe122[_0x402f('0x29')]);_0x1a1112(_0x1fe122);}else{return createEndUser(_0x1fe122,_0x372340,_0x4fef19,_0x5cec14)[_0x402f('0x1e')](function(_0x20189f){logger['info'](_0x402f('0x2b'),_0x1fe122[_0x402f('0x29')]);_0x1a1112(_0x20189f);});}}else{return createEndUser(_0x1fe122,_0x372340,_0x4fef19,_0x5cec14)[_0x402f('0x1e')](function(_0x24620d){logger[_0x402f('0xe')]('Contact\x20created:',_0x1fe122[_0x402f('0x29')]);_0x1a1112(_0x24620d);});}})[_0x402f('0x1c')](function(_0x2ccada){throw new Error(_0x2ccada[_0x402f('0x14')]);});});};}function createEndUser(_0x279c31,_0x2b36e4,_0x522cb7,_0x2768b6){return new Promise(function(_0x2aedf0,_0x17fc0a){var _0x16a5fc=moment();var _0x59c03a={'method':_0x402f('0x2c'),'uri':_0x2768b6+_0x402f('0x2d'),'body':{'contact':{'last_name':_0x279c31['contactNumber'],'work_number':_0x279c31['contactNumber'],'mobile_number':_0x279c31[_0x402f('0x25')],'owner_id':_0x279c31[_0x402f('0x19')],'created_at':_0x16a5fc[_0x402f('0x2e')]('YYYY-MM-DDTHH:mm:ss')}},'json':!![]};_0x59c03a[_0x402f('0x15')]=_0x522cb7;logger[_0x402f('0xe')](_0x402f('0x2f'));return rp(_0x59c03a)[_0x402f('0x1e')](function(_0xb76368){_0x279c31['endUserId']=_0xb76368[_0x402f('0x30')]['id'];_0x2aedf0(_0x279c31);})[_0x402f('0x1c')](function(_0x13a6cb){logger[_0x402f('0x12')]('['+[_0x2b36e4[_0x402f('0x13')]()]+']',_0x13a6cb['message']);_0x17fc0a(_0x13a6cb[_0x402f('0x14')]);});});}function getTicket(_0x89f666,_0x3b139f,_0x234330,_0x153455,_0x234ec9){return function(_0x18b3c7){logger['info'](_0x402f('0x31'));return new Promise(function(_0x2230b9,_0x1e0fa2){var _0x12c100=moment();var _0x1ae323={'method':_0x402f('0x2c'),'uri':_0x234330+_0x402f('0x32'),'body':{'title':intUtil[_0x402f('0x33')](_0x153455['Subjects'],_0x234ec9,'\x20'),'description':intUtil['getString'](_0x153455[_0x402f('0x34')],_0x234ec9,'\x0a'),'owner_id':_0x18b3c7['userId'],'creater_id':_0x18b3c7[_0x402f('0x10')],'targetable_id':_0x18b3c7['endUserId'],'targetable_type':'Contact','created_at':_0x12c100['format'](_0x402f('0x35')),'due_date':_0x12c100['add'](0x1e,'m')[_0x402f('0x2e')]('YYYY-MM-DDTHH:mm:ss')},'json':!![]};_0x1ae323['headers']=_0x3b139f;return rp(_0x1ae323)[_0x402f('0x1e')](function(_0x427d2c){_0x18b3c7[_0x402f('0x36')]=_0x427d2c['task']['id'];logger['info'](_0x402f('0x37'),_0x18b3c7[_0x402f('0x36')]);_0x2230b9(_0x18b3c7);})[_0x402f('0x1c')](function(_0x4beb37){logger['error']('['+[_0x89f666[_0x402f('0x13')]()]+']',_0x4beb37[_0x402f('0x14')]);_0x1e0fa2(_0x4beb37['message']);});});};}function emit(_0x94ce79,_0x59564f,_0x2d88f6){var _0x3fb213={'uri':_0x94ce79+'/contacts/'+_0x2d88f6};io['to'](util[_0x402f('0x2e')](_0x402f('0x38'),_0x59564f))[_0x402f('0x39')](_0x402f('0x3a'),_0x3fb213);}exports['cs']=function(_0x4f25f6,_0x19179d,_0x47defa,_0x5a3670,_0x6948f9,_0x416465,_0x34cbee,_0x1ff147){var _0x44628d={};var _0x11242a={'Authorization':_0x402f('0x3b')+_0x416465[_0x402f('0x3c')]};_0x416465[_0x402f('0x3d')]=intUtil[_0x402f('0x3e')](_0x416465['remoteUri']);_0x416465[_0x402f('0x3f')]=intUtil['stripTrailingSlash'](_0x416465[_0x402f('0x3f')]);var _0x3271cb=_0x416465['remoteUri'];_0x44628d[_0x402f('0x1b')]=_0x416465[_0x402f('0x40')];_0x44628d[_0x402f('0x25')]=_0x1ff147[_0x402f('0x41')]()==='outbound'?_0x19179d[_0x402f('0x42')]:_0x19179d['calleridnum'];_0x44628d[_0x402f('0x43')]=_0x1ff147===_0x402f('0x44')||_0x1ff147===_0x402f('0x45')?_0x402f('0x44'):_0x402f('0x46');if(_0x5a3670){_0x44628d[_0x402f('0x16')]=_0x5a3670[_0x402f('0x47')];}var _0x486622=util['format']('%s/api/voice/recordings/%s/downloads?type=uniqueid&token=%s',_0x416465['serverUrl'],_0x19179d[_0x402f('0x48')],md5(_0x19179d[_0x402f('0x48')]));if(_0x6948f9&&_0x6948f9[_0x402f('0x49')]){logger[_0x402f('0xe')]('[QUEUE]',_0x402f('0x4a'));_0x19179d[_0x402f('0x4b')]=_0x486622;}else if(_0x34cbee&&_0x34cbee[_0x402f('0x4c')]&&_0x34cbee[_0x402f('0x4c')]!==_0x402f('0x4d')){logger[_0x402f('0xe')](_0x402f('0x4e'),'Recording\x20is\x20enabled!');_0x19179d[_0x402f('0x4b')]=_0x486622;}else{_0x19179d[_0x402f('0x4b')]='';}return getAdminId(_0x44628d,_0x1ff147,_0x11242a,_0x3271cb)[_0x402f('0x1e')](getUser(_0x1ff147,_0x11242a,_0x3271cb))[_0x402f('0x1e')](getEndUser(_0x1ff147,_0x11242a,_0x3271cb))[_0x402f('0x1e')](getTicket(_0x1ff147,_0x11242a,_0x3271cb,_0x47defa,_0x19179d))['then'](function(_0x390c14){logger[_0x402f('0xe')](util['format']('The\x20ticket\x20ID\x20is:\x20%s',_0x390c14['ticketId']));if(_0x1ff147!=='abandoned'){logger[_0x402f('0xe')]('['+[_0x1ff147[_0x402f('0x13')]()]+']',_0x402f('0x4f'));emit(_0x3271cb,_0x5a3670[_0x402f('0x21')],_0x390c14['endUserId']);}})[_0x402f('0x1c')](function(_0x12dcc7){logger[_0x402f('0x12')]('['+[_0x1ff147['toUpperCase']()]+_0x402f('0x50'),util[_0x402f('0x51')](_0x12dcc7,{'showHidden':!![],'depth':null}));});};
\ No newline at end of file
+var _0x01a5=['moment','bluebird','ioredis','./util','../../../../config/environment','freshsales','redis','defaults','localhost','/api/selector/owners','headers','info','Getting\x20admin\x20information','then','users','length','email','adminEmail','adminId','Admin\x20found:','Requested\x20Resource\x20not\x20Found','catch','error','toUpperCase','GET','Getting\x20user\x20list','agentEmail','userEmail','userId','User\x20found:','message','/api/lookup?q=','&f=','&entities=contact','find','contacts','contactNumber','mobile_number','endUserId','work_number','Contact\x20found\x20work_number:','Contact\x20created:','POST','/api/contacts','format','YYYY-MM-DDTHH:mm:ss','Contact\x20not\x20found,\x20creating\x20a\x20new\x20contact','Creating\x20new\x20task','getString','Subjects','Contact','add','ticketId','Task\x20created:','/contacts/','user:%s','trigger:browser:url','Token\x20token=','remoteUri','stripTrailingSlash','serverUrl','username','outbound','destcalleridnum','calleridnum','queue','%s/api/voice/recordings/%s/downloads?type=uniqueid&token=%s','uniqueid','monitor_format','[QUEUE]','Recording\x20is\x20enabled!','recordingFormat','none','[OUTBOUND]','recordingURL','The\x20ticket\x20ID\x20is:\x20%s','unmanaged',']\x20Error\x20running\x20Freshsales\x20integration','inspect','lodash','request-promise','md5','util'];(function(_0x5a54a9,_0x4f08b4){var _0x3c7f83=function(_0x2c312d){while(--_0x2c312d){_0x5a54a9['push'](_0x5a54a9['shift']());}};_0x3c7f83(++_0x4f08b4);}(_0x01a5,0x148));var _0x501a=function(_0x210661,_0x2f2a83){_0x210661=_0x210661-0x0;var _0x23ece6=_0x01a5[_0x210661];return _0x23ece6;};'use strict';var _=require(_0x501a('0x0'));var rp=require(_0x501a('0x1'));var md5=require(_0x501a('0x2'));var util=require(_0x501a('0x3'));var moment=require(_0x501a('0x4'));var Promise=require(_0x501a('0x5'));var Redis=require(_0x501a('0x6'));var intUtil=require(_0x501a('0x7'));var config=require(_0x501a('0x8'));var logger=require('../../../../config/logger')(_0x501a('0x9'));config[_0x501a('0xa')]=_[_0x501a('0xb')](config[_0x501a('0xa')],{'host':_0x501a('0xc'),'port':0x18eb});var io=require('socket.io-emitter')(new Redis(config[_0x501a('0xa')]));function getAdminId(_0x5d8308,_0x17c090,_0x37bf43,_0x20c7ee){return new Promise(function(_0x25d7e2,_0x44054e){var _0x2cd6f5=![];var _0x30940e={'method':'GET','uri':_0x20c7ee+_0x501a('0xd'),'json':!![]};_0x30940e[_0x501a('0xe')]=_0x37bf43;logger[_0x501a('0xf')](_0x501a('0x10'));return rp(_0x30940e)[_0x501a('0x11')](function(_0x192001){if(_0x192001){var _0x35ad09=_0x192001[_0x501a('0x12')];var _0x8f63f4=null;for(_0x8f63f4=0x0;_0x8f63f4<_0x35ad09[_0x501a('0x13')];_0x8f63f4++){if(_0x35ad09[_0x8f63f4][_0x501a('0x14')]===_0x5d8308[_0x501a('0x15')]){_0x5d8308[_0x501a('0x16')]=_0x35ad09[_0x8f63f4]['id'];_0x2cd6f5=!![];}}if(_0x2cd6f5){logger[_0x501a('0xf')](_0x501a('0x17'),_0x5d8308['adminId']);_0x25d7e2(_0x5d8308);}else{_0x44054e({'statusCode':0x194,'message':_0x501a('0x18')});}}else{_0x44054e({'statusCode':0x194,'message':_0x501a('0x18')});}})[_0x501a('0x19')](function(_0x167aa4){logger[_0x501a('0x1a')]('['+[_0x17c090[_0x501a('0x1b')]()]+']',_0x167aa4['message']);_0x44054e(_0x167aa4);});});}function getUser(_0x5c82ba,_0x21accf,_0x31d8f2){return function(_0x300315){return new Promise(function(_0x5d3799,_0x1567df){var _0x8ac009={'method':_0x501a('0x1c'),'uri':_0x31d8f2+_0x501a('0xd'),'json':!![]};_0x8ac009[_0x501a('0xe')]=_0x21accf;logger[_0x501a('0xf')](_0x501a('0x1d'));return rp(_0x8ac009)[_0x501a('0x11')](function(_0x1b3688){if(_0x1b3688){var _0x50416e=_0x1b3688[_0x501a('0x12')];var _0x32bde2=![];var _0x163d67=null;if(_0x300315[_0x501a('0x1e')]!==null){logger['info']('Getting\x20user\x20with\x20email',_0x300315[_0x501a('0x1e')]);_0x300315[_0x501a('0x1f')]=_0x300315[_0x501a('0x1e')];for(_0x163d67=0x0;_0x163d67<_0x50416e['length'];_0x163d67++){if(_0x50416e[_0x163d67]['email']===_0x300315[_0x501a('0x1e')]){_0x32bde2=!![];_0x300315[_0x501a('0x20')]=_0x50416e[_0x163d67]['id'];logger['info'](_0x501a('0x21'),_0x300315[_0x501a('0x20')]);}}}if(!_0x32bde2){logger[_0x501a('0xf')]('Admin\x20selected');_0x300315['userEmail']=_0x300315[_0x501a('0x15')];_0x300315[_0x501a('0x20')]=_0x300315[_0x501a('0x16')];_0x32bde2=!![];}if(_0x32bde2){_0x5d3799(_0x300315);}else{_0x1567df({'statusCode':0x194,'message':'Requested\x20Resource\x20not\x20Found'});}}else{_0x1567df({'statusCode':0x194,'message':_0x501a('0x18')});}})[_0x501a('0x19')](function(_0x892dfa){logger['error']('['+[_0x5c82ba[_0x501a('0x1b')]()]+']',_0x892dfa[_0x501a('0x22')]);_0x1567df(_0x892dfa);});});};}function searchContact(_0x783556,_0x802dd0,_0x16b3a8,_0x32e864){return new Promise(function(_0x2c3a81,_0x812db){var _0x36ebaf={'method':'GET','headers':_0x802dd0,'uri':_0x783556+_0x501a('0x23')+_0x32e864+_0x501a('0x24')+_0x16b3a8+_0x501a('0x25'),'json':!![]};rp(_0x36ebaf)[_0x501a('0x11')](function(_0x233387){var _0x49c2b7=_[_0x501a('0x26')](_0x233387[_0x501a('0x27')][_0x501a('0x27')],[_0x16b3a8,_0x32e864]);_0x2c3a81(_0x49c2b7);})[_0x501a('0x19')](function(_0x366c2f){_0x812db(_0x366c2f);});});}function getEndUser(_0x54d698,_0x45b410,_0x19dff6){return function(_0x1cc16e){return new Promise(function(_0x5de7a5,_0x2ae229){logger['info'](util['format']('Searching\x20contact\x20with\x20phone\x20%s',_0x1cc16e[_0x501a('0x28')]));searchContact(_0x19dff6,_0x45b410,_0x501a('0x29'),_0x1cc16e[_0x501a('0x28')])[_0x501a('0x11')](function(_0x2fb3d8){if(_0x2fb3d8){_0x1cc16e[_0x501a('0x2a')]=_0x2fb3d8['id'];logger['info']('Contact\x20found\x20mobile_number:',_0x1cc16e['endUserId']);return _0x5de7a5(_0x1cc16e);}searchContact(_0x19dff6,_0x45b410,_0x501a('0x2b'),_0x1cc16e[_0x501a('0x28')])[_0x501a('0x11')](function(_0x12a8d4){if(_0x12a8d4){_0x1cc16e[_0x501a('0x2a')]=_0x12a8d4['id'];logger['info'](_0x501a('0x2c'),_0x1cc16e['endUserId']);return _0x5de7a5(_0x1cc16e);}createEndUser(_0x1cc16e,_0x54d698,_0x45b410,_0x19dff6)[_0x501a('0x11')](function(_0x4e39b4){logger[_0x501a('0xf')](_0x501a('0x2d'),_0x4e39b4[_0x501a('0x2a')]);return _0x5de7a5(_0x4e39b4);});});})[_0x501a('0x19')](function(_0x28f6c0){_0x2ae229(_0x28f6c0);});});};}function createEndUser(_0x38850b,_0x486904,_0x45ad4c,_0x7a8287){return new Promise(function(_0x11c192,_0x28972e){var _0x299dea=moment();var _0x585f22={'method':_0x501a('0x2e'),'uri':_0x7a8287+_0x501a('0x2f'),'body':{'contact':{'last_name':_0x38850b['contactNumber'],'work_number':_0x38850b[_0x501a('0x28')],'mobile_number':_0x38850b[_0x501a('0x28')],'owner_id':_0x38850b['userId'],'created_at':_0x299dea[_0x501a('0x30')](_0x501a('0x31'))}},'json':!![]};_0x585f22['headers']=_0x45ad4c;logger[_0x501a('0xf')](_0x501a('0x32'));return rp(_0x585f22)[_0x501a('0x11')](function(_0x3a2c79){_0x38850b['endUserId']=_0x3a2c79['contact']['id'];_0x11c192(_0x38850b);})['catch'](function(_0x2c74b9){logger[_0x501a('0x1a')]('['+[_0x486904[_0x501a('0x1b')]()]+']',_0x2c74b9[_0x501a('0x22')]);_0x28972e(_0x2c74b9[_0x501a('0x22')]);});});}function getTicket(_0x530b4c,_0x5868c9,_0x251949,_0x23ad88,_0x43c4c5){return function(_0x2429ff){logger[_0x501a('0xf')](_0x501a('0x33'));return new Promise(function(_0x545445,_0x339566){var _0x2af5ed=moment();var _0x41fa12={'method':_0x501a('0x2e'),'uri':_0x251949+'/api/tasks','body':{'title':intUtil[_0x501a('0x34')](_0x23ad88[_0x501a('0x35')],_0x43c4c5,'\x20'),'description':intUtil[_0x501a('0x34')](_0x23ad88['Descriptions'],_0x43c4c5,'\x0a'),'owner_id':_0x2429ff[_0x501a('0x20')],'creater_id':_0x2429ff[_0x501a('0x16')],'targetable_id':_0x2429ff[_0x501a('0x2a')],'targetable_type':_0x501a('0x36'),'created_at':_0x2af5ed['format']('YYYY-MM-DDTHH:mm:ss'),'due_date':_0x2af5ed[_0x501a('0x37')](0x1e,'m')[_0x501a('0x30')](_0x501a('0x31'))},'json':!![]};_0x41fa12[_0x501a('0xe')]=_0x5868c9;return rp(_0x41fa12)[_0x501a('0x11')](function(_0x49f675){_0x2429ff[_0x501a('0x38')]=_0x49f675['task']['id'];logger[_0x501a('0xf')](_0x501a('0x39'),_0x2429ff[_0x501a('0x38')]);_0x545445(_0x2429ff);})['catch'](function(_0x2f9621){logger[_0x501a('0x1a')]('['+[_0x530b4c['toUpperCase']()]+']',_0x2f9621['message']);_0x339566(_0x2f9621[_0x501a('0x22')]);});});};}function emit(_0x3c3d7e,_0x31778f,_0x27a28b){var _0x22c031={'uri':_0x3c3d7e+_0x501a('0x3a')+_0x27a28b};io['to'](util[_0x501a('0x30')](_0x501a('0x3b'),_0x31778f))['emit'](_0x501a('0x3c'),_0x22c031);}exports['cs']=function(_0x472600,_0x232539,_0x56a881,_0x567661,_0x5d09f9,_0x4a07db,_0x2ac45f,_0x204ce1){var _0x32de6c={};var _0x32404d={'Authorization':_0x501a('0x3d')+_0x4a07db['apiKey']};_0x4a07db[_0x501a('0x3e')]=intUtil[_0x501a('0x3f')](_0x4a07db[_0x501a('0x3e')]);_0x4a07db[_0x501a('0x40')]=intUtil[_0x501a('0x3f')](_0x4a07db[_0x501a('0x40')]);var _0x114df5=_0x4a07db['remoteUri'];_0x32de6c[_0x501a('0x15')]=_0x4a07db[_0x501a('0x41')];_0x32de6c['contactNumber']=_0x204ce1['toLowerCase']()===_0x501a('0x42')?_0x232539[_0x501a('0x43')]:_0x232539[_0x501a('0x44')];_0x32de6c['callDirection']=_0x204ce1===_0x501a('0x45')||_0x204ce1==='unmanaged'?_0x501a('0x45'):_0x501a('0x42');if(_0x567661){_0x32de6c[_0x501a('0x1e')]=_0x567661['email'];}var _0x43fc74=util[_0x501a('0x30')](_0x501a('0x46'),_0x4a07db['serverUrl'],_0x232539[_0x501a('0x47')],md5(_0x232539['uniqueid']));if(_0x5d09f9&&_0x5d09f9[_0x501a('0x48')]){logger[_0x501a('0xf')](_0x501a('0x49'),_0x501a('0x4a'));_0x232539['recordingURL']=_0x43fc74;}else if(_0x2ac45f&&_0x2ac45f[_0x501a('0x4b')]&&_0x2ac45f[_0x501a('0x4b')]!==_0x501a('0x4c')){logger[_0x501a('0xf')](_0x501a('0x4d'),_0x501a('0x4a'));_0x232539['recordingURL']=_0x43fc74;}else{_0x232539[_0x501a('0x4e')]='';}return getAdminId(_0x32de6c,_0x204ce1,_0x32404d,_0x114df5)[_0x501a('0x11')](getUser(_0x204ce1,_0x32404d,_0x114df5))[_0x501a('0x11')](getEndUser(_0x204ce1,_0x32404d,_0x114df5))[_0x501a('0x11')](getTicket(_0x204ce1,_0x32404d,_0x114df5,_0x56a881,_0x232539))['then'](function(_0x3287d1){logger[_0x501a('0xf')](util[_0x501a('0x30')](_0x501a('0x4f'),_0x3287d1[_0x501a('0x38')]));if(_0x204ce1!==_0x501a('0x50')){logger['info']('['+[_0x204ce1[_0x501a('0x1b')]()]+']','Displaying\x20task\x20in\x20a\x20new\x20tab...');emit(_0x114df5,_0x567661['name'],_0x3287d1['endUserId']);}})[_0x501a('0x19')](function(_0x1e9e36){logger[_0x501a('0x1a')]('['+[_0x204ce1[_0x501a('0x1b')]()]+_0x501a('0x51'),util[_0x501a('0x52')](_0x1e9e36,{'showHidden':!![],'depth':null}));});};
\ No newline at end of file