Built motion from commit da24aabd.|2.6.20
[motion2.git] / server / components / import / cm / csv.js
index 1284b85..7c3da0b 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x0fc5=['query','VoiceQueueId','sequelize','BlackLists','get','Campaign','dialCheckDuplicateType','Lists','CampaignId','onlyIfOpen','all','cmContact,\x20%s,\x20%s','generalCheckHopper','Error\x20processing\x20rows\x20block:','finally','emit','contact:csv_','resume','unlinkSync','Unable\x20to\x20delete\x20temp\x20file:','SIGINT','info','CSV\x20import\x20process\x20stopped!','resolve','CmContact','createReadStream','parse','pause','CSV\x20parsed\x20correctly!','CSV\x20parse\x20error','bluebird','util','lodash','squel','../../../mysqldb','../../../config/environment','../../../config/logger','api','redis','register','argv','undefined','null','Missing\x20filepath\x20parameter!','Missing\x20binding\x20parameters!','split','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','data','firstName','firstName\x20not\x20specified!','phone','phone\x20not\x20specified!','birthDate','isValid','birthDate\x20format\x20is\x20invalid,\x20YYYY-MM-DD\x20format\x20is\x20supported!','email','email\x20format\x20is\x20not\x20valid!','ListId','CompanyId','find','duplicate','Duplicate\x20Contact','create','keys','then','push','pick','catch','Error\x20while\x20creating\x20contact:\x20','stringify','cmContact','inspect','fromQuery','createdAt','updatedAt','select','field','NOW()','scheduledAt','ContactId','from','cm_contacts','where','deletedAt\x20IS\x20NULL','phone\x20IS\x20NOT\x20NULL','cm_hopper','\x20=\x20?','toString','insert','into','ListId\x20=\x20?','id\x20IN\x20?','str','phone\x20NOT\x20IN\x20(?)','calleridnum','cm_hopper_black','VoiceQueue','findAll','outbound','CmList','always'];(function(_0x240362,_0x156794){var _0x26de18=function(_0x4a4431){while(--_0x4a4431){_0x240362['push'](_0x240362['shift']());}};_0x26de18(++_0x156794);}(_0x0fc5,0x8f));var _0x50fc=function(_0x1e9385,_0xa80c81){_0x1e9385=_0x1e9385-0x0;var _0x274e88=_0x0fc5[_0x1e9385];return _0x274e88;};'use strict';var BPromise=require(_0x50fc('0x0'));var util=require(_0x50fc('0x1'));var _=require(_0x50fc('0x2'));var fs=require('fs');var squel=require(_0x50fc('0x3'));var Papa=require('papaparse');var Redis=require('ioredis');var db=require(_0x50fc('0x4'))['db'];var config=require(_0x50fc('0x5'));var logger=require(_0x50fc('0x6'))(_0x50fc('0x7'));config[_0x50fc('0x8')]=_['defaults'](config[_0x50fc('0x8')],{'host':'localhost','port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config['redis']));require('../../../api/cmContact/cmContact.socket')[_0x50fc('0x9')](socket);try{if(!process['argv'][0x2]||process[_0x50fc('0xa')][0x2]===_0x50fc('0xb')||process[_0x50fc('0xa')][0x2]===_0x50fc('0xc')){throw new Error(_0x50fc('0xd'));}var FILEPATH=process[_0x50fc('0xa')][0x2];if(!process[_0x50fc('0xa')][0x3]||process['argv'][0x3]===_0x50fc('0xb')||process[_0x50fc('0xa')][0x3]===_0x50fc('0xc')||!process[_0x50fc('0xa')][0x4]||process[_0x50fc('0xa')][0x4]===_0x50fc('0xb')||process[_0x50fc('0xa')][0x4]===_0x50fc('0xc')){throw new Error(_0x50fc('0xe'));}var FIELDS=_['zipObject'](process[_0x50fc('0xa')][0x3][_0x50fc('0xf')](','),process[_0x50fc('0xa')][0x4][_0x50fc('0xf')](','));if(!process[_0x50fc('0xa')][0x5]||process[_0x50fc('0xa')][0x5]===_0x50fc('0xb')||process['argv'][0x5]==='null'){throw new Error(_0x50fc('0x10'));}var LISTID=process[_0x50fc('0xa')][0x5];var COMPANYID=process['argv'][0x6]&&process[_0x50fc('0xa')][0x6]!==_0x50fc('0xb')&&process[_0x50fc('0xa')][0x6]!=='null'?process[_0x50fc('0xa')][0x6]:null;var DUPLICATES=process[_0x50fc('0xa')][0x7]&&process[_0x50fc('0xa')][0x7]!==_0x50fc('0xb')&&process[_0x50fc('0xa')][0x7]!=='null'?process[_0x50fc('0xa')][0x7]:null;if(!process['argv'][0x8]||process[_0x50fc('0xa')][0x8]==='undefined'||process['argv'][0x8]==='null'){throw new Error(_0x50fc('0x11'));}var SOCKET_TIMESTAMP=process[_0x50fc('0xa')][0x8];}catch(_0x470acf){logger[_0x50fc('0x12')](_0x470acf);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(_0x5241b4,_0x2f6191,_0x43efae,_0x25393f){var _0x1a1790={'message':_0x2f6191};_0x1a1790[_0x5241b4]=!![];if(_0x43efae){_0x1a1790[_0x50fc('0x13')]=_0x43efae;}if(_0x25393f){_0x1a1790[_0x50fc('0x14')]=_0x25393f;}return _0x1a1790;}function isEmail(_0x36b585){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))*$/[_0x50fc('0x15')](_0x36b585);}function checkRow(_0x3e75a7,_0x6b5e8b,_0x197cd4){return new BPromise(function(_0x360b71,_0x579ca5){if(_[_0x50fc('0x16')](_0x3e75a7)){return _0x579ca5(handleCheckRowError(_0x50fc('0x12'),_0x50fc('0x17'),null,_0x197cd4));}if(_0x3e75a7[_0x50fc('0x18')]&&_0x3e75a7['errors'][_0x50fc('0x19')]){var _0xa0c54c=_[_0x50fc('0x1a')](_0x3e75a7[_0x50fc('0x18')],_0x50fc('0x1b'))[_0x50fc('0x1c')](';');return _0x579ca5(handleCheckRowError(_0x50fc('0x12'),_0xa0c54c,null,_0x197cd4));}var _0x522ca6={};for(var _0x282de3 in FIELDS){if(FIELDS['hasOwnProperty'](_0x282de3)&&FIELDS[_0x282de3]){_0x522ca6[_0x282de3]=_0x3e75a7['data'][0x0][FIELDS[_0x282de3]]||_0x3e75a7[_0x50fc('0x1d')][0x0]['\ufeff'+FIELDS[_0x282de3]];}}if(!_0x522ca6[_0x50fc('0x1e')]){return _0x579ca5(handleCheckRowError(_0x50fc('0x12'),_0x50fc('0x1f'),null,_0x197cd4));}if(!_0x522ca6[_0x50fc('0x20')]){return _0x579ca5(handleCheckRowError(_0x50fc('0x12'),_0x50fc('0x21'),null,_0x197cd4));}if(_0x522ca6[_0x50fc('0x22')]){var _0x1556a2=moment(_0x522ca6[_0x50fc('0x22')],'YYYY-MM-DD');if(!_0x1556a2[_0x50fc('0x23')]()){return _0x579ca5(handleCheckRowError('error',_0x50fc('0x24'),null,_0x197cd4));}}if(_0x522ca6[_0x50fc('0x25')]){if(!isEmail(_0x522ca6[_0x50fc('0x25')])){return _0x579ca5(handleCheckRowError('error',_0x50fc('0x26'),null,_0x197cd4));}}_0x522ca6[_0x50fc('0x27')]=LISTID;_0x522ca6[_0x50fc('0x28')]=COMPANYID||undefined;if(DUPLICATES&&DUPLICATES[_0x50fc('0x19')]&&_0x6b5e8b){var _0x93d7e={};for(var _0x315479=0x0,_0x4a0071=DUPLICATES[_0x50fc('0x19')];_0x315479<_0x4a0071;_0x315479+=0x1){_0x93d7e[DUPLICATES[_0x315479]]=_0x522ca6[DUPLICATES[_0x315479]];}var _0x561d9e=_[_0x50fc('0x29')](_0x6b5e8b,_0x93d7e);if(_0x561d9e){return _0x579ca5(handleCheckRowError(_0x50fc('0x2a'),_0x50fc('0x2b'),_0x561d9e,_0x197cd4));}}return db['CmContact'][_0x50fc('0x2c')](_0x522ca6,{'raw':!![],'hooks':![],'fields':_[_0x50fc('0x2d')](_0x522ca6)})[_0x50fc('0x2e')](function(_0x5b156e){if(DUPLICATES&&DUPLICATES['length']&&_0x6b5e8b){_0x6b5e8b[_0x50fc('0x2f')](_[_0x50fc('0x30')](_0x522ca6,DUPLICATES));}hopperContacts+=(hopperContacts?',':'')+_0x5b156e['id'];return _0x360b71();})[_0x50fc('0x31')](function(_0x123079){return _0x579ca5(handleCheckRowError(_0x50fc('0x12'),_0x50fc('0x32')+(_0x123079['message']||JSON[_0x50fc('0x33')](_0x123079)),null,_0x197cd4));});});}function checkHopper(){function _0x54cdbd(){return function(_0x18e38b){logger[_0x50fc('0x12')](_0x50fc('0x34'),'checkHopper',util[_0x50fc('0x35')](_0x18e38b,{'showHidden':![],'depth':null}));};}var _0x45cc2f=function(_0x266f92,_0xab4bf5){var _0x375502=squel['insert']()['into']('cm_hopper')[_0x50fc('0x36')]([_0x50fc('0x20'),'scheduledAt','ContactId',_0x50fc('0x27'),_0xab4bf5,_0x50fc('0x37'),_0x50fc('0x38')],squel[_0x50fc('0x39')]()[_0x50fc('0x3a')]('phone',_0x50fc('0x20'))[_0x50fc('0x3a')](_0x50fc('0x3b'),_0x50fc('0x3c'))[_0x50fc('0x3a')]('id',_0x50fc('0x3d'))['field'](LISTID['toString'](),_0x50fc('0x27'))['field'](_0x266f92['id']['toString'](),_0xab4bf5)[_0x50fc('0x3a')](_0x50fc('0x3b'),_0x50fc('0x37'))[_0x50fc('0x3a')](_0x50fc('0x3b'),_0x50fc('0x38'))[_0x50fc('0x3e')](_0x50fc('0x3f'))[_0x50fc('0x40')](_0x50fc('0x41'))['where']('ListId\x20=\x20?',LISTID['toString']())[_0x50fc('0x40')](_0x50fc('0x42'))['where']('phone\x20NOT\x20IN\x20(?)',squel[_0x50fc('0x39')]()[_0x50fc('0x3a')](_0x50fc('0x20'))[_0x50fc('0x3e')](_0x50fc('0x43'))['where'](_0xab4bf5+_0x50fc('0x44'),_0x266f92['id'][_0x50fc('0x45')]())))[_0x50fc('0x45')]();return _0x375502;};var _0x4afb2a=function(_0x288f43,_0xb44826){var _0x1e3e92=squel[_0x50fc('0x46')]()[_0x50fc('0x47')]('cm_hopper')[_0x50fc('0x36')]([_0x50fc('0x20'),_0x50fc('0x3c'),'ContactId',_0x50fc('0x27'),_0xb44826,'createdAt','updatedAt'],squel[_0x50fc('0x39')]()[_0x50fc('0x3a')](_0x50fc('0x20'),_0x50fc('0x20'))['field'](_0x50fc('0x3b'),'scheduledAt')[_0x50fc('0x3a')]('id',_0x50fc('0x3d'))['field'](LISTID[_0x50fc('0x45')](),'ListId')[_0x50fc('0x3a')](_0x288f43['id'][_0x50fc('0x45')](),_0xb44826)[_0x50fc('0x3a')](_0x50fc('0x3b'),_0x50fc('0x37'))[_0x50fc('0x3a')](_0x50fc('0x3b'),'updatedAt')[_0x50fc('0x3e')]('cm_contacts')[_0x50fc('0x40')](_0x50fc('0x41'))[_0x50fc('0x40')](_0x50fc('0x48'),LISTID[_0x50fc('0x45')]())[_0x50fc('0x40')](_0x50fc('0x49'),squel[_0x50fc('0x4a')](hopperContacts))[_0x50fc('0x40')](_0x50fc('0x42'))[_0x50fc('0x40')](_0x50fc('0x4b'),squel[_0x50fc('0x39')]()[_0x50fc('0x3a')](_0x50fc('0x4c'))['from']('cm_hopper_final')[_0x50fc('0x40')](_0xb44826+'\x20=\x20?',_0x288f43['id'][_0x50fc('0x45')]()))[_0x50fc('0x40')](_0x50fc('0x4b'),squel[_0x50fc('0x39')]()['field'](_0x50fc('0x20'))[_0x50fc('0x3e')](_0x50fc('0x43'))['where'](_0xb44826+_0x50fc('0x44'),_0x288f43['id'][_0x50fc('0x45')]())))[_0x50fc('0x45')]();return _0x1e3e92;};function _0x2883e3(_0x3c322c,_0x32787c){var _0x2c979a=squel[_0x50fc('0x46')]()['into']('cm_hopper')['fromQuery']([_0x50fc('0x20'),_0x50fc('0x3c'),'ContactId',_0x50fc('0x27'),_0x32787c,_0x50fc('0x37'),_0x50fc('0x38')],squel['select']()['field'](_0x50fc('0x20'),_0x50fc('0x20'))[_0x50fc('0x3a')](_0x50fc('0x3b'),_0x50fc('0x3c'))['field']('id','ContactId')[_0x50fc('0x3a')](LISTID[_0x50fc('0x45')](),'ListId')[_0x50fc('0x3a')](_0x3c322c['id'][_0x50fc('0x45')](),_0x32787c)['field'](_0x50fc('0x3b'),_0x50fc('0x37'))[_0x50fc('0x3a')](_0x50fc('0x3b'),_0x50fc('0x38'))[_0x50fc('0x3e')](_0x50fc('0x3f'))[_0x50fc('0x40')](_0x50fc('0x41'))[_0x50fc('0x40')](_0x50fc('0x48'),LISTID[_0x50fc('0x45')]())[_0x50fc('0x40')](_0x50fc('0x49'),squel[_0x50fc('0x4a')](hopperContacts))[_0x50fc('0x40')](_0x50fc('0x42')))[_0x50fc('0x45')]();return _0x2c979a;}function _0x1a2d54(_0x98d366,_0x15e2e5){var _0x1e86d3=squel['insert']()[_0x50fc('0x47')](_0x50fc('0x4d'))['fromQuery']([_0x50fc('0x20'),'ContactId','ListId',_0x15e2e5,'createdAt','updatedAt'],squel[_0x50fc('0x39')]()['field'](_0x50fc('0x20'),_0x50fc('0x20'))['field']('id',_0x50fc('0x3d'))[_0x50fc('0x3a')](LISTID[_0x50fc('0x45')](),_0x50fc('0x27'))[_0x50fc('0x3a')](_0x98d366['id']['toString'](),_0x15e2e5)[_0x50fc('0x3a')](_0x50fc('0x3b'),_0x50fc('0x37'))['field']('NOW()','updatedAt')['from'](_0x50fc('0x3f'))[_0x50fc('0x40')](_0x50fc('0x41'))['where'](_0x50fc('0x48'),LISTID[_0x50fc('0x45')]())[_0x50fc('0x40')](_0x50fc('0x49'),squel[_0x50fc('0x4a')](hopperContacts))['where'](_0x50fc('0x42')))[_0x50fc('0x45')]();return _0x1e86d3;}return db[_0x50fc('0x4e')][_0x50fc('0x4f')]({'where':{'type':_0x50fc('0x50')},'attributes':['id','dialCheckDuplicateType'],'include':[{'model':db[_0x50fc('0x51')],'as':'Lists','where':{'id':LISTID}}]})['then'](function(_0x314fa6){var _0xfa63f2=[];if(_0x314fa6){var _0x3ba65b;for(var _0x2a355e=0x0,_0x513ce5;_0x2a355e<_0x314fa6['length'];_0x2a355e+=0x1){_0x513ce5=_0x314fa6[_0x2a355e]['get']({'plain':!![]});switch(_0x513ce5['dialCheckDuplicateType']){case _0x50fc('0x52'):_0xfa63f2[_0x50fc('0x2f')](db['sequelize'][_0x50fc('0x53')](_0x4afb2a(_0x513ce5,_0x50fc('0x54')))[_0x50fc('0x2e')](function(){})[_0x50fc('0x31')](_0x54cdbd()));break;case'onlyIfOpen':_0xfa63f2[_0x50fc('0x2f')](db[_0x50fc('0x55')][_0x50fc('0x53')](_0x45cc2f(_0x513ce5,_0x50fc('0x54')))[_0x50fc('0x2e')](function(){})[_0x50fc('0x31')](_0x54cdbd()));break;default:_0xfa63f2[_0x50fc('0x2f')](db[_0x50fc('0x55')][_0x50fc('0x53')](_0x2883e3(_0x513ce5,_0x50fc('0x54')))['then'](function(){})['catch'](_0x54cdbd()));}}}return _0xfa63f2;})['all']()[_0x50fc('0x2e')](function(){return db[_0x50fc('0x4e')]['findAll']({'where':{'type':'outbound'},'attributes':['id'],'include':[{'model':db[_0x50fc('0x51')],'as':_0x50fc('0x56'),'where':{'id':LISTID}}]})[_0x50fc('0x2e')](function(_0x84dca5){var _0x4189b2=[];if(_0x84dca5){var _0x335519;for(var _0x16919d=0x0,_0x570f07;_0x16919d<_0x84dca5[_0x50fc('0x19')];_0x16919d+=0x1){_0x570f07=_0x84dca5[_0x16919d][_0x50fc('0x57')]({'plain':!![]});_0x4189b2[_0x50fc('0x2f')](db[_0x50fc('0x55')][_0x50fc('0x53')](_0x1a2d54(_0x570f07,'VoiceQueueId'))[_0x50fc('0x2e')](function(){})['catch'](_0x54cdbd()));}}return _0x4189b2;})['all']();})[_0x50fc('0x2e')](function(){return db[_0x50fc('0x58')][_0x50fc('0x4f')]({'attributes':['id',_0x50fc('0x59')],'include':[{'model':db[_0x50fc('0x51')],'as':_0x50fc('0x5a'),'where':{'id':LISTID}}]})[_0x50fc('0x2e')](function(_0x5d6337){var _0x3ff321=[];if(_0x5d6337){for(var _0x4f4f8c=0x0,_0x25f236;_0x4f4f8c<_0x5d6337[_0x50fc('0x19')];_0x4f4f8c+=0x1){_0x25f236=_0x5d6337[_0x4f4f8c][_0x50fc('0x57')]({'plain':!![]});switch(_0x25f236[_0x50fc('0x59')]){case _0x50fc('0x52'):_0x3ff321[_0x50fc('0x2f')](db[_0x50fc('0x55')][_0x50fc('0x53')](_0x4afb2a(_0x25f236,_0x50fc('0x5b')))[_0x50fc('0x2e')](function(){})['catch'](_0x54cdbd()));break;case _0x50fc('0x5c'):_0x3ff321['push'](db[_0x50fc('0x55')][_0x50fc('0x53')](_0x45cc2f(_0x25f236,_0x50fc('0x5b')))[_0x50fc('0x2e')](function(){})['catch'](_0x54cdbd()));break;default:_0x3ff321['push'](db[_0x50fc('0x55')][_0x50fc('0x53')](_0x2883e3(_0x25f236,_0x50fc('0x5b')))[_0x50fc('0x2e')](function(){})['catch'](_0x54cdbd()));}}}return _0x3ff321;})['all']();})[_0x50fc('0x2e')](function(){return db[_0x50fc('0x58')]['findAll']({'attributes':['id'],'include':[{'model':db[_0x50fc('0x51')],'as':_0x50fc('0x56'),'where':{'id':LISTID}}]})[_0x50fc('0x2e')](function(_0x28ca0e){var _0x55df69=[];if(_0x28ca0e){for(var _0x2d0d29=0x0,_0x3fa7a0;_0x2d0d29<_0x28ca0e[_0x50fc('0x19')];_0x2d0d29+=0x1){_0x3fa7a0=_0x28ca0e[_0x2d0d29][_0x50fc('0x57')]({'plain':!![]});_0x55df69[_0x50fc('0x2f')](db[_0x50fc('0x55')][_0x50fc('0x53')](_0x1a2d54(_0x3fa7a0,_0x50fc('0x5b')))[_0x50fc('0x2e')](function(){})[_0x50fc('0x31')](_0x54cdbd()));}}return _0x55df69;})[_0x50fc('0x5d')]();})[_0x50fc('0x31')](function(_0x4faa91){logger[_0x50fc('0x12')](_0x50fc('0x5e'),_0x50fc('0x5f'),_0x4faa91[_0x50fc('0x1b')]);});}var processPromises=function(_0x528408){return BPromise[_0x50fc('0x5d')](promises)['then'](function(_0x5d1cb5){})['catch'](function(_0x4f7bef){logger[_0x50fc('0x12')](_0x50fc('0x60'),JSON[_0x50fc('0x33')](_0x4f7bef));})[_0x50fc('0x61')](function(){socket[_0x50fc('0x62')](_0x50fc('0x63')+SOCKET_TIMESTAMP,{'success':success,'errors':errors,'duplicates':duplicates,'rows':rows});promises=[];success=0x0;errors=0x0;duplicates=0x0;rows=[];if(_0x528408){return _0x528408[_0x50fc('0x64')]();}});};var endCsv=function(){return BPromise['resolve']()['then'](function(){if(hopperContacts){return checkHopper();}})[_0x50fc('0x2e')](function(){socket[_0x50fc('0x62')](_0x50fc('0x63')+SOCKET_TIMESTAMP,{'finished':!![],'success':success,'errors':errors,'duplicates':duplicates,'rows':rows});try{fs[_0x50fc('0x65')](FILEPATH);}catch(_0x2cef4e){logger[_0x50fc('0x12')](_0x50fc('0x66'),JSON[_0x50fc('0x33')](_0x2cef4e));}finally{process['exit'](0x0);}});};process['on'](_0x50fc('0x67'),function(){logger[_0x50fc('0x68')](_0x50fc('0x69'));endCsv();});function main(){return BPromise[_0x50fc('0x6a')]()['then'](function(){if(DUPLICATES){DUPLICATES=DUPLICATES[_0x50fc('0xf')](',');return db[_0x50fc('0x6b')][_0x50fc('0x4f')]({'where':{'ListId':LISTID},'attributes':DUPLICATES,'raw':!![]});}})['then'](function(_0x24456f){var _0x15208b=fs[_0x50fc('0x6c')](FILEPATH,{'highWaterMark':0xf*0x400*0x400});Papa[_0x50fc('0x6d')](_0x15208b,{'header':!![],'skipEmptyLines':!![],'step':function(_0x35a846,_0x1a2728){total+=0x1;var _0x21f72a=total;promises[_0x50fc('0x2f')](checkRow(_0x35a846,_0x24456f,_0x21f72a)[_0x50fc('0x2e')](function(){success+=0x1;})[_0x50fc('0x31')](function(_0x54187d){if(_0x54187d[_0x50fc('0x12')]){errors+=0x1;delete _0x54187d[_0x50fc('0x12')];}else if(_0x54187d[_0x50fc('0x2a')]){duplicates+=0x1;delete _0x54187d[_0x50fc('0x2a')];}rows[_0x50fc('0x2f')](_0x54187d);}));if(total%0xc8===0x0){_0x1a2728[_0x50fc('0x6e')]();return processPromises(_0x1a2728);}},'complete':function(){return processPromises()[_0x50fc('0x2e')](function(){logger[_0x50fc('0x68')](_0x50fc('0x6f'));endCsv();});},'error':function(_0x1d6049,_0x2e71ca){logger[_0x50fc('0x68')](_0x50fc('0x70'),JSON[_0x50fc('0x33')](_0x1d6049));endCsv();}});})[_0x50fc('0x31')](function(_0x3c41f5){logger[_0x50fc('0x12')]('Error\x20executing\x20contact\x20csv\x20import:',JSON[_0x50fc('0x33')](_0x3c41f5));});}main();
\ No newline at end of file
+var _0xc2f2=['Campaign','CmList','Lists','CampaignId','cmContact,\x20%s,\x20%s','generalCheckHopper','Error\x20processing\x20rows\x20block:','stringify','finally','emit','contact:csv_','resolve','unlinkSync','exit','SIGINT','info','CSV\x20import\x20process\x20stopped!','parse','pause','CSV\x20parsed\x20correctly!','CSV\x20parse\x20error','Error\x20executing\x20contact\x20csv\x20import:','bluebird','lodash','squel','papaparse','ioredis','../../../mysqldb','../../../config/logger','api','redis','defaults','localhost','socket.io-emitter','../../../api/cmContact/cmContact.socket','argv','undefined','null','Missing\x20filepath\x20parameter!','Missing\x20binding\x20parameters!','zipObject','split','Missing\x20ListId\x20parameter!','Missing\x20socket_timestamp\x20parameter!','error','contact','test','isNil','The\x20row\x20is\x20empty\x20or\x20the\x20number\x20of\x20parameters\x20does\x20not\x20match\x20the\x20columns!','errors','map','message','join','data','firstName\x20not\x20specified!','phone','phone\x20not\x20specified!','birthDate','YYYY-MM-DD','birthDate\x20format\x20is\x20invalid,\x20YYYY-MM-DD\x20format\x20is\x20supported!','email','email\x20format\x20is\x20not\x20valid!','ListId','CompanyId','find','duplicate','Duplicate\x20Contact','CmContact','create','then','push','pick','catch','Error\x20while\x20creating\x20contact:\x20','cmContact','insert','into','cm_hopper','fromQuery','scheduledAt','createdAt','updatedAt','field','ContactId','toString','NOW()','from','cm_contacts','where','deletedAt\x20IS\x20NULL','ListId\x20=\x20?','phone\x20IS\x20NOT\x20NULL','phone\x20NOT\x20IN\x20(?)','select','id\x20IN\x20?','calleridnum','cm_hopper_final','\x20=\x20?','str','cm_hopper_black','findAll','dialCheckDuplicateType','length','get','always','query','onlyIfOpen','sequelize','VoiceQueueId','all','VoiceQueue','outbound','BlackLists'];(function(_0x558e53,_0x56ffc4){var _0x1fd3a2=function(_0x5c2d13){while(--_0x5c2d13){_0x558e53['push'](_0x558e53['shift']());}};_0x1fd3a2(++_0x56ffc4);}(_0xc2f2,0x169));var _0x2c2f=function(_0x5af97c,_0x24a49f){_0x5af97c=_0x5af97c-0x0;var _0x3472ae=_0xc2f2[_0x5af97c];return _0x3472ae;};'use strict';var BPromise=require(_0x2c2f('0x0'));var util=require('util');var _=require(_0x2c2f('0x1'));var fs=require('fs');var squel=require(_0x2c2f('0x2'));var Papa=require(_0x2c2f('0x3'));var Redis=require(_0x2c2f('0x4'));var db=require(_0x2c2f('0x5'))['db'];var config=require('../../../config/environment');var logger=require(_0x2c2f('0x6'))(_0x2c2f('0x7'));config[_0x2c2f('0x8')]=_[_0x2c2f('0x9')](config[_0x2c2f('0x8')],{'host':_0x2c2f('0xa'),'port':0x18eb});var socket=require(_0x2c2f('0xb'))(new Redis(config[_0x2c2f('0x8')]));require(_0x2c2f('0xc'))['register'](socket);try{if(!process['argv'][0x2]||process[_0x2c2f('0xd')][0x2]===_0x2c2f('0xe')||process[_0x2c2f('0xd')][0x2]===_0x2c2f('0xf')){throw new Error(_0x2c2f('0x10'));}var FILEPATH=process[_0x2c2f('0xd')][0x2];if(!process[_0x2c2f('0xd')][0x3]||process[_0x2c2f('0xd')][0x3]===_0x2c2f('0xe')||process[_0x2c2f('0xd')][0x3]===_0x2c2f('0xf')||!process[_0x2c2f('0xd')][0x4]||process[_0x2c2f('0xd')][0x4]==='undefined'||process[_0x2c2f('0xd')][0x4]===_0x2c2f('0xf')){throw new Error(_0x2c2f('0x11'));}var FIELDS=_[_0x2c2f('0x12')](process[_0x2c2f('0xd')][0x3][_0x2c2f('0x13')](','),process[_0x2c2f('0xd')][0x4][_0x2c2f('0x13')](','));if(!process['argv'][0x5]||process[_0x2c2f('0xd')][0x5]==='undefined'||process[_0x2c2f('0xd')][0x5]===_0x2c2f('0xf')){throw new Error(_0x2c2f('0x14'));}var LISTID=process[_0x2c2f('0xd')][0x5];var COMPANYID=process['argv'][0x6]&&process[_0x2c2f('0xd')][0x6]!=='undefined'&&process[_0x2c2f('0xd')][0x6]!==_0x2c2f('0xf')?process[_0x2c2f('0xd')][0x6]:null;var DUPLICATES=process[_0x2c2f('0xd')][0x7]&&process['argv'][0x7]!==_0x2c2f('0xe')&&process['argv'][0x7]!=='null'?process[_0x2c2f('0xd')][0x7]:null;if(!process[_0x2c2f('0xd')][0x8]||process[_0x2c2f('0xd')][0x8]===_0x2c2f('0xe')||process[_0x2c2f('0xd')][0x8]===_0x2c2f('0xf')){throw new Error(_0x2c2f('0x15'));}var SOCKET_TIMESTAMP=process[_0x2c2f('0xd')][0x8];}catch(_0xdf0efa){logger[_0x2c2f('0x16')](_0xdf0efa);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(_0x128abe,_0x1afcba,_0x1984a4,_0x109517){var _0xbbcd79={'message':_0x1afcba};_0xbbcd79[_0x128abe]=!![];if(_0x1984a4){_0xbbcd79[_0x2c2f('0x17')]=_0x1984a4;}if(_0x109517){_0xbbcd79['index']=_0x109517;}return _0xbbcd79;}function isEmail(_0x5cfe89){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))*$/[_0x2c2f('0x18')](_0x5cfe89);}function checkRow(_0x27863f,_0x103e4f,_0x512434){return new BPromise(function(_0x17f75a,_0x10aee3){if(_[_0x2c2f('0x19')](_0x27863f)){return _0x10aee3(handleCheckRowError('error',_0x2c2f('0x1a'),null,_0x512434));}if(_0x27863f[_0x2c2f('0x1b')]&&_0x27863f[_0x2c2f('0x1b')]['length']){var _0x53259d=_[_0x2c2f('0x1c')](_0x27863f['errors'],_0x2c2f('0x1d'))[_0x2c2f('0x1e')](';');return _0x10aee3(handleCheckRowError(_0x2c2f('0x16'),_0x53259d,null,_0x512434));}var _0x8c772f={};for(var _0x442d84 in FIELDS){if(FIELDS['hasOwnProperty'](_0x442d84)&&FIELDS[_0x442d84]){_0x8c772f[_0x442d84]=_0x27863f['data'][0x0][FIELDS[_0x442d84]]||_0x27863f[_0x2c2f('0x1f')][0x0]['\ufeff'+FIELDS[_0x442d84]];}}if(!_0x8c772f['firstName']){return _0x10aee3(handleCheckRowError(_0x2c2f('0x16'),_0x2c2f('0x20'),null,_0x512434));}if(!_0x8c772f[_0x2c2f('0x21')]){return _0x10aee3(handleCheckRowError(_0x2c2f('0x16'),_0x2c2f('0x22'),null,_0x512434));}if(_0x8c772f['birthDate']){var _0x3c447b=moment(_0x8c772f[_0x2c2f('0x23')],_0x2c2f('0x24'));if(!_0x3c447b['isValid']()){return _0x10aee3(handleCheckRowError(_0x2c2f('0x16'),_0x2c2f('0x25'),null,_0x512434));}}if(_0x8c772f[_0x2c2f('0x26')]){if(!isEmail(_0x8c772f[_0x2c2f('0x26')])){return _0x10aee3(handleCheckRowError(_0x2c2f('0x16'),_0x2c2f('0x27'),null,_0x512434));}}_0x8c772f[_0x2c2f('0x28')]=LISTID;_0x8c772f[_0x2c2f('0x29')]=COMPANYID||undefined;if(DUPLICATES&&DUPLICATES['length']&&_0x103e4f){var _0x299249={};for(var _0x38043d=0x0,_0x56d297=DUPLICATES['length'];_0x38043d<_0x56d297;_0x38043d+=0x1){_0x299249[DUPLICATES[_0x38043d]]=_0x8c772f[DUPLICATES[_0x38043d]];}var _0x7ff074=_[_0x2c2f('0x2a')](_0x103e4f,_0x299249);if(_0x7ff074){return _0x10aee3(handleCheckRowError(_0x2c2f('0x2b'),_0x2c2f('0x2c'),_0x7ff074,_0x512434));}}return db[_0x2c2f('0x2d')][_0x2c2f('0x2e')](_0x8c772f,{'raw':!![],'hooks':![],'fields':_['keys'](_0x8c772f)})[_0x2c2f('0x2f')](function(_0x5c7a33){if(DUPLICATES&&DUPLICATES['length']&&_0x103e4f){_0x103e4f[_0x2c2f('0x30')](_[_0x2c2f('0x31')](_0x8c772f,DUPLICATES));}hopperContacts+=(hopperContacts?',':'')+_0x5c7a33['id'];return _0x17f75a();})[_0x2c2f('0x32')](function(_0x2b6de1){return _0x10aee3(handleCheckRowError(_0x2c2f('0x16'),_0x2c2f('0x33')+(_0x2b6de1[_0x2c2f('0x1d')]||JSON['stringify'](_0x2b6de1)),null,_0x512434));});});}function checkHopper(){function _0x2fe209(){return function(_0x46ffb4){logger['error'](_0x2c2f('0x34'),'checkHopper',util['inspect'](_0x46ffb4,{'showHidden':![],'depth':null}));};}var _0x1bfdd2=function(_0x522d94,_0x5da945){var _0x5aa76b=squel[_0x2c2f('0x35')]()[_0x2c2f('0x36')](_0x2c2f('0x37'))[_0x2c2f('0x38')](['phone',_0x2c2f('0x39'),'ContactId',_0x2c2f('0x28'),_0x5da945,_0x2c2f('0x3a'),_0x2c2f('0x3b')],squel['select']()[_0x2c2f('0x3c')](_0x2c2f('0x21'),_0x2c2f('0x21'))['field']('NOW()',_0x2c2f('0x39'))[_0x2c2f('0x3c')]('id',_0x2c2f('0x3d'))[_0x2c2f('0x3c')](LISTID[_0x2c2f('0x3e')](),'ListId')[_0x2c2f('0x3c')](_0x522d94['id'][_0x2c2f('0x3e')](),_0x5da945)['field']('NOW()',_0x2c2f('0x3a'))[_0x2c2f('0x3c')](_0x2c2f('0x3f'),_0x2c2f('0x3b'))[_0x2c2f('0x40')](_0x2c2f('0x41'))[_0x2c2f('0x42')](_0x2c2f('0x43'))['where'](_0x2c2f('0x44'),LISTID[_0x2c2f('0x3e')]())[_0x2c2f('0x42')](_0x2c2f('0x45'))[_0x2c2f('0x42')](_0x2c2f('0x46'),squel[_0x2c2f('0x47')]()[_0x2c2f('0x3c')](_0x2c2f('0x21'))['from'](_0x2c2f('0x37'))['where'](_0x5da945+'\x20=\x20?',_0x522d94['id'][_0x2c2f('0x3e')]())))['toString']();return _0x5aa76b;};var _0x42be21=function(_0x3f360e,_0xf7ee88){var _0x3d6220=squel[_0x2c2f('0x35')]()[_0x2c2f('0x36')]('cm_hopper')['fromQuery']([_0x2c2f('0x21'),_0x2c2f('0x39'),_0x2c2f('0x3d'),_0x2c2f('0x28'),_0xf7ee88,_0x2c2f('0x3a'),_0x2c2f('0x3b')],squel[_0x2c2f('0x47')]()[_0x2c2f('0x3c')](_0x2c2f('0x21'),_0x2c2f('0x21'))['field'](_0x2c2f('0x3f'),_0x2c2f('0x39'))['field']('id','ContactId')['field'](LISTID[_0x2c2f('0x3e')](),_0x2c2f('0x28'))[_0x2c2f('0x3c')](_0x3f360e['id']['toString'](),_0xf7ee88)[_0x2c2f('0x3c')]('NOW()','createdAt')[_0x2c2f('0x3c')]('NOW()',_0x2c2f('0x3b'))[_0x2c2f('0x40')](_0x2c2f('0x41'))['where'](_0x2c2f('0x43'))['where']('ListId\x20=\x20?',LISTID[_0x2c2f('0x3e')]())[_0x2c2f('0x42')](_0x2c2f('0x48'),squel['str'](hopperContacts))[_0x2c2f('0x42')]('phone\x20IS\x20NOT\x20NULL')[_0x2c2f('0x42')](_0x2c2f('0x46'),squel['select']()[_0x2c2f('0x3c')](_0x2c2f('0x49'))[_0x2c2f('0x40')](_0x2c2f('0x4a'))[_0x2c2f('0x42')](_0xf7ee88+_0x2c2f('0x4b'),_0x3f360e['id']['toString']()))['where'](_0x2c2f('0x46'),squel[_0x2c2f('0x47')]()['field'](_0x2c2f('0x21'))[_0x2c2f('0x40')]('cm_hopper')[_0x2c2f('0x42')](_0xf7ee88+_0x2c2f('0x4b'),_0x3f360e['id']['toString']())))[_0x2c2f('0x3e')]();return _0x3d6220;};function _0x510563(_0xeaefc7,_0x2da4b0){var _0x282b05=squel['insert']()[_0x2c2f('0x36')](_0x2c2f('0x37'))[_0x2c2f('0x38')]([_0x2c2f('0x21'),'scheduledAt','ContactId',_0x2c2f('0x28'),_0x2da4b0,'createdAt',_0x2c2f('0x3b')],squel[_0x2c2f('0x47')]()[_0x2c2f('0x3c')](_0x2c2f('0x21'),'phone')[_0x2c2f('0x3c')](_0x2c2f('0x3f'),'scheduledAt')[_0x2c2f('0x3c')]('id',_0x2c2f('0x3d'))[_0x2c2f('0x3c')](LISTID[_0x2c2f('0x3e')](),_0x2c2f('0x28'))[_0x2c2f('0x3c')](_0xeaefc7['id']['toString'](),_0x2da4b0)['field'](_0x2c2f('0x3f'),'createdAt')[_0x2c2f('0x3c')](_0x2c2f('0x3f'),'updatedAt')[_0x2c2f('0x40')](_0x2c2f('0x41'))[_0x2c2f('0x42')]('deletedAt\x20IS\x20NULL')[_0x2c2f('0x42')]('ListId\x20=\x20?',LISTID[_0x2c2f('0x3e')]())[_0x2c2f('0x42')]('id\x20IN\x20?',squel[_0x2c2f('0x4c')](hopperContacts))[_0x2c2f('0x42')](_0x2c2f('0x45')))['toString']();return _0x282b05;}function _0x4de468(_0x1ed398,_0xbd7bd9){var _0x400430=squel['insert']()[_0x2c2f('0x36')](_0x2c2f('0x4d'))['fromQuery']([_0x2c2f('0x21'),_0x2c2f('0x3d'),_0x2c2f('0x28'),_0xbd7bd9,'createdAt',_0x2c2f('0x3b')],squel['select']()['field'](_0x2c2f('0x21'),_0x2c2f('0x21'))[_0x2c2f('0x3c')]('id',_0x2c2f('0x3d'))[_0x2c2f('0x3c')](LISTID[_0x2c2f('0x3e')](),_0x2c2f('0x28'))[_0x2c2f('0x3c')](_0x1ed398['id'][_0x2c2f('0x3e')](),_0xbd7bd9)['field'](_0x2c2f('0x3f'),_0x2c2f('0x3a'))[_0x2c2f('0x3c')](_0x2c2f('0x3f'),_0x2c2f('0x3b'))[_0x2c2f('0x40')]('cm_contacts')[_0x2c2f('0x42')](_0x2c2f('0x43'))['where'](_0x2c2f('0x44'),LISTID[_0x2c2f('0x3e')]())[_0x2c2f('0x42')]('id\x20IN\x20?',squel['str'](hopperContacts))[_0x2c2f('0x42')](_0x2c2f('0x45')))[_0x2c2f('0x3e')]();return _0x400430;}return db['VoiceQueue'][_0x2c2f('0x4e')]({'where':{'type':'outbound'},'attributes':['id',_0x2c2f('0x4f')],'include':[{'model':db['CmList'],'as':'Lists','where':{'id':LISTID}}]})[_0x2c2f('0x2f')](function(_0x503744){var _0x559977=[];if(_0x503744){var _0x48bb32;for(var _0x2b78f5=0x0,_0x195313;_0x2b78f5<_0x503744[_0x2c2f('0x50')];_0x2b78f5+=0x1){_0x195313=_0x503744[_0x2b78f5][_0x2c2f('0x51')]({'plain':!![]});switch(_0x195313[_0x2c2f('0x4f')]){case _0x2c2f('0x52'):_0x559977['push'](db['sequelize'][_0x2c2f('0x53')](_0x42be21(_0x195313,'VoiceQueueId'))[_0x2c2f('0x2f')](function(){})[_0x2c2f('0x32')](_0x2fe209()));break;case _0x2c2f('0x54'):_0x559977[_0x2c2f('0x30')](db[_0x2c2f('0x55')][_0x2c2f('0x53')](_0x1bfdd2(_0x195313,_0x2c2f('0x56')))[_0x2c2f('0x2f')](function(){})['catch'](_0x2fe209()));break;default:_0x559977['push'](db['sequelize'][_0x2c2f('0x53')](_0x510563(_0x195313,'VoiceQueueId'))[_0x2c2f('0x2f')](function(){})[_0x2c2f('0x32')](_0x2fe209()));}}}return _0x559977;})[_0x2c2f('0x57')]()[_0x2c2f('0x2f')](function(){return db[_0x2c2f('0x58')][_0x2c2f('0x4e')]({'where':{'type':_0x2c2f('0x59')},'attributes':['id'],'include':[{'model':db['CmList'],'as':_0x2c2f('0x5a'),'where':{'id':LISTID}}]})['then'](function(_0x5db28b){var _0x40a200=[];if(_0x5db28b){var _0x478a2f;for(var _0x43fc07=0x0,_0x50778b;_0x43fc07<_0x5db28b[_0x2c2f('0x50')];_0x43fc07+=0x1){_0x50778b=_0x5db28b[_0x43fc07][_0x2c2f('0x51')]({'plain':!![]});_0x40a200[_0x2c2f('0x30')](db[_0x2c2f('0x55')][_0x2c2f('0x53')](_0x4de468(_0x50778b,_0x2c2f('0x56')))[_0x2c2f('0x2f')](function(){})['catch'](_0x2fe209()));}}return _0x40a200;})[_0x2c2f('0x57')]();})[_0x2c2f('0x2f')](function(){return db[_0x2c2f('0x5b')][_0x2c2f('0x4e')]({'attributes':['id','dialCheckDuplicateType'],'include':[{'model':db[_0x2c2f('0x5c')],'as':_0x2c2f('0x5d'),'where':{'id':LISTID}}]})[_0x2c2f('0x2f')](function(_0x189667){var _0x1f40a7=[];if(_0x189667){for(var _0x504d02=0x0,_0x587108;_0x504d02<_0x189667[_0x2c2f('0x50')];_0x504d02+=0x1){_0x587108=_0x189667[_0x504d02][_0x2c2f('0x51')]({'plain':!![]});switch(_0x587108[_0x2c2f('0x4f')]){case _0x2c2f('0x52'):_0x1f40a7[_0x2c2f('0x30')](db[_0x2c2f('0x55')]['query'](_0x42be21(_0x587108,'CampaignId'))['then'](function(){})[_0x2c2f('0x32')](_0x2fe209()));break;case'onlyIfOpen':_0x1f40a7[_0x2c2f('0x30')](db[_0x2c2f('0x55')][_0x2c2f('0x53')](_0x1bfdd2(_0x587108,_0x2c2f('0x5e')))['then'](function(){})[_0x2c2f('0x32')](_0x2fe209()));break;default:_0x1f40a7[_0x2c2f('0x30')](db['sequelize'][_0x2c2f('0x53')](_0x510563(_0x587108,_0x2c2f('0x5e')))['then'](function(){})[_0x2c2f('0x32')](_0x2fe209()));}}}return _0x1f40a7;})[_0x2c2f('0x57')]();})[_0x2c2f('0x2f')](function(){return db['Campaign'][_0x2c2f('0x4e')]({'attributes':['id'],'include':[{'model':db[_0x2c2f('0x5c')],'as':'BlackLists','where':{'id':LISTID}}]})[_0x2c2f('0x2f')](function(_0x4f3139){var _0x4fb7eb=[];if(_0x4f3139){for(var _0x3a36f4=0x0,_0x17a776;_0x3a36f4<_0x4f3139[_0x2c2f('0x50')];_0x3a36f4+=0x1){_0x17a776=_0x4f3139[_0x3a36f4]['get']({'plain':!![]});_0x4fb7eb[_0x2c2f('0x30')](db[_0x2c2f('0x55')][_0x2c2f('0x53')](_0x4de468(_0x17a776,'CampaignId'))['then'](function(){})[_0x2c2f('0x32')](_0x2fe209()));}}return _0x4fb7eb;})[_0x2c2f('0x57')]();})[_0x2c2f('0x32')](function(_0x54e826){logger[_0x2c2f('0x16')](_0x2c2f('0x5f'),_0x2c2f('0x60'),_0x54e826[_0x2c2f('0x1d')]);});}var processPromises=function(_0x4f9466){return BPromise[_0x2c2f('0x57')](promises)['then'](function(_0x51fa88){})['catch'](function(_0x7cfe2){logger[_0x2c2f('0x16')](_0x2c2f('0x61'),JSON[_0x2c2f('0x62')](_0x7cfe2));})[_0x2c2f('0x63')](function(){socket[_0x2c2f('0x64')](_0x2c2f('0x65')+SOCKET_TIMESTAMP,{'success':success,'errors':errors,'duplicates':duplicates,'rows':rows});promises=[];success=0x0;errors=0x0;duplicates=0x0;rows=[];if(_0x4f9466){return _0x4f9466['resume']();}});};var endCsv=function(){return BPromise[_0x2c2f('0x66')]()[_0x2c2f('0x2f')](function(){if(hopperContacts){return checkHopper();}})[_0x2c2f('0x2f')](function(){socket[_0x2c2f('0x64')](_0x2c2f('0x65')+SOCKET_TIMESTAMP,{'finished':!![],'success':success,'errors':errors,'duplicates':duplicates,'rows':rows});try{fs[_0x2c2f('0x67')](FILEPATH);}catch(_0x1b400f){logger[_0x2c2f('0x16')]('Unable\x20to\x20delete\x20temp\x20file:',JSON[_0x2c2f('0x62')](_0x1b400f));}finally{process[_0x2c2f('0x68')](0x0);}});};process['on'](_0x2c2f('0x69'),function(){logger[_0x2c2f('0x6a')](_0x2c2f('0x6b'));endCsv();});function main(){return BPromise[_0x2c2f('0x66')]()[_0x2c2f('0x2f')](function(){if(DUPLICATES){DUPLICATES=DUPLICATES[_0x2c2f('0x13')](',');return db['CmContact'][_0x2c2f('0x4e')]({'where':{'ListId':LISTID},'attributes':DUPLICATES,'raw':!![]});}})[_0x2c2f('0x2f')](function(_0x35312a){var _0x2fb8cf=fs['createReadStream'](FILEPATH,{'highWaterMark':0xf*0x400*0x400});Papa[_0x2c2f('0x6c')](_0x2fb8cf,{'header':!![],'skipEmptyLines':!![],'step':function(_0xed8f42,_0x1f7338){total+=0x1;var _0x4dcf59=total;promises[_0x2c2f('0x30')](checkRow(_0xed8f42,_0x35312a,_0x4dcf59)['then'](function(){success+=0x1;})[_0x2c2f('0x32')](function(_0x43f9f0){if(_0x43f9f0['error']){errors+=0x1;delete _0x43f9f0[_0x2c2f('0x16')];}else if(_0x43f9f0[_0x2c2f('0x2b')]){duplicates+=0x1;delete _0x43f9f0['duplicate'];}rows[_0x2c2f('0x30')](_0x43f9f0);}));if(total%0xc8===0x0){_0x1f7338[_0x2c2f('0x6d')]();return processPromises(_0x1f7338);}},'complete':function(){return processPromises()[_0x2c2f('0x2f')](function(){logger['info'](_0x2c2f('0x6e'));endCsv();});},'error':function(_0x4da1f9,_0x346e61){logger['info'](_0x2c2f('0x6f'),JSON[_0x2c2f('0x62')](_0x4da1f9));endCsv();}});})[_0x2c2f('0x32')](function(_0xe6d644){logger[_0x2c2f('0x16')](_0x2c2f('0x70'),JSON[_0x2c2f('0x62')](_0xe6d644));});}main();
\ No newline at end of file