Built motion from commit 953226e6.|2.6.32
[motion2.git] / server / api / cmHopper / cmHopper.controller.js
index f984608..5033cc2 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x2caf=['$lte','$ne','$eq','$not','$between','$notBetween','$in','$notIn','$notLike','$iLike','$notILike','$like','$overlap','$contains','$contained','$any','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','VIRTUAL','merge','options','then','includeAll','include','findAll','catch','show','params','find','create','body','describe','destroy','CampaignId','VoiceQueueId','Campaign','omit','dataValues','createdAt','updatedAt','state','membername','user','deleted','deletedat','format','YYYY-MM-DD\x20HH:mm:ss','calleridnum','phone','queue','ivr','ContactId','lastName','isNil','firstName','calleridname','finally','CmHopperFinal','CmHopperAdditionalPhone','getPreview','CmContact','getVoiceQueues','preview','dialOrderByScheduledAt','dialPreviewAutoRecallMe','sequelize','transaction','value','direction','isEmpty','hopperIds','priority','ASC','scheduledAt','DESC','COALESCE(CmHopper.UserId,\x200)\x20ASC','findOne','scheduledat','LOCK','UPDATE','Contact','CmCompany','CmList','List','VoiceQueue','Queue','dialActive','update','getPreviewRecall','Company','getOpenContacts','outbound','isNumber','entity\x20not\x20found','timezones','push','utcOffset','getTimezone','../../config/logger','../../config/environment','../../mysqldb','status','json','limit','undefined','count','offset','Content-Range','sendStatus','error','name','index','map','CmHopper','rawAttributes','fieldName','type','key','query','keys','filters','intersection','model','concat','$and','$or','$gt'];(function(_0x93b675,_0x9f4d81){var _0x53d795=function(_0x2e1337){while(--_0x2e1337){_0x93b675['push'](_0x93b675['shift']());}};_0x53d795(++_0x9f4d81);}(_0x2caf,0x6a));var _0xf2ca=function(_0x22d53f,_0x15720d){_0x22d53f=_0x22d53f-0x0;var _0x3fa7a0=_0x2caf[_0x22d53f];return _0x3fa7a0;};'use strict';var moment=require('moment');var _=require('lodash');var qs=require('../../components/parsers/qs');var logger=require(_0xf2ca('0x0'))('api');var shared=require(_0xf2ca('0x1'));var db=require(_0xf2ca('0x2'))['db'];function respondWithResult(_0x43b96c,_0x375e8b){_0x375e8b=_0x375e8b||0xc8;return function(_0x137501){if(_0x137501){return _0x43b96c[_0xf2ca('0x3')](_0x375e8b)[_0xf2ca('0x4')](_0x137501);}};}function respondWithFilteredResult(_0x51372a,_0x8ce770){return function(_0x4292b4){if(_0x4292b4){var _0x16cabd=typeof _0x8ce770['offset']==='undefined'&&typeof _0x8ce770[_0xf2ca('0x5')]===_0xf2ca('0x6');var _0x1177f0=_0x4292b4[_0xf2ca('0x7')];var _0x1c1afd=_0x16cabd?0x0:_0x8ce770['offset'];var _0x1ecd50=_0x16cabd?_0x4292b4[_0xf2ca('0x7')]:_0x8ce770[_0xf2ca('0x8')]+_0x8ce770[_0xf2ca('0x5')];var _0x1ff621;if(_0x1ecd50>=_0x1177f0){_0x1ecd50=_0x1177f0;_0x1ff621=0xc8;}else{_0x1ff621=0xce;}_0x51372a[_0xf2ca('0x3')](_0x1ff621);return _0x51372a['set'](_0xf2ca('0x9'),_0x1c1afd+'-'+_0x1ecd50+'/'+_0x1177f0)[_0xf2ca('0x4')](_0x4292b4);}return null;};}function saveUpdates(_0x54a3cb,_0x88529f){return function(_0x383112){if(_0x383112){return _0x383112['update'](_0x54a3cb)['then'](function(_0xa4e5b1){return _0xa4e5b1;});}return null;};}function handleEntityNotFound(_0x52a278,_0x284484){return function(_0x3123fe){if(!_0x3123fe){_0x52a278[_0xf2ca('0xa')](0x194);}return _0x3123fe;};}function handleError(_0x1e9227,_0x410997){_0x410997=_0x410997||0x1f4;return function(_0x2057a2){logger[_0xf2ca('0xb')](_0x2057a2['stack']);if(_0x2057a2[_0xf2ca('0xc')]){delete _0x2057a2['name'];}_0x1e9227[_0xf2ca('0x3')](_0x410997)['send'](_0x2057a2);};}exports[_0xf2ca('0xd')]=function(_0x6a2b25,_0x59ea3c){var _0x3c0055={},_0x160230={},_0x1b3a36={'count':0x0,'rows':[]};var _0x310504=_[_0xf2ca('0xe')](db[_0xf2ca('0xf')][_0xf2ca('0x10')],function(_0x1548a4){return{'name':_0x1548a4[_0xf2ca('0x11')],'type':_0x1548a4[_0xf2ca('0x12')][_0xf2ca('0x13')]};});_0x160230['model']=_[_0xf2ca('0xe')](_0x310504,_0xf2ca('0xc'));_0x160230[_0xf2ca('0x14')]=_[_0xf2ca('0x15')](_0x6a2b25[_0xf2ca('0x14')]);_0x160230[_0xf2ca('0x16')]=_[_0xf2ca('0x17')](_0x160230[_0xf2ca('0x18')],_0x160230['query']);_0x160230[_0xf2ca('0x16')]=_[_0xf2ca('0x19')](_0x160230['filters'],[_0xf2ca('0x1a'),_0xf2ca('0x1b'),_0xf2ca('0x1c'),'$gte','$lt',_0xf2ca('0x1d'),_0xf2ca('0x1e'),_0xf2ca('0x1f'),_0xf2ca('0x20'),_0xf2ca('0x21'),_0xf2ca('0x22'),_0xf2ca('0x23'),_0xf2ca('0x24'),'$like',_0xf2ca('0x25'),_0xf2ca('0x26'),_0xf2ca('0x27'),_0xf2ca('0x28'),_0xf2ca('0x29'),_0xf2ca('0x2a'),_0xf2ca('0x2b'),_0xf2ca('0x2c')]);_0x3c0055[_0xf2ca('0x2d')]=_[_0xf2ca('0x17')](_0x160230[_0xf2ca('0x18')],qs[_0xf2ca('0x2e')](_0x6a2b25[_0xf2ca('0x14')][_0xf2ca('0x2e')]));_0x3c0055[_0xf2ca('0x2d')]=_0x3c0055[_0xf2ca('0x2d')][_0xf2ca('0x2f')]?_0x3c0055[_0xf2ca('0x2d')]:_0x160230[_0xf2ca('0x18')];if(!_0x6a2b25['query'][_0xf2ca('0x30')](_0xf2ca('0x31'))){_0x3c0055[_0xf2ca('0x5')]=qs[_0xf2ca('0x5')](_0x6a2b25[_0xf2ca('0x14')][_0xf2ca('0x5')]);_0x3c0055[_0xf2ca('0x8')]=qs[_0xf2ca('0x8')](_0x6a2b25[_0xf2ca('0x14')]['offset']);}_0x3c0055[_0xf2ca('0x32')]=qs[_0xf2ca('0x33')](_0x6a2b25[_0xf2ca('0x14')]['sort']);_0x3c0055[_0xf2ca('0x34')]=qs['filters'](_[_0xf2ca('0x35')](_0x6a2b25[_0xf2ca('0x14')],_0x160230[_0xf2ca('0x16')]),_0x310504);if(_0x6a2b25[_0xf2ca('0x14')][_0xf2ca('0x36')]){_0x3c0055['where']=_['merge'](_0x3c0055[_0xf2ca('0x34')],{'$or':_['map'](_0x310504,function(_0x3caa5d){if(_0x3caa5d[_0xf2ca('0x12')]!==_0xf2ca('0x37')){var _0x3152eb={};_0x3152eb[_0x3caa5d[_0xf2ca('0xc')]]={'$like':'%'+_0x6a2b25[_0xf2ca('0x14')][_0xf2ca('0x36')]+'%'};return _0x3152eb;}})});}_0x3c0055=_[_0xf2ca('0x38')]({},_0x3c0055,_0x6a2b25[_0xf2ca('0x39')]);var _0x1ad216={'where':_0x3c0055[_0xf2ca('0x34')]};return db[_0xf2ca('0xf')][_0xf2ca('0x7')](_0x1ad216)[_0xf2ca('0x3a')](function(_0x211f00){_0x1b3a36[_0xf2ca('0x7')]=_0x211f00;if(_0x6a2b25['query'][_0xf2ca('0x3b')]){_0x3c0055[_0xf2ca('0x3c')]=[{'all':!![]}];}return db[_0xf2ca('0xf')][_0xf2ca('0x3d')](_0x3c0055);})['then'](function(_0x46643e){_0x1b3a36['rows']=_0x46643e;return _0x1b3a36;})[_0xf2ca('0x3a')](respondWithFilteredResult(_0x59ea3c,_0x3c0055))[_0xf2ca('0x3e')](handleError(_0x59ea3c,null));};exports[_0xf2ca('0x3f')]=function(_0x2c196d,_0x385904){var _0x4fbaec={'raw':!![],'where':{'id':_0x2c196d[_0xf2ca('0x40')]['id']}},_0x37e50e={};_0x37e50e['model']=_[_0xf2ca('0x15')](db[_0xf2ca('0xf')][_0xf2ca('0x10')]);_0x37e50e['query']=_[_0xf2ca('0x15')](_0x2c196d['query']);_0x37e50e[_0xf2ca('0x16')]=_[_0xf2ca('0x17')](_0x37e50e[_0xf2ca('0x18')],_0x37e50e[_0xf2ca('0x14')]);_0x4fbaec[_0xf2ca('0x2d')]=_[_0xf2ca('0x17')](_0x37e50e[_0xf2ca('0x18')],qs[_0xf2ca('0x2e')](_0x2c196d[_0xf2ca('0x14')][_0xf2ca('0x2e')]));_0x4fbaec[_0xf2ca('0x2d')]=_0x4fbaec[_0xf2ca('0x2d')][_0xf2ca('0x2f')]?_0x4fbaec[_0xf2ca('0x2d')]:_0x37e50e[_0xf2ca('0x18')];if(_0x2c196d['query'][_0xf2ca('0x3b')]){_0x4fbaec[_0xf2ca('0x3c')]=[{'all':!![]}];}_0x4fbaec=_[_0xf2ca('0x38')]({},_0x4fbaec,_0x2c196d[_0xf2ca('0x39')]);return db[_0xf2ca('0xf')][_0xf2ca('0x41')](_0x4fbaec)[_0xf2ca('0x3a')](handleEntityNotFound(_0x385904,null))[_0xf2ca('0x3a')](respondWithResult(_0x385904,null))[_0xf2ca('0x3e')](handleError(_0x385904,null));};exports[_0xf2ca('0x42')]=function(_0x20f215,_0x142789){return db[_0xf2ca('0xf')]['create'](_0x20f215['body'],{})[_0xf2ca('0x3a')](respondWithResult(_0x142789,0xc9))[_0xf2ca('0x3e')](handleError(_0x142789,null));};exports['update']=function(_0x102c3c,_0x4c5125){if(_0x102c3c[_0xf2ca('0x43')]['id']){delete _0x102c3c[_0xf2ca('0x43')]['id'];}return db[_0xf2ca('0xf')]['find']({'where':{'id':_0x102c3c[_0xf2ca('0x40')]['id']}})[_0xf2ca('0x3a')](handleEntityNotFound(_0x4c5125,null))['then'](saveUpdates(_0x102c3c[_0xf2ca('0x43')],null))[_0xf2ca('0x3a')](respondWithResult(_0x4c5125,null))[_0xf2ca('0x3e')](handleError(_0x4c5125,null));};exports[_0xf2ca('0x44')]=function(_0x4a6439,_0x3d67fe){return db[_0xf2ca('0xf')][_0xf2ca('0x44')]()['then'](respondWithResult(_0x3d67fe,null))['catch'](handleError(_0x3d67fe,null));};exports[_0xf2ca('0x45')]=function(_0x2f7596,_0x1a65c6){var _0x718ee1;var _0x3f31de=_0x2f7596[_0xf2ca('0x40')]['id'];return db['CmHopper']['find']({'where':{'id':_0x2f7596[_0xf2ca('0x40')]['id']}})[_0xf2ca('0x3a')](handleEntityNotFound(_0x1a65c6,null))['then'](function(_0x2f8ba0){if(_0x2f8ba0){return _0x2f8ba0['destroy']()[_0xf2ca('0x3a')](function(_0x59bbb8){return _0x59bbb8;});}})[_0xf2ca('0x3a')](function(_0x5f3fc7){_0x718ee1=_0x5f3fc7;if(_0x5f3fc7){if(_0x5f3fc7['VoiceQueueId']||_0x5f3fc7[_0xf2ca('0x46')]){return db[_0x5f3fc7[_0xf2ca('0x47')]?'VoiceQueue':_0xf2ca('0x48')][_0xf2ca('0x41')]({'where':{'id':_0x5f3fc7[_0xf2ca('0x47')]?_0x5f3fc7[_0xf2ca('0x47')]:_0x5f3fc7[_0xf2ca('0x46')]},'attributes':['id',_0xf2ca('0xc')],'raw':!![]});}}})['then'](function(_0x223cb1){var _0x3ac6ec={};if(_0x223cb1){_['merge'](_0x3ac6ec,_[_0xf2ca('0x49')](_0x718ee1[_0xf2ca('0x4a')],[_0xf2ca('0x4b'),_0xf2ca('0x4c'),'id']));_0x3ac6ec[_0xf2ca('0x4d')]=0x15;_0x3ac6ec['statedesc']='deleted';_0x3ac6ec['campaign']=_0x223cb1[_0xf2ca('0xc')];_0x3ac6ec[_0xf2ca('0x4e')]=_0x2f7596[_0xf2ca('0x4f')][_0xf2ca('0xc')];_0x3ac6ec['UserId']=_0x2f7596[_0xf2ca('0x4f')]['id'];_0x3ac6ec[_0xf2ca('0x50')]=!![];_0x3ac6ec[_0xf2ca('0x51')]=moment()[_0xf2ca('0x52')](_0xf2ca('0x53'));_0x3ac6ec[_0xf2ca('0x54')]=_0x718ee1[_0xf2ca('0x55')];_0x3ac6ec['campaigntype']=_0x718ee1[_0xf2ca('0x47')]?_0xf2ca('0x56'):_0xf2ca('0x57');return db['CmContact'][_0xf2ca('0x41')]({'where':{'id':_0x3ac6ec[_0xf2ca('0x58')]},'attributes':['firstName',_0xf2ca('0x59')]})[_0xf2ca('0x3a')](function(_0x381448){if(!_['isNil'](_0x1a65c6)&&!_[_0xf2ca('0x5a')](_0x381448[_0xf2ca('0x5b')])){_0x3ac6ec[_0xf2ca('0x5c')]=_0x381448[_0xf2ca('0x5b')];if(!_['isNil'](_0x381448['lastName'])){_0x3ac6ec[_0xf2ca('0x5c')]+='\x20'+_0x381448[_0xf2ca('0x59')];}}})[_0xf2ca('0x5d')](function(){return db[_0xf2ca('0x5e')]['create'](_0x3ac6ec);});}})[_0xf2ca('0x3a')](function(_0x4e1f9d){return db[_0xf2ca('0x5f')][_0xf2ca('0x45')]({'where':{'CmHopperId':_0x3f31de}});})[_0xf2ca('0x3a')](function(){return _0x1a65c6[_0xf2ca('0x3')](0xcc)['end']();})[_0xf2ca('0x3e')](handleError(_0x1a65c6,null));};exports[_0xf2ca('0x60')]=function(_0x2a7a70,_0x359eef){var _0x40364c=[];return db[_0xf2ca('0x61')]['describe']()[_0xf2ca('0x3a')](function(_0x588363){_0x40364c=_[_0xf2ca('0x15')](_0x588363);return _0x2a7a70[_0xf2ca('0x4f')][_0xf2ca('0x62')]({'where':{'type':'outbound','dialActive':!![],'dialMethod':_0xf2ca('0x63')},'attributes':['id',_0xf2ca('0x64'),_0xf2ca('0x65')],'raw':!![]});})['then'](function(_0x19c73b){if(_0x19c73b&&_0x19c73b[_0xf2ca('0x2f')]){return db[_0xf2ca('0x66')][_0xf2ca('0x67')](function(_0x315420){var _0x219854={'active':![],'recallme':![],'scheduledAt':{'$lte':moment()[_0xf2ca('0x52')]('YYYY-MM-DD\x20HH:mm:ss')},'VoiceQueueId':{'$in':_['map'](_0x19c73b,'id')},'$or':[{'UserId':null},{'UserId':_0x2a7a70['user']['id']}]};var _0x470603={'active':![],'recallme':!![],'VoiceQueueId':{'$in':_(_0x19c73b)[_0xf2ca('0x36')]([_0xf2ca('0x65'),0x0])[_0xf2ca('0xe')]('id')[_0xf2ca('0x68')]()},'$or':[{'UserId':null},{'UserId':_0x2a7a70['user']['id']}]};var _0x4c6f28={'$or':[_0x219854,_0x470603]};var _0xbd933=[];if(_0x2a7a70['body'][_0xf2ca('0x69')]&&_0x2a7a70['body']['direction']==='prev'){if(!_[_0xf2ca('0x6a')](_0x2a7a70[_0xf2ca('0x43')][_0xf2ca('0x6b')])){_0x4c6f28['id']={'$in':_0x2a7a70[_0xf2ca('0x43')][_0xf2ca('0x6b')]};}_0xbd933=[[_0xf2ca('0x6c'),_0xf2ca('0x6d')],[_0xf2ca('0x6e'),_0x19c73b[0x0]['dialOrderByScheduledAt']===_0xf2ca('0x6d')?_0xf2ca('0x6f'):_0xf2ca('0x6d')],db[_0xf2ca('0x66')]['literal'](_0xf2ca('0x70')),['id',_0xf2ca('0x6f')]];}else{if(!_['isEmpty'](_0x2a7a70[_0xf2ca('0x43')]['hopperIds'])){_0x4c6f28['id']={'$notIn':_0x2a7a70[_0xf2ca('0x43')]['hopperIds']};}_0xbd933=[[_0xf2ca('0x6c'),_0xf2ca('0x6f')],[_0xf2ca('0x6e'),_0x19c73b[0x0]['dialOrderByScheduledAt']],db[_0xf2ca('0x66')]['literal']('COALESCE(CmHopper.UserId,\x200)\x20DESC'),['id','ASC']];}return db[_0xf2ca('0xf')][_0xf2ca('0x71')]({'attributes':['id',_0xf2ca('0x72'),_0xf2ca('0x55'),'recallme'],'where':_0x4c6f28,'order':_0xbd933,'transaction':_0x315420,'lock':_0x315420[_0xf2ca('0x73')][_0xf2ca('0x74')],'include':[{'model':db['CmContact'],'as':_0xf2ca('0x75'),'attributes':_0x40364c,'include':[{'model':db[_0xf2ca('0x76')],'as':'Company','attributes':['id',_0xf2ca('0xc')]}]},{'model':db[_0xf2ca('0x77')],'as':_0xf2ca('0x78'),'attributes':['id',_0xf2ca('0xc')]},{'model':db[_0xf2ca('0x79')],'as':_0xf2ca('0x7a'),'attributes':['id','name',_0xf2ca('0x7b')]}]})[_0xf2ca('0x3a')](function(_0x3c9e50){if(_0x3c9e50){return _0x3c9e50[_0xf2ca('0x7c')]({'UserId':_0x2a7a70[_0xf2ca('0x4f')]['id']},{'transaction':_0x315420});}});});}})[_0xf2ca('0x3a')](handleEntityNotFound(_0x359eef,null))[_0xf2ca('0x3a')](respondWithResult(_0x359eef,null))['catch'](handleError(_0x359eef,null));};exports[_0xf2ca('0x7d')]=function(_0x877d77,_0x1d7e23,_0x424dad){var _0x5bea6e=[];var _0x581886=_0x877d77[_0xf2ca('0x40')]['id'];var _0x53f005=_0x877d77['user']['id'];return db[_0xf2ca('0x61')][_0xf2ca('0x44')]()[_0xf2ca('0x3a')](function(_0x482877){_0x5bea6e=_[_0xf2ca('0x15')](_0x482877);return db[_0xf2ca('0x66')][_0xf2ca('0x67')](function(_0x294d6f){const _0xdbcb3={'id':_0x581886};return db['CmHopper'][_0xf2ca('0x71')]({'attributes':['id',_0xf2ca('0x72'),'recallme'],'where':_0xdbcb3,'transaction':_0x294d6f,'lock':_0x294d6f[_0xf2ca('0x73')][_0xf2ca('0x74')],'include':[{'model':db[_0xf2ca('0x61')],'as':_0xf2ca('0x75'),'attributes':_0x5bea6e,'include':[{'model':db[_0xf2ca('0x76')],'as':_0xf2ca('0x7e'),'attributes':['id',_0xf2ca('0xc')]}]},{'model':db[_0xf2ca('0x77')],'as':_0xf2ca('0x78'),'attributes':['id','name']},{'model':db[_0xf2ca('0x79')],'as':_0xf2ca('0x7a'),'attributes':['id',_0xf2ca('0xc'),_0xf2ca('0x7b')]}]})[_0xf2ca('0x3a')](function(_0x2f7b82){if(_0x2f7b82){return _0x2f7b82['update']({'UserId':_0x53f005},{'transaction':_0x294d6f});}});});})['then'](handleEntityNotFound(_0x1d7e23,null))[_0xf2ca('0x3a')](respondWithResult(_0x1d7e23,null))[_0xf2ca('0x3e')](handleError(_0x1d7e23,null));};exports[_0xf2ca('0x7f')]=function(_0xda8883,_0x1d11f8){return _0xda8883[_0xf2ca('0x4f')][_0xf2ca('0x62')]({'where':{'type':_0xf2ca('0x80'),'dialActive':!![],'dialMethod':'preview'},'attributes':['id'],'raw':!![]})[_0xf2ca('0x3a')](function(_0x1b16b1){if(_0x1b16b1&&_0x1b16b1[_0xf2ca('0x2f')]){return db['CmHopper'][_0xf2ca('0x7')]({'where':{'active':![],'recallme':![],'scheduledAt':{'$lte':moment()[_0xf2ca('0x52')](_0xf2ca('0x53'))},'VoiceQueueId':{'$in':_[_0xf2ca('0xe')](_0x1b16b1,'id')},'$or':[{'UserId':null},{'UserId':_0xda8883['user']['id']}]}});}return 0x0;})[_0xf2ca('0x3a')](function(_0x271ec6){if(!_[_0xf2ca('0x5a')](_0x271ec6)&&_[_0xf2ca('0x81')](_0x271ec6)){return _0x1d11f8[_0xf2ca('0x3')](0xc8)['json']({'contacts':_0x271ec6});}else{logger[_0xf2ca('0xb')]('CmHopper,\x20%s,\x20%s,\x20%s',_0xf2ca('0x7f'),0x194,_0xf2ca('0x82'));_0x1d11f8[_0xf2ca('0xa')](0x194);}})[_0xf2ca('0x3e')](handleError(_0x1d11f8,null));};exports['getTimezones']=function(_0x532684,_0x1bb147){var _0x1d3e6f=shared[_0xf2ca('0x83')];var _0x28ee05=[];_[_0xf2ca('0xe')](_0x1d3e6f,function(_0x2dc994){_0x28ee05[_0xf2ca('0x84')]({'id':_0x2dc994[_0xf2ca('0xc')],'name':_0x2dc994['name'],'utcOffset':_0x2dc994[_0xf2ca('0x85')]});});return _0x1bb147[_0xf2ca('0x3')](0xc8)[_0xf2ca('0x4')]({'tz':_0x28ee05});};exports[_0xf2ca('0x86')]=function(_0x59d3d4,_0x494761){var _0x23f9cf=shared['timezones'];var _0x3412fc={};if(!_[_0xf2ca('0x5a')](_0x23f9cf[_0x59d3d4[_0xf2ca('0x43')]['id']]))_0x3412fc=_0x23f9cf[_0x59d3d4[_0xf2ca('0x43')]['id']];return _0x494761['status'](0xc8)[_0xf2ca('0x4')](_0x3412fc);};
\ No newline at end of file
+var _0x6f47=['VoiceQueue','Campaign','CampaignId','omit','dataValues','createdAt','updatedAt','statedesc','deleted','campaign','user','UserId','format','YYYY-MM-DD\x20HH:mm:ss','calleridnum','campaigntype','queue','ContactId','isNil','firstName','calleridname','lastName','CmHopperFinal','create','end','getPreview','getVoiceQueues','outbound','dialOrderByScheduledAt','dialPreviewAutoRecallMe','sequelize','transaction','value','body','direction','prev','isEmpty','priority','ASC','scheduledAt','DESC','literal','COALESCE(CmHopper.UserId,\x200)\x20ASC','hopperIds','COALESCE(CmHopper.UserId,\x200)\x20DESC','findOne','scheduledat','phone','recallme','LOCK','UPDATE','Contact','CmCompany','Company','List','dialActive','getPreviewRecall','CmContact','CmList','getOpenContacts','preview','isNumber','CmHopper,\x20%s,\x20%s,\x20%s','entity\x20not\x20found','sendStatus','getTimezones','timezones','push','getTimezone','lodash','../../components/parsers/qs','api','../../mysqldb','status','json','undefined','limit','count','set','Content-Range','update','error','stack','name','send','index','map','CmHopper','rawAttributes','fieldName','type','model','query','keys','filters','concat','$and','$or','$lt','$ne','$notBetween','$in','$notIn','$like','$notLike','$iLike','$any','attributes','intersection','length','nolimit','offset','order','sort','filter','where','VIRTUAL','merge','options','then','includeAll','include','show','params','fields','find','catch','describe','destroy','VoiceQueueId'];(function(_0x19e1e8,_0x150698){var _0x21fc2c=function(_0x55facc){while(--_0x55facc){_0x19e1e8['push'](_0x19e1e8['shift']());}};_0x21fc2c(++_0x150698);}(_0x6f47,0xc7));var _0x76f4=function(_0x9fd887,_0x47f76c){_0x9fd887=_0x9fd887-0x0;var _0x1a54ab=_0x6f47[_0x9fd887];return _0x1a54ab;};'use strict';var moment=require('moment');var _=require(_0x76f4('0x0'));var qs=require(_0x76f4('0x1'));var logger=require('../../config/logger')(_0x76f4('0x2'));var shared=require('../../config/environment');var db=require(_0x76f4('0x3'))['db'];function respondWithResult(_0x47d3e1,_0xe214ad){_0xe214ad=_0xe214ad||0xc8;return function(_0xc5dddc){if(_0xc5dddc){return _0x47d3e1[_0x76f4('0x4')](_0xe214ad)[_0x76f4('0x5')](_0xc5dddc);}};}function respondWithFilteredResult(_0x5754ca,_0x35602f){return function(_0xfc2405){if(_0xfc2405){var _0x2176a7=typeof _0x35602f['offset']===_0x76f4('0x6')&&typeof _0x35602f[_0x76f4('0x7')]===_0x76f4('0x6');var _0xf9b468=_0xfc2405[_0x76f4('0x8')];var _0x4c6b5c=_0x2176a7?0x0:_0x35602f['offset'];var _0x3347ef=_0x2176a7?_0xfc2405[_0x76f4('0x8')]:_0x35602f['offset']+_0x35602f['limit'];var _0x3d8554;if(_0x3347ef>=_0xf9b468){_0x3347ef=_0xf9b468;_0x3d8554=0xc8;}else{_0x3d8554=0xce;}_0x5754ca[_0x76f4('0x4')](_0x3d8554);return _0x5754ca[_0x76f4('0x9')](_0x76f4('0xa'),_0x4c6b5c+'-'+_0x3347ef+'/'+_0xf9b468)[_0x76f4('0x5')](_0xfc2405);}return null;};}function saveUpdates(_0xafd21e,_0xf7e347){return function(_0x3ec740){if(_0x3ec740){return _0x3ec740[_0x76f4('0xb')](_0xafd21e)['then'](function(_0x41ba00){return _0x41ba00;});}return null;};}function handleEntityNotFound(_0x30dabf,_0x5da1ff){return function(_0x4b6021){if(!_0x4b6021){_0x30dabf['sendStatus'](0x194);}return _0x4b6021;};}function handleError(_0x1d7755,_0x3dd240){_0x3dd240=_0x3dd240||0x1f4;return function(_0x979946){logger[_0x76f4('0xc')](_0x979946[_0x76f4('0xd')]);if(_0x979946[_0x76f4('0xe')]){delete _0x979946[_0x76f4('0xe')];}_0x1d7755[_0x76f4('0x4')](_0x3dd240)[_0x76f4('0xf')](_0x979946);};}exports[_0x76f4('0x10')]=function(_0x672960,_0x2d4bd1){var _0x214bef={},_0x38450e={},_0x17625e={'count':0x0,'rows':[]};var _0x397360=_[_0x76f4('0x11')](db[_0x76f4('0x12')][_0x76f4('0x13')],function(_0x35b406){return{'name':_0x35b406[_0x76f4('0x14')],'type':_0x35b406[_0x76f4('0x15')]['key']};});_0x38450e[_0x76f4('0x16')]=_['map'](_0x397360,_0x76f4('0xe'));_0x38450e[_0x76f4('0x17')]=_[_0x76f4('0x18')](_0x672960['query']);_0x38450e['filters']=_['intersection'](_0x38450e[_0x76f4('0x16')],_0x38450e[_0x76f4('0x17')]);_0x38450e[_0x76f4('0x19')]=_[_0x76f4('0x1a')](_0x38450e[_0x76f4('0x19')],[_0x76f4('0x1b'),_0x76f4('0x1c'),'$gt','$gte',_0x76f4('0x1d'),'$lte',_0x76f4('0x1e'),'$eq','$not','$between',_0x76f4('0x1f'),_0x76f4('0x20'),_0x76f4('0x21'),_0x76f4('0x22'),_0x76f4('0x23'),_0x76f4('0x24'),'$notILike',_0x76f4('0x22'),'$overlap','$contains','$contained',_0x76f4('0x25')]);_0x214bef[_0x76f4('0x26')]=_[_0x76f4('0x27')](_0x38450e[_0x76f4('0x16')],qs['fields'](_0x672960[_0x76f4('0x17')]['fields']));_0x214bef[_0x76f4('0x26')]=_0x214bef[_0x76f4('0x26')][_0x76f4('0x28')]?_0x214bef[_0x76f4('0x26')]:_0x38450e[_0x76f4('0x16')];if(!_0x672960['query']['hasOwnProperty'](_0x76f4('0x29'))){_0x214bef[_0x76f4('0x7')]=qs[_0x76f4('0x7')](_0x672960[_0x76f4('0x17')][_0x76f4('0x7')]);_0x214bef[_0x76f4('0x2a')]=qs[_0x76f4('0x2a')](_0x672960[_0x76f4('0x17')][_0x76f4('0x2a')]);}_0x214bef[_0x76f4('0x2b')]=qs[_0x76f4('0x2c')](_0x672960[_0x76f4('0x17')]['sort']);_0x214bef['where']=qs['filters'](_['pick'](_0x672960[_0x76f4('0x17')],_0x38450e[_0x76f4('0x19')]),_0x397360);if(_0x672960[_0x76f4('0x17')][_0x76f4('0x2d')]){_0x214bef[_0x76f4('0x2e')]=_['merge'](_0x214bef[_0x76f4('0x2e')],{'$or':_[_0x76f4('0x11')](_0x397360,function(_0x37a233){if(_0x37a233[_0x76f4('0x15')]!==_0x76f4('0x2f')){var _0x23278f={};_0x23278f[_0x37a233[_0x76f4('0xe')]]={'$like':'%'+_0x672960[_0x76f4('0x17')][_0x76f4('0x2d')]+'%'};return _0x23278f;}})});}_0x214bef=_[_0x76f4('0x30')]({},_0x214bef,_0x672960[_0x76f4('0x31')]);var _0x244607={'where':_0x214bef[_0x76f4('0x2e')]};return db[_0x76f4('0x12')][_0x76f4('0x8')](_0x244607)[_0x76f4('0x32')](function(_0x3308e3){_0x17625e[_0x76f4('0x8')]=_0x3308e3;if(_0x672960['query'][_0x76f4('0x33')]){_0x214bef[_0x76f4('0x34')]=[{'all':!![]}];}return db[_0x76f4('0x12')]['findAll'](_0x214bef);})['then'](function(_0x237fba){_0x17625e['rows']=_0x237fba;return _0x17625e;})[_0x76f4('0x32')](respondWithFilteredResult(_0x2d4bd1,_0x214bef))['catch'](handleError(_0x2d4bd1,null));};exports[_0x76f4('0x35')]=function(_0x16f36d,_0x312243){var _0x378675={'raw':!![],'where':{'id':_0x16f36d[_0x76f4('0x36')]['id']}},_0x2c0b76={};_0x2c0b76[_0x76f4('0x16')]=_[_0x76f4('0x18')](db[_0x76f4('0x12')][_0x76f4('0x13')]);_0x2c0b76['query']=_['keys'](_0x16f36d[_0x76f4('0x17')]);_0x2c0b76[_0x76f4('0x19')]=_[_0x76f4('0x27')](_0x2c0b76[_0x76f4('0x16')],_0x2c0b76[_0x76f4('0x17')]);_0x378675[_0x76f4('0x26')]=_[_0x76f4('0x27')](_0x2c0b76[_0x76f4('0x16')],qs[_0x76f4('0x37')](_0x16f36d['query'][_0x76f4('0x37')]));_0x378675[_0x76f4('0x26')]=_0x378675['attributes']['length']?_0x378675[_0x76f4('0x26')]:_0x2c0b76[_0x76f4('0x16')];if(_0x16f36d[_0x76f4('0x17')][_0x76f4('0x33')]){_0x378675[_0x76f4('0x34')]=[{'all':!![]}];}_0x378675=_['merge']({},_0x378675,_0x16f36d[_0x76f4('0x31')]);return db[_0x76f4('0x12')][_0x76f4('0x38')](_0x378675)[_0x76f4('0x32')](handleEntityNotFound(_0x312243,null))[_0x76f4('0x32')](respondWithResult(_0x312243,null))[_0x76f4('0x39')](handleError(_0x312243,null));};exports['create']=function(_0x317c91,_0x2795db){return db[_0x76f4('0x12')]['create'](_0x317c91['body'],{})[_0x76f4('0x32')](respondWithResult(_0x2795db,0xc9))[_0x76f4('0x39')](handleError(_0x2795db,null));};exports[_0x76f4('0xb')]=function(_0x2bea6d,_0x36fa03){if(_0x2bea6d['body']['id']){delete _0x2bea6d['body']['id'];}return db[_0x76f4('0x12')]['find']({'where':{'id':_0x2bea6d[_0x76f4('0x36')]['id']}})[_0x76f4('0x32')](handleEntityNotFound(_0x36fa03,null))['then'](saveUpdates(_0x2bea6d['body'],null))[_0x76f4('0x32')](respondWithResult(_0x36fa03,null))[_0x76f4('0x39')](handleError(_0x36fa03,null));};exports[_0x76f4('0x3a')]=function(_0x217d3a,_0x55e4cc){return db[_0x76f4('0x12')][_0x76f4('0x3a')]()[_0x76f4('0x32')](respondWithResult(_0x55e4cc,null))['catch'](handleError(_0x55e4cc,null));};exports[_0x76f4('0x3b')]=function(_0x6bbcf2,_0x535eca){var _0x56d905;var _0x4ab620=_0x6bbcf2[_0x76f4('0x36')]['id'];return db[_0x76f4('0x12')][_0x76f4('0x38')]({'where':{'id':_0x6bbcf2[_0x76f4('0x36')]['id']}})['then'](handleEntityNotFound(_0x535eca,null))[_0x76f4('0x32')](function(_0x597de5){if(_0x597de5){return _0x597de5[_0x76f4('0x3b')]()[_0x76f4('0x32')](function(_0x270baf){return _0x270baf;});}})['then'](function(_0x312319){_0x56d905=_0x312319;if(_0x312319){if(_0x312319[_0x76f4('0x3c')]||_0x312319['CampaignId']){return db[_0x312319[_0x76f4('0x3c')]?_0x76f4('0x3d'):_0x76f4('0x3e')][_0x76f4('0x38')]({'where':{'id':_0x312319[_0x76f4('0x3c')]?_0x312319['VoiceQueueId']:_0x312319[_0x76f4('0x3f')]},'attributes':['id','name'],'raw':!![]});}}})[_0x76f4('0x32')](function(_0x38dc69){var _0x154ba={};if(_0x38dc69){_['merge'](_0x154ba,_[_0x76f4('0x40')](_0x56d905[_0x76f4('0x41')],[_0x76f4('0x42'),_0x76f4('0x43'),'id']));_0x154ba['state']=0x15;_0x154ba[_0x76f4('0x44')]=_0x76f4('0x45');_0x154ba[_0x76f4('0x46')]=_0x38dc69[_0x76f4('0xe')];_0x154ba['membername']=_0x6bbcf2[_0x76f4('0x47')]['name'];_0x154ba[_0x76f4('0x48')]=_0x6bbcf2[_0x76f4('0x47')]['id'];_0x154ba['deleted']=!![];_0x154ba['deletedat']=moment()[_0x76f4('0x49')](_0x76f4('0x4a'));_0x154ba[_0x76f4('0x4b')]=_0x56d905['phone'];_0x154ba[_0x76f4('0x4c')]=_0x56d905[_0x76f4('0x3c')]?_0x76f4('0x4d'):'ivr';return db['CmContact'][_0x76f4('0x38')]({'where':{'id':_0x154ba[_0x76f4('0x4e')]},'attributes':['firstName','lastName']})[_0x76f4('0x32')](function(_0x34a5d1){if(!_[_0x76f4('0x4f')](_0x535eca)&&!_[_0x76f4('0x4f')](_0x34a5d1[_0x76f4('0x50')])){_0x154ba[_0x76f4('0x51')]=_0x34a5d1[_0x76f4('0x50')];if(!_[_0x76f4('0x4f')](_0x34a5d1[_0x76f4('0x52')])){_0x154ba['calleridname']+='\x20'+_0x34a5d1['lastName'];}}})['finally'](function(){return db[_0x76f4('0x53')][_0x76f4('0x54')](_0x154ba);});}})[_0x76f4('0x32')](function(_0x3b6c16){return db['CmHopperAdditionalPhone']['destroy']({'where':{'CmHopperId':_0x4ab620}});})[_0x76f4('0x32')](function(){return _0x535eca['status'](0xcc)[_0x76f4('0x55')]();})['catch'](handleError(_0x535eca,null));};exports[_0x76f4('0x56')]=function(_0x25e510,_0x3984d3){var _0x3317a4=[];return db['CmContact'][_0x76f4('0x3a')]()[_0x76f4('0x32')](function(_0x22a0cc){_0x3317a4=_[_0x76f4('0x18')](_0x22a0cc);return _0x25e510[_0x76f4('0x47')][_0x76f4('0x57')]({'where':{'type':_0x76f4('0x58'),'dialActive':!![],'dialMethod':'preview'},'attributes':['id',_0x76f4('0x59'),_0x76f4('0x5a')],'raw':!![]});})[_0x76f4('0x32')](function(_0x320a87){if(_0x320a87&&_0x320a87[_0x76f4('0x28')]){return db[_0x76f4('0x5b')][_0x76f4('0x5c')](function(_0x551d38){var _0x5724c3={'active':![],'recallme':![],'scheduledAt':{'$lte':moment()['format'](_0x76f4('0x4a'))},'VoiceQueueId':{'$in':_[_0x76f4('0x11')](_0x320a87,'id')},'$or':[{'UserId':null},{'UserId':_0x25e510[_0x76f4('0x47')]['id']}]};var _0x5f0dc2={'active':![],'recallme':!![],'VoiceQueueId':{'$in':_(_0x320a87)[_0x76f4('0x2d')](['dialPreviewAutoRecallMe',0x0])[_0x76f4('0x11')]('id')[_0x76f4('0x5d')]()},'$or':[{'UserId':null},{'UserId':_0x25e510['user']['id']}]};var _0xda0ac2={'$or':[_0x5724c3,_0x5f0dc2]};var _0x37b7f7=[];if(_0x25e510[_0x76f4('0x5e')][_0x76f4('0x5f')]&&_0x25e510[_0x76f4('0x5e')][_0x76f4('0x5f')]===_0x76f4('0x60')){if(!_[_0x76f4('0x61')](_0x25e510[_0x76f4('0x5e')]['hopperIds'])){_0xda0ac2['id']={'$in':_0x25e510[_0x76f4('0x5e')]['hopperIds']};}_0x37b7f7=[[_0x76f4('0x62'),_0x76f4('0x63')],[_0x76f4('0x64'),_0x320a87[0x0][_0x76f4('0x59')]===_0x76f4('0x63')?_0x76f4('0x65'):_0x76f4('0x63')],db[_0x76f4('0x5b')][_0x76f4('0x66')](_0x76f4('0x67')),['id','DESC']];}else{if(!_[_0x76f4('0x61')](_0x25e510[_0x76f4('0x5e')]['hopperIds'])){_0xda0ac2['id']={'$notIn':_0x25e510[_0x76f4('0x5e')][_0x76f4('0x68')]};}_0x37b7f7=[[_0x76f4('0x62'),'DESC'],[_0x76f4('0x64'),_0x320a87[0x0][_0x76f4('0x59')]],db[_0x76f4('0x5b')]['literal'](_0x76f4('0x69')),['id',_0x76f4('0x63')]];}return db[_0x76f4('0x12')][_0x76f4('0x6a')]({'attributes':['id',_0x76f4('0x6b'),_0x76f4('0x6c'),_0x76f4('0x6d')],'where':_0xda0ac2,'order':_0x37b7f7,'transaction':_0x551d38,'lock':_0x551d38[_0x76f4('0x6e')][_0x76f4('0x6f')],'include':[{'model':db['CmContact'],'as':_0x76f4('0x70'),'attributes':_0x3317a4,'include':[{'model':db[_0x76f4('0x71')],'as':_0x76f4('0x72'),'attributes':['id',_0x76f4('0xe')]}]},{'model':db['CmList'],'as':_0x76f4('0x73'),'attributes':['id',_0x76f4('0xe')]},{'model':db[_0x76f4('0x3d')],'as':'Queue','attributes':['id',_0x76f4('0xe'),_0x76f4('0x74')]}]})[_0x76f4('0x32')](function(_0x99fbd6){if(_0x99fbd6){return _0x99fbd6[_0x76f4('0xb')]({'UserId':_0x25e510['user']['id']},{'transaction':_0x551d38});}});});}})[_0x76f4('0x32')](handleEntityNotFound(_0x3984d3,null))['then'](respondWithResult(_0x3984d3,null))[_0x76f4('0x39')](handleError(_0x3984d3,null));};exports[_0x76f4('0x75')]=function(_0x5e6df9,_0x53cb70,_0x58251e){var _0x3aa958=[];var _0x462f3e=_0x5e6df9[_0x76f4('0x36')]['id'];var _0x3e2a07=_0x5e6df9[_0x76f4('0x47')]['id'];return db[_0x76f4('0x76')]['describe']()[_0x76f4('0x32')](function(_0x1bb9b3){_0x3aa958=_[_0x76f4('0x18')](_0x1bb9b3);return db[_0x76f4('0x5b')][_0x76f4('0x5c')](function(_0x1c8973){const _0x307060={'id':_0x462f3e};return db[_0x76f4('0x12')]['findOne']({'attributes':['id',_0x76f4('0x6b'),'recallme'],'where':_0x307060,'transaction':_0x1c8973,'lock':_0x1c8973[_0x76f4('0x6e')][_0x76f4('0x6f')],'include':[{'model':db[_0x76f4('0x76')],'as':_0x76f4('0x70'),'attributes':_0x3aa958,'include':[{'model':db[_0x76f4('0x71')],'as':_0x76f4('0x72'),'attributes':['id',_0x76f4('0xe')]}]},{'model':db[_0x76f4('0x77')],'as':'List','attributes':['id',_0x76f4('0xe')]},{'model':db['VoiceQueue'],'as':'Queue','attributes':['id','name',_0x76f4('0x74')]}]})[_0x76f4('0x32')](function(_0x279040){if(_0x279040){return _0x279040[_0x76f4('0xb')]({'UserId':_0x3e2a07},{'transaction':_0x1c8973});}});});})['then'](handleEntityNotFound(_0x53cb70,null))[_0x76f4('0x32')](respondWithResult(_0x53cb70,null))[_0x76f4('0x39')](handleError(_0x53cb70,null));};exports[_0x76f4('0x78')]=function(_0x5f5c24,_0x12f16e){return _0x5f5c24[_0x76f4('0x47')][_0x76f4('0x57')]({'where':{'type':_0x76f4('0x58'),'dialActive':!![],'dialMethod':_0x76f4('0x79')},'attributes':['id'],'raw':!![]})[_0x76f4('0x32')](function(_0x3b5e15){if(_0x3b5e15&&_0x3b5e15['length']){return db[_0x76f4('0x12')][_0x76f4('0x8')]({'where':{'active':![],'recallme':![],'scheduledAt':{'$lte':moment()['format'](_0x76f4('0x4a'))},'VoiceQueueId':{'$in':_[_0x76f4('0x11')](_0x3b5e15,'id')},'$or':[{'UserId':null},{'UserId':_0x5f5c24[_0x76f4('0x47')]['id']}]}});}return 0x0;})[_0x76f4('0x32')](function(_0x36d95c){if(!_[_0x76f4('0x4f')](_0x36d95c)&&_[_0x76f4('0x7a')](_0x36d95c)){return _0x12f16e[_0x76f4('0x4')](0xc8)[_0x76f4('0x5')]({'contacts':_0x36d95c});}else{logger['error'](_0x76f4('0x7b'),_0x76f4('0x78'),0x194,_0x76f4('0x7c'));_0x12f16e[_0x76f4('0x7d')](0x194);}})['catch'](handleError(_0x12f16e,null));};exports[_0x76f4('0x7e')]=function(_0x5df706,_0x420281){var _0x4a7a98=shared[_0x76f4('0x7f')];var _0x7380f=[];_['map'](_0x4a7a98,function(_0x5a3239){_0x7380f[_0x76f4('0x80')]({'id':_0x5a3239[_0x76f4('0xe')],'name':_0x5a3239[_0x76f4('0xe')],'utcOffset':_0x5a3239['utcOffset']});});return _0x420281['status'](0xc8)[_0x76f4('0x5')]({'tz':_0x7380f});};exports[_0x76f4('0x81')]=function(_0x52453,_0x36ab57){var _0x291b87=shared[_0x76f4('0x7f')];var _0x98a269={};if(!_[_0x76f4('0x4f')](_0x291b87[_0x52453['body']['id']]))_0x98a269=_0x291b87[_0x52453['body']['id']];return _0x36ab57[_0x76f4('0x4')](0xc8)[_0x76f4('0x5')](_0x98a269);};
\ No newline at end of file