Built motion from commit (unavailable).|2.5.31
[motion2.git] / server / services / ami / trigger / cmContact / index.js
index 9a28d6a..44e1ef3 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x72d5=['localhost','socket.io-emitter','info','[CM][%s][%s]','stringify','emit','data1','data2','xmd-contactid','ListId','data3','split','phone','routeId','destcalleridnum','firstName','lastName','mobile','scheduledAt','updatedAt','union','resolve','then','getContacts','length','uniqueid','[CM][%s][%s]\x20Multiple\x20contacts\x20found:[%s]','map','join','[CM][%s][%s]\x20Contact\x20not\x20found','data4','[CM][%s][%s]\x20Autocreate\x20enabled','calleridname','<unknown>','destcalleridname','Unknown','createContact','[CM][%s][%s]\x20Contact\x20created:%s','[CM][%s][%s]\x20Autocreate\x20disabled','calleridnum','format','name','trigger:%s','action','toLowerCase','merge','lodash','bluebird','ioredis','util','../../../../config/logger','trigger','../../rpc/cmContact','redis','defaults'];(function(_0x2c0cf4,_0x5241b){var _0x4b4899=function(_0x26606a){while(--_0x26606a){_0x2c0cf4['push'](_0x2c0cf4['shift']());}};_0x4b4899(++_0x5241b);}(_0x72d5,0x9c));var _0x572d=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0x72d5[_0x3dd15e];return _0x231fd0;};'use strict';var _=require(_0x572d('0x0'));var BPromise=require(_0x572d('0x1'));var Redis=require(_0x572d('0x2'));var util=require(_0x572d('0x3'));var config=require('../../../../config/environment');var logger=require(_0x572d('0x4'))(_0x572d('0x5'));var cmContactRpc=require(_0x572d('0x6'));config[_0x572d('0x7')]=_[_0x572d('0x8')](config[_0x572d('0x7')],{'host':_0x572d('0x9'),'port':0x18eb});var io=require(_0x572d('0xa'))(new Redis(config[_0x572d('0x7')]));function emit(_0x19b33b,_0x1b67e4,_0x30aaff,_0x9c7638,_0xbd5407){logger[_0x572d('0xb')](_0x572d('0xc'),_0x19b33b,_0x1b67e4['id'],_0x30aaff,_0x9c7638,JSON[_0x572d('0xd')](_0xbd5407));io['to'](_0x30aaff)[_0x572d('0xe')](_0x9c7638,_0xbd5407);}exports['exec']=function(_0x51c5e7,_0x352230,_0x33226f,_0x8625d9){var _0x15e215,_0x566c6c;var _0x3e44fb={};var _0x314c66=Number(_0x33226f[_0x572d('0xf')]);var _0x29d287=_0x33226f['data2']?Boolean(Number(_0x33226f[_0x572d('0x10')])):![];var _0x42f31f;if(_0x8625d9[_0x572d('0x11')]){_0x3e44fb['id']=_0x8625d9[_0x572d('0x11')];}if(!_0x3e44fb['id']){_0x3e44fb[_0x572d('0x12')]=_0x314c66;_0x42f31f=_0x33226f[_0x572d('0x13')]&&_0x33226f['data3']!=='0'?_0x33226f['data3'][_0x572d('0x14')](','):[_0x572d('0x15')];_0x3e44fb['$or']=_['map'](_0x42f31f,function(_0x2fbde1){var _0x14bd00={};_0x14bd00[_0x2fbde1]=_0x8625d9[_0x572d('0x16')]?_0x8625d9[_0x572d('0x17')]:_0x8625d9['calleridnum'];return _0x14bd00;});}var _0x1f0fa5=['id',_0x572d('0x18'),_0x572d('0x19'),'phone',_0x572d('0x1a'),'fax',_0x572d('0x12'),'createdAt',_0x572d('0x1b'),_0x572d('0x1c')];var _0x1b8fb3=_[_0x572d('0x1d')](_0x1f0fa5,_0x42f31f);BPromise[_0x572d('0x1e')]()[_0x572d('0x1f')](cmContactRpc[_0x572d('0x20')]({'attributes':_0x1b8fb3,'where':_0x3e44fb}))[_0x572d('0x1f')](function(_0x23ca4e){_0x566c6c=_0x23ca4e;if(!_['isEmpty'](_0x566c6c)){if(_0x566c6c[_0x572d('0x21')]===0x1){_0x15e215=_0x566c6c[0x0];logger[_0x572d('0xb')]('[CM][%s][%s]\x20Contact\x20found:%s',_0x8625d9[_0x572d('0x22')],_0x352230['id'],_0x15e215['id']);}else{logger[_0x572d('0xb')](_0x572d('0x23'),_0x8625d9[_0x572d('0x22')],_0x352230['id'],_[_0x572d('0x24')](_0x566c6c,'id')[_0x572d('0x25')](','));}return;}else{logger[_0x572d('0xb')](_0x572d('0x26'),_0x8625d9[_0x572d('0x22')],_0x352230['id']);var _0x40b6a8={'ListId':_0x314c66};var _0x2cb030=_0x33226f[_0x572d('0x27')]&&_0x33226f[_0x572d('0x27')]!=='0'?_0x33226f[_0x572d('0x27')]:_0x572d('0x15');if(_0x29d287){logger[_0x572d('0xb')](_0x572d('0x28'),_0x8625d9[_0x572d('0x22')],_0x352230['id']);_0x40b6a8[_0x2cb030]=_['isNil'](_0x8625d9['routeId'])?_0x8625d9['calleridnum']:_0x8625d9[_0x572d('0x17')];if(_['isNil'](_0x8625d9[_0x572d('0x16')])){_0x40b6a8['firstName']=_0x8625d9[_0x572d('0x29')]&&_0x8625d9[_0x572d('0x29')]!==_0x572d('0x2a')?_0x8625d9[_0x572d('0x29')]:'Unknown';}else{_0x40b6a8['firstName']=_0x8625d9[_0x572d('0x2b')]&&_0x8625d9[_0x572d('0x2b')]!==_0x572d('0x2a')?_0x8625d9[_0x572d('0x2b')]:_0x572d('0x2c');}return BPromise[_0x572d('0x1e')]()[_0x572d('0x1f')](cmContactRpc[_0x572d('0x2d')](_0x40b6a8))['then'](function(_0x41a743){_0x15e215=_0x41a743;_0x566c6c['push'](_0x41a743);if(_0x15e215){logger[_0x572d('0xb')](_0x572d('0x2e'),_0x8625d9['uniqueid'],_0x352230['id'],_0x15e215['id']);}return;});}else{logger[_0x572d('0xb')](_0x572d('0x2f'),_0x8625d9[_0x572d('0x22')],_0x352230['id']);_0x40b6a8[_0x2cb030]=_['isNil'](_0x8625d9['routeId'])?_0x8625d9[_0x572d('0x30')]:_0x8625d9['destcalleridnum'];if(_['isNil'](_0x8625d9[_0x572d('0x16')])){_0x40b6a8[_0x572d('0x18')]=_0x8625d9[_0x572d('0x29')]&&_0x8625d9[_0x572d('0x29')]!=='<unknown>'?_0x8625d9[_0x572d('0x29')]:_0x572d('0x2c');}else{_0x40b6a8['firstName']=_0x8625d9[_0x572d('0x2b')]&&_0x8625d9[_0x572d('0x2b')]!==_0x572d('0x2a')?_0x8625d9[_0x572d('0x2b')]:'Unknown';}_0x15e215=_0x40b6a8;_0x566c6c['push'](_0x40b6a8);return;}}})[_0x572d('0x1f')](function(){if(_0x51c5e7){emit(_0x8625d9[_0x572d('0x22')],_0x352230,util[_0x572d('0x31')]('user:%s',_0x51c5e7[_0x572d('0x32')]),util[_0x572d('0x31')](_0x572d('0x33'),_0x33226f[_0x572d('0x34')][_0x572d('0x35')]()),{'evt':_[_0x572d('0x36')](_0x8625d9,{'autoCreate':_0x29d287}),'contact':_0x15e215===undefined?{}:_0x15e215,'contacts':_0x566c6c[_0x572d('0x21')]===0x0?undefined:_0x566c6c});}});};
\ No newline at end of file
+var _0x244f=['util','../../../../config/environment','../../../../config/logger','trigger','../../rpc/cmContact','redis','localhost','info','[CM][%s][%s]','stringify','exec','data1','data2','xmd-contactid','ListId','data3','split','phone','map','destcalleridnum','calleridnum','firstName','lastName','mobile','fax','createdAt','scheduledAt','updatedAt','union','resolve','then','getContacts','isEmpty','[CM][%s][%s]\x20Contact\x20found:%s','uniqueid','[CM][%s][%s]\x20Multiple\x20contacts\x20found:[%s]','join','[CM][%s][%s]\x20Contact\x20not\x20found','data4','[CM][%s][%s]\x20Autocreate\x20enabled','isNil','routeId','calleridname','Unknown','destcalleridname','<unknown>','push','[CM][%s][%s]\x20Contact\x20created:%s','user:%s','name','format','trigger:%s','toLowerCase','merge','lodash','bluebird'];(function(_0x1d24eb,_0x12295b){var _0x1dc576=function(_0x4d5770){while(--_0x4d5770){_0x1d24eb['push'](_0x1d24eb['shift']());}};_0x1dc576(++_0x12295b);}(_0x244f,0x14e));var _0xf244=function(_0x3dd623,_0x5bb2e0){_0x3dd623=_0x3dd623-0x0;var _0x36a54e=_0x244f[_0x3dd623];return _0x36a54e;};'use strict';var _=require(_0xf244('0x0'));var BPromise=require(_0xf244('0x1'));var Redis=require('ioredis');var util=require(_0xf244('0x2'));var config=require(_0xf244('0x3'));var logger=require(_0xf244('0x4'))(_0xf244('0x5'));var cmContactRpc=require(_0xf244('0x6'));config[_0xf244('0x7')]=_['defaults'](config['redis'],{'host':_0xf244('0x8'),'port':0x18eb});var io=require('socket.io-emitter')(new Redis(config[_0xf244('0x7')]));function emit(_0x3d5832,_0xb656f1,_0x7cf160,_0x412575,_0x41d973){logger[_0xf244('0x9')](_0xf244('0xa'),_0x3d5832,_0xb656f1['id'],_0x7cf160,_0x412575,JSON[_0xf244('0xb')](_0x41d973));io['to'](_0x7cf160)['emit'](_0x412575,_0x41d973);}exports[_0xf244('0xc')]=function(_0x8e7a4d,_0x31ed45,_0x2ddbbc,_0x41e10d){var _0x4b9051,_0x587abb;var _0x50c124={};var _0x465df6=Number(_0x2ddbbc[_0xf244('0xd')]);var _0x3ce714=_0x2ddbbc[_0xf244('0xe')]?Boolean(Number(_0x2ddbbc[_0xf244('0xe')])):![];var _0x1cf7a9;if(_0x41e10d['xmd-contactid']){_0x50c124['id']=_0x41e10d[_0xf244('0xf')];}if(!_0x50c124['id']){_0x50c124[_0xf244('0x10')]=_0x465df6;_0x1cf7a9=_0x2ddbbc[_0xf244('0x11')]&&_0x2ddbbc[_0xf244('0x11')]!=='0'?_0x2ddbbc[_0xf244('0x11')][_0xf244('0x12')](','):[_0xf244('0x13')];_0x50c124['$or']=_[_0xf244('0x14')](_0x1cf7a9,function(_0x5743af){var _0x5d9276={};_0x5d9276[_0x5743af]=_0x41e10d['routeId']?_0x41e10d[_0xf244('0x15')]:_0x41e10d[_0xf244('0x16')];return _0x5d9276;});}var _0x3c92bf=['id',_0xf244('0x17'),_0xf244('0x18'),_0xf244('0x13'),_0xf244('0x19'),_0xf244('0x1a'),'ListId',_0xf244('0x1b'),_0xf244('0x1c'),_0xf244('0x1d')];var _0x2e9bc8=_[_0xf244('0x1e')](_0x3c92bf,_0x1cf7a9);BPromise[_0xf244('0x1f')]()[_0xf244('0x20')](cmContactRpc[_0xf244('0x21')]({'attributes':_0x2e9bc8,'where':_0x50c124}))[_0xf244('0x20')](function(_0x41574b){_0x587abb=_0x41574b;if(!_[_0xf244('0x22')](_0x587abb)){if(_0x587abb['length']===0x1){_0x4b9051=_0x587abb[0x0];logger[_0xf244('0x9')](_0xf244('0x23'),_0x41e10d[_0xf244('0x24')],_0x31ed45['id'],_0x4b9051['id']);}else{logger['info'](_0xf244('0x25'),_0x41e10d[_0xf244('0x24')],_0x31ed45['id'],_[_0xf244('0x14')](_0x587abb,'id')[_0xf244('0x26')](','));}return;}else{logger[_0xf244('0x9')](_0xf244('0x27'),_0x41e10d[_0xf244('0x24')],_0x31ed45['id']);var _0x28d2db={'ListId':_0x465df6};var _0x3eabe5=_0x2ddbbc[_0xf244('0x28')]&&_0x2ddbbc[_0xf244('0x28')]!=='0'?_0x2ddbbc[_0xf244('0x28')]:'phone';if(_0x3ce714){logger[_0xf244('0x9')](_0xf244('0x29'),_0x41e10d[_0xf244('0x24')],_0x31ed45['id']);_0x28d2db[_0x3eabe5]=_[_0xf244('0x2a')](_0x41e10d[_0xf244('0x2b')])?_0x41e10d[_0xf244('0x16')]:_0x41e10d[_0xf244('0x15')];if(_[_0xf244('0x2a')](_0x41e10d[_0xf244('0x2b')])){_0x28d2db[_0xf244('0x17')]=_0x41e10d[_0xf244('0x2c')]&&_0x41e10d[_0xf244('0x2c')]!=='<unknown>'?_0x41e10d[_0xf244('0x2c')]:_0xf244('0x2d');}else{_0x28d2db['firstName']=_0x41e10d['destcalleridname']&&_0x41e10d[_0xf244('0x2e')]!==_0xf244('0x2f')?_0x41e10d['destcalleridname']:_0xf244('0x2d');}return BPromise[_0xf244('0x1f')]()[_0xf244('0x20')](cmContactRpc['createContact'](_0x28d2db))[_0xf244('0x20')](function(_0x43c0c7){_0x4b9051=_0x43c0c7;_0x587abb[_0xf244('0x30')](_0x43c0c7);if(_0x4b9051){logger[_0xf244('0x9')](_0xf244('0x31'),_0x41e10d[_0xf244('0x24')],_0x31ed45['id'],_0x4b9051['id']);}return;});}else{logger[_0xf244('0x9')]('[CM][%s][%s]\x20Autocreate\x20disabled',_0x41e10d[_0xf244('0x24')],_0x31ed45['id']);_0x28d2db[_0x3eabe5]=_[_0xf244('0x2a')](_0x41e10d[_0xf244('0x2b')])?_0x41e10d[_0xf244('0x16')]:_0x41e10d[_0xf244('0x15')];if(_['isNil'](_0x41e10d[_0xf244('0x2b')])){_0x28d2db[_0xf244('0x17')]=_0x41e10d[_0xf244('0x2c')]&&_0x41e10d[_0xf244('0x2c')]!==_0xf244('0x2f')?_0x41e10d[_0xf244('0x2c')]:'Unknown';}else{_0x28d2db[_0xf244('0x17')]=_0x41e10d['destcalleridname']&&_0x41e10d[_0xf244('0x2e')]!=='<unknown>'?_0x41e10d['destcalleridname']:_0xf244('0x2d');}_0x4b9051=_0x28d2db;_0x587abb[_0xf244('0x30')](_0x28d2db);return;}}})['then'](function(){if(_0x8e7a4d){emit(_0x41e10d[_0xf244('0x24')],_0x31ed45,util['format'](_0xf244('0x32'),_0x8e7a4d[_0xf244('0x33')]),util[_0xf244('0x34')](_0xf244('0x35'),_0x2ddbbc['action'][_0xf244('0x36')]()),{'evt':_[_0xf244('0x37')](_0x41e10d,{'autoCreate':_0x3ce714}),'contact':_0x4b9051===undefined?{}:_0x4b9051,'contacts':_0x587abb['length']===0x0?undefined:_0x587abb});}});};
\ No newline at end of file