Built motion from commit (unavailable).|2.5.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 _0x6f9f=['map','value','includes','type','find','name','UserProfileResource','stack','index','VoiceQueue','fieldName','key','query','keys','intersection','model','attributes','fields','length','nolimit','order','sort','where','filters','pick','filter','merge','VIRTUAL','options','includeAll','include','findAll','rows','catch','show','params','rawAttributes','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','userProfileId','autoAssociation','clone','omit','updatedAt','createdAt','error','CmHopper','hasOwnProperty','getHopperHistories','findOne','CmHopperHistory','VoiceQueueId','getHopperFinals','CmHopperFinal','CmHopperBlack','getTeams','Team','addTeams','User','Agents','voicePause','interface','flatMap','forEach','penalty','transaction','UserVoiceQueue','findOrCreate','each','format','emit','userVoiceQueue:save','removeTeams','ids','field','tq.TeamId','from','team_has_voice_queues','join','user_has_teams','ut.TeamId\x20=\x20tq.TeamId','VoiceQueueId\x20=\x20?','ut.UserId\x20=\x20?','push','sequelize','toString','QueryTypes','SELECT','all','union','isEmpty','UserVoiceQueueRt','destroy','userVoiceQueue:remove','online','upsert','isNil','SIP/%s','removeAgents','getAgents','getMembers','getLists','CmList','addLists','spread','dialCheckDuplicateType','always','insert','into','cm_hopper','phone','scheduledAt','ContactId','ListId','select','NOW()','deletedAt\x20IS\x20NULL','ListId\x20=\x20?','CmListId','phone\x20IS\x20NOT\x20NULL','phone\x20NOT\x20IN\x20(?)','COALESCE(calleridnum,\x27\x27)','cm_hopper_final','COALESCE(phone,\x27\x27)','onlyIfOpen','fromQuery','cm_contacts','removeLists','getBlackLists','addBlackLists','cm_hopper_black','removeBlackLists','html-pdf','rimraf','zip-dir','fast-json-patch','request-promise','bluebird','mustache','util','path','sox','to-csv','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','redis','defaults','localhost','socket.io-emitter','./voiceQueue.socket','register','sendStatus','status','end','json','count','offset','limit','set','apply','reject','save','update','then','get','VoiceQueues','inbound','QueueCampaigns','outbound','ignore'];(function(_0x1ca29f,_0x318ac5){var _0x576c3b=function(_0x40caab){while(--_0x40caab){_0x1ca29f['push'](_0x1ca29f['shift']());}};_0x576c3b(++_0x318ac5);}(_0x6f9f,0x142));var _0xf6f9=function(_0x4de1d3,_0x46b0ba){_0x4de1d3=_0x4de1d3-0x0;var _0x1879a6=_0x6f9f[_0x4de1d3];return _0x1879a6;};'use strict';var pdf=require(_0xf6f9('0x0'));var emlformat=require('eml-format');var rimraf=require(_0xf6f9('0x1'));var zipdir=require(_0xf6f9('0x2'));var jsonpatch=require(_0xf6f9('0x3'));var rp=require(_0xf6f9('0x4'));var moment=require('moment');var BPromise=require(_0xf6f9('0x5'));var Mustache=require(_0xf6f9('0x6'));var util=require(_0xf6f9('0x7'));var path=require(_0xf6f9('0x8'));var sox=require(_0xf6f9('0x9'));var csv=require(_0xf6f9('0xa'));var ejs=require('ejs');var fs=require('fs');var _=require(_0xf6f9('0xb'));var squel=require(_0xf6f9('0xc'));var crypto=require(_0xf6f9('0xd'));var jsforce=require(_0xf6f9('0xe'));var deskjs=require(_0xf6f9('0xf'));var toCsv=require(_0xf6f9('0xa'));var querystring=require(_0xf6f9('0x10'));var Papa=require(_0xf6f9('0x11'));var Redis=require(_0xf6f9('0x12'));var authService=require(_0xf6f9('0x13'));var qs=require(_0xf6f9('0x14'));var as=require(_0xf6f9('0x15'));var hardwareService=require(_0xf6f9('0x16'));var logger=require(_0xf6f9('0x17'))(_0xf6f9('0x18'));var utils=require(_0xf6f9('0x19'));var config=require(_0xf6f9('0x1a'));var licenseUtil=require('../../config/license/util');var db=require('../../mysqldb')['db'];config[_0xf6f9('0x1b')]=_[_0xf6f9('0x1c')](config['redis'],{'host':_0xf6f9('0x1d'),'port':0x18eb});var socket=require(_0xf6f9('0x1e'))(new Redis(config[_0xf6f9('0x1b')]));require(_0xf6f9('0x1f'))[_0xf6f9('0x20')](socket);function respondWithStatusCode(_0x1b558c,_0x4c1374){_0x4c1374=_0x4c1374||0xcc;return function(_0x384fa5){if(_0x384fa5){return _0x1b558c[_0xf6f9('0x21')](_0x4c1374);}return _0x1b558c[_0xf6f9('0x22')](_0x4c1374)[_0xf6f9('0x23')]();};}function respondWithResult(_0x165930,_0x179df9){_0x179df9=_0x179df9||0xc8;return function(_0x53afbb){if(_0x53afbb){return _0x165930[_0xf6f9('0x22')](_0x179df9)[_0xf6f9('0x24')](_0x53afbb);}};}function respondWithFilteredResult(_0x1ec1e7,_0x3cb10d){return function(_0x4b8336){if(_0x4b8336){var _0x3ce53a=_0x4b8336[_0xf6f9('0x25')],_0x1f35bc=_0x3cb10d['offset'],_0x508a07=_0x3cb10d[_0xf6f9('0x26')]+_0x3cb10d[_0xf6f9('0x27')],_0x65fbbc;if(_0x508a07>=_0x3ce53a){_0x508a07=_0x3ce53a;_0x65fbbc=0xc8;}else{_0x65fbbc=0xce;}_0x1ec1e7[_0xf6f9('0x22')](_0x65fbbc);return _0x1ec1e7[_0xf6f9('0x28')]('Content-Range',_0x1f35bc+'-'+_0x508a07+'/'+_0x3ce53a)[_0xf6f9('0x24')](_0x4b8336);}return null;};}function patchUpdates(_0x4bfd97){return function(_0x11e990){try{jsonpatch[_0xf6f9('0x29')](_0x11e990,_0x4bfd97,!![]);}catch(_0x4f41ea){return BPromise[_0xf6f9('0x2a')](_0x4f41ea);}return _0x11e990[_0xf6f9('0x2b')]();};}function saveUpdates(_0x4a3724,_0x4b76f0){return function(_0x3c92de){if(_0x3c92de){return _0x3c92de[_0xf6f9('0x2c')](_0x4a3724)[_0xf6f9('0x2d')](function(_0x2b924b){return _0x2b924b;});}return null;};}function removeEntity(_0x434ccd,_0x17dac2){return function(_0x1dc19d){if(_0x1dc19d){return _0x1dc19d['destroy']()[_0xf6f9('0x2d')](function(){var _0x39d1b0=_0x1dc19d[_0xf6f9('0x2e')]({'plain':!![]});var _0x414315=[{'name':_0xf6f9('0x2f'),'value':_0xf6f9('0x30'),'ignore':![]},{'name':_0xf6f9('0x31'),'value':_0xf6f9('0x32'),'ignore':![]}];var _0x480c9e=_(_0x414315)['filter'](_0xf6f9('0x33'))[_0xf6f9('0x34')](_0xf6f9('0x35'))['value']();if(_[_0xf6f9('0x36')](_0x480c9e,_0x39d1b0[_0xf6f9('0x37')])){return;}var _0x55b422=_[_0xf6f9('0x38')](_0x414315,['value',_0x39d1b0[_0xf6f9('0x37')]])[_0xf6f9('0x39')];return db[_0xf6f9('0x3a')]['destroy']({'where':{'type':_0x55b422,'resourceId':_0x39d1b0['id']}})[_0xf6f9('0x2d')](function(){return _0x1dc19d;});})['then'](function(){_0x434ccd[_0xf6f9('0x22')](0xcc)[_0xf6f9('0x23')]();});}};}function handleEntityNotFound(_0x566f59,_0x436f32){return function(_0x4a74eb){if(!_0x4a74eb){_0x566f59[_0xf6f9('0x21')](0x194);}return _0x4a74eb;};}function handleError(_0x485f36,_0x1349d0){_0x1349d0=_0x1349d0||0x1f4;return function(_0x3717de){logger['error'](_0x3717de[_0xf6f9('0x3b')]);if(_0x3717de[_0xf6f9('0x39')]){delete _0x3717de[_0xf6f9('0x39')];}_0x485f36[_0xf6f9('0x22')](_0x1349d0)['send'](_0x3717de);};}exports[_0xf6f9('0x3c')]=function(_0x405cb9,_0x3a8ea5){var _0xed95b3={},_0x18869c={},_0x2c1855={'count':0x0,'rows':[]};var _0x4f1f30=_[_0xf6f9('0x34')](db[_0xf6f9('0x3d')]['rawAttributes'],function(_0x5296a5){return{'name':_0x5296a5[_0xf6f9('0x3e')],'type':_0x5296a5[_0xf6f9('0x37')][_0xf6f9('0x3f')]};});_0x18869c['model']=_[_0xf6f9('0x34')](_0x4f1f30,_0xf6f9('0x39'));_0x18869c[_0xf6f9('0x40')]=_[_0xf6f9('0x41')](_0x405cb9['query']);_0x18869c['filters']=_[_0xf6f9('0x42')](_0x18869c[_0xf6f9('0x43')],_0x18869c['query']);_0xed95b3[_0xf6f9('0x44')]=_['intersection'](_0x18869c[_0xf6f9('0x43')],qs[_0xf6f9('0x45')](_0x405cb9['query'][_0xf6f9('0x45')]));_0xed95b3[_0xf6f9('0x44')]=_0xed95b3[_0xf6f9('0x44')][_0xf6f9('0x46')]?_0xed95b3[_0xf6f9('0x44')]:_0x18869c[_0xf6f9('0x43')];if(!_0x405cb9[_0xf6f9('0x40')]['hasOwnProperty'](_0xf6f9('0x47'))){_0xed95b3[_0xf6f9('0x27')]=qs['limit'](_0x405cb9[_0xf6f9('0x40')][_0xf6f9('0x27')]);_0xed95b3[_0xf6f9('0x26')]=qs['offset'](_0x405cb9['query'][_0xf6f9('0x26')]);}_0xed95b3[_0xf6f9('0x48')]=qs['sort'](_0x405cb9['query'][_0xf6f9('0x49')]);_0xed95b3[_0xf6f9('0x4a')]=qs[_0xf6f9('0x4b')](_[_0xf6f9('0x4c')](_0x405cb9[_0xf6f9('0x40')],_0x18869c[_0xf6f9('0x4b')]),_0x4f1f30);if(_0x405cb9[_0xf6f9('0x40')][_0xf6f9('0x4d')]){_0xed95b3['where']=_[_0xf6f9('0x4e')](_0xed95b3['where'],{'$or':_[_0xf6f9('0x34')](_0x4f1f30,function(_0x2f948b){if(_0x2f948b[_0xf6f9('0x37')]!==_0xf6f9('0x4f')){var _0x1bb037={};_0x1bb037[_0x2f948b[_0xf6f9('0x39')]]={'$like':'%'+_0x405cb9[_0xf6f9('0x40')]['filter']+'%'};return _0x1bb037;}})});}_0xed95b3=_['merge']({},_0xed95b3,_0x405cb9[_0xf6f9('0x50')]);var _0x5b508c={'where':_0xed95b3['where']};return db[_0xf6f9('0x3d')][_0xf6f9('0x25')](_0x5b508c)[_0xf6f9('0x2d')](function(_0x5f1f84){_0x2c1855[_0xf6f9('0x25')]=_0x5f1f84;if(_0x405cb9[_0xf6f9('0x40')][_0xf6f9('0x51')]){_0xed95b3[_0xf6f9('0x52')]=[{'all':!![]}];}return db[_0xf6f9('0x3d')][_0xf6f9('0x53')](_0xed95b3);})['then'](function(_0x24ad16){_0x2c1855[_0xf6f9('0x54')]=_0x24ad16;return _0x2c1855;})['then'](respondWithFilteredResult(_0x3a8ea5,_0xed95b3))[_0xf6f9('0x55')](handleError(_0x3a8ea5,null));};exports[_0xf6f9('0x56')]=function(_0x4ea714,_0x2b437c){var _0x6b638d={'raw':![],'where':{'id':_0x4ea714[_0xf6f9('0x57')]['id']}},_0xd7e8bd={};_0xd7e8bd[_0xf6f9('0x43')]=_[_0xf6f9('0x41')](db[_0xf6f9('0x3d')][_0xf6f9('0x58')]);_0xd7e8bd['query']=_[_0xf6f9('0x41')](_0x4ea714[_0xf6f9('0x40')]);_0xd7e8bd['filters']=_[_0xf6f9('0x42')](_0xd7e8bd['model'],_0xd7e8bd['query']);_0x6b638d[_0xf6f9('0x44')]=_[_0xf6f9('0x42')](_0xd7e8bd['model'],qs[_0xf6f9('0x45')](_0x4ea714[_0xf6f9('0x40')]['fields']));_0x6b638d[_0xf6f9('0x44')]=_0x6b638d[_0xf6f9('0x44')][_0xf6f9('0x46')]?_0x6b638d[_0xf6f9('0x44')]:_0xd7e8bd['model'];if(_0x4ea714[_0xf6f9('0x40')][_0xf6f9('0x51')]){_0x6b638d[_0xf6f9('0x52')]=[{'all':!![]}];}_0x6b638d=_[_0xf6f9('0x4e')]({},_0x6b638d,_0x4ea714[_0xf6f9('0x50')]);return db['VoiceQueue'][_0xf6f9('0x38')](_0x6b638d)[_0xf6f9('0x2d')](handleEntityNotFound(_0x2b437c,null))[_0xf6f9('0x2d')](respondWithResult(_0x2b437c,null))[_0xf6f9('0x55')](handleError(_0x2b437c,null));};exports[_0xf6f9('0x59')]=function(_0x33f22a,_0x3d7922){return db[_0xf6f9('0x3d')][_0xf6f9('0x59')](_0x33f22a[_0xf6f9('0x5a')],{})[_0xf6f9('0x2d')](function(_0x8f410c){var _0x20f48d=_0x33f22a[_0xf6f9('0x5b')][_0xf6f9('0x2e')]({'plain':!![]});if(!_0x20f48d)throw new Error(_0xf6f9('0x5c'));if(_0x20f48d[_0xf6f9('0x5d')]==='user'){var _0x8511d=_0x8f410c[_0xf6f9('0x2e')]({'plain':!![]});var _0x52c1d3=[{'name':_0xf6f9('0x2f'),'value':_0xf6f9('0x30')},{'name':_0xf6f9('0x31'),'value':'outbound'}];var _0x19c98a=_[_0xf6f9('0x38')](_0x52c1d3,[_0xf6f9('0x35'),_0x8511d['type']])[_0xf6f9('0x39')];return db['UserProfileSection'][_0xf6f9('0x38')]({'where':{'name':_0x19c98a,'userProfileId':_0x20f48d[_0xf6f9('0x5e')]},'raw':!![]})[_0xf6f9('0x2d')](function(_0x48278a){if(_0x48278a&&_0x48278a[_0xf6f9('0x5f')]===0x0){return db[_0xf6f9('0x3a')][_0xf6f9('0x59')]({'name':_0x8511d['name'],'resourceId':_0x8511d['id'],'type':_0x48278a[_0xf6f9('0x39')],'sectionId':_0x48278a['id']},{})['then'](function(){return _0x8f410c;});}else{return _0x8f410c;}})[_0xf6f9('0x55')](function(_0x276590){logger['error']('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x276590);throw _0x276590;});}return _0x8f410c;})[_0xf6f9('0x2d')](respondWithResult(_0x3d7922,0xc9))[_0xf6f9('0x55')](handleError(_0x3d7922,null));};exports[_0xf6f9('0x60')]=function(_0x42e2b0,_0x418cc6){var _0x35834c={'where':{'id':_0x42e2b0[_0xf6f9('0x57')]['id']}},_0xdb6061={};_0xdb6061[_0xf6f9('0x43')]=_[_0xf6f9('0x41')](db[_0xf6f9('0x3d')]['rawAttributes']);_0x35834c['attributes']=_[_0xf6f9('0x42')](_0xdb6061[_0xf6f9('0x43')],qs[_0xf6f9('0x45')](_0x42e2b0['query'][_0xf6f9('0x45')]));_0x35834c['attributes']=_0x35834c[_0xf6f9('0x44')]['length']?_0x35834c['attributes']:_0xdb6061[_0xf6f9('0x43')];if(_0x42e2b0[_0xf6f9('0x40')][_0xf6f9('0x51')]){_0x35834c[_0xf6f9('0x52')]=[{'all':!![]}];}_0x35834c=_[_0xf6f9('0x4e')]({},_0x35834c,_0x42e2b0[_0xf6f9('0x50')]);return db[_0xf6f9('0x3d')][_0xf6f9('0x38')](_0x35834c)[_0xf6f9('0x2d')](handleEntityNotFound(_0x418cc6,null))[_0xf6f9('0x2d')](function(_0x12ca82){if(_0x12ca82){var _0x21cf8a=_0x12ca82[_0xf6f9('0x2e')]({'plain':!![]});_0x21cf8a=qs[_0xf6f9('0x61')](_0x21cf8a,['id','createdAt',_0xf6f9('0x62')]);_0x42e2b0['body']=_[_0xf6f9('0x61')](_0x42e2b0[_0xf6f9('0x5a')],['id',_0xf6f9('0x63'),'updatedAt']);return db[_0xf6f9('0x3d')][_0xf6f9('0x59')](_[_0xf6f9('0x4e')](_0x21cf8a,_0x42e2b0[_0xf6f9('0x5a')]),{'include':_0x42e2b0[_0xf6f9('0x40')][_0xf6f9('0x51')]?[{'all':!![]}]:undefined})['then'](function(_0x2cc031){var _0x1275ce=_0x42e2b0[_0xf6f9('0x5b')]['get']({'plain':!![]});if(!_0x1275ce)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x1275ce[_0xf6f9('0x5d')]===_0xf6f9('0x5b')){var _0x110998=_0x2cc031['get']({'plain':!![]});var _0x4dcb98=[{'name':'VoiceQueues','value':'inbound'},{'name':_0xf6f9('0x31'),'value':'outbound'}];var _0x29b992=_[_0xf6f9('0x38')](_0x4dcb98,[_0xf6f9('0x35'),_0x110998[_0xf6f9('0x37')]])['name'];return db['UserProfileSection'][_0xf6f9('0x38')]({'where':{'name':_0x29b992,'userProfileId':_0x1275ce['userProfileId']},'raw':!![]})[_0xf6f9('0x2d')](function(_0x27f1b0){if(_0x27f1b0&&_0x27f1b0['autoAssociation']===0x0){return db[_0xf6f9('0x3a')][_0xf6f9('0x59')]({'name':_0x110998[_0xf6f9('0x39')],'resourceId':_0x110998['id'],'type':_0x27f1b0[_0xf6f9('0x39')],'sectionId':_0x27f1b0['id']},{})[_0xf6f9('0x2d')](function(){return _0x2cc031;});}else{return _0x2cc031;}})['catch'](function(_0x51568a){logger[_0xf6f9('0x64')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x51568a);throw _0x51568a;});}return _0x2cc031;});}})[_0xf6f9('0x2d')](respondWithResult(_0x418cc6,0xc9))[_0xf6f9('0x55')](handleError(_0x418cc6,null));};exports[_0xf6f9('0x2c')]=function(_0x31f9ef,_0x15d234){if(_0x31f9ef[_0xf6f9('0x5a')]['id']){delete _0x31f9ef[_0xf6f9('0x5a')]['id'];}return db['VoiceQueue'][_0xf6f9('0x38')]({'where':{'id':_0x31f9ef[_0xf6f9('0x57')]['id']}})['then'](handleEntityNotFound(_0x15d234,null))[_0xf6f9('0x2d')](saveUpdates(_0x31f9ef['body'],null))[_0xf6f9('0x2d')](respondWithResult(_0x15d234,null))['catch'](handleError(_0x15d234,null));};exports['destroy']=function(_0x42c095,_0x3c3704){return db[_0xf6f9('0x3d')]['find']({'where':{'id':_0x42c095[_0xf6f9('0x57')]['id']}})[_0xf6f9('0x2d')](handleEntityNotFound(_0x3c3704,null))[_0xf6f9('0x2d')](removeEntity(_0x3c3704,null))[_0xf6f9('0x55')](handleError(_0x3c3704,null));};exports['getHoppers']=function(_0x39bd4c,_0x8f3dc3,_0x262bc9){var _0x871b22={'raw':![],'where':{}};var _0x258881={};var _0x3a52f6={'count':0x0,'rows':[]};return db[_0xf6f9('0x3d')]['findOne']({'where':{'id':_0x39bd4c[_0xf6f9('0x57')]['id']}})['then'](handleEntityNotFound(_0x8f3dc3,null))[_0xf6f9('0x2d')](function(_0x632e9f){if(_0x632e9f){_0x258881[_0xf6f9('0x43')]=_['keys'](db[_0xf6f9('0x65')][_0xf6f9('0x58')]);_0x258881['query']=_[_0xf6f9('0x41')](_0x39bd4c[_0xf6f9('0x40')]);_0x258881['filters']=_[_0xf6f9('0x42')](_0x258881['model'],_0x258881['query']);_0x871b22[_0xf6f9('0x44')]=_[_0xf6f9('0x42')](_0x258881['model'],qs[_0xf6f9('0x45')](_0x39bd4c['query'][_0xf6f9('0x45')]));_0x871b22[_0xf6f9('0x44')]=_0x871b22[_0xf6f9('0x44')][_0xf6f9('0x46')]?_0x871b22[_0xf6f9('0x44')]:_0x258881[_0xf6f9('0x43')];if(!_0x39bd4c[_0xf6f9('0x40')][_0xf6f9('0x66')](_0xf6f9('0x47'))){_0x871b22[_0xf6f9('0x27')]=qs[_0xf6f9('0x27')](_0x39bd4c[_0xf6f9('0x40')][_0xf6f9('0x27')]);_0x871b22['offset']=qs['offset'](_0x39bd4c['query']['offset']);}_0x871b22[_0xf6f9('0x48')]=qs[_0xf6f9('0x49')](_0x39bd4c[_0xf6f9('0x40')]['sort']);_0x871b22[_0xf6f9('0x4a')]=qs['filters'](_[_0xf6f9('0x4c')](_0x39bd4c[_0xf6f9('0x40')],_0x258881[_0xf6f9('0x4b')]));_0x871b22[_0xf6f9('0x4a')]['VoiceQueueId']=_0x632e9f['id'];if(_0x39bd4c[_0xf6f9('0x40')][_0xf6f9('0x4d')]){_0x871b22['where']=_[_0xf6f9('0x4e')](_0x871b22[_0xf6f9('0x4a')],{'$or':_['map'](_0x871b22[_0xf6f9('0x44')],function(_0x5ce279){var _0x183072={};_0x183072[_0x5ce279]={'$like':'%'+_0x39bd4c['query']['filter']+'%'};return _0x183072;})});}_0x871b22=_['merge']({},_0x871b22,_0x39bd4c['options']);return db[_0xf6f9('0x65')][_0xf6f9('0x25')]({'where':_0x871b22['where']})[_0xf6f9('0x2d')](function(_0x2875bf){_0x3a52f6[_0xf6f9('0x25')]=_0x2875bf;if(_0x39bd4c[_0xf6f9('0x40')][_0xf6f9('0x51')]){_0x871b22[_0xf6f9('0x52')]=[{'all':!![]}];}return db['CmHopper']['findAll'](_0x871b22);})[_0xf6f9('0x2d')](function(_0x33596d){_0x3a52f6[_0xf6f9('0x54')]=_0x33596d;return _0x3a52f6;});}})[_0xf6f9('0x2d')](respondWithFilteredResult(_0x8f3dc3,_0x871b22))[_0xf6f9('0x55')](handleError(_0x8f3dc3,null));};exports[_0xf6f9('0x67')]=function(_0x4f76fc,_0xcfd1c6,_0x45c126){var _0x517d04={'raw':!![],'where':{}};var _0x2b03dd={};var _0x491be0={'count':0x0,'rows':[]};return db[_0xf6f9('0x3d')][_0xf6f9('0x68')]({'where':{'id':_0x4f76fc[_0xf6f9('0x57')]['id']}})[_0xf6f9('0x2d')](handleEntityNotFound(_0xcfd1c6,null))[_0xf6f9('0x2d')](function(_0x6ea69c){if(_0x6ea69c){_0x2b03dd[_0xf6f9('0x43')]=_[_0xf6f9('0x41')](db[_0xf6f9('0x69')][_0xf6f9('0x58')]);_0x2b03dd['query']=_[_0xf6f9('0x41')](_0x4f76fc[_0xf6f9('0x40')]);_0x2b03dd[_0xf6f9('0x4b')]=_[_0xf6f9('0x42')](_0x2b03dd[_0xf6f9('0x43')],_0x2b03dd[_0xf6f9('0x40')]);_0x517d04[_0xf6f9('0x44')]=_[_0xf6f9('0x42')](_0x2b03dd[_0xf6f9('0x43')],qs[_0xf6f9('0x45')](_0x4f76fc[_0xf6f9('0x40')][_0xf6f9('0x45')]));_0x517d04[_0xf6f9('0x44')]=_0x517d04[_0xf6f9('0x44')][_0xf6f9('0x46')]?_0x517d04[_0xf6f9('0x44')]:_0x2b03dd[_0xf6f9('0x43')];if(!_0x4f76fc['query'][_0xf6f9('0x66')](_0xf6f9('0x47'))){_0x517d04[_0xf6f9('0x27')]=qs['limit'](_0x4f76fc[_0xf6f9('0x40')][_0xf6f9('0x27')]);_0x517d04['offset']=qs[_0xf6f9('0x26')](_0x4f76fc['query']['offset']);}_0x517d04[_0xf6f9('0x48')]=qs[_0xf6f9('0x49')](_0x4f76fc[_0xf6f9('0x40')][_0xf6f9('0x49')]);_0x517d04[_0xf6f9('0x4a')]=qs[_0xf6f9('0x4b')](_[_0xf6f9('0x4c')](_0x4f76fc['query'],_0x2b03dd[_0xf6f9('0x4b')]));_0x517d04['where'][_0xf6f9('0x6a')]=_0x6ea69c['id'];if(_0x4f76fc[_0xf6f9('0x40')]['filter']){_0x517d04[_0xf6f9('0x4a')]=_[_0xf6f9('0x4e')](_0x517d04[_0xf6f9('0x4a')],{'$or':_[_0xf6f9('0x34')](_0x517d04[_0xf6f9('0x44')],function(_0x1f486e){var _0x45b040={};_0x45b040[_0x1f486e]={'$like':'%'+_0x4f76fc[_0xf6f9('0x40')]['filter']+'%'};return _0x45b040;})});}_0x517d04=_[_0xf6f9('0x4e')]({},_0x517d04,_0x4f76fc[_0xf6f9('0x50')]);return db[_0xf6f9('0x69')][_0xf6f9('0x25')]({'where':_0x517d04[_0xf6f9('0x4a')]})['then'](function(_0x3c7d55){_0x491be0[_0xf6f9('0x25')]=_0x3c7d55;if(_0x4f76fc['query'][_0xf6f9('0x51')]){_0x517d04['include']=[{'all':!![]}];}return db['CmHopperHistory'][_0xf6f9('0x53')](_0x517d04);})[_0xf6f9('0x2d')](function(_0x5abcc0){_0x491be0[_0xf6f9('0x54')]=_0x5abcc0;return _0x491be0;});}})[_0xf6f9('0x2d')](respondWithFilteredResult(_0xcfd1c6,_0x517d04))[_0xf6f9('0x55')](handleError(_0xcfd1c6,null));};exports[_0xf6f9('0x6b')]=function(_0x33f04c,_0x220ecf,_0x4b7dde){var _0x4bdddc={'raw':!![],'where':{}};var _0xf82dda={};var _0x154129={'count':0x0,'rows':[]};return db[_0xf6f9('0x3d')][_0xf6f9('0x68')]({'where':{'id':_0x33f04c[_0xf6f9('0x57')]['id']}})['then'](handleEntityNotFound(_0x220ecf,null))[_0xf6f9('0x2d')](function(_0x424f05){if(_0x424f05){_0xf82dda[_0xf6f9('0x43')]=_['keys'](db[_0xf6f9('0x6c')][_0xf6f9('0x58')]);_0xf82dda[_0xf6f9('0x40')]=_[_0xf6f9('0x41')](_0x33f04c[_0xf6f9('0x40')]);_0xf82dda['filters']=_['intersection'](_0xf82dda[_0xf6f9('0x43')],_0xf82dda['query']);_0x4bdddc[_0xf6f9('0x44')]=_[_0xf6f9('0x42')](_0xf82dda[_0xf6f9('0x43')],qs[_0xf6f9('0x45')](_0x33f04c['query'][_0xf6f9('0x45')]));_0x4bdddc[_0xf6f9('0x44')]=_0x4bdddc[_0xf6f9('0x44')]['length']?_0x4bdddc[_0xf6f9('0x44')]:_0xf82dda[_0xf6f9('0x43')];if(!_0x33f04c[_0xf6f9('0x40')]['hasOwnProperty'](_0xf6f9('0x47'))){_0x4bdddc[_0xf6f9('0x27')]=qs[_0xf6f9('0x27')](_0x33f04c['query'][_0xf6f9('0x27')]);_0x4bdddc[_0xf6f9('0x26')]=qs[_0xf6f9('0x26')](_0x33f04c[_0xf6f9('0x40')][_0xf6f9('0x26')]);}_0x4bdddc[_0xf6f9('0x48')]=qs[_0xf6f9('0x49')](_0x33f04c[_0xf6f9('0x40')][_0xf6f9('0x49')]);_0x4bdddc[_0xf6f9('0x4a')]=qs[_0xf6f9('0x4b')](_[_0xf6f9('0x4c')](_0x33f04c[_0xf6f9('0x40')],_0xf82dda['filters']));_0x4bdddc[_0xf6f9('0x4a')]['VoiceQueueId']=_0x424f05['id'];if(_0x33f04c[_0xf6f9('0x40')][_0xf6f9('0x4d')]){_0x4bdddc['where']=_[_0xf6f9('0x4e')](_0x4bdddc[_0xf6f9('0x4a')],{'$or':_['map'](_0x4bdddc[_0xf6f9('0x44')],function(_0x5f2be8){var _0x1d45b9={};_0x1d45b9[_0x5f2be8]={'$like':'%'+_0x33f04c[_0xf6f9('0x40')][_0xf6f9('0x4d')]+'%'};return _0x1d45b9;})});}_0x4bdddc=_[_0xf6f9('0x4e')]({},_0x4bdddc,_0x33f04c['options']);return db[_0xf6f9('0x6c')]['count']({'where':_0x4bdddc[_0xf6f9('0x4a')]})[_0xf6f9('0x2d')](function(_0x4eb651){_0x154129[_0xf6f9('0x25')]=_0x4eb651;if(_0x33f04c[_0xf6f9('0x40')][_0xf6f9('0x51')]){_0x4bdddc[_0xf6f9('0x52')]=[{'all':!![]}];}return db['CmHopperFinal']['findAll'](_0x4bdddc);})[_0xf6f9('0x2d')](function(_0x35074d){_0x154129[_0xf6f9('0x54')]=_0x35074d;return _0x154129;});}})[_0xf6f9('0x2d')](respondWithFilteredResult(_0x220ecf,_0x4bdddc))['catch'](handleError(_0x220ecf,null));};exports['getHopperBlacks']=function(_0x360f9c,_0x4bb4cf,_0x14339e){var _0x230d8c={'raw':!![],'where':{}};var _0x5ed43a={};var _0x507c17={'count':0x0,'rows':[]};return db['VoiceQueue'][_0xf6f9('0x68')]({'where':{'id':_0x360f9c[_0xf6f9('0x57')]['id']}})['then'](handleEntityNotFound(_0x4bb4cf,null))['then'](function(_0x478e50){if(_0x478e50){_0x5ed43a[_0xf6f9('0x43')]=_[_0xf6f9('0x41')](db['CmHopperBlack'][_0xf6f9('0x58')]);_0x5ed43a[_0xf6f9('0x40')]=_['keys'](_0x360f9c[_0xf6f9('0x40')]);_0x5ed43a[_0xf6f9('0x4b')]=_[_0xf6f9('0x42')](_0x5ed43a[_0xf6f9('0x43')],_0x5ed43a['query']);_0x230d8c[_0xf6f9('0x44')]=_['intersection'](_0x5ed43a[_0xf6f9('0x43')],qs[_0xf6f9('0x45')](_0x360f9c[_0xf6f9('0x40')]['fields']));_0x230d8c[_0xf6f9('0x44')]=_0x230d8c[_0xf6f9('0x44')]['length']?_0x230d8c[_0xf6f9('0x44')]:_0x5ed43a[_0xf6f9('0x43')];if(!_0x360f9c[_0xf6f9('0x40')][_0xf6f9('0x66')](_0xf6f9('0x47'))){_0x230d8c['limit']=qs[_0xf6f9('0x27')](_0x360f9c['query']['limit']);_0x230d8c['offset']=qs[_0xf6f9('0x26')](_0x360f9c[_0xf6f9('0x40')][_0xf6f9('0x26')]);}_0x230d8c[_0xf6f9('0x48')]=qs[_0xf6f9('0x49')](_0x360f9c[_0xf6f9('0x40')][_0xf6f9('0x49')]);_0x230d8c[_0xf6f9('0x4a')]=qs[_0xf6f9('0x4b')](_[_0xf6f9('0x4c')](_0x360f9c[_0xf6f9('0x40')],_0x5ed43a[_0xf6f9('0x4b')]));_0x230d8c[_0xf6f9('0x4a')][_0xf6f9('0x6a')]=_0x478e50['id'];if(_0x360f9c[_0xf6f9('0x40')][_0xf6f9('0x4d')]){_0x230d8c['where']=_[_0xf6f9('0x4e')](_0x230d8c[_0xf6f9('0x4a')],{'$or':_[_0xf6f9('0x34')](_0x230d8c[_0xf6f9('0x44')],function(_0x19bc01){var _0x38c1ae={};_0x38c1ae[_0x19bc01]={'$like':'%'+_0x360f9c['query']['filter']+'%'};return _0x38c1ae;})});}_0x230d8c=_['merge']({},_0x230d8c,_0x360f9c[_0xf6f9('0x50')]);return db[_0xf6f9('0x6d')][_0xf6f9('0x25')]({'where':_0x230d8c['where']})[_0xf6f9('0x2d')](function(_0x471154){_0x507c17[_0xf6f9('0x25')]=_0x471154;if(_0x360f9c['query']['includeAll']){_0x230d8c[_0xf6f9('0x52')]=[{'all':!![]}];}return db[_0xf6f9('0x6d')][_0xf6f9('0x53')](_0x230d8c);})[_0xf6f9('0x2d')](function(_0x1ced71){_0x507c17[_0xf6f9('0x54')]=_0x1ced71;return _0x507c17;});}})[_0xf6f9('0x2d')](respondWithFilteredResult(_0x4bb4cf,_0x230d8c))['catch'](handleError(_0x4bb4cf,null));};exports[_0xf6f9('0x6e')]=function(_0x2d4a9c,_0x4caa18,_0x4167aa){var _0x12cda6={};var _0x198eb1={};var _0x5e1e0a;var _0x34b8ae;return db['VoiceQueue'][_0xf6f9('0x68')]({'where':{'id':_0x2d4a9c[_0xf6f9('0x57')]['id']}})['then'](handleEntityNotFound(_0x4caa18,null))[_0xf6f9('0x2d')](function(_0x3d8c05){if(_0x3d8c05){_0x5e1e0a=_0x3d8c05;_0x198eb1[_0xf6f9('0x43')]=_[_0xf6f9('0x41')](db[_0xf6f9('0x6f')]['rawAttributes']);_0x198eb1[_0xf6f9('0x40')]=_['keys'](_0x2d4a9c[_0xf6f9('0x40')]);_0x198eb1[_0xf6f9('0x4b')]=_[_0xf6f9('0x42')](_0x198eb1[_0xf6f9('0x43')],_0x198eb1[_0xf6f9('0x40')]);_0x12cda6['attributes']=_[_0xf6f9('0x42')](_0x198eb1['model'],qs[_0xf6f9('0x45')](_0x2d4a9c[_0xf6f9('0x40')]['fields']));_0x12cda6[_0xf6f9('0x44')]=_0x12cda6['attributes'][_0xf6f9('0x46')]?_0x12cda6[_0xf6f9('0x44')]:_0x198eb1['model'];_0x12cda6[_0xf6f9('0x48')]=qs[_0xf6f9('0x49')](_0x2d4a9c[_0xf6f9('0x40')]['sort']);_0x12cda6['where']=qs['filters'](_[_0xf6f9('0x4c')](_0x2d4a9c[_0xf6f9('0x40')],_0x198eb1[_0xf6f9('0x4b')]));if(_0x2d4a9c[_0xf6f9('0x40')][_0xf6f9('0x4d')]){_0x12cda6[_0xf6f9('0x4a')]=_[_0xf6f9('0x4e')](_0x12cda6['where'],{'$or':_[_0xf6f9('0x34')](_0x12cda6[_0xf6f9('0x44')],function(_0x27a21d){var _0x839b2a={};_0x839b2a[_0x27a21d]={'$like':'%'+_0x2d4a9c[_0xf6f9('0x40')][_0xf6f9('0x4d')]+'%'};return _0x839b2a;})});}_0x12cda6=_['merge']({},_0x12cda6,_0x2d4a9c[_0xf6f9('0x50')]);return _0x5e1e0a['getTeams'](_0x12cda6);}})[_0xf6f9('0x2d')](function(_0x45bc6a){if(_0x45bc6a){_0x34b8ae=_0x45bc6a[_0xf6f9('0x46')];if(!_0x2d4a9c[_0xf6f9('0x40')][_0xf6f9('0x66')]('nolimit')){_0x12cda6[_0xf6f9('0x27')]=qs['limit'](_0x2d4a9c['query'][_0xf6f9('0x27')]);_0x12cda6[_0xf6f9('0x26')]=qs['offset'](_0x2d4a9c[_0xf6f9('0x40')][_0xf6f9('0x26')]);}return _0x5e1e0a[_0xf6f9('0x6e')](_0x12cda6);}})[_0xf6f9('0x2d')](function(_0x4097db){if(_0x4097db){return _0x4097db?{'count':_0x34b8ae,'rows':_0x4097db}:null;}})['then'](respondWithResult(_0x4caa18,null))['catch'](handleError(_0x4caa18,null));};exports[_0xf6f9('0x70')]=function(_0x25962b,_0x445dce,_0x5e0d58){var _0x25fcae=_0x25962b[_0xf6f9('0x5a')]['teams'];var _0x3bd2f6=_[_0xf6f9('0x34')](_0x25fcae,'id');return db[_0xf6f9('0x6f')]['findAll']({'where':{'id':_0x3bd2f6},'attributes':['id'],'include':[{'model':db[_0xf6f9('0x71')],'as':_0xf6f9('0x72'),'attributes':['id',_0xf6f9('0x39'),'online',_0xf6f9('0x73'),_0xf6f9('0x74')],'raw':!![]}]})['then'](function(_0x1aea8e){if(_0x1aea8e){var _0x345a32=_[_0xf6f9('0x75')](_0x1aea8e,function(_0x3be40a){var _0x468e68=_0x3be40a[_0xf6f9('0x2e')]({'plain':!![]});_0x468e68['Agents'][_0xf6f9('0x76')](function(_0x365819){_0x365819[_0xf6f9('0x77')]=_[_0xf6f9('0x38')](_0x25fcae,{'id':_0x468e68['id']})[_0xf6f9('0x77')];});return _0x468e68['Agents'];});return db['VoiceQueue'][_0xf6f9('0x38')]({'where':{'id':_0x25962b[_0xf6f9('0x57')]['id']}})[_0xf6f9('0x2d')](function(_0x47898b){return db['sequelize'][_0xf6f9('0x78')](function(_0x269afa){return _0x47898b['addTeams'](_0x3bd2f6,{'transaction':_0x269afa})['then'](function(){return BPromise['each'](_0x345a32,function(_0x5be84c){return db[_0xf6f9('0x79')][_0xf6f9('0x7a')]({'where':{'UserId':_0x5be84c['id'],'VoiceQueueId':_0x25962b['params']['id']},'defaults':{'penalty':_0x5be84c['penalty']},'transaction':_0x269afa});});})[_0xf6f9('0x2d')](function(){return BPromise[_0xf6f9('0x7b')](_[_0xf6f9('0x4d')](_0x345a32,{'online':!![]}),function(_0x555d12){return db['UserVoiceQueueRt']['upsert']({'membername':_0x555d12[_0xf6f9('0x39')],'UserId':_0x555d12['id'],'queue_name':_0x47898b[_0xf6f9('0x39')],'VoiceQueueId':_0x47898b['id'],'interface':_['isNil'](_0x555d12[_0xf6f9('0x74')])?util[_0xf6f9('0x7c')]('SIP/%s',_0x555d12['name']):_0x555d12[_0xf6f9('0x74')],'paused':_0x555d12[_0xf6f9('0x73')]||![],'penalty':_0x555d12[_0xf6f9('0x77')]},{'transaction':_0x269afa});});})[_0xf6f9('0x2d')](function(){_0x345a32[_0xf6f9('0x76')](function(_0x431471){socket[_0xf6f9('0x7d')](_0xf6f9('0x7e'),{'UserId':_0x431471['id'],'VoiceQueueId':_0x47898b['id']});});});});});}})[_0xf6f9('0x2d')](respondWithStatusCode(_0x445dce,null))[_0xf6f9('0x55')](handleError(_0x445dce,null));};exports[_0xf6f9('0x7f')]=function(_0x2ef450,_0x41a05c,_0x483490){return db[_0xf6f9('0x6f')]['findAll']({'where':{'id':_0x2ef450[_0xf6f9('0x40')][_0xf6f9('0x80')]},'attributes':['id'],'include':[{'model':db['User'],'as':'Agents','attributes':['id'],'raw':!![]}]})[_0xf6f9('0x2d')](handleEntityNotFound(_0x41a05c,null))[_0xf6f9('0x2d')](function(_0x2eb0aa){var _0x222f85=_[_0xf6f9('0x34')](_0x2eb0aa,'id');var _0x593508=[];var _0x6b696b=[];var _0x2301ea=squel['select']();_0x2301ea[_0xf6f9('0x81')](_0xf6f9('0x82'))[_0xf6f9('0x83')](_0xf6f9('0x84'),'tq')[_0xf6f9('0x85')](_0xf6f9('0x86'),'ut',_0xf6f9('0x87'))[_0xf6f9('0x4a')](_0xf6f9('0x88'),_0x2ef450[_0xf6f9('0x57')]['id']);for(var _0xe1dbc7=0x0;_0xe1dbc7<_0x2eb0aa[_0xf6f9('0x46')];_0xe1dbc7+=0x1){let _0x477113=_0x2eb0aa[_0xe1dbc7];for(var _0x1849af=0x0;_0x1849af<_0x477113[_0xf6f9('0x72')][_0xf6f9('0x46')];_0x1849af+=0x1){let _0x465d88=_0x477113['Agents'][_0x1849af];var _0x494d55=_0x2301ea[_0xf6f9('0x60')]();_0x494d55[_0xf6f9('0x4a')](_0xf6f9('0x89'),_0x465d88['id']);_0x6b696b[_0xf6f9('0x8a')](db[_0xf6f9('0x8b')][_0xf6f9('0x40')](_0x494d55[_0xf6f9('0x8c')](),{'type':db[_0xf6f9('0x8b')][_0xf6f9('0x8d')][_0xf6f9('0x8e')]})[_0xf6f9('0x2d')](function(_0x51aef8){if(_0x51aef8[_0xf6f9('0x46')]===0x1){return _0x465d88['id'];}else{var _0x44c085=_['every'](_[_0xf6f9('0x34')](_0x51aef8,'TeamId'),function(_0x2d5532){return _['includes'](_0x222f85,_0x2d5532);});if(_0x44c085){return _0x465d88['id'];}}}));}}return BPromise[_0xf6f9('0x8f')](_0x6b696b)[_0xf6f9('0x2d')](function(_0x59934e){_0x593508=_(_0x593508)[_0xf6f9('0x90')](_0x59934e)['compact']()[_0xf6f9('0x35')]();return db[_0xf6f9('0x3d')][_0xf6f9('0x38')]({'where':{'id':_0x2ef450[_0xf6f9('0x57')]['id']}})[_0xf6f9('0x2d')](function(_0x15dc46){return db[_0xf6f9('0x8b')][_0xf6f9('0x78')](function(_0x6ad6b5){return _0x15dc46['removeTeams'](_0x2ef450[_0xf6f9('0x40')][_0xf6f9('0x80')],{'transaction':_0x6ad6b5})['then'](function(){if(!_[_0xf6f9('0x91')](_0x593508)){return _0x15dc46['removeAgents'](_0x593508,{'transaction':_0x6ad6b5})[_0xf6f9('0x2d')](function(){return db[_0xf6f9('0x92')][_0xf6f9('0x93')]({'where':{'VoiceQueueId':_0x2ef450[_0xf6f9('0x57')]['id'],'UserId':_0x593508},'transaction':_0x6ad6b5});});}})[_0xf6f9('0x2d')](function(){_0x593508[_0xf6f9('0x76')](function(_0x3b7c23){socket[_0xf6f9('0x7d')](_0xf6f9('0x94'),{'UserId':_0x3b7c23,'VoiceQueueId':_0x15dc46['id']});});});});});});})[_0xf6f9('0x2d')](respondWithStatusCode(_0x41a05c,null))[_0xf6f9('0x55')](handleError(_0x41a05c,null));};exports['addAgents']=function(_0x1182d4,_0x29320b,_0x230011){var _0x574813,_0x551ca2;return db[_0xf6f9('0x3d')][_0xf6f9('0x38')]({'where':{'id':_0x1182d4[_0xf6f9('0x57')]['id']}})['then'](handleEntityNotFound(_0x29320b,null))[_0xf6f9('0x2d')](function(_0xab7a83){if(_0xab7a83){_0x551ca2=_0xab7a83;return _0xab7a83['addAgents'](_0x1182d4[_0xf6f9('0x5a')][_0xf6f9('0x80')],_[_0xf6f9('0x61')](_0x1182d4[_0xf6f9('0x5a')],[_0xf6f9('0x80'),'id'])||{})['spread'](function(_0x14b78c){for(var _0x5800de=0x0;_0x5800de<_0x1182d4[_0xf6f9('0x5a')][_0xf6f9('0x80')][_0xf6f9('0x46')];_0x5800de+=0x1){socket[_0xf6f9('0x7d')](_0xf6f9('0x7e'),{'UserId':_0x1182d4['body'][_0xf6f9('0x80')][_0x5800de],'VoiceQueueId':_0x1182d4[_0xf6f9('0x57')]['id']});}return _0x14b78c;});}})[_0xf6f9('0x2d')](function(_0x3d865f){_0x574813=_0x3d865f||[];if(_0x551ca2){return db[_0xf6f9('0x71')][_0xf6f9('0x53')]({'where':{'id':_0x1182d4[_0xf6f9('0x5a')][_0xf6f9('0x80')]},'attributes':['id',_0xf6f9('0x39'),_0xf6f9('0x95'),_0xf6f9('0x73'),_0xf6f9('0x74')],'raw':!![]});}})[_0xf6f9('0x2d')](function(_0x569b3a){if(!_[_0xf6f9('0x91')](_0x569b3a)){var _0x860c83=[];for(var _0x3555f7=0x0;_0x3555f7<_0x569b3a[_0xf6f9('0x46')];_0x3555f7++){if(_0x569b3a[_0x3555f7][_0xf6f9('0x95')]){_0x860c83[_0xf6f9('0x8a')](db[_0xf6f9('0x92')][_0xf6f9('0x96')]({'membername':_0x569b3a[_0x3555f7][_0xf6f9('0x39')],'UserId':_0x569b3a[_0x3555f7]['id'],'queue_name':_0x551ca2[_0xf6f9('0x39')],'VoiceQueueId':_0x551ca2['id'],'interface':_[_0xf6f9('0x97')](_0x569b3a[_0x3555f7][_0xf6f9('0x74')])?util[_0xf6f9('0x7c')](_0xf6f9('0x98'),_0x569b3a[_0x3555f7]['name']):_0x569b3a[_0x3555f7]['interface'],'paused':_0x569b3a[_0x3555f7]['voicePause']||![],'penalty':_0x1182d4[_0xf6f9('0x5a')][_0xf6f9('0x77')]||0x0}));}}return BPromise['all'](_0x860c83);}})[_0xf6f9('0x2d')](function(){return _0x574813;})[_0xf6f9('0x2d')](respondWithResult(_0x29320b,null))['catch'](handleError(_0x29320b,null));};exports[_0xf6f9('0x99')]=function(_0x3783ea,_0x384961,_0x13f478){return db['VoiceQueue'][_0xf6f9('0x38')]({'where':{'id':_0x3783ea[_0xf6f9('0x57')]['id']}})[_0xf6f9('0x2d')](handleEntityNotFound(_0x384961,null))[_0xf6f9('0x2d')](function(_0x40250f){if(_0x40250f){return _0x40250f[_0xf6f9('0x99')](_0x3783ea[_0xf6f9('0x40')][_0xf6f9('0x80')])[_0xf6f9('0x2d')](function(){if(_['isArray'](_0x3783ea[_0xf6f9('0x40')]['ids'])){for(var _0x37405c=0x0;_0x37405c<_0x3783ea[_0xf6f9('0x40')][_0xf6f9('0x80')][_0xf6f9('0x46')];_0x37405c+=0x1){socket[_0xf6f9('0x7d')](_0xf6f9('0x94'),{'UserId':Number(_0x3783ea[_0xf6f9('0x40')][_0xf6f9('0x80')][_0x37405c]),'VoiceQueueId':Number(_0x3783ea['params']['id'])});}}else{socket[_0xf6f9('0x7d')](_0xf6f9('0x94'),{'UserId':Number(_0x3783ea['query']['ids']),'VoiceQueueId':Number(_0x3783ea[_0xf6f9('0x57')]['id'])});}});}})['then'](function(_0xa1551a){return db[_0xf6f9('0x92')]['destroy']({'where':{'VoiceQueueId':_0x3783ea[_0xf6f9('0x57')]['id'],'UserId':_0x3783ea[_0xf6f9('0x40')][_0xf6f9('0x80')]}})[_0xf6f9('0x2d')](function(){return _0xa1551a;});})[_0xf6f9('0x2d')](respondWithStatusCode(_0x384961,null))['catch'](handleError(_0x384961,null));};exports[_0xf6f9('0x9a')]=function(_0xe2de80,_0x76165c,_0x5cecdb){var _0x8842f8={};var _0x26639e={};var _0x10d96f;var _0x5b77f0;return db['VoiceQueue'][_0xf6f9('0x68')]({'where':{'id':_0xe2de80[_0xf6f9('0x57')]['id']}})[_0xf6f9('0x2d')](handleEntityNotFound(_0x76165c,null))['then'](function(_0x2ace8e){if(_0x2ace8e){_0x10d96f=_0x2ace8e;_0x26639e[_0xf6f9('0x43')]=_['keys'](db[_0xf6f9('0x71')][_0xf6f9('0x58')]);_0x26639e[_0xf6f9('0x40')]=_['keys'](_0xe2de80[_0xf6f9('0x40')]);_0x26639e[_0xf6f9('0x4b')]=_['intersection'](_0x26639e[_0xf6f9('0x43')],_0x26639e['query']);_0x8842f8[_0xf6f9('0x44')]=_[_0xf6f9('0x42')](_0x26639e['model'],qs[_0xf6f9('0x45')](_0xe2de80['query'][_0xf6f9('0x45')]));_0x8842f8['attributes']=_0x8842f8[_0xf6f9('0x44')][_0xf6f9('0x46')]?_0x8842f8[_0xf6f9('0x44')]:_0x26639e[_0xf6f9('0x43')];_0x8842f8[_0xf6f9('0x48')]=qs['sort'](_0xe2de80[_0xf6f9('0x40')]['sort']);_0x8842f8['where']=qs[_0xf6f9('0x4b')](_[_0xf6f9('0x4c')](_0xe2de80[_0xf6f9('0x40')],_0x26639e['filters']));if(_0xe2de80['query'][_0xf6f9('0x4d')]){_0x8842f8[_0xf6f9('0x4a')]=_[_0xf6f9('0x4e')](_0x8842f8[_0xf6f9('0x4a')],{'$or':_[_0xf6f9('0x34')](_0x8842f8['attributes'],function(_0x715bef){var _0x3e7de3={};_0x3e7de3[_0x715bef]={'$like':'%'+_0xe2de80['query']['filter']+'%'};return _0x3e7de3;})});}_0x8842f8=_['merge']({},_0x8842f8,_0xe2de80[_0xf6f9('0x50')]);return _0x10d96f[_0xf6f9('0x9a')](_0x8842f8);}})[_0xf6f9('0x2d')](function(_0x426e6a){if(_0x426e6a){_0x5b77f0=_0x426e6a[_0xf6f9('0x46')];if(!_0xe2de80[_0xf6f9('0x40')][_0xf6f9('0x66')](_0xf6f9('0x47'))){_0x8842f8['limit']=qs[_0xf6f9('0x27')](_0xe2de80[_0xf6f9('0x40')][_0xf6f9('0x27')]);_0x8842f8[_0xf6f9('0x26')]=qs[_0xf6f9('0x26')](_0xe2de80[_0xf6f9('0x40')][_0xf6f9('0x26')]);}return _0x10d96f[_0xf6f9('0x9a')](_0x8842f8);}})[_0xf6f9('0x2d')](function(_0x3b8dc6){if(_0x3b8dc6){return _0x3b8dc6?{'count':_0x5b77f0,'rows':_0x3b8dc6}:null;}})[_0xf6f9('0x2d')](respondWithResult(_0x76165c,null))[_0xf6f9('0x55')](handleError(_0x76165c,null));};exports['getMembers']=function(_0x16ee18,_0x16cc8d,_0x3b0691){var _0x5129eb={};var _0x54c8e7={};var _0x33e419;var _0x1519a4;return db[_0xf6f9('0x3d')]['findOne']({'where':{'id':_0x16ee18[_0xf6f9('0x57')]['id']}})['then'](handleEntityNotFound(_0x16cc8d,null))[_0xf6f9('0x2d')](function(_0x2ce239){if(_0x2ce239){_0x33e419=_0x2ce239;_0x54c8e7['model']=_[_0xf6f9('0x41')](db['UserVoiceQueueRt']['rawAttributes']);_0x54c8e7['query']=_[_0xf6f9('0x41')](_0x16ee18[_0xf6f9('0x40')]);_0x54c8e7[_0xf6f9('0x4b')]=_[_0xf6f9('0x42')](_0x54c8e7[_0xf6f9('0x43')],_0x54c8e7[_0xf6f9('0x40')]);_0x5129eb['attributes']=_[_0xf6f9('0x42')](_0x54c8e7[_0xf6f9('0x43')],qs['fields'](_0x16ee18[_0xf6f9('0x40')][_0xf6f9('0x45')]));_0x5129eb[_0xf6f9('0x44')]=_0x5129eb[_0xf6f9('0x44')]['length']?_0x5129eb['attributes']:_0x54c8e7['model'];_0x5129eb[_0xf6f9('0x48')]=qs['sort'](_0x16ee18[_0xf6f9('0x40')][_0xf6f9('0x49')]);_0x5129eb[_0xf6f9('0x4a')]=qs['filters'](_[_0xf6f9('0x4c')](_0x16ee18['query'],_0x54c8e7[_0xf6f9('0x4b')]));if(_0x16ee18[_0xf6f9('0x40')][_0xf6f9('0x4d')]){_0x5129eb[_0xf6f9('0x4a')]=_[_0xf6f9('0x4e')](_0x5129eb['where'],{'$or':_['map'](_0x5129eb['attributes'],function(_0x548c95){var _0x4f310a={};_0x4f310a[_0x548c95]={'$like':'%'+_0x16ee18[_0xf6f9('0x40')][_0xf6f9('0x4d')]+'%'};return _0x4f310a;})});}_0x5129eb=_[_0xf6f9('0x4e')]({},_0x5129eb,_0x16ee18[_0xf6f9('0x50')]);return _0x33e419[_0xf6f9('0x9b')](_0x5129eb);}})['then'](function(_0x16353c){if(_0x16353c){_0x1519a4=_0x16353c[_0xf6f9('0x46')];if(!_0x16ee18['query'][_0xf6f9('0x66')](_0xf6f9('0x47'))){_0x5129eb[_0xf6f9('0x27')]=qs[_0xf6f9('0x27')](_0x16ee18[_0xf6f9('0x40')][_0xf6f9('0x27')]);_0x5129eb[_0xf6f9('0x26')]=qs[_0xf6f9('0x26')](_0x16ee18[_0xf6f9('0x40')][_0xf6f9('0x26')]);}return _0x33e419[_0xf6f9('0x9b')](_0x5129eb);}})[_0xf6f9('0x2d')](function(_0x428c8d){return _0x428c8d?{'count':_0x1519a4,'rows':_0x428c8d}:null;})[_0xf6f9('0x2d')](respondWithResult(_0x16cc8d,null))['catch'](handleError(_0x16cc8d,null));};exports[_0xf6f9('0x9c')]=function(_0x2d80c0,_0x498378,_0x130947){var _0x51f93b={};var _0x153104={};var _0x3e5b91;var _0x29f3b2;return db[_0xf6f9('0x3d')]['findOne']({'where':{'id':_0x2d80c0[_0xf6f9('0x57')]['id']}})['then'](handleEntityNotFound(_0x498378,null))[_0xf6f9('0x2d')](function(_0x127cc0){if(_0x127cc0){_0x3e5b91=_0x127cc0;_0x153104[_0xf6f9('0x43')]=_['keys'](db[_0xf6f9('0x9d')][_0xf6f9('0x58')]);_0x153104[_0xf6f9('0x40')]=_[_0xf6f9('0x41')](_0x2d80c0[_0xf6f9('0x40')]);_0x153104[_0xf6f9('0x4b')]=_['intersection'](_0x153104[_0xf6f9('0x43')],_0x153104['query']);_0x51f93b[_0xf6f9('0x44')]=_[_0xf6f9('0x42')](_0x153104[_0xf6f9('0x43')],qs[_0xf6f9('0x45')](_0x2d80c0[_0xf6f9('0x40')][_0xf6f9('0x45')]));_0x51f93b[_0xf6f9('0x44')]=_0x51f93b[_0xf6f9('0x44')]['length']?_0x51f93b[_0xf6f9('0x44')]:_0x153104[_0xf6f9('0x43')];_0x51f93b[_0xf6f9('0x48')]=qs['sort'](_0x2d80c0[_0xf6f9('0x40')][_0xf6f9('0x49')]);_0x51f93b['where']=qs[_0xf6f9('0x4b')](_[_0xf6f9('0x4c')](_0x2d80c0[_0xf6f9('0x40')],_0x153104[_0xf6f9('0x4b')]));if(_0x2d80c0[_0xf6f9('0x40')][_0xf6f9('0x4d')]){_0x51f93b[_0xf6f9('0x4a')]=_[_0xf6f9('0x4e')](_0x51f93b[_0xf6f9('0x4a')],{'$or':_[_0xf6f9('0x34')](_0x51f93b[_0xf6f9('0x44')],function(_0x5bbfed){var _0x2f0d17={};_0x2f0d17[_0x5bbfed]={'$like':'%'+_0x2d80c0['query'][_0xf6f9('0x4d')]+'%'};return _0x2f0d17;})});}_0x51f93b=_['merge']({},_0x51f93b,_0x2d80c0[_0xf6f9('0x50')]);return _0x3e5b91['getLists'](_0x51f93b);}})[_0xf6f9('0x2d')](function(_0x1ac48f){if(_0x1ac48f){_0x29f3b2=_0x1ac48f[_0xf6f9('0x46')];if(!_0x2d80c0[_0xf6f9('0x40')][_0xf6f9('0x66')](_0xf6f9('0x47'))){_0x51f93b['limit']=qs[_0xf6f9('0x27')](_0x2d80c0[_0xf6f9('0x40')][_0xf6f9('0x27')]);_0x51f93b['offset']=qs[_0xf6f9('0x26')](_0x2d80c0['query'][_0xf6f9('0x26')]);}return _0x3e5b91[_0xf6f9('0x9c')](_0x51f93b);}})[_0xf6f9('0x2d')](function(_0xe14d90){if(_0xe14d90){return _0xe14d90?{'count':_0x29f3b2,'rows':_0xe14d90}:null;}})[_0xf6f9('0x2d')](respondWithResult(_0x498378,null))[_0xf6f9('0x55')](handleError(_0x498378,null));};exports[_0xf6f9('0x9e')]=function(_0x3bffd2,_0x1f6d7f,_0x236f13){var _0x2f535d,_0x5ab5d1;return db[_0xf6f9('0x3d')][_0xf6f9('0x38')]({'where':{'id':_0x3bffd2['params']['id']}})[_0xf6f9('0x2d')](handleEntityNotFound(_0x1f6d7f,null))[_0xf6f9('0x2d')](function(_0x58cb08){if(_0x58cb08){_0x5ab5d1=_0x58cb08;return _0x58cb08[_0xf6f9('0x9e')](_0x3bffd2[_0xf6f9('0x5a')]['ids'],_['omit'](_0x3bffd2[_0xf6f9('0x5a')],[_0xf6f9('0x80'),'id'])||{});}return null;})[_0xf6f9('0x9f')](function(_0x1dfd50){var _0x2c15e7;_0x2f535d=_0x1dfd50||[];var _0x8c32b7=[];if(_0x1dfd50){for(var _0x5ca6d4=0x0;_0x5ca6d4<_0x1dfd50[_0xf6f9('0x46')];_0x5ca6d4+=0x1){var _0x10f2f3=_0x1dfd50[_0x5ca6d4][_0xf6f9('0x2e')]({'plain':!![]});_0x5ab5d1[_0xf6f9('0xa0')]=_0x3bffd2[_0xf6f9('0x5a')][_0xf6f9('0xa0')]?_0x3bffd2[_0xf6f9('0x5a')][_0xf6f9('0xa0')]:_0x5ab5d1[_0xf6f9('0xa0')];switch(_0x5ab5d1['dialCheckDuplicateType']){case _0xf6f9('0xa1'):_0x2c15e7=squel[_0xf6f9('0xa2')]()[_0xf6f9('0xa3')](_0xf6f9('0xa4'))['fromQuery']([_0xf6f9('0xa5'),_0xf6f9('0xa6'),_0xf6f9('0xa7'),_0xf6f9('0xa8'),_0xf6f9('0x6a'),'createdAt',_0xf6f9('0x62')],squel[_0xf6f9('0xa9')]()[_0xf6f9('0x81')](_0xf6f9('0xa5'),_0xf6f9('0xa5'))['field'](_0xf6f9('0xaa'),_0xf6f9('0xa6'))[_0xf6f9('0x81')]('id',_0xf6f9('0xa7'))[_0xf6f9('0x81')](_0x10f2f3['CmListId']['toString'](),_0xf6f9('0xa8'))[_0xf6f9('0x81')](_0x3bffd2['params']['id'][_0xf6f9('0x8c')](),'VoiceQueueId')[_0xf6f9('0x81')](_0xf6f9('0xaa'),_0xf6f9('0x63'))[_0xf6f9('0x81')]('NOW()',_0xf6f9('0x62'))[_0xf6f9('0x83')]('cm_contacts')[_0xf6f9('0x4a')](_0xf6f9('0xab'))[_0xf6f9('0x4a')](_0xf6f9('0xac'),_0x10f2f3[_0xf6f9('0xad')][_0xf6f9('0x8c')]())[_0xf6f9('0x4a')](_0xf6f9('0xae'))['where'](_0xf6f9('0xaf'),squel[_0xf6f9('0xa9')]()[_0xf6f9('0x81')](_0xf6f9('0xb0'))[_0xf6f9('0x83')](_0xf6f9('0xb1'))[_0xf6f9('0x4a')]('VoiceQueueId\x20=\x20?',_0x3bffd2[_0xf6f9('0x57')]['id'][_0xf6f9('0x8c')]()))[_0xf6f9('0x4a')](_0xf6f9('0xaf'),squel[_0xf6f9('0xa9')]()['field'](_0xf6f9('0xb2'))[_0xf6f9('0x83')](_0xf6f9('0xa4'))[_0xf6f9('0x4a')](_0xf6f9('0x88'),_0x3bffd2[_0xf6f9('0x57')]['id'][_0xf6f9('0x8c')]())))[_0xf6f9('0x8c')]();break;case _0xf6f9('0xb3'):_0x2c15e7=squel[_0xf6f9('0xa2')]()[_0xf6f9('0xa3')](_0xf6f9('0xa4'))[_0xf6f9('0xb4')]([_0xf6f9('0xa5'),_0xf6f9('0xa6'),_0xf6f9('0xa7'),'ListId',_0xf6f9('0x6a'),_0xf6f9('0x63'),'updatedAt'],squel[_0xf6f9('0xa9')]()[_0xf6f9('0x81')](_0xf6f9('0xa5'),'phone')['field']('NOW()',_0xf6f9('0xa6'))['field']('id',_0xf6f9('0xa7'))['field'](_0x10f2f3[_0xf6f9('0xad')][_0xf6f9('0x8c')](),_0xf6f9('0xa8'))[_0xf6f9('0x81')](_0x3bffd2[_0xf6f9('0x57')]['id'][_0xf6f9('0x8c')](),'VoiceQueueId')['field'](_0xf6f9('0xaa'),_0xf6f9('0x63'))[_0xf6f9('0x81')]('NOW()',_0xf6f9('0x62'))[_0xf6f9('0x83')](_0xf6f9('0xb5'))['where'](_0xf6f9('0xab'))[_0xf6f9('0x4a')](_0xf6f9('0xac'),_0x10f2f3[_0xf6f9('0xad')][_0xf6f9('0x8c')]())[_0xf6f9('0x4a')](_0xf6f9('0xae'))[_0xf6f9('0x4a')](_0xf6f9('0xaf'),squel[_0xf6f9('0xa9')]()[_0xf6f9('0x81')](_0xf6f9('0xb2'))[_0xf6f9('0x83')](_0xf6f9('0xa4'))[_0xf6f9('0x4a')](_0xf6f9('0x88'),_0x3bffd2[_0xf6f9('0x57')]['id'][_0xf6f9('0x8c')]())))[_0xf6f9('0x8c')]();break;default:_0x2c15e7=squel[_0xf6f9('0xa2')]()['into'](_0xf6f9('0xa4'))[_0xf6f9('0xb4')](['phone',_0xf6f9('0xa6'),_0xf6f9('0xa7'),_0xf6f9('0xa8'),_0xf6f9('0x6a'),_0xf6f9('0x63'),_0xf6f9('0x62')],squel['select']()[_0xf6f9('0x81')]('phone',_0xf6f9('0xa5'))[_0xf6f9('0x81')](_0xf6f9('0xaa'),_0xf6f9('0xa6'))[_0xf6f9('0x81')]('id',_0xf6f9('0xa7'))[_0xf6f9('0x81')](_0x10f2f3[_0xf6f9('0xad')]['toString'](),'ListId')['field'](_0x3bffd2['params']['id'][_0xf6f9('0x8c')](),_0xf6f9('0x6a'))[_0xf6f9('0x81')](_0xf6f9('0xaa'),_0xf6f9('0x63'))[_0xf6f9('0x81')](_0xf6f9('0xaa'),_0xf6f9('0x62'))[_0xf6f9('0x83')](_0xf6f9('0xb5'))[_0xf6f9('0x4a')](_0xf6f9('0xab'))[_0xf6f9('0x4a')]('ListId\x20=\x20?',_0x10f2f3[_0xf6f9('0xad')][_0xf6f9('0x8c')]())[_0xf6f9('0x4a')]('phone\x20IS\x20NOT\x20NULL'))[_0xf6f9('0x8c')]();}_0x8c32b7[_0xf6f9('0x8a')](db['sequelize'][_0xf6f9('0x40')](_0x2c15e7));}return BPromise[_0xf6f9('0x8f')](_0x8c32b7);}})[_0xf6f9('0x2d')](function(){return _0x2f535d;})[_0xf6f9('0x2d')](respondWithResult(_0x1f6d7f,null))['catch'](handleError(_0x1f6d7f,null));};exports[_0xf6f9('0xb6')]=function(_0xaf43ca,_0x41db3e,_0x4581c3){return db['VoiceQueue'][_0xf6f9('0x38')]({'where':{'id':_0xaf43ca['params']['id']}})[_0xf6f9('0x2d')](handleEntityNotFound(_0x41db3e,null))[_0xf6f9('0x2d')](function(_0x13bc1e){if(_0x13bc1e){return _0x13bc1e[_0xf6f9('0xb6')](_0xaf43ca[_0xf6f9('0x40')][_0xf6f9('0x80')]);}})[_0xf6f9('0x2d')](function(_0x575f90){if(_0x575f90){return db[_0xf6f9('0x65')][_0xf6f9('0x93')]({'where':{'ListId':_0xaf43ca[_0xf6f9('0x40')][_0xf6f9('0x80')],'VoiceQueueId':_0xaf43ca[_0xf6f9('0x57')]['id']}})[_0xf6f9('0x2d')](function(){return _0x575f90;});}})[_0xf6f9('0x2d')](respondWithStatusCode(_0x41db3e,null))[_0xf6f9('0x55')](handleError(_0x41db3e,null));};exports[_0xf6f9('0xb7')]=function(_0x1ca209,_0x163821,_0x5ad514){var _0x5c0c1e={};var _0x3db9b4={};var _0x3024f9;var _0xbc2462;return db[_0xf6f9('0x3d')][_0xf6f9('0x68')]({'where':{'id':_0x1ca209['params']['id']}})['then'](handleEntityNotFound(_0x163821,null))[_0xf6f9('0x2d')](function(_0x2b9a5c){if(_0x2b9a5c){_0x3024f9=_0x2b9a5c;_0x3db9b4[_0xf6f9('0x43')]=_[_0xf6f9('0x41')](db[_0xf6f9('0x9d')][_0xf6f9('0x58')]);_0x3db9b4[_0xf6f9('0x40')]=_[_0xf6f9('0x41')](_0x1ca209['query']);_0x3db9b4['filters']=_['intersection'](_0x3db9b4['model'],_0x3db9b4[_0xf6f9('0x40')]);_0x5c0c1e[_0xf6f9('0x44')]=_[_0xf6f9('0x42')](_0x3db9b4[_0xf6f9('0x43')],qs[_0xf6f9('0x45')](_0x1ca209[_0xf6f9('0x40')][_0xf6f9('0x45')]));_0x5c0c1e[_0xf6f9('0x44')]=_0x5c0c1e[_0xf6f9('0x44')][_0xf6f9('0x46')]?_0x5c0c1e['attributes']:_0x3db9b4[_0xf6f9('0x43')];_0x5c0c1e[_0xf6f9('0x48')]=qs['sort'](_0x1ca209[_0xf6f9('0x40')][_0xf6f9('0x49')]);_0x5c0c1e[_0xf6f9('0x4a')]=qs['filters'](_[_0xf6f9('0x4c')](_0x1ca209['query'],_0x3db9b4[_0xf6f9('0x4b')]));if(_0x1ca209[_0xf6f9('0x40')][_0xf6f9('0x4d')]){_0x5c0c1e[_0xf6f9('0x4a')]=_[_0xf6f9('0x4e')](_0x5c0c1e[_0xf6f9('0x4a')],{'$or':_[_0xf6f9('0x34')](_0x5c0c1e[_0xf6f9('0x44')],function(_0x53df10){var _0x4b1907={};_0x4b1907[_0x53df10]={'$like':'%'+_0x1ca209[_0xf6f9('0x40')][_0xf6f9('0x4d')]+'%'};return _0x4b1907;})});}_0x5c0c1e=_[_0xf6f9('0x4e')]({},_0x5c0c1e,_0x1ca209[_0xf6f9('0x50')]);return _0x3024f9['getBlackLists'](_0x5c0c1e);}})[_0xf6f9('0x2d')](function(_0x2bcd98){if(_0x2bcd98){_0xbc2462=_0x2bcd98['length'];if(!_0x1ca209[_0xf6f9('0x40')]['hasOwnProperty'](_0xf6f9('0x47'))){_0x5c0c1e['limit']=qs[_0xf6f9('0x27')](_0x1ca209['query'][_0xf6f9('0x27')]);_0x5c0c1e[_0xf6f9('0x26')]=qs['offset'](_0x1ca209[_0xf6f9('0x40')]['offset']);}return _0x3024f9[_0xf6f9('0xb7')](_0x5c0c1e);}})[_0xf6f9('0x2d')](function(_0x586d29){if(_0x586d29){return _0x586d29?{'count':_0xbc2462,'rows':_0x586d29}:null;}})[_0xf6f9('0x2d')](respondWithResult(_0x163821,null))[_0xf6f9('0x55')](handleError(_0x163821,null));};exports[_0xf6f9('0xb8')]=function(_0x157791,_0x29bdf3,_0x4a78d5){var _0xadb722,_0x5c852f;return db[_0xf6f9('0x3d')][_0xf6f9('0x38')]({'where':{'id':_0x157791[_0xf6f9('0x57')]['id']}})['then'](handleEntityNotFound(_0x29bdf3,null))['then'](function(_0x1535fb){if(_0x1535fb){_0x5c852f=_0x1535fb;return _0x1535fb['addBlackLists'](_0x157791[_0xf6f9('0x5a')][_0xf6f9('0x80')],_[_0xf6f9('0x61')](_0x157791[_0xf6f9('0x5a')],[_0xf6f9('0x80'),'id'])||{});}return null;})[_0xf6f9('0x9f')](function(_0x1aa070){var _0x51b8bb;_0xadb722=_0x1aa070||[];var _0x5cf0e2=[];if(_0x1aa070){for(var _0x3aeb21=0x0;_0x3aeb21<_0x1aa070['length'];_0x3aeb21+=0x1){var _0x228a98=_0x1aa070[_0x3aeb21][_0xf6f9('0x2e')]({'plain':!![]});_0x51b8bb=squel['insert']()['into'](_0xf6f9('0xb9'))[_0xf6f9('0xb4')]([_0xf6f9('0xa5'),_0xf6f9('0xa7'),_0xf6f9('0xa8'),_0xf6f9('0x6a'),_0xf6f9('0x63'),_0xf6f9('0x62')],squel[_0xf6f9('0xa9')]()['field'](_0xf6f9('0xa5'),_0xf6f9('0xa5'))[_0xf6f9('0x81')]('id','ContactId')[_0xf6f9('0x81')](_0x228a98[_0xf6f9('0xad')][_0xf6f9('0x8c')](),_0xf6f9('0xa8'))['field'](_0x157791['params']['id'][_0xf6f9('0x8c')](),_0xf6f9('0x6a'))[_0xf6f9('0x81')](_0xf6f9('0xaa'),_0xf6f9('0x63'))[_0xf6f9('0x81')](_0xf6f9('0xaa'),_0xf6f9('0x62'))[_0xf6f9('0x83')](_0xf6f9('0xb5'))[_0xf6f9('0x4a')](_0xf6f9('0xab'))[_0xf6f9('0x4a')](_0xf6f9('0xac'),_0x228a98[_0xf6f9('0xad')][_0xf6f9('0x8c')]())[_0xf6f9('0x4a')](_0xf6f9('0xae')))[_0xf6f9('0x8c')]();_0x5cf0e2[_0xf6f9('0x8a')](db[_0xf6f9('0x8b')][_0xf6f9('0x40')](_0x51b8bb));}return BPromise[_0xf6f9('0x8f')](_0x5cf0e2);}})[_0xf6f9('0x2d')](function(){return _0xadb722;})[_0xf6f9('0x2d')](respondWithResult(_0x29bdf3,null))['catch'](handleError(_0x29bdf3,null));};exports['removeBlackLists']=function(_0x2bb463,_0x17cea4,_0x352a7b){return db[_0xf6f9('0x3d')]['find']({'where':{'id':_0x2bb463['params']['id']}})[_0xf6f9('0x2d')](handleEntityNotFound(_0x17cea4,null))[_0xf6f9('0x2d')](function(_0x588c2b){if(_0x588c2b){return _0x588c2b[_0xf6f9('0xba')](_0x2bb463[_0xf6f9('0x40')]['ids']);}})[_0xf6f9('0x2d')](function(_0x4159a7){if(_0x4159a7){return db[_0xf6f9('0x6d')]['destroy']({'where':{'ListId':_0x2bb463[_0xf6f9('0x40')][_0xf6f9('0x80')],'VoiceQueueId':_0x2bb463[_0xf6f9('0x57')]['id']}})[_0xf6f9('0x2d')](function(){return _0x4159a7;});}})[_0xf6f9('0x2d')](respondWithStatusCode(_0x17cea4,null))[_0xf6f9('0x55')](handleError(_0x17cea4,null));};