Built motion from commit da617fac.|2.6.6
[motion2.git] / server / api / smsQueue / smsQueue.controller.js
index 09b3dc8..2f0b28c 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 _0xa8b1=['SmsQueue','rawAttributes','fieldName','key','query','keys','filters','intersection','model','fields','attributes','nolimit','sort','where','merge','type','VIRTUAL','filter','options','includeAll','include','rows','catch','show','params','find','create','body','user','UserProfileSection','userProfileId','UserProfileResource','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','describe','findOne','UserSmsQueue','length','hasOwnProperty','order','pick','SmsQueueId','findAll','User','findAndCountAll','UserId','smsPause','updatedAt','createdAt','format','%s/%s','Team','getTeams','ids','Agents','voicePause','flatMap','sequelize','each','findOrCreate','emit','removeTeams','select','field','from','join','push','QueryTypes','every','includes','all','union','compact','value','transaction','isEmpty','removeAgents','forEach','userSmsQueue:remove','addAgents','spread','userSmsQueue:save','isArray','getAgents','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','to-csv','ejs','squel','crypto','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/utils','../../config/environment','../../mysqldb','socket.io-emitter','./smsQueue.socket','register','sendStatus','status','end','json','offset','undefined','limit','count','set','apply','reject','save','update','then','destroy','get','SmsQueues','error','stack','name','send','index','map'];(function(_0x35b4d9,_0x4dea32){var _0xda3222=function(_0x1c02e9){while(--_0x1c02e9){_0x35b4d9['push'](_0x35b4d9['shift']());}};_0xda3222(++_0x4dea32);}(_0xa8b1,0xd7));var _0x1a8b=function(_0x2aea56,_0x241ac4){_0x2aea56=_0x2aea56-0x0;var _0x311497=_0xa8b1[_0x2aea56];return _0x311497;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x1a8b('0x0'));var zipdir=require(_0x1a8b('0x1'));var jsonpatch=require(_0x1a8b('0x2'));var rp=require(_0x1a8b('0x3'));var moment=require(_0x1a8b('0x4'));var BPromise=require(_0x1a8b('0x5'));var Mustache=require(_0x1a8b('0x6'));var util=require(_0x1a8b('0x7'));var path=require(_0x1a8b('0x8'));var sox=require('sox');var csv=require(_0x1a8b('0x9'));var ejs=require(_0x1a8b('0xa'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require('lodash');var squel=require(_0x1a8b('0xb'));var crypto=require(_0x1a8b('0xc'));var jsforce=require('jsforce');var deskjs=require('desk.js');var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require(_0x1a8b('0xd'));var Redis=require(_0x1a8b('0xe'));var authService=require(_0x1a8b('0xf'));var qs=require(_0x1a8b('0x10'));var as=require(_0x1a8b('0x11'));var hardwareService=require(_0x1a8b('0x12'));var logger=require('../../config/logger')(_0x1a8b('0x13'));var utils=require(_0x1a8b('0x14'));var config=require(_0x1a8b('0x15'));var licenseUtil=require('../../config/license/util');var db=require(_0x1a8b('0x16'))['db'];config['redis']=_['defaults'](config['redis'],{'host':'localhost','port':0x18eb});var socket=require(_0x1a8b('0x17'))(new Redis(config['redis']));require(_0x1a8b('0x18'))[_0x1a8b('0x19')](socket);function respondWithStatusCode(_0x2e7397,_0x367fe9){_0x367fe9=_0x367fe9||0xcc;return function(_0x38d304){if(_0x38d304){return _0x2e7397[_0x1a8b('0x1a')](_0x367fe9);}return _0x2e7397[_0x1a8b('0x1b')](_0x367fe9)[_0x1a8b('0x1c')]();};}function respondWithResult(_0xebc0db,_0x2d5622){_0x2d5622=_0x2d5622||0xc8;return function(_0x396edb){if(_0x396edb){return _0xebc0db[_0x1a8b('0x1b')](_0x2d5622)[_0x1a8b('0x1d')](_0x396edb);}};}function respondWithFilteredResult(_0x31935e,_0x460d4e){return function(_0x4e6a30){if(_0x4e6a30){var _0x22f790=typeof _0x460d4e[_0x1a8b('0x1e')]===_0x1a8b('0x1f')&&typeof _0x460d4e[_0x1a8b('0x20')]===_0x1a8b('0x1f');var _0x356e01=_0x4e6a30[_0x1a8b('0x21')];var _0x5605a6=_0x22f790?0x0:_0x460d4e[_0x1a8b('0x1e')];var _0x2e7407=_0x22f790?_0x4e6a30[_0x1a8b('0x21')]:_0x460d4e[_0x1a8b('0x1e')]+_0x460d4e[_0x1a8b('0x20')];var _0x466d34;if(_0x2e7407>=_0x356e01){_0x2e7407=_0x356e01;_0x466d34=0xc8;}else{_0x466d34=0xce;}_0x31935e[_0x1a8b('0x1b')](_0x466d34);return _0x31935e[_0x1a8b('0x22')]('Content-Range',_0x5605a6+'-'+_0x2e7407+'/'+_0x356e01)[_0x1a8b('0x1d')](_0x4e6a30);}return null;};}function patchUpdates(_0x373e72){return function(_0x3928db){try{jsonpatch[_0x1a8b('0x23')](_0x3928db,_0x373e72,!![]);}catch(_0x547326){return BPromise[_0x1a8b('0x24')](_0x547326);}return _0x3928db[_0x1a8b('0x25')]();};}function saveUpdates(_0x204f46,_0xd67e34){return function(_0x249403){if(_0x249403){return _0x249403[_0x1a8b('0x26')](_0x204f46)[_0x1a8b('0x27')](function(_0x3afdfa){return _0x3afdfa;});}return null;};}function removeEntity(_0x48efd1,_0x2823bb){return function(_0x4459f6){if(_0x4459f6){return _0x4459f6[_0x1a8b('0x28')]()['then'](function(){var _0x5075e0=_0x4459f6[_0x1a8b('0x29')]({'plain':!![]});var _0x573473=_0x1a8b('0x2a');return db['UserProfileResource'][_0x1a8b('0x28')]({'where':{'type':_0x573473,'resourceId':_0x5075e0['id']}})[_0x1a8b('0x27')](function(){return _0x4459f6;});})['then'](function(){_0x48efd1[_0x1a8b('0x1b')](0xcc)[_0x1a8b('0x1c')]();});}};}function handleEntityNotFound(_0x59f301,_0x5f40fd){return function(_0x4b52ce){if(!_0x4b52ce){_0x59f301[_0x1a8b('0x1a')](0x194);}return _0x4b52ce;};}function handleError(_0x4b96f3,_0x22a66b){_0x22a66b=_0x22a66b||0x1f4;return function(_0x599670){logger[_0x1a8b('0x2b')](_0x599670[_0x1a8b('0x2c')]);if(_0x599670[_0x1a8b('0x2d')]){delete _0x599670['name'];}_0x4b96f3[_0x1a8b('0x1b')](_0x22a66b)[_0x1a8b('0x2e')](_0x599670);};}exports[_0x1a8b('0x2f')]=function(_0xb5c7c1,_0x3f7330){var _0x100a25={},_0x5869d6={},_0x14b4b9={'count':0x0,'rows':[]};var _0x35e765=_[_0x1a8b('0x30')](db[_0x1a8b('0x31')][_0x1a8b('0x32')],function(_0x1a6574){return{'name':_0x1a6574[_0x1a8b('0x33')],'type':_0x1a6574['type'][_0x1a8b('0x34')]};});_0x5869d6['model']=_[_0x1a8b('0x30')](_0x35e765,'name');_0x5869d6[_0x1a8b('0x35')]=_[_0x1a8b('0x36')](_0xb5c7c1[_0x1a8b('0x35')]);_0x5869d6[_0x1a8b('0x37')]=_[_0x1a8b('0x38')](_0x5869d6[_0x1a8b('0x39')],_0x5869d6[_0x1a8b('0x35')]);_0x100a25['attributes']=_['intersection'](_0x5869d6['model'],qs[_0x1a8b('0x3a')](_0xb5c7c1[_0x1a8b('0x35')][_0x1a8b('0x3a')]));_0x100a25[_0x1a8b('0x3b')]=_0x100a25[_0x1a8b('0x3b')]['length']?_0x100a25[_0x1a8b('0x3b')]:_0x5869d6[_0x1a8b('0x39')];if(!_0xb5c7c1[_0x1a8b('0x35')]['hasOwnProperty'](_0x1a8b('0x3c'))){_0x100a25[_0x1a8b('0x20')]=qs[_0x1a8b('0x20')](_0xb5c7c1[_0x1a8b('0x35')][_0x1a8b('0x20')]);_0x100a25[_0x1a8b('0x1e')]=qs[_0x1a8b('0x1e')](_0xb5c7c1[_0x1a8b('0x35')]['offset']);}_0x100a25['order']=qs[_0x1a8b('0x3d')](_0xb5c7c1['query']['sort']);_0x100a25[_0x1a8b('0x3e')]=qs[_0x1a8b('0x37')](_['pick'](_0xb5c7c1['query'],_0x5869d6[_0x1a8b('0x37')]),_0x35e765);if(_0xb5c7c1[_0x1a8b('0x35')]['filter']){_0x100a25[_0x1a8b('0x3e')]=_[_0x1a8b('0x3f')](_0x100a25[_0x1a8b('0x3e')],{'$or':_[_0x1a8b('0x30')](_0x35e765,function(_0xf4aebb){if(_0xf4aebb[_0x1a8b('0x40')]!==_0x1a8b('0x41')){var _0x3aad42={};_0x3aad42[_0xf4aebb[_0x1a8b('0x2d')]]={'$like':'%'+_0xb5c7c1['query'][_0x1a8b('0x42')]+'%'};return _0x3aad42;}})});}_0x100a25=_[_0x1a8b('0x3f')]({},_0x100a25,_0xb5c7c1[_0x1a8b('0x43')]);var _0x16540c={'where':_0x100a25[_0x1a8b('0x3e')]};return db['SmsQueue'][_0x1a8b('0x21')](_0x16540c)[_0x1a8b('0x27')](function(_0x1c744d){_0x14b4b9[_0x1a8b('0x21')]=_0x1c744d;if(_0xb5c7c1[_0x1a8b('0x35')][_0x1a8b('0x44')]){_0x100a25[_0x1a8b('0x45')]=[{'all':!![]}];}return db['SmsQueue']['findAll'](_0x100a25);})['then'](function(_0x137e4e){_0x14b4b9[_0x1a8b('0x46')]=_0x137e4e;return _0x14b4b9;})[_0x1a8b('0x27')](respondWithFilteredResult(_0x3f7330,_0x100a25))[_0x1a8b('0x47')](handleError(_0x3f7330,null));};exports[_0x1a8b('0x48')]=function(_0x87a37f,_0x2834b4){var _0x5de0e8={'raw':!![],'where':{'id':_0x87a37f[_0x1a8b('0x49')]['id']}},_0x527569={};_0x527569['model']=_[_0x1a8b('0x36')](db[_0x1a8b('0x31')][_0x1a8b('0x32')]);_0x527569['query']=_[_0x1a8b('0x36')](_0x87a37f['query']);_0x527569[_0x1a8b('0x37')]=_[_0x1a8b('0x38')](_0x527569[_0x1a8b('0x39')],_0x527569[_0x1a8b('0x35')]);_0x5de0e8[_0x1a8b('0x3b')]=_[_0x1a8b('0x38')](_0x527569[_0x1a8b('0x39')],qs[_0x1a8b('0x3a')](_0x87a37f[_0x1a8b('0x35')]['fields']));_0x5de0e8['attributes']=_0x5de0e8['attributes']['length']?_0x5de0e8['attributes']:_0x527569[_0x1a8b('0x39')];if(_0x87a37f[_0x1a8b('0x35')][_0x1a8b('0x44')]){_0x5de0e8['include']=[{'all':!![]}];}_0x5de0e8=_[_0x1a8b('0x3f')]({},_0x5de0e8,_0x87a37f['options']);return db[_0x1a8b('0x31')][_0x1a8b('0x4a')](_0x5de0e8)[_0x1a8b('0x27')](handleEntityNotFound(_0x2834b4,null))[_0x1a8b('0x27')](respondWithResult(_0x2834b4,null))['catch'](handleError(_0x2834b4,null));};exports[_0x1a8b('0x4b')]=function(_0x4b789d,_0x1bbb80){return db['SmsQueue'][_0x1a8b('0x4b')](_0x4b789d[_0x1a8b('0x4c')],{})[_0x1a8b('0x27')](function(_0x1a7cee){var _0x41e31a=_0x4b789d[_0x1a8b('0x4d')][_0x1a8b('0x29')]({'plain':!![]});if(!_0x41e31a)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x41e31a['role']===_0x1a8b('0x4d')){var _0x3bbcf9=_0x1a7cee[_0x1a8b('0x29')]({'plain':!![]});var _0x35b5c8='SmsQueues';return db[_0x1a8b('0x4e')][_0x1a8b('0x4a')]({'where':{'name':_0x35b5c8,'userProfileId':_0x41e31a[_0x1a8b('0x4f')]},'raw':!![]})['then'](function(_0x352712){if(_0x352712&&_0x352712['autoAssociation']===0x0){return db[_0x1a8b('0x50')][_0x1a8b('0x4b')]({'name':_0x3bbcf9[_0x1a8b('0x2d')],'resourceId':_0x3bbcf9['id'],'type':_0x352712[_0x1a8b('0x2d')],'sectionId':_0x352712['id']},{})[_0x1a8b('0x27')](function(){return _0x1a7cee;});}else{return _0x1a7cee;}})[_0x1a8b('0x47')](function(_0x4ca28d){logger[_0x1a8b('0x2b')](_0x1a8b('0x51'),_0x4ca28d);throw _0x4ca28d;});}return _0x1a7cee;})[_0x1a8b('0x27')](respondWithResult(_0x1bbb80,0xc9))['catch'](handleError(_0x1bbb80,null));};exports[_0x1a8b('0x26')]=function(_0x41b65e,_0x3b039d){if(_0x41b65e[_0x1a8b('0x4c')]['id']){delete _0x41b65e[_0x1a8b('0x4c')]['id'];}return db[_0x1a8b('0x31')][_0x1a8b('0x4a')]({'where':{'id':_0x41b65e[_0x1a8b('0x49')]['id']}})['then'](handleEntityNotFound(_0x3b039d,null))[_0x1a8b('0x27')](saveUpdates(_0x41b65e[_0x1a8b('0x4c')],null))[_0x1a8b('0x27')](respondWithResult(_0x3b039d,null))[_0x1a8b('0x47')](handleError(_0x3b039d,null));};exports[_0x1a8b('0x28')]=function(_0x55558b,_0x491be8){return db[_0x1a8b('0x31')][_0x1a8b('0x4a')]({'where':{'id':_0x55558b[_0x1a8b('0x49')]['id']}})[_0x1a8b('0x27')](handleEntityNotFound(_0x491be8,null))[_0x1a8b('0x27')](removeEntity(_0x491be8,null))[_0x1a8b('0x47')](handleError(_0x491be8,null));};exports['describe']=function(_0x228b6b,_0x411c1d){return db[_0x1a8b('0x31')][_0x1a8b('0x52')]()[_0x1a8b('0x27')](respondWithResult(_0x411c1d,null))[_0x1a8b('0x47')](handleError(_0x411c1d,null));};exports['getMembers']=function(_0x315eaa,_0x58d73c,_0x508e87){var _0x5e3f64={'raw':!![],'where':{}},_0x513cc6={},_0x1db621;return db[_0x1a8b('0x31')][_0x1a8b('0x53')]({'where':{'id':_0x315eaa[_0x1a8b('0x49')]['id']}})['then'](handleEntityNotFound(_0x58d73c,null))['then'](function(_0x4486c3){if(_0x4486c3){_0x1db621=_0x4486c3['get']({'plain':!![]});_0x513cc6[_0x1a8b('0x39')]=_['keys'](db[_0x1a8b('0x54')]['rawAttributes']);_0x513cc6['query']=_[_0x1a8b('0x36')](_0x315eaa['query']);_0x513cc6[_0x1a8b('0x37')]=_[_0x1a8b('0x38')](_0x513cc6[_0x1a8b('0x39')],_0x513cc6[_0x1a8b('0x35')]);_0x5e3f64['attributes']=_[_0x1a8b('0x38')](_0x513cc6[_0x1a8b('0x39')],qs[_0x1a8b('0x3a')](_0x315eaa['query'][_0x1a8b('0x3a')]));_0x5e3f64[_0x1a8b('0x3b')]=_0x5e3f64['attributes'][_0x1a8b('0x55')]?_0x5e3f64['attributes']:_0x513cc6[_0x1a8b('0x39')];if(!_0x315eaa[_0x1a8b('0x35')][_0x1a8b('0x56')](_0x1a8b('0x3c'))){_0x5e3f64[_0x1a8b('0x20')]=qs[_0x1a8b('0x20')](_0x315eaa[_0x1a8b('0x35')][_0x1a8b('0x20')]);_0x5e3f64[_0x1a8b('0x1e')]=qs[_0x1a8b('0x1e')](_0x315eaa[_0x1a8b('0x35')][_0x1a8b('0x1e')]);}_0x5e3f64[_0x1a8b('0x57')]=qs['sort'](_0x315eaa[_0x1a8b('0x35')][_0x1a8b('0x3d')]);_0x5e3f64[_0x1a8b('0x3e')]=qs[_0x1a8b('0x37')](_[_0x1a8b('0x58')](_0x315eaa[_0x1a8b('0x35')],_0x513cc6[_0x1a8b('0x37')]));_0x5e3f64[_0x1a8b('0x3e')][_0x1a8b('0x59')]=_0x4486c3['id'];if(_0x315eaa[_0x1a8b('0x35')][_0x1a8b('0x42')]){_0x5e3f64[_0x1a8b('0x3e')]=_[_0x1a8b('0x3f')](_0x5e3f64['where'],{'$or':_['map'](_0x5e3f64[_0x1a8b('0x3b')],function(_0x5dbd8b){var _0x3ef577={};_0x3ef577[_0x5dbd8b]={'$like':'%'+_0x315eaa[_0x1a8b('0x35')]['filter']+'%'};return _0x3ef577;})});}_0x5e3f64=_[_0x1a8b('0x3f')]({},_0x5e3f64,_0x315eaa['options']);return db[_0x1a8b('0x54')][_0x1a8b('0x5a')](_0x5e3f64);}})[_0x1a8b('0x27')](function(_0x724ffd){if(_0x724ffd){return db[_0x1a8b('0x5b')][_0x1a8b('0x5c')]({'where':{'id':_['map'](_0x724ffd,_0x1a8b('0x5d')),'role':'agent'},'attributes':['id',_0x1a8b('0x2d'),_0x1a8b('0x5e'),_0x1a8b('0x5f'),_0x1a8b('0x60')]});}})[_0x1a8b('0x27')](function(_0x449b2a){if(_0x449b2a){return{'count':_0x449b2a[_0x1a8b('0x21')],'rows':_[_0x1a8b('0x30')](_0x449b2a[_0x1a8b('0x46')],function(_0x5ba7f7){return{'membername':_0x5ba7f7[_0x1a8b('0x2d')],'UserId':_0x5ba7f7['id'],'queue_name':_0x1db621[_0x1a8b('0x2d')],'SmsQueueId':_0x1db621['id'],'interface':util[_0x1a8b('0x61')](_0x1a8b('0x62'),'SIP',_0x5ba7f7[_0x1a8b('0x2d')]),'penalty':0x0,'paused':_0x5ba7f7[_0x1a8b('0x5e')],'createdAt':_0x5ba7f7[_0x1a8b('0x60')],'updatedAt':_0x5ba7f7[_0x1a8b('0x5f')]};})};}else{return{'count':0x0,'rows':[]};}})[_0x1a8b('0x27')](respondWithFilteredResult(_0x58d73c,_0x5e3f64))[_0x1a8b('0x47')](handleError(_0x58d73c,null));};exports['getTeams']=function(_0x3acab4,_0x46a13a,_0xa87981){var _0x538283={};var _0x5da092={};var _0x3214ab;var _0x559263;return db['SmsQueue'][_0x1a8b('0x53')]({'where':{'id':_0x3acab4[_0x1a8b('0x49')]['id']}})[_0x1a8b('0x27')](handleEntityNotFound(_0x46a13a,null))[_0x1a8b('0x27')](function(_0x58b276){if(_0x58b276){_0x3214ab=_0x58b276;_0x5da092[_0x1a8b('0x39')]=_[_0x1a8b('0x36')](db[_0x1a8b('0x63')][_0x1a8b('0x32')]);_0x5da092[_0x1a8b('0x35')]=_['keys'](_0x3acab4['query']);_0x5da092['filters']=_[_0x1a8b('0x38')](_0x5da092['model'],_0x5da092[_0x1a8b('0x35')]);_0x538283[_0x1a8b('0x3b')]=_[_0x1a8b('0x38')](_0x5da092['model'],qs[_0x1a8b('0x3a')](_0x3acab4[_0x1a8b('0x35')]['fields']));_0x538283[_0x1a8b('0x3b')]=_0x538283[_0x1a8b('0x3b')][_0x1a8b('0x55')]?_0x538283[_0x1a8b('0x3b')]:_0x5da092[_0x1a8b('0x39')];_0x538283['order']=qs[_0x1a8b('0x3d')](_0x3acab4[_0x1a8b('0x35')][_0x1a8b('0x3d')]);_0x538283[_0x1a8b('0x3e')]=qs[_0x1a8b('0x37')](_['pick'](_0x3acab4[_0x1a8b('0x35')],_0x5da092[_0x1a8b('0x37')]));if(_0x3acab4['query'][_0x1a8b('0x42')]){_0x538283[_0x1a8b('0x3e')]=_[_0x1a8b('0x3f')](_0x538283[_0x1a8b('0x3e')],{'$or':_[_0x1a8b('0x30')](_0x538283[_0x1a8b('0x3b')],function(_0x3a1e1b){var _0x382553={};_0x382553[_0x3a1e1b]={'$like':'%'+_0x3acab4[_0x1a8b('0x35')]['filter']+'%'};return _0x382553;})});}_0x538283=_[_0x1a8b('0x3f')]({},_0x538283,_0x3acab4[_0x1a8b('0x43')]);return _0x3214ab[_0x1a8b('0x64')](_0x538283);}})[_0x1a8b('0x27')](function(_0x587ccb){if(_0x587ccb){_0x559263=_0x587ccb['length'];if(!_0x3acab4['query'][_0x1a8b('0x56')](_0x1a8b('0x3c'))){_0x538283[_0x1a8b('0x20')]=qs[_0x1a8b('0x20')](_0x3acab4[_0x1a8b('0x35')][_0x1a8b('0x20')]);_0x538283[_0x1a8b('0x1e')]=qs[_0x1a8b('0x1e')](_0x3acab4[_0x1a8b('0x35')]['offset']);}return _0x3214ab[_0x1a8b('0x64')](_0x538283);}})['then'](function(_0x4d15f6){if(_0x4d15f6){return _0x4d15f6?{'count':_0x559263,'rows':_0x4d15f6}:null;}})[_0x1a8b('0x27')](respondWithResult(_0x46a13a,null))[_0x1a8b('0x47')](handleError(_0x46a13a,null));};exports['addTeams']=function(_0x5f3401,_0xdbe2fd,_0x18a0f7){var _0x557f29=_0x5f3401['body'][_0x1a8b('0x65')];return db['Team'][_0x1a8b('0x5a')]({'where':{'id':_0x557f29},'attributes':['id'],'include':[{'model':db[_0x1a8b('0x5b')],'as':_0x1a8b('0x66'),'attributes':['id',_0x1a8b('0x2d'),'online',_0x1a8b('0x67'),'interface'],'raw':!![]}]})[_0x1a8b('0x27')](function(_0x5a1e0a){if(_0x5a1e0a){var _0x168d61=_[_0x1a8b('0x68')](_0x5a1e0a,function(_0x3afdbd){var _0x3775a0=_0x3afdbd[_0x1a8b('0x29')]({'plain':!![]});return _0x3775a0[_0x1a8b('0x66')];});return db[_0x1a8b('0x31')][_0x1a8b('0x4a')]({'where':{'id':_0x5f3401['params']['id']}})[_0x1a8b('0x27')](function(_0x51e757){return db[_0x1a8b('0x69')]['transaction'](function(_0x417b11){return _0x51e757['addTeams'](_0x557f29,{'transaction':_0x417b11})[_0x1a8b('0x27')](function(){return BPromise[_0x1a8b('0x6a')](_0x168d61,function(_0x5bcc4e){return db[_0x1a8b('0x54')][_0x1a8b('0x6b')]({'where':{'UserId':_0x5bcc4e['id'],'SmsQueueId':_0x5f3401['params']['id']},'transaction':_0x417b11});});})['then'](function(){_0x168d61['forEach'](function(_0x4de264){socket[_0x1a8b('0x6c')]('userSmsQueue:save',{'UserId':_0x4de264['id'],'SmsQueueId':_0x51e757['id']});});});});});}})[_0x1a8b('0x27')](respondWithStatusCode(_0xdbe2fd,null))['catch'](handleError(_0xdbe2fd,null));};exports[_0x1a8b('0x6d')]=function(_0x45c8ca,_0x36e109,_0x1516ab){return db['Team'][_0x1a8b('0x5a')]({'where':{'id':_0x45c8ca[_0x1a8b('0x35')][_0x1a8b('0x65')]},'attributes':['id'],'include':[{'model':db[_0x1a8b('0x5b')],'as':_0x1a8b('0x66'),'attributes':['id'],'raw':!![]}]})[_0x1a8b('0x27')](handleEntityNotFound(_0x36e109,null))['then'](function(_0x19d9fe){var _0x4018b3=_[_0x1a8b('0x30')](_0x19d9fe,'id');var _0x1b7116=[];var _0x249778=[];var _0x1476a5=squel[_0x1a8b('0x6e')]();_0x1476a5[_0x1a8b('0x6f')]('tq.TeamId')[_0x1a8b('0x70')]('team_has_sms_queues','tq')[_0x1a8b('0x71')]('user_has_teams','ut','ut.TeamId\x20=\x20tq.TeamId')[_0x1a8b('0x3e')]('SmsQueueId\x20=\x20?',_0x45c8ca[_0x1a8b('0x49')]['id']);for(var _0x133f93=0x0;_0x133f93<_0x19d9fe[_0x1a8b('0x55')];_0x133f93+=0x1){let _0x104cd5=_0x19d9fe[_0x133f93];for(var _0x1688ba=0x0;_0x1688ba<_0x104cd5['Agents'][_0x1a8b('0x55')];_0x1688ba+=0x1){let _0x3a89aa=_0x104cd5['Agents'][_0x1688ba];var _0x14cd36=_0x1476a5['clone']();_0x14cd36['where']('ut.UserId\x20=\x20?',_0x3a89aa['id']);_0x249778[_0x1a8b('0x72')](db[_0x1a8b('0x69')][_0x1a8b('0x35')](_0x14cd36['toString'](),{'type':db['sequelize'][_0x1a8b('0x73')]['SELECT']})[_0x1a8b('0x27')](function(_0x13bfd7){if(_0x13bfd7['length']===0x1){return _0x3a89aa['id'];}else{var _0x45cd07=_[_0x1a8b('0x74')](_[_0x1a8b('0x30')](_0x13bfd7,'TeamId'),function(_0x3b47ce){return _[_0x1a8b('0x75')](_0x4018b3,_0x3b47ce);});if(_0x45cd07){return _0x3a89aa['id'];}}}));}}return BPromise[_0x1a8b('0x76')](_0x249778)[_0x1a8b('0x27')](function(_0x16bd83){_0x1b7116=_(_0x1b7116)[_0x1a8b('0x77')](_0x16bd83)[_0x1a8b('0x78')]()[_0x1a8b('0x79')]();return db['SmsQueue'][_0x1a8b('0x4a')]({'where':{'id':_0x45c8ca['params']['id']}})['then'](function(_0x41e06c){return db[_0x1a8b('0x69')][_0x1a8b('0x7a')](function(_0x696a6f){return _0x41e06c['removeTeams'](_0x45c8ca[_0x1a8b('0x35')]['ids'],{'transaction':_0x696a6f})[_0x1a8b('0x27')](function(){if(!_[_0x1a8b('0x7b')](_0x1b7116)){return _0x41e06c[_0x1a8b('0x7c')](_0x1b7116,{'transaction':_0x696a6f});}})[_0x1a8b('0x27')](function(){_0x1b7116[_0x1a8b('0x7d')](function(_0x524f37){socket[_0x1a8b('0x6c')](_0x1a8b('0x7e'),{'UserId':_0x524f37,'SmsQueueId':_0x41e06c['id']});});});});});});})[_0x1a8b('0x27')](respondWithStatusCode(_0x36e109,null))[_0x1a8b('0x47')](handleError(_0x36e109,null));};exports[_0x1a8b('0x7f')]=function(_0x1ad583,_0x44c580,_0x55e96f){return db[_0x1a8b('0x31')][_0x1a8b('0x4a')]({'where':{'id':_0x1ad583[_0x1a8b('0x49')]['id']}})[_0x1a8b('0x27')](handleEntityNotFound(_0x44c580,null))['then'](function(_0x2d0a85){if(_0x2d0a85){return _0x2d0a85[_0x1a8b('0x7f')](_0x1ad583[_0x1a8b('0x4c')][_0x1a8b('0x65')],_['omit'](_0x1ad583[_0x1a8b('0x4c')],[_0x1a8b('0x65'),'id'])||{})[_0x1a8b('0x80')](function(_0x5afab2){for(var _0x252f48=0x0;_0x252f48<_0x1ad583[_0x1a8b('0x4c')][_0x1a8b('0x65')][_0x1a8b('0x55')];_0x252f48+=0x1){socket[_0x1a8b('0x6c')](_0x1a8b('0x81'),{'UserId':Number(_0x1ad583[_0x1a8b('0x4c')][_0x1a8b('0x65')][_0x252f48]),'SmsQueueId':Number(_0x1ad583[_0x1a8b('0x49')]['id'])});}return _0x5afab2;});}})[_0x1a8b('0x27')](respondWithResult(_0x44c580,null))['catch'](handleError(_0x44c580,null));};exports['removeAgents']=function(_0x10da35,_0x5c9e7a,_0x321d62){return db['SmsQueue'][_0x1a8b('0x4a')]({'where':{'id':_0x10da35[_0x1a8b('0x49')]['id']}})[_0x1a8b('0x27')](handleEntityNotFound(_0x5c9e7a,null))['then'](function(_0x45d178){if(_0x45d178){return _0x45d178['removeAgents'](_0x10da35['query'][_0x1a8b('0x65')])[_0x1a8b('0x27')](function(){if(_[_0x1a8b('0x82')](_0x10da35[_0x1a8b('0x35')][_0x1a8b('0x65')])){for(var _0x5a53c1=0x0;_0x5a53c1<_0x10da35['query'][_0x1a8b('0x65')][_0x1a8b('0x55')];_0x5a53c1+=0x1){socket[_0x1a8b('0x6c')]('userSmsQueue:remove',{'UserId':Number(_0x10da35[_0x1a8b('0x35')][_0x1a8b('0x65')][_0x5a53c1]),'SmsQueueId':Number(_0x10da35[_0x1a8b('0x49')]['id'])});}}else{socket[_0x1a8b('0x6c')]('userSmsQueue:remove',{'UserId':Number(_0x10da35[_0x1a8b('0x35')][_0x1a8b('0x65')]),'SmsQueueId':Number(_0x10da35[_0x1a8b('0x49')]['id'])});}});}})[_0x1a8b('0x27')](respondWithStatusCode(_0x5c9e7a,null))[_0x1a8b('0x47')](handleError(_0x5c9e7a,null));};exports['getAgents']=function(_0x402e78,_0x393eb0,_0x28d58d){var _0x58c202={};var _0x1588fb={};var _0x539082;var _0xa77645;return db[_0x1a8b('0x31')]['findOne']({'where':{'id':_0x402e78[_0x1a8b('0x49')]['id']}})[_0x1a8b('0x27')](handleEntityNotFound(_0x393eb0,null))[_0x1a8b('0x27')](function(_0x347cf1){if(_0x347cf1){_0x539082=_0x347cf1;_0x1588fb[_0x1a8b('0x39')]=_[_0x1a8b('0x36')](db['User']['rawAttributes']);_0x1588fb[_0x1a8b('0x35')]=_[_0x1a8b('0x36')](_0x402e78[_0x1a8b('0x35')]);_0x1588fb[_0x1a8b('0x37')]=_[_0x1a8b('0x38')](_0x1588fb['model'],_0x1588fb[_0x1a8b('0x35')]);_0x58c202['attributes']=_[_0x1a8b('0x38')](_0x1588fb[_0x1a8b('0x39')],qs[_0x1a8b('0x3a')](_0x402e78[_0x1a8b('0x35')][_0x1a8b('0x3a')]));_0x58c202[_0x1a8b('0x3b')]=_0x58c202[_0x1a8b('0x3b')][_0x1a8b('0x55')]?_0x58c202[_0x1a8b('0x3b')]:_0x1588fb[_0x1a8b('0x39')];_0x58c202[_0x1a8b('0x57')]=qs[_0x1a8b('0x3d')](_0x402e78[_0x1a8b('0x35')][_0x1a8b('0x3d')]);_0x58c202[_0x1a8b('0x3e')]=qs[_0x1a8b('0x37')](_[_0x1a8b('0x58')](_0x402e78[_0x1a8b('0x35')],_0x1588fb[_0x1a8b('0x37')]));if(_0x402e78[_0x1a8b('0x35')][_0x1a8b('0x42')]){_0x58c202[_0x1a8b('0x3e')]=_[_0x1a8b('0x3f')](_0x58c202[_0x1a8b('0x3e')],{'$or':_[_0x1a8b('0x30')](_0x58c202[_0x1a8b('0x3b')],function(_0x2f0f82){var _0x4f6064={};_0x4f6064[_0x2f0f82]={'$like':'%'+_0x402e78[_0x1a8b('0x35')][_0x1a8b('0x42')]+'%'};return _0x4f6064;})});}_0x58c202=_[_0x1a8b('0x3f')]({},_0x58c202,_0x402e78[_0x1a8b('0x43')]);return _0x539082[_0x1a8b('0x83')](_0x58c202);}})[_0x1a8b('0x27')](function(_0x17d59c){if(_0x17d59c){_0xa77645=_0x17d59c['length'];if(!_0x402e78[_0x1a8b('0x35')][_0x1a8b('0x56')](_0x1a8b('0x3c'))){_0x58c202['limit']=qs[_0x1a8b('0x20')](_0x402e78[_0x1a8b('0x35')][_0x1a8b('0x20')]);_0x58c202[_0x1a8b('0x1e')]=qs[_0x1a8b('0x1e')](_0x402e78[_0x1a8b('0x35')][_0x1a8b('0x1e')]);}return _0x539082['getAgents'](_0x58c202);}})[_0x1a8b('0x27')](function(_0xeec598){if(_0xeec598){return _0xeec598?{'count':_0xa77645,'rows':_0xeec598}:null;}})[_0x1a8b('0x27')](respondWithResult(_0x393eb0,null))[_0x1a8b('0x47')](handleError(_0x393eb0,null));};
\ No newline at end of file