bee35ea628aa4316a4e5e3dcd1845cac5266d3ce
[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 _0xf786=['length','hasOwnProperty','nolimit','order','sort','merge','where','VIRTUAL','options','findAll','rows','catch','show','params','includeAll','create','user','get','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','QueueCampaigns','outbound','UserProfileSection','autoAssociation','error','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','clone','omit','updatedAt','body','createdAt','inbound','value','userProfileId','update','getHoppers','findOne','CmHopper','pick','VoiceQueueId','include','getHopperHistories','CmHopperHistory','getHopperFinals','CmHopperFinal','getHopperBlacks','CmHopperBlack','getTeams','Team','addTeams','User','voicePause','interface','flatMap','penalty','sequelize','transaction','TeamVoiceQueue','each','UserVoiceQueue','isNil','format','SIP/%s','forEach','userVoiceQueue:save','removeTeams','ids','select','tq.TeamId','team_has_voice_queues','user_has_teams','ut.TeamId\x20=\x20tq.TeamId','VoiceQueueId\x20=\x20?','Agents','ut.UserId\x20=\x20?','push','toString','QueryTypes','every','TeamId','includes','union','compact','isEmpty','removeAgents','UserVoiceQueueRt','emit','userVoiceQueue:remove','addAgents','spread','online','upsert','all','isArray','getAgents','getMembers','getLists','CmList','addLists','dialCheckDuplicateType','always','insert','cm_hopper','phone','scheduledAt','ContactId','ListId','field','NOW()','CmListId','from','cm_contacts','deletedAt\x20IS\x20NULL','ListId\x20=\x20?','phone\x20IS\x20NOT\x20NULL','phone\x20NOT\x20IN\x20(?)','COALESCE(calleridnum,\x27\x27)','cm_hopper_final','COALESCE(phone,\x27\x27)','onlyIfOpen','into','fromQuery','removeLists','getBlackLists','addBlackLists','cm_hopper_black','removeBlackLists','html-pdf','rimraf','fast-json-patch','request-promise','moment','bluebird','mustache','util','sox','lodash','squel','crypto','jsforce','desk.js','to-csv','papaparse','../../components/parsers/qs','../../config/license/hardware','../../config/utils','../../config/license/util','../../mysqldb','redis','./voiceQueue.socket','register','sendStatus','status','end','count','offset','limit','Content-Range','json','apply','then','destroy','VoiceQueues','filter','ignore','map','type','find','name','UserProfileResource','stack','send','VoiceQueue','rawAttributes','fieldName','key','model','query','keys','filters','attributes','intersection','fields'];(function(_0x5d71fb,_0x5b3f42){var _0x19bac8=function(_0x436c7d){while(--_0x436c7d){_0x5d71fb['push'](_0x5d71fb['shift']());}};_0x19bac8(++_0x5b3f42);}(_0xf786,0x136));var _0x6f78=function(_0x54facc,_0x3eac15){_0x54facc=_0x54facc-0x0;var _0x5b39ef=_0xf786[_0x54facc];return _0x5b39ef;};'use strict';var pdf=require(_0x6f78('0x0'));var emlformat=require('eml-format');var rimraf=require(_0x6f78('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0x6f78('0x2'));var rp=require(_0x6f78('0x3'));var moment=require(_0x6f78('0x4'));var BPromise=require(_0x6f78('0x5'));var Mustache=require(_0x6f78('0x6'));var util=require(_0x6f78('0x7'));var path=require('path');var sox=require(_0x6f78('0x8'));var csv=require('to-csv');var ejs=require('ejs');var fs=require('fs');var _=require(_0x6f78('0x9'));var squel=require(_0x6f78('0xa'));var crypto=require(_0x6f78('0xb'));var jsforce=require(_0x6f78('0xc'));var deskjs=require(_0x6f78('0xd'));var toCsv=require(_0x6f78('0xe'));var querystring=require('querystring');var Papa=require(_0x6f78('0xf'));var Redis=require('ioredis');var authService=require('../../components/auth/service');var qs=require(_0x6f78('0x10'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x6f78('0x11'));var logger=require('../../config/logger')('api');var utils=require(_0x6f78('0x12'));var config=require('../../config/environment');var licenseUtil=require(_0x6f78('0x13'));var db=require(_0x6f78('0x14'))['db'];config[_0x6f78('0x15')]=_['defaults'](config['redis'],{'host':'localhost','port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x6f78('0x15')]));require(_0x6f78('0x16'))[_0x6f78('0x17')](socket);function respondWithStatusCode(_0x2894bc,_0x5b2c76){_0x5b2c76=_0x5b2c76||0xcc;return function(_0x4fed1c){if(_0x4fed1c){return _0x2894bc[_0x6f78('0x18')](_0x5b2c76);}return _0x2894bc[_0x6f78('0x19')](_0x5b2c76)[_0x6f78('0x1a')]();};}function respondWithResult(_0x299f21,_0x560002){_0x560002=_0x560002||0xc8;return function(_0x4e7b4d){if(_0x4e7b4d){return _0x299f21['status'](_0x560002)['json'](_0x4e7b4d);}};}function respondWithFilteredResult(_0x1a7e9c,_0x576200){return function(_0x3908ea){if(_0x3908ea){var _0x1644ee=_0x3908ea[_0x6f78('0x1b')],_0x48e36b=_0x576200[_0x6f78('0x1c')],_0x80bfda=_0x576200[_0x6f78('0x1c')]+_0x576200[_0x6f78('0x1d')],_0x30b434;if(_0x80bfda>=_0x1644ee){_0x80bfda=_0x1644ee;_0x30b434=0xc8;}else{_0x30b434=0xce;}_0x1a7e9c[_0x6f78('0x19')](_0x30b434);return _0x1a7e9c['set'](_0x6f78('0x1e'),_0x48e36b+'-'+_0x80bfda+'/'+_0x1644ee)[_0x6f78('0x1f')](_0x3908ea);}return null;};}function patchUpdates(_0x51891f){return function(_0x148737){try{jsonpatch[_0x6f78('0x20')](_0x148737,_0x51891f,!![]);}catch(_0x49fa31){return BPromise['reject'](_0x49fa31);}return _0x148737['save']();};}function saveUpdates(_0x3b38e4,_0x712f54){return function(_0x308844){if(_0x308844){return _0x308844['update'](_0x3b38e4)[_0x6f78('0x21')](function(_0x2b4d64){return _0x2b4d64;});}return null;};}function removeEntity(_0x155d07,_0x4969c0){return function(_0x883e5b){if(_0x883e5b){return _0x883e5b[_0x6f78('0x22')]()['then'](function(){var _0x438f4a=_0x883e5b['get']({'plain':!![]});var _0x282081=[{'name':_0x6f78('0x23'),'value':'inbound','ignore':![]},{'name':'QueueCampaigns','value':'outbound','ignore':![]}];var _0x370fa1=_(_0x282081)[_0x6f78('0x24')](_0x6f78('0x25'))[_0x6f78('0x26')]('value')['value']();if(_['includes'](_0x370fa1,_0x438f4a[_0x6f78('0x27')])){return;}var _0x2cd061=_[_0x6f78('0x28')](_0x282081,['value',_0x438f4a[_0x6f78('0x27')]])[_0x6f78('0x29')];return db[_0x6f78('0x2a')]['destroy']({'where':{'type':_0x2cd061,'resourceId':_0x438f4a['id']}})[_0x6f78('0x21')](function(){return _0x883e5b;});})['then'](function(){_0x155d07[_0x6f78('0x19')](0xcc)['end']();});}};}function handleEntityNotFound(_0x253c69,_0x5506ec){return function(_0x460b46){if(!_0x460b46){_0x253c69[_0x6f78('0x18')](0x194);}return _0x460b46;};}function handleError(_0x26dcd8,_0x2dab2a){_0x2dab2a=_0x2dab2a||0x1f4;return function(_0x1494a5){logger['error'](_0x1494a5[_0x6f78('0x2b')]);if(_0x1494a5[_0x6f78('0x29')]){delete _0x1494a5['name'];}_0x26dcd8[_0x6f78('0x19')](_0x2dab2a)[_0x6f78('0x2c')](_0x1494a5);};}exports['index']=function(_0x25f07a,_0x246092){var _0x4daf21={},_0x515281={},_0x570f39={'count':0x0,'rows':[]};var _0xf32bfa=_[_0x6f78('0x26')](db[_0x6f78('0x2d')][_0x6f78('0x2e')],function(_0x4b8bc2){return{'name':_0x4b8bc2[_0x6f78('0x2f')],'type':_0x4b8bc2[_0x6f78('0x27')][_0x6f78('0x30')]};});_0x515281[_0x6f78('0x31')]=_[_0x6f78('0x26')](_0xf32bfa,'name');_0x515281[_0x6f78('0x32')]=_[_0x6f78('0x33')](_0x25f07a['query']);_0x515281[_0x6f78('0x34')]=_['intersection'](_0x515281['model'],_0x515281[_0x6f78('0x32')]);_0x4daf21[_0x6f78('0x35')]=_[_0x6f78('0x36')](_0x515281[_0x6f78('0x31')],qs[_0x6f78('0x37')](_0x25f07a[_0x6f78('0x32')][_0x6f78('0x37')]));_0x4daf21[_0x6f78('0x35')]=_0x4daf21['attributes'][_0x6f78('0x38')]?_0x4daf21['attributes']:_0x515281[_0x6f78('0x31')];if(!_0x25f07a[_0x6f78('0x32')][_0x6f78('0x39')](_0x6f78('0x3a'))){_0x4daf21[_0x6f78('0x1d')]=qs[_0x6f78('0x1d')](_0x25f07a['query']['limit']);_0x4daf21[_0x6f78('0x1c')]=qs['offset'](_0x25f07a[_0x6f78('0x32')][_0x6f78('0x1c')]);}_0x4daf21[_0x6f78('0x3b')]=qs[_0x6f78('0x3c')](_0x25f07a[_0x6f78('0x32')][_0x6f78('0x3c')]);_0x4daf21['where']=qs[_0x6f78('0x34')](_['pick'](_0x25f07a[_0x6f78('0x32')],_0x515281[_0x6f78('0x34')]),_0xf32bfa);if(_0x25f07a[_0x6f78('0x32')][_0x6f78('0x24')]){_0x4daf21['where']=_[_0x6f78('0x3d')](_0x4daf21[_0x6f78('0x3e')],{'$or':_[_0x6f78('0x26')](_0xf32bfa,function(_0x279c8d){if(_0x279c8d['type']!==_0x6f78('0x3f')){var _0x10ee35={};_0x10ee35[_0x279c8d[_0x6f78('0x29')]]={'$like':'%'+_0x25f07a[_0x6f78('0x32')][_0x6f78('0x24')]+'%'};return _0x10ee35;}})});}_0x4daf21=_[_0x6f78('0x3d')]({},_0x4daf21,_0x25f07a[_0x6f78('0x40')]);var _0x5c49cb={'where':_0x4daf21[_0x6f78('0x3e')]};return db['VoiceQueue'][_0x6f78('0x1b')](_0x5c49cb)[_0x6f78('0x21')](function(_0x206a37){_0x570f39[_0x6f78('0x1b')]=_0x206a37;if(_0x25f07a[_0x6f78('0x32')]['includeAll']){_0x4daf21['include']=[{'all':!![]}];}return db['VoiceQueue'][_0x6f78('0x41')](_0x4daf21);})[_0x6f78('0x21')](function(_0x2d3f91){_0x570f39[_0x6f78('0x42')]=_0x2d3f91;return _0x570f39;})[_0x6f78('0x21')](respondWithFilteredResult(_0x246092,_0x4daf21))[_0x6f78('0x43')](handleError(_0x246092,null));};exports[_0x6f78('0x44')]=function(_0x2da6ec,_0x4bc367){var _0x24a6f1={'raw':![],'where':{'id':_0x2da6ec[_0x6f78('0x45')]['id']}},_0x49512e={};_0x49512e['model']=_[_0x6f78('0x33')](db[_0x6f78('0x2d')]['rawAttributes']);_0x49512e[_0x6f78('0x32')]=_[_0x6f78('0x33')](_0x2da6ec[_0x6f78('0x32')]);_0x49512e[_0x6f78('0x34')]=_[_0x6f78('0x36')](_0x49512e[_0x6f78('0x31')],_0x49512e[_0x6f78('0x32')]);_0x24a6f1[_0x6f78('0x35')]=_['intersection'](_0x49512e[_0x6f78('0x31')],qs['fields'](_0x2da6ec['query'][_0x6f78('0x37')]));_0x24a6f1['attributes']=_0x24a6f1[_0x6f78('0x35')][_0x6f78('0x38')]?_0x24a6f1[_0x6f78('0x35')]:_0x49512e['model'];if(_0x2da6ec['query'][_0x6f78('0x46')]){_0x24a6f1['include']=[{'all':!![]}];}_0x24a6f1=_[_0x6f78('0x3d')]({},_0x24a6f1,_0x2da6ec['options']);return db['VoiceQueue'][_0x6f78('0x28')](_0x24a6f1)[_0x6f78('0x21')](handleEntityNotFound(_0x4bc367,null))[_0x6f78('0x21')](respondWithResult(_0x4bc367,null))[_0x6f78('0x43')](handleError(_0x4bc367,null));};exports[_0x6f78('0x47')]=function(_0x42445b,_0x118def){return db[_0x6f78('0x2d')]['create'](_0x42445b['body'],{})['then'](function(_0x5ca17d){var _0x1e5f50=_0x42445b[_0x6f78('0x48')][_0x6f78('0x49')]({'plain':!![]});if(!_0x1e5f50)throw new Error(_0x6f78('0x4a'));if(_0x1e5f50[_0x6f78('0x4b')]===_0x6f78('0x48')){var _0xdfe3c9=_0x5ca17d[_0x6f78('0x49')]({'plain':!![]});var _0x5931a8=[{'name':_0x6f78('0x23'),'value':'inbound'},{'name':_0x6f78('0x4c'),'value':_0x6f78('0x4d')}];var _0x455632=_['find'](_0x5931a8,['value',_0xdfe3c9[_0x6f78('0x27')]])[_0x6f78('0x29')];return db[_0x6f78('0x4e')]['find']({'where':{'name':_0x455632,'userProfileId':_0x1e5f50['userProfileId']},'raw':!![]})['then'](function(_0x2239a8){if(_0x2239a8&&_0x2239a8[_0x6f78('0x4f')]===0x0){return db[_0x6f78('0x2a')][_0x6f78('0x47')]({'name':_0xdfe3c9[_0x6f78('0x29')],'resourceId':_0xdfe3c9['id'],'type':_0x2239a8[_0x6f78('0x29')],'sectionId':_0x2239a8['id']},{})[_0x6f78('0x21')](function(){return _0x5ca17d;});}else{return _0x5ca17d;}})['catch'](function(_0x438075){logger[_0x6f78('0x50')](_0x6f78('0x51'),_0x438075);throw _0x438075;});}return _0x5ca17d;})[_0x6f78('0x21')](respondWithResult(_0x118def,0xc9))[_0x6f78('0x43')](handleError(_0x118def,null));};exports[_0x6f78('0x52')]=function(_0x30e09f,_0x5417c5){var _0x37b0ae={'where':{'id':_0x30e09f[_0x6f78('0x45')]['id']}},_0x47fe3d={};_0x47fe3d['model']=_[_0x6f78('0x33')](db[_0x6f78('0x2d')][_0x6f78('0x2e')]);_0x37b0ae[_0x6f78('0x35')]=_['intersection'](_0x47fe3d['model'],qs[_0x6f78('0x37')](_0x30e09f['query'][_0x6f78('0x37')]));_0x37b0ae['attributes']=_0x37b0ae[_0x6f78('0x35')][_0x6f78('0x38')]?_0x37b0ae[_0x6f78('0x35')]:_0x47fe3d[_0x6f78('0x31')];if(_0x30e09f[_0x6f78('0x32')]['includeAll']){_0x37b0ae['include']=[{'all':!![]}];}_0x37b0ae=_[_0x6f78('0x3d')]({},_0x37b0ae,_0x30e09f[_0x6f78('0x40')]);return db[_0x6f78('0x2d')][_0x6f78('0x28')](_0x37b0ae)[_0x6f78('0x21')](handleEntityNotFound(_0x5417c5,null))[_0x6f78('0x21')](function(_0x10f36f){if(_0x10f36f){var _0x5c4dea=_0x10f36f[_0x6f78('0x49')]({'plain':!![]});_0x5c4dea=qs[_0x6f78('0x53')](_0x5c4dea,['id','createdAt',_0x6f78('0x54')]);_0x30e09f[_0x6f78('0x55')]=_[_0x6f78('0x53')](_0x30e09f[_0x6f78('0x55')],['id',_0x6f78('0x56'),'updatedAt']);return db[_0x6f78('0x2d')]['create'](_['merge'](_0x5c4dea,_0x30e09f[_0x6f78('0x55')]),{'include':_0x30e09f['query'][_0x6f78('0x46')]?[{'all':!![]}]:undefined})['then'](function(_0x31be8c){var _0x4a66ab=_0x30e09f[_0x6f78('0x48')][_0x6f78('0x49')]({'plain':!![]});if(!_0x4a66ab)throw new Error(_0x6f78('0x4a'));if(_0x4a66ab[_0x6f78('0x4b')]===_0x6f78('0x48')){var _0x3fadcc=_0x31be8c['get']({'plain':!![]});var _0x19cddb=[{'name':_0x6f78('0x23'),'value':_0x6f78('0x57')},{'name':'QueueCampaigns','value':_0x6f78('0x4d')}];var _0x31a6b1=_[_0x6f78('0x28')](_0x19cddb,[_0x6f78('0x58'),_0x3fadcc[_0x6f78('0x27')]])[_0x6f78('0x29')];return db[_0x6f78('0x4e')][_0x6f78('0x28')]({'where':{'name':_0x31a6b1,'userProfileId':_0x4a66ab[_0x6f78('0x59')]},'raw':!![]})[_0x6f78('0x21')](function(_0x2b9f67){if(_0x2b9f67&&_0x2b9f67['autoAssociation']===0x0){return db['UserProfileResource'][_0x6f78('0x47')]({'name':_0x3fadcc[_0x6f78('0x29')],'resourceId':_0x3fadcc['id'],'type':_0x2b9f67[_0x6f78('0x29')],'sectionId':_0x2b9f67['id']},{})[_0x6f78('0x21')](function(){return _0x31be8c;});}else{return _0x31be8c;}})[_0x6f78('0x43')](function(_0x1c6d6a){logger[_0x6f78('0x50')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x1c6d6a);throw _0x1c6d6a;});}return _0x31be8c;});}})[_0x6f78('0x21')](respondWithResult(_0x5417c5,0xc9))['catch'](handleError(_0x5417c5,null));};exports[_0x6f78('0x5a')]=function(_0x2e5ae5,_0x394961){if(_0x2e5ae5[_0x6f78('0x55')]['id']){delete _0x2e5ae5['body']['id'];}return db['VoiceQueue'][_0x6f78('0x28')]({'where':{'id':_0x2e5ae5[_0x6f78('0x45')]['id']}})[_0x6f78('0x21')](handleEntityNotFound(_0x394961,null))[_0x6f78('0x21')](saveUpdates(_0x2e5ae5['body'],null))[_0x6f78('0x21')](respondWithResult(_0x394961,null))[_0x6f78('0x43')](handleError(_0x394961,null));};exports[_0x6f78('0x22')]=function(_0x4f6dbb,_0x46f76f){return db['VoiceQueue'][_0x6f78('0x28')]({'where':{'id':_0x4f6dbb[_0x6f78('0x45')]['id']}})[_0x6f78('0x21')](handleEntityNotFound(_0x46f76f,null))[_0x6f78('0x21')](removeEntity(_0x46f76f,null))[_0x6f78('0x43')](handleError(_0x46f76f,null));};exports[_0x6f78('0x5b')]=function(_0x4a50da,_0x5c2d50,_0x3ad56f){var _0x25636a={'raw':![],'where':{}};var _0x52e939={};var _0x1d28db={'count':0x0,'rows':[]};return db[_0x6f78('0x2d')][_0x6f78('0x5c')]({'where':{'id':_0x4a50da[_0x6f78('0x45')]['id']}})[_0x6f78('0x21')](handleEntityNotFound(_0x5c2d50,null))['then'](function(_0x247b95){if(_0x247b95){_0x52e939['model']=_[_0x6f78('0x33')](db[_0x6f78('0x5d')]['rawAttributes']);_0x52e939['query']=_[_0x6f78('0x33')](_0x4a50da[_0x6f78('0x32')]);_0x52e939[_0x6f78('0x34')]=_['intersection'](_0x52e939[_0x6f78('0x31')],_0x52e939[_0x6f78('0x32')]);_0x25636a[_0x6f78('0x35')]=_[_0x6f78('0x36')](_0x52e939[_0x6f78('0x31')],qs[_0x6f78('0x37')](_0x4a50da[_0x6f78('0x32')]['fields']));_0x25636a['attributes']=_0x25636a[_0x6f78('0x35')][_0x6f78('0x38')]?_0x25636a[_0x6f78('0x35')]:_0x52e939[_0x6f78('0x31')];if(!_0x4a50da[_0x6f78('0x32')][_0x6f78('0x39')](_0x6f78('0x3a'))){_0x25636a[_0x6f78('0x1d')]=qs['limit'](_0x4a50da[_0x6f78('0x32')][_0x6f78('0x1d')]);_0x25636a[_0x6f78('0x1c')]=qs[_0x6f78('0x1c')](_0x4a50da[_0x6f78('0x32')]['offset']);}_0x25636a['order']=qs[_0x6f78('0x3c')](_0x4a50da['query'][_0x6f78('0x3c')]);_0x25636a[_0x6f78('0x3e')]=qs[_0x6f78('0x34')](_[_0x6f78('0x5e')](_0x4a50da[_0x6f78('0x32')],_0x52e939['filters']));_0x25636a[_0x6f78('0x3e')][_0x6f78('0x5f')]=_0x247b95['id'];if(_0x4a50da[_0x6f78('0x32')]['filter']){_0x25636a['where']=_['merge'](_0x25636a['where'],{'$or':_['map'](_0x25636a['attributes'],function(_0x26684f){var _0x3c02ae={};_0x3c02ae[_0x26684f]={'$like':'%'+_0x4a50da[_0x6f78('0x32')][_0x6f78('0x24')]+'%'};return _0x3c02ae;})});}_0x25636a=_[_0x6f78('0x3d')]({},_0x25636a,_0x4a50da[_0x6f78('0x40')]);return db[_0x6f78('0x5d')]['count']({'where':_0x25636a[_0x6f78('0x3e')]})[_0x6f78('0x21')](function(_0x208169){_0x1d28db[_0x6f78('0x1b')]=_0x208169;if(_0x4a50da[_0x6f78('0x32')][_0x6f78('0x46')]){_0x25636a[_0x6f78('0x60')]=[{'all':!![]}];}return db['CmHopper'][_0x6f78('0x41')](_0x25636a);})[_0x6f78('0x21')](function(_0x4a2121){_0x1d28db[_0x6f78('0x42')]=_0x4a2121;return _0x1d28db;});}})[_0x6f78('0x21')](respondWithFilteredResult(_0x5c2d50,_0x25636a))['catch'](handleError(_0x5c2d50,null));};exports[_0x6f78('0x61')]=function(_0x23ab83,_0x195b74,_0x58c92b){var _0x2844c7={'raw':!![],'where':{}};var _0x202d42={};var _0x37f9a8={'count':0x0,'rows':[]};return db[_0x6f78('0x2d')][_0x6f78('0x5c')]({'where':{'id':_0x23ab83[_0x6f78('0x45')]['id']}})[_0x6f78('0x21')](handleEntityNotFound(_0x195b74,null))[_0x6f78('0x21')](function(_0x4afac6){if(_0x4afac6){_0x202d42[_0x6f78('0x31')]=_[_0x6f78('0x33')](db[_0x6f78('0x62')][_0x6f78('0x2e')]);_0x202d42[_0x6f78('0x32')]=_[_0x6f78('0x33')](_0x23ab83[_0x6f78('0x32')]);_0x202d42[_0x6f78('0x34')]=_[_0x6f78('0x36')](_0x202d42[_0x6f78('0x31')],_0x202d42[_0x6f78('0x32')]);_0x2844c7[_0x6f78('0x35')]=_[_0x6f78('0x36')](_0x202d42[_0x6f78('0x31')],qs[_0x6f78('0x37')](_0x23ab83[_0x6f78('0x32')]['fields']));_0x2844c7['attributes']=_0x2844c7['attributes']['length']?_0x2844c7[_0x6f78('0x35')]:_0x202d42[_0x6f78('0x31')];if(!_0x23ab83[_0x6f78('0x32')]['hasOwnProperty'](_0x6f78('0x3a'))){_0x2844c7[_0x6f78('0x1d')]=qs[_0x6f78('0x1d')](_0x23ab83[_0x6f78('0x32')]['limit']);_0x2844c7[_0x6f78('0x1c')]=qs[_0x6f78('0x1c')](_0x23ab83[_0x6f78('0x32')][_0x6f78('0x1c')]);}_0x2844c7['order']=qs[_0x6f78('0x3c')](_0x23ab83[_0x6f78('0x32')][_0x6f78('0x3c')]);_0x2844c7[_0x6f78('0x3e')]=qs[_0x6f78('0x34')](_['pick'](_0x23ab83[_0x6f78('0x32')],_0x202d42[_0x6f78('0x34')]));_0x2844c7[_0x6f78('0x3e')][_0x6f78('0x5f')]=_0x4afac6['id'];if(_0x23ab83['query'][_0x6f78('0x24')]){_0x2844c7[_0x6f78('0x3e')]=_[_0x6f78('0x3d')](_0x2844c7[_0x6f78('0x3e')],{'$or':_[_0x6f78('0x26')](_0x2844c7[_0x6f78('0x35')],function(_0x26684c){var _0x5c06af={};_0x5c06af[_0x26684c]={'$like':'%'+_0x23ab83['query']['filter']+'%'};return _0x5c06af;})});}_0x2844c7=_[_0x6f78('0x3d')]({},_0x2844c7,_0x23ab83[_0x6f78('0x40')]);return db[_0x6f78('0x62')][_0x6f78('0x1b')]({'where':_0x2844c7[_0x6f78('0x3e')]})[_0x6f78('0x21')](function(_0x3ab3d1){_0x37f9a8['count']=_0x3ab3d1;if(_0x23ab83[_0x6f78('0x32')][_0x6f78('0x46')]){_0x2844c7[_0x6f78('0x60')]=[{'all':!![]}];}return db[_0x6f78('0x62')][_0x6f78('0x41')](_0x2844c7);})[_0x6f78('0x21')](function(_0x4ec07f){_0x37f9a8[_0x6f78('0x42')]=_0x4ec07f;return _0x37f9a8;});}})[_0x6f78('0x21')](respondWithFilteredResult(_0x195b74,_0x2844c7))[_0x6f78('0x43')](handleError(_0x195b74,null));};exports[_0x6f78('0x63')]=function(_0x3a2bba,_0x46b436,_0x56325d){var _0x3403e7={'raw':!![],'where':{}};var _0x2c8068={};var _0x478496={'count':0x0,'rows':[]};return db[_0x6f78('0x2d')][_0x6f78('0x5c')]({'where':{'id':_0x3a2bba[_0x6f78('0x45')]['id']}})[_0x6f78('0x21')](handleEntityNotFound(_0x46b436,null))[_0x6f78('0x21')](function(_0xfdfa8b){if(_0xfdfa8b){_0x2c8068[_0x6f78('0x31')]=_['keys'](db[_0x6f78('0x64')][_0x6f78('0x2e')]);_0x2c8068[_0x6f78('0x32')]=_['keys'](_0x3a2bba['query']);_0x2c8068[_0x6f78('0x34')]=_['intersection'](_0x2c8068['model'],_0x2c8068[_0x6f78('0x32')]);_0x3403e7[_0x6f78('0x35')]=_[_0x6f78('0x36')](_0x2c8068[_0x6f78('0x31')],qs['fields'](_0x3a2bba['query'][_0x6f78('0x37')]));_0x3403e7['attributes']=_0x3403e7[_0x6f78('0x35')][_0x6f78('0x38')]?_0x3403e7[_0x6f78('0x35')]:_0x2c8068[_0x6f78('0x31')];if(!_0x3a2bba[_0x6f78('0x32')][_0x6f78('0x39')](_0x6f78('0x3a'))){_0x3403e7[_0x6f78('0x1d')]=qs[_0x6f78('0x1d')](_0x3a2bba[_0x6f78('0x32')][_0x6f78('0x1d')]);_0x3403e7[_0x6f78('0x1c')]=qs[_0x6f78('0x1c')](_0x3a2bba[_0x6f78('0x32')][_0x6f78('0x1c')]);}_0x3403e7[_0x6f78('0x3b')]=qs[_0x6f78('0x3c')](_0x3a2bba[_0x6f78('0x32')][_0x6f78('0x3c')]);_0x3403e7[_0x6f78('0x3e')]=qs[_0x6f78('0x34')](_[_0x6f78('0x5e')](_0x3a2bba[_0x6f78('0x32')],_0x2c8068[_0x6f78('0x34')]));_0x3403e7[_0x6f78('0x3e')]['VoiceQueueId']=_0xfdfa8b['id'];if(_0x3a2bba['query'][_0x6f78('0x24')]){_0x3403e7[_0x6f78('0x3e')]=_[_0x6f78('0x3d')](_0x3403e7['where'],{'$or':_[_0x6f78('0x26')](_0x3403e7['attributes'],function(_0x5032ce){var _0x341781={};_0x341781[_0x5032ce]={'$like':'%'+_0x3a2bba[_0x6f78('0x32')][_0x6f78('0x24')]+'%'};return _0x341781;})});}_0x3403e7=_[_0x6f78('0x3d')]({},_0x3403e7,_0x3a2bba[_0x6f78('0x40')]);return db['CmHopperFinal']['count']({'where':_0x3403e7[_0x6f78('0x3e')]})[_0x6f78('0x21')](function(_0x359064){_0x478496[_0x6f78('0x1b')]=_0x359064;if(_0x3a2bba[_0x6f78('0x32')][_0x6f78('0x46')]){_0x3403e7[_0x6f78('0x60')]=[{'all':!![]}];}return db[_0x6f78('0x64')]['findAll'](_0x3403e7);})[_0x6f78('0x21')](function(_0xbade06){_0x478496['rows']=_0xbade06;return _0x478496;});}})['then'](respondWithFilteredResult(_0x46b436,_0x3403e7))[_0x6f78('0x43')](handleError(_0x46b436,null));};exports[_0x6f78('0x65')]=function(_0x2dbb22,_0x2e8745,_0x128ea8){var _0x414f1a={'raw':!![],'where':{}};var _0xa928dd={};var _0xdad9a8={'count':0x0,'rows':[]};return db[_0x6f78('0x2d')][_0x6f78('0x5c')]({'where':{'id':_0x2dbb22[_0x6f78('0x45')]['id']}})[_0x6f78('0x21')](handleEntityNotFound(_0x2e8745,null))[_0x6f78('0x21')](function(_0x5c5fc9){if(_0x5c5fc9){_0xa928dd[_0x6f78('0x31')]=_['keys'](db[_0x6f78('0x66')][_0x6f78('0x2e')]);_0xa928dd[_0x6f78('0x32')]=_[_0x6f78('0x33')](_0x2dbb22[_0x6f78('0x32')]);_0xa928dd[_0x6f78('0x34')]=_[_0x6f78('0x36')](_0xa928dd[_0x6f78('0x31')],_0xa928dd['query']);_0x414f1a['attributes']=_[_0x6f78('0x36')](_0xa928dd[_0x6f78('0x31')],qs[_0x6f78('0x37')](_0x2dbb22[_0x6f78('0x32')]['fields']));_0x414f1a[_0x6f78('0x35')]=_0x414f1a[_0x6f78('0x35')][_0x6f78('0x38')]?_0x414f1a[_0x6f78('0x35')]:_0xa928dd[_0x6f78('0x31')];if(!_0x2dbb22[_0x6f78('0x32')][_0x6f78('0x39')](_0x6f78('0x3a'))){_0x414f1a[_0x6f78('0x1d')]=qs[_0x6f78('0x1d')](_0x2dbb22[_0x6f78('0x32')][_0x6f78('0x1d')]);_0x414f1a[_0x6f78('0x1c')]=qs[_0x6f78('0x1c')](_0x2dbb22[_0x6f78('0x32')][_0x6f78('0x1c')]);}_0x414f1a['order']=qs['sort'](_0x2dbb22[_0x6f78('0x32')][_0x6f78('0x3c')]);_0x414f1a[_0x6f78('0x3e')]=qs['filters'](_[_0x6f78('0x5e')](_0x2dbb22[_0x6f78('0x32')],_0xa928dd[_0x6f78('0x34')]));_0x414f1a[_0x6f78('0x3e')][_0x6f78('0x5f')]=_0x5c5fc9['id'];if(_0x2dbb22[_0x6f78('0x32')][_0x6f78('0x24')]){_0x414f1a[_0x6f78('0x3e')]=_[_0x6f78('0x3d')](_0x414f1a[_0x6f78('0x3e')],{'$or':_[_0x6f78('0x26')](_0x414f1a[_0x6f78('0x35')],function(_0x475362){var _0x2f58fc={};_0x2f58fc[_0x475362]={'$like':'%'+_0x2dbb22['query']['filter']+'%'};return _0x2f58fc;})});}_0x414f1a=_[_0x6f78('0x3d')]({},_0x414f1a,_0x2dbb22['options']);return db[_0x6f78('0x66')]['count']({'where':_0x414f1a[_0x6f78('0x3e')]})['then'](function(_0x6664a2){_0xdad9a8[_0x6f78('0x1b')]=_0x6664a2;if(_0x2dbb22['query'][_0x6f78('0x46')]){_0x414f1a[_0x6f78('0x60')]=[{'all':!![]}];}return db[_0x6f78('0x66')][_0x6f78('0x41')](_0x414f1a);})[_0x6f78('0x21')](function(_0x24fc06){_0xdad9a8[_0x6f78('0x42')]=_0x24fc06;return _0xdad9a8;});}})['then'](respondWithFilteredResult(_0x2e8745,_0x414f1a))[_0x6f78('0x43')](handleError(_0x2e8745,null));};exports[_0x6f78('0x67')]=function(_0x89af27,_0x11b0ba,_0x68b585){var _0x4ffec4={};var _0x2504fc={};var _0x222283;var _0x297a2e;return db[_0x6f78('0x2d')][_0x6f78('0x5c')]({'where':{'id':_0x89af27[_0x6f78('0x45')]['id']}})[_0x6f78('0x21')](handleEntityNotFound(_0x11b0ba,null))[_0x6f78('0x21')](function(_0x64c03b){if(_0x64c03b){_0x222283=_0x64c03b;_0x2504fc[_0x6f78('0x31')]=_[_0x6f78('0x33')](db[_0x6f78('0x68')][_0x6f78('0x2e')]);_0x2504fc['query']=_['keys'](_0x89af27[_0x6f78('0x32')]);_0x2504fc['filters']=_[_0x6f78('0x36')](_0x2504fc[_0x6f78('0x31')],_0x2504fc['query']);_0x4ffec4[_0x6f78('0x35')]=_[_0x6f78('0x36')](_0x2504fc[_0x6f78('0x31')],qs[_0x6f78('0x37')](_0x89af27['query'][_0x6f78('0x37')]));_0x4ffec4[_0x6f78('0x35')]=_0x4ffec4[_0x6f78('0x35')]['length']?_0x4ffec4['attributes']:_0x2504fc[_0x6f78('0x31')];_0x4ffec4['order']=qs[_0x6f78('0x3c')](_0x89af27['query'][_0x6f78('0x3c')]);_0x4ffec4['where']=qs['filters'](_[_0x6f78('0x5e')](_0x89af27['query'],_0x2504fc[_0x6f78('0x34')]));if(_0x89af27[_0x6f78('0x32')][_0x6f78('0x24')]){_0x4ffec4[_0x6f78('0x3e')]=_['merge'](_0x4ffec4[_0x6f78('0x3e')],{'$or':_[_0x6f78('0x26')](_0x4ffec4[_0x6f78('0x35')],function(_0x4150c1){var _0x73baaf={};_0x73baaf[_0x4150c1]={'$like':'%'+_0x89af27['query'][_0x6f78('0x24')]+'%'};return _0x73baaf;})});}_0x4ffec4=_['merge']({},_0x4ffec4,_0x89af27[_0x6f78('0x40')]);return _0x222283[_0x6f78('0x67')](_0x4ffec4);}})[_0x6f78('0x21')](function(_0x2db2ad){if(_0x2db2ad){_0x297a2e=_0x2db2ad[_0x6f78('0x38')];if(!_0x89af27['query'][_0x6f78('0x39')](_0x6f78('0x3a'))){_0x4ffec4[_0x6f78('0x1d')]=qs[_0x6f78('0x1d')](_0x89af27['query']['limit']);_0x4ffec4[_0x6f78('0x1c')]=qs[_0x6f78('0x1c')](_0x89af27['query']['offset']);}return _0x222283[_0x6f78('0x67')](_0x4ffec4);}})[_0x6f78('0x21')](function(_0x4b0720){if(_0x4b0720){return _0x4b0720?{'count':_0x297a2e,'rows':_0x4b0720}:null;}})[_0x6f78('0x21')](respondWithResult(_0x11b0ba,null))['catch'](handleError(_0x11b0ba,null));};exports[_0x6f78('0x69')]=function(_0x2fb215,_0x469196,_0x20934b){var _0xd7b3f1=_0x2fb215[_0x6f78('0x55')]['teams'];var _0x4a3a7a=_[_0x6f78('0x26')](_0xd7b3f1,'id');return db['Team'][_0x6f78('0x41')]({'where':{'id':_0x4a3a7a},'attributes':['id'],'include':[{'model':db[_0x6f78('0x6a')],'as':'Agents','attributes':['id','name','online',_0x6f78('0x6b'),_0x6f78('0x6c')],'raw':!![]}]})[_0x6f78('0x21')](function(_0x5ebee8){if(_0x5ebee8){var _0x3e19d=_[_0x6f78('0x6d')](_0x5ebee8,function(_0x45c97f){var _0x5df4e4=_0x45c97f['get']({'plain':!![]});_0x5df4e4['Agents']['forEach'](function(_0x222819){_0x222819[_0x6f78('0x6e')]=_[_0x6f78('0x28')](_0xd7b3f1,{'id':_0x5df4e4['id']})[_0x6f78('0x6e')];});return _0x5df4e4['Agents'];});return db[_0x6f78('0x2d')]['find']({'where':{'id':_0x2fb215[_0x6f78('0x45')]['id']}})[_0x6f78('0x21')](function(_0x376f67){return db[_0x6f78('0x6f')][_0x6f78('0x70')](function(_0x2ebc53){return _0x376f67[_0x6f78('0x69')](_0x4a3a7a,{'transaction':_0x2ebc53})[_0x6f78('0x21')](function(){return BPromise['each'](_0xd7b3f1,function(_0x115b89){return db[_0x6f78('0x71')]['upsert']({'TeamId':_0x115b89['id'],'VoiceQueueId':_0x2fb215['params']['id'],'penalty':_0x115b89[_0x6f78('0x6e')]},{'transaction':_0x2ebc53});});})[_0x6f78('0x21')](function(){return BPromise[_0x6f78('0x72')](_0x3e19d,function(_0x3146a8){return db[_0x6f78('0x73')]['findOrCreate']({'where':{'UserId':_0x3146a8['id'],'VoiceQueueId':_0x2fb215[_0x6f78('0x45')]['id']},'defaults':{'penalty':_0x3146a8[_0x6f78('0x6e')]},'transaction':_0x2ebc53});});})[_0x6f78('0x21')](function(){return BPromise[_0x6f78('0x72')](_[_0x6f78('0x24')](_0x3e19d,{'online':!![]}),function(_0x3ea390){return db['UserVoiceQueueRt']['upsert']({'membername':_0x3ea390[_0x6f78('0x29')],'UserId':_0x3ea390['id'],'queue_name':_0x376f67['name'],'VoiceQueueId':_0x376f67['id'],'interface':_[_0x6f78('0x74')](_0x3ea390[_0x6f78('0x6c')])?util[_0x6f78('0x75')](_0x6f78('0x76'),_0x3ea390[_0x6f78('0x29')]):_0x3ea390['interface'],'paused':_0x3ea390[_0x6f78('0x6b')]||![],'penalty':_0x3ea390['penalty']},{'transaction':_0x2ebc53});});})[_0x6f78('0x21')](function(){_0x3e19d[_0x6f78('0x77')](function(_0x36bbdd){socket['emit'](_0x6f78('0x78'),{'UserId':_0x36bbdd['id'],'VoiceQueueId':_0x376f67['id']});});});});});}})[_0x6f78('0x21')](respondWithStatusCode(_0x469196,null))[_0x6f78('0x43')](handleError(_0x469196,null));};exports[_0x6f78('0x79')]=function(_0x396df9,_0x5cc509,_0xf8fa16){return db[_0x6f78('0x68')][_0x6f78('0x41')]({'where':{'id':_0x396df9[_0x6f78('0x32')][_0x6f78('0x7a')]},'attributes':['id'],'include':[{'model':db['User'],'as':'Agents','attributes':['id'],'raw':!![]}]})['then'](handleEntityNotFound(_0x5cc509,null))[_0x6f78('0x21')](function(_0x4cfd0d){var _0x132d20=_[_0x6f78('0x26')](_0x4cfd0d,'id');var _0x1ad038=[];var _0x30c9ab=[];var _0x3ad33a=squel[_0x6f78('0x7b')]();_0x3ad33a['field'](_0x6f78('0x7c'))['from'](_0x6f78('0x7d'),'tq')['join'](_0x6f78('0x7e'),'ut',_0x6f78('0x7f'))[_0x6f78('0x3e')](_0x6f78('0x80'),_0x396df9['params']['id']);for(var _0x560b6d=0x0;_0x560b6d<_0x4cfd0d[_0x6f78('0x38')];_0x560b6d+=0x1){let _0x1b2581=_0x4cfd0d[_0x560b6d];for(var _0x18a162=0x0;_0x18a162<_0x1b2581[_0x6f78('0x81')][_0x6f78('0x38')];_0x18a162+=0x1){let _0x70f72c=_0x1b2581[_0x6f78('0x81')][_0x18a162];var _0x2d8b9b=_0x3ad33a[_0x6f78('0x52')]();_0x2d8b9b[_0x6f78('0x3e')](_0x6f78('0x82'),_0x70f72c['id']);_0x30c9ab[_0x6f78('0x83')](db[_0x6f78('0x6f')][_0x6f78('0x32')](_0x2d8b9b[_0x6f78('0x84')](),{'type':db[_0x6f78('0x6f')][_0x6f78('0x85')]['SELECT']})['then'](function(_0x500c3e){if(_0x500c3e['length']===0x1){return _0x70f72c['id'];}else{var _0x1ed20b=_[_0x6f78('0x86')](_[_0x6f78('0x26')](_0x500c3e,_0x6f78('0x87')),function(_0x993057){return _[_0x6f78('0x88')](_0x132d20,_0x993057);});if(_0x1ed20b){return _0x70f72c['id'];}}}));}}return BPromise['all'](_0x30c9ab)['then'](function(_0x39a261){_0x1ad038=_(_0x1ad038)[_0x6f78('0x89')](_0x39a261)[_0x6f78('0x8a')]()['value']();return db[_0x6f78('0x2d')][_0x6f78('0x28')]({'where':{'id':_0x396df9[_0x6f78('0x45')]['id']}})[_0x6f78('0x21')](function(_0x38fa8f){return db[_0x6f78('0x6f')][_0x6f78('0x70')](function(_0x322b1f){return _0x38fa8f[_0x6f78('0x79')](_0x396df9['query']['ids'],{'transaction':_0x322b1f})['then'](function(){if(!_[_0x6f78('0x8b')](_0x1ad038)){return _0x38fa8f[_0x6f78('0x8c')](_0x1ad038,{'transaction':_0x322b1f})[_0x6f78('0x21')](function(){return db[_0x6f78('0x8d')][_0x6f78('0x22')]({'where':{'VoiceQueueId':_0x396df9['params']['id'],'UserId':_0x1ad038},'transaction':_0x322b1f});});}})[_0x6f78('0x21')](function(){_0x1ad038[_0x6f78('0x77')](function(_0x156a15){socket[_0x6f78('0x8e')](_0x6f78('0x8f'),{'UserId':_0x156a15,'VoiceQueueId':_0x38fa8f['id']});});});});});});})['then'](respondWithStatusCode(_0x5cc509,null))[_0x6f78('0x43')](handleError(_0x5cc509,null));};exports[_0x6f78('0x90')]=function(_0x557743,_0x170857,_0x7bf7ce){var _0x1810ef,_0x203aa;return db['VoiceQueue'][_0x6f78('0x28')]({'where':{'id':_0x557743[_0x6f78('0x45')]['id']}})[_0x6f78('0x21')](handleEntityNotFound(_0x170857,null))[_0x6f78('0x21')](function(_0x2deb6a){if(_0x2deb6a){_0x203aa=_0x2deb6a;return _0x2deb6a['addAgents'](_0x557743[_0x6f78('0x55')][_0x6f78('0x7a')],_[_0x6f78('0x53')](_0x557743[_0x6f78('0x55')],[_0x6f78('0x7a'),'id'])||{})[_0x6f78('0x91')](function(_0x4b33ff){for(var _0xdbb546=0x0;_0xdbb546<_0x557743['body'][_0x6f78('0x7a')][_0x6f78('0x38')];_0xdbb546+=0x1){socket['emit']('userVoiceQueue:save',{'UserId':_0x557743[_0x6f78('0x55')]['ids'][_0xdbb546],'VoiceQueueId':_0x557743['params']['id']});}return _0x4b33ff;});}})[_0x6f78('0x21')](function(_0x33338c){_0x1810ef=_0x33338c||[];if(_0x203aa){return db[_0x6f78('0x6a')]['findAll']({'where':{'id':_0x557743['body'][_0x6f78('0x7a')]},'attributes':['id','name',_0x6f78('0x92'),'voicePause','interface'],'raw':!![]});}})['then'](function(_0x90e3e1){if(!_[_0x6f78('0x8b')](_0x90e3e1)){var _0x29acac=[];for(var _0x319a81=0x0;_0x319a81<_0x90e3e1[_0x6f78('0x38')];_0x319a81++){if(_0x90e3e1[_0x319a81][_0x6f78('0x92')]){_0x29acac['push'](db[_0x6f78('0x8d')][_0x6f78('0x93')]({'membername':_0x90e3e1[_0x319a81][_0x6f78('0x29')],'UserId':_0x90e3e1[_0x319a81]['id'],'queue_name':_0x203aa[_0x6f78('0x29')],'VoiceQueueId':_0x203aa['id'],'interface':_[_0x6f78('0x74')](_0x90e3e1[_0x319a81][_0x6f78('0x6c')])?util[_0x6f78('0x75')](_0x6f78('0x76'),_0x90e3e1[_0x319a81][_0x6f78('0x29')]):_0x90e3e1[_0x319a81][_0x6f78('0x6c')],'paused':_0x90e3e1[_0x319a81][_0x6f78('0x6b')]||![],'penalty':_0x557743[_0x6f78('0x55')][_0x6f78('0x6e')]||0x0}));}}return BPromise[_0x6f78('0x94')](_0x29acac);}})[_0x6f78('0x21')](function(){return _0x1810ef;})[_0x6f78('0x21')](respondWithResult(_0x170857,null))[_0x6f78('0x43')](handleError(_0x170857,null));};exports[_0x6f78('0x8c')]=function(_0x3ba1c2,_0x37d4cb,_0x58a358){return db[_0x6f78('0x2d')][_0x6f78('0x28')]({'where':{'id':_0x3ba1c2[_0x6f78('0x45')]['id']}})['then'](handleEntityNotFound(_0x37d4cb,null))['then'](function(_0x51ac1d){if(_0x51ac1d){return _0x51ac1d['removeAgents'](_0x3ba1c2[_0x6f78('0x32')]['ids'])['then'](function(){if(_[_0x6f78('0x95')](_0x3ba1c2[_0x6f78('0x32')][_0x6f78('0x7a')])){for(var _0xf98763=0x0;_0xf98763<_0x3ba1c2['query'][_0x6f78('0x7a')]['length'];_0xf98763+=0x1){socket[_0x6f78('0x8e')](_0x6f78('0x8f'),{'UserId':Number(_0x3ba1c2[_0x6f78('0x32')][_0x6f78('0x7a')][_0xf98763]),'VoiceQueueId':Number(_0x3ba1c2[_0x6f78('0x45')]['id'])});}}else{socket[_0x6f78('0x8e')]('userVoiceQueue:remove',{'UserId':Number(_0x3ba1c2[_0x6f78('0x32')][_0x6f78('0x7a')]),'VoiceQueueId':Number(_0x3ba1c2[_0x6f78('0x45')]['id'])});}});}})['then'](function(_0x5754cc){return db[_0x6f78('0x8d')][_0x6f78('0x22')]({'where':{'VoiceQueueId':_0x3ba1c2[_0x6f78('0x45')]['id'],'UserId':_0x3ba1c2['query'][_0x6f78('0x7a')]}})[_0x6f78('0x21')](function(){return _0x5754cc;});})[_0x6f78('0x21')](respondWithStatusCode(_0x37d4cb,null))[_0x6f78('0x43')](handleError(_0x37d4cb,null));};exports[_0x6f78('0x96')]=function(_0x591cad,_0x6d7ef7,_0x16b8dc){var _0x4d3916={};var _0x3128fc={};var _0x21c10b;var _0xe8736f;return db[_0x6f78('0x2d')][_0x6f78('0x5c')]({'where':{'id':_0x591cad[_0x6f78('0x45')]['id']}})[_0x6f78('0x21')](handleEntityNotFound(_0x6d7ef7,null))[_0x6f78('0x21')](function(_0x584a2d){if(_0x584a2d){_0x21c10b=_0x584a2d;_0x3128fc[_0x6f78('0x31')]=_[_0x6f78('0x33')](db[_0x6f78('0x6a')][_0x6f78('0x2e')]);_0x3128fc[_0x6f78('0x32')]=_[_0x6f78('0x33')](_0x591cad[_0x6f78('0x32')]);_0x3128fc[_0x6f78('0x34')]=_[_0x6f78('0x36')](_0x3128fc[_0x6f78('0x31')],_0x3128fc['query']);_0x4d3916[_0x6f78('0x35')]=_['intersection'](_0x3128fc[_0x6f78('0x31')],qs[_0x6f78('0x37')](_0x591cad[_0x6f78('0x32')][_0x6f78('0x37')]));_0x4d3916[_0x6f78('0x35')]=_0x4d3916[_0x6f78('0x35')][_0x6f78('0x38')]?_0x4d3916[_0x6f78('0x35')]:_0x3128fc[_0x6f78('0x31')];_0x4d3916[_0x6f78('0x3b')]=qs[_0x6f78('0x3c')](_0x591cad['query']['sort']);_0x4d3916[_0x6f78('0x3e')]=qs[_0x6f78('0x34')](_['pick'](_0x591cad['query'],_0x3128fc[_0x6f78('0x34')]));if(_0x591cad[_0x6f78('0x32')][_0x6f78('0x24')]){_0x4d3916[_0x6f78('0x3e')]=_[_0x6f78('0x3d')](_0x4d3916[_0x6f78('0x3e')],{'$or':_['map'](_0x4d3916[_0x6f78('0x35')],function(_0x50e9d5){var _0x8d78b6={};_0x8d78b6[_0x50e9d5]={'$like':'%'+_0x591cad[_0x6f78('0x32')][_0x6f78('0x24')]+'%'};return _0x8d78b6;})});}_0x4d3916=_[_0x6f78('0x3d')]({},_0x4d3916,_0x591cad['options']);return _0x21c10b[_0x6f78('0x96')](_0x4d3916);}})[_0x6f78('0x21')](function(_0x56b8dd){if(_0x56b8dd){_0xe8736f=_0x56b8dd[_0x6f78('0x38')];if(!_0x591cad[_0x6f78('0x32')][_0x6f78('0x39')](_0x6f78('0x3a'))){_0x4d3916[_0x6f78('0x1d')]=qs[_0x6f78('0x1d')](_0x591cad[_0x6f78('0x32')][_0x6f78('0x1d')]);_0x4d3916[_0x6f78('0x1c')]=qs[_0x6f78('0x1c')](_0x591cad['query'][_0x6f78('0x1c')]);}return _0x21c10b[_0x6f78('0x96')](_0x4d3916);}})[_0x6f78('0x21')](function(_0x1d9085){if(_0x1d9085){return _0x1d9085?{'count':_0xe8736f,'rows':_0x1d9085}:null;}})[_0x6f78('0x21')](respondWithResult(_0x6d7ef7,null))[_0x6f78('0x43')](handleError(_0x6d7ef7,null));};exports[_0x6f78('0x97')]=function(_0x2a83cf,_0x556fbb,_0x372f44){var _0x55499c={};var _0x4dd5c6={};var _0x1b4568;var _0x973e81;return db['VoiceQueue'][_0x6f78('0x5c')]({'where':{'id':_0x2a83cf[_0x6f78('0x45')]['id']}})[_0x6f78('0x21')](handleEntityNotFound(_0x556fbb,null))[_0x6f78('0x21')](function(_0x169f2e){if(_0x169f2e){_0x1b4568=_0x169f2e;_0x4dd5c6['model']=_['keys'](db[_0x6f78('0x8d')][_0x6f78('0x2e')]);_0x4dd5c6[_0x6f78('0x32')]=_[_0x6f78('0x33')](_0x2a83cf[_0x6f78('0x32')]);_0x4dd5c6[_0x6f78('0x34')]=_['intersection'](_0x4dd5c6['model'],_0x4dd5c6[_0x6f78('0x32')]);_0x55499c[_0x6f78('0x35')]=_['intersection'](_0x4dd5c6['model'],qs[_0x6f78('0x37')](_0x2a83cf[_0x6f78('0x32')][_0x6f78('0x37')]));_0x55499c['attributes']=_0x55499c['attributes'][_0x6f78('0x38')]?_0x55499c['attributes']:_0x4dd5c6[_0x6f78('0x31')];_0x55499c[_0x6f78('0x3b')]=qs[_0x6f78('0x3c')](_0x2a83cf[_0x6f78('0x32')]['sort']);_0x55499c[_0x6f78('0x3e')]=qs[_0x6f78('0x34')](_[_0x6f78('0x5e')](_0x2a83cf[_0x6f78('0x32')],_0x4dd5c6[_0x6f78('0x34')]));if(_0x2a83cf[_0x6f78('0x32')][_0x6f78('0x24')]){_0x55499c[_0x6f78('0x3e')]=_[_0x6f78('0x3d')](_0x55499c[_0x6f78('0x3e')],{'$or':_[_0x6f78('0x26')](_0x55499c['attributes'],function(_0x44bee2){var _0xddcece={};_0xddcece[_0x44bee2]={'$like':'%'+_0x2a83cf[_0x6f78('0x32')][_0x6f78('0x24')]+'%'};return _0xddcece;})});}_0x55499c=_['merge']({},_0x55499c,_0x2a83cf[_0x6f78('0x40')]);return _0x1b4568['getMembers'](_0x55499c);}})[_0x6f78('0x21')](function(_0x5c065a){if(_0x5c065a){_0x973e81=_0x5c065a[_0x6f78('0x38')];if(!_0x2a83cf['query'][_0x6f78('0x39')](_0x6f78('0x3a'))){_0x55499c[_0x6f78('0x1d')]=qs[_0x6f78('0x1d')](_0x2a83cf['query'][_0x6f78('0x1d')]);_0x55499c[_0x6f78('0x1c')]=qs['offset'](_0x2a83cf[_0x6f78('0x32')][_0x6f78('0x1c')]);}return _0x1b4568[_0x6f78('0x97')](_0x55499c);}})[_0x6f78('0x21')](function(_0x1c6559){return _0x1c6559?{'count':_0x973e81,'rows':_0x1c6559}:null;})[_0x6f78('0x21')](respondWithResult(_0x556fbb,null))[_0x6f78('0x43')](handleError(_0x556fbb,null));};exports[_0x6f78('0x98')]=function(_0x84d12b,_0x47b791,_0x358c85){var _0x4bc191={};var _0x59f3b9={};var _0x2e3f2e;var _0x4e0c93;return db[_0x6f78('0x2d')][_0x6f78('0x5c')]({'where':{'id':_0x84d12b['params']['id']}})[_0x6f78('0x21')](handleEntityNotFound(_0x47b791,null))['then'](function(_0x25a082){if(_0x25a082){_0x2e3f2e=_0x25a082;_0x59f3b9[_0x6f78('0x31')]=_[_0x6f78('0x33')](db[_0x6f78('0x99')][_0x6f78('0x2e')]);_0x59f3b9[_0x6f78('0x32')]=_[_0x6f78('0x33')](_0x84d12b[_0x6f78('0x32')]);_0x59f3b9[_0x6f78('0x34')]=_[_0x6f78('0x36')](_0x59f3b9['model'],_0x59f3b9[_0x6f78('0x32')]);_0x4bc191['attributes']=_[_0x6f78('0x36')](_0x59f3b9[_0x6f78('0x31')],qs[_0x6f78('0x37')](_0x84d12b['query'][_0x6f78('0x37')]));_0x4bc191['attributes']=_0x4bc191[_0x6f78('0x35')][_0x6f78('0x38')]?_0x4bc191[_0x6f78('0x35')]:_0x59f3b9[_0x6f78('0x31')];_0x4bc191[_0x6f78('0x3b')]=qs[_0x6f78('0x3c')](_0x84d12b[_0x6f78('0x32')][_0x6f78('0x3c')]);_0x4bc191[_0x6f78('0x3e')]=qs[_0x6f78('0x34')](_[_0x6f78('0x5e')](_0x84d12b[_0x6f78('0x32')],_0x59f3b9[_0x6f78('0x34')]));if(_0x84d12b[_0x6f78('0x32')]['filter']){_0x4bc191['where']=_[_0x6f78('0x3d')](_0x4bc191[_0x6f78('0x3e')],{'$or':_[_0x6f78('0x26')](_0x4bc191[_0x6f78('0x35')],function(_0xd8755a){var _0x48e525={};_0x48e525[_0xd8755a]={'$like':'%'+_0x84d12b[_0x6f78('0x32')][_0x6f78('0x24')]+'%'};return _0x48e525;})});}_0x4bc191=_['merge']({},_0x4bc191,_0x84d12b[_0x6f78('0x40')]);return _0x2e3f2e[_0x6f78('0x98')](_0x4bc191);}})[_0x6f78('0x21')](function(_0x478a28){if(_0x478a28){_0x4e0c93=_0x478a28[_0x6f78('0x38')];if(!_0x84d12b[_0x6f78('0x32')][_0x6f78('0x39')]('nolimit')){_0x4bc191[_0x6f78('0x1d')]=qs['limit'](_0x84d12b[_0x6f78('0x32')][_0x6f78('0x1d')]);_0x4bc191[_0x6f78('0x1c')]=qs[_0x6f78('0x1c')](_0x84d12b['query'][_0x6f78('0x1c')]);}return _0x2e3f2e[_0x6f78('0x98')](_0x4bc191);}})[_0x6f78('0x21')](function(_0x423fb0){if(_0x423fb0){return _0x423fb0?{'count':_0x4e0c93,'rows':_0x423fb0}:null;}})[_0x6f78('0x21')](respondWithResult(_0x47b791,null))[_0x6f78('0x43')](handleError(_0x47b791,null));};exports[_0x6f78('0x9a')]=function(_0x3aebae,_0x4c52bb,_0x362b25){var _0x307ccd,_0x345e79;return db[_0x6f78('0x2d')][_0x6f78('0x28')]({'where':{'id':_0x3aebae['params']['id']}})[_0x6f78('0x21')](handleEntityNotFound(_0x4c52bb,null))[_0x6f78('0x21')](function(_0x2293d8){if(_0x2293d8){_0x345e79=_0x2293d8;return _0x2293d8[_0x6f78('0x9a')](_0x3aebae[_0x6f78('0x55')][_0x6f78('0x7a')],_['omit'](_0x3aebae[_0x6f78('0x55')],[_0x6f78('0x7a'),'id'])||{});}return null;})['spread'](function(_0x2341b9){var _0x3e41d7;_0x307ccd=_0x2341b9||[];var _0x3b9524=[];if(_0x2341b9){for(var _0x44e556=0x0;_0x44e556<_0x2341b9['length'];_0x44e556+=0x1){var _0x3fd4ab=_0x2341b9[_0x44e556][_0x6f78('0x49')]({'plain':!![]});_0x345e79[_0x6f78('0x9b')]=_0x3aebae[_0x6f78('0x55')][_0x6f78('0x9b')]?_0x3aebae[_0x6f78('0x55')]['dialCheckDuplicateType']:_0x345e79['dialCheckDuplicateType'];switch(_0x345e79[_0x6f78('0x9b')]){case _0x6f78('0x9c'):_0x3e41d7=squel[_0x6f78('0x9d')]()['into'](_0x6f78('0x9e'))['fromQuery']([_0x6f78('0x9f'),_0x6f78('0xa0'),_0x6f78('0xa1'),_0x6f78('0xa2'),_0x6f78('0x5f'),'createdAt',_0x6f78('0x54')],squel['select']()[_0x6f78('0xa3')](_0x6f78('0x9f'),_0x6f78('0x9f'))[_0x6f78('0xa3')](_0x6f78('0xa4'),_0x6f78('0xa0'))[_0x6f78('0xa3')]('id','ContactId')[_0x6f78('0xa3')](_0x3fd4ab[_0x6f78('0xa5')][_0x6f78('0x84')](),_0x6f78('0xa2'))[_0x6f78('0xa3')](_0x3aebae[_0x6f78('0x45')]['id']['toString'](),'VoiceQueueId')[_0x6f78('0xa3')](_0x6f78('0xa4'),_0x6f78('0x56'))['field'](_0x6f78('0xa4'),_0x6f78('0x54'))[_0x6f78('0xa6')](_0x6f78('0xa7'))['where'](_0x6f78('0xa8'))[_0x6f78('0x3e')](_0x6f78('0xa9'),_0x3fd4ab[_0x6f78('0xa5')][_0x6f78('0x84')]())[_0x6f78('0x3e')](_0x6f78('0xaa'))[_0x6f78('0x3e')](_0x6f78('0xab'),squel[_0x6f78('0x7b')]()['field'](_0x6f78('0xac'))[_0x6f78('0xa6')](_0x6f78('0xad'))[_0x6f78('0x3e')](_0x6f78('0x80'),_0x3aebae['params']['id'][_0x6f78('0x84')]()))[_0x6f78('0x3e')](_0x6f78('0xab'),squel[_0x6f78('0x7b')]()['field'](_0x6f78('0xae'))[_0x6f78('0xa6')](_0x6f78('0x9e'))[_0x6f78('0x3e')](_0x6f78('0x80'),_0x3aebae[_0x6f78('0x45')]['id'][_0x6f78('0x84')]())))[_0x6f78('0x84')]();break;case _0x6f78('0xaf'):_0x3e41d7=squel['insert']()[_0x6f78('0xb0')]('cm_hopper')[_0x6f78('0xb1')](['phone','scheduledAt','ContactId',_0x6f78('0xa2'),'VoiceQueueId','createdAt','updatedAt'],squel[_0x6f78('0x7b')]()[_0x6f78('0xa3')]('phone',_0x6f78('0x9f'))['field'](_0x6f78('0xa4'),_0x6f78('0xa0'))[_0x6f78('0xa3')]('id',_0x6f78('0xa1'))[_0x6f78('0xa3')](_0x3fd4ab[_0x6f78('0xa5')][_0x6f78('0x84')](),'ListId')[_0x6f78('0xa3')](_0x3aebae[_0x6f78('0x45')]['id'][_0x6f78('0x84')](),_0x6f78('0x5f'))[_0x6f78('0xa3')]('NOW()',_0x6f78('0x56'))[_0x6f78('0xa3')](_0x6f78('0xa4'),_0x6f78('0x54'))[_0x6f78('0xa6')](_0x6f78('0xa7'))['where'](_0x6f78('0xa8'))[_0x6f78('0x3e')]('ListId\x20=\x20?',_0x3fd4ab[_0x6f78('0xa5')][_0x6f78('0x84')]())[_0x6f78('0x3e')](_0x6f78('0xaa'))[_0x6f78('0x3e')](_0x6f78('0xab'),squel[_0x6f78('0x7b')]()[_0x6f78('0xa3')]('COALESCE(phone,\x27\x27)')[_0x6f78('0xa6')](_0x6f78('0x9e'))[_0x6f78('0x3e')](_0x6f78('0x80'),_0x3aebae['params']['id'][_0x6f78('0x84')]())))[_0x6f78('0x84')]();break;default:_0x3e41d7=squel[_0x6f78('0x9d')]()[_0x6f78('0xb0')]('cm_hopper')[_0x6f78('0xb1')](['phone',_0x6f78('0xa0'),_0x6f78('0xa1'),_0x6f78('0xa2'),_0x6f78('0x5f'),_0x6f78('0x56'),_0x6f78('0x54')],squel['select']()['field'](_0x6f78('0x9f'),_0x6f78('0x9f'))['field']('NOW()',_0x6f78('0xa0'))[_0x6f78('0xa3')]('id','ContactId')['field'](_0x3fd4ab[_0x6f78('0xa5')]['toString'](),_0x6f78('0xa2'))['field'](_0x3aebae[_0x6f78('0x45')]['id']['toString'](),_0x6f78('0x5f'))[_0x6f78('0xa3')]('NOW()','createdAt')[_0x6f78('0xa3')]('NOW()',_0x6f78('0x54'))[_0x6f78('0xa6')]('cm_contacts')[_0x6f78('0x3e')](_0x6f78('0xa8'))[_0x6f78('0x3e')](_0x6f78('0xa9'),_0x3fd4ab[_0x6f78('0xa5')][_0x6f78('0x84')]())[_0x6f78('0x3e')]('phone\x20IS\x20NOT\x20NULL'))[_0x6f78('0x84')]();}_0x3b9524[_0x6f78('0x83')](db[_0x6f78('0x6f')][_0x6f78('0x32')](_0x3e41d7));}return BPromise['all'](_0x3b9524);}})[_0x6f78('0x21')](function(){return _0x307ccd;})[_0x6f78('0x21')](respondWithResult(_0x4c52bb,null))[_0x6f78('0x43')](handleError(_0x4c52bb,null));};exports[_0x6f78('0xb2')]=function(_0x2fa626,_0x5ac716,_0x5cf494){return db[_0x6f78('0x2d')][_0x6f78('0x28')]({'where':{'id':_0x2fa626[_0x6f78('0x45')]['id']}})['then'](handleEntityNotFound(_0x5ac716,null))['then'](function(_0x34373c){if(_0x34373c){return _0x34373c[_0x6f78('0xb2')](_0x2fa626['query']['ids']);}})[_0x6f78('0x21')](function(_0x2adb23){if(_0x2adb23){return db[_0x6f78('0x5d')][_0x6f78('0x22')]({'where':{'ListId':_0x2fa626[_0x6f78('0x32')][_0x6f78('0x7a')],'VoiceQueueId':_0x2fa626['params']['id']}})[_0x6f78('0x21')](function(){return _0x2adb23;});}})[_0x6f78('0x21')](respondWithStatusCode(_0x5ac716,null))[_0x6f78('0x43')](handleError(_0x5ac716,null));};exports[_0x6f78('0xb3')]=function(_0x3de681,_0x151914,_0x1da1b6){var _0x28e05c={};var _0x1787aa={};var _0x44dc13;var _0x236d5c;return db[_0x6f78('0x2d')][_0x6f78('0x5c')]({'where':{'id':_0x3de681[_0x6f78('0x45')]['id']}})[_0x6f78('0x21')](handleEntityNotFound(_0x151914,null))[_0x6f78('0x21')](function(_0x3c25df){if(_0x3c25df){_0x44dc13=_0x3c25df;_0x1787aa[_0x6f78('0x31')]=_[_0x6f78('0x33')](db[_0x6f78('0x99')]['rawAttributes']);_0x1787aa[_0x6f78('0x32')]=_[_0x6f78('0x33')](_0x3de681[_0x6f78('0x32')]);_0x1787aa[_0x6f78('0x34')]=_[_0x6f78('0x36')](_0x1787aa[_0x6f78('0x31')],_0x1787aa[_0x6f78('0x32')]);_0x28e05c['attributes']=_['intersection'](_0x1787aa[_0x6f78('0x31')],qs[_0x6f78('0x37')](_0x3de681[_0x6f78('0x32')][_0x6f78('0x37')]));_0x28e05c[_0x6f78('0x35')]=_0x28e05c[_0x6f78('0x35')][_0x6f78('0x38')]?_0x28e05c[_0x6f78('0x35')]:_0x1787aa[_0x6f78('0x31')];_0x28e05c[_0x6f78('0x3b')]=qs['sort'](_0x3de681[_0x6f78('0x32')]['sort']);_0x28e05c[_0x6f78('0x3e')]=qs[_0x6f78('0x34')](_['pick'](_0x3de681[_0x6f78('0x32')],_0x1787aa['filters']));if(_0x3de681[_0x6f78('0x32')]['filter']){_0x28e05c[_0x6f78('0x3e')]=_['merge'](_0x28e05c[_0x6f78('0x3e')],{'$or':_['map'](_0x28e05c['attributes'],function(_0x130140){var _0x8bcf78={};_0x8bcf78[_0x130140]={'$like':'%'+_0x3de681[_0x6f78('0x32')]['filter']+'%'};return _0x8bcf78;})});}_0x28e05c=_['merge']({},_0x28e05c,_0x3de681['options']);return _0x44dc13[_0x6f78('0xb3')](_0x28e05c);}})[_0x6f78('0x21')](function(_0x487bca){if(_0x487bca){_0x236d5c=_0x487bca[_0x6f78('0x38')];if(!_0x3de681[_0x6f78('0x32')][_0x6f78('0x39')](_0x6f78('0x3a'))){_0x28e05c['limit']=qs[_0x6f78('0x1d')](_0x3de681[_0x6f78('0x32')][_0x6f78('0x1d')]);_0x28e05c[_0x6f78('0x1c')]=qs[_0x6f78('0x1c')](_0x3de681[_0x6f78('0x32')][_0x6f78('0x1c')]);}return _0x44dc13[_0x6f78('0xb3')](_0x28e05c);}})['then'](function(_0x12240c){if(_0x12240c){return _0x12240c?{'count':_0x236d5c,'rows':_0x12240c}:null;}})[_0x6f78('0x21')](respondWithResult(_0x151914,null))['catch'](handleError(_0x151914,null));};exports[_0x6f78('0xb4')]=function(_0x5da574,_0x16fd1d,_0x3a1ed3){var _0x6d8a03,_0x1a1af0;return db[_0x6f78('0x2d')][_0x6f78('0x28')]({'where':{'id':_0x5da574[_0x6f78('0x45')]['id']}})[_0x6f78('0x21')](handleEntityNotFound(_0x16fd1d,null))['then'](function(_0x1101ef){if(_0x1101ef){_0x1a1af0=_0x1101ef;return _0x1101ef[_0x6f78('0xb4')](_0x5da574[_0x6f78('0x55')][_0x6f78('0x7a')],_[_0x6f78('0x53')](_0x5da574[_0x6f78('0x55')],[_0x6f78('0x7a'),'id'])||{});}return null;})[_0x6f78('0x91')](function(_0x136bd5){var _0x11f48d;_0x6d8a03=_0x136bd5||[];var _0xaca81b=[];if(_0x136bd5){for(var _0x320f89=0x0;_0x320f89<_0x136bd5[_0x6f78('0x38')];_0x320f89+=0x1){var _0x11c13a=_0x136bd5[_0x320f89][_0x6f78('0x49')]({'plain':!![]});_0x11f48d=squel[_0x6f78('0x9d')]()['into'](_0x6f78('0xb5'))[_0x6f78('0xb1')](['phone',_0x6f78('0xa1'),_0x6f78('0xa2'),'VoiceQueueId',_0x6f78('0x56'),_0x6f78('0x54')],squel[_0x6f78('0x7b')]()[_0x6f78('0xa3')](_0x6f78('0x9f'),'phone')[_0x6f78('0xa3')]('id','ContactId')[_0x6f78('0xa3')](_0x11c13a[_0x6f78('0xa5')][_0x6f78('0x84')](),_0x6f78('0xa2'))[_0x6f78('0xa3')](_0x5da574[_0x6f78('0x45')]['id'][_0x6f78('0x84')](),'VoiceQueueId')[_0x6f78('0xa3')](_0x6f78('0xa4'),'createdAt')[_0x6f78('0xa3')](_0x6f78('0xa4'),_0x6f78('0x54'))['from'](_0x6f78('0xa7'))[_0x6f78('0x3e')](_0x6f78('0xa8'))['where'](_0x6f78('0xa9'),_0x11c13a['CmListId'][_0x6f78('0x84')]())['where']('phone\x20IS\x20NOT\x20NULL'))[_0x6f78('0x84')]();_0xaca81b[_0x6f78('0x83')](db['sequelize']['query'](_0x11f48d));}return BPromise[_0x6f78('0x94')](_0xaca81b);}})[_0x6f78('0x21')](function(){return _0x6d8a03;})[_0x6f78('0x21')](respondWithResult(_0x16fd1d,null))[_0x6f78('0x43')](handleError(_0x16fd1d,null));};exports[_0x6f78('0xb6')]=function(_0x10bedd,_0x42c79b,_0x3fbdda){return db[_0x6f78('0x2d')]['find']({'where':{'id':_0x10bedd[_0x6f78('0x45')]['id']}})[_0x6f78('0x21')](handleEntityNotFound(_0x42c79b,null))[_0x6f78('0x21')](function(_0xc6424b){if(_0xc6424b){return _0xc6424b['removeBlackLists'](_0x10bedd['query']['ids']);}})['then'](function(_0x7f9adc){if(_0x7f9adc){return db[_0x6f78('0x66')][_0x6f78('0x22')]({'where':{'ListId':_0x10bedd['query'][_0x6f78('0x7a')],'VoiceQueueId':_0x10bedd[_0x6f78('0x45')]['id']}})[_0x6f78('0x21')](function(){return _0x7f9adc;});}})['then'](respondWithStatusCode(_0x42c79b,null))[_0x6f78('0x43')](handleError(_0x42c79b,null));};