Built motion from commit 0900f080.|2.5.45
[motion2.git] / server / api / voiceQueue / voiceQueue.controller.js
index 2fb65c5..88ca625 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xba7b=['toString','QueryTypes','SELECT','every','TeamId','all','union','compact','ids','isEmpty','emit','userVoiceQueue:remove','spread','removeAgents','isArray','getAgents','getMembers','getLists','addLists','dialCheckDuplicateType','always','insert','into','cm_hopper','phone','scheduledAt','select','NOW()','ContactId','CmListId','ListId','cm_contacts','ListId\x20=\x20?','phone\x20IS\x20NOT\x20NULL','phone\x20NOT\x20IN\x20(?)','cm_hopper_final','VoiceQueueId\x20=\x20?','COALESCE(phone,\x27\x27)','onlyIfOpen','fromQuery','deletedAt\x20IS\x20NULL','removeLists','CmHopper','getBlackLists','addBlackLists','cm_hopper_black','removeBlackLists','html-pdf','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','path','sox','to-csv','lodash','squel','crypto','desk.js','papaparse','../../config/logger','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','defaults','localhost','socket.io-emitter','redis','sendStatus','status','end','count','offset','limit','set','Content-Range','save','update','destroy','then','get','VoiceQueues','inbound','QueueCampaigns','outbound','filter','ignore','value','type','find','UserProfileResource','stack','name','send','index','map','VoiceQueue','rawAttributes','fieldName','key','model','query','filters','intersection','fields','attributes','length','hasOwnProperty','nolimit','sort','where','pick','merge','VIRTUAL','options','includeAll','include','catch','show','params','keys','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','userProfileId','error','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','clone','omit','createdAt','updatedAt','UserProfileSection','autoAssociation','findOne','order','VoiceQueueId','findAll','getHopperHistories','CmHopperHistory','CmHopperFinal','CmHopperBlack','getTeams','Team','addTeams','teams','Agents','online','voicePause','forEach','penalty','sequelize','UserVoiceQueue','each','UserVoiceQueueRt','upsert','isNil','interface','format','userVoiceQueue:save','removeTeams','User','field','from','team_has_voice_queues','user_has_teams','ut.UserId\x20=\x20?','push'];(function(_0x2a2691,_0xb51e87){var _0xac18b=function(_0x504b35){while(--_0x504b35){_0x2a2691['push'](_0x2a2691['shift']());}};_0xac18b(++_0xb51e87);}(_0xba7b,0x18b));var _0xbba7=function(_0x6089fc,_0x4a450e){_0x6089fc=_0x6089fc-0x0;var _0x1d1a87=_0xba7b[_0x6089fc];return _0x1d1a87;};'use strict';var pdf=require(_0xbba7('0x0'));var emlformat=require(_0xbba7('0x1'));var rimraf=require(_0xbba7('0x2'));var zipdir=require(_0xbba7('0x3'));var jsonpatch=require(_0xbba7('0x4'));var rp=require(_0xbba7('0x5'));var moment=require(_0xbba7('0x6'));var BPromise=require(_0xbba7('0x7'));var Mustache=require(_0xbba7('0x8'));var util=require('util');var path=require(_0xbba7('0x9'));var sox=require(_0xbba7('0xa'));var csv=require(_0xbba7('0xb'));var ejs=require('ejs');var fs=require('fs');var _=require(_0xbba7('0xc'));var squel=require(_0xbba7('0xd'));var crypto=require(_0xbba7('0xe'));var jsforce=require('jsforce');var deskjs=require(_0xbba7('0xf'));var toCsv=require(_0xbba7('0xb'));var querystring=require('querystring');var Papa=require(_0xbba7('0x10'));var Redis=require('ioredis');var authService=require('../../components/auth/service');var qs=require('../../components/parsers/qs');var as=require('../../components/parsers/advancedSearch');var hardwareService=require('../../config/license/hardware');var logger=require(_0xbba7('0x11'))('api');var utils=require(_0xbba7('0x12'));var config=require(_0xbba7('0x13'));var licenseUtil=require(_0xbba7('0x14'));var db=require(_0xbba7('0x15'))['db'];config['redis']=_[_0xbba7('0x16')](config['redis'],{'host':_0xbba7('0x17'),'port':0x18eb});var socket=require(_0xbba7('0x18'))(new Redis(config[_0xbba7('0x19')]));require('./voiceQueue.socket')['register'](socket);function respondWithStatusCode(_0x56cfa8,_0x593293){_0x593293=_0x593293||0xcc;return function(_0x42d46b){if(_0x42d46b){return _0x56cfa8[_0xbba7('0x1a')](_0x593293);}return _0x56cfa8[_0xbba7('0x1b')](_0x593293)[_0xbba7('0x1c')]();};}function respondWithResult(_0x2b4b66,_0x276fdf){_0x276fdf=_0x276fdf||0xc8;return function(_0x366fe4){if(_0x366fe4){return _0x2b4b66[_0xbba7('0x1b')](_0x276fdf)['json'](_0x366fe4);}};}function respondWithFilteredResult(_0x5dd0da,_0x9e94d0){return function(_0x313a07){if(_0x313a07){var _0x4e8b3b=_0x313a07[_0xbba7('0x1d')],_0x4aa203=_0x9e94d0[_0xbba7('0x1e')],_0x2dc5a3=_0x9e94d0[_0xbba7('0x1e')]+_0x9e94d0[_0xbba7('0x1f')],_0x2f23fa;if(_0x2dc5a3>=_0x4e8b3b){_0x2dc5a3=_0x4e8b3b;_0x2f23fa=0xc8;}else{_0x2f23fa=0xce;}_0x5dd0da[_0xbba7('0x1b')](_0x2f23fa);return _0x5dd0da[_0xbba7('0x20')](_0xbba7('0x21'),_0x4aa203+'-'+_0x2dc5a3+'/'+_0x4e8b3b)['json'](_0x313a07);}return null;};}function patchUpdates(_0x3b6a24){return function(_0x2f0bb6){try{jsonpatch['apply'](_0x2f0bb6,_0x3b6a24,!![]);}catch(_0x2822e2){return BPromise['reject'](_0x2822e2);}return _0x2f0bb6[_0xbba7('0x22')]();};}function saveUpdates(_0x5934f9,_0x1e9b9b){return function(_0x588ed2){if(_0x588ed2){return _0x588ed2[_0xbba7('0x23')](_0x5934f9)['then'](function(_0x1bb6a8){return _0x1bb6a8;});}return null;};}function removeEntity(_0x4ecf4c,_0x55e6b0){return function(_0x1dec24){if(_0x1dec24){return _0x1dec24[_0xbba7('0x24')]()[_0xbba7('0x25')](function(){var _0x5c550f=_0x1dec24[_0xbba7('0x26')]({'plain':!![]});var _0x56c02b=[{'name':_0xbba7('0x27'),'value':_0xbba7('0x28'),'ignore':![]},{'name':_0xbba7('0x29'),'value':_0xbba7('0x2a'),'ignore':![]}];var _0x3cee70=_(_0x56c02b)[_0xbba7('0x2b')](_0xbba7('0x2c'))['map'](_0xbba7('0x2d'))[_0xbba7('0x2d')]();if(_['includes'](_0x3cee70,_0x5c550f[_0xbba7('0x2e')])){return;}var _0xe263e6=_[_0xbba7('0x2f')](_0x56c02b,[_0xbba7('0x2d'),_0x5c550f[_0xbba7('0x2e')]])['name'];return db[_0xbba7('0x30')][_0xbba7('0x24')]({'where':{'type':_0xe263e6,'resourceId':_0x5c550f['id']}})[_0xbba7('0x25')](function(){return _0x1dec24;});})[_0xbba7('0x25')](function(){_0x4ecf4c[_0xbba7('0x1b')](0xcc)[_0xbba7('0x1c')]();});}};}function handleEntityNotFound(_0x4088ab,_0x43643c){return function(_0x52ab5d){if(!_0x52ab5d){_0x4088ab['sendStatus'](0x194);}return _0x52ab5d;};}function handleError(_0x3ed93b,_0x5abe14){_0x5abe14=_0x5abe14||0x1f4;return function(_0x2fbbee){logger['error'](_0x2fbbee[_0xbba7('0x31')]);if(_0x2fbbee[_0xbba7('0x32')]){delete _0x2fbbee[_0xbba7('0x32')];}_0x3ed93b[_0xbba7('0x1b')](_0x5abe14)[_0xbba7('0x33')](_0x2fbbee);};}exports[_0xbba7('0x34')]=function(_0x48d684,_0x21494b){var _0x41170d={},_0x44f8a6={},_0x5e2262={'count':0x0,'rows':[]};var _0x23d408=_[_0xbba7('0x35')](db[_0xbba7('0x36')][_0xbba7('0x37')],function(_0x24befc){return{'name':_0x24befc[_0xbba7('0x38')],'type':_0x24befc[_0xbba7('0x2e')][_0xbba7('0x39')]};});_0x44f8a6[_0xbba7('0x3a')]=_[_0xbba7('0x35')](_0x23d408,_0xbba7('0x32'));_0x44f8a6['query']=_['keys'](_0x48d684[_0xbba7('0x3b')]);_0x44f8a6[_0xbba7('0x3c')]=_[_0xbba7('0x3d')](_0x44f8a6[_0xbba7('0x3a')],_0x44f8a6['query']);_0x41170d['attributes']=_['intersection'](_0x44f8a6[_0xbba7('0x3a')],qs[_0xbba7('0x3e')](_0x48d684[_0xbba7('0x3b')][_0xbba7('0x3e')]));_0x41170d[_0xbba7('0x3f')]=_0x41170d[_0xbba7('0x3f')][_0xbba7('0x40')]?_0x41170d[_0xbba7('0x3f')]:_0x44f8a6[_0xbba7('0x3a')];if(!_0x48d684[_0xbba7('0x3b')][_0xbba7('0x41')](_0xbba7('0x42'))){_0x41170d['limit']=qs['limit'](_0x48d684[_0xbba7('0x3b')][_0xbba7('0x1f')]);_0x41170d[_0xbba7('0x1e')]=qs['offset'](_0x48d684[_0xbba7('0x3b')]['offset']);}_0x41170d['order']=qs[_0xbba7('0x43')](_0x48d684[_0xbba7('0x3b')]['sort']);_0x41170d[_0xbba7('0x44')]=qs[_0xbba7('0x3c')](_[_0xbba7('0x45')](_0x48d684[_0xbba7('0x3b')],_0x44f8a6['filters']),_0x23d408);if(_0x48d684[_0xbba7('0x3b')][_0xbba7('0x2b')]){_0x41170d['where']=_[_0xbba7('0x46')](_0x41170d['where'],{'$or':_[_0xbba7('0x35')](_0x23d408,function(_0x59e7a6){if(_0x59e7a6['type']!==_0xbba7('0x47')){var _0x3caa79={};_0x3caa79[_0x59e7a6[_0xbba7('0x32')]]={'$like':'%'+_0x48d684[_0xbba7('0x3b')][_0xbba7('0x2b')]+'%'};return _0x3caa79;}})});}_0x41170d=_[_0xbba7('0x46')]({},_0x41170d,_0x48d684[_0xbba7('0x48')]);var _0x523e24={'where':_0x41170d['where']};return db[_0xbba7('0x36')][_0xbba7('0x1d')](_0x523e24)[_0xbba7('0x25')](function(_0x1f869c){_0x5e2262[_0xbba7('0x1d')]=_0x1f869c;if(_0x48d684[_0xbba7('0x3b')][_0xbba7('0x49')]){_0x41170d[_0xbba7('0x4a')]=[{'all':!![]}];}return db[_0xbba7('0x36')]['findAll'](_0x41170d);})[_0xbba7('0x25')](function(_0x53a111){_0x5e2262['rows']=_0x53a111;return _0x5e2262;})[_0xbba7('0x25')](respondWithFilteredResult(_0x21494b,_0x41170d))[_0xbba7('0x4b')](handleError(_0x21494b,null));};exports[_0xbba7('0x4c')]=function(_0x357d82,_0x5e49bb){var _0x3209ad={'raw':![],'where':{'id':_0x357d82[_0xbba7('0x4d')]['id']}},_0x466ace={};_0x466ace['model']=_[_0xbba7('0x4e')](db[_0xbba7('0x36')][_0xbba7('0x37')]);_0x466ace[_0xbba7('0x3b')]=_[_0xbba7('0x4e')](_0x357d82[_0xbba7('0x3b')]);_0x466ace[_0xbba7('0x3c')]=_[_0xbba7('0x3d')](_0x466ace[_0xbba7('0x3a')],_0x466ace[_0xbba7('0x3b')]);_0x3209ad[_0xbba7('0x3f')]=_[_0xbba7('0x3d')](_0x466ace[_0xbba7('0x3a')],qs[_0xbba7('0x3e')](_0x357d82[_0xbba7('0x3b')][_0xbba7('0x3e')]));_0x3209ad['attributes']=_0x3209ad[_0xbba7('0x3f')][_0xbba7('0x40')]?_0x3209ad[_0xbba7('0x3f')]:_0x466ace[_0xbba7('0x3a')];if(_0x357d82['query'][_0xbba7('0x49')]){_0x3209ad[_0xbba7('0x4a')]=[{'all':!![]}];}_0x3209ad=_['merge']({},_0x3209ad,_0x357d82[_0xbba7('0x48')]);return db['VoiceQueue'][_0xbba7('0x2f')](_0x3209ad)[_0xbba7('0x25')](handleEntityNotFound(_0x5e49bb,null))[_0xbba7('0x25')](respondWithResult(_0x5e49bb,null))['catch'](handleError(_0x5e49bb,null));};exports[_0xbba7('0x4f')]=function(_0x1346e9,_0x24b675){return db['VoiceQueue'][_0xbba7('0x4f')](_0x1346e9[_0xbba7('0x50')],{})[_0xbba7('0x25')](function(_0x526e9c){var _0xea988c=_0x1346e9[_0xbba7('0x51')][_0xbba7('0x26')]({'plain':!![]});if(!_0xea988c)throw new Error(_0xbba7('0x52'));if(_0xea988c[_0xbba7('0x53')]===_0xbba7('0x51')){var _0x519bfb=_0x526e9c[_0xbba7('0x26')]({'plain':!![]});var _0x747a18=[{'name':_0xbba7('0x27'),'value':_0xbba7('0x28')},{'name':_0xbba7('0x29'),'value':_0xbba7('0x2a')}];var _0x3aa43f=_[_0xbba7('0x2f')](_0x747a18,[_0xbba7('0x2d'),_0x519bfb['type']])['name'];return db['UserProfileSection'][_0xbba7('0x2f')]({'where':{'name':_0x3aa43f,'userProfileId':_0xea988c[_0xbba7('0x54')]},'raw':!![]})[_0xbba7('0x25')](function(_0x41cb49){if(_0x41cb49&&_0x41cb49['autoAssociation']===0x0){return db[_0xbba7('0x30')][_0xbba7('0x4f')]({'name':_0x519bfb['name'],'resourceId':_0x519bfb['id'],'type':_0x41cb49[_0xbba7('0x32')],'sectionId':_0x41cb49['id']},{})[_0xbba7('0x25')](function(){return _0x526e9c;});}else{return _0x526e9c;}})[_0xbba7('0x4b')](function(_0x34f0c5){logger[_0xbba7('0x55')](_0xbba7('0x56'),_0x34f0c5);throw _0x34f0c5;});}return _0x526e9c;})['then'](respondWithResult(_0x24b675,0xc9))[_0xbba7('0x4b')](handleError(_0x24b675,null));};exports[_0xbba7('0x57')]=function(_0x3a8219,_0x4e34a1){var _0x114414={'where':{'id':_0x3a8219['params']['id']}},_0x1d4514={};_0x1d4514[_0xbba7('0x3a')]=_[_0xbba7('0x4e')](db[_0xbba7('0x36')][_0xbba7('0x37')]);_0x114414[_0xbba7('0x3f')]=_[_0xbba7('0x3d')](_0x1d4514[_0xbba7('0x3a')],qs[_0xbba7('0x3e')](_0x3a8219[_0xbba7('0x3b')][_0xbba7('0x3e')]));_0x114414[_0xbba7('0x3f')]=_0x114414[_0xbba7('0x3f')][_0xbba7('0x40')]?_0x114414[_0xbba7('0x3f')]:_0x1d4514[_0xbba7('0x3a')];if(_0x3a8219[_0xbba7('0x3b')][_0xbba7('0x49')]){_0x114414[_0xbba7('0x4a')]=[{'all':!![]}];}_0x114414=_['merge']({},_0x114414,_0x3a8219[_0xbba7('0x48')]);return db[_0xbba7('0x36')][_0xbba7('0x2f')](_0x114414)[_0xbba7('0x25')](handleEntityNotFound(_0x4e34a1,null))[_0xbba7('0x25')](function(_0x1fa408){if(_0x1fa408){var _0x5e47c7=_0x1fa408[_0xbba7('0x26')]({'plain':!![]});_0x5e47c7=qs[_0xbba7('0x58')](_0x5e47c7,['id',_0xbba7('0x59'),_0xbba7('0x5a')]);_0x3a8219['body']=_[_0xbba7('0x58')](_0x3a8219['body'],['id',_0xbba7('0x59'),_0xbba7('0x5a')]);return db[_0xbba7('0x36')][_0xbba7('0x4f')](_['merge'](_0x5e47c7,_0x3a8219[_0xbba7('0x50')]),{'include':_0x3a8219[_0xbba7('0x3b')]['includeAll']?[{'all':!![]}]:undefined})[_0xbba7('0x25')](function(_0x47966b){var _0x15228e=_0x3a8219[_0xbba7('0x51')][_0xbba7('0x26')]({'plain':!![]});if(!_0x15228e)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x15228e['role']===_0xbba7('0x51')){var _0x26785b=_0x47966b[_0xbba7('0x26')]({'plain':!![]});var _0x224a44=[{'name':_0xbba7('0x27'),'value':_0xbba7('0x28')},{'name':_0xbba7('0x29'),'value':'outbound'}];var _0x5b46cf=_[_0xbba7('0x2f')](_0x224a44,[_0xbba7('0x2d'),_0x26785b['type']])[_0xbba7('0x32')];return db[_0xbba7('0x5b')]['find']({'where':{'name':_0x5b46cf,'userProfileId':_0x15228e[_0xbba7('0x54')]},'raw':!![]})['then'](function(_0x1d0659){if(_0x1d0659&&_0x1d0659[_0xbba7('0x5c')]===0x0){return db[_0xbba7('0x30')][_0xbba7('0x4f')]({'name':_0x26785b[_0xbba7('0x32')],'resourceId':_0x26785b['id'],'type':_0x1d0659[_0xbba7('0x32')],'sectionId':_0x1d0659['id']},{})['then'](function(){return _0x47966b;});}else{return _0x47966b;}})['catch'](function(_0xc09c04){logger[_0xbba7('0x55')](_0xbba7('0x56'),_0xc09c04);throw _0xc09c04;});}return _0x47966b;});}})[_0xbba7('0x25')](respondWithResult(_0x4e34a1,0xc9))[_0xbba7('0x4b')](handleError(_0x4e34a1,null));};exports['update']=function(_0x73924,_0x308d91){if(_0x73924[_0xbba7('0x50')]['id']){delete _0x73924[_0xbba7('0x50')]['id'];}return db[_0xbba7('0x36')][_0xbba7('0x2f')]({'where':{'id':_0x73924[_0xbba7('0x4d')]['id']}})['then'](handleEntityNotFound(_0x308d91,null))[_0xbba7('0x25')](saveUpdates(_0x73924['body'],null))[_0xbba7('0x25')](respondWithResult(_0x308d91,null))['catch'](handleError(_0x308d91,null));};exports[_0xbba7('0x24')]=function(_0x4f88bd,_0x4ae4dd){return db[_0xbba7('0x36')][_0xbba7('0x2f')]({'where':{'id':_0x4f88bd['params']['id']}})[_0xbba7('0x25')](handleEntityNotFound(_0x4ae4dd,null))[_0xbba7('0x25')](removeEntity(_0x4ae4dd,null))[_0xbba7('0x4b')](handleError(_0x4ae4dd,null));};exports['getHoppers']=function(_0x15b481,_0x15be33,_0x1f01c2){var _0x2c6adb={'raw':![],'where':{}};var _0x445d71={};var _0x7c6e98={'count':0x0,'rows':[]};return db[_0xbba7('0x36')][_0xbba7('0x5d')]({'where':{'id':_0x15b481[_0xbba7('0x4d')]['id']}})[_0xbba7('0x25')](handleEntityNotFound(_0x15be33,null))[_0xbba7('0x25')](function(_0x49a9fa){if(_0x49a9fa){_0x445d71[_0xbba7('0x3a')]=_['keys'](db['CmHopper']['rawAttributes']);_0x445d71[_0xbba7('0x3b')]=_['keys'](_0x15b481[_0xbba7('0x3b')]);_0x445d71[_0xbba7('0x3c')]=_['intersection'](_0x445d71['model'],_0x445d71[_0xbba7('0x3b')]);_0x2c6adb[_0xbba7('0x3f')]=_['intersection'](_0x445d71['model'],qs[_0xbba7('0x3e')](_0x15b481[_0xbba7('0x3b')][_0xbba7('0x3e')]));_0x2c6adb['attributes']=_0x2c6adb['attributes'][_0xbba7('0x40')]?_0x2c6adb[_0xbba7('0x3f')]:_0x445d71[_0xbba7('0x3a')];if(!_0x15b481[_0xbba7('0x3b')][_0xbba7('0x41')](_0xbba7('0x42'))){_0x2c6adb[_0xbba7('0x1f')]=qs[_0xbba7('0x1f')](_0x15b481['query'][_0xbba7('0x1f')]);_0x2c6adb[_0xbba7('0x1e')]=qs['offset'](_0x15b481[_0xbba7('0x3b')]['offset']);}_0x2c6adb[_0xbba7('0x5e')]=qs['sort'](_0x15b481[_0xbba7('0x3b')]['sort']);_0x2c6adb[_0xbba7('0x44')]=qs['filters'](_[_0xbba7('0x45')](_0x15b481[_0xbba7('0x3b')],_0x445d71[_0xbba7('0x3c')]));_0x2c6adb[_0xbba7('0x44')][_0xbba7('0x5f')]=_0x49a9fa['id'];if(_0x15b481[_0xbba7('0x3b')][_0xbba7('0x2b')]){_0x2c6adb[_0xbba7('0x44')]=_[_0xbba7('0x46')](_0x2c6adb['where'],{'$or':_[_0xbba7('0x35')](_0x2c6adb['attributes'],function(_0xa79180){var _0x1a469d={};_0x1a469d[_0xa79180]={'$like':'%'+_0x15b481[_0xbba7('0x3b')][_0xbba7('0x2b')]+'%'};return _0x1a469d;})});}_0x2c6adb=_[_0xbba7('0x46')]({},_0x2c6adb,_0x15b481['options']);return db['CmHopper'][_0xbba7('0x1d')]({'where':_0x2c6adb[_0xbba7('0x44')]})[_0xbba7('0x25')](function(_0xd4272){_0x7c6e98[_0xbba7('0x1d')]=_0xd4272;if(_0x15b481[_0xbba7('0x3b')][_0xbba7('0x49')]){_0x2c6adb[_0xbba7('0x4a')]=[{'all':!![]}];}return db['CmHopper'][_0xbba7('0x60')](_0x2c6adb);})['then'](function(_0x5f455a){_0x7c6e98['rows']=_0x5f455a;return _0x7c6e98;});}})['then'](respondWithFilteredResult(_0x15be33,_0x2c6adb))[_0xbba7('0x4b')](handleError(_0x15be33,null));};exports[_0xbba7('0x61')]=function(_0x4978bf,_0x44d5d6,_0x21003c){var _0x4220cc={'raw':!![],'where':{}};var _0x3ea56b={};var _0x5449a8={'count':0x0,'rows':[]};return db[_0xbba7('0x36')]['findOne']({'where':{'id':_0x4978bf[_0xbba7('0x4d')]['id']}})[_0xbba7('0x25')](handleEntityNotFound(_0x44d5d6,null))['then'](function(_0x4b1508){if(_0x4b1508){_0x3ea56b['model']=_[_0xbba7('0x4e')](db[_0xbba7('0x62')][_0xbba7('0x37')]);_0x3ea56b[_0xbba7('0x3b')]=_[_0xbba7('0x4e')](_0x4978bf[_0xbba7('0x3b')]);_0x3ea56b[_0xbba7('0x3c')]=_[_0xbba7('0x3d')](_0x3ea56b['model'],_0x3ea56b['query']);_0x4220cc[_0xbba7('0x3f')]=_[_0xbba7('0x3d')](_0x3ea56b[_0xbba7('0x3a')],qs[_0xbba7('0x3e')](_0x4978bf['query'][_0xbba7('0x3e')]));_0x4220cc[_0xbba7('0x3f')]=_0x4220cc[_0xbba7('0x3f')][_0xbba7('0x40')]?_0x4220cc['attributes']:_0x3ea56b[_0xbba7('0x3a')];if(!_0x4978bf[_0xbba7('0x3b')][_0xbba7('0x41')]('nolimit')){_0x4220cc[_0xbba7('0x1f')]=qs[_0xbba7('0x1f')](_0x4978bf[_0xbba7('0x3b')][_0xbba7('0x1f')]);_0x4220cc[_0xbba7('0x1e')]=qs[_0xbba7('0x1e')](_0x4978bf[_0xbba7('0x3b')]['offset']);}_0x4220cc[_0xbba7('0x5e')]=qs[_0xbba7('0x43')](_0x4978bf[_0xbba7('0x3b')][_0xbba7('0x43')]);_0x4220cc[_0xbba7('0x44')]=qs[_0xbba7('0x3c')](_['pick'](_0x4978bf[_0xbba7('0x3b')],_0x3ea56b[_0xbba7('0x3c')]));_0x4220cc['where'][_0xbba7('0x5f')]=_0x4b1508['id'];if(_0x4978bf[_0xbba7('0x3b')][_0xbba7('0x2b')]){_0x4220cc['where']=_[_0xbba7('0x46')](_0x4220cc[_0xbba7('0x44')],{'$or':_[_0xbba7('0x35')](_0x4220cc[_0xbba7('0x3f')],function(_0x59d92f){var _0x6b73e6={};_0x6b73e6[_0x59d92f]={'$like':'%'+_0x4978bf[_0xbba7('0x3b')]['filter']+'%'};return _0x6b73e6;})});}_0x4220cc=_[_0xbba7('0x46')]({},_0x4220cc,_0x4978bf['options']);return db[_0xbba7('0x62')]['count']({'where':_0x4220cc[_0xbba7('0x44')]})['then'](function(_0x3173cf){_0x5449a8[_0xbba7('0x1d')]=_0x3173cf;if(_0x4978bf[_0xbba7('0x3b')][_0xbba7('0x49')]){_0x4220cc[_0xbba7('0x4a')]=[{'all':!![]}];}return db[_0xbba7('0x62')][_0xbba7('0x60')](_0x4220cc);})[_0xbba7('0x25')](function(_0x28449c){_0x5449a8['rows']=_0x28449c;return _0x5449a8;});}})[_0xbba7('0x25')](respondWithFilteredResult(_0x44d5d6,_0x4220cc))['catch'](handleError(_0x44d5d6,null));};exports['getHopperFinals']=function(_0x289d74,_0x5ec810,_0x29117d){var _0x45dd2b={'raw':!![],'where':{}};var _0x13ca36={};var _0x18ad02={'count':0x0,'rows':[]};return db[_0xbba7('0x36')][_0xbba7('0x5d')]({'where':{'id':_0x289d74[_0xbba7('0x4d')]['id']}})[_0xbba7('0x25')](handleEntityNotFound(_0x5ec810,null))['then'](function(_0x2e8b86){if(_0x2e8b86){_0x13ca36[_0xbba7('0x3a')]=_[_0xbba7('0x4e')](db[_0xbba7('0x63')][_0xbba7('0x37')]);_0x13ca36['query']=_[_0xbba7('0x4e')](_0x289d74[_0xbba7('0x3b')]);_0x13ca36[_0xbba7('0x3c')]=_[_0xbba7('0x3d')](_0x13ca36['model'],_0x13ca36['query']);_0x45dd2b['attributes']=_[_0xbba7('0x3d')](_0x13ca36[_0xbba7('0x3a')],qs[_0xbba7('0x3e')](_0x289d74[_0xbba7('0x3b')][_0xbba7('0x3e')]));_0x45dd2b['attributes']=_0x45dd2b[_0xbba7('0x3f')]['length']?_0x45dd2b[_0xbba7('0x3f')]:_0x13ca36[_0xbba7('0x3a')];if(!_0x289d74[_0xbba7('0x3b')][_0xbba7('0x41')](_0xbba7('0x42'))){_0x45dd2b[_0xbba7('0x1f')]=qs['limit'](_0x289d74['query'][_0xbba7('0x1f')]);_0x45dd2b[_0xbba7('0x1e')]=qs[_0xbba7('0x1e')](_0x289d74[_0xbba7('0x3b')][_0xbba7('0x1e')]);}_0x45dd2b[_0xbba7('0x5e')]=qs['sort'](_0x289d74[_0xbba7('0x3b')][_0xbba7('0x43')]);_0x45dd2b[_0xbba7('0x44')]=qs[_0xbba7('0x3c')](_[_0xbba7('0x45')](_0x289d74[_0xbba7('0x3b')],_0x13ca36['filters']));_0x45dd2b['where'][_0xbba7('0x5f')]=_0x2e8b86['id'];if(_0x289d74[_0xbba7('0x3b')]['filter']){_0x45dd2b['where']=_[_0xbba7('0x46')](_0x45dd2b['where'],{'$or':_[_0xbba7('0x35')](_0x45dd2b['attributes'],function(_0x3358dd){var _0x276f8a={};_0x276f8a[_0x3358dd]={'$like':'%'+_0x289d74['query'][_0xbba7('0x2b')]+'%'};return _0x276f8a;})});}_0x45dd2b=_['merge']({},_0x45dd2b,_0x289d74[_0xbba7('0x48')]);return db[_0xbba7('0x63')][_0xbba7('0x1d')]({'where':_0x45dd2b[_0xbba7('0x44')]})[_0xbba7('0x25')](function(_0x995db5){_0x18ad02[_0xbba7('0x1d')]=_0x995db5;if(_0x289d74[_0xbba7('0x3b')]['includeAll']){_0x45dd2b[_0xbba7('0x4a')]=[{'all':!![]}];}return db['CmHopperFinal'][_0xbba7('0x60')](_0x45dd2b);})[_0xbba7('0x25')](function(_0x58afcf){_0x18ad02['rows']=_0x58afcf;return _0x18ad02;});}})[_0xbba7('0x25')](respondWithFilteredResult(_0x5ec810,_0x45dd2b))[_0xbba7('0x4b')](handleError(_0x5ec810,null));};exports['getHopperBlacks']=function(_0x4b3ffc,_0x44ac73,_0x16fd2e){var _0x4fc306={'raw':!![],'where':{}};var _0x2f3ae1={};var _0x2537ef={'count':0x0,'rows':[]};return db[_0xbba7('0x36')]['findOne']({'where':{'id':_0x4b3ffc[_0xbba7('0x4d')]['id']}})[_0xbba7('0x25')](handleEntityNotFound(_0x44ac73,null))[_0xbba7('0x25')](function(_0x2b1544){if(_0x2b1544){_0x2f3ae1[_0xbba7('0x3a')]=_[_0xbba7('0x4e')](db[_0xbba7('0x64')][_0xbba7('0x37')]);_0x2f3ae1[_0xbba7('0x3b')]=_[_0xbba7('0x4e')](_0x4b3ffc[_0xbba7('0x3b')]);_0x2f3ae1[_0xbba7('0x3c')]=_[_0xbba7('0x3d')](_0x2f3ae1[_0xbba7('0x3a')],_0x2f3ae1[_0xbba7('0x3b')]);_0x4fc306[_0xbba7('0x3f')]=_['intersection'](_0x2f3ae1[_0xbba7('0x3a')],qs[_0xbba7('0x3e')](_0x4b3ffc['query']['fields']));_0x4fc306[_0xbba7('0x3f')]=_0x4fc306['attributes'][_0xbba7('0x40')]?_0x4fc306[_0xbba7('0x3f')]:_0x2f3ae1[_0xbba7('0x3a')];if(!_0x4b3ffc[_0xbba7('0x3b')][_0xbba7('0x41')](_0xbba7('0x42'))){_0x4fc306[_0xbba7('0x1f')]=qs[_0xbba7('0x1f')](_0x4b3ffc[_0xbba7('0x3b')]['limit']);_0x4fc306[_0xbba7('0x1e')]=qs[_0xbba7('0x1e')](_0x4b3ffc['query'][_0xbba7('0x1e')]);}_0x4fc306[_0xbba7('0x5e')]=qs[_0xbba7('0x43')](_0x4b3ffc[_0xbba7('0x3b')]['sort']);_0x4fc306[_0xbba7('0x44')]=qs[_0xbba7('0x3c')](_[_0xbba7('0x45')](_0x4b3ffc[_0xbba7('0x3b')],_0x2f3ae1[_0xbba7('0x3c')]));_0x4fc306[_0xbba7('0x44')][_0xbba7('0x5f')]=_0x2b1544['id'];if(_0x4b3ffc[_0xbba7('0x3b')][_0xbba7('0x2b')]){_0x4fc306['where']=_[_0xbba7('0x46')](_0x4fc306[_0xbba7('0x44')],{'$or':_[_0xbba7('0x35')](_0x4fc306[_0xbba7('0x3f')],function(_0x486d80){var _0x296f0c={};_0x296f0c[_0x486d80]={'$like':'%'+_0x4b3ffc[_0xbba7('0x3b')][_0xbba7('0x2b')]+'%'};return _0x296f0c;})});}_0x4fc306=_['merge']({},_0x4fc306,_0x4b3ffc[_0xbba7('0x48')]);return db[_0xbba7('0x64')][_0xbba7('0x1d')]({'where':_0x4fc306[_0xbba7('0x44')]})['then'](function(_0x27436f){_0x2537ef[_0xbba7('0x1d')]=_0x27436f;if(_0x4b3ffc[_0xbba7('0x3b')][_0xbba7('0x49')]){_0x4fc306[_0xbba7('0x4a')]=[{'all':!![]}];}return db['CmHopperBlack'][_0xbba7('0x60')](_0x4fc306);})['then'](function(_0x49f63b){_0x2537ef['rows']=_0x49f63b;return _0x2537ef;});}})[_0xbba7('0x25')](respondWithFilteredResult(_0x44ac73,_0x4fc306))[_0xbba7('0x4b')](handleError(_0x44ac73,null));};exports[_0xbba7('0x65')]=function(_0x21d592,_0x559c39,_0x479907){var _0xbb8417={};var _0x4bfb53={};var _0x4bd371;var _0x1d60cc;return db[_0xbba7('0x36')]['findOne']({'where':{'id':_0x21d592[_0xbba7('0x4d')]['id']}})[_0xbba7('0x25')](handleEntityNotFound(_0x559c39,null))['then'](function(_0x5a4453){if(_0x5a4453){_0x4bd371=_0x5a4453;_0x4bfb53[_0xbba7('0x3a')]=_[_0xbba7('0x4e')](db[_0xbba7('0x66')][_0xbba7('0x37')]);_0x4bfb53[_0xbba7('0x3b')]=_[_0xbba7('0x4e')](_0x21d592[_0xbba7('0x3b')]);_0x4bfb53[_0xbba7('0x3c')]=_[_0xbba7('0x3d')](_0x4bfb53[_0xbba7('0x3a')],_0x4bfb53[_0xbba7('0x3b')]);_0xbb8417[_0xbba7('0x3f')]=_[_0xbba7('0x3d')](_0x4bfb53['model'],qs[_0xbba7('0x3e')](_0x21d592[_0xbba7('0x3b')][_0xbba7('0x3e')]));_0xbb8417['attributes']=_0xbb8417[_0xbba7('0x3f')][_0xbba7('0x40')]?_0xbb8417[_0xbba7('0x3f')]:_0x4bfb53[_0xbba7('0x3a')];_0xbb8417[_0xbba7('0x5e')]=qs[_0xbba7('0x43')](_0x21d592[_0xbba7('0x3b')][_0xbba7('0x43')]);_0xbb8417[_0xbba7('0x44')]=qs['filters'](_['pick'](_0x21d592['query'],_0x4bfb53[_0xbba7('0x3c')]));if(_0x21d592['query'][_0xbba7('0x2b')]){_0xbb8417['where']=_[_0xbba7('0x46')](_0xbb8417[_0xbba7('0x44')],{'$or':_['map'](_0xbb8417[_0xbba7('0x3f')],function(_0x1195cf){var _0x1f3419={};_0x1f3419[_0x1195cf]={'$like':'%'+_0x21d592[_0xbba7('0x3b')]['filter']+'%'};return _0x1f3419;})});}_0xbb8417=_[_0xbba7('0x46')]({},_0xbb8417,_0x21d592[_0xbba7('0x48')]);return _0x4bd371[_0xbba7('0x65')](_0xbb8417);}})[_0xbba7('0x25')](function(_0x259c6c){if(_0x259c6c){_0x1d60cc=_0x259c6c['length'];if(!_0x21d592[_0xbba7('0x3b')][_0xbba7('0x41')](_0xbba7('0x42'))){_0xbb8417[_0xbba7('0x1f')]=qs[_0xbba7('0x1f')](_0x21d592[_0xbba7('0x3b')][_0xbba7('0x1f')]);_0xbb8417['offset']=qs[_0xbba7('0x1e')](_0x21d592[_0xbba7('0x3b')][_0xbba7('0x1e')]);}return _0x4bd371['getTeams'](_0xbb8417);}})[_0xbba7('0x25')](function(_0x2ea579){if(_0x2ea579){return _0x2ea579?{'count':_0x1d60cc,'rows':_0x2ea579}:null;}})[_0xbba7('0x25')](respondWithResult(_0x559c39,null))[_0xbba7('0x4b')](handleError(_0x559c39,null));};exports[_0xbba7('0x67')]=function(_0x3471eb,_0x31086b,_0x507a5f){var _0x1bbe93=_0x3471eb[_0xbba7('0x50')][_0xbba7('0x68')];var _0x4ce0fa=_[_0xbba7('0x35')](_0x1bbe93,'id');return db[_0xbba7('0x66')]['findAll']({'where':{'id':_0x4ce0fa},'attributes':['id'],'include':[{'model':db['User'],'as':_0xbba7('0x69'),'attributes':['id','name',_0xbba7('0x6a'),_0xbba7('0x6b'),'interface'],'raw':!![]}]})[_0xbba7('0x25')](function(_0x573c08){if(_0x573c08){var _0x344784=_['flatMap'](_0x573c08,function(_0x4a98b9){var _0x2bad79=_0x4a98b9[_0xbba7('0x26')]({'plain':!![]});_0x2bad79[_0xbba7('0x69')][_0xbba7('0x6c')](function(_0x1aebb0){_0x1aebb0[_0xbba7('0x6d')]=_[_0xbba7('0x2f')](_0x1bbe93,{'id':_0x2bad79['id']})[_0xbba7('0x6d')];});return _0x2bad79[_0xbba7('0x69')];});return db[_0xbba7('0x36')]['find']({'where':{'id':_0x3471eb[_0xbba7('0x4d')]['id']}})[_0xbba7('0x25')](function(_0x2ec672){return db[_0xbba7('0x6e')]['transaction'](function(_0x4665b5){return _0x2ec672[_0xbba7('0x67')](_0x4ce0fa,{'transaction':_0x4665b5})[_0xbba7('0x25')](function(){return BPromise['each'](_0x344784,function(_0x986dd9){return db[_0xbba7('0x6f')]['findOrCreate']({'where':{'UserId':_0x986dd9['id'],'VoiceQueueId':_0x3471eb[_0xbba7('0x4d')]['id']},'defaults':{'penalty':_0x986dd9[_0xbba7('0x6d')]},'transaction':_0x4665b5});});})[_0xbba7('0x25')](function(){return BPromise[_0xbba7('0x70')](_[_0xbba7('0x2b')](_0x344784,{'online':!![]}),function(_0x42f758){return db[_0xbba7('0x71')][_0xbba7('0x72')]({'membername':_0x42f758[_0xbba7('0x32')],'UserId':_0x42f758['id'],'queue_name':_0x2ec672[_0xbba7('0x32')],'VoiceQueueId':_0x2ec672['id'],'interface':_[_0xbba7('0x73')](_0x42f758[_0xbba7('0x74')])?util[_0xbba7('0x75')]('SIP/%s',_0x42f758['name']):_0x42f758[_0xbba7('0x74')],'paused':_0x42f758[_0xbba7('0x6b')]||![],'penalty':_0x42f758['penalty']},{'transaction':_0x4665b5});});})['then'](function(){_0x344784[_0xbba7('0x6c')](function(_0x59220e){socket['emit'](_0xbba7('0x76'),{'UserId':_0x59220e['id'],'VoiceQueueId':_0x2ec672['id']});});});});});}})[_0xbba7('0x25')](respondWithStatusCode(_0x31086b,null))[_0xbba7('0x4b')](handleError(_0x31086b,null));};exports[_0xbba7('0x77')]=function(_0xb971e1,_0x1b042d,_0x14c344){return db[_0xbba7('0x66')][_0xbba7('0x60')]({'where':{'id':_0xb971e1[_0xbba7('0x3b')]['ids']},'attributes':['id'],'include':[{'model':db[_0xbba7('0x78')],'as':_0xbba7('0x69'),'attributes':['id'],'raw':!![]}]})['then'](handleEntityNotFound(_0x1b042d,null))[_0xbba7('0x25')](function(_0x2f3af2){var _0x398da9=_[_0xbba7('0x35')](_0x2f3af2,'id');var _0x517586=[];var _0x36d06f=[];var _0x548aff=squel['select']();_0x548aff[_0xbba7('0x79')]('tq.TeamId')[_0xbba7('0x7a')](_0xbba7('0x7b'),'tq')['join'](_0xbba7('0x7c'),'ut','ut.TeamId\x20=\x20tq.TeamId')[_0xbba7('0x44')]('VoiceQueueId\x20=\x20?',_0xb971e1[_0xbba7('0x4d')]['id']);for(var _0x1e7712=0x0;_0x1e7712<_0x2f3af2[_0xbba7('0x40')];_0x1e7712+=0x1){let _0x4d43e5=_0x2f3af2[_0x1e7712];for(var _0x5338c7=0x0;_0x5338c7<_0x4d43e5['Agents'][_0xbba7('0x40')];_0x5338c7+=0x1){let _0x382064=_0x4d43e5[_0xbba7('0x69')][_0x5338c7];var _0x9497e3=_0x548aff['clone']();_0x9497e3[_0xbba7('0x44')](_0xbba7('0x7d'),_0x382064['id']);_0x36d06f[_0xbba7('0x7e')](db[_0xbba7('0x6e')]['query'](_0x9497e3[_0xbba7('0x7f')](),{'type':db[_0xbba7('0x6e')][_0xbba7('0x80')][_0xbba7('0x81')]})[_0xbba7('0x25')](function(_0x1b7427){if(_0x1b7427['length']===0x1){return _0x382064['id'];}else{var _0x19388b=_[_0xbba7('0x82')](_[_0xbba7('0x35')](_0x1b7427,_0xbba7('0x83')),function(_0xc34cbb){return _['includes'](_0x398da9,_0xc34cbb);});if(_0x19388b){return _0x382064['id'];}}}));}}return BPromise[_0xbba7('0x84')](_0x36d06f)[_0xbba7('0x25')](function(_0x4bedac){_0x517586=_(_0x517586)[_0xbba7('0x85')](_0x4bedac)[_0xbba7('0x86')]()[_0xbba7('0x2d')]();return db[_0xbba7('0x36')][_0xbba7('0x2f')]({'where':{'id':_0xb971e1[_0xbba7('0x4d')]['id']}})[_0xbba7('0x25')](function(_0x284925){return db['sequelize']['transaction'](function(_0x3952df){return _0x284925[_0xbba7('0x77')](_0xb971e1[_0xbba7('0x3b')][_0xbba7('0x87')],{'transaction':_0x3952df})['then'](function(){if(!_[_0xbba7('0x88')](_0x517586)){return _0x284925['removeAgents'](_0x517586,{'transaction':_0x3952df})[_0xbba7('0x25')](function(){return db['UserVoiceQueueRt'][_0xbba7('0x24')]({'where':{'VoiceQueueId':_0xb971e1[_0xbba7('0x4d')]['id'],'UserId':_0x517586},'transaction':_0x3952df});});}})[_0xbba7('0x25')](function(){_0x517586[_0xbba7('0x6c')](function(_0x161d1a){socket[_0xbba7('0x89')](_0xbba7('0x8a'),{'UserId':_0x161d1a,'VoiceQueueId':_0x284925['id']});});});});});});})['then'](respondWithStatusCode(_0x1b042d,null))['catch'](handleError(_0x1b042d,null));};exports['addAgents']=function(_0x38154d,_0x7109ff,_0x102a2f){var _0x9c9e43,_0x24bee9;return db[_0xbba7('0x36')][_0xbba7('0x2f')]({'where':{'id':_0x38154d[_0xbba7('0x4d')]['id']}})[_0xbba7('0x25')](handleEntityNotFound(_0x7109ff,null))[_0xbba7('0x25')](function(_0x5b86fd){if(_0x5b86fd){_0x24bee9=_0x5b86fd;return _0x5b86fd['addAgents'](_0x38154d[_0xbba7('0x50')][_0xbba7('0x87')],_[_0xbba7('0x58')](_0x38154d[_0xbba7('0x50')],[_0xbba7('0x87'),'id'])||{})[_0xbba7('0x8b')](function(_0x4a5a29){for(var _0x446e49=0x0;_0x446e49<_0x38154d[_0xbba7('0x50')][_0xbba7('0x87')][_0xbba7('0x40')];_0x446e49+=0x1){socket[_0xbba7('0x89')](_0xbba7('0x76'),{'UserId':_0x38154d[_0xbba7('0x50')][_0xbba7('0x87')][_0x446e49],'VoiceQueueId':_0x38154d['params']['id']});}return _0x4a5a29;});}})[_0xbba7('0x25')](function(_0x4d9e7a){_0x9c9e43=_0x4d9e7a||[];if(_0x24bee9){return db[_0xbba7('0x78')][_0xbba7('0x60')]({'where':{'id':_0x38154d[_0xbba7('0x50')][_0xbba7('0x87')]},'attributes':['id',_0xbba7('0x32'),_0xbba7('0x6a'),_0xbba7('0x6b'),'interface'],'raw':!![]});}})[_0xbba7('0x25')](function(_0x5f37b9){if(!_[_0xbba7('0x88')](_0x5f37b9)){var _0x31b801=[];for(var _0x44da01=0x0;_0x44da01<_0x5f37b9[_0xbba7('0x40')];_0x44da01++){if(_0x5f37b9[_0x44da01]['online']){_0x31b801[_0xbba7('0x7e')](db[_0xbba7('0x71')]['upsert']({'membername':_0x5f37b9[_0x44da01][_0xbba7('0x32')],'UserId':_0x5f37b9[_0x44da01]['id'],'queue_name':_0x24bee9[_0xbba7('0x32')],'VoiceQueueId':_0x24bee9['id'],'interface':_[_0xbba7('0x73')](_0x5f37b9[_0x44da01][_0xbba7('0x74')])?util['format']('SIP/%s',_0x5f37b9[_0x44da01][_0xbba7('0x32')]):_0x5f37b9[_0x44da01][_0xbba7('0x74')],'paused':_0x5f37b9[_0x44da01][_0xbba7('0x6b')]||![],'penalty':_0x38154d[_0xbba7('0x50')][_0xbba7('0x6d')]||0x0}));}}return BPromise[_0xbba7('0x84')](_0x31b801);}})[_0xbba7('0x25')](function(){return _0x9c9e43;})[_0xbba7('0x25')](respondWithResult(_0x7109ff,null))[_0xbba7('0x4b')](handleError(_0x7109ff,null));};exports['removeAgents']=function(_0x3e4721,_0x77761a,_0x29477e){return db[_0xbba7('0x36')][_0xbba7('0x2f')]({'where':{'id':_0x3e4721['params']['id']}})[_0xbba7('0x25')](handleEntityNotFound(_0x77761a,null))[_0xbba7('0x25')](function(_0x5af599){if(_0x5af599){return _0x5af599[_0xbba7('0x8c')](_0x3e4721['query'][_0xbba7('0x87')])[_0xbba7('0x25')](function(){if(_[_0xbba7('0x8d')](_0x3e4721[_0xbba7('0x3b')][_0xbba7('0x87')])){for(var _0x240b62=0x0;_0x240b62<_0x3e4721[_0xbba7('0x3b')]['ids'][_0xbba7('0x40')];_0x240b62+=0x1){socket[_0xbba7('0x89')]('userVoiceQueue:remove',{'UserId':Number(_0x3e4721['query']['ids'][_0x240b62]),'VoiceQueueId':Number(_0x3e4721[_0xbba7('0x4d')]['id'])});}}else{socket['emit'](_0xbba7('0x8a'),{'UserId':Number(_0x3e4721[_0xbba7('0x3b')][_0xbba7('0x87')]),'VoiceQueueId':Number(_0x3e4721[_0xbba7('0x4d')]['id'])});}});}})[_0xbba7('0x25')](function(_0x24f1eb){return db[_0xbba7('0x71')][_0xbba7('0x24')]({'where':{'VoiceQueueId':_0x3e4721[_0xbba7('0x4d')]['id'],'UserId':_0x3e4721[_0xbba7('0x3b')][_0xbba7('0x87')]}})[_0xbba7('0x25')](function(){return _0x24f1eb;});})['then'](respondWithStatusCode(_0x77761a,null))[_0xbba7('0x4b')](handleError(_0x77761a,null));};exports[_0xbba7('0x8e')]=function(_0x5edf25,_0x50fb9e,_0x477f49){var _0x3db87d={};var _0x181c00={};var _0x3a6e86;var _0x2030f7;return db[_0xbba7('0x36')][_0xbba7('0x5d')]({'where':{'id':_0x5edf25[_0xbba7('0x4d')]['id']}})[_0xbba7('0x25')](handleEntityNotFound(_0x50fb9e,null))[_0xbba7('0x25')](function(_0x1ee7a5){if(_0x1ee7a5){_0x3a6e86=_0x1ee7a5;_0x181c00[_0xbba7('0x3a')]=_[_0xbba7('0x4e')](db['User'][_0xbba7('0x37')]);_0x181c00[_0xbba7('0x3b')]=_['keys'](_0x5edf25[_0xbba7('0x3b')]);_0x181c00[_0xbba7('0x3c')]=_[_0xbba7('0x3d')](_0x181c00[_0xbba7('0x3a')],_0x181c00[_0xbba7('0x3b')]);_0x3db87d[_0xbba7('0x3f')]=_[_0xbba7('0x3d')](_0x181c00[_0xbba7('0x3a')],qs[_0xbba7('0x3e')](_0x5edf25[_0xbba7('0x3b')][_0xbba7('0x3e')]));_0x3db87d[_0xbba7('0x3f')]=_0x3db87d[_0xbba7('0x3f')][_0xbba7('0x40')]?_0x3db87d[_0xbba7('0x3f')]:_0x181c00[_0xbba7('0x3a')];_0x3db87d['order']=qs[_0xbba7('0x43')](_0x5edf25[_0xbba7('0x3b')][_0xbba7('0x43')]);_0x3db87d['where']=qs['filters'](_[_0xbba7('0x45')](_0x5edf25[_0xbba7('0x3b')],_0x181c00['filters']));if(_0x5edf25[_0xbba7('0x3b')][_0xbba7('0x2b')]){_0x3db87d[_0xbba7('0x44')]=_[_0xbba7('0x46')](_0x3db87d[_0xbba7('0x44')],{'$or':_['map'](_0x3db87d[_0xbba7('0x3f')],function(_0x12ea3a){var _0x5ad121={};_0x5ad121[_0x12ea3a]={'$like':'%'+_0x5edf25['query']['filter']+'%'};return _0x5ad121;})});}_0x3db87d=_[_0xbba7('0x46')]({},_0x3db87d,_0x5edf25[_0xbba7('0x48')]);return _0x3a6e86[_0xbba7('0x8e')](_0x3db87d);}})[_0xbba7('0x25')](function(_0x346f44){if(_0x346f44){_0x2030f7=_0x346f44[_0xbba7('0x40')];if(!_0x5edf25[_0xbba7('0x3b')]['hasOwnProperty'](_0xbba7('0x42'))){_0x3db87d['limit']=qs[_0xbba7('0x1f')](_0x5edf25[_0xbba7('0x3b')][_0xbba7('0x1f')]);_0x3db87d[_0xbba7('0x1e')]=qs[_0xbba7('0x1e')](_0x5edf25[_0xbba7('0x3b')][_0xbba7('0x1e')]);}return _0x3a6e86[_0xbba7('0x8e')](_0x3db87d);}})[_0xbba7('0x25')](function(_0x360d60){if(_0x360d60){return _0x360d60?{'count':_0x2030f7,'rows':_0x360d60}:null;}})[_0xbba7('0x25')](respondWithResult(_0x50fb9e,null))[_0xbba7('0x4b')](handleError(_0x50fb9e,null));};exports[_0xbba7('0x8f')]=function(_0x3c233c,_0x1cedbb,_0x5dca58){var _0x25d760={};var _0x510e3d={};var _0x20cd05;var _0x59d166;return db[_0xbba7('0x36')]['findOne']({'where':{'id':_0x3c233c[_0xbba7('0x4d')]['id']}})[_0xbba7('0x25')](handleEntityNotFound(_0x1cedbb,null))[_0xbba7('0x25')](function(_0x1b7753){if(_0x1b7753){_0x20cd05=_0x1b7753;_0x510e3d[_0xbba7('0x3a')]=_['keys'](db[_0xbba7('0x71')][_0xbba7('0x37')]);_0x510e3d[_0xbba7('0x3b')]=_[_0xbba7('0x4e')](_0x3c233c[_0xbba7('0x3b')]);_0x510e3d[_0xbba7('0x3c')]=_[_0xbba7('0x3d')](_0x510e3d[_0xbba7('0x3a')],_0x510e3d['query']);_0x25d760[_0xbba7('0x3f')]=_['intersection'](_0x510e3d[_0xbba7('0x3a')],qs[_0xbba7('0x3e')](_0x3c233c[_0xbba7('0x3b')][_0xbba7('0x3e')]));_0x25d760[_0xbba7('0x3f')]=_0x25d760[_0xbba7('0x3f')][_0xbba7('0x40')]?_0x25d760[_0xbba7('0x3f')]:_0x510e3d[_0xbba7('0x3a')];_0x25d760[_0xbba7('0x5e')]=qs['sort'](_0x3c233c[_0xbba7('0x3b')][_0xbba7('0x43')]);_0x25d760[_0xbba7('0x44')]=qs['filters'](_[_0xbba7('0x45')](_0x3c233c[_0xbba7('0x3b')],_0x510e3d['filters']));if(_0x3c233c['query']['filter']){_0x25d760[_0xbba7('0x44')]=_[_0xbba7('0x46')](_0x25d760[_0xbba7('0x44')],{'$or':_[_0xbba7('0x35')](_0x25d760['attributes'],function(_0x21a093){var _0x14ea74={};_0x14ea74[_0x21a093]={'$like':'%'+_0x3c233c['query']['filter']+'%'};return _0x14ea74;})});}_0x25d760=_[_0xbba7('0x46')]({},_0x25d760,_0x3c233c[_0xbba7('0x48')]);return _0x20cd05[_0xbba7('0x8f')](_0x25d760);}})[_0xbba7('0x25')](function(_0x319796){if(_0x319796){_0x59d166=_0x319796[_0xbba7('0x40')];if(!_0x3c233c[_0xbba7('0x3b')][_0xbba7('0x41')](_0xbba7('0x42'))){_0x25d760[_0xbba7('0x1f')]=qs[_0xbba7('0x1f')](_0x3c233c['query']['limit']);_0x25d760[_0xbba7('0x1e')]=qs[_0xbba7('0x1e')](_0x3c233c[_0xbba7('0x3b')][_0xbba7('0x1e')]);}return _0x20cd05[_0xbba7('0x8f')](_0x25d760);}})[_0xbba7('0x25')](function(_0x3833f7){return _0x3833f7?{'count':_0x59d166,'rows':_0x3833f7}:null;})[_0xbba7('0x25')](respondWithResult(_0x1cedbb,null))[_0xbba7('0x4b')](handleError(_0x1cedbb,null));};exports[_0xbba7('0x90')]=function(_0x3fc090,_0x5c841f,_0x254a78){var _0x12aa34={};var _0x46f5ab={};var _0x31a6d7;var _0xe14365;return db['VoiceQueue']['findOne']({'where':{'id':_0x3fc090['params']['id']}})[_0xbba7('0x25')](handleEntityNotFound(_0x5c841f,null))[_0xbba7('0x25')](function(_0x56b513){if(_0x56b513){_0x31a6d7=_0x56b513;_0x46f5ab['model']=_[_0xbba7('0x4e')](db['CmList'][_0xbba7('0x37')]);_0x46f5ab[_0xbba7('0x3b')]=_[_0xbba7('0x4e')](_0x3fc090[_0xbba7('0x3b')]);_0x46f5ab[_0xbba7('0x3c')]=_[_0xbba7('0x3d')](_0x46f5ab[_0xbba7('0x3a')],_0x46f5ab[_0xbba7('0x3b')]);_0x12aa34['attributes']=_[_0xbba7('0x3d')](_0x46f5ab[_0xbba7('0x3a')],qs[_0xbba7('0x3e')](_0x3fc090[_0xbba7('0x3b')][_0xbba7('0x3e')]));_0x12aa34['attributes']=_0x12aa34['attributes'][_0xbba7('0x40')]?_0x12aa34[_0xbba7('0x3f')]:_0x46f5ab[_0xbba7('0x3a')];_0x12aa34[_0xbba7('0x5e')]=qs[_0xbba7('0x43')](_0x3fc090[_0xbba7('0x3b')]['sort']);_0x12aa34[_0xbba7('0x44')]=qs[_0xbba7('0x3c')](_[_0xbba7('0x45')](_0x3fc090[_0xbba7('0x3b')],_0x46f5ab[_0xbba7('0x3c')]));if(_0x3fc090[_0xbba7('0x3b')]['filter']){_0x12aa34[_0xbba7('0x44')]=_[_0xbba7('0x46')](_0x12aa34[_0xbba7('0x44')],{'$or':_['map'](_0x12aa34[_0xbba7('0x3f')],function(_0xaa152){var _0xa77c92={};_0xa77c92[_0xaa152]={'$like':'%'+_0x3fc090['query'][_0xbba7('0x2b')]+'%'};return _0xa77c92;})});}_0x12aa34=_['merge']({},_0x12aa34,_0x3fc090['options']);return _0x31a6d7[_0xbba7('0x90')](_0x12aa34);}})[_0xbba7('0x25')](function(_0x3f7056){if(_0x3f7056){_0xe14365=_0x3f7056[_0xbba7('0x40')];if(!_0x3fc090[_0xbba7('0x3b')][_0xbba7('0x41')](_0xbba7('0x42'))){_0x12aa34[_0xbba7('0x1f')]=qs[_0xbba7('0x1f')](_0x3fc090[_0xbba7('0x3b')]['limit']);_0x12aa34[_0xbba7('0x1e')]=qs[_0xbba7('0x1e')](_0x3fc090[_0xbba7('0x3b')][_0xbba7('0x1e')]);}return _0x31a6d7[_0xbba7('0x90')](_0x12aa34);}})['then'](function(_0x1a4eb1){if(_0x1a4eb1){return _0x1a4eb1?{'count':_0xe14365,'rows':_0x1a4eb1}:null;}})[_0xbba7('0x25')](respondWithResult(_0x5c841f,null))['catch'](handleError(_0x5c841f,null));};exports[_0xbba7('0x91')]=function(_0x282ec1,_0x3aed5c,_0x2023cf){var _0x4cae14,_0x201236;return db['VoiceQueue']['find']({'where':{'id':_0x282ec1['params']['id']}})[_0xbba7('0x25')](handleEntityNotFound(_0x3aed5c,null))['then'](function(_0x5631a3){if(_0x5631a3){_0x201236=_0x5631a3;return _0x5631a3['addLists'](_0x282ec1['body'][_0xbba7('0x87')],_['omit'](_0x282ec1[_0xbba7('0x50')],['ids','id'])||{});}return null;})['spread'](function(_0x31272f){var _0x319807;_0x4cae14=_0x31272f||[];var _0x310401=[];if(_0x31272f){for(var _0x686933=0x0;_0x686933<_0x31272f[_0xbba7('0x40')];_0x686933+=0x1){var _0x1efc9b=_0x31272f[_0x686933]['get']({'plain':!![]});_0x201236[_0xbba7('0x92')]=_0x282ec1[_0xbba7('0x50')]['dialCheckDuplicateType']?_0x282ec1[_0xbba7('0x50')][_0xbba7('0x92')]:_0x201236[_0xbba7('0x92')];switch(_0x201236[_0xbba7('0x92')]){case _0xbba7('0x93'):_0x319807=squel[_0xbba7('0x94')]()[_0xbba7('0x95')](_0xbba7('0x96'))['fromQuery']([_0xbba7('0x97'),_0xbba7('0x98'),'ContactId','ListId',_0xbba7('0x5f'),_0xbba7('0x59'),'updatedAt'],squel[_0xbba7('0x99')]()[_0xbba7('0x79')]('phone','phone')[_0xbba7('0x79')](_0xbba7('0x9a'),_0xbba7('0x98'))[_0xbba7('0x79')]('id',_0xbba7('0x9b'))[_0xbba7('0x79')](_0x1efc9b[_0xbba7('0x9c')][_0xbba7('0x7f')](),_0xbba7('0x9d'))[_0xbba7('0x79')](_0x282ec1['params']['id']['toString'](),'VoiceQueueId')[_0xbba7('0x79')](_0xbba7('0x9a'),_0xbba7('0x59'))['field'](_0xbba7('0x9a'),_0xbba7('0x5a'))[_0xbba7('0x7a')](_0xbba7('0x9e'))[_0xbba7('0x44')]('deletedAt\x20IS\x20NULL')[_0xbba7('0x44')](_0xbba7('0x9f'),_0x1efc9b[_0xbba7('0x9c')][_0xbba7('0x7f')]())[_0xbba7('0x44')](_0xbba7('0xa0'))[_0xbba7('0x44')](_0xbba7('0xa1'),squel[_0xbba7('0x99')]()['field']('COALESCE(calleridnum,\x27\x27)')[_0xbba7('0x7a')](_0xbba7('0xa2'))[_0xbba7('0x44')](_0xbba7('0xa3'),_0x282ec1[_0xbba7('0x4d')]['id'][_0xbba7('0x7f')]()))[_0xbba7('0x44')]('phone\x20NOT\x20IN\x20(?)',squel[_0xbba7('0x99')]()[_0xbba7('0x79')](_0xbba7('0xa4'))[_0xbba7('0x7a')](_0xbba7('0x96'))[_0xbba7('0x44')](_0xbba7('0xa3'),_0x282ec1[_0xbba7('0x4d')]['id'][_0xbba7('0x7f')]())))[_0xbba7('0x7f')]();break;case _0xbba7('0xa5'):_0x319807=squel['insert']()['into'](_0xbba7('0x96'))[_0xbba7('0xa6')]([_0xbba7('0x97'),_0xbba7('0x98'),_0xbba7('0x9b'),'ListId','VoiceQueueId',_0xbba7('0x59'),_0xbba7('0x5a')],squel[_0xbba7('0x99')]()[_0xbba7('0x79')](_0xbba7('0x97'),_0xbba7('0x97'))[_0xbba7('0x79')](_0xbba7('0x9a'),'scheduledAt')[_0xbba7('0x79')]('id',_0xbba7('0x9b'))['field'](_0x1efc9b[_0xbba7('0x9c')][_0xbba7('0x7f')](),'ListId')[_0xbba7('0x79')](_0x282ec1[_0xbba7('0x4d')]['id']['toString'](),_0xbba7('0x5f'))[_0xbba7('0x79')](_0xbba7('0x9a'),'createdAt')[_0xbba7('0x79')](_0xbba7('0x9a'),'updatedAt')['from'](_0xbba7('0x9e'))[_0xbba7('0x44')]('deletedAt\x20IS\x20NULL')['where'](_0xbba7('0x9f'),_0x1efc9b[_0xbba7('0x9c')]['toString']())[_0xbba7('0x44')](_0xbba7('0xa0'))[_0xbba7('0x44')](_0xbba7('0xa1'),squel[_0xbba7('0x99')]()[_0xbba7('0x79')](_0xbba7('0xa4'))[_0xbba7('0x7a')](_0xbba7('0x96'))['where'](_0xbba7('0xa3'),_0x282ec1[_0xbba7('0x4d')]['id'][_0xbba7('0x7f')]())))['toString']();break;default:_0x319807=squel[_0xbba7('0x94')]()[_0xbba7('0x95')](_0xbba7('0x96'))[_0xbba7('0xa6')]([_0xbba7('0x97'),_0xbba7('0x98'),_0xbba7('0x9b'),'ListId',_0xbba7('0x5f'),_0xbba7('0x59'),_0xbba7('0x5a')],squel[_0xbba7('0x99')]()[_0xbba7('0x79')](_0xbba7('0x97'),_0xbba7('0x97'))['field'](_0xbba7('0x9a'),_0xbba7('0x98'))[_0xbba7('0x79')]('id',_0xbba7('0x9b'))[_0xbba7('0x79')](_0x1efc9b[_0xbba7('0x9c')]['toString'](),_0xbba7('0x9d'))[_0xbba7('0x79')](_0x282ec1[_0xbba7('0x4d')]['id'][_0xbba7('0x7f')](),'VoiceQueueId')['field']('NOW()',_0xbba7('0x59'))[_0xbba7('0x79')]('NOW()','updatedAt')[_0xbba7('0x7a')](_0xbba7('0x9e'))[_0xbba7('0x44')](_0xbba7('0xa7'))[_0xbba7('0x44')](_0xbba7('0x9f'),_0x1efc9b[_0xbba7('0x9c')][_0xbba7('0x7f')]())['where'](_0xbba7('0xa0')))['toString']();}_0x310401[_0xbba7('0x7e')](db['sequelize'][_0xbba7('0x3b')](_0x319807));}return BPromise[_0xbba7('0x84')](_0x310401);}})[_0xbba7('0x25')](function(){return _0x4cae14;})[_0xbba7('0x25')](respondWithResult(_0x3aed5c,null))['catch'](handleError(_0x3aed5c,null));};exports[_0xbba7('0xa8')]=function(_0x30aa04,_0x4a1562,_0x263046){return db[_0xbba7('0x36')][_0xbba7('0x2f')]({'where':{'id':_0x30aa04[_0xbba7('0x4d')]['id']}})[_0xbba7('0x25')](handleEntityNotFound(_0x4a1562,null))[_0xbba7('0x25')](function(_0x28507c){if(_0x28507c){return _0x28507c[_0xbba7('0xa8')](_0x30aa04[_0xbba7('0x3b')][_0xbba7('0x87')]);}})[_0xbba7('0x25')](function(_0x223c1d){if(_0x223c1d){return db[_0xbba7('0xa9')]['destroy']({'where':{'ListId':_0x30aa04[_0xbba7('0x3b')]['ids'],'VoiceQueueId':_0x30aa04['params']['id']}})[_0xbba7('0x25')](function(){return _0x223c1d;});}})['then'](respondWithStatusCode(_0x4a1562,null))['catch'](handleError(_0x4a1562,null));};exports['getBlackLists']=function(_0x2bd3b6,_0x589d7c,_0x5a9089){var _0x2d1926={};var _0x4ba3ce={};var _0x23b7e2;var _0x3236a5;return db[_0xbba7('0x36')]['findOne']({'where':{'id':_0x2bd3b6[_0xbba7('0x4d')]['id']}})[_0xbba7('0x25')](handleEntityNotFound(_0x589d7c,null))[_0xbba7('0x25')](function(_0x4184b2){if(_0x4184b2){_0x23b7e2=_0x4184b2;_0x4ba3ce[_0xbba7('0x3a')]=_[_0xbba7('0x4e')](db['CmList']['rawAttributes']);_0x4ba3ce[_0xbba7('0x3b')]=_[_0xbba7('0x4e')](_0x2bd3b6[_0xbba7('0x3b')]);_0x4ba3ce[_0xbba7('0x3c')]=_['intersection'](_0x4ba3ce[_0xbba7('0x3a')],_0x4ba3ce[_0xbba7('0x3b')]);_0x2d1926[_0xbba7('0x3f')]=_['intersection'](_0x4ba3ce['model'],qs[_0xbba7('0x3e')](_0x2bd3b6[_0xbba7('0x3b')]['fields']));_0x2d1926[_0xbba7('0x3f')]=_0x2d1926[_0xbba7('0x3f')]['length']?_0x2d1926[_0xbba7('0x3f')]:_0x4ba3ce[_0xbba7('0x3a')];_0x2d1926[_0xbba7('0x5e')]=qs[_0xbba7('0x43')](_0x2bd3b6[_0xbba7('0x3b')][_0xbba7('0x43')]);_0x2d1926['where']=qs['filters'](_[_0xbba7('0x45')](_0x2bd3b6[_0xbba7('0x3b')],_0x4ba3ce[_0xbba7('0x3c')]));if(_0x2bd3b6['query'][_0xbba7('0x2b')]){_0x2d1926['where']=_[_0xbba7('0x46')](_0x2d1926[_0xbba7('0x44')],{'$or':_[_0xbba7('0x35')](_0x2d1926[_0xbba7('0x3f')],function(_0x4b4e0f){var _0x4ced3f={};_0x4ced3f[_0x4b4e0f]={'$like':'%'+_0x2bd3b6[_0xbba7('0x3b')]['filter']+'%'};return _0x4ced3f;})});}_0x2d1926=_[_0xbba7('0x46')]({},_0x2d1926,_0x2bd3b6[_0xbba7('0x48')]);return _0x23b7e2[_0xbba7('0xaa')](_0x2d1926);}})['then'](function(_0x2dc06b){if(_0x2dc06b){_0x3236a5=_0x2dc06b['length'];if(!_0x2bd3b6[_0xbba7('0x3b')]['hasOwnProperty'](_0xbba7('0x42'))){_0x2d1926[_0xbba7('0x1f')]=qs[_0xbba7('0x1f')](_0x2bd3b6[_0xbba7('0x3b')]['limit']);_0x2d1926[_0xbba7('0x1e')]=qs[_0xbba7('0x1e')](_0x2bd3b6['query'][_0xbba7('0x1e')]);}return _0x23b7e2[_0xbba7('0xaa')](_0x2d1926);}})[_0xbba7('0x25')](function(_0x51bd54){if(_0x51bd54){return _0x51bd54?{'count':_0x3236a5,'rows':_0x51bd54}:null;}})[_0xbba7('0x25')](respondWithResult(_0x589d7c,null))[_0xbba7('0x4b')](handleError(_0x589d7c,null));};exports[_0xbba7('0xab')]=function(_0x3c7017,_0x4cd1f8,_0x3db3f1){var _0x28a8ab,_0x2e7a80;return db['VoiceQueue'][_0xbba7('0x2f')]({'where':{'id':_0x3c7017[_0xbba7('0x4d')]['id']}})[_0xbba7('0x25')](handleEntityNotFound(_0x4cd1f8,null))[_0xbba7('0x25')](function(_0x5c416a){if(_0x5c416a){_0x2e7a80=_0x5c416a;return _0x5c416a[_0xbba7('0xab')](_0x3c7017['body']['ids'],_['omit'](_0x3c7017[_0xbba7('0x50')],[_0xbba7('0x87'),'id'])||{});}return null;})[_0xbba7('0x8b')](function(_0x3f65f4){var _0xabc37c;_0x28a8ab=_0x3f65f4||[];var _0x22f462=[];if(_0x3f65f4){for(var _0x14213f=0x0;_0x14213f<_0x3f65f4[_0xbba7('0x40')];_0x14213f+=0x1){var _0x24c634=_0x3f65f4[_0x14213f][_0xbba7('0x26')]({'plain':!![]});_0xabc37c=squel[_0xbba7('0x94')]()[_0xbba7('0x95')](_0xbba7('0xac'))[_0xbba7('0xa6')]([_0xbba7('0x97'),_0xbba7('0x9b'),'ListId','VoiceQueueId','createdAt',_0xbba7('0x5a')],squel[_0xbba7('0x99')]()[_0xbba7('0x79')](_0xbba7('0x97'),_0xbba7('0x97'))[_0xbba7('0x79')]('id',_0xbba7('0x9b'))[_0xbba7('0x79')](_0x24c634[_0xbba7('0x9c')][_0xbba7('0x7f')](),_0xbba7('0x9d'))[_0xbba7('0x79')](_0x3c7017['params']['id'][_0xbba7('0x7f')](),_0xbba7('0x5f'))[_0xbba7('0x79')]('NOW()','createdAt')[_0xbba7('0x79')](_0xbba7('0x9a'),'updatedAt')[_0xbba7('0x7a')](_0xbba7('0x9e'))[_0xbba7('0x44')](_0xbba7('0xa7'))['where'](_0xbba7('0x9f'),_0x24c634[_0xbba7('0x9c')][_0xbba7('0x7f')]())['where']('phone\x20IS\x20NOT\x20NULL'))['toString']();_0x22f462[_0xbba7('0x7e')](db[_0xbba7('0x6e')][_0xbba7('0x3b')](_0xabc37c));}return BPromise[_0xbba7('0x84')](_0x22f462);}})[_0xbba7('0x25')](function(){return _0x28a8ab;})[_0xbba7('0x25')](respondWithResult(_0x4cd1f8,null))[_0xbba7('0x4b')](handleError(_0x4cd1f8,null));};exports[_0xbba7('0xad')]=function(_0x53570c,_0x3d4847,_0x5dc0cd){return db[_0xbba7('0x36')][_0xbba7('0x2f')]({'where':{'id':_0x53570c[_0xbba7('0x4d')]['id']}})[_0xbba7('0x25')](handleEntityNotFound(_0x3d4847,null))['then'](function(_0x25a122){if(_0x25a122){return _0x25a122['removeBlackLists'](_0x53570c[_0xbba7('0x3b')]['ids']);}})['then'](function(_0x12d14e){if(_0x12d14e){return db[_0xbba7('0x64')]['destroy']({'where':{'ListId':_0x53570c[_0xbba7('0x3b')][_0xbba7('0x87')],'VoiceQueueId':_0x53570c[_0xbba7('0x4d')]['id']}})['then'](function(){return _0x12d14e;});}})[_0xbba7('0x25')](respondWithStatusCode(_0x3d4847,null))[_0xbba7('0x4b')](handleError(_0x3d4847,null));};
\ No newline at end of file
+var _0x3fdb=['CmHopperFinal','getHopperBlacks','CmHopperBlack','getTeams','teams','Team','online','voicePause','interface','flatMap','Agents','forEach','sequelize','transaction','each','TeamVoiceQueue','penalty','findOrCreate','UserVoiceQueueRt','isNil','format','SIP/%s','emit','userVoiceQueue:save','ids','User','select','field','join','VoiceQueueId\x20=\x20?','ut.UserId\x20=\x20?','push','toString','QueryTypes','SELECT','every','TeamId','all','removeTeams','userVoiceQueue:remove','addAgents','spread','removeAgents','getAgents','getMembers','getLists','CmList','addLists','dialCheckDuplicateType','always','insert','into','cm_hopper','fromQuery','phone','scheduledAt','ContactId','NOW()','CmListId','ListId','cm_contacts','deletedAt\x20IS\x20NULL','ListId\x20=\x20?','phone\x20IS\x20NOT\x20NULL','COALESCE(calleridnum,\x27\x27)','from','COALESCE(phone,\x27\x27)','onlyIfOpen','phone\x20NOT\x20IN\x20(?)','getBlackLists','addBlackLists','cm_hopper_black','removeBlackLists','eml-format','rimraf','zip-dir','request-promise','bluebird','mustache','util','to-csv','ejs','fs-extra','lodash','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','defaults','register','end','offset','limit','undefined','count','status','set','Content-Range','apply','reject','update','then','get','VoiceQueues','inbound','QueueCampaigns','outbound','filter','ignore','map','value','type','find','name','UserProfileResource','destroy','sendStatus','error','send','index','VoiceQueue','rawAttributes','fieldName','key','model','query','keys','filters','intersection','fields','attributes','length','order','where','pick','merge','VIRTUAL','options','includeAll','include','findAll','rows','catch','create','body','role','user','UserProfileSection','userProfileId','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','clone','params','omit','updatedAt','createdAt','autoAssociation','getHoppers','findOne','hasOwnProperty','nolimit','sort','VoiceQueueId','CmHopper','getHopperHistories','CmHopperHistory','getHopperFinals'];(function(_0x7d710,_0x412547){var _0x3f5e58=function(_0x11b52c){while(--_0x11b52c){_0x7d710['push'](_0x7d710['shift']());}};_0x3f5e58(++_0x412547);}(_0x3fdb,0x1af));var _0xb3fd=function(_0x38960a,_0x4e49b0){_0x38960a=_0x38960a-0x0;var _0x1003e2=_0x3fdb[_0x38960a];return _0x1003e2;};'use strict';var emlformat=require(_0xb3fd('0x0'));var rimraf=require(_0xb3fd('0x1'));var zipdir=require(_0xb3fd('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0xb3fd('0x3'));var moment=require('moment');var BPromise=require(_0xb3fd('0x4'));var Mustache=require(_0xb3fd('0x5'));var util=require(_0xb3fd('0x6'));var path=require('path');var sox=require('sox');var csv=require(_0xb3fd('0x7'));var ejs=require(_0xb3fd('0x8'));var fs=require('fs');var fs_extra=require(_0xb3fd('0x9'));var _=require(_0xb3fd('0xa'));var squel=require('squel');var crypto=require(_0xb3fd('0xb'));var jsforce=require(_0xb3fd('0xc'));var deskjs=require(_0xb3fd('0xd'));var toCsv=require(_0xb3fd('0x7'));var querystring=require(_0xb3fd('0xe'));var Papa=require(_0xb3fd('0xf'));var Redis=require(_0xb3fd('0x10'));var authService=require(_0xb3fd('0x11'));var qs=require(_0xb3fd('0x12'));var as=require(_0xb3fd('0x13'));var hardwareService=require(_0xb3fd('0x14'));var logger=require(_0xb3fd('0x15'))(_0xb3fd('0x16'));var utils=require(_0xb3fd('0x17'));var config=require(_0xb3fd('0x18'));var licenseUtil=require(_0xb3fd('0x19'));var db=require(_0xb3fd('0x1a'))['db'];config[_0xb3fd('0x1b')]=_[_0xb3fd('0x1c')](config[_0xb3fd('0x1b')],{'host':'localhost','port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0xb3fd('0x1b')]));require('./voiceQueue.socket')[_0xb3fd('0x1d')](socket);function respondWithStatusCode(_0x1f706b,_0x33a33c){_0x33a33c=_0x33a33c||0xcc;return function(_0x44bf55){if(_0x44bf55){return _0x1f706b['sendStatus'](_0x33a33c);}return _0x1f706b['status'](_0x33a33c)[_0xb3fd('0x1e')]();};}function respondWithResult(_0x3403fb,_0x519fd3){_0x519fd3=_0x519fd3||0xc8;return function(_0x5634af){if(_0x5634af){return _0x3403fb['status'](_0x519fd3)['json'](_0x5634af);}};}function respondWithFilteredResult(_0x36b67d,_0x3d92b9){return function(_0x13d283){if(_0x13d283){var _0x9c7ea9=typeof _0x3d92b9[_0xb3fd('0x1f')]==='undefined'&&typeof _0x3d92b9[_0xb3fd('0x20')]===_0xb3fd('0x21');var _0x38911e=_0x13d283[_0xb3fd('0x22')];var _0x14f402=_0x9c7ea9?0x0:_0x3d92b9[_0xb3fd('0x1f')];var _0x3c099a=_0x9c7ea9?_0x13d283['count']:_0x3d92b9[_0xb3fd('0x1f')]+_0x3d92b9[_0xb3fd('0x20')];var _0x123314;if(_0x3c099a>=_0x38911e){_0x3c099a=_0x38911e;_0x123314=0xc8;}else{_0x123314=0xce;}_0x36b67d[_0xb3fd('0x23')](_0x123314);return _0x36b67d[_0xb3fd('0x24')](_0xb3fd('0x25'),_0x14f402+'-'+_0x3c099a+'/'+_0x38911e)['json'](_0x13d283);}return null;};}function patchUpdates(_0x5a8a8d){return function(_0x590eb5){try{jsonpatch[_0xb3fd('0x26')](_0x590eb5,_0x5a8a8d,!![]);}catch(_0x3a8819){return BPromise[_0xb3fd('0x27')](_0x3a8819);}return _0x590eb5['save']();};}function saveUpdates(_0x45c993,_0x3417e9){return function(_0x4af128){if(_0x4af128){return _0x4af128[_0xb3fd('0x28')](_0x45c993)['then'](function(_0x147d0e){return _0x147d0e;});}return null;};}function removeEntity(_0x1866c1,_0x416912){return function(_0x23dec8){if(_0x23dec8){return _0x23dec8['destroy']()[_0xb3fd('0x29')](function(){var _0x171f17=_0x23dec8[_0xb3fd('0x2a')]({'plain':!![]});var _0x4c2b0c=[{'name':_0xb3fd('0x2b'),'value':_0xb3fd('0x2c'),'ignore':![]},{'name':_0xb3fd('0x2d'),'value':_0xb3fd('0x2e'),'ignore':![]}];var _0x4ea6ba=_(_0x4c2b0c)[_0xb3fd('0x2f')](_0xb3fd('0x30'))[_0xb3fd('0x31')]('value')[_0xb3fd('0x32')]();if(_['includes'](_0x4ea6ba,_0x171f17[_0xb3fd('0x33')])){return;}var _0x1df219=_[_0xb3fd('0x34')](_0x4c2b0c,[_0xb3fd('0x32'),_0x171f17[_0xb3fd('0x33')]])[_0xb3fd('0x35')];return db[_0xb3fd('0x36')][_0xb3fd('0x37')]({'where':{'type':_0x1df219,'resourceId':_0x171f17['id']}})[_0xb3fd('0x29')](function(){return _0x23dec8;});})[_0xb3fd('0x29')](function(){_0x1866c1[_0xb3fd('0x23')](0xcc)[_0xb3fd('0x1e')]();});}};}function handleEntityNotFound(_0x2923db,_0x5f3852){return function(_0x2f6e3d){if(!_0x2f6e3d){_0x2923db[_0xb3fd('0x38')](0x194);}return _0x2f6e3d;};}function handleError(_0x4dd2ce,_0x1cb48c){_0x1cb48c=_0x1cb48c||0x1f4;return function(_0x111b25){logger[_0xb3fd('0x39')](_0x111b25['stack']);if(_0x111b25[_0xb3fd('0x35')]){delete _0x111b25[_0xb3fd('0x35')];}_0x4dd2ce[_0xb3fd('0x23')](_0x1cb48c)[_0xb3fd('0x3a')](_0x111b25);};}exports[_0xb3fd('0x3b')]=function(_0x3f578b,_0x1ff8c1){var _0x5338f6={},_0x50cdae={},_0x181790={'count':0x0,'rows':[]};var _0x1cdab9=_[_0xb3fd('0x31')](db[_0xb3fd('0x3c')][_0xb3fd('0x3d')],function(_0x47f449){return{'name':_0x47f449[_0xb3fd('0x3e')],'type':_0x47f449['type'][_0xb3fd('0x3f')]};});_0x50cdae[_0xb3fd('0x40')]=_[_0xb3fd('0x31')](_0x1cdab9,_0xb3fd('0x35'));_0x50cdae[_0xb3fd('0x41')]=_[_0xb3fd('0x42')](_0x3f578b[_0xb3fd('0x41')]);_0x50cdae[_0xb3fd('0x43')]=_[_0xb3fd('0x44')](_0x50cdae[_0xb3fd('0x40')],_0x50cdae[_0xb3fd('0x41')]);_0x5338f6['attributes']=_[_0xb3fd('0x44')](_0x50cdae['model'],qs[_0xb3fd('0x45')](_0x3f578b[_0xb3fd('0x41')]['fields']));_0x5338f6[_0xb3fd('0x46')]=_0x5338f6[_0xb3fd('0x46')][_0xb3fd('0x47')]?_0x5338f6[_0xb3fd('0x46')]:_0x50cdae[_0xb3fd('0x40')];if(!_0x3f578b[_0xb3fd('0x41')]['hasOwnProperty']('nolimit')){_0x5338f6[_0xb3fd('0x20')]=qs['limit'](_0x3f578b[_0xb3fd('0x41')][_0xb3fd('0x20')]);_0x5338f6['offset']=qs[_0xb3fd('0x1f')](_0x3f578b[_0xb3fd('0x41')][_0xb3fd('0x1f')]);}_0x5338f6[_0xb3fd('0x48')]=qs['sort'](_0x3f578b['query']['sort']);_0x5338f6[_0xb3fd('0x49')]=qs[_0xb3fd('0x43')](_[_0xb3fd('0x4a')](_0x3f578b['query'],_0x50cdae[_0xb3fd('0x43')]),_0x1cdab9);if(_0x3f578b[_0xb3fd('0x41')][_0xb3fd('0x2f')]){_0x5338f6['where']=_[_0xb3fd('0x4b')](_0x5338f6[_0xb3fd('0x49')],{'$or':_[_0xb3fd('0x31')](_0x1cdab9,function(_0x13bd29){if(_0x13bd29[_0xb3fd('0x33')]!==_0xb3fd('0x4c')){var _0x5f3b42={};_0x5f3b42[_0x13bd29['name']]={'$like':'%'+_0x3f578b['query'][_0xb3fd('0x2f')]+'%'};return _0x5f3b42;}})});}_0x5338f6=_['merge']({},_0x5338f6,_0x3f578b[_0xb3fd('0x4d')]);var _0x27efe4={'where':_0x5338f6[_0xb3fd('0x49')]};return db[_0xb3fd('0x3c')][_0xb3fd('0x22')](_0x27efe4)[_0xb3fd('0x29')](function(_0x1f2532){_0x181790[_0xb3fd('0x22')]=_0x1f2532;if(_0x3f578b[_0xb3fd('0x41')][_0xb3fd('0x4e')]){_0x5338f6[_0xb3fd('0x4f')]=[{'all':!![]}];}return db[_0xb3fd('0x3c')][_0xb3fd('0x50')](_0x5338f6);})[_0xb3fd('0x29')](function(_0x39a6ce){_0x181790[_0xb3fd('0x51')]=_0x39a6ce;return _0x181790;})[_0xb3fd('0x29')](respondWithFilteredResult(_0x1ff8c1,_0x5338f6))[_0xb3fd('0x52')](handleError(_0x1ff8c1,null));};exports['show']=function(_0x559d1f,_0x3d96b0){var _0x7e08d6={'raw':![],'where':{'id':_0x559d1f['params']['id']}},_0x40836c={};_0x40836c[_0xb3fd('0x40')]=_[_0xb3fd('0x42')](db[_0xb3fd('0x3c')]['rawAttributes']);_0x40836c[_0xb3fd('0x41')]=_['keys'](_0x559d1f[_0xb3fd('0x41')]);_0x40836c['filters']=_['intersection'](_0x40836c[_0xb3fd('0x40')],_0x40836c[_0xb3fd('0x41')]);_0x7e08d6[_0xb3fd('0x46')]=_[_0xb3fd('0x44')](_0x40836c[_0xb3fd('0x40')],qs[_0xb3fd('0x45')](_0x559d1f['query'][_0xb3fd('0x45')]));_0x7e08d6[_0xb3fd('0x46')]=_0x7e08d6['attributes'][_0xb3fd('0x47')]?_0x7e08d6[_0xb3fd('0x46')]:_0x40836c[_0xb3fd('0x40')];if(_0x559d1f[_0xb3fd('0x41')]['includeAll']){_0x7e08d6['include']=[{'all':!![]}];}_0x7e08d6=_['merge']({},_0x7e08d6,_0x559d1f[_0xb3fd('0x4d')]);return db['VoiceQueue'][_0xb3fd('0x34')](_0x7e08d6)['then'](handleEntityNotFound(_0x3d96b0,null))[_0xb3fd('0x29')](respondWithResult(_0x3d96b0,null))[_0xb3fd('0x52')](handleError(_0x3d96b0,null));};exports[_0xb3fd('0x53')]=function(_0x4a9214,_0x367703){return db['VoiceQueue'][_0xb3fd('0x53')](_0x4a9214[_0xb3fd('0x54')],{})['then'](function(_0x21fbdc){var _0x221922=_0x4a9214['user'][_0xb3fd('0x2a')]({'plain':!![]});if(!_0x221922)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x221922[_0xb3fd('0x55')]===_0xb3fd('0x56')){var _0x5bddcd=_0x21fbdc[_0xb3fd('0x2a')]({'plain':!![]});var _0x13d39f=[{'name':'VoiceQueues','value':'inbound'},{'name':_0xb3fd('0x2d'),'value':'outbound'}];var _0x2296a8=_[_0xb3fd('0x34')](_0x13d39f,[_0xb3fd('0x32'),_0x5bddcd['type']])[_0xb3fd('0x35')];return db[_0xb3fd('0x57')][_0xb3fd('0x34')]({'where':{'name':_0x2296a8,'userProfileId':_0x221922[_0xb3fd('0x58')]},'raw':!![]})[_0xb3fd('0x29')](function(_0x3e1e5e){if(_0x3e1e5e&&_0x3e1e5e['autoAssociation']===0x0){return db['UserProfileResource']['create']({'name':_0x5bddcd[_0xb3fd('0x35')],'resourceId':_0x5bddcd['id'],'type':_0x3e1e5e[_0xb3fd('0x35')],'sectionId':_0x3e1e5e['id']},{})[_0xb3fd('0x29')](function(){return _0x21fbdc;});}else{return _0x21fbdc;}})[_0xb3fd('0x52')](function(_0x5c996e){logger[_0xb3fd('0x39')](_0xb3fd('0x59'),_0x5c996e);throw _0x5c996e;});}return _0x21fbdc;})['then'](respondWithResult(_0x367703,0xc9))[_0xb3fd('0x52')](handleError(_0x367703,null));};exports[_0xb3fd('0x5a')]=function(_0x2934e,_0x1a822d){var _0x7cbf03={'where':{'id':_0x2934e[_0xb3fd('0x5b')]['id']}},_0x5eb62f={};_0x5eb62f[_0xb3fd('0x40')]=_['keys'](db['VoiceQueue'][_0xb3fd('0x3d')]);_0x7cbf03[_0xb3fd('0x46')]=_[_0xb3fd('0x44')](_0x5eb62f[_0xb3fd('0x40')],qs[_0xb3fd('0x45')](_0x2934e[_0xb3fd('0x41')]['fields']));_0x7cbf03[_0xb3fd('0x46')]=_0x7cbf03[_0xb3fd('0x46')][_0xb3fd('0x47')]?_0x7cbf03['attributes']:_0x5eb62f['model'];if(_0x2934e['query'][_0xb3fd('0x4e')]){_0x7cbf03[_0xb3fd('0x4f')]=[{'all':!![]}];}_0x7cbf03=_[_0xb3fd('0x4b')]({},_0x7cbf03,_0x2934e['options']);return db[_0xb3fd('0x3c')][_0xb3fd('0x34')](_0x7cbf03)['then'](handleEntityNotFound(_0x1a822d,null))[_0xb3fd('0x29')](function(_0x3e53b0){if(_0x3e53b0){var _0x386dc4=_0x3e53b0['get']({'plain':!![]});_0x386dc4=qs[_0xb3fd('0x5c')](_0x386dc4,['id','createdAt',_0xb3fd('0x5d')]);_0x2934e[_0xb3fd('0x54')]=_[_0xb3fd('0x5c')](_0x2934e['body'],['id',_0xb3fd('0x5e'),_0xb3fd('0x5d')]);return db[_0xb3fd('0x3c')]['create'](_[_0xb3fd('0x4b')](_0x386dc4,_0x2934e['body']),{'include':_0x2934e[_0xb3fd('0x41')][_0xb3fd('0x4e')]?[{'all':!![]}]:undefined})[_0xb3fd('0x29')](function(_0x551530){var _0x2fe570=_0x2934e[_0xb3fd('0x56')][_0xb3fd('0x2a')]({'plain':!![]});if(!_0x2fe570)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x2fe570[_0xb3fd('0x55')]===_0xb3fd('0x56')){var _0x37f662=_0x551530[_0xb3fd('0x2a')]({'plain':!![]});var _0x587fd9=[{'name':'VoiceQueues','value':'inbound'},{'name':'QueueCampaigns','value':_0xb3fd('0x2e')}];var _0x36eb2b=_[_0xb3fd('0x34')](_0x587fd9,[_0xb3fd('0x32'),_0x37f662[_0xb3fd('0x33')]])[_0xb3fd('0x35')];return db[_0xb3fd('0x57')][_0xb3fd('0x34')]({'where':{'name':_0x36eb2b,'userProfileId':_0x2fe570[_0xb3fd('0x58')]},'raw':!![]})[_0xb3fd('0x29')](function(_0x385d1b){if(_0x385d1b&&_0x385d1b[_0xb3fd('0x5f')]===0x0){return db[_0xb3fd('0x36')]['create']({'name':_0x37f662[_0xb3fd('0x35')],'resourceId':_0x37f662['id'],'type':_0x385d1b['name'],'sectionId':_0x385d1b['id']},{})['then'](function(){return _0x551530;});}else{return _0x551530;}})[_0xb3fd('0x52')](function(_0x210ad7){logger[_0xb3fd('0x39')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x210ad7);throw _0x210ad7;});}return _0x551530;});}})[_0xb3fd('0x29')](respondWithResult(_0x1a822d,0xc9))[_0xb3fd('0x52')](handleError(_0x1a822d,null));};exports[_0xb3fd('0x28')]=function(_0x430087,_0x48b0bf){if(_0x430087[_0xb3fd('0x54')]['id']){delete _0x430087[_0xb3fd('0x54')]['id'];}return db[_0xb3fd('0x3c')][_0xb3fd('0x34')]({'where':{'id':_0x430087[_0xb3fd('0x5b')]['id']}})[_0xb3fd('0x29')](handleEntityNotFound(_0x48b0bf,null))[_0xb3fd('0x29')](saveUpdates(_0x430087[_0xb3fd('0x54')],null))[_0xb3fd('0x29')](respondWithResult(_0x48b0bf,null))[_0xb3fd('0x52')](handleError(_0x48b0bf,null));};exports[_0xb3fd('0x37')]=function(_0x1d61f0,_0x5abd72){return db[_0xb3fd('0x3c')][_0xb3fd('0x34')]({'where':{'id':_0x1d61f0[_0xb3fd('0x5b')]['id']}})['then'](handleEntityNotFound(_0x5abd72,null))[_0xb3fd('0x29')](removeEntity(_0x5abd72,null))['catch'](handleError(_0x5abd72,null));};exports[_0xb3fd('0x60')]=function(_0x5ee0d9,_0x242cc8,_0x2673e2){var _0xb8bbb5={'raw':![],'where':{}};var _0x339d75={};var _0x16f018={'count':0x0,'rows':[]};return db[_0xb3fd('0x3c')][_0xb3fd('0x61')]({'where':{'id':_0x5ee0d9[_0xb3fd('0x5b')]['id']}})[_0xb3fd('0x29')](handleEntityNotFound(_0x242cc8,null))['then'](function(_0x5ad749){if(_0x5ad749){_0x339d75['model']=_['keys'](db['CmHopper'][_0xb3fd('0x3d')]);_0x339d75[_0xb3fd('0x41')]=_[_0xb3fd('0x42')](_0x5ee0d9['query']);_0x339d75[_0xb3fd('0x43')]=_[_0xb3fd('0x44')](_0x339d75[_0xb3fd('0x40')],_0x339d75[_0xb3fd('0x41')]);_0xb8bbb5['attributes']=_[_0xb3fd('0x44')](_0x339d75[_0xb3fd('0x40')],qs[_0xb3fd('0x45')](_0x5ee0d9[_0xb3fd('0x41')]['fields']));_0xb8bbb5['attributes']=_0xb8bbb5[_0xb3fd('0x46')][_0xb3fd('0x47')]?_0xb8bbb5[_0xb3fd('0x46')]:_0x339d75[_0xb3fd('0x40')];if(!_0x5ee0d9[_0xb3fd('0x41')][_0xb3fd('0x62')](_0xb3fd('0x63'))){_0xb8bbb5[_0xb3fd('0x20')]=qs[_0xb3fd('0x20')](_0x5ee0d9['query'][_0xb3fd('0x20')]);_0xb8bbb5[_0xb3fd('0x1f')]=qs[_0xb3fd('0x1f')](_0x5ee0d9[_0xb3fd('0x41')][_0xb3fd('0x1f')]);}_0xb8bbb5[_0xb3fd('0x48')]=qs['sort'](_0x5ee0d9[_0xb3fd('0x41')][_0xb3fd('0x64')]);_0xb8bbb5[_0xb3fd('0x49')]=qs[_0xb3fd('0x43')](_[_0xb3fd('0x4a')](_0x5ee0d9[_0xb3fd('0x41')],_0x339d75[_0xb3fd('0x43')]));_0xb8bbb5['where'][_0xb3fd('0x65')]=_0x5ad749['id'];if(_0x5ee0d9[_0xb3fd('0x41')][_0xb3fd('0x2f')]){_0xb8bbb5['where']=_[_0xb3fd('0x4b')](_0xb8bbb5[_0xb3fd('0x49')],{'$or':_['map'](_0xb8bbb5[_0xb3fd('0x46')],function(_0x5520d2){var _0xcb0fa2={};_0xcb0fa2[_0x5520d2]={'$like':'%'+_0x5ee0d9[_0xb3fd('0x41')][_0xb3fd('0x2f')]+'%'};return _0xcb0fa2;})});}_0xb8bbb5=_[_0xb3fd('0x4b')]({},_0xb8bbb5,_0x5ee0d9[_0xb3fd('0x4d')]);return db[_0xb3fd('0x66')]['count']({'where':_0xb8bbb5[_0xb3fd('0x49')]})[_0xb3fd('0x29')](function(_0x20ea78){_0x16f018[_0xb3fd('0x22')]=_0x20ea78;if(_0x5ee0d9[_0xb3fd('0x41')][_0xb3fd('0x4e')]){_0xb8bbb5[_0xb3fd('0x4f')]=[{'all':!![]}];}return db[_0xb3fd('0x66')]['findAll'](_0xb8bbb5);})[_0xb3fd('0x29')](function(_0x5cc606){_0x16f018[_0xb3fd('0x51')]=_0x5cc606;return _0x16f018;});}})['then'](respondWithFilteredResult(_0x242cc8,_0xb8bbb5))[_0xb3fd('0x52')](handleError(_0x242cc8,null));};exports[_0xb3fd('0x67')]=function(_0x645e08,_0x29f4ac,_0x3026a6){var _0x148b8f={'raw':!![],'where':{}};var _0x5aea99={};var _0x2e4fbf={'count':0x0,'rows':[]};return db[_0xb3fd('0x3c')][_0xb3fd('0x61')]({'where':{'id':_0x645e08['params']['id']}})['then'](handleEntityNotFound(_0x29f4ac,null))[_0xb3fd('0x29')](function(_0x41db8b){if(_0x41db8b){_0x5aea99['model']=_['keys'](db['CmHopperHistory'][_0xb3fd('0x3d')]);_0x5aea99[_0xb3fd('0x41')]=_[_0xb3fd('0x42')](_0x645e08['query']);_0x5aea99[_0xb3fd('0x43')]=_[_0xb3fd('0x44')](_0x5aea99['model'],_0x5aea99['query']);_0x148b8f['attributes']=_[_0xb3fd('0x44')](_0x5aea99[_0xb3fd('0x40')],qs[_0xb3fd('0x45')](_0x645e08[_0xb3fd('0x41')][_0xb3fd('0x45')]));_0x148b8f[_0xb3fd('0x46')]=_0x148b8f[_0xb3fd('0x46')]['length']?_0x148b8f[_0xb3fd('0x46')]:_0x5aea99['model'];if(!_0x645e08['query'][_0xb3fd('0x62')]('nolimit')){_0x148b8f[_0xb3fd('0x20')]=qs[_0xb3fd('0x20')](_0x645e08[_0xb3fd('0x41')]['limit']);_0x148b8f[_0xb3fd('0x1f')]=qs['offset'](_0x645e08['query'][_0xb3fd('0x1f')]);}_0x148b8f[_0xb3fd('0x48')]=qs['sort'](_0x645e08[_0xb3fd('0x41')][_0xb3fd('0x64')]);_0x148b8f['where']=qs[_0xb3fd('0x43')](_['pick'](_0x645e08[_0xb3fd('0x41')],_0x5aea99['filters']));_0x148b8f[_0xb3fd('0x49')][_0xb3fd('0x65')]=_0x41db8b['id'];if(_0x645e08[_0xb3fd('0x41')][_0xb3fd('0x2f')]){_0x148b8f[_0xb3fd('0x49')]=_[_0xb3fd('0x4b')](_0x148b8f[_0xb3fd('0x49')],{'$or':_[_0xb3fd('0x31')](_0x148b8f[_0xb3fd('0x46')],function(_0x1ca808){var _0x57d78e={};_0x57d78e[_0x1ca808]={'$like':'%'+_0x645e08[_0xb3fd('0x41')]['filter']+'%'};return _0x57d78e;})});}_0x148b8f=_[_0xb3fd('0x4b')]({},_0x148b8f,_0x645e08[_0xb3fd('0x4d')]);return db[_0xb3fd('0x68')][_0xb3fd('0x22')]({'where':_0x148b8f[_0xb3fd('0x49')]})['then'](function(_0x2f1e80){_0x2e4fbf['count']=_0x2f1e80;if(_0x645e08['query'][_0xb3fd('0x4e')]){_0x148b8f['include']=[{'all':!![]}];}return db[_0xb3fd('0x68')][_0xb3fd('0x50')](_0x148b8f);})[_0xb3fd('0x29')](function(_0x152b7b){_0x2e4fbf[_0xb3fd('0x51')]=_0x152b7b;return _0x2e4fbf;});}})[_0xb3fd('0x29')](respondWithFilteredResult(_0x29f4ac,_0x148b8f))[_0xb3fd('0x52')](handleError(_0x29f4ac,null));};exports[_0xb3fd('0x69')]=function(_0x3001bb,_0x3a6fa5,_0x51acfe){var _0x70f1db={'raw':!![],'where':{}};var _0x49b9c2={};var _0x352ee4={'count':0x0,'rows':[]};return db[_0xb3fd('0x3c')][_0xb3fd('0x61')]({'where':{'id':_0x3001bb['params']['id']}})[_0xb3fd('0x29')](handleEntityNotFound(_0x3a6fa5,null))[_0xb3fd('0x29')](function(_0x28cb50){if(_0x28cb50){_0x49b9c2['model']=_[_0xb3fd('0x42')](db[_0xb3fd('0x6a')][_0xb3fd('0x3d')]);_0x49b9c2['query']=_['keys'](_0x3001bb['query']);_0x49b9c2['filters']=_['intersection'](_0x49b9c2['model'],_0x49b9c2[_0xb3fd('0x41')]);_0x70f1db[_0xb3fd('0x46')]=_[_0xb3fd('0x44')](_0x49b9c2['model'],qs[_0xb3fd('0x45')](_0x3001bb[_0xb3fd('0x41')][_0xb3fd('0x45')]));_0x70f1db['attributes']=_0x70f1db['attributes']['length']?_0x70f1db[_0xb3fd('0x46')]:_0x49b9c2[_0xb3fd('0x40')];if(!_0x3001bb['query']['hasOwnProperty'](_0xb3fd('0x63'))){_0x70f1db[_0xb3fd('0x20')]=qs[_0xb3fd('0x20')](_0x3001bb[_0xb3fd('0x41')][_0xb3fd('0x20')]);_0x70f1db['offset']=qs[_0xb3fd('0x1f')](_0x3001bb[_0xb3fd('0x41')][_0xb3fd('0x1f')]);}_0x70f1db[_0xb3fd('0x48')]=qs[_0xb3fd('0x64')](_0x3001bb[_0xb3fd('0x41')][_0xb3fd('0x64')]);_0x70f1db[_0xb3fd('0x49')]=qs[_0xb3fd('0x43')](_[_0xb3fd('0x4a')](_0x3001bb[_0xb3fd('0x41')],_0x49b9c2[_0xb3fd('0x43')]));_0x70f1db['where'][_0xb3fd('0x65')]=_0x28cb50['id'];if(_0x3001bb['query']['filter']){_0x70f1db[_0xb3fd('0x49')]=_['merge'](_0x70f1db['where'],{'$or':_[_0xb3fd('0x31')](_0x70f1db[_0xb3fd('0x46')],function(_0x124877){var _0x3929b3={};_0x3929b3[_0x124877]={'$like':'%'+_0x3001bb['query']['filter']+'%'};return _0x3929b3;})});}_0x70f1db=_[_0xb3fd('0x4b')]({},_0x70f1db,_0x3001bb[_0xb3fd('0x4d')]);return db['CmHopperFinal'][_0xb3fd('0x22')]({'where':_0x70f1db[_0xb3fd('0x49')]})[_0xb3fd('0x29')](function(_0x1e810e){_0x352ee4['count']=_0x1e810e;if(_0x3001bb[_0xb3fd('0x41')]['includeAll']){_0x70f1db['include']=[{'all':!![]}];}return db[_0xb3fd('0x6a')][_0xb3fd('0x50')](_0x70f1db);})[_0xb3fd('0x29')](function(_0x2377a5){_0x352ee4[_0xb3fd('0x51')]=_0x2377a5;return _0x352ee4;});}})[_0xb3fd('0x29')](respondWithFilteredResult(_0x3a6fa5,_0x70f1db))[_0xb3fd('0x52')](handleError(_0x3a6fa5,null));};exports[_0xb3fd('0x6b')]=function(_0x265dbf,_0x359c3d,_0x58d092){var _0x185908={'raw':!![],'where':{}};var _0x2f44e5={};var _0x6eb95c={'count':0x0,'rows':[]};return db[_0xb3fd('0x3c')]['findOne']({'where':{'id':_0x265dbf[_0xb3fd('0x5b')]['id']}})[_0xb3fd('0x29')](handleEntityNotFound(_0x359c3d,null))['then'](function(_0x18cc20){if(_0x18cc20){_0x2f44e5[_0xb3fd('0x40')]=_[_0xb3fd('0x42')](db[_0xb3fd('0x6c')]['rawAttributes']);_0x2f44e5[_0xb3fd('0x41')]=_['keys'](_0x265dbf[_0xb3fd('0x41')]);_0x2f44e5[_0xb3fd('0x43')]=_[_0xb3fd('0x44')](_0x2f44e5[_0xb3fd('0x40')],_0x2f44e5[_0xb3fd('0x41')]);_0x185908['attributes']=_['intersection'](_0x2f44e5[_0xb3fd('0x40')],qs[_0xb3fd('0x45')](_0x265dbf[_0xb3fd('0x41')][_0xb3fd('0x45')]));_0x185908[_0xb3fd('0x46')]=_0x185908['attributes'][_0xb3fd('0x47')]?_0x185908['attributes']:_0x2f44e5[_0xb3fd('0x40')];if(!_0x265dbf[_0xb3fd('0x41')][_0xb3fd('0x62')]('nolimit')){_0x185908[_0xb3fd('0x20')]=qs[_0xb3fd('0x20')](_0x265dbf[_0xb3fd('0x41')]['limit']);_0x185908[_0xb3fd('0x1f')]=qs[_0xb3fd('0x1f')](_0x265dbf['query'][_0xb3fd('0x1f')]);}_0x185908['order']=qs[_0xb3fd('0x64')](_0x265dbf[_0xb3fd('0x41')]['sort']);_0x185908[_0xb3fd('0x49')]=qs[_0xb3fd('0x43')](_['pick'](_0x265dbf[_0xb3fd('0x41')],_0x2f44e5[_0xb3fd('0x43')]));_0x185908[_0xb3fd('0x49')][_0xb3fd('0x65')]=_0x18cc20['id'];if(_0x265dbf[_0xb3fd('0x41')][_0xb3fd('0x2f')]){_0x185908[_0xb3fd('0x49')]=_['merge'](_0x185908[_0xb3fd('0x49')],{'$or':_[_0xb3fd('0x31')](_0x185908[_0xb3fd('0x46')],function(_0x568ece){var _0x606ef8={};_0x606ef8[_0x568ece]={'$like':'%'+_0x265dbf[_0xb3fd('0x41')]['filter']+'%'};return _0x606ef8;})});}_0x185908=_[_0xb3fd('0x4b')]({},_0x185908,_0x265dbf[_0xb3fd('0x4d')]);return db[_0xb3fd('0x6c')][_0xb3fd('0x22')]({'where':_0x185908[_0xb3fd('0x49')]})['then'](function(_0x43f875){_0x6eb95c['count']=_0x43f875;if(_0x265dbf[_0xb3fd('0x41')][_0xb3fd('0x4e')]){_0x185908[_0xb3fd('0x4f')]=[{'all':!![]}];}return db[_0xb3fd('0x6c')][_0xb3fd('0x50')](_0x185908);})[_0xb3fd('0x29')](function(_0x54e420){_0x6eb95c[_0xb3fd('0x51')]=_0x54e420;return _0x6eb95c;});}})[_0xb3fd('0x29')](respondWithFilteredResult(_0x359c3d,_0x185908))[_0xb3fd('0x52')](handleError(_0x359c3d,null));};exports[_0xb3fd('0x6d')]=function(_0x24e9c3,_0x3aad43,_0x2f64f7){var _0x58b552={};var _0x1bd0e5={};var _0x4e756e;var _0x220066;return db[_0xb3fd('0x3c')][_0xb3fd('0x61')]({'where':{'id':_0x24e9c3[_0xb3fd('0x5b')]['id']}})[_0xb3fd('0x29')](handleEntityNotFound(_0x3aad43,null))['then'](function(_0x217a0d){if(_0x217a0d){_0x4e756e=_0x217a0d;_0x1bd0e5[_0xb3fd('0x40')]=_[_0xb3fd('0x42')](db['Team'][_0xb3fd('0x3d')]);_0x1bd0e5[_0xb3fd('0x41')]=_['keys'](_0x24e9c3[_0xb3fd('0x41')]);_0x1bd0e5['filters']=_['intersection'](_0x1bd0e5[_0xb3fd('0x40')],_0x1bd0e5['query']);_0x58b552['attributes']=_[_0xb3fd('0x44')](_0x1bd0e5[_0xb3fd('0x40')],qs[_0xb3fd('0x45')](_0x24e9c3[_0xb3fd('0x41')]['fields']));_0x58b552[_0xb3fd('0x46')]=_0x58b552[_0xb3fd('0x46')][_0xb3fd('0x47')]?_0x58b552[_0xb3fd('0x46')]:_0x1bd0e5['model'];_0x58b552[_0xb3fd('0x48')]=qs[_0xb3fd('0x64')](_0x24e9c3[_0xb3fd('0x41')][_0xb3fd('0x64')]);_0x58b552[_0xb3fd('0x49')]=qs[_0xb3fd('0x43')](_['pick'](_0x24e9c3['query'],_0x1bd0e5[_0xb3fd('0x43')]));if(_0x24e9c3[_0xb3fd('0x41')][_0xb3fd('0x2f')]){_0x58b552[_0xb3fd('0x49')]=_[_0xb3fd('0x4b')](_0x58b552['where'],{'$or':_[_0xb3fd('0x31')](_0x58b552[_0xb3fd('0x46')],function(_0x3cc72f){var _0x304b9e={};_0x304b9e[_0x3cc72f]={'$like':'%'+_0x24e9c3['query'][_0xb3fd('0x2f')]+'%'};return _0x304b9e;})});}_0x58b552=_[_0xb3fd('0x4b')]({},_0x58b552,_0x24e9c3[_0xb3fd('0x4d')]);return _0x4e756e[_0xb3fd('0x6d')](_0x58b552);}})[_0xb3fd('0x29')](function(_0x10e147){if(_0x10e147){_0x220066=_0x10e147[_0xb3fd('0x47')];if(!_0x24e9c3[_0xb3fd('0x41')][_0xb3fd('0x62')]('nolimit')){_0x58b552[_0xb3fd('0x20')]=qs[_0xb3fd('0x20')](_0x24e9c3['query'][_0xb3fd('0x20')]);_0x58b552['offset']=qs[_0xb3fd('0x1f')](_0x24e9c3[_0xb3fd('0x41')][_0xb3fd('0x1f')]);}return _0x4e756e[_0xb3fd('0x6d')](_0x58b552);}})[_0xb3fd('0x29')](function(_0x565c8d){if(_0x565c8d){return _0x565c8d?{'count':_0x220066,'rows':_0x565c8d}:null;}})[_0xb3fd('0x29')](respondWithResult(_0x3aad43,null))[_0xb3fd('0x52')](handleError(_0x3aad43,null));};exports['addTeams']=function(_0x41e636,_0xa132aa,_0x1a025c){var _0x33e4bd=_0x41e636['body'][_0xb3fd('0x6e')];var _0xbb1870=_[_0xb3fd('0x31')](_0x33e4bd,'id');return db[_0xb3fd('0x6f')][_0xb3fd('0x50')]({'where':{'id':_0xbb1870},'attributes':['id'],'include':[{'model':db['User'],'as':'Agents','attributes':['id',_0xb3fd('0x35'),_0xb3fd('0x70'),_0xb3fd('0x71'),_0xb3fd('0x72')],'raw':!![]}]})[_0xb3fd('0x29')](function(_0x5bdf08){if(_0x5bdf08){var _0x230beb=_[_0xb3fd('0x73')](_0x5bdf08,function(_0x5d0bf4){var _0x2cf093=_0x5d0bf4[_0xb3fd('0x2a')]({'plain':!![]});_0x2cf093[_0xb3fd('0x74')][_0xb3fd('0x75')](function(_0x897e23){_0x897e23['penalty']=_[_0xb3fd('0x34')](_0x33e4bd,{'id':_0x2cf093['id']})['penalty'];});return _0x2cf093[_0xb3fd('0x74')];});return db[_0xb3fd('0x3c')]['find']({'where':{'id':_0x41e636[_0xb3fd('0x5b')]['id']}})[_0xb3fd('0x29')](function(_0x5376c8){return db[_0xb3fd('0x76')][_0xb3fd('0x77')](function(_0x463479){return _0x5376c8['addTeams'](_0xbb1870,{'transaction':_0x463479})['then'](function(){return BPromise[_0xb3fd('0x78')](_0x33e4bd,function(_0xb3d03d){return db[_0xb3fd('0x79')]['upsert']({'TeamId':_0xb3d03d['id'],'VoiceQueueId':_0x41e636['params']['id'],'penalty':_0xb3d03d[_0xb3fd('0x7a')]},{'transaction':_0x463479});});})[_0xb3fd('0x29')](function(){return BPromise[_0xb3fd('0x78')](_0x230beb,function(_0x57af6a){return db['UserVoiceQueue'][_0xb3fd('0x7b')]({'where':{'UserId':_0x57af6a['id'],'VoiceQueueId':_0x41e636[_0xb3fd('0x5b')]['id']},'defaults':{'penalty':_0x57af6a[_0xb3fd('0x7a')]},'transaction':_0x463479});});})['then'](function(){return BPromise[_0xb3fd('0x78')](_[_0xb3fd('0x2f')](_0x230beb,{'online':!![]}),function(_0x564838){return db[_0xb3fd('0x7c')]['upsert']({'membername':_0x564838['name'],'UserId':_0x564838['id'],'queue_name':_0x5376c8[_0xb3fd('0x35')],'VoiceQueueId':_0x5376c8['id'],'interface':_[_0xb3fd('0x7d')](_0x564838[_0xb3fd('0x72')])?util[_0xb3fd('0x7e')](_0xb3fd('0x7f'),_0x564838['name']):_0x564838[_0xb3fd('0x72')],'paused':_0x564838[_0xb3fd('0x71')]||![],'penalty':_0x564838['penalty']},{'transaction':_0x463479});});})[_0xb3fd('0x29')](function(){_0x230beb['forEach'](function(_0xa47d43){socket[_0xb3fd('0x80')](_0xb3fd('0x81'),{'UserId':_0xa47d43['id'],'VoiceQueueId':_0x5376c8['id']});});});});});}})['then'](respondWithStatusCode(_0xa132aa,null))[_0xb3fd('0x52')](handleError(_0xa132aa,null));};exports['removeTeams']=function(_0x9788bf,_0x19a4cb,_0x5f51a2){return db[_0xb3fd('0x6f')][_0xb3fd('0x50')]({'where':{'id':_0x9788bf['query'][_0xb3fd('0x82')]},'attributes':['id'],'include':[{'model':db[_0xb3fd('0x83')],'as':_0xb3fd('0x74'),'attributes':['id'],'raw':!![]}]})[_0xb3fd('0x29')](handleEntityNotFound(_0x19a4cb,null))[_0xb3fd('0x29')](function(_0x4b9be3){var _0x5dc78c=_[_0xb3fd('0x31')](_0x4b9be3,'id');var _0x1453cc=[];var _0x2b9400=[];var _0x5ef26b=squel[_0xb3fd('0x84')]();_0x5ef26b[_0xb3fd('0x85')]('tq.TeamId')['from']('team_has_voice_queues','tq')[_0xb3fd('0x86')]('user_has_teams','ut','ut.TeamId\x20=\x20tq.TeamId')[_0xb3fd('0x49')](_0xb3fd('0x87'),_0x9788bf['params']['id']);for(var _0x43d669=0x0;_0x43d669<_0x4b9be3['length'];_0x43d669+=0x1){let _0x92bb8=_0x4b9be3[_0x43d669];for(var _0x29e5aa=0x0;_0x29e5aa<_0x92bb8[_0xb3fd('0x74')][_0xb3fd('0x47')];_0x29e5aa+=0x1){let _0x5c49e7=_0x92bb8[_0xb3fd('0x74')][_0x29e5aa];var _0xd3f381=_0x5ef26b['clone']();_0xd3f381[_0xb3fd('0x49')](_0xb3fd('0x88'),_0x5c49e7['id']);_0x2b9400[_0xb3fd('0x89')](db[_0xb3fd('0x76')][_0xb3fd('0x41')](_0xd3f381[_0xb3fd('0x8a')](),{'type':db['sequelize'][_0xb3fd('0x8b')][_0xb3fd('0x8c')]})[_0xb3fd('0x29')](function(_0x2e48d5){if(_0x2e48d5[_0xb3fd('0x47')]===0x1){return _0x5c49e7['id'];}else{var _0xdcebf4=_[_0xb3fd('0x8d')](_[_0xb3fd('0x31')](_0x2e48d5,_0xb3fd('0x8e')),function(_0x4186cd){return _['includes'](_0x5dc78c,_0x4186cd);});if(_0xdcebf4){return _0x5c49e7['id'];}}}));}}return BPromise[_0xb3fd('0x8f')](_0x2b9400)[_0xb3fd('0x29')](function(_0x281b4d){_0x1453cc=_(_0x1453cc)['union'](_0x281b4d)['compact']()[_0xb3fd('0x32')]();return db[_0xb3fd('0x3c')][_0xb3fd('0x34')]({'where':{'id':_0x9788bf[_0xb3fd('0x5b')]['id']}})[_0xb3fd('0x29')](function(_0x485949){return db[_0xb3fd('0x76')][_0xb3fd('0x77')](function(_0x539886){return _0x485949[_0xb3fd('0x90')](_0x9788bf[_0xb3fd('0x41')][_0xb3fd('0x82')],{'transaction':_0x539886})[_0xb3fd('0x29')](function(){if(!_['isEmpty'](_0x1453cc)){return _0x485949['removeAgents'](_0x1453cc,{'transaction':_0x539886})[_0xb3fd('0x29')](function(){return db['UserVoiceQueueRt']['destroy']({'where':{'VoiceQueueId':_0x9788bf[_0xb3fd('0x5b')]['id'],'UserId':_0x1453cc},'transaction':_0x539886});});}})[_0xb3fd('0x29')](function(){_0x1453cc[_0xb3fd('0x75')](function(_0x362b5e){socket[_0xb3fd('0x80')](_0xb3fd('0x91'),{'UserId':_0x362b5e,'VoiceQueueId':_0x485949['id']});});});});});});})['then'](respondWithStatusCode(_0x19a4cb,null))['catch'](handleError(_0x19a4cb,null));};exports[_0xb3fd('0x92')]=function(_0x15277a,_0x40d450,_0x28854a){var _0x5c899c,_0x3f8f7a;return db[_0xb3fd('0x3c')][_0xb3fd('0x34')]({'where':{'id':_0x15277a[_0xb3fd('0x5b')]['id']}})[_0xb3fd('0x29')](handleEntityNotFound(_0x40d450,null))[_0xb3fd('0x29')](function(_0x1dfb09){if(_0x1dfb09){_0x3f8f7a=_0x1dfb09;return _0x1dfb09[_0xb3fd('0x92')](_0x15277a[_0xb3fd('0x54')][_0xb3fd('0x82')],_[_0xb3fd('0x5c')](_0x15277a[_0xb3fd('0x54')],[_0xb3fd('0x82'),'id'])||{})[_0xb3fd('0x93')](function(_0x556a33){for(var _0x5a7235=0x0;_0x5a7235<_0x15277a[_0xb3fd('0x54')][_0xb3fd('0x82')][_0xb3fd('0x47')];_0x5a7235+=0x1){socket['emit'](_0xb3fd('0x81'),{'UserId':Number(_0x15277a[_0xb3fd('0x54')]['ids'][_0x5a7235]),'VoiceQueueId':Number(_0x15277a[_0xb3fd('0x5b')]['id'])});}return _0x556a33;});}})['then'](function(_0x908d92){_0x5c899c=_0x908d92||[];if(_0x3f8f7a){return db[_0xb3fd('0x83')][_0xb3fd('0x50')]({'where':{'id':_0x15277a[_0xb3fd('0x54')]['ids']},'attributes':['id',_0xb3fd('0x35'),_0xb3fd('0x70'),_0xb3fd('0x71'),_0xb3fd('0x72')],'raw':!![]});}})[_0xb3fd('0x29')](function(_0x16a324){if(!_['isEmpty'](_0x16a324)){var _0x45b085=[];for(var _0x4b79dc=0x0;_0x4b79dc<_0x16a324[_0xb3fd('0x47')];_0x4b79dc++){if(_0x16a324[_0x4b79dc]['online']){_0x45b085['push'](db['UserVoiceQueueRt']['upsert']({'membername':_0x16a324[_0x4b79dc][_0xb3fd('0x35')],'UserId':_0x16a324[_0x4b79dc]['id'],'queue_name':_0x3f8f7a['name'],'VoiceQueueId':_0x3f8f7a['id'],'interface':_[_0xb3fd('0x7d')](_0x16a324[_0x4b79dc][_0xb3fd('0x72')])?util[_0xb3fd('0x7e')](_0xb3fd('0x7f'),_0x16a324[_0x4b79dc][_0xb3fd('0x35')]):_0x16a324[_0x4b79dc][_0xb3fd('0x72')],'paused':_0x16a324[_0x4b79dc]['voicePause']||![],'penalty':_0x15277a['body']['penalty']||0x0}));}}return BPromise['all'](_0x45b085);}})[_0xb3fd('0x29')](function(){return _0x5c899c;})[_0xb3fd('0x29')](respondWithResult(_0x40d450,null))[_0xb3fd('0x52')](handleError(_0x40d450,null));};exports[_0xb3fd('0x94')]=function(_0x189d02,_0x1d8003,_0x168b10){return db[_0xb3fd('0x3c')]['find']({'where':{'id':_0x189d02['params']['id']}})['then'](handleEntityNotFound(_0x1d8003,null))[_0xb3fd('0x29')](function(_0x256597){if(_0x256597){return _0x256597[_0xb3fd('0x94')](_0x189d02[_0xb3fd('0x41')]['ids'])[_0xb3fd('0x29')](function(){if(_['isArray'](_0x189d02[_0xb3fd('0x41')][_0xb3fd('0x82')])){for(var _0x36755c=0x0;_0x36755c<_0x189d02[_0xb3fd('0x41')][_0xb3fd('0x82')]['length'];_0x36755c+=0x1){socket[_0xb3fd('0x80')](_0xb3fd('0x91'),{'UserId':Number(_0x189d02['query'][_0xb3fd('0x82')][_0x36755c]),'VoiceQueueId':Number(_0x189d02['params']['id'])});}}else{socket[_0xb3fd('0x80')](_0xb3fd('0x91'),{'UserId':Number(_0x189d02['query'][_0xb3fd('0x82')]),'VoiceQueueId':Number(_0x189d02[_0xb3fd('0x5b')]['id'])});}});}})[_0xb3fd('0x29')](function(_0x18324b){return db[_0xb3fd('0x7c')][_0xb3fd('0x37')]({'where':{'VoiceQueueId':_0x189d02['params']['id'],'UserId':_0x189d02[_0xb3fd('0x41')][_0xb3fd('0x82')]}})[_0xb3fd('0x29')](function(){return _0x18324b;});})[_0xb3fd('0x29')](respondWithStatusCode(_0x1d8003,null))['catch'](handleError(_0x1d8003,null));};exports['getAgents']=function(_0x10049d,_0x357612,_0x187c47){var _0x392353={};var _0x3ad565={};var _0xd1ada2;var _0x5c499a;return db['VoiceQueue'][_0xb3fd('0x61')]({'where':{'id':_0x10049d['params']['id']}})['then'](handleEntityNotFound(_0x357612,null))[_0xb3fd('0x29')](function(_0x152e5f){if(_0x152e5f){_0xd1ada2=_0x152e5f;_0x3ad565[_0xb3fd('0x40')]=_[_0xb3fd('0x42')](db[_0xb3fd('0x83')][_0xb3fd('0x3d')]);_0x3ad565[_0xb3fd('0x41')]=_[_0xb3fd('0x42')](_0x10049d['query']);_0x3ad565[_0xb3fd('0x43')]=_[_0xb3fd('0x44')](_0x3ad565['model'],_0x3ad565[_0xb3fd('0x41')]);_0x392353['attributes']=_[_0xb3fd('0x44')](_0x3ad565[_0xb3fd('0x40')],qs[_0xb3fd('0x45')](_0x10049d[_0xb3fd('0x41')]['fields']));_0x392353['attributes']=_0x392353['attributes'][_0xb3fd('0x47')]?_0x392353[_0xb3fd('0x46')]:_0x3ad565[_0xb3fd('0x40')];_0x392353[_0xb3fd('0x48')]=qs['sort'](_0x10049d[_0xb3fd('0x41')][_0xb3fd('0x64')]);_0x392353[_0xb3fd('0x49')]=qs[_0xb3fd('0x43')](_[_0xb3fd('0x4a')](_0x10049d[_0xb3fd('0x41')],_0x3ad565[_0xb3fd('0x43')]));if(_0x10049d[_0xb3fd('0x41')]['filter']){_0x392353[_0xb3fd('0x49')]=_[_0xb3fd('0x4b')](_0x392353[_0xb3fd('0x49')],{'$or':_[_0xb3fd('0x31')](_0x392353[_0xb3fd('0x46')],function(_0x59f024){var _0x2cc91b={};_0x2cc91b[_0x59f024]={'$like':'%'+_0x10049d[_0xb3fd('0x41')][_0xb3fd('0x2f')]+'%'};return _0x2cc91b;})});}_0x392353=_[_0xb3fd('0x4b')]({},_0x392353,_0x10049d['options']);return _0xd1ada2[_0xb3fd('0x95')](_0x392353);}})[_0xb3fd('0x29')](function(_0x378bf8){if(_0x378bf8){_0x5c499a=_0x378bf8[_0xb3fd('0x47')];if(!_0x10049d[_0xb3fd('0x41')]['hasOwnProperty']('nolimit')){_0x392353[_0xb3fd('0x20')]=qs[_0xb3fd('0x20')](_0x10049d[_0xb3fd('0x41')][_0xb3fd('0x20')]);_0x392353[_0xb3fd('0x1f')]=qs[_0xb3fd('0x1f')](_0x10049d[_0xb3fd('0x41')][_0xb3fd('0x1f')]);}return _0xd1ada2[_0xb3fd('0x95')](_0x392353);}})['then'](function(_0x3be443){if(_0x3be443){return _0x3be443?{'count':_0x5c499a,'rows':_0x3be443}:null;}})[_0xb3fd('0x29')](respondWithResult(_0x357612,null))['catch'](handleError(_0x357612,null));};exports[_0xb3fd('0x96')]=function(_0x29ad66,_0x270fbe,_0x3dcca2){var _0x43f3e3={};var _0x1c9cd6={};var _0x4d9185;var _0x2a9621;return db[_0xb3fd('0x3c')][_0xb3fd('0x61')]({'where':{'id':_0x29ad66[_0xb3fd('0x5b')]['id']}})[_0xb3fd('0x29')](handleEntityNotFound(_0x270fbe,null))[_0xb3fd('0x29')](function(_0x52e6a3){if(_0x52e6a3){_0x4d9185=_0x52e6a3;_0x1c9cd6[_0xb3fd('0x40')]=_['keys'](db[_0xb3fd('0x7c')][_0xb3fd('0x3d')]);_0x1c9cd6['query']=_[_0xb3fd('0x42')](_0x29ad66['query']);_0x1c9cd6['filters']=_[_0xb3fd('0x44')](_0x1c9cd6[_0xb3fd('0x40')],_0x1c9cd6[_0xb3fd('0x41')]);_0x43f3e3[_0xb3fd('0x46')]=_[_0xb3fd('0x44')](_0x1c9cd6['model'],qs[_0xb3fd('0x45')](_0x29ad66[_0xb3fd('0x41')][_0xb3fd('0x45')]));_0x43f3e3[_0xb3fd('0x46')]=_0x43f3e3[_0xb3fd('0x46')][_0xb3fd('0x47')]?_0x43f3e3['attributes']:_0x1c9cd6[_0xb3fd('0x40')];_0x43f3e3[_0xb3fd('0x48')]=qs[_0xb3fd('0x64')](_0x29ad66[_0xb3fd('0x41')]['sort']);_0x43f3e3[_0xb3fd('0x49')]=qs[_0xb3fd('0x43')](_[_0xb3fd('0x4a')](_0x29ad66[_0xb3fd('0x41')],_0x1c9cd6['filters']));if(_0x29ad66[_0xb3fd('0x41')][_0xb3fd('0x2f')]){_0x43f3e3['where']=_[_0xb3fd('0x4b')](_0x43f3e3[_0xb3fd('0x49')],{'$or':_[_0xb3fd('0x31')](_0x43f3e3[_0xb3fd('0x46')],function(_0x16d680){var _0x2fecf9={};_0x2fecf9[_0x16d680]={'$like':'%'+_0x29ad66['query']['filter']+'%'};return _0x2fecf9;})});}_0x43f3e3=_[_0xb3fd('0x4b')]({},_0x43f3e3,_0x29ad66[_0xb3fd('0x4d')]);return _0x4d9185[_0xb3fd('0x96')](_0x43f3e3);}})[_0xb3fd('0x29')](function(_0x54a8ff){if(_0x54a8ff){_0x2a9621=_0x54a8ff[_0xb3fd('0x47')];if(!_0x29ad66['query'][_0xb3fd('0x62')](_0xb3fd('0x63'))){_0x43f3e3[_0xb3fd('0x20')]=qs[_0xb3fd('0x20')](_0x29ad66[_0xb3fd('0x41')][_0xb3fd('0x20')]);_0x43f3e3[_0xb3fd('0x1f')]=qs[_0xb3fd('0x1f')](_0x29ad66[_0xb3fd('0x41')][_0xb3fd('0x1f')]);}return _0x4d9185[_0xb3fd('0x96')](_0x43f3e3);}})[_0xb3fd('0x29')](function(_0x96ed60){return _0x96ed60?{'count':_0x2a9621,'rows':_0x96ed60}:null;})[_0xb3fd('0x29')](respondWithResult(_0x270fbe,null))[_0xb3fd('0x52')](handleError(_0x270fbe,null));};exports[_0xb3fd('0x97')]=function(_0x189094,_0x15e6c7,_0xb5fd96){var _0x374740={};var _0x26466e={};var _0x1e65fb;var _0x47c8f7;return db[_0xb3fd('0x3c')][_0xb3fd('0x61')]({'where':{'id':_0x189094[_0xb3fd('0x5b')]['id']}})[_0xb3fd('0x29')](handleEntityNotFound(_0x15e6c7,null))[_0xb3fd('0x29')](function(_0x252460){if(_0x252460){_0x1e65fb=_0x252460;_0x26466e[_0xb3fd('0x40')]=_[_0xb3fd('0x42')](db[_0xb3fd('0x98')][_0xb3fd('0x3d')]);_0x26466e['query']=_[_0xb3fd('0x42')](_0x189094[_0xb3fd('0x41')]);_0x26466e['filters']=_[_0xb3fd('0x44')](_0x26466e[_0xb3fd('0x40')],_0x26466e['query']);_0x374740[_0xb3fd('0x46')]=_[_0xb3fd('0x44')](_0x26466e['model'],qs[_0xb3fd('0x45')](_0x189094[_0xb3fd('0x41')]['fields']));_0x374740[_0xb3fd('0x46')]=_0x374740[_0xb3fd('0x46')][_0xb3fd('0x47')]?_0x374740[_0xb3fd('0x46')]:_0x26466e[_0xb3fd('0x40')];_0x374740[_0xb3fd('0x48')]=qs[_0xb3fd('0x64')](_0x189094[_0xb3fd('0x41')][_0xb3fd('0x64')]);_0x374740['where']=qs[_0xb3fd('0x43')](_[_0xb3fd('0x4a')](_0x189094[_0xb3fd('0x41')],_0x26466e[_0xb3fd('0x43')]));if(_0x189094[_0xb3fd('0x41')]['filter']){_0x374740[_0xb3fd('0x49')]=_['merge'](_0x374740[_0xb3fd('0x49')],{'$or':_[_0xb3fd('0x31')](_0x374740['attributes'],function(_0x5230fe){var _0x38c996={};_0x38c996[_0x5230fe]={'$like':'%'+_0x189094[_0xb3fd('0x41')][_0xb3fd('0x2f')]+'%'};return _0x38c996;})});}_0x374740=_[_0xb3fd('0x4b')]({},_0x374740,_0x189094[_0xb3fd('0x4d')]);return _0x1e65fb[_0xb3fd('0x97')](_0x374740);}})[_0xb3fd('0x29')](function(_0x4164c6){if(_0x4164c6){_0x47c8f7=_0x4164c6[_0xb3fd('0x47')];if(!_0x189094[_0xb3fd('0x41')][_0xb3fd('0x62')](_0xb3fd('0x63'))){_0x374740[_0xb3fd('0x20')]=qs[_0xb3fd('0x20')](_0x189094['query'][_0xb3fd('0x20')]);_0x374740[_0xb3fd('0x1f')]=qs[_0xb3fd('0x1f')](_0x189094[_0xb3fd('0x41')][_0xb3fd('0x1f')]);}return _0x1e65fb[_0xb3fd('0x97')](_0x374740);}})['then'](function(_0x5afd00){if(_0x5afd00){return _0x5afd00?{'count':_0x47c8f7,'rows':_0x5afd00}:null;}})[_0xb3fd('0x29')](respondWithResult(_0x15e6c7,null))['catch'](handleError(_0x15e6c7,null));};exports[_0xb3fd('0x99')]=function(_0x45b62a,_0x475183,_0x49a16a){var _0xd8da4,_0x433675;return db['VoiceQueue'][_0xb3fd('0x34')]({'where':{'id':_0x45b62a['params']['id']}})[_0xb3fd('0x29')](handleEntityNotFound(_0x475183,null))[_0xb3fd('0x29')](function(_0xd23a50){if(_0xd23a50){_0x433675=_0xd23a50;return _0xd23a50[_0xb3fd('0x99')](_0x45b62a[_0xb3fd('0x54')][_0xb3fd('0x82')],_[_0xb3fd('0x5c')](_0x45b62a[_0xb3fd('0x54')],[_0xb3fd('0x82'),'id'])||{});}return null;})['spread'](function(_0x12d55b){var _0xb343c;_0xd8da4=_0x12d55b||[];var _0x335ed8=[];if(_0x12d55b){for(var _0x9d0ef3=0x0;_0x9d0ef3<_0x12d55b[_0xb3fd('0x47')];_0x9d0ef3+=0x1){var _0x458cfc=_0x12d55b[_0x9d0ef3][_0xb3fd('0x2a')]({'plain':!![]});_0x433675[_0xb3fd('0x9a')]=_0x45b62a[_0xb3fd('0x54')][_0xb3fd('0x9a')]?_0x45b62a[_0xb3fd('0x54')][_0xb3fd('0x9a')]:_0x433675[_0xb3fd('0x9a')];switch(_0x433675[_0xb3fd('0x9a')]){case _0xb3fd('0x9b'):_0xb343c=squel[_0xb3fd('0x9c')]()[_0xb3fd('0x9d')](_0xb3fd('0x9e'))[_0xb3fd('0x9f')]([_0xb3fd('0xa0'),_0xb3fd('0xa1'),_0xb3fd('0xa2'),'ListId',_0xb3fd('0x65'),_0xb3fd('0x5e'),_0xb3fd('0x5d')],squel[_0xb3fd('0x84')]()[_0xb3fd('0x85')](_0xb3fd('0xa0'),_0xb3fd('0xa0'))[_0xb3fd('0x85')](_0xb3fd('0xa3'),_0xb3fd('0xa1'))['field']('id',_0xb3fd('0xa2'))['field'](_0x458cfc[_0xb3fd('0xa4')]['toString'](),_0xb3fd('0xa5'))[_0xb3fd('0x85')](_0x45b62a[_0xb3fd('0x5b')]['id'][_0xb3fd('0x8a')](),_0xb3fd('0x65'))['field'](_0xb3fd('0xa3'),'createdAt')[_0xb3fd('0x85')](_0xb3fd('0xa3'),_0xb3fd('0x5d'))['from'](_0xb3fd('0xa6'))['where'](_0xb3fd('0xa7'))['where'](_0xb3fd('0xa8'),_0x458cfc[_0xb3fd('0xa4')]['toString']())['where'](_0xb3fd('0xa9'))[_0xb3fd('0x49')]('phone\x20NOT\x20IN\x20(?)',squel[_0xb3fd('0x84')]()['field'](_0xb3fd('0xaa'))[_0xb3fd('0xab')]('cm_hopper_final')['where']('VoiceQueueId\x20=\x20?',_0x45b62a['params']['id'][_0xb3fd('0x8a')]()))[_0xb3fd('0x49')]('phone\x20NOT\x20IN\x20(?)',squel[_0xb3fd('0x84')]()[_0xb3fd('0x85')](_0xb3fd('0xac'))[_0xb3fd('0xab')](_0xb3fd('0x9e'))[_0xb3fd('0x49')](_0xb3fd('0x87'),_0x45b62a['params']['id'][_0xb3fd('0x8a')]())))['toString']();break;case _0xb3fd('0xad'):_0xb343c=squel[_0xb3fd('0x9c')]()[_0xb3fd('0x9d')]('cm_hopper')[_0xb3fd('0x9f')]([_0xb3fd('0xa0'),_0xb3fd('0xa1'),_0xb3fd('0xa2'),_0xb3fd('0xa5'),_0xb3fd('0x65'),_0xb3fd('0x5e'),'updatedAt'],squel['select']()[_0xb3fd('0x85')](_0xb3fd('0xa0'),_0xb3fd('0xa0'))[_0xb3fd('0x85')](_0xb3fd('0xa3'),_0xb3fd('0xa1'))[_0xb3fd('0x85')]('id',_0xb3fd('0xa2'))[_0xb3fd('0x85')](_0x458cfc[_0xb3fd('0xa4')][_0xb3fd('0x8a')](),'ListId')[_0xb3fd('0x85')](_0x45b62a[_0xb3fd('0x5b')]['id'][_0xb3fd('0x8a')](),_0xb3fd('0x65'))[_0xb3fd('0x85')](_0xb3fd('0xa3'),_0xb3fd('0x5e'))['field']('NOW()',_0xb3fd('0x5d'))['from'](_0xb3fd('0xa6'))[_0xb3fd('0x49')](_0xb3fd('0xa7'))[_0xb3fd('0x49')](_0xb3fd('0xa8'),_0x458cfc[_0xb3fd('0xa4')][_0xb3fd('0x8a')]())[_0xb3fd('0x49')]('phone\x20IS\x20NOT\x20NULL')[_0xb3fd('0x49')](_0xb3fd('0xae'),squel[_0xb3fd('0x84')]()[_0xb3fd('0x85')](_0xb3fd('0xac'))[_0xb3fd('0xab')](_0xb3fd('0x9e'))[_0xb3fd('0x49')]('VoiceQueueId\x20=\x20?',_0x45b62a[_0xb3fd('0x5b')]['id'][_0xb3fd('0x8a')]())))[_0xb3fd('0x8a')]();break;default:_0xb343c=squel['insert']()[_0xb3fd('0x9d')](_0xb3fd('0x9e'))[_0xb3fd('0x9f')]([_0xb3fd('0xa0'),_0xb3fd('0xa1'),_0xb3fd('0xa2'),_0xb3fd('0xa5'),_0xb3fd('0x65'),_0xb3fd('0x5e'),'updatedAt'],squel[_0xb3fd('0x84')]()['field'](_0xb3fd('0xa0'),'phone')[_0xb3fd('0x85')](_0xb3fd('0xa3'),'scheduledAt')[_0xb3fd('0x85')]('id','ContactId')[_0xb3fd('0x85')](_0x458cfc[_0xb3fd('0xa4')]['toString'](),'ListId')[_0xb3fd('0x85')](_0x45b62a[_0xb3fd('0x5b')]['id'][_0xb3fd('0x8a')](),_0xb3fd('0x65'))[_0xb3fd('0x85')](_0xb3fd('0xa3'),_0xb3fd('0x5e'))[_0xb3fd('0x85')](_0xb3fd('0xa3'),_0xb3fd('0x5d'))[_0xb3fd('0xab')](_0xb3fd('0xa6'))[_0xb3fd('0x49')]('deletedAt\x20IS\x20NULL')['where'](_0xb3fd('0xa8'),_0x458cfc[_0xb3fd('0xa4')]['toString']())[_0xb3fd('0x49')]('phone\x20IS\x20NOT\x20NULL'))['toString']();}_0x335ed8[_0xb3fd('0x89')](db['sequelize'][_0xb3fd('0x41')](_0xb343c));}return BPromise[_0xb3fd('0x8f')](_0x335ed8);}})['then'](function(){return _0xd8da4;})[_0xb3fd('0x29')](respondWithResult(_0x475183,null))[_0xb3fd('0x52')](handleError(_0x475183,null));};exports['removeLists']=function(_0x1177cc,_0x17ad48,_0x6d049e){return db['VoiceQueue']['find']({'where':{'id':_0x1177cc[_0xb3fd('0x5b')]['id']}})[_0xb3fd('0x29')](handleEntityNotFound(_0x17ad48,null))[_0xb3fd('0x29')](function(_0x23e58e){if(_0x23e58e){return _0x23e58e['removeLists'](_0x1177cc['query'][_0xb3fd('0x82')]);}})[_0xb3fd('0x29')](function(_0x3b696b){if(_0x3b696b){return db[_0xb3fd('0x66')][_0xb3fd('0x37')]({'where':{'ListId':_0x1177cc[_0xb3fd('0x41')]['ids'],'VoiceQueueId':_0x1177cc['params']['id']}})[_0xb3fd('0x29')](function(){return _0x3b696b;});}})[_0xb3fd('0x29')](respondWithStatusCode(_0x17ad48,null))[_0xb3fd('0x52')](handleError(_0x17ad48,null));};exports[_0xb3fd('0xaf')]=function(_0x42dde0,_0xc82fa5,_0x2776ff){var _0x184399={};var _0x44fee2={};var _0x264819;var _0x30af0f;return db[_0xb3fd('0x3c')][_0xb3fd('0x61')]({'where':{'id':_0x42dde0[_0xb3fd('0x5b')]['id']}})['then'](handleEntityNotFound(_0xc82fa5,null))[_0xb3fd('0x29')](function(_0x1b76ff){if(_0x1b76ff){_0x264819=_0x1b76ff;_0x44fee2[_0xb3fd('0x40')]=_['keys'](db[_0xb3fd('0x98')][_0xb3fd('0x3d')]);_0x44fee2[_0xb3fd('0x41')]=_['keys'](_0x42dde0[_0xb3fd('0x41')]);_0x44fee2[_0xb3fd('0x43')]=_[_0xb3fd('0x44')](_0x44fee2[_0xb3fd('0x40')],_0x44fee2[_0xb3fd('0x41')]);_0x184399['attributes']=_['intersection'](_0x44fee2['model'],qs[_0xb3fd('0x45')](_0x42dde0[_0xb3fd('0x41')][_0xb3fd('0x45')]));_0x184399[_0xb3fd('0x46')]=_0x184399[_0xb3fd('0x46')][_0xb3fd('0x47')]?_0x184399[_0xb3fd('0x46')]:_0x44fee2['model'];_0x184399[_0xb3fd('0x48')]=qs[_0xb3fd('0x64')](_0x42dde0[_0xb3fd('0x41')][_0xb3fd('0x64')]);_0x184399['where']=qs[_0xb3fd('0x43')](_[_0xb3fd('0x4a')](_0x42dde0[_0xb3fd('0x41')],_0x44fee2[_0xb3fd('0x43')]));if(_0x42dde0[_0xb3fd('0x41')]['filter']){_0x184399[_0xb3fd('0x49')]=_[_0xb3fd('0x4b')](_0x184399[_0xb3fd('0x49')],{'$or':_[_0xb3fd('0x31')](_0x184399[_0xb3fd('0x46')],function(_0x448210){var _0x95eb46={};_0x95eb46[_0x448210]={'$like':'%'+_0x42dde0[_0xb3fd('0x41')][_0xb3fd('0x2f')]+'%'};return _0x95eb46;})});}_0x184399=_[_0xb3fd('0x4b')]({},_0x184399,_0x42dde0[_0xb3fd('0x4d')]);return _0x264819[_0xb3fd('0xaf')](_0x184399);}})[_0xb3fd('0x29')](function(_0x559e77){if(_0x559e77){_0x30af0f=_0x559e77[_0xb3fd('0x47')];if(!_0x42dde0[_0xb3fd('0x41')][_0xb3fd('0x62')](_0xb3fd('0x63'))){_0x184399[_0xb3fd('0x20')]=qs['limit'](_0x42dde0[_0xb3fd('0x41')][_0xb3fd('0x20')]);_0x184399[_0xb3fd('0x1f')]=qs['offset'](_0x42dde0['query'][_0xb3fd('0x1f')]);}return _0x264819[_0xb3fd('0xaf')](_0x184399);}})['then'](function(_0x5d0ea5){if(_0x5d0ea5){return _0x5d0ea5?{'count':_0x30af0f,'rows':_0x5d0ea5}:null;}})['then'](respondWithResult(_0xc82fa5,null))[_0xb3fd('0x52')](handleError(_0xc82fa5,null));};exports[_0xb3fd('0xb0')]=function(_0x31b06d,_0x424872,_0x16896c){var _0x424194,_0x5498bc;return db[_0xb3fd('0x3c')][_0xb3fd('0x34')]({'where':{'id':_0x31b06d[_0xb3fd('0x5b')]['id']}})['then'](handleEntityNotFound(_0x424872,null))[_0xb3fd('0x29')](function(_0xe28ee2){if(_0xe28ee2){_0x5498bc=_0xe28ee2;return _0xe28ee2[_0xb3fd('0xb0')](_0x31b06d[_0xb3fd('0x54')]['ids'],_['omit'](_0x31b06d[_0xb3fd('0x54')],[_0xb3fd('0x82'),'id'])||{});}return null;})['spread'](function(_0x51765e){var _0x2cc5e5;_0x424194=_0x51765e||[];var _0x5cf9ea=[];if(_0x51765e){for(var _0x486275=0x0;_0x486275<_0x51765e[_0xb3fd('0x47')];_0x486275+=0x1){var _0x31d2dc=_0x51765e[_0x486275][_0xb3fd('0x2a')]({'plain':!![]});_0x2cc5e5=squel['insert']()[_0xb3fd('0x9d')](_0xb3fd('0xb1'))[_0xb3fd('0x9f')]([_0xb3fd('0xa0'),_0xb3fd('0xa2'),_0xb3fd('0xa5'),_0xb3fd('0x65'),_0xb3fd('0x5e'),'updatedAt'],squel[_0xb3fd('0x84')]()[_0xb3fd('0x85')](_0xb3fd('0xa0'),_0xb3fd('0xa0'))[_0xb3fd('0x85')]('id','ContactId')[_0xb3fd('0x85')](_0x31d2dc[_0xb3fd('0xa4')][_0xb3fd('0x8a')](),_0xb3fd('0xa5'))[_0xb3fd('0x85')](_0x31b06d['params']['id']['toString'](),_0xb3fd('0x65'))['field'](_0xb3fd('0xa3'),_0xb3fd('0x5e'))[_0xb3fd('0x85')](_0xb3fd('0xa3'),_0xb3fd('0x5d'))['from'](_0xb3fd('0xa6'))[_0xb3fd('0x49')](_0xb3fd('0xa7'))[_0xb3fd('0x49')](_0xb3fd('0xa8'),_0x31d2dc[_0xb3fd('0xa4')][_0xb3fd('0x8a')]())['where'](_0xb3fd('0xa9')))[_0xb3fd('0x8a')]();_0x5cf9ea[_0xb3fd('0x89')](db['sequelize'][_0xb3fd('0x41')](_0x2cc5e5));}return BPromise[_0xb3fd('0x8f')](_0x5cf9ea);}})[_0xb3fd('0x29')](function(){return _0x424194;})[_0xb3fd('0x29')](respondWithResult(_0x424872,null))[_0xb3fd('0x52')](handleError(_0x424872,null));};exports[_0xb3fd('0xb2')]=function(_0x24cf2f,_0x2a9343,_0x289c50){return db[_0xb3fd('0x3c')]['find']({'where':{'id':_0x24cf2f['params']['id']}})[_0xb3fd('0x29')](handleEntityNotFound(_0x2a9343,null))[_0xb3fd('0x29')](function(_0x532664){if(_0x532664){return _0x532664[_0xb3fd('0xb2')](_0x24cf2f[_0xb3fd('0x41')][_0xb3fd('0x82')]);}})[_0xb3fd('0x29')](function(_0xe1d190){if(_0xe1d190){return db[_0xb3fd('0x6c')][_0xb3fd('0x37')]({'where':{'ListId':_0x24cf2f['query'][_0xb3fd('0x82')],'VoiceQueueId':_0x24cf2f['params']['id']}})['then'](function(){return _0xe1d190;});}})[_0xb3fd('0x29')](respondWithStatusCode(_0x2a9343,null))[_0xb3fd('0x52')](handleError(_0x2a9343,null));};
\ No newline at end of file