Built motion from commit ba71417a.|2.6.28
[motion2.git] / server / components / import / cm / csv.js
1 // *************************************************************************
2 // *                                                                       *
3 // * xCALLY Motion -  The Omnichannel Contact Center                       *
4 // * Copyright (c) Xenialab s.r.l. All Rights Reserved                     *
5 // *                                                                       *
6 // *************************************************************************
7 // *                                                                       *
8 // * Email: info@xcally.com                                                *
9 // * Website: https://www.xcally.com                                       *
10 // *                                                                       *
11 // *************************************************************************
12 // *                                                                       *
13 // * The SOFTWARE PRODUCT is protected by copyright laws and international *
14 // * copyright treaties, as well as other intellectual property laws and   *
15 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                         *
16 // *                                                                       *
17 // *************************************************************************
18 var _0xe4fe=['Error\x20while\x20creating\x20contact:\x20','stringify','cmContact','checkHopper','inspect','insert','into','cm_hopper','phone','scheduledAt','ContactId','createdAt','updatedAt','select','field','NOW()','toString','from','cm_contacts','deletedAt\x20IS\x20NULL','ListId\x20=\x20?','where','phone\x20IS\x20NOT\x20NULL','phone\x20NOT\x20IN\x20(?)','\x20=\x20?','fromQuery','calleridnum','cm_hopper_final','str','VoiceQueue','findAll','outbound','dialCheckDuplicateType','CmList','Lists','get','push','sequelize','query','VoiceQueueId','onlyIfOpen','all','always','CampaignId','Campaign','cmContact,\x20%s,\x20%s','Error\x20processing\x20rows\x20block:','finally','emit','contact:csv_','resume','unlinkSync','Unable\x20to\x20delete\x20temp\x20file:','exit','SIGINT','CSV\x20import\x20process\x20stopped!','resolve','createReadStream','pause','info','CSV\x20parsed\x20correctly!','Error\x20executing\x20contact\x20csv\x20import:','papaparse','../../../mysqldb','../../../config/environment','redis','defaults','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','contact','index','test','The\x20row\x20is\x20empty\x20or\x20the\x20number\x20of\x20parameters\x20does\x20not\x20match\x20the\x20columns!','errors','length','map','message','join','hasOwnProperty','data','firstName','phone\x20not\x20specified!','birthDate','YYYY-MM-DD','isValid','email','ListId','find','duplicate','Duplicate\x20Contact','CmContact','create','keys','then','pick','catch'];(function(_0x462204,_0x36460f){var _0x21b377=function(_0x39f2c7){while(--_0x39f2c7){_0x462204['push'](_0x462204['shift']());}};_0x21b377(++_0x36460f);}(_0xe4fe,0x1ee));var _0xee4f=function(_0x285c85,_0x132c21){_0x285c85=_0x285c85-0x0;var _0x2f81cd=_0xe4fe[_0x285c85];return _0x2f81cd;};'use strict';var BPromise=require('bluebird');var util=require('util');var _=require('lodash');var fs=require('fs');var squel=require('squel');var Papa=require(_0xee4f('0x0'));var Redis=require('ioredis');var db=require(_0xee4f('0x1'))['db'];var config=require(_0xee4f('0x2'));var logger=require('../../../config/logger')('api');config[_0xee4f('0x3')]=_[_0xee4f('0x4')](config['redis'],{'host':_0xee4f('0x5'),'port':0x18eb});var socket=require(_0xee4f('0x6'))(new Redis(config[_0xee4f('0x3')]));require(_0xee4f('0x7'))[_0xee4f('0x8')](socket);try{if(!process[_0xee4f('0x9')][0x2]||process[_0xee4f('0x9')][0x2]===_0xee4f('0xa')||process[_0xee4f('0x9')][0x2]===_0xee4f('0xb')){throw new Error(_0xee4f('0xc'));}var FILEPATH=process['argv'][0x2];if(!process[_0xee4f('0x9')][0x3]||process[_0xee4f('0x9')][0x3]===_0xee4f('0xa')||process[_0xee4f('0x9')][0x3]==='null'||!process[_0xee4f('0x9')][0x4]||process['argv'][0x4]===_0xee4f('0xa')||process[_0xee4f('0x9')][0x4]===_0xee4f('0xb')){throw new Error(_0xee4f('0xd'));}var FIELDS=_[_0xee4f('0xe')](process[_0xee4f('0x9')][0x3][_0xee4f('0xf')](','),process[_0xee4f('0x9')][0x4]['split'](','));if(!process[_0xee4f('0x9')][0x5]||process['argv'][0x5]===_0xee4f('0xa')||process[_0xee4f('0x9')][0x5]===_0xee4f('0xb')){throw new Error(_0xee4f('0x10'));}var LISTID=process[_0xee4f('0x9')][0x5];var COMPANYID=process['argv'][0x6]&&process[_0xee4f('0x9')][0x6]!==_0xee4f('0xa')&&process[_0xee4f('0x9')][0x6]!==_0xee4f('0xb')?process[_0xee4f('0x9')][0x6]:null;var DUPLICATES=process['argv'][0x7]&&process[_0xee4f('0x9')][0x7]!==_0xee4f('0xa')&&process[_0xee4f('0x9')][0x7]!=='null'?process[_0xee4f('0x9')][0x7]:null;if(!process['argv'][0x8]||process[_0xee4f('0x9')][0x8]==='undefined'||process[_0xee4f('0x9')][0x8]===_0xee4f('0xb')){throw new Error(_0xee4f('0x11'));}var SOCKET_TIMESTAMP=process[_0xee4f('0x9')][0x8];}catch(_0x33c793){logger[_0xee4f('0x12')](_0x33c793);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(_0x3f56dd,_0x4e73a5,_0x51fd1c,_0x567710){var _0x208383={'message':_0x4e73a5};_0x208383[_0x3f56dd]=!![];if(_0x51fd1c){_0x208383[_0xee4f('0x13')]=_0x51fd1c;}if(_0x567710){_0x208383[_0xee4f('0x14')]=_0x567710;}return _0x208383;}function isEmail(_0x2ce05c){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))*$/[_0xee4f('0x15')](_0x2ce05c);}function checkRow(_0x514adf,_0x581a63,_0x5d4eb6){return new BPromise(function(_0x428be8,_0x3a365d){if(_['isNil'](_0x514adf)){return _0x3a365d(handleCheckRowError(_0xee4f('0x12'),_0xee4f('0x16'),null,_0x5d4eb6));}if(_0x514adf['errors']&&_0x514adf[_0xee4f('0x17')][_0xee4f('0x18')]){var _0x14afd3=_[_0xee4f('0x19')](_0x514adf[_0xee4f('0x17')],_0xee4f('0x1a'))[_0xee4f('0x1b')](';');return _0x3a365d(handleCheckRowError('error',_0x14afd3,null,_0x5d4eb6));}var _0x33726e={};for(var _0x341623 in FIELDS){if(FIELDS[_0xee4f('0x1c')](_0x341623)&&FIELDS[_0x341623]){_0x33726e[_0x341623]=_0x514adf[_0xee4f('0x1d')][0x0][FIELDS[_0x341623]]||_0x514adf['data'][0x0]['\ufeff'+FIELDS[_0x341623]];}}if(!_0x33726e[_0xee4f('0x1e')]){return _0x3a365d(handleCheckRowError('error','firstName\x20not\x20specified!',null,_0x5d4eb6));}if(!_0x33726e['phone']){return _0x3a365d(handleCheckRowError(_0xee4f('0x12'),_0xee4f('0x1f'),null,_0x5d4eb6));}if(_0x33726e[_0xee4f('0x20')]){var _0x4c3da0=moment(_0x33726e[_0xee4f('0x20')],_0xee4f('0x21'));if(!_0x4c3da0[_0xee4f('0x22')]()){return _0x3a365d(handleCheckRowError('error','birthDate\x20format\x20is\x20invalid,\x20YYYY-MM-DD\x20format\x20is\x20supported!',null,_0x5d4eb6));}}if(_0x33726e[_0xee4f('0x23')]){if(!isEmail(_0x33726e[_0xee4f('0x23')])){return _0x3a365d(handleCheckRowError(_0xee4f('0x12'),'email\x20format\x20is\x20not\x20valid!',null,_0x5d4eb6));}}_0x33726e[_0xee4f('0x24')]=LISTID;_0x33726e['CompanyId']=COMPANYID||undefined;if(DUPLICATES&&DUPLICATES[_0xee4f('0x18')]&&_0x581a63){var _0x5335ce={};for(var _0x133841=0x0,_0x363e72=DUPLICATES[_0xee4f('0x18')];_0x133841<_0x363e72;_0x133841+=0x1){_0x5335ce[DUPLICATES[_0x133841]]=_0x33726e[DUPLICATES[_0x133841]];}var _0x563edb=_[_0xee4f('0x25')](_0x581a63,_0x5335ce);if(_0x563edb){return _0x3a365d(handleCheckRowError(_0xee4f('0x26'),_0xee4f('0x27'),_0x563edb,_0x5d4eb6));}}return db[_0xee4f('0x28')][_0xee4f('0x29')](_0x33726e,{'raw':!![],'hooks':![],'fields':_[_0xee4f('0x2a')](_0x33726e)})[_0xee4f('0x2b')](function(_0x520be9){if(DUPLICATES&&DUPLICATES[_0xee4f('0x18')]&&_0x581a63){_0x581a63['push'](_[_0xee4f('0x2c')](_0x33726e,DUPLICATES));}hopperContacts+=(hopperContacts?',':'')+_0x520be9['id'];return _0x428be8();})[_0xee4f('0x2d')](function(_0x494a62){return _0x3a365d(handleCheckRowError('error',_0xee4f('0x2e')+(_0x494a62[_0xee4f('0x1a')]||JSON[_0xee4f('0x2f')](_0x494a62)),null,_0x5d4eb6));});});}function checkHopper(){function _0xd15f32(){return function(_0x23f2d1){logger['error'](_0xee4f('0x30'),_0xee4f('0x31'),util[_0xee4f('0x32')](_0x23f2d1,{'showHidden':![],'depth':null}));};}var _0x3a1dc1=function(_0x11e128,_0x22ceff){var _0x487190=squel[_0xee4f('0x33')]()[_0xee4f('0x34')](_0xee4f('0x35'))['fromQuery']([_0xee4f('0x36'),_0xee4f('0x37'),_0xee4f('0x38'),_0xee4f('0x24'),_0x22ceff,_0xee4f('0x39'),_0xee4f('0x3a')],squel[_0xee4f('0x3b')]()['field']('phone','phone')[_0xee4f('0x3c')](_0xee4f('0x3d'),_0xee4f('0x37'))[_0xee4f('0x3c')]('id','ContactId')[_0xee4f('0x3c')](LISTID[_0xee4f('0x3e')](),_0xee4f('0x24'))[_0xee4f('0x3c')](_0x11e128['id'][_0xee4f('0x3e')](),_0x22ceff)[_0xee4f('0x3c')](_0xee4f('0x3d'),_0xee4f('0x39'))[_0xee4f('0x3c')](_0xee4f('0x3d'),_0xee4f('0x3a'))[_0xee4f('0x3f')](_0xee4f('0x40'))['where'](_0xee4f('0x41'))['where'](_0xee4f('0x42'),LISTID[_0xee4f('0x3e')]())[_0xee4f('0x43')](_0xee4f('0x44'))[_0xee4f('0x43')](_0xee4f('0x45'),squel[_0xee4f('0x3b')]()[_0xee4f('0x3c')]('phone')['from'](_0xee4f('0x35'))[_0xee4f('0x43')](_0x22ceff+_0xee4f('0x46'),_0x11e128['id'][_0xee4f('0x3e')]())))[_0xee4f('0x3e')]();return _0x487190;};var _0x151e13=function(_0x5aba6e,_0x47a86c){var _0x1437e3=squel[_0xee4f('0x33')]()[_0xee4f('0x34')](_0xee4f('0x35'))[_0xee4f('0x47')]([_0xee4f('0x36'),'scheduledAt','ContactId',_0xee4f('0x24'),_0x47a86c,_0xee4f('0x39'),_0xee4f('0x3a')],squel[_0xee4f('0x3b')]()[_0xee4f('0x3c')](_0xee4f('0x36'),_0xee4f('0x36'))['field']('NOW()',_0xee4f('0x37'))[_0xee4f('0x3c')]('id',_0xee4f('0x38'))[_0xee4f('0x3c')](LISTID[_0xee4f('0x3e')](),'ListId')['field'](_0x5aba6e['id']['toString'](),_0x47a86c)['field'](_0xee4f('0x3d'),_0xee4f('0x39'))[_0xee4f('0x3c')](_0xee4f('0x3d'),_0xee4f('0x3a'))[_0xee4f('0x3f')](_0xee4f('0x40'))[_0xee4f('0x43')](_0xee4f('0x41'))['where'](_0xee4f('0x42'),LISTID['toString']())[_0xee4f('0x43')]('id\x20IN\x20?',squel['str'](hopperContacts))[_0xee4f('0x43')](_0xee4f('0x44'))[_0xee4f('0x43')]('phone\x20NOT\x20IN\x20(?)',squel[_0xee4f('0x3b')]()['field'](_0xee4f('0x48'))[_0xee4f('0x3f')](_0xee4f('0x49'))[_0xee4f('0x43')](_0x47a86c+'\x20=\x20?',_0x5aba6e['id'][_0xee4f('0x3e')]()))['where'](_0xee4f('0x45'),squel[_0xee4f('0x3b')]()[_0xee4f('0x3c')](_0xee4f('0x36'))[_0xee4f('0x3f')](_0xee4f('0x35'))[_0xee4f('0x43')](_0x47a86c+_0xee4f('0x46'),_0x5aba6e['id'][_0xee4f('0x3e')]())))[_0xee4f('0x3e')]();return _0x1437e3;};function _0x496cd(_0x680f47,_0x1d68aa){var _0x3f0bc4=squel[_0xee4f('0x33')]()[_0xee4f('0x34')](_0xee4f('0x35'))['fromQuery']([_0xee4f('0x36'),_0xee4f('0x37'),_0xee4f('0x38'),_0xee4f('0x24'),_0x1d68aa,_0xee4f('0x39'),_0xee4f('0x3a')],squel[_0xee4f('0x3b')]()['field'](_0xee4f('0x36'),_0xee4f('0x36'))[_0xee4f('0x3c')]('NOW()',_0xee4f('0x37'))[_0xee4f('0x3c')]('id','ContactId')[_0xee4f('0x3c')](LISTID['toString'](),_0xee4f('0x24'))['field'](_0x680f47['id'][_0xee4f('0x3e')](),_0x1d68aa)[_0xee4f('0x3c')](_0xee4f('0x3d'),_0xee4f('0x39'))['field'](_0xee4f('0x3d'),_0xee4f('0x3a'))[_0xee4f('0x3f')]('cm_contacts')[_0xee4f('0x43')]('deletedAt\x20IS\x20NULL')[_0xee4f('0x43')](_0xee4f('0x42'),LISTID[_0xee4f('0x3e')]())[_0xee4f('0x43')]('id\x20IN\x20?',squel['str'](hopperContacts))[_0xee4f('0x43')](_0xee4f('0x44')))[_0xee4f('0x3e')]();return _0x3f0bc4;}function _0x3cfca9(_0x2bae33,_0x25a09f){var _0x370c04=squel[_0xee4f('0x33')]()['into']('cm_hopper_black')[_0xee4f('0x47')]([_0xee4f('0x36'),_0xee4f('0x38'),'ListId',_0x25a09f,_0xee4f('0x39'),_0xee4f('0x3a')],squel[_0xee4f('0x3b')]()[_0xee4f('0x3c')](_0xee4f('0x36'),_0xee4f('0x36'))[_0xee4f('0x3c')]('id',_0xee4f('0x38'))[_0xee4f('0x3c')](LISTID[_0xee4f('0x3e')](),_0xee4f('0x24'))['field'](_0x2bae33['id'][_0xee4f('0x3e')](),_0x25a09f)[_0xee4f('0x3c')](_0xee4f('0x3d'),_0xee4f('0x39'))['field'](_0xee4f('0x3d'),_0xee4f('0x3a'))[_0xee4f('0x3f')](_0xee4f('0x40'))['where'](_0xee4f('0x41'))['where'](_0xee4f('0x42'),LISTID[_0xee4f('0x3e')]())['where']('id\x20IN\x20?',squel[_0xee4f('0x4a')](hopperContacts))['where'](_0xee4f('0x44')))[_0xee4f('0x3e')]();return _0x370c04;}return db[_0xee4f('0x4b')][_0xee4f('0x4c')]({'where':{'type':_0xee4f('0x4d')},'attributes':['id',_0xee4f('0x4e')],'include':[{'model':db[_0xee4f('0x4f')],'as':_0xee4f('0x50'),'where':{'id':LISTID}}]})[_0xee4f('0x2b')](function(_0x39decc){var _0x12ee1b=[];if(_0x39decc){var _0x4eb025;for(var _0x5455fc=0x0,_0x5b8971;_0x5455fc<_0x39decc[_0xee4f('0x18')];_0x5455fc+=0x1){_0x5b8971=_0x39decc[_0x5455fc][_0xee4f('0x51')]({'plain':!![]});switch(_0x5b8971[_0xee4f('0x4e')]){case'always':_0x12ee1b[_0xee4f('0x52')](db[_0xee4f('0x53')][_0xee4f('0x54')](_0x151e13(_0x5b8971,_0xee4f('0x55')))[_0xee4f('0x2b')](function(){})[_0xee4f('0x2d')](_0xd15f32()));break;case _0xee4f('0x56'):_0x12ee1b[_0xee4f('0x52')](db[_0xee4f('0x53')][_0xee4f('0x54')](_0x3a1dc1(_0x5b8971,_0xee4f('0x55')))['then'](function(){})[_0xee4f('0x2d')](_0xd15f32()));break;default:_0x12ee1b[_0xee4f('0x52')](db['sequelize'][_0xee4f('0x54')](_0x496cd(_0x5b8971,_0xee4f('0x55')))[_0xee4f('0x2b')](function(){})[_0xee4f('0x2d')](_0xd15f32()));}}}return _0x12ee1b;})[_0xee4f('0x57')]()[_0xee4f('0x2b')](function(){return db['VoiceQueue']['findAll']({'where':{'type':'outbound'},'attributes':['id'],'include':[{'model':db['CmList'],'as':'BlackLists','where':{'id':LISTID}}]})['then'](function(_0x5e59c7){var _0x520587=[];if(_0x5e59c7){var _0x36b1e4;for(var _0x3fc292=0x0,_0x4345d5;_0x3fc292<_0x5e59c7[_0xee4f('0x18')];_0x3fc292+=0x1){_0x4345d5=_0x5e59c7[_0x3fc292][_0xee4f('0x51')]({'plain':!![]});_0x520587[_0xee4f('0x52')](db['sequelize'][_0xee4f('0x54')](_0x3cfca9(_0x4345d5,_0xee4f('0x55')))[_0xee4f('0x2b')](function(){})['catch'](_0xd15f32()));}}return _0x520587;})[_0xee4f('0x57')]();})[_0xee4f('0x2b')](function(){return db['Campaign'][_0xee4f('0x4c')]({'attributes':['id','dialCheckDuplicateType'],'include':[{'model':db[_0xee4f('0x4f')],'as':_0xee4f('0x50'),'where':{'id':LISTID}}]})[_0xee4f('0x2b')](function(_0x2af5cf){var _0x204d8b=[];if(_0x2af5cf){for(var _0x3dcc50=0x0,_0xf65b58;_0x3dcc50<_0x2af5cf[_0xee4f('0x18')];_0x3dcc50+=0x1){_0xf65b58=_0x2af5cf[_0x3dcc50][_0xee4f('0x51')]({'plain':!![]});switch(_0xf65b58[_0xee4f('0x4e')]){case _0xee4f('0x58'):_0x204d8b['push'](db['sequelize'][_0xee4f('0x54')](_0x151e13(_0xf65b58,_0xee4f('0x59')))[_0xee4f('0x2b')](function(){})[_0xee4f('0x2d')](_0xd15f32()));break;case _0xee4f('0x56'):_0x204d8b[_0xee4f('0x52')](db[_0xee4f('0x53')][_0xee4f('0x54')](_0x3a1dc1(_0xf65b58,_0xee4f('0x59')))['then'](function(){})[_0xee4f('0x2d')](_0xd15f32()));break;default:_0x204d8b[_0xee4f('0x52')](db['sequelize'][_0xee4f('0x54')](_0x496cd(_0xf65b58,'CampaignId'))[_0xee4f('0x2b')](function(){})[_0xee4f('0x2d')](_0xd15f32()));}}}return _0x204d8b;})[_0xee4f('0x57')]();})[_0xee4f('0x2b')](function(){return db[_0xee4f('0x5a')]['findAll']({'attributes':['id'],'include':[{'model':db[_0xee4f('0x4f')],'as':'BlackLists','where':{'id':LISTID}}]})[_0xee4f('0x2b')](function(_0x23ae50){var _0x5cc541=[];if(_0x23ae50){for(var _0x3b7f14=0x0,_0x341fce;_0x3b7f14<_0x23ae50[_0xee4f('0x18')];_0x3b7f14+=0x1){_0x341fce=_0x23ae50[_0x3b7f14][_0xee4f('0x51')]({'plain':!![]});_0x5cc541['push'](db[_0xee4f('0x53')][_0xee4f('0x54')](_0x3cfca9(_0x341fce,_0xee4f('0x59')))['then'](function(){})[_0xee4f('0x2d')](_0xd15f32()));}}return _0x5cc541;})[_0xee4f('0x57')]();})[_0xee4f('0x2d')](function(_0x33a091){logger[_0xee4f('0x12')](_0xee4f('0x5b'),'generalCheckHopper',_0x33a091[_0xee4f('0x1a')]);});}var processPromises=function(_0x1dcbec){return BPromise[_0xee4f('0x57')](promises)[_0xee4f('0x2b')](function(_0x5e5011){})[_0xee4f('0x2d')](function(_0x1dd4e5){logger['error'](_0xee4f('0x5c'),JSON[_0xee4f('0x2f')](_0x1dd4e5));})[_0xee4f('0x5d')](function(){socket[_0xee4f('0x5e')](_0xee4f('0x5f')+SOCKET_TIMESTAMP,{'success':success,'errors':errors,'duplicates':duplicates,'rows':rows});promises=[];success=0x0;errors=0x0;duplicates=0x0;rows=[];if(_0x1dcbec){return _0x1dcbec[_0xee4f('0x60')]();}});};var endCsv=function(){return BPromise['resolve']()[_0xee4f('0x2b')](function(){if(hopperContacts){return checkHopper();}})[_0xee4f('0x2b')](function(){socket[_0xee4f('0x5e')](_0xee4f('0x5f')+SOCKET_TIMESTAMP,{'finished':!![],'success':success,'errors':errors,'duplicates':duplicates,'rows':rows});try{fs[_0xee4f('0x61')](FILEPATH);}catch(_0x1d454c){logger[_0xee4f('0x12')](_0xee4f('0x62'),JSON[_0xee4f('0x2f')](_0x1d454c));}finally{process[_0xee4f('0x63')](0x0);}});};process['on'](_0xee4f('0x64'),function(){logger['info'](_0xee4f('0x65'));endCsv();});function main(){return BPromise[_0xee4f('0x66')]()[_0xee4f('0x2b')](function(){if(DUPLICATES){DUPLICATES=DUPLICATES[_0xee4f('0xf')](',');return db[_0xee4f('0x28')][_0xee4f('0x4c')]({'where':{'ListId':LISTID},'attributes':DUPLICATES,'raw':!![]});}})[_0xee4f('0x2b')](function(_0x4d8e56){var _0x48b8b2=fs[_0xee4f('0x67')](FILEPATH,{'highWaterMark':0xf*0x400*0x400});Papa['parse'](_0x48b8b2,{'header':!![],'skipEmptyLines':!![],'step':function(_0x177033,_0x13dbe4){total+=0x1;var _0x1ddc25=total;promises[_0xee4f('0x52')](checkRow(_0x177033,_0x4d8e56,_0x1ddc25)[_0xee4f('0x2b')](function(){success+=0x1;})[_0xee4f('0x2d')](function(_0x10fd25){if(_0x10fd25[_0xee4f('0x12')]){errors+=0x1;delete _0x10fd25['error'];}else if(_0x10fd25['duplicate']){duplicates+=0x1;delete _0x10fd25[_0xee4f('0x26')];}rows[_0xee4f('0x52')](_0x10fd25);}));if(total%0xc8===0x0){_0x13dbe4[_0xee4f('0x68')]();return processPromises(_0x13dbe4);}},'complete':function(){return processPromises()[_0xee4f('0x2b')](function(){logger[_0xee4f('0x69')](_0xee4f('0x6a'));endCsv();});},'error':function(_0x22541e,_0x115f26){logger['info']('CSV\x20parse\x20error',JSON[_0xee4f('0x2f')](_0x22541e));endCsv();}});})[_0xee4f('0x2d')](function(_0x495d78){logger[_0xee4f('0x12')](_0xee4f('0x6b'),JSON['stringify'](_0x495d78));});}main();