Built motion from commit (unavailable).|2.5.26
[motion2.git] / server / api / voiceQueue / voiceQueue.controller.js
index 6ce18ae..37e6237 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xe626=['isArray','getAgents','getMembers','CmList','getLists','addLists','dialCheckDuplicateType','insert','into','cm_hopper','fromQuery','scheduledAt','ContactId','ListId','select','phone','NOW()','cm_contacts','CmListId','toString','phone\x20IS\x20NOT\x20NULL','phone\x20NOT\x20IN\x20(?)','COALESCE(calleridnum,\x27\x27)','onlyIfOpen','deletedAt\x20IS\x20NULL','ListId\x20=\x20?','COALESCE(phone,\x27\x27)','removeLists','getBlackLists','addBlackLists','cm_hopper_black','removeBlackLists','html-pdf','rimraf','zip-dir','fast-json-patch','request-promise','bluebird','path','sox','to-csv','ejs','squel','crypto','querystring','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/license/util','redis','defaults','localhost','socket.io-emitter','./voiceQueue.socket','sendStatus','status','end','json','count','offset','limit','set','Content-Range','apply','reject','save','update','then','destroy','VoiceQueues','QueueCampaigns','map','value','includes','type','name','error','send','index','VoiceQueue','rawAttributes','fieldName','key','model','query','keys','attributes','fields','nolimit','order','sort','where','filters','pick','merge','filter','options','catch','show','params','intersection','length','find','create','body','user','get','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','inbound','outbound','userProfileId','autoAssociation','UserProfileResource','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','includeAll','include','omit','createdAt','updatedAt','UserProfileSection','findOne','CmHopper','hasOwnProperty','VoiceQueueId','findAll','rows','getHopperHistories','CmHopperHistory','getHopperFinals','CmHopperFinal','getHopperBlacks','CmHopperBlack','getTeams','Team','addTeams','teams','User','Agents','online','voicePause','interface','flatMap','forEach','penalty','sequelize','transaction','upsert','each','UserVoiceQueue','findOrCreate','UserVoiceQueueRt','isNil','format','SIP/%s','emit','userVoiceQueue:save','removeTeams','ids','field','tq.TeamId','from','team_has_voice_queues','join','user_has_teams','ut.TeamId\x20=\x20tq.TeamId','VoiceQueueId\x20=\x20?','QueryTypes','SELECT','TeamId','all','compact','userVoiceQueue:remove','addAgents','spread','isEmpty','push','removeAgents'];(function(_0x28859b,_0x373075){var _0x5ecef3=function(_0x3feca7){while(--_0x3feca7){_0x28859b['push'](_0x28859b['shift']());}};_0x5ecef3(++_0x373075);}(_0xe626,0x18a));var _0x6e62=function(_0x41444c,_0x1bda2e){_0x41444c=_0x41444c-0x0;var _0x11feeb=_0xe626[_0x41444c];return _0x11feeb;};'use strict';var pdf=require(_0x6e62('0x0'));var emlformat=require('eml-format');var rimraf=require(_0x6e62('0x1'));var zipdir=require(_0x6e62('0x2'));var jsonpatch=require(_0x6e62('0x3'));var rp=require(_0x6e62('0x4'));var moment=require('moment');var BPromise=require(_0x6e62('0x5'));var Mustache=require('mustache');var util=require('util');var path=require(_0x6e62('0x6'));var sox=require(_0x6e62('0x7'));var csv=require(_0x6e62('0x8'));var ejs=require(_0x6e62('0x9'));var fs=require('fs');var _=require('lodash');var squel=require(_0x6e62('0xa'));var crypto=require(_0x6e62('0xb'));var jsforce=require('jsforce');var deskjs=require('desk.js');var toCsv=require('to-csv');var querystring=require(_0x6e62('0xc'));var Papa=require('papaparse');var Redis=require(_0x6e62('0xd'));var authService=require('../../components/auth/service');var qs=require(_0x6e62('0xe'));var as=require(_0x6e62('0xf'));var hardwareService=require(_0x6e62('0x10'));var logger=require(_0x6e62('0x11'))(_0x6e62('0x12'));var utils=require('../../config/utils');var config=require('../../config/environment');var licenseUtil=require(_0x6e62('0x13'));var db=require('../../mysqldb')['db'];config[_0x6e62('0x14')]=_[_0x6e62('0x15')](config['redis'],{'host':_0x6e62('0x16'),'port':0x18eb});var socket=require(_0x6e62('0x17'))(new Redis(config[_0x6e62('0x14')]));require(_0x6e62('0x18'))['register'](socket);function respondWithStatusCode(_0x4c4526,_0x1405b4){_0x1405b4=_0x1405b4||0xcc;return function(_0x1e60a9){if(_0x1e60a9){return _0x4c4526[_0x6e62('0x19')](_0x1405b4);}return _0x4c4526[_0x6e62('0x1a')](_0x1405b4)[_0x6e62('0x1b')]();};}function respondWithResult(_0x1e5f53,_0x1da4ed){_0x1da4ed=_0x1da4ed||0xc8;return function(_0x44b2f8){if(_0x44b2f8){return _0x1e5f53['status'](_0x1da4ed)[_0x6e62('0x1c')](_0x44b2f8);}};}function respondWithFilteredResult(_0x4b900c,_0x1f58a8){return function(_0x50f467){if(_0x50f467){var _0x155727=_0x50f467[_0x6e62('0x1d')],_0x3083d5=_0x1f58a8[_0x6e62('0x1e')],_0x2b97b1=_0x1f58a8[_0x6e62('0x1e')]+_0x1f58a8[_0x6e62('0x1f')],_0x490186;if(_0x2b97b1>=_0x155727){_0x2b97b1=_0x155727;_0x490186=0xc8;}else{_0x490186=0xce;}_0x4b900c['status'](_0x490186);return _0x4b900c[_0x6e62('0x20')](_0x6e62('0x21'),_0x3083d5+'-'+_0x2b97b1+'/'+_0x155727)[_0x6e62('0x1c')](_0x50f467);}return null;};}function patchUpdates(_0x50cc7f){return function(_0xc2c0b2){try{jsonpatch[_0x6e62('0x22')](_0xc2c0b2,_0x50cc7f,!![]);}catch(_0x37e3b3){return BPromise[_0x6e62('0x23')](_0x37e3b3);}return _0xc2c0b2[_0x6e62('0x24')]();};}function saveUpdates(_0x557be6,_0x1af8f5){return function(_0x1d4a3e){if(_0x1d4a3e){return _0x1d4a3e[_0x6e62('0x25')](_0x557be6)[_0x6e62('0x26')](function(_0x16dd1a){return _0x16dd1a;});}return null;};}function removeEntity(_0x2864fd,_0x55dfc1){return function(_0x33ba36){if(_0x33ba36){return _0x33ba36[_0x6e62('0x27')]()[_0x6e62('0x26')](function(){var _0x258e7e=_0x33ba36['get']({'plain':!![]});var _0x307c79=[{'name':_0x6e62('0x28'),'value':'inbound','ignore':![]},{'name':_0x6e62('0x29'),'value':'outbound','ignore':![]}];var _0x483a5f=_(_0x307c79)['filter']('ignore')[_0x6e62('0x2a')](_0x6e62('0x2b'))[_0x6e62('0x2b')]();if(_[_0x6e62('0x2c')](_0x483a5f,_0x258e7e[_0x6e62('0x2d')])){return;}var _0x170c70=_['find'](_0x307c79,['value',_0x258e7e[_0x6e62('0x2d')]])[_0x6e62('0x2e')];return db['UserProfileResource'][_0x6e62('0x27')]({'where':{'type':_0x170c70,'resourceId':_0x258e7e['id']}})[_0x6e62('0x26')](function(){return _0x33ba36;});})[_0x6e62('0x26')](function(){_0x2864fd[_0x6e62('0x1a')](0xcc)[_0x6e62('0x1b')]();});}};}function handleEntityNotFound(_0x5c5359,_0xb6819e){return function(_0x1fe657){if(!_0x1fe657){_0x5c5359[_0x6e62('0x19')](0x194);}return _0x1fe657;};}function handleError(_0x591df3,_0x39fcb3){_0x39fcb3=_0x39fcb3||0x1f4;return function(_0x231f5b){logger[_0x6e62('0x2f')](_0x231f5b['stack']);if(_0x231f5b[_0x6e62('0x2e')]){delete _0x231f5b[_0x6e62('0x2e')];}_0x591df3['status'](_0x39fcb3)[_0x6e62('0x30')](_0x231f5b);};}exports[_0x6e62('0x31')]=function(_0x596925,_0x56b632){var _0x1a6f40={},_0x189ca2={},_0x3ce212={'count':0x0,'rows':[]};var _0x371453=_['map'](db[_0x6e62('0x32')][_0x6e62('0x33')],function(_0x15d98c){return{'name':_0x15d98c[_0x6e62('0x34')],'type':_0x15d98c[_0x6e62('0x2d')][_0x6e62('0x35')]};});_0x189ca2[_0x6e62('0x36')]=_['map'](_0x371453,_0x6e62('0x2e'));_0x189ca2[_0x6e62('0x37')]=_[_0x6e62('0x38')](_0x596925[_0x6e62('0x37')]);_0x189ca2['filters']=_['intersection'](_0x189ca2[_0x6e62('0x36')],_0x189ca2[_0x6e62('0x37')]);_0x1a6f40[_0x6e62('0x39')]=_['intersection'](_0x189ca2[_0x6e62('0x36')],qs[_0x6e62('0x3a')](_0x596925[_0x6e62('0x37')][_0x6e62('0x3a')]));_0x1a6f40[_0x6e62('0x39')]=_0x1a6f40[_0x6e62('0x39')]['length']?_0x1a6f40['attributes']:_0x189ca2['model'];if(!_0x596925[_0x6e62('0x37')]['hasOwnProperty'](_0x6e62('0x3b'))){_0x1a6f40[_0x6e62('0x1f')]=qs['limit'](_0x596925[_0x6e62('0x37')][_0x6e62('0x1f')]);_0x1a6f40[_0x6e62('0x1e')]=qs['offset'](_0x596925[_0x6e62('0x37')][_0x6e62('0x1e')]);}_0x1a6f40[_0x6e62('0x3c')]=qs[_0x6e62('0x3d')](_0x596925[_0x6e62('0x37')][_0x6e62('0x3d')]);_0x1a6f40[_0x6e62('0x3e')]=qs[_0x6e62('0x3f')](_[_0x6e62('0x40')](_0x596925[_0x6e62('0x37')],_0x189ca2['filters']),_0x371453);if(_0x596925[_0x6e62('0x37')]['filter']){_0x1a6f40[_0x6e62('0x3e')]=_[_0x6e62('0x41')](_0x1a6f40['where'],{'$or':_[_0x6e62('0x2a')](_0x371453,function(_0x160f90){if(_0x160f90[_0x6e62('0x2d')]!=='VIRTUAL'){var _0x3c509d={};_0x3c509d[_0x160f90[_0x6e62('0x2e')]]={'$like':'%'+_0x596925[_0x6e62('0x37')][_0x6e62('0x42')]+'%'};return _0x3c509d;}})});}_0x1a6f40=_[_0x6e62('0x41')]({},_0x1a6f40,_0x596925[_0x6e62('0x43')]);var _0x1b5fd5={'where':_0x1a6f40['where']};return db[_0x6e62('0x32')][_0x6e62('0x1d')](_0x1b5fd5)['then'](function(_0x5c9cc7){_0x3ce212[_0x6e62('0x1d')]=_0x5c9cc7;if(_0x596925[_0x6e62('0x37')]['includeAll']){_0x1a6f40['include']=[{'all':!![]}];}return db[_0x6e62('0x32')]['findAll'](_0x1a6f40);})[_0x6e62('0x26')](function(_0x5bd1b5){_0x3ce212['rows']=_0x5bd1b5;return _0x3ce212;})[_0x6e62('0x26')](respondWithFilteredResult(_0x56b632,_0x1a6f40))[_0x6e62('0x44')](handleError(_0x56b632,null));};exports[_0x6e62('0x45')]=function(_0x155d50,_0x2977c9){var _0x498d27={'raw':![],'where':{'id':_0x155d50[_0x6e62('0x46')]['id']}},_0x4f064a={};_0x4f064a[_0x6e62('0x36')]=_[_0x6e62('0x38')](db[_0x6e62('0x32')]['rawAttributes']);_0x4f064a[_0x6e62('0x37')]=_['keys'](_0x155d50[_0x6e62('0x37')]);_0x4f064a[_0x6e62('0x3f')]=_[_0x6e62('0x47')](_0x4f064a['model'],_0x4f064a[_0x6e62('0x37')]);_0x498d27['attributes']=_['intersection'](_0x4f064a[_0x6e62('0x36')],qs[_0x6e62('0x3a')](_0x155d50['query'][_0x6e62('0x3a')]));_0x498d27['attributes']=_0x498d27['attributes'][_0x6e62('0x48')]?_0x498d27[_0x6e62('0x39')]:_0x4f064a['model'];if(_0x155d50[_0x6e62('0x37')]['includeAll']){_0x498d27['include']=[{'all':!![]}];}_0x498d27=_['merge']({},_0x498d27,_0x155d50['options']);return db[_0x6e62('0x32')][_0x6e62('0x49')](_0x498d27)['then'](handleEntityNotFound(_0x2977c9,null))[_0x6e62('0x26')](respondWithResult(_0x2977c9,null))['catch'](handleError(_0x2977c9,null));};exports[_0x6e62('0x4a')]=function(_0x1dfc7d,_0x3f2cb5){return db[_0x6e62('0x32')][_0x6e62('0x4a')](_0x1dfc7d[_0x6e62('0x4b')],{})['then'](function(_0xbe7347){var _0x3fc0c7=_0x1dfc7d[_0x6e62('0x4c')][_0x6e62('0x4d')]({'plain':!![]});if(!_0x3fc0c7)throw new Error(_0x6e62('0x4e'));if(_0x3fc0c7[_0x6e62('0x4f')]==='user'){var _0x169a41=_0xbe7347[_0x6e62('0x4d')]({'plain':!![]});var _0x43ae9d=[{'name':'VoiceQueues','value':_0x6e62('0x50')},{'name':_0x6e62('0x29'),'value':_0x6e62('0x51')}];var _0x39343d=_[_0x6e62('0x49')](_0x43ae9d,[_0x6e62('0x2b'),_0x169a41[_0x6e62('0x2d')]])[_0x6e62('0x2e')];return db['UserProfileSection'][_0x6e62('0x49')]({'where':{'name':_0x39343d,'userProfileId':_0x3fc0c7[_0x6e62('0x52')]},'raw':!![]})[_0x6e62('0x26')](function(_0xa303b6){if(_0xa303b6&&_0xa303b6[_0x6e62('0x53')]===0x0){return db[_0x6e62('0x54')][_0x6e62('0x4a')]({'name':_0x169a41[_0x6e62('0x2e')],'resourceId':_0x169a41['id'],'type':_0xa303b6['name'],'sectionId':_0xa303b6['id']},{})[_0x6e62('0x26')](function(){return _0xbe7347;});}else{return _0xbe7347;}})[_0x6e62('0x44')](function(_0x16fbba){logger['error'](_0x6e62('0x55'),_0x16fbba);throw _0x16fbba;});}return _0xbe7347;})['then'](respondWithResult(_0x3f2cb5,0xc9))[_0x6e62('0x44')](handleError(_0x3f2cb5,null));};exports['clone']=function(_0x4c320a,_0x5a3deb){var _0x20e18d={'where':{'id':_0x4c320a[_0x6e62('0x46')]['id']}},_0x587f6b={};_0x587f6b[_0x6e62('0x36')]=_[_0x6e62('0x38')](db['VoiceQueue'][_0x6e62('0x33')]);_0x20e18d['attributes']=_[_0x6e62('0x47')](_0x587f6b[_0x6e62('0x36')],qs[_0x6e62('0x3a')](_0x4c320a['query'][_0x6e62('0x3a')]));_0x20e18d[_0x6e62('0x39')]=_0x20e18d['attributes'][_0x6e62('0x48')]?_0x20e18d['attributes']:_0x587f6b[_0x6e62('0x36')];if(_0x4c320a[_0x6e62('0x37')][_0x6e62('0x56')]){_0x20e18d[_0x6e62('0x57')]=[{'all':!![]}];}_0x20e18d=_[_0x6e62('0x41')]({},_0x20e18d,_0x4c320a[_0x6e62('0x43')]);return db[_0x6e62('0x32')][_0x6e62('0x49')](_0x20e18d)[_0x6e62('0x26')](handleEntityNotFound(_0x5a3deb,null))[_0x6e62('0x26')](function(_0x518a86){if(_0x518a86){var _0x6ba97b=_0x518a86[_0x6e62('0x4d')]({'plain':!![]});_0x6ba97b=qs[_0x6e62('0x58')](_0x6ba97b,['id',_0x6e62('0x59'),_0x6e62('0x5a')]);_0x4c320a[_0x6e62('0x4b')]=_[_0x6e62('0x58')](_0x4c320a[_0x6e62('0x4b')],['id',_0x6e62('0x59'),_0x6e62('0x5a')]);return db[_0x6e62('0x32')]['create'](_[_0x6e62('0x41')](_0x6ba97b,_0x4c320a[_0x6e62('0x4b')]),{'include':_0x4c320a['query'][_0x6e62('0x56')]?[{'all':!![]}]:undefined})[_0x6e62('0x26')](function(_0x3ec28c){var _0x50babe=_0x4c320a['user'][_0x6e62('0x4d')]({'plain':!![]});if(!_0x50babe)throw new Error(_0x6e62('0x4e'));if(_0x50babe[_0x6e62('0x4f')]===_0x6e62('0x4c')){var _0x362f38=_0x3ec28c[_0x6e62('0x4d')]({'plain':!![]});var _0x5e838a=[{'name':'VoiceQueues','value':_0x6e62('0x50')},{'name':'QueueCampaigns','value':'outbound'}];var _0x3a227f=_[_0x6e62('0x49')](_0x5e838a,[_0x6e62('0x2b'),_0x362f38[_0x6e62('0x2d')]])[_0x6e62('0x2e')];return db[_0x6e62('0x5b')][_0x6e62('0x49')]({'where':{'name':_0x3a227f,'userProfileId':_0x50babe[_0x6e62('0x52')]},'raw':!![]})[_0x6e62('0x26')](function(_0x7a1326){if(_0x7a1326&&_0x7a1326[_0x6e62('0x53')]===0x0){return db[_0x6e62('0x54')][_0x6e62('0x4a')]({'name':_0x362f38['name'],'resourceId':_0x362f38['id'],'type':_0x7a1326['name'],'sectionId':_0x7a1326['id']},{})['then'](function(){return _0x3ec28c;});}else{return _0x3ec28c;}})[_0x6e62('0x44')](function(_0x2bf2f7){logger[_0x6e62('0x2f')](_0x6e62('0x55'),_0x2bf2f7);throw _0x2bf2f7;});}return _0x3ec28c;});}})[_0x6e62('0x26')](respondWithResult(_0x5a3deb,0xc9))[_0x6e62('0x44')](handleError(_0x5a3deb,null));};exports[_0x6e62('0x25')]=function(_0x33e5a0,_0x179da8){if(_0x33e5a0[_0x6e62('0x4b')]['id']){delete _0x33e5a0[_0x6e62('0x4b')]['id'];}return db['VoiceQueue'][_0x6e62('0x49')]({'where':{'id':_0x33e5a0[_0x6e62('0x46')]['id']}})[_0x6e62('0x26')](handleEntityNotFound(_0x179da8,null))[_0x6e62('0x26')](saveUpdates(_0x33e5a0['body'],null))[_0x6e62('0x26')](respondWithResult(_0x179da8,null))[_0x6e62('0x44')](handleError(_0x179da8,null));};exports[_0x6e62('0x27')]=function(_0x3c3f58,_0x495586){return db['VoiceQueue'][_0x6e62('0x49')]({'where':{'id':_0x3c3f58[_0x6e62('0x46')]['id']}})['then'](handleEntityNotFound(_0x495586,null))[_0x6e62('0x26')](removeEntity(_0x495586,null))[_0x6e62('0x44')](handleError(_0x495586,null));};exports['getHoppers']=function(_0xf4349,_0x3dab0f,_0x1d74c5){var _0x187cec={'raw':![],'where':{}};var _0x27e696={};var _0x4d36c6={'count':0x0,'rows':[]};return db[_0x6e62('0x32')][_0x6e62('0x5c')]({'where':{'id':_0xf4349[_0x6e62('0x46')]['id']}})[_0x6e62('0x26')](handleEntityNotFound(_0x3dab0f,null))[_0x6e62('0x26')](function(_0x55d063){if(_0x55d063){_0x27e696[_0x6e62('0x36')]=_[_0x6e62('0x38')](db[_0x6e62('0x5d')][_0x6e62('0x33')]);_0x27e696[_0x6e62('0x37')]=_[_0x6e62('0x38')](_0xf4349[_0x6e62('0x37')]);_0x27e696[_0x6e62('0x3f')]=_[_0x6e62('0x47')](_0x27e696[_0x6e62('0x36')],_0x27e696['query']);_0x187cec[_0x6e62('0x39')]=_[_0x6e62('0x47')](_0x27e696[_0x6e62('0x36')],qs[_0x6e62('0x3a')](_0xf4349[_0x6e62('0x37')]['fields']));_0x187cec[_0x6e62('0x39')]=_0x187cec[_0x6e62('0x39')]['length']?_0x187cec[_0x6e62('0x39')]:_0x27e696['model'];if(!_0xf4349['query'][_0x6e62('0x5e')]('nolimit')){_0x187cec['limit']=qs[_0x6e62('0x1f')](_0xf4349[_0x6e62('0x37')][_0x6e62('0x1f')]);_0x187cec[_0x6e62('0x1e')]=qs[_0x6e62('0x1e')](_0xf4349[_0x6e62('0x37')]['offset']);}_0x187cec[_0x6e62('0x3c')]=qs['sort'](_0xf4349['query']['sort']);_0x187cec[_0x6e62('0x3e')]=qs[_0x6e62('0x3f')](_[_0x6e62('0x40')](_0xf4349[_0x6e62('0x37')],_0x27e696[_0x6e62('0x3f')]));_0x187cec[_0x6e62('0x3e')][_0x6e62('0x5f')]=_0x55d063['id'];if(_0xf4349[_0x6e62('0x37')][_0x6e62('0x42')]){_0x187cec['where']=_[_0x6e62('0x41')](_0x187cec[_0x6e62('0x3e')],{'$or':_[_0x6e62('0x2a')](_0x187cec[_0x6e62('0x39')],function(_0x21bddb){var _0x2e4255={};_0x2e4255[_0x21bddb]={'$like':'%'+_0xf4349[_0x6e62('0x37')][_0x6e62('0x42')]+'%'};return _0x2e4255;})});}_0x187cec=_[_0x6e62('0x41')]({},_0x187cec,_0xf4349['options']);return db[_0x6e62('0x5d')]['count']({'where':_0x187cec['where']})[_0x6e62('0x26')](function(_0x3c2798){_0x4d36c6[_0x6e62('0x1d')]=_0x3c2798;if(_0xf4349[_0x6e62('0x37')]['includeAll']){_0x187cec[_0x6e62('0x57')]=[{'all':!![]}];}return db[_0x6e62('0x5d')][_0x6e62('0x60')](_0x187cec);})[_0x6e62('0x26')](function(_0x42dfe5){_0x4d36c6[_0x6e62('0x61')]=_0x42dfe5;return _0x4d36c6;});}})['then'](respondWithFilteredResult(_0x3dab0f,_0x187cec))[_0x6e62('0x44')](handleError(_0x3dab0f,null));};exports[_0x6e62('0x62')]=function(_0x1ceb1a,_0x2a2aed,_0x1fdfb7){var _0x1b3ba7={'raw':!![],'where':{}};var _0x39c3c0={};var _0x4522ea={'count':0x0,'rows':[]};return db[_0x6e62('0x32')][_0x6e62('0x5c')]({'where':{'id':_0x1ceb1a[_0x6e62('0x46')]['id']}})['then'](handleEntityNotFound(_0x2a2aed,null))['then'](function(_0x440779){if(_0x440779){_0x39c3c0[_0x6e62('0x36')]=_['keys'](db[_0x6e62('0x63')][_0x6e62('0x33')]);_0x39c3c0['query']=_['keys'](_0x1ceb1a['query']);_0x39c3c0['filters']=_['intersection'](_0x39c3c0[_0x6e62('0x36')],_0x39c3c0[_0x6e62('0x37')]);_0x1b3ba7[_0x6e62('0x39')]=_[_0x6e62('0x47')](_0x39c3c0[_0x6e62('0x36')],qs[_0x6e62('0x3a')](_0x1ceb1a[_0x6e62('0x37')][_0x6e62('0x3a')]));_0x1b3ba7[_0x6e62('0x39')]=_0x1b3ba7[_0x6e62('0x39')][_0x6e62('0x48')]?_0x1b3ba7[_0x6e62('0x39')]:_0x39c3c0[_0x6e62('0x36')];if(!_0x1ceb1a['query'][_0x6e62('0x5e')](_0x6e62('0x3b'))){_0x1b3ba7[_0x6e62('0x1f')]=qs[_0x6e62('0x1f')](_0x1ceb1a[_0x6e62('0x37')]['limit']);_0x1b3ba7[_0x6e62('0x1e')]=qs[_0x6e62('0x1e')](_0x1ceb1a[_0x6e62('0x37')][_0x6e62('0x1e')]);}_0x1b3ba7[_0x6e62('0x3c')]=qs[_0x6e62('0x3d')](_0x1ceb1a[_0x6e62('0x37')][_0x6e62('0x3d')]);_0x1b3ba7[_0x6e62('0x3e')]=qs[_0x6e62('0x3f')](_[_0x6e62('0x40')](_0x1ceb1a[_0x6e62('0x37')],_0x39c3c0[_0x6e62('0x3f')]));_0x1b3ba7[_0x6e62('0x3e')][_0x6e62('0x5f')]=_0x440779['id'];if(_0x1ceb1a[_0x6e62('0x37')][_0x6e62('0x42')]){_0x1b3ba7[_0x6e62('0x3e')]=_[_0x6e62('0x41')](_0x1b3ba7[_0x6e62('0x3e')],{'$or':_['map'](_0x1b3ba7[_0x6e62('0x39')],function(_0x3c5f2a){var _0x112451={};_0x112451[_0x3c5f2a]={'$like':'%'+_0x1ceb1a[_0x6e62('0x37')][_0x6e62('0x42')]+'%'};return _0x112451;})});}_0x1b3ba7=_[_0x6e62('0x41')]({},_0x1b3ba7,_0x1ceb1a[_0x6e62('0x43')]);return db[_0x6e62('0x63')][_0x6e62('0x1d')]({'where':_0x1b3ba7[_0x6e62('0x3e')]})[_0x6e62('0x26')](function(_0x25b555){_0x4522ea[_0x6e62('0x1d')]=_0x25b555;if(_0x1ceb1a[_0x6e62('0x37')][_0x6e62('0x56')]){_0x1b3ba7['include']=[{'all':!![]}];}return db[_0x6e62('0x63')][_0x6e62('0x60')](_0x1b3ba7);})[_0x6e62('0x26')](function(_0x370634){_0x4522ea['rows']=_0x370634;return _0x4522ea;});}})[_0x6e62('0x26')](respondWithFilteredResult(_0x2a2aed,_0x1b3ba7))[_0x6e62('0x44')](handleError(_0x2a2aed,null));};exports[_0x6e62('0x64')]=function(_0x58ef7e,_0x515b9e,_0x216014){var _0x2703ff={'raw':!![],'where':{}};var _0x38afc3={};var _0x3a9aa4={'count':0x0,'rows':[]};return db[_0x6e62('0x32')][_0x6e62('0x5c')]({'where':{'id':_0x58ef7e[_0x6e62('0x46')]['id']}})[_0x6e62('0x26')](handleEntityNotFound(_0x515b9e,null))[_0x6e62('0x26')](function(_0x3e04dc){if(_0x3e04dc){_0x38afc3[_0x6e62('0x36')]=_[_0x6e62('0x38')](db[_0x6e62('0x65')]['rawAttributes']);_0x38afc3[_0x6e62('0x37')]=_[_0x6e62('0x38')](_0x58ef7e[_0x6e62('0x37')]);_0x38afc3[_0x6e62('0x3f')]=_[_0x6e62('0x47')](_0x38afc3[_0x6e62('0x36')],_0x38afc3[_0x6e62('0x37')]);_0x2703ff[_0x6e62('0x39')]=_['intersection'](_0x38afc3[_0x6e62('0x36')],qs['fields'](_0x58ef7e[_0x6e62('0x37')]['fields']));_0x2703ff[_0x6e62('0x39')]=_0x2703ff[_0x6e62('0x39')][_0x6e62('0x48')]?_0x2703ff['attributes']:_0x38afc3[_0x6e62('0x36')];if(!_0x58ef7e[_0x6e62('0x37')]['hasOwnProperty']('nolimit')){_0x2703ff[_0x6e62('0x1f')]=qs[_0x6e62('0x1f')](_0x58ef7e[_0x6e62('0x37')][_0x6e62('0x1f')]);_0x2703ff[_0x6e62('0x1e')]=qs[_0x6e62('0x1e')](_0x58ef7e[_0x6e62('0x37')][_0x6e62('0x1e')]);}_0x2703ff['order']=qs[_0x6e62('0x3d')](_0x58ef7e['query']['sort']);_0x2703ff['where']=qs[_0x6e62('0x3f')](_[_0x6e62('0x40')](_0x58ef7e[_0x6e62('0x37')],_0x38afc3[_0x6e62('0x3f')]));_0x2703ff[_0x6e62('0x3e')]['VoiceQueueId']=_0x3e04dc['id'];if(_0x58ef7e['query'][_0x6e62('0x42')]){_0x2703ff['where']=_[_0x6e62('0x41')](_0x2703ff['where'],{'$or':_[_0x6e62('0x2a')](_0x2703ff[_0x6e62('0x39')],function(_0x4af515){var _0x54fb1c={};_0x54fb1c[_0x4af515]={'$like':'%'+_0x58ef7e[_0x6e62('0x37')][_0x6e62('0x42')]+'%'};return _0x54fb1c;})});}_0x2703ff=_[_0x6e62('0x41')]({},_0x2703ff,_0x58ef7e['options']);return db[_0x6e62('0x65')][_0x6e62('0x1d')]({'where':_0x2703ff['where']})['then'](function(_0x1814f8){_0x3a9aa4['count']=_0x1814f8;if(_0x58ef7e[_0x6e62('0x37')][_0x6e62('0x56')]){_0x2703ff[_0x6e62('0x57')]=[{'all':!![]}];}return db[_0x6e62('0x65')][_0x6e62('0x60')](_0x2703ff);})['then'](function(_0x5dc3dc){_0x3a9aa4[_0x6e62('0x61')]=_0x5dc3dc;return _0x3a9aa4;});}})[_0x6e62('0x26')](respondWithFilteredResult(_0x515b9e,_0x2703ff))[_0x6e62('0x44')](handleError(_0x515b9e,null));};exports[_0x6e62('0x66')]=function(_0xf05164,_0x171b3c,_0x5002d1){var _0x2ad043={'raw':!![],'where':{}};var _0x16afd0={};var _0xf583f8={'count':0x0,'rows':[]};return db[_0x6e62('0x32')][_0x6e62('0x5c')]({'where':{'id':_0xf05164[_0x6e62('0x46')]['id']}})['then'](handleEntityNotFound(_0x171b3c,null))[_0x6e62('0x26')](function(_0x451a12){if(_0x451a12){_0x16afd0[_0x6e62('0x36')]=_[_0x6e62('0x38')](db['CmHopperBlack'][_0x6e62('0x33')]);_0x16afd0[_0x6e62('0x37')]=_[_0x6e62('0x38')](_0xf05164[_0x6e62('0x37')]);_0x16afd0['filters']=_[_0x6e62('0x47')](_0x16afd0[_0x6e62('0x36')],_0x16afd0[_0x6e62('0x37')]);_0x2ad043[_0x6e62('0x39')]=_[_0x6e62('0x47')](_0x16afd0[_0x6e62('0x36')],qs[_0x6e62('0x3a')](_0xf05164[_0x6e62('0x37')][_0x6e62('0x3a')]));_0x2ad043[_0x6e62('0x39')]=_0x2ad043[_0x6e62('0x39')][_0x6e62('0x48')]?_0x2ad043['attributes']:_0x16afd0[_0x6e62('0x36')];if(!_0xf05164[_0x6e62('0x37')][_0x6e62('0x5e')]('nolimit')){_0x2ad043['limit']=qs[_0x6e62('0x1f')](_0xf05164[_0x6e62('0x37')][_0x6e62('0x1f')]);_0x2ad043[_0x6e62('0x1e')]=qs[_0x6e62('0x1e')](_0xf05164[_0x6e62('0x37')][_0x6e62('0x1e')]);}_0x2ad043[_0x6e62('0x3c')]=qs['sort'](_0xf05164[_0x6e62('0x37')][_0x6e62('0x3d')]);_0x2ad043[_0x6e62('0x3e')]=qs[_0x6e62('0x3f')](_[_0x6e62('0x40')](_0xf05164[_0x6e62('0x37')],_0x16afd0[_0x6e62('0x3f')]));_0x2ad043[_0x6e62('0x3e')][_0x6e62('0x5f')]=_0x451a12['id'];if(_0xf05164[_0x6e62('0x37')][_0x6e62('0x42')]){_0x2ad043[_0x6e62('0x3e')]=_[_0x6e62('0x41')](_0x2ad043[_0x6e62('0x3e')],{'$or':_[_0x6e62('0x2a')](_0x2ad043[_0x6e62('0x39')],function(_0x2aacdf){var _0x1024e0={};_0x1024e0[_0x2aacdf]={'$like':'%'+_0xf05164[_0x6e62('0x37')][_0x6e62('0x42')]+'%'};return _0x1024e0;})});}_0x2ad043=_[_0x6e62('0x41')]({},_0x2ad043,_0xf05164[_0x6e62('0x43')]);return db[_0x6e62('0x67')]['count']({'where':_0x2ad043['where']})[_0x6e62('0x26')](function(_0x5d5fe4){_0xf583f8[_0x6e62('0x1d')]=_0x5d5fe4;if(_0xf05164[_0x6e62('0x37')][_0x6e62('0x56')]){_0x2ad043[_0x6e62('0x57')]=[{'all':!![]}];}return db['CmHopperBlack'][_0x6e62('0x60')](_0x2ad043);})[_0x6e62('0x26')](function(_0x535e91){_0xf583f8[_0x6e62('0x61')]=_0x535e91;return _0xf583f8;});}})['then'](respondWithFilteredResult(_0x171b3c,_0x2ad043))[_0x6e62('0x44')](handleError(_0x171b3c,null));};exports[_0x6e62('0x68')]=function(_0x2174ac,_0x2af526,_0x5136ac){var _0x36b89d={};var _0x21fd87={};var _0xcec037;var _0x289f8f;return db['VoiceQueue'][_0x6e62('0x5c')]({'where':{'id':_0x2174ac[_0x6e62('0x46')]['id']}})[_0x6e62('0x26')](handleEntityNotFound(_0x2af526,null))[_0x6e62('0x26')](function(_0x1e25ca){if(_0x1e25ca){_0xcec037=_0x1e25ca;_0x21fd87[_0x6e62('0x36')]=_[_0x6e62('0x38')](db[_0x6e62('0x69')][_0x6e62('0x33')]);_0x21fd87[_0x6e62('0x37')]=_[_0x6e62('0x38')](_0x2174ac[_0x6e62('0x37')]);_0x21fd87[_0x6e62('0x3f')]=_['intersection'](_0x21fd87['model'],_0x21fd87[_0x6e62('0x37')]);_0x36b89d['attributes']=_[_0x6e62('0x47')](_0x21fd87['model'],qs[_0x6e62('0x3a')](_0x2174ac[_0x6e62('0x37')][_0x6e62('0x3a')]));_0x36b89d[_0x6e62('0x39')]=_0x36b89d['attributes'][_0x6e62('0x48')]?_0x36b89d[_0x6e62('0x39')]:_0x21fd87[_0x6e62('0x36')];_0x36b89d[_0x6e62('0x3c')]=qs[_0x6e62('0x3d')](_0x2174ac[_0x6e62('0x37')]['sort']);_0x36b89d[_0x6e62('0x3e')]=qs['filters'](_[_0x6e62('0x40')](_0x2174ac[_0x6e62('0x37')],_0x21fd87[_0x6e62('0x3f')]));if(_0x2174ac[_0x6e62('0x37')]['filter']){_0x36b89d[_0x6e62('0x3e')]=_[_0x6e62('0x41')](_0x36b89d['where'],{'$or':_['map'](_0x36b89d[_0x6e62('0x39')],function(_0x44bb58){var _0x29e95e={};_0x29e95e[_0x44bb58]={'$like':'%'+_0x2174ac['query'][_0x6e62('0x42')]+'%'};return _0x29e95e;})});}_0x36b89d=_[_0x6e62('0x41')]({},_0x36b89d,_0x2174ac[_0x6e62('0x43')]);return _0xcec037[_0x6e62('0x68')](_0x36b89d);}})[_0x6e62('0x26')](function(_0x3a36c7){if(_0x3a36c7){_0x289f8f=_0x3a36c7[_0x6e62('0x48')];if(!_0x2174ac['query']['hasOwnProperty'](_0x6e62('0x3b'))){_0x36b89d[_0x6e62('0x1f')]=qs[_0x6e62('0x1f')](_0x2174ac[_0x6e62('0x37')]['limit']);_0x36b89d[_0x6e62('0x1e')]=qs['offset'](_0x2174ac[_0x6e62('0x37')][_0x6e62('0x1e')]);}return _0xcec037['getTeams'](_0x36b89d);}})[_0x6e62('0x26')](function(_0x38b3be){if(_0x38b3be){return _0x38b3be?{'count':_0x289f8f,'rows':_0x38b3be}:null;}})['then'](respondWithResult(_0x2af526,null))[_0x6e62('0x44')](handleError(_0x2af526,null));};exports[_0x6e62('0x6a')]=function(_0x9acbff,_0x406fbb,_0x426e14){var _0x12e280=_0x9acbff[_0x6e62('0x4b')][_0x6e62('0x6b')];var _0x35c057=_[_0x6e62('0x2a')](_0x12e280,'id');return db[_0x6e62('0x69')][_0x6e62('0x60')]({'where':{'id':_0x35c057},'attributes':['id'],'include':[{'model':db[_0x6e62('0x6c')],'as':_0x6e62('0x6d'),'attributes':['id',_0x6e62('0x2e'),_0x6e62('0x6e'),_0x6e62('0x6f'),_0x6e62('0x70')],'raw':!![]}]})[_0x6e62('0x26')](function(_0x44459a){if(_0x44459a){var _0x530f63=_[_0x6e62('0x71')](_0x44459a,function(_0x3287e4){var _0x2ae82c=_0x3287e4[_0x6e62('0x4d')]({'plain':!![]});_0x2ae82c['Agents'][_0x6e62('0x72')](function(_0x19f4f1){_0x19f4f1[_0x6e62('0x73')]=_[_0x6e62('0x49')](_0x12e280,{'id':_0x2ae82c['id']})[_0x6e62('0x73')];});return _0x2ae82c[_0x6e62('0x6d')];});return db[_0x6e62('0x32')][_0x6e62('0x49')]({'where':{'id':_0x9acbff[_0x6e62('0x46')]['id']}})['then'](function(_0x25a857){return db[_0x6e62('0x74')][_0x6e62('0x75')](function(_0x4f8126){return _0x25a857[_0x6e62('0x6a')](_0x35c057,{'transaction':_0x4f8126})[_0x6e62('0x26')](function(){return BPromise['each'](_0x12e280,function(_0x41dd12){return db['TeamVoiceQueue'][_0x6e62('0x76')]({'TeamId':_0x41dd12['id'],'VoiceQueueId':_0x9acbff[_0x6e62('0x46')]['id'],'penalty':_0x41dd12['penalty']},{'transaction':_0x4f8126});});})['then'](function(){return BPromise[_0x6e62('0x77')](_0x530f63,function(_0xc3e27f){return db[_0x6e62('0x78')][_0x6e62('0x79')]({'where':{'UserId':_0xc3e27f['id'],'VoiceQueueId':_0x9acbff['params']['id']},'defaults':{'penalty':_0xc3e27f[_0x6e62('0x73')]},'transaction':_0x4f8126});});})[_0x6e62('0x26')](function(){return BPromise[_0x6e62('0x77')](_['filter'](_0x530f63,{'online':!![]}),function(_0x25488f){return db[_0x6e62('0x7a')][_0x6e62('0x76')]({'membername':_0x25488f[_0x6e62('0x2e')],'UserId':_0x25488f['id'],'queue_name':_0x25a857['name'],'VoiceQueueId':_0x25a857['id'],'interface':_[_0x6e62('0x7b')](_0x25488f[_0x6e62('0x70')])?util[_0x6e62('0x7c')](_0x6e62('0x7d'),_0x25488f['name']):_0x25488f[_0x6e62('0x70')],'paused':_0x25488f['voicePause']||![],'penalty':_0x25488f[_0x6e62('0x73')]},{'transaction':_0x4f8126});});})[_0x6e62('0x26')](function(){_0x530f63['forEach'](function(_0x34c504){socket[_0x6e62('0x7e')](_0x6e62('0x7f'),{'UserId':_0x34c504['id'],'VoiceQueueId':_0x25a857['id']});});});});});}})[_0x6e62('0x26')](respondWithStatusCode(_0x406fbb,null))[_0x6e62('0x44')](handleError(_0x406fbb,null));};exports[_0x6e62('0x80')]=function(_0xe337da,_0x41aef9,_0x49d9cb){return db[_0x6e62('0x69')][_0x6e62('0x60')]({'where':{'id':_0xe337da['query'][_0x6e62('0x81')]},'attributes':['id'],'include':[{'model':db['User'],'as':_0x6e62('0x6d'),'attributes':['id'],'raw':!![]}]})[_0x6e62('0x26')](handleEntityNotFound(_0x41aef9,null))[_0x6e62('0x26')](function(_0x2db7f5){var _0x2648dd=_[_0x6e62('0x2a')](_0x2db7f5,'id');var _0x183458=[];var _0x235e72=[];var _0x17cdb3=squel['select']();_0x17cdb3[_0x6e62('0x82')](_0x6e62('0x83'))[_0x6e62('0x84')](_0x6e62('0x85'),'tq')[_0x6e62('0x86')](_0x6e62('0x87'),'ut',_0x6e62('0x88'))[_0x6e62('0x3e')](_0x6e62('0x89'),_0xe337da['params']['id']);for(var _0x2f97de=0x0;_0x2f97de<_0x2db7f5[_0x6e62('0x48')];_0x2f97de+=0x1){let _0x762392=_0x2db7f5[_0x2f97de];for(var _0x1034f9=0x0;_0x1034f9<_0x762392['Agents'][_0x6e62('0x48')];_0x1034f9+=0x1){let _0x11e425=_0x762392[_0x6e62('0x6d')][_0x1034f9];var _0x5781c5=_0x17cdb3['clone']();_0x5781c5[_0x6e62('0x3e')]('ut.UserId\x20=\x20?',_0x11e425['id']);_0x235e72['push'](db[_0x6e62('0x74')][_0x6e62('0x37')](_0x5781c5['toString'](),{'type':db[_0x6e62('0x74')][_0x6e62('0x8a')][_0x6e62('0x8b')]})['then'](function(_0x1b6c4e){if(_0x1b6c4e[_0x6e62('0x48')]===0x1){return _0x11e425['id'];}else{var _0xcf1bd8=_['every'](_['map'](_0x1b6c4e,_0x6e62('0x8c')),function(_0x5ff8f1){return _[_0x6e62('0x2c')](_0x2648dd,_0x5ff8f1);});if(_0xcf1bd8){return _0x11e425['id'];}}}));}}return BPromise[_0x6e62('0x8d')](_0x235e72)['then'](function(_0x95cb1a){_0x183458=_(_0x183458)['union'](_0x95cb1a)[_0x6e62('0x8e')]()[_0x6e62('0x2b')]();return db[_0x6e62('0x32')][_0x6e62('0x49')]({'where':{'id':_0xe337da['params']['id']}})[_0x6e62('0x26')](function(_0x35eae8){return db['sequelize']['transaction'](function(_0x240d03){return _0x35eae8[_0x6e62('0x80')](_0xe337da[_0x6e62('0x37')][_0x6e62('0x81')],{'transaction':_0x240d03})[_0x6e62('0x26')](function(){if(!_['isEmpty'](_0x183458)){return _0x35eae8['removeAgents'](_0x183458,{'transaction':_0x240d03})['then'](function(){return db[_0x6e62('0x7a')][_0x6e62('0x27')]({'where':{'VoiceQueueId':_0xe337da[_0x6e62('0x46')]['id'],'UserId':_0x183458},'transaction':_0x240d03});});}})[_0x6e62('0x26')](function(){_0x183458[_0x6e62('0x72')](function(_0x79dba){socket['emit'](_0x6e62('0x8f'),{'UserId':_0x79dba,'VoiceQueueId':_0x35eae8['id']});});});});});});})[_0x6e62('0x26')](respondWithStatusCode(_0x41aef9,null))['catch'](handleError(_0x41aef9,null));};exports[_0x6e62('0x90')]=function(_0x2a29fa,_0x2f8669,_0x30f8ca){var _0x12a798,_0x1c07a1;return db['VoiceQueue']['find']({'where':{'id':_0x2a29fa[_0x6e62('0x46')]['id']}})[_0x6e62('0x26')](handleEntityNotFound(_0x2f8669,null))[_0x6e62('0x26')](function(_0x4004c7){if(_0x4004c7){_0x1c07a1=_0x4004c7;return _0x4004c7[_0x6e62('0x90')](_0x2a29fa[_0x6e62('0x4b')][_0x6e62('0x81')],_['omit'](_0x2a29fa[_0x6e62('0x4b')],[_0x6e62('0x81'),'id'])||{})[_0x6e62('0x91')](function(_0x1ad170){for(var _0x492dc9=0x0;_0x492dc9<_0x2a29fa[_0x6e62('0x4b')][_0x6e62('0x81')]['length'];_0x492dc9+=0x1){socket[_0x6e62('0x7e')](_0x6e62('0x7f'),{'UserId':_0x2a29fa[_0x6e62('0x4b')][_0x6e62('0x81')][_0x492dc9],'VoiceQueueId':_0x2a29fa['params']['id']});}return _0x1ad170;});}})[_0x6e62('0x26')](function(_0x46a461){_0x12a798=_0x46a461||[];if(_0x1c07a1){return db['User'][_0x6e62('0x60')]({'where':{'id':_0x2a29fa['body'][_0x6e62('0x81')]},'attributes':['id',_0x6e62('0x2e'),_0x6e62('0x6e'),_0x6e62('0x6f'),_0x6e62('0x70')],'raw':!![]});}})['then'](function(_0x27270c){if(!_[_0x6e62('0x92')](_0x27270c)){var _0x519ad1=[];for(var _0x723470=0x0;_0x723470<_0x27270c[_0x6e62('0x48')];_0x723470++){if(_0x27270c[_0x723470][_0x6e62('0x6e')]){_0x519ad1[_0x6e62('0x93')](db[_0x6e62('0x7a')][_0x6e62('0x76')]({'membername':_0x27270c[_0x723470][_0x6e62('0x2e')],'UserId':_0x27270c[_0x723470]['id'],'queue_name':_0x1c07a1[_0x6e62('0x2e')],'VoiceQueueId':_0x1c07a1['id'],'interface':_[_0x6e62('0x7b')](_0x27270c[_0x723470]['interface'])?util[_0x6e62('0x7c')]('SIP/%s',_0x27270c[_0x723470]['name']):_0x27270c[_0x723470][_0x6e62('0x70')],'paused':_0x27270c[_0x723470][_0x6e62('0x6f')]||![],'penalty':_0x2a29fa[_0x6e62('0x4b')][_0x6e62('0x73')]||0x0}));}}return BPromise[_0x6e62('0x8d')](_0x519ad1);}})[_0x6e62('0x26')](function(){return _0x12a798;})[_0x6e62('0x26')](respondWithResult(_0x2f8669,null))['catch'](handleError(_0x2f8669,null));};exports[_0x6e62('0x94')]=function(_0xb9155b,_0x1c9caa,_0x547967){return db[_0x6e62('0x32')][_0x6e62('0x49')]({'where':{'id':_0xb9155b[_0x6e62('0x46')]['id']}})['then'](handleEntityNotFound(_0x1c9caa,null))[_0x6e62('0x26')](function(_0x51c702){if(_0x51c702){return _0x51c702[_0x6e62('0x94')](_0xb9155b[_0x6e62('0x37')][_0x6e62('0x81')])['then'](function(){if(_[_0x6e62('0x95')](_0xb9155b[_0x6e62('0x37')]['ids'])){for(var _0x2b16a3=0x0;_0x2b16a3<_0xb9155b[_0x6e62('0x37')][_0x6e62('0x81')][_0x6e62('0x48')];_0x2b16a3+=0x1){socket[_0x6e62('0x7e')](_0x6e62('0x8f'),{'UserId':Number(_0xb9155b[_0x6e62('0x37')]['ids'][_0x2b16a3]),'VoiceQueueId':Number(_0xb9155b['params']['id'])});}}else{socket[_0x6e62('0x7e')](_0x6e62('0x8f'),{'UserId':Number(_0xb9155b[_0x6e62('0x37')][_0x6e62('0x81')]),'VoiceQueueId':Number(_0xb9155b['params']['id'])});}});}})[_0x6e62('0x26')](function(_0x1e1bde){return db[_0x6e62('0x7a')]['destroy']({'where':{'VoiceQueueId':_0xb9155b[_0x6e62('0x46')]['id'],'UserId':_0xb9155b[_0x6e62('0x37')][_0x6e62('0x81')]}})[_0x6e62('0x26')](function(){return _0x1e1bde;});})[_0x6e62('0x26')](respondWithStatusCode(_0x1c9caa,null))[_0x6e62('0x44')](handleError(_0x1c9caa,null));};exports[_0x6e62('0x96')]=function(_0xbe80b5,_0x4956d0,_0x437641){var _0x2f26bf={};var _0x1f803a={};var _0x4bf418;var _0x26eced;return db[_0x6e62('0x32')][_0x6e62('0x5c')]({'where':{'id':_0xbe80b5[_0x6e62('0x46')]['id']}})['then'](handleEntityNotFound(_0x4956d0,null))[_0x6e62('0x26')](function(_0x1061a3){if(_0x1061a3){_0x4bf418=_0x1061a3;_0x1f803a[_0x6e62('0x36')]=_[_0x6e62('0x38')](db['User']['rawAttributes']);_0x1f803a['query']=_[_0x6e62('0x38')](_0xbe80b5[_0x6e62('0x37')]);_0x1f803a[_0x6e62('0x3f')]=_[_0x6e62('0x47')](_0x1f803a['model'],_0x1f803a[_0x6e62('0x37')]);_0x2f26bf['attributes']=_[_0x6e62('0x47')](_0x1f803a[_0x6e62('0x36')],qs[_0x6e62('0x3a')](_0xbe80b5[_0x6e62('0x37')]['fields']));_0x2f26bf[_0x6e62('0x39')]=_0x2f26bf[_0x6e62('0x39')][_0x6e62('0x48')]?_0x2f26bf['attributes']:_0x1f803a[_0x6e62('0x36')];_0x2f26bf[_0x6e62('0x3c')]=qs[_0x6e62('0x3d')](_0xbe80b5[_0x6e62('0x37')][_0x6e62('0x3d')]);_0x2f26bf[_0x6e62('0x3e')]=qs[_0x6e62('0x3f')](_[_0x6e62('0x40')](_0xbe80b5[_0x6e62('0x37')],_0x1f803a[_0x6e62('0x3f')]));if(_0xbe80b5[_0x6e62('0x37')][_0x6e62('0x42')]){_0x2f26bf[_0x6e62('0x3e')]=_['merge'](_0x2f26bf['where'],{'$or':_[_0x6e62('0x2a')](_0x2f26bf[_0x6e62('0x39')],function(_0x261b8e){var _0x150998={};_0x150998[_0x261b8e]={'$like':'%'+_0xbe80b5[_0x6e62('0x37')][_0x6e62('0x42')]+'%'};return _0x150998;})});}_0x2f26bf=_[_0x6e62('0x41')]({},_0x2f26bf,_0xbe80b5[_0x6e62('0x43')]);return _0x4bf418[_0x6e62('0x96')](_0x2f26bf);}})['then'](function(_0x56dd67){if(_0x56dd67){_0x26eced=_0x56dd67[_0x6e62('0x48')];if(!_0xbe80b5[_0x6e62('0x37')]['hasOwnProperty'](_0x6e62('0x3b'))){_0x2f26bf[_0x6e62('0x1f')]=qs['limit'](_0xbe80b5['query'][_0x6e62('0x1f')]);_0x2f26bf[_0x6e62('0x1e')]=qs[_0x6e62('0x1e')](_0xbe80b5[_0x6e62('0x37')]['offset']);}return _0x4bf418['getAgents'](_0x2f26bf);}})[_0x6e62('0x26')](function(_0x3c20dd){if(_0x3c20dd){return _0x3c20dd?{'count':_0x26eced,'rows':_0x3c20dd}:null;}})[_0x6e62('0x26')](respondWithResult(_0x4956d0,null))[_0x6e62('0x44')](handleError(_0x4956d0,null));};exports['getMembers']=function(_0x5bda5,_0x3d264c,_0x4bb0b5){var _0x4053e6={};var _0x1a34ee={};var _0x546ee5;var _0x241f2c;return db[_0x6e62('0x32')][_0x6e62('0x5c')]({'where':{'id':_0x5bda5['params']['id']}})[_0x6e62('0x26')](handleEntityNotFound(_0x3d264c,null))[_0x6e62('0x26')](function(_0x647db6){if(_0x647db6){_0x546ee5=_0x647db6;_0x1a34ee[_0x6e62('0x36')]=_[_0x6e62('0x38')](db[_0x6e62('0x7a')][_0x6e62('0x33')]);_0x1a34ee[_0x6e62('0x37')]=_[_0x6e62('0x38')](_0x5bda5['query']);_0x1a34ee[_0x6e62('0x3f')]=_[_0x6e62('0x47')](_0x1a34ee['model'],_0x1a34ee[_0x6e62('0x37')]);_0x4053e6[_0x6e62('0x39')]=_[_0x6e62('0x47')](_0x1a34ee[_0x6e62('0x36')],qs[_0x6e62('0x3a')](_0x5bda5[_0x6e62('0x37')][_0x6e62('0x3a')]));_0x4053e6[_0x6e62('0x39')]=_0x4053e6[_0x6e62('0x39')]['length']?_0x4053e6[_0x6e62('0x39')]:_0x1a34ee[_0x6e62('0x36')];_0x4053e6['order']=qs[_0x6e62('0x3d')](_0x5bda5[_0x6e62('0x37')][_0x6e62('0x3d')]);_0x4053e6[_0x6e62('0x3e')]=qs[_0x6e62('0x3f')](_[_0x6e62('0x40')](_0x5bda5[_0x6e62('0x37')],_0x1a34ee[_0x6e62('0x3f')]));if(_0x5bda5[_0x6e62('0x37')]['filter']){_0x4053e6[_0x6e62('0x3e')]=_[_0x6e62('0x41')](_0x4053e6[_0x6e62('0x3e')],{'$or':_[_0x6e62('0x2a')](_0x4053e6[_0x6e62('0x39')],function(_0x455569){var _0x26cd89={};_0x26cd89[_0x455569]={'$like':'%'+_0x5bda5[_0x6e62('0x37')]['filter']+'%'};return _0x26cd89;})});}_0x4053e6=_[_0x6e62('0x41')]({},_0x4053e6,_0x5bda5['options']);return _0x546ee5['getMembers'](_0x4053e6);}})[_0x6e62('0x26')](function(_0x5c8d96){if(_0x5c8d96){_0x241f2c=_0x5c8d96['length'];if(!_0x5bda5[_0x6e62('0x37')][_0x6e62('0x5e')](_0x6e62('0x3b'))){_0x4053e6[_0x6e62('0x1f')]=qs['limit'](_0x5bda5[_0x6e62('0x37')][_0x6e62('0x1f')]);_0x4053e6[_0x6e62('0x1e')]=qs[_0x6e62('0x1e')](_0x5bda5[_0x6e62('0x37')]['offset']);}return _0x546ee5[_0x6e62('0x97')](_0x4053e6);}})[_0x6e62('0x26')](function(_0x3da469){return _0x3da469?{'count':_0x241f2c,'rows':_0x3da469}:null;})['then'](respondWithResult(_0x3d264c,null))[_0x6e62('0x44')](handleError(_0x3d264c,null));};exports['getLists']=function(_0x3b0ac0,_0x553257,_0x1804d3){var _0x34fc27={};var _0x483970={};var _0x2954b1;var _0x57f18d;return db[_0x6e62('0x32')][_0x6e62('0x5c')]({'where':{'id':_0x3b0ac0[_0x6e62('0x46')]['id']}})[_0x6e62('0x26')](handleEntityNotFound(_0x553257,null))[_0x6e62('0x26')](function(_0xe6f164){if(_0xe6f164){_0x2954b1=_0xe6f164;_0x483970[_0x6e62('0x36')]=_['keys'](db[_0x6e62('0x98')]['rawAttributes']);_0x483970[_0x6e62('0x37')]=_[_0x6e62('0x38')](_0x3b0ac0[_0x6e62('0x37')]);_0x483970[_0x6e62('0x3f')]=_[_0x6e62('0x47')](_0x483970[_0x6e62('0x36')],_0x483970[_0x6e62('0x37')]);_0x34fc27[_0x6e62('0x39')]=_[_0x6e62('0x47')](_0x483970[_0x6e62('0x36')],qs['fields'](_0x3b0ac0['query'][_0x6e62('0x3a')]));_0x34fc27[_0x6e62('0x39')]=_0x34fc27['attributes'][_0x6e62('0x48')]?_0x34fc27[_0x6e62('0x39')]:_0x483970[_0x6e62('0x36')];_0x34fc27[_0x6e62('0x3c')]=qs['sort'](_0x3b0ac0[_0x6e62('0x37')][_0x6e62('0x3d')]);_0x34fc27[_0x6e62('0x3e')]=qs['filters'](_['pick'](_0x3b0ac0['query'],_0x483970['filters']));if(_0x3b0ac0[_0x6e62('0x37')][_0x6e62('0x42')]){_0x34fc27[_0x6e62('0x3e')]=_[_0x6e62('0x41')](_0x34fc27['where'],{'$or':_['map'](_0x34fc27[_0x6e62('0x39')],function(_0x3cd6a3){var _0x2fef08={};_0x2fef08[_0x3cd6a3]={'$like':'%'+_0x3b0ac0[_0x6e62('0x37')][_0x6e62('0x42')]+'%'};return _0x2fef08;})});}_0x34fc27=_[_0x6e62('0x41')]({},_0x34fc27,_0x3b0ac0[_0x6e62('0x43')]);return _0x2954b1[_0x6e62('0x99')](_0x34fc27);}})[_0x6e62('0x26')](function(_0x4e309c){if(_0x4e309c){_0x57f18d=_0x4e309c['length'];if(!_0x3b0ac0[_0x6e62('0x37')][_0x6e62('0x5e')]('nolimit')){_0x34fc27[_0x6e62('0x1f')]=qs[_0x6e62('0x1f')](_0x3b0ac0[_0x6e62('0x37')]['limit']);_0x34fc27['offset']=qs[_0x6e62('0x1e')](_0x3b0ac0[_0x6e62('0x37')][_0x6e62('0x1e')]);}return _0x2954b1[_0x6e62('0x99')](_0x34fc27);}})[_0x6e62('0x26')](function(_0x330400){if(_0x330400){return _0x330400?{'count':_0x57f18d,'rows':_0x330400}:null;}})['then'](respondWithResult(_0x553257,null))[_0x6e62('0x44')](handleError(_0x553257,null));};exports[_0x6e62('0x9a')]=function(_0x3b11d2,_0x7faa54,_0x35bd33){var _0x14cdbb,_0x487a78;return db[_0x6e62('0x32')][_0x6e62('0x49')]({'where':{'id':_0x3b11d2[_0x6e62('0x46')]['id']}})[_0x6e62('0x26')](handleEntityNotFound(_0x7faa54,null))['then'](function(_0x2391c7){if(_0x2391c7){_0x487a78=_0x2391c7;return _0x2391c7[_0x6e62('0x9a')](_0x3b11d2[_0x6e62('0x4b')]['ids'],_[_0x6e62('0x58')](_0x3b11d2[_0x6e62('0x4b')],[_0x6e62('0x81'),'id'])||{});}return null;})[_0x6e62('0x91')](function(_0x263b07){var _0x5cc590;_0x14cdbb=_0x263b07||[];var _0x550b14=[];if(_0x263b07){for(var _0x1cc32a=0x0;_0x1cc32a<_0x263b07[_0x6e62('0x48')];_0x1cc32a+=0x1){var _0x63ab36=_0x263b07[_0x1cc32a]['get']({'plain':!![]});_0x487a78[_0x6e62('0x9b')]=_0x3b11d2[_0x6e62('0x4b')][_0x6e62('0x9b')]?_0x3b11d2[_0x6e62('0x4b')][_0x6e62('0x9b')]:_0x487a78[_0x6e62('0x9b')];switch(_0x487a78['dialCheckDuplicateType']){case'always':_0x5cc590=squel[_0x6e62('0x9c')]()[_0x6e62('0x9d')](_0x6e62('0x9e'))[_0x6e62('0x9f')](['phone',_0x6e62('0xa0'),_0x6e62('0xa1'),_0x6e62('0xa2'),_0x6e62('0x5f'),'createdAt',_0x6e62('0x5a')],squel[_0x6e62('0xa3')]()[_0x6e62('0x82')](_0x6e62('0xa4'),'phone')[_0x6e62('0x82')]('NOW()',_0x6e62('0xa0'))[_0x6e62('0x82')]('id',_0x6e62('0xa1'))[_0x6e62('0x82')](_0x63ab36['CmListId']['toString'](),_0x6e62('0xa2'))[_0x6e62('0x82')](_0x3b11d2[_0x6e62('0x46')]['id']['toString'](),_0x6e62('0x5f'))[_0x6e62('0x82')](_0x6e62('0xa5'),_0x6e62('0x59'))[_0x6e62('0x82')](_0x6e62('0xa5'),'updatedAt')[_0x6e62('0x84')](_0x6e62('0xa6'))[_0x6e62('0x3e')]('deletedAt\x20IS\x20NULL')[_0x6e62('0x3e')]('ListId\x20=\x20?',_0x63ab36[_0x6e62('0xa7')][_0x6e62('0xa8')]())[_0x6e62('0x3e')](_0x6e62('0xa9'))[_0x6e62('0x3e')](_0x6e62('0xaa'),squel[_0x6e62('0xa3')]()['field'](_0x6e62('0xab'))['from']('cm_hopper_final')[_0x6e62('0x3e')](_0x6e62('0x89'),_0x3b11d2[_0x6e62('0x46')]['id'][_0x6e62('0xa8')]()))[_0x6e62('0x3e')](_0x6e62('0xaa'),squel[_0x6e62('0xa3')]()[_0x6e62('0x82')]('COALESCE(phone,\x27\x27)')[_0x6e62('0x84')](_0x6e62('0x9e'))['where'](_0x6e62('0x89'),_0x3b11d2[_0x6e62('0x46')]['id'][_0x6e62('0xa8')]())))[_0x6e62('0xa8')]();break;case _0x6e62('0xac'):_0x5cc590=squel[_0x6e62('0x9c')]()[_0x6e62('0x9d')](_0x6e62('0x9e'))[_0x6e62('0x9f')](['phone',_0x6e62('0xa0'),_0x6e62('0xa1'),'ListId','VoiceQueueId',_0x6e62('0x59'),_0x6e62('0x5a')],squel[_0x6e62('0xa3')]()[_0x6e62('0x82')](_0x6e62('0xa4'),_0x6e62('0xa4'))[_0x6e62('0x82')](_0x6e62('0xa5'),_0x6e62('0xa0'))[_0x6e62('0x82')]('id',_0x6e62('0xa1'))[_0x6e62('0x82')](_0x63ab36[_0x6e62('0xa7')][_0x6e62('0xa8')](),_0x6e62('0xa2'))[_0x6e62('0x82')](_0x3b11d2[_0x6e62('0x46')]['id'][_0x6e62('0xa8')](),'VoiceQueueId')[_0x6e62('0x82')](_0x6e62('0xa5'),_0x6e62('0x59'))[_0x6e62('0x82')]('NOW()',_0x6e62('0x5a'))[_0x6e62('0x84')](_0x6e62('0xa6'))['where'](_0x6e62('0xad'))['where'](_0x6e62('0xae'),_0x63ab36['CmListId'][_0x6e62('0xa8')]())[_0x6e62('0x3e')]('phone\x20IS\x20NOT\x20NULL')[_0x6e62('0x3e')](_0x6e62('0xaa'),squel['select']()[_0x6e62('0x82')](_0x6e62('0xaf'))['from']('cm_hopper')[_0x6e62('0x3e')]('VoiceQueueId\x20=\x20?',_0x3b11d2[_0x6e62('0x46')]['id'][_0x6e62('0xa8')]())))[_0x6e62('0xa8')]();break;default:_0x5cc590=squel[_0x6e62('0x9c')]()['into'](_0x6e62('0x9e'))[_0x6e62('0x9f')]([_0x6e62('0xa4'),_0x6e62('0xa0'),_0x6e62('0xa1'),_0x6e62('0xa2'),_0x6e62('0x5f'),_0x6e62('0x59'),_0x6e62('0x5a')],squel[_0x6e62('0xa3')]()[_0x6e62('0x82')](_0x6e62('0xa4'),_0x6e62('0xa4'))['field']('NOW()',_0x6e62('0xa0'))[_0x6e62('0x82')]('id',_0x6e62('0xa1'))[_0x6e62('0x82')](_0x63ab36[_0x6e62('0xa7')][_0x6e62('0xa8')](),_0x6e62('0xa2'))['field'](_0x3b11d2[_0x6e62('0x46')]['id'][_0x6e62('0xa8')](),_0x6e62('0x5f'))[_0x6e62('0x82')]('NOW()',_0x6e62('0x59'))[_0x6e62('0x82')](_0x6e62('0xa5'),_0x6e62('0x5a'))[_0x6e62('0x84')](_0x6e62('0xa6'))['where'](_0x6e62('0xad'))[_0x6e62('0x3e')](_0x6e62('0xae'),_0x63ab36[_0x6e62('0xa7')][_0x6e62('0xa8')]())[_0x6e62('0x3e')](_0x6e62('0xa9')))[_0x6e62('0xa8')]();}_0x550b14[_0x6e62('0x93')](db[_0x6e62('0x74')]['query'](_0x5cc590));}return BPromise[_0x6e62('0x8d')](_0x550b14);}})[_0x6e62('0x26')](function(){return _0x14cdbb;})[_0x6e62('0x26')](respondWithResult(_0x7faa54,null))[_0x6e62('0x44')](handleError(_0x7faa54,null));};exports[_0x6e62('0xb0')]=function(_0x1c20db,_0x32ef2d,_0x13a7de){return db[_0x6e62('0x32')][_0x6e62('0x49')]({'where':{'id':_0x1c20db[_0x6e62('0x46')]['id']}})[_0x6e62('0x26')](handleEntityNotFound(_0x32ef2d,null))[_0x6e62('0x26')](function(_0x1500dc){if(_0x1500dc){return _0x1500dc[_0x6e62('0xb0')](_0x1c20db[_0x6e62('0x37')][_0x6e62('0x81')]);}})[_0x6e62('0x26')](function(_0x17928d){if(_0x17928d){return db[_0x6e62('0x5d')]['destroy']({'where':{'ListId':_0x1c20db[_0x6e62('0x37')][_0x6e62('0x81')],'VoiceQueueId':_0x1c20db[_0x6e62('0x46')]['id']}})[_0x6e62('0x26')](function(){return _0x17928d;});}})[_0x6e62('0x26')](respondWithStatusCode(_0x32ef2d,null))['catch'](handleError(_0x32ef2d,null));};exports[_0x6e62('0xb1')]=function(_0x36348b,_0x1911e3,_0x340779){var _0x2bb36d={};var _0x353ae6={};var _0x27919c;var _0x457aff;return db[_0x6e62('0x32')][_0x6e62('0x5c')]({'where':{'id':_0x36348b[_0x6e62('0x46')]['id']}})[_0x6e62('0x26')](handleEntityNotFound(_0x1911e3,null))['then'](function(_0x4d39d0){if(_0x4d39d0){_0x27919c=_0x4d39d0;_0x353ae6['model']=_[_0x6e62('0x38')](db[_0x6e62('0x98')][_0x6e62('0x33')]);_0x353ae6[_0x6e62('0x37')]=_['keys'](_0x36348b[_0x6e62('0x37')]);_0x353ae6[_0x6e62('0x3f')]=_[_0x6e62('0x47')](_0x353ae6[_0x6e62('0x36')],_0x353ae6['query']);_0x2bb36d[_0x6e62('0x39')]=_[_0x6e62('0x47')](_0x353ae6[_0x6e62('0x36')],qs[_0x6e62('0x3a')](_0x36348b[_0x6e62('0x37')][_0x6e62('0x3a')]));_0x2bb36d[_0x6e62('0x39')]=_0x2bb36d[_0x6e62('0x39')]['length']?_0x2bb36d[_0x6e62('0x39')]:_0x353ae6['model'];_0x2bb36d['order']=qs[_0x6e62('0x3d')](_0x36348b[_0x6e62('0x37')][_0x6e62('0x3d')]);_0x2bb36d[_0x6e62('0x3e')]=qs[_0x6e62('0x3f')](_[_0x6e62('0x40')](_0x36348b[_0x6e62('0x37')],_0x353ae6['filters']));if(_0x36348b[_0x6e62('0x37')][_0x6e62('0x42')]){_0x2bb36d[_0x6e62('0x3e')]=_['merge'](_0x2bb36d[_0x6e62('0x3e')],{'$or':_[_0x6e62('0x2a')](_0x2bb36d[_0x6e62('0x39')],function(_0x168c24){var _0x2b0178={};_0x2b0178[_0x168c24]={'$like':'%'+_0x36348b[_0x6e62('0x37')][_0x6e62('0x42')]+'%'};return _0x2b0178;})});}_0x2bb36d=_[_0x6e62('0x41')]({},_0x2bb36d,_0x36348b[_0x6e62('0x43')]);return _0x27919c[_0x6e62('0xb1')](_0x2bb36d);}})[_0x6e62('0x26')](function(_0x8427da){if(_0x8427da){_0x457aff=_0x8427da[_0x6e62('0x48')];if(!_0x36348b[_0x6e62('0x37')][_0x6e62('0x5e')](_0x6e62('0x3b'))){_0x2bb36d[_0x6e62('0x1f')]=qs[_0x6e62('0x1f')](_0x36348b[_0x6e62('0x37')][_0x6e62('0x1f')]);_0x2bb36d[_0x6e62('0x1e')]=qs[_0x6e62('0x1e')](_0x36348b[_0x6e62('0x37')][_0x6e62('0x1e')]);}return _0x27919c[_0x6e62('0xb1')](_0x2bb36d);}})[_0x6e62('0x26')](function(_0x1b91dd){if(_0x1b91dd){return _0x1b91dd?{'count':_0x457aff,'rows':_0x1b91dd}:null;}})[_0x6e62('0x26')](respondWithResult(_0x1911e3,null))[_0x6e62('0x44')](handleError(_0x1911e3,null));};exports[_0x6e62('0xb2')]=function(_0x2684c0,_0x2cfad3,_0x3617e3){var _0x58fcfb,_0x528cbf;return db[_0x6e62('0x32')][_0x6e62('0x49')]({'where':{'id':_0x2684c0[_0x6e62('0x46')]['id']}})[_0x6e62('0x26')](handleEntityNotFound(_0x2cfad3,null))['then'](function(_0x5dab03){if(_0x5dab03){_0x528cbf=_0x5dab03;return _0x5dab03[_0x6e62('0xb2')](_0x2684c0[_0x6e62('0x4b')][_0x6e62('0x81')],_['omit'](_0x2684c0[_0x6e62('0x4b')],['ids','id'])||{});}return null;})[_0x6e62('0x91')](function(_0x35a31d){var _0x49a49a;_0x58fcfb=_0x35a31d||[];var _0x4a788d=[];if(_0x35a31d){for(var _0x1174d8=0x0;_0x1174d8<_0x35a31d[_0x6e62('0x48')];_0x1174d8+=0x1){var _0x7996b4=_0x35a31d[_0x1174d8][_0x6e62('0x4d')]({'plain':!![]});_0x49a49a=squel['insert']()['into'](_0x6e62('0xb3'))[_0x6e62('0x9f')](['phone',_0x6e62('0xa1'),_0x6e62('0xa2'),_0x6e62('0x5f'),'createdAt',_0x6e62('0x5a')],squel[_0x6e62('0xa3')]()[_0x6e62('0x82')](_0x6e62('0xa4'),_0x6e62('0xa4'))[_0x6e62('0x82')]('id',_0x6e62('0xa1'))[_0x6e62('0x82')](_0x7996b4['CmListId'][_0x6e62('0xa8')](),_0x6e62('0xa2'))[_0x6e62('0x82')](_0x2684c0['params']['id']['toString'](),'VoiceQueueId')[_0x6e62('0x82')](_0x6e62('0xa5'),'createdAt')['field'](_0x6e62('0xa5'),'updatedAt')[_0x6e62('0x84')](_0x6e62('0xa6'))[_0x6e62('0x3e')](_0x6e62('0xad'))[_0x6e62('0x3e')](_0x6e62('0xae'),_0x7996b4[_0x6e62('0xa7')][_0x6e62('0xa8')]())[_0x6e62('0x3e')](_0x6e62('0xa9')))['toString']();_0x4a788d[_0x6e62('0x93')](db[_0x6e62('0x74')][_0x6e62('0x37')](_0x49a49a));}return BPromise[_0x6e62('0x8d')](_0x4a788d);}})[_0x6e62('0x26')](function(){return _0x58fcfb;})[_0x6e62('0x26')](respondWithResult(_0x2cfad3,null))['catch'](handleError(_0x2cfad3,null));};exports[_0x6e62('0xb4')]=function(_0x5f1de1,_0x42082d,_0x44cbcf){return db[_0x6e62('0x32')]['find']({'where':{'id':_0x5f1de1[_0x6e62('0x46')]['id']}})['then'](handleEntityNotFound(_0x42082d,null))['then'](function(_0x302883){if(_0x302883){return _0x302883[_0x6e62('0xb4')](_0x5f1de1[_0x6e62('0x37')][_0x6e62('0x81')]);}})[_0x6e62('0x26')](function(_0x1ff6b5){if(_0x1ff6b5){return db[_0x6e62('0x67')][_0x6e62('0x27')]({'where':{'ListId':_0x5f1de1[_0x6e62('0x37')][_0x6e62('0x81')],'VoiceQueueId':_0x5f1de1[_0x6e62('0x46')]['id']}})[_0x6e62('0x26')](function(){return _0x1ff6b5;});}})[_0x6e62('0x26')](respondWithStatusCode(_0x42082d,null))[_0x6e62('0x44')](handleError(_0x42082d,null));};
\ No newline at end of file
+var _0x9bfb=['Team','teams','voicePause','interface','flatMap','penalty','Agents','transaction','each','TeamVoiceQueue','upsert','findOrCreate','UserVoiceQueueRt','isNil','format','forEach','emit','userVoiceQueue:save','removeTeams','ids','User','select','field','tq.TeamId','from','team_has_voice_queues','join','VoiceQueueId\x20=\x20?','ut.UserId\x20=\x20?','push','sequelize','toString','QueryTypes','every','all','union','compact','isEmpty','removeAgents','userVoiceQueue:remove','addAgents','online','SIP/%s','isArray','getAgents','getMembers','CmList','getLists','addLists','spread','dialCheckDuplicateType','always','insert','cm_hopper','fromQuery','phone','ListId','NOW()','scheduledAt','ContactId','CmListId','cm_contacts','ListId\x20=\x20?','phone\x20IS\x20NOT\x20NULL','phone\x20NOT\x20IN\x20(?)','COALESCE(calleridnum,\x27\x27)','COALESCE(phone,\x27\x27)','into','deletedAt\x20IS\x20NULL','removeLists','getBlackLists','addBlackLists','cm_hopper_black','removeBlackLists','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','path','fs-extra','squel','crypto','jsforce','desk.js','to-csv','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','api','../../mysqldb','defaults','redis','localhost','socket.io-emitter','./voiceQueue.socket','register','sendStatus','status','json','offset','limit','set','Content-Range','apply','reject','save','update','get','QueueCampaigns','outbound','filter','ignore','value','includes','type','find','name','destroy','then','end','stack','send','index','map','VoiceQueue','rawAttributes','fieldName','key','query','filters','attributes','intersection','fields','length','model','hasOwnProperty','nolimit','order','sort','where','pick','merge','VIRTUAL','options','count','include','findAll','show','keys','includeAll','catch','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','VoiceQueues','inbound','UserProfileSection','userProfileId','autoAssociation','UserProfileResource','error','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','clone','params','omit','createdAt','updatedAt','getHoppers','findOne','CmHopper','VoiceQueueId','rows','getHopperHistories','CmHopperHistory','getHopperFinals','CmHopperFinal','getHopperBlacks','CmHopperBlack','getTeams'];(function(_0x4a9fb1,_0x273043){var _0x348672=function(_0x142b69){while(--_0x142b69){_0x4a9fb1['push'](_0x4a9fb1['shift']());}};_0x348672(++_0x273043);}(_0x9bfb,0x1c0));var _0xb9bf=function(_0x218ca4,_0x41cc40){_0x218ca4=_0x218ca4-0x0;var _0x1b3ff9=_0x9bfb[_0x218ca4];return _0x1b3ff9;};'use strict';var emlformat=require(_0xb9bf('0x0'));var rimraf=require(_0xb9bf('0x1'));var zipdir=require(_0xb9bf('0x2'));var jsonpatch=require(_0xb9bf('0x3'));var rp=require(_0xb9bf('0x4'));var moment=require(_0xb9bf('0x5'));var BPromise=require(_0xb9bf('0x6'));var Mustache=require(_0xb9bf('0x7'));var util=require('util');var path=require(_0xb9bf('0x8'));var sox=require('sox');var csv=require('to-csv');var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0xb9bf('0x9'));var _=require('lodash');var squel=require(_0xb9bf('0xa'));var crypto=require(_0xb9bf('0xb'));var jsforce=require(_0xb9bf('0xc'));var deskjs=require(_0xb9bf('0xd'));var toCsv=require(_0xb9bf('0xe'));var querystring=require('querystring');var Papa=require(_0xb9bf('0xf'));var Redis=require(_0xb9bf('0x10'));var authService=require(_0xb9bf('0x11'));var qs=require(_0xb9bf('0x12'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xb9bf('0x13'));var logger=require('../../config/logger')(_0xb9bf('0x14'));var utils=require('../../config/utils');var config=require('../../config/environment');var licenseUtil=require('../../config/license/util');var db=require(_0xb9bf('0x15'))['db'];config['redis']=_[_0xb9bf('0x16')](config[_0xb9bf('0x17')],{'host':_0xb9bf('0x18'),'port':0x18eb});var socket=require(_0xb9bf('0x19'))(new Redis(config[_0xb9bf('0x17')]));require(_0xb9bf('0x1a'))[_0xb9bf('0x1b')](socket);function respondWithStatusCode(_0x56be0f,_0x306cc9){_0x306cc9=_0x306cc9||0xcc;return function(_0x273038){if(_0x273038){return _0x56be0f[_0xb9bf('0x1c')](_0x306cc9);}return _0x56be0f['status'](_0x306cc9)['end']();};}function respondWithResult(_0xa9e664,_0x42324c){_0x42324c=_0x42324c||0xc8;return function(_0x5b0e1a){if(_0x5b0e1a){return _0xa9e664[_0xb9bf('0x1d')](_0x42324c)[_0xb9bf('0x1e')](_0x5b0e1a);}};}function respondWithFilteredResult(_0x439de9,_0x16a81e){return function(_0x375ff9){if(_0x375ff9){var _0x45138a=_0x375ff9['count'],_0xb72759=_0x16a81e[_0xb9bf('0x1f')],_0x28bcba=_0x16a81e['offset']+_0x16a81e[_0xb9bf('0x20')],_0x56b7ef;if(_0x28bcba>=_0x45138a){_0x28bcba=_0x45138a;_0x56b7ef=0xc8;}else{_0x56b7ef=0xce;}_0x439de9[_0xb9bf('0x1d')](_0x56b7ef);return _0x439de9[_0xb9bf('0x21')](_0xb9bf('0x22'),_0xb72759+'-'+_0x28bcba+'/'+_0x45138a)[_0xb9bf('0x1e')](_0x375ff9);}return null;};}function patchUpdates(_0xd1e9cf){return function(_0xc9c964){try{jsonpatch[_0xb9bf('0x23')](_0xc9c964,_0xd1e9cf,!![]);}catch(_0x4bf359){return BPromise[_0xb9bf('0x24')](_0x4bf359);}return _0xc9c964[_0xb9bf('0x25')]();};}function saveUpdates(_0x440a20,_0x46d636){return function(_0x3758e3){if(_0x3758e3){return _0x3758e3[_0xb9bf('0x26')](_0x440a20)['then'](function(_0x47544a){return _0x47544a;});}return null;};}function removeEntity(_0x3098e6,_0x6a8149){return function(_0x54d005){if(_0x54d005){return _0x54d005['destroy']()['then'](function(){var _0x7471a5=_0x54d005[_0xb9bf('0x27')]({'plain':!![]});var _0x4f9ece=[{'name':'VoiceQueues','value':'inbound','ignore':![]},{'name':_0xb9bf('0x28'),'value':_0xb9bf('0x29'),'ignore':![]}];var _0x512b27=_(_0x4f9ece)[_0xb9bf('0x2a')](_0xb9bf('0x2b'))['map'](_0xb9bf('0x2c'))[_0xb9bf('0x2c')]();if(_[_0xb9bf('0x2d')](_0x512b27,_0x7471a5[_0xb9bf('0x2e')])){return;}var _0x536c30=_[_0xb9bf('0x2f')](_0x4f9ece,[_0xb9bf('0x2c'),_0x7471a5[_0xb9bf('0x2e')]])[_0xb9bf('0x30')];return db['UserProfileResource'][_0xb9bf('0x31')]({'where':{'type':_0x536c30,'resourceId':_0x7471a5['id']}})[_0xb9bf('0x32')](function(){return _0x54d005;});})['then'](function(){_0x3098e6[_0xb9bf('0x1d')](0xcc)[_0xb9bf('0x33')]();});}};}function handleEntityNotFound(_0x3d4c7b,_0x282dfb){return function(_0x241b59){if(!_0x241b59){_0x3d4c7b['sendStatus'](0x194);}return _0x241b59;};}function handleError(_0x1de822,_0x3172b7){_0x3172b7=_0x3172b7||0x1f4;return function(_0x5427ba){logger['error'](_0x5427ba[_0xb9bf('0x34')]);if(_0x5427ba[_0xb9bf('0x30')]){delete _0x5427ba[_0xb9bf('0x30')];}_0x1de822['status'](_0x3172b7)[_0xb9bf('0x35')](_0x5427ba);};}exports[_0xb9bf('0x36')]=function(_0x35aefb,_0x110068){var _0x353bb9={},_0x4c371d={},_0x40a822={'count':0x0,'rows':[]};var _0x3ca146=_[_0xb9bf('0x37')](db[_0xb9bf('0x38')][_0xb9bf('0x39')],function(_0xb091f5){return{'name':_0xb091f5[_0xb9bf('0x3a')],'type':_0xb091f5['type'][_0xb9bf('0x3b')]};});_0x4c371d['model']=_[_0xb9bf('0x37')](_0x3ca146,'name');_0x4c371d[_0xb9bf('0x3c')]=_['keys'](_0x35aefb[_0xb9bf('0x3c')]);_0x4c371d[_0xb9bf('0x3d')]=_['intersection'](_0x4c371d['model'],_0x4c371d[_0xb9bf('0x3c')]);_0x353bb9[_0xb9bf('0x3e')]=_[_0xb9bf('0x3f')](_0x4c371d['model'],qs['fields'](_0x35aefb[_0xb9bf('0x3c')][_0xb9bf('0x40')]));_0x353bb9[_0xb9bf('0x3e')]=_0x353bb9['attributes'][_0xb9bf('0x41')]?_0x353bb9[_0xb9bf('0x3e')]:_0x4c371d[_0xb9bf('0x42')];if(!_0x35aefb['query'][_0xb9bf('0x43')](_0xb9bf('0x44'))){_0x353bb9['limit']=qs['limit'](_0x35aefb['query'][_0xb9bf('0x20')]);_0x353bb9['offset']=qs[_0xb9bf('0x1f')](_0x35aefb['query'][_0xb9bf('0x1f')]);}_0x353bb9[_0xb9bf('0x45')]=qs['sort'](_0x35aefb[_0xb9bf('0x3c')][_0xb9bf('0x46')]);_0x353bb9[_0xb9bf('0x47')]=qs[_0xb9bf('0x3d')](_[_0xb9bf('0x48')](_0x35aefb['query'],_0x4c371d['filters']),_0x3ca146);if(_0x35aefb[_0xb9bf('0x3c')]['filter']){_0x353bb9[_0xb9bf('0x47')]=_[_0xb9bf('0x49')](_0x353bb9[_0xb9bf('0x47')],{'$or':_[_0xb9bf('0x37')](_0x3ca146,function(_0x44ae71){if(_0x44ae71[_0xb9bf('0x2e')]!==_0xb9bf('0x4a')){var _0x2588a8={};_0x2588a8[_0x44ae71[_0xb9bf('0x30')]]={'$like':'%'+_0x35aefb['query'][_0xb9bf('0x2a')]+'%'};return _0x2588a8;}})});}_0x353bb9=_[_0xb9bf('0x49')]({},_0x353bb9,_0x35aefb[_0xb9bf('0x4b')]);var _0x5034ad={'where':_0x353bb9[_0xb9bf('0x47')]};return db['VoiceQueue']['count'](_0x5034ad)[_0xb9bf('0x32')](function(_0x57ae18){_0x40a822[_0xb9bf('0x4c')]=_0x57ae18;if(_0x35aefb[_0xb9bf('0x3c')]['includeAll']){_0x353bb9[_0xb9bf('0x4d')]=[{'all':!![]}];}return db[_0xb9bf('0x38')][_0xb9bf('0x4e')](_0x353bb9);})[_0xb9bf('0x32')](function(_0xec6cc1){_0x40a822['rows']=_0xec6cc1;return _0x40a822;})[_0xb9bf('0x32')](respondWithFilteredResult(_0x110068,_0x353bb9))['catch'](handleError(_0x110068,null));};exports[_0xb9bf('0x4f')]=function(_0x2ab3b8,_0x97828b){var _0xdd5db3={'raw':![],'where':{'id':_0x2ab3b8['params']['id']}},_0x29dddc={};_0x29dddc[_0xb9bf('0x42')]=_[_0xb9bf('0x50')](db[_0xb9bf('0x38')][_0xb9bf('0x39')]);_0x29dddc[_0xb9bf('0x3c')]=_[_0xb9bf('0x50')](_0x2ab3b8[_0xb9bf('0x3c')]);_0x29dddc[_0xb9bf('0x3d')]=_[_0xb9bf('0x3f')](_0x29dddc[_0xb9bf('0x42')],_0x29dddc[_0xb9bf('0x3c')]);_0xdd5db3[_0xb9bf('0x3e')]=_[_0xb9bf('0x3f')](_0x29dddc[_0xb9bf('0x42')],qs[_0xb9bf('0x40')](_0x2ab3b8[_0xb9bf('0x3c')][_0xb9bf('0x40')]));_0xdd5db3[_0xb9bf('0x3e')]=_0xdd5db3[_0xb9bf('0x3e')][_0xb9bf('0x41')]?_0xdd5db3[_0xb9bf('0x3e')]:_0x29dddc[_0xb9bf('0x42')];if(_0x2ab3b8[_0xb9bf('0x3c')][_0xb9bf('0x51')]){_0xdd5db3[_0xb9bf('0x4d')]=[{'all':!![]}];}_0xdd5db3=_[_0xb9bf('0x49')]({},_0xdd5db3,_0x2ab3b8['options']);return db[_0xb9bf('0x38')][_0xb9bf('0x2f')](_0xdd5db3)[_0xb9bf('0x32')](handleEntityNotFound(_0x97828b,null))[_0xb9bf('0x32')](respondWithResult(_0x97828b,null))[_0xb9bf('0x52')](handleError(_0x97828b,null));};exports['create']=function(_0x490d8f,_0x52b326){return db[_0xb9bf('0x38')][_0xb9bf('0x53')](_0x490d8f[_0xb9bf('0x54')],{})['then'](function(_0x19f091){var _0x18d353=_0x490d8f[_0xb9bf('0x55')]['get']({'plain':!![]});if(!_0x18d353)throw new Error(_0xb9bf('0x56'));if(_0x18d353[_0xb9bf('0x57')]===_0xb9bf('0x55')){var _0x2fd267=_0x19f091['get']({'plain':!![]});var _0x14b2a9=[{'name':_0xb9bf('0x58'),'value':_0xb9bf('0x59')},{'name':_0xb9bf('0x28'),'value':_0xb9bf('0x29')}];var _0xada234=_['find'](_0x14b2a9,['value',_0x2fd267[_0xb9bf('0x2e')]])[_0xb9bf('0x30')];return db[_0xb9bf('0x5a')][_0xb9bf('0x2f')]({'where':{'name':_0xada234,'userProfileId':_0x18d353[_0xb9bf('0x5b')]},'raw':!![]})['then'](function(_0x538974){if(_0x538974&&_0x538974[_0xb9bf('0x5c')]===0x0){return db[_0xb9bf('0x5d')]['create']({'name':_0x2fd267[_0xb9bf('0x30')],'resourceId':_0x2fd267['id'],'type':_0x538974[_0xb9bf('0x30')],'sectionId':_0x538974['id']},{})[_0xb9bf('0x32')](function(){return _0x19f091;});}else{return _0x19f091;}})[_0xb9bf('0x52')](function(_0x864ad9){logger[_0xb9bf('0x5e')](_0xb9bf('0x5f'),_0x864ad9);throw _0x864ad9;});}return _0x19f091;})[_0xb9bf('0x32')](respondWithResult(_0x52b326,0xc9))['catch'](handleError(_0x52b326,null));};exports[_0xb9bf('0x60')]=function(_0x2139fe,_0x4157bd){var _0x157af1={'where':{'id':_0x2139fe[_0xb9bf('0x61')]['id']}},_0x159291={};_0x159291['model']=_['keys'](db[_0xb9bf('0x38')][_0xb9bf('0x39')]);_0x157af1['attributes']=_[_0xb9bf('0x3f')](_0x159291[_0xb9bf('0x42')],qs[_0xb9bf('0x40')](_0x2139fe[_0xb9bf('0x3c')][_0xb9bf('0x40')]));_0x157af1[_0xb9bf('0x3e')]=_0x157af1[_0xb9bf('0x3e')][_0xb9bf('0x41')]?_0x157af1[_0xb9bf('0x3e')]:_0x159291[_0xb9bf('0x42')];if(_0x2139fe['query'][_0xb9bf('0x51')]){_0x157af1[_0xb9bf('0x4d')]=[{'all':!![]}];}_0x157af1=_['merge']({},_0x157af1,_0x2139fe['options']);return db[_0xb9bf('0x38')][_0xb9bf('0x2f')](_0x157af1)[_0xb9bf('0x32')](handleEntityNotFound(_0x4157bd,null))[_0xb9bf('0x32')](function(_0x10be77){if(_0x10be77){var _0x2e102a=_0x10be77[_0xb9bf('0x27')]({'plain':!![]});_0x2e102a=qs[_0xb9bf('0x62')](_0x2e102a,['id',_0xb9bf('0x63'),_0xb9bf('0x64')]);_0x2139fe['body']=_[_0xb9bf('0x62')](_0x2139fe[_0xb9bf('0x54')],['id',_0xb9bf('0x63'),_0xb9bf('0x64')]);return db[_0xb9bf('0x38')][_0xb9bf('0x53')](_[_0xb9bf('0x49')](_0x2e102a,_0x2139fe[_0xb9bf('0x54')]),{'include':_0x2139fe[_0xb9bf('0x3c')][_0xb9bf('0x51')]?[{'all':!![]}]:undefined})['then'](function(_0x447724){var _0x818bd0=_0x2139fe[_0xb9bf('0x55')][_0xb9bf('0x27')]({'plain':!![]});if(!_0x818bd0)throw new Error(_0xb9bf('0x56'));if(_0x818bd0[_0xb9bf('0x57')]===_0xb9bf('0x55')){var _0x5b0859=_0x447724[_0xb9bf('0x27')]({'plain':!![]});var _0x2a0b89=[{'name':_0xb9bf('0x58'),'value':_0xb9bf('0x59')},{'name':'QueueCampaigns','value':'outbound'}];var _0x48e035=_['find'](_0x2a0b89,[_0xb9bf('0x2c'),_0x5b0859[_0xb9bf('0x2e')]])['name'];return db['UserProfileSection'][_0xb9bf('0x2f')]({'where':{'name':_0x48e035,'userProfileId':_0x818bd0[_0xb9bf('0x5b')]},'raw':!![]})[_0xb9bf('0x32')](function(_0x25911d){if(_0x25911d&&_0x25911d[_0xb9bf('0x5c')]===0x0){return db['UserProfileResource']['create']({'name':_0x5b0859[_0xb9bf('0x30')],'resourceId':_0x5b0859['id'],'type':_0x25911d[_0xb9bf('0x30')],'sectionId':_0x25911d['id']},{})[_0xb9bf('0x32')](function(){return _0x447724;});}else{return _0x447724;}})['catch'](function(_0x2e0735){logger[_0xb9bf('0x5e')](_0xb9bf('0x5f'),_0x2e0735);throw _0x2e0735;});}return _0x447724;});}})[_0xb9bf('0x32')](respondWithResult(_0x4157bd,0xc9))[_0xb9bf('0x52')](handleError(_0x4157bd,null));};exports[_0xb9bf('0x26')]=function(_0x12c6bd,_0x2ae4a0){if(_0x12c6bd[_0xb9bf('0x54')]['id']){delete _0x12c6bd[_0xb9bf('0x54')]['id'];}return db[_0xb9bf('0x38')][_0xb9bf('0x2f')]({'where':{'id':_0x12c6bd[_0xb9bf('0x61')]['id']}})[_0xb9bf('0x32')](handleEntityNotFound(_0x2ae4a0,null))[_0xb9bf('0x32')](saveUpdates(_0x12c6bd[_0xb9bf('0x54')],null))['then'](respondWithResult(_0x2ae4a0,null))[_0xb9bf('0x52')](handleError(_0x2ae4a0,null));};exports[_0xb9bf('0x31')]=function(_0x12f2ab,_0x18e763){return db[_0xb9bf('0x38')][_0xb9bf('0x2f')]({'where':{'id':_0x12f2ab[_0xb9bf('0x61')]['id']}})[_0xb9bf('0x32')](handleEntityNotFound(_0x18e763,null))[_0xb9bf('0x32')](removeEntity(_0x18e763,null))[_0xb9bf('0x52')](handleError(_0x18e763,null));};exports[_0xb9bf('0x65')]=function(_0x21ea92,_0x73aeb6,_0x23be45){var _0x595a00={'raw':![],'where':{}};var _0x5df005={};var _0x539217={'count':0x0,'rows':[]};return db['VoiceQueue'][_0xb9bf('0x66')]({'where':{'id':_0x21ea92[_0xb9bf('0x61')]['id']}})[_0xb9bf('0x32')](handleEntityNotFound(_0x73aeb6,null))[_0xb9bf('0x32')](function(_0x53c970){if(_0x53c970){_0x5df005[_0xb9bf('0x42')]=_[_0xb9bf('0x50')](db[_0xb9bf('0x67')][_0xb9bf('0x39')]);_0x5df005[_0xb9bf('0x3c')]=_['keys'](_0x21ea92[_0xb9bf('0x3c')]);_0x5df005[_0xb9bf('0x3d')]=_['intersection'](_0x5df005['model'],_0x5df005[_0xb9bf('0x3c')]);_0x595a00[_0xb9bf('0x3e')]=_[_0xb9bf('0x3f')](_0x5df005[_0xb9bf('0x42')],qs['fields'](_0x21ea92['query'][_0xb9bf('0x40')]));_0x595a00[_0xb9bf('0x3e')]=_0x595a00[_0xb9bf('0x3e')][_0xb9bf('0x41')]?_0x595a00[_0xb9bf('0x3e')]:_0x5df005[_0xb9bf('0x42')];if(!_0x21ea92[_0xb9bf('0x3c')]['hasOwnProperty'](_0xb9bf('0x44'))){_0x595a00['limit']=qs['limit'](_0x21ea92[_0xb9bf('0x3c')][_0xb9bf('0x20')]);_0x595a00[_0xb9bf('0x1f')]=qs['offset'](_0x21ea92[_0xb9bf('0x3c')][_0xb9bf('0x1f')]);}_0x595a00['order']=qs[_0xb9bf('0x46')](_0x21ea92[_0xb9bf('0x3c')]['sort']);_0x595a00[_0xb9bf('0x47')]=qs[_0xb9bf('0x3d')](_[_0xb9bf('0x48')](_0x21ea92[_0xb9bf('0x3c')],_0x5df005['filters']));_0x595a00[_0xb9bf('0x47')][_0xb9bf('0x68')]=_0x53c970['id'];if(_0x21ea92[_0xb9bf('0x3c')][_0xb9bf('0x2a')]){_0x595a00[_0xb9bf('0x47')]=_['merge'](_0x595a00[_0xb9bf('0x47')],{'$or':_[_0xb9bf('0x37')](_0x595a00[_0xb9bf('0x3e')],function(_0x37fe2b){var _0xced5fc={};_0xced5fc[_0x37fe2b]={'$like':'%'+_0x21ea92['query'][_0xb9bf('0x2a')]+'%'};return _0xced5fc;})});}_0x595a00=_[_0xb9bf('0x49')]({},_0x595a00,_0x21ea92[_0xb9bf('0x4b')]);return db[_0xb9bf('0x67')]['count']({'where':_0x595a00[_0xb9bf('0x47')]})[_0xb9bf('0x32')](function(_0x5a439c){_0x539217[_0xb9bf('0x4c')]=_0x5a439c;if(_0x21ea92[_0xb9bf('0x3c')][_0xb9bf('0x51')]){_0x595a00[_0xb9bf('0x4d')]=[{'all':!![]}];}return db[_0xb9bf('0x67')][_0xb9bf('0x4e')](_0x595a00);})[_0xb9bf('0x32')](function(_0x7c8610){_0x539217[_0xb9bf('0x69')]=_0x7c8610;return _0x539217;});}})['then'](respondWithFilteredResult(_0x73aeb6,_0x595a00))[_0xb9bf('0x52')](handleError(_0x73aeb6,null));};exports[_0xb9bf('0x6a')]=function(_0x11b208,_0x3c2142,_0x43acb2){var _0x58c446={'raw':!![],'where':{}};var _0x1b551a={};var _0x3af337={'count':0x0,'rows':[]};return db[_0xb9bf('0x38')][_0xb9bf('0x66')]({'where':{'id':_0x11b208[_0xb9bf('0x61')]['id']}})[_0xb9bf('0x32')](handleEntityNotFound(_0x3c2142,null))[_0xb9bf('0x32')](function(_0x1a61a9){if(_0x1a61a9){_0x1b551a[_0xb9bf('0x42')]=_[_0xb9bf('0x50')](db[_0xb9bf('0x6b')][_0xb9bf('0x39')]);_0x1b551a[_0xb9bf('0x3c')]=_[_0xb9bf('0x50')](_0x11b208['query']);_0x1b551a[_0xb9bf('0x3d')]=_[_0xb9bf('0x3f')](_0x1b551a[_0xb9bf('0x42')],_0x1b551a[_0xb9bf('0x3c')]);_0x58c446[_0xb9bf('0x3e')]=_[_0xb9bf('0x3f')](_0x1b551a[_0xb9bf('0x42')],qs[_0xb9bf('0x40')](_0x11b208[_0xb9bf('0x3c')]['fields']));_0x58c446[_0xb9bf('0x3e')]=_0x58c446[_0xb9bf('0x3e')]['length']?_0x58c446[_0xb9bf('0x3e')]:_0x1b551a['model'];if(!_0x11b208[_0xb9bf('0x3c')][_0xb9bf('0x43')]('nolimit')){_0x58c446[_0xb9bf('0x20')]=qs['limit'](_0x11b208[_0xb9bf('0x3c')]['limit']);_0x58c446['offset']=qs[_0xb9bf('0x1f')](_0x11b208[_0xb9bf('0x3c')][_0xb9bf('0x1f')]);}_0x58c446[_0xb9bf('0x45')]=qs[_0xb9bf('0x46')](_0x11b208[_0xb9bf('0x3c')][_0xb9bf('0x46')]);_0x58c446['where']=qs[_0xb9bf('0x3d')](_[_0xb9bf('0x48')](_0x11b208[_0xb9bf('0x3c')],_0x1b551a[_0xb9bf('0x3d')]));_0x58c446[_0xb9bf('0x47')]['VoiceQueueId']=_0x1a61a9['id'];if(_0x11b208[_0xb9bf('0x3c')][_0xb9bf('0x2a')]){_0x58c446['where']=_[_0xb9bf('0x49')](_0x58c446[_0xb9bf('0x47')],{'$or':_[_0xb9bf('0x37')](_0x58c446['attributes'],function(_0xfcf825){var _0x42fb80={};_0x42fb80[_0xfcf825]={'$like':'%'+_0x11b208[_0xb9bf('0x3c')]['filter']+'%'};return _0x42fb80;})});}_0x58c446=_[_0xb9bf('0x49')]({},_0x58c446,_0x11b208['options']);return db[_0xb9bf('0x6b')][_0xb9bf('0x4c')]({'where':_0x58c446[_0xb9bf('0x47')]})[_0xb9bf('0x32')](function(_0x53f7d6){_0x3af337[_0xb9bf('0x4c')]=_0x53f7d6;if(_0x11b208['query'][_0xb9bf('0x51')]){_0x58c446[_0xb9bf('0x4d')]=[{'all':!![]}];}return db[_0xb9bf('0x6b')][_0xb9bf('0x4e')](_0x58c446);})[_0xb9bf('0x32')](function(_0x1d5a58){_0x3af337[_0xb9bf('0x69')]=_0x1d5a58;return _0x3af337;});}})[_0xb9bf('0x32')](respondWithFilteredResult(_0x3c2142,_0x58c446))['catch'](handleError(_0x3c2142,null));};exports[_0xb9bf('0x6c')]=function(_0x2b74d0,_0xb0710f,_0x41fb88){var _0x59ea5f={'raw':!![],'where':{}};var _0xe6f445={};var _0x200921={'count':0x0,'rows':[]};return db[_0xb9bf('0x38')]['findOne']({'where':{'id':_0x2b74d0[_0xb9bf('0x61')]['id']}})['then'](handleEntityNotFound(_0xb0710f,null))[_0xb9bf('0x32')](function(_0x3a8544){if(_0x3a8544){_0xe6f445[_0xb9bf('0x42')]=_['keys'](db[_0xb9bf('0x6d')][_0xb9bf('0x39')]);_0xe6f445[_0xb9bf('0x3c')]=_['keys'](_0x2b74d0[_0xb9bf('0x3c')]);_0xe6f445['filters']=_['intersection'](_0xe6f445[_0xb9bf('0x42')],_0xe6f445[_0xb9bf('0x3c')]);_0x59ea5f[_0xb9bf('0x3e')]=_['intersection'](_0xe6f445[_0xb9bf('0x42')],qs['fields'](_0x2b74d0[_0xb9bf('0x3c')][_0xb9bf('0x40')]));_0x59ea5f[_0xb9bf('0x3e')]=_0x59ea5f[_0xb9bf('0x3e')][_0xb9bf('0x41')]?_0x59ea5f['attributes']:_0xe6f445[_0xb9bf('0x42')];if(!_0x2b74d0[_0xb9bf('0x3c')]['hasOwnProperty'](_0xb9bf('0x44'))){_0x59ea5f[_0xb9bf('0x20')]=qs[_0xb9bf('0x20')](_0x2b74d0[_0xb9bf('0x3c')][_0xb9bf('0x20')]);_0x59ea5f[_0xb9bf('0x1f')]=qs[_0xb9bf('0x1f')](_0x2b74d0[_0xb9bf('0x3c')][_0xb9bf('0x1f')]);}_0x59ea5f[_0xb9bf('0x45')]=qs[_0xb9bf('0x46')](_0x2b74d0[_0xb9bf('0x3c')]['sort']);_0x59ea5f['where']=qs['filters'](_[_0xb9bf('0x48')](_0x2b74d0[_0xb9bf('0x3c')],_0xe6f445[_0xb9bf('0x3d')]));_0x59ea5f[_0xb9bf('0x47')]['VoiceQueueId']=_0x3a8544['id'];if(_0x2b74d0[_0xb9bf('0x3c')][_0xb9bf('0x2a')]){_0x59ea5f[_0xb9bf('0x47')]=_[_0xb9bf('0x49')](_0x59ea5f[_0xb9bf('0x47')],{'$or':_[_0xb9bf('0x37')](_0x59ea5f['attributes'],function(_0x1c1564){var _0x55f74b={};_0x55f74b[_0x1c1564]={'$like':'%'+_0x2b74d0['query'][_0xb9bf('0x2a')]+'%'};return _0x55f74b;})});}_0x59ea5f=_[_0xb9bf('0x49')]({},_0x59ea5f,_0x2b74d0[_0xb9bf('0x4b')]);return db[_0xb9bf('0x6d')][_0xb9bf('0x4c')]({'where':_0x59ea5f[_0xb9bf('0x47')]})[_0xb9bf('0x32')](function(_0x124d53){_0x200921[_0xb9bf('0x4c')]=_0x124d53;if(_0x2b74d0[_0xb9bf('0x3c')][_0xb9bf('0x51')]){_0x59ea5f[_0xb9bf('0x4d')]=[{'all':!![]}];}return db[_0xb9bf('0x6d')][_0xb9bf('0x4e')](_0x59ea5f);})[_0xb9bf('0x32')](function(_0x56f676){_0x200921[_0xb9bf('0x69')]=_0x56f676;return _0x200921;});}})[_0xb9bf('0x32')](respondWithFilteredResult(_0xb0710f,_0x59ea5f))[_0xb9bf('0x52')](handleError(_0xb0710f,null));};exports[_0xb9bf('0x6e')]=function(_0x49ed99,_0x28735a,_0x74bc67){var _0x1c0b0e={'raw':!![],'where':{}};var _0xb6a14e={};var _0x3fbf87={'count':0x0,'rows':[]};return db[_0xb9bf('0x38')][_0xb9bf('0x66')]({'where':{'id':_0x49ed99[_0xb9bf('0x61')]['id']}})[_0xb9bf('0x32')](handleEntityNotFound(_0x28735a,null))['then'](function(_0x56422e){if(_0x56422e){_0xb6a14e['model']=_[_0xb9bf('0x50')](db[_0xb9bf('0x6f')][_0xb9bf('0x39')]);_0xb6a14e[_0xb9bf('0x3c')]=_[_0xb9bf('0x50')](_0x49ed99[_0xb9bf('0x3c')]);_0xb6a14e[_0xb9bf('0x3d')]=_[_0xb9bf('0x3f')](_0xb6a14e[_0xb9bf('0x42')],_0xb6a14e[_0xb9bf('0x3c')]);_0x1c0b0e[_0xb9bf('0x3e')]=_[_0xb9bf('0x3f')](_0xb6a14e[_0xb9bf('0x42')],qs['fields'](_0x49ed99['query'][_0xb9bf('0x40')]));_0x1c0b0e[_0xb9bf('0x3e')]=_0x1c0b0e['attributes'][_0xb9bf('0x41')]?_0x1c0b0e[_0xb9bf('0x3e')]:_0xb6a14e[_0xb9bf('0x42')];if(!_0x49ed99['query'][_0xb9bf('0x43')](_0xb9bf('0x44'))){_0x1c0b0e[_0xb9bf('0x20')]=qs[_0xb9bf('0x20')](_0x49ed99[_0xb9bf('0x3c')][_0xb9bf('0x20')]);_0x1c0b0e[_0xb9bf('0x1f')]=qs[_0xb9bf('0x1f')](_0x49ed99['query'][_0xb9bf('0x1f')]);}_0x1c0b0e['order']=qs[_0xb9bf('0x46')](_0x49ed99[_0xb9bf('0x3c')]['sort']);_0x1c0b0e[_0xb9bf('0x47')]=qs[_0xb9bf('0x3d')](_[_0xb9bf('0x48')](_0x49ed99[_0xb9bf('0x3c')],_0xb6a14e['filters']));_0x1c0b0e[_0xb9bf('0x47')][_0xb9bf('0x68')]=_0x56422e['id'];if(_0x49ed99[_0xb9bf('0x3c')][_0xb9bf('0x2a')]){_0x1c0b0e[_0xb9bf('0x47')]=_['merge'](_0x1c0b0e[_0xb9bf('0x47')],{'$or':_[_0xb9bf('0x37')](_0x1c0b0e[_0xb9bf('0x3e')],function(_0x354d7c){var _0x410689={};_0x410689[_0x354d7c]={'$like':'%'+_0x49ed99[_0xb9bf('0x3c')]['filter']+'%'};return _0x410689;})});}_0x1c0b0e=_[_0xb9bf('0x49')]({},_0x1c0b0e,_0x49ed99[_0xb9bf('0x4b')]);return db[_0xb9bf('0x6f')][_0xb9bf('0x4c')]({'where':_0x1c0b0e[_0xb9bf('0x47')]})['then'](function(_0x79a9bf){_0x3fbf87[_0xb9bf('0x4c')]=_0x79a9bf;if(_0x49ed99['query'][_0xb9bf('0x51')]){_0x1c0b0e[_0xb9bf('0x4d')]=[{'all':!![]}];}return db[_0xb9bf('0x6f')]['findAll'](_0x1c0b0e);})['then'](function(_0x49666b){_0x3fbf87['rows']=_0x49666b;return _0x3fbf87;});}})[_0xb9bf('0x32')](respondWithFilteredResult(_0x28735a,_0x1c0b0e))[_0xb9bf('0x52')](handleError(_0x28735a,null));};exports[_0xb9bf('0x70')]=function(_0xc668c8,_0x1a0ac3,_0x250993){var _0x110d75={};var _0x4b7901={};var _0x3d2833;var _0xf56709;return db['VoiceQueue']['findOne']({'where':{'id':_0xc668c8[_0xb9bf('0x61')]['id']}})['then'](handleEntityNotFound(_0x1a0ac3,null))[_0xb9bf('0x32')](function(_0x10dde2){if(_0x10dde2){_0x3d2833=_0x10dde2;_0x4b7901[_0xb9bf('0x42')]=_['keys'](db[_0xb9bf('0x71')][_0xb9bf('0x39')]);_0x4b7901[_0xb9bf('0x3c')]=_['keys'](_0xc668c8[_0xb9bf('0x3c')]);_0x4b7901[_0xb9bf('0x3d')]=_[_0xb9bf('0x3f')](_0x4b7901[_0xb9bf('0x42')],_0x4b7901[_0xb9bf('0x3c')]);_0x110d75[_0xb9bf('0x3e')]=_[_0xb9bf('0x3f')](_0x4b7901[_0xb9bf('0x42')],qs[_0xb9bf('0x40')](_0xc668c8[_0xb9bf('0x3c')][_0xb9bf('0x40')]));_0x110d75[_0xb9bf('0x3e')]=_0x110d75[_0xb9bf('0x3e')][_0xb9bf('0x41')]?_0x110d75['attributes']:_0x4b7901[_0xb9bf('0x42')];_0x110d75[_0xb9bf('0x45')]=qs['sort'](_0xc668c8[_0xb9bf('0x3c')][_0xb9bf('0x46')]);_0x110d75['where']=qs[_0xb9bf('0x3d')](_['pick'](_0xc668c8[_0xb9bf('0x3c')],_0x4b7901[_0xb9bf('0x3d')]));if(_0xc668c8[_0xb9bf('0x3c')][_0xb9bf('0x2a')]){_0x110d75[_0xb9bf('0x47')]=_['merge'](_0x110d75[_0xb9bf('0x47')],{'$or':_[_0xb9bf('0x37')](_0x110d75[_0xb9bf('0x3e')],function(_0x42b073){var _0x4d8bd3={};_0x4d8bd3[_0x42b073]={'$like':'%'+_0xc668c8[_0xb9bf('0x3c')]['filter']+'%'};return _0x4d8bd3;})});}_0x110d75=_[_0xb9bf('0x49')]({},_0x110d75,_0xc668c8[_0xb9bf('0x4b')]);return _0x3d2833['getTeams'](_0x110d75);}})[_0xb9bf('0x32')](function(_0x4c4c87){if(_0x4c4c87){_0xf56709=_0x4c4c87[_0xb9bf('0x41')];if(!_0xc668c8[_0xb9bf('0x3c')][_0xb9bf('0x43')](_0xb9bf('0x44'))){_0x110d75[_0xb9bf('0x20')]=qs[_0xb9bf('0x20')](_0xc668c8['query'][_0xb9bf('0x20')]);_0x110d75['offset']=qs[_0xb9bf('0x1f')](_0xc668c8[_0xb9bf('0x3c')][_0xb9bf('0x1f')]);}return _0x3d2833[_0xb9bf('0x70')](_0x110d75);}})[_0xb9bf('0x32')](function(_0x51f59c){if(_0x51f59c){return _0x51f59c?{'count':_0xf56709,'rows':_0x51f59c}:null;}})['then'](respondWithResult(_0x1a0ac3,null))[_0xb9bf('0x52')](handleError(_0x1a0ac3,null));};exports['addTeams']=function(_0x391659,_0x1f981c,_0x2765bd){var _0x369179=_0x391659['body'][_0xb9bf('0x72')];var _0x484a17=_[_0xb9bf('0x37')](_0x369179,'id');return db[_0xb9bf('0x71')][_0xb9bf('0x4e')]({'where':{'id':_0x484a17},'attributes':['id'],'include':[{'model':db['User'],'as':'Agents','attributes':['id',_0xb9bf('0x30'),'online',_0xb9bf('0x73'),_0xb9bf('0x74')],'raw':!![]}]})[_0xb9bf('0x32')](function(_0xdf187d){if(_0xdf187d){var _0x3caf36=_[_0xb9bf('0x75')](_0xdf187d,function(_0x177759){var _0x4a5b3f=_0x177759[_0xb9bf('0x27')]({'plain':!![]});_0x4a5b3f['Agents']['forEach'](function(_0x3ec790){_0x3ec790[_0xb9bf('0x76')]=_['find'](_0x369179,{'id':_0x4a5b3f['id']})[_0xb9bf('0x76')];});return _0x4a5b3f[_0xb9bf('0x77')];});return db['VoiceQueue'][_0xb9bf('0x2f')]({'where':{'id':_0x391659[_0xb9bf('0x61')]['id']}})[_0xb9bf('0x32')](function(_0x578468){return db['sequelize'][_0xb9bf('0x78')](function(_0x1caa23){return _0x578468['addTeams'](_0x484a17,{'transaction':_0x1caa23})['then'](function(){return BPromise[_0xb9bf('0x79')](_0x369179,function(_0x4a929f){return db[_0xb9bf('0x7a')][_0xb9bf('0x7b')]({'TeamId':_0x4a929f['id'],'VoiceQueueId':_0x391659['params']['id'],'penalty':_0x4a929f['penalty']},{'transaction':_0x1caa23});});})[_0xb9bf('0x32')](function(){return BPromise[_0xb9bf('0x79')](_0x3caf36,function(_0x4b8478){return db['UserVoiceQueue'][_0xb9bf('0x7c')]({'where':{'UserId':_0x4b8478['id'],'VoiceQueueId':_0x391659[_0xb9bf('0x61')]['id']},'defaults':{'penalty':_0x4b8478[_0xb9bf('0x76')]},'transaction':_0x1caa23});});})[_0xb9bf('0x32')](function(){return BPromise['each'](_['filter'](_0x3caf36,{'online':!![]}),function(_0x48f827){return db[_0xb9bf('0x7d')][_0xb9bf('0x7b')]({'membername':_0x48f827['name'],'UserId':_0x48f827['id'],'queue_name':_0x578468['name'],'VoiceQueueId':_0x578468['id'],'interface':_[_0xb9bf('0x7e')](_0x48f827['interface'])?util[_0xb9bf('0x7f')]('SIP/%s',_0x48f827[_0xb9bf('0x30')]):_0x48f827[_0xb9bf('0x74')],'paused':_0x48f827[_0xb9bf('0x73')]||![],'penalty':_0x48f827[_0xb9bf('0x76')]},{'transaction':_0x1caa23});});})[_0xb9bf('0x32')](function(){_0x3caf36[_0xb9bf('0x80')](function(_0x539574){socket[_0xb9bf('0x81')](_0xb9bf('0x82'),{'UserId':_0x539574['id'],'VoiceQueueId':_0x578468['id']});});});});});}})[_0xb9bf('0x32')](respondWithStatusCode(_0x1f981c,null))['catch'](handleError(_0x1f981c,null));};exports[_0xb9bf('0x83')]=function(_0x2f09c7,_0x1e079f,_0x559c93){return db[_0xb9bf('0x71')]['findAll']({'where':{'id':_0x2f09c7['query'][_0xb9bf('0x84')]},'attributes':['id'],'include':[{'model':db[_0xb9bf('0x85')],'as':_0xb9bf('0x77'),'attributes':['id'],'raw':!![]}]})[_0xb9bf('0x32')](handleEntityNotFound(_0x1e079f,null))[_0xb9bf('0x32')](function(_0xac3ea9){var _0x3a9b10=_[_0xb9bf('0x37')](_0xac3ea9,'id');var _0x564c56=[];var _0x278ff1=[];var _0x333f4e=squel[_0xb9bf('0x86')]();_0x333f4e[_0xb9bf('0x87')](_0xb9bf('0x88'))[_0xb9bf('0x89')](_0xb9bf('0x8a'),'tq')[_0xb9bf('0x8b')]('user_has_teams','ut','ut.TeamId\x20=\x20tq.TeamId')[_0xb9bf('0x47')](_0xb9bf('0x8c'),_0x2f09c7[_0xb9bf('0x61')]['id']);for(var _0x5ede33=0x0;_0x5ede33<_0xac3ea9[_0xb9bf('0x41')];_0x5ede33+=0x1){let _0x24b964=_0xac3ea9[_0x5ede33];for(var _0x243c14=0x0;_0x243c14<_0x24b964[_0xb9bf('0x77')]['length'];_0x243c14+=0x1){let _0x260731=_0x24b964[_0xb9bf('0x77')][_0x243c14];var _0x53dc03=_0x333f4e['clone']();_0x53dc03['where'](_0xb9bf('0x8d'),_0x260731['id']);_0x278ff1[_0xb9bf('0x8e')](db[_0xb9bf('0x8f')][_0xb9bf('0x3c')](_0x53dc03[_0xb9bf('0x90')](),{'type':db[_0xb9bf('0x8f')][_0xb9bf('0x91')]['SELECT']})[_0xb9bf('0x32')](function(_0x3fbda2){if(_0x3fbda2[_0xb9bf('0x41')]===0x1){return _0x260731['id'];}else{var _0x416d35=_[_0xb9bf('0x92')](_[_0xb9bf('0x37')](_0x3fbda2,'TeamId'),function(_0x4dafca){return _[_0xb9bf('0x2d')](_0x3a9b10,_0x4dafca);});if(_0x416d35){return _0x260731['id'];}}}));}}return BPromise[_0xb9bf('0x93')](_0x278ff1)[_0xb9bf('0x32')](function(_0x236df3){_0x564c56=_(_0x564c56)[_0xb9bf('0x94')](_0x236df3)[_0xb9bf('0x95')]()['value']();return db['VoiceQueue'][_0xb9bf('0x2f')]({'where':{'id':_0x2f09c7['params']['id']}})[_0xb9bf('0x32')](function(_0x36da5d){return db[_0xb9bf('0x8f')][_0xb9bf('0x78')](function(_0x55bb20){return _0x36da5d[_0xb9bf('0x83')](_0x2f09c7[_0xb9bf('0x3c')][_0xb9bf('0x84')],{'transaction':_0x55bb20})[_0xb9bf('0x32')](function(){if(!_[_0xb9bf('0x96')](_0x564c56)){return _0x36da5d[_0xb9bf('0x97')](_0x564c56,{'transaction':_0x55bb20})[_0xb9bf('0x32')](function(){return db[_0xb9bf('0x7d')]['destroy']({'where':{'VoiceQueueId':_0x2f09c7[_0xb9bf('0x61')]['id'],'UserId':_0x564c56},'transaction':_0x55bb20});});}})['then'](function(){_0x564c56[_0xb9bf('0x80')](function(_0x3702db){socket['emit'](_0xb9bf('0x98'),{'UserId':_0x3702db,'VoiceQueueId':_0x36da5d['id']});});});});});});})['then'](respondWithStatusCode(_0x1e079f,null))[_0xb9bf('0x52')](handleError(_0x1e079f,null));};exports[_0xb9bf('0x99')]=function(_0x3bb5f0,_0x47f8ae,_0x2942a7){var _0x4a4429,_0x4c03ba;return db['VoiceQueue'][_0xb9bf('0x2f')]({'where':{'id':_0x3bb5f0['params']['id']}})[_0xb9bf('0x32')](handleEntityNotFound(_0x47f8ae,null))[_0xb9bf('0x32')](function(_0x29876f){if(_0x29876f){_0x4c03ba=_0x29876f;return _0x29876f[_0xb9bf('0x99')](_0x3bb5f0[_0xb9bf('0x54')][_0xb9bf('0x84')],_[_0xb9bf('0x62')](_0x3bb5f0[_0xb9bf('0x54')],[_0xb9bf('0x84'),'id'])||{})['spread'](function(_0x59814c){for(var _0xf567c9=0x0;_0xf567c9<_0x3bb5f0[_0xb9bf('0x54')][_0xb9bf('0x84')]['length'];_0xf567c9+=0x1){socket[_0xb9bf('0x81')](_0xb9bf('0x82'),{'UserId':_0x3bb5f0[_0xb9bf('0x54')][_0xb9bf('0x84')][_0xf567c9],'VoiceQueueId':_0x3bb5f0['params']['id']});}return _0x59814c;});}})[_0xb9bf('0x32')](function(_0x301bc9){_0x4a4429=_0x301bc9||[];if(_0x4c03ba){return db['User'][_0xb9bf('0x4e')]({'where':{'id':_0x3bb5f0[_0xb9bf('0x54')][_0xb9bf('0x84')]},'attributes':['id',_0xb9bf('0x30'),'online',_0xb9bf('0x73'),'interface'],'raw':!![]});}})[_0xb9bf('0x32')](function(_0xb9a474){if(!_[_0xb9bf('0x96')](_0xb9a474)){var _0x16051b=[];for(var _0x473f61=0x0;_0x473f61<_0xb9a474[_0xb9bf('0x41')];_0x473f61++){if(_0xb9a474[_0x473f61][_0xb9bf('0x9a')]){_0x16051b[_0xb9bf('0x8e')](db[_0xb9bf('0x7d')]['upsert']({'membername':_0xb9a474[_0x473f61][_0xb9bf('0x30')],'UserId':_0xb9a474[_0x473f61]['id'],'queue_name':_0x4c03ba[_0xb9bf('0x30')],'VoiceQueueId':_0x4c03ba['id'],'interface':_['isNil'](_0xb9a474[_0x473f61]['interface'])?util[_0xb9bf('0x7f')](_0xb9bf('0x9b'),_0xb9a474[_0x473f61]['name']):_0xb9a474[_0x473f61][_0xb9bf('0x74')],'paused':_0xb9a474[_0x473f61]['voicePause']||![],'penalty':_0x3bb5f0[_0xb9bf('0x54')][_0xb9bf('0x76')]||0x0}));}}return BPromise['all'](_0x16051b);}})['then'](function(){return _0x4a4429;})[_0xb9bf('0x32')](respondWithResult(_0x47f8ae,null))[_0xb9bf('0x52')](handleError(_0x47f8ae,null));};exports[_0xb9bf('0x97')]=function(_0x1bc763,_0x584493,_0x183e1b){return db[_0xb9bf('0x38')][_0xb9bf('0x2f')]({'where':{'id':_0x1bc763['params']['id']}})[_0xb9bf('0x32')](handleEntityNotFound(_0x584493,null))[_0xb9bf('0x32')](function(_0x3548ed){if(_0x3548ed){return _0x3548ed[_0xb9bf('0x97')](_0x1bc763[_0xb9bf('0x3c')][_0xb9bf('0x84')])[_0xb9bf('0x32')](function(){if(_[_0xb9bf('0x9c')](_0x1bc763['query'][_0xb9bf('0x84')])){for(var _0x1fb873=0x0;_0x1fb873<_0x1bc763[_0xb9bf('0x3c')][_0xb9bf('0x84')][_0xb9bf('0x41')];_0x1fb873+=0x1){socket['emit'](_0xb9bf('0x98'),{'UserId':Number(_0x1bc763[_0xb9bf('0x3c')][_0xb9bf('0x84')][_0x1fb873]),'VoiceQueueId':Number(_0x1bc763[_0xb9bf('0x61')]['id'])});}}else{socket['emit']('userVoiceQueue:remove',{'UserId':Number(_0x1bc763['query']['ids']),'VoiceQueueId':Number(_0x1bc763[_0xb9bf('0x61')]['id'])});}});}})['then'](function(_0x543c28){return db[_0xb9bf('0x7d')][_0xb9bf('0x31')]({'where':{'VoiceQueueId':_0x1bc763[_0xb9bf('0x61')]['id'],'UserId':_0x1bc763['query'][_0xb9bf('0x84')]}})[_0xb9bf('0x32')](function(){return _0x543c28;});})[_0xb9bf('0x32')](respondWithStatusCode(_0x584493,null))[_0xb9bf('0x52')](handleError(_0x584493,null));};exports[_0xb9bf('0x9d')]=function(_0x150d3,_0x18acab,_0x2becff){var _0x4be109={};var _0x2457aa={};var _0x3bd966;var _0x23fda6;return db[_0xb9bf('0x38')]['findOne']({'where':{'id':_0x150d3[_0xb9bf('0x61')]['id']}})[_0xb9bf('0x32')](handleEntityNotFound(_0x18acab,null))[_0xb9bf('0x32')](function(_0x2e0c0a){if(_0x2e0c0a){_0x3bd966=_0x2e0c0a;_0x2457aa[_0xb9bf('0x42')]=_['keys'](db[_0xb9bf('0x85')][_0xb9bf('0x39')]);_0x2457aa[_0xb9bf('0x3c')]=_['keys'](_0x150d3[_0xb9bf('0x3c')]);_0x2457aa['filters']=_['intersection'](_0x2457aa['model'],_0x2457aa[_0xb9bf('0x3c')]);_0x4be109[_0xb9bf('0x3e')]=_[_0xb9bf('0x3f')](_0x2457aa[_0xb9bf('0x42')],qs[_0xb9bf('0x40')](_0x150d3[_0xb9bf('0x3c')][_0xb9bf('0x40')]));_0x4be109[_0xb9bf('0x3e')]=_0x4be109[_0xb9bf('0x3e')][_0xb9bf('0x41')]?_0x4be109[_0xb9bf('0x3e')]:_0x2457aa[_0xb9bf('0x42')];_0x4be109[_0xb9bf('0x45')]=qs[_0xb9bf('0x46')](_0x150d3[_0xb9bf('0x3c')][_0xb9bf('0x46')]);_0x4be109['where']=qs[_0xb9bf('0x3d')](_[_0xb9bf('0x48')](_0x150d3[_0xb9bf('0x3c')],_0x2457aa[_0xb9bf('0x3d')]));if(_0x150d3[_0xb9bf('0x3c')][_0xb9bf('0x2a')]){_0x4be109[_0xb9bf('0x47')]=_[_0xb9bf('0x49')](_0x4be109['where'],{'$or':_['map'](_0x4be109[_0xb9bf('0x3e')],function(_0x55f36){var _0x2d9380={};_0x2d9380[_0x55f36]={'$like':'%'+_0x150d3[_0xb9bf('0x3c')][_0xb9bf('0x2a')]+'%'};return _0x2d9380;})});}_0x4be109=_[_0xb9bf('0x49')]({},_0x4be109,_0x150d3[_0xb9bf('0x4b')]);return _0x3bd966['getAgents'](_0x4be109);}})[_0xb9bf('0x32')](function(_0x3b71e5){if(_0x3b71e5){_0x23fda6=_0x3b71e5['length'];if(!_0x150d3['query'][_0xb9bf('0x43')]('nolimit')){_0x4be109[_0xb9bf('0x20')]=qs[_0xb9bf('0x20')](_0x150d3[_0xb9bf('0x3c')][_0xb9bf('0x20')]);_0x4be109[_0xb9bf('0x1f')]=qs[_0xb9bf('0x1f')](_0x150d3[_0xb9bf('0x3c')]['offset']);}return _0x3bd966['getAgents'](_0x4be109);}})[_0xb9bf('0x32')](function(_0x1a706c){if(_0x1a706c){return _0x1a706c?{'count':_0x23fda6,'rows':_0x1a706c}:null;}})[_0xb9bf('0x32')](respondWithResult(_0x18acab,null))['catch'](handleError(_0x18acab,null));};exports[_0xb9bf('0x9e')]=function(_0x588e20,_0x1355a9,_0x33695c){var _0x4890b7={};var _0x22234d={};var _0x397e51;var _0x5d8721;return db['VoiceQueue'][_0xb9bf('0x66')]({'where':{'id':_0x588e20['params']['id']}})[_0xb9bf('0x32')](handleEntityNotFound(_0x1355a9,null))['then'](function(_0x7301a){if(_0x7301a){_0x397e51=_0x7301a;_0x22234d[_0xb9bf('0x42')]=_[_0xb9bf('0x50')](db[_0xb9bf('0x7d')][_0xb9bf('0x39')]);_0x22234d['query']=_[_0xb9bf('0x50')](_0x588e20[_0xb9bf('0x3c')]);_0x22234d[_0xb9bf('0x3d')]=_['intersection'](_0x22234d['model'],_0x22234d[_0xb9bf('0x3c')]);_0x4890b7['attributes']=_[_0xb9bf('0x3f')](_0x22234d[_0xb9bf('0x42')],qs[_0xb9bf('0x40')](_0x588e20['query'][_0xb9bf('0x40')]));_0x4890b7[_0xb9bf('0x3e')]=_0x4890b7[_0xb9bf('0x3e')][_0xb9bf('0x41')]?_0x4890b7[_0xb9bf('0x3e')]:_0x22234d[_0xb9bf('0x42')];_0x4890b7[_0xb9bf('0x45')]=qs[_0xb9bf('0x46')](_0x588e20[_0xb9bf('0x3c')]['sort']);_0x4890b7[_0xb9bf('0x47')]=qs[_0xb9bf('0x3d')](_[_0xb9bf('0x48')](_0x588e20[_0xb9bf('0x3c')],_0x22234d[_0xb9bf('0x3d')]));if(_0x588e20[_0xb9bf('0x3c')][_0xb9bf('0x2a')]){_0x4890b7['where']=_[_0xb9bf('0x49')](_0x4890b7[_0xb9bf('0x47')],{'$or':_['map'](_0x4890b7['attributes'],function(_0xa38641){var _0x264b1c={};_0x264b1c[_0xa38641]={'$like':'%'+_0x588e20[_0xb9bf('0x3c')][_0xb9bf('0x2a')]+'%'};return _0x264b1c;})});}_0x4890b7=_[_0xb9bf('0x49')]({},_0x4890b7,_0x588e20['options']);return _0x397e51['getMembers'](_0x4890b7);}})[_0xb9bf('0x32')](function(_0x1a40e9){if(_0x1a40e9){_0x5d8721=_0x1a40e9[_0xb9bf('0x41')];if(!_0x588e20[_0xb9bf('0x3c')]['hasOwnProperty'](_0xb9bf('0x44'))){_0x4890b7[_0xb9bf('0x20')]=qs[_0xb9bf('0x20')](_0x588e20[_0xb9bf('0x3c')]['limit']);_0x4890b7[_0xb9bf('0x1f')]=qs[_0xb9bf('0x1f')](_0x588e20['query'][_0xb9bf('0x1f')]);}return _0x397e51['getMembers'](_0x4890b7);}})[_0xb9bf('0x32')](function(_0x57b803){return _0x57b803?{'count':_0x5d8721,'rows':_0x57b803}:null;})[_0xb9bf('0x32')](respondWithResult(_0x1355a9,null))[_0xb9bf('0x52')](handleError(_0x1355a9,null));};exports['getLists']=function(_0x36e43f,_0x580bc3,_0x1ddad6){var _0x29585a={};var _0x52bf41={};var _0x56ac87;var _0x44c41b;return db['VoiceQueue']['findOne']({'where':{'id':_0x36e43f[_0xb9bf('0x61')]['id']}})[_0xb9bf('0x32')](handleEntityNotFound(_0x580bc3,null))[_0xb9bf('0x32')](function(_0x4f3bd4){if(_0x4f3bd4){_0x56ac87=_0x4f3bd4;_0x52bf41[_0xb9bf('0x42')]=_[_0xb9bf('0x50')](db[_0xb9bf('0x9f')]['rawAttributes']);_0x52bf41[_0xb9bf('0x3c')]=_[_0xb9bf('0x50')](_0x36e43f[_0xb9bf('0x3c')]);_0x52bf41[_0xb9bf('0x3d')]=_[_0xb9bf('0x3f')](_0x52bf41[_0xb9bf('0x42')],_0x52bf41['query']);_0x29585a['attributes']=_[_0xb9bf('0x3f')](_0x52bf41['model'],qs[_0xb9bf('0x40')](_0x36e43f[_0xb9bf('0x3c')]['fields']));_0x29585a['attributes']=_0x29585a['attributes'][_0xb9bf('0x41')]?_0x29585a['attributes']:_0x52bf41[_0xb9bf('0x42')];_0x29585a[_0xb9bf('0x45')]=qs[_0xb9bf('0x46')](_0x36e43f[_0xb9bf('0x3c')]['sort']);_0x29585a[_0xb9bf('0x47')]=qs[_0xb9bf('0x3d')](_[_0xb9bf('0x48')](_0x36e43f[_0xb9bf('0x3c')],_0x52bf41[_0xb9bf('0x3d')]));if(_0x36e43f['query'][_0xb9bf('0x2a')]){_0x29585a[_0xb9bf('0x47')]=_['merge'](_0x29585a[_0xb9bf('0x47')],{'$or':_[_0xb9bf('0x37')](_0x29585a[_0xb9bf('0x3e')],function(_0x3b1904){var _0x1a96c1={};_0x1a96c1[_0x3b1904]={'$like':'%'+_0x36e43f[_0xb9bf('0x3c')][_0xb9bf('0x2a')]+'%'};return _0x1a96c1;})});}_0x29585a=_[_0xb9bf('0x49')]({},_0x29585a,_0x36e43f[_0xb9bf('0x4b')]);return _0x56ac87[_0xb9bf('0xa0')](_0x29585a);}})[_0xb9bf('0x32')](function(_0x1a3989){if(_0x1a3989){_0x44c41b=_0x1a3989[_0xb9bf('0x41')];if(!_0x36e43f[_0xb9bf('0x3c')][_0xb9bf('0x43')]('nolimit')){_0x29585a[_0xb9bf('0x20')]=qs['limit'](_0x36e43f[_0xb9bf('0x3c')]['limit']);_0x29585a[_0xb9bf('0x1f')]=qs[_0xb9bf('0x1f')](_0x36e43f[_0xb9bf('0x3c')][_0xb9bf('0x1f')]);}return _0x56ac87[_0xb9bf('0xa0')](_0x29585a);}})[_0xb9bf('0x32')](function(_0x5ecf42){if(_0x5ecf42){return _0x5ecf42?{'count':_0x44c41b,'rows':_0x5ecf42}:null;}})['then'](respondWithResult(_0x580bc3,null))[_0xb9bf('0x52')](handleError(_0x580bc3,null));};exports['addLists']=function(_0x5d13c3,_0x12c90b,_0x29827a){var _0x5d9341,_0x4f1433;return db['VoiceQueue'][_0xb9bf('0x2f')]({'where':{'id':_0x5d13c3[_0xb9bf('0x61')]['id']}})[_0xb9bf('0x32')](handleEntityNotFound(_0x12c90b,null))[_0xb9bf('0x32')](function(_0x55da3b){if(_0x55da3b){_0x4f1433=_0x55da3b;return _0x55da3b[_0xb9bf('0xa1')](_0x5d13c3[_0xb9bf('0x54')]['ids'],_['omit'](_0x5d13c3[_0xb9bf('0x54')],[_0xb9bf('0x84'),'id'])||{});}return null;})[_0xb9bf('0xa2')](function(_0x478343){var _0x3eb8b7;_0x5d9341=_0x478343||[];var _0x538f0d=[];if(_0x478343){for(var _0x493140=0x0;_0x493140<_0x478343['length'];_0x493140+=0x1){var _0x3a6a1c=_0x478343[_0x493140][_0xb9bf('0x27')]({'plain':!![]});_0x4f1433[_0xb9bf('0xa3')]=_0x5d13c3[_0xb9bf('0x54')]['dialCheckDuplicateType']?_0x5d13c3['body'][_0xb9bf('0xa3')]:_0x4f1433['dialCheckDuplicateType'];switch(_0x4f1433[_0xb9bf('0xa3')]){case _0xb9bf('0xa4'):_0x3eb8b7=squel[_0xb9bf('0xa5')]()['into'](_0xb9bf('0xa6'))[_0xb9bf('0xa7')]([_0xb9bf('0xa8'),'scheduledAt','ContactId',_0xb9bf('0xa9'),'VoiceQueueId',_0xb9bf('0x63'),_0xb9bf('0x64')],squel['select']()[_0xb9bf('0x87')](_0xb9bf('0xa8'),_0xb9bf('0xa8'))[_0xb9bf('0x87')](_0xb9bf('0xaa'),_0xb9bf('0xab'))['field']('id',_0xb9bf('0xac'))[_0xb9bf('0x87')](_0x3a6a1c[_0xb9bf('0xad')][_0xb9bf('0x90')](),_0xb9bf('0xa9'))[_0xb9bf('0x87')](_0x5d13c3[_0xb9bf('0x61')]['id'][_0xb9bf('0x90')](),_0xb9bf('0x68'))[_0xb9bf('0x87')](_0xb9bf('0xaa'),_0xb9bf('0x63'))[_0xb9bf('0x87')](_0xb9bf('0xaa'),_0xb9bf('0x64'))['from'](_0xb9bf('0xae'))[_0xb9bf('0x47')]('deletedAt\x20IS\x20NULL')['where'](_0xb9bf('0xaf'),_0x3a6a1c[_0xb9bf('0xad')][_0xb9bf('0x90')]())[_0xb9bf('0x47')](_0xb9bf('0xb0'))['where'](_0xb9bf('0xb1'),squel[_0xb9bf('0x86')]()[_0xb9bf('0x87')](_0xb9bf('0xb2'))[_0xb9bf('0x89')]('cm_hopper_final')['where'](_0xb9bf('0x8c'),_0x5d13c3['params']['id'][_0xb9bf('0x90')]()))[_0xb9bf('0x47')](_0xb9bf('0xb1'),squel['select']()[_0xb9bf('0x87')](_0xb9bf('0xb3'))['from']('cm_hopper')['where'](_0xb9bf('0x8c'),_0x5d13c3[_0xb9bf('0x61')]['id'][_0xb9bf('0x90')]())))[_0xb9bf('0x90')]();break;case'onlyIfOpen':_0x3eb8b7=squel['insert']()[_0xb9bf('0xb4')](_0xb9bf('0xa6'))['fromQuery']([_0xb9bf('0xa8'),'scheduledAt',_0xb9bf('0xac'),_0xb9bf('0xa9'),_0xb9bf('0x68'),_0xb9bf('0x63'),_0xb9bf('0x64')],squel[_0xb9bf('0x86')]()[_0xb9bf('0x87')](_0xb9bf('0xa8'),_0xb9bf('0xa8'))[_0xb9bf('0x87')](_0xb9bf('0xaa'),_0xb9bf('0xab'))['field']('id','ContactId')['field'](_0x3a6a1c['CmListId']['toString'](),_0xb9bf('0xa9'))[_0xb9bf('0x87')](_0x5d13c3[_0xb9bf('0x61')]['id'][_0xb9bf('0x90')](),_0xb9bf('0x68'))[_0xb9bf('0x87')]('NOW()',_0xb9bf('0x63'))['field'](_0xb9bf('0xaa'),_0xb9bf('0x64'))[_0xb9bf('0x89')](_0xb9bf('0xae'))[_0xb9bf('0x47')](_0xb9bf('0xb5'))[_0xb9bf('0x47')](_0xb9bf('0xaf'),_0x3a6a1c[_0xb9bf('0xad')][_0xb9bf('0x90')]())[_0xb9bf('0x47')](_0xb9bf('0xb0'))[_0xb9bf('0x47')](_0xb9bf('0xb1'),squel['select']()[_0xb9bf('0x87')](_0xb9bf('0xb3'))[_0xb9bf('0x89')](_0xb9bf('0xa6'))['where'](_0xb9bf('0x8c'),_0x5d13c3[_0xb9bf('0x61')]['id'][_0xb9bf('0x90')]())))['toString']();break;default:_0x3eb8b7=squel[_0xb9bf('0xa5')]()[_0xb9bf('0xb4')]('cm_hopper')[_0xb9bf('0xa7')]([_0xb9bf('0xa8'),'scheduledAt',_0xb9bf('0xac'),_0xb9bf('0xa9'),'VoiceQueueId','createdAt',_0xb9bf('0x64')],squel[_0xb9bf('0x86')]()[_0xb9bf('0x87')](_0xb9bf('0xa8'),'phone')[_0xb9bf('0x87')](_0xb9bf('0xaa'),_0xb9bf('0xab'))[_0xb9bf('0x87')]('id',_0xb9bf('0xac'))[_0xb9bf('0x87')](_0x3a6a1c[_0xb9bf('0xad')][_0xb9bf('0x90')](),'ListId')[_0xb9bf('0x87')](_0x5d13c3[_0xb9bf('0x61')]['id']['toString'](),'VoiceQueueId')['field'](_0xb9bf('0xaa'),'createdAt')[_0xb9bf('0x87')](_0xb9bf('0xaa'),_0xb9bf('0x64'))[_0xb9bf('0x89')]('cm_contacts')[_0xb9bf('0x47')](_0xb9bf('0xb5'))['where'](_0xb9bf('0xaf'),_0x3a6a1c[_0xb9bf('0xad')][_0xb9bf('0x90')]())[_0xb9bf('0x47')](_0xb9bf('0xb0')))[_0xb9bf('0x90')]();}_0x538f0d[_0xb9bf('0x8e')](db[_0xb9bf('0x8f')]['query'](_0x3eb8b7));}return BPromise[_0xb9bf('0x93')](_0x538f0d);}})['then'](function(){return _0x5d9341;})[_0xb9bf('0x32')](respondWithResult(_0x12c90b,null))['catch'](handleError(_0x12c90b,null));};exports[_0xb9bf('0xb6')]=function(_0x1a6dfd,_0x3e441b,_0x4adb50){return db['VoiceQueue'][_0xb9bf('0x2f')]({'where':{'id':_0x1a6dfd[_0xb9bf('0x61')]['id']}})['then'](handleEntityNotFound(_0x3e441b,null))[_0xb9bf('0x32')](function(_0x19f76b){if(_0x19f76b){return _0x19f76b[_0xb9bf('0xb6')](_0x1a6dfd[_0xb9bf('0x3c')][_0xb9bf('0x84')]);}})[_0xb9bf('0x32')](function(_0x75896c){if(_0x75896c){return db[_0xb9bf('0x67')]['destroy']({'where':{'ListId':_0x1a6dfd[_0xb9bf('0x3c')][_0xb9bf('0x84')],'VoiceQueueId':_0x1a6dfd['params']['id']}})[_0xb9bf('0x32')](function(){return _0x75896c;});}})[_0xb9bf('0x32')](respondWithStatusCode(_0x3e441b,null))[_0xb9bf('0x52')](handleError(_0x3e441b,null));};exports[_0xb9bf('0xb7')]=function(_0x1891a4,_0x3f861d,_0xf585cf){var _0x2ec98f={};var _0x332326={};var _0x11541a;var _0x132903;return db[_0xb9bf('0x38')]['findOne']({'where':{'id':_0x1891a4[_0xb9bf('0x61')]['id']}})[_0xb9bf('0x32')](handleEntityNotFound(_0x3f861d,null))[_0xb9bf('0x32')](function(_0x416c39){if(_0x416c39){_0x11541a=_0x416c39;_0x332326[_0xb9bf('0x42')]=_['keys'](db['CmList'][_0xb9bf('0x39')]);_0x332326['query']=_[_0xb9bf('0x50')](_0x1891a4[_0xb9bf('0x3c')]);_0x332326[_0xb9bf('0x3d')]=_[_0xb9bf('0x3f')](_0x332326[_0xb9bf('0x42')],_0x332326[_0xb9bf('0x3c')]);_0x2ec98f[_0xb9bf('0x3e')]=_[_0xb9bf('0x3f')](_0x332326[_0xb9bf('0x42')],qs[_0xb9bf('0x40')](_0x1891a4[_0xb9bf('0x3c')][_0xb9bf('0x40')]));_0x2ec98f[_0xb9bf('0x3e')]=_0x2ec98f['attributes'][_0xb9bf('0x41')]?_0x2ec98f[_0xb9bf('0x3e')]:_0x332326['model'];_0x2ec98f[_0xb9bf('0x45')]=qs['sort'](_0x1891a4[_0xb9bf('0x3c')]['sort']);_0x2ec98f[_0xb9bf('0x47')]=qs[_0xb9bf('0x3d')](_['pick'](_0x1891a4[_0xb9bf('0x3c')],_0x332326['filters']));if(_0x1891a4[_0xb9bf('0x3c')][_0xb9bf('0x2a')]){_0x2ec98f[_0xb9bf('0x47')]=_[_0xb9bf('0x49')](_0x2ec98f[_0xb9bf('0x47')],{'$or':_[_0xb9bf('0x37')](_0x2ec98f[_0xb9bf('0x3e')],function(_0x26e613){var _0x36384e={};_0x36384e[_0x26e613]={'$like':'%'+_0x1891a4['query'][_0xb9bf('0x2a')]+'%'};return _0x36384e;})});}_0x2ec98f=_[_0xb9bf('0x49')]({},_0x2ec98f,_0x1891a4[_0xb9bf('0x4b')]);return _0x11541a[_0xb9bf('0xb7')](_0x2ec98f);}})[_0xb9bf('0x32')](function(_0x35d345){if(_0x35d345){_0x132903=_0x35d345[_0xb9bf('0x41')];if(!_0x1891a4['query'][_0xb9bf('0x43')](_0xb9bf('0x44'))){_0x2ec98f[_0xb9bf('0x20')]=qs[_0xb9bf('0x20')](_0x1891a4[_0xb9bf('0x3c')][_0xb9bf('0x20')]);_0x2ec98f[_0xb9bf('0x1f')]=qs[_0xb9bf('0x1f')](_0x1891a4[_0xb9bf('0x3c')][_0xb9bf('0x1f')]);}return _0x11541a['getBlackLists'](_0x2ec98f);}})[_0xb9bf('0x32')](function(_0xf6973f){if(_0xf6973f){return _0xf6973f?{'count':_0x132903,'rows':_0xf6973f}:null;}})['then'](respondWithResult(_0x3f861d,null))[_0xb9bf('0x52')](handleError(_0x3f861d,null));};exports['addBlackLists']=function(_0x1790cb,_0x1e839a,_0x3f5aa5){var _0x2ed450,_0x120a73;return db['VoiceQueue']['find']({'where':{'id':_0x1790cb[_0xb9bf('0x61')]['id']}})[_0xb9bf('0x32')](handleEntityNotFound(_0x1e839a,null))[_0xb9bf('0x32')](function(_0x40bb63){if(_0x40bb63){_0x120a73=_0x40bb63;return _0x40bb63[_0xb9bf('0xb8')](_0x1790cb[_0xb9bf('0x54')][_0xb9bf('0x84')],_[_0xb9bf('0x62')](_0x1790cb[_0xb9bf('0x54')],[_0xb9bf('0x84'),'id'])||{});}return null;})[_0xb9bf('0xa2')](function(_0xa429d9){var _0xc8fcc;_0x2ed450=_0xa429d9||[];var _0x16e34f=[];if(_0xa429d9){for(var _0x56807a=0x0;_0x56807a<_0xa429d9['length'];_0x56807a+=0x1){var _0x505ac2=_0xa429d9[_0x56807a][_0xb9bf('0x27')]({'plain':!![]});_0xc8fcc=squel[_0xb9bf('0xa5')]()[_0xb9bf('0xb4')](_0xb9bf('0xb9'))[_0xb9bf('0xa7')]([_0xb9bf('0xa8'),'ContactId',_0xb9bf('0xa9'),_0xb9bf('0x68'),_0xb9bf('0x63'),'updatedAt'],squel['select']()[_0xb9bf('0x87')]('phone',_0xb9bf('0xa8'))[_0xb9bf('0x87')]('id',_0xb9bf('0xac'))[_0xb9bf('0x87')](_0x505ac2[_0xb9bf('0xad')][_0xb9bf('0x90')](),'ListId')[_0xb9bf('0x87')](_0x1790cb[_0xb9bf('0x61')]['id'][_0xb9bf('0x90')](),'VoiceQueueId')['field'](_0xb9bf('0xaa'),_0xb9bf('0x63'))[_0xb9bf('0x87')](_0xb9bf('0xaa'),_0xb9bf('0x64'))[_0xb9bf('0x89')](_0xb9bf('0xae'))['where'](_0xb9bf('0xb5'))[_0xb9bf('0x47')](_0xb9bf('0xaf'),_0x505ac2['CmListId']['toString']())[_0xb9bf('0x47')](_0xb9bf('0xb0')))['toString']();_0x16e34f[_0xb9bf('0x8e')](db[_0xb9bf('0x8f')][_0xb9bf('0x3c')](_0xc8fcc));}return BPromise['all'](_0x16e34f);}})['then'](function(){return _0x2ed450;})[_0xb9bf('0x32')](respondWithResult(_0x1e839a,null))['catch'](handleError(_0x1e839a,null));};exports[_0xb9bf('0xba')]=function(_0x37812c,_0x12df45,_0x35319d){return db[_0xb9bf('0x38')]['find']({'where':{'id':_0x37812c['params']['id']}})[_0xb9bf('0x32')](handleEntityNotFound(_0x12df45,null))[_0xb9bf('0x32')](function(_0x2d9815){if(_0x2d9815){return _0x2d9815['removeBlackLists'](_0x37812c['query'][_0xb9bf('0x84')]);}})[_0xb9bf('0x32')](function(_0x3f08a0){if(_0x3f08a0){return db[_0xb9bf('0x6f')]['destroy']({'where':{'ListId':_0x37812c[_0xb9bf('0x3c')]['ids'],'VoiceQueueId':_0x37812c[_0xb9bf('0x61')]['id']}})[_0xb9bf('0x32')](function(){return _0x3f08a0;});}})[_0xb9bf('0x32')](respondWithStatusCode(_0x12df45,null))[_0xb9bf('0x52')](handleError(_0x12df45,null));};
\ No newline at end of file