Built motion from commit eddce310.|2.6.12
[motion2.git] / server / components / import / cm / csv.js
index aa96ec4..8099802 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-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
+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