Built motion from commit 497d3d92.|2.5.43
[motion2.git] / server / services / ami / trigger / cmContact / index.js
index 3e96367..179c1ae 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x7bae=['data5','xmd-contactid','ListId','data3','map','firstName','lastName','phone','mobile','createdAt','scheduledAt','updatedAt','union','resolve','getContacts','then','isEmpty','length','[CM][%s][%s]\x20Contact\x20found:%s','uniqueid','[CM][%s][%s]\x20Multiple\x20contacts\x20found:[%s]','[CM][%s][%s]\x20Contact\x20not\x20found','data4','[CM][%s][%s]\x20Autocreate\x20enabled','calleridnum','routeId','<unknown>','calleridname','Unknown','destcalleridname','push','[CM][%s][%s]\x20Contact\x20created:%s','[CM][%s][%s]\x20Autocreate\x20disabled','destcalleridnum','format','user:%s','trigger:%s','action','toLowerCase','merge','ioredis','util','../../../../config/logger','../../rpc/cmContact','redis','defaults','localhost','socket.io-emitter','info','[CM][%s][%s]','emit','exec','data1','data2','isNil'];(function(_0x16ca8b,_0x551ee8){var _0x123101=function(_0x33f34f){while(--_0x33f34f){_0x16ca8b['push'](_0x16ca8b['shift']());}};_0x123101(++_0x551ee8);}(_0x7bae,0x13b));var _0xe7ba=function(_0x2cf2e9,_0xd58ea1){_0x2cf2e9=_0x2cf2e9-0x0;var _0xd3670d=_0x7bae[_0x2cf2e9];return _0xd3670d;};'use strict';var _=require('lodash');var BPromise=require('bluebird');var Redis=require(_0xe7ba('0x0'));var util=require(_0xe7ba('0x1'));var config=require('../../../../config/environment');var logger=require(_0xe7ba('0x2'))('trigger');var cmContactRpc=require(_0xe7ba('0x3'));config[_0xe7ba('0x4')]=_[_0xe7ba('0x5')](config[_0xe7ba('0x4')],{'host':_0xe7ba('0x6'),'port':0x18eb});var io=require(_0xe7ba('0x7'))(new Redis(config[_0xe7ba('0x4')]));function emit(_0x3c5e59,_0x10b307,_0x34fb18,_0x160565,_0x27b1d5){logger[_0xe7ba('0x8')](_0xe7ba('0x9'),_0x3c5e59,_0x10b307['id'],_0x34fb18,_0x160565,JSON['stringify'](_0x27b1d5));io['to'](_0x34fb18)[_0xe7ba('0xa')](_0x160565,_0x27b1d5);}exports[_0xe7ba('0xb')]=function(_0x375ebb,_0x276bc3,_0x15083a,_0x1672f0){var _0x99a86f,_0x448bcc;var _0x194447={};var _0x4b6597=Number(_0x15083a[_0xe7ba('0xc')]);var _0x588c8b=_0x15083a[_0xe7ba('0xd')]?Boolean(Number(_0x15083a[_0xe7ba('0xd')])):![];var _0x390596;var _0x17e4e6=![];if(!_[_0xe7ba('0xe')](_0x15083a[_0xe7ba('0xf')])){if(_0x15083a['data5']=='1')_0x17e4e6=!![];}if(!_0x17e4e6){if(_0x1672f0['xmd-contactid']){_0x194447['id']=_0x1672f0[_0xe7ba('0x10')];}}if(!_0x194447['id']){_0x194447[_0xe7ba('0x11')]=_0x4b6597;_0x390596=_0x15083a[_0xe7ba('0x12')]&&_0x15083a['data3']!=='0'?_0x15083a[_0xe7ba('0x12')]['split'](','):['phone'];_0x194447['$or']=_[_0xe7ba('0x13')](_0x390596,function(_0x4e87f5){var _0x41a773={};_0x41a773[_0x4e87f5]=_0x1672f0['routeId']?_0x1672f0['destcalleridnum']:_0x1672f0['calleridnum'];return _0x41a773;});}var _0x3f326a=['id',_0xe7ba('0x14'),_0xe7ba('0x15'),_0xe7ba('0x16'),_0xe7ba('0x17'),'fax',_0xe7ba('0x11'),_0xe7ba('0x18'),_0xe7ba('0x19'),_0xe7ba('0x1a')];var _0x4aaf35=_[_0xe7ba('0x1b')](_0x3f326a,_0x390596);BPromise[_0xe7ba('0x1c')]()['then'](cmContactRpc[_0xe7ba('0x1d')]({'attributes':_0x4aaf35,'where':_0x194447}))[_0xe7ba('0x1e')](function(_0x27c882){_0x448bcc=_0x27c882;if(!_[_0xe7ba('0x1f')](_0x448bcc)){if(_0x448bcc[_0xe7ba('0x20')]===0x1){_0x99a86f=_0x448bcc[0x0];logger[_0xe7ba('0x8')](_0xe7ba('0x21'),_0x1672f0[_0xe7ba('0x22')],_0x276bc3['id'],_0x99a86f['id']);}else{logger[_0xe7ba('0x8')](_0xe7ba('0x23'),_0x1672f0['uniqueid'],_0x276bc3['id'],_['map'](_0x448bcc,'id')['join'](','));}return;}else{logger['info'](_0xe7ba('0x24'),_0x1672f0['uniqueid'],_0x276bc3['id']);var _0x4ecc0d={'ListId':_0x4b6597};var _0x5ece11=_0x15083a[_0xe7ba('0x25')]&&_0x15083a[_0xe7ba('0x25')]!=='0'?_0x15083a[_0xe7ba('0x25')]:_0xe7ba('0x16');if(_0x588c8b){logger[_0xe7ba('0x8')](_0xe7ba('0x26'),_0x1672f0[_0xe7ba('0x22')],_0x276bc3['id']);_0x4ecc0d[_0x5ece11]=_[_0xe7ba('0xe')](_0x1672f0['routeId'])?_0x1672f0[_0xe7ba('0x27')]:_0x1672f0['destcalleridnum'];if(_[_0xe7ba('0xe')](_0x1672f0[_0xe7ba('0x28')])){_0x4ecc0d[_0xe7ba('0x14')]=_0x1672f0['calleridname']&&_0x1672f0['calleridname']!==_0xe7ba('0x29')?_0x1672f0[_0xe7ba('0x2a')]:_0xe7ba('0x2b');}else{_0x4ecc0d[_0xe7ba('0x14')]=_0x1672f0[_0xe7ba('0x2c')]&&_0x1672f0['destcalleridname']!==_0xe7ba('0x29')?_0x1672f0[_0xe7ba('0x2c')]:'Unknown';}return BPromise[_0xe7ba('0x1c')]()['then'](cmContactRpc['createContact'](_0x4ecc0d))[_0xe7ba('0x1e')](function(_0x134f21){_0x99a86f=_0x134f21;_0x448bcc[_0xe7ba('0x2d')](_0x134f21);if(_0x99a86f){logger['info'](_0xe7ba('0x2e'),_0x1672f0['uniqueid'],_0x276bc3['id'],_0x99a86f['id']);}return;});}else{logger[_0xe7ba('0x8')](_0xe7ba('0x2f'),_0x1672f0[_0xe7ba('0x22')],_0x276bc3['id']);_0x4ecc0d[_0x5ece11]=_[_0xe7ba('0xe')](_0x1672f0[_0xe7ba('0x28')])?_0x1672f0['calleridnum']:_0x1672f0[_0xe7ba('0x30')];if(_[_0xe7ba('0xe')](_0x1672f0['routeId'])){_0x4ecc0d[_0xe7ba('0x14')]=_0x1672f0[_0xe7ba('0x2a')]&&_0x1672f0[_0xe7ba('0x2a')]!=='<unknown>'?_0x1672f0[_0xe7ba('0x2a')]:_0xe7ba('0x2b');}else{_0x4ecc0d['firstName']=_0x1672f0[_0xe7ba('0x2c')]&&_0x1672f0[_0xe7ba('0x2c')]!==_0xe7ba('0x29')?_0x1672f0['destcalleridname']:_0xe7ba('0x2b');}_0x99a86f=_0x4ecc0d;_0x448bcc[_0xe7ba('0x2d')](_0x4ecc0d);return;}}})['then'](function(){if(_0x375ebb){emit(_0x1672f0[_0xe7ba('0x22')],_0x276bc3,util[_0xe7ba('0x31')](_0xe7ba('0x32'),_0x375ebb['name']),util['format'](_0xe7ba('0x33'),_0x15083a[_0xe7ba('0x34')][_0xe7ba('0x35')]()),{'evt':_[_0xe7ba('0x36')](_0x1672f0,{'autoCreate':_0x588c8b}),'contact':_0x99a86f===undefined?{}:_0x99a86f,'contacts':_0x448bcc[_0xe7ba('0x20')]===0x0?undefined:_0x448bcc});}});};
\ No newline at end of file
+var _0xb903=['data1','data2','data5','xmd-contactid','data3','split','phone','destcalleridnum','calleridnum','firstName','fax','ListId','scheduledAt','updatedAt','union','resolve','then','getContacts','isEmpty','[CM][%s][%s]\x20Contact\x20found:%s','uniqueid','[CM][%s][%s]\x20Multiple\x20contacts\x20found:[%s]','[CM][%s][%s]\x20Contact\x20not\x20found','data4','[CM][%s][%s]\x20Autocreate\x20enabled','isNil','routeId','calleridname','<unknown>','Unknown','destcalleridname','push','user:%s','format','trigger:%s','action','toLowerCase','merge','length','lodash','bluebird','ioredis','util','../../../../config/logger','trigger','../../rpc/cmContact','redis','defaults','localhost','info'];(function(_0x2162e2,_0x1f8da5){var _0x493bd1=function(_0x3ccccc){while(--_0x3ccccc){_0x2162e2['push'](_0x2162e2['shift']());}};_0x493bd1(++_0x1f8da5);}(_0xb903,0x185));var _0x3b90=function(_0x2e2450,_0x30df16){_0x2e2450=_0x2e2450-0x0;var _0x3cedc3=_0xb903[_0x2e2450];return _0x3cedc3;};'use strict';var _=require(_0x3b90('0x0'));var BPromise=require(_0x3b90('0x1'));var Redis=require(_0x3b90('0x2'));var util=require(_0x3b90('0x3'));var config=require('../../../../config/environment');var logger=require(_0x3b90('0x4'))(_0x3b90('0x5'));var cmContactRpc=require(_0x3b90('0x6'));config[_0x3b90('0x7')]=_[_0x3b90('0x8')](config[_0x3b90('0x7')],{'host':_0x3b90('0x9'),'port':0x18eb});var io=require('socket.io-emitter')(new Redis(config[_0x3b90('0x7')]));function emit(_0x5e845a,_0x55792c,_0x153283,_0x2e4c06,_0x42efe8){logger[_0x3b90('0xa')]('[CM][%s][%s]',_0x5e845a,_0x55792c['id'],_0x153283,_0x2e4c06,JSON['stringify'](_0x42efe8));io['to'](_0x153283)['emit'](_0x2e4c06,_0x42efe8);}exports['exec']=function(_0x56261b,_0x55db3f,_0x336913,_0x5af39c){var _0x574955,_0x30c49c;var _0x233509={};var _0x4bb8f4=Number(_0x336913[_0x3b90('0xb')]);var _0x174c0d=_0x336913[_0x3b90('0xc')]?Boolean(Number(_0x336913['data2'])):![];var _0x5447df;var _0x58c4d1=![];if(!_['isNil'](_0x336913['data5'])){if(_0x336913[_0x3b90('0xd')]=='1')_0x58c4d1=!![];}if(!_0x58c4d1){if(_0x5af39c[_0x3b90('0xe')]){_0x233509['id']=_0x5af39c['xmd-contactid'];}}if(!_0x233509['id']){_0x233509['ListId']=_0x4bb8f4;_0x5447df=_0x336913[_0x3b90('0xf')]&&_0x336913[_0x3b90('0xf')]!=='0'?_0x336913[_0x3b90('0xf')][_0x3b90('0x10')](','):[_0x3b90('0x11')];_0x233509['$or']=_['map'](_0x5447df,function(_0xd83280){var _0x5420dc={};_0x5420dc[_0xd83280]=_0x5af39c['routeId']?_0x5af39c[_0x3b90('0x12')]:_0x5af39c[_0x3b90('0x13')];return _0x5420dc;});}var _0x11ad7d=['id',_0x3b90('0x14'),'lastName',_0x3b90('0x11'),'mobile',_0x3b90('0x15'),_0x3b90('0x16'),'createdAt',_0x3b90('0x17'),_0x3b90('0x18')];var _0x3642c0=_[_0x3b90('0x19')](_0x11ad7d,_0x5447df);BPromise[_0x3b90('0x1a')]()[_0x3b90('0x1b')](cmContactRpc[_0x3b90('0x1c')]({'attributes':_0x3642c0,'where':_0x233509}))[_0x3b90('0x1b')](function(_0xa98414){_0x30c49c=_0xa98414;if(!_[_0x3b90('0x1d')](_0x30c49c)){if(_0x30c49c['length']===0x1){_0x574955=_0x30c49c[0x0];logger[_0x3b90('0xa')](_0x3b90('0x1e'),_0x5af39c[_0x3b90('0x1f')],_0x55db3f['id'],_0x574955['id']);}else{logger[_0x3b90('0xa')](_0x3b90('0x20'),_0x5af39c[_0x3b90('0x1f')],_0x55db3f['id'],_['map'](_0x30c49c,'id')['join'](','));}return;}else{logger[_0x3b90('0xa')](_0x3b90('0x21'),_0x5af39c[_0x3b90('0x1f')],_0x55db3f['id']);var _0x2ffa1a={'ListId':_0x4bb8f4};var _0x583523=_0x336913[_0x3b90('0x22')]&&_0x336913[_0x3b90('0x22')]!=='0'?_0x336913[_0x3b90('0x22')]:'phone';if(_0x174c0d){logger[_0x3b90('0xa')](_0x3b90('0x23'),_0x5af39c[_0x3b90('0x1f')],_0x55db3f['id']);_0x2ffa1a[_0x583523]=_[_0x3b90('0x24')](_0x5af39c[_0x3b90('0x25')])?_0x5af39c[_0x3b90('0x13')]:_0x5af39c['destcalleridnum'];if(_[_0x3b90('0x24')](_0x5af39c['routeId'])){_0x2ffa1a[_0x3b90('0x14')]=_0x5af39c[_0x3b90('0x26')]&&_0x5af39c[_0x3b90('0x26')]!==_0x3b90('0x27')?_0x5af39c[_0x3b90('0x26')]:_0x3b90('0x28');}else{_0x2ffa1a[_0x3b90('0x14')]=_0x5af39c[_0x3b90('0x29')]&&_0x5af39c['destcalleridname']!=='<unknown>'?_0x5af39c[_0x3b90('0x29')]:_0x3b90('0x28');}return BPromise[_0x3b90('0x1a')]()[_0x3b90('0x1b')](cmContactRpc['createContact'](_0x2ffa1a))['then'](function(_0xd33ac9){_0x574955=_0xd33ac9;_0x30c49c[_0x3b90('0x2a')](_0xd33ac9);if(_0x574955){logger[_0x3b90('0xa')]('[CM][%s][%s]\x20Contact\x20created:%s',_0x5af39c[_0x3b90('0x1f')],_0x55db3f['id'],_0x574955['id']);}return;});}else{logger['info']('[CM][%s][%s]\x20Autocreate\x20disabled',_0x5af39c[_0x3b90('0x1f')],_0x55db3f['id']);_0x2ffa1a[_0x583523]=_[_0x3b90('0x24')](_0x5af39c['routeId'])?_0x5af39c[_0x3b90('0x13')]:_0x5af39c[_0x3b90('0x12')];if(_[_0x3b90('0x24')](_0x5af39c['routeId'])){_0x2ffa1a['firstName']=_0x5af39c[_0x3b90('0x26')]&&_0x5af39c[_0x3b90('0x26')]!==_0x3b90('0x27')?_0x5af39c[_0x3b90('0x26')]:'Unknown';}else{_0x2ffa1a['firstName']=_0x5af39c[_0x3b90('0x29')]&&_0x5af39c[_0x3b90('0x29')]!=='<unknown>'?_0x5af39c['destcalleridname']:_0x3b90('0x28');}_0x574955=_0x2ffa1a;_0x30c49c[_0x3b90('0x2a')](_0x2ffa1a);return;}}})[_0x3b90('0x1b')](function(){if(_0x56261b){emit(_0x5af39c[_0x3b90('0x1f')],_0x55db3f,util['format'](_0x3b90('0x2b'),_0x56261b['name']),util[_0x3b90('0x2c')](_0x3b90('0x2d'),_0x336913[_0x3b90('0x2e')][_0x3b90('0x2f')]()),{'evt':_[_0x3b90('0x30')](_0x5af39c,{'autoCreate':_0x174c0d}),'contact':_0x574955===undefined?{}:_0x574955,'contacts':_0x30c49c[_0x3b90('0x31')]===0x0?undefined:_0x30c49c});}});};
\ No newline at end of file