Built motion from commit 39adb707.|2.6.14
[motion2.git] / server / components / import / cm / csv.js
index 235209a..cd6bbbf 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xcb3f=['Missing\x20filepath\x20parameter!','Missing\x20binding\x20parameters!','zipObject','split','Missing\x20ListId\x20parameter!','contact','index','test','isNil','error','length','errors','message','data','firstName\x20not\x20specified!','phone','birthDate','isValid','birthDate\x20format\x20is\x20invalid,\x20YYYY-MM-DD\x20format\x20is\x20supported!','email','email\x20format\x20is\x20not\x20valid!','ListId','CompanyId','find','duplicate','keys','then','push','pick','Error\x20while\x20creating\x20contact:\x20','cmContact','checkHopper','insert','into','cm_hopper','scheduledAt','ContactId','createdAt','updatedAt','select','field','NOW()','toString','from','where','deletedAt\x20IS\x20NULL','phone\x20NOT\x20IN\x20(?)','\x20=\x20?','fromQuery','cm_contacts','ListId\x20=\x20?','id\x20IN\x20?','str','phone\x20IS\x20NOT\x20NULL','calleridnum','cm_hopper_final','findAll','outbound','CmList','Lists','get','dialCheckDuplicateType','sequelize','query','VoiceQueueId','catch','onlyIfOpen','all','VoiceQueue','BlackLists','Campaign','always','CampaignId','cmContact,\x20%s,\x20%s','generalCheckHopper','Error\x20processing\x20rows\x20block:','stringify','emit','contact:csv_','resume','resolve','exit','SIGINT','info','CSV\x20import\x20process\x20stopped!','CmContact','createReadStream','parse','CSV\x20parse\x20error','Error\x20executing\x20contact\x20csv\x20import:','bluebird','util','lodash','squel','papaparse','ioredis','../../../config/environment','api','redis','socket.io-emitter','../../../api/cmContact/cmContact.socket','undefined','argv','null'];(function(_0xaa1b3e,_0x47d976){var _0x454d7d=function(_0x575b32){while(--_0x575b32){_0xaa1b3e['push'](_0xaa1b3e['shift']());}};_0x454d7d(++_0x47d976);}(_0xcb3f,0xc2));var _0xfcb3=function(_0x160c73,_0x2ee678){_0x160c73=_0x160c73-0x0;var _0xd9302=_0xcb3f[_0x160c73];return _0xd9302;};'use strict';var BPromise=require(_0xfcb3('0x0'));var util=require(_0xfcb3('0x1'));var _=require(_0xfcb3('0x2'));var fs=require('fs');var squel=require(_0xfcb3('0x3'));var Papa=require(_0xfcb3('0x4'));var Redis=require(_0xfcb3('0x5'));var db=require('../../../mysqldb')['db'];var config=require(_0xfcb3('0x6'));var logger=require('../../../config/logger')(_0xfcb3('0x7'));config[_0xfcb3('0x8')]=_['defaults'](config[_0xfcb3('0x8')],{'host':'localhost','port':0x18eb});var socket=require(_0xfcb3('0x9'))(new Redis(config[_0xfcb3('0x8')]));require(_0xfcb3('0xa'))['register'](socket);try{if(!process['argv'][0x2]||process['argv'][0x2]===_0xfcb3('0xb')||process[_0xfcb3('0xc')][0x2]===_0xfcb3('0xd')){throw new Error(_0xfcb3('0xe'));}var FILEPATH=process[_0xfcb3('0xc')][0x2];if(!process[_0xfcb3('0xc')][0x3]||process[_0xfcb3('0xc')][0x3]===_0xfcb3('0xb')||process[_0xfcb3('0xc')][0x3]===_0xfcb3('0xd')||!process[_0xfcb3('0xc')][0x4]||process[_0xfcb3('0xc')][0x4]==='undefined'||process['argv'][0x4]==='null'){throw new Error(_0xfcb3('0xf'));}var FIELDS=_[_0xfcb3('0x10')](process[_0xfcb3('0xc')][0x3][_0xfcb3('0x11')](','),process[_0xfcb3('0xc')][0x4][_0xfcb3('0x11')](','));if(!process['argv'][0x5]||process[_0xfcb3('0xc')][0x5]===_0xfcb3('0xb')||process[_0xfcb3('0xc')][0x5]===_0xfcb3('0xd')){throw new Error(_0xfcb3('0x12'));}var LISTID=process[_0xfcb3('0xc')][0x5];var COMPANYID=process[_0xfcb3('0xc')][0x6]&&process[_0xfcb3('0xc')][0x6]!==_0xfcb3('0xb')&&process[_0xfcb3('0xc')][0x6]!==_0xfcb3('0xd')?process[_0xfcb3('0xc')][0x6]:null;var DUPLICATES=process['argv'][0x7]&&process[_0xfcb3('0xc')][0x7]!==_0xfcb3('0xb')&&process[_0xfcb3('0xc')][0x7]!==_0xfcb3('0xd')?process[_0xfcb3('0xc')][0x7]:null;if(!process[_0xfcb3('0xc')][0x8]||process[_0xfcb3('0xc')][0x8]===_0xfcb3('0xb')||process[_0xfcb3('0xc')][0x8]===_0xfcb3('0xd')){throw new Error('Missing\x20socket_timestamp\x20parameter!');}var SOCKET_TIMESTAMP=process['argv'][0x8];}catch(_0x134f4a){logger['error'](_0x134f4a);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(_0x225f52,_0x8a9141,_0x1e059,_0x41d4a1){var _0x22689c={'message':_0x8a9141};_0x22689c[_0x225f52]=!![];if(_0x1e059){_0x22689c[_0xfcb3('0x13')]=_0x1e059;}if(_0x41d4a1){_0x22689c[_0xfcb3('0x14')]=_0x41d4a1;}return _0x22689c;}function isEmail(_0x201048){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))*$/[_0xfcb3('0x15')](_0x201048);}function checkRow(_0x1ad1ca,_0x38bd63,_0xc9aca9){return new BPromise(function(_0xcc0139,_0x425a09){if(_[_0xfcb3('0x16')](_0x1ad1ca)){return _0x425a09(handleCheckRowError(_0xfcb3('0x17'),'The\x20row\x20is\x20empty\x20or\x20the\x20number\x20of\x20parameters\x20does\x20not\x20match\x20the\x20columns!',null,_0xc9aca9));}if(_0x1ad1ca['errors']&&_0x1ad1ca['errors'][_0xfcb3('0x18')]){var _0x301157=_['map'](_0x1ad1ca[_0xfcb3('0x19')],_0xfcb3('0x1a'))['join'](';');return _0x425a09(handleCheckRowError(_0xfcb3('0x17'),_0x301157,null,_0xc9aca9));}var _0x360a1c={};for(var _0x485866 in FIELDS){if(FIELDS['hasOwnProperty'](_0x485866)&&FIELDS[_0x485866]){_0x360a1c[_0x485866]=_0x1ad1ca[_0xfcb3('0x1b')][0x0][FIELDS[_0x485866]]||_0x1ad1ca[_0xfcb3('0x1b')][0x0]['\ufeff'+FIELDS[_0x485866]];}}if(!_0x360a1c['firstName']){return _0x425a09(handleCheckRowError('error',_0xfcb3('0x1c'),null,_0xc9aca9));}if(!_0x360a1c[_0xfcb3('0x1d')]){return _0x425a09(handleCheckRowError(_0xfcb3('0x17'),'phone\x20not\x20specified!',null,_0xc9aca9));}if(_0x360a1c[_0xfcb3('0x1e')]){var _0x205fd=moment(_0x360a1c['birthDate'],'YYYY-MM-DD');if(!_0x205fd[_0xfcb3('0x1f')]()){return _0x425a09(handleCheckRowError(_0xfcb3('0x17'),_0xfcb3('0x20'),null,_0xc9aca9));}}if(_0x360a1c[_0xfcb3('0x21')]){if(!isEmail(_0x360a1c[_0xfcb3('0x21')])){return _0x425a09(handleCheckRowError(_0xfcb3('0x17'),_0xfcb3('0x22'),null,_0xc9aca9));}}_0x360a1c[_0xfcb3('0x23')]=LISTID;_0x360a1c[_0xfcb3('0x24')]=COMPANYID||undefined;if(DUPLICATES&&DUPLICATES['length']&&_0x38bd63){var _0x25d417={};for(var _0xb528c0=0x0,_0x19c590=DUPLICATES[_0xfcb3('0x18')];_0xb528c0<_0x19c590;_0xb528c0+=0x1){_0x25d417[DUPLICATES[_0xb528c0]]=_0x360a1c[DUPLICATES[_0xb528c0]];}var _0xbf678e=_[_0xfcb3('0x25')](_0x38bd63,_0x25d417);if(_0xbf678e){return _0x425a09(handleCheckRowError(_0xfcb3('0x26'),'Duplicate\x20Contact',_0xbf678e,_0xc9aca9));}}return db['CmContact']['create'](_0x360a1c,{'raw':!![],'hooks':![],'fields':_[_0xfcb3('0x27')](_0x360a1c)})[_0xfcb3('0x28')](function(_0x1eda6d){if(DUPLICATES&&DUPLICATES['length']&&_0x38bd63){_0x38bd63[_0xfcb3('0x29')](_[_0xfcb3('0x2a')](_0x360a1c,DUPLICATES));}hopperContacts+=(hopperContacts?',':'')+_0x1eda6d['id'];return _0xcc0139();})['catch'](function(_0x199c46){return _0x425a09(handleCheckRowError('error',_0xfcb3('0x2b')+(_0x199c46[_0xfcb3('0x1a')]||JSON['stringify'](_0x199c46)),null,_0xc9aca9));});});}function checkHopper(){function _0x3b789b(){return function(_0xf0ce28){logger[_0xfcb3('0x17')](_0xfcb3('0x2c'),_0xfcb3('0x2d'),util['inspect'](_0xf0ce28,{'showHidden':![],'depth':null}));};}var _0x3554d7=function(_0x5b0754,_0x460042){var _0x4803e2=squel[_0xfcb3('0x2e')]()[_0xfcb3('0x2f')](_0xfcb3('0x30'))['fromQuery']([_0xfcb3('0x1d'),_0xfcb3('0x31'),_0xfcb3('0x32'),_0xfcb3('0x23'),_0x460042,_0xfcb3('0x33'),_0xfcb3('0x34')],squel[_0xfcb3('0x35')]()[_0xfcb3('0x36')](_0xfcb3('0x1d'),_0xfcb3('0x1d'))[_0xfcb3('0x36')](_0xfcb3('0x37'),_0xfcb3('0x31'))[_0xfcb3('0x36')]('id','ContactId')[_0xfcb3('0x36')](LISTID[_0xfcb3('0x38')](),_0xfcb3('0x23'))[_0xfcb3('0x36')](_0x5b0754['id'][_0xfcb3('0x38')](),_0x460042)[_0xfcb3('0x36')](_0xfcb3('0x37'),'createdAt')[_0xfcb3('0x36')]('NOW()',_0xfcb3('0x34'))[_0xfcb3('0x39')]('cm_contacts')[_0xfcb3('0x3a')](_0xfcb3('0x3b'))[_0xfcb3('0x3a')]('ListId\x20=\x20?',LISTID[_0xfcb3('0x38')]())[_0xfcb3('0x3a')]('phone\x20IS\x20NOT\x20NULL')['where'](_0xfcb3('0x3c'),squel[_0xfcb3('0x35')]()[_0xfcb3('0x36')](_0xfcb3('0x1d'))[_0xfcb3('0x39')]('cm_hopper')[_0xfcb3('0x3a')](_0x460042+_0xfcb3('0x3d'),_0x5b0754['id'][_0xfcb3('0x38')]())))[_0xfcb3('0x38')]();return _0x4803e2;};var _0x5b2831=function(_0x5aeb3d,_0x1db676){var _0x40ee61=squel['insert']()['into'](_0xfcb3('0x30'))[_0xfcb3('0x3e')]([_0xfcb3('0x1d'),_0xfcb3('0x31'),_0xfcb3('0x32'),_0xfcb3('0x23'),_0x1db676,_0xfcb3('0x33'),_0xfcb3('0x34')],squel[_0xfcb3('0x35')]()[_0xfcb3('0x36')](_0xfcb3('0x1d'),_0xfcb3('0x1d'))[_0xfcb3('0x36')](_0xfcb3('0x37'),_0xfcb3('0x31'))[_0xfcb3('0x36')]('id',_0xfcb3('0x32'))[_0xfcb3('0x36')](LISTID['toString'](),_0xfcb3('0x23'))[_0xfcb3('0x36')](_0x5aeb3d['id'][_0xfcb3('0x38')](),_0x1db676)[_0xfcb3('0x36')](_0xfcb3('0x37'),'createdAt')[_0xfcb3('0x36')]('NOW()','updatedAt')[_0xfcb3('0x39')](_0xfcb3('0x3f'))[_0xfcb3('0x3a')](_0xfcb3('0x3b'))[_0xfcb3('0x3a')](_0xfcb3('0x40'),LISTID[_0xfcb3('0x38')]())[_0xfcb3('0x3a')](_0xfcb3('0x41'),squel[_0xfcb3('0x42')](hopperContacts))[_0xfcb3('0x3a')](_0xfcb3('0x43'))[_0xfcb3('0x3a')]('phone\x20NOT\x20IN\x20(?)',squel[_0xfcb3('0x35')]()[_0xfcb3('0x36')](_0xfcb3('0x44'))[_0xfcb3('0x39')](_0xfcb3('0x45'))['where'](_0x1db676+'\x20=\x20?',_0x5aeb3d['id'][_0xfcb3('0x38')]()))[_0xfcb3('0x3a')](_0xfcb3('0x3c'),squel[_0xfcb3('0x35')]()[_0xfcb3('0x36')]('phone')['from']('cm_hopper')[_0xfcb3('0x3a')](_0x1db676+_0xfcb3('0x3d'),_0x5aeb3d['id'][_0xfcb3('0x38')]())))[_0xfcb3('0x38')]();return _0x40ee61;};function _0x3f8fe4(_0x2236dd,_0xecddd2){var _0x1e86d2=squel[_0xfcb3('0x2e')]()['into'](_0xfcb3('0x30'))[_0xfcb3('0x3e')](['phone',_0xfcb3('0x31'),_0xfcb3('0x32'),'ListId',_0xecddd2,'createdAt',_0xfcb3('0x34')],squel[_0xfcb3('0x35')]()[_0xfcb3('0x36')](_0xfcb3('0x1d'),_0xfcb3('0x1d'))[_0xfcb3('0x36')](_0xfcb3('0x37'),'scheduledAt')['field']('id',_0xfcb3('0x32'))[_0xfcb3('0x36')](LISTID[_0xfcb3('0x38')](),_0xfcb3('0x23'))[_0xfcb3('0x36')](_0x2236dd['id'][_0xfcb3('0x38')](),_0xecddd2)[_0xfcb3('0x36')](_0xfcb3('0x37'),'createdAt')[_0xfcb3('0x36')](_0xfcb3('0x37'),_0xfcb3('0x34'))[_0xfcb3('0x39')](_0xfcb3('0x3f'))[_0xfcb3('0x3a')](_0xfcb3('0x3b'))[_0xfcb3('0x3a')](_0xfcb3('0x40'),LISTID[_0xfcb3('0x38')]())['where']('id\x20IN\x20?',squel[_0xfcb3('0x42')](hopperContacts))['where'](_0xfcb3('0x43')))[_0xfcb3('0x38')]();return _0x1e86d2;}function _0x2f2e36(_0x31ef0b,_0x24c097){var _0x3c285b=squel['insert']()[_0xfcb3('0x2f')]('cm_hopper_black')['fromQuery'](['phone',_0xfcb3('0x32'),_0xfcb3('0x23'),_0x24c097,_0xfcb3('0x33'),_0xfcb3('0x34')],squel[_0xfcb3('0x35')]()[_0xfcb3('0x36')](_0xfcb3('0x1d'),_0xfcb3('0x1d'))[_0xfcb3('0x36')]('id',_0xfcb3('0x32'))['field'](LISTID[_0xfcb3('0x38')](),_0xfcb3('0x23'))['field'](_0x31ef0b['id'][_0xfcb3('0x38')](),_0x24c097)[_0xfcb3('0x36')](_0xfcb3('0x37'),_0xfcb3('0x33'))[_0xfcb3('0x36')]('NOW()','updatedAt')[_0xfcb3('0x39')](_0xfcb3('0x3f'))['where'](_0xfcb3('0x3b'))['where']('ListId\x20=\x20?',LISTID[_0xfcb3('0x38')]())[_0xfcb3('0x3a')](_0xfcb3('0x41'),squel[_0xfcb3('0x42')](hopperContacts))[_0xfcb3('0x3a')](_0xfcb3('0x43')))[_0xfcb3('0x38')]();return _0x3c285b;}return db['VoiceQueue'][_0xfcb3('0x46')]({'where':{'type':_0xfcb3('0x47')},'attributes':['id','dialCheckDuplicateType'],'include':[{'model':db[_0xfcb3('0x48')],'as':_0xfcb3('0x49'),'where':{'id':LISTID}}]})[_0xfcb3('0x28')](function(_0x2a31bd){var _0x1849f0=[];if(_0x2a31bd){var _0x23157d;for(var _0x5e4f7a=0x0,_0xf9f649;_0x5e4f7a<_0x2a31bd[_0xfcb3('0x18')];_0x5e4f7a+=0x1){_0xf9f649=_0x2a31bd[_0x5e4f7a][_0xfcb3('0x4a')]({'plain':!![]});switch(_0xf9f649[_0xfcb3('0x4b')]){case'always':_0x1849f0[_0xfcb3('0x29')](db[_0xfcb3('0x4c')][_0xfcb3('0x4d')](_0x5b2831(_0xf9f649,_0xfcb3('0x4e')))['then'](function(){})[_0xfcb3('0x4f')](_0x3b789b()));break;case _0xfcb3('0x50'):_0x1849f0[_0xfcb3('0x29')](db[_0xfcb3('0x4c')]['query'](_0x3554d7(_0xf9f649,'VoiceQueueId'))[_0xfcb3('0x28')](function(){})[_0xfcb3('0x4f')](_0x3b789b()));break;default:_0x1849f0[_0xfcb3('0x29')](db['sequelize'][_0xfcb3('0x4d')](_0x3f8fe4(_0xf9f649,_0xfcb3('0x4e')))[_0xfcb3('0x28')](function(){})[_0xfcb3('0x4f')](_0x3b789b()));}}}return _0x1849f0;})[_0xfcb3('0x51')]()['then'](function(){return db[_0xfcb3('0x52')][_0xfcb3('0x46')]({'where':{'type':'outbound'},'attributes':['id'],'include':[{'model':db[_0xfcb3('0x48')],'as':_0xfcb3('0x53'),'where':{'id':LISTID}}]})[_0xfcb3('0x28')](function(_0x3036ce){var _0xa73eca=[];if(_0x3036ce){var _0xa76d33;for(var _0x42be91=0x0,_0x229155;_0x42be91<_0x3036ce['length'];_0x42be91+=0x1){_0x229155=_0x3036ce[_0x42be91][_0xfcb3('0x4a')]({'plain':!![]});_0xa73eca['push'](db['sequelize'][_0xfcb3('0x4d')](_0x2f2e36(_0x229155,_0xfcb3('0x4e')))['then'](function(){})[_0xfcb3('0x4f')](_0x3b789b()));}}return _0xa73eca;})['all']();})[_0xfcb3('0x28')](function(){return db[_0xfcb3('0x54')][_0xfcb3('0x46')]({'attributes':['id',_0xfcb3('0x4b')],'include':[{'model':db[_0xfcb3('0x48')],'as':_0xfcb3('0x49'),'where':{'id':LISTID}}]})[_0xfcb3('0x28')](function(_0x291dbe){var _0x27d185=[];if(_0x291dbe){for(var _0x118102=0x0,_0x4f4aba;_0x118102<_0x291dbe[_0xfcb3('0x18')];_0x118102+=0x1){_0x4f4aba=_0x291dbe[_0x118102]['get']({'plain':!![]});switch(_0x4f4aba[_0xfcb3('0x4b')]){case _0xfcb3('0x55'):_0x27d185[_0xfcb3('0x29')](db[_0xfcb3('0x4c')][_0xfcb3('0x4d')](_0x5b2831(_0x4f4aba,_0xfcb3('0x56')))[_0xfcb3('0x28')](function(){})['catch'](_0x3b789b()));break;case _0xfcb3('0x50'):_0x27d185[_0xfcb3('0x29')](db['sequelize'][_0xfcb3('0x4d')](_0x3554d7(_0x4f4aba,'CampaignId'))[_0xfcb3('0x28')](function(){})['catch'](_0x3b789b()));break;default:_0x27d185['push'](db[_0xfcb3('0x4c')][_0xfcb3('0x4d')](_0x3f8fe4(_0x4f4aba,_0xfcb3('0x56')))[_0xfcb3('0x28')](function(){})[_0xfcb3('0x4f')](_0x3b789b()));}}}return _0x27d185;})[_0xfcb3('0x51')]();})['then'](function(){return db[_0xfcb3('0x54')][_0xfcb3('0x46')]({'attributes':['id'],'include':[{'model':db[_0xfcb3('0x48')],'as':_0xfcb3('0x53'),'where':{'id':LISTID}}]})['then'](function(_0x33c470){var _0x3b573d=[];if(_0x33c470){for(var _0x4d2140=0x0,_0x2b203b;_0x4d2140<_0x33c470[_0xfcb3('0x18')];_0x4d2140+=0x1){_0x2b203b=_0x33c470[_0x4d2140][_0xfcb3('0x4a')]({'plain':!![]});_0x3b573d[_0xfcb3('0x29')](db['sequelize'][_0xfcb3('0x4d')](_0x2f2e36(_0x2b203b,_0xfcb3('0x56')))['then'](function(){})[_0xfcb3('0x4f')](_0x3b789b()));}}return _0x3b573d;})[_0xfcb3('0x51')]();})['catch'](function(_0x14032b){logger['error'](_0xfcb3('0x57'),_0xfcb3('0x58'),_0x14032b[_0xfcb3('0x1a')]);});}var processPromises=function(_0x44158b){return BPromise[_0xfcb3('0x51')](promises)['then'](function(_0x8fafc1){})['catch'](function(_0x556eb1){logger[_0xfcb3('0x17')](_0xfcb3('0x59'),JSON[_0xfcb3('0x5a')](_0x556eb1));})['finally'](function(){socket[_0xfcb3('0x5b')](_0xfcb3('0x5c')+SOCKET_TIMESTAMP,{'success':success,'errors':errors,'duplicates':duplicates,'rows':rows});promises=[];success=0x0;errors=0x0;duplicates=0x0;rows=[];if(_0x44158b){return _0x44158b[_0xfcb3('0x5d')]();}});};var endCsv=function(){return BPromise[_0xfcb3('0x5e')]()[_0xfcb3('0x28')](function(){if(hopperContacts){return checkHopper();}})['then'](function(){socket[_0xfcb3('0x5b')](_0xfcb3('0x5c')+SOCKET_TIMESTAMP,{'finished':!![],'success':success,'errors':errors,'duplicates':duplicates,'rows':rows});try{fs['unlinkSync'](FILEPATH);}catch(_0x4716f2){logger['error']('Unable\x20to\x20delete\x20temp\x20file:',JSON['stringify'](_0x4716f2));}finally{process[_0xfcb3('0x5f')](0x0);}});};process['on'](_0xfcb3('0x60'),function(){logger[_0xfcb3('0x61')](_0xfcb3('0x62'));endCsv();});function main(){return BPromise[_0xfcb3('0x5e')]()[_0xfcb3('0x28')](function(){if(DUPLICATES){DUPLICATES=DUPLICATES['split'](',');return db[_0xfcb3('0x63')]['findAll']({'where':{'ListId':LISTID},'attributes':DUPLICATES,'raw':!![]});}})[_0xfcb3('0x28')](function(_0x42c292){var _0x28e868=fs[_0xfcb3('0x64')](FILEPATH,{'highWaterMark':0xf*0x400*0x400});Papa[_0xfcb3('0x65')](_0x28e868,{'header':!![],'skipEmptyLines':!![],'step':function(_0x47de3e,_0x4af59b){total+=0x1;var _0x45ca5d=total;promises[_0xfcb3('0x29')](checkRow(_0x47de3e,_0x42c292,_0x45ca5d)[_0xfcb3('0x28')](function(){success+=0x1;})[_0xfcb3('0x4f')](function(_0x1ce0bd){if(_0x1ce0bd[_0xfcb3('0x17')]){errors+=0x1;delete _0x1ce0bd['error'];}else if(_0x1ce0bd['duplicate']){duplicates+=0x1;delete _0x1ce0bd[_0xfcb3('0x26')];}rows[_0xfcb3('0x29')](_0x1ce0bd);}));if(total%0xc8===0x0){_0x4af59b['pause']();return processPromises(_0x4af59b);}},'complete':function(){return processPromises()[_0xfcb3('0x28')](function(){logger[_0xfcb3('0x61')]('CSV\x20parsed\x20correctly!');endCsv();});},'error':function(_0x49460a,_0x2e3256){logger[_0xfcb3('0x61')](_0xfcb3('0x66'),JSON[_0xfcb3('0x5a')](_0x49460a));endCsv();}});})[_0xfcb3('0x4f')](function(_0x3b99c0){logger[_0xfcb3('0x17')](_0xfcb3('0x67'),JSON[_0xfcb3('0x5a')](_0x3b99c0));});}main();
\ No newline at end of file
+var _0x92ed=['id\x20IN\x20?','str','phone\x20IS\x20NOT\x20NULL','calleridnum','cm_hopper_final','\x20=\x20?','into','cm_hopper_black','VoiceQueue','dialCheckDuplicateType','CmList','Lists','get','always','sequelize','query','VoiceQueueId','onlyIfOpen','all','findAll','BlackLists','Campaign','CampaignId','Error\x20processing\x20rows\x20block:','finally','contact:csv_','emit','unlinkSync','Unable\x20to\x20delete\x20temp\x20file:','exit','SIGINT','info','CSV\x20import\x20process\x20stopped!','resolve','createReadStream','parse','pause','CSV\x20parsed\x20correctly!','CSV\x20parse\x20error','Error\x20executing\x20contact\x20csv\x20import:','bluebird','util','lodash','squel','papaparse','ioredis','../../../mysqldb','../../../config/logger','api','redis','defaults','localhost','argv','null','Missing\x20filepath\x20parameter!','undefined','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','join','data','firstName','firstName\x20not\x20specified!','phone\x20not\x20specified!','birthDate','YYYY-MM-DD','isValid','email','email\x20format\x20is\x20not\x20valid!','ListId','duplicate','Duplicate\x20Contact','CmContact','create','keys','then','push','pick','catch','Error\x20while\x20creating\x20contact:\x20','message','stringify','checkHopper','inspect','insert','phone','scheduledAt','ContactId','select','field','toString','createdAt','NOW()','updatedAt','from','cm_contacts','where','deletedAt\x20IS\x20NULL','ListId\x20=\x20?','phone\x20NOT\x20IN\x20(?)','cm_hopper','fromQuery'];(function(_0x47a12a,_0x70f591){var _0x30cd40=function(_0x46b68f){while(--_0x46b68f){_0x47a12a['push'](_0x47a12a['shift']());}};_0x30cd40(++_0x70f591);}(_0x92ed,0x10a));var _0xd92e=function(_0x8d5286,_0x1afb5c){_0x8d5286=_0x8d5286-0x0;var _0x45891a=_0x92ed[_0x8d5286];return _0x45891a;};'use strict';var BPromise=require(_0xd92e('0x0'));var util=require(_0xd92e('0x1'));var _=require(_0xd92e('0x2'));var fs=require('fs');var squel=require(_0xd92e('0x3'));var Papa=require(_0xd92e('0x4'));var Redis=require(_0xd92e('0x5'));var db=require(_0xd92e('0x6'))['db'];var config=require('../../../config/environment');var logger=require(_0xd92e('0x7'))(_0xd92e('0x8'));config[_0xd92e('0x9')]=_[_0xd92e('0xa')](config['redis'],{'host':_0xd92e('0xb'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0xd92e('0x9')]));require('../../../api/cmContact/cmContact.socket')['register'](socket);try{if(!process['argv'][0x2]||process['argv'][0x2]==='undefined'||process[_0xd92e('0xc')][0x2]===_0xd92e('0xd')){throw new Error(_0xd92e('0xe'));}var FILEPATH=process['argv'][0x2];if(!process[_0xd92e('0xc')][0x3]||process[_0xd92e('0xc')][0x3]===_0xd92e('0xf')||process[_0xd92e('0xc')][0x3]==='null'||!process[_0xd92e('0xc')][0x4]||process[_0xd92e('0xc')][0x4]===_0xd92e('0xf')||process[_0xd92e('0xc')][0x4]===_0xd92e('0xd')){throw new Error(_0xd92e('0x10'));}var FIELDS=_[_0xd92e('0x11')](process[_0xd92e('0xc')][0x3][_0xd92e('0x12')](','),process[_0xd92e('0xc')][0x4][_0xd92e('0x12')](','));if(!process[_0xd92e('0xc')][0x5]||process['argv'][0x5]===_0xd92e('0xf')||process[_0xd92e('0xc')][0x5]===_0xd92e('0xd')){throw new Error(_0xd92e('0x13'));}var LISTID=process[_0xd92e('0xc')][0x5];var COMPANYID=process[_0xd92e('0xc')][0x6]&&process[_0xd92e('0xc')][0x6]!==_0xd92e('0xf')&&process[_0xd92e('0xc')][0x6]!==_0xd92e('0xd')?process[_0xd92e('0xc')][0x6]:null;var DUPLICATES=process[_0xd92e('0xc')][0x7]&&process['argv'][0x7]!==_0xd92e('0xf')&&process[_0xd92e('0xc')][0x7]!==_0xd92e('0xd')?process[_0xd92e('0xc')][0x7]:null;if(!process[_0xd92e('0xc')][0x8]||process[_0xd92e('0xc')][0x8]===_0xd92e('0xf')||process[_0xd92e('0xc')][0x8]===_0xd92e('0xd')){throw new Error(_0xd92e('0x14'));}var SOCKET_TIMESTAMP=process[_0xd92e('0xc')][0x8];}catch(_0x551453){logger[_0xd92e('0x15')](_0x551453);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(_0x3aa11b,_0x501550,_0x5da1ce,_0x193947){var _0x201c3c={'message':_0x501550};_0x201c3c[_0x3aa11b]=!![];if(_0x5da1ce){_0x201c3c[_0xd92e('0x16')]=_0x5da1ce;}if(_0x193947){_0x201c3c[_0xd92e('0x17')]=_0x193947;}return _0x201c3c;}function isEmail(_0x461995){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))*$/[_0xd92e('0x18')](_0x461995);}function checkRow(_0x13b1fa,_0x3ab960,_0x2fe2da){return new BPromise(function(_0x2f8d18,_0x3ad220){if(_[_0xd92e('0x19')](_0x13b1fa)){return _0x3ad220(handleCheckRowError('error',_0xd92e('0x1a'),null,_0x2fe2da));}if(_0x13b1fa['errors']&&_0x13b1fa[_0xd92e('0x1b')][_0xd92e('0x1c')]){var _0x4f83d4=_[_0xd92e('0x1d')](_0x13b1fa[_0xd92e('0x1b')],'message')[_0xd92e('0x1e')](';');return _0x3ad220(handleCheckRowError(_0xd92e('0x15'),_0x4f83d4,null,_0x2fe2da));}var _0x4f2d70={};for(var _0x40504f in FIELDS){if(FIELDS['hasOwnProperty'](_0x40504f)&&FIELDS[_0x40504f]){_0x4f2d70[_0x40504f]=_0x13b1fa[_0xd92e('0x1f')][0x0][FIELDS[_0x40504f]]||_0x13b1fa[_0xd92e('0x1f')][0x0]['\ufeff'+FIELDS[_0x40504f]];}}if(!_0x4f2d70[_0xd92e('0x20')]){return _0x3ad220(handleCheckRowError(_0xd92e('0x15'),_0xd92e('0x21'),null,_0x2fe2da));}if(!_0x4f2d70['phone']){return _0x3ad220(handleCheckRowError(_0xd92e('0x15'),_0xd92e('0x22'),null,_0x2fe2da));}if(_0x4f2d70['birthDate']){var _0x595db=moment(_0x4f2d70[_0xd92e('0x23')],_0xd92e('0x24'));if(!_0x595db[_0xd92e('0x25')]()){return _0x3ad220(handleCheckRowError(_0xd92e('0x15'),'birthDate\x20format\x20is\x20invalid,\x20YYYY-MM-DD\x20format\x20is\x20supported!',null,_0x2fe2da));}}if(_0x4f2d70[_0xd92e('0x26')]){if(!isEmail(_0x4f2d70[_0xd92e('0x26')])){return _0x3ad220(handleCheckRowError(_0xd92e('0x15'),_0xd92e('0x27'),null,_0x2fe2da));}}_0x4f2d70[_0xd92e('0x28')]=LISTID;_0x4f2d70['CompanyId']=COMPANYID||undefined;if(DUPLICATES&&DUPLICATES['length']&&_0x3ab960){var _0x40f527={};for(var _0x34f35e=0x0,_0x3dc9da=DUPLICATES[_0xd92e('0x1c')];_0x34f35e<_0x3dc9da;_0x34f35e+=0x1){_0x40f527[DUPLICATES[_0x34f35e]]=_0x4f2d70[DUPLICATES[_0x34f35e]];}var _0x260486=_['find'](_0x3ab960,_0x40f527);if(_0x260486){return _0x3ad220(handleCheckRowError(_0xd92e('0x29'),_0xd92e('0x2a'),_0x260486,_0x2fe2da));}}return db[_0xd92e('0x2b')][_0xd92e('0x2c')](_0x4f2d70,{'raw':!![],'hooks':![],'fields':_[_0xd92e('0x2d')](_0x4f2d70)})[_0xd92e('0x2e')](function(_0x507c8c){if(DUPLICATES&&DUPLICATES['length']&&_0x3ab960){_0x3ab960[_0xd92e('0x2f')](_[_0xd92e('0x30')](_0x4f2d70,DUPLICATES));}hopperContacts+=(hopperContacts?',':'')+_0x507c8c['id'];return _0x2f8d18();})[_0xd92e('0x31')](function(_0xcf46e2){return _0x3ad220(handleCheckRowError(_0xd92e('0x15'),_0xd92e('0x32')+(_0xcf46e2[_0xd92e('0x33')]||JSON[_0xd92e('0x34')](_0xcf46e2)),null,_0x2fe2da));});});}function checkHopper(){function _0x2a6d0b(){return function(_0x5a13f3){logger['error']('cmContact',_0xd92e('0x35'),util[_0xd92e('0x36')](_0x5a13f3,{'showHidden':![],'depth':null}));};}var _0x1ef1e1=function(_0x2c29ac,_0x2b31dd){var _0xd14ee4=squel[_0xd92e('0x37')]()['into']('cm_hopper')['fromQuery']([_0xd92e('0x38'),_0xd92e('0x39'),_0xd92e('0x3a'),_0xd92e('0x28'),_0x2b31dd,'createdAt','updatedAt'],squel[_0xd92e('0x3b')]()[_0xd92e('0x3c')](_0xd92e('0x38'),'phone')[_0xd92e('0x3c')]('NOW()',_0xd92e('0x39'))[_0xd92e('0x3c')]('id',_0xd92e('0x3a'))[_0xd92e('0x3c')](LISTID['toString'](),_0xd92e('0x28'))[_0xd92e('0x3c')](_0x2c29ac['id'][_0xd92e('0x3d')](),_0x2b31dd)[_0xd92e('0x3c')]('NOW()',_0xd92e('0x3e'))[_0xd92e('0x3c')](_0xd92e('0x3f'),_0xd92e('0x40'))[_0xd92e('0x41')](_0xd92e('0x42'))[_0xd92e('0x43')](_0xd92e('0x44'))[_0xd92e('0x43')](_0xd92e('0x45'),LISTID[_0xd92e('0x3d')]())[_0xd92e('0x43')]('phone\x20IS\x20NOT\x20NULL')[_0xd92e('0x43')](_0xd92e('0x46'),squel[_0xd92e('0x3b')]()[_0xd92e('0x3c')]('phone')[_0xd92e('0x41')](_0xd92e('0x47'))['where'](_0x2b31dd+'\x20=\x20?',_0x2c29ac['id']['toString']())))[_0xd92e('0x3d')]();return _0xd14ee4;};var _0x26f518=function(_0x595688,_0x47d798){var _0x2064a9=squel[_0xd92e('0x37')]()['into'](_0xd92e('0x47'))[_0xd92e('0x48')]([_0xd92e('0x38'),'scheduledAt','ContactId',_0xd92e('0x28'),_0x47d798,_0xd92e('0x3e'),_0xd92e('0x40')],squel['select']()[_0xd92e('0x3c')]('phone',_0xd92e('0x38'))['field'](_0xd92e('0x3f'),_0xd92e('0x39'))['field']('id','ContactId')['field'](LISTID['toString'](),_0xd92e('0x28'))[_0xd92e('0x3c')](_0x595688['id'][_0xd92e('0x3d')](),_0x47d798)[_0xd92e('0x3c')]('NOW()',_0xd92e('0x3e'))['field'](_0xd92e('0x3f'),'updatedAt')[_0xd92e('0x41')](_0xd92e('0x42'))['where'](_0xd92e('0x44'))['where'](_0xd92e('0x45'),LISTID[_0xd92e('0x3d')]())[_0xd92e('0x43')](_0xd92e('0x49'),squel[_0xd92e('0x4a')](hopperContacts))['where'](_0xd92e('0x4b'))[_0xd92e('0x43')](_0xd92e('0x46'),squel[_0xd92e('0x3b')]()[_0xd92e('0x3c')](_0xd92e('0x4c'))['from'](_0xd92e('0x4d'))['where'](_0x47d798+_0xd92e('0x4e'),_0x595688['id'][_0xd92e('0x3d')]()))[_0xd92e('0x43')](_0xd92e('0x46'),squel[_0xd92e('0x3b')]()[_0xd92e('0x3c')]('phone')[_0xd92e('0x41')](_0xd92e('0x47'))[_0xd92e('0x43')](_0x47d798+_0xd92e('0x4e'),_0x595688['id'][_0xd92e('0x3d')]())))['toString']();return _0x2064a9;};function _0x2f4369(_0x4e5c57,_0x1ce6e1){var _0x1bc2d1=squel['insert']()[_0xd92e('0x4f')](_0xd92e('0x47'))[_0xd92e('0x48')]([_0xd92e('0x38'),_0xd92e('0x39'),'ContactId',_0xd92e('0x28'),_0x1ce6e1,_0xd92e('0x3e'),_0xd92e('0x40')],squel[_0xd92e('0x3b')]()[_0xd92e('0x3c')](_0xd92e('0x38'),_0xd92e('0x38'))['field'](_0xd92e('0x3f'),_0xd92e('0x39'))[_0xd92e('0x3c')]('id',_0xd92e('0x3a'))[_0xd92e('0x3c')](LISTID['toString'](),'ListId')[_0xd92e('0x3c')](_0x4e5c57['id'][_0xd92e('0x3d')](),_0x1ce6e1)[_0xd92e('0x3c')]('NOW()','createdAt')[_0xd92e('0x3c')]('NOW()',_0xd92e('0x40'))[_0xd92e('0x41')]('cm_contacts')[_0xd92e('0x43')](_0xd92e('0x44'))[_0xd92e('0x43')]('ListId\x20=\x20?',LISTID[_0xd92e('0x3d')]())[_0xd92e('0x43')](_0xd92e('0x49'),squel[_0xd92e('0x4a')](hopperContacts))[_0xd92e('0x43')](_0xd92e('0x4b')))[_0xd92e('0x3d')]();return _0x1bc2d1;}function _0x37ab9f(_0x586595,_0x3bce2f){var _0x1c5aa2=squel[_0xd92e('0x37')]()[_0xd92e('0x4f')](_0xd92e('0x50'))['fromQuery']([_0xd92e('0x38'),_0xd92e('0x3a'),_0xd92e('0x28'),_0x3bce2f,_0xd92e('0x3e'),_0xd92e('0x40')],squel[_0xd92e('0x3b')]()[_0xd92e('0x3c')](_0xd92e('0x38'),'phone')[_0xd92e('0x3c')]('id',_0xd92e('0x3a'))[_0xd92e('0x3c')](LISTID[_0xd92e('0x3d')](),'ListId')[_0xd92e('0x3c')](_0x586595['id']['toString'](),_0x3bce2f)['field'](_0xd92e('0x3f'),'createdAt')[_0xd92e('0x3c')](_0xd92e('0x3f'),_0xd92e('0x40'))[_0xd92e('0x41')](_0xd92e('0x42'))[_0xd92e('0x43')](_0xd92e('0x44'))['where']('ListId\x20=\x20?',LISTID[_0xd92e('0x3d')]())[_0xd92e('0x43')](_0xd92e('0x49'),squel['str'](hopperContacts))[_0xd92e('0x43')](_0xd92e('0x4b')))['toString']();return _0x1c5aa2;}return db[_0xd92e('0x51')]['findAll']({'where':{'type':'outbound'},'attributes':['id',_0xd92e('0x52')],'include':[{'model':db[_0xd92e('0x53')],'as':_0xd92e('0x54'),'where':{'id':LISTID}}]})[_0xd92e('0x2e')](function(_0x3c2d9f){var _0x170698=[];if(_0x3c2d9f){var _0x596982;for(var _0x1ecf1c=0x0,_0x156581;_0x1ecf1c<_0x3c2d9f[_0xd92e('0x1c')];_0x1ecf1c+=0x1){_0x156581=_0x3c2d9f[_0x1ecf1c][_0xd92e('0x55')]({'plain':!![]});switch(_0x156581[_0xd92e('0x52')]){case _0xd92e('0x56'):_0x170698['push'](db[_0xd92e('0x57')][_0xd92e('0x58')](_0x26f518(_0x156581,_0xd92e('0x59')))[_0xd92e('0x2e')](function(){})['catch'](_0x2a6d0b()));break;case _0xd92e('0x5a'):_0x170698[_0xd92e('0x2f')](db['sequelize'][_0xd92e('0x58')](_0x1ef1e1(_0x156581,_0xd92e('0x59')))[_0xd92e('0x2e')](function(){})[_0xd92e('0x31')](_0x2a6d0b()));break;default:_0x170698[_0xd92e('0x2f')](db['sequelize']['query'](_0x2f4369(_0x156581,'VoiceQueueId'))['then'](function(){})[_0xd92e('0x31')](_0x2a6d0b()));}}}return _0x170698;})[_0xd92e('0x5b')]()['then'](function(){return db[_0xd92e('0x51')][_0xd92e('0x5c')]({'where':{'type':'outbound'},'attributes':['id'],'include':[{'model':db[_0xd92e('0x53')],'as':_0xd92e('0x5d'),'where':{'id':LISTID}}]})[_0xd92e('0x2e')](function(_0x262a55){var _0x4267e5=[];if(_0x262a55){var _0x56bb97;for(var _0x4b196e=0x0,_0x3e1e98;_0x4b196e<_0x262a55[_0xd92e('0x1c')];_0x4b196e+=0x1){_0x3e1e98=_0x262a55[_0x4b196e]['get']({'plain':!![]});_0x4267e5[_0xd92e('0x2f')](db['sequelize']['query'](_0x37ab9f(_0x3e1e98,'VoiceQueueId'))[_0xd92e('0x2e')](function(){})[_0xd92e('0x31')](_0x2a6d0b()));}}return _0x4267e5;})[_0xd92e('0x5b')]();})[_0xd92e('0x2e')](function(){return db[_0xd92e('0x5e')][_0xd92e('0x5c')]({'attributes':['id',_0xd92e('0x52')],'include':[{'model':db[_0xd92e('0x53')],'as':'Lists','where':{'id':LISTID}}]})[_0xd92e('0x2e')](function(_0x3b4234){var _0x1355d5=[];if(_0x3b4234){for(var _0x1eea10=0x0,_0x38243f;_0x1eea10<_0x3b4234['length'];_0x1eea10+=0x1){_0x38243f=_0x3b4234[_0x1eea10][_0xd92e('0x55')]({'plain':!![]});switch(_0x38243f[_0xd92e('0x52')]){case'always':_0x1355d5['push'](db['sequelize'][_0xd92e('0x58')](_0x26f518(_0x38243f,_0xd92e('0x5f')))['then'](function(){})['catch'](_0x2a6d0b()));break;case'onlyIfOpen':_0x1355d5[_0xd92e('0x2f')](db[_0xd92e('0x57')][_0xd92e('0x58')](_0x1ef1e1(_0x38243f,'CampaignId'))[_0xd92e('0x2e')](function(){})[_0xd92e('0x31')](_0x2a6d0b()));break;default:_0x1355d5['push'](db[_0xd92e('0x57')][_0xd92e('0x58')](_0x2f4369(_0x38243f,'CampaignId'))['then'](function(){})[_0xd92e('0x31')](_0x2a6d0b()));}}}return _0x1355d5;})[_0xd92e('0x5b')]();})[_0xd92e('0x2e')](function(){return db['Campaign'][_0xd92e('0x5c')]({'attributes':['id'],'include':[{'model':db[_0xd92e('0x53')],'as':_0xd92e('0x5d'),'where':{'id':LISTID}}]})[_0xd92e('0x2e')](function(_0x47abaf){var _0x35355f=[];if(_0x47abaf){for(var _0x347677=0x0,_0x5b9476;_0x347677<_0x47abaf[_0xd92e('0x1c')];_0x347677+=0x1){_0x5b9476=_0x47abaf[_0x347677][_0xd92e('0x55')]({'plain':!![]});_0x35355f[_0xd92e('0x2f')](db[_0xd92e('0x57')][_0xd92e('0x58')](_0x37ab9f(_0x5b9476,_0xd92e('0x5f')))[_0xd92e('0x2e')](function(){})[_0xd92e('0x31')](_0x2a6d0b()));}}return _0x35355f;})[_0xd92e('0x5b')]();})[_0xd92e('0x31')](function(_0x323901){logger[_0xd92e('0x15')]('cmContact,\x20%s,\x20%s','generalCheckHopper',_0x323901[_0xd92e('0x33')]);});}var processPromises=function(_0x3864ce){return BPromise[_0xd92e('0x5b')](promises)[_0xd92e('0x2e')](function(_0x513376){})[_0xd92e('0x31')](function(_0x4c63c0){logger['error'](_0xd92e('0x60'),JSON['stringify'](_0x4c63c0));})[_0xd92e('0x61')](function(){socket['emit'](_0xd92e('0x62')+SOCKET_TIMESTAMP,{'success':success,'errors':errors,'duplicates':duplicates,'rows':rows});promises=[];success=0x0;errors=0x0;duplicates=0x0;rows=[];if(_0x3864ce){return _0x3864ce['resume']();}});};var endCsv=function(){return BPromise['resolve']()[_0xd92e('0x2e')](function(){if(hopperContacts){return checkHopper();}})[_0xd92e('0x2e')](function(){socket[_0xd92e('0x63')](_0xd92e('0x62')+SOCKET_TIMESTAMP,{'finished':!![],'success':success,'errors':errors,'duplicates':duplicates,'rows':rows});try{fs[_0xd92e('0x64')](FILEPATH);}catch(_0x20b056){logger[_0xd92e('0x15')](_0xd92e('0x65'),JSON[_0xd92e('0x34')](_0x20b056));}finally{process[_0xd92e('0x66')](0x0);}});};process['on'](_0xd92e('0x67'),function(){logger[_0xd92e('0x68')](_0xd92e('0x69'));endCsv();});function main(){return BPromise[_0xd92e('0x6a')]()[_0xd92e('0x2e')](function(){if(DUPLICATES){DUPLICATES=DUPLICATES['split'](',');return db['CmContact'][_0xd92e('0x5c')]({'where':{'ListId':LISTID},'attributes':DUPLICATES,'raw':!![]});}})[_0xd92e('0x2e')](function(_0x2649d0){var _0xb3ab98=fs[_0xd92e('0x6b')](FILEPATH,{'highWaterMark':0xf*0x400*0x400});Papa[_0xd92e('0x6c')](_0xb3ab98,{'header':!![],'skipEmptyLines':!![],'step':function(_0x20d80c,_0x2e826b){total+=0x1;var _0x2cd576=total;promises[_0xd92e('0x2f')](checkRow(_0x20d80c,_0x2649d0,_0x2cd576)[_0xd92e('0x2e')](function(){success+=0x1;})['catch'](function(_0x5b34cf){if(_0x5b34cf[_0xd92e('0x15')]){errors+=0x1;delete _0x5b34cf[_0xd92e('0x15')];}else if(_0x5b34cf[_0xd92e('0x29')]){duplicates+=0x1;delete _0x5b34cf[_0xd92e('0x29')];}rows['push'](_0x5b34cf);}));if(total%0xc8===0x0){_0x2e826b[_0xd92e('0x6d')]();return processPromises(_0x2e826b);}},'complete':function(){return processPromises()['then'](function(){logger['info'](_0xd92e('0x6e'));endCsv();});},'error':function(_0x3bfd80,_0x2073d3){logger[_0xd92e('0x68')](_0xd92e('0x6f'),JSON[_0xd92e('0x34')](_0x3bfd80));endCsv();}});})[_0xd92e('0x31')](function(_0x45dadd){logger['error'](_0xd92e('0x70'),JSON[_0xd92e('0x34')](_0x45dadd));});}main();
\ No newline at end of file