Built motion from commit da617fac.|2.6.6
[motion2.git] / server / api / voiceQueue / voiceQueue.controller.js
index 1ccb1a1..f8d9543 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x86b7=['register','sendStatus','status','json','offset','undefined','limit','count','set','Content-Range','save','update','then','VoiceQueues','inbound','QueueCampaigns','outbound','filter','ignore','map','value','includes','type','find','name','UserProfileResource','destroy','error','stack','index','VoiceQueue','rawAttributes','fieldName','key','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','merge','include','findAll','rows','catch','show','includeAll','options','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','get','UserProfileSection','userProfileId','clone','params','omit','createdAt','updatedAt','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','getHoppers','CmHopper','VoiceQueueId','getHopperHistories','findOne','CmHopperHistory','getHopperFinals','CmHopperFinal','getHopperBlacks','CmHopperBlack','getTeams','Team','addTeams','online','voicePause','interface','flatMap','Agents','forEach','penalty','sequelize','transaction','TeamVoiceQueue','upsert','UserVoiceQueue','each','UserVoiceQueueRt','isNil','format','SIP/%s','emit','removeTeams','ids','User','select','field','tq.TeamId','from','join','user_has_teams','ut.TeamId\x20=\x20tq.TeamId','ut.UserId\x20=\x20?','push','toString','QueryTypes','SELECT','TeamId','all','union','compact','removeAgents','userVoiceQueue:remove','addAgents','spread','userVoiceQueue:save','isEmpty','isArray','getAgents','getMembers','getLists','CmList','addLists','dialCheckDuplicateType','always','into','cm_hopper','phone','scheduledAt','ContactId','CmListId','NOW()','cm_contacts','deletedAt\x20IS\x20NULL','ListId\x20=\x20?','phone\x20NOT\x20IN\x20(?)','COALESCE(calleridnum,\x27\x27)','cm_hopper_final','VoiceQueueId\x20=\x20?','COALESCE(phone,\x27\x27)','onlyIfOpen','insert','ListId','phone\x20IS\x20NOT\x20NULL','fromQuery','removeLists','getBlackLists','addBlackLists','cm_hopper_black','removeBlackLists','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','fs-extra','lodash','crypto','jsforce','to-csv','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','../../config/environment','../../mysqldb','redis','defaults','localhost','socket.io-emitter','./voiceQueue.socket'];(function(_0x10bc2e,_0x47b94e){var _0x3c6aaf=function(_0x1fd869){while(--_0x1fd869){_0x10bc2e['push'](_0x10bc2e['shift']());}};_0x3c6aaf(++_0x47b94e);}(_0x86b7,0xa0));var _0x786b=function(_0x5331b2,_0x457265){_0x5331b2=_0x5331b2-0x0;var _0x1095f8=_0x86b7[_0x5331b2];return _0x1095f8;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x786b('0x0'));var zipdir=require(_0x786b('0x1'));var jsonpatch=require(_0x786b('0x2'));var rp=require(_0x786b('0x3'));var moment=require(_0x786b('0x4'));var BPromise=require(_0x786b('0x5'));var Mustache=require(_0x786b('0x6'));var util=require('util');var path=require('path');var sox=require('sox');var csv=require('to-csv');var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x786b('0x7'));var _=require(_0x786b('0x8'));var squel=require('squel');var crypto=require(_0x786b('0x9'));var jsforce=require(_0x786b('0xa'));var deskjs=require('desk.js');var toCsv=require(_0x786b('0xb'));var querystring=require(_0x786b('0xc'));var Papa=require(_0x786b('0xd'));var Redis=require('ioredis');var authService=require(_0x786b('0xe'));var qs=require(_0x786b('0xf'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x786b('0x10'));var logger=require(_0x786b('0x11'))(_0x786b('0x12'));var utils=require('../../config/utils');var config=require(_0x786b('0x13'));var licenseUtil=require('../../config/license/util');var db=require(_0x786b('0x14'))['db'];config[_0x786b('0x15')]=_[_0x786b('0x16')](config['redis'],{'host':_0x786b('0x17'),'port':0x18eb});var socket=require(_0x786b('0x18'))(new Redis(config[_0x786b('0x15')]));require(_0x786b('0x19'))[_0x786b('0x1a')](socket);function respondWithStatusCode(_0x3ea97a,_0x223129){_0x223129=_0x223129||0xcc;return function(_0x39aeb4){if(_0x39aeb4){return _0x3ea97a[_0x786b('0x1b')](_0x223129);}return _0x3ea97a[_0x786b('0x1c')](_0x223129)['end']();};}function respondWithResult(_0x56132c,_0xe06459){_0xe06459=_0xe06459||0xc8;return function(_0x1d2312){if(_0x1d2312){return _0x56132c[_0x786b('0x1c')](_0xe06459)[_0x786b('0x1d')](_0x1d2312);}};}function respondWithFilteredResult(_0x4948f4,_0x3bb984){return function(_0x3f6cc3){if(_0x3f6cc3){var _0x2a2dd7=typeof _0x3bb984[_0x786b('0x1e')]===_0x786b('0x1f')&&typeof _0x3bb984[_0x786b('0x20')]===_0x786b('0x1f');var _0x2175f7=_0x3f6cc3[_0x786b('0x21')];var _0x1abe8b=_0x2a2dd7?0x0:_0x3bb984[_0x786b('0x1e')];var _0x4a6066=_0x2a2dd7?_0x3f6cc3[_0x786b('0x21')]:_0x3bb984[_0x786b('0x1e')]+_0x3bb984[_0x786b('0x20')];var _0x31c27a;if(_0x4a6066>=_0x2175f7){_0x4a6066=_0x2175f7;_0x31c27a=0xc8;}else{_0x31c27a=0xce;}_0x4948f4[_0x786b('0x1c')](_0x31c27a);return _0x4948f4[_0x786b('0x22')](_0x786b('0x23'),_0x1abe8b+'-'+_0x4a6066+'/'+_0x2175f7)[_0x786b('0x1d')](_0x3f6cc3);}return null;};}function patchUpdates(_0x59bc30){return function(_0x299e08){try{jsonpatch['apply'](_0x299e08,_0x59bc30,!![]);}catch(_0x504ff5){return BPromise['reject'](_0x504ff5);}return _0x299e08[_0x786b('0x24')]();};}function saveUpdates(_0x30c2b5,_0x3b3d98){return function(_0x82919e){if(_0x82919e){return _0x82919e[_0x786b('0x25')](_0x30c2b5)[_0x786b('0x26')](function(_0x4a750e){return _0x4a750e;});}return null;};}function removeEntity(_0x45c75a,_0x49b22b){return function(_0x2c9ad1){if(_0x2c9ad1){return _0x2c9ad1['destroy']()[_0x786b('0x26')](function(){var _0xd4d337=_0x2c9ad1['get']({'plain':!![]});var _0x30e69a=[{'name':_0x786b('0x27'),'value':_0x786b('0x28'),'ignore':![]},{'name':_0x786b('0x29'),'value':_0x786b('0x2a'),'ignore':![]}];var _0x273a39=_(_0x30e69a)[_0x786b('0x2b')](_0x786b('0x2c'))[_0x786b('0x2d')](_0x786b('0x2e'))[_0x786b('0x2e')]();if(_[_0x786b('0x2f')](_0x273a39,_0xd4d337[_0x786b('0x30')])){return;}var _0x24fafc=_[_0x786b('0x31')](_0x30e69a,[_0x786b('0x2e'),_0xd4d337[_0x786b('0x30')]])[_0x786b('0x32')];return db[_0x786b('0x33')][_0x786b('0x34')]({'where':{'type':_0x24fafc,'resourceId':_0xd4d337['id']}})['then'](function(){return _0x2c9ad1;});})[_0x786b('0x26')](function(){_0x45c75a[_0x786b('0x1c')](0xcc)['end']();});}};}function handleEntityNotFound(_0x4c614d,_0x1b71d6){return function(_0x223145){if(!_0x223145){_0x4c614d[_0x786b('0x1b')](0x194);}return _0x223145;};}function handleError(_0x4e350,_0x517cd3){_0x517cd3=_0x517cd3||0x1f4;return function(_0x19ecd0){logger[_0x786b('0x35')](_0x19ecd0[_0x786b('0x36')]);if(_0x19ecd0[_0x786b('0x32')]){delete _0x19ecd0[_0x786b('0x32')];}_0x4e350['status'](_0x517cd3)['send'](_0x19ecd0);};}exports[_0x786b('0x37')]=function(_0x5878d4,_0x2136c8){var _0x580c27={},_0xf294b3={},_0x575480={'count':0x0,'rows':[]};var _0x2a0cbf=_['map'](db[_0x786b('0x38')][_0x786b('0x39')],function(_0x2653d8){return{'name':_0x2653d8[_0x786b('0x3a')],'type':_0x2653d8[_0x786b('0x30')][_0x786b('0x3b')]};});_0xf294b3[_0x786b('0x3c')]=_['map'](_0x2a0cbf,_0x786b('0x32'));_0xf294b3[_0x786b('0x3d')]=_[_0x786b('0x3e')](_0x5878d4['query']);_0xf294b3[_0x786b('0x3f')]=_[_0x786b('0x40')](_0xf294b3[_0x786b('0x3c')],_0xf294b3['query']);_0x580c27[_0x786b('0x41')]=_[_0x786b('0x40')](_0xf294b3[_0x786b('0x3c')],qs[_0x786b('0x42')](_0x5878d4[_0x786b('0x3d')]['fields']));_0x580c27[_0x786b('0x41')]=_0x580c27[_0x786b('0x41')][_0x786b('0x43')]?_0x580c27[_0x786b('0x41')]:_0xf294b3[_0x786b('0x3c')];if(!_0x5878d4['query'][_0x786b('0x44')](_0x786b('0x45'))){_0x580c27['limit']=qs['limit'](_0x5878d4[_0x786b('0x3d')]['limit']);_0x580c27['offset']=qs['offset'](_0x5878d4['query'][_0x786b('0x1e')]);}_0x580c27[_0x786b('0x46')]=qs[_0x786b('0x47')](_0x5878d4[_0x786b('0x3d')][_0x786b('0x47')]);_0x580c27[_0x786b('0x48')]=qs[_0x786b('0x3f')](_[_0x786b('0x49')](_0x5878d4['query'],_0xf294b3['filters']),_0x2a0cbf);if(_0x5878d4[_0x786b('0x3d')][_0x786b('0x2b')]){_0x580c27[_0x786b('0x48')]=_[_0x786b('0x4a')](_0x580c27[_0x786b('0x48')],{'$or':_[_0x786b('0x2d')](_0x2a0cbf,function(_0x303fc6){if(_0x303fc6[_0x786b('0x30')]!=='VIRTUAL'){var _0x3f6a81={};_0x3f6a81[_0x303fc6[_0x786b('0x32')]]={'$like':'%'+_0x5878d4['query'][_0x786b('0x2b')]+'%'};return _0x3f6a81;}})});}_0x580c27=_['merge']({},_0x580c27,_0x5878d4['options']);var _0x1c642b={'where':_0x580c27[_0x786b('0x48')]};return db[_0x786b('0x38')][_0x786b('0x21')](_0x1c642b)['then'](function(_0x36962c){_0x575480[_0x786b('0x21')]=_0x36962c;if(_0x5878d4[_0x786b('0x3d')]['includeAll']){_0x580c27[_0x786b('0x4b')]=[{'all':!![]}];}return db[_0x786b('0x38')][_0x786b('0x4c')](_0x580c27);})[_0x786b('0x26')](function(_0x461ac3){_0x575480[_0x786b('0x4d')]=_0x461ac3;return _0x575480;})[_0x786b('0x26')](respondWithFilteredResult(_0x2136c8,_0x580c27))[_0x786b('0x4e')](handleError(_0x2136c8,null));};exports[_0x786b('0x4f')]=function(_0x298a6b,_0x54bd27){var _0x20f256={'raw':![],'where':{'id':_0x298a6b['params']['id']}},_0x4d4367={};_0x4d4367['model']=_[_0x786b('0x3e')](db[_0x786b('0x38')][_0x786b('0x39')]);_0x4d4367[_0x786b('0x3d')]=_[_0x786b('0x3e')](_0x298a6b[_0x786b('0x3d')]);_0x4d4367[_0x786b('0x3f')]=_['intersection'](_0x4d4367[_0x786b('0x3c')],_0x4d4367[_0x786b('0x3d')]);_0x20f256[_0x786b('0x41')]=_[_0x786b('0x40')](_0x4d4367[_0x786b('0x3c')],qs['fields'](_0x298a6b[_0x786b('0x3d')][_0x786b('0x42')]));_0x20f256[_0x786b('0x41')]=_0x20f256[_0x786b('0x41')][_0x786b('0x43')]?_0x20f256['attributes']:_0x4d4367[_0x786b('0x3c')];if(_0x298a6b['query'][_0x786b('0x50')]){_0x20f256['include']=[{'all':!![]}];}_0x20f256=_[_0x786b('0x4a')]({},_0x20f256,_0x298a6b[_0x786b('0x51')]);return db[_0x786b('0x38')][_0x786b('0x31')](_0x20f256)[_0x786b('0x26')](handleEntityNotFound(_0x54bd27,null))[_0x786b('0x26')](respondWithResult(_0x54bd27,null))['catch'](handleError(_0x54bd27,null));};exports[_0x786b('0x52')]=function(_0x2d7f4e,_0x497dfd){return db['VoiceQueue'][_0x786b('0x52')](_0x2d7f4e[_0x786b('0x53')],{})[_0x786b('0x26')](function(_0xed143f){var _0x579fbe=_0x2d7f4e[_0x786b('0x54')]['get']({'plain':!![]});if(!_0x579fbe)throw new Error(_0x786b('0x55'));if(_0x579fbe[_0x786b('0x56')]===_0x786b('0x54')){var _0x5aafe2=_0xed143f[_0x786b('0x57')]({'plain':!![]});var _0x5ce938=[{'name':_0x786b('0x27'),'value':_0x786b('0x28')},{'name':_0x786b('0x29'),'value':_0x786b('0x2a')}];var _0x58f763=_[_0x786b('0x31')](_0x5ce938,[_0x786b('0x2e'),_0x5aafe2['type']])[_0x786b('0x32')];return db[_0x786b('0x58')]['find']({'where':{'name':_0x58f763,'userProfileId':_0x579fbe[_0x786b('0x59')]},'raw':!![]})[_0x786b('0x26')](function(_0x4d274d){if(_0x4d274d&&_0x4d274d['autoAssociation']===0x0){return db[_0x786b('0x33')]['create']({'name':_0x5aafe2['name'],'resourceId':_0x5aafe2['id'],'type':_0x4d274d[_0x786b('0x32')],'sectionId':_0x4d274d['id']},{})[_0x786b('0x26')](function(){return _0xed143f;});}else{return _0xed143f;}})[_0x786b('0x4e')](function(_0x406555){logger[_0x786b('0x35')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x406555);throw _0x406555;});}return _0xed143f;})['then'](respondWithResult(_0x497dfd,0xc9))[_0x786b('0x4e')](handleError(_0x497dfd,null));};exports[_0x786b('0x5a')]=function(_0x16907b,_0x3047be){var _0x1d6691={'where':{'id':_0x16907b[_0x786b('0x5b')]['id']}},_0x12a24c={};_0x12a24c[_0x786b('0x3c')]=_[_0x786b('0x3e')](db['VoiceQueue'][_0x786b('0x39')]);_0x1d6691[_0x786b('0x41')]=_[_0x786b('0x40')](_0x12a24c[_0x786b('0x3c')],qs[_0x786b('0x42')](_0x16907b['query'][_0x786b('0x42')]));_0x1d6691['attributes']=_0x1d6691['attributes']['length']?_0x1d6691[_0x786b('0x41')]:_0x12a24c['model'];if(_0x16907b[_0x786b('0x3d')][_0x786b('0x50')]){_0x1d6691['include']=[{'all':!![]}];}_0x1d6691=_[_0x786b('0x4a')]({},_0x1d6691,_0x16907b['options']);return db[_0x786b('0x38')][_0x786b('0x31')](_0x1d6691)['then'](handleEntityNotFound(_0x3047be,null))[_0x786b('0x26')](function(_0xe3aa89){if(_0xe3aa89){var _0x52107a=_0xe3aa89[_0x786b('0x57')]({'plain':!![]});_0x52107a=qs[_0x786b('0x5c')](_0x52107a,['id',_0x786b('0x5d'),_0x786b('0x5e')]);_0x16907b[_0x786b('0x53')]=_[_0x786b('0x5c')](_0x16907b[_0x786b('0x53')],['id','createdAt','updatedAt']);return db[_0x786b('0x38')][_0x786b('0x52')](_[_0x786b('0x4a')](_0x52107a,_0x16907b['body']),{'include':_0x16907b[_0x786b('0x3d')]['includeAll']?[{'all':!![]}]:undefined})[_0x786b('0x26')](function(_0x402c3a){var _0x2e02c3=_0x16907b[_0x786b('0x54')][_0x786b('0x57')]({'plain':!![]});if(!_0x2e02c3)throw new Error(_0x786b('0x55'));if(_0x2e02c3[_0x786b('0x56')]===_0x786b('0x54')){var _0x578bcf=_0x402c3a[_0x786b('0x57')]({'plain':!![]});var _0x2c69c0=[{'name':'VoiceQueues','value':_0x786b('0x28')},{'name':'QueueCampaigns','value':_0x786b('0x2a')}];var _0x1d33dc=_[_0x786b('0x31')](_0x2c69c0,[_0x786b('0x2e'),_0x578bcf[_0x786b('0x30')]])[_0x786b('0x32')];return db[_0x786b('0x58')][_0x786b('0x31')]({'where':{'name':_0x1d33dc,'userProfileId':_0x2e02c3[_0x786b('0x59')]},'raw':!![]})[_0x786b('0x26')](function(_0x45ed84){if(_0x45ed84&&_0x45ed84[_0x786b('0x5f')]===0x0){return db[_0x786b('0x33')][_0x786b('0x52')]({'name':_0x578bcf[_0x786b('0x32')],'resourceId':_0x578bcf['id'],'type':_0x45ed84[_0x786b('0x32')],'sectionId':_0x45ed84['id']},{})[_0x786b('0x26')](function(){return _0x402c3a;});}else{return _0x402c3a;}})[_0x786b('0x4e')](function(_0x14c39f){logger[_0x786b('0x35')](_0x786b('0x60'),_0x14c39f);throw _0x14c39f;});}return _0x402c3a;});}})['then'](respondWithResult(_0x3047be,0xc9))[_0x786b('0x4e')](handleError(_0x3047be,null));};exports[_0x786b('0x25')]=function(_0x11d129,_0x1fc826){if(_0x11d129[_0x786b('0x53')]['id']){delete _0x11d129[_0x786b('0x53')]['id'];}return db['VoiceQueue'][_0x786b('0x31')]({'where':{'id':_0x11d129[_0x786b('0x5b')]['id']}})[_0x786b('0x26')](handleEntityNotFound(_0x1fc826,null))['then'](saveUpdates(_0x11d129[_0x786b('0x53')],null))[_0x786b('0x26')](respondWithResult(_0x1fc826,null))[_0x786b('0x4e')](handleError(_0x1fc826,null));};exports['destroy']=function(_0x158b11,_0x103780){return db[_0x786b('0x38')][_0x786b('0x31')]({'where':{'id':_0x158b11[_0x786b('0x5b')]['id']}})['then'](handleEntityNotFound(_0x103780,null))['then'](removeEntity(_0x103780,null))['catch'](handleError(_0x103780,null));};exports[_0x786b('0x61')]=function(_0x4234ca,_0x33f456,_0x2e9370){var _0x14ab60={'raw':![],'where':{}};var _0xfbd53c={};var _0x1fdfa6={'count':0x0,'rows':[]};return db[_0x786b('0x38')]['findOne']({'where':{'id':_0x4234ca[_0x786b('0x5b')]['id']}})['then'](handleEntityNotFound(_0x33f456,null))['then'](function(_0x23a4b2){if(_0x23a4b2){_0xfbd53c[_0x786b('0x3c')]=_[_0x786b('0x3e')](db[_0x786b('0x62')]['rawAttributes']);_0xfbd53c['query']=_['keys'](_0x4234ca['query']);_0xfbd53c[_0x786b('0x3f')]=_['intersection'](_0xfbd53c[_0x786b('0x3c')],_0xfbd53c[_0x786b('0x3d')]);_0x14ab60[_0x786b('0x41')]=_[_0x786b('0x40')](_0xfbd53c['model'],qs[_0x786b('0x42')](_0x4234ca['query'][_0x786b('0x42')]));_0x14ab60[_0x786b('0x41')]=_0x14ab60[_0x786b('0x41')]['length']?_0x14ab60[_0x786b('0x41')]:_0xfbd53c[_0x786b('0x3c')];if(!_0x4234ca[_0x786b('0x3d')]['hasOwnProperty'](_0x786b('0x45'))){_0x14ab60[_0x786b('0x20')]=qs[_0x786b('0x20')](_0x4234ca[_0x786b('0x3d')]['limit']);_0x14ab60[_0x786b('0x1e')]=qs['offset'](_0x4234ca[_0x786b('0x3d')][_0x786b('0x1e')]);}_0x14ab60[_0x786b('0x46')]=qs[_0x786b('0x47')](_0x4234ca[_0x786b('0x3d')][_0x786b('0x47')]);_0x14ab60[_0x786b('0x48')]=qs[_0x786b('0x3f')](_[_0x786b('0x49')](_0x4234ca[_0x786b('0x3d')],_0xfbd53c[_0x786b('0x3f')]));_0x14ab60[_0x786b('0x48')][_0x786b('0x63')]=_0x23a4b2['id'];if(_0x4234ca['query'][_0x786b('0x2b')]){_0x14ab60[_0x786b('0x48')]=_[_0x786b('0x4a')](_0x14ab60['where'],{'$or':_[_0x786b('0x2d')](_0x14ab60[_0x786b('0x41')],function(_0x2e8eea){var _0x39a2e2={};_0x39a2e2[_0x2e8eea]={'$like':'%'+_0x4234ca['query'][_0x786b('0x2b')]+'%'};return _0x39a2e2;})});}_0x14ab60=_[_0x786b('0x4a')]({},_0x14ab60,_0x4234ca[_0x786b('0x51')]);return db[_0x786b('0x62')][_0x786b('0x21')]({'where':_0x14ab60[_0x786b('0x48')]})[_0x786b('0x26')](function(_0x13c5c3){_0x1fdfa6[_0x786b('0x21')]=_0x13c5c3;if(_0x4234ca[_0x786b('0x3d')][_0x786b('0x50')]){_0x14ab60[_0x786b('0x4b')]=[{'all':!![]}];}return db[_0x786b('0x62')]['findAll'](_0x14ab60);})[_0x786b('0x26')](function(_0x51340f){_0x1fdfa6[_0x786b('0x4d')]=_0x51340f;return _0x1fdfa6;});}})[_0x786b('0x26')](respondWithFilteredResult(_0x33f456,_0x14ab60))[_0x786b('0x4e')](handleError(_0x33f456,null));};exports[_0x786b('0x64')]=function(_0x3df691,_0x2cef07,_0x13b9b2){var _0x5b8974={'raw':!![],'where':{}};var _0x59c729={};var _0x28a388={'count':0x0,'rows':[]};return db[_0x786b('0x38')][_0x786b('0x65')]({'where':{'id':_0x3df691[_0x786b('0x5b')]['id']}})[_0x786b('0x26')](handleEntityNotFound(_0x2cef07,null))[_0x786b('0x26')](function(_0x363183){if(_0x363183){_0x59c729[_0x786b('0x3c')]=_['keys'](db['CmHopperHistory'][_0x786b('0x39')]);_0x59c729['query']=_[_0x786b('0x3e')](_0x3df691[_0x786b('0x3d')]);_0x59c729[_0x786b('0x3f')]=_[_0x786b('0x40')](_0x59c729[_0x786b('0x3c')],_0x59c729[_0x786b('0x3d')]);_0x5b8974['attributes']=_[_0x786b('0x40')](_0x59c729[_0x786b('0x3c')],qs[_0x786b('0x42')](_0x3df691[_0x786b('0x3d')][_0x786b('0x42')]));_0x5b8974[_0x786b('0x41')]=_0x5b8974[_0x786b('0x41')][_0x786b('0x43')]?_0x5b8974[_0x786b('0x41')]:_0x59c729[_0x786b('0x3c')];if(!_0x3df691[_0x786b('0x3d')][_0x786b('0x44')](_0x786b('0x45'))){_0x5b8974['limit']=qs[_0x786b('0x20')](_0x3df691[_0x786b('0x3d')][_0x786b('0x20')]);_0x5b8974[_0x786b('0x1e')]=qs['offset'](_0x3df691[_0x786b('0x3d')][_0x786b('0x1e')]);}_0x5b8974[_0x786b('0x46')]=qs[_0x786b('0x47')](_0x3df691[_0x786b('0x3d')][_0x786b('0x47')]);_0x5b8974[_0x786b('0x48')]=qs['filters'](_[_0x786b('0x49')](_0x3df691[_0x786b('0x3d')],_0x59c729['filters']));_0x5b8974['where'][_0x786b('0x63')]=_0x363183['id'];if(_0x3df691[_0x786b('0x3d')][_0x786b('0x2b')]){_0x5b8974['where']=_[_0x786b('0x4a')](_0x5b8974['where'],{'$or':_['map'](_0x5b8974['attributes'],function(_0x306355){var _0x494710={};_0x494710[_0x306355]={'$like':'%'+_0x3df691['query'][_0x786b('0x2b')]+'%'};return _0x494710;})});}_0x5b8974=_[_0x786b('0x4a')]({},_0x5b8974,_0x3df691[_0x786b('0x51')]);return db['CmHopperHistory'][_0x786b('0x21')]({'where':_0x5b8974[_0x786b('0x48')]})['then'](function(_0x1753a8){_0x28a388[_0x786b('0x21')]=_0x1753a8;if(_0x3df691['query'][_0x786b('0x50')]){_0x5b8974['include']=[{'all':!![]}];}return db[_0x786b('0x66')][_0x786b('0x4c')](_0x5b8974);})[_0x786b('0x26')](function(_0x42828c){_0x28a388[_0x786b('0x4d')]=_0x42828c;return _0x28a388;});}})['then'](respondWithFilteredResult(_0x2cef07,_0x5b8974))[_0x786b('0x4e')](handleError(_0x2cef07,null));};exports[_0x786b('0x67')]=function(_0x544e3b,_0x5a1ba5,_0x595dcc){var _0x5f2050={'raw':!![],'where':{}};var _0x13c1fc={};var _0x56dad7={'count':0x0,'rows':[]};return db['VoiceQueue'][_0x786b('0x65')]({'where':{'id':_0x544e3b[_0x786b('0x5b')]['id']}})[_0x786b('0x26')](handleEntityNotFound(_0x5a1ba5,null))[_0x786b('0x26')](function(_0x5d51eb){if(_0x5d51eb){_0x13c1fc[_0x786b('0x3c')]=_[_0x786b('0x3e')](db['CmHopperFinal'][_0x786b('0x39')]);_0x13c1fc['query']=_[_0x786b('0x3e')](_0x544e3b[_0x786b('0x3d')]);_0x13c1fc[_0x786b('0x3f')]=_[_0x786b('0x40')](_0x13c1fc[_0x786b('0x3c')],_0x13c1fc[_0x786b('0x3d')]);_0x5f2050['attributes']=_['intersection'](_0x13c1fc[_0x786b('0x3c')],qs[_0x786b('0x42')](_0x544e3b[_0x786b('0x3d')]['fields']));_0x5f2050[_0x786b('0x41')]=_0x5f2050[_0x786b('0x41')]['length']?_0x5f2050[_0x786b('0x41')]:_0x13c1fc['model'];if(!_0x544e3b[_0x786b('0x3d')][_0x786b('0x44')](_0x786b('0x45'))){_0x5f2050['limit']=qs[_0x786b('0x20')](_0x544e3b[_0x786b('0x3d')][_0x786b('0x20')]);_0x5f2050[_0x786b('0x1e')]=qs[_0x786b('0x1e')](_0x544e3b[_0x786b('0x3d')][_0x786b('0x1e')]);}_0x5f2050['order']=qs['sort'](_0x544e3b[_0x786b('0x3d')]['sort']);_0x5f2050[_0x786b('0x48')]=qs[_0x786b('0x3f')](_[_0x786b('0x49')](_0x544e3b[_0x786b('0x3d')],_0x13c1fc[_0x786b('0x3f')]));_0x5f2050[_0x786b('0x48')][_0x786b('0x63')]=_0x5d51eb['id'];if(_0x544e3b[_0x786b('0x3d')][_0x786b('0x2b')]){_0x5f2050[_0x786b('0x48')]=_['merge'](_0x5f2050[_0x786b('0x48')],{'$or':_[_0x786b('0x2d')](_0x5f2050['attributes'],function(_0x5215ca){var _0x3a9b0c={};_0x3a9b0c[_0x5215ca]={'$like':'%'+_0x544e3b[_0x786b('0x3d')]['filter']+'%'};return _0x3a9b0c;})});}_0x5f2050=_['merge']({},_0x5f2050,_0x544e3b[_0x786b('0x51')]);return db[_0x786b('0x68')][_0x786b('0x21')]({'where':_0x5f2050[_0x786b('0x48')]})[_0x786b('0x26')](function(_0x5c961b){_0x56dad7[_0x786b('0x21')]=_0x5c961b;if(_0x544e3b[_0x786b('0x3d')][_0x786b('0x50')]){_0x5f2050[_0x786b('0x4b')]=[{'all':!![]}];}return db['CmHopperFinal'][_0x786b('0x4c')](_0x5f2050);})['then'](function(_0x4c6571){_0x56dad7[_0x786b('0x4d')]=_0x4c6571;return _0x56dad7;});}})[_0x786b('0x26')](respondWithFilteredResult(_0x5a1ba5,_0x5f2050))[_0x786b('0x4e')](handleError(_0x5a1ba5,null));};exports[_0x786b('0x69')]=function(_0x169eab,_0x2db73f,_0x2c2c9b){var _0x46c3e1={'raw':!![],'where':{}};var _0x4cd0b1={};var _0x1ca252={'count':0x0,'rows':[]};return db[_0x786b('0x38')][_0x786b('0x65')]({'where':{'id':_0x169eab['params']['id']}})['then'](handleEntityNotFound(_0x2db73f,null))['then'](function(_0x412367){if(_0x412367){_0x4cd0b1[_0x786b('0x3c')]=_[_0x786b('0x3e')](db[_0x786b('0x6a')][_0x786b('0x39')]);_0x4cd0b1['query']=_[_0x786b('0x3e')](_0x169eab[_0x786b('0x3d')]);_0x4cd0b1[_0x786b('0x3f')]=_['intersection'](_0x4cd0b1[_0x786b('0x3c')],_0x4cd0b1['query']);_0x46c3e1[_0x786b('0x41')]=_['intersection'](_0x4cd0b1['model'],qs['fields'](_0x169eab[_0x786b('0x3d')][_0x786b('0x42')]));_0x46c3e1[_0x786b('0x41')]=_0x46c3e1[_0x786b('0x41')][_0x786b('0x43')]?_0x46c3e1[_0x786b('0x41')]:_0x4cd0b1[_0x786b('0x3c')];if(!_0x169eab[_0x786b('0x3d')][_0x786b('0x44')](_0x786b('0x45'))){_0x46c3e1[_0x786b('0x20')]=qs[_0x786b('0x20')](_0x169eab[_0x786b('0x3d')][_0x786b('0x20')]);_0x46c3e1[_0x786b('0x1e')]=qs[_0x786b('0x1e')](_0x169eab['query']['offset']);}_0x46c3e1['order']=qs['sort'](_0x169eab['query'][_0x786b('0x47')]);_0x46c3e1[_0x786b('0x48')]=qs[_0x786b('0x3f')](_[_0x786b('0x49')](_0x169eab[_0x786b('0x3d')],_0x4cd0b1[_0x786b('0x3f')]));_0x46c3e1[_0x786b('0x48')][_0x786b('0x63')]=_0x412367['id'];if(_0x169eab[_0x786b('0x3d')][_0x786b('0x2b')]){_0x46c3e1[_0x786b('0x48')]=_[_0x786b('0x4a')](_0x46c3e1[_0x786b('0x48')],{'$or':_[_0x786b('0x2d')](_0x46c3e1['attributes'],function(_0x318944){var _0x53586f={};_0x53586f[_0x318944]={'$like':'%'+_0x169eab[_0x786b('0x3d')][_0x786b('0x2b')]+'%'};return _0x53586f;})});}_0x46c3e1=_[_0x786b('0x4a')]({},_0x46c3e1,_0x169eab[_0x786b('0x51')]);return db[_0x786b('0x6a')][_0x786b('0x21')]({'where':_0x46c3e1[_0x786b('0x48')]})[_0x786b('0x26')](function(_0x35f528){_0x1ca252[_0x786b('0x21')]=_0x35f528;if(_0x169eab[_0x786b('0x3d')][_0x786b('0x50')]){_0x46c3e1[_0x786b('0x4b')]=[{'all':!![]}];}return db[_0x786b('0x6a')][_0x786b('0x4c')](_0x46c3e1);})[_0x786b('0x26')](function(_0x4208fb){_0x1ca252[_0x786b('0x4d')]=_0x4208fb;return _0x1ca252;});}})['then'](respondWithFilteredResult(_0x2db73f,_0x46c3e1))['catch'](handleError(_0x2db73f,null));};exports[_0x786b('0x6b')]=function(_0x1a5238,_0x31aaf,_0x15ebfe){var _0x22711b={};var _0xbccfa4={};var _0x3f87f8;var _0x3d6051;return db[_0x786b('0x38')][_0x786b('0x65')]({'where':{'id':_0x1a5238['params']['id']}})[_0x786b('0x26')](handleEntityNotFound(_0x31aaf,null))[_0x786b('0x26')](function(_0xc1b5d6){if(_0xc1b5d6){_0x3f87f8=_0xc1b5d6;_0xbccfa4[_0x786b('0x3c')]=_[_0x786b('0x3e')](db[_0x786b('0x6c')][_0x786b('0x39')]);_0xbccfa4[_0x786b('0x3d')]=_[_0x786b('0x3e')](_0x1a5238[_0x786b('0x3d')]);_0xbccfa4[_0x786b('0x3f')]=_[_0x786b('0x40')](_0xbccfa4[_0x786b('0x3c')],_0xbccfa4['query']);_0x22711b['attributes']=_[_0x786b('0x40')](_0xbccfa4[_0x786b('0x3c')],qs['fields'](_0x1a5238['query'][_0x786b('0x42')]));_0x22711b[_0x786b('0x41')]=_0x22711b['attributes']['length']?_0x22711b[_0x786b('0x41')]:_0xbccfa4[_0x786b('0x3c')];_0x22711b[_0x786b('0x46')]=qs['sort'](_0x1a5238[_0x786b('0x3d')]['sort']);_0x22711b[_0x786b('0x48')]=qs['filters'](_[_0x786b('0x49')](_0x1a5238[_0x786b('0x3d')],_0xbccfa4['filters']));if(_0x1a5238[_0x786b('0x3d')][_0x786b('0x2b')]){_0x22711b[_0x786b('0x48')]=_['merge'](_0x22711b[_0x786b('0x48')],{'$or':_[_0x786b('0x2d')](_0x22711b[_0x786b('0x41')],function(_0x10e69b){var _0x1a49c6={};_0x1a49c6[_0x10e69b]={'$like':'%'+_0x1a5238[_0x786b('0x3d')][_0x786b('0x2b')]+'%'};return _0x1a49c6;})});}_0x22711b=_[_0x786b('0x4a')]({},_0x22711b,_0x1a5238['options']);return _0x3f87f8[_0x786b('0x6b')](_0x22711b);}})['then'](function(_0x1c0edc){if(_0x1c0edc){_0x3d6051=_0x1c0edc['length'];if(!_0x1a5238[_0x786b('0x3d')][_0x786b('0x44')]('nolimit')){_0x22711b[_0x786b('0x20')]=qs['limit'](_0x1a5238['query'][_0x786b('0x20')]);_0x22711b[_0x786b('0x1e')]=qs[_0x786b('0x1e')](_0x1a5238['query'][_0x786b('0x1e')]);}return _0x3f87f8['getTeams'](_0x22711b);}})[_0x786b('0x26')](function(_0x10bc4a){if(_0x10bc4a){return _0x10bc4a?{'count':_0x3d6051,'rows':_0x10bc4a}:null;}})[_0x786b('0x26')](respondWithResult(_0x31aaf,null))['catch'](handleError(_0x31aaf,null));};exports[_0x786b('0x6d')]=function(_0x5c70d4,_0x44e5f6,_0x2cf998){var _0x4e2402=_0x5c70d4[_0x786b('0x53')]['teams'];var _0x519138=_[_0x786b('0x2d')](_0x4e2402,'id');return db[_0x786b('0x6c')][_0x786b('0x4c')]({'where':{'id':_0x519138},'attributes':['id'],'include':[{'model':db['User'],'as':'Agents','attributes':['id','name',_0x786b('0x6e'),_0x786b('0x6f'),_0x786b('0x70')],'raw':!![]}]})[_0x786b('0x26')](function(_0x36663c){if(_0x36663c){var _0x29126a=_[_0x786b('0x71')](_0x36663c,function(_0x3aa0e0){var _0x593191=_0x3aa0e0[_0x786b('0x57')]({'plain':!![]});_0x593191[_0x786b('0x72')][_0x786b('0x73')](function(_0x5cf38c){_0x5cf38c[_0x786b('0x74')]=_['find'](_0x4e2402,{'id':_0x593191['id']})[_0x786b('0x74')];});return _0x593191['Agents'];});return db[_0x786b('0x38')][_0x786b('0x31')]({'where':{'id':_0x5c70d4['params']['id']}})['then'](function(_0x3bfcae){return db[_0x786b('0x75')][_0x786b('0x76')](function(_0x2bdb99){return _0x3bfcae['addTeams'](_0x519138,{'transaction':_0x2bdb99})[_0x786b('0x26')](function(){return BPromise['each'](_0x4e2402,function(_0x55b76b){return db[_0x786b('0x77')][_0x786b('0x78')]({'TeamId':_0x55b76b['id'],'VoiceQueueId':_0x5c70d4[_0x786b('0x5b')]['id'],'penalty':_0x55b76b[_0x786b('0x74')]},{'transaction':_0x2bdb99});});})[_0x786b('0x26')](function(){return BPromise['each'](_0x29126a,function(_0x22f4cf){return db[_0x786b('0x79')]['findOrCreate']({'where':{'UserId':_0x22f4cf['id'],'VoiceQueueId':_0x5c70d4['params']['id']},'defaults':{'penalty':_0x22f4cf[_0x786b('0x74')]},'transaction':_0x2bdb99});});})[_0x786b('0x26')](function(){return BPromise[_0x786b('0x7a')](_[_0x786b('0x2b')](_0x29126a,{'online':!![]}),function(_0x25ca97){return db[_0x786b('0x7b')][_0x786b('0x78')]({'membername':_0x25ca97[_0x786b('0x32')],'UserId':_0x25ca97['id'],'queue_name':_0x3bfcae[_0x786b('0x32')],'VoiceQueueId':_0x3bfcae['id'],'interface':_[_0x786b('0x7c')](_0x25ca97[_0x786b('0x70')])?util[_0x786b('0x7d')](_0x786b('0x7e'),_0x25ca97[_0x786b('0x32')]):_0x25ca97[_0x786b('0x70')],'paused':_0x25ca97[_0x786b('0x6f')]||![],'penalty':_0x25ca97[_0x786b('0x74')]},{'transaction':_0x2bdb99});});})[_0x786b('0x26')](function(){_0x29126a[_0x786b('0x73')](function(_0x22daf7){socket[_0x786b('0x7f')]('userVoiceQueue:save',{'UserId':_0x22daf7['id'],'VoiceQueueId':_0x3bfcae['id']});});});});});}})[_0x786b('0x26')](respondWithStatusCode(_0x44e5f6,null))[_0x786b('0x4e')](handleError(_0x44e5f6,null));};exports[_0x786b('0x80')]=function(_0x1ef6ba,_0x38b6fa,_0x1885b9){return db['Team'][_0x786b('0x4c')]({'where':{'id':_0x1ef6ba[_0x786b('0x3d')][_0x786b('0x81')]},'attributes':['id'],'include':[{'model':db[_0x786b('0x82')],'as':_0x786b('0x72'),'attributes':['id'],'raw':!![]}]})['then'](handleEntityNotFound(_0x38b6fa,null))[_0x786b('0x26')](function(_0x1d91f5){var _0x4d1cef=_['map'](_0x1d91f5,'id');var _0x4ee793=[];var _0x4f21ca=[];var _0x40491b=squel[_0x786b('0x83')]();_0x40491b[_0x786b('0x84')](_0x786b('0x85'))[_0x786b('0x86')]('team_has_voice_queues','tq')[_0x786b('0x87')](_0x786b('0x88'),'ut',_0x786b('0x89'))[_0x786b('0x48')]('VoiceQueueId\x20=\x20?',_0x1ef6ba[_0x786b('0x5b')]['id']);for(var _0x590786=0x0;_0x590786<_0x1d91f5[_0x786b('0x43')];_0x590786+=0x1){let _0x139f10=_0x1d91f5[_0x590786];for(var _0x5e068b=0x0;_0x5e068b<_0x139f10[_0x786b('0x72')]['length'];_0x5e068b+=0x1){let _0x12e940=_0x139f10[_0x786b('0x72')][_0x5e068b];var _0x2216a3=_0x40491b[_0x786b('0x5a')]();_0x2216a3[_0x786b('0x48')](_0x786b('0x8a'),_0x12e940['id']);_0x4f21ca[_0x786b('0x8b')](db[_0x786b('0x75')][_0x786b('0x3d')](_0x2216a3[_0x786b('0x8c')](),{'type':db[_0x786b('0x75')][_0x786b('0x8d')][_0x786b('0x8e')]})[_0x786b('0x26')](function(_0x2bb9ee){if(_0x2bb9ee[_0x786b('0x43')]===0x1){return _0x12e940['id'];}else{var _0x4cf058=_['every'](_[_0x786b('0x2d')](_0x2bb9ee,_0x786b('0x8f')),function(_0x9ad308){return _[_0x786b('0x2f')](_0x4d1cef,_0x9ad308);});if(_0x4cf058){return _0x12e940['id'];}}}));}}return BPromise[_0x786b('0x90')](_0x4f21ca)['then'](function(_0x39cb75){_0x4ee793=_(_0x4ee793)[_0x786b('0x91')](_0x39cb75)[_0x786b('0x92')]()[_0x786b('0x2e')]();return db[_0x786b('0x38')][_0x786b('0x31')]({'where':{'id':_0x1ef6ba['params']['id']}})[_0x786b('0x26')](function(_0x517b9c){return db[_0x786b('0x75')][_0x786b('0x76')](function(_0x2b722d){return _0x517b9c[_0x786b('0x80')](_0x1ef6ba[_0x786b('0x3d')][_0x786b('0x81')],{'transaction':_0x2b722d})[_0x786b('0x26')](function(){if(!_['isEmpty'](_0x4ee793)){return _0x517b9c[_0x786b('0x93')](_0x4ee793,{'transaction':_0x2b722d})[_0x786b('0x26')](function(){return db[_0x786b('0x7b')][_0x786b('0x34')]({'where':{'VoiceQueueId':_0x1ef6ba[_0x786b('0x5b')]['id'],'UserId':_0x4ee793},'transaction':_0x2b722d});});}})[_0x786b('0x26')](function(){_0x4ee793[_0x786b('0x73')](function(_0x5aa9f2){socket[_0x786b('0x7f')](_0x786b('0x94'),{'UserId':_0x5aa9f2,'VoiceQueueId':_0x517b9c['id']});});});});});});})[_0x786b('0x26')](respondWithStatusCode(_0x38b6fa,null))[_0x786b('0x4e')](handleError(_0x38b6fa,null));};exports[_0x786b('0x95')]=function(_0x117add,_0x24cf63,_0x373e75){var _0x22338a,_0x27c288;return db[_0x786b('0x38')][_0x786b('0x31')]({'where':{'id':_0x117add[_0x786b('0x5b')]['id']}})[_0x786b('0x26')](handleEntityNotFound(_0x24cf63,null))[_0x786b('0x26')](function(_0x17fe08){if(_0x17fe08){_0x27c288=_0x17fe08;return _0x17fe08[_0x786b('0x95')](_0x117add[_0x786b('0x53')][_0x786b('0x81')],_[_0x786b('0x5c')](_0x117add[_0x786b('0x53')],[_0x786b('0x81'),'id'])||{})[_0x786b('0x96')](function(_0xe0b3e7){for(var _0x2e2361=0x0;_0x2e2361<_0x117add[_0x786b('0x53')][_0x786b('0x81')][_0x786b('0x43')];_0x2e2361+=0x1){socket['emit'](_0x786b('0x97'),{'UserId':Number(_0x117add[_0x786b('0x53')][_0x786b('0x81')][_0x2e2361]),'VoiceQueueId':Number(_0x117add['params']['id'])});}return _0xe0b3e7;});}})[_0x786b('0x26')](function(_0x2bf50b){_0x22338a=_0x2bf50b||[];if(_0x27c288){return db[_0x786b('0x82')][_0x786b('0x4c')]({'where':{'id':_0x117add[_0x786b('0x53')][_0x786b('0x81')]},'attributes':['id',_0x786b('0x32'),_0x786b('0x6e'),_0x786b('0x6f'),'interface'],'raw':!![]});}})[_0x786b('0x26')](function(_0x16c93b){if(!_[_0x786b('0x98')](_0x16c93b)){var _0x1c21e4=[];for(var _0x2d26a4=0x0;_0x2d26a4<_0x16c93b[_0x786b('0x43')];_0x2d26a4++){if(_0x16c93b[_0x2d26a4]['online']){_0x1c21e4[_0x786b('0x8b')](db[_0x786b('0x7b')][_0x786b('0x78')]({'membername':_0x16c93b[_0x2d26a4][_0x786b('0x32')],'UserId':_0x16c93b[_0x2d26a4]['id'],'queue_name':_0x27c288['name'],'VoiceQueueId':_0x27c288['id'],'interface':_['isNil'](_0x16c93b[_0x2d26a4][_0x786b('0x70')])?util[_0x786b('0x7d')]('SIP/%s',_0x16c93b[_0x2d26a4][_0x786b('0x32')]):_0x16c93b[_0x2d26a4]['interface'],'paused':_0x16c93b[_0x2d26a4]['voicePause']||![],'penalty':_0x117add[_0x786b('0x53')][_0x786b('0x74')]||0x0}));}}return BPromise[_0x786b('0x90')](_0x1c21e4);}})[_0x786b('0x26')](function(){return _0x22338a;})[_0x786b('0x26')](respondWithResult(_0x24cf63,null))[_0x786b('0x4e')](handleError(_0x24cf63,null));};exports[_0x786b('0x93')]=function(_0x2e5774,_0x522692,_0x1e6a31){return db[_0x786b('0x38')]['find']({'where':{'id':_0x2e5774[_0x786b('0x5b')]['id']}})[_0x786b('0x26')](handleEntityNotFound(_0x522692,null))[_0x786b('0x26')](function(_0x111fa7){if(_0x111fa7){return _0x111fa7['removeAgents'](_0x2e5774[_0x786b('0x3d')][_0x786b('0x81')])[_0x786b('0x26')](function(){if(_[_0x786b('0x99')](_0x2e5774[_0x786b('0x3d')][_0x786b('0x81')])){for(var _0x32aaa5=0x0;_0x32aaa5<_0x2e5774['query']['ids'][_0x786b('0x43')];_0x32aaa5+=0x1){socket[_0x786b('0x7f')]('userVoiceQueue:remove',{'UserId':Number(_0x2e5774['query'][_0x786b('0x81')][_0x32aaa5]),'VoiceQueueId':Number(_0x2e5774[_0x786b('0x5b')]['id'])});}}else{socket[_0x786b('0x7f')]('userVoiceQueue:remove',{'UserId':Number(_0x2e5774['query'][_0x786b('0x81')]),'VoiceQueueId':Number(_0x2e5774[_0x786b('0x5b')]['id'])});}});}})[_0x786b('0x26')](function(_0x304bf1){return db[_0x786b('0x7b')][_0x786b('0x34')]({'where':{'VoiceQueueId':_0x2e5774[_0x786b('0x5b')]['id'],'UserId':_0x2e5774[_0x786b('0x3d')][_0x786b('0x81')]}})[_0x786b('0x26')](function(){return _0x304bf1;});})[_0x786b('0x26')](respondWithStatusCode(_0x522692,null))['catch'](handleError(_0x522692,null));};exports[_0x786b('0x9a')]=function(_0x3120fc,_0x15c650,_0x4574da){var _0x371715={};var _0x3290b8={};var _0x2c1844;var _0x138834;return db[_0x786b('0x38')][_0x786b('0x65')]({'where':{'id':_0x3120fc[_0x786b('0x5b')]['id']}})[_0x786b('0x26')](handleEntityNotFound(_0x15c650,null))[_0x786b('0x26')](function(_0x6e2e47){if(_0x6e2e47){_0x2c1844=_0x6e2e47;_0x3290b8[_0x786b('0x3c')]=_[_0x786b('0x3e')](db['User']['rawAttributes']);_0x3290b8[_0x786b('0x3d')]=_[_0x786b('0x3e')](_0x3120fc[_0x786b('0x3d')]);_0x3290b8[_0x786b('0x3f')]=_['intersection'](_0x3290b8[_0x786b('0x3c')],_0x3290b8['query']);_0x371715[_0x786b('0x41')]=_[_0x786b('0x40')](_0x3290b8[_0x786b('0x3c')],qs[_0x786b('0x42')](_0x3120fc['query'][_0x786b('0x42')]));_0x371715[_0x786b('0x41')]=_0x371715[_0x786b('0x41')]['length']?_0x371715['attributes']:_0x3290b8[_0x786b('0x3c')];_0x371715[_0x786b('0x46')]=qs[_0x786b('0x47')](_0x3120fc['query']['sort']);_0x371715[_0x786b('0x48')]=qs['filters'](_[_0x786b('0x49')](_0x3120fc['query'],_0x3290b8['filters']));if(_0x3120fc[_0x786b('0x3d')]['filter']){_0x371715[_0x786b('0x48')]=_['merge'](_0x371715[_0x786b('0x48')],{'$or':_[_0x786b('0x2d')](_0x371715[_0x786b('0x41')],function(_0xcf2f35){var _0x2eee8b={};_0x2eee8b[_0xcf2f35]={'$like':'%'+_0x3120fc[_0x786b('0x3d')][_0x786b('0x2b')]+'%'};return _0x2eee8b;})});}_0x371715=_[_0x786b('0x4a')]({},_0x371715,_0x3120fc['options']);return _0x2c1844[_0x786b('0x9a')](_0x371715);}})['then'](function(_0x24d12a){if(_0x24d12a){_0x138834=_0x24d12a['length'];if(!_0x3120fc[_0x786b('0x3d')][_0x786b('0x44')](_0x786b('0x45'))){_0x371715[_0x786b('0x20')]=qs[_0x786b('0x20')](_0x3120fc[_0x786b('0x3d')]['limit']);_0x371715['offset']=qs[_0x786b('0x1e')](_0x3120fc[_0x786b('0x3d')]['offset']);}return _0x2c1844[_0x786b('0x9a')](_0x371715);}})[_0x786b('0x26')](function(_0x3336ca){if(_0x3336ca){return _0x3336ca?{'count':_0x138834,'rows':_0x3336ca}:null;}})[_0x786b('0x26')](respondWithResult(_0x15c650,null))[_0x786b('0x4e')](handleError(_0x15c650,null));};exports[_0x786b('0x9b')]=function(_0xec01d0,_0x2eba02,_0x16eba0){var _0x1f5fa5={};var _0x244a53={};var _0xac0fab;var _0x58aa3b;return db['VoiceQueue'][_0x786b('0x65')]({'where':{'id':_0xec01d0[_0x786b('0x5b')]['id']}})[_0x786b('0x26')](handleEntityNotFound(_0x2eba02,null))['then'](function(_0x4a2151){if(_0x4a2151){_0xac0fab=_0x4a2151;_0x244a53[_0x786b('0x3c')]=_[_0x786b('0x3e')](db[_0x786b('0x7b')]['rawAttributes']);_0x244a53[_0x786b('0x3d')]=_[_0x786b('0x3e')](_0xec01d0['query']);_0x244a53['filters']=_[_0x786b('0x40')](_0x244a53[_0x786b('0x3c')],_0x244a53[_0x786b('0x3d')]);_0x1f5fa5[_0x786b('0x41')]=_[_0x786b('0x40')](_0x244a53['model'],qs[_0x786b('0x42')](_0xec01d0[_0x786b('0x3d')][_0x786b('0x42')]));_0x1f5fa5[_0x786b('0x41')]=_0x1f5fa5[_0x786b('0x41')][_0x786b('0x43')]?_0x1f5fa5['attributes']:_0x244a53[_0x786b('0x3c')];_0x1f5fa5[_0x786b('0x46')]=qs[_0x786b('0x47')](_0xec01d0[_0x786b('0x3d')][_0x786b('0x47')]);_0x1f5fa5[_0x786b('0x48')]=qs['filters'](_[_0x786b('0x49')](_0xec01d0[_0x786b('0x3d')],_0x244a53[_0x786b('0x3f')]));if(_0xec01d0[_0x786b('0x3d')][_0x786b('0x2b')]){_0x1f5fa5[_0x786b('0x48')]=_[_0x786b('0x4a')](_0x1f5fa5[_0x786b('0x48')],{'$or':_['map'](_0x1f5fa5[_0x786b('0x41')],function(_0x1ebc5a){var _0x3dd508={};_0x3dd508[_0x1ebc5a]={'$like':'%'+_0xec01d0['query'][_0x786b('0x2b')]+'%'};return _0x3dd508;})});}_0x1f5fa5=_['merge']({},_0x1f5fa5,_0xec01d0['options']);return _0xac0fab[_0x786b('0x9b')](_0x1f5fa5);}})[_0x786b('0x26')](function(_0x18b49f){if(_0x18b49f){_0x58aa3b=_0x18b49f[_0x786b('0x43')];if(!_0xec01d0[_0x786b('0x3d')][_0x786b('0x44')](_0x786b('0x45'))){_0x1f5fa5[_0x786b('0x20')]=qs['limit'](_0xec01d0[_0x786b('0x3d')][_0x786b('0x20')]);_0x1f5fa5[_0x786b('0x1e')]=qs[_0x786b('0x1e')](_0xec01d0[_0x786b('0x3d')][_0x786b('0x1e')]);}return _0xac0fab['getMembers'](_0x1f5fa5);}})[_0x786b('0x26')](function(_0x5def9c){return _0x5def9c?{'count':_0x58aa3b,'rows':_0x5def9c}:null;})[_0x786b('0x26')](respondWithResult(_0x2eba02,null))[_0x786b('0x4e')](handleError(_0x2eba02,null));};exports[_0x786b('0x9c')]=function(_0x4fe48d,_0x38c778,_0x83fffb){var _0x12ed77={};var _0x4d02b3={};var _0x537f41;var _0x3902dc;return db[_0x786b('0x38')][_0x786b('0x65')]({'where':{'id':_0x4fe48d['params']['id']}})[_0x786b('0x26')](handleEntityNotFound(_0x38c778,null))[_0x786b('0x26')](function(_0x3188c0){if(_0x3188c0){_0x537f41=_0x3188c0;_0x4d02b3[_0x786b('0x3c')]=_[_0x786b('0x3e')](db[_0x786b('0x9d')][_0x786b('0x39')]);_0x4d02b3['query']=_['keys'](_0x4fe48d[_0x786b('0x3d')]);_0x4d02b3[_0x786b('0x3f')]=_[_0x786b('0x40')](_0x4d02b3[_0x786b('0x3c')],_0x4d02b3['query']);_0x12ed77[_0x786b('0x41')]=_[_0x786b('0x40')](_0x4d02b3[_0x786b('0x3c')],qs['fields'](_0x4fe48d[_0x786b('0x3d')][_0x786b('0x42')]));_0x12ed77['attributes']=_0x12ed77[_0x786b('0x41')]['length']?_0x12ed77[_0x786b('0x41')]:_0x4d02b3[_0x786b('0x3c')];_0x12ed77[_0x786b('0x46')]=qs[_0x786b('0x47')](_0x4fe48d[_0x786b('0x3d')][_0x786b('0x47')]);_0x12ed77[_0x786b('0x48')]=qs[_0x786b('0x3f')](_[_0x786b('0x49')](_0x4fe48d[_0x786b('0x3d')],_0x4d02b3[_0x786b('0x3f')]));if(_0x4fe48d[_0x786b('0x3d')][_0x786b('0x2b')]){_0x12ed77[_0x786b('0x48')]=_['merge'](_0x12ed77[_0x786b('0x48')],{'$or':_['map'](_0x12ed77[_0x786b('0x41')],function(_0x12e2d5){var _0x2a20fe={};_0x2a20fe[_0x12e2d5]={'$like':'%'+_0x4fe48d[_0x786b('0x3d')][_0x786b('0x2b')]+'%'};return _0x2a20fe;})});}_0x12ed77=_[_0x786b('0x4a')]({},_0x12ed77,_0x4fe48d[_0x786b('0x51')]);return _0x537f41[_0x786b('0x9c')](_0x12ed77);}})['then'](function(_0x34a4c9){if(_0x34a4c9){_0x3902dc=_0x34a4c9[_0x786b('0x43')];if(!_0x4fe48d[_0x786b('0x3d')]['hasOwnProperty'](_0x786b('0x45'))){_0x12ed77[_0x786b('0x20')]=qs['limit'](_0x4fe48d[_0x786b('0x3d')][_0x786b('0x20')]);_0x12ed77[_0x786b('0x1e')]=qs['offset'](_0x4fe48d[_0x786b('0x3d')][_0x786b('0x1e')]);}return _0x537f41[_0x786b('0x9c')](_0x12ed77);}})[_0x786b('0x26')](function(_0x24721f){if(_0x24721f){return _0x24721f?{'count':_0x3902dc,'rows':_0x24721f}:null;}})['then'](respondWithResult(_0x38c778,null))[_0x786b('0x4e')](handleError(_0x38c778,null));};exports[_0x786b('0x9e')]=function(_0x4a824a,_0x477f9a,_0x53dd67){var _0x7b2d27,_0x16834d;return db[_0x786b('0x38')][_0x786b('0x31')]({'where':{'id':_0x4a824a[_0x786b('0x5b')]['id']}})[_0x786b('0x26')](handleEntityNotFound(_0x477f9a,null))[_0x786b('0x26')](function(_0x3e3c5c){if(_0x3e3c5c){_0x16834d=_0x3e3c5c;return _0x3e3c5c[_0x786b('0x9e')](_0x4a824a[_0x786b('0x53')][_0x786b('0x81')],_[_0x786b('0x5c')](_0x4a824a[_0x786b('0x53')],[_0x786b('0x81'),'id'])||{});}return null;})[_0x786b('0x96')](function(_0x48ef5a){var _0x6b5f47;_0x7b2d27=_0x48ef5a||[];var _0x1f696f=[];if(_0x48ef5a){for(var _0x24113f=0x0;_0x24113f<_0x48ef5a[_0x786b('0x43')];_0x24113f+=0x1){var _0xad1a05=_0x48ef5a[_0x24113f]['get']({'plain':!![]});_0x16834d[_0x786b('0x9f')]=_0x4a824a[_0x786b('0x53')][_0x786b('0x9f')]?_0x4a824a[_0x786b('0x53')][_0x786b('0x9f')]:_0x16834d[_0x786b('0x9f')];switch(_0x16834d[_0x786b('0x9f')]){case _0x786b('0xa0'):_0x6b5f47=squel['insert']()[_0x786b('0xa1')](_0x786b('0xa2'))['fromQuery']([_0x786b('0xa3'),_0x786b('0xa4'),_0x786b('0xa5'),'ListId',_0x786b('0x63'),_0x786b('0x5d'),_0x786b('0x5e')],squel[_0x786b('0x83')]()[_0x786b('0x84')](_0x786b('0xa3'),_0x786b('0xa3'))['field']('NOW()',_0x786b('0xa4'))[_0x786b('0x84')]('id',_0x786b('0xa5'))['field'](_0xad1a05[_0x786b('0xa6')][_0x786b('0x8c')](),'ListId')['field'](_0x4a824a[_0x786b('0x5b')]['id'][_0x786b('0x8c')](),'VoiceQueueId')[_0x786b('0x84')](_0x786b('0xa7'),_0x786b('0x5d'))[_0x786b('0x84')](_0x786b('0xa7'),'updatedAt')[_0x786b('0x86')](_0x786b('0xa8'))[_0x786b('0x48')](_0x786b('0xa9'))[_0x786b('0x48')](_0x786b('0xaa'),_0xad1a05['CmListId'][_0x786b('0x8c')]())[_0x786b('0x48')]('phone\x20IS\x20NOT\x20NULL')[_0x786b('0x48')](_0x786b('0xab'),squel[_0x786b('0x83')]()[_0x786b('0x84')](_0x786b('0xac'))[_0x786b('0x86')](_0x786b('0xad'))['where'](_0x786b('0xae'),_0x4a824a[_0x786b('0x5b')]['id']['toString']()))[_0x786b('0x48')]('phone\x20NOT\x20IN\x20(?)',squel[_0x786b('0x83')]()[_0x786b('0x84')](_0x786b('0xaf'))[_0x786b('0x86')]('cm_hopper')[_0x786b('0x48')](_0x786b('0xae'),_0x4a824a[_0x786b('0x5b')]['id']['toString']())))[_0x786b('0x8c')]();break;case _0x786b('0xb0'):_0x6b5f47=squel[_0x786b('0xb1')]()[_0x786b('0xa1')](_0x786b('0xa2'))['fromQuery']([_0x786b('0xa3'),_0x786b('0xa4'),_0x786b('0xa5'),_0x786b('0xb2'),'VoiceQueueId',_0x786b('0x5d'),_0x786b('0x5e')],squel['select']()['field'](_0x786b('0xa3'),_0x786b('0xa3'))[_0x786b('0x84')](_0x786b('0xa7'),'scheduledAt')[_0x786b('0x84')]('id',_0x786b('0xa5'))[_0x786b('0x84')](_0xad1a05['CmListId']['toString'](),_0x786b('0xb2'))[_0x786b('0x84')](_0x4a824a[_0x786b('0x5b')]['id'][_0x786b('0x8c')](),_0x786b('0x63'))[_0x786b('0x84')](_0x786b('0xa7'),_0x786b('0x5d'))[_0x786b('0x84')](_0x786b('0xa7'),_0x786b('0x5e'))['from'](_0x786b('0xa8'))[_0x786b('0x48')](_0x786b('0xa9'))[_0x786b('0x48')](_0x786b('0xaa'),_0xad1a05[_0x786b('0xa6')]['toString']())['where'](_0x786b('0xb3'))[_0x786b('0x48')](_0x786b('0xab'),squel[_0x786b('0x83')]()[_0x786b('0x84')](_0x786b('0xaf'))[_0x786b('0x86')]('cm_hopper')[_0x786b('0x48')](_0x786b('0xae'),_0x4a824a[_0x786b('0x5b')]['id'][_0x786b('0x8c')]())))[_0x786b('0x8c')]();break;default:_0x6b5f47=squel[_0x786b('0xb1')]()[_0x786b('0xa1')](_0x786b('0xa2'))[_0x786b('0xb4')](['phone',_0x786b('0xa4'),_0x786b('0xa5'),'ListId','VoiceQueueId',_0x786b('0x5d'),_0x786b('0x5e')],squel[_0x786b('0x83')]()[_0x786b('0x84')]('phone',_0x786b('0xa3'))[_0x786b('0x84')]('NOW()',_0x786b('0xa4'))[_0x786b('0x84')]('id','ContactId')[_0x786b('0x84')](_0xad1a05[_0x786b('0xa6')]['toString'](),'ListId')[_0x786b('0x84')](_0x4a824a[_0x786b('0x5b')]['id'][_0x786b('0x8c')](),'VoiceQueueId')['field'](_0x786b('0xa7'),_0x786b('0x5d'))['field'](_0x786b('0xa7'),_0x786b('0x5e'))[_0x786b('0x86')](_0x786b('0xa8'))[_0x786b('0x48')](_0x786b('0xa9'))['where'](_0x786b('0xaa'),_0xad1a05['CmListId'][_0x786b('0x8c')]())[_0x786b('0x48')](_0x786b('0xb3')))[_0x786b('0x8c')]();}_0x1f696f[_0x786b('0x8b')](db[_0x786b('0x75')]['query'](_0x6b5f47));}return BPromise[_0x786b('0x90')](_0x1f696f);}})[_0x786b('0x26')](function(){return _0x7b2d27;})['then'](respondWithResult(_0x477f9a,null))[_0x786b('0x4e')](handleError(_0x477f9a,null));};exports[_0x786b('0xb5')]=function(_0x57f201,_0x4b9831,_0x102b05){return db[_0x786b('0x38')][_0x786b('0x31')]({'where':{'id':_0x57f201[_0x786b('0x5b')]['id']}})[_0x786b('0x26')](handleEntityNotFound(_0x4b9831,null))[_0x786b('0x26')](function(_0x2b1a8e){if(_0x2b1a8e){return _0x2b1a8e[_0x786b('0xb5')](_0x57f201[_0x786b('0x3d')]['ids']);}})[_0x786b('0x26')](function(_0x24e139){if(_0x24e139){return db['CmHopper'][_0x786b('0x34')]({'where':{'ListId':_0x57f201['query'][_0x786b('0x81')],'VoiceQueueId':_0x57f201[_0x786b('0x5b')]['id']}})[_0x786b('0x26')](function(){return _0x24e139;});}})[_0x786b('0x26')](respondWithStatusCode(_0x4b9831,null))[_0x786b('0x4e')](handleError(_0x4b9831,null));};exports['getBlackLists']=function(_0x19851b,_0x2f4b2c,_0x4a4147){var _0x3ce068={};var _0x296b84={};var _0x4e52eb;var _0xf26cf0;return db[_0x786b('0x38')]['findOne']({'where':{'id':_0x19851b[_0x786b('0x5b')]['id']}})[_0x786b('0x26')](handleEntityNotFound(_0x2f4b2c,null))[_0x786b('0x26')](function(_0x446e82){if(_0x446e82){_0x4e52eb=_0x446e82;_0x296b84[_0x786b('0x3c')]=_[_0x786b('0x3e')](db[_0x786b('0x9d')][_0x786b('0x39')]);_0x296b84[_0x786b('0x3d')]=_[_0x786b('0x3e')](_0x19851b[_0x786b('0x3d')]);_0x296b84['filters']=_[_0x786b('0x40')](_0x296b84['model'],_0x296b84[_0x786b('0x3d')]);_0x3ce068[_0x786b('0x41')]=_[_0x786b('0x40')](_0x296b84[_0x786b('0x3c')],qs['fields'](_0x19851b['query'][_0x786b('0x42')]));_0x3ce068['attributes']=_0x3ce068[_0x786b('0x41')][_0x786b('0x43')]?_0x3ce068[_0x786b('0x41')]:_0x296b84['model'];_0x3ce068[_0x786b('0x46')]=qs['sort'](_0x19851b[_0x786b('0x3d')][_0x786b('0x47')]);_0x3ce068[_0x786b('0x48')]=qs[_0x786b('0x3f')](_[_0x786b('0x49')](_0x19851b[_0x786b('0x3d')],_0x296b84[_0x786b('0x3f')]));if(_0x19851b[_0x786b('0x3d')]['filter']){_0x3ce068['where']=_[_0x786b('0x4a')](_0x3ce068['where'],{'$or':_['map'](_0x3ce068[_0x786b('0x41')],function(_0x37c5ab){var _0x5eec60={};_0x5eec60[_0x37c5ab]={'$like':'%'+_0x19851b[_0x786b('0x3d')][_0x786b('0x2b')]+'%'};return _0x5eec60;})});}_0x3ce068=_[_0x786b('0x4a')]({},_0x3ce068,_0x19851b['options']);return _0x4e52eb['getBlackLists'](_0x3ce068);}})[_0x786b('0x26')](function(_0x2165e5){if(_0x2165e5){_0xf26cf0=_0x2165e5[_0x786b('0x43')];if(!_0x19851b[_0x786b('0x3d')][_0x786b('0x44')](_0x786b('0x45'))){_0x3ce068[_0x786b('0x20')]=qs['limit'](_0x19851b[_0x786b('0x3d')][_0x786b('0x20')]);_0x3ce068[_0x786b('0x1e')]=qs[_0x786b('0x1e')](_0x19851b[_0x786b('0x3d')]['offset']);}return _0x4e52eb[_0x786b('0xb6')](_0x3ce068);}})[_0x786b('0x26')](function(_0x28700a){if(_0x28700a){return _0x28700a?{'count':_0xf26cf0,'rows':_0x28700a}:null;}})[_0x786b('0x26')](respondWithResult(_0x2f4b2c,null))[_0x786b('0x4e')](handleError(_0x2f4b2c,null));};exports[_0x786b('0xb7')]=function(_0x5737cc,_0x7053be,_0x8a1353){var _0x267097,_0x2e863f;return db[_0x786b('0x38')][_0x786b('0x31')]({'where':{'id':_0x5737cc[_0x786b('0x5b')]['id']}})['then'](handleEntityNotFound(_0x7053be,null))['then'](function(_0x2847c2){if(_0x2847c2){_0x2e863f=_0x2847c2;return _0x2847c2[_0x786b('0xb7')](_0x5737cc[_0x786b('0x53')][_0x786b('0x81')],_[_0x786b('0x5c')](_0x5737cc[_0x786b('0x53')],['ids','id'])||{});}return null;})[_0x786b('0x96')](function(_0x15a524){var _0x367ef1;_0x267097=_0x15a524||[];var _0xaa0056=[];if(_0x15a524){for(var _0x3302be=0x0;_0x3302be<_0x15a524[_0x786b('0x43')];_0x3302be+=0x1){var _0x33b51=_0x15a524[_0x3302be][_0x786b('0x57')]({'plain':!![]});_0x367ef1=squel[_0x786b('0xb1')]()[_0x786b('0xa1')](_0x786b('0xb8'))[_0x786b('0xb4')]([_0x786b('0xa3'),_0x786b('0xa5'),_0x786b('0xb2'),'VoiceQueueId',_0x786b('0x5d'),_0x786b('0x5e')],squel['select']()[_0x786b('0x84')]('phone','phone')['field']('id',_0x786b('0xa5'))['field'](_0x33b51[_0x786b('0xa6')][_0x786b('0x8c')](),'ListId')[_0x786b('0x84')](_0x5737cc['params']['id'][_0x786b('0x8c')](),'VoiceQueueId')['field'](_0x786b('0xa7'),_0x786b('0x5d'))[_0x786b('0x84')](_0x786b('0xa7'),_0x786b('0x5e'))[_0x786b('0x86')](_0x786b('0xa8'))[_0x786b('0x48')](_0x786b('0xa9'))[_0x786b('0x48')](_0x786b('0xaa'),_0x33b51[_0x786b('0xa6')][_0x786b('0x8c')]())[_0x786b('0x48')]('phone\x20IS\x20NOT\x20NULL'))['toString']();_0xaa0056[_0x786b('0x8b')](db[_0x786b('0x75')][_0x786b('0x3d')](_0x367ef1));}return BPromise[_0x786b('0x90')](_0xaa0056);}})[_0x786b('0x26')](function(){return _0x267097;})[_0x786b('0x26')](respondWithResult(_0x7053be,null))[_0x786b('0x4e')](handleError(_0x7053be,null));};exports[_0x786b('0xb9')]=function(_0x46bb2c,_0x52eb41,_0x56c5e8){return db[_0x786b('0x38')][_0x786b('0x31')]({'where':{'id':_0x46bb2c[_0x786b('0x5b')]['id']}})[_0x786b('0x26')](handleEntityNotFound(_0x52eb41,null))[_0x786b('0x26')](function(_0x547927){if(_0x547927){return _0x547927[_0x786b('0xb9')](_0x46bb2c[_0x786b('0x3d')][_0x786b('0x81')]);}})['then'](function(_0x3f3088){if(_0x3f3088){return db['CmHopperBlack'][_0x786b('0x34')]({'where':{'ListId':_0x46bb2c[_0x786b('0x3d')][_0x786b('0x81')],'VoiceQueueId':_0x46bb2c[_0x786b('0x5b')]['id']}})['then'](function(){return _0x3f3088;});}})[_0x786b('0x26')](respondWithStatusCode(_0x52eb41,null))[_0x786b('0x4e')](handleError(_0x52eb41,null));};
\ No newline at end of file
+var _0x07d7=['stack','send','index','VoiceQueue','rawAttributes','key','model','keys','query','filters','attributes','intersection','fields','nolimit','order','sort','where','pick','merge','options','includeAll','include','findAll','catch','show','params','length','find','body','role','user','UserProfileSection','autoAssociation','create','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','clone','omit','createdAt','userProfileId','getHoppers','CmHopper','hasOwnProperty','VoiceQueueId','rows','getHopperHistories','findOne','CmHopperHistory','getHopperFinals','CmHopperFinal','getHopperBlacks','CmHopperBlack','getTeams','Team','teams','User','Agents','penalty','sequelize','transaction','TeamVoiceQueue','upsert','each','UserVoiceQueue','findOrCreate','isNil','interface','format','voicePause','emit','userVoiceQueue:save','removeTeams','ids','select','field','tq.TeamId','from','team_has_voice_queues','join','VoiceQueueId\x20=\x20?','push','toString','SELECT','TeamId','all','union','compact','isEmpty','removeAgents','UserVoiceQueueRt','userVoiceQueue:remove','addAgents','online','SIP/%s','isArray','getAgents','getMembers','getLists','CmList','YYYY-MM-DD\x20HH:mm:ss','addLists','spread','dialCheckDuplicateType','always','cm_hopper','scheduledAt','ContactId','ListId','phone','CmListId','updatedAt','ListId\x20=\x20?','phone\x20IS\x20NOT\x20NULL','cm_hopper_final','phone\x20NOT\x20IN\x20(?)','COALESCE(phone,\x27\x27)','insert','into','cm_contacts','deletedAt\x20IS\x20NULL','cm_hopper_additional_phones','fromQuery','OrderBy','ci.item','ci.OrderBy+1','h.ContactId=ci.CmContactId','h.scheduledat=?','ci.ItemClass=?','removeLists','getBlackLists','addBlackLists','cm_hopper_black','NOW()','removeBlackLists','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','ejs','fs-extra','lodash','squel','desk.js','querystring','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/utils','../../config/environment','defaults','redis','localhost','register','sendStatus','end','status','json','offset','limit','undefined','count','set','Content-Range','save','update','destroy','then','get','VoiceQueues','inbound','QueueCampaigns','outbound','filter','ignore','map','value','includes','type','name','UserProfileResource','error'];(function(_0x33505b,_0x1517b6){var _0x89a416=function(_0x84db75){while(--_0x84db75){_0x33505b['push'](_0x33505b['shift']());}};_0x89a416(++_0x1517b6);}(_0x07d7,0x85));var _0x707d=function(_0x725b8e,_0xc22b48){_0x725b8e=_0x725b8e-0x0;var _0x43ac45=_0x07d7[_0x725b8e];return _0x43ac45;};'use strict';var emlformat=require(_0x707d('0x0'));var rimraf=require(_0x707d('0x1'));var zipdir=require(_0x707d('0x2'));var jsonpatch=require(_0x707d('0x3'));var rp=require(_0x707d('0x4'));var moment=require(_0x707d('0x5'));var BPromise=require(_0x707d('0x6'));var Mustache=require(_0x707d('0x7'));var util=require(_0x707d('0x8'));var path=require(_0x707d('0x9'));var sox=require(_0x707d('0xa'));var csv=require(_0x707d('0xb'));var ejs=require(_0x707d('0xc'));var fs=require('fs');var fs_extra=require(_0x707d('0xd'));var _=require(_0x707d('0xe'));var squel=require(_0x707d('0xf'));var crypto=require('crypto');var jsforce=require('jsforce');var deskjs=require(_0x707d('0x10'));var toCsv=require(_0x707d('0xb'));var querystring=require(_0x707d('0x11'));var Papa=require(_0x707d('0x12'));var Redis=require(_0x707d('0x13'));var authService=require('../../components/auth/service');var qs=require(_0x707d('0x14'));var as=require(_0x707d('0x15'));var hardwareService=require(_0x707d('0x16'));var logger=require('../../config/logger')(_0x707d('0x17'));var utils=require(_0x707d('0x18'));var config=require(_0x707d('0x19'));var licenseUtil=require('../../config/license/util');var db=require('../../mysqldb')['db'];config['redis']=_[_0x707d('0x1a')](config[_0x707d('0x1b')],{'host':_0x707d('0x1c'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x707d('0x1b')]));require('./voiceQueue.socket')[_0x707d('0x1d')](socket);function respondWithStatusCode(_0x42e27f,_0x509ec8){_0x509ec8=_0x509ec8||0xcc;return function(_0x4d598e){if(_0x4d598e){return _0x42e27f[_0x707d('0x1e')](_0x509ec8);}return _0x42e27f['status'](_0x509ec8)[_0x707d('0x1f')]();};}function respondWithResult(_0x2c63c9,_0xeed67d){_0xeed67d=_0xeed67d||0xc8;return function(_0x1f4f0e){if(_0x1f4f0e){return _0x2c63c9[_0x707d('0x20')](_0xeed67d)[_0x707d('0x21')](_0x1f4f0e);}};}function respondWithFilteredResult(_0x318251,_0x50869d){return function(_0x1d3fe6){if(_0x1d3fe6){var _0x275a7b=typeof _0x50869d[_0x707d('0x22')]==='undefined'&&typeof _0x50869d[_0x707d('0x23')]===_0x707d('0x24');var _0xf5375f=_0x1d3fe6[_0x707d('0x25')];var _0x81f93f=_0x275a7b?0x0:_0x50869d[_0x707d('0x22')];var _0xb7171a=_0x275a7b?_0x1d3fe6[_0x707d('0x25')]:_0x50869d[_0x707d('0x22')]+_0x50869d[_0x707d('0x23')];var _0x2da0c0;if(_0xb7171a>=_0xf5375f){_0xb7171a=_0xf5375f;_0x2da0c0=0xc8;}else{_0x2da0c0=0xce;}_0x318251[_0x707d('0x20')](_0x2da0c0);return _0x318251[_0x707d('0x26')](_0x707d('0x27'),_0x81f93f+'-'+_0xb7171a+'/'+_0xf5375f)[_0x707d('0x21')](_0x1d3fe6);}return null;};}function patchUpdates(_0x30d175){return function(_0x1ce813){try{jsonpatch['apply'](_0x1ce813,_0x30d175,!![]);}catch(_0x24ba23){return BPromise['reject'](_0x24ba23);}return _0x1ce813[_0x707d('0x28')]();};}function saveUpdates(_0x139ad5,_0x8810fe){return function(_0x1a5e03){if(_0x1a5e03){return _0x1a5e03[_0x707d('0x29')](_0x139ad5)['then'](function(_0x115e5c){return _0x115e5c;});}return null;};}function removeEntity(_0x5b2db7,_0x3760bb){return function(_0x26741e){if(_0x26741e){return _0x26741e[_0x707d('0x2a')]()[_0x707d('0x2b')](function(){var _0x40551d=_0x26741e[_0x707d('0x2c')]({'plain':!![]});var _0x38b4fe=[{'name':_0x707d('0x2d'),'value':_0x707d('0x2e'),'ignore':![]},{'name':_0x707d('0x2f'),'value':_0x707d('0x30'),'ignore':![]}];var _0x4274e9=_(_0x38b4fe)[_0x707d('0x31')](_0x707d('0x32'))[_0x707d('0x33')](_0x707d('0x34'))['value']();if(_[_0x707d('0x35')](_0x4274e9,_0x40551d[_0x707d('0x36')])){return;}var _0x1784ce=_['find'](_0x38b4fe,['value',_0x40551d['type']])[_0x707d('0x37')];return db[_0x707d('0x38')][_0x707d('0x2a')]({'where':{'type':_0x1784ce,'resourceId':_0x40551d['id']}})[_0x707d('0x2b')](function(){return _0x26741e;});})[_0x707d('0x2b')](function(){_0x5b2db7[_0x707d('0x20')](0xcc)[_0x707d('0x1f')]();});}};}function handleEntityNotFound(_0x3734be,_0xd310cc){return function(_0x43ec7a){if(!_0x43ec7a){_0x3734be[_0x707d('0x1e')](0x194);}return _0x43ec7a;};}function handleError(_0x455841,_0x54a0f3){_0x54a0f3=_0x54a0f3||0x1f4;return function(_0x39bb5f){logger[_0x707d('0x39')](_0x39bb5f[_0x707d('0x3a')]);if(_0x39bb5f[_0x707d('0x37')]){delete _0x39bb5f[_0x707d('0x37')];}_0x455841['status'](_0x54a0f3)[_0x707d('0x3b')](_0x39bb5f);};}exports[_0x707d('0x3c')]=function(_0x4d2051,_0x325bd9){var _0x260b2={},_0x299460={},_0x425e2e={'count':0x0,'rows':[]};var _0x247aa8=_[_0x707d('0x33')](db[_0x707d('0x3d')][_0x707d('0x3e')],function(_0x19e6a7){return{'name':_0x19e6a7['fieldName'],'type':_0x19e6a7[_0x707d('0x36')][_0x707d('0x3f')]};});_0x299460[_0x707d('0x40')]=_[_0x707d('0x33')](_0x247aa8,_0x707d('0x37'));_0x299460['query']=_[_0x707d('0x41')](_0x4d2051[_0x707d('0x42')]);_0x299460[_0x707d('0x43')]=_['intersection'](_0x299460[_0x707d('0x40')],_0x299460['query']);_0x260b2[_0x707d('0x44')]=_[_0x707d('0x45')](_0x299460[_0x707d('0x40')],qs[_0x707d('0x46')](_0x4d2051['query']['fields']));_0x260b2[_0x707d('0x44')]=_0x260b2[_0x707d('0x44')]['length']?_0x260b2['attributes']:_0x299460[_0x707d('0x40')];if(!_0x4d2051['query']['hasOwnProperty'](_0x707d('0x47'))){_0x260b2[_0x707d('0x23')]=qs[_0x707d('0x23')](_0x4d2051[_0x707d('0x42')][_0x707d('0x23')]);_0x260b2['offset']=qs[_0x707d('0x22')](_0x4d2051[_0x707d('0x42')][_0x707d('0x22')]);}_0x260b2[_0x707d('0x48')]=qs[_0x707d('0x49')](_0x4d2051[_0x707d('0x42')][_0x707d('0x49')]);_0x260b2[_0x707d('0x4a')]=qs[_0x707d('0x43')](_[_0x707d('0x4b')](_0x4d2051[_0x707d('0x42')],_0x299460['filters']),_0x247aa8);if(_0x4d2051[_0x707d('0x42')][_0x707d('0x31')]){_0x260b2['where']=_[_0x707d('0x4c')](_0x260b2[_0x707d('0x4a')],{'$or':_[_0x707d('0x33')](_0x247aa8,function(_0x8183a9){if(_0x8183a9[_0x707d('0x36')]!=='VIRTUAL'){var _0x1f90af={};_0x1f90af[_0x8183a9[_0x707d('0x37')]]={'$like':'%'+_0x4d2051[_0x707d('0x42')][_0x707d('0x31')]+'%'};return _0x1f90af;}})});}_0x260b2=_[_0x707d('0x4c')]({},_0x260b2,_0x4d2051[_0x707d('0x4d')]);var _0x93aacd={'where':_0x260b2[_0x707d('0x4a')]};return db[_0x707d('0x3d')]['count'](_0x93aacd)[_0x707d('0x2b')](function(_0x59b928){_0x425e2e[_0x707d('0x25')]=_0x59b928;if(_0x4d2051[_0x707d('0x42')][_0x707d('0x4e')]){_0x260b2[_0x707d('0x4f')]=[{'all':!![]}];}return db[_0x707d('0x3d')][_0x707d('0x50')](_0x260b2);})[_0x707d('0x2b')](function(_0x8bf45a){_0x425e2e['rows']=_0x8bf45a;return _0x425e2e;})[_0x707d('0x2b')](respondWithFilteredResult(_0x325bd9,_0x260b2))[_0x707d('0x51')](handleError(_0x325bd9,null));};exports[_0x707d('0x52')]=function(_0x3f9c77,_0xe5c80b){var _0x225dde={'raw':![],'where':{'id':_0x3f9c77[_0x707d('0x53')]['id']}},_0x5d6590={};_0x5d6590[_0x707d('0x40')]=_[_0x707d('0x41')](db[_0x707d('0x3d')][_0x707d('0x3e')]);_0x5d6590[_0x707d('0x42')]=_['keys'](_0x3f9c77['query']);_0x5d6590[_0x707d('0x43')]=_[_0x707d('0x45')](_0x5d6590['model'],_0x5d6590[_0x707d('0x42')]);_0x225dde[_0x707d('0x44')]=_[_0x707d('0x45')](_0x5d6590[_0x707d('0x40')],qs['fields'](_0x3f9c77[_0x707d('0x42')][_0x707d('0x46')]));_0x225dde[_0x707d('0x44')]=_0x225dde['attributes'][_0x707d('0x54')]?_0x225dde[_0x707d('0x44')]:_0x5d6590['model'];if(_0x3f9c77[_0x707d('0x42')]['includeAll']){_0x225dde['include']=[{'all':!![]}];}_0x225dde=_['merge']({},_0x225dde,_0x3f9c77[_0x707d('0x4d')]);return db[_0x707d('0x3d')][_0x707d('0x55')](_0x225dde)[_0x707d('0x2b')](handleEntityNotFound(_0xe5c80b,null))[_0x707d('0x2b')](respondWithResult(_0xe5c80b,null))[_0x707d('0x51')](handleError(_0xe5c80b,null));};exports['create']=function(_0x439281,_0x2f4627){return db['VoiceQueue']['create'](_0x439281[_0x707d('0x56')],{})['then'](function(_0x17c0df){var _0x1582e4=_0x439281['user'][_0x707d('0x2c')]({'plain':!![]});if(!_0x1582e4)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x1582e4[_0x707d('0x57')]===_0x707d('0x58')){var _0x1c540c=_0x17c0df[_0x707d('0x2c')]({'plain':!![]});var _0x32fd36=[{'name':'VoiceQueues','value':_0x707d('0x2e')},{'name':_0x707d('0x2f'),'value':_0x707d('0x30')}];var _0x4f7081=_[_0x707d('0x55')](_0x32fd36,['value',_0x1c540c[_0x707d('0x36')]])[_0x707d('0x37')];return db[_0x707d('0x59')]['find']({'where':{'name':_0x4f7081,'userProfileId':_0x1582e4['userProfileId']},'raw':!![]})[_0x707d('0x2b')](function(_0x211c37){if(_0x211c37&&_0x211c37[_0x707d('0x5a')]===0x0){return db[_0x707d('0x38')][_0x707d('0x5b')]({'name':_0x1c540c[_0x707d('0x37')],'resourceId':_0x1c540c['id'],'type':_0x211c37[_0x707d('0x37')],'sectionId':_0x211c37['id']},{})[_0x707d('0x2b')](function(){return _0x17c0df;});}else{return _0x17c0df;}})['catch'](function(_0x475dbc){logger[_0x707d('0x39')](_0x707d('0x5c'),_0x475dbc);throw _0x475dbc;});}return _0x17c0df;})[_0x707d('0x2b')](respondWithResult(_0x2f4627,0xc9))[_0x707d('0x51')](handleError(_0x2f4627,null));};exports[_0x707d('0x5d')]=function(_0x20ed5f,_0x20c101){var _0x1b8b5a={'where':{'id':_0x20ed5f[_0x707d('0x53')]['id']}},_0x90c5c4={};_0x90c5c4[_0x707d('0x40')]=_[_0x707d('0x41')](db[_0x707d('0x3d')][_0x707d('0x3e')]);_0x1b8b5a[_0x707d('0x44')]=_['intersection'](_0x90c5c4[_0x707d('0x40')],qs[_0x707d('0x46')](_0x20ed5f[_0x707d('0x42')][_0x707d('0x46')]));_0x1b8b5a[_0x707d('0x44')]=_0x1b8b5a['attributes'][_0x707d('0x54')]?_0x1b8b5a[_0x707d('0x44')]:_0x90c5c4[_0x707d('0x40')];if(_0x20ed5f[_0x707d('0x42')][_0x707d('0x4e')]){_0x1b8b5a[_0x707d('0x4f')]=[{'all':!![]}];}_0x1b8b5a=_[_0x707d('0x4c')]({},_0x1b8b5a,_0x20ed5f['options']);return db[_0x707d('0x3d')]['find'](_0x1b8b5a)[_0x707d('0x2b')](handleEntityNotFound(_0x20c101,null))[_0x707d('0x2b')](function(_0x4aaaff){if(_0x4aaaff){var _0x2f8869=_0x4aaaff[_0x707d('0x2c')]({'plain':!![]});_0x2f8869=qs[_0x707d('0x5e')](_0x2f8869,['id',_0x707d('0x5f'),'updatedAt']);_0x20ed5f[_0x707d('0x56')]=_[_0x707d('0x5e')](_0x20ed5f[_0x707d('0x56')],['id',_0x707d('0x5f'),'updatedAt']);return db[_0x707d('0x3d')]['create'](_[_0x707d('0x4c')](_0x2f8869,_0x20ed5f['body']),{'include':_0x20ed5f[_0x707d('0x42')][_0x707d('0x4e')]?[{'all':!![]}]:undefined})['then'](function(_0x278483){var _0x592953=_0x20ed5f[_0x707d('0x58')][_0x707d('0x2c')]({'plain':!![]});if(!_0x592953)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x592953[_0x707d('0x57')]===_0x707d('0x58')){var _0x4ab11d=_0x278483[_0x707d('0x2c')]({'plain':!![]});var _0x4eba16=[{'name':_0x707d('0x2d'),'value':_0x707d('0x2e')},{'name':_0x707d('0x2f'),'value':_0x707d('0x30')}];var _0x30b5cb=_[_0x707d('0x55')](_0x4eba16,[_0x707d('0x34'),_0x4ab11d[_0x707d('0x36')]])[_0x707d('0x37')];return db[_0x707d('0x59')][_0x707d('0x55')]({'where':{'name':_0x30b5cb,'userProfileId':_0x592953[_0x707d('0x60')]},'raw':!![]})[_0x707d('0x2b')](function(_0x5ea54f){if(_0x5ea54f&&_0x5ea54f['autoAssociation']===0x0){return db[_0x707d('0x38')]['create']({'name':_0x4ab11d[_0x707d('0x37')],'resourceId':_0x4ab11d['id'],'type':_0x5ea54f[_0x707d('0x37')],'sectionId':_0x5ea54f['id']},{})[_0x707d('0x2b')](function(){return _0x278483;});}else{return _0x278483;}})[_0x707d('0x51')](function(_0xfbe3c0){logger[_0x707d('0x39')](_0x707d('0x5c'),_0xfbe3c0);throw _0xfbe3c0;});}return _0x278483;});}})['then'](respondWithResult(_0x20c101,0xc9))['catch'](handleError(_0x20c101,null));};exports['update']=function(_0x7d7fac,_0x5179eb){if(_0x7d7fac[_0x707d('0x56')]['id']){delete _0x7d7fac[_0x707d('0x56')]['id'];}return db['VoiceQueue'][_0x707d('0x55')]({'where':{'id':_0x7d7fac[_0x707d('0x53')]['id']}})[_0x707d('0x2b')](handleEntityNotFound(_0x5179eb,null))[_0x707d('0x2b')](saveUpdates(_0x7d7fac[_0x707d('0x56')],null))[_0x707d('0x2b')](respondWithResult(_0x5179eb,null))[_0x707d('0x51')](handleError(_0x5179eb,null));};exports[_0x707d('0x2a')]=function(_0x2c4f59,_0x1ff192){return db['VoiceQueue']['find']({'where':{'id':_0x2c4f59[_0x707d('0x53')]['id']}})[_0x707d('0x2b')](handleEntityNotFound(_0x1ff192,null))[_0x707d('0x2b')](removeEntity(_0x1ff192,null))[_0x707d('0x51')](handleError(_0x1ff192,null));};exports[_0x707d('0x61')]=function(_0x1c2dcf,_0x4a8fbb,_0xf71ac){var _0x5a15aa={'raw':![],'where':{}};var _0x4d2578={};var _0x424a6e={'count':0x0,'rows':[]};return db[_0x707d('0x3d')]['findOne']({'where':{'id':_0x1c2dcf[_0x707d('0x53')]['id']}})['then'](handleEntityNotFound(_0x4a8fbb,null))['then'](function(_0x11d410){if(_0x11d410){_0x4d2578[_0x707d('0x40')]=_['keys'](db[_0x707d('0x62')][_0x707d('0x3e')]);_0x4d2578[_0x707d('0x42')]=_[_0x707d('0x41')](_0x1c2dcf['query']);_0x4d2578[_0x707d('0x43')]=_[_0x707d('0x45')](_0x4d2578[_0x707d('0x40')],_0x4d2578['query']);_0x5a15aa[_0x707d('0x44')]=_['intersection'](_0x4d2578[_0x707d('0x40')],qs[_0x707d('0x46')](_0x1c2dcf['query'][_0x707d('0x46')]));_0x5a15aa[_0x707d('0x44')]=_0x5a15aa['attributes'][_0x707d('0x54')]?_0x5a15aa[_0x707d('0x44')]:_0x4d2578[_0x707d('0x40')];if(!_0x1c2dcf[_0x707d('0x42')][_0x707d('0x63')]('nolimit')){_0x5a15aa['limit']=qs['limit'](_0x1c2dcf['query']['limit']);_0x5a15aa[_0x707d('0x22')]=qs[_0x707d('0x22')](_0x1c2dcf[_0x707d('0x42')][_0x707d('0x22')]);}_0x5a15aa[_0x707d('0x48')]=qs[_0x707d('0x49')](_0x1c2dcf[_0x707d('0x42')][_0x707d('0x49')]);_0x5a15aa['where']=qs[_0x707d('0x43')](_['pick'](_0x1c2dcf[_0x707d('0x42')],_0x4d2578[_0x707d('0x43')]));_0x5a15aa[_0x707d('0x4a')][_0x707d('0x64')]=_0x11d410['id'];if(_0x1c2dcf[_0x707d('0x42')]['filter']){_0x5a15aa[_0x707d('0x4a')]=_['merge'](_0x5a15aa[_0x707d('0x4a')],{'$or':_[_0x707d('0x33')](_0x5a15aa[_0x707d('0x44')],function(_0x2ec5c4){var _0x36c591={};_0x36c591[_0x2ec5c4]={'$like':'%'+_0x1c2dcf[_0x707d('0x42')][_0x707d('0x31')]+'%'};return _0x36c591;})});}_0x5a15aa=_[_0x707d('0x4c')]({},_0x5a15aa,_0x1c2dcf[_0x707d('0x4d')]);return db['CmHopper'][_0x707d('0x25')]({'where':_0x5a15aa[_0x707d('0x4a')]})['then'](function(_0xa301b3){_0x424a6e[_0x707d('0x25')]=_0xa301b3;if(_0x1c2dcf['query'][_0x707d('0x4e')]){_0x5a15aa[_0x707d('0x4f')]=[{'all':!![]}];}return db[_0x707d('0x62')][_0x707d('0x50')](_0x5a15aa);})['then'](function(_0x206003){_0x424a6e[_0x707d('0x65')]=_0x206003;return _0x424a6e;});}})[_0x707d('0x2b')](respondWithFilteredResult(_0x4a8fbb,_0x5a15aa))['catch'](handleError(_0x4a8fbb,null));};exports[_0x707d('0x66')]=function(_0x6363bd,_0x12f8ec,_0x2c4940){var _0x30023b={'raw':!![],'where':{}};var _0x34ba29={};var _0x580c83={'count':0x0,'rows':[]};return db['VoiceQueue'][_0x707d('0x67')]({'where':{'id':_0x6363bd[_0x707d('0x53')]['id']}})[_0x707d('0x2b')](handleEntityNotFound(_0x12f8ec,null))[_0x707d('0x2b')](function(_0x160907){if(_0x160907){_0x34ba29[_0x707d('0x40')]=_[_0x707d('0x41')](db[_0x707d('0x68')]['rawAttributes']);_0x34ba29[_0x707d('0x42')]=_[_0x707d('0x41')](_0x6363bd[_0x707d('0x42')]);_0x34ba29[_0x707d('0x43')]=_[_0x707d('0x45')](_0x34ba29[_0x707d('0x40')],_0x34ba29['query']);_0x30023b['attributes']=_[_0x707d('0x45')](_0x34ba29['model'],qs[_0x707d('0x46')](_0x6363bd[_0x707d('0x42')][_0x707d('0x46')]));_0x30023b[_0x707d('0x44')]=_0x30023b[_0x707d('0x44')][_0x707d('0x54')]?_0x30023b['attributes']:_0x34ba29[_0x707d('0x40')];if(!_0x6363bd[_0x707d('0x42')][_0x707d('0x63')](_0x707d('0x47'))){_0x30023b[_0x707d('0x23')]=qs[_0x707d('0x23')](_0x6363bd[_0x707d('0x42')][_0x707d('0x23')]);_0x30023b[_0x707d('0x22')]=qs[_0x707d('0x22')](_0x6363bd[_0x707d('0x42')][_0x707d('0x22')]);}_0x30023b[_0x707d('0x48')]=qs[_0x707d('0x49')](_0x6363bd[_0x707d('0x42')][_0x707d('0x49')]);_0x30023b[_0x707d('0x4a')]=qs[_0x707d('0x43')](_[_0x707d('0x4b')](_0x6363bd[_0x707d('0x42')],_0x34ba29['filters']));_0x30023b[_0x707d('0x4a')][_0x707d('0x64')]=_0x160907['id'];if(_0x6363bd[_0x707d('0x42')][_0x707d('0x31')]){_0x30023b['where']=_[_0x707d('0x4c')](_0x30023b[_0x707d('0x4a')],{'$or':_[_0x707d('0x33')](_0x30023b[_0x707d('0x44')],function(_0x5c7049){var _0x3eb4c7={};_0x3eb4c7[_0x5c7049]={'$like':'%'+_0x6363bd['query'][_0x707d('0x31')]+'%'};return _0x3eb4c7;})});}_0x30023b=_[_0x707d('0x4c')]({},_0x30023b,_0x6363bd[_0x707d('0x4d')]);return db[_0x707d('0x68')][_0x707d('0x25')]({'where':_0x30023b['where']})[_0x707d('0x2b')](function(_0x49704f){_0x580c83[_0x707d('0x25')]=_0x49704f;if(_0x6363bd[_0x707d('0x42')][_0x707d('0x4e')]){_0x30023b['include']=[{'all':!![]}];}return db[_0x707d('0x68')][_0x707d('0x50')](_0x30023b);})['then'](function(_0x4ee0d0){_0x580c83[_0x707d('0x65')]=_0x4ee0d0;return _0x580c83;});}})[_0x707d('0x2b')](respondWithFilteredResult(_0x12f8ec,_0x30023b))[_0x707d('0x51')](handleError(_0x12f8ec,null));};exports[_0x707d('0x69')]=function(_0x18c641,_0xce0ddb,_0x54190e){var _0x22d3e4={'raw':!![],'where':{}};var _0x456e77={};var _0xb15220={'count':0x0,'rows':[]};return db[_0x707d('0x3d')]['findOne']({'where':{'id':_0x18c641[_0x707d('0x53')]['id']}})['then'](handleEntityNotFound(_0xce0ddb,null))[_0x707d('0x2b')](function(_0x3c5621){if(_0x3c5621){_0x456e77['model']=_[_0x707d('0x41')](db[_0x707d('0x6a')][_0x707d('0x3e')]);_0x456e77[_0x707d('0x42')]=_[_0x707d('0x41')](_0x18c641['query']);_0x456e77[_0x707d('0x43')]=_[_0x707d('0x45')](_0x456e77['model'],_0x456e77[_0x707d('0x42')]);_0x22d3e4[_0x707d('0x44')]=_[_0x707d('0x45')](_0x456e77[_0x707d('0x40')],qs['fields'](_0x18c641['query'][_0x707d('0x46')]));_0x22d3e4[_0x707d('0x44')]=_0x22d3e4[_0x707d('0x44')]['length']?_0x22d3e4[_0x707d('0x44')]:_0x456e77[_0x707d('0x40')];if(!_0x18c641['query']['hasOwnProperty'](_0x707d('0x47'))){_0x22d3e4[_0x707d('0x23')]=qs[_0x707d('0x23')](_0x18c641[_0x707d('0x42')][_0x707d('0x23')]);_0x22d3e4[_0x707d('0x22')]=qs['offset'](_0x18c641[_0x707d('0x42')][_0x707d('0x22')]);}_0x22d3e4[_0x707d('0x48')]=qs[_0x707d('0x49')](_0x18c641[_0x707d('0x42')][_0x707d('0x49')]);_0x22d3e4['where']=qs[_0x707d('0x43')](_[_0x707d('0x4b')](_0x18c641['query'],_0x456e77[_0x707d('0x43')]));_0x22d3e4[_0x707d('0x4a')][_0x707d('0x64')]=_0x3c5621['id'];if(_0x18c641['query']['filter']){_0x22d3e4[_0x707d('0x4a')]=_[_0x707d('0x4c')](_0x22d3e4[_0x707d('0x4a')],{'$or':_[_0x707d('0x33')](_0x22d3e4[_0x707d('0x44')],function(_0x1e9db1){var _0x3d7a57={};_0x3d7a57[_0x1e9db1]={'$like':'%'+_0x18c641[_0x707d('0x42')]['filter']+'%'};return _0x3d7a57;})});}_0x22d3e4=_[_0x707d('0x4c')]({},_0x22d3e4,_0x18c641[_0x707d('0x4d')]);return db[_0x707d('0x6a')][_0x707d('0x25')]({'where':_0x22d3e4[_0x707d('0x4a')]})['then'](function(_0x46685a){_0xb15220['count']=_0x46685a;if(_0x18c641[_0x707d('0x42')][_0x707d('0x4e')]){_0x22d3e4['include']=[{'all':!![]}];}return db['CmHopperFinal'][_0x707d('0x50')](_0x22d3e4);})['then'](function(_0x1c8879){_0xb15220['rows']=_0x1c8879;return _0xb15220;});}})['then'](respondWithFilteredResult(_0xce0ddb,_0x22d3e4))[_0x707d('0x51')](handleError(_0xce0ddb,null));};exports[_0x707d('0x6b')]=function(_0x2e8763,_0x40bed5,_0x1b26c9){var _0x26bbb1={'raw':!![],'where':{}};var _0x8e725={};var _0x311044={'count':0x0,'rows':[]};return db[_0x707d('0x3d')][_0x707d('0x67')]({'where':{'id':_0x2e8763[_0x707d('0x53')]['id']}})[_0x707d('0x2b')](handleEntityNotFound(_0x40bed5,null))[_0x707d('0x2b')](function(_0x35dee7){if(_0x35dee7){_0x8e725[_0x707d('0x40')]=_[_0x707d('0x41')](db[_0x707d('0x6c')][_0x707d('0x3e')]);_0x8e725[_0x707d('0x42')]=_[_0x707d('0x41')](_0x2e8763['query']);_0x8e725[_0x707d('0x43')]=_[_0x707d('0x45')](_0x8e725['model'],_0x8e725[_0x707d('0x42')]);_0x26bbb1[_0x707d('0x44')]=_[_0x707d('0x45')](_0x8e725['model'],qs['fields'](_0x2e8763[_0x707d('0x42')][_0x707d('0x46')]));_0x26bbb1[_0x707d('0x44')]=_0x26bbb1[_0x707d('0x44')][_0x707d('0x54')]?_0x26bbb1['attributes']:_0x8e725['model'];if(!_0x2e8763[_0x707d('0x42')][_0x707d('0x63')](_0x707d('0x47'))){_0x26bbb1['limit']=qs[_0x707d('0x23')](_0x2e8763[_0x707d('0x42')][_0x707d('0x23')]);_0x26bbb1[_0x707d('0x22')]=qs[_0x707d('0x22')](_0x2e8763[_0x707d('0x42')][_0x707d('0x22')]);}_0x26bbb1[_0x707d('0x48')]=qs[_0x707d('0x49')](_0x2e8763[_0x707d('0x42')]['sort']);_0x26bbb1[_0x707d('0x4a')]=qs[_0x707d('0x43')](_[_0x707d('0x4b')](_0x2e8763[_0x707d('0x42')],_0x8e725['filters']));_0x26bbb1[_0x707d('0x4a')]['VoiceQueueId']=_0x35dee7['id'];if(_0x2e8763[_0x707d('0x42')][_0x707d('0x31')]){_0x26bbb1['where']=_[_0x707d('0x4c')](_0x26bbb1['where'],{'$or':_[_0x707d('0x33')](_0x26bbb1['attributes'],function(_0x52fe2e){var _0x54ad2c={};_0x54ad2c[_0x52fe2e]={'$like':'%'+_0x2e8763['query'][_0x707d('0x31')]+'%'};return _0x54ad2c;})});}_0x26bbb1=_['merge']({},_0x26bbb1,_0x2e8763[_0x707d('0x4d')]);return db[_0x707d('0x6c')][_0x707d('0x25')]({'where':_0x26bbb1[_0x707d('0x4a')]})[_0x707d('0x2b')](function(_0xbeba07){_0x311044['count']=_0xbeba07;if(_0x2e8763[_0x707d('0x42')][_0x707d('0x4e')]){_0x26bbb1['include']=[{'all':!![]}];}return db[_0x707d('0x6c')][_0x707d('0x50')](_0x26bbb1);})[_0x707d('0x2b')](function(_0xdaabd1){_0x311044[_0x707d('0x65')]=_0xdaabd1;return _0x311044;});}})[_0x707d('0x2b')](respondWithFilteredResult(_0x40bed5,_0x26bbb1))[_0x707d('0x51')](handleError(_0x40bed5,null));};exports[_0x707d('0x6d')]=function(_0x53cf9a,_0x140685,_0x27ebf0){var _0x589ba7={};var _0x4f20da={};var _0x214517;var _0x5121f9;return db[_0x707d('0x3d')][_0x707d('0x67')]({'where':{'id':_0x53cf9a['params']['id']}})[_0x707d('0x2b')](handleEntityNotFound(_0x140685,null))[_0x707d('0x2b')](function(_0x3f0cb0){if(_0x3f0cb0){_0x214517=_0x3f0cb0;_0x4f20da[_0x707d('0x40')]=_[_0x707d('0x41')](db[_0x707d('0x6e')][_0x707d('0x3e')]);_0x4f20da[_0x707d('0x42')]=_[_0x707d('0x41')](_0x53cf9a[_0x707d('0x42')]);_0x4f20da[_0x707d('0x43')]=_[_0x707d('0x45')](_0x4f20da['model'],_0x4f20da[_0x707d('0x42')]);_0x589ba7[_0x707d('0x44')]=_[_0x707d('0x45')](_0x4f20da[_0x707d('0x40')],qs[_0x707d('0x46')](_0x53cf9a[_0x707d('0x42')][_0x707d('0x46')]));_0x589ba7[_0x707d('0x44')]=_0x589ba7[_0x707d('0x44')][_0x707d('0x54')]?_0x589ba7['attributes']:_0x4f20da[_0x707d('0x40')];_0x589ba7[_0x707d('0x48')]=qs[_0x707d('0x49')](_0x53cf9a[_0x707d('0x42')][_0x707d('0x49')]);_0x589ba7[_0x707d('0x4a')]=qs[_0x707d('0x43')](_['pick'](_0x53cf9a[_0x707d('0x42')],_0x4f20da[_0x707d('0x43')]));if(_0x53cf9a['query'][_0x707d('0x31')]){_0x589ba7[_0x707d('0x4a')]=_[_0x707d('0x4c')](_0x589ba7['where'],{'$or':_['map'](_0x589ba7[_0x707d('0x44')],function(_0x27251d){var _0x4952cb={};_0x4952cb[_0x27251d]={'$like':'%'+_0x53cf9a[_0x707d('0x42')][_0x707d('0x31')]+'%'};return _0x4952cb;})});}_0x589ba7=_['merge']({},_0x589ba7,_0x53cf9a[_0x707d('0x4d')]);return _0x214517[_0x707d('0x6d')](_0x589ba7);}})[_0x707d('0x2b')](function(_0x327304){if(_0x327304){_0x5121f9=_0x327304['length'];if(!_0x53cf9a[_0x707d('0x42')][_0x707d('0x63')](_0x707d('0x47'))){_0x589ba7[_0x707d('0x23')]=qs['limit'](_0x53cf9a[_0x707d('0x42')][_0x707d('0x23')]);_0x589ba7[_0x707d('0x22')]=qs[_0x707d('0x22')](_0x53cf9a[_0x707d('0x42')][_0x707d('0x22')]);}return _0x214517[_0x707d('0x6d')](_0x589ba7);}})[_0x707d('0x2b')](function(_0x530c48){if(_0x530c48){return _0x530c48?{'count':_0x5121f9,'rows':_0x530c48}:null;}})[_0x707d('0x2b')](respondWithResult(_0x140685,null))[_0x707d('0x51')](handleError(_0x140685,null));};exports['addTeams']=function(_0x55eab1,_0x474d48,_0x1993a8){var _0x3c76cb=_0x55eab1['body'][_0x707d('0x6f')];var _0x31c711=_[_0x707d('0x33')](_0x3c76cb,'id');return db[_0x707d('0x6e')]['findAll']({'where':{'id':_0x31c711},'attributes':['id'],'include':[{'model':db[_0x707d('0x70')],'as':'Agents','attributes':['id',_0x707d('0x37'),'online','voicePause','interface'],'raw':!![]}]})[_0x707d('0x2b')](function(_0x515704){if(_0x515704){var _0x37a4ab=_['flatMap'](_0x515704,function(_0x51e554){var _0x162e7a=_0x51e554[_0x707d('0x2c')]({'plain':!![]});_0x162e7a[_0x707d('0x71')]['forEach'](function(_0x4bfb92){_0x4bfb92[_0x707d('0x72')]=_[_0x707d('0x55')](_0x3c76cb,{'id':_0x162e7a['id']})[_0x707d('0x72')];});return _0x162e7a[_0x707d('0x71')];});return db['VoiceQueue'][_0x707d('0x55')]({'where':{'id':_0x55eab1[_0x707d('0x53')]['id']}})[_0x707d('0x2b')](function(_0x5cb102){return db[_0x707d('0x73')][_0x707d('0x74')](function(_0x26b528){return _0x5cb102['addTeams'](_0x31c711,{'transaction':_0x26b528})[_0x707d('0x2b')](function(){return BPromise['each'](_0x3c76cb,function(_0x3ffa80){return db[_0x707d('0x75')][_0x707d('0x76')]({'TeamId':_0x3ffa80['id'],'VoiceQueueId':_0x55eab1[_0x707d('0x53')]['id'],'penalty':_0x3ffa80[_0x707d('0x72')]},{'transaction':_0x26b528});});})[_0x707d('0x2b')](function(){return BPromise[_0x707d('0x77')](_0x37a4ab,function(_0x5f4a92){return db[_0x707d('0x78')][_0x707d('0x79')]({'where':{'UserId':_0x5f4a92['id'],'VoiceQueueId':_0x55eab1[_0x707d('0x53')]['id']},'defaults':{'penalty':_0x5f4a92['penalty']},'transaction':_0x26b528});});})[_0x707d('0x2b')](function(){return BPromise[_0x707d('0x77')](_[_0x707d('0x31')](_0x37a4ab,{'online':!![]}),function(_0x5a4489){return db['UserVoiceQueueRt']['upsert']({'membername':_0x5a4489[_0x707d('0x37')],'UserId':_0x5a4489['id'],'queue_name':_0x5cb102[_0x707d('0x37')],'VoiceQueueId':_0x5cb102['id'],'interface':_[_0x707d('0x7a')](_0x5a4489[_0x707d('0x7b')])?util[_0x707d('0x7c')]('SIP/%s',_0x5a4489[_0x707d('0x37')]):_0x5a4489[_0x707d('0x7b')],'paused':_0x5a4489[_0x707d('0x7d')]||![],'penalty':_0x5a4489[_0x707d('0x72')]},{'transaction':_0x26b528});});})['then'](function(){_0x37a4ab['forEach'](function(_0x254f7b){socket[_0x707d('0x7e')](_0x707d('0x7f'),{'UserId':_0x254f7b['id'],'VoiceQueueId':_0x5cb102['id']});});});});});}})[_0x707d('0x2b')](respondWithStatusCode(_0x474d48,null))[_0x707d('0x51')](handleError(_0x474d48,null));};exports[_0x707d('0x80')]=function(_0x31da99,_0x1e847e,_0x19ba1a){return db['Team'][_0x707d('0x50')]({'where':{'id':_0x31da99[_0x707d('0x42')][_0x707d('0x81')]},'attributes':['id'],'include':[{'model':db['User'],'as':_0x707d('0x71'),'attributes':['id'],'raw':!![]}]})[_0x707d('0x2b')](handleEntityNotFound(_0x1e847e,null))[_0x707d('0x2b')](function(_0x2f6809){var _0x245ad9=_[_0x707d('0x33')](_0x2f6809,'id');var _0x164a2c=[];var _0x59086f=[];var _0xc3733a=squel[_0x707d('0x82')]();_0xc3733a[_0x707d('0x83')](_0x707d('0x84'))[_0x707d('0x85')](_0x707d('0x86'),'tq')[_0x707d('0x87')]('user_has_teams','ut','ut.TeamId\x20=\x20tq.TeamId')[_0x707d('0x4a')](_0x707d('0x88'),_0x31da99[_0x707d('0x53')]['id']);for(var _0x37a62f=0x0;_0x37a62f<_0x2f6809['length'];_0x37a62f+=0x1){let _0x2bdb10=_0x2f6809[_0x37a62f];for(var _0x4190bc=0x0;_0x4190bc<_0x2bdb10[_0x707d('0x71')]['length'];_0x4190bc+=0x1){let _0x5c710d=_0x2bdb10[_0x707d('0x71')][_0x4190bc];var _0x4970aa=_0xc3733a[_0x707d('0x5d')]();_0x4970aa[_0x707d('0x4a')]('ut.UserId\x20=\x20?',_0x5c710d['id']);_0x59086f[_0x707d('0x89')](db[_0x707d('0x73')]['query'](_0x4970aa[_0x707d('0x8a')](),{'type':db[_0x707d('0x73')]['QueryTypes'][_0x707d('0x8b')]})['then'](function(_0x444965){if(_0x444965['length']===0x1){return _0x5c710d['id'];}else{var _0x2a41aa=_['every'](_['map'](_0x444965,_0x707d('0x8c')),function(_0x4f0e96){return _[_0x707d('0x35')](_0x245ad9,_0x4f0e96);});if(_0x2a41aa){return _0x5c710d['id'];}}}));}}return BPromise[_0x707d('0x8d')](_0x59086f)[_0x707d('0x2b')](function(_0x57601e){_0x164a2c=_(_0x164a2c)[_0x707d('0x8e')](_0x57601e)[_0x707d('0x8f')]()[_0x707d('0x34')]();return db['VoiceQueue']['find']({'where':{'id':_0x31da99[_0x707d('0x53')]['id']}})[_0x707d('0x2b')](function(_0x360c80){return db[_0x707d('0x73')][_0x707d('0x74')](function(_0x4eff7f){return _0x360c80[_0x707d('0x80')](_0x31da99['query']['ids'],{'transaction':_0x4eff7f})['then'](function(){if(!_[_0x707d('0x90')](_0x164a2c)){return _0x360c80[_0x707d('0x91')](_0x164a2c,{'transaction':_0x4eff7f})[_0x707d('0x2b')](function(){return db[_0x707d('0x92')]['destroy']({'where':{'VoiceQueueId':_0x31da99[_0x707d('0x53')]['id'],'UserId':_0x164a2c},'transaction':_0x4eff7f});});}})[_0x707d('0x2b')](function(){_0x164a2c['forEach'](function(_0x3083d4){socket[_0x707d('0x7e')](_0x707d('0x93'),{'UserId':_0x3083d4,'VoiceQueueId':_0x360c80['id']});});});});});});})[_0x707d('0x2b')](respondWithStatusCode(_0x1e847e,null))['catch'](handleError(_0x1e847e,null));};exports[_0x707d('0x94')]=function(_0x2d0faf,_0x54f6dd,_0x1237f5){var _0x1c7e8c,_0x164f8c;return db['VoiceQueue'][_0x707d('0x55')]({'where':{'id':_0x2d0faf[_0x707d('0x53')]['id']}})[_0x707d('0x2b')](handleEntityNotFound(_0x54f6dd,null))[_0x707d('0x2b')](function(_0x13c988){if(_0x13c988){_0x164f8c=_0x13c988;return _0x13c988['addAgents'](_0x2d0faf[_0x707d('0x56')]['ids'],_[_0x707d('0x5e')](_0x2d0faf['body'],[_0x707d('0x81'),'id'])||{})['spread'](function(_0x4da240){for(var _0x3dd8b8=0x0;_0x3dd8b8<_0x2d0faf[_0x707d('0x56')][_0x707d('0x81')][_0x707d('0x54')];_0x3dd8b8+=0x1){socket['emit']('userVoiceQueue:save',{'UserId':Number(_0x2d0faf[_0x707d('0x56')][_0x707d('0x81')][_0x3dd8b8]),'VoiceQueueId':Number(_0x2d0faf['params']['id'])});}return _0x4da240;});}})[_0x707d('0x2b')](function(_0x2134c6){_0x1c7e8c=_0x2134c6||[];if(_0x164f8c){return db[_0x707d('0x70')]['findAll']({'where':{'id':_0x2d0faf['body'][_0x707d('0x81')]},'attributes':['id',_0x707d('0x37'),_0x707d('0x95'),'voicePause',_0x707d('0x7b')],'raw':!![]});}})['then'](function(_0x174451){if(!_[_0x707d('0x90')](_0x174451)){var _0x378539=[];for(var _0x2fe9c8=0x0;_0x2fe9c8<_0x174451[_0x707d('0x54')];_0x2fe9c8++){if(_0x174451[_0x2fe9c8][_0x707d('0x95')]){_0x378539['push'](db[_0x707d('0x92')][_0x707d('0x76')]({'membername':_0x174451[_0x2fe9c8][_0x707d('0x37')],'UserId':_0x174451[_0x2fe9c8]['id'],'queue_name':_0x164f8c[_0x707d('0x37')],'VoiceQueueId':_0x164f8c['id'],'interface':_[_0x707d('0x7a')](_0x174451[_0x2fe9c8][_0x707d('0x7b')])?util['format'](_0x707d('0x96'),_0x174451[_0x2fe9c8][_0x707d('0x37')]):_0x174451[_0x2fe9c8][_0x707d('0x7b')],'paused':_0x174451[_0x2fe9c8]['voicePause']||![],'penalty':_0x2d0faf['body'][_0x707d('0x72')]||0x0}));}}return BPromise[_0x707d('0x8d')](_0x378539);}})[_0x707d('0x2b')](function(){return _0x1c7e8c;})[_0x707d('0x2b')](respondWithResult(_0x54f6dd,null))[_0x707d('0x51')](handleError(_0x54f6dd,null));};exports['removeAgents']=function(_0x257edb,_0x1b0edb,_0x3903cd){return db[_0x707d('0x3d')]['find']({'where':{'id':_0x257edb[_0x707d('0x53')]['id']}})[_0x707d('0x2b')](handleEntityNotFound(_0x1b0edb,null))['then'](function(_0x39de42){if(_0x39de42){return _0x39de42[_0x707d('0x91')](_0x257edb[_0x707d('0x42')][_0x707d('0x81')])[_0x707d('0x2b')](function(){if(_[_0x707d('0x97')](_0x257edb['query'][_0x707d('0x81')])){for(var _0x17c223=0x0;_0x17c223<_0x257edb['query'][_0x707d('0x81')][_0x707d('0x54')];_0x17c223+=0x1){socket[_0x707d('0x7e')](_0x707d('0x93'),{'UserId':Number(_0x257edb[_0x707d('0x42')][_0x707d('0x81')][_0x17c223]),'VoiceQueueId':Number(_0x257edb[_0x707d('0x53')]['id'])});}}else{socket['emit']('userVoiceQueue:remove',{'UserId':Number(_0x257edb[_0x707d('0x42')][_0x707d('0x81')]),'VoiceQueueId':Number(_0x257edb[_0x707d('0x53')]['id'])});}});}})[_0x707d('0x2b')](function(_0x1a6179){return db[_0x707d('0x92')]['destroy']({'where':{'VoiceQueueId':_0x257edb['params']['id'],'UserId':_0x257edb['query'][_0x707d('0x81')]}})[_0x707d('0x2b')](function(){return _0x1a6179;});})['then'](respondWithStatusCode(_0x1b0edb,null))[_0x707d('0x51')](handleError(_0x1b0edb,null));};exports[_0x707d('0x98')]=function(_0x320171,_0x17e33e,_0x132d8d){var _0x4ac27c={};var _0x4ddc3f={};var _0x3ae4a1;var _0xfbf1e0;return db[_0x707d('0x3d')][_0x707d('0x67')]({'where':{'id':_0x320171['params']['id']}})[_0x707d('0x2b')](handleEntityNotFound(_0x17e33e,null))[_0x707d('0x2b')](function(_0x3f5076){if(_0x3f5076){_0x3ae4a1=_0x3f5076;_0x4ddc3f[_0x707d('0x40')]=_[_0x707d('0x41')](db[_0x707d('0x70')][_0x707d('0x3e')]);_0x4ddc3f['query']=_[_0x707d('0x41')](_0x320171['query']);_0x4ddc3f[_0x707d('0x43')]=_['intersection'](_0x4ddc3f[_0x707d('0x40')],_0x4ddc3f[_0x707d('0x42')]);_0x4ac27c[_0x707d('0x44')]=_['intersection'](_0x4ddc3f[_0x707d('0x40')],qs[_0x707d('0x46')](_0x320171['query']['fields']));_0x4ac27c[_0x707d('0x44')]=_0x4ac27c['attributes'][_0x707d('0x54')]?_0x4ac27c[_0x707d('0x44')]:_0x4ddc3f[_0x707d('0x40')];_0x4ac27c[_0x707d('0x48')]=qs['sort'](_0x320171[_0x707d('0x42')]['sort']);_0x4ac27c[_0x707d('0x4a')]=qs[_0x707d('0x43')](_[_0x707d('0x4b')](_0x320171['query'],_0x4ddc3f[_0x707d('0x43')]));if(_0x320171[_0x707d('0x42')]['filter']){_0x4ac27c['where']=_[_0x707d('0x4c')](_0x4ac27c[_0x707d('0x4a')],{'$or':_['map'](_0x4ac27c[_0x707d('0x44')],function(_0x4fd358){var _0x499cdf={};_0x499cdf[_0x4fd358]={'$like':'%'+_0x320171[_0x707d('0x42')][_0x707d('0x31')]+'%'};return _0x499cdf;})});}_0x4ac27c=_[_0x707d('0x4c')]({},_0x4ac27c,_0x320171[_0x707d('0x4d')]);return _0x3ae4a1[_0x707d('0x98')](_0x4ac27c);}})[_0x707d('0x2b')](function(_0x1683ae){if(_0x1683ae){_0xfbf1e0=_0x1683ae['length'];if(!_0x320171['query'][_0x707d('0x63')](_0x707d('0x47'))){_0x4ac27c[_0x707d('0x23')]=qs[_0x707d('0x23')](_0x320171[_0x707d('0x42')][_0x707d('0x23')]);_0x4ac27c[_0x707d('0x22')]=qs[_0x707d('0x22')](_0x320171['query']['offset']);}return _0x3ae4a1[_0x707d('0x98')](_0x4ac27c);}})[_0x707d('0x2b')](function(_0x496849){if(_0x496849){return _0x496849?{'count':_0xfbf1e0,'rows':_0x496849}:null;}})['then'](respondWithResult(_0x17e33e,null))[_0x707d('0x51')](handleError(_0x17e33e,null));};exports[_0x707d('0x99')]=function(_0x2d99ea,_0x1aadbe,_0x47dd95){var _0x565467={};var _0x599fb4={};var _0xe1e062;var _0x14dcef;return db['VoiceQueue'][_0x707d('0x67')]({'where':{'id':_0x2d99ea[_0x707d('0x53')]['id']}})['then'](handleEntityNotFound(_0x1aadbe,null))[_0x707d('0x2b')](function(_0x35e80a){if(_0x35e80a){_0xe1e062=_0x35e80a;_0x599fb4[_0x707d('0x40')]=_[_0x707d('0x41')](db['UserVoiceQueueRt']['rawAttributes']);_0x599fb4['query']=_[_0x707d('0x41')](_0x2d99ea[_0x707d('0x42')]);_0x599fb4[_0x707d('0x43')]=_['intersection'](_0x599fb4[_0x707d('0x40')],_0x599fb4[_0x707d('0x42')]);_0x565467[_0x707d('0x44')]=_[_0x707d('0x45')](_0x599fb4[_0x707d('0x40')],qs[_0x707d('0x46')](_0x2d99ea[_0x707d('0x42')][_0x707d('0x46')]));_0x565467[_0x707d('0x44')]=_0x565467[_0x707d('0x44')]['length']?_0x565467[_0x707d('0x44')]:_0x599fb4['model'];_0x565467[_0x707d('0x48')]=qs[_0x707d('0x49')](_0x2d99ea[_0x707d('0x42')][_0x707d('0x49')]);_0x565467[_0x707d('0x4a')]=qs[_0x707d('0x43')](_[_0x707d('0x4b')](_0x2d99ea[_0x707d('0x42')],_0x599fb4[_0x707d('0x43')]));if(_0x2d99ea['query'][_0x707d('0x31')]){_0x565467[_0x707d('0x4a')]=_[_0x707d('0x4c')](_0x565467['where'],{'$or':_['map'](_0x565467[_0x707d('0x44')],function(_0x17f9b0){var _0x41ac21={};_0x41ac21[_0x17f9b0]={'$like':'%'+_0x2d99ea['query'][_0x707d('0x31')]+'%'};return _0x41ac21;})});}_0x565467=_[_0x707d('0x4c')]({},_0x565467,_0x2d99ea['options']);return _0xe1e062[_0x707d('0x99')](_0x565467);}})['then'](function(_0x6cbcbd){if(_0x6cbcbd){_0x14dcef=_0x6cbcbd[_0x707d('0x54')];if(!_0x2d99ea['query'][_0x707d('0x63')](_0x707d('0x47'))){_0x565467[_0x707d('0x23')]=qs[_0x707d('0x23')](_0x2d99ea[_0x707d('0x42')]['limit']);_0x565467[_0x707d('0x22')]=qs[_0x707d('0x22')](_0x2d99ea[_0x707d('0x42')][_0x707d('0x22')]);}return _0xe1e062[_0x707d('0x99')](_0x565467);}})[_0x707d('0x2b')](function(_0x5489ca){return _0x5489ca?{'count':_0x14dcef,'rows':_0x5489ca}:null;})[_0x707d('0x2b')](respondWithResult(_0x1aadbe,null))[_0x707d('0x51')](handleError(_0x1aadbe,null));};exports[_0x707d('0x9a')]=function(_0x5c51ea,_0x4f93de,_0x5afcc4){var _0xfe67a5={};var _0x541a7e={};var _0x391d59;var _0x3d215e;return db['VoiceQueue']['findOne']({'where':{'id':_0x5c51ea[_0x707d('0x53')]['id']}})[_0x707d('0x2b')](handleEntityNotFound(_0x4f93de,null))[_0x707d('0x2b')](function(_0xa581cf){if(_0xa581cf){_0x391d59=_0xa581cf;_0x541a7e[_0x707d('0x40')]=_['keys'](db[_0x707d('0x9b')][_0x707d('0x3e')]);_0x541a7e[_0x707d('0x42')]=_['keys'](_0x5c51ea[_0x707d('0x42')]);_0x541a7e[_0x707d('0x43')]=_[_0x707d('0x45')](_0x541a7e[_0x707d('0x40')],_0x541a7e['query']);_0xfe67a5[_0x707d('0x44')]=_[_0x707d('0x45')](_0x541a7e[_0x707d('0x40')],qs[_0x707d('0x46')](_0x5c51ea[_0x707d('0x42')][_0x707d('0x46')]));_0xfe67a5[_0x707d('0x44')]=_0xfe67a5[_0x707d('0x44')][_0x707d('0x54')]?_0xfe67a5[_0x707d('0x44')]:_0x541a7e[_0x707d('0x40')];_0xfe67a5[_0x707d('0x48')]=qs[_0x707d('0x49')](_0x5c51ea['query'][_0x707d('0x49')]);_0xfe67a5[_0x707d('0x4a')]=qs[_0x707d('0x43')](_[_0x707d('0x4b')](_0x5c51ea['query'],_0x541a7e['filters']));if(_0x5c51ea[_0x707d('0x42')][_0x707d('0x31')]){_0xfe67a5[_0x707d('0x4a')]=_['merge'](_0xfe67a5[_0x707d('0x4a')],{'$or':_['map'](_0xfe67a5[_0x707d('0x44')],function(_0x280cca){var _0x20c197={};_0x20c197[_0x280cca]={'$like':'%'+_0x5c51ea['query']['filter']+'%'};return _0x20c197;})});}_0xfe67a5=_[_0x707d('0x4c')]({},_0xfe67a5,_0x5c51ea[_0x707d('0x4d')]);return _0x391d59[_0x707d('0x9a')](_0xfe67a5);}})['then'](function(_0x11971d){if(_0x11971d){_0x3d215e=_0x11971d[_0x707d('0x54')];if(!_0x5c51ea[_0x707d('0x42')][_0x707d('0x63')]('nolimit')){_0xfe67a5['limit']=qs[_0x707d('0x23')](_0x5c51ea['query']['limit']);_0xfe67a5['offset']=qs[_0x707d('0x22')](_0x5c51ea['query'][_0x707d('0x22')]);}return _0x391d59[_0x707d('0x9a')](_0xfe67a5);}})['then'](function(_0x369100){if(_0x369100){return _0x369100?{'count':_0x3d215e,'rows':_0x369100}:null;}})['then'](respondWithResult(_0x4f93de,null))[_0x707d('0x51')](handleError(_0x4f93de,null));};exports['addLists']=function(_0xcf6002,_0xe9c38e,_0x40381d){var _0x104709=moment()[_0x707d('0x7c')](_0x707d('0x9c'));var _0x5c67f5,_0x4e985c;return db[_0x707d('0x3d')]['find']({'where':{'id':_0xcf6002[_0x707d('0x53')]['id']}})[_0x707d('0x2b')](handleEntityNotFound(_0xe9c38e,null))['then'](function(_0x3abc79){if(_0x3abc79){_0x4e985c=_0x3abc79;return _0x3abc79[_0x707d('0x9d')](_0xcf6002['body']['ids'],_[_0x707d('0x5e')](_0xcf6002['body'],[_0x707d('0x81'),'id'])||{});}return null;})[_0x707d('0x9e')](function(_0x2acc07){var _0x3d7be0;_0x5c67f5=_0x2acc07||[];var _0x5be04c=[];if(_0x2acc07){for(var _0x4fa015=0x0;_0x4fa015<_0x2acc07[_0x707d('0x54')];_0x4fa015+=0x1){var _0x1cf938=_0x2acc07[_0x4fa015][_0x707d('0x2c')]({'plain':!![]});_0x4e985c['dialCheckDuplicateType']=_0xcf6002[_0x707d('0x56')][_0x707d('0x9f')]?_0xcf6002[_0x707d('0x56')]['dialCheckDuplicateType']:_0x4e985c[_0x707d('0x9f')];switch(_0x4e985c[_0x707d('0x9f')]){case _0x707d('0xa0'):_0x3d7be0=squel['insert']()['into'](_0x707d('0xa1'))['fromQuery'](['phone',_0x707d('0xa2'),_0x707d('0xa3'),_0x707d('0xa4'),_0x707d('0x64'),_0x707d('0x5f'),'updatedAt'],squel[_0x707d('0x82')]()['field'](_0x707d('0xa5'),_0x707d('0xa5'))[_0x707d('0x83')]('\x27'+_0x104709+'\x27','scheduledAt')['field']('id',_0x707d('0xa3'))['field'](_0x1cf938[_0x707d('0xa6')][_0x707d('0x8a')](),_0x707d('0xa4'))[_0x707d('0x83')](_0xcf6002[_0x707d('0x53')]['id']['toString'](),'VoiceQueueId')[_0x707d('0x83')]('\x27'+_0x104709+'\x27',_0x707d('0x5f'))[_0x707d('0x83')]('\x27'+_0x104709+'\x27',_0x707d('0xa7'))[_0x707d('0x85')]('cm_contacts')[_0x707d('0x4a')]('deletedAt\x20IS\x20NULL')[_0x707d('0x4a')](_0x707d('0xa8'),_0x1cf938['CmListId']['toString']())[_0x707d('0x4a')](_0x707d('0xa9'))[_0x707d('0x4a')]('phone\x20NOT\x20IN\x20(?)',squel[_0x707d('0x82')]()[_0x707d('0x83')]('COALESCE(calleridnum,\x27\x27)')[_0x707d('0x85')](_0x707d('0xaa'))[_0x707d('0x4a')](_0x707d('0x88'),_0xcf6002['params']['id'][_0x707d('0x8a')]()))[_0x707d('0x4a')](_0x707d('0xab'),squel[_0x707d('0x82')]()[_0x707d('0x83')](_0x707d('0xac'))[_0x707d('0x85')](_0x707d('0xa1'))[_0x707d('0x4a')](_0x707d('0x88'),_0xcf6002[_0x707d('0x53')]['id'][_0x707d('0x8a')]())))[_0x707d('0x8a')]();break;case'onlyIfOpen':_0x3d7be0=squel[_0x707d('0xad')]()[_0x707d('0xae')](_0x707d('0xa1'))['fromQuery']([_0x707d('0xa5'),'scheduledAt',_0x707d('0xa3'),_0x707d('0xa4'),_0x707d('0x64'),_0x707d('0x5f'),'updatedAt'],squel['select']()['field'](_0x707d('0xa5'),_0x707d('0xa5'))[_0x707d('0x83')]('\x27'+_0x104709+'\x27',_0x707d('0xa2'))[_0x707d('0x83')]('id',_0x707d('0xa3'))[_0x707d('0x83')](_0x1cf938[_0x707d('0xa6')][_0x707d('0x8a')](),_0x707d('0xa4'))[_0x707d('0x83')](_0xcf6002['params']['id'][_0x707d('0x8a')](),_0x707d('0x64'))['field']('\x27'+_0x104709+'\x27',_0x707d('0x5f'))['field']('\x27'+_0x104709+'\x27',_0x707d('0xa7'))[_0x707d('0x85')](_0x707d('0xaf'))[_0x707d('0x4a')](_0x707d('0xb0'))['where'](_0x707d('0xa8'),_0x1cf938[_0x707d('0xa6')][_0x707d('0x8a')]())[_0x707d('0x4a')](_0x707d('0xa9'))[_0x707d('0x4a')](_0x707d('0xab'),squel[_0x707d('0x82')]()[_0x707d('0x83')](_0x707d('0xac'))['from'](_0x707d('0xa1'))[_0x707d('0x4a')](_0x707d('0x88'),_0xcf6002[_0x707d('0x53')]['id']['toString']())))['toString']();break;default:_0x3d7be0=squel['insert']()['into'](_0x707d('0xa1'))['fromQuery']([_0x707d('0xa5'),'scheduledAt',_0x707d('0xa3'),_0x707d('0xa4'),_0x707d('0x64'),_0x707d('0x5f'),_0x707d('0xa7')],squel[_0x707d('0x82')]()[_0x707d('0x83')](_0x707d('0xa5'),_0x707d('0xa5'))[_0x707d('0x83')]('\x27'+_0x104709+'\x27',_0x707d('0xa2'))[_0x707d('0x83')]('id',_0x707d('0xa3'))[_0x707d('0x83')](_0x1cf938[_0x707d('0xa6')][_0x707d('0x8a')](),'ListId')[_0x707d('0x83')](_0xcf6002[_0x707d('0x53')]['id'][_0x707d('0x8a')](),_0x707d('0x64'))[_0x707d('0x83')]('\x27'+_0x104709+'\x27','createdAt')[_0x707d('0x83')]('\x27'+_0x104709+'\x27',_0x707d('0xa7'))[_0x707d('0x85')]('cm_contacts')[_0x707d('0x4a')](_0x707d('0xb0'))[_0x707d('0x4a')]('ListId\x20=\x20?',_0x1cf938[_0x707d('0xa6')]['toString']())[_0x707d('0x4a')](_0x707d('0xa9')))[_0x707d('0x8a')]();}_0x5be04c[_0x707d('0x89')](db[_0x707d('0x73')][_0x707d('0x42')](_0x3d7be0));}return BPromise[_0x707d('0x8d')](_0x5be04c);}})[_0x707d('0x2b')](function(){var _0x3db3d3=[];var _0x538f5f=squel['insert']()[_0x707d('0xae')](_0x707d('0xb1'))[_0x707d('0xb2')](['CmHopperId',_0x707d('0xa5'),_0x707d('0xb3'),'createdAt',_0x707d('0xa7')],squel[_0x707d('0x82')]()[_0x707d('0x83')]('h.id')[_0x707d('0x83')](_0x707d('0xb4'))[_0x707d('0x83')](_0x707d('0xb5'))[_0x707d('0x83')]('\x27'+_0x104709+'\x27',_0x707d('0x5f'))['field']('\x27'+_0x104709+'\x27',_0x707d('0xa7'))[_0x707d('0x85')]('cm_contact_has_items','ci')['join']('cm_hopper','h',_0x707d('0xb6'))[_0x707d('0x4a')](_0x707d('0xb7'),_0x104709)[_0x707d('0x4a')](_0x707d('0xb8'),'PHONE'))[_0x707d('0x8a')]();_0x3db3d3[_0x707d('0x89')](db[_0x707d('0x73')]['query'](_0x538f5f));return BPromise[_0x707d('0x8d')](_0x3db3d3);})[_0x707d('0x2b')](function(){return _0x5c67f5;})[_0x707d('0x2b')](respondWithResult(_0xe9c38e,null))[_0x707d('0x51')](handleError(_0xe9c38e,null));};exports[_0x707d('0xb9')]=function(_0x207a95,_0x40e36b,_0x37bb7f){return db['VoiceQueue'][_0x707d('0x55')]({'where':{'id':_0x207a95[_0x707d('0x53')]['id']}})[_0x707d('0x2b')](handleEntityNotFound(_0x40e36b,null))[_0x707d('0x2b')](function(_0x13a55a){if(_0x13a55a){return _0x13a55a[_0x707d('0xb9')](_0x207a95[_0x707d('0x42')][_0x707d('0x81')]);}})[_0x707d('0x2b')](function(_0x10b9e4){if(_0x10b9e4){return db[_0x707d('0x62')][_0x707d('0x2a')]({'where':{'ListId':_0x207a95[_0x707d('0x42')][_0x707d('0x81')],'VoiceQueueId':_0x207a95[_0x707d('0x53')]['id']}})[_0x707d('0x2b')](function(){return _0x10b9e4;});}})[_0x707d('0x2b')](respondWithStatusCode(_0x40e36b,null))['catch'](handleError(_0x40e36b,null));};exports[_0x707d('0xba')]=function(_0x1fdc5e,_0xc479ab,_0xb0ab94){var _0x59fa37={};var _0x590278={};var _0x2c28ab;var _0x497c85;return db[_0x707d('0x3d')]['findOne']({'where':{'id':_0x1fdc5e['params']['id']}})[_0x707d('0x2b')](handleEntityNotFound(_0xc479ab,null))[_0x707d('0x2b')](function(_0x4ef445){if(_0x4ef445){_0x2c28ab=_0x4ef445;_0x590278[_0x707d('0x40')]=_['keys'](db[_0x707d('0x9b')]['rawAttributes']);_0x590278['query']=_[_0x707d('0x41')](_0x1fdc5e['query']);_0x590278[_0x707d('0x43')]=_[_0x707d('0x45')](_0x590278[_0x707d('0x40')],_0x590278[_0x707d('0x42')]);_0x59fa37[_0x707d('0x44')]=_['intersection'](_0x590278[_0x707d('0x40')],qs[_0x707d('0x46')](_0x1fdc5e[_0x707d('0x42')][_0x707d('0x46')]));_0x59fa37[_0x707d('0x44')]=_0x59fa37[_0x707d('0x44')][_0x707d('0x54')]?_0x59fa37[_0x707d('0x44')]:_0x590278[_0x707d('0x40')];_0x59fa37['order']=qs[_0x707d('0x49')](_0x1fdc5e[_0x707d('0x42')][_0x707d('0x49')]);_0x59fa37['where']=qs[_0x707d('0x43')](_['pick'](_0x1fdc5e[_0x707d('0x42')],_0x590278[_0x707d('0x43')]));if(_0x1fdc5e[_0x707d('0x42')]['filter']){_0x59fa37[_0x707d('0x4a')]=_['merge'](_0x59fa37[_0x707d('0x4a')],{'$or':_[_0x707d('0x33')](_0x59fa37[_0x707d('0x44')],function(_0x5647e0){var _0x45b864={};_0x45b864[_0x5647e0]={'$like':'%'+_0x1fdc5e[_0x707d('0x42')][_0x707d('0x31')]+'%'};return _0x45b864;})});}_0x59fa37=_[_0x707d('0x4c')]({},_0x59fa37,_0x1fdc5e['options']);return _0x2c28ab[_0x707d('0xba')](_0x59fa37);}})['then'](function(_0x43a0a7){if(_0x43a0a7){_0x497c85=_0x43a0a7[_0x707d('0x54')];if(!_0x1fdc5e['query'][_0x707d('0x63')](_0x707d('0x47'))){_0x59fa37[_0x707d('0x23')]=qs[_0x707d('0x23')](_0x1fdc5e[_0x707d('0x42')][_0x707d('0x23')]);_0x59fa37[_0x707d('0x22')]=qs[_0x707d('0x22')](_0x1fdc5e[_0x707d('0x42')][_0x707d('0x22')]);}return _0x2c28ab['getBlackLists'](_0x59fa37);}})['then'](function(_0x10e0ab){if(_0x10e0ab){return _0x10e0ab?{'count':_0x497c85,'rows':_0x10e0ab}:null;}})['then'](respondWithResult(_0xc479ab,null))[_0x707d('0x51')](handleError(_0xc479ab,null));};exports[_0x707d('0xbb')]=function(_0xdb193,_0x5b6f23,_0x217ab9){var _0x1e8fad,_0x15edf2;return db[_0x707d('0x3d')][_0x707d('0x55')]({'where':{'id':_0xdb193[_0x707d('0x53')]['id']}})[_0x707d('0x2b')](handleEntityNotFound(_0x5b6f23,null))[_0x707d('0x2b')](function(_0x455cf4){if(_0x455cf4){_0x15edf2=_0x455cf4;return _0x455cf4[_0x707d('0xbb')](_0xdb193['body'][_0x707d('0x81')],_['omit'](_0xdb193['body'],[_0x707d('0x81'),'id'])||{});}return null;})[_0x707d('0x9e')](function(_0x316bf2){var _0x43475f;_0x1e8fad=_0x316bf2||[];var _0x380bea=[];if(_0x316bf2){for(var _0xd43cd=0x0;_0xd43cd<_0x316bf2[_0x707d('0x54')];_0xd43cd+=0x1){var _0x327559=_0x316bf2[_0xd43cd]['get']({'plain':!![]});_0x43475f=squel['insert']()['into'](_0x707d('0xbc'))[_0x707d('0xb2')]([_0x707d('0xa5'),_0x707d('0xa3'),_0x707d('0xa4'),'VoiceQueueId','createdAt',_0x707d('0xa7')],squel[_0x707d('0x82')]()[_0x707d('0x83')](_0x707d('0xa5'),_0x707d('0xa5'))[_0x707d('0x83')]('id','ContactId')['field'](_0x327559[_0x707d('0xa6')][_0x707d('0x8a')](),'ListId')['field'](_0xdb193['params']['id'][_0x707d('0x8a')](),'VoiceQueueId')[_0x707d('0x83')]('NOW()','createdAt')[_0x707d('0x83')](_0x707d('0xbd'),_0x707d('0xa7'))[_0x707d('0x85')](_0x707d('0xaf'))[_0x707d('0x4a')](_0x707d('0xb0'))['where']('ListId\x20=\x20?',_0x327559[_0x707d('0xa6')]['toString']())[_0x707d('0x4a')](_0x707d('0xa9')))[_0x707d('0x8a')]();_0x380bea[_0x707d('0x89')](db[_0x707d('0x73')][_0x707d('0x42')](_0x43475f));}return BPromise['all'](_0x380bea);}})['then'](function(){return _0x1e8fad;})['then'](respondWithResult(_0x5b6f23,null))[_0x707d('0x51')](handleError(_0x5b6f23,null));};exports[_0x707d('0xbe')]=function(_0x1be10c,_0x264b2f,_0xab81bb){return db[_0x707d('0x3d')][_0x707d('0x55')]({'where':{'id':_0x1be10c['params']['id']}})[_0x707d('0x2b')](handleEntityNotFound(_0x264b2f,null))[_0x707d('0x2b')](function(_0x31f37c){if(_0x31f37c){return _0x31f37c[_0x707d('0xbe')](_0x1be10c[_0x707d('0x42')][_0x707d('0x81')]);}})[_0x707d('0x2b')](function(_0x11d313){if(_0x11d313){return db[_0x707d('0x6c')][_0x707d('0x2a')]({'where':{'ListId':_0x1be10c['query'][_0x707d('0x81')],'VoiceQueueId':_0x1be10c[_0x707d('0x53')]['id']}})[_0x707d('0x2b')](function(){return _0x11d313;});}})[_0x707d('0x2b')](respondWithStatusCode(_0x264b2f,null))[_0x707d('0x51')](handleError(_0x264b2f,null));};
\ No newline at end of file