Built motion from commit cb845558.|2.6.34
[motion2.git] / server / api / cmHopper / cmHopper.controller.js
index 4c5e7cb..23b9f04 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x86f4=['$notIn','$like','$notLike','$iLike','$notILike','$any','intersection','attributes','length','nolimit','order','sort','where','pick','filter','merge','VIRTUAL','options','then','includeAll','include','findAll','rows','catch','show','params','fields','find','create','body','describe','destroy','VoiceQueueId','VoiceQueue','Campaign','CampaignId','omit','dataValues','createdAt','updatedAt','state','statedesc','campaign','membername','user','UserId','deleted','deletedat','format','YYYY-MM-DD\x20HH:mm:ss','phone','campaigntype','queue','ivr','CmContact','ContactId','lastName','isNil','firstName','calleridname','finally','CmHopperFinal','CmHopperAdditionalPhone','end','getPreview','outbound','dialOrderByScheduledAt','dialPreviewAutoRecallMe','transaction','value','direction','prev','isEmpty','hopperIds','priority','scheduledAt','ASC','DESC','sequelize','literal','COALESCE(CmHopper.UserId,\x200)\x20ASC','COALESCE(CmHopper.UserId,\x200)\x20DESC','findOne','scheduledat','recallme','UPDATE','Contact','CmCompany','Company','List','Queue','getPreviewRecall','LOCK','CmList','dialActive','getOpenContacts','getVoiceQueues','sendStatus','getTimezones','timezones','utcOffset','getTimezone','moment','lodash','../../components/parsers/qs','../../config/logger','api','../../config/environment','../../mysqldb','json','offset','limit','undefined','count','status','set','Content-Range','update','error','stack','name','send','index','map','CmHopper','rawAttributes','fieldName','type','key','model','query','keys','filters','concat','$and','$or','$gt','$gte','$lt','$lte','$ne','$eq','$not','$between','$notBetween','$in'];(function(_0x3e7623,_0x131adc){var _0x29b12a=function(_0x1a4437){while(--_0x1a4437){_0x3e7623['push'](_0x3e7623['shift']());}};_0x29b12a(++_0x131adc);}(_0x86f4,0x18a));var _0x486f=function(_0x47e0d9,_0x193567){_0x47e0d9=_0x47e0d9-0x0;var _0x5ea6e3=_0x86f4[_0x47e0d9];return _0x5ea6e3;};'use strict';var moment=require(_0x486f('0x0'));var _=require(_0x486f('0x1'));var qs=require(_0x486f('0x2'));var logger=require(_0x486f('0x3'))(_0x486f('0x4'));var shared=require(_0x486f('0x5'));var db=require(_0x486f('0x6'))['db'];function respondWithResult(_0x53305d,_0xf8d50f){_0xf8d50f=_0xf8d50f||0xc8;return function(_0x1539b1){if(_0x1539b1){return _0x53305d['status'](_0xf8d50f)[_0x486f('0x7')](_0x1539b1);}};}function respondWithFilteredResult(_0x1adb27,_0x39f767){return function(_0x207201){if(_0x207201){var _0x3c6469=typeof _0x39f767[_0x486f('0x8')]==='undefined'&&typeof _0x39f767[_0x486f('0x9')]===_0x486f('0xa');var _0x37975a=_0x207201[_0x486f('0xb')];var _0x377d09=_0x3c6469?0x0:_0x39f767[_0x486f('0x8')];var _0x19ccdd=_0x3c6469?_0x207201[_0x486f('0xb')]:_0x39f767[_0x486f('0x8')]+_0x39f767[_0x486f('0x9')];var _0xb57b8c;if(_0x19ccdd>=_0x37975a){_0x19ccdd=_0x37975a;_0xb57b8c=0xc8;}else{_0xb57b8c=0xce;}_0x1adb27[_0x486f('0xc')](_0xb57b8c);return _0x1adb27[_0x486f('0xd')](_0x486f('0xe'),_0x377d09+'-'+_0x19ccdd+'/'+_0x37975a)[_0x486f('0x7')](_0x207201);}return null;};}function saveUpdates(_0x4312fb,_0x1c4e55){return function(_0x4eb4f9){if(_0x4eb4f9){return _0x4eb4f9[_0x486f('0xf')](_0x4312fb)['then'](function(_0x46d0a9){return _0x46d0a9;});}return null;};}function handleEntityNotFound(_0x2cc608,_0x1ac871){return function(_0x50bee8){if(!_0x50bee8){_0x2cc608['sendStatus'](0x194);}return _0x50bee8;};}function handleError(_0x11c2af,_0x3a4fef){_0x3a4fef=_0x3a4fef||0x1f4;return function(_0x51334f){logger[_0x486f('0x10')](_0x51334f[_0x486f('0x11')]);if(_0x51334f[_0x486f('0x12')]){delete _0x51334f['name'];}_0x11c2af['status'](_0x3a4fef)[_0x486f('0x13')](_0x51334f);};}exports[_0x486f('0x14')]=function(_0x360cb7,_0x39bfac){var _0x4e68d1={},_0x59deb8={},_0x268eb9={'count':0x0,'rows':[]};var _0x9518=_[_0x486f('0x15')](db[_0x486f('0x16')][_0x486f('0x17')],function(_0x243dbf){return{'name':_0x243dbf[_0x486f('0x18')],'type':_0x243dbf[_0x486f('0x19')][_0x486f('0x1a')]};});_0x59deb8[_0x486f('0x1b')]=_[_0x486f('0x15')](_0x9518,_0x486f('0x12'));_0x59deb8[_0x486f('0x1c')]=_[_0x486f('0x1d')](_0x360cb7[_0x486f('0x1c')]);_0x59deb8[_0x486f('0x1e')]=_['intersection'](_0x59deb8[_0x486f('0x1b')],_0x59deb8[_0x486f('0x1c')]);_0x59deb8[_0x486f('0x1e')]=_[_0x486f('0x1f')](_0x59deb8[_0x486f('0x1e')],[_0x486f('0x20'),_0x486f('0x21'),_0x486f('0x22'),_0x486f('0x23'),_0x486f('0x24'),_0x486f('0x25'),_0x486f('0x26'),_0x486f('0x27'),_0x486f('0x28'),_0x486f('0x29'),_0x486f('0x2a'),_0x486f('0x2b'),_0x486f('0x2c'),_0x486f('0x2d'),_0x486f('0x2e'),_0x486f('0x2f'),_0x486f('0x30'),'$like','$overlap','$contains','$contained',_0x486f('0x31')]);_0x4e68d1['attributes']=_[_0x486f('0x32')](_0x59deb8[_0x486f('0x1b')],qs['fields'](_0x360cb7[_0x486f('0x1c')]['fields']));_0x4e68d1[_0x486f('0x33')]=_0x4e68d1[_0x486f('0x33')][_0x486f('0x34')]?_0x4e68d1[_0x486f('0x33')]:_0x59deb8[_0x486f('0x1b')];if(!_0x360cb7[_0x486f('0x1c')]['hasOwnProperty'](_0x486f('0x35'))){_0x4e68d1[_0x486f('0x9')]=qs[_0x486f('0x9')](_0x360cb7[_0x486f('0x1c')][_0x486f('0x9')]);_0x4e68d1[_0x486f('0x8')]=qs[_0x486f('0x8')](_0x360cb7[_0x486f('0x1c')]['offset']);}_0x4e68d1[_0x486f('0x36')]=qs[_0x486f('0x37')](_0x360cb7['query'][_0x486f('0x37')]);_0x4e68d1[_0x486f('0x38')]=qs[_0x486f('0x1e')](_[_0x486f('0x39')](_0x360cb7[_0x486f('0x1c')],_0x59deb8['filters']),_0x9518);if(_0x360cb7[_0x486f('0x1c')][_0x486f('0x3a')]){_0x4e68d1[_0x486f('0x38')]=_[_0x486f('0x3b')](_0x4e68d1[_0x486f('0x38')],{'$or':_[_0x486f('0x15')](_0x9518,function(_0x2bbcd4){if(_0x2bbcd4['type']!==_0x486f('0x3c')){var _0x219e8a={};_0x219e8a[_0x2bbcd4[_0x486f('0x12')]]={'$like':'%'+_0x360cb7['query']['filter']+'%'};return _0x219e8a;}})});}_0x4e68d1=_[_0x486f('0x3b')]({},_0x4e68d1,_0x360cb7[_0x486f('0x3d')]);var _0x4b80f8={'where':_0x4e68d1[_0x486f('0x38')]};return db['CmHopper'][_0x486f('0xb')](_0x4b80f8)[_0x486f('0x3e')](function(_0x5ca543){_0x268eb9['count']=_0x5ca543;if(_0x360cb7[_0x486f('0x1c')][_0x486f('0x3f')]){_0x4e68d1[_0x486f('0x40')]=[{'all':!![]}];}return db[_0x486f('0x16')][_0x486f('0x41')](_0x4e68d1);})[_0x486f('0x3e')](function(_0x901b9){_0x268eb9[_0x486f('0x42')]=_0x901b9;return _0x268eb9;})[_0x486f('0x3e')](respondWithFilteredResult(_0x39bfac,_0x4e68d1))[_0x486f('0x43')](handleError(_0x39bfac,null));};exports[_0x486f('0x44')]=function(_0x737fee,_0x849116){var _0x43d9be={'raw':!![],'where':{'id':_0x737fee[_0x486f('0x45')]['id']}},_0x4f657e={};_0x4f657e[_0x486f('0x1b')]=_['keys'](db[_0x486f('0x16')][_0x486f('0x17')]);_0x4f657e[_0x486f('0x1c')]=_[_0x486f('0x1d')](_0x737fee[_0x486f('0x1c')]);_0x4f657e[_0x486f('0x1e')]=_[_0x486f('0x32')](_0x4f657e[_0x486f('0x1b')],_0x4f657e[_0x486f('0x1c')]);_0x43d9be['attributes']=_['intersection'](_0x4f657e[_0x486f('0x1b')],qs[_0x486f('0x46')](_0x737fee[_0x486f('0x1c')][_0x486f('0x46')]));_0x43d9be[_0x486f('0x33')]=_0x43d9be[_0x486f('0x33')][_0x486f('0x34')]?_0x43d9be[_0x486f('0x33')]:_0x4f657e[_0x486f('0x1b')];if(_0x737fee['query'][_0x486f('0x3f')]){_0x43d9be[_0x486f('0x40')]=[{'all':!![]}];}_0x43d9be=_[_0x486f('0x3b')]({},_0x43d9be,_0x737fee[_0x486f('0x3d')]);return db['CmHopper'][_0x486f('0x47')](_0x43d9be)['then'](handleEntityNotFound(_0x849116,null))[_0x486f('0x3e')](respondWithResult(_0x849116,null))[_0x486f('0x43')](handleError(_0x849116,null));};exports[_0x486f('0x48')]=function(_0x1fe73f,_0xa57bd6){return db[_0x486f('0x16')]['create'](_0x1fe73f['body'],{})[_0x486f('0x3e')](respondWithResult(_0xa57bd6,0xc9))[_0x486f('0x43')](handleError(_0xa57bd6,null));};exports[_0x486f('0xf')]=function(_0xefe4e4,_0x4dbf30){if(_0xefe4e4[_0x486f('0x49')]['id']){delete _0xefe4e4[_0x486f('0x49')]['id'];}return db[_0x486f('0x16')]['find']({'where':{'id':_0xefe4e4[_0x486f('0x45')]['id']}})[_0x486f('0x3e')](handleEntityNotFound(_0x4dbf30,null))[_0x486f('0x3e')](saveUpdates(_0xefe4e4[_0x486f('0x49')],null))[_0x486f('0x3e')](respondWithResult(_0x4dbf30,null))[_0x486f('0x43')](handleError(_0x4dbf30,null));};exports[_0x486f('0x4a')]=function(_0x21f222,_0x51ca91){return db[_0x486f('0x16')]['describe']()[_0x486f('0x3e')](respondWithResult(_0x51ca91,null))[_0x486f('0x43')](handleError(_0x51ca91,null));};exports[_0x486f('0x4b')]=function(_0x1055cf,_0x34033e){var _0x2e5746;var _0x4d2902=_0x1055cf[_0x486f('0x45')]['id'];return db[_0x486f('0x16')][_0x486f('0x47')]({'where':{'id':_0x1055cf[_0x486f('0x45')]['id']}})[_0x486f('0x3e')](handleEntityNotFound(_0x34033e,null))[_0x486f('0x3e')](function(_0x1bc683){if(_0x1bc683){return _0x1bc683[_0x486f('0x4b')]()[_0x486f('0x3e')](function(_0x5cd989){return _0x5cd989;});}})[_0x486f('0x3e')](function(_0x39f90b){_0x2e5746=_0x39f90b;if(_0x39f90b){if(_0x39f90b[_0x486f('0x4c')]||_0x39f90b['CampaignId']){return db[_0x39f90b[_0x486f('0x4c')]?_0x486f('0x4d'):_0x486f('0x4e')]['find']({'where':{'id':_0x39f90b[_0x486f('0x4c')]?_0x39f90b[_0x486f('0x4c')]:_0x39f90b[_0x486f('0x4f')]},'attributes':['id',_0x486f('0x12')],'raw':!![]});}}})['then'](function(_0x57aac0){var _0x16228a={};if(_0x57aac0){_[_0x486f('0x3b')](_0x16228a,_[_0x486f('0x50')](_0x2e5746[_0x486f('0x51')],[_0x486f('0x52'),_0x486f('0x53'),'id']));_0x16228a[_0x486f('0x54')]=0x15;_0x16228a[_0x486f('0x55')]='deleted';_0x16228a[_0x486f('0x56')]=_0x57aac0['name'];_0x16228a[_0x486f('0x57')]=_0x1055cf[_0x486f('0x58')][_0x486f('0x12')];_0x16228a[_0x486f('0x59')]=_0x1055cf['user']['id'];_0x16228a[_0x486f('0x5a')]=!![];_0x16228a[_0x486f('0x5b')]=moment()[_0x486f('0x5c')](_0x486f('0x5d'));_0x16228a['calleridnum']=_0x2e5746[_0x486f('0x5e')];_0x16228a[_0x486f('0x5f')]=_0x2e5746[_0x486f('0x4c')]?_0x486f('0x60'):_0x486f('0x61');return db[_0x486f('0x62')][_0x486f('0x47')]({'where':{'id':_0x16228a[_0x486f('0x63')]},'attributes':['firstName',_0x486f('0x64')]})[_0x486f('0x3e')](function(_0x5fa282){if(!_[_0x486f('0x65')](_0x34033e)&&!_['isNil'](_0x5fa282[_0x486f('0x66')])){_0x16228a['calleridname']=_0x5fa282[_0x486f('0x66')];if(!_[_0x486f('0x65')](_0x5fa282[_0x486f('0x64')])){_0x16228a[_0x486f('0x67')]+='\x20'+_0x5fa282['lastName'];}}})[_0x486f('0x68')](function(){return db[_0x486f('0x69')][_0x486f('0x48')](_0x16228a);});}})[_0x486f('0x3e')](function(_0x5cf926){return db[_0x486f('0x6a')][_0x486f('0x4b')]({'where':{'CmHopperId':_0x4d2902}});})[_0x486f('0x3e')](function(){return _0x34033e[_0x486f('0xc')](0xcc)[_0x486f('0x6b')]();})[_0x486f('0x43')](handleError(_0x34033e,null));};exports[_0x486f('0x6c')]=function(_0xc78ac9,_0x63c750){var _0x88dbac=[];return db[_0x486f('0x62')][_0x486f('0x4a')]()[_0x486f('0x3e')](function(_0x286141){_0x88dbac=_['keys'](_0x286141);return _0xc78ac9[_0x486f('0x58')]['getVoiceQueues']({'where':{'type':_0x486f('0x6d'),'dialActive':!![],'dialMethod':'preview'},'attributes':['id',_0x486f('0x6e'),_0x486f('0x6f')],'raw':!![]});})['then'](function(_0x565e9d){if(_0x565e9d&&_0x565e9d[_0x486f('0x34')]){return db['sequelize'][_0x486f('0x70')](function(_0x3648c0){var _0x587fb1={'active':![],'recallme':![],'scheduledAt':{'$lte':moment()[_0x486f('0x5c')](_0x486f('0x5d'))},'VoiceQueueId':{'$in':_[_0x486f('0x15')](_0x565e9d,'id')},'$or':[{'UserId':null},{'UserId':_0xc78ac9[_0x486f('0x58')]['id']}]};var _0x5118e5={'active':![],'recallme':!![],'VoiceQueueId':{'$in':_(_0x565e9d)[_0x486f('0x3a')](['dialPreviewAutoRecallMe',0x0])[_0x486f('0x15')]('id')[_0x486f('0x71')]()},'$or':[{'UserId':null},{'UserId':_0xc78ac9[_0x486f('0x58')]['id']}]};var _0x5a1406={'$or':[_0x587fb1,_0x5118e5]};var _0x3c8b40=[];if(_0xc78ac9['body'][_0x486f('0x72')]&&_0xc78ac9['body'][_0x486f('0x72')]===_0x486f('0x73')){if(!_[_0x486f('0x74')](_0xc78ac9[_0x486f('0x49')]['hopperIds'])){_0x5a1406['id']={'$in':_0xc78ac9[_0x486f('0x49')][_0x486f('0x75')]};}_0x3c8b40=[[_0x486f('0x76'),'ASC'],[_0x486f('0x77'),_0x565e9d[0x0][_0x486f('0x6e')]===_0x486f('0x78')?_0x486f('0x79'):'ASC'],db[_0x486f('0x7a')][_0x486f('0x7b')](_0x486f('0x7c')),['id','DESC']];}else{if(!_[_0x486f('0x74')](_0xc78ac9[_0x486f('0x49')][_0x486f('0x75')])){_0x5a1406['id']={'$notIn':_0xc78ac9['body'][_0x486f('0x75')]};}_0x3c8b40=[[_0x486f('0x76'),'DESC'],['scheduledAt',_0x565e9d[0x0]['dialOrderByScheduledAt']],db['sequelize'][_0x486f('0x7b')](_0x486f('0x7d')),['id',_0x486f('0x78')]];}return db[_0x486f('0x16')][_0x486f('0x7e')]({'attributes':['id',_0x486f('0x7f'),_0x486f('0x5e'),_0x486f('0x80')],'where':_0x5a1406,'order':_0x3c8b40,'transaction':_0x3648c0,'lock':_0x3648c0['LOCK'][_0x486f('0x81')],'include':[{'model':db[_0x486f('0x62')],'as':_0x486f('0x82'),'attributes':_0x88dbac,'include':[{'model':db[_0x486f('0x83')],'as':_0x486f('0x84'),'attributes':['id','name']}]},{'model':db['CmList'],'as':_0x486f('0x85'),'attributes':['id',_0x486f('0x12')]},{'model':db['VoiceQueue'],'as':_0x486f('0x86'),'attributes':['id',_0x486f('0x12'),'dialActive']}]})['then'](function(_0x25e5c9){if(_0x25e5c9){return _0x25e5c9[_0x486f('0xf')]({'UserId':_0xc78ac9[_0x486f('0x58')]['id']},{'transaction':_0x3648c0});}});});}})[_0x486f('0x3e')](handleEntityNotFound(_0x63c750,null))[_0x486f('0x3e')](respondWithResult(_0x63c750,null))[_0x486f('0x43')](handleError(_0x63c750,null));};exports[_0x486f('0x87')]=function(_0x5bff5d,_0x4d4b67,_0x63ab8a){var _0x48cb52=[];var _0xdef0af=_0x5bff5d['params']['id'];var _0xcf9385=_0x5bff5d['user']['id'];return db['CmContact'][_0x486f('0x4a')]()['then'](function(_0x4fc8bd){_0x48cb52=_[_0x486f('0x1d')](_0x4fc8bd);return db['sequelize'][_0x486f('0x70')](function(_0x5961c3){const _0x1d1eb4={'id':_0xdef0af};return db[_0x486f('0x16')][_0x486f('0x7e')]({'attributes':['id',_0x486f('0x7f'),'recallme'],'where':_0x1d1eb4,'transaction':_0x5961c3,'lock':_0x5961c3[_0x486f('0x88')][_0x486f('0x81')],'include':[{'model':db['CmContact'],'as':_0x486f('0x82'),'attributes':_0x48cb52,'include':[{'model':db['CmCompany'],'as':_0x486f('0x84'),'attributes':['id','name']}]},{'model':db[_0x486f('0x89')],'as':'List','attributes':['id','name']},{'model':db['VoiceQueue'],'as':_0x486f('0x86'),'attributes':['id',_0x486f('0x12'),_0x486f('0x8a')]}]})[_0x486f('0x3e')](function(_0x22a426){if(_0x22a426){return _0x22a426[_0x486f('0xf')]({'UserId':_0xcf9385},{'transaction':_0x5961c3});}});});})[_0x486f('0x3e')](handleEntityNotFound(_0x4d4b67,null))[_0x486f('0x3e')](respondWithResult(_0x4d4b67,null))[_0x486f('0x43')](handleError(_0x4d4b67,null));};exports[_0x486f('0x8b')]=function(_0x4f2213,_0x1022de){return _0x4f2213[_0x486f('0x58')][_0x486f('0x8c')]({'where':{'type':_0x486f('0x6d'),'dialActive':!![],'dialMethod':'preview'},'attributes':['id'],'raw':!![]})[_0x486f('0x3e')](function(_0x5c2d46){if(_0x5c2d46&&_0x5c2d46[_0x486f('0x34')]){return db[_0x486f('0x16')]['count']({'where':{'active':![],'recallme':![],'scheduledAt':{'$lte':moment()['format']('YYYY-MM-DD\x20HH:mm:ss')},'VoiceQueueId':{'$in':_[_0x486f('0x15')](_0x5c2d46,'id')},'$or':[{'UserId':null},{'UserId':_0x4f2213[_0x486f('0x58')]['id']}]}});}return 0x0;})[_0x486f('0x3e')](function(_0x4a0510){if(!_['isNil'](_0x4a0510)&&_['isNumber'](_0x4a0510)){return _0x1022de[_0x486f('0xc')](0xc8)['json']({'contacts':_0x4a0510});}else{logger[_0x486f('0x10')]('CmHopper,\x20%s,\x20%s,\x20%s',_0x486f('0x8b'),0x194,'entity\x20not\x20found');_0x1022de[_0x486f('0x8d')](0x194);}})[_0x486f('0x43')](handleError(_0x1022de,null));};exports[_0x486f('0x8e')]=function(_0x13832f,_0x196437){var _0x157976=shared[_0x486f('0x8f')];var _0x201541=[];_['map'](_0x157976,function(_0xd42cf4){_0x201541['push']({'id':_0xd42cf4[_0x486f('0x12')],'name':_0xd42cf4['name'],'utcOffset':_0xd42cf4[_0x486f('0x90')]});});return _0x196437[_0x486f('0xc')](0xc8)['json']({'tz':_0x201541});};exports[_0x486f('0x91')]=function(_0x345490,_0x140d8d){var _0x58f864=shared[_0x486f('0x8f')];var _0x294127={};if(!_[_0x486f('0x65')](_0x58f864[_0x345490['body']['id']]))_0x294127=_0x58f864[_0x345490['body']['id']];return _0x140d8d[_0x486f('0xc')](0xc8)[_0x486f('0x7')](_0x294127);};
\ No newline at end of file
+var _0xa3e6=['ivr','CmContact','ContactId','firstName','isNil','calleridname','lastName','finally','CmHopperFinal','create','CmHopperAdditionalPhone','end','getPreview','getVoiceQueues','outbound','preview','dialOrderByScheduledAt','dialPreviewAutoRecallMe','sequelize','transaction','format','value','direction','prev','isEmpty','hopperIds','priority','ASC','DESC','literal','COALESCE(CmHopper.UserId,\x200)\x20ASC','scheduledAt','findOne','scheduledat','phone','recallme','UPDATE','Contact','CmCompany','Company','VoiceQueue','Queue','dialActive','getPreviewRecall','LOCK','CmList','List','error','getOpenContacts','entity\x20not\x20found','push','utcOffset','timezones','moment','../../components/parsers/qs','api','../../config/environment','../../mysqldb','status','json','offset','undefined','count','limit','set','Content-Range','update','then','sendStatus','stack','name','map','CmHopper','rawAttributes','fieldName','key','query','keys','intersection','model','filters','concat','$and','$or','$gt','$gte','$lt','$lte','$ne','$eq','$not','$in','$notIn','$like','$notLike','$iLike','$notILike','$overlap','$contains','$contained','$any','attributes','length','hasOwnProperty','nolimit','order','sort','pick','filter','where','merge','type','VIRTUAL','options','includeAll','include','findAll','params','fields','find','catch','body','describe','destroy','VoiceQueueId','CampaignId','Campaign','omit','dataValues','createdAt','deleted','campaign','membername','user','YYYY-MM-DD\x20HH:mm:ss','calleridnum','campaigntype'];(function(_0x443317,_0x482e44){var _0x39dd9c=function(_0x466f04){while(--_0x466f04){_0x443317['push'](_0x443317['shift']());}};_0x39dd9c(++_0x482e44);}(_0xa3e6,0xbe));var _0x6a3e=function(_0x190e4f,_0x334f46){_0x190e4f=_0x190e4f-0x0;var _0x27a170=_0xa3e6[_0x190e4f];return _0x27a170;};'use strict';var moment=require(_0x6a3e('0x0'));var _=require('lodash');var qs=require(_0x6a3e('0x1'));var logger=require('../../config/logger')(_0x6a3e('0x2'));var shared=require(_0x6a3e('0x3'));var db=require(_0x6a3e('0x4'))['db'];function respondWithResult(_0x56e3f4,_0xe03261){_0xe03261=_0xe03261||0xc8;return function(_0x5e9a85){if(_0x5e9a85){return _0x56e3f4[_0x6a3e('0x5')](_0xe03261)[_0x6a3e('0x6')](_0x5e9a85);}};}function respondWithFilteredResult(_0x1c7709,_0x315ed8){return function(_0x19dd88){if(_0x19dd88){var _0x52a2f8=typeof _0x315ed8[_0x6a3e('0x7')]===_0x6a3e('0x8')&&typeof _0x315ed8['limit']==='undefined';var _0x2d2477=_0x19dd88['count'];var _0x54a40c=_0x52a2f8?0x0:_0x315ed8[_0x6a3e('0x7')];var _0x4f5a4a=_0x52a2f8?_0x19dd88[_0x6a3e('0x9')]:_0x315ed8['offset']+_0x315ed8[_0x6a3e('0xa')];var _0x3159db;if(_0x4f5a4a>=_0x2d2477){_0x4f5a4a=_0x2d2477;_0x3159db=0xc8;}else{_0x3159db=0xce;}_0x1c7709[_0x6a3e('0x5')](_0x3159db);return _0x1c7709[_0x6a3e('0xb')](_0x6a3e('0xc'),_0x54a40c+'-'+_0x4f5a4a+'/'+_0x2d2477)[_0x6a3e('0x6')](_0x19dd88);}return null;};}function saveUpdates(_0x4a3a97,_0x27e169){return function(_0x385c29){if(_0x385c29){return _0x385c29[_0x6a3e('0xd')](_0x4a3a97)[_0x6a3e('0xe')](function(_0x1364be){return _0x1364be;});}return null;};}function handleEntityNotFound(_0x31aefa,_0x222f7c){return function(_0x4bd05f){if(!_0x4bd05f){_0x31aefa[_0x6a3e('0xf')](0x194);}return _0x4bd05f;};}function handleError(_0x13b172,_0x8ed74b){_0x8ed74b=_0x8ed74b||0x1f4;return function(_0x2a62a8){logger['error'](_0x2a62a8[_0x6a3e('0x10')]);if(_0x2a62a8[_0x6a3e('0x11')]){delete _0x2a62a8['name'];}_0x13b172['status'](_0x8ed74b)['send'](_0x2a62a8);};}exports['index']=function(_0x48adf6,_0x3693a2){var _0x467e2c={},_0x31a190={},_0x701d04={'count':0x0,'rows':[]};var _0x17fde0=_[_0x6a3e('0x12')](db[_0x6a3e('0x13')][_0x6a3e('0x14')],function(_0x493454){return{'name':_0x493454[_0x6a3e('0x15')],'type':_0x493454['type'][_0x6a3e('0x16')]};});_0x31a190['model']=_[_0x6a3e('0x12')](_0x17fde0,_0x6a3e('0x11'));_0x31a190[_0x6a3e('0x17')]=_[_0x6a3e('0x18')](_0x48adf6['query']);_0x31a190['filters']=_[_0x6a3e('0x19')](_0x31a190[_0x6a3e('0x1a')],_0x31a190[_0x6a3e('0x17')]);_0x31a190[_0x6a3e('0x1b')]=_[_0x6a3e('0x1c')](_0x31a190[_0x6a3e('0x1b')],[_0x6a3e('0x1d'),_0x6a3e('0x1e'),_0x6a3e('0x1f'),_0x6a3e('0x20'),_0x6a3e('0x21'),_0x6a3e('0x22'),_0x6a3e('0x23'),_0x6a3e('0x24'),_0x6a3e('0x25'),'$between','$notBetween',_0x6a3e('0x26'),_0x6a3e('0x27'),_0x6a3e('0x28'),_0x6a3e('0x29'),_0x6a3e('0x2a'),_0x6a3e('0x2b'),_0x6a3e('0x28'),_0x6a3e('0x2c'),_0x6a3e('0x2d'),_0x6a3e('0x2e'),_0x6a3e('0x2f')]);_0x467e2c['attributes']=_['intersection'](_0x31a190[_0x6a3e('0x1a')],qs['fields'](_0x48adf6[_0x6a3e('0x17')]['fields']));_0x467e2c['attributes']=_0x467e2c[_0x6a3e('0x30')][_0x6a3e('0x31')]?_0x467e2c['attributes']:_0x31a190['model'];if(!_0x48adf6[_0x6a3e('0x17')][_0x6a3e('0x32')](_0x6a3e('0x33'))){_0x467e2c[_0x6a3e('0xa')]=qs['limit'](_0x48adf6['query'][_0x6a3e('0xa')]);_0x467e2c[_0x6a3e('0x7')]=qs[_0x6a3e('0x7')](_0x48adf6[_0x6a3e('0x17')]['offset']);}_0x467e2c[_0x6a3e('0x34')]=qs[_0x6a3e('0x35')](_0x48adf6['query']['sort']);_0x467e2c['where']=qs[_0x6a3e('0x1b')](_[_0x6a3e('0x36')](_0x48adf6[_0x6a3e('0x17')],_0x31a190[_0x6a3e('0x1b')]),_0x17fde0);if(_0x48adf6[_0x6a3e('0x17')][_0x6a3e('0x37')]){_0x467e2c[_0x6a3e('0x38')]=_[_0x6a3e('0x39')](_0x467e2c[_0x6a3e('0x38')],{'$or':_[_0x6a3e('0x12')](_0x17fde0,function(_0xe442a9){if(_0xe442a9[_0x6a3e('0x3a')]!==_0x6a3e('0x3b')){var _0x12469a={};_0x12469a[_0xe442a9[_0x6a3e('0x11')]]={'$like':'%'+_0x48adf6['query'][_0x6a3e('0x37')]+'%'};return _0x12469a;}})});}_0x467e2c=_[_0x6a3e('0x39')]({},_0x467e2c,_0x48adf6[_0x6a3e('0x3c')]);var _0x5cf995={'where':_0x467e2c[_0x6a3e('0x38')]};return db[_0x6a3e('0x13')]['count'](_0x5cf995)[_0x6a3e('0xe')](function(_0x3f7e1){_0x701d04[_0x6a3e('0x9')]=_0x3f7e1;if(_0x48adf6['query'][_0x6a3e('0x3d')]){_0x467e2c[_0x6a3e('0x3e')]=[{'all':!![]}];}return db[_0x6a3e('0x13')][_0x6a3e('0x3f')](_0x467e2c);})[_0x6a3e('0xe')](function(_0x1f7d13){_0x701d04['rows']=_0x1f7d13;return _0x701d04;})[_0x6a3e('0xe')](respondWithFilteredResult(_0x3693a2,_0x467e2c))['catch'](handleError(_0x3693a2,null));};exports['show']=function(_0x4bc630,_0xfbbb78){var _0x4bb1ba={'raw':!![],'where':{'id':_0x4bc630[_0x6a3e('0x40')]['id']}},_0x1a6b68={};_0x1a6b68[_0x6a3e('0x1a')]=_[_0x6a3e('0x18')](db[_0x6a3e('0x13')][_0x6a3e('0x14')]);_0x1a6b68['query']=_['keys'](_0x4bc630[_0x6a3e('0x17')]);_0x1a6b68[_0x6a3e('0x1b')]=_[_0x6a3e('0x19')](_0x1a6b68[_0x6a3e('0x1a')],_0x1a6b68[_0x6a3e('0x17')]);_0x4bb1ba['attributes']=_[_0x6a3e('0x19')](_0x1a6b68[_0x6a3e('0x1a')],qs['fields'](_0x4bc630[_0x6a3e('0x17')][_0x6a3e('0x41')]));_0x4bb1ba[_0x6a3e('0x30')]=_0x4bb1ba['attributes'][_0x6a3e('0x31')]?_0x4bb1ba[_0x6a3e('0x30')]:_0x1a6b68[_0x6a3e('0x1a')];if(_0x4bc630[_0x6a3e('0x17')][_0x6a3e('0x3d')]){_0x4bb1ba[_0x6a3e('0x3e')]=[{'all':!![]}];}_0x4bb1ba=_['merge']({},_0x4bb1ba,_0x4bc630[_0x6a3e('0x3c')]);return db[_0x6a3e('0x13')][_0x6a3e('0x42')](_0x4bb1ba)['then'](handleEntityNotFound(_0xfbbb78,null))[_0x6a3e('0xe')](respondWithResult(_0xfbbb78,null))['catch'](handleError(_0xfbbb78,null));};exports['create']=function(_0x1b801e,_0x2788a8){return db[_0x6a3e('0x13')]['create'](_0x1b801e['body'],{})[_0x6a3e('0xe')](respondWithResult(_0x2788a8,0xc9))[_0x6a3e('0x43')](handleError(_0x2788a8,null));};exports[_0x6a3e('0xd')]=function(_0x320530,_0x1c9f75){if(_0x320530[_0x6a3e('0x44')]['id']){delete _0x320530['body']['id'];}return db[_0x6a3e('0x13')][_0x6a3e('0x42')]({'where':{'id':_0x320530[_0x6a3e('0x40')]['id']}})[_0x6a3e('0xe')](handleEntityNotFound(_0x1c9f75,null))[_0x6a3e('0xe')](saveUpdates(_0x320530[_0x6a3e('0x44')],null))[_0x6a3e('0xe')](respondWithResult(_0x1c9f75,null))[_0x6a3e('0x43')](handleError(_0x1c9f75,null));};exports[_0x6a3e('0x45')]=function(_0x4d36e2,_0x40a09d){return db[_0x6a3e('0x13')]['describe']()[_0x6a3e('0xe')](respondWithResult(_0x40a09d,null))['catch'](handleError(_0x40a09d,null));};exports[_0x6a3e('0x46')]=function(_0x10cd8e,_0x28a3e9){var _0x4f288d;var _0x25fa0c=_0x10cd8e[_0x6a3e('0x40')]['id'];return db['CmHopper']['find']({'where':{'id':_0x10cd8e['params']['id']}})[_0x6a3e('0xe')](handleEntityNotFound(_0x28a3e9,null))[_0x6a3e('0xe')](function(_0x32fb36){if(_0x32fb36){return _0x32fb36[_0x6a3e('0x46')]()[_0x6a3e('0xe')](function(_0x448e46){return _0x448e46;});}})[_0x6a3e('0xe')](function(_0x1ce964){_0x4f288d=_0x1ce964;if(_0x1ce964){if(_0x1ce964[_0x6a3e('0x47')]||_0x1ce964[_0x6a3e('0x48')]){return db[_0x1ce964[_0x6a3e('0x47')]?'VoiceQueue':_0x6a3e('0x49')][_0x6a3e('0x42')]({'where':{'id':_0x1ce964[_0x6a3e('0x47')]?_0x1ce964[_0x6a3e('0x47')]:_0x1ce964[_0x6a3e('0x48')]},'attributes':['id','name'],'raw':!![]});}}})[_0x6a3e('0xe')](function(_0x4d1882){var _0x1afa0a={};if(_0x4d1882){_[_0x6a3e('0x39')](_0x1afa0a,_[_0x6a3e('0x4a')](_0x4f288d[_0x6a3e('0x4b')],[_0x6a3e('0x4c'),'updatedAt','id']));_0x1afa0a['state']=0x15;_0x1afa0a['statedesc']=_0x6a3e('0x4d');_0x1afa0a[_0x6a3e('0x4e')]=_0x4d1882[_0x6a3e('0x11')];_0x1afa0a[_0x6a3e('0x4f')]=_0x10cd8e[_0x6a3e('0x50')][_0x6a3e('0x11')];_0x1afa0a['UserId']=_0x10cd8e[_0x6a3e('0x50')]['id'];_0x1afa0a['deleted']=!![];_0x1afa0a['deletedat']=moment()['format'](_0x6a3e('0x51'));_0x1afa0a[_0x6a3e('0x52')]=_0x4f288d['phone'];_0x1afa0a[_0x6a3e('0x53')]=_0x4f288d[_0x6a3e('0x47')]?'queue':_0x6a3e('0x54');return db[_0x6a3e('0x55')][_0x6a3e('0x42')]({'where':{'id':_0x1afa0a[_0x6a3e('0x56')]},'attributes':[_0x6a3e('0x57'),'lastName']})[_0x6a3e('0xe')](function(_0x9128f8){if(!_['isNil'](_0x28a3e9)&&!_[_0x6a3e('0x58')](_0x9128f8[_0x6a3e('0x57')])){_0x1afa0a[_0x6a3e('0x59')]=_0x9128f8[_0x6a3e('0x57')];if(!_[_0x6a3e('0x58')](_0x9128f8[_0x6a3e('0x5a')])){_0x1afa0a[_0x6a3e('0x59')]+='\x20'+_0x9128f8[_0x6a3e('0x5a')];}}})[_0x6a3e('0x5b')](function(){return db[_0x6a3e('0x5c')][_0x6a3e('0x5d')](_0x1afa0a);});}})['then'](function(_0x2870be){return db[_0x6a3e('0x5e')][_0x6a3e('0x46')]({'where':{'CmHopperId':_0x25fa0c}});})['then'](function(){return _0x28a3e9[_0x6a3e('0x5')](0xcc)[_0x6a3e('0x5f')]();})[_0x6a3e('0x43')](handleError(_0x28a3e9,null));};exports[_0x6a3e('0x60')]=function(_0x582ad9,_0x3e29a8){var _0x5ed33d=[];return db[_0x6a3e('0x55')]['describe']()[_0x6a3e('0xe')](function(_0x486d4a){_0x5ed33d=_[_0x6a3e('0x18')](_0x486d4a);return _0x582ad9[_0x6a3e('0x50')][_0x6a3e('0x61')]({'where':{'type':_0x6a3e('0x62'),'dialActive':!![],'dialMethod':_0x6a3e('0x63')},'attributes':['id',_0x6a3e('0x64'),_0x6a3e('0x65')],'raw':!![]});})['then'](function(_0x3a5f9d){if(_0x3a5f9d&&_0x3a5f9d[_0x6a3e('0x31')]){return db[_0x6a3e('0x66')][_0x6a3e('0x67')](function(_0x145655){var _0x3a4a29={'active':![],'recallme':![],'scheduledAt':{'$lte':moment()[_0x6a3e('0x68')](_0x6a3e('0x51'))},'VoiceQueueId':{'$in':_[_0x6a3e('0x12')](_0x3a5f9d,'id')},'$or':[{'UserId':null},{'UserId':_0x582ad9[_0x6a3e('0x50')]['id']}]};var _0x3c7bd0={'active':![],'recallme':!![],'VoiceQueueId':{'$in':_(_0x3a5f9d)[_0x6a3e('0x37')](['dialPreviewAutoRecallMe',0x0])[_0x6a3e('0x12')]('id')[_0x6a3e('0x69')]()},'$or':[{'UserId':null},{'UserId':_0x582ad9[_0x6a3e('0x50')]['id']}]};var _0x5d11f9={'$or':[_0x3a4a29,_0x3c7bd0]};var _0x4420b9=[];if(_0x582ad9['body'][_0x6a3e('0x6a')]&&_0x582ad9[_0x6a3e('0x44')]['direction']===_0x6a3e('0x6b')){if(!_[_0x6a3e('0x6c')](_0x582ad9['body'][_0x6a3e('0x6d')])){_0x5d11f9['id']={'$in':_0x582ad9[_0x6a3e('0x44')][_0x6a3e('0x6d')]};}_0x4420b9=[[_0x6a3e('0x6e'),_0x6a3e('0x6f')],['scheduledAt',_0x3a5f9d[0x0][_0x6a3e('0x64')]==='ASC'?_0x6a3e('0x70'):'ASC'],db[_0x6a3e('0x66')][_0x6a3e('0x71')](_0x6a3e('0x72')),['id',_0x6a3e('0x70')]];}else{if(!_['isEmpty'](_0x582ad9['body'][_0x6a3e('0x6d')])){_0x5d11f9['id']={'$notIn':_0x582ad9[_0x6a3e('0x44')]['hopperIds']};}_0x4420b9=[[_0x6a3e('0x6e'),_0x6a3e('0x70')],[_0x6a3e('0x73'),_0x3a5f9d[0x0][_0x6a3e('0x64')]],db[_0x6a3e('0x66')]['literal']('COALESCE(CmHopper.UserId,\x200)\x20DESC'),['id',_0x6a3e('0x6f')]];}return db[_0x6a3e('0x13')][_0x6a3e('0x74')]({'attributes':['id',_0x6a3e('0x75'),_0x6a3e('0x76'),_0x6a3e('0x77')],'where':_0x5d11f9,'order':_0x4420b9,'transaction':_0x145655,'lock':_0x145655['LOCK'][_0x6a3e('0x78')],'include':[{'model':db[_0x6a3e('0x55')],'as':_0x6a3e('0x79'),'attributes':_0x5ed33d,'include':[{'model':db[_0x6a3e('0x7a')],'as':_0x6a3e('0x7b'),'attributes':['id',_0x6a3e('0x11')]}]},{'model':db['CmList'],'as':'List','attributes':['id',_0x6a3e('0x11')]},{'model':db[_0x6a3e('0x7c')],'as':_0x6a3e('0x7d'),'attributes':['id',_0x6a3e('0x11'),_0x6a3e('0x7e')]}]})[_0x6a3e('0xe')](function(_0x2208e9){if(_0x2208e9){return _0x2208e9[_0x6a3e('0xd')]({'UserId':_0x582ad9[_0x6a3e('0x50')]['id']},{'transaction':_0x145655});}});});}})['then'](handleEntityNotFound(_0x3e29a8,null))[_0x6a3e('0xe')](respondWithResult(_0x3e29a8,null))[_0x6a3e('0x43')](handleError(_0x3e29a8,null));};exports[_0x6a3e('0x7f')]=function(_0x2e8af7,_0x35bbfe,_0x281fba){var _0x7e983a=[];var _0x687f86=_0x2e8af7['params']['id'];var _0x477bfb=_0x2e8af7['user']['id'];return db['CmContact'][_0x6a3e('0x45')]()[_0x6a3e('0xe')](function(_0x3f68c6){_0x7e983a=_['keys'](_0x3f68c6);return db[_0x6a3e('0x66')][_0x6a3e('0x67')](function(_0x20fdf4){const _0x672d9d={'id':_0x687f86};return db[_0x6a3e('0x13')][_0x6a3e('0x74')]({'attributes':['id',_0x6a3e('0x75'),_0x6a3e('0x77')],'where':_0x672d9d,'transaction':_0x20fdf4,'lock':_0x20fdf4[_0x6a3e('0x80')]['UPDATE'],'include':[{'model':db[_0x6a3e('0x55')],'as':_0x6a3e('0x79'),'attributes':_0x7e983a,'include':[{'model':db[_0x6a3e('0x7a')],'as':_0x6a3e('0x7b'),'attributes':['id',_0x6a3e('0x11')]}]},{'model':db[_0x6a3e('0x81')],'as':_0x6a3e('0x82'),'attributes':['id',_0x6a3e('0x11')]},{'model':db[_0x6a3e('0x7c')],'as':_0x6a3e('0x7d'),'attributes':['id',_0x6a3e('0x11'),'dialActive']}]})['then'](function(_0x5148de){if(_0x5148de){return _0x5148de[_0x6a3e('0xd')]({'UserId':_0x477bfb},{'transaction':_0x20fdf4});}});});})['then'](handleEntityNotFound(_0x35bbfe,null))['then'](respondWithResult(_0x35bbfe,null))[_0x6a3e('0x43')](handleError(_0x35bbfe,null));};exports['getOpenContacts']=function(_0x1029f9,_0x7bf1b2){return _0x1029f9[_0x6a3e('0x50')][_0x6a3e('0x61')]({'where':{'type':_0x6a3e('0x62'),'dialActive':!![],'dialMethod':'preview'},'attributes':['id'],'raw':!![]})[_0x6a3e('0xe')](function(_0x5bb624){if(_0x5bb624&&_0x5bb624[_0x6a3e('0x31')]){return db[_0x6a3e('0x13')][_0x6a3e('0x9')]({'where':{'active':![],'recallme':![],'scheduledAt':{'$lte':moment()[_0x6a3e('0x68')]('YYYY-MM-DD\x20HH:mm:ss')},'VoiceQueueId':{'$in':_['map'](_0x5bb624,'id')},'$or':[{'UserId':null},{'UserId':_0x1029f9[_0x6a3e('0x50')]['id']}]}});}return 0x0;})[_0x6a3e('0xe')](function(_0x242f2e){if(!_[_0x6a3e('0x58')](_0x242f2e)&&_['isNumber'](_0x242f2e)){return _0x7bf1b2[_0x6a3e('0x5')](0xc8)[_0x6a3e('0x6')]({'contacts':_0x242f2e});}else{logger[_0x6a3e('0x83')]('CmHopper,\x20%s,\x20%s,\x20%s',_0x6a3e('0x84'),0x194,_0x6a3e('0x85'));_0x7bf1b2[_0x6a3e('0xf')](0x194);}})['catch'](handleError(_0x7bf1b2,null));};exports['getTimezones']=function(_0x242c45,_0xe89e40){var _0x35cefc=shared['timezones'];var _0xb9d497=[];_[_0x6a3e('0x12')](_0x35cefc,function(_0x5bf103){_0xb9d497[_0x6a3e('0x86')]({'id':_0x5bf103[_0x6a3e('0x11')],'name':_0x5bf103[_0x6a3e('0x11')],'utcOffset':_0x5bf103[_0x6a3e('0x87')]});});return _0xe89e40['status'](0xc8)['json']({'tz':_0xb9d497});};exports['getTimezone']=function(_0x4b71f4,_0x515764){var _0x32aefd=shared[_0x6a3e('0x88')];var _0x442eca={};if(!_[_0x6a3e('0x58')](_0x32aefd[_0x4b71f4[_0x6a3e('0x44')]['id']]))_0x442eca=_0x32aefd[_0x4b71f4['body']['id']];return _0x515764[_0x6a3e('0x5')](0xc8)[_0x6a3e('0x6')](_0x442eca);};
\ No newline at end of file