Built motion from commit 10af8726.|2.6.34
[motion2.git] / server / api / smsQueue / smsQueue.controller.js
index 20f08f3..c998908 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x5fc3=['team_has_sms_queues','join','ut.TeamId\x20=\x20tq.TeamId','SmsQueueId\x20=\x20?','clone','ut.UserId\x20=\x20?','push','sequelize','toString','QueryTypes','SELECT','every','TeamId','includes','all','compact','value','userSmsQueue:remove','addAgents','omit','spread','emit','userSmsQueue:save','removeAgents','isArray','getAgents','html-pdf','eml-format','zip-dir','fast-json-patch','request-promise','moment','bluebird','util','path','sox','lodash','crypto','jsforce','desk.js','to-csv','querystring','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/environment','../../config/license/util','defaults','localhost','socket.io-emitter','redis','./smsQueue.socket','register','status','end','count','offset','set','Content-Range','json','apply','reject','save','update','then','get','SmsQueues','destroy','error','stack','name','index','map','SmsQueue','rawAttributes','fieldName','type','key','keys','query','filters','intersection','model','fields','attributes','length','hasOwnProperty','limit','sort','where','pick','merge','VIRTUAL','filter','options','includeAll','include','findAll','rows','params','catch','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','find','userProfileId','autoAssociation','UserProfileResource','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','findOne','nolimit','order','UserSmsQueue','User','findAndCountAll','UserId','agent','updatedAt','createdAt','format','%s/%s','SIP','smsPause','getTeams','Team','addTeams','ids','Agents','voicePause','transaction','findOrCreate','forEach','removeTeams','select','tq.TeamId','from'];(function(_0x482a12,_0x38e1d2){var _0xcd464e=function(_0x4c82c9){while(--_0x4c82c9){_0x482a12['push'](_0x482a12['shift']());}};_0xcd464e(++_0x38e1d2);}(_0x5fc3,0xa8));var _0x35fc=function(_0x45bf86,_0x75586e){_0x45bf86=_0x45bf86-0x0;var _0x1f02b7=_0x5fc3[_0x45bf86];return _0x1f02b7;};'use strict';var pdf=require(_0x35fc('0x0'));var emlformat=require(_0x35fc('0x1'));var rimraf=require('rimraf');var zipdir=require(_0x35fc('0x2'));var jsonpatch=require(_0x35fc('0x3'));var rp=require(_0x35fc('0x4'));var moment=require(_0x35fc('0x5'));var BPromise=require(_0x35fc('0x6'));var Mustache=require('mustache');var util=require(_0x35fc('0x7'));var path=require(_0x35fc('0x8'));var sox=require(_0x35fc('0x9'));var csv=require('to-csv');var ejs=require('ejs');var fs=require('fs');var _=require(_0x35fc('0xa'));var squel=require('squel');var crypto=require(_0x35fc('0xb'));var jsforce=require(_0x35fc('0xc'));var deskjs=require(_0x35fc('0xd'));var toCsv=require(_0x35fc('0xe'));var querystring=require(_0x35fc('0xf'));var Papa=require(_0x35fc('0x10'));var Redis=require(_0x35fc('0x11'));var authService=require('../../components/auth/service');var qs=require(_0x35fc('0x12'));var as=require(_0x35fc('0x13'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x35fc('0x14'))(_0x35fc('0x15'));var utils=require('../../config/utils');var config=require(_0x35fc('0x16'));var licenseUtil=require(_0x35fc('0x17'));var db=require('../../mysqldb')['db'];config['redis']=_[_0x35fc('0x18')](config['redis'],{'host':_0x35fc('0x19'),'port':0x18eb});var socket=require(_0x35fc('0x1a'))(new Redis(config[_0x35fc('0x1b')]));require(_0x35fc('0x1c'))[_0x35fc('0x1d')](socket);function respondWithStatusCode(_0x5cfe94,_0x59507a){_0x59507a=_0x59507a||0xcc;return function(_0x5eac0f){if(_0x5eac0f){return _0x5cfe94['sendStatus'](_0x59507a);}return _0x5cfe94[_0x35fc('0x1e')](_0x59507a)[_0x35fc('0x1f')]();};}function respondWithResult(_0x53b898,_0x154958){_0x154958=_0x154958||0xc8;return function(_0x227a49){if(_0x227a49){return _0x53b898[_0x35fc('0x1e')](_0x154958)['json'](_0x227a49);}};}function respondWithFilteredResult(_0x26ba54,_0x45c8b7){return function(_0x553677){if(_0x553677){var _0x41e165=_0x553677[_0x35fc('0x20')],_0x363e47=_0x45c8b7[_0x35fc('0x21')],_0x2e513b=_0x45c8b7[_0x35fc('0x21')]+_0x45c8b7['limit'],_0x5f56c6;if(_0x2e513b>=_0x41e165){_0x2e513b=_0x41e165;_0x5f56c6=0xc8;}else{_0x5f56c6=0xce;}_0x26ba54[_0x35fc('0x1e')](_0x5f56c6);return _0x26ba54[_0x35fc('0x22')](_0x35fc('0x23'),_0x363e47+'-'+_0x2e513b+'/'+_0x41e165)[_0x35fc('0x24')](_0x553677);}return null;};}function patchUpdates(_0x20ffde){return function(_0x21f1a9){try{jsonpatch[_0x35fc('0x25')](_0x21f1a9,_0x20ffde,!![]);}catch(_0x3b05b0){return BPromise[_0x35fc('0x26')](_0x3b05b0);}return _0x21f1a9[_0x35fc('0x27')]();};}function saveUpdates(_0x5bd2b8,_0x323aee){return function(_0xd5399f){if(_0xd5399f){return _0xd5399f[_0x35fc('0x28')](_0x5bd2b8)[_0x35fc('0x29')](function(_0x3b4743){return _0x3b4743;});}return null;};}function removeEntity(_0x55e9e7,_0x33f5e8){return function(_0x4c587a){if(_0x4c587a){return _0x4c587a['destroy']()[_0x35fc('0x29')](function(){var _0x5a93df=_0x4c587a[_0x35fc('0x2a')]({'plain':!![]});var _0x51cfec=_0x35fc('0x2b');return db['UserProfileResource'][_0x35fc('0x2c')]({'where':{'type':_0x51cfec,'resourceId':_0x5a93df['id']}})[_0x35fc('0x29')](function(){return _0x4c587a;});})['then'](function(){_0x55e9e7['status'](0xcc)[_0x35fc('0x1f')]();});}};}function handleEntityNotFound(_0x58edb6,_0x274208){return function(_0x1a5d92){if(!_0x1a5d92){_0x58edb6['sendStatus'](0x194);}return _0x1a5d92;};}function handleError(_0x26b7cb,_0x645eac){_0x645eac=_0x645eac||0x1f4;return function(_0x383837){logger[_0x35fc('0x2d')](_0x383837[_0x35fc('0x2e')]);if(_0x383837[_0x35fc('0x2f')]){delete _0x383837[_0x35fc('0x2f')];}_0x26b7cb[_0x35fc('0x1e')](_0x645eac)['send'](_0x383837);};}exports[_0x35fc('0x30')]=function(_0x220931,_0x22af18){var _0x52acc5={},_0xe79f52={},_0x16f067={'count':0x0,'rows':[]};var _0x3822a8=_[_0x35fc('0x31')](db[_0x35fc('0x32')][_0x35fc('0x33')],function(_0x222ddb){return{'name':_0x222ddb[_0x35fc('0x34')],'type':_0x222ddb[_0x35fc('0x35')][_0x35fc('0x36')]};});_0xe79f52['model']=_['map'](_0x3822a8,_0x35fc('0x2f'));_0xe79f52['query']=_[_0x35fc('0x37')](_0x220931[_0x35fc('0x38')]);_0xe79f52[_0x35fc('0x39')]=_[_0x35fc('0x3a')](_0xe79f52[_0x35fc('0x3b')],_0xe79f52[_0x35fc('0x38')]);_0x52acc5['attributes']=_[_0x35fc('0x3a')](_0xe79f52[_0x35fc('0x3b')],qs[_0x35fc('0x3c')](_0x220931[_0x35fc('0x38')][_0x35fc('0x3c')]));_0x52acc5[_0x35fc('0x3d')]=_0x52acc5['attributes'][_0x35fc('0x3e')]?_0x52acc5[_0x35fc('0x3d')]:_0xe79f52[_0x35fc('0x3b')];if(!_0x220931['query'][_0x35fc('0x3f')]('nolimit')){_0x52acc5[_0x35fc('0x40')]=qs[_0x35fc('0x40')](_0x220931[_0x35fc('0x38')][_0x35fc('0x40')]);_0x52acc5['offset']=qs['offset'](_0x220931['query'][_0x35fc('0x21')]);}_0x52acc5['order']=qs[_0x35fc('0x41')](_0x220931['query'][_0x35fc('0x41')]);_0x52acc5[_0x35fc('0x42')]=qs[_0x35fc('0x39')](_[_0x35fc('0x43')](_0x220931[_0x35fc('0x38')],_0xe79f52[_0x35fc('0x39')]),_0x3822a8);if(_0x220931[_0x35fc('0x38')]['filter']){_0x52acc5[_0x35fc('0x42')]=_[_0x35fc('0x44')](_0x52acc5['where'],{'$or':_[_0x35fc('0x31')](_0x3822a8,function(_0x1ccc41){if(_0x1ccc41[_0x35fc('0x35')]!==_0x35fc('0x45')){var _0x813866={};_0x813866[_0x1ccc41[_0x35fc('0x2f')]]={'$like':'%'+_0x220931['query'][_0x35fc('0x46')]+'%'};return _0x813866;}})});}_0x52acc5=_[_0x35fc('0x44')]({},_0x52acc5,_0x220931[_0x35fc('0x47')]);var _0x52543b={'where':_0x52acc5[_0x35fc('0x42')]};return db[_0x35fc('0x32')]['count'](_0x52543b)[_0x35fc('0x29')](function(_0x280af1){_0x16f067[_0x35fc('0x20')]=_0x280af1;if(_0x220931[_0x35fc('0x38')][_0x35fc('0x48')]){_0x52acc5[_0x35fc('0x49')]=[{'all':!![]}];}return db[_0x35fc('0x32')][_0x35fc('0x4a')](_0x52acc5);})['then'](function(_0x596e83){_0x16f067[_0x35fc('0x4b')]=_0x596e83;return _0x16f067;})[_0x35fc('0x29')](respondWithFilteredResult(_0x22af18,_0x52acc5))['catch'](handleError(_0x22af18,null));};exports['show']=function(_0x4ff202,_0x79677d){var _0x10f98b={'raw':!![],'where':{'id':_0x4ff202[_0x35fc('0x4c')]['id']}},_0x4e56ed={};_0x4e56ed[_0x35fc('0x3b')]=_[_0x35fc('0x37')](db[_0x35fc('0x32')]['rawAttributes']);_0x4e56ed['query']=_['keys'](_0x4ff202['query']);_0x4e56ed['filters']=_[_0x35fc('0x3a')](_0x4e56ed[_0x35fc('0x3b')],_0x4e56ed['query']);_0x10f98b[_0x35fc('0x3d')]=_['intersection'](_0x4e56ed[_0x35fc('0x3b')],qs[_0x35fc('0x3c')](_0x4ff202[_0x35fc('0x38')][_0x35fc('0x3c')]));_0x10f98b[_0x35fc('0x3d')]=_0x10f98b['attributes'][_0x35fc('0x3e')]?_0x10f98b[_0x35fc('0x3d')]:_0x4e56ed['model'];if(_0x4ff202[_0x35fc('0x38')][_0x35fc('0x48')]){_0x10f98b[_0x35fc('0x49')]=[{'all':!![]}];}_0x10f98b=_[_0x35fc('0x44')]({},_0x10f98b,_0x4ff202['options']);return db[_0x35fc('0x32')]['find'](_0x10f98b)['then'](handleEntityNotFound(_0x79677d,null))[_0x35fc('0x29')](respondWithResult(_0x79677d,null))[_0x35fc('0x4d')](handleError(_0x79677d,null));};exports[_0x35fc('0x4e')]=function(_0xca8aef,_0xf2ca20){return db[_0x35fc('0x32')][_0x35fc('0x4e')](_0xca8aef[_0x35fc('0x4f')],{})['then'](function(_0x3e2961){var _0x91d7c0=_0xca8aef[_0x35fc('0x50')][_0x35fc('0x2a')]({'plain':!![]});if(!_0x91d7c0)throw new Error(_0x35fc('0x51'));if(_0x91d7c0[_0x35fc('0x52')]===_0x35fc('0x50')){var _0x347a4a=_0x3e2961[_0x35fc('0x2a')]({'plain':!![]});var _0xe6eb6a=_0x35fc('0x2b');return db[_0x35fc('0x53')][_0x35fc('0x54')]({'where':{'name':_0xe6eb6a,'userProfileId':_0x91d7c0[_0x35fc('0x55')]},'raw':!![]})['then'](function(_0x553ed6){if(_0x553ed6&&_0x553ed6[_0x35fc('0x56')]===0x0){return db[_0x35fc('0x57')][_0x35fc('0x4e')]({'name':_0x347a4a[_0x35fc('0x2f')],'resourceId':_0x347a4a['id'],'type':_0x553ed6[_0x35fc('0x2f')],'sectionId':_0x553ed6['id']},{})[_0x35fc('0x29')](function(){return _0x3e2961;});}else{return _0x3e2961;}})['catch'](function(_0x4f024c){logger[_0x35fc('0x2d')](_0x35fc('0x58'),_0x4f024c);throw _0x4f024c;});}return _0x3e2961;})[_0x35fc('0x29')](respondWithResult(_0xf2ca20,0xc9))[_0x35fc('0x4d')](handleError(_0xf2ca20,null));};exports['update']=function(_0x467980,_0x13281f){if(_0x467980['body']['id']){delete _0x467980[_0x35fc('0x4f')]['id'];}return db[_0x35fc('0x32')]['find']({'where':{'id':_0x467980[_0x35fc('0x4c')]['id']}})[_0x35fc('0x29')](handleEntityNotFound(_0x13281f,null))[_0x35fc('0x29')](saveUpdates(_0x467980[_0x35fc('0x4f')],null))['then'](respondWithResult(_0x13281f,null))['catch'](handleError(_0x13281f,null));};exports['destroy']=function(_0x240338,_0x2ea8d6){return db['SmsQueue'][_0x35fc('0x54')]({'where':{'id':_0x240338[_0x35fc('0x4c')]['id']}})[_0x35fc('0x29')](handleEntityNotFound(_0x2ea8d6,null))[_0x35fc('0x29')](removeEntity(_0x2ea8d6,null))[_0x35fc('0x4d')](handleError(_0x2ea8d6,null));};exports['describe']=function(_0x2d9d45,_0x757aa6){return db[_0x35fc('0x32')]['describe']()[_0x35fc('0x29')](respondWithResult(_0x757aa6,null))[_0x35fc('0x4d')](handleError(_0x757aa6,null));};exports['getMembers']=function(_0x35a676,_0x164c7b,_0x1c46b1){var _0x1c4c33={'raw':!![],'where':{}},_0x314666={},_0x41453b;return db[_0x35fc('0x32')][_0x35fc('0x59')]({'where':{'id':_0x35a676['params']['id']}})[_0x35fc('0x29')](handleEntityNotFound(_0x164c7b,null))[_0x35fc('0x29')](function(_0x303927){if(_0x303927){_0x41453b=_0x303927['get']({'plain':!![]});_0x314666[_0x35fc('0x3b')]=_['keys'](db['UserSmsQueue']['rawAttributes']);_0x314666[_0x35fc('0x38')]=_[_0x35fc('0x37')](_0x35a676[_0x35fc('0x38')]);_0x314666[_0x35fc('0x39')]=_[_0x35fc('0x3a')](_0x314666['model'],_0x314666['query']);_0x1c4c33['attributes']=_['intersection'](_0x314666['model'],qs[_0x35fc('0x3c')](_0x35a676[_0x35fc('0x38')][_0x35fc('0x3c')]));_0x1c4c33[_0x35fc('0x3d')]=_0x1c4c33['attributes'][_0x35fc('0x3e')]?_0x1c4c33[_0x35fc('0x3d')]:_0x314666[_0x35fc('0x3b')];if(!_0x35a676[_0x35fc('0x38')][_0x35fc('0x3f')](_0x35fc('0x5a'))){_0x1c4c33[_0x35fc('0x40')]=qs[_0x35fc('0x40')](_0x35a676[_0x35fc('0x38')]['limit']);_0x1c4c33[_0x35fc('0x21')]=qs['offset'](_0x35a676[_0x35fc('0x38')][_0x35fc('0x21')]);}_0x1c4c33[_0x35fc('0x5b')]=qs[_0x35fc('0x41')](_0x35a676['query'][_0x35fc('0x41')]);_0x1c4c33['where']=qs['filters'](_['pick'](_0x35a676[_0x35fc('0x38')],_0x314666['filters']));_0x1c4c33[_0x35fc('0x42')]['SmsQueueId']=_0x303927['id'];if(_0x35a676[_0x35fc('0x38')]['filter']){_0x1c4c33[_0x35fc('0x42')]=_[_0x35fc('0x44')](_0x1c4c33[_0x35fc('0x42')],{'$or':_[_0x35fc('0x31')](_0x1c4c33['attributes'],function(_0x3d0ecc){var _0x1e2214={};_0x1e2214[_0x3d0ecc]={'$like':'%'+_0x35a676[_0x35fc('0x38')]['filter']+'%'};return _0x1e2214;})});}_0x1c4c33=_[_0x35fc('0x44')]({},_0x1c4c33,_0x35a676[_0x35fc('0x47')]);return db[_0x35fc('0x5c')][_0x35fc('0x4a')](_0x1c4c33);}})[_0x35fc('0x29')](function(_0x2c4309){if(_0x2c4309){return db[_0x35fc('0x5d')][_0x35fc('0x5e')]({'where':{'id':_['map'](_0x2c4309,_0x35fc('0x5f')),'role':_0x35fc('0x60')},'attributes':['id',_0x35fc('0x2f'),'smsPause',_0x35fc('0x61'),_0x35fc('0x62')]});}})['then'](function(_0x4d09d4){if(_0x4d09d4){return{'count':_0x4d09d4[_0x35fc('0x20')],'rows':_['map'](_0x4d09d4[_0x35fc('0x4b')],function(_0x2dbc81){return{'membername':_0x2dbc81[_0x35fc('0x2f')],'UserId':_0x2dbc81['id'],'queue_name':_0x41453b[_0x35fc('0x2f')],'SmsQueueId':_0x41453b['id'],'interface':util[_0x35fc('0x63')](_0x35fc('0x64'),_0x35fc('0x65'),_0x2dbc81[_0x35fc('0x2f')]),'penalty':0x0,'paused':_0x2dbc81[_0x35fc('0x66')],'createdAt':_0x2dbc81[_0x35fc('0x62')],'updatedAt':_0x2dbc81[_0x35fc('0x61')]};})};}else{return{'count':0x0,'rows':[]};}})[_0x35fc('0x29')](respondWithFilteredResult(_0x164c7b,_0x1c4c33))[_0x35fc('0x4d')](handleError(_0x164c7b,null));};exports[_0x35fc('0x67')]=function(_0x184f28,_0xd1e7ed,_0x2d8219){var _0x2d7b16={};var _0x3b2160={};var _0x3f3f36;var _0x4ba1b0;return db[_0x35fc('0x32')]['findOne']({'where':{'id':_0x184f28[_0x35fc('0x4c')]['id']}})[_0x35fc('0x29')](handleEntityNotFound(_0xd1e7ed,null))[_0x35fc('0x29')](function(_0x516b26){if(_0x516b26){_0x3f3f36=_0x516b26;_0x3b2160[_0x35fc('0x3b')]=_[_0x35fc('0x37')](db[_0x35fc('0x68')][_0x35fc('0x33')]);_0x3b2160[_0x35fc('0x38')]=_[_0x35fc('0x37')](_0x184f28[_0x35fc('0x38')]);_0x3b2160['filters']=_[_0x35fc('0x3a')](_0x3b2160[_0x35fc('0x3b')],_0x3b2160[_0x35fc('0x38')]);_0x2d7b16[_0x35fc('0x3d')]=_[_0x35fc('0x3a')](_0x3b2160[_0x35fc('0x3b')],qs['fields'](_0x184f28[_0x35fc('0x38')][_0x35fc('0x3c')]));_0x2d7b16[_0x35fc('0x3d')]=_0x2d7b16[_0x35fc('0x3d')][_0x35fc('0x3e')]?_0x2d7b16[_0x35fc('0x3d')]:_0x3b2160[_0x35fc('0x3b')];_0x2d7b16[_0x35fc('0x5b')]=qs[_0x35fc('0x41')](_0x184f28['query'][_0x35fc('0x41')]);_0x2d7b16['where']=qs[_0x35fc('0x39')](_[_0x35fc('0x43')](_0x184f28['query'],_0x3b2160[_0x35fc('0x39')]));if(_0x184f28[_0x35fc('0x38')][_0x35fc('0x46')]){_0x2d7b16[_0x35fc('0x42')]=_[_0x35fc('0x44')](_0x2d7b16[_0x35fc('0x42')],{'$or':_[_0x35fc('0x31')](_0x2d7b16[_0x35fc('0x3d')],function(_0x25ee61){var _0x5806bf={};_0x5806bf[_0x25ee61]={'$like':'%'+_0x184f28['query']['filter']+'%'};return _0x5806bf;})});}_0x2d7b16=_['merge']({},_0x2d7b16,_0x184f28[_0x35fc('0x47')]);return _0x3f3f36[_0x35fc('0x67')](_0x2d7b16);}})[_0x35fc('0x29')](function(_0x1f5cbc){if(_0x1f5cbc){_0x4ba1b0=_0x1f5cbc[_0x35fc('0x3e')];if(!_0x184f28['query'][_0x35fc('0x3f')](_0x35fc('0x5a'))){_0x2d7b16[_0x35fc('0x40')]=qs[_0x35fc('0x40')](_0x184f28['query'][_0x35fc('0x40')]);_0x2d7b16[_0x35fc('0x21')]=qs[_0x35fc('0x21')](_0x184f28['query'][_0x35fc('0x21')]);}return _0x3f3f36[_0x35fc('0x67')](_0x2d7b16);}})[_0x35fc('0x29')](function(_0x9fe765){if(_0x9fe765){return _0x9fe765?{'count':_0x4ba1b0,'rows':_0x9fe765}:null;}})[_0x35fc('0x29')](respondWithResult(_0xd1e7ed,null))[_0x35fc('0x4d')](handleError(_0xd1e7ed,null));};exports[_0x35fc('0x69')]=function(_0x13fc47,_0x4b6c03,_0x2faff7){var _0xa2c5f8=_0x13fc47[_0x35fc('0x4f')][_0x35fc('0x6a')];return db[_0x35fc('0x68')][_0x35fc('0x4a')]({'where':{'id':_0xa2c5f8},'attributes':['id'],'include':[{'model':db['User'],'as':_0x35fc('0x6b'),'attributes':['id','name','online',_0x35fc('0x6c'),'interface'],'raw':!![]}]})[_0x35fc('0x29')](function(_0x233b7d){if(_0x233b7d){var _0x2885b9=_['flatMap'](_0x233b7d,function(_0x205ee9){var _0x2b3edc=_0x205ee9[_0x35fc('0x2a')]({'plain':!![]});return _0x2b3edc[_0x35fc('0x6b')];});return db[_0x35fc('0x32')]['find']({'where':{'id':_0x13fc47['params']['id']}})['then'](function(_0x23b261){return db['sequelize'][_0x35fc('0x6d')](function(_0x1824c2){return _0x23b261[_0x35fc('0x69')](_0xa2c5f8,{'transaction':_0x1824c2})[_0x35fc('0x29')](function(){return BPromise['each'](_0x2885b9,function(_0x28e80d){return db[_0x35fc('0x5c')][_0x35fc('0x6e')]({'where':{'UserId':_0x28e80d['id'],'SmsQueueId':_0x13fc47['params']['id']},'transaction':_0x1824c2});});})[_0x35fc('0x29')](function(){_0x2885b9[_0x35fc('0x6f')](function(_0x163e70){socket['emit']('userSmsQueue:save',{'UserId':_0x163e70['id'],'SmsQueueId':_0x23b261['id']});});});});});}})['then'](respondWithStatusCode(_0x4b6c03,null))[_0x35fc('0x4d')](handleError(_0x4b6c03,null));};exports[_0x35fc('0x70')]=function(_0x163b04,_0x3858a9,_0x4859be){return db[_0x35fc('0x68')][_0x35fc('0x4a')]({'where':{'id':_0x163b04['query']['ids']},'attributes':['id'],'include':[{'model':db[_0x35fc('0x5d')],'as':_0x35fc('0x6b'),'attributes':['id'],'raw':!![]}]})[_0x35fc('0x29')](handleEntityNotFound(_0x3858a9,null))['then'](function(_0x4dd05f){var _0x134e60=_[_0x35fc('0x31')](_0x4dd05f,'id');var _0x4d5204=[];var _0x3439de=[];var _0x163edb=squel[_0x35fc('0x71')]();_0x163edb['field'](_0x35fc('0x72'))[_0x35fc('0x73')](_0x35fc('0x74'),'tq')[_0x35fc('0x75')]('user_has_teams','ut',_0x35fc('0x76'))[_0x35fc('0x42')](_0x35fc('0x77'),_0x163b04['params']['id']);for(var _0x96dfc=0x0;_0x96dfc<_0x4dd05f[_0x35fc('0x3e')];_0x96dfc+=0x1){let _0x425f72=_0x4dd05f[_0x96dfc];for(var _0x5c6c2b=0x0;_0x5c6c2b<_0x425f72[_0x35fc('0x6b')][_0x35fc('0x3e')];_0x5c6c2b+=0x1){let _0x524f49=_0x425f72[_0x35fc('0x6b')][_0x5c6c2b];var _0xa15c80=_0x163edb[_0x35fc('0x78')]();_0xa15c80[_0x35fc('0x42')](_0x35fc('0x79'),_0x524f49['id']);_0x3439de[_0x35fc('0x7a')](db[_0x35fc('0x7b')][_0x35fc('0x38')](_0xa15c80[_0x35fc('0x7c')](),{'type':db['sequelize'][_0x35fc('0x7d')][_0x35fc('0x7e')]})[_0x35fc('0x29')](function(_0x3f2788){if(_0x3f2788['length']===0x1){return _0x524f49['id'];}else{var _0x2f1c4d=_[_0x35fc('0x7f')](_[_0x35fc('0x31')](_0x3f2788,_0x35fc('0x80')),function(_0x4684b6){return _[_0x35fc('0x81')](_0x134e60,_0x4684b6);});if(_0x2f1c4d){return _0x524f49['id'];}}}));}}return BPromise[_0x35fc('0x82')](_0x3439de)[_0x35fc('0x29')](function(_0x5c4785){_0x4d5204=_(_0x4d5204)['union'](_0x5c4785)[_0x35fc('0x83')]()[_0x35fc('0x84')]();return db[_0x35fc('0x32')]['find']({'where':{'id':_0x163b04[_0x35fc('0x4c')]['id']}})[_0x35fc('0x29')](function(_0x699ecf){return db[_0x35fc('0x7b')]['transaction'](function(_0x5874db){return _0x699ecf[_0x35fc('0x70')](_0x163b04['query'][_0x35fc('0x6a')],{'transaction':_0x5874db})[_0x35fc('0x29')](function(){if(!_['isEmpty'](_0x4d5204)){return _0x699ecf['removeAgents'](_0x4d5204,{'transaction':_0x5874db});}})[_0x35fc('0x29')](function(){_0x4d5204[_0x35fc('0x6f')](function(_0xa4652b){socket['emit'](_0x35fc('0x85'),{'UserId':_0xa4652b,'SmsQueueId':_0x699ecf['id']});});});});});});})[_0x35fc('0x29')](respondWithStatusCode(_0x3858a9,null))[_0x35fc('0x4d')](handleError(_0x3858a9,null));};exports['addAgents']=function(_0xde26e7,_0x32cbd,_0x18b4bd){return db[_0x35fc('0x32')]['find']({'where':{'id':_0xde26e7[_0x35fc('0x4c')]['id']}})[_0x35fc('0x29')](handleEntityNotFound(_0x32cbd,null))[_0x35fc('0x29')](function(_0x2732a8){if(_0x2732a8){return _0x2732a8[_0x35fc('0x86')](_0xde26e7[_0x35fc('0x4f')]['ids'],_[_0x35fc('0x87')](_0xde26e7[_0x35fc('0x4f')],['ids','id'])||{})[_0x35fc('0x88')](function(_0xdb2f24){for(var _0x58feeb=0x0;_0x58feeb<_0xde26e7[_0x35fc('0x4f')][_0x35fc('0x6a')][_0x35fc('0x3e')];_0x58feeb+=0x1){socket[_0x35fc('0x89')](_0x35fc('0x8a'),{'UserId':_0xde26e7['body'][_0x35fc('0x6a')][_0x58feeb],'SmsQueueId':_0xde26e7[_0x35fc('0x4c')]['id']});}return _0xdb2f24;});}})[_0x35fc('0x29')](respondWithResult(_0x32cbd,null))['catch'](handleError(_0x32cbd,null));};exports[_0x35fc('0x8b')]=function(_0x5a8641,_0x58d3d5,_0x28582d){return db[_0x35fc('0x32')][_0x35fc('0x54')]({'where':{'id':_0x5a8641[_0x35fc('0x4c')]['id']}})[_0x35fc('0x29')](handleEntityNotFound(_0x58d3d5,null))['then'](function(_0x1a753){if(_0x1a753){return _0x1a753[_0x35fc('0x8b')](_0x5a8641[_0x35fc('0x38')]['ids'])[_0x35fc('0x29')](function(){if(_[_0x35fc('0x8c')](_0x5a8641[_0x35fc('0x38')][_0x35fc('0x6a')])){for(var _0x169112=0x0;_0x169112<_0x5a8641['query'][_0x35fc('0x6a')][_0x35fc('0x3e')];_0x169112+=0x1){socket['emit']('userSmsQueue:remove',{'UserId':Number(_0x5a8641[_0x35fc('0x38')][_0x35fc('0x6a')][_0x169112]),'SmsQueueId':Number(_0x5a8641[_0x35fc('0x4c')]['id'])});}}else{socket[_0x35fc('0x89')](_0x35fc('0x85'),{'UserId':Number(_0x5a8641[_0x35fc('0x38')][_0x35fc('0x6a')]),'SmsQueueId':Number(_0x5a8641['params']['id'])});}});}})['then'](respondWithStatusCode(_0x58d3d5,null))[_0x35fc('0x4d')](handleError(_0x58d3d5,null));};exports[_0x35fc('0x8d')]=function(_0x1c4eec,_0x1a92fa,_0x1c3630){var _0x4e40ad={};var _0x50e6bf={};var _0x2c213d;var _0x2451f2;return db[_0x35fc('0x32')][_0x35fc('0x59')]({'where':{'id':_0x1c4eec['params']['id']}})['then'](handleEntityNotFound(_0x1a92fa,null))[_0x35fc('0x29')](function(_0x2f7980){if(_0x2f7980){_0x2c213d=_0x2f7980;_0x50e6bf[_0x35fc('0x3b')]=_[_0x35fc('0x37')](db['User']['rawAttributes']);_0x50e6bf[_0x35fc('0x38')]=_[_0x35fc('0x37')](_0x1c4eec['query']);_0x50e6bf[_0x35fc('0x39')]=_[_0x35fc('0x3a')](_0x50e6bf[_0x35fc('0x3b')],_0x50e6bf[_0x35fc('0x38')]);_0x4e40ad[_0x35fc('0x3d')]=_[_0x35fc('0x3a')](_0x50e6bf[_0x35fc('0x3b')],qs[_0x35fc('0x3c')](_0x1c4eec[_0x35fc('0x38')][_0x35fc('0x3c')]));_0x4e40ad[_0x35fc('0x3d')]=_0x4e40ad[_0x35fc('0x3d')][_0x35fc('0x3e')]?_0x4e40ad[_0x35fc('0x3d')]:_0x50e6bf[_0x35fc('0x3b')];_0x4e40ad[_0x35fc('0x5b')]=qs['sort'](_0x1c4eec[_0x35fc('0x38')]['sort']);_0x4e40ad[_0x35fc('0x42')]=qs['filters'](_['pick'](_0x1c4eec[_0x35fc('0x38')],_0x50e6bf[_0x35fc('0x39')]));if(_0x1c4eec[_0x35fc('0x38')]['filter']){_0x4e40ad[_0x35fc('0x42')]=_[_0x35fc('0x44')](_0x4e40ad[_0x35fc('0x42')],{'$or':_[_0x35fc('0x31')](_0x4e40ad[_0x35fc('0x3d')],function(_0x1f7090){var _0x59f733={};_0x59f733[_0x1f7090]={'$like':'%'+_0x1c4eec['query'][_0x35fc('0x46')]+'%'};return _0x59f733;})});}_0x4e40ad=_['merge']({},_0x4e40ad,_0x1c4eec['options']);return _0x2c213d[_0x35fc('0x8d')](_0x4e40ad);}})['then'](function(_0x556f9a){if(_0x556f9a){_0x2451f2=_0x556f9a['length'];if(!_0x1c4eec[_0x35fc('0x38')]['hasOwnProperty'](_0x35fc('0x5a'))){_0x4e40ad[_0x35fc('0x40')]=qs[_0x35fc('0x40')](_0x1c4eec[_0x35fc('0x38')][_0x35fc('0x40')]);_0x4e40ad[_0x35fc('0x21')]=qs['offset'](_0x1c4eec['query'][_0x35fc('0x21')]);}return _0x2c213d['getAgents'](_0x4e40ad);}})[_0x35fc('0x29')](function(_0x39d9ec){if(_0x39d9ec){return _0x39d9ec?{'count':_0x2451f2,'rows':_0x39d9ec}:null;}})['then'](respondWithResult(_0x1a92fa,null))['catch'](handleError(_0x1a92fa,null));};
\ No newline at end of file
+var _0x5f66=['show','params','model','keys','intersection','attributes','fields','includeAll','merge','options','create','body','user','get','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','SmsQueues','find','userProfileId','error','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','describe','rawAttributes','filters','hasOwnProperty','order','sort','pick','map','UserSmsQueue','User','findAndCountAll','UserId','agent','smsPause','updatedAt','createdAt','%s/%s','SIP','getTeams','length','filter','nolimit','ids','Team','Agents','interface','flatMap','sequelize','transaction','addTeams','forEach','emit','userSmsQueue:save','removeTeams','select','tq.TeamId','team_has_sms_queues','user_has_teams','ut.TeamId\x20=\x20tq.TeamId','clone','ut.UserId\x20=\x20?','toString','QueryTypes','SELECT','includes','all','compact','value','isEmpty','removeAgents','userSmsQueue:remove','addAgents','spread','isArray','findOne','getAgents','util','squel','ioredis','../../components/parsers/qs','../../config/logger','api','../../mysqldb','defaults','redis','./smsQueue.socket','register','end','json','offset','limit','undefined','count','status','update','then','UserProfileResource','destroy','sendStatus','stack','name','send','index','fieldName','key','getOptions','where','SmsQueue','include','query','findAll','catch'];(function(_0x4d62ae,_0x1509f5){var _0x54d4b7=function(_0x492d51){while(--_0x492d51){_0x4d62ae['push'](_0x4d62ae['shift']());}};_0x54d4b7(++_0x1509f5);}(_0x5f66,0x1a0));var _0x65f6=function(_0x3947c9,_0x4d6c97){_0x3947c9=_0x3947c9-0x0;var _0x2e7871=_0x5f66[_0x3947c9];return _0x2e7871;};'use strict';var BPromise=require('bluebird');var util=require(_0x65f6('0x0'));var _=require('lodash');var squel=require(_0x65f6('0x1'));var Redis=require(_0x65f6('0x2'));var qs=require(_0x65f6('0x3'));var logger=require(_0x65f6('0x4'))(_0x65f6('0x5'));var config=require('../../config/environment');var db=require(_0x65f6('0x6'))['db'];config['redis']=_[_0x65f6('0x7')](config[_0x65f6('0x8')],{'host':'localhost','port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x65f6('0x8')]));require(_0x65f6('0x9'))[_0x65f6('0xa')](socket);function respondWithStatusCode(_0x8f6451,_0xc44c70){_0xc44c70=_0xc44c70||0xcc;return function(_0x14f4c7){if(_0x14f4c7){return _0x8f6451['sendStatus'](_0xc44c70);}return _0x8f6451['status'](_0xc44c70)[_0x65f6('0xb')]();};}function respondWithResult(_0x2f6d5b,_0x264647){_0x264647=_0x264647||0xc8;return function(_0x25c416){if(_0x25c416){return _0x2f6d5b['status'](_0x264647)[_0x65f6('0xc')](_0x25c416);}};}function respondWithFilteredResult(_0x571436,_0x497cf3){return function(_0x2d2dfa){if(_0x2d2dfa){var _0x576875=typeof _0x497cf3[_0x65f6('0xd')]==='undefined'&&typeof _0x497cf3[_0x65f6('0xe')]===_0x65f6('0xf');var _0x2c4ee5=_0x2d2dfa[_0x65f6('0x10')];var _0x369f96=_0x576875?0x0:_0x497cf3[_0x65f6('0xd')];var _0x44144b=_0x576875?_0x2d2dfa[_0x65f6('0x10')]:_0x497cf3[_0x65f6('0xd')]+_0x497cf3[_0x65f6('0xe')];var _0x59154e;if(_0x44144b>=_0x2c4ee5){_0x44144b=_0x2c4ee5;_0x59154e=0xc8;}else{_0x59154e=0xce;}_0x571436[_0x65f6('0x11')](_0x59154e);return _0x571436['set']('Content-Range',_0x369f96+'-'+_0x44144b+'/'+_0x2c4ee5)[_0x65f6('0xc')](_0x2d2dfa);}return null;};}function saveUpdates(_0x5c69f8){return function(_0x37330d){if(_0x37330d){return _0x37330d[_0x65f6('0x12')](_0x5c69f8)[_0x65f6('0x13')](function(_0x1f974c){return _0x1f974c;});}return null;};}function removeEntity(_0xc8660c){return function(_0x18380e){if(_0x18380e){return _0x18380e['destroy']()['then'](function(){var _0x2d538c=_0x18380e['get']({'plain':!![]});var _0x4c81f3='SmsQueues';return db[_0x65f6('0x14')][_0x65f6('0x15')]({'where':{'type':_0x4c81f3,'resourceId':_0x2d538c['id']}})['then'](function(){return _0x18380e;});})[_0x65f6('0x13')](function(){_0xc8660c[_0x65f6('0x11')](0xcc)[_0x65f6('0xb')]();});}};}function handleEntityNotFound(_0x3876ed){return function(_0x219ab2){if(!_0x219ab2){_0x3876ed[_0x65f6('0x16')](0x194);}return _0x219ab2;};}function handleError(_0x581374,_0x197a49){_0x197a49=_0x197a49||0x1f4;return function(_0x4bb39e){logger['error'](_0x4bb39e[_0x65f6('0x17')]);if(_0x4bb39e[_0x65f6('0x18')]){delete _0x4bb39e['name'];}_0x581374[_0x65f6('0x11')](_0x197a49)[_0x65f6('0x19')](_0x4bb39e);};}exports[_0x65f6('0x1a')]=function(_0x2774a1,_0x4f5a69){var _0x9d7bb0={};var _0x59ea32={'count':0x0,'rows':[]};var _0x20a161=_['map'](db['SmsQueue']['rawAttributes'],function(_0x29abdb){return{'name':_0x29abdb[_0x65f6('0x1b')],'type':_0x29abdb['type'][_0x65f6('0x1c')]};});_0x9d7bb0=qs[_0x65f6('0x1d')](_0x20a161,_0x2774a1);var _0x52277c={'where':_0x9d7bb0[_0x65f6('0x1e')]};return db[_0x65f6('0x1f')][_0x65f6('0x10')](_0x52277c)['then'](function(_0x4ac04b){_0x59ea32['count']=_0x4ac04b;_0x9d7bb0[_0x65f6('0x20')]=qs[_0x65f6('0x20')](_0x2774a1[_0x65f6('0x21')]);return db[_0x65f6('0x1f')][_0x65f6('0x22')](_0x9d7bb0);})[_0x65f6('0x13')](function(_0x144e55){_0x59ea32['rows']=_0x144e55;return _0x59ea32;})['then'](respondWithFilteredResult(_0x4f5a69,_0x9d7bb0))[_0x65f6('0x23')](handleError(_0x4f5a69,null));};exports[_0x65f6('0x24')]=function(_0x5878bc,_0x4e50c0){var _0x10b368={'raw':!![],'where':{'id':_0x5878bc[_0x65f6('0x25')]['id']}},_0x1ce43c={};_0x1ce43c[_0x65f6('0x26')]=_[_0x65f6('0x27')](db[_0x65f6('0x1f')]['rawAttributes']);_0x1ce43c[_0x65f6('0x21')]=_[_0x65f6('0x27')](_0x5878bc[_0x65f6('0x21')]);_0x1ce43c['filters']=_[_0x65f6('0x28')](_0x1ce43c[_0x65f6('0x26')],_0x1ce43c[_0x65f6('0x21')]);_0x10b368[_0x65f6('0x29')]=_[_0x65f6('0x28')](_0x1ce43c[_0x65f6('0x26')],qs['fields'](_0x5878bc[_0x65f6('0x21')][_0x65f6('0x2a')]));_0x10b368['attributes']=_0x10b368[_0x65f6('0x29')]['length']?_0x10b368[_0x65f6('0x29')]:_0x1ce43c['model'];if(_0x5878bc[_0x65f6('0x21')][_0x65f6('0x2b')]){_0x10b368['include']=[{'all':!![]}];}_0x10b368=_[_0x65f6('0x2c')]({},_0x10b368,_0x5878bc[_0x65f6('0x2d')]);return db[_0x65f6('0x1f')]['find'](_0x10b368)['then'](handleEntityNotFound(_0x4e50c0,null))[_0x65f6('0x13')](respondWithResult(_0x4e50c0,null))['catch'](handleError(_0x4e50c0,null));};exports[_0x65f6('0x2e')]=function(_0x4e6653,_0x22d760){return db[_0x65f6('0x1f')]['create'](_0x4e6653[_0x65f6('0x2f')],{})['then'](function(_0x5edd04){var _0x71b16b=_0x4e6653[_0x65f6('0x30')][_0x65f6('0x31')]({'plain':!![]});if(!_0x71b16b)throw new Error(_0x65f6('0x32'));if(_0x71b16b[_0x65f6('0x33')]===_0x65f6('0x30')){var _0x1a55da=_0x5edd04[_0x65f6('0x31')]({'plain':!![]});var _0x4f933b=_0x65f6('0x34');return db['UserProfileSection'][_0x65f6('0x35')]({'where':{'name':_0x4f933b,'userProfileId':_0x71b16b[_0x65f6('0x36')]},'raw':!![]})[_0x65f6('0x13')](function(_0x2ea7f7){if(_0x2ea7f7&&_0x2ea7f7['autoAssociation']===0x0){return db[_0x65f6('0x14')][_0x65f6('0x2e')]({'name':_0x1a55da[_0x65f6('0x18')],'resourceId':_0x1a55da['id'],'type':_0x2ea7f7[_0x65f6('0x18')],'sectionId':_0x2ea7f7['id']},{})[_0x65f6('0x13')](function(){return _0x5edd04;});}else{return _0x5edd04;}})[_0x65f6('0x23')](function(_0xed4c96){logger[_0x65f6('0x37')](_0x65f6('0x38'),_0xed4c96);throw _0xed4c96;});}return _0x5edd04;})['then'](respondWithResult(_0x22d760,0xc9))[_0x65f6('0x23')](handleError(_0x22d760,null));};exports[_0x65f6('0x12')]=function(_0x377ae5,_0x181798){if(_0x377ae5[_0x65f6('0x2f')]['id']){delete _0x377ae5[_0x65f6('0x2f')]['id'];}return db[_0x65f6('0x1f')][_0x65f6('0x35')]({'where':{'id':_0x377ae5[_0x65f6('0x25')]['id']}})[_0x65f6('0x13')](handleEntityNotFound(_0x181798,null))[_0x65f6('0x13')](saveUpdates(_0x377ae5[_0x65f6('0x2f')],null))[_0x65f6('0x13')](respondWithResult(_0x181798,null))[_0x65f6('0x23')](handleError(_0x181798,null));};exports[_0x65f6('0x15')]=function(_0x2cb38d,_0x5119ee){return db[_0x65f6('0x1f')][_0x65f6('0x35')]({'where':{'id':_0x2cb38d[_0x65f6('0x25')]['id']}})[_0x65f6('0x13')](handleEntityNotFound(_0x5119ee,null))['then'](removeEntity(_0x5119ee,null))[_0x65f6('0x23')](handleError(_0x5119ee,null));};exports[_0x65f6('0x39')]=function(_0x2b01eb,_0x5e69b4){return db[_0x65f6('0x1f')][_0x65f6('0x39')]()[_0x65f6('0x13')](respondWithResult(_0x5e69b4,null))[_0x65f6('0x23')](handleError(_0x5e69b4,null));};exports['getMembers']=function(_0x2ec114,_0x512527){var _0x3f1baa={'raw':!![],'where':{}},_0x6968b={},_0x577c93;return db[_0x65f6('0x1f')]['findOne']({'where':{'id':_0x2ec114[_0x65f6('0x25')]['id']}})[_0x65f6('0x13')](handleEntityNotFound(_0x512527,null))[_0x65f6('0x13')](function(_0xc0db01){if(_0xc0db01){_0x577c93=_0xc0db01[_0x65f6('0x31')]({'plain':!![]});_0x6968b[_0x65f6('0x26')]=_['keys'](db['UserSmsQueue'][_0x65f6('0x3a')]);_0x6968b[_0x65f6('0x21')]=_[_0x65f6('0x27')](_0x2ec114[_0x65f6('0x21')]);_0x6968b[_0x65f6('0x3b')]=_[_0x65f6('0x28')](_0x6968b[_0x65f6('0x26')],_0x6968b[_0x65f6('0x21')]);_0x3f1baa[_0x65f6('0x29')]=_['intersection'](_0x6968b[_0x65f6('0x26')],qs[_0x65f6('0x2a')](_0x2ec114[_0x65f6('0x21')]['fields']));_0x3f1baa[_0x65f6('0x29')]=_0x3f1baa[_0x65f6('0x29')]['length']?_0x3f1baa[_0x65f6('0x29')]:_0x6968b[_0x65f6('0x26')];if(!_0x2ec114['query'][_0x65f6('0x3c')]('nolimit')){_0x3f1baa[_0x65f6('0xe')]=qs[_0x65f6('0xe')](_0x2ec114[_0x65f6('0x21')]['limit']);_0x3f1baa[_0x65f6('0xd')]=qs[_0x65f6('0xd')](_0x2ec114['query'][_0x65f6('0xd')]);}_0x3f1baa[_0x65f6('0x3d')]=qs['sort'](_0x2ec114[_0x65f6('0x21')][_0x65f6('0x3e')]);_0x3f1baa[_0x65f6('0x1e')]=qs[_0x65f6('0x3b')](_[_0x65f6('0x3f')](_0x2ec114[_0x65f6('0x21')],_0x6968b[_0x65f6('0x3b')]));_0x3f1baa[_0x65f6('0x1e')]['SmsQueueId']=_0xc0db01['id'];if(_0x2ec114['query']['filter']){_0x3f1baa[_0x65f6('0x1e')]=_[_0x65f6('0x2c')](_0x3f1baa[_0x65f6('0x1e')],{'$or':_[_0x65f6('0x40')](_0x3f1baa['attributes'],function(_0x183c08){var _0x2032b9={};_0x2032b9[_0x183c08]={'$like':'%'+_0x2ec114[_0x65f6('0x21')]['filter']+'%'};return _0x2032b9;})});}_0x3f1baa=_[_0x65f6('0x2c')]({},_0x3f1baa,_0x2ec114[_0x65f6('0x2d')]);return db[_0x65f6('0x41')]['findAll'](_0x3f1baa);}})['then'](function(_0x1d337d){if(_0x1d337d){return db[_0x65f6('0x42')][_0x65f6('0x43')]({'where':{'id':_[_0x65f6('0x40')](_0x1d337d,_0x65f6('0x44')),'role':_0x65f6('0x45')},'attributes':['id',_0x65f6('0x18'),_0x65f6('0x46'),_0x65f6('0x47'),_0x65f6('0x48')]});}})[_0x65f6('0x13')](function(_0x141fcc){if(_0x141fcc){return{'count':_0x141fcc[_0x65f6('0x10')],'rows':_[_0x65f6('0x40')](_0x141fcc['rows'],function(_0x47610a){return{'membername':_0x47610a[_0x65f6('0x18')],'UserId':_0x47610a['id'],'queue_name':_0x577c93[_0x65f6('0x18')],'SmsQueueId':_0x577c93['id'],'interface':util['format'](_0x65f6('0x49'),_0x65f6('0x4a'),_0x47610a[_0x65f6('0x18')]),'penalty':0x0,'paused':_0x47610a[_0x65f6('0x46')],'createdAt':_0x47610a['createdAt'],'updatedAt':_0x47610a[_0x65f6('0x47')]};})};}else{return{'count':0x0,'rows':[]};}})[_0x65f6('0x13')](respondWithFilteredResult(_0x512527,_0x3f1baa))[_0x65f6('0x23')](handleError(_0x512527,null));};exports[_0x65f6('0x4b')]=function(_0x553ff0,_0x2923ff){var _0x2fc20f={};var _0x5c55e4={};var _0x28682b;var _0x26481e;return db[_0x65f6('0x1f')]['findOne']({'where':{'id':_0x553ff0[_0x65f6('0x25')]['id']}})[_0x65f6('0x13')](handleEntityNotFound(_0x2923ff,null))[_0x65f6('0x13')](function(_0x3c23e3){if(_0x3c23e3){_0x28682b=_0x3c23e3;_0x5c55e4[_0x65f6('0x26')]=_[_0x65f6('0x27')](db['Team']['rawAttributes']);_0x5c55e4['query']=_[_0x65f6('0x27')](_0x553ff0[_0x65f6('0x21')]);_0x5c55e4[_0x65f6('0x3b')]=_[_0x65f6('0x28')](_0x5c55e4[_0x65f6('0x26')],_0x5c55e4[_0x65f6('0x21')]);_0x2fc20f['attributes']=_[_0x65f6('0x28')](_0x5c55e4[_0x65f6('0x26')],qs['fields'](_0x553ff0[_0x65f6('0x21')][_0x65f6('0x2a')]));_0x2fc20f[_0x65f6('0x29')]=_0x2fc20f['attributes'][_0x65f6('0x4c')]?_0x2fc20f[_0x65f6('0x29')]:_0x5c55e4['model'];_0x2fc20f[_0x65f6('0x3d')]=qs[_0x65f6('0x3e')](_0x553ff0[_0x65f6('0x21')][_0x65f6('0x3e')]);_0x2fc20f[_0x65f6('0x1e')]=qs[_0x65f6('0x3b')](_[_0x65f6('0x3f')](_0x553ff0['query'],_0x5c55e4['filters']));if(_0x553ff0[_0x65f6('0x21')][_0x65f6('0x4d')]){_0x2fc20f['where']=_[_0x65f6('0x2c')](_0x2fc20f['where'],{'$or':_[_0x65f6('0x40')](_0x2fc20f['attributes'],function(_0x440df1){var _0xdc8989={};_0xdc8989[_0x440df1]={'$like':'%'+_0x553ff0[_0x65f6('0x21')][_0x65f6('0x4d')]+'%'};return _0xdc8989;})});}_0x2fc20f=_[_0x65f6('0x2c')]({},_0x2fc20f,_0x553ff0[_0x65f6('0x2d')]);return _0x28682b[_0x65f6('0x4b')](_0x2fc20f);}})[_0x65f6('0x13')](function(_0x2405a7){if(_0x2405a7){_0x26481e=_0x2405a7['length'];if(!_0x553ff0['query'][_0x65f6('0x3c')](_0x65f6('0x4e'))){_0x2fc20f[_0x65f6('0xe')]=qs['limit'](_0x553ff0['query'][_0x65f6('0xe')]);_0x2fc20f[_0x65f6('0xd')]=qs[_0x65f6('0xd')](_0x553ff0[_0x65f6('0x21')][_0x65f6('0xd')]);}return _0x28682b[_0x65f6('0x4b')](_0x2fc20f);}})['then'](function(_0x4f42ae){if(_0x4f42ae){return _0x4f42ae?{'count':_0x26481e,'rows':_0x4f42ae}:null;}})[_0x65f6('0x13')](respondWithResult(_0x2923ff,null))[_0x65f6('0x23')](handleError(_0x2923ff,null));};exports['addTeams']=function(_0x219bf8,_0x4a8b60){var _0x254e9f=_0x219bf8[_0x65f6('0x2f')][_0x65f6('0x4f')];return db[_0x65f6('0x50')]['findAll']({'where':{'id':_0x254e9f},'attributes':['id'],'include':[{'model':db[_0x65f6('0x42')],'as':_0x65f6('0x51'),'attributes':['id',_0x65f6('0x18'),'online','voicePause',_0x65f6('0x52')],'raw':!![]}]})['then'](function(_0x305967){if(_0x305967){var _0xf6de=_[_0x65f6('0x53')](_0x305967,function(_0x354b90){var _0x512776=_0x354b90['get']({'plain':!![]});return _0x512776['Agents'];});return db[_0x65f6('0x1f')][_0x65f6('0x35')]({'where':{'id':_0x219bf8[_0x65f6('0x25')]['id']}})['then'](function(_0x46cbde){return db[_0x65f6('0x54')][_0x65f6('0x55')](function(_0x49cee2){return _0x46cbde[_0x65f6('0x56')](_0x254e9f,{'transaction':_0x49cee2})[_0x65f6('0x13')](function(){return BPromise['each'](_0xf6de,function(_0x758e80){return db[_0x65f6('0x41')]['findOrCreate']({'where':{'UserId':_0x758e80['id'],'SmsQueueId':_0x219bf8[_0x65f6('0x25')]['id']},'transaction':_0x49cee2});});})['then'](function(){_0xf6de[_0x65f6('0x57')](function(_0x55ea91){socket[_0x65f6('0x58')](_0x65f6('0x59'),{'UserId':_0x55ea91['id'],'SmsQueueId':_0x46cbde['id']});});});});});}})['then'](respondWithStatusCode(_0x4a8b60,null))[_0x65f6('0x23')](handleError(_0x4a8b60,null));};exports[_0x65f6('0x5a')]=function(_0x2a700b,_0x299b85){return db[_0x65f6('0x50')][_0x65f6('0x22')]({'where':{'id':_0x2a700b[_0x65f6('0x21')][_0x65f6('0x4f')]},'attributes':['id'],'include':[{'model':db[_0x65f6('0x42')],'as':_0x65f6('0x51'),'attributes':['id'],'raw':!![]}]})[_0x65f6('0x13')](handleEntityNotFound(_0x299b85,null))['then'](function(_0x10a661){var _0x1cf1bd=_[_0x65f6('0x40')](_0x10a661,'id');var _0x219e42=[];var _0x5694f9=[];var _0x453080=squel[_0x65f6('0x5b')]();_0x453080['field'](_0x65f6('0x5c'))['from'](_0x65f6('0x5d'),'tq')['join'](_0x65f6('0x5e'),'ut',_0x65f6('0x5f'))['where']('SmsQueueId\x20=\x20?',_0x2a700b[_0x65f6('0x25')]['id']);for(var _0x413c21=0x0;_0x413c21<_0x10a661['length'];_0x413c21+=0x1){let _0x2d86c8=_0x10a661[_0x413c21];for(var _0x3b3bd5=0x0;_0x3b3bd5<_0x2d86c8[_0x65f6('0x51')]['length'];_0x3b3bd5+=0x1){let _0x1348ec=_0x2d86c8[_0x65f6('0x51')][_0x3b3bd5];var _0x5889dc=_0x453080[_0x65f6('0x60')]();_0x5889dc['where'](_0x65f6('0x61'),_0x1348ec['id']);_0x5694f9['push'](db['sequelize'][_0x65f6('0x21')](_0x5889dc[_0x65f6('0x62')](),{'type':db[_0x65f6('0x54')][_0x65f6('0x63')][_0x65f6('0x64')]})[_0x65f6('0x13')](function(_0x1ac46f){if(_0x1ac46f[_0x65f6('0x4c')]===0x1){return _0x1348ec['id'];}else{var _0x4d66fe=_['every'](_[_0x65f6('0x40')](_0x1ac46f,'TeamId'),function(_0x1ee28a){return _[_0x65f6('0x65')](_0x1cf1bd,_0x1ee28a);});if(_0x4d66fe){return _0x1348ec['id'];}}}));}}return BPromise[_0x65f6('0x66')](_0x5694f9)[_0x65f6('0x13')](function(_0x43127b){_0x219e42=_(_0x219e42)['union'](_0x43127b)[_0x65f6('0x67')]()[_0x65f6('0x68')]();return db[_0x65f6('0x1f')]['find']({'where':{'id':_0x2a700b[_0x65f6('0x25')]['id']}})[_0x65f6('0x13')](function(_0x4254c2){return db[_0x65f6('0x54')][_0x65f6('0x55')](function(_0x16bf93){return _0x4254c2['removeTeams'](_0x2a700b['query'][_0x65f6('0x4f')],{'transaction':_0x16bf93})[_0x65f6('0x13')](function(){if(!_[_0x65f6('0x69')](_0x219e42)){return _0x4254c2[_0x65f6('0x6a')](_0x219e42,{'transaction':_0x16bf93});}})['then'](function(){_0x219e42['forEach'](function(_0x336076){socket[_0x65f6('0x58')](_0x65f6('0x6b'),{'UserId':_0x336076,'SmsQueueId':_0x4254c2['id']});});});});});});})[_0x65f6('0x13')](respondWithStatusCode(_0x299b85,null))[_0x65f6('0x23')](handleError(_0x299b85,null));};exports[_0x65f6('0x6c')]=function(_0x5daaf4,_0x4d607a){return db['SmsQueue'][_0x65f6('0x35')]({'where':{'id':_0x5daaf4[_0x65f6('0x25')]['id']}})[_0x65f6('0x13')](handleEntityNotFound(_0x4d607a,null))[_0x65f6('0x13')](function(_0x53b11c){if(_0x53b11c){return _0x53b11c['addAgents'](_0x5daaf4[_0x65f6('0x2f')][_0x65f6('0x4f')],_['omit'](_0x5daaf4[_0x65f6('0x2f')],['ids','id'])||{})[_0x65f6('0x6d')](function(_0x4f3ef8){for(var _0x3a30ed=0x0;_0x3a30ed<_0x5daaf4[_0x65f6('0x2f')]['ids'][_0x65f6('0x4c')];_0x3a30ed+=0x1){socket[_0x65f6('0x58')](_0x65f6('0x59'),{'UserId':Number(_0x5daaf4[_0x65f6('0x2f')][_0x65f6('0x4f')][_0x3a30ed]),'SmsQueueId':Number(_0x5daaf4[_0x65f6('0x25')]['id'])});}return _0x4f3ef8;});}})['then'](respondWithResult(_0x4d607a,null))[_0x65f6('0x23')](handleError(_0x4d607a,null));};exports['removeAgents']=function(_0x24495c,_0x56336a){return db[_0x65f6('0x1f')][_0x65f6('0x35')]({'where':{'id':_0x24495c[_0x65f6('0x25')]['id']}})[_0x65f6('0x13')](handleEntityNotFound(_0x56336a,null))['then'](function(_0x2b6f98){if(_0x2b6f98){return _0x2b6f98[_0x65f6('0x6a')](_0x24495c[_0x65f6('0x21')]['ids'])['then'](function(){if(_[_0x65f6('0x6e')](_0x24495c[_0x65f6('0x21')]['ids'])){for(var _0x180cde=0x0;_0x180cde<_0x24495c[_0x65f6('0x21')][_0x65f6('0x4f')]['length'];_0x180cde+=0x1){socket[_0x65f6('0x58')](_0x65f6('0x6b'),{'UserId':Number(_0x24495c['query'][_0x65f6('0x4f')][_0x180cde]),'SmsQueueId':Number(_0x24495c[_0x65f6('0x25')]['id'])});}}else{socket[_0x65f6('0x58')]('userSmsQueue:remove',{'UserId':Number(_0x24495c[_0x65f6('0x21')][_0x65f6('0x4f')]),'SmsQueueId':Number(_0x24495c[_0x65f6('0x25')]['id'])});}});}})['then'](respondWithStatusCode(_0x56336a,null))[_0x65f6('0x23')](handleError(_0x56336a,null));};exports['getAgents']=function(_0x1beaa7,_0x87a9e4){var _0x31ec61={};var _0x22be6e={};var _0x29b2de;var _0x430fb8;return db['SmsQueue'][_0x65f6('0x6f')]({'where':{'id':_0x1beaa7[_0x65f6('0x25')]['id']}})[_0x65f6('0x13')](handleEntityNotFound(_0x87a9e4,null))[_0x65f6('0x13')](function(_0x207d15){if(_0x207d15){_0x29b2de=_0x207d15;_0x22be6e['model']=_['keys'](db['User'][_0x65f6('0x3a')]);_0x22be6e[_0x65f6('0x21')]=_[_0x65f6('0x27')](_0x1beaa7['query']);_0x22be6e[_0x65f6('0x3b')]=_['intersection'](_0x22be6e['model'],_0x22be6e[_0x65f6('0x21')]);_0x31ec61[_0x65f6('0x29')]=_['intersection'](_0x22be6e[_0x65f6('0x26')],qs[_0x65f6('0x2a')](_0x1beaa7[_0x65f6('0x21')][_0x65f6('0x2a')]));_0x31ec61[_0x65f6('0x29')]=_0x31ec61[_0x65f6('0x29')][_0x65f6('0x4c')]?_0x31ec61[_0x65f6('0x29')]:_0x22be6e[_0x65f6('0x26')];_0x31ec61[_0x65f6('0x3d')]=qs[_0x65f6('0x3e')](_0x1beaa7[_0x65f6('0x21')]['sort']);_0x31ec61[_0x65f6('0x1e')]=qs['filters'](_['pick'](_0x1beaa7[_0x65f6('0x21')],_0x22be6e[_0x65f6('0x3b')]));if(_0x1beaa7[_0x65f6('0x21')][_0x65f6('0x4d')]){_0x31ec61['where']=_[_0x65f6('0x2c')](_0x31ec61['where'],{'$or':_['map'](_0x31ec61[_0x65f6('0x29')],function(_0x99fe6e){var _0x1a7e52={};_0x1a7e52[_0x99fe6e]={'$like':'%'+_0x1beaa7[_0x65f6('0x21')][_0x65f6('0x4d')]+'%'};return _0x1a7e52;})});}_0x31ec61=_[_0x65f6('0x2c')]({},_0x31ec61,_0x1beaa7['options']);return _0x29b2de[_0x65f6('0x70')](_0x31ec61);}})['then'](function(_0x1ef2a0){if(_0x1ef2a0){_0x430fb8=_0x1ef2a0[_0x65f6('0x4c')];if(!_0x1beaa7[_0x65f6('0x21')]['hasOwnProperty'](_0x65f6('0x4e'))){_0x31ec61['limit']=qs['limit'](_0x1beaa7[_0x65f6('0x21')][_0x65f6('0xe')]);_0x31ec61[_0x65f6('0xd')]=qs[_0x65f6('0xd')](_0x1beaa7[_0x65f6('0x21')]['offset']);}return _0x29b2de[_0x65f6('0x70')](_0x31ec61);}})[_0x65f6('0x13')](function(_0x3bebe3){if(_0x3bebe3){return _0x3bebe3?{'count':_0x430fb8,'rows':_0x3bebe3}:null;}})[_0x65f6('0x13')](respondWithResult(_0x87a9e4,null))['catch'](handleError(_0x87a9e4,null));};
\ No newline at end of file