67d593ea3f5e2bbd2519941b3576e093ba1e7cfb
[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 _0x5b4b=['format','all','isArray','getAgents','getMembers','CmList','getLists','addLists','dialCheckDuplicateType','always','cm_hopper','phone','scheduledAt','ContactId','ListId','NOW()','CmListId','ListId\x20=\x20?','phone\x20IS\x20NOT\x20NULL','COALESCE(calleridnum,\x27\x27)','from','VoiceQueueId\x20=\x20?','phone\x20NOT\x20IN\x20(?)','COALESCE(phone,\x27\x27)','onlyIfOpen','insert','into','fromQuery','cm_contacts','removeLists','getBlackLists','addBlackLists','cm_hopper_black','removeBlackLists','zip-dir','fast-json-patch','request-promise','bluebird','util','sox','to-csv','ejs','lodash','crypto','desk.js','querystring','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','defaults','socket.io-emitter','./voiceQueue.socket','register','sendStatus','status','json','offset','undefined','limit','count','set','Content-Range','apply','reject','save','update','destroy','then','get','VoiceQueues','inbound','QueueCampaigns','outbound','filter','map','value','find','type','UserProfileResource','end','error','name','send','index','rawAttributes','fieldName','key','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','pick','where','merge','VoiceQueue','include','findAll','rows','show','params','includeAll','options','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','userProfileId','autoAssociation','catch','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','clone','omit','updatedAt','createdAt','role','UserProfileSection','findOne','CmHopper','VoiceQueueId','getHopperHistories','CmHopperHistory','getHopperFinals','CmHopperFinal','CmHopperBlack','getTeams','Team','teams','User','Agents','online','voicePause','interface','flatMap','forEach','penalty','sequelize','transaction','addTeams','each','TeamVoiceQueue','findOrCreate','UserVoiceQueueRt','upsert','isNil','SIP/%s','emit','userVoiceQueue:save','removeTeams','ids','select','field','join','user_has_teams','ut.TeamId\x20=\x20tq.TeamId','ut.UserId\x20=\x20?','push','toString','QueryTypes','SELECT','every','TeamId','includes','union','isEmpty','removeAgents','userVoiceQueue:remove','addAgents','spread'];(function(_0x4100e7,_0x4e2876){var _0x3ac3c6=function(_0x581ee6){while(--_0x581ee6){_0x4100e7['push'](_0x4100e7['shift']());}};_0x3ac3c6(++_0x4e2876);}(_0x5b4b,0xdb));var _0xb5b4=function(_0x170bba,_0x2be92f){_0x170bba=_0x170bba-0x0;var _0xa7c249=_0x5b4b[_0x170bba];return _0xa7c249;};'use strict';var emlformat=require('eml-format');var rimraf=require('rimraf');var zipdir=require(_0xb5b4('0x0'));var jsonpatch=require(_0xb5b4('0x1'));var rp=require(_0xb5b4('0x2'));var moment=require('moment');var BPromise=require(_0xb5b4('0x3'));var Mustache=require('mustache');var util=require(_0xb5b4('0x4'));var path=require('path');var sox=require(_0xb5b4('0x5'));var csv=require(_0xb5b4('0x6'));var ejs=require(_0xb5b4('0x7'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0xb5b4('0x8'));var squel=require('squel');var crypto=require(_0xb5b4('0x9'));var jsforce=require('jsforce');var deskjs=require(_0xb5b4('0xa'));var toCsv=require(_0xb5b4('0x6'));var querystring=require(_0xb5b4('0xb'));var Papa=require(_0xb5b4('0xc'));var Redis=require(_0xb5b4('0xd'));var authService=require('../../components/auth/service');var qs=require(_0xb5b4('0xe'));var as=require(_0xb5b4('0xf'));var hardwareService=require(_0xb5b4('0x10'));var logger=require(_0xb5b4('0x11'))(_0xb5b4('0x12'));var utils=require(_0xb5b4('0x13'));var config=require(_0xb5b4('0x14'));var licenseUtil=require(_0xb5b4('0x15'));var db=require(_0xb5b4('0x16'))['db'];config[_0xb5b4('0x17')]=_[_0xb5b4('0x18')](config[_0xb5b4('0x17')],{'host':'localhost','port':0x18eb});var socket=require(_0xb5b4('0x19'))(new Redis(config[_0xb5b4('0x17')]));require(_0xb5b4('0x1a'))[_0xb5b4('0x1b')](socket);function respondWithStatusCode(_0x47d70c,_0x487da4){_0x487da4=_0x487da4||0xcc;return function(_0xfe3cfe){if(_0xfe3cfe){return _0x47d70c[_0xb5b4('0x1c')](_0x487da4);}return _0x47d70c[_0xb5b4('0x1d')](_0x487da4)['end']();};}function respondWithResult(_0x3c6fa8,_0x197972){_0x197972=_0x197972||0xc8;return function(_0x25b2f5){if(_0x25b2f5){return _0x3c6fa8['status'](_0x197972)[_0xb5b4('0x1e')](_0x25b2f5);}};}function respondWithFilteredResult(_0x21cf26,_0x2989b5){return function(_0x3bb096){if(_0x3bb096){var _0x57d978=typeof _0x2989b5[_0xb5b4('0x1f')]===_0xb5b4('0x20')&&typeof _0x2989b5[_0xb5b4('0x21')]==='undefined';var _0x43d0c3=_0x3bb096[_0xb5b4('0x22')];var _0x23d89a=_0x57d978?0x0:_0x2989b5[_0xb5b4('0x1f')];var _0x5251d8=_0x57d978?_0x3bb096['count']:_0x2989b5[_0xb5b4('0x1f')]+_0x2989b5[_0xb5b4('0x21')];var _0x3bc109;if(_0x5251d8>=_0x43d0c3){_0x5251d8=_0x43d0c3;_0x3bc109=0xc8;}else{_0x3bc109=0xce;}_0x21cf26['status'](_0x3bc109);return _0x21cf26[_0xb5b4('0x23')](_0xb5b4('0x24'),_0x23d89a+'-'+_0x5251d8+'/'+_0x43d0c3)[_0xb5b4('0x1e')](_0x3bb096);}return null;};}function patchUpdates(_0x2cdb43){return function(_0x665eda){try{jsonpatch[_0xb5b4('0x25')](_0x665eda,_0x2cdb43,!![]);}catch(_0x4c17df){return BPromise[_0xb5b4('0x26')](_0x4c17df);}return _0x665eda[_0xb5b4('0x27')]();};}function saveUpdates(_0x541801,_0x324e79){return function(_0x2b343c){if(_0x2b343c){return _0x2b343c[_0xb5b4('0x28')](_0x541801)['then'](function(_0x4f7c6e){return _0x4f7c6e;});}return null;};}function removeEntity(_0x43b63b,_0x5282ac){return function(_0xa42fdc){if(_0xa42fdc){return _0xa42fdc[_0xb5b4('0x29')]()[_0xb5b4('0x2a')](function(){var _0x47cbab=_0xa42fdc[_0xb5b4('0x2b')]({'plain':!![]});var _0x5e91fc=[{'name':_0xb5b4('0x2c'),'value':_0xb5b4('0x2d'),'ignore':![]},{'name':_0xb5b4('0x2e'),'value':_0xb5b4('0x2f'),'ignore':![]}];var _0x36b2ee=_(_0x5e91fc)[_0xb5b4('0x30')]('ignore')[_0xb5b4('0x31')](_0xb5b4('0x32'))[_0xb5b4('0x32')]();if(_['includes'](_0x36b2ee,_0x47cbab['type'])){return;}var _0x2a23e7=_[_0xb5b4('0x33')](_0x5e91fc,[_0xb5b4('0x32'),_0x47cbab[_0xb5b4('0x34')]])['name'];return db[_0xb5b4('0x35')][_0xb5b4('0x29')]({'where':{'type':_0x2a23e7,'resourceId':_0x47cbab['id']}})['then'](function(){return _0xa42fdc;});})[_0xb5b4('0x2a')](function(){_0x43b63b['status'](0xcc)[_0xb5b4('0x36')]();});}};}function handleEntityNotFound(_0x179dc3,_0x41b78c){return function(_0x165bd6){if(!_0x165bd6){_0x179dc3[_0xb5b4('0x1c')](0x194);}return _0x165bd6;};}function handleError(_0x160ec4,_0x5be37f){_0x5be37f=_0x5be37f||0x1f4;return function(_0x3d8b1b){logger[_0xb5b4('0x37')](_0x3d8b1b['stack']);if(_0x3d8b1b[_0xb5b4('0x38')]){delete _0x3d8b1b[_0xb5b4('0x38')];}_0x160ec4['status'](_0x5be37f)[_0xb5b4('0x39')](_0x3d8b1b);};}exports[_0xb5b4('0x3a')]=function(_0x3784d7,_0x4f41ee){var _0x5dbbc4={},_0x35b4c0={},_0x33a079={'count':0x0,'rows':[]};var _0x54a27d=_[_0xb5b4('0x31')](db['VoiceQueue'][_0xb5b4('0x3b')],function(_0x51330a){return{'name':_0x51330a[_0xb5b4('0x3c')],'type':_0x51330a[_0xb5b4('0x34')][_0xb5b4('0x3d')]};});_0x35b4c0[_0xb5b4('0x3e')]=_[_0xb5b4('0x31')](_0x54a27d,_0xb5b4('0x38'));_0x35b4c0[_0xb5b4('0x3f')]=_[_0xb5b4('0x40')](_0x3784d7[_0xb5b4('0x3f')]);_0x35b4c0[_0xb5b4('0x41')]=_[_0xb5b4('0x42')](_0x35b4c0[_0xb5b4('0x3e')],_0x35b4c0[_0xb5b4('0x3f')]);_0x5dbbc4[_0xb5b4('0x43')]=_[_0xb5b4('0x42')](_0x35b4c0[_0xb5b4('0x3e')],qs['fields'](_0x3784d7[_0xb5b4('0x3f')][_0xb5b4('0x44')]));_0x5dbbc4[_0xb5b4('0x43')]=_0x5dbbc4[_0xb5b4('0x43')][_0xb5b4('0x45')]?_0x5dbbc4['attributes']:_0x35b4c0[_0xb5b4('0x3e')];if(!_0x3784d7[_0xb5b4('0x3f')][_0xb5b4('0x46')](_0xb5b4('0x47'))){_0x5dbbc4[_0xb5b4('0x21')]=qs[_0xb5b4('0x21')](_0x3784d7['query'][_0xb5b4('0x21')]);_0x5dbbc4[_0xb5b4('0x1f')]=qs[_0xb5b4('0x1f')](_0x3784d7['query']['offset']);}_0x5dbbc4[_0xb5b4('0x48')]=qs[_0xb5b4('0x49')](_0x3784d7['query'][_0xb5b4('0x49')]);_0x5dbbc4['where']=qs[_0xb5b4('0x41')](_[_0xb5b4('0x4a')](_0x3784d7[_0xb5b4('0x3f')],_0x35b4c0[_0xb5b4('0x41')]),_0x54a27d);if(_0x3784d7['query'][_0xb5b4('0x30')]){_0x5dbbc4[_0xb5b4('0x4b')]=_[_0xb5b4('0x4c')](_0x5dbbc4[_0xb5b4('0x4b')],{'$or':_[_0xb5b4('0x31')](_0x54a27d,function(_0x1cefbf){if(_0x1cefbf['type']!=='VIRTUAL'){var _0x41af86={};_0x41af86[_0x1cefbf['name']]={'$like':'%'+_0x3784d7[_0xb5b4('0x3f')]['filter']+'%'};return _0x41af86;}})});}_0x5dbbc4=_['merge']({},_0x5dbbc4,_0x3784d7['options']);var _0x25a9b0={'where':_0x5dbbc4[_0xb5b4('0x4b')]};return db[_0xb5b4('0x4d')][_0xb5b4('0x22')](_0x25a9b0)[_0xb5b4('0x2a')](function(_0x5f4f2a){_0x33a079[_0xb5b4('0x22')]=_0x5f4f2a;if(_0x3784d7[_0xb5b4('0x3f')]['includeAll']){_0x5dbbc4[_0xb5b4('0x4e')]=[{'all':!![]}];}return db[_0xb5b4('0x4d')][_0xb5b4('0x4f')](_0x5dbbc4);})[_0xb5b4('0x2a')](function(_0x27d1ca){_0x33a079[_0xb5b4('0x50')]=_0x27d1ca;return _0x33a079;})['then'](respondWithFilteredResult(_0x4f41ee,_0x5dbbc4))['catch'](handleError(_0x4f41ee,null));};exports[_0xb5b4('0x51')]=function(_0x1cd7d3,_0x42dde0){var _0x3e3dd6={'raw':![],'where':{'id':_0x1cd7d3[_0xb5b4('0x52')]['id']}},_0x16977d={};_0x16977d[_0xb5b4('0x3e')]=_[_0xb5b4('0x40')](db[_0xb5b4('0x4d')][_0xb5b4('0x3b')]);_0x16977d[_0xb5b4('0x3f')]=_[_0xb5b4('0x40')](_0x1cd7d3[_0xb5b4('0x3f')]);_0x16977d[_0xb5b4('0x41')]=_['intersection'](_0x16977d['model'],_0x16977d[_0xb5b4('0x3f')]);_0x3e3dd6[_0xb5b4('0x43')]=_[_0xb5b4('0x42')](_0x16977d[_0xb5b4('0x3e')],qs['fields'](_0x1cd7d3[_0xb5b4('0x3f')]['fields']));_0x3e3dd6[_0xb5b4('0x43')]=_0x3e3dd6[_0xb5b4('0x43')]['length']?_0x3e3dd6['attributes']:_0x16977d[_0xb5b4('0x3e')];if(_0x1cd7d3[_0xb5b4('0x3f')][_0xb5b4('0x53')]){_0x3e3dd6[_0xb5b4('0x4e')]=[{'all':!![]}];}_0x3e3dd6=_['merge']({},_0x3e3dd6,_0x1cd7d3[_0xb5b4('0x54')]);return db[_0xb5b4('0x4d')][_0xb5b4('0x33')](_0x3e3dd6)[_0xb5b4('0x2a')](handleEntityNotFound(_0x42dde0,null))['then'](respondWithResult(_0x42dde0,null))['catch'](handleError(_0x42dde0,null));};exports[_0xb5b4('0x55')]=function(_0x30a2d5,_0x45a473){return db[_0xb5b4('0x4d')]['create'](_0x30a2d5[_0xb5b4('0x56')],{})[_0xb5b4('0x2a')](function(_0x54c402){var _0x565451=_0x30a2d5[_0xb5b4('0x57')]['get']({'plain':!![]});if(!_0x565451)throw new Error(_0xb5b4('0x58'));if(_0x565451['role']===_0xb5b4('0x57')){var _0x4c1fc4=_0x54c402[_0xb5b4('0x2b')]({'plain':!![]});var _0x521324=[{'name':_0xb5b4('0x2c'),'value':_0xb5b4('0x2d')},{'name':'QueueCampaigns','value':'outbound'}];var _0x2d0781=_[_0xb5b4('0x33')](_0x521324,[_0xb5b4('0x32'),_0x4c1fc4['type']])[_0xb5b4('0x38')];return db['UserProfileSection'][_0xb5b4('0x33')]({'where':{'name':_0x2d0781,'userProfileId':_0x565451[_0xb5b4('0x59')]},'raw':!![]})[_0xb5b4('0x2a')](function(_0x49e2b1){if(_0x49e2b1&&_0x49e2b1[_0xb5b4('0x5a')]===0x0){return db['UserProfileResource'][_0xb5b4('0x55')]({'name':_0x4c1fc4['name'],'resourceId':_0x4c1fc4['id'],'type':_0x49e2b1[_0xb5b4('0x38')],'sectionId':_0x49e2b1['id']},{})[_0xb5b4('0x2a')](function(){return _0x54c402;});}else{return _0x54c402;}})[_0xb5b4('0x5b')](function(_0x3bac36){logger[_0xb5b4('0x37')](_0xb5b4('0x5c'),_0x3bac36);throw _0x3bac36;});}return _0x54c402;})['then'](respondWithResult(_0x45a473,0xc9))[_0xb5b4('0x5b')](handleError(_0x45a473,null));};exports[_0xb5b4('0x5d')]=function(_0x4cfa33,_0x5bc345){var _0x2957ee={'where':{'id':_0x4cfa33['params']['id']}},_0x5e67bb={};_0x5e67bb['model']=_[_0xb5b4('0x40')](db[_0xb5b4('0x4d')][_0xb5b4('0x3b')]);_0x2957ee[_0xb5b4('0x43')]=_['intersection'](_0x5e67bb[_0xb5b4('0x3e')],qs['fields'](_0x4cfa33[_0xb5b4('0x3f')]['fields']));_0x2957ee[_0xb5b4('0x43')]=_0x2957ee['attributes'][_0xb5b4('0x45')]?_0x2957ee[_0xb5b4('0x43')]:_0x5e67bb[_0xb5b4('0x3e')];if(_0x4cfa33['query'][_0xb5b4('0x53')]){_0x2957ee['include']=[{'all':!![]}];}_0x2957ee=_[_0xb5b4('0x4c')]({},_0x2957ee,_0x4cfa33[_0xb5b4('0x54')]);return db[_0xb5b4('0x4d')]['find'](_0x2957ee)[_0xb5b4('0x2a')](handleEntityNotFound(_0x5bc345,null))[_0xb5b4('0x2a')](function(_0x336c19){if(_0x336c19){var _0x9fdead=_0x336c19[_0xb5b4('0x2b')]({'plain':!![]});_0x9fdead=qs[_0xb5b4('0x5e')](_0x9fdead,['id','createdAt',_0xb5b4('0x5f')]);_0x4cfa33[_0xb5b4('0x56')]=_[_0xb5b4('0x5e')](_0x4cfa33['body'],['id',_0xb5b4('0x60'),_0xb5b4('0x5f')]);return db['VoiceQueue']['create'](_[_0xb5b4('0x4c')](_0x9fdead,_0x4cfa33['body']),{'include':_0x4cfa33[_0xb5b4('0x3f')][_0xb5b4('0x53')]?[{'all':!![]}]:undefined})['then'](function(_0x370b33){var _0x5d7e3a=_0x4cfa33[_0xb5b4('0x57')][_0xb5b4('0x2b')]({'plain':!![]});if(!_0x5d7e3a)throw new Error(_0xb5b4('0x58'));if(_0x5d7e3a[_0xb5b4('0x61')]==='user'){var _0x539cd7=_0x370b33['get']({'plain':!![]});var _0x110c17=[{'name':'VoiceQueues','value':_0xb5b4('0x2d')},{'name':_0xb5b4('0x2e'),'value':'outbound'}];var _0x3eb971=_[_0xb5b4('0x33')](_0x110c17,[_0xb5b4('0x32'),_0x539cd7[_0xb5b4('0x34')]])[_0xb5b4('0x38')];return db[_0xb5b4('0x62')]['find']({'where':{'name':_0x3eb971,'userProfileId':_0x5d7e3a[_0xb5b4('0x59')]},'raw':!![]})['then'](function(_0x24b6b0){if(_0x24b6b0&&_0x24b6b0[_0xb5b4('0x5a')]===0x0){return db[_0xb5b4('0x35')][_0xb5b4('0x55')]({'name':_0x539cd7[_0xb5b4('0x38')],'resourceId':_0x539cd7['id'],'type':_0x24b6b0['name'],'sectionId':_0x24b6b0['id']},{})[_0xb5b4('0x2a')](function(){return _0x370b33;});}else{return _0x370b33;}})[_0xb5b4('0x5b')](function(_0x3546d9){logger[_0xb5b4('0x37')](_0xb5b4('0x5c'),_0x3546d9);throw _0x3546d9;});}return _0x370b33;});}})[_0xb5b4('0x2a')](respondWithResult(_0x5bc345,0xc9))['catch'](handleError(_0x5bc345,null));};exports[_0xb5b4('0x28')]=function(_0x561065,_0xebec09){if(_0x561065[_0xb5b4('0x56')]['id']){delete _0x561065['body']['id'];}return db['VoiceQueue'][_0xb5b4('0x33')]({'where':{'id':_0x561065[_0xb5b4('0x52')]['id']}})[_0xb5b4('0x2a')](handleEntityNotFound(_0xebec09,null))['then'](saveUpdates(_0x561065[_0xb5b4('0x56')],null))[_0xb5b4('0x2a')](respondWithResult(_0xebec09,null))['catch'](handleError(_0xebec09,null));};exports[_0xb5b4('0x29')]=function(_0x16ee61,_0x888bd7){return db['VoiceQueue'][_0xb5b4('0x33')]({'where':{'id':_0x16ee61[_0xb5b4('0x52')]['id']}})[_0xb5b4('0x2a')](handleEntityNotFound(_0x888bd7,null))['then'](removeEntity(_0x888bd7,null))[_0xb5b4('0x5b')](handleError(_0x888bd7,null));};exports['getHoppers']=function(_0x2034e6,_0xb7e8b1,_0x35c90f){var _0xb44bca={'raw':![],'where':{}};var _0x3a00eb={};var _0x10bf1f={'count':0x0,'rows':[]};return db[_0xb5b4('0x4d')][_0xb5b4('0x63')]({'where':{'id':_0x2034e6[_0xb5b4('0x52')]['id']}})[_0xb5b4('0x2a')](handleEntityNotFound(_0xb7e8b1,null))[_0xb5b4('0x2a')](function(_0x125568){if(_0x125568){_0x3a00eb[_0xb5b4('0x3e')]=_[_0xb5b4('0x40')](db[_0xb5b4('0x64')][_0xb5b4('0x3b')]);_0x3a00eb['query']=_[_0xb5b4('0x40')](_0x2034e6[_0xb5b4('0x3f')]);_0x3a00eb['filters']=_[_0xb5b4('0x42')](_0x3a00eb[_0xb5b4('0x3e')],_0x3a00eb[_0xb5b4('0x3f')]);_0xb44bca[_0xb5b4('0x43')]=_[_0xb5b4('0x42')](_0x3a00eb[_0xb5b4('0x3e')],qs[_0xb5b4('0x44')](_0x2034e6[_0xb5b4('0x3f')][_0xb5b4('0x44')]));_0xb44bca[_0xb5b4('0x43')]=_0xb44bca[_0xb5b4('0x43')]['length']?_0xb44bca[_0xb5b4('0x43')]:_0x3a00eb['model'];if(!_0x2034e6[_0xb5b4('0x3f')][_0xb5b4('0x46')](_0xb5b4('0x47'))){_0xb44bca[_0xb5b4('0x21')]=qs[_0xb5b4('0x21')](_0x2034e6['query'][_0xb5b4('0x21')]);_0xb44bca[_0xb5b4('0x1f')]=qs[_0xb5b4('0x1f')](_0x2034e6[_0xb5b4('0x3f')]['offset']);}_0xb44bca[_0xb5b4('0x48')]=qs[_0xb5b4('0x49')](_0x2034e6[_0xb5b4('0x3f')][_0xb5b4('0x49')]);_0xb44bca[_0xb5b4('0x4b')]=qs[_0xb5b4('0x41')](_[_0xb5b4('0x4a')](_0x2034e6[_0xb5b4('0x3f')],_0x3a00eb[_0xb5b4('0x41')]));_0xb44bca[_0xb5b4('0x4b')][_0xb5b4('0x65')]=_0x125568['id'];if(_0x2034e6[_0xb5b4('0x3f')]['filter']){_0xb44bca[_0xb5b4('0x4b')]=_[_0xb5b4('0x4c')](_0xb44bca[_0xb5b4('0x4b')],{'$or':_['map'](_0xb44bca[_0xb5b4('0x43')],function(_0x417fa8){var _0x553a93={};_0x553a93[_0x417fa8]={'$like':'%'+_0x2034e6['query']['filter']+'%'};return _0x553a93;})});}_0xb44bca=_[_0xb5b4('0x4c')]({},_0xb44bca,_0x2034e6[_0xb5b4('0x54')]);return db[_0xb5b4('0x64')][_0xb5b4('0x22')]({'where':_0xb44bca[_0xb5b4('0x4b')]})[_0xb5b4('0x2a')](function(_0x80b365){_0x10bf1f['count']=_0x80b365;if(_0x2034e6[_0xb5b4('0x3f')][_0xb5b4('0x53')]){_0xb44bca[_0xb5b4('0x4e')]=[{'all':!![]}];}return db[_0xb5b4('0x64')][_0xb5b4('0x4f')](_0xb44bca);})[_0xb5b4('0x2a')](function(_0x4100fe){_0x10bf1f[_0xb5b4('0x50')]=_0x4100fe;return _0x10bf1f;});}})[_0xb5b4('0x2a')](respondWithFilteredResult(_0xb7e8b1,_0xb44bca))['catch'](handleError(_0xb7e8b1,null));};exports[_0xb5b4('0x66')]=function(_0x4f74b7,_0x3fc28a,_0x508592){var _0x330a1f={'raw':!![],'where':{}};var _0x5c6494={};var _0x379a6={'count':0x0,'rows':[]};return db[_0xb5b4('0x4d')][_0xb5b4('0x63')]({'where':{'id':_0x4f74b7[_0xb5b4('0x52')]['id']}})[_0xb5b4('0x2a')](handleEntityNotFound(_0x3fc28a,null))['then'](function(_0x14efd1){if(_0x14efd1){_0x5c6494[_0xb5b4('0x3e')]=_[_0xb5b4('0x40')](db[_0xb5b4('0x67')][_0xb5b4('0x3b')]);_0x5c6494[_0xb5b4('0x3f')]=_[_0xb5b4('0x40')](_0x4f74b7[_0xb5b4('0x3f')]);_0x5c6494[_0xb5b4('0x41')]=_[_0xb5b4('0x42')](_0x5c6494[_0xb5b4('0x3e')],_0x5c6494['query']);_0x330a1f[_0xb5b4('0x43')]=_[_0xb5b4('0x42')](_0x5c6494['model'],qs[_0xb5b4('0x44')](_0x4f74b7['query'][_0xb5b4('0x44')]));_0x330a1f['attributes']=_0x330a1f['attributes'][_0xb5b4('0x45')]?_0x330a1f[_0xb5b4('0x43')]:_0x5c6494[_0xb5b4('0x3e')];if(!_0x4f74b7['query'][_0xb5b4('0x46')](_0xb5b4('0x47'))){_0x330a1f[_0xb5b4('0x21')]=qs[_0xb5b4('0x21')](_0x4f74b7[_0xb5b4('0x3f')][_0xb5b4('0x21')]);_0x330a1f[_0xb5b4('0x1f')]=qs[_0xb5b4('0x1f')](_0x4f74b7[_0xb5b4('0x3f')][_0xb5b4('0x1f')]);}_0x330a1f[_0xb5b4('0x48')]=qs['sort'](_0x4f74b7[_0xb5b4('0x3f')][_0xb5b4('0x49')]);_0x330a1f['where']=qs[_0xb5b4('0x41')](_['pick'](_0x4f74b7['query'],_0x5c6494[_0xb5b4('0x41')]));_0x330a1f[_0xb5b4('0x4b')][_0xb5b4('0x65')]=_0x14efd1['id'];if(_0x4f74b7[_0xb5b4('0x3f')][_0xb5b4('0x30')]){_0x330a1f['where']=_[_0xb5b4('0x4c')](_0x330a1f[_0xb5b4('0x4b')],{'$or':_[_0xb5b4('0x31')](_0x330a1f['attributes'],function(_0x1b61eb){var _0x304592={};_0x304592[_0x1b61eb]={'$like':'%'+_0x4f74b7[_0xb5b4('0x3f')][_0xb5b4('0x30')]+'%'};return _0x304592;})});}_0x330a1f=_[_0xb5b4('0x4c')]({},_0x330a1f,_0x4f74b7[_0xb5b4('0x54')]);return db['CmHopperHistory'][_0xb5b4('0x22')]({'where':_0x330a1f[_0xb5b4('0x4b')]})[_0xb5b4('0x2a')](function(_0x3ae34b){_0x379a6[_0xb5b4('0x22')]=_0x3ae34b;if(_0x4f74b7[_0xb5b4('0x3f')][_0xb5b4('0x53')]){_0x330a1f[_0xb5b4('0x4e')]=[{'all':!![]}];}return db['CmHopperHistory'][_0xb5b4('0x4f')](_0x330a1f);})['then'](function(_0x35f5d0){_0x379a6[_0xb5b4('0x50')]=_0x35f5d0;return _0x379a6;});}})[_0xb5b4('0x2a')](respondWithFilteredResult(_0x3fc28a,_0x330a1f))[_0xb5b4('0x5b')](handleError(_0x3fc28a,null));};exports[_0xb5b4('0x68')]=function(_0x5cb987,_0x49b752,_0x28a9d){var _0x3c8b59={'raw':!![],'where':{}};var _0x116efe={};var _0x7bbe1e={'count':0x0,'rows':[]};return db[_0xb5b4('0x4d')]['findOne']({'where':{'id':_0x5cb987[_0xb5b4('0x52')]['id']}})['then'](handleEntityNotFound(_0x49b752,null))[_0xb5b4('0x2a')](function(_0x208245){if(_0x208245){_0x116efe[_0xb5b4('0x3e')]=_[_0xb5b4('0x40')](db[_0xb5b4('0x69')][_0xb5b4('0x3b')]);_0x116efe[_0xb5b4('0x3f')]=_['keys'](_0x5cb987[_0xb5b4('0x3f')]);_0x116efe['filters']=_[_0xb5b4('0x42')](_0x116efe['model'],_0x116efe['query']);_0x3c8b59[_0xb5b4('0x43')]=_[_0xb5b4('0x42')](_0x116efe[_0xb5b4('0x3e')],qs[_0xb5b4('0x44')](_0x5cb987[_0xb5b4('0x3f')][_0xb5b4('0x44')]));_0x3c8b59[_0xb5b4('0x43')]=_0x3c8b59[_0xb5b4('0x43')][_0xb5b4('0x45')]?_0x3c8b59[_0xb5b4('0x43')]:_0x116efe['model'];if(!_0x5cb987['query'][_0xb5b4('0x46')]('nolimit')){_0x3c8b59['limit']=qs['limit'](_0x5cb987[_0xb5b4('0x3f')][_0xb5b4('0x21')]);_0x3c8b59[_0xb5b4('0x1f')]=qs[_0xb5b4('0x1f')](_0x5cb987[_0xb5b4('0x3f')][_0xb5b4('0x1f')]);}_0x3c8b59['order']=qs[_0xb5b4('0x49')](_0x5cb987['query'][_0xb5b4('0x49')]);_0x3c8b59['where']=qs['filters'](_[_0xb5b4('0x4a')](_0x5cb987['query'],_0x116efe['filters']));_0x3c8b59[_0xb5b4('0x4b')][_0xb5b4('0x65')]=_0x208245['id'];if(_0x5cb987[_0xb5b4('0x3f')][_0xb5b4('0x30')]){_0x3c8b59[_0xb5b4('0x4b')]=_[_0xb5b4('0x4c')](_0x3c8b59[_0xb5b4('0x4b')],{'$or':_[_0xb5b4('0x31')](_0x3c8b59[_0xb5b4('0x43')],function(_0x47cf18){var _0x2be91d={};_0x2be91d[_0x47cf18]={'$like':'%'+_0x5cb987[_0xb5b4('0x3f')]['filter']+'%'};return _0x2be91d;})});}_0x3c8b59=_[_0xb5b4('0x4c')]({},_0x3c8b59,_0x5cb987[_0xb5b4('0x54')]);return db['CmHopperFinal'][_0xb5b4('0x22')]({'where':_0x3c8b59[_0xb5b4('0x4b')]})[_0xb5b4('0x2a')](function(_0x25fac7){_0x7bbe1e[_0xb5b4('0x22')]=_0x25fac7;if(_0x5cb987[_0xb5b4('0x3f')][_0xb5b4('0x53')]){_0x3c8b59[_0xb5b4('0x4e')]=[{'all':!![]}];}return db['CmHopperFinal'][_0xb5b4('0x4f')](_0x3c8b59);})['then'](function(_0x4470fb){_0x7bbe1e[_0xb5b4('0x50')]=_0x4470fb;return _0x7bbe1e;});}})[_0xb5b4('0x2a')](respondWithFilteredResult(_0x49b752,_0x3c8b59))[_0xb5b4('0x5b')](handleError(_0x49b752,null));};exports['getHopperBlacks']=function(_0x50f6e7,_0x5cc378,_0x249a52){var _0x421c1f={'raw':!![],'where':{}};var _0x54f0b6={};var _0x41413c={'count':0x0,'rows':[]};return db[_0xb5b4('0x4d')][_0xb5b4('0x63')]({'where':{'id':_0x50f6e7[_0xb5b4('0x52')]['id']}})[_0xb5b4('0x2a')](handleEntityNotFound(_0x5cc378,null))[_0xb5b4('0x2a')](function(_0x2982d7){if(_0x2982d7){_0x54f0b6[_0xb5b4('0x3e')]=_[_0xb5b4('0x40')](db[_0xb5b4('0x6a')][_0xb5b4('0x3b')]);_0x54f0b6[_0xb5b4('0x3f')]=_[_0xb5b4('0x40')](_0x50f6e7[_0xb5b4('0x3f')]);_0x54f0b6[_0xb5b4('0x41')]=_[_0xb5b4('0x42')](_0x54f0b6[_0xb5b4('0x3e')],_0x54f0b6[_0xb5b4('0x3f')]);_0x421c1f['attributes']=_[_0xb5b4('0x42')](_0x54f0b6[_0xb5b4('0x3e')],qs[_0xb5b4('0x44')](_0x50f6e7[_0xb5b4('0x3f')][_0xb5b4('0x44')]));_0x421c1f[_0xb5b4('0x43')]=_0x421c1f['attributes'][_0xb5b4('0x45')]?_0x421c1f[_0xb5b4('0x43')]:_0x54f0b6[_0xb5b4('0x3e')];if(!_0x50f6e7[_0xb5b4('0x3f')][_0xb5b4('0x46')](_0xb5b4('0x47'))){_0x421c1f[_0xb5b4('0x21')]=qs['limit'](_0x50f6e7[_0xb5b4('0x3f')]['limit']);_0x421c1f['offset']=qs['offset'](_0x50f6e7[_0xb5b4('0x3f')][_0xb5b4('0x1f')]);}_0x421c1f[_0xb5b4('0x48')]=qs[_0xb5b4('0x49')](_0x50f6e7['query'][_0xb5b4('0x49')]);_0x421c1f[_0xb5b4('0x4b')]=qs[_0xb5b4('0x41')](_['pick'](_0x50f6e7[_0xb5b4('0x3f')],_0x54f0b6[_0xb5b4('0x41')]));_0x421c1f[_0xb5b4('0x4b')][_0xb5b4('0x65')]=_0x2982d7['id'];if(_0x50f6e7[_0xb5b4('0x3f')][_0xb5b4('0x30')]){_0x421c1f[_0xb5b4('0x4b')]=_['merge'](_0x421c1f[_0xb5b4('0x4b')],{'$or':_['map'](_0x421c1f[_0xb5b4('0x43')],function(_0x213c6d){var _0x128020={};_0x128020[_0x213c6d]={'$like':'%'+_0x50f6e7[_0xb5b4('0x3f')][_0xb5b4('0x30')]+'%'};return _0x128020;})});}_0x421c1f=_['merge']({},_0x421c1f,_0x50f6e7[_0xb5b4('0x54')]);return db[_0xb5b4('0x6a')][_0xb5b4('0x22')]({'where':_0x421c1f[_0xb5b4('0x4b')]})['then'](function(_0x4cab59){_0x41413c[_0xb5b4('0x22')]=_0x4cab59;if(_0x50f6e7[_0xb5b4('0x3f')][_0xb5b4('0x53')]){_0x421c1f['include']=[{'all':!![]}];}return db[_0xb5b4('0x6a')]['findAll'](_0x421c1f);})['then'](function(_0x4e8a90){_0x41413c['rows']=_0x4e8a90;return _0x41413c;});}})[_0xb5b4('0x2a')](respondWithFilteredResult(_0x5cc378,_0x421c1f))[_0xb5b4('0x5b')](handleError(_0x5cc378,null));};exports[_0xb5b4('0x6b')]=function(_0x761f3c,_0x5c0896,_0x13e7d9){var _0x365f13={};var _0x3822d5={};var _0x5c8e0e;var _0x1d0b21;return db[_0xb5b4('0x4d')][_0xb5b4('0x63')]({'where':{'id':_0x761f3c[_0xb5b4('0x52')]['id']}})[_0xb5b4('0x2a')](handleEntityNotFound(_0x5c0896,null))[_0xb5b4('0x2a')](function(_0x45cd89){if(_0x45cd89){_0x5c8e0e=_0x45cd89;_0x3822d5[_0xb5b4('0x3e')]=_['keys'](db[_0xb5b4('0x6c')]['rawAttributes']);_0x3822d5[_0xb5b4('0x3f')]=_[_0xb5b4('0x40')](_0x761f3c[_0xb5b4('0x3f')]);_0x3822d5['filters']=_['intersection'](_0x3822d5[_0xb5b4('0x3e')],_0x3822d5[_0xb5b4('0x3f')]);_0x365f13[_0xb5b4('0x43')]=_[_0xb5b4('0x42')](_0x3822d5['model'],qs[_0xb5b4('0x44')](_0x761f3c[_0xb5b4('0x3f')][_0xb5b4('0x44')]));_0x365f13['attributes']=_0x365f13[_0xb5b4('0x43')]['length']?_0x365f13[_0xb5b4('0x43')]:_0x3822d5['model'];_0x365f13[_0xb5b4('0x48')]=qs[_0xb5b4('0x49')](_0x761f3c[_0xb5b4('0x3f')][_0xb5b4('0x49')]);_0x365f13['where']=qs[_0xb5b4('0x41')](_['pick'](_0x761f3c[_0xb5b4('0x3f')],_0x3822d5[_0xb5b4('0x41')]));if(_0x761f3c[_0xb5b4('0x3f')][_0xb5b4('0x30')]){_0x365f13[_0xb5b4('0x4b')]=_['merge'](_0x365f13[_0xb5b4('0x4b')],{'$or':_[_0xb5b4('0x31')](_0x365f13['attributes'],function(_0x46222b){var _0x2f09c1={};_0x2f09c1[_0x46222b]={'$like':'%'+_0x761f3c[_0xb5b4('0x3f')][_0xb5b4('0x30')]+'%'};return _0x2f09c1;})});}_0x365f13=_['merge']({},_0x365f13,_0x761f3c[_0xb5b4('0x54')]);return _0x5c8e0e[_0xb5b4('0x6b')](_0x365f13);}})[_0xb5b4('0x2a')](function(_0x12dd2f){if(_0x12dd2f){_0x1d0b21=_0x12dd2f['length'];if(!_0x761f3c[_0xb5b4('0x3f')][_0xb5b4('0x46')](_0xb5b4('0x47'))){_0x365f13[_0xb5b4('0x21')]=qs[_0xb5b4('0x21')](_0x761f3c[_0xb5b4('0x3f')][_0xb5b4('0x21')]);_0x365f13['offset']=qs[_0xb5b4('0x1f')](_0x761f3c[_0xb5b4('0x3f')][_0xb5b4('0x1f')]);}return _0x5c8e0e[_0xb5b4('0x6b')](_0x365f13);}})[_0xb5b4('0x2a')](function(_0x1bc198){if(_0x1bc198){return _0x1bc198?{'count':_0x1d0b21,'rows':_0x1bc198}:null;}})[_0xb5b4('0x2a')](respondWithResult(_0x5c0896,null))['catch'](handleError(_0x5c0896,null));};exports['addTeams']=function(_0x3eaa33,_0x280b90,_0x5f5366){var _0x19a848=_0x3eaa33[_0xb5b4('0x56')][_0xb5b4('0x6d')];var _0x2e083c=_[_0xb5b4('0x31')](_0x19a848,'id');return db[_0xb5b4('0x6c')][_0xb5b4('0x4f')]({'where':{'id':_0x2e083c},'attributes':['id'],'include':[{'model':db[_0xb5b4('0x6e')],'as':_0xb5b4('0x6f'),'attributes':['id',_0xb5b4('0x38'),_0xb5b4('0x70'),_0xb5b4('0x71'),_0xb5b4('0x72')],'raw':!![]}]})['then'](function(_0x2682d1){if(_0x2682d1){var _0x4b91fa=_[_0xb5b4('0x73')](_0x2682d1,function(_0x4cdfe2){var _0x5a178e=_0x4cdfe2[_0xb5b4('0x2b')]({'plain':!![]});_0x5a178e[_0xb5b4('0x6f')][_0xb5b4('0x74')](function(_0x2d63be){_0x2d63be[_0xb5b4('0x75')]=_[_0xb5b4('0x33')](_0x19a848,{'id':_0x5a178e['id']})[_0xb5b4('0x75')];});return _0x5a178e['Agents'];});return db['VoiceQueue'][_0xb5b4('0x33')]({'where':{'id':_0x3eaa33['params']['id']}})[_0xb5b4('0x2a')](function(_0x4e95da){return db[_0xb5b4('0x76')][_0xb5b4('0x77')](function(_0xf693d7){return _0x4e95da[_0xb5b4('0x78')](_0x2e083c,{'transaction':_0xf693d7})[_0xb5b4('0x2a')](function(){return BPromise[_0xb5b4('0x79')](_0x19a848,function(_0x3c1705){return db[_0xb5b4('0x7a')]['upsert']({'TeamId':_0x3c1705['id'],'VoiceQueueId':_0x3eaa33[_0xb5b4('0x52')]['id'],'penalty':_0x3c1705['penalty']},{'transaction':_0xf693d7});});})['then'](function(){return BPromise[_0xb5b4('0x79')](_0x4b91fa,function(_0x43487b){return db['UserVoiceQueue'][_0xb5b4('0x7b')]({'where':{'UserId':_0x43487b['id'],'VoiceQueueId':_0x3eaa33[_0xb5b4('0x52')]['id']},'defaults':{'penalty':_0x43487b['penalty']},'transaction':_0xf693d7});});})[_0xb5b4('0x2a')](function(){return BPromise[_0xb5b4('0x79')](_['filter'](_0x4b91fa,{'online':!![]}),function(_0x318a4f){return db[_0xb5b4('0x7c')][_0xb5b4('0x7d')]({'membername':_0x318a4f[_0xb5b4('0x38')],'UserId':_0x318a4f['id'],'queue_name':_0x4e95da['name'],'VoiceQueueId':_0x4e95da['id'],'interface':_[_0xb5b4('0x7e')](_0x318a4f[_0xb5b4('0x72')])?util['format'](_0xb5b4('0x7f'),_0x318a4f['name']):_0x318a4f['interface'],'paused':_0x318a4f[_0xb5b4('0x71')]||![],'penalty':_0x318a4f['penalty']},{'transaction':_0xf693d7});});})[_0xb5b4('0x2a')](function(){_0x4b91fa['forEach'](function(_0x2f285d){socket[_0xb5b4('0x80')](_0xb5b4('0x81'),{'UserId':_0x2f285d['id'],'VoiceQueueId':_0x4e95da['id']});});});});});}})[_0xb5b4('0x2a')](respondWithStatusCode(_0x280b90,null))[_0xb5b4('0x5b')](handleError(_0x280b90,null));};exports[_0xb5b4('0x82')]=function(_0x2b0f7a,_0xec7407,_0x50e420){return db['Team']['findAll']({'where':{'id':_0x2b0f7a[_0xb5b4('0x3f')][_0xb5b4('0x83')]},'attributes':['id'],'include':[{'model':db[_0xb5b4('0x6e')],'as':'Agents','attributes':['id'],'raw':!![]}]})['then'](handleEntityNotFound(_0xec7407,null))[_0xb5b4('0x2a')](function(_0x279b52){var _0x5e9354=_['map'](_0x279b52,'id');var _0x267d96=[];var _0x2ec68e=[];var _0xfeaed6=squel[_0xb5b4('0x84')]();_0xfeaed6[_0xb5b4('0x85')]('tq.TeamId')['from']('team_has_voice_queues','tq')[_0xb5b4('0x86')](_0xb5b4('0x87'),'ut',_0xb5b4('0x88'))[_0xb5b4('0x4b')]('VoiceQueueId\x20=\x20?',_0x2b0f7a[_0xb5b4('0x52')]['id']);for(var _0x594e20=0x0;_0x594e20<_0x279b52[_0xb5b4('0x45')];_0x594e20+=0x1){let _0xc86e1d=_0x279b52[_0x594e20];for(var _0x439a1d=0x0;_0x439a1d<_0xc86e1d[_0xb5b4('0x6f')][_0xb5b4('0x45')];_0x439a1d+=0x1){let _0x593401=_0xc86e1d['Agents'][_0x439a1d];var _0x35cfaa=_0xfeaed6[_0xb5b4('0x5d')]();_0x35cfaa[_0xb5b4('0x4b')](_0xb5b4('0x89'),_0x593401['id']);_0x2ec68e[_0xb5b4('0x8a')](db[_0xb5b4('0x76')][_0xb5b4('0x3f')](_0x35cfaa[_0xb5b4('0x8b')](),{'type':db[_0xb5b4('0x76')][_0xb5b4('0x8c')][_0xb5b4('0x8d')]})[_0xb5b4('0x2a')](function(_0x33af66){if(_0x33af66[_0xb5b4('0x45')]===0x1){return _0x593401['id'];}else{var _0x583f4f=_[_0xb5b4('0x8e')](_[_0xb5b4('0x31')](_0x33af66,_0xb5b4('0x8f')),function(_0x541eb4){return _[_0xb5b4('0x90')](_0x5e9354,_0x541eb4);});if(_0x583f4f){return _0x593401['id'];}}}));}}return BPromise['all'](_0x2ec68e)['then'](function(_0x19e56e){_0x267d96=_(_0x267d96)[_0xb5b4('0x91')](_0x19e56e)['compact']()[_0xb5b4('0x32')]();return db[_0xb5b4('0x4d')][_0xb5b4('0x33')]({'where':{'id':_0x2b0f7a[_0xb5b4('0x52')]['id']}})['then'](function(_0x18166c){return db[_0xb5b4('0x76')][_0xb5b4('0x77')](function(_0x28eb98){return _0x18166c['removeTeams'](_0x2b0f7a[_0xb5b4('0x3f')][_0xb5b4('0x83')],{'transaction':_0x28eb98})[_0xb5b4('0x2a')](function(){if(!_[_0xb5b4('0x92')](_0x267d96)){return _0x18166c[_0xb5b4('0x93')](_0x267d96,{'transaction':_0x28eb98})['then'](function(){return db[_0xb5b4('0x7c')][_0xb5b4('0x29')]({'where':{'VoiceQueueId':_0x2b0f7a[_0xb5b4('0x52')]['id'],'UserId':_0x267d96},'transaction':_0x28eb98});});}})[_0xb5b4('0x2a')](function(){_0x267d96[_0xb5b4('0x74')](function(_0x2c7203){socket[_0xb5b4('0x80')](_0xb5b4('0x94'),{'UserId':_0x2c7203,'VoiceQueueId':_0x18166c['id']});});});});});});})[_0xb5b4('0x2a')](respondWithStatusCode(_0xec7407,null))[_0xb5b4('0x5b')](handleError(_0xec7407,null));};exports[_0xb5b4('0x95')]=function(_0x160008,_0x19c9b7,_0x65f76a){var _0x19e420,_0x4921b3;return db['VoiceQueue'][_0xb5b4('0x33')]({'where':{'id':_0x160008['params']['id']}})[_0xb5b4('0x2a')](handleEntityNotFound(_0x19c9b7,null))[_0xb5b4('0x2a')](function(_0x2722f7){if(_0x2722f7){_0x4921b3=_0x2722f7;return _0x2722f7[_0xb5b4('0x95')](_0x160008['body'][_0xb5b4('0x83')],_[_0xb5b4('0x5e')](_0x160008[_0xb5b4('0x56')],[_0xb5b4('0x83'),'id'])||{})[_0xb5b4('0x96')](function(_0x26870b){for(var _0x48dfc7=0x0;_0x48dfc7<_0x160008['body']['ids'][_0xb5b4('0x45')];_0x48dfc7+=0x1){socket['emit'](_0xb5b4('0x81'),{'UserId':_0x160008[_0xb5b4('0x56')][_0xb5b4('0x83')][_0x48dfc7],'VoiceQueueId':_0x160008['params']['id']});}return _0x26870b;});}})[_0xb5b4('0x2a')](function(_0x3efe53){_0x19e420=_0x3efe53||[];if(_0x4921b3){return db['User']['findAll']({'where':{'id':_0x160008[_0xb5b4('0x56')][_0xb5b4('0x83')]},'attributes':['id',_0xb5b4('0x38'),_0xb5b4('0x70'),_0xb5b4('0x71'),_0xb5b4('0x72')],'raw':!![]});}})[_0xb5b4('0x2a')](function(_0x5ab834){if(!_[_0xb5b4('0x92')](_0x5ab834)){var _0x965189=[];for(var _0x1d73f1=0x0;_0x1d73f1<_0x5ab834[_0xb5b4('0x45')];_0x1d73f1++){if(_0x5ab834[_0x1d73f1][_0xb5b4('0x70')]){_0x965189[_0xb5b4('0x8a')](db['UserVoiceQueueRt']['upsert']({'membername':_0x5ab834[_0x1d73f1][_0xb5b4('0x38')],'UserId':_0x5ab834[_0x1d73f1]['id'],'queue_name':_0x4921b3['name'],'VoiceQueueId':_0x4921b3['id'],'interface':_[_0xb5b4('0x7e')](_0x5ab834[_0x1d73f1][_0xb5b4('0x72')])?util[_0xb5b4('0x97')](_0xb5b4('0x7f'),_0x5ab834[_0x1d73f1][_0xb5b4('0x38')]):_0x5ab834[_0x1d73f1]['interface'],'paused':_0x5ab834[_0x1d73f1]['voicePause']||![],'penalty':_0x160008[_0xb5b4('0x56')][_0xb5b4('0x75')]||0x0}));}}return BPromise[_0xb5b4('0x98')](_0x965189);}})['then'](function(){return _0x19e420;})['then'](respondWithResult(_0x19c9b7,null))[_0xb5b4('0x5b')](handleError(_0x19c9b7,null));};exports[_0xb5b4('0x93')]=function(_0x48c11d,_0x42a2f9,_0x520a92){return db[_0xb5b4('0x4d')]['find']({'where':{'id':_0x48c11d['params']['id']}})['then'](handleEntityNotFound(_0x42a2f9,null))[_0xb5b4('0x2a')](function(_0x2631c6){if(_0x2631c6){return _0x2631c6[_0xb5b4('0x93')](_0x48c11d[_0xb5b4('0x3f')]['ids'])[_0xb5b4('0x2a')](function(){if(_[_0xb5b4('0x99')](_0x48c11d['query'][_0xb5b4('0x83')])){for(var _0x2c6a83=0x0;_0x2c6a83<_0x48c11d[_0xb5b4('0x3f')][_0xb5b4('0x83')][_0xb5b4('0x45')];_0x2c6a83+=0x1){socket['emit'](_0xb5b4('0x94'),{'UserId':Number(_0x48c11d[_0xb5b4('0x3f')][_0xb5b4('0x83')][_0x2c6a83]),'VoiceQueueId':Number(_0x48c11d[_0xb5b4('0x52')]['id'])});}}else{socket[_0xb5b4('0x80')]('userVoiceQueue:remove',{'UserId':Number(_0x48c11d['query'][_0xb5b4('0x83')]),'VoiceQueueId':Number(_0x48c11d[_0xb5b4('0x52')]['id'])});}});}})['then'](function(_0xe959cc){return db[_0xb5b4('0x7c')]['destroy']({'where':{'VoiceQueueId':_0x48c11d[_0xb5b4('0x52')]['id'],'UserId':_0x48c11d[_0xb5b4('0x3f')][_0xb5b4('0x83')]}})[_0xb5b4('0x2a')](function(){return _0xe959cc;});})[_0xb5b4('0x2a')](respondWithStatusCode(_0x42a2f9,null))['catch'](handleError(_0x42a2f9,null));};exports[_0xb5b4('0x9a')]=function(_0x5d9e15,_0x5b32fe,_0x1a22ae){var _0x34c522={};var _0x58cc7b={};var _0x5b2271;var _0x10f7b6;return db['VoiceQueue'][_0xb5b4('0x63')]({'where':{'id':_0x5d9e15[_0xb5b4('0x52')]['id']}})[_0xb5b4('0x2a')](handleEntityNotFound(_0x5b32fe,null))[_0xb5b4('0x2a')](function(_0x191faa){if(_0x191faa){_0x5b2271=_0x191faa;_0x58cc7b[_0xb5b4('0x3e')]=_[_0xb5b4('0x40')](db[_0xb5b4('0x6e')]['rawAttributes']);_0x58cc7b[_0xb5b4('0x3f')]=_['keys'](_0x5d9e15[_0xb5b4('0x3f')]);_0x58cc7b[_0xb5b4('0x41')]=_['intersection'](_0x58cc7b[_0xb5b4('0x3e')],_0x58cc7b[_0xb5b4('0x3f')]);_0x34c522[_0xb5b4('0x43')]=_['intersection'](_0x58cc7b[_0xb5b4('0x3e')],qs['fields'](_0x5d9e15[_0xb5b4('0x3f')][_0xb5b4('0x44')]));_0x34c522['attributes']=_0x34c522[_0xb5b4('0x43')][_0xb5b4('0x45')]?_0x34c522[_0xb5b4('0x43')]:_0x58cc7b['model'];_0x34c522[_0xb5b4('0x48')]=qs[_0xb5b4('0x49')](_0x5d9e15[_0xb5b4('0x3f')][_0xb5b4('0x49')]);_0x34c522[_0xb5b4('0x4b')]=qs['filters'](_[_0xb5b4('0x4a')](_0x5d9e15['query'],_0x58cc7b['filters']));if(_0x5d9e15[_0xb5b4('0x3f')][_0xb5b4('0x30')]){_0x34c522[_0xb5b4('0x4b')]=_[_0xb5b4('0x4c')](_0x34c522[_0xb5b4('0x4b')],{'$or':_[_0xb5b4('0x31')](_0x34c522[_0xb5b4('0x43')],function(_0x528abb){var _0x302166={};_0x302166[_0x528abb]={'$like':'%'+_0x5d9e15[_0xb5b4('0x3f')][_0xb5b4('0x30')]+'%'};return _0x302166;})});}_0x34c522=_[_0xb5b4('0x4c')]({},_0x34c522,_0x5d9e15[_0xb5b4('0x54')]);return _0x5b2271[_0xb5b4('0x9a')](_0x34c522);}})[_0xb5b4('0x2a')](function(_0x164c96){if(_0x164c96){_0x10f7b6=_0x164c96['length'];if(!_0x5d9e15[_0xb5b4('0x3f')][_0xb5b4('0x46')](_0xb5b4('0x47'))){_0x34c522[_0xb5b4('0x21')]=qs[_0xb5b4('0x21')](_0x5d9e15['query'][_0xb5b4('0x21')]);_0x34c522[_0xb5b4('0x1f')]=qs[_0xb5b4('0x1f')](_0x5d9e15[_0xb5b4('0x3f')][_0xb5b4('0x1f')]);}return _0x5b2271[_0xb5b4('0x9a')](_0x34c522);}})[_0xb5b4('0x2a')](function(_0xc72e34){if(_0xc72e34){return _0xc72e34?{'count':_0x10f7b6,'rows':_0xc72e34}:null;}})[_0xb5b4('0x2a')](respondWithResult(_0x5b32fe,null))[_0xb5b4('0x5b')](handleError(_0x5b32fe,null));};exports[_0xb5b4('0x9b')]=function(_0x255f91,_0x15f897,_0x30e693){var _0x2d19b6={};var _0x3cdc8e={};var _0x432fb0;var _0x3177e4;return db['VoiceQueue']['findOne']({'where':{'id':_0x255f91['params']['id']}})[_0xb5b4('0x2a')](handleEntityNotFound(_0x15f897,null))[_0xb5b4('0x2a')](function(_0x245862){if(_0x245862){_0x432fb0=_0x245862;_0x3cdc8e[_0xb5b4('0x3e')]=_[_0xb5b4('0x40')](db['UserVoiceQueueRt'][_0xb5b4('0x3b')]);_0x3cdc8e['query']=_[_0xb5b4('0x40')](_0x255f91[_0xb5b4('0x3f')]);_0x3cdc8e['filters']=_[_0xb5b4('0x42')](_0x3cdc8e[_0xb5b4('0x3e')],_0x3cdc8e[_0xb5b4('0x3f')]);_0x2d19b6['attributes']=_[_0xb5b4('0x42')](_0x3cdc8e[_0xb5b4('0x3e')],qs[_0xb5b4('0x44')](_0x255f91[_0xb5b4('0x3f')][_0xb5b4('0x44')]));_0x2d19b6['attributes']=_0x2d19b6[_0xb5b4('0x43')][_0xb5b4('0x45')]?_0x2d19b6[_0xb5b4('0x43')]:_0x3cdc8e[_0xb5b4('0x3e')];_0x2d19b6['order']=qs[_0xb5b4('0x49')](_0x255f91[_0xb5b4('0x3f')][_0xb5b4('0x49')]);_0x2d19b6[_0xb5b4('0x4b')]=qs[_0xb5b4('0x41')](_[_0xb5b4('0x4a')](_0x255f91[_0xb5b4('0x3f')],_0x3cdc8e[_0xb5b4('0x41')]));if(_0x255f91['query'][_0xb5b4('0x30')]){_0x2d19b6[_0xb5b4('0x4b')]=_[_0xb5b4('0x4c')](_0x2d19b6['where'],{'$or':_[_0xb5b4('0x31')](_0x2d19b6[_0xb5b4('0x43')],function(_0x25964d){var _0x17edf3={};_0x17edf3[_0x25964d]={'$like':'%'+_0x255f91[_0xb5b4('0x3f')][_0xb5b4('0x30')]+'%'};return _0x17edf3;})});}_0x2d19b6=_[_0xb5b4('0x4c')]({},_0x2d19b6,_0x255f91[_0xb5b4('0x54')]);return _0x432fb0[_0xb5b4('0x9b')](_0x2d19b6);}})[_0xb5b4('0x2a')](function(_0x485cfe){if(_0x485cfe){_0x3177e4=_0x485cfe[_0xb5b4('0x45')];if(!_0x255f91[_0xb5b4('0x3f')][_0xb5b4('0x46')](_0xb5b4('0x47'))){_0x2d19b6['limit']=qs[_0xb5b4('0x21')](_0x255f91[_0xb5b4('0x3f')][_0xb5b4('0x21')]);_0x2d19b6[_0xb5b4('0x1f')]=qs[_0xb5b4('0x1f')](_0x255f91[_0xb5b4('0x3f')][_0xb5b4('0x1f')]);}return _0x432fb0[_0xb5b4('0x9b')](_0x2d19b6);}})['then'](function(_0x151e87){return _0x151e87?{'count':_0x3177e4,'rows':_0x151e87}:null;})[_0xb5b4('0x2a')](respondWithResult(_0x15f897,null))[_0xb5b4('0x5b')](handleError(_0x15f897,null));};exports['getLists']=function(_0x30323b,_0x4289d2,_0x5069a3){var _0x5ef968={};var _0x409c1f={};var _0x4ceb22;var _0x1c25bd;return db[_0xb5b4('0x4d')][_0xb5b4('0x63')]({'where':{'id':_0x30323b[_0xb5b4('0x52')]['id']}})['then'](handleEntityNotFound(_0x4289d2,null))[_0xb5b4('0x2a')](function(_0x2b01c4){if(_0x2b01c4){_0x4ceb22=_0x2b01c4;_0x409c1f['model']=_['keys'](db[_0xb5b4('0x9c')][_0xb5b4('0x3b')]);_0x409c1f[_0xb5b4('0x3f')]=_[_0xb5b4('0x40')](_0x30323b['query']);_0x409c1f[_0xb5b4('0x41')]=_[_0xb5b4('0x42')](_0x409c1f[_0xb5b4('0x3e')],_0x409c1f[_0xb5b4('0x3f')]);_0x5ef968['attributes']=_[_0xb5b4('0x42')](_0x409c1f[_0xb5b4('0x3e')],qs[_0xb5b4('0x44')](_0x30323b['query'][_0xb5b4('0x44')]));_0x5ef968['attributes']=_0x5ef968[_0xb5b4('0x43')][_0xb5b4('0x45')]?_0x5ef968[_0xb5b4('0x43')]:_0x409c1f[_0xb5b4('0x3e')];_0x5ef968[_0xb5b4('0x48')]=qs[_0xb5b4('0x49')](_0x30323b[_0xb5b4('0x3f')][_0xb5b4('0x49')]);_0x5ef968[_0xb5b4('0x4b')]=qs[_0xb5b4('0x41')](_[_0xb5b4('0x4a')](_0x30323b[_0xb5b4('0x3f')],_0x409c1f['filters']));if(_0x30323b['query']['filter']){_0x5ef968['where']=_[_0xb5b4('0x4c')](_0x5ef968[_0xb5b4('0x4b')],{'$or':_[_0xb5b4('0x31')](_0x5ef968['attributes'],function(_0x32051e){var _0x4e3bbe={};_0x4e3bbe[_0x32051e]={'$like':'%'+_0x30323b[_0xb5b4('0x3f')][_0xb5b4('0x30')]+'%'};return _0x4e3bbe;})});}_0x5ef968=_[_0xb5b4('0x4c')]({},_0x5ef968,_0x30323b[_0xb5b4('0x54')]);return _0x4ceb22[_0xb5b4('0x9d')](_0x5ef968);}})[_0xb5b4('0x2a')](function(_0x58317e){if(_0x58317e){_0x1c25bd=_0x58317e[_0xb5b4('0x45')];if(!_0x30323b[_0xb5b4('0x3f')]['hasOwnProperty']('nolimit')){_0x5ef968[_0xb5b4('0x21')]=qs[_0xb5b4('0x21')](_0x30323b[_0xb5b4('0x3f')][_0xb5b4('0x21')]);_0x5ef968[_0xb5b4('0x1f')]=qs[_0xb5b4('0x1f')](_0x30323b[_0xb5b4('0x3f')]['offset']);}return _0x4ceb22[_0xb5b4('0x9d')](_0x5ef968);}})[_0xb5b4('0x2a')](function(_0x888aaa){if(_0x888aaa){return _0x888aaa?{'count':_0x1c25bd,'rows':_0x888aaa}:null;}})[_0xb5b4('0x2a')](respondWithResult(_0x4289d2,null))[_0xb5b4('0x5b')](handleError(_0x4289d2,null));};exports[_0xb5b4('0x9e')]=function(_0x1d8589,_0x448b88,_0x147cb9){var _0x47b331,_0x766ab4;return db[_0xb5b4('0x4d')][_0xb5b4('0x33')]({'where':{'id':_0x1d8589['params']['id']}})['then'](handleEntityNotFound(_0x448b88,null))[_0xb5b4('0x2a')](function(_0x10ee87){if(_0x10ee87){_0x766ab4=_0x10ee87;return _0x10ee87[_0xb5b4('0x9e')](_0x1d8589[_0xb5b4('0x56')][_0xb5b4('0x83')],_['omit'](_0x1d8589['body'],[_0xb5b4('0x83'),'id'])||{});}return null;})[_0xb5b4('0x96')](function(_0x1b0dd5){var _0x4f5009;_0x47b331=_0x1b0dd5||[];var _0x187fb7=[];if(_0x1b0dd5){for(var _0x3ce4e0=0x0;_0x3ce4e0<_0x1b0dd5['length'];_0x3ce4e0+=0x1){var _0x4ff5b8=_0x1b0dd5[_0x3ce4e0][_0xb5b4('0x2b')]({'plain':!![]});_0x766ab4[_0xb5b4('0x9f')]=_0x1d8589[_0xb5b4('0x56')]['dialCheckDuplicateType']?_0x1d8589[_0xb5b4('0x56')][_0xb5b4('0x9f')]:_0x766ab4[_0xb5b4('0x9f')];switch(_0x766ab4[_0xb5b4('0x9f')]){case _0xb5b4('0xa0'):_0x4f5009=squel['insert']()['into'](_0xb5b4('0xa1'))['fromQuery']([_0xb5b4('0xa2'),_0xb5b4('0xa3'),_0xb5b4('0xa4'),_0xb5b4('0xa5'),_0xb5b4('0x65'),_0xb5b4('0x60'),_0xb5b4('0x5f')],squel['select']()[_0xb5b4('0x85')](_0xb5b4('0xa2'),_0xb5b4('0xa2'))[_0xb5b4('0x85')](_0xb5b4('0xa6'),_0xb5b4('0xa3'))[_0xb5b4('0x85')]('id',_0xb5b4('0xa4'))['field'](_0x4ff5b8[_0xb5b4('0xa7')][_0xb5b4('0x8b')](),_0xb5b4('0xa5'))[_0xb5b4('0x85')](_0x1d8589[_0xb5b4('0x52')]['id'][_0xb5b4('0x8b')](),_0xb5b4('0x65'))[_0xb5b4('0x85')]('NOW()',_0xb5b4('0x60'))[_0xb5b4('0x85')]('NOW()',_0xb5b4('0x5f'))['from']('cm_contacts')[_0xb5b4('0x4b')]('deletedAt\x20IS\x20NULL')[_0xb5b4('0x4b')](_0xb5b4('0xa8'),_0x4ff5b8[_0xb5b4('0xa7')]['toString']())[_0xb5b4('0x4b')](_0xb5b4('0xa9'))['where']('phone\x20NOT\x20IN\x20(?)',squel['select']()[_0xb5b4('0x85')](_0xb5b4('0xaa'))[_0xb5b4('0xab')]('cm_hopper_final')[_0xb5b4('0x4b')](_0xb5b4('0xac'),_0x1d8589['params']['id'][_0xb5b4('0x8b')]()))[_0xb5b4('0x4b')](_0xb5b4('0xad'),squel[_0xb5b4('0x84')]()[_0xb5b4('0x85')](_0xb5b4('0xae'))[_0xb5b4('0xab')](_0xb5b4('0xa1'))['where'](_0xb5b4('0xac'),_0x1d8589[_0xb5b4('0x52')]['id'][_0xb5b4('0x8b')]())))[_0xb5b4('0x8b')]();break;case _0xb5b4('0xaf'):_0x4f5009=squel[_0xb5b4('0xb0')]()[_0xb5b4('0xb1')]('cm_hopper')['fromQuery']([_0xb5b4('0xa2'),'scheduledAt',_0xb5b4('0xa4'),_0xb5b4('0xa5'),'VoiceQueueId',_0xb5b4('0x60'),'updatedAt'],squel[_0xb5b4('0x84')]()[_0xb5b4('0x85')](_0xb5b4('0xa2'),_0xb5b4('0xa2'))[_0xb5b4('0x85')]('NOW()',_0xb5b4('0xa3'))[_0xb5b4('0x85')]('id',_0xb5b4('0xa4'))['field'](_0x4ff5b8[_0xb5b4('0xa7')][_0xb5b4('0x8b')](),'ListId')['field'](_0x1d8589[_0xb5b4('0x52')]['id']['toString'](),_0xb5b4('0x65'))[_0xb5b4('0x85')]('NOW()',_0xb5b4('0x60'))[_0xb5b4('0x85')]('NOW()',_0xb5b4('0x5f'))[_0xb5b4('0xab')]('cm_contacts')[_0xb5b4('0x4b')]('deletedAt\x20IS\x20NULL')[_0xb5b4('0x4b')](_0xb5b4('0xa8'),_0x4ff5b8['CmListId']['toString']())['where']('phone\x20IS\x20NOT\x20NULL')[_0xb5b4('0x4b')](_0xb5b4('0xad'),squel[_0xb5b4('0x84')]()[_0xb5b4('0x85')]('COALESCE(phone,\x27\x27)')[_0xb5b4('0xab')](_0xb5b4('0xa1'))[_0xb5b4('0x4b')](_0xb5b4('0xac'),_0x1d8589['params']['id'][_0xb5b4('0x8b')]())))[_0xb5b4('0x8b')]();break;default:_0x4f5009=squel[_0xb5b4('0xb0')]()[_0xb5b4('0xb1')](_0xb5b4('0xa1'))[_0xb5b4('0xb2')]([_0xb5b4('0xa2'),_0xb5b4('0xa3'),_0xb5b4('0xa4'),'ListId',_0xb5b4('0x65'),_0xb5b4('0x60'),_0xb5b4('0x5f')],squel[_0xb5b4('0x84')]()[_0xb5b4('0x85')](_0xb5b4('0xa2'),_0xb5b4('0xa2'))[_0xb5b4('0x85')](_0xb5b4('0xa6'),_0xb5b4('0xa3'))[_0xb5b4('0x85')]('id','ContactId')[_0xb5b4('0x85')](_0x4ff5b8[_0xb5b4('0xa7')][_0xb5b4('0x8b')](),'ListId')[_0xb5b4('0x85')](_0x1d8589[_0xb5b4('0x52')]['id'][_0xb5b4('0x8b')](),'VoiceQueueId')[_0xb5b4('0x85')](_0xb5b4('0xa6'),_0xb5b4('0x60'))[_0xb5b4('0x85')](_0xb5b4('0xa6'),_0xb5b4('0x5f'))['from'](_0xb5b4('0xb3'))['where']('deletedAt\x20IS\x20NULL')[_0xb5b4('0x4b')](_0xb5b4('0xa8'),_0x4ff5b8[_0xb5b4('0xa7')]['toString']())[_0xb5b4('0x4b')]('phone\x20IS\x20NOT\x20NULL'))[_0xb5b4('0x8b')]();}_0x187fb7[_0xb5b4('0x8a')](db[_0xb5b4('0x76')]['query'](_0x4f5009));}return BPromise[_0xb5b4('0x98')](_0x187fb7);}})[_0xb5b4('0x2a')](function(){return _0x47b331;})['then'](respondWithResult(_0x448b88,null))['catch'](handleError(_0x448b88,null));};exports['removeLists']=function(_0xaf9d4c,_0x206a5d,_0x59dcb0){return db[_0xb5b4('0x4d')]['find']({'where':{'id':_0xaf9d4c[_0xb5b4('0x52')]['id']}})['then'](handleEntityNotFound(_0x206a5d,null))['then'](function(_0x5b8b5f){if(_0x5b8b5f){return _0x5b8b5f[_0xb5b4('0xb4')](_0xaf9d4c[_0xb5b4('0x3f')]['ids']);}})['then'](function(_0x1b0f1b){if(_0x1b0f1b){return db[_0xb5b4('0x64')][_0xb5b4('0x29')]({'where':{'ListId':_0xaf9d4c[_0xb5b4('0x3f')][_0xb5b4('0x83')],'VoiceQueueId':_0xaf9d4c[_0xb5b4('0x52')]['id']}})[_0xb5b4('0x2a')](function(){return _0x1b0f1b;});}})[_0xb5b4('0x2a')](respondWithStatusCode(_0x206a5d,null))[_0xb5b4('0x5b')](handleError(_0x206a5d,null));};exports['getBlackLists']=function(_0x430735,_0x3c4e99,_0x57f6c7){var _0x30aeb4={};var _0x325af6={};var _0x21ba13;var _0x1d2a4e;return db[_0xb5b4('0x4d')][_0xb5b4('0x63')]({'where':{'id':_0x430735[_0xb5b4('0x52')]['id']}})['then'](handleEntityNotFound(_0x3c4e99,null))[_0xb5b4('0x2a')](function(_0x56e2ed){if(_0x56e2ed){_0x21ba13=_0x56e2ed;_0x325af6[_0xb5b4('0x3e')]=_['keys'](db[_0xb5b4('0x9c')]['rawAttributes']);_0x325af6[_0xb5b4('0x3f')]=_[_0xb5b4('0x40')](_0x430735[_0xb5b4('0x3f')]);_0x325af6[_0xb5b4('0x41')]=_['intersection'](_0x325af6[_0xb5b4('0x3e')],_0x325af6['query']);_0x30aeb4[_0xb5b4('0x43')]=_['intersection'](_0x325af6[_0xb5b4('0x3e')],qs[_0xb5b4('0x44')](_0x430735[_0xb5b4('0x3f')]['fields']));_0x30aeb4['attributes']=_0x30aeb4[_0xb5b4('0x43')]['length']?_0x30aeb4['attributes']:_0x325af6['model'];_0x30aeb4[_0xb5b4('0x48')]=qs['sort'](_0x430735['query'][_0xb5b4('0x49')]);_0x30aeb4[_0xb5b4('0x4b')]=qs[_0xb5b4('0x41')](_[_0xb5b4('0x4a')](_0x430735[_0xb5b4('0x3f')],_0x325af6[_0xb5b4('0x41')]));if(_0x430735[_0xb5b4('0x3f')][_0xb5b4('0x30')]){_0x30aeb4[_0xb5b4('0x4b')]=_[_0xb5b4('0x4c')](_0x30aeb4['where'],{'$or':_[_0xb5b4('0x31')](_0x30aeb4[_0xb5b4('0x43')],function(_0x4dee0d){var _0x2a7e93={};_0x2a7e93[_0x4dee0d]={'$like':'%'+_0x430735[_0xb5b4('0x3f')][_0xb5b4('0x30')]+'%'};return _0x2a7e93;})});}_0x30aeb4=_[_0xb5b4('0x4c')]({},_0x30aeb4,_0x430735[_0xb5b4('0x54')]);return _0x21ba13[_0xb5b4('0xb5')](_0x30aeb4);}})[_0xb5b4('0x2a')](function(_0x171073){if(_0x171073){_0x1d2a4e=_0x171073['length'];if(!_0x430735['query'][_0xb5b4('0x46')](_0xb5b4('0x47'))){_0x30aeb4[_0xb5b4('0x21')]=qs[_0xb5b4('0x21')](_0x430735[_0xb5b4('0x3f')]['limit']);_0x30aeb4[_0xb5b4('0x1f')]=qs['offset'](_0x430735[_0xb5b4('0x3f')][_0xb5b4('0x1f')]);}return _0x21ba13[_0xb5b4('0xb5')](_0x30aeb4);}})[_0xb5b4('0x2a')](function(_0x174225){if(_0x174225){return _0x174225?{'count':_0x1d2a4e,'rows':_0x174225}:null;}})[_0xb5b4('0x2a')](respondWithResult(_0x3c4e99,null))[_0xb5b4('0x5b')](handleError(_0x3c4e99,null));};exports[_0xb5b4('0xb6')]=function(_0x5c8d45,_0x5a417c,_0x528eed){var _0x34a714,_0x6392ce;return db[_0xb5b4('0x4d')]['find']({'where':{'id':_0x5c8d45[_0xb5b4('0x52')]['id']}})[_0xb5b4('0x2a')](handleEntityNotFound(_0x5a417c,null))[_0xb5b4('0x2a')](function(_0x10019c){if(_0x10019c){_0x6392ce=_0x10019c;return _0x10019c[_0xb5b4('0xb6')](_0x5c8d45[_0xb5b4('0x56')][_0xb5b4('0x83')],_[_0xb5b4('0x5e')](_0x5c8d45['body'],[_0xb5b4('0x83'),'id'])||{});}return null;})[_0xb5b4('0x96')](function(_0x58a8ea){var _0x3c9a25;_0x34a714=_0x58a8ea||[];var _0x49523b=[];if(_0x58a8ea){for(var _0x38a000=0x0;_0x38a000<_0x58a8ea[_0xb5b4('0x45')];_0x38a000+=0x1){var _0x45e507=_0x58a8ea[_0x38a000][_0xb5b4('0x2b')]({'plain':!![]});_0x3c9a25=squel['insert']()[_0xb5b4('0xb1')](_0xb5b4('0xb7'))['fromQuery']([_0xb5b4('0xa2'),_0xb5b4('0xa4'),_0xb5b4('0xa5'),_0xb5b4('0x65'),'createdAt',_0xb5b4('0x5f')],squel[_0xb5b4('0x84')]()[_0xb5b4('0x85')](_0xb5b4('0xa2'),'phone')[_0xb5b4('0x85')]('id',_0xb5b4('0xa4'))[_0xb5b4('0x85')](_0x45e507[_0xb5b4('0xa7')][_0xb5b4('0x8b')](),_0xb5b4('0xa5'))[_0xb5b4('0x85')](_0x5c8d45[_0xb5b4('0x52')]['id'][_0xb5b4('0x8b')](),'VoiceQueueId')[_0xb5b4('0x85')](_0xb5b4('0xa6'),'createdAt')[_0xb5b4('0x85')](_0xb5b4('0xa6'),_0xb5b4('0x5f'))['from'](_0xb5b4('0xb3'))['where']('deletedAt\x20IS\x20NULL')[_0xb5b4('0x4b')](_0xb5b4('0xa8'),_0x45e507[_0xb5b4('0xa7')][_0xb5b4('0x8b')]())[_0xb5b4('0x4b')]('phone\x20IS\x20NOT\x20NULL'))[_0xb5b4('0x8b')]();_0x49523b['push'](db[_0xb5b4('0x76')][_0xb5b4('0x3f')](_0x3c9a25));}return BPromise[_0xb5b4('0x98')](_0x49523b);}})[_0xb5b4('0x2a')](function(){return _0x34a714;})['then'](respondWithResult(_0x5a417c,null))['catch'](handleError(_0x5a417c,null));};exports[_0xb5b4('0xb8')]=function(_0x2b9ed3,_0x1d9563,_0x1ccb25){return db[_0xb5b4('0x4d')][_0xb5b4('0x33')]({'where':{'id':_0x2b9ed3[_0xb5b4('0x52')]['id']}})[_0xb5b4('0x2a')](handleEntityNotFound(_0x1d9563,null))[_0xb5b4('0x2a')](function(_0x5532d3){if(_0x5532d3){return _0x5532d3[_0xb5b4('0xb8')](_0x2b9ed3[_0xb5b4('0x3f')][_0xb5b4('0x83')]);}})['then'](function(_0x4d146b){if(_0x4d146b){return db[_0xb5b4('0x6a')][_0xb5b4('0x29')]({'where':{'ListId':_0x2b9ed3[_0xb5b4('0x3f')][_0xb5b4('0x83')],'VoiceQueueId':_0x2b9ed3[_0xb5b4('0x52')]['id']}})[_0xb5b4('0x2a')](function(){return _0x4d146b;});}})[_0xb5b4('0x2a')](respondWithStatusCode(_0x1d9563,null))[_0xb5b4('0x5b')](handleError(_0x1d9563,null));};