Built motion from commit e02f907f.|2.6.14
[motion2.git] / server / api / voiceQueue / voiceQueue.controller.js
1 // *************************************************************************
2 // *                                                                       *
3 // * xCALLY Motion -  The Omnichannel Contact Center                       *
4 // * Copyright (c) Xenialab s.r.l. All Rights Reserved                     *
5 // *                                                                       *
6 // *************************************************************************
7 // *                                                                       *
8 // * Email: info@xcally.com                                                *
9 // * Website: https://www.xcally.com                                       *
10 // *                                                                       *
11 // *************************************************************************
12 // *                                                                       *
13 // * The SOFTWARE PRODUCT is protected by copyright laws and international *
14 // * copyright treaties, as well as other intellectual property laws and   *
15 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                         *
16 // *                                                                       *
17 // *************************************************************************
18 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));};