Built motion from commit 00bf23f6.|2.6.16
[motion2.git] / server / components / import / cm / csv.js
index 1284b85..35ed4a3 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 _0x6022=['generalCheckHopper','message','Error\x20processing\x20rows\x20block:','finally','emit','contact:csv_','resume','resolve','unlinkSync','exit','info','CSV\x20import\x20process\x20stopped!','createReadStream','parse','pause','CSV\x20parsed\x20correctly!','CSV\x20parse\x20error','Error\x20executing\x20contact\x20csv\x20import:','bluebird','util','lodash','squel','papaparse','ioredis','../../../mysqldb','../../../config/environment','../../../config/logger','api','redis','localhost','../../../api/cmContact/cmContact.socket','argv','undefined','null','Missing\x20filepath\x20parameter!','Missing\x20binding\x20parameters!','zipObject','split','Missing\x20ListId\x20parameter!','error','index','test','The\x20row\x20is\x20empty\x20or\x20the\x20number\x20of\x20parameters\x20does\x20not\x20match\x20the\x20columns!','errors','length','hasOwnProperty','data','firstName','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','find','duplicate','Duplicate\x20Contact','CmContact','keys','push','pick','catch','Error\x20while\x20creating\x20contact:\x20','stringify','checkHopper','inspect','into','cm_hopper','fromQuery','ContactId','createdAt','updatedAt','select','field','NOW()','toString','from','cm_contacts','where','deletedAt\x20IS\x20NULL','ListId\x20=\x20?','phone\x20IS\x20NOT\x20NULL','\x20=\x20?','insert','scheduledAt','id\x20IN\x20?','str','phone\x20NOT\x20IN\x20(?)','calleridnum','cm_hopper_black','VoiceQueue','outbound','dialCheckDuplicateType','CmList','Lists','then','get','sequelize','query','VoiceQueueId','onlyIfOpen','all','findAll','BlackLists','always','CampaignId','Campaign','cmContact,\x20%s,\x20%s'];(function(_0x247dc0,_0x3a2bb){var _0x554e23=function(_0x33f75e){while(--_0x33f75e){_0x247dc0['push'](_0x247dc0['shift']());}};_0x554e23(++_0x3a2bb);}(_0x6022,0x162));var _0x2602=function(_0xe8bc84,_0x54f2ca){_0xe8bc84=_0xe8bc84-0x0;var _0x298c0b=_0x6022[_0xe8bc84];return _0x298c0b;};'use strict';var BPromise=require(_0x2602('0x0'));var util=require(_0x2602('0x1'));var _=require(_0x2602('0x2'));var fs=require('fs');var squel=require(_0x2602('0x3'));var Papa=require(_0x2602('0x4'));var Redis=require(_0x2602('0x5'));var db=require(_0x2602('0x6'))['db'];var config=require(_0x2602('0x7'));var logger=require(_0x2602('0x8'))(_0x2602('0x9'));config[_0x2602('0xa')]=_['defaults'](config[_0x2602('0xa')],{'host':_0x2602('0xb'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x2602('0xa')]));require(_0x2602('0xc'))['register'](socket);try{if(!process[_0x2602('0xd')][0x2]||process[_0x2602('0xd')][0x2]===_0x2602('0xe')||process[_0x2602('0xd')][0x2]===_0x2602('0xf')){throw new Error(_0x2602('0x10'));}var FILEPATH=process['argv'][0x2];if(!process[_0x2602('0xd')][0x3]||process['argv'][0x3]==='undefined'||process[_0x2602('0xd')][0x3]===_0x2602('0xf')||!process[_0x2602('0xd')][0x4]||process[_0x2602('0xd')][0x4]==='undefined'||process[_0x2602('0xd')][0x4]===_0x2602('0xf')){throw new Error(_0x2602('0x11'));}var FIELDS=_[_0x2602('0x12')](process[_0x2602('0xd')][0x3][_0x2602('0x13')](','),process[_0x2602('0xd')][0x4][_0x2602('0x13')](','));if(!process[_0x2602('0xd')][0x5]||process[_0x2602('0xd')][0x5]===_0x2602('0xe')||process[_0x2602('0xd')][0x5]===_0x2602('0xf')){throw new Error(_0x2602('0x14'));}var LISTID=process['argv'][0x5];var COMPANYID=process[_0x2602('0xd')][0x6]&&process[_0x2602('0xd')][0x6]!=='undefined'&&process[_0x2602('0xd')][0x6]!==_0x2602('0xf')?process['argv'][0x6]:null;var DUPLICATES=process[_0x2602('0xd')][0x7]&&process[_0x2602('0xd')][0x7]!=='undefined'&&process['argv'][0x7]!==_0x2602('0xf')?process['argv'][0x7]:null;if(!process[_0x2602('0xd')][0x8]||process[_0x2602('0xd')][0x8]===_0x2602('0xe')||process[_0x2602('0xd')][0x8]==='null'){throw new Error('Missing\x20socket_timestamp\x20parameter!');}var SOCKET_TIMESTAMP=process['argv'][0x8];}catch(_0x11700e){logger[_0x2602('0x15')](_0x11700e);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(_0x36fc4f,_0x2bf2ad,_0xea3ac4,_0x1b8e6f){var _0x38f447={'message':_0x2bf2ad};_0x38f447[_0x36fc4f]=!![];if(_0xea3ac4){_0x38f447['contact']=_0xea3ac4;}if(_0x1b8e6f){_0x38f447[_0x2602('0x16')]=_0x1b8e6f;}return _0x38f447;}function isEmail(_0x2997e4){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))*$/[_0x2602('0x17')](_0x2997e4);}function checkRow(_0xc56548,_0x559de1,_0x4add6d){return new BPromise(function(_0xfe2444,_0x2650c7){if(_['isNil'](_0xc56548)){return _0x2650c7(handleCheckRowError(_0x2602('0x15'),_0x2602('0x18'),null,_0x4add6d));}if(_0xc56548['errors']&&_0xc56548[_0x2602('0x19')][_0x2602('0x1a')]){var _0x405339=_['map'](_0xc56548[_0x2602('0x19')],'message')['join'](';');return _0x2650c7(handleCheckRowError('error',_0x405339,null,_0x4add6d));}var _0x51bd4a={};for(var _0x529e3c in FIELDS){if(FIELDS[_0x2602('0x1b')](_0x529e3c)&&FIELDS[_0x529e3c]){_0x51bd4a[_0x529e3c]=_0xc56548[_0x2602('0x1c')][0x0][FIELDS[_0x529e3c]]||_0xc56548['data'][0x0]['\ufeff'+FIELDS[_0x529e3c]];}}if(!_0x51bd4a[_0x2602('0x1d')]){return _0x2650c7(handleCheckRowError(_0x2602('0x15'),'firstName\x20not\x20specified!',null,_0x4add6d));}if(!_0x51bd4a[_0x2602('0x1e')]){return _0x2650c7(handleCheckRowError(_0x2602('0x15'),_0x2602('0x1f'),null,_0x4add6d));}if(_0x51bd4a[_0x2602('0x20')]){var _0x16f144=moment(_0x51bd4a[_0x2602('0x20')],_0x2602('0x21'));if(!_0x16f144[_0x2602('0x22')]()){return _0x2650c7(handleCheckRowError('error',_0x2602('0x23'),null,_0x4add6d));}}if(_0x51bd4a[_0x2602('0x24')]){if(!isEmail(_0x51bd4a['email'])){return _0x2650c7(handleCheckRowError(_0x2602('0x15'),_0x2602('0x25'),null,_0x4add6d));}}_0x51bd4a[_0x2602('0x26')]=LISTID;_0x51bd4a[_0x2602('0x27')]=COMPANYID||undefined;if(DUPLICATES&&DUPLICATES['length']&&_0x559de1){var _0x55d1b9={};for(var _0x4925b4=0x0,_0x4a05c0=DUPLICATES[_0x2602('0x1a')];_0x4925b4<_0x4a05c0;_0x4925b4+=0x1){_0x55d1b9[DUPLICATES[_0x4925b4]]=_0x51bd4a[DUPLICATES[_0x4925b4]];}var _0x514664=_[_0x2602('0x28')](_0x559de1,_0x55d1b9);if(_0x514664){return _0x2650c7(handleCheckRowError(_0x2602('0x29'),_0x2602('0x2a'),_0x514664,_0x4add6d));}}return db[_0x2602('0x2b')]['create'](_0x51bd4a,{'raw':!![],'hooks':![],'fields':_[_0x2602('0x2c')](_0x51bd4a)})['then'](function(_0xdc9ce5){if(DUPLICATES&&DUPLICATES['length']&&_0x559de1){_0x559de1[_0x2602('0x2d')](_[_0x2602('0x2e')](_0x51bd4a,DUPLICATES));}hopperContacts+=(hopperContacts?',':'')+_0xdc9ce5['id'];return _0xfe2444();})[_0x2602('0x2f')](function(_0x24acbe){return _0x2650c7(handleCheckRowError(_0x2602('0x15'),_0x2602('0x30')+(_0x24acbe['message']||JSON[_0x2602('0x31')](_0x24acbe)),null,_0x4add6d));});});}function checkHopper(){function _0x2f2a16(){return function(_0x5b9731){logger[_0x2602('0x15')]('cmContact',_0x2602('0x32'),util[_0x2602('0x33')](_0x5b9731,{'showHidden':![],'depth':null}));};}var _0x41e3bb=function(_0x577278,_0x229b7){var _0xf4e3c9=squel['insert']()[_0x2602('0x34')](_0x2602('0x35'))[_0x2602('0x36')](['phone','scheduledAt',_0x2602('0x37'),_0x2602('0x26'),_0x229b7,_0x2602('0x38'),_0x2602('0x39')],squel[_0x2602('0x3a')]()[_0x2602('0x3b')](_0x2602('0x1e'),_0x2602('0x1e'))[_0x2602('0x3b')](_0x2602('0x3c'),'scheduledAt')[_0x2602('0x3b')]('id',_0x2602('0x37'))['field'](LISTID['toString'](),_0x2602('0x26'))[_0x2602('0x3b')](_0x577278['id'][_0x2602('0x3d')](),_0x229b7)[_0x2602('0x3b')]('NOW()',_0x2602('0x38'))['field']('NOW()',_0x2602('0x39'))[_0x2602('0x3e')](_0x2602('0x3f'))[_0x2602('0x40')](_0x2602('0x41'))[_0x2602('0x40')](_0x2602('0x42'),LISTID[_0x2602('0x3d')]())[_0x2602('0x40')](_0x2602('0x43'))[_0x2602('0x40')]('phone\x20NOT\x20IN\x20(?)',squel[_0x2602('0x3a')]()['field'](_0x2602('0x1e'))[_0x2602('0x3e')]('cm_hopper')[_0x2602('0x40')](_0x229b7+_0x2602('0x44'),_0x577278['id'][_0x2602('0x3d')]())))[_0x2602('0x3d')]();return _0xf4e3c9;};var _0xc7ece2=function(_0x4d842f,_0x120378){var _0x3d68b7=squel[_0x2602('0x45')]()[_0x2602('0x34')](_0x2602('0x35'))[_0x2602('0x36')]([_0x2602('0x1e'),_0x2602('0x46'),_0x2602('0x37'),_0x2602('0x26'),_0x120378,'createdAt','updatedAt'],squel[_0x2602('0x3a')]()[_0x2602('0x3b')](_0x2602('0x1e'),_0x2602('0x1e'))[_0x2602('0x3b')]('NOW()',_0x2602('0x46'))[_0x2602('0x3b')]('id',_0x2602('0x37'))[_0x2602('0x3b')](LISTID[_0x2602('0x3d')](),_0x2602('0x26'))['field'](_0x4d842f['id'][_0x2602('0x3d')](),_0x120378)[_0x2602('0x3b')]('NOW()','createdAt')[_0x2602('0x3b')](_0x2602('0x3c'),_0x2602('0x39'))[_0x2602('0x3e')](_0x2602('0x3f'))[_0x2602('0x40')](_0x2602('0x41'))[_0x2602('0x40')](_0x2602('0x42'),LISTID[_0x2602('0x3d')]())[_0x2602('0x40')](_0x2602('0x47'),squel[_0x2602('0x48')](hopperContacts))[_0x2602('0x40')](_0x2602('0x43'))[_0x2602('0x40')](_0x2602('0x49'),squel[_0x2602('0x3a')]()[_0x2602('0x3b')](_0x2602('0x4a'))[_0x2602('0x3e')]('cm_hopper_final')['where'](_0x120378+_0x2602('0x44'),_0x4d842f['id'][_0x2602('0x3d')]()))[_0x2602('0x40')](_0x2602('0x49'),squel[_0x2602('0x3a')]()[_0x2602('0x3b')](_0x2602('0x1e'))['from'](_0x2602('0x35'))[_0x2602('0x40')](_0x120378+_0x2602('0x44'),_0x4d842f['id'][_0x2602('0x3d')]())))['toString']();return _0x3d68b7;};function _0x337863(_0x34babd,_0xda1eaa){var _0x2cb921=squel[_0x2602('0x45')]()['into']('cm_hopper')[_0x2602('0x36')]([_0x2602('0x1e'),_0x2602('0x46'),_0x2602('0x37'),_0x2602('0x26'),_0xda1eaa,_0x2602('0x38'),_0x2602('0x39')],squel[_0x2602('0x3a')]()['field'](_0x2602('0x1e'),_0x2602('0x1e'))[_0x2602('0x3b')](_0x2602('0x3c'),_0x2602('0x46'))['field']('id',_0x2602('0x37'))['field'](LISTID[_0x2602('0x3d')](),_0x2602('0x26'))['field'](_0x34babd['id']['toString'](),_0xda1eaa)['field'](_0x2602('0x3c'),'createdAt')[_0x2602('0x3b')]('NOW()','updatedAt')[_0x2602('0x3e')](_0x2602('0x3f'))[_0x2602('0x40')]('deletedAt\x20IS\x20NULL')[_0x2602('0x40')](_0x2602('0x42'),LISTID['toString']())[_0x2602('0x40')](_0x2602('0x47'),squel[_0x2602('0x48')](hopperContacts))['where'](_0x2602('0x43')))['toString']();return _0x2cb921;}function _0x360c2a(_0x730599,_0x4a66dc){var _0x23e4c3=squel[_0x2602('0x45')]()['into'](_0x2602('0x4b'))['fromQuery']([_0x2602('0x1e'),_0x2602('0x37'),'ListId',_0x4a66dc,_0x2602('0x38'),_0x2602('0x39')],squel[_0x2602('0x3a')]()[_0x2602('0x3b')](_0x2602('0x1e'),_0x2602('0x1e'))[_0x2602('0x3b')]('id',_0x2602('0x37'))['field'](LISTID[_0x2602('0x3d')](),_0x2602('0x26'))[_0x2602('0x3b')](_0x730599['id']['toString'](),_0x4a66dc)['field'](_0x2602('0x3c'),'createdAt')['field'](_0x2602('0x3c'),'updatedAt')[_0x2602('0x3e')](_0x2602('0x3f'))['where'](_0x2602('0x41'))[_0x2602('0x40')](_0x2602('0x42'),LISTID[_0x2602('0x3d')]())[_0x2602('0x40')](_0x2602('0x47'),squel[_0x2602('0x48')](hopperContacts))[_0x2602('0x40')](_0x2602('0x43')))[_0x2602('0x3d')]();return _0x23e4c3;}return db[_0x2602('0x4c')]['findAll']({'where':{'type':_0x2602('0x4d')},'attributes':['id',_0x2602('0x4e')],'include':[{'model':db[_0x2602('0x4f')],'as':_0x2602('0x50'),'where':{'id':LISTID}}]})[_0x2602('0x51')](function(_0x590c22){var _0x1e632a=[];if(_0x590c22){var _0x2faaa8;for(var _0x210094=0x0,_0x2cf84c;_0x210094<_0x590c22[_0x2602('0x1a')];_0x210094+=0x1){_0x2cf84c=_0x590c22[_0x210094][_0x2602('0x52')]({'plain':!![]});switch(_0x2cf84c[_0x2602('0x4e')]){case'always':_0x1e632a[_0x2602('0x2d')](db[_0x2602('0x53')][_0x2602('0x54')](_0xc7ece2(_0x2cf84c,_0x2602('0x55')))[_0x2602('0x51')](function(){})[_0x2602('0x2f')](_0x2f2a16()));break;case _0x2602('0x56'):_0x1e632a[_0x2602('0x2d')](db[_0x2602('0x53')][_0x2602('0x54')](_0x41e3bb(_0x2cf84c,'VoiceQueueId'))[_0x2602('0x51')](function(){})['catch'](_0x2f2a16()));break;default:_0x1e632a[_0x2602('0x2d')](db['sequelize']['query'](_0x337863(_0x2cf84c,_0x2602('0x55')))[_0x2602('0x51')](function(){})['catch'](_0x2f2a16()));}}}return _0x1e632a;})[_0x2602('0x57')]()[_0x2602('0x51')](function(){return db[_0x2602('0x4c')][_0x2602('0x58')]({'where':{'type':'outbound'},'attributes':['id'],'include':[{'model':db[_0x2602('0x4f')],'as':_0x2602('0x59'),'where':{'id':LISTID}}]})[_0x2602('0x51')](function(_0x4270ae){var _0x5e358b=[];if(_0x4270ae){var _0x1f785e;for(var _0xd7a48=0x0,_0x3c5826;_0xd7a48<_0x4270ae[_0x2602('0x1a')];_0xd7a48+=0x1){_0x3c5826=_0x4270ae[_0xd7a48][_0x2602('0x52')]({'plain':!![]});_0x5e358b[_0x2602('0x2d')](db[_0x2602('0x53')][_0x2602('0x54')](_0x360c2a(_0x3c5826,_0x2602('0x55')))['then'](function(){})[_0x2602('0x2f')](_0x2f2a16()));}}return _0x5e358b;})[_0x2602('0x57')]();})[_0x2602('0x51')](function(){return db['Campaign']['findAll']({'attributes':['id',_0x2602('0x4e')],'include':[{'model':db[_0x2602('0x4f')],'as':_0x2602('0x50'),'where':{'id':LISTID}}]})[_0x2602('0x51')](function(_0x533c4c){var _0x40f546=[];if(_0x533c4c){for(var _0x125007=0x0,_0x185d24;_0x125007<_0x533c4c[_0x2602('0x1a')];_0x125007+=0x1){_0x185d24=_0x533c4c[_0x125007]['get']({'plain':!![]});switch(_0x185d24[_0x2602('0x4e')]){case _0x2602('0x5a'):_0x40f546[_0x2602('0x2d')](db[_0x2602('0x53')][_0x2602('0x54')](_0xc7ece2(_0x185d24,_0x2602('0x5b')))[_0x2602('0x51')](function(){})[_0x2602('0x2f')](_0x2f2a16()));break;case'onlyIfOpen':_0x40f546[_0x2602('0x2d')](db[_0x2602('0x53')][_0x2602('0x54')](_0x41e3bb(_0x185d24,'CampaignId'))['then'](function(){})['catch'](_0x2f2a16()));break;default:_0x40f546[_0x2602('0x2d')](db[_0x2602('0x53')][_0x2602('0x54')](_0x337863(_0x185d24,_0x2602('0x5b')))[_0x2602('0x51')](function(){})['catch'](_0x2f2a16()));}}}return _0x40f546;})['all']();})[_0x2602('0x51')](function(){return db[_0x2602('0x5c')][_0x2602('0x58')]({'attributes':['id'],'include':[{'model':db[_0x2602('0x4f')],'as':_0x2602('0x59'),'where':{'id':LISTID}}]})[_0x2602('0x51')](function(_0x23f497){var _0x22b346=[];if(_0x23f497){for(var _0x411c0a=0x0,_0x40eb40;_0x411c0a<_0x23f497[_0x2602('0x1a')];_0x411c0a+=0x1){_0x40eb40=_0x23f497[_0x411c0a][_0x2602('0x52')]({'plain':!![]});_0x22b346[_0x2602('0x2d')](db[_0x2602('0x53')][_0x2602('0x54')](_0x360c2a(_0x40eb40,_0x2602('0x5b')))['then'](function(){})['catch'](_0x2f2a16()));}}return _0x22b346;})[_0x2602('0x57')]();})[_0x2602('0x2f')](function(_0x24052c){logger[_0x2602('0x15')](_0x2602('0x5d'),_0x2602('0x5e'),_0x24052c[_0x2602('0x5f')]);});}var processPromises=function(_0x44dd15){return BPromise['all'](promises)[_0x2602('0x51')](function(_0x5f2c02){})[_0x2602('0x2f')](function(_0x3fbc9f){logger[_0x2602('0x15')](_0x2602('0x60'),JSON[_0x2602('0x31')](_0x3fbc9f));})[_0x2602('0x61')](function(){socket[_0x2602('0x62')](_0x2602('0x63')+SOCKET_TIMESTAMP,{'success':success,'errors':errors,'duplicates':duplicates,'rows':rows});promises=[];success=0x0;errors=0x0;duplicates=0x0;rows=[];if(_0x44dd15){return _0x44dd15[_0x2602('0x64')]();}});};var endCsv=function(){return BPromise[_0x2602('0x65')]()[_0x2602('0x51')](function(){if(hopperContacts){return checkHopper();}})['then'](function(){socket[_0x2602('0x62')]('contact:csv_'+SOCKET_TIMESTAMP,{'finished':!![],'success':success,'errors':errors,'duplicates':duplicates,'rows':rows});try{fs[_0x2602('0x66')](FILEPATH);}catch(_0x40fabb){logger[_0x2602('0x15')]('Unable\x20to\x20delete\x20temp\x20file:',JSON[_0x2602('0x31')](_0x40fabb));}finally{process[_0x2602('0x67')](0x0);}});};process['on']('SIGINT',function(){logger[_0x2602('0x68')](_0x2602('0x69'));endCsv();});function main(){return BPromise[_0x2602('0x65')]()[_0x2602('0x51')](function(){if(DUPLICATES){DUPLICATES=DUPLICATES[_0x2602('0x13')](',');return db['CmContact'][_0x2602('0x58')]({'where':{'ListId':LISTID},'attributes':DUPLICATES,'raw':!![]});}})[_0x2602('0x51')](function(_0x126429){var _0x3d80b0=fs[_0x2602('0x6a')](FILEPATH,{'highWaterMark':0xf*0x400*0x400});Papa[_0x2602('0x6b')](_0x3d80b0,{'header':!![],'skipEmptyLines':!![],'step':function(_0x30e40,_0xea2ab8){total+=0x1;var _0xea0d9c=total;promises[_0x2602('0x2d')](checkRow(_0x30e40,_0x126429,_0xea0d9c)[_0x2602('0x51')](function(){success+=0x1;})['catch'](function(_0x5ccb5d){if(_0x5ccb5d[_0x2602('0x15')]){errors+=0x1;delete _0x5ccb5d[_0x2602('0x15')];}else if(_0x5ccb5d[_0x2602('0x29')]){duplicates+=0x1;delete _0x5ccb5d[_0x2602('0x29')];}rows['push'](_0x5ccb5d);}));if(total%0xc8===0x0){_0xea2ab8[_0x2602('0x6c')]();return processPromises(_0xea2ab8);}},'complete':function(){return processPromises()[_0x2602('0x51')](function(){logger[_0x2602('0x68')](_0x2602('0x6d'));endCsv();});},'error':function(_0x2cd538,_0x117799){logger[_0x2602('0x68')](_0x2602('0x6e'),JSON[_0x2602('0x31')](_0x2cd538));endCsv();}});})[_0x2602('0x2f')](function(_0x32f3e6){logger[_0x2602('0x15')](_0x2602('0x6f'),JSON['stringify'](_0x32f3e6));});}main();
\ No newline at end of file