Built motion from commit d1eab355.|2.6.28
[motion2.git] / server / api / smsQueue / smsQueue.controller.js
index 09b3dc8..4007293 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x3c4f=['each','findOrCreate','forEach','emit','userSmsQueue:save','removeTeams','select','field','tq.TeamId','from','team_has_sms_queues','join','ut.TeamId\x20=\x20tq.TeamId','clone','push','toString','QueryTypes','every','includes','all','compact','value','isEmpty','removeAgents','userSmsQueue:remove','addAgents','omit','spread','isArray','getAgents','html-pdf','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','bluebird','mustache','util','path','sox','to-csv','lodash','squel','crypto','desk.js','papaparse','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','defaults','localhost','./smsQueue.socket','register','status','end','count','offset','limit','Content-Range','json','apply','reject','then','destroy','SmsQueues','UserProfileResource','sendStatus','error','name','send','index','SmsQueue','rawAttributes','fieldName','type','model','map','query','attributes','fields','length','hasOwnProperty','order','sort','where','filters','pick','filter','merge','VIRTUAL','options','includeAll','include','findAll','catch','params','keys','intersection','find','create','body','user','get','Unable\x20to\x20retrieve\x20the\x20current\x20user','UserProfileSection','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','describe','findOne','nolimit','SmsQueueId','UserSmsQueue','findAndCountAll','UserId','agent','rows','format','SIP','createdAt','updatedAt','getTeams','Team','addTeams','ids','User','online','flatMap','Agents','sequelize'];(function(_0x203353,_0x3c21f3){var _0x1735de=function(_0x4c63b2){while(--_0x4c63b2){_0x203353['push'](_0x203353['shift']());}};_0x1735de(++_0x3c21f3);}(_0x3c4f,0x12e));var _0xf3c4=function(_0x5b6328,_0x1e53b8){_0x5b6328=_0x5b6328-0x0;var _0x53637b=_0x3c4f[_0x5b6328];return _0x53637b;};'use strict';var pdf=require(_0xf3c4('0x0'));var emlformat=require(_0xf3c4('0x1'));var rimraf=require(_0xf3c4('0x2'));var zipdir=require(_0xf3c4('0x3'));var jsonpatch=require(_0xf3c4('0x4'));var rp=require(_0xf3c4('0x5'));var moment=require('moment');var BPromise=require(_0xf3c4('0x6'));var Mustache=require(_0xf3c4('0x7'));var util=require(_0xf3c4('0x8'));var path=require(_0xf3c4('0x9'));var sox=require(_0xf3c4('0xa'));var csv=require(_0xf3c4('0xb'));var ejs=require('ejs');var fs=require('fs');var _=require(_0xf3c4('0xc'));var squel=require(_0xf3c4('0xd'));var crypto=require(_0xf3c4('0xe'));var jsforce=require('jsforce');var deskjs=require(_0xf3c4('0xf'));var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require(_0xf3c4('0x10'));var Redis=require('ioredis');var authService=require('../../components/auth/service');var qs=require(_0xf3c4('0x11'));var as=require(_0xf3c4('0x12'));var hardwareService=require(_0xf3c4('0x13'));var logger=require('../../config/logger')('api');var utils=require(_0xf3c4('0x14'));var config=require(_0xf3c4('0x15'));var licenseUtil=require(_0xf3c4('0x16'));var db=require(_0xf3c4('0x17'))['db'];config[_0xf3c4('0x18')]=_[_0xf3c4('0x19')](config['redis'],{'host':_0xf3c4('0x1a'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0xf3c4('0x18')]));require(_0xf3c4('0x1b'))[_0xf3c4('0x1c')](socket);function respondWithStatusCode(_0x3c6b4a,_0x345916){_0x345916=_0x345916||0xcc;return function(_0x3e14fb){if(_0x3e14fb){return _0x3c6b4a['sendStatus'](_0x345916);}return _0x3c6b4a[_0xf3c4('0x1d')](_0x345916)[_0xf3c4('0x1e')]();};}function respondWithResult(_0x1fcf7c,_0x4e7308){_0x4e7308=_0x4e7308||0xc8;return function(_0x1ae27c){if(_0x1ae27c){return _0x1fcf7c[_0xf3c4('0x1d')](_0x4e7308)['json'](_0x1ae27c);}};}function respondWithFilteredResult(_0xc45c0f,_0x1ec3d8){return function(_0x35fc00){if(_0x35fc00){var _0x1df51f=_0x35fc00[_0xf3c4('0x1f')],_0x3239f5=_0x1ec3d8[_0xf3c4('0x20')],_0x5bb0c6=_0x1ec3d8[_0xf3c4('0x20')]+_0x1ec3d8[_0xf3c4('0x21')],_0xbcb87b;if(_0x5bb0c6>=_0x1df51f){_0x5bb0c6=_0x1df51f;_0xbcb87b=0xc8;}else{_0xbcb87b=0xce;}_0xc45c0f[_0xf3c4('0x1d')](_0xbcb87b);return _0xc45c0f['set'](_0xf3c4('0x22'),_0x3239f5+'-'+_0x5bb0c6+'/'+_0x1df51f)[_0xf3c4('0x23')](_0x35fc00);}return null;};}function patchUpdates(_0x164ceb){return function(_0x4c343e){try{jsonpatch[_0xf3c4('0x24')](_0x4c343e,_0x164ceb,!![]);}catch(_0x34f40b){return BPromise[_0xf3c4('0x25')](_0x34f40b);}return _0x4c343e['save']();};}function saveUpdates(_0x1eb48d,_0x23d91b){return function(_0x1b8dbd){if(_0x1b8dbd){return _0x1b8dbd['update'](_0x1eb48d)[_0xf3c4('0x26')](function(_0x2dad9e){return _0x2dad9e;});}return null;};}function removeEntity(_0x2267a7,_0x29ec03){return function(_0x184c75){if(_0x184c75){return _0x184c75[_0xf3c4('0x27')]()[_0xf3c4('0x26')](function(){var _0x15674a=_0x184c75['get']({'plain':!![]});var _0x3a130b=_0xf3c4('0x28');return db[_0xf3c4('0x29')][_0xf3c4('0x27')]({'where':{'type':_0x3a130b,'resourceId':_0x15674a['id']}})['then'](function(){return _0x184c75;});})[_0xf3c4('0x26')](function(){_0x2267a7[_0xf3c4('0x1d')](0xcc)[_0xf3c4('0x1e')]();});}};}function handleEntityNotFound(_0x578ed8,_0x18404a){return function(_0x40d679){if(!_0x40d679){_0x578ed8[_0xf3c4('0x2a')](0x194);}return _0x40d679;};}function handleError(_0x36260f,_0xbdba50){_0xbdba50=_0xbdba50||0x1f4;return function(_0x177dec){logger[_0xf3c4('0x2b')](_0x177dec['stack']);if(_0x177dec[_0xf3c4('0x2c')]){delete _0x177dec['name'];}_0x36260f[_0xf3c4('0x1d')](_0xbdba50)[_0xf3c4('0x2d')](_0x177dec);};}exports[_0xf3c4('0x2e')]=function(_0x1e317f,_0x428601){var _0x1e653d={},_0x2a5157={},_0x3c09c8={'count':0x0,'rows':[]};var _0x10cf70=_['map'](db[_0xf3c4('0x2f')][_0xf3c4('0x30')],function(_0x4caff3){return{'name':_0x4caff3[_0xf3c4('0x31')],'type':_0x4caff3[_0xf3c4('0x32')]['key']};});_0x2a5157[_0xf3c4('0x33')]=_[_0xf3c4('0x34')](_0x10cf70,_0xf3c4('0x2c'));_0x2a5157[_0xf3c4('0x35')]=_['keys'](_0x1e317f[_0xf3c4('0x35')]);_0x2a5157['filters']=_['intersection'](_0x2a5157['model'],_0x2a5157[_0xf3c4('0x35')]);_0x1e653d[_0xf3c4('0x36')]=_['intersection'](_0x2a5157[_0xf3c4('0x33')],qs[_0xf3c4('0x37')](_0x1e317f[_0xf3c4('0x35')][_0xf3c4('0x37')]));_0x1e653d[_0xf3c4('0x36')]=_0x1e653d[_0xf3c4('0x36')][_0xf3c4('0x38')]?_0x1e653d[_0xf3c4('0x36')]:_0x2a5157[_0xf3c4('0x33')];if(!_0x1e317f['query'][_0xf3c4('0x39')]('nolimit')){_0x1e653d['limit']=qs[_0xf3c4('0x21')](_0x1e317f[_0xf3c4('0x35')][_0xf3c4('0x21')]);_0x1e653d[_0xf3c4('0x20')]=qs['offset'](_0x1e317f[_0xf3c4('0x35')][_0xf3c4('0x20')]);}_0x1e653d[_0xf3c4('0x3a')]=qs[_0xf3c4('0x3b')](_0x1e317f['query'][_0xf3c4('0x3b')]);_0x1e653d[_0xf3c4('0x3c')]=qs[_0xf3c4('0x3d')](_[_0xf3c4('0x3e')](_0x1e317f[_0xf3c4('0x35')],_0x2a5157[_0xf3c4('0x3d')]),_0x10cf70);if(_0x1e317f[_0xf3c4('0x35')][_0xf3c4('0x3f')]){_0x1e653d[_0xf3c4('0x3c')]=_[_0xf3c4('0x40')](_0x1e653d['where'],{'$or':_[_0xf3c4('0x34')](_0x10cf70,function(_0x249a83){if(_0x249a83[_0xf3c4('0x32')]!==_0xf3c4('0x41')){var _0x214273={};_0x214273[_0x249a83[_0xf3c4('0x2c')]]={'$like':'%'+_0x1e317f[_0xf3c4('0x35')][_0xf3c4('0x3f')]+'%'};return _0x214273;}})});}_0x1e653d=_[_0xf3c4('0x40')]({},_0x1e653d,_0x1e317f[_0xf3c4('0x42')]);var _0x2ce308={'where':_0x1e653d[_0xf3c4('0x3c')]};return db[_0xf3c4('0x2f')][_0xf3c4('0x1f')](_0x2ce308)['then'](function(_0x55aa1e){_0x3c09c8[_0xf3c4('0x1f')]=_0x55aa1e;if(_0x1e317f['query'][_0xf3c4('0x43')]){_0x1e653d[_0xf3c4('0x44')]=[{'all':!![]}];}return db['SmsQueue'][_0xf3c4('0x45')](_0x1e653d);})[_0xf3c4('0x26')](function(_0x26f708){_0x3c09c8['rows']=_0x26f708;return _0x3c09c8;})[_0xf3c4('0x26')](respondWithFilteredResult(_0x428601,_0x1e653d))[_0xf3c4('0x46')](handleError(_0x428601,null));};exports['show']=function(_0x373b95,_0x24b67a){var _0xab6fda={'raw':!![],'where':{'id':_0x373b95[_0xf3c4('0x47')]['id']}},_0x22f204={};_0x22f204[_0xf3c4('0x33')]=_['keys'](db[_0xf3c4('0x2f')][_0xf3c4('0x30')]);_0x22f204[_0xf3c4('0x35')]=_[_0xf3c4('0x48')](_0x373b95[_0xf3c4('0x35')]);_0x22f204[_0xf3c4('0x3d')]=_['intersection'](_0x22f204[_0xf3c4('0x33')],_0x22f204[_0xf3c4('0x35')]);_0xab6fda[_0xf3c4('0x36')]=_[_0xf3c4('0x49')](_0x22f204[_0xf3c4('0x33')],qs[_0xf3c4('0x37')](_0x373b95['query']['fields']));_0xab6fda[_0xf3c4('0x36')]=_0xab6fda['attributes'][_0xf3c4('0x38')]?_0xab6fda['attributes']:_0x22f204[_0xf3c4('0x33')];if(_0x373b95[_0xf3c4('0x35')][_0xf3c4('0x43')]){_0xab6fda['include']=[{'all':!![]}];}_0xab6fda=_[_0xf3c4('0x40')]({},_0xab6fda,_0x373b95['options']);return db['SmsQueue'][_0xf3c4('0x4a')](_0xab6fda)[_0xf3c4('0x26')](handleEntityNotFound(_0x24b67a,null))[_0xf3c4('0x26')](respondWithResult(_0x24b67a,null))[_0xf3c4('0x46')](handleError(_0x24b67a,null));};exports[_0xf3c4('0x4b')]=function(_0x4c699d,_0x10596b){return db['SmsQueue']['create'](_0x4c699d[_0xf3c4('0x4c')],{})[_0xf3c4('0x26')](function(_0x1b437e){var _0xb76fb9=_0x4c699d[_0xf3c4('0x4d')][_0xf3c4('0x4e')]({'plain':!![]});if(!_0xb76fb9)throw new Error(_0xf3c4('0x4f'));if(_0xb76fb9['role']==='user'){var _0x41d291=_0x1b437e[_0xf3c4('0x4e')]({'plain':!![]});var _0xcdabb7='SmsQueues';return db[_0xf3c4('0x50')]['find']({'where':{'name':_0xcdabb7,'userProfileId':_0xb76fb9[_0xf3c4('0x51')]},'raw':!![]})[_0xf3c4('0x26')](function(_0x3cf56d){if(_0x3cf56d&&_0x3cf56d[_0xf3c4('0x52')]===0x0){return db[_0xf3c4('0x29')]['create']({'name':_0x41d291[_0xf3c4('0x2c')],'resourceId':_0x41d291['id'],'type':_0x3cf56d['name'],'sectionId':_0x3cf56d['id']},{})[_0xf3c4('0x26')](function(){return _0x1b437e;});}else{return _0x1b437e;}})['catch'](function(_0x58dc12){logger[_0xf3c4('0x2b')](_0xf3c4('0x53'),_0x58dc12);throw _0x58dc12;});}return _0x1b437e;})[_0xf3c4('0x26')](respondWithResult(_0x10596b,0xc9))[_0xf3c4('0x46')](handleError(_0x10596b,null));};exports['update']=function(_0x38d049,_0x18f9bd){if(_0x38d049['body']['id']){delete _0x38d049[_0xf3c4('0x4c')]['id'];}return db['SmsQueue'][_0xf3c4('0x4a')]({'where':{'id':_0x38d049[_0xf3c4('0x47')]['id']}})[_0xf3c4('0x26')](handleEntityNotFound(_0x18f9bd,null))[_0xf3c4('0x26')](saveUpdates(_0x38d049[_0xf3c4('0x4c')],null))['then'](respondWithResult(_0x18f9bd,null))[_0xf3c4('0x46')](handleError(_0x18f9bd,null));};exports[_0xf3c4('0x27')]=function(_0x471342,_0x51116a){return db[_0xf3c4('0x2f')][_0xf3c4('0x4a')]({'where':{'id':_0x471342[_0xf3c4('0x47')]['id']}})[_0xf3c4('0x26')](handleEntityNotFound(_0x51116a,null))[_0xf3c4('0x26')](removeEntity(_0x51116a,null))[_0xf3c4('0x46')](handleError(_0x51116a,null));};exports[_0xf3c4('0x54')]=function(_0x405ab4,_0x35bc0c){return db[_0xf3c4('0x2f')][_0xf3c4('0x54')]()[_0xf3c4('0x26')](respondWithResult(_0x35bc0c,null))['catch'](handleError(_0x35bc0c,null));};exports['getMembers']=function(_0x6f7254,_0x2d3957,_0x1659dc){var _0x49f800={'raw':!![],'where':{}},_0x660c97={},_0x551461;return db[_0xf3c4('0x2f')][_0xf3c4('0x55')]({'where':{'id':_0x6f7254[_0xf3c4('0x47')]['id']}})[_0xf3c4('0x26')](handleEntityNotFound(_0x2d3957,null))[_0xf3c4('0x26')](function(_0x316896){if(_0x316896){_0x551461=_0x316896[_0xf3c4('0x4e')]({'plain':!![]});_0x660c97[_0xf3c4('0x33')]=_[_0xf3c4('0x48')](db['UserSmsQueue']['rawAttributes']);_0x660c97[_0xf3c4('0x35')]=_['keys'](_0x6f7254[_0xf3c4('0x35')]);_0x660c97[_0xf3c4('0x3d')]=_['intersection'](_0x660c97['model'],_0x660c97[_0xf3c4('0x35')]);_0x49f800['attributes']=_[_0xf3c4('0x49')](_0x660c97[_0xf3c4('0x33')],qs['fields'](_0x6f7254['query'][_0xf3c4('0x37')]));_0x49f800[_0xf3c4('0x36')]=_0x49f800[_0xf3c4('0x36')][_0xf3c4('0x38')]?_0x49f800[_0xf3c4('0x36')]:_0x660c97[_0xf3c4('0x33')];if(!_0x6f7254[_0xf3c4('0x35')][_0xf3c4('0x39')](_0xf3c4('0x56'))){_0x49f800[_0xf3c4('0x21')]=qs[_0xf3c4('0x21')](_0x6f7254[_0xf3c4('0x35')][_0xf3c4('0x21')]);_0x49f800['offset']=qs['offset'](_0x6f7254[_0xf3c4('0x35')][_0xf3c4('0x20')]);}_0x49f800['order']=qs[_0xf3c4('0x3b')](_0x6f7254[_0xf3c4('0x35')][_0xf3c4('0x3b')]);_0x49f800['where']=qs['filters'](_[_0xf3c4('0x3e')](_0x6f7254[_0xf3c4('0x35')],_0x660c97['filters']));_0x49f800[_0xf3c4('0x3c')][_0xf3c4('0x57')]=_0x316896['id'];if(_0x6f7254[_0xf3c4('0x35')][_0xf3c4('0x3f')]){_0x49f800[_0xf3c4('0x3c')]=_['merge'](_0x49f800[_0xf3c4('0x3c')],{'$or':_['map'](_0x49f800['attributes'],function(_0x6467e0){var _0x3a3646={};_0x3a3646[_0x6467e0]={'$like':'%'+_0x6f7254[_0xf3c4('0x35')][_0xf3c4('0x3f')]+'%'};return _0x3a3646;})});}_0x49f800=_[_0xf3c4('0x40')]({},_0x49f800,_0x6f7254[_0xf3c4('0x42')]);return db[_0xf3c4('0x58')][_0xf3c4('0x45')](_0x49f800);}})[_0xf3c4('0x26')](function(_0x24d99b){if(_0x24d99b){return db['User'][_0xf3c4('0x59')]({'where':{'id':_[_0xf3c4('0x34')](_0x24d99b,_0xf3c4('0x5a')),'role':_0xf3c4('0x5b')},'attributes':['id',_0xf3c4('0x2c'),'smsPause','updatedAt','createdAt']});}})[_0xf3c4('0x26')](function(_0x25cefb){if(_0x25cefb){return{'count':_0x25cefb[_0xf3c4('0x1f')],'rows':_[_0xf3c4('0x34')](_0x25cefb[_0xf3c4('0x5c')],function(_0x276808){return{'membername':_0x276808['name'],'UserId':_0x276808['id'],'queue_name':_0x551461[_0xf3c4('0x2c')],'SmsQueueId':_0x551461['id'],'interface':util[_0xf3c4('0x5d')]('%s/%s',_0xf3c4('0x5e'),_0x276808[_0xf3c4('0x2c')]),'penalty':0x0,'paused':_0x276808['smsPause'],'createdAt':_0x276808[_0xf3c4('0x5f')],'updatedAt':_0x276808[_0xf3c4('0x60')]};})};}else{return{'count':0x0,'rows':[]};}})['then'](respondWithFilteredResult(_0x2d3957,_0x49f800))[_0xf3c4('0x46')](handleError(_0x2d3957,null));};exports[_0xf3c4('0x61')]=function(_0x3b5fed,_0x5b061f,_0x1f2c55){var _0x2c99ef={};var _0x32fe61={};var _0x56d44e;var _0x3fc852;return db['SmsQueue']['findOne']({'where':{'id':_0x3b5fed[_0xf3c4('0x47')]['id']}})['then'](handleEntityNotFound(_0x5b061f,null))[_0xf3c4('0x26')](function(_0x5934ed){if(_0x5934ed){_0x56d44e=_0x5934ed;_0x32fe61[_0xf3c4('0x33')]=_[_0xf3c4('0x48')](db[_0xf3c4('0x62')][_0xf3c4('0x30')]);_0x32fe61[_0xf3c4('0x35')]=_['keys'](_0x3b5fed[_0xf3c4('0x35')]);_0x32fe61['filters']=_['intersection'](_0x32fe61[_0xf3c4('0x33')],_0x32fe61['query']);_0x2c99ef[_0xf3c4('0x36')]=_['intersection'](_0x32fe61[_0xf3c4('0x33')],qs['fields'](_0x3b5fed[_0xf3c4('0x35')]['fields']));_0x2c99ef[_0xf3c4('0x36')]=_0x2c99ef['attributes'][_0xf3c4('0x38')]?_0x2c99ef['attributes']:_0x32fe61['model'];_0x2c99ef[_0xf3c4('0x3a')]=qs['sort'](_0x3b5fed[_0xf3c4('0x35')][_0xf3c4('0x3b')]);_0x2c99ef['where']=qs[_0xf3c4('0x3d')](_[_0xf3c4('0x3e')](_0x3b5fed['query'],_0x32fe61[_0xf3c4('0x3d')]));if(_0x3b5fed[_0xf3c4('0x35')]['filter']){_0x2c99ef[_0xf3c4('0x3c')]=_[_0xf3c4('0x40')](_0x2c99ef[_0xf3c4('0x3c')],{'$or':_['map'](_0x2c99ef[_0xf3c4('0x36')],function(_0x524413){var _0x391e3d={};_0x391e3d[_0x524413]={'$like':'%'+_0x3b5fed['query'][_0xf3c4('0x3f')]+'%'};return _0x391e3d;})});}_0x2c99ef=_[_0xf3c4('0x40')]({},_0x2c99ef,_0x3b5fed[_0xf3c4('0x42')]);return _0x56d44e[_0xf3c4('0x61')](_0x2c99ef);}})[_0xf3c4('0x26')](function(_0x12ae50){if(_0x12ae50){_0x3fc852=_0x12ae50['length'];if(!_0x3b5fed[_0xf3c4('0x35')][_0xf3c4('0x39')](_0xf3c4('0x56'))){_0x2c99ef[_0xf3c4('0x21')]=qs['limit'](_0x3b5fed['query'][_0xf3c4('0x21')]);_0x2c99ef[_0xf3c4('0x20')]=qs[_0xf3c4('0x20')](_0x3b5fed[_0xf3c4('0x35')][_0xf3c4('0x20')]);}return _0x56d44e[_0xf3c4('0x61')](_0x2c99ef);}})[_0xf3c4('0x26')](function(_0x5d57e3){if(_0x5d57e3){return _0x5d57e3?{'count':_0x3fc852,'rows':_0x5d57e3}:null;}})[_0xf3c4('0x26')](respondWithResult(_0x5b061f,null))['catch'](handleError(_0x5b061f,null));};exports[_0xf3c4('0x63')]=function(_0x1b15f6,_0x31ac42,_0x5e0f2e){var _0x2feb11=_0x1b15f6[_0xf3c4('0x4c')][_0xf3c4('0x64')];return db[_0xf3c4('0x62')][_0xf3c4('0x45')]({'where':{'id':_0x2feb11},'attributes':['id'],'include':[{'model':db[_0xf3c4('0x65')],'as':'Agents','attributes':['id',_0xf3c4('0x2c'),_0xf3c4('0x66'),'voicePause','interface'],'raw':!![]}]})[_0xf3c4('0x26')](function(_0x53dfdd){if(_0x53dfdd){var _0x60403=_[_0xf3c4('0x67')](_0x53dfdd,function(_0x557160){var _0x5f0844=_0x557160[_0xf3c4('0x4e')]({'plain':!![]});return _0x5f0844[_0xf3c4('0x68')];});return db[_0xf3c4('0x2f')][_0xf3c4('0x4a')]({'where':{'id':_0x1b15f6[_0xf3c4('0x47')]['id']}})[_0xf3c4('0x26')](function(_0x2681eb){return db[_0xf3c4('0x69')]['transaction'](function(_0x445bde){return _0x2681eb[_0xf3c4('0x63')](_0x2feb11,{'transaction':_0x445bde})[_0xf3c4('0x26')](function(){return BPromise[_0xf3c4('0x6a')](_0x60403,function(_0x10d8fb){return db['UserSmsQueue'][_0xf3c4('0x6b')]({'where':{'UserId':_0x10d8fb['id'],'SmsQueueId':_0x1b15f6[_0xf3c4('0x47')]['id']},'transaction':_0x445bde});});})[_0xf3c4('0x26')](function(){_0x60403[_0xf3c4('0x6c')](function(_0x57eae7){socket[_0xf3c4('0x6d')](_0xf3c4('0x6e'),{'UserId':_0x57eae7['id'],'SmsQueueId':_0x2681eb['id']});});});});});}})[_0xf3c4('0x26')](respondWithStatusCode(_0x31ac42,null))[_0xf3c4('0x46')](handleError(_0x31ac42,null));};exports[_0xf3c4('0x6f')]=function(_0x4da564,_0x3b5422,_0x483163){return db[_0xf3c4('0x62')][_0xf3c4('0x45')]({'where':{'id':_0x4da564[_0xf3c4('0x35')][_0xf3c4('0x64')]},'attributes':['id'],'include':[{'model':db[_0xf3c4('0x65')],'as':_0xf3c4('0x68'),'attributes':['id'],'raw':!![]}]})['then'](handleEntityNotFound(_0x3b5422,null))[_0xf3c4('0x26')](function(_0x3d2109){var _0x7dccde=_[_0xf3c4('0x34')](_0x3d2109,'id');var _0x2e6a95=[];var _0x5856da=[];var _0x5a882c=squel[_0xf3c4('0x70')]();_0x5a882c[_0xf3c4('0x71')](_0xf3c4('0x72'))[_0xf3c4('0x73')](_0xf3c4('0x74'),'tq')[_0xf3c4('0x75')]('user_has_teams','ut',_0xf3c4('0x76'))['where']('SmsQueueId\x20=\x20?',_0x4da564['params']['id']);for(var _0x4f2749=0x0;_0x4f2749<_0x3d2109['length'];_0x4f2749+=0x1){let _0x525862=_0x3d2109[_0x4f2749];for(var _0xdd49da=0x0;_0xdd49da<_0x525862['Agents'][_0xf3c4('0x38')];_0xdd49da+=0x1){let _0x17f674=_0x525862[_0xf3c4('0x68')][_0xdd49da];var _0x19d453=_0x5a882c[_0xf3c4('0x77')]();_0x19d453[_0xf3c4('0x3c')]('ut.UserId\x20=\x20?',_0x17f674['id']);_0x5856da[_0xf3c4('0x78')](db[_0xf3c4('0x69')][_0xf3c4('0x35')](_0x19d453[_0xf3c4('0x79')](),{'type':db[_0xf3c4('0x69')][_0xf3c4('0x7a')]['SELECT']})[_0xf3c4('0x26')](function(_0x15a5e0){if(_0x15a5e0[_0xf3c4('0x38')]===0x1){return _0x17f674['id'];}else{var _0x2deda6=_[_0xf3c4('0x7b')](_[_0xf3c4('0x34')](_0x15a5e0,'TeamId'),function(_0x180c0b){return _[_0xf3c4('0x7c')](_0x7dccde,_0x180c0b);});if(_0x2deda6){return _0x17f674['id'];}}}));}}return BPromise[_0xf3c4('0x7d')](_0x5856da)[_0xf3c4('0x26')](function(_0x51f750){_0x2e6a95=_(_0x2e6a95)['union'](_0x51f750)[_0xf3c4('0x7e')]()[_0xf3c4('0x7f')]();return db[_0xf3c4('0x2f')][_0xf3c4('0x4a')]({'where':{'id':_0x4da564['params']['id']}})[_0xf3c4('0x26')](function(_0x34fe06){return db['sequelize']['transaction'](function(_0x5938a7){return _0x34fe06[_0xf3c4('0x6f')](_0x4da564[_0xf3c4('0x35')][_0xf3c4('0x64')],{'transaction':_0x5938a7})[_0xf3c4('0x26')](function(){if(!_[_0xf3c4('0x80')](_0x2e6a95)){return _0x34fe06[_0xf3c4('0x81')](_0x2e6a95,{'transaction':_0x5938a7});}})[_0xf3c4('0x26')](function(){_0x2e6a95[_0xf3c4('0x6c')](function(_0x35c346){socket[_0xf3c4('0x6d')](_0xf3c4('0x82'),{'UserId':_0x35c346,'SmsQueueId':_0x34fe06['id']});});});});});});})[_0xf3c4('0x26')](respondWithStatusCode(_0x3b5422,null))[_0xf3c4('0x46')](handleError(_0x3b5422,null));};exports[_0xf3c4('0x83')]=function(_0x4a7e3f,_0x55274d,_0x21c38e){return db[_0xf3c4('0x2f')]['find']({'where':{'id':_0x4a7e3f[_0xf3c4('0x47')]['id']}})[_0xf3c4('0x26')](handleEntityNotFound(_0x55274d,null))[_0xf3c4('0x26')](function(_0x4680c7){if(_0x4680c7){return _0x4680c7[_0xf3c4('0x83')](_0x4a7e3f[_0xf3c4('0x4c')]['ids'],_[_0xf3c4('0x84')](_0x4a7e3f[_0xf3c4('0x4c')],[_0xf3c4('0x64'),'id'])||{})[_0xf3c4('0x85')](function(_0x4ec9c6){for(var _0x3b8281=0x0;_0x3b8281<_0x4a7e3f[_0xf3c4('0x4c')][_0xf3c4('0x64')][_0xf3c4('0x38')];_0x3b8281+=0x1){socket['emit'](_0xf3c4('0x6e'),{'UserId':_0x4a7e3f[_0xf3c4('0x4c')][_0xf3c4('0x64')][_0x3b8281],'SmsQueueId':_0x4a7e3f[_0xf3c4('0x47')]['id']});}return _0x4ec9c6;});}})['then'](respondWithResult(_0x55274d,null))[_0xf3c4('0x46')](handleError(_0x55274d,null));};exports[_0xf3c4('0x81')]=function(_0x3a8547,_0xe51402,_0xfeca3a){return db[_0xf3c4('0x2f')][_0xf3c4('0x4a')]({'where':{'id':_0x3a8547[_0xf3c4('0x47')]['id']}})[_0xf3c4('0x26')](handleEntityNotFound(_0xe51402,null))[_0xf3c4('0x26')](function(_0x1c8823){if(_0x1c8823){return _0x1c8823[_0xf3c4('0x81')](_0x3a8547[_0xf3c4('0x35')]['ids'])[_0xf3c4('0x26')](function(){if(_[_0xf3c4('0x86')](_0x3a8547[_0xf3c4('0x35')][_0xf3c4('0x64')])){for(var _0x89a1e2=0x0;_0x89a1e2<_0x3a8547[_0xf3c4('0x35')][_0xf3c4('0x64')][_0xf3c4('0x38')];_0x89a1e2+=0x1){socket[_0xf3c4('0x6d')]('userSmsQueue:remove',{'UserId':Number(_0x3a8547['query'][_0xf3c4('0x64')][_0x89a1e2]),'SmsQueueId':Number(_0x3a8547[_0xf3c4('0x47')]['id'])});}}else{socket[_0xf3c4('0x6d')](_0xf3c4('0x82'),{'UserId':Number(_0x3a8547[_0xf3c4('0x35')][_0xf3c4('0x64')]),'SmsQueueId':Number(_0x3a8547[_0xf3c4('0x47')]['id'])});}});}})[_0xf3c4('0x26')](respondWithStatusCode(_0xe51402,null))['catch'](handleError(_0xe51402,null));};exports[_0xf3c4('0x87')]=function(_0xaa0ede,_0x406663,_0x5f2cf2){var _0x21ba25={};var _0x10b801={};var _0x4a6a27;var _0x3c2c81;return db[_0xf3c4('0x2f')][_0xf3c4('0x55')]({'where':{'id':_0xaa0ede[_0xf3c4('0x47')]['id']}})[_0xf3c4('0x26')](handleEntityNotFound(_0x406663,null))[_0xf3c4('0x26')](function(_0x52f73b){if(_0x52f73b){_0x4a6a27=_0x52f73b;_0x10b801['model']=_[_0xf3c4('0x48')](db[_0xf3c4('0x65')][_0xf3c4('0x30')]);_0x10b801[_0xf3c4('0x35')]=_[_0xf3c4('0x48')](_0xaa0ede[_0xf3c4('0x35')]);_0x10b801[_0xf3c4('0x3d')]=_[_0xf3c4('0x49')](_0x10b801['model'],_0x10b801['query']);_0x21ba25['attributes']=_[_0xf3c4('0x49')](_0x10b801[_0xf3c4('0x33')],qs['fields'](_0xaa0ede[_0xf3c4('0x35')][_0xf3c4('0x37')]));_0x21ba25['attributes']=_0x21ba25[_0xf3c4('0x36')][_0xf3c4('0x38')]?_0x21ba25[_0xf3c4('0x36')]:_0x10b801[_0xf3c4('0x33')];_0x21ba25[_0xf3c4('0x3a')]=qs[_0xf3c4('0x3b')](_0xaa0ede['query'][_0xf3c4('0x3b')]);_0x21ba25[_0xf3c4('0x3c')]=qs[_0xf3c4('0x3d')](_['pick'](_0xaa0ede[_0xf3c4('0x35')],_0x10b801[_0xf3c4('0x3d')]));if(_0xaa0ede['query']['filter']){_0x21ba25[_0xf3c4('0x3c')]=_[_0xf3c4('0x40')](_0x21ba25[_0xf3c4('0x3c')],{'$or':_[_0xf3c4('0x34')](_0x21ba25[_0xf3c4('0x36')],function(_0x37247d){var _0x2dfe27={};_0x2dfe27[_0x37247d]={'$like':'%'+_0xaa0ede['query']['filter']+'%'};return _0x2dfe27;})});}_0x21ba25=_[_0xf3c4('0x40')]({},_0x21ba25,_0xaa0ede[_0xf3c4('0x42')]);return _0x4a6a27['getAgents'](_0x21ba25);}})['then'](function(_0x113f6e){if(_0x113f6e){_0x3c2c81=_0x113f6e[_0xf3c4('0x38')];if(!_0xaa0ede[_0xf3c4('0x35')][_0xf3c4('0x39')](_0xf3c4('0x56'))){_0x21ba25[_0xf3c4('0x21')]=qs['limit'](_0xaa0ede[_0xf3c4('0x35')][_0xf3c4('0x21')]);_0x21ba25[_0xf3c4('0x20')]=qs['offset'](_0xaa0ede[_0xf3c4('0x35')]['offset']);}return _0x4a6a27[_0xf3c4('0x87')](_0x21ba25);}})[_0xf3c4('0x26')](function(_0x2aaec5){if(_0x2aaec5){return _0x2aaec5?{'count':_0x3c2c81,'rows':_0x2aaec5}:null;}})[_0xf3c4('0x26')](respondWithResult(_0x406663,null))[_0xf3c4('0x46')](handleError(_0x406663,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(_0x3b2395,_0x1cf2c1){var _0x2e6751=function(_0x4ea274){while(--_0x4ea274){_0x3b2395['push'](_0x3b2395['shift']());}};_0x2e6751(++_0x1cf2c1);}(_0x5f66,0x1a0));var _0x65f6=function(_0x3e5086,_0x48f4a2){_0x3e5086=_0x3e5086-0x0;var _0xfeb102=_0x5f66[_0x3e5086];return _0xfeb102;};'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