Built motion from commit 19a84241.|2.5.34
[motion2.git] / server / services / ami / trigger / cmContact / index.js
index b0be839..efe580d 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x32f4=['lodash','ioredis','../../../../config/logger','trigger','redis','defaults','localhost','socket.io-emitter','stringify','exec','autoCreate','data2','data1','isNil','routeId','calleridname','calleridnum','destcalleridname','<unknown>','destcalleridnum','phone','uniqueid','resolve','then','showContact','omit','xmd-contactid2','format','user:%s','name','trigger:%s','action','toLowerCase','merge','catch','Error\x20creating\x20contact','bluebird','util'];(function(_0x148574,_0x590777){var _0x549913=function(_0x53c7c6){while(--_0x53c7c6){_0x148574['push'](_0x148574['shift']());}};_0x549913(++_0x590777);}(_0x32f4,0x154));var _0x432f=function(_0x146a58,_0x151d13){_0x146a58=_0x146a58-0x0;var _0x365f0b=_0x32f4[_0x146a58];return _0x365f0b;};'use strict';var BPromise=require(_0x432f('0x0'));var util=require(_0x432f('0x1'));var _=require(_0x432f('0x2'));var Redis=require(_0x432f('0x3'));var config=require('../../../../config/environment');var logger=require(_0x432f('0x4'))(_0x432f('0x5'));var cmContactRpc=require('../../rpc/cmContact');config[_0x432f('0x6')]=_[_0x432f('0x7')](config[_0x432f('0x6')],{'host':_0x432f('0x8'),'port':0x18eb});var io=require(_0x432f('0x9'))(new Redis(config['redis']));function emit(_0x5b5f08,_0x2f66fd,_0x32b062){logger['info'](_0x5b5f08,_0x2f66fd,JSON[_0x432f('0xa')](_0x32b062));io['to'](_0x5b5f08)['emit'](_0x2f66fd,_0x32b062);}exports[_0x432f('0xb')]=function(_0x340fe9,_0x3a0d4b,_0x13369a){_0x13369a[_0x432f('0xc')]=0x0;if(_0x3a0d4b['data2']&&parseInt(_0x3a0d4b[_0x432f('0xd')],0xa)){var _0x5758d7={'ListId':parseInt(_0x3a0d4b[_0x432f('0xe')],0xa),'phone':_0x13369a['calleridnum']};if(_[_0x432f('0xf')](_0x13369a[_0x432f('0x10')])){_0x5758d7['firstName']=_0x13369a[_0x432f('0x11')]&&_0x13369a[_0x432f('0x11')]!=='<unknown>'?_0x13369a[_0x432f('0x11')]:_0x13369a[_0x432f('0x12')]||_0x13369a['uniqueid'];}else{_0x5758d7['firstName']=_0x13369a[_0x432f('0x13')]&&_0x13369a[_0x432f('0x13')]!==_0x432f('0x14')?_0x13369a[_0x432f('0x13')]:_0x13369a[_0x432f('0x15')]||_0x13369a['uniqueid'];_0x5758d7[_0x432f('0x16')]=_0x13369a[_0x432f('0x13')]&&_0x13369a[_0x432f('0x13')]!==_0x432f('0x14')?_0x13369a['destcalleridname']:_0x13369a[_0x432f('0x15')]||_0x13369a[_0x432f('0x17')];}BPromise[_0x432f('0x18')]()[_0x432f('0x19')](cmContactRpc[_0x432f('0x1a')]({'where':_[_0x432f('0x1b')](_0x5758d7,['firstName'])}))[_0x432f('0x19')](function(_0x4ddd21){if(_0x4ddd21){_0x13369a[_0x432f('0x1c')]=_0x4ddd21['id'];emit(util[_0x432f('0x1d')](_0x432f('0x1e'),_0x340fe9[_0x432f('0x1f')]),util[_0x432f('0x1d')](_0x432f('0x20'),_0x3a0d4b[_0x432f('0x21')][_0x432f('0x22')]()),_[_0x432f('0x23')](_0x13369a,{'ListId':parseInt(_0x3a0d4b[_0x432f('0xe')],0xa)}));return;}else{return BPromise[_0x432f('0x18')]()[_0x432f('0x19')](cmContactRpc['createContact'](_0x5758d7));}})['then'](function(_0x343d13){if(_0x343d13){_0x13369a['xmd-contactid2']=_0x343d13['id'];emit(util[_0x432f('0x1d')]('user:%s',_0x340fe9[_0x432f('0x1f')]),util[_0x432f('0x1d')](_0x432f('0x20'),_0x3a0d4b[_0x432f('0x21')][_0x432f('0x22')]()),_[_0x432f('0x23')](_0x13369a,{'ListId':parseInt(_0x3a0d4b['data1'],0xa)}));}})[_0x432f('0x24')](function(_0x33edec){logger['error'](_0x432f('0x25'),JSON[_0x432f('0xa')](_0x33edec));});}else{if(_0x340fe9){emit(util[_0x432f('0x1d')](_0x432f('0x1e'),_0x340fe9[_0x432f('0x1f')]),util[_0x432f('0x1d')](_0x432f('0x20'),_0x3a0d4b['action'][_0x432f('0x22')]()),_['merge']({'ListId':parseInt(_0x3a0d4b[_0x432f('0xe')],0xa)},_0x13369a));}}};
\ No newline at end of file
+var _0xd9ed=['data4','[CM][%s][%s]\x20Autocreate\x20enabled','isNil','destcalleridnum','calleridname','<unknown>','Unknown','destcalleridname','resolve','createContact','[CM][%s][%s]\x20Contact\x20created:%s','[CM][%s][%s]\x20Autocreate\x20disabled','push','user:%s','name','trigger:%s','action','toLowerCase','merge','lodash','bluebird','ioredis','util','../../../../config/logger','redis','localhost','socket.io-emitter','[CM][%s][%s]','stringify','exec','data1','data2','xmd-contactid','ListId','data3','phone','$or','map','routeId','calleridnum','firstName','lastName','mobile','fax','scheduledAt','union','then','isEmpty','length','info','uniqueid','join','[CM][%s][%s]\x20Contact\x20not\x20found'];(function(_0x2be99d,_0x1422ea){var _0x4a885d=function(_0x27d301){while(--_0x27d301){_0x2be99d['push'](_0x2be99d['shift']());}};_0x4a885d(++_0x1422ea);}(_0xd9ed,0x151));var _0xdd9e=function(_0x591cc8,_0x51c5ba){_0x591cc8=_0x591cc8-0x0;var _0x3ad157=_0xd9ed[_0x591cc8];return _0x3ad157;};'use strict';var _=require(_0xdd9e('0x0'));var BPromise=require(_0xdd9e('0x1'));var Redis=require(_0xdd9e('0x2'));var util=require(_0xdd9e('0x3'));var config=require('../../../../config/environment');var logger=require(_0xdd9e('0x4'))('trigger');var cmContactRpc=require('../../rpc/cmContact');config[_0xdd9e('0x5')]=_['defaults'](config[_0xdd9e('0x5')],{'host':_0xdd9e('0x6'),'port':0x18eb});var io=require(_0xdd9e('0x7'))(new Redis(config[_0xdd9e('0x5')]));function emit(_0x78abae,_0x56c292,_0x43557e,_0x431405,_0x13059b){logger['info'](_0xdd9e('0x8'),_0x78abae,_0x56c292['id'],_0x43557e,_0x431405,JSON[_0xdd9e('0x9')](_0x13059b));io['to'](_0x43557e)['emit'](_0x431405,_0x13059b);}exports[_0xdd9e('0xa')]=function(_0x42f131,_0xaa4d2,_0x21a5e3,_0x18b8c8){var _0x325fda,_0x132204;var _0x468105={};var _0x5c99f5=Number(_0x21a5e3[_0xdd9e('0xb')]);var _0x204cb7=_0x21a5e3[_0xdd9e('0xc')]?Boolean(Number(_0x21a5e3[_0xdd9e('0xc')])):![];var _0x3133d3;if(_0x18b8c8[_0xdd9e('0xd')]){_0x468105['id']=_0x18b8c8[_0xdd9e('0xd')];}if(!_0x468105['id']){_0x468105[_0xdd9e('0xe')]=_0x5c99f5;_0x3133d3=_0x21a5e3[_0xdd9e('0xf')]&&_0x21a5e3['data3']!=='0'?_0x21a5e3[_0xdd9e('0xf')]['split'](','):[_0xdd9e('0x10')];_0x468105[_0xdd9e('0x11')]=_[_0xdd9e('0x12')](_0x3133d3,function(_0x571043){var _0x50d860={};_0x50d860[_0x571043]=_0x18b8c8[_0xdd9e('0x13')]?_0x18b8c8['destcalleridnum']:_0x18b8c8[_0xdd9e('0x14')];return _0x50d860;});}var _0x87600b=['id',_0xdd9e('0x15'),_0xdd9e('0x16'),_0xdd9e('0x10'),_0xdd9e('0x17'),_0xdd9e('0x18'),'ListId','createdAt',_0xdd9e('0x19'),'updatedAt'];var _0x5167ea=_[_0xdd9e('0x1a')](_0x87600b,_0x3133d3);BPromise['resolve']()[_0xdd9e('0x1b')](cmContactRpc['getContacts']({'attributes':_0x5167ea,'where':_0x468105}))[_0xdd9e('0x1b')](function(_0x42962f){_0x132204=_0x42962f;if(!_[_0xdd9e('0x1c')](_0x132204)){if(_0x132204[_0xdd9e('0x1d')]===0x1){_0x325fda=_0x132204[0x0];logger[_0xdd9e('0x1e')]('[CM][%s][%s]\x20Contact\x20found:%s',_0x18b8c8['uniqueid'],_0xaa4d2['id'],_0x325fda['id']);}else{logger[_0xdd9e('0x1e')]('[CM][%s][%s]\x20Multiple\x20contacts\x20found:[%s]',_0x18b8c8[_0xdd9e('0x1f')],_0xaa4d2['id'],_[_0xdd9e('0x12')](_0x132204,'id')[_0xdd9e('0x20')](','));}return;}else{logger[_0xdd9e('0x1e')](_0xdd9e('0x21'),_0x18b8c8[_0xdd9e('0x1f')],_0xaa4d2['id']);var _0x3c8769={'ListId':_0x5c99f5};var _0x5cb146=_0x21a5e3[_0xdd9e('0x22')]&&_0x21a5e3[_0xdd9e('0x22')]!=='0'?_0x21a5e3[_0xdd9e('0x22')]:'phone';if(_0x204cb7){logger[_0xdd9e('0x1e')](_0xdd9e('0x23'),_0x18b8c8['uniqueid'],_0xaa4d2['id']);_0x3c8769[_0x5cb146]=_[_0xdd9e('0x24')](_0x18b8c8['routeId'])?_0x18b8c8[_0xdd9e('0x14')]:_0x18b8c8[_0xdd9e('0x25')];if(_[_0xdd9e('0x24')](_0x18b8c8[_0xdd9e('0x13')])){_0x3c8769[_0xdd9e('0x15')]=_0x18b8c8['calleridname']&&_0x18b8c8[_0xdd9e('0x26')]!==_0xdd9e('0x27')?_0x18b8c8[_0xdd9e('0x26')]:_0xdd9e('0x28');}else{_0x3c8769[_0xdd9e('0x15')]=_0x18b8c8['destcalleridname']&&_0x18b8c8[_0xdd9e('0x29')]!==_0xdd9e('0x27')?_0x18b8c8[_0xdd9e('0x29')]:_0xdd9e('0x28');}return BPromise[_0xdd9e('0x2a')]()[_0xdd9e('0x1b')](cmContactRpc[_0xdd9e('0x2b')](_0x3c8769))[_0xdd9e('0x1b')](function(_0x58cad7){_0x325fda=_0x58cad7;_0x132204['push'](_0x58cad7);if(_0x325fda){logger[_0xdd9e('0x1e')](_0xdd9e('0x2c'),_0x18b8c8[_0xdd9e('0x1f')],_0xaa4d2['id'],_0x325fda['id']);}return;});}else{logger['info'](_0xdd9e('0x2d'),_0x18b8c8['uniqueid'],_0xaa4d2['id']);_0x3c8769[_0x5cb146]=_['isNil'](_0x18b8c8[_0xdd9e('0x13')])?_0x18b8c8['calleridnum']:_0x18b8c8[_0xdd9e('0x25')];if(_[_0xdd9e('0x24')](_0x18b8c8[_0xdd9e('0x13')])){_0x3c8769[_0xdd9e('0x15')]=_0x18b8c8[_0xdd9e('0x26')]&&_0x18b8c8[_0xdd9e('0x26')]!==_0xdd9e('0x27')?_0x18b8c8[_0xdd9e('0x26')]:_0xdd9e('0x28');}else{_0x3c8769[_0xdd9e('0x15')]=_0x18b8c8[_0xdd9e('0x29')]&&_0x18b8c8[_0xdd9e('0x29')]!==_0xdd9e('0x27')?_0x18b8c8[_0xdd9e('0x29')]:_0xdd9e('0x28');}_0x325fda=_0x3c8769;_0x132204[_0xdd9e('0x2e')](_0x3c8769);return;}}})[_0xdd9e('0x1b')](function(){if(_0x42f131){emit(_0x18b8c8[_0xdd9e('0x1f')],_0xaa4d2,util['format'](_0xdd9e('0x2f'),_0x42f131[_0xdd9e('0x30')]),util['format'](_0xdd9e('0x31'),_0x21a5e3[_0xdd9e('0x32')][_0xdd9e('0x33')]()),{'evt':_[_0xdd9e('0x34')](_0x18b8c8,{'autoCreate':_0x204cb7}),'contact':_0x325fda===undefined?{}:_0x325fda,'contacts':_0x132204[_0xdd9e('0x1d')]===0x0?undefined:_0x132204});}});};
\ No newline at end of file