Built motion from commit a679711e.|2.6.15
[motion2.git] / server / api / voiceQueue / voiceQueue.controller.js
index 01f3fa4..300c508 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x9bfa=['undefined','limit','count','set','Content-Range','apply','reject','save','update','then','get','VoiceQueues','inbound','outbound','filter','ignore','value','includes','type','find','UserProfileResource','destroy','error','stack','name','send','rawAttributes','fieldName','model','map','query','filters','intersection','attributes','fields','hasOwnProperty','nolimit','order','sort','where','merge','includeAll','include','VoiceQueue','findAll','rows','catch','show','params','keys','length','options','create','body','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','user','UserProfileSection','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','clone','createdAt','updatedAt','QueueCampaigns','findOne','CmHopper','VoiceQueueId','CmHopperHistory','pick','getHopperFinals','CmHopperFinal','getHopperBlacks','CmHopperBlack','getTeams','Team','Agents','online','voicePause','penalty','transaction','each','upsert','UserVoiceQueue','findOrCreate','UserVoiceQueueRt','isNil','format','SIP/%s','interface','emit','removeTeams','User','select','field','tq.TeamId','from','team_has_voice_queues','join','user_has_teams','ut.TeamId\x20=\x20tq.TeamId','toString','sequelize','every','TeamId','compact','ids','isEmpty','removeAgents','forEach','userVoiceQueue:remove','addAgents','omit','spread','userVoiceQueue:save','push','all','isArray','getAgents','getMembers','CmList','getLists','addLists','dialCheckDuplicateType','insert','into','cm_hopper','fromQuery','phone','scheduledAt','ContactId','NOW()','CmListId','ListId\x20=\x20?','phone\x20IS\x20NOT\x20NULL','phone\x20NOT\x20IN\x20(?)','COALESCE(calleridnum,\x27\x27)','VoiceQueueId\x20=\x20?','onlyIfOpen','ListId','cm_contacts','removeLists','getBlackLists','addBlackLists','cm_hopper_black','deletedAt\x20IS\x20NULL','removeBlackLists','eml-format','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','to-csv','ejs','fs-extra','lodash','squel','jsforce','desk.js','querystring','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','defaults','redis','localhost','./voiceQueue.socket','register','sendStatus','end','status','json','offset'];(function(_0x7e2eb0,_0x17cd58){var _0xd92de4=function(_0x5d005b){while(--_0x5d005b){_0x7e2eb0['push'](_0x7e2eb0['shift']());}};_0xd92de4(++_0x17cd58);}(_0x9bfa,0x93));var _0xa9bf=function(_0x47ef62,_0x2f36a3){_0x47ef62=_0x47ef62-0x0;var _0x229ab6=_0x9bfa[_0x47ef62];return _0x229ab6;};'use strict';var emlformat=require(_0xa9bf('0x0'));var rimraf=require('rimraf');var zipdir=require(_0xa9bf('0x1'));var jsonpatch=require(_0xa9bf('0x2'));var rp=require(_0xa9bf('0x3'));var moment=require(_0xa9bf('0x4'));var BPromise=require(_0xa9bf('0x5'));var Mustache=require(_0xa9bf('0x6'));var util=require(_0xa9bf('0x7'));var path=require(_0xa9bf('0x8'));var sox=require('sox');var csv=require(_0xa9bf('0x9'));var ejs=require(_0xa9bf('0xa'));var fs=require('fs');var fs_extra=require(_0xa9bf('0xb'));var _=require(_0xa9bf('0xc'));var squel=require(_0xa9bf('0xd'));var crypto=require('crypto');var jsforce=require(_0xa9bf('0xe'));var deskjs=require(_0xa9bf('0xf'));var toCsv=require(_0xa9bf('0x9'));var querystring=require(_0xa9bf('0x10'));var Papa=require(_0xa9bf('0x11'));var Redis=require(_0xa9bf('0x12'));var authService=require('../../components/auth/service');var qs=require(_0xa9bf('0x13'));var as=require(_0xa9bf('0x14'));var hardwareService=require(_0xa9bf('0x15'));var logger=require(_0xa9bf('0x16'))(_0xa9bf('0x17'));var utils=require(_0xa9bf('0x18'));var config=require(_0xa9bf('0x19'));var licenseUtil=require(_0xa9bf('0x1a'));var db=require(_0xa9bf('0x1b'))['db'];config['redis']=_[_0xa9bf('0x1c')](config[_0xa9bf('0x1d')],{'host':_0xa9bf('0x1e'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config['redis']));require(_0xa9bf('0x1f'))[_0xa9bf('0x20')](socket);function respondWithStatusCode(_0x2d0510,_0x492c8b){_0x492c8b=_0x492c8b||0xcc;return function(_0x33b9f7){if(_0x33b9f7){return _0x2d0510[_0xa9bf('0x21')](_0x492c8b);}return _0x2d0510['status'](_0x492c8b)[_0xa9bf('0x22')]();};}function respondWithResult(_0x2cd06b,_0x25c23c){_0x25c23c=_0x25c23c||0xc8;return function(_0x445b75){if(_0x445b75){return _0x2cd06b[_0xa9bf('0x23')](_0x25c23c)[_0xa9bf('0x24')](_0x445b75);}};}function respondWithFilteredResult(_0x277751,_0x4b6616){return function(_0x32c7bc){if(_0x32c7bc){var _0x1791df=typeof _0x4b6616[_0xa9bf('0x25')]===_0xa9bf('0x26')&&typeof _0x4b6616[_0xa9bf('0x27')]==='undefined';var _0x1e5ab4=_0x32c7bc[_0xa9bf('0x28')];var _0x1e3d71=_0x1791df?0x0:_0x4b6616[_0xa9bf('0x25')];var _0x490b03=_0x1791df?_0x32c7bc[_0xa9bf('0x28')]:_0x4b6616[_0xa9bf('0x25')]+_0x4b6616['limit'];var _0x2866d6;if(_0x490b03>=_0x1e5ab4){_0x490b03=_0x1e5ab4;_0x2866d6=0xc8;}else{_0x2866d6=0xce;}_0x277751[_0xa9bf('0x23')](_0x2866d6);return _0x277751[_0xa9bf('0x29')](_0xa9bf('0x2a'),_0x1e3d71+'-'+_0x490b03+'/'+_0x1e5ab4)[_0xa9bf('0x24')](_0x32c7bc);}return null;};}function patchUpdates(_0x5e36d2){return function(_0x235404){try{jsonpatch[_0xa9bf('0x2b')](_0x235404,_0x5e36d2,!![]);}catch(_0x4b4ecb){return BPromise[_0xa9bf('0x2c')](_0x4b4ecb);}return _0x235404[_0xa9bf('0x2d')]();};}function saveUpdates(_0x50f433,_0x3e0c79){return function(_0x32730d){if(_0x32730d){return _0x32730d[_0xa9bf('0x2e')](_0x50f433)[_0xa9bf('0x2f')](function(_0x308919){return _0x308919;});}return null;};}function removeEntity(_0x29e77f,_0x301438){return function(_0x507f9e){if(_0x507f9e){return _0x507f9e['destroy']()[_0xa9bf('0x2f')](function(){var _0x2dcd8d=_0x507f9e[_0xa9bf('0x30')]({'plain':!![]});var _0x2a04a2=[{'name':_0xa9bf('0x31'),'value':_0xa9bf('0x32'),'ignore':![]},{'name':'QueueCampaigns','value':_0xa9bf('0x33'),'ignore':![]}];var _0x4b0ab5=_(_0x2a04a2)[_0xa9bf('0x34')](_0xa9bf('0x35'))['map'](_0xa9bf('0x36'))[_0xa9bf('0x36')]();if(_[_0xa9bf('0x37')](_0x4b0ab5,_0x2dcd8d[_0xa9bf('0x38')])){return;}var _0x1626a4=_[_0xa9bf('0x39')](_0x2a04a2,[_0xa9bf('0x36'),_0x2dcd8d[_0xa9bf('0x38')]])['name'];return db[_0xa9bf('0x3a')][_0xa9bf('0x3b')]({'where':{'type':_0x1626a4,'resourceId':_0x2dcd8d['id']}})['then'](function(){return _0x507f9e;});})['then'](function(){_0x29e77f['status'](0xcc)[_0xa9bf('0x22')]();});}};}function handleEntityNotFound(_0x2deb73,_0x4f42e8){return function(_0x487d92){if(!_0x487d92){_0x2deb73[_0xa9bf('0x21')](0x194);}return _0x487d92;};}function handleError(_0x1be952,_0xab7f8d){_0xab7f8d=_0xab7f8d||0x1f4;return function(_0x5e89f5){logger[_0xa9bf('0x3c')](_0x5e89f5[_0xa9bf('0x3d')]);if(_0x5e89f5[_0xa9bf('0x3e')]){delete _0x5e89f5[_0xa9bf('0x3e')];}_0x1be952[_0xa9bf('0x23')](_0xab7f8d)[_0xa9bf('0x3f')](_0x5e89f5);};}exports['index']=function(_0x25670d,_0x3ec33d){var _0x19f4b={},_0x597f4f={},_0x325b95={'count':0x0,'rows':[]};var _0x42a6d0=_['map'](db['VoiceQueue'][_0xa9bf('0x40')],function(_0x41c7b6){return{'name':_0x41c7b6[_0xa9bf('0x41')],'type':_0x41c7b6[_0xa9bf('0x38')]['key']};});_0x597f4f[_0xa9bf('0x42')]=_[_0xa9bf('0x43')](_0x42a6d0,_0xa9bf('0x3e'));_0x597f4f['query']=_['keys'](_0x25670d[_0xa9bf('0x44')]);_0x597f4f[_0xa9bf('0x45')]=_[_0xa9bf('0x46')](_0x597f4f[_0xa9bf('0x42')],_0x597f4f[_0xa9bf('0x44')]);_0x19f4b[_0xa9bf('0x47')]=_[_0xa9bf('0x46')](_0x597f4f[_0xa9bf('0x42')],qs[_0xa9bf('0x48')](_0x25670d[_0xa9bf('0x44')]['fields']));_0x19f4b[_0xa9bf('0x47')]=_0x19f4b[_0xa9bf('0x47')]['length']?_0x19f4b['attributes']:_0x597f4f[_0xa9bf('0x42')];if(!_0x25670d[_0xa9bf('0x44')][_0xa9bf('0x49')](_0xa9bf('0x4a'))){_0x19f4b[_0xa9bf('0x27')]=qs[_0xa9bf('0x27')](_0x25670d[_0xa9bf('0x44')][_0xa9bf('0x27')]);_0x19f4b['offset']=qs[_0xa9bf('0x25')](_0x25670d['query'][_0xa9bf('0x25')]);}_0x19f4b[_0xa9bf('0x4b')]=qs[_0xa9bf('0x4c')](_0x25670d[_0xa9bf('0x44')]['sort']);_0x19f4b[_0xa9bf('0x4d')]=qs[_0xa9bf('0x45')](_['pick'](_0x25670d[_0xa9bf('0x44')],_0x597f4f[_0xa9bf('0x45')]),_0x42a6d0);if(_0x25670d[_0xa9bf('0x44')][_0xa9bf('0x34')]){_0x19f4b[_0xa9bf('0x4d')]=_['merge'](_0x19f4b[_0xa9bf('0x4d')],{'$or':_[_0xa9bf('0x43')](_0x42a6d0,function(_0x112277){if(_0x112277['type']!=='VIRTUAL'){var _0x54dbc2={};_0x54dbc2[_0x112277['name']]={'$like':'%'+_0x25670d[_0xa9bf('0x44')]['filter']+'%'};return _0x54dbc2;}})});}_0x19f4b=_[_0xa9bf('0x4e')]({},_0x19f4b,_0x25670d['options']);var _0x3902d6={'where':_0x19f4b['where']};return db['VoiceQueue'][_0xa9bf('0x28')](_0x3902d6)['then'](function(_0x531787){_0x325b95['count']=_0x531787;if(_0x25670d[_0xa9bf('0x44')][_0xa9bf('0x4f')]){_0x19f4b[_0xa9bf('0x50')]=[{'all':!![]}];}return db[_0xa9bf('0x51')][_0xa9bf('0x52')](_0x19f4b);})[_0xa9bf('0x2f')](function(_0x489a1c){_0x325b95[_0xa9bf('0x53')]=_0x489a1c;return _0x325b95;})['then'](respondWithFilteredResult(_0x3ec33d,_0x19f4b))[_0xa9bf('0x54')](handleError(_0x3ec33d,null));};exports[_0xa9bf('0x55')]=function(_0x3f5980,_0x2e9371){var _0x2789f1={'raw':![],'where':{'id':_0x3f5980[_0xa9bf('0x56')]['id']}},_0x595b38={};_0x595b38[_0xa9bf('0x42')]=_['keys'](db['VoiceQueue'][_0xa9bf('0x40')]);_0x595b38[_0xa9bf('0x44')]=_[_0xa9bf('0x57')](_0x3f5980[_0xa9bf('0x44')]);_0x595b38[_0xa9bf('0x45')]=_[_0xa9bf('0x46')](_0x595b38['model'],_0x595b38[_0xa9bf('0x44')]);_0x2789f1['attributes']=_[_0xa9bf('0x46')](_0x595b38[_0xa9bf('0x42')],qs[_0xa9bf('0x48')](_0x3f5980[_0xa9bf('0x44')][_0xa9bf('0x48')]));_0x2789f1[_0xa9bf('0x47')]=_0x2789f1[_0xa9bf('0x47')][_0xa9bf('0x58')]?_0x2789f1['attributes']:_0x595b38[_0xa9bf('0x42')];if(_0x3f5980['query']['includeAll']){_0x2789f1[_0xa9bf('0x50')]=[{'all':!![]}];}_0x2789f1=_[_0xa9bf('0x4e')]({},_0x2789f1,_0x3f5980[_0xa9bf('0x59')]);return db[_0xa9bf('0x51')]['find'](_0x2789f1)[_0xa9bf('0x2f')](handleEntityNotFound(_0x2e9371,null))['then'](respondWithResult(_0x2e9371,null))['catch'](handleError(_0x2e9371,null));};exports[_0xa9bf('0x5a')]=function(_0x2eadf4,_0xb0b37){return db[_0xa9bf('0x51')][_0xa9bf('0x5a')](_0x2eadf4[_0xa9bf('0x5b')],{})[_0xa9bf('0x2f')](function(_0x38636f){var _0x2364a5=_0x2eadf4['user'][_0xa9bf('0x30')]({'plain':!![]});if(!_0x2364a5)throw new Error(_0xa9bf('0x5c'));if(_0x2364a5[_0xa9bf('0x5d')]===_0xa9bf('0x5e')){var _0x12ba63=_0x38636f[_0xa9bf('0x30')]({'plain':!![]});var _0x466850=[{'name':_0xa9bf('0x31'),'value':'inbound'},{'name':'QueueCampaigns','value':_0xa9bf('0x33')}];var _0x5277ee=_[_0xa9bf('0x39')](_0x466850,['value',_0x12ba63[_0xa9bf('0x38')]])[_0xa9bf('0x3e')];return db[_0xa9bf('0x5f')][_0xa9bf('0x39')]({'where':{'name':_0x5277ee,'userProfileId':_0x2364a5[_0xa9bf('0x60')]},'raw':!![]})['then'](function(_0x3e2557){if(_0x3e2557&&_0x3e2557[_0xa9bf('0x61')]===0x0){return db['UserProfileResource'][_0xa9bf('0x5a')]({'name':_0x12ba63[_0xa9bf('0x3e')],'resourceId':_0x12ba63['id'],'type':_0x3e2557[_0xa9bf('0x3e')],'sectionId':_0x3e2557['id']},{})[_0xa9bf('0x2f')](function(){return _0x38636f;});}else{return _0x38636f;}})['catch'](function(_0x82176f){logger[_0xa9bf('0x3c')](_0xa9bf('0x62'),_0x82176f);throw _0x82176f;});}return _0x38636f;})['then'](respondWithResult(_0xb0b37,0xc9))[_0xa9bf('0x54')](handleError(_0xb0b37,null));};exports[_0xa9bf('0x63')]=function(_0x21b02d,_0x537c48){var _0x539df6={'where':{'id':_0x21b02d['params']['id']}},_0x5604ac={};_0x5604ac[_0xa9bf('0x42')]=_[_0xa9bf('0x57')](db[_0xa9bf('0x51')][_0xa9bf('0x40')]);_0x539df6[_0xa9bf('0x47')]=_[_0xa9bf('0x46')](_0x5604ac['model'],qs['fields'](_0x21b02d[_0xa9bf('0x44')]['fields']));_0x539df6[_0xa9bf('0x47')]=_0x539df6[_0xa9bf('0x47')][_0xa9bf('0x58')]?_0x539df6['attributes']:_0x5604ac['model'];if(_0x21b02d['query'][_0xa9bf('0x4f')]){_0x539df6['include']=[{'all':!![]}];}_0x539df6=_[_0xa9bf('0x4e')]({},_0x539df6,_0x21b02d[_0xa9bf('0x59')]);return db['VoiceQueue'][_0xa9bf('0x39')](_0x539df6)['then'](handleEntityNotFound(_0x537c48,null))[_0xa9bf('0x2f')](function(_0x585a28){if(_0x585a28){var _0x52189e=_0x585a28[_0xa9bf('0x30')]({'plain':!![]});_0x52189e=qs['omit'](_0x52189e,['id',_0xa9bf('0x64'),_0xa9bf('0x65')]);_0x21b02d[_0xa9bf('0x5b')]=_['omit'](_0x21b02d[_0xa9bf('0x5b')],['id','createdAt',_0xa9bf('0x65')]);return db['VoiceQueue'][_0xa9bf('0x5a')](_['merge'](_0x52189e,_0x21b02d[_0xa9bf('0x5b')]),{'include':_0x21b02d[_0xa9bf('0x44')][_0xa9bf('0x4f')]?[{'all':!![]}]:undefined})[_0xa9bf('0x2f')](function(_0x560eb7){var _0x3b1ab5=_0x21b02d[_0xa9bf('0x5e')][_0xa9bf('0x30')]({'plain':!![]});if(!_0x3b1ab5)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x3b1ab5[_0xa9bf('0x5d')]===_0xa9bf('0x5e')){var _0x343e79=_0x560eb7[_0xa9bf('0x30')]({'plain':!![]});var _0x4a1e61=[{'name':'VoiceQueues','value':_0xa9bf('0x32')},{'name':_0xa9bf('0x66'),'value':_0xa9bf('0x33')}];var _0x5e42c9=_[_0xa9bf('0x39')](_0x4a1e61,[_0xa9bf('0x36'),_0x343e79['type']])['name'];return db[_0xa9bf('0x5f')][_0xa9bf('0x39')]({'where':{'name':_0x5e42c9,'userProfileId':_0x3b1ab5[_0xa9bf('0x60')]},'raw':!![]})[_0xa9bf('0x2f')](function(_0x32b41e){if(_0x32b41e&&_0x32b41e[_0xa9bf('0x61')]===0x0){return db[_0xa9bf('0x3a')]['create']({'name':_0x343e79[_0xa9bf('0x3e')],'resourceId':_0x343e79['id'],'type':_0x32b41e['name'],'sectionId':_0x32b41e['id']},{})['then'](function(){return _0x560eb7;});}else{return _0x560eb7;}})['catch'](function(_0x2167c9){logger['error'](_0xa9bf('0x62'),_0x2167c9);throw _0x2167c9;});}return _0x560eb7;});}})[_0xa9bf('0x2f')](respondWithResult(_0x537c48,0xc9))[_0xa9bf('0x54')](handleError(_0x537c48,null));};exports[_0xa9bf('0x2e')]=function(_0x352439,_0x2739c6){if(_0x352439['body']['id']){delete _0x352439[_0xa9bf('0x5b')]['id'];}return db[_0xa9bf('0x51')]['find']({'where':{'id':_0x352439[_0xa9bf('0x56')]['id']}})['then'](handleEntityNotFound(_0x2739c6,null))[_0xa9bf('0x2f')](saveUpdates(_0x352439[_0xa9bf('0x5b')],null))[_0xa9bf('0x2f')](respondWithResult(_0x2739c6,null))[_0xa9bf('0x54')](handleError(_0x2739c6,null));};exports[_0xa9bf('0x3b')]=function(_0x3c20f4,_0x387f0d){return db[_0xa9bf('0x51')]['find']({'where':{'id':_0x3c20f4[_0xa9bf('0x56')]['id']}})[_0xa9bf('0x2f')](handleEntityNotFound(_0x387f0d,null))['then'](removeEntity(_0x387f0d,null))[_0xa9bf('0x54')](handleError(_0x387f0d,null));};exports['getHoppers']=function(_0x4279fe,_0x3b4ae3,_0x15f635){var _0x74cfd={'raw':![],'where':{}};var _0x1f79e9={};var _0x39d22e={'count':0x0,'rows':[]};return db['VoiceQueue'][_0xa9bf('0x67')]({'where':{'id':_0x4279fe[_0xa9bf('0x56')]['id']}})[_0xa9bf('0x2f')](handleEntityNotFound(_0x3b4ae3,null))['then'](function(_0x5152c6){if(_0x5152c6){_0x1f79e9[_0xa9bf('0x42')]=_[_0xa9bf('0x57')](db[_0xa9bf('0x68')][_0xa9bf('0x40')]);_0x1f79e9[_0xa9bf('0x44')]=_[_0xa9bf('0x57')](_0x4279fe['query']);_0x1f79e9[_0xa9bf('0x45')]=_['intersection'](_0x1f79e9[_0xa9bf('0x42')],_0x1f79e9[_0xa9bf('0x44')]);_0x74cfd['attributes']=_[_0xa9bf('0x46')](_0x1f79e9['model'],qs['fields'](_0x4279fe['query']['fields']));_0x74cfd['attributes']=_0x74cfd[_0xa9bf('0x47')]['length']?_0x74cfd[_0xa9bf('0x47')]:_0x1f79e9['model'];if(!_0x4279fe[_0xa9bf('0x44')]['hasOwnProperty'](_0xa9bf('0x4a'))){_0x74cfd[_0xa9bf('0x27')]=qs[_0xa9bf('0x27')](_0x4279fe[_0xa9bf('0x44')]['limit']);_0x74cfd[_0xa9bf('0x25')]=qs[_0xa9bf('0x25')](_0x4279fe[_0xa9bf('0x44')][_0xa9bf('0x25')]);}_0x74cfd['order']=qs[_0xa9bf('0x4c')](_0x4279fe[_0xa9bf('0x44')][_0xa9bf('0x4c')]);_0x74cfd[_0xa9bf('0x4d')]=qs[_0xa9bf('0x45')](_['pick'](_0x4279fe[_0xa9bf('0x44')],_0x1f79e9[_0xa9bf('0x45')]));_0x74cfd[_0xa9bf('0x4d')][_0xa9bf('0x69')]=_0x5152c6['id'];if(_0x4279fe[_0xa9bf('0x44')][_0xa9bf('0x34')]){_0x74cfd[_0xa9bf('0x4d')]=_['merge'](_0x74cfd[_0xa9bf('0x4d')],{'$or':_[_0xa9bf('0x43')](_0x74cfd['attributes'],function(_0x4fb793){var _0x3d6c69={};_0x3d6c69[_0x4fb793]={'$like':'%'+_0x4279fe[_0xa9bf('0x44')][_0xa9bf('0x34')]+'%'};return _0x3d6c69;})});}_0x74cfd=_[_0xa9bf('0x4e')]({},_0x74cfd,_0x4279fe[_0xa9bf('0x59')]);return db[_0xa9bf('0x68')][_0xa9bf('0x28')]({'where':_0x74cfd['where']})[_0xa9bf('0x2f')](function(_0x5dcc4c){_0x39d22e[_0xa9bf('0x28')]=_0x5dcc4c;if(_0x4279fe[_0xa9bf('0x44')][_0xa9bf('0x4f')]){_0x74cfd[_0xa9bf('0x50')]=[{'all':!![]}];}return db['CmHopper'][_0xa9bf('0x52')](_0x74cfd);})[_0xa9bf('0x2f')](function(_0x3f8fa8){_0x39d22e[_0xa9bf('0x53')]=_0x3f8fa8;return _0x39d22e;});}})['then'](respondWithFilteredResult(_0x3b4ae3,_0x74cfd))[_0xa9bf('0x54')](handleError(_0x3b4ae3,null));};exports['getHopperHistories']=function(_0x8a8ac8,_0x303468,_0x50414a){var _0x3a11e1={'raw':!![],'where':{}};var _0x2823d3={};var _0x2ce2dc={'count':0x0,'rows':[]};return db[_0xa9bf('0x51')][_0xa9bf('0x67')]({'where':{'id':_0x8a8ac8['params']['id']}})[_0xa9bf('0x2f')](handleEntityNotFound(_0x303468,null))['then'](function(_0x3fdb8a){if(_0x3fdb8a){_0x2823d3[_0xa9bf('0x42')]=_[_0xa9bf('0x57')](db[_0xa9bf('0x6a')][_0xa9bf('0x40')]);_0x2823d3[_0xa9bf('0x44')]=_[_0xa9bf('0x57')](_0x8a8ac8[_0xa9bf('0x44')]);_0x2823d3[_0xa9bf('0x45')]=_[_0xa9bf('0x46')](_0x2823d3[_0xa9bf('0x42')],_0x2823d3[_0xa9bf('0x44')]);_0x3a11e1[_0xa9bf('0x47')]=_['intersection'](_0x2823d3[_0xa9bf('0x42')],qs[_0xa9bf('0x48')](_0x8a8ac8[_0xa9bf('0x44')][_0xa9bf('0x48')]));_0x3a11e1[_0xa9bf('0x47')]=_0x3a11e1[_0xa9bf('0x47')][_0xa9bf('0x58')]?_0x3a11e1[_0xa9bf('0x47')]:_0x2823d3[_0xa9bf('0x42')];if(!_0x8a8ac8[_0xa9bf('0x44')][_0xa9bf('0x49')](_0xa9bf('0x4a'))){_0x3a11e1['limit']=qs[_0xa9bf('0x27')](_0x8a8ac8[_0xa9bf('0x44')][_0xa9bf('0x27')]);_0x3a11e1[_0xa9bf('0x25')]=qs['offset'](_0x8a8ac8[_0xa9bf('0x44')][_0xa9bf('0x25')]);}_0x3a11e1[_0xa9bf('0x4b')]=qs['sort'](_0x8a8ac8[_0xa9bf('0x44')][_0xa9bf('0x4c')]);_0x3a11e1[_0xa9bf('0x4d')]=qs[_0xa9bf('0x45')](_[_0xa9bf('0x6b')](_0x8a8ac8['query'],_0x2823d3['filters']));_0x3a11e1[_0xa9bf('0x4d')][_0xa9bf('0x69')]=_0x3fdb8a['id'];if(_0x8a8ac8[_0xa9bf('0x44')][_0xa9bf('0x34')]){_0x3a11e1[_0xa9bf('0x4d')]=_[_0xa9bf('0x4e')](_0x3a11e1['where'],{'$or':_[_0xa9bf('0x43')](_0x3a11e1[_0xa9bf('0x47')],function(_0x7c90d6){var _0x984dd8={};_0x984dd8[_0x7c90d6]={'$like':'%'+_0x8a8ac8[_0xa9bf('0x44')][_0xa9bf('0x34')]+'%'};return _0x984dd8;})});}_0x3a11e1=_[_0xa9bf('0x4e')]({},_0x3a11e1,_0x8a8ac8[_0xa9bf('0x59')]);return db[_0xa9bf('0x6a')][_0xa9bf('0x28')]({'where':_0x3a11e1[_0xa9bf('0x4d')]})[_0xa9bf('0x2f')](function(_0x508a30){_0x2ce2dc[_0xa9bf('0x28')]=_0x508a30;if(_0x8a8ac8[_0xa9bf('0x44')][_0xa9bf('0x4f')]){_0x3a11e1[_0xa9bf('0x50')]=[{'all':!![]}];}return db[_0xa9bf('0x6a')][_0xa9bf('0x52')](_0x3a11e1);})[_0xa9bf('0x2f')](function(_0x11b6f3){_0x2ce2dc[_0xa9bf('0x53')]=_0x11b6f3;return _0x2ce2dc;});}})[_0xa9bf('0x2f')](respondWithFilteredResult(_0x303468,_0x3a11e1))[_0xa9bf('0x54')](handleError(_0x303468,null));};exports[_0xa9bf('0x6c')]=function(_0x54ae13,_0x3ccf20,_0xc6b3d7){var _0x342112={'raw':!![],'where':{}};var _0x28494a={};var _0x45f839={'count':0x0,'rows':[]};return db[_0xa9bf('0x51')][_0xa9bf('0x67')]({'where':{'id':_0x54ae13[_0xa9bf('0x56')]['id']}})[_0xa9bf('0x2f')](handleEntityNotFound(_0x3ccf20,null))[_0xa9bf('0x2f')](function(_0x10ec47){if(_0x10ec47){_0x28494a[_0xa9bf('0x42')]=_[_0xa9bf('0x57')](db[_0xa9bf('0x6d')][_0xa9bf('0x40')]);_0x28494a['query']=_[_0xa9bf('0x57')](_0x54ae13[_0xa9bf('0x44')]);_0x28494a[_0xa9bf('0x45')]=_[_0xa9bf('0x46')](_0x28494a[_0xa9bf('0x42')],_0x28494a[_0xa9bf('0x44')]);_0x342112[_0xa9bf('0x47')]=_[_0xa9bf('0x46')](_0x28494a[_0xa9bf('0x42')],qs[_0xa9bf('0x48')](_0x54ae13[_0xa9bf('0x44')][_0xa9bf('0x48')]));_0x342112['attributes']=_0x342112[_0xa9bf('0x47')][_0xa9bf('0x58')]?_0x342112[_0xa9bf('0x47')]:_0x28494a[_0xa9bf('0x42')];if(!_0x54ae13[_0xa9bf('0x44')][_0xa9bf('0x49')](_0xa9bf('0x4a'))){_0x342112[_0xa9bf('0x27')]=qs['limit'](_0x54ae13[_0xa9bf('0x44')][_0xa9bf('0x27')]);_0x342112[_0xa9bf('0x25')]=qs['offset'](_0x54ae13[_0xa9bf('0x44')][_0xa9bf('0x25')]);}_0x342112[_0xa9bf('0x4b')]=qs[_0xa9bf('0x4c')](_0x54ae13['query'][_0xa9bf('0x4c')]);_0x342112[_0xa9bf('0x4d')]=qs[_0xa9bf('0x45')](_[_0xa9bf('0x6b')](_0x54ae13[_0xa9bf('0x44')],_0x28494a[_0xa9bf('0x45')]));_0x342112[_0xa9bf('0x4d')][_0xa9bf('0x69')]=_0x10ec47['id'];if(_0x54ae13[_0xa9bf('0x44')]['filter']){_0x342112[_0xa9bf('0x4d')]=_[_0xa9bf('0x4e')](_0x342112[_0xa9bf('0x4d')],{'$or':_['map'](_0x342112['attributes'],function(_0xe252fc){var _0x3f9847={};_0x3f9847[_0xe252fc]={'$like':'%'+_0x54ae13[_0xa9bf('0x44')][_0xa9bf('0x34')]+'%'};return _0x3f9847;})});}_0x342112=_[_0xa9bf('0x4e')]({},_0x342112,_0x54ae13[_0xa9bf('0x59')]);return db[_0xa9bf('0x6d')][_0xa9bf('0x28')]({'where':_0x342112[_0xa9bf('0x4d')]})['then'](function(_0x20443f){_0x45f839[_0xa9bf('0x28')]=_0x20443f;if(_0x54ae13['query'][_0xa9bf('0x4f')]){_0x342112['include']=[{'all':!![]}];}return db[_0xa9bf('0x6d')][_0xa9bf('0x52')](_0x342112);})[_0xa9bf('0x2f')](function(_0x49516d){_0x45f839[_0xa9bf('0x53')]=_0x49516d;return _0x45f839;});}})[_0xa9bf('0x2f')](respondWithFilteredResult(_0x3ccf20,_0x342112))[_0xa9bf('0x54')](handleError(_0x3ccf20,null));};exports[_0xa9bf('0x6e')]=function(_0x89648d,_0x43df3b,_0x2fee9e){var _0x58ef53={'raw':!![],'where':{}};var _0x545a94={};var _0x49965b={'count':0x0,'rows':[]};return db['VoiceQueue'][_0xa9bf('0x67')]({'where':{'id':_0x89648d['params']['id']}})[_0xa9bf('0x2f')](handleEntityNotFound(_0x43df3b,null))[_0xa9bf('0x2f')](function(_0x5c524b){if(_0x5c524b){_0x545a94[_0xa9bf('0x42')]=_[_0xa9bf('0x57')](db[_0xa9bf('0x6f')]['rawAttributes']);_0x545a94[_0xa9bf('0x44')]=_['keys'](_0x89648d[_0xa9bf('0x44')]);_0x545a94['filters']=_[_0xa9bf('0x46')](_0x545a94[_0xa9bf('0x42')],_0x545a94[_0xa9bf('0x44')]);_0x58ef53[_0xa9bf('0x47')]=_[_0xa9bf('0x46')](_0x545a94[_0xa9bf('0x42')],qs[_0xa9bf('0x48')](_0x89648d[_0xa9bf('0x44')][_0xa9bf('0x48')]));_0x58ef53['attributes']=_0x58ef53['attributes'][_0xa9bf('0x58')]?_0x58ef53[_0xa9bf('0x47')]:_0x545a94[_0xa9bf('0x42')];if(!_0x89648d[_0xa9bf('0x44')][_0xa9bf('0x49')](_0xa9bf('0x4a'))){_0x58ef53[_0xa9bf('0x27')]=qs[_0xa9bf('0x27')](_0x89648d['query'][_0xa9bf('0x27')]);_0x58ef53[_0xa9bf('0x25')]=qs['offset'](_0x89648d['query'][_0xa9bf('0x25')]);}_0x58ef53[_0xa9bf('0x4b')]=qs[_0xa9bf('0x4c')](_0x89648d['query'][_0xa9bf('0x4c')]);_0x58ef53[_0xa9bf('0x4d')]=qs[_0xa9bf('0x45')](_['pick'](_0x89648d['query'],_0x545a94['filters']));_0x58ef53['where'][_0xa9bf('0x69')]=_0x5c524b['id'];if(_0x89648d[_0xa9bf('0x44')][_0xa9bf('0x34')]){_0x58ef53[_0xa9bf('0x4d')]=_[_0xa9bf('0x4e')](_0x58ef53[_0xa9bf('0x4d')],{'$or':_[_0xa9bf('0x43')](_0x58ef53[_0xa9bf('0x47')],function(_0x1e56a8){var _0x1d5819={};_0x1d5819[_0x1e56a8]={'$like':'%'+_0x89648d[_0xa9bf('0x44')]['filter']+'%'};return _0x1d5819;})});}_0x58ef53=_['merge']({},_0x58ef53,_0x89648d[_0xa9bf('0x59')]);return db[_0xa9bf('0x6f')][_0xa9bf('0x28')]({'where':_0x58ef53[_0xa9bf('0x4d')]})[_0xa9bf('0x2f')](function(_0x4e5030){_0x49965b['count']=_0x4e5030;if(_0x89648d[_0xa9bf('0x44')]['includeAll']){_0x58ef53[_0xa9bf('0x50')]=[{'all':!![]}];}return db[_0xa9bf('0x6f')][_0xa9bf('0x52')](_0x58ef53);})[_0xa9bf('0x2f')](function(_0x12b106){_0x49965b['rows']=_0x12b106;return _0x49965b;});}})[_0xa9bf('0x2f')](respondWithFilteredResult(_0x43df3b,_0x58ef53))[_0xa9bf('0x54')](handleError(_0x43df3b,null));};exports['getTeams']=function(_0x237988,_0x32b410,_0x3c88bc){var _0x533500={};var _0x52996a={};var _0x5f17ac;var _0x15df01;return db[_0xa9bf('0x51')][_0xa9bf('0x67')]({'where':{'id':_0x237988[_0xa9bf('0x56')]['id']}})[_0xa9bf('0x2f')](handleEntityNotFound(_0x32b410,null))['then'](function(_0xd54fb6){if(_0xd54fb6){_0x5f17ac=_0xd54fb6;_0x52996a[_0xa9bf('0x42')]=_[_0xa9bf('0x57')](db['Team']['rawAttributes']);_0x52996a[_0xa9bf('0x44')]=_[_0xa9bf('0x57')](_0x237988[_0xa9bf('0x44')]);_0x52996a[_0xa9bf('0x45')]=_[_0xa9bf('0x46')](_0x52996a[_0xa9bf('0x42')],_0x52996a[_0xa9bf('0x44')]);_0x533500['attributes']=_[_0xa9bf('0x46')](_0x52996a['model'],qs[_0xa9bf('0x48')](_0x237988[_0xa9bf('0x44')][_0xa9bf('0x48')]));_0x533500['attributes']=_0x533500['attributes'][_0xa9bf('0x58')]?_0x533500[_0xa9bf('0x47')]:_0x52996a[_0xa9bf('0x42')];_0x533500[_0xa9bf('0x4b')]=qs['sort'](_0x237988['query'][_0xa9bf('0x4c')]);_0x533500[_0xa9bf('0x4d')]=qs[_0xa9bf('0x45')](_[_0xa9bf('0x6b')](_0x237988[_0xa9bf('0x44')],_0x52996a['filters']));if(_0x237988['query'][_0xa9bf('0x34')]){_0x533500[_0xa9bf('0x4d')]=_[_0xa9bf('0x4e')](_0x533500['where'],{'$or':_[_0xa9bf('0x43')](_0x533500['attributes'],function(_0x4f292a){var _0x2e7287={};_0x2e7287[_0x4f292a]={'$like':'%'+_0x237988[_0xa9bf('0x44')][_0xa9bf('0x34')]+'%'};return _0x2e7287;})});}_0x533500=_[_0xa9bf('0x4e')]({},_0x533500,_0x237988[_0xa9bf('0x59')]);return _0x5f17ac[_0xa9bf('0x70')](_0x533500);}})['then'](function(_0x3b1716){if(_0x3b1716){_0x15df01=_0x3b1716['length'];if(!_0x237988['query'][_0xa9bf('0x49')](_0xa9bf('0x4a'))){_0x533500[_0xa9bf('0x27')]=qs[_0xa9bf('0x27')](_0x237988[_0xa9bf('0x44')]['limit']);_0x533500[_0xa9bf('0x25')]=qs[_0xa9bf('0x25')](_0x237988[_0xa9bf('0x44')][_0xa9bf('0x25')]);}return _0x5f17ac[_0xa9bf('0x70')](_0x533500);}})['then'](function(_0x38d687){if(_0x38d687){return _0x38d687?{'count':_0x15df01,'rows':_0x38d687}:null;}})[_0xa9bf('0x2f')](respondWithResult(_0x32b410,null))[_0xa9bf('0x54')](handleError(_0x32b410,null));};exports['addTeams']=function(_0x59adcf,_0x465b2d,_0x38f11b){var _0x5fd560=_0x59adcf[_0xa9bf('0x5b')]['teams'];var _0x2f2b69=_[_0xa9bf('0x43')](_0x5fd560,'id');return db[_0xa9bf('0x71')]['findAll']({'where':{'id':_0x2f2b69},'attributes':['id'],'include':[{'model':db['User'],'as':_0xa9bf('0x72'),'attributes':['id',_0xa9bf('0x3e'),_0xa9bf('0x73'),_0xa9bf('0x74'),'interface'],'raw':!![]}]})['then'](function(_0x4efdaf){if(_0x4efdaf){var _0x22d1d8=_['flatMap'](_0x4efdaf,function(_0x31475b){var _0x2ca05c=_0x31475b[_0xa9bf('0x30')]({'plain':!![]});_0x2ca05c['Agents']['forEach'](function(_0x292671){_0x292671[_0xa9bf('0x75')]=_['find'](_0x5fd560,{'id':_0x2ca05c['id']})[_0xa9bf('0x75')];});return _0x2ca05c[_0xa9bf('0x72')];});return db[_0xa9bf('0x51')][_0xa9bf('0x39')]({'where':{'id':_0x59adcf['params']['id']}})[_0xa9bf('0x2f')](function(_0x19e499){return db['sequelize'][_0xa9bf('0x76')](function(_0x181a98){return _0x19e499['addTeams'](_0x2f2b69,{'transaction':_0x181a98})['then'](function(){return BPromise[_0xa9bf('0x77')](_0x5fd560,function(_0x496220){return db['TeamVoiceQueue'][_0xa9bf('0x78')]({'TeamId':_0x496220['id'],'VoiceQueueId':_0x59adcf[_0xa9bf('0x56')]['id'],'penalty':_0x496220[_0xa9bf('0x75')]},{'transaction':_0x181a98});});})[_0xa9bf('0x2f')](function(){return BPromise[_0xa9bf('0x77')](_0x22d1d8,function(_0x417b98){return db[_0xa9bf('0x79')][_0xa9bf('0x7a')]({'where':{'UserId':_0x417b98['id'],'VoiceQueueId':_0x59adcf['params']['id']},'defaults':{'penalty':_0x417b98[_0xa9bf('0x75')]},'transaction':_0x181a98});});})[_0xa9bf('0x2f')](function(){return BPromise[_0xa9bf('0x77')](_[_0xa9bf('0x34')](_0x22d1d8,{'online':!![]}),function(_0x2db787){return db[_0xa9bf('0x7b')][_0xa9bf('0x78')]({'membername':_0x2db787[_0xa9bf('0x3e')],'UserId':_0x2db787['id'],'queue_name':_0x19e499[_0xa9bf('0x3e')],'VoiceQueueId':_0x19e499['id'],'interface':_[_0xa9bf('0x7c')](_0x2db787['interface'])?util[_0xa9bf('0x7d')](_0xa9bf('0x7e'),_0x2db787['name']):_0x2db787[_0xa9bf('0x7f')],'paused':_0x2db787[_0xa9bf('0x74')]||![],'penalty':_0x2db787['penalty']},{'transaction':_0x181a98});});})[_0xa9bf('0x2f')](function(){_0x22d1d8['forEach'](function(_0x33cee8){socket[_0xa9bf('0x80')]('userVoiceQueue:save',{'UserId':_0x33cee8['id'],'VoiceQueueId':_0x19e499['id']});});});});});}})['then'](respondWithStatusCode(_0x465b2d,null))[_0xa9bf('0x54')](handleError(_0x465b2d,null));};exports[_0xa9bf('0x81')]=function(_0x12ab03,_0x3f2697,_0x18a414){return db['Team'][_0xa9bf('0x52')]({'where':{'id':_0x12ab03[_0xa9bf('0x44')]['ids']},'attributes':['id'],'include':[{'model':db[_0xa9bf('0x82')],'as':_0xa9bf('0x72'),'attributes':['id'],'raw':!![]}]})[_0xa9bf('0x2f')](handleEntityNotFound(_0x3f2697,null))[_0xa9bf('0x2f')](function(_0xd28589){var _0x43fbca=_['map'](_0xd28589,'id');var _0x25b2dc=[];var _0x2343aa=[];var _0x132457=squel[_0xa9bf('0x83')]();_0x132457[_0xa9bf('0x84')](_0xa9bf('0x85'))[_0xa9bf('0x86')](_0xa9bf('0x87'),'tq')[_0xa9bf('0x88')](_0xa9bf('0x89'),'ut',_0xa9bf('0x8a'))[_0xa9bf('0x4d')]('VoiceQueueId\x20=\x20?',_0x12ab03[_0xa9bf('0x56')]['id']);for(var _0x14ad30=0x0;_0x14ad30<_0xd28589['length'];_0x14ad30+=0x1){let _0x5b0429=_0xd28589[_0x14ad30];for(var _0x244cc0=0x0;_0x244cc0<_0x5b0429[_0xa9bf('0x72')][_0xa9bf('0x58')];_0x244cc0+=0x1){let _0x2510b7=_0x5b0429['Agents'][_0x244cc0];var _0x4672f9=_0x132457[_0xa9bf('0x63')]();_0x4672f9[_0xa9bf('0x4d')]('ut.UserId\x20=\x20?',_0x2510b7['id']);_0x2343aa['push'](db['sequelize'][_0xa9bf('0x44')](_0x4672f9[_0xa9bf('0x8b')](),{'type':db[_0xa9bf('0x8c')]['QueryTypes']['SELECT']})['then'](function(_0x131363){if(_0x131363[_0xa9bf('0x58')]===0x1){return _0x2510b7['id'];}else{var _0x3bda45=_[_0xa9bf('0x8d')](_[_0xa9bf('0x43')](_0x131363,_0xa9bf('0x8e')),function(_0x5f4c9c){return _[_0xa9bf('0x37')](_0x43fbca,_0x5f4c9c);});if(_0x3bda45){return _0x2510b7['id'];}}}));}}return BPromise['all'](_0x2343aa)[_0xa9bf('0x2f')](function(_0x5b4f7b){_0x25b2dc=_(_0x25b2dc)['union'](_0x5b4f7b)[_0xa9bf('0x8f')]()['value']();return db[_0xa9bf('0x51')][_0xa9bf('0x39')]({'where':{'id':_0x12ab03['params']['id']}})['then'](function(_0x500329){return db[_0xa9bf('0x8c')]['transaction'](function(_0x471b91){return _0x500329[_0xa9bf('0x81')](_0x12ab03[_0xa9bf('0x44')][_0xa9bf('0x90')],{'transaction':_0x471b91})['then'](function(){if(!_[_0xa9bf('0x91')](_0x25b2dc)){return _0x500329[_0xa9bf('0x92')](_0x25b2dc,{'transaction':_0x471b91})[_0xa9bf('0x2f')](function(){return db[_0xa9bf('0x7b')]['destroy']({'where':{'VoiceQueueId':_0x12ab03[_0xa9bf('0x56')]['id'],'UserId':_0x25b2dc},'transaction':_0x471b91});});}})[_0xa9bf('0x2f')](function(){_0x25b2dc[_0xa9bf('0x93')](function(_0x2a54db){socket[_0xa9bf('0x80')](_0xa9bf('0x94'),{'UserId':_0x2a54db,'VoiceQueueId':_0x500329['id']});});});});});});})['then'](respondWithStatusCode(_0x3f2697,null))['catch'](handleError(_0x3f2697,null));};exports[_0xa9bf('0x95')]=function(_0x1083f7,_0x35ae6d,_0x2a9558){var _0x3f1163,_0x33203b;return db[_0xa9bf('0x51')][_0xa9bf('0x39')]({'where':{'id':_0x1083f7[_0xa9bf('0x56')]['id']}})['then'](handleEntityNotFound(_0x35ae6d,null))['then'](function(_0x22ec48){if(_0x22ec48){_0x33203b=_0x22ec48;return _0x22ec48['addAgents'](_0x1083f7[_0xa9bf('0x5b')][_0xa9bf('0x90')],_[_0xa9bf('0x96')](_0x1083f7[_0xa9bf('0x5b')],[_0xa9bf('0x90'),'id'])||{})[_0xa9bf('0x97')](function(_0x42998d){for(var _0x59224f=0x0;_0x59224f<_0x1083f7[_0xa9bf('0x5b')][_0xa9bf('0x90')][_0xa9bf('0x58')];_0x59224f+=0x1){socket[_0xa9bf('0x80')](_0xa9bf('0x98'),{'UserId':Number(_0x1083f7[_0xa9bf('0x5b')]['ids'][_0x59224f]),'VoiceQueueId':Number(_0x1083f7[_0xa9bf('0x56')]['id'])});}return _0x42998d;});}})[_0xa9bf('0x2f')](function(_0x4736fb){_0x3f1163=_0x4736fb||[];if(_0x33203b){return db['User'][_0xa9bf('0x52')]({'where':{'id':_0x1083f7[_0xa9bf('0x5b')][_0xa9bf('0x90')]},'attributes':['id','name','online',_0xa9bf('0x74'),_0xa9bf('0x7f')],'raw':!![]});}})[_0xa9bf('0x2f')](function(_0x5a09dc){if(!_[_0xa9bf('0x91')](_0x5a09dc)){var _0x56a1c9=[];for(var _0x4a3b59=0x0;_0x4a3b59<_0x5a09dc[_0xa9bf('0x58')];_0x4a3b59++){if(_0x5a09dc[_0x4a3b59][_0xa9bf('0x73')]){_0x56a1c9[_0xa9bf('0x99')](db[_0xa9bf('0x7b')][_0xa9bf('0x78')]({'membername':_0x5a09dc[_0x4a3b59][_0xa9bf('0x3e')],'UserId':_0x5a09dc[_0x4a3b59]['id'],'queue_name':_0x33203b[_0xa9bf('0x3e')],'VoiceQueueId':_0x33203b['id'],'interface':_['isNil'](_0x5a09dc[_0x4a3b59][_0xa9bf('0x7f')])?util['format']('SIP/%s',_0x5a09dc[_0x4a3b59]['name']):_0x5a09dc[_0x4a3b59][_0xa9bf('0x7f')],'paused':_0x5a09dc[_0x4a3b59][_0xa9bf('0x74')]||![],'penalty':_0x1083f7['body']['penalty']||0x0}));}}return BPromise[_0xa9bf('0x9a')](_0x56a1c9);}})['then'](function(){return _0x3f1163;})[_0xa9bf('0x2f')](respondWithResult(_0x35ae6d,null))['catch'](handleError(_0x35ae6d,null));};exports[_0xa9bf('0x92')]=function(_0x37001e,_0x4f772e,_0x40d6c3){return db['VoiceQueue']['find']({'where':{'id':_0x37001e[_0xa9bf('0x56')]['id']}})[_0xa9bf('0x2f')](handleEntityNotFound(_0x4f772e,null))[_0xa9bf('0x2f')](function(_0x3c1474){if(_0x3c1474){return _0x3c1474[_0xa9bf('0x92')](_0x37001e[_0xa9bf('0x44')]['ids'])[_0xa9bf('0x2f')](function(){if(_[_0xa9bf('0x9b')](_0x37001e[_0xa9bf('0x44')][_0xa9bf('0x90')])){for(var _0x26cb8b=0x0;_0x26cb8b<_0x37001e[_0xa9bf('0x44')][_0xa9bf('0x90')]['length'];_0x26cb8b+=0x1){socket['emit'](_0xa9bf('0x94'),{'UserId':Number(_0x37001e['query']['ids'][_0x26cb8b]),'VoiceQueueId':Number(_0x37001e[_0xa9bf('0x56')]['id'])});}}else{socket[_0xa9bf('0x80')]('userVoiceQueue:remove',{'UserId':Number(_0x37001e['query'][_0xa9bf('0x90')]),'VoiceQueueId':Number(_0x37001e['params']['id'])});}});}})['then'](function(_0x57bf14){return db['UserVoiceQueueRt'][_0xa9bf('0x3b')]({'where':{'VoiceQueueId':_0x37001e[_0xa9bf('0x56')]['id'],'UserId':_0x37001e[_0xa9bf('0x44')][_0xa9bf('0x90')]}})['then'](function(){return _0x57bf14;});})[_0xa9bf('0x2f')](respondWithStatusCode(_0x4f772e,null))[_0xa9bf('0x54')](handleError(_0x4f772e,null));};exports[_0xa9bf('0x9c')]=function(_0x2e32ed,_0x46ab8d,_0x127aab){var _0x114a4c={};var _0xa3492c={};var _0x129a1e;var _0xc81547;return db[_0xa9bf('0x51')][_0xa9bf('0x67')]({'where':{'id':_0x2e32ed['params']['id']}})[_0xa9bf('0x2f')](handleEntityNotFound(_0x46ab8d,null))[_0xa9bf('0x2f')](function(_0x41dafa){if(_0x41dafa){_0x129a1e=_0x41dafa;_0xa3492c[_0xa9bf('0x42')]=_[_0xa9bf('0x57')](db[_0xa9bf('0x82')][_0xa9bf('0x40')]);_0xa3492c[_0xa9bf('0x44')]=_[_0xa9bf('0x57')](_0x2e32ed[_0xa9bf('0x44')]);_0xa3492c[_0xa9bf('0x45')]=_[_0xa9bf('0x46')](_0xa3492c[_0xa9bf('0x42')],_0xa3492c[_0xa9bf('0x44')]);_0x114a4c[_0xa9bf('0x47')]=_[_0xa9bf('0x46')](_0xa3492c[_0xa9bf('0x42')],qs[_0xa9bf('0x48')](_0x2e32ed[_0xa9bf('0x44')]['fields']));_0x114a4c[_0xa9bf('0x47')]=_0x114a4c[_0xa9bf('0x47')][_0xa9bf('0x58')]?_0x114a4c[_0xa9bf('0x47')]:_0xa3492c[_0xa9bf('0x42')];_0x114a4c[_0xa9bf('0x4b')]=qs[_0xa9bf('0x4c')](_0x2e32ed[_0xa9bf('0x44')][_0xa9bf('0x4c')]);_0x114a4c['where']=qs[_0xa9bf('0x45')](_[_0xa9bf('0x6b')](_0x2e32ed[_0xa9bf('0x44')],_0xa3492c['filters']));if(_0x2e32ed[_0xa9bf('0x44')][_0xa9bf('0x34')]){_0x114a4c['where']=_[_0xa9bf('0x4e')](_0x114a4c[_0xa9bf('0x4d')],{'$or':_[_0xa9bf('0x43')](_0x114a4c[_0xa9bf('0x47')],function(_0x2a27b1){var _0x23ac10={};_0x23ac10[_0x2a27b1]={'$like':'%'+_0x2e32ed[_0xa9bf('0x44')][_0xa9bf('0x34')]+'%'};return _0x23ac10;})});}_0x114a4c=_[_0xa9bf('0x4e')]({},_0x114a4c,_0x2e32ed[_0xa9bf('0x59')]);return _0x129a1e['getAgents'](_0x114a4c);}})[_0xa9bf('0x2f')](function(_0x5f4f67){if(_0x5f4f67){_0xc81547=_0x5f4f67[_0xa9bf('0x58')];if(!_0x2e32ed[_0xa9bf('0x44')][_0xa9bf('0x49')](_0xa9bf('0x4a'))){_0x114a4c[_0xa9bf('0x27')]=qs['limit'](_0x2e32ed['query'][_0xa9bf('0x27')]);_0x114a4c['offset']=qs[_0xa9bf('0x25')](_0x2e32ed[_0xa9bf('0x44')][_0xa9bf('0x25')]);}return _0x129a1e[_0xa9bf('0x9c')](_0x114a4c);}})[_0xa9bf('0x2f')](function(_0x28c6c6){if(_0x28c6c6){return _0x28c6c6?{'count':_0xc81547,'rows':_0x28c6c6}:null;}})[_0xa9bf('0x2f')](respondWithResult(_0x46ab8d,null))[_0xa9bf('0x54')](handleError(_0x46ab8d,null));};exports[_0xa9bf('0x9d')]=function(_0x489728,_0x4df23c,_0x298d43){var _0x4581c7={};var _0xf811b5={};var _0x1166c4;var _0x18c702;return db[_0xa9bf('0x51')][_0xa9bf('0x67')]({'where':{'id':_0x489728['params']['id']}})[_0xa9bf('0x2f')](handleEntityNotFound(_0x4df23c,null))['then'](function(_0x2a17db){if(_0x2a17db){_0x1166c4=_0x2a17db;_0xf811b5[_0xa9bf('0x42')]=_[_0xa9bf('0x57')](db[_0xa9bf('0x7b')][_0xa9bf('0x40')]);_0xf811b5[_0xa9bf('0x44')]=_[_0xa9bf('0x57')](_0x489728['query']);_0xf811b5[_0xa9bf('0x45')]=_[_0xa9bf('0x46')](_0xf811b5[_0xa9bf('0x42')],_0xf811b5[_0xa9bf('0x44')]);_0x4581c7[_0xa9bf('0x47')]=_[_0xa9bf('0x46')](_0xf811b5[_0xa9bf('0x42')],qs[_0xa9bf('0x48')](_0x489728[_0xa9bf('0x44')][_0xa9bf('0x48')]));_0x4581c7[_0xa9bf('0x47')]=_0x4581c7['attributes'][_0xa9bf('0x58')]?_0x4581c7[_0xa9bf('0x47')]:_0xf811b5[_0xa9bf('0x42')];_0x4581c7[_0xa9bf('0x4b')]=qs['sort'](_0x489728['query'][_0xa9bf('0x4c')]);_0x4581c7['where']=qs[_0xa9bf('0x45')](_[_0xa9bf('0x6b')](_0x489728[_0xa9bf('0x44')],_0xf811b5['filters']));if(_0x489728[_0xa9bf('0x44')][_0xa9bf('0x34')]){_0x4581c7[_0xa9bf('0x4d')]=_[_0xa9bf('0x4e')](_0x4581c7[_0xa9bf('0x4d')],{'$or':_[_0xa9bf('0x43')](_0x4581c7[_0xa9bf('0x47')],function(_0x473deb){var _0x39d3e7={};_0x39d3e7[_0x473deb]={'$like':'%'+_0x489728[_0xa9bf('0x44')][_0xa9bf('0x34')]+'%'};return _0x39d3e7;})});}_0x4581c7=_[_0xa9bf('0x4e')]({},_0x4581c7,_0x489728[_0xa9bf('0x59')]);return _0x1166c4[_0xa9bf('0x9d')](_0x4581c7);}})[_0xa9bf('0x2f')](function(_0x124789){if(_0x124789){_0x18c702=_0x124789[_0xa9bf('0x58')];if(!_0x489728[_0xa9bf('0x44')]['hasOwnProperty'](_0xa9bf('0x4a'))){_0x4581c7['limit']=qs['limit'](_0x489728[_0xa9bf('0x44')][_0xa9bf('0x27')]);_0x4581c7[_0xa9bf('0x25')]=qs['offset'](_0x489728[_0xa9bf('0x44')][_0xa9bf('0x25')]);}return _0x1166c4[_0xa9bf('0x9d')](_0x4581c7);}})[_0xa9bf('0x2f')](function(_0x791640){return _0x791640?{'count':_0x18c702,'rows':_0x791640}:null;})['then'](respondWithResult(_0x4df23c,null))[_0xa9bf('0x54')](handleError(_0x4df23c,null));};exports['getLists']=function(_0x51632d,_0x2074ca,_0x399316){var _0x3e8854={};var _0x514ce8={};var _0x251134;var _0x3a4554;return db[_0xa9bf('0x51')]['findOne']({'where':{'id':_0x51632d[_0xa9bf('0x56')]['id']}})['then'](handleEntityNotFound(_0x2074ca,null))[_0xa9bf('0x2f')](function(_0x1dfe4a){if(_0x1dfe4a){_0x251134=_0x1dfe4a;_0x514ce8[_0xa9bf('0x42')]=_[_0xa9bf('0x57')](db[_0xa9bf('0x9e')][_0xa9bf('0x40')]);_0x514ce8[_0xa9bf('0x44')]=_[_0xa9bf('0x57')](_0x51632d[_0xa9bf('0x44')]);_0x514ce8['filters']=_[_0xa9bf('0x46')](_0x514ce8[_0xa9bf('0x42')],_0x514ce8[_0xa9bf('0x44')]);_0x3e8854[_0xa9bf('0x47')]=_[_0xa9bf('0x46')](_0x514ce8[_0xa9bf('0x42')],qs[_0xa9bf('0x48')](_0x51632d[_0xa9bf('0x44')][_0xa9bf('0x48')]));_0x3e8854[_0xa9bf('0x47')]=_0x3e8854[_0xa9bf('0x47')]['length']?_0x3e8854[_0xa9bf('0x47')]:_0x514ce8[_0xa9bf('0x42')];_0x3e8854[_0xa9bf('0x4b')]=qs[_0xa9bf('0x4c')](_0x51632d['query'][_0xa9bf('0x4c')]);_0x3e8854[_0xa9bf('0x4d')]=qs[_0xa9bf('0x45')](_['pick'](_0x51632d['query'],_0x514ce8['filters']));if(_0x51632d[_0xa9bf('0x44')][_0xa9bf('0x34')]){_0x3e8854[_0xa9bf('0x4d')]=_[_0xa9bf('0x4e')](_0x3e8854[_0xa9bf('0x4d')],{'$or':_[_0xa9bf('0x43')](_0x3e8854[_0xa9bf('0x47')],function(_0x403e2e){var _0x292e5b={};_0x292e5b[_0x403e2e]={'$like':'%'+_0x51632d[_0xa9bf('0x44')][_0xa9bf('0x34')]+'%'};return _0x292e5b;})});}_0x3e8854=_['merge']({},_0x3e8854,_0x51632d[_0xa9bf('0x59')]);return _0x251134[_0xa9bf('0x9f')](_0x3e8854);}})[_0xa9bf('0x2f')](function(_0x49c904){if(_0x49c904){_0x3a4554=_0x49c904[_0xa9bf('0x58')];if(!_0x51632d[_0xa9bf('0x44')]['hasOwnProperty'](_0xa9bf('0x4a'))){_0x3e8854[_0xa9bf('0x27')]=qs[_0xa9bf('0x27')](_0x51632d[_0xa9bf('0x44')][_0xa9bf('0x27')]);_0x3e8854[_0xa9bf('0x25')]=qs[_0xa9bf('0x25')](_0x51632d[_0xa9bf('0x44')][_0xa9bf('0x25')]);}return _0x251134[_0xa9bf('0x9f')](_0x3e8854);}})['then'](function(_0x213432){if(_0x213432){return _0x213432?{'count':_0x3a4554,'rows':_0x213432}:null;}})[_0xa9bf('0x2f')](respondWithResult(_0x2074ca,null))[_0xa9bf('0x54')](handleError(_0x2074ca,null));};exports[_0xa9bf('0xa0')]=function(_0x245323,_0x37603e,_0x24285d){var _0x1e8060,_0x26d1f1;return db['VoiceQueue']['find']({'where':{'id':_0x245323['params']['id']}})[_0xa9bf('0x2f')](handleEntityNotFound(_0x37603e,null))[_0xa9bf('0x2f')](function(_0x1d1a9f){if(_0x1d1a9f){_0x26d1f1=_0x1d1a9f;return _0x1d1a9f[_0xa9bf('0xa0')](_0x245323[_0xa9bf('0x5b')][_0xa9bf('0x90')],_[_0xa9bf('0x96')](_0x245323['body'],['ids','id'])||{});}return null;})[_0xa9bf('0x97')](function(_0x31f7ea){var _0x271c33;_0x1e8060=_0x31f7ea||[];var _0x3472c7=[];if(_0x31f7ea){for(var _0x4abd4b=0x0;_0x4abd4b<_0x31f7ea[_0xa9bf('0x58')];_0x4abd4b+=0x1){var _0x1fd307=_0x31f7ea[_0x4abd4b][_0xa9bf('0x30')]({'plain':!![]});_0x26d1f1[_0xa9bf('0xa1')]=_0x245323[_0xa9bf('0x5b')][_0xa9bf('0xa1')]?_0x245323[_0xa9bf('0x5b')]['dialCheckDuplicateType']:_0x26d1f1[_0xa9bf('0xa1')];switch(_0x26d1f1[_0xa9bf('0xa1')]){case'always':_0x271c33=squel[_0xa9bf('0xa2')]()[_0xa9bf('0xa3')](_0xa9bf('0xa4'))[_0xa9bf('0xa5')]([_0xa9bf('0xa6'),_0xa9bf('0xa7'),_0xa9bf('0xa8'),'ListId',_0xa9bf('0x69'),_0xa9bf('0x64'),_0xa9bf('0x65')],squel['select']()['field'](_0xa9bf('0xa6'),_0xa9bf('0xa6'))['field'](_0xa9bf('0xa9'),_0xa9bf('0xa7'))[_0xa9bf('0x84')]('id','ContactId')['field'](_0x1fd307[_0xa9bf('0xaa')][_0xa9bf('0x8b')](),'ListId')['field'](_0x245323['params']['id'][_0xa9bf('0x8b')](),'VoiceQueueId')['field'](_0xa9bf('0xa9'),_0xa9bf('0x64'))[_0xa9bf('0x84')](_0xa9bf('0xa9'),'updatedAt')[_0xa9bf('0x86')]('cm_contacts')[_0xa9bf('0x4d')]('deletedAt\x20IS\x20NULL')['where'](_0xa9bf('0xab'),_0x1fd307[_0xa9bf('0xaa')]['toString']())[_0xa9bf('0x4d')](_0xa9bf('0xac'))[_0xa9bf('0x4d')](_0xa9bf('0xad'),squel[_0xa9bf('0x83')]()[_0xa9bf('0x84')](_0xa9bf('0xae'))[_0xa9bf('0x86')]('cm_hopper_final')[_0xa9bf('0x4d')](_0xa9bf('0xaf'),_0x245323[_0xa9bf('0x56')]['id'][_0xa9bf('0x8b')]()))[_0xa9bf('0x4d')]('phone\x20NOT\x20IN\x20(?)',squel[_0xa9bf('0x83')]()[_0xa9bf('0x84')]('COALESCE(phone,\x27\x27)')[_0xa9bf('0x86')](_0xa9bf('0xa4'))[_0xa9bf('0x4d')](_0xa9bf('0xaf'),_0x245323['params']['id'][_0xa9bf('0x8b')]())))[_0xa9bf('0x8b')]();break;case _0xa9bf('0xb0'):_0x271c33=squel['insert']()[_0xa9bf('0xa3')](_0xa9bf('0xa4'))[_0xa9bf('0xa5')](['phone','scheduledAt',_0xa9bf('0xa8'),_0xa9bf('0xb1'),_0xa9bf('0x69'),'createdAt',_0xa9bf('0x65')],squel[_0xa9bf('0x83')]()[_0xa9bf('0x84')](_0xa9bf('0xa6'),_0xa9bf('0xa6'))['field'](_0xa9bf('0xa9'),_0xa9bf('0xa7'))['field']('id',_0xa9bf('0xa8'))[_0xa9bf('0x84')](_0x1fd307['CmListId'][_0xa9bf('0x8b')](),'ListId')[_0xa9bf('0x84')](_0x245323[_0xa9bf('0x56')]['id'][_0xa9bf('0x8b')](),_0xa9bf('0x69'))[_0xa9bf('0x84')]('NOW()',_0xa9bf('0x64'))[_0xa9bf('0x84')]('NOW()',_0xa9bf('0x65'))[_0xa9bf('0x86')](_0xa9bf('0xb2'))[_0xa9bf('0x4d')]('deletedAt\x20IS\x20NULL')[_0xa9bf('0x4d')](_0xa9bf('0xab'),_0x1fd307[_0xa9bf('0xaa')][_0xa9bf('0x8b')]())[_0xa9bf('0x4d')](_0xa9bf('0xac'))[_0xa9bf('0x4d')](_0xa9bf('0xad'),squel[_0xa9bf('0x83')]()[_0xa9bf('0x84')]('COALESCE(phone,\x27\x27)')[_0xa9bf('0x86')](_0xa9bf('0xa4'))[_0xa9bf('0x4d')](_0xa9bf('0xaf'),_0x245323[_0xa9bf('0x56')]['id'][_0xa9bf('0x8b')]())))[_0xa9bf('0x8b')]();break;default:_0x271c33=squel[_0xa9bf('0xa2')]()[_0xa9bf('0xa3')](_0xa9bf('0xa4'))[_0xa9bf('0xa5')]([_0xa9bf('0xa6'),'scheduledAt',_0xa9bf('0xa8'),'ListId',_0xa9bf('0x69'),'createdAt',_0xa9bf('0x65')],squel[_0xa9bf('0x83')]()['field'](_0xa9bf('0xa6'),_0xa9bf('0xa6'))['field'](_0xa9bf('0xa9'),_0xa9bf('0xa7'))[_0xa9bf('0x84')]('id',_0xa9bf('0xa8'))[_0xa9bf('0x84')](_0x1fd307[_0xa9bf('0xaa')][_0xa9bf('0x8b')](),_0xa9bf('0xb1'))[_0xa9bf('0x84')](_0x245323['params']['id']['toString'](),_0xa9bf('0x69'))[_0xa9bf('0x84')](_0xa9bf('0xa9'),_0xa9bf('0x64'))[_0xa9bf('0x84')](_0xa9bf('0xa9'),'updatedAt')[_0xa9bf('0x86')](_0xa9bf('0xb2'))[_0xa9bf('0x4d')]('deletedAt\x20IS\x20NULL')[_0xa9bf('0x4d')](_0xa9bf('0xab'),_0x1fd307['CmListId'][_0xa9bf('0x8b')]())[_0xa9bf('0x4d')](_0xa9bf('0xac')))['toString']();}_0x3472c7[_0xa9bf('0x99')](db[_0xa9bf('0x8c')][_0xa9bf('0x44')](_0x271c33));}return BPromise[_0xa9bf('0x9a')](_0x3472c7);}})[_0xa9bf('0x2f')](function(){return _0x1e8060;})[_0xa9bf('0x2f')](respondWithResult(_0x37603e,null))[_0xa9bf('0x54')](handleError(_0x37603e,null));};exports['removeLists']=function(_0xa2ae6d,_0xa6fa5b,_0x6c2570){return db['VoiceQueue'][_0xa9bf('0x39')]({'where':{'id':_0xa2ae6d[_0xa9bf('0x56')]['id']}})['then'](handleEntityNotFound(_0xa6fa5b,null))[_0xa9bf('0x2f')](function(_0x29197e){if(_0x29197e){return _0x29197e[_0xa9bf('0xb3')](_0xa2ae6d[_0xa9bf('0x44')][_0xa9bf('0x90')]);}})[_0xa9bf('0x2f')](function(_0x44af66){if(_0x44af66){return db[_0xa9bf('0x68')][_0xa9bf('0x3b')]({'where':{'ListId':_0xa2ae6d[_0xa9bf('0x44')][_0xa9bf('0x90')],'VoiceQueueId':_0xa2ae6d[_0xa9bf('0x56')]['id']}})['then'](function(){return _0x44af66;});}})[_0xa9bf('0x2f')](respondWithStatusCode(_0xa6fa5b,null))[_0xa9bf('0x54')](handleError(_0xa6fa5b,null));};exports[_0xa9bf('0xb4')]=function(_0x188c97,_0x20edc1,_0x4285b7){var _0x1d49e8={};var _0x5cd42f={};var _0x1a42d0;var _0x552ddc;return db[_0xa9bf('0x51')][_0xa9bf('0x67')]({'where':{'id':_0x188c97['params']['id']}})[_0xa9bf('0x2f')](handleEntityNotFound(_0x20edc1,null))[_0xa9bf('0x2f')](function(_0x13de8a){if(_0x13de8a){_0x1a42d0=_0x13de8a;_0x5cd42f[_0xa9bf('0x42')]=_[_0xa9bf('0x57')](db[_0xa9bf('0x9e')][_0xa9bf('0x40')]);_0x5cd42f['query']=_[_0xa9bf('0x57')](_0x188c97[_0xa9bf('0x44')]);_0x5cd42f[_0xa9bf('0x45')]=_[_0xa9bf('0x46')](_0x5cd42f['model'],_0x5cd42f['query']);_0x1d49e8[_0xa9bf('0x47')]=_[_0xa9bf('0x46')](_0x5cd42f[_0xa9bf('0x42')],qs[_0xa9bf('0x48')](_0x188c97[_0xa9bf('0x44')][_0xa9bf('0x48')]));_0x1d49e8[_0xa9bf('0x47')]=_0x1d49e8[_0xa9bf('0x47')][_0xa9bf('0x58')]?_0x1d49e8[_0xa9bf('0x47')]:_0x5cd42f[_0xa9bf('0x42')];_0x1d49e8[_0xa9bf('0x4b')]=qs[_0xa9bf('0x4c')](_0x188c97[_0xa9bf('0x44')][_0xa9bf('0x4c')]);_0x1d49e8[_0xa9bf('0x4d')]=qs[_0xa9bf('0x45')](_[_0xa9bf('0x6b')](_0x188c97['query'],_0x5cd42f['filters']));if(_0x188c97['query'][_0xa9bf('0x34')]){_0x1d49e8[_0xa9bf('0x4d')]=_['merge'](_0x1d49e8[_0xa9bf('0x4d')],{'$or':_['map'](_0x1d49e8[_0xa9bf('0x47')],function(_0x19a9cb){var _0x1aa495={};_0x1aa495[_0x19a9cb]={'$like':'%'+_0x188c97[_0xa9bf('0x44')][_0xa9bf('0x34')]+'%'};return _0x1aa495;})});}_0x1d49e8=_[_0xa9bf('0x4e')]({},_0x1d49e8,_0x188c97[_0xa9bf('0x59')]);return _0x1a42d0[_0xa9bf('0xb4')](_0x1d49e8);}})[_0xa9bf('0x2f')](function(_0x29c0cc){if(_0x29c0cc){_0x552ddc=_0x29c0cc[_0xa9bf('0x58')];if(!_0x188c97[_0xa9bf('0x44')][_0xa9bf('0x49')]('nolimit')){_0x1d49e8[_0xa9bf('0x27')]=qs['limit'](_0x188c97[_0xa9bf('0x44')][_0xa9bf('0x27')]);_0x1d49e8[_0xa9bf('0x25')]=qs['offset'](_0x188c97[_0xa9bf('0x44')][_0xa9bf('0x25')]);}return _0x1a42d0[_0xa9bf('0xb4')](_0x1d49e8);}})['then'](function(_0xe77604){if(_0xe77604){return _0xe77604?{'count':_0x552ddc,'rows':_0xe77604}:null;}})[_0xa9bf('0x2f')](respondWithResult(_0x20edc1,null))[_0xa9bf('0x54')](handleError(_0x20edc1,null));};exports[_0xa9bf('0xb5')]=function(_0x1d9bef,_0x37f0fd,_0xc63bb4){var _0x3cf115,_0x40eb74;return db[_0xa9bf('0x51')]['find']({'where':{'id':_0x1d9bef[_0xa9bf('0x56')]['id']}})['then'](handleEntityNotFound(_0x37f0fd,null))[_0xa9bf('0x2f')](function(_0x246809){if(_0x246809){_0x40eb74=_0x246809;return _0x246809[_0xa9bf('0xb5')](_0x1d9bef['body'][_0xa9bf('0x90')],_['omit'](_0x1d9bef[_0xa9bf('0x5b')],['ids','id'])||{});}return null;})[_0xa9bf('0x97')](function(_0x8699bc){var _0x485b6a;_0x3cf115=_0x8699bc||[];var _0x3c0306=[];if(_0x8699bc){for(var _0x51d490=0x0;_0x51d490<_0x8699bc['length'];_0x51d490+=0x1){var _0x425df2=_0x8699bc[_0x51d490][_0xa9bf('0x30')]({'plain':!![]});_0x485b6a=squel['insert']()[_0xa9bf('0xa3')](_0xa9bf('0xb6'))[_0xa9bf('0xa5')](['phone',_0xa9bf('0xa8'),_0xa9bf('0xb1'),'VoiceQueueId',_0xa9bf('0x64'),'updatedAt'],squel[_0xa9bf('0x83')]()[_0xa9bf('0x84')]('phone','phone')[_0xa9bf('0x84')]('id',_0xa9bf('0xa8'))[_0xa9bf('0x84')](_0x425df2[_0xa9bf('0xaa')][_0xa9bf('0x8b')](),_0xa9bf('0xb1'))[_0xa9bf('0x84')](_0x1d9bef[_0xa9bf('0x56')]['id'][_0xa9bf('0x8b')](),_0xa9bf('0x69'))[_0xa9bf('0x84')](_0xa9bf('0xa9'),_0xa9bf('0x64'))[_0xa9bf('0x84')](_0xa9bf('0xa9'),_0xa9bf('0x65'))['from'](_0xa9bf('0xb2'))[_0xa9bf('0x4d')](_0xa9bf('0xb7'))[_0xa9bf('0x4d')](_0xa9bf('0xab'),_0x425df2[_0xa9bf('0xaa')][_0xa9bf('0x8b')]())['where'](_0xa9bf('0xac')))[_0xa9bf('0x8b')]();_0x3c0306[_0xa9bf('0x99')](db['sequelize'][_0xa9bf('0x44')](_0x485b6a));}return BPromise['all'](_0x3c0306);}})[_0xa9bf('0x2f')](function(){return _0x3cf115;})[_0xa9bf('0x2f')](respondWithResult(_0x37f0fd,null))[_0xa9bf('0x54')](handleError(_0x37f0fd,null));};exports['removeBlackLists']=function(_0x4f812a,_0x1e0107,_0x4559c3){return db['VoiceQueue'][_0xa9bf('0x39')]({'where':{'id':_0x4f812a[_0xa9bf('0x56')]['id']}})[_0xa9bf('0x2f')](handleEntityNotFound(_0x1e0107,null))[_0xa9bf('0x2f')](function(_0xc0ce49){if(_0xc0ce49){return _0xc0ce49[_0xa9bf('0xb8')](_0x4f812a['query']['ids']);}})[_0xa9bf('0x2f')](function(_0x9de40){if(_0x9de40){return db[_0xa9bf('0x6f')][_0xa9bf('0x3b')]({'where':{'ListId':_0x4f812a[_0xa9bf('0x44')][_0xa9bf('0x90')],'VoiceQueueId':_0x4f812a[_0xa9bf('0x56')]['id']}})[_0xa9bf('0x2f')](function(){return _0x9de40;});}})[_0xa9bf('0x2f')](respondWithStatusCode(_0x1e0107,null))[_0xa9bf('0x54')](handleError(_0x1e0107,null));};
\ No newline at end of file
+var _0x3079=['UserVoiceQueue','findOrCreate','UserVoiceQueueRt','isNil','format','SIP/%s','forEach','emit','removeTeams','ids','select','field','tq.TeamId','from','user_has_teams','ut.TeamId\x20=\x20tq.TeamId','VoiceQueueId\x20=\x20?','ut.UserId\x20=\x20?','push','toString','QueryTypes','SELECT','every','TeamId','all','union','compact','isEmpty','removeAgents','userVoiceQueue:remove','addAgents','spread','userVoiceQueue:save','voicePause','isArray','getAgents','getMembers','getLists','CmList','addLists','YYYY-MM-DD\x20HH:mm:ss','dialCheckDuplicateType','always','insert','into','cm_hopper','fromQuery','scheduledAt','ContactId','phone','CmListId','ListId','cm_contacts','ListId\x20=\x20?','phone\x20IS\x20NOT\x20NULL','phone\x20NOT\x20IN\x20(?)','cm_hopper_final','COALESCE(phone,\x27\x27)','onlyIfOpen','deletedAt\x20IS\x20NULL','cm_hopper_additional_phones','OrderBy','h.id','ci.item','ci.OrderBy+1','cm_contact_has_items','h.ContactId=ci.CmContactId','h.scheduledat=?','ci.ItemClass=?','PHONE','removeLists','CmHopper','getBlackLists','addBlackLists','cm_hopper_black','NOW()','removeBlackLists','rimraf','zip-dir','fast-json-patch','request-promise','bluebird','mustache','sox','to-csv','ejs','fs-extra','lodash','jsforce','querystring','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','defaults','redis','./voiceQueue.socket','sendStatus','status','json','offset','undefined','limit','count','set','Content-Range','apply','reject','save','update','destroy','then','get','VoiceQueues','QueueCampaigns','filter','ignore','value','type','name','UserProfileResource','end','error','stack','send','index','map','VoiceQueue','rawAttributes','fieldName','key','model','query','keys','filters','intersection','attributes','fields','nolimit','where','merge','options','includeAll','findAll','rows','catch','show','params','length','include','create','user','role','inbound','find','UserProfileSection','userProfileId','clone','omit','createdAt','updatedAt','body','Unable\x20to\x20retrieve\x20the\x20current\x20user','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','getHoppers','findOne','order','sort','VoiceQueueId','getHopperHistories','CmHopperHistory','hasOwnProperty','pick','getHopperFinals','CmHopperFinal','getHopperBlacks','CmHopperBlack','getTeams','addTeams','Team','User','online','interface','Agents','penalty','sequelize','transaction','each','TeamVoiceQueue'];(function(_0x2e54bc,_0x304463){var _0x95de19=function(_0x46fbac){while(--_0x46fbac){_0x2e54bc['push'](_0x2e54bc['shift']());}};_0x95de19(++_0x304463);}(_0x3079,0x110));var _0x9307=function(_0x37c7a5,_0x1c901b){_0x37c7a5=_0x37c7a5-0x0;var _0x3ecbc7=_0x3079[_0x37c7a5];return _0x3ecbc7;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x9307('0x0'));var zipdir=require(_0x9307('0x1'));var jsonpatch=require(_0x9307('0x2'));var rp=require(_0x9307('0x3'));var moment=require('moment');var BPromise=require(_0x9307('0x4'));var Mustache=require(_0x9307('0x5'));var util=require('util');var path=require('path');var sox=require(_0x9307('0x6'));var csv=require(_0x9307('0x7'));var ejs=require(_0x9307('0x8'));var fs=require('fs');var fs_extra=require(_0x9307('0x9'));var _=require(_0x9307('0xa'));var squel=require('squel');var crypto=require('crypto');var jsforce=require(_0x9307('0xb'));var deskjs=require('desk.js');var toCsv=require(_0x9307('0x7'));var querystring=require(_0x9307('0xc'));var Papa=require('papaparse');var Redis=require(_0x9307('0xd'));var authService=require(_0x9307('0xe'));var qs=require(_0x9307('0xf'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require('../../config/license/hardware');var logger=require(_0x9307('0x10'))(_0x9307('0x11'));var utils=require(_0x9307('0x12'));var config=require(_0x9307('0x13'));var licenseUtil=require(_0x9307('0x14'));var db=require(_0x9307('0x15'))['db'];config['redis']=_[_0x9307('0x16')](config[_0x9307('0x17')],{'host':'localhost','port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x9307('0x17')]));require(_0x9307('0x18'))['register'](socket);function respondWithStatusCode(_0x3d9864,_0x4053e2){_0x4053e2=_0x4053e2||0xcc;return function(_0x545b0a){if(_0x545b0a){return _0x3d9864[_0x9307('0x19')](_0x4053e2);}return _0x3d9864[_0x9307('0x1a')](_0x4053e2)['end']();};}function respondWithResult(_0x3fc6fd,_0x4296e9){_0x4296e9=_0x4296e9||0xc8;return function(_0x100f15){if(_0x100f15){return _0x3fc6fd['status'](_0x4296e9)[_0x9307('0x1b')](_0x100f15);}};}function respondWithFilteredResult(_0x27682a,_0x503338){return function(_0xbba867){if(_0xbba867){var _0x3d84b0=typeof _0x503338[_0x9307('0x1c')]===_0x9307('0x1d')&&typeof _0x503338[_0x9307('0x1e')]===_0x9307('0x1d');var _0x5810d7=_0xbba867[_0x9307('0x1f')];var _0x10aa66=_0x3d84b0?0x0:_0x503338[_0x9307('0x1c')];var _0x58574e=_0x3d84b0?_0xbba867[_0x9307('0x1f')]:_0x503338[_0x9307('0x1c')]+_0x503338['limit'];var _0x307ab9;if(_0x58574e>=_0x5810d7){_0x58574e=_0x5810d7;_0x307ab9=0xc8;}else{_0x307ab9=0xce;}_0x27682a[_0x9307('0x1a')](_0x307ab9);return _0x27682a[_0x9307('0x20')](_0x9307('0x21'),_0x10aa66+'-'+_0x58574e+'/'+_0x5810d7)[_0x9307('0x1b')](_0xbba867);}return null;};}function patchUpdates(_0xf39222){return function(_0x1d671b){try{jsonpatch[_0x9307('0x22')](_0x1d671b,_0xf39222,!![]);}catch(_0x2f5f68){return BPromise[_0x9307('0x23')](_0x2f5f68);}return _0x1d671b[_0x9307('0x24')]();};}function saveUpdates(_0x5d42a0,_0x1e17c5){return function(_0x593f27){if(_0x593f27){return _0x593f27[_0x9307('0x25')](_0x5d42a0)['then'](function(_0x2c59ef){return _0x2c59ef;});}return null;};}function removeEntity(_0x5bb98a,_0x4d1a13){return function(_0x428043){if(_0x428043){return _0x428043[_0x9307('0x26')]()[_0x9307('0x27')](function(){var _0x330d48=_0x428043[_0x9307('0x28')]({'plain':!![]});var _0xd89e2f=[{'name':_0x9307('0x29'),'value':'inbound','ignore':![]},{'name':_0x9307('0x2a'),'value':'outbound','ignore':![]}];var _0x1da3e3=_(_0xd89e2f)[_0x9307('0x2b')](_0x9307('0x2c'))['map'](_0x9307('0x2d'))['value']();if(_['includes'](_0x1da3e3,_0x330d48['type'])){return;}var _0x27faa5=_['find'](_0xd89e2f,[_0x9307('0x2d'),_0x330d48[_0x9307('0x2e')]])[_0x9307('0x2f')];return db[_0x9307('0x30')][_0x9307('0x26')]({'where':{'type':_0x27faa5,'resourceId':_0x330d48['id']}})[_0x9307('0x27')](function(){return _0x428043;});})['then'](function(){_0x5bb98a[_0x9307('0x1a')](0xcc)[_0x9307('0x31')]();});}};}function handleEntityNotFound(_0x824001,_0x1f5ee1){return function(_0x34fa73){if(!_0x34fa73){_0x824001[_0x9307('0x19')](0x194);}return _0x34fa73;};}function handleError(_0x158145,_0x54ffa7){_0x54ffa7=_0x54ffa7||0x1f4;return function(_0x5b79da){logger[_0x9307('0x32')](_0x5b79da[_0x9307('0x33')]);if(_0x5b79da[_0x9307('0x2f')]){delete _0x5b79da[_0x9307('0x2f')];}_0x158145[_0x9307('0x1a')](_0x54ffa7)[_0x9307('0x34')](_0x5b79da);};}exports[_0x9307('0x35')]=function(_0x139c45,_0x8e2cb4){var _0x33a507={},_0x4df3a6={},_0x443d35={'count':0x0,'rows':[]};var _0x42595e=_[_0x9307('0x36')](db[_0x9307('0x37')][_0x9307('0x38')],function(_0x11d342){return{'name':_0x11d342[_0x9307('0x39')],'type':_0x11d342[_0x9307('0x2e')][_0x9307('0x3a')]};});_0x4df3a6[_0x9307('0x3b')]=_[_0x9307('0x36')](_0x42595e,_0x9307('0x2f'));_0x4df3a6[_0x9307('0x3c')]=_[_0x9307('0x3d')](_0x139c45['query']);_0x4df3a6[_0x9307('0x3e')]=_[_0x9307('0x3f')](_0x4df3a6[_0x9307('0x3b')],_0x4df3a6[_0x9307('0x3c')]);_0x33a507[_0x9307('0x40')]=_[_0x9307('0x3f')](_0x4df3a6[_0x9307('0x3b')],qs[_0x9307('0x41')](_0x139c45['query'][_0x9307('0x41')]));_0x33a507[_0x9307('0x40')]=_0x33a507[_0x9307('0x40')]['length']?_0x33a507[_0x9307('0x40')]:_0x4df3a6[_0x9307('0x3b')];if(!_0x139c45[_0x9307('0x3c')]['hasOwnProperty'](_0x9307('0x42'))){_0x33a507[_0x9307('0x1e')]=qs[_0x9307('0x1e')](_0x139c45[_0x9307('0x3c')]['limit']);_0x33a507['offset']=qs[_0x9307('0x1c')](_0x139c45[_0x9307('0x3c')][_0x9307('0x1c')]);}_0x33a507['order']=qs['sort'](_0x139c45[_0x9307('0x3c')]['sort']);_0x33a507[_0x9307('0x43')]=qs[_0x9307('0x3e')](_['pick'](_0x139c45[_0x9307('0x3c')],_0x4df3a6[_0x9307('0x3e')]),_0x42595e);if(_0x139c45[_0x9307('0x3c')][_0x9307('0x2b')]){_0x33a507[_0x9307('0x43')]=_[_0x9307('0x44')](_0x33a507[_0x9307('0x43')],{'$or':_[_0x9307('0x36')](_0x42595e,function(_0x593a19){if(_0x593a19['type']!=='VIRTUAL'){var _0x274598={};_0x274598[_0x593a19[_0x9307('0x2f')]]={'$like':'%'+_0x139c45[_0x9307('0x3c')][_0x9307('0x2b')]+'%'};return _0x274598;}})});}_0x33a507=_[_0x9307('0x44')]({},_0x33a507,_0x139c45[_0x9307('0x45')]);var _0x4fadc9={'where':_0x33a507['where']};return db[_0x9307('0x37')][_0x9307('0x1f')](_0x4fadc9)['then'](function(_0x1d24d3){_0x443d35['count']=_0x1d24d3;if(_0x139c45[_0x9307('0x3c')][_0x9307('0x46')]){_0x33a507['include']=[{'all':!![]}];}return db[_0x9307('0x37')][_0x9307('0x47')](_0x33a507);})[_0x9307('0x27')](function(_0x276ed5){_0x443d35[_0x9307('0x48')]=_0x276ed5;return _0x443d35;})[_0x9307('0x27')](respondWithFilteredResult(_0x8e2cb4,_0x33a507))[_0x9307('0x49')](handleError(_0x8e2cb4,null));};exports[_0x9307('0x4a')]=function(_0x57f146,_0x3ff0a4){var _0x2d2e5b={'raw':![],'where':{'id':_0x57f146[_0x9307('0x4b')]['id']}},_0x390eef={};_0x390eef[_0x9307('0x3b')]=_['keys'](db[_0x9307('0x37')]['rawAttributes']);_0x390eef['query']=_[_0x9307('0x3d')](_0x57f146[_0x9307('0x3c')]);_0x390eef[_0x9307('0x3e')]=_[_0x9307('0x3f')](_0x390eef[_0x9307('0x3b')],_0x390eef['query']);_0x2d2e5b[_0x9307('0x40')]=_['intersection'](_0x390eef[_0x9307('0x3b')],qs[_0x9307('0x41')](_0x57f146['query']['fields']));_0x2d2e5b[_0x9307('0x40')]=_0x2d2e5b[_0x9307('0x40')][_0x9307('0x4c')]?_0x2d2e5b[_0x9307('0x40')]:_0x390eef[_0x9307('0x3b')];if(_0x57f146['query'][_0x9307('0x46')]){_0x2d2e5b[_0x9307('0x4d')]=[{'all':!![]}];}_0x2d2e5b=_[_0x9307('0x44')]({},_0x2d2e5b,_0x57f146[_0x9307('0x45')]);return db['VoiceQueue']['find'](_0x2d2e5b)['then'](handleEntityNotFound(_0x3ff0a4,null))[_0x9307('0x27')](respondWithResult(_0x3ff0a4,null))['catch'](handleError(_0x3ff0a4,null));};exports[_0x9307('0x4e')]=function(_0x5bb358,_0x6272c7){return db[_0x9307('0x37')][_0x9307('0x4e')](_0x5bb358['body'],{})[_0x9307('0x27')](function(_0x1e8e32){var _0x4db0dd=_0x5bb358[_0x9307('0x4f')][_0x9307('0x28')]({'plain':!![]});if(!_0x4db0dd)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x4db0dd[_0x9307('0x50')]===_0x9307('0x4f')){var _0xf75713=_0x1e8e32[_0x9307('0x28')]({'plain':!![]});var _0x1cca54=[{'name':_0x9307('0x29'),'value':_0x9307('0x51')},{'name':'QueueCampaigns','value':'outbound'}];var _0x2268d2=_[_0x9307('0x52')](_0x1cca54,[_0x9307('0x2d'),_0xf75713['type']])[_0x9307('0x2f')];return db[_0x9307('0x53')]['find']({'where':{'name':_0x2268d2,'userProfileId':_0x4db0dd[_0x9307('0x54')]},'raw':!![]})[_0x9307('0x27')](function(_0x1bb8e1){if(_0x1bb8e1&&_0x1bb8e1['autoAssociation']===0x0){return db[_0x9307('0x30')][_0x9307('0x4e')]({'name':_0xf75713['name'],'resourceId':_0xf75713['id'],'type':_0x1bb8e1[_0x9307('0x2f')],'sectionId':_0x1bb8e1['id']},{})[_0x9307('0x27')](function(){return _0x1e8e32;});}else{return _0x1e8e32;}})[_0x9307('0x49')](function(_0x49fa2b){logger['error']('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x49fa2b);throw _0x49fa2b;});}return _0x1e8e32;})['then'](respondWithResult(_0x6272c7,0xc9))[_0x9307('0x49')](handleError(_0x6272c7,null));};exports[_0x9307('0x55')]=function(_0x34bc1e,_0x5c4907){var _0x5ec1ac={'where':{'id':_0x34bc1e[_0x9307('0x4b')]['id']}},_0x39b01d={};_0x39b01d[_0x9307('0x3b')]=_[_0x9307('0x3d')](db[_0x9307('0x37')][_0x9307('0x38')]);_0x5ec1ac['attributes']=_[_0x9307('0x3f')](_0x39b01d[_0x9307('0x3b')],qs[_0x9307('0x41')](_0x34bc1e[_0x9307('0x3c')][_0x9307('0x41')]));_0x5ec1ac['attributes']=_0x5ec1ac[_0x9307('0x40')][_0x9307('0x4c')]?_0x5ec1ac['attributes']:_0x39b01d[_0x9307('0x3b')];if(_0x34bc1e[_0x9307('0x3c')]['includeAll']){_0x5ec1ac[_0x9307('0x4d')]=[{'all':!![]}];}_0x5ec1ac=_[_0x9307('0x44')]({},_0x5ec1ac,_0x34bc1e['options']);return db[_0x9307('0x37')][_0x9307('0x52')](_0x5ec1ac)[_0x9307('0x27')](handleEntityNotFound(_0x5c4907,null))[_0x9307('0x27')](function(_0x3a6564){if(_0x3a6564){var _0x383e4d=_0x3a6564[_0x9307('0x28')]({'plain':!![]});_0x383e4d=qs[_0x9307('0x56')](_0x383e4d,['id',_0x9307('0x57'),_0x9307('0x58')]);_0x34bc1e[_0x9307('0x59')]=_[_0x9307('0x56')](_0x34bc1e['body'],['id',_0x9307('0x57'),'updatedAt']);return db[_0x9307('0x37')][_0x9307('0x4e')](_['merge'](_0x383e4d,_0x34bc1e[_0x9307('0x59')]),{'include':_0x34bc1e[_0x9307('0x3c')]['includeAll']?[{'all':!![]}]:undefined})[_0x9307('0x27')](function(_0xf5390d){var _0xdb251b=_0x34bc1e[_0x9307('0x4f')][_0x9307('0x28')]({'plain':!![]});if(!_0xdb251b)throw new Error(_0x9307('0x5a'));if(_0xdb251b['role']===_0x9307('0x4f')){var _0x1f0936=_0xf5390d[_0x9307('0x28')]({'plain':!![]});var _0x5041d3=[{'name':_0x9307('0x29'),'value':_0x9307('0x51')},{'name':_0x9307('0x2a'),'value':'outbound'}];var _0x16a62b=_[_0x9307('0x52')](_0x5041d3,['value',_0x1f0936[_0x9307('0x2e')]])[_0x9307('0x2f')];return db[_0x9307('0x53')][_0x9307('0x52')]({'where':{'name':_0x16a62b,'userProfileId':_0xdb251b[_0x9307('0x54')]},'raw':!![]})['then'](function(_0x22fc8c){if(_0x22fc8c&&_0x22fc8c[_0x9307('0x5b')]===0x0){return db['UserProfileResource']['create']({'name':_0x1f0936[_0x9307('0x2f')],'resourceId':_0x1f0936['id'],'type':_0x22fc8c['name'],'sectionId':_0x22fc8c['id']},{})['then'](function(){return _0xf5390d;});}else{return _0xf5390d;}})[_0x9307('0x49')](function(_0x2780a2){logger[_0x9307('0x32')](_0x9307('0x5c'),_0x2780a2);throw _0x2780a2;});}return _0xf5390d;});}})['then'](respondWithResult(_0x5c4907,0xc9))[_0x9307('0x49')](handleError(_0x5c4907,null));};exports[_0x9307('0x25')]=function(_0x1da55c,_0x17e344){if(_0x1da55c['body']['id']){delete _0x1da55c[_0x9307('0x59')]['id'];}return db['VoiceQueue'][_0x9307('0x52')]({'where':{'id':_0x1da55c[_0x9307('0x4b')]['id']}})[_0x9307('0x27')](handleEntityNotFound(_0x17e344,null))['then'](saveUpdates(_0x1da55c[_0x9307('0x59')],null))[_0x9307('0x27')](respondWithResult(_0x17e344,null))['catch'](handleError(_0x17e344,null));};exports[_0x9307('0x26')]=function(_0x53d490,_0x1c1351){return db[_0x9307('0x37')][_0x9307('0x52')]({'where':{'id':_0x53d490[_0x9307('0x4b')]['id']}})[_0x9307('0x27')](handleEntityNotFound(_0x1c1351,null))['then'](removeEntity(_0x1c1351,null))[_0x9307('0x49')](handleError(_0x1c1351,null));};exports[_0x9307('0x5d')]=function(_0x36d456,_0x1224b3,_0x798430){var _0x270afc={'raw':![],'where':{}};var _0x1102c7={};var _0x340e6e={'count':0x0,'rows':[]};return db['VoiceQueue'][_0x9307('0x5e')]({'where':{'id':_0x36d456[_0x9307('0x4b')]['id']}})[_0x9307('0x27')](handleEntityNotFound(_0x1224b3,null))[_0x9307('0x27')](function(_0x4e798d){if(_0x4e798d){_0x1102c7['model']=_[_0x9307('0x3d')](db['CmHopper']['rawAttributes']);_0x1102c7[_0x9307('0x3c')]=_[_0x9307('0x3d')](_0x36d456['query']);_0x1102c7[_0x9307('0x3e')]=_[_0x9307('0x3f')](_0x1102c7['model'],_0x1102c7['query']);_0x270afc[_0x9307('0x40')]=_[_0x9307('0x3f')](_0x1102c7[_0x9307('0x3b')],qs[_0x9307('0x41')](_0x36d456['query']['fields']));_0x270afc['attributes']=_0x270afc[_0x9307('0x40')][_0x9307('0x4c')]?_0x270afc[_0x9307('0x40')]:_0x1102c7[_0x9307('0x3b')];if(!_0x36d456[_0x9307('0x3c')]['hasOwnProperty'](_0x9307('0x42'))){_0x270afc[_0x9307('0x1e')]=qs[_0x9307('0x1e')](_0x36d456[_0x9307('0x3c')]['limit']);_0x270afc[_0x9307('0x1c')]=qs[_0x9307('0x1c')](_0x36d456[_0x9307('0x3c')][_0x9307('0x1c')]);}_0x270afc[_0x9307('0x5f')]=qs['sort'](_0x36d456[_0x9307('0x3c')][_0x9307('0x60')]);_0x270afc['where']=qs[_0x9307('0x3e')](_['pick'](_0x36d456[_0x9307('0x3c')],_0x1102c7[_0x9307('0x3e')]));_0x270afc['where'][_0x9307('0x61')]=_0x4e798d['id'];if(_0x36d456[_0x9307('0x3c')][_0x9307('0x2b')]){_0x270afc[_0x9307('0x43')]=_['merge'](_0x270afc[_0x9307('0x43')],{'$or':_[_0x9307('0x36')](_0x270afc[_0x9307('0x40')],function(_0x2abde0){var _0x3e1d15={};_0x3e1d15[_0x2abde0]={'$like':'%'+_0x36d456[_0x9307('0x3c')][_0x9307('0x2b')]+'%'};return _0x3e1d15;})});}_0x270afc=_[_0x9307('0x44')]({},_0x270afc,_0x36d456[_0x9307('0x45')]);return db['CmHopper'][_0x9307('0x1f')]({'where':_0x270afc[_0x9307('0x43')]})['then'](function(_0x1d37ac){_0x340e6e[_0x9307('0x1f')]=_0x1d37ac;if(_0x36d456[_0x9307('0x3c')][_0x9307('0x46')]){_0x270afc['include']=[{'all':!![]}];}return db['CmHopper'][_0x9307('0x47')](_0x270afc);})[_0x9307('0x27')](function(_0x456095){_0x340e6e[_0x9307('0x48')]=_0x456095;return _0x340e6e;});}})['then'](respondWithFilteredResult(_0x1224b3,_0x270afc))[_0x9307('0x49')](handleError(_0x1224b3,null));};exports[_0x9307('0x62')]=function(_0x4fdda9,_0x3a2290,_0x3207ba){var _0x59a5fa={'raw':!![],'where':{}};var _0x159d6f={};var _0x285d99={'count':0x0,'rows':[]};return db[_0x9307('0x37')][_0x9307('0x5e')]({'where':{'id':_0x4fdda9[_0x9307('0x4b')]['id']}})[_0x9307('0x27')](handleEntityNotFound(_0x3a2290,null))[_0x9307('0x27')](function(_0x4c8349){if(_0x4c8349){_0x159d6f[_0x9307('0x3b')]=_['keys'](db[_0x9307('0x63')][_0x9307('0x38')]);_0x159d6f[_0x9307('0x3c')]=_['keys'](_0x4fdda9[_0x9307('0x3c')]);_0x159d6f[_0x9307('0x3e')]=_['intersection'](_0x159d6f['model'],_0x159d6f[_0x9307('0x3c')]);_0x59a5fa[_0x9307('0x40')]=_[_0x9307('0x3f')](_0x159d6f[_0x9307('0x3b')],qs[_0x9307('0x41')](_0x4fdda9[_0x9307('0x3c')][_0x9307('0x41')]));_0x59a5fa['attributes']=_0x59a5fa[_0x9307('0x40')][_0x9307('0x4c')]?_0x59a5fa[_0x9307('0x40')]:_0x159d6f[_0x9307('0x3b')];if(!_0x4fdda9[_0x9307('0x3c')][_0x9307('0x64')](_0x9307('0x42'))){_0x59a5fa[_0x9307('0x1e')]=qs[_0x9307('0x1e')](_0x4fdda9[_0x9307('0x3c')][_0x9307('0x1e')]);_0x59a5fa[_0x9307('0x1c')]=qs[_0x9307('0x1c')](_0x4fdda9['query'][_0x9307('0x1c')]);}_0x59a5fa[_0x9307('0x5f')]=qs['sort'](_0x4fdda9[_0x9307('0x3c')][_0x9307('0x60')]);_0x59a5fa[_0x9307('0x43')]=qs[_0x9307('0x3e')](_[_0x9307('0x65')](_0x4fdda9[_0x9307('0x3c')],_0x159d6f['filters']));_0x59a5fa['where'][_0x9307('0x61')]=_0x4c8349['id'];if(_0x4fdda9[_0x9307('0x3c')][_0x9307('0x2b')]){_0x59a5fa[_0x9307('0x43')]=_['merge'](_0x59a5fa['where'],{'$or':_['map'](_0x59a5fa['attributes'],function(_0x8e5f70){var _0x4a14af={};_0x4a14af[_0x8e5f70]={'$like':'%'+_0x4fdda9[_0x9307('0x3c')]['filter']+'%'};return _0x4a14af;})});}_0x59a5fa=_[_0x9307('0x44')]({},_0x59a5fa,_0x4fdda9[_0x9307('0x45')]);return db[_0x9307('0x63')]['count']({'where':_0x59a5fa[_0x9307('0x43')]})[_0x9307('0x27')](function(_0x21c818){_0x285d99[_0x9307('0x1f')]=_0x21c818;if(_0x4fdda9[_0x9307('0x3c')][_0x9307('0x46')]){_0x59a5fa[_0x9307('0x4d')]=[{'all':!![]}];}return db[_0x9307('0x63')]['findAll'](_0x59a5fa);})[_0x9307('0x27')](function(_0x2c2806){_0x285d99[_0x9307('0x48')]=_0x2c2806;return _0x285d99;});}})[_0x9307('0x27')](respondWithFilteredResult(_0x3a2290,_0x59a5fa))[_0x9307('0x49')](handleError(_0x3a2290,null));};exports[_0x9307('0x66')]=function(_0x4bc9a0,_0x54b06a,_0x268b52){var _0x21e3da={'raw':!![],'where':{}};var _0x530bb0={};var _0x9e0e88={'count':0x0,'rows':[]};return db[_0x9307('0x37')][_0x9307('0x5e')]({'where':{'id':_0x4bc9a0[_0x9307('0x4b')]['id']}})[_0x9307('0x27')](handleEntityNotFound(_0x54b06a,null))[_0x9307('0x27')](function(_0x4cfdbb){if(_0x4cfdbb){_0x530bb0[_0x9307('0x3b')]=_[_0x9307('0x3d')](db['CmHopperFinal'][_0x9307('0x38')]);_0x530bb0['query']=_[_0x9307('0x3d')](_0x4bc9a0[_0x9307('0x3c')]);_0x530bb0[_0x9307('0x3e')]=_[_0x9307('0x3f')](_0x530bb0[_0x9307('0x3b')],_0x530bb0[_0x9307('0x3c')]);_0x21e3da[_0x9307('0x40')]=_[_0x9307('0x3f')](_0x530bb0[_0x9307('0x3b')],qs[_0x9307('0x41')](_0x4bc9a0[_0x9307('0x3c')][_0x9307('0x41')]));_0x21e3da[_0x9307('0x40')]=_0x21e3da[_0x9307('0x40')]['length']?_0x21e3da[_0x9307('0x40')]:_0x530bb0[_0x9307('0x3b')];if(!_0x4bc9a0[_0x9307('0x3c')][_0x9307('0x64')](_0x9307('0x42'))){_0x21e3da[_0x9307('0x1e')]=qs['limit'](_0x4bc9a0[_0x9307('0x3c')][_0x9307('0x1e')]);_0x21e3da[_0x9307('0x1c')]=qs[_0x9307('0x1c')](_0x4bc9a0[_0x9307('0x3c')][_0x9307('0x1c')]);}_0x21e3da['order']=qs[_0x9307('0x60')](_0x4bc9a0['query'][_0x9307('0x60')]);_0x21e3da[_0x9307('0x43')]=qs[_0x9307('0x3e')](_['pick'](_0x4bc9a0[_0x9307('0x3c')],_0x530bb0[_0x9307('0x3e')]));_0x21e3da[_0x9307('0x43')][_0x9307('0x61')]=_0x4cfdbb['id'];if(_0x4bc9a0[_0x9307('0x3c')][_0x9307('0x2b')]){_0x21e3da['where']=_[_0x9307('0x44')](_0x21e3da[_0x9307('0x43')],{'$or':_[_0x9307('0x36')](_0x21e3da[_0x9307('0x40')],function(_0x50014d){var _0x3bbdd1={};_0x3bbdd1[_0x50014d]={'$like':'%'+_0x4bc9a0[_0x9307('0x3c')][_0x9307('0x2b')]+'%'};return _0x3bbdd1;})});}_0x21e3da=_[_0x9307('0x44')]({},_0x21e3da,_0x4bc9a0[_0x9307('0x45')]);return db[_0x9307('0x67')]['count']({'where':_0x21e3da[_0x9307('0x43')]})['then'](function(_0x52f551){_0x9e0e88[_0x9307('0x1f')]=_0x52f551;if(_0x4bc9a0['query'][_0x9307('0x46')]){_0x21e3da['include']=[{'all':!![]}];}return db[_0x9307('0x67')]['findAll'](_0x21e3da);})[_0x9307('0x27')](function(_0x4f0994){_0x9e0e88[_0x9307('0x48')]=_0x4f0994;return _0x9e0e88;});}})[_0x9307('0x27')](respondWithFilteredResult(_0x54b06a,_0x21e3da))['catch'](handleError(_0x54b06a,null));};exports[_0x9307('0x68')]=function(_0x57c981,_0x5ee5e0,_0x5037ca){var _0x4383cb={'raw':!![],'where':{}};var _0x3e3bbf={};var _0x366e9d={'count':0x0,'rows':[]};return db[_0x9307('0x37')][_0x9307('0x5e')]({'where':{'id':_0x57c981[_0x9307('0x4b')]['id']}})[_0x9307('0x27')](handleEntityNotFound(_0x5ee5e0,null))[_0x9307('0x27')](function(_0x5dd2c3){if(_0x5dd2c3){_0x3e3bbf[_0x9307('0x3b')]=_['keys'](db['CmHopperBlack'][_0x9307('0x38')]);_0x3e3bbf[_0x9307('0x3c')]=_['keys'](_0x57c981[_0x9307('0x3c')]);_0x3e3bbf['filters']=_[_0x9307('0x3f')](_0x3e3bbf[_0x9307('0x3b')],_0x3e3bbf['query']);_0x4383cb[_0x9307('0x40')]=_['intersection'](_0x3e3bbf[_0x9307('0x3b')],qs[_0x9307('0x41')](_0x57c981[_0x9307('0x3c')]['fields']));_0x4383cb['attributes']=_0x4383cb[_0x9307('0x40')][_0x9307('0x4c')]?_0x4383cb[_0x9307('0x40')]:_0x3e3bbf[_0x9307('0x3b')];if(!_0x57c981[_0x9307('0x3c')][_0x9307('0x64')](_0x9307('0x42'))){_0x4383cb[_0x9307('0x1e')]=qs[_0x9307('0x1e')](_0x57c981['query'][_0x9307('0x1e')]);_0x4383cb[_0x9307('0x1c')]=qs[_0x9307('0x1c')](_0x57c981[_0x9307('0x3c')][_0x9307('0x1c')]);}_0x4383cb[_0x9307('0x5f')]=qs[_0x9307('0x60')](_0x57c981[_0x9307('0x3c')]['sort']);_0x4383cb[_0x9307('0x43')]=qs['filters'](_['pick'](_0x57c981[_0x9307('0x3c')],_0x3e3bbf[_0x9307('0x3e')]));_0x4383cb['where'][_0x9307('0x61')]=_0x5dd2c3['id'];if(_0x57c981[_0x9307('0x3c')][_0x9307('0x2b')]){_0x4383cb[_0x9307('0x43')]=_[_0x9307('0x44')](_0x4383cb[_0x9307('0x43')],{'$or':_[_0x9307('0x36')](_0x4383cb[_0x9307('0x40')],function(_0x45e1c1){var _0x4974dd={};_0x4974dd[_0x45e1c1]={'$like':'%'+_0x57c981[_0x9307('0x3c')][_0x9307('0x2b')]+'%'};return _0x4974dd;})});}_0x4383cb=_[_0x9307('0x44')]({},_0x4383cb,_0x57c981[_0x9307('0x45')]);return db[_0x9307('0x69')]['count']({'where':_0x4383cb[_0x9307('0x43')]})[_0x9307('0x27')](function(_0x30af84){_0x366e9d['count']=_0x30af84;if(_0x57c981[_0x9307('0x3c')]['includeAll']){_0x4383cb['include']=[{'all':!![]}];}return db[_0x9307('0x69')][_0x9307('0x47')](_0x4383cb);})[_0x9307('0x27')](function(_0x3f1920){_0x366e9d[_0x9307('0x48')]=_0x3f1920;return _0x366e9d;});}})[_0x9307('0x27')](respondWithFilteredResult(_0x5ee5e0,_0x4383cb))[_0x9307('0x49')](handleError(_0x5ee5e0,null));};exports[_0x9307('0x6a')]=function(_0x3a834d,_0x4fc7f3,_0x593e0e){var _0x19def4={};var _0x4ec335={};var _0x4cd875;var _0x44724c;return db['VoiceQueue'][_0x9307('0x5e')]({'where':{'id':_0x3a834d[_0x9307('0x4b')]['id']}})[_0x9307('0x27')](handleEntityNotFound(_0x4fc7f3,null))[_0x9307('0x27')](function(_0x4e2e2e){if(_0x4e2e2e){_0x4cd875=_0x4e2e2e;_0x4ec335['model']=_[_0x9307('0x3d')](db['Team'][_0x9307('0x38')]);_0x4ec335['query']=_['keys'](_0x3a834d[_0x9307('0x3c')]);_0x4ec335[_0x9307('0x3e')]=_[_0x9307('0x3f')](_0x4ec335[_0x9307('0x3b')],_0x4ec335[_0x9307('0x3c')]);_0x19def4[_0x9307('0x40')]=_[_0x9307('0x3f')](_0x4ec335['model'],qs[_0x9307('0x41')](_0x3a834d['query'][_0x9307('0x41')]));_0x19def4[_0x9307('0x40')]=_0x19def4[_0x9307('0x40')][_0x9307('0x4c')]?_0x19def4['attributes']:_0x4ec335[_0x9307('0x3b')];_0x19def4[_0x9307('0x5f')]=qs['sort'](_0x3a834d[_0x9307('0x3c')][_0x9307('0x60')]);_0x19def4[_0x9307('0x43')]=qs[_0x9307('0x3e')](_[_0x9307('0x65')](_0x3a834d[_0x9307('0x3c')],_0x4ec335[_0x9307('0x3e')]));if(_0x3a834d[_0x9307('0x3c')][_0x9307('0x2b')]){_0x19def4['where']=_[_0x9307('0x44')](_0x19def4[_0x9307('0x43')],{'$or':_[_0x9307('0x36')](_0x19def4[_0x9307('0x40')],function(_0x7a0d7e){var _0xf067f6={};_0xf067f6[_0x7a0d7e]={'$like':'%'+_0x3a834d['query']['filter']+'%'};return _0xf067f6;})});}_0x19def4=_[_0x9307('0x44')]({},_0x19def4,_0x3a834d[_0x9307('0x45')]);return _0x4cd875[_0x9307('0x6a')](_0x19def4);}})[_0x9307('0x27')](function(_0x96c64a){if(_0x96c64a){_0x44724c=_0x96c64a[_0x9307('0x4c')];if(!_0x3a834d[_0x9307('0x3c')][_0x9307('0x64')](_0x9307('0x42'))){_0x19def4[_0x9307('0x1e')]=qs['limit'](_0x3a834d['query'][_0x9307('0x1e')]);_0x19def4[_0x9307('0x1c')]=qs[_0x9307('0x1c')](_0x3a834d[_0x9307('0x3c')]['offset']);}return _0x4cd875[_0x9307('0x6a')](_0x19def4);}})['then'](function(_0x5562a8){if(_0x5562a8){return _0x5562a8?{'count':_0x44724c,'rows':_0x5562a8}:null;}})['then'](respondWithResult(_0x4fc7f3,null))[_0x9307('0x49')](handleError(_0x4fc7f3,null));};exports[_0x9307('0x6b')]=function(_0x216953,_0x9127d,_0x505bb4){var _0x21aeb8=_0x216953[_0x9307('0x59')]['teams'];var _0xa0bfe7=_[_0x9307('0x36')](_0x21aeb8,'id');return db[_0x9307('0x6c')][_0x9307('0x47')]({'where':{'id':_0xa0bfe7},'attributes':['id'],'include':[{'model':db[_0x9307('0x6d')],'as':'Agents','attributes':['id',_0x9307('0x2f'),_0x9307('0x6e'),'voicePause',_0x9307('0x6f')],'raw':!![]}]})['then'](function(_0x195b90){if(_0x195b90){var _0x3e166c=_['flatMap'](_0x195b90,function(_0x12f7db){var _0x4616b2=_0x12f7db['get']({'plain':!![]});_0x4616b2[_0x9307('0x70')]['forEach'](function(_0x5d5cdf){_0x5d5cdf[_0x9307('0x71')]=_['find'](_0x21aeb8,{'id':_0x4616b2['id']})['penalty'];});return _0x4616b2[_0x9307('0x70')];});return db[_0x9307('0x37')]['find']({'where':{'id':_0x216953[_0x9307('0x4b')]['id']}})['then'](function(_0x40ad77){return db[_0x9307('0x72')][_0x9307('0x73')](function(_0x21dba8){return _0x40ad77[_0x9307('0x6b')](_0xa0bfe7,{'transaction':_0x21dba8})['then'](function(){return BPromise[_0x9307('0x74')](_0x21aeb8,function(_0x1614ac){return db[_0x9307('0x75')]['upsert']({'TeamId':_0x1614ac['id'],'VoiceQueueId':_0x216953['params']['id'],'penalty':_0x1614ac[_0x9307('0x71')]},{'transaction':_0x21dba8});});})[_0x9307('0x27')](function(){return BPromise[_0x9307('0x74')](_0x3e166c,function(_0x18a44f){return db[_0x9307('0x76')][_0x9307('0x77')]({'where':{'UserId':_0x18a44f['id'],'VoiceQueueId':_0x216953[_0x9307('0x4b')]['id']},'defaults':{'penalty':_0x18a44f[_0x9307('0x71')]},'transaction':_0x21dba8});});})[_0x9307('0x27')](function(){return BPromise[_0x9307('0x74')](_[_0x9307('0x2b')](_0x3e166c,{'online':!![]}),function(_0x567681){return db[_0x9307('0x78')]['upsert']({'membername':_0x567681[_0x9307('0x2f')],'UserId':_0x567681['id'],'queue_name':_0x40ad77[_0x9307('0x2f')],'VoiceQueueId':_0x40ad77['id'],'interface':_[_0x9307('0x79')](_0x567681['interface'])?util[_0x9307('0x7a')](_0x9307('0x7b'),_0x567681[_0x9307('0x2f')]):_0x567681[_0x9307('0x6f')],'paused':_0x567681['voicePause']||![],'penalty':_0x567681[_0x9307('0x71')]},{'transaction':_0x21dba8});});})['then'](function(){_0x3e166c[_0x9307('0x7c')](function(_0x40fa18){socket[_0x9307('0x7d')]('userVoiceQueue:save',{'UserId':_0x40fa18['id'],'VoiceQueueId':_0x40ad77['id']});});});});});}})[_0x9307('0x27')](respondWithStatusCode(_0x9127d,null))['catch'](handleError(_0x9127d,null));};exports[_0x9307('0x7e')]=function(_0x21a4de,_0x9a6f62,_0x5b946a){return db[_0x9307('0x6c')][_0x9307('0x47')]({'where':{'id':_0x21a4de['query'][_0x9307('0x7f')]},'attributes':['id'],'include':[{'model':db[_0x9307('0x6d')],'as':_0x9307('0x70'),'attributes':['id'],'raw':!![]}]})[_0x9307('0x27')](handleEntityNotFound(_0x9a6f62,null))[_0x9307('0x27')](function(_0x38239d){var _0x4010a5=_[_0x9307('0x36')](_0x38239d,'id');var _0x5e93a2=[];var _0x6c402=[];var _0x157f7e=squel[_0x9307('0x80')]();_0x157f7e[_0x9307('0x81')](_0x9307('0x82'))[_0x9307('0x83')]('team_has_voice_queues','tq')['join'](_0x9307('0x84'),'ut',_0x9307('0x85'))[_0x9307('0x43')](_0x9307('0x86'),_0x21a4de[_0x9307('0x4b')]['id']);for(var _0x4219a1=0x0;_0x4219a1<_0x38239d[_0x9307('0x4c')];_0x4219a1+=0x1){let _0x2f75d3=_0x38239d[_0x4219a1];for(var _0x114cf5=0x0;_0x114cf5<_0x2f75d3[_0x9307('0x70')][_0x9307('0x4c')];_0x114cf5+=0x1){let _0xb2905f=_0x2f75d3[_0x9307('0x70')][_0x114cf5];var _0x10ae91=_0x157f7e[_0x9307('0x55')]();_0x10ae91[_0x9307('0x43')](_0x9307('0x87'),_0xb2905f['id']);_0x6c402[_0x9307('0x88')](db[_0x9307('0x72')][_0x9307('0x3c')](_0x10ae91[_0x9307('0x89')](),{'type':db['sequelize'][_0x9307('0x8a')][_0x9307('0x8b')]})[_0x9307('0x27')](function(_0x4ce6d5){if(_0x4ce6d5['length']===0x1){return _0xb2905f['id'];}else{var _0x359031=_[_0x9307('0x8c')](_[_0x9307('0x36')](_0x4ce6d5,_0x9307('0x8d')),function(_0x4b7d15){return _['includes'](_0x4010a5,_0x4b7d15);});if(_0x359031){return _0xb2905f['id'];}}}));}}return BPromise[_0x9307('0x8e')](_0x6c402)[_0x9307('0x27')](function(_0x49cca6){_0x5e93a2=_(_0x5e93a2)[_0x9307('0x8f')](_0x49cca6)[_0x9307('0x90')]()[_0x9307('0x2d')]();return db[_0x9307('0x37')][_0x9307('0x52')]({'where':{'id':_0x21a4de[_0x9307('0x4b')]['id']}})['then'](function(_0x4c0366){return db[_0x9307('0x72')][_0x9307('0x73')](function(_0x2dfced){return _0x4c0366[_0x9307('0x7e')](_0x21a4de[_0x9307('0x3c')][_0x9307('0x7f')],{'transaction':_0x2dfced})[_0x9307('0x27')](function(){if(!_[_0x9307('0x91')](_0x5e93a2)){return _0x4c0366[_0x9307('0x92')](_0x5e93a2,{'transaction':_0x2dfced})[_0x9307('0x27')](function(){return db['UserVoiceQueueRt']['destroy']({'where':{'VoiceQueueId':_0x21a4de[_0x9307('0x4b')]['id'],'UserId':_0x5e93a2},'transaction':_0x2dfced});});}})[_0x9307('0x27')](function(){_0x5e93a2[_0x9307('0x7c')](function(_0x366059){socket[_0x9307('0x7d')](_0x9307('0x93'),{'UserId':_0x366059,'VoiceQueueId':_0x4c0366['id']});});});});});});})['then'](respondWithStatusCode(_0x9a6f62,null))[_0x9307('0x49')](handleError(_0x9a6f62,null));};exports[_0x9307('0x94')]=function(_0x13a4b7,_0x517ce5,_0x303946){var _0x4daf38,_0xc8877b;return db[_0x9307('0x37')][_0x9307('0x52')]({'where':{'id':_0x13a4b7[_0x9307('0x4b')]['id']}})[_0x9307('0x27')](handleEntityNotFound(_0x517ce5,null))[_0x9307('0x27')](function(_0x1c02fa){if(_0x1c02fa){_0xc8877b=_0x1c02fa;return _0x1c02fa[_0x9307('0x94')](_0x13a4b7['body'][_0x9307('0x7f')],_[_0x9307('0x56')](_0x13a4b7[_0x9307('0x59')],[_0x9307('0x7f'),'id'])||{})[_0x9307('0x95')](function(_0x23bc4a){for(var _0x4175b4=0x0;_0x4175b4<_0x13a4b7[_0x9307('0x59')][_0x9307('0x7f')][_0x9307('0x4c')];_0x4175b4+=0x1){socket[_0x9307('0x7d')](_0x9307('0x96'),{'UserId':Number(_0x13a4b7['body']['ids'][_0x4175b4]),'VoiceQueueId':Number(_0x13a4b7[_0x9307('0x4b')]['id'])});}return _0x23bc4a;});}})[_0x9307('0x27')](function(_0x536930){_0x4daf38=_0x536930||[];if(_0xc8877b){return db[_0x9307('0x6d')][_0x9307('0x47')]({'where':{'id':_0x13a4b7[_0x9307('0x59')][_0x9307('0x7f')]},'attributes':['id',_0x9307('0x2f'),_0x9307('0x6e'),_0x9307('0x97'),_0x9307('0x6f')],'raw':!![]});}})[_0x9307('0x27')](function(_0xa95202){if(!_[_0x9307('0x91')](_0xa95202)){var _0x17b856=[];for(var _0x12f595=0x0;_0x12f595<_0xa95202[_0x9307('0x4c')];_0x12f595++){if(_0xa95202[_0x12f595][_0x9307('0x6e')]){_0x17b856[_0x9307('0x88')](db[_0x9307('0x78')]['upsert']({'membername':_0xa95202[_0x12f595]['name'],'UserId':_0xa95202[_0x12f595]['id'],'queue_name':_0xc8877b[_0x9307('0x2f')],'VoiceQueueId':_0xc8877b['id'],'interface':_[_0x9307('0x79')](_0xa95202[_0x12f595]['interface'])?util[_0x9307('0x7a')](_0x9307('0x7b'),_0xa95202[_0x12f595][_0x9307('0x2f')]):_0xa95202[_0x12f595][_0x9307('0x6f')],'paused':_0xa95202[_0x12f595]['voicePause']||![],'penalty':_0x13a4b7['body'][_0x9307('0x71')]||0x0}));}}return BPromise[_0x9307('0x8e')](_0x17b856);}})['then'](function(){return _0x4daf38;})[_0x9307('0x27')](respondWithResult(_0x517ce5,null))[_0x9307('0x49')](handleError(_0x517ce5,null));};exports[_0x9307('0x92')]=function(_0x2d8ea9,_0x484f1c,_0x310402){return db[_0x9307('0x37')][_0x9307('0x52')]({'where':{'id':_0x2d8ea9[_0x9307('0x4b')]['id']}})[_0x9307('0x27')](handleEntityNotFound(_0x484f1c,null))[_0x9307('0x27')](function(_0x3e4fec){if(_0x3e4fec){return _0x3e4fec[_0x9307('0x92')](_0x2d8ea9['query'][_0x9307('0x7f')])[_0x9307('0x27')](function(){if(_[_0x9307('0x98')](_0x2d8ea9['query'][_0x9307('0x7f')])){for(var _0x51ffd0=0x0;_0x51ffd0<_0x2d8ea9[_0x9307('0x3c')][_0x9307('0x7f')][_0x9307('0x4c')];_0x51ffd0+=0x1){socket[_0x9307('0x7d')]('userVoiceQueue:remove',{'UserId':Number(_0x2d8ea9[_0x9307('0x3c')][_0x9307('0x7f')][_0x51ffd0]),'VoiceQueueId':Number(_0x2d8ea9[_0x9307('0x4b')]['id'])});}}else{socket[_0x9307('0x7d')]('userVoiceQueue:remove',{'UserId':Number(_0x2d8ea9[_0x9307('0x3c')][_0x9307('0x7f')]),'VoiceQueueId':Number(_0x2d8ea9[_0x9307('0x4b')]['id'])});}});}})[_0x9307('0x27')](function(_0x56e69e){return db[_0x9307('0x78')][_0x9307('0x26')]({'where':{'VoiceQueueId':_0x2d8ea9[_0x9307('0x4b')]['id'],'UserId':_0x2d8ea9[_0x9307('0x3c')][_0x9307('0x7f')]}})[_0x9307('0x27')](function(){return _0x56e69e;});})[_0x9307('0x27')](respondWithStatusCode(_0x484f1c,null))['catch'](handleError(_0x484f1c,null));};exports[_0x9307('0x99')]=function(_0x55f414,_0x5d69d6,_0x36c195){var _0x3f020b={};var _0x166c73={};var _0x5c3b81;var _0x229499;return db[_0x9307('0x37')][_0x9307('0x5e')]({'where':{'id':_0x55f414['params']['id']}})[_0x9307('0x27')](handleEntityNotFound(_0x5d69d6,null))['then'](function(_0x193d52){if(_0x193d52){_0x5c3b81=_0x193d52;_0x166c73[_0x9307('0x3b')]=_['keys'](db[_0x9307('0x6d')][_0x9307('0x38')]);_0x166c73['query']=_['keys'](_0x55f414['query']);_0x166c73['filters']=_[_0x9307('0x3f')](_0x166c73[_0x9307('0x3b')],_0x166c73['query']);_0x3f020b[_0x9307('0x40')]=_['intersection'](_0x166c73[_0x9307('0x3b')],qs[_0x9307('0x41')](_0x55f414[_0x9307('0x3c')][_0x9307('0x41')]));_0x3f020b['attributes']=_0x3f020b[_0x9307('0x40')]['length']?_0x3f020b[_0x9307('0x40')]:_0x166c73[_0x9307('0x3b')];_0x3f020b[_0x9307('0x5f')]=qs[_0x9307('0x60')](_0x55f414[_0x9307('0x3c')][_0x9307('0x60')]);_0x3f020b['where']=qs[_0x9307('0x3e')](_['pick'](_0x55f414[_0x9307('0x3c')],_0x166c73[_0x9307('0x3e')]));if(_0x55f414[_0x9307('0x3c')]['filter']){_0x3f020b['where']=_[_0x9307('0x44')](_0x3f020b['where'],{'$or':_[_0x9307('0x36')](_0x3f020b[_0x9307('0x40')],function(_0x1be923){var _0x146962={};_0x146962[_0x1be923]={'$like':'%'+_0x55f414[_0x9307('0x3c')]['filter']+'%'};return _0x146962;})});}_0x3f020b=_[_0x9307('0x44')]({},_0x3f020b,_0x55f414[_0x9307('0x45')]);return _0x5c3b81['getAgents'](_0x3f020b);}})[_0x9307('0x27')](function(_0x375280){if(_0x375280){_0x229499=_0x375280['length'];if(!_0x55f414['query'][_0x9307('0x64')](_0x9307('0x42'))){_0x3f020b[_0x9307('0x1e')]=qs[_0x9307('0x1e')](_0x55f414[_0x9307('0x3c')][_0x9307('0x1e')]);_0x3f020b[_0x9307('0x1c')]=qs[_0x9307('0x1c')](_0x55f414[_0x9307('0x3c')]['offset']);}return _0x5c3b81[_0x9307('0x99')](_0x3f020b);}})[_0x9307('0x27')](function(_0xce8c88){if(_0xce8c88){return _0xce8c88?{'count':_0x229499,'rows':_0xce8c88}:null;}})[_0x9307('0x27')](respondWithResult(_0x5d69d6,null))['catch'](handleError(_0x5d69d6,null));};exports[_0x9307('0x9a')]=function(_0x3301c3,_0x1daf74,_0x3db4cc){var _0x4dd2e4={};var _0x5baf63={};var _0x73d1aa;var _0xed5cfa;return db[_0x9307('0x37')][_0x9307('0x5e')]({'where':{'id':_0x3301c3[_0x9307('0x4b')]['id']}})[_0x9307('0x27')](handleEntityNotFound(_0x1daf74,null))[_0x9307('0x27')](function(_0x1495af){if(_0x1495af){_0x73d1aa=_0x1495af;_0x5baf63['model']=_['keys'](db['UserVoiceQueueRt'][_0x9307('0x38')]);_0x5baf63[_0x9307('0x3c')]=_[_0x9307('0x3d')](_0x3301c3[_0x9307('0x3c')]);_0x5baf63['filters']=_[_0x9307('0x3f')](_0x5baf63['model'],_0x5baf63[_0x9307('0x3c')]);_0x4dd2e4['attributes']=_[_0x9307('0x3f')](_0x5baf63[_0x9307('0x3b')],qs['fields'](_0x3301c3[_0x9307('0x3c')][_0x9307('0x41')]));_0x4dd2e4[_0x9307('0x40')]=_0x4dd2e4[_0x9307('0x40')][_0x9307('0x4c')]?_0x4dd2e4[_0x9307('0x40')]:_0x5baf63[_0x9307('0x3b')];_0x4dd2e4[_0x9307('0x5f')]=qs['sort'](_0x3301c3['query']['sort']);_0x4dd2e4[_0x9307('0x43')]=qs[_0x9307('0x3e')](_[_0x9307('0x65')](_0x3301c3[_0x9307('0x3c')],_0x5baf63[_0x9307('0x3e')]));if(_0x3301c3['query'][_0x9307('0x2b')]){_0x4dd2e4[_0x9307('0x43')]=_['merge'](_0x4dd2e4[_0x9307('0x43')],{'$or':_[_0x9307('0x36')](_0x4dd2e4[_0x9307('0x40')],function(_0x324fa9){var _0x4b106c={};_0x4b106c[_0x324fa9]={'$like':'%'+_0x3301c3[_0x9307('0x3c')]['filter']+'%'};return _0x4b106c;})});}_0x4dd2e4=_[_0x9307('0x44')]({},_0x4dd2e4,_0x3301c3[_0x9307('0x45')]);return _0x73d1aa['getMembers'](_0x4dd2e4);}})[_0x9307('0x27')](function(_0x2743f5){if(_0x2743f5){_0xed5cfa=_0x2743f5[_0x9307('0x4c')];if(!_0x3301c3[_0x9307('0x3c')][_0x9307('0x64')](_0x9307('0x42'))){_0x4dd2e4[_0x9307('0x1e')]=qs[_0x9307('0x1e')](_0x3301c3[_0x9307('0x3c')][_0x9307('0x1e')]);_0x4dd2e4[_0x9307('0x1c')]=qs[_0x9307('0x1c')](_0x3301c3[_0x9307('0x3c')][_0x9307('0x1c')]);}return _0x73d1aa['getMembers'](_0x4dd2e4);}})[_0x9307('0x27')](function(_0x434a7b){return _0x434a7b?{'count':_0xed5cfa,'rows':_0x434a7b}:null;})[_0x9307('0x27')](respondWithResult(_0x1daf74,null))[_0x9307('0x49')](handleError(_0x1daf74,null));};exports[_0x9307('0x9b')]=function(_0x413d86,_0x444e17,_0x4c9cdf){var _0xaf6e35={};var _0x33cd1={};var _0x3e3834;var _0x456589;return db[_0x9307('0x37')][_0x9307('0x5e')]({'where':{'id':_0x413d86[_0x9307('0x4b')]['id']}})[_0x9307('0x27')](handleEntityNotFound(_0x444e17,null))['then'](function(_0x7f93de){if(_0x7f93de){_0x3e3834=_0x7f93de;_0x33cd1[_0x9307('0x3b')]=_[_0x9307('0x3d')](db[_0x9307('0x9c')]['rawAttributes']);_0x33cd1['query']=_['keys'](_0x413d86[_0x9307('0x3c')]);_0x33cd1['filters']=_[_0x9307('0x3f')](_0x33cd1[_0x9307('0x3b')],_0x33cd1[_0x9307('0x3c')]);_0xaf6e35[_0x9307('0x40')]=_['intersection'](_0x33cd1[_0x9307('0x3b')],qs[_0x9307('0x41')](_0x413d86[_0x9307('0x3c')][_0x9307('0x41')]));_0xaf6e35[_0x9307('0x40')]=_0xaf6e35[_0x9307('0x40')][_0x9307('0x4c')]?_0xaf6e35['attributes']:_0x33cd1[_0x9307('0x3b')];_0xaf6e35['order']=qs[_0x9307('0x60')](_0x413d86[_0x9307('0x3c')]['sort']);_0xaf6e35[_0x9307('0x43')]=qs[_0x9307('0x3e')](_[_0x9307('0x65')](_0x413d86['query'],_0x33cd1[_0x9307('0x3e')]));if(_0x413d86[_0x9307('0x3c')][_0x9307('0x2b')]){_0xaf6e35['where']=_['merge'](_0xaf6e35[_0x9307('0x43')],{'$or':_[_0x9307('0x36')](_0xaf6e35[_0x9307('0x40')],function(_0x447171){var _0x560f62={};_0x560f62[_0x447171]={'$like':'%'+_0x413d86['query'][_0x9307('0x2b')]+'%'};return _0x560f62;})});}_0xaf6e35=_[_0x9307('0x44')]({},_0xaf6e35,_0x413d86[_0x9307('0x45')]);return _0x3e3834['getLists'](_0xaf6e35);}})['then'](function(_0x2b054a){if(_0x2b054a){_0x456589=_0x2b054a[_0x9307('0x4c')];if(!_0x413d86[_0x9307('0x3c')][_0x9307('0x64')](_0x9307('0x42'))){_0xaf6e35[_0x9307('0x1e')]=qs[_0x9307('0x1e')](_0x413d86['query'][_0x9307('0x1e')]);_0xaf6e35[_0x9307('0x1c')]=qs[_0x9307('0x1c')](_0x413d86[_0x9307('0x3c')][_0x9307('0x1c')]);}return _0x3e3834[_0x9307('0x9b')](_0xaf6e35);}})[_0x9307('0x27')](function(_0x3373cf){if(_0x3373cf){return _0x3373cf?{'count':_0x456589,'rows':_0x3373cf}:null;}})['then'](respondWithResult(_0x444e17,null))[_0x9307('0x49')](handleError(_0x444e17,null));};exports[_0x9307('0x9d')]=function(_0x1b58c5,_0xa13cd1,_0x58b692){var _0x1b564d=moment()[_0x9307('0x7a')](_0x9307('0x9e'));var _0x1cd08c,_0x4631ec;return db[_0x9307('0x37')][_0x9307('0x52')]({'where':{'id':_0x1b58c5[_0x9307('0x4b')]['id']}})[_0x9307('0x27')](handleEntityNotFound(_0xa13cd1,null))[_0x9307('0x27')](function(_0x2f7ad9){if(_0x2f7ad9){_0x4631ec=_0x2f7ad9;return _0x2f7ad9[_0x9307('0x9d')](_0x1b58c5[_0x9307('0x59')][_0x9307('0x7f')],_[_0x9307('0x56')](_0x1b58c5['body'],[_0x9307('0x7f'),'id'])||{});}return null;})[_0x9307('0x95')](function(_0x3c140e){var _0x4da62e;_0x1cd08c=_0x3c140e||[];var _0x25f206=[];if(_0x3c140e){for(var _0x501875=0x0;_0x501875<_0x3c140e[_0x9307('0x4c')];_0x501875+=0x1){var _0x534638=_0x3c140e[_0x501875][_0x9307('0x28')]({'plain':!![]});_0x4631ec[_0x9307('0x9f')]=_0x1b58c5[_0x9307('0x59')]['dialCheckDuplicateType']?_0x1b58c5[_0x9307('0x59')][_0x9307('0x9f')]:_0x4631ec[_0x9307('0x9f')];switch(_0x4631ec[_0x9307('0x9f')]){case _0x9307('0xa0'):_0x4da62e=squel[_0x9307('0xa1')]()[_0x9307('0xa2')](_0x9307('0xa3'))[_0x9307('0xa4')](['phone',_0x9307('0xa5'),_0x9307('0xa6'),'ListId',_0x9307('0x61'),_0x9307('0x57'),_0x9307('0x58')],squel[_0x9307('0x80')]()[_0x9307('0x81')](_0x9307('0xa7'),_0x9307('0xa7'))[_0x9307('0x81')]('\x27'+_0x1b564d+'\x27',_0x9307('0xa5'))[_0x9307('0x81')]('id',_0x9307('0xa6'))[_0x9307('0x81')](_0x534638[_0x9307('0xa8')]['toString'](),_0x9307('0xa9'))[_0x9307('0x81')](_0x1b58c5['params']['id'][_0x9307('0x89')](),_0x9307('0x61'))[_0x9307('0x81')]('\x27'+_0x1b564d+'\x27',_0x9307('0x57'))[_0x9307('0x81')]('\x27'+_0x1b564d+'\x27',_0x9307('0x58'))[_0x9307('0x83')](_0x9307('0xaa'))[_0x9307('0x43')]('deletedAt\x20IS\x20NULL')[_0x9307('0x43')](_0x9307('0xab'),_0x534638[_0x9307('0xa8')][_0x9307('0x89')]())[_0x9307('0x43')](_0x9307('0xac'))[_0x9307('0x43')](_0x9307('0xad'),squel[_0x9307('0x80')]()[_0x9307('0x81')]('COALESCE(calleridnum,\x27\x27)')[_0x9307('0x83')](_0x9307('0xae'))[_0x9307('0x43')](_0x9307('0x86'),_0x1b58c5[_0x9307('0x4b')]['id'][_0x9307('0x89')]()))[_0x9307('0x43')]('phone\x20NOT\x20IN\x20(?)',squel[_0x9307('0x80')]()[_0x9307('0x81')](_0x9307('0xaf'))['from']('cm_hopper')[_0x9307('0x43')](_0x9307('0x86'),_0x1b58c5['params']['id'][_0x9307('0x89')]())))[_0x9307('0x89')]();break;case _0x9307('0xb0'):_0x4da62e=squel[_0x9307('0xa1')]()[_0x9307('0xa2')](_0x9307('0xa3'))[_0x9307('0xa4')]([_0x9307('0xa7'),'scheduledAt',_0x9307('0xa6'),_0x9307('0xa9'),'VoiceQueueId','createdAt',_0x9307('0x58')],squel[_0x9307('0x80')]()[_0x9307('0x81')](_0x9307('0xa7'),_0x9307('0xa7'))[_0x9307('0x81')]('\x27'+_0x1b564d+'\x27',_0x9307('0xa5'))[_0x9307('0x81')]('id','ContactId')[_0x9307('0x81')](_0x534638[_0x9307('0xa8')][_0x9307('0x89')](),_0x9307('0xa9'))[_0x9307('0x81')](_0x1b58c5[_0x9307('0x4b')]['id'][_0x9307('0x89')](),_0x9307('0x61'))['field']('\x27'+_0x1b564d+'\x27',_0x9307('0x57'))['field']('\x27'+_0x1b564d+'\x27',_0x9307('0x58'))['from'](_0x9307('0xaa'))['where'](_0x9307('0xb1'))[_0x9307('0x43')](_0x9307('0xab'),_0x534638[_0x9307('0xa8')]['toString']())[_0x9307('0x43')](_0x9307('0xac'))['where']('phone\x20NOT\x20IN\x20(?)',squel[_0x9307('0x80')]()[_0x9307('0x81')]('COALESCE(phone,\x27\x27)')[_0x9307('0x83')](_0x9307('0xa3'))[_0x9307('0x43')](_0x9307('0x86'),_0x1b58c5['params']['id']['toString']())))[_0x9307('0x89')]();break;default:_0x4da62e=squel['insert']()[_0x9307('0xa2')](_0x9307('0xa3'))['fromQuery']([_0x9307('0xa7'),_0x9307('0xa5'),_0x9307('0xa6'),_0x9307('0xa9'),_0x9307('0x61'),_0x9307('0x57'),_0x9307('0x58')],squel['select']()[_0x9307('0x81')](_0x9307('0xa7'),_0x9307('0xa7'))['field']('\x27'+_0x1b564d+'\x27',_0x9307('0xa5'))[_0x9307('0x81')]('id',_0x9307('0xa6'))['field'](_0x534638[_0x9307('0xa8')][_0x9307('0x89')](),_0x9307('0xa9'))['field'](_0x1b58c5[_0x9307('0x4b')]['id'][_0x9307('0x89')](),_0x9307('0x61'))[_0x9307('0x81')]('\x27'+_0x1b564d+'\x27',_0x9307('0x57'))['field']('\x27'+_0x1b564d+'\x27','updatedAt')[_0x9307('0x83')](_0x9307('0xaa'))[_0x9307('0x43')](_0x9307('0xb1'))[_0x9307('0x43')](_0x9307('0xab'),_0x534638[_0x9307('0xa8')]['toString']())[_0x9307('0x43')]('phone\x20IS\x20NOT\x20NULL'))['toString']();}_0x25f206[_0x9307('0x88')](db['sequelize'][_0x9307('0x3c')](_0x4da62e));}return BPromise['all'](_0x25f206);}})[_0x9307('0x27')](function(){var _0x7d82bc=[];var _0x21a33b=squel['insert']()[_0x9307('0xa2')](_0x9307('0xb2'))[_0x9307('0xa4')](['CmHopperId',_0x9307('0xa7'),_0x9307('0xb3'),'createdAt',_0x9307('0x58')],squel[_0x9307('0x80')]()[_0x9307('0x81')](_0x9307('0xb4'))[_0x9307('0x81')](_0x9307('0xb5'))[_0x9307('0x81')](_0x9307('0xb6'))[_0x9307('0x81')]('\x27'+_0x1b564d+'\x27',_0x9307('0x57'))[_0x9307('0x81')]('\x27'+_0x1b564d+'\x27','updatedAt')['from'](_0x9307('0xb7'),'ci')['join']('cm_hopper','h',_0x9307('0xb8'))['where'](_0x9307('0xb9'),_0x1b564d)['where'](_0x9307('0xba'),_0x9307('0xbb')))[_0x9307('0x89')]();_0x7d82bc[_0x9307('0x88')](db[_0x9307('0x72')][_0x9307('0x3c')](_0x21a33b));return BPromise[_0x9307('0x8e')](_0x7d82bc);})[_0x9307('0x27')](function(){return _0x1cd08c;})[_0x9307('0x27')](respondWithResult(_0xa13cd1,null))[_0x9307('0x49')](handleError(_0xa13cd1,null));};exports[_0x9307('0xbc')]=function(_0x4e62f8,_0x40d1c3,_0x33495e){return db['VoiceQueue'][_0x9307('0x52')]({'where':{'id':_0x4e62f8[_0x9307('0x4b')]['id']}})[_0x9307('0x27')](handleEntityNotFound(_0x40d1c3,null))['then'](function(_0xc41ba3){if(_0xc41ba3){return _0xc41ba3['removeLists'](_0x4e62f8[_0x9307('0x3c')]['ids']);}})[_0x9307('0x27')](function(_0x116e55){if(_0x116e55){return db[_0x9307('0xbd')][_0x9307('0x26')]({'where':{'ListId':_0x4e62f8[_0x9307('0x3c')][_0x9307('0x7f')],'VoiceQueueId':_0x4e62f8[_0x9307('0x4b')]['id']}})['then'](function(){return _0x116e55;});}})[_0x9307('0x27')](respondWithStatusCode(_0x40d1c3,null))['catch'](handleError(_0x40d1c3,null));};exports[_0x9307('0xbe')]=function(_0x58167e,_0x2abb5e,_0x1a6cd5){var _0x5ec693={};var _0x4e28ed={};var _0x387e30;var _0x37a9ac;return db[_0x9307('0x37')][_0x9307('0x5e')]({'where':{'id':_0x58167e[_0x9307('0x4b')]['id']}})['then'](handleEntityNotFound(_0x2abb5e,null))['then'](function(_0x1490ff){if(_0x1490ff){_0x387e30=_0x1490ff;_0x4e28ed[_0x9307('0x3b')]=_[_0x9307('0x3d')](db[_0x9307('0x9c')][_0x9307('0x38')]);_0x4e28ed[_0x9307('0x3c')]=_[_0x9307('0x3d')](_0x58167e['query']);_0x4e28ed['filters']=_[_0x9307('0x3f')](_0x4e28ed[_0x9307('0x3b')],_0x4e28ed[_0x9307('0x3c')]);_0x5ec693['attributes']=_[_0x9307('0x3f')](_0x4e28ed[_0x9307('0x3b')],qs[_0x9307('0x41')](_0x58167e[_0x9307('0x3c')]['fields']));_0x5ec693[_0x9307('0x40')]=_0x5ec693['attributes'][_0x9307('0x4c')]?_0x5ec693[_0x9307('0x40')]:_0x4e28ed['model'];_0x5ec693[_0x9307('0x5f')]=qs[_0x9307('0x60')](_0x58167e[_0x9307('0x3c')][_0x9307('0x60')]);_0x5ec693[_0x9307('0x43')]=qs[_0x9307('0x3e')](_[_0x9307('0x65')](_0x58167e[_0x9307('0x3c')],_0x4e28ed[_0x9307('0x3e')]));if(_0x58167e[_0x9307('0x3c')][_0x9307('0x2b')]){_0x5ec693['where']=_[_0x9307('0x44')](_0x5ec693['where'],{'$or':_[_0x9307('0x36')](_0x5ec693['attributes'],function(_0x29b0c3){var _0x1fa8c9={};_0x1fa8c9[_0x29b0c3]={'$like':'%'+_0x58167e[_0x9307('0x3c')][_0x9307('0x2b')]+'%'};return _0x1fa8c9;})});}_0x5ec693=_[_0x9307('0x44')]({},_0x5ec693,_0x58167e['options']);return _0x387e30[_0x9307('0xbe')](_0x5ec693);}})[_0x9307('0x27')](function(_0x33270c){if(_0x33270c){_0x37a9ac=_0x33270c[_0x9307('0x4c')];if(!_0x58167e[_0x9307('0x3c')][_0x9307('0x64')](_0x9307('0x42'))){_0x5ec693[_0x9307('0x1e')]=qs[_0x9307('0x1e')](_0x58167e['query']['limit']);_0x5ec693[_0x9307('0x1c')]=qs[_0x9307('0x1c')](_0x58167e['query']['offset']);}return _0x387e30[_0x9307('0xbe')](_0x5ec693);}})[_0x9307('0x27')](function(_0x4f1234){if(_0x4f1234){return _0x4f1234?{'count':_0x37a9ac,'rows':_0x4f1234}:null;}})[_0x9307('0x27')](respondWithResult(_0x2abb5e,null))[_0x9307('0x49')](handleError(_0x2abb5e,null));};exports[_0x9307('0xbf')]=function(_0x3ac422,_0x31b34e,_0x49774c){var _0x2e6975,_0x1ba90d;return db[_0x9307('0x37')][_0x9307('0x52')]({'where':{'id':_0x3ac422[_0x9307('0x4b')]['id']}})[_0x9307('0x27')](handleEntityNotFound(_0x31b34e,null))['then'](function(_0x2ffb3e){if(_0x2ffb3e){_0x1ba90d=_0x2ffb3e;return _0x2ffb3e[_0x9307('0xbf')](_0x3ac422[_0x9307('0x59')][_0x9307('0x7f')],_[_0x9307('0x56')](_0x3ac422[_0x9307('0x59')],['ids','id'])||{});}return null;})[_0x9307('0x95')](function(_0x242835){var _0x13fd0f;_0x2e6975=_0x242835||[];var _0x4b547f=[];if(_0x242835){for(var _0x4c2086=0x0;_0x4c2086<_0x242835[_0x9307('0x4c')];_0x4c2086+=0x1){var _0x29fdf6=_0x242835[_0x4c2086][_0x9307('0x28')]({'plain':!![]});_0x13fd0f=squel[_0x9307('0xa1')]()[_0x9307('0xa2')](_0x9307('0xc0'))['fromQuery']([_0x9307('0xa7'),_0x9307('0xa6'),_0x9307('0xa9'),'VoiceQueueId',_0x9307('0x57'),_0x9307('0x58')],squel[_0x9307('0x80')]()[_0x9307('0x81')](_0x9307('0xa7'),'phone')[_0x9307('0x81')]('id',_0x9307('0xa6'))[_0x9307('0x81')](_0x29fdf6[_0x9307('0xa8')][_0x9307('0x89')](),_0x9307('0xa9'))[_0x9307('0x81')](_0x3ac422['params']['id'][_0x9307('0x89')](),'VoiceQueueId')[_0x9307('0x81')](_0x9307('0xc1'),_0x9307('0x57'))[_0x9307('0x81')](_0x9307('0xc1'),_0x9307('0x58'))[_0x9307('0x83')](_0x9307('0xaa'))[_0x9307('0x43')]('deletedAt\x20IS\x20NULL')['where']('ListId\x20=\x20?',_0x29fdf6[_0x9307('0xa8')]['toString']())[_0x9307('0x43')](_0x9307('0xac')))[_0x9307('0x89')]();_0x4b547f['push'](db[_0x9307('0x72')][_0x9307('0x3c')](_0x13fd0f));}return BPromise[_0x9307('0x8e')](_0x4b547f);}})['then'](function(){return _0x2e6975;})[_0x9307('0x27')](respondWithResult(_0x31b34e,null))[_0x9307('0x49')](handleError(_0x31b34e,null));};exports[_0x9307('0xc2')]=function(_0x5a9f60,_0x20cb54,_0xfb3a2){return db[_0x9307('0x37')]['find']({'where':{'id':_0x5a9f60['params']['id']}})[_0x9307('0x27')](handleEntityNotFound(_0x20cb54,null))[_0x9307('0x27')](function(_0x4842d4){if(_0x4842d4){return _0x4842d4[_0x9307('0xc2')](_0x5a9f60['query']['ids']);}})[_0x9307('0x27')](function(_0x190875){if(_0x190875){return db['CmHopperBlack'][_0x9307('0x26')]({'where':{'ListId':_0x5a9f60[_0x9307('0x3c')][_0x9307('0x7f')],'VoiceQueueId':_0x5a9f60[_0x9307('0x4b')]['id']}})[_0x9307('0x27')](function(){return _0x190875;});}})['then'](respondWithStatusCode(_0x20cb54,null))['catch'](handleError(_0x20cb54,null));};
\ No newline at end of file