Built motion from commit d5e4af8c.|2.6.23
[motion2.git] / server / components / import / cm / csv2.js
index c3c9f11..8c2d169 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xa66d=['voice_queues','voice_queues_has_cm_lists','voice_queues.id\x20=\x20voice_queues_has_cm_lists.VoiceQueueId','voice_queues_has_cm_lists.CmListId=','then','timezones','dialTimezone','isNil','utcOffset','set','offset','main','stringify','send','start','binding','socket_timestamp','root','.csv','includes','header',',utcOffset','writeFileSync','parse','rows','errors','data','hasOwnProperty','trim','replace','isValid','scheduledat\x20wrong\x20format\x20(YYYY-MM-DD\x20HH:mm:ss)','isNaN','isNumber','agent\x20not\x20exists','email','email\x20wrong\x20format','dateOfBirth','YYYY-MM-DD','dateOfBirth\x20wrong\x20format\x20(YYYY-MM-DD)','firstName','\x20not\x20specified','SystemRow','appendFileSync','contact:import:','Abort\x20parser','SystemError','step','duplicates','cm_contacts_','CREATE\x20TABLE\x20','\x20LIKE\x20cm_contacts;','campaigns_','(id\x20int,dialTimezone\x20varchar(255),offset\x20int);','each','LOAD\x20DATA\x20LOCAL\x20INFILE\x20\x27%s\x27\x20INTO\x20TABLE\x20%s\x20CHARACTER\x20SET\x20UTF8\x20FIELDS\x20TERMINATED\x20BY\x20\x27,\x27\x20ENCLOSED\x20BY\x20\x27\x22\x27\x20LINES\x20TERMINATED\x20BY\x20\x27\x0a\x27\x20IGNORE\x201\x20ROWS\x20(%s)\x20SET\x20id\x20=\x20NULL,\x20ListId\x20=\x20%s,\x20CompanyId\x20=\x20%s,\x20createdAt\x20=\x20\x27%s\x27,\x20updatedAt\x20=\x20\x27%s\x27',',\x20scheduledAt\x20=\x20NOW()','voice_queues_has_cm_blacklists','VoiceQueueId','campaigns_has_cm_blacklists','CampaignId','DROP\x20TABLE\x20','finish','affectedRows','emit','unlink','complete','argv','server/files/tmp','binding\x20doesn\x27t\x20exists','phone\x20is\x20mandatory','firstName\x20is\x20mandatory','ListId\x20is\x20mandatory','body\x20id\x20mandatory','No\x20agent\x20available','SIGINT','uncaughtException','path','lodash','papaparse','moment','squel','ioredis','../../../mysqldb','../../../config/environment','../../../config/environment/shared','../../../config/logger','redis','defaults','localhost','format','YYYY-MM-DD\x20HH:mm:ss','select','field','phone','from','where','join','cm_contacts.phone','cm_contacts.scheduledat','cm_contacts.ListId','cm_contacts.createdAt','cm_contacts.priority','cm_contacts.UserId','insert','into','cm_hopper','fromQuery','scheduledat','ListId','updatedAt','priority','UserId','recallme','fields','cm_contacts','cm_contacts.ListId\x20=\x20','.CmListId\x20=\x20?','cm_contacts.createdAt\x20=\x20?','cm_contacts.phone\x20NOT\x20IN\x20(?)','\x22always\x22','\x22onlyIfOpen\x22','toString','cm_contacts.id','ContactId','.CmListId','.id\x20=\x20','cm_hopper_black','\x20=\x20?','date_add(cm_contacts.scheduledat,interval\x20','.offset-cm_contacts.utcOffset\x20minute)','cm_contacts.updatedAt','createdAt','ListId\x20=\x20?','keys','CompanyId','id\x20IN\x20?','MIN(id)','min_id','group','info','Received\x20SIGINT','error','exit','push','code','message','sequelize','query','spread','campaigns.dialTimezone','campaigns','campaigns_has_cm_lists','campaigns_has_cm_lists.CmListId=','length','all','catch','voice_queues.dialTimezone'];(function(_0x5522d4,_0x453448){var _0x23a3f9=function(_0x1a8cbc){while(--_0x1a8cbc){_0x5522d4['push'](_0x5522d4['shift']());}};_0x23a3f9(++_0x453448);}(_0xa66d,0xeb));var _0xda66=function(_0xa6603d,_0x374178){_0xa6603d=_0xa6603d-0x0;var _0x3500d8=_0xa66d[_0xa6603d];return _0x3500d8;};'use strict';var fs=require('fs');var path=require(_0xda66('0x0'));var _=require(_0xda66('0x1'));var Papa=require(_0xda66('0x2'));var util=require('util');var BPromise=require('bluebird');var moment=require(_0xda66('0x3'));var squel=require(_0xda66('0x4'));var Redis=require(_0xda66('0x5'));var db=require(_0xda66('0x6'))['db'];var config=require(_0xda66('0x7'));var shared=require(_0xda66('0x8'));var logger=require(_0xda66('0x9'))('import');config[_0xda66('0xa')]=_[_0xda66('0xb')](config[_0xda66('0xa')],{'host':_0xda66('0xc'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0xda66('0xa')]));var stats={'finish':![],'errors':[],'rows':0x0,'affectedRows':0x0};var results=[];var stopped=![];var tmp_voice_queues;var tmp_campaigns;var tzOffset=0x0;var hasTZ;var NOW=moment()[_0xda66('0xd')](_0xda66('0xe'));function isEmail(_0x3d7d41){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))*$/['test'](_0x3d7d41);}function selectNotIn(_0x407f96,_0x219417,_0x3c3ff8,_0x3690b5,_0x5c1238){return squel[_0xda66('0xf')]()[_0xda66('0x10')](_0xda66('0x11'))[_0xda66('0x12')](_0x3690b5)['join'](_0x219417,null,_0x219417+'.id\x20=\x20'+_0x3690b5+'.'+_0x3c3ff8)[_0xda66('0x13')](_0x3690b5+'.'+_0x3c3ff8+'\x20=\x20'+_0x407f96+'.'+_0x3c3ff8)[_0xda66('0x13')](_0x219417+'.dialCheckDuplicateType\x20IN\x20('+_0x5c1238[_0xda66('0x14')]()+')');}function insertCmHopper(_0x1aa462,_0x18c68c,_0x1e5905,_0x45c0c4,_0x2f745e){var _0x5a351b=[_0xda66('0x15'),_0xda66('0x16'),'cm_contacts.id',_0xda66('0x17'),_0x18c68c+'.'+_0x45c0c4,_0xda66('0x18'),'cm_contacts.updatedAt',_0xda66('0x19'),_0xda66('0x1a'),'\x22'+_0x2f745e+'\x22'];return squel[_0xda66('0x1b')]()[_0xda66('0x1c')](_0xda66('0x1d'))[_0xda66('0x1e')](['phone',_0xda66('0x1f'),'ContactId',_0xda66('0x20'),_0x45c0c4,'createdAt',_0xda66('0x21'),_0xda66('0x22'),_0xda66('0x23'),_0xda66('0x24')],squel[_0xda66('0xf')]()[_0xda66('0x25')](_0x5a351b)[_0xda66('0x12')](_0x18c68c)['join'](_0xda66('0x26'),null,_0xda66('0x27')+_0x18c68c+'.CmListId')['join'](_0x1e5905,null,_0x1e5905+'.id\x20=\x20'+_0x18c68c+'.'+_0x45c0c4)[_0xda66('0x13')](_0x18c68c+_0xda66('0x28'),_0x1aa462)['where'](_0xda66('0x29'),NOW)['where'](_0xda66('0x2a'),selectNotIn(_0x18c68c,_0x1e5905,_0x45c0c4,'cm_hopper',[_0xda66('0x2b'),_0xda66('0x2c')]))[_0xda66('0x13')]('cm_contacts.phone\x20NOT\x20IN\x20(?)',selectNotIn(_0x18c68c,_0x1e5905,_0x45c0c4,'cm_hopper',['\x22always\x22'])))[_0xda66('0x2d')]();}function insertCmHopperBlack(_0x304921,_0x3e4f83,_0x4f1fdd,_0x52c387){var _0x4bd851=['cm_contacts.phone',_0xda66('0x2e'),_0xda66('0x17'),_0x3e4f83+'.'+_0x52c387,_0xda66('0x18'),'cm_contacts.updatedAt'];return squel[_0xda66('0x1b')]()[_0xda66('0x1c')]('cm_hopper_black')[_0xda66('0x1e')]([_0xda66('0x11'),_0xda66('0x2f'),'ListId',_0x52c387,'createdAt',_0xda66('0x21')],squel[_0xda66('0xf')]()[_0xda66('0x25')](_0x4bd851)[_0xda66('0x12')](_0x3e4f83)['join']('cm_contacts',null,_0xda66('0x27')+_0x3e4f83+_0xda66('0x30'))[_0xda66('0x14')](_0x4f1fdd,null,_0x4f1fdd+_0xda66('0x31')+_0x3e4f83+'.'+_0x52c387)[_0xda66('0x13')](_0x3e4f83+_0xda66('0x28'),_0x304921)[_0xda66('0x13')](_0xda66('0x29'),NOW)[_0xda66('0x13')](_0xda66('0x2a'),squel[_0xda66('0xf')]()[_0xda66('0x10')](_0xda66('0x11'))[_0xda66('0x12')](_0xda66('0x32'))['where']('ListId\x20=\x20?',_0x304921)[_0xda66('0x13')](_0x52c387+_0xda66('0x33'),_0x3e4f83+'.'+_0x52c387)))[_0xda66('0x2d')]();}function insertTzCmHopper(_0x307873,_0x22a9ca,_0x391e17,_0x29cfcf,_0x2da5b5,_0x26dfbd){var _0xd65d4c=[_0xda66('0x15'),_0xda66('0x34')+_0x26dfbd+_0xda66('0x35'),_0xda66('0x2e'),_0xda66('0x17'),_0x22a9ca+'.'+_0x29cfcf,_0xda66('0x18'),_0xda66('0x36'),_0xda66('0x19'),_0xda66('0x1a'),'\x22'+_0x2da5b5+'\x22'];var _0x800af2=squel[_0xda66('0x1b')]()[_0xda66('0x1c')](_0xda66('0x1d'))[_0xda66('0x1e')]([_0xda66('0x11'),'scheduledat',_0xda66('0x2f'),_0xda66('0x20'),_0x29cfcf,'createdAt',_0xda66('0x21'),'priority',_0xda66('0x23'),_0xda66('0x24')],squel[_0xda66('0xf')]()[_0xda66('0x25')](_0xd65d4c)['from'](_0x22a9ca)[_0xda66('0x14')](_0xda66('0x26'),null,'cm_contacts.ListId\x20=\x20'+_0x22a9ca+_0xda66('0x30'))[_0xda66('0x14')](_0x391e17,null,_0x391e17+_0xda66('0x31')+_0x22a9ca+'.'+_0x29cfcf)[_0xda66('0x14')](_0x26dfbd,null,_0x26dfbd+_0xda66('0x31')+_0x22a9ca+'.'+_0x29cfcf)['where'](_0x22a9ca+_0xda66('0x28'),_0x307873)['where'](_0xda66('0x29'),NOW)[_0xda66('0x13')](_0xda66('0x2a'),selectNotIn(_0x22a9ca,_0x391e17,_0x29cfcf,_0xda66('0x1d'),['\x22always\x22','\x22onlyIfOpen\x22']))[_0xda66('0x13')](_0xda66('0x2a'),selectNotIn(_0x22a9ca,_0x391e17,_0x29cfcf,_0xda66('0x1d'),[_0xda66('0x2b')])))['toString']();return _0x800af2;}function insertTzCmHopperBlack(_0x57e39b,_0x42c152,_0x17193e,_0x1cea17){var _0x2833be=['cm_contacts.phone','cm_contacts.id','cm_contacts.ListId',_0x42c152+'.'+_0x1cea17,'cm_contacts.createdAt','cm_contacts.updatedAt'];return squel[_0xda66('0x1b')]()[_0xda66('0x1c')](_0xda66('0x32'))[_0xda66('0x1e')]([_0xda66('0x11'),_0xda66('0x2f'),_0xda66('0x20'),_0x1cea17,_0xda66('0x37'),_0xda66('0x21')],squel[_0xda66('0xf')]()['fields'](_0x2833be)['from'](_0x42c152)[_0xda66('0x14')](_0xda66('0x26'),null,_0xda66('0x27')+_0x42c152+_0xda66('0x30'))[_0xda66('0x14')](_0x17193e,null,_0x17193e+_0xda66('0x31')+_0x42c152+'.'+_0x1cea17)[_0xda66('0x13')](_0x42c152+_0xda66('0x28'),_0x57e39b)[_0xda66('0x13')]('cm_contacts.createdAt\x20=\x20?',NOW)[_0xda66('0x13')]('cm_contacts.phone\x20NOT\x20IN\x20(?)',squel[_0xda66('0xf')]()[_0xda66('0x10')](_0xda66('0x11'))[_0xda66('0x12')](_0xda66('0x32'))[_0xda66('0x13')](_0xda66('0x38'),_0x57e39b)[_0xda66('0x13')](_0x1cea17+_0xda66('0x33'),_0x42c152+'.'+_0x1cea17)))[_0xda66('0x2d')]();}function insertCmContact(_0x39765a,_0x1afe28,_0x2cff05,_0x436c5f){var _0x15fa08=_['concat'](_[_0xda66('0x39')](_0x436c5f),[_0xda66('0x20'),_0xda66('0x3a'),_0xda66('0x37'),_0xda66('0x21')]);return squel[_0xda66('0x1b')]()[_0xda66('0x1c')]('cm_contacts')[_0xda66('0x1e')](_0x15fa08,squel[_0xda66('0xf')]()['fields'](_0x15fa08)['from'](_0x1afe28)[_0xda66('0x13')]('('+_0x2cff05['join'](',')+')\x20NOT\x20IN\x20?',squel[_0xda66('0xf')]()['fields'](_0x2cff05)[_0xda66('0x12')](_0xda66('0x26'))[_0xda66('0x13')](_0xda66('0x38'),_0x39765a)[_0xda66('0x13')]('deletedAt\x20IS\x20NULL'))[_0xda66('0x13')](_0xda66('0x3b'),squel['select']()[_0xda66('0x10')](_0xda66('0x3c'),_0xda66('0x3d'))[_0xda66('0x12')](_0x1afe28)[_0xda66('0x3e')](_0x2cff05['join'](','))))['toString']();}function handleStop(){logger[_0xda66('0x3f')](_0xda66('0x40'));stopped=!![];}function handleUncaughtException(_0x1cacea){logger[_0xda66('0x41')](_0x1cacea['message']);process[_0xda66('0x42')](0x1);}function handleError(_0xc7e10b,_0x572ef6){stats['errors'][_0xda66('0x43')]({'name':_0x572ef6[_0xda66('0x44')],'message':_0x572ef6[_0xda66('0x45')],'row':_0xc7e10b});}function handleQuery(_0x842529){logger[_0xda66('0x3f')](_0x842529);return db[_0xda66('0x46')][_0xda66('0x47')](_0x842529)[_0xda66('0x48')](function(_0x20ceaf){results[_0xda66('0x43')](_0x20ceaf);})['catch'](function(_0x39995b){logger[_0xda66('0x41')](_0x39995b[_0xda66('0x45')]);});}function updateTzCampaigns(_0xbc1d58){return new Promise(function(_0x54f7c3,_0x281fa9){var _0xdcc283=squel['select']()[_0xda66('0x25')](['campaigns.id',_0xda66('0x49')])[_0xda66('0x12')](_0xda66('0x4a'))[_0xda66('0x14')](_0xda66('0x4b'),null,'campaigns.id\x20=\x20campaigns_has_cm_lists.CampaignId')['where'](_0xda66('0x4c')+_0xbc1d58);db[_0xda66('0x46')]['query'](_0xdcc283[_0xda66('0x2d')]())[_0xda66('0x48')](function(_0x3490ee){var _0x5afd93=[];for(var _0x18234f=0x0;_0x18234f<_0x3490ee[_0xda66('0x4d')];_0x18234f++){_0x5afd93['push'](getTimezoneData(_0x3490ee[_0x18234f],tmp_campaigns));}BPromise[_0xda66('0x4e')](_0x5afd93)['then'](function(){_0x54f7c3({'val':0x1});});})[_0xda66('0x4f')](function(_0x15a155){logger[_0xda66('0x41')](_0x15a155[_0xda66('0x45')]);_0x54f7c3({'val':0x0});});});}function updateTzVoiceQueues(_0x2e1138){return new Promise(function(_0x4e8255,_0x4e1937){var _0x2ec57a=squel[_0xda66('0xf')]()[_0xda66('0x25')](['voice_queues.id',_0xda66('0x50')])[_0xda66('0x12')](_0xda66('0x51'))[_0xda66('0x14')](_0xda66('0x52'),null,_0xda66('0x53'))[_0xda66('0x13')](_0xda66('0x54')+_0x2e1138);db['sequelize']['query'](_0x2ec57a[_0xda66('0x2d')]())[_0xda66('0x48')](function(_0x2d84ef){var _0x200800=[];for(var _0x55ef28=0x0;_0x55ef28<_0x2d84ef[_0xda66('0x4d')];_0x55ef28++){_0x200800['push'](getTimezoneData(_0x2d84ef[_0x55ef28],tmp_voice_queues));}BPromise[_0xda66('0x4e')](_0x200800)[_0xda66('0x55')](function(){_0x4e8255({'val':0x1});});})[_0xda66('0x4f')](function(_0x48ac14){logger[_0xda66('0x41')](_0x48ac14[_0xda66('0x45')]);_0x4e8255({'val':0x0});});});}function getTimezoneData(_0x19781e,_0x1119bb){return new Promise(function(_0x4332ff,_0x314741){var _0x59487b=shared[_0xda66('0x56')];var _0x2aa37f=_0x59487b[_0x19781e[_0xda66('0x57')]];if(_[_0xda66('0x58')](_0x2aa37f)){_0x4332ff({'ret':0x1});}else{var _0x1db818=_0x2aa37f[_0xda66('0x59')];var _0x4457f8=squel['insert']()[_0xda66('0x1c')](_0x1119bb)[_0xda66('0x5a')]('id',_0x19781e['id'])[_0xda66('0x5a')](_0xda66('0x5b'),_0x1db818)[_0xda66('0x5a')](_0xda66('0x57'),_0x19781e[_0xda66('0x57')])[_0xda66('0x2d')]();return db[_0xda66('0x46')][_0xda66('0x47')](_0x4457f8)[_0xda66('0x48')](function(_0x13411a){_0x4332ff({'ret':0x1});})[_0xda66('0x4f')](function(_0x1aa11c){logger[_0xda66('0x41')](_0x1aa11c[_0xda66('0x45')]);_0x314741({'ret':0x1});});}});}function handleTZQuery(_0x26cdd7){logger[_0xda66('0x3f')](_0x26cdd7);return db[_0xda66('0x46')][_0xda66('0x47')](_0x26cdd7)[_0xda66('0x48')](function(_0x160f7d){})[_0xda66('0x4f')](function(_0x3156ad){logger[_0xda66('0x41')](_0x3156ad[_0xda66('0x45')]);});}function main(_0x1fed52,_0x2b73ac,_0x37b50f,_0x5a60ed){logger[_0xda66('0x3f')](_0xda66('0x5c'),_0x1fed52,JSON[_0xda66('0x5d')](_0x2b73ac));process[_0xda66('0x5e')](_0xda66('0x5f'));var _0x857ed0=_0x2b73ac[_0xda66('0x60')];var _0xe0c439=_0x2b73ac[_0xda66('0x61')];var _0x3cccd3=path[_0xda66('0x14')](config[_0xda66('0x62')],'server/files/tmp',_0xe0c439+_0xda66('0x63'));hasTZ=_[_0xda66('0x39')](_0x857ed0)[_0xda66('0x64')]('dialTimezone');var _0x46caf0=_[_0xda66('0x39')](_0x857ed0)['join']();logger[_0xda66('0x3f')](_0xda66('0x65'),_0x46caf0);if(hasTZ)_0x46caf0+=_0xda66('0x66');fs[_0xda66('0x67')](_0x3cccd3,_0x46caf0+'\x0a');Papa[_0xda66('0x68')](fs['createReadStream'](_0x1fed52),{'header':!![],'skipEmptyLines':!![],'step':function(_0x5111be,_0x247895){try{for(var _0x408bfd=0x0,_0x4561d4=[];_0x408bfd<_0x5111be['data'][_0xda66('0x4d')];_0x408bfd++){stats[_0xda66('0x69')]+=0x1;if(_0x5111be[_0xda66('0x6a')][_0x408bfd]){handleError(_0x5111be[_0xda66('0x6b')][_0x408bfd],_0x5111be[_0xda66('0x6a')][_0x408bfd]);}else{var _0x4a9101=[];for(var _0x5ed874 in _0x857ed0){if(_0x857ed0[_0xda66('0x6c')](_0x5ed874)){if(_0x5111be[_0xda66('0x6b')][_0x408bfd][_0x857ed0[_0x5ed874]]){var _0x4bde1a=_[_0xda66('0x6d')](_0x5111be[_0xda66('0x6b')][_0x408bfd][_0x857ed0[_0x5ed874]][_0xda66('0x6e')](/"/g,'\x27'));switch(_0x5ed874){case _0xda66('0x1f'):var _0x47cc49=moment(_0x4bde1a,_0xda66('0xe'),!![]);if(_0x47cc49[_0xda66('0x6f')]()){_0x4561d4[_0xda66('0x43')]('\x22'+_0x4bde1a+'\x22');}else{_0x4a9101[_0xda66('0x43')](_0xda66('0x70'));}break;case _0xda66('0x22'):var _0x35d89c=parseInt(_0x4bde1a);_0x4bde1a=_[_0xda66('0x71')](_0x35d89c)||_0x35d89c<0x0||_0x35d89c>0x4?_0x5a60ed?0x3:0x2:_0x35d89c;_0x4561d4[_0xda66('0x43')]('\x22'+_0x4bde1a+'\x22');break;case _0xda66('0x23'):var _0x9badfa=parseInt(_0x4bde1a);if(_[_0xda66('0x72')](_0x9badfa)&&_[_0xda66('0x64')](_0x37b50f,_0x9badfa)){_0x4561d4[_0xda66('0x43')]('\x22'+_0x9badfa+'\x22');}else{_0x4a9101[_0xda66('0x43')](_0xda66('0x73'));}break;case _0xda66('0x74'):if(isEmail(_0x4bde1a)){_0x4561d4[_0xda66('0x43')]('\x22'+_0x4bde1a+'\x22');}else{_0x4a9101['push'](_0xda66('0x75'));}break;case _0xda66('0x76'):var _0x5231d0=moment(_0x4bde1a,_0xda66('0x77'),!![]);if(_0x5231d0[_0xda66('0x6f')]()){_0x4561d4[_0xda66('0x43')]('\x22'+_0x4bde1a+'\x22');}else{_0x4a9101[_0xda66('0x43')](_0xda66('0x78'));}break;case'dialTimezone':var _0x4d765d=shared[_0xda66('0x56')];var _0x3063bd=_0x4d765d[_0x4bde1a];if(!_[_0xda66('0x58')](_0x3063bd)){var _0x284957=_0x3063bd[_0xda66('0x59')];_0x4561d4['push']('\x22'+_0x4bde1a+'\x22');_0x4561d4[_0xda66('0x43')]('\x22'+_0x284957+'\x22');}break;default:_0x4561d4[_0xda66('0x43')]('\x22'+_0x4bde1a+'\x22');}}else{switch(_0x5ed874){case _0xda66('0x79'):case _0xda66('0x11'):_0x4a9101['push'](_0x5ed874+_0xda66('0x7a'));break;default:_0x4561d4[_0xda66('0x43')]('\x22\x22');}}}}if(_0x4a9101['length']){handleError(_0x5111be[_0xda66('0x6b')][_0x408bfd],{'code':_0xda66('0x7b'),'message':_0x4a9101['join']()});}else{fs[_0xda66('0x7c')](_0x3cccd3,_0x4561d4['join']()+'\x0a');}_0x4561d4=[];}if(!(stats[_0xda66('0x69')]%0xc8)){socket['emit'](_0xda66('0x7d')+_0xe0c439,stats);stats[_0xda66('0x6a')]=[];}}if(stopped){logger['info'](_0xda66('0x7e'));_0x247895['abort']();}}catch(_0xf0c894){handleError(_0x5111be[_0xda66('0x6b')][_0x408bfd],{'code':_0xda66('0x7f'),'message':_0xf0c894[_0xda66('0x45')]});logger['error'](_0xda66('0x80'),_0xf0c894['message']);}},'complete':function(){try{var _0x216c2c=[];var _0x149240=[];var _0x3857a2=_0xda66('0x26');if(_0x2b73ac['duplicates']&&_0x2b73ac[_0xda66('0x81')]['length']){_0x3857a2=_0xda66('0x82')+_0xe0c439;_0x216c2c['push'](_0xda66('0x83')+_0x3857a2+_0xda66('0x84'));}tmp_campaigns=_0xda66('0x85')+_0xe0c439;tmp_voice_queues='voice_queues_'+_0xe0c439;_0x149240[_0xda66('0x43')](_0xda66('0x83')+tmp_campaigns+_0xda66('0x86'));_0x149240[_0xda66('0x43')](_0xda66('0x83')+tmp_voice_queues+_0xda66('0x86'));BPromise[_0xda66('0x87')](_0x149240,handleTZQuery)['then'](function(_0x24cae2){updateTzCampaigns(_0x2b73ac['ListId'])[_0xda66('0x55')](function(_0x33e286){updateTzVoiceQueues(_0x2b73ac[_0xda66('0x20')])['then'](function(_0x32c228){var _0x5de96c=util['format'](_0xda66('0x88'),_0x3cccd3,_0x3857a2,_0x46caf0,_0x2b73ac[_0xda66('0x20')],_0x2b73ac[_0xda66('0x3a')]||null,NOW,NOW);if(_[_0xda66('0x58')](_0x857ed0[_0xda66('0x1f')])){_0x5de96c+=_0xda66('0x89');}_0x216c2c[_0xda66('0x43')](_0x5de96c);if(_0x2b73ac[_0xda66('0x81')]&&_0x2b73ac[_0xda66('0x81')]['length']){_0x216c2c['push'](insertCmContact(_0x2b73ac[_0xda66('0x20')],_0x3857a2,_0x2b73ac[_0xda66('0x81')],_0x857ed0));_0x216c2c[_0xda66('0x43')]('DROP\x20TABLE\x20'+_0x3857a2+';');}if(hasTZ){_0x216c2c[_0xda66('0x43')](insertTzCmHopper(_0x2b73ac[_0xda66('0x20')],'voice_queues_has_cm_lists','voice_queues','VoiceQueueId',_0x5a60ed,tmp_voice_queues));_0x216c2c[_0xda66('0x43')](insertTzCmHopperBlack(_0x2b73ac[_0xda66('0x20')],_0xda66('0x8a'),_0xda66('0x51'),_0xda66('0x8b')));_0x216c2c[_0xda66('0x43')](insertTzCmHopper(_0x2b73ac[_0xda66('0x20')],_0xda66('0x4b'),_0xda66('0x4a'),'CampaignId',_0x5a60ed,tmp_campaigns));_0x216c2c['push'](insertTzCmHopperBlack(_0x2b73ac[_0xda66('0x20')],_0xda66('0x8c'),_0xda66('0x4a'),'CampaignId'));}else{_0x216c2c[_0xda66('0x43')](insertCmHopper(_0x2b73ac['ListId'],_0xda66('0x52'),'voice_queues',_0xda66('0x8b'),_0x5a60ed));_0x216c2c[_0xda66('0x43')](insertCmHopperBlack(_0x2b73ac[_0xda66('0x20')],_0xda66('0x8a'),_0xda66('0x51'),_0xda66('0x8b')));_0x216c2c[_0xda66('0x43')](insertCmHopper(_0x2b73ac[_0xda66('0x20')],'campaigns_has_cm_lists',_0xda66('0x4a'),_0xda66('0x8d'),_0x5a60ed));_0x216c2c['push'](insertCmHopperBlack(_0x2b73ac[_0xda66('0x20')],'campaigns_has_cm_blacklists',_0xda66('0x4a'),_0xda66('0x8d')));}_0x216c2c[_0xda66('0x43')](_0xda66('0x8e')+tmp_campaigns+';');_0x216c2c[_0xda66('0x43')](_0xda66('0x8e')+tmp_voice_queues+';');BPromise['each'](_0x216c2c,handleQuery)['then'](function(_0x11f111){stats[_0xda66('0x8f')]=!![];stats[_0xda66('0x90')]=_0x2b73ac['duplicates']&&_0x2b73ac['duplicates'][_0xda66('0x4d')]?results[0x2][_0xda66('0x90')]:results[0x0][_0xda66('0x90')];socket[_0xda66('0x91')]('contact:import:'+_0xe0c439,stats);fs['unlink'](_0x1fed52);fs[_0xda66('0x92')](_0x3cccd3);process[_0xda66('0x42')](0x0);})['catch'](function(_0x9eee63){logger[_0xda66('0x41')](_0x9eee63['message']);process[_0xda66('0x42')](0x1);});});});});}catch(_0x225c42){logger[_0xda66('0x41')](_0xda66('0x93'),_0x225c42[_0xda66('0x45')]);process[_0xda66('0x42')](0x1);}},'error':function(_0x32e78d,_0x56d1d0,_0x59c931,_0x5a7ebd){throw new Error(_0x5a7ebd);}});}function validate(){if(process['argv']&&process[_0xda66('0x94')][_0xda66('0x4d')]<0x4){throw new Error('arguments\x20<filename>\x20<parameters>\x20<agents>');}var _0x2e4f23=path[_0xda66('0x14')](config[_0xda66('0x62')],_0xda66('0x95'),process['argv'][0x2]);if(!fs['existsSync'](_0x2e4f23)){throw new Error('file\x20doesn\x27t\x20exists');}var _0x62aacd={};try{_0x62aacd=JSON[_0xda66('0x68')](process[_0xda66('0x94')][0x3]);if(!_0x62aacd['binding']){throw new Error(_0xda66('0x96'));}if(!_0x62aacd[_0xda66('0x60')][_0xda66('0x11')]){throw new Error(_0xda66('0x97'));}if(!_0x62aacd['binding'][_0xda66('0x79')]){throw new Error(_0xda66('0x98'));}var _0x2c56e7=0x0;if(_0x62aacd[_0xda66('0x60')][_0xda66('0x23')]){_0x2c56e7=0x1;}if(!_0x62aacd['ListId']){throw new Error(_0xda66('0x99'));}}catch(_0x1b356a){throw new Error(_0xda66('0x9a'));}var _0x4dce2e=[];try{_0x4dce2e=_['map'](JSON[_0xda66('0x68')](process[_0xda66('0x94')][0x4]),'id');}catch(_0x4b6f4f){logger[_0xda66('0x3f')](_0xda66('0x9b'));}main(_0x2e4f23,_0x62aacd,_0x4dce2e,_0x2c56e7);}validate();process['on'](_0xda66('0x9c'),handleStop);process['on'](_0xda66('0x9d'),handleUncaughtException);
\ No newline at end of file
+var _0xd67c=['voice_queues','voice_queues_has_cm_lists','voice_queues_has_cm_lists.CmListId=','query','dialTimezone','set','offset','main','stringify','start','clone','socket_timestamp','root','server/files/tmp','includes','header','ContactItemType','name','_description','writeFileSync','parse','createReadStream','data','find','hasOwnProperty','trim','isNaN','isNumber','email','email\x20wrong\x20format','dateOfBirth','YYYY-MM-DD','utcOffset','firstName','itemTypeId','description','SystemRow','appendFileSync','rows','emit','contact:import:','Abort\x20parser','abort','step','duplicates','cm_contacts_','CREATE\x20TABLE\x20','\x20LIKE\x20cm_contacts;','voice_queues_','(id\x20int,dialTimezone\x20varchar(255),offset\x20int);','each','replace','dialTimezone,utcOffset','LOAD\x20DATA\x20LOCAL\x20INFILE\x20\x27%s\x27\x20INTO\x20TABLE\x20%s\x20CHARACTER\x20SET\x20UTF8\x20FIELDS\x20TERMINATED\x20BY\x20\x27,\x27\x20ENCLOSED\x20BY\x20\x27\x22\x27\x20LINES\x20TERMINATED\x20BY\x20\x27\x0a\x27\x20IGNORE\x201\x20ROWS\x20(%s)\x20SET\x20id\x20=\x20NULL,\x20ListId\x20=\x20%s,\x20CompanyId\x20=\x20%s,\x20createdAt\x20=\x20\x27%s\x27,\x20updatedAt\x20=\x20\x27%s\x27','CompanyId',',\x20scheduledAt\x20=\x20NOW()','DROP\x20TABLE\x20','contactTypeId','orderBy','VoiceQueueId','voice_queues_has_cm_blacklists','campaigns_has_cm_lists','campaigns','CampaignId','campaigns_has_cm_blacklists','finish','affectedRows','unlink','argv','arguments\x20<filename>\x20<parameters>\x20<agents>','existsSync','file\x20doesn\x27t\x20exists','binding','phone\x20is\x20mandatory','firstName\x20is\x20mandatory','ListId\x20is\x20mandatory','No\x20agent\x20available','SIGINT','path','lodash','papaparse','util','bluebird','moment','squel','ioredis','../../../mysqldb','../../../config/environment/shared','import','redis','defaults','localhost','socket.io-emitter','format','YYYY-MM-DD\x20HH:mm:ss','test','field','phone','from','.id\x20=\x20','\x20=\x20','where','.dialCheckDuplicateType\x20IN\x20(','join','CmContact','findAll','AdditionalPhones','then','length','all','split','push','isNil','filter','CmContactHasItem','update','updated','create','PHONE','inserted','cm_contacts.scheduledat','cm_contacts.id','cm_contacts.createdAt','cm_contacts.updatedAt','cm_contacts.priority','insert','into','cm_hopper','fromQuery','scheduledat','ContactId','ListId','createdAt','updatedAt','priority','UserId','recallme','select','fields','cm_contacts','.CmListId','.CmListId\x20=\x20?','cm_contacts.createdAt\x20=\x20?','\x22always\x22','\x22onlyIfOpen\x22','cm_contacts.phone\x20NOT\x20IN\x20(?)','toString','cm_contacts.ListId','cm_hopper_black','cm_contacts.ListId\x20=\x20','ListId\x20=\x20?','cm_contacts.phone','cm_contacts.UserId','cm_hopper.id','cm_contact_has_items.item','cm_contact_has_items.OrderBy','cm_contact_has_items.updatedAt','cm_hopper_additional_phones','CmHopperId','OrderBy','cm_contact_has_items','concat','keys','id\x20IN\x20?','MIN(id)','group','info','Received\x20SIGINT','error','message','exit','errors','code','spread','catch','campaigns.id','campaigns.dialTimezone','campaigns.id\x20=\x20campaigns_has_cm_lists.CampaignId','sequelize','voice_queues.id','voice_queues.dialTimezone'];(function(_0x4a9fb1,_0x273043){var _0x348672=function(_0x142b69){while(--_0x142b69){_0x4a9fb1['push'](_0x4a9fb1['shift']());}};_0x348672(++_0x273043);}(_0xd67c,0x103));var _0xcd67=function(_0x32f7d7,_0x54231b){_0x32f7d7=_0x32f7d7-0x0;var _0x133d09=_0xd67c[_0x32f7d7];return _0x133d09;};'use strict';var fs=require('fs');var path=require(_0xcd67('0x0'));var _=require(_0xcd67('0x1'));var Papa=require(_0xcd67('0x2'));var util=require(_0xcd67('0x3'));var BPromise=require(_0xcd67('0x4'));var moment=require(_0xcd67('0x5'));var squel=require(_0xcd67('0x6'));var Redis=require(_0xcd67('0x7'));var db=require(_0xcd67('0x8'))['db'];var config=require('../../../config/environment');var shared=require(_0xcd67('0x9'));var logger=require('../../../config/logger')(_0xcd67('0xa'));config[_0xcd67('0xb')]=_[_0xcd67('0xc')](config[_0xcd67('0xb')],{'host':_0xcd67('0xd'),'port':0x18eb});var socket=require(_0xcd67('0xe'))(new Redis(config[_0xcd67('0xb')]));var stats={'finish':![],'errors':[],'rows':0x0,'affectedRows':0x0};var results=[];var promisesAdditionalPhones=[];var orderBy=0x0;var stopped=![];var NOW=moment()[_0xcd67('0xf')](_0xcd67('0x10'));var contactItemTypes=[];var phoneDescriptions=[];var hasAdditionalPhones=![];var tmp_voice_queues;var tmp_campaigns;var tzOffset=0x0;var hasTZ;var NOW=moment()[_0xcd67('0xf')](_0xcd67('0x10'));function isEmail(_0x92bd22){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))*$/[_0xcd67('0x11')](_0x92bd22);}function selectNotIn(_0x56f084,_0x3d18cc,_0x2e689e,_0x1415fb,_0x491f7b){return squel['select']()[_0xcd67('0x12')](_0xcd67('0x13'))[_0xcd67('0x14')](_0x1415fb)['join'](_0x3d18cc,null,_0x3d18cc+_0xcd67('0x15')+_0x1415fb+'.'+_0x2e689e)['where'](_0x1415fb+'.'+_0x2e689e+_0xcd67('0x16')+_0x56f084+'.'+_0x2e689e)[_0xcd67('0x17')](_0x3d18cc+_0xcd67('0x18')+_0x491f7b[_0xcd67('0x19')]()+')');}function handleAdditionalPhones(){return new Promise(function(_0x38b7f3,_0x20dd5b){promisesAdditionalPhones=[];return db[_0xcd67('0x1a')][_0xcd67('0x1b')]({'raw':!![],'attributes':['id',_0xcd67('0x1c')],'where':{'createdAt':NOW,'AdditionalPhones':{'$ne':null}}})[_0xcd67('0x1d')](function(_0x200ca6){if(_0x200ca6!==null){var _0x39d32d=[];for(var _0x15507f=0x0;_0x15507f<_0x200ca6[_0xcd67('0x1e')];_0x15507f++){var _0x234bf1=_0x200ca6[_0x15507f];_0x39d32d['push'](insertAdditionalPhones(_0x234bf1));}}Promise[_0xcd67('0x1f')](_0x39d32d)[_0xcd67('0x1d')](function(){_0x38b7f3({'val':0x1});});});});}function insertAdditionalPhones(_0x32cbb6){return new Promise(function(_0x219646,_0x56f03b){var _0x785644=_0x32cbb6['AdditionalPhones'];var _0x2e2ded=_0x785644[_0xcd67('0x20')](';');var _0x44a1f1=[];orderBy=0x0;for(var _0x47236a=0x0;_0x47236a<_0x2e2ded['length'];_0x47236a++){_0x44a1f1[_0xcd67('0x21')](splitAdditionalPhone(_0x32cbb6['id'],_0x2e2ded[_0x47236a]));}Promise[_0xcd67('0x1f')](_0x44a1f1)[_0xcd67('0x1d')](function(){_0x219646({'val':_0x2e2ded[_0xcd67('0x1e')]});});});}function splitAdditionalPhone(_0x48014d,_0x4c182f){return new Promise(function(_0xe97297,_0x50ea07){var _0x5f4876=_0x4c182f[_0xcd67('0x20')](':');var _0x39d981=_0x5f4876[0x0];var _0x225cbe=_0x5f4876[0x1];if(!_[_0xcd67('0x22')](_0x225cbe)){var _0xa18b49=_0x225cbe[_0xcd67('0x20')]('|');var _0x5a345c=[];for(var _0x17eba6=0x0;_0x17eba6<_0xa18b49['length'];_0x17eba6++){if(_0xa18b49[_0x17eba6]!==''){var _0x2d0046=_[_0xcd67('0x23')](promisesAdditionalPhones,{'contactId':_0x48014d,'phone':_0xa18b49[_0x17eba6]});if(_0x2d0046[_0xcd67('0x1e')]==0x0){orderBy++;promisesAdditionalPhones['push']({'contactId':_0x48014d,'contactTypeId':_0x39d981,'phone':_0xa18b49[_0x17eba6],'orderBy':orderBy});}}}_0xe97297({'ok':0x1});}else _0xe97297({'res':0x0});});}function createAdditionalPhone(_0x40bb40,_0x31debe,_0x29e898,_0x5ad3cd){var _0x8c0376='';var _0xec9c0d='';var _0x538550=_0x29e898['split']('§');_0x8c0376=_0x538550[0x0];if(_0x538550['length']==0x2)_0xec9c0d=_0x538550[0x1];return new Promise(function(_0x433473,_0x26fd83){return db[_0xcd67('0x24')]['findOne']({'where':{'CmContactId':_0x40bb40,'item':_0x8c0376}})[_0xcd67('0x1d')](function(_0xe4d60){if(_0xe4d60){return db['CmContactHasItem'][_0xcd67('0x25')]({'ItemTypeId':_0x31debe,'description':_0xec9c0d,'OrderBy':_0x5ad3cd},{'where':{'CmContactId':_0x40bb40,'item':_0x8c0376}})['then'](function(_0x3755d2){_0x433473({'res':_0xcd67('0x26')});});}else{return db[_0xcd67('0x24')][_0xcd67('0x27')]({'CmContactId':_0x40bb40,'item':_0x8c0376,'description':_0xec9c0d,'ItemTypeId':_0x31debe,'OrderBy':_0x5ad3cd,'ItemClass':_0xcd67('0x28')})['then'](function(_0x39fd00){_0x433473({'res':_0xcd67('0x29')});});}});});}function insertCmHopper(_0x2a04dc,_0x3b86af,_0x110df8,_0x22c03e,_0x16df27){var _0xf3413e=['cm_contacts.phone',_0xcd67('0x2a'),_0xcd67('0x2b'),'cm_contacts.ListId',_0x3b86af+'.'+_0x22c03e,_0xcd67('0x2c'),_0xcd67('0x2d'),_0xcd67('0x2e'),'cm_contacts.UserId','\x22'+_0x16df27+'\x22'];return squel[_0xcd67('0x2f')]()[_0xcd67('0x30')](_0xcd67('0x31'))[_0xcd67('0x32')]([_0xcd67('0x13'),_0xcd67('0x33'),_0xcd67('0x34'),_0xcd67('0x35'),_0x22c03e,_0xcd67('0x36'),_0xcd67('0x37'),_0xcd67('0x38'),_0xcd67('0x39'),_0xcd67('0x3a')],squel[_0xcd67('0x3b')]()[_0xcd67('0x3c')](_0xf3413e)[_0xcd67('0x14')](_0x3b86af)[_0xcd67('0x19')](_0xcd67('0x3d'),null,'cm_contacts.ListId\x20=\x20'+_0x3b86af+_0xcd67('0x3e'))['join'](_0x110df8,null,_0x110df8+'.id\x20=\x20'+_0x3b86af+'.'+_0x22c03e)[_0xcd67('0x17')](_0x3b86af+_0xcd67('0x3f'),_0x2a04dc)[_0xcd67('0x17')](_0xcd67('0x40'),NOW)['where']('cm_contacts.phone\x20NOT\x20IN\x20(?)',selectNotIn(_0x3b86af,_0x110df8,_0x22c03e,_0xcd67('0x31'),[_0xcd67('0x41'),_0xcd67('0x42')]))[_0xcd67('0x17')](_0xcd67('0x43'),selectNotIn(_0x3b86af,_0x110df8,_0x22c03e,_0xcd67('0x31'),[_0xcd67('0x41')])))[_0xcd67('0x44')]();}function insertCmHopperBlack(_0x9fefbd,_0x5b9bf3,_0x43996f,_0x3356b7){var _0x489d83=['cm_contacts.phone',_0xcd67('0x2b'),_0xcd67('0x45'),_0x5b9bf3+'.'+_0x3356b7,_0xcd67('0x2c'),_0xcd67('0x2d')];return squel[_0xcd67('0x2f')]()['into'](_0xcd67('0x46'))[_0xcd67('0x32')](['phone',_0xcd67('0x34'),_0xcd67('0x35'),_0x3356b7,_0xcd67('0x36'),_0xcd67('0x37')],squel[_0xcd67('0x3b')]()[_0xcd67('0x3c')](_0x489d83)[_0xcd67('0x14')](_0x5b9bf3)[_0xcd67('0x19')]('cm_contacts',null,_0xcd67('0x47')+_0x5b9bf3+'.CmListId')[_0xcd67('0x19')](_0x43996f,null,_0x43996f+_0xcd67('0x15')+_0x5b9bf3+'.'+_0x3356b7)[_0xcd67('0x17')](_0x5b9bf3+'.CmListId\x20=\x20?',_0x9fefbd)['where']('cm_contacts.createdAt\x20=\x20?',NOW)[_0xcd67('0x17')](_0xcd67('0x43'),squel['select']()[_0xcd67('0x12')](_0xcd67('0x13'))[_0xcd67('0x14')](_0xcd67('0x46'))[_0xcd67('0x17')](_0xcd67('0x48'),_0x9fefbd)[_0xcd67('0x17')](_0x3356b7+_0xcd67('0x16')+_0x5b9bf3+'.'+_0x3356b7)))[_0xcd67('0x44')]();}function insertTzCmHopper(_0x359cef,_0x4b89a2,_0x401849,_0x4f2485,_0x53ce85,_0x5832d6){var _0x4cde90=[_0xcd67('0x49'),'date_add(cm_contacts.scheduledat,interval\x20'+_0x5832d6+'.offset-cm_contacts.utcOffset\x20minute)',_0xcd67('0x2b'),_0xcd67('0x45'),_0x4b89a2+'.'+_0x4f2485,_0xcd67('0x2c'),_0xcd67('0x2d'),_0xcd67('0x2e'),_0xcd67('0x4a'),'\x22'+_0x53ce85+'\x22'];var _0x59e6c0=squel[_0xcd67('0x2f')]()['into'](_0xcd67('0x31'))[_0xcd67('0x32')]([_0xcd67('0x13'),_0xcd67('0x33'),_0xcd67('0x34'),'ListId',_0x4f2485,_0xcd67('0x36'),_0xcd67('0x37'),_0xcd67('0x38'),_0xcd67('0x39'),_0xcd67('0x3a')],squel[_0xcd67('0x3b')]()[_0xcd67('0x3c')](_0x4cde90)[_0xcd67('0x14')](_0x4b89a2)['join'](_0xcd67('0x3d'),null,'cm_contacts.ListId\x20=\x20'+_0x4b89a2+'.CmListId')['join'](_0x401849,null,_0x401849+'.id\x20=\x20'+_0x4b89a2+'.'+_0x4f2485)[_0xcd67('0x19')](_0x5832d6,null,_0x5832d6+_0xcd67('0x15')+_0x4b89a2+'.'+_0x4f2485)['where'](_0x4b89a2+'.CmListId\x20=\x20?',_0x359cef)[_0xcd67('0x17')](_0xcd67('0x40'),NOW)[_0xcd67('0x17')](_0xcd67('0x43'),selectNotIn(_0x4b89a2,_0x401849,_0x4f2485,_0xcd67('0x31'),[_0xcd67('0x41'),_0xcd67('0x42')]))[_0xcd67('0x17')](_0xcd67('0x43'),selectNotIn(_0x4b89a2,_0x401849,_0x4f2485,_0xcd67('0x31'),['\x22always\x22'])))['toString']();return _0x59e6c0;}function insertTzCmHopperBlack(_0x15c656,_0x30bacf,_0x1926e0,_0x4818e2){var _0x1cff17=[_0xcd67('0x49'),_0xcd67('0x2b'),_0xcd67('0x45'),_0x30bacf+'.'+_0x4818e2,_0xcd67('0x2c'),'cm_contacts.updatedAt'];return squel[_0xcd67('0x2f')]()[_0xcd67('0x30')](_0xcd67('0x46'))['fromQuery']([_0xcd67('0x13'),'ContactId',_0xcd67('0x35'),_0x4818e2,'createdAt',_0xcd67('0x37')],squel['select']()[_0xcd67('0x3c')](_0x1cff17)['from'](_0x30bacf)[_0xcd67('0x19')](_0xcd67('0x3d'),null,_0xcd67('0x47')+_0x30bacf+_0xcd67('0x3e'))[_0xcd67('0x19')](_0x1926e0,null,_0x1926e0+'.id\x20=\x20'+_0x30bacf+'.'+_0x4818e2)[_0xcd67('0x17')](_0x30bacf+'.CmListId\x20=\x20?',_0x15c656)[_0xcd67('0x17')]('cm_contacts.createdAt\x20=\x20?',NOW)[_0xcd67('0x17')](_0xcd67('0x43'),squel[_0xcd67('0x3b')]()[_0xcd67('0x12')](_0xcd67('0x13'))['from']('cm_hopper_black')['where']('ListId\x20=\x20?',_0x15c656)['where'](_0x4818e2+_0xcd67('0x16')+_0x30bacf+'.'+_0x4818e2)))['toString']();}function insertCmHopperAdditionalPhones(_0x5174fb){var _0x308461=[_0xcd67('0x4b'),_0xcd67('0x4c'),_0xcd67('0x4d'),'cm_contact_has_items.createdAt',_0xcd67('0x4e')];return squel[_0xcd67('0x2f')]()[_0xcd67('0x30')](_0xcd67('0x4f'))[_0xcd67('0x32')]([_0xcd67('0x50'),_0xcd67('0x13'),_0xcd67('0x51'),_0xcd67('0x36'),_0xcd67('0x37')],squel[_0xcd67('0x3b')]()[_0xcd67('0x3c')](_0x308461)[_0xcd67('0x14')](_0xcd67('0x31'))[_0xcd67('0x19')](_0xcd67('0x3d'),null,'cm_contacts.id\x20=\x20cm_hopper.ContactId')['join'](_0xcd67('0x52'),null,'cm_contacts.id\x20=\x20cm_contact_has_items.CmContactId')[_0xcd67('0x17')]('cm_hopper.ListId\x20=\x20?',_0x5174fb)[_0xcd67('0x17')](_0xcd67('0x40'),NOW))[_0xcd67('0x44')]();}function insertCmContact(_0x310380,_0x58aadb,_0x2356a5,_0x117c2b){var _0x4e0365=_[_0xcd67('0x53')](_[_0xcd67('0x54')](_0x117c2b),[_0xcd67('0x35'),'CompanyId',_0xcd67('0x36'),_0xcd67('0x37'),'scheduledAt']);return squel[_0xcd67('0x2f')]()[_0xcd67('0x30')]('cm_contacts')['fromQuery'](_0x4e0365,squel[_0xcd67('0x3b')]()['fields'](_0x4e0365)[_0xcd67('0x14')](_0x58aadb)[_0xcd67('0x17')]('('+_0x2356a5[_0xcd67('0x19')](',')+')\x20NOT\x20IN\x20?',squel['select']()[_0xcd67('0x3c')](_0x2356a5)[_0xcd67('0x14')](_0xcd67('0x3d'))['where']('ListId\x20=\x20?',_0x310380)[_0xcd67('0x17')]('deletedAt\x20IS\x20NULL'))[_0xcd67('0x17')](_0xcd67('0x55'),squel[_0xcd67('0x3b')]()['field'](_0xcd67('0x56'),'min_id')['from'](_0x58aadb)[_0xcd67('0x57')](_0x2356a5[_0xcd67('0x19')](','))))[_0xcd67('0x44')]();}function handleStop(){logger[_0xcd67('0x58')](_0xcd67('0x59'));stopped=!![];}function handleUncaughtException(_0x31852f){logger[_0xcd67('0x5a')](_0x31852f[_0xcd67('0x5b')]);process[_0xcd67('0x5c')](0x1);}function handleError(_0x4b3cd2,_0x97365a){stats[_0xcd67('0x5d')][_0xcd67('0x21')]({'name':_0x97365a[_0xcd67('0x5e')],'message':_0x97365a[_0xcd67('0x5b')],'row':_0x4b3cd2});}function handleQuery(_0x388964){logger[_0xcd67('0x58')](_0x388964);return db['sequelize']['query'](_0x388964)[_0xcd67('0x5f')](function(_0x24b17d){results[_0xcd67('0x21')](_0x24b17d);})[_0xcd67('0x60')](function(_0x21cb11){logger[_0xcd67('0x5a')](_0x21cb11[_0xcd67('0x5b')]);});}function updateTzCampaigns(_0x1a1327){return new Promise(function(_0x4f654b,_0x15c41a){var _0x3e18fe=squel[_0xcd67('0x3b')]()['fields']([_0xcd67('0x61'),_0xcd67('0x62')])[_0xcd67('0x14')]('campaigns')[_0xcd67('0x19')]('campaigns_has_cm_lists',null,_0xcd67('0x63'))['where']('campaigns_has_cm_lists.CmListId='+_0x1a1327);db[_0xcd67('0x64')]['query'](_0x3e18fe[_0xcd67('0x44')]())['spread'](function(_0x40f836){var _0x15adf5=[];for(var _0x1540da=0x0;_0x1540da<_0x40f836['length'];_0x1540da++){_0x15adf5[_0xcd67('0x21')](getTimezoneData(_0x40f836[_0x1540da],tmp_campaigns));}BPromise[_0xcd67('0x1f')](_0x15adf5)[_0xcd67('0x1d')](function(){_0x4f654b({'val':0x1});});})[_0xcd67('0x60')](function(_0x910ffa){logger[_0xcd67('0x5a')](_0x910ffa[_0xcd67('0x5b')]);_0x4f654b({'val':0x0});});});}function updateTzVoiceQueues(_0x14b550){return new Promise(function(_0x418fc4,_0x594052){var _0x175329=squel[_0xcd67('0x3b')]()['fields']([_0xcd67('0x65'),_0xcd67('0x66')])[_0xcd67('0x14')](_0xcd67('0x67'))[_0xcd67('0x19')](_0xcd67('0x68'),null,'voice_queues.id\x20=\x20voice_queues_has_cm_lists.VoiceQueueId')[_0xcd67('0x17')](_0xcd67('0x69')+_0x14b550);db[_0xcd67('0x64')][_0xcd67('0x6a')](_0x175329['toString']())[_0xcd67('0x5f')](function(_0x4b3477){var _0x4f21de=[];for(var _0x537d87=0x0;_0x537d87<_0x4b3477[_0xcd67('0x1e')];_0x537d87++){_0x4f21de[_0xcd67('0x21')](getTimezoneData(_0x4b3477[_0x537d87],tmp_voice_queues));}BPromise['all'](_0x4f21de)[_0xcd67('0x1d')](function(){_0x418fc4({'val':0x1});});})[_0xcd67('0x60')](function(_0x2afbed){logger['error'](_0x2afbed[_0xcd67('0x5b')]);_0x418fc4({'val':0x0});});});}function getTimezoneData(_0x150d85,_0x5b37e9){return new Promise(function(_0x21e5dc,_0x3f6a2f){var _0x1b458b=shared['timezones'];var _0x2410b3=_0x1b458b[_0x150d85[_0xcd67('0x6b')]];if(_[_0xcd67('0x22')](_0x2410b3)){_0x21e5dc({'ret':0x1});}else{var _0x2c17d1=_0x2410b3['utcOffset'];var _0x347f74=squel['insert']()['into'](_0x5b37e9)[_0xcd67('0x6c')]('id',_0x150d85['id'])[_0xcd67('0x6c')](_0xcd67('0x6d'),_0x2c17d1)[_0xcd67('0x6c')](_0xcd67('0x6b'),_0x150d85[_0xcd67('0x6b')])[_0xcd67('0x44')]();return db[_0xcd67('0x64')]['query'](_0x347f74)[_0xcd67('0x5f')](function(_0x58bc1a){_0x21e5dc({'ret':0x1});})['catch'](function(_0x3f8601){logger[_0xcd67('0x5a')](_0x3f8601['message']);_0x3f6a2f({'ret':0x1});});}});}function handleTZQuery(_0x15339f){logger[_0xcd67('0x58')](_0x15339f);return db[_0xcd67('0x64')][_0xcd67('0x6a')](_0x15339f)[_0xcd67('0x5f')](function(_0x4b9961){})[_0xcd67('0x60')](function(_0x485820){logger[_0xcd67('0x5a')](_0x485820[_0xcd67('0x5b')]);});}function main(_0x5d04ac,_0x50b454,_0x2b05e7,_0x4b5155){logger[_0xcd67('0x58')](_0xcd67('0x6e'),_0x5d04ac,JSON[_0xcd67('0x6f')](_0x50b454));process['send'](_0xcd67('0x70'));var _0x26015f=_0x50b454['binding'];var _0x473ba9=_[_0xcd67('0x71')](_0x26015f);var _0x21ecd6=_0x50b454[_0xcd67('0x72')];var _0x3c3080=path[_0xcd67('0x19')](config[_0xcd67('0x73')],_0xcd67('0x74'),_0x21ecd6+'.csv');hasTZ=_[_0xcd67('0x54')](_0x26015f)[_0xcd67('0x75')](_0xcd67('0x6b'));var _0x2b3596=_[_0xcd67('0x54')](_0x26015f)[_0xcd67('0x19')]();logger[_0xcd67('0x58')](_0xcd67('0x76'),_0x2b3596);db[_0xcd67('0x77')][_0xcd67('0x1b')]({'raw':!![],'attributes':['id',_0xcd67('0x78')]})[_0xcd67('0x1d')](function(_0x500041){for(var _0x305c3e=0x0;_0x305c3e<_0x500041[_0xcd67('0x1e')];_0x305c3e++){if(_0x500041[_0x305c3e][_0xcd67('0x78')]in _0x26015f){contactItemTypes[_0xcd67('0x21')](_0x500041[_0x305c3e]);delete _0x473ba9[_0x500041[_0x305c3e][_0xcd67('0x78')]];hasAdditionalPhones=!![];}for(var _0x96469f in _0x26015f){if(_0x500041[_0x305c3e][_0xcd67('0x78')]+_0xcd67('0x79')===_0x96469f){phoneDescriptions[_0xcd67('0x21')]({'itemTypeId':_0x500041[_0x305c3e]['id'],'description':_0x96469f});delete _0x473ba9[_0x96469f];}}}if(hasAdditionalPhones)_0x473ba9[_0xcd67('0x1c')]='';var _0x367978=_[_0xcd67('0x54')](_0x473ba9)['join']();logger['info'](_0xcd67('0x76'),_0x367978);fs[_0xcd67('0x7a')](_0x3c3080,_0x367978+'\x0a');Papa[_0xcd67('0x7b')](fs[_0xcd67('0x7c')](_0x5d04ac),{'header':!![],'skipEmptyLines':!![],'step':function(_0x9e0fb1,_0x452739){try{for(var _0x4b5a74=0x0,_0x3c864f=[];_0x4b5a74<_0x9e0fb1[_0xcd67('0x7d')][_0xcd67('0x1e')];_0x4b5a74++){stats['rows']+=0x1;if(_0x9e0fb1['errors'][_0x4b5a74]){handleError(_0x9e0fb1[_0xcd67('0x7d')][_0x4b5a74],_0x9e0fb1[_0xcd67('0x5d')][_0x4b5a74]);}else{var _0x3393f5=[];var _0x597e52=[];var _0x586a31={};for(var _0x2d0ead in _0x26015f){let _0x593d5c=contactItemTypes[_0xcd67('0x7e')](_0x21349f=>_0x21349f[_0xcd67('0x78')]===_0x2d0ead);let _0xe12422=contactItemTypes[_0xcd67('0x7e')](_0x4c8f7a=>_0x4c8f7a[_0xcd67('0x78')]+_0xcd67('0x79')===_0x2d0ead);if(_[_0xcd67('0x22')](_0x593d5c)&&_[_0xcd67('0x22')](_0xe12422)){if(_0x26015f[_0xcd67('0x7f')](_0x2d0ead)){if(_0x9e0fb1[_0xcd67('0x7d')][_0x4b5a74][_0x26015f[_0x2d0ead]]){var _0x179065=_[_0xcd67('0x80')](_0x9e0fb1[_0xcd67('0x7d')][_0x4b5a74][_0x26015f[_0x2d0ead]]['replace'](/"/g,'\x27'));switch(_0x2d0ead){case'scheduledat':var _0x4bb46d=moment(_0x179065,'YYYY-MM-DD\x20HH:mm:ss',!![]);if(_0x4bb46d['isValid']()){_0x3c864f[_0xcd67('0x21')]('\x22'+_0x179065+'\x22');}else{_0x3393f5[_0xcd67('0x21')]('scheduledat\x20wrong\x20format\x20(YYYY-MM-DD\x20HH:mm:ss)');}break;case _0xcd67('0x38'):var _0x253ba8=parseInt(_0x179065);_0x179065=_[_0xcd67('0x81')](_0x253ba8)||_0x253ba8<0x0||_0x253ba8>0x4?_0x4b5155?0x3:0x2:_0x253ba8;_0x3c864f[_0xcd67('0x21')]('\x22'+_0x179065+'\x22');break;case _0xcd67('0x39'):var _0x2e0afb=parseInt(_0x179065);if(_[_0xcd67('0x82')](_0x2e0afb)&&_[_0xcd67('0x75')](_0x2b05e7,_0x2e0afb)){_0x3c864f['push']('\x22'+_0x2e0afb+'\x22');}else{_0x3393f5[_0xcd67('0x21')]('agent\x20not\x20exists');}break;case _0xcd67('0x83'):if(isEmail(_0x179065)){_0x3c864f[_0xcd67('0x21')]('\x22'+_0x179065+'\x22');}else{_0x3393f5[_0xcd67('0x21')](_0xcd67('0x84'));}break;case _0xcd67('0x85'):var _0x3dc3dd=moment(_0x179065,_0xcd67('0x86'),!![]);if(_0x3dc3dd['isValid']()){_0x3c864f[_0xcd67('0x21')]('\x22'+_0x179065+'\x22');}else{_0x3393f5[_0xcd67('0x21')]('dateOfBirth\x20wrong\x20format\x20(YYYY-MM-DD)');}break;case _0xcd67('0x6b'):var _0x3d61ec=shared['timezones'];var _0x4a0dfe=_0x3d61ec[_0x179065];if(!_[_0xcd67('0x22')](_0x4a0dfe)){var _0x3aa603=_0x4a0dfe[_0xcd67('0x87')];_0x3c864f[_0xcd67('0x21')]('\x22'+_0x179065+'\x22');_0x3c864f[_0xcd67('0x21')]('\x22'+_0x3aa603+'\x22');}break;default:_0x3c864f[_0xcd67('0x21')]('\x22'+_0x179065+'\x22');}}else{switch(_0x2d0ead){case _0xcd67('0x88'):case'phone':_0x3393f5[_0xcd67('0x21')](_0x2d0ead+'\x20not\x20specified');break;default:_0x3c864f[_0xcd67('0x21')]('\x22\x22');}}}}else{var _0x1235c7='';if(!_[_0xcd67('0x22')](_0x593d5c)){if(!_0x586a31[_0xcd67('0x7f')](_0x593d5c['id'])){if(!_[_0xcd67('0x22')](_0x9e0fb1[_0xcd67('0x7d')][_0x4b5a74][_0x26015f[_0x2d0ead]])){var _0x179065=_[_0xcd67('0x80')](_0x9e0fb1[_0xcd67('0x7d')][_0x4b5a74][_0x26015f[_0x2d0ead]]['replace'](/"/g,'\x27'));var _0xd000fe=phoneDescriptions[_0xcd67('0x7e')](_0x31042e=>_0x31042e[_0xcd67('0x89')]===_0x593d5c['id']);if(!_['isNil'](_0xd000fe)){var _0x5edf3c=_['trim'](_0x9e0fb1[_0xcd67('0x7d')][_0x4b5a74][_0x26015f[_0xd000fe[_0xcd67('0x8a')]]]['replace'](/"/g,'\x27'));if(!_[_0xcd67('0x22')](_0x5edf3c))_0x179065=_0x179065+'§'+_0x5edf3c;}if(_0x1235c7=='')_0x1235c7=_0x179065;else _0x1235c7+='|'+_0x179065;}_0x597e52[_0xcd67('0x21')](_0x593d5c['id']+':'+_0x1235c7);_0x586a31[_0x593d5c['id']]=0x1;}}}}if(hasAdditionalPhones){_0x3c864f['push']('\x22'+_0x597e52['join'](';')+'\x22');}if(_0x3393f5[_0xcd67('0x1e')]){handleError(_0x9e0fb1[_0xcd67('0x7d')][_0x4b5a74],{'code':_0xcd67('0x8b'),'message':_0x3393f5[_0xcd67('0x19')]()});}else{fs[_0xcd67('0x8c')](_0x3c3080,_0x3c864f[_0xcd67('0x19')]()+'\x0a');}_0x3c864f=[];}if(!(stats[_0xcd67('0x8d')]%0xc8)){socket[_0xcd67('0x8e')](_0xcd67('0x8f')+_0x21ecd6,stats);stats[_0xcd67('0x5d')]=[];}}if(stopped){logger[_0xcd67('0x58')](_0xcd67('0x90'));_0x452739[_0xcd67('0x91')]();}}catch(_0x2bd0fe){handleError(_0x9e0fb1[_0xcd67('0x7d')][_0x4b5a74],{'code':'SystemError','message':_0x2bd0fe[_0xcd67('0x5b')]});logger[_0xcd67('0x5a')](_0xcd67('0x92'),_0x2bd0fe[_0xcd67('0x5b')]);}},'complete':function(){try{var _0x42ef63=[];var _0x3e35ab=[];var _0x4b9452=_0xcd67('0x3d');if(_0x50b454[_0xcd67('0x93')]&&_0x50b454[_0xcd67('0x93')][_0xcd67('0x1e')]){_0x4b9452=_0xcd67('0x94')+_0x21ecd6;_0x42ef63['push'](_0xcd67('0x95')+_0x4b9452+_0xcd67('0x96'));}tmp_campaigns='campaigns_'+_0x21ecd6;tmp_voice_queues=_0xcd67('0x97')+_0x21ecd6;_0x3e35ab[_0xcd67('0x21')](_0xcd67('0x95')+tmp_campaigns+_0xcd67('0x98'));_0x3e35ab[_0xcd67('0x21')]('CREATE\x20TABLE\x20'+tmp_voice_queues+_0xcd67('0x98'));BPromise[_0xcd67('0x99')](_0x3e35ab,handleTZQuery)['then'](function(_0x5deff3){updateTzCampaigns(_0x50b454['ListId'])[_0xcd67('0x1d')](function(_0x11ac12){updateTzVoiceQueues(_0x50b454[_0xcd67('0x35')])['then'](function(_0x554619){if(hasTZ)_0x367978=_0x367978[_0xcd67('0x9a')](_0xcd67('0x6b'),_0xcd67('0x9b'));var _0x4ad015=util['format'](_0xcd67('0x9c'),_0x3c3080,_0x4b9452,_0x367978,_0x50b454[_0xcd67('0x35')],_0x50b454[_0xcd67('0x9d')]||null,NOW,NOW);if(_[_0xcd67('0x22')](_0x26015f[_0xcd67('0x33')])){_0x4ad015+=_0xcd67('0x9e');}_0x42ef63[_0xcd67('0x21')](_0x4ad015);if(_0x50b454['duplicates']&&_0x50b454[_0xcd67('0x93')][_0xcd67('0x1e')]){_0x42ef63[_0xcd67('0x21')](insertCmContact(_0x50b454[_0xcd67('0x35')],_0x4b9452,_0x50b454['duplicates'],_0x26015f));_0x42ef63[_0xcd67('0x21')](_0xcd67('0x9f')+_0x4b9452+';');}BPromise[_0xcd67('0x99')](_0x42ef63,handleQuery)[_0xcd67('0x1d')](function(_0xefc358){BPromise[_0xcd67('0x1f')]([handleAdditionalPhones()])['then'](function(){_0x42ef63=[];for(var _0x3a7b82=0x0;_0x3a7b82<promisesAdditionalPhones[_0xcd67('0x1e')];_0x3a7b82++){if(promisesAdditionalPhones[_0x3a7b82]['phone']!='§'){_0x42ef63['push'](createAdditionalPhone(promisesAdditionalPhones[_0x3a7b82]['contactId'],promisesAdditionalPhones[_0x3a7b82][_0xcd67('0xa0')],promisesAdditionalPhones[_0x3a7b82][_0xcd67('0x13')],promisesAdditionalPhones[_0x3a7b82][_0xcd67('0xa1')]));}}BPromise[_0xcd67('0x1f')](_0x42ef63)[_0xcd67('0x1d')](function(){_0x42ef63=[];if(hasTZ){_0x42ef63[_0xcd67('0x21')](insertTzCmHopper(_0x50b454[_0xcd67('0x35')],_0xcd67('0x68'),'voice_queues',_0xcd67('0xa2'),_0x4b5155,tmp_voice_queues));_0x42ef63[_0xcd67('0x21')](insertTzCmHopperBlack(_0x50b454['ListId'],_0xcd67('0xa3'),_0xcd67('0x67'),_0xcd67('0xa2')));_0x42ef63[_0xcd67('0x21')](insertTzCmHopper(_0x50b454['ListId'],_0xcd67('0xa4'),_0xcd67('0xa5'),_0xcd67('0xa6'),_0x4b5155,tmp_campaigns));_0x42ef63[_0xcd67('0x21')](insertTzCmHopperBlack(_0x50b454['ListId'],_0xcd67('0xa7'),'campaigns',_0xcd67('0xa6')));_0x42ef63[_0xcd67('0x21')](insertCmHopperAdditionalPhones(_0x50b454[_0xcd67('0x35')]));}else{_0x42ef63[_0xcd67('0x21')](insertCmHopper(_0x50b454[_0xcd67('0x35')],_0xcd67('0x68'),_0xcd67('0x67'),_0xcd67('0xa2'),_0x4b5155));_0x42ef63['push'](insertCmHopperBlack(_0x50b454['ListId'],'voice_queues_has_cm_blacklists',_0xcd67('0x67'),_0xcd67('0xa2')));_0x42ef63['push'](insertCmHopper(_0x50b454[_0xcd67('0x35')],_0xcd67('0xa4'),_0xcd67('0xa5'),_0xcd67('0xa6'),_0x4b5155));_0x42ef63[_0xcd67('0x21')](insertCmHopperBlack(_0x50b454['ListId'],_0xcd67('0xa7'),_0xcd67('0xa5'),_0xcd67('0xa6')));_0x42ef63[_0xcd67('0x21')](insertCmHopperAdditionalPhones(_0x50b454[_0xcd67('0x35')]));}_0x42ef63[_0xcd67('0x21')]('DROP\x20TABLE\x20'+tmp_campaigns+';');_0x42ef63[_0xcd67('0x21')](_0xcd67('0x9f')+tmp_voice_queues+';');BPromise[_0xcd67('0x99')](_0x42ef63,handleQuery)['then'](function(_0x40d330){stats[_0xcd67('0xa8')]=!![];stats[_0xcd67('0xa9')]=_0x50b454[_0xcd67('0x93')]&&_0x50b454[_0xcd67('0x93')]['length']?results[0x2][_0xcd67('0xa9')]:results[0x0][_0xcd67('0xa9')];socket[_0xcd67('0x8e')]('contact:import:'+_0x21ecd6,stats);fs['unlink'](_0x5d04ac);fs[_0xcd67('0xaa')](_0x3c3080);process[_0xcd67('0x5c')](0x0);})['catch'](function(_0x10cc8c){logger[_0xcd67('0x5a')](_0x10cc8c[_0xcd67('0x5b')]);process[_0xcd67('0x5c')](0x1);});});});})[_0xcd67('0x60')](function(_0x57eb9c){logger[_0xcd67('0x5a')](_0x57eb9c['message']);process[_0xcd67('0x5c')](0x1);});});});});}catch(_0x2f5176){logger['error']('complete',_0x2f5176[_0xcd67('0x5b')]);process[_0xcd67('0x5c')](0x1);}},'error':function(_0xbe6f59,_0x61c68,_0x5b9fef,_0x47e42f){throw new Error(_0x47e42f);}});});}function validate(){if(process['argv']&&process[_0xcd67('0xab')][_0xcd67('0x1e')]<0x4){throw new Error(_0xcd67('0xac'));}var _0x1c06cf=path[_0xcd67('0x19')](config['root'],'server/files/tmp',process['argv'][0x2]);if(!fs[_0xcd67('0xad')](_0x1c06cf)){throw new Error(_0xcd67('0xae'));}var _0x4938c2={};try{_0x4938c2=JSON[_0xcd67('0x7b')](process[_0xcd67('0xab')][0x3]);if(!_0x4938c2[_0xcd67('0xaf')]){throw new Error('binding\x20doesn\x27t\x20exists');}if(!_0x4938c2[_0xcd67('0xaf')]['phone']){throw new Error(_0xcd67('0xb0'));}if(!_0x4938c2['binding'][_0xcd67('0x88')]){throw new Error(_0xcd67('0xb1'));}var _0x515a57=0x0;if(_0x4938c2[_0xcd67('0xaf')][_0xcd67('0x39')]){_0x515a57=0x1;}if(!_0x4938c2[_0xcd67('0x35')]){throw new Error(_0xcd67('0xb2'));}}catch(_0x481356){throw new Error('body\x20id\x20mandatory');}var _0x51ee0f=[];try{_0x51ee0f=_['map'](JSON['parse'](process[_0xcd67('0xab')][0x4]),'id');}catch(_0x139fd6){logger['info'](_0xcd67('0xb3'));}main(_0x1c06cf,_0x4938c2,_0x51ee0f,_0x515a57);}validate();process['on'](_0xcd67('0xb4'),handleStop);process['on']('uncaughtException',handleUncaughtException);
\ No newline at end of file