Built motion from commit da24aabd.|2.6.20
[motion2.git] / server / api / smsQueue / smsQueue.controller.js
index 9f779b8..a81f9e5 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x43fb=['where','merge','options','includeAll','include','findAll','rows','params','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','SmsQueues','UserProfileSection','find','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','catch','describe','UserSmsQueue','nolimit','SmsQueueId','findAndCountAll','UserId','agent','smsPause','updatedAt','createdAt','format','%s/%s','getTeams','findOne','Team','User','voicePause','interface','flatMap','Agents','sequelize','transaction','addTeams','each','findOrCreate','forEach','userSmsQueue:save','removeTeams','ids','select','field','tq.TeamId','from','team_has_sms_queues','join','ut.TeamId\x20=\x20tq.TeamId','SmsQueueId\x20=\x20?','ut.UserId\x20=\x20?','toString','QueryTypes','SELECT','every','TeamId','includes','all','union','compact','value','isEmpty','emit','userSmsQueue:remove','addAgents','omit','spread','removeAgents','getAgents','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','ejs','fs-extra','lodash','squel','crypto','jsforce','querystring','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/license/util','../../mysqldb','redis','localhost','./smsQueue.socket','register','sendStatus','status','json','offset','limit','undefined','count','set','Content-Range','apply','reject','save','update','then','destroy','get','UserProfileResource','end','error','stack','name','send','index','map','SmsQueue','rawAttributes','fieldName','type','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','order','sort','pick','filter'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0x43fb,0x170));var _0xb43f=function(_0x4f8d07,_0x47ff22){_0x4f8d07=_0x4f8d07-0x0;var _0x177041=_0x43fb[_0x4f8d07];return _0x177041;};'use strict';var emlformat=require(_0xb43f('0x0'));var rimraf=require(_0xb43f('0x1'));var zipdir=require(_0xb43f('0x2'));var jsonpatch=require(_0xb43f('0x3'));var rp=require(_0xb43f('0x4'));var moment=require(_0xb43f('0x5'));var BPromise=require(_0xb43f('0x6'));var Mustache=require(_0xb43f('0x7'));var util=require(_0xb43f('0x8'));var path=require(_0xb43f('0x9'));var sox=require(_0xb43f('0xa'));var csv=require(_0xb43f('0xb'));var ejs=require(_0xb43f('0xc'));var fs=require('fs');var fs_extra=require(_0xb43f('0xd'));var _=require(_0xb43f('0xe'));var squel=require(_0xb43f('0xf'));var crypto=require(_0xb43f('0x10'));var jsforce=require(_0xb43f('0x11'));var deskjs=require('desk.js');var toCsv=require('to-csv');var querystring=require(_0xb43f('0x12'));var Papa=require('papaparse');var Redis=require('ioredis');var authService=require(_0xb43f('0x13'));var qs=require(_0xb43f('0x14'));var as=require(_0xb43f('0x15'));var hardwareService=require(_0xb43f('0x16'));var logger=require('../../config/logger')('api');var utils=require('../../config/utils');var config=require('../../config/environment');var licenseUtil=require(_0xb43f('0x17'));var db=require(_0xb43f('0x18'))['db'];config[_0xb43f('0x19')]=_['defaults'](config[_0xb43f('0x19')],{'host':_0xb43f('0x1a'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0xb43f('0x19')]));require(_0xb43f('0x1b'))[_0xb43f('0x1c')](socket);function respondWithStatusCode(_0x5c8a4a,_0x4136f2){_0x4136f2=_0x4136f2||0xcc;return function(_0x55c7bc){if(_0x55c7bc){return _0x5c8a4a[_0xb43f('0x1d')](_0x4136f2);}return _0x5c8a4a[_0xb43f('0x1e')](_0x4136f2)['end']();};}function respondWithResult(_0x346b30,_0x3fe929){_0x3fe929=_0x3fe929||0xc8;return function(_0x289055){if(_0x289055){return _0x346b30[_0xb43f('0x1e')](_0x3fe929)[_0xb43f('0x1f')](_0x289055);}};}function respondWithFilteredResult(_0x5182f9,_0x41a5ac){return function(_0x1631ad){if(_0x1631ad){var _0x3d850e=typeof _0x41a5ac[_0xb43f('0x20')]==='undefined'&&typeof _0x41a5ac[_0xb43f('0x21')]===_0xb43f('0x22');var _0x5d1e61=_0x1631ad[_0xb43f('0x23')];var _0xe59b30=_0x3d850e?0x0:_0x41a5ac[_0xb43f('0x20')];var _0x42e678=_0x3d850e?_0x1631ad[_0xb43f('0x23')]:_0x41a5ac[_0xb43f('0x20')]+_0x41a5ac['limit'];var _0x22becc;if(_0x42e678>=_0x5d1e61){_0x42e678=_0x5d1e61;_0x22becc=0xc8;}else{_0x22becc=0xce;}_0x5182f9[_0xb43f('0x1e')](_0x22becc);return _0x5182f9[_0xb43f('0x24')](_0xb43f('0x25'),_0xe59b30+'-'+_0x42e678+'/'+_0x5d1e61)[_0xb43f('0x1f')](_0x1631ad);}return null;};}function patchUpdates(_0x141708){return function(_0x534c4f){try{jsonpatch[_0xb43f('0x26')](_0x534c4f,_0x141708,!![]);}catch(_0x1af7ff){return BPromise[_0xb43f('0x27')](_0x1af7ff);}return _0x534c4f[_0xb43f('0x28')]();};}function saveUpdates(_0x27905d,_0x2da014){return function(_0x5b941a){if(_0x5b941a){return _0x5b941a[_0xb43f('0x29')](_0x27905d)[_0xb43f('0x2a')](function(_0x48eda8){return _0x48eda8;});}return null;};}function removeEntity(_0x3b8a9d,_0x4d0822){return function(_0x2b2031){if(_0x2b2031){return _0x2b2031[_0xb43f('0x2b')]()[_0xb43f('0x2a')](function(){var _0x52eff9=_0x2b2031[_0xb43f('0x2c')]({'plain':!![]});var _0x410563='SmsQueues';return db[_0xb43f('0x2d')][_0xb43f('0x2b')]({'where':{'type':_0x410563,'resourceId':_0x52eff9['id']}})[_0xb43f('0x2a')](function(){return _0x2b2031;});})[_0xb43f('0x2a')](function(){_0x3b8a9d['status'](0xcc)[_0xb43f('0x2e')]();});}};}function handleEntityNotFound(_0x324b63,_0x469778){return function(_0x882367){if(!_0x882367){_0x324b63[_0xb43f('0x1d')](0x194);}return _0x882367;};}function handleError(_0x3cf9cc,_0x3ae9fd){_0x3ae9fd=_0x3ae9fd||0x1f4;return function(_0x531eee){logger[_0xb43f('0x2f')](_0x531eee[_0xb43f('0x30')]);if(_0x531eee[_0xb43f('0x31')]){delete _0x531eee[_0xb43f('0x31')];}_0x3cf9cc[_0xb43f('0x1e')](_0x3ae9fd)[_0xb43f('0x32')](_0x531eee);};}exports[_0xb43f('0x33')]=function(_0x3c1148,_0x4691b5){var _0x347b1b={},_0x5b576d={},_0x2ac364={'count':0x0,'rows':[]};var _0x4fabbb=_[_0xb43f('0x34')](db[_0xb43f('0x35')][_0xb43f('0x36')],function(_0x3c0c74){return{'name':_0x3c0c74[_0xb43f('0x37')],'type':_0x3c0c74[_0xb43f('0x38')]['key']};});_0x5b576d[_0xb43f('0x39')]=_['map'](_0x4fabbb,_0xb43f('0x31'));_0x5b576d[_0xb43f('0x3a')]=_[_0xb43f('0x3b')](_0x3c1148[_0xb43f('0x3a')]);_0x5b576d[_0xb43f('0x3c')]=_[_0xb43f('0x3d')](_0x5b576d[_0xb43f('0x39')],_0x5b576d['query']);_0x347b1b[_0xb43f('0x3e')]=_[_0xb43f('0x3d')](_0x5b576d[_0xb43f('0x39')],qs['fields'](_0x3c1148[_0xb43f('0x3a')][_0xb43f('0x3f')]));_0x347b1b[_0xb43f('0x3e')]=_0x347b1b[_0xb43f('0x3e')][_0xb43f('0x40')]?_0x347b1b['attributes']:_0x5b576d['model'];if(!_0x3c1148[_0xb43f('0x3a')][_0xb43f('0x41')]('nolimit')){_0x347b1b[_0xb43f('0x21')]=qs[_0xb43f('0x21')](_0x3c1148[_0xb43f('0x3a')][_0xb43f('0x21')]);_0x347b1b[_0xb43f('0x20')]=qs['offset'](_0x3c1148[_0xb43f('0x3a')]['offset']);}_0x347b1b[_0xb43f('0x42')]=qs['sort'](_0x3c1148[_0xb43f('0x3a')][_0xb43f('0x43')]);_0x347b1b['where']=qs['filters'](_[_0xb43f('0x44')](_0x3c1148[_0xb43f('0x3a')],_0x5b576d[_0xb43f('0x3c')]),_0x4fabbb);if(_0x3c1148['query'][_0xb43f('0x45')]){_0x347b1b[_0xb43f('0x46')]=_[_0xb43f('0x47')](_0x347b1b['where'],{'$or':_[_0xb43f('0x34')](_0x4fabbb,function(_0x5d592f){if(_0x5d592f[_0xb43f('0x38')]!=='VIRTUAL'){var _0x5355a4={};_0x5355a4[_0x5d592f['name']]={'$like':'%'+_0x3c1148[_0xb43f('0x3a')][_0xb43f('0x45')]+'%'};return _0x5355a4;}})});}_0x347b1b=_[_0xb43f('0x47')]({},_0x347b1b,_0x3c1148[_0xb43f('0x48')]);var _0x5c9ad7={'where':_0x347b1b[_0xb43f('0x46')]};return db[_0xb43f('0x35')][_0xb43f('0x23')](_0x5c9ad7)[_0xb43f('0x2a')](function(_0x1d3589){_0x2ac364[_0xb43f('0x23')]=_0x1d3589;if(_0x3c1148[_0xb43f('0x3a')][_0xb43f('0x49')]){_0x347b1b[_0xb43f('0x4a')]=[{'all':!![]}];}return db['SmsQueue'][_0xb43f('0x4b')](_0x347b1b);})[_0xb43f('0x2a')](function(_0x5cd0b5){_0x2ac364[_0xb43f('0x4c')]=_0x5cd0b5;return _0x2ac364;})[_0xb43f('0x2a')](respondWithFilteredResult(_0x4691b5,_0x347b1b))['catch'](handleError(_0x4691b5,null));};exports['show']=function(_0x3639f0,_0x678d5b){var _0x445646={'raw':!![],'where':{'id':_0x3639f0[_0xb43f('0x4d')]['id']}},_0xa8a6ba={};_0xa8a6ba[_0xb43f('0x39')]=_[_0xb43f('0x3b')](db[_0xb43f('0x35')][_0xb43f('0x36')]);_0xa8a6ba['query']=_[_0xb43f('0x3b')](_0x3639f0['query']);_0xa8a6ba[_0xb43f('0x3c')]=_[_0xb43f('0x3d')](_0xa8a6ba[_0xb43f('0x39')],_0xa8a6ba['query']);_0x445646[_0xb43f('0x3e')]=_[_0xb43f('0x3d')](_0xa8a6ba[_0xb43f('0x39')],qs[_0xb43f('0x3f')](_0x3639f0['query']['fields']));_0x445646[_0xb43f('0x3e')]=_0x445646['attributes'][_0xb43f('0x40')]?_0x445646[_0xb43f('0x3e')]:_0xa8a6ba['model'];if(_0x3639f0[_0xb43f('0x3a')]['includeAll']){_0x445646['include']=[{'all':!![]}];}_0x445646=_[_0xb43f('0x47')]({},_0x445646,_0x3639f0[_0xb43f('0x48')]);return db[_0xb43f('0x35')]['find'](_0x445646)['then'](handleEntityNotFound(_0x678d5b,null))[_0xb43f('0x2a')](respondWithResult(_0x678d5b,null))['catch'](handleError(_0x678d5b,null));};exports['create']=function(_0x3b24e8,_0x173805){return db[_0xb43f('0x35')][_0xb43f('0x4e')](_0x3b24e8[_0xb43f('0x4f')],{})[_0xb43f('0x2a')](function(_0x4228cb){var _0x58696a=_0x3b24e8[_0xb43f('0x50')][_0xb43f('0x2c')]({'plain':!![]});if(!_0x58696a)throw new Error(_0xb43f('0x51'));if(_0x58696a[_0xb43f('0x52')]==='user'){var _0x145b08=_0x4228cb[_0xb43f('0x2c')]({'plain':!![]});var _0x79a2d5=_0xb43f('0x53');return db[_0xb43f('0x54')][_0xb43f('0x55')]({'where':{'name':_0x79a2d5,'userProfileId':_0x58696a[_0xb43f('0x56')]},'raw':!![]})['then'](function(_0x46c96c){if(_0x46c96c&&_0x46c96c[_0xb43f('0x57')]===0x0){return db['UserProfileResource'][_0xb43f('0x4e')]({'name':_0x145b08[_0xb43f('0x31')],'resourceId':_0x145b08['id'],'type':_0x46c96c[_0xb43f('0x31')],'sectionId':_0x46c96c['id']},{})['then'](function(){return _0x4228cb;});}else{return _0x4228cb;}})['catch'](function(_0x30ab11){logger[_0xb43f('0x2f')](_0xb43f('0x58'),_0x30ab11);throw _0x30ab11;});}return _0x4228cb;})['then'](respondWithResult(_0x173805,0xc9))[_0xb43f('0x59')](handleError(_0x173805,null));};exports[_0xb43f('0x29')]=function(_0xb67c08,_0x4fd95e){if(_0xb67c08[_0xb43f('0x4f')]['id']){delete _0xb67c08[_0xb43f('0x4f')]['id'];}return db[_0xb43f('0x35')]['find']({'where':{'id':_0xb67c08[_0xb43f('0x4d')]['id']}})[_0xb43f('0x2a')](handleEntityNotFound(_0x4fd95e,null))['then'](saveUpdates(_0xb67c08[_0xb43f('0x4f')],null))[_0xb43f('0x2a')](respondWithResult(_0x4fd95e,null))['catch'](handleError(_0x4fd95e,null));};exports[_0xb43f('0x2b')]=function(_0xe4ed0d,_0x598d69){return db[_0xb43f('0x35')][_0xb43f('0x55')]({'where':{'id':_0xe4ed0d[_0xb43f('0x4d')]['id']}})['then'](handleEntityNotFound(_0x598d69,null))[_0xb43f('0x2a')](removeEntity(_0x598d69,null))[_0xb43f('0x59')](handleError(_0x598d69,null));};exports[_0xb43f('0x5a')]=function(_0x5db6bf,_0x1f3cf2){return db[_0xb43f('0x35')][_0xb43f('0x5a')]()[_0xb43f('0x2a')](respondWithResult(_0x1f3cf2,null))[_0xb43f('0x59')](handleError(_0x1f3cf2,null));};exports['getMembers']=function(_0x567d29,_0x647b7e,_0x3594f3){var _0x3151b1={'raw':!![],'where':{}},_0x238aa1={},_0x28b0c9;return db[_0xb43f('0x35')]['findOne']({'where':{'id':_0x567d29[_0xb43f('0x4d')]['id']}})['then'](handleEntityNotFound(_0x647b7e,null))[_0xb43f('0x2a')](function(_0x3ab354){if(_0x3ab354){_0x28b0c9=_0x3ab354[_0xb43f('0x2c')]({'plain':!![]});_0x238aa1[_0xb43f('0x39')]=_['keys'](db[_0xb43f('0x5b')][_0xb43f('0x36')]);_0x238aa1[_0xb43f('0x3a')]=_[_0xb43f('0x3b')](_0x567d29[_0xb43f('0x3a')]);_0x238aa1['filters']=_[_0xb43f('0x3d')](_0x238aa1[_0xb43f('0x39')],_0x238aa1[_0xb43f('0x3a')]);_0x3151b1[_0xb43f('0x3e')]=_[_0xb43f('0x3d')](_0x238aa1[_0xb43f('0x39')],qs[_0xb43f('0x3f')](_0x567d29['query'][_0xb43f('0x3f')]));_0x3151b1[_0xb43f('0x3e')]=_0x3151b1[_0xb43f('0x3e')][_0xb43f('0x40')]?_0x3151b1[_0xb43f('0x3e')]:_0x238aa1['model'];if(!_0x567d29[_0xb43f('0x3a')][_0xb43f('0x41')](_0xb43f('0x5c'))){_0x3151b1['limit']=qs['limit'](_0x567d29[_0xb43f('0x3a')][_0xb43f('0x21')]);_0x3151b1['offset']=qs[_0xb43f('0x20')](_0x567d29[_0xb43f('0x3a')]['offset']);}_0x3151b1[_0xb43f('0x42')]=qs[_0xb43f('0x43')](_0x567d29[_0xb43f('0x3a')][_0xb43f('0x43')]);_0x3151b1[_0xb43f('0x46')]=qs[_0xb43f('0x3c')](_[_0xb43f('0x44')](_0x567d29['query'],_0x238aa1['filters']));_0x3151b1['where'][_0xb43f('0x5d')]=_0x3ab354['id'];if(_0x567d29['query']['filter']){_0x3151b1[_0xb43f('0x46')]=_['merge'](_0x3151b1['where'],{'$or':_[_0xb43f('0x34')](_0x3151b1[_0xb43f('0x3e')],function(_0x1a41b2){var _0xe9874e={};_0xe9874e[_0x1a41b2]={'$like':'%'+_0x567d29[_0xb43f('0x3a')][_0xb43f('0x45')]+'%'};return _0xe9874e;})});}_0x3151b1=_[_0xb43f('0x47')]({},_0x3151b1,_0x567d29['options']);return db['UserSmsQueue']['findAll'](_0x3151b1);}})[_0xb43f('0x2a')](function(_0x4f45cb){if(_0x4f45cb){return db['User'][_0xb43f('0x5e')]({'where':{'id':_[_0xb43f('0x34')](_0x4f45cb,_0xb43f('0x5f')),'role':_0xb43f('0x60')},'attributes':['id',_0xb43f('0x31'),_0xb43f('0x61'),_0xb43f('0x62'),_0xb43f('0x63')]});}})[_0xb43f('0x2a')](function(_0x498884){if(_0x498884){return{'count':_0x498884['count'],'rows':_['map'](_0x498884[_0xb43f('0x4c')],function(_0x2ed569){return{'membername':_0x2ed569['name'],'UserId':_0x2ed569['id'],'queue_name':_0x28b0c9[_0xb43f('0x31')],'SmsQueueId':_0x28b0c9['id'],'interface':util[_0xb43f('0x64')](_0xb43f('0x65'),'SIP',_0x2ed569[_0xb43f('0x31')]),'penalty':0x0,'paused':_0x2ed569[_0xb43f('0x61')],'createdAt':_0x2ed569[_0xb43f('0x63')],'updatedAt':_0x2ed569[_0xb43f('0x62')]};})};}else{return{'count':0x0,'rows':[]};}})[_0xb43f('0x2a')](respondWithFilteredResult(_0x647b7e,_0x3151b1))[_0xb43f('0x59')](handleError(_0x647b7e,null));};exports[_0xb43f('0x66')]=function(_0x29def2,_0x54afbf,_0x6a96a6){var _0x4dc209={};var _0x28f091={};var _0x131f88;var _0x36baa5;return db[_0xb43f('0x35')][_0xb43f('0x67')]({'where':{'id':_0x29def2[_0xb43f('0x4d')]['id']}})['then'](handleEntityNotFound(_0x54afbf,null))['then'](function(_0x23c2f2){if(_0x23c2f2){_0x131f88=_0x23c2f2;_0x28f091[_0xb43f('0x39')]=_[_0xb43f('0x3b')](db['Team'][_0xb43f('0x36')]);_0x28f091[_0xb43f('0x3a')]=_[_0xb43f('0x3b')](_0x29def2[_0xb43f('0x3a')]);_0x28f091[_0xb43f('0x3c')]=_[_0xb43f('0x3d')](_0x28f091[_0xb43f('0x39')],_0x28f091[_0xb43f('0x3a')]);_0x4dc209['attributes']=_['intersection'](_0x28f091['model'],qs['fields'](_0x29def2[_0xb43f('0x3a')][_0xb43f('0x3f')]));_0x4dc209[_0xb43f('0x3e')]=_0x4dc209[_0xb43f('0x3e')]['length']?_0x4dc209['attributes']:_0x28f091[_0xb43f('0x39')];_0x4dc209[_0xb43f('0x42')]=qs[_0xb43f('0x43')](_0x29def2[_0xb43f('0x3a')][_0xb43f('0x43')]);_0x4dc209[_0xb43f('0x46')]=qs[_0xb43f('0x3c')](_[_0xb43f('0x44')](_0x29def2[_0xb43f('0x3a')],_0x28f091['filters']));if(_0x29def2['query'][_0xb43f('0x45')]){_0x4dc209[_0xb43f('0x46')]=_[_0xb43f('0x47')](_0x4dc209['where'],{'$or':_[_0xb43f('0x34')](_0x4dc209['attributes'],function(_0x239125){var _0xe03eb7={};_0xe03eb7[_0x239125]={'$like':'%'+_0x29def2[_0xb43f('0x3a')][_0xb43f('0x45')]+'%'};return _0xe03eb7;})});}_0x4dc209=_['merge']({},_0x4dc209,_0x29def2[_0xb43f('0x48')]);return _0x131f88['getTeams'](_0x4dc209);}})[_0xb43f('0x2a')](function(_0x16b274){if(_0x16b274){_0x36baa5=_0x16b274['length'];if(!_0x29def2[_0xb43f('0x3a')][_0xb43f('0x41')](_0xb43f('0x5c'))){_0x4dc209[_0xb43f('0x21')]=qs[_0xb43f('0x21')](_0x29def2['query'][_0xb43f('0x21')]);_0x4dc209['offset']=qs['offset'](_0x29def2[_0xb43f('0x3a')][_0xb43f('0x20')]);}return _0x131f88[_0xb43f('0x66')](_0x4dc209);}})[_0xb43f('0x2a')](function(_0x49bfb1){if(_0x49bfb1){return _0x49bfb1?{'count':_0x36baa5,'rows':_0x49bfb1}:null;}})[_0xb43f('0x2a')](respondWithResult(_0x54afbf,null))[_0xb43f('0x59')](handleError(_0x54afbf,null));};exports['addTeams']=function(_0x4951af,_0x4167c9,_0x238799){var _0x319cc7=_0x4951af['body']['ids'];return db[_0xb43f('0x68')][_0xb43f('0x4b')]({'where':{'id':_0x319cc7},'attributes':['id'],'include':[{'model':db[_0xb43f('0x69')],'as':'Agents','attributes':['id',_0xb43f('0x31'),'online',_0xb43f('0x6a'),_0xb43f('0x6b')],'raw':!![]}]})[_0xb43f('0x2a')](function(_0x38006f){if(_0x38006f){var _0x73a7=_[_0xb43f('0x6c')](_0x38006f,function(_0xe0b685){var _0x3d82ef=_0xe0b685[_0xb43f('0x2c')]({'plain':!![]});return _0x3d82ef[_0xb43f('0x6d')];});return db[_0xb43f('0x35')][_0xb43f('0x55')]({'where':{'id':_0x4951af[_0xb43f('0x4d')]['id']}})[_0xb43f('0x2a')](function(_0x253ccd){return db[_0xb43f('0x6e')][_0xb43f('0x6f')](function(_0x245698){return _0x253ccd[_0xb43f('0x70')](_0x319cc7,{'transaction':_0x245698})[_0xb43f('0x2a')](function(){return BPromise[_0xb43f('0x71')](_0x73a7,function(_0x34997f){return db[_0xb43f('0x5b')][_0xb43f('0x72')]({'where':{'UserId':_0x34997f['id'],'SmsQueueId':_0x4951af['params']['id']},'transaction':_0x245698});});})[_0xb43f('0x2a')](function(){_0x73a7[_0xb43f('0x73')](function(_0x121ee8){socket['emit'](_0xb43f('0x74'),{'UserId':_0x121ee8['id'],'SmsQueueId':_0x253ccd['id']});});});});});}})['then'](respondWithStatusCode(_0x4167c9,null))[_0xb43f('0x59')](handleError(_0x4167c9,null));};exports[_0xb43f('0x75')]=function(_0x365df7,_0x12d655,_0x5bb86f){return db[_0xb43f('0x68')][_0xb43f('0x4b')]({'where':{'id':_0x365df7[_0xb43f('0x3a')][_0xb43f('0x76')]},'attributes':['id'],'include':[{'model':db[_0xb43f('0x69')],'as':'Agents','attributes':['id'],'raw':!![]}]})[_0xb43f('0x2a')](handleEntityNotFound(_0x12d655,null))[_0xb43f('0x2a')](function(_0x50781d){var _0x5206f2=_[_0xb43f('0x34')](_0x50781d,'id');var _0x2ba1c8=[];var _0x4e9cd9=[];var _0x491a05=squel[_0xb43f('0x77')]();_0x491a05[_0xb43f('0x78')](_0xb43f('0x79'))[_0xb43f('0x7a')](_0xb43f('0x7b'),'tq')[_0xb43f('0x7c')]('user_has_teams','ut',_0xb43f('0x7d'))[_0xb43f('0x46')](_0xb43f('0x7e'),_0x365df7['params']['id']);for(var _0x1a9d8f=0x0;_0x1a9d8f<_0x50781d[_0xb43f('0x40')];_0x1a9d8f+=0x1){let _0x12ea6b=_0x50781d[_0x1a9d8f];for(var _0x5936d4=0x0;_0x5936d4<_0x12ea6b[_0xb43f('0x6d')][_0xb43f('0x40')];_0x5936d4+=0x1){let _0xe7daed=_0x12ea6b[_0xb43f('0x6d')][_0x5936d4];var _0xe9b95f=_0x491a05['clone']();_0xe9b95f['where'](_0xb43f('0x7f'),_0xe7daed['id']);_0x4e9cd9['push'](db[_0xb43f('0x6e')][_0xb43f('0x3a')](_0xe9b95f[_0xb43f('0x80')](),{'type':db['sequelize'][_0xb43f('0x81')][_0xb43f('0x82')]})[_0xb43f('0x2a')](function(_0x25fc92){if(_0x25fc92['length']===0x1){return _0xe7daed['id'];}else{var _0x4ae30d=_[_0xb43f('0x83')](_[_0xb43f('0x34')](_0x25fc92,_0xb43f('0x84')),function(_0x546b8a){return _[_0xb43f('0x85')](_0x5206f2,_0x546b8a);});if(_0x4ae30d){return _0xe7daed['id'];}}}));}}return BPromise[_0xb43f('0x86')](_0x4e9cd9)[_0xb43f('0x2a')](function(_0x149baa){_0x2ba1c8=_(_0x2ba1c8)[_0xb43f('0x87')](_0x149baa)[_0xb43f('0x88')]()[_0xb43f('0x89')]();return db[_0xb43f('0x35')][_0xb43f('0x55')]({'where':{'id':_0x365df7[_0xb43f('0x4d')]['id']}})[_0xb43f('0x2a')](function(_0x53184b){return db['sequelize']['transaction'](function(_0x34764d){return _0x53184b[_0xb43f('0x75')](_0x365df7['query']['ids'],{'transaction':_0x34764d})[_0xb43f('0x2a')](function(){if(!_[_0xb43f('0x8a')](_0x2ba1c8)){return _0x53184b['removeAgents'](_0x2ba1c8,{'transaction':_0x34764d});}})['then'](function(){_0x2ba1c8[_0xb43f('0x73')](function(_0x2b1395){socket[_0xb43f('0x8b')](_0xb43f('0x8c'),{'UserId':_0x2b1395,'SmsQueueId':_0x53184b['id']});});});});});});})[_0xb43f('0x2a')](respondWithStatusCode(_0x12d655,null))['catch'](handleError(_0x12d655,null));};exports[_0xb43f('0x8d')]=function(_0x3d8cfb,_0x51e7d4,_0x38f79a){return db[_0xb43f('0x35')][_0xb43f('0x55')]({'where':{'id':_0x3d8cfb[_0xb43f('0x4d')]['id']}})['then'](handleEntityNotFound(_0x51e7d4,null))[_0xb43f('0x2a')](function(_0x14fe89){if(_0x14fe89){return _0x14fe89[_0xb43f('0x8d')](_0x3d8cfb[_0xb43f('0x4f')]['ids'],_[_0xb43f('0x8e')](_0x3d8cfb['body'],[_0xb43f('0x76'),'id'])||{})[_0xb43f('0x8f')](function(_0x353e36){for(var _0x339996=0x0;_0x339996<_0x3d8cfb[_0xb43f('0x4f')][_0xb43f('0x76')][_0xb43f('0x40')];_0x339996+=0x1){socket[_0xb43f('0x8b')](_0xb43f('0x74'),{'UserId':Number(_0x3d8cfb['body']['ids'][_0x339996]),'SmsQueueId':Number(_0x3d8cfb[_0xb43f('0x4d')]['id'])});}return _0x353e36;});}})['then'](respondWithResult(_0x51e7d4,null))[_0xb43f('0x59')](handleError(_0x51e7d4,null));};exports[_0xb43f('0x90')]=function(_0xab6276,_0x20d524,_0x3462e2){return db['SmsQueue'][_0xb43f('0x55')]({'where':{'id':_0xab6276[_0xb43f('0x4d')]['id']}})[_0xb43f('0x2a')](handleEntityNotFound(_0x20d524,null))[_0xb43f('0x2a')](function(_0x15ac75){if(_0x15ac75){return _0x15ac75[_0xb43f('0x90')](_0xab6276['query'][_0xb43f('0x76')])[_0xb43f('0x2a')](function(){if(_['isArray'](_0xab6276[_0xb43f('0x3a')]['ids'])){for(var _0x1f5a9f=0x0;_0x1f5a9f<_0xab6276[_0xb43f('0x3a')]['ids'][_0xb43f('0x40')];_0x1f5a9f+=0x1){socket[_0xb43f('0x8b')](_0xb43f('0x8c'),{'UserId':Number(_0xab6276['query'][_0xb43f('0x76')][_0x1f5a9f]),'SmsQueueId':Number(_0xab6276['params']['id'])});}}else{socket[_0xb43f('0x8b')]('userSmsQueue:remove',{'UserId':Number(_0xab6276[_0xb43f('0x3a')][_0xb43f('0x76')]),'SmsQueueId':Number(_0xab6276[_0xb43f('0x4d')]['id'])});}});}})[_0xb43f('0x2a')](respondWithStatusCode(_0x20d524,null))[_0xb43f('0x59')](handleError(_0x20d524,null));};exports['getAgents']=function(_0x9b5bac,_0x103e71,_0x470b57){var _0x213a9a={};var _0x2df28c={};var _0x24ab06;var _0x271484;return db['SmsQueue'][_0xb43f('0x67')]({'where':{'id':_0x9b5bac['params']['id']}})[_0xb43f('0x2a')](handleEntityNotFound(_0x103e71,null))[_0xb43f('0x2a')](function(_0x53bf2f){if(_0x53bf2f){_0x24ab06=_0x53bf2f;_0x2df28c['model']=_[_0xb43f('0x3b')](db['User'][_0xb43f('0x36')]);_0x2df28c[_0xb43f('0x3a')]=_['keys'](_0x9b5bac['query']);_0x2df28c['filters']=_[_0xb43f('0x3d')](_0x2df28c[_0xb43f('0x39')],_0x2df28c[_0xb43f('0x3a')]);_0x213a9a[_0xb43f('0x3e')]=_[_0xb43f('0x3d')](_0x2df28c[_0xb43f('0x39')],qs[_0xb43f('0x3f')](_0x9b5bac['query'][_0xb43f('0x3f')]));_0x213a9a[_0xb43f('0x3e')]=_0x213a9a[_0xb43f('0x3e')][_0xb43f('0x40')]?_0x213a9a['attributes']:_0x2df28c[_0xb43f('0x39')];_0x213a9a[_0xb43f('0x42')]=qs[_0xb43f('0x43')](_0x9b5bac[_0xb43f('0x3a')][_0xb43f('0x43')]);_0x213a9a[_0xb43f('0x46')]=qs[_0xb43f('0x3c')](_[_0xb43f('0x44')](_0x9b5bac[_0xb43f('0x3a')],_0x2df28c['filters']));if(_0x9b5bac[_0xb43f('0x3a')][_0xb43f('0x45')]){_0x213a9a[_0xb43f('0x46')]=_[_0xb43f('0x47')](_0x213a9a[_0xb43f('0x46')],{'$or':_[_0xb43f('0x34')](_0x213a9a[_0xb43f('0x3e')],function(_0x2779a3){var _0x2177cf={};_0x2177cf[_0x2779a3]={'$like':'%'+_0x9b5bac['query'][_0xb43f('0x45')]+'%'};return _0x2177cf;})});}_0x213a9a=_[_0xb43f('0x47')]({},_0x213a9a,_0x9b5bac['options']);return _0x24ab06[_0xb43f('0x91')](_0x213a9a);}})[_0xb43f('0x2a')](function(_0x324b91){if(_0x324b91){_0x271484=_0x324b91['length'];if(!_0x9b5bac[_0xb43f('0x3a')][_0xb43f('0x41')](_0xb43f('0x5c'))){_0x213a9a[_0xb43f('0x21')]=qs['limit'](_0x9b5bac[_0xb43f('0x3a')][_0xb43f('0x21')]);_0x213a9a[_0xb43f('0x20')]=qs[_0xb43f('0x20')](_0x9b5bac[_0xb43f('0x3a')]['offset']);}return _0x24ab06[_0xb43f('0x91')](_0x213a9a);}})[_0xb43f('0x2a')](function(_0x3be62a){if(_0x3be62a){return _0x3be62a?{'count':_0x271484,'rows':_0x3be62a}:null;}})[_0xb43f('0x2a')](respondWithResult(_0x103e71,null))['catch'](handleError(_0x103e71,null));};
\ No newline at end of file
+var _0xdb28=['userSmsQueue:save','removeTeams','select','field','from','team_has_sms_queues','join','SmsQueueId\x20=\x20?','ut.UserId\x20=\x20?','push','QueryTypes','TeamId','includes','all','union','value','isEmpty','removeAgents','forEach','addAgents','omit','spread','userSmsQueue:remove','getAgents','bluebird','util','lodash','squel','../../components/parsers/qs','../../config/logger','api','../../config/environment','../../mysqldb','defaults','redis','./smsQueue.socket','register','sendStatus','end','status','json','offset','undefined','count','limit','Content-Range','update','then','get','SmsQueues','destroy','error','stack','name','map','SmsQueue','fieldName','type','key','where','include','rows','show','keys','query','filters','intersection','model','attributes','fields','length','includeAll','merge','options','find','create','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','UserProfileSection','userProfileId','autoAssociation','UserProfileResource','catch','body','params','describe','getMembers','findOne','UserSmsQueue','rawAttributes','hasOwnProperty','nolimit','order','sort','SmsQueueId','filter','findAll','User','findAndCountAll','UserId','agent','smsPause','updatedAt','createdAt','format','%s/%s','getTeams','Team','pick','ids','Agents','online','voicePause','interface','sequelize','transaction','addTeams','each','emit'];(function(_0x552968,_0x2f8515){var _0x12b6b7=function(_0x4a70e1){while(--_0x4a70e1){_0x552968['push'](_0x552968['shift']());}};_0x12b6b7(++_0x2f8515);}(_0xdb28,0x106));var _0x8db2=function(_0x5da38a,_0x323010){_0x5da38a=_0x5da38a-0x0;var _0x206f85=_0xdb28[_0x5da38a];return _0x206f85;};'use strict';var BPromise=require(_0x8db2('0x0'));var util=require(_0x8db2('0x1'));var _=require(_0x8db2('0x2'));var squel=require(_0x8db2('0x3'));var Redis=require('ioredis');var qs=require(_0x8db2('0x4'));var logger=require(_0x8db2('0x5'))(_0x8db2('0x6'));var config=require(_0x8db2('0x7'));var db=require(_0x8db2('0x8'))['db'];config['redis']=_[_0x8db2('0x9')](config[_0x8db2('0xa')],{'host':'localhost','port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x8db2('0xa')]));require(_0x8db2('0xb'))[_0x8db2('0xc')](socket);function respondWithStatusCode(_0x29f698,_0x2f3f2f){_0x2f3f2f=_0x2f3f2f||0xcc;return function(_0x1ff362){if(_0x1ff362){return _0x29f698[_0x8db2('0xd')](_0x2f3f2f);}return _0x29f698['status'](_0x2f3f2f)[_0x8db2('0xe')]();};}function respondWithResult(_0x476216,_0x1f62af){_0x1f62af=_0x1f62af||0xc8;return function(_0x57015f){if(_0x57015f){return _0x476216[_0x8db2('0xf')](_0x1f62af)[_0x8db2('0x10')](_0x57015f);}};}function respondWithFilteredResult(_0x576475,_0x41beda){return function(_0x3b2faa){if(_0x3b2faa){var _0x1349f6=typeof _0x41beda[_0x8db2('0x11')]===_0x8db2('0x12')&&typeof _0x41beda['limit']==='undefined';var _0x15070d=_0x3b2faa[_0x8db2('0x13')];var _0x350d61=_0x1349f6?0x0:_0x41beda[_0x8db2('0x11')];var _0x227355=_0x1349f6?_0x3b2faa[_0x8db2('0x13')]:_0x41beda[_0x8db2('0x11')]+_0x41beda[_0x8db2('0x14')];var _0x131252;if(_0x227355>=_0x15070d){_0x227355=_0x15070d;_0x131252=0xc8;}else{_0x131252=0xce;}_0x576475[_0x8db2('0xf')](_0x131252);return _0x576475['set'](_0x8db2('0x15'),_0x350d61+'-'+_0x227355+'/'+_0x15070d)[_0x8db2('0x10')](_0x3b2faa);}return null;};}function saveUpdates(_0x48101e){return function(_0x2b3f73){if(_0x2b3f73){return _0x2b3f73[_0x8db2('0x16')](_0x48101e)[_0x8db2('0x17')](function(_0x3fddc2){return _0x3fddc2;});}return null;};}function removeEntity(_0x2efd06){return function(_0x46ce14){if(_0x46ce14){return _0x46ce14['destroy']()['then'](function(){var _0x77789=_0x46ce14[_0x8db2('0x18')]({'plain':!![]});var _0x1310d3=_0x8db2('0x19');return db['UserProfileResource'][_0x8db2('0x1a')]({'where':{'type':_0x1310d3,'resourceId':_0x77789['id']}})[_0x8db2('0x17')](function(){return _0x46ce14;});})[_0x8db2('0x17')](function(){_0x2efd06[_0x8db2('0xf')](0xcc)[_0x8db2('0xe')]();});}};}function handleEntityNotFound(_0x597260){return function(_0x124467){if(!_0x124467){_0x597260[_0x8db2('0xd')](0x194);}return _0x124467;};}function handleError(_0x18f69c,_0x125be2){_0x125be2=_0x125be2||0x1f4;return function(_0x2260d8){logger[_0x8db2('0x1b')](_0x2260d8[_0x8db2('0x1c')]);if(_0x2260d8['name']){delete _0x2260d8[_0x8db2('0x1d')];}_0x18f69c['status'](_0x125be2)['send'](_0x2260d8);};}exports['index']=function(_0x4d923c,_0xec8cd2){var _0x29b5cd={};var _0x3be281={'count':0x0,'rows':[]};var _0x2baed0=_[_0x8db2('0x1e')](db[_0x8db2('0x1f')]['rawAttributes'],function(_0x3544ba){return{'name':_0x3544ba[_0x8db2('0x20')],'type':_0x3544ba[_0x8db2('0x21')][_0x8db2('0x22')]};});_0x29b5cd=qs['getOptions'](_0x2baed0,_0x4d923c);var _0x2e0691={'where':_0x29b5cd[_0x8db2('0x23')]};return db[_0x8db2('0x1f')][_0x8db2('0x13')](_0x2e0691)[_0x8db2('0x17')](function(_0x21bae5){_0x3be281[_0x8db2('0x13')]=_0x21bae5;_0x29b5cd[_0x8db2('0x24')]=qs[_0x8db2('0x24')](_0x4d923c['query']);return db[_0x8db2('0x1f')]['findAll'](_0x29b5cd);})['then'](function(_0x302188){_0x3be281[_0x8db2('0x25')]=_0x302188;return _0x3be281;})[_0x8db2('0x17')](respondWithFilteredResult(_0xec8cd2,_0x29b5cd))['catch'](handleError(_0xec8cd2,null));};exports[_0x8db2('0x26')]=function(_0x56b71a,_0x3f7aac){var _0x2b653b={'raw':!![],'where':{'id':_0x56b71a['params']['id']}},_0x14bd12={};_0x14bd12['model']=_[_0x8db2('0x27')](db[_0x8db2('0x1f')]['rawAttributes']);_0x14bd12['query']=_[_0x8db2('0x27')](_0x56b71a[_0x8db2('0x28')]);_0x14bd12[_0x8db2('0x29')]=_[_0x8db2('0x2a')](_0x14bd12[_0x8db2('0x2b')],_0x14bd12[_0x8db2('0x28')]);_0x2b653b[_0x8db2('0x2c')]=_[_0x8db2('0x2a')](_0x14bd12[_0x8db2('0x2b')],qs[_0x8db2('0x2d')](_0x56b71a['query'][_0x8db2('0x2d')]));_0x2b653b[_0x8db2('0x2c')]=_0x2b653b['attributes'][_0x8db2('0x2e')]?_0x2b653b[_0x8db2('0x2c')]:_0x14bd12['model'];if(_0x56b71a['query'][_0x8db2('0x2f')]){_0x2b653b['include']=[{'all':!![]}];}_0x2b653b=_[_0x8db2('0x30')]({},_0x2b653b,_0x56b71a[_0x8db2('0x31')]);return db[_0x8db2('0x1f')][_0x8db2('0x32')](_0x2b653b)['then'](handleEntityNotFound(_0x3f7aac,null))[_0x8db2('0x17')](respondWithResult(_0x3f7aac,null))['catch'](handleError(_0x3f7aac,null));};exports[_0x8db2('0x33')]=function(_0xd550ae,_0x2c8bc9){return db[_0x8db2('0x1f')]['create'](_0xd550ae['body'],{})[_0x8db2('0x17')](function(_0x2c0507){var _0x5dc2b4=_0xd550ae[_0x8db2('0x34')][_0x8db2('0x18')]({'plain':!![]});if(!_0x5dc2b4)throw new Error(_0x8db2('0x35'));if(_0x5dc2b4['role']===_0x8db2('0x34')){var _0x149186=_0x2c0507[_0x8db2('0x18')]({'plain':!![]});var _0x279e74=_0x8db2('0x19');return db[_0x8db2('0x36')][_0x8db2('0x32')]({'where':{'name':_0x279e74,'userProfileId':_0x5dc2b4[_0x8db2('0x37')]},'raw':!![]})[_0x8db2('0x17')](function(_0x63c561){if(_0x63c561&&_0x63c561[_0x8db2('0x38')]===0x0){return db[_0x8db2('0x39')][_0x8db2('0x33')]({'name':_0x149186['name'],'resourceId':_0x149186['id'],'type':_0x63c561[_0x8db2('0x1d')],'sectionId':_0x63c561['id']},{})[_0x8db2('0x17')](function(){return _0x2c0507;});}else{return _0x2c0507;}})['catch'](function(_0x49a7ae){logger[_0x8db2('0x1b')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x49a7ae);throw _0x49a7ae;});}return _0x2c0507;})[_0x8db2('0x17')](respondWithResult(_0x2c8bc9,0xc9))[_0x8db2('0x3a')](handleError(_0x2c8bc9,null));};exports[_0x8db2('0x16')]=function(_0x307783,_0xb4fe2c){if(_0x307783[_0x8db2('0x3b')]['id']){delete _0x307783[_0x8db2('0x3b')]['id'];}return db['SmsQueue'][_0x8db2('0x32')]({'where':{'id':_0x307783[_0x8db2('0x3c')]['id']}})[_0x8db2('0x17')](handleEntityNotFound(_0xb4fe2c,null))[_0x8db2('0x17')](saveUpdates(_0x307783['body'],null))[_0x8db2('0x17')](respondWithResult(_0xb4fe2c,null))[_0x8db2('0x3a')](handleError(_0xb4fe2c,null));};exports[_0x8db2('0x1a')]=function(_0x2c47cc,_0x5427af){return db[_0x8db2('0x1f')]['find']({'where':{'id':_0x2c47cc[_0x8db2('0x3c')]['id']}})[_0x8db2('0x17')](handleEntityNotFound(_0x5427af,null))[_0x8db2('0x17')](removeEntity(_0x5427af,null))['catch'](handleError(_0x5427af,null));};exports['describe']=function(_0x1ec3d0,_0x47c556){return db[_0x8db2('0x1f')][_0x8db2('0x3d')]()[_0x8db2('0x17')](respondWithResult(_0x47c556,null))[_0x8db2('0x3a')](handleError(_0x47c556,null));};exports[_0x8db2('0x3e')]=function(_0x40c6e6,_0x4355e2){var _0xab6bdd={'raw':!![],'where':{}},_0x4291e3={},_0x12a1ef;return db[_0x8db2('0x1f')][_0x8db2('0x3f')]({'where':{'id':_0x40c6e6['params']['id']}})[_0x8db2('0x17')](handleEntityNotFound(_0x4355e2,null))[_0x8db2('0x17')](function(_0xdbba64){if(_0xdbba64){_0x12a1ef=_0xdbba64[_0x8db2('0x18')]({'plain':!![]});_0x4291e3['model']=_['keys'](db[_0x8db2('0x40')][_0x8db2('0x41')]);_0x4291e3[_0x8db2('0x28')]=_['keys'](_0x40c6e6['query']);_0x4291e3['filters']=_[_0x8db2('0x2a')](_0x4291e3[_0x8db2('0x2b')],_0x4291e3[_0x8db2('0x28')]);_0xab6bdd[_0x8db2('0x2c')]=_[_0x8db2('0x2a')](_0x4291e3[_0x8db2('0x2b')],qs[_0x8db2('0x2d')](_0x40c6e6['query']['fields']));_0xab6bdd[_0x8db2('0x2c')]=_0xab6bdd[_0x8db2('0x2c')][_0x8db2('0x2e')]?_0xab6bdd[_0x8db2('0x2c')]:_0x4291e3[_0x8db2('0x2b')];if(!_0x40c6e6[_0x8db2('0x28')][_0x8db2('0x42')](_0x8db2('0x43'))){_0xab6bdd[_0x8db2('0x14')]=qs[_0x8db2('0x14')](_0x40c6e6[_0x8db2('0x28')][_0x8db2('0x14')]);_0xab6bdd[_0x8db2('0x11')]=qs[_0x8db2('0x11')](_0x40c6e6[_0x8db2('0x28')]['offset']);}_0xab6bdd[_0x8db2('0x44')]=qs[_0x8db2('0x45')](_0x40c6e6['query'][_0x8db2('0x45')]);_0xab6bdd[_0x8db2('0x23')]=qs[_0x8db2('0x29')](_['pick'](_0x40c6e6[_0x8db2('0x28')],_0x4291e3[_0x8db2('0x29')]));_0xab6bdd[_0x8db2('0x23')][_0x8db2('0x46')]=_0xdbba64['id'];if(_0x40c6e6[_0x8db2('0x28')]['filter']){_0xab6bdd[_0x8db2('0x23')]=_[_0x8db2('0x30')](_0xab6bdd[_0x8db2('0x23')],{'$or':_['map'](_0xab6bdd[_0x8db2('0x2c')],function(_0x18cc13){var _0x33dddd={};_0x33dddd[_0x18cc13]={'$like':'%'+_0x40c6e6[_0x8db2('0x28')][_0x8db2('0x47')]+'%'};return _0x33dddd;})});}_0xab6bdd=_[_0x8db2('0x30')]({},_0xab6bdd,_0x40c6e6[_0x8db2('0x31')]);return db['UserSmsQueue'][_0x8db2('0x48')](_0xab6bdd);}})[_0x8db2('0x17')](function(_0x4d3c19){if(_0x4d3c19){return db[_0x8db2('0x49')][_0x8db2('0x4a')]({'where':{'id':_['map'](_0x4d3c19,_0x8db2('0x4b')),'role':_0x8db2('0x4c')},'attributes':['id',_0x8db2('0x1d'),_0x8db2('0x4d'),_0x8db2('0x4e'),_0x8db2('0x4f')]});}})[_0x8db2('0x17')](function(_0x33a600){if(_0x33a600){return{'count':_0x33a600[_0x8db2('0x13')],'rows':_[_0x8db2('0x1e')](_0x33a600[_0x8db2('0x25')],function(_0x447a47){return{'membername':_0x447a47[_0x8db2('0x1d')],'UserId':_0x447a47['id'],'queue_name':_0x12a1ef[_0x8db2('0x1d')],'SmsQueueId':_0x12a1ef['id'],'interface':util[_0x8db2('0x50')](_0x8db2('0x51'),'SIP',_0x447a47[_0x8db2('0x1d')]),'penalty':0x0,'paused':_0x447a47[_0x8db2('0x4d')],'createdAt':_0x447a47[_0x8db2('0x4f')],'updatedAt':_0x447a47[_0x8db2('0x4e')]};})};}else{return{'count':0x0,'rows':[]};}})[_0x8db2('0x17')](respondWithFilteredResult(_0x4355e2,_0xab6bdd))['catch'](handleError(_0x4355e2,null));};exports[_0x8db2('0x52')]=function(_0x2c3087,_0x3ab670){var _0x1e1c0d={};var _0x2ad70f={};var _0x348da8;var _0x17341d;return db[_0x8db2('0x1f')][_0x8db2('0x3f')]({'where':{'id':_0x2c3087[_0x8db2('0x3c')]['id']}})[_0x8db2('0x17')](handleEntityNotFound(_0x3ab670,null))[_0x8db2('0x17')](function(_0x170a72){if(_0x170a72){_0x348da8=_0x170a72;_0x2ad70f[_0x8db2('0x2b')]=_[_0x8db2('0x27')](db[_0x8db2('0x53')][_0x8db2('0x41')]);_0x2ad70f[_0x8db2('0x28')]=_['keys'](_0x2c3087[_0x8db2('0x28')]);_0x2ad70f['filters']=_[_0x8db2('0x2a')](_0x2ad70f['model'],_0x2ad70f[_0x8db2('0x28')]);_0x1e1c0d[_0x8db2('0x2c')]=_[_0x8db2('0x2a')](_0x2ad70f[_0x8db2('0x2b')],qs[_0x8db2('0x2d')](_0x2c3087['query']['fields']));_0x1e1c0d[_0x8db2('0x2c')]=_0x1e1c0d[_0x8db2('0x2c')][_0x8db2('0x2e')]?_0x1e1c0d[_0x8db2('0x2c')]:_0x2ad70f[_0x8db2('0x2b')];_0x1e1c0d[_0x8db2('0x44')]=qs[_0x8db2('0x45')](_0x2c3087[_0x8db2('0x28')]['sort']);_0x1e1c0d[_0x8db2('0x23')]=qs[_0x8db2('0x29')](_[_0x8db2('0x54')](_0x2c3087[_0x8db2('0x28')],_0x2ad70f[_0x8db2('0x29')]));if(_0x2c3087[_0x8db2('0x28')][_0x8db2('0x47')]){_0x1e1c0d[_0x8db2('0x23')]=_['merge'](_0x1e1c0d['where'],{'$or':_[_0x8db2('0x1e')](_0x1e1c0d[_0x8db2('0x2c')],function(_0x1d2dfc){var _0x27f4cd={};_0x27f4cd[_0x1d2dfc]={'$like':'%'+_0x2c3087[_0x8db2('0x28')]['filter']+'%'};return _0x27f4cd;})});}_0x1e1c0d=_['merge']({},_0x1e1c0d,_0x2c3087[_0x8db2('0x31')]);return _0x348da8[_0x8db2('0x52')](_0x1e1c0d);}})['then'](function(_0xa698bd){if(_0xa698bd){_0x17341d=_0xa698bd[_0x8db2('0x2e')];if(!_0x2c3087[_0x8db2('0x28')]['hasOwnProperty'](_0x8db2('0x43'))){_0x1e1c0d[_0x8db2('0x14')]=qs[_0x8db2('0x14')](_0x2c3087['query'][_0x8db2('0x14')]);_0x1e1c0d[_0x8db2('0x11')]=qs[_0x8db2('0x11')](_0x2c3087[_0x8db2('0x28')][_0x8db2('0x11')]);}return _0x348da8['getTeams'](_0x1e1c0d);}})[_0x8db2('0x17')](function(_0x3023fe){if(_0x3023fe){return _0x3023fe?{'count':_0x17341d,'rows':_0x3023fe}:null;}})[_0x8db2('0x17')](respondWithResult(_0x3ab670,null))['catch'](handleError(_0x3ab670,null));};exports['addTeams']=function(_0x2cdf3c,_0xbe05ca){var _0x487dcb=_0x2cdf3c[_0x8db2('0x3b')][_0x8db2('0x55')];return db[_0x8db2('0x53')][_0x8db2('0x48')]({'where':{'id':_0x487dcb},'attributes':['id'],'include':[{'model':db[_0x8db2('0x49')],'as':_0x8db2('0x56'),'attributes':['id',_0x8db2('0x1d'),_0x8db2('0x57'),_0x8db2('0x58'),_0x8db2('0x59')],'raw':!![]}]})[_0x8db2('0x17')](function(_0x3e1478){if(_0x3e1478){var _0x24a52d=_['flatMap'](_0x3e1478,function(_0x2ba42d){var _0x4f29f1=_0x2ba42d[_0x8db2('0x18')]({'plain':!![]});return _0x4f29f1[_0x8db2('0x56')];});return db['SmsQueue'][_0x8db2('0x32')]({'where':{'id':_0x2cdf3c[_0x8db2('0x3c')]['id']}})['then'](function(_0x2159c4){return db[_0x8db2('0x5a')][_0x8db2('0x5b')](function(_0x25a3ab){return _0x2159c4[_0x8db2('0x5c')](_0x487dcb,{'transaction':_0x25a3ab})[_0x8db2('0x17')](function(){return BPromise[_0x8db2('0x5d')](_0x24a52d,function(_0x3ac0fa){return db[_0x8db2('0x40')]['findOrCreate']({'where':{'UserId':_0x3ac0fa['id'],'SmsQueueId':_0x2cdf3c['params']['id']},'transaction':_0x25a3ab});});})[_0x8db2('0x17')](function(){_0x24a52d['forEach'](function(_0xf8afa5){socket[_0x8db2('0x5e')](_0x8db2('0x5f'),{'UserId':_0xf8afa5['id'],'SmsQueueId':_0x2159c4['id']});});});});});}})['then'](respondWithStatusCode(_0xbe05ca,null))[_0x8db2('0x3a')](handleError(_0xbe05ca,null));};exports[_0x8db2('0x60')]=function(_0x3e37e7,_0x591c5d){return db[_0x8db2('0x53')][_0x8db2('0x48')]({'where':{'id':_0x3e37e7[_0x8db2('0x28')][_0x8db2('0x55')]},'attributes':['id'],'include':[{'model':db['User'],'as':_0x8db2('0x56'),'attributes':['id'],'raw':!![]}]})[_0x8db2('0x17')](handleEntityNotFound(_0x591c5d,null))[_0x8db2('0x17')](function(_0x1edb1a){var _0xcf1c42=_[_0x8db2('0x1e')](_0x1edb1a,'id');var _0x1aadfb=[];var _0x3682bf=[];var _0x358f48=squel[_0x8db2('0x61')]();_0x358f48[_0x8db2('0x62')]('tq.TeamId')[_0x8db2('0x63')](_0x8db2('0x64'),'tq')[_0x8db2('0x65')]('user_has_teams','ut','ut.TeamId\x20=\x20tq.TeamId')['where'](_0x8db2('0x66'),_0x3e37e7[_0x8db2('0x3c')]['id']);for(var _0x3191c8=0x0;_0x3191c8<_0x1edb1a[_0x8db2('0x2e')];_0x3191c8+=0x1){let _0x2ad024=_0x1edb1a[_0x3191c8];for(var _0x313918=0x0;_0x313918<_0x2ad024[_0x8db2('0x56')][_0x8db2('0x2e')];_0x313918+=0x1){let _0x3b1929=_0x2ad024[_0x8db2('0x56')][_0x313918];var _0x46eb80=_0x358f48['clone']();_0x46eb80[_0x8db2('0x23')](_0x8db2('0x67'),_0x3b1929['id']);_0x3682bf[_0x8db2('0x68')](db[_0x8db2('0x5a')]['query'](_0x46eb80['toString'](),{'type':db[_0x8db2('0x5a')][_0x8db2('0x69')]['SELECT']})[_0x8db2('0x17')](function(_0x121f31){if(_0x121f31[_0x8db2('0x2e')]===0x1){return _0x3b1929['id'];}else{var _0x5f2ece=_['every'](_['map'](_0x121f31,_0x8db2('0x6a')),function(_0x18b4a6){return _[_0x8db2('0x6b')](_0xcf1c42,_0x18b4a6);});if(_0x5f2ece){return _0x3b1929['id'];}}}));}}return BPromise[_0x8db2('0x6c')](_0x3682bf)[_0x8db2('0x17')](function(_0x4e8aac){_0x1aadfb=_(_0x1aadfb)[_0x8db2('0x6d')](_0x4e8aac)['compact']()[_0x8db2('0x6e')]();return db[_0x8db2('0x1f')][_0x8db2('0x32')]({'where':{'id':_0x3e37e7[_0x8db2('0x3c')]['id']}})[_0x8db2('0x17')](function(_0x5d5380){return db['sequelize'][_0x8db2('0x5b')](function(_0x51afcf){return _0x5d5380[_0x8db2('0x60')](_0x3e37e7[_0x8db2('0x28')][_0x8db2('0x55')],{'transaction':_0x51afcf})[_0x8db2('0x17')](function(){if(!_[_0x8db2('0x6f')](_0x1aadfb)){return _0x5d5380[_0x8db2('0x70')](_0x1aadfb,{'transaction':_0x51afcf});}})['then'](function(){_0x1aadfb[_0x8db2('0x71')](function(_0x222ea2){socket[_0x8db2('0x5e')]('userSmsQueue:remove',{'UserId':_0x222ea2,'SmsQueueId':_0x5d5380['id']});});});});});});})[_0x8db2('0x17')](respondWithStatusCode(_0x591c5d,null))[_0x8db2('0x3a')](handleError(_0x591c5d,null));};exports['addAgents']=function(_0x2d7abf,_0x7cb97d){return db[_0x8db2('0x1f')][_0x8db2('0x32')]({'where':{'id':_0x2d7abf[_0x8db2('0x3c')]['id']}})[_0x8db2('0x17')](handleEntityNotFound(_0x7cb97d,null))[_0x8db2('0x17')](function(_0x19e25b){if(_0x19e25b){return _0x19e25b[_0x8db2('0x72')](_0x2d7abf['body'][_0x8db2('0x55')],_[_0x8db2('0x73')](_0x2d7abf[_0x8db2('0x3b')],[_0x8db2('0x55'),'id'])||{})[_0x8db2('0x74')](function(_0x345ff9){for(var _0x16d1c5=0x0;_0x16d1c5<_0x2d7abf[_0x8db2('0x3b')][_0x8db2('0x55')][_0x8db2('0x2e')];_0x16d1c5+=0x1){socket['emit'](_0x8db2('0x5f'),{'UserId':Number(_0x2d7abf[_0x8db2('0x3b')][_0x8db2('0x55')][_0x16d1c5]),'SmsQueueId':Number(_0x2d7abf[_0x8db2('0x3c')]['id'])});}return _0x345ff9;});}})['then'](respondWithResult(_0x7cb97d,null))[_0x8db2('0x3a')](handleError(_0x7cb97d,null));};exports[_0x8db2('0x70')]=function(_0x46476e,_0x4f653e){return db['SmsQueue'][_0x8db2('0x32')]({'where':{'id':_0x46476e[_0x8db2('0x3c')]['id']}})[_0x8db2('0x17')](handleEntityNotFound(_0x4f653e,null))[_0x8db2('0x17')](function(_0x4f9ce4){if(_0x4f9ce4){return _0x4f9ce4[_0x8db2('0x70')](_0x46476e[_0x8db2('0x28')][_0x8db2('0x55')])[_0x8db2('0x17')](function(){if(_['isArray'](_0x46476e[_0x8db2('0x28')][_0x8db2('0x55')])){for(var _0x3e7b24=0x0;_0x3e7b24<_0x46476e['query']['ids']['length'];_0x3e7b24+=0x1){socket[_0x8db2('0x5e')](_0x8db2('0x75'),{'UserId':Number(_0x46476e[_0x8db2('0x28')][_0x8db2('0x55')][_0x3e7b24]),'SmsQueueId':Number(_0x46476e['params']['id'])});}}else{socket['emit'](_0x8db2('0x75'),{'UserId':Number(_0x46476e[_0x8db2('0x28')][_0x8db2('0x55')]),'SmsQueueId':Number(_0x46476e[_0x8db2('0x3c')]['id'])});}});}})[_0x8db2('0x17')](respondWithStatusCode(_0x4f653e,null))[_0x8db2('0x3a')](handleError(_0x4f653e,null));};exports['getAgents']=function(_0x2942eb,_0x5f32ce){var _0x432780={};var _0x23457b={};var _0x1ef898;var _0x39f2d3;return db[_0x8db2('0x1f')]['findOne']({'where':{'id':_0x2942eb[_0x8db2('0x3c')]['id']}})[_0x8db2('0x17')](handleEntityNotFound(_0x5f32ce,null))['then'](function(_0x28beec){if(_0x28beec){_0x1ef898=_0x28beec;_0x23457b[_0x8db2('0x2b')]=_[_0x8db2('0x27')](db[_0x8db2('0x49')]['rawAttributes']);_0x23457b[_0x8db2('0x28')]=_['keys'](_0x2942eb['query']);_0x23457b[_0x8db2('0x29')]=_[_0x8db2('0x2a')](_0x23457b[_0x8db2('0x2b')],_0x23457b[_0x8db2('0x28')]);_0x432780[_0x8db2('0x2c')]=_[_0x8db2('0x2a')](_0x23457b[_0x8db2('0x2b')],qs['fields'](_0x2942eb[_0x8db2('0x28')]['fields']));_0x432780['attributes']=_0x432780[_0x8db2('0x2c')]['length']?_0x432780['attributes']:_0x23457b[_0x8db2('0x2b')];_0x432780[_0x8db2('0x44')]=qs[_0x8db2('0x45')](_0x2942eb['query'][_0x8db2('0x45')]);_0x432780[_0x8db2('0x23')]=qs[_0x8db2('0x29')](_['pick'](_0x2942eb[_0x8db2('0x28')],_0x23457b[_0x8db2('0x29')]));if(_0x2942eb[_0x8db2('0x28')][_0x8db2('0x47')]){_0x432780[_0x8db2('0x23')]=_[_0x8db2('0x30')](_0x432780[_0x8db2('0x23')],{'$or':_[_0x8db2('0x1e')](_0x432780['attributes'],function(_0xa7b208){var _0x3cb456={};_0x3cb456[_0xa7b208]={'$like':'%'+_0x2942eb[_0x8db2('0x28')][_0x8db2('0x47')]+'%'};return _0x3cb456;})});}_0x432780=_[_0x8db2('0x30')]({},_0x432780,_0x2942eb[_0x8db2('0x31')]);return _0x1ef898[_0x8db2('0x76')](_0x432780);}})[_0x8db2('0x17')](function(_0x3a53e2){if(_0x3a53e2){_0x39f2d3=_0x3a53e2[_0x8db2('0x2e')];if(!_0x2942eb[_0x8db2('0x28')]['hasOwnProperty'](_0x8db2('0x43'))){_0x432780[_0x8db2('0x14')]=qs[_0x8db2('0x14')](_0x2942eb['query'][_0x8db2('0x14')]);_0x432780[_0x8db2('0x11')]=qs[_0x8db2('0x11')](_0x2942eb['query']['offset']);}return _0x1ef898[_0x8db2('0x76')](_0x432780);}})[_0x8db2('0x17')](function(_0x296966){if(_0x296966){return _0x296966?{'count':_0x39f2d3,'rows':_0x296966}:null;}})[_0x8db2('0x17')](respondWithResult(_0x5f32ce,null))[_0x8db2('0x3a')](handleError(_0x5f32ce,null));};
\ No newline at end of file