Built motion from commit 3c2ce842.|2.6.31
[motion2.git] / server / api / voiceQueue / voiceQueue.controller.js
index 8a7713c..60e63c2 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xedd9=['penalty','UserVoiceQueueRt','interface','format','SIP/%s','voicePause','emit','userVoiceQueue:save','User','select','field','tq.TeamId','team_has_voice_queues','join','user_has_teams','ut.TeamId\x20=\x20tq.TeamId','VoiceQueueId\x20=\x20?','ut.UserId\x20=\x20?','push','toString','QueryTypes','SELECT','every','TeamId','union','compact','removeTeams','ids','removeAgents','userVoiceQueue:remove','addAgents','spread','isEmpty','upsert','isNil','all','isArray','getAgents','getMembers','CmList','getLists','dialCheckDuplicateType','always','insert','into','cm_hopper','phone','scheduledAt','ContactId','ListId','NOW()','from','ListId\x20=\x20?','CmListId','phone\x20IS\x20NOT\x20NULL','COALESCE(calleridnum,\x27\x27)','cm_hopper_final','phone\x20NOT\x20IN\x20(?)','COALESCE(phone,\x27\x27)','onlyIfOpen','fromQuery','cm_contacts','deletedAt\x20IS\x20NULL','removeLists','getBlackLists','addBlackLists','cm_hopper_black','removeBlackLists','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','path','sox','to-csv','ejs','squel','jsforce','desk.js','querystring','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/environment','../../config/license/util','../../mysqldb','redis','defaults','localhost','socket.io-emitter','./voiceQueue.socket','register','sendStatus','status','end','count','limit','set','reject','save','update','then','destroy','get','inbound','QueueCampaigns','outbound','filter','value','includes','find','type','UserProfileResource','error','stack','name','send','map','VoiceQueue','rawAttributes','fieldName','key','model','keys','query','filters','intersection','attributes','fields','length','nolimit','offset','sort','where','pick','merge','options','includeAll','include','findAll','rows','catch','show','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','VoiceQueues','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','clone','params','createdAt','updatedAt','omit','UserProfileSection','getHoppers','hasOwnProperty','order','CmHopper','CmHopperHistory','VoiceQueueId','findOne','CmHopperFinal','CmHopperBlack','getTeams','Team','addTeams','teams','Agents','online','flatMap','forEach','sequelize','each','UserVoiceQueue','findOrCreate'];(function(_0x47adb8,_0x591ccc){var _0x4689a8=function(_0x2ba76f){while(--_0x2ba76f){_0x47adb8['push'](_0x47adb8['shift']());}};_0x4689a8(++_0x591ccc);}(_0xedd9,0xfc));var _0x9edd=function(_0x208f90,_0x54451e){_0x208f90=_0x208f90-0x0;var _0x2fc0cb=_0xedd9[_0x208f90];return _0x2fc0cb;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0x9edd('0x0'));var rimraf=require(_0x9edd('0x1'));var zipdir=require(_0x9edd('0x2'));var jsonpatch=require(_0x9edd('0x3'));var rp=require(_0x9edd('0x4'));var moment=require(_0x9edd('0x5'));var BPromise=require(_0x9edd('0x6'));var Mustache=require(_0x9edd('0x7'));var util=require('util');var path=require(_0x9edd('0x8'));var sox=require(_0x9edd('0x9'));var csv=require(_0x9edd('0xa'));var ejs=require(_0x9edd('0xb'));var fs=require('fs');var _=require('lodash');var squel=require(_0x9edd('0xc'));var crypto=require('crypto');var jsforce=require(_0x9edd('0xd'));var deskjs=require(_0x9edd('0xe'));var toCsv=require(_0x9edd('0xa'));var querystring=require(_0x9edd('0xf'));var Papa=require('papaparse');var Redis=require(_0x9edd('0x10'));var authService=require('../../components/auth/service');var qs=require(_0x9edd('0x11'));var as=require(_0x9edd('0x12'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x9edd('0x13'))(_0x9edd('0x14'));var utils=require('../../config/utils');var config=require(_0x9edd('0x15'));var licenseUtil=require(_0x9edd('0x16'));var db=require(_0x9edd('0x17'))['db'];config[_0x9edd('0x18')]=_[_0x9edd('0x19')](config[_0x9edd('0x18')],{'host':_0x9edd('0x1a'),'port':0x18eb});var socket=require(_0x9edd('0x1b'))(new Redis(config['redis']));require(_0x9edd('0x1c'))[_0x9edd('0x1d')](socket);function respondWithStatusCode(_0x891832,_0x4d9a7){_0x4d9a7=_0x4d9a7||0xcc;return function(_0x13b6b6){if(_0x13b6b6){return _0x891832[_0x9edd('0x1e')](_0x4d9a7);}return _0x891832[_0x9edd('0x1f')](_0x4d9a7)[_0x9edd('0x20')]();};}function respondWithResult(_0x4ea60f,_0x5f5bf4){_0x5f5bf4=_0x5f5bf4||0xc8;return function(_0x448996){if(_0x448996){return _0x4ea60f[_0x9edd('0x1f')](_0x5f5bf4)['json'](_0x448996);}};}function respondWithFilteredResult(_0x1b54c0,_0x35f454){return function(_0x40ba32){if(_0x40ba32){var _0x4d8f33=_0x40ba32[_0x9edd('0x21')],_0x43dc70=_0x35f454['offset'],_0x5d879c=_0x35f454['offset']+_0x35f454[_0x9edd('0x22')],_0x2cdcef;if(_0x5d879c>=_0x4d8f33){_0x5d879c=_0x4d8f33;_0x2cdcef=0xc8;}else{_0x2cdcef=0xce;}_0x1b54c0['status'](_0x2cdcef);return _0x1b54c0[_0x9edd('0x23')]('Content-Range',_0x43dc70+'-'+_0x5d879c+'/'+_0x4d8f33)['json'](_0x40ba32);}return null;};}function patchUpdates(_0x356751){return function(_0x1c46a8){try{jsonpatch['apply'](_0x1c46a8,_0x356751,!![]);}catch(_0x5823bc){return BPromise[_0x9edd('0x24')](_0x5823bc);}return _0x1c46a8[_0x9edd('0x25')]();};}function saveUpdates(_0x477878,_0x542172){return function(_0x3741c8){if(_0x3741c8){return _0x3741c8[_0x9edd('0x26')](_0x477878)[_0x9edd('0x27')](function(_0x2ca65f){return _0x2ca65f;});}return null;};}function removeEntity(_0x339a0d,_0x4c75d2){return function(_0x46c383){if(_0x46c383){return _0x46c383[_0x9edd('0x28')]()[_0x9edd('0x27')](function(){var _0x2f9f86=_0x46c383[_0x9edd('0x29')]({'plain':!![]});var _0x4d507f=[{'name':'VoiceQueues','value':_0x9edd('0x2a'),'ignore':![]},{'name':_0x9edd('0x2b'),'value':_0x9edd('0x2c'),'ignore':![]}];var _0x25e135=_(_0x4d507f)[_0x9edd('0x2d')]('ignore')['map'](_0x9edd('0x2e'))[_0x9edd('0x2e')]();if(_[_0x9edd('0x2f')](_0x25e135,_0x2f9f86['type'])){return;}var _0x238b22=_[_0x9edd('0x30')](_0x4d507f,[_0x9edd('0x2e'),_0x2f9f86[_0x9edd('0x31')]])['name'];return db[_0x9edd('0x32')][_0x9edd('0x28')]({'where':{'type':_0x238b22,'resourceId':_0x2f9f86['id']}})[_0x9edd('0x27')](function(){return _0x46c383;});})[_0x9edd('0x27')](function(){_0x339a0d[_0x9edd('0x1f')](0xcc)[_0x9edd('0x20')]();});}};}function handleEntityNotFound(_0x209aba,_0x1fba7b){return function(_0x19b6c1){if(!_0x19b6c1){_0x209aba[_0x9edd('0x1e')](0x194);}return _0x19b6c1;};}function handleError(_0x4fd03f,_0x138002){_0x138002=_0x138002||0x1f4;return function(_0x6907a5){logger[_0x9edd('0x33')](_0x6907a5[_0x9edd('0x34')]);if(_0x6907a5['name']){delete _0x6907a5[_0x9edd('0x35')];}_0x4fd03f[_0x9edd('0x1f')](_0x138002)[_0x9edd('0x36')](_0x6907a5);};}exports['index']=function(_0x2d2f88,_0x3990fb){var _0xde9b13={},_0x38a7be={},_0x21bc30={'count':0x0,'rows':[]};var _0x2bc4ed=_[_0x9edd('0x37')](db[_0x9edd('0x38')][_0x9edd('0x39')],function(_0x2539c6){return{'name':_0x2539c6[_0x9edd('0x3a')],'type':_0x2539c6[_0x9edd('0x31')][_0x9edd('0x3b')]};});_0x38a7be[_0x9edd('0x3c')]=_['map'](_0x2bc4ed,_0x9edd('0x35'));_0x38a7be['query']=_[_0x9edd('0x3d')](_0x2d2f88[_0x9edd('0x3e')]);_0x38a7be[_0x9edd('0x3f')]=_[_0x9edd('0x40')](_0x38a7be[_0x9edd('0x3c')],_0x38a7be['query']);_0xde9b13[_0x9edd('0x41')]=_[_0x9edd('0x40')](_0x38a7be[_0x9edd('0x3c')],qs[_0x9edd('0x42')](_0x2d2f88[_0x9edd('0x3e')][_0x9edd('0x42')]));_0xde9b13[_0x9edd('0x41')]=_0xde9b13[_0x9edd('0x41')][_0x9edd('0x43')]?_0xde9b13[_0x9edd('0x41')]:_0x38a7be['model'];if(!_0x2d2f88[_0x9edd('0x3e')]['hasOwnProperty'](_0x9edd('0x44'))){_0xde9b13['limit']=qs[_0x9edd('0x22')](_0x2d2f88[_0x9edd('0x3e')][_0x9edd('0x22')]);_0xde9b13['offset']=qs[_0x9edd('0x45')](_0x2d2f88[_0x9edd('0x3e')][_0x9edd('0x45')]);}_0xde9b13['order']=qs[_0x9edd('0x46')](_0x2d2f88['query'][_0x9edd('0x46')]);_0xde9b13[_0x9edd('0x47')]=qs['filters'](_[_0x9edd('0x48')](_0x2d2f88[_0x9edd('0x3e')],_0x38a7be[_0x9edd('0x3f')]),_0x2bc4ed);if(_0x2d2f88[_0x9edd('0x3e')]['filter']){_0xde9b13[_0x9edd('0x47')]=_['merge'](_0xde9b13[_0x9edd('0x47')],{'$or':_[_0x9edd('0x37')](_0x2bc4ed,function(_0x587d74){if(_0x587d74[_0x9edd('0x31')]!=='VIRTUAL'){var _0x548299={};_0x548299[_0x587d74[_0x9edd('0x35')]]={'$like':'%'+_0x2d2f88[_0x9edd('0x3e')][_0x9edd('0x2d')]+'%'};return _0x548299;}})});}_0xde9b13=_[_0x9edd('0x49')]({},_0xde9b13,_0x2d2f88[_0x9edd('0x4a')]);var _0x4737ae={'where':_0xde9b13[_0x9edd('0x47')]};return db[_0x9edd('0x38')][_0x9edd('0x21')](_0x4737ae)[_0x9edd('0x27')](function(_0x37a263){_0x21bc30[_0x9edd('0x21')]=_0x37a263;if(_0x2d2f88[_0x9edd('0x3e')][_0x9edd('0x4b')]){_0xde9b13[_0x9edd('0x4c')]=[{'all':!![]}];}return db['VoiceQueue'][_0x9edd('0x4d')](_0xde9b13);})[_0x9edd('0x27')](function(_0x2231c1){_0x21bc30[_0x9edd('0x4e')]=_0x2231c1;return _0x21bc30;})[_0x9edd('0x27')](respondWithFilteredResult(_0x3990fb,_0xde9b13))[_0x9edd('0x4f')](handleError(_0x3990fb,null));};exports[_0x9edd('0x50')]=function(_0x4e9ad1,_0x4a4656){var _0x4bc7a1={'raw':![],'where':{'id':_0x4e9ad1['params']['id']}},_0x4a7dc9={};_0x4a7dc9[_0x9edd('0x3c')]=_[_0x9edd('0x3d')](db[_0x9edd('0x38')][_0x9edd('0x39')]);_0x4a7dc9[_0x9edd('0x3e')]=_['keys'](_0x4e9ad1[_0x9edd('0x3e')]);_0x4a7dc9[_0x9edd('0x3f')]=_[_0x9edd('0x40')](_0x4a7dc9['model'],_0x4a7dc9[_0x9edd('0x3e')]);_0x4bc7a1[_0x9edd('0x41')]=_[_0x9edd('0x40')](_0x4a7dc9[_0x9edd('0x3c')],qs[_0x9edd('0x42')](_0x4e9ad1[_0x9edd('0x3e')]['fields']));_0x4bc7a1[_0x9edd('0x41')]=_0x4bc7a1[_0x9edd('0x41')]['length']?_0x4bc7a1[_0x9edd('0x41')]:_0x4a7dc9[_0x9edd('0x3c')];if(_0x4e9ad1['query'][_0x9edd('0x4b')]){_0x4bc7a1[_0x9edd('0x4c')]=[{'all':!![]}];}_0x4bc7a1=_[_0x9edd('0x49')]({},_0x4bc7a1,_0x4e9ad1['options']);return db[_0x9edd('0x38')][_0x9edd('0x30')](_0x4bc7a1)[_0x9edd('0x27')](handleEntityNotFound(_0x4a4656,null))[_0x9edd('0x27')](respondWithResult(_0x4a4656,null))['catch'](handleError(_0x4a4656,null));};exports[_0x9edd('0x51')]=function(_0x527727,_0x12ba09){return db['VoiceQueue'][_0x9edd('0x51')](_0x527727[_0x9edd('0x52')],{})['then'](function(_0x8e59bd){var _0x4e2aaf=_0x527727[_0x9edd('0x53')][_0x9edd('0x29')]({'plain':!![]});if(!_0x4e2aaf)throw new Error(_0x9edd('0x54'));if(_0x4e2aaf[_0x9edd('0x55')]===_0x9edd('0x53')){var _0x18548e=_0x8e59bd[_0x9edd('0x29')]({'plain':!![]});var _0x14dd27=[{'name':_0x9edd('0x56'),'value':_0x9edd('0x2a')},{'name':_0x9edd('0x2b'),'value':'outbound'}];var _0x161bea=_[_0x9edd('0x30')](_0x14dd27,[_0x9edd('0x2e'),_0x18548e['type']])[_0x9edd('0x35')];return db['UserProfileSection']['find']({'where':{'name':_0x161bea,'userProfileId':_0x4e2aaf['userProfileId']},'raw':!![]})[_0x9edd('0x27')](function(_0x45f47c){if(_0x45f47c&&_0x45f47c[_0x9edd('0x57')]===0x0){return db[_0x9edd('0x32')]['create']({'name':_0x18548e['name'],'resourceId':_0x18548e['id'],'type':_0x45f47c['name'],'sectionId':_0x45f47c['id']},{})[_0x9edd('0x27')](function(){return _0x8e59bd;});}else{return _0x8e59bd;}})[_0x9edd('0x4f')](function(_0xd5090a){logger[_0x9edd('0x33')](_0x9edd('0x58'),_0xd5090a);throw _0xd5090a;});}return _0x8e59bd;})[_0x9edd('0x27')](respondWithResult(_0x12ba09,0xc9))[_0x9edd('0x4f')](handleError(_0x12ba09,null));};exports[_0x9edd('0x59')]=function(_0x4eb780,_0x16dfdc){var _0x49d0ce={'where':{'id':_0x4eb780[_0x9edd('0x5a')]['id']}},_0x421e82={};_0x421e82['model']=_[_0x9edd('0x3d')](db[_0x9edd('0x38')][_0x9edd('0x39')]);_0x49d0ce['attributes']=_[_0x9edd('0x40')](_0x421e82[_0x9edd('0x3c')],qs[_0x9edd('0x42')](_0x4eb780[_0x9edd('0x3e')][_0x9edd('0x42')]));_0x49d0ce[_0x9edd('0x41')]=_0x49d0ce['attributes']['length']?_0x49d0ce[_0x9edd('0x41')]:_0x421e82['model'];if(_0x4eb780[_0x9edd('0x3e')][_0x9edd('0x4b')]){_0x49d0ce[_0x9edd('0x4c')]=[{'all':!![]}];}_0x49d0ce=_[_0x9edd('0x49')]({},_0x49d0ce,_0x4eb780['options']);return db[_0x9edd('0x38')]['find'](_0x49d0ce)[_0x9edd('0x27')](handleEntityNotFound(_0x16dfdc,null))[_0x9edd('0x27')](function(_0xc6bde6){if(_0xc6bde6){var _0x5ca123=_0xc6bde6[_0x9edd('0x29')]({'plain':!![]});_0x5ca123=qs['omit'](_0x5ca123,['id',_0x9edd('0x5b'),_0x9edd('0x5c')]);_0x4eb780['body']=_[_0x9edd('0x5d')](_0x4eb780['body'],['id',_0x9edd('0x5b'),_0x9edd('0x5c')]);return db[_0x9edd('0x38')]['create'](_[_0x9edd('0x49')](_0x5ca123,_0x4eb780[_0x9edd('0x52')]),{'include':_0x4eb780[_0x9edd('0x3e')][_0x9edd('0x4b')]?[{'all':!![]}]:undefined})[_0x9edd('0x27')](function(_0x4d8fbb){var _0x48f017=_0x4eb780[_0x9edd('0x53')][_0x9edd('0x29')]({'plain':!![]});if(!_0x48f017)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x48f017['role']==='user'){var _0x1bc89b=_0x4d8fbb['get']({'plain':!![]});var _0x5cde37=[{'name':_0x9edd('0x56'),'value':_0x9edd('0x2a')},{'name':'QueueCampaigns','value':_0x9edd('0x2c')}];var _0x11e082=_[_0x9edd('0x30')](_0x5cde37,['value',_0x1bc89b[_0x9edd('0x31')]])['name'];return db[_0x9edd('0x5e')][_0x9edd('0x30')]({'where':{'name':_0x11e082,'userProfileId':_0x48f017['userProfileId']},'raw':!![]})[_0x9edd('0x27')](function(_0x27da1a){if(_0x27da1a&&_0x27da1a['autoAssociation']===0x0){return db[_0x9edd('0x32')][_0x9edd('0x51')]({'name':_0x1bc89b[_0x9edd('0x35')],'resourceId':_0x1bc89b['id'],'type':_0x27da1a[_0x9edd('0x35')],'sectionId':_0x27da1a['id']},{})['then'](function(){return _0x4d8fbb;});}else{return _0x4d8fbb;}})[_0x9edd('0x4f')](function(_0x58330c){logger[_0x9edd('0x33')](_0x9edd('0x58'),_0x58330c);throw _0x58330c;});}return _0x4d8fbb;});}})[_0x9edd('0x27')](respondWithResult(_0x16dfdc,0xc9))['catch'](handleError(_0x16dfdc,null));};exports[_0x9edd('0x26')]=function(_0x286593,_0x130dba){if(_0x286593[_0x9edd('0x52')]['id']){delete _0x286593[_0x9edd('0x52')]['id'];}return db[_0x9edd('0x38')][_0x9edd('0x30')]({'where':{'id':_0x286593['params']['id']}})['then'](handleEntityNotFound(_0x130dba,null))[_0x9edd('0x27')](saveUpdates(_0x286593[_0x9edd('0x52')],null))[_0x9edd('0x27')](respondWithResult(_0x130dba,null))[_0x9edd('0x4f')](handleError(_0x130dba,null));};exports[_0x9edd('0x28')]=function(_0x52f6f3,_0x2e40c8){return db[_0x9edd('0x38')][_0x9edd('0x30')]({'where':{'id':_0x52f6f3['params']['id']}})[_0x9edd('0x27')](handleEntityNotFound(_0x2e40c8,null))[_0x9edd('0x27')](removeEntity(_0x2e40c8,null))['catch'](handleError(_0x2e40c8,null));};exports[_0x9edd('0x5f')]=function(_0x3801c4,_0x58c839,_0x40b7db){var _0x1e2de6={'raw':![],'where':{}};var _0x566be7={};var _0x3f08ac={'count':0x0,'rows':[]};return db['VoiceQueue']['findOne']({'where':{'id':_0x3801c4[_0x9edd('0x5a')]['id']}})[_0x9edd('0x27')](handleEntityNotFound(_0x58c839,null))[_0x9edd('0x27')](function(_0x5b56c7){if(_0x5b56c7){_0x566be7[_0x9edd('0x3c')]=_[_0x9edd('0x3d')](db['CmHopper'][_0x9edd('0x39')]);_0x566be7[_0x9edd('0x3e')]=_[_0x9edd('0x3d')](_0x3801c4[_0x9edd('0x3e')]);_0x566be7['filters']=_['intersection'](_0x566be7[_0x9edd('0x3c')],_0x566be7['query']);_0x1e2de6[_0x9edd('0x41')]=_[_0x9edd('0x40')](_0x566be7[_0x9edd('0x3c')],qs[_0x9edd('0x42')](_0x3801c4[_0x9edd('0x3e')][_0x9edd('0x42')]));_0x1e2de6[_0x9edd('0x41')]=_0x1e2de6[_0x9edd('0x41')][_0x9edd('0x43')]?_0x1e2de6['attributes']:_0x566be7[_0x9edd('0x3c')];if(!_0x3801c4[_0x9edd('0x3e')][_0x9edd('0x60')](_0x9edd('0x44'))){_0x1e2de6[_0x9edd('0x22')]=qs[_0x9edd('0x22')](_0x3801c4[_0x9edd('0x3e')]['limit']);_0x1e2de6[_0x9edd('0x45')]=qs[_0x9edd('0x45')](_0x3801c4['query'][_0x9edd('0x45')]);}_0x1e2de6[_0x9edd('0x61')]=qs['sort'](_0x3801c4[_0x9edd('0x3e')][_0x9edd('0x46')]);_0x1e2de6[_0x9edd('0x47')]=qs['filters'](_[_0x9edd('0x48')](_0x3801c4[_0x9edd('0x3e')],_0x566be7[_0x9edd('0x3f')]));_0x1e2de6['where']['VoiceQueueId']=_0x5b56c7['id'];if(_0x3801c4['query']['filter']){_0x1e2de6[_0x9edd('0x47')]=_[_0x9edd('0x49')](_0x1e2de6[_0x9edd('0x47')],{'$or':_['map'](_0x1e2de6['attributes'],function(_0x49dc1d){var _0x56d794={};_0x56d794[_0x49dc1d]={'$like':'%'+_0x3801c4[_0x9edd('0x3e')][_0x9edd('0x2d')]+'%'};return _0x56d794;})});}_0x1e2de6=_[_0x9edd('0x49')]({},_0x1e2de6,_0x3801c4[_0x9edd('0x4a')]);return db[_0x9edd('0x62')][_0x9edd('0x21')]({'where':_0x1e2de6[_0x9edd('0x47')]})[_0x9edd('0x27')](function(_0x2f2c34){_0x3f08ac[_0x9edd('0x21')]=_0x2f2c34;if(_0x3801c4[_0x9edd('0x3e')]['includeAll']){_0x1e2de6[_0x9edd('0x4c')]=[{'all':!![]}];}return db[_0x9edd('0x62')][_0x9edd('0x4d')](_0x1e2de6);})[_0x9edd('0x27')](function(_0x104afc){_0x3f08ac[_0x9edd('0x4e')]=_0x104afc;return _0x3f08ac;});}})[_0x9edd('0x27')](respondWithFilteredResult(_0x58c839,_0x1e2de6))[_0x9edd('0x4f')](handleError(_0x58c839,null));};exports['getHopperHistories']=function(_0x5ada4e,_0xe02a6,_0x4ec836){var _0x35950b={'raw':!![],'where':{}};var _0x4a685e={};var _0x21c35f={'count':0x0,'rows':[]};return db[_0x9edd('0x38')]['findOne']({'where':{'id':_0x5ada4e[_0x9edd('0x5a')]['id']}})[_0x9edd('0x27')](handleEntityNotFound(_0xe02a6,null))['then'](function(_0x2bcc7a){if(_0x2bcc7a){_0x4a685e[_0x9edd('0x3c')]=_[_0x9edd('0x3d')](db[_0x9edd('0x63')][_0x9edd('0x39')]);_0x4a685e['query']=_[_0x9edd('0x3d')](_0x5ada4e[_0x9edd('0x3e')]);_0x4a685e[_0x9edd('0x3f')]=_[_0x9edd('0x40')](_0x4a685e[_0x9edd('0x3c')],_0x4a685e['query']);_0x35950b['attributes']=_['intersection'](_0x4a685e['model'],qs['fields'](_0x5ada4e[_0x9edd('0x3e')]['fields']));_0x35950b['attributes']=_0x35950b[_0x9edd('0x41')][_0x9edd('0x43')]?_0x35950b[_0x9edd('0x41')]:_0x4a685e[_0x9edd('0x3c')];if(!_0x5ada4e[_0x9edd('0x3e')][_0x9edd('0x60')](_0x9edd('0x44'))){_0x35950b[_0x9edd('0x22')]=qs[_0x9edd('0x22')](_0x5ada4e[_0x9edd('0x3e')]['limit']);_0x35950b[_0x9edd('0x45')]=qs[_0x9edd('0x45')](_0x5ada4e[_0x9edd('0x3e')][_0x9edd('0x45')]);}_0x35950b[_0x9edd('0x61')]=qs[_0x9edd('0x46')](_0x5ada4e[_0x9edd('0x3e')][_0x9edd('0x46')]);_0x35950b['where']=qs['filters'](_[_0x9edd('0x48')](_0x5ada4e[_0x9edd('0x3e')],_0x4a685e[_0x9edd('0x3f')]));_0x35950b[_0x9edd('0x47')][_0x9edd('0x64')]=_0x2bcc7a['id'];if(_0x5ada4e[_0x9edd('0x3e')][_0x9edd('0x2d')]){_0x35950b[_0x9edd('0x47')]=_[_0x9edd('0x49')](_0x35950b[_0x9edd('0x47')],{'$or':_[_0x9edd('0x37')](_0x35950b[_0x9edd('0x41')],function(_0x103a61){var _0xf418d={};_0xf418d[_0x103a61]={'$like':'%'+_0x5ada4e['query'][_0x9edd('0x2d')]+'%'};return _0xf418d;})});}_0x35950b=_[_0x9edd('0x49')]({},_0x35950b,_0x5ada4e['options']);return db[_0x9edd('0x63')][_0x9edd('0x21')]({'where':_0x35950b[_0x9edd('0x47')]})[_0x9edd('0x27')](function(_0x559503){_0x21c35f[_0x9edd('0x21')]=_0x559503;if(_0x5ada4e[_0x9edd('0x3e')][_0x9edd('0x4b')]){_0x35950b[_0x9edd('0x4c')]=[{'all':!![]}];}return db[_0x9edd('0x63')]['findAll'](_0x35950b);})[_0x9edd('0x27')](function(_0x1c21d5){_0x21c35f[_0x9edd('0x4e')]=_0x1c21d5;return _0x21c35f;});}})[_0x9edd('0x27')](respondWithFilteredResult(_0xe02a6,_0x35950b))[_0x9edd('0x4f')](handleError(_0xe02a6,null));};exports['getHopperFinals']=function(_0x4d0734,_0x2f8ce1,_0x5435e3){var _0x30208f={'raw':!![],'where':{}};var _0x52308a={};var _0xe9ab48={'count':0x0,'rows':[]};return db[_0x9edd('0x38')][_0x9edd('0x65')]({'where':{'id':_0x4d0734[_0x9edd('0x5a')]['id']}})[_0x9edd('0x27')](handleEntityNotFound(_0x2f8ce1,null))[_0x9edd('0x27')](function(_0x5975f9){if(_0x5975f9){_0x52308a[_0x9edd('0x3c')]=_[_0x9edd('0x3d')](db[_0x9edd('0x66')][_0x9edd('0x39')]);_0x52308a[_0x9edd('0x3e')]=_[_0x9edd('0x3d')](_0x4d0734[_0x9edd('0x3e')]);_0x52308a[_0x9edd('0x3f')]=_['intersection'](_0x52308a[_0x9edd('0x3c')],_0x52308a[_0x9edd('0x3e')]);_0x30208f[_0x9edd('0x41')]=_[_0x9edd('0x40')](_0x52308a[_0x9edd('0x3c')],qs[_0x9edd('0x42')](_0x4d0734[_0x9edd('0x3e')][_0x9edd('0x42')]));_0x30208f[_0x9edd('0x41')]=_0x30208f[_0x9edd('0x41')][_0x9edd('0x43')]?_0x30208f[_0x9edd('0x41')]:_0x52308a[_0x9edd('0x3c')];if(!_0x4d0734[_0x9edd('0x3e')][_0x9edd('0x60')](_0x9edd('0x44'))){_0x30208f[_0x9edd('0x22')]=qs[_0x9edd('0x22')](_0x4d0734[_0x9edd('0x3e')][_0x9edd('0x22')]);_0x30208f[_0x9edd('0x45')]=qs['offset'](_0x4d0734[_0x9edd('0x3e')]['offset']);}_0x30208f['order']=qs[_0x9edd('0x46')](_0x4d0734[_0x9edd('0x3e')][_0x9edd('0x46')]);_0x30208f[_0x9edd('0x47')]=qs[_0x9edd('0x3f')](_[_0x9edd('0x48')](_0x4d0734[_0x9edd('0x3e')],_0x52308a[_0x9edd('0x3f')]));_0x30208f[_0x9edd('0x47')][_0x9edd('0x64')]=_0x5975f9['id'];if(_0x4d0734['query'][_0x9edd('0x2d')]){_0x30208f[_0x9edd('0x47')]=_['merge'](_0x30208f['where'],{'$or':_[_0x9edd('0x37')](_0x30208f[_0x9edd('0x41')],function(_0x29feb7){var _0x28a8ff={};_0x28a8ff[_0x29feb7]={'$like':'%'+_0x4d0734['query']['filter']+'%'};return _0x28a8ff;})});}_0x30208f=_[_0x9edd('0x49')]({},_0x30208f,_0x4d0734['options']);return db[_0x9edd('0x66')][_0x9edd('0x21')]({'where':_0x30208f[_0x9edd('0x47')]})['then'](function(_0x5cb572){_0xe9ab48['count']=_0x5cb572;if(_0x4d0734[_0x9edd('0x3e')][_0x9edd('0x4b')]){_0x30208f[_0x9edd('0x4c')]=[{'all':!![]}];}return db['CmHopperFinal'][_0x9edd('0x4d')](_0x30208f);})[_0x9edd('0x27')](function(_0x4f12b9){_0xe9ab48[_0x9edd('0x4e')]=_0x4f12b9;return _0xe9ab48;});}})[_0x9edd('0x27')](respondWithFilteredResult(_0x2f8ce1,_0x30208f))['catch'](handleError(_0x2f8ce1,null));};exports['getHopperBlacks']=function(_0x427db2,_0x81cf58,_0x525441){var _0x33fe33={'raw':!![],'where':{}};var _0x16c7f={};var _0x54c6a0={'count':0x0,'rows':[]};return db[_0x9edd('0x38')]['findOne']({'where':{'id':_0x427db2[_0x9edd('0x5a')]['id']}})[_0x9edd('0x27')](handleEntityNotFound(_0x81cf58,null))[_0x9edd('0x27')](function(_0x742e13){if(_0x742e13){_0x16c7f[_0x9edd('0x3c')]=_[_0x9edd('0x3d')](db['CmHopperBlack'][_0x9edd('0x39')]);_0x16c7f[_0x9edd('0x3e')]=_[_0x9edd('0x3d')](_0x427db2['query']);_0x16c7f[_0x9edd('0x3f')]=_['intersection'](_0x16c7f[_0x9edd('0x3c')],_0x16c7f[_0x9edd('0x3e')]);_0x33fe33[_0x9edd('0x41')]=_[_0x9edd('0x40')](_0x16c7f['model'],qs['fields'](_0x427db2['query'][_0x9edd('0x42')]));_0x33fe33[_0x9edd('0x41')]=_0x33fe33[_0x9edd('0x41')]['length']?_0x33fe33[_0x9edd('0x41')]:_0x16c7f[_0x9edd('0x3c')];if(!_0x427db2[_0x9edd('0x3e')][_0x9edd('0x60')](_0x9edd('0x44'))){_0x33fe33[_0x9edd('0x22')]=qs['limit'](_0x427db2['query'][_0x9edd('0x22')]);_0x33fe33[_0x9edd('0x45')]=qs[_0x9edd('0x45')](_0x427db2['query'][_0x9edd('0x45')]);}_0x33fe33[_0x9edd('0x61')]=qs[_0x9edd('0x46')](_0x427db2[_0x9edd('0x3e')]['sort']);_0x33fe33[_0x9edd('0x47')]=qs['filters'](_[_0x9edd('0x48')](_0x427db2[_0x9edd('0x3e')],_0x16c7f[_0x9edd('0x3f')]));_0x33fe33[_0x9edd('0x47')][_0x9edd('0x64')]=_0x742e13['id'];if(_0x427db2['query'][_0x9edd('0x2d')]){_0x33fe33['where']=_[_0x9edd('0x49')](_0x33fe33['where'],{'$or':_[_0x9edd('0x37')](_0x33fe33['attributes'],function(_0x363c5c){var _0x96e3d7={};_0x96e3d7[_0x363c5c]={'$like':'%'+_0x427db2[_0x9edd('0x3e')]['filter']+'%'};return _0x96e3d7;})});}_0x33fe33=_[_0x9edd('0x49')]({},_0x33fe33,_0x427db2[_0x9edd('0x4a')]);return db[_0x9edd('0x67')][_0x9edd('0x21')]({'where':_0x33fe33[_0x9edd('0x47')]})[_0x9edd('0x27')](function(_0x6a24f3){_0x54c6a0[_0x9edd('0x21')]=_0x6a24f3;if(_0x427db2[_0x9edd('0x3e')][_0x9edd('0x4b')]){_0x33fe33[_0x9edd('0x4c')]=[{'all':!![]}];}return db[_0x9edd('0x67')][_0x9edd('0x4d')](_0x33fe33);})[_0x9edd('0x27')](function(_0x33dbe8){_0x54c6a0[_0x9edd('0x4e')]=_0x33dbe8;return _0x54c6a0;});}})[_0x9edd('0x27')](respondWithFilteredResult(_0x81cf58,_0x33fe33))[_0x9edd('0x4f')](handleError(_0x81cf58,null));};exports[_0x9edd('0x68')]=function(_0x1bba37,_0x33e1f0,_0x31ff2f){var _0x5100a9={};var _0x45905b={};var _0x530866;var _0x3a743d;return db[_0x9edd('0x38')][_0x9edd('0x65')]({'where':{'id':_0x1bba37[_0x9edd('0x5a')]['id']}})[_0x9edd('0x27')](handleEntityNotFound(_0x33e1f0,null))['then'](function(_0x2d7cff){if(_0x2d7cff){_0x530866=_0x2d7cff;_0x45905b['model']=_[_0x9edd('0x3d')](db[_0x9edd('0x69')][_0x9edd('0x39')]);_0x45905b[_0x9edd('0x3e')]=_[_0x9edd('0x3d')](_0x1bba37[_0x9edd('0x3e')]);_0x45905b['filters']=_[_0x9edd('0x40')](_0x45905b[_0x9edd('0x3c')],_0x45905b['query']);_0x5100a9['attributes']=_['intersection'](_0x45905b['model'],qs[_0x9edd('0x42')](_0x1bba37[_0x9edd('0x3e')][_0x9edd('0x42')]));_0x5100a9[_0x9edd('0x41')]=_0x5100a9[_0x9edd('0x41')][_0x9edd('0x43')]?_0x5100a9[_0x9edd('0x41')]:_0x45905b[_0x9edd('0x3c')];_0x5100a9[_0x9edd('0x61')]=qs[_0x9edd('0x46')](_0x1bba37['query'][_0x9edd('0x46')]);_0x5100a9['where']=qs['filters'](_[_0x9edd('0x48')](_0x1bba37[_0x9edd('0x3e')],_0x45905b[_0x9edd('0x3f')]));if(_0x1bba37[_0x9edd('0x3e')][_0x9edd('0x2d')]){_0x5100a9['where']=_[_0x9edd('0x49')](_0x5100a9[_0x9edd('0x47')],{'$or':_[_0x9edd('0x37')](_0x5100a9[_0x9edd('0x41')],function(_0x550439){var _0x16f295={};_0x16f295[_0x550439]={'$like':'%'+_0x1bba37[_0x9edd('0x3e')][_0x9edd('0x2d')]+'%'};return _0x16f295;})});}_0x5100a9=_[_0x9edd('0x49')]({},_0x5100a9,_0x1bba37[_0x9edd('0x4a')]);return _0x530866[_0x9edd('0x68')](_0x5100a9);}})[_0x9edd('0x27')](function(_0x9ff2d3){if(_0x9ff2d3){_0x3a743d=_0x9ff2d3[_0x9edd('0x43')];if(!_0x1bba37[_0x9edd('0x3e')][_0x9edd('0x60')]('nolimit')){_0x5100a9[_0x9edd('0x22')]=qs[_0x9edd('0x22')](_0x1bba37[_0x9edd('0x3e')][_0x9edd('0x22')]);_0x5100a9[_0x9edd('0x45')]=qs[_0x9edd('0x45')](_0x1bba37[_0x9edd('0x3e')][_0x9edd('0x45')]);}return _0x530866['getTeams'](_0x5100a9);}})['then'](function(_0x5741cb){if(_0x5741cb){return _0x5741cb?{'count':_0x3a743d,'rows':_0x5741cb}:null;}})[_0x9edd('0x27')](respondWithResult(_0x33e1f0,null))[_0x9edd('0x4f')](handleError(_0x33e1f0,null));};exports[_0x9edd('0x6a')]=function(_0x2810dc,_0x223c42,_0x2e9df8){var _0x3cddc7=_0x2810dc[_0x9edd('0x52')][_0x9edd('0x6b')];var _0x366483=_['map'](_0x3cddc7,'id');return db[_0x9edd('0x69')]['findAll']({'where':{'id':_0x366483},'attributes':['id'],'include':[{'model':db['User'],'as':_0x9edd('0x6c'),'attributes':['id',_0x9edd('0x35'),_0x9edd('0x6d'),'voicePause','interface'],'raw':!![]}]})['then'](function(_0x56bdb9){if(_0x56bdb9){var _0x5a3bca=_[_0x9edd('0x6e')](_0x56bdb9,function(_0x3b683f){var _0x64505a=_0x3b683f['get']({'plain':!![]});_0x64505a[_0x9edd('0x6c')][_0x9edd('0x6f')](function(_0x231917){_0x231917['penalty']=_[_0x9edd('0x30')](_0x3cddc7,{'id':_0x64505a['id']})['penalty'];});return _0x64505a[_0x9edd('0x6c')];});return db[_0x9edd('0x38')][_0x9edd('0x30')]({'where':{'id':_0x2810dc[_0x9edd('0x5a')]['id']}})['then'](function(_0x44933c){return db[_0x9edd('0x70')]['transaction'](function(_0x3309ba){return _0x44933c[_0x9edd('0x6a')](_0x366483,{'transaction':_0x3309ba})[_0x9edd('0x27')](function(){return BPromise[_0x9edd('0x71')](_0x5a3bca,function(_0x5c0254){return db[_0x9edd('0x72')][_0x9edd('0x73')]({'where':{'UserId':_0x5c0254['id'],'VoiceQueueId':_0x2810dc[_0x9edd('0x5a')]['id']},'defaults':{'penalty':_0x5c0254[_0x9edd('0x74')]},'transaction':_0x3309ba});});})[_0x9edd('0x27')](function(){return BPromise[_0x9edd('0x71')](_[_0x9edd('0x2d')](_0x5a3bca,{'online':!![]}),function(_0x5baec8){return db[_0x9edd('0x75')]['upsert']({'membername':_0x5baec8[_0x9edd('0x35')],'UserId':_0x5baec8['id'],'queue_name':_0x44933c[_0x9edd('0x35')],'VoiceQueueId':_0x44933c['id'],'interface':_['isNil'](_0x5baec8[_0x9edd('0x76')])?util[_0x9edd('0x77')](_0x9edd('0x78'),_0x5baec8['name']):_0x5baec8[_0x9edd('0x76')],'paused':_0x5baec8[_0x9edd('0x79')]||![],'penalty':_0x5baec8[_0x9edd('0x74')]},{'transaction':_0x3309ba});});})['then'](function(){_0x5a3bca[_0x9edd('0x6f')](function(_0x517142){socket[_0x9edd('0x7a')](_0x9edd('0x7b'),{'UserId':_0x517142['id'],'VoiceQueueId':_0x44933c['id']});});});});});}})[_0x9edd('0x27')](respondWithStatusCode(_0x223c42,null))[_0x9edd('0x4f')](handleError(_0x223c42,null));};exports['removeTeams']=function(_0x4843f2,_0x3bceb3,_0x12f23f){return db[_0x9edd('0x69')][_0x9edd('0x4d')]({'where':{'id':_0x4843f2[_0x9edd('0x3e')]['ids']},'attributes':['id'],'include':[{'model':db[_0x9edd('0x7c')],'as':_0x9edd('0x6c'),'attributes':['id'],'raw':!![]}]})[_0x9edd('0x27')](handleEntityNotFound(_0x3bceb3,null))[_0x9edd('0x27')](function(_0x37879a){var _0x100cad=_[_0x9edd('0x37')](_0x37879a,'id');var _0x3d1ea5=[];var _0x3173fa=[];var _0x2eb738=squel[_0x9edd('0x7d')]();_0x2eb738[_0x9edd('0x7e')](_0x9edd('0x7f'))['from'](_0x9edd('0x80'),'tq')[_0x9edd('0x81')](_0x9edd('0x82'),'ut',_0x9edd('0x83'))['where'](_0x9edd('0x84'),_0x4843f2[_0x9edd('0x5a')]['id']);for(var _0x3eb99c=0x0;_0x3eb99c<_0x37879a['length'];_0x3eb99c+=0x1){let _0x910adf=_0x37879a[_0x3eb99c];for(var _0x49a24f=0x0;_0x49a24f<_0x910adf['Agents'][_0x9edd('0x43')];_0x49a24f+=0x1){let _0x94a989=_0x910adf[_0x9edd('0x6c')][_0x49a24f];var _0x1934d3=_0x2eb738['clone']();_0x1934d3[_0x9edd('0x47')](_0x9edd('0x85'),_0x94a989['id']);_0x3173fa[_0x9edd('0x86')](db[_0x9edd('0x70')][_0x9edd('0x3e')](_0x1934d3[_0x9edd('0x87')](),{'type':db[_0x9edd('0x70')][_0x9edd('0x88')][_0x9edd('0x89')]})[_0x9edd('0x27')](function(_0xa4a0f3){if(_0xa4a0f3[_0x9edd('0x43')]===0x1){return _0x94a989['id'];}else{var _0x5c17fb=_[_0x9edd('0x8a')](_[_0x9edd('0x37')](_0xa4a0f3,_0x9edd('0x8b')),function(_0x16f5f4){return _[_0x9edd('0x2f')](_0x100cad,_0x16f5f4);});if(_0x5c17fb){return _0x94a989['id'];}}}));}}return BPromise['all'](_0x3173fa)[_0x9edd('0x27')](function(_0x4a4581){_0x3d1ea5=_(_0x3d1ea5)[_0x9edd('0x8c')](_0x4a4581)[_0x9edd('0x8d')]()['value']();return db['VoiceQueue'][_0x9edd('0x30')]({'where':{'id':_0x4843f2[_0x9edd('0x5a')]['id']}})[_0x9edd('0x27')](function(_0x25b361){return db[_0x9edd('0x70')]['transaction'](function(_0x5601fc){return _0x25b361[_0x9edd('0x8e')](_0x4843f2[_0x9edd('0x3e')][_0x9edd('0x8f')],{'transaction':_0x5601fc})[_0x9edd('0x27')](function(){if(!_['isEmpty'](_0x3d1ea5)){return _0x25b361[_0x9edd('0x90')](_0x3d1ea5,{'transaction':_0x5601fc})[_0x9edd('0x27')](function(){return db[_0x9edd('0x75')][_0x9edd('0x28')]({'where':{'VoiceQueueId':_0x4843f2[_0x9edd('0x5a')]['id'],'UserId':_0x3d1ea5},'transaction':_0x5601fc});});}})[_0x9edd('0x27')](function(){_0x3d1ea5[_0x9edd('0x6f')](function(_0x5bda3a){socket[_0x9edd('0x7a')](_0x9edd('0x91'),{'UserId':_0x5bda3a,'VoiceQueueId':_0x25b361['id']});});});});});});})[_0x9edd('0x27')](respondWithStatusCode(_0x3bceb3,null))[_0x9edd('0x4f')](handleError(_0x3bceb3,null));};exports[_0x9edd('0x92')]=function(_0x252617,_0x1f527b,_0x24a665){var _0x8fdcf0,_0x8161b1;return db[_0x9edd('0x38')][_0x9edd('0x30')]({'where':{'id':_0x252617[_0x9edd('0x5a')]['id']}})['then'](handleEntityNotFound(_0x1f527b,null))[_0x9edd('0x27')](function(_0x32cb87){if(_0x32cb87){_0x8161b1=_0x32cb87;return _0x32cb87[_0x9edd('0x92')](_0x252617[_0x9edd('0x52')]['ids'],_[_0x9edd('0x5d')](_0x252617[_0x9edd('0x52')],[_0x9edd('0x8f'),'id'])||{})[_0x9edd('0x93')](function(_0x30f26a){for(var _0x1bf963=0x0;_0x1bf963<_0x252617[_0x9edd('0x52')][_0x9edd('0x8f')][_0x9edd('0x43')];_0x1bf963+=0x1){socket[_0x9edd('0x7a')](_0x9edd('0x7b'),{'UserId':_0x252617['body'][_0x9edd('0x8f')][_0x1bf963],'VoiceQueueId':_0x252617[_0x9edd('0x5a')]['id']});}return _0x30f26a;});}})[_0x9edd('0x27')](function(_0x257dee){_0x8fdcf0=_0x257dee||[];if(_0x8161b1){return db[_0x9edd('0x7c')][_0x9edd('0x4d')]({'where':{'id':_0x252617[_0x9edd('0x52')]['ids']},'attributes':['id',_0x9edd('0x35'),_0x9edd('0x6d'),_0x9edd('0x79'),_0x9edd('0x76')],'raw':!![]});}})[_0x9edd('0x27')](function(_0x116fcb){if(!_[_0x9edd('0x94')](_0x116fcb)){var _0x2cb08b=[];for(var _0x1b780b=0x0;_0x1b780b<_0x116fcb[_0x9edd('0x43')];_0x1b780b++){if(_0x116fcb[_0x1b780b][_0x9edd('0x6d')]){_0x2cb08b[_0x9edd('0x86')](db[_0x9edd('0x75')][_0x9edd('0x95')]({'membername':_0x116fcb[_0x1b780b][_0x9edd('0x35')],'UserId':_0x116fcb[_0x1b780b]['id'],'queue_name':_0x8161b1[_0x9edd('0x35')],'VoiceQueueId':_0x8161b1['id'],'interface':_[_0x9edd('0x96')](_0x116fcb[_0x1b780b]['interface'])?util[_0x9edd('0x77')](_0x9edd('0x78'),_0x116fcb[_0x1b780b][_0x9edd('0x35')]):_0x116fcb[_0x1b780b][_0x9edd('0x76')],'paused':_0x116fcb[_0x1b780b][_0x9edd('0x79')]||![],'penalty':_0x252617[_0x9edd('0x52')][_0x9edd('0x74')]||0x0}));}}return BPromise[_0x9edd('0x97')](_0x2cb08b);}})[_0x9edd('0x27')](function(){return _0x8fdcf0;})['then'](respondWithResult(_0x1f527b,null))[_0x9edd('0x4f')](handleError(_0x1f527b,null));};exports[_0x9edd('0x90')]=function(_0x2d5b04,_0x583feb,_0x248ca2){return db['VoiceQueue'][_0x9edd('0x30')]({'where':{'id':_0x2d5b04['params']['id']}})[_0x9edd('0x27')](handleEntityNotFound(_0x583feb,null))[_0x9edd('0x27')](function(_0x5c79c5){if(_0x5c79c5){return _0x5c79c5[_0x9edd('0x90')](_0x2d5b04[_0x9edd('0x3e')][_0x9edd('0x8f')])[_0x9edd('0x27')](function(){if(_[_0x9edd('0x98')](_0x2d5b04[_0x9edd('0x3e')][_0x9edd('0x8f')])){for(var _0x5c3f89=0x0;_0x5c3f89<_0x2d5b04[_0x9edd('0x3e')][_0x9edd('0x8f')]['length'];_0x5c3f89+=0x1){socket[_0x9edd('0x7a')]('userVoiceQueue:remove',{'UserId':Number(_0x2d5b04[_0x9edd('0x3e')][_0x9edd('0x8f')][_0x5c3f89]),'VoiceQueueId':Number(_0x2d5b04[_0x9edd('0x5a')]['id'])});}}else{socket[_0x9edd('0x7a')](_0x9edd('0x91'),{'UserId':Number(_0x2d5b04[_0x9edd('0x3e')][_0x9edd('0x8f')]),'VoiceQueueId':Number(_0x2d5b04[_0x9edd('0x5a')]['id'])});}});}})[_0x9edd('0x27')](function(_0x2bc46d){return db[_0x9edd('0x75')][_0x9edd('0x28')]({'where':{'VoiceQueueId':_0x2d5b04['params']['id'],'UserId':_0x2d5b04['query'][_0x9edd('0x8f')]}})[_0x9edd('0x27')](function(){return _0x2bc46d;});})[_0x9edd('0x27')](respondWithStatusCode(_0x583feb,null))[_0x9edd('0x4f')](handleError(_0x583feb,null));};exports[_0x9edd('0x99')]=function(_0x1f64f5,_0x43a859,_0x2f4462){var _0x27c709={};var _0x491905={};var _0x1395fa;var _0x49181c;return db[_0x9edd('0x38')][_0x9edd('0x65')]({'where':{'id':_0x1f64f5[_0x9edd('0x5a')]['id']}})[_0x9edd('0x27')](handleEntityNotFound(_0x43a859,null))[_0x9edd('0x27')](function(_0x12561b){if(_0x12561b){_0x1395fa=_0x12561b;_0x491905[_0x9edd('0x3c')]=_[_0x9edd('0x3d')](db[_0x9edd('0x7c')][_0x9edd('0x39')]);_0x491905[_0x9edd('0x3e')]=_[_0x9edd('0x3d')](_0x1f64f5[_0x9edd('0x3e')]);_0x491905[_0x9edd('0x3f')]=_[_0x9edd('0x40')](_0x491905[_0x9edd('0x3c')],_0x491905[_0x9edd('0x3e')]);_0x27c709[_0x9edd('0x41')]=_[_0x9edd('0x40')](_0x491905['model'],qs['fields'](_0x1f64f5[_0x9edd('0x3e')]['fields']));_0x27c709[_0x9edd('0x41')]=_0x27c709[_0x9edd('0x41')][_0x9edd('0x43')]?_0x27c709[_0x9edd('0x41')]:_0x491905['model'];_0x27c709['order']=qs[_0x9edd('0x46')](_0x1f64f5[_0x9edd('0x3e')][_0x9edd('0x46')]);_0x27c709[_0x9edd('0x47')]=qs[_0x9edd('0x3f')](_['pick'](_0x1f64f5[_0x9edd('0x3e')],_0x491905['filters']));if(_0x1f64f5[_0x9edd('0x3e')][_0x9edd('0x2d')]){_0x27c709[_0x9edd('0x47')]=_[_0x9edd('0x49')](_0x27c709['where'],{'$or':_['map'](_0x27c709['attributes'],function(_0x3bb205){var _0x11b5be={};_0x11b5be[_0x3bb205]={'$like':'%'+_0x1f64f5[_0x9edd('0x3e')][_0x9edd('0x2d')]+'%'};return _0x11b5be;})});}_0x27c709=_[_0x9edd('0x49')]({},_0x27c709,_0x1f64f5[_0x9edd('0x4a')]);return _0x1395fa['getAgents'](_0x27c709);}})[_0x9edd('0x27')](function(_0x2779a8){if(_0x2779a8){_0x49181c=_0x2779a8['length'];if(!_0x1f64f5['query'][_0x9edd('0x60')](_0x9edd('0x44'))){_0x27c709[_0x9edd('0x22')]=qs['limit'](_0x1f64f5[_0x9edd('0x3e')][_0x9edd('0x22')]);_0x27c709[_0x9edd('0x45')]=qs[_0x9edd('0x45')](_0x1f64f5['query'][_0x9edd('0x45')]);}return _0x1395fa[_0x9edd('0x99')](_0x27c709);}})[_0x9edd('0x27')](function(_0x18924e){if(_0x18924e){return _0x18924e?{'count':_0x49181c,'rows':_0x18924e}:null;}})[_0x9edd('0x27')](respondWithResult(_0x43a859,null))[_0x9edd('0x4f')](handleError(_0x43a859,null));};exports['getMembers']=function(_0x93a34d,_0x8316f9,_0x1de546){var _0xceabed={};var _0x4a0462={};var _0x57a6bc;var _0x42f2e8;return db[_0x9edd('0x38')][_0x9edd('0x65')]({'where':{'id':_0x93a34d[_0x9edd('0x5a')]['id']}})[_0x9edd('0x27')](handleEntityNotFound(_0x8316f9,null))[_0x9edd('0x27')](function(_0x457a29){if(_0x457a29){_0x57a6bc=_0x457a29;_0x4a0462[_0x9edd('0x3c')]=_[_0x9edd('0x3d')](db[_0x9edd('0x75')][_0x9edd('0x39')]);_0x4a0462[_0x9edd('0x3e')]=_['keys'](_0x93a34d['query']);_0x4a0462[_0x9edd('0x3f')]=_[_0x9edd('0x40')](_0x4a0462[_0x9edd('0x3c')],_0x4a0462[_0x9edd('0x3e')]);_0xceabed[_0x9edd('0x41')]=_[_0x9edd('0x40')](_0x4a0462[_0x9edd('0x3c')],qs[_0x9edd('0x42')](_0x93a34d['query'][_0x9edd('0x42')]));_0xceabed[_0x9edd('0x41')]=_0xceabed[_0x9edd('0x41')][_0x9edd('0x43')]?_0xceabed[_0x9edd('0x41')]:_0x4a0462[_0x9edd('0x3c')];_0xceabed['order']=qs['sort'](_0x93a34d[_0x9edd('0x3e')][_0x9edd('0x46')]);_0xceabed[_0x9edd('0x47')]=qs['filters'](_['pick'](_0x93a34d[_0x9edd('0x3e')],_0x4a0462[_0x9edd('0x3f')]));if(_0x93a34d[_0x9edd('0x3e')][_0x9edd('0x2d')]){_0xceabed[_0x9edd('0x47')]=_[_0x9edd('0x49')](_0xceabed[_0x9edd('0x47')],{'$or':_[_0x9edd('0x37')](_0xceabed[_0x9edd('0x41')],function(_0x44f821){var _0x246d42={};_0x246d42[_0x44f821]={'$like':'%'+_0x93a34d['query'][_0x9edd('0x2d')]+'%'};return _0x246d42;})});}_0xceabed=_['merge']({},_0xceabed,_0x93a34d['options']);return _0x57a6bc['getMembers'](_0xceabed);}})[_0x9edd('0x27')](function(_0x660591){if(_0x660591){_0x42f2e8=_0x660591['length'];if(!_0x93a34d['query']['hasOwnProperty']('nolimit')){_0xceabed[_0x9edd('0x22')]=qs[_0x9edd('0x22')](_0x93a34d[_0x9edd('0x3e')]['limit']);_0xceabed[_0x9edd('0x45')]=qs[_0x9edd('0x45')](_0x93a34d[_0x9edd('0x3e')][_0x9edd('0x45')]);}return _0x57a6bc[_0x9edd('0x9a')](_0xceabed);}})['then'](function(_0x33b06c){return _0x33b06c?{'count':_0x42f2e8,'rows':_0x33b06c}:null;})['then'](respondWithResult(_0x8316f9,null))[_0x9edd('0x4f')](handleError(_0x8316f9,null));};exports['getLists']=function(_0x28706a,_0x20cf26,_0x1121ec){var _0x5f37d1={};var _0x2ef921={};var _0x294e40;var _0x3e2fc7;return db['VoiceQueue']['findOne']({'where':{'id':_0x28706a[_0x9edd('0x5a')]['id']}})[_0x9edd('0x27')](handleEntityNotFound(_0x20cf26,null))[_0x9edd('0x27')](function(_0x2040ad){if(_0x2040ad){_0x294e40=_0x2040ad;_0x2ef921[_0x9edd('0x3c')]=_[_0x9edd('0x3d')](db[_0x9edd('0x9b')][_0x9edd('0x39')]);_0x2ef921[_0x9edd('0x3e')]=_[_0x9edd('0x3d')](_0x28706a['query']);_0x2ef921[_0x9edd('0x3f')]=_[_0x9edd('0x40')](_0x2ef921['model'],_0x2ef921['query']);_0x5f37d1[_0x9edd('0x41')]=_[_0x9edd('0x40')](_0x2ef921[_0x9edd('0x3c')],qs[_0x9edd('0x42')](_0x28706a['query'][_0x9edd('0x42')]));_0x5f37d1[_0x9edd('0x41')]=_0x5f37d1[_0x9edd('0x41')][_0x9edd('0x43')]?_0x5f37d1['attributes']:_0x2ef921[_0x9edd('0x3c')];_0x5f37d1[_0x9edd('0x61')]=qs[_0x9edd('0x46')](_0x28706a['query'][_0x9edd('0x46')]);_0x5f37d1[_0x9edd('0x47')]=qs[_0x9edd('0x3f')](_[_0x9edd('0x48')](_0x28706a[_0x9edd('0x3e')],_0x2ef921[_0x9edd('0x3f')]));if(_0x28706a[_0x9edd('0x3e')]['filter']){_0x5f37d1[_0x9edd('0x47')]=_[_0x9edd('0x49')](_0x5f37d1['where'],{'$or':_[_0x9edd('0x37')](_0x5f37d1['attributes'],function(_0x5a43af){var _0x3fc229={};_0x3fc229[_0x5a43af]={'$like':'%'+_0x28706a[_0x9edd('0x3e')][_0x9edd('0x2d')]+'%'};return _0x3fc229;})});}_0x5f37d1=_[_0x9edd('0x49')]({},_0x5f37d1,_0x28706a[_0x9edd('0x4a')]);return _0x294e40[_0x9edd('0x9c')](_0x5f37d1);}})[_0x9edd('0x27')](function(_0x3c19f7){if(_0x3c19f7){_0x3e2fc7=_0x3c19f7[_0x9edd('0x43')];if(!_0x28706a[_0x9edd('0x3e')][_0x9edd('0x60')]('nolimit')){_0x5f37d1['limit']=qs[_0x9edd('0x22')](_0x28706a[_0x9edd('0x3e')][_0x9edd('0x22')]);_0x5f37d1[_0x9edd('0x45')]=qs[_0x9edd('0x45')](_0x28706a[_0x9edd('0x3e')]['offset']);}return _0x294e40[_0x9edd('0x9c')](_0x5f37d1);}})[_0x9edd('0x27')](function(_0x38eb4f){if(_0x38eb4f){return _0x38eb4f?{'count':_0x3e2fc7,'rows':_0x38eb4f}:null;}})['then'](respondWithResult(_0x20cf26,null))[_0x9edd('0x4f')](handleError(_0x20cf26,null));};exports['addLists']=function(_0x4d14ae,_0x4ab386,_0x11175c){var _0x2af999,_0x124004;return db[_0x9edd('0x38')][_0x9edd('0x30')]({'where':{'id':_0x4d14ae[_0x9edd('0x5a')]['id']}})[_0x9edd('0x27')](handleEntityNotFound(_0x4ab386,null))[_0x9edd('0x27')](function(_0xefe1d2){if(_0xefe1d2){_0x124004=_0xefe1d2;return _0xefe1d2['addLists'](_0x4d14ae[_0x9edd('0x52')][_0x9edd('0x8f')],_['omit'](_0x4d14ae['body'],[_0x9edd('0x8f'),'id'])||{});}return null;})[_0x9edd('0x93')](function(_0x560050){var _0x17c5a6;_0x2af999=_0x560050||[];var _0x42c24c=[];if(_0x560050){for(var _0x9e245f=0x0;_0x9e245f<_0x560050[_0x9edd('0x43')];_0x9e245f+=0x1){var _0x4f292d=_0x560050[_0x9e245f][_0x9edd('0x29')]({'plain':!![]});_0x124004[_0x9edd('0x9d')]=_0x4d14ae[_0x9edd('0x52')]['dialCheckDuplicateType']?_0x4d14ae[_0x9edd('0x52')][_0x9edd('0x9d')]:_0x124004[_0x9edd('0x9d')];switch(_0x124004[_0x9edd('0x9d')]){case _0x9edd('0x9e'):_0x17c5a6=squel[_0x9edd('0x9f')]()[_0x9edd('0xa0')](_0x9edd('0xa1'))['fromQuery']([_0x9edd('0xa2'),_0x9edd('0xa3'),_0x9edd('0xa4'),_0x9edd('0xa5'),_0x9edd('0x64'),_0x9edd('0x5b'),_0x9edd('0x5c')],squel['select']()[_0x9edd('0x7e')]('phone','phone')[_0x9edd('0x7e')](_0x9edd('0xa6'),'scheduledAt')[_0x9edd('0x7e')]('id',_0x9edd('0xa4'))[_0x9edd('0x7e')](_0x4f292d['CmListId']['toString'](),_0x9edd('0xa5'))[_0x9edd('0x7e')](_0x4d14ae['params']['id']['toString'](),_0x9edd('0x64'))[_0x9edd('0x7e')](_0x9edd('0xa6'),_0x9edd('0x5b'))['field']('NOW()',_0x9edd('0x5c'))[_0x9edd('0xa7')]('cm_contacts')[_0x9edd('0x47')]('deletedAt\x20IS\x20NULL')[_0x9edd('0x47')](_0x9edd('0xa8'),_0x4f292d[_0x9edd('0xa9')][_0x9edd('0x87')]())['where'](_0x9edd('0xaa'))[_0x9edd('0x47')]('phone\x20NOT\x20IN\x20(?)',squel[_0x9edd('0x7d')]()['field'](_0x9edd('0xab'))[_0x9edd('0xa7')](_0x9edd('0xac'))[_0x9edd('0x47')](_0x9edd('0x84'),_0x4d14ae[_0x9edd('0x5a')]['id']['toString']()))[_0x9edd('0x47')](_0x9edd('0xad'),squel[_0x9edd('0x7d')]()[_0x9edd('0x7e')](_0x9edd('0xae'))[_0x9edd('0xa7')](_0x9edd('0xa1'))[_0x9edd('0x47')](_0x9edd('0x84'),_0x4d14ae[_0x9edd('0x5a')]['id']['toString']())))[_0x9edd('0x87')]();break;case _0x9edd('0xaf'):_0x17c5a6=squel[_0x9edd('0x9f')]()[_0x9edd('0xa0')](_0x9edd('0xa1'))[_0x9edd('0xb0')]([_0x9edd('0xa2'),_0x9edd('0xa3'),_0x9edd('0xa4'),_0x9edd('0xa5'),_0x9edd('0x64'),_0x9edd('0x5b'),_0x9edd('0x5c')],squel[_0x9edd('0x7d')]()[_0x9edd('0x7e')]('phone',_0x9edd('0xa2'))['field']('NOW()',_0x9edd('0xa3'))[_0x9edd('0x7e')]('id',_0x9edd('0xa4'))['field'](_0x4f292d[_0x9edd('0xa9')][_0x9edd('0x87')](),'ListId')['field'](_0x4d14ae[_0x9edd('0x5a')]['id'][_0x9edd('0x87')](),'VoiceQueueId')[_0x9edd('0x7e')](_0x9edd('0xa6'),'createdAt')[_0x9edd('0x7e')](_0x9edd('0xa6'),_0x9edd('0x5c'))[_0x9edd('0xa7')](_0x9edd('0xb1'))[_0x9edd('0x47')](_0x9edd('0xb2'))[_0x9edd('0x47')]('ListId\x20=\x20?',_0x4f292d[_0x9edd('0xa9')][_0x9edd('0x87')]())[_0x9edd('0x47')](_0x9edd('0xaa'))[_0x9edd('0x47')](_0x9edd('0xad'),squel['select']()[_0x9edd('0x7e')](_0x9edd('0xae'))[_0x9edd('0xa7')](_0x9edd('0xa1'))[_0x9edd('0x47')](_0x9edd('0x84'),_0x4d14ae[_0x9edd('0x5a')]['id']['toString']())))[_0x9edd('0x87')]();break;default:_0x17c5a6=squel[_0x9edd('0x9f')]()[_0x9edd('0xa0')]('cm_hopper')[_0x9edd('0xb0')]([_0x9edd('0xa2'),_0x9edd('0xa3'),_0x9edd('0xa4'),_0x9edd('0xa5'),'VoiceQueueId',_0x9edd('0x5b'),_0x9edd('0x5c')],squel[_0x9edd('0x7d')]()[_0x9edd('0x7e')](_0x9edd('0xa2'),'phone')['field']('NOW()',_0x9edd('0xa3'))[_0x9edd('0x7e')]('id',_0x9edd('0xa4'))[_0x9edd('0x7e')](_0x4f292d[_0x9edd('0xa9')]['toString'](),_0x9edd('0xa5'))[_0x9edd('0x7e')](_0x4d14ae[_0x9edd('0x5a')]['id'][_0x9edd('0x87')](),'VoiceQueueId')[_0x9edd('0x7e')](_0x9edd('0xa6'),'createdAt')[_0x9edd('0x7e')](_0x9edd('0xa6'),_0x9edd('0x5c'))[_0x9edd('0xa7')](_0x9edd('0xb1'))[_0x9edd('0x47')](_0x9edd('0xb2'))[_0x9edd('0x47')](_0x9edd('0xa8'),_0x4f292d[_0x9edd('0xa9')][_0x9edd('0x87')]())['where'](_0x9edd('0xaa')))[_0x9edd('0x87')]();}_0x42c24c['push'](db[_0x9edd('0x70')][_0x9edd('0x3e')](_0x17c5a6));}return BPromise[_0x9edd('0x97')](_0x42c24c);}})['then'](function(){return _0x2af999;})[_0x9edd('0x27')](respondWithResult(_0x4ab386,null))[_0x9edd('0x4f')](handleError(_0x4ab386,null));};exports[_0x9edd('0xb3')]=function(_0x341249,_0x492f78,_0x4e7274){return db['VoiceQueue'][_0x9edd('0x30')]({'where':{'id':_0x341249[_0x9edd('0x5a')]['id']}})[_0x9edd('0x27')](handleEntityNotFound(_0x492f78,null))[_0x9edd('0x27')](function(_0x331526){if(_0x331526){return _0x331526[_0x9edd('0xb3')](_0x341249[_0x9edd('0x3e')][_0x9edd('0x8f')]);}})['then'](function(_0xb1ce05){if(_0xb1ce05){return db[_0x9edd('0x62')]['destroy']({'where':{'ListId':_0x341249[_0x9edd('0x3e')][_0x9edd('0x8f')],'VoiceQueueId':_0x341249[_0x9edd('0x5a')]['id']}})['then'](function(){return _0xb1ce05;});}})[_0x9edd('0x27')](respondWithStatusCode(_0x492f78,null))[_0x9edd('0x4f')](handleError(_0x492f78,null));};exports[_0x9edd('0xb4')]=function(_0x423e1c,_0x4ab8d7,_0x1fc001){var _0x219d8b={};var _0x17b5b3={};var _0x196359;var _0x36faef;return db[_0x9edd('0x38')][_0x9edd('0x65')]({'where':{'id':_0x423e1c[_0x9edd('0x5a')]['id']}})[_0x9edd('0x27')](handleEntityNotFound(_0x4ab8d7,null))[_0x9edd('0x27')](function(_0x4ec4dc){if(_0x4ec4dc){_0x196359=_0x4ec4dc;_0x17b5b3[_0x9edd('0x3c')]=_[_0x9edd('0x3d')](db['CmList']['rawAttributes']);_0x17b5b3[_0x9edd('0x3e')]=_[_0x9edd('0x3d')](_0x423e1c[_0x9edd('0x3e')]);_0x17b5b3[_0x9edd('0x3f')]=_[_0x9edd('0x40')](_0x17b5b3[_0x9edd('0x3c')],_0x17b5b3['query']);_0x219d8b[_0x9edd('0x41')]=_[_0x9edd('0x40')](_0x17b5b3[_0x9edd('0x3c')],qs[_0x9edd('0x42')](_0x423e1c[_0x9edd('0x3e')]['fields']));_0x219d8b[_0x9edd('0x41')]=_0x219d8b[_0x9edd('0x41')][_0x9edd('0x43')]?_0x219d8b[_0x9edd('0x41')]:_0x17b5b3[_0x9edd('0x3c')];_0x219d8b['order']=qs['sort'](_0x423e1c[_0x9edd('0x3e')][_0x9edd('0x46')]);_0x219d8b[_0x9edd('0x47')]=qs[_0x9edd('0x3f')](_[_0x9edd('0x48')](_0x423e1c['query'],_0x17b5b3[_0x9edd('0x3f')]));if(_0x423e1c[_0x9edd('0x3e')][_0x9edd('0x2d')]){_0x219d8b[_0x9edd('0x47')]=_[_0x9edd('0x49')](_0x219d8b[_0x9edd('0x47')],{'$or':_[_0x9edd('0x37')](_0x219d8b['attributes'],function(_0x5e6f1e){var _0x228418={};_0x228418[_0x5e6f1e]={'$like':'%'+_0x423e1c['query']['filter']+'%'};return _0x228418;})});}_0x219d8b=_[_0x9edd('0x49')]({},_0x219d8b,_0x423e1c[_0x9edd('0x4a')]);return _0x196359['getBlackLists'](_0x219d8b);}})['then'](function(_0x3dab89){if(_0x3dab89){_0x36faef=_0x3dab89[_0x9edd('0x43')];if(!_0x423e1c[_0x9edd('0x3e')]['hasOwnProperty'](_0x9edd('0x44'))){_0x219d8b[_0x9edd('0x22')]=qs[_0x9edd('0x22')](_0x423e1c['query'][_0x9edd('0x22')]);_0x219d8b[_0x9edd('0x45')]=qs['offset'](_0x423e1c[_0x9edd('0x3e')][_0x9edd('0x45')]);}return _0x196359['getBlackLists'](_0x219d8b);}})[_0x9edd('0x27')](function(_0x182f1b){if(_0x182f1b){return _0x182f1b?{'count':_0x36faef,'rows':_0x182f1b}:null;}})[_0x9edd('0x27')](respondWithResult(_0x4ab8d7,null))[_0x9edd('0x4f')](handleError(_0x4ab8d7,null));};exports[_0x9edd('0xb5')]=function(_0x108bd5,_0x10b638,_0x39b3b6){var _0x592771,_0x4b33c0;return db['VoiceQueue'][_0x9edd('0x30')]({'where':{'id':_0x108bd5[_0x9edd('0x5a')]['id']}})['then'](handleEntityNotFound(_0x10b638,null))[_0x9edd('0x27')](function(_0x5c3283){if(_0x5c3283){_0x4b33c0=_0x5c3283;return _0x5c3283[_0x9edd('0xb5')](_0x108bd5['body'][_0x9edd('0x8f')],_['omit'](_0x108bd5[_0x9edd('0x52')],[_0x9edd('0x8f'),'id'])||{});}return null;})['spread'](function(_0x28e39c){var _0x53df3c;_0x592771=_0x28e39c||[];var _0x10041e=[];if(_0x28e39c){for(var _0x1fa94d=0x0;_0x1fa94d<_0x28e39c['length'];_0x1fa94d+=0x1){var _0x3b66f3=_0x28e39c[_0x1fa94d]['get']({'plain':!![]});_0x53df3c=squel[_0x9edd('0x9f')]()[_0x9edd('0xa0')](_0x9edd('0xb6'))[_0x9edd('0xb0')]([_0x9edd('0xa2'),_0x9edd('0xa4'),'ListId',_0x9edd('0x64'),_0x9edd('0x5b'),_0x9edd('0x5c')],squel[_0x9edd('0x7d')]()[_0x9edd('0x7e')](_0x9edd('0xa2'),'phone')[_0x9edd('0x7e')]('id',_0x9edd('0xa4'))[_0x9edd('0x7e')](_0x3b66f3[_0x9edd('0xa9')]['toString'](),_0x9edd('0xa5'))[_0x9edd('0x7e')](_0x108bd5['params']['id'][_0x9edd('0x87')](),_0x9edd('0x64'))[_0x9edd('0x7e')](_0x9edd('0xa6'),_0x9edd('0x5b'))['field'](_0x9edd('0xa6'),_0x9edd('0x5c'))[_0x9edd('0xa7')](_0x9edd('0xb1'))[_0x9edd('0x47')](_0x9edd('0xb2'))[_0x9edd('0x47')](_0x9edd('0xa8'),_0x3b66f3['CmListId'][_0x9edd('0x87')]())[_0x9edd('0x47')]('phone\x20IS\x20NOT\x20NULL'))[_0x9edd('0x87')]();_0x10041e[_0x9edd('0x86')](db[_0x9edd('0x70')][_0x9edd('0x3e')](_0x53df3c));}return BPromise[_0x9edd('0x97')](_0x10041e);}})[_0x9edd('0x27')](function(){return _0x592771;})[_0x9edd('0x27')](respondWithResult(_0x10b638,null))[_0x9edd('0x4f')](handleError(_0x10b638,null));};exports[_0x9edd('0xb7')]=function(_0x38c183,_0x3cf8ae,_0x11f5f2){return db['VoiceQueue'][_0x9edd('0x30')]({'where':{'id':_0x38c183[_0x9edd('0x5a')]['id']}})[_0x9edd('0x27')](handleEntityNotFound(_0x3cf8ae,null))[_0x9edd('0x27')](function(_0x181243){if(_0x181243){return _0x181243[_0x9edd('0xb7')](_0x38c183['query'][_0x9edd('0x8f')]);}})[_0x9edd('0x27')](function(_0x1e1ab6){if(_0x1e1ab6){return db[_0x9edd('0x67')][_0x9edd('0x28')]({'where':{'ListId':_0x38c183[_0x9edd('0x3e')][_0x9edd('0x8f')],'VoiceQueueId':_0x38c183[_0x9edd('0x5a')]['id']}})[_0x9edd('0x27')](function(){return _0x1e1ab6;});}})[_0x9edd('0x27')](respondWithStatusCode(_0x3cf8ae,null))['catch'](handleError(_0x3cf8ae,null));};
\ No newline at end of file
+var _0x00bb=['query','filters','intersection','attributes','fields','length','merge','options','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','VoiceQueues','QueueCampaigns','UserProfileSection','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','clone','omit','createdAt','updatedAt','role','getHoppers','hasOwnProperty','nolimit','sort','VoiceQueueId','CmHopper','includeAll','findAll','CmHopperHistory','order','pick','getHopperFinals','findOne','CmHopperFinal','CmHopperBlack','getTeams','Team','addTeams','online','voicePause','interface','Agents','forEach','penalty','sequelize','transaction','each','upsert','UserVoiceQueue','UserVoiceQueueRt','SIP/%s','emit','userVoiceQueue:save','ids','User','field','tq.TeamId','from','team_has_voice_queues','join','user_has_teams','ut.TeamId\x20=\x20tq.TeamId','VoiceQueueId\x20=\x20?','ut.UserId\x20=\x20?','toString','QueryTypes','every','all','union','compact','isEmpty','removeAgents','userVoiceQueue:remove','addAgents','spread','isNil','format','isArray','getAgents','getMembers','getLists','CmList','addLists','YYYY-MM-DD\x20HH:mm:ss','dialCheckDuplicateType','always','insert','into','cm_hopper','fromQuery','phone','ContactId','ListId','select','scheduledAt','CmListId','cm_contacts','deletedAt\x20IS\x20NULL','ListId\x20=\x20?','phone\x20IS\x20NOT\x20NULL','phone\x20NOT\x20IN\x20(?)','COALESCE(calleridnum,\x27\x27)','cm_hopper_final','onlyIfOpen','push','CmHopperId','OrderBy','ci.item','ci.OrderBy+1','cm_contact_has_items','h.ContactId=ci.CmContactId','h.scheduledat=?','PHONE','removeLists','getBlackLists','addBlackLists','cm_hopper_black','NOW()','removeBlackLists','moment','bluebird','util','squel','../../components/parsers/qs','../../config/logger','../../config/environment','../../mysqldb','localhost','socket.io-emitter','redis','./voiceQueue.socket','register','sendStatus','status','end','offset','undefined','limit','count','Content-Range','json','then','destroy','get','inbound','outbound','filter','ignore','value','includes','type','find','name','UserProfileResource','error','stack','send','index','map','rawAttributes','fieldName','key','getOptions','where','VoiceQueue','include','rows','catch','show','params','model','keys'];(function(_0x457b74,_0xecd07a){var _0x38e079=function(_0x405da9){while(--_0x405da9){_0x457b74['push'](_0x457b74['shift']());}};_0x38e079(++_0xecd07a);}(_0x00bb,0x1d8));var _0xb00b=function(_0x56482c,_0x16118d){_0x56482c=_0x56482c-0x0;var _0x5aae7a=_0x00bb[_0x56482c];return _0x5aae7a;};'use strict';var moment=require(_0xb00b('0x0'));var BPromise=require(_0xb00b('0x1'));var util=require(_0xb00b('0x2'));var _=require('lodash');var squel=require(_0xb00b('0x3'));var Redis=require('ioredis');var qs=require(_0xb00b('0x4'));var logger=require(_0xb00b('0x5'))('api');var config=require(_0xb00b('0x6'));var db=require(_0xb00b('0x7'))['db'];config['redis']=_['defaults'](config['redis'],{'host':_0xb00b('0x8'),'port':0x18eb});var socket=require(_0xb00b('0x9'))(new Redis(config[_0xb00b('0xa')]));require(_0xb00b('0xb'))[_0xb00b('0xc')](socket);function respondWithStatusCode(_0x3c36c5,_0x5b0c03){_0x5b0c03=_0x5b0c03||0xcc;return function(_0x51d12b){if(_0x51d12b){return _0x3c36c5[_0xb00b('0xd')](_0x5b0c03);}return _0x3c36c5[_0xb00b('0xe')](_0x5b0c03)[_0xb00b('0xf')]();};}function respondWithResult(_0x46a25c,_0x28d3cc){_0x28d3cc=_0x28d3cc||0xc8;return function(_0x48e125){if(_0x48e125){return _0x46a25c[_0xb00b('0xe')](_0x28d3cc)['json'](_0x48e125);}};}function respondWithFilteredResult(_0x5a4fea,_0x594075){return function(_0x4ff792){if(_0x4ff792){var _0x2d8ddf=typeof _0x594075[_0xb00b('0x10')]===_0xb00b('0x11')&&typeof _0x594075[_0xb00b('0x12')]===_0xb00b('0x11');var _0x4ada81=_0x4ff792[_0xb00b('0x13')];var _0xb0d42e=_0x2d8ddf?0x0:_0x594075['offset'];var _0x88d95e=_0x2d8ddf?_0x4ff792[_0xb00b('0x13')]:_0x594075['offset']+_0x594075['limit'];var _0x9b471e;if(_0x88d95e>=_0x4ada81){_0x88d95e=_0x4ada81;_0x9b471e=0xc8;}else{_0x9b471e=0xce;}_0x5a4fea['status'](_0x9b471e);return _0x5a4fea['set'](_0xb00b('0x14'),_0xb0d42e+'-'+_0x88d95e+'/'+_0x4ada81)[_0xb00b('0x15')](_0x4ff792);}return null;};}function saveUpdates(_0x387d97){return function(_0xbb72fc){if(_0xbb72fc){return _0xbb72fc['update'](_0x387d97)[_0xb00b('0x16')](function(_0x599347){return _0x599347;});}return null;};}function removeEntity(_0x415f91){return function(_0x5aa9a0){if(_0x5aa9a0){return _0x5aa9a0[_0xb00b('0x17')]()['then'](function(){var _0xb26ebb=_0x5aa9a0[_0xb00b('0x18')]({'plain':!![]});var _0x53ee68=[{'name':'VoiceQueues','value':_0xb00b('0x19'),'ignore':![]},{'name':'QueueCampaigns','value':_0xb00b('0x1a'),'ignore':![]}];var _0x43da66=_(_0x53ee68)[_0xb00b('0x1b')](_0xb00b('0x1c'))['map'](_0xb00b('0x1d'))['value']();if(_[_0xb00b('0x1e')](_0x43da66,_0xb26ebb[_0xb00b('0x1f')])){return;}var _0x51b841=_[_0xb00b('0x20')](_0x53ee68,[_0xb00b('0x1d'),_0xb26ebb['type']])[_0xb00b('0x21')];return db[_0xb00b('0x22')]['destroy']({'where':{'type':_0x51b841,'resourceId':_0xb26ebb['id']}})[_0xb00b('0x16')](function(){return _0x5aa9a0;});})[_0xb00b('0x16')](function(){_0x415f91[_0xb00b('0xe')](0xcc)[_0xb00b('0xf')]();});}};}function handleEntityNotFound(_0x520e55){return function(_0x50be6c){if(!_0x50be6c){_0x520e55[_0xb00b('0xd')](0x194);}return _0x50be6c;};}function handleError(_0x490380,_0x550587){_0x550587=_0x550587||0x1f4;return function(_0x4a635e){logger[_0xb00b('0x23')](_0x4a635e[_0xb00b('0x24')]);if(_0x4a635e[_0xb00b('0x21')]){delete _0x4a635e[_0xb00b('0x21')];}_0x490380[_0xb00b('0xe')](_0x550587)[_0xb00b('0x25')](_0x4a635e);};}exports[_0xb00b('0x26')]=function(_0x4a8d2b,_0x22c22d){var _0x503c9c={};var _0x450129={'count':0x0,'rows':[]};var _0x348165=_[_0xb00b('0x27')](db['VoiceQueue'][_0xb00b('0x28')],function(_0x280ed3){return{'name':_0x280ed3[_0xb00b('0x29')],'type':_0x280ed3[_0xb00b('0x1f')][_0xb00b('0x2a')]};});_0x503c9c=qs[_0xb00b('0x2b')](_0x348165,_0x4a8d2b);var _0x2e160a={'where':_0x503c9c[_0xb00b('0x2c')]};return db[_0xb00b('0x2d')]['count'](_0x2e160a)[_0xb00b('0x16')](function(_0x44918d){_0x450129['count']=_0x44918d;_0x503c9c[_0xb00b('0x2e')]=qs[_0xb00b('0x2e')](_0x4a8d2b['query']);return db[_0xb00b('0x2d')]['findAll'](_0x503c9c);})[_0xb00b('0x16')](function(_0x4117f2){_0x450129[_0xb00b('0x2f')]=_0x4117f2;return _0x450129;})[_0xb00b('0x16')](respondWithFilteredResult(_0x22c22d,_0x503c9c))[_0xb00b('0x30')](handleError(_0x22c22d,null));};exports[_0xb00b('0x31')]=function(_0x17f613,_0x594840){var _0x57e8f9={'raw':![],'where':{'id':_0x17f613[_0xb00b('0x32')]['id']}},_0x5b04c2={};_0x5b04c2[_0xb00b('0x33')]=_[_0xb00b('0x34')](db[_0xb00b('0x2d')]['rawAttributes']);_0x5b04c2[_0xb00b('0x35')]=_[_0xb00b('0x34')](_0x17f613[_0xb00b('0x35')]);_0x5b04c2[_0xb00b('0x36')]=_[_0xb00b('0x37')](_0x5b04c2[_0xb00b('0x33')],_0x5b04c2[_0xb00b('0x35')]);_0x57e8f9[_0xb00b('0x38')]=_['intersection'](_0x5b04c2['model'],qs[_0xb00b('0x39')](_0x17f613['query'][_0xb00b('0x39')]));_0x57e8f9[_0xb00b('0x38')]=_0x57e8f9[_0xb00b('0x38')][_0xb00b('0x3a')]?_0x57e8f9[_0xb00b('0x38')]:_0x5b04c2[_0xb00b('0x33')];if(_0x17f613[_0xb00b('0x35')]['includeAll']){_0x57e8f9[_0xb00b('0x2e')]=[{'all':!![]}];}_0x57e8f9=_[_0xb00b('0x3b')]({},_0x57e8f9,_0x17f613[_0xb00b('0x3c')]);return db[_0xb00b('0x2d')][_0xb00b('0x20')](_0x57e8f9)[_0xb00b('0x16')](handleEntityNotFound(_0x594840,null))['then'](respondWithResult(_0x594840,null))[_0xb00b('0x30')](handleError(_0x594840,null));};exports[_0xb00b('0x3d')]=function(_0x4801e7,_0x17ff34){return db[_0xb00b('0x2d')][_0xb00b('0x3d')](_0x4801e7[_0xb00b('0x3e')],{})[_0xb00b('0x16')](function(_0x5636b1){var _0x14ff6a=_0x4801e7[_0xb00b('0x3f')][_0xb00b('0x18')]({'plain':!![]});if(!_0x14ff6a)throw new Error(_0xb00b('0x40'));if(_0x14ff6a['role']==='user'){var _0x43f834=_0x5636b1[_0xb00b('0x18')]({'plain':!![]});var _0x10a348=[{'name':_0xb00b('0x41'),'value':_0xb00b('0x19')},{'name':_0xb00b('0x42'),'value':_0xb00b('0x1a')}];var _0x493841=_[_0xb00b('0x20')](_0x10a348,[_0xb00b('0x1d'),_0x43f834[_0xb00b('0x1f')]])[_0xb00b('0x21')];return db[_0xb00b('0x43')][_0xb00b('0x20')]({'where':{'name':_0x493841,'userProfileId':_0x14ff6a[_0xb00b('0x44')]},'raw':!![]})[_0xb00b('0x16')](function(_0x2d58e2){if(_0x2d58e2&&_0x2d58e2[_0xb00b('0x45')]===0x0){return db[_0xb00b('0x22')][_0xb00b('0x3d')]({'name':_0x43f834['name'],'resourceId':_0x43f834['id'],'type':_0x2d58e2[_0xb00b('0x21')],'sectionId':_0x2d58e2['id']},{})[_0xb00b('0x16')](function(){return _0x5636b1;});}else{return _0x5636b1;}})[_0xb00b('0x30')](function(_0x44afa0){logger[_0xb00b('0x23')](_0xb00b('0x46'),_0x44afa0);throw _0x44afa0;});}return _0x5636b1;})[_0xb00b('0x16')](respondWithResult(_0x17ff34,0xc9))[_0xb00b('0x30')](handleError(_0x17ff34,null));};exports[_0xb00b('0x47')]=function(_0x103320,_0x1eec12){var _0x3b3031={'where':{'id':_0x103320['params']['id']}},_0x5dbe00={};_0x5dbe00['model']=_[_0xb00b('0x34')](db[_0xb00b('0x2d')]['rawAttributes']);_0x3b3031[_0xb00b('0x38')]=_[_0xb00b('0x37')](_0x5dbe00[_0xb00b('0x33')],qs[_0xb00b('0x39')](_0x103320['query']['fields']));_0x3b3031[_0xb00b('0x38')]=_0x3b3031[_0xb00b('0x38')]['length']?_0x3b3031['attributes']:_0x5dbe00[_0xb00b('0x33')];if(_0x103320[_0xb00b('0x35')]['includeAll']){_0x3b3031[_0xb00b('0x2e')]=[{'all':!![]}];}_0x3b3031=_['merge']({},_0x3b3031,_0x103320['options']);return db['VoiceQueue'][_0xb00b('0x20')](_0x3b3031)['then'](handleEntityNotFound(_0x1eec12,null))[_0xb00b('0x16')](function(_0x3178aa){if(_0x3178aa){var _0x4b6482=_0x3178aa[_0xb00b('0x18')]({'plain':!![]});_0x4b6482=qs[_0xb00b('0x48')](_0x4b6482,['id',_0xb00b('0x49'),'updatedAt']);_0x103320['body']=_[_0xb00b('0x48')](_0x103320[_0xb00b('0x3e')],['id','createdAt',_0xb00b('0x4a')]);return db[_0xb00b('0x2d')]['create'](_[_0xb00b('0x3b')](_0x4b6482,_0x103320[_0xb00b('0x3e')]),{'include':_0x103320[_0xb00b('0x35')]['includeAll']?[{'all':!![]}]:undefined})['then'](function(_0x19f907){var _0x398deb=_0x103320[_0xb00b('0x3f')][_0xb00b('0x18')]({'plain':!![]});if(!_0x398deb)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x398deb[_0xb00b('0x4b')]===_0xb00b('0x3f')){var _0x4ad9cb=_0x19f907['get']({'plain':!![]});var _0x160965=[{'name':'VoiceQueues','value':_0xb00b('0x19')},{'name':_0xb00b('0x42'),'value':_0xb00b('0x1a')}];var _0x222459=_[_0xb00b('0x20')](_0x160965,[_0xb00b('0x1d'),_0x4ad9cb['type']])[_0xb00b('0x21')];return db['UserProfileSection'][_0xb00b('0x20')]({'where':{'name':_0x222459,'userProfileId':_0x398deb[_0xb00b('0x44')]},'raw':!![]})[_0xb00b('0x16')](function(_0x5ac79e){if(_0x5ac79e&&_0x5ac79e[_0xb00b('0x45')]===0x0){return db[_0xb00b('0x22')][_0xb00b('0x3d')]({'name':_0x4ad9cb['name'],'resourceId':_0x4ad9cb['id'],'type':_0x5ac79e[_0xb00b('0x21')],'sectionId':_0x5ac79e['id']},{})[_0xb00b('0x16')](function(){return _0x19f907;});}else{return _0x19f907;}})[_0xb00b('0x30')](function(_0x385029){logger[_0xb00b('0x23')](_0xb00b('0x46'),_0x385029);throw _0x385029;});}return _0x19f907;});}})[_0xb00b('0x16')](respondWithResult(_0x1eec12,0xc9))[_0xb00b('0x30')](handleError(_0x1eec12,null));};exports['update']=function(_0x153551,_0x2cbe80){if(_0x153551[_0xb00b('0x3e')]['id']){delete _0x153551['body']['id'];}return db[_0xb00b('0x2d')][_0xb00b('0x20')]({'where':{'id':_0x153551[_0xb00b('0x32')]['id']}})[_0xb00b('0x16')](handleEntityNotFound(_0x2cbe80,null))[_0xb00b('0x16')](saveUpdates(_0x153551['body'],null))[_0xb00b('0x16')](respondWithResult(_0x2cbe80,null))[_0xb00b('0x30')](handleError(_0x2cbe80,null));};exports[_0xb00b('0x17')]=function(_0x1cad79,_0x4b1e5f){return db[_0xb00b('0x2d')][_0xb00b('0x20')]({'where':{'id':_0x1cad79[_0xb00b('0x32')]['id']}})[_0xb00b('0x16')](handleEntityNotFound(_0x4b1e5f,null))[_0xb00b('0x16')](removeEntity(_0x4b1e5f,null))[_0xb00b('0x30')](handleError(_0x4b1e5f,null));};exports[_0xb00b('0x4c')]=function(_0x542223,_0x2b090a){var _0x502822={'raw':![],'where':{}};var _0x3e0648={};var _0x4c2186={'count':0x0,'rows':[]};return db[_0xb00b('0x2d')]['findOne']({'where':{'id':_0x542223[_0xb00b('0x32')]['id']}})['then'](handleEntityNotFound(_0x2b090a,null))[_0xb00b('0x16')](function(_0x2534ed){if(_0x2534ed){_0x3e0648[_0xb00b('0x33')]=_['keys'](db['CmHopper']['rawAttributes']);_0x3e0648[_0xb00b('0x35')]=_[_0xb00b('0x34')](_0x542223[_0xb00b('0x35')]);_0x3e0648['filters']=_[_0xb00b('0x37')](_0x3e0648[_0xb00b('0x33')],_0x3e0648[_0xb00b('0x35')]);_0x502822[_0xb00b('0x38')]=_[_0xb00b('0x37')](_0x3e0648['model'],qs[_0xb00b('0x39')](_0x542223[_0xb00b('0x35')]['fields']));_0x502822[_0xb00b('0x38')]=_0x502822[_0xb00b('0x38')][_0xb00b('0x3a')]?_0x502822['attributes']:_0x3e0648['model'];if(!_0x542223[_0xb00b('0x35')][_0xb00b('0x4d')](_0xb00b('0x4e'))){_0x502822['limit']=qs['limit'](_0x542223['query']['limit']);_0x502822[_0xb00b('0x10')]=qs['offset'](_0x542223[_0xb00b('0x35')][_0xb00b('0x10')]);}_0x502822['order']=qs[_0xb00b('0x4f')](_0x542223[_0xb00b('0x35')][_0xb00b('0x4f')]);_0x502822[_0xb00b('0x2c')]=qs[_0xb00b('0x36')](_['pick'](_0x542223[_0xb00b('0x35')],_0x3e0648[_0xb00b('0x36')]));_0x502822[_0xb00b('0x2c')][_0xb00b('0x50')]=_0x2534ed['id'];if(_0x542223[_0xb00b('0x35')][_0xb00b('0x1b')]){_0x502822[_0xb00b('0x2c')]=_['merge'](_0x502822[_0xb00b('0x2c')],{'$or':_[_0xb00b('0x27')](_0x502822[_0xb00b('0x38')],function(_0x328f72){var _0x109f56={};_0x109f56[_0x328f72]={'$like':'%'+_0x542223[_0xb00b('0x35')][_0xb00b('0x1b')]+'%'};return _0x109f56;})});}_0x502822=_[_0xb00b('0x3b')]({},_0x502822,_0x542223['options']);return db[_0xb00b('0x51')][_0xb00b('0x13')]({'where':_0x502822[_0xb00b('0x2c')]})[_0xb00b('0x16')](function(_0x3d6b33){_0x4c2186[_0xb00b('0x13')]=_0x3d6b33;if(_0x542223[_0xb00b('0x35')][_0xb00b('0x52')]){_0x502822['include']=[{'all':!![]}];}return db[_0xb00b('0x51')][_0xb00b('0x53')](_0x502822);})[_0xb00b('0x16')](function(_0x26b82a){_0x4c2186[_0xb00b('0x2f')]=_0x26b82a;return _0x4c2186;});}})[_0xb00b('0x16')](respondWithFilteredResult(_0x2b090a,_0x502822))[_0xb00b('0x30')](handleError(_0x2b090a,null));};exports['getHopperHistories']=function(_0x207bda,_0x37a4c0){var _0x28ecf8={'raw':!![],'where':{}};var _0x22b19c={};var _0x16e8ff={'count':0x0,'rows':[]};return db[_0xb00b('0x2d')]['findOne']({'where':{'id':_0x207bda[_0xb00b('0x32')]['id']}})['then'](handleEntityNotFound(_0x37a4c0,null))[_0xb00b('0x16')](function(_0x50922f){if(_0x50922f){_0x22b19c[_0xb00b('0x33')]=_[_0xb00b('0x34')](db[_0xb00b('0x54')]['rawAttributes']);_0x22b19c['query']=_[_0xb00b('0x34')](_0x207bda[_0xb00b('0x35')]);_0x22b19c[_0xb00b('0x36')]=_[_0xb00b('0x37')](_0x22b19c[_0xb00b('0x33')],_0x22b19c[_0xb00b('0x35')]);_0x28ecf8[_0xb00b('0x38')]=_[_0xb00b('0x37')](_0x22b19c[_0xb00b('0x33')],qs[_0xb00b('0x39')](_0x207bda[_0xb00b('0x35')][_0xb00b('0x39')]));_0x28ecf8[_0xb00b('0x38')]=_0x28ecf8[_0xb00b('0x38')]['length']?_0x28ecf8['attributes']:_0x22b19c[_0xb00b('0x33')];if(!_0x207bda[_0xb00b('0x35')]['hasOwnProperty']('nolimit')){_0x28ecf8[_0xb00b('0x12')]=qs[_0xb00b('0x12')](_0x207bda[_0xb00b('0x35')]['limit']);_0x28ecf8[_0xb00b('0x10')]=qs[_0xb00b('0x10')](_0x207bda[_0xb00b('0x35')][_0xb00b('0x10')]);}_0x28ecf8[_0xb00b('0x55')]=qs[_0xb00b('0x4f')](_0x207bda[_0xb00b('0x35')]['sort']);_0x28ecf8[_0xb00b('0x2c')]=qs['filters'](_[_0xb00b('0x56')](_0x207bda[_0xb00b('0x35')],_0x22b19c['filters']));_0x28ecf8[_0xb00b('0x2c')][_0xb00b('0x50')]=_0x50922f['id'];if(_0x207bda[_0xb00b('0x35')][_0xb00b('0x1b')]){_0x28ecf8[_0xb00b('0x2c')]=_[_0xb00b('0x3b')](_0x28ecf8[_0xb00b('0x2c')],{'$or':_[_0xb00b('0x27')](_0x28ecf8[_0xb00b('0x38')],function(_0x383d16){var _0x2ec3f2={};_0x2ec3f2[_0x383d16]={'$like':'%'+_0x207bda[_0xb00b('0x35')]['filter']+'%'};return _0x2ec3f2;})});}_0x28ecf8=_[_0xb00b('0x3b')]({},_0x28ecf8,_0x207bda[_0xb00b('0x3c')]);return db[_0xb00b('0x54')][_0xb00b('0x13')]({'where':_0x28ecf8['where']})[_0xb00b('0x16')](function(_0x17503d){_0x16e8ff[_0xb00b('0x13')]=_0x17503d;if(_0x207bda[_0xb00b('0x35')][_0xb00b('0x52')]){_0x28ecf8['include']=[{'all':!![]}];}return db[_0xb00b('0x54')][_0xb00b('0x53')](_0x28ecf8);})[_0xb00b('0x16')](function(_0x2b66b7){_0x16e8ff['rows']=_0x2b66b7;return _0x16e8ff;});}})[_0xb00b('0x16')](respondWithFilteredResult(_0x37a4c0,_0x28ecf8))['catch'](handleError(_0x37a4c0,null));};exports[_0xb00b('0x57')]=function(_0x202d5f,_0x69b4e0){var _0x165442={'raw':!![],'where':{}};var _0x188349={};var _0x27e051={'count':0x0,'rows':[]};return db[_0xb00b('0x2d')][_0xb00b('0x58')]({'where':{'id':_0x202d5f[_0xb00b('0x32')]['id']}})[_0xb00b('0x16')](handleEntityNotFound(_0x69b4e0,null))[_0xb00b('0x16')](function(_0x551a55){if(_0x551a55){_0x188349[_0xb00b('0x33')]=_[_0xb00b('0x34')](db[_0xb00b('0x59')][_0xb00b('0x28')]);_0x188349['query']=_[_0xb00b('0x34')](_0x202d5f[_0xb00b('0x35')]);_0x188349['filters']=_[_0xb00b('0x37')](_0x188349['model'],_0x188349[_0xb00b('0x35')]);_0x165442[_0xb00b('0x38')]=_[_0xb00b('0x37')](_0x188349['model'],qs[_0xb00b('0x39')](_0x202d5f[_0xb00b('0x35')][_0xb00b('0x39')]));_0x165442[_0xb00b('0x38')]=_0x165442[_0xb00b('0x38')][_0xb00b('0x3a')]?_0x165442[_0xb00b('0x38')]:_0x188349[_0xb00b('0x33')];if(!_0x202d5f[_0xb00b('0x35')]['hasOwnProperty']('nolimit')){_0x165442[_0xb00b('0x12')]=qs[_0xb00b('0x12')](_0x202d5f[_0xb00b('0x35')][_0xb00b('0x12')]);_0x165442['offset']=qs[_0xb00b('0x10')](_0x202d5f[_0xb00b('0x35')]['offset']);}_0x165442[_0xb00b('0x55')]=qs[_0xb00b('0x4f')](_0x202d5f[_0xb00b('0x35')]['sort']);_0x165442[_0xb00b('0x2c')]=qs[_0xb00b('0x36')](_['pick'](_0x202d5f[_0xb00b('0x35')],_0x188349[_0xb00b('0x36')]));_0x165442[_0xb00b('0x2c')][_0xb00b('0x50')]=_0x551a55['id'];if(_0x202d5f[_0xb00b('0x35')][_0xb00b('0x1b')]){_0x165442[_0xb00b('0x2c')]=_[_0xb00b('0x3b')](_0x165442['where'],{'$or':_[_0xb00b('0x27')](_0x165442[_0xb00b('0x38')],function(_0x320542){var _0x29d101={};_0x29d101[_0x320542]={'$like':'%'+_0x202d5f['query'][_0xb00b('0x1b')]+'%'};return _0x29d101;})});}_0x165442=_['merge']({},_0x165442,_0x202d5f[_0xb00b('0x3c')]);return db['CmHopperFinal'][_0xb00b('0x13')]({'where':_0x165442[_0xb00b('0x2c')]})[_0xb00b('0x16')](function(_0x3e0e49){_0x27e051[_0xb00b('0x13')]=_0x3e0e49;if(_0x202d5f['query'][_0xb00b('0x52')]){_0x165442[_0xb00b('0x2e')]=[{'all':!![]}];}return db['CmHopperFinal'][_0xb00b('0x53')](_0x165442);})['then'](function(_0x20a690){_0x27e051[_0xb00b('0x2f')]=_0x20a690;return _0x27e051;});}})[_0xb00b('0x16')](respondWithFilteredResult(_0x69b4e0,_0x165442))[_0xb00b('0x30')](handleError(_0x69b4e0,null));};exports['getHopperBlacks']=function(_0x3ae4a4,_0x76b483){var _0x190019={'raw':!![],'where':{}};var _0x44ea58={};var _0x11172e={'count':0x0,'rows':[]};return db['VoiceQueue']['findOne']({'where':{'id':_0x3ae4a4[_0xb00b('0x32')]['id']}})[_0xb00b('0x16')](handleEntityNotFound(_0x76b483,null))[_0xb00b('0x16')](function(_0x2d5652){if(_0x2d5652){_0x44ea58[_0xb00b('0x33')]=_['keys'](db['CmHopperBlack'][_0xb00b('0x28')]);_0x44ea58[_0xb00b('0x35')]=_[_0xb00b('0x34')](_0x3ae4a4[_0xb00b('0x35')]);_0x44ea58[_0xb00b('0x36')]=_[_0xb00b('0x37')](_0x44ea58[_0xb00b('0x33')],_0x44ea58['query']);_0x190019[_0xb00b('0x38')]=_['intersection'](_0x44ea58[_0xb00b('0x33')],qs['fields'](_0x3ae4a4[_0xb00b('0x35')][_0xb00b('0x39')]));_0x190019[_0xb00b('0x38')]=_0x190019[_0xb00b('0x38')][_0xb00b('0x3a')]?_0x190019[_0xb00b('0x38')]:_0x44ea58[_0xb00b('0x33')];if(!_0x3ae4a4[_0xb00b('0x35')][_0xb00b('0x4d')](_0xb00b('0x4e'))){_0x190019[_0xb00b('0x12')]=qs['limit'](_0x3ae4a4[_0xb00b('0x35')][_0xb00b('0x12')]);_0x190019[_0xb00b('0x10')]=qs[_0xb00b('0x10')](_0x3ae4a4['query'][_0xb00b('0x10')]);}_0x190019[_0xb00b('0x55')]=qs['sort'](_0x3ae4a4[_0xb00b('0x35')]['sort']);_0x190019[_0xb00b('0x2c')]=qs[_0xb00b('0x36')](_['pick'](_0x3ae4a4[_0xb00b('0x35')],_0x44ea58[_0xb00b('0x36')]));_0x190019[_0xb00b('0x2c')][_0xb00b('0x50')]=_0x2d5652['id'];if(_0x3ae4a4[_0xb00b('0x35')][_0xb00b('0x1b')]){_0x190019['where']=_[_0xb00b('0x3b')](_0x190019['where'],{'$or':_[_0xb00b('0x27')](_0x190019[_0xb00b('0x38')],function(_0x140bfd){var _0x43fbc5={};_0x43fbc5[_0x140bfd]={'$like':'%'+_0x3ae4a4['query'][_0xb00b('0x1b')]+'%'};return _0x43fbc5;})});}_0x190019=_[_0xb00b('0x3b')]({},_0x190019,_0x3ae4a4[_0xb00b('0x3c')]);return db['CmHopperBlack'][_0xb00b('0x13')]({'where':_0x190019[_0xb00b('0x2c')]})[_0xb00b('0x16')](function(_0xcc2183){_0x11172e['count']=_0xcc2183;if(_0x3ae4a4[_0xb00b('0x35')][_0xb00b('0x52')]){_0x190019[_0xb00b('0x2e')]=[{'all':!![]}];}return db[_0xb00b('0x5a')][_0xb00b('0x53')](_0x190019);})[_0xb00b('0x16')](function(_0x568c0a){_0x11172e['rows']=_0x568c0a;return _0x11172e;});}})[_0xb00b('0x16')](respondWithFilteredResult(_0x76b483,_0x190019))[_0xb00b('0x30')](handleError(_0x76b483,null));};exports[_0xb00b('0x5b')]=function(_0x2ec514,_0x3de4f6){var _0x5f0fd8={};var _0x3d80e7={};var _0xbe553c;var _0x14597c;return db[_0xb00b('0x2d')][_0xb00b('0x58')]({'where':{'id':_0x2ec514[_0xb00b('0x32')]['id']}})['then'](handleEntityNotFound(_0x3de4f6,null))[_0xb00b('0x16')](function(_0x2414bd){if(_0x2414bd){_0xbe553c=_0x2414bd;_0x3d80e7[_0xb00b('0x33')]=_[_0xb00b('0x34')](db[_0xb00b('0x5c')][_0xb00b('0x28')]);_0x3d80e7[_0xb00b('0x35')]=_[_0xb00b('0x34')](_0x2ec514[_0xb00b('0x35')]);_0x3d80e7[_0xb00b('0x36')]=_['intersection'](_0x3d80e7['model'],_0x3d80e7[_0xb00b('0x35')]);_0x5f0fd8[_0xb00b('0x38')]=_[_0xb00b('0x37')](_0x3d80e7['model'],qs['fields'](_0x2ec514['query'][_0xb00b('0x39')]));_0x5f0fd8[_0xb00b('0x38')]=_0x5f0fd8[_0xb00b('0x38')]['length']?_0x5f0fd8[_0xb00b('0x38')]:_0x3d80e7[_0xb00b('0x33')];_0x5f0fd8[_0xb00b('0x55')]=qs[_0xb00b('0x4f')](_0x2ec514['query'][_0xb00b('0x4f')]);_0x5f0fd8[_0xb00b('0x2c')]=qs[_0xb00b('0x36')](_[_0xb00b('0x56')](_0x2ec514[_0xb00b('0x35')],_0x3d80e7[_0xb00b('0x36')]));if(_0x2ec514[_0xb00b('0x35')][_0xb00b('0x1b')]){_0x5f0fd8['where']=_[_0xb00b('0x3b')](_0x5f0fd8[_0xb00b('0x2c')],{'$or':_[_0xb00b('0x27')](_0x5f0fd8[_0xb00b('0x38')],function(_0xf9c361){var _0x24c646={};_0x24c646[_0xf9c361]={'$like':'%'+_0x2ec514[_0xb00b('0x35')][_0xb00b('0x1b')]+'%'};return _0x24c646;})});}_0x5f0fd8=_['merge']({},_0x5f0fd8,_0x2ec514[_0xb00b('0x3c')]);return _0xbe553c[_0xb00b('0x5b')](_0x5f0fd8);}})[_0xb00b('0x16')](function(_0x122522){if(_0x122522){_0x14597c=_0x122522['length'];if(!_0x2ec514[_0xb00b('0x35')][_0xb00b('0x4d')](_0xb00b('0x4e'))){_0x5f0fd8[_0xb00b('0x12')]=qs[_0xb00b('0x12')](_0x2ec514[_0xb00b('0x35')][_0xb00b('0x12')]);_0x5f0fd8[_0xb00b('0x10')]=qs['offset'](_0x2ec514['query'][_0xb00b('0x10')]);}return _0xbe553c[_0xb00b('0x5b')](_0x5f0fd8);}})[_0xb00b('0x16')](function(_0x58894a){if(_0x58894a){return _0x58894a?{'count':_0x14597c,'rows':_0x58894a}:null;}})[_0xb00b('0x16')](respondWithResult(_0x3de4f6,null))[_0xb00b('0x30')](handleError(_0x3de4f6,null));};exports[_0xb00b('0x5d')]=function(_0x581548,_0x44d3c0){var _0x3d5880=_0x581548[_0xb00b('0x3e')]['teams'];var _0x58808e=_[_0xb00b('0x27')](_0x3d5880,'id');return db['Team'][_0xb00b('0x53')]({'where':{'id':_0x58808e},'attributes':['id'],'include':[{'model':db['User'],'as':'Agents','attributes':['id',_0xb00b('0x21'),_0xb00b('0x5e'),_0xb00b('0x5f'),_0xb00b('0x60')],'raw':!![]}]})[_0xb00b('0x16')](function(_0x5c5a04){if(_0x5c5a04){var _0x1aa5e5=_['flatMap'](_0x5c5a04,function(_0x592206){var _0x3551ca=_0x592206[_0xb00b('0x18')]({'plain':!![]});_0x3551ca[_0xb00b('0x61')][_0xb00b('0x62')](function(_0x8b31d3){_0x8b31d3[_0xb00b('0x63')]=_['find'](_0x3d5880,{'id':_0x3551ca['id']})[_0xb00b('0x63')];});return _0x3551ca['Agents'];});return db[_0xb00b('0x2d')][_0xb00b('0x20')]({'where':{'id':_0x581548[_0xb00b('0x32')]['id']}})['then'](function(_0x226527){return db[_0xb00b('0x64')][_0xb00b('0x65')](function(_0x3dc8d2){return _0x226527['addTeams'](_0x58808e,{'transaction':_0x3dc8d2})['then'](function(){return BPromise[_0xb00b('0x66')](_0x3d5880,function(_0x55bb31){return db['TeamVoiceQueue'][_0xb00b('0x67')]({'TeamId':_0x55bb31['id'],'VoiceQueueId':_0x581548['params']['id'],'penalty':_0x55bb31['penalty']},{'transaction':_0x3dc8d2});});})[_0xb00b('0x16')](function(){return BPromise[_0xb00b('0x66')](_0x1aa5e5,function(_0x745803){return db[_0xb00b('0x68')]['findOrCreate']({'where':{'UserId':_0x745803['id'],'VoiceQueueId':_0x581548['params']['id']},'defaults':{'penalty':_0x745803[_0xb00b('0x63')]},'transaction':_0x3dc8d2});});})[_0xb00b('0x16')](function(){return BPromise[_0xb00b('0x66')](_['filter'](_0x1aa5e5,{'online':!![]}),function(_0x48bac5){return db[_0xb00b('0x69')]['upsert']({'membername':_0x48bac5['name'],'UserId':_0x48bac5['id'],'queue_name':_0x226527[_0xb00b('0x21')],'VoiceQueueId':_0x226527['id'],'interface':_['isNil'](_0x48bac5[_0xb00b('0x60')])?util['format'](_0xb00b('0x6a'),_0x48bac5['name']):_0x48bac5[_0xb00b('0x60')],'paused':_0x48bac5[_0xb00b('0x5f')]||![],'penalty':_0x48bac5[_0xb00b('0x63')]},{'transaction':_0x3dc8d2});});})['then'](function(){_0x1aa5e5[_0xb00b('0x62')](function(_0x596092){socket[_0xb00b('0x6b')](_0xb00b('0x6c'),{'UserId':_0x596092['id'],'VoiceQueueId':_0x226527['id']});});});});});}})['then'](respondWithStatusCode(_0x44d3c0,null))['catch'](handleError(_0x44d3c0,null));};exports['removeTeams']=function(_0x552f73,_0x192b43){return db['Team'][_0xb00b('0x53')]({'where':{'id':_0x552f73['query'][_0xb00b('0x6d')]},'attributes':['id'],'include':[{'model':db[_0xb00b('0x6e')],'as':_0xb00b('0x61'),'attributes':['id'],'raw':!![]}]})[_0xb00b('0x16')](handleEntityNotFound(_0x192b43,null))[_0xb00b('0x16')](function(_0x5b1576){var _0x8292fe=_[_0xb00b('0x27')](_0x5b1576,'id');var _0x3c1cc5=[];var _0x38e425=[];var _0x515143=squel['select']();_0x515143[_0xb00b('0x6f')](_0xb00b('0x70'))[_0xb00b('0x71')](_0xb00b('0x72'),'tq')[_0xb00b('0x73')](_0xb00b('0x74'),'ut',_0xb00b('0x75'))[_0xb00b('0x2c')](_0xb00b('0x76'),_0x552f73['params']['id']);for(var _0x45bae8=0x0;_0x45bae8<_0x5b1576[_0xb00b('0x3a')];_0x45bae8+=0x1){let _0x496500=_0x5b1576[_0x45bae8];for(var _0x475ebb=0x0;_0x475ebb<_0x496500['Agents'][_0xb00b('0x3a')];_0x475ebb+=0x1){let _0x13054a=_0x496500['Agents'][_0x475ebb];var _0x4ce456=_0x515143[_0xb00b('0x47')]();_0x4ce456[_0xb00b('0x2c')](_0xb00b('0x77'),_0x13054a['id']);_0x38e425['push'](db[_0xb00b('0x64')][_0xb00b('0x35')](_0x4ce456[_0xb00b('0x78')](),{'type':db['sequelize'][_0xb00b('0x79')]['SELECT']})['then'](function(_0x58ea43){if(_0x58ea43[_0xb00b('0x3a')]===0x1){return _0x13054a['id'];}else{var _0x4d42af=_[_0xb00b('0x7a')](_[_0xb00b('0x27')](_0x58ea43,'TeamId'),function(_0x4c389f){return _[_0xb00b('0x1e')](_0x8292fe,_0x4c389f);});if(_0x4d42af){return _0x13054a['id'];}}}));}}return BPromise[_0xb00b('0x7b')](_0x38e425)['then'](function(_0x2f131e){_0x3c1cc5=_(_0x3c1cc5)[_0xb00b('0x7c')](_0x2f131e)[_0xb00b('0x7d')]()[_0xb00b('0x1d')]();return db[_0xb00b('0x2d')][_0xb00b('0x20')]({'where':{'id':_0x552f73['params']['id']}})[_0xb00b('0x16')](function(_0x22b425){return db['sequelize'][_0xb00b('0x65')](function(_0x4ed3c7){return _0x22b425['removeTeams'](_0x552f73[_0xb00b('0x35')]['ids'],{'transaction':_0x4ed3c7})[_0xb00b('0x16')](function(){if(!_[_0xb00b('0x7e')](_0x3c1cc5)){return _0x22b425[_0xb00b('0x7f')](_0x3c1cc5,{'transaction':_0x4ed3c7})['then'](function(){return db['UserVoiceQueueRt']['destroy']({'where':{'VoiceQueueId':_0x552f73[_0xb00b('0x32')]['id'],'UserId':_0x3c1cc5},'transaction':_0x4ed3c7});});}})[_0xb00b('0x16')](function(){_0x3c1cc5['forEach'](function(_0x20f4d2){socket[_0xb00b('0x6b')](_0xb00b('0x80'),{'UserId':_0x20f4d2,'VoiceQueueId':_0x22b425['id']});});});});});});})[_0xb00b('0x16')](respondWithStatusCode(_0x192b43,null))[_0xb00b('0x30')](handleError(_0x192b43,null));};exports[_0xb00b('0x81')]=function(_0x21ecef,_0x40f6f6){var _0x48125c,_0x1b097a;return db[_0xb00b('0x2d')][_0xb00b('0x20')]({'where':{'id':_0x21ecef['params']['id']}})['then'](handleEntityNotFound(_0x40f6f6,null))['then'](function(_0x1e66eb){if(_0x1e66eb){_0x1b097a=_0x1e66eb;return _0x1e66eb[_0xb00b('0x81')](_0x21ecef[_0xb00b('0x3e')]['ids'],_[_0xb00b('0x48')](_0x21ecef[_0xb00b('0x3e')],[_0xb00b('0x6d'),'id'])||{})[_0xb00b('0x82')](function(_0x2c3557){for(var _0x5b7137=0x0;_0x5b7137<_0x21ecef[_0xb00b('0x3e')]['ids'][_0xb00b('0x3a')];_0x5b7137+=0x1){socket[_0xb00b('0x6b')](_0xb00b('0x6c'),{'UserId':Number(_0x21ecef[_0xb00b('0x3e')][_0xb00b('0x6d')][_0x5b7137]),'VoiceQueueId':Number(_0x21ecef[_0xb00b('0x32')]['id'])});}return _0x2c3557;});}})['then'](function(_0xeaa6ea){_0x48125c=_0xeaa6ea||[];if(_0x1b097a){return db[_0xb00b('0x6e')][_0xb00b('0x53')]({'where':{'id':_0x21ecef[_0xb00b('0x3e')][_0xb00b('0x6d')]},'attributes':['id',_0xb00b('0x21'),_0xb00b('0x5e'),_0xb00b('0x5f'),_0xb00b('0x60')],'raw':!![]});}})[_0xb00b('0x16')](function(_0x5f1258){if(!_[_0xb00b('0x7e')](_0x5f1258)){var _0x33952b=[];for(var _0x4cd459=0x0;_0x4cd459<_0x5f1258[_0xb00b('0x3a')];_0x4cd459++){if(_0x5f1258[_0x4cd459]['online']){_0x33952b['push'](db['UserVoiceQueueRt'][_0xb00b('0x67')]({'membername':_0x5f1258[_0x4cd459]['name'],'UserId':_0x5f1258[_0x4cd459]['id'],'queue_name':_0x1b097a[_0xb00b('0x21')],'VoiceQueueId':_0x1b097a['id'],'interface':_[_0xb00b('0x83')](_0x5f1258[_0x4cd459][_0xb00b('0x60')])?util[_0xb00b('0x84')](_0xb00b('0x6a'),_0x5f1258[_0x4cd459][_0xb00b('0x21')]):_0x5f1258[_0x4cd459][_0xb00b('0x60')],'paused':_0x5f1258[_0x4cd459][_0xb00b('0x5f')]||![],'penalty':_0x21ecef[_0xb00b('0x3e')][_0xb00b('0x63')]||0x0}));}}return BPromise[_0xb00b('0x7b')](_0x33952b);}})[_0xb00b('0x16')](function(){return _0x48125c;})[_0xb00b('0x16')](respondWithResult(_0x40f6f6,null))[_0xb00b('0x30')](handleError(_0x40f6f6,null));};exports['removeAgents']=function(_0x31d2f0,_0x15f9cd){return db[_0xb00b('0x2d')][_0xb00b('0x20')]({'where':{'id':_0x31d2f0[_0xb00b('0x32')]['id']}})['then'](handleEntityNotFound(_0x15f9cd,null))[_0xb00b('0x16')](function(_0x387744){if(_0x387744){return _0x387744['removeAgents'](_0x31d2f0['query'][_0xb00b('0x6d')])[_0xb00b('0x16')](function(){if(_[_0xb00b('0x85')](_0x31d2f0[_0xb00b('0x35')][_0xb00b('0x6d')])){for(var _0x11f9b7=0x0;_0x11f9b7<_0x31d2f0[_0xb00b('0x35')][_0xb00b('0x6d')][_0xb00b('0x3a')];_0x11f9b7+=0x1){socket[_0xb00b('0x6b')](_0xb00b('0x80'),{'UserId':Number(_0x31d2f0['query'][_0xb00b('0x6d')][_0x11f9b7]),'VoiceQueueId':Number(_0x31d2f0['params']['id'])});}}else{socket[_0xb00b('0x6b')](_0xb00b('0x80'),{'UserId':Number(_0x31d2f0[_0xb00b('0x35')][_0xb00b('0x6d')]),'VoiceQueueId':Number(_0x31d2f0[_0xb00b('0x32')]['id'])});}});}})[_0xb00b('0x16')](function(_0x59c4b6){return db[_0xb00b('0x69')][_0xb00b('0x17')]({'where':{'VoiceQueueId':_0x31d2f0[_0xb00b('0x32')]['id'],'UserId':_0x31d2f0[_0xb00b('0x35')]['ids']}})[_0xb00b('0x16')](function(){return _0x59c4b6;});})[_0xb00b('0x16')](respondWithStatusCode(_0x15f9cd,null))['catch'](handleError(_0x15f9cd,null));};exports[_0xb00b('0x86')]=function(_0x16cca9,_0x3c57b2){var _0xca4a87={};var _0x456515={};var _0x26145a;var _0x31fa5b;return db[_0xb00b('0x2d')][_0xb00b('0x58')]({'where':{'id':_0x16cca9['params']['id']}})[_0xb00b('0x16')](handleEntityNotFound(_0x3c57b2,null))[_0xb00b('0x16')](function(_0x4b0306){if(_0x4b0306){_0x26145a=_0x4b0306;_0x456515[_0xb00b('0x33')]=_[_0xb00b('0x34')](db[_0xb00b('0x6e')][_0xb00b('0x28')]);_0x456515[_0xb00b('0x35')]=_[_0xb00b('0x34')](_0x16cca9[_0xb00b('0x35')]);_0x456515[_0xb00b('0x36')]=_[_0xb00b('0x37')](_0x456515[_0xb00b('0x33')],_0x456515[_0xb00b('0x35')]);_0xca4a87['attributes']=_[_0xb00b('0x37')](_0x456515[_0xb00b('0x33')],qs[_0xb00b('0x39')](_0x16cca9['query'][_0xb00b('0x39')]));_0xca4a87[_0xb00b('0x38')]=_0xca4a87[_0xb00b('0x38')][_0xb00b('0x3a')]?_0xca4a87['attributes']:_0x456515[_0xb00b('0x33')];_0xca4a87[_0xb00b('0x55')]=qs['sort'](_0x16cca9['query'][_0xb00b('0x4f')]);_0xca4a87[_0xb00b('0x2c')]=qs['filters'](_[_0xb00b('0x56')](_0x16cca9['query'],_0x456515['filters']));if(_0x16cca9[_0xb00b('0x35')]['filter']){_0xca4a87['where']=_[_0xb00b('0x3b')](_0xca4a87[_0xb00b('0x2c')],{'$or':_[_0xb00b('0x27')](_0xca4a87[_0xb00b('0x38')],function(_0x11e9b4){var _0x2ae27c={};_0x2ae27c[_0x11e9b4]={'$like':'%'+_0x16cca9[_0xb00b('0x35')][_0xb00b('0x1b')]+'%'};return _0x2ae27c;})});}_0xca4a87=_[_0xb00b('0x3b')]({},_0xca4a87,_0x16cca9[_0xb00b('0x3c')]);return _0x26145a[_0xb00b('0x86')](_0xca4a87);}})[_0xb00b('0x16')](function(_0x29ba55){if(_0x29ba55){_0x31fa5b=_0x29ba55[_0xb00b('0x3a')];if(!_0x16cca9['query'][_0xb00b('0x4d')](_0xb00b('0x4e'))){_0xca4a87['limit']=qs[_0xb00b('0x12')](_0x16cca9['query'][_0xb00b('0x12')]);_0xca4a87[_0xb00b('0x10')]=qs[_0xb00b('0x10')](_0x16cca9['query'][_0xb00b('0x10')]);}return _0x26145a[_0xb00b('0x86')](_0xca4a87);}})['then'](function(_0x8478c8){if(_0x8478c8){return _0x8478c8?{'count':_0x31fa5b,'rows':_0x8478c8}:null;}})[_0xb00b('0x16')](respondWithResult(_0x3c57b2,null))[_0xb00b('0x30')](handleError(_0x3c57b2,null));};exports[_0xb00b('0x87')]=function(_0x57bfab,_0x2dab12){var _0x47194e={};var _0x19d24b={};var _0x52b54b;var _0x571811;return db['VoiceQueue'][_0xb00b('0x58')]({'where':{'id':_0x57bfab[_0xb00b('0x32')]['id']}})[_0xb00b('0x16')](handleEntityNotFound(_0x2dab12,null))[_0xb00b('0x16')](function(_0x344379){if(_0x344379){_0x52b54b=_0x344379;_0x19d24b[_0xb00b('0x33')]=_[_0xb00b('0x34')](db[_0xb00b('0x69')][_0xb00b('0x28')]);_0x19d24b['query']=_['keys'](_0x57bfab[_0xb00b('0x35')]);_0x19d24b[_0xb00b('0x36')]=_['intersection'](_0x19d24b[_0xb00b('0x33')],_0x19d24b['query']);_0x47194e[_0xb00b('0x38')]=_['intersection'](_0x19d24b[_0xb00b('0x33')],qs[_0xb00b('0x39')](_0x57bfab['query'][_0xb00b('0x39')]));_0x47194e[_0xb00b('0x38')]=_0x47194e['attributes'][_0xb00b('0x3a')]?_0x47194e['attributes']:_0x19d24b[_0xb00b('0x33')];_0x47194e[_0xb00b('0x55')]=qs[_0xb00b('0x4f')](_0x57bfab[_0xb00b('0x35')][_0xb00b('0x4f')]);_0x47194e[_0xb00b('0x2c')]=qs[_0xb00b('0x36')](_[_0xb00b('0x56')](_0x57bfab[_0xb00b('0x35')],_0x19d24b[_0xb00b('0x36')]));if(_0x57bfab['query']['filter']){_0x47194e[_0xb00b('0x2c')]=_['merge'](_0x47194e[_0xb00b('0x2c')],{'$or':_['map'](_0x47194e[_0xb00b('0x38')],function(_0x1600f1){var _0x58bd2a={};_0x58bd2a[_0x1600f1]={'$like':'%'+_0x57bfab[_0xb00b('0x35')]['filter']+'%'};return _0x58bd2a;})});}_0x47194e=_[_0xb00b('0x3b')]({},_0x47194e,_0x57bfab[_0xb00b('0x3c')]);return _0x52b54b['getMembers'](_0x47194e);}})[_0xb00b('0x16')](function(_0x307c52){if(_0x307c52){_0x571811=_0x307c52[_0xb00b('0x3a')];if(!_0x57bfab[_0xb00b('0x35')][_0xb00b('0x4d')]('nolimit')){_0x47194e[_0xb00b('0x12')]=qs[_0xb00b('0x12')](_0x57bfab['query']['limit']);_0x47194e[_0xb00b('0x10')]=qs['offset'](_0x57bfab['query']['offset']);}return _0x52b54b[_0xb00b('0x87')](_0x47194e);}})[_0xb00b('0x16')](function(_0x39eb7a){return _0x39eb7a?{'count':_0x571811,'rows':_0x39eb7a}:null;})[_0xb00b('0x16')](respondWithResult(_0x2dab12,null))['catch'](handleError(_0x2dab12,null));};exports[_0xb00b('0x88')]=function(_0x482fc4,_0x3232cc){var _0x89225a={};var _0x22f2f6={};var _0x459f30;var _0x5aa72a;return db[_0xb00b('0x2d')][_0xb00b('0x58')]({'where':{'id':_0x482fc4['params']['id']}})[_0xb00b('0x16')](handleEntityNotFound(_0x3232cc,null))[_0xb00b('0x16')](function(_0x4291a3){if(_0x4291a3){_0x459f30=_0x4291a3;_0x22f2f6['model']=_['keys'](db[_0xb00b('0x89')][_0xb00b('0x28')]);_0x22f2f6[_0xb00b('0x35')]=_[_0xb00b('0x34')](_0x482fc4[_0xb00b('0x35')]);_0x22f2f6[_0xb00b('0x36')]=_[_0xb00b('0x37')](_0x22f2f6['model'],_0x22f2f6['query']);_0x89225a[_0xb00b('0x38')]=_['intersection'](_0x22f2f6['model'],qs[_0xb00b('0x39')](_0x482fc4[_0xb00b('0x35')]['fields']));_0x89225a[_0xb00b('0x38')]=_0x89225a[_0xb00b('0x38')][_0xb00b('0x3a')]?_0x89225a['attributes']:_0x22f2f6[_0xb00b('0x33')];_0x89225a[_0xb00b('0x55')]=qs[_0xb00b('0x4f')](_0x482fc4[_0xb00b('0x35')][_0xb00b('0x4f')]);_0x89225a[_0xb00b('0x2c')]=qs[_0xb00b('0x36')](_['pick'](_0x482fc4[_0xb00b('0x35')],_0x22f2f6[_0xb00b('0x36')]));if(_0x482fc4['query']['filter']){_0x89225a['where']=_[_0xb00b('0x3b')](_0x89225a[_0xb00b('0x2c')],{'$or':_[_0xb00b('0x27')](_0x89225a[_0xb00b('0x38')],function(_0x3deb79){var _0x1901d1={};_0x1901d1[_0x3deb79]={'$like':'%'+_0x482fc4[_0xb00b('0x35')]['filter']+'%'};return _0x1901d1;})});}_0x89225a=_['merge']({},_0x89225a,_0x482fc4[_0xb00b('0x3c')]);return _0x459f30[_0xb00b('0x88')](_0x89225a);}})['then'](function(_0x3517d6){if(_0x3517d6){_0x5aa72a=_0x3517d6[_0xb00b('0x3a')];if(!_0x482fc4['query'][_0xb00b('0x4d')]('nolimit')){_0x89225a[_0xb00b('0x12')]=qs['limit'](_0x482fc4['query']['limit']);_0x89225a[_0xb00b('0x10')]=qs[_0xb00b('0x10')](_0x482fc4[_0xb00b('0x35')][_0xb00b('0x10')]);}return _0x459f30['getLists'](_0x89225a);}})[_0xb00b('0x16')](function(_0x481abb){if(_0x481abb){return _0x481abb?{'count':_0x5aa72a,'rows':_0x481abb}:null;}})[_0xb00b('0x16')](respondWithResult(_0x3232cc,null))[_0xb00b('0x30')](handleError(_0x3232cc,null));};exports[_0xb00b('0x8a')]=function(_0x7ecc19,_0x1cc9fb){var _0x259acf=moment()[_0xb00b('0x84')](_0xb00b('0x8b'));var _0x57834b,_0x5448bb;return db[_0xb00b('0x2d')][_0xb00b('0x20')]({'where':{'id':_0x7ecc19[_0xb00b('0x32')]['id']}})[_0xb00b('0x16')](handleEntityNotFound(_0x1cc9fb,null))[_0xb00b('0x16')](function(_0x1e0206){if(_0x1e0206){_0x5448bb=_0x1e0206;return _0x1e0206[_0xb00b('0x8a')](_0x7ecc19[_0xb00b('0x3e')][_0xb00b('0x6d')],_['omit'](_0x7ecc19[_0xb00b('0x3e')],[_0xb00b('0x6d'),'id'])||{});}return null;})[_0xb00b('0x82')](function(_0x26b234){var _0x4fe674;_0x57834b=_0x26b234||[];var _0x45ad1f=[];if(_0x26b234){for(var _0x11b817=0x0;_0x11b817<_0x26b234[_0xb00b('0x3a')];_0x11b817+=0x1){var _0x89dd0a=_0x26b234[_0x11b817][_0xb00b('0x18')]({'plain':!![]});_0x5448bb[_0xb00b('0x8c')]=_0x7ecc19[_0xb00b('0x3e')][_0xb00b('0x8c')]?_0x7ecc19[_0xb00b('0x3e')]['dialCheckDuplicateType']:_0x5448bb['dialCheckDuplicateType'];switch(_0x5448bb[_0xb00b('0x8c')]){case _0xb00b('0x8d'):_0x4fe674=squel[_0xb00b('0x8e')]()[_0xb00b('0x8f')](_0xb00b('0x90'))[_0xb00b('0x91')]([_0xb00b('0x92'),'scheduledAt',_0xb00b('0x93'),_0xb00b('0x94'),_0xb00b('0x50'),_0xb00b('0x49'),_0xb00b('0x4a')],squel[_0xb00b('0x95')]()['field'](_0xb00b('0x92'),_0xb00b('0x92'))['field']('\x27'+_0x259acf+'\x27',_0xb00b('0x96'))[_0xb00b('0x6f')]('id',_0xb00b('0x93'))[_0xb00b('0x6f')](_0x89dd0a[_0xb00b('0x97')][_0xb00b('0x78')](),'ListId')['field'](_0x7ecc19[_0xb00b('0x32')]['id']['toString'](),'VoiceQueueId')['field']('\x27'+_0x259acf+'\x27',_0xb00b('0x49'))[_0xb00b('0x6f')]('\x27'+_0x259acf+'\x27','updatedAt')['from'](_0xb00b('0x98'))[_0xb00b('0x2c')](_0xb00b('0x99'))[_0xb00b('0x2c')](_0xb00b('0x9a'),_0x89dd0a[_0xb00b('0x97')][_0xb00b('0x78')]())[_0xb00b('0x2c')](_0xb00b('0x9b'))[_0xb00b('0x2c')](_0xb00b('0x9c'),squel['select']()[_0xb00b('0x6f')](_0xb00b('0x9d'))[_0xb00b('0x71')](_0xb00b('0x9e'))[_0xb00b('0x2c')](_0xb00b('0x76'),_0x7ecc19['params']['id'][_0xb00b('0x78')]()))[_0xb00b('0x2c')](_0xb00b('0x9c'),squel[_0xb00b('0x95')]()['field']('COALESCE(phone,\x27\x27)')[_0xb00b('0x71')](_0xb00b('0x90'))[_0xb00b('0x2c')](_0xb00b('0x76'),_0x7ecc19[_0xb00b('0x32')]['id'][_0xb00b('0x78')]())))[_0xb00b('0x78')]();break;case _0xb00b('0x9f'):_0x4fe674=squel[_0xb00b('0x8e')]()[_0xb00b('0x8f')](_0xb00b('0x90'))['fromQuery']([_0xb00b('0x92'),_0xb00b('0x96'),_0xb00b('0x93'),_0xb00b('0x94'),_0xb00b('0x50'),_0xb00b('0x49'),_0xb00b('0x4a')],squel[_0xb00b('0x95')]()['field'](_0xb00b('0x92'),_0xb00b('0x92'))[_0xb00b('0x6f')]('\x27'+_0x259acf+'\x27',_0xb00b('0x96'))['field']('id','ContactId')['field'](_0x89dd0a[_0xb00b('0x97')]['toString'](),_0xb00b('0x94'))[_0xb00b('0x6f')](_0x7ecc19[_0xb00b('0x32')]['id'][_0xb00b('0x78')](),'VoiceQueueId')['field']('\x27'+_0x259acf+'\x27',_0xb00b('0x49'))['field']('\x27'+_0x259acf+'\x27','updatedAt')[_0xb00b('0x71')]('cm_contacts')[_0xb00b('0x2c')](_0xb00b('0x99'))[_0xb00b('0x2c')](_0xb00b('0x9a'),_0x89dd0a['CmListId'][_0xb00b('0x78')]())[_0xb00b('0x2c')](_0xb00b('0x9b'))[_0xb00b('0x2c')](_0xb00b('0x9c'),squel['select']()['field']('COALESCE(phone,\x27\x27)')[_0xb00b('0x71')](_0xb00b('0x90'))['where'](_0xb00b('0x76'),_0x7ecc19[_0xb00b('0x32')]['id'][_0xb00b('0x78')]())))[_0xb00b('0x78')]();break;default:_0x4fe674=squel['insert']()[_0xb00b('0x8f')](_0xb00b('0x90'))[_0xb00b('0x91')]([_0xb00b('0x92'),'scheduledAt',_0xb00b('0x93'),'ListId',_0xb00b('0x50'),_0xb00b('0x49'),_0xb00b('0x4a')],squel[_0xb00b('0x95')]()[_0xb00b('0x6f')](_0xb00b('0x92'),_0xb00b('0x92'))[_0xb00b('0x6f')]('\x27'+_0x259acf+'\x27',_0xb00b('0x96'))[_0xb00b('0x6f')]('id',_0xb00b('0x93'))[_0xb00b('0x6f')](_0x89dd0a[_0xb00b('0x97')][_0xb00b('0x78')](),_0xb00b('0x94'))[_0xb00b('0x6f')](_0x7ecc19[_0xb00b('0x32')]['id']['toString'](),_0xb00b('0x50'))[_0xb00b('0x6f')]('\x27'+_0x259acf+'\x27',_0xb00b('0x49'))[_0xb00b('0x6f')]('\x27'+_0x259acf+'\x27',_0xb00b('0x4a'))['from'](_0xb00b('0x98'))[_0xb00b('0x2c')](_0xb00b('0x99'))[_0xb00b('0x2c')](_0xb00b('0x9a'),_0x89dd0a[_0xb00b('0x97')][_0xb00b('0x78')]())['where'](_0xb00b('0x9b')))['toString']();}_0x45ad1f[_0xb00b('0xa0')](db[_0xb00b('0x64')][_0xb00b('0x35')](_0x4fe674));}return BPromise['all'](_0x45ad1f);}})[_0xb00b('0x16')](function(){var _0x2bf68f=[];var _0x283ad6=squel[_0xb00b('0x8e')]()['into']('cm_hopper_additional_phones')[_0xb00b('0x91')]([_0xb00b('0xa1'),'phone',_0xb00b('0xa2'),_0xb00b('0x49'),_0xb00b('0x4a')],squel[_0xb00b('0x95')]()['field']('h.id')[_0xb00b('0x6f')](_0xb00b('0xa3'))[_0xb00b('0x6f')](_0xb00b('0xa4'))[_0xb00b('0x6f')]('\x27'+_0x259acf+'\x27',_0xb00b('0x49'))[_0xb00b('0x6f')]('\x27'+_0x259acf+'\x27',_0xb00b('0x4a'))['from'](_0xb00b('0xa5'),'ci')[_0xb00b('0x73')](_0xb00b('0x90'),'h',_0xb00b('0xa6'))[_0xb00b('0x2c')](_0xb00b('0xa7'),_0x259acf)[_0xb00b('0x2c')]('ci.ItemClass=?',_0xb00b('0xa8')))[_0xb00b('0x78')]();_0x2bf68f[_0xb00b('0xa0')](db[_0xb00b('0x64')][_0xb00b('0x35')](_0x283ad6));return BPromise[_0xb00b('0x7b')](_0x2bf68f);})[_0xb00b('0x16')](function(){return _0x57834b;})[_0xb00b('0x16')](respondWithResult(_0x1cc9fb,null))[_0xb00b('0x30')](handleError(_0x1cc9fb,null));};exports[_0xb00b('0xa9')]=function(_0x229197,_0x5ce3f3){return db[_0xb00b('0x2d')][_0xb00b('0x20')]({'where':{'id':_0x229197[_0xb00b('0x32')]['id']}})[_0xb00b('0x16')](handleEntityNotFound(_0x5ce3f3,null))[_0xb00b('0x16')](function(_0x406469){if(_0x406469){return _0x406469['removeLists'](_0x229197[_0xb00b('0x35')][_0xb00b('0x6d')]);}})[_0xb00b('0x16')](function(_0x4ffe41){if(_0x4ffe41){return db['CmHopper'][_0xb00b('0x17')]({'where':{'ListId':_0x229197['query'][_0xb00b('0x6d')],'VoiceQueueId':_0x229197[_0xb00b('0x32')]['id']}})['then'](function(){return _0x4ffe41;});}})[_0xb00b('0x16')](respondWithStatusCode(_0x5ce3f3,null))['catch'](handleError(_0x5ce3f3,null));};exports['getBlackLists']=function(_0x122be3,_0x4cb6ba){var _0x3ca253={};var _0x438281={};var _0x23b994;var _0x564934;return db[_0xb00b('0x2d')][_0xb00b('0x58')]({'where':{'id':_0x122be3[_0xb00b('0x32')]['id']}})[_0xb00b('0x16')](handleEntityNotFound(_0x4cb6ba,null))[_0xb00b('0x16')](function(_0x18f5ac){if(_0x18f5ac){_0x23b994=_0x18f5ac;_0x438281[_0xb00b('0x33')]=_['keys'](db[_0xb00b('0x89')]['rawAttributes']);_0x438281[_0xb00b('0x35')]=_[_0xb00b('0x34')](_0x122be3[_0xb00b('0x35')]);_0x438281[_0xb00b('0x36')]=_['intersection'](_0x438281[_0xb00b('0x33')],_0x438281[_0xb00b('0x35')]);_0x3ca253[_0xb00b('0x38')]=_[_0xb00b('0x37')](_0x438281[_0xb00b('0x33')],qs[_0xb00b('0x39')](_0x122be3['query'][_0xb00b('0x39')]));_0x3ca253[_0xb00b('0x38')]=_0x3ca253['attributes'][_0xb00b('0x3a')]?_0x3ca253[_0xb00b('0x38')]:_0x438281[_0xb00b('0x33')];_0x3ca253[_0xb00b('0x55')]=qs[_0xb00b('0x4f')](_0x122be3[_0xb00b('0x35')][_0xb00b('0x4f')]);_0x3ca253[_0xb00b('0x2c')]=qs[_0xb00b('0x36')](_[_0xb00b('0x56')](_0x122be3[_0xb00b('0x35')],_0x438281[_0xb00b('0x36')]));if(_0x122be3[_0xb00b('0x35')][_0xb00b('0x1b')]){_0x3ca253['where']=_['merge'](_0x3ca253['where'],{'$or':_[_0xb00b('0x27')](_0x3ca253[_0xb00b('0x38')],function(_0x966247){var _0x58b695={};_0x58b695[_0x966247]={'$like':'%'+_0x122be3[_0xb00b('0x35')][_0xb00b('0x1b')]+'%'};return _0x58b695;})});}_0x3ca253=_[_0xb00b('0x3b')]({},_0x3ca253,_0x122be3[_0xb00b('0x3c')]);return _0x23b994[_0xb00b('0xaa')](_0x3ca253);}})['then'](function(_0x1bafb2){if(_0x1bafb2){_0x564934=_0x1bafb2['length'];if(!_0x122be3['query']['hasOwnProperty'](_0xb00b('0x4e'))){_0x3ca253[_0xb00b('0x12')]=qs['limit'](_0x122be3[_0xb00b('0x35')][_0xb00b('0x12')]);_0x3ca253[_0xb00b('0x10')]=qs['offset'](_0x122be3[_0xb00b('0x35')]['offset']);}return _0x23b994[_0xb00b('0xaa')](_0x3ca253);}})[_0xb00b('0x16')](function(_0x2e3e5a){if(_0x2e3e5a){return _0x2e3e5a?{'count':_0x564934,'rows':_0x2e3e5a}:null;}})[_0xb00b('0x16')](respondWithResult(_0x4cb6ba,null))['catch'](handleError(_0x4cb6ba,null));};exports['addBlackLists']=function(_0x470c4a,_0x12cc9d){var _0xe5b66f;return db[_0xb00b('0x2d')][_0xb00b('0x20')]({'where':{'id':_0x470c4a[_0xb00b('0x32')]['id']}})['then'](handleEntityNotFound(_0x12cc9d,null))[_0xb00b('0x16')](function(_0x3afb66){if(_0x3afb66){return _0x3afb66[_0xb00b('0xab')](_0x470c4a[_0xb00b('0x3e')]['ids'],_[_0xb00b('0x48')](_0x470c4a[_0xb00b('0x3e')],[_0xb00b('0x6d'),'id'])||{});}return null;})[_0xb00b('0x82')](function(_0x379b81){var _0x46c784;_0xe5b66f=_0x379b81||[];var _0x471db4=[];if(_0x379b81){for(var _0x333bee=0x0;_0x333bee<_0x379b81['length'];_0x333bee+=0x1){var _0x1a94bf=_0x379b81[_0x333bee][_0xb00b('0x18')]({'plain':!![]});_0x46c784=squel[_0xb00b('0x8e')]()['into'](_0xb00b('0xac'))[_0xb00b('0x91')]([_0xb00b('0x92'),'ContactId',_0xb00b('0x94'),_0xb00b('0x50'),_0xb00b('0x49'),_0xb00b('0x4a')],squel[_0xb00b('0x95')]()[_0xb00b('0x6f')](_0xb00b('0x92'),'phone')[_0xb00b('0x6f')]('id',_0xb00b('0x93'))[_0xb00b('0x6f')](_0x1a94bf['CmListId'][_0xb00b('0x78')](),_0xb00b('0x94'))[_0xb00b('0x6f')](_0x470c4a[_0xb00b('0x32')]['id']['toString'](),_0xb00b('0x50'))['field'](_0xb00b('0xad'),_0xb00b('0x49'))['field'](_0xb00b('0xad'),_0xb00b('0x4a'))[_0xb00b('0x71')](_0xb00b('0x98'))[_0xb00b('0x2c')]('deletedAt\x20IS\x20NULL')['where'](_0xb00b('0x9a'),_0x1a94bf[_0xb00b('0x97')][_0xb00b('0x78')]())['where'](_0xb00b('0x9b')))[_0xb00b('0x78')]();_0x471db4[_0xb00b('0xa0')](db['sequelize'][_0xb00b('0x35')](_0x46c784));}return BPromise[_0xb00b('0x7b')](_0x471db4);}})[_0xb00b('0x16')](function(){return _0xe5b66f;})['then'](respondWithResult(_0x12cc9d,null))[_0xb00b('0x30')](handleError(_0x12cc9d,null));};exports[_0xb00b('0xae')]=function(_0x4d30c3,_0x5099fd){return db[_0xb00b('0x2d')][_0xb00b('0x20')]({'where':{'id':_0x4d30c3[_0xb00b('0x32')]['id']}})[_0xb00b('0x16')](handleEntityNotFound(_0x5099fd,null))['then'](function(_0x45b2e1){if(_0x45b2e1){return _0x45b2e1[_0xb00b('0xae')](_0x4d30c3[_0xb00b('0x35')][_0xb00b('0x6d')]);}})[_0xb00b('0x16')](function(_0x5e12dc){if(_0x5e12dc){return db[_0xb00b('0x5a')][_0xb00b('0x17')]({'where':{'ListId':_0x4d30c3[_0xb00b('0x35')][_0xb00b('0x6d')],'VoiceQueueId':_0x4d30c3[_0xb00b('0x32')]['id']}})[_0xb00b('0x16')](function(){return _0x5e12dc;});}})[_0xb00b('0x16')](respondWithStatusCode(_0x5099fd,null))[_0xb00b('0x30')](handleError(_0x5099fd,null));};
\ No newline at end of file