Built motion from commit 6a09e18b.|2.6.11
[motion2.git] / server / components / import / cm / csv.js
index 2f18840..aa96ec4 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xa1d0=['Missing\x20ListId\x20parameter!','Missing\x20socket_timestamp\x20parameter!','error','test','isNil','errors','length','join','firstName','firstName\x20not\x20specified!','phone','phone\x20not\x20specified!','YYYY-MM-DD','isValid','email','email\x20format\x20is\x20not\x20valid!','CompanyId','find','duplicate','create','keys','then','push','pick','catch','Error\x20while\x20creating\x20contact:\x20','message','stringify','cmContact','checkHopper','inspect','insert','into','fromQuery','scheduledAt','ContactId','ListId','createdAt','updatedAt','select','field','toString','NOW()','from','cm_contacts','where','deletedAt\x20IS\x20NULL','ListId\x20=\x20?','phone\x20IS\x20NOT\x20NULL','phone\x20NOT\x20IN\x20(?)','cm_hopper','\x20=\x20?','id\x20IN\x20?','str','calleridnum','cm_hopper_final','cm_hopper_black','VoiceQueue','findAll','outbound','Lists','get','always','sequelize','VoiceQueueId','onlyIfOpen','query','CmList','BlackLists','all','Campaign','CampaignId','cmContact,\x20%s,\x20%s','generalCheckHopper','Error\x20processing\x20rows\x20block:','finally','contact:csv_','resume','unlinkSync','Unable\x20to\x20delete\x20temp\x20file:','exit','SIGINT','CSV\x20import\x20process\x20stopped!','CmContact','createReadStream','parse','info','CSV\x20parse\x20error','bluebird','util','lodash','squel','papaparse','ioredis','../../../mysqldb','../../../config/environment','../../../config/logger','api','redis','defaults','localhost','../../../api/cmContact/cmContact.socket','register','argv','undefined','Missing\x20filepath\x20parameter!','null','zipObject','split'];(function(_0x2554a9,_0x466c5a){var _0x22b0df=function(_0xe96591){while(--_0xe96591){_0x2554a9['push'](_0x2554a9['shift']());}};_0x22b0df(++_0x466c5a);}(_0xa1d0,0x19f));var _0x0a1d=function(_0x2ba95a,_0x4f1647){_0x2ba95a=_0x2ba95a-0x0;var _0x37387c=_0xa1d0[_0x2ba95a];return _0x37387c;};'use strict';var BPromise=require(_0x0a1d('0x0'));var util=require(_0x0a1d('0x1'));var _=require(_0x0a1d('0x2'));var fs=require('fs');var squel=require(_0x0a1d('0x3'));var Papa=require(_0x0a1d('0x4'));var Redis=require(_0x0a1d('0x5'));var db=require(_0x0a1d('0x6'))['db'];var config=require(_0x0a1d('0x7'));var logger=require(_0x0a1d('0x8'))(_0x0a1d('0x9'));config[_0x0a1d('0xa')]=_[_0x0a1d('0xb')](config[_0x0a1d('0xa')],{'host':_0x0a1d('0xc'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x0a1d('0xa')]));require(_0x0a1d('0xd'))[_0x0a1d('0xe')](socket);try{if(!process[_0x0a1d('0xf')][0x2]||process[_0x0a1d('0xf')][0x2]===_0x0a1d('0x10')||process[_0x0a1d('0xf')][0x2]==='null'){throw new Error(_0x0a1d('0x11'));}var FILEPATH=process[_0x0a1d('0xf')][0x2];if(!process[_0x0a1d('0xf')][0x3]||process[_0x0a1d('0xf')][0x3]==='undefined'||process[_0x0a1d('0xf')][0x3]===_0x0a1d('0x12')||!process[_0x0a1d('0xf')][0x4]||process['argv'][0x4]===_0x0a1d('0x10')||process['argv'][0x4]==='null'){throw new Error('Missing\x20binding\x20parameters!');}var FIELDS=_[_0x0a1d('0x13')](process[_0x0a1d('0xf')][0x3][_0x0a1d('0x14')](','),process[_0x0a1d('0xf')][0x4][_0x0a1d('0x14')](','));if(!process[_0x0a1d('0xf')][0x5]||process[_0x0a1d('0xf')][0x5]===_0x0a1d('0x10')||process[_0x0a1d('0xf')][0x5]==='null'){throw new Error(_0x0a1d('0x15'));}var LISTID=process[_0x0a1d('0xf')][0x5];var COMPANYID=process[_0x0a1d('0xf')][0x6]&&process[_0x0a1d('0xf')][0x6]!==_0x0a1d('0x10')&&process[_0x0a1d('0xf')][0x6]!==_0x0a1d('0x12')?process[_0x0a1d('0xf')][0x6]:null;var DUPLICATES=process[_0x0a1d('0xf')][0x7]&&process[_0x0a1d('0xf')][0x7]!==_0x0a1d('0x10')&&process['argv'][0x7]!==_0x0a1d('0x12')?process[_0x0a1d('0xf')][0x7]:null;if(!process[_0x0a1d('0xf')][0x8]||process['argv'][0x8]===_0x0a1d('0x10')||process['argv'][0x8]===_0x0a1d('0x12')){throw new Error(_0x0a1d('0x16'));}var SOCKET_TIMESTAMP=process[_0x0a1d('0xf')][0x8];}catch(_0x119c57){logger[_0x0a1d('0x17')](_0x119c57);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(_0x14ef10,_0x555017,_0xab2456,_0x2977cb){var _0x4487a6={'message':_0x555017};_0x4487a6[_0x14ef10]=!![];if(_0xab2456){_0x4487a6['contact']=_0xab2456;}if(_0x2977cb){_0x4487a6['index']=_0x2977cb;}return _0x4487a6;}function isEmail(_0x11d2d4){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))*$/[_0x0a1d('0x18')](_0x11d2d4);}function checkRow(_0x1077c9,_0xbe19b2,_0x459d6d){return new BPromise(function(_0x5d3d09,_0x213eab){if(_[_0x0a1d('0x19')](_0x1077c9)){return _0x213eab(handleCheckRowError(_0x0a1d('0x17'),'The\x20row\x20is\x20empty\x20or\x20the\x20number\x20of\x20parameters\x20does\x20not\x20match\x20the\x20columns!',null,_0x459d6d));}if(_0x1077c9[_0x0a1d('0x1a')]&&_0x1077c9[_0x0a1d('0x1a')][_0x0a1d('0x1b')]){var _0x405833=_['map'](_0x1077c9[_0x0a1d('0x1a')],'message')[_0x0a1d('0x1c')](';');return _0x213eab(handleCheckRowError(_0x0a1d('0x17'),_0x405833,null,_0x459d6d));}var _0x5c1c9f={};for(var _0x255ab0 in FIELDS){if(FIELDS['hasOwnProperty'](_0x255ab0)&&FIELDS[_0x255ab0]){_0x5c1c9f[_0x255ab0]=_0x1077c9['data'][0x0][FIELDS[_0x255ab0]]||_0x1077c9['data'][0x0]['\ufeff'+FIELDS[_0x255ab0]];}}if(!_0x5c1c9f[_0x0a1d('0x1d')]){return _0x213eab(handleCheckRowError(_0x0a1d('0x17'),_0x0a1d('0x1e'),null,_0x459d6d));}if(!_0x5c1c9f[_0x0a1d('0x1f')]){return _0x213eab(handleCheckRowError(_0x0a1d('0x17'),_0x0a1d('0x20'),null,_0x459d6d));}if(_0x5c1c9f['birthDate']){var _0x4701bf=moment(_0x5c1c9f['birthDate'],_0x0a1d('0x21'));if(!_0x4701bf[_0x0a1d('0x22')]()){return _0x213eab(handleCheckRowError(_0x0a1d('0x17'),'birthDate\x20format\x20is\x20invalid,\x20YYYY-MM-DD\x20format\x20is\x20supported!',null,_0x459d6d));}}if(_0x5c1c9f[_0x0a1d('0x23')]){if(!isEmail(_0x5c1c9f['email'])){return _0x213eab(handleCheckRowError(_0x0a1d('0x17'),_0x0a1d('0x24'),null,_0x459d6d));}}_0x5c1c9f['ListId']=LISTID;_0x5c1c9f[_0x0a1d('0x25')]=COMPANYID||undefined;if(DUPLICATES&&DUPLICATES[_0x0a1d('0x1b')]&&_0xbe19b2){var _0x62efef={};for(var _0x521eec=0x0,_0x5a96b7=DUPLICATES[_0x0a1d('0x1b')];_0x521eec<_0x5a96b7;_0x521eec+=0x1){_0x62efef[DUPLICATES[_0x521eec]]=_0x5c1c9f[DUPLICATES[_0x521eec]];}var _0x5331a9=_[_0x0a1d('0x26')](_0xbe19b2,_0x62efef);if(_0x5331a9){return _0x213eab(handleCheckRowError(_0x0a1d('0x27'),'Duplicate\x20Contact',_0x5331a9,_0x459d6d));}}return db['CmContact'][_0x0a1d('0x28')](_0x5c1c9f,{'raw':!![],'hooks':![],'fields':_[_0x0a1d('0x29')](_0x5c1c9f)})[_0x0a1d('0x2a')](function(_0xb8b43){if(DUPLICATES&&DUPLICATES[_0x0a1d('0x1b')]&&_0xbe19b2){_0xbe19b2[_0x0a1d('0x2b')](_[_0x0a1d('0x2c')](_0x5c1c9f,DUPLICATES));}hopperContacts+=(hopperContacts?',':'')+_0xb8b43['id'];return _0x5d3d09();})[_0x0a1d('0x2d')](function(_0x23058f){return _0x213eab(handleCheckRowError('error',_0x0a1d('0x2e')+(_0x23058f[_0x0a1d('0x2f')]||JSON[_0x0a1d('0x30')](_0x23058f)),null,_0x459d6d));});});}function checkHopper(){function _0x1d8052(){return function(_0x35177e){logger[_0x0a1d('0x17')](_0x0a1d('0x31'),_0x0a1d('0x32'),util[_0x0a1d('0x33')](_0x35177e,{'showHidden':![],'depth':null}));};}var _0xfa5836=function(_0x1a6581,_0x14c096){var _0x373e47=squel[_0x0a1d('0x34')]()[_0x0a1d('0x35')]('cm_hopper')[_0x0a1d('0x36')]([_0x0a1d('0x1f'),_0x0a1d('0x37'),_0x0a1d('0x38'),_0x0a1d('0x39'),_0x14c096,_0x0a1d('0x3a'),_0x0a1d('0x3b')],squel[_0x0a1d('0x3c')]()[_0x0a1d('0x3d')](_0x0a1d('0x1f'),_0x0a1d('0x1f'))['field']('NOW()',_0x0a1d('0x37'))[_0x0a1d('0x3d')]('id',_0x0a1d('0x38'))[_0x0a1d('0x3d')](LISTID[_0x0a1d('0x3e')](),'ListId')['field'](_0x1a6581['id'][_0x0a1d('0x3e')](),_0x14c096)[_0x0a1d('0x3d')](_0x0a1d('0x3f'),'createdAt')[_0x0a1d('0x3d')](_0x0a1d('0x3f'),'updatedAt')[_0x0a1d('0x40')](_0x0a1d('0x41'))[_0x0a1d('0x42')](_0x0a1d('0x43'))[_0x0a1d('0x42')](_0x0a1d('0x44'),LISTID['toString']())[_0x0a1d('0x42')](_0x0a1d('0x45'))[_0x0a1d('0x42')](_0x0a1d('0x46'),squel['select']()[_0x0a1d('0x3d')](_0x0a1d('0x1f'))[_0x0a1d('0x40')](_0x0a1d('0x47'))[_0x0a1d('0x42')](_0x14c096+_0x0a1d('0x48'),_0x1a6581['id'][_0x0a1d('0x3e')]())))[_0x0a1d('0x3e')]();return _0x373e47;};var _0x2b7742=function(_0x259917,_0x7a091e){var _0x5167de=squel[_0x0a1d('0x34')]()['into'](_0x0a1d('0x47'))[_0x0a1d('0x36')]([_0x0a1d('0x1f'),_0x0a1d('0x37'),_0x0a1d('0x38'),_0x0a1d('0x39'),_0x7a091e,_0x0a1d('0x3a'),'updatedAt'],squel[_0x0a1d('0x3c')]()['field']('phone',_0x0a1d('0x1f'))[_0x0a1d('0x3d')](_0x0a1d('0x3f'),_0x0a1d('0x37'))['field']('id','ContactId')[_0x0a1d('0x3d')](LISTID[_0x0a1d('0x3e')](),_0x0a1d('0x39'))[_0x0a1d('0x3d')](_0x259917['id']['toString'](),_0x7a091e)[_0x0a1d('0x3d')](_0x0a1d('0x3f'),_0x0a1d('0x3a'))[_0x0a1d('0x3d')](_0x0a1d('0x3f'),_0x0a1d('0x3b'))[_0x0a1d('0x40')]('cm_contacts')[_0x0a1d('0x42')](_0x0a1d('0x43'))['where'](_0x0a1d('0x44'),LISTID[_0x0a1d('0x3e')]())[_0x0a1d('0x42')](_0x0a1d('0x49'),squel[_0x0a1d('0x4a')](hopperContacts))[_0x0a1d('0x42')](_0x0a1d('0x45'))[_0x0a1d('0x42')]('phone\x20NOT\x20IN\x20(?)',squel[_0x0a1d('0x3c')]()[_0x0a1d('0x3d')](_0x0a1d('0x4b'))[_0x0a1d('0x40')](_0x0a1d('0x4c'))[_0x0a1d('0x42')](_0x7a091e+_0x0a1d('0x48'),_0x259917['id'][_0x0a1d('0x3e')]()))[_0x0a1d('0x42')]('phone\x20NOT\x20IN\x20(?)',squel[_0x0a1d('0x3c')]()[_0x0a1d('0x3d')]('phone')[_0x0a1d('0x40')](_0x0a1d('0x47'))[_0x0a1d('0x42')](_0x7a091e+'\x20=\x20?',_0x259917['id'][_0x0a1d('0x3e')]())))[_0x0a1d('0x3e')]();return _0x5167de;};function _0x13b1cf(_0x3b29b2,_0x1795e3){var _0xac9161=squel[_0x0a1d('0x34')]()[_0x0a1d('0x35')](_0x0a1d('0x47'))['fromQuery']([_0x0a1d('0x1f'),'scheduledAt',_0x0a1d('0x38'),_0x0a1d('0x39'),_0x1795e3,_0x0a1d('0x3a'),_0x0a1d('0x3b')],squel[_0x0a1d('0x3c')]()['field'](_0x0a1d('0x1f'),_0x0a1d('0x1f'))['field'](_0x0a1d('0x3f'),_0x0a1d('0x37'))[_0x0a1d('0x3d')]('id','ContactId')[_0x0a1d('0x3d')](LISTID['toString'](),_0x0a1d('0x39'))[_0x0a1d('0x3d')](_0x3b29b2['id'][_0x0a1d('0x3e')](),_0x1795e3)[_0x0a1d('0x3d')]('NOW()',_0x0a1d('0x3a'))[_0x0a1d('0x3d')](_0x0a1d('0x3f'),_0x0a1d('0x3b'))['from'](_0x0a1d('0x41'))[_0x0a1d('0x42')](_0x0a1d('0x43'))['where'](_0x0a1d('0x44'),LISTID[_0x0a1d('0x3e')]())[_0x0a1d('0x42')](_0x0a1d('0x49'),squel[_0x0a1d('0x4a')](hopperContacts))[_0x0a1d('0x42')](_0x0a1d('0x45')))[_0x0a1d('0x3e')]();return _0xac9161;}function _0x19fe09(_0x1e2dc5,_0x320953){var _0x281ba1=squel[_0x0a1d('0x34')]()[_0x0a1d('0x35')](_0x0a1d('0x4d'))['fromQuery']([_0x0a1d('0x1f'),_0x0a1d('0x38'),_0x0a1d('0x39'),_0x320953,_0x0a1d('0x3a'),_0x0a1d('0x3b')],squel[_0x0a1d('0x3c')]()['field'](_0x0a1d('0x1f'),_0x0a1d('0x1f'))[_0x0a1d('0x3d')]('id',_0x0a1d('0x38'))['field'](LISTID['toString'](),_0x0a1d('0x39'))[_0x0a1d('0x3d')](_0x1e2dc5['id'][_0x0a1d('0x3e')](),_0x320953)[_0x0a1d('0x3d')](_0x0a1d('0x3f'),'createdAt')[_0x0a1d('0x3d')](_0x0a1d('0x3f'),_0x0a1d('0x3b'))['from'](_0x0a1d('0x41'))[_0x0a1d('0x42')](_0x0a1d('0x43'))[_0x0a1d('0x42')]('ListId\x20=\x20?',LISTID[_0x0a1d('0x3e')]())[_0x0a1d('0x42')]('id\x20IN\x20?',squel[_0x0a1d('0x4a')](hopperContacts))[_0x0a1d('0x42')](_0x0a1d('0x45')))['toString']();return _0x281ba1;}return db[_0x0a1d('0x4e')][_0x0a1d('0x4f')]({'where':{'type':_0x0a1d('0x50')},'attributes':['id','dialCheckDuplicateType'],'include':[{'model':db['CmList'],'as':_0x0a1d('0x51'),'where':{'id':LISTID}}]})[_0x0a1d('0x2a')](function(_0x5421){var _0x1fb1e7=[];if(_0x5421){var _0x233a57;for(var _0x7d8094=0x0,_0x4530f8;_0x7d8094<_0x5421['length'];_0x7d8094+=0x1){_0x4530f8=_0x5421[_0x7d8094][_0x0a1d('0x52')]({'plain':!![]});switch(_0x4530f8['dialCheckDuplicateType']){case _0x0a1d('0x53'):_0x1fb1e7[_0x0a1d('0x2b')](db[_0x0a1d('0x54')]['query'](_0x2b7742(_0x4530f8,_0x0a1d('0x55')))[_0x0a1d('0x2a')](function(){})[_0x0a1d('0x2d')](_0x1d8052()));break;case _0x0a1d('0x56'):_0x1fb1e7[_0x0a1d('0x2b')](db[_0x0a1d('0x54')][_0x0a1d('0x57')](_0xfa5836(_0x4530f8,_0x0a1d('0x55')))[_0x0a1d('0x2a')](function(){})[_0x0a1d('0x2d')](_0x1d8052()));break;default:_0x1fb1e7[_0x0a1d('0x2b')](db[_0x0a1d('0x54')][_0x0a1d('0x57')](_0x13b1cf(_0x4530f8,'VoiceQueueId'))[_0x0a1d('0x2a')](function(){})['catch'](_0x1d8052()));}}}return _0x1fb1e7;})['all']()[_0x0a1d('0x2a')](function(){return db['VoiceQueue']['findAll']({'where':{'type':_0x0a1d('0x50')},'attributes':['id'],'include':[{'model':db[_0x0a1d('0x58')],'as':_0x0a1d('0x59'),'where':{'id':LISTID}}]})[_0x0a1d('0x2a')](function(_0x34c5dd){var _0x2dd549=[];if(_0x34c5dd){var _0x373163;for(var _0x322943=0x0,_0x346adf;_0x322943<_0x34c5dd[_0x0a1d('0x1b')];_0x322943+=0x1){_0x346adf=_0x34c5dd[_0x322943][_0x0a1d('0x52')]({'plain':!![]});_0x2dd549[_0x0a1d('0x2b')](db[_0x0a1d('0x54')]['query'](_0x19fe09(_0x346adf,_0x0a1d('0x55')))[_0x0a1d('0x2a')](function(){})['catch'](_0x1d8052()));}}return _0x2dd549;})[_0x0a1d('0x5a')]();})[_0x0a1d('0x2a')](function(){return db[_0x0a1d('0x5b')][_0x0a1d('0x4f')]({'attributes':['id','dialCheckDuplicateType'],'include':[{'model':db[_0x0a1d('0x58')],'as':'Lists','where':{'id':LISTID}}]})[_0x0a1d('0x2a')](function(_0x43bddd){var _0x3bc8b0=[];if(_0x43bddd){for(var _0x5aca44=0x0,_0x302a1a;_0x5aca44<_0x43bddd[_0x0a1d('0x1b')];_0x5aca44+=0x1){_0x302a1a=_0x43bddd[_0x5aca44][_0x0a1d('0x52')]({'plain':!![]});switch(_0x302a1a['dialCheckDuplicateType']){case _0x0a1d('0x53'):_0x3bc8b0[_0x0a1d('0x2b')](db['sequelize'][_0x0a1d('0x57')](_0x2b7742(_0x302a1a,'CampaignId'))[_0x0a1d('0x2a')](function(){})['catch'](_0x1d8052()));break;case _0x0a1d('0x56'):_0x3bc8b0['push'](db[_0x0a1d('0x54')]['query'](_0xfa5836(_0x302a1a,_0x0a1d('0x5c')))[_0x0a1d('0x2a')](function(){})[_0x0a1d('0x2d')](_0x1d8052()));break;default:_0x3bc8b0[_0x0a1d('0x2b')](db[_0x0a1d('0x54')]['query'](_0x13b1cf(_0x302a1a,_0x0a1d('0x5c')))[_0x0a1d('0x2a')](function(){})[_0x0a1d('0x2d')](_0x1d8052()));}}}return _0x3bc8b0;})[_0x0a1d('0x5a')]();})[_0x0a1d('0x2a')](function(){return db['Campaign'][_0x0a1d('0x4f')]({'attributes':['id'],'include':[{'model':db[_0x0a1d('0x58')],'as':'BlackLists','where':{'id':LISTID}}]})[_0x0a1d('0x2a')](function(_0x417863){var _0x2a088b=[];if(_0x417863){for(var _0x5247db=0x0,_0x5bdd9b;_0x5247db<_0x417863[_0x0a1d('0x1b')];_0x5247db+=0x1){_0x5bdd9b=_0x417863[_0x5247db][_0x0a1d('0x52')]({'plain':!![]});_0x2a088b[_0x0a1d('0x2b')](db['sequelize'][_0x0a1d('0x57')](_0x19fe09(_0x5bdd9b,_0x0a1d('0x5c')))[_0x0a1d('0x2a')](function(){})[_0x0a1d('0x2d')](_0x1d8052()));}}return _0x2a088b;})[_0x0a1d('0x5a')]();})['catch'](function(_0x5d8386){logger[_0x0a1d('0x17')](_0x0a1d('0x5d'),_0x0a1d('0x5e'),_0x5d8386[_0x0a1d('0x2f')]);});}var processPromises=function(_0x30a1d0){return BPromise[_0x0a1d('0x5a')](promises)[_0x0a1d('0x2a')](function(_0x1de868){})['catch'](function(_0x560df5){logger[_0x0a1d('0x17')](_0x0a1d('0x5f'),JSON[_0x0a1d('0x30')](_0x560df5));})[_0x0a1d('0x60')](function(){socket['emit'](_0x0a1d('0x61')+SOCKET_TIMESTAMP,{'success':success,'errors':errors,'duplicates':duplicates,'rows':rows});promises=[];success=0x0;errors=0x0;duplicates=0x0;rows=[];if(_0x30a1d0){return _0x30a1d0[_0x0a1d('0x62')]();}});};var endCsv=function(){return BPromise['resolve']()[_0x0a1d('0x2a')](function(){if(hopperContacts){return checkHopper();}})[_0x0a1d('0x2a')](function(){socket['emit'](_0x0a1d('0x61')+SOCKET_TIMESTAMP,{'finished':!![],'success':success,'errors':errors,'duplicates':duplicates,'rows':rows});try{fs[_0x0a1d('0x63')](FILEPATH);}catch(_0x21feab){logger['error'](_0x0a1d('0x64'),JSON[_0x0a1d('0x30')](_0x21feab));}finally{process[_0x0a1d('0x65')](0x0);}});};process['on'](_0x0a1d('0x66'),function(){logger['info'](_0x0a1d('0x67'));endCsv();});function main(){return BPromise['resolve']()[_0x0a1d('0x2a')](function(){if(DUPLICATES){DUPLICATES=DUPLICATES[_0x0a1d('0x14')](',');return db[_0x0a1d('0x68')]['findAll']({'where':{'ListId':LISTID},'attributes':DUPLICATES,'raw':!![]});}})[_0x0a1d('0x2a')](function(_0x56aeca){var _0x458175=fs[_0x0a1d('0x69')](FILEPATH,{'highWaterMark':0xf*0x400*0x400});Papa[_0x0a1d('0x6a')](_0x458175,{'header':!![],'skipEmptyLines':!![],'step':function(_0x11df5b,_0x4521de){total+=0x1;var _0x43c662=total;promises[_0x0a1d('0x2b')](checkRow(_0x11df5b,_0x56aeca,_0x43c662)['then'](function(){success+=0x1;})[_0x0a1d('0x2d')](function(_0x1ad142){if(_0x1ad142['error']){errors+=0x1;delete _0x1ad142[_0x0a1d('0x17')];}else if(_0x1ad142[_0x0a1d('0x27')]){duplicates+=0x1;delete _0x1ad142[_0x0a1d('0x27')];}rows[_0x0a1d('0x2b')](_0x1ad142);}));if(total%0xc8===0x0){_0x4521de['pause']();return processPromises(_0x4521de);}},'complete':function(){return processPromises()[_0x0a1d('0x2a')](function(){logger['info']('CSV\x20parsed\x20correctly!');endCsv();});},'error':function(_0x500094,_0x51c8bb){logger[_0x0a1d('0x6b')](_0x0a1d('0x6c'),JSON[_0x0a1d('0x30')](_0x500094));endCsv();}});})[_0x0a1d('0x2d')](function(_0x286b0e){logger[_0x0a1d('0x17')]('Error\x20executing\x20contact\x20csv\x20import:',JSON['stringify'](_0x286b0e));});}main();
\ No newline at end of file
+var _0x4fc3=['test','isNil','The\x20row\x20is\x20empty\x20or\x20the\x20number\x20of\x20parameters\x20does\x20not\x20match\x20the\x20columns!','errors','length','join','hasOwnProperty','data','firstName','firstName\x20not\x20specified!','birthDate','YYYY-MM-DD','birthDate\x20format\x20is\x20invalid,\x20YYYY-MM-DD\x20format\x20is\x20supported!','email','email\x20format\x20is\x20not\x20valid!','CompanyId','find','duplicate','Duplicate\x20Contact','CmContact','create','then','pick','catch','stringify','cmContact','checkHopper','inspect','insert','fromQuery','phone','scheduledAt','createdAt','updatedAt','select','field','ContactId','toString','ListId','NOW()','where','deletedAt\x20IS\x20NULL','ListId\x20=\x20?','phone\x20NOT\x20IN\x20(?)','cm_hopper','\x20=\x20?','into','from','id\x20IN\x20?','str','calleridnum','cm_hopper_final','cm_contacts','phone\x20IS\x20NOT\x20NULL','cm_hopper_black','VoiceQueue','findAll','outbound','dialCheckDuplicateType','CmList','Lists','get','sequelize','VoiceQueueId','onlyIfOpen','push','query','all','BlackLists','Campaign','always','CampaignId','generalCheckHopper','message','Error\x20processing\x20rows\x20block:','finally','emit','contact:csv_','resume','resolve','Unable\x20to\x20delete\x20temp\x20file:','exit','SIGINT','info','createReadStream','parse','pause','CSV\x20parsed\x20correctly!','CSV\x20parse\x20error','Error\x20executing\x20contact\x20csv\x20import:','bluebird','util','papaparse','ioredis','../../../mysqldb','../../../config/environment','../../../config/logger','api','redis','defaults','localhost','socket.io-emitter','../../../api/cmContact/cmContact.socket','argv','undefined','Missing\x20filepath\x20parameter!','null','Missing\x20binding\x20parameters!','zipObject','split','Missing\x20ListId\x20parameter!','Missing\x20socket_timestamp\x20parameter!','error','index'];(function(_0x5a3b79,_0x2e7582){var _0x23c45e=function(_0x5a94d0){while(--_0x5a94d0){_0x5a3b79['push'](_0x5a3b79['shift']());}};_0x23c45e(++_0x2e7582);}(_0x4fc3,0x1b0));var _0x34fc=function(_0x13e00e,_0x46d33e){_0x13e00e=_0x13e00e-0x0;var _0x2bca87=_0x4fc3[_0x13e00e];return _0x2bca87;};'use strict';var BPromise=require(_0x34fc('0x0'));var util=require(_0x34fc('0x1'));var _=require('lodash');var fs=require('fs');var squel=require('squel');var Papa=require(_0x34fc('0x2'));var Redis=require(_0x34fc('0x3'));var db=require(_0x34fc('0x4'))['db'];var config=require(_0x34fc('0x5'));var logger=require(_0x34fc('0x6'))(_0x34fc('0x7'));config[_0x34fc('0x8')]=_[_0x34fc('0x9')](config[_0x34fc('0x8')],{'host':_0x34fc('0xa'),'port':0x18eb});var socket=require(_0x34fc('0xb'))(new Redis(config['redis']));require(_0x34fc('0xc'))['register'](socket);try{if(!process[_0x34fc('0xd')][0x2]||process[_0x34fc('0xd')][0x2]===_0x34fc('0xe')||process[_0x34fc('0xd')][0x2]==='null'){throw new Error(_0x34fc('0xf'));}var FILEPATH=process[_0x34fc('0xd')][0x2];if(!process['argv'][0x3]||process[_0x34fc('0xd')][0x3]===_0x34fc('0xe')||process[_0x34fc('0xd')][0x3]===_0x34fc('0x10')||!process['argv'][0x4]||process[_0x34fc('0xd')][0x4]===_0x34fc('0xe')||process[_0x34fc('0xd')][0x4]===_0x34fc('0x10')){throw new Error(_0x34fc('0x11'));}var FIELDS=_[_0x34fc('0x12')](process['argv'][0x3][_0x34fc('0x13')](','),process[_0x34fc('0xd')][0x4][_0x34fc('0x13')](','));if(!process[_0x34fc('0xd')][0x5]||process[_0x34fc('0xd')][0x5]==='undefined'||process[_0x34fc('0xd')][0x5]===_0x34fc('0x10')){throw new Error(_0x34fc('0x14'));}var LISTID=process['argv'][0x5];var COMPANYID=process[_0x34fc('0xd')][0x6]&&process['argv'][0x6]!==_0x34fc('0xe')&&process[_0x34fc('0xd')][0x6]!==_0x34fc('0x10')?process[_0x34fc('0xd')][0x6]:null;var DUPLICATES=process[_0x34fc('0xd')][0x7]&&process[_0x34fc('0xd')][0x7]!==_0x34fc('0xe')&&process[_0x34fc('0xd')][0x7]!==_0x34fc('0x10')?process[_0x34fc('0xd')][0x7]:null;if(!process[_0x34fc('0xd')][0x8]||process[_0x34fc('0xd')][0x8]===_0x34fc('0xe')||process[_0x34fc('0xd')][0x8]===_0x34fc('0x10')){throw new Error(_0x34fc('0x15'));}var SOCKET_TIMESTAMP=process[_0x34fc('0xd')][0x8];}catch(_0x3a9ca3){logger[_0x34fc('0x16')](_0x3a9ca3);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(_0x478c2e,_0x453c14,_0x4385f6,_0x598292){var _0x2a9e16={'message':_0x453c14};_0x2a9e16[_0x478c2e]=!![];if(_0x4385f6){_0x2a9e16['contact']=_0x4385f6;}if(_0x598292){_0x2a9e16[_0x34fc('0x17')]=_0x598292;}return _0x2a9e16;}function isEmail(_0x3e02b7){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))*$/[_0x34fc('0x18')](_0x3e02b7);}function checkRow(_0x2255b5,_0x1123c7,_0x4c725f){return new BPromise(function(_0x2e26ea,_0xd9734c){if(_[_0x34fc('0x19')](_0x2255b5)){return _0xd9734c(handleCheckRowError(_0x34fc('0x16'),_0x34fc('0x1a'),null,_0x4c725f));}if(_0x2255b5[_0x34fc('0x1b')]&&_0x2255b5[_0x34fc('0x1b')][_0x34fc('0x1c')]){var _0xc3ba0e=_['map'](_0x2255b5[_0x34fc('0x1b')],'message')[_0x34fc('0x1d')](';');return _0xd9734c(handleCheckRowError('error',_0xc3ba0e,null,_0x4c725f));}var _0x5c7fe0={};for(var _0x357d6f in FIELDS){if(FIELDS[_0x34fc('0x1e')](_0x357d6f)&&FIELDS[_0x357d6f]){_0x5c7fe0[_0x357d6f]=_0x2255b5[_0x34fc('0x1f')][0x0][FIELDS[_0x357d6f]]||_0x2255b5[_0x34fc('0x1f')][0x0]['\ufeff'+FIELDS[_0x357d6f]];}}if(!_0x5c7fe0[_0x34fc('0x20')]){return _0xd9734c(handleCheckRowError(_0x34fc('0x16'),_0x34fc('0x21'),null,_0x4c725f));}if(!_0x5c7fe0['phone']){return _0xd9734c(handleCheckRowError(_0x34fc('0x16'),'phone\x20not\x20specified!',null,_0x4c725f));}if(_0x5c7fe0[_0x34fc('0x22')]){var _0x297751=moment(_0x5c7fe0['birthDate'],_0x34fc('0x23'));if(!_0x297751['isValid']()){return _0xd9734c(handleCheckRowError(_0x34fc('0x16'),_0x34fc('0x24'),null,_0x4c725f));}}if(_0x5c7fe0[_0x34fc('0x25')]){if(!isEmail(_0x5c7fe0[_0x34fc('0x25')])){return _0xd9734c(handleCheckRowError(_0x34fc('0x16'),_0x34fc('0x26'),null,_0x4c725f));}}_0x5c7fe0['ListId']=LISTID;_0x5c7fe0[_0x34fc('0x27')]=COMPANYID||undefined;if(DUPLICATES&&DUPLICATES['length']&&_0x1123c7){var _0x49ff1c={};for(var _0x409bbe=0x0,_0x37442b=DUPLICATES[_0x34fc('0x1c')];_0x409bbe<_0x37442b;_0x409bbe+=0x1){_0x49ff1c[DUPLICATES[_0x409bbe]]=_0x5c7fe0[DUPLICATES[_0x409bbe]];}var _0x28d6bd=_[_0x34fc('0x28')](_0x1123c7,_0x49ff1c);if(_0x28d6bd){return _0xd9734c(handleCheckRowError(_0x34fc('0x29'),_0x34fc('0x2a'),_0x28d6bd,_0x4c725f));}}return db[_0x34fc('0x2b')][_0x34fc('0x2c')](_0x5c7fe0,{'raw':!![],'hooks':![],'fields':_['keys'](_0x5c7fe0)})[_0x34fc('0x2d')](function(_0x3e2bac){if(DUPLICATES&&DUPLICATES[_0x34fc('0x1c')]&&_0x1123c7){_0x1123c7['push'](_[_0x34fc('0x2e')](_0x5c7fe0,DUPLICATES));}hopperContacts+=(hopperContacts?',':'')+_0x3e2bac['id'];return _0x2e26ea();})[_0x34fc('0x2f')](function(_0x5486b2){return _0xd9734c(handleCheckRowError('error','Error\x20while\x20creating\x20contact:\x20'+(_0x5486b2['message']||JSON[_0x34fc('0x30')](_0x5486b2)),null,_0x4c725f));});});}function checkHopper(){function _0x335ebe(){return function(_0x2b56fd){logger[_0x34fc('0x16')](_0x34fc('0x31'),_0x34fc('0x32'),util[_0x34fc('0x33')](_0x2b56fd,{'showHidden':![],'depth':null}));};}var _0x1c8740=function(_0x152a3e,_0x56d19c){var _0x587454=squel[_0x34fc('0x34')]()['into']('cm_hopper')[_0x34fc('0x35')]([_0x34fc('0x36'),_0x34fc('0x37'),'ContactId','ListId',_0x56d19c,_0x34fc('0x38'),_0x34fc('0x39')],squel[_0x34fc('0x3a')]()[_0x34fc('0x3b')](_0x34fc('0x36'),_0x34fc('0x36'))['field']('NOW()',_0x34fc('0x37'))[_0x34fc('0x3b')]('id',_0x34fc('0x3c'))[_0x34fc('0x3b')](LISTID[_0x34fc('0x3d')](),_0x34fc('0x3e'))[_0x34fc('0x3b')](_0x152a3e['id'][_0x34fc('0x3d')](),_0x56d19c)[_0x34fc('0x3b')](_0x34fc('0x3f'),_0x34fc('0x38'))[_0x34fc('0x3b')](_0x34fc('0x3f'),'updatedAt')['from']('cm_contacts')[_0x34fc('0x40')](_0x34fc('0x41'))[_0x34fc('0x40')](_0x34fc('0x42'),LISTID[_0x34fc('0x3d')]())[_0x34fc('0x40')]('phone\x20IS\x20NOT\x20NULL')[_0x34fc('0x40')](_0x34fc('0x43'),squel[_0x34fc('0x3a')]()[_0x34fc('0x3b')]('phone')['from'](_0x34fc('0x44'))[_0x34fc('0x40')](_0x56d19c+_0x34fc('0x45'),_0x152a3e['id'][_0x34fc('0x3d')]())))[_0x34fc('0x3d')]();return _0x587454;};var _0x3e4e51=function(_0x15dc30,_0x2e3430){var _0x1ee9ec=squel[_0x34fc('0x34')]()[_0x34fc('0x46')](_0x34fc('0x44'))['fromQuery'](['phone',_0x34fc('0x37'),_0x34fc('0x3c'),_0x34fc('0x3e'),_0x2e3430,_0x34fc('0x38'),_0x34fc('0x39')],squel[_0x34fc('0x3a')]()['field'](_0x34fc('0x36'),_0x34fc('0x36'))[_0x34fc('0x3b')](_0x34fc('0x3f'),_0x34fc('0x37'))[_0x34fc('0x3b')]('id',_0x34fc('0x3c'))[_0x34fc('0x3b')](LISTID['toString'](),_0x34fc('0x3e'))[_0x34fc('0x3b')](_0x15dc30['id']['toString'](),_0x2e3430)[_0x34fc('0x3b')](_0x34fc('0x3f'),_0x34fc('0x38'))[_0x34fc('0x3b')](_0x34fc('0x3f'),'updatedAt')[_0x34fc('0x47')]('cm_contacts')[_0x34fc('0x40')](_0x34fc('0x41'))['where']('ListId\x20=\x20?',LISTID[_0x34fc('0x3d')]())[_0x34fc('0x40')](_0x34fc('0x48'),squel[_0x34fc('0x49')](hopperContacts))[_0x34fc('0x40')]('phone\x20IS\x20NOT\x20NULL')[_0x34fc('0x40')]('phone\x20NOT\x20IN\x20(?)',squel[_0x34fc('0x3a')]()['field'](_0x34fc('0x4a'))[_0x34fc('0x47')](_0x34fc('0x4b'))[_0x34fc('0x40')](_0x2e3430+_0x34fc('0x45'),_0x15dc30['id'][_0x34fc('0x3d')]()))[_0x34fc('0x40')](_0x34fc('0x43'),squel[_0x34fc('0x3a')]()[_0x34fc('0x3b')](_0x34fc('0x36'))[_0x34fc('0x47')]('cm_hopper')[_0x34fc('0x40')](_0x2e3430+'\x20=\x20?',_0x15dc30['id']['toString']())))[_0x34fc('0x3d')]();return _0x1ee9ec;};function _0x5e1488(_0x3cb7ca,_0x19f147){var _0x582e5d=squel['insert']()[_0x34fc('0x46')](_0x34fc('0x44'))[_0x34fc('0x35')]([_0x34fc('0x36'),_0x34fc('0x37'),_0x34fc('0x3c'),_0x34fc('0x3e'),_0x19f147,'createdAt','updatedAt'],squel[_0x34fc('0x3a')]()[_0x34fc('0x3b')](_0x34fc('0x36'),_0x34fc('0x36'))[_0x34fc('0x3b')](_0x34fc('0x3f'),_0x34fc('0x37'))[_0x34fc('0x3b')]('id',_0x34fc('0x3c'))[_0x34fc('0x3b')](LISTID[_0x34fc('0x3d')](),_0x34fc('0x3e'))[_0x34fc('0x3b')](_0x3cb7ca['id'][_0x34fc('0x3d')](),_0x19f147)['field'](_0x34fc('0x3f'),_0x34fc('0x38'))['field'](_0x34fc('0x3f'),_0x34fc('0x39'))['from'](_0x34fc('0x4c'))[_0x34fc('0x40')](_0x34fc('0x41'))[_0x34fc('0x40')](_0x34fc('0x42'),LISTID[_0x34fc('0x3d')]())[_0x34fc('0x40')]('id\x20IN\x20?',squel[_0x34fc('0x49')](hopperContacts))[_0x34fc('0x40')](_0x34fc('0x4d')))[_0x34fc('0x3d')]();return _0x582e5d;}function _0x4bca46(_0x498638,_0x37e606){var _0x2bf6c5=squel[_0x34fc('0x34')]()[_0x34fc('0x46')](_0x34fc('0x4e'))[_0x34fc('0x35')]([_0x34fc('0x36'),_0x34fc('0x3c'),_0x34fc('0x3e'),_0x37e606,_0x34fc('0x38'),_0x34fc('0x39')],squel[_0x34fc('0x3a')]()[_0x34fc('0x3b')](_0x34fc('0x36'),'phone')[_0x34fc('0x3b')]('id','ContactId')[_0x34fc('0x3b')](LISTID[_0x34fc('0x3d')](),_0x34fc('0x3e'))[_0x34fc('0x3b')](_0x498638['id'][_0x34fc('0x3d')](),_0x37e606)['field'](_0x34fc('0x3f'),_0x34fc('0x38'))['field']('NOW()',_0x34fc('0x39'))[_0x34fc('0x47')](_0x34fc('0x4c'))[_0x34fc('0x40')](_0x34fc('0x41'))[_0x34fc('0x40')](_0x34fc('0x42'),LISTID[_0x34fc('0x3d')]())['where']('id\x20IN\x20?',squel[_0x34fc('0x49')](hopperContacts))[_0x34fc('0x40')](_0x34fc('0x4d')))['toString']();return _0x2bf6c5;}return db[_0x34fc('0x4f')][_0x34fc('0x50')]({'where':{'type':_0x34fc('0x51')},'attributes':['id',_0x34fc('0x52')],'include':[{'model':db[_0x34fc('0x53')],'as':_0x34fc('0x54'),'where':{'id':LISTID}}]})[_0x34fc('0x2d')](function(_0x4216d4){var _0x4646f3=[];if(_0x4216d4){var _0x2db220;for(var _0x19563f=0x0,_0x5ce8ac;_0x19563f<_0x4216d4[_0x34fc('0x1c')];_0x19563f+=0x1){_0x5ce8ac=_0x4216d4[_0x19563f][_0x34fc('0x55')]({'plain':!![]});switch(_0x5ce8ac[_0x34fc('0x52')]){case'always':_0x4646f3['push'](db[_0x34fc('0x56')]['query'](_0x3e4e51(_0x5ce8ac,_0x34fc('0x57')))[_0x34fc('0x2d')](function(){})[_0x34fc('0x2f')](_0x335ebe()));break;case _0x34fc('0x58'):_0x4646f3[_0x34fc('0x59')](db[_0x34fc('0x56')][_0x34fc('0x5a')](_0x1c8740(_0x5ce8ac,'VoiceQueueId'))[_0x34fc('0x2d')](function(){})[_0x34fc('0x2f')](_0x335ebe()));break;default:_0x4646f3[_0x34fc('0x59')](db[_0x34fc('0x56')][_0x34fc('0x5a')](_0x5e1488(_0x5ce8ac,_0x34fc('0x57')))[_0x34fc('0x2d')](function(){})[_0x34fc('0x2f')](_0x335ebe()));}}}return _0x4646f3;})[_0x34fc('0x5b')]()[_0x34fc('0x2d')](function(){return db[_0x34fc('0x4f')][_0x34fc('0x50')]({'where':{'type':_0x34fc('0x51')},'attributes':['id'],'include':[{'model':db[_0x34fc('0x53')],'as':_0x34fc('0x5c'),'where':{'id':LISTID}}]})[_0x34fc('0x2d')](function(_0x593691){var _0x422b3a=[];if(_0x593691){var _0x5b4160;for(var _0x51110f=0x0,_0x5ad5a0;_0x51110f<_0x593691[_0x34fc('0x1c')];_0x51110f+=0x1){_0x5ad5a0=_0x593691[_0x51110f][_0x34fc('0x55')]({'plain':!![]});_0x422b3a[_0x34fc('0x59')](db[_0x34fc('0x56')][_0x34fc('0x5a')](_0x4bca46(_0x5ad5a0,'VoiceQueueId'))['then'](function(){})[_0x34fc('0x2f')](_0x335ebe()));}}return _0x422b3a;})[_0x34fc('0x5b')]();})['then'](function(){return db[_0x34fc('0x5d')]['findAll']({'attributes':['id',_0x34fc('0x52')],'include':[{'model':db[_0x34fc('0x53')],'as':_0x34fc('0x54'),'where':{'id':LISTID}}]})[_0x34fc('0x2d')](function(_0x2c7176){var _0x551c2f=[];if(_0x2c7176){for(var _0x5bd94b=0x0,_0x5c3f59;_0x5bd94b<_0x2c7176[_0x34fc('0x1c')];_0x5bd94b+=0x1){_0x5c3f59=_0x2c7176[_0x5bd94b][_0x34fc('0x55')]({'plain':!![]});switch(_0x5c3f59['dialCheckDuplicateType']){case _0x34fc('0x5e'):_0x551c2f[_0x34fc('0x59')](db[_0x34fc('0x56')][_0x34fc('0x5a')](_0x3e4e51(_0x5c3f59,_0x34fc('0x5f')))[_0x34fc('0x2d')](function(){})[_0x34fc('0x2f')](_0x335ebe()));break;case'onlyIfOpen':_0x551c2f[_0x34fc('0x59')](db[_0x34fc('0x56')]['query'](_0x1c8740(_0x5c3f59,_0x34fc('0x5f')))['then'](function(){})[_0x34fc('0x2f')](_0x335ebe()));break;default:_0x551c2f['push'](db[_0x34fc('0x56')]['query'](_0x5e1488(_0x5c3f59,_0x34fc('0x5f')))[_0x34fc('0x2d')](function(){})['catch'](_0x335ebe()));}}}return _0x551c2f;})['all']();})[_0x34fc('0x2d')](function(){return db['Campaign'][_0x34fc('0x50')]({'attributes':['id'],'include':[{'model':db['CmList'],'as':_0x34fc('0x5c'),'where':{'id':LISTID}}]})[_0x34fc('0x2d')](function(_0x24c111){var _0x2428e0=[];if(_0x24c111){for(var _0x345943=0x0,_0x249afd;_0x345943<_0x24c111[_0x34fc('0x1c')];_0x345943+=0x1){_0x249afd=_0x24c111[_0x345943]['get']({'plain':!![]});_0x2428e0[_0x34fc('0x59')](db['sequelize'][_0x34fc('0x5a')](_0x4bca46(_0x249afd,'CampaignId'))['then'](function(){})['catch'](_0x335ebe()));}}return _0x2428e0;})[_0x34fc('0x5b')]();})[_0x34fc('0x2f')](function(_0x57d188){logger['error']('cmContact,\x20%s,\x20%s',_0x34fc('0x60'),_0x57d188[_0x34fc('0x61')]);});}var processPromises=function(_0x4b1092){return BPromise[_0x34fc('0x5b')](promises)[_0x34fc('0x2d')](function(_0x3207fa){})[_0x34fc('0x2f')](function(_0xd8fb86){logger[_0x34fc('0x16')](_0x34fc('0x62'),JSON[_0x34fc('0x30')](_0xd8fb86));})[_0x34fc('0x63')](function(){socket[_0x34fc('0x64')](_0x34fc('0x65')+SOCKET_TIMESTAMP,{'success':success,'errors':errors,'duplicates':duplicates,'rows':rows});promises=[];success=0x0;errors=0x0;duplicates=0x0;rows=[];if(_0x4b1092){return _0x4b1092[_0x34fc('0x66')]();}});};var endCsv=function(){return BPromise[_0x34fc('0x67')]()[_0x34fc('0x2d')](function(){if(hopperContacts){return checkHopper();}})['then'](function(){socket['emit']('contact:csv_'+SOCKET_TIMESTAMP,{'finished':!![],'success':success,'errors':errors,'duplicates':duplicates,'rows':rows});try{fs['unlinkSync'](FILEPATH);}catch(_0xbd6f06){logger[_0x34fc('0x16')](_0x34fc('0x68'),JSON[_0x34fc('0x30')](_0xbd6f06));}finally{process[_0x34fc('0x69')](0x0);}});};process['on'](_0x34fc('0x6a'),function(){logger[_0x34fc('0x6b')]('CSV\x20import\x20process\x20stopped!');endCsv();});function main(){return BPromise['resolve']()[_0x34fc('0x2d')](function(){if(DUPLICATES){DUPLICATES=DUPLICATES['split'](',');return db[_0x34fc('0x2b')][_0x34fc('0x50')]({'where':{'ListId':LISTID},'attributes':DUPLICATES,'raw':!![]});}})[_0x34fc('0x2d')](function(_0x591084){var _0x17432b=fs[_0x34fc('0x6c')](FILEPATH,{'highWaterMark':0xf*0x400*0x400});Papa[_0x34fc('0x6d')](_0x17432b,{'header':!![],'skipEmptyLines':!![],'step':function(_0x7a1397,_0x2f2a6c){total+=0x1;var _0x4ffc17=total;promises[_0x34fc('0x59')](checkRow(_0x7a1397,_0x591084,_0x4ffc17)[_0x34fc('0x2d')](function(){success+=0x1;})[_0x34fc('0x2f')](function(_0x545d1a){if(_0x545d1a[_0x34fc('0x16')]){errors+=0x1;delete _0x545d1a['error'];}else if(_0x545d1a['duplicate']){duplicates+=0x1;delete _0x545d1a[_0x34fc('0x29')];}rows[_0x34fc('0x59')](_0x545d1a);}));if(total%0xc8===0x0){_0x2f2a6c[_0x34fc('0x6e')]();return processPromises(_0x2f2a6c);}},'complete':function(){return processPromises()[_0x34fc('0x2d')](function(){logger[_0x34fc('0x6b')](_0x34fc('0x6f'));endCsv();});},'error':function(_0x4696d6,_0x50f3e7){logger[_0x34fc('0x6b')](_0x34fc('0x70'),JSON[_0x34fc('0x30')](_0x4696d6));endCsv();}});})[_0x34fc('0x2f')](function(_0x3147ad){logger[_0x34fc('0x16')](_0x34fc('0x71'),JSON[_0x34fc('0x30')](_0x3147ad));});}main();
\ No newline at end of file