Built motion from commit d5e4af8c.|2.6.23
[motion2.git] / server / api / voiceQueue / voiceQueue.controller.js
index 329845c..6435dbc 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xb3f9=['VIRTUAL','merge','options','includeAll','include','catch','show','create','body','user','role','inbound','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','clone','params','omit','createdAt','updatedAt','QueueCampaigns','UserProfileSection','update','getHoppers','findOne','CmHopper','nolimit','pick','findAll','getHopperHistories','CmHopperHistory','VoiceQueueId','rows','CmHopperFinal','getHopperBlacks','CmHopperBlack','Team','getTeams','addTeams','Agents','online','voicePause','flatMap','forEach','penalty','sequelize','TeamVoiceQueue','each','UserVoiceQueue','findOrCreate','UserVoiceQueueRt','upsert','isNil','format','SIP/%s','emit','userVoiceQueue:save','removeTeams','User','select','field','from','team_has_voice_queues','user_has_teams','ut.TeamId\x20=\x20tq.TeamId','VoiceQueueId\x20=\x20?','ut.UserId\x20=\x20?','push','QueryTypes','SELECT','all','union','compact','transaction','ids','isEmpty','removeAgents','userVoiceQueue:remove','addAgents','interface','isArray','getAgents','getLists','CmList','addLists','spread','dialCheckDuplicateType','always','into','cm_hopper','fromQuery','phone','scheduledAt','ContactId','CmListId','toString','cm_contacts','deletedAt\x20IS\x20NULL','phone\x20IS\x20NOT\x20NULL','phone\x20NOT\x20IN\x20(?)','cm_hopper_final','COALESCE(phone,\x27\x27)','onlyIfOpen','insert','ListId','cm_hopper_additional_phones','CmHopperId','OrderBy','h.id','ci.item','ci.OrderBy+1','cm_contact_has_items','join','h.scheduledat=?','ci.ItemClass=?','PHONE','removeLists','getBlackLists','addBlackLists','NOW()','ListId\x20=\x20?','removeBlackLists','eml-format','rimraf','request-promise','bluebird','mustache','util','path','sox','to-csv','lodash','squel','jsforce','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','defaults','localhost','./voiceQueue.socket','register','status','json','offset','undefined','limit','count','set','Content-Range','apply','reject','then','destroy','get','VoiceQueues','outbound','filter','map','value','includes','type','find','name','UserProfileResource','end','error','stack','send','index','VoiceQueue','rawAttributes','fieldName','key','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','order','sort','where'];(function(_0xcc956e,_0x5b8076){var _0x352d62=function(_0x5e7a59){while(--_0x5e7a59){_0xcc956e['push'](_0xcc956e['shift']());}};_0x352d62(++_0x5b8076);}(_0xb3f9,0x7a));var _0x9b3f=function(_0xb1b3a6,_0x38623f){_0xb1b3a6=_0xb1b3a6-0x0;var _0x4e074e=_0xb3f9[_0xb1b3a6];return _0x4e074e;};'use strict';var emlformat=require(_0x9b3f('0x0'));var rimraf=require(_0x9b3f('0x1'));var zipdir=require('zip-dir');var jsonpatch=require('fast-json-patch');var rp=require(_0x9b3f('0x2'));var moment=require('moment');var BPromise=require(_0x9b3f('0x3'));var Mustache=require(_0x9b3f('0x4'));var util=require(_0x9b3f('0x5'));var path=require(_0x9b3f('0x6'));var sox=require(_0x9b3f('0x7'));var csv=require(_0x9b3f('0x8'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x9b3f('0x9'));var squel=require(_0x9b3f('0xa'));var crypto=require('crypto');var jsforce=require(_0x9b3f('0xb'));var deskjs=require('desk.js');var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require(_0x9b3f('0xc'));var Redis=require('ioredis');var authService=require(_0x9b3f('0xd'));var qs=require(_0x9b3f('0xe'));var as=require(_0x9b3f('0xf'));var hardwareService=require(_0x9b3f('0x10'));var logger=require(_0x9b3f('0x11'))('api');var utils=require(_0x9b3f('0x12'));var config=require(_0x9b3f('0x13'));var licenseUtil=require(_0x9b3f('0x14'));var db=require(_0x9b3f('0x15'))['db'];config[_0x9b3f('0x16')]=_[_0x9b3f('0x17')](config[_0x9b3f('0x16')],{'host':_0x9b3f('0x18'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config['redis']));require(_0x9b3f('0x19'))[_0x9b3f('0x1a')](socket);function respondWithStatusCode(_0x27dab5,_0x377bfa){_0x377bfa=_0x377bfa||0xcc;return function(_0x76978e){if(_0x76978e){return _0x27dab5['sendStatus'](_0x377bfa);}return _0x27dab5['status'](_0x377bfa)['end']();};}function respondWithResult(_0x34fb19,_0x427992){_0x427992=_0x427992||0xc8;return function(_0x484323){if(_0x484323){return _0x34fb19[_0x9b3f('0x1b')](_0x427992)[_0x9b3f('0x1c')](_0x484323);}};}function respondWithFilteredResult(_0x2cdc7c,_0x5f5c1c){return function(_0x579c32){if(_0x579c32){var _0x2f2a53=typeof _0x5f5c1c[_0x9b3f('0x1d')]===_0x9b3f('0x1e')&&typeof _0x5f5c1c[_0x9b3f('0x1f')]===_0x9b3f('0x1e');var _0x297fa8=_0x579c32[_0x9b3f('0x20')];var _0x17f2d3=_0x2f2a53?0x0:_0x5f5c1c[_0x9b3f('0x1d')];var _0x13e65b=_0x2f2a53?_0x579c32[_0x9b3f('0x20')]:_0x5f5c1c[_0x9b3f('0x1d')]+_0x5f5c1c[_0x9b3f('0x1f')];var _0x1218c0;if(_0x13e65b>=_0x297fa8){_0x13e65b=_0x297fa8;_0x1218c0=0xc8;}else{_0x1218c0=0xce;}_0x2cdc7c[_0x9b3f('0x1b')](_0x1218c0);return _0x2cdc7c[_0x9b3f('0x21')](_0x9b3f('0x22'),_0x17f2d3+'-'+_0x13e65b+'/'+_0x297fa8)[_0x9b3f('0x1c')](_0x579c32);}return null;};}function patchUpdates(_0x3360d6){return function(_0x5b4f21){try{jsonpatch[_0x9b3f('0x23')](_0x5b4f21,_0x3360d6,!![]);}catch(_0x4db496){return BPromise[_0x9b3f('0x24')](_0x4db496);}return _0x5b4f21['save']();};}function saveUpdates(_0x3c9d8d,_0x28dd96){return function(_0x16452e){if(_0x16452e){return _0x16452e['update'](_0x3c9d8d)[_0x9b3f('0x25')](function(_0x483eb3){return _0x483eb3;});}return null;};}function removeEntity(_0x325c74,_0x526355){return function(_0x1b3ba8){if(_0x1b3ba8){return _0x1b3ba8[_0x9b3f('0x26')]()['then'](function(){var _0x248c9d=_0x1b3ba8[_0x9b3f('0x27')]({'plain':!![]});var _0x2dfef4=[{'name':_0x9b3f('0x28'),'value':'inbound','ignore':![]},{'name':'QueueCampaigns','value':_0x9b3f('0x29'),'ignore':![]}];var _0x555bf4=_(_0x2dfef4)[_0x9b3f('0x2a')]('ignore')[_0x9b3f('0x2b')](_0x9b3f('0x2c'))[_0x9b3f('0x2c')]();if(_[_0x9b3f('0x2d')](_0x555bf4,_0x248c9d[_0x9b3f('0x2e')])){return;}var _0x590e9c=_[_0x9b3f('0x2f')](_0x2dfef4,[_0x9b3f('0x2c'),_0x248c9d[_0x9b3f('0x2e')]])[_0x9b3f('0x30')];return db[_0x9b3f('0x31')][_0x9b3f('0x26')]({'where':{'type':_0x590e9c,'resourceId':_0x248c9d['id']}})[_0x9b3f('0x25')](function(){return _0x1b3ba8;});})['then'](function(){_0x325c74['status'](0xcc)[_0x9b3f('0x32')]();});}};}function handleEntityNotFound(_0x4ddecb,_0x53bf78){return function(_0x20b019){if(!_0x20b019){_0x4ddecb['sendStatus'](0x194);}return _0x20b019;};}function handleError(_0x44dab3,_0x1a123a){_0x1a123a=_0x1a123a||0x1f4;return function(_0x294506){logger[_0x9b3f('0x33')](_0x294506[_0x9b3f('0x34')]);if(_0x294506['name']){delete _0x294506[_0x9b3f('0x30')];}_0x44dab3[_0x9b3f('0x1b')](_0x1a123a)[_0x9b3f('0x35')](_0x294506);};}exports[_0x9b3f('0x36')]=function(_0x378e87,_0x365df5){var _0x5c7a9d={},_0x1ae307={},_0x4082cb={'count':0x0,'rows':[]};var _0x222118=_['map'](db[_0x9b3f('0x37')][_0x9b3f('0x38')],function(_0x23d4d6){return{'name':_0x23d4d6[_0x9b3f('0x39')],'type':_0x23d4d6[_0x9b3f('0x2e')][_0x9b3f('0x3a')]};});_0x1ae307[_0x9b3f('0x3b')]=_[_0x9b3f('0x2b')](_0x222118,_0x9b3f('0x30'));_0x1ae307[_0x9b3f('0x3c')]=_[_0x9b3f('0x3d')](_0x378e87[_0x9b3f('0x3c')]);_0x1ae307[_0x9b3f('0x3e')]=_[_0x9b3f('0x3f')](_0x1ae307[_0x9b3f('0x3b')],_0x1ae307['query']);_0x5c7a9d[_0x9b3f('0x40')]=_[_0x9b3f('0x3f')](_0x1ae307[_0x9b3f('0x3b')],qs[_0x9b3f('0x41')](_0x378e87[_0x9b3f('0x3c')][_0x9b3f('0x41')]));_0x5c7a9d[_0x9b3f('0x40')]=_0x5c7a9d['attributes'][_0x9b3f('0x42')]?_0x5c7a9d[_0x9b3f('0x40')]:_0x1ae307['model'];if(!_0x378e87[_0x9b3f('0x3c')][_0x9b3f('0x43')]('nolimit')){_0x5c7a9d[_0x9b3f('0x1f')]=qs[_0x9b3f('0x1f')](_0x378e87[_0x9b3f('0x3c')]['limit']);_0x5c7a9d[_0x9b3f('0x1d')]=qs[_0x9b3f('0x1d')](_0x378e87[_0x9b3f('0x3c')][_0x9b3f('0x1d')]);}_0x5c7a9d[_0x9b3f('0x44')]=qs['sort'](_0x378e87['query'][_0x9b3f('0x45')]);_0x5c7a9d[_0x9b3f('0x46')]=qs['filters'](_['pick'](_0x378e87[_0x9b3f('0x3c')],_0x1ae307['filters']),_0x222118);if(_0x378e87[_0x9b3f('0x3c')]['filter']){_0x5c7a9d[_0x9b3f('0x46')]=_['merge'](_0x5c7a9d['where'],{'$or':_[_0x9b3f('0x2b')](_0x222118,function(_0x3ff5f5){if(_0x3ff5f5[_0x9b3f('0x2e')]!==_0x9b3f('0x47')){var _0x588e84={};_0x588e84[_0x3ff5f5['name']]={'$like':'%'+_0x378e87[_0x9b3f('0x3c')]['filter']+'%'};return _0x588e84;}})});}_0x5c7a9d=_[_0x9b3f('0x48')]({},_0x5c7a9d,_0x378e87[_0x9b3f('0x49')]);var _0x503210={'where':_0x5c7a9d[_0x9b3f('0x46')]};return db[_0x9b3f('0x37')][_0x9b3f('0x20')](_0x503210)[_0x9b3f('0x25')](function(_0x5bb2a7){_0x4082cb[_0x9b3f('0x20')]=_0x5bb2a7;if(_0x378e87[_0x9b3f('0x3c')][_0x9b3f('0x4a')]){_0x5c7a9d[_0x9b3f('0x4b')]=[{'all':!![]}];}return db[_0x9b3f('0x37')]['findAll'](_0x5c7a9d);})[_0x9b3f('0x25')](function(_0x2cb8e0){_0x4082cb['rows']=_0x2cb8e0;return _0x4082cb;})[_0x9b3f('0x25')](respondWithFilteredResult(_0x365df5,_0x5c7a9d))[_0x9b3f('0x4c')](handleError(_0x365df5,null));};exports[_0x9b3f('0x4d')]=function(_0x735da1,_0x2efc70){var _0xdf1738={'raw':![],'where':{'id':_0x735da1['params']['id']}},_0x24d87c={};_0x24d87c[_0x9b3f('0x3b')]=_[_0x9b3f('0x3d')](db[_0x9b3f('0x37')][_0x9b3f('0x38')]);_0x24d87c[_0x9b3f('0x3c')]=_[_0x9b3f('0x3d')](_0x735da1[_0x9b3f('0x3c')]);_0x24d87c[_0x9b3f('0x3e')]=_[_0x9b3f('0x3f')](_0x24d87c['model'],_0x24d87c[_0x9b3f('0x3c')]);_0xdf1738['attributes']=_[_0x9b3f('0x3f')](_0x24d87c[_0x9b3f('0x3b')],qs[_0x9b3f('0x41')](_0x735da1[_0x9b3f('0x3c')]['fields']));_0xdf1738[_0x9b3f('0x40')]=_0xdf1738[_0x9b3f('0x40')][_0x9b3f('0x42')]?_0xdf1738[_0x9b3f('0x40')]:_0x24d87c['model'];if(_0x735da1['query']['includeAll']){_0xdf1738['include']=[{'all':!![]}];}_0xdf1738=_[_0x9b3f('0x48')]({},_0xdf1738,_0x735da1[_0x9b3f('0x49')]);return db[_0x9b3f('0x37')][_0x9b3f('0x2f')](_0xdf1738)[_0x9b3f('0x25')](handleEntityNotFound(_0x2efc70,null))['then'](respondWithResult(_0x2efc70,null))[_0x9b3f('0x4c')](handleError(_0x2efc70,null));};exports['create']=function(_0x330975,_0x3c6950){return db['VoiceQueue'][_0x9b3f('0x4e')](_0x330975[_0x9b3f('0x4f')],{})[_0x9b3f('0x25')](function(_0x42b751){var _0x36320e=_0x330975[_0x9b3f('0x50')][_0x9b3f('0x27')]({'plain':!![]});if(!_0x36320e)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x36320e[_0x9b3f('0x51')]==='user'){var _0x9503f0=_0x42b751[_0x9b3f('0x27')]({'plain':!![]});var _0x7839f9=[{'name':_0x9b3f('0x28'),'value':_0x9b3f('0x52')},{'name':'QueueCampaigns','value':_0x9b3f('0x29')}];var _0xbea8cb=_['find'](_0x7839f9,[_0x9b3f('0x2c'),_0x9503f0[_0x9b3f('0x2e')]])[_0x9b3f('0x30')];return db['UserProfileSection'][_0x9b3f('0x2f')]({'where':{'name':_0xbea8cb,'userProfileId':_0x36320e[_0x9b3f('0x53')]},'raw':!![]})['then'](function(_0x4652c4){if(_0x4652c4&&_0x4652c4[_0x9b3f('0x54')]===0x0){return db[_0x9b3f('0x31')][_0x9b3f('0x4e')]({'name':_0x9503f0[_0x9b3f('0x30')],'resourceId':_0x9503f0['id'],'type':_0x4652c4['name'],'sectionId':_0x4652c4['id']},{})[_0x9b3f('0x25')](function(){return _0x42b751;});}else{return _0x42b751;}})[_0x9b3f('0x4c')](function(_0x36eb9c){logger[_0x9b3f('0x33')](_0x9b3f('0x55'),_0x36eb9c);throw _0x36eb9c;});}return _0x42b751;})[_0x9b3f('0x25')](respondWithResult(_0x3c6950,0xc9))[_0x9b3f('0x4c')](handleError(_0x3c6950,null));};exports[_0x9b3f('0x56')]=function(_0x323c6d,_0x3dd4fc){var _0x2dc3b2={'where':{'id':_0x323c6d[_0x9b3f('0x57')]['id']}},_0x11011e={};_0x11011e[_0x9b3f('0x3b')]=_[_0x9b3f('0x3d')](db['VoiceQueue'][_0x9b3f('0x38')]);_0x2dc3b2[_0x9b3f('0x40')]=_[_0x9b3f('0x3f')](_0x11011e[_0x9b3f('0x3b')],qs[_0x9b3f('0x41')](_0x323c6d[_0x9b3f('0x3c')][_0x9b3f('0x41')]));_0x2dc3b2[_0x9b3f('0x40')]=_0x2dc3b2['attributes'][_0x9b3f('0x42')]?_0x2dc3b2['attributes']:_0x11011e[_0x9b3f('0x3b')];if(_0x323c6d[_0x9b3f('0x3c')][_0x9b3f('0x4a')]){_0x2dc3b2[_0x9b3f('0x4b')]=[{'all':!![]}];}_0x2dc3b2=_[_0x9b3f('0x48')]({},_0x2dc3b2,_0x323c6d[_0x9b3f('0x49')]);return db[_0x9b3f('0x37')][_0x9b3f('0x2f')](_0x2dc3b2)[_0x9b3f('0x25')](handleEntityNotFound(_0x3dd4fc,null))[_0x9b3f('0x25')](function(_0x51adab){if(_0x51adab){var _0x461999=_0x51adab[_0x9b3f('0x27')]({'plain':!![]});_0x461999=qs[_0x9b3f('0x58')](_0x461999,['id',_0x9b3f('0x59'),_0x9b3f('0x5a')]);_0x323c6d['body']=_[_0x9b3f('0x58')](_0x323c6d[_0x9b3f('0x4f')],['id','createdAt',_0x9b3f('0x5a')]);return db['VoiceQueue']['create'](_['merge'](_0x461999,_0x323c6d['body']),{'include':_0x323c6d[_0x9b3f('0x3c')][_0x9b3f('0x4a')]?[{'all':!![]}]:undefined})['then'](function(_0x514aac){var _0x24a45a=_0x323c6d[_0x9b3f('0x50')][_0x9b3f('0x27')]({'plain':!![]});if(!_0x24a45a)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x24a45a[_0x9b3f('0x51')]==='user'){var _0x4b0575=_0x514aac['get']({'plain':!![]});var _0x56631b=[{'name':'VoiceQueues','value':_0x9b3f('0x52')},{'name':_0x9b3f('0x5b'),'value':_0x9b3f('0x29')}];var _0x1bfaad=_[_0x9b3f('0x2f')](_0x56631b,[_0x9b3f('0x2c'),_0x4b0575[_0x9b3f('0x2e')]])['name'];return db[_0x9b3f('0x5c')][_0x9b3f('0x2f')]({'where':{'name':_0x1bfaad,'userProfileId':_0x24a45a[_0x9b3f('0x53')]},'raw':!![]})[_0x9b3f('0x25')](function(_0x44ec13){if(_0x44ec13&&_0x44ec13['autoAssociation']===0x0){return db['UserProfileResource'][_0x9b3f('0x4e')]({'name':_0x4b0575[_0x9b3f('0x30')],'resourceId':_0x4b0575['id'],'type':_0x44ec13['name'],'sectionId':_0x44ec13['id']},{})[_0x9b3f('0x25')](function(){return _0x514aac;});}else{return _0x514aac;}})[_0x9b3f('0x4c')](function(_0x3fdfe9){logger[_0x9b3f('0x33')](_0x9b3f('0x55'),_0x3fdfe9);throw _0x3fdfe9;});}return _0x514aac;});}})['then'](respondWithResult(_0x3dd4fc,0xc9))[_0x9b3f('0x4c')](handleError(_0x3dd4fc,null));};exports[_0x9b3f('0x5d')]=function(_0x41fff0,_0x430570){if(_0x41fff0['body']['id']){delete _0x41fff0[_0x9b3f('0x4f')]['id'];}return db[_0x9b3f('0x37')][_0x9b3f('0x2f')]({'where':{'id':_0x41fff0['params']['id']}})[_0x9b3f('0x25')](handleEntityNotFound(_0x430570,null))['then'](saveUpdates(_0x41fff0[_0x9b3f('0x4f')],null))[_0x9b3f('0x25')](respondWithResult(_0x430570,null))[_0x9b3f('0x4c')](handleError(_0x430570,null));};exports[_0x9b3f('0x26')]=function(_0x39fdb1,_0x25b2a5){return db[_0x9b3f('0x37')][_0x9b3f('0x2f')]({'where':{'id':_0x39fdb1[_0x9b3f('0x57')]['id']}})[_0x9b3f('0x25')](handleEntityNotFound(_0x25b2a5,null))[_0x9b3f('0x25')](removeEntity(_0x25b2a5,null))[_0x9b3f('0x4c')](handleError(_0x25b2a5,null));};exports[_0x9b3f('0x5e')]=function(_0x37d719,_0x2896de,_0x43751c){var _0x479657={'raw':![],'where':{}};var _0x5ab9f4={};var _0xca9f52={'count':0x0,'rows':[]};return db[_0x9b3f('0x37')][_0x9b3f('0x5f')]({'where':{'id':_0x37d719[_0x9b3f('0x57')]['id']}})[_0x9b3f('0x25')](handleEntityNotFound(_0x2896de,null))[_0x9b3f('0x25')](function(_0x3b2b87){if(_0x3b2b87){_0x5ab9f4[_0x9b3f('0x3b')]=_['keys'](db[_0x9b3f('0x60')][_0x9b3f('0x38')]);_0x5ab9f4[_0x9b3f('0x3c')]=_[_0x9b3f('0x3d')](_0x37d719[_0x9b3f('0x3c')]);_0x5ab9f4[_0x9b3f('0x3e')]=_[_0x9b3f('0x3f')](_0x5ab9f4[_0x9b3f('0x3b')],_0x5ab9f4[_0x9b3f('0x3c')]);_0x479657['attributes']=_[_0x9b3f('0x3f')](_0x5ab9f4['model'],qs[_0x9b3f('0x41')](_0x37d719[_0x9b3f('0x3c')]['fields']));_0x479657[_0x9b3f('0x40')]=_0x479657[_0x9b3f('0x40')][_0x9b3f('0x42')]?_0x479657[_0x9b3f('0x40')]:_0x5ab9f4[_0x9b3f('0x3b')];if(!_0x37d719['query'][_0x9b3f('0x43')](_0x9b3f('0x61'))){_0x479657[_0x9b3f('0x1f')]=qs[_0x9b3f('0x1f')](_0x37d719[_0x9b3f('0x3c')][_0x9b3f('0x1f')]);_0x479657[_0x9b3f('0x1d')]=qs[_0x9b3f('0x1d')](_0x37d719[_0x9b3f('0x3c')]['offset']);}_0x479657[_0x9b3f('0x44')]=qs[_0x9b3f('0x45')](_0x37d719[_0x9b3f('0x3c')][_0x9b3f('0x45')]);_0x479657[_0x9b3f('0x46')]=qs[_0x9b3f('0x3e')](_[_0x9b3f('0x62')](_0x37d719[_0x9b3f('0x3c')],_0x5ab9f4['filters']));_0x479657[_0x9b3f('0x46')]['VoiceQueueId']=_0x3b2b87['id'];if(_0x37d719[_0x9b3f('0x3c')][_0x9b3f('0x2a')]){_0x479657[_0x9b3f('0x46')]=_[_0x9b3f('0x48')](_0x479657['where'],{'$or':_[_0x9b3f('0x2b')](_0x479657[_0x9b3f('0x40')],function(_0xf7412c){var _0x4b94f3={};_0x4b94f3[_0xf7412c]={'$like':'%'+_0x37d719['query'][_0x9b3f('0x2a')]+'%'};return _0x4b94f3;})});}_0x479657=_[_0x9b3f('0x48')]({},_0x479657,_0x37d719[_0x9b3f('0x49')]);return db['CmHopper']['count']({'where':_0x479657[_0x9b3f('0x46')]})['then'](function(_0x48a45c){_0xca9f52[_0x9b3f('0x20')]=_0x48a45c;if(_0x37d719[_0x9b3f('0x3c')][_0x9b3f('0x4a')]){_0x479657['include']=[{'all':!![]}];}return db['CmHopper'][_0x9b3f('0x63')](_0x479657);})[_0x9b3f('0x25')](function(_0x5d7cf7){_0xca9f52['rows']=_0x5d7cf7;return _0xca9f52;});}})[_0x9b3f('0x25')](respondWithFilteredResult(_0x2896de,_0x479657))[_0x9b3f('0x4c')](handleError(_0x2896de,null));};exports[_0x9b3f('0x64')]=function(_0x22d633,_0x37bcc2,_0x81d2a0){var _0x8cdf78={'raw':!![],'where':{}};var _0x57d301={};var _0xbb6d44={'count':0x0,'rows':[]};return db['VoiceQueue']['findOne']({'where':{'id':_0x22d633[_0x9b3f('0x57')]['id']}})[_0x9b3f('0x25')](handleEntityNotFound(_0x37bcc2,null))[_0x9b3f('0x25')](function(_0x21ab78){if(_0x21ab78){_0x57d301[_0x9b3f('0x3b')]=_[_0x9b3f('0x3d')](db[_0x9b3f('0x65')]['rawAttributes']);_0x57d301[_0x9b3f('0x3c')]=_[_0x9b3f('0x3d')](_0x22d633[_0x9b3f('0x3c')]);_0x57d301[_0x9b3f('0x3e')]=_[_0x9b3f('0x3f')](_0x57d301[_0x9b3f('0x3b')],_0x57d301['query']);_0x8cdf78[_0x9b3f('0x40')]=_[_0x9b3f('0x3f')](_0x57d301['model'],qs['fields'](_0x22d633[_0x9b3f('0x3c')][_0x9b3f('0x41')]));_0x8cdf78[_0x9b3f('0x40')]=_0x8cdf78['attributes']['length']?_0x8cdf78[_0x9b3f('0x40')]:_0x57d301[_0x9b3f('0x3b')];if(!_0x22d633['query'][_0x9b3f('0x43')](_0x9b3f('0x61'))){_0x8cdf78[_0x9b3f('0x1f')]=qs['limit'](_0x22d633[_0x9b3f('0x3c')][_0x9b3f('0x1f')]);_0x8cdf78[_0x9b3f('0x1d')]=qs[_0x9b3f('0x1d')](_0x22d633[_0x9b3f('0x3c')][_0x9b3f('0x1d')]);}_0x8cdf78[_0x9b3f('0x44')]=qs['sort'](_0x22d633[_0x9b3f('0x3c')][_0x9b3f('0x45')]);_0x8cdf78[_0x9b3f('0x46')]=qs[_0x9b3f('0x3e')](_[_0x9b3f('0x62')](_0x22d633[_0x9b3f('0x3c')],_0x57d301[_0x9b3f('0x3e')]));_0x8cdf78[_0x9b3f('0x46')][_0x9b3f('0x66')]=_0x21ab78['id'];if(_0x22d633[_0x9b3f('0x3c')]['filter']){_0x8cdf78['where']=_[_0x9b3f('0x48')](_0x8cdf78[_0x9b3f('0x46')],{'$or':_[_0x9b3f('0x2b')](_0x8cdf78[_0x9b3f('0x40')],function(_0x7e5dce){var _0x19c42b={};_0x19c42b[_0x7e5dce]={'$like':'%'+_0x22d633['query']['filter']+'%'};return _0x19c42b;})});}_0x8cdf78=_[_0x9b3f('0x48')]({},_0x8cdf78,_0x22d633[_0x9b3f('0x49')]);return db[_0x9b3f('0x65')]['count']({'where':_0x8cdf78['where']})[_0x9b3f('0x25')](function(_0x573abe){_0xbb6d44[_0x9b3f('0x20')]=_0x573abe;if(_0x22d633[_0x9b3f('0x3c')][_0x9b3f('0x4a')]){_0x8cdf78['include']=[{'all':!![]}];}return db[_0x9b3f('0x65')][_0x9b3f('0x63')](_0x8cdf78);})['then'](function(_0xd911b7){_0xbb6d44[_0x9b3f('0x67')]=_0xd911b7;return _0xbb6d44;});}})['then'](respondWithFilteredResult(_0x37bcc2,_0x8cdf78))['catch'](handleError(_0x37bcc2,null));};exports['getHopperFinals']=function(_0x13d7f5,_0x27584f,_0x296989){var _0x1b4a44={'raw':!![],'where':{}};var _0x468cb2={};var _0x53d7ef={'count':0x0,'rows':[]};return db[_0x9b3f('0x37')][_0x9b3f('0x5f')]({'where':{'id':_0x13d7f5['params']['id']}})[_0x9b3f('0x25')](handleEntityNotFound(_0x27584f,null))[_0x9b3f('0x25')](function(_0x4174cb){if(_0x4174cb){_0x468cb2['model']=_[_0x9b3f('0x3d')](db[_0x9b3f('0x68')][_0x9b3f('0x38')]);_0x468cb2[_0x9b3f('0x3c')]=_['keys'](_0x13d7f5[_0x9b3f('0x3c')]);_0x468cb2[_0x9b3f('0x3e')]=_[_0x9b3f('0x3f')](_0x468cb2[_0x9b3f('0x3b')],_0x468cb2[_0x9b3f('0x3c')]);_0x1b4a44[_0x9b3f('0x40')]=_[_0x9b3f('0x3f')](_0x468cb2[_0x9b3f('0x3b')],qs['fields'](_0x13d7f5['query']['fields']));_0x1b4a44['attributes']=_0x1b4a44[_0x9b3f('0x40')]['length']?_0x1b4a44[_0x9b3f('0x40')]:_0x468cb2['model'];if(!_0x13d7f5['query'][_0x9b3f('0x43')]('nolimit')){_0x1b4a44[_0x9b3f('0x1f')]=qs[_0x9b3f('0x1f')](_0x13d7f5['query']['limit']);_0x1b4a44[_0x9b3f('0x1d')]=qs[_0x9b3f('0x1d')](_0x13d7f5[_0x9b3f('0x3c')]['offset']);}_0x1b4a44[_0x9b3f('0x44')]=qs[_0x9b3f('0x45')](_0x13d7f5['query'][_0x9b3f('0x45')]);_0x1b4a44[_0x9b3f('0x46')]=qs['filters'](_[_0x9b3f('0x62')](_0x13d7f5[_0x9b3f('0x3c')],_0x468cb2[_0x9b3f('0x3e')]));_0x1b4a44[_0x9b3f('0x46')]['VoiceQueueId']=_0x4174cb['id'];if(_0x13d7f5['query'][_0x9b3f('0x2a')]){_0x1b4a44['where']=_['merge'](_0x1b4a44[_0x9b3f('0x46')],{'$or':_['map'](_0x1b4a44[_0x9b3f('0x40')],function(_0x3476d7){var _0x1891fa={};_0x1891fa[_0x3476d7]={'$like':'%'+_0x13d7f5[_0x9b3f('0x3c')]['filter']+'%'};return _0x1891fa;})});}_0x1b4a44=_[_0x9b3f('0x48')]({},_0x1b4a44,_0x13d7f5[_0x9b3f('0x49')]);return db['CmHopperFinal'][_0x9b3f('0x20')]({'where':_0x1b4a44['where']})[_0x9b3f('0x25')](function(_0x3b9018){_0x53d7ef[_0x9b3f('0x20')]=_0x3b9018;if(_0x13d7f5['query'][_0x9b3f('0x4a')]){_0x1b4a44[_0x9b3f('0x4b')]=[{'all':!![]}];}return db[_0x9b3f('0x68')][_0x9b3f('0x63')](_0x1b4a44);})[_0x9b3f('0x25')](function(_0x357cc1){_0x53d7ef[_0x9b3f('0x67')]=_0x357cc1;return _0x53d7ef;});}})[_0x9b3f('0x25')](respondWithFilteredResult(_0x27584f,_0x1b4a44))[_0x9b3f('0x4c')](handleError(_0x27584f,null));};exports[_0x9b3f('0x69')]=function(_0x279406,_0x136498,_0xf47c7){var _0x38a399={'raw':!![],'where':{}};var _0x3625ec={};var _0x2d9f95={'count':0x0,'rows':[]};return db[_0x9b3f('0x37')][_0x9b3f('0x5f')]({'where':{'id':_0x279406[_0x9b3f('0x57')]['id']}})['then'](handleEntityNotFound(_0x136498,null))['then'](function(_0x5a4418){if(_0x5a4418){_0x3625ec[_0x9b3f('0x3b')]=_['keys'](db[_0x9b3f('0x6a')][_0x9b3f('0x38')]);_0x3625ec['query']=_[_0x9b3f('0x3d')](_0x279406[_0x9b3f('0x3c')]);_0x3625ec[_0x9b3f('0x3e')]=_[_0x9b3f('0x3f')](_0x3625ec[_0x9b3f('0x3b')],_0x3625ec[_0x9b3f('0x3c')]);_0x38a399[_0x9b3f('0x40')]=_['intersection'](_0x3625ec[_0x9b3f('0x3b')],qs[_0x9b3f('0x41')](_0x279406[_0x9b3f('0x3c')][_0x9b3f('0x41')]));_0x38a399['attributes']=_0x38a399[_0x9b3f('0x40')][_0x9b3f('0x42')]?_0x38a399[_0x9b3f('0x40')]:_0x3625ec['model'];if(!_0x279406[_0x9b3f('0x3c')]['hasOwnProperty']('nolimit')){_0x38a399['limit']=qs['limit'](_0x279406['query']['limit']);_0x38a399['offset']=qs[_0x9b3f('0x1d')](_0x279406[_0x9b3f('0x3c')][_0x9b3f('0x1d')]);}_0x38a399[_0x9b3f('0x44')]=qs[_0x9b3f('0x45')](_0x279406[_0x9b3f('0x3c')][_0x9b3f('0x45')]);_0x38a399[_0x9b3f('0x46')]=qs[_0x9b3f('0x3e')](_[_0x9b3f('0x62')](_0x279406[_0x9b3f('0x3c')],_0x3625ec['filters']));_0x38a399[_0x9b3f('0x46')][_0x9b3f('0x66')]=_0x5a4418['id'];if(_0x279406[_0x9b3f('0x3c')][_0x9b3f('0x2a')]){_0x38a399['where']=_[_0x9b3f('0x48')](_0x38a399[_0x9b3f('0x46')],{'$or':_[_0x9b3f('0x2b')](_0x38a399['attributes'],function(_0x164294){var _0x509551={};_0x509551[_0x164294]={'$like':'%'+_0x279406[_0x9b3f('0x3c')]['filter']+'%'};return _0x509551;})});}_0x38a399=_[_0x9b3f('0x48')]({},_0x38a399,_0x279406['options']);return db[_0x9b3f('0x6a')]['count']({'where':_0x38a399['where']})[_0x9b3f('0x25')](function(_0xc4af69){_0x2d9f95[_0x9b3f('0x20')]=_0xc4af69;if(_0x279406[_0x9b3f('0x3c')][_0x9b3f('0x4a')]){_0x38a399[_0x9b3f('0x4b')]=[{'all':!![]}];}return db[_0x9b3f('0x6a')][_0x9b3f('0x63')](_0x38a399);})[_0x9b3f('0x25')](function(_0x5cc7bf){_0x2d9f95[_0x9b3f('0x67')]=_0x5cc7bf;return _0x2d9f95;});}})[_0x9b3f('0x25')](respondWithFilteredResult(_0x136498,_0x38a399))[_0x9b3f('0x4c')](handleError(_0x136498,null));};exports['getTeams']=function(_0x91daa8,_0x23e6db,_0x3fdd88){var _0x179905={};var _0x1e53c0={};var _0x27b517;var _0x3b2150;return db['VoiceQueue'][_0x9b3f('0x5f')]({'where':{'id':_0x91daa8['params']['id']}})[_0x9b3f('0x25')](handleEntityNotFound(_0x23e6db,null))[_0x9b3f('0x25')](function(_0x38b675){if(_0x38b675){_0x27b517=_0x38b675;_0x1e53c0['model']=_[_0x9b3f('0x3d')](db[_0x9b3f('0x6b')][_0x9b3f('0x38')]);_0x1e53c0[_0x9b3f('0x3c')]=_[_0x9b3f('0x3d')](_0x91daa8['query']);_0x1e53c0[_0x9b3f('0x3e')]=_[_0x9b3f('0x3f')](_0x1e53c0[_0x9b3f('0x3b')],_0x1e53c0['query']);_0x179905[_0x9b3f('0x40')]=_[_0x9b3f('0x3f')](_0x1e53c0['model'],qs[_0x9b3f('0x41')](_0x91daa8[_0x9b3f('0x3c')]['fields']));_0x179905[_0x9b3f('0x40')]=_0x179905[_0x9b3f('0x40')]['length']?_0x179905[_0x9b3f('0x40')]:_0x1e53c0[_0x9b3f('0x3b')];_0x179905[_0x9b3f('0x44')]=qs[_0x9b3f('0x45')](_0x91daa8[_0x9b3f('0x3c')]['sort']);_0x179905[_0x9b3f('0x46')]=qs['filters'](_[_0x9b3f('0x62')](_0x91daa8[_0x9b3f('0x3c')],_0x1e53c0[_0x9b3f('0x3e')]));if(_0x91daa8[_0x9b3f('0x3c')][_0x9b3f('0x2a')]){_0x179905[_0x9b3f('0x46')]=_['merge'](_0x179905[_0x9b3f('0x46')],{'$or':_[_0x9b3f('0x2b')](_0x179905[_0x9b3f('0x40')],function(_0x59e63b){var _0x27f5cf={};_0x27f5cf[_0x59e63b]={'$like':'%'+_0x91daa8[_0x9b3f('0x3c')][_0x9b3f('0x2a')]+'%'};return _0x27f5cf;})});}_0x179905=_[_0x9b3f('0x48')]({},_0x179905,_0x91daa8[_0x9b3f('0x49')]);return _0x27b517[_0x9b3f('0x6c')](_0x179905);}})[_0x9b3f('0x25')](function(_0x11d867){if(_0x11d867){_0x3b2150=_0x11d867[_0x9b3f('0x42')];if(!_0x91daa8[_0x9b3f('0x3c')][_0x9b3f('0x43')](_0x9b3f('0x61'))){_0x179905[_0x9b3f('0x1f')]=qs[_0x9b3f('0x1f')](_0x91daa8['query'][_0x9b3f('0x1f')]);_0x179905[_0x9b3f('0x1d')]=qs[_0x9b3f('0x1d')](_0x91daa8[_0x9b3f('0x3c')][_0x9b3f('0x1d')]);}return _0x27b517[_0x9b3f('0x6c')](_0x179905);}})[_0x9b3f('0x25')](function(_0xb45da2){if(_0xb45da2){return _0xb45da2?{'count':_0x3b2150,'rows':_0xb45da2}:null;}})[_0x9b3f('0x25')](respondWithResult(_0x23e6db,null))['catch'](handleError(_0x23e6db,null));};exports[_0x9b3f('0x6d')]=function(_0x16bf29,_0x221c2a,_0x45bd1f){var _0x152e4a=_0x16bf29[_0x9b3f('0x4f')]['teams'];var _0x5ef2f1=_['map'](_0x152e4a,'id');return db[_0x9b3f('0x6b')]['findAll']({'where':{'id':_0x5ef2f1},'attributes':['id'],'include':[{'model':db['User'],'as':_0x9b3f('0x6e'),'attributes':['id','name',_0x9b3f('0x6f'),_0x9b3f('0x70'),'interface'],'raw':!![]}]})[_0x9b3f('0x25')](function(_0x55b3e5){if(_0x55b3e5){var _0x297172=_[_0x9b3f('0x71')](_0x55b3e5,function(_0x4f03b1){var _0x4657eb=_0x4f03b1['get']({'plain':!![]});_0x4657eb[_0x9b3f('0x6e')][_0x9b3f('0x72')](function(_0x33baf9){_0x33baf9[_0x9b3f('0x73')]=_[_0x9b3f('0x2f')](_0x152e4a,{'id':_0x4657eb['id']})[_0x9b3f('0x73')];});return _0x4657eb[_0x9b3f('0x6e')];});return db[_0x9b3f('0x37')][_0x9b3f('0x2f')]({'where':{'id':_0x16bf29[_0x9b3f('0x57')]['id']}})[_0x9b3f('0x25')](function(_0x5cd274){return db[_0x9b3f('0x74')]['transaction'](function(_0x467b2a){return _0x5cd274[_0x9b3f('0x6d')](_0x5ef2f1,{'transaction':_0x467b2a})[_0x9b3f('0x25')](function(){return BPromise['each'](_0x152e4a,function(_0x235d18){return db[_0x9b3f('0x75')]['upsert']({'TeamId':_0x235d18['id'],'VoiceQueueId':_0x16bf29[_0x9b3f('0x57')]['id'],'penalty':_0x235d18[_0x9b3f('0x73')]},{'transaction':_0x467b2a});});})['then'](function(){return BPromise[_0x9b3f('0x76')](_0x297172,function(_0x2e589a){return db[_0x9b3f('0x77')][_0x9b3f('0x78')]({'where':{'UserId':_0x2e589a['id'],'VoiceQueueId':_0x16bf29[_0x9b3f('0x57')]['id']},'defaults':{'penalty':_0x2e589a[_0x9b3f('0x73')]},'transaction':_0x467b2a});});})[_0x9b3f('0x25')](function(){return BPromise[_0x9b3f('0x76')](_[_0x9b3f('0x2a')](_0x297172,{'online':!![]}),function(_0x5e78d8){return db[_0x9b3f('0x79')][_0x9b3f('0x7a')]({'membername':_0x5e78d8['name'],'UserId':_0x5e78d8['id'],'queue_name':_0x5cd274['name'],'VoiceQueueId':_0x5cd274['id'],'interface':_[_0x9b3f('0x7b')](_0x5e78d8['interface'])?util[_0x9b3f('0x7c')](_0x9b3f('0x7d'),_0x5e78d8[_0x9b3f('0x30')]):_0x5e78d8['interface'],'paused':_0x5e78d8['voicePause']||![],'penalty':_0x5e78d8[_0x9b3f('0x73')]},{'transaction':_0x467b2a});});})[_0x9b3f('0x25')](function(){_0x297172[_0x9b3f('0x72')](function(_0x58b594){socket[_0x9b3f('0x7e')](_0x9b3f('0x7f'),{'UserId':_0x58b594['id'],'VoiceQueueId':_0x5cd274['id']});});});});});}})[_0x9b3f('0x25')](respondWithStatusCode(_0x221c2a,null))[_0x9b3f('0x4c')](handleError(_0x221c2a,null));};exports[_0x9b3f('0x80')]=function(_0x37bde7,_0x5304fe,_0x172ebb){return db[_0x9b3f('0x6b')][_0x9b3f('0x63')]({'where':{'id':_0x37bde7[_0x9b3f('0x3c')]['ids']},'attributes':['id'],'include':[{'model':db[_0x9b3f('0x81')],'as':_0x9b3f('0x6e'),'attributes':['id'],'raw':!![]}]})[_0x9b3f('0x25')](handleEntityNotFound(_0x5304fe,null))[_0x9b3f('0x25')](function(_0x44b8af){var _0x1a7336=_['map'](_0x44b8af,'id');var _0x375ade=[];var _0x421cd8=[];var _0x3abe8f=squel[_0x9b3f('0x82')]();_0x3abe8f[_0x9b3f('0x83')]('tq.TeamId')[_0x9b3f('0x84')](_0x9b3f('0x85'),'tq')['join'](_0x9b3f('0x86'),'ut',_0x9b3f('0x87'))[_0x9b3f('0x46')](_0x9b3f('0x88'),_0x37bde7[_0x9b3f('0x57')]['id']);for(var _0xeda184=0x0;_0xeda184<_0x44b8af['length'];_0xeda184+=0x1){let _0x4b1b77=_0x44b8af[_0xeda184];for(var _0xc956ce=0x0;_0xc956ce<_0x4b1b77[_0x9b3f('0x6e')][_0x9b3f('0x42')];_0xc956ce+=0x1){let _0x1a73ab=_0x4b1b77[_0x9b3f('0x6e')][_0xc956ce];var _0xa85fa=_0x3abe8f['clone']();_0xa85fa['where'](_0x9b3f('0x89'),_0x1a73ab['id']);_0x421cd8[_0x9b3f('0x8a')](db[_0x9b3f('0x74')]['query'](_0xa85fa['toString'](),{'type':db[_0x9b3f('0x74')][_0x9b3f('0x8b')][_0x9b3f('0x8c')]})[_0x9b3f('0x25')](function(_0x429bc3){if(_0x429bc3['length']===0x1){return _0x1a73ab['id'];}else{var _0x224012=_['every'](_['map'](_0x429bc3,'TeamId'),function(_0x1c224a){return _[_0x9b3f('0x2d')](_0x1a7336,_0x1c224a);});if(_0x224012){return _0x1a73ab['id'];}}}));}}return BPromise[_0x9b3f('0x8d')](_0x421cd8)['then'](function(_0x58759e){_0x375ade=_(_0x375ade)[_0x9b3f('0x8e')](_0x58759e)[_0x9b3f('0x8f')]()[_0x9b3f('0x2c')]();return db[_0x9b3f('0x37')][_0x9b3f('0x2f')]({'where':{'id':_0x37bde7[_0x9b3f('0x57')]['id']}})[_0x9b3f('0x25')](function(_0x1c0eeb){return db[_0x9b3f('0x74')][_0x9b3f('0x90')](function(_0x5f2bf7){return _0x1c0eeb[_0x9b3f('0x80')](_0x37bde7['query'][_0x9b3f('0x91')],{'transaction':_0x5f2bf7})['then'](function(){if(!_[_0x9b3f('0x92')](_0x375ade)){return _0x1c0eeb[_0x9b3f('0x93')](_0x375ade,{'transaction':_0x5f2bf7})[_0x9b3f('0x25')](function(){return db[_0x9b3f('0x79')][_0x9b3f('0x26')]({'where':{'VoiceQueueId':_0x37bde7[_0x9b3f('0x57')]['id'],'UserId':_0x375ade},'transaction':_0x5f2bf7});});}})[_0x9b3f('0x25')](function(){_0x375ade[_0x9b3f('0x72')](function(_0x37886f){socket[_0x9b3f('0x7e')](_0x9b3f('0x94'),{'UserId':_0x37886f,'VoiceQueueId':_0x1c0eeb['id']});});});});});});})[_0x9b3f('0x25')](respondWithStatusCode(_0x5304fe,null))[_0x9b3f('0x4c')](handleError(_0x5304fe,null));};exports[_0x9b3f('0x95')]=function(_0x3c56a2,_0x23aa6c,_0x246813){var _0x268566,_0x2b21ec;return db[_0x9b3f('0x37')]['find']({'where':{'id':_0x3c56a2[_0x9b3f('0x57')]['id']}})[_0x9b3f('0x25')](handleEntityNotFound(_0x23aa6c,null))[_0x9b3f('0x25')](function(_0x3b73b4){if(_0x3b73b4){_0x2b21ec=_0x3b73b4;return _0x3b73b4[_0x9b3f('0x95')](_0x3c56a2[_0x9b3f('0x4f')][_0x9b3f('0x91')],_[_0x9b3f('0x58')](_0x3c56a2[_0x9b3f('0x4f')],[_0x9b3f('0x91'),'id'])||{})['spread'](function(_0x262f23){for(var _0x491d83=0x0;_0x491d83<_0x3c56a2[_0x9b3f('0x4f')][_0x9b3f('0x91')][_0x9b3f('0x42')];_0x491d83+=0x1){socket[_0x9b3f('0x7e')](_0x9b3f('0x7f'),{'UserId':Number(_0x3c56a2[_0x9b3f('0x4f')][_0x9b3f('0x91')][_0x491d83]),'VoiceQueueId':Number(_0x3c56a2[_0x9b3f('0x57')]['id'])});}return _0x262f23;});}})['then'](function(_0x3504e1){_0x268566=_0x3504e1||[];if(_0x2b21ec){return db[_0x9b3f('0x81')][_0x9b3f('0x63')]({'where':{'id':_0x3c56a2[_0x9b3f('0x4f')][_0x9b3f('0x91')]},'attributes':['id',_0x9b3f('0x30'),'online',_0x9b3f('0x70'),_0x9b3f('0x96')],'raw':!![]});}})['then'](function(_0x9d437f){if(!_[_0x9b3f('0x92')](_0x9d437f)){var _0x209dce=[];for(var _0x572b1b=0x0;_0x572b1b<_0x9d437f[_0x9b3f('0x42')];_0x572b1b++){if(_0x9d437f[_0x572b1b][_0x9b3f('0x6f')]){_0x209dce[_0x9b3f('0x8a')](db[_0x9b3f('0x79')][_0x9b3f('0x7a')]({'membername':_0x9d437f[_0x572b1b][_0x9b3f('0x30')],'UserId':_0x9d437f[_0x572b1b]['id'],'queue_name':_0x2b21ec[_0x9b3f('0x30')],'VoiceQueueId':_0x2b21ec['id'],'interface':_[_0x9b3f('0x7b')](_0x9d437f[_0x572b1b][_0x9b3f('0x96')])?util[_0x9b3f('0x7c')]('SIP/%s',_0x9d437f[_0x572b1b]['name']):_0x9d437f[_0x572b1b][_0x9b3f('0x96')],'paused':_0x9d437f[_0x572b1b][_0x9b3f('0x70')]||![],'penalty':_0x3c56a2[_0x9b3f('0x4f')]['penalty']||0x0}));}}return BPromise[_0x9b3f('0x8d')](_0x209dce);}})[_0x9b3f('0x25')](function(){return _0x268566;})[_0x9b3f('0x25')](respondWithResult(_0x23aa6c,null))[_0x9b3f('0x4c')](handleError(_0x23aa6c,null));};exports['removeAgents']=function(_0x463bc3,_0x1d79f4,_0xa9c31b){return db[_0x9b3f('0x37')][_0x9b3f('0x2f')]({'where':{'id':_0x463bc3[_0x9b3f('0x57')]['id']}})['then'](handleEntityNotFound(_0x1d79f4,null))[_0x9b3f('0x25')](function(_0x4aaaa2){if(_0x4aaaa2){return _0x4aaaa2[_0x9b3f('0x93')](_0x463bc3[_0x9b3f('0x3c')]['ids'])[_0x9b3f('0x25')](function(){if(_[_0x9b3f('0x97')](_0x463bc3['query'][_0x9b3f('0x91')])){for(var _0x5a78c8=0x0;_0x5a78c8<_0x463bc3[_0x9b3f('0x3c')][_0x9b3f('0x91')][_0x9b3f('0x42')];_0x5a78c8+=0x1){socket[_0x9b3f('0x7e')](_0x9b3f('0x94'),{'UserId':Number(_0x463bc3[_0x9b3f('0x3c')]['ids'][_0x5a78c8]),'VoiceQueueId':Number(_0x463bc3['params']['id'])});}}else{socket[_0x9b3f('0x7e')](_0x9b3f('0x94'),{'UserId':Number(_0x463bc3[_0x9b3f('0x3c')][_0x9b3f('0x91')]),'VoiceQueueId':Number(_0x463bc3[_0x9b3f('0x57')]['id'])});}});}})[_0x9b3f('0x25')](function(_0x461f3c){return db[_0x9b3f('0x79')][_0x9b3f('0x26')]({'where':{'VoiceQueueId':_0x463bc3['params']['id'],'UserId':_0x463bc3[_0x9b3f('0x3c')]['ids']}})[_0x9b3f('0x25')](function(){return _0x461f3c;});})[_0x9b3f('0x25')](respondWithStatusCode(_0x1d79f4,null))['catch'](handleError(_0x1d79f4,null));};exports['getAgents']=function(_0x56ec83,_0x876a8b,_0x2f933a){var _0x5e369a={};var _0x2a661c={};var _0x115cb0;var _0x4cca54;return db[_0x9b3f('0x37')][_0x9b3f('0x5f')]({'where':{'id':_0x56ec83[_0x9b3f('0x57')]['id']}})[_0x9b3f('0x25')](handleEntityNotFound(_0x876a8b,null))[_0x9b3f('0x25')](function(_0x5d3261){if(_0x5d3261){_0x115cb0=_0x5d3261;_0x2a661c[_0x9b3f('0x3b')]=_[_0x9b3f('0x3d')](db[_0x9b3f('0x81')]['rawAttributes']);_0x2a661c['query']=_['keys'](_0x56ec83['query']);_0x2a661c[_0x9b3f('0x3e')]=_['intersection'](_0x2a661c['model'],_0x2a661c[_0x9b3f('0x3c')]);_0x5e369a[_0x9b3f('0x40')]=_[_0x9b3f('0x3f')](_0x2a661c[_0x9b3f('0x3b')],qs[_0x9b3f('0x41')](_0x56ec83['query']['fields']));_0x5e369a[_0x9b3f('0x40')]=_0x5e369a['attributes'][_0x9b3f('0x42')]?_0x5e369a[_0x9b3f('0x40')]:_0x2a661c[_0x9b3f('0x3b')];_0x5e369a[_0x9b3f('0x44')]=qs['sort'](_0x56ec83[_0x9b3f('0x3c')][_0x9b3f('0x45')]);_0x5e369a[_0x9b3f('0x46')]=qs['filters'](_[_0x9b3f('0x62')](_0x56ec83['query'],_0x2a661c[_0x9b3f('0x3e')]));if(_0x56ec83[_0x9b3f('0x3c')]['filter']){_0x5e369a[_0x9b3f('0x46')]=_[_0x9b3f('0x48')](_0x5e369a['where'],{'$or':_[_0x9b3f('0x2b')](_0x5e369a[_0x9b3f('0x40')],function(_0x20bb74){var _0x4d5fd1={};_0x4d5fd1[_0x20bb74]={'$like':'%'+_0x56ec83[_0x9b3f('0x3c')][_0x9b3f('0x2a')]+'%'};return _0x4d5fd1;})});}_0x5e369a=_[_0x9b3f('0x48')]({},_0x5e369a,_0x56ec83[_0x9b3f('0x49')]);return _0x115cb0[_0x9b3f('0x98')](_0x5e369a);}})[_0x9b3f('0x25')](function(_0x35871a){if(_0x35871a){_0x4cca54=_0x35871a[_0x9b3f('0x42')];if(!_0x56ec83['query'][_0x9b3f('0x43')]('nolimit')){_0x5e369a['limit']=qs['limit'](_0x56ec83[_0x9b3f('0x3c')]['limit']);_0x5e369a['offset']=qs[_0x9b3f('0x1d')](_0x56ec83[_0x9b3f('0x3c')][_0x9b3f('0x1d')]);}return _0x115cb0[_0x9b3f('0x98')](_0x5e369a);}})[_0x9b3f('0x25')](function(_0x255dcb){if(_0x255dcb){return _0x255dcb?{'count':_0x4cca54,'rows':_0x255dcb}:null;}})[_0x9b3f('0x25')](respondWithResult(_0x876a8b,null))['catch'](handleError(_0x876a8b,null));};exports['getMembers']=function(_0x23fcf9,_0xb6cda0,_0x29f684){var _0x5084d1={};var _0x1aa0cb={};var _0x21aa68;var _0x4d991e;return db[_0x9b3f('0x37')][_0x9b3f('0x5f')]({'where':{'id':_0x23fcf9[_0x9b3f('0x57')]['id']}})[_0x9b3f('0x25')](handleEntityNotFound(_0xb6cda0,null))['then'](function(_0x2d1511){if(_0x2d1511){_0x21aa68=_0x2d1511;_0x1aa0cb[_0x9b3f('0x3b')]=_['keys'](db[_0x9b3f('0x79')][_0x9b3f('0x38')]);_0x1aa0cb[_0x9b3f('0x3c')]=_[_0x9b3f('0x3d')](_0x23fcf9[_0x9b3f('0x3c')]);_0x1aa0cb[_0x9b3f('0x3e')]=_[_0x9b3f('0x3f')](_0x1aa0cb[_0x9b3f('0x3b')],_0x1aa0cb[_0x9b3f('0x3c')]);_0x5084d1[_0x9b3f('0x40')]=_[_0x9b3f('0x3f')](_0x1aa0cb[_0x9b3f('0x3b')],qs[_0x9b3f('0x41')](_0x23fcf9['query'][_0x9b3f('0x41')]));_0x5084d1[_0x9b3f('0x40')]=_0x5084d1[_0x9b3f('0x40')]['length']?_0x5084d1[_0x9b3f('0x40')]:_0x1aa0cb[_0x9b3f('0x3b')];_0x5084d1[_0x9b3f('0x44')]=qs[_0x9b3f('0x45')](_0x23fcf9[_0x9b3f('0x3c')][_0x9b3f('0x45')]);_0x5084d1[_0x9b3f('0x46')]=qs['filters'](_[_0x9b3f('0x62')](_0x23fcf9[_0x9b3f('0x3c')],_0x1aa0cb[_0x9b3f('0x3e')]));if(_0x23fcf9[_0x9b3f('0x3c')][_0x9b3f('0x2a')]){_0x5084d1['where']=_[_0x9b3f('0x48')](_0x5084d1[_0x9b3f('0x46')],{'$or':_['map'](_0x5084d1['attributes'],function(_0x199477){var _0x2b71ff={};_0x2b71ff[_0x199477]={'$like':'%'+_0x23fcf9[_0x9b3f('0x3c')][_0x9b3f('0x2a')]+'%'};return _0x2b71ff;})});}_0x5084d1=_[_0x9b3f('0x48')]({},_0x5084d1,_0x23fcf9[_0x9b3f('0x49')]);return _0x21aa68['getMembers'](_0x5084d1);}})[_0x9b3f('0x25')](function(_0x5a96d8){if(_0x5a96d8){_0x4d991e=_0x5a96d8['length'];if(!_0x23fcf9[_0x9b3f('0x3c')][_0x9b3f('0x43')]('nolimit')){_0x5084d1[_0x9b3f('0x1f')]=qs[_0x9b3f('0x1f')](_0x23fcf9[_0x9b3f('0x3c')][_0x9b3f('0x1f')]);_0x5084d1['offset']=qs[_0x9b3f('0x1d')](_0x23fcf9[_0x9b3f('0x3c')][_0x9b3f('0x1d')]);}return _0x21aa68['getMembers'](_0x5084d1);}})['then'](function(_0x1b3fb7){return _0x1b3fb7?{'count':_0x4d991e,'rows':_0x1b3fb7}:null;})[_0x9b3f('0x25')](respondWithResult(_0xb6cda0,null))[_0x9b3f('0x4c')](handleError(_0xb6cda0,null));};exports[_0x9b3f('0x99')]=function(_0xe8cbd1,_0x1d2887,_0x3c2e8d){var _0x113923={};var _0x4a84e8={};var _0x1ea162;var _0x229b52;return db[_0x9b3f('0x37')][_0x9b3f('0x5f')]({'where':{'id':_0xe8cbd1[_0x9b3f('0x57')]['id']}})[_0x9b3f('0x25')](handleEntityNotFound(_0x1d2887,null))[_0x9b3f('0x25')](function(_0x50d6c1){if(_0x50d6c1){_0x1ea162=_0x50d6c1;_0x4a84e8[_0x9b3f('0x3b')]=_[_0x9b3f('0x3d')](db[_0x9b3f('0x9a')][_0x9b3f('0x38')]);_0x4a84e8[_0x9b3f('0x3c')]=_[_0x9b3f('0x3d')](_0xe8cbd1[_0x9b3f('0x3c')]);_0x4a84e8[_0x9b3f('0x3e')]=_[_0x9b3f('0x3f')](_0x4a84e8['model'],_0x4a84e8[_0x9b3f('0x3c')]);_0x113923[_0x9b3f('0x40')]=_[_0x9b3f('0x3f')](_0x4a84e8[_0x9b3f('0x3b')],qs['fields'](_0xe8cbd1[_0x9b3f('0x3c')][_0x9b3f('0x41')]));_0x113923[_0x9b3f('0x40')]=_0x113923[_0x9b3f('0x40')][_0x9b3f('0x42')]?_0x113923['attributes']:_0x4a84e8[_0x9b3f('0x3b')];_0x113923[_0x9b3f('0x44')]=qs[_0x9b3f('0x45')](_0xe8cbd1[_0x9b3f('0x3c')][_0x9b3f('0x45')]);_0x113923[_0x9b3f('0x46')]=qs[_0x9b3f('0x3e')](_[_0x9b3f('0x62')](_0xe8cbd1['query'],_0x4a84e8[_0x9b3f('0x3e')]));if(_0xe8cbd1['query'][_0x9b3f('0x2a')]){_0x113923[_0x9b3f('0x46')]=_[_0x9b3f('0x48')](_0x113923['where'],{'$or':_[_0x9b3f('0x2b')](_0x113923[_0x9b3f('0x40')],function(_0x133095){var _0x102bfe={};_0x102bfe[_0x133095]={'$like':'%'+_0xe8cbd1['query'][_0x9b3f('0x2a')]+'%'};return _0x102bfe;})});}_0x113923=_[_0x9b3f('0x48')]({},_0x113923,_0xe8cbd1['options']);return _0x1ea162[_0x9b3f('0x99')](_0x113923);}})['then'](function(_0x357dd8){if(_0x357dd8){_0x229b52=_0x357dd8[_0x9b3f('0x42')];if(!_0xe8cbd1['query'][_0x9b3f('0x43')]('nolimit')){_0x113923[_0x9b3f('0x1f')]=qs[_0x9b3f('0x1f')](_0xe8cbd1['query']['limit']);_0x113923[_0x9b3f('0x1d')]=qs[_0x9b3f('0x1d')](_0xe8cbd1[_0x9b3f('0x3c')]['offset']);}return _0x1ea162['getLists'](_0x113923);}})[_0x9b3f('0x25')](function(_0x425b6e){if(_0x425b6e){return _0x425b6e?{'count':_0x229b52,'rows':_0x425b6e}:null;}})[_0x9b3f('0x25')](respondWithResult(_0x1d2887,null))[_0x9b3f('0x4c')](handleError(_0x1d2887,null));};exports[_0x9b3f('0x9b')]=function(_0x2317fd,_0x36131f,_0x55498b){var _0x291cbe=moment()[_0x9b3f('0x7c')]('YYYY-MM-DD\x20HH:mm:ss');var _0x1e72b9,_0x2abfde;return db[_0x9b3f('0x37')][_0x9b3f('0x2f')]({'where':{'id':_0x2317fd[_0x9b3f('0x57')]['id']}})[_0x9b3f('0x25')](handleEntityNotFound(_0x36131f,null))['then'](function(_0xbf63dc){if(_0xbf63dc){_0x2abfde=_0xbf63dc;return _0xbf63dc['addLists'](_0x2317fd[_0x9b3f('0x4f')]['ids'],_[_0x9b3f('0x58')](_0x2317fd[_0x9b3f('0x4f')],[_0x9b3f('0x91'),'id'])||{});}return null;})[_0x9b3f('0x9c')](function(_0x2896ad){var _0x19e8a6;_0x1e72b9=_0x2896ad||[];var _0x4f5d97=[];if(_0x2896ad){for(var _0x296fe8=0x0;_0x296fe8<_0x2896ad['length'];_0x296fe8+=0x1){var _0x567212=_0x2896ad[_0x296fe8]['get']({'plain':!![]});_0x2abfde[_0x9b3f('0x9d')]=_0x2317fd[_0x9b3f('0x4f')]['dialCheckDuplicateType']?_0x2317fd['body']['dialCheckDuplicateType']:_0x2abfde[_0x9b3f('0x9d')];switch(_0x2abfde[_0x9b3f('0x9d')]){case _0x9b3f('0x9e'):_0x19e8a6=squel['insert']()[_0x9b3f('0x9f')](_0x9b3f('0xa0'))[_0x9b3f('0xa1')]([_0x9b3f('0xa2'),_0x9b3f('0xa3'),_0x9b3f('0xa4'),'ListId',_0x9b3f('0x66'),_0x9b3f('0x59'),'updatedAt'],squel[_0x9b3f('0x82')]()['field'](_0x9b3f('0xa2'),_0x9b3f('0xa2'))[_0x9b3f('0x83')]('\x27'+_0x291cbe+'\x27','scheduledAt')[_0x9b3f('0x83')]('id',_0x9b3f('0xa4'))['field'](_0x567212[_0x9b3f('0xa5')][_0x9b3f('0xa6')](),'ListId')[_0x9b3f('0x83')](_0x2317fd[_0x9b3f('0x57')]['id'][_0x9b3f('0xa6')](),'VoiceQueueId')[_0x9b3f('0x83')]('\x27'+_0x291cbe+'\x27',_0x9b3f('0x59'))[_0x9b3f('0x83')]('\x27'+_0x291cbe+'\x27','updatedAt')[_0x9b3f('0x84')](_0x9b3f('0xa7'))[_0x9b3f('0x46')](_0x9b3f('0xa8'))['where']('ListId\x20=\x20?',_0x567212[_0x9b3f('0xa5')][_0x9b3f('0xa6')]())[_0x9b3f('0x46')](_0x9b3f('0xa9'))['where'](_0x9b3f('0xaa'),squel['select']()['field']('COALESCE(calleridnum,\x27\x27)')['from'](_0x9b3f('0xab'))[_0x9b3f('0x46')](_0x9b3f('0x88'),_0x2317fd[_0x9b3f('0x57')]['id'][_0x9b3f('0xa6')]()))[_0x9b3f('0x46')](_0x9b3f('0xaa'),squel[_0x9b3f('0x82')]()[_0x9b3f('0x83')](_0x9b3f('0xac'))[_0x9b3f('0x84')](_0x9b3f('0xa0'))[_0x9b3f('0x46')](_0x9b3f('0x88'),_0x2317fd[_0x9b3f('0x57')]['id'][_0x9b3f('0xa6')]())))[_0x9b3f('0xa6')]();break;case _0x9b3f('0xad'):_0x19e8a6=squel[_0x9b3f('0xae')]()['into'](_0x9b3f('0xa0'))['fromQuery']([_0x9b3f('0xa2'),_0x9b3f('0xa3'),'ContactId',_0x9b3f('0xaf'),_0x9b3f('0x66'),'createdAt',_0x9b3f('0x5a')],squel[_0x9b3f('0x82')]()[_0x9b3f('0x83')](_0x9b3f('0xa2'),_0x9b3f('0xa2'))[_0x9b3f('0x83')]('\x27'+_0x291cbe+'\x27',_0x9b3f('0xa3'))['field']('id',_0x9b3f('0xa4'))[_0x9b3f('0x83')](_0x567212[_0x9b3f('0xa5')][_0x9b3f('0xa6')](),_0x9b3f('0xaf'))[_0x9b3f('0x83')](_0x2317fd[_0x9b3f('0x57')]['id'][_0x9b3f('0xa6')](),_0x9b3f('0x66'))[_0x9b3f('0x83')]('\x27'+_0x291cbe+'\x27',_0x9b3f('0x59'))[_0x9b3f('0x83')]('\x27'+_0x291cbe+'\x27',_0x9b3f('0x5a'))[_0x9b3f('0x84')](_0x9b3f('0xa7'))[_0x9b3f('0x46')]('deletedAt\x20IS\x20NULL')[_0x9b3f('0x46')]('ListId\x20=\x20?',_0x567212[_0x9b3f('0xa5')][_0x9b3f('0xa6')]())['where'](_0x9b3f('0xa9'))[_0x9b3f('0x46')](_0x9b3f('0xaa'),squel[_0x9b3f('0x82')]()[_0x9b3f('0x83')](_0x9b3f('0xac'))['from'](_0x9b3f('0xa0'))[_0x9b3f('0x46')](_0x9b3f('0x88'),_0x2317fd['params']['id'][_0x9b3f('0xa6')]())))[_0x9b3f('0xa6')]();break;default:_0x19e8a6=squel[_0x9b3f('0xae')]()[_0x9b3f('0x9f')](_0x9b3f('0xa0'))[_0x9b3f('0xa1')]([_0x9b3f('0xa2'),_0x9b3f('0xa3'),'ContactId',_0x9b3f('0xaf'),'VoiceQueueId',_0x9b3f('0x59'),_0x9b3f('0x5a')],squel['select']()['field'](_0x9b3f('0xa2'),_0x9b3f('0xa2'))[_0x9b3f('0x83')]('\x27'+_0x291cbe+'\x27',_0x9b3f('0xa3'))['field']('id','ContactId')['field'](_0x567212['CmListId'][_0x9b3f('0xa6')](),_0x9b3f('0xaf'))[_0x9b3f('0x83')](_0x2317fd[_0x9b3f('0x57')]['id'][_0x9b3f('0xa6')](),_0x9b3f('0x66'))[_0x9b3f('0x83')]('\x27'+_0x291cbe+'\x27',_0x9b3f('0x59'))[_0x9b3f('0x83')]('\x27'+_0x291cbe+'\x27',_0x9b3f('0x5a'))[_0x9b3f('0x84')](_0x9b3f('0xa7'))[_0x9b3f('0x46')](_0x9b3f('0xa8'))['where']('ListId\x20=\x20?',_0x567212[_0x9b3f('0xa5')][_0x9b3f('0xa6')]())[_0x9b3f('0x46')]('phone\x20IS\x20NOT\x20NULL'))['toString']();}_0x4f5d97[_0x9b3f('0x8a')](db[_0x9b3f('0x74')][_0x9b3f('0x3c')](_0x19e8a6));}return BPromise[_0x9b3f('0x8d')](_0x4f5d97);}})['then'](function(){var _0x395455=[];var _0x542f0f=squel[_0x9b3f('0xae')]()[_0x9b3f('0x9f')](_0x9b3f('0xb0'))[_0x9b3f('0xa1')]([_0x9b3f('0xb1'),_0x9b3f('0xa2'),_0x9b3f('0xb2'),_0x9b3f('0x59'),_0x9b3f('0x5a')],squel[_0x9b3f('0x82')]()[_0x9b3f('0x83')](_0x9b3f('0xb3'))[_0x9b3f('0x83')](_0x9b3f('0xb4'))[_0x9b3f('0x83')](_0x9b3f('0xb5'))[_0x9b3f('0x83')]('\x27'+_0x291cbe+'\x27',_0x9b3f('0x59'))[_0x9b3f('0x83')]('\x27'+_0x291cbe+'\x27',_0x9b3f('0x5a'))[_0x9b3f('0x84')](_0x9b3f('0xb6'),'ci')[_0x9b3f('0xb7')](_0x9b3f('0xa0'),'h','h.ContactId=ci.CmContactId')[_0x9b3f('0x46')](_0x9b3f('0xb8'),_0x291cbe)['where'](_0x9b3f('0xb9'),_0x9b3f('0xba')))[_0x9b3f('0xa6')]();_0x395455[_0x9b3f('0x8a')](db[_0x9b3f('0x74')][_0x9b3f('0x3c')](_0x542f0f));return BPromise['all'](_0x395455);})['then'](function(){return _0x1e72b9;})['then'](respondWithResult(_0x36131f,null))[_0x9b3f('0x4c')](handleError(_0x36131f,null));};exports[_0x9b3f('0xbb')]=function(_0x13e7a5,_0xcf9bad,_0x168698){return db[_0x9b3f('0x37')][_0x9b3f('0x2f')]({'where':{'id':_0x13e7a5[_0x9b3f('0x57')]['id']}})[_0x9b3f('0x25')](handleEntityNotFound(_0xcf9bad,null))[_0x9b3f('0x25')](function(_0x11ffce){if(_0x11ffce){return _0x11ffce[_0x9b3f('0xbb')](_0x13e7a5[_0x9b3f('0x3c')][_0x9b3f('0x91')]);}})[_0x9b3f('0x25')](function(_0x35ecc7){if(_0x35ecc7){return db[_0x9b3f('0x60')]['destroy']({'where':{'ListId':_0x13e7a5['query'][_0x9b3f('0x91')],'VoiceQueueId':_0x13e7a5[_0x9b3f('0x57')]['id']}})[_0x9b3f('0x25')](function(){return _0x35ecc7;});}})[_0x9b3f('0x25')](respondWithStatusCode(_0xcf9bad,null))[_0x9b3f('0x4c')](handleError(_0xcf9bad,null));};exports[_0x9b3f('0xbc')]=function(_0x3081fd,_0xd0aa59,_0x114f15){var _0x2314e8={};var _0x50fd7a={};var _0x174182;var _0x5726ce;return db['VoiceQueue'][_0x9b3f('0x5f')]({'where':{'id':_0x3081fd['params']['id']}})[_0x9b3f('0x25')](handleEntityNotFound(_0xd0aa59,null))[_0x9b3f('0x25')](function(_0x2a30b9){if(_0x2a30b9){_0x174182=_0x2a30b9;_0x50fd7a[_0x9b3f('0x3b')]=_[_0x9b3f('0x3d')](db[_0x9b3f('0x9a')]['rawAttributes']);_0x50fd7a['query']=_['keys'](_0x3081fd[_0x9b3f('0x3c')]);_0x50fd7a['filters']=_[_0x9b3f('0x3f')](_0x50fd7a[_0x9b3f('0x3b')],_0x50fd7a[_0x9b3f('0x3c')]);_0x2314e8[_0x9b3f('0x40')]=_['intersection'](_0x50fd7a[_0x9b3f('0x3b')],qs[_0x9b3f('0x41')](_0x3081fd[_0x9b3f('0x3c')]['fields']));_0x2314e8['attributes']=_0x2314e8[_0x9b3f('0x40')][_0x9b3f('0x42')]?_0x2314e8[_0x9b3f('0x40')]:_0x50fd7a[_0x9b3f('0x3b')];_0x2314e8['order']=qs[_0x9b3f('0x45')](_0x3081fd[_0x9b3f('0x3c')][_0x9b3f('0x45')]);_0x2314e8[_0x9b3f('0x46')]=qs[_0x9b3f('0x3e')](_['pick'](_0x3081fd[_0x9b3f('0x3c')],_0x50fd7a[_0x9b3f('0x3e')]));if(_0x3081fd[_0x9b3f('0x3c')]['filter']){_0x2314e8[_0x9b3f('0x46')]=_[_0x9b3f('0x48')](_0x2314e8[_0x9b3f('0x46')],{'$or':_['map'](_0x2314e8[_0x9b3f('0x40')],function(_0x48082a){var _0x1b0f50={};_0x1b0f50[_0x48082a]={'$like':'%'+_0x3081fd[_0x9b3f('0x3c')][_0x9b3f('0x2a')]+'%'};return _0x1b0f50;})});}_0x2314e8=_['merge']({},_0x2314e8,_0x3081fd[_0x9b3f('0x49')]);return _0x174182[_0x9b3f('0xbc')](_0x2314e8);}})[_0x9b3f('0x25')](function(_0x4f9219){if(_0x4f9219){_0x5726ce=_0x4f9219[_0x9b3f('0x42')];if(!_0x3081fd[_0x9b3f('0x3c')][_0x9b3f('0x43')](_0x9b3f('0x61'))){_0x2314e8[_0x9b3f('0x1f')]=qs[_0x9b3f('0x1f')](_0x3081fd[_0x9b3f('0x3c')][_0x9b3f('0x1f')]);_0x2314e8[_0x9b3f('0x1d')]=qs[_0x9b3f('0x1d')](_0x3081fd[_0x9b3f('0x3c')][_0x9b3f('0x1d')]);}return _0x174182[_0x9b3f('0xbc')](_0x2314e8);}})[_0x9b3f('0x25')](function(_0x59cb79){if(_0x59cb79){return _0x59cb79?{'count':_0x5726ce,'rows':_0x59cb79}:null;}})[_0x9b3f('0x25')](respondWithResult(_0xd0aa59,null))[_0x9b3f('0x4c')](handleError(_0xd0aa59,null));};exports[_0x9b3f('0xbd')]=function(_0x34bb7c,_0x1390a7,_0xf542b5){var _0xa77f64,_0x47b122;return db[_0x9b3f('0x37')]['find']({'where':{'id':_0x34bb7c['params']['id']}})['then'](handleEntityNotFound(_0x1390a7,null))[_0x9b3f('0x25')](function(_0x45b9fa){if(_0x45b9fa){_0x47b122=_0x45b9fa;return _0x45b9fa['addBlackLists'](_0x34bb7c[_0x9b3f('0x4f')][_0x9b3f('0x91')],_['omit'](_0x34bb7c[_0x9b3f('0x4f')],[_0x9b3f('0x91'),'id'])||{});}return null;})[_0x9b3f('0x9c')](function(_0x4df618){var _0x1327cc;_0xa77f64=_0x4df618||[];var _0x2aa355=[];if(_0x4df618){for(var _0x48457d=0x0;_0x48457d<_0x4df618['length'];_0x48457d+=0x1){var _0xf75f7e=_0x4df618[_0x48457d][_0x9b3f('0x27')]({'plain':!![]});_0x1327cc=squel[_0x9b3f('0xae')]()[_0x9b3f('0x9f')]('cm_hopper_black')['fromQuery']([_0x9b3f('0xa2'),'ContactId',_0x9b3f('0xaf'),_0x9b3f('0x66'),_0x9b3f('0x59'),_0x9b3f('0x5a')],squel[_0x9b3f('0x82')]()['field']('phone','phone')['field']('id',_0x9b3f('0xa4'))[_0x9b3f('0x83')](_0xf75f7e[_0x9b3f('0xa5')][_0x9b3f('0xa6')](),'ListId')['field'](_0x34bb7c[_0x9b3f('0x57')]['id'][_0x9b3f('0xa6')](),_0x9b3f('0x66'))[_0x9b3f('0x83')](_0x9b3f('0xbe'),_0x9b3f('0x59'))['field']('NOW()','updatedAt')[_0x9b3f('0x84')](_0x9b3f('0xa7'))[_0x9b3f('0x46')](_0x9b3f('0xa8'))[_0x9b3f('0x46')](_0x9b3f('0xbf'),_0xf75f7e[_0x9b3f('0xa5')]['toString']())[_0x9b3f('0x46')](_0x9b3f('0xa9')))[_0x9b3f('0xa6')]();_0x2aa355[_0x9b3f('0x8a')](db['sequelize'][_0x9b3f('0x3c')](_0x1327cc));}return BPromise[_0x9b3f('0x8d')](_0x2aa355);}})[_0x9b3f('0x25')](function(){return _0xa77f64;})[_0x9b3f('0x25')](respondWithResult(_0x1390a7,null))[_0x9b3f('0x4c')](handleError(_0x1390a7,null));};exports[_0x9b3f('0xc0')]=function(_0x2ef027,_0x3b1a67,_0x5e6d5d){return db['VoiceQueue'][_0x9b3f('0x2f')]({'where':{'id':_0x2ef027[_0x9b3f('0x57')]['id']}})[_0x9b3f('0x25')](handleEntityNotFound(_0x3b1a67,null))[_0x9b3f('0x25')](function(_0x453c16){if(_0x453c16){return _0x453c16[_0x9b3f('0xc0')](_0x2ef027[_0x9b3f('0x3c')]['ids']);}})[_0x9b3f('0x25')](function(_0x61e89b){if(_0x61e89b){return db[_0x9b3f('0x6a')][_0x9b3f('0x26')]({'where':{'ListId':_0x2ef027[_0x9b3f('0x3c')][_0x9b3f('0x91')],'VoiceQueueId':_0x2ef027[_0x9b3f('0x57')]['id']}})[_0x9b3f('0x25')](function(){return _0x61e89b;});}})[_0x9b3f('0x25')](respondWithStatusCode(_0x3b1a67,null))[_0x9b3f('0x4c')](handleError(_0x3b1a67,null));};
\ No newline at end of file
+var _0x6aa7=['ListId\x20=\x20?','CmListId','phone\x20IS\x20NOT\x20NULL','deletedAt\x20IS\x20NULL','cm_hopper_additional_phones','CmHopperId','OrderBy','ci.item','ci.OrderBy+1','cm_contact_has_items','h.ContactId=ci.CmContactId','h.scheduledat=?','ci.ItemClass=?','PHONE','getBlackLists','CmList','addBlackLists','cm_hopper_black','NOW()','removeBlackLists','moment','util','lodash','squel','ioredis','../../config/logger','api','../../config/environment','defaults','localhost','socket.io-emitter','redis','register','sendStatus','status','end','json','undefined','limit','count','offset','Content-Range','update','then','get','VoiceQueues','inbound','QueueCampaigns','outbound','ignore','map','value','includes','type','find','name','UserProfileResource','destroy','error','stack','index','VoiceQueue','rawAttributes','fieldName','getOptions','where','include','rows','show','model','keys','query','attributes','intersection','fields','length','includeAll','merge','options','catch','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','clone','params','omit','updatedAt','createdAt','getHoppers','findOne','filters','nolimit','order','sort','pick','VoiceQueueId','filter','CmHopper','findAll','getHopperHistories','CmHopperHistory','CmHopperFinal','hasOwnProperty','CmHopperBlack','getTeams','Team','addTeams','teams','User','online','voicePause','interface','flatMap','forEach','penalty','Agents','sequelize','transaction','each','TeamVoiceQueue','upsert','findOrCreate','UserVoiceQueueRt','isNil','format','SIP/%s','emit','userVoiceQueue:save','removeTeams','ids','field','tq.TeamId','from','team_has_voice_queues','join','user_has_teams','VoiceQueueId\x20=\x20?','ut.UserId\x20=\x20?','push','SELECT','every','TeamId','compact','isEmpty','removeAgents','addAgents','spread','all','isArray','userVoiceQueue:remove','getAgents','getMembers','getLists','addLists','YYYY-MM-DD\x20HH:mm:ss','dialCheckDuplicateType','insert','into','cm_hopper','fromQuery','phone','scheduledAt','ContactId','ListId','toString','cm_contacts','COALESCE(calleridnum,\x27\x27)','cm_hopper_final','phone\x20NOT\x20IN\x20(?)','COALESCE(phone,\x27\x27)','onlyIfOpen','select'];(function(_0x4baae2,_0x487ab6){var _0x1a2285=function(_0x1cea47){while(--_0x1cea47){_0x4baae2['push'](_0x4baae2['shift']());}};_0x1a2285(++_0x487ab6);}(_0x6aa7,0x178));var _0x76aa=function(_0x55579c,_0x1bc809){_0x55579c=_0x55579c-0x0;var _0x3b421a=_0x6aa7[_0x55579c];return _0x3b421a;};'use strict';var moment=require(_0x76aa('0x0'));var BPromise=require('bluebird');var util=require(_0x76aa('0x1'));var _=require(_0x76aa('0x2'));var squel=require(_0x76aa('0x3'));var Redis=require(_0x76aa('0x4'));var qs=require('../../components/parsers/qs');var logger=require(_0x76aa('0x5'))(_0x76aa('0x6'));var config=require(_0x76aa('0x7'));var db=require('../../mysqldb')['db'];config['redis']=_[_0x76aa('0x8')](config['redis'],{'host':_0x76aa('0x9'),'port':0x18eb});var socket=require(_0x76aa('0xa'))(new Redis(config[_0x76aa('0xb')]));require('./voiceQueue.socket')[_0x76aa('0xc')](socket);function respondWithStatusCode(_0x266bd5,_0x3a3f36){_0x3a3f36=_0x3a3f36||0xcc;return function(_0x557d69){if(_0x557d69){return _0x266bd5[_0x76aa('0xd')](_0x3a3f36);}return _0x266bd5[_0x76aa('0xe')](_0x3a3f36)[_0x76aa('0xf')]();};}function respondWithResult(_0x16cb50,_0x37f1ab){_0x37f1ab=_0x37f1ab||0xc8;return function(_0x128435){if(_0x128435){return _0x16cb50[_0x76aa('0xe')](_0x37f1ab)[_0x76aa('0x10')](_0x128435);}};}function respondWithFilteredResult(_0xd6327,_0x17a417){return function(_0x5e5f47){if(_0x5e5f47){var _0x112c39=typeof _0x17a417['offset']===_0x76aa('0x11')&&typeof _0x17a417[_0x76aa('0x12')]===_0x76aa('0x11');var _0x8e44ed=_0x5e5f47[_0x76aa('0x13')];var _0x4e309f=_0x112c39?0x0:_0x17a417['offset'];var _0x2b3b4f=_0x112c39?_0x5e5f47['count']:_0x17a417[_0x76aa('0x14')]+_0x17a417[_0x76aa('0x12')];var _0x5cf594;if(_0x2b3b4f>=_0x8e44ed){_0x2b3b4f=_0x8e44ed;_0x5cf594=0xc8;}else{_0x5cf594=0xce;}_0xd6327[_0x76aa('0xe')](_0x5cf594);return _0xd6327['set'](_0x76aa('0x15'),_0x4e309f+'-'+_0x2b3b4f+'/'+_0x8e44ed)['json'](_0x5e5f47);}return null;};}function saveUpdates(_0x1515e9){return function(_0x413cf6){if(_0x413cf6){return _0x413cf6[_0x76aa('0x16')](_0x1515e9)[_0x76aa('0x17')](function(_0xa1bc7){return _0xa1bc7;});}return null;};}function removeEntity(_0x3ead3f){return function(_0x496902){if(_0x496902){return _0x496902['destroy']()[_0x76aa('0x17')](function(){var _0x454dd3=_0x496902[_0x76aa('0x18')]({'plain':!![]});var _0x15b931=[{'name':_0x76aa('0x19'),'value':_0x76aa('0x1a'),'ignore':![]},{'name':_0x76aa('0x1b'),'value':_0x76aa('0x1c'),'ignore':![]}];var _0x385157=_(_0x15b931)['filter'](_0x76aa('0x1d'))[_0x76aa('0x1e')](_0x76aa('0x1f'))['value']();if(_[_0x76aa('0x20')](_0x385157,_0x454dd3[_0x76aa('0x21')])){return;}var _0x31252f=_[_0x76aa('0x22')](_0x15b931,[_0x76aa('0x1f'),_0x454dd3[_0x76aa('0x21')]])[_0x76aa('0x23')];return db[_0x76aa('0x24')][_0x76aa('0x25')]({'where':{'type':_0x31252f,'resourceId':_0x454dd3['id']}})[_0x76aa('0x17')](function(){return _0x496902;});})[_0x76aa('0x17')](function(){_0x3ead3f[_0x76aa('0xe')](0xcc)[_0x76aa('0xf')]();});}};}function handleEntityNotFound(_0x4ef9b0){return function(_0xb5e8a9){if(!_0xb5e8a9){_0x4ef9b0[_0x76aa('0xd')](0x194);}return _0xb5e8a9;};}function handleError(_0x25c614,_0x2e7ab4){_0x2e7ab4=_0x2e7ab4||0x1f4;return function(_0xa1e6){logger[_0x76aa('0x26')](_0xa1e6[_0x76aa('0x27')]);if(_0xa1e6[_0x76aa('0x23')]){delete _0xa1e6[_0x76aa('0x23')];}_0x25c614[_0x76aa('0xe')](_0x2e7ab4)['send'](_0xa1e6);};}exports[_0x76aa('0x28')]=function(_0x5a8030,_0x994550){var _0x365ff8={};var _0x2dec94={'count':0x0,'rows':[]};var _0x1e90b9=_[_0x76aa('0x1e')](db[_0x76aa('0x29')][_0x76aa('0x2a')],function(_0x3827ec){return{'name':_0x3827ec[_0x76aa('0x2b')],'type':_0x3827ec[_0x76aa('0x21')]['key']};});_0x365ff8=qs[_0x76aa('0x2c')](_0x1e90b9,_0x5a8030);var _0x5532c7={'where':_0x365ff8[_0x76aa('0x2d')]};return db[_0x76aa('0x29')][_0x76aa('0x13')](_0x5532c7)[_0x76aa('0x17')](function(_0x35a705){_0x2dec94['count']=_0x35a705;_0x365ff8[_0x76aa('0x2e')]=qs[_0x76aa('0x2e')](_0x5a8030['query']);return db[_0x76aa('0x29')]['findAll'](_0x365ff8);})[_0x76aa('0x17')](function(_0x4c90b6){_0x2dec94[_0x76aa('0x2f')]=_0x4c90b6;return _0x2dec94;})['then'](respondWithFilteredResult(_0x994550,_0x365ff8))['catch'](handleError(_0x994550,null));};exports[_0x76aa('0x30')]=function(_0x282c56,_0x198fcb){var _0x37dfab={'raw':![],'where':{'id':_0x282c56['params']['id']}},_0x595a0f={};_0x595a0f[_0x76aa('0x31')]=_[_0x76aa('0x32')](db[_0x76aa('0x29')][_0x76aa('0x2a')]);_0x595a0f[_0x76aa('0x33')]=_['keys'](_0x282c56[_0x76aa('0x33')]);_0x595a0f['filters']=_['intersection'](_0x595a0f[_0x76aa('0x31')],_0x595a0f[_0x76aa('0x33')]);_0x37dfab[_0x76aa('0x34')]=_[_0x76aa('0x35')](_0x595a0f['model'],qs[_0x76aa('0x36')](_0x282c56[_0x76aa('0x33')][_0x76aa('0x36')]));_0x37dfab['attributes']=_0x37dfab[_0x76aa('0x34')][_0x76aa('0x37')]?_0x37dfab[_0x76aa('0x34')]:_0x595a0f[_0x76aa('0x31')];if(_0x282c56[_0x76aa('0x33')][_0x76aa('0x38')]){_0x37dfab[_0x76aa('0x2e')]=[{'all':!![]}];}_0x37dfab=_[_0x76aa('0x39')]({},_0x37dfab,_0x282c56[_0x76aa('0x3a')]);return db['VoiceQueue'][_0x76aa('0x22')](_0x37dfab)[_0x76aa('0x17')](handleEntityNotFound(_0x198fcb,null))[_0x76aa('0x17')](respondWithResult(_0x198fcb,null))[_0x76aa('0x3b')](handleError(_0x198fcb,null));};exports[_0x76aa('0x3c')]=function(_0x2957aa,_0x572fdb){return db['VoiceQueue'][_0x76aa('0x3c')](_0x2957aa[_0x76aa('0x3d')],{})[_0x76aa('0x17')](function(_0x365612){var _0x50599f=_0x2957aa[_0x76aa('0x3e')][_0x76aa('0x18')]({'plain':!![]});if(!_0x50599f)throw new Error(_0x76aa('0x3f'));if(_0x50599f[_0x76aa('0x40')]===_0x76aa('0x3e')){var _0x4aa2f3=_0x365612[_0x76aa('0x18')]({'plain':!![]});var _0x556f59=[{'name':_0x76aa('0x19'),'value':'inbound'},{'name':'QueueCampaigns','value':'outbound'}];var _0x144f0a=_['find'](_0x556f59,['value',_0x4aa2f3['type']])[_0x76aa('0x23')];return db[_0x76aa('0x41')][_0x76aa('0x22')]({'where':{'name':_0x144f0a,'userProfileId':_0x50599f[_0x76aa('0x42')]},'raw':!![]})[_0x76aa('0x17')](function(_0x47b0c8){if(_0x47b0c8&&_0x47b0c8[_0x76aa('0x43')]===0x0){return db[_0x76aa('0x24')][_0x76aa('0x3c')]({'name':_0x4aa2f3[_0x76aa('0x23')],'resourceId':_0x4aa2f3['id'],'type':_0x47b0c8[_0x76aa('0x23')],'sectionId':_0x47b0c8['id']},{})['then'](function(){return _0x365612;});}else{return _0x365612;}})[_0x76aa('0x3b')](function(_0x1c62a9){logger['error'](_0x76aa('0x44'),_0x1c62a9);throw _0x1c62a9;});}return _0x365612;})['then'](respondWithResult(_0x572fdb,0xc9))[_0x76aa('0x3b')](handleError(_0x572fdb,null));};exports[_0x76aa('0x45')]=function(_0x31930b,_0x18fd3e){var _0x2d0bc4={'where':{'id':_0x31930b[_0x76aa('0x46')]['id']}},_0x3e0315={};_0x3e0315[_0x76aa('0x31')]=_[_0x76aa('0x32')](db[_0x76aa('0x29')]['rawAttributes']);_0x2d0bc4[_0x76aa('0x34')]=_['intersection'](_0x3e0315[_0x76aa('0x31')],qs[_0x76aa('0x36')](_0x31930b[_0x76aa('0x33')][_0x76aa('0x36')]));_0x2d0bc4['attributes']=_0x2d0bc4['attributes'][_0x76aa('0x37')]?_0x2d0bc4['attributes']:_0x3e0315[_0x76aa('0x31')];if(_0x31930b[_0x76aa('0x33')][_0x76aa('0x38')]){_0x2d0bc4[_0x76aa('0x2e')]=[{'all':!![]}];}_0x2d0bc4=_[_0x76aa('0x39')]({},_0x2d0bc4,_0x31930b[_0x76aa('0x3a')]);return db['VoiceQueue']['find'](_0x2d0bc4)[_0x76aa('0x17')](handleEntityNotFound(_0x18fd3e,null))[_0x76aa('0x17')](function(_0x1708d4){if(_0x1708d4){var _0x40e8ff=_0x1708d4[_0x76aa('0x18')]({'plain':!![]});_0x40e8ff=qs[_0x76aa('0x47')](_0x40e8ff,['id','createdAt',_0x76aa('0x48')]);_0x31930b[_0x76aa('0x3d')]=_[_0x76aa('0x47')](_0x31930b['body'],['id',_0x76aa('0x49'),'updatedAt']);return db[_0x76aa('0x29')]['create'](_[_0x76aa('0x39')](_0x40e8ff,_0x31930b[_0x76aa('0x3d')]),{'include':_0x31930b[_0x76aa('0x33')][_0x76aa('0x38')]?[{'all':!![]}]:undefined})[_0x76aa('0x17')](function(_0x316de3){var _0x953726=_0x31930b['user'][_0x76aa('0x18')]({'plain':!![]});if(!_0x953726)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x953726[_0x76aa('0x40')]===_0x76aa('0x3e')){var _0x288151=_0x316de3[_0x76aa('0x18')]({'plain':!![]});var _0x3fa7ec=[{'name':_0x76aa('0x19'),'value':_0x76aa('0x1a')},{'name':'QueueCampaigns','value':_0x76aa('0x1c')}];var _0x281f73=_[_0x76aa('0x22')](_0x3fa7ec,[_0x76aa('0x1f'),_0x288151['type']])[_0x76aa('0x23')];return db[_0x76aa('0x41')][_0x76aa('0x22')]({'where':{'name':_0x281f73,'userProfileId':_0x953726[_0x76aa('0x42')]},'raw':!![]})[_0x76aa('0x17')](function(_0xf7732){if(_0xf7732&&_0xf7732['autoAssociation']===0x0){return db[_0x76aa('0x24')][_0x76aa('0x3c')]({'name':_0x288151[_0x76aa('0x23')],'resourceId':_0x288151['id'],'type':_0xf7732[_0x76aa('0x23')],'sectionId':_0xf7732['id']},{})[_0x76aa('0x17')](function(){return _0x316de3;});}else{return _0x316de3;}})[_0x76aa('0x3b')](function(_0x37babe){logger['error']('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x37babe);throw _0x37babe;});}return _0x316de3;});}})[_0x76aa('0x17')](respondWithResult(_0x18fd3e,0xc9))[_0x76aa('0x3b')](handleError(_0x18fd3e,null));};exports['update']=function(_0x3d7802,_0x1e6f3c){if(_0x3d7802['body']['id']){delete _0x3d7802[_0x76aa('0x3d')]['id'];}return db[_0x76aa('0x29')][_0x76aa('0x22')]({'where':{'id':_0x3d7802[_0x76aa('0x46')]['id']}})[_0x76aa('0x17')](handleEntityNotFound(_0x1e6f3c,null))[_0x76aa('0x17')](saveUpdates(_0x3d7802[_0x76aa('0x3d')],null))[_0x76aa('0x17')](respondWithResult(_0x1e6f3c,null))[_0x76aa('0x3b')](handleError(_0x1e6f3c,null));};exports['destroy']=function(_0xd337f0,_0x49156c){return db[_0x76aa('0x29')][_0x76aa('0x22')]({'where':{'id':_0xd337f0[_0x76aa('0x46')]['id']}})[_0x76aa('0x17')](handleEntityNotFound(_0x49156c,null))[_0x76aa('0x17')](removeEntity(_0x49156c,null))[_0x76aa('0x3b')](handleError(_0x49156c,null));};exports[_0x76aa('0x4a')]=function(_0x431d1c,_0x2f1263){var _0x5eceba={'raw':![],'where':{}};var _0x267fcf={};var _0x3d4025={'count':0x0,'rows':[]};return db[_0x76aa('0x29')][_0x76aa('0x4b')]({'where':{'id':_0x431d1c[_0x76aa('0x46')]['id']}})[_0x76aa('0x17')](handleEntityNotFound(_0x2f1263,null))[_0x76aa('0x17')](function(_0x157540){if(_0x157540){_0x267fcf['model']=_[_0x76aa('0x32')](db['CmHopper'][_0x76aa('0x2a')]);_0x267fcf[_0x76aa('0x33')]=_[_0x76aa('0x32')](_0x431d1c[_0x76aa('0x33')]);_0x267fcf[_0x76aa('0x4c')]=_[_0x76aa('0x35')](_0x267fcf[_0x76aa('0x31')],_0x267fcf['query']);_0x5eceba[_0x76aa('0x34')]=_[_0x76aa('0x35')](_0x267fcf['model'],qs['fields'](_0x431d1c[_0x76aa('0x33')][_0x76aa('0x36')]));_0x5eceba['attributes']=_0x5eceba[_0x76aa('0x34')][_0x76aa('0x37')]?_0x5eceba[_0x76aa('0x34')]:_0x267fcf['model'];if(!_0x431d1c[_0x76aa('0x33')]['hasOwnProperty'](_0x76aa('0x4d'))){_0x5eceba[_0x76aa('0x12')]=qs[_0x76aa('0x12')](_0x431d1c[_0x76aa('0x33')]['limit']);_0x5eceba['offset']=qs[_0x76aa('0x14')](_0x431d1c['query'][_0x76aa('0x14')]);}_0x5eceba[_0x76aa('0x4e')]=qs[_0x76aa('0x4f')](_0x431d1c[_0x76aa('0x33')][_0x76aa('0x4f')]);_0x5eceba[_0x76aa('0x2d')]=qs[_0x76aa('0x4c')](_[_0x76aa('0x50')](_0x431d1c[_0x76aa('0x33')],_0x267fcf['filters']));_0x5eceba[_0x76aa('0x2d')][_0x76aa('0x51')]=_0x157540['id'];if(_0x431d1c[_0x76aa('0x33')][_0x76aa('0x52')]){_0x5eceba['where']=_['merge'](_0x5eceba['where'],{'$or':_[_0x76aa('0x1e')](_0x5eceba['attributes'],function(_0xb61e5){var _0x256195={};_0x256195[_0xb61e5]={'$like':'%'+_0x431d1c[_0x76aa('0x33')][_0x76aa('0x52')]+'%'};return _0x256195;})});}_0x5eceba=_['merge']({},_0x5eceba,_0x431d1c[_0x76aa('0x3a')]);return db['CmHopper'][_0x76aa('0x13')]({'where':_0x5eceba[_0x76aa('0x2d')]})[_0x76aa('0x17')](function(_0x11d602){_0x3d4025[_0x76aa('0x13')]=_0x11d602;if(_0x431d1c['query'][_0x76aa('0x38')]){_0x5eceba[_0x76aa('0x2e')]=[{'all':!![]}];}return db[_0x76aa('0x53')][_0x76aa('0x54')](_0x5eceba);})[_0x76aa('0x17')](function(_0x22432d){_0x3d4025[_0x76aa('0x2f')]=_0x22432d;return _0x3d4025;});}})[_0x76aa('0x17')](respondWithFilteredResult(_0x2f1263,_0x5eceba))['catch'](handleError(_0x2f1263,null));};exports[_0x76aa('0x55')]=function(_0x381f44,_0x48136a){var _0x3c1b98={'raw':!![],'where':{}};var _0x215463={};var _0x325487={'count':0x0,'rows':[]};return db[_0x76aa('0x29')][_0x76aa('0x4b')]({'where':{'id':_0x381f44[_0x76aa('0x46')]['id']}})[_0x76aa('0x17')](handleEntityNotFound(_0x48136a,null))['then'](function(_0xdb821b){if(_0xdb821b){_0x215463['model']=_['keys'](db[_0x76aa('0x56')][_0x76aa('0x2a')]);_0x215463['query']=_['keys'](_0x381f44[_0x76aa('0x33')]);_0x215463[_0x76aa('0x4c')]=_[_0x76aa('0x35')](_0x215463['model'],_0x215463['query']);_0x3c1b98[_0x76aa('0x34')]=_[_0x76aa('0x35')](_0x215463[_0x76aa('0x31')],qs['fields'](_0x381f44[_0x76aa('0x33')]['fields']));_0x3c1b98[_0x76aa('0x34')]=_0x3c1b98[_0x76aa('0x34')][_0x76aa('0x37')]?_0x3c1b98[_0x76aa('0x34')]:_0x215463[_0x76aa('0x31')];if(!_0x381f44['query']['hasOwnProperty'](_0x76aa('0x4d'))){_0x3c1b98[_0x76aa('0x12')]=qs[_0x76aa('0x12')](_0x381f44['query'][_0x76aa('0x12')]);_0x3c1b98[_0x76aa('0x14')]=qs[_0x76aa('0x14')](_0x381f44[_0x76aa('0x33')][_0x76aa('0x14')]);}_0x3c1b98['order']=qs[_0x76aa('0x4f')](_0x381f44['query'][_0x76aa('0x4f')]);_0x3c1b98[_0x76aa('0x2d')]=qs[_0x76aa('0x4c')](_[_0x76aa('0x50')](_0x381f44[_0x76aa('0x33')],_0x215463[_0x76aa('0x4c')]));_0x3c1b98['where']['VoiceQueueId']=_0xdb821b['id'];if(_0x381f44['query']['filter']){_0x3c1b98['where']=_[_0x76aa('0x39')](_0x3c1b98[_0x76aa('0x2d')],{'$or':_['map'](_0x3c1b98['attributes'],function(_0x4f01e9){var _0x3a6326={};_0x3a6326[_0x4f01e9]={'$like':'%'+_0x381f44[_0x76aa('0x33')][_0x76aa('0x52')]+'%'};return _0x3a6326;})});}_0x3c1b98=_['merge']({},_0x3c1b98,_0x381f44['options']);return db[_0x76aa('0x56')][_0x76aa('0x13')]({'where':_0x3c1b98[_0x76aa('0x2d')]})[_0x76aa('0x17')](function(_0x354c7b){_0x325487['count']=_0x354c7b;if(_0x381f44['query'][_0x76aa('0x38')]){_0x3c1b98['include']=[{'all':!![]}];}return db['CmHopperHistory']['findAll'](_0x3c1b98);})[_0x76aa('0x17')](function(_0xbb1ccd){_0x325487['rows']=_0xbb1ccd;return _0x325487;});}})[_0x76aa('0x17')](respondWithFilteredResult(_0x48136a,_0x3c1b98))[_0x76aa('0x3b')](handleError(_0x48136a,null));};exports['getHopperFinals']=function(_0x22063f,_0x24331a){var _0x11d91f={'raw':!![],'where':{}};var _0x258e5a={};var _0x1fa86b={'count':0x0,'rows':[]};return db[_0x76aa('0x29')][_0x76aa('0x4b')]({'where':{'id':_0x22063f[_0x76aa('0x46')]['id']}})[_0x76aa('0x17')](handleEntityNotFound(_0x24331a,null))['then'](function(_0x84bc91){if(_0x84bc91){_0x258e5a[_0x76aa('0x31')]=_['keys'](db[_0x76aa('0x57')][_0x76aa('0x2a')]);_0x258e5a[_0x76aa('0x33')]=_['keys'](_0x22063f[_0x76aa('0x33')]);_0x258e5a[_0x76aa('0x4c')]=_['intersection'](_0x258e5a[_0x76aa('0x31')],_0x258e5a[_0x76aa('0x33')]);_0x11d91f[_0x76aa('0x34')]=_['intersection'](_0x258e5a[_0x76aa('0x31')],qs[_0x76aa('0x36')](_0x22063f['query']['fields']));_0x11d91f['attributes']=_0x11d91f[_0x76aa('0x34')][_0x76aa('0x37')]?_0x11d91f[_0x76aa('0x34')]:_0x258e5a[_0x76aa('0x31')];if(!_0x22063f['query']['hasOwnProperty']('nolimit')){_0x11d91f[_0x76aa('0x12')]=qs['limit'](_0x22063f[_0x76aa('0x33')][_0x76aa('0x12')]);_0x11d91f['offset']=qs[_0x76aa('0x14')](_0x22063f[_0x76aa('0x33')]['offset']);}_0x11d91f[_0x76aa('0x4e')]=qs[_0x76aa('0x4f')](_0x22063f[_0x76aa('0x33')][_0x76aa('0x4f')]);_0x11d91f[_0x76aa('0x2d')]=qs[_0x76aa('0x4c')](_['pick'](_0x22063f[_0x76aa('0x33')],_0x258e5a['filters']));_0x11d91f['where']['VoiceQueueId']=_0x84bc91['id'];if(_0x22063f['query']['filter']){_0x11d91f[_0x76aa('0x2d')]=_[_0x76aa('0x39')](_0x11d91f[_0x76aa('0x2d')],{'$or':_[_0x76aa('0x1e')](_0x11d91f['attributes'],function(_0x447103){var _0x2192ed={};_0x2192ed[_0x447103]={'$like':'%'+_0x22063f[_0x76aa('0x33')][_0x76aa('0x52')]+'%'};return _0x2192ed;})});}_0x11d91f=_[_0x76aa('0x39')]({},_0x11d91f,_0x22063f['options']);return db[_0x76aa('0x57')][_0x76aa('0x13')]({'where':_0x11d91f[_0x76aa('0x2d')]})[_0x76aa('0x17')](function(_0x13be70){_0x1fa86b[_0x76aa('0x13')]=_0x13be70;if(_0x22063f[_0x76aa('0x33')]['includeAll']){_0x11d91f[_0x76aa('0x2e')]=[{'all':!![]}];}return db[_0x76aa('0x57')]['findAll'](_0x11d91f);})['then'](function(_0x216e87){_0x1fa86b[_0x76aa('0x2f')]=_0x216e87;return _0x1fa86b;});}})['then'](respondWithFilteredResult(_0x24331a,_0x11d91f))[_0x76aa('0x3b')](handleError(_0x24331a,null));};exports['getHopperBlacks']=function(_0x28ec11,_0x5cc005){var _0x28b439={'raw':!![],'where':{}};var _0x583924={};var _0x45227e={'count':0x0,'rows':[]};return db[_0x76aa('0x29')][_0x76aa('0x4b')]({'where':{'id':_0x28ec11['params']['id']}})[_0x76aa('0x17')](handleEntityNotFound(_0x5cc005,null))['then'](function(_0x1af32e){if(_0x1af32e){_0x583924[_0x76aa('0x31')]=_['keys'](db['CmHopperBlack'][_0x76aa('0x2a')]);_0x583924[_0x76aa('0x33')]=_[_0x76aa('0x32')](_0x28ec11[_0x76aa('0x33')]);_0x583924['filters']=_['intersection'](_0x583924[_0x76aa('0x31')],_0x583924['query']);_0x28b439[_0x76aa('0x34')]=_['intersection'](_0x583924[_0x76aa('0x31')],qs[_0x76aa('0x36')](_0x28ec11['query'][_0x76aa('0x36')]));_0x28b439['attributes']=_0x28b439['attributes'][_0x76aa('0x37')]?_0x28b439[_0x76aa('0x34')]:_0x583924['model'];if(!_0x28ec11[_0x76aa('0x33')][_0x76aa('0x58')](_0x76aa('0x4d'))){_0x28b439['limit']=qs[_0x76aa('0x12')](_0x28ec11[_0x76aa('0x33')][_0x76aa('0x12')]);_0x28b439[_0x76aa('0x14')]=qs[_0x76aa('0x14')](_0x28ec11[_0x76aa('0x33')][_0x76aa('0x14')]);}_0x28b439[_0x76aa('0x4e')]=qs[_0x76aa('0x4f')](_0x28ec11[_0x76aa('0x33')][_0x76aa('0x4f')]);_0x28b439[_0x76aa('0x2d')]=qs['filters'](_[_0x76aa('0x50')](_0x28ec11[_0x76aa('0x33')],_0x583924['filters']));_0x28b439[_0x76aa('0x2d')][_0x76aa('0x51')]=_0x1af32e['id'];if(_0x28ec11['query']['filter']){_0x28b439[_0x76aa('0x2d')]=_[_0x76aa('0x39')](_0x28b439['where'],{'$or':_[_0x76aa('0x1e')](_0x28b439[_0x76aa('0x34')],function(_0x24af48){var _0x5010c8={};_0x5010c8[_0x24af48]={'$like':'%'+_0x28ec11[_0x76aa('0x33')][_0x76aa('0x52')]+'%'};return _0x5010c8;})});}_0x28b439=_['merge']({},_0x28b439,_0x28ec11[_0x76aa('0x3a')]);return db[_0x76aa('0x59')][_0x76aa('0x13')]({'where':_0x28b439[_0x76aa('0x2d')]})[_0x76aa('0x17')](function(_0x42543c){_0x45227e['count']=_0x42543c;if(_0x28ec11[_0x76aa('0x33')]['includeAll']){_0x28b439[_0x76aa('0x2e')]=[{'all':!![]}];}return db[_0x76aa('0x59')][_0x76aa('0x54')](_0x28b439);})['then'](function(_0x4c5f54){_0x45227e[_0x76aa('0x2f')]=_0x4c5f54;return _0x45227e;});}})[_0x76aa('0x17')](respondWithFilteredResult(_0x5cc005,_0x28b439))[_0x76aa('0x3b')](handleError(_0x5cc005,null));};exports[_0x76aa('0x5a')]=function(_0x1a81fd,_0x1eb8f2){var _0x4f7dd4={};var _0x5a4c03={};var _0x2565a2;var _0x109bd3;return db[_0x76aa('0x29')][_0x76aa('0x4b')]({'where':{'id':_0x1a81fd['params']['id']}})[_0x76aa('0x17')](handleEntityNotFound(_0x1eb8f2,null))['then'](function(_0x54d530){if(_0x54d530){_0x2565a2=_0x54d530;_0x5a4c03[_0x76aa('0x31')]=_[_0x76aa('0x32')](db[_0x76aa('0x5b')]['rawAttributes']);_0x5a4c03[_0x76aa('0x33')]=_[_0x76aa('0x32')](_0x1a81fd[_0x76aa('0x33')]);_0x5a4c03[_0x76aa('0x4c')]=_[_0x76aa('0x35')](_0x5a4c03[_0x76aa('0x31')],_0x5a4c03[_0x76aa('0x33')]);_0x4f7dd4['attributes']=_[_0x76aa('0x35')](_0x5a4c03[_0x76aa('0x31')],qs[_0x76aa('0x36')](_0x1a81fd[_0x76aa('0x33')][_0x76aa('0x36')]));_0x4f7dd4[_0x76aa('0x34')]=_0x4f7dd4['attributes'][_0x76aa('0x37')]?_0x4f7dd4[_0x76aa('0x34')]:_0x5a4c03[_0x76aa('0x31')];_0x4f7dd4[_0x76aa('0x4e')]=qs['sort'](_0x1a81fd[_0x76aa('0x33')][_0x76aa('0x4f')]);_0x4f7dd4[_0x76aa('0x2d')]=qs[_0x76aa('0x4c')](_[_0x76aa('0x50')](_0x1a81fd['query'],_0x5a4c03[_0x76aa('0x4c')]));if(_0x1a81fd[_0x76aa('0x33')]['filter']){_0x4f7dd4['where']=_[_0x76aa('0x39')](_0x4f7dd4[_0x76aa('0x2d')],{'$or':_[_0x76aa('0x1e')](_0x4f7dd4[_0x76aa('0x34')],function(_0x46f098){var _0x293221={};_0x293221[_0x46f098]={'$like':'%'+_0x1a81fd['query'][_0x76aa('0x52')]+'%'};return _0x293221;})});}_0x4f7dd4=_[_0x76aa('0x39')]({},_0x4f7dd4,_0x1a81fd[_0x76aa('0x3a')]);return _0x2565a2[_0x76aa('0x5a')](_0x4f7dd4);}})[_0x76aa('0x17')](function(_0x2e7bb7){if(_0x2e7bb7){_0x109bd3=_0x2e7bb7['length'];if(!_0x1a81fd[_0x76aa('0x33')][_0x76aa('0x58')](_0x76aa('0x4d'))){_0x4f7dd4[_0x76aa('0x12')]=qs[_0x76aa('0x12')](_0x1a81fd[_0x76aa('0x33')]['limit']);_0x4f7dd4[_0x76aa('0x14')]=qs['offset'](_0x1a81fd[_0x76aa('0x33')]['offset']);}return _0x2565a2[_0x76aa('0x5a')](_0x4f7dd4);}})[_0x76aa('0x17')](function(_0x56d6af){if(_0x56d6af){return _0x56d6af?{'count':_0x109bd3,'rows':_0x56d6af}:null;}})[_0x76aa('0x17')](respondWithResult(_0x1eb8f2,null))[_0x76aa('0x3b')](handleError(_0x1eb8f2,null));};exports[_0x76aa('0x5c')]=function(_0x57636c,_0x3ae5e8){var _0x46c818=_0x57636c['body'][_0x76aa('0x5d')];var _0xfe926d=_[_0x76aa('0x1e')](_0x46c818,'id');return db[_0x76aa('0x5b')][_0x76aa('0x54')]({'where':{'id':_0xfe926d},'attributes':['id'],'include':[{'model':db[_0x76aa('0x5e')],'as':'Agents','attributes':['id',_0x76aa('0x23'),_0x76aa('0x5f'),_0x76aa('0x60'),_0x76aa('0x61')],'raw':!![]}]})[_0x76aa('0x17')](function(_0x28e1a4){if(_0x28e1a4){var _0x8bb516=_[_0x76aa('0x62')](_0x28e1a4,function(_0xf9f670){var _0x1359f9=_0xf9f670[_0x76aa('0x18')]({'plain':!![]});_0x1359f9['Agents'][_0x76aa('0x63')](function(_0x58cd0c){_0x58cd0c[_0x76aa('0x64')]=_[_0x76aa('0x22')](_0x46c818,{'id':_0x1359f9['id']})[_0x76aa('0x64')];});return _0x1359f9[_0x76aa('0x65')];});return db[_0x76aa('0x29')][_0x76aa('0x22')]({'where':{'id':_0x57636c['params']['id']}})[_0x76aa('0x17')](function(_0x53090c){return db[_0x76aa('0x66')][_0x76aa('0x67')](function(_0x2045a2){return _0x53090c['addTeams'](_0xfe926d,{'transaction':_0x2045a2})[_0x76aa('0x17')](function(){return BPromise[_0x76aa('0x68')](_0x46c818,function(_0x228968){return db[_0x76aa('0x69')][_0x76aa('0x6a')]({'TeamId':_0x228968['id'],'VoiceQueueId':_0x57636c['params']['id'],'penalty':_0x228968[_0x76aa('0x64')]},{'transaction':_0x2045a2});});})['then'](function(){return BPromise[_0x76aa('0x68')](_0x8bb516,function(_0x1bc764){return db['UserVoiceQueue'][_0x76aa('0x6b')]({'where':{'UserId':_0x1bc764['id'],'VoiceQueueId':_0x57636c[_0x76aa('0x46')]['id']},'defaults':{'penalty':_0x1bc764[_0x76aa('0x64')]},'transaction':_0x2045a2});});})[_0x76aa('0x17')](function(){return BPromise[_0x76aa('0x68')](_[_0x76aa('0x52')](_0x8bb516,{'online':!![]}),function(_0x245af7){return db[_0x76aa('0x6c')]['upsert']({'membername':_0x245af7[_0x76aa('0x23')],'UserId':_0x245af7['id'],'queue_name':_0x53090c[_0x76aa('0x23')],'VoiceQueueId':_0x53090c['id'],'interface':_[_0x76aa('0x6d')](_0x245af7[_0x76aa('0x61')])?util[_0x76aa('0x6e')](_0x76aa('0x6f'),_0x245af7[_0x76aa('0x23')]):_0x245af7[_0x76aa('0x61')],'paused':_0x245af7['voicePause']||![],'penalty':_0x245af7[_0x76aa('0x64')]},{'transaction':_0x2045a2});});})[_0x76aa('0x17')](function(){_0x8bb516[_0x76aa('0x63')](function(_0x54e450){socket[_0x76aa('0x70')](_0x76aa('0x71'),{'UserId':_0x54e450['id'],'VoiceQueueId':_0x53090c['id']});});});});});}})[_0x76aa('0x17')](respondWithStatusCode(_0x3ae5e8,null))[_0x76aa('0x3b')](handleError(_0x3ae5e8,null));};exports[_0x76aa('0x72')]=function(_0x5db8d8,_0x21fd43){return db['Team'][_0x76aa('0x54')]({'where':{'id':_0x5db8d8[_0x76aa('0x33')][_0x76aa('0x73')]},'attributes':['id'],'include':[{'model':db[_0x76aa('0x5e')],'as':_0x76aa('0x65'),'attributes':['id'],'raw':!![]}]})['then'](handleEntityNotFound(_0x21fd43,null))[_0x76aa('0x17')](function(_0x4920fa){var _0x577463=_[_0x76aa('0x1e')](_0x4920fa,'id');var _0x20ba92=[];var _0x533080=[];var _0x3cd088=squel['select']();_0x3cd088[_0x76aa('0x74')](_0x76aa('0x75'))[_0x76aa('0x76')](_0x76aa('0x77'),'tq')[_0x76aa('0x78')](_0x76aa('0x79'),'ut','ut.TeamId\x20=\x20tq.TeamId')[_0x76aa('0x2d')](_0x76aa('0x7a'),_0x5db8d8[_0x76aa('0x46')]['id']);for(var _0x3ebe91=0x0;_0x3ebe91<_0x4920fa[_0x76aa('0x37')];_0x3ebe91+=0x1){let _0x14318c=_0x4920fa[_0x3ebe91];for(var _0xbfa5f8=0x0;_0xbfa5f8<_0x14318c[_0x76aa('0x65')][_0x76aa('0x37')];_0xbfa5f8+=0x1){let _0x46772f=_0x14318c[_0x76aa('0x65')][_0xbfa5f8];var _0x40df44=_0x3cd088[_0x76aa('0x45')]();_0x40df44[_0x76aa('0x2d')](_0x76aa('0x7b'),_0x46772f['id']);_0x533080[_0x76aa('0x7c')](db[_0x76aa('0x66')][_0x76aa('0x33')](_0x40df44['toString'](),{'type':db[_0x76aa('0x66')]['QueryTypes'][_0x76aa('0x7d')]})[_0x76aa('0x17')](function(_0x4a093b){if(_0x4a093b[_0x76aa('0x37')]===0x1){return _0x46772f['id'];}else{var _0x5305f1=_[_0x76aa('0x7e')](_[_0x76aa('0x1e')](_0x4a093b,_0x76aa('0x7f')),function(_0x5ceae2){return _[_0x76aa('0x20')](_0x577463,_0x5ceae2);});if(_0x5305f1){return _0x46772f['id'];}}}));}}return BPromise['all'](_0x533080)['then'](function(_0x3c9841){_0x20ba92=_(_0x20ba92)['union'](_0x3c9841)[_0x76aa('0x80')]()['value']();return db['VoiceQueue'][_0x76aa('0x22')]({'where':{'id':_0x5db8d8[_0x76aa('0x46')]['id']}})[_0x76aa('0x17')](function(_0x3f4ded){return db[_0x76aa('0x66')][_0x76aa('0x67')](function(_0x434634){return _0x3f4ded[_0x76aa('0x72')](_0x5db8d8[_0x76aa('0x33')][_0x76aa('0x73')],{'transaction':_0x434634})[_0x76aa('0x17')](function(){if(!_[_0x76aa('0x81')](_0x20ba92)){return _0x3f4ded[_0x76aa('0x82')](_0x20ba92,{'transaction':_0x434634})[_0x76aa('0x17')](function(){return db['UserVoiceQueueRt'][_0x76aa('0x25')]({'where':{'VoiceQueueId':_0x5db8d8[_0x76aa('0x46')]['id'],'UserId':_0x20ba92},'transaction':_0x434634});});}})[_0x76aa('0x17')](function(){_0x20ba92[_0x76aa('0x63')](function(_0x540bf3){socket[_0x76aa('0x70')]('userVoiceQueue:remove',{'UserId':_0x540bf3,'VoiceQueueId':_0x3f4ded['id']});});});});});});})[_0x76aa('0x17')](respondWithStatusCode(_0x21fd43,null))['catch'](handleError(_0x21fd43,null));};exports[_0x76aa('0x83')]=function(_0x5427f0,_0x3e9153){var _0x490090,_0x31b7a8;return db['VoiceQueue'][_0x76aa('0x22')]({'where':{'id':_0x5427f0[_0x76aa('0x46')]['id']}})['then'](handleEntityNotFound(_0x3e9153,null))[_0x76aa('0x17')](function(_0x51feca){if(_0x51feca){_0x31b7a8=_0x51feca;return _0x51feca[_0x76aa('0x83')](_0x5427f0['body'][_0x76aa('0x73')],_['omit'](_0x5427f0['body'],[_0x76aa('0x73'),'id'])||{})[_0x76aa('0x84')](function(_0x38b6aa){for(var _0x395501=0x0;_0x395501<_0x5427f0[_0x76aa('0x3d')][_0x76aa('0x73')][_0x76aa('0x37')];_0x395501+=0x1){socket[_0x76aa('0x70')](_0x76aa('0x71'),{'UserId':Number(_0x5427f0[_0x76aa('0x3d')]['ids'][_0x395501]),'VoiceQueueId':Number(_0x5427f0[_0x76aa('0x46')]['id'])});}return _0x38b6aa;});}})[_0x76aa('0x17')](function(_0x3d969f){_0x490090=_0x3d969f||[];if(_0x31b7a8){return db[_0x76aa('0x5e')][_0x76aa('0x54')]({'where':{'id':_0x5427f0[_0x76aa('0x3d')][_0x76aa('0x73')]},'attributes':['id',_0x76aa('0x23'),_0x76aa('0x5f'),_0x76aa('0x60'),_0x76aa('0x61')],'raw':!![]});}})[_0x76aa('0x17')](function(_0x3274a9){if(!_[_0x76aa('0x81')](_0x3274a9)){var _0x5c0268=[];for(var _0x5c5a6f=0x0;_0x5c5a6f<_0x3274a9[_0x76aa('0x37')];_0x5c5a6f++){if(_0x3274a9[_0x5c5a6f][_0x76aa('0x5f')]){_0x5c0268[_0x76aa('0x7c')](db['UserVoiceQueueRt']['upsert']({'membername':_0x3274a9[_0x5c5a6f][_0x76aa('0x23')],'UserId':_0x3274a9[_0x5c5a6f]['id'],'queue_name':_0x31b7a8[_0x76aa('0x23')],'VoiceQueueId':_0x31b7a8['id'],'interface':_[_0x76aa('0x6d')](_0x3274a9[_0x5c5a6f]['interface'])?util[_0x76aa('0x6e')](_0x76aa('0x6f'),_0x3274a9[_0x5c5a6f]['name']):_0x3274a9[_0x5c5a6f]['interface'],'paused':_0x3274a9[_0x5c5a6f]['voicePause']||![],'penalty':_0x5427f0[_0x76aa('0x3d')][_0x76aa('0x64')]||0x0}));}}return BPromise[_0x76aa('0x85')](_0x5c0268);}})['then'](function(){return _0x490090;})[_0x76aa('0x17')](respondWithResult(_0x3e9153,null))[_0x76aa('0x3b')](handleError(_0x3e9153,null));};exports['removeAgents']=function(_0x5433dc,_0x328d1a){return db[_0x76aa('0x29')][_0x76aa('0x22')]({'where':{'id':_0x5433dc['params']['id']}})[_0x76aa('0x17')](handleEntityNotFound(_0x328d1a,null))[_0x76aa('0x17')](function(_0x546770){if(_0x546770){return _0x546770[_0x76aa('0x82')](_0x5433dc[_0x76aa('0x33')]['ids'])[_0x76aa('0x17')](function(){if(_[_0x76aa('0x86')](_0x5433dc['query'][_0x76aa('0x73')])){for(var _0x4df504=0x0;_0x4df504<_0x5433dc['query'][_0x76aa('0x73')][_0x76aa('0x37')];_0x4df504+=0x1){socket[_0x76aa('0x70')](_0x76aa('0x87'),{'UserId':Number(_0x5433dc[_0x76aa('0x33')][_0x76aa('0x73')][_0x4df504]),'VoiceQueueId':Number(_0x5433dc[_0x76aa('0x46')]['id'])});}}else{socket[_0x76aa('0x70')](_0x76aa('0x87'),{'UserId':Number(_0x5433dc[_0x76aa('0x33')]['ids']),'VoiceQueueId':Number(_0x5433dc['params']['id'])});}});}})[_0x76aa('0x17')](function(_0x2726da){return db[_0x76aa('0x6c')][_0x76aa('0x25')]({'where':{'VoiceQueueId':_0x5433dc[_0x76aa('0x46')]['id'],'UserId':_0x5433dc[_0x76aa('0x33')]['ids']}})[_0x76aa('0x17')](function(){return _0x2726da;});})[_0x76aa('0x17')](respondWithStatusCode(_0x328d1a,null))[_0x76aa('0x3b')](handleError(_0x328d1a,null));};exports[_0x76aa('0x88')]=function(_0x38694d,_0xf0b932){var _0x1c8cf5={};var _0x5a8d0f={};var _0x5f513d;var _0x54e70c;return db[_0x76aa('0x29')][_0x76aa('0x4b')]({'where':{'id':_0x38694d[_0x76aa('0x46')]['id']}})[_0x76aa('0x17')](handleEntityNotFound(_0xf0b932,null))[_0x76aa('0x17')](function(_0x4afe13){if(_0x4afe13){_0x5f513d=_0x4afe13;_0x5a8d0f['model']=_[_0x76aa('0x32')](db[_0x76aa('0x5e')][_0x76aa('0x2a')]);_0x5a8d0f[_0x76aa('0x33')]=_[_0x76aa('0x32')](_0x38694d['query']);_0x5a8d0f[_0x76aa('0x4c')]=_['intersection'](_0x5a8d0f[_0x76aa('0x31')],_0x5a8d0f['query']);_0x1c8cf5['attributes']=_[_0x76aa('0x35')](_0x5a8d0f['model'],qs[_0x76aa('0x36')](_0x38694d[_0x76aa('0x33')][_0x76aa('0x36')]));_0x1c8cf5[_0x76aa('0x34')]=_0x1c8cf5[_0x76aa('0x34')][_0x76aa('0x37')]?_0x1c8cf5[_0x76aa('0x34')]:_0x5a8d0f[_0x76aa('0x31')];_0x1c8cf5['order']=qs[_0x76aa('0x4f')](_0x38694d[_0x76aa('0x33')][_0x76aa('0x4f')]);_0x1c8cf5[_0x76aa('0x2d')]=qs[_0x76aa('0x4c')](_['pick'](_0x38694d[_0x76aa('0x33')],_0x5a8d0f['filters']));if(_0x38694d[_0x76aa('0x33')]['filter']){_0x1c8cf5[_0x76aa('0x2d')]=_['merge'](_0x1c8cf5[_0x76aa('0x2d')],{'$or':_['map'](_0x1c8cf5[_0x76aa('0x34')],function(_0x8b2ee1){var _0x279be2={};_0x279be2[_0x8b2ee1]={'$like':'%'+_0x38694d['query']['filter']+'%'};return _0x279be2;})});}_0x1c8cf5=_[_0x76aa('0x39')]({},_0x1c8cf5,_0x38694d['options']);return _0x5f513d[_0x76aa('0x88')](_0x1c8cf5);}})[_0x76aa('0x17')](function(_0x1b99d8){if(_0x1b99d8){_0x54e70c=_0x1b99d8['length'];if(!_0x38694d['query']['hasOwnProperty']('nolimit')){_0x1c8cf5[_0x76aa('0x12')]=qs[_0x76aa('0x12')](_0x38694d[_0x76aa('0x33')][_0x76aa('0x12')]);_0x1c8cf5[_0x76aa('0x14')]=qs[_0x76aa('0x14')](_0x38694d[_0x76aa('0x33')][_0x76aa('0x14')]);}return _0x5f513d[_0x76aa('0x88')](_0x1c8cf5);}})[_0x76aa('0x17')](function(_0x2484fd){if(_0x2484fd){return _0x2484fd?{'count':_0x54e70c,'rows':_0x2484fd}:null;}})[_0x76aa('0x17')](respondWithResult(_0xf0b932,null))[_0x76aa('0x3b')](handleError(_0xf0b932,null));};exports['getMembers']=function(_0x2b12e9,_0x4e697b){var _0x1e902d={};var _0x3a7658={};var _0x1b1f85;var _0x3fb275;return db[_0x76aa('0x29')][_0x76aa('0x4b')]({'where':{'id':_0x2b12e9[_0x76aa('0x46')]['id']}})[_0x76aa('0x17')](handleEntityNotFound(_0x4e697b,null))[_0x76aa('0x17')](function(_0x1bdc5c){if(_0x1bdc5c){_0x1b1f85=_0x1bdc5c;_0x3a7658[_0x76aa('0x31')]=_['keys'](db['UserVoiceQueueRt'][_0x76aa('0x2a')]);_0x3a7658[_0x76aa('0x33')]=_['keys'](_0x2b12e9[_0x76aa('0x33')]);_0x3a7658[_0x76aa('0x4c')]=_[_0x76aa('0x35')](_0x3a7658[_0x76aa('0x31')],_0x3a7658[_0x76aa('0x33')]);_0x1e902d[_0x76aa('0x34')]=_[_0x76aa('0x35')](_0x3a7658['model'],qs[_0x76aa('0x36')](_0x2b12e9[_0x76aa('0x33')]['fields']));_0x1e902d['attributes']=_0x1e902d[_0x76aa('0x34')][_0x76aa('0x37')]?_0x1e902d[_0x76aa('0x34')]:_0x3a7658[_0x76aa('0x31')];_0x1e902d[_0x76aa('0x4e')]=qs[_0x76aa('0x4f')](_0x2b12e9[_0x76aa('0x33')][_0x76aa('0x4f')]);_0x1e902d[_0x76aa('0x2d')]=qs[_0x76aa('0x4c')](_[_0x76aa('0x50')](_0x2b12e9[_0x76aa('0x33')],_0x3a7658[_0x76aa('0x4c')]));if(_0x2b12e9['query']['filter']){_0x1e902d[_0x76aa('0x2d')]=_[_0x76aa('0x39')](_0x1e902d[_0x76aa('0x2d')],{'$or':_[_0x76aa('0x1e')](_0x1e902d['attributes'],function(_0x5f3819){var _0x2a8410={};_0x2a8410[_0x5f3819]={'$like':'%'+_0x2b12e9[_0x76aa('0x33')][_0x76aa('0x52')]+'%'};return _0x2a8410;})});}_0x1e902d=_['merge']({},_0x1e902d,_0x2b12e9['options']);return _0x1b1f85['getMembers'](_0x1e902d);}})[_0x76aa('0x17')](function(_0x4df872){if(_0x4df872){_0x3fb275=_0x4df872[_0x76aa('0x37')];if(!_0x2b12e9[_0x76aa('0x33')][_0x76aa('0x58')](_0x76aa('0x4d'))){_0x1e902d[_0x76aa('0x12')]=qs[_0x76aa('0x12')](_0x2b12e9[_0x76aa('0x33')][_0x76aa('0x12')]);_0x1e902d[_0x76aa('0x14')]=qs[_0x76aa('0x14')](_0x2b12e9[_0x76aa('0x33')][_0x76aa('0x14')]);}return _0x1b1f85[_0x76aa('0x89')](_0x1e902d);}})[_0x76aa('0x17')](function(_0x3b1f33){return _0x3b1f33?{'count':_0x3fb275,'rows':_0x3b1f33}:null;})[_0x76aa('0x17')](respondWithResult(_0x4e697b,null))['catch'](handleError(_0x4e697b,null));};exports[_0x76aa('0x8a')]=function(_0x5e8cec,_0x1a37e9){var _0x58932f={};var _0x17bd1a={};var _0x5d7a2b;var _0x363c45;return db['VoiceQueue']['findOne']({'where':{'id':_0x5e8cec[_0x76aa('0x46')]['id']}})[_0x76aa('0x17')](handleEntityNotFound(_0x1a37e9,null))[_0x76aa('0x17')](function(_0x44668d){if(_0x44668d){_0x5d7a2b=_0x44668d;_0x17bd1a[_0x76aa('0x31')]=_[_0x76aa('0x32')](db['CmList'][_0x76aa('0x2a')]);_0x17bd1a[_0x76aa('0x33')]=_[_0x76aa('0x32')](_0x5e8cec[_0x76aa('0x33')]);_0x17bd1a['filters']=_[_0x76aa('0x35')](_0x17bd1a[_0x76aa('0x31')],_0x17bd1a[_0x76aa('0x33')]);_0x58932f[_0x76aa('0x34')]=_[_0x76aa('0x35')](_0x17bd1a[_0x76aa('0x31')],qs[_0x76aa('0x36')](_0x5e8cec[_0x76aa('0x33')][_0x76aa('0x36')]));_0x58932f[_0x76aa('0x34')]=_0x58932f[_0x76aa('0x34')][_0x76aa('0x37')]?_0x58932f['attributes']:_0x17bd1a['model'];_0x58932f[_0x76aa('0x4e')]=qs[_0x76aa('0x4f')](_0x5e8cec[_0x76aa('0x33')][_0x76aa('0x4f')]);_0x58932f[_0x76aa('0x2d')]=qs[_0x76aa('0x4c')](_[_0x76aa('0x50')](_0x5e8cec[_0x76aa('0x33')],_0x17bd1a[_0x76aa('0x4c')]));if(_0x5e8cec[_0x76aa('0x33')][_0x76aa('0x52')]){_0x58932f['where']=_[_0x76aa('0x39')](_0x58932f['where'],{'$or':_[_0x76aa('0x1e')](_0x58932f[_0x76aa('0x34')],function(_0x278bac){var _0x14256c={};_0x14256c[_0x278bac]={'$like':'%'+_0x5e8cec[_0x76aa('0x33')]['filter']+'%'};return _0x14256c;})});}_0x58932f=_['merge']({},_0x58932f,_0x5e8cec[_0x76aa('0x3a')]);return _0x5d7a2b['getLists'](_0x58932f);}})[_0x76aa('0x17')](function(_0xb760ca){if(_0xb760ca){_0x363c45=_0xb760ca[_0x76aa('0x37')];if(!_0x5e8cec[_0x76aa('0x33')][_0x76aa('0x58')]('nolimit')){_0x58932f['limit']=qs[_0x76aa('0x12')](_0x5e8cec[_0x76aa('0x33')][_0x76aa('0x12')]);_0x58932f[_0x76aa('0x14')]=qs[_0x76aa('0x14')](_0x5e8cec[_0x76aa('0x33')][_0x76aa('0x14')]);}return _0x5d7a2b[_0x76aa('0x8a')](_0x58932f);}})[_0x76aa('0x17')](function(_0x33644d){if(_0x33644d){return _0x33644d?{'count':_0x363c45,'rows':_0x33644d}:null;}})['then'](respondWithResult(_0x1a37e9,null))[_0x76aa('0x3b')](handleError(_0x1a37e9,null));};exports[_0x76aa('0x8b')]=function(_0x4830ea,_0x20638f){var _0x2b2f27=moment()[_0x76aa('0x6e')](_0x76aa('0x8c'));var _0x1a5297,_0x487c28;return db[_0x76aa('0x29')]['find']({'where':{'id':_0x4830ea[_0x76aa('0x46')]['id']}})[_0x76aa('0x17')](handleEntityNotFound(_0x20638f,null))[_0x76aa('0x17')](function(_0x2f2a27){if(_0x2f2a27){_0x487c28=_0x2f2a27;return _0x2f2a27['addLists'](_0x4830ea[_0x76aa('0x3d')][_0x76aa('0x73')],_[_0x76aa('0x47')](_0x4830ea[_0x76aa('0x3d')],[_0x76aa('0x73'),'id'])||{});}return null;})[_0x76aa('0x84')](function(_0xca12fa){var _0xb0a4e1;_0x1a5297=_0xca12fa||[];var _0x1f7f1d=[];if(_0xca12fa){for(var _0x413528=0x0;_0x413528<_0xca12fa[_0x76aa('0x37')];_0x413528+=0x1){var _0x39de41=_0xca12fa[_0x413528][_0x76aa('0x18')]({'plain':!![]});_0x487c28[_0x76aa('0x8d')]=_0x4830ea['body']['dialCheckDuplicateType']?_0x4830ea[_0x76aa('0x3d')][_0x76aa('0x8d')]:_0x487c28['dialCheckDuplicateType'];switch(_0x487c28[_0x76aa('0x8d')]){case'always':_0xb0a4e1=squel[_0x76aa('0x8e')]()[_0x76aa('0x8f')](_0x76aa('0x90'))[_0x76aa('0x91')]([_0x76aa('0x92'),_0x76aa('0x93'),_0x76aa('0x94'),_0x76aa('0x95'),'VoiceQueueId',_0x76aa('0x49'),_0x76aa('0x48')],squel['select']()['field'](_0x76aa('0x92'),_0x76aa('0x92'))[_0x76aa('0x74')]('\x27'+_0x2b2f27+'\x27',_0x76aa('0x93'))[_0x76aa('0x74')]('id','ContactId')[_0x76aa('0x74')](_0x39de41['CmListId'][_0x76aa('0x96')](),_0x76aa('0x95'))[_0x76aa('0x74')](_0x4830ea[_0x76aa('0x46')]['id'][_0x76aa('0x96')](),_0x76aa('0x51'))[_0x76aa('0x74')]('\x27'+_0x2b2f27+'\x27',_0x76aa('0x49'))[_0x76aa('0x74')]('\x27'+_0x2b2f27+'\x27',_0x76aa('0x48'))[_0x76aa('0x76')](_0x76aa('0x97'))[_0x76aa('0x2d')]('deletedAt\x20IS\x20NULL')[_0x76aa('0x2d')]('ListId\x20=\x20?',_0x39de41['CmListId']['toString']())[_0x76aa('0x2d')]('phone\x20IS\x20NOT\x20NULL')['where']('phone\x20NOT\x20IN\x20(?)',squel['select']()[_0x76aa('0x74')](_0x76aa('0x98'))['from'](_0x76aa('0x99'))[_0x76aa('0x2d')](_0x76aa('0x7a'),_0x4830ea['params']['id']['toString']()))['where'](_0x76aa('0x9a'),squel['select']()[_0x76aa('0x74')](_0x76aa('0x9b'))['from'](_0x76aa('0x90'))[_0x76aa('0x2d')]('VoiceQueueId\x20=\x20?',_0x4830ea[_0x76aa('0x46')]['id'][_0x76aa('0x96')]())))[_0x76aa('0x96')]();break;case _0x76aa('0x9c'):_0xb0a4e1=squel[_0x76aa('0x8e')]()[_0x76aa('0x8f')](_0x76aa('0x90'))[_0x76aa('0x91')](['phone',_0x76aa('0x93'),_0x76aa('0x94'),_0x76aa('0x95'),_0x76aa('0x51'),_0x76aa('0x49'),_0x76aa('0x48')],squel[_0x76aa('0x9d')]()[_0x76aa('0x74')](_0x76aa('0x92'),_0x76aa('0x92'))['field']('\x27'+_0x2b2f27+'\x27',_0x76aa('0x93'))[_0x76aa('0x74')]('id',_0x76aa('0x94'))['field'](_0x39de41['CmListId']['toString'](),_0x76aa('0x95'))[_0x76aa('0x74')](_0x4830ea['params']['id'][_0x76aa('0x96')](),'VoiceQueueId')['field']('\x27'+_0x2b2f27+'\x27',_0x76aa('0x49'))[_0x76aa('0x74')]('\x27'+_0x2b2f27+'\x27','updatedAt')[_0x76aa('0x76')](_0x76aa('0x97'))[_0x76aa('0x2d')]('deletedAt\x20IS\x20NULL')[_0x76aa('0x2d')](_0x76aa('0x9e'),_0x39de41[_0x76aa('0x9f')][_0x76aa('0x96')]())[_0x76aa('0x2d')](_0x76aa('0xa0'))[_0x76aa('0x2d')](_0x76aa('0x9a'),squel[_0x76aa('0x9d')]()[_0x76aa('0x74')](_0x76aa('0x9b'))['from'](_0x76aa('0x90'))[_0x76aa('0x2d')](_0x76aa('0x7a'),_0x4830ea['params']['id']['toString']())))[_0x76aa('0x96')]();break;default:_0xb0a4e1=squel[_0x76aa('0x8e')]()[_0x76aa('0x8f')]('cm_hopper')[_0x76aa('0x91')]([_0x76aa('0x92'),_0x76aa('0x93'),_0x76aa('0x94'),_0x76aa('0x95'),_0x76aa('0x51'),_0x76aa('0x49'),_0x76aa('0x48')],squel[_0x76aa('0x9d')]()[_0x76aa('0x74')](_0x76aa('0x92'),_0x76aa('0x92'))[_0x76aa('0x74')]('\x27'+_0x2b2f27+'\x27',_0x76aa('0x93'))['field']('id',_0x76aa('0x94'))['field'](_0x39de41[_0x76aa('0x9f')]['toString'](),_0x76aa('0x95'))[_0x76aa('0x74')](_0x4830ea[_0x76aa('0x46')]['id']['toString'](),_0x76aa('0x51'))[_0x76aa('0x74')]('\x27'+_0x2b2f27+'\x27',_0x76aa('0x49'))[_0x76aa('0x74')]('\x27'+_0x2b2f27+'\x27',_0x76aa('0x48'))[_0x76aa('0x76')]('cm_contacts')['where'](_0x76aa('0xa1'))[_0x76aa('0x2d')](_0x76aa('0x9e'),_0x39de41['CmListId']['toString']())[_0x76aa('0x2d')](_0x76aa('0xa0')))[_0x76aa('0x96')]();}_0x1f7f1d['push'](db['sequelize'][_0x76aa('0x33')](_0xb0a4e1));}return BPromise[_0x76aa('0x85')](_0x1f7f1d);}})[_0x76aa('0x17')](function(){var _0xbb19e4=[];var _0x226b44=squel[_0x76aa('0x8e')]()[_0x76aa('0x8f')](_0x76aa('0xa2'))['fromQuery']([_0x76aa('0xa3'),_0x76aa('0x92'),_0x76aa('0xa4'),'createdAt',_0x76aa('0x48')],squel[_0x76aa('0x9d')]()[_0x76aa('0x74')]('h.id')['field'](_0x76aa('0xa5'))['field'](_0x76aa('0xa6'))[_0x76aa('0x74')]('\x27'+_0x2b2f27+'\x27',_0x76aa('0x49'))[_0x76aa('0x74')]('\x27'+_0x2b2f27+'\x27','updatedAt')['from'](_0x76aa('0xa7'),'ci')[_0x76aa('0x78')](_0x76aa('0x90'),'h',_0x76aa('0xa8'))[_0x76aa('0x2d')](_0x76aa('0xa9'),_0x2b2f27)['where'](_0x76aa('0xaa'),_0x76aa('0xab')))[_0x76aa('0x96')]();_0xbb19e4['push'](db[_0x76aa('0x66')][_0x76aa('0x33')](_0x226b44));return BPromise[_0x76aa('0x85')](_0xbb19e4);})['then'](function(){return _0x1a5297;})[_0x76aa('0x17')](respondWithResult(_0x20638f,null))['catch'](handleError(_0x20638f,null));};exports['removeLists']=function(_0xef9ea7,_0x45f21f){return db[_0x76aa('0x29')]['find']({'where':{'id':_0xef9ea7[_0x76aa('0x46')]['id']}})['then'](handleEntityNotFound(_0x45f21f,null))[_0x76aa('0x17')](function(_0x113e70){if(_0x113e70){return _0x113e70['removeLists'](_0xef9ea7[_0x76aa('0x33')]['ids']);}})['then'](function(_0x583d68){if(_0x583d68){return db[_0x76aa('0x53')]['destroy']({'where':{'ListId':_0xef9ea7[_0x76aa('0x33')]['ids'],'VoiceQueueId':_0xef9ea7['params']['id']}})[_0x76aa('0x17')](function(){return _0x583d68;});}})['then'](respondWithStatusCode(_0x45f21f,null))['catch'](handleError(_0x45f21f,null));};exports[_0x76aa('0xac')]=function(_0x3b7370,_0x1c3431){var _0x865a1b={};var _0x132d60={};var _0x1a3074;var _0x3184a2;return db['VoiceQueue']['findOne']({'where':{'id':_0x3b7370[_0x76aa('0x46')]['id']}})[_0x76aa('0x17')](handleEntityNotFound(_0x1c3431,null))[_0x76aa('0x17')](function(_0x274356){if(_0x274356){_0x1a3074=_0x274356;_0x132d60[_0x76aa('0x31')]=_[_0x76aa('0x32')](db[_0x76aa('0xad')][_0x76aa('0x2a')]);_0x132d60[_0x76aa('0x33')]=_['keys'](_0x3b7370['query']);_0x132d60[_0x76aa('0x4c')]=_[_0x76aa('0x35')](_0x132d60[_0x76aa('0x31')],_0x132d60[_0x76aa('0x33')]);_0x865a1b['attributes']=_['intersection'](_0x132d60[_0x76aa('0x31')],qs['fields'](_0x3b7370[_0x76aa('0x33')][_0x76aa('0x36')]));_0x865a1b['attributes']=_0x865a1b[_0x76aa('0x34')][_0x76aa('0x37')]?_0x865a1b[_0x76aa('0x34')]:_0x132d60[_0x76aa('0x31')];_0x865a1b[_0x76aa('0x4e')]=qs['sort'](_0x3b7370[_0x76aa('0x33')][_0x76aa('0x4f')]);_0x865a1b['where']=qs['filters'](_[_0x76aa('0x50')](_0x3b7370[_0x76aa('0x33')],_0x132d60[_0x76aa('0x4c')]));if(_0x3b7370[_0x76aa('0x33')][_0x76aa('0x52')]){_0x865a1b[_0x76aa('0x2d')]=_[_0x76aa('0x39')](_0x865a1b[_0x76aa('0x2d')],{'$or':_[_0x76aa('0x1e')](_0x865a1b[_0x76aa('0x34')],function(_0xbb0ea3){var _0x4978dd={};_0x4978dd[_0xbb0ea3]={'$like':'%'+_0x3b7370[_0x76aa('0x33')][_0x76aa('0x52')]+'%'};return _0x4978dd;})});}_0x865a1b=_[_0x76aa('0x39')]({},_0x865a1b,_0x3b7370[_0x76aa('0x3a')]);return _0x1a3074['getBlackLists'](_0x865a1b);}})['then'](function(_0x4ee1d3){if(_0x4ee1d3){_0x3184a2=_0x4ee1d3['length'];if(!_0x3b7370[_0x76aa('0x33')][_0x76aa('0x58')](_0x76aa('0x4d'))){_0x865a1b[_0x76aa('0x12')]=qs[_0x76aa('0x12')](_0x3b7370[_0x76aa('0x33')][_0x76aa('0x12')]);_0x865a1b['offset']=qs['offset'](_0x3b7370[_0x76aa('0x33')]['offset']);}return _0x1a3074[_0x76aa('0xac')](_0x865a1b);}})[_0x76aa('0x17')](function(_0x3bc149){if(_0x3bc149){return _0x3bc149?{'count':_0x3184a2,'rows':_0x3bc149}:null;}})['then'](respondWithResult(_0x1c3431,null))[_0x76aa('0x3b')](handleError(_0x1c3431,null));};exports[_0x76aa('0xae')]=function(_0x29e112,_0x3fd683){var _0x5c2c4d;return db[_0x76aa('0x29')][_0x76aa('0x22')]({'where':{'id':_0x29e112[_0x76aa('0x46')]['id']}})['then'](handleEntityNotFound(_0x3fd683,null))[_0x76aa('0x17')](function(_0xcb041d){if(_0xcb041d){return _0xcb041d[_0x76aa('0xae')](_0x29e112[_0x76aa('0x3d')][_0x76aa('0x73')],_[_0x76aa('0x47')](_0x29e112[_0x76aa('0x3d')],['ids','id'])||{});}return null;})['spread'](function(_0x72b9a){var _0x29db0f;_0x5c2c4d=_0x72b9a||[];var _0x28a212=[];if(_0x72b9a){for(var _0x242cd6=0x0;_0x242cd6<_0x72b9a[_0x76aa('0x37')];_0x242cd6+=0x1){var _0xeb428a=_0x72b9a[_0x242cd6][_0x76aa('0x18')]({'plain':!![]});_0x29db0f=squel[_0x76aa('0x8e')]()[_0x76aa('0x8f')](_0x76aa('0xaf'))[_0x76aa('0x91')]([_0x76aa('0x92'),_0x76aa('0x94'),_0x76aa('0x95'),_0x76aa('0x51'),_0x76aa('0x49'),_0x76aa('0x48')],squel[_0x76aa('0x9d')]()[_0x76aa('0x74')](_0x76aa('0x92'),_0x76aa('0x92'))[_0x76aa('0x74')]('id',_0x76aa('0x94'))[_0x76aa('0x74')](_0xeb428a[_0x76aa('0x9f')][_0x76aa('0x96')](),_0x76aa('0x95'))[_0x76aa('0x74')](_0x29e112['params']['id'][_0x76aa('0x96')](),_0x76aa('0x51'))[_0x76aa('0x74')](_0x76aa('0xb0'),'createdAt')[_0x76aa('0x74')](_0x76aa('0xb0'),_0x76aa('0x48'))['from'](_0x76aa('0x97'))[_0x76aa('0x2d')]('deletedAt\x20IS\x20NULL')[_0x76aa('0x2d')]('ListId\x20=\x20?',_0xeb428a[_0x76aa('0x9f')][_0x76aa('0x96')]())[_0x76aa('0x2d')](_0x76aa('0xa0')))['toString']();_0x28a212[_0x76aa('0x7c')](db['sequelize'][_0x76aa('0x33')](_0x29db0f));}return BPromise['all'](_0x28a212);}})[_0x76aa('0x17')](function(){return _0x5c2c4d;})['then'](respondWithResult(_0x3fd683,null))[_0x76aa('0x3b')](handleError(_0x3fd683,null));};exports[_0x76aa('0xb1')]=function(_0x140ee1,_0x3d9e9e){return db[_0x76aa('0x29')][_0x76aa('0x22')]({'where':{'id':_0x140ee1['params']['id']}})[_0x76aa('0x17')](handleEntityNotFound(_0x3d9e9e,null))[_0x76aa('0x17')](function(_0x139e67){if(_0x139e67){return _0x139e67[_0x76aa('0xb1')](_0x140ee1['query'][_0x76aa('0x73')]);}})[_0x76aa('0x17')](function(_0x506cad){if(_0x506cad){return db['CmHopperBlack'][_0x76aa('0x25')]({'where':{'ListId':_0x140ee1[_0x76aa('0x33')][_0x76aa('0x73')],'VoiceQueueId':_0x140ee1[_0x76aa('0x46')]['id']}})['then'](function(){return _0x506cad;});}})['then'](respondWithStatusCode(_0x3d9e9e,null))[_0x76aa('0x3b')](handleError(_0x3d9e9e,null));};
\ No newline at end of file