Built motion from commit (unavailable).|2.5.4
[motion2.git] / server / api / voiceQueue / voiceQueue.controller.js
index e0633ef..c2e1c8e 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x492f=['nolimit','VoiceQueueId','rows','getHopperHistories','CmHopperHistory','getHopperFinals','CmHopperFinal','getHopperBlacks','CmHopperBlack','getTeams','addTeams','teams','Team','User','Agents','voicePause','interface','flatMap','penalty','sequelize','each','UserVoiceQueueRt','upsert','isNil','SIP/%s','forEach','select','field','tq.TeamId','join','user_has_teams','VoiceQueueId\x20=\x20?','ut.UserId\x20=\x20?','toString','QueryTypes','SELECT','every','TeamId','compact','ids','isEmpty','removeAgents','userVoiceQueue:remove','addAgents','spread','emit','userVoiceQueue:save','online','push','format','all','isArray','getAgents','getMembers','CmList','getLists','addLists','dialCheckDuplicateType','insert','into','cm_hopper','fromQuery','phone','ContactId','ListId','NOW()','scheduledAt','from','cm_contacts','deletedAt\x20IS\x20NULL','CmListId','phone\x20IS\x20NOT\x20NULL','COALESCE(calleridnum,\x27\x27)','cm_hopper_final','onlyIfOpen','phone\x20NOT\x20IN\x20(?)','COALESCE(phone,\x27\x27)','removeLists','getBlackLists','addBlackLists','ListId\x20=\x20?','removeBlackLists','html-pdf','eml-format','zip-dir','request-promise','moment','path','sox','to-csv','ejs','lodash','crypto','jsforce','querystring','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/environment','../../mysqldb','redis','defaults','localhost','register','sendStatus','status','end','json','count','offset','limit','set','apply','reject','save','update','then','destroy','VoiceQueues','inbound','outbound','ignore','map','value','includes','type','find','UserProfileResource','error','stack','name','send','index','VoiceQueue','rawAttributes','fieldName','model','query','keys','filters','intersection','attributes','length','hasOwnProperty','order','sort','where','pick','merge','VIRTUAL','filter','includeAll','include','findAll','catch','params','fields','options','create','user','get','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','QueueCampaigns','UserProfileSection','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','createdAt','updatedAt','body','omit','getHoppers','findOne','CmHopper'];(function(_0x2f3e2f,_0x32aaf8){var _0x23cd4a=function(_0x4deaee){while(--_0x4deaee){_0x2f3e2f['push'](_0x2f3e2f['shift']());}};_0x23cd4a(++_0x32aaf8);}(_0x492f,0x103));var _0xf492=function(_0x1f689e,_0x1c3e0d){_0x1f689e=_0x1f689e-0x0;var _0x535029=_0x492f[_0x1f689e];return _0x535029;};'use strict';var pdf=require(_0xf492('0x0'));var emlformat=require(_0xf492('0x1'));var rimraf=require('rimraf');var zipdir=require(_0xf492('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0xf492('0x3'));var moment=require(_0xf492('0x4'));var BPromise=require('bluebird');var Mustache=require('mustache');var util=require('util');var path=require(_0xf492('0x5'));var sox=require(_0xf492('0x6'));var csv=require(_0xf492('0x7'));var ejs=require(_0xf492('0x8'));var fs=require('fs');var _=require(_0xf492('0x9'));var squel=require('squel');var crypto=require(_0xf492('0xa'));var jsforce=require(_0xf492('0xb'));var deskjs=require('desk.js');var toCsv=require(_0xf492('0x7'));var querystring=require(_0xf492('0xc'));var Papa=require(_0xf492('0xd'));var Redis=require(_0xf492('0xe'));var authService=require('../../components/auth/service');var qs=require(_0xf492('0xf'));var as=require(_0xf492('0x10'));var hardwareService=require(_0xf492('0x11'));var logger=require('../../config/logger')('api');var utils=require('../../config/utils');var config=require(_0xf492('0x12'));var db=require(_0xf492('0x13'))['db'];config[_0xf492('0x14')]=_[_0xf492('0x15')](config[_0xf492('0x14')],{'host':_0xf492('0x16'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config['redis']));require('./voiceQueue.socket')[_0xf492('0x17')](socket);function respondWithStatusCode(_0x9bb935,_0x5da8de){_0x5da8de=_0x5da8de||0xcc;return function(_0x381ef3){if(_0x381ef3){return _0x9bb935[_0xf492('0x18')](_0x5da8de);}return _0x9bb935[_0xf492('0x19')](_0x5da8de)[_0xf492('0x1a')]();};}function respondWithResult(_0x1c2d78,_0x5e2509){_0x5e2509=_0x5e2509||0xc8;return function(_0x311cd8){if(_0x311cd8){return _0x1c2d78[_0xf492('0x19')](_0x5e2509)[_0xf492('0x1b')](_0x311cd8);}};}function respondWithFilteredResult(_0x4c62db,_0x17ae46){return function(_0x1e857c){if(_0x1e857c){var _0x35dbfe=_0x1e857c[_0xf492('0x1c')],_0x2d4124=_0x17ae46[_0xf492('0x1d')],_0x1de63a=_0x17ae46[_0xf492('0x1d')]+_0x17ae46[_0xf492('0x1e')],_0x29d5f3;if(_0x1de63a>=_0x35dbfe){_0x1de63a=_0x35dbfe;_0x29d5f3=0xc8;}else{_0x29d5f3=0xce;}_0x4c62db[_0xf492('0x19')](_0x29d5f3);return _0x4c62db[_0xf492('0x1f')]('Content-Range',_0x2d4124+'-'+_0x1de63a+'/'+_0x35dbfe)[_0xf492('0x1b')](_0x1e857c);}return null;};}function patchUpdates(_0x4aa832){return function(_0x2adcd1){try{jsonpatch[_0xf492('0x20')](_0x2adcd1,_0x4aa832,!![]);}catch(_0x4ff62c){return BPromise[_0xf492('0x21')](_0x4ff62c);}return _0x2adcd1[_0xf492('0x22')]();};}function saveUpdates(_0xd2033d,_0x1e11e7){return function(_0x2a89fb){if(_0x2a89fb){return _0x2a89fb[_0xf492('0x23')](_0xd2033d)[_0xf492('0x24')](function(_0x3f9310){return _0x3f9310;});}return null;};}function removeEntity(_0x378b67,_0x483796){return function(_0x27bbe4){if(_0x27bbe4){return _0x27bbe4[_0xf492('0x25')]()[_0xf492('0x24')](function(){var _0x30c0e2=_0x27bbe4['get']({'plain':!![]});var _0xba7a42=[{'name':_0xf492('0x26'),'value':_0xf492('0x27'),'ignore':![]},{'name':'QueueCampaigns','value':_0xf492('0x28'),'ignore':![]}];var _0x5ab005=_(_0xba7a42)['filter'](_0xf492('0x29'))[_0xf492('0x2a')](_0xf492('0x2b'))[_0xf492('0x2b')]();if(_[_0xf492('0x2c')](_0x5ab005,_0x30c0e2[_0xf492('0x2d')])){return;}var _0x342dbc=_[_0xf492('0x2e')](_0xba7a42,[_0xf492('0x2b'),_0x30c0e2[_0xf492('0x2d')]])['name'];return db[_0xf492('0x2f')][_0xf492('0x25')]({'where':{'type':_0x342dbc,'resourceId':_0x30c0e2['id']}})[_0xf492('0x24')](function(){return _0x27bbe4;});})['then'](function(){_0x378b67[_0xf492('0x19')](0xcc)[_0xf492('0x1a')]();});}};}function handleEntityNotFound(_0x45b175,_0x5d3f66){return function(_0x544fb7){if(!_0x544fb7){_0x45b175['sendStatus'](0x194);}return _0x544fb7;};}function handleError(_0x2c07a7,_0x4ff272){_0x4ff272=_0x4ff272||0x1f4;return function(_0x54b786){logger[_0xf492('0x30')](_0x54b786[_0xf492('0x31')]);if(_0x54b786[_0xf492('0x32')]){delete _0x54b786[_0xf492('0x32')];}_0x2c07a7[_0xf492('0x19')](_0x4ff272)[_0xf492('0x33')](_0x54b786);};}exports[_0xf492('0x34')]=function(_0x2e98e7,_0x10f0f2){var _0x3b0f1a={},_0x3678a8={},_0xdce339={'count':0x0,'rows':[]};var _0x5ce554=_[_0xf492('0x2a')](db[_0xf492('0x35')][_0xf492('0x36')],function(_0x4937da){return{'name':_0x4937da[_0xf492('0x37')],'type':_0x4937da[_0xf492('0x2d')]['key']};});_0x3678a8[_0xf492('0x38')]=_[_0xf492('0x2a')](_0x5ce554,'name');_0x3678a8[_0xf492('0x39')]=_[_0xf492('0x3a')](_0x2e98e7[_0xf492('0x39')]);_0x3678a8[_0xf492('0x3b')]=_[_0xf492('0x3c')](_0x3678a8[_0xf492('0x38')],_0x3678a8[_0xf492('0x39')]);_0x3b0f1a[_0xf492('0x3d')]=_[_0xf492('0x3c')](_0x3678a8['model'],qs['fields'](_0x2e98e7[_0xf492('0x39')]['fields']));_0x3b0f1a['attributes']=_0x3b0f1a[_0xf492('0x3d')][_0xf492('0x3e')]?_0x3b0f1a[_0xf492('0x3d')]:_0x3678a8[_0xf492('0x38')];if(!_0x2e98e7[_0xf492('0x39')][_0xf492('0x3f')]('nolimit')){_0x3b0f1a[_0xf492('0x1e')]=qs[_0xf492('0x1e')](_0x2e98e7[_0xf492('0x39')][_0xf492('0x1e')]);_0x3b0f1a[_0xf492('0x1d')]=qs[_0xf492('0x1d')](_0x2e98e7[_0xf492('0x39')]['offset']);}_0x3b0f1a[_0xf492('0x40')]=qs['sort'](_0x2e98e7[_0xf492('0x39')][_0xf492('0x41')]);_0x3b0f1a[_0xf492('0x42')]=qs[_0xf492('0x3b')](_[_0xf492('0x43')](_0x2e98e7[_0xf492('0x39')],_0x3678a8[_0xf492('0x3b')]),_0x5ce554);if(_0x2e98e7[_0xf492('0x39')]['filter']){_0x3b0f1a[_0xf492('0x42')]=_[_0xf492('0x44')](_0x3b0f1a['where'],{'$or':_[_0xf492('0x2a')](_0x5ce554,function(_0x5ded8e){if(_0x5ded8e[_0xf492('0x2d')]!==_0xf492('0x45')){var _0x4222b8={};_0x4222b8[_0x5ded8e['name']]={'$like':'%'+_0x2e98e7[_0xf492('0x39')][_0xf492('0x46')]+'%'};return _0x4222b8;}})});}_0x3b0f1a=_['merge']({},_0x3b0f1a,_0x2e98e7['options']);var _0x45e734={'where':_0x3b0f1a[_0xf492('0x42')]};return db['VoiceQueue']['count'](_0x45e734)['then'](function(_0x564b8d){_0xdce339['count']=_0x564b8d;if(_0x2e98e7[_0xf492('0x39')][_0xf492('0x47')]){_0x3b0f1a[_0xf492('0x48')]=[{'all':!![]}];}return db[_0xf492('0x35')][_0xf492('0x49')](_0x3b0f1a);})['then'](function(_0x301520){_0xdce339['rows']=_0x301520;return _0xdce339;})[_0xf492('0x24')](respondWithFilteredResult(_0x10f0f2,_0x3b0f1a))[_0xf492('0x4a')](handleError(_0x10f0f2,null));};exports['show']=function(_0x264d35,_0x1ef926){var _0x2bab12={'raw':![],'where':{'id':_0x264d35[_0xf492('0x4b')]['id']}},_0x1bc8c7={};_0x1bc8c7['model']=_[_0xf492('0x3a')](db[_0xf492('0x35')][_0xf492('0x36')]);_0x1bc8c7['query']=_['keys'](_0x264d35[_0xf492('0x39')]);_0x1bc8c7[_0xf492('0x3b')]=_[_0xf492('0x3c')](_0x1bc8c7['model'],_0x1bc8c7[_0xf492('0x39')]);_0x2bab12[_0xf492('0x3d')]=_['intersection'](_0x1bc8c7['model'],qs[_0xf492('0x4c')](_0x264d35['query'][_0xf492('0x4c')]));_0x2bab12[_0xf492('0x3d')]=_0x2bab12['attributes'][_0xf492('0x3e')]?_0x2bab12[_0xf492('0x3d')]:_0x1bc8c7[_0xf492('0x38')];if(_0x264d35[_0xf492('0x39')][_0xf492('0x47')]){_0x2bab12[_0xf492('0x48')]=[{'all':!![]}];}_0x2bab12=_[_0xf492('0x44')]({},_0x2bab12,_0x264d35[_0xf492('0x4d')]);return db[_0xf492('0x35')]['find'](_0x2bab12)[_0xf492('0x24')](handleEntityNotFound(_0x1ef926,null))[_0xf492('0x24')](respondWithResult(_0x1ef926,null))[_0xf492('0x4a')](handleError(_0x1ef926,null));};exports[_0xf492('0x4e')]=function(_0x3c8655,_0x4475d7){return db[_0xf492('0x35')][_0xf492('0x4e')](_0x3c8655['body'],{})[_0xf492('0x24')](function(_0x44fbb8){var _0x31235c=_0x3c8655[_0xf492('0x4f')][_0xf492('0x50')]({'plain':!![]});if(!_0x31235c)throw new Error(_0xf492('0x51'));if(_0x31235c[_0xf492('0x52')]===_0xf492('0x4f')){var _0x15bc8b=_0x44fbb8[_0xf492('0x50')]({'plain':!![]});var _0x2b9e57=[{'name':_0xf492('0x26'),'value':_0xf492('0x27')},{'name':_0xf492('0x53'),'value':_0xf492('0x28')}];var _0x7f171e=_[_0xf492('0x2e')](_0x2b9e57,['value',_0x15bc8b['type']])[_0xf492('0x32')];return db[_0xf492('0x54')]['find']({'where':{'name':_0x7f171e,'userProfileId':_0x31235c[_0xf492('0x55')]},'raw':!![]})[_0xf492('0x24')](function(_0x3296a4){if(_0x3296a4&&_0x3296a4[_0xf492('0x56')]===0x0){return db[_0xf492('0x2f')][_0xf492('0x4e')]({'name':_0x15bc8b[_0xf492('0x32')],'resourceId':_0x15bc8b['id'],'type':_0x3296a4[_0xf492('0x32')],'sectionId':_0x3296a4['id']},{})[_0xf492('0x24')](function(){return _0x44fbb8;});}else{return _0x44fbb8;}})[_0xf492('0x4a')](function(_0x4b363b){logger[_0xf492('0x30')](_0xf492('0x57'),_0x4b363b);throw _0x4b363b;});}return _0x44fbb8;})[_0xf492('0x24')](respondWithResult(_0x4475d7,0xc9))[_0xf492('0x4a')](handleError(_0x4475d7,null));};exports['clone']=function(_0x3ed7bb,_0x19cbe1){var _0x501936={'where':{'id':_0x3ed7bb[_0xf492('0x4b')]['id']}},_0x1c6b97={};_0x1c6b97[_0xf492('0x38')]=_[_0xf492('0x3a')](db[_0xf492('0x35')][_0xf492('0x36')]);_0x501936[_0xf492('0x3d')]=_[_0xf492('0x3c')](_0x1c6b97[_0xf492('0x38')],qs[_0xf492('0x4c')](_0x3ed7bb['query'][_0xf492('0x4c')]));_0x501936[_0xf492('0x3d')]=_0x501936[_0xf492('0x3d')]['length']?_0x501936[_0xf492('0x3d')]:_0x1c6b97['model'];if(_0x3ed7bb[_0xf492('0x39')][_0xf492('0x47')]){_0x501936[_0xf492('0x48')]=[{'all':!![]}];}_0x501936=_['merge']({},_0x501936,_0x3ed7bb[_0xf492('0x4d')]);return db[_0xf492('0x35')][_0xf492('0x2e')](_0x501936)[_0xf492('0x24')](handleEntityNotFound(_0x19cbe1,null))['then'](function(_0x5d57ec){if(_0x5d57ec){var _0x101bbf=_0x5d57ec[_0xf492('0x50')]({'plain':!![]});_0x101bbf=qs['omit'](_0x101bbf,['id',_0xf492('0x58'),_0xf492('0x59')]);_0x3ed7bb[_0xf492('0x5a')]=_[_0xf492('0x5b')](_0x3ed7bb[_0xf492('0x5a')],['id',_0xf492('0x58'),_0xf492('0x59')]);return db['VoiceQueue'][_0xf492('0x4e')](_[_0xf492('0x44')](_0x101bbf,_0x3ed7bb[_0xf492('0x5a')]),{'include':_0x3ed7bb[_0xf492('0x39')][_0xf492('0x47')]?[{'all':!![]}]:undefined})['then'](function(_0x502aba){var _0x4d52ca=_0x3ed7bb[_0xf492('0x4f')][_0xf492('0x50')]({'plain':!![]});if(!_0x4d52ca)throw new Error(_0xf492('0x51'));if(_0x4d52ca[_0xf492('0x52')]===_0xf492('0x4f')){var _0x2170cd=_0x502aba[_0xf492('0x50')]({'plain':!![]});var _0x38da47=[{'name':_0xf492('0x26'),'value':'inbound'},{'name':_0xf492('0x53'),'value':_0xf492('0x28')}];var _0x5d150a=_[_0xf492('0x2e')](_0x38da47,[_0xf492('0x2b'),_0x2170cd[_0xf492('0x2d')]])[_0xf492('0x32')];return db[_0xf492('0x54')]['find']({'where':{'name':_0x5d150a,'userProfileId':_0x4d52ca[_0xf492('0x55')]},'raw':!![]})['then'](function(_0x5a9117){if(_0x5a9117&&_0x5a9117[_0xf492('0x56')]===0x0){return db[_0xf492('0x2f')][_0xf492('0x4e')]({'name':_0x2170cd[_0xf492('0x32')],'resourceId':_0x2170cd['id'],'type':_0x5a9117[_0xf492('0x32')],'sectionId':_0x5a9117['id']},{})[_0xf492('0x24')](function(){return _0x502aba;});}else{return _0x502aba;}})['catch'](function(_0x5c540f){logger[_0xf492('0x30')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x5c540f);throw _0x5c540f;});}return _0x502aba;});}})['then'](respondWithResult(_0x19cbe1,0xc9))['catch'](handleError(_0x19cbe1,null));};exports['update']=function(_0x139f8f,_0x2c3bc0){if(_0x139f8f[_0xf492('0x5a')]['id']){delete _0x139f8f[_0xf492('0x5a')]['id'];}return db[_0xf492('0x35')]['find']({'where':{'id':_0x139f8f[_0xf492('0x4b')]['id']}})[_0xf492('0x24')](handleEntityNotFound(_0x2c3bc0,null))['then'](saveUpdates(_0x139f8f[_0xf492('0x5a')],null))[_0xf492('0x24')](respondWithResult(_0x2c3bc0,null))['catch'](handleError(_0x2c3bc0,null));};exports[_0xf492('0x25')]=function(_0x28d4a4,_0xe9e650){return db[_0xf492('0x35')]['find']({'where':{'id':_0x28d4a4[_0xf492('0x4b')]['id']}})['then'](handleEntityNotFound(_0xe9e650,null))[_0xf492('0x24')](removeEntity(_0xe9e650,null))[_0xf492('0x4a')](handleError(_0xe9e650,null));};exports[_0xf492('0x5c')]=function(_0x5b4966,_0x195f6a,_0x44f520){var _0x2fd687={'raw':![],'where':{}};var _0x1435b7={};var _0x265505={'count':0x0,'rows':[]};return db[_0xf492('0x35')][_0xf492('0x5d')]({'where':{'id':_0x5b4966['params']['id']}})[_0xf492('0x24')](handleEntityNotFound(_0x195f6a,null))[_0xf492('0x24')](function(_0x21d572){if(_0x21d572){_0x1435b7[_0xf492('0x38')]=_[_0xf492('0x3a')](db[_0xf492('0x5e')][_0xf492('0x36')]);_0x1435b7[_0xf492('0x39')]=_[_0xf492('0x3a')](_0x5b4966['query']);_0x1435b7[_0xf492('0x3b')]=_[_0xf492('0x3c')](_0x1435b7[_0xf492('0x38')],_0x1435b7[_0xf492('0x39')]);_0x2fd687[_0xf492('0x3d')]=_[_0xf492('0x3c')](_0x1435b7[_0xf492('0x38')],qs['fields'](_0x5b4966[_0xf492('0x39')][_0xf492('0x4c')]));_0x2fd687[_0xf492('0x3d')]=_0x2fd687[_0xf492('0x3d')][_0xf492('0x3e')]?_0x2fd687[_0xf492('0x3d')]:_0x1435b7[_0xf492('0x38')];if(!_0x5b4966[_0xf492('0x39')][_0xf492('0x3f')](_0xf492('0x5f'))){_0x2fd687['limit']=qs['limit'](_0x5b4966[_0xf492('0x39')][_0xf492('0x1e')]);_0x2fd687[_0xf492('0x1d')]=qs['offset'](_0x5b4966[_0xf492('0x39')][_0xf492('0x1d')]);}_0x2fd687[_0xf492('0x40')]=qs['sort'](_0x5b4966[_0xf492('0x39')][_0xf492('0x41')]);_0x2fd687[_0xf492('0x42')]=qs['filters'](_[_0xf492('0x43')](_0x5b4966['query'],_0x1435b7['filters']));_0x2fd687['where'][_0xf492('0x60')]=_0x21d572['id'];if(_0x5b4966[_0xf492('0x39')][_0xf492('0x46')]){_0x2fd687[_0xf492('0x42')]=_[_0xf492('0x44')](_0x2fd687['where'],{'$or':_[_0xf492('0x2a')](_0x2fd687['attributes'],function(_0xb858af){var _0x3f6611={};_0x3f6611[_0xb858af]={'$like':'%'+_0x5b4966[_0xf492('0x39')][_0xf492('0x46')]+'%'};return _0x3f6611;})});}_0x2fd687=_[_0xf492('0x44')]({},_0x2fd687,_0x5b4966[_0xf492('0x4d')]);return db[_0xf492('0x5e')][_0xf492('0x1c')]({'where':_0x2fd687[_0xf492('0x42')]})['then'](function(_0xf7718c){_0x265505[_0xf492('0x1c')]=_0xf7718c;if(_0x5b4966[_0xf492('0x39')][_0xf492('0x47')]){_0x2fd687['include']=[{'all':!![]}];}return db[_0xf492('0x5e')]['findAll'](_0x2fd687);})[_0xf492('0x24')](function(_0x4a09ed){_0x265505[_0xf492('0x61')]=_0x4a09ed;return _0x265505;});}})[_0xf492('0x24')](respondWithFilteredResult(_0x195f6a,_0x2fd687))[_0xf492('0x4a')](handleError(_0x195f6a,null));};exports[_0xf492('0x62')]=function(_0x15d6df,_0x24d36a,_0x479d5c){var _0x1edf8e={'raw':!![],'where':{}};var _0x5647a9={};var _0x61a77f={'count':0x0,'rows':[]};return db['VoiceQueue']['findOne']({'where':{'id':_0x15d6df[_0xf492('0x4b')]['id']}})[_0xf492('0x24')](handleEntityNotFound(_0x24d36a,null))['then'](function(_0x39a6e4){if(_0x39a6e4){_0x5647a9[_0xf492('0x38')]=_[_0xf492('0x3a')](db[_0xf492('0x63')][_0xf492('0x36')]);_0x5647a9[_0xf492('0x39')]=_['keys'](_0x15d6df['query']);_0x5647a9['filters']=_[_0xf492('0x3c')](_0x5647a9['model'],_0x5647a9[_0xf492('0x39')]);_0x1edf8e[_0xf492('0x3d')]=_[_0xf492('0x3c')](_0x5647a9['model'],qs[_0xf492('0x4c')](_0x15d6df['query'][_0xf492('0x4c')]));_0x1edf8e[_0xf492('0x3d')]=_0x1edf8e[_0xf492('0x3d')][_0xf492('0x3e')]?_0x1edf8e['attributes']:_0x5647a9[_0xf492('0x38')];if(!_0x15d6df[_0xf492('0x39')]['hasOwnProperty'](_0xf492('0x5f'))){_0x1edf8e[_0xf492('0x1e')]=qs[_0xf492('0x1e')](_0x15d6df[_0xf492('0x39')][_0xf492('0x1e')]);_0x1edf8e[_0xf492('0x1d')]=qs[_0xf492('0x1d')](_0x15d6df[_0xf492('0x39')][_0xf492('0x1d')]);}_0x1edf8e[_0xf492('0x40')]=qs[_0xf492('0x41')](_0x15d6df['query'][_0xf492('0x41')]);_0x1edf8e['where']=qs[_0xf492('0x3b')](_[_0xf492('0x43')](_0x15d6df[_0xf492('0x39')],_0x5647a9[_0xf492('0x3b')]));_0x1edf8e[_0xf492('0x42')][_0xf492('0x60')]=_0x39a6e4['id'];if(_0x15d6df[_0xf492('0x39')][_0xf492('0x46')]){_0x1edf8e['where']=_[_0xf492('0x44')](_0x1edf8e[_0xf492('0x42')],{'$or':_[_0xf492('0x2a')](_0x1edf8e[_0xf492('0x3d')],function(_0x1567e0){var _0x5845c8={};_0x5845c8[_0x1567e0]={'$like':'%'+_0x15d6df['query'][_0xf492('0x46')]+'%'};return _0x5845c8;})});}_0x1edf8e=_[_0xf492('0x44')]({},_0x1edf8e,_0x15d6df['options']);return db[_0xf492('0x63')][_0xf492('0x1c')]({'where':_0x1edf8e['where']})[_0xf492('0x24')](function(_0x3f9967){_0x61a77f[_0xf492('0x1c')]=_0x3f9967;if(_0x15d6df[_0xf492('0x39')][_0xf492('0x47')]){_0x1edf8e['include']=[{'all':!![]}];}return db[_0xf492('0x63')][_0xf492('0x49')](_0x1edf8e);})[_0xf492('0x24')](function(_0x59789e){_0x61a77f[_0xf492('0x61')]=_0x59789e;return _0x61a77f;});}})[_0xf492('0x24')](respondWithFilteredResult(_0x24d36a,_0x1edf8e))[_0xf492('0x4a')](handleError(_0x24d36a,null));};exports[_0xf492('0x64')]=function(_0xa2909,_0x2e93d6,_0x36e18a){var _0xcef401={'raw':!![],'where':{}};var _0x1146ef={};var _0x2429d5={'count':0x0,'rows':[]};return db[_0xf492('0x35')][_0xf492('0x5d')]({'where':{'id':_0xa2909[_0xf492('0x4b')]['id']}})['then'](handleEntityNotFound(_0x2e93d6,null))[_0xf492('0x24')](function(_0x3be1ad){if(_0x3be1ad){_0x1146ef[_0xf492('0x38')]=_['keys'](db[_0xf492('0x65')][_0xf492('0x36')]);_0x1146ef[_0xf492('0x39')]=_[_0xf492('0x3a')](_0xa2909[_0xf492('0x39')]);_0x1146ef[_0xf492('0x3b')]=_[_0xf492('0x3c')](_0x1146ef['model'],_0x1146ef[_0xf492('0x39')]);_0xcef401['attributes']=_[_0xf492('0x3c')](_0x1146ef[_0xf492('0x38')],qs[_0xf492('0x4c')](_0xa2909[_0xf492('0x39')][_0xf492('0x4c')]));_0xcef401['attributes']=_0xcef401[_0xf492('0x3d')][_0xf492('0x3e')]?_0xcef401[_0xf492('0x3d')]:_0x1146ef['model'];if(!_0xa2909['query'][_0xf492('0x3f')]('nolimit')){_0xcef401['limit']=qs[_0xf492('0x1e')](_0xa2909[_0xf492('0x39')][_0xf492('0x1e')]);_0xcef401['offset']=qs[_0xf492('0x1d')](_0xa2909[_0xf492('0x39')]['offset']);}_0xcef401[_0xf492('0x40')]=qs[_0xf492('0x41')](_0xa2909[_0xf492('0x39')][_0xf492('0x41')]);_0xcef401['where']=qs[_0xf492('0x3b')](_['pick'](_0xa2909[_0xf492('0x39')],_0x1146ef[_0xf492('0x3b')]));_0xcef401[_0xf492('0x42')][_0xf492('0x60')]=_0x3be1ad['id'];if(_0xa2909['query'][_0xf492('0x46')]){_0xcef401[_0xf492('0x42')]=_[_0xf492('0x44')](_0xcef401[_0xf492('0x42')],{'$or':_[_0xf492('0x2a')](_0xcef401['attributes'],function(_0x5851f9){var _0x3fef1f={};_0x3fef1f[_0x5851f9]={'$like':'%'+_0xa2909['query'][_0xf492('0x46')]+'%'};return _0x3fef1f;})});}_0xcef401=_[_0xf492('0x44')]({},_0xcef401,_0xa2909['options']);return db[_0xf492('0x65')][_0xf492('0x1c')]({'where':_0xcef401[_0xf492('0x42')]})['then'](function(_0x1898b1){_0x2429d5[_0xf492('0x1c')]=_0x1898b1;if(_0xa2909[_0xf492('0x39')][_0xf492('0x47')]){_0xcef401['include']=[{'all':!![]}];}return db['CmHopperFinal'][_0xf492('0x49')](_0xcef401);})[_0xf492('0x24')](function(_0x1cc11e){_0x2429d5['rows']=_0x1cc11e;return _0x2429d5;});}})[_0xf492('0x24')](respondWithFilteredResult(_0x2e93d6,_0xcef401))['catch'](handleError(_0x2e93d6,null));};exports[_0xf492('0x66')]=function(_0x54e85e,_0x39d425,_0x21b6ff){var _0x2542e5={'raw':!![],'where':{}};var _0x34242d={};var _0x4ee001={'count':0x0,'rows':[]};return db['VoiceQueue'][_0xf492('0x5d')]({'where':{'id':_0x54e85e[_0xf492('0x4b')]['id']}})[_0xf492('0x24')](handleEntityNotFound(_0x39d425,null))['then'](function(_0x53d384){if(_0x53d384){_0x34242d[_0xf492('0x38')]=_['keys'](db['CmHopperBlack'][_0xf492('0x36')]);_0x34242d['query']=_[_0xf492('0x3a')](_0x54e85e[_0xf492('0x39')]);_0x34242d[_0xf492('0x3b')]=_[_0xf492('0x3c')](_0x34242d[_0xf492('0x38')],_0x34242d[_0xf492('0x39')]);_0x2542e5[_0xf492('0x3d')]=_['intersection'](_0x34242d[_0xf492('0x38')],qs[_0xf492('0x4c')](_0x54e85e['query'][_0xf492('0x4c')]));_0x2542e5[_0xf492('0x3d')]=_0x2542e5[_0xf492('0x3d')][_0xf492('0x3e')]?_0x2542e5['attributes']:_0x34242d['model'];if(!_0x54e85e[_0xf492('0x39')][_0xf492('0x3f')](_0xf492('0x5f'))){_0x2542e5[_0xf492('0x1e')]=qs[_0xf492('0x1e')](_0x54e85e[_0xf492('0x39')]['limit']);_0x2542e5['offset']=qs[_0xf492('0x1d')](_0x54e85e[_0xf492('0x39')][_0xf492('0x1d')]);}_0x2542e5[_0xf492('0x40')]=qs[_0xf492('0x41')](_0x54e85e[_0xf492('0x39')][_0xf492('0x41')]);_0x2542e5[_0xf492('0x42')]=qs[_0xf492('0x3b')](_[_0xf492('0x43')](_0x54e85e[_0xf492('0x39')],_0x34242d[_0xf492('0x3b')]));_0x2542e5[_0xf492('0x42')][_0xf492('0x60')]=_0x53d384['id'];if(_0x54e85e['query'][_0xf492('0x46')]){_0x2542e5['where']=_[_0xf492('0x44')](_0x2542e5['where'],{'$or':_[_0xf492('0x2a')](_0x2542e5[_0xf492('0x3d')],function(_0x971e01){var _0x30dcb={};_0x30dcb[_0x971e01]={'$like':'%'+_0x54e85e[_0xf492('0x39')][_0xf492('0x46')]+'%'};return _0x30dcb;})});}_0x2542e5=_[_0xf492('0x44')]({},_0x2542e5,_0x54e85e[_0xf492('0x4d')]);return db[_0xf492('0x67')][_0xf492('0x1c')]({'where':_0x2542e5[_0xf492('0x42')]})['then'](function(_0x48403c){_0x4ee001[_0xf492('0x1c')]=_0x48403c;if(_0x54e85e['query'][_0xf492('0x47')]){_0x2542e5[_0xf492('0x48')]=[{'all':!![]}];}return db[_0xf492('0x67')]['findAll'](_0x2542e5);})['then'](function(_0x2d666d){_0x4ee001[_0xf492('0x61')]=_0x2d666d;return _0x4ee001;});}})[_0xf492('0x24')](respondWithFilteredResult(_0x39d425,_0x2542e5))[_0xf492('0x4a')](handleError(_0x39d425,null));};exports[_0xf492('0x68')]=function(_0x496f49,_0x40ec96,_0x1a74f6){var _0x95cc23={};var _0x27fdc3={};var _0x425076;var _0x26d551;return db['VoiceQueue']['findOne']({'where':{'id':_0x496f49['params']['id']}})[_0xf492('0x24')](handleEntityNotFound(_0x40ec96,null))['then'](function(_0x26583c){if(_0x26583c){_0x425076=_0x26583c;_0x27fdc3[_0xf492('0x38')]=_['keys'](db['Team'][_0xf492('0x36')]);_0x27fdc3[_0xf492('0x39')]=_[_0xf492('0x3a')](_0x496f49['query']);_0x27fdc3[_0xf492('0x3b')]=_['intersection'](_0x27fdc3[_0xf492('0x38')],_0x27fdc3['query']);_0x95cc23[_0xf492('0x3d')]=_[_0xf492('0x3c')](_0x27fdc3['model'],qs['fields'](_0x496f49[_0xf492('0x39')][_0xf492('0x4c')]));_0x95cc23['attributes']=_0x95cc23[_0xf492('0x3d')][_0xf492('0x3e')]?_0x95cc23[_0xf492('0x3d')]:_0x27fdc3[_0xf492('0x38')];_0x95cc23[_0xf492('0x40')]=qs[_0xf492('0x41')](_0x496f49[_0xf492('0x39')][_0xf492('0x41')]);_0x95cc23[_0xf492('0x42')]=qs[_0xf492('0x3b')](_[_0xf492('0x43')](_0x496f49[_0xf492('0x39')],_0x27fdc3[_0xf492('0x3b')]));if(_0x496f49[_0xf492('0x39')]['filter']){_0x95cc23['where']=_['merge'](_0x95cc23[_0xf492('0x42')],{'$or':_[_0xf492('0x2a')](_0x95cc23['attributes'],function(_0x52b4f0){var _0x4f7554={};_0x4f7554[_0x52b4f0]={'$like':'%'+_0x496f49['query'][_0xf492('0x46')]+'%'};return _0x4f7554;})});}_0x95cc23=_['merge']({},_0x95cc23,_0x496f49[_0xf492('0x4d')]);return _0x425076[_0xf492('0x68')](_0x95cc23);}})[_0xf492('0x24')](function(_0x172b28){if(_0x172b28){_0x26d551=_0x172b28[_0xf492('0x3e')];if(!_0x496f49[_0xf492('0x39')]['hasOwnProperty'](_0xf492('0x5f'))){_0x95cc23[_0xf492('0x1e')]=qs[_0xf492('0x1e')](_0x496f49[_0xf492('0x39')][_0xf492('0x1e')]);_0x95cc23[_0xf492('0x1d')]=qs[_0xf492('0x1d')](_0x496f49[_0xf492('0x39')][_0xf492('0x1d')]);}return _0x425076['getTeams'](_0x95cc23);}})[_0xf492('0x24')](function(_0x5b3538){if(_0x5b3538){return _0x5b3538?{'count':_0x26d551,'rows':_0x5b3538}:null;}})['then'](respondWithResult(_0x40ec96,null))[_0xf492('0x4a')](handleError(_0x40ec96,null));};exports[_0xf492('0x69')]=function(_0x4a281c,_0x38c217,_0x57f259){var _0x77c18e=_0x4a281c[_0xf492('0x5a')][_0xf492('0x6a')];var _0x4f3e8b=_[_0xf492('0x2a')](_0x77c18e,'id');return db[_0xf492('0x6b')][_0xf492('0x49')]({'where':{'id':_0x4f3e8b},'attributes':['id'],'include':[{'model':db[_0xf492('0x6c')],'as':_0xf492('0x6d'),'attributes':['id',_0xf492('0x32'),'online',_0xf492('0x6e'),_0xf492('0x6f')],'raw':!![]}]})[_0xf492('0x24')](function(_0x1bea8f){if(_0x1bea8f){var _0x5a369d=_[_0xf492('0x70')](_0x1bea8f,function(_0x5f3f27){var _0x279943=_0x5f3f27[_0xf492('0x50')]({'plain':!![]});_0x279943[_0xf492('0x6d')]['forEach'](function(_0x58ea26){_0x58ea26[_0xf492('0x71')]=_[_0xf492('0x2e')](_0x77c18e,{'id':_0x279943['id']})[_0xf492('0x71')];});return _0x279943[_0xf492('0x6d')];});return db[_0xf492('0x35')][_0xf492('0x2e')]({'where':{'id':_0x4a281c[_0xf492('0x4b')]['id']}})[_0xf492('0x24')](function(_0x5527ba){return db[_0xf492('0x72')]['transaction'](function(_0x229842){return _0x5527ba[_0xf492('0x69')](_0x4f3e8b,{'transaction':_0x229842})[_0xf492('0x24')](function(){return BPromise['each'](_0x5a369d,function(_0xf5504){return db['UserVoiceQueue']['findOrCreate']({'where':{'UserId':_0xf5504['id'],'VoiceQueueId':_0x4a281c[_0xf492('0x4b')]['id']},'defaults':{'penalty':_0xf5504[_0xf492('0x71')]},'transaction':_0x229842});});})[_0xf492('0x24')](function(){return BPromise[_0xf492('0x73')](_['filter'](_0x5a369d,{'online':!![]}),function(_0x55fcba){return db[_0xf492('0x74')][_0xf492('0x75')]({'membername':_0x55fcba[_0xf492('0x32')],'UserId':_0x55fcba['id'],'queue_name':_0x5527ba[_0xf492('0x32')],'VoiceQueueId':_0x5527ba['id'],'interface':_[_0xf492('0x76')](_0x55fcba[_0xf492('0x6f')])?util['format'](_0xf492('0x77'),_0x55fcba[_0xf492('0x32')]):_0x55fcba['interface'],'paused':_0x55fcba['voicePause']||![],'penalty':_0x55fcba[_0xf492('0x71')]},{'transaction':_0x229842});});})[_0xf492('0x24')](function(){_0x5a369d[_0xf492('0x78')](function(_0x4dd447){socket['emit']('userVoiceQueue:save',{'UserId':_0x4dd447['id'],'VoiceQueueId':_0x5527ba['id']});});});});});}})[_0xf492('0x24')](respondWithStatusCode(_0x38c217,null))['catch'](handleError(_0x38c217,null));};exports['removeTeams']=function(_0x5bf244,_0x322d39,_0x1d9fd0){return db[_0xf492('0x6b')]['findAll']({'where':{'id':_0x5bf244['query']['ids']},'attributes':['id'],'include':[{'model':db[_0xf492('0x6c')],'as':_0xf492('0x6d'),'attributes':['id'],'raw':!![]}]})[_0xf492('0x24')](handleEntityNotFound(_0x322d39,null))['then'](function(_0x48cb87){var _0x2b8ac6=_[_0xf492('0x2a')](_0x48cb87,'id');var _0x513fc3=[];var _0x2bf10b=[];var _0x486082=squel[_0xf492('0x79')]();_0x486082[_0xf492('0x7a')](_0xf492('0x7b'))['from']('team_has_voice_queues','tq')[_0xf492('0x7c')](_0xf492('0x7d'),'ut','ut.TeamId\x20=\x20tq.TeamId')['where'](_0xf492('0x7e'),_0x5bf244[_0xf492('0x4b')]['id']);for(var _0x1de0bb=0x0;_0x1de0bb<_0x48cb87[_0xf492('0x3e')];_0x1de0bb+=0x1){let _0x5e0b0f=_0x48cb87[_0x1de0bb];for(var _0x1de59b=0x0;_0x1de59b<_0x5e0b0f[_0xf492('0x6d')][_0xf492('0x3e')];_0x1de59b+=0x1){let _0x145009=_0x5e0b0f[_0xf492('0x6d')][_0x1de59b];var _0x2979f8=_0x486082['clone']();_0x2979f8[_0xf492('0x42')](_0xf492('0x7f'),_0x145009['id']);_0x2bf10b['push'](db[_0xf492('0x72')][_0xf492('0x39')](_0x2979f8[_0xf492('0x80')](),{'type':db[_0xf492('0x72')][_0xf492('0x81')][_0xf492('0x82')]})[_0xf492('0x24')](function(_0x4340e1){if(_0x4340e1[_0xf492('0x3e')]===0x1){return _0x145009['id'];}else{var _0x40b802=_[_0xf492('0x83')](_[_0xf492('0x2a')](_0x4340e1,_0xf492('0x84')),function(_0x3e8aac){return _[_0xf492('0x2c')](_0x2b8ac6,_0x3e8aac);});if(_0x40b802){return _0x145009['id'];}}}));}}return BPromise['all'](_0x2bf10b)['then'](function(_0x569e73){_0x513fc3=_(_0x513fc3)['union'](_0x569e73)[_0xf492('0x85')]()[_0xf492('0x2b')]();return db[_0xf492('0x35')]['find']({'where':{'id':_0x5bf244[_0xf492('0x4b')]['id']}})[_0xf492('0x24')](function(_0x2ebd49){return db['sequelize']['transaction'](function(_0x5e837e){return _0x2ebd49['removeTeams'](_0x5bf244[_0xf492('0x39')][_0xf492('0x86')],{'transaction':_0x5e837e})[_0xf492('0x24')](function(){if(!_[_0xf492('0x87')](_0x513fc3)){return _0x2ebd49[_0xf492('0x88')](_0x513fc3,{'transaction':_0x5e837e})[_0xf492('0x24')](function(){return db[_0xf492('0x74')][_0xf492('0x25')]({'where':{'VoiceQueueId':_0x5bf244['params']['id'],'UserId':_0x513fc3},'transaction':_0x5e837e});});}})[_0xf492('0x24')](function(){_0x513fc3[_0xf492('0x78')](function(_0x2e9ec2){socket['emit'](_0xf492('0x89'),{'UserId':_0x2e9ec2,'VoiceQueueId':_0x2ebd49['id']});});});});});});})[_0xf492('0x24')](respondWithStatusCode(_0x322d39,null))[_0xf492('0x4a')](handleError(_0x322d39,null));};exports['addAgents']=function(_0x45f189,_0x45a6cf,_0x179ca6){var _0x148795,_0x2380c2;return db[_0xf492('0x35')][_0xf492('0x2e')]({'where':{'id':_0x45f189['params']['id']}})[_0xf492('0x24')](handleEntityNotFound(_0x45a6cf,null))['then'](function(_0x2c3f7d){if(_0x2c3f7d){_0x2380c2=_0x2c3f7d;return _0x2c3f7d[_0xf492('0x8a')](_0x45f189[_0xf492('0x5a')][_0xf492('0x86')],_[_0xf492('0x5b')](_0x45f189['body'],[_0xf492('0x86'),'id'])||{})[_0xf492('0x8b')](function(_0xe5dd89){for(var _0x14a7ac=0x0;_0x14a7ac<_0x45f189[_0xf492('0x5a')][_0xf492('0x86')][_0xf492('0x3e')];_0x14a7ac+=0x1){socket[_0xf492('0x8c')](_0xf492('0x8d'),{'UserId':_0x45f189['body']['ids'][_0x14a7ac],'VoiceQueueId':_0x45f189[_0xf492('0x4b')]['id']});}return _0xe5dd89;});}})['then'](function(_0x23ab92){_0x148795=_0x23ab92||[];if(_0x2380c2){return db[_0xf492('0x6c')][_0xf492('0x49')]({'where':{'id':_0x45f189['body'][_0xf492('0x86')]},'attributes':['id',_0xf492('0x32'),'online',_0xf492('0x6e'),'interface'],'raw':!![]});}})[_0xf492('0x24')](function(_0x54b68b){if(!_[_0xf492('0x87')](_0x54b68b)){var _0x560458=[];for(var _0x1cd14a=0x0;_0x1cd14a<_0x54b68b['length'];_0x1cd14a++){if(_0x54b68b[_0x1cd14a][_0xf492('0x8e')]){_0x560458[_0xf492('0x8f')](db[_0xf492('0x74')][_0xf492('0x75')]({'membername':_0x54b68b[_0x1cd14a][_0xf492('0x32')],'UserId':_0x54b68b[_0x1cd14a]['id'],'queue_name':_0x2380c2[_0xf492('0x32')],'VoiceQueueId':_0x2380c2['id'],'interface':_[_0xf492('0x76')](_0x54b68b[_0x1cd14a][_0xf492('0x6f')])?util[_0xf492('0x90')](_0xf492('0x77'),_0x54b68b[_0x1cd14a][_0xf492('0x32')]):_0x54b68b[_0x1cd14a]['interface'],'paused':_0x54b68b[_0x1cd14a][_0xf492('0x6e')]||![],'penalty':_0x45f189[_0xf492('0x5a')][_0xf492('0x71')]||0x0}));}}return BPromise[_0xf492('0x91')](_0x560458);}})[_0xf492('0x24')](function(){return _0x148795;})[_0xf492('0x24')](respondWithResult(_0x45a6cf,null))['catch'](handleError(_0x45a6cf,null));};exports[_0xf492('0x88')]=function(_0x1936c7,_0x20ee1e,_0x5b9be8){return db[_0xf492('0x35')]['find']({'where':{'id':_0x1936c7[_0xf492('0x4b')]['id']}})[_0xf492('0x24')](handleEntityNotFound(_0x20ee1e,null))['then'](function(_0x8d2f53){if(_0x8d2f53){return _0x8d2f53[_0xf492('0x88')](_0x1936c7[_0xf492('0x39')][_0xf492('0x86')])['then'](function(){if(_[_0xf492('0x92')](_0x1936c7['query'][_0xf492('0x86')])){for(var _0x1bcab2=0x0;_0x1bcab2<_0x1936c7[_0xf492('0x39')][_0xf492('0x86')]['length'];_0x1bcab2+=0x1){socket[_0xf492('0x8c')](_0xf492('0x89'),{'UserId':Number(_0x1936c7['query']['ids'][_0x1bcab2]),'VoiceQueueId':Number(_0x1936c7[_0xf492('0x4b')]['id'])});}}else{socket[_0xf492('0x8c')](_0xf492('0x89'),{'UserId':Number(_0x1936c7[_0xf492('0x39')][_0xf492('0x86')]),'VoiceQueueId':Number(_0x1936c7[_0xf492('0x4b')]['id'])});}});}})[_0xf492('0x24')](function(_0x19cb9a){return db[_0xf492('0x74')][_0xf492('0x25')]({'where':{'VoiceQueueId':_0x1936c7[_0xf492('0x4b')]['id'],'UserId':_0x1936c7['query'][_0xf492('0x86')]}})[_0xf492('0x24')](function(){return _0x19cb9a;});})[_0xf492('0x24')](respondWithStatusCode(_0x20ee1e,null))[_0xf492('0x4a')](handleError(_0x20ee1e,null));};exports[_0xf492('0x93')]=function(_0x997c60,_0x1c8086,_0x3beb91){var _0x52d3a1={};var _0x1a0239={};var _0x41096c;var _0x4a8c35;return db[_0xf492('0x35')]['findOne']({'where':{'id':_0x997c60['params']['id']}})[_0xf492('0x24')](handleEntityNotFound(_0x1c8086,null))[_0xf492('0x24')](function(_0x252413){if(_0x252413){_0x41096c=_0x252413;_0x1a0239[_0xf492('0x38')]=_['keys'](db[_0xf492('0x6c')][_0xf492('0x36')]);_0x1a0239['query']=_['keys'](_0x997c60['query']);_0x1a0239[_0xf492('0x3b')]=_[_0xf492('0x3c')](_0x1a0239[_0xf492('0x38')],_0x1a0239[_0xf492('0x39')]);_0x52d3a1[_0xf492('0x3d')]=_['intersection'](_0x1a0239[_0xf492('0x38')],qs[_0xf492('0x4c')](_0x997c60[_0xf492('0x39')][_0xf492('0x4c')]));_0x52d3a1[_0xf492('0x3d')]=_0x52d3a1[_0xf492('0x3d')][_0xf492('0x3e')]?_0x52d3a1[_0xf492('0x3d')]:_0x1a0239[_0xf492('0x38')];_0x52d3a1[_0xf492('0x40')]=qs[_0xf492('0x41')](_0x997c60['query'][_0xf492('0x41')]);_0x52d3a1['where']=qs[_0xf492('0x3b')](_['pick'](_0x997c60[_0xf492('0x39')],_0x1a0239[_0xf492('0x3b')]));if(_0x997c60[_0xf492('0x39')][_0xf492('0x46')]){_0x52d3a1[_0xf492('0x42')]=_[_0xf492('0x44')](_0x52d3a1[_0xf492('0x42')],{'$or':_['map'](_0x52d3a1[_0xf492('0x3d')],function(_0x3af4f1){var _0x1e3700={};_0x1e3700[_0x3af4f1]={'$like':'%'+_0x997c60[_0xf492('0x39')][_0xf492('0x46')]+'%'};return _0x1e3700;})});}_0x52d3a1=_[_0xf492('0x44')]({},_0x52d3a1,_0x997c60['options']);return _0x41096c[_0xf492('0x93')](_0x52d3a1);}})[_0xf492('0x24')](function(_0x210c9a){if(_0x210c9a){_0x4a8c35=_0x210c9a['length'];if(!_0x997c60[_0xf492('0x39')][_0xf492('0x3f')](_0xf492('0x5f'))){_0x52d3a1[_0xf492('0x1e')]=qs[_0xf492('0x1e')](_0x997c60[_0xf492('0x39')][_0xf492('0x1e')]);_0x52d3a1[_0xf492('0x1d')]=qs[_0xf492('0x1d')](_0x997c60[_0xf492('0x39')][_0xf492('0x1d')]);}return _0x41096c[_0xf492('0x93')](_0x52d3a1);}})['then'](function(_0x23a5b5){if(_0x23a5b5){return _0x23a5b5?{'count':_0x4a8c35,'rows':_0x23a5b5}:null;}})[_0xf492('0x24')](respondWithResult(_0x1c8086,null))[_0xf492('0x4a')](handleError(_0x1c8086,null));};exports[_0xf492('0x94')]=function(_0x1ea762,_0x15adfa,_0x44e1dd){var _0x46cb59={};var _0x2a812b={};var _0xa7b1a9;var _0x9b3be5;return db[_0xf492('0x35')]['findOne']({'where':{'id':_0x1ea762[_0xf492('0x4b')]['id']}})['then'](handleEntityNotFound(_0x15adfa,null))[_0xf492('0x24')](function(_0x1bcca8){if(_0x1bcca8){_0xa7b1a9=_0x1bcca8;_0x2a812b[_0xf492('0x38')]=_[_0xf492('0x3a')](db[_0xf492('0x74')]['rawAttributes']);_0x2a812b[_0xf492('0x39')]=_[_0xf492('0x3a')](_0x1ea762['query']);_0x2a812b['filters']=_[_0xf492('0x3c')](_0x2a812b[_0xf492('0x38')],_0x2a812b[_0xf492('0x39')]);_0x46cb59[_0xf492('0x3d')]=_[_0xf492('0x3c')](_0x2a812b[_0xf492('0x38')],qs['fields'](_0x1ea762[_0xf492('0x39')][_0xf492('0x4c')]));_0x46cb59['attributes']=_0x46cb59[_0xf492('0x3d')][_0xf492('0x3e')]?_0x46cb59[_0xf492('0x3d')]:_0x2a812b[_0xf492('0x38')];_0x46cb59[_0xf492('0x40')]=qs[_0xf492('0x41')](_0x1ea762['query'][_0xf492('0x41')]);_0x46cb59[_0xf492('0x42')]=qs['filters'](_[_0xf492('0x43')](_0x1ea762[_0xf492('0x39')],_0x2a812b['filters']));if(_0x1ea762[_0xf492('0x39')]['filter']){_0x46cb59[_0xf492('0x42')]=_[_0xf492('0x44')](_0x46cb59[_0xf492('0x42')],{'$or':_[_0xf492('0x2a')](_0x46cb59[_0xf492('0x3d')],function(_0x4661d0){var _0x3693d6={};_0x3693d6[_0x4661d0]={'$like':'%'+_0x1ea762[_0xf492('0x39')][_0xf492('0x46')]+'%'};return _0x3693d6;})});}_0x46cb59=_[_0xf492('0x44')]({},_0x46cb59,_0x1ea762['options']);return _0xa7b1a9[_0xf492('0x94')](_0x46cb59);}})[_0xf492('0x24')](function(_0xac4436){if(_0xac4436){_0x9b3be5=_0xac4436[_0xf492('0x3e')];if(!_0x1ea762['query'][_0xf492('0x3f')]('nolimit')){_0x46cb59[_0xf492('0x1e')]=qs['limit'](_0x1ea762['query'][_0xf492('0x1e')]);_0x46cb59['offset']=qs[_0xf492('0x1d')](_0x1ea762[_0xf492('0x39')][_0xf492('0x1d')]);}return _0xa7b1a9['getMembers'](_0x46cb59);}})['then'](function(_0x53d3df){return _0x53d3df?{'count':_0x9b3be5,'rows':_0x53d3df}:null;})['then'](respondWithResult(_0x15adfa,null))['catch'](handleError(_0x15adfa,null));};exports['getLists']=function(_0x1f312d,_0x475577,_0x106ea5){var _0x2602f2={};var _0x237ea1={};var _0x26ec85;var _0x204646;return db['VoiceQueue'][_0xf492('0x5d')]({'where':{'id':_0x1f312d['params']['id']}})['then'](handleEntityNotFound(_0x475577,null))[_0xf492('0x24')](function(_0x4a411f){if(_0x4a411f){_0x26ec85=_0x4a411f;_0x237ea1[_0xf492('0x38')]=_[_0xf492('0x3a')](db[_0xf492('0x95')]['rawAttributes']);_0x237ea1[_0xf492('0x39')]=_['keys'](_0x1f312d[_0xf492('0x39')]);_0x237ea1['filters']=_['intersection'](_0x237ea1['model'],_0x237ea1[_0xf492('0x39')]);_0x2602f2[_0xf492('0x3d')]=_[_0xf492('0x3c')](_0x237ea1[_0xf492('0x38')],qs[_0xf492('0x4c')](_0x1f312d['query']['fields']));_0x2602f2['attributes']=_0x2602f2[_0xf492('0x3d')][_0xf492('0x3e')]?_0x2602f2[_0xf492('0x3d')]:_0x237ea1[_0xf492('0x38')];_0x2602f2[_0xf492('0x40')]=qs[_0xf492('0x41')](_0x1f312d[_0xf492('0x39')][_0xf492('0x41')]);_0x2602f2[_0xf492('0x42')]=qs['filters'](_[_0xf492('0x43')](_0x1f312d[_0xf492('0x39')],_0x237ea1[_0xf492('0x3b')]));if(_0x1f312d[_0xf492('0x39')][_0xf492('0x46')]){_0x2602f2[_0xf492('0x42')]=_[_0xf492('0x44')](_0x2602f2['where'],{'$or':_[_0xf492('0x2a')](_0x2602f2['attributes'],function(_0x4cdba5){var _0x36de7e={};_0x36de7e[_0x4cdba5]={'$like':'%'+_0x1f312d[_0xf492('0x39')][_0xf492('0x46')]+'%'};return _0x36de7e;})});}_0x2602f2=_[_0xf492('0x44')]({},_0x2602f2,_0x1f312d[_0xf492('0x4d')]);return _0x26ec85[_0xf492('0x96')](_0x2602f2);}})[_0xf492('0x24')](function(_0x133066){if(_0x133066){_0x204646=_0x133066[_0xf492('0x3e')];if(!_0x1f312d[_0xf492('0x39')][_0xf492('0x3f')](_0xf492('0x5f'))){_0x2602f2['limit']=qs['limit'](_0x1f312d['query']['limit']);_0x2602f2['offset']=qs[_0xf492('0x1d')](_0x1f312d[_0xf492('0x39')][_0xf492('0x1d')]);}return _0x26ec85[_0xf492('0x96')](_0x2602f2);}})['then'](function(_0x3ca8cb){if(_0x3ca8cb){return _0x3ca8cb?{'count':_0x204646,'rows':_0x3ca8cb}:null;}})['then'](respondWithResult(_0x475577,null))[_0xf492('0x4a')](handleError(_0x475577,null));};exports[_0xf492('0x97')]=function(_0x251403,_0x1e21fa,_0x3255ed){var _0x589a07,_0x286fc2;return db['VoiceQueue']['find']({'where':{'id':_0x251403[_0xf492('0x4b')]['id']}})['then'](handleEntityNotFound(_0x1e21fa,null))[_0xf492('0x24')](function(_0x21d519){if(_0x21d519){_0x286fc2=_0x21d519;return _0x21d519['addLists'](_0x251403[_0xf492('0x5a')][_0xf492('0x86')],_['omit'](_0x251403[_0xf492('0x5a')],[_0xf492('0x86'),'id'])||{});}return null;})['spread'](function(_0x2e8bbb){var _0xc54a7;_0x589a07=_0x2e8bbb||[];var _0x330f0a=[];if(_0x2e8bbb){for(var _0x4eb7f4=0x0;_0x4eb7f4<_0x2e8bbb['length'];_0x4eb7f4+=0x1){var _0x3516bc=_0x2e8bbb[_0x4eb7f4][_0xf492('0x50')]({'plain':!![]});_0x286fc2['dialCheckDuplicateType']=_0x251403[_0xf492('0x5a')][_0xf492('0x98')]?_0x251403[_0xf492('0x5a')][_0xf492('0x98')]:_0x286fc2[_0xf492('0x98')];switch(_0x286fc2[_0xf492('0x98')]){case'always':_0xc54a7=squel[_0xf492('0x99')]()[_0xf492('0x9a')](_0xf492('0x9b'))[_0xf492('0x9c')]([_0xf492('0x9d'),'scheduledAt',_0xf492('0x9e'),_0xf492('0x9f'),'VoiceQueueId','createdAt',_0xf492('0x59')],squel[_0xf492('0x79')]()[_0xf492('0x7a')](_0xf492('0x9d'),'phone')[_0xf492('0x7a')](_0xf492('0xa0'),_0xf492('0xa1'))[_0xf492('0x7a')]('id','ContactId')[_0xf492('0x7a')](_0x3516bc['CmListId'][_0xf492('0x80')](),'ListId')[_0xf492('0x7a')](_0x251403[_0xf492('0x4b')]['id'][_0xf492('0x80')](),_0xf492('0x60'))['field'](_0xf492('0xa0'),_0xf492('0x58'))[_0xf492('0x7a')](_0xf492('0xa0'),_0xf492('0x59'))[_0xf492('0xa2')](_0xf492('0xa3'))[_0xf492('0x42')](_0xf492('0xa4'))['where']('ListId\x20=\x20?',_0x3516bc[_0xf492('0xa5')][_0xf492('0x80')]())[_0xf492('0x42')](_0xf492('0xa6'))[_0xf492('0x42')]('phone\x20NOT\x20IN\x20(?)',squel['select']()[_0xf492('0x7a')](_0xf492('0xa7'))[_0xf492('0xa2')](_0xf492('0xa8'))['where'](_0xf492('0x7e'),_0x251403[_0xf492('0x4b')]['id'][_0xf492('0x80')]()))['where']('phone\x20NOT\x20IN\x20(?)',squel[_0xf492('0x79')]()[_0xf492('0x7a')]('COALESCE(phone,\x27\x27)')[_0xf492('0xa2')](_0xf492('0x9b'))[_0xf492('0x42')](_0xf492('0x7e'),_0x251403['params']['id'][_0xf492('0x80')]())))[_0xf492('0x80')]();break;case _0xf492('0xa9'):_0xc54a7=squel[_0xf492('0x99')]()['into'](_0xf492('0x9b'))[_0xf492('0x9c')]([_0xf492('0x9d'),_0xf492('0xa1'),_0xf492('0x9e'),_0xf492('0x9f'),_0xf492('0x60'),'createdAt','updatedAt'],squel['select']()[_0xf492('0x7a')](_0xf492('0x9d'),_0xf492('0x9d'))[_0xf492('0x7a')](_0xf492('0xa0'),'scheduledAt')[_0xf492('0x7a')]('id',_0xf492('0x9e'))[_0xf492('0x7a')](_0x3516bc['CmListId'][_0xf492('0x80')](),_0xf492('0x9f'))['field'](_0x251403[_0xf492('0x4b')]['id'][_0xf492('0x80')](),'VoiceQueueId')[_0xf492('0x7a')](_0xf492('0xa0'),_0xf492('0x58'))[_0xf492('0x7a')](_0xf492('0xa0'),_0xf492('0x59'))[_0xf492('0xa2')]('cm_contacts')[_0xf492('0x42')](_0xf492('0xa4'))[_0xf492('0x42')]('ListId\x20=\x20?',_0x3516bc['CmListId'][_0xf492('0x80')]())[_0xf492('0x42')]('phone\x20IS\x20NOT\x20NULL')[_0xf492('0x42')](_0xf492('0xaa'),squel[_0xf492('0x79')]()['field'](_0xf492('0xab'))[_0xf492('0xa2')](_0xf492('0x9b'))[_0xf492('0x42')]('VoiceQueueId\x20=\x20?',_0x251403['params']['id'][_0xf492('0x80')]())))['toString']();break;default:_0xc54a7=squel['insert']()[_0xf492('0x9a')](_0xf492('0x9b'))[_0xf492('0x9c')]([_0xf492('0x9d'),_0xf492('0xa1'),_0xf492('0x9e'),_0xf492('0x9f'),_0xf492('0x60'),_0xf492('0x58'),'updatedAt'],squel[_0xf492('0x79')]()[_0xf492('0x7a')]('phone',_0xf492('0x9d'))[_0xf492('0x7a')](_0xf492('0xa0'),'scheduledAt')[_0xf492('0x7a')]('id','ContactId')[_0xf492('0x7a')](_0x3516bc[_0xf492('0xa5')][_0xf492('0x80')](),_0xf492('0x9f'))[_0xf492('0x7a')](_0x251403[_0xf492('0x4b')]['id'][_0xf492('0x80')](),_0xf492('0x60'))[_0xf492('0x7a')]('NOW()','createdAt')[_0xf492('0x7a')](_0xf492('0xa0'),_0xf492('0x59'))[_0xf492('0xa2')](_0xf492('0xa3'))[_0xf492('0x42')](_0xf492('0xa4'))[_0xf492('0x42')]('ListId\x20=\x20?',_0x3516bc[_0xf492('0xa5')][_0xf492('0x80')]())['where'](_0xf492('0xa6')))[_0xf492('0x80')]();}_0x330f0a[_0xf492('0x8f')](db['sequelize'][_0xf492('0x39')](_0xc54a7));}return BPromise['all'](_0x330f0a);}})['then'](function(){return _0x589a07;})[_0xf492('0x24')](respondWithResult(_0x1e21fa,null))['catch'](handleError(_0x1e21fa,null));};exports[_0xf492('0xac')]=function(_0x894b71,_0x444868,_0xff10d6){return db[_0xf492('0x35')][_0xf492('0x2e')]({'where':{'id':_0x894b71['params']['id']}})[_0xf492('0x24')](handleEntityNotFound(_0x444868,null))[_0xf492('0x24')](function(_0xb983ee){if(_0xb983ee){return _0xb983ee[_0xf492('0xac')](_0x894b71[_0xf492('0x39')][_0xf492('0x86')]);}})[_0xf492('0x24')](function(_0x2c5004){if(_0x2c5004){return db[_0xf492('0x5e')]['destroy']({'where':{'ListId':_0x894b71['query']['ids'],'VoiceQueueId':_0x894b71[_0xf492('0x4b')]['id']}})[_0xf492('0x24')](function(){return _0x2c5004;});}})[_0xf492('0x24')](respondWithStatusCode(_0x444868,null))[_0xf492('0x4a')](handleError(_0x444868,null));};exports[_0xf492('0xad')]=function(_0x16cb4c,_0x4d6c7c,_0xb8bc4a){var _0x40927a={};var _0x204668={};var _0x273138;var _0x2a5792;return db['VoiceQueue'][_0xf492('0x5d')]({'where':{'id':_0x16cb4c[_0xf492('0x4b')]['id']}})[_0xf492('0x24')](handleEntityNotFound(_0x4d6c7c,null))[_0xf492('0x24')](function(_0x396eb0){if(_0x396eb0){_0x273138=_0x396eb0;_0x204668[_0xf492('0x38')]=_[_0xf492('0x3a')](db[_0xf492('0x95')][_0xf492('0x36')]);_0x204668['query']=_[_0xf492('0x3a')](_0x16cb4c['query']);_0x204668[_0xf492('0x3b')]=_[_0xf492('0x3c')](_0x204668[_0xf492('0x38')],_0x204668['query']);_0x40927a[_0xf492('0x3d')]=_[_0xf492('0x3c')](_0x204668[_0xf492('0x38')],qs['fields'](_0x16cb4c[_0xf492('0x39')][_0xf492('0x4c')]));_0x40927a['attributes']=_0x40927a['attributes'][_0xf492('0x3e')]?_0x40927a[_0xf492('0x3d')]:_0x204668[_0xf492('0x38')];_0x40927a[_0xf492('0x40')]=qs['sort'](_0x16cb4c[_0xf492('0x39')][_0xf492('0x41')]);_0x40927a['where']=qs[_0xf492('0x3b')](_[_0xf492('0x43')](_0x16cb4c[_0xf492('0x39')],_0x204668[_0xf492('0x3b')]));if(_0x16cb4c['query'][_0xf492('0x46')]){_0x40927a[_0xf492('0x42')]=_[_0xf492('0x44')](_0x40927a['where'],{'$or':_['map'](_0x40927a['attributes'],function(_0x5e2759){var _0x4c58ae={};_0x4c58ae[_0x5e2759]={'$like':'%'+_0x16cb4c[_0xf492('0x39')]['filter']+'%'};return _0x4c58ae;})});}_0x40927a=_[_0xf492('0x44')]({},_0x40927a,_0x16cb4c['options']);return _0x273138['getBlackLists'](_0x40927a);}})['then'](function(_0x41573f){if(_0x41573f){_0x2a5792=_0x41573f[_0xf492('0x3e')];if(!_0x16cb4c[_0xf492('0x39')][_0xf492('0x3f')]('nolimit')){_0x40927a[_0xf492('0x1e')]=qs[_0xf492('0x1e')](_0x16cb4c[_0xf492('0x39')][_0xf492('0x1e')]);_0x40927a[_0xf492('0x1d')]=qs[_0xf492('0x1d')](_0x16cb4c[_0xf492('0x39')]['offset']);}return _0x273138[_0xf492('0xad')](_0x40927a);}})[_0xf492('0x24')](function(_0x5d83a1){if(_0x5d83a1){return _0x5d83a1?{'count':_0x2a5792,'rows':_0x5d83a1}:null;}})[_0xf492('0x24')](respondWithResult(_0x4d6c7c,null))[_0xf492('0x4a')](handleError(_0x4d6c7c,null));};exports['addBlackLists']=function(_0x369452,_0x499efc,_0x1be39c){var _0x3a99e9,_0xa04b18;return db[_0xf492('0x35')][_0xf492('0x2e')]({'where':{'id':_0x369452[_0xf492('0x4b')]['id']}})['then'](handleEntityNotFound(_0x499efc,null))[_0xf492('0x24')](function(_0x4b09f2){if(_0x4b09f2){_0xa04b18=_0x4b09f2;return _0x4b09f2[_0xf492('0xae')](_0x369452[_0xf492('0x5a')][_0xf492('0x86')],_['omit'](_0x369452['body'],['ids','id'])||{});}return null;})['spread'](function(_0x402bdc){var _0x2daeba;_0x3a99e9=_0x402bdc||[];var _0x5a7441=[];if(_0x402bdc){for(var _0x43dd7d=0x0;_0x43dd7d<_0x402bdc[_0xf492('0x3e')];_0x43dd7d+=0x1){var _0x294806=_0x402bdc[_0x43dd7d][_0xf492('0x50')]({'plain':!![]});_0x2daeba=squel['insert']()[_0xf492('0x9a')]('cm_hopper_black')[_0xf492('0x9c')]([_0xf492('0x9d'),_0xf492('0x9e'),_0xf492('0x9f'),_0xf492('0x60'),_0xf492('0x58'),'updatedAt'],squel[_0xf492('0x79')]()['field']('phone',_0xf492('0x9d'))[_0xf492('0x7a')]('id',_0xf492('0x9e'))['field'](_0x294806[_0xf492('0xa5')][_0xf492('0x80')](),_0xf492('0x9f'))[_0xf492('0x7a')](_0x369452[_0xf492('0x4b')]['id']['toString'](),_0xf492('0x60'))[_0xf492('0x7a')](_0xf492('0xa0'),_0xf492('0x58'))[_0xf492('0x7a')](_0xf492('0xa0'),'updatedAt')[_0xf492('0xa2')](_0xf492('0xa3'))[_0xf492('0x42')](_0xf492('0xa4'))[_0xf492('0x42')](_0xf492('0xaf'),_0x294806['CmListId'][_0xf492('0x80')]())[_0xf492('0x42')](_0xf492('0xa6')))[_0xf492('0x80')]();_0x5a7441[_0xf492('0x8f')](db[_0xf492('0x72')]['query'](_0x2daeba));}return BPromise['all'](_0x5a7441);}})[_0xf492('0x24')](function(){return _0x3a99e9;})[_0xf492('0x24')](respondWithResult(_0x499efc,null))[_0xf492('0x4a')](handleError(_0x499efc,null));};exports[_0xf492('0xb0')]=function(_0x3ac2ba,_0x58a381,_0x356a3c){return db[_0xf492('0x35')][_0xf492('0x2e')]({'where':{'id':_0x3ac2ba[_0xf492('0x4b')]['id']}})['then'](handleEntityNotFound(_0x58a381,null))[_0xf492('0x24')](function(_0x1608e4){if(_0x1608e4){return _0x1608e4[_0xf492('0xb0')](_0x3ac2ba[_0xf492('0x39')]['ids']);}})[_0xf492('0x24')](function(_0x4208a1){if(_0x4208a1){return db[_0xf492('0x67')][_0xf492('0x25')]({'where':{'ListId':_0x3ac2ba[_0xf492('0x39')]['ids'],'VoiceQueueId':_0x3ac2ba[_0xf492('0x4b')]['id']}})[_0xf492('0x24')](function(){return _0x4208a1;});}})['then'](respondWithStatusCode(_0x58a381,null))[_0xf492('0x4a')](handleError(_0x58a381,null));};
\ No newline at end of file
+var _0x5402=['params','catch','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','VoiceQueues','UserProfileSection','userProfileId','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','clone','includeAll','options','omit','createdAt','updatedAt','autoAssociation','update','getHoppers','findOne','CmHopper','nolimit','VoiceQueueId','rows','getHopperHistories','CmHopperHistory','pick','getHopperFinals','CmHopperFinal','getHopperBlacks','CmHopperBlack','getTeams','Team','addTeams','teams','User','Agents','online','interface','flatMap','forEach','penalty','sequelize','transaction','UserVoiceQueue','UserVoiceQueueRt','isNil','format','SIP/%s','voicePause','emit','userVoiceQueue:save','removeTeams','ids','select','field','tq.TeamId','from','team_has_voice_queues','ut.TeamId\x20=\x20tq.TeamId','VoiceQueueId\x20=\x20?','ut.UserId\x20=\x20?','push','toString','every','TeamId','includes','all','union','compact','isEmpty','removeAgents','userVoiceQueue:remove','addAgents','spread','upsert','getAgents','getMembers','getLists','CmList','dialCheckDuplicateType','always','insert','into','cm_hopper','fromQuery','phone','scheduledAt','ContactId','ListId','NOW()','CmListId','cm_contacts','deletedAt\x20IS\x20NULL','ListId\x20=\x20?','phone\x20IS\x20NOT\x20NULL','phone\x20NOT\x20IN\x20(?)','COALESCE(calleridnum,\x27\x27)','cm_hopper_final','COALESCE(phone,\x27\x27)','onlyIfOpen','getBlackLists','addBlackLists','cm_hopper_black','removeBlackLists','html-pdf','eml-format','rimraf','fast-json-patch','request-promise','util','path','sox','to-csv','ejs','lodash','squel','crypto','desk.js','querystring','papaparse','ioredis','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','../../config/environment','../../mysqldb','redis','defaults','localhost','socket.io-emitter','./voiceQueue.socket','register','sendStatus','status','end','json','offset','limit','Content-Range','reject','save','then','destroy','get','inbound','QueueCampaigns','outbound','filter','value','type','find','name','UserProfileResource','error','stack','send','index','rawAttributes','fieldName','key','model','query','keys','filters','intersection','fields','attributes','length','hasOwnProperty','order','sort','where','merge','map','VIRTUAL','count','include','VoiceQueue','findAll','show'];(function(_0x1de104,_0x5d7701){var _0x351a5f=function(_0x4baaff){while(--_0x4baaff){_0x1de104['push'](_0x1de104['shift']());}};_0x351a5f(++_0x5d7701);}(_0x5402,0x121));var _0x2540=function(_0x36b1e7,_0x151468){_0x36b1e7=_0x36b1e7-0x0;var _0x395eb3=_0x5402[_0x36b1e7];return _0x395eb3;};'use strict';var pdf=require(_0x2540('0x0'));var emlformat=require(_0x2540('0x1'));var rimraf=require(_0x2540('0x2'));var zipdir=require('zip-dir');var jsonpatch=require(_0x2540('0x3'));var rp=require(_0x2540('0x4'));var moment=require('moment');var BPromise=require('bluebird');var Mustache=require('mustache');var util=require(_0x2540('0x5'));var path=require(_0x2540('0x6'));var sox=require(_0x2540('0x7'));var csv=require(_0x2540('0x8'));var ejs=require(_0x2540('0x9'));var fs=require('fs');var _=require(_0x2540('0xa'));var squel=require(_0x2540('0xb'));var crypto=require(_0x2540('0xc'));var jsforce=require('jsforce');var deskjs=require(_0x2540('0xd'));var toCsv=require(_0x2540('0x8'));var querystring=require(_0x2540('0xe'));var Papa=require(_0x2540('0xf'));var Redis=require(_0x2540('0x10'));var authService=require('../../components/auth/service');var qs=require(_0x2540('0x11'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x2540('0x12'));var logger=require(_0x2540('0x13'))(_0x2540('0x14'));var utils=require('../../config/utils');var config=require(_0x2540('0x15'));var db=require(_0x2540('0x16'))['db'];config[_0x2540('0x17')]=_[_0x2540('0x18')](config[_0x2540('0x17')],{'host':_0x2540('0x19'),'port':0x18eb});var socket=require(_0x2540('0x1a'))(new Redis(config['redis']));require(_0x2540('0x1b'))[_0x2540('0x1c')](socket);function respondWithStatusCode(_0x4586fb,_0x925dfa){_0x925dfa=_0x925dfa||0xcc;return function(_0x87615f){if(_0x87615f){return _0x4586fb[_0x2540('0x1d')](_0x925dfa);}return _0x4586fb[_0x2540('0x1e')](_0x925dfa)[_0x2540('0x1f')]();};}function respondWithResult(_0x131b0f,_0x47f436){_0x47f436=_0x47f436||0xc8;return function(_0x5aa7df){if(_0x5aa7df){return _0x131b0f['status'](_0x47f436)[_0x2540('0x20')](_0x5aa7df);}};}function respondWithFilteredResult(_0x4f04ce,_0x4bb89b){return function(_0x3b2e4e){if(_0x3b2e4e){var _0x2882b9=_0x3b2e4e['count'],_0x52899a=_0x4bb89b[_0x2540('0x21')],_0x2c361a=_0x4bb89b['offset']+_0x4bb89b[_0x2540('0x22')],_0x426c0a;if(_0x2c361a>=_0x2882b9){_0x2c361a=_0x2882b9;_0x426c0a=0xc8;}else{_0x426c0a=0xce;}_0x4f04ce[_0x2540('0x1e')](_0x426c0a);return _0x4f04ce['set'](_0x2540('0x23'),_0x52899a+'-'+_0x2c361a+'/'+_0x2882b9)['json'](_0x3b2e4e);}return null;};}function patchUpdates(_0x3c2a18){return function(_0x143b81){try{jsonpatch['apply'](_0x143b81,_0x3c2a18,!![]);}catch(_0x292ab4){return BPromise[_0x2540('0x24')](_0x292ab4);}return _0x143b81[_0x2540('0x25')]();};}function saveUpdates(_0x1d253e,_0x522c44){return function(_0x1651c9){if(_0x1651c9){return _0x1651c9['update'](_0x1d253e)[_0x2540('0x26')](function(_0x308112){return _0x308112;});}return null;};}function removeEntity(_0x5653ba,_0x4e928a){return function(_0x1347ea){if(_0x1347ea){return _0x1347ea[_0x2540('0x27')]()[_0x2540('0x26')](function(){var _0x5d46ae=_0x1347ea[_0x2540('0x28')]({'plain':!![]});var _0x1de7ca=[{'name':'VoiceQueues','value':_0x2540('0x29'),'ignore':![]},{'name':_0x2540('0x2a'),'value':_0x2540('0x2b'),'ignore':![]}];var _0x4dd6ee=_(_0x1de7ca)[_0x2540('0x2c')]('ignore')['map'](_0x2540('0x2d'))['value']();if(_['includes'](_0x4dd6ee,_0x5d46ae[_0x2540('0x2e')])){return;}var _0x39e22c=_[_0x2540('0x2f')](_0x1de7ca,[_0x2540('0x2d'),_0x5d46ae[_0x2540('0x2e')]])[_0x2540('0x30')];return db[_0x2540('0x31')][_0x2540('0x27')]({'where':{'type':_0x39e22c,'resourceId':_0x5d46ae['id']}})[_0x2540('0x26')](function(){return _0x1347ea;});})[_0x2540('0x26')](function(){_0x5653ba[_0x2540('0x1e')](0xcc)[_0x2540('0x1f')]();});}};}function handleEntityNotFound(_0x36197d,_0x54aa9c){return function(_0x4b4abb){if(!_0x4b4abb){_0x36197d['sendStatus'](0x194);}return _0x4b4abb;};}function handleError(_0x593537,_0x46b680){_0x46b680=_0x46b680||0x1f4;return function(_0xaf3965){logger[_0x2540('0x32')](_0xaf3965[_0x2540('0x33')]);if(_0xaf3965[_0x2540('0x30')]){delete _0xaf3965['name'];}_0x593537['status'](_0x46b680)[_0x2540('0x34')](_0xaf3965);};}exports[_0x2540('0x35')]=function(_0x1ac323,_0x18e149){var _0x3276e2={},_0x308810={},_0x5a05c7={'count':0x0,'rows':[]};var _0x1cec2d=_['map'](db['VoiceQueue'][_0x2540('0x36')],function(_0x3f3d1b){return{'name':_0x3f3d1b[_0x2540('0x37')],'type':_0x3f3d1b[_0x2540('0x2e')][_0x2540('0x38')]};});_0x308810[_0x2540('0x39')]=_['map'](_0x1cec2d,'name');_0x308810[_0x2540('0x3a')]=_[_0x2540('0x3b')](_0x1ac323['query']);_0x308810[_0x2540('0x3c')]=_[_0x2540('0x3d')](_0x308810[_0x2540('0x39')],_0x308810[_0x2540('0x3a')]);_0x3276e2['attributes']=_['intersection'](_0x308810[_0x2540('0x39')],qs['fields'](_0x1ac323[_0x2540('0x3a')][_0x2540('0x3e')]));_0x3276e2[_0x2540('0x3f')]=_0x3276e2[_0x2540('0x3f')][_0x2540('0x40')]?_0x3276e2['attributes']:_0x308810['model'];if(!_0x1ac323[_0x2540('0x3a')][_0x2540('0x41')]('nolimit')){_0x3276e2[_0x2540('0x22')]=qs[_0x2540('0x22')](_0x1ac323[_0x2540('0x3a')][_0x2540('0x22')]);_0x3276e2[_0x2540('0x21')]=qs['offset'](_0x1ac323[_0x2540('0x3a')][_0x2540('0x21')]);}_0x3276e2[_0x2540('0x42')]=qs[_0x2540('0x43')](_0x1ac323[_0x2540('0x3a')][_0x2540('0x43')]);_0x3276e2[_0x2540('0x44')]=qs['filters'](_['pick'](_0x1ac323[_0x2540('0x3a')],_0x308810[_0x2540('0x3c')]),_0x1cec2d);if(_0x1ac323['query'][_0x2540('0x2c')]){_0x3276e2['where']=_[_0x2540('0x45')](_0x3276e2[_0x2540('0x44')],{'$or':_[_0x2540('0x46')](_0x1cec2d,function(_0xc23ef2){if(_0xc23ef2[_0x2540('0x2e')]!==_0x2540('0x47')){var _0x2bc6b1={};_0x2bc6b1[_0xc23ef2['name']]={'$like':'%'+_0x1ac323[_0x2540('0x3a')]['filter']+'%'};return _0x2bc6b1;}})});}_0x3276e2=_[_0x2540('0x45')]({},_0x3276e2,_0x1ac323['options']);var _0x47cc5b={'where':_0x3276e2[_0x2540('0x44')]};return db['VoiceQueue'][_0x2540('0x48')](_0x47cc5b)['then'](function(_0x130ce4){_0x5a05c7['count']=_0x130ce4;if(_0x1ac323[_0x2540('0x3a')]['includeAll']){_0x3276e2[_0x2540('0x49')]=[{'all':!![]}];}return db[_0x2540('0x4a')][_0x2540('0x4b')](_0x3276e2);})[_0x2540('0x26')](function(_0x2ee2fb){_0x5a05c7['rows']=_0x2ee2fb;return _0x5a05c7;})[_0x2540('0x26')](respondWithFilteredResult(_0x18e149,_0x3276e2))['catch'](handleError(_0x18e149,null));};exports[_0x2540('0x4c')]=function(_0x190b3d,_0x12036c){var _0x20737b={'raw':![],'where':{'id':_0x190b3d[_0x2540('0x4d')]['id']}},_0x2e0d1f={};_0x2e0d1f[_0x2540('0x39')]=_[_0x2540('0x3b')](db[_0x2540('0x4a')][_0x2540('0x36')]);_0x2e0d1f['query']=_['keys'](_0x190b3d[_0x2540('0x3a')]);_0x2e0d1f['filters']=_[_0x2540('0x3d')](_0x2e0d1f['model'],_0x2e0d1f[_0x2540('0x3a')]);_0x20737b[_0x2540('0x3f')]=_[_0x2540('0x3d')](_0x2e0d1f[_0x2540('0x39')],qs['fields'](_0x190b3d[_0x2540('0x3a')]['fields']));_0x20737b['attributes']=_0x20737b[_0x2540('0x3f')][_0x2540('0x40')]?_0x20737b['attributes']:_0x2e0d1f[_0x2540('0x39')];if(_0x190b3d[_0x2540('0x3a')]['includeAll']){_0x20737b[_0x2540('0x49')]=[{'all':!![]}];}_0x20737b=_[_0x2540('0x45')]({},_0x20737b,_0x190b3d['options']);return db[_0x2540('0x4a')][_0x2540('0x2f')](_0x20737b)[_0x2540('0x26')](handleEntityNotFound(_0x12036c,null))[_0x2540('0x26')](respondWithResult(_0x12036c,null))[_0x2540('0x4e')](handleError(_0x12036c,null));};exports[_0x2540('0x4f')]=function(_0x3259c6,_0x37ca19){return db[_0x2540('0x4a')][_0x2540('0x4f')](_0x3259c6[_0x2540('0x50')],{})['then'](function(_0x92456d){var _0x6ca2ea=_0x3259c6[_0x2540('0x51')][_0x2540('0x28')]({'plain':!![]});if(!_0x6ca2ea)throw new Error(_0x2540('0x52'));if(_0x6ca2ea[_0x2540('0x53')]===_0x2540('0x51')){var _0x292dec=_0x92456d[_0x2540('0x28')]({'plain':!![]});var _0xfd7957=[{'name':_0x2540('0x54'),'value':_0x2540('0x29')},{'name':_0x2540('0x2a'),'value':'outbound'}];var _0x26ab69=_[_0x2540('0x2f')](_0xfd7957,['value',_0x292dec['type']])['name'];return db[_0x2540('0x55')][_0x2540('0x2f')]({'where':{'name':_0x26ab69,'userProfileId':_0x6ca2ea[_0x2540('0x56')]},'raw':!![]})[_0x2540('0x26')](function(_0x5ab177){if(_0x5ab177&&_0x5ab177['autoAssociation']===0x0){return db[_0x2540('0x31')][_0x2540('0x4f')]({'name':_0x292dec['name'],'resourceId':_0x292dec['id'],'type':_0x5ab177['name'],'sectionId':_0x5ab177['id']},{})['then'](function(){return _0x92456d;});}else{return _0x92456d;}})['catch'](function(_0x567763){logger[_0x2540('0x32')](_0x2540('0x57'),_0x567763);throw _0x567763;});}return _0x92456d;})[_0x2540('0x26')](respondWithResult(_0x37ca19,0xc9))[_0x2540('0x4e')](handleError(_0x37ca19,null));};exports[_0x2540('0x58')]=function(_0x5bb842,_0x42b0f0){var _0x5287a6={'where':{'id':_0x5bb842[_0x2540('0x4d')]['id']}},_0x80083d={};_0x80083d[_0x2540('0x39')]=_[_0x2540('0x3b')](db['VoiceQueue'][_0x2540('0x36')]);_0x5287a6[_0x2540('0x3f')]=_[_0x2540('0x3d')](_0x80083d[_0x2540('0x39')],qs['fields'](_0x5bb842['query'][_0x2540('0x3e')]));_0x5287a6[_0x2540('0x3f')]=_0x5287a6[_0x2540('0x3f')][_0x2540('0x40')]?_0x5287a6[_0x2540('0x3f')]:_0x80083d[_0x2540('0x39')];if(_0x5bb842[_0x2540('0x3a')][_0x2540('0x59')]){_0x5287a6[_0x2540('0x49')]=[{'all':!![]}];}_0x5287a6=_[_0x2540('0x45')]({},_0x5287a6,_0x5bb842[_0x2540('0x5a')]);return db[_0x2540('0x4a')]['find'](_0x5287a6)[_0x2540('0x26')](handleEntityNotFound(_0x42b0f0,null))['then'](function(_0x1205e6){if(_0x1205e6){var _0x383ca6=_0x1205e6[_0x2540('0x28')]({'plain':!![]});_0x383ca6=qs[_0x2540('0x5b')](_0x383ca6,['id',_0x2540('0x5c'),_0x2540('0x5d')]);_0x5bb842[_0x2540('0x50')]=_[_0x2540('0x5b')](_0x5bb842[_0x2540('0x50')],['id','createdAt',_0x2540('0x5d')]);return db[_0x2540('0x4a')]['create'](_[_0x2540('0x45')](_0x383ca6,_0x5bb842[_0x2540('0x50')]),{'include':_0x5bb842[_0x2540('0x3a')][_0x2540('0x59')]?[{'all':!![]}]:undefined})[_0x2540('0x26')](function(_0x4cdf58){var _0x32cfc5=_0x5bb842[_0x2540('0x51')][_0x2540('0x28')]({'plain':!![]});if(!_0x32cfc5)throw new Error(_0x2540('0x52'));if(_0x32cfc5[_0x2540('0x53')]===_0x2540('0x51')){var _0x5ac77e=_0x4cdf58['get']({'plain':!![]});var _0x529985=[{'name':_0x2540('0x54'),'value':'inbound'},{'name':'QueueCampaigns','value':_0x2540('0x2b')}];var _0xaf213=_['find'](_0x529985,[_0x2540('0x2d'),_0x5ac77e[_0x2540('0x2e')]])[_0x2540('0x30')];return db[_0x2540('0x55')][_0x2540('0x2f')]({'where':{'name':_0xaf213,'userProfileId':_0x32cfc5[_0x2540('0x56')]},'raw':!![]})[_0x2540('0x26')](function(_0x257b68){if(_0x257b68&&_0x257b68[_0x2540('0x5e')]===0x0){return db[_0x2540('0x31')]['create']({'name':_0x5ac77e[_0x2540('0x30')],'resourceId':_0x5ac77e['id'],'type':_0x257b68[_0x2540('0x30')],'sectionId':_0x257b68['id']},{})[_0x2540('0x26')](function(){return _0x4cdf58;});}else{return _0x4cdf58;}})[_0x2540('0x4e')](function(_0x1c45a7){logger[_0x2540('0x32')](_0x2540('0x57'),_0x1c45a7);throw _0x1c45a7;});}return _0x4cdf58;});}})[_0x2540('0x26')](respondWithResult(_0x42b0f0,0xc9))[_0x2540('0x4e')](handleError(_0x42b0f0,null));};exports[_0x2540('0x5f')]=function(_0x653bfd,_0xbd81cf){if(_0x653bfd['body']['id']){delete _0x653bfd[_0x2540('0x50')]['id'];}return db[_0x2540('0x4a')][_0x2540('0x2f')]({'where':{'id':_0x653bfd[_0x2540('0x4d')]['id']}})[_0x2540('0x26')](handleEntityNotFound(_0xbd81cf,null))[_0x2540('0x26')](saveUpdates(_0x653bfd['body'],null))[_0x2540('0x26')](respondWithResult(_0xbd81cf,null))[_0x2540('0x4e')](handleError(_0xbd81cf,null));};exports[_0x2540('0x27')]=function(_0x10f588,_0x2fcee9){return db[_0x2540('0x4a')][_0x2540('0x2f')]({'where':{'id':_0x10f588[_0x2540('0x4d')]['id']}})[_0x2540('0x26')](handleEntityNotFound(_0x2fcee9,null))['then'](removeEntity(_0x2fcee9,null))[_0x2540('0x4e')](handleError(_0x2fcee9,null));};exports[_0x2540('0x60')]=function(_0x26aa3b,_0x388c78,_0x1c3601){var _0x4dcef0={'raw':![],'where':{}};var _0x1eb59f={};var _0x353337={'count':0x0,'rows':[]};return db[_0x2540('0x4a')][_0x2540('0x61')]({'where':{'id':_0x26aa3b[_0x2540('0x4d')]['id']}})['then'](handleEntityNotFound(_0x388c78,null))[_0x2540('0x26')](function(_0x12d95c){if(_0x12d95c){_0x1eb59f[_0x2540('0x39')]=_['keys'](db[_0x2540('0x62')][_0x2540('0x36')]);_0x1eb59f['query']=_['keys'](_0x26aa3b[_0x2540('0x3a')]);_0x1eb59f[_0x2540('0x3c')]=_[_0x2540('0x3d')](_0x1eb59f[_0x2540('0x39')],_0x1eb59f[_0x2540('0x3a')]);_0x4dcef0['attributes']=_[_0x2540('0x3d')](_0x1eb59f[_0x2540('0x39')],qs[_0x2540('0x3e')](_0x26aa3b[_0x2540('0x3a')]['fields']));_0x4dcef0['attributes']=_0x4dcef0[_0x2540('0x3f')]['length']?_0x4dcef0['attributes']:_0x1eb59f[_0x2540('0x39')];if(!_0x26aa3b[_0x2540('0x3a')][_0x2540('0x41')](_0x2540('0x63'))){_0x4dcef0[_0x2540('0x22')]=qs[_0x2540('0x22')](_0x26aa3b[_0x2540('0x3a')][_0x2540('0x22')]);_0x4dcef0[_0x2540('0x21')]=qs['offset'](_0x26aa3b[_0x2540('0x3a')][_0x2540('0x21')]);}_0x4dcef0['order']=qs[_0x2540('0x43')](_0x26aa3b[_0x2540('0x3a')]['sort']);_0x4dcef0[_0x2540('0x44')]=qs['filters'](_['pick'](_0x26aa3b[_0x2540('0x3a')],_0x1eb59f['filters']));_0x4dcef0['where'][_0x2540('0x64')]=_0x12d95c['id'];if(_0x26aa3b[_0x2540('0x3a')][_0x2540('0x2c')]){_0x4dcef0[_0x2540('0x44')]=_[_0x2540('0x45')](_0x4dcef0[_0x2540('0x44')],{'$or':_['map'](_0x4dcef0[_0x2540('0x3f')],function(_0x3d89be){var _0x2677ab={};_0x2677ab[_0x3d89be]={'$like':'%'+_0x26aa3b['query'][_0x2540('0x2c')]+'%'};return _0x2677ab;})});}_0x4dcef0=_[_0x2540('0x45')]({},_0x4dcef0,_0x26aa3b[_0x2540('0x5a')]);return db['CmHopper'][_0x2540('0x48')]({'where':_0x4dcef0[_0x2540('0x44')]})[_0x2540('0x26')](function(_0x3e4372){_0x353337[_0x2540('0x48')]=_0x3e4372;if(_0x26aa3b[_0x2540('0x3a')][_0x2540('0x59')]){_0x4dcef0[_0x2540('0x49')]=[{'all':!![]}];}return db[_0x2540('0x62')][_0x2540('0x4b')](_0x4dcef0);})[_0x2540('0x26')](function(_0x449318){_0x353337[_0x2540('0x65')]=_0x449318;return _0x353337;});}})[_0x2540('0x26')](respondWithFilteredResult(_0x388c78,_0x4dcef0))[_0x2540('0x4e')](handleError(_0x388c78,null));};exports[_0x2540('0x66')]=function(_0x389ee1,_0x2daa49,_0x302f7b){var _0xa81981={'raw':!![],'where':{}};var _0x5203e2={};var _0x424289={'count':0x0,'rows':[]};return db[_0x2540('0x4a')][_0x2540('0x61')]({'where':{'id':_0x389ee1['params']['id']}})[_0x2540('0x26')](handleEntityNotFound(_0x2daa49,null))[_0x2540('0x26')](function(_0x2bdc89){if(_0x2bdc89){_0x5203e2[_0x2540('0x39')]=_['keys'](db[_0x2540('0x67')][_0x2540('0x36')]);_0x5203e2[_0x2540('0x3a')]=_[_0x2540('0x3b')](_0x389ee1['query']);_0x5203e2['filters']=_[_0x2540('0x3d')](_0x5203e2[_0x2540('0x39')],_0x5203e2[_0x2540('0x3a')]);_0xa81981[_0x2540('0x3f')]=_[_0x2540('0x3d')](_0x5203e2[_0x2540('0x39')],qs[_0x2540('0x3e')](_0x389ee1[_0x2540('0x3a')][_0x2540('0x3e')]));_0xa81981[_0x2540('0x3f')]=_0xa81981['attributes'][_0x2540('0x40')]?_0xa81981[_0x2540('0x3f')]:_0x5203e2[_0x2540('0x39')];if(!_0x389ee1[_0x2540('0x3a')]['hasOwnProperty'](_0x2540('0x63'))){_0xa81981['limit']=qs[_0x2540('0x22')](_0x389ee1['query'][_0x2540('0x22')]);_0xa81981[_0x2540('0x21')]=qs[_0x2540('0x21')](_0x389ee1['query'][_0x2540('0x21')]);}_0xa81981[_0x2540('0x42')]=qs[_0x2540('0x43')](_0x389ee1['query'][_0x2540('0x43')]);_0xa81981[_0x2540('0x44')]=qs['filters'](_[_0x2540('0x68')](_0x389ee1[_0x2540('0x3a')],_0x5203e2[_0x2540('0x3c')]));_0xa81981[_0x2540('0x44')]['VoiceQueueId']=_0x2bdc89['id'];if(_0x389ee1['query']['filter']){_0xa81981['where']=_[_0x2540('0x45')](_0xa81981[_0x2540('0x44')],{'$or':_[_0x2540('0x46')](_0xa81981[_0x2540('0x3f')],function(_0x5555e8){var _0x27c4a4={};_0x27c4a4[_0x5555e8]={'$like':'%'+_0x389ee1[_0x2540('0x3a')][_0x2540('0x2c')]+'%'};return _0x27c4a4;})});}_0xa81981=_[_0x2540('0x45')]({},_0xa81981,_0x389ee1['options']);return db[_0x2540('0x67')]['count']({'where':_0xa81981['where']})[_0x2540('0x26')](function(_0x370212){_0x424289[_0x2540('0x48')]=_0x370212;if(_0x389ee1['query'][_0x2540('0x59')]){_0xa81981[_0x2540('0x49')]=[{'all':!![]}];}return db[_0x2540('0x67')][_0x2540('0x4b')](_0xa81981);})[_0x2540('0x26')](function(_0x216395){_0x424289['rows']=_0x216395;return _0x424289;});}})[_0x2540('0x26')](respondWithFilteredResult(_0x2daa49,_0xa81981))[_0x2540('0x4e')](handleError(_0x2daa49,null));};exports[_0x2540('0x69')]=function(_0x5e74c0,_0x110394,_0x1f0f04){var _0x3719ca={'raw':!![],'where':{}};var _0x41f6e6={};var _0x1bb688={'count':0x0,'rows':[]};return db[_0x2540('0x4a')][_0x2540('0x61')]({'where':{'id':_0x5e74c0[_0x2540('0x4d')]['id']}})[_0x2540('0x26')](handleEntityNotFound(_0x110394,null))[_0x2540('0x26')](function(_0x433640){if(_0x433640){_0x41f6e6[_0x2540('0x39')]=_['keys'](db[_0x2540('0x6a')][_0x2540('0x36')]);_0x41f6e6[_0x2540('0x3a')]=_[_0x2540('0x3b')](_0x5e74c0[_0x2540('0x3a')]);_0x41f6e6[_0x2540('0x3c')]=_[_0x2540('0x3d')](_0x41f6e6['model'],_0x41f6e6['query']);_0x3719ca[_0x2540('0x3f')]=_['intersection'](_0x41f6e6[_0x2540('0x39')],qs[_0x2540('0x3e')](_0x5e74c0[_0x2540('0x3a')][_0x2540('0x3e')]));_0x3719ca['attributes']=_0x3719ca['attributes'][_0x2540('0x40')]?_0x3719ca[_0x2540('0x3f')]:_0x41f6e6[_0x2540('0x39')];if(!_0x5e74c0['query'][_0x2540('0x41')](_0x2540('0x63'))){_0x3719ca[_0x2540('0x22')]=qs[_0x2540('0x22')](_0x5e74c0['query']['limit']);_0x3719ca[_0x2540('0x21')]=qs[_0x2540('0x21')](_0x5e74c0[_0x2540('0x3a')][_0x2540('0x21')]);}_0x3719ca['order']=qs[_0x2540('0x43')](_0x5e74c0[_0x2540('0x3a')][_0x2540('0x43')]);_0x3719ca[_0x2540('0x44')]=qs[_0x2540('0x3c')](_['pick'](_0x5e74c0[_0x2540('0x3a')],_0x41f6e6[_0x2540('0x3c')]));_0x3719ca[_0x2540('0x44')]['VoiceQueueId']=_0x433640['id'];if(_0x5e74c0[_0x2540('0x3a')][_0x2540('0x2c')]){_0x3719ca[_0x2540('0x44')]=_[_0x2540('0x45')](_0x3719ca['where'],{'$or':_[_0x2540('0x46')](_0x3719ca[_0x2540('0x3f')],function(_0x1dc870){var _0x810954={};_0x810954[_0x1dc870]={'$like':'%'+_0x5e74c0[_0x2540('0x3a')][_0x2540('0x2c')]+'%'};return _0x810954;})});}_0x3719ca=_[_0x2540('0x45')]({},_0x3719ca,_0x5e74c0[_0x2540('0x5a')]);return db[_0x2540('0x6a')][_0x2540('0x48')]({'where':_0x3719ca['where']})[_0x2540('0x26')](function(_0x42dfe0){_0x1bb688[_0x2540('0x48')]=_0x42dfe0;if(_0x5e74c0[_0x2540('0x3a')][_0x2540('0x59')]){_0x3719ca[_0x2540('0x49')]=[{'all':!![]}];}return db[_0x2540('0x6a')][_0x2540('0x4b')](_0x3719ca);})[_0x2540('0x26')](function(_0x5bb553){_0x1bb688[_0x2540('0x65')]=_0x5bb553;return _0x1bb688;});}})[_0x2540('0x26')](respondWithFilteredResult(_0x110394,_0x3719ca))[_0x2540('0x4e')](handleError(_0x110394,null));};exports[_0x2540('0x6b')]=function(_0x40b525,_0x12124b,_0x48d2d7){var _0x1a91f0={'raw':!![],'where':{}};var _0x33743e={};var _0x46d222={'count':0x0,'rows':[]};return db[_0x2540('0x4a')][_0x2540('0x61')]({'where':{'id':_0x40b525[_0x2540('0x4d')]['id']}})['then'](handleEntityNotFound(_0x12124b,null))[_0x2540('0x26')](function(_0x52a988){if(_0x52a988){_0x33743e['model']=_[_0x2540('0x3b')](db[_0x2540('0x6c')][_0x2540('0x36')]);_0x33743e[_0x2540('0x3a')]=_['keys'](_0x40b525[_0x2540('0x3a')]);_0x33743e[_0x2540('0x3c')]=_['intersection'](_0x33743e[_0x2540('0x39')],_0x33743e['query']);_0x1a91f0[_0x2540('0x3f')]=_[_0x2540('0x3d')](_0x33743e['model'],qs[_0x2540('0x3e')](_0x40b525[_0x2540('0x3a')][_0x2540('0x3e')]));_0x1a91f0['attributes']=_0x1a91f0[_0x2540('0x3f')][_0x2540('0x40')]?_0x1a91f0[_0x2540('0x3f')]:_0x33743e[_0x2540('0x39')];if(!_0x40b525['query'][_0x2540('0x41')](_0x2540('0x63'))){_0x1a91f0[_0x2540('0x22')]=qs[_0x2540('0x22')](_0x40b525[_0x2540('0x3a')][_0x2540('0x22')]);_0x1a91f0['offset']=qs[_0x2540('0x21')](_0x40b525[_0x2540('0x3a')]['offset']);}_0x1a91f0[_0x2540('0x42')]=qs[_0x2540('0x43')](_0x40b525[_0x2540('0x3a')]['sort']);_0x1a91f0[_0x2540('0x44')]=qs[_0x2540('0x3c')](_[_0x2540('0x68')](_0x40b525[_0x2540('0x3a')],_0x33743e[_0x2540('0x3c')]));_0x1a91f0['where'][_0x2540('0x64')]=_0x52a988['id'];if(_0x40b525[_0x2540('0x3a')][_0x2540('0x2c')]){_0x1a91f0['where']=_['merge'](_0x1a91f0['where'],{'$or':_[_0x2540('0x46')](_0x1a91f0[_0x2540('0x3f')],function(_0x13d9ba){var _0x383b5d={};_0x383b5d[_0x13d9ba]={'$like':'%'+_0x40b525['query'][_0x2540('0x2c')]+'%'};return _0x383b5d;})});}_0x1a91f0=_[_0x2540('0x45')]({},_0x1a91f0,_0x40b525['options']);return db[_0x2540('0x6c')]['count']({'where':_0x1a91f0[_0x2540('0x44')]})['then'](function(_0x3f7d58){_0x46d222[_0x2540('0x48')]=_0x3f7d58;if(_0x40b525[_0x2540('0x3a')][_0x2540('0x59')]){_0x1a91f0[_0x2540('0x49')]=[{'all':!![]}];}return db[_0x2540('0x6c')][_0x2540('0x4b')](_0x1a91f0);})[_0x2540('0x26')](function(_0x42ca4c){_0x46d222[_0x2540('0x65')]=_0x42ca4c;return _0x46d222;});}})[_0x2540('0x26')](respondWithFilteredResult(_0x12124b,_0x1a91f0))[_0x2540('0x4e')](handleError(_0x12124b,null));};exports[_0x2540('0x6d')]=function(_0x3dc87a,_0x349f87,_0x1405a4){var _0x55f5b2={};var _0x1305d9={};var _0x5b2c1c;var _0x4af313;return db['VoiceQueue'][_0x2540('0x61')]({'where':{'id':_0x3dc87a[_0x2540('0x4d')]['id']}})[_0x2540('0x26')](handleEntityNotFound(_0x349f87,null))[_0x2540('0x26')](function(_0x539118){if(_0x539118){_0x5b2c1c=_0x539118;_0x1305d9[_0x2540('0x39')]=_[_0x2540('0x3b')](db[_0x2540('0x6e')][_0x2540('0x36')]);_0x1305d9[_0x2540('0x3a')]=_[_0x2540('0x3b')](_0x3dc87a[_0x2540('0x3a')]);_0x1305d9[_0x2540('0x3c')]=_[_0x2540('0x3d')](_0x1305d9[_0x2540('0x39')],_0x1305d9[_0x2540('0x3a')]);_0x55f5b2[_0x2540('0x3f')]=_['intersection'](_0x1305d9[_0x2540('0x39')],qs['fields'](_0x3dc87a[_0x2540('0x3a')][_0x2540('0x3e')]));_0x55f5b2[_0x2540('0x3f')]=_0x55f5b2[_0x2540('0x3f')][_0x2540('0x40')]?_0x55f5b2['attributes']:_0x1305d9[_0x2540('0x39')];_0x55f5b2['order']=qs[_0x2540('0x43')](_0x3dc87a['query'][_0x2540('0x43')]);_0x55f5b2[_0x2540('0x44')]=qs[_0x2540('0x3c')](_['pick'](_0x3dc87a['query'],_0x1305d9[_0x2540('0x3c')]));if(_0x3dc87a[_0x2540('0x3a')]['filter']){_0x55f5b2[_0x2540('0x44')]=_[_0x2540('0x45')](_0x55f5b2['where'],{'$or':_[_0x2540('0x46')](_0x55f5b2['attributes'],function(_0x278449){var _0x2a53c6={};_0x2a53c6[_0x278449]={'$like':'%'+_0x3dc87a[_0x2540('0x3a')]['filter']+'%'};return _0x2a53c6;})});}_0x55f5b2=_[_0x2540('0x45')]({},_0x55f5b2,_0x3dc87a[_0x2540('0x5a')]);return _0x5b2c1c[_0x2540('0x6d')](_0x55f5b2);}})[_0x2540('0x26')](function(_0x174eef){if(_0x174eef){_0x4af313=_0x174eef['length'];if(!_0x3dc87a['query'][_0x2540('0x41')](_0x2540('0x63'))){_0x55f5b2[_0x2540('0x22')]=qs[_0x2540('0x22')](_0x3dc87a[_0x2540('0x3a')][_0x2540('0x22')]);_0x55f5b2[_0x2540('0x21')]=qs[_0x2540('0x21')](_0x3dc87a[_0x2540('0x3a')][_0x2540('0x21')]);}return _0x5b2c1c[_0x2540('0x6d')](_0x55f5b2);}})[_0x2540('0x26')](function(_0x4732f7){if(_0x4732f7){return _0x4732f7?{'count':_0x4af313,'rows':_0x4732f7}:null;}})[_0x2540('0x26')](respondWithResult(_0x349f87,null))[_0x2540('0x4e')](handleError(_0x349f87,null));};exports[_0x2540('0x6f')]=function(_0x2332ce,_0xb05fa9,_0x4fcd52){var _0x34de7f=_0x2332ce[_0x2540('0x50')][_0x2540('0x70')];var _0x4cc02c=_[_0x2540('0x46')](_0x34de7f,'id');return db[_0x2540('0x6e')][_0x2540('0x4b')]({'where':{'id':_0x4cc02c},'attributes':['id'],'include':[{'model':db[_0x2540('0x71')],'as':_0x2540('0x72'),'attributes':['id',_0x2540('0x30'),_0x2540('0x73'),'voicePause',_0x2540('0x74')],'raw':!![]}]})[_0x2540('0x26')](function(_0x4c073f){if(_0x4c073f){var _0x305e49=_[_0x2540('0x75')](_0x4c073f,function(_0x4851fb){var _0x22eff8=_0x4851fb[_0x2540('0x28')]({'plain':!![]});_0x22eff8[_0x2540('0x72')][_0x2540('0x76')](function(_0x6af71e){_0x6af71e[_0x2540('0x77')]=_['find'](_0x34de7f,{'id':_0x22eff8['id']})[_0x2540('0x77')];});return _0x22eff8['Agents'];});return db[_0x2540('0x4a')][_0x2540('0x2f')]({'where':{'id':_0x2332ce['params']['id']}})[_0x2540('0x26')](function(_0x1d820f){return db[_0x2540('0x78')][_0x2540('0x79')](function(_0x3d3c40){return _0x1d820f[_0x2540('0x6f')](_0x4cc02c,{'transaction':_0x3d3c40})[_0x2540('0x26')](function(){return BPromise['each'](_0x305e49,function(_0x4dee2b){return db[_0x2540('0x7a')]['findOrCreate']({'where':{'UserId':_0x4dee2b['id'],'VoiceQueueId':_0x2332ce[_0x2540('0x4d')]['id']},'defaults':{'penalty':_0x4dee2b[_0x2540('0x77')]},'transaction':_0x3d3c40});});})['then'](function(){return BPromise['each'](_[_0x2540('0x2c')](_0x305e49,{'online':!![]}),function(_0x5b6ff0){return db[_0x2540('0x7b')]['upsert']({'membername':_0x5b6ff0[_0x2540('0x30')],'UserId':_0x5b6ff0['id'],'queue_name':_0x1d820f['name'],'VoiceQueueId':_0x1d820f['id'],'interface':_[_0x2540('0x7c')](_0x5b6ff0['interface'])?util[_0x2540('0x7d')](_0x2540('0x7e'),_0x5b6ff0['name']):_0x5b6ff0['interface'],'paused':_0x5b6ff0[_0x2540('0x7f')]||![],'penalty':_0x5b6ff0[_0x2540('0x77')]},{'transaction':_0x3d3c40});});})[_0x2540('0x26')](function(){_0x305e49[_0x2540('0x76')](function(_0x197e27){socket[_0x2540('0x80')](_0x2540('0x81'),{'UserId':_0x197e27['id'],'VoiceQueueId':_0x1d820f['id']});});});});});}})[_0x2540('0x26')](respondWithStatusCode(_0xb05fa9,null))[_0x2540('0x4e')](handleError(_0xb05fa9,null));};exports[_0x2540('0x82')]=function(_0xa59d82,_0x4005ab,_0x1b6f0c){return db['Team'][_0x2540('0x4b')]({'where':{'id':_0xa59d82[_0x2540('0x3a')][_0x2540('0x83')]},'attributes':['id'],'include':[{'model':db['User'],'as':_0x2540('0x72'),'attributes':['id'],'raw':!![]}]})[_0x2540('0x26')](handleEntityNotFound(_0x4005ab,null))['then'](function(_0x3c6724){var _0x4dc3f4=_[_0x2540('0x46')](_0x3c6724,'id');var _0x4f96e3=[];var _0x1a4bb8=[];var _0x415c3a=squel[_0x2540('0x84')]();_0x415c3a[_0x2540('0x85')](_0x2540('0x86'))[_0x2540('0x87')](_0x2540('0x88'),'tq')['join']('user_has_teams','ut',_0x2540('0x89'))[_0x2540('0x44')](_0x2540('0x8a'),_0xa59d82[_0x2540('0x4d')]['id']);for(var _0x40f3a8=0x0;_0x40f3a8<_0x3c6724[_0x2540('0x40')];_0x40f3a8+=0x1){let _0x5b45b0=_0x3c6724[_0x40f3a8];for(var _0x46d3f=0x0;_0x46d3f<_0x5b45b0[_0x2540('0x72')][_0x2540('0x40')];_0x46d3f+=0x1){let _0x1ee3d5=_0x5b45b0[_0x2540('0x72')][_0x46d3f];var _0x5383b0=_0x415c3a[_0x2540('0x58')]();_0x5383b0[_0x2540('0x44')](_0x2540('0x8b'),_0x1ee3d5['id']);_0x1a4bb8[_0x2540('0x8c')](db[_0x2540('0x78')][_0x2540('0x3a')](_0x5383b0[_0x2540('0x8d')](),{'type':db[_0x2540('0x78')]['QueryTypes']['SELECT']})[_0x2540('0x26')](function(_0x3995ec){if(_0x3995ec[_0x2540('0x40')]===0x1){return _0x1ee3d5['id'];}else{var _0x27fd12=_[_0x2540('0x8e')](_['map'](_0x3995ec,_0x2540('0x8f')),function(_0xaec1b){return _[_0x2540('0x90')](_0x4dc3f4,_0xaec1b);});if(_0x27fd12){return _0x1ee3d5['id'];}}}));}}return BPromise[_0x2540('0x91')](_0x1a4bb8)['then'](function(_0x513bc7){_0x4f96e3=_(_0x4f96e3)[_0x2540('0x92')](_0x513bc7)[_0x2540('0x93')]()[_0x2540('0x2d')]();return db[_0x2540('0x4a')][_0x2540('0x2f')]({'where':{'id':_0xa59d82['params']['id']}})[_0x2540('0x26')](function(_0x15ac95){return db[_0x2540('0x78')]['transaction'](function(_0x43534c){return _0x15ac95[_0x2540('0x82')](_0xa59d82[_0x2540('0x3a')][_0x2540('0x83')],{'transaction':_0x43534c})[_0x2540('0x26')](function(){if(!_[_0x2540('0x94')](_0x4f96e3)){return _0x15ac95[_0x2540('0x95')](_0x4f96e3,{'transaction':_0x43534c})[_0x2540('0x26')](function(){return db[_0x2540('0x7b')]['destroy']({'where':{'VoiceQueueId':_0xa59d82['params']['id'],'UserId':_0x4f96e3},'transaction':_0x43534c});});}})[_0x2540('0x26')](function(){_0x4f96e3[_0x2540('0x76')](function(_0x6e9e87){socket[_0x2540('0x80')](_0x2540('0x96'),{'UserId':_0x6e9e87,'VoiceQueueId':_0x15ac95['id']});});});});});});})[_0x2540('0x26')](respondWithStatusCode(_0x4005ab,null))[_0x2540('0x4e')](handleError(_0x4005ab,null));};exports[_0x2540('0x97')]=function(_0x193776,_0x40725e,_0x2e770b){var _0x2f7c74,_0x4f3de8;return db[_0x2540('0x4a')][_0x2540('0x2f')]({'where':{'id':_0x193776[_0x2540('0x4d')]['id']}})['then'](handleEntityNotFound(_0x40725e,null))[_0x2540('0x26')](function(_0x3df89b){if(_0x3df89b){_0x4f3de8=_0x3df89b;return _0x3df89b['addAgents'](_0x193776[_0x2540('0x50')][_0x2540('0x83')],_[_0x2540('0x5b')](_0x193776['body'],[_0x2540('0x83'),'id'])||{})[_0x2540('0x98')](function(_0x37b2c2){for(var _0x2d2641=0x0;_0x2d2641<_0x193776['body'][_0x2540('0x83')][_0x2540('0x40')];_0x2d2641+=0x1){socket['emit']('userVoiceQueue:save',{'UserId':_0x193776[_0x2540('0x50')][_0x2540('0x83')][_0x2d2641],'VoiceQueueId':_0x193776['params']['id']});}return _0x37b2c2;});}})['then'](function(_0x3e28c2){_0x2f7c74=_0x3e28c2||[];if(_0x4f3de8){return db[_0x2540('0x71')]['findAll']({'where':{'id':_0x193776['body']['ids']},'attributes':['id','name',_0x2540('0x73'),_0x2540('0x7f'),'interface'],'raw':!![]});}})['then'](function(_0x2ce0ee){if(!_[_0x2540('0x94')](_0x2ce0ee)){var _0x238b6f=[];for(var _0x127839=0x0;_0x127839<_0x2ce0ee[_0x2540('0x40')];_0x127839++){if(_0x2ce0ee[_0x127839][_0x2540('0x73')]){_0x238b6f['push'](db[_0x2540('0x7b')][_0x2540('0x99')]({'membername':_0x2ce0ee[_0x127839][_0x2540('0x30')],'UserId':_0x2ce0ee[_0x127839]['id'],'queue_name':_0x4f3de8[_0x2540('0x30')],'VoiceQueueId':_0x4f3de8['id'],'interface':_['isNil'](_0x2ce0ee[_0x127839][_0x2540('0x74')])?util[_0x2540('0x7d')](_0x2540('0x7e'),_0x2ce0ee[_0x127839][_0x2540('0x30')]):_0x2ce0ee[_0x127839][_0x2540('0x74')],'paused':_0x2ce0ee[_0x127839]['voicePause']||![],'penalty':_0x193776['body'][_0x2540('0x77')]||0x0}));}}return BPromise[_0x2540('0x91')](_0x238b6f);}})['then'](function(){return _0x2f7c74;})['then'](respondWithResult(_0x40725e,null))['catch'](handleError(_0x40725e,null));};exports[_0x2540('0x95')]=function(_0x4af3ce,_0x230e03,_0x184d0e){return db['VoiceQueue'][_0x2540('0x2f')]({'where':{'id':_0x4af3ce[_0x2540('0x4d')]['id']}})[_0x2540('0x26')](handleEntityNotFound(_0x230e03,null))[_0x2540('0x26')](function(_0x15d4f6){if(_0x15d4f6){return _0x15d4f6['removeAgents'](_0x4af3ce[_0x2540('0x3a')][_0x2540('0x83')])['then'](function(){if(_['isArray'](_0x4af3ce[_0x2540('0x3a')][_0x2540('0x83')])){for(var _0x1a9eec=0x0;_0x1a9eec<_0x4af3ce[_0x2540('0x3a')][_0x2540('0x83')]['length'];_0x1a9eec+=0x1){socket['emit'](_0x2540('0x96'),{'UserId':Number(_0x4af3ce[_0x2540('0x3a')]['ids'][_0x1a9eec]),'VoiceQueueId':Number(_0x4af3ce[_0x2540('0x4d')]['id'])});}}else{socket['emit']('userVoiceQueue:remove',{'UserId':Number(_0x4af3ce[_0x2540('0x3a')]['ids']),'VoiceQueueId':Number(_0x4af3ce[_0x2540('0x4d')]['id'])});}});}})[_0x2540('0x26')](function(_0x4f62e0){return db[_0x2540('0x7b')][_0x2540('0x27')]({'where':{'VoiceQueueId':_0x4af3ce['params']['id'],'UserId':_0x4af3ce[_0x2540('0x3a')][_0x2540('0x83')]}})[_0x2540('0x26')](function(){return _0x4f62e0;});})[_0x2540('0x26')](respondWithStatusCode(_0x230e03,null))[_0x2540('0x4e')](handleError(_0x230e03,null));};exports['getAgents']=function(_0x19bdf3,_0x2a453a,_0x227b00){var _0x5de7e5={};var _0x364192={};var _0x3adb4c;var _0x558a6f;return db[_0x2540('0x4a')][_0x2540('0x61')]({'where':{'id':_0x19bdf3[_0x2540('0x4d')]['id']}})[_0x2540('0x26')](handleEntityNotFound(_0x2a453a,null))[_0x2540('0x26')](function(_0x158c4d){if(_0x158c4d){_0x3adb4c=_0x158c4d;_0x364192['model']=_[_0x2540('0x3b')](db[_0x2540('0x71')]['rawAttributes']);_0x364192[_0x2540('0x3a')]=_[_0x2540('0x3b')](_0x19bdf3[_0x2540('0x3a')]);_0x364192[_0x2540('0x3c')]=_[_0x2540('0x3d')](_0x364192[_0x2540('0x39')],_0x364192[_0x2540('0x3a')]);_0x5de7e5[_0x2540('0x3f')]=_[_0x2540('0x3d')](_0x364192[_0x2540('0x39')],qs[_0x2540('0x3e')](_0x19bdf3[_0x2540('0x3a')]['fields']));_0x5de7e5[_0x2540('0x3f')]=_0x5de7e5[_0x2540('0x3f')][_0x2540('0x40')]?_0x5de7e5[_0x2540('0x3f')]:_0x364192[_0x2540('0x39')];_0x5de7e5[_0x2540('0x42')]=qs['sort'](_0x19bdf3['query'][_0x2540('0x43')]);_0x5de7e5['where']=qs[_0x2540('0x3c')](_[_0x2540('0x68')](_0x19bdf3[_0x2540('0x3a')],_0x364192[_0x2540('0x3c')]));if(_0x19bdf3[_0x2540('0x3a')]['filter']){_0x5de7e5[_0x2540('0x44')]=_[_0x2540('0x45')](_0x5de7e5[_0x2540('0x44')],{'$or':_[_0x2540('0x46')](_0x5de7e5[_0x2540('0x3f')],function(_0x19798d){var _0x20d9aa={};_0x20d9aa[_0x19798d]={'$like':'%'+_0x19bdf3[_0x2540('0x3a')][_0x2540('0x2c')]+'%'};return _0x20d9aa;})});}_0x5de7e5=_[_0x2540('0x45')]({},_0x5de7e5,_0x19bdf3[_0x2540('0x5a')]);return _0x3adb4c[_0x2540('0x9a')](_0x5de7e5);}})[_0x2540('0x26')](function(_0x1c8e54){if(_0x1c8e54){_0x558a6f=_0x1c8e54[_0x2540('0x40')];if(!_0x19bdf3[_0x2540('0x3a')][_0x2540('0x41')]('nolimit')){_0x5de7e5[_0x2540('0x22')]=qs['limit'](_0x19bdf3['query']['limit']);_0x5de7e5[_0x2540('0x21')]=qs[_0x2540('0x21')](_0x19bdf3['query'][_0x2540('0x21')]);}return _0x3adb4c['getAgents'](_0x5de7e5);}})[_0x2540('0x26')](function(_0x5f50c1){if(_0x5f50c1){return _0x5f50c1?{'count':_0x558a6f,'rows':_0x5f50c1}:null;}})[_0x2540('0x26')](respondWithResult(_0x2a453a,null))['catch'](handleError(_0x2a453a,null));};exports['getMembers']=function(_0x116151,_0x2ed977,_0x4079cd){var _0x2d66ae={};var _0x41f572={};var _0x1892f9;var _0xaf3ebd;return db[_0x2540('0x4a')][_0x2540('0x61')]({'where':{'id':_0x116151[_0x2540('0x4d')]['id']}})[_0x2540('0x26')](handleEntityNotFound(_0x2ed977,null))['then'](function(_0x5e6e9c){if(_0x5e6e9c){_0x1892f9=_0x5e6e9c;_0x41f572['model']=_[_0x2540('0x3b')](db['UserVoiceQueueRt'][_0x2540('0x36')]);_0x41f572[_0x2540('0x3a')]=_[_0x2540('0x3b')](_0x116151[_0x2540('0x3a')]);_0x41f572[_0x2540('0x3c')]=_[_0x2540('0x3d')](_0x41f572[_0x2540('0x39')],_0x41f572['query']);_0x2d66ae[_0x2540('0x3f')]=_[_0x2540('0x3d')](_0x41f572[_0x2540('0x39')],qs[_0x2540('0x3e')](_0x116151['query'][_0x2540('0x3e')]));_0x2d66ae[_0x2540('0x3f')]=_0x2d66ae[_0x2540('0x3f')]['length']?_0x2d66ae[_0x2540('0x3f')]:_0x41f572[_0x2540('0x39')];_0x2d66ae[_0x2540('0x42')]=qs[_0x2540('0x43')](_0x116151[_0x2540('0x3a')][_0x2540('0x43')]);_0x2d66ae[_0x2540('0x44')]=qs['filters'](_['pick'](_0x116151[_0x2540('0x3a')],_0x41f572[_0x2540('0x3c')]));if(_0x116151['query'][_0x2540('0x2c')]){_0x2d66ae[_0x2540('0x44')]=_[_0x2540('0x45')](_0x2d66ae[_0x2540('0x44')],{'$or':_[_0x2540('0x46')](_0x2d66ae[_0x2540('0x3f')],function(_0x130e86){var _0x426729={};_0x426729[_0x130e86]={'$like':'%'+_0x116151[_0x2540('0x3a')][_0x2540('0x2c')]+'%'};return _0x426729;})});}_0x2d66ae=_[_0x2540('0x45')]({},_0x2d66ae,_0x116151['options']);return _0x1892f9[_0x2540('0x9b')](_0x2d66ae);}})['then'](function(_0x56c0fd){if(_0x56c0fd){_0xaf3ebd=_0x56c0fd['length'];if(!_0x116151[_0x2540('0x3a')]['hasOwnProperty'](_0x2540('0x63'))){_0x2d66ae[_0x2540('0x22')]=qs[_0x2540('0x22')](_0x116151[_0x2540('0x3a')][_0x2540('0x22')]);_0x2d66ae[_0x2540('0x21')]=qs[_0x2540('0x21')](_0x116151[_0x2540('0x3a')]['offset']);}return _0x1892f9[_0x2540('0x9b')](_0x2d66ae);}})[_0x2540('0x26')](function(_0x3b53f8){return _0x3b53f8?{'count':_0xaf3ebd,'rows':_0x3b53f8}:null;})[_0x2540('0x26')](respondWithResult(_0x2ed977,null))[_0x2540('0x4e')](handleError(_0x2ed977,null));};exports[_0x2540('0x9c')]=function(_0xa9aec,_0xa6fdb7,_0x26c6b6){var _0x2417de={};var _0x23d889={};var _0x4e5874;var _0xe12cb6;return db[_0x2540('0x4a')][_0x2540('0x61')]({'where':{'id':_0xa9aec['params']['id']}})[_0x2540('0x26')](handleEntityNotFound(_0xa6fdb7,null))['then'](function(_0xdd9378){if(_0xdd9378){_0x4e5874=_0xdd9378;_0x23d889['model']=_[_0x2540('0x3b')](db[_0x2540('0x9d')]['rawAttributes']);_0x23d889[_0x2540('0x3a')]=_[_0x2540('0x3b')](_0xa9aec[_0x2540('0x3a')]);_0x23d889['filters']=_['intersection'](_0x23d889['model'],_0x23d889[_0x2540('0x3a')]);_0x2417de[_0x2540('0x3f')]=_[_0x2540('0x3d')](_0x23d889[_0x2540('0x39')],qs[_0x2540('0x3e')](_0xa9aec[_0x2540('0x3a')][_0x2540('0x3e')]));_0x2417de[_0x2540('0x3f')]=_0x2417de['attributes'][_0x2540('0x40')]?_0x2417de[_0x2540('0x3f')]:_0x23d889[_0x2540('0x39')];_0x2417de[_0x2540('0x42')]=qs[_0x2540('0x43')](_0xa9aec[_0x2540('0x3a')][_0x2540('0x43')]);_0x2417de[_0x2540('0x44')]=qs[_0x2540('0x3c')](_[_0x2540('0x68')](_0xa9aec[_0x2540('0x3a')],_0x23d889[_0x2540('0x3c')]));if(_0xa9aec[_0x2540('0x3a')][_0x2540('0x2c')]){_0x2417de[_0x2540('0x44')]=_['merge'](_0x2417de[_0x2540('0x44')],{'$or':_[_0x2540('0x46')](_0x2417de[_0x2540('0x3f')],function(_0x30ab39){var _0x72a31a={};_0x72a31a[_0x30ab39]={'$like':'%'+_0xa9aec[_0x2540('0x3a')][_0x2540('0x2c')]+'%'};return _0x72a31a;})});}_0x2417de=_[_0x2540('0x45')]({},_0x2417de,_0xa9aec[_0x2540('0x5a')]);return _0x4e5874[_0x2540('0x9c')](_0x2417de);}})[_0x2540('0x26')](function(_0x2e6560){if(_0x2e6560){_0xe12cb6=_0x2e6560[_0x2540('0x40')];if(!_0xa9aec['query'][_0x2540('0x41')](_0x2540('0x63'))){_0x2417de[_0x2540('0x22')]=qs['limit'](_0xa9aec['query']['limit']);_0x2417de[_0x2540('0x21')]=qs['offset'](_0xa9aec[_0x2540('0x3a')][_0x2540('0x21')]);}return _0x4e5874[_0x2540('0x9c')](_0x2417de);}})[_0x2540('0x26')](function(_0x314db7){if(_0x314db7){return _0x314db7?{'count':_0xe12cb6,'rows':_0x314db7}:null;}})[_0x2540('0x26')](respondWithResult(_0xa6fdb7,null))[_0x2540('0x4e')](handleError(_0xa6fdb7,null));};exports['addLists']=function(_0x2c0ada,_0x4059b5,_0x215af5){var _0x436e0f,_0x54dbe9;return db[_0x2540('0x4a')]['find']({'where':{'id':_0x2c0ada[_0x2540('0x4d')]['id']}})[_0x2540('0x26')](handleEntityNotFound(_0x4059b5,null))[_0x2540('0x26')](function(_0x486ef8){if(_0x486ef8){_0x54dbe9=_0x486ef8;return _0x486ef8['addLists'](_0x2c0ada[_0x2540('0x50')][_0x2540('0x83')],_[_0x2540('0x5b')](_0x2c0ada['body'],[_0x2540('0x83'),'id'])||{});}return null;})['spread'](function(_0x545c5b){var _0x27b64c;_0x436e0f=_0x545c5b||[];var _0x330b44=[];if(_0x545c5b){for(var _0x265084=0x0;_0x265084<_0x545c5b[_0x2540('0x40')];_0x265084+=0x1){var _0xfb2627=_0x545c5b[_0x265084][_0x2540('0x28')]({'plain':!![]});_0x54dbe9[_0x2540('0x9e')]=_0x2c0ada[_0x2540('0x50')]['dialCheckDuplicateType']?_0x2c0ada[_0x2540('0x50')][_0x2540('0x9e')]:_0x54dbe9[_0x2540('0x9e')];switch(_0x54dbe9[_0x2540('0x9e')]){case _0x2540('0x9f'):_0x27b64c=squel[_0x2540('0xa0')]()[_0x2540('0xa1')](_0x2540('0xa2'))[_0x2540('0xa3')]([_0x2540('0xa4'),_0x2540('0xa5'),_0x2540('0xa6'),_0x2540('0xa7'),_0x2540('0x64'),_0x2540('0x5c'),_0x2540('0x5d')],squel[_0x2540('0x84')]()[_0x2540('0x85')](_0x2540('0xa4'),'phone')[_0x2540('0x85')](_0x2540('0xa8'),_0x2540('0xa5'))[_0x2540('0x85')]('id','ContactId')[_0x2540('0x85')](_0xfb2627[_0x2540('0xa9')][_0x2540('0x8d')](),_0x2540('0xa7'))[_0x2540('0x85')](_0x2c0ada[_0x2540('0x4d')]['id'][_0x2540('0x8d')](),_0x2540('0x64'))['field'](_0x2540('0xa8'),'createdAt')[_0x2540('0x85')](_0x2540('0xa8'),_0x2540('0x5d'))[_0x2540('0x87')](_0x2540('0xaa'))[_0x2540('0x44')](_0x2540('0xab'))[_0x2540('0x44')](_0x2540('0xac'),_0xfb2627[_0x2540('0xa9')][_0x2540('0x8d')]())[_0x2540('0x44')](_0x2540('0xad'))[_0x2540('0x44')](_0x2540('0xae'),squel['select']()['field'](_0x2540('0xaf'))['from'](_0x2540('0xb0'))[_0x2540('0x44')]('VoiceQueueId\x20=\x20?',_0x2c0ada['params']['id'][_0x2540('0x8d')]()))['where'](_0x2540('0xae'),squel[_0x2540('0x84')]()[_0x2540('0x85')](_0x2540('0xb1'))[_0x2540('0x87')]('cm_hopper')[_0x2540('0x44')](_0x2540('0x8a'),_0x2c0ada[_0x2540('0x4d')]['id']['toString']())))[_0x2540('0x8d')]();break;case _0x2540('0xb2'):_0x27b64c=squel['insert']()[_0x2540('0xa1')](_0x2540('0xa2'))[_0x2540('0xa3')](['phone',_0x2540('0xa5'),_0x2540('0xa6'),_0x2540('0xa7'),_0x2540('0x64'),_0x2540('0x5c'),'updatedAt'],squel[_0x2540('0x84')]()[_0x2540('0x85')](_0x2540('0xa4'),_0x2540('0xa4'))[_0x2540('0x85')]('NOW()',_0x2540('0xa5'))[_0x2540('0x85')]('id',_0x2540('0xa6'))['field'](_0xfb2627[_0x2540('0xa9')][_0x2540('0x8d')](),_0x2540('0xa7'))[_0x2540('0x85')](_0x2c0ada[_0x2540('0x4d')]['id'][_0x2540('0x8d')](),_0x2540('0x64'))['field'](_0x2540('0xa8'),_0x2540('0x5c'))[_0x2540('0x85')](_0x2540('0xa8'),_0x2540('0x5d'))[_0x2540('0x87')](_0x2540('0xaa'))[_0x2540('0x44')](_0x2540('0xab'))[_0x2540('0x44')](_0x2540('0xac'),_0xfb2627[_0x2540('0xa9')][_0x2540('0x8d')]())[_0x2540('0x44')](_0x2540('0xad'))[_0x2540('0x44')](_0x2540('0xae'),squel[_0x2540('0x84')]()[_0x2540('0x85')]('COALESCE(phone,\x27\x27)')[_0x2540('0x87')]('cm_hopper')[_0x2540('0x44')]('VoiceQueueId\x20=\x20?',_0x2c0ada[_0x2540('0x4d')]['id'][_0x2540('0x8d')]())))['toString']();break;default:_0x27b64c=squel[_0x2540('0xa0')]()[_0x2540('0xa1')]('cm_hopper')[_0x2540('0xa3')](['phone',_0x2540('0xa5'),_0x2540('0xa6'),_0x2540('0xa7'),_0x2540('0x64'),_0x2540('0x5c'),_0x2540('0x5d')],squel[_0x2540('0x84')]()[_0x2540('0x85')](_0x2540('0xa4'),_0x2540('0xa4'))['field'](_0x2540('0xa8'),_0x2540('0xa5'))[_0x2540('0x85')]('id',_0x2540('0xa6'))['field'](_0xfb2627[_0x2540('0xa9')][_0x2540('0x8d')](),_0x2540('0xa7'))[_0x2540('0x85')](_0x2c0ada[_0x2540('0x4d')]['id'][_0x2540('0x8d')](),_0x2540('0x64'))[_0x2540('0x85')](_0x2540('0xa8'),_0x2540('0x5c'))['field']('NOW()',_0x2540('0x5d'))['from'](_0x2540('0xaa'))[_0x2540('0x44')]('deletedAt\x20IS\x20NULL')[_0x2540('0x44')](_0x2540('0xac'),_0xfb2627[_0x2540('0xa9')]['toString']())[_0x2540('0x44')](_0x2540('0xad')))[_0x2540('0x8d')]();}_0x330b44['push'](db[_0x2540('0x78')][_0x2540('0x3a')](_0x27b64c));}return BPromise['all'](_0x330b44);}})[_0x2540('0x26')](function(){return _0x436e0f;})[_0x2540('0x26')](respondWithResult(_0x4059b5,null))[_0x2540('0x4e')](handleError(_0x4059b5,null));};exports['removeLists']=function(_0x252716,_0x37c07b,_0x366dde){return db[_0x2540('0x4a')][_0x2540('0x2f')]({'where':{'id':_0x252716[_0x2540('0x4d')]['id']}})[_0x2540('0x26')](handleEntityNotFound(_0x37c07b,null))[_0x2540('0x26')](function(_0x2e0cbf){if(_0x2e0cbf){return _0x2e0cbf['removeLists'](_0x252716[_0x2540('0x3a')][_0x2540('0x83')]);}})[_0x2540('0x26')](function(_0x4364eb){if(_0x4364eb){return db[_0x2540('0x62')][_0x2540('0x27')]({'where':{'ListId':_0x252716[_0x2540('0x3a')][_0x2540('0x83')],'VoiceQueueId':_0x252716[_0x2540('0x4d')]['id']}})['then'](function(){return _0x4364eb;});}})[_0x2540('0x26')](respondWithStatusCode(_0x37c07b,null))[_0x2540('0x4e')](handleError(_0x37c07b,null));};exports[_0x2540('0xb3')]=function(_0x3959a0,_0x3c79e5,_0x317245){var _0x2bc414={};var _0x2e70d9={};var _0x2a96fa;var _0x43107c;return db[_0x2540('0x4a')][_0x2540('0x61')]({'where':{'id':_0x3959a0[_0x2540('0x4d')]['id']}})[_0x2540('0x26')](handleEntityNotFound(_0x3c79e5,null))[_0x2540('0x26')](function(_0x4bfbda){if(_0x4bfbda){_0x2a96fa=_0x4bfbda;_0x2e70d9[_0x2540('0x39')]=_[_0x2540('0x3b')](db[_0x2540('0x9d')][_0x2540('0x36')]);_0x2e70d9[_0x2540('0x3a')]=_[_0x2540('0x3b')](_0x3959a0[_0x2540('0x3a')]);_0x2e70d9[_0x2540('0x3c')]=_['intersection'](_0x2e70d9[_0x2540('0x39')],_0x2e70d9[_0x2540('0x3a')]);_0x2bc414[_0x2540('0x3f')]=_['intersection'](_0x2e70d9[_0x2540('0x39')],qs[_0x2540('0x3e')](_0x3959a0[_0x2540('0x3a')][_0x2540('0x3e')]));_0x2bc414[_0x2540('0x3f')]=_0x2bc414[_0x2540('0x3f')][_0x2540('0x40')]?_0x2bc414[_0x2540('0x3f')]:_0x2e70d9[_0x2540('0x39')];_0x2bc414[_0x2540('0x42')]=qs[_0x2540('0x43')](_0x3959a0[_0x2540('0x3a')]['sort']);_0x2bc414[_0x2540('0x44')]=qs[_0x2540('0x3c')](_[_0x2540('0x68')](_0x3959a0[_0x2540('0x3a')],_0x2e70d9[_0x2540('0x3c')]));if(_0x3959a0['query'][_0x2540('0x2c')]){_0x2bc414[_0x2540('0x44')]=_['merge'](_0x2bc414['where'],{'$or':_['map'](_0x2bc414[_0x2540('0x3f')],function(_0x2988b2){var _0x35b970={};_0x35b970[_0x2988b2]={'$like':'%'+_0x3959a0[_0x2540('0x3a')][_0x2540('0x2c')]+'%'};return _0x35b970;})});}_0x2bc414=_['merge']({},_0x2bc414,_0x3959a0['options']);return _0x2a96fa[_0x2540('0xb3')](_0x2bc414);}})[_0x2540('0x26')](function(_0x5c7963){if(_0x5c7963){_0x43107c=_0x5c7963[_0x2540('0x40')];if(!_0x3959a0[_0x2540('0x3a')][_0x2540('0x41')](_0x2540('0x63'))){_0x2bc414['limit']=qs['limit'](_0x3959a0[_0x2540('0x3a')]['limit']);_0x2bc414[_0x2540('0x21')]=qs[_0x2540('0x21')](_0x3959a0['query'][_0x2540('0x21')]);}return _0x2a96fa[_0x2540('0xb3')](_0x2bc414);}})[_0x2540('0x26')](function(_0x20d5e8){if(_0x20d5e8){return _0x20d5e8?{'count':_0x43107c,'rows':_0x20d5e8}:null;}})[_0x2540('0x26')](respondWithResult(_0x3c79e5,null))[_0x2540('0x4e')](handleError(_0x3c79e5,null));};exports['addBlackLists']=function(_0xe90833,_0x399a72,_0x137439){var _0x7ed000,_0xa1e82;return db[_0x2540('0x4a')][_0x2540('0x2f')]({'where':{'id':_0xe90833[_0x2540('0x4d')]['id']}})[_0x2540('0x26')](handleEntityNotFound(_0x399a72,null))[_0x2540('0x26')](function(_0x3c6309){if(_0x3c6309){_0xa1e82=_0x3c6309;return _0x3c6309[_0x2540('0xb4')](_0xe90833[_0x2540('0x50')][_0x2540('0x83')],_['omit'](_0xe90833[_0x2540('0x50')],[_0x2540('0x83'),'id'])||{});}return null;})['spread'](function(_0x28dd70){var _0x5eabd5;_0x7ed000=_0x28dd70||[];var _0x195122=[];if(_0x28dd70){for(var _0x13dddc=0x0;_0x13dddc<_0x28dd70['length'];_0x13dddc+=0x1){var _0x2702d6=_0x28dd70[_0x13dddc]['get']({'plain':!![]});_0x5eabd5=squel['insert']()[_0x2540('0xa1')](_0x2540('0xb5'))[_0x2540('0xa3')](['phone',_0x2540('0xa6'),_0x2540('0xa7'),_0x2540('0x64'),_0x2540('0x5c'),'updatedAt'],squel[_0x2540('0x84')]()[_0x2540('0x85')](_0x2540('0xa4'),_0x2540('0xa4'))[_0x2540('0x85')]('id',_0x2540('0xa6'))[_0x2540('0x85')](_0x2702d6[_0x2540('0xa9')][_0x2540('0x8d')](),'ListId')[_0x2540('0x85')](_0xe90833['params']['id'][_0x2540('0x8d')](),_0x2540('0x64'))[_0x2540('0x85')](_0x2540('0xa8'),'createdAt')['field'](_0x2540('0xa8'),_0x2540('0x5d'))['from']('cm_contacts')[_0x2540('0x44')](_0x2540('0xab'))[_0x2540('0x44')](_0x2540('0xac'),_0x2702d6[_0x2540('0xa9')][_0x2540('0x8d')]())[_0x2540('0x44')]('phone\x20IS\x20NOT\x20NULL'))[_0x2540('0x8d')]();_0x195122[_0x2540('0x8c')](db[_0x2540('0x78')][_0x2540('0x3a')](_0x5eabd5));}return BPromise[_0x2540('0x91')](_0x195122);}})['then'](function(){return _0x7ed000;})[_0x2540('0x26')](respondWithResult(_0x399a72,null))['catch'](handleError(_0x399a72,null));};exports[_0x2540('0xb6')]=function(_0x22b340,_0x521d1b,_0x2d51ba){return db[_0x2540('0x4a')][_0x2540('0x2f')]({'where':{'id':_0x22b340['params']['id']}})[_0x2540('0x26')](handleEntityNotFound(_0x521d1b,null))[_0x2540('0x26')](function(_0x3a685c){if(_0x3a685c){return _0x3a685c['removeBlackLists'](_0x22b340[_0x2540('0x3a')][_0x2540('0x83')]);}})['then'](function(_0x22ed41){if(_0x22ed41){return db[_0x2540('0x6c')][_0x2540('0x27')]({'where':{'ListId':_0x22b340[_0x2540('0x3a')][_0x2540('0x83')],'VoiceQueueId':_0x22b340[_0x2540('0x4d')]['id']}})['then'](function(){return _0x22ed41;});}})[_0x2540('0x26')](respondWithStatusCode(_0x521d1b,null))[_0x2540('0x4e')](handleError(_0x521d1b,null));};
\ No newline at end of file