Built motion from commit 1fa89557.|2.6.10
[motion2.git] / server / components / import / cm / csv.js
index 706f52b..1284b85 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xe9d3=['stringify','emit','resume','resolve','contact:csv_','exit','info','CSV\x20import\x20process\x20stopped!','CmContact','createReadStream','parse','pause','CSV\x20parsed\x20correctly!','CSV\x20parse\x20error','Error\x20executing\x20contact\x20csv\x20import:','bluebird','util','lodash','squel','ioredis','api','defaults','redis','localhost','socket.io-emitter','../../../api/cmContact/cmContact.socket','register','argv','undefined','null','Missing\x20filepath\x20parameter!','Missing\x20binding\x20parameters!','zipObject','split','Missing\x20ListId\x20parameter!','Missing\x20socket_timestamp\x20parameter!','error','test','isNil','The\x20row\x20is\x20empty\x20or\x20the\x20number\x20of\x20parameters\x20does\x20not\x20match\x20the\x20columns!','errors','length','map','join','hasOwnProperty','data','firstName','firstName\x20not\x20specified!','phone','phone\x20not\x20specified!','birthDate','YYYY-MM-DD','isValid','birthDate\x20format\x20is\x20invalid,\x20YYYY-MM-DD\x20format\x20is\x20supported!','email','email\x20format\x20is\x20not\x20valid!','ListId','CompanyId','find','duplicate','Duplicate\x20Contact','create','keys','push','pick','catch','Error\x20while\x20creating\x20contact:\x20','cmContact','checkHopper','inspect','insert','cm_hopper','ContactId','createdAt','select','field','scheduledAt','toString','NOW()','updatedAt','cm_contacts','where','phone\x20IS\x20NOT\x20NULL','phone\x20NOT\x20IN\x20(?)','from','into','fromQuery','deletedAt\x20IS\x20NULL','ListId\x20=\x20?','id\x20IN\x20?','str','calleridnum','\x20=\x20?','cm_hopper_black','VoiceQueue','findAll','dialCheckDuplicateType','then','get','always','sequelize','query','VoiceQueueId','onlyIfOpen','outbound','CmList','all','Campaign','CampaignId','BlackLists','generalCheckHopper','message','Error\x20processing\x20rows\x20block:'];(function(_0x284a61,_0x231686){var _0x220e3c=function(_0x104496){while(--_0x104496){_0x284a61['push'](_0x284a61['shift']());}};_0x220e3c(++_0x231686);}(_0xe9d3,0x162));var _0x3e9d=function(_0x2676e1,_0x8f5f28){_0x2676e1=_0x2676e1-0x0;var _0x4565f4=_0xe9d3[_0x2676e1];return _0x4565f4;};'use strict';var BPromise=require(_0x3e9d('0x0'));var util=require(_0x3e9d('0x1'));var _=require(_0x3e9d('0x2'));var fs=require('fs');var squel=require(_0x3e9d('0x3'));var Papa=require('papaparse');var Redis=require(_0x3e9d('0x4'));var db=require('../../../mysqldb')['db'];var config=require('../../../config/environment');var logger=require('../../../config/logger')(_0x3e9d('0x5'));config['redis']=_[_0x3e9d('0x6')](config[_0x3e9d('0x7')],{'host':_0x3e9d('0x8'),'port':0x18eb});var socket=require(_0x3e9d('0x9'))(new Redis(config[_0x3e9d('0x7')]));require(_0x3e9d('0xa'))[_0x3e9d('0xb')](socket);try{if(!process[_0x3e9d('0xc')][0x2]||process[_0x3e9d('0xc')][0x2]===_0x3e9d('0xd')||process[_0x3e9d('0xc')][0x2]===_0x3e9d('0xe')){throw new Error(_0x3e9d('0xf'));}var FILEPATH=process['argv'][0x2];if(!process[_0x3e9d('0xc')][0x3]||process[_0x3e9d('0xc')][0x3]===_0x3e9d('0xd')||process['argv'][0x3]===_0x3e9d('0xe')||!process['argv'][0x4]||process['argv'][0x4]===_0x3e9d('0xd')||process[_0x3e9d('0xc')][0x4]===_0x3e9d('0xe')){throw new Error(_0x3e9d('0x10'));}var FIELDS=_[_0x3e9d('0x11')](process[_0x3e9d('0xc')][0x3][_0x3e9d('0x12')](','),process[_0x3e9d('0xc')][0x4][_0x3e9d('0x12')](','));if(!process[_0x3e9d('0xc')][0x5]||process[_0x3e9d('0xc')][0x5]===_0x3e9d('0xd')||process[_0x3e9d('0xc')][0x5]===_0x3e9d('0xe')){throw new Error(_0x3e9d('0x13'));}var LISTID=process[_0x3e9d('0xc')][0x5];var COMPANYID=process['argv'][0x6]&&process[_0x3e9d('0xc')][0x6]!==_0x3e9d('0xd')&&process[_0x3e9d('0xc')][0x6]!==_0x3e9d('0xe')?process['argv'][0x6]:null;var DUPLICATES=process[_0x3e9d('0xc')][0x7]&&process[_0x3e9d('0xc')][0x7]!==_0x3e9d('0xd')&&process['argv'][0x7]!==_0x3e9d('0xe')?process[_0x3e9d('0xc')][0x7]:null;if(!process[_0x3e9d('0xc')][0x8]||process['argv'][0x8]===_0x3e9d('0xd')||process[_0x3e9d('0xc')][0x8]===_0x3e9d('0xe')){throw new Error(_0x3e9d('0x14'));}var SOCKET_TIMESTAMP=process['argv'][0x8];}catch(_0x3b909f){logger[_0x3e9d('0x15')](_0x3b909f);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(_0x560954,_0x58f542,_0x11cba1,_0x146260){var _0x1b5658={'message':_0x58f542};_0x1b5658[_0x560954]=!![];if(_0x11cba1){_0x1b5658['contact']=_0x11cba1;}if(_0x146260){_0x1b5658['index']=_0x146260;}return _0x1b5658;}function isEmail(_0xa2e3c0){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))*$/[_0x3e9d('0x16')](_0xa2e3c0);}function checkRow(_0x156ad4,_0x287c36,_0x18c259){return new BPromise(function(_0x131f36,_0x1d9a77){if(_[_0x3e9d('0x17')](_0x156ad4)){return _0x1d9a77(handleCheckRowError('error',_0x3e9d('0x18'),null,_0x18c259));}if(_0x156ad4['errors']&&_0x156ad4[_0x3e9d('0x19')][_0x3e9d('0x1a')]){var _0x6624fa=_[_0x3e9d('0x1b')](_0x156ad4[_0x3e9d('0x19')],'message')[_0x3e9d('0x1c')](';');return _0x1d9a77(handleCheckRowError(_0x3e9d('0x15'),_0x6624fa,null,_0x18c259));}var _0x19b9ad={};for(var _0x4cb59d in FIELDS){if(FIELDS[_0x3e9d('0x1d')](_0x4cb59d)&&FIELDS[_0x4cb59d]){_0x19b9ad[_0x4cb59d]=_0x156ad4[_0x3e9d('0x1e')][0x0][FIELDS[_0x4cb59d]]||_0x156ad4[_0x3e9d('0x1e')][0x0]['\ufeff'+FIELDS[_0x4cb59d]];}}if(!_0x19b9ad[_0x3e9d('0x1f')]){return _0x1d9a77(handleCheckRowError(_0x3e9d('0x15'),_0x3e9d('0x20'),null,_0x18c259));}if(!_0x19b9ad[_0x3e9d('0x21')]){return _0x1d9a77(handleCheckRowError(_0x3e9d('0x15'),_0x3e9d('0x22'),null,_0x18c259));}if(_0x19b9ad['birthDate']){var _0x59e6f9=moment(_0x19b9ad[_0x3e9d('0x23')],_0x3e9d('0x24'));if(!_0x59e6f9[_0x3e9d('0x25')]()){return _0x1d9a77(handleCheckRowError('error',_0x3e9d('0x26'),null,_0x18c259));}}if(_0x19b9ad[_0x3e9d('0x27')]){if(!isEmail(_0x19b9ad['email'])){return _0x1d9a77(handleCheckRowError(_0x3e9d('0x15'),_0x3e9d('0x28'),null,_0x18c259));}}_0x19b9ad[_0x3e9d('0x29')]=LISTID;_0x19b9ad[_0x3e9d('0x2a')]=COMPANYID||undefined;if(DUPLICATES&&DUPLICATES[_0x3e9d('0x1a')]&&_0x287c36){var _0x5364f0={};for(var _0x2bbd50=0x0,_0x5e7f79=DUPLICATES[_0x3e9d('0x1a')];_0x2bbd50<_0x5e7f79;_0x2bbd50+=0x1){_0x5364f0[DUPLICATES[_0x2bbd50]]=_0x19b9ad[DUPLICATES[_0x2bbd50]];}var _0x3dd773=_[_0x3e9d('0x2b')](_0x287c36,_0x5364f0);if(_0x3dd773){return _0x1d9a77(handleCheckRowError(_0x3e9d('0x2c'),_0x3e9d('0x2d'),_0x3dd773,_0x18c259));}}return db['CmContact'][_0x3e9d('0x2e')](_0x19b9ad,{'raw':!![],'hooks':![],'fields':_[_0x3e9d('0x2f')](_0x19b9ad)})['then'](function(_0x147d34){if(DUPLICATES&&DUPLICATES[_0x3e9d('0x1a')]&&_0x287c36){_0x287c36[_0x3e9d('0x30')](_[_0x3e9d('0x31')](_0x19b9ad,DUPLICATES));}hopperContacts+=(hopperContacts?',':'')+_0x147d34['id'];return _0x131f36();})[_0x3e9d('0x32')](function(_0x1f2c2a){return _0x1d9a77(handleCheckRowError(_0x3e9d('0x15'),_0x3e9d('0x33')+(_0x1f2c2a['message']||JSON['stringify'](_0x1f2c2a)),null,_0x18c259));});});}function checkHopper(){function _0x4a665a(){return function(_0x5a9b59){logger[_0x3e9d('0x15')](_0x3e9d('0x34'),_0x3e9d('0x35'),util[_0x3e9d('0x36')](_0x5a9b59,{'showHidden':![],'depth':null}));};}var _0x313e36=function(_0x1e8711,_0x410c49){var _0x122c8c=squel[_0x3e9d('0x37')]()['into'](_0x3e9d('0x38'))['fromQuery']([_0x3e9d('0x21'),'scheduledAt',_0x3e9d('0x39'),_0x3e9d('0x29'),_0x410c49,_0x3e9d('0x3a'),'updatedAt'],squel[_0x3e9d('0x3b')]()[_0x3e9d('0x3c')](_0x3e9d('0x21'),_0x3e9d('0x21'))['field']('NOW()',_0x3e9d('0x3d'))[_0x3e9d('0x3c')]('id',_0x3e9d('0x39'))[_0x3e9d('0x3c')](LISTID['toString'](),_0x3e9d('0x29'))[_0x3e9d('0x3c')](_0x1e8711['id'][_0x3e9d('0x3e')](),_0x410c49)[_0x3e9d('0x3c')]('NOW()',_0x3e9d('0x3a'))['field'](_0x3e9d('0x3f'),_0x3e9d('0x40'))['from'](_0x3e9d('0x41'))[_0x3e9d('0x42')]('deletedAt\x20IS\x20NULL')[_0x3e9d('0x42')]('ListId\x20=\x20?',LISTID[_0x3e9d('0x3e')]())[_0x3e9d('0x42')](_0x3e9d('0x43'))[_0x3e9d('0x42')](_0x3e9d('0x44'),squel[_0x3e9d('0x3b')]()[_0x3e9d('0x3c')](_0x3e9d('0x21'))[_0x3e9d('0x45')]('cm_hopper')[_0x3e9d('0x42')](_0x410c49+'\x20=\x20?',_0x1e8711['id'][_0x3e9d('0x3e')]())))[_0x3e9d('0x3e')]();return _0x122c8c;};var _0x39633c=function(_0xf0d858,_0x232e09){var _0xea2a98=squel[_0x3e9d('0x37')]()[_0x3e9d('0x46')](_0x3e9d('0x38'))[_0x3e9d('0x47')]([_0x3e9d('0x21'),'scheduledAt',_0x3e9d('0x39'),_0x3e9d('0x29'),_0x232e09,_0x3e9d('0x3a'),_0x3e9d('0x40')],squel[_0x3e9d('0x3b')]()[_0x3e9d('0x3c')](_0x3e9d('0x21'),'phone')[_0x3e9d('0x3c')]('NOW()',_0x3e9d('0x3d'))[_0x3e9d('0x3c')]('id',_0x3e9d('0x39'))[_0x3e9d('0x3c')](LISTID['toString'](),_0x3e9d('0x29'))[_0x3e9d('0x3c')](_0xf0d858['id'][_0x3e9d('0x3e')](),_0x232e09)['field']('NOW()',_0x3e9d('0x3a'))[_0x3e9d('0x3c')]('NOW()','updatedAt')[_0x3e9d('0x45')]('cm_contacts')['where'](_0x3e9d('0x48'))[_0x3e9d('0x42')](_0x3e9d('0x49'),LISTID['toString']())['where'](_0x3e9d('0x4a'),squel[_0x3e9d('0x4b')](hopperContacts))[_0x3e9d('0x42')](_0x3e9d('0x43'))[_0x3e9d('0x42')](_0x3e9d('0x44'),squel[_0x3e9d('0x3b')]()[_0x3e9d('0x3c')](_0x3e9d('0x4c'))[_0x3e9d('0x45')]('cm_hopper_final')['where'](_0x232e09+_0x3e9d('0x4d'),_0xf0d858['id'][_0x3e9d('0x3e')]()))['where'](_0x3e9d('0x44'),squel[_0x3e9d('0x3b')]()['field']('phone')[_0x3e9d('0x45')]('cm_hopper')['where'](_0x232e09+_0x3e9d('0x4d'),_0xf0d858['id'][_0x3e9d('0x3e')]())))['toString']();return _0xea2a98;};function _0x5118a0(_0xf50d16,_0x11580b){var _0x43c7da=squel[_0x3e9d('0x37')]()[_0x3e9d('0x46')](_0x3e9d('0x38'))[_0x3e9d('0x47')]([_0x3e9d('0x21'),_0x3e9d('0x3d'),'ContactId',_0x3e9d('0x29'),_0x11580b,'createdAt','updatedAt'],squel['select']()[_0x3e9d('0x3c')]('phone',_0x3e9d('0x21'))[_0x3e9d('0x3c')](_0x3e9d('0x3f'),_0x3e9d('0x3d'))[_0x3e9d('0x3c')]('id',_0x3e9d('0x39'))['field'](LISTID[_0x3e9d('0x3e')](),_0x3e9d('0x29'))[_0x3e9d('0x3c')](_0xf50d16['id']['toString'](),_0x11580b)[_0x3e9d('0x3c')](_0x3e9d('0x3f'),_0x3e9d('0x3a'))[_0x3e9d('0x3c')](_0x3e9d('0x3f'),'updatedAt')[_0x3e9d('0x45')](_0x3e9d('0x41'))[_0x3e9d('0x42')]('deletedAt\x20IS\x20NULL')['where']('ListId\x20=\x20?',LISTID['toString']())[_0x3e9d('0x42')](_0x3e9d('0x4a'),squel[_0x3e9d('0x4b')](hopperContacts))[_0x3e9d('0x42')](_0x3e9d('0x43')))['toString']();return _0x43c7da;}function _0x47eb2d(_0x46de6d,_0x423cb7){var _0x5b6d16=squel[_0x3e9d('0x37')]()['into'](_0x3e9d('0x4e'))['fromQuery']([_0x3e9d('0x21'),_0x3e9d('0x39'),_0x3e9d('0x29'),_0x423cb7,_0x3e9d('0x3a'),_0x3e9d('0x40')],squel[_0x3e9d('0x3b')]()[_0x3e9d('0x3c')]('phone',_0x3e9d('0x21'))[_0x3e9d('0x3c')]('id',_0x3e9d('0x39'))['field'](LISTID[_0x3e9d('0x3e')](),_0x3e9d('0x29'))[_0x3e9d('0x3c')](_0x46de6d['id'][_0x3e9d('0x3e')](),_0x423cb7)[_0x3e9d('0x3c')](_0x3e9d('0x3f'),'createdAt')[_0x3e9d('0x3c')](_0x3e9d('0x3f'),_0x3e9d('0x40'))[_0x3e9d('0x45')](_0x3e9d('0x41'))[_0x3e9d('0x42')]('deletedAt\x20IS\x20NULL')[_0x3e9d('0x42')](_0x3e9d('0x49'),LISTID['toString']())[_0x3e9d('0x42')]('id\x20IN\x20?',squel['str'](hopperContacts))[_0x3e9d('0x42')](_0x3e9d('0x43')))[_0x3e9d('0x3e')]();return _0x5b6d16;}return db[_0x3e9d('0x4f')][_0x3e9d('0x50')]({'where':{'type':'outbound'},'attributes':['id',_0x3e9d('0x51')],'include':[{'model':db['CmList'],'as':'Lists','where':{'id':LISTID}}]})[_0x3e9d('0x52')](function(_0x390ae4){var _0x1edf5c=[];if(_0x390ae4){var _0x42eb22;for(var _0x55d4eb=0x0,_0x18e09e;_0x55d4eb<_0x390ae4[_0x3e9d('0x1a')];_0x55d4eb+=0x1){_0x18e09e=_0x390ae4[_0x55d4eb][_0x3e9d('0x53')]({'plain':!![]});switch(_0x18e09e[_0x3e9d('0x51')]){case _0x3e9d('0x54'):_0x1edf5c[_0x3e9d('0x30')](db[_0x3e9d('0x55')][_0x3e9d('0x56')](_0x39633c(_0x18e09e,_0x3e9d('0x57')))[_0x3e9d('0x52')](function(){})[_0x3e9d('0x32')](_0x4a665a()));break;case _0x3e9d('0x58'):_0x1edf5c[_0x3e9d('0x30')](db[_0x3e9d('0x55')][_0x3e9d('0x56')](_0x313e36(_0x18e09e,_0x3e9d('0x57')))['then'](function(){})[_0x3e9d('0x32')](_0x4a665a()));break;default:_0x1edf5c[_0x3e9d('0x30')](db[_0x3e9d('0x55')][_0x3e9d('0x56')](_0x5118a0(_0x18e09e,_0x3e9d('0x57')))['then'](function(){})[_0x3e9d('0x32')](_0x4a665a()));}}}return _0x1edf5c;})['all']()[_0x3e9d('0x52')](function(){return db[_0x3e9d('0x4f')]['findAll']({'where':{'type':_0x3e9d('0x59')},'attributes':['id'],'include':[{'model':db[_0x3e9d('0x5a')],'as':'BlackLists','where':{'id':LISTID}}]})[_0x3e9d('0x52')](function(_0x3513fb){var _0x33c137=[];if(_0x3513fb){var _0x30abdf;for(var _0x5916f1=0x0,_0x373574;_0x5916f1<_0x3513fb[_0x3e9d('0x1a')];_0x5916f1+=0x1){_0x373574=_0x3513fb[_0x5916f1]['get']({'plain':!![]});_0x33c137[_0x3e9d('0x30')](db['sequelize'][_0x3e9d('0x56')](_0x47eb2d(_0x373574,_0x3e9d('0x57')))[_0x3e9d('0x52')](function(){})[_0x3e9d('0x32')](_0x4a665a()));}}return _0x33c137;})[_0x3e9d('0x5b')]();})[_0x3e9d('0x52')](function(){return db[_0x3e9d('0x5c')][_0x3e9d('0x50')]({'attributes':['id',_0x3e9d('0x51')],'include':[{'model':db[_0x3e9d('0x5a')],'as':'Lists','where':{'id':LISTID}}]})['then'](function(_0x34c8b4){var _0x176cca=[];if(_0x34c8b4){for(var _0x1199cf=0x0,_0x5bbe9d;_0x1199cf<_0x34c8b4[_0x3e9d('0x1a')];_0x1199cf+=0x1){_0x5bbe9d=_0x34c8b4[_0x1199cf][_0x3e9d('0x53')]({'plain':!![]});switch(_0x5bbe9d[_0x3e9d('0x51')]){case'always':_0x176cca[_0x3e9d('0x30')](db['sequelize'][_0x3e9d('0x56')](_0x39633c(_0x5bbe9d,_0x3e9d('0x5d')))[_0x3e9d('0x52')](function(){})['catch'](_0x4a665a()));break;case _0x3e9d('0x58'):_0x176cca[_0x3e9d('0x30')](db[_0x3e9d('0x55')][_0x3e9d('0x56')](_0x313e36(_0x5bbe9d,_0x3e9d('0x5d')))[_0x3e9d('0x52')](function(){})[_0x3e9d('0x32')](_0x4a665a()));break;default:_0x176cca[_0x3e9d('0x30')](db[_0x3e9d('0x55')][_0x3e9d('0x56')](_0x5118a0(_0x5bbe9d,'CampaignId'))[_0x3e9d('0x52')](function(){})[_0x3e9d('0x32')](_0x4a665a()));}}}return _0x176cca;})[_0x3e9d('0x5b')]();})['then'](function(){return db[_0x3e9d('0x5c')][_0x3e9d('0x50')]({'attributes':['id'],'include':[{'model':db[_0x3e9d('0x5a')],'as':_0x3e9d('0x5e'),'where':{'id':LISTID}}]})['then'](function(_0x893354){var _0x4de707=[];if(_0x893354){for(var _0x35cf86=0x0,_0x5599bd;_0x35cf86<_0x893354['length'];_0x35cf86+=0x1){_0x5599bd=_0x893354[_0x35cf86]['get']({'plain':!![]});_0x4de707[_0x3e9d('0x30')](db['sequelize'][_0x3e9d('0x56')](_0x47eb2d(_0x5599bd,_0x3e9d('0x5d')))[_0x3e9d('0x52')](function(){})[_0x3e9d('0x32')](_0x4a665a()));}}return _0x4de707;})['all']();})['catch'](function(_0x50af45){logger[_0x3e9d('0x15')]('cmContact,\x20%s,\x20%s',_0x3e9d('0x5f'),_0x50af45[_0x3e9d('0x60')]);});}var processPromises=function(_0x420dd2){return BPromise['all'](promises)[_0x3e9d('0x52')](function(_0x4231b4){})[_0x3e9d('0x32')](function(_0x5f3774){logger[_0x3e9d('0x15')](_0x3e9d('0x61'),JSON[_0x3e9d('0x62')](_0x5f3774));})['finally'](function(){socket[_0x3e9d('0x63')]('contact:csv_'+SOCKET_TIMESTAMP,{'success':success,'errors':errors,'duplicates':duplicates,'rows':rows});promises=[];success=0x0;errors=0x0;duplicates=0x0;rows=[];if(_0x420dd2){return _0x420dd2[_0x3e9d('0x64')]();}});};var endCsv=function(){return BPromise[_0x3e9d('0x65')]()[_0x3e9d('0x52')](function(){if(hopperContacts){return checkHopper();}})[_0x3e9d('0x52')](function(){socket[_0x3e9d('0x63')](_0x3e9d('0x66')+SOCKET_TIMESTAMP,{'finished':!![],'success':success,'errors':errors,'duplicates':duplicates,'rows':rows});try{fs['unlinkSync'](FILEPATH);}catch(_0x38a23d){logger[_0x3e9d('0x15')]('Unable\x20to\x20delete\x20temp\x20file:',JSON['stringify'](_0x38a23d));}finally{process[_0x3e9d('0x67')](0x0);}});};process['on']('SIGINT',function(){logger[_0x3e9d('0x68')](_0x3e9d('0x69'));endCsv();});function main(){return BPromise['resolve']()[_0x3e9d('0x52')](function(){if(DUPLICATES){DUPLICATES=DUPLICATES[_0x3e9d('0x12')](',');return db[_0x3e9d('0x6a')][_0x3e9d('0x50')]({'where':{'ListId':LISTID},'attributes':DUPLICATES,'raw':!![]});}})['then'](function(_0x4edb1e){var _0x16e74a=fs[_0x3e9d('0x6b')](FILEPATH,{'highWaterMark':0xf*0x400*0x400});Papa[_0x3e9d('0x6c')](_0x16e74a,{'header':!![],'skipEmptyLines':!![],'step':function(_0x1e24fa,_0x8353e9){total+=0x1;var _0x197683=total;promises[_0x3e9d('0x30')](checkRow(_0x1e24fa,_0x4edb1e,_0x197683)[_0x3e9d('0x52')](function(){success+=0x1;})[_0x3e9d('0x32')](function(_0x522025){if(_0x522025[_0x3e9d('0x15')]){errors+=0x1;delete _0x522025[_0x3e9d('0x15')];}else if(_0x522025[_0x3e9d('0x2c')]){duplicates+=0x1;delete _0x522025[_0x3e9d('0x2c')];}rows[_0x3e9d('0x30')](_0x522025);}));if(total%0xc8===0x0){_0x8353e9[_0x3e9d('0x6d')]();return processPromises(_0x8353e9);}},'complete':function(){return processPromises()[_0x3e9d('0x52')](function(){logger[_0x3e9d('0x68')](_0x3e9d('0x6e'));endCsv();});},'error':function(_0x244dd1,_0x40fbb2){logger[_0x3e9d('0x68')](_0x3e9d('0x6f'),JSON[_0x3e9d('0x62')](_0x244dd1));endCsv();}});})[_0x3e9d('0x32')](function(_0x345528){logger[_0x3e9d('0x15')](_0x3e9d('0x70'),JSON[_0x3e9d('0x62')](_0x345528));});}main();
\ No newline at end of file
+var _0x0fc5=['query','VoiceQueueId','sequelize','BlackLists','get','Campaign','dialCheckDuplicateType','Lists','CampaignId','onlyIfOpen','all','cmContact,\x20%s,\x20%s','generalCheckHopper','Error\x20processing\x20rows\x20block:','finally','emit','contact:csv_','resume','unlinkSync','Unable\x20to\x20delete\x20temp\x20file:','SIGINT','info','CSV\x20import\x20process\x20stopped!','resolve','CmContact','createReadStream','parse','pause','CSV\x20parsed\x20correctly!','CSV\x20parse\x20error','bluebird','util','lodash','squel','../../../mysqldb','../../../config/environment','../../../config/logger','api','redis','register','argv','undefined','null','Missing\x20filepath\x20parameter!','Missing\x20binding\x20parameters!','split','Missing\x20ListId\x20parameter!','Missing\x20socket_timestamp\x20parameter!','error','contact','index','test','isNil','The\x20row\x20is\x20empty\x20or\x20the\x20number\x20of\x20parameters\x20does\x20not\x20match\x20the\x20columns!','errors','length','map','message','join','data','firstName','firstName\x20not\x20specified!','phone','phone\x20not\x20specified!','birthDate','isValid','birthDate\x20format\x20is\x20invalid,\x20YYYY-MM-DD\x20format\x20is\x20supported!','email','email\x20format\x20is\x20not\x20valid!','ListId','CompanyId','find','duplicate','Duplicate\x20Contact','create','keys','then','push','pick','catch','Error\x20while\x20creating\x20contact:\x20','stringify','cmContact','inspect','fromQuery','createdAt','updatedAt','select','field','NOW()','scheduledAt','ContactId','from','cm_contacts','where','deletedAt\x20IS\x20NULL','phone\x20IS\x20NOT\x20NULL','cm_hopper','\x20=\x20?','toString','insert','into','ListId\x20=\x20?','id\x20IN\x20?','str','phone\x20NOT\x20IN\x20(?)','calleridnum','cm_hopper_black','VoiceQueue','findAll','outbound','CmList','always'];(function(_0x240362,_0x156794){var _0x26de18=function(_0x4a4431){while(--_0x4a4431){_0x240362['push'](_0x240362['shift']());}};_0x26de18(++_0x156794);}(_0x0fc5,0x8f));var _0x50fc=function(_0x1e9385,_0xa80c81){_0x1e9385=_0x1e9385-0x0;var _0x274e88=_0x0fc5[_0x1e9385];return _0x274e88;};'use strict';var BPromise=require(_0x50fc('0x0'));var util=require(_0x50fc('0x1'));var _=require(_0x50fc('0x2'));var fs=require('fs');var squel=require(_0x50fc('0x3'));var Papa=require('papaparse');var Redis=require('ioredis');var db=require(_0x50fc('0x4'))['db'];var config=require(_0x50fc('0x5'));var logger=require(_0x50fc('0x6'))(_0x50fc('0x7'));config[_0x50fc('0x8')]=_['defaults'](config[_0x50fc('0x8')],{'host':'localhost','port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config['redis']));require('../../../api/cmContact/cmContact.socket')[_0x50fc('0x9')](socket);try{if(!process['argv'][0x2]||process[_0x50fc('0xa')][0x2]===_0x50fc('0xb')||process[_0x50fc('0xa')][0x2]===_0x50fc('0xc')){throw new Error(_0x50fc('0xd'));}var FILEPATH=process[_0x50fc('0xa')][0x2];if(!process[_0x50fc('0xa')][0x3]||process['argv'][0x3]===_0x50fc('0xb')||process[_0x50fc('0xa')][0x3]===_0x50fc('0xc')||!process[_0x50fc('0xa')][0x4]||process[_0x50fc('0xa')][0x4]===_0x50fc('0xb')||process[_0x50fc('0xa')][0x4]===_0x50fc('0xc')){throw new Error(_0x50fc('0xe'));}var FIELDS=_['zipObject'](process[_0x50fc('0xa')][0x3][_0x50fc('0xf')](','),process[_0x50fc('0xa')][0x4][_0x50fc('0xf')](','));if(!process[_0x50fc('0xa')][0x5]||process[_0x50fc('0xa')][0x5]===_0x50fc('0xb')||process['argv'][0x5]==='null'){throw new Error(_0x50fc('0x10'));}var LISTID=process[_0x50fc('0xa')][0x5];var COMPANYID=process['argv'][0x6]&&process[_0x50fc('0xa')][0x6]!==_0x50fc('0xb')&&process[_0x50fc('0xa')][0x6]!=='null'?process[_0x50fc('0xa')][0x6]:null;var DUPLICATES=process[_0x50fc('0xa')][0x7]&&process[_0x50fc('0xa')][0x7]!==_0x50fc('0xb')&&process[_0x50fc('0xa')][0x7]!=='null'?process[_0x50fc('0xa')][0x7]:null;if(!process['argv'][0x8]||process[_0x50fc('0xa')][0x8]==='undefined'||process['argv'][0x8]==='null'){throw new Error(_0x50fc('0x11'));}var SOCKET_TIMESTAMP=process[_0x50fc('0xa')][0x8];}catch(_0x470acf){logger[_0x50fc('0x12')](_0x470acf);endCsv();}var total=0x0;var pTotal=0x0;var success=0x0;var errors=0x0;var duplicates=0x0;var rows=[];var hopperContacts='';var promises=[];var index=0x0;var alreadyInvalid=![];function handleCheckRowError(_0x5241b4,_0x2f6191,_0x43efae,_0x25393f){var _0x1a1790={'message':_0x2f6191};_0x1a1790[_0x5241b4]=!![];if(_0x43efae){_0x1a1790[_0x50fc('0x13')]=_0x43efae;}if(_0x25393f){_0x1a1790[_0x50fc('0x14')]=_0x25393f;}return _0x1a1790;}function isEmail(_0x36b585){return/^([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x22([^\x0d\x22\x5c\x80-\xff]|\x5c[\x00-\x7f])*\x22)(\x2e([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x22([^\x0d\x22\x5c\x80-\xff]|\x5c[\x00-\x7f])*\x22))*\x40([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x5b([^\x0d\x5b-\x5d\x80-\xff]|\x5c[\x00-\x7f])*\x5d)(\x2e([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x5b([^\x0d\x5b-\x5d\x80-\xff]|\x5c[\x00-\x7f])*\x5d))*$/[_0x50fc('0x15')](_0x36b585);}function checkRow(_0x3e75a7,_0x6b5e8b,_0x197cd4){return new BPromise(function(_0x360b71,_0x579ca5){if(_[_0x50fc('0x16')](_0x3e75a7)){return _0x579ca5(handleCheckRowError(_0x50fc('0x12'),_0x50fc('0x17'),null,_0x197cd4));}if(_0x3e75a7[_0x50fc('0x18')]&&_0x3e75a7['errors'][_0x50fc('0x19')]){var _0xa0c54c=_[_0x50fc('0x1a')](_0x3e75a7[_0x50fc('0x18')],_0x50fc('0x1b'))[_0x50fc('0x1c')](';');return _0x579ca5(handleCheckRowError(_0x50fc('0x12'),_0xa0c54c,null,_0x197cd4));}var _0x522ca6={};for(var _0x282de3 in FIELDS){if(FIELDS['hasOwnProperty'](_0x282de3)&&FIELDS[_0x282de3]){_0x522ca6[_0x282de3]=_0x3e75a7['data'][0x0][FIELDS[_0x282de3]]||_0x3e75a7[_0x50fc('0x1d')][0x0]['\ufeff'+FIELDS[_0x282de3]];}}if(!_0x522ca6[_0x50fc('0x1e')]){return _0x579ca5(handleCheckRowError(_0x50fc('0x12'),_0x50fc('0x1f'),null,_0x197cd4));}if(!_0x522ca6[_0x50fc('0x20')]){return _0x579ca5(handleCheckRowError(_0x50fc('0x12'),_0x50fc('0x21'),null,_0x197cd4));}if(_0x522ca6[_0x50fc('0x22')]){var _0x1556a2=moment(_0x522ca6[_0x50fc('0x22')],'YYYY-MM-DD');if(!_0x1556a2[_0x50fc('0x23')]()){return _0x579ca5(handleCheckRowError('error',_0x50fc('0x24'),null,_0x197cd4));}}if(_0x522ca6[_0x50fc('0x25')]){if(!isEmail(_0x522ca6[_0x50fc('0x25')])){return _0x579ca5(handleCheckRowError('error',_0x50fc('0x26'),null,_0x197cd4));}}_0x522ca6[_0x50fc('0x27')]=LISTID;_0x522ca6[_0x50fc('0x28')]=COMPANYID||undefined;if(DUPLICATES&&DUPLICATES[_0x50fc('0x19')]&&_0x6b5e8b){var _0x93d7e={};for(var _0x315479=0x0,_0x4a0071=DUPLICATES[_0x50fc('0x19')];_0x315479<_0x4a0071;_0x315479+=0x1){_0x93d7e[DUPLICATES[_0x315479]]=_0x522ca6[DUPLICATES[_0x315479]];}var _0x561d9e=_[_0x50fc('0x29')](_0x6b5e8b,_0x93d7e);if(_0x561d9e){return _0x579ca5(handleCheckRowError(_0x50fc('0x2a'),_0x50fc('0x2b'),_0x561d9e,_0x197cd4));}}return db['CmContact'][_0x50fc('0x2c')](_0x522ca6,{'raw':!![],'hooks':![],'fields':_[_0x50fc('0x2d')](_0x522ca6)})[_0x50fc('0x2e')](function(_0x5b156e){if(DUPLICATES&&DUPLICATES['length']&&_0x6b5e8b){_0x6b5e8b[_0x50fc('0x2f')](_[_0x50fc('0x30')](_0x522ca6,DUPLICATES));}hopperContacts+=(hopperContacts?',':'')+_0x5b156e['id'];return _0x360b71();})[_0x50fc('0x31')](function(_0x123079){return _0x579ca5(handleCheckRowError(_0x50fc('0x12'),_0x50fc('0x32')+(_0x123079['message']||JSON[_0x50fc('0x33')](_0x123079)),null,_0x197cd4));});});}function checkHopper(){function _0x54cdbd(){return function(_0x18e38b){logger[_0x50fc('0x12')](_0x50fc('0x34'),'checkHopper',util[_0x50fc('0x35')](_0x18e38b,{'showHidden':![],'depth':null}));};}var _0x45cc2f=function(_0x266f92,_0xab4bf5){var _0x375502=squel['insert']()['into']('cm_hopper')[_0x50fc('0x36')]([_0x50fc('0x20'),'scheduledAt','ContactId',_0x50fc('0x27'),_0xab4bf5,_0x50fc('0x37'),_0x50fc('0x38')],squel[_0x50fc('0x39')]()[_0x50fc('0x3a')]('phone',_0x50fc('0x20'))[_0x50fc('0x3a')](_0x50fc('0x3b'),_0x50fc('0x3c'))[_0x50fc('0x3a')]('id',_0x50fc('0x3d'))['field'](LISTID['toString'](),_0x50fc('0x27'))['field'](_0x266f92['id']['toString'](),_0xab4bf5)[_0x50fc('0x3a')](_0x50fc('0x3b'),_0x50fc('0x37'))[_0x50fc('0x3a')](_0x50fc('0x3b'),_0x50fc('0x38'))[_0x50fc('0x3e')](_0x50fc('0x3f'))[_0x50fc('0x40')](_0x50fc('0x41'))['where']('ListId\x20=\x20?',LISTID['toString']())[_0x50fc('0x40')](_0x50fc('0x42'))['where']('phone\x20NOT\x20IN\x20(?)',squel[_0x50fc('0x39')]()[_0x50fc('0x3a')](_0x50fc('0x20'))[_0x50fc('0x3e')](_0x50fc('0x43'))['where'](_0xab4bf5+_0x50fc('0x44'),_0x266f92['id'][_0x50fc('0x45')]())))[_0x50fc('0x45')]();return _0x375502;};var _0x4afb2a=function(_0x288f43,_0xb44826){var _0x1e3e92=squel[_0x50fc('0x46')]()[_0x50fc('0x47')]('cm_hopper')[_0x50fc('0x36')]([_0x50fc('0x20'),_0x50fc('0x3c'),'ContactId',_0x50fc('0x27'),_0xb44826,'createdAt','updatedAt'],squel[_0x50fc('0x39')]()[_0x50fc('0x3a')](_0x50fc('0x20'),_0x50fc('0x20'))['field'](_0x50fc('0x3b'),'scheduledAt')[_0x50fc('0x3a')]('id',_0x50fc('0x3d'))['field'](LISTID[_0x50fc('0x45')](),'ListId')[_0x50fc('0x3a')](_0x288f43['id'][_0x50fc('0x45')](),_0xb44826)[_0x50fc('0x3a')](_0x50fc('0x3b'),_0x50fc('0x37'))[_0x50fc('0x3a')](_0x50fc('0x3b'),'updatedAt')[_0x50fc('0x3e')]('cm_contacts')[_0x50fc('0x40')](_0x50fc('0x41'))[_0x50fc('0x40')](_0x50fc('0x48'),LISTID[_0x50fc('0x45')]())[_0x50fc('0x40')](_0x50fc('0x49'),squel[_0x50fc('0x4a')](hopperContacts))[_0x50fc('0x40')](_0x50fc('0x42'))[_0x50fc('0x40')](_0x50fc('0x4b'),squel[_0x50fc('0x39')]()[_0x50fc('0x3a')](_0x50fc('0x4c'))['from']('cm_hopper_final')[_0x50fc('0x40')](_0xb44826+'\x20=\x20?',_0x288f43['id'][_0x50fc('0x45')]()))[_0x50fc('0x40')](_0x50fc('0x4b'),squel[_0x50fc('0x39')]()['field'](_0x50fc('0x20'))[_0x50fc('0x3e')](_0x50fc('0x43'))['where'](_0xb44826+_0x50fc('0x44'),_0x288f43['id'][_0x50fc('0x45')]())))[_0x50fc('0x45')]();return _0x1e3e92;};function _0x2883e3(_0x3c322c,_0x32787c){var _0x2c979a=squel[_0x50fc('0x46')]()['into']('cm_hopper')['fromQuery']([_0x50fc('0x20'),_0x50fc('0x3c'),'ContactId',_0x50fc('0x27'),_0x32787c,_0x50fc('0x37'),_0x50fc('0x38')],squel['select']()['field'](_0x50fc('0x20'),_0x50fc('0x20'))[_0x50fc('0x3a')](_0x50fc('0x3b'),_0x50fc('0x3c'))['field']('id','ContactId')[_0x50fc('0x3a')](LISTID[_0x50fc('0x45')](),'ListId')[_0x50fc('0x3a')](_0x3c322c['id'][_0x50fc('0x45')](),_0x32787c)['field'](_0x50fc('0x3b'),_0x50fc('0x37'))[_0x50fc('0x3a')](_0x50fc('0x3b'),_0x50fc('0x38'))[_0x50fc('0x3e')](_0x50fc('0x3f'))[_0x50fc('0x40')](_0x50fc('0x41'))[_0x50fc('0x40')](_0x50fc('0x48'),LISTID[_0x50fc('0x45')]())[_0x50fc('0x40')](_0x50fc('0x49'),squel[_0x50fc('0x4a')](hopperContacts))[_0x50fc('0x40')](_0x50fc('0x42')))[_0x50fc('0x45')]();return _0x2c979a;}function _0x1a2d54(_0x98d366,_0x15e2e5){var _0x1e86d3=squel['insert']()[_0x50fc('0x47')](_0x50fc('0x4d'))['fromQuery']([_0x50fc('0x20'),'ContactId','ListId',_0x15e2e5,'createdAt','updatedAt'],squel[_0x50fc('0x39')]()['field'](_0x50fc('0x20'),_0x50fc('0x20'))['field']('id',_0x50fc('0x3d'))[_0x50fc('0x3a')](LISTID[_0x50fc('0x45')](),_0x50fc('0x27'))[_0x50fc('0x3a')](_0x98d366['id']['toString'](),_0x15e2e5)[_0x50fc('0x3a')](_0x50fc('0x3b'),_0x50fc('0x37'))['field']('NOW()','updatedAt')['from'](_0x50fc('0x3f'))[_0x50fc('0x40')](_0x50fc('0x41'))['where'](_0x50fc('0x48'),LISTID[_0x50fc('0x45')]())[_0x50fc('0x40')](_0x50fc('0x49'),squel[_0x50fc('0x4a')](hopperContacts))['where'](_0x50fc('0x42')))[_0x50fc('0x45')]();return _0x1e86d3;}return db[_0x50fc('0x4e')][_0x50fc('0x4f')]({'where':{'type':_0x50fc('0x50')},'attributes':['id','dialCheckDuplicateType'],'include':[{'model':db[_0x50fc('0x51')],'as':'Lists','where':{'id':LISTID}}]})['then'](function(_0x314fa6){var _0xfa63f2=[];if(_0x314fa6){var _0x3ba65b;for(var _0x2a355e=0x0,_0x513ce5;_0x2a355e<_0x314fa6['length'];_0x2a355e+=0x1){_0x513ce5=_0x314fa6[_0x2a355e]['get']({'plain':!![]});switch(_0x513ce5['dialCheckDuplicateType']){case _0x50fc('0x52'):_0xfa63f2[_0x50fc('0x2f')](db['sequelize'][_0x50fc('0x53')](_0x4afb2a(_0x513ce5,_0x50fc('0x54')))[_0x50fc('0x2e')](function(){})[_0x50fc('0x31')](_0x54cdbd()));break;case'onlyIfOpen':_0xfa63f2[_0x50fc('0x2f')](db[_0x50fc('0x55')][_0x50fc('0x53')](_0x45cc2f(_0x513ce5,_0x50fc('0x54')))[_0x50fc('0x2e')](function(){})[_0x50fc('0x31')](_0x54cdbd()));break;default:_0xfa63f2[_0x50fc('0x2f')](db[_0x50fc('0x55')][_0x50fc('0x53')](_0x2883e3(_0x513ce5,_0x50fc('0x54')))['then'](function(){})['catch'](_0x54cdbd()));}}}return _0xfa63f2;})['all']()[_0x50fc('0x2e')](function(){return db[_0x50fc('0x4e')]['findAll']({'where':{'type':'outbound'},'attributes':['id'],'include':[{'model':db[_0x50fc('0x51')],'as':_0x50fc('0x56'),'where':{'id':LISTID}}]})[_0x50fc('0x2e')](function(_0x84dca5){var _0x4189b2=[];if(_0x84dca5){var _0x335519;for(var _0x16919d=0x0,_0x570f07;_0x16919d<_0x84dca5[_0x50fc('0x19')];_0x16919d+=0x1){_0x570f07=_0x84dca5[_0x16919d][_0x50fc('0x57')]({'plain':!![]});_0x4189b2[_0x50fc('0x2f')](db[_0x50fc('0x55')][_0x50fc('0x53')](_0x1a2d54(_0x570f07,'VoiceQueueId'))[_0x50fc('0x2e')](function(){})['catch'](_0x54cdbd()));}}return _0x4189b2;})['all']();})[_0x50fc('0x2e')](function(){return db[_0x50fc('0x58')][_0x50fc('0x4f')]({'attributes':['id',_0x50fc('0x59')],'include':[{'model':db[_0x50fc('0x51')],'as':_0x50fc('0x5a'),'where':{'id':LISTID}}]})[_0x50fc('0x2e')](function(_0x5d6337){var _0x3ff321=[];if(_0x5d6337){for(var _0x4f4f8c=0x0,_0x25f236;_0x4f4f8c<_0x5d6337[_0x50fc('0x19')];_0x4f4f8c+=0x1){_0x25f236=_0x5d6337[_0x4f4f8c][_0x50fc('0x57')]({'plain':!![]});switch(_0x25f236[_0x50fc('0x59')]){case _0x50fc('0x52'):_0x3ff321[_0x50fc('0x2f')](db[_0x50fc('0x55')][_0x50fc('0x53')](_0x4afb2a(_0x25f236,_0x50fc('0x5b')))[_0x50fc('0x2e')](function(){})['catch'](_0x54cdbd()));break;case _0x50fc('0x5c'):_0x3ff321['push'](db[_0x50fc('0x55')][_0x50fc('0x53')](_0x45cc2f(_0x25f236,_0x50fc('0x5b')))[_0x50fc('0x2e')](function(){})['catch'](_0x54cdbd()));break;default:_0x3ff321['push'](db[_0x50fc('0x55')][_0x50fc('0x53')](_0x2883e3(_0x25f236,_0x50fc('0x5b')))[_0x50fc('0x2e')](function(){})['catch'](_0x54cdbd()));}}}return _0x3ff321;})['all']();})[_0x50fc('0x2e')](function(){return db[_0x50fc('0x58')]['findAll']({'attributes':['id'],'include':[{'model':db[_0x50fc('0x51')],'as':_0x50fc('0x56'),'where':{'id':LISTID}}]})[_0x50fc('0x2e')](function(_0x28ca0e){var _0x55df69=[];if(_0x28ca0e){for(var _0x2d0d29=0x0,_0x3fa7a0;_0x2d0d29<_0x28ca0e[_0x50fc('0x19')];_0x2d0d29+=0x1){_0x3fa7a0=_0x28ca0e[_0x2d0d29][_0x50fc('0x57')]({'plain':!![]});_0x55df69[_0x50fc('0x2f')](db[_0x50fc('0x55')][_0x50fc('0x53')](_0x1a2d54(_0x3fa7a0,_0x50fc('0x5b')))[_0x50fc('0x2e')](function(){})[_0x50fc('0x31')](_0x54cdbd()));}}return _0x55df69;})[_0x50fc('0x5d')]();})[_0x50fc('0x31')](function(_0x4faa91){logger[_0x50fc('0x12')](_0x50fc('0x5e'),_0x50fc('0x5f'),_0x4faa91[_0x50fc('0x1b')]);});}var processPromises=function(_0x528408){return BPromise[_0x50fc('0x5d')](promises)['then'](function(_0x5d1cb5){})['catch'](function(_0x4f7bef){logger[_0x50fc('0x12')](_0x50fc('0x60'),JSON[_0x50fc('0x33')](_0x4f7bef));})[_0x50fc('0x61')](function(){socket[_0x50fc('0x62')](_0x50fc('0x63')+SOCKET_TIMESTAMP,{'success':success,'errors':errors,'duplicates':duplicates,'rows':rows});promises=[];success=0x0;errors=0x0;duplicates=0x0;rows=[];if(_0x528408){return _0x528408[_0x50fc('0x64')]();}});};var endCsv=function(){return BPromise['resolve']()['then'](function(){if(hopperContacts){return checkHopper();}})[_0x50fc('0x2e')](function(){socket[_0x50fc('0x62')](_0x50fc('0x63')+SOCKET_TIMESTAMP,{'finished':!![],'success':success,'errors':errors,'duplicates':duplicates,'rows':rows});try{fs[_0x50fc('0x65')](FILEPATH);}catch(_0x2cef4e){logger[_0x50fc('0x12')](_0x50fc('0x66'),JSON[_0x50fc('0x33')](_0x2cef4e));}finally{process['exit'](0x0);}});};process['on'](_0x50fc('0x67'),function(){logger[_0x50fc('0x68')](_0x50fc('0x69'));endCsv();});function main(){return BPromise[_0x50fc('0x6a')]()['then'](function(){if(DUPLICATES){DUPLICATES=DUPLICATES[_0x50fc('0xf')](',');return db[_0x50fc('0x6b')][_0x50fc('0x4f')]({'where':{'ListId':LISTID},'attributes':DUPLICATES,'raw':!![]});}})['then'](function(_0x24456f){var _0x15208b=fs[_0x50fc('0x6c')](FILEPATH,{'highWaterMark':0xf*0x400*0x400});Papa[_0x50fc('0x6d')](_0x15208b,{'header':!![],'skipEmptyLines':!![],'step':function(_0x35a846,_0x1a2728){total+=0x1;var _0x21f72a=total;promises[_0x50fc('0x2f')](checkRow(_0x35a846,_0x24456f,_0x21f72a)[_0x50fc('0x2e')](function(){success+=0x1;})[_0x50fc('0x31')](function(_0x54187d){if(_0x54187d[_0x50fc('0x12')]){errors+=0x1;delete _0x54187d[_0x50fc('0x12')];}else if(_0x54187d[_0x50fc('0x2a')]){duplicates+=0x1;delete _0x54187d[_0x50fc('0x2a')];}rows[_0x50fc('0x2f')](_0x54187d);}));if(total%0xc8===0x0){_0x1a2728[_0x50fc('0x6e')]();return processPromises(_0x1a2728);}},'complete':function(){return processPromises()[_0x50fc('0x2e')](function(){logger[_0x50fc('0x68')](_0x50fc('0x6f'));endCsv();});},'error':function(_0x1d6049,_0x2e71ca){logger[_0x50fc('0x68')](_0x50fc('0x70'),JSON[_0x50fc('0x33')](_0x1d6049));endCsv();}});})[_0x50fc('0x31')](function(_0x3c41f5){logger[_0x50fc('0x12')]('Error\x20executing\x20contact\x20csv\x20import:',JSON[_0x50fc('0x33')](_0x3c41f5));});}main();
\ No newline at end of file