Built motion from commit (unavailable).|2.5.16
[motion2.git] / server / api / voiceQueue / voiceQueue.controller.js
index 9109678..ab32fb9 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xa902=['destroy','then','get','VoiceQueues','inbound','outbound','filter','ignore','map','includes','value','type','error','name','send','VoiceQueue','rawAttributes','fieldName','key','model','query','filters','intersection','attributes','nolimit','order','sort','where','pick','merge','VIRTUAL','options','count','includeAll','include','findAll','catch','show','params','keys','fields','length','create','body','Unable\x20to\x20retrieve\x20the\x20current\x20user','QueueCampaigns','find','userProfileId','UserProfileResource','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','clone','omit','createdAt','updatedAt','role','user','autoAssociation','getHoppers','findOne','CmHopper','hasOwnProperty','VoiceQueueId','rows','getHopperHistories','CmHopperHistory','getHopperFinals','CmHopperFinal','getHopperBlacks','CmHopperBlack','Team','getTeams','addTeams','teams','Agents','online','voicePause','interface','flatMap','forEach','penalty','transaction','each','UserVoiceQueue','findOrCreate','UserVoiceQueueRt','format','SIP/%s','emit','userVoiceQueue:save','removeTeams','ids','select','field','tq.TeamId','from','team_has_voice_queues','user_has_teams','ut.TeamId\x20=\x20tq.TeamId','toString','sequelize','SELECT','TeamId','all','union','compact','userVoiceQueue:remove','addAgents','spread','User','push','upsert','isNil','removeAgents','getAgents','getLists','CmList','addLists','dialCheckDuplicateType','always','insert','into','cm_hopper','fromQuery','ContactId','ListId','phone','NOW()','scheduledAt','CmListId','cm_contacts','deletedAt\x20IS\x20NULL','ListId\x20=\x20?','phone\x20IS\x20NOT\x20NULL','phone\x20NOT\x20IN\x20(?)','cm_hopper_final','COALESCE(phone,\x27\x27)','VoiceQueueId\x20=\x20?','removeLists','getBlackLists','addBlackLists','removeBlackLists','html-pdf','eml-format','rimraf','zip-dir','fast-json-patch','moment','util','path','sox','to-csv','ejs','lodash','crypto','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/environment','redis','socket.io-emitter','./voiceQueue.socket','sendStatus','end','status','json','offset','limit','set','Content-Range','apply','reject','update'];(function(_0x3df7b8,_0x55db91){var _0x16f05d=function(_0x5501c8){while(--_0x5501c8){_0x3df7b8['push'](_0x3df7b8['shift']());}};_0x16f05d(++_0x55db91);}(_0xa902,0x8d));var _0x2a90=function(_0x21bd89,_0x5cb3e3){_0x21bd89=_0x21bd89-0x0;var _0x5a07ee=_0xa902[_0x21bd89];return _0x5a07ee;};'use strict';var pdf=require(_0x2a90('0x0'));var emlformat=require(_0x2a90('0x1'));var rimraf=require(_0x2a90('0x2'));var zipdir=require(_0x2a90('0x3'));var jsonpatch=require(_0x2a90('0x4'));var rp=require('request-promise');var moment=require(_0x2a90('0x5'));var BPromise=require('bluebird');var Mustache=require('mustache');var util=require(_0x2a90('0x6'));var path=require(_0x2a90('0x7'));var sox=require(_0x2a90('0x8'));var csv=require(_0x2a90('0x9'));var ejs=require(_0x2a90('0xa'));var fs=require('fs');var _=require(_0x2a90('0xb'));var squel=require('squel');var crypto=require(_0x2a90('0xc'));var jsforce=require('jsforce');var deskjs=require('desk.js');var toCsv=require(_0x2a90('0x9'));var querystring=require(_0x2a90('0xd'));var Papa=require(_0x2a90('0xe'));var Redis=require(_0x2a90('0xf'));var authService=require(_0x2a90('0x10'));var qs=require('../../components/parsers/qs');var as=require(_0x2a90('0x11'));var hardwareService=require(_0x2a90('0x12'));var logger=require(_0x2a90('0x13'))(_0x2a90('0x14'));var utils=require('../../config/utils');var config=require(_0x2a90('0x15'));var db=require('../../mysqldb')['db'];config[_0x2a90('0x16')]=_['defaults'](config[_0x2a90('0x16')],{'host':'localhost','port':0x18eb});var socket=require(_0x2a90('0x17'))(new Redis(config[_0x2a90('0x16')]));require(_0x2a90('0x18'))['register'](socket);function respondWithStatusCode(_0x56d1b8,_0x57227c){_0x57227c=_0x57227c||0xcc;return function(_0x46cb32){if(_0x46cb32){return _0x56d1b8[_0x2a90('0x19')](_0x57227c);}return _0x56d1b8['status'](_0x57227c)[_0x2a90('0x1a')]();};}function respondWithResult(_0x21c648,_0x312782){_0x312782=_0x312782||0xc8;return function(_0x25bd0e){if(_0x25bd0e){return _0x21c648[_0x2a90('0x1b')](_0x312782)[_0x2a90('0x1c')](_0x25bd0e);}};}function respondWithFilteredResult(_0x2fa60f,_0x10cf94){return function(_0x43eea5){if(_0x43eea5){var _0x5c3e4b=_0x43eea5['count'],_0x162f0b=_0x10cf94[_0x2a90('0x1d')],_0x1d9a28=_0x10cf94[_0x2a90('0x1d')]+_0x10cf94[_0x2a90('0x1e')],_0x4190ff;if(_0x1d9a28>=_0x5c3e4b){_0x1d9a28=_0x5c3e4b;_0x4190ff=0xc8;}else{_0x4190ff=0xce;}_0x2fa60f[_0x2a90('0x1b')](_0x4190ff);return _0x2fa60f[_0x2a90('0x1f')](_0x2a90('0x20'),_0x162f0b+'-'+_0x1d9a28+'/'+_0x5c3e4b)[_0x2a90('0x1c')](_0x43eea5);}return null;};}function patchUpdates(_0x114d42){return function(_0xf97adb){try{jsonpatch[_0x2a90('0x21')](_0xf97adb,_0x114d42,!![]);}catch(_0x1340b9){return BPromise[_0x2a90('0x22')](_0x1340b9);}return _0xf97adb['save']();};}function saveUpdates(_0x3da7d0,_0x217873){return function(_0x2955a9){if(_0x2955a9){return _0x2955a9[_0x2a90('0x23')](_0x3da7d0)['then'](function(_0x180485){return _0x180485;});}return null;};}function removeEntity(_0xd033d,_0x4ed9e6){return function(_0x1bcfd7){if(_0x1bcfd7){return _0x1bcfd7[_0x2a90('0x24')]()[_0x2a90('0x25')](function(){var _0x2a4e28=_0x1bcfd7[_0x2a90('0x26')]({'plain':!![]});var _0x1303d9=[{'name':_0x2a90('0x27'),'value':_0x2a90('0x28'),'ignore':![]},{'name':'QueueCampaigns','value':_0x2a90('0x29'),'ignore':![]}];var _0x17f978=_(_0x1303d9)[_0x2a90('0x2a')](_0x2a90('0x2b'))[_0x2a90('0x2c')]('value')['value']();if(_[_0x2a90('0x2d')](_0x17f978,_0x2a4e28['type'])){return;}var _0x53391e=_['find'](_0x1303d9,[_0x2a90('0x2e'),_0x2a4e28[_0x2a90('0x2f')]])['name'];return db['UserProfileResource'][_0x2a90('0x24')]({'where':{'type':_0x53391e,'resourceId':_0x2a4e28['id']}})['then'](function(){return _0x1bcfd7;});})[_0x2a90('0x25')](function(){_0xd033d[_0x2a90('0x1b')](0xcc)[_0x2a90('0x1a')]();});}};}function handleEntityNotFound(_0x27b6b6,_0xf18d11){return function(_0x11586c){if(!_0x11586c){_0x27b6b6[_0x2a90('0x19')](0x194);}return _0x11586c;};}function handleError(_0x4a0bfa,_0x427918){_0x427918=_0x427918||0x1f4;return function(_0x22b1f3){logger[_0x2a90('0x30')](_0x22b1f3['stack']);if(_0x22b1f3[_0x2a90('0x31')]){delete _0x22b1f3[_0x2a90('0x31')];}_0x4a0bfa[_0x2a90('0x1b')](_0x427918)[_0x2a90('0x32')](_0x22b1f3);};}exports['index']=function(_0x44899d,_0x1b5f73){var _0xee69e4={},_0x38158b={},_0x129d6e={'count':0x0,'rows':[]};var _0x431942=_['map'](db[_0x2a90('0x33')][_0x2a90('0x34')],function(_0x1bdebf){return{'name':_0x1bdebf[_0x2a90('0x35')],'type':_0x1bdebf['type'][_0x2a90('0x36')]};});_0x38158b[_0x2a90('0x37')]=_['map'](_0x431942,_0x2a90('0x31'));_0x38158b[_0x2a90('0x38')]=_['keys'](_0x44899d['query']);_0x38158b[_0x2a90('0x39')]=_[_0x2a90('0x3a')](_0x38158b[_0x2a90('0x37')],_0x38158b['query']);_0xee69e4[_0x2a90('0x3b')]=_['intersection'](_0x38158b[_0x2a90('0x37')],qs['fields'](_0x44899d[_0x2a90('0x38')]['fields']));_0xee69e4['attributes']=_0xee69e4[_0x2a90('0x3b')]['length']?_0xee69e4[_0x2a90('0x3b')]:_0x38158b[_0x2a90('0x37')];if(!_0x44899d[_0x2a90('0x38')]['hasOwnProperty'](_0x2a90('0x3c'))){_0xee69e4[_0x2a90('0x1e')]=qs[_0x2a90('0x1e')](_0x44899d['query'][_0x2a90('0x1e')]);_0xee69e4[_0x2a90('0x1d')]=qs[_0x2a90('0x1d')](_0x44899d['query'][_0x2a90('0x1d')]);}_0xee69e4[_0x2a90('0x3d')]=qs['sort'](_0x44899d[_0x2a90('0x38')][_0x2a90('0x3e')]);_0xee69e4[_0x2a90('0x3f')]=qs[_0x2a90('0x39')](_[_0x2a90('0x40')](_0x44899d[_0x2a90('0x38')],_0x38158b[_0x2a90('0x39')]));if(_0x44899d[_0x2a90('0x38')][_0x2a90('0x2a')]){_0xee69e4[_0x2a90('0x3f')]=_[_0x2a90('0x41')](_0xee69e4[_0x2a90('0x3f')],{'$or':_[_0x2a90('0x2c')](_0x431942,function(_0x18a6ea){if(_0x18a6ea['type']!==_0x2a90('0x42')){var _0x3a70fe={};_0x3a70fe[_0x18a6ea['name']]={'$like':'%'+_0x44899d[_0x2a90('0x38')][_0x2a90('0x2a')]+'%'};return _0x3a70fe;}})});}_0xee69e4=_[_0x2a90('0x41')]({},_0xee69e4,_0x44899d[_0x2a90('0x43')]);var _0x471f6a={'where':_0xee69e4['where']};return db[_0x2a90('0x33')]['count'](_0x471f6a)[_0x2a90('0x25')](function(_0x5161ec){_0x129d6e[_0x2a90('0x44')]=_0x5161ec;if(_0x44899d[_0x2a90('0x38')][_0x2a90('0x45')]){_0xee69e4[_0x2a90('0x46')]=[{'all':!![]}];}return db[_0x2a90('0x33')][_0x2a90('0x47')](_0xee69e4);})[_0x2a90('0x25')](function(_0x48d464){_0x129d6e['rows']=_0x48d464;return _0x129d6e;})[_0x2a90('0x25')](respondWithFilteredResult(_0x1b5f73,_0xee69e4))[_0x2a90('0x48')](handleError(_0x1b5f73,null));};exports[_0x2a90('0x49')]=function(_0x28944c,_0x1ae049){var _0xff4f4a={'raw':![],'where':{'id':_0x28944c[_0x2a90('0x4a')]['id']}},_0x654803={};_0x654803['model']=_[_0x2a90('0x4b')](db['VoiceQueue'][_0x2a90('0x34')]);_0x654803[_0x2a90('0x38')]=_['keys'](_0x28944c[_0x2a90('0x38')]);_0x654803[_0x2a90('0x39')]=_[_0x2a90('0x3a')](_0x654803[_0x2a90('0x37')],_0x654803[_0x2a90('0x38')]);_0xff4f4a[_0x2a90('0x3b')]=_[_0x2a90('0x3a')](_0x654803['model'],qs['fields'](_0x28944c[_0x2a90('0x38')][_0x2a90('0x4c')]));_0xff4f4a[_0x2a90('0x3b')]=_0xff4f4a[_0x2a90('0x3b')][_0x2a90('0x4d')]?_0xff4f4a['attributes']:_0x654803['model'];if(_0x28944c[_0x2a90('0x38')][_0x2a90('0x45')]){_0xff4f4a['include']=[{'all':!![]}];}_0xff4f4a=_['merge']({},_0xff4f4a,_0x28944c['options']);return db[_0x2a90('0x33')]['find'](_0xff4f4a)[_0x2a90('0x25')](handleEntityNotFound(_0x1ae049,null))[_0x2a90('0x25')](respondWithResult(_0x1ae049,null))[_0x2a90('0x48')](handleError(_0x1ae049,null));};exports[_0x2a90('0x4e')]=function(_0x3b2630,_0x3ade08){return db['VoiceQueue'][_0x2a90('0x4e')](_0x3b2630[_0x2a90('0x4f')],{})['then'](function(_0x265769){var _0x4d1303=_0x3b2630['user'][_0x2a90('0x26')]({'plain':!![]});if(!_0x4d1303)throw new Error(_0x2a90('0x50'));if(_0x4d1303['role']==='user'){var _0x2dd550=_0x265769['get']({'plain':!![]});var _0x273111=[{'name':_0x2a90('0x27'),'value':'inbound'},{'name':_0x2a90('0x51'),'value':_0x2a90('0x29')}];var _0xd7a708=_['find'](_0x273111,[_0x2a90('0x2e'),_0x2dd550[_0x2a90('0x2f')]])['name'];return db['UserProfileSection'][_0x2a90('0x52')]({'where':{'name':_0xd7a708,'userProfileId':_0x4d1303[_0x2a90('0x53')]},'raw':!![]})['then'](function(_0x274f25){if(_0x274f25&&_0x274f25['autoAssociation']===0x0){return db[_0x2a90('0x54')]['create']({'name':_0x2dd550[_0x2a90('0x31')],'resourceId':_0x2dd550['id'],'type':_0x274f25[_0x2a90('0x31')],'sectionId':_0x274f25['id']},{})[_0x2a90('0x25')](function(){return _0x265769;});}else{return _0x265769;}})['catch'](function(_0x5ad248){logger['error'](_0x2a90('0x55'),_0x5ad248);throw _0x5ad248;});}return _0x265769;})[_0x2a90('0x25')](respondWithResult(_0x3ade08,0xc9))[_0x2a90('0x48')](handleError(_0x3ade08,null));};exports[_0x2a90('0x56')]=function(_0x2e5762,_0x1f08d4){var _0x5148ce={'where':{'id':_0x2e5762[_0x2a90('0x4a')]['id']}},_0x37f34b={};_0x37f34b[_0x2a90('0x37')]=_[_0x2a90('0x4b')](db[_0x2a90('0x33')][_0x2a90('0x34')]);_0x5148ce['attributes']=_['intersection'](_0x37f34b['model'],qs[_0x2a90('0x4c')](_0x2e5762[_0x2a90('0x38')][_0x2a90('0x4c')]));_0x5148ce[_0x2a90('0x3b')]=_0x5148ce[_0x2a90('0x3b')][_0x2a90('0x4d')]?_0x5148ce[_0x2a90('0x3b')]:_0x37f34b[_0x2a90('0x37')];if(_0x2e5762[_0x2a90('0x38')][_0x2a90('0x45')]){_0x5148ce[_0x2a90('0x46')]=[{'all':!![]}];}_0x5148ce=_[_0x2a90('0x41')]({},_0x5148ce,_0x2e5762[_0x2a90('0x43')]);return db[_0x2a90('0x33')][_0x2a90('0x52')](_0x5148ce)[_0x2a90('0x25')](handleEntityNotFound(_0x1f08d4,null))['then'](function(_0x30e257){if(_0x30e257){var _0x4d2a63=_0x30e257[_0x2a90('0x26')]({'plain':!![]});_0x4d2a63=qs[_0x2a90('0x57')](_0x4d2a63,['id',_0x2a90('0x58'),_0x2a90('0x59')]);_0x2e5762[_0x2a90('0x4f')]=_[_0x2a90('0x57')](_0x2e5762[_0x2a90('0x4f')],['id','createdAt',_0x2a90('0x59')]);return db[_0x2a90('0x33')][_0x2a90('0x4e')](_['merge'](_0x4d2a63,_0x2e5762[_0x2a90('0x4f')]),{'include':_0x2e5762[_0x2a90('0x38')][_0x2a90('0x45')]?[{'all':!![]}]:undefined})[_0x2a90('0x25')](function(_0x502856){var _0x18dce7=_0x2e5762['user'][_0x2a90('0x26')]({'plain':!![]});if(!_0x18dce7)throw new Error(_0x2a90('0x50'));if(_0x18dce7[_0x2a90('0x5a')]===_0x2a90('0x5b')){var _0x106d01=_0x502856[_0x2a90('0x26')]({'plain':!![]});var _0x4e541a=[{'name':_0x2a90('0x27'),'value':_0x2a90('0x28')},{'name':_0x2a90('0x51'),'value':_0x2a90('0x29')}];var _0x1f8788=_[_0x2a90('0x52')](_0x4e541a,[_0x2a90('0x2e'),_0x106d01[_0x2a90('0x2f')]])[_0x2a90('0x31')];return db['UserProfileSection'][_0x2a90('0x52')]({'where':{'name':_0x1f8788,'userProfileId':_0x18dce7[_0x2a90('0x53')]},'raw':!![]})[_0x2a90('0x25')](function(_0x507599){if(_0x507599&&_0x507599[_0x2a90('0x5c')]===0x0){return db[_0x2a90('0x54')][_0x2a90('0x4e')]({'name':_0x106d01[_0x2a90('0x31')],'resourceId':_0x106d01['id'],'type':_0x507599[_0x2a90('0x31')],'sectionId':_0x507599['id']},{})['then'](function(){return _0x502856;});}else{return _0x502856;}})[_0x2a90('0x48')](function(_0x5e0bf2){logger['error'](_0x2a90('0x55'),_0x5e0bf2);throw _0x5e0bf2;});}return _0x502856;});}})['then'](respondWithResult(_0x1f08d4,0xc9))['catch'](handleError(_0x1f08d4,null));};exports[_0x2a90('0x23')]=function(_0x5f3ae1,_0xac4adb){if(_0x5f3ae1[_0x2a90('0x4f')]['id']){delete _0x5f3ae1['body']['id'];}return db['VoiceQueue'][_0x2a90('0x52')]({'where':{'id':_0x5f3ae1['params']['id']}})['then'](handleEntityNotFound(_0xac4adb,null))[_0x2a90('0x25')](saveUpdates(_0x5f3ae1[_0x2a90('0x4f')],null))[_0x2a90('0x25')](respondWithResult(_0xac4adb,null))[_0x2a90('0x48')](handleError(_0xac4adb,null));};exports['destroy']=function(_0x4eaee2,_0x370144){return db[_0x2a90('0x33')][_0x2a90('0x52')]({'where':{'id':_0x4eaee2[_0x2a90('0x4a')]['id']}})[_0x2a90('0x25')](handleEntityNotFound(_0x370144,null))[_0x2a90('0x25')](removeEntity(_0x370144,null))[_0x2a90('0x48')](handleError(_0x370144,null));};exports[_0x2a90('0x5d')]=function(_0x325c3a,_0xe20002,_0xe10abe){var _0x19edd1={'raw':![],'where':{}};var _0x5a1a53={};var _0x2e4646={'count':0x0,'rows':[]};return db['VoiceQueue'][_0x2a90('0x5e')]({'where':{'id':_0x325c3a['params']['id']}})[_0x2a90('0x25')](handleEntityNotFound(_0xe20002,null))['then'](function(_0x4ea392){if(_0x4ea392){_0x5a1a53[_0x2a90('0x37')]=_[_0x2a90('0x4b')](db[_0x2a90('0x5f')][_0x2a90('0x34')]);_0x5a1a53['query']=_['keys'](_0x325c3a[_0x2a90('0x38')]);_0x5a1a53[_0x2a90('0x39')]=_[_0x2a90('0x3a')](_0x5a1a53[_0x2a90('0x37')],_0x5a1a53[_0x2a90('0x38')]);_0x19edd1[_0x2a90('0x3b')]=_[_0x2a90('0x3a')](_0x5a1a53[_0x2a90('0x37')],qs[_0x2a90('0x4c')](_0x325c3a[_0x2a90('0x38')][_0x2a90('0x4c')]));_0x19edd1[_0x2a90('0x3b')]=_0x19edd1['attributes'][_0x2a90('0x4d')]?_0x19edd1[_0x2a90('0x3b')]:_0x5a1a53[_0x2a90('0x37')];if(!_0x325c3a[_0x2a90('0x38')][_0x2a90('0x60')](_0x2a90('0x3c'))){_0x19edd1[_0x2a90('0x1e')]=qs[_0x2a90('0x1e')](_0x325c3a['query'][_0x2a90('0x1e')]);_0x19edd1[_0x2a90('0x1d')]=qs['offset'](_0x325c3a[_0x2a90('0x38')][_0x2a90('0x1d')]);}_0x19edd1[_0x2a90('0x3d')]=qs[_0x2a90('0x3e')](_0x325c3a[_0x2a90('0x38')][_0x2a90('0x3e')]);_0x19edd1['where']=qs[_0x2a90('0x39')](_[_0x2a90('0x40')](_0x325c3a[_0x2a90('0x38')],_0x5a1a53[_0x2a90('0x39')]));_0x19edd1[_0x2a90('0x3f')][_0x2a90('0x61')]=_0x4ea392['id'];if(_0x325c3a[_0x2a90('0x38')][_0x2a90('0x2a')]){_0x19edd1['where']=_[_0x2a90('0x41')](_0x19edd1[_0x2a90('0x3f')],{'$or':_[_0x2a90('0x2c')](_0x19edd1[_0x2a90('0x3b')],function(_0xb6fded){var _0x14138e={};_0x14138e[_0xb6fded]={'$like':'%'+_0x325c3a['query'][_0x2a90('0x2a')]+'%'};return _0x14138e;})});}_0x19edd1=_[_0x2a90('0x41')]({},_0x19edd1,_0x325c3a[_0x2a90('0x43')]);return db['CmHopper'][_0x2a90('0x44')]({'where':_0x19edd1[_0x2a90('0x3f')]})[_0x2a90('0x25')](function(_0x5c0a1b){_0x2e4646['count']=_0x5c0a1b;if(_0x325c3a[_0x2a90('0x38')][_0x2a90('0x45')]){_0x19edd1['include']=[{'all':!![]}];}return db[_0x2a90('0x5f')][_0x2a90('0x47')](_0x19edd1);})['then'](function(_0x241d4b){_0x2e4646[_0x2a90('0x62')]=_0x241d4b;return _0x2e4646;});}})['then'](respondWithFilteredResult(_0xe20002,_0x19edd1))[_0x2a90('0x48')](handleError(_0xe20002,null));};exports[_0x2a90('0x63')]=function(_0x4b480a,_0x58905e,_0x34c740){var _0x432db3={'raw':!![],'where':{}};var _0x184263={};var _0x3011e9={'count':0x0,'rows':[]};return db[_0x2a90('0x33')][_0x2a90('0x5e')]({'where':{'id':_0x4b480a[_0x2a90('0x4a')]['id']}})[_0x2a90('0x25')](handleEntityNotFound(_0x58905e,null))[_0x2a90('0x25')](function(_0x9c11df){if(_0x9c11df){_0x184263[_0x2a90('0x37')]=_['keys'](db[_0x2a90('0x64')][_0x2a90('0x34')]);_0x184263[_0x2a90('0x38')]=_['keys'](_0x4b480a[_0x2a90('0x38')]);_0x184263[_0x2a90('0x39')]=_[_0x2a90('0x3a')](_0x184263['model'],_0x184263[_0x2a90('0x38')]);_0x432db3[_0x2a90('0x3b')]=_[_0x2a90('0x3a')](_0x184263[_0x2a90('0x37')],qs[_0x2a90('0x4c')](_0x4b480a[_0x2a90('0x38')][_0x2a90('0x4c')]));_0x432db3['attributes']=_0x432db3['attributes'][_0x2a90('0x4d')]?_0x432db3['attributes']:_0x184263[_0x2a90('0x37')];if(!_0x4b480a[_0x2a90('0x38')]['hasOwnProperty'](_0x2a90('0x3c'))){_0x432db3[_0x2a90('0x1e')]=qs[_0x2a90('0x1e')](_0x4b480a[_0x2a90('0x38')][_0x2a90('0x1e')]);_0x432db3[_0x2a90('0x1d')]=qs[_0x2a90('0x1d')](_0x4b480a[_0x2a90('0x38')][_0x2a90('0x1d')]);}_0x432db3['order']=qs['sort'](_0x4b480a[_0x2a90('0x38')][_0x2a90('0x3e')]);_0x432db3[_0x2a90('0x3f')]=qs[_0x2a90('0x39')](_[_0x2a90('0x40')](_0x4b480a[_0x2a90('0x38')],_0x184263[_0x2a90('0x39')]));_0x432db3[_0x2a90('0x3f')][_0x2a90('0x61')]=_0x9c11df['id'];if(_0x4b480a[_0x2a90('0x38')][_0x2a90('0x2a')]){_0x432db3[_0x2a90('0x3f')]=_[_0x2a90('0x41')](_0x432db3[_0x2a90('0x3f')],{'$or':_[_0x2a90('0x2c')](_0x432db3[_0x2a90('0x3b')],function(_0x46b9de){var _0x484afc={};_0x484afc[_0x46b9de]={'$like':'%'+_0x4b480a[_0x2a90('0x38')][_0x2a90('0x2a')]+'%'};return _0x484afc;})});}_0x432db3=_[_0x2a90('0x41')]({},_0x432db3,_0x4b480a[_0x2a90('0x43')]);return db['CmHopperHistory'][_0x2a90('0x44')]({'where':_0x432db3[_0x2a90('0x3f')]})[_0x2a90('0x25')](function(_0x58110b){_0x3011e9[_0x2a90('0x44')]=_0x58110b;if(_0x4b480a[_0x2a90('0x38')][_0x2a90('0x45')]){_0x432db3[_0x2a90('0x46')]=[{'all':!![]}];}return db[_0x2a90('0x64')]['findAll'](_0x432db3);})['then'](function(_0xd429f5){_0x3011e9[_0x2a90('0x62')]=_0xd429f5;return _0x3011e9;});}})['then'](respondWithFilteredResult(_0x58905e,_0x432db3))[_0x2a90('0x48')](handleError(_0x58905e,null));};exports[_0x2a90('0x65')]=function(_0x32a924,_0x45570b,_0x1e0862){var _0x399f09={'raw':!![],'where':{}};var _0x99a847={};var _0x3411a6={'count':0x0,'rows':[]};return db[_0x2a90('0x33')][_0x2a90('0x5e')]({'where':{'id':_0x32a924['params']['id']}})[_0x2a90('0x25')](handleEntityNotFound(_0x45570b,null))[_0x2a90('0x25')](function(_0x2a6d16){if(_0x2a6d16){_0x99a847[_0x2a90('0x37')]=_[_0x2a90('0x4b')](db[_0x2a90('0x66')][_0x2a90('0x34')]);_0x99a847[_0x2a90('0x38')]=_[_0x2a90('0x4b')](_0x32a924[_0x2a90('0x38')]);_0x99a847['filters']=_[_0x2a90('0x3a')](_0x99a847[_0x2a90('0x37')],_0x99a847[_0x2a90('0x38')]);_0x399f09['attributes']=_[_0x2a90('0x3a')](_0x99a847[_0x2a90('0x37')],qs[_0x2a90('0x4c')](_0x32a924[_0x2a90('0x38')][_0x2a90('0x4c')]));_0x399f09['attributes']=_0x399f09['attributes']['length']?_0x399f09[_0x2a90('0x3b')]:_0x99a847[_0x2a90('0x37')];if(!_0x32a924[_0x2a90('0x38')][_0x2a90('0x60')](_0x2a90('0x3c'))){_0x399f09[_0x2a90('0x1e')]=qs[_0x2a90('0x1e')](_0x32a924[_0x2a90('0x38')]['limit']);_0x399f09[_0x2a90('0x1d')]=qs[_0x2a90('0x1d')](_0x32a924[_0x2a90('0x38')][_0x2a90('0x1d')]);}_0x399f09[_0x2a90('0x3d')]=qs[_0x2a90('0x3e')](_0x32a924[_0x2a90('0x38')][_0x2a90('0x3e')]);_0x399f09[_0x2a90('0x3f')]=qs['filters'](_[_0x2a90('0x40')](_0x32a924[_0x2a90('0x38')],_0x99a847[_0x2a90('0x39')]));_0x399f09[_0x2a90('0x3f')][_0x2a90('0x61')]=_0x2a6d16['id'];if(_0x32a924[_0x2a90('0x38')]['filter']){_0x399f09[_0x2a90('0x3f')]=_[_0x2a90('0x41')](_0x399f09[_0x2a90('0x3f')],{'$or':_[_0x2a90('0x2c')](_0x399f09[_0x2a90('0x3b')],function(_0x5cb4b6){var _0x101477={};_0x101477[_0x5cb4b6]={'$like':'%'+_0x32a924[_0x2a90('0x38')][_0x2a90('0x2a')]+'%'};return _0x101477;})});}_0x399f09=_[_0x2a90('0x41')]({},_0x399f09,_0x32a924['options']);return db[_0x2a90('0x66')][_0x2a90('0x44')]({'where':_0x399f09[_0x2a90('0x3f')]})[_0x2a90('0x25')](function(_0x50201c){_0x3411a6['count']=_0x50201c;if(_0x32a924[_0x2a90('0x38')]['includeAll']){_0x399f09[_0x2a90('0x46')]=[{'all':!![]}];}return db['CmHopperFinal']['findAll'](_0x399f09);})[_0x2a90('0x25')](function(_0x5c9783){_0x3411a6[_0x2a90('0x62')]=_0x5c9783;return _0x3411a6;});}})[_0x2a90('0x25')](respondWithFilteredResult(_0x45570b,_0x399f09))[_0x2a90('0x48')](handleError(_0x45570b,null));};exports[_0x2a90('0x67')]=function(_0x39b7d4,_0x1f2e2a,_0x21ed4c){var _0x3fad53={'raw':!![],'where':{}};var _0x98059e={};var _0x113799={'count':0x0,'rows':[]};return db['VoiceQueue']['findOne']({'where':{'id':_0x39b7d4[_0x2a90('0x4a')]['id']}})[_0x2a90('0x25')](handleEntityNotFound(_0x1f2e2a,null))[_0x2a90('0x25')](function(_0x1f0c76){if(_0x1f0c76){_0x98059e[_0x2a90('0x37')]=_['keys'](db['CmHopperBlack'][_0x2a90('0x34')]);_0x98059e[_0x2a90('0x38')]=_[_0x2a90('0x4b')](_0x39b7d4[_0x2a90('0x38')]);_0x98059e[_0x2a90('0x39')]=_[_0x2a90('0x3a')](_0x98059e[_0x2a90('0x37')],_0x98059e[_0x2a90('0x38')]);_0x3fad53['attributes']=_[_0x2a90('0x3a')](_0x98059e[_0x2a90('0x37')],qs[_0x2a90('0x4c')](_0x39b7d4['query'][_0x2a90('0x4c')]));_0x3fad53[_0x2a90('0x3b')]=_0x3fad53[_0x2a90('0x3b')]['length']?_0x3fad53[_0x2a90('0x3b')]:_0x98059e['model'];if(!_0x39b7d4[_0x2a90('0x38')]['hasOwnProperty'](_0x2a90('0x3c'))){_0x3fad53[_0x2a90('0x1e')]=qs[_0x2a90('0x1e')](_0x39b7d4[_0x2a90('0x38')][_0x2a90('0x1e')]);_0x3fad53[_0x2a90('0x1d')]=qs[_0x2a90('0x1d')](_0x39b7d4[_0x2a90('0x38')][_0x2a90('0x1d')]);}_0x3fad53[_0x2a90('0x3d')]=qs['sort'](_0x39b7d4['query'][_0x2a90('0x3e')]);_0x3fad53[_0x2a90('0x3f')]=qs['filters'](_[_0x2a90('0x40')](_0x39b7d4['query'],_0x98059e['filters']));_0x3fad53[_0x2a90('0x3f')][_0x2a90('0x61')]=_0x1f0c76['id'];if(_0x39b7d4[_0x2a90('0x38')][_0x2a90('0x2a')]){_0x3fad53[_0x2a90('0x3f')]=_[_0x2a90('0x41')](_0x3fad53['where'],{'$or':_['map'](_0x3fad53[_0x2a90('0x3b')],function(_0x59fec5){var _0x2910b1={};_0x2910b1[_0x59fec5]={'$like':'%'+_0x39b7d4[_0x2a90('0x38')][_0x2a90('0x2a')]+'%'};return _0x2910b1;})});}_0x3fad53=_[_0x2a90('0x41')]({},_0x3fad53,_0x39b7d4[_0x2a90('0x43')]);return db[_0x2a90('0x68')][_0x2a90('0x44')]({'where':_0x3fad53['where']})[_0x2a90('0x25')](function(_0x1e89c9){_0x113799[_0x2a90('0x44')]=_0x1e89c9;if(_0x39b7d4[_0x2a90('0x38')][_0x2a90('0x45')]){_0x3fad53['include']=[{'all':!![]}];}return db[_0x2a90('0x68')]['findAll'](_0x3fad53);})['then'](function(_0x490f4a){_0x113799[_0x2a90('0x62')]=_0x490f4a;return _0x113799;});}})[_0x2a90('0x25')](respondWithFilteredResult(_0x1f2e2a,_0x3fad53))[_0x2a90('0x48')](handleError(_0x1f2e2a,null));};exports['getTeams']=function(_0x19e885,_0x1232aa,_0x5eecff){var _0x8d176c={};var _0x49842c={};var _0xbef2e2;var _0x5316c0;return db[_0x2a90('0x33')][_0x2a90('0x5e')]({'where':{'id':_0x19e885[_0x2a90('0x4a')]['id']}})[_0x2a90('0x25')](handleEntityNotFound(_0x1232aa,null))[_0x2a90('0x25')](function(_0x12bde8){if(_0x12bde8){_0xbef2e2=_0x12bde8;_0x49842c[_0x2a90('0x37')]=_['keys'](db[_0x2a90('0x69')]['rawAttributes']);_0x49842c[_0x2a90('0x38')]=_[_0x2a90('0x4b')](_0x19e885[_0x2a90('0x38')]);_0x49842c[_0x2a90('0x39')]=_[_0x2a90('0x3a')](_0x49842c[_0x2a90('0x37')],_0x49842c[_0x2a90('0x38')]);_0x8d176c[_0x2a90('0x3b')]=_['intersection'](_0x49842c['model'],qs[_0x2a90('0x4c')](_0x19e885[_0x2a90('0x38')][_0x2a90('0x4c')]));_0x8d176c[_0x2a90('0x3b')]=_0x8d176c[_0x2a90('0x3b')][_0x2a90('0x4d')]?_0x8d176c[_0x2a90('0x3b')]:_0x49842c[_0x2a90('0x37')];_0x8d176c[_0x2a90('0x3d')]=qs['sort'](_0x19e885['query']['sort']);_0x8d176c[_0x2a90('0x3f')]=qs[_0x2a90('0x39')](_[_0x2a90('0x40')](_0x19e885['query'],_0x49842c['filters']));if(_0x19e885['query'][_0x2a90('0x2a')]){_0x8d176c['where']=_[_0x2a90('0x41')](_0x8d176c[_0x2a90('0x3f')],{'$or':_[_0x2a90('0x2c')](_0x8d176c[_0x2a90('0x3b')],function(_0xe1b84c){var _0x1bf24c={};_0x1bf24c[_0xe1b84c]={'$like':'%'+_0x19e885[_0x2a90('0x38')][_0x2a90('0x2a')]+'%'};return _0x1bf24c;})});}_0x8d176c=_['merge']({},_0x8d176c,_0x19e885[_0x2a90('0x43')]);return _0xbef2e2[_0x2a90('0x6a')](_0x8d176c);}})[_0x2a90('0x25')](function(_0x4e9df0){if(_0x4e9df0){_0x5316c0=_0x4e9df0[_0x2a90('0x4d')];if(!_0x19e885[_0x2a90('0x38')][_0x2a90('0x60')](_0x2a90('0x3c'))){_0x8d176c[_0x2a90('0x1e')]=qs[_0x2a90('0x1e')](_0x19e885[_0x2a90('0x38')][_0x2a90('0x1e')]);_0x8d176c['offset']=qs['offset'](_0x19e885[_0x2a90('0x38')][_0x2a90('0x1d')]);}return _0xbef2e2[_0x2a90('0x6a')](_0x8d176c);}})[_0x2a90('0x25')](function(_0x16a109){if(_0x16a109){return _0x16a109?{'count':_0x5316c0,'rows':_0x16a109}:null;}})['then'](respondWithResult(_0x1232aa,null))[_0x2a90('0x48')](handleError(_0x1232aa,null));};exports[_0x2a90('0x6b')]=function(_0x5921b2,_0x25ce19,_0x20ac0e){var _0x255dce=_0x5921b2[_0x2a90('0x4f')][_0x2a90('0x6c')];var _0xcc1142=_[_0x2a90('0x2c')](_0x255dce,'id');return db[_0x2a90('0x69')][_0x2a90('0x47')]({'where':{'id':_0xcc1142},'attributes':['id'],'include':[{'model':db['User'],'as':_0x2a90('0x6d'),'attributes':['id',_0x2a90('0x31'),_0x2a90('0x6e'),_0x2a90('0x6f'),_0x2a90('0x70')],'raw':!![]}]})[_0x2a90('0x25')](function(_0x33b421){if(_0x33b421){var _0x43e67f=_[_0x2a90('0x71')](_0x33b421,function(_0x69c0dd){var _0x3e90c8=_0x69c0dd['get']({'plain':!![]});_0x3e90c8['Agents'][_0x2a90('0x72')](function(_0x5a5b99){_0x5a5b99[_0x2a90('0x73')]=_[_0x2a90('0x52')](_0x255dce,{'id':_0x3e90c8['id']})[_0x2a90('0x73')];});return _0x3e90c8[_0x2a90('0x6d')];});return db[_0x2a90('0x33')][_0x2a90('0x52')]({'where':{'id':_0x5921b2[_0x2a90('0x4a')]['id']}})[_0x2a90('0x25')](function(_0x2b8bb1){return db['sequelize'][_0x2a90('0x74')](function(_0x200c65){return _0x2b8bb1['addTeams'](_0xcc1142,{'transaction':_0x200c65})[_0x2a90('0x25')](function(){return BPromise[_0x2a90('0x75')](_0x43e67f,function(_0x369dca){return db[_0x2a90('0x76')][_0x2a90('0x77')]({'where':{'UserId':_0x369dca['id'],'VoiceQueueId':_0x5921b2[_0x2a90('0x4a')]['id']},'defaults':{'penalty':_0x369dca[_0x2a90('0x73')]},'transaction':_0x200c65});});})[_0x2a90('0x25')](function(){return BPromise['each'](_['filter'](_0x43e67f,{'online':!![]}),function(_0x488f8b){return db[_0x2a90('0x78')]['upsert']({'membername':_0x488f8b['name'],'UserId':_0x488f8b['id'],'queue_name':_0x2b8bb1[_0x2a90('0x31')],'VoiceQueueId':_0x2b8bb1['id'],'interface':_['isNil'](_0x488f8b['interface'])?util[_0x2a90('0x79')](_0x2a90('0x7a'),_0x488f8b[_0x2a90('0x31')]):_0x488f8b['interface'],'paused':_0x488f8b[_0x2a90('0x6f')]||![],'penalty':_0x488f8b[_0x2a90('0x73')]},{'transaction':_0x200c65});});})[_0x2a90('0x25')](function(){_0x43e67f[_0x2a90('0x72')](function(_0x4e9303){socket[_0x2a90('0x7b')](_0x2a90('0x7c'),{'UserId':_0x4e9303['id'],'VoiceQueueId':_0x2b8bb1['id']});});});});});}})[_0x2a90('0x25')](respondWithStatusCode(_0x25ce19,null))[_0x2a90('0x48')](handleError(_0x25ce19,null));};exports[_0x2a90('0x7d')]=function(_0x2b5835,_0x378218,_0x201ee7){return db['Team'][_0x2a90('0x47')]({'where':{'id':_0x2b5835['query'][_0x2a90('0x7e')]},'attributes':['id'],'include':[{'model':db['User'],'as':_0x2a90('0x6d'),'attributes':['id'],'raw':!![]}]})[_0x2a90('0x25')](handleEntityNotFound(_0x378218,null))[_0x2a90('0x25')](function(_0x2fe164){var _0x16e236=_[_0x2a90('0x2c')](_0x2fe164,'id');var _0x6626c3=[];var _0x446e2d=[];var _0x42723c=squel[_0x2a90('0x7f')]();_0x42723c[_0x2a90('0x80')](_0x2a90('0x81'))[_0x2a90('0x82')](_0x2a90('0x83'),'tq')['join'](_0x2a90('0x84'),'ut',_0x2a90('0x85'))[_0x2a90('0x3f')]('VoiceQueueId\x20=\x20?',_0x2b5835['params']['id']);for(var _0x304e0f=0x0;_0x304e0f<_0x2fe164[_0x2a90('0x4d')];_0x304e0f+=0x1){let _0x218bc0=_0x2fe164[_0x304e0f];for(var _0x260a19=0x0;_0x260a19<_0x218bc0[_0x2a90('0x6d')][_0x2a90('0x4d')];_0x260a19+=0x1){let _0x3b8266=_0x218bc0[_0x2a90('0x6d')][_0x260a19];var _0xed6e6c=_0x42723c['clone']();_0xed6e6c[_0x2a90('0x3f')]('ut.UserId\x20=\x20?',_0x3b8266['id']);_0x446e2d['push'](db['sequelize']['query'](_0xed6e6c[_0x2a90('0x86')](),{'type':db[_0x2a90('0x87')]['QueryTypes'][_0x2a90('0x88')]})[_0x2a90('0x25')](function(_0x5e2a44){if(_0x5e2a44[_0x2a90('0x4d')]===0x1){return _0x3b8266['id'];}else{var _0x477239=_['every'](_[_0x2a90('0x2c')](_0x5e2a44,_0x2a90('0x89')),function(_0x2ec4b9){return _[_0x2a90('0x2d')](_0x16e236,_0x2ec4b9);});if(_0x477239){return _0x3b8266['id'];}}}));}}return BPromise[_0x2a90('0x8a')](_0x446e2d)[_0x2a90('0x25')](function(_0x19c761){_0x6626c3=_(_0x6626c3)[_0x2a90('0x8b')](_0x19c761)[_0x2a90('0x8c')]()[_0x2a90('0x2e')]();return db['VoiceQueue']['find']({'where':{'id':_0x2b5835[_0x2a90('0x4a')]['id']}})[_0x2a90('0x25')](function(_0x58c865){return db[_0x2a90('0x87')][_0x2a90('0x74')](function(_0x28c8c3){return _0x58c865[_0x2a90('0x7d')](_0x2b5835[_0x2a90('0x38')][_0x2a90('0x7e')],{'transaction':_0x28c8c3})[_0x2a90('0x25')](function(){if(!_['isEmpty'](_0x6626c3)){return _0x58c865['removeAgents'](_0x6626c3,{'transaction':_0x28c8c3})[_0x2a90('0x25')](function(){return db['UserVoiceQueueRt'][_0x2a90('0x24')]({'where':{'VoiceQueueId':_0x2b5835[_0x2a90('0x4a')]['id'],'UserId':_0x6626c3},'transaction':_0x28c8c3});});}})[_0x2a90('0x25')](function(){_0x6626c3[_0x2a90('0x72')](function(_0x226ed8){socket[_0x2a90('0x7b')](_0x2a90('0x8d'),{'UserId':_0x226ed8,'VoiceQueueId':_0x58c865['id']});});});});});});})['then'](respondWithStatusCode(_0x378218,null))['catch'](handleError(_0x378218,null));};exports[_0x2a90('0x8e')]=function(_0x34b8bd,_0x4fff8d,_0x474512){var _0x4f4930,_0x470411;return db['VoiceQueue'][_0x2a90('0x52')]({'where':{'id':_0x34b8bd[_0x2a90('0x4a')]['id']}})['then'](handleEntityNotFound(_0x4fff8d,null))[_0x2a90('0x25')](function(_0x4c8e97){if(_0x4c8e97){_0x470411=_0x4c8e97;return _0x4c8e97[_0x2a90('0x8e')](_0x34b8bd[_0x2a90('0x4f')][_0x2a90('0x7e')],_[_0x2a90('0x57')](_0x34b8bd[_0x2a90('0x4f')],['ids','id'])||{})[_0x2a90('0x8f')](function(_0x410639){for(var _0x134fdd=0x0;_0x134fdd<_0x34b8bd['body']['ids'][_0x2a90('0x4d')];_0x134fdd+=0x1){socket[_0x2a90('0x7b')]('userVoiceQueue:save',{'UserId':_0x34b8bd['body'][_0x2a90('0x7e')][_0x134fdd],'VoiceQueueId':_0x34b8bd[_0x2a90('0x4a')]['id']});}return _0x410639;});}})[_0x2a90('0x25')](function(_0x5026d0){_0x4f4930=_0x5026d0||[];if(_0x470411){return db[_0x2a90('0x90')][_0x2a90('0x47')]({'where':{'id':_0x34b8bd[_0x2a90('0x4f')]['ids']},'attributes':['id',_0x2a90('0x31'),_0x2a90('0x6e'),'voicePause',_0x2a90('0x70')],'raw':!![]});}})[_0x2a90('0x25')](function(_0x9a4568){if(!_['isEmpty'](_0x9a4568)){var _0x497267=[];for(var _0x155807=0x0;_0x155807<_0x9a4568['length'];_0x155807++){if(_0x9a4568[_0x155807][_0x2a90('0x6e')]){_0x497267[_0x2a90('0x91')](db[_0x2a90('0x78')][_0x2a90('0x92')]({'membername':_0x9a4568[_0x155807][_0x2a90('0x31')],'UserId':_0x9a4568[_0x155807]['id'],'queue_name':_0x470411[_0x2a90('0x31')],'VoiceQueueId':_0x470411['id'],'interface':_[_0x2a90('0x93')](_0x9a4568[_0x155807]['interface'])?util[_0x2a90('0x79')](_0x2a90('0x7a'),_0x9a4568[_0x155807]['name']):_0x9a4568[_0x155807]['interface'],'paused':_0x9a4568[_0x155807]['voicePause']||![],'penalty':_0x34b8bd[_0x2a90('0x4f')][_0x2a90('0x73')]||0x0}));}}return BPromise['all'](_0x497267);}})['then'](function(){return _0x4f4930;})[_0x2a90('0x25')](respondWithResult(_0x4fff8d,null))[_0x2a90('0x48')](handleError(_0x4fff8d,null));};exports[_0x2a90('0x94')]=function(_0x49f096,_0x4d75d8,_0x8fd8dd){return db['VoiceQueue'][_0x2a90('0x52')]({'where':{'id':_0x49f096['params']['id']}})[_0x2a90('0x25')](handleEntityNotFound(_0x4d75d8,null))[_0x2a90('0x25')](function(_0x5e7792){if(_0x5e7792){return _0x5e7792['removeAgents'](_0x49f096[_0x2a90('0x38')][_0x2a90('0x7e')])[_0x2a90('0x25')](function(){if(_['isArray'](_0x49f096['query']['ids'])){for(var _0x44b37c=0x0;_0x44b37c<_0x49f096['query']['ids'][_0x2a90('0x4d')];_0x44b37c+=0x1){socket[_0x2a90('0x7b')](_0x2a90('0x8d'),{'UserId':Number(_0x49f096['query'][_0x2a90('0x7e')][_0x44b37c]),'VoiceQueueId':Number(_0x49f096[_0x2a90('0x4a')]['id'])});}}else{socket[_0x2a90('0x7b')](_0x2a90('0x8d'),{'UserId':Number(_0x49f096['query']['ids']),'VoiceQueueId':Number(_0x49f096[_0x2a90('0x4a')]['id'])});}});}})[_0x2a90('0x25')](function(_0x1d1cb1){return db['UserVoiceQueueRt'][_0x2a90('0x24')]({'where':{'VoiceQueueId':_0x49f096[_0x2a90('0x4a')]['id'],'UserId':_0x49f096[_0x2a90('0x38')]['ids']}})[_0x2a90('0x25')](function(){return _0x1d1cb1;});})[_0x2a90('0x25')](respondWithStatusCode(_0x4d75d8,null))['catch'](handleError(_0x4d75d8,null));};exports[_0x2a90('0x95')]=function(_0x4b5b22,_0x5a345b,_0x42ce13){var _0x99db47={};var _0x229b3e={};var _0x208aaa;var _0x7072f0;return db['VoiceQueue'][_0x2a90('0x5e')]({'where':{'id':_0x4b5b22['params']['id']}})[_0x2a90('0x25')](handleEntityNotFound(_0x5a345b,null))['then'](function(_0x3dc509){if(_0x3dc509){_0x208aaa=_0x3dc509;_0x229b3e[_0x2a90('0x37')]=_[_0x2a90('0x4b')](db[_0x2a90('0x90')][_0x2a90('0x34')]);_0x229b3e[_0x2a90('0x38')]=_[_0x2a90('0x4b')](_0x4b5b22[_0x2a90('0x38')]);_0x229b3e[_0x2a90('0x39')]=_['intersection'](_0x229b3e[_0x2a90('0x37')],_0x229b3e[_0x2a90('0x38')]);_0x99db47[_0x2a90('0x3b')]=_['intersection'](_0x229b3e['model'],qs[_0x2a90('0x4c')](_0x4b5b22[_0x2a90('0x38')][_0x2a90('0x4c')]));_0x99db47[_0x2a90('0x3b')]=_0x99db47['attributes']['length']?_0x99db47[_0x2a90('0x3b')]:_0x229b3e[_0x2a90('0x37')];_0x99db47[_0x2a90('0x3d')]=qs['sort'](_0x4b5b22['query'][_0x2a90('0x3e')]);_0x99db47['where']=qs['filters'](_[_0x2a90('0x40')](_0x4b5b22['query'],_0x229b3e[_0x2a90('0x39')]));if(_0x4b5b22[_0x2a90('0x38')][_0x2a90('0x2a')]){_0x99db47[_0x2a90('0x3f')]=_['merge'](_0x99db47['where'],{'$or':_[_0x2a90('0x2c')](_0x99db47['attributes'],function(_0x5f0783){var _0x37dddf={};_0x37dddf[_0x5f0783]={'$like':'%'+_0x4b5b22['query'][_0x2a90('0x2a')]+'%'};return _0x37dddf;})});}_0x99db47=_['merge']({},_0x99db47,_0x4b5b22[_0x2a90('0x43')]);return _0x208aaa[_0x2a90('0x95')](_0x99db47);}})['then'](function(_0x2022c8){if(_0x2022c8){_0x7072f0=_0x2022c8[_0x2a90('0x4d')];if(!_0x4b5b22[_0x2a90('0x38')][_0x2a90('0x60')](_0x2a90('0x3c'))){_0x99db47[_0x2a90('0x1e')]=qs[_0x2a90('0x1e')](_0x4b5b22[_0x2a90('0x38')][_0x2a90('0x1e')]);_0x99db47[_0x2a90('0x1d')]=qs[_0x2a90('0x1d')](_0x4b5b22[_0x2a90('0x38')][_0x2a90('0x1d')]);}return _0x208aaa[_0x2a90('0x95')](_0x99db47);}})[_0x2a90('0x25')](function(_0x5c8016){if(_0x5c8016){return _0x5c8016?{'count':_0x7072f0,'rows':_0x5c8016}:null;}})[_0x2a90('0x25')](respondWithResult(_0x5a345b,null))[_0x2a90('0x48')](handleError(_0x5a345b,null));};exports['getMembers']=function(_0x54d75b,_0x262a07,_0x1ee4ed){var _0x4eabcf={};var _0x5a219e={};var _0x316cfd;var _0x5004be;return db[_0x2a90('0x33')][_0x2a90('0x5e')]({'where':{'id':_0x54d75b[_0x2a90('0x4a')]['id']}})[_0x2a90('0x25')](handleEntityNotFound(_0x262a07,null))['then'](function(_0x33ea9f){if(_0x33ea9f){_0x316cfd=_0x33ea9f;_0x5a219e[_0x2a90('0x37')]=_[_0x2a90('0x4b')](db['UserVoiceQueueRt'][_0x2a90('0x34')]);_0x5a219e['query']=_['keys'](_0x54d75b[_0x2a90('0x38')]);_0x5a219e[_0x2a90('0x39')]=_[_0x2a90('0x3a')](_0x5a219e[_0x2a90('0x37')],_0x5a219e[_0x2a90('0x38')]);_0x4eabcf[_0x2a90('0x3b')]=_['intersection'](_0x5a219e['model'],qs[_0x2a90('0x4c')](_0x54d75b[_0x2a90('0x38')]['fields']));_0x4eabcf[_0x2a90('0x3b')]=_0x4eabcf[_0x2a90('0x3b')][_0x2a90('0x4d')]?_0x4eabcf[_0x2a90('0x3b')]:_0x5a219e[_0x2a90('0x37')];_0x4eabcf['order']=qs['sort'](_0x54d75b['query'][_0x2a90('0x3e')]);_0x4eabcf[_0x2a90('0x3f')]=qs[_0x2a90('0x39')](_[_0x2a90('0x40')](_0x54d75b[_0x2a90('0x38')],_0x5a219e['filters']));if(_0x54d75b[_0x2a90('0x38')][_0x2a90('0x2a')]){_0x4eabcf[_0x2a90('0x3f')]=_[_0x2a90('0x41')](_0x4eabcf['where'],{'$or':_['map'](_0x4eabcf[_0x2a90('0x3b')],function(_0xf121f1){var _0x31e36d={};_0x31e36d[_0xf121f1]={'$like':'%'+_0x54d75b[_0x2a90('0x38')]['filter']+'%'};return _0x31e36d;})});}_0x4eabcf=_[_0x2a90('0x41')]({},_0x4eabcf,_0x54d75b['options']);return _0x316cfd['getMembers'](_0x4eabcf);}})[_0x2a90('0x25')](function(_0x492f1e){if(_0x492f1e){_0x5004be=_0x492f1e['length'];if(!_0x54d75b[_0x2a90('0x38')]['hasOwnProperty'](_0x2a90('0x3c'))){_0x4eabcf[_0x2a90('0x1e')]=qs['limit'](_0x54d75b[_0x2a90('0x38')][_0x2a90('0x1e')]);_0x4eabcf['offset']=qs['offset'](_0x54d75b[_0x2a90('0x38')][_0x2a90('0x1d')]);}return _0x316cfd['getMembers'](_0x4eabcf);}})[_0x2a90('0x25')](function(_0x2b4bd1){return _0x2b4bd1?{'count':_0x5004be,'rows':_0x2b4bd1}:null;})[_0x2a90('0x25')](respondWithResult(_0x262a07,null))[_0x2a90('0x48')](handleError(_0x262a07,null));};exports[_0x2a90('0x96')]=function(_0x3cc791,_0xfd1836,_0x2a30ec){var _0x3626e0={};var _0x567f33={};var _0xd9b809;var _0x59c687;return db['VoiceQueue']['findOne']({'where':{'id':_0x3cc791['params']['id']}})[_0x2a90('0x25')](handleEntityNotFound(_0xfd1836,null))[_0x2a90('0x25')](function(_0x423887){if(_0x423887){_0xd9b809=_0x423887;_0x567f33[_0x2a90('0x37')]=_[_0x2a90('0x4b')](db[_0x2a90('0x97')]['rawAttributes']);_0x567f33['query']=_[_0x2a90('0x4b')](_0x3cc791[_0x2a90('0x38')]);_0x567f33[_0x2a90('0x39')]=_[_0x2a90('0x3a')](_0x567f33[_0x2a90('0x37')],_0x567f33['query']);_0x3626e0[_0x2a90('0x3b')]=_[_0x2a90('0x3a')](_0x567f33[_0x2a90('0x37')],qs[_0x2a90('0x4c')](_0x3cc791[_0x2a90('0x38')][_0x2a90('0x4c')]));_0x3626e0['attributes']=_0x3626e0['attributes'][_0x2a90('0x4d')]?_0x3626e0[_0x2a90('0x3b')]:_0x567f33['model'];_0x3626e0[_0x2a90('0x3d')]=qs[_0x2a90('0x3e')](_0x3cc791[_0x2a90('0x38')][_0x2a90('0x3e')]);_0x3626e0[_0x2a90('0x3f')]=qs['filters'](_[_0x2a90('0x40')](_0x3cc791[_0x2a90('0x38')],_0x567f33[_0x2a90('0x39')]));if(_0x3cc791[_0x2a90('0x38')]['filter']){_0x3626e0[_0x2a90('0x3f')]=_['merge'](_0x3626e0['where'],{'$or':_[_0x2a90('0x2c')](_0x3626e0[_0x2a90('0x3b')],function(_0x643b0f){var _0x1c1217={};_0x1c1217[_0x643b0f]={'$like':'%'+_0x3cc791[_0x2a90('0x38')][_0x2a90('0x2a')]+'%'};return _0x1c1217;})});}_0x3626e0=_[_0x2a90('0x41')]({},_0x3626e0,_0x3cc791['options']);return _0xd9b809[_0x2a90('0x96')](_0x3626e0);}})['then'](function(_0x1b4b6){if(_0x1b4b6){_0x59c687=_0x1b4b6[_0x2a90('0x4d')];if(!_0x3cc791[_0x2a90('0x38')][_0x2a90('0x60')]('nolimit')){_0x3626e0[_0x2a90('0x1e')]=qs[_0x2a90('0x1e')](_0x3cc791[_0x2a90('0x38')][_0x2a90('0x1e')]);_0x3626e0[_0x2a90('0x1d')]=qs[_0x2a90('0x1d')](_0x3cc791[_0x2a90('0x38')][_0x2a90('0x1d')]);}return _0xd9b809[_0x2a90('0x96')](_0x3626e0);}})[_0x2a90('0x25')](function(_0x4ddad3){if(_0x4ddad3){return _0x4ddad3?{'count':_0x59c687,'rows':_0x4ddad3}:null;}})[_0x2a90('0x25')](respondWithResult(_0xfd1836,null))[_0x2a90('0x48')](handleError(_0xfd1836,null));};exports[_0x2a90('0x98')]=function(_0x2d0fa7,_0x22cfc,_0x4061ff){var _0x2f0fa0,_0x26ba4c;return db[_0x2a90('0x33')]['find']({'where':{'id':_0x2d0fa7[_0x2a90('0x4a')]['id']}})[_0x2a90('0x25')](handleEntityNotFound(_0x22cfc,null))['then'](function(_0x184b09){if(_0x184b09){_0x26ba4c=_0x184b09;return _0x184b09[_0x2a90('0x98')](_0x2d0fa7[_0x2a90('0x4f')][_0x2a90('0x7e')],_['omit'](_0x2d0fa7[_0x2a90('0x4f')],[_0x2a90('0x7e'),'id'])||{});}return null;})['spread'](function(_0x4a477e){var _0x5c4694;_0x2f0fa0=_0x4a477e||[];var _0x4cc134=[];if(_0x4a477e){for(var _0x169416=0x0;_0x169416<_0x4a477e[_0x2a90('0x4d')];_0x169416+=0x1){var _0x58d288=_0x4a477e[_0x169416][_0x2a90('0x26')]({'plain':!![]});_0x26ba4c['dialCheckDuplicateType']=_0x2d0fa7[_0x2a90('0x4f')][_0x2a90('0x99')]?_0x2d0fa7[_0x2a90('0x4f')]['dialCheckDuplicateType']:_0x26ba4c[_0x2a90('0x99')];switch(_0x26ba4c['dialCheckDuplicateType']){case _0x2a90('0x9a'):_0x5c4694=squel[_0x2a90('0x9b')]()[_0x2a90('0x9c')](_0x2a90('0x9d'))[_0x2a90('0x9e')](['phone','scheduledAt',_0x2a90('0x9f'),_0x2a90('0xa0'),_0x2a90('0x61'),'createdAt',_0x2a90('0x59')],squel[_0x2a90('0x7f')]()[_0x2a90('0x80')](_0x2a90('0xa1'),_0x2a90('0xa1'))[_0x2a90('0x80')](_0x2a90('0xa2'),_0x2a90('0xa3'))[_0x2a90('0x80')]('id',_0x2a90('0x9f'))[_0x2a90('0x80')](_0x58d288[_0x2a90('0xa4')][_0x2a90('0x86')](),_0x2a90('0xa0'))[_0x2a90('0x80')](_0x2d0fa7[_0x2a90('0x4a')]['id'][_0x2a90('0x86')](),_0x2a90('0x61'))[_0x2a90('0x80')](_0x2a90('0xa2'),'createdAt')[_0x2a90('0x80')]('NOW()',_0x2a90('0x59'))[_0x2a90('0x82')](_0x2a90('0xa5'))[_0x2a90('0x3f')](_0x2a90('0xa6'))[_0x2a90('0x3f')](_0x2a90('0xa7'),_0x58d288[_0x2a90('0xa4')]['toString']())['where'](_0x2a90('0xa8'))[_0x2a90('0x3f')](_0x2a90('0xa9'),squel[_0x2a90('0x7f')]()[_0x2a90('0x80')]('COALESCE(calleridnum,\x27\x27)')[_0x2a90('0x82')](_0x2a90('0xaa'))['where']('VoiceQueueId\x20=\x20?',_0x2d0fa7[_0x2a90('0x4a')]['id']['toString']()))[_0x2a90('0x3f')]('phone\x20NOT\x20IN\x20(?)',squel['select']()['field'](_0x2a90('0xab'))[_0x2a90('0x82')](_0x2a90('0x9d'))[_0x2a90('0x3f')](_0x2a90('0xac'),_0x2d0fa7['params']['id'][_0x2a90('0x86')]())))[_0x2a90('0x86')]();break;case'onlyIfOpen':_0x5c4694=squel[_0x2a90('0x9b')]()['into'](_0x2a90('0x9d'))[_0x2a90('0x9e')]([_0x2a90('0xa1'),_0x2a90('0xa3'),'ContactId','ListId',_0x2a90('0x61'),'createdAt',_0x2a90('0x59')],squel[_0x2a90('0x7f')]()[_0x2a90('0x80')](_0x2a90('0xa1'),'phone')[_0x2a90('0x80')](_0x2a90('0xa2'),_0x2a90('0xa3'))[_0x2a90('0x80')]('id',_0x2a90('0x9f'))[_0x2a90('0x80')](_0x58d288[_0x2a90('0xa4')][_0x2a90('0x86')](),_0x2a90('0xa0'))[_0x2a90('0x80')](_0x2d0fa7['params']['id'][_0x2a90('0x86')](),_0x2a90('0x61'))[_0x2a90('0x80')](_0x2a90('0xa2'),_0x2a90('0x58'))['field'](_0x2a90('0xa2'),_0x2a90('0x59'))[_0x2a90('0x82')](_0x2a90('0xa5'))[_0x2a90('0x3f')](_0x2a90('0xa6'))['where'](_0x2a90('0xa7'),_0x58d288[_0x2a90('0xa4')][_0x2a90('0x86')]())[_0x2a90('0x3f')](_0x2a90('0xa8'))[_0x2a90('0x3f')](_0x2a90('0xa9'),squel[_0x2a90('0x7f')]()['field'](_0x2a90('0xab'))[_0x2a90('0x82')]('cm_hopper')[_0x2a90('0x3f')](_0x2a90('0xac'),_0x2d0fa7['params']['id']['toString']())))[_0x2a90('0x86')]();break;default:_0x5c4694=squel['insert']()['into']('cm_hopper')[_0x2a90('0x9e')]([_0x2a90('0xa1'),'scheduledAt','ContactId',_0x2a90('0xa0'),'VoiceQueueId',_0x2a90('0x58'),_0x2a90('0x59')],squel[_0x2a90('0x7f')]()['field']('phone',_0x2a90('0xa1'))[_0x2a90('0x80')](_0x2a90('0xa2'),_0x2a90('0xa3'))['field']('id',_0x2a90('0x9f'))[_0x2a90('0x80')](_0x58d288[_0x2a90('0xa4')][_0x2a90('0x86')](),'ListId')[_0x2a90('0x80')](_0x2d0fa7[_0x2a90('0x4a')]['id'][_0x2a90('0x86')](),_0x2a90('0x61'))[_0x2a90('0x80')]('NOW()','createdAt')[_0x2a90('0x80')](_0x2a90('0xa2'),_0x2a90('0x59'))[_0x2a90('0x82')](_0x2a90('0xa5'))[_0x2a90('0x3f')](_0x2a90('0xa6'))[_0x2a90('0x3f')](_0x2a90('0xa7'),_0x58d288[_0x2a90('0xa4')]['toString']())[_0x2a90('0x3f')](_0x2a90('0xa8')))[_0x2a90('0x86')]();}_0x4cc134['push'](db['sequelize']['query'](_0x5c4694));}return BPromise[_0x2a90('0x8a')](_0x4cc134);}})[_0x2a90('0x25')](function(){return _0x2f0fa0;})['then'](respondWithResult(_0x22cfc,null))[_0x2a90('0x48')](handleError(_0x22cfc,null));};exports[_0x2a90('0xad')]=function(_0xc8ec3b,_0x23550d,_0x5a626b){return db['VoiceQueue']['find']({'where':{'id':_0xc8ec3b[_0x2a90('0x4a')]['id']}})[_0x2a90('0x25')](handleEntityNotFound(_0x23550d,null))[_0x2a90('0x25')](function(_0x3dbefa){if(_0x3dbefa){return _0x3dbefa[_0x2a90('0xad')](_0xc8ec3b[_0x2a90('0x38')][_0x2a90('0x7e')]);}})[_0x2a90('0x25')](function(_0x54146d){if(_0x54146d){return db['CmHopper'][_0x2a90('0x24')]({'where':{'ListId':_0xc8ec3b[_0x2a90('0x38')]['ids'],'VoiceQueueId':_0xc8ec3b[_0x2a90('0x4a')]['id']}})['then'](function(){return _0x54146d;});}})[_0x2a90('0x25')](respondWithStatusCode(_0x23550d,null))[_0x2a90('0x48')](handleError(_0x23550d,null));};exports['getBlackLists']=function(_0xb20993,_0x24a06e,_0x18c12d){var _0x2f29ed={};var _0x4cc5cd={};var _0x427409;var _0x19976c;return db[_0x2a90('0x33')]['findOne']({'where':{'id':_0xb20993['params']['id']}})['then'](handleEntityNotFound(_0x24a06e,null))[_0x2a90('0x25')](function(_0x4af7f5){if(_0x4af7f5){_0x427409=_0x4af7f5;_0x4cc5cd['model']=_[_0x2a90('0x4b')](db[_0x2a90('0x97')][_0x2a90('0x34')]);_0x4cc5cd[_0x2a90('0x38')]=_['keys'](_0xb20993[_0x2a90('0x38')]);_0x4cc5cd[_0x2a90('0x39')]=_['intersection'](_0x4cc5cd[_0x2a90('0x37')],_0x4cc5cd[_0x2a90('0x38')]);_0x2f29ed[_0x2a90('0x3b')]=_[_0x2a90('0x3a')](_0x4cc5cd[_0x2a90('0x37')],qs[_0x2a90('0x4c')](_0xb20993[_0x2a90('0x38')][_0x2a90('0x4c')]));_0x2f29ed[_0x2a90('0x3b')]=_0x2f29ed[_0x2a90('0x3b')][_0x2a90('0x4d')]?_0x2f29ed[_0x2a90('0x3b')]:_0x4cc5cd[_0x2a90('0x37')];_0x2f29ed[_0x2a90('0x3d')]=qs['sort'](_0xb20993[_0x2a90('0x38')]['sort']);_0x2f29ed[_0x2a90('0x3f')]=qs['filters'](_[_0x2a90('0x40')](_0xb20993[_0x2a90('0x38')],_0x4cc5cd[_0x2a90('0x39')]));if(_0xb20993[_0x2a90('0x38')][_0x2a90('0x2a')]){_0x2f29ed[_0x2a90('0x3f')]=_['merge'](_0x2f29ed[_0x2a90('0x3f')],{'$or':_[_0x2a90('0x2c')](_0x2f29ed['attributes'],function(_0x1d8b7a){var _0x13f9ee={};_0x13f9ee[_0x1d8b7a]={'$like':'%'+_0xb20993['query']['filter']+'%'};return _0x13f9ee;})});}_0x2f29ed=_[_0x2a90('0x41')]({},_0x2f29ed,_0xb20993['options']);return _0x427409[_0x2a90('0xae')](_0x2f29ed);}})[_0x2a90('0x25')](function(_0x54a060){if(_0x54a060){_0x19976c=_0x54a060['length'];if(!_0xb20993[_0x2a90('0x38')][_0x2a90('0x60')]('nolimit')){_0x2f29ed[_0x2a90('0x1e')]=qs[_0x2a90('0x1e')](_0xb20993['query'][_0x2a90('0x1e')]);_0x2f29ed[_0x2a90('0x1d')]=qs[_0x2a90('0x1d')](_0xb20993[_0x2a90('0x38')]['offset']);}return _0x427409['getBlackLists'](_0x2f29ed);}})[_0x2a90('0x25')](function(_0x759ff5){if(_0x759ff5){return _0x759ff5?{'count':_0x19976c,'rows':_0x759ff5}:null;}})[_0x2a90('0x25')](respondWithResult(_0x24a06e,null))[_0x2a90('0x48')](handleError(_0x24a06e,null));};exports[_0x2a90('0xaf')]=function(_0x497cee,_0x20451f,_0x3cccb0){var _0x24624d,_0x5e9a30;return db[_0x2a90('0x33')][_0x2a90('0x52')]({'where':{'id':_0x497cee[_0x2a90('0x4a')]['id']}})[_0x2a90('0x25')](handleEntityNotFound(_0x20451f,null))[_0x2a90('0x25')](function(_0x437558){if(_0x437558){_0x5e9a30=_0x437558;return _0x437558['addBlackLists'](_0x497cee[_0x2a90('0x4f')][_0x2a90('0x7e')],_['omit'](_0x497cee[_0x2a90('0x4f')],[_0x2a90('0x7e'),'id'])||{});}return null;})[_0x2a90('0x8f')](function(_0x5c5ef3){var _0x572734;_0x24624d=_0x5c5ef3||[];var _0x44abf5=[];if(_0x5c5ef3){for(var _0x20c95c=0x0;_0x20c95c<_0x5c5ef3[_0x2a90('0x4d')];_0x20c95c+=0x1){var _0x5d2fbc=_0x5c5ef3[_0x20c95c][_0x2a90('0x26')]({'plain':!![]});_0x572734=squel[_0x2a90('0x9b')]()[_0x2a90('0x9c')]('cm_hopper_black')[_0x2a90('0x9e')]([_0x2a90('0xa1'),'ContactId',_0x2a90('0xa0'),'VoiceQueueId','createdAt',_0x2a90('0x59')],squel[_0x2a90('0x7f')]()[_0x2a90('0x80')]('phone',_0x2a90('0xa1'))[_0x2a90('0x80')]('id',_0x2a90('0x9f'))[_0x2a90('0x80')](_0x5d2fbc[_0x2a90('0xa4')][_0x2a90('0x86')](),_0x2a90('0xa0'))['field'](_0x497cee['params']['id']['toString'](),_0x2a90('0x61'))['field'](_0x2a90('0xa2'),'createdAt')[_0x2a90('0x80')]('NOW()',_0x2a90('0x59'))[_0x2a90('0x82')](_0x2a90('0xa5'))[_0x2a90('0x3f')]('deletedAt\x20IS\x20NULL')['where'](_0x2a90('0xa7'),_0x5d2fbc[_0x2a90('0xa4')][_0x2a90('0x86')]())[_0x2a90('0x3f')]('phone\x20IS\x20NOT\x20NULL'))[_0x2a90('0x86')]();_0x44abf5[_0x2a90('0x91')](db[_0x2a90('0x87')][_0x2a90('0x38')](_0x572734));}return BPromise[_0x2a90('0x8a')](_0x44abf5);}})['then'](function(){return _0x24624d;})[_0x2a90('0x25')](respondWithResult(_0x20451f,null))[_0x2a90('0x48')](handleError(_0x20451f,null));};exports[_0x2a90('0xb0')]=function(_0x1d4647,_0x3bc679,_0x8cc4fa){return db[_0x2a90('0x33')][_0x2a90('0x52')]({'where':{'id':_0x1d4647['params']['id']}})['then'](handleEntityNotFound(_0x3bc679,null))[_0x2a90('0x25')](function(_0x5175b4){if(_0x5175b4){return _0x5175b4[_0x2a90('0xb0')](_0x1d4647[_0x2a90('0x38')][_0x2a90('0x7e')]);}})[_0x2a90('0x25')](function(_0x38f01f){if(_0x38f01f){return db['CmHopperBlack'][_0x2a90('0x24')]({'where':{'ListId':_0x1d4647[_0x2a90('0x38')][_0x2a90('0x7e')],'VoiceQueueId':_0x1d4647['params']['id']}})[_0x2a90('0x25')](function(){return _0x38f01f;});}})[_0x2a90('0x25')](respondWithStatusCode(_0x3bc679,null))[_0x2a90('0x48')](handleError(_0x3bc679,null));};
\ No newline at end of file
+var _0x46f3=['sequelize','transaction','each','UserVoiceQueue','findOrCreate','UserVoiceQueueRt','upsert','interface','format','emit','userVoiceQueue:save','removeTeams','select','field','from','team_has_voice_queues','join','user_has_teams','ut.TeamId\x20=\x20tq.TeamId','VoiceQueueId\x20=\x20?','ut.UserId\x20=\x20?','push','toString','QueryTypes','SELECT','all','compact','removeAgents','forEach','addAgents','ids','spread','isEmpty','SIP/%s','isArray','getAgents','getMembers','getLists','CmList','addLists','dialCheckDuplicateType','always','insert','into','cm_hopper','fromQuery','phone','ContactId','ListId','NOW()','scheduledAt','CmListId','cm_contacts','deletedAt\x20IS\x20NULL','ListId\x20=\x20?','phone\x20NOT\x20IN\x20(?)','COALESCE(calleridnum,\x27\x27)','cm_hopper_final','COALESCE(phone,\x27\x27)','onlyIfOpen','phone\x20IS\x20NOT\x20NULL','removeLists','getBlackLists','cm_hopper_black','removeBlackLists','html-pdf','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','mustache','util','path','sox','to-csv','ejs','squel','crypto','desk.js','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','defaults','localhost','./voiceQueue.socket','register','sendStatus','status','end','json','count','offset','limit','set','Content-Range','apply','reject','save','update','then','destroy','get','inbound','QueueCampaigns','outbound','filter','map','value','type','error','stack','name','send','index','VoiceQueue','rawAttributes','key','model','query','keys','intersection','attributes','fields','length','hasOwnProperty','order','sort','filters','pick','where','merge','VIRTUAL','options','includeAll','include','findAll','rows','catch','params','find','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','VoiceQueues','UserProfileSection','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','clone','omit','createdAt','updatedAt','userProfileId','UserProfileResource','getHoppers','findOne','CmHopperHistory','nolimit','VoiceQueueId','CmHopperFinal','getHopperBlacks','CmHopperBlack','getTeams','Team','addTeams','teams','User','Agents','online','voicePause','flatMap','penalty'];(function(_0x2fc5a9,_0x2a92f0){var _0x2b1b8b=function(_0x1f4e55){while(--_0x1f4e55){_0x2fc5a9['push'](_0x2fc5a9['shift']());}};_0x2b1b8b(++_0x2a92f0);}(_0x46f3,0xf9));var _0x346f=function(_0x5a9e50,_0x48dd72){_0x5a9e50=_0x5a9e50-0x0;var _0x26cbd8=_0x46f3[_0x5a9e50];return _0x26cbd8;};'use strict';var pdf=require(_0x346f('0x0'));var emlformat=require(_0x346f('0x1'));var rimraf=require(_0x346f('0x2'));var zipdir=require(_0x346f('0x3'));var jsonpatch=require(_0x346f('0x4'));var rp=require(_0x346f('0x5'));var moment=require(_0x346f('0x6'));var BPromise=require('bluebird');var Mustache=require(_0x346f('0x7'));var util=require(_0x346f('0x8'));var path=require(_0x346f('0x9'));var sox=require(_0x346f('0xa'));var csv=require(_0x346f('0xb'));var ejs=require(_0x346f('0xc'));var fs=require('fs');var _=require('lodash');var squel=require(_0x346f('0xd'));var crypto=require(_0x346f('0xe'));var jsforce=require('jsforce');var deskjs=require(_0x346f('0xf'));var toCsv=require(_0x346f('0xb'));var querystring=require('querystring');var Papa=require(_0x346f('0x10'));var Redis=require(_0x346f('0x11'));var authService=require('../../components/auth/service');var qs=require(_0x346f('0x12'));var as=require(_0x346f('0x13'));var hardwareService=require(_0x346f('0x14'));var logger=require(_0x346f('0x15'))(_0x346f('0x16'));var utils=require(_0x346f('0x17'));var config=require(_0x346f('0x18'));var licenseUtil=require(_0x346f('0x19'));var db=require(_0x346f('0x1a'))['db'];config[_0x346f('0x1b')]=_[_0x346f('0x1c')](config['redis'],{'host':_0x346f('0x1d'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x346f('0x1b')]));require(_0x346f('0x1e'))[_0x346f('0x1f')](socket);function respondWithStatusCode(_0x48525a,_0x3d3249){_0x3d3249=_0x3d3249||0xcc;return function(_0xfca475){if(_0xfca475){return _0x48525a[_0x346f('0x20')](_0x3d3249);}return _0x48525a[_0x346f('0x21')](_0x3d3249)[_0x346f('0x22')]();};}function respondWithResult(_0x37ee7c,_0x5e035c){_0x5e035c=_0x5e035c||0xc8;return function(_0x3cf89f){if(_0x3cf89f){return _0x37ee7c[_0x346f('0x21')](_0x5e035c)[_0x346f('0x23')](_0x3cf89f);}};}function respondWithFilteredResult(_0x5002ad,_0x13010c){return function(_0x2b30ed){if(_0x2b30ed){var _0x20d1d3=_0x2b30ed[_0x346f('0x24')],_0x2b0ad4=_0x13010c['offset'],_0x53c0ed=_0x13010c[_0x346f('0x25')]+_0x13010c[_0x346f('0x26')],_0xe9eecf;if(_0x53c0ed>=_0x20d1d3){_0x53c0ed=_0x20d1d3;_0xe9eecf=0xc8;}else{_0xe9eecf=0xce;}_0x5002ad['status'](_0xe9eecf);return _0x5002ad[_0x346f('0x27')](_0x346f('0x28'),_0x2b0ad4+'-'+_0x53c0ed+'/'+_0x20d1d3)[_0x346f('0x23')](_0x2b30ed);}return null;};}function patchUpdates(_0x1e319c){return function(_0x2311a8){try{jsonpatch[_0x346f('0x29')](_0x2311a8,_0x1e319c,!![]);}catch(_0x45d62b){return BPromise[_0x346f('0x2a')](_0x45d62b);}return _0x2311a8[_0x346f('0x2b')]();};}function saveUpdates(_0x2158c1,_0x519371){return function(_0x1d9a51){if(_0x1d9a51){return _0x1d9a51[_0x346f('0x2c')](_0x2158c1)[_0x346f('0x2d')](function(_0x46113f){return _0x46113f;});}return null;};}function removeEntity(_0x1d5e2b,_0x5a6ac0){return function(_0x14319e){if(_0x14319e){return _0x14319e[_0x346f('0x2e')]()['then'](function(){var _0x560615=_0x14319e[_0x346f('0x2f')]({'plain':!![]});var _0x4c3f30=[{'name':'VoiceQueues','value':_0x346f('0x30'),'ignore':![]},{'name':_0x346f('0x31'),'value':_0x346f('0x32'),'ignore':![]}];var _0x166bce=_(_0x4c3f30)[_0x346f('0x33')]('ignore')[_0x346f('0x34')](_0x346f('0x35'))[_0x346f('0x35')]();if(_['includes'](_0x166bce,_0x560615[_0x346f('0x36')])){return;}var _0x8223ea=_['find'](_0x4c3f30,[_0x346f('0x35'),_0x560615[_0x346f('0x36')]])['name'];return db['UserProfileResource'][_0x346f('0x2e')]({'where':{'type':_0x8223ea,'resourceId':_0x560615['id']}})[_0x346f('0x2d')](function(){return _0x14319e;});})[_0x346f('0x2d')](function(){_0x1d5e2b[_0x346f('0x21')](0xcc)[_0x346f('0x22')]();});}};}function handleEntityNotFound(_0x501eea,_0x5c928c){return function(_0x2aa6cc){if(!_0x2aa6cc){_0x501eea[_0x346f('0x20')](0x194);}return _0x2aa6cc;};}function handleError(_0x594961,_0x5103e5){_0x5103e5=_0x5103e5||0x1f4;return function(_0x3f6202){logger[_0x346f('0x37')](_0x3f6202[_0x346f('0x38')]);if(_0x3f6202[_0x346f('0x39')]){delete _0x3f6202[_0x346f('0x39')];}_0x594961[_0x346f('0x21')](_0x5103e5)[_0x346f('0x3a')](_0x3f6202);};}exports[_0x346f('0x3b')]=function(_0x235c97,_0x547c11){var _0x17d09f={},_0x24e81e={},_0x5e1b73={'count':0x0,'rows':[]};var _0x916a9c=_[_0x346f('0x34')](db[_0x346f('0x3c')][_0x346f('0x3d')],function(_0x167eef){return{'name':_0x167eef['fieldName'],'type':_0x167eef[_0x346f('0x36')][_0x346f('0x3e')]};});_0x24e81e[_0x346f('0x3f')]=_[_0x346f('0x34')](_0x916a9c,_0x346f('0x39'));_0x24e81e[_0x346f('0x40')]=_[_0x346f('0x41')](_0x235c97['query']);_0x24e81e['filters']=_[_0x346f('0x42')](_0x24e81e[_0x346f('0x3f')],_0x24e81e[_0x346f('0x40')]);_0x17d09f[_0x346f('0x43')]=_['intersection'](_0x24e81e[_0x346f('0x3f')],qs[_0x346f('0x44')](_0x235c97[_0x346f('0x40')]['fields']));_0x17d09f[_0x346f('0x43')]=_0x17d09f[_0x346f('0x43')][_0x346f('0x45')]?_0x17d09f['attributes']:_0x24e81e['model'];if(!_0x235c97[_0x346f('0x40')][_0x346f('0x46')]('nolimit')){_0x17d09f[_0x346f('0x26')]=qs[_0x346f('0x26')](_0x235c97[_0x346f('0x40')][_0x346f('0x26')]);_0x17d09f[_0x346f('0x25')]=qs[_0x346f('0x25')](_0x235c97[_0x346f('0x40')][_0x346f('0x25')]);}_0x17d09f[_0x346f('0x47')]=qs[_0x346f('0x48')](_0x235c97[_0x346f('0x40')][_0x346f('0x48')]);_0x17d09f['where']=qs[_0x346f('0x49')](_[_0x346f('0x4a')](_0x235c97[_0x346f('0x40')],_0x24e81e['filters']),_0x916a9c);if(_0x235c97[_0x346f('0x40')]['filter']){_0x17d09f[_0x346f('0x4b')]=_[_0x346f('0x4c')](_0x17d09f[_0x346f('0x4b')],{'$or':_[_0x346f('0x34')](_0x916a9c,function(_0x1c4604){if(_0x1c4604[_0x346f('0x36')]!==_0x346f('0x4d')){var _0x9da185={};_0x9da185[_0x1c4604['name']]={'$like':'%'+_0x235c97['query'][_0x346f('0x33')]+'%'};return _0x9da185;}})});}_0x17d09f=_[_0x346f('0x4c')]({},_0x17d09f,_0x235c97[_0x346f('0x4e')]);var _0x73c34d={'where':_0x17d09f[_0x346f('0x4b')]};return db[_0x346f('0x3c')][_0x346f('0x24')](_0x73c34d)[_0x346f('0x2d')](function(_0x12a0eb){_0x5e1b73['count']=_0x12a0eb;if(_0x235c97['query'][_0x346f('0x4f')]){_0x17d09f[_0x346f('0x50')]=[{'all':!![]}];}return db['VoiceQueue'][_0x346f('0x51')](_0x17d09f);})[_0x346f('0x2d')](function(_0x453f38){_0x5e1b73[_0x346f('0x52')]=_0x453f38;return _0x5e1b73;})[_0x346f('0x2d')](respondWithFilteredResult(_0x547c11,_0x17d09f))[_0x346f('0x53')](handleError(_0x547c11,null));};exports['show']=function(_0x1e7bb0,_0x5a7ec8){var _0x2a46cf={'raw':![],'where':{'id':_0x1e7bb0[_0x346f('0x54')]['id']}},_0xe49feb={};_0xe49feb[_0x346f('0x3f')]=_[_0x346f('0x41')](db[_0x346f('0x3c')][_0x346f('0x3d')]);_0xe49feb['query']=_[_0x346f('0x41')](_0x1e7bb0['query']);_0xe49feb['filters']=_[_0x346f('0x42')](_0xe49feb[_0x346f('0x3f')],_0xe49feb[_0x346f('0x40')]);_0x2a46cf[_0x346f('0x43')]=_[_0x346f('0x42')](_0xe49feb[_0x346f('0x3f')],qs['fields'](_0x1e7bb0['query'][_0x346f('0x44')]));_0x2a46cf[_0x346f('0x43')]=_0x2a46cf[_0x346f('0x43')][_0x346f('0x45')]?_0x2a46cf['attributes']:_0xe49feb[_0x346f('0x3f')];if(_0x1e7bb0[_0x346f('0x40')][_0x346f('0x4f')]){_0x2a46cf[_0x346f('0x50')]=[{'all':!![]}];}_0x2a46cf=_['merge']({},_0x2a46cf,_0x1e7bb0[_0x346f('0x4e')]);return db['VoiceQueue'][_0x346f('0x55')](_0x2a46cf)['then'](handleEntityNotFound(_0x5a7ec8,null))[_0x346f('0x2d')](respondWithResult(_0x5a7ec8,null))[_0x346f('0x53')](handleError(_0x5a7ec8,null));};exports['create']=function(_0x45f85f,_0x545eaa){return db[_0x346f('0x3c')][_0x346f('0x56')](_0x45f85f[_0x346f('0x57')],{})[_0x346f('0x2d')](function(_0x10c631){var _0x7603c8=_0x45f85f[_0x346f('0x58')][_0x346f('0x2f')]({'plain':!![]});if(!_0x7603c8)throw new Error(_0x346f('0x59'));if(_0x7603c8[_0x346f('0x5a')]===_0x346f('0x58')){var _0x2438c9=_0x10c631[_0x346f('0x2f')]({'plain':!![]});var _0x275854=[{'name':_0x346f('0x5b'),'value':_0x346f('0x30')},{'name':'QueueCampaigns','value':_0x346f('0x32')}];var _0x53e571=_[_0x346f('0x55')](_0x275854,[_0x346f('0x35'),_0x2438c9[_0x346f('0x36')]])[_0x346f('0x39')];return db[_0x346f('0x5c')][_0x346f('0x55')]({'where':{'name':_0x53e571,'userProfileId':_0x7603c8['userProfileId']},'raw':!![]})[_0x346f('0x2d')](function(_0x4d7bfd){if(_0x4d7bfd&&_0x4d7bfd[_0x346f('0x5d')]===0x0){return db['UserProfileResource'][_0x346f('0x56')]({'name':_0x2438c9['name'],'resourceId':_0x2438c9['id'],'type':_0x4d7bfd[_0x346f('0x39')],'sectionId':_0x4d7bfd['id']},{})[_0x346f('0x2d')](function(){return _0x10c631;});}else{return _0x10c631;}})[_0x346f('0x53')](function(_0x5cfe44){logger[_0x346f('0x37')](_0x346f('0x5e'),_0x5cfe44);throw _0x5cfe44;});}return _0x10c631;})[_0x346f('0x2d')](respondWithResult(_0x545eaa,0xc9))[_0x346f('0x53')](handleError(_0x545eaa,null));};exports[_0x346f('0x5f')]=function(_0xb1e0d7,_0x4ed3bc){var _0x1c1256={'where':{'id':_0xb1e0d7[_0x346f('0x54')]['id']}},_0x428aea={};_0x428aea[_0x346f('0x3f')]=_[_0x346f('0x41')](db[_0x346f('0x3c')]['rawAttributes']);_0x1c1256[_0x346f('0x43')]=_[_0x346f('0x42')](_0x428aea[_0x346f('0x3f')],qs[_0x346f('0x44')](_0xb1e0d7['query'][_0x346f('0x44')]));_0x1c1256['attributes']=_0x1c1256[_0x346f('0x43')][_0x346f('0x45')]?_0x1c1256['attributes']:_0x428aea[_0x346f('0x3f')];if(_0xb1e0d7['query'][_0x346f('0x4f')]){_0x1c1256['include']=[{'all':!![]}];}_0x1c1256=_[_0x346f('0x4c')]({},_0x1c1256,_0xb1e0d7['options']);return db[_0x346f('0x3c')][_0x346f('0x55')](_0x1c1256)['then'](handleEntityNotFound(_0x4ed3bc,null))['then'](function(_0x5ba986){if(_0x5ba986){var _0x1b3837=_0x5ba986[_0x346f('0x2f')]({'plain':!![]});_0x1b3837=qs[_0x346f('0x60')](_0x1b3837,['id',_0x346f('0x61'),_0x346f('0x62')]);_0xb1e0d7['body']=_[_0x346f('0x60')](_0xb1e0d7[_0x346f('0x57')],['id',_0x346f('0x61'),_0x346f('0x62')]);return db[_0x346f('0x3c')][_0x346f('0x56')](_[_0x346f('0x4c')](_0x1b3837,_0xb1e0d7[_0x346f('0x57')]),{'include':_0xb1e0d7['query']['includeAll']?[{'all':!![]}]:undefined})[_0x346f('0x2d')](function(_0x14d111){var _0x503732=_0xb1e0d7[_0x346f('0x58')][_0x346f('0x2f')]({'plain':!![]});if(!_0x503732)throw new Error(_0x346f('0x59'));if(_0x503732['role']==='user'){var _0x14a25f=_0x14d111[_0x346f('0x2f')]({'plain':!![]});var _0x2e35ea=[{'name':_0x346f('0x5b'),'value':_0x346f('0x30')},{'name':'QueueCampaigns','value':_0x346f('0x32')}];var _0x4b17b9=_[_0x346f('0x55')](_0x2e35ea,['value',_0x14a25f[_0x346f('0x36')]])[_0x346f('0x39')];return db[_0x346f('0x5c')][_0x346f('0x55')]({'where':{'name':_0x4b17b9,'userProfileId':_0x503732[_0x346f('0x63')]},'raw':!![]})['then'](function(_0x34ac40){if(_0x34ac40&&_0x34ac40['autoAssociation']===0x0){return db[_0x346f('0x64')][_0x346f('0x56')]({'name':_0x14a25f['name'],'resourceId':_0x14a25f['id'],'type':_0x34ac40[_0x346f('0x39')],'sectionId':_0x34ac40['id']},{})['then'](function(){return _0x14d111;});}else{return _0x14d111;}})[_0x346f('0x53')](function(_0x384786){logger[_0x346f('0x37')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x384786);throw _0x384786;});}return _0x14d111;});}})['then'](respondWithResult(_0x4ed3bc,0xc9))[_0x346f('0x53')](handleError(_0x4ed3bc,null));};exports[_0x346f('0x2c')]=function(_0x20ec67,_0x3ae29e){if(_0x20ec67['body']['id']){delete _0x20ec67[_0x346f('0x57')]['id'];}return db[_0x346f('0x3c')][_0x346f('0x55')]({'where':{'id':_0x20ec67[_0x346f('0x54')]['id']}})[_0x346f('0x2d')](handleEntityNotFound(_0x3ae29e,null))[_0x346f('0x2d')](saveUpdates(_0x20ec67[_0x346f('0x57')],null))[_0x346f('0x2d')](respondWithResult(_0x3ae29e,null))[_0x346f('0x53')](handleError(_0x3ae29e,null));};exports[_0x346f('0x2e')]=function(_0x3bcd2e,_0x169d3d){return db[_0x346f('0x3c')]['find']({'where':{'id':_0x3bcd2e[_0x346f('0x54')]['id']}})['then'](handleEntityNotFound(_0x169d3d,null))[_0x346f('0x2d')](removeEntity(_0x169d3d,null))[_0x346f('0x53')](handleError(_0x169d3d,null));};exports[_0x346f('0x65')]=function(_0x2e144f,_0x1b7075,_0x1fefdb){var _0x21e802={'raw':![],'where':{}};var _0xd3b38b={};var _0x26a7d8={'count':0x0,'rows':[]};return db[_0x346f('0x3c')][_0x346f('0x66')]({'where':{'id':_0x2e144f[_0x346f('0x54')]['id']}})[_0x346f('0x2d')](handleEntityNotFound(_0x1b7075,null))[_0x346f('0x2d')](function(_0x3f097c){if(_0x3f097c){_0xd3b38b[_0x346f('0x3f')]=_[_0x346f('0x41')](db['CmHopper']['rawAttributes']);_0xd3b38b[_0x346f('0x40')]=_[_0x346f('0x41')](_0x2e144f['query']);_0xd3b38b[_0x346f('0x49')]=_[_0x346f('0x42')](_0xd3b38b['model'],_0xd3b38b[_0x346f('0x40')]);_0x21e802[_0x346f('0x43')]=_[_0x346f('0x42')](_0xd3b38b[_0x346f('0x3f')],qs['fields'](_0x2e144f[_0x346f('0x40')][_0x346f('0x44')]));_0x21e802[_0x346f('0x43')]=_0x21e802[_0x346f('0x43')][_0x346f('0x45')]?_0x21e802[_0x346f('0x43')]:_0xd3b38b['model'];if(!_0x2e144f[_0x346f('0x40')][_0x346f('0x46')]('nolimit')){_0x21e802[_0x346f('0x26')]=qs['limit'](_0x2e144f[_0x346f('0x40')][_0x346f('0x26')]);_0x21e802[_0x346f('0x25')]=qs['offset'](_0x2e144f['query'][_0x346f('0x25')]);}_0x21e802[_0x346f('0x47')]=qs[_0x346f('0x48')](_0x2e144f[_0x346f('0x40')]['sort']);_0x21e802[_0x346f('0x4b')]=qs['filters'](_[_0x346f('0x4a')](_0x2e144f[_0x346f('0x40')],_0xd3b38b[_0x346f('0x49')]));_0x21e802[_0x346f('0x4b')]['VoiceQueueId']=_0x3f097c['id'];if(_0x2e144f['query']['filter']){_0x21e802[_0x346f('0x4b')]=_[_0x346f('0x4c')](_0x21e802[_0x346f('0x4b')],{'$or':_[_0x346f('0x34')](_0x21e802[_0x346f('0x43')],function(_0x3c6eac){var _0x2a9a01={};_0x2a9a01[_0x3c6eac]={'$like':'%'+_0x2e144f[_0x346f('0x40')][_0x346f('0x33')]+'%'};return _0x2a9a01;})});}_0x21e802=_[_0x346f('0x4c')]({},_0x21e802,_0x2e144f['options']);return db['CmHopper']['count']({'where':_0x21e802[_0x346f('0x4b')]})[_0x346f('0x2d')](function(_0x2942b1){_0x26a7d8[_0x346f('0x24')]=_0x2942b1;if(_0x2e144f[_0x346f('0x40')][_0x346f('0x4f')]){_0x21e802['include']=[{'all':!![]}];}return db['CmHopper'][_0x346f('0x51')](_0x21e802);})[_0x346f('0x2d')](function(_0xb93cd8){_0x26a7d8[_0x346f('0x52')]=_0xb93cd8;return _0x26a7d8;});}})[_0x346f('0x2d')](respondWithFilteredResult(_0x1b7075,_0x21e802))['catch'](handleError(_0x1b7075,null));};exports['getHopperHistories']=function(_0x4a77cd,_0x359b80,_0x17b450){var _0x380e9b={'raw':!![],'where':{}};var _0x5da2e2={};var _0x582d2e={'count':0x0,'rows':[]};return db['VoiceQueue'][_0x346f('0x66')]({'where':{'id':_0x4a77cd[_0x346f('0x54')]['id']}})[_0x346f('0x2d')](handleEntityNotFound(_0x359b80,null))['then'](function(_0x2cfee2){if(_0x2cfee2){_0x5da2e2['model']=_[_0x346f('0x41')](db[_0x346f('0x67')][_0x346f('0x3d')]);_0x5da2e2[_0x346f('0x40')]=_[_0x346f('0x41')](_0x4a77cd[_0x346f('0x40')]);_0x5da2e2[_0x346f('0x49')]=_[_0x346f('0x42')](_0x5da2e2[_0x346f('0x3f')],_0x5da2e2[_0x346f('0x40')]);_0x380e9b[_0x346f('0x43')]=_[_0x346f('0x42')](_0x5da2e2[_0x346f('0x3f')],qs[_0x346f('0x44')](_0x4a77cd['query'][_0x346f('0x44')]));_0x380e9b['attributes']=_0x380e9b['attributes']['length']?_0x380e9b[_0x346f('0x43')]:_0x5da2e2['model'];if(!_0x4a77cd[_0x346f('0x40')][_0x346f('0x46')](_0x346f('0x68'))){_0x380e9b[_0x346f('0x26')]=qs['limit'](_0x4a77cd[_0x346f('0x40')]['limit']);_0x380e9b[_0x346f('0x25')]=qs[_0x346f('0x25')](_0x4a77cd[_0x346f('0x40')]['offset']);}_0x380e9b[_0x346f('0x47')]=qs[_0x346f('0x48')](_0x4a77cd['query']['sort']);_0x380e9b[_0x346f('0x4b')]=qs[_0x346f('0x49')](_[_0x346f('0x4a')](_0x4a77cd[_0x346f('0x40')],_0x5da2e2['filters']));_0x380e9b[_0x346f('0x4b')][_0x346f('0x69')]=_0x2cfee2['id'];if(_0x4a77cd['query']['filter']){_0x380e9b['where']=_[_0x346f('0x4c')](_0x380e9b[_0x346f('0x4b')],{'$or':_['map'](_0x380e9b['attributes'],function(_0x382cd7){var _0xa756da={};_0xa756da[_0x382cd7]={'$like':'%'+_0x4a77cd[_0x346f('0x40')][_0x346f('0x33')]+'%'};return _0xa756da;})});}_0x380e9b=_['merge']({},_0x380e9b,_0x4a77cd[_0x346f('0x4e')]);return db[_0x346f('0x67')][_0x346f('0x24')]({'where':_0x380e9b[_0x346f('0x4b')]})[_0x346f('0x2d')](function(_0x33d20f){_0x582d2e[_0x346f('0x24')]=_0x33d20f;if(_0x4a77cd[_0x346f('0x40')][_0x346f('0x4f')]){_0x380e9b['include']=[{'all':!![]}];}return db[_0x346f('0x67')][_0x346f('0x51')](_0x380e9b);})[_0x346f('0x2d')](function(_0x2fdeba){_0x582d2e['rows']=_0x2fdeba;return _0x582d2e;});}})[_0x346f('0x2d')](respondWithFilteredResult(_0x359b80,_0x380e9b))['catch'](handleError(_0x359b80,null));};exports['getHopperFinals']=function(_0x48f29b,_0x56d3db,_0x565f93){var _0x421469={'raw':!![],'where':{}};var _0x2b7ed8={};var _0x576d86={'count':0x0,'rows':[]};return db[_0x346f('0x3c')][_0x346f('0x66')]({'where':{'id':_0x48f29b[_0x346f('0x54')]['id']}})[_0x346f('0x2d')](handleEntityNotFound(_0x56d3db,null))[_0x346f('0x2d')](function(_0x3c607b){if(_0x3c607b){_0x2b7ed8[_0x346f('0x3f')]=_[_0x346f('0x41')](db[_0x346f('0x6a')][_0x346f('0x3d')]);_0x2b7ed8['query']=_[_0x346f('0x41')](_0x48f29b[_0x346f('0x40')]);_0x2b7ed8['filters']=_[_0x346f('0x42')](_0x2b7ed8[_0x346f('0x3f')],_0x2b7ed8[_0x346f('0x40')]);_0x421469[_0x346f('0x43')]=_[_0x346f('0x42')](_0x2b7ed8[_0x346f('0x3f')],qs[_0x346f('0x44')](_0x48f29b[_0x346f('0x40')][_0x346f('0x44')]));_0x421469['attributes']=_0x421469['attributes'][_0x346f('0x45')]?_0x421469[_0x346f('0x43')]:_0x2b7ed8['model'];if(!_0x48f29b[_0x346f('0x40')]['hasOwnProperty']('nolimit')){_0x421469['limit']=qs[_0x346f('0x26')](_0x48f29b[_0x346f('0x40')][_0x346f('0x26')]);_0x421469['offset']=qs[_0x346f('0x25')](_0x48f29b[_0x346f('0x40')][_0x346f('0x25')]);}_0x421469[_0x346f('0x47')]=qs[_0x346f('0x48')](_0x48f29b[_0x346f('0x40')][_0x346f('0x48')]);_0x421469[_0x346f('0x4b')]=qs[_0x346f('0x49')](_[_0x346f('0x4a')](_0x48f29b[_0x346f('0x40')],_0x2b7ed8[_0x346f('0x49')]));_0x421469[_0x346f('0x4b')][_0x346f('0x69')]=_0x3c607b['id'];if(_0x48f29b[_0x346f('0x40')][_0x346f('0x33')]){_0x421469[_0x346f('0x4b')]=_[_0x346f('0x4c')](_0x421469['where'],{'$or':_[_0x346f('0x34')](_0x421469[_0x346f('0x43')],function(_0x1691be){var _0x318358={};_0x318358[_0x1691be]={'$like':'%'+_0x48f29b['query'][_0x346f('0x33')]+'%'};return _0x318358;})});}_0x421469=_[_0x346f('0x4c')]({},_0x421469,_0x48f29b[_0x346f('0x4e')]);return db[_0x346f('0x6a')][_0x346f('0x24')]({'where':_0x421469[_0x346f('0x4b')]})[_0x346f('0x2d')](function(_0x1aac17){_0x576d86['count']=_0x1aac17;if(_0x48f29b[_0x346f('0x40')][_0x346f('0x4f')]){_0x421469[_0x346f('0x50')]=[{'all':!![]}];}return db[_0x346f('0x6a')][_0x346f('0x51')](_0x421469);})[_0x346f('0x2d')](function(_0x539f0c){_0x576d86[_0x346f('0x52')]=_0x539f0c;return _0x576d86;});}})[_0x346f('0x2d')](respondWithFilteredResult(_0x56d3db,_0x421469))[_0x346f('0x53')](handleError(_0x56d3db,null));};exports[_0x346f('0x6b')]=function(_0x27a504,_0xfb39d1,_0x2aa63f){var _0x2b7e53={'raw':!![],'where':{}};var _0x6675f6={};var _0x1134b9={'count':0x0,'rows':[]};return db[_0x346f('0x3c')][_0x346f('0x66')]({'where':{'id':_0x27a504[_0x346f('0x54')]['id']}})[_0x346f('0x2d')](handleEntityNotFound(_0xfb39d1,null))[_0x346f('0x2d')](function(_0x280eed){if(_0x280eed){_0x6675f6['model']=_[_0x346f('0x41')](db[_0x346f('0x6c')]['rawAttributes']);_0x6675f6[_0x346f('0x40')]=_['keys'](_0x27a504[_0x346f('0x40')]);_0x6675f6[_0x346f('0x49')]=_[_0x346f('0x42')](_0x6675f6[_0x346f('0x3f')],_0x6675f6[_0x346f('0x40')]);_0x2b7e53[_0x346f('0x43')]=_[_0x346f('0x42')](_0x6675f6['model'],qs[_0x346f('0x44')](_0x27a504[_0x346f('0x40')][_0x346f('0x44')]));_0x2b7e53[_0x346f('0x43')]=_0x2b7e53[_0x346f('0x43')]['length']?_0x2b7e53['attributes']:_0x6675f6['model'];if(!_0x27a504['query'][_0x346f('0x46')]('nolimit')){_0x2b7e53[_0x346f('0x26')]=qs[_0x346f('0x26')](_0x27a504[_0x346f('0x40')][_0x346f('0x26')]);_0x2b7e53[_0x346f('0x25')]=qs['offset'](_0x27a504['query'][_0x346f('0x25')]);}_0x2b7e53[_0x346f('0x47')]=qs[_0x346f('0x48')](_0x27a504[_0x346f('0x40')][_0x346f('0x48')]);_0x2b7e53[_0x346f('0x4b')]=qs[_0x346f('0x49')](_['pick'](_0x27a504[_0x346f('0x40')],_0x6675f6[_0x346f('0x49')]));_0x2b7e53[_0x346f('0x4b')]['VoiceQueueId']=_0x280eed['id'];if(_0x27a504[_0x346f('0x40')][_0x346f('0x33')]){_0x2b7e53[_0x346f('0x4b')]=_[_0x346f('0x4c')](_0x2b7e53[_0x346f('0x4b')],{'$or':_[_0x346f('0x34')](_0x2b7e53[_0x346f('0x43')],function(_0x243aa9){var _0x558aca={};_0x558aca[_0x243aa9]={'$like':'%'+_0x27a504[_0x346f('0x40')][_0x346f('0x33')]+'%'};return _0x558aca;})});}_0x2b7e53=_[_0x346f('0x4c')]({},_0x2b7e53,_0x27a504[_0x346f('0x4e')]);return db[_0x346f('0x6c')][_0x346f('0x24')]({'where':_0x2b7e53[_0x346f('0x4b')]})['then'](function(_0x13a04a){_0x1134b9[_0x346f('0x24')]=_0x13a04a;if(_0x27a504[_0x346f('0x40')][_0x346f('0x4f')]){_0x2b7e53[_0x346f('0x50')]=[{'all':!![]}];}return db[_0x346f('0x6c')][_0x346f('0x51')](_0x2b7e53);})[_0x346f('0x2d')](function(_0x2623db){_0x1134b9['rows']=_0x2623db;return _0x1134b9;});}})[_0x346f('0x2d')](respondWithFilteredResult(_0xfb39d1,_0x2b7e53))[_0x346f('0x53')](handleError(_0xfb39d1,null));};exports[_0x346f('0x6d')]=function(_0x14dd21,_0x4e31d2,_0x31ad9a){var _0x58f9ed={};var _0x3c3895={};var _0x5220ba;var _0x44d737;return db[_0x346f('0x3c')][_0x346f('0x66')]({'where':{'id':_0x14dd21[_0x346f('0x54')]['id']}})['then'](handleEntityNotFound(_0x4e31d2,null))[_0x346f('0x2d')](function(_0xc23b7b){if(_0xc23b7b){_0x5220ba=_0xc23b7b;_0x3c3895[_0x346f('0x3f')]=_[_0x346f('0x41')](db[_0x346f('0x6e')][_0x346f('0x3d')]);_0x3c3895[_0x346f('0x40')]=_[_0x346f('0x41')](_0x14dd21[_0x346f('0x40')]);_0x3c3895[_0x346f('0x49')]=_[_0x346f('0x42')](_0x3c3895[_0x346f('0x3f')],_0x3c3895[_0x346f('0x40')]);_0x58f9ed[_0x346f('0x43')]=_[_0x346f('0x42')](_0x3c3895['model'],qs[_0x346f('0x44')](_0x14dd21[_0x346f('0x40')][_0x346f('0x44')]));_0x58f9ed[_0x346f('0x43')]=_0x58f9ed[_0x346f('0x43')]['length']?_0x58f9ed[_0x346f('0x43')]:_0x3c3895[_0x346f('0x3f')];_0x58f9ed[_0x346f('0x47')]=qs['sort'](_0x14dd21[_0x346f('0x40')][_0x346f('0x48')]);_0x58f9ed[_0x346f('0x4b')]=qs[_0x346f('0x49')](_[_0x346f('0x4a')](_0x14dd21[_0x346f('0x40')],_0x3c3895[_0x346f('0x49')]));if(_0x14dd21['query'][_0x346f('0x33')]){_0x58f9ed['where']=_[_0x346f('0x4c')](_0x58f9ed[_0x346f('0x4b')],{'$or':_['map'](_0x58f9ed[_0x346f('0x43')],function(_0x5f1772){var _0x5ce42f={};_0x5ce42f[_0x5f1772]={'$like':'%'+_0x14dd21[_0x346f('0x40')][_0x346f('0x33')]+'%'};return _0x5ce42f;})});}_0x58f9ed=_[_0x346f('0x4c')]({},_0x58f9ed,_0x14dd21[_0x346f('0x4e')]);return _0x5220ba['getTeams'](_0x58f9ed);}})[_0x346f('0x2d')](function(_0x3b51f6){if(_0x3b51f6){_0x44d737=_0x3b51f6['length'];if(!_0x14dd21[_0x346f('0x40')]['hasOwnProperty'](_0x346f('0x68'))){_0x58f9ed[_0x346f('0x26')]=qs[_0x346f('0x26')](_0x14dd21[_0x346f('0x40')][_0x346f('0x26')]);_0x58f9ed['offset']=qs['offset'](_0x14dd21[_0x346f('0x40')][_0x346f('0x25')]);}return _0x5220ba[_0x346f('0x6d')](_0x58f9ed);}})[_0x346f('0x2d')](function(_0x26c739){if(_0x26c739){return _0x26c739?{'count':_0x44d737,'rows':_0x26c739}:null;}})[_0x346f('0x2d')](respondWithResult(_0x4e31d2,null))[_0x346f('0x53')](handleError(_0x4e31d2,null));};exports[_0x346f('0x6f')]=function(_0x1e6fdc,_0x58b7a0,_0x5d8ac8){var _0x2957e9=_0x1e6fdc['body'][_0x346f('0x70')];var _0xd006a5=_[_0x346f('0x34')](_0x2957e9,'id');return db[_0x346f('0x6e')][_0x346f('0x51')]({'where':{'id':_0xd006a5},'attributes':['id'],'include':[{'model':db[_0x346f('0x71')],'as':_0x346f('0x72'),'attributes':['id',_0x346f('0x39'),_0x346f('0x73'),_0x346f('0x74'),'interface'],'raw':!![]}]})['then'](function(_0x7ebb92){if(_0x7ebb92){var _0x45692b=_[_0x346f('0x75')](_0x7ebb92,function(_0x35cdcb){var _0x2459c6=_0x35cdcb[_0x346f('0x2f')]({'plain':!![]});_0x2459c6['Agents']['forEach'](function(_0x2084d5){_0x2084d5[_0x346f('0x76')]=_['find'](_0x2957e9,{'id':_0x2459c6['id']})[_0x346f('0x76')];});return _0x2459c6[_0x346f('0x72')];});return db['VoiceQueue'][_0x346f('0x55')]({'where':{'id':_0x1e6fdc[_0x346f('0x54')]['id']}})[_0x346f('0x2d')](function(_0x228876){return db[_0x346f('0x77')][_0x346f('0x78')](function(_0x373081){return _0x228876[_0x346f('0x6f')](_0xd006a5,{'transaction':_0x373081})['then'](function(){return BPromise[_0x346f('0x79')](_0x45692b,function(_0x489f49){return db[_0x346f('0x7a')][_0x346f('0x7b')]({'where':{'UserId':_0x489f49['id'],'VoiceQueueId':_0x1e6fdc[_0x346f('0x54')]['id']},'defaults':{'penalty':_0x489f49[_0x346f('0x76')]},'transaction':_0x373081});});})[_0x346f('0x2d')](function(){return BPromise[_0x346f('0x79')](_[_0x346f('0x33')](_0x45692b,{'online':!![]}),function(_0x286611){return db[_0x346f('0x7c')][_0x346f('0x7d')]({'membername':_0x286611['name'],'UserId':_0x286611['id'],'queue_name':_0x228876[_0x346f('0x39')],'VoiceQueueId':_0x228876['id'],'interface':_['isNil'](_0x286611[_0x346f('0x7e')])?util[_0x346f('0x7f')]('SIP/%s',_0x286611['name']):_0x286611[_0x346f('0x7e')],'paused':_0x286611[_0x346f('0x74')]||![],'penalty':_0x286611[_0x346f('0x76')]},{'transaction':_0x373081});});})[_0x346f('0x2d')](function(){_0x45692b['forEach'](function(_0x594b16){socket[_0x346f('0x80')](_0x346f('0x81'),{'UserId':_0x594b16['id'],'VoiceQueueId':_0x228876['id']});});});});});}})['then'](respondWithStatusCode(_0x58b7a0,null))['catch'](handleError(_0x58b7a0,null));};exports[_0x346f('0x82')]=function(_0x59182a,_0x514008,_0x1daa86){return db[_0x346f('0x6e')][_0x346f('0x51')]({'where':{'id':_0x59182a[_0x346f('0x40')]['ids']},'attributes':['id'],'include':[{'model':db['User'],'as':_0x346f('0x72'),'attributes':['id'],'raw':!![]}]})['then'](handleEntityNotFound(_0x514008,null))[_0x346f('0x2d')](function(_0x1f37b2){var _0x2b5bde=_['map'](_0x1f37b2,'id');var _0x5d8a31=[];var _0xd89dbb=[];var _0x1b37de=squel[_0x346f('0x83')]();_0x1b37de[_0x346f('0x84')]('tq.TeamId')[_0x346f('0x85')](_0x346f('0x86'),'tq')[_0x346f('0x87')](_0x346f('0x88'),'ut',_0x346f('0x89'))[_0x346f('0x4b')](_0x346f('0x8a'),_0x59182a[_0x346f('0x54')]['id']);for(var _0x22c2d4=0x0;_0x22c2d4<_0x1f37b2[_0x346f('0x45')];_0x22c2d4+=0x1){let _0x295ea3=_0x1f37b2[_0x22c2d4];for(var _0x77f940=0x0;_0x77f940<_0x295ea3[_0x346f('0x72')][_0x346f('0x45')];_0x77f940+=0x1){let _0x9df2d4=_0x295ea3[_0x346f('0x72')][_0x77f940];var _0x337e14=_0x1b37de[_0x346f('0x5f')]();_0x337e14[_0x346f('0x4b')](_0x346f('0x8b'),_0x9df2d4['id']);_0xd89dbb[_0x346f('0x8c')](db[_0x346f('0x77')][_0x346f('0x40')](_0x337e14[_0x346f('0x8d')](),{'type':db[_0x346f('0x77')][_0x346f('0x8e')][_0x346f('0x8f')]})['then'](function(_0x472cf2){if(_0x472cf2[_0x346f('0x45')]===0x1){return _0x9df2d4['id'];}else{var _0x57e69b=_['every'](_[_0x346f('0x34')](_0x472cf2,'TeamId'),function(_0x42c97a){return _['includes'](_0x2b5bde,_0x42c97a);});if(_0x57e69b){return _0x9df2d4['id'];}}}));}}return BPromise[_0x346f('0x90')](_0xd89dbb)[_0x346f('0x2d')](function(_0x106b58){_0x5d8a31=_(_0x5d8a31)['union'](_0x106b58)[_0x346f('0x91')]()[_0x346f('0x35')]();return db[_0x346f('0x3c')][_0x346f('0x55')]({'where':{'id':_0x59182a[_0x346f('0x54')]['id']}})[_0x346f('0x2d')](function(_0x8d73c){return db[_0x346f('0x77')][_0x346f('0x78')](function(_0x3bc903){return _0x8d73c[_0x346f('0x82')](_0x59182a[_0x346f('0x40')]['ids'],{'transaction':_0x3bc903})['then'](function(){if(!_['isEmpty'](_0x5d8a31)){return _0x8d73c[_0x346f('0x92')](_0x5d8a31,{'transaction':_0x3bc903})[_0x346f('0x2d')](function(){return db[_0x346f('0x7c')][_0x346f('0x2e')]({'where':{'VoiceQueueId':_0x59182a[_0x346f('0x54')]['id'],'UserId':_0x5d8a31},'transaction':_0x3bc903});});}})[_0x346f('0x2d')](function(){_0x5d8a31[_0x346f('0x93')](function(_0x2fb725){socket['emit']('userVoiceQueue:remove',{'UserId':_0x2fb725,'VoiceQueueId':_0x8d73c['id']});});});});});});})[_0x346f('0x2d')](respondWithStatusCode(_0x514008,null))['catch'](handleError(_0x514008,null));};exports[_0x346f('0x94')]=function(_0x525222,_0x41306f,_0x3d99f2){var _0x3bd1bd,_0x21f863;return db[_0x346f('0x3c')][_0x346f('0x55')]({'where':{'id':_0x525222[_0x346f('0x54')]['id']}})[_0x346f('0x2d')](handleEntityNotFound(_0x41306f,null))[_0x346f('0x2d')](function(_0x5e779b){if(_0x5e779b){_0x21f863=_0x5e779b;return _0x5e779b[_0x346f('0x94')](_0x525222[_0x346f('0x57')][_0x346f('0x95')],_[_0x346f('0x60')](_0x525222[_0x346f('0x57')],['ids','id'])||{})[_0x346f('0x96')](function(_0x464bc3){for(var _0x4f3981=0x0;_0x4f3981<_0x525222[_0x346f('0x57')][_0x346f('0x95')][_0x346f('0x45')];_0x4f3981+=0x1){socket[_0x346f('0x80')](_0x346f('0x81'),{'UserId':_0x525222[_0x346f('0x57')]['ids'][_0x4f3981],'VoiceQueueId':_0x525222[_0x346f('0x54')]['id']});}return _0x464bc3;});}})['then'](function(_0x31d4fa){_0x3bd1bd=_0x31d4fa||[];if(_0x21f863){return db[_0x346f('0x71')][_0x346f('0x51')]({'where':{'id':_0x525222['body'][_0x346f('0x95')]},'attributes':['id',_0x346f('0x39'),_0x346f('0x73'),_0x346f('0x74'),_0x346f('0x7e')],'raw':!![]});}})[_0x346f('0x2d')](function(_0x2c5bc7){if(!_[_0x346f('0x97')](_0x2c5bc7)){var _0x3d872d=[];for(var _0x5bfcf3=0x0;_0x5bfcf3<_0x2c5bc7[_0x346f('0x45')];_0x5bfcf3++){if(_0x2c5bc7[_0x5bfcf3][_0x346f('0x73')]){_0x3d872d['push'](db[_0x346f('0x7c')]['upsert']({'membername':_0x2c5bc7[_0x5bfcf3][_0x346f('0x39')],'UserId':_0x2c5bc7[_0x5bfcf3]['id'],'queue_name':_0x21f863[_0x346f('0x39')],'VoiceQueueId':_0x21f863['id'],'interface':_['isNil'](_0x2c5bc7[_0x5bfcf3]['interface'])?util['format'](_0x346f('0x98'),_0x2c5bc7[_0x5bfcf3][_0x346f('0x39')]):_0x2c5bc7[_0x5bfcf3][_0x346f('0x7e')],'paused':_0x2c5bc7[_0x5bfcf3][_0x346f('0x74')]||![],'penalty':_0x525222[_0x346f('0x57')][_0x346f('0x76')]||0x0}));}}return BPromise[_0x346f('0x90')](_0x3d872d);}})[_0x346f('0x2d')](function(){return _0x3bd1bd;})[_0x346f('0x2d')](respondWithResult(_0x41306f,null))[_0x346f('0x53')](handleError(_0x41306f,null));};exports[_0x346f('0x92')]=function(_0x42a0e4,_0x2ff3e4,_0x5bc502){return db[_0x346f('0x3c')][_0x346f('0x55')]({'where':{'id':_0x42a0e4[_0x346f('0x54')]['id']}})[_0x346f('0x2d')](handleEntityNotFound(_0x2ff3e4,null))[_0x346f('0x2d')](function(_0x5e1231){if(_0x5e1231){return _0x5e1231[_0x346f('0x92')](_0x42a0e4[_0x346f('0x40')][_0x346f('0x95')])[_0x346f('0x2d')](function(){if(_[_0x346f('0x99')](_0x42a0e4[_0x346f('0x40')][_0x346f('0x95')])){for(var _0x2b4c7d=0x0;_0x2b4c7d<_0x42a0e4[_0x346f('0x40')][_0x346f('0x95')][_0x346f('0x45')];_0x2b4c7d+=0x1){socket[_0x346f('0x80')]('userVoiceQueue:remove',{'UserId':Number(_0x42a0e4[_0x346f('0x40')][_0x346f('0x95')][_0x2b4c7d]),'VoiceQueueId':Number(_0x42a0e4[_0x346f('0x54')]['id'])});}}else{socket['emit']('userVoiceQueue:remove',{'UserId':Number(_0x42a0e4[_0x346f('0x40')][_0x346f('0x95')]),'VoiceQueueId':Number(_0x42a0e4[_0x346f('0x54')]['id'])});}});}})[_0x346f('0x2d')](function(_0x566149){return db[_0x346f('0x7c')][_0x346f('0x2e')]({'where':{'VoiceQueueId':_0x42a0e4[_0x346f('0x54')]['id'],'UserId':_0x42a0e4[_0x346f('0x40')][_0x346f('0x95')]}})['then'](function(){return _0x566149;});})[_0x346f('0x2d')](respondWithStatusCode(_0x2ff3e4,null))['catch'](handleError(_0x2ff3e4,null));};exports[_0x346f('0x9a')]=function(_0x3c9bdd,_0x34c808,_0x18e276){var _0x543161={};var _0x281f29={};var _0x18a39e;var _0x95bac9;return db[_0x346f('0x3c')][_0x346f('0x66')]({'where':{'id':_0x3c9bdd[_0x346f('0x54')]['id']}})[_0x346f('0x2d')](handleEntityNotFound(_0x34c808,null))['then'](function(_0x5ca303){if(_0x5ca303){_0x18a39e=_0x5ca303;_0x281f29['model']=_[_0x346f('0x41')](db[_0x346f('0x71')][_0x346f('0x3d')]);_0x281f29['query']=_[_0x346f('0x41')](_0x3c9bdd['query']);_0x281f29[_0x346f('0x49')]=_[_0x346f('0x42')](_0x281f29[_0x346f('0x3f')],_0x281f29[_0x346f('0x40')]);_0x543161[_0x346f('0x43')]=_[_0x346f('0x42')](_0x281f29['model'],qs[_0x346f('0x44')](_0x3c9bdd[_0x346f('0x40')][_0x346f('0x44')]));_0x543161['attributes']=_0x543161[_0x346f('0x43')][_0x346f('0x45')]?_0x543161[_0x346f('0x43')]:_0x281f29['model'];_0x543161['order']=qs[_0x346f('0x48')](_0x3c9bdd['query']['sort']);_0x543161[_0x346f('0x4b')]=qs['filters'](_['pick'](_0x3c9bdd[_0x346f('0x40')],_0x281f29[_0x346f('0x49')]));if(_0x3c9bdd['query'][_0x346f('0x33')]){_0x543161[_0x346f('0x4b')]=_[_0x346f('0x4c')](_0x543161[_0x346f('0x4b')],{'$or':_[_0x346f('0x34')](_0x543161[_0x346f('0x43')],function(_0x47f6a5){var _0x557455={};_0x557455[_0x47f6a5]={'$like':'%'+_0x3c9bdd[_0x346f('0x40')][_0x346f('0x33')]+'%'};return _0x557455;})});}_0x543161=_[_0x346f('0x4c')]({},_0x543161,_0x3c9bdd['options']);return _0x18a39e['getAgents'](_0x543161);}})[_0x346f('0x2d')](function(_0x15702f){if(_0x15702f){_0x95bac9=_0x15702f[_0x346f('0x45')];if(!_0x3c9bdd[_0x346f('0x40')][_0x346f('0x46')]('nolimit')){_0x543161[_0x346f('0x26')]=qs[_0x346f('0x26')](_0x3c9bdd[_0x346f('0x40')][_0x346f('0x26')]);_0x543161[_0x346f('0x25')]=qs[_0x346f('0x25')](_0x3c9bdd[_0x346f('0x40')][_0x346f('0x25')]);}return _0x18a39e['getAgents'](_0x543161);}})[_0x346f('0x2d')](function(_0x1f1b15){if(_0x1f1b15){return _0x1f1b15?{'count':_0x95bac9,'rows':_0x1f1b15}:null;}})[_0x346f('0x2d')](respondWithResult(_0x34c808,null))['catch'](handleError(_0x34c808,null));};exports[_0x346f('0x9b')]=function(_0x1d1d00,_0xfaf597,_0x443e1a){var _0x21c490={};var _0x3fd31b={};var _0x224cab;var _0xa5ebca;return db['VoiceQueue'][_0x346f('0x66')]({'where':{'id':_0x1d1d00[_0x346f('0x54')]['id']}})[_0x346f('0x2d')](handleEntityNotFound(_0xfaf597,null))[_0x346f('0x2d')](function(_0xb19752){if(_0xb19752){_0x224cab=_0xb19752;_0x3fd31b[_0x346f('0x3f')]=_[_0x346f('0x41')](db[_0x346f('0x7c')][_0x346f('0x3d')]);_0x3fd31b[_0x346f('0x40')]=_['keys'](_0x1d1d00['query']);_0x3fd31b['filters']=_['intersection'](_0x3fd31b[_0x346f('0x3f')],_0x3fd31b[_0x346f('0x40')]);_0x21c490['attributes']=_[_0x346f('0x42')](_0x3fd31b[_0x346f('0x3f')],qs['fields'](_0x1d1d00[_0x346f('0x40')][_0x346f('0x44')]));_0x21c490[_0x346f('0x43')]=_0x21c490[_0x346f('0x43')][_0x346f('0x45')]?_0x21c490[_0x346f('0x43')]:_0x3fd31b[_0x346f('0x3f')];_0x21c490[_0x346f('0x47')]=qs[_0x346f('0x48')](_0x1d1d00['query'][_0x346f('0x48')]);_0x21c490['where']=qs[_0x346f('0x49')](_[_0x346f('0x4a')](_0x1d1d00['query'],_0x3fd31b[_0x346f('0x49')]));if(_0x1d1d00['query'][_0x346f('0x33')]){_0x21c490['where']=_['merge'](_0x21c490['where'],{'$or':_[_0x346f('0x34')](_0x21c490[_0x346f('0x43')],function(_0x57fae4){var _0x3b8b0d={};_0x3b8b0d[_0x57fae4]={'$like':'%'+_0x1d1d00[_0x346f('0x40')]['filter']+'%'};return _0x3b8b0d;})});}_0x21c490=_[_0x346f('0x4c')]({},_0x21c490,_0x1d1d00[_0x346f('0x4e')]);return _0x224cab[_0x346f('0x9b')](_0x21c490);}})[_0x346f('0x2d')](function(_0x4d73e0){if(_0x4d73e0){_0xa5ebca=_0x4d73e0[_0x346f('0x45')];if(!_0x1d1d00[_0x346f('0x40')][_0x346f('0x46')](_0x346f('0x68'))){_0x21c490[_0x346f('0x26')]=qs[_0x346f('0x26')](_0x1d1d00['query'][_0x346f('0x26')]);_0x21c490[_0x346f('0x25')]=qs[_0x346f('0x25')](_0x1d1d00[_0x346f('0x40')][_0x346f('0x25')]);}return _0x224cab[_0x346f('0x9b')](_0x21c490);}})[_0x346f('0x2d')](function(_0x2c7f84){return _0x2c7f84?{'count':_0xa5ebca,'rows':_0x2c7f84}:null;})[_0x346f('0x2d')](respondWithResult(_0xfaf597,null))[_0x346f('0x53')](handleError(_0xfaf597,null));};exports[_0x346f('0x9c')]=function(_0x313dca,_0x512c2b,_0xcbc53d){var _0x222e84={};var _0x43eeaa={};var _0x29e2e1;var _0x2ecbec;return db[_0x346f('0x3c')][_0x346f('0x66')]({'where':{'id':_0x313dca[_0x346f('0x54')]['id']}})[_0x346f('0x2d')](handleEntityNotFound(_0x512c2b,null))[_0x346f('0x2d')](function(_0x5848a5){if(_0x5848a5){_0x29e2e1=_0x5848a5;_0x43eeaa['model']=_[_0x346f('0x41')](db[_0x346f('0x9d')][_0x346f('0x3d')]);_0x43eeaa['query']=_[_0x346f('0x41')](_0x313dca['query']);_0x43eeaa[_0x346f('0x49')]=_[_0x346f('0x42')](_0x43eeaa[_0x346f('0x3f')],_0x43eeaa[_0x346f('0x40')]);_0x222e84['attributes']=_[_0x346f('0x42')](_0x43eeaa[_0x346f('0x3f')],qs[_0x346f('0x44')](_0x313dca['query'][_0x346f('0x44')]));_0x222e84[_0x346f('0x43')]=_0x222e84[_0x346f('0x43')][_0x346f('0x45')]?_0x222e84[_0x346f('0x43')]:_0x43eeaa['model'];_0x222e84[_0x346f('0x47')]=qs[_0x346f('0x48')](_0x313dca[_0x346f('0x40')][_0x346f('0x48')]);_0x222e84[_0x346f('0x4b')]=qs[_0x346f('0x49')](_[_0x346f('0x4a')](_0x313dca[_0x346f('0x40')],_0x43eeaa[_0x346f('0x49')]));if(_0x313dca[_0x346f('0x40')][_0x346f('0x33')]){_0x222e84[_0x346f('0x4b')]=_['merge'](_0x222e84['where'],{'$or':_['map'](_0x222e84[_0x346f('0x43')],function(_0x45c261){var _0x3b9b56={};_0x3b9b56[_0x45c261]={'$like':'%'+_0x313dca['query'][_0x346f('0x33')]+'%'};return _0x3b9b56;})});}_0x222e84=_[_0x346f('0x4c')]({},_0x222e84,_0x313dca[_0x346f('0x4e')]);return _0x29e2e1[_0x346f('0x9c')](_0x222e84);}})[_0x346f('0x2d')](function(_0x3715cc){if(_0x3715cc){_0x2ecbec=_0x3715cc[_0x346f('0x45')];if(!_0x313dca['query'][_0x346f('0x46')](_0x346f('0x68'))){_0x222e84[_0x346f('0x26')]=qs[_0x346f('0x26')](_0x313dca['query'][_0x346f('0x26')]);_0x222e84[_0x346f('0x25')]=qs[_0x346f('0x25')](_0x313dca[_0x346f('0x40')]['offset']);}return _0x29e2e1[_0x346f('0x9c')](_0x222e84);}})[_0x346f('0x2d')](function(_0x32f8ba){if(_0x32f8ba){return _0x32f8ba?{'count':_0x2ecbec,'rows':_0x32f8ba}:null;}})[_0x346f('0x2d')](respondWithResult(_0x512c2b,null))[_0x346f('0x53')](handleError(_0x512c2b,null));};exports[_0x346f('0x9e')]=function(_0x2260ef,_0x5f9695,_0x21daad){var _0x1b33fd,_0x363d80;return db['VoiceQueue'][_0x346f('0x55')]({'where':{'id':_0x2260ef[_0x346f('0x54')]['id']}})[_0x346f('0x2d')](handleEntityNotFound(_0x5f9695,null))['then'](function(_0x5577c6){if(_0x5577c6){_0x363d80=_0x5577c6;return _0x5577c6[_0x346f('0x9e')](_0x2260ef['body']['ids'],_[_0x346f('0x60')](_0x2260ef['body'],[_0x346f('0x95'),'id'])||{});}return null;})[_0x346f('0x96')](function(_0x5b31f4){var _0x3fb82d;_0x1b33fd=_0x5b31f4||[];var _0x2222b1=[];if(_0x5b31f4){for(var _0x3c1150=0x0;_0x3c1150<_0x5b31f4[_0x346f('0x45')];_0x3c1150+=0x1){var _0x5943df=_0x5b31f4[_0x3c1150][_0x346f('0x2f')]({'plain':!![]});_0x363d80[_0x346f('0x9f')]=_0x2260ef[_0x346f('0x57')][_0x346f('0x9f')]?_0x2260ef[_0x346f('0x57')][_0x346f('0x9f')]:_0x363d80[_0x346f('0x9f')];switch(_0x363d80[_0x346f('0x9f')]){case _0x346f('0xa0'):_0x3fb82d=squel[_0x346f('0xa1')]()[_0x346f('0xa2')](_0x346f('0xa3'))[_0x346f('0xa4')]([_0x346f('0xa5'),'scheduledAt',_0x346f('0xa6'),_0x346f('0xa7'),_0x346f('0x69'),'createdAt',_0x346f('0x62')],squel[_0x346f('0x83')]()['field'](_0x346f('0xa5'),_0x346f('0xa5'))[_0x346f('0x84')](_0x346f('0xa8'),_0x346f('0xa9'))['field']('id',_0x346f('0xa6'))[_0x346f('0x84')](_0x5943df[_0x346f('0xaa')][_0x346f('0x8d')](),_0x346f('0xa7'))['field'](_0x2260ef[_0x346f('0x54')]['id'][_0x346f('0x8d')](),'VoiceQueueId')[_0x346f('0x84')]('NOW()',_0x346f('0x61'))[_0x346f('0x84')]('NOW()','updatedAt')['from'](_0x346f('0xab'))[_0x346f('0x4b')](_0x346f('0xac'))['where'](_0x346f('0xad'),_0x5943df[_0x346f('0xaa')][_0x346f('0x8d')]())[_0x346f('0x4b')]('phone\x20IS\x20NOT\x20NULL')[_0x346f('0x4b')](_0x346f('0xae'),squel[_0x346f('0x83')]()['field'](_0x346f('0xaf'))[_0x346f('0x85')](_0x346f('0xb0'))[_0x346f('0x4b')](_0x346f('0x8a'),_0x2260ef[_0x346f('0x54')]['id'][_0x346f('0x8d')]()))[_0x346f('0x4b')]('phone\x20NOT\x20IN\x20(?)',squel[_0x346f('0x83')]()[_0x346f('0x84')](_0x346f('0xb1'))['from'](_0x346f('0xa3'))[_0x346f('0x4b')](_0x346f('0x8a'),_0x2260ef[_0x346f('0x54')]['id'][_0x346f('0x8d')]())))[_0x346f('0x8d')]();break;case _0x346f('0xb2'):_0x3fb82d=squel[_0x346f('0xa1')]()[_0x346f('0xa2')](_0x346f('0xa3'))['fromQuery']([_0x346f('0xa5'),_0x346f('0xa9'),_0x346f('0xa6'),_0x346f('0xa7'),_0x346f('0x69'),'createdAt',_0x346f('0x62')],squel['select']()[_0x346f('0x84')]('phone','phone')[_0x346f('0x84')]('NOW()',_0x346f('0xa9'))[_0x346f('0x84')]('id','ContactId')[_0x346f('0x84')](_0x5943df[_0x346f('0xaa')][_0x346f('0x8d')](),_0x346f('0xa7'))[_0x346f('0x84')](_0x2260ef['params']['id']['toString'](),_0x346f('0x69'))['field'](_0x346f('0xa8'),_0x346f('0x61'))[_0x346f('0x84')](_0x346f('0xa8'),_0x346f('0x62'))['from'](_0x346f('0xab'))['where'](_0x346f('0xac'))[_0x346f('0x4b')]('ListId\x20=\x20?',_0x5943df[_0x346f('0xaa')][_0x346f('0x8d')]())[_0x346f('0x4b')](_0x346f('0xb3'))[_0x346f('0x4b')](_0x346f('0xae'),squel[_0x346f('0x83')]()[_0x346f('0x84')](_0x346f('0xb1'))[_0x346f('0x85')](_0x346f('0xa3'))[_0x346f('0x4b')](_0x346f('0x8a'),_0x2260ef['params']['id'][_0x346f('0x8d')]())))[_0x346f('0x8d')]();break;default:_0x3fb82d=squel[_0x346f('0xa1')]()[_0x346f('0xa2')](_0x346f('0xa3'))['fromQuery']([_0x346f('0xa5'),'scheduledAt',_0x346f('0xa6'),_0x346f('0xa7'),'VoiceQueueId',_0x346f('0x61'),_0x346f('0x62')],squel[_0x346f('0x83')]()[_0x346f('0x84')](_0x346f('0xa5'),_0x346f('0xa5'))['field'](_0x346f('0xa8'),_0x346f('0xa9'))[_0x346f('0x84')]('id',_0x346f('0xa6'))['field'](_0x5943df[_0x346f('0xaa')]['toString'](),_0x346f('0xa7'))[_0x346f('0x84')](_0x2260ef[_0x346f('0x54')]['id'][_0x346f('0x8d')](),_0x346f('0x69'))[_0x346f('0x84')]('NOW()',_0x346f('0x61'))['field']('NOW()',_0x346f('0x62'))[_0x346f('0x85')](_0x346f('0xab'))[_0x346f('0x4b')](_0x346f('0xac'))[_0x346f('0x4b')]('ListId\x20=\x20?',_0x5943df[_0x346f('0xaa')][_0x346f('0x8d')]())['where'](_0x346f('0xb3')))[_0x346f('0x8d')]();}_0x2222b1['push'](db['sequelize'][_0x346f('0x40')](_0x3fb82d));}return BPromise[_0x346f('0x90')](_0x2222b1);}})[_0x346f('0x2d')](function(){return _0x1b33fd;})['then'](respondWithResult(_0x5f9695,null))[_0x346f('0x53')](handleError(_0x5f9695,null));};exports[_0x346f('0xb4')]=function(_0x53f1b7,_0x298c26,_0x3ae85d){return db[_0x346f('0x3c')][_0x346f('0x55')]({'where':{'id':_0x53f1b7[_0x346f('0x54')]['id']}})['then'](handleEntityNotFound(_0x298c26,null))[_0x346f('0x2d')](function(_0x5c0a7c){if(_0x5c0a7c){return _0x5c0a7c[_0x346f('0xb4')](_0x53f1b7[_0x346f('0x40')]['ids']);}})['then'](function(_0x9986ec){if(_0x9986ec){return db['CmHopper'][_0x346f('0x2e')]({'where':{'ListId':_0x53f1b7['query'][_0x346f('0x95')],'VoiceQueueId':_0x53f1b7[_0x346f('0x54')]['id']}})[_0x346f('0x2d')](function(){return _0x9986ec;});}})['then'](respondWithStatusCode(_0x298c26,null))[_0x346f('0x53')](handleError(_0x298c26,null));};exports['getBlackLists']=function(_0x359539,_0x183dd4,_0x5546b5){var _0x43bf56={};var _0x3698e3={};var _0x27e555;var _0x1c4413;return db['VoiceQueue'][_0x346f('0x66')]({'where':{'id':_0x359539[_0x346f('0x54')]['id']}})['then'](handleEntityNotFound(_0x183dd4,null))[_0x346f('0x2d')](function(_0x509170){if(_0x509170){_0x27e555=_0x509170;_0x3698e3[_0x346f('0x3f')]=_[_0x346f('0x41')](db[_0x346f('0x9d')][_0x346f('0x3d')]);_0x3698e3[_0x346f('0x40')]=_['keys'](_0x359539[_0x346f('0x40')]);_0x3698e3[_0x346f('0x49')]=_[_0x346f('0x42')](_0x3698e3[_0x346f('0x3f')],_0x3698e3[_0x346f('0x40')]);_0x43bf56[_0x346f('0x43')]=_['intersection'](_0x3698e3[_0x346f('0x3f')],qs[_0x346f('0x44')](_0x359539['query'][_0x346f('0x44')]));_0x43bf56['attributes']=_0x43bf56[_0x346f('0x43')]['length']?_0x43bf56[_0x346f('0x43')]:_0x3698e3['model'];_0x43bf56[_0x346f('0x47')]=qs['sort'](_0x359539[_0x346f('0x40')][_0x346f('0x48')]);_0x43bf56[_0x346f('0x4b')]=qs[_0x346f('0x49')](_['pick'](_0x359539['query'],_0x3698e3['filters']));if(_0x359539[_0x346f('0x40')][_0x346f('0x33')]){_0x43bf56[_0x346f('0x4b')]=_[_0x346f('0x4c')](_0x43bf56[_0x346f('0x4b')],{'$or':_[_0x346f('0x34')](_0x43bf56[_0x346f('0x43')],function(_0x1fb7a9){var _0x57dc7c={};_0x57dc7c[_0x1fb7a9]={'$like':'%'+_0x359539[_0x346f('0x40')]['filter']+'%'};return _0x57dc7c;})});}_0x43bf56=_[_0x346f('0x4c')]({},_0x43bf56,_0x359539['options']);return _0x27e555[_0x346f('0xb5')](_0x43bf56);}})[_0x346f('0x2d')](function(_0x5a0a1f){if(_0x5a0a1f){_0x1c4413=_0x5a0a1f[_0x346f('0x45')];if(!_0x359539[_0x346f('0x40')][_0x346f('0x46')](_0x346f('0x68'))){_0x43bf56[_0x346f('0x26')]=qs[_0x346f('0x26')](_0x359539[_0x346f('0x40')][_0x346f('0x26')]);_0x43bf56['offset']=qs[_0x346f('0x25')](_0x359539[_0x346f('0x40')]['offset']);}return _0x27e555[_0x346f('0xb5')](_0x43bf56);}})[_0x346f('0x2d')](function(_0x1ea7ab){if(_0x1ea7ab){return _0x1ea7ab?{'count':_0x1c4413,'rows':_0x1ea7ab}:null;}})[_0x346f('0x2d')](respondWithResult(_0x183dd4,null))[_0x346f('0x53')](handleError(_0x183dd4,null));};exports['addBlackLists']=function(_0x528d36,_0x133a9c,_0x933aac){var _0x5d80e0,_0x4bddd4;return db[_0x346f('0x3c')][_0x346f('0x55')]({'where':{'id':_0x528d36[_0x346f('0x54')]['id']}})[_0x346f('0x2d')](handleEntityNotFound(_0x133a9c,null))[_0x346f('0x2d')](function(_0x23831c){if(_0x23831c){_0x4bddd4=_0x23831c;return _0x23831c['addBlackLists'](_0x528d36[_0x346f('0x57')][_0x346f('0x95')],_['omit'](_0x528d36[_0x346f('0x57')],[_0x346f('0x95'),'id'])||{});}return null;})[_0x346f('0x96')](function(_0x445165){var _0x3023a7;_0x5d80e0=_0x445165||[];var _0x323eaf=[];if(_0x445165){for(var _0x2797a2=0x0;_0x2797a2<_0x445165[_0x346f('0x45')];_0x2797a2+=0x1){var _0x5cff76=_0x445165[_0x2797a2][_0x346f('0x2f')]({'plain':!![]});_0x3023a7=squel['insert']()[_0x346f('0xa2')](_0x346f('0xb6'))[_0x346f('0xa4')](['phone',_0x346f('0xa6'),_0x346f('0xa7'),_0x346f('0x69'),'createdAt',_0x346f('0x62')],squel[_0x346f('0x83')]()[_0x346f('0x84')](_0x346f('0xa5'),'phone')[_0x346f('0x84')]('id','ContactId')[_0x346f('0x84')](_0x5cff76[_0x346f('0xaa')][_0x346f('0x8d')](),_0x346f('0xa7'))[_0x346f('0x84')](_0x528d36['params']['id'][_0x346f('0x8d')](),'VoiceQueueId')[_0x346f('0x84')](_0x346f('0xa8'),_0x346f('0x61'))[_0x346f('0x84')](_0x346f('0xa8'),'updatedAt')[_0x346f('0x85')]('cm_contacts')[_0x346f('0x4b')]('deletedAt\x20IS\x20NULL')['where'](_0x346f('0xad'),_0x5cff76[_0x346f('0xaa')][_0x346f('0x8d')]())[_0x346f('0x4b')](_0x346f('0xb3')))['toString']();_0x323eaf['push'](db[_0x346f('0x77')][_0x346f('0x40')](_0x3023a7));}return BPromise['all'](_0x323eaf);}})[_0x346f('0x2d')](function(){return _0x5d80e0;})[_0x346f('0x2d')](respondWithResult(_0x133a9c,null))[_0x346f('0x53')](handleError(_0x133a9c,null));};exports[_0x346f('0xb7')]=function(_0x371bf1,_0xe53827,_0xe19558){return db[_0x346f('0x3c')]['find']({'where':{'id':_0x371bf1[_0x346f('0x54')]['id']}})[_0x346f('0x2d')](handleEntityNotFound(_0xe53827,null))[_0x346f('0x2d')](function(_0xaff884){if(_0xaff884){return _0xaff884[_0x346f('0xb7')](_0x371bf1[_0x346f('0x40')][_0x346f('0x95')]);}})[_0x346f('0x2d')](function(_0x5b8d81){if(_0x5b8d81){return db[_0x346f('0x6c')]['destroy']({'where':{'ListId':_0x371bf1['query'][_0x346f('0x95')],'VoiceQueueId':_0x371bf1[_0x346f('0x54')]['id']}})[_0x346f('0x2d')](function(){return _0x5b8d81;});}})[_0x346f('0x2d')](respondWithStatusCode(_0xe53827,null))[_0x346f('0x53')](handleError(_0xe53827,null));};
\ No newline at end of file