Built motion from commit 00bf23f6.|2.6.16
[motion2.git] / server / api / cmContact / cmContact.model.js
index 765ba3f..8e96341 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x231f=['cmContact,\x20%s,\x20%s','List\x20not\x20found','models','isEmpty','destroy','ContactId','VoiceQueueId','CampaignId','push','all','info','[CmContact][afterDestroy][Succesfull]','[CmContact][afterDestroy][Error]','lodash','util','../../config/logger','moment','bluebird','request-promise','path','../../config/environment','./cmContact.attributes','exports','define','CmContact','cm_contacts','phone','fti_cm_contacts','firstName','lastName','mobile','fax','email','FULLTEXT','utf8mb4','utf8mb4_unicode_ci','error','cmContact','afterCreate','inspect','scheduledat','format','YYYY-MM-DD\x20HH:mm:ss','isNil','dialTimezone','VoiceQueue','then','utcOffset','add','ret','CmHopper','findOne','cmContact,\x20afterCreate\x20','\x20contact\x20not\x20insert\x20in\x20hopper,\x20check\x20duplicate\x20onlyIfOpen,\x20exist\x20in\x20hopper\x20VoiceQueue\x20','create','ListId','priority','callbackUniqueid','catch','\x20contact\x20not\x20insert\x20in\x20hopper,\x20check\x20duplicate\x20always,\x20exist\x20in\x20hopper\x20VoiceQueue\x20','CmHopperFinal','\x20contact\x20not\x20insert\x20in\x20hopper,\x20check\x20duplicate\x20always,\x20exist\x20in\x20hopperFinal\x20VoiceQueue\x20','Campaign','timezones','minutes','\x20contact\x20not\x20insert\x20in\x20hopper,\x20check\x20duplicate\x20always,\x20exist\x20in\x20hopper\x20Campaign\x20','cmContact,\x20afterCreate,\x20','\x20contact\x20not\x20insert\x20in\x20hopper,\x20check\x20duplicate\x20always,\x20exist\x20in\x20hopperFinal\x20Campaign\x20','findAll','CmList','Lists','length','get','dialCheckDuplicateType','always','onlyIfOpen','outbound','CmHopperBlack','message','BlackLists'];(function(_0x2847ec,_0x40ce19){var _0x507988=function(_0x3545a1){while(--_0x3545a1){_0x2847ec['push'](_0x2847ec['shift']());}};_0x507988(++_0x40ce19);}(_0x231f,0xad));var _0xf231=function(_0x57d7b3,_0x5407a4){_0x57d7b3=_0x57d7b3-0x0;var _0x3fb442=_0x231f[_0x57d7b3];return _0x3fb442;};'use strict';var _=require(_0xf231('0x0'));var util=require(_0xf231('0x1'));var logger=require(_0xf231('0x2'))('api');var moment=require(_0xf231('0x3'));var BPromise=require(_0xf231('0x4'));var rp=require(_0xf231('0x5'));var fs=require('fs');var path=require(_0xf231('0x6'));var rimraf=require('rimraf');var config=require(_0xf231('0x7'));var shared=require('../../config/environment/shared');var attributes=require(_0xf231('0x8'));module[_0xf231('0x9')]=function(_0x384a22,_0x3ef48f){return _0x384a22[_0xf231('0xa')](_0xf231('0xb'),attributes,{'tableName':_0xf231('0xc'),'paranoid':!![],'indexes':[{'name':_0xf231('0xd'),'fields':[_0xf231('0xd')]},{'name':_0xf231('0xe'),'fields':[_0xf231('0xf'),_0xf231('0x10'),_0xf231('0xd'),_0xf231('0x11'),_0xf231('0x12'),_0xf231('0x13')],'type':_0xf231('0x14')}],'timestamps':!![],'charset':_0xf231('0x15'),'collate':_0xf231('0x16'),'hooks':{'afterCreate':function(_0x461a37,_0x520c53,_0x22449b){var _0x3d826c=_0x384a22['models'];var _0x512972=_0x461a37['get']({'plain':!![]});function _0x376c5a(){return function(_0x3e26f8){logger[_0xf231('0x17')](_0xf231('0x18'),_0xf231('0x19'),util[_0xf231('0x1a')](_0x3e26f8,{'showHidden':![],'depth':null}));};}function _0x226020(_0x1bcc79,_0x105ffb){var _0x35c9f2=_0x105ffb[_0xf231('0x1b')]?_0x105ffb['scheduledat']:moment()[_0xf231('0x1c')](_0xf231('0x1d'));return new BPromise(function(_0x4a242a,_0x5487e5){if(_[_0xf231('0x1e')](_0x105ffb[_0xf231('0x1f')])){_0x4a242a({'ret':_0x35c9f2});}else{_0x3d826c[_0xf231('0x20')]['findOne']({'where':{'id':_0x1bcc79['id']}})[_0xf231('0x21')](function(_0x261cec){if(!_[_0xf231('0x1e')](_0x261cec)){var _0x698ecf=_0x261cec[_0xf231('0x1f')];if(!_[_0xf231('0x1e')](_0x698ecf)){var _0x5cdcf6=shared['timezones'];var _0x24f7c5=_0x5cdcf6[_0x698ecf];var _0x404b52=_0x5cdcf6[_0x105ffb['dialTimezone']];if(!_['isNil'](_0x24f7c5)&&!_[_0xf231('0x1e')](_0x404b52)){var _0x38933f=_0x24f7c5[_0xf231('0x22')]-_0x404b52['utcOffset'];_0x35c9f2=_0x105ffb[_0xf231('0x1b')]?_0x105ffb['scheduledat']:moment();var _0x242907=moment(_0x35c9f2)[_0xf231('0x23')](_0x38933f,'minutes');_0x4a242a({'ret':_0x242907[_0xf231('0x1c')](_0xf231('0x1d'))});}else _0x4a242a({'ret':_0x35c9f2});}else _0x4a242a({'ret':_0x35c9f2});}else{_0x4a242a({'ret':_0x35c9f2});}});}});return 0xa;}var _0x189660=function(_0xdb4398){return new BPromise(function(_0x2e1ae8,_0x1d615f){_0x226020(_0xdb4398,_0x512972)['then'](function(_0x5a6fd8){_0x512972[_0xf231('0x1b')]=_0x5a6fd8[_0xf231('0x24')];_0x3d826c[_0xf231('0x25')][_0xf231('0x26')]({'where':{'phone':_0x512972[_0xf231('0xd')],'VoiceQueueId':_0xdb4398['id']}})[_0xf231('0x21')](function(_0x3b3f0c){if(!_[_0xf231('0x1e')](_0x3b3f0c)){throw new Error(_0xf231('0x27')+_0x512972['phone']+_0xf231('0x28')+_0xdb4398['id']);}return _0x3d826c['CmHopper'][_0xf231('0x29')]({'phone':_0x512972[_0xf231('0xd')],'ContactId':_0x512972['id'],'ListId':_0x512972[_0xf231('0x2a')],'priority':_0x512972['priority']?_0x512972[_0xf231('0x2b')]:0x2,'scheduledat':_0x512972[_0xf231('0x1b')]?_0x512972[_0xf231('0x1b')]:moment()[_0xf231('0x1c')](_0xf231('0x1d')),'callback':_0x512972[_0xf231('0x2c')]?!![]:![],'callbackuniqueid':_0x512972[_0xf231('0x2c')]?_0x512972[_0xf231('0x2c')]:undefined,'callbackat':_0x512972[_0xf231('0x2c')]?moment()['format'](_0xf231('0x1d')):undefined,'VoiceQueueId':_0xdb4398['id']});})[_0xf231('0x2d')](function(_0x5a2e18){_0x1d615f(_0x5a2e18);});});});};var _0x29a224=function(_0x5e99ba){return new BPromise(function(_0x247c5e,_0x49ede1){_0x226020(_0x5e99ba,_0x512972)['then'](function(_0x5251be){_0x512972['scheduledat']=_0x5251be[_0xf231('0x24')];_0x3d826c['CmHopper'][_0xf231('0x26')]({'where':{'phone':_0x512972[_0xf231('0xd')],'VoiceQueueId':_0x5e99ba['id']}})['then'](function(_0x1ebdc2){if(!_[_0xf231('0x1e')](_0x1ebdc2)){throw new Error(_0xf231('0x27')+_0x512972[_0xf231('0xd')]+_0xf231('0x2e')+_0x5e99ba['id']);}return _0x3d826c[_0xf231('0x2f')][_0xf231('0x26')]({'where':{'calleridnum':_0x512972[_0xf231('0xd')],'VoiceQueueId':_0x5e99ba['id']}});})['then'](function(_0x29e16a){if(!_[_0xf231('0x1e')](_0x29e16a)){throw new Error('cmContact,\x20afterCreate,\x20'+_0x512972['phone']+_0xf231('0x30')+_0x5e99ba['id']);}return _0x3d826c[_0xf231('0x25')][_0xf231('0x29')]({'phone':_0x512972[_0xf231('0xd')],'ContactId':_0x512972['id'],'ListId':_0x512972[_0xf231('0x2a')],'priority':_0x512972['priority']?_0x512972[_0xf231('0x2b')]:0x2,'scheduledat':_0x512972['scheduledat']?_0x512972[_0xf231('0x1b')]:moment()[_0xf231('0x1c')](_0xf231('0x1d')),'callback':_0x512972[_0xf231('0x2c')]?!![]:![],'callbackuniqueid':_0x512972[_0xf231('0x2c')]?_0x512972[_0xf231('0x2c')]:undefined,'callbackat':_0x512972[_0xf231('0x2c')]?moment()[_0xf231('0x1c')]('YYYY-MM-DD\x20HH:mm:ss'):undefined,'VoiceQueueId':_0x5e99ba['id']});})[_0xf231('0x2d')](function(_0x14605c){_0x49ede1(_0x14605c);});});});};function _0x305cf7(){return function(_0x3003cd){logger[_0xf231('0x17')](_0xf231('0x18'),_0xf231('0x19'),util[_0xf231('0x1a')](_0x3003cd,{'showHidden':![],'depth':null}));};}function _0x38ad37(_0x5eb1c3,_0x55c940){var _0x247bff=_0x55c940[_0xf231('0x1b')]?_0x55c940[_0xf231('0x1b')]:moment()['format'](_0xf231('0x1d'));return new BPromise(function(_0x4e4ba4,_0x20b4b9){if(_[_0xf231('0x1e')](_0x55c940[_0xf231('0x1f')])){_0x4e4ba4({'ret':_0x247bff});}else{_0x3d826c[_0xf231('0x31')][_0xf231('0x26')]({'where':{'id':_0x5eb1c3['id']}})['then'](function(_0x344836){if(!_[_0xf231('0x1e')](_0x344836)){var _0x4cd665=_0x344836['dialTimezone'];if(!_[_0xf231('0x1e')](_0x4cd665)){var _0x2d811a=shared[_0xf231('0x32')];var _0x4a8b4a=_0x2d811a[_0x4cd665];var _0x1e375b=_0x2d811a[_0x55c940[_0xf231('0x1f')]];if(!_[_0xf231('0x1e')](_0x4a8b4a)&&!_[_0xf231('0x1e')](_0x1e375b)){var _0x4fae4e=_0x4a8b4a[_0xf231('0x22')]-_0x1e375b[_0xf231('0x22')];_0x247bff=_0x55c940[_0xf231('0x1b')]?_0x55c940[_0xf231('0x1b')]:moment();var _0x3fc96f=moment(_0x247bff)[_0xf231('0x23')](_0x4fae4e,_0xf231('0x33'));_0x4e4ba4({'ret':_0x3fc96f[_0xf231('0x1c')]('YYYY-MM-DD\x20HH:mm:ss')});}else _0x4e4ba4({'ret':_0x247bff});}else _0x4e4ba4({'ret':_0x247bff});}else{_0x4e4ba4({'ret':_0x247bff});}});}});return 0xa;}var _0xb9c748=function(_0x10ef4b){return new BPromise(function(_0x56582b,_0x27fa38){_0x38ad37(_0x10ef4b,_0x512972)['then'](function(_0xb0bdcd){_0x512972[_0xf231('0x1b')]=_0xb0bdcd[_0xf231('0x24')];_0x3d826c[_0xf231('0x25')][_0xf231('0x26')]({'where':{'phone':_0x512972[_0xf231('0xd')],'CampaignId':_0x10ef4b['id']}})[_0xf231('0x21')](function(_0x55237c){if(!_[_0xf231('0x1e')](_0x55237c)){throw new Error(_0xf231('0x27')+_0x512972['phone']+'\x20contact\x20not\x20insert\x20in\x20hopper,\x20check\x20duplicate\x20onlyIfOpen,\x20exist\x20in\x20hopper\x20Campaign\x20'+_0x10ef4b['id']);}return _0x3d826c[_0xf231('0x25')][_0xf231('0x29')]({'phone':_0x512972[_0xf231('0xd')],'ContactId':_0x512972['id'],'ListId':_0x512972['ListId'],'priority':_0x512972[_0xf231('0x2b')]?_0x512972[_0xf231('0x2b')]:0x2,'scheduledat':_0x512972[_0xf231('0x1b')]?_0x512972[_0xf231('0x1b')]:moment()[_0xf231('0x1c')](_0xf231('0x1d')),'callback':_0x512972[_0xf231('0x2c')]?!![]:![],'callbackuniqueid':_0x512972[_0xf231('0x2c')]?_0x512972[_0xf231('0x2c')]:undefined,'callbackat':_0x512972[_0xf231('0x2c')]?moment()[_0xf231('0x1c')]('YYYY-MM-DD\x20HH:mm:ss'):undefined,'CampaignId':_0x10ef4b['id']});})['catch'](function(_0x2cebb2){_0x27fa38(_0x2cebb2);});});});};var _0x3a3dcd=function(_0x33357b){return new BPromise(function(_0x1b235a,_0x3e7f3a){_0x38ad37(_0x33357b,_0x512972)[_0xf231('0x21')](function(_0x4d6c63){_0x512972['scheduledat']=_0x4d6c63[_0xf231('0x24')];_0x3d826c[_0xf231('0x25')][_0xf231('0x26')]({'where':{'phone':_0x512972[_0xf231('0xd')],'CampaignId':_0x33357b['id']}})['then'](function(_0x52880f){if(!_[_0xf231('0x1e')](_0x52880f)){throw new Error('cmContact,\x20afterCreate\x20'+_0x512972[_0xf231('0xd')]+_0xf231('0x34')+_0x33357b['id']);}return _0x3d826c[_0xf231('0x2f')][_0xf231('0x26')]({'where':{'calleridnum':_0x512972[_0xf231('0xd')],'CampaignId':_0x33357b['id']}});})[_0xf231('0x21')](function(_0x254971){if(!_[_0xf231('0x1e')](_0x254971)){throw new Error(_0xf231('0x35')+_0x512972[_0xf231('0xd')]+_0xf231('0x36')+_0x33357b['id']);}return _0x3d826c[_0xf231('0x25')][_0xf231('0x29')]({'phone':_0x512972[_0xf231('0xd')],'ContactId':_0x512972['id'],'ListId':_0x512972['ListId'],'priority':_0x512972['priority']?_0x512972[_0xf231('0x2b')]:0x2,'scheduledat':_0x512972['scheduledat']?_0x512972['scheduledat']:moment()['format'](_0xf231('0x1d')),'callback':_0x512972[_0xf231('0x2c')]?!![]:![],'callbackuniqueid':_0x512972[_0xf231('0x2c')]?_0x512972[_0xf231('0x2c')]:undefined,'callbackat':_0x512972[_0xf231('0x2c')]?moment()[_0xf231('0x1c')](_0xf231('0x1d')):undefined,'CampaignId':_0x33357b['id']});})[_0xf231('0x2d')](function(_0x1e0488){_0x3e7f3a(_0x1e0488);});});});};if(_0x512972['ListId']){_0x3d826c['VoiceQueue'][_0xf231('0x37')]({'where':{'type':'outbound'},'attributes':['id','dialCheckDuplicateType',_0xf231('0x1f')],'include':[{'model':_0x3d826c[_0xf231('0x38')],'as':_0xf231('0x39'),'where':{'id':_0x512972[_0xf231('0x2a')]}}]})[_0xf231('0x21')](function(_0x251100){if(_0x251100){var _0x173908=[];for(var _0x1fc08a=0x0,_0x4a76aa;_0x1fc08a<_0x251100[_0xf231('0x3a')];_0x1fc08a+=0x1){_0x4a76aa=_0x251100[_0x1fc08a][_0xf231('0x3b')]({'plain':!![]});switch(_0x4a76aa[_0xf231('0x3c')]){case _0xf231('0x3d'):_0x29a224(_0x4a76aa)['catch'](_0x376c5a());break;case _0xf231('0x3e'):_0x189660(_0x4a76aa)[_0xf231('0x2d')](_0x376c5a());break;default:_0x38ad37(_0x4a76aa,_0x512972)[_0xf231('0x21')](function(_0x337e8c){_0x512972[_0xf231('0x1b')]=_0x337e8c['ret'];_0x3d826c[_0xf231('0x25')]['create']({'phone':_0x512972[_0xf231('0xd')],'ContactId':_0x512972['id'],'ListId':_0x512972[_0xf231('0x2a')],'scheduledat':_0x512972[_0xf231('0x1b')]?_0x512972[_0xf231('0x1b')]:moment()[_0xf231('0x1c')](_0xf231('0x1d')),'priority':_0x512972[_0xf231('0x2b')]?_0x512972[_0xf231('0x2b')]:0x2,'callback':_0x512972[_0xf231('0x2c')]?!![]:![],'callbackuniqueid':_0x512972[_0xf231('0x2c')]?_0x512972['callbackUniqueid']:undefined,'callbackat':_0x512972[_0xf231('0x2c')]?moment()[_0xf231('0x1c')]('YYYY-MM-DD\x20HH:mm:ss'):undefined,'VoiceQueueId':_0x4a76aa['id']})[_0xf231('0x2d')](_0x376c5a());});}}}})[_0xf231('0x21')](function(){return _0x3d826c['VoiceQueue'][_0xf231('0x37')]({'where':{'type':_0xf231('0x3f')},'attributes':['id'],'include':[{'model':_0x3d826c['CmList'],'as':'BlackLists','where':{'id':_0x512972[_0xf231('0x2a')]}}]})['then'](function(_0x41749e){if(_0x41749e){var _0x3fd0a7=[];for(var _0x5b3cb0=0x0,_0x46aa2c;_0x5b3cb0<_0x41749e['length'];_0x5b3cb0+=0x1){_0x46aa2c=_0x41749e[_0x5b3cb0][_0xf231('0x3b')]({'plain':!![]});_0x3d826c[_0xf231('0x40')]['create']({'phone':_0x512972[_0xf231('0xd')],'ContactId':_0x512972['id'],'ListId':_0x512972['ListId'],'VoiceQueueId':_0x46aa2c['id']})['catch'](function(_0x5350fa){logger[_0xf231('0x17')]('cmContact,\x20%s,\x20%s',_0xf231('0x19'),_0x5350fa[_0xf231('0x41')]);});}}});})[_0xf231('0x21')](function(){return _0x3d826c[_0xf231('0x31')][_0xf231('0x37')]({'attributes':['id','dialCheckDuplicateType',_0xf231('0x1f')],'include':[{'model':_0x3d826c['CmList'],'as':_0xf231('0x39'),'where':{'id':_0x512972[_0xf231('0x2a')]}}]})[_0xf231('0x21')](function(_0x3df03c){if(_0x3df03c){var _0x419c2b=[];for(var _0x549c67=0x0,_0x5448bf;_0x549c67<_0x3df03c[_0xf231('0x3a')];_0x549c67+=0x1){_0x5448bf=_0x3df03c[_0x549c67][_0xf231('0x3b')]({'plain':!![]});switch(_0x5448bf[_0xf231('0x3c')]){case _0xf231('0x3d'):_0x3a3dcd(_0x5448bf)[_0xf231('0x2d')](_0x305cf7());break;case'onlyIfOpen':_0xb9c748(_0x5448bf)[_0xf231('0x2d')](_0x305cf7());break;default:_0x3d826c['CmHopper'][_0xf231('0x29')]({'phone':_0x512972['phone'],'ContactId':_0x512972['id'],'ListId':_0x512972[_0xf231('0x2a')],'scheduledat':_0x512972[_0xf231('0x1b')]?_0x512972[_0xf231('0x1b')]:moment()[_0xf231('0x1c')](_0xf231('0x1d')),'priority':_0x512972[_0xf231('0x2b')]?_0x512972[_0xf231('0x2b')]:0x2,'callback':_0x512972[_0xf231('0x2c')]?!![]:![],'callbackuniqueid':_0x512972['callbackUniqueid']?_0x512972[_0xf231('0x2c')]:undefined,'callbackat':_0x512972[_0xf231('0x2c')]?moment()[_0xf231('0x1c')](_0xf231('0x1d')):undefined,'CampaignId':_0x5448bf['id']})[_0xf231('0x2d')](_0x305cf7());}}}});})[_0xf231('0x21')](function(){return _0x3d826c['Campaign']['findAll']({'attributes':['id'],'include':[{'model':_0x3d826c[_0xf231('0x38')],'as':_0xf231('0x42'),'where':{'id':_0x512972[_0xf231('0x2a')]}}]})[_0xf231('0x21')](function(_0x911f8f){if(_0x911f8f){var _0x4b24fe=[];for(var _0x373148=0x0,_0x5e671d;_0x373148<_0x911f8f[_0xf231('0x3a')];_0x373148+=0x1){_0x5e671d=_0x911f8f[_0x373148]['get']({'plain':!![]});_0x3d826c[_0xf231('0x40')][_0xf231('0x29')]({'phone':_0x512972[_0xf231('0xd')],'ContactId':_0x512972['id'],'ListId':_0x512972['ListId'],'CampaignId':_0x5e671d['id']})['catch'](function(_0x2a822f){logger[_0xf231('0x17')](_0xf231('0x43'),'afterCreate',_0x2a822f[_0xf231('0x41')]);});}}});})['then'](function(){_0x22449b();})[_0xf231('0x2d')](function(_0x14ec29){logger[_0xf231('0x17')](_0xf231('0x43'),_0xf231('0x19'),_0x14ec29[_0xf231('0x41')]);_0x22449b(_0x14ec29);});}else{_0x22449b(new Error(_0xf231('0x44')));}},'afterDestroy':function(_0x16668a,_0x20f8da,_0x489395){var _0x43419f=_0x384a22[_0xf231('0x45')];var _0xdf1efd=_0x16668a['get']({'plain':!![]});return _0x43419f[_0xf231('0x25')]['findAll']({'raw':!![],'where':{'ListId':_0xdf1efd[_0xf231('0x2a')],'ContactId':_0xdf1efd['id']}})[_0xf231('0x21')](function(_0xf4525b){if(!_[_0xf231('0x46')](_0xf4525b)){var _0x5ddfe0=[];for(var _0xfddd2e=0x0;_0xfddd2e<_0xf4525b[_0xf231('0x3a')];_0xfddd2e+=0x1){var _0xcbe686=_0x43419f[_0xf231('0x25')][_0xf231('0x47')]({'where':{'ListId':_0xf4525b[_0xfddd2e][_0xf231('0x2a')],'ContactId':_0xf4525b[_0xfddd2e][_0xf231('0x48')],'VoiceQueueId':_0xf4525b[_0xfddd2e][_0xf231('0x49')],'CampaignId':_0xf4525b[_0xfddd2e][_0xf231('0x4a')]}});_0x5ddfe0[_0xf231('0x4b')](_0xcbe686);}return BPromise[_0xf231('0x4c')](_0x5ddfe0);}})['then'](function(_0x2f8424){logger[_0xf231('0x4d')](_0xf231('0x4e'),util[_0xf231('0x1a')](_0x2f8424,{'showHidden':![],'depth':null}));_0x489395();})[_0xf231('0x2d')](function(_0x45b91f){logger[_0xf231('0x17')](_0xf231('0x4f'),util[_0xf231('0x1a')](_0x45b91f,{'showHidden':![],'depth':null}));_0x489395(_0x45b91f);});}}});};
\ No newline at end of file
+var _0x1ec3=['findOne','isNil','dialTimezone','timezones','utcOffset','scheduledat','then','ret','CmHopper','\x20contact\x20not\x20insert\x20in\x20hopper,\x20check\x20duplicate\x20onlyIfOpen,\x20exist\x20in\x20hopper\x20VoiceQueue\x20','ListId','priority','callbackUniqueid','catch','cmContact,\x20afterCreate\x20','\x20contact\x20not\x20insert\x20in\x20hopper,\x20check\x20duplicate\x20always,\x20exist\x20in\x20hopper\x20VoiceQueue\x20','CmHopperFinal','cmContact,\x20afterCreate,\x20','\x20contact\x20not\x20insert\x20in\x20hopper,\x20check\x20duplicate\x20always,\x20exist\x20in\x20hopperFinal\x20VoiceQueue\x20','create','error','Campaign','add','minutes','\x20contact\x20not\x20insert\x20in\x20hopper,\x20check\x20duplicate\x20onlyIfOpen,\x20exist\x20in\x20hopper\x20Campaign\x20','\x20contact\x20not\x20insert\x20in\x20hopper,\x20check\x20duplicate\x20always,\x20exist\x20in\x20hopper\x20Campaign\x20','\x20contact\x20not\x20insert\x20in\x20hopper,\x20check\x20duplicate\x20always,\x20exist\x20in\x20hopperFinal\x20Campaign\x20','outbound','dialCheckDuplicateType','CmList','Lists','length','always','onlyIfOpen','BlackLists','get','cmContact,\x20%s,\x20%s','message','findAll','CmHopperBlack','List\x20not\x20found','destroy','ContactId','CampaignId','push','info','[CmContact][afterDestroy][Succesfull]','inspect','lodash','util','../../config/logger','api','moment','bluebird','request-promise','path','rimraf','../../config/environment','../../config/environment/shared','./cmContact.attributes','exports','define','CmContact','cm_contacts','phone','fti_cm_contacts','firstName','mobile','fax','FULLTEXT','utf8mb4','utf8mb4_unicode_ci','models','cmContact','afterCreate','format','YYYY-MM-DD\x20HH:mm:ss','VoiceQueue'];(function(_0x4ca188,_0x1b1b05){var _0x54626c=function(_0x58626d){while(--_0x58626d){_0x4ca188['push'](_0x4ca188['shift']());}};_0x54626c(++_0x1b1b05);}(_0x1ec3,0x7e));var _0x31ec=function(_0x2cf412,_0xeb2361){_0x2cf412=_0x2cf412-0x0;var _0x4bb8c9=_0x1ec3[_0x2cf412];return _0x4bb8c9;};'use strict';var _=require(_0x31ec('0x0'));var util=require(_0x31ec('0x1'));var logger=require(_0x31ec('0x2'))(_0x31ec('0x3'));var moment=require(_0x31ec('0x4'));var BPromise=require(_0x31ec('0x5'));var rp=require(_0x31ec('0x6'));var fs=require('fs');var path=require(_0x31ec('0x7'));var rimraf=require(_0x31ec('0x8'));var config=require(_0x31ec('0x9'));var shared=require(_0x31ec('0xa'));var attributes=require(_0x31ec('0xb'));module[_0x31ec('0xc')]=function(_0xa44fad,_0x27a673){return _0xa44fad[_0x31ec('0xd')](_0x31ec('0xe'),attributes,{'tableName':_0x31ec('0xf'),'paranoid':!![],'indexes':[{'name':_0x31ec('0x10'),'fields':['phone']},{'name':_0x31ec('0x11'),'fields':[_0x31ec('0x12'),'lastName',_0x31ec('0x10'),_0x31ec('0x13'),_0x31ec('0x14'),'email'],'type':_0x31ec('0x15')}],'timestamps':!![],'charset':_0x31ec('0x16'),'collate':_0x31ec('0x17'),'hooks':{'afterCreate':function(_0x111807,_0x51164e,_0x591f36){var _0x380619=_0xa44fad[_0x31ec('0x18')];var _0x512908=_0x111807['get']({'plain':!![]});function _0x137e18(){return function(_0x2508ee){logger['error'](_0x31ec('0x19'),_0x31ec('0x1a'),util['inspect'](_0x2508ee,{'showHidden':![],'depth':null}));};}function _0x4c00b8(_0x4ae2b4,_0x20e7a2){var _0x3fde5d=_0x20e7a2['scheduledat']?_0x20e7a2['scheduledat']:moment()[_0x31ec('0x1b')](_0x31ec('0x1c'));return new BPromise(function(_0x1414f7,_0x53a563){if(_['isNil'](_0x20e7a2['dialTimezone'])){_0x1414f7({'ret':_0x3fde5d});}else{_0x380619[_0x31ec('0x1d')][_0x31ec('0x1e')]({'where':{'id':_0x4ae2b4['id']}})['then'](function(_0x1f68e9){if(!_[_0x31ec('0x1f')](_0x1f68e9)){var _0x3bd34d=_0x1f68e9[_0x31ec('0x20')];if(!_[_0x31ec('0x1f')](_0x3bd34d)){var _0x5d3712=shared[_0x31ec('0x21')];var _0x598e24=_0x5d3712[_0x3bd34d];var _0x2b9852=_0x5d3712[_0x20e7a2[_0x31ec('0x20')]];if(!_[_0x31ec('0x1f')](_0x598e24)&&!_[_0x31ec('0x1f')](_0x2b9852)){var _0x145f58=_0x598e24[_0x31ec('0x22')]-_0x2b9852[_0x31ec('0x22')];_0x3fde5d=_0x20e7a2[_0x31ec('0x23')]?_0x20e7a2[_0x31ec('0x23')]:moment();var _0xd2cff1=moment(_0x3fde5d)['add'](_0x145f58,'minutes');_0x1414f7({'ret':_0xd2cff1['format']('YYYY-MM-DD\x20HH:mm:ss')});}else _0x1414f7({'ret':_0x3fde5d});}else _0x1414f7({'ret':_0x3fde5d});}else{_0x1414f7({'ret':_0x3fde5d});}});}});return 0xa;}var _0x486614=function(_0x1863cf){return new BPromise(function(_0xde1ff5,_0x25962b){_0x4c00b8(_0x1863cf,_0x512908)[_0x31ec('0x24')](function(_0x190c90){_0x512908['scheduledat']=_0x190c90[_0x31ec('0x25')];_0x380619[_0x31ec('0x26')][_0x31ec('0x1e')]({'where':{'phone':_0x512908[_0x31ec('0x10')],'VoiceQueueId':_0x1863cf['id']}})[_0x31ec('0x24')](function(_0x299e7a){if(!_['isNil'](_0x299e7a)){throw new Error('cmContact,\x20afterCreate\x20'+_0x512908[_0x31ec('0x10')]+_0x31ec('0x27')+_0x1863cf['id']);}return _0x380619[_0x31ec('0x26')]['create']({'phone':_0x512908[_0x31ec('0x10')],'ContactId':_0x512908['id'],'ListId':_0x512908[_0x31ec('0x28')],'priority':_0x512908[_0x31ec('0x29')]?_0x512908[_0x31ec('0x29')]:0x2,'scheduledat':_0x512908[_0x31ec('0x23')]?_0x512908[_0x31ec('0x23')]:moment()[_0x31ec('0x1b')](_0x31ec('0x1c')),'callback':_0x512908['callbackUniqueid']?!![]:![],'callbackuniqueid':_0x512908['callbackUniqueid']?_0x512908[_0x31ec('0x2a')]:undefined,'callbackat':_0x512908[_0x31ec('0x2a')]?moment()['format'](_0x31ec('0x1c')):undefined,'VoiceQueueId':_0x1863cf['id']});})[_0x31ec('0x2b')](function(_0x150b92){_0x25962b(_0x150b92);});});});};var _0xf71dad=function(_0x3793ce){return new BPromise(function(_0x569338,_0x25f5b1){_0x4c00b8(_0x3793ce,_0x512908)[_0x31ec('0x24')](function(_0x51772c){_0x512908[_0x31ec('0x23')]=_0x51772c[_0x31ec('0x25')];_0x380619[_0x31ec('0x26')][_0x31ec('0x1e')]({'where':{'phone':_0x512908[_0x31ec('0x10')],'VoiceQueueId':_0x3793ce['id']}})['then'](function(_0x824b62){if(!_[_0x31ec('0x1f')](_0x824b62)){throw new Error(_0x31ec('0x2c')+_0x512908[_0x31ec('0x10')]+_0x31ec('0x2d')+_0x3793ce['id']);}return _0x380619[_0x31ec('0x2e')][_0x31ec('0x1e')]({'where':{'calleridnum':_0x512908[_0x31ec('0x10')],'VoiceQueueId':_0x3793ce['id']}});})[_0x31ec('0x24')](function(_0x18724c){if(!_[_0x31ec('0x1f')](_0x18724c)){throw new Error(_0x31ec('0x2f')+_0x512908[_0x31ec('0x10')]+_0x31ec('0x30')+_0x3793ce['id']);}return _0x380619[_0x31ec('0x26')][_0x31ec('0x31')]({'phone':_0x512908['phone'],'ContactId':_0x512908['id'],'ListId':_0x512908[_0x31ec('0x28')],'priority':_0x512908[_0x31ec('0x29')]?_0x512908[_0x31ec('0x29')]:0x2,'scheduledat':_0x512908[_0x31ec('0x23')]?_0x512908[_0x31ec('0x23')]:moment()[_0x31ec('0x1b')]('YYYY-MM-DD\x20HH:mm:ss'),'callback':_0x512908[_0x31ec('0x2a')]?!![]:![],'callbackuniqueid':_0x512908['callbackUniqueid']?_0x512908[_0x31ec('0x2a')]:undefined,'callbackat':_0x512908[_0x31ec('0x2a')]?moment()[_0x31ec('0x1b')]('YYYY-MM-DD\x20HH:mm:ss'):undefined,'VoiceQueueId':_0x3793ce['id']});})[_0x31ec('0x2b')](function(_0x4f6af8){_0x25f5b1(_0x4f6af8);});});});};function _0x360480(){return function(_0x206bb6){logger[_0x31ec('0x32')](_0x31ec('0x19'),'afterCreate',util['inspect'](_0x206bb6,{'showHidden':![],'depth':null}));};}function _0x4a6a35(_0x334959,_0x5b328d){var _0x5c96b0=_0x5b328d[_0x31ec('0x23')]?_0x5b328d[_0x31ec('0x23')]:moment()[_0x31ec('0x1b')](_0x31ec('0x1c'));return new BPromise(function(_0x1a3f38,_0x26cb68){if(_[_0x31ec('0x1f')](_0x5b328d[_0x31ec('0x20')])){_0x1a3f38({'ret':_0x5c96b0});}else{_0x380619[_0x31ec('0x33')][_0x31ec('0x1e')]({'where':{'id':_0x334959['id']}})[_0x31ec('0x24')](function(_0x512b81){if(!_['isNil'](_0x512b81)){var _0x18efe8=_0x512b81[_0x31ec('0x20')];if(!_['isNil'](_0x18efe8)){var _0x5b4208=shared[_0x31ec('0x21')];var _0x2d628d=_0x5b4208[_0x18efe8];var _0x229251=_0x5b4208[_0x5b328d[_0x31ec('0x20')]];if(!_['isNil'](_0x2d628d)&&!_[_0x31ec('0x1f')](_0x229251)){var _0x59f826=_0x2d628d[_0x31ec('0x22')]-_0x229251[_0x31ec('0x22')];_0x5c96b0=_0x5b328d['scheduledat']?_0x5b328d[_0x31ec('0x23')]:moment();var _0x257a08=moment(_0x5c96b0)[_0x31ec('0x34')](_0x59f826,_0x31ec('0x35'));_0x1a3f38({'ret':_0x257a08[_0x31ec('0x1b')](_0x31ec('0x1c'))});}else _0x1a3f38({'ret':_0x5c96b0});}else _0x1a3f38({'ret':_0x5c96b0});}else{_0x1a3f38({'ret':_0x5c96b0});}});}});return 0xa;}var _0x4f40ac=function(_0x178f44){return new BPromise(function(_0x123e17,_0x30ccef){_0x4a6a35(_0x178f44,_0x512908)['then'](function(_0x27e1ab){_0x512908[_0x31ec('0x23')]=_0x27e1ab['ret'];_0x380619[_0x31ec('0x26')][_0x31ec('0x1e')]({'where':{'phone':_0x512908[_0x31ec('0x10')],'CampaignId':_0x178f44['id']}})[_0x31ec('0x24')](function(_0x31fa8c){if(!_[_0x31ec('0x1f')](_0x31fa8c)){throw new Error(_0x31ec('0x2c')+_0x512908['phone']+_0x31ec('0x36')+_0x178f44['id']);}return _0x380619[_0x31ec('0x26')]['create']({'phone':_0x512908[_0x31ec('0x10')],'ContactId':_0x512908['id'],'ListId':_0x512908['ListId'],'priority':_0x512908[_0x31ec('0x29')]?_0x512908['priority']:0x2,'scheduledat':_0x512908[_0x31ec('0x23')]?_0x512908[_0x31ec('0x23')]:moment()[_0x31ec('0x1b')]('YYYY-MM-DD\x20HH:mm:ss'),'callback':_0x512908[_0x31ec('0x2a')]?!![]:![],'callbackuniqueid':_0x512908['callbackUniqueid']?_0x512908['callbackUniqueid']:undefined,'callbackat':_0x512908[_0x31ec('0x2a')]?moment()[_0x31ec('0x1b')](_0x31ec('0x1c')):undefined,'CampaignId':_0x178f44['id']});})[_0x31ec('0x2b')](function(_0xbe0638){_0x30ccef(_0xbe0638);});});});};var _0x30127a=function(_0x4eaa6a){return new BPromise(function(_0xb01edd,_0x57ac07){_0x4a6a35(_0x4eaa6a,_0x512908)[_0x31ec('0x24')](function(_0x5e1267){_0x512908[_0x31ec('0x23')]=_0x5e1267[_0x31ec('0x25')];_0x380619[_0x31ec('0x26')]['findOne']({'where':{'phone':_0x512908[_0x31ec('0x10')],'CampaignId':_0x4eaa6a['id']}})[_0x31ec('0x24')](function(_0x474dbb){if(!_[_0x31ec('0x1f')](_0x474dbb)){throw new Error(_0x31ec('0x2c')+_0x512908['phone']+_0x31ec('0x37')+_0x4eaa6a['id']);}return _0x380619[_0x31ec('0x2e')]['findOne']({'where':{'calleridnum':_0x512908[_0x31ec('0x10')],'CampaignId':_0x4eaa6a['id']}});})[_0x31ec('0x24')](function(_0x4bc560){if(!_[_0x31ec('0x1f')](_0x4bc560)){throw new Error(_0x31ec('0x2f')+_0x512908[_0x31ec('0x10')]+_0x31ec('0x38')+_0x4eaa6a['id']);}return _0x380619[_0x31ec('0x26')][_0x31ec('0x31')]({'phone':_0x512908[_0x31ec('0x10')],'ContactId':_0x512908['id'],'ListId':_0x512908[_0x31ec('0x28')],'priority':_0x512908[_0x31ec('0x29')]?_0x512908[_0x31ec('0x29')]:0x2,'scheduledat':_0x512908[_0x31ec('0x23')]?_0x512908[_0x31ec('0x23')]:moment()[_0x31ec('0x1b')](_0x31ec('0x1c')),'callback':_0x512908[_0x31ec('0x2a')]?!![]:![],'callbackuniqueid':_0x512908[_0x31ec('0x2a')]?_0x512908[_0x31ec('0x2a')]:undefined,'callbackat':_0x512908[_0x31ec('0x2a')]?moment()[_0x31ec('0x1b')](_0x31ec('0x1c')):undefined,'CampaignId':_0x4eaa6a['id']});})[_0x31ec('0x2b')](function(_0x2567c6){_0x57ac07(_0x2567c6);});});});};if(_0x512908[_0x31ec('0x28')]){_0x380619[_0x31ec('0x1d')]['findAll']({'where':{'type':_0x31ec('0x39')},'attributes':['id',_0x31ec('0x3a'),_0x31ec('0x20')],'include':[{'model':_0x380619[_0x31ec('0x3b')],'as':_0x31ec('0x3c'),'where':{'id':_0x512908[_0x31ec('0x28')]}}]})[_0x31ec('0x24')](function(_0x12b24a){if(_0x12b24a){var _0x4b2014=[];for(var _0xf650cc=0x0,_0x6c8397;_0xf650cc<_0x12b24a[_0x31ec('0x3d')];_0xf650cc+=0x1){_0x6c8397=_0x12b24a[_0xf650cc]['get']({'plain':!![]});switch(_0x6c8397[_0x31ec('0x3a')]){case _0x31ec('0x3e'):_0xf71dad(_0x6c8397)['catch'](_0x137e18());break;case _0x31ec('0x3f'):_0x486614(_0x6c8397)[_0x31ec('0x2b')](_0x137e18());break;default:_0x4a6a35(_0x6c8397,_0x512908)[_0x31ec('0x24')](function(_0x9d2bc){_0x512908['scheduledat']=_0x9d2bc[_0x31ec('0x25')];_0x380619['CmHopper'][_0x31ec('0x31')]({'phone':_0x512908[_0x31ec('0x10')],'ContactId':_0x512908['id'],'ListId':_0x512908['ListId'],'scheduledat':_0x512908[_0x31ec('0x23')]?_0x512908[_0x31ec('0x23')]:moment()['format']('YYYY-MM-DD\x20HH:mm:ss'),'priority':_0x512908['priority']?_0x512908['priority']:0x2,'callback':_0x512908[_0x31ec('0x2a')]?!![]:![],'callbackuniqueid':_0x512908[_0x31ec('0x2a')]?_0x512908[_0x31ec('0x2a')]:undefined,'callbackat':_0x512908[_0x31ec('0x2a')]?moment()['format'](_0x31ec('0x1c')):undefined,'VoiceQueueId':_0x6c8397['id']})[_0x31ec('0x2b')](_0x137e18());});}}}})[_0x31ec('0x24')](function(){return _0x380619['VoiceQueue']['findAll']({'where':{'type':_0x31ec('0x39')},'attributes':['id'],'include':[{'model':_0x380619[_0x31ec('0x3b')],'as':_0x31ec('0x40'),'where':{'id':_0x512908['ListId']}}]})['then'](function(_0x1941a6){if(_0x1941a6){var _0x357fef=[];for(var _0x5d9d68=0x0,_0x3e2408;_0x5d9d68<_0x1941a6[_0x31ec('0x3d')];_0x5d9d68+=0x1){_0x3e2408=_0x1941a6[_0x5d9d68][_0x31ec('0x41')]({'plain':!![]});_0x380619['CmHopperBlack'][_0x31ec('0x31')]({'phone':_0x512908[_0x31ec('0x10')],'ContactId':_0x512908['id'],'ListId':_0x512908['ListId'],'VoiceQueueId':_0x3e2408['id']})[_0x31ec('0x2b')](function(_0x47f204){logger['error'](_0x31ec('0x42'),_0x31ec('0x1a'),_0x47f204[_0x31ec('0x43')]);});}}});})[_0x31ec('0x24')](function(){return _0x380619[_0x31ec('0x33')][_0x31ec('0x44')]({'attributes':['id',_0x31ec('0x3a'),'dialTimezone'],'include':[{'model':_0x380619['CmList'],'as':_0x31ec('0x3c'),'where':{'id':_0x512908[_0x31ec('0x28')]}}]})[_0x31ec('0x24')](function(_0x2d691c){if(_0x2d691c){var _0x1d1c55=[];for(var _0xa74f05=0x0,_0x39239b;_0xa74f05<_0x2d691c[_0x31ec('0x3d')];_0xa74f05+=0x1){_0x39239b=_0x2d691c[_0xa74f05][_0x31ec('0x41')]({'plain':!![]});switch(_0x39239b[_0x31ec('0x3a')]){case'always':_0x30127a(_0x39239b)[_0x31ec('0x2b')](_0x360480());break;case _0x31ec('0x3f'):_0x4f40ac(_0x39239b)[_0x31ec('0x2b')](_0x360480());break;default:_0x380619[_0x31ec('0x26')]['create']({'phone':_0x512908['phone'],'ContactId':_0x512908['id'],'ListId':_0x512908[_0x31ec('0x28')],'scheduledat':_0x512908[_0x31ec('0x23')]?_0x512908[_0x31ec('0x23')]:moment()[_0x31ec('0x1b')]('YYYY-MM-DD\x20HH:mm:ss'),'priority':_0x512908[_0x31ec('0x29')]?_0x512908[_0x31ec('0x29')]:0x2,'callback':_0x512908[_0x31ec('0x2a')]?!![]:![],'callbackuniqueid':_0x512908[_0x31ec('0x2a')]?_0x512908[_0x31ec('0x2a')]:undefined,'callbackat':_0x512908[_0x31ec('0x2a')]?moment()[_0x31ec('0x1b')](_0x31ec('0x1c')):undefined,'CampaignId':_0x39239b['id']})[_0x31ec('0x2b')](_0x360480());}}}});})[_0x31ec('0x24')](function(){return _0x380619['Campaign'][_0x31ec('0x44')]({'attributes':['id'],'include':[{'model':_0x380619[_0x31ec('0x3b')],'as':_0x31ec('0x40'),'where':{'id':_0x512908[_0x31ec('0x28')]}}]})[_0x31ec('0x24')](function(_0x27e3c3){if(_0x27e3c3){var _0x3028a5=[];for(var _0x29565b=0x0,_0x169ac5;_0x29565b<_0x27e3c3[_0x31ec('0x3d')];_0x29565b+=0x1){_0x169ac5=_0x27e3c3[_0x29565b]['get']({'plain':!![]});_0x380619[_0x31ec('0x45')][_0x31ec('0x31')]({'phone':_0x512908[_0x31ec('0x10')],'ContactId':_0x512908['id'],'ListId':_0x512908[_0x31ec('0x28')],'CampaignId':_0x169ac5['id']})['catch'](function(_0x122b22){logger[_0x31ec('0x32')](_0x31ec('0x42'),'afterCreate',_0x122b22[_0x31ec('0x43')]);});}}});})[_0x31ec('0x24')](function(){_0x591f36();})['catch'](function(_0x50849a){logger[_0x31ec('0x32')](_0x31ec('0x42'),_0x31ec('0x1a'),_0x50849a['message']);_0x591f36(_0x50849a);});}else{_0x591f36(new Error(_0x31ec('0x46')));}},'afterDestroy':function(_0x294870,_0x474c6e,_0x5006b3){var _0x3c4fe0=_0xa44fad[_0x31ec('0x18')];var _0x172d32=_0x294870[_0x31ec('0x41')]({'plain':!![]});return _0x3c4fe0['CmHopper'][_0x31ec('0x44')]({'raw':!![],'where':{'ListId':_0x172d32[_0x31ec('0x28')],'ContactId':_0x172d32['id']}})[_0x31ec('0x24')](function(_0x64524d){if(!_['isEmpty'](_0x64524d)){var _0x48dd38=[];for(var _0x2a69d2=0x0;_0x2a69d2<_0x64524d[_0x31ec('0x3d')];_0x2a69d2+=0x1){var _0x575828=_0x3c4fe0[_0x31ec('0x26')][_0x31ec('0x47')]({'where':{'ListId':_0x64524d[_0x2a69d2][_0x31ec('0x28')],'ContactId':_0x64524d[_0x2a69d2][_0x31ec('0x48')],'VoiceQueueId':_0x64524d[_0x2a69d2]['VoiceQueueId'],'CampaignId':_0x64524d[_0x2a69d2][_0x31ec('0x49')]}});_0x48dd38[_0x31ec('0x4a')](_0x575828);}return BPromise['all'](_0x48dd38);}})[_0x31ec('0x24')](function(_0x2b12af){logger[_0x31ec('0x4b')](_0x31ec('0x4c'),util[_0x31ec('0x4d')](_0x2b12af,{'showHidden':![],'depth':null}));_0x5006b3();})['catch'](function(_0x1dcb32){logger['error']('[CmContact][afterDestroy][Error]',util[_0x31ec('0x4d')](_0x1dcb32,{'showHidden':![],'depth':null}));_0x5006b3(_0x1dcb32);});}}});};
\ No newline at end of file