Built motion from commit 4c281f94.|2.6.31
[motion2.git] / server / api / cmContact / cmContact.model.js
index 2654535..069ad9f 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x5dc0=['models','get','error','[cmContact][afterCreate]\x20List\x20not\x20found\x20for\x20contact\x20with\x20id\x20','catch','[cmContact][afterCreate]','message','isEmpty','length','ContactId','push','info','[CmContact][afterDestroy][Succesfull]','inspect','[CmContact][afterDestroy][Error]','lodash','api','moment','../../config/environment/shared','./cmContact.attributes','scheduledat','format','YYYY-MM-DD\x20HH:mm:ss','isNil','dialTimezone','resolve','then','timezones','utcOffset','add','priority','callbackUniqueid','phone','assign','CmHopper','findOne','\x20in\x20Campaign\x20with\x20id\x20','CmHopperFinal','[Always]\x20Hopper\x20Final\x20already\x20exists\x20for\x20contact\x20with\x20phone\x20','VoiceQueueId','create','[OnlyIfOpen]\x20Hopper\x20already\x20exists\x20for\x20contact\x20with\x20phone\x20','CampaignId','dialCheckDuplicateType','always','onlyIfOpen','findAll','outbound','CmList','Lists','ListId','map','all','Campaign','VoiceQueue','CmHopperBlack','BlackLists','exports','define','CmContact','firstName','lastName','fax','email','FULLTEXT','utf8mb4','utf8mb4_unicode_ci'];(function(_0x43a68c,_0x180570){var _0x85bdc1=function(_0x26249f){while(--_0x26249f){_0x43a68c['push'](_0x43a68c['shift']());}};_0x85bdc1(++_0x180570);}(_0x5dc0,0x95));var _0x05dc=function(_0x2dbf7a,_0x505ee1){_0x2dbf7a=_0x2dbf7a-0x0;var _0x38ae70=_0x5dc0[_0x2dbf7a];return _0x38ae70;};'use strict';var _=require(_0x05dc('0x0'));var util=require('util');var logger=require('../../config/logger')(_0x05dc('0x1'));var moment=require(_0x05dc('0x2'));var shared=require(_0x05dc('0x3'));var attributes=require(_0x05dc('0x4'));function getTimezoneCallbackAt(_0x527c13,_0x26ec0e,_0x41b9ab,_0x3f7cab){var _0x5555ca=_0x3f7cab?'Campaign':'VoiceQueue';var _0xd8d5c3=_0x41b9ab[_0x05dc('0x5')]?_0x41b9ab['scheduledat']:moment()[_0x05dc('0x6')](_0x05dc('0x7'));if(_[_0x05dc('0x8')](_0x41b9ab[_0x05dc('0x9')])){return Promise[_0x05dc('0xa')](_0xd8d5c3);}return _0x527c13[_0x5555ca]['findOne']({'where':{'id':_0x26ec0e}})[_0x05dc('0xb')](function(_0x4f3352){if(_[_0x05dc('0x8')](_0x4f3352)||_[_0x05dc('0x8')](_0x4f3352[_0x05dc('0x9')])){return Promise[_0x05dc('0xa')](_0xd8d5c3);}var _0x37452b=shared[_0x05dc('0xc')];var _0x21ca1c=_0x37452b[_0x4f3352[_0x05dc('0x9')]];var _0x396186=_0x37452b[_0x41b9ab['dialTimezone']];if(_[_0x05dc('0x8')](_0x21ca1c)&&_[_0x05dc('0x8')](_0x396186)){return Promise[_0x05dc('0xa')](_0xd8d5c3);}var _0x3da3f8=_0x21ca1c[_0x05dc('0xd')]-_0x396186[_0x05dc('0xd')];var _0x51d7e1=_0x41b9ab[_0x05dc('0x5')]?_0x41b9ab[_0x05dc('0x5')]:moment();_0xd8d5c3=moment(_0x51d7e1)[_0x05dc('0xe')](_0x3da3f8,'minutes')[_0x05dc('0x6')]('YYYY-MM-DD\x20HH:mm:ss');return Promise[_0x05dc('0xa')](_0xd8d5c3);});}function getNewHopperPayload(_0x1d5378){return{'phone':_0x1d5378['phone'],'ContactId':_0x1d5378['id'],'ListId':_0x1d5378['ListId'],'scheduledat':_0x1d5378[_0x05dc('0x5')]?_0x1d5378[_0x05dc('0x5')]:moment()[_0x05dc('0x6')](_0x05dc('0x7')),'priority':_0x1d5378[_0x05dc('0xf')]?_0x1d5378['priority']:0x2,'callback':_0x1d5378[_0x05dc('0x10')]?!![]:![],'callbackuniqueid':_0x1d5378['callbackUniqueid']?_0x1d5378[_0x05dc('0x10')]:undefined,'callbackat':_0x1d5378[_0x05dc('0x10')]?moment()[_0x05dc('0x6')](_0x05dc('0x7')):undefined};}function handleAlwaysCheckDuplicate(_0x5806c4,_0x251569,_0x2638f5,_0x31492d){var _0x7acbbe={'phone':_0x2638f5[_0x05dc('0x11')]};var _0x3e15c9={'calleridnum':_0x2638f5[_0x05dc('0x11')]};if(_0x31492d){Object[_0x05dc('0x12')](_0x7acbbe,{'CampaignId':_0x251569['id']});Object[_0x05dc('0x12')](_0x3e15c9,{'CampaignId':_0x251569['id']});}else{Object[_0x05dc('0x12')](_0x7acbbe,{'VoiceQueueId':_0x251569['id']});Object[_0x05dc('0x12')](_0x3e15c9,{'VoiceQueueId':_0x251569['id']});}return _0x5806c4[_0x05dc('0x13')][_0x05dc('0x14')]({'where':_0x7acbbe})['then'](function(_0x2a33a0){if(_0x2a33a0){throw new Error('[Always]\x20Hopper\x20already\x20exists\x20for\x20contact\x20with\x20phone\x20'+_0x2638f5[_0x05dc('0x11')]+_0x05dc('0x15')+_0x251569['id']);}return _0x5806c4[_0x05dc('0x16')][_0x05dc('0x14')]({'where':_0x3e15c9});})[_0x05dc('0xb')](function(_0x55f79f){if(_0x55f79f){throw new Error(_0x05dc('0x17')+_0x2638f5['phone']+_0x05dc('0x15')+_0x251569['id']);}var _0x2258ad=getNewHopperPayload(_0x2638f5);if(_0x31492d){_0x2258ad['CampaignId']=_0x251569['id'];}else{_0x2258ad[_0x05dc('0x18')]=_0x251569['id'];}return _0x5806c4[_0x05dc('0x13')][_0x05dc('0x19')](_0x2258ad);});}function handleOnlyIfOpenCheckDuplicate(_0x3b8d7a,_0x19bf52,_0x25e1c9,_0x41b94f){var _0x344786={'phone':_0x25e1c9['phone']};if(_0x41b94f){Object[_0x05dc('0x12')](_0x344786,{'CampaignId':_0x19bf52['id']});}else{Object[_0x05dc('0x12')](_0x344786,{'VoiceQueueId':_0x19bf52['id']});}return _0x3b8d7a[_0x05dc('0x13')][_0x05dc('0x14')]({'where':_0x344786})[_0x05dc('0xb')](function(_0x492d80){if(_0x492d80){throw new Error(_0x05dc('0x1a')+_0x25e1c9[_0x05dc('0x11')]+_0x05dc('0x15')+_0x19bf52['id']);}var _0x5db608=getNewHopperPayload(_0x25e1c9);if(_0x41b94f){_0x5db608[_0x05dc('0x1b')]=_0x19bf52['id'];}else{_0x5db608[_0x05dc('0x18')]=_0x19bf52['id'];}return _0x3b8d7a['CmHopper'][_0x05dc('0x19')](_0x5db608);});}function handleNeverCheckDuplicate(_0x5b7ce2,_0x4ef95f,_0x5ebb46){var _0x3d7a7d=getNewHopperPayload(_0x5ebb46);_0x3d7a7d[_0x05dc('0x18')]=_0x4ef95f['id'];return _0x5b7ce2[_0x05dc('0x13')]['create'](_0x3d7a7d);}function handleCheckDuplicate(_0x1eb16f,_0x1e91f4,_0x196d77,_0x354eb2){return getTimezoneCallbackAt(_0x1eb16f,_0x1e91f4,_0x196d77,_0x354eb2)[_0x05dc('0xb')](function(_0x5c7104){_0x196d77['scheduledat']=_0x5c7104;switch(_0x1e91f4[_0x05dc('0x1c')]){case _0x05dc('0x1d'):return handleAlwaysCheckDuplicate(_0x1eb16f,_0x1e91f4,_0x196d77,_0x354eb2);case _0x05dc('0x1e'):return handleOnlyIfOpenCheckDuplicate(_0x1eb16f,_0x1e91f4,_0x196d77,_0x354eb2);default:return handleNeverCheckDuplicate(_0x1eb16f,_0x1e91f4,_0x196d77);}});}function createHopperForVoiceQueues(_0x5a8d55,_0x56091a){return _0x5a8d55['VoiceQueue'][_0x05dc('0x1f')]({'where':{'type':_0x05dc('0x20')},'attributes':['id',_0x05dc('0x1c'),'dialTimezone'],'include':[{'model':_0x5a8d55[_0x05dc('0x21')],'as':_0x05dc('0x22'),'where':{'id':_0x56091a[_0x05dc('0x23')]}}],'raw':!![]})[_0x05dc('0xb')](function(_0x2842ba){var _0x16bb27=_0x2842ba[_0x05dc('0x24')](function(_0x49d6d1){return handleCheckDuplicate(_0x5a8d55,_0x49d6d1,_0x56091a,![]);});return Promise[_0x05dc('0x25')](_0x16bb27);});}function createHopperForCampaigns(_0xc8b906,_0x3f9de6){return _0xc8b906[_0x05dc('0x26')][_0x05dc('0x1f')]({'attributes':['id',_0x05dc('0x1c'),'dialTimezone'],'include':[{'model':_0xc8b906[_0x05dc('0x21')],'as':_0x05dc('0x22'),'where':{'id':_0x3f9de6[_0x05dc('0x23')]}}],'raw':!![]})['then'](function(_0x4f691a){var _0x3d34ca=_0x4f691a[_0x05dc('0x24')](function(_0x4fb1c5){return handleCheckDuplicate(_0xc8b906,_0x4fb1c5,_0x3f9de6,!![]);});return Promise[_0x05dc('0x25')](_0x3d34ca);});}function createHopperBlackForVoiceQueues(_0x7c6835,_0x2afd69){return _0x7c6835[_0x05dc('0x27')][_0x05dc('0x1f')]({'where':{'type':_0x05dc('0x20')},'attributes':['id'],'include':[{'model':_0x7c6835[_0x05dc('0x21')],'as':'BlackLists','where':{'id':_0x2afd69[_0x05dc('0x23')]}}],'raw':!![]})[_0x05dc('0xb')](function(_0xae0222){var _0x2a4e08=_0xae0222[_0x05dc('0x24')](function(_0x1cd630){return _0x7c6835[_0x05dc('0x28')][_0x05dc('0x19')]({'phone':_0x2afd69[_0x05dc('0x11')],'ContactId':_0x2afd69['id'],'ListId':_0x2afd69[_0x05dc('0x23')],'VoiceQueueId':_0x1cd630['id']});});return Promise[_0x05dc('0x25')](_0x2a4e08);});}function createHopperBlackForCampaigns(_0x5f25ee,_0x3bee4e){return _0x5f25ee[_0x05dc('0x26')][_0x05dc('0x1f')]({'attributes':['id'],'include':[{'model':_0x5f25ee[_0x05dc('0x21')],'as':_0x05dc('0x29'),'where':{'id':_0x3bee4e[_0x05dc('0x23')]}}],'raw':!![]})[_0x05dc('0xb')](function(_0x37e1a7){var _0x2a56dc=_0x37e1a7[_0x05dc('0x24')](function(_0x2e5dfb){return _0x5f25ee['CmHopperBlack'][_0x05dc('0x19')]({'phone':_0x3bee4e[_0x05dc('0x11')],'ContactId':_0x3bee4e['id'],'ListId':_0x3bee4e['ListId'],'CampaignId':_0x2e5dfb['id']});});return Promise[_0x05dc('0x25')](_0x2a56dc);});}module[_0x05dc('0x2a')]=function(_0x18f279){return _0x18f279[_0x05dc('0x2b')](_0x05dc('0x2c'),attributes,{'tableName':'cm_contacts','paranoid':!![],'indexes':[{'name':_0x05dc('0x11'),'fields':['phone']},{'name':'fti_cm_contacts','fields':[_0x05dc('0x2d'),_0x05dc('0x2e'),_0x05dc('0x11'),'mobile',_0x05dc('0x2f'),_0x05dc('0x30')],'type':_0x05dc('0x31')}],'timestamps':!![],'charset':_0x05dc('0x32'),'collate':_0x05dc('0x33'),'hooks':{'afterCreate':function(_0x2fa277,_0x277fd0,_0x382dbe){var _0x45b1c1=_0x18f279[_0x05dc('0x34')];var _0x1fe76f=_0x2fa277[_0x05dc('0x35')]({'plain':!![]});if(!_0x1fe76f[_0x05dc('0x23')]){logger[_0x05dc('0x36')](_0x05dc('0x37')+_0x1fe76f['id']);return _0x382dbe();}if(!_0x1fe76f[_0x05dc('0x11')]){return _0x382dbe();}return createHopperForVoiceQueues(_0x45b1c1,_0x1fe76f)['then'](function(){return createHopperBlackForVoiceQueues(_0x45b1c1,_0x1fe76f);})[_0x05dc('0xb')](function(){return createHopperForCampaigns(_0x45b1c1,_0x1fe76f);})[_0x05dc('0xb')](function(){return createHopperBlackForCampaigns(_0x45b1c1,_0x1fe76f);})[_0x05dc('0xb')](function(){return _0x382dbe();})[_0x05dc('0x38')](function(_0x6bb6f2){logger[_0x05dc('0x36')](_0x05dc('0x39'),_0x6bb6f2[_0x05dc('0x3a')]);_0x382dbe();});},'afterDestroy':function(_0x4f8312,_0xa5f5fc,_0x30f66a){var _0x17908f=_0x18f279[_0x05dc('0x34')];var _0x2e5b6b=_0x4f8312[_0x05dc('0x35')]({'plain':!![]});return _0x17908f['CmHopper'][_0x05dc('0x1f')]({'raw':!![],'where':{'ListId':_0x2e5b6b[_0x05dc('0x23')],'ContactId':_0x2e5b6b['id']}})[_0x05dc('0xb')](function(_0x56ebfb){if(!_[_0x05dc('0x3b')](_0x56ebfb)){var _0x1f0d8a=[];for(var _0x4612b4=0x0;_0x4612b4<_0x56ebfb[_0x05dc('0x3c')];_0x4612b4+=0x1){var _0xfd5e66=_0x17908f['CmHopper']['destroy']({'where':{'ListId':_0x56ebfb[_0x4612b4][_0x05dc('0x23')],'ContactId':_0x56ebfb[_0x4612b4][_0x05dc('0x3d')],'VoiceQueueId':_0x56ebfb[_0x4612b4][_0x05dc('0x18')],'CampaignId':_0x56ebfb[_0x4612b4][_0x05dc('0x1b')]}});_0x1f0d8a[_0x05dc('0x3e')](_0xfd5e66);}return Promise['all'](_0x1f0d8a);}})[_0x05dc('0xb')](function(_0x41f089){logger[_0x05dc('0x3f')](_0x05dc('0x40'),util[_0x05dc('0x41')](_0x41f089,{'showHidden':![],'depth':null}));_0x30f66a();})[_0x05dc('0x38')](function(_0x34295b){logger['error'](_0x05dc('0x42'),util[_0x05dc('0x41')](_0x34295b,{'showHidden':![],'depth':null}));_0x30f66a(_0x34295b);});}}});};
\ No newline at end of file
+var _0x2f92=['FULLTEXT','utf8mb4','utf8mb4_unicode_ci','models','get','error','[cmContact][afterCreate]\x20List\x20not\x20found\x20for\x20contact\x20with\x20id\x20','[cmContact][afterCreate]','length','destroy','info','[CmContact][afterDestroy][Succesfull]','catch','[CmContact][afterDestroy][Error]','inspect','../../config/logger','api','moment','../../config/environment/shared','./cmContact.attributes','VoiceQueue','format','YYYY-MM-DD\x20HH:mm:ss','isNil','resolve','findOne','then','dialTimezone','utcOffset','scheduledat','add','minutes','phone','priority','callbackUniqueid','assign','CmHopper','[Always]\x20Hopper\x20already\x20exists\x20for\x20contact\x20with\x20phone\x20','\x20in\x20Campaign\x20with\x20id\x20','CmHopperFinal','CampaignId','VoiceQueueId','create','dialCheckDuplicateType','always','findAll','CmList','Lists','ListId','map','all','Campaign','outbound','BlackLists','CmHopperBlack','exports','CmContact','cm_contacts','lastName','fax'];(function(_0x54ebe8,_0x4660d3){var _0x3785f1=function(_0x4abdff){while(--_0x4abdff){_0x54ebe8['push'](_0x54ebe8['shift']());}};_0x3785f1(++_0x4660d3);}(_0x2f92,0x13b));var _0x22f9=function(_0x126558,_0x143c9a){_0x126558=_0x126558-0x0;var _0x1f6d14=_0x2f92[_0x126558];return _0x1f6d14;};'use strict';var _=require('lodash');var util=require('util');var logger=require(_0x22f9('0x0'))(_0x22f9('0x1'));var moment=require(_0x22f9('0x2'));var shared=require(_0x22f9('0x3'));var attributes=require(_0x22f9('0x4'));function getTimezoneCallbackAt(_0x15ad7d,_0x4e7be8,_0x403bc8,_0x4e25a1){var _0xbc9098=_0x4e25a1?'Campaign':_0x22f9('0x5');var _0x3a4c2e=_0x403bc8['scheduledat']?_0x403bc8['scheduledat']:moment()[_0x22f9('0x6')](_0x22f9('0x7'));if(_[_0x22f9('0x8')](_0x403bc8['dialTimezone'])){return Promise[_0x22f9('0x9')](_0x3a4c2e);}return _0x15ad7d[_0xbc9098][_0x22f9('0xa')]({'where':{'id':_0x4e7be8}})[_0x22f9('0xb')](function(_0x69df93){if(_[_0x22f9('0x8')](_0x69df93)||_[_0x22f9('0x8')](_0x69df93['dialTimezone'])){return Promise[_0x22f9('0x9')](_0x3a4c2e);}var _0x39869d=shared['timezones'];var _0x446cb8=_0x39869d[_0x69df93['dialTimezone']];var _0x2ff24e=_0x39869d[_0x403bc8[_0x22f9('0xc')]];if(_[_0x22f9('0x8')](_0x446cb8)&&_['isNil'](_0x2ff24e)){return Promise[_0x22f9('0x9')](_0x3a4c2e);}var _0x22a1d2=_0x446cb8[_0x22f9('0xd')]-_0x2ff24e['utcOffset'];var _0xbc2d58=_0x403bc8[_0x22f9('0xe')]?_0x403bc8[_0x22f9('0xe')]:moment();_0x3a4c2e=moment(_0xbc2d58)[_0x22f9('0xf')](_0x22a1d2,_0x22f9('0x10'))[_0x22f9('0x6')](_0x22f9('0x7'));return Promise[_0x22f9('0x9')](_0x3a4c2e);});}function getNewHopperPayload(_0x2e2717){return{'phone':_0x2e2717[_0x22f9('0x11')],'ContactId':_0x2e2717['id'],'ListId':_0x2e2717['ListId'],'scheduledat':_0x2e2717['scheduledat']?_0x2e2717[_0x22f9('0xe')]:moment()[_0x22f9('0x6')](_0x22f9('0x7')),'priority':_0x2e2717[_0x22f9('0x12')]?_0x2e2717[_0x22f9('0x12')]:0x2,'callback':_0x2e2717['callbackUniqueid']?!![]:![],'callbackuniqueid':_0x2e2717[_0x22f9('0x13')]?_0x2e2717[_0x22f9('0x13')]:undefined,'callbackat':_0x2e2717[_0x22f9('0x13')]?moment()[_0x22f9('0x6')](_0x22f9('0x7')):undefined};}function handleAlwaysCheckDuplicate(_0x443a61,_0x6d2178,_0x59b6f4,_0x26bd95){var _0x1a0c34={'phone':_0x59b6f4[_0x22f9('0x11')]};var _0x1e8d22={'calleridnum':_0x59b6f4[_0x22f9('0x11')]};if(_0x26bd95){Object['assign'](_0x1a0c34,{'CampaignId':_0x6d2178['id']});Object[_0x22f9('0x14')](_0x1e8d22,{'CampaignId':_0x6d2178['id']});}else{Object[_0x22f9('0x14')](_0x1a0c34,{'VoiceQueueId':_0x6d2178['id']});Object[_0x22f9('0x14')](_0x1e8d22,{'VoiceQueueId':_0x6d2178['id']});}return _0x443a61[_0x22f9('0x15')][_0x22f9('0xa')]({'where':_0x1a0c34})[_0x22f9('0xb')](function(_0x45a819){if(_0x45a819){throw new Error(_0x22f9('0x16')+_0x59b6f4[_0x22f9('0x11')]+_0x22f9('0x17')+_0x6d2178['id']);}return _0x443a61[_0x22f9('0x18')][_0x22f9('0xa')]({'where':_0x1e8d22});})['then'](function(_0x46861f){if(_0x46861f){throw new Error('[Always]\x20Hopper\x20Final\x20already\x20exists\x20for\x20contact\x20with\x20phone\x20'+_0x59b6f4[_0x22f9('0x11')]+_0x22f9('0x17')+_0x6d2178['id']);}var _0x2ed628=getNewHopperPayload(_0x59b6f4);if(_0x26bd95){_0x2ed628[_0x22f9('0x19')]=_0x6d2178['id'];}else{_0x2ed628[_0x22f9('0x1a')]=_0x6d2178['id'];}return _0x443a61[_0x22f9('0x15')][_0x22f9('0x1b')](_0x2ed628);});}function handleOnlyIfOpenCheckDuplicate(_0x55fdf0,_0x1ada46,_0x5ea162,_0x3dfb96){var _0x5c7f73={'phone':_0x5ea162[_0x22f9('0x11')]};if(_0x3dfb96){Object[_0x22f9('0x14')](_0x5c7f73,{'CampaignId':_0x1ada46['id']});}else{Object['assign'](_0x5c7f73,{'VoiceQueueId':_0x1ada46['id']});}return _0x55fdf0[_0x22f9('0x15')][_0x22f9('0xa')]({'where':_0x5c7f73})[_0x22f9('0xb')](function(_0x2c0ca1){if(_0x2c0ca1){throw new Error('[OnlyIfOpen]\x20Hopper\x20already\x20exists\x20for\x20contact\x20with\x20phone\x20'+_0x5ea162[_0x22f9('0x11')]+_0x22f9('0x17')+_0x1ada46['id']);}var _0x3ffb95=getNewHopperPayload(_0x5ea162);if(_0x3dfb96){_0x3ffb95['CampaignId']=_0x1ada46['id'];}else{_0x3ffb95['VoiceQueueId']=_0x1ada46['id'];}return _0x55fdf0[_0x22f9('0x15')][_0x22f9('0x1b')](_0x3ffb95);});}function handleNeverCheckDuplicate(_0x4929e4,_0x406115,_0x4cf444){var _0x5c656a=getNewHopperPayload(_0x4cf444);_0x5c656a[_0x22f9('0x1a')]=_0x406115['id'];return _0x4929e4['CmHopper'][_0x22f9('0x1b')](_0x5c656a);}function handleCheckDuplicate(_0x3a040a,_0x48d1db,_0x1a12b3,_0x885b9a){return getTimezoneCallbackAt(_0x3a040a,_0x48d1db,_0x1a12b3,_0x885b9a)[_0x22f9('0xb')](function(_0x4f59e4){_0x1a12b3[_0x22f9('0xe')]=_0x4f59e4;switch(_0x48d1db[_0x22f9('0x1c')]){case _0x22f9('0x1d'):return handleAlwaysCheckDuplicate(_0x3a040a,_0x48d1db,_0x1a12b3,_0x885b9a);case'onlyIfOpen':return handleOnlyIfOpenCheckDuplicate(_0x3a040a,_0x48d1db,_0x1a12b3,_0x885b9a);default:return handleNeverCheckDuplicate(_0x3a040a,_0x48d1db,_0x1a12b3);}});}function createHopperForVoiceQueues(_0xb73ccc,_0x129823){return _0xb73ccc[_0x22f9('0x5')][_0x22f9('0x1e')]({'where':{'type':'outbound'},'attributes':['id','dialCheckDuplicateType',_0x22f9('0xc')],'include':[{'model':_0xb73ccc[_0x22f9('0x1f')],'as':_0x22f9('0x20'),'where':{'id':_0x129823[_0x22f9('0x21')]}}],'raw':!![]})[_0x22f9('0xb')](function(_0x1ca4d8){var _0x137875=_0x1ca4d8[_0x22f9('0x22')](function(_0x16fc59){return handleCheckDuplicate(_0xb73ccc,_0x16fc59,_0x129823,![]);});return Promise[_0x22f9('0x23')](_0x137875);});}function createHopperForCampaigns(_0x4b49e2,_0x5d6308){return _0x4b49e2[_0x22f9('0x24')]['findAll']({'attributes':['id',_0x22f9('0x1c'),_0x22f9('0xc')],'include':[{'model':_0x4b49e2[_0x22f9('0x1f')],'as':_0x22f9('0x20'),'where':{'id':_0x5d6308[_0x22f9('0x21')]}}],'raw':!![]})[_0x22f9('0xb')](function(_0x5ef421){var _0x545e54=_0x5ef421[_0x22f9('0x22')](function(_0x113f78){return handleCheckDuplicate(_0x4b49e2,_0x113f78,_0x5d6308,!![]);});return Promise[_0x22f9('0x23')](_0x545e54);});}function createHopperBlackForVoiceQueues(_0x241d67,_0x57e687){return _0x241d67['VoiceQueue']['findAll']({'where':{'type':_0x22f9('0x25')},'attributes':['id'],'include':[{'model':_0x241d67[_0x22f9('0x1f')],'as':_0x22f9('0x26'),'where':{'id':_0x57e687['ListId']}}],'raw':!![]})['then'](function(_0x3b357f){var _0x2da0e0=_0x3b357f[_0x22f9('0x22')](function(_0x105634){return _0x241d67[_0x22f9('0x27')]['create']({'phone':_0x57e687[_0x22f9('0x11')],'ContactId':_0x57e687['id'],'ListId':_0x57e687[_0x22f9('0x21')],'VoiceQueueId':_0x105634['id']});});return Promise[_0x22f9('0x23')](_0x2da0e0);});}function createHopperBlackForCampaigns(_0x21cd46,_0x467d13){return _0x21cd46[_0x22f9('0x24')][_0x22f9('0x1e')]({'attributes':['id'],'include':[{'model':_0x21cd46[_0x22f9('0x1f')],'as':'BlackLists','where':{'id':_0x467d13['ListId']}}],'raw':!![]})['then'](function(_0x3e9ee4){var _0x167b13=_0x3e9ee4[_0x22f9('0x22')](function(_0x30d361){return _0x21cd46[_0x22f9('0x27')][_0x22f9('0x1b')]({'phone':_0x467d13[_0x22f9('0x11')],'ContactId':_0x467d13['id'],'ListId':_0x467d13['ListId'],'CampaignId':_0x30d361['id']});});return Promise[_0x22f9('0x23')](_0x167b13);});}module[_0x22f9('0x28')]=function(_0x1927f4){return _0x1927f4['define'](_0x22f9('0x29'),attributes,{'tableName':_0x22f9('0x2a'),'paranoid':!![],'indexes':[{'name':_0x22f9('0x11'),'fields':[_0x22f9('0x11')]},{'name':'fti_cm_contacts','fields':['firstName',_0x22f9('0x2b'),_0x22f9('0x11'),'mobile',_0x22f9('0x2c'),'email'],'type':_0x22f9('0x2d')}],'timestamps':!![],'charset':_0x22f9('0x2e'),'collate':_0x22f9('0x2f'),'hooks':{'afterCreate':function(_0x54d480,_0x206b8b,_0x60eb67){var _0x5c22f4=_0x1927f4[_0x22f9('0x30')];var _0x5f06a6=_0x54d480[_0x22f9('0x31')]({'plain':!![]});if(!_0x5f06a6[_0x22f9('0x21')]){logger[_0x22f9('0x32')](_0x22f9('0x33')+_0x5f06a6['id']);return _0x60eb67();}if(!_0x5f06a6[_0x22f9('0x11')]){return _0x60eb67();}return createHopperForVoiceQueues(_0x5c22f4,_0x5f06a6)[_0x22f9('0xb')](function(){return createHopperBlackForVoiceQueues(_0x5c22f4,_0x5f06a6);})[_0x22f9('0xb')](function(){return createHopperForCampaigns(_0x5c22f4,_0x5f06a6);})[_0x22f9('0xb')](function(){return createHopperBlackForCampaigns(_0x5c22f4,_0x5f06a6);})[_0x22f9('0xb')](function(){return _0x60eb67();})['catch'](function(_0x18c612){logger[_0x22f9('0x32')](_0x22f9('0x34'),_0x18c612['message']);_0x60eb67();});},'afterDestroy':function(_0x4866d0,_0x48399b,_0xd9f672){var _0x5a6eb6=_0x1927f4[_0x22f9('0x30')];var _0x47b527=_0x4866d0[_0x22f9('0x31')]({'plain':!![]});return _0x5a6eb6[_0x22f9('0x15')][_0x22f9('0x1e')]({'raw':!![],'where':{'ListId':_0x47b527[_0x22f9('0x21')],'ContactId':_0x47b527['id']}})[_0x22f9('0xb')](function(_0x812c99){if(!_['isEmpty'](_0x812c99)){var _0x3bdca4=[];for(var _0x44f2ff=0x0;_0x44f2ff<_0x812c99[_0x22f9('0x35')];_0x44f2ff+=0x1){var _0x1e0b36=_0x5a6eb6['CmHopper'][_0x22f9('0x36')]({'where':{'ListId':_0x812c99[_0x44f2ff]['ListId'],'ContactId':_0x812c99[_0x44f2ff]['ContactId'],'VoiceQueueId':_0x812c99[_0x44f2ff][_0x22f9('0x1a')],'CampaignId':_0x812c99[_0x44f2ff]['CampaignId']}});_0x3bdca4['push'](_0x1e0b36);}return Promise[_0x22f9('0x23')](_0x3bdca4);}})['then'](function(_0x479d21){logger[_0x22f9('0x37')](_0x22f9('0x38'),util['inspect'](_0x479d21,{'showHidden':![],'depth':null}));_0xd9f672();})[_0x22f9('0x39')](function(_0x524722){logger[_0x22f9('0x32')](_0x22f9('0x3a'),util[_0x22f9('0x3b')](_0x524722,{'showHidden':![],'depth':null}));_0xd9f672(_0x524722);});}}});};
\ No newline at end of file