Built motion from commit (unavailable).|2.5.22
[motion2.git] / server / api / cmContact / cmContact.model.js
index 09d4426..5049d5f 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xc373=['destroy','ContactId','VoiceQueueId','push','all','info','[CmContact][afterDestroy][Error]','util','../../config/logger','api','request-promise','path','rimraf','../../config/environment','./cmContact.attributes','exports','define','CmContact','cm_contacts','phone','fti_cm_contacts','firstName','lastName','email','FULLTEXT','models','get','afterCreate','CmHopper','findOne','then','isNil','\x20contact\x20not\x20insert\x20in\x20hopper,\x20check\x20duplicate\x20onlyIfOpen,\x20exist\x20in\x20hopper\x20VoiceQueue\x20','ListId','priority','scheduledat','YYYY-MM-DD\x20HH:mm:ss','callbackUniqueid','format','catch','\x20contact\x20not\x20insert\x20in\x20hopper,\x20check\x20duplicate\x20always,\x20exist\x20in\x20hopper\x20VoiceQueue\x20','CmHopperFinal','cmContact,\x20afterCreate,\x20','create','error','inspect','\x20contact\x20not\x20insert\x20in\x20hopper,\x20check\x20duplicate\x20onlyIfOpen,\x20exist\x20in\x20hopper\x20Campaign\x20','cmContact,\x20afterCreate\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','VoiceQueue','outbound','dialCheckDuplicateType','CmList','Lists','length','onlyIfOpen','findAll','BlackLists','CmHopperBlack','cmContact,\x20%s,\x20%s','message','Campaign','isEmpty'];(function(_0x15c3f2,_0x2f59bc){var _0x1decfe=function(_0x2e394c){while(--_0x2e394c){_0x15c3f2['push'](_0x15c3f2['shift']());}};_0x1decfe(++_0x2f59bc);}(_0xc373,0x1c7));var _0x3c37=function(_0x53afa6,_0x59e786){_0x53afa6=_0x53afa6-0x0;var _0x51f86a=_0xc373[_0x53afa6];return _0x51f86a;};'use strict';var _=require('lodash');var util=require(_0x3c37('0x0'));var logger=require(_0x3c37('0x1'))(_0x3c37('0x2'));var moment=require('moment');var BPromise=require('bluebird');var rp=require(_0x3c37('0x3'));var fs=require('fs');var path=require(_0x3c37('0x4'));var rimraf=require(_0x3c37('0x5'));var config=require(_0x3c37('0x6'));var attributes=require(_0x3c37('0x7'));module[_0x3c37('0x8')]=function(_0x5b05c6,_0x4c71cc){return _0x5b05c6[_0x3c37('0x9')](_0x3c37('0xa'),attributes,{'tableName':_0x3c37('0xb'),'paranoid':!![],'indexes':[{'name':_0x3c37('0xc'),'fields':[_0x3c37('0xc')]},{'name':_0x3c37('0xd'),'fields':[_0x3c37('0xe'),_0x3c37('0xf'),_0x3c37('0xc'),'mobile','fax',_0x3c37('0x10')],'type':_0x3c37('0x11')}],'timestamps':!![],'hooks':{'afterCreate':function(_0x2beb44,_0x141def,_0x17a164){var _0x27ec3d=_0x5b05c6[_0x3c37('0x12')];var _0x5e29ba=_0x2beb44[_0x3c37('0x13')]({'plain':!![]});function _0x454f92(){return function(_0x458002){logger['error']('cmContact',_0x3c37('0x14'),util['inspect'](_0x458002,{'showHidden':![],'depth':null}));};}var _0x52ab1f=function(_0x37904b){return new BPromise(function(_0x3be8b3,_0x2eca76){_0x27ec3d[_0x3c37('0x15')][_0x3c37('0x16')]({'where':{'phone':_0x5e29ba[_0x3c37('0xc')],'VoiceQueueId':_0x37904b['id']}})[_0x3c37('0x17')](function(_0x40d3ee){if(!_[_0x3c37('0x18')](_0x40d3ee)){throw new Error('cmContact,\x20afterCreate\x20'+_0x5e29ba[_0x3c37('0xc')]+_0x3c37('0x19')+_0x37904b['id']);}return _0x27ec3d['CmHopper']['create']({'phone':_0x5e29ba[_0x3c37('0xc')],'ContactId':_0x5e29ba['id'],'ListId':_0x5e29ba[_0x3c37('0x1a')],'priority':_0x5e29ba[_0x3c37('0x1b')]?_0x5e29ba[_0x3c37('0x1b')]:0x2,'scheduledat':_0x5e29ba[_0x3c37('0x1c')]?_0x5e29ba[_0x3c37('0x1c')]:moment()['format'](_0x3c37('0x1d')),'callback':_0x5e29ba['callbackUniqueid']?!![]:![],'callbackuniqueid':_0x5e29ba['callbackUniqueid']?_0x5e29ba[_0x3c37('0x1e')]:undefined,'callbackat':_0x5e29ba[_0x3c37('0x1e')]?moment()[_0x3c37('0x1f')](_0x3c37('0x1d')):undefined,'VoiceQueueId':_0x37904b['id']});})[_0x3c37('0x20')](function(_0x5903ee){_0x2eca76(_0x5903ee);});});};var _0x27f83e=function(_0x54776f){return new BPromise(function(_0x3399a7,_0x510baf){_0x27ec3d[_0x3c37('0x15')][_0x3c37('0x16')]({'where':{'phone':_0x5e29ba[_0x3c37('0xc')],'VoiceQueueId':_0x54776f['id']}})['then'](function(_0x51d25d){if(!_['isNil'](_0x51d25d)){throw new Error('cmContact,\x20afterCreate\x20'+_0x5e29ba['phone']+_0x3c37('0x21')+_0x54776f['id']);}return _0x27ec3d[_0x3c37('0x22')][_0x3c37('0x16')]({'where':{'calleridnum':_0x5e29ba[_0x3c37('0xc')],'VoiceQueueId':_0x54776f['id']}});})['then'](function(_0x52b5d9){if(!_['isNil'](_0x52b5d9)){throw new Error(_0x3c37('0x23')+_0x5e29ba[_0x3c37('0xc')]+'\x20contact\x20not\x20insert\x20in\x20hopper,\x20check\x20duplicate\x20always,\x20exist\x20in\x20hopperFinal\x20VoiceQueue\x20'+_0x54776f['id']);}return _0x27ec3d['CmHopper'][_0x3c37('0x24')]({'phone':_0x5e29ba[_0x3c37('0xc')],'ContactId':_0x5e29ba['id'],'ListId':_0x5e29ba[_0x3c37('0x1a')],'priority':_0x5e29ba[_0x3c37('0x1b')]?_0x5e29ba[_0x3c37('0x1b')]:0x2,'scheduledat':_0x5e29ba[_0x3c37('0x1c')]?_0x5e29ba[_0x3c37('0x1c')]:moment()[_0x3c37('0x1f')](_0x3c37('0x1d')),'callback':_0x5e29ba[_0x3c37('0x1e')]?!![]:![],'callbackuniqueid':_0x5e29ba['callbackUniqueid']?_0x5e29ba[_0x3c37('0x1e')]:undefined,'callbackat':_0x5e29ba[_0x3c37('0x1e')]?moment()['format']('YYYY-MM-DD\x20HH:mm:ss'):undefined,'VoiceQueueId':_0x54776f['id']});})[_0x3c37('0x20')](function(_0x3bc99a){_0x510baf(_0x3bc99a);});});};function _0x35590b(){return function(_0x4aefd0){logger[_0x3c37('0x25')]('cmContact',_0x3c37('0x14'),util[_0x3c37('0x26')](_0x4aefd0,{'showHidden':![],'depth':null}));};}var _0x2596d6=function(_0x45caee){return new BPromise(function(_0x20083e,_0x248ad6){_0x27ec3d[_0x3c37('0x15')][_0x3c37('0x16')]({'where':{'phone':_0x5e29ba[_0x3c37('0xc')],'CampaignId':_0x45caee['id']}})[_0x3c37('0x17')](function(_0x4bd569){if(!_['isNil'](_0x4bd569)){throw new Error('cmContact,\x20afterCreate\x20'+_0x5e29ba[_0x3c37('0xc')]+_0x3c37('0x27')+_0x45caee['id']);}return _0x27ec3d[_0x3c37('0x15')][_0x3c37('0x24')]({'phone':_0x5e29ba[_0x3c37('0xc')],'ContactId':_0x5e29ba['id'],'ListId':_0x5e29ba[_0x3c37('0x1a')],'priority':_0x5e29ba[_0x3c37('0x1b')]?_0x5e29ba[_0x3c37('0x1b')]:0x2,'scheduledat':_0x5e29ba[_0x3c37('0x1c')]?_0x5e29ba[_0x3c37('0x1c')]:moment()[_0x3c37('0x1f')](_0x3c37('0x1d')),'callback':_0x5e29ba['callbackUniqueid']?!![]:![],'callbackuniqueid':_0x5e29ba[_0x3c37('0x1e')]?_0x5e29ba[_0x3c37('0x1e')]:undefined,'callbackat':_0x5e29ba['callbackUniqueid']?moment()['format'](_0x3c37('0x1d')):undefined,'CampaignId':_0x45caee['id']});})[_0x3c37('0x20')](function(_0x3c43a7){_0x248ad6(_0x3c43a7);});});};var _0x43a3f2=function(_0x2ac6e6){return new BPromise(function(_0x46c745,_0x466b28){_0x27ec3d[_0x3c37('0x15')][_0x3c37('0x16')]({'where':{'phone':_0x5e29ba['phone'],'CampaignId':_0x2ac6e6['id']}})[_0x3c37('0x17')](function(_0x38501f){if(!_[_0x3c37('0x18')](_0x38501f)){throw new Error(_0x3c37('0x28')+_0x5e29ba[_0x3c37('0xc')]+_0x3c37('0x29')+_0x2ac6e6['id']);}return _0x27ec3d[_0x3c37('0x22')][_0x3c37('0x16')]({'where':{'calleridnum':_0x5e29ba[_0x3c37('0xc')],'CampaignId':_0x2ac6e6['id']}});})[_0x3c37('0x17')](function(_0x4ca5d7){if(!_[_0x3c37('0x18')](_0x4ca5d7)){throw new Error(_0x3c37('0x23')+_0x5e29ba[_0x3c37('0xc')]+_0x3c37('0x2a')+_0x2ac6e6['id']);}return _0x27ec3d[_0x3c37('0x15')]['create']({'phone':_0x5e29ba[_0x3c37('0xc')],'ContactId':_0x5e29ba['id'],'ListId':_0x5e29ba[_0x3c37('0x1a')],'priority':_0x5e29ba[_0x3c37('0x1b')]?_0x5e29ba[_0x3c37('0x1b')]:0x2,'scheduledat':_0x5e29ba['scheduledat']?_0x5e29ba[_0x3c37('0x1c')]:moment()['format'](_0x3c37('0x1d')),'callback':_0x5e29ba['callbackUniqueid']?!![]:![],'callbackuniqueid':_0x5e29ba[_0x3c37('0x1e')]?_0x5e29ba[_0x3c37('0x1e')]:undefined,'callbackat':_0x5e29ba[_0x3c37('0x1e')]?moment()['format'](_0x3c37('0x1d')):undefined,'CampaignId':_0x2ac6e6['id']});})[_0x3c37('0x20')](function(_0x2e82d0){_0x466b28(_0x2e82d0);});});};if(_0x5e29ba[_0x3c37('0x1a')]){_0x27ec3d[_0x3c37('0x2b')]['findAll']({'where':{'type':_0x3c37('0x2c')},'attributes':['id',_0x3c37('0x2d')],'include':[{'model':_0x27ec3d[_0x3c37('0x2e')],'as':_0x3c37('0x2f'),'where':{'id':_0x5e29ba[_0x3c37('0x1a')]}}]})[_0x3c37('0x17')](function(_0x35f8a2){if(_0x35f8a2){var _0x5e60eb=[];for(var _0x474358=0x0,_0x228f01;_0x474358<_0x35f8a2[_0x3c37('0x30')];_0x474358+=0x1){_0x228f01=_0x35f8a2[_0x474358]['get']({'plain':!![]});switch(_0x228f01[_0x3c37('0x2d')]){case'always':_0x27f83e(_0x228f01)[_0x3c37('0x20')](_0x454f92());break;case _0x3c37('0x31'):_0x52ab1f(_0x228f01)[_0x3c37('0x20')](_0x454f92());break;default:_0x27ec3d[_0x3c37('0x15')]['create']({'phone':_0x5e29ba['phone'],'ContactId':_0x5e29ba['id'],'ListId':_0x5e29ba['ListId'],'scheduledat':_0x5e29ba[_0x3c37('0x1c')]?_0x5e29ba[_0x3c37('0x1c')]:moment()['format']('YYYY-MM-DD\x20HH:mm:ss'),'priority':_0x5e29ba[_0x3c37('0x1b')]?_0x5e29ba['priority']:0x2,'callback':_0x5e29ba[_0x3c37('0x1e')]?!![]:![],'callbackuniqueid':_0x5e29ba[_0x3c37('0x1e')]?_0x5e29ba[_0x3c37('0x1e')]:undefined,'callbackat':_0x5e29ba[_0x3c37('0x1e')]?moment()[_0x3c37('0x1f')](_0x3c37('0x1d')):undefined,'VoiceQueueId':_0x228f01['id']})[_0x3c37('0x20')](_0x454f92());}}}})[_0x3c37('0x17')](function(){return _0x27ec3d[_0x3c37('0x2b')][_0x3c37('0x32')]({'where':{'type':_0x3c37('0x2c')},'attributes':['id'],'include':[{'model':_0x27ec3d['CmList'],'as':_0x3c37('0x33'),'where':{'id':_0x5e29ba[_0x3c37('0x1a')]}}]})['then'](function(_0x173551){if(_0x173551){var _0x359f9c=[];for(var _0x42ddf4=0x0,_0x5a2351;_0x42ddf4<_0x173551[_0x3c37('0x30')];_0x42ddf4+=0x1){_0x5a2351=_0x173551[_0x42ddf4]['get']({'plain':!![]});_0x27ec3d[_0x3c37('0x34')][_0x3c37('0x24')]({'phone':_0x5e29ba[_0x3c37('0xc')],'ContactId':_0x5e29ba['id'],'ListId':_0x5e29ba['ListId'],'VoiceQueueId':_0x5a2351['id']})[_0x3c37('0x20')](function(_0x415bac){logger[_0x3c37('0x25')](_0x3c37('0x35'),_0x3c37('0x14'),_0x415bac[_0x3c37('0x36')]);});}}});})[_0x3c37('0x17')](function(){return _0x27ec3d[_0x3c37('0x37')][_0x3c37('0x32')]({'attributes':['id',_0x3c37('0x2d')],'include':[{'model':_0x27ec3d[_0x3c37('0x2e')],'as':_0x3c37('0x2f'),'where':{'id':_0x5e29ba[_0x3c37('0x1a')]}}]})['then'](function(_0xed6864){if(_0xed6864){var _0x294ea3=[];for(var _0xd9f15d=0x0,_0x5803a6;_0xd9f15d<_0xed6864[_0x3c37('0x30')];_0xd9f15d+=0x1){_0x5803a6=_0xed6864[_0xd9f15d][_0x3c37('0x13')]({'plain':!![]});switch(_0x5803a6[_0x3c37('0x2d')]){case'always':_0x43a3f2(_0x5803a6)[_0x3c37('0x20')](_0x35590b());break;case _0x3c37('0x31'):_0x2596d6(_0x5803a6)[_0x3c37('0x20')](_0x35590b());break;default:_0x27ec3d[_0x3c37('0x15')][_0x3c37('0x24')]({'phone':_0x5e29ba['phone'],'ContactId':_0x5e29ba['id'],'ListId':_0x5e29ba[_0x3c37('0x1a')],'scheduledat':_0x5e29ba[_0x3c37('0x1c')]?_0x5e29ba[_0x3c37('0x1c')]:moment()[_0x3c37('0x1f')]('YYYY-MM-DD\x20HH:mm:ss'),'priority':_0x5e29ba['priority']?_0x5e29ba[_0x3c37('0x1b')]:0x2,'callback':_0x5e29ba['callbackUniqueid']?!![]:![],'callbackuniqueid':_0x5e29ba[_0x3c37('0x1e')]?_0x5e29ba[_0x3c37('0x1e')]:undefined,'callbackat':_0x5e29ba[_0x3c37('0x1e')]?moment()[_0x3c37('0x1f')]('YYYY-MM-DD\x20HH:mm:ss'):undefined,'CampaignId':_0x5803a6['id']})[_0x3c37('0x20')](_0x35590b());}}}});})[_0x3c37('0x17')](function(){return _0x27ec3d[_0x3c37('0x37')][_0x3c37('0x32')]({'attributes':['id'],'include':[{'model':_0x27ec3d['CmList'],'as':_0x3c37('0x33'),'where':{'id':_0x5e29ba[_0x3c37('0x1a')]}}]})['then'](function(_0x548e2d){if(_0x548e2d){var _0x41117f=[];for(var _0x521fde=0x0,_0x38fabf;_0x521fde<_0x548e2d[_0x3c37('0x30')];_0x521fde+=0x1){_0x38fabf=_0x548e2d[_0x521fde][_0x3c37('0x13')]({'plain':!![]});_0x27ec3d[_0x3c37('0x34')]['create']({'phone':_0x5e29ba[_0x3c37('0xc')],'ContactId':_0x5e29ba['id'],'ListId':_0x5e29ba['ListId'],'CampaignId':_0x38fabf['id']})[_0x3c37('0x20')](function(_0xfda3a2){logger[_0x3c37('0x25')](_0x3c37('0x35'),'afterCreate',_0xfda3a2[_0x3c37('0x36')]);});}}});})['then'](function(){_0x17a164();})[_0x3c37('0x20')](function(_0x6e6cfe){logger[_0x3c37('0x25')]('cmContact,\x20%s,\x20%s',_0x3c37('0x14'),_0x6e6cfe[_0x3c37('0x36')]);_0x17a164(_0x6e6cfe);});}else{_0x17a164(new Error('List\x20not\x20found'));}},'afterDestroy':function(_0x415627,_0x22a86c,_0x1d5c6f){var _0x5964d4=_0x5b05c6[_0x3c37('0x12')];var _0x3608c6=_0x415627['get']({'plain':!![]});return _0x5964d4['CmHopper']['findAll']({'raw':!![],'where':{'ListId':_0x3608c6[_0x3c37('0x1a')],'ContactId':_0x3608c6['id']}})[_0x3c37('0x17')](function(_0x1fef45){if(!_[_0x3c37('0x38')](_0x1fef45)){var _0x111d05=[];for(var _0x42e3db=0x0;_0x42e3db<_0x1fef45[_0x3c37('0x30')];_0x42e3db+=0x1){var _0x53455c=_0x5964d4[_0x3c37('0x15')][_0x3c37('0x39')]({'where':{'ListId':_0x1fef45[_0x42e3db][_0x3c37('0x1a')],'ContactId':_0x1fef45[_0x42e3db][_0x3c37('0x3a')],'VoiceQueueId':_0x1fef45[_0x42e3db][_0x3c37('0x3b')],'CampaignId':_0x1fef45[_0x42e3db]['CampaignId']}});_0x111d05[_0x3c37('0x3c')](_0x53455c);}return BPromise[_0x3c37('0x3d')](_0x111d05);}})[_0x3c37('0x17')](function(_0x34b8ec){logger[_0x3c37('0x3e')]('[CmContact][afterDestroy][Succesfull]',util[_0x3c37('0x26')](_0x34b8ec,{'showHidden':![],'depth':null}));_0x1d5c6f();})[_0x3c37('0x20')](function(_0x7972a3){logger[_0x3c37('0x25')](_0x3c37('0x3f'),util['inspect'](_0x7972a3,{'showHidden':![],'depth':null}));_0x1d5c6f(_0x7972a3);});}}});};
\ No newline at end of file
+var _0x1ab1=['exports','define','CmContact','cm_contacts','phone','fti_cm_contacts','lastName','mobile','fax','email','FULLTEXT','models','error','cmContact','afterCreate','findOne','then','isNil','cmContact,\x20afterCreate\x20','CmHopper','create','ListId','priority','scheduledat','format','YYYY-MM-DD\x20HH:mm:ss','callbackUniqueid','catch','CmHopperFinal','\x20contact\x20not\x20insert\x20in\x20hopper,\x20check\x20duplicate\x20always,\x20exist\x20in\x20hopperFinal\x20VoiceQueue\x20','inspect','\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','VoiceQueue','findAll','outbound','dialCheckDuplicateType','Lists','onlyIfOpen','length','get','CmHopperBlack','cmContact,\x20%s,\x20%s','Campaign','CmList','always','BlackLists','message','List\x20not\x20found','isEmpty','ContactId','VoiceQueueId','all','info','[CmContact][afterDestroy][Error]','lodash','api','path','../../config/environment','./cmContact.attributes'];(function(_0x51a03c,_0x28e37a){var _0x4d9b98=function(_0x3aa944){while(--_0x3aa944){_0x51a03c['push'](_0x51a03c['shift']());}};_0x4d9b98(++_0x28e37a);}(_0x1ab1,0x12c));var _0x11ab=function(_0x5dbc65,_0x27acb2){_0x5dbc65=_0x5dbc65-0x0;var _0x107a6f=_0x1ab1[_0x5dbc65];return _0x107a6f;};'use strict';var _=require(_0x11ab('0x0'));var util=require('util');var logger=require('../../config/logger')(_0x11ab('0x1'));var moment=require('moment');var BPromise=require('bluebird');var rp=require('request-promise');var fs=require('fs');var path=require(_0x11ab('0x2'));var rimraf=require('rimraf');var config=require(_0x11ab('0x3'));var attributes=require(_0x11ab('0x4'));module[_0x11ab('0x5')]=function(_0x1399f4,_0x5758c5){return _0x1399f4[_0x11ab('0x6')](_0x11ab('0x7'),attributes,{'tableName':_0x11ab('0x8'),'paranoid':!![],'indexes':[{'name':_0x11ab('0x9'),'fields':[_0x11ab('0x9')]},{'name':_0x11ab('0xa'),'fields':['firstName',_0x11ab('0xb'),'phone',_0x11ab('0xc'),_0x11ab('0xd'),_0x11ab('0xe')],'type':_0x11ab('0xf')}],'timestamps':!![],'hooks':{'afterCreate':function(_0x57cb21,_0x1ab643,_0x225793){var _0x410ab0=_0x1399f4[_0x11ab('0x10')];var _0x5e6436=_0x57cb21['get']({'plain':!![]});function _0x45202d(){return function(_0x2d772f){logger[_0x11ab('0x11')](_0x11ab('0x12'),_0x11ab('0x13'),util['inspect'](_0x2d772f,{'showHidden':![],'depth':null}));};}var _0x33b5a8=function(_0x43f5d6){return new BPromise(function(_0x215b33,_0x1d8a39){_0x410ab0['CmHopper'][_0x11ab('0x14')]({'where':{'phone':_0x5e6436[_0x11ab('0x9')],'VoiceQueueId':_0x43f5d6['id']}})[_0x11ab('0x15')](function(_0x223b80){if(!_[_0x11ab('0x16')](_0x223b80)){throw new Error(_0x11ab('0x17')+_0x5e6436[_0x11ab('0x9')]+'\x20contact\x20not\x20insert\x20in\x20hopper,\x20check\x20duplicate\x20onlyIfOpen,\x20exist\x20in\x20hopper\x20VoiceQueue\x20'+_0x43f5d6['id']);}return _0x410ab0[_0x11ab('0x18')][_0x11ab('0x19')]({'phone':_0x5e6436[_0x11ab('0x9')],'ContactId':_0x5e6436['id'],'ListId':_0x5e6436[_0x11ab('0x1a')],'priority':_0x5e6436[_0x11ab('0x1b')]?_0x5e6436[_0x11ab('0x1b')]:0x2,'scheduledat':_0x5e6436[_0x11ab('0x1c')]?_0x5e6436['scheduledat']:moment()[_0x11ab('0x1d')](_0x11ab('0x1e')),'callback':_0x5e6436[_0x11ab('0x1f')]?!![]:![],'callbackuniqueid':_0x5e6436[_0x11ab('0x1f')]?_0x5e6436[_0x11ab('0x1f')]:undefined,'callbackat':_0x5e6436['callbackUniqueid']?moment()['format'](_0x11ab('0x1e')):undefined,'VoiceQueueId':_0x43f5d6['id']});})[_0x11ab('0x20')](function(_0x2752d3){_0x1d8a39(_0x2752d3);});});};var _0x27fdfd=function(_0x22b406){return new BPromise(function(_0x333b18,_0x9df86e){_0x410ab0['CmHopper']['findOne']({'where':{'phone':_0x5e6436[_0x11ab('0x9')],'VoiceQueueId':_0x22b406['id']}})[_0x11ab('0x15')](function(_0x1bae08){if(!_[_0x11ab('0x16')](_0x1bae08)){throw new Error(_0x11ab('0x17')+_0x5e6436[_0x11ab('0x9')]+'\x20contact\x20not\x20insert\x20in\x20hopper,\x20check\x20duplicate\x20always,\x20exist\x20in\x20hopper\x20VoiceQueue\x20'+_0x22b406['id']);}return _0x410ab0[_0x11ab('0x21')][_0x11ab('0x14')]({'where':{'calleridnum':_0x5e6436[_0x11ab('0x9')],'VoiceQueueId':_0x22b406['id']}});})[_0x11ab('0x15')](function(_0x3aeaee){if(!_['isNil'](_0x3aeaee)){throw new Error('cmContact,\x20afterCreate,\x20'+_0x5e6436[_0x11ab('0x9')]+_0x11ab('0x22')+_0x22b406['id']);}return _0x410ab0[_0x11ab('0x18')][_0x11ab('0x19')]({'phone':_0x5e6436[_0x11ab('0x9')],'ContactId':_0x5e6436['id'],'ListId':_0x5e6436[_0x11ab('0x1a')],'priority':_0x5e6436[_0x11ab('0x1b')]?_0x5e6436['priority']:0x2,'scheduledat':_0x5e6436[_0x11ab('0x1c')]?_0x5e6436[_0x11ab('0x1c')]:moment()[_0x11ab('0x1d')](_0x11ab('0x1e')),'callback':_0x5e6436[_0x11ab('0x1f')]?!![]:![],'callbackuniqueid':_0x5e6436[_0x11ab('0x1f')]?_0x5e6436[_0x11ab('0x1f')]:undefined,'callbackat':_0x5e6436['callbackUniqueid']?moment()[_0x11ab('0x1d')](_0x11ab('0x1e')):undefined,'VoiceQueueId':_0x22b406['id']});})[_0x11ab('0x20')](function(_0x46fc84){_0x9df86e(_0x46fc84);});});};function _0x224bca(){return function(_0x41ccc1){logger['error'](_0x11ab('0x12'),'afterCreate',util[_0x11ab('0x23')](_0x41ccc1,{'showHidden':![],'depth':null}));};}var _0x2ced09=function(_0x34f805){return new BPromise(function(_0xdc3177,_0x313fc4){_0x410ab0[_0x11ab('0x18')]['findOne']({'where':{'phone':_0x5e6436[_0x11ab('0x9')],'CampaignId':_0x34f805['id']}})[_0x11ab('0x15')](function(_0x5c5832){if(!_[_0x11ab('0x16')](_0x5c5832)){throw new Error(_0x11ab('0x17')+_0x5e6436[_0x11ab('0x9')]+_0x11ab('0x24')+_0x34f805['id']);}return _0x410ab0[_0x11ab('0x18')]['create']({'phone':_0x5e6436[_0x11ab('0x9')],'ContactId':_0x5e6436['id'],'ListId':_0x5e6436[_0x11ab('0x1a')],'priority':_0x5e6436[_0x11ab('0x1b')]?_0x5e6436[_0x11ab('0x1b')]:0x2,'scheduledat':_0x5e6436[_0x11ab('0x1c')]?_0x5e6436[_0x11ab('0x1c')]:moment()[_0x11ab('0x1d')](_0x11ab('0x1e')),'callback':_0x5e6436[_0x11ab('0x1f')]?!![]:![],'callbackuniqueid':_0x5e6436[_0x11ab('0x1f')]?_0x5e6436['callbackUniqueid']:undefined,'callbackat':_0x5e6436[_0x11ab('0x1f')]?moment()['format'](_0x11ab('0x1e')):undefined,'CampaignId':_0x34f805['id']});})[_0x11ab('0x20')](function(_0x5a2956){_0x313fc4(_0x5a2956);});});};var _0x3763c1=function(_0x1c1efc){return new BPromise(function(_0x4b98d8,_0x40a783){_0x410ab0[_0x11ab('0x18')][_0x11ab('0x14')]({'where':{'phone':_0x5e6436[_0x11ab('0x9')],'CampaignId':_0x1c1efc['id']}})[_0x11ab('0x15')](function(_0x354307){if(!_[_0x11ab('0x16')](_0x354307)){throw new Error(_0x11ab('0x17')+_0x5e6436[_0x11ab('0x9')]+_0x11ab('0x25')+_0x1c1efc['id']);}return _0x410ab0['CmHopperFinal'][_0x11ab('0x14')]({'where':{'calleridnum':_0x5e6436[_0x11ab('0x9')],'CampaignId':_0x1c1efc['id']}});})[_0x11ab('0x15')](function(_0x138fbc){if(!_[_0x11ab('0x16')](_0x138fbc)){throw new Error('cmContact,\x20afterCreate,\x20'+_0x5e6436[_0x11ab('0x9')]+_0x11ab('0x26')+_0x1c1efc['id']);}return _0x410ab0['CmHopper']['create']({'phone':_0x5e6436[_0x11ab('0x9')],'ContactId':_0x5e6436['id'],'ListId':_0x5e6436[_0x11ab('0x1a')],'priority':_0x5e6436[_0x11ab('0x1b')]?_0x5e6436['priority']:0x2,'scheduledat':_0x5e6436[_0x11ab('0x1c')]?_0x5e6436['scheduledat']:moment()[_0x11ab('0x1d')](_0x11ab('0x1e')),'callback':_0x5e6436['callbackUniqueid']?!![]:![],'callbackuniqueid':_0x5e6436[_0x11ab('0x1f')]?_0x5e6436[_0x11ab('0x1f')]:undefined,'callbackat':_0x5e6436['callbackUniqueid']?moment()[_0x11ab('0x1d')](_0x11ab('0x1e')):undefined,'CampaignId':_0x1c1efc['id']});})[_0x11ab('0x20')](function(_0x38f585){_0x40a783(_0x38f585);});});};if(_0x5e6436[_0x11ab('0x1a')]){_0x410ab0[_0x11ab('0x27')][_0x11ab('0x28')]({'where':{'type':_0x11ab('0x29')},'attributes':['id',_0x11ab('0x2a')],'include':[{'model':_0x410ab0['CmList'],'as':_0x11ab('0x2b'),'where':{'id':_0x5e6436['ListId']}}]})[_0x11ab('0x15')](function(_0x18c7ad){if(_0x18c7ad){var _0x1a262f=[];for(var _0x31d637=0x0,_0x48d45a;_0x31d637<_0x18c7ad['length'];_0x31d637+=0x1){_0x48d45a=_0x18c7ad[_0x31d637]['get']({'plain':!![]});switch(_0x48d45a[_0x11ab('0x2a')]){case'always':_0x27fdfd(_0x48d45a)['catch'](_0x45202d());break;case _0x11ab('0x2c'):_0x33b5a8(_0x48d45a)[_0x11ab('0x20')](_0x45202d());break;default:_0x410ab0[_0x11ab('0x18')][_0x11ab('0x19')]({'phone':_0x5e6436['phone'],'ContactId':_0x5e6436['id'],'ListId':_0x5e6436['ListId'],'scheduledat':_0x5e6436[_0x11ab('0x1c')]?_0x5e6436[_0x11ab('0x1c')]:moment()[_0x11ab('0x1d')]('YYYY-MM-DD\x20HH:mm:ss'),'priority':_0x5e6436['priority']?_0x5e6436[_0x11ab('0x1b')]:0x2,'callback':_0x5e6436[_0x11ab('0x1f')]?!![]:![],'callbackuniqueid':_0x5e6436[_0x11ab('0x1f')]?_0x5e6436[_0x11ab('0x1f')]:undefined,'callbackat':_0x5e6436['callbackUniqueid']?moment()[_0x11ab('0x1d')](_0x11ab('0x1e')):undefined,'VoiceQueueId':_0x48d45a['id']})[_0x11ab('0x20')](_0x45202d());}}}})['then'](function(){return _0x410ab0['VoiceQueue']['findAll']({'where':{'type':_0x11ab('0x29')},'attributes':['id'],'include':[{'model':_0x410ab0['CmList'],'as':'BlackLists','where':{'id':_0x5e6436[_0x11ab('0x1a')]}}]})[_0x11ab('0x15')](function(_0x1f965e){if(_0x1f965e){var _0xcbe5c7=[];for(var _0x27f875=0x0,_0x51ff46;_0x27f875<_0x1f965e[_0x11ab('0x2d')];_0x27f875+=0x1){_0x51ff46=_0x1f965e[_0x27f875][_0x11ab('0x2e')]({'plain':!![]});_0x410ab0[_0x11ab('0x2f')]['create']({'phone':_0x5e6436[_0x11ab('0x9')],'ContactId':_0x5e6436['id'],'ListId':_0x5e6436[_0x11ab('0x1a')],'VoiceQueueId':_0x51ff46['id']})[_0x11ab('0x20')](function(_0x627714){logger[_0x11ab('0x11')](_0x11ab('0x30'),_0x11ab('0x13'),_0x627714['message']);});}}});})['then'](function(){return _0x410ab0[_0x11ab('0x31')]['findAll']({'attributes':['id',_0x11ab('0x2a')],'include':[{'model':_0x410ab0[_0x11ab('0x32')],'as':'Lists','where':{'id':_0x5e6436[_0x11ab('0x1a')]}}]})[_0x11ab('0x15')](function(_0x2c286e){if(_0x2c286e){var _0x2ed9db=[];for(var _0xc3a3d0=0x0,_0x23d80e;_0xc3a3d0<_0x2c286e[_0x11ab('0x2d')];_0xc3a3d0+=0x1){_0x23d80e=_0x2c286e[_0xc3a3d0][_0x11ab('0x2e')]({'plain':!![]});switch(_0x23d80e[_0x11ab('0x2a')]){case _0x11ab('0x33'):_0x3763c1(_0x23d80e)[_0x11ab('0x20')](_0x224bca());break;case _0x11ab('0x2c'):_0x2ced09(_0x23d80e)['catch'](_0x224bca());break;default:_0x410ab0[_0x11ab('0x18')][_0x11ab('0x19')]({'phone':_0x5e6436[_0x11ab('0x9')],'ContactId':_0x5e6436['id'],'ListId':_0x5e6436[_0x11ab('0x1a')],'scheduledat':_0x5e6436[_0x11ab('0x1c')]?_0x5e6436['scheduledat']:moment()[_0x11ab('0x1d')](_0x11ab('0x1e')),'priority':_0x5e6436[_0x11ab('0x1b')]?_0x5e6436[_0x11ab('0x1b')]:0x2,'callback':_0x5e6436[_0x11ab('0x1f')]?!![]:![],'callbackuniqueid':_0x5e6436[_0x11ab('0x1f')]?_0x5e6436[_0x11ab('0x1f')]:undefined,'callbackat':_0x5e6436[_0x11ab('0x1f')]?moment()[_0x11ab('0x1d')](_0x11ab('0x1e')):undefined,'CampaignId':_0x23d80e['id']})[_0x11ab('0x20')](_0x224bca());}}}});})[_0x11ab('0x15')](function(){return _0x410ab0['Campaign'][_0x11ab('0x28')]({'attributes':['id'],'include':[{'model':_0x410ab0[_0x11ab('0x32')],'as':_0x11ab('0x34'),'where':{'id':_0x5e6436[_0x11ab('0x1a')]}}]})[_0x11ab('0x15')](function(_0x5d8a9d){if(_0x5d8a9d){var _0x14625f=[];for(var _0x36369a=0x0,_0x2b227e;_0x36369a<_0x5d8a9d[_0x11ab('0x2d')];_0x36369a+=0x1){_0x2b227e=_0x5d8a9d[_0x36369a][_0x11ab('0x2e')]({'plain':!![]});_0x410ab0['CmHopperBlack'][_0x11ab('0x19')]({'phone':_0x5e6436['phone'],'ContactId':_0x5e6436['id'],'ListId':_0x5e6436[_0x11ab('0x1a')],'CampaignId':_0x2b227e['id']})[_0x11ab('0x20')](function(_0x3c9337){logger[_0x11ab('0x11')](_0x11ab('0x30'),_0x11ab('0x13'),_0x3c9337[_0x11ab('0x35')]);});}}});})[_0x11ab('0x15')](function(){_0x225793();})[_0x11ab('0x20')](function(_0x42b4a2){logger['error'](_0x11ab('0x30'),_0x11ab('0x13'),_0x42b4a2['message']);_0x225793(_0x42b4a2);});}else{_0x225793(new Error(_0x11ab('0x36')));}},'afterDestroy':function(_0x20cef5,_0x2b7755,_0x2eb9cd){var _0x2c52f1=_0x1399f4[_0x11ab('0x10')];var _0x2c6abe=_0x20cef5[_0x11ab('0x2e')]({'plain':!![]});return _0x2c52f1['CmHopper']['findAll']({'raw':!![],'where':{'ListId':_0x2c6abe[_0x11ab('0x1a')],'ContactId':_0x2c6abe['id']}})['then'](function(_0x4a0010){if(!_[_0x11ab('0x37')](_0x4a0010)){var _0xf7799a=[];for(var _0x5f4cbf=0x0;_0x5f4cbf<_0x4a0010['length'];_0x5f4cbf+=0x1){var _0x2f0daa=_0x2c52f1[_0x11ab('0x18')]['destroy']({'where':{'ListId':_0x4a0010[_0x5f4cbf]['ListId'],'ContactId':_0x4a0010[_0x5f4cbf][_0x11ab('0x38')],'VoiceQueueId':_0x4a0010[_0x5f4cbf][_0x11ab('0x39')],'CampaignId':_0x4a0010[_0x5f4cbf]['CampaignId']}});_0xf7799a['push'](_0x2f0daa);}return BPromise[_0x11ab('0x3a')](_0xf7799a);}})[_0x11ab('0x15')](function(_0x2411e7){logger[_0x11ab('0x3b')]('[CmContact][afterDestroy][Succesfull]',util[_0x11ab('0x23')](_0x2411e7,{'showHidden':![],'depth':null}));_0x2eb9cd();})['catch'](function(_0x2eb9cf){logger[_0x11ab('0x11')](_0x11ab('0x3c'),util[_0x11ab('0x23')](_0x2eb9cf,{'showHidden':![],'depth':null}));_0x2eb9cd(_0x2eb9cf);});}}});};
\ No newline at end of file