Built motion from commit (unavailable).|2.5.1
[motion2.git] / server / services / ami / trigger / cmContact / index.js
index 4f03ee3..ab74e12 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x4ac9=['getContacts','then','length','uniqueid','[CM][%s][%s]\x20Multiple\x20contacts\x20found:[%s]','data4','phone','[CM][%s][%s]\x20Autocreate\x20enabled','isNil','calleridname','<unknown>','destcalleridname','push','[CM][%s][%s]\x20Contact\x20created:%s','[CM][%s][%s]\x20Autocreate\x20disabled','Unknown','format','name','trigger:%s','action','toLowerCase','merge','lodash','bluebird','ioredis','util','../../../../config/environment','trigger','../../rpc/cmContact','redis','defaults','socket.io-emitter','info','[CM][%s][%s]','exec','data1','data2','xmd-contactid','ListId','data3','map','routeId','destcalleridnum','calleridnum','firstName','lastName','mobile','createdAt','scheduledAt','updatedAt','resolve'];(function(_0x49f0b9,_0x28afce){var _0x2c3ec0=function(_0x178fb0){while(--_0x178fb0){_0x49f0b9['push'](_0x49f0b9['shift']());}};_0x2c3ec0(++_0x28afce);}(_0x4ac9,0x115));var _0x94ac=function(_0x53ccf2,_0x13cb67){_0x53ccf2=_0x53ccf2-0x0;var _0x5a2964=_0x4ac9[_0x53ccf2];return _0x5a2964;};'use strict';var _=require(_0x94ac('0x0'));var BPromise=require(_0x94ac('0x1'));var Redis=require(_0x94ac('0x2'));var util=require(_0x94ac('0x3'));var config=require(_0x94ac('0x4'));var logger=require('../../../../config/logger')(_0x94ac('0x5'));var cmContactRpc=require(_0x94ac('0x6'));config[_0x94ac('0x7')]=_[_0x94ac('0x8')](config[_0x94ac('0x7')],{'host':'localhost','port':0x18eb});var io=require(_0x94ac('0x9'))(new Redis(config[_0x94ac('0x7')]));function emit(_0x16e8c7,_0x4ca6ab,_0x1dea3a,_0x33310f,_0x3499fa){logger[_0x94ac('0xa')](_0x94ac('0xb'),_0x16e8c7,_0x4ca6ab['id'],_0x1dea3a,_0x33310f,JSON['stringify'](_0x3499fa));io['to'](_0x1dea3a)['emit'](_0x33310f,_0x3499fa);}exports[_0x94ac('0xc')]=function(_0x428160,_0x4146d2,_0x242a95,_0xcac163){var _0x4c540c,_0x306ad9;var _0x4039b9={};var _0x16c1cd=Number(_0x242a95[_0x94ac('0xd')]);var _0x14d7a0=_0x242a95['data2']?Boolean(Number(_0x242a95[_0x94ac('0xe')])):![];var _0xc94772;if(_0xcac163[_0x94ac('0xf')]){_0x4039b9['id']=_0xcac163[_0x94ac('0xf')];}if(!_0x4039b9['id']){_0x4039b9[_0x94ac('0x10')]=_0x16c1cd;_0xc94772=_0x242a95['data3']&&_0x242a95['data3']!=='0'?_0x242a95[_0x94ac('0x11')]['split'](','):['phone'];_0x4039b9['$or']=_[_0x94ac('0x12')](_0xc94772,function(_0x2e7a53){var _0x38d592={};_0x38d592[_0x2e7a53]=_0xcac163[_0x94ac('0x13')]?_0xcac163[_0x94ac('0x14')]:_0xcac163[_0x94ac('0x15')];return _0x38d592;});}var _0x17a32b=['id',_0x94ac('0x16'),_0x94ac('0x17'),'phone',_0x94ac('0x18'),'fax',_0x94ac('0x10'),_0x94ac('0x19'),_0x94ac('0x1a'),_0x94ac('0x1b')];var _0x57ed94=_['union'](_0x17a32b,_0xc94772);BPromise[_0x94ac('0x1c')]()['then'](cmContactRpc[_0x94ac('0x1d')]({'attributes':_0x57ed94,'where':_0x4039b9}))[_0x94ac('0x1e')](function(_0x4cff8a){_0x306ad9=_0x4cff8a;if(!_['isEmpty'](_0x306ad9)){if(_0x306ad9[_0x94ac('0x1f')]===0x1){_0x4c540c=_0x306ad9[0x0];logger[_0x94ac('0xa')]('[CM][%s][%s]\x20Contact\x20found:%s',_0xcac163[_0x94ac('0x20')],_0x4146d2['id'],_0x4c540c['id']);}else{logger[_0x94ac('0xa')](_0x94ac('0x21'),_0xcac163['uniqueid'],_0x4146d2['id'],_['map'](_0x306ad9,'id')['join'](','));}return;}else{logger[_0x94ac('0xa')]('[CM][%s][%s]\x20Contact\x20not\x20found',_0xcac163[_0x94ac('0x20')],_0x4146d2['id']);var _0x1f14b5={'ListId':_0x16c1cd};var _0x402585=_0x242a95[_0x94ac('0x22')]&&_0x242a95[_0x94ac('0x22')]!=='0'?_0x242a95[_0x94ac('0x22')]:_0x94ac('0x23');if(_0x14d7a0){logger[_0x94ac('0xa')](_0x94ac('0x24'),_0xcac163[_0x94ac('0x20')],_0x4146d2['id']);_0x1f14b5[_0x402585]=_[_0x94ac('0x25')](_0xcac163['routeId'])?_0xcac163[_0x94ac('0x15')]:_0xcac163[_0x94ac('0x14')];if(_[_0x94ac('0x25')](_0xcac163['routeId'])){_0x1f14b5[_0x94ac('0x16')]=_0xcac163[_0x94ac('0x26')]&&_0xcac163[_0x94ac('0x26')]!==_0x94ac('0x27')?_0xcac163['calleridname']:'Unknown';}else{_0x1f14b5[_0x94ac('0x16')]=_0xcac163[_0x94ac('0x28')]&&_0xcac163[_0x94ac('0x28')]!=='<unknown>'?_0xcac163[_0x94ac('0x28')]:'Unknown';}return BPromise['resolve']()[_0x94ac('0x1e')](cmContactRpc['createContact'](_0x1f14b5))[_0x94ac('0x1e')](function(_0x58ded4){_0x4c540c=_0x58ded4;_0x306ad9[_0x94ac('0x29')](_0x58ded4);if(_0x4c540c){logger['info'](_0x94ac('0x2a'),_0xcac163[_0x94ac('0x20')],_0x4146d2['id'],_0x4c540c['id']);}return;});}else{logger[_0x94ac('0xa')](_0x94ac('0x2b'),_0xcac163[_0x94ac('0x20')],_0x4146d2['id']);_0x1f14b5[_0x402585]=_['isNil'](_0xcac163[_0x94ac('0x13')])?_0xcac163['calleridnum']:_0xcac163[_0x94ac('0x14')];if(_[_0x94ac('0x25')](_0xcac163[_0x94ac('0x13')])){_0x1f14b5['firstName']=_0xcac163[_0x94ac('0x26')]&&_0xcac163['calleridname']!=='<unknown>'?_0xcac163[_0x94ac('0x26')]:_0x94ac('0x2c');}else{_0x1f14b5[_0x94ac('0x16')]=_0xcac163[_0x94ac('0x28')]&&_0xcac163[_0x94ac('0x28')]!==_0x94ac('0x27')?_0xcac163[_0x94ac('0x28')]:_0x94ac('0x2c');}_0x4c540c=_0x1f14b5;_0x306ad9[_0x94ac('0x29')](_0x1f14b5);return;}}})['then'](function(){if(_0x428160){emit(_0xcac163[_0x94ac('0x20')],_0x4146d2,util[_0x94ac('0x2d')]('user:%s',_0x428160[_0x94ac('0x2e')]),util['format'](_0x94ac('0x2f'),_0x242a95[_0x94ac('0x30')][_0x94ac('0x31')]()),{'evt':_[_0x94ac('0x32')](_0xcac163,{'autoCreate':_0x14d7a0}),'contact':_0x4c540c===undefined?{}:_0x4c540c,'contacts':_0x306ad9['length']===0x0?undefined:_0x306ad9});}});};
\ No newline at end of file
+var _0xf3fd=['isNil','format','user:%s','name','trigger:%s','action','toLowerCase','merge','length','lodash','bluebird','util','../../../../config/environment','../../../../config/logger','trigger','../../rpc/cmContact','redis','defaults','socket.io-emitter','info','stringify','emit','exec','data2','xmd-contactid','ListId','data3','split','destcalleridnum','calleridnum','firstName','lastName','phone','mobile','createdAt','scheduledAt','updatedAt','union','resolve','getContacts','then','isEmpty','[CM][%s][%s]\x20Contact\x20found:%s','uniqueid','[CM][%s][%s]\x20Multiple\x20contacts\x20found:[%s]','map','join','[CM][%s][%s]\x20Contact\x20not\x20found','data4','[CM][%s][%s]\x20Autocreate\x20enabled','routeId','calleridname','Unknown','destcalleridname','<unknown>','createContact','push','[CM][%s][%s]\x20Contact\x20created:%s','[CM][%s][%s]\x20Autocreate\x20disabled'];(function(_0x795b85,_0xa0ddc9){var _0x48516a=function(_0x340f30){while(--_0x340f30){_0x795b85['push'](_0x795b85['shift']());}};_0x48516a(++_0xa0ddc9);}(_0xf3fd,0x7f));var _0xdf3f=function(_0x6131cd,_0x4c26a1){_0x6131cd=_0x6131cd-0x0;var _0x47e916=_0xf3fd[_0x6131cd];return _0x47e916;};'use strict';var _=require(_0xdf3f('0x0'));var BPromise=require(_0xdf3f('0x1'));var Redis=require('ioredis');var util=require(_0xdf3f('0x2'));var config=require(_0xdf3f('0x3'));var logger=require(_0xdf3f('0x4'))(_0xdf3f('0x5'));var cmContactRpc=require(_0xdf3f('0x6'));config[_0xdf3f('0x7')]=_[_0xdf3f('0x8')](config[_0xdf3f('0x7')],{'host':'localhost','port':0x18eb});var io=require(_0xdf3f('0x9'))(new Redis(config['redis']));function emit(_0x20cd43,_0x2e6073,_0x263a2a,_0xdbe17c,_0x1f40e0){logger[_0xdf3f('0xa')]('[CM][%s][%s]',_0x20cd43,_0x2e6073['id'],_0x263a2a,_0xdbe17c,JSON[_0xdf3f('0xb')](_0x1f40e0));io['to'](_0x263a2a)[_0xdf3f('0xc')](_0xdbe17c,_0x1f40e0);}exports[_0xdf3f('0xd')]=function(_0x36645e,_0x396b47,_0x17cd68,_0x4fa68c){var _0x1a513e,_0x41ba36;var _0x566907={};var _0x4adca8=Number(_0x17cd68['data1']);var _0x1379ab=_0x17cd68[_0xdf3f('0xe')]?Boolean(Number(_0x17cd68[_0xdf3f('0xe')])):![];var _0x28e14d;if(_0x4fa68c['xmd-contactid']){_0x566907['id']=_0x4fa68c[_0xdf3f('0xf')];}if(!_0x566907['id']){_0x566907[_0xdf3f('0x10')]=_0x4adca8;_0x28e14d=_0x17cd68['data3']&&_0x17cd68[_0xdf3f('0x11')]!=='0'?_0x17cd68[_0xdf3f('0x11')][_0xdf3f('0x12')](','):['phone'];_0x566907['$or']=_['map'](_0x28e14d,function(_0x545a2a){var _0x384c39={};_0x384c39[_0x545a2a]=_0x4fa68c['routeId']?_0x4fa68c[_0xdf3f('0x13')]:_0x4fa68c[_0xdf3f('0x14')];return _0x384c39;});}var _0x359b71=['id',_0xdf3f('0x15'),_0xdf3f('0x16'),_0xdf3f('0x17'),_0xdf3f('0x18'),'fax','ListId',_0xdf3f('0x19'),_0xdf3f('0x1a'),_0xdf3f('0x1b')];var _0x157a2f=_[_0xdf3f('0x1c')](_0x359b71,_0x28e14d);BPromise[_0xdf3f('0x1d')]()['then'](cmContactRpc[_0xdf3f('0x1e')]({'attributes':_0x157a2f,'where':_0x566907}))[_0xdf3f('0x1f')](function(_0x4131f5){_0x41ba36=_0x4131f5;if(!_[_0xdf3f('0x20')](_0x41ba36)){if(_0x41ba36['length']===0x1){_0x1a513e=_0x41ba36[0x0];logger[_0xdf3f('0xa')](_0xdf3f('0x21'),_0x4fa68c[_0xdf3f('0x22')],_0x396b47['id'],_0x1a513e['id']);}else{logger['info'](_0xdf3f('0x23'),_0x4fa68c[_0xdf3f('0x22')],_0x396b47['id'],_[_0xdf3f('0x24')](_0x41ba36,'id')[_0xdf3f('0x25')](','));}return;}else{logger[_0xdf3f('0xa')](_0xdf3f('0x26'),_0x4fa68c[_0xdf3f('0x22')],_0x396b47['id']);var _0x16e2bb={'ListId':_0x4adca8};var _0x4c2c65=_0x17cd68[_0xdf3f('0x27')]&&_0x17cd68['data4']!=='0'?_0x17cd68['data4']:_0xdf3f('0x17');if(_0x1379ab){logger[_0xdf3f('0xa')](_0xdf3f('0x28'),_0x4fa68c[_0xdf3f('0x22')],_0x396b47['id']);_0x16e2bb[_0x4c2c65]=_['isNil'](_0x4fa68c[_0xdf3f('0x29')])?_0x4fa68c[_0xdf3f('0x14')]:_0x4fa68c['destcalleridnum'];if(_['isNil'](_0x4fa68c[_0xdf3f('0x29')])){_0x16e2bb[_0xdf3f('0x15')]=_0x4fa68c[_0xdf3f('0x2a')]&&_0x4fa68c[_0xdf3f('0x2a')]!=='<unknown>'?_0x4fa68c[_0xdf3f('0x2a')]:_0xdf3f('0x2b');}else{_0x16e2bb[_0xdf3f('0x15')]=_0x4fa68c['destcalleridname']&&_0x4fa68c[_0xdf3f('0x2c')]!==_0xdf3f('0x2d')?_0x4fa68c[_0xdf3f('0x2c')]:_0xdf3f('0x2b');}return BPromise[_0xdf3f('0x1d')]()[_0xdf3f('0x1f')](cmContactRpc[_0xdf3f('0x2e')](_0x16e2bb))['then'](function(_0x55228a){_0x1a513e=_0x55228a;_0x41ba36[_0xdf3f('0x2f')](_0x55228a);if(_0x1a513e){logger[_0xdf3f('0xa')](_0xdf3f('0x30'),_0x4fa68c['uniqueid'],_0x396b47['id'],_0x1a513e['id']);}return;});}else{logger[_0xdf3f('0xa')](_0xdf3f('0x31'),_0x4fa68c[_0xdf3f('0x22')],_0x396b47['id']);_0x16e2bb[_0x4c2c65]=_[_0xdf3f('0x32')](_0x4fa68c[_0xdf3f('0x29')])?_0x4fa68c[_0xdf3f('0x14')]:_0x4fa68c[_0xdf3f('0x13')];if(_[_0xdf3f('0x32')](_0x4fa68c[_0xdf3f('0x29')])){_0x16e2bb[_0xdf3f('0x15')]=_0x4fa68c[_0xdf3f('0x2a')]&&_0x4fa68c[_0xdf3f('0x2a')]!==_0xdf3f('0x2d')?_0x4fa68c['calleridname']:'Unknown';}else{_0x16e2bb[_0xdf3f('0x15')]=_0x4fa68c['destcalleridname']&&_0x4fa68c[_0xdf3f('0x2c')]!==_0xdf3f('0x2d')?_0x4fa68c[_0xdf3f('0x2c')]:'Unknown';}_0x1a513e=_0x16e2bb;_0x41ba36['push'](_0x16e2bb);return;}}})['then'](function(){if(_0x36645e){emit(_0x4fa68c[_0xdf3f('0x22')],_0x396b47,util[_0xdf3f('0x33')](_0xdf3f('0x34'),_0x36645e[_0xdf3f('0x35')]),util[_0xdf3f('0x33')](_0xdf3f('0x36'),_0x17cd68[_0xdf3f('0x37')][_0xdf3f('0x38')]()),{'evt':_[_0xdf3f('0x39')](_0x4fa68c,{'autoCreate':_0x1379ab}),'contact':_0x1a513e===undefined?{}:_0x1a513e,'contacts':_0x41ba36[_0xdf3f('0x3a')]===0x0?undefined:_0x41ba36});}});};
\ No newline at end of file