Built motion from commit 52c8a02d.|2.6.29
[motion2.git] / server / components / import / cm / csv2.js
index 184a1ff..7dd1090 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x5b97=['then','split','isNil','CmContactHasItem','updated','PHONE','inserted','cm_contacts.phone','cm_contacts.scheduledat','cm_contacts.id','cm_contacts.ListId','cm_contacts.createdAt','cm_contacts.updatedAt','cm_contacts.priority','cm_contacts.UserId','insert','into','fromQuery','scheduledat','ContactId','createdAt','priority','UserId','recallme','fields','cm_contacts','cm_contacts.ListId\x20=\x20','.CmListId','.CmListId\x20=\x20?','cm_hopper','\x22always\x22','\x22onlyIfOpen\x22','cm_contacts.phone\x20NOT\x20IN\x20(?)','toString','cm_hopper_black','ListId','updatedAt','from','cm_contacts.createdAt\x20=\x20?','field','ListId\x20=\x20?','.offset-cm_contacts.utcOffset\x20minute)','cm_hopper.id','cm_contact_has_items.OrderBy','cm_contact_has_items.createdAt','cm_contact_has_items.updatedAt','CmHopperId','OrderBy','cm_contact_has_items','cm_contacts.id\x20=\x20cm_contact_has_items.CmContactId','cm_hopper.ListId\x20=\x20?','concat','keys','scheduledAt','deletedAt\x20IS\x20NULL','id\x20IN\x20?','MIN(id)','group','info','Received\x20SIGINT','error','exit','errors','code','message','sequelize','query','spread','campaigns.id','campaigns.dialTimezone','campaigns.id\x20=\x20campaigns_has_cm_lists.CampaignId','catch','voice_queues.id','voice_queues.dialTimezone','voice_queues','voice_queues_has_cm_lists','voice_queues.id\x20=\x20voice_queues_has_cm_lists.VoiceQueueId','voice_queues_has_cm_lists.CmListId=','timezones','dialTimezone','utcOffset','set','offset','main','send','start','root','server/files/tmp','.csv','includes','header','findAll','name','createReadStream','data','rows','find','_description','hasOwnProperty','isValid','scheduledat\x20wrong\x20format\x20(YYYY-MM-DD\x20HH:mm:ss)','isNaN','isNumber','agent\x20not\x20exists','email','dateOfBirth','YYYY-MM-DD','dateOfBirth\x20wrong\x20format\x20(YYYY-MM-DD)','firstName','\x20not\x20specified','replace','itemTypeId','trim','description','appendFileSync','emit','contact:import:','Abort\x20parser','abort','SystemError','step','duplicates','cm_contacts_','\x20LIKE\x20cm_contacts;','campaigns_','voice_queues_','CREATE\x20TABLE\x20','(id\x20int,dialTimezone\x20varchar(255),offset\x20int);','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','each','contactId','contactTypeId','orderBy','VoiceQueueId','voice_queues_has_cm_blacklists','CampaignId','campaigns_has_cm_blacklists','campaigns','affectedRows','unlink','complete','argv','existsSync','file\x20doesn\x27t\x20exists','parse','binding\x20doesn\x27t\x20exists','binding','phone\x20is\x20mandatory','firstName\x20is\x20mandatory','No\x20agent\x20available','SIGINT','path','lodash','papaparse','util','bluebird','moment','squel','ioredis','../../../config/environment','../../../config/environment/shared','../../../config/logger','import','redis','defaults','localhost','socket.io-emitter','YYYY-MM-DD\x20HH:mm:ss','format','test','select','phone','join','.id\x20=\x20','\x20=\x20','where','.dialCheckDuplicateType\x20IN\x20(','CmContact','AdditionalPhones','length','push','all'];(function(_0x5f0a51,_0x20c147){var _0x3d6ecc=function(_0x1ba66c){while(--_0x1ba66c){_0x5f0a51['push'](_0x5f0a51['shift']());}};_0x3d6ecc(++_0x20c147);}(_0x5b97,0x155));var _0x75b9=function(_0x386525,_0xefae6){_0x386525=_0x386525-0x0;var _0x14d015=_0x5b97[_0x386525];return _0x14d015;};'use strict';var fs=require('fs');var path=require(_0x75b9('0x0'));var _=require(_0x75b9('0x1'));var Papa=require(_0x75b9('0x2'));var util=require(_0x75b9('0x3'));var BPromise=require(_0x75b9('0x4'));var moment=require(_0x75b9('0x5'));var squel=require(_0x75b9('0x6'));var Redis=require(_0x75b9('0x7'));var db=require('../../../mysqldb')['db'];var config=require(_0x75b9('0x8'));var shared=require(_0x75b9('0x9'));var logger=require(_0x75b9('0xa'))(_0x75b9('0xb'));config[_0x75b9('0xc')]=_[_0x75b9('0xd')](config['redis'],{'host':_0x75b9('0xe'),'port':0x18eb});var socket=require(_0x75b9('0xf'))(new Redis(config['redis']));var stats={'finish':![],'errors':[],'rows':0x0,'affectedRows':0x0};var results=[];var promisesAdditionalPhones=[];var orderBy=0x0;var stopped=![];var NOW=moment()['format'](_0x75b9('0x10'));var contactItemTypes=[];var phoneDescriptions=[];var hasAdditionalPhones=![];var tmp_voice_queues;var tmp_campaigns;var tzOffset=0x0;var hasTZ;var NOW=moment()[_0x75b9('0x11')]('YYYY-MM-DD\x20HH:mm:ss');function isEmail(_0x41e5b2){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))*$/[_0x75b9('0x12')](_0x41e5b2);}function selectNotIn(_0x158b83,_0x59f21e,_0x11dcbd,_0x3c03fe,_0x5ed2d0){return squel[_0x75b9('0x13')]()['field'](_0x75b9('0x14'))['from'](_0x3c03fe)[_0x75b9('0x15')](_0x59f21e,null,_0x59f21e+_0x75b9('0x16')+_0x3c03fe+'.'+_0x11dcbd)['where'](_0x3c03fe+'.'+_0x11dcbd+_0x75b9('0x17')+_0x158b83+'.'+_0x11dcbd)[_0x75b9('0x18')](_0x59f21e+_0x75b9('0x19')+_0x5ed2d0[_0x75b9('0x15')]()+')');}function handleAdditionalPhones(){return new Promise(function(_0x5f484b,_0x242bcb){promisesAdditionalPhones=[];return db[_0x75b9('0x1a')]['findAll']({'raw':!![],'attributes':['id',_0x75b9('0x1b')],'where':{'createdAt':NOW,'AdditionalPhones':{'$ne':null}}})['then'](function(_0xb668e7){if(_0xb668e7!==null){var _0x4ad606=[];for(var _0x210913=0x0;_0x210913<_0xb668e7[_0x75b9('0x1c')];_0x210913++){var _0x2e163a=_0xb668e7[_0x210913];_0x4ad606[_0x75b9('0x1d')](insertAdditionalPhones(_0x2e163a));}}Promise[_0x75b9('0x1e')](_0x4ad606)[_0x75b9('0x1f')](function(){_0x5f484b({'val':0x1});});});});}function insertAdditionalPhones(_0x5e20b0){return new Promise(function(_0x4226d0,_0x201530){var _0x2b80e1=_0x5e20b0[_0x75b9('0x1b')];var _0x2488fd=_0x2b80e1['split'](';');var _0x172aa2=[];orderBy=0x0;for(var _0x54c231=0x0;_0x54c231<_0x2488fd['length'];_0x54c231++){_0x172aa2[_0x75b9('0x1d')](splitAdditionalPhone(_0x5e20b0['id'],_0x2488fd[_0x54c231]));}Promise[_0x75b9('0x1e')](_0x172aa2)['then'](function(){_0x4226d0({'val':_0x2488fd['length']});});});}function splitAdditionalPhone(_0x3aadd2,_0x3276db){return new Promise(function(_0x439883,_0x21369e){var _0x6a07b8=_0x3276db[_0x75b9('0x20')](':');var _0x178ae0=_0x6a07b8[0x0];var _0x4d85e8=_0x6a07b8[0x1];if(!_[_0x75b9('0x21')](_0x4d85e8)){var _0x23c235=_0x4d85e8[_0x75b9('0x20')]('|');var _0x2ed00f=[];for(var _0x3f2b7e=0x0;_0x3f2b7e<_0x23c235[_0x75b9('0x1c')];_0x3f2b7e++){if(_0x23c235[_0x3f2b7e]!==''){var _0x5870b2=_['filter'](promisesAdditionalPhones,{'contactId':_0x3aadd2,'phone':_0x23c235[_0x3f2b7e]});if(_0x5870b2['length']==0x0){orderBy++;promisesAdditionalPhones[_0x75b9('0x1d')]({'contactId':_0x3aadd2,'contactTypeId':_0x178ae0,'phone':_0x23c235[_0x3f2b7e],'orderBy':orderBy});}}}_0x439883({'ok':0x1});}else _0x439883({'res':0x0});});}function createAdditionalPhone(_0x33166d,_0x56d231,_0x163549,_0x4763c4){var _0x48ec2c='';var _0x2c65f7='';var _0x2b1ba3=_0x163549['split']('§');_0x48ec2c=_0x2b1ba3[0x0];if(_0x2b1ba3['length']==0x2)_0x2c65f7=_0x2b1ba3[0x1];return new Promise(function(_0x11619f,_0xae5ea8){return db[_0x75b9('0x22')]['findOne']({'where':{'CmContactId':_0x33166d,'item':_0x48ec2c}})[_0x75b9('0x1f')](function(_0xf27996){if(_0xf27996){return db['CmContactHasItem']['update']({'ItemTypeId':_0x56d231,'description':_0x2c65f7,'OrderBy':_0x4763c4},{'where':{'CmContactId':_0x33166d,'item':_0x48ec2c}})[_0x75b9('0x1f')](function(_0x5b3bc7){_0x11619f({'res':_0x75b9('0x23')});});}else{return db[_0x75b9('0x22')]['create']({'CmContactId':_0x33166d,'item':_0x48ec2c,'description':_0x2c65f7,'ItemTypeId':_0x56d231,'OrderBy':_0x4763c4,'ItemClass':_0x75b9('0x24')})[_0x75b9('0x1f')](function(_0x43ca9d){_0x11619f({'res':_0x75b9('0x25')});});}});});}function insertCmHopper(_0x4a30b6,_0x31c5bc,_0x3a6110,_0x4a3356,_0xd31fb){var _0x461cd9=[_0x75b9('0x26'),_0x75b9('0x27'),_0x75b9('0x28'),_0x75b9('0x29'),_0x31c5bc+'.'+_0x4a3356,_0x75b9('0x2a'),_0x75b9('0x2b'),_0x75b9('0x2c'),_0x75b9('0x2d'),'\x22'+_0xd31fb+'\x22'];return squel[_0x75b9('0x2e')]()[_0x75b9('0x2f')]('cm_hopper')[_0x75b9('0x30')]([_0x75b9('0x14'),_0x75b9('0x31'),_0x75b9('0x32'),'ListId',_0x4a3356,_0x75b9('0x33'),'updatedAt',_0x75b9('0x34'),_0x75b9('0x35'),_0x75b9('0x36')],squel[_0x75b9('0x13')]()[_0x75b9('0x37')](_0x461cd9)['from'](_0x31c5bc)[_0x75b9('0x15')](_0x75b9('0x38'),null,_0x75b9('0x39')+_0x31c5bc+_0x75b9('0x3a'))[_0x75b9('0x15')](_0x3a6110,null,_0x3a6110+_0x75b9('0x16')+_0x31c5bc+'.'+_0x4a3356)[_0x75b9('0x18')](_0x31c5bc+_0x75b9('0x3b'),_0x4a30b6)[_0x75b9('0x18')]('cm_contacts.createdAt\x20=\x20?',NOW)[_0x75b9('0x18')]('cm_contacts.phone\x20NOT\x20IN\x20(?)',selectNotIn(_0x31c5bc,_0x3a6110,_0x4a3356,_0x75b9('0x3c'),[_0x75b9('0x3d'),_0x75b9('0x3e')]))['where'](_0x75b9('0x3f'),selectNotIn(_0x31c5bc,_0x3a6110,_0x4a3356,_0x75b9('0x3c'),[_0x75b9('0x3d')])))[_0x75b9('0x40')]();}function insertCmHopperBlack(_0x253045,_0x4cb68e,_0xb52af9,_0x3eb634){var _0x1bc1b0=[_0x75b9('0x26'),'cm_contacts.id','cm_contacts.ListId',_0x4cb68e+'.'+_0x3eb634,_0x75b9('0x2a'),_0x75b9('0x2b')];return squel[_0x75b9('0x2e')]()[_0x75b9('0x2f')](_0x75b9('0x41'))['fromQuery']([_0x75b9('0x14'),'ContactId',_0x75b9('0x42'),_0x3eb634,'createdAt',_0x75b9('0x43')],squel[_0x75b9('0x13')]()[_0x75b9('0x37')](_0x1bc1b0)[_0x75b9('0x44')](_0x4cb68e)[_0x75b9('0x15')](_0x75b9('0x38'),null,_0x75b9('0x39')+_0x4cb68e+_0x75b9('0x3a'))[_0x75b9('0x15')](_0xb52af9,null,_0xb52af9+_0x75b9('0x16')+_0x4cb68e+'.'+_0x3eb634)[_0x75b9('0x18')](_0x4cb68e+'.CmListId\x20=\x20?',_0x253045)[_0x75b9('0x18')](_0x75b9('0x45'),NOW)[_0x75b9('0x18')](_0x75b9('0x3f'),squel['select']()[_0x75b9('0x46')]('phone')[_0x75b9('0x44')](_0x75b9('0x41'))[_0x75b9('0x18')](_0x75b9('0x47'),_0x253045)[_0x75b9('0x18')](_0x3eb634+_0x75b9('0x17')+_0x4cb68e+'.'+_0x3eb634)))['toString']();}function insertTzCmHopper(_0xc4f69d,_0x5a58cb,_0x27124b,_0x1df56c,_0x1359a5,_0x519d8c){var _0x11c566=['cm_contacts.phone','date_add(cm_contacts.scheduledat,interval\x20'+_0x519d8c+_0x75b9('0x48'),_0x75b9('0x28'),_0x75b9('0x29'),_0x5a58cb+'.'+_0x1df56c,'cm_contacts.createdAt',_0x75b9('0x2b'),_0x75b9('0x2c'),_0x75b9('0x2d'),'\x22'+_0x1359a5+'\x22'];var _0x256ec6=squel[_0x75b9('0x2e')]()[_0x75b9('0x2f')](_0x75b9('0x3c'))['fromQuery'](['phone',_0x75b9('0x31'),'ContactId','ListId',_0x1df56c,'createdAt',_0x75b9('0x43'),_0x75b9('0x34'),_0x75b9('0x35'),'recallme'],squel[_0x75b9('0x13')]()[_0x75b9('0x37')](_0x11c566)[_0x75b9('0x44')](_0x5a58cb)[_0x75b9('0x15')](_0x75b9('0x38'),null,'cm_contacts.ListId\x20=\x20'+_0x5a58cb+_0x75b9('0x3a'))['join'](_0x27124b,null,_0x27124b+_0x75b9('0x16')+_0x5a58cb+'.'+_0x1df56c)[_0x75b9('0x15')](_0x519d8c,null,_0x519d8c+_0x75b9('0x16')+_0x5a58cb+'.'+_0x1df56c)[_0x75b9('0x18')](_0x5a58cb+_0x75b9('0x3b'),_0xc4f69d)[_0x75b9('0x18')](_0x75b9('0x45'),NOW)['where'](_0x75b9('0x3f'),selectNotIn(_0x5a58cb,_0x27124b,_0x1df56c,_0x75b9('0x3c'),[_0x75b9('0x3d'),'\x22onlyIfOpen\x22']))['where'](_0x75b9('0x3f'),selectNotIn(_0x5a58cb,_0x27124b,_0x1df56c,_0x75b9('0x3c'),[_0x75b9('0x3d')])))['toString']();return _0x256ec6;}function insertTzCmHopperBlack(_0x1a2fa6,_0x3eaab5,_0x1e6925,_0x230db4){var _0x21586a=[_0x75b9('0x26'),'cm_contacts.id',_0x75b9('0x29'),_0x3eaab5+'.'+_0x230db4,_0x75b9('0x2a'),_0x75b9('0x2b')];return squel[_0x75b9('0x2e')]()['into'](_0x75b9('0x41'))['fromQuery'](['phone','ContactId',_0x75b9('0x42'),_0x230db4,_0x75b9('0x33'),_0x75b9('0x43')],squel[_0x75b9('0x13')]()['fields'](_0x21586a)['from'](_0x3eaab5)[_0x75b9('0x15')](_0x75b9('0x38'),null,_0x75b9('0x39')+_0x3eaab5+_0x75b9('0x3a'))['join'](_0x1e6925,null,_0x1e6925+_0x75b9('0x16')+_0x3eaab5+'.'+_0x230db4)[_0x75b9('0x18')](_0x3eaab5+_0x75b9('0x3b'),_0x1a2fa6)[_0x75b9('0x18')](_0x75b9('0x45'),NOW)[_0x75b9('0x18')](_0x75b9('0x3f'),squel[_0x75b9('0x13')]()[_0x75b9('0x46')](_0x75b9('0x14'))[_0x75b9('0x44')](_0x75b9('0x41'))['where']('ListId\x20=\x20?',_0x1a2fa6)[_0x75b9('0x18')](_0x230db4+'\x20=\x20'+_0x3eaab5+'.'+_0x230db4)))[_0x75b9('0x40')]();}function insertCmHopperAdditionalPhones(_0x3e3e06){var _0x54ffd4=[_0x75b9('0x49'),'cm_contact_has_items.item',_0x75b9('0x4a'),_0x75b9('0x4b'),_0x75b9('0x4c')];return squel[_0x75b9('0x2e')]()[_0x75b9('0x2f')]('cm_hopper_additional_phones')['fromQuery']([_0x75b9('0x4d'),_0x75b9('0x14'),_0x75b9('0x4e'),_0x75b9('0x33'),'updatedAt'],squel[_0x75b9('0x13')]()[_0x75b9('0x37')](_0x54ffd4)['from'](_0x75b9('0x3c'))[_0x75b9('0x15')](_0x75b9('0x38'),null,'cm_contacts.id\x20=\x20cm_hopper.ContactId')[_0x75b9('0x15')](_0x75b9('0x4f'),null,_0x75b9('0x50'))[_0x75b9('0x18')](_0x75b9('0x51'),_0x3e3e06)[_0x75b9('0x18')]('cm_contacts.createdAt\x20=\x20?',NOW))['toString']();}function insertCmContact(_0x209662,_0x1b8b28,_0x29a3b8,_0xe6142b){var _0x1e9a46=_[_0x75b9('0x52')](_[_0x75b9('0x53')](_0xe6142b),[_0x75b9('0x42'),'CompanyId',_0x75b9('0x33'),_0x75b9('0x43'),_0x75b9('0x54')]);return squel[_0x75b9('0x2e')]()[_0x75b9('0x2f')](_0x75b9('0x38'))[_0x75b9('0x30')](_0x1e9a46,squel[_0x75b9('0x13')]()[_0x75b9('0x37')](_0x1e9a46)[_0x75b9('0x44')](_0x1b8b28)[_0x75b9('0x18')]('('+_0x29a3b8['join'](',')+')\x20NOT\x20IN\x20?',squel[_0x75b9('0x13')]()[_0x75b9('0x37')](_0x29a3b8)[_0x75b9('0x44')](_0x75b9('0x38'))[_0x75b9('0x18')](_0x75b9('0x47'),_0x209662)[_0x75b9('0x18')](_0x75b9('0x55')))[_0x75b9('0x18')](_0x75b9('0x56'),squel[_0x75b9('0x13')]()[_0x75b9('0x46')](_0x75b9('0x57'),'min_id')[_0x75b9('0x44')](_0x1b8b28)[_0x75b9('0x58')](_0x29a3b8[_0x75b9('0x15')](','))))[_0x75b9('0x40')]();}function handleStop(){logger[_0x75b9('0x59')](_0x75b9('0x5a'));stopped=!![];}function handleUncaughtException(_0x3630ea){logger[_0x75b9('0x5b')](_0x3630ea['message']);process[_0x75b9('0x5c')](0x1);}function handleError(_0x12b9e8,_0x50a1ca){stats[_0x75b9('0x5d')][_0x75b9('0x1d')]({'name':_0x50a1ca[_0x75b9('0x5e')],'message':_0x50a1ca[_0x75b9('0x5f')],'row':_0x12b9e8});}function handleQuery(_0x13ab94){logger['info'](_0x13ab94);return db[_0x75b9('0x60')][_0x75b9('0x61')](_0x13ab94)[_0x75b9('0x62')](function(_0x49773f){results[_0x75b9('0x1d')](_0x49773f);})['catch'](function(_0x4c7ce9){logger[_0x75b9('0x5b')](_0x4c7ce9['message']);});}function updateTzCampaigns(_0x4386f7){return new Promise(function(_0x3cddce,_0x30016e){var _0xd5469=squel[_0x75b9('0x13')]()[_0x75b9('0x37')]([_0x75b9('0x63'),_0x75b9('0x64')])[_0x75b9('0x44')]('campaigns')[_0x75b9('0x15')]('campaigns_has_cm_lists',null,_0x75b9('0x65'))[_0x75b9('0x18')]('campaigns_has_cm_lists.CmListId='+_0x4386f7);db[_0x75b9('0x60')][_0x75b9('0x61')](_0xd5469[_0x75b9('0x40')]())[_0x75b9('0x62')](function(_0x42a113){var _0x432bf1=[];for(var _0x3a1332=0x0;_0x3a1332<_0x42a113['length'];_0x3a1332++){_0x432bf1[_0x75b9('0x1d')](getTimezoneData(_0x42a113[_0x3a1332],tmp_campaigns));}BPromise['all'](_0x432bf1)['then'](function(){_0x3cddce({'val':0x1});});})[_0x75b9('0x66')](function(_0x1f1986){logger[_0x75b9('0x5b')](_0x1f1986[_0x75b9('0x5f')]);_0x3cddce({'val':0x0});});});}function updateTzVoiceQueues(_0x1638ae){return new Promise(function(_0x2d7438,_0x5ae640){var _0x1a9727=squel[_0x75b9('0x13')]()[_0x75b9('0x37')]([_0x75b9('0x67'),_0x75b9('0x68')])[_0x75b9('0x44')](_0x75b9('0x69'))['join'](_0x75b9('0x6a'),null,_0x75b9('0x6b'))[_0x75b9('0x18')](_0x75b9('0x6c')+_0x1638ae);db['sequelize'][_0x75b9('0x61')](_0x1a9727[_0x75b9('0x40')]())[_0x75b9('0x62')](function(_0x213f58){var _0x296bad=[];for(var _0x5df8da=0x0;_0x5df8da<_0x213f58[_0x75b9('0x1c')];_0x5df8da++){_0x296bad[_0x75b9('0x1d')](getTimezoneData(_0x213f58[_0x5df8da],tmp_voice_queues));}BPromise[_0x75b9('0x1e')](_0x296bad)[_0x75b9('0x1f')](function(){_0x2d7438({'val':0x1});});})['catch'](function(_0x561d72){logger['error'](_0x561d72[_0x75b9('0x5f')]);_0x2d7438({'val':0x0});});});}function getTimezoneData(_0x2c7917,_0x501ec3){return new Promise(function(_0x5cbb65,_0x252993){var _0x2c456b=shared[_0x75b9('0x6d')];var _0x1b8724=_0x2c456b[_0x2c7917[_0x75b9('0x6e')]];if(_[_0x75b9('0x21')](_0x1b8724)){_0x5cbb65({'ret':0x1});}else{var _0x3a7409=_0x1b8724[_0x75b9('0x6f')];var _0x14af6c=squel[_0x75b9('0x2e')]()['into'](_0x501ec3)[_0x75b9('0x70')]('id',_0x2c7917['id'])['set'](_0x75b9('0x71'),_0x3a7409)['set'](_0x75b9('0x6e'),_0x2c7917[_0x75b9('0x6e')])[_0x75b9('0x40')]();return db[_0x75b9('0x60')][_0x75b9('0x61')](_0x14af6c)[_0x75b9('0x62')](function(_0x3cdd75){_0x5cbb65({'ret':0x1});})[_0x75b9('0x66')](function(_0x273c35){logger[_0x75b9('0x5b')](_0x273c35['message']);_0x252993({'ret':0x1});});}});}function handleTZQuery(_0x5d6972){logger[_0x75b9('0x59')](_0x5d6972);return db[_0x75b9('0x60')][_0x75b9('0x61')](_0x5d6972)[_0x75b9('0x62')](function(_0x5981a7){})[_0x75b9('0x66')](function(_0x319470){logger[_0x75b9('0x5b')](_0x319470[_0x75b9('0x5f')]);});}function main(_0x2d6cb6,_0x1de266,_0x3953b1,_0x9d8365){logger[_0x75b9('0x59')](_0x75b9('0x72'),_0x2d6cb6,JSON['stringify'](_0x1de266));process[_0x75b9('0x73')](_0x75b9('0x74'));var _0x4ef5db=_0x1de266['binding'];var _0x10652b=_['clone'](_0x4ef5db);var _0x48ae42=_0x1de266['socket_timestamp'];var _0x451133=path[_0x75b9('0x15')](config[_0x75b9('0x75')],_0x75b9('0x76'),_0x48ae42+_0x75b9('0x77'));hasTZ=_['keys'](_0x4ef5db)[_0x75b9('0x78')]('dialTimezone');var _0x412f1b=_[_0x75b9('0x53')](_0x4ef5db)[_0x75b9('0x15')]();logger[_0x75b9('0x59')](_0x75b9('0x79'),_0x412f1b);db['ContactItemType'][_0x75b9('0x7a')]({'raw':!![],'attributes':['id',_0x75b9('0x7b')]})[_0x75b9('0x1f')](function(_0x6614fe){for(var _0x205460=0x0;_0x205460<_0x6614fe[_0x75b9('0x1c')];_0x205460++){if(_0x6614fe[_0x205460][_0x75b9('0x7b')]in _0x4ef5db){contactItemTypes[_0x75b9('0x1d')](_0x6614fe[_0x205460]);delete _0x10652b[_0x6614fe[_0x205460][_0x75b9('0x7b')]];hasAdditionalPhones=!![];}for(var _0x454bdf in _0x4ef5db){if(_0x6614fe[_0x205460]['name']+'_description'===_0x454bdf){phoneDescriptions[_0x75b9('0x1d')]({'itemTypeId':_0x6614fe[_0x205460]['id'],'description':_0x454bdf});delete _0x10652b[_0x454bdf];}}}if(hasAdditionalPhones)_0x10652b[_0x75b9('0x1b')]='';var _0x328062=_['keys'](_0x10652b)['join']();logger[_0x75b9('0x59')](_0x75b9('0x79'),_0x328062);fs['writeFileSync'](_0x451133,_0x328062+'\x0a');Papa['parse'](fs[_0x75b9('0x7c')](_0x2d6cb6),{'header':!![],'skipEmptyLines':!![],'step':function(_0x5a1eeb,_0x2c866e){try{for(var _0x533236=0x0,_0x3fe258=[];_0x533236<_0x5a1eeb[_0x75b9('0x7d')][_0x75b9('0x1c')];_0x533236++){stats[_0x75b9('0x7e')]+=0x1;if(_0x5a1eeb[_0x75b9('0x5d')][_0x533236]){handleError(_0x5a1eeb['data'][_0x533236],_0x5a1eeb['errors'][_0x533236]);}else{var _0x4da35d=[];var _0x241269=[];var _0x2e348b={};for(var _0x296b8d in _0x4ef5db){let _0x27f5d4=contactItemTypes[_0x75b9('0x7f')](_0x254ed3=>_0x254ed3[_0x75b9('0x7b')]===_0x296b8d);let _0x563093=contactItemTypes[_0x75b9('0x7f')](_0x51244d=>_0x51244d['name']+_0x75b9('0x80')===_0x296b8d);if(_[_0x75b9('0x21')](_0x27f5d4)&&_['isNil'](_0x563093)){if(_0x4ef5db[_0x75b9('0x81')](_0x296b8d)){if(_0x5a1eeb[_0x75b9('0x7d')][_0x533236][_0x4ef5db[_0x296b8d]]){var _0x50b57e=_['trim'](_0x5a1eeb[_0x75b9('0x7d')][_0x533236][_0x4ef5db[_0x296b8d]]['replace'](/"/g,'\x27'));switch(_0x296b8d){case _0x75b9('0x31'):var _0xc33477=moment(_0x50b57e,_0x75b9('0x10'),!![]);if(_0xc33477[_0x75b9('0x82')]()){_0x3fe258['push']('\x22'+_0x50b57e+'\x22');}else{_0x4da35d[_0x75b9('0x1d')](_0x75b9('0x83'));}break;case _0x75b9('0x34'):var _0x202bb5=parseInt(_0x50b57e);_0x50b57e=_[_0x75b9('0x84')](_0x202bb5)||_0x202bb5<0x0||_0x202bb5>0x4?_0x9d8365?0x3:0x2:_0x202bb5;_0x3fe258[_0x75b9('0x1d')]('\x22'+_0x50b57e+'\x22');break;case _0x75b9('0x35'):var _0x2783cf=parseInt(_0x50b57e);if(_[_0x75b9('0x85')](_0x2783cf)&&_[_0x75b9('0x78')](_0x3953b1,_0x2783cf)){_0x3fe258[_0x75b9('0x1d')]('\x22'+_0x2783cf+'\x22');}else{_0x4da35d['push'](_0x75b9('0x86'));}break;case _0x75b9('0x87'):if(isEmail(_0x50b57e)){_0x3fe258[_0x75b9('0x1d')]('\x22'+_0x50b57e+'\x22');}else{_0x4da35d['push']('email\x20wrong\x20format');}break;case _0x75b9('0x88'):var _0x4e1bfd=moment(_0x50b57e,_0x75b9('0x89'),!![]);if(_0x4e1bfd[_0x75b9('0x82')]()){_0x3fe258[_0x75b9('0x1d')]('\x22'+_0x50b57e+'\x22');}else{_0x4da35d['push'](_0x75b9('0x8a'));}break;case _0x75b9('0x6e'):var _0x28ac8d=shared[_0x75b9('0x6d')];var _0x46218e=_0x28ac8d[_0x50b57e];if(!_[_0x75b9('0x21')](_0x46218e)){var _0xc9816e=_0x46218e[_0x75b9('0x6f')];_0x3fe258[_0x75b9('0x1d')]('\x22'+_0x50b57e+'\x22');_0x3fe258['push']('\x22'+_0xc9816e+'\x22');}break;default:_0x3fe258[_0x75b9('0x1d')]('\x22'+_0x50b57e+'\x22');}}else{switch(_0x296b8d){case _0x75b9('0x8b'):case _0x75b9('0x14'):_0x4da35d[_0x75b9('0x1d')](_0x296b8d+_0x75b9('0x8c'));break;default:_0x3fe258[_0x75b9('0x1d')]('\x22\x22');}}}}else{var _0x3ffe0c='';if(!_[_0x75b9('0x21')](_0x27f5d4)){if(!_0x2e348b['hasOwnProperty'](_0x27f5d4['id'])){if(!_[_0x75b9('0x21')](_0x5a1eeb[_0x75b9('0x7d')][_0x533236][_0x4ef5db[_0x296b8d]])){var _0x50b57e=_['trim'](_0x5a1eeb[_0x75b9('0x7d')][_0x533236][_0x4ef5db[_0x296b8d]][_0x75b9('0x8d')](/"/g,'\x27'));var _0x5cbdd7=phoneDescriptions[_0x75b9('0x7f')](_0x3977a1=>_0x3977a1[_0x75b9('0x8e')]===_0x27f5d4['id']);if(!_[_0x75b9('0x21')](_0x5cbdd7)){var _0x522fe8=_[_0x75b9('0x8f')](_0x5a1eeb['data'][_0x533236][_0x4ef5db[_0x5cbdd7[_0x75b9('0x90')]]][_0x75b9('0x8d')](/"/g,'\x27'));if(!_[_0x75b9('0x21')](_0x522fe8))_0x50b57e=_0x50b57e+'§'+_0x522fe8;}if(_0x3ffe0c=='')_0x3ffe0c=_0x50b57e;else _0x3ffe0c+='|'+_0x50b57e;}_0x241269[_0x75b9('0x1d')](_0x27f5d4['id']+':'+_0x3ffe0c);_0x2e348b[_0x27f5d4['id']]=0x1;}}}}if(hasAdditionalPhones){_0x3fe258[_0x75b9('0x1d')]('\x22'+_0x241269[_0x75b9('0x15')](';')+'\x22');}if(_0x4da35d[_0x75b9('0x1c')]){handleError(_0x5a1eeb[_0x75b9('0x7d')][_0x533236],{'code':'SystemRow','message':_0x4da35d[_0x75b9('0x15')]()});}else{fs[_0x75b9('0x91')](_0x451133,_0x3fe258[_0x75b9('0x15')]()+'\x0a');}_0x3fe258=[];}if(!(stats['rows']%0xc8)){socket[_0x75b9('0x92')](_0x75b9('0x93')+_0x48ae42,stats);stats[_0x75b9('0x5d')]=[];}}if(stopped){logger[_0x75b9('0x59')](_0x75b9('0x94'));_0x2c866e[_0x75b9('0x95')]();}}catch(_0x5ebc13){handleError(_0x5a1eeb['data'][_0x533236],{'code':_0x75b9('0x96'),'message':_0x5ebc13['message']});logger[_0x75b9('0x5b')](_0x75b9('0x97'),_0x5ebc13[_0x75b9('0x5f')]);}},'complete':function(){try{var _0xee8dc2=[];var _0x29b471=[];var _0x5619f9='cm_contacts';if(_0x1de266[_0x75b9('0x98')]&&_0x1de266[_0x75b9('0x98')][_0x75b9('0x1c')]){_0x5619f9=_0x75b9('0x99')+_0x48ae42;_0xee8dc2[_0x75b9('0x1d')]('CREATE\x20TABLE\x20'+_0x5619f9+_0x75b9('0x9a'));}tmp_campaigns=_0x75b9('0x9b')+_0x48ae42;tmp_voice_queues=_0x75b9('0x9c')+_0x48ae42;_0x29b471[_0x75b9('0x1d')](_0x75b9('0x9d')+tmp_campaigns+_0x75b9('0x9e'));_0x29b471[_0x75b9('0x1d')](_0x75b9('0x9d')+tmp_voice_queues+_0x75b9('0x9e'));BPromise['each'](_0x29b471,handleTZQuery)[_0x75b9('0x1f')](function(_0x11cce3){updateTzCampaigns(_0x1de266[_0x75b9('0x42')])[_0x75b9('0x1f')](function(_0x3e3818){updateTzVoiceQueues(_0x1de266[_0x75b9('0x42')])['then'](function(_0x3c836b){if(hasTZ)_0x328062=_0x328062[_0x75b9('0x8d')](_0x75b9('0x6e'),_0x75b9('0x9f'));var _0x47bb5f=util[_0x75b9('0x11')](_0x75b9('0xa0'),_0x451133,_0x5619f9,_0x328062,_0x1de266[_0x75b9('0x42')],_0x1de266[_0x75b9('0xa1')]||null,NOW,NOW);if(_['isNil'](_0x4ef5db['scheduledat'])){_0x47bb5f+=_0x75b9('0xa2');}_0xee8dc2[_0x75b9('0x1d')](_0x47bb5f);if(_0x1de266[_0x75b9('0x98')]&&_0x1de266[_0x75b9('0x98')]['length']){_0xee8dc2[_0x75b9('0x1d')](insertCmContact(_0x1de266[_0x75b9('0x42')],_0x5619f9,_0x1de266['duplicates'],_0x4ef5db));_0xee8dc2['push'](_0x75b9('0xa3')+_0x5619f9+';');}BPromise[_0x75b9('0xa4')](_0xee8dc2,handleQuery)[_0x75b9('0x1f')](function(_0x411880){BPromise[_0x75b9('0x1e')]([handleAdditionalPhones()])[_0x75b9('0x1f')](function(){_0xee8dc2=[];for(var _0x17865c=0x0;_0x17865c<promisesAdditionalPhones[_0x75b9('0x1c')];_0x17865c++){if(promisesAdditionalPhones[_0x17865c][_0x75b9('0x14')]!='§'){_0xee8dc2['push'](createAdditionalPhone(promisesAdditionalPhones[_0x17865c][_0x75b9('0xa5')],promisesAdditionalPhones[_0x17865c][_0x75b9('0xa6')],promisesAdditionalPhones[_0x17865c]['phone'],promisesAdditionalPhones[_0x17865c][_0x75b9('0xa7')]));}}BPromise[_0x75b9('0x1e')](_0xee8dc2)['then'](function(){_0xee8dc2=[];if(hasTZ){_0xee8dc2['push'](insertTzCmHopper(_0x1de266[_0x75b9('0x42')],_0x75b9('0x6a'),_0x75b9('0x69'),_0x75b9('0xa8'),_0x9d8365,tmp_voice_queues));_0xee8dc2[_0x75b9('0x1d')](insertTzCmHopperBlack(_0x1de266[_0x75b9('0x42')],_0x75b9('0xa9'),'voice_queues',_0x75b9('0xa8')));_0xee8dc2[_0x75b9('0x1d')](insertTzCmHopper(_0x1de266['ListId'],'campaigns_has_cm_lists','campaigns',_0x75b9('0xaa'),_0x9d8365,tmp_campaigns));_0xee8dc2[_0x75b9('0x1d')](insertTzCmHopperBlack(_0x1de266['ListId'],_0x75b9('0xab'),_0x75b9('0xac'),_0x75b9('0xaa')));_0xee8dc2['push'](insertCmHopperAdditionalPhones(_0x1de266[_0x75b9('0x42')]));}else{_0xee8dc2[_0x75b9('0x1d')](insertCmHopper(_0x1de266[_0x75b9('0x42')],_0x75b9('0x6a'),_0x75b9('0x69'),'VoiceQueueId',_0x9d8365));_0xee8dc2[_0x75b9('0x1d')](insertCmHopperBlack(_0x1de266[_0x75b9('0x42')],_0x75b9('0xa9'),_0x75b9('0x69'),_0x75b9('0xa8')));_0xee8dc2['push'](insertCmHopper(_0x1de266[_0x75b9('0x42')],'campaigns_has_cm_lists',_0x75b9('0xac'),_0x75b9('0xaa'),_0x9d8365));_0xee8dc2[_0x75b9('0x1d')](insertCmHopperBlack(_0x1de266['ListId'],'campaigns_has_cm_blacklists','campaigns','CampaignId'));_0xee8dc2[_0x75b9('0x1d')](insertCmHopperAdditionalPhones(_0x1de266['ListId']));}_0xee8dc2[_0x75b9('0x1d')](_0x75b9('0xa3')+tmp_campaigns+';');_0xee8dc2[_0x75b9('0x1d')]('DROP\x20TABLE\x20'+tmp_voice_queues+';');BPromise[_0x75b9('0xa4')](_0xee8dc2,handleQuery)['then'](function(_0x1d2d6e){stats['finish']=!![];stats[_0x75b9('0xad')]=_0x1de266[_0x75b9('0x98')]&&_0x1de266[_0x75b9('0x98')][_0x75b9('0x1c')]?results[0x2][_0x75b9('0xad')]:results[0x0]['affectedRows'];socket[_0x75b9('0x92')](_0x75b9('0x93')+_0x48ae42,stats);fs[_0x75b9('0xae')](_0x2d6cb6);fs[_0x75b9('0xae')](_0x451133);process[_0x75b9('0x5c')](0x0);})[_0x75b9('0x66')](function(_0x4defdd){logger['error'](_0x4defdd['message']);process[_0x75b9('0x5c')](0x1);});});});})[_0x75b9('0x66')](function(_0x7b0c44){logger[_0x75b9('0x5b')](_0x7b0c44['message']);process['exit'](0x1);});});});});}catch(_0x3450fa){logger['error'](_0x75b9('0xaf'),_0x3450fa[_0x75b9('0x5f')]);process[_0x75b9('0x5c')](0x1);}},'error':function(_0x3fec49,_0x195333,_0x10a8b1,_0x5206af){throw new Error(_0x5206af);}});});}function validate(){if(process[_0x75b9('0xb0')]&&process['argv']['length']<0x4){throw new Error('arguments\x20<filename>\x20<parameters>\x20<agents>');}var _0x59660b=path[_0x75b9('0x15')](config[_0x75b9('0x75')],_0x75b9('0x76'),process[_0x75b9('0xb0')][0x2]);if(!fs[_0x75b9('0xb1')](_0x59660b)){throw new Error(_0x75b9('0xb2'));}var _0x2e88d6={};try{_0x2e88d6=JSON[_0x75b9('0xb3')](process['argv'][0x3]);if(!_0x2e88d6['binding']){throw new Error(_0x75b9('0xb4'));}if(!_0x2e88d6[_0x75b9('0xb5')][_0x75b9('0x14')]){throw new Error(_0x75b9('0xb6'));}if(!_0x2e88d6[_0x75b9('0xb5')][_0x75b9('0x8b')]){throw new Error(_0x75b9('0xb7'));}var _0x3cdb80=0x0;if(_0x2e88d6[_0x75b9('0xb5')][_0x75b9('0x35')]){_0x3cdb80=0x1;}if(!_0x2e88d6['ListId']){throw new Error('ListId\x20is\x20mandatory');}}catch(_0x43988a){throw new Error('body\x20id\x20mandatory');}var _0x1e9236=[];try{_0x1e9236=_['map'](JSON[_0x75b9('0xb3')](process[_0x75b9('0xb0')][0x4]),'id');}catch(_0x1365b0){logger[_0x75b9('0x59')](_0x75b9('0xb8'));}main(_0x59660b,_0x2e88d6,_0x1e9236,_0x3cdb80);}validate();process['on'](_0x75b9('0xb9'),handleStop);process['on']('uncaughtException',handleUncaughtException);
\ No newline at end of file
+var _0x42d4=['scheduledat','ContactId','ListId','createdAt','updatedAt','priority','UserId','recallme','fields','cm_contacts','cm_contacts.ListId\x20=\x20','.CmListId','.CmListId\x20=\x20?','cm_contacts.createdAt\x20=\x20?','cm_contacts.phone\x20NOT\x20IN\x20(?)','\x22always\x22','cm_hopper','toString','cm_hopper_black','ListId\x20=\x20?','date_add(cm_contacts.scheduledat,interval\x20','.offset-cm_contacts.utcOffset\x20minute)','cm_contacts.createdAt','cm_contacts.priority','\x22onlyIfOpen\x22','cm_contact_has_items.createdAt','cm_contact_has_items.updatedAt','CmHopperId','OrderBy','cm_contacts.id\x20=\x20cm_contact_has_items.CmContactId','cm_hopper.ListId\x20=\x20?','concat','CompanyId','scheduledAt','id\x20IN\x20?','MIN(id)','group','Received\x20SIGINT','error','message','exit','errors','info','query','spread','catch','campaigns.dialTimezone','campaigns_has_cm_lists','campaigns.id\x20=\x20campaigns_has_cm_lists.CampaignId','sequelize','voice_queues.id','voice_queues.dialTimezone','voice_queues_has_cm_lists','voice_queues.id\x20=\x20voice_queues_has_cm_lists.VoiceQueueId','voice_queues_has_cm_lists.CmListId=','timezones','utcOffset','set','offset','dialTimezone','main','start','binding','clone','socket_timestamp','root','server/files/tmp','.csv','keys','includes','header','findAll','name','_description','writeFileSync','parse','createReadStream','data','rows','find','hasOwnProperty','replace','isValid','isNaN','agent\x20not\x20exists','email\x20wrong\x20format','dateOfBirth','YYYY-MM-DD','firstName','trim','itemTypeId','SystemRow','appendFileSync','Abort\x20parser','abort','SystemError','step','duplicates','CREATE\x20TABLE\x20','campaigns_','voice_queues_','(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()','DROP\x20TABLE\x20','contactId','contactTypeId','orderBy','voice_queues','VoiceQueueId','voice_queues_has_cm_blacklists','CampaignId','campaigns_has_cm_blacklists','campaigns','affectedRows','emit','contact:import:','unlink','complete','argv','arguments\x20<filename>\x20<parameters>\x20<agents>','existsSync','binding\x20doesn\x27t\x20exists','phone\x20is\x20mandatory','firstName\x20is\x20mandatory','ListId\x20is\x20mandatory','body\x20id\x20mandatory','map','No\x20agent\x20available','uncaughtException','path','papaparse','util','bluebird','moment','ioredis','../../../mysqldb','../../../config/logger','import','redis','defaults','localhost','socket.io-emitter','format','YYYY-MM-DD\x20HH:mm:ss','select','field','phone','from','join','.id\x20=\x20','where','\x20=\x20','AdditionalPhones','then','push','all','split','length','isNil','filter','CmContactHasItem','findOne','update','updated','create','PHONE','inserted','cm_contacts.phone','cm_contacts.id','cm_contacts.ListId','cm_contacts.updatedAt','cm_contacts.UserId','insert','into','fromQuery'];(function(_0x352fbf,_0x17cd4f){var _0x3d4c9b=function(_0x424bf5){while(--_0x424bf5){_0x352fbf['push'](_0x352fbf['shift']());}};_0x3d4c9b(++_0x17cd4f);}(_0x42d4,0x1e5));var _0x442d=function(_0x32e419,_0xff0455){_0x32e419=_0x32e419-0x0;var _0x1f0315=_0x42d4[_0x32e419];return _0x1f0315;};'use strict';var fs=require('fs');var path=require(_0x442d('0x0'));var _=require('lodash');var Papa=require(_0x442d('0x1'));var util=require(_0x442d('0x2'));var BPromise=require(_0x442d('0x3'));var moment=require(_0x442d('0x4'));var squel=require('squel');var Redis=require(_0x442d('0x5'));var db=require(_0x442d('0x6'))['db'];var config=require('../../../config/environment');var shared=require('../../../config/environment/shared');var logger=require(_0x442d('0x7'))(_0x442d('0x8'));config[_0x442d('0x9')]=_[_0x442d('0xa')](config[_0x442d('0x9')],{'host':_0x442d('0xb'),'port':0x18eb});var socket=require(_0x442d('0xc'))(new Redis(config['redis']));var stats={'finish':![],'errors':[],'rows':0x0,'affectedRows':0x0};var results=[];var promisesAdditionalPhones=[];var orderBy=0x0;var stopped=![];var NOW=moment()[_0x442d('0xd')]('YYYY-MM-DD\x20HH:mm:ss');var contactItemTypes=[];var phoneDescriptions=[];var hasAdditionalPhones=![];var tmp_voice_queues;var tmp_campaigns;var tzOffset=0x0;var hasTZ;var NOW=moment()['format'](_0x442d('0xe'));function isEmail(_0x161564){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'](_0x161564);}function selectNotIn(_0x5e740b,_0x29cd67,_0xf6c7e4,_0x1e3c9e,_0x492467){return squel[_0x442d('0xf')]()[_0x442d('0x10')](_0x442d('0x11'))[_0x442d('0x12')](_0x1e3c9e)[_0x442d('0x13')](_0x29cd67,null,_0x29cd67+_0x442d('0x14')+_0x1e3c9e+'.'+_0xf6c7e4)[_0x442d('0x15')](_0x1e3c9e+'.'+_0xf6c7e4+_0x442d('0x16')+_0x5e740b+'.'+_0xf6c7e4)[_0x442d('0x15')](_0x29cd67+'.dialCheckDuplicateType\x20IN\x20('+_0x492467[_0x442d('0x13')]()+')');}function handleAdditionalPhones(){return new Promise(function(_0xcc4fc2,_0x6afab3){promisesAdditionalPhones=[];return db['CmContact']['findAll']({'raw':!![],'attributes':['id',_0x442d('0x17')],'where':{'createdAt':NOW,'AdditionalPhones':{'$ne':null}}})[_0x442d('0x18')](function(_0x303209){if(_0x303209!==null){var _0x1f4e4d=[];for(var _0x1e8ad1=0x0;_0x1e8ad1<_0x303209['length'];_0x1e8ad1++){var _0x10d7d6=_0x303209[_0x1e8ad1];_0x1f4e4d[_0x442d('0x19')](insertAdditionalPhones(_0x10d7d6));}}Promise[_0x442d('0x1a')](_0x1f4e4d)[_0x442d('0x18')](function(){_0xcc4fc2({'val':0x1});});});});}function insertAdditionalPhones(_0x5e3c44){return new Promise(function(_0x586aca,_0x2e6321){var _0x29fe52=_0x5e3c44[_0x442d('0x17')];var _0x494d95=_0x29fe52[_0x442d('0x1b')](';');var _0xa9e4f0=[];orderBy=0x0;for(var _0x189e6f=0x0;_0x189e6f<_0x494d95[_0x442d('0x1c')];_0x189e6f++){_0xa9e4f0['push'](splitAdditionalPhone(_0x5e3c44['id'],_0x494d95[_0x189e6f]));}Promise['all'](_0xa9e4f0)[_0x442d('0x18')](function(){_0x586aca({'val':_0x494d95[_0x442d('0x1c')]});});});}function splitAdditionalPhone(_0x12d4ce,_0x2519af){return new Promise(function(_0x6a2964,_0x2d2300){var _0x3190ad=_0x2519af[_0x442d('0x1b')](':');var _0x2d139c=_0x3190ad[0x0];var _0x3d637c=_0x3190ad[0x1];if(!_[_0x442d('0x1d')](_0x3d637c)){var _0xf9d1ec=_0x3d637c[_0x442d('0x1b')]('|');var _0x29d35a=[];for(var _0x385c24=0x0;_0x385c24<_0xf9d1ec[_0x442d('0x1c')];_0x385c24++){if(_0xf9d1ec[_0x385c24]!==''){var _0x270769=_[_0x442d('0x1e')](promisesAdditionalPhones,{'contactId':_0x12d4ce,'phone':_0xf9d1ec[_0x385c24]});if(_0x270769[_0x442d('0x1c')]==0x0){orderBy++;promisesAdditionalPhones['push']({'contactId':_0x12d4ce,'contactTypeId':_0x2d139c,'phone':_0xf9d1ec[_0x385c24],'orderBy':orderBy});}}}_0x6a2964({'ok':0x1});}else _0x6a2964({'res':0x0});});}function createAdditionalPhone(_0x5c8a9a,_0x1a029c,_0x460586,_0x3a4579){var _0x521085='';var _0x2653bf='';var _0x413e2f=_0x460586[_0x442d('0x1b')]('§');_0x521085=_0x413e2f[0x0];if(_0x413e2f[_0x442d('0x1c')]==0x2)_0x2653bf=_0x413e2f[0x1];return new Promise(function(_0x5b1019,_0x195491){return db[_0x442d('0x1f')][_0x442d('0x20')]({'where':{'CmContactId':_0x5c8a9a,'item':_0x521085}})[_0x442d('0x18')](function(_0x52faf){if(_0x52faf){return db[_0x442d('0x1f')][_0x442d('0x21')]({'ItemTypeId':_0x1a029c,'description':_0x2653bf,'OrderBy':_0x3a4579},{'where':{'CmContactId':_0x5c8a9a,'item':_0x521085}})[_0x442d('0x18')](function(_0x3a638e){_0x5b1019({'res':_0x442d('0x22')});});}else{return db[_0x442d('0x1f')][_0x442d('0x23')]({'CmContactId':_0x5c8a9a,'item':_0x521085,'description':_0x2653bf,'ItemTypeId':_0x1a029c,'OrderBy':_0x3a4579,'ItemClass':_0x442d('0x24')})[_0x442d('0x18')](function(_0x5c9521){_0x5b1019({'res':_0x442d('0x25')});});}});});}function insertCmHopper(_0x2d162c,_0x262d91,_0x2ea550,_0x1ed887,_0x17c154){var _0x49514d=[_0x442d('0x26'),'cm_contacts.scheduledat',_0x442d('0x27'),_0x442d('0x28'),_0x262d91+'.'+_0x1ed887,'cm_contacts.createdAt',_0x442d('0x29'),'cm_contacts.priority',_0x442d('0x2a'),'\x22'+_0x17c154+'\x22'];return squel[_0x442d('0x2b')]()[_0x442d('0x2c')]('cm_hopper')[_0x442d('0x2d')]([_0x442d('0x11'),_0x442d('0x2e'),_0x442d('0x2f'),_0x442d('0x30'),_0x1ed887,_0x442d('0x31'),_0x442d('0x32'),_0x442d('0x33'),_0x442d('0x34'),_0x442d('0x35')],squel['select']()[_0x442d('0x36')](_0x49514d)[_0x442d('0x12')](_0x262d91)[_0x442d('0x13')](_0x442d('0x37'),null,_0x442d('0x38')+_0x262d91+_0x442d('0x39'))['join'](_0x2ea550,null,_0x2ea550+'.id\x20=\x20'+_0x262d91+'.'+_0x1ed887)[_0x442d('0x15')](_0x262d91+_0x442d('0x3a'),_0x2d162c)[_0x442d('0x15')](_0x442d('0x3b'),NOW)[_0x442d('0x15')](_0x442d('0x3c'),selectNotIn(_0x262d91,_0x2ea550,_0x1ed887,'cm_hopper',[_0x442d('0x3d'),'\x22onlyIfOpen\x22']))[_0x442d('0x15')]('cm_contacts.phone\x20NOT\x20IN\x20(?)',selectNotIn(_0x262d91,_0x2ea550,_0x1ed887,_0x442d('0x3e'),[_0x442d('0x3d')])))[_0x442d('0x3f')]();}function insertCmHopperBlack(_0x39d99a,_0x3b22c5,_0x2efc42,_0x34ff2f){var _0x4e2613=[_0x442d('0x26'),_0x442d('0x27'),'cm_contacts.ListId',_0x3b22c5+'.'+_0x34ff2f,'cm_contacts.createdAt',_0x442d('0x29')];return squel[_0x442d('0x2b')]()[_0x442d('0x2c')](_0x442d('0x40'))[_0x442d('0x2d')]([_0x442d('0x11'),'ContactId','ListId',_0x34ff2f,_0x442d('0x31'),_0x442d('0x32')],squel[_0x442d('0xf')]()[_0x442d('0x36')](_0x4e2613)['from'](_0x3b22c5)['join'](_0x442d('0x37'),null,_0x442d('0x38')+_0x3b22c5+_0x442d('0x39'))[_0x442d('0x13')](_0x2efc42,null,_0x2efc42+_0x442d('0x14')+_0x3b22c5+'.'+_0x34ff2f)[_0x442d('0x15')](_0x3b22c5+_0x442d('0x3a'),_0x39d99a)[_0x442d('0x15')](_0x442d('0x3b'),NOW)['where'](_0x442d('0x3c'),squel['select']()[_0x442d('0x10')](_0x442d('0x11'))[_0x442d('0x12')](_0x442d('0x40'))['where'](_0x442d('0x41'),_0x39d99a)[_0x442d('0x15')](_0x34ff2f+'\x20=\x20'+_0x3b22c5+'.'+_0x34ff2f)))[_0x442d('0x3f')]();}function insertTzCmHopper(_0x25c31f,_0x529bc0,_0x152862,_0x5fb3b0,_0x18bbc1,_0x15a871){var _0x552eb5=[_0x442d('0x26'),_0x442d('0x42')+_0x15a871+_0x442d('0x43'),'cm_contacts.id',_0x442d('0x28'),_0x529bc0+'.'+_0x5fb3b0,_0x442d('0x44'),_0x442d('0x29'),_0x442d('0x45'),_0x442d('0x2a'),'\x22'+_0x18bbc1+'\x22'];var _0x4a65bf=squel[_0x442d('0x2b')]()[_0x442d('0x2c')](_0x442d('0x3e'))[_0x442d('0x2d')]([_0x442d('0x11'),_0x442d('0x2e'),'ContactId',_0x442d('0x30'),_0x5fb3b0,_0x442d('0x31'),_0x442d('0x32'),'priority','UserId',_0x442d('0x35')],squel[_0x442d('0xf')]()['fields'](_0x552eb5)[_0x442d('0x12')](_0x529bc0)[_0x442d('0x13')]('cm_contacts',null,'cm_contacts.ListId\x20=\x20'+_0x529bc0+'.CmListId')[_0x442d('0x13')](_0x152862,null,_0x152862+'.id\x20=\x20'+_0x529bc0+'.'+_0x5fb3b0)[_0x442d('0x13')](_0x15a871,null,_0x15a871+'.id\x20=\x20'+_0x529bc0+'.'+_0x5fb3b0)[_0x442d('0x15')](_0x529bc0+'.CmListId\x20=\x20?',_0x25c31f)[_0x442d('0x15')](_0x442d('0x3b'),NOW)['where'](_0x442d('0x3c'),selectNotIn(_0x529bc0,_0x152862,_0x5fb3b0,_0x442d('0x3e'),['\x22always\x22',_0x442d('0x46')]))[_0x442d('0x15')](_0x442d('0x3c'),selectNotIn(_0x529bc0,_0x152862,_0x5fb3b0,_0x442d('0x3e'),['\x22always\x22'])))['toString']();return _0x4a65bf;}function insertTzCmHopperBlack(_0xc78b57,_0x10b38d,_0x6ecefa,_0x2a6ad2){var _0x457def=[_0x442d('0x26'),_0x442d('0x27'),'cm_contacts.ListId',_0x10b38d+'.'+_0x2a6ad2,'cm_contacts.createdAt',_0x442d('0x29')];return squel[_0x442d('0x2b')]()[_0x442d('0x2c')]('cm_hopper_black')[_0x442d('0x2d')]([_0x442d('0x11'),_0x442d('0x2f'),'ListId',_0x2a6ad2,_0x442d('0x31'),'updatedAt'],squel[_0x442d('0xf')]()[_0x442d('0x36')](_0x457def)['from'](_0x10b38d)['join']('cm_contacts',null,'cm_contacts.ListId\x20=\x20'+_0x10b38d+_0x442d('0x39'))[_0x442d('0x13')](_0x6ecefa,null,_0x6ecefa+_0x442d('0x14')+_0x10b38d+'.'+_0x2a6ad2)[_0x442d('0x15')](_0x10b38d+'.CmListId\x20=\x20?',_0xc78b57)['where']('cm_contacts.createdAt\x20=\x20?',NOW)[_0x442d('0x15')]('cm_contacts.phone\x20NOT\x20IN\x20(?)',squel['select']()[_0x442d('0x10')]('phone')['from'](_0x442d('0x40'))['where'](_0x442d('0x41'),_0xc78b57)[_0x442d('0x15')](_0x2a6ad2+'\x20=\x20'+_0x10b38d+'.'+_0x2a6ad2)))[_0x442d('0x3f')]();}function insertCmHopperAdditionalPhones(_0x1abaab){var _0x5d109b=['cm_hopper.id','cm_contact_has_items.item','cm_contact_has_items.OrderBy',_0x442d('0x47'),_0x442d('0x48')];return squel[_0x442d('0x2b')]()[_0x442d('0x2c')]('cm_hopper_additional_phones')[_0x442d('0x2d')]([_0x442d('0x49'),_0x442d('0x11'),_0x442d('0x4a'),_0x442d('0x31'),_0x442d('0x32')],squel[_0x442d('0xf')]()[_0x442d('0x36')](_0x5d109b)['from']('cm_hopper')['join'](_0x442d('0x37'),null,'cm_contacts.id\x20=\x20cm_hopper.ContactId')[_0x442d('0x13')]('cm_contact_has_items',null,_0x442d('0x4b'))['where'](_0x442d('0x4c'),_0x1abaab)['where'](_0x442d('0x3b'),NOW))[_0x442d('0x3f')]();}function insertCmContact(_0x551de7,_0xe62f18,_0x5253f3,_0x5ab148){var _0x160dfe=_[_0x442d('0x4d')](_['keys'](_0x5ab148),['ListId',_0x442d('0x4e'),_0x442d('0x31'),'updatedAt',_0x442d('0x4f')]);return squel[_0x442d('0x2b')]()[_0x442d('0x2c')](_0x442d('0x37'))[_0x442d('0x2d')](_0x160dfe,squel[_0x442d('0xf')]()[_0x442d('0x36')](_0x160dfe)[_0x442d('0x12')](_0xe62f18)[_0x442d('0x15')]('('+_0x5253f3['join'](',')+')\x20NOT\x20IN\x20?',squel[_0x442d('0xf')]()[_0x442d('0x36')](_0x5253f3)['from']('cm_contacts')['where'](_0x442d('0x41'),_0x551de7)[_0x442d('0x15')]('deletedAt\x20IS\x20NULL'))['where'](_0x442d('0x50'),squel[_0x442d('0xf')]()[_0x442d('0x10')](_0x442d('0x51'),'min_id')[_0x442d('0x12')](_0xe62f18)[_0x442d('0x52')](_0x5253f3['join'](','))))[_0x442d('0x3f')]();}function handleStop(){logger['info'](_0x442d('0x53'));stopped=!![];}function handleUncaughtException(_0x280a70){logger[_0x442d('0x54')](_0x280a70[_0x442d('0x55')]);process[_0x442d('0x56')](0x1);}function handleError(_0x9137b1,_0x2939c4){stats[_0x442d('0x57')]['push']({'name':_0x2939c4['code'],'message':_0x2939c4['message'],'row':_0x9137b1});}function handleQuery(_0x5d00fb){logger[_0x442d('0x58')](_0x5d00fb);return db['sequelize'][_0x442d('0x59')](_0x5d00fb)[_0x442d('0x5a')](function(_0x40b016){results[_0x442d('0x19')](_0x40b016);})[_0x442d('0x5b')](function(_0x5828a4){logger[_0x442d('0x54')](_0x5828a4[_0x442d('0x55')]);});}function updateTzCampaigns(_0x485fcd){return new Promise(function(_0x46839f,_0x4feef0){var _0x1b5e6f=squel['select']()[_0x442d('0x36')](['campaigns.id',_0x442d('0x5c')])[_0x442d('0x12')]('campaigns')[_0x442d('0x13')](_0x442d('0x5d'),null,_0x442d('0x5e'))[_0x442d('0x15')]('campaigns_has_cm_lists.CmListId='+_0x485fcd);db[_0x442d('0x5f')][_0x442d('0x59')](_0x1b5e6f['toString']())[_0x442d('0x5a')](function(_0x2d52cb){var _0x17772a=[];for(var _0x2f7d60=0x0;_0x2f7d60<_0x2d52cb['length'];_0x2f7d60++){_0x17772a[_0x442d('0x19')](getTimezoneData(_0x2d52cb[_0x2f7d60],tmp_campaigns));}BPromise['all'](_0x17772a)[_0x442d('0x18')](function(){_0x46839f({'val':0x1});});})[_0x442d('0x5b')](function(_0x297583){logger[_0x442d('0x54')](_0x297583[_0x442d('0x55')]);_0x46839f({'val':0x0});});});}function updateTzVoiceQueues(_0x2252af){return new Promise(function(_0x2bcd7c,_0x45001a){var _0x896268=squel['select']()[_0x442d('0x36')]([_0x442d('0x60'),_0x442d('0x61')])['from']('voice_queues')[_0x442d('0x13')](_0x442d('0x62'),null,_0x442d('0x63'))['where'](_0x442d('0x64')+_0x2252af);db[_0x442d('0x5f')][_0x442d('0x59')](_0x896268[_0x442d('0x3f')]())['spread'](function(_0x299fc6){var _0x1fb315=[];for(var _0x4d9d81=0x0;_0x4d9d81<_0x299fc6['length'];_0x4d9d81++){_0x1fb315[_0x442d('0x19')](getTimezoneData(_0x299fc6[_0x4d9d81],tmp_voice_queues));}BPromise['all'](_0x1fb315)[_0x442d('0x18')](function(){_0x2bcd7c({'val':0x1});});})[_0x442d('0x5b')](function(_0x1e8937){logger[_0x442d('0x54')](_0x1e8937['message']);_0x2bcd7c({'val':0x0});});});}function getTimezoneData(_0x1b12bf,_0x496510){return new Promise(function(_0x19dfcc,_0xfc6290){var _0x13a0e0=shared[_0x442d('0x65')];var _0x43e4a1=_0x13a0e0[_0x1b12bf['dialTimezone']];if(_['isNil'](_0x43e4a1)){_0x19dfcc({'ret':0x1});}else{var _0x458d74=_0x43e4a1[_0x442d('0x66')];var _0x4c76c9=squel[_0x442d('0x2b')]()[_0x442d('0x2c')](_0x496510)[_0x442d('0x67')]('id',_0x1b12bf['id'])[_0x442d('0x67')](_0x442d('0x68'),_0x458d74)[_0x442d('0x67')](_0x442d('0x69'),_0x1b12bf[_0x442d('0x69')])[_0x442d('0x3f')]();return db[_0x442d('0x5f')][_0x442d('0x59')](_0x4c76c9)[_0x442d('0x5a')](function(_0x534ad5){_0x19dfcc({'ret':0x1});})['catch'](function(_0x1c0d22){logger[_0x442d('0x54')](_0x1c0d22[_0x442d('0x55')]);_0xfc6290({'ret':0x1});});}});}function handleTZQuery(_0x312eb6){logger[_0x442d('0x58')](_0x312eb6);return db[_0x442d('0x5f')]['query'](_0x312eb6)[_0x442d('0x5a')](function(_0x50523e){})[_0x442d('0x5b')](function(_0x431fe3){logger[_0x442d('0x54')](_0x431fe3[_0x442d('0x55')]);});}function main(_0x32fa00,_0x4d13f6,_0x225aa3,_0x1da14c){logger[_0x442d('0x58')](_0x442d('0x6a'),_0x32fa00,JSON['stringify'](_0x4d13f6));process['send'](_0x442d('0x6b'));var _0x310a15=_0x4d13f6[_0x442d('0x6c')];var _0xc96524=_[_0x442d('0x6d')](_0x310a15);var _0xf39590=_0x4d13f6[_0x442d('0x6e')];var _0x496ea4=path[_0x442d('0x13')](config[_0x442d('0x6f')],_0x442d('0x70'),_0xf39590+_0x442d('0x71'));hasTZ=_[_0x442d('0x72')](_0x310a15)[_0x442d('0x73')]('dialTimezone');var _0x403053=_['keys'](_0x310a15)[_0x442d('0x13')]();logger[_0x442d('0x58')](_0x442d('0x74'),_0x403053);db['ContactItemType'][_0x442d('0x75')]({'raw':!![],'attributes':['id',_0x442d('0x76')]})[_0x442d('0x18')](function(_0x54cef0){for(var _0x524510=0x0;_0x524510<_0x54cef0['length'];_0x524510++){if(_0x54cef0[_0x524510][_0x442d('0x76')]in _0x310a15){contactItemTypes[_0x442d('0x19')](_0x54cef0[_0x524510]);delete _0xc96524[_0x54cef0[_0x524510]['name']];hasAdditionalPhones=!![];}for(var _0x1352d7 in _0x310a15){if(_0x54cef0[_0x524510][_0x442d('0x76')]+_0x442d('0x77')===_0x1352d7){phoneDescriptions[_0x442d('0x19')]({'itemTypeId':_0x54cef0[_0x524510]['id'],'description':_0x1352d7});delete _0xc96524[_0x1352d7];}}}if(hasAdditionalPhones)_0xc96524[_0x442d('0x17')]='';var _0x3fefa2=_['keys'](_0xc96524)[_0x442d('0x13')]();logger[_0x442d('0x58')](_0x442d('0x74'),_0x3fefa2);fs[_0x442d('0x78')](_0x496ea4,_0x3fefa2+'\x0a');Papa[_0x442d('0x79')](fs[_0x442d('0x7a')](_0x32fa00),{'header':!![],'skipEmptyLines':!![],'step':function(_0xa4be42,_0x1aabb1){try{for(var _0x5557fc=0x0,_0x6060f4=[];_0x5557fc<_0xa4be42[_0x442d('0x7b')][_0x442d('0x1c')];_0x5557fc++){stats[_0x442d('0x7c')]+=0x1;if(_0xa4be42[_0x442d('0x57')][_0x5557fc]){handleError(_0xa4be42['data'][_0x5557fc],_0xa4be42[_0x442d('0x57')][_0x5557fc]);}else{var _0x1ac88d=[];var _0xe62ec3=[];var _0x5f52db={};for(var _0x374ea0 in _0x310a15){let _0x495f3f=contactItemTypes[_0x442d('0x7d')](_0x3c09d5=>_0x3c09d5[_0x442d('0x76')]===_0x374ea0);let _0x410ce3=contactItemTypes[_0x442d('0x7d')](_0x84c7e8=>_0x84c7e8[_0x442d('0x76')]+_0x442d('0x77')===_0x374ea0);if(_[_0x442d('0x1d')](_0x495f3f)&&_['isNil'](_0x410ce3)){if(_0x310a15[_0x442d('0x7e')](_0x374ea0)){if(_0xa4be42[_0x442d('0x7b')][_0x5557fc][_0x310a15[_0x374ea0]]){var _0x55e326=_['trim'](_0xa4be42['data'][_0x5557fc][_0x310a15[_0x374ea0]][_0x442d('0x7f')](/"/g,'\x27'));switch(_0x374ea0){case _0x442d('0x2e'):var _0x460231=moment(_0x55e326,_0x442d('0xe'),!![]);if(_0x460231[_0x442d('0x80')]()){_0x6060f4['push']('\x22'+_0x55e326+'\x22');}else{_0x1ac88d[_0x442d('0x19')]('scheduledat\x20wrong\x20format\x20(YYYY-MM-DD\x20HH:mm:ss)');}break;case _0x442d('0x33'):var _0x38b225=parseInt(_0x55e326);_0x55e326=_[_0x442d('0x81')](_0x38b225)||_0x38b225<0x0||_0x38b225>0x4?_0x1da14c?0x3:0x2:_0x38b225;_0x6060f4[_0x442d('0x19')]('\x22'+_0x55e326+'\x22');break;case _0x442d('0x34'):var _0x50cb4e=parseInt(_0x55e326);if(_['isNumber'](_0x50cb4e)&&_[_0x442d('0x73')](_0x225aa3,_0x50cb4e)){_0x6060f4[_0x442d('0x19')]('\x22'+_0x50cb4e+'\x22');}else{_0x1ac88d['push'](_0x442d('0x82'));}break;case'email':if(isEmail(_0x55e326)){_0x6060f4['push']('\x22'+_0x55e326+'\x22');}else{_0x1ac88d[_0x442d('0x19')](_0x442d('0x83'));}break;case _0x442d('0x84'):var _0x4d2167=moment(_0x55e326,_0x442d('0x85'),!![]);if(_0x4d2167[_0x442d('0x80')]()){_0x6060f4[_0x442d('0x19')]('\x22'+_0x55e326+'\x22');}else{_0x1ac88d[_0x442d('0x19')]('dateOfBirth\x20wrong\x20format\x20(YYYY-MM-DD)');}break;case _0x442d('0x69'):var _0x206f50=shared[_0x442d('0x65')];var _0x1c2134=_0x206f50[_0x55e326];if(!_[_0x442d('0x1d')](_0x1c2134)){var _0x4dc087=_0x1c2134['utcOffset'];_0x6060f4['push']('\x22'+_0x55e326+'\x22');_0x6060f4[_0x442d('0x19')]('\x22'+_0x4dc087+'\x22');}break;default:_0x6060f4[_0x442d('0x19')]('\x22'+_0x55e326+'\x22');}}else{switch(_0x374ea0){case _0x442d('0x86'):case _0x442d('0x11'):_0x1ac88d[_0x442d('0x19')](_0x374ea0+'\x20not\x20specified');break;default:_0x6060f4[_0x442d('0x19')]('\x22\x22');}}}}else{var _0x2f3a02='';if(!_[_0x442d('0x1d')](_0x495f3f)){if(!_0x5f52db[_0x442d('0x7e')](_0x495f3f['id'])){if(!_[_0x442d('0x1d')](_0xa4be42['data'][_0x5557fc][_0x310a15[_0x374ea0]])){var _0x55e326=_[_0x442d('0x87')](_0xa4be42[_0x442d('0x7b')][_0x5557fc][_0x310a15[_0x374ea0]][_0x442d('0x7f')](/"/g,'\x27'));var _0x2cc864=phoneDescriptions['find'](_0x561002=>_0x561002[_0x442d('0x88')]===_0x495f3f['id']);if(!_[_0x442d('0x1d')](_0x2cc864)){var _0x5627a7=_[_0x442d('0x87')](_0xa4be42['data'][_0x5557fc][_0x310a15[_0x2cc864['description']]]['replace'](/"/g,'\x27'));if(!_['isNil'](_0x5627a7))_0x55e326=_0x55e326+'§'+_0x5627a7;}if(_0x2f3a02=='')_0x2f3a02=_0x55e326;else _0x2f3a02+='|'+_0x55e326;}_0xe62ec3['push'](_0x495f3f['id']+':'+_0x2f3a02);_0x5f52db[_0x495f3f['id']]=0x1;}}}}if(hasAdditionalPhones){_0x6060f4[_0x442d('0x19')]('\x22'+_0xe62ec3['join'](';')+'\x22');}if(_0x1ac88d[_0x442d('0x1c')]){handleError(_0xa4be42[_0x442d('0x7b')][_0x5557fc],{'code':_0x442d('0x89'),'message':_0x1ac88d['join']()});}else{fs[_0x442d('0x8a')](_0x496ea4,_0x6060f4[_0x442d('0x13')]()+'\x0a');}_0x6060f4=[];}if(!(stats[_0x442d('0x7c')]%0xc8)){socket['emit']('contact:import:'+_0xf39590,stats);stats[_0x442d('0x57')]=[];}}if(stopped){logger[_0x442d('0x58')](_0x442d('0x8b'));_0x1aabb1[_0x442d('0x8c')]();}}catch(_0x9cb596){handleError(_0xa4be42[_0x442d('0x7b')][_0x5557fc],{'code':_0x442d('0x8d'),'message':_0x9cb596['message']});logger[_0x442d('0x54')](_0x442d('0x8e'),_0x9cb596['message']);}},'complete':function(){try{var _0x223859=[];var _0x34a782=[];var _0xcaabd7=_0x442d('0x37');if(_0x4d13f6[_0x442d('0x8f')]&&_0x4d13f6['duplicates'][_0x442d('0x1c')]){_0xcaabd7='cm_contacts_'+_0xf39590;_0x223859[_0x442d('0x19')](_0x442d('0x90')+_0xcaabd7+'\x20LIKE\x20cm_contacts;');}tmp_campaigns=_0x442d('0x91')+_0xf39590;tmp_voice_queues=_0x442d('0x92')+_0xf39590;_0x34a782[_0x442d('0x19')](_0x442d('0x90')+tmp_campaigns+_0x442d('0x93'));_0x34a782['push']('CREATE\x20TABLE\x20'+tmp_voice_queues+_0x442d('0x93'));BPromise[_0x442d('0x94')](_0x34a782,handleTZQuery)[_0x442d('0x18')](function(_0x185060){updateTzCampaigns(_0x4d13f6[_0x442d('0x30')])['then'](function(_0x1e392c){updateTzVoiceQueues(_0x4d13f6[_0x442d('0x30')])['then'](function(_0x2579c0){if(hasTZ)_0x3fefa2=_0x3fefa2[_0x442d('0x7f')](_0x442d('0x69'),'dialTimezone,utcOffset');var _0x494d0d=util['format'](_0x442d('0x95'),_0x496ea4,_0xcaabd7,_0x3fefa2,_0x4d13f6[_0x442d('0x30')],_0x4d13f6[_0x442d('0x4e')]||null,NOW,NOW);if(_['isNil'](_0x310a15[_0x442d('0x2e')])){_0x494d0d+=_0x442d('0x96');}_0x223859['push'](_0x494d0d);if(_0x4d13f6[_0x442d('0x8f')]&&_0x4d13f6[_0x442d('0x8f')][_0x442d('0x1c')]){_0x223859[_0x442d('0x19')](insertCmContact(_0x4d13f6[_0x442d('0x30')],_0xcaabd7,_0x4d13f6[_0x442d('0x8f')],_0x310a15));_0x223859[_0x442d('0x19')](_0x442d('0x97')+_0xcaabd7+';');}BPromise[_0x442d('0x94')](_0x223859,handleQuery)[_0x442d('0x18')](function(_0x503e85){BPromise[_0x442d('0x1a')]([handleAdditionalPhones()])[_0x442d('0x18')](function(){_0x223859=[];for(var _0x5a4de8=0x0;_0x5a4de8<promisesAdditionalPhones[_0x442d('0x1c')];_0x5a4de8++){if(promisesAdditionalPhones[_0x5a4de8]['phone']!='§'){_0x223859[_0x442d('0x19')](createAdditionalPhone(promisesAdditionalPhones[_0x5a4de8][_0x442d('0x98')],promisesAdditionalPhones[_0x5a4de8][_0x442d('0x99')],promisesAdditionalPhones[_0x5a4de8][_0x442d('0x11')],promisesAdditionalPhones[_0x5a4de8][_0x442d('0x9a')]));}}BPromise['all'](_0x223859)['then'](function(){_0x223859=[];if(hasTZ){_0x223859[_0x442d('0x19')](insertTzCmHopper(_0x4d13f6[_0x442d('0x30')],'voice_queues_has_cm_lists',_0x442d('0x9b'),_0x442d('0x9c'),_0x1da14c,tmp_voice_queues));_0x223859['push'](insertTzCmHopperBlack(_0x4d13f6[_0x442d('0x30')],_0x442d('0x9d'),'voice_queues',_0x442d('0x9c')));_0x223859[_0x442d('0x19')](insertTzCmHopper(_0x4d13f6['ListId'],'campaigns_has_cm_lists','campaigns',_0x442d('0x9e'),_0x1da14c,tmp_campaigns));_0x223859[_0x442d('0x19')](insertTzCmHopperBlack(_0x4d13f6[_0x442d('0x30')],_0x442d('0x9f'),'campaigns','CampaignId'));_0x223859[_0x442d('0x19')](insertCmHopperAdditionalPhones(_0x4d13f6[_0x442d('0x30')]));}else{_0x223859[_0x442d('0x19')](insertCmHopper(_0x4d13f6[_0x442d('0x30')],_0x442d('0x62'),_0x442d('0x9b'),_0x442d('0x9c'),_0x1da14c));_0x223859[_0x442d('0x19')](insertCmHopperBlack(_0x4d13f6[_0x442d('0x30')],_0x442d('0x9d'),_0x442d('0x9b'),_0x442d('0x9c')));_0x223859[_0x442d('0x19')](insertCmHopper(_0x4d13f6[_0x442d('0x30')],_0x442d('0x5d'),_0x442d('0xa0'),_0x442d('0x9e'),_0x1da14c));_0x223859[_0x442d('0x19')](insertCmHopperBlack(_0x4d13f6['ListId'],_0x442d('0x9f'),_0x442d('0xa0'),_0x442d('0x9e')));_0x223859[_0x442d('0x19')](insertCmHopperAdditionalPhones(_0x4d13f6['ListId']));}_0x223859[_0x442d('0x19')]('DROP\x20TABLE\x20'+tmp_campaigns+';');_0x223859['push'](_0x442d('0x97')+tmp_voice_queues+';');BPromise[_0x442d('0x94')](_0x223859,handleQuery)[_0x442d('0x18')](function(_0x24f6be){stats['finish']=!![];stats[_0x442d('0xa1')]=_0x4d13f6[_0x442d('0x8f')]&&_0x4d13f6[_0x442d('0x8f')][_0x442d('0x1c')]?results[0x2]['affectedRows']:results[0x0][_0x442d('0xa1')];socket[_0x442d('0xa2')](_0x442d('0xa3')+_0xf39590,stats);fs['unlink'](_0x32fa00);fs[_0x442d('0xa4')](_0x496ea4);process[_0x442d('0x56')](0x0);})[_0x442d('0x5b')](function(_0x262c6b){logger[_0x442d('0x54')](_0x262c6b['message']);process['exit'](0x1);});});});})['catch'](function(_0xf5f450){logger[_0x442d('0x54')](_0xf5f450[_0x442d('0x55')]);process[_0x442d('0x56')](0x1);});});});});}catch(_0x56e758){logger[_0x442d('0x54')](_0x442d('0xa5'),_0x56e758[_0x442d('0x55')]);process['exit'](0x1);}},'error':function(_0x4f1a0a,_0x2c4fea,_0x31853c,_0x3faa55){throw new Error(_0x3faa55);}});});}function validate(){if(process[_0x442d('0xa6')]&&process[_0x442d('0xa6')][_0x442d('0x1c')]<0x4){throw new Error(_0x442d('0xa7'));}var _0x459ed2=path[_0x442d('0x13')](config[_0x442d('0x6f')],_0x442d('0x70'),process[_0x442d('0xa6')][0x2]);if(!fs[_0x442d('0xa8')](_0x459ed2)){throw new Error('file\x20doesn\x27t\x20exists');}var _0x321221={};try{_0x321221=JSON[_0x442d('0x79')](process['argv'][0x3]);if(!_0x321221[_0x442d('0x6c')]){throw new Error(_0x442d('0xa9'));}if(!_0x321221[_0x442d('0x6c')][_0x442d('0x11')]){throw new Error(_0x442d('0xaa'));}if(!_0x321221['binding'][_0x442d('0x86')]){throw new Error(_0x442d('0xab'));}var _0x110ba2=0x0;if(_0x321221[_0x442d('0x6c')][_0x442d('0x34')]){_0x110ba2=0x1;}if(!_0x321221[_0x442d('0x30')]){throw new Error(_0x442d('0xac'));}}catch(_0x66615b){throw new Error(_0x442d('0xad'));}var _0x13840a=[];try{_0x13840a=_[_0x442d('0xae')](JSON['parse'](process[_0x442d('0xa6')][0x4]),'id');}catch(_0x2ab9f6){logger[_0x442d('0x58')](_0x442d('0xaf'));}main(_0x459ed2,_0x321221,_0x13840a,_0x110ba2);}validate();process['on']('SIGINT',handleStop);process['on'](_0x442d('0xb0'),handleUncaughtException);
\ No newline at end of file