Built motion from commit eddce310.|2.6.12
[motion2.git] / server / components / import / cm / csv.js
index 9fb49be..8099802 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x1b3c=['get','dialCheckDuplicateType','always','push','VoiceQueueId','onlyIfOpen','sequelize','query','all','CampaignId','Campaign','BlackLists','generalCheckHopper','Error\x20processing\x20rows\x20block:','finally','emit','contact:csv_','resume','resolve','unlinkSync','Unable\x20to\x20delete\x20temp\x20file:','info','CSV\x20import\x20process\x20stopped!','createReadStream','parse','duplicate','pause','CSV\x20parse\x20error','bluebird','util','lodash','squel','papaparse','ioredis','../../../mysqldb','../../../config/environment','api','redis','localhost','argv','undefined','Missing\x20filepath\x20parameter!','null','Missing\x20binding\x20parameters!','zipObject','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','data','firstName','firstName\x20not\x20specified!','phone','phone\x20not\x20specified!','birthDate','YYYY-MM-DD','birthDate\x20format\x20is\x20invalid,\x20YYYY-MM-DD\x20format\x20is\x20supported!','email','email\x20format\x20is\x20not\x20valid!','ListId','CompanyId','find','Duplicate\x20Contact','CmContact','create','then','pick','catch','Error\x20while\x20creating\x20contact:\x20','stringify','cmContact','inspect','scheduledAt','ContactId','createdAt','select','field','NOW()','toString','updatedAt','from','cm_contacts','where','ListId\x20=\x20?','phone\x20IS\x20NOT\x20NULL','cm_hopper','\x20=\x20?','insert','into','fromQuery','deletedAt\x20IS\x20NULL','str','phone\x20NOT\x20IN\x20(?)','cm_hopper_final','id\x20IN\x20?','cm_hopper_black','VoiceQueue','findAll','outbound','CmList','Lists'];(function(_0x2c6626,_0x3c7a68){var _0x3ee899=function(_0x3d2d31){while(--_0x3d2d31){_0x2c6626['push'](_0x2c6626['shift']());}};_0x3ee899(++_0x3c7a68);}(_0x1b3c,0xf8));var _0xc1b3=function(_0x6ad2,_0x205a3b){_0x6ad2=_0x6ad2-0x0;var _0x151d14=_0x1b3c[_0x6ad2];return _0x151d14;};'use strict';var BPromise=require(_0xc1b3('0x0'));var util=require(_0xc1b3('0x1'));var _=require(_0xc1b3('0x2'));var fs=require('fs');var squel=require(_0xc1b3('0x3'));var Papa=require(_0xc1b3('0x4'));var Redis=require(_0xc1b3('0x5'));var db=require(_0xc1b3('0x6'))['db'];var config=require(_0xc1b3('0x7'));var logger=require('../../../config/logger')(_0xc1b3('0x8'));config['redis']=_['defaults'](config[_0xc1b3('0x9')],{'host':_0xc1b3('0xa'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0xc1b3('0x9')]));require('../../../api/cmContact/cmContact.socket')['register'](socket);try{if(!process[_0xc1b3('0xb')][0x2]||process[_0xc1b3('0xb')][0x2]===_0xc1b3('0xc')||process[_0xc1b3('0xb')][0x2]==='null'){throw new Error(_0xc1b3('0xd'));}var FILEPATH=process[_0xc1b3('0xb')][0x2];if(!process[_0xc1b3('0xb')][0x3]||process[_0xc1b3('0xb')][0x3]===_0xc1b3('0xc')||process[_0xc1b3('0xb')][0x3]===_0xc1b3('0xe')||!process['argv'][0x4]||process[_0xc1b3('0xb')][0x4]===_0xc1b3('0xc')||process[_0xc1b3('0xb')][0x4]==='null'){throw new Error(_0xc1b3('0xf'));}var FIELDS=_[_0xc1b3('0x10')](process['argv'][0x3][_0xc1b3('0x11')](','),process['argv'][0x4]['split'](','));if(!process['argv'][0x5]||process[_0xc1b3('0xb')][0x5]==='undefined'||process[_0xc1b3('0xb')][0x5]===_0xc1b3('0xe')){throw new Error(_0xc1b3('0x12'));}var LISTID=process[_0xc1b3('0xb')][0x5];var COMPANYID=process[_0xc1b3('0xb')][0x6]&&process[_0xc1b3('0xb')][0x6]!==_0xc1b3('0xc')&&process[_0xc1b3('0xb')][0x6]!==_0xc1b3('0xe')?process[_0xc1b3('0xb')][0x6]:null;var DUPLICATES=process[_0xc1b3('0xb')][0x7]&&process[_0xc1b3('0xb')][0x7]!==_0xc1b3('0xc')&&process[_0xc1b3('0xb')][0x7]!==_0xc1b3('0xe')?process[_0xc1b3('0xb')][0x7]:null;if(!process[_0xc1b3('0xb')][0x8]||process[_0xc1b3('0xb')][0x8]===_0xc1b3('0xc')||process[_0xc1b3('0xb')][0x8]===_0xc1b3('0xe')){throw new Error(_0xc1b3('0x13'));}var SOCKET_TIMESTAMP=process[_0xc1b3('0xb')][0x8];}catch(_0x94c306){logger[_0xc1b3('0x14')](_0x94c306);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(_0x1aaeb6,_0x575ce7,_0xddc674,_0x367891){var _0x5e5533={'message':_0x575ce7};_0x5e5533[_0x1aaeb6]=!![];if(_0xddc674){_0x5e5533[_0xc1b3('0x15')]=_0xddc674;}if(_0x367891){_0x5e5533[_0xc1b3('0x16')]=_0x367891;}return _0x5e5533;}function isEmail(_0x440971){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))*$/[_0xc1b3('0x17')](_0x440971);}function checkRow(_0xc3c431,_0x398664,_0x562ed7){return new BPromise(function(_0x3ed99c,_0x5af580){if(_[_0xc1b3('0x18')](_0xc3c431)){return _0x5af580(handleCheckRowError(_0xc1b3('0x14'),_0xc1b3('0x19'),null,_0x562ed7));}if(_0xc3c431[_0xc1b3('0x1a')]&&_0xc3c431[_0xc1b3('0x1a')][_0xc1b3('0x1b')]){var _0x3949e9=_[_0xc1b3('0x1c')](_0xc3c431[_0xc1b3('0x1a')],_0xc1b3('0x1d'))['join'](';');return _0x5af580(handleCheckRowError(_0xc1b3('0x14'),_0x3949e9,null,_0x562ed7));}var _0x4388a3={};for(var _0x17e08e in FIELDS){if(FIELDS['hasOwnProperty'](_0x17e08e)&&FIELDS[_0x17e08e]){_0x4388a3[_0x17e08e]=_0xc3c431[_0xc1b3('0x1e')][0x0][FIELDS[_0x17e08e]]||_0xc3c431[_0xc1b3('0x1e')][0x0]['\ufeff'+FIELDS[_0x17e08e]];}}if(!_0x4388a3[_0xc1b3('0x1f')]){return _0x5af580(handleCheckRowError('error',_0xc1b3('0x20'),null,_0x562ed7));}if(!_0x4388a3[_0xc1b3('0x21')]){return _0x5af580(handleCheckRowError(_0xc1b3('0x14'),_0xc1b3('0x22'),null,_0x562ed7));}if(_0x4388a3['birthDate']){var _0x53cefe=moment(_0x4388a3[_0xc1b3('0x23')],_0xc1b3('0x24'));if(!_0x53cefe['isValid']()){return _0x5af580(handleCheckRowError(_0xc1b3('0x14'),_0xc1b3('0x25'),null,_0x562ed7));}}if(_0x4388a3['email']){if(!isEmail(_0x4388a3[_0xc1b3('0x26')])){return _0x5af580(handleCheckRowError('error',_0xc1b3('0x27'),null,_0x562ed7));}}_0x4388a3[_0xc1b3('0x28')]=LISTID;_0x4388a3[_0xc1b3('0x29')]=COMPANYID||undefined;if(DUPLICATES&&DUPLICATES[_0xc1b3('0x1b')]&&_0x398664){var _0x24f9cf={};for(var _0x4402fb=0x0,_0x48d458=DUPLICATES[_0xc1b3('0x1b')];_0x4402fb<_0x48d458;_0x4402fb+=0x1){_0x24f9cf[DUPLICATES[_0x4402fb]]=_0x4388a3[DUPLICATES[_0x4402fb]];}var _0x5513ed=_[_0xc1b3('0x2a')](_0x398664,_0x24f9cf);if(_0x5513ed){return _0x5af580(handleCheckRowError('duplicate',_0xc1b3('0x2b'),_0x5513ed,_0x562ed7));}}return db[_0xc1b3('0x2c')][_0xc1b3('0x2d')](_0x4388a3,{'raw':!![],'hooks':![],'fields':_['keys'](_0x4388a3)})[_0xc1b3('0x2e')](function(_0x1e9ebb){if(DUPLICATES&&DUPLICATES[_0xc1b3('0x1b')]&&_0x398664){_0x398664['push'](_[_0xc1b3('0x2f')](_0x4388a3,DUPLICATES));}hopperContacts+=(hopperContacts?',':'')+_0x1e9ebb['id'];return _0x3ed99c();})[_0xc1b3('0x30')](function(_0x35b362){return _0x5af580(handleCheckRowError(_0xc1b3('0x14'),_0xc1b3('0x31')+(_0x35b362[_0xc1b3('0x1d')]||JSON[_0xc1b3('0x32')](_0x35b362)),null,_0x562ed7));});});}function checkHopper(){function _0x47252a(){return function(_0x56d51e){logger[_0xc1b3('0x14')](_0xc1b3('0x33'),'checkHopper',util[_0xc1b3('0x34')](_0x56d51e,{'showHidden':![],'depth':null}));};}var _0x5433d0=function(_0x4016fb,_0x2ce405){var _0x5bfb76=squel['insert']()['into']('cm_hopper')['fromQuery']([_0xc1b3('0x21'),_0xc1b3('0x35'),_0xc1b3('0x36'),_0xc1b3('0x28'),_0x2ce405,_0xc1b3('0x37'),'updatedAt'],squel[_0xc1b3('0x38')]()[_0xc1b3('0x39')]('phone',_0xc1b3('0x21'))[_0xc1b3('0x39')](_0xc1b3('0x3a'),_0xc1b3('0x35'))[_0xc1b3('0x39')]('id',_0xc1b3('0x36'))[_0xc1b3('0x39')](LISTID[_0xc1b3('0x3b')](),_0xc1b3('0x28'))[_0xc1b3('0x39')](_0x4016fb['id']['toString'](),_0x2ce405)[_0xc1b3('0x39')]('NOW()','createdAt')[_0xc1b3('0x39')]('NOW()',_0xc1b3('0x3c'))[_0xc1b3('0x3d')](_0xc1b3('0x3e'))[_0xc1b3('0x3f')]('deletedAt\x20IS\x20NULL')[_0xc1b3('0x3f')](_0xc1b3('0x40'),LISTID[_0xc1b3('0x3b')]())[_0xc1b3('0x3f')](_0xc1b3('0x41'))[_0xc1b3('0x3f')]('phone\x20NOT\x20IN\x20(?)',squel[_0xc1b3('0x38')]()[_0xc1b3('0x39')](_0xc1b3('0x21'))[_0xc1b3('0x3d')](_0xc1b3('0x42'))[_0xc1b3('0x3f')](_0x2ce405+_0xc1b3('0x43'),_0x4016fb['id'][_0xc1b3('0x3b')]())))[_0xc1b3('0x3b')]();return _0x5bfb76;};var _0x353b43=function(_0x5cbe93,_0x58fec3){var _0x4d945e=squel[_0xc1b3('0x44')]()[_0xc1b3('0x45')]('cm_hopper')[_0xc1b3('0x46')]([_0xc1b3('0x21'),_0xc1b3('0x35'),_0xc1b3('0x36'),_0xc1b3('0x28'),_0x58fec3,_0xc1b3('0x37'),_0xc1b3('0x3c')],squel['select']()[_0xc1b3('0x39')](_0xc1b3('0x21'),_0xc1b3('0x21'))['field']('NOW()',_0xc1b3('0x35'))['field']('id',_0xc1b3('0x36'))['field'](LISTID[_0xc1b3('0x3b')](),_0xc1b3('0x28'))[_0xc1b3('0x39')](_0x5cbe93['id'][_0xc1b3('0x3b')](),_0x58fec3)[_0xc1b3('0x39')](_0xc1b3('0x3a'),'createdAt')[_0xc1b3('0x39')](_0xc1b3('0x3a'),_0xc1b3('0x3c'))[_0xc1b3('0x3d')](_0xc1b3('0x3e'))[_0xc1b3('0x3f')](_0xc1b3('0x47'))['where'](_0xc1b3('0x40'),LISTID['toString']())[_0xc1b3('0x3f')]('id\x20IN\x20?',squel[_0xc1b3('0x48')](hopperContacts))['where'](_0xc1b3('0x41'))[_0xc1b3('0x3f')](_0xc1b3('0x49'),squel[_0xc1b3('0x38')]()[_0xc1b3('0x39')]('calleridnum')['from'](_0xc1b3('0x4a'))[_0xc1b3('0x3f')](_0x58fec3+'\x20=\x20?',_0x5cbe93['id']['toString']()))['where'](_0xc1b3('0x49'),squel[_0xc1b3('0x38')]()['field'](_0xc1b3('0x21'))[_0xc1b3('0x3d')](_0xc1b3('0x42'))[_0xc1b3('0x3f')](_0x58fec3+_0xc1b3('0x43'),_0x5cbe93['id']['toString']())))[_0xc1b3('0x3b')]();return _0x4d945e;};function _0x25d1e5(_0x59ee4c,_0x520994){var _0x26ee5f=squel[_0xc1b3('0x44')]()[_0xc1b3('0x45')](_0xc1b3('0x42'))[_0xc1b3('0x46')]([_0xc1b3('0x21'),_0xc1b3('0x35'),_0xc1b3('0x36'),_0xc1b3('0x28'),_0x520994,_0xc1b3('0x37'),'updatedAt'],squel[_0xc1b3('0x38')]()[_0xc1b3('0x39')](_0xc1b3('0x21'),'phone')[_0xc1b3('0x39')]('NOW()','scheduledAt')[_0xc1b3('0x39')]('id',_0xc1b3('0x36'))[_0xc1b3('0x39')](LISTID[_0xc1b3('0x3b')](),_0xc1b3('0x28'))[_0xc1b3('0x39')](_0x59ee4c['id'][_0xc1b3('0x3b')](),_0x520994)[_0xc1b3('0x39')](_0xc1b3('0x3a'),'createdAt')['field'](_0xc1b3('0x3a'),_0xc1b3('0x3c'))[_0xc1b3('0x3d')](_0xc1b3('0x3e'))[_0xc1b3('0x3f')]('deletedAt\x20IS\x20NULL')[_0xc1b3('0x3f')](_0xc1b3('0x40'),LISTID[_0xc1b3('0x3b')]())[_0xc1b3('0x3f')](_0xc1b3('0x4b'),squel[_0xc1b3('0x48')](hopperContacts))[_0xc1b3('0x3f')](_0xc1b3('0x41')))[_0xc1b3('0x3b')]();return _0x26ee5f;}function _0x38c164(_0x9ccb40,_0x433cd5){var _0x17bb5b=squel[_0xc1b3('0x44')]()[_0xc1b3('0x45')](_0xc1b3('0x4c'))['fromQuery'](['phone','ContactId',_0xc1b3('0x28'),_0x433cd5,_0xc1b3('0x37'),'updatedAt'],squel[_0xc1b3('0x38')]()[_0xc1b3('0x39')]('phone',_0xc1b3('0x21'))['field']('id',_0xc1b3('0x36'))[_0xc1b3('0x39')](LISTID[_0xc1b3('0x3b')](),_0xc1b3('0x28'))[_0xc1b3('0x39')](_0x9ccb40['id'][_0xc1b3('0x3b')](),_0x433cd5)[_0xc1b3('0x39')]('NOW()',_0xc1b3('0x37'))[_0xc1b3('0x39')]('NOW()',_0xc1b3('0x3c'))['from'](_0xc1b3('0x3e'))[_0xc1b3('0x3f')]('deletedAt\x20IS\x20NULL')['where'](_0xc1b3('0x40'),LISTID[_0xc1b3('0x3b')]())['where'](_0xc1b3('0x4b'),squel[_0xc1b3('0x48')](hopperContacts))[_0xc1b3('0x3f')](_0xc1b3('0x41')))[_0xc1b3('0x3b')]();return _0x17bb5b;}return db[_0xc1b3('0x4d')][_0xc1b3('0x4e')]({'where':{'type':_0xc1b3('0x4f')},'attributes':['id','dialCheckDuplicateType'],'include':[{'model':db[_0xc1b3('0x50')],'as':_0xc1b3('0x51'),'where':{'id':LISTID}}]})[_0xc1b3('0x2e')](function(_0x5a9b63){var _0x24b3e6=[];if(_0x5a9b63){var _0xdf2fbb;for(var _0x5e831c=0x0,_0xc1c026;_0x5e831c<_0x5a9b63['length'];_0x5e831c+=0x1){_0xc1c026=_0x5a9b63[_0x5e831c][_0xc1b3('0x52')]({'plain':!![]});switch(_0xc1c026[_0xc1b3('0x53')]){case _0xc1b3('0x54'):_0x24b3e6[_0xc1b3('0x55')](db['sequelize']['query'](_0x353b43(_0xc1c026,_0xc1b3('0x56')))['then'](function(){})['catch'](_0x47252a()));break;case _0xc1b3('0x57'):_0x24b3e6[_0xc1b3('0x55')](db[_0xc1b3('0x58')][_0xc1b3('0x59')](_0x5433d0(_0xc1c026,'VoiceQueueId'))[_0xc1b3('0x2e')](function(){})[_0xc1b3('0x30')](_0x47252a()));break;default:_0x24b3e6[_0xc1b3('0x55')](db['sequelize'][_0xc1b3('0x59')](_0x25d1e5(_0xc1c026,_0xc1b3('0x56')))[_0xc1b3('0x2e')](function(){})[_0xc1b3('0x30')](_0x47252a()));}}}return _0x24b3e6;})[_0xc1b3('0x5a')]()['then'](function(){return db[_0xc1b3('0x4d')]['findAll']({'where':{'type':'outbound'},'attributes':['id'],'include':[{'model':db[_0xc1b3('0x50')],'as':'BlackLists','where':{'id':LISTID}}]})[_0xc1b3('0x2e')](function(_0x4b31a9){var _0x4ef3f0=[];if(_0x4b31a9){var _0x2492e4;for(var _0x18167a=0x0,_0x2d6767;_0x18167a<_0x4b31a9[_0xc1b3('0x1b')];_0x18167a+=0x1){_0x2d6767=_0x4b31a9[_0x18167a]['get']({'plain':!![]});_0x4ef3f0[_0xc1b3('0x55')](db['sequelize'][_0xc1b3('0x59')](_0x38c164(_0x2d6767,_0xc1b3('0x56')))[_0xc1b3('0x2e')](function(){})['catch'](_0x47252a()));}}return _0x4ef3f0;})[_0xc1b3('0x5a')]();})[_0xc1b3('0x2e')](function(){return db['Campaign'][_0xc1b3('0x4e')]({'attributes':['id',_0xc1b3('0x53')],'include':[{'model':db['CmList'],'as':_0xc1b3('0x51'),'where':{'id':LISTID}}]})[_0xc1b3('0x2e')](function(_0x50a934){var _0x12cc8a=[];if(_0x50a934){for(var _0x32d5cf=0x0,_0x106165;_0x32d5cf<_0x50a934[_0xc1b3('0x1b')];_0x32d5cf+=0x1){_0x106165=_0x50a934[_0x32d5cf][_0xc1b3('0x52')]({'plain':!![]});switch(_0x106165[_0xc1b3('0x53')]){case'always':_0x12cc8a['push'](db[_0xc1b3('0x58')][_0xc1b3('0x59')](_0x353b43(_0x106165,_0xc1b3('0x5b')))[_0xc1b3('0x2e')](function(){})['catch'](_0x47252a()));break;case _0xc1b3('0x57'):_0x12cc8a[_0xc1b3('0x55')](db[_0xc1b3('0x58')][_0xc1b3('0x59')](_0x5433d0(_0x106165,_0xc1b3('0x5b')))['then'](function(){})['catch'](_0x47252a()));break;default:_0x12cc8a[_0xc1b3('0x55')](db[_0xc1b3('0x58')][_0xc1b3('0x59')](_0x25d1e5(_0x106165,_0xc1b3('0x5b')))[_0xc1b3('0x2e')](function(){})['catch'](_0x47252a()));}}}return _0x12cc8a;})['all']();})[_0xc1b3('0x2e')](function(){return db[_0xc1b3('0x5c')][_0xc1b3('0x4e')]({'attributes':['id'],'include':[{'model':db[_0xc1b3('0x50')],'as':_0xc1b3('0x5d'),'where':{'id':LISTID}}]})[_0xc1b3('0x2e')](function(_0x2ae9f0){var _0x4d5eb5=[];if(_0x2ae9f0){for(var _0x165071=0x0,_0xd777e;_0x165071<_0x2ae9f0[_0xc1b3('0x1b')];_0x165071+=0x1){_0xd777e=_0x2ae9f0[_0x165071]['get']({'plain':!![]});_0x4d5eb5[_0xc1b3('0x55')](db[_0xc1b3('0x58')][_0xc1b3('0x59')](_0x38c164(_0xd777e,_0xc1b3('0x5b')))['then'](function(){})['catch'](_0x47252a()));}}return _0x4d5eb5;})['all']();})['catch'](function(_0x353f78){logger[_0xc1b3('0x14')]('cmContact,\x20%s,\x20%s',_0xc1b3('0x5e'),_0x353f78['message']);});}var processPromises=function(_0x11fe3c){return BPromise[_0xc1b3('0x5a')](promises)[_0xc1b3('0x2e')](function(_0x874179){})[_0xc1b3('0x30')](function(_0x31f4eb){logger[_0xc1b3('0x14')](_0xc1b3('0x5f'),JSON[_0xc1b3('0x32')](_0x31f4eb));})[_0xc1b3('0x60')](function(){socket[_0xc1b3('0x61')](_0xc1b3('0x62')+SOCKET_TIMESTAMP,{'success':success,'errors':errors,'duplicates':duplicates,'rows':rows});promises=[];success=0x0;errors=0x0;duplicates=0x0;rows=[];if(_0x11fe3c){return _0x11fe3c[_0xc1b3('0x63')]();}});};var endCsv=function(){return BPromise[_0xc1b3('0x64')]()[_0xc1b3('0x2e')](function(){if(hopperContacts){return checkHopper();}})[_0xc1b3('0x2e')](function(){socket[_0xc1b3('0x61')](_0xc1b3('0x62')+SOCKET_TIMESTAMP,{'finished':!![],'success':success,'errors':errors,'duplicates':duplicates,'rows':rows});try{fs[_0xc1b3('0x65')](FILEPATH);}catch(_0x537bd6){logger['error'](_0xc1b3('0x66'),JSON[_0xc1b3('0x32')](_0x537bd6));}finally{process['exit'](0x0);}});};process['on']('SIGINT',function(){logger[_0xc1b3('0x67')](_0xc1b3('0x68'));endCsv();});function main(){return BPromise[_0xc1b3('0x64')]()[_0xc1b3('0x2e')](function(){if(DUPLICATES){DUPLICATES=DUPLICATES[_0xc1b3('0x11')](',');return db[_0xc1b3('0x2c')]['findAll']({'where':{'ListId':LISTID},'attributes':DUPLICATES,'raw':!![]});}})[_0xc1b3('0x2e')](function(_0x3057c1){var _0x190347=fs[_0xc1b3('0x69')](FILEPATH,{'highWaterMark':0xf*0x400*0x400});Papa[_0xc1b3('0x6a')](_0x190347,{'header':!![],'skipEmptyLines':!![],'step':function(_0x3a538c,_0x5b2e92){total+=0x1;var _0x2da7a2=total;promises['push'](checkRow(_0x3a538c,_0x3057c1,_0x2da7a2)[_0xc1b3('0x2e')](function(){success+=0x1;})['catch'](function(_0x42c70c){if(_0x42c70c['error']){errors+=0x1;delete _0x42c70c[_0xc1b3('0x14')];}else if(_0x42c70c[_0xc1b3('0x6b')]){duplicates+=0x1;delete _0x42c70c[_0xc1b3('0x6b')];}rows[_0xc1b3('0x55')](_0x42c70c);}));if(total%0xc8===0x0){_0x5b2e92[_0xc1b3('0x6c')]();return processPromises(_0x5b2e92);}},'complete':function(){return processPromises()[_0xc1b3('0x2e')](function(){logger[_0xc1b3('0x67')]('CSV\x20parsed\x20correctly!');endCsv();});},'error':function(_0x5f0e62,_0x1e7792){logger[_0xc1b3('0x67')](_0xc1b3('0x6d'),JSON[_0xc1b3('0x32')](_0x5f0e62));endCsv();}});})[_0xc1b3('0x30')](function(_0x1c54a3){logger[_0xc1b3('0x14')]('Error\x20executing\x20contact\x20csv\x20import:',JSON[_0xc1b3('0x32')](_0x1c54a3));});}main();
\ No newline at end of file
+var _0x1cfb=['../../../api/cmContact/cmContact.socket','register','argv','undefined','Missing\x20filepath\x20parameter!','null','Missing\x20binding\x20parameters!','Missing\x20ListId\x20parameter!','Missing\x20socket_timestamp\x20parameter!','error','contact','index','test','isNil','errors','length','map','message','join','hasOwnProperty','data','firstName','firstName\x20not\x20specified!','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','create','keys','then','pick','catch','Error\x20while\x20creating\x20contact:\x20','stringify','checkHopper','inspect','insert','into','cm_hopper','phone','scheduledAt','ContactId','createdAt','updatedAt','select','field','toString','NOW()','where','deletedAt\x20IS\x20NULL','phone\x20IS\x20NOT\x20NULL','from','fromQuery','cm_contacts','ListId\x20=\x20?','id\x20IN\x20?','str','phone\x20NOT\x20IN\x20(?)','calleridnum','cm_hopper_final','\x20=\x20?','cm_hopper_black','VoiceQueue','findAll','outbound','dialCheckDuplicateType','CmList','Lists','always','push','sequelize','query','VoiceQueueId','all','get','onlyIfOpen','CampaignId','Campaign','BlackLists','cmContact,\x20%s,\x20%s','generalCheckHopper','Error\x20processing\x20rows\x20block:','emit','resume','resolve','unlinkSync','exit','SIGINT','info','CSV\x20import\x20process\x20stopped!','split','pause','CSV\x20parsed\x20correctly!','Error\x20executing\x20contact\x20csv\x20import:','lodash','squel','ioredis','../../../mysqldb','../../../config/environment','../../../config/logger','redis','defaults','localhost'];(function(_0x515784,_0x4c79a3){var _0x1fb287=function(_0x5f226a){while(--_0x5f226a){_0x515784['push'](_0x515784['shift']());}};_0x1fb287(++_0x4c79a3);}(_0x1cfb,0xd7));var _0xb1cf=function(_0x1b68ff,_0x5e68a2){_0x1b68ff=_0x1b68ff-0x0;var _0x4b3b07=_0x1cfb[_0x1b68ff];return _0x4b3b07;};'use strict';var BPromise=require('bluebird');var util=require('util');var _=require(_0xb1cf('0x0'));var fs=require('fs');var squel=require(_0xb1cf('0x1'));var Papa=require('papaparse');var Redis=require(_0xb1cf('0x2'));var db=require(_0xb1cf('0x3'))['db'];var config=require(_0xb1cf('0x4'));var logger=require(_0xb1cf('0x5'))('api');config[_0xb1cf('0x6')]=_[_0xb1cf('0x7')](config[_0xb1cf('0x6')],{'host':_0xb1cf('0x8'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config['redis']));require(_0xb1cf('0x9'))[_0xb1cf('0xa')](socket);try{if(!process['argv'][0x2]||process[_0xb1cf('0xb')][0x2]===_0xb1cf('0xc')||process[_0xb1cf('0xb')][0x2]==='null'){throw new Error(_0xb1cf('0xd'));}var FILEPATH=process[_0xb1cf('0xb')][0x2];if(!process['argv'][0x3]||process[_0xb1cf('0xb')][0x3]===_0xb1cf('0xc')||process[_0xb1cf('0xb')][0x3]===_0xb1cf('0xe')||!process['argv'][0x4]||process[_0xb1cf('0xb')][0x4]==='undefined'||process['argv'][0x4]===_0xb1cf('0xe')){throw new Error(_0xb1cf('0xf'));}var FIELDS=_['zipObject'](process[_0xb1cf('0xb')][0x3]['split'](','),process[_0xb1cf('0xb')][0x4]['split'](','));if(!process['argv'][0x5]||process['argv'][0x5]===_0xb1cf('0xc')||process[_0xb1cf('0xb')][0x5]===_0xb1cf('0xe')){throw new Error(_0xb1cf('0x10'));}var LISTID=process[_0xb1cf('0xb')][0x5];var COMPANYID=process[_0xb1cf('0xb')][0x6]&&process['argv'][0x6]!==_0xb1cf('0xc')&&process[_0xb1cf('0xb')][0x6]!==_0xb1cf('0xe')?process[_0xb1cf('0xb')][0x6]:null;var DUPLICATES=process['argv'][0x7]&&process[_0xb1cf('0xb')][0x7]!==_0xb1cf('0xc')&&process[_0xb1cf('0xb')][0x7]!==_0xb1cf('0xe')?process['argv'][0x7]:null;if(!process[_0xb1cf('0xb')][0x8]||process[_0xb1cf('0xb')][0x8]===_0xb1cf('0xc')||process[_0xb1cf('0xb')][0x8]==='null'){throw new Error(_0xb1cf('0x11'));}var SOCKET_TIMESTAMP=process[_0xb1cf('0xb')][0x8];}catch(_0x7bf429){logger[_0xb1cf('0x12')](_0x7bf429);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(_0x41a8c6,_0x242c27,_0x4b8574,_0x20cc37){var _0x25f3ca={'message':_0x242c27};_0x25f3ca[_0x41a8c6]=!![];if(_0x4b8574){_0x25f3ca[_0xb1cf('0x13')]=_0x4b8574;}if(_0x20cc37){_0x25f3ca[_0xb1cf('0x14')]=_0x20cc37;}return _0x25f3ca;}function isEmail(_0x57fd31){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))*$/[_0xb1cf('0x15')](_0x57fd31);}function checkRow(_0x1b00b5,_0x5dfea9,_0x5191a0){return new BPromise(function(_0x52b5f0,_0x71e33c){if(_[_0xb1cf('0x16')](_0x1b00b5)){return _0x71e33c(handleCheckRowError('error','The\x20row\x20is\x20empty\x20or\x20the\x20number\x20of\x20parameters\x20does\x20not\x20match\x20the\x20columns!',null,_0x5191a0));}if(_0x1b00b5[_0xb1cf('0x17')]&&_0x1b00b5[_0xb1cf('0x17')][_0xb1cf('0x18')]){var _0x5252a4=_[_0xb1cf('0x19')](_0x1b00b5[_0xb1cf('0x17')],_0xb1cf('0x1a'))[_0xb1cf('0x1b')](';');return _0x71e33c(handleCheckRowError('error',_0x5252a4,null,_0x5191a0));}var _0x91a4c3={};for(var _0x5107d4 in FIELDS){if(FIELDS[_0xb1cf('0x1c')](_0x5107d4)&&FIELDS[_0x5107d4]){_0x91a4c3[_0x5107d4]=_0x1b00b5[_0xb1cf('0x1d')][0x0][FIELDS[_0x5107d4]]||_0x1b00b5[_0xb1cf('0x1d')][0x0]['\ufeff'+FIELDS[_0x5107d4]];}}if(!_0x91a4c3[_0xb1cf('0x1e')]){return _0x71e33c(handleCheckRowError('error',_0xb1cf('0x1f'),null,_0x5191a0));}if(!_0x91a4c3['phone']){return _0x71e33c(handleCheckRowError(_0xb1cf('0x12'),_0xb1cf('0x20'),null,_0x5191a0));}if(_0x91a4c3[_0xb1cf('0x21')]){var _0x5a32fe=moment(_0x91a4c3[_0xb1cf('0x21')],_0xb1cf('0x22'));if(!_0x5a32fe[_0xb1cf('0x23')]()){return _0x71e33c(handleCheckRowError('error',_0xb1cf('0x24'),null,_0x5191a0));}}if(_0x91a4c3[_0xb1cf('0x25')]){if(!isEmail(_0x91a4c3[_0xb1cf('0x25')])){return _0x71e33c(handleCheckRowError('error',_0xb1cf('0x26'),null,_0x5191a0));}}_0x91a4c3[_0xb1cf('0x27')]=LISTID;_0x91a4c3[_0xb1cf('0x28')]=COMPANYID||undefined;if(DUPLICATES&&DUPLICATES[_0xb1cf('0x18')]&&_0x5dfea9){var _0x5b5d9={};for(var _0x4f9ec7=0x0,_0x214f7e=DUPLICATES['length'];_0x4f9ec7<_0x214f7e;_0x4f9ec7+=0x1){_0x5b5d9[DUPLICATES[_0x4f9ec7]]=_0x91a4c3[DUPLICATES[_0x4f9ec7]];}var _0x49a7fd=_[_0xb1cf('0x29')](_0x5dfea9,_0x5b5d9);if(_0x49a7fd){return _0x71e33c(handleCheckRowError(_0xb1cf('0x2a'),_0xb1cf('0x2b'),_0x49a7fd,_0x5191a0));}}return db[_0xb1cf('0x2c')][_0xb1cf('0x2d')](_0x91a4c3,{'raw':!![],'hooks':![],'fields':_[_0xb1cf('0x2e')](_0x91a4c3)})[_0xb1cf('0x2f')](function(_0x2a32e2){if(DUPLICATES&&DUPLICATES['length']&&_0x5dfea9){_0x5dfea9['push'](_[_0xb1cf('0x30')](_0x91a4c3,DUPLICATES));}hopperContacts+=(hopperContacts?',':'')+_0x2a32e2['id'];return _0x52b5f0();})[_0xb1cf('0x31')](function(_0x43aa00){return _0x71e33c(handleCheckRowError(_0xb1cf('0x12'),_0xb1cf('0x32')+(_0x43aa00[_0xb1cf('0x1a')]||JSON[_0xb1cf('0x33')](_0x43aa00)),null,_0x5191a0));});});}function checkHopper(){function _0x3053af(){return function(_0x7015bb){logger['error']('cmContact',_0xb1cf('0x34'),util[_0xb1cf('0x35')](_0x7015bb,{'showHidden':![],'depth':null}));};}var _0x451a22=function(_0x503c56,_0x12ee28){var _0x44b08c=squel[_0xb1cf('0x36')]()[_0xb1cf('0x37')](_0xb1cf('0x38'))['fromQuery']([_0xb1cf('0x39'),_0xb1cf('0x3a'),_0xb1cf('0x3b'),_0xb1cf('0x27'),_0x12ee28,_0xb1cf('0x3c'),_0xb1cf('0x3d')],squel[_0xb1cf('0x3e')]()[_0xb1cf('0x3f')](_0xb1cf('0x39'),_0xb1cf('0x39'))[_0xb1cf('0x3f')]('NOW()',_0xb1cf('0x3a'))['field']('id',_0xb1cf('0x3b'))[_0xb1cf('0x3f')](LISTID[_0xb1cf('0x40')](),_0xb1cf('0x27'))[_0xb1cf('0x3f')](_0x503c56['id'][_0xb1cf('0x40')](),_0x12ee28)[_0xb1cf('0x3f')](_0xb1cf('0x41'),'createdAt')[_0xb1cf('0x3f')](_0xb1cf('0x41'),_0xb1cf('0x3d'))['from']('cm_contacts')[_0xb1cf('0x42')](_0xb1cf('0x43'))[_0xb1cf('0x42')]('ListId\x20=\x20?',LISTID[_0xb1cf('0x40')]())[_0xb1cf('0x42')](_0xb1cf('0x44'))[_0xb1cf('0x42')]('phone\x20NOT\x20IN\x20(?)',squel[_0xb1cf('0x3e')]()[_0xb1cf('0x3f')]('phone')[_0xb1cf('0x45')]('cm_hopper')['where'](_0x12ee28+'\x20=\x20?',_0x503c56['id'][_0xb1cf('0x40')]())))[_0xb1cf('0x40')]();return _0x44b08c;};var _0x153108=function(_0x4f77c1,_0x515887){var _0x490684=squel[_0xb1cf('0x36')]()[_0xb1cf('0x37')](_0xb1cf('0x38'))[_0xb1cf('0x46')]([_0xb1cf('0x39'),'scheduledAt',_0xb1cf('0x3b'),_0xb1cf('0x27'),_0x515887,_0xb1cf('0x3c'),_0xb1cf('0x3d')],squel[_0xb1cf('0x3e')]()[_0xb1cf('0x3f')](_0xb1cf('0x39'),_0xb1cf('0x39'))[_0xb1cf('0x3f')](_0xb1cf('0x41'),_0xb1cf('0x3a'))[_0xb1cf('0x3f')]('id',_0xb1cf('0x3b'))[_0xb1cf('0x3f')](LISTID['toString'](),_0xb1cf('0x27'))[_0xb1cf('0x3f')](_0x4f77c1['id'][_0xb1cf('0x40')](),_0x515887)[_0xb1cf('0x3f')](_0xb1cf('0x41'),'createdAt')[_0xb1cf('0x3f')](_0xb1cf('0x41'),_0xb1cf('0x3d'))[_0xb1cf('0x45')](_0xb1cf('0x47'))[_0xb1cf('0x42')](_0xb1cf('0x43'))[_0xb1cf('0x42')](_0xb1cf('0x48'),LISTID[_0xb1cf('0x40')]())[_0xb1cf('0x42')](_0xb1cf('0x49'),squel[_0xb1cf('0x4a')](hopperContacts))[_0xb1cf('0x42')](_0xb1cf('0x44'))[_0xb1cf('0x42')](_0xb1cf('0x4b'),squel['select']()[_0xb1cf('0x3f')](_0xb1cf('0x4c'))['from'](_0xb1cf('0x4d'))[_0xb1cf('0x42')](_0x515887+_0xb1cf('0x4e'),_0x4f77c1['id']['toString']()))[_0xb1cf('0x42')](_0xb1cf('0x4b'),squel['select']()[_0xb1cf('0x3f')](_0xb1cf('0x39'))['from']('cm_hopper')[_0xb1cf('0x42')](_0x515887+_0xb1cf('0x4e'),_0x4f77c1['id'][_0xb1cf('0x40')]())))[_0xb1cf('0x40')]();return _0x490684;};function _0x262b54(_0xe85674,_0x10e526){var _0xdc7d0=squel[_0xb1cf('0x36')]()[_0xb1cf('0x37')](_0xb1cf('0x38'))['fromQuery'](['phone',_0xb1cf('0x3a'),_0xb1cf('0x3b'),'ListId',_0x10e526,'createdAt',_0xb1cf('0x3d')],squel['select']()['field'](_0xb1cf('0x39'),'phone')['field'](_0xb1cf('0x41'),_0xb1cf('0x3a'))[_0xb1cf('0x3f')]('id',_0xb1cf('0x3b'))['field'](LISTID[_0xb1cf('0x40')](),_0xb1cf('0x27'))['field'](_0xe85674['id'][_0xb1cf('0x40')](),_0x10e526)[_0xb1cf('0x3f')](_0xb1cf('0x41'),_0xb1cf('0x3c'))['field'](_0xb1cf('0x41'),_0xb1cf('0x3d'))[_0xb1cf('0x45')](_0xb1cf('0x47'))[_0xb1cf('0x42')](_0xb1cf('0x43'))['where'](_0xb1cf('0x48'),LISTID['toString']())[_0xb1cf('0x42')](_0xb1cf('0x49'),squel[_0xb1cf('0x4a')](hopperContacts))['where'](_0xb1cf('0x44')))[_0xb1cf('0x40')]();return _0xdc7d0;}function _0x2c2362(_0x38351e,_0x59fa5c){var _0x5ed1fc=squel['insert']()[_0xb1cf('0x37')](_0xb1cf('0x4f'))[_0xb1cf('0x46')]([_0xb1cf('0x39'),_0xb1cf('0x3b'),'ListId',_0x59fa5c,_0xb1cf('0x3c'),_0xb1cf('0x3d')],squel['select']()[_0xb1cf('0x3f')](_0xb1cf('0x39'),_0xb1cf('0x39'))[_0xb1cf('0x3f')]('id','ContactId')[_0xb1cf('0x3f')](LISTID[_0xb1cf('0x40')](),_0xb1cf('0x27'))['field'](_0x38351e['id'][_0xb1cf('0x40')](),_0x59fa5c)['field'](_0xb1cf('0x41'),'createdAt')[_0xb1cf('0x3f')]('NOW()',_0xb1cf('0x3d'))[_0xb1cf('0x45')](_0xb1cf('0x47'))[_0xb1cf('0x42')](_0xb1cf('0x43'))['where']('ListId\x20=\x20?',LISTID['toString']())[_0xb1cf('0x42')](_0xb1cf('0x49'),squel[_0xb1cf('0x4a')](hopperContacts))[_0xb1cf('0x42')](_0xb1cf('0x44')))[_0xb1cf('0x40')]();return _0x5ed1fc;}return db[_0xb1cf('0x50')][_0xb1cf('0x51')]({'where':{'type':_0xb1cf('0x52')},'attributes':['id',_0xb1cf('0x53')],'include':[{'model':db[_0xb1cf('0x54')],'as':_0xb1cf('0x55'),'where':{'id':LISTID}}]})[_0xb1cf('0x2f')](function(_0x3af313){var _0x393a47=[];if(_0x3af313){var _0x17a9ee;for(var _0x43a2a=0x0,_0xcdb601;_0x43a2a<_0x3af313[_0xb1cf('0x18')];_0x43a2a+=0x1){_0xcdb601=_0x3af313[_0x43a2a]['get']({'plain':!![]});switch(_0xcdb601[_0xb1cf('0x53')]){case _0xb1cf('0x56'):_0x393a47[_0xb1cf('0x57')](db[_0xb1cf('0x58')][_0xb1cf('0x59')](_0x153108(_0xcdb601,_0xb1cf('0x5a')))[_0xb1cf('0x2f')](function(){})[_0xb1cf('0x31')](_0x3053af()));break;case'onlyIfOpen':_0x393a47[_0xb1cf('0x57')](db[_0xb1cf('0x58')][_0xb1cf('0x59')](_0x451a22(_0xcdb601,'VoiceQueueId'))['then'](function(){})[_0xb1cf('0x31')](_0x3053af()));break;default:_0x393a47[_0xb1cf('0x57')](db[_0xb1cf('0x58')][_0xb1cf('0x59')](_0x262b54(_0xcdb601,_0xb1cf('0x5a')))[_0xb1cf('0x2f')](function(){})[_0xb1cf('0x31')](_0x3053af()));}}}return _0x393a47;})[_0xb1cf('0x5b')]()[_0xb1cf('0x2f')](function(){return db[_0xb1cf('0x50')]['findAll']({'where':{'type':'outbound'},'attributes':['id'],'include':[{'model':db[_0xb1cf('0x54')],'as':'BlackLists','where':{'id':LISTID}}]})[_0xb1cf('0x2f')](function(_0x17b3bf){var _0x5a9d69=[];if(_0x17b3bf){var _0x34c49f;for(var _0x43af28=0x0,_0x4bad47;_0x43af28<_0x17b3bf[_0xb1cf('0x18')];_0x43af28+=0x1){_0x4bad47=_0x17b3bf[_0x43af28][_0xb1cf('0x5c')]({'plain':!![]});_0x5a9d69['push'](db[_0xb1cf('0x58')][_0xb1cf('0x59')](_0x2c2362(_0x4bad47,'VoiceQueueId'))[_0xb1cf('0x2f')](function(){})[_0xb1cf('0x31')](_0x3053af()));}}return _0x5a9d69;})[_0xb1cf('0x5b')]();})[_0xb1cf('0x2f')](function(){return db['Campaign'][_0xb1cf('0x51')]({'attributes':['id',_0xb1cf('0x53')],'include':[{'model':db['CmList'],'as':_0xb1cf('0x55'),'where':{'id':LISTID}}]})['then'](function(_0xb5cdf8){var _0x337136=[];if(_0xb5cdf8){for(var _0x366636=0x0,_0x79ff2;_0x366636<_0xb5cdf8[_0xb1cf('0x18')];_0x366636+=0x1){_0x79ff2=_0xb5cdf8[_0x366636]['get']({'plain':!![]});switch(_0x79ff2['dialCheckDuplicateType']){case'always':_0x337136[_0xb1cf('0x57')](db[_0xb1cf('0x58')][_0xb1cf('0x59')](_0x153108(_0x79ff2,'CampaignId'))[_0xb1cf('0x2f')](function(){})['catch'](_0x3053af()));break;case _0xb1cf('0x5d'):_0x337136[_0xb1cf('0x57')](db[_0xb1cf('0x58')][_0xb1cf('0x59')](_0x451a22(_0x79ff2,_0xb1cf('0x5e')))[_0xb1cf('0x2f')](function(){})['catch'](_0x3053af()));break;default:_0x337136[_0xb1cf('0x57')](db[_0xb1cf('0x58')][_0xb1cf('0x59')](_0x262b54(_0x79ff2,_0xb1cf('0x5e')))[_0xb1cf('0x2f')](function(){})[_0xb1cf('0x31')](_0x3053af()));}}}return _0x337136;})[_0xb1cf('0x5b')]();})[_0xb1cf('0x2f')](function(){return db[_0xb1cf('0x5f')][_0xb1cf('0x51')]({'attributes':['id'],'include':[{'model':db[_0xb1cf('0x54')],'as':_0xb1cf('0x60'),'where':{'id':LISTID}}]})[_0xb1cf('0x2f')](function(_0x462877){var _0x2e162d=[];if(_0x462877){for(var _0x1313c9=0x0,_0xe5f9ff;_0x1313c9<_0x462877[_0xb1cf('0x18')];_0x1313c9+=0x1){_0xe5f9ff=_0x462877[_0x1313c9][_0xb1cf('0x5c')]({'plain':!![]});_0x2e162d[_0xb1cf('0x57')](db[_0xb1cf('0x58')][_0xb1cf('0x59')](_0x2c2362(_0xe5f9ff,_0xb1cf('0x5e')))['then'](function(){})[_0xb1cf('0x31')](_0x3053af()));}}return _0x2e162d;})['all']();})[_0xb1cf('0x31')](function(_0x55b04a){logger[_0xb1cf('0x12')](_0xb1cf('0x61'),_0xb1cf('0x62'),_0x55b04a[_0xb1cf('0x1a')]);});}var processPromises=function(_0x4ca966){return BPromise[_0xb1cf('0x5b')](promises)['then'](function(_0x13e332){})[_0xb1cf('0x31')](function(_0x1ec54a){logger['error'](_0xb1cf('0x63'),JSON[_0xb1cf('0x33')](_0x1ec54a));})['finally'](function(){socket[_0xb1cf('0x64')]('contact:csv_'+SOCKET_TIMESTAMP,{'success':success,'errors':errors,'duplicates':duplicates,'rows':rows});promises=[];success=0x0;errors=0x0;duplicates=0x0;rows=[];if(_0x4ca966){return _0x4ca966[_0xb1cf('0x65')]();}});};var endCsv=function(){return BPromise[_0xb1cf('0x66')]()[_0xb1cf('0x2f')](function(){if(hopperContacts){return checkHopper();}})['then'](function(){socket['emit']('contact:csv_'+SOCKET_TIMESTAMP,{'finished':!![],'success':success,'errors':errors,'duplicates':duplicates,'rows':rows});try{fs[_0xb1cf('0x67')](FILEPATH);}catch(_0x30f4ac){logger[_0xb1cf('0x12')]('Unable\x20to\x20delete\x20temp\x20file:',JSON[_0xb1cf('0x33')](_0x30f4ac));}finally{process[_0xb1cf('0x68')](0x0);}});};process['on'](_0xb1cf('0x69'),function(){logger[_0xb1cf('0x6a')](_0xb1cf('0x6b'));endCsv();});function main(){return BPromise[_0xb1cf('0x66')]()['then'](function(){if(DUPLICATES){DUPLICATES=DUPLICATES[_0xb1cf('0x6c')](',');return db[_0xb1cf('0x2c')][_0xb1cf('0x51')]({'where':{'ListId':LISTID},'attributes':DUPLICATES,'raw':!![]});}})['then'](function(_0x2cb3ec){var _0x28ad26=fs['createReadStream'](FILEPATH,{'highWaterMark':0xf*0x400*0x400});Papa['parse'](_0x28ad26,{'header':!![],'skipEmptyLines':!![],'step':function(_0x532658,_0x254755){total+=0x1;var _0x34621f=total;promises[_0xb1cf('0x57')](checkRow(_0x532658,_0x2cb3ec,_0x34621f)['then'](function(){success+=0x1;})['catch'](function(_0x2b62b4){if(_0x2b62b4[_0xb1cf('0x12')]){errors+=0x1;delete _0x2b62b4[_0xb1cf('0x12')];}else if(_0x2b62b4[_0xb1cf('0x2a')]){duplicates+=0x1;delete _0x2b62b4[_0xb1cf('0x2a')];}rows[_0xb1cf('0x57')](_0x2b62b4);}));if(total%0xc8===0x0){_0x254755[_0xb1cf('0x6d')]();return processPromises(_0x254755);}},'complete':function(){return processPromises()[_0xb1cf('0x2f')](function(){logger[_0xb1cf('0x6a')](_0xb1cf('0x6e'));endCsv();});},'error':function(_0x1a3601,_0x5b2e17){logger[_0xb1cf('0x6a')]('CSV\x20parse\x20error',JSON[_0xb1cf('0x33')](_0x1a3601));endCsv();}});})['catch'](function(_0x25b063){logger[_0xb1cf('0x12')](_0xb1cf('0x6f'),JSON[_0xb1cf('0x33')](_0x25b063));});}main();
\ No newline at end of file