Built motion from commit efa66e19.|2.6.22
[motion2.git] / server / components / import / cm / csv.js
index 58c6ec3..30fee7c 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xbaf0=['YYYY-MM-DD','isValid','birthDate\x20format\x20is\x20invalid,\x20YYYY-MM-DD\x20format\x20is\x20supported!','email','email\x20format\x20is\x20not\x20valid!','ListId','CompanyId','find','Duplicate\x20Contact','create','keys','then','push','pick','Error\x20while\x20creating\x20contact:\x20','stringify','checkHopper','inspect','insert','into','phone','scheduledAt','ContactId','createdAt','updatedAt','select','field','NOW()','toString','from','where','deletedAt\x20IS\x20NULL','ListId\x20=\x20?','phone\x20IS\x20NOT\x20NULL','phone\x20NOT\x20IN\x20(?)','cm_hopper','fromQuery','cm_contacts','str','cm_hopper_final','\x20=\x20?','id\x20IN\x20?','cm_hopper_black','VoiceQueue','findAll','outbound','CmList','Lists','dialCheckDuplicateType','always','sequelize','query','VoiceQueueId','onlyIfOpen','catch','all','BlackLists','get','CampaignId','cmContact,\x20%s,\x20%s','generalCheckHopper','Error\x20processing\x20rows\x20block:','finally','resolve','contact:csv_','unlinkSync','Unable\x20to\x20delete\x20temp\x20file:','exit','SIGINT','info','CSV\x20import\x20process\x20stopped!','CmContact','createReadStream','parse','duplicate','pause','util','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\x20socket_timestamp\x20parameter!','error','contact','isNil','The\x20row\x20is\x20empty\x20or\x20the\x20number\x20of\x20parameters\x20does\x20not\x20match\x20the\x20columns!','errors','length','map','message','join','hasOwnProperty','data','firstName\x20not\x20specified!','phone\x20not\x20specified!','birthDate'];(function(_0x198384,_0x475963){var _0x531d08=function(_0x2f7b31){while(--_0x2f7b31){_0x198384['push'](_0x198384['shift']());}};_0x531d08(++_0x475963);}(_0xbaf0,0x12a));var _0x0baf=function(_0x465028,_0x4570ac){_0x465028=_0x465028-0x0;var _0xb783d4=_0xbaf0[_0x465028];return _0xb783d4;};'use strict';var BPromise=require('bluebird');var util=require(_0x0baf('0x0'));var _=require(_0x0baf('0x1'));var fs=require('fs');var squel=require(_0x0baf('0x2'));var Papa=require(_0x0baf('0x3'));var Redis=require(_0x0baf('0x4'));var db=require(_0x0baf('0x5'))['db'];var config=require('../../../config/environment');var logger=require(_0x0baf('0x6'))(_0x0baf('0x7'));config[_0x0baf('0x8')]=_[_0x0baf('0x9')](config[_0x0baf('0x8')],{'host':_0x0baf('0xa'),'port':0x18eb});var socket=require(_0x0baf('0xb'))(new Redis(config[_0x0baf('0x8')]));require(_0x0baf('0xc'))['register'](socket);try{if(!process[_0x0baf('0xd')][0x2]||process['argv'][0x2]===_0x0baf('0xe')||process[_0x0baf('0xd')][0x2]===_0x0baf('0xf')){throw new Error(_0x0baf('0x10'));}var FILEPATH=process[_0x0baf('0xd')][0x2];if(!process[_0x0baf('0xd')][0x3]||process[_0x0baf('0xd')][0x3]===_0x0baf('0xe')||process[_0x0baf('0xd')][0x3]===_0x0baf('0xf')||!process[_0x0baf('0xd')][0x4]||process['argv'][0x4]==='undefined'||process[_0x0baf('0xd')][0x4]===_0x0baf('0xf')){throw new Error(_0x0baf('0x11'));}var FIELDS=_[_0x0baf('0x12')](process['argv'][0x3][_0x0baf('0x13')](','),process['argv'][0x4][_0x0baf('0x13')](','));if(!process[_0x0baf('0xd')][0x5]||process[_0x0baf('0xd')][0x5]===_0x0baf('0xe')||process[_0x0baf('0xd')][0x5]===_0x0baf('0xf')){throw new Error('Missing\x20ListId\x20parameter!');}var LISTID=process['argv'][0x5];var COMPANYID=process[_0x0baf('0xd')][0x6]&&process[_0x0baf('0xd')][0x6]!==_0x0baf('0xe')&&process[_0x0baf('0xd')][0x6]!==_0x0baf('0xf')?process[_0x0baf('0xd')][0x6]:null;var DUPLICATES=process['argv'][0x7]&&process[_0x0baf('0xd')][0x7]!==_0x0baf('0xe')&&process[_0x0baf('0xd')][0x7]!==_0x0baf('0xf')?process[_0x0baf('0xd')][0x7]:null;if(!process[_0x0baf('0xd')][0x8]||process['argv'][0x8]==='undefined'||process[_0x0baf('0xd')][0x8]===_0x0baf('0xf')){throw new Error(_0x0baf('0x14'));}var SOCKET_TIMESTAMP=process[_0x0baf('0xd')][0x8];}catch(_0x1fa92b){logger[_0x0baf('0x15')](_0x1fa92b);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(_0x210cd8,_0x636a13,_0x2c42e2,_0x15a2c3){var _0x54f2fa={'message':_0x636a13};_0x54f2fa[_0x210cd8]=!![];if(_0x2c42e2){_0x54f2fa[_0x0baf('0x16')]=_0x2c42e2;}if(_0x15a2c3){_0x54f2fa['index']=_0x15a2c3;}return _0x54f2fa;}function isEmail(_0xf6c158){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))*$/['test'](_0xf6c158);}function checkRow(_0x4de74c,_0x2ef0aa,_0x48a0e9){return new BPromise(function(_0x4be1b9,_0x47c4b){if(_[_0x0baf('0x17')](_0x4de74c)){return _0x47c4b(handleCheckRowError(_0x0baf('0x15'),_0x0baf('0x18'),null,_0x48a0e9));}if(_0x4de74c[_0x0baf('0x19')]&&_0x4de74c['errors'][_0x0baf('0x1a')]){var _0x4681c5=_[_0x0baf('0x1b')](_0x4de74c[_0x0baf('0x19')],_0x0baf('0x1c'))[_0x0baf('0x1d')](';');return _0x47c4b(handleCheckRowError(_0x0baf('0x15'),_0x4681c5,null,_0x48a0e9));}var _0x549fd0={};for(var _0x1590b4 in FIELDS){if(FIELDS[_0x0baf('0x1e')](_0x1590b4)&&FIELDS[_0x1590b4]){_0x549fd0[_0x1590b4]=_0x4de74c[_0x0baf('0x1f')][0x0][FIELDS[_0x1590b4]]||_0x4de74c[_0x0baf('0x1f')][0x0]['\ufeff'+FIELDS[_0x1590b4]];}}if(!_0x549fd0['firstName']){return _0x47c4b(handleCheckRowError(_0x0baf('0x15'),_0x0baf('0x20'),null,_0x48a0e9));}if(!_0x549fd0['phone']){return _0x47c4b(handleCheckRowError(_0x0baf('0x15'),_0x0baf('0x21'),null,_0x48a0e9));}if(_0x549fd0[_0x0baf('0x22')]){var _0xb4dbb1=moment(_0x549fd0[_0x0baf('0x22')],_0x0baf('0x23'));if(!_0xb4dbb1[_0x0baf('0x24')]()){return _0x47c4b(handleCheckRowError('error',_0x0baf('0x25'),null,_0x48a0e9));}}if(_0x549fd0[_0x0baf('0x26')]){if(!isEmail(_0x549fd0[_0x0baf('0x26')])){return _0x47c4b(handleCheckRowError(_0x0baf('0x15'),_0x0baf('0x27'),null,_0x48a0e9));}}_0x549fd0[_0x0baf('0x28')]=LISTID;_0x549fd0[_0x0baf('0x29')]=COMPANYID||undefined;if(DUPLICATES&&DUPLICATES[_0x0baf('0x1a')]&&_0x2ef0aa){var _0x59431b={};for(var _0x3ded64=0x0,_0x2adfd7=DUPLICATES[_0x0baf('0x1a')];_0x3ded64<_0x2adfd7;_0x3ded64+=0x1){_0x59431b[DUPLICATES[_0x3ded64]]=_0x549fd0[DUPLICATES[_0x3ded64]];}var _0x45294a=_[_0x0baf('0x2a')](_0x2ef0aa,_0x59431b);if(_0x45294a){return _0x47c4b(handleCheckRowError('duplicate',_0x0baf('0x2b'),_0x45294a,_0x48a0e9));}}return db['CmContact'][_0x0baf('0x2c')](_0x549fd0,{'raw':!![],'hooks':![],'fields':_[_0x0baf('0x2d')](_0x549fd0)})[_0x0baf('0x2e')](function(_0x3d65f2){if(DUPLICATES&&DUPLICATES['length']&&_0x2ef0aa){_0x2ef0aa[_0x0baf('0x2f')](_[_0x0baf('0x30')](_0x549fd0,DUPLICATES));}hopperContacts+=(hopperContacts?',':'')+_0x3d65f2['id'];return _0x4be1b9();})['catch'](function(_0x23d890){return _0x47c4b(handleCheckRowError(_0x0baf('0x15'),_0x0baf('0x31')+(_0x23d890[_0x0baf('0x1c')]||JSON[_0x0baf('0x32')](_0x23d890)),null,_0x48a0e9));});});}function checkHopper(){function _0x1b0991(){return function(_0xe03d82){logger[_0x0baf('0x15')]('cmContact',_0x0baf('0x33'),util[_0x0baf('0x34')](_0xe03d82,{'showHidden':![],'depth':null}));};}var _0x5b991f=function(_0x32c022,_0x57783c){var _0x5c545f=squel[_0x0baf('0x35')]()[_0x0baf('0x36')]('cm_hopper')['fromQuery']([_0x0baf('0x37'),_0x0baf('0x38'),_0x0baf('0x39'),_0x0baf('0x28'),_0x57783c,_0x0baf('0x3a'),_0x0baf('0x3b')],squel[_0x0baf('0x3c')]()[_0x0baf('0x3d')](_0x0baf('0x37'),_0x0baf('0x37'))[_0x0baf('0x3d')](_0x0baf('0x3e'),_0x0baf('0x38'))[_0x0baf('0x3d')]('id','ContactId')[_0x0baf('0x3d')](LISTID[_0x0baf('0x3f')](),'ListId')[_0x0baf('0x3d')](_0x32c022['id'][_0x0baf('0x3f')](),_0x57783c)[_0x0baf('0x3d')](_0x0baf('0x3e'),_0x0baf('0x3a'))[_0x0baf('0x3d')]('NOW()',_0x0baf('0x3b'))[_0x0baf('0x40')]('cm_contacts')[_0x0baf('0x41')](_0x0baf('0x42'))[_0x0baf('0x41')](_0x0baf('0x43'),LISTID['toString']())[_0x0baf('0x41')](_0x0baf('0x44'))[_0x0baf('0x41')](_0x0baf('0x45'),squel[_0x0baf('0x3c')]()[_0x0baf('0x3d')](_0x0baf('0x37'))[_0x0baf('0x40')](_0x0baf('0x46'))[_0x0baf('0x41')](_0x57783c+'\x20=\x20?',_0x32c022['id'][_0x0baf('0x3f')]())))[_0x0baf('0x3f')]();return _0x5c545f;};var _0x1daf1d=function(_0x339aff,_0x22207a){var _0x55f4f8=squel[_0x0baf('0x35')]()[_0x0baf('0x36')](_0x0baf('0x46'))[_0x0baf('0x47')]([_0x0baf('0x37'),'scheduledAt',_0x0baf('0x39'),_0x0baf('0x28'),_0x22207a,_0x0baf('0x3a'),_0x0baf('0x3b')],squel[_0x0baf('0x3c')]()[_0x0baf('0x3d')](_0x0baf('0x37'),'phone')[_0x0baf('0x3d')](_0x0baf('0x3e'),_0x0baf('0x38'))['field']('id',_0x0baf('0x39'))[_0x0baf('0x3d')](LISTID[_0x0baf('0x3f')](),_0x0baf('0x28'))[_0x0baf('0x3d')](_0x339aff['id'][_0x0baf('0x3f')](),_0x22207a)[_0x0baf('0x3d')]('NOW()',_0x0baf('0x3a'))[_0x0baf('0x3d')](_0x0baf('0x3e'),_0x0baf('0x3b'))[_0x0baf('0x40')](_0x0baf('0x48'))[_0x0baf('0x41')](_0x0baf('0x42'))[_0x0baf('0x41')](_0x0baf('0x43'),LISTID[_0x0baf('0x3f')]())['where']('id\x20IN\x20?',squel[_0x0baf('0x49')](hopperContacts))[_0x0baf('0x41')](_0x0baf('0x44'))[_0x0baf('0x41')](_0x0baf('0x45'),squel[_0x0baf('0x3c')]()[_0x0baf('0x3d')]('calleridnum')[_0x0baf('0x40')](_0x0baf('0x4a'))[_0x0baf('0x41')](_0x22207a+_0x0baf('0x4b'),_0x339aff['id'][_0x0baf('0x3f')]()))[_0x0baf('0x41')]('phone\x20NOT\x20IN\x20(?)',squel[_0x0baf('0x3c')]()['field'](_0x0baf('0x37'))['from'](_0x0baf('0x46'))['where'](_0x22207a+_0x0baf('0x4b'),_0x339aff['id']['toString']())))[_0x0baf('0x3f')]();return _0x55f4f8;};function _0xcf7b8d(_0x411c1f,_0x4520d1){var _0x42a68b=squel['insert']()[_0x0baf('0x36')](_0x0baf('0x46'))[_0x0baf('0x47')]([_0x0baf('0x37'),_0x0baf('0x38'),_0x0baf('0x39'),'ListId',_0x4520d1,_0x0baf('0x3a'),_0x0baf('0x3b')],squel[_0x0baf('0x3c')]()[_0x0baf('0x3d')](_0x0baf('0x37'),_0x0baf('0x37'))[_0x0baf('0x3d')]('NOW()','scheduledAt')[_0x0baf('0x3d')]('id',_0x0baf('0x39'))[_0x0baf('0x3d')](LISTID[_0x0baf('0x3f')](),_0x0baf('0x28'))[_0x0baf('0x3d')](_0x411c1f['id'][_0x0baf('0x3f')](),_0x4520d1)[_0x0baf('0x3d')](_0x0baf('0x3e'),'createdAt')[_0x0baf('0x3d')](_0x0baf('0x3e'),_0x0baf('0x3b'))[_0x0baf('0x40')](_0x0baf('0x48'))[_0x0baf('0x41')](_0x0baf('0x42'))['where'](_0x0baf('0x43'),LISTID[_0x0baf('0x3f')]())[_0x0baf('0x41')](_0x0baf('0x4c'),squel[_0x0baf('0x49')](hopperContacts))[_0x0baf('0x41')](_0x0baf('0x44')))[_0x0baf('0x3f')]();return _0x42a68b;}function _0x498405(_0x178495,_0x5dc434){var _0x3c00e7=squel['insert']()['into'](_0x0baf('0x4d'))['fromQuery']([_0x0baf('0x37'),_0x0baf('0x39'),'ListId',_0x5dc434,_0x0baf('0x3a'),_0x0baf('0x3b')],squel[_0x0baf('0x3c')]()['field']('phone',_0x0baf('0x37'))[_0x0baf('0x3d')]('id',_0x0baf('0x39'))[_0x0baf('0x3d')](LISTID[_0x0baf('0x3f')](),'ListId')[_0x0baf('0x3d')](_0x178495['id']['toString'](),_0x5dc434)['field']('NOW()',_0x0baf('0x3a'))['field']('NOW()',_0x0baf('0x3b'))[_0x0baf('0x40')](_0x0baf('0x48'))[_0x0baf('0x41')](_0x0baf('0x42'))[_0x0baf('0x41')]('ListId\x20=\x20?',LISTID[_0x0baf('0x3f')]())[_0x0baf('0x41')](_0x0baf('0x4c'),squel[_0x0baf('0x49')](hopperContacts))[_0x0baf('0x41')](_0x0baf('0x44')))['toString']();return _0x3c00e7;}return db[_0x0baf('0x4e')][_0x0baf('0x4f')]({'where':{'type':_0x0baf('0x50')},'attributes':['id','dialCheckDuplicateType'],'include':[{'model':db[_0x0baf('0x51')],'as':_0x0baf('0x52'),'where':{'id':LISTID}}]})[_0x0baf('0x2e')](function(_0x2c20fe){var _0x125906=[];if(_0x2c20fe){var _0x27a959;for(var _0x4cc046=0x0,_0x5874cc;_0x4cc046<_0x2c20fe['length'];_0x4cc046+=0x1){_0x5874cc=_0x2c20fe[_0x4cc046]['get']({'plain':!![]});switch(_0x5874cc[_0x0baf('0x53')]){case _0x0baf('0x54'):_0x125906[_0x0baf('0x2f')](db[_0x0baf('0x55')][_0x0baf('0x56')](_0x1daf1d(_0x5874cc,_0x0baf('0x57')))['then'](function(){})['catch'](_0x1b0991()));break;case _0x0baf('0x58'):_0x125906['push'](db[_0x0baf('0x55')][_0x0baf('0x56')](_0x5b991f(_0x5874cc,'VoiceQueueId'))[_0x0baf('0x2e')](function(){})[_0x0baf('0x59')](_0x1b0991()));break;default:_0x125906[_0x0baf('0x2f')](db[_0x0baf('0x55')][_0x0baf('0x56')](_0xcf7b8d(_0x5874cc,_0x0baf('0x57')))[_0x0baf('0x2e')](function(){})[_0x0baf('0x59')](_0x1b0991()));}}}return _0x125906;})[_0x0baf('0x5a')]()['then'](function(){return db['VoiceQueue']['findAll']({'where':{'type':'outbound'},'attributes':['id'],'include':[{'model':db['CmList'],'as':_0x0baf('0x5b'),'where':{'id':LISTID}}]})[_0x0baf('0x2e')](function(_0x333b07){var _0x20a514=[];if(_0x333b07){var _0x5093f5;for(var _0x1be7f2=0x0,_0x410f6c;_0x1be7f2<_0x333b07['length'];_0x1be7f2+=0x1){_0x410f6c=_0x333b07[_0x1be7f2]['get']({'plain':!![]});_0x20a514[_0x0baf('0x2f')](db[_0x0baf('0x55')][_0x0baf('0x56')](_0x498405(_0x410f6c,_0x0baf('0x57')))[_0x0baf('0x2e')](function(){})[_0x0baf('0x59')](_0x1b0991()));}}return _0x20a514;})[_0x0baf('0x5a')]();})[_0x0baf('0x2e')](function(){return db['Campaign'][_0x0baf('0x4f')]({'attributes':['id',_0x0baf('0x53')],'include':[{'model':db['CmList'],'as':_0x0baf('0x52'),'where':{'id':LISTID}}]})[_0x0baf('0x2e')](function(_0x538f24){var _0x97d385=[];if(_0x538f24){for(var _0x4043d5=0x0,_0x421ca0;_0x4043d5<_0x538f24[_0x0baf('0x1a')];_0x4043d5+=0x1){_0x421ca0=_0x538f24[_0x4043d5][_0x0baf('0x5c')]({'plain':!![]});switch(_0x421ca0['dialCheckDuplicateType']){case'always':_0x97d385[_0x0baf('0x2f')](db[_0x0baf('0x55')]['query'](_0x1daf1d(_0x421ca0,_0x0baf('0x5d')))[_0x0baf('0x2e')](function(){})[_0x0baf('0x59')](_0x1b0991()));break;case'onlyIfOpen':_0x97d385[_0x0baf('0x2f')](db[_0x0baf('0x55')][_0x0baf('0x56')](_0x5b991f(_0x421ca0,'CampaignId'))[_0x0baf('0x2e')](function(){})['catch'](_0x1b0991()));break;default:_0x97d385[_0x0baf('0x2f')](db[_0x0baf('0x55')][_0x0baf('0x56')](_0xcf7b8d(_0x421ca0,_0x0baf('0x5d')))[_0x0baf('0x2e')](function(){})['catch'](_0x1b0991()));}}}return _0x97d385;})[_0x0baf('0x5a')]();})[_0x0baf('0x2e')](function(){return db['Campaign'][_0x0baf('0x4f')]({'attributes':['id'],'include':[{'model':db[_0x0baf('0x51')],'as':_0x0baf('0x5b'),'where':{'id':LISTID}}]})[_0x0baf('0x2e')](function(_0x1cbbcc){var _0x250df2=[];if(_0x1cbbcc){for(var _0xa4fd1b=0x0,_0x1cda78;_0xa4fd1b<_0x1cbbcc[_0x0baf('0x1a')];_0xa4fd1b+=0x1){_0x1cda78=_0x1cbbcc[_0xa4fd1b][_0x0baf('0x5c')]({'plain':!![]});_0x250df2[_0x0baf('0x2f')](db[_0x0baf('0x55')]['query'](_0x498405(_0x1cda78,'CampaignId'))[_0x0baf('0x2e')](function(){})[_0x0baf('0x59')](_0x1b0991()));}}return _0x250df2;})[_0x0baf('0x5a')]();})['catch'](function(_0x507783){logger[_0x0baf('0x15')](_0x0baf('0x5e'),_0x0baf('0x5f'),_0x507783[_0x0baf('0x1c')]);});}var processPromises=function(_0x2dcdfe){return BPromise[_0x0baf('0x5a')](promises)[_0x0baf('0x2e')](function(_0xa2d315){})[_0x0baf('0x59')](function(_0x4e8e85){logger[_0x0baf('0x15')](_0x0baf('0x60'),JSON[_0x0baf('0x32')](_0x4e8e85));})[_0x0baf('0x61')](function(){socket['emit']('contact:csv_'+SOCKET_TIMESTAMP,{'success':success,'errors':errors,'duplicates':duplicates,'rows':rows});promises=[];success=0x0;errors=0x0;duplicates=0x0;rows=[];if(_0x2dcdfe){return _0x2dcdfe['resume']();}});};var endCsv=function(){return BPromise[_0x0baf('0x62')]()[_0x0baf('0x2e')](function(){if(hopperContacts){return checkHopper();}})['then'](function(){socket['emit'](_0x0baf('0x63')+SOCKET_TIMESTAMP,{'finished':!![],'success':success,'errors':errors,'duplicates':duplicates,'rows':rows});try{fs[_0x0baf('0x64')](FILEPATH);}catch(_0x52e0c4){logger[_0x0baf('0x15')](_0x0baf('0x65'),JSON[_0x0baf('0x32')](_0x52e0c4));}finally{process[_0x0baf('0x66')](0x0);}});};process['on'](_0x0baf('0x67'),function(){logger[_0x0baf('0x68')](_0x0baf('0x69'));endCsv();});function main(){return BPromise[_0x0baf('0x62')]()[_0x0baf('0x2e')](function(){if(DUPLICATES){DUPLICATES=DUPLICATES[_0x0baf('0x13')](',');return db[_0x0baf('0x6a')][_0x0baf('0x4f')]({'where':{'ListId':LISTID},'attributes':DUPLICATES,'raw':!![]});}})['then'](function(_0x1ed607){var _0xd0f63b=fs[_0x0baf('0x6b')](FILEPATH,{'highWaterMark':0xf*0x400*0x400});Papa[_0x0baf('0x6c')](_0xd0f63b,{'header':!![],'skipEmptyLines':!![],'step':function(_0x3c37b4,_0x195303){total+=0x1;var _0x49d411=total;promises[_0x0baf('0x2f')](checkRow(_0x3c37b4,_0x1ed607,_0x49d411)[_0x0baf('0x2e')](function(){success+=0x1;})[_0x0baf('0x59')](function(_0x457ae8){if(_0x457ae8[_0x0baf('0x15')]){errors+=0x1;delete _0x457ae8['error'];}else if(_0x457ae8[_0x0baf('0x6d')]){duplicates+=0x1;delete _0x457ae8[_0x0baf('0x6d')];}rows[_0x0baf('0x2f')](_0x457ae8);}));if(total%0xc8===0x0){_0x195303[_0x0baf('0x6e')]();return processPromises(_0x195303);}},'complete':function(){return processPromises()[_0x0baf('0x2e')](function(){logger['info']('CSV\x20parsed\x20correctly!');endCsv();});},'error':function(_0xb5f4e5,_0x5a2454){logger[_0x0baf('0x68')]('CSV\x20parse\x20error',JSON[_0x0baf('0x32')](_0xb5f4e5));endCsv();}});})[_0x0baf('0x59')](function(_0x1ce7bb){logger[_0x0baf('0x15')]('Error\x20executing\x20contact\x20csv\x20import:',JSON[_0x0baf('0x32')](_0x1ce7bb));});}main();
\ No newline at end of file
+var _0x1e62=['phone\x20IS\x20NOT\x20NULL','phone\x20NOT\x20IN\x20(?)','from','cm_hopper','\x20=\x20?','NOW()','id\x20IN\x20?','str','calleridnum','cm_hopper_final','cm_hopper_black','cm_contacts','VoiceQueue','CmList','Lists','get','dialCheckDuplicateType','always','sequelize','query','VoiceQueueId','catch','onlyIfOpen','findAll','BlackLists','all','Campaign','CampaignId','cmContact,\x20%s,\x20%s','generalCheckHopper','Error\x20processing\x20rows\x20block:','finally','emit','contact:csv_','resume','resolve','unlinkSync','Unable\x20to\x20delete\x20temp\x20file:','SIGINT','info','parse','duplicate','pause','CSV\x20parse\x20error','Error\x20executing\x20contact\x20csv\x20import:','squel','papaparse','ioredis','../../../mysqldb','../../../config/environment','../../../config/logger','api','redis','localhost','socket.io-emitter','register','argv','undefined','null','Missing\x20binding\x20parameters!','zipObject','split','Missing\x20ListId\x20parameter!','error','contact','index','isNil','The\x20row\x20is\x20empty\x20or\x20the\x20number\x20of\x20parameters\x20does\x20not\x20match\x20the\x20columns!','errors','map','message','join','hasOwnProperty','data','firstName','firstName\x20not\x20specified!','birthDate','YYYY-MM-DD','birthDate\x20format\x20is\x20invalid,\x20YYYY-MM-DD\x20format\x20is\x20supported!','email','ListId','length','find','CmContact','create','keys','then','push','pick','Error\x20while\x20creating\x20contact:\x20','stringify','checkHopper','inspect','insert','into','fromQuery','scheduledAt','ContactId','createdAt','updatedAt','select','phone','field','toString','where','deletedAt\x20IS\x20NULL','ListId\x20=\x20?'];(function(_0x40a825,_0x3bac79){var _0x273a54=function(_0x5628d8){while(--_0x5628d8){_0x40a825['push'](_0x40a825['shift']());}};_0x273a54(++_0x3bac79);}(_0x1e62,0x98));var _0x21e6=function(_0x2baf85,_0x74639b){_0x2baf85=_0x2baf85-0x0;var _0x57fd18=_0x1e62[_0x2baf85];return _0x57fd18;};'use strict';var BPromise=require('bluebird');var util=require('util');var _=require('lodash');var fs=require('fs');var squel=require(_0x21e6('0x0'));var Papa=require(_0x21e6('0x1'));var Redis=require(_0x21e6('0x2'));var db=require(_0x21e6('0x3'))['db'];var config=require(_0x21e6('0x4'));var logger=require(_0x21e6('0x5'))(_0x21e6('0x6'));config[_0x21e6('0x7')]=_['defaults'](config[_0x21e6('0x7')],{'host':_0x21e6('0x8'),'port':0x18eb});var socket=require(_0x21e6('0x9'))(new Redis(config[_0x21e6('0x7')]));require('../../../api/cmContact/cmContact.socket')[_0x21e6('0xa')](socket);try{if(!process[_0x21e6('0xb')][0x2]||process[_0x21e6('0xb')][0x2]===_0x21e6('0xc')||process['argv'][0x2]===_0x21e6('0xd')){throw new Error('Missing\x20filepath\x20parameter!');}var FILEPATH=process[_0x21e6('0xb')][0x2];if(!process[_0x21e6('0xb')][0x3]||process[_0x21e6('0xb')][0x3]===_0x21e6('0xc')||process[_0x21e6('0xb')][0x3]===_0x21e6('0xd')||!process[_0x21e6('0xb')][0x4]||process[_0x21e6('0xb')][0x4]===_0x21e6('0xc')||process[_0x21e6('0xb')][0x4]===_0x21e6('0xd')){throw new Error(_0x21e6('0xe'));}var FIELDS=_[_0x21e6('0xf')](process[_0x21e6('0xb')][0x3][_0x21e6('0x10')](','),process[_0x21e6('0xb')][0x4][_0x21e6('0x10')](','));if(!process[_0x21e6('0xb')][0x5]||process[_0x21e6('0xb')][0x5]===_0x21e6('0xc')||process['argv'][0x5]===_0x21e6('0xd')){throw new Error(_0x21e6('0x11'));}var LISTID=process[_0x21e6('0xb')][0x5];var COMPANYID=process[_0x21e6('0xb')][0x6]&&process[_0x21e6('0xb')][0x6]!=='undefined'&&process[_0x21e6('0xb')][0x6]!==_0x21e6('0xd')?process[_0x21e6('0xb')][0x6]:null;var DUPLICATES=process[_0x21e6('0xb')][0x7]&&process['argv'][0x7]!=='undefined'&&process['argv'][0x7]!==_0x21e6('0xd')?process[_0x21e6('0xb')][0x7]:null;if(!process['argv'][0x8]||process['argv'][0x8]==='undefined'||process[_0x21e6('0xb')][0x8]===_0x21e6('0xd')){throw new Error('Missing\x20socket_timestamp\x20parameter!');}var SOCKET_TIMESTAMP=process[_0x21e6('0xb')][0x8];}catch(_0x56a789){logger[_0x21e6('0x12')](_0x56a789);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(_0x4c0b15,_0x565e49,_0x52a5c3,_0x49f8ff){var _0x32bf96={'message':_0x565e49};_0x32bf96[_0x4c0b15]=!![];if(_0x52a5c3){_0x32bf96[_0x21e6('0x13')]=_0x52a5c3;}if(_0x49f8ff){_0x32bf96[_0x21e6('0x14')]=_0x49f8ff;}return _0x32bf96;}function isEmail(_0x4f8b5b){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))*$/['test'](_0x4f8b5b);}function checkRow(_0x1e0d23,_0x100631,_0x255f3a){return new BPromise(function(_0x1929f9,_0x5b789a){if(_[_0x21e6('0x15')](_0x1e0d23)){return _0x5b789a(handleCheckRowError(_0x21e6('0x12'),_0x21e6('0x16'),null,_0x255f3a));}if(_0x1e0d23['errors']&&_0x1e0d23[_0x21e6('0x17')]['length']){var _0xb75363=_[_0x21e6('0x18')](_0x1e0d23['errors'],_0x21e6('0x19'))[_0x21e6('0x1a')](';');return _0x5b789a(handleCheckRowError('error',_0xb75363,null,_0x255f3a));}var _0x3438e4={};for(var _0x3c39a3 in FIELDS){if(FIELDS[_0x21e6('0x1b')](_0x3c39a3)&&FIELDS[_0x3c39a3]){_0x3438e4[_0x3c39a3]=_0x1e0d23[_0x21e6('0x1c')][0x0][FIELDS[_0x3c39a3]]||_0x1e0d23['data'][0x0]['\ufeff'+FIELDS[_0x3c39a3]];}}if(!_0x3438e4[_0x21e6('0x1d')]){return _0x5b789a(handleCheckRowError(_0x21e6('0x12'),_0x21e6('0x1e'),null,_0x255f3a));}if(!_0x3438e4['phone']){return _0x5b789a(handleCheckRowError('error','phone\x20not\x20specified!',null,_0x255f3a));}if(_0x3438e4[_0x21e6('0x1f')]){var _0x194ae9=moment(_0x3438e4[_0x21e6('0x1f')],_0x21e6('0x20'));if(!_0x194ae9['isValid']()){return _0x5b789a(handleCheckRowError(_0x21e6('0x12'),_0x21e6('0x21'),null,_0x255f3a));}}if(_0x3438e4['email']){if(!isEmail(_0x3438e4[_0x21e6('0x22')])){return _0x5b789a(handleCheckRowError('error','email\x20format\x20is\x20not\x20valid!',null,_0x255f3a));}}_0x3438e4[_0x21e6('0x23')]=LISTID;_0x3438e4['CompanyId']=COMPANYID||undefined;if(DUPLICATES&&DUPLICATES['length']&&_0x100631){var _0x413e8a={};for(var _0x2881bc=0x0,_0x17c506=DUPLICATES[_0x21e6('0x24')];_0x2881bc<_0x17c506;_0x2881bc+=0x1){_0x413e8a[DUPLICATES[_0x2881bc]]=_0x3438e4[DUPLICATES[_0x2881bc]];}var _0x56219a=_[_0x21e6('0x25')](_0x100631,_0x413e8a);if(_0x56219a){return _0x5b789a(handleCheckRowError('duplicate','Duplicate\x20Contact',_0x56219a,_0x255f3a));}}return db[_0x21e6('0x26')][_0x21e6('0x27')](_0x3438e4,{'raw':!![],'hooks':![],'fields':_[_0x21e6('0x28')](_0x3438e4)})[_0x21e6('0x29')](function(_0x444a9a){if(DUPLICATES&&DUPLICATES[_0x21e6('0x24')]&&_0x100631){_0x100631[_0x21e6('0x2a')](_[_0x21e6('0x2b')](_0x3438e4,DUPLICATES));}hopperContacts+=(hopperContacts?',':'')+_0x444a9a['id'];return _0x1929f9();})['catch'](function(_0x3c4baa){return _0x5b789a(handleCheckRowError(_0x21e6('0x12'),_0x21e6('0x2c')+(_0x3c4baa[_0x21e6('0x19')]||JSON[_0x21e6('0x2d')](_0x3c4baa)),null,_0x255f3a));});});}function checkHopper(){function _0x3239ac(){return function(_0x6da5d5){logger['error']('cmContact',_0x21e6('0x2e'),util[_0x21e6('0x2f')](_0x6da5d5,{'showHidden':![],'depth':null}));};}var _0x3a9918=function(_0x2e9350,_0xa82f0b){var _0x36b4ac=squel[_0x21e6('0x30')]()[_0x21e6('0x31')]('cm_hopper')[_0x21e6('0x32')](['phone',_0x21e6('0x33'),_0x21e6('0x34'),_0x21e6('0x23'),_0xa82f0b,_0x21e6('0x35'),_0x21e6('0x36')],squel[_0x21e6('0x37')]()['field'](_0x21e6('0x38'),_0x21e6('0x38'))['field']('NOW()','scheduledAt')[_0x21e6('0x39')]('id',_0x21e6('0x34'))[_0x21e6('0x39')](LISTID[_0x21e6('0x3a')](),_0x21e6('0x23'))[_0x21e6('0x39')](_0x2e9350['id']['toString'](),_0xa82f0b)['field']('NOW()','createdAt')[_0x21e6('0x39')]('NOW()',_0x21e6('0x36'))['from']('cm_contacts')[_0x21e6('0x3b')](_0x21e6('0x3c'))[_0x21e6('0x3b')](_0x21e6('0x3d'),LISTID['toString']())[_0x21e6('0x3b')](_0x21e6('0x3e'))[_0x21e6('0x3b')](_0x21e6('0x3f'),squel[_0x21e6('0x37')]()[_0x21e6('0x39')](_0x21e6('0x38'))[_0x21e6('0x40')](_0x21e6('0x41'))[_0x21e6('0x3b')](_0xa82f0b+_0x21e6('0x42'),_0x2e9350['id'][_0x21e6('0x3a')]())))[_0x21e6('0x3a')]();return _0x36b4ac;};var _0x2441b9=function(_0x17e72d,_0x589e1f){var _0x486903=squel['insert']()[_0x21e6('0x31')](_0x21e6('0x41'))['fromQuery'](['phone',_0x21e6('0x33'),'ContactId',_0x21e6('0x23'),_0x589e1f,_0x21e6('0x35'),_0x21e6('0x36')],squel[_0x21e6('0x37')]()[_0x21e6('0x39')](_0x21e6('0x38'),'phone')[_0x21e6('0x39')](_0x21e6('0x43'),_0x21e6('0x33'))[_0x21e6('0x39')]('id','ContactId')[_0x21e6('0x39')](LISTID[_0x21e6('0x3a')](),_0x21e6('0x23'))[_0x21e6('0x39')](_0x17e72d['id'][_0x21e6('0x3a')](),_0x589e1f)['field'](_0x21e6('0x43'),_0x21e6('0x35'))[_0x21e6('0x39')](_0x21e6('0x43'),_0x21e6('0x36'))[_0x21e6('0x40')]('cm_contacts')[_0x21e6('0x3b')](_0x21e6('0x3c'))[_0x21e6('0x3b')](_0x21e6('0x3d'),LISTID[_0x21e6('0x3a')]())[_0x21e6('0x3b')](_0x21e6('0x44'),squel[_0x21e6('0x45')](hopperContacts))[_0x21e6('0x3b')](_0x21e6('0x3e'))[_0x21e6('0x3b')](_0x21e6('0x3f'),squel[_0x21e6('0x37')]()[_0x21e6('0x39')](_0x21e6('0x46'))[_0x21e6('0x40')](_0x21e6('0x47'))[_0x21e6('0x3b')](_0x589e1f+_0x21e6('0x42'),_0x17e72d['id'][_0x21e6('0x3a')]()))['where'](_0x21e6('0x3f'),squel[_0x21e6('0x37')]()[_0x21e6('0x39')](_0x21e6('0x38'))[_0x21e6('0x40')](_0x21e6('0x41'))['where'](_0x589e1f+_0x21e6('0x42'),_0x17e72d['id']['toString']())))[_0x21e6('0x3a')]();return _0x486903;};function _0xe79625(_0x2d51c8,_0x489e3c){var _0x1a8564=squel[_0x21e6('0x30')]()['into'](_0x21e6('0x41'))[_0x21e6('0x32')](['phone',_0x21e6('0x33'),_0x21e6('0x34'),_0x21e6('0x23'),_0x489e3c,_0x21e6('0x35'),_0x21e6('0x36')],squel[_0x21e6('0x37')]()[_0x21e6('0x39')](_0x21e6('0x38'),'phone')[_0x21e6('0x39')](_0x21e6('0x43'),_0x21e6('0x33'))[_0x21e6('0x39')]('id','ContactId')[_0x21e6('0x39')](LISTID[_0x21e6('0x3a')](),_0x21e6('0x23'))[_0x21e6('0x39')](_0x2d51c8['id'][_0x21e6('0x3a')](),_0x489e3c)['field'](_0x21e6('0x43'),_0x21e6('0x35'))['field'](_0x21e6('0x43'),_0x21e6('0x36'))['from']('cm_contacts')[_0x21e6('0x3b')](_0x21e6('0x3c'))[_0x21e6('0x3b')](_0x21e6('0x3d'),LISTID['toString']())[_0x21e6('0x3b')](_0x21e6('0x44'),squel[_0x21e6('0x45')](hopperContacts))[_0x21e6('0x3b')]('phone\x20IS\x20NOT\x20NULL'))['toString']();return _0x1a8564;}function _0x299215(_0x9494b6,_0x2b62fc){var _0x91cfc7=squel[_0x21e6('0x30')]()[_0x21e6('0x31')](_0x21e6('0x48'))[_0x21e6('0x32')]([_0x21e6('0x38'),_0x21e6('0x34'),_0x21e6('0x23'),_0x2b62fc,_0x21e6('0x35'),_0x21e6('0x36')],squel['select']()[_0x21e6('0x39')](_0x21e6('0x38'),_0x21e6('0x38'))[_0x21e6('0x39')]('id',_0x21e6('0x34'))['field'](LISTID['toString'](),_0x21e6('0x23'))[_0x21e6('0x39')](_0x9494b6['id'][_0x21e6('0x3a')](),_0x2b62fc)['field'](_0x21e6('0x43'),_0x21e6('0x35'))[_0x21e6('0x39')](_0x21e6('0x43'),'updatedAt')[_0x21e6('0x40')](_0x21e6('0x49'))[_0x21e6('0x3b')](_0x21e6('0x3c'))['where'](_0x21e6('0x3d'),LISTID[_0x21e6('0x3a')]())[_0x21e6('0x3b')](_0x21e6('0x44'),squel[_0x21e6('0x45')](hopperContacts))[_0x21e6('0x3b')](_0x21e6('0x3e')))[_0x21e6('0x3a')]();return _0x91cfc7;}return db[_0x21e6('0x4a')]['findAll']({'where':{'type':'outbound'},'attributes':['id','dialCheckDuplicateType'],'include':[{'model':db[_0x21e6('0x4b')],'as':_0x21e6('0x4c'),'where':{'id':LISTID}}]})[_0x21e6('0x29')](function(_0x17f65d){var _0x211516=[];if(_0x17f65d){var _0x5d9e51;for(var _0x34b3b5=0x0,_0x278a20;_0x34b3b5<_0x17f65d['length'];_0x34b3b5+=0x1){_0x278a20=_0x17f65d[_0x34b3b5][_0x21e6('0x4d')]({'plain':!![]});switch(_0x278a20[_0x21e6('0x4e')]){case _0x21e6('0x4f'):_0x211516[_0x21e6('0x2a')](db[_0x21e6('0x50')][_0x21e6('0x51')](_0x2441b9(_0x278a20,_0x21e6('0x52')))[_0x21e6('0x29')](function(){})[_0x21e6('0x53')](_0x3239ac()));break;case _0x21e6('0x54'):_0x211516[_0x21e6('0x2a')](db[_0x21e6('0x50')][_0x21e6('0x51')](_0x3a9918(_0x278a20,_0x21e6('0x52')))[_0x21e6('0x29')](function(){})['catch'](_0x3239ac()));break;default:_0x211516[_0x21e6('0x2a')](db[_0x21e6('0x50')][_0x21e6('0x51')](_0xe79625(_0x278a20,'VoiceQueueId'))[_0x21e6('0x29')](function(){})[_0x21e6('0x53')](_0x3239ac()));}}}return _0x211516;})['all']()['then'](function(){return db['VoiceQueue'][_0x21e6('0x55')]({'where':{'type':'outbound'},'attributes':['id'],'include':[{'model':db[_0x21e6('0x4b')],'as':_0x21e6('0x56'),'where':{'id':LISTID}}]})['then'](function(_0x9c233d){var _0x5d49ad=[];if(_0x9c233d){var _0x5634dc;for(var _0x1a8bd6=0x0,_0x53bef5;_0x1a8bd6<_0x9c233d[_0x21e6('0x24')];_0x1a8bd6+=0x1){_0x53bef5=_0x9c233d[_0x1a8bd6][_0x21e6('0x4d')]({'plain':!![]});_0x5d49ad[_0x21e6('0x2a')](db[_0x21e6('0x50')][_0x21e6('0x51')](_0x299215(_0x53bef5,_0x21e6('0x52')))['then'](function(){})[_0x21e6('0x53')](_0x3239ac()));}}return _0x5d49ad;})[_0x21e6('0x57')]();})[_0x21e6('0x29')](function(){return db[_0x21e6('0x58')]['findAll']({'attributes':['id','dialCheckDuplicateType'],'include':[{'model':db['CmList'],'as':_0x21e6('0x4c'),'where':{'id':LISTID}}]})[_0x21e6('0x29')](function(_0x32b08d){var _0x3eb01a=[];if(_0x32b08d){for(var _0x517326=0x0,_0x4a9527;_0x517326<_0x32b08d[_0x21e6('0x24')];_0x517326+=0x1){_0x4a9527=_0x32b08d[_0x517326][_0x21e6('0x4d')]({'plain':!![]});switch(_0x4a9527['dialCheckDuplicateType']){case'always':_0x3eb01a[_0x21e6('0x2a')](db[_0x21e6('0x50')][_0x21e6('0x51')](_0x2441b9(_0x4a9527,'CampaignId'))[_0x21e6('0x29')](function(){})[_0x21e6('0x53')](_0x3239ac()));break;case _0x21e6('0x54'):_0x3eb01a[_0x21e6('0x2a')](db[_0x21e6('0x50')][_0x21e6('0x51')](_0x3a9918(_0x4a9527,_0x21e6('0x59')))['then'](function(){})[_0x21e6('0x53')](_0x3239ac()));break;default:_0x3eb01a[_0x21e6('0x2a')](db[_0x21e6('0x50')]['query'](_0xe79625(_0x4a9527,_0x21e6('0x59')))[_0x21e6('0x29')](function(){})[_0x21e6('0x53')](_0x3239ac()));}}}return _0x3eb01a;})['all']();})[_0x21e6('0x29')](function(){return db['Campaign']['findAll']({'attributes':['id'],'include':[{'model':db[_0x21e6('0x4b')],'as':_0x21e6('0x56'),'where':{'id':LISTID}}]})[_0x21e6('0x29')](function(_0xbc4f69){var _0x3fb1de=[];if(_0xbc4f69){for(var _0x1088d7=0x0,_0xb1d0d;_0x1088d7<_0xbc4f69[_0x21e6('0x24')];_0x1088d7+=0x1){_0xb1d0d=_0xbc4f69[_0x1088d7]['get']({'plain':!![]});_0x3fb1de[_0x21e6('0x2a')](db[_0x21e6('0x50')][_0x21e6('0x51')](_0x299215(_0xb1d0d,_0x21e6('0x59')))[_0x21e6('0x29')](function(){})[_0x21e6('0x53')](_0x3239ac()));}}return _0x3fb1de;})[_0x21e6('0x57')]();})['catch'](function(_0x3052b3){logger['error'](_0x21e6('0x5a'),_0x21e6('0x5b'),_0x3052b3[_0x21e6('0x19')]);});}var processPromises=function(_0xdc9f00){return BPromise[_0x21e6('0x57')](promises)['then'](function(_0x1137ea){})[_0x21e6('0x53')](function(_0x19ad12){logger['error'](_0x21e6('0x5c'),JSON[_0x21e6('0x2d')](_0x19ad12));})[_0x21e6('0x5d')](function(){socket[_0x21e6('0x5e')](_0x21e6('0x5f')+SOCKET_TIMESTAMP,{'success':success,'errors':errors,'duplicates':duplicates,'rows':rows});promises=[];success=0x0;errors=0x0;duplicates=0x0;rows=[];if(_0xdc9f00){return _0xdc9f00[_0x21e6('0x60')]();}});};var endCsv=function(){return BPromise[_0x21e6('0x61')]()[_0x21e6('0x29')](function(){if(hopperContacts){return checkHopper();}})[_0x21e6('0x29')](function(){socket[_0x21e6('0x5e')](_0x21e6('0x5f')+SOCKET_TIMESTAMP,{'finished':!![],'success':success,'errors':errors,'duplicates':duplicates,'rows':rows});try{fs[_0x21e6('0x62')](FILEPATH);}catch(_0x239984){logger[_0x21e6('0x12')](_0x21e6('0x63'),JSON[_0x21e6('0x2d')](_0x239984));}finally{process['exit'](0x0);}});};process['on'](_0x21e6('0x64'),function(){logger[_0x21e6('0x65')]('CSV\x20import\x20process\x20stopped!');endCsv();});function main(){return BPromise[_0x21e6('0x61')]()[_0x21e6('0x29')](function(){if(DUPLICATES){DUPLICATES=DUPLICATES[_0x21e6('0x10')](',');return db[_0x21e6('0x26')][_0x21e6('0x55')]({'where':{'ListId':LISTID},'attributes':DUPLICATES,'raw':!![]});}})[_0x21e6('0x29')](function(_0x43d44d){var _0x19223a=fs['createReadStream'](FILEPATH,{'highWaterMark':0xf*0x400*0x400});Papa[_0x21e6('0x66')](_0x19223a,{'header':!![],'skipEmptyLines':!![],'step':function(_0x33bf0b,_0x3b2f03){total+=0x1;var _0x2e5754=total;promises[_0x21e6('0x2a')](checkRow(_0x33bf0b,_0x43d44d,_0x2e5754)[_0x21e6('0x29')](function(){success+=0x1;})[_0x21e6('0x53')](function(_0xc7003e){if(_0xc7003e[_0x21e6('0x12')]){errors+=0x1;delete _0xc7003e['error'];}else if(_0xc7003e[_0x21e6('0x67')]){duplicates+=0x1;delete _0xc7003e[_0x21e6('0x67')];}rows[_0x21e6('0x2a')](_0xc7003e);}));if(total%0xc8===0x0){_0x3b2f03[_0x21e6('0x68')]();return processPromises(_0x3b2f03);}},'complete':function(){return processPromises()['then'](function(){logger[_0x21e6('0x65')]('CSV\x20parsed\x20correctly!');endCsv();});},'error':function(_0x538fc7,_0x395b52){logger[_0x21e6('0x65')](_0x21e6('0x69'),JSON[_0x21e6('0x2d')](_0x538fc7));endCsv();}});})['catch'](function(_0x460018){logger['error'](_0x21e6('0x6a'),JSON[_0x21e6('0x2d')](_0x460018));});}main();
\ No newline at end of file