Built motion from commit ddca4d0d.|2.5.47
[motion2.git] / server / api / cmContact / cmContact.model.js
index c40b3c8..bf564e6 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x147b=['\x20contact\x20not\x20insert\x20in\x20hopper,\x20check\x20duplicate\x20always,\x20exist\x20in\x20hopper\x20VoiceQueue\x20','cmContact,\x20afterCreate,\x20','create','afterCreate','\x20contact\x20not\x20insert\x20in\x20hopper,\x20check\x20duplicate\x20onlyIfOpen,\x20exist\x20in\x20hopper\x20Campaign\x20','scheduledat','\x20contact\x20not\x20insert\x20in\x20hopper,\x20check\x20duplicate\x20always,\x20exist\x20in\x20hopper\x20Campaign\x20','CmHopperFinal','\x20contact\x20not\x20insert\x20in\x20hopper,\x20check\x20duplicate\x20always,\x20exist\x20in\x20hopperFinal\x20Campaign\x20','findAll','outbound','dialCheckDuplicateType','CmList','Lists','length','always','onlyIfOpen','VoiceQueue','BlackLists','CmHopperBlack','message','Campaign','cmContact,\x20%s,\x20%s','isEmpty','destroy','ContactId','VoiceQueueId','push','all','[CmContact][afterDestroy][Succesfull]','[CmContact][afterDestroy][Error]','lodash','util','api','moment','request-promise','path','rimraf','./cmContact.attributes','define','phone','fti_cm_contacts','firstName','lastName','mobile','fax','models','get','error','cmContact','inspect','CmHopper','findOne','isNil','cmContact,\x20afterCreate\x20','ListId','priority','format','YYYY-MM-DD\x20HH:mm:ss','callbackUniqueid','catch','then'];(function(_0x52c9f5,_0x4b5a0a){var _0x3054be=function(_0x4b5901){while(--_0x4b5901){_0x52c9f5['push'](_0x52c9f5['shift']());}};_0x3054be(++_0x4b5a0a);}(_0x147b,0x193));var _0xb147=function(_0x11f67d,_0x38606d){_0x11f67d=_0x11f67d-0x0;var _0x1f4872=_0x147b[_0x11f67d];return _0x1f4872;};'use strict';var _=require(_0xb147('0x0'));var util=require(_0xb147('0x1'));var logger=require('../../config/logger')(_0xb147('0x2'));var moment=require(_0xb147('0x3'));var BPromise=require('bluebird');var rp=require(_0xb147('0x4'));var fs=require('fs');var path=require(_0xb147('0x5'));var rimraf=require(_0xb147('0x6'));var config=require('../../config/environment');var attributes=require(_0xb147('0x7'));module['exports']=function(_0x2432f1,_0x72c3cf){return _0x2432f1[_0xb147('0x8')]('CmContact',attributes,{'tableName':'cm_contacts','paranoid':!![],'indexes':[{'name':_0xb147('0x9'),'fields':[_0xb147('0x9')]},{'name':_0xb147('0xa'),'fields':[_0xb147('0xb'),_0xb147('0xc'),_0xb147('0x9'),_0xb147('0xd'),_0xb147('0xe'),'email'],'type':'FULLTEXT'}],'timestamps':!![],'hooks':{'afterCreate':function(_0x2cd04a,_0x203581,_0xf0c7cc){var _0x177a8f=_0x2432f1[_0xb147('0xf')];var _0xc1269c=_0x2cd04a[_0xb147('0x10')]({'plain':!![]});function _0x2d5e1c(){return function(_0x38040c){logger[_0xb147('0x11')](_0xb147('0x12'),'afterCreate',util[_0xb147('0x13')](_0x38040c,{'showHidden':![],'depth':null}));};}var _0x3dcfe0=function(_0x23ad29){return new BPromise(function(_0x2c1952,_0x5479b4){_0x177a8f[_0xb147('0x14')][_0xb147('0x15')]({'where':{'phone':_0xc1269c['phone'],'VoiceQueueId':_0x23ad29['id']}})['then'](function(_0x1f424a){if(!_[_0xb147('0x16')](_0x1f424a)){throw new Error(_0xb147('0x17')+_0xc1269c['phone']+'\x20contact\x20not\x20insert\x20in\x20hopper,\x20check\x20duplicate\x20onlyIfOpen,\x20exist\x20in\x20hopper\x20VoiceQueue\x20'+_0x23ad29['id']);}return _0x177a8f[_0xb147('0x14')]['create']({'phone':_0xc1269c[_0xb147('0x9')],'ContactId':_0xc1269c['id'],'ListId':_0xc1269c[_0xb147('0x18')],'priority':_0xc1269c[_0xb147('0x19')]?_0xc1269c['priority']:0x2,'scheduledat':_0xc1269c['scheduledat']?_0xc1269c['scheduledat']:moment()[_0xb147('0x1a')](_0xb147('0x1b')),'callback':_0xc1269c[_0xb147('0x1c')]?!![]:![],'callbackuniqueid':_0xc1269c['callbackUniqueid']?_0xc1269c[_0xb147('0x1c')]:undefined,'callbackat':_0xc1269c[_0xb147('0x1c')]?moment()[_0xb147('0x1a')](_0xb147('0x1b')):undefined,'VoiceQueueId':_0x23ad29['id']});})[_0xb147('0x1d')](function(_0x57d261){_0x5479b4(_0x57d261);});});};var _0xa85f38=function(_0xf64527){return new BPromise(function(_0x243523,_0x420452){_0x177a8f[_0xb147('0x14')]['findOne']({'where':{'phone':_0xc1269c['phone'],'VoiceQueueId':_0xf64527['id']}})[_0xb147('0x1e')](function(_0x98509e){if(!_[_0xb147('0x16')](_0x98509e)){throw new Error(_0xb147('0x17')+_0xc1269c['phone']+_0xb147('0x1f')+_0xf64527['id']);}return _0x177a8f['CmHopperFinal']['findOne']({'where':{'calleridnum':_0xc1269c[_0xb147('0x9')],'VoiceQueueId':_0xf64527['id']}});})[_0xb147('0x1e')](function(_0x444d58){if(!_[_0xb147('0x16')](_0x444d58)){throw new Error(_0xb147('0x20')+_0xc1269c[_0xb147('0x9')]+'\x20contact\x20not\x20insert\x20in\x20hopper,\x20check\x20duplicate\x20always,\x20exist\x20in\x20hopperFinal\x20VoiceQueue\x20'+_0xf64527['id']);}return _0x177a8f['CmHopper'][_0xb147('0x21')]({'phone':_0xc1269c[_0xb147('0x9')],'ContactId':_0xc1269c['id'],'ListId':_0xc1269c['ListId'],'priority':_0xc1269c[_0xb147('0x19')]?_0xc1269c[_0xb147('0x19')]:0x2,'scheduledat':_0xc1269c['scheduledat']?_0xc1269c['scheduledat']:moment()[_0xb147('0x1a')](_0xb147('0x1b')),'callback':_0xc1269c[_0xb147('0x1c')]?!![]:![],'callbackuniqueid':_0xc1269c[_0xb147('0x1c')]?_0xc1269c[_0xb147('0x1c')]:undefined,'callbackat':_0xc1269c['callbackUniqueid']?moment()[_0xb147('0x1a')](_0xb147('0x1b')):undefined,'VoiceQueueId':_0xf64527['id']});})[_0xb147('0x1d')](function(_0x15cdfa){_0x420452(_0x15cdfa);});});};function _0x40608d(){return function(_0x4afede){logger[_0xb147('0x11')](_0xb147('0x12'),_0xb147('0x22'),util[_0xb147('0x13')](_0x4afede,{'showHidden':![],'depth':null}));};}var _0x3b2eb2=function(_0x28a923){return new BPromise(function(_0x35d348,_0xb2b398){_0x177a8f[_0xb147('0x14')]['findOne']({'where':{'phone':_0xc1269c[_0xb147('0x9')],'CampaignId':_0x28a923['id']}})[_0xb147('0x1e')](function(_0xf373bc){if(!_[_0xb147('0x16')](_0xf373bc)){throw new Error(_0xb147('0x17')+_0xc1269c[_0xb147('0x9')]+_0xb147('0x23')+_0x28a923['id']);}return _0x177a8f[_0xb147('0x14')]['create']({'phone':_0xc1269c[_0xb147('0x9')],'ContactId':_0xc1269c['id'],'ListId':_0xc1269c[_0xb147('0x18')],'priority':_0xc1269c[_0xb147('0x19')]?_0xc1269c[_0xb147('0x19')]:0x2,'scheduledat':_0xc1269c[_0xb147('0x24')]?_0xc1269c[_0xb147('0x24')]:moment()[_0xb147('0x1a')]('YYYY-MM-DD\x20HH:mm:ss'),'callback':_0xc1269c[_0xb147('0x1c')]?!![]:![],'callbackuniqueid':_0xc1269c['callbackUniqueid']?_0xc1269c[_0xb147('0x1c')]:undefined,'callbackat':_0xc1269c[_0xb147('0x1c')]?moment()['format']('YYYY-MM-DD\x20HH:mm:ss'):undefined,'CampaignId':_0x28a923['id']});})['catch'](function(_0x344b11){_0xb2b398(_0x344b11);});});};var _0x38735d=function(_0xfce81){return new BPromise(function(_0x11821a,_0x2a60a1){_0x177a8f['CmHopper'][_0xb147('0x15')]({'where':{'phone':_0xc1269c['phone'],'CampaignId':_0xfce81['id']}})['then'](function(_0x48ca8c){if(!_[_0xb147('0x16')](_0x48ca8c)){throw new Error(_0xb147('0x17')+_0xc1269c[_0xb147('0x9')]+_0xb147('0x25')+_0xfce81['id']);}return _0x177a8f[_0xb147('0x26')][_0xb147('0x15')]({'where':{'calleridnum':_0xc1269c['phone'],'CampaignId':_0xfce81['id']}});})[_0xb147('0x1e')](function(_0x3be87a){if(!_[_0xb147('0x16')](_0x3be87a)){throw new Error(_0xb147('0x20')+_0xc1269c[_0xb147('0x9')]+_0xb147('0x27')+_0xfce81['id']);}return _0x177a8f['CmHopper'][_0xb147('0x21')]({'phone':_0xc1269c[_0xb147('0x9')],'ContactId':_0xc1269c['id'],'ListId':_0xc1269c[_0xb147('0x18')],'priority':_0xc1269c['priority']?_0xc1269c[_0xb147('0x19')]:0x2,'scheduledat':_0xc1269c[_0xb147('0x24')]?_0xc1269c['scheduledat']:moment()['format']('YYYY-MM-DD\x20HH:mm:ss'),'callback':_0xc1269c[_0xb147('0x1c')]?!![]:![],'callbackuniqueid':_0xc1269c['callbackUniqueid']?_0xc1269c['callbackUniqueid']:undefined,'callbackat':_0xc1269c[_0xb147('0x1c')]?moment()[_0xb147('0x1a')](_0xb147('0x1b')):undefined,'CampaignId':_0xfce81['id']});})[_0xb147('0x1d')](function(_0x4a7c03){_0x2a60a1(_0x4a7c03);});});};if(_0xc1269c[_0xb147('0x18')]){_0x177a8f['VoiceQueue'][_0xb147('0x28')]({'where':{'type':_0xb147('0x29')},'attributes':['id',_0xb147('0x2a')],'include':[{'model':_0x177a8f[_0xb147('0x2b')],'as':_0xb147('0x2c'),'where':{'id':_0xc1269c[_0xb147('0x18')]}}]})[_0xb147('0x1e')](function(_0x1f439d){if(_0x1f439d){var _0x5d3d1f=[];for(var _0x45bd14=0x0,_0x175e2a;_0x45bd14<_0x1f439d[_0xb147('0x2d')];_0x45bd14+=0x1){_0x175e2a=_0x1f439d[_0x45bd14][_0xb147('0x10')]({'plain':!![]});switch(_0x175e2a[_0xb147('0x2a')]){case _0xb147('0x2e'):_0xa85f38(_0x175e2a)['catch'](_0x2d5e1c());break;case _0xb147('0x2f'):_0x3dcfe0(_0x175e2a)['catch'](_0x2d5e1c());break;default:_0x177a8f[_0xb147('0x14')][_0xb147('0x21')]({'phone':_0xc1269c[_0xb147('0x9')],'ContactId':_0xc1269c['id'],'ListId':_0xc1269c[_0xb147('0x18')],'scheduledat':_0xc1269c['scheduledat']?_0xc1269c[_0xb147('0x24')]:moment()[_0xb147('0x1a')](_0xb147('0x1b')),'priority':_0xc1269c['priority']?_0xc1269c[_0xb147('0x19')]:0x2,'callback':_0xc1269c['callbackUniqueid']?!![]:![],'callbackuniqueid':_0xc1269c[_0xb147('0x1c')]?_0xc1269c[_0xb147('0x1c')]:undefined,'callbackat':_0xc1269c[_0xb147('0x1c')]?moment()[_0xb147('0x1a')](_0xb147('0x1b')):undefined,'VoiceQueueId':_0x175e2a['id']})[_0xb147('0x1d')](_0x2d5e1c());}}}})[_0xb147('0x1e')](function(){return _0x177a8f[_0xb147('0x30')][_0xb147('0x28')]({'where':{'type':_0xb147('0x29')},'attributes':['id'],'include':[{'model':_0x177a8f[_0xb147('0x2b')],'as':_0xb147('0x31'),'where':{'id':_0xc1269c[_0xb147('0x18')]}}]})[_0xb147('0x1e')](function(_0x31e2b3){if(_0x31e2b3){var _0x4b9134=[];for(var _0x2bad54=0x0,_0x14d622;_0x2bad54<_0x31e2b3[_0xb147('0x2d')];_0x2bad54+=0x1){_0x14d622=_0x31e2b3[_0x2bad54][_0xb147('0x10')]({'plain':!![]});_0x177a8f[_0xb147('0x32')]['create']({'phone':_0xc1269c[_0xb147('0x9')],'ContactId':_0xc1269c['id'],'ListId':_0xc1269c[_0xb147('0x18')],'VoiceQueueId':_0x14d622['id']})['catch'](function(_0x2d6c1d){logger['error']('cmContact,\x20%s,\x20%s',_0xb147('0x22'),_0x2d6c1d[_0xb147('0x33')]);});}}});})['then'](function(){return _0x177a8f[_0xb147('0x34')][_0xb147('0x28')]({'attributes':['id',_0xb147('0x2a')],'include':[{'model':_0x177a8f[_0xb147('0x2b')],'as':_0xb147('0x2c'),'where':{'id':_0xc1269c['ListId']}}]})[_0xb147('0x1e')](function(_0x19eb25){if(_0x19eb25){var _0x42e8e6=[];for(var _0x127ef3=0x0,_0x2a4655;_0x127ef3<_0x19eb25[_0xb147('0x2d')];_0x127ef3+=0x1){_0x2a4655=_0x19eb25[_0x127ef3][_0xb147('0x10')]({'plain':!![]});switch(_0x2a4655[_0xb147('0x2a')]){case _0xb147('0x2e'):_0x38735d(_0x2a4655)[_0xb147('0x1d')](_0x40608d());break;case _0xb147('0x2f'):_0x3b2eb2(_0x2a4655)['catch'](_0x40608d());break;default:_0x177a8f[_0xb147('0x14')][_0xb147('0x21')]({'phone':_0xc1269c['phone'],'ContactId':_0xc1269c['id'],'ListId':_0xc1269c[_0xb147('0x18')],'scheduledat':_0xc1269c[_0xb147('0x24')]?_0xc1269c[_0xb147('0x24')]:moment()['format'](_0xb147('0x1b')),'priority':_0xc1269c['priority']?_0xc1269c[_0xb147('0x19')]:0x2,'callback':_0xc1269c[_0xb147('0x1c')]?!![]:![],'callbackuniqueid':_0xc1269c['callbackUniqueid']?_0xc1269c[_0xb147('0x1c')]:undefined,'callbackat':_0xc1269c[_0xb147('0x1c')]?moment()['format'](_0xb147('0x1b')):undefined,'CampaignId':_0x2a4655['id']})[_0xb147('0x1d')](_0x40608d());}}}});})[_0xb147('0x1e')](function(){return _0x177a8f[_0xb147('0x34')][_0xb147('0x28')]({'attributes':['id'],'include':[{'model':_0x177a8f[_0xb147('0x2b')],'as':_0xb147('0x31'),'where':{'id':_0xc1269c[_0xb147('0x18')]}}]})[_0xb147('0x1e')](function(_0xb5959){if(_0xb5959){var _0x52b498=[];for(var _0x20f32c=0x0,_0x202d4e;_0x20f32c<_0xb5959['length'];_0x20f32c+=0x1){_0x202d4e=_0xb5959[_0x20f32c][_0xb147('0x10')]({'plain':!![]});_0x177a8f[_0xb147('0x32')]['create']({'phone':_0xc1269c[_0xb147('0x9')],'ContactId':_0xc1269c['id'],'ListId':_0xc1269c[_0xb147('0x18')],'CampaignId':_0x202d4e['id']})[_0xb147('0x1d')](function(_0x2559d6){logger[_0xb147('0x11')](_0xb147('0x35'),_0xb147('0x22'),_0x2559d6[_0xb147('0x33')]);});}}});})[_0xb147('0x1e')](function(){_0xf0c7cc();})[_0xb147('0x1d')](function(_0x5b8a0e){logger['error'](_0xb147('0x35'),_0xb147('0x22'),_0x5b8a0e[_0xb147('0x33')]);_0xf0c7cc(_0x5b8a0e);});}else{_0xf0c7cc(new Error('List\x20not\x20found'));}},'afterDestroy':function(_0x5820df,_0x8361a9,_0x19a9b3){var _0x491b46=_0x2432f1['models'];var _0xf5d51e=_0x5820df[_0xb147('0x10')]({'plain':!![]});return _0x491b46[_0xb147('0x14')]['findAll']({'raw':!![],'where':{'ListId':_0xf5d51e[_0xb147('0x18')],'ContactId':_0xf5d51e['id']}})[_0xb147('0x1e')](function(_0x3867f0){if(!_[_0xb147('0x36')](_0x3867f0)){var _0x9f1298=[];for(var _0x531987=0x0;_0x531987<_0x3867f0[_0xb147('0x2d')];_0x531987+=0x1){var _0x256ae7=_0x491b46['CmHopper'][_0xb147('0x37')]({'where':{'ListId':_0x3867f0[_0x531987][_0xb147('0x18')],'ContactId':_0x3867f0[_0x531987][_0xb147('0x38')],'VoiceQueueId':_0x3867f0[_0x531987][_0xb147('0x39')],'CampaignId':_0x3867f0[_0x531987]['CampaignId']}});_0x9f1298[_0xb147('0x3a')](_0x256ae7);}return BPromise[_0xb147('0x3b')](_0x9f1298);}})['then'](function(_0x216cbf){logger['info'](_0xb147('0x3c'),util[_0xb147('0x13')](_0x216cbf,{'showHidden':![],'depth':null}));_0x19a9b3();})[_0xb147('0x1d')](function(_0x5cb1d7){logger[_0xb147('0x11')](_0xb147('0x3d'),util['inspect'](_0x5cb1d7,{'showHidden':![],'depth':null}));_0x19a9b3(_0x5cb1d7);});}}});};
\ No newline at end of file
+var _0x958b=['timezones','utcOffset','add','minutes','YYYY-MM-DD\x20HH:mm:ss','ret','CmHopper','findOne','cmContact,\x20afterCreate\x20','\x20contact\x20not\x20insert\x20in\x20hopper,\x20check\x20duplicate\x20onlyIfOpen,\x20exist\x20in\x20hopper\x20VoiceQueue\x20','create','priority','callbackUniqueid','catch','\x20contact\x20not\x20insert\x20in\x20hopper,\x20check\x20duplicate\x20always,\x20exist\x20in\x20hopper\x20VoiceQueue\x20','\x20contact\x20not\x20insert\x20in\x20hopper,\x20check\x20duplicate\x20always,\x20exist\x20in\x20hopperFinal\x20VoiceQueue\x20','ListId','error','Campaign','\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','CmHopperFinal','cmContact,\x20afterCreate,\x20','\x20contact\x20not\x20insert\x20in\x20hopper,\x20check\x20duplicate\x20always,\x20exist\x20in\x20hopperFinal\x20Campaign\x20','findAll','outbound','dialCheckDuplicateType','CmList','Lists','length','always','BlackLists','CmHopperBlack','cmContact,\x20%s,\x20%s','message','List\x20not\x20found','isEmpty','ContactId','push','all','info','[CmContact][afterDestroy][Succesfull]','[CmContact][afterDestroy][Error]','../../config/logger','api','moment','bluebird','request-promise','../../config/environment','../../config/environment/shared','define','CmContact','cm_contacts','phone','fti_cm_contacts','firstName','lastName','fax','email','utf8mb4','utf8mb4_unicode_ci','models','get','cmContact','afterCreate','inspect','scheduledat','format','isNil','dialTimezone','VoiceQueue','then'];(function(_0x897636,_0x277f46){var _0x50fc61=function(_0x385e51){while(--_0x385e51){_0x897636['push'](_0x897636['shift']());}};_0x50fc61(++_0x277f46);}(_0x958b,0x1db));var _0xb958=function(_0x721a02,_0x11682f){_0x721a02=_0x721a02-0x0;var _0x38a4aa=_0x958b[_0x721a02];return _0x38a4aa;};'use strict';var _=require('lodash');var util=require('util');var logger=require(_0xb958('0x0'))(_0xb958('0x1'));var moment=require(_0xb958('0x2'));var BPromise=require(_0xb958('0x3'));var rp=require(_0xb958('0x4'));var fs=require('fs');var path=require('path');var rimraf=require('rimraf');var config=require(_0xb958('0x5'));var shared=require(_0xb958('0x6'));var attributes=require('./cmContact.attributes');module['exports']=function(_0x2bca8f,_0x4a7f52){return _0x2bca8f[_0xb958('0x7')](_0xb958('0x8'),attributes,{'tableName':_0xb958('0x9'),'paranoid':!![],'indexes':[{'name':_0xb958('0xa'),'fields':['phone']},{'name':_0xb958('0xb'),'fields':[_0xb958('0xc'),_0xb958('0xd'),_0xb958('0xa'),'mobile',_0xb958('0xe'),_0xb958('0xf')],'type':'FULLTEXT'}],'timestamps':!![],'charset':_0xb958('0x10'),'collate':_0xb958('0x11'),'hooks':{'afterCreate':function(_0x390018,_0x2fcef6,_0x194c1f){var _0x4ed2b0=_0x2bca8f[_0xb958('0x12')];var _0x29d4c9=_0x390018[_0xb958('0x13')]({'plain':!![]});function _0x1c584a(){return function(_0x16ff14){logger['error'](_0xb958('0x14'),_0xb958('0x15'),util[_0xb958('0x16')](_0x16ff14,{'showHidden':![],'depth':null}));};}function _0x47f6a5(_0x268e86,_0x3fb4a4){var _0x54a4b3=_0x3fb4a4[_0xb958('0x17')]?_0x3fb4a4[_0xb958('0x17')]:moment()[_0xb958('0x18')]('YYYY-MM-DD\x20HH:mm:ss');return new BPromise(function(_0x4b3779,_0xec7ea5){if(_[_0xb958('0x19')](_0x3fb4a4[_0xb958('0x1a')])){_0x4b3779({'ret':_0x54a4b3});}else{_0x4ed2b0[_0xb958('0x1b')]['findOne']({'where':{'id':_0x268e86['id']}})[_0xb958('0x1c')](function(_0x56ca44){if(!_[_0xb958('0x19')](_0x56ca44)){var _0x2ff38e=_0x56ca44[_0xb958('0x1a')];if(!_[_0xb958('0x19')](_0x2ff38e)){var _0x6a41e4=shared[_0xb958('0x1d')];var _0x40fb43=_0x6a41e4[_0x2ff38e];var _0x32d2f4=_0x6a41e4[_0x3fb4a4['dialTimezone']];if(!_[_0xb958('0x19')](_0x40fb43)&&!_[_0xb958('0x19')](_0x32d2f4)){var _0x270b85=_0x40fb43[_0xb958('0x1e')]-_0x32d2f4[_0xb958('0x1e')];_0x54a4b3=_0x3fb4a4['scheduledat']?_0x3fb4a4[_0xb958('0x17')]:moment();var _0x27d83e=moment(_0x54a4b3)[_0xb958('0x1f')](_0x270b85,_0xb958('0x20'));_0x4b3779({'ret':_0x27d83e[_0xb958('0x18')](_0xb958('0x21'))});}else _0x4b3779({'ret':_0x54a4b3});}else _0x4b3779({'ret':_0x54a4b3});}else{_0x4b3779({'ret':_0x54a4b3});}});}});return 0xa;}var _0x2c1c9a=function(_0x5b3fa3){return new BPromise(function(_0x3b70b2,_0x1e970b){_0x47f6a5(_0x5b3fa3,_0x29d4c9)[_0xb958('0x1c')](function(_0x1a8d66){_0x29d4c9[_0xb958('0x17')]=_0x1a8d66[_0xb958('0x22')];_0x4ed2b0[_0xb958('0x23')][_0xb958('0x24')]({'where':{'phone':_0x29d4c9[_0xb958('0xa')],'VoiceQueueId':_0x5b3fa3['id']}})[_0xb958('0x1c')](function(_0xcf80cd){if(!_[_0xb958('0x19')](_0xcf80cd)){throw new Error(_0xb958('0x25')+_0x29d4c9[_0xb958('0xa')]+_0xb958('0x26')+_0x5b3fa3['id']);}return _0x4ed2b0[_0xb958('0x23')][_0xb958('0x27')]({'phone':_0x29d4c9[_0xb958('0xa')],'ContactId':_0x29d4c9['id'],'ListId':_0x29d4c9['ListId'],'priority':_0x29d4c9[_0xb958('0x28')]?_0x29d4c9['priority']:0x2,'scheduledat':_0x29d4c9[_0xb958('0x17')]?_0x29d4c9[_0xb958('0x17')]:moment()[_0xb958('0x18')](_0xb958('0x21')),'callback':_0x29d4c9[_0xb958('0x29')]?!![]:![],'callbackuniqueid':_0x29d4c9[_0xb958('0x29')]?_0x29d4c9[_0xb958('0x29')]:undefined,'callbackat':_0x29d4c9[_0xb958('0x29')]?moment()[_0xb958('0x18')](_0xb958('0x21')):undefined,'VoiceQueueId':_0x5b3fa3['id']});})[_0xb958('0x2a')](function(_0x10f84a){_0x1e970b(_0x10f84a);});});});};var _0x165b40=function(_0x19ff8c){return new BPromise(function(_0x29d46b,_0x222e02){_0x47f6a5(_0x19ff8c,_0x29d4c9)[_0xb958('0x1c')](function(_0x4f8edc){_0x29d4c9[_0xb958('0x17')]=_0x4f8edc[_0xb958('0x22')];_0x4ed2b0[_0xb958('0x23')]['findOne']({'where':{'phone':_0x29d4c9['phone'],'VoiceQueueId':_0x19ff8c['id']}})[_0xb958('0x1c')](function(_0xb8f241){if(!_['isNil'](_0xb8f241)){throw new Error(_0xb958('0x25')+_0x29d4c9[_0xb958('0xa')]+_0xb958('0x2b')+_0x19ff8c['id']);}return _0x4ed2b0['CmHopperFinal'][_0xb958('0x24')]({'where':{'calleridnum':_0x29d4c9[_0xb958('0xa')],'VoiceQueueId':_0x19ff8c['id']}});})[_0xb958('0x1c')](function(_0x4d45b7){if(!_[_0xb958('0x19')](_0x4d45b7)){throw new Error('cmContact,\x20afterCreate,\x20'+_0x29d4c9['phone']+_0xb958('0x2c')+_0x19ff8c['id']);}return _0x4ed2b0['CmHopper'][_0xb958('0x27')]({'phone':_0x29d4c9['phone'],'ContactId':_0x29d4c9['id'],'ListId':_0x29d4c9[_0xb958('0x2d')],'priority':_0x29d4c9[_0xb958('0x28')]?_0x29d4c9['priority']:0x2,'scheduledat':_0x29d4c9[_0xb958('0x17')]?_0x29d4c9[_0xb958('0x17')]:moment()['format'](_0xb958('0x21')),'callback':_0x29d4c9[_0xb958('0x29')]?!![]:![],'callbackuniqueid':_0x29d4c9[_0xb958('0x29')]?_0x29d4c9['callbackUniqueid']:undefined,'callbackat':_0x29d4c9[_0xb958('0x29')]?moment()[_0xb958('0x18')](_0xb958('0x21')):undefined,'VoiceQueueId':_0x19ff8c['id']});})[_0xb958('0x2a')](function(_0x22160a){_0x222e02(_0x22160a);});});});};function _0x5633fc(){return function(_0x5b6002){logger[_0xb958('0x2e')](_0xb958('0x14'),_0xb958('0x15'),util['inspect'](_0x5b6002,{'showHidden':![],'depth':null}));};}function _0x2860a3(_0x1a75df,_0x30dba7){var _0x35fb93=_0x30dba7[_0xb958('0x17')]?_0x30dba7[_0xb958('0x17')]:moment()[_0xb958('0x18')](_0xb958('0x21'));return new BPromise(function(_0x37b2cb,_0x3df69c){if(_[_0xb958('0x19')](_0x30dba7['dialTimezone'])){_0x37b2cb({'ret':_0x35fb93});}else{_0x4ed2b0[_0xb958('0x2f')]['findOne']({'where':{'id':_0x1a75df['id']}})[_0xb958('0x1c')](function(_0x19d6e){if(!_[_0xb958('0x19')](_0x19d6e)){var _0x5ef015=_0x19d6e[_0xb958('0x1a')];if(!_[_0xb958('0x19')](_0x5ef015)){var _0x2944a9=shared[_0xb958('0x1d')];var _0x281dce=_0x2944a9[_0x5ef015];var _0xf4e174=_0x2944a9[_0x30dba7[_0xb958('0x1a')]];if(!_[_0xb958('0x19')](_0x281dce)&&!_[_0xb958('0x19')](_0xf4e174)){var _0x490da1=_0x281dce[_0xb958('0x1e')]-_0xf4e174[_0xb958('0x1e')];_0x35fb93=_0x30dba7[_0xb958('0x17')]?_0x30dba7[_0xb958('0x17')]:moment();var _0x282fa3=moment(_0x35fb93)[_0xb958('0x1f')](_0x490da1,_0xb958('0x20'));_0x37b2cb({'ret':_0x282fa3[_0xb958('0x18')]('YYYY-MM-DD\x20HH:mm:ss')});}else _0x37b2cb({'ret':_0x35fb93});}else _0x37b2cb({'ret':_0x35fb93});}else{_0x37b2cb({'ret':_0x35fb93});}});}});return 0xa;}var _0x5f1540=function(_0xf695ca){return new BPromise(function(_0x274453,_0x3fb258){_0x2860a3(_0xf695ca,_0x29d4c9)['then'](function(_0xc7b693){_0x29d4c9[_0xb958('0x17')]=_0xc7b693[_0xb958('0x22')];_0x4ed2b0['CmHopper'][_0xb958('0x24')]({'where':{'phone':_0x29d4c9['phone'],'CampaignId':_0xf695ca['id']}})[_0xb958('0x1c')](function(_0x7cbf9e){if(!_['isNil'](_0x7cbf9e)){throw new Error(_0xb958('0x25')+_0x29d4c9[_0xb958('0xa')]+_0xb958('0x30')+_0xf695ca['id']);}return _0x4ed2b0[_0xb958('0x23')][_0xb958('0x27')]({'phone':_0x29d4c9['phone'],'ContactId':_0x29d4c9['id'],'ListId':_0x29d4c9['ListId'],'priority':_0x29d4c9[_0xb958('0x28')]?_0x29d4c9[_0xb958('0x28')]:0x2,'scheduledat':_0x29d4c9[_0xb958('0x17')]?_0x29d4c9[_0xb958('0x17')]:moment()[_0xb958('0x18')]('YYYY-MM-DD\x20HH:mm:ss'),'callback':_0x29d4c9[_0xb958('0x29')]?!![]:![],'callbackuniqueid':_0x29d4c9['callbackUniqueid']?_0x29d4c9[_0xb958('0x29')]:undefined,'callbackat':_0x29d4c9[_0xb958('0x29')]?moment()[_0xb958('0x18')](_0xb958('0x21')):undefined,'CampaignId':_0xf695ca['id']});})[_0xb958('0x2a')](function(_0x461e70){_0x3fb258(_0x461e70);});});});};var _0x241c15=function(_0x1f3142){return new BPromise(function(_0x52a698,_0x1b91d7){_0x2860a3(_0x1f3142,_0x29d4c9)[_0xb958('0x1c')](function(_0x4b392d){_0x29d4c9['scheduledat']=_0x4b392d[_0xb958('0x22')];_0x4ed2b0['CmHopper'][_0xb958('0x24')]({'where':{'phone':_0x29d4c9[_0xb958('0xa')],'CampaignId':_0x1f3142['id']}})[_0xb958('0x1c')](function(_0x539924){if(!_[_0xb958('0x19')](_0x539924)){throw new Error(_0xb958('0x25')+_0x29d4c9[_0xb958('0xa')]+_0xb958('0x31')+_0x1f3142['id']);}return _0x4ed2b0[_0xb958('0x32')][_0xb958('0x24')]({'where':{'calleridnum':_0x29d4c9['phone'],'CampaignId':_0x1f3142['id']}});})[_0xb958('0x1c')](function(_0x5f4c53){if(!_[_0xb958('0x19')](_0x5f4c53)){throw new Error(_0xb958('0x33')+_0x29d4c9['phone']+_0xb958('0x34')+_0x1f3142['id']);}return _0x4ed2b0['CmHopper'][_0xb958('0x27')]({'phone':_0x29d4c9[_0xb958('0xa')],'ContactId':_0x29d4c9['id'],'ListId':_0x29d4c9['ListId'],'priority':_0x29d4c9[_0xb958('0x28')]?_0x29d4c9[_0xb958('0x28')]:0x2,'scheduledat':_0x29d4c9[_0xb958('0x17')]?_0x29d4c9[_0xb958('0x17')]:moment()['format'](_0xb958('0x21')),'callback':_0x29d4c9[_0xb958('0x29')]?!![]:![],'callbackuniqueid':_0x29d4c9[_0xb958('0x29')]?_0x29d4c9[_0xb958('0x29')]:undefined,'callbackat':_0x29d4c9['callbackUniqueid']?moment()[_0xb958('0x18')](_0xb958('0x21')):undefined,'CampaignId':_0x1f3142['id']});})[_0xb958('0x2a')](function(_0x254905){_0x1b91d7(_0x254905);});});});};if(_0x29d4c9[_0xb958('0x2d')]){_0x4ed2b0['VoiceQueue'][_0xb958('0x35')]({'where':{'type':_0xb958('0x36')},'attributes':['id',_0xb958('0x37'),_0xb958('0x1a')],'include':[{'model':_0x4ed2b0[_0xb958('0x38')],'as':_0xb958('0x39'),'where':{'id':_0x29d4c9['ListId']}}]})['then'](function(_0x1af8cb){if(_0x1af8cb){var _0x2fc9aa=[];for(var _0x39156d=0x0,_0x2a9177;_0x39156d<_0x1af8cb[_0xb958('0x3a')];_0x39156d+=0x1){_0x2a9177=_0x1af8cb[_0x39156d][_0xb958('0x13')]({'plain':!![]});switch(_0x2a9177[_0xb958('0x37')]){case _0xb958('0x3b'):_0x165b40(_0x2a9177)[_0xb958('0x2a')](_0x1c584a());break;case'onlyIfOpen':_0x2c1c9a(_0x2a9177)[_0xb958('0x2a')](_0x1c584a());break;default:_0x2860a3(_0x2a9177,_0x29d4c9)[_0xb958('0x1c')](function(_0x223c58){_0x29d4c9[_0xb958('0x17')]=_0x223c58[_0xb958('0x22')];_0x4ed2b0[_0xb958('0x23')][_0xb958('0x27')]({'phone':_0x29d4c9['phone'],'ContactId':_0x29d4c9['id'],'ListId':_0x29d4c9[_0xb958('0x2d')],'scheduledat':_0x29d4c9['scheduledat']?_0x29d4c9['scheduledat']:moment()[_0xb958('0x18')](_0xb958('0x21')),'priority':_0x29d4c9['priority']?_0x29d4c9[_0xb958('0x28')]:0x2,'callback':_0x29d4c9['callbackUniqueid']?!![]:![],'callbackuniqueid':_0x29d4c9[_0xb958('0x29')]?_0x29d4c9['callbackUniqueid']:undefined,'callbackat':_0x29d4c9[_0xb958('0x29')]?moment()[_0xb958('0x18')]('YYYY-MM-DD\x20HH:mm:ss'):undefined,'VoiceQueueId':_0x2a9177['id']})['catch'](_0x1c584a());});}}}})[_0xb958('0x1c')](function(){return _0x4ed2b0['VoiceQueue'][_0xb958('0x35')]({'where':{'type':_0xb958('0x36')},'attributes':['id'],'include':[{'model':_0x4ed2b0[_0xb958('0x38')],'as':_0xb958('0x3c'),'where':{'id':_0x29d4c9[_0xb958('0x2d')]}}]})[_0xb958('0x1c')](function(_0x5a2752){if(_0x5a2752){var _0x5ae493=[];for(var _0x4222bc=0x0,_0x3a2fba;_0x4222bc<_0x5a2752[_0xb958('0x3a')];_0x4222bc+=0x1){_0x3a2fba=_0x5a2752[_0x4222bc][_0xb958('0x13')]({'plain':!![]});_0x4ed2b0[_0xb958('0x3d')][_0xb958('0x27')]({'phone':_0x29d4c9['phone'],'ContactId':_0x29d4c9['id'],'ListId':_0x29d4c9[_0xb958('0x2d')],'VoiceQueueId':_0x3a2fba['id']})['catch'](function(_0x3c81be){logger['error'](_0xb958('0x3e'),_0xb958('0x15'),_0x3c81be[_0xb958('0x3f')]);});}}});})[_0xb958('0x1c')](function(){return _0x4ed2b0[_0xb958('0x2f')][_0xb958('0x35')]({'attributes':['id','dialCheckDuplicateType',_0xb958('0x1a')],'include':[{'model':_0x4ed2b0['CmList'],'as':_0xb958('0x39'),'where':{'id':_0x29d4c9[_0xb958('0x2d')]}}]})[_0xb958('0x1c')](function(_0x15fdab){if(_0x15fdab){var _0x56cdd6=[];for(var _0x200ed8=0x0,_0x1a73dd;_0x200ed8<_0x15fdab[_0xb958('0x3a')];_0x200ed8+=0x1){_0x1a73dd=_0x15fdab[_0x200ed8][_0xb958('0x13')]({'plain':!![]});switch(_0x1a73dd[_0xb958('0x37')]){case _0xb958('0x3b'):_0x241c15(_0x1a73dd)['catch'](_0x5633fc());break;case'onlyIfOpen':_0x5f1540(_0x1a73dd)['catch'](_0x5633fc());break;default:_0x4ed2b0[_0xb958('0x23')][_0xb958('0x27')]({'phone':_0x29d4c9[_0xb958('0xa')],'ContactId':_0x29d4c9['id'],'ListId':_0x29d4c9[_0xb958('0x2d')],'scheduledat':_0x29d4c9['scheduledat']?_0x29d4c9[_0xb958('0x17')]:moment()[_0xb958('0x18')](_0xb958('0x21')),'priority':_0x29d4c9[_0xb958('0x28')]?_0x29d4c9[_0xb958('0x28')]:0x2,'callback':_0x29d4c9[_0xb958('0x29')]?!![]:![],'callbackuniqueid':_0x29d4c9['callbackUniqueid']?_0x29d4c9[_0xb958('0x29')]:undefined,'callbackat':_0x29d4c9['callbackUniqueid']?moment()[_0xb958('0x18')](_0xb958('0x21')):undefined,'CampaignId':_0x1a73dd['id']})[_0xb958('0x2a')](_0x5633fc());}}}});})[_0xb958('0x1c')](function(){return _0x4ed2b0[_0xb958('0x2f')][_0xb958('0x35')]({'attributes':['id'],'include':[{'model':_0x4ed2b0[_0xb958('0x38')],'as':_0xb958('0x3c'),'where':{'id':_0x29d4c9['ListId']}}]})[_0xb958('0x1c')](function(_0x592584){if(_0x592584){var _0x41e495=[];for(var _0x319ebb=0x0,_0x318cbe;_0x319ebb<_0x592584['length'];_0x319ebb+=0x1){_0x318cbe=_0x592584[_0x319ebb][_0xb958('0x13')]({'plain':!![]});_0x4ed2b0[_0xb958('0x3d')][_0xb958('0x27')]({'phone':_0x29d4c9['phone'],'ContactId':_0x29d4c9['id'],'ListId':_0x29d4c9['ListId'],'CampaignId':_0x318cbe['id']})['catch'](function(_0x13161b){logger[_0xb958('0x2e')](_0xb958('0x3e'),_0xb958('0x15'),_0x13161b[_0xb958('0x3f')]);});}}});})[_0xb958('0x1c')](function(){_0x194c1f();})[_0xb958('0x2a')](function(_0x250d31){logger['error'](_0xb958('0x3e'),'afterCreate',_0x250d31['message']);_0x194c1f(_0x250d31);});}else{_0x194c1f(new Error(_0xb958('0x40')));}},'afterDestroy':function(_0x576b77,_0x291f96,_0x4a9ea1){var _0x248b35=_0x2bca8f[_0xb958('0x12')];var _0x3b945c=_0x576b77[_0xb958('0x13')]({'plain':!![]});return _0x248b35['CmHopper'][_0xb958('0x35')]({'raw':!![],'where':{'ListId':_0x3b945c[_0xb958('0x2d')],'ContactId':_0x3b945c['id']}})['then'](function(_0x109809){if(!_[_0xb958('0x41')](_0x109809)){var _0x588546=[];for(var _0x476605=0x0;_0x476605<_0x109809['length'];_0x476605+=0x1){var _0x4ba38d=_0x248b35[_0xb958('0x23')]['destroy']({'where':{'ListId':_0x109809[_0x476605][_0xb958('0x2d')],'ContactId':_0x109809[_0x476605][_0xb958('0x42')],'VoiceQueueId':_0x109809[_0x476605]['VoiceQueueId'],'CampaignId':_0x109809[_0x476605]['CampaignId']}});_0x588546[_0xb958('0x43')](_0x4ba38d);}return BPromise[_0xb958('0x44')](_0x588546);}})[_0xb958('0x1c')](function(_0x3cc5e0){logger[_0xb958('0x45')](_0xb958('0x46'),util[_0xb958('0x16')](_0x3cc5e0,{'showHidden':![],'depth':null}));_0x4a9ea1();})[_0xb958('0x2a')](function(_0x94d96f){logger[_0xb958('0x2e')](_0xb958('0x47'),util[_0xb958('0x16')](_0x94d96f,{'showHidden':![],'depth':null}));_0x4a9ea1(_0x94d96f);});}}});};
\ No newline at end of file