Built motion from commit 52c8a02d.|2.6.29
[motion2.git] / server / components / import / cm / csv.js
index 0077099..3abad74 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xcc6c=['finally','contact:csv_','resume','resolve','emit','unlinkSync','Unable\x20to\x20delete\x20temp\x20file:','exit','SIGINT','info','CSV\x20parse\x20error','Error\x20executing\x20contact\x20csv\x20import:','lodash','squel','papaparse','../../../mysqldb','../../../config/environment','../../../config/logger','api','redis','localhost','socket.io-emitter','../../../api/cmContact/cmContact.socket','register','argv','undefined','null','Missing\x20filepath\x20parameter!','Missing\x20binding\x20parameters!','Missing\x20ListId\x20parameter!','Missing\x20socket_timestamp\x20parameter!','error','contact','index','test','isNil','The\x20row\x20is\x20empty\x20or\x20the\x20number\x20of\x20parameters\x20does\x20not\x20match\x20the\x20columns!','errors','length','map','message','join','hasOwnProperty','data','phone','birthDate','YYYY-MM-DD','isValid','birthDate\x20format\x20is\x20invalid,\x20YYYY-MM-DD\x20format\x20is\x20supported!','email','email\x20format\x20is\x20not\x20valid!','ListId','CompanyId','find','duplicate','Duplicate\x20Contact','CmContact','then','pick','catch','Error\x20while\x20creating\x20contact:\x20','stringify','cmContact','checkHopper','inspect','insert','into','cm_hopper','ContactId','createdAt','updatedAt','select','field','NOW()','scheduledAt','toString','from','cm_contacts','where','phone\x20IS\x20NOT\x20NULL','phone\x20NOT\x20IN\x20(?)','\x20=\x20?','deletedAt\x20IS\x20NULL','ListId\x20=\x20?','id\x20IN\x20?','str','calleridnum','fromQuery','VoiceQueue','outbound','dialCheckDuplicateType','get','always','push','query','VoiceQueueId','sequelize','all','CmList','BlackLists','Lists','CampaignId','onlyIfOpen','Campaign','findAll','generalCheckHopper','Error\x20processing\x20rows\x20block:'];(function(_0xc54a99,_0x205712){var _0x3b28d1=function(_0x4d60fe){while(--_0x4d60fe){_0xc54a99['push'](_0xc54a99['shift']());}};_0x3b28d1(++_0x205712);}(_0xcc6c,0x1b8));var _0xccc6=function(_0x4f064f,_0x31c44f){_0x4f064f=_0x4f064f-0x0;var _0x4f96fc=_0xcc6c[_0x4f064f];return _0x4f96fc;};'use strict';var BPromise=require('bluebird');var util=require('util');var _=require(_0xccc6('0x0'));var fs=require('fs');var squel=require(_0xccc6('0x1'));var Papa=require(_0xccc6('0x2'));var Redis=require('ioredis');var db=require(_0xccc6('0x3'))['db'];var config=require(_0xccc6('0x4'));var logger=require(_0xccc6('0x5'))(_0xccc6('0x6'));config[_0xccc6('0x7')]=_['defaults'](config[_0xccc6('0x7')],{'host':_0xccc6('0x8'),'port':0x18eb});var socket=require(_0xccc6('0x9'))(new Redis(config[_0xccc6('0x7')]));require(_0xccc6('0xa'))[_0xccc6('0xb')](socket);try{if(!process[_0xccc6('0xc')][0x2]||process[_0xccc6('0xc')][0x2]===_0xccc6('0xd')||process[_0xccc6('0xc')][0x2]===_0xccc6('0xe')){throw new Error(_0xccc6('0xf'));}var FILEPATH=process[_0xccc6('0xc')][0x2];if(!process[_0xccc6('0xc')][0x3]||process['argv'][0x3]===_0xccc6('0xd')||process[_0xccc6('0xc')][0x3]===_0xccc6('0xe')||!process['argv'][0x4]||process[_0xccc6('0xc')][0x4]===_0xccc6('0xd')||process[_0xccc6('0xc')][0x4]===_0xccc6('0xe')){throw new Error(_0xccc6('0x10'));}var FIELDS=_['zipObject'](process[_0xccc6('0xc')][0x3]['split'](','),process['argv'][0x4]['split'](','));if(!process[_0xccc6('0xc')][0x5]||process[_0xccc6('0xc')][0x5]===_0xccc6('0xd')||process[_0xccc6('0xc')][0x5]===_0xccc6('0xe')){throw new Error(_0xccc6('0x11'));}var LISTID=process['argv'][0x5];var COMPANYID=process[_0xccc6('0xc')][0x6]&&process[_0xccc6('0xc')][0x6]!=='undefined'&&process['argv'][0x6]!==_0xccc6('0xe')?process[_0xccc6('0xc')][0x6]:null;var DUPLICATES=process[_0xccc6('0xc')][0x7]&&process[_0xccc6('0xc')][0x7]!=='undefined'&&process[_0xccc6('0xc')][0x7]!==_0xccc6('0xe')?process[_0xccc6('0xc')][0x7]:null;if(!process['argv'][0x8]||process['argv'][0x8]===_0xccc6('0xd')||process[_0xccc6('0xc')][0x8]===_0xccc6('0xe')){throw new Error(_0xccc6('0x12'));}var SOCKET_TIMESTAMP=process[_0xccc6('0xc')][0x8];}catch(_0x5f123c){logger[_0xccc6('0x13')](_0x5f123c);endCsv();}var total=0x0;var pTotal=0x0;var success=0x0;var errors=0x0;var duplicates=0x0;var rows=[];var hopperContacts='';var promises=[];var index=0x0;var alreadyInvalid=![];function handleCheckRowError(_0xc4cf3b,_0x4ddd4e,_0x19ab34,_0xa172a0){var _0x19f7df={'message':_0x4ddd4e};_0x19f7df[_0xc4cf3b]=!![];if(_0x19ab34){_0x19f7df[_0xccc6('0x14')]=_0x19ab34;}if(_0xa172a0){_0x19f7df[_0xccc6('0x15')]=_0xa172a0;}return _0x19f7df;}function isEmail(_0x1ded62){return/^([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x22([^\x0d\x22\x5c\x80-\xff]|\x5c[\x00-\x7f])*\x22)(\x2e([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x22([^\x0d\x22\x5c\x80-\xff]|\x5c[\x00-\x7f])*\x22))*\x40([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x5b([^\x0d\x5b-\x5d\x80-\xff]|\x5c[\x00-\x7f])*\x5d)(\x2e([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x5b([^\x0d\x5b-\x5d\x80-\xff]|\x5c[\x00-\x7f])*\x5d))*$/[_0xccc6('0x16')](_0x1ded62);}function checkRow(_0x4d53f1,_0x32c9a1,_0x29f930){return new BPromise(function(_0xc4e943,_0x1cee0e){if(_[_0xccc6('0x17')](_0x4d53f1)){return _0x1cee0e(handleCheckRowError('error',_0xccc6('0x18'),null,_0x29f930));}if(_0x4d53f1[_0xccc6('0x19')]&&_0x4d53f1['errors'][_0xccc6('0x1a')]){var _0x11cd34=_[_0xccc6('0x1b')](_0x4d53f1['errors'],_0xccc6('0x1c'))[_0xccc6('0x1d')](';');return _0x1cee0e(handleCheckRowError(_0xccc6('0x13'),_0x11cd34,null,_0x29f930));}var _0x430d54={};for(var _0x5b1902 in FIELDS){if(FIELDS[_0xccc6('0x1e')](_0x5b1902)&&FIELDS[_0x5b1902]){_0x430d54[_0x5b1902]=_0x4d53f1[_0xccc6('0x1f')][0x0][FIELDS[_0x5b1902]]||_0x4d53f1[_0xccc6('0x1f')][0x0]['\ufeff'+FIELDS[_0x5b1902]];}}if(!_0x430d54['firstName']){return _0x1cee0e(handleCheckRowError('error','firstName\x20not\x20specified!',null,_0x29f930));}if(!_0x430d54[_0xccc6('0x20')]){return _0x1cee0e(handleCheckRowError(_0xccc6('0x13'),'phone\x20not\x20specified!',null,_0x29f930));}if(_0x430d54['birthDate']){var _0x90e0b6=moment(_0x430d54[_0xccc6('0x21')],_0xccc6('0x22'));if(!_0x90e0b6[_0xccc6('0x23')]()){return _0x1cee0e(handleCheckRowError('error',_0xccc6('0x24'),null,_0x29f930));}}if(_0x430d54[_0xccc6('0x25')]){if(!isEmail(_0x430d54[_0xccc6('0x25')])){return _0x1cee0e(handleCheckRowError(_0xccc6('0x13'),_0xccc6('0x26'),null,_0x29f930));}}_0x430d54[_0xccc6('0x27')]=LISTID;_0x430d54[_0xccc6('0x28')]=COMPANYID||undefined;if(DUPLICATES&&DUPLICATES[_0xccc6('0x1a')]&&_0x32c9a1){var _0x28d776={};for(var _0x129e64=0x0,_0x472256=DUPLICATES['length'];_0x129e64<_0x472256;_0x129e64+=0x1){_0x28d776[DUPLICATES[_0x129e64]]=_0x430d54[DUPLICATES[_0x129e64]];}var _0x3a3e76=_[_0xccc6('0x29')](_0x32c9a1,_0x28d776);if(_0x3a3e76){return _0x1cee0e(handleCheckRowError(_0xccc6('0x2a'),_0xccc6('0x2b'),_0x3a3e76,_0x29f930));}}return db[_0xccc6('0x2c')]['create'](_0x430d54,{'raw':!![],'hooks':![],'fields':_['keys'](_0x430d54)})[_0xccc6('0x2d')](function(_0x502e58){if(DUPLICATES&&DUPLICATES[_0xccc6('0x1a')]&&_0x32c9a1){_0x32c9a1['push'](_[_0xccc6('0x2e')](_0x430d54,DUPLICATES));}hopperContacts+=(hopperContacts?',':'')+_0x502e58['id'];return _0xc4e943();})[_0xccc6('0x2f')](function(_0x39e8f7){return _0x1cee0e(handleCheckRowError(_0xccc6('0x13'),_0xccc6('0x30')+(_0x39e8f7[_0xccc6('0x1c')]||JSON[_0xccc6('0x31')](_0x39e8f7)),null,_0x29f930));});});}function checkHopper(){function _0x470afe(){return function(_0x505036){logger[_0xccc6('0x13')](_0xccc6('0x32'),_0xccc6('0x33'),util[_0xccc6('0x34')](_0x505036,{'showHidden':![],'depth':null}));};}var _0xa43a3e=function(_0x12976b,_0x41c8b9){var _0x11d742=squel[_0xccc6('0x35')]()[_0xccc6('0x36')](_0xccc6('0x37'))['fromQuery']([_0xccc6('0x20'),'scheduledAt',_0xccc6('0x38'),_0xccc6('0x27'),_0x41c8b9,_0xccc6('0x39'),_0xccc6('0x3a')],squel[_0xccc6('0x3b')]()['field'](_0xccc6('0x20'),_0xccc6('0x20'))[_0xccc6('0x3c')](_0xccc6('0x3d'),_0xccc6('0x3e'))['field']('id',_0xccc6('0x38'))[_0xccc6('0x3c')](LISTID[_0xccc6('0x3f')](),_0xccc6('0x27'))[_0xccc6('0x3c')](_0x12976b['id'][_0xccc6('0x3f')](),_0x41c8b9)[_0xccc6('0x3c')](_0xccc6('0x3d'),'createdAt')['field'](_0xccc6('0x3d'),_0xccc6('0x3a'))[_0xccc6('0x40')](_0xccc6('0x41'))[_0xccc6('0x42')]('deletedAt\x20IS\x20NULL')[_0xccc6('0x42')]('ListId\x20=\x20?',LISTID[_0xccc6('0x3f')]())[_0xccc6('0x42')](_0xccc6('0x43'))[_0xccc6('0x42')](_0xccc6('0x44'),squel[_0xccc6('0x3b')]()[_0xccc6('0x3c')]('phone')[_0xccc6('0x40')](_0xccc6('0x37'))[_0xccc6('0x42')](_0x41c8b9+_0xccc6('0x45'),_0x12976b['id'][_0xccc6('0x3f')]())))[_0xccc6('0x3f')]();return _0x11d742;};var _0x57054b=function(_0x5aba84,_0x44030f){var _0x4bf485=squel['insert']()['into'](_0xccc6('0x37'))['fromQuery']([_0xccc6('0x20'),'scheduledAt',_0xccc6('0x38'),_0xccc6('0x27'),_0x44030f,_0xccc6('0x39'),_0xccc6('0x3a')],squel[_0xccc6('0x3b')]()['field'](_0xccc6('0x20'),'phone')[_0xccc6('0x3c')](_0xccc6('0x3d'),_0xccc6('0x3e'))['field']('id',_0xccc6('0x38'))[_0xccc6('0x3c')](LISTID[_0xccc6('0x3f')](),_0xccc6('0x27'))[_0xccc6('0x3c')](_0x5aba84['id'][_0xccc6('0x3f')](),_0x44030f)[_0xccc6('0x3c')]('NOW()','createdAt')[_0xccc6('0x3c')](_0xccc6('0x3d'),'updatedAt')['from'](_0xccc6('0x41'))[_0xccc6('0x42')](_0xccc6('0x46'))['where'](_0xccc6('0x47'),LISTID['toString']())[_0xccc6('0x42')](_0xccc6('0x48'),squel[_0xccc6('0x49')](hopperContacts))[_0xccc6('0x42')](_0xccc6('0x43'))[_0xccc6('0x42')]('phone\x20NOT\x20IN\x20(?)',squel['select']()['field'](_0xccc6('0x4a'))[_0xccc6('0x40')]('cm_hopper_final')[_0xccc6('0x42')](_0x44030f+_0xccc6('0x45'),_0x5aba84['id'][_0xccc6('0x3f')]()))['where']('phone\x20NOT\x20IN\x20(?)',squel['select']()['field'](_0xccc6('0x20'))[_0xccc6('0x40')](_0xccc6('0x37'))[_0xccc6('0x42')](_0x44030f+'\x20=\x20?',_0x5aba84['id'][_0xccc6('0x3f')]())))['toString']();return _0x4bf485;};function _0x104b8e(_0x178233,_0x165bdf){var _0x2825e1=squel['insert']()[_0xccc6('0x36')]('cm_hopper')['fromQuery']([_0xccc6('0x20'),_0xccc6('0x3e'),_0xccc6('0x38'),_0xccc6('0x27'),_0x165bdf,_0xccc6('0x39'),_0xccc6('0x3a')],squel['select']()[_0xccc6('0x3c')](_0xccc6('0x20'),_0xccc6('0x20'))[_0xccc6('0x3c')](_0xccc6('0x3d'),'scheduledAt')[_0xccc6('0x3c')]('id',_0xccc6('0x38'))[_0xccc6('0x3c')](LISTID['toString'](),'ListId')['field'](_0x178233['id'][_0xccc6('0x3f')](),_0x165bdf)['field'](_0xccc6('0x3d'),_0xccc6('0x39'))[_0xccc6('0x3c')]('NOW()',_0xccc6('0x3a'))[_0xccc6('0x40')](_0xccc6('0x41'))[_0xccc6('0x42')]('deletedAt\x20IS\x20NULL')[_0xccc6('0x42')]('ListId\x20=\x20?',LISTID[_0xccc6('0x3f')]())[_0xccc6('0x42')](_0xccc6('0x48'),squel[_0xccc6('0x49')](hopperContacts))['where']('phone\x20IS\x20NOT\x20NULL'))[_0xccc6('0x3f')]();return _0x2825e1;}function _0x3aa3dc(_0x2213dc,_0x2bbf0b){var _0x18d302=squel['insert']()[_0xccc6('0x36')]('cm_hopper_black')[_0xccc6('0x4b')]([_0xccc6('0x20'),'ContactId','ListId',_0x2bbf0b,_0xccc6('0x39'),'updatedAt'],squel['select']()['field'](_0xccc6('0x20'),_0xccc6('0x20'))[_0xccc6('0x3c')]('id','ContactId')['field'](LISTID[_0xccc6('0x3f')](),_0xccc6('0x27'))[_0xccc6('0x3c')](_0x2213dc['id'][_0xccc6('0x3f')](),_0x2bbf0b)[_0xccc6('0x3c')](_0xccc6('0x3d'),_0xccc6('0x39'))[_0xccc6('0x3c')]('NOW()',_0xccc6('0x3a'))[_0xccc6('0x40')](_0xccc6('0x41'))[_0xccc6('0x42')](_0xccc6('0x46'))[_0xccc6('0x42')](_0xccc6('0x47'),LISTID['toString']())[_0xccc6('0x42')](_0xccc6('0x48'),squel['str'](hopperContacts))[_0xccc6('0x42')](_0xccc6('0x43')))[_0xccc6('0x3f')]();return _0x18d302;}return db[_0xccc6('0x4c')]['findAll']({'where':{'type':_0xccc6('0x4d')},'attributes':['id',_0xccc6('0x4e')],'include':[{'model':db['CmList'],'as':'Lists','where':{'id':LISTID}}]})['then'](function(_0x1aa75e){var _0x219142=[];if(_0x1aa75e){var _0x258e16;for(var _0x4d6138=0x0,_0x1e1446;_0x4d6138<_0x1aa75e[_0xccc6('0x1a')];_0x4d6138+=0x1){_0x1e1446=_0x1aa75e[_0x4d6138][_0xccc6('0x4f')]({'plain':!![]});switch(_0x1e1446['dialCheckDuplicateType']){case _0xccc6('0x50'):_0x219142[_0xccc6('0x51')](db['sequelize'][_0xccc6('0x52')](_0x57054b(_0x1e1446,_0xccc6('0x53')))[_0xccc6('0x2d')](function(){})['catch'](_0x470afe()));break;case'onlyIfOpen':_0x219142[_0xccc6('0x51')](db['sequelize'][_0xccc6('0x52')](_0xa43a3e(_0x1e1446,'VoiceQueueId'))['then'](function(){})['catch'](_0x470afe()));break;default:_0x219142['push'](db[_0xccc6('0x54')][_0xccc6('0x52')](_0x104b8e(_0x1e1446,_0xccc6('0x53')))[_0xccc6('0x2d')](function(){})[_0xccc6('0x2f')](_0x470afe()));}}}return _0x219142;})[_0xccc6('0x55')]()[_0xccc6('0x2d')](function(){return db[_0xccc6('0x4c')]['findAll']({'where':{'type':_0xccc6('0x4d')},'attributes':['id'],'include':[{'model':db[_0xccc6('0x56')],'as':_0xccc6('0x57'),'where':{'id':LISTID}}]})[_0xccc6('0x2d')](function(_0x485da4){var _0x3a0dad=[];if(_0x485da4){var _0x1a2ebf;for(var _0x1119e1=0x0,_0x50d8b1;_0x1119e1<_0x485da4[_0xccc6('0x1a')];_0x1119e1+=0x1){_0x50d8b1=_0x485da4[_0x1119e1][_0xccc6('0x4f')]({'plain':!![]});_0x3a0dad[_0xccc6('0x51')](db[_0xccc6('0x54')]['query'](_0x3aa3dc(_0x50d8b1,'VoiceQueueId'))[_0xccc6('0x2d')](function(){})[_0xccc6('0x2f')](_0x470afe()));}}return _0x3a0dad;})[_0xccc6('0x55')]();})[_0xccc6('0x2d')](function(){return db['Campaign']['findAll']({'attributes':['id',_0xccc6('0x4e')],'include':[{'model':db[_0xccc6('0x56')],'as':_0xccc6('0x58'),'where':{'id':LISTID}}]})[_0xccc6('0x2d')](function(_0x37895a){var _0xdb9314=[];if(_0x37895a){for(var _0x2e0c01=0x0,_0x3de040;_0x2e0c01<_0x37895a[_0xccc6('0x1a')];_0x2e0c01+=0x1){_0x3de040=_0x37895a[_0x2e0c01][_0xccc6('0x4f')]({'plain':!![]});switch(_0x3de040[_0xccc6('0x4e')]){case'always':_0xdb9314[_0xccc6('0x51')](db[_0xccc6('0x54')][_0xccc6('0x52')](_0x57054b(_0x3de040,_0xccc6('0x59')))[_0xccc6('0x2d')](function(){})[_0xccc6('0x2f')](_0x470afe()));break;case _0xccc6('0x5a'):_0xdb9314[_0xccc6('0x51')](db[_0xccc6('0x54')][_0xccc6('0x52')](_0xa43a3e(_0x3de040,_0xccc6('0x59')))[_0xccc6('0x2d')](function(){})[_0xccc6('0x2f')](_0x470afe()));break;default:_0xdb9314['push'](db['sequelize'][_0xccc6('0x52')](_0x104b8e(_0x3de040,'CampaignId'))['then'](function(){})[_0xccc6('0x2f')](_0x470afe()));}}}return _0xdb9314;})['all']();})[_0xccc6('0x2d')](function(){return db[_0xccc6('0x5b')][_0xccc6('0x5c')]({'attributes':['id'],'include':[{'model':db[_0xccc6('0x56')],'as':_0xccc6('0x57'),'where':{'id':LISTID}}]})[_0xccc6('0x2d')](function(_0x34e9f3){var _0x35e5a7=[];if(_0x34e9f3){for(var _0x5dd3bf=0x0,_0x1272ed;_0x5dd3bf<_0x34e9f3[_0xccc6('0x1a')];_0x5dd3bf+=0x1){_0x1272ed=_0x34e9f3[_0x5dd3bf][_0xccc6('0x4f')]({'plain':!![]});_0x35e5a7['push'](db[_0xccc6('0x54')][_0xccc6('0x52')](_0x3aa3dc(_0x1272ed,_0xccc6('0x59')))[_0xccc6('0x2d')](function(){})['catch'](_0x470afe()));}}return _0x35e5a7;})[_0xccc6('0x55')]();})[_0xccc6('0x2f')](function(_0x146220){logger[_0xccc6('0x13')]('cmContact,\x20%s,\x20%s',_0xccc6('0x5d'),_0x146220[_0xccc6('0x1c')]);});}var processPromises=function(_0x31a29e){return BPromise['all'](promises)[_0xccc6('0x2d')](function(_0x4b52f1){})[_0xccc6('0x2f')](function(_0x128239){logger[_0xccc6('0x13')](_0xccc6('0x5e'),JSON[_0xccc6('0x31')](_0x128239));})[_0xccc6('0x5f')](function(){socket['emit'](_0xccc6('0x60')+SOCKET_TIMESTAMP,{'success':success,'errors':errors,'duplicates':duplicates,'rows':rows});promises=[];success=0x0;errors=0x0;duplicates=0x0;rows=[];if(_0x31a29e){return _0x31a29e[_0xccc6('0x61')]();}});};var endCsv=function(){return BPromise[_0xccc6('0x62')]()[_0xccc6('0x2d')](function(){if(hopperContacts){return checkHopper();}})[_0xccc6('0x2d')](function(){socket[_0xccc6('0x63')](_0xccc6('0x60')+SOCKET_TIMESTAMP,{'finished':!![],'success':success,'errors':errors,'duplicates':duplicates,'rows':rows});try{fs[_0xccc6('0x64')](FILEPATH);}catch(_0x5a488d){logger[_0xccc6('0x13')](_0xccc6('0x65'),JSON[_0xccc6('0x31')](_0x5a488d));}finally{process[_0xccc6('0x66')](0x0);}});};process['on'](_0xccc6('0x67'),function(){logger[_0xccc6('0x68')]('CSV\x20import\x20process\x20stopped!');endCsv();});function main(){return BPromise[_0xccc6('0x62')]()[_0xccc6('0x2d')](function(){if(DUPLICATES){DUPLICATES=DUPLICATES['split'](',');return db[_0xccc6('0x2c')][_0xccc6('0x5c')]({'where':{'ListId':LISTID},'attributes':DUPLICATES,'raw':!![]});}})[_0xccc6('0x2d')](function(_0x5a07fe){var _0x4326fb=fs['createReadStream'](FILEPATH,{'highWaterMark':0xf*0x400*0x400});Papa['parse'](_0x4326fb,{'header':!![],'skipEmptyLines':!![],'step':function(_0x25f8df,_0x36dccd){total+=0x1;var _0x287047=total;promises[_0xccc6('0x51')](checkRow(_0x25f8df,_0x5a07fe,_0x287047)[_0xccc6('0x2d')](function(){success+=0x1;})[_0xccc6('0x2f')](function(_0x3a93fa){if(_0x3a93fa[_0xccc6('0x13')]){errors+=0x1;delete _0x3a93fa[_0xccc6('0x13')];}else if(_0x3a93fa['duplicate']){duplicates+=0x1;delete _0x3a93fa[_0xccc6('0x2a')];}rows[_0xccc6('0x51')](_0x3a93fa);}));if(total%0xc8===0x0){_0x36dccd['pause']();return processPromises(_0x36dccd);}},'complete':function(){return processPromises()[_0xccc6('0x2d')](function(){logger[_0xccc6('0x68')]('CSV\x20parsed\x20correctly!');endCsv();});},'error':function(_0x5e4d09,_0x5b3eb6){logger[_0xccc6('0x68')](_0xccc6('0x69'),JSON['stringify'](_0x5e4d09));endCsv();}});})['catch'](function(_0xc26a15){logger[_0xccc6('0x13')](_0xccc6('0x6a'),JSON[_0xccc6('0x31')](_0xc26a15));});}main();
\ No newline at end of file
+var _0x4c10=['cmContact','inspect','insert','into','cm_hopper','fromQuery','ContactId','createdAt','select','field','NOW()','scheduledAt','toString','updatedAt','from','cm_contacts','where','deletedAt\x20IS\x20NULL','ListId\x20=\x20?','phone\x20IS\x20NOT\x20NULL','phone\x20NOT\x20IN\x20(?)','\x20=\x20?','str','calleridnum','cm_hopper_final','cm_hopper_black','id\x20IN\x20?','VoiceQueue','findAll','outbound','dialCheckDuplicateType','CmList','Lists','always','query','VoiceQueueId','catch','sequelize','all','BlackLists','Campaign','CampaignId','get','cmContact,\x20%s,\x20%s','generalCheckHopper','Error\x20processing\x20rows\x20block:','finally','emit','contact:csv_','resume','resolve','exit','SIGINT','info','CSV\x20import\x20process\x20stopped!','createReadStream','parse','CSV\x20parsed\x20correctly!','CSV\x20parse\x20error','Error\x20executing\x20contact\x20csv\x20import:','util','lodash','squel','papaparse','ioredis','../../../config/environment','redis','../../../api/cmContact/cmContact.socket','register','argv','null','undefined','zipObject','split','Missing\x20ListId\x20parameter!','Missing\x20socket_timestamp\x20parameter!','index','test','isNil','error','errors','length','message','join','hasOwnProperty','data','firstName','firstName\x20not\x20specified!','phone','phone\x20not\x20specified!','birthDate','YYYY-MM-DD','isValid','birthDate\x20format\x20is\x20invalid,\x20YYYY-MM-DD\x20format\x20is\x20supported!','email','email\x20format\x20is\x20not\x20valid!','ListId','CompanyId','duplicate','Duplicate\x20Contact','CmContact','keys','then','push','Error\x20while\x20creating\x20contact:\x20','stringify'];(function(_0x42cae2,_0x284ef8){var _0x5f256f=function(_0x41abc8){while(--_0x41abc8){_0x42cae2['push'](_0x42cae2['shift']());}};_0x5f256f(++_0x284ef8);}(_0x4c10,0x17a));var _0x04c1=function(_0x5cdf51,_0x2ce86c){_0x5cdf51=_0x5cdf51-0x0;var _0x470a5f=_0x4c10[_0x5cdf51];return _0x470a5f;};'use strict';var BPromise=require('bluebird');var util=require(_0x04c1('0x0'));var _=require(_0x04c1('0x1'));var fs=require('fs');var squel=require(_0x04c1('0x2'));var Papa=require(_0x04c1('0x3'));var Redis=require(_0x04c1('0x4'));var db=require('../../../mysqldb')['db'];var config=require(_0x04c1('0x5'));var logger=require('../../../config/logger')('api');config['redis']=_['defaults'](config[_0x04c1('0x6')],{'host':'localhost','port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x04c1('0x6')]));require(_0x04c1('0x7'))[_0x04c1('0x8')](socket);try{if(!process[_0x04c1('0x9')][0x2]||process[_0x04c1('0x9')][0x2]==='undefined'||process[_0x04c1('0x9')][0x2]===_0x04c1('0xa')){throw new Error('Missing\x20filepath\x20parameter!');}var FILEPATH=process[_0x04c1('0x9')][0x2];if(!process[_0x04c1('0x9')][0x3]||process['argv'][0x3]==='undefined'||process[_0x04c1('0x9')][0x3]===_0x04c1('0xa')||!process['argv'][0x4]||process[_0x04c1('0x9')][0x4]===_0x04c1('0xb')||process['argv'][0x4]===_0x04c1('0xa')){throw new Error('Missing\x20binding\x20parameters!');}var FIELDS=_[_0x04c1('0xc')](process[_0x04c1('0x9')][0x3]['split'](','),process[_0x04c1('0x9')][0x4][_0x04c1('0xd')](','));if(!process['argv'][0x5]||process[_0x04c1('0x9')][0x5]==='undefined'||process['argv'][0x5]===_0x04c1('0xa')){throw new Error(_0x04c1('0xe'));}var LISTID=process['argv'][0x5];var COMPANYID=process[_0x04c1('0x9')][0x6]&&process[_0x04c1('0x9')][0x6]!==_0x04c1('0xb')&&process[_0x04c1('0x9')][0x6]!==_0x04c1('0xa')?process['argv'][0x6]:null;var DUPLICATES=process[_0x04c1('0x9')][0x7]&&process[_0x04c1('0x9')][0x7]!=='undefined'&&process[_0x04c1('0x9')][0x7]!==_0x04c1('0xa')?process[_0x04c1('0x9')][0x7]:null;if(!process[_0x04c1('0x9')][0x8]||process[_0x04c1('0x9')][0x8]===_0x04c1('0xb')||process[_0x04c1('0x9')][0x8]==='null'){throw new Error(_0x04c1('0xf'));}var SOCKET_TIMESTAMP=process[_0x04c1('0x9')][0x8];}catch(_0x52a1d1){logger['error'](_0x52a1d1);endCsv();}var total=0x0;var pTotal=0x0;var success=0x0;var errors=0x0;var duplicates=0x0;var rows=[];var hopperContacts='';var promises=[];var index=0x0;var alreadyInvalid=![];function handleCheckRowError(_0x555b09,_0xaf0b28,_0x3e5397,_0x590d51){var _0x4086f1={'message':_0xaf0b28};_0x4086f1[_0x555b09]=!![];if(_0x3e5397){_0x4086f1['contact']=_0x3e5397;}if(_0x590d51){_0x4086f1[_0x04c1('0x10')]=_0x590d51;}return _0x4086f1;}function isEmail(_0x202098){return/^([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x22([^\x0d\x22\x5c\x80-\xff]|\x5c[\x00-\x7f])*\x22)(\x2e([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x22([^\x0d\x22\x5c\x80-\xff]|\x5c[\x00-\x7f])*\x22))*\x40([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x5b([^\x0d\x5b-\x5d\x80-\xff]|\x5c[\x00-\x7f])*\x5d)(\x2e([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x5b([^\x0d\x5b-\x5d\x80-\xff]|\x5c[\x00-\x7f])*\x5d))*$/[_0x04c1('0x11')](_0x202098);}function checkRow(_0x1eacde,_0x32d5b5,_0x8b4608){return new BPromise(function(_0x4b2ca8,_0x25dfea){if(_[_0x04c1('0x12')](_0x1eacde)){return _0x25dfea(handleCheckRowError(_0x04c1('0x13'),'The\x20row\x20is\x20empty\x20or\x20the\x20number\x20of\x20parameters\x20does\x20not\x20match\x20the\x20columns!',null,_0x8b4608));}if(_0x1eacde[_0x04c1('0x14')]&&_0x1eacde[_0x04c1('0x14')][_0x04c1('0x15')]){var _0x3c2438=_['map'](_0x1eacde[_0x04c1('0x14')],_0x04c1('0x16'))[_0x04c1('0x17')](';');return _0x25dfea(handleCheckRowError(_0x04c1('0x13'),_0x3c2438,null,_0x8b4608));}var _0x2dcd4e={};for(var _0x4aa63a in FIELDS){if(FIELDS[_0x04c1('0x18')](_0x4aa63a)&&FIELDS[_0x4aa63a]){_0x2dcd4e[_0x4aa63a]=_0x1eacde[_0x04c1('0x19')][0x0][FIELDS[_0x4aa63a]]||_0x1eacde[_0x04c1('0x19')][0x0]['\ufeff'+FIELDS[_0x4aa63a]];}}if(!_0x2dcd4e[_0x04c1('0x1a')]){return _0x25dfea(handleCheckRowError(_0x04c1('0x13'),_0x04c1('0x1b'),null,_0x8b4608));}if(!_0x2dcd4e[_0x04c1('0x1c')]){return _0x25dfea(handleCheckRowError(_0x04c1('0x13'),_0x04c1('0x1d'),null,_0x8b4608));}if(_0x2dcd4e['birthDate']){var _0x53f3fd=moment(_0x2dcd4e[_0x04c1('0x1e')],_0x04c1('0x1f'));if(!_0x53f3fd[_0x04c1('0x20')]()){return _0x25dfea(handleCheckRowError(_0x04c1('0x13'),_0x04c1('0x21'),null,_0x8b4608));}}if(_0x2dcd4e['email']){if(!isEmail(_0x2dcd4e[_0x04c1('0x22')])){return _0x25dfea(handleCheckRowError(_0x04c1('0x13'),_0x04c1('0x23'),null,_0x8b4608));}}_0x2dcd4e[_0x04c1('0x24')]=LISTID;_0x2dcd4e[_0x04c1('0x25')]=COMPANYID||undefined;if(DUPLICATES&&DUPLICATES[_0x04c1('0x15')]&&_0x32d5b5){var _0x46f533={};for(var _0x1bb538=0x0,_0x27c9bd=DUPLICATES[_0x04c1('0x15')];_0x1bb538<_0x27c9bd;_0x1bb538+=0x1){_0x46f533[DUPLICATES[_0x1bb538]]=_0x2dcd4e[DUPLICATES[_0x1bb538]];}var _0xf85aef=_['find'](_0x32d5b5,_0x46f533);if(_0xf85aef){return _0x25dfea(handleCheckRowError(_0x04c1('0x26'),_0x04c1('0x27'),_0xf85aef,_0x8b4608));}}return db[_0x04c1('0x28')]['create'](_0x2dcd4e,{'raw':!![],'hooks':![],'fields':_[_0x04c1('0x29')](_0x2dcd4e)})[_0x04c1('0x2a')](function(_0x135972){if(DUPLICATES&&DUPLICATES['length']&&_0x32d5b5){_0x32d5b5[_0x04c1('0x2b')](_['pick'](_0x2dcd4e,DUPLICATES));}hopperContacts+=(hopperContacts?',':'')+_0x135972['id'];return _0x4b2ca8();})['catch'](function(_0x43f003){return _0x25dfea(handleCheckRowError('error',_0x04c1('0x2c')+(_0x43f003[_0x04c1('0x16')]||JSON[_0x04c1('0x2d')](_0x43f003)),null,_0x8b4608));});});}function checkHopper(){function _0x2c77f1(){return function(_0x48bc21){logger[_0x04c1('0x13')](_0x04c1('0x2e'),'checkHopper',util[_0x04c1('0x2f')](_0x48bc21,{'showHidden':![],'depth':null}));};}var _0xa5da11=function(_0xea7235,_0x57087d){var _0x1e865a=squel[_0x04c1('0x30')]()[_0x04c1('0x31')](_0x04c1('0x32'))[_0x04c1('0x33')]([_0x04c1('0x1c'),'scheduledAt',_0x04c1('0x34'),_0x04c1('0x24'),_0x57087d,_0x04c1('0x35'),'updatedAt'],squel[_0x04c1('0x36')]()[_0x04c1('0x37')]('phone','phone')[_0x04c1('0x37')](_0x04c1('0x38'),_0x04c1('0x39'))[_0x04c1('0x37')]('id',_0x04c1('0x34'))[_0x04c1('0x37')](LISTID['toString'](),_0x04c1('0x24'))[_0x04c1('0x37')](_0xea7235['id'][_0x04c1('0x3a')](),_0x57087d)[_0x04c1('0x37')](_0x04c1('0x38'),'createdAt')[_0x04c1('0x37')](_0x04c1('0x38'),_0x04c1('0x3b'))[_0x04c1('0x3c')](_0x04c1('0x3d'))[_0x04c1('0x3e')](_0x04c1('0x3f'))[_0x04c1('0x3e')](_0x04c1('0x40'),LISTID['toString']())['where'](_0x04c1('0x41'))[_0x04c1('0x3e')](_0x04c1('0x42'),squel[_0x04c1('0x36')]()[_0x04c1('0x37')](_0x04c1('0x1c'))[_0x04c1('0x3c')](_0x04c1('0x32'))[_0x04c1('0x3e')](_0x57087d+_0x04c1('0x43'),_0xea7235['id']['toString']())))[_0x04c1('0x3a')]();return _0x1e865a;};var _0x43b4eb=function(_0x5959b8,_0x4d260e){var _0x176997=squel[_0x04c1('0x30')]()['into'](_0x04c1('0x32'))[_0x04c1('0x33')]([_0x04c1('0x1c'),'scheduledAt',_0x04c1('0x34'),_0x04c1('0x24'),_0x4d260e,_0x04c1('0x35'),_0x04c1('0x3b')],squel[_0x04c1('0x36')]()[_0x04c1('0x37')]('phone','phone')[_0x04c1('0x37')](_0x04c1('0x38'),_0x04c1('0x39'))['field']('id','ContactId')['field'](LISTID[_0x04c1('0x3a')](),'ListId')[_0x04c1('0x37')](_0x5959b8['id']['toString'](),_0x4d260e)[_0x04c1('0x37')](_0x04c1('0x38'),_0x04c1('0x35'))[_0x04c1('0x37')](_0x04c1('0x38'),_0x04c1('0x3b'))[_0x04c1('0x3c')]('cm_contacts')[_0x04c1('0x3e')](_0x04c1('0x3f'))['where'](_0x04c1('0x40'),LISTID[_0x04c1('0x3a')]())['where']('id\x20IN\x20?',squel[_0x04c1('0x44')](hopperContacts))[_0x04c1('0x3e')](_0x04c1('0x41'))[_0x04c1('0x3e')](_0x04c1('0x42'),squel[_0x04c1('0x36')]()[_0x04c1('0x37')](_0x04c1('0x45'))[_0x04c1('0x3c')](_0x04c1('0x46'))[_0x04c1('0x3e')](_0x4d260e+_0x04c1('0x43'),_0x5959b8['id'][_0x04c1('0x3a')]()))['where'](_0x04c1('0x42'),squel[_0x04c1('0x36')]()['field']('phone')[_0x04c1('0x3c')](_0x04c1('0x32'))['where'](_0x4d260e+_0x04c1('0x43'),_0x5959b8['id']['toString']())))[_0x04c1('0x3a')]();return _0x176997;};function _0x5e7f7e(_0x44c6dd,_0xafa4d6){var _0x4931b3=squel['insert']()['into'](_0x04c1('0x32'))[_0x04c1('0x33')]([_0x04c1('0x1c'),'scheduledAt',_0x04c1('0x34'),_0x04c1('0x24'),_0xafa4d6,_0x04c1('0x35'),_0x04c1('0x3b')],squel[_0x04c1('0x36')]()[_0x04c1('0x37')](_0x04c1('0x1c'),'phone')[_0x04c1('0x37')](_0x04c1('0x38'),_0x04c1('0x39'))[_0x04c1('0x37')]('id',_0x04c1('0x34'))[_0x04c1('0x37')](LISTID[_0x04c1('0x3a')](),_0x04c1('0x24'))['field'](_0x44c6dd['id']['toString'](),_0xafa4d6)['field'](_0x04c1('0x38'),'createdAt')[_0x04c1('0x37')](_0x04c1('0x38'),_0x04c1('0x3b'))[_0x04c1('0x3c')](_0x04c1('0x3d'))[_0x04c1('0x3e')]('deletedAt\x20IS\x20NULL')['where'](_0x04c1('0x40'),LISTID[_0x04c1('0x3a')]())[_0x04c1('0x3e')]('id\x20IN\x20?',squel['str'](hopperContacts))[_0x04c1('0x3e')](_0x04c1('0x41')))['toString']();return _0x4931b3;}function _0x319c7d(_0x1c2f25,_0x4d5dbb){var _0x47ee59=squel[_0x04c1('0x30')]()['into'](_0x04c1('0x47'))[_0x04c1('0x33')]([_0x04c1('0x1c'),_0x04c1('0x34'),'ListId',_0x4d5dbb,'createdAt','updatedAt'],squel[_0x04c1('0x36')]()[_0x04c1('0x37')](_0x04c1('0x1c'),_0x04c1('0x1c'))[_0x04c1('0x37')]('id',_0x04c1('0x34'))[_0x04c1('0x37')](LISTID['toString'](),_0x04c1('0x24'))[_0x04c1('0x37')](_0x1c2f25['id'][_0x04c1('0x3a')](),_0x4d5dbb)[_0x04c1('0x37')]('NOW()',_0x04c1('0x35'))[_0x04c1('0x37')]('NOW()','updatedAt')[_0x04c1('0x3c')]('cm_contacts')[_0x04c1('0x3e')](_0x04c1('0x3f'))[_0x04c1('0x3e')](_0x04c1('0x40'),LISTID[_0x04c1('0x3a')]())[_0x04c1('0x3e')](_0x04c1('0x48'),squel[_0x04c1('0x44')](hopperContacts))['where']('phone\x20IS\x20NOT\x20NULL'))[_0x04c1('0x3a')]();return _0x47ee59;}return db[_0x04c1('0x49')][_0x04c1('0x4a')]({'where':{'type':_0x04c1('0x4b')},'attributes':['id',_0x04c1('0x4c')],'include':[{'model':db[_0x04c1('0x4d')],'as':_0x04c1('0x4e'),'where':{'id':LISTID}}]})[_0x04c1('0x2a')](function(_0x2ea14e){var _0xf1dcf6=[];if(_0x2ea14e){var _0x19d7a2;for(var _0x3775d6=0x0,_0x4b90cf;_0x3775d6<_0x2ea14e[_0x04c1('0x15')];_0x3775d6+=0x1){_0x4b90cf=_0x2ea14e[_0x3775d6]['get']({'plain':!![]});switch(_0x4b90cf[_0x04c1('0x4c')]){case _0x04c1('0x4f'):_0xf1dcf6[_0x04c1('0x2b')](db['sequelize'][_0x04c1('0x50')](_0x43b4eb(_0x4b90cf,_0x04c1('0x51')))[_0x04c1('0x2a')](function(){})[_0x04c1('0x52')](_0x2c77f1()));break;case'onlyIfOpen':_0xf1dcf6[_0x04c1('0x2b')](db['sequelize'][_0x04c1('0x50')](_0xa5da11(_0x4b90cf,_0x04c1('0x51')))['then'](function(){})[_0x04c1('0x52')](_0x2c77f1()));break;default:_0xf1dcf6[_0x04c1('0x2b')](db[_0x04c1('0x53')][_0x04c1('0x50')](_0x5e7f7e(_0x4b90cf,_0x04c1('0x51')))[_0x04c1('0x2a')](function(){})[_0x04c1('0x52')](_0x2c77f1()));}}}return _0xf1dcf6;})[_0x04c1('0x54')]()['then'](function(){return db[_0x04c1('0x49')][_0x04c1('0x4a')]({'where':{'type':'outbound'},'attributes':['id'],'include':[{'model':db[_0x04c1('0x4d')],'as':_0x04c1('0x55'),'where':{'id':LISTID}}]})[_0x04c1('0x2a')](function(_0x3327b4){var _0x19114e=[];if(_0x3327b4){var _0x1d0a40;for(var _0x2ee06f=0x0,_0x11082a;_0x2ee06f<_0x3327b4[_0x04c1('0x15')];_0x2ee06f+=0x1){_0x11082a=_0x3327b4[_0x2ee06f]['get']({'plain':!![]});_0x19114e[_0x04c1('0x2b')](db[_0x04c1('0x53')][_0x04c1('0x50')](_0x319c7d(_0x11082a,_0x04c1('0x51')))[_0x04c1('0x2a')](function(){})[_0x04c1('0x52')](_0x2c77f1()));}}return _0x19114e;})[_0x04c1('0x54')]();})[_0x04c1('0x2a')](function(){return db[_0x04c1('0x56')][_0x04c1('0x4a')]({'attributes':['id',_0x04c1('0x4c')],'include':[{'model':db['CmList'],'as':_0x04c1('0x4e'),'where':{'id':LISTID}}]})[_0x04c1('0x2a')](function(_0x1bf816){var _0x4184ad=[];if(_0x1bf816){for(var _0x5c1c28=0x0,_0x3fb641;_0x5c1c28<_0x1bf816['length'];_0x5c1c28+=0x1){_0x3fb641=_0x1bf816[_0x5c1c28]['get']({'plain':!![]});switch(_0x3fb641[_0x04c1('0x4c')]){case _0x04c1('0x4f'):_0x4184ad['push'](db[_0x04c1('0x53')]['query'](_0x43b4eb(_0x3fb641,'CampaignId'))['then'](function(){})[_0x04c1('0x52')](_0x2c77f1()));break;case'onlyIfOpen':_0x4184ad[_0x04c1('0x2b')](db[_0x04c1('0x53')][_0x04c1('0x50')](_0xa5da11(_0x3fb641,_0x04c1('0x57')))['then'](function(){})['catch'](_0x2c77f1()));break;default:_0x4184ad[_0x04c1('0x2b')](db['sequelize'][_0x04c1('0x50')](_0x5e7f7e(_0x3fb641,_0x04c1('0x57')))[_0x04c1('0x2a')](function(){})[_0x04c1('0x52')](_0x2c77f1()));}}}return _0x4184ad;})[_0x04c1('0x54')]();})['then'](function(){return db[_0x04c1('0x56')][_0x04c1('0x4a')]({'attributes':['id'],'include':[{'model':db[_0x04c1('0x4d')],'as':_0x04c1('0x55'),'where':{'id':LISTID}}]})[_0x04c1('0x2a')](function(_0x3614d5){var _0x58793e=[];if(_0x3614d5){for(var _0x8bcead=0x0,_0x3f906f;_0x8bcead<_0x3614d5['length'];_0x8bcead+=0x1){_0x3f906f=_0x3614d5[_0x8bcead][_0x04c1('0x58')]({'plain':!![]});_0x58793e[_0x04c1('0x2b')](db[_0x04c1('0x53')][_0x04c1('0x50')](_0x319c7d(_0x3f906f,'CampaignId'))[_0x04c1('0x2a')](function(){})[_0x04c1('0x52')](_0x2c77f1()));}}return _0x58793e;})[_0x04c1('0x54')]();})[_0x04c1('0x52')](function(_0x3cb7e5){logger[_0x04c1('0x13')](_0x04c1('0x59'),_0x04c1('0x5a'),_0x3cb7e5['message']);});}var processPromises=function(_0x3f78df){return BPromise[_0x04c1('0x54')](promises)[_0x04c1('0x2a')](function(_0x55bdf0){})[_0x04c1('0x52')](function(_0x695afa){logger['error'](_0x04c1('0x5b'),JSON[_0x04c1('0x2d')](_0x695afa));})[_0x04c1('0x5c')](function(){socket[_0x04c1('0x5d')](_0x04c1('0x5e')+SOCKET_TIMESTAMP,{'success':success,'errors':errors,'duplicates':duplicates,'rows':rows});promises=[];success=0x0;errors=0x0;duplicates=0x0;rows=[];if(_0x3f78df){return _0x3f78df[_0x04c1('0x5f')]();}});};var endCsv=function(){return BPromise[_0x04c1('0x60')]()['then'](function(){if(hopperContacts){return checkHopper();}})[_0x04c1('0x2a')](function(){socket[_0x04c1('0x5d')](_0x04c1('0x5e')+SOCKET_TIMESTAMP,{'finished':!![],'success':success,'errors':errors,'duplicates':duplicates,'rows':rows});try{fs['unlinkSync'](FILEPATH);}catch(_0xb9ac36){logger[_0x04c1('0x13')]('Unable\x20to\x20delete\x20temp\x20file:',JSON[_0x04c1('0x2d')](_0xb9ac36));}finally{process[_0x04c1('0x61')](0x0);}});};process['on'](_0x04c1('0x62'),function(){logger[_0x04c1('0x63')](_0x04c1('0x64'));endCsv();});function main(){return BPromise[_0x04c1('0x60')]()[_0x04c1('0x2a')](function(){if(DUPLICATES){DUPLICATES=DUPLICATES[_0x04c1('0xd')](',');return db['CmContact']['findAll']({'where':{'ListId':LISTID},'attributes':DUPLICATES,'raw':!![]});}})[_0x04c1('0x2a')](function(_0x5e207d){var _0x46d9ab=fs[_0x04c1('0x65')](FILEPATH,{'highWaterMark':0xf*0x400*0x400});Papa[_0x04c1('0x66')](_0x46d9ab,{'header':!![],'skipEmptyLines':!![],'step':function(_0x24d850,_0x1892e7){total+=0x1;var _0x2e559f=total;promises['push'](checkRow(_0x24d850,_0x5e207d,_0x2e559f)[_0x04c1('0x2a')](function(){success+=0x1;})[_0x04c1('0x52')](function(_0xe9006){if(_0xe9006[_0x04c1('0x13')]){errors+=0x1;delete _0xe9006[_0x04c1('0x13')];}else if(_0xe9006[_0x04c1('0x26')]){duplicates+=0x1;delete _0xe9006[_0x04c1('0x26')];}rows[_0x04c1('0x2b')](_0xe9006);}));if(total%0xc8===0x0){_0x1892e7['pause']();return processPromises(_0x1892e7);}},'complete':function(){return processPromises()[_0x04c1('0x2a')](function(){logger[_0x04c1('0x63')](_0x04c1('0x67'));endCsv();});},'error':function(_0x4b2d66,_0x1e9661){logger[_0x04c1('0x63')](_0x04c1('0x68'),JSON[_0x04c1('0x2d')](_0x4b2d66));endCsv();}});})[_0x04c1('0x52')](function(_0x14760b){logger[_0x04c1('0x13')](_0x04c1('0x69'),JSON[_0x04c1('0x2d')](_0x14760b));});}main();
\ No newline at end of file