Built motion from commit (unavailable).|2.5.14
[motion2.git] / server / api / smsQueue / smsQueue.controller.js
index 09b3dc8..7871fc0 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 _0x1db9=['hasOwnProperty','order','sort','where','filters','pick','filter','merge','VIRTUAL','options','count','includeAll','include','SmsQueue','findAll','catch','show','params','keys','length','find','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','autoAssociation','update','describe','getMembers','findOne','UserSmsQueue','nolimit','SmsQueueId','User','findAndCountAll','UserId','agent','smsPause','updatedAt','createdAt','rows','format','SIP','getTeams','Team','addTeams','ids','online','voicePause','interface','flatMap','Agents','sequelize','transaction','forEach','emit','removeTeams','select','field','tq.TeamId','from','team_has_sms_queues','user_has_teams','SmsQueueId\x20=\x20?','clone','ut.UserId\x20=\x20?','push','toString','QueryTypes','SELECT','every','TeamId','includes','all','union','compact','value','isEmpty','removeAgents','userSmsQueue:remove','addAgents','omit','spread','userSmsQueue:save','isArray','getAgents','html-pdf','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','bluebird','mustache','sox','lodash','squel','crypto','jsforce','desk.js','querystring','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/environment','../../config/license/util','defaults','redis','localhost','socket.io-emitter','register','sendStatus','status','end','json','offset','limit','set','apply','reject','save','destroy','then','get','UserProfileResource','error','stack','name','send','index','map','rawAttributes','fieldName','type','key','query','intersection','model','attributes','fields'];(function(_0x2aa669,_0x5ce9d7){var _0x5dbeb8=function(_0x2a7a8b){while(--_0x2a7a8b){_0x2aa669['push'](_0x2aa669['shift']());}};_0x5dbeb8(++_0x5ce9d7);}(_0x1db9,0x176));var _0x91db=function(_0x1ef205,_0x1d6c4e){_0x1ef205=_0x1ef205-0x0;var _0x5431f0=_0x1db9[_0x1ef205];return _0x5431f0;};'use strict';var pdf=require(_0x91db('0x0'));var emlformat=require(_0x91db('0x1'));var rimraf=require(_0x91db('0x2'));var zipdir=require(_0x91db('0x3'));var jsonpatch=require(_0x91db('0x4'));var rp=require(_0x91db('0x5'));var moment=require('moment');var BPromise=require(_0x91db('0x6'));var Mustache=require(_0x91db('0x7'));var util=require('util');var path=require('path');var sox=require(_0x91db('0x8'));var csv=require('to-csv');var ejs=require('ejs');var fs=require('fs');var _=require(_0x91db('0x9'));var squel=require(_0x91db('0xa'));var crypto=require(_0x91db('0xb'));var jsforce=require(_0x91db('0xc'));var deskjs=require(_0x91db('0xd'));var toCsv=require('to-csv');var querystring=require(_0x91db('0xe'));var Papa=require('papaparse');var Redis=require(_0x91db('0xf'));var authService=require(_0x91db('0x10'));var qs=require(_0x91db('0x11'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x91db('0x12'));var logger=require('../../config/logger')('api');var utils=require('../../config/utils');var config=require(_0x91db('0x13'));var licenseUtil=require(_0x91db('0x14'));var db=require('../../mysqldb')['db'];config['redis']=_[_0x91db('0x15')](config[_0x91db('0x16')],{'host':_0x91db('0x17'),'port':0x18eb});var socket=require(_0x91db('0x18'))(new Redis(config[_0x91db('0x16')]));require('./smsQueue.socket')[_0x91db('0x19')](socket);function respondWithStatusCode(_0x285052,_0x3cadc4){_0x3cadc4=_0x3cadc4||0xcc;return function(_0x4035b2){if(_0x4035b2){return _0x285052[_0x91db('0x1a')](_0x3cadc4);}return _0x285052[_0x91db('0x1b')](_0x3cadc4)[_0x91db('0x1c')]();};}function respondWithResult(_0x143bc4,_0x675bd){_0x675bd=_0x675bd||0xc8;return function(_0x26d10c){if(_0x26d10c){return _0x143bc4[_0x91db('0x1b')](_0x675bd)[_0x91db('0x1d')](_0x26d10c);}};}function respondWithFilteredResult(_0x5f5440,_0x3f744f){return function(_0x23d125){if(_0x23d125){var _0x39480f=_0x23d125['count'],_0x42e66c=_0x3f744f['offset'],_0xeb51b0=_0x3f744f[_0x91db('0x1e')]+_0x3f744f[_0x91db('0x1f')],_0x306e92;if(_0xeb51b0>=_0x39480f){_0xeb51b0=_0x39480f;_0x306e92=0xc8;}else{_0x306e92=0xce;}_0x5f5440[_0x91db('0x1b')](_0x306e92);return _0x5f5440[_0x91db('0x20')]('Content-Range',_0x42e66c+'-'+_0xeb51b0+'/'+_0x39480f)[_0x91db('0x1d')](_0x23d125);}return null;};}function patchUpdates(_0x324de7){return function(_0x6e3ca6){try{jsonpatch[_0x91db('0x21')](_0x6e3ca6,_0x324de7,!![]);}catch(_0x25593c){return BPromise[_0x91db('0x22')](_0x25593c);}return _0x6e3ca6[_0x91db('0x23')]();};}function saveUpdates(_0x8e323f,_0xdb48b8){return function(_0x31295f){if(_0x31295f){return _0x31295f['update'](_0x8e323f)['then'](function(_0x134caa){return _0x134caa;});}return null;};}function removeEntity(_0x2ac8d5,_0x50687e){return function(_0xc82085){if(_0xc82085){return _0xc82085[_0x91db('0x24')]()[_0x91db('0x25')](function(){var _0x6e3a9c=_0xc82085[_0x91db('0x26')]({'plain':!![]});var _0x4e2a8f='SmsQueues';return db[_0x91db('0x27')][_0x91db('0x24')]({'where':{'type':_0x4e2a8f,'resourceId':_0x6e3a9c['id']}})[_0x91db('0x25')](function(){return _0xc82085;});})['then'](function(){_0x2ac8d5[_0x91db('0x1b')](0xcc)[_0x91db('0x1c')]();});}};}function handleEntityNotFound(_0x46c0e8,_0x1bb4f8){return function(_0x512c79){if(!_0x512c79){_0x46c0e8[_0x91db('0x1a')](0x194);}return _0x512c79;};}function handleError(_0x2a00d1,_0x1805ef){_0x1805ef=_0x1805ef||0x1f4;return function(_0x49c504){logger[_0x91db('0x28')](_0x49c504[_0x91db('0x29')]);if(_0x49c504[_0x91db('0x2a')]){delete _0x49c504[_0x91db('0x2a')];}_0x2a00d1[_0x91db('0x1b')](_0x1805ef)[_0x91db('0x2b')](_0x49c504);};}exports[_0x91db('0x2c')]=function(_0x1b5a7b,_0x330a9a){var _0x1b27f9={},_0x1946ae={},_0x5b24b2={'count':0x0,'rows':[]};var _0xbef598=_[_0x91db('0x2d')](db['SmsQueue'][_0x91db('0x2e')],function(_0x1368b9){return{'name':_0x1368b9[_0x91db('0x2f')],'type':_0x1368b9[_0x91db('0x30')][_0x91db('0x31')]};});_0x1946ae['model']=_[_0x91db('0x2d')](_0xbef598,_0x91db('0x2a'));_0x1946ae[_0x91db('0x32')]=_['keys'](_0x1b5a7b[_0x91db('0x32')]);_0x1946ae['filters']=_[_0x91db('0x33')](_0x1946ae[_0x91db('0x34')],_0x1946ae[_0x91db('0x32')]);_0x1b27f9[_0x91db('0x35')]=_['intersection'](_0x1946ae[_0x91db('0x34')],qs[_0x91db('0x36')](_0x1b5a7b[_0x91db('0x32')]['fields']));_0x1b27f9[_0x91db('0x35')]=_0x1b27f9[_0x91db('0x35')]['length']?_0x1b27f9[_0x91db('0x35')]:_0x1946ae[_0x91db('0x34')];if(!_0x1b5a7b['query'][_0x91db('0x37')]('nolimit')){_0x1b27f9[_0x91db('0x1f')]=qs[_0x91db('0x1f')](_0x1b5a7b['query']['limit']);_0x1b27f9['offset']=qs[_0x91db('0x1e')](_0x1b5a7b[_0x91db('0x32')]['offset']);}_0x1b27f9[_0x91db('0x38')]=qs[_0x91db('0x39')](_0x1b5a7b[_0x91db('0x32')][_0x91db('0x39')]);_0x1b27f9[_0x91db('0x3a')]=qs[_0x91db('0x3b')](_[_0x91db('0x3c')](_0x1b5a7b[_0x91db('0x32')],_0x1946ae[_0x91db('0x3b')]),_0xbef598);if(_0x1b5a7b[_0x91db('0x32')][_0x91db('0x3d')]){_0x1b27f9['where']=_[_0x91db('0x3e')](_0x1b27f9['where'],{'$or':_[_0x91db('0x2d')](_0xbef598,function(_0xd42afe){if(_0xd42afe['type']!==_0x91db('0x3f')){var _0x191cf0={};_0x191cf0[_0xd42afe[_0x91db('0x2a')]]={'$like':'%'+_0x1b5a7b[_0x91db('0x32')][_0x91db('0x3d')]+'%'};return _0x191cf0;}})});}_0x1b27f9=_['merge']({},_0x1b27f9,_0x1b5a7b[_0x91db('0x40')]);var _0x3f6091={'where':_0x1b27f9[_0x91db('0x3a')]};return db['SmsQueue'][_0x91db('0x41')](_0x3f6091)[_0x91db('0x25')](function(_0x3aaf2e){_0x5b24b2['count']=_0x3aaf2e;if(_0x1b5a7b[_0x91db('0x32')][_0x91db('0x42')]){_0x1b27f9[_0x91db('0x43')]=[{'all':!![]}];}return db[_0x91db('0x44')][_0x91db('0x45')](_0x1b27f9);})['then'](function(_0x4dcdad){_0x5b24b2['rows']=_0x4dcdad;return _0x5b24b2;})[_0x91db('0x25')](respondWithFilteredResult(_0x330a9a,_0x1b27f9))[_0x91db('0x46')](handleError(_0x330a9a,null));};exports[_0x91db('0x47')]=function(_0x3e07fc,_0x46c92a){var _0x2fcf33={'raw':!![],'where':{'id':_0x3e07fc[_0x91db('0x48')]['id']}},_0x2b1fef={};_0x2b1fef[_0x91db('0x34')]=_[_0x91db('0x49')](db[_0x91db('0x44')]['rawAttributes']);_0x2b1fef['query']=_[_0x91db('0x49')](_0x3e07fc[_0x91db('0x32')]);_0x2b1fef[_0x91db('0x3b')]=_['intersection'](_0x2b1fef[_0x91db('0x34')],_0x2b1fef[_0x91db('0x32')]);_0x2fcf33[_0x91db('0x35')]=_[_0x91db('0x33')](_0x2b1fef[_0x91db('0x34')],qs['fields'](_0x3e07fc[_0x91db('0x32')]['fields']));_0x2fcf33[_0x91db('0x35')]=_0x2fcf33[_0x91db('0x35')][_0x91db('0x4a')]?_0x2fcf33[_0x91db('0x35')]:_0x2b1fef[_0x91db('0x34')];if(_0x3e07fc[_0x91db('0x32')][_0x91db('0x42')]){_0x2fcf33[_0x91db('0x43')]=[{'all':!![]}];}_0x2fcf33=_[_0x91db('0x3e')]({},_0x2fcf33,_0x3e07fc['options']);return db['SmsQueue'][_0x91db('0x4b')](_0x2fcf33)[_0x91db('0x25')](handleEntityNotFound(_0x46c92a,null))[_0x91db('0x25')](respondWithResult(_0x46c92a,null))[_0x91db('0x46')](handleError(_0x46c92a,null));};exports[_0x91db('0x4c')]=function(_0x4a3e44,_0x272657){return db[_0x91db('0x44')][_0x91db('0x4c')](_0x4a3e44[_0x91db('0x4d')],{})[_0x91db('0x25')](function(_0x51a75b){var _0xf90032=_0x4a3e44[_0x91db('0x4e')][_0x91db('0x26')]({'plain':!![]});if(!_0xf90032)throw new Error(_0x91db('0x4f'));if(_0xf90032[_0x91db('0x50')]===_0x91db('0x4e')){var _0x59003f=_0x51a75b['get']({'plain':!![]});var _0x132fb5='SmsQueues';return db[_0x91db('0x51')]['find']({'where':{'name':_0x132fb5,'userProfileId':_0xf90032['userProfileId']},'raw':!![]})[_0x91db('0x25')](function(_0x371277){if(_0x371277&&_0x371277[_0x91db('0x52')]===0x0){return db['UserProfileResource'][_0x91db('0x4c')]({'name':_0x59003f[_0x91db('0x2a')],'resourceId':_0x59003f['id'],'type':_0x371277[_0x91db('0x2a')],'sectionId':_0x371277['id']},{})['then'](function(){return _0x51a75b;});}else{return _0x51a75b;}})['catch'](function(_0x173d3e){logger[_0x91db('0x28')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x173d3e);throw _0x173d3e;});}return _0x51a75b;})[_0x91db('0x25')](respondWithResult(_0x272657,0xc9))['catch'](handleError(_0x272657,null));};exports[_0x91db('0x53')]=function(_0x239965,_0x24fa52){if(_0x239965[_0x91db('0x4d')]['id']){delete _0x239965['body']['id'];}return db[_0x91db('0x44')][_0x91db('0x4b')]({'where':{'id':_0x239965[_0x91db('0x48')]['id']}})[_0x91db('0x25')](handleEntityNotFound(_0x24fa52,null))[_0x91db('0x25')](saveUpdates(_0x239965[_0x91db('0x4d')],null))[_0x91db('0x25')](respondWithResult(_0x24fa52,null))[_0x91db('0x46')](handleError(_0x24fa52,null));};exports[_0x91db('0x24')]=function(_0x3e2e43,_0x5b127d){return db[_0x91db('0x44')][_0x91db('0x4b')]({'where':{'id':_0x3e2e43[_0x91db('0x48')]['id']}})[_0x91db('0x25')](handleEntityNotFound(_0x5b127d,null))[_0x91db('0x25')](removeEntity(_0x5b127d,null))['catch'](handleError(_0x5b127d,null));};exports[_0x91db('0x54')]=function(_0x5a90e2,_0x1a22dd){return db[_0x91db('0x44')]['describe']()['then'](respondWithResult(_0x1a22dd,null))[_0x91db('0x46')](handleError(_0x1a22dd,null));};exports[_0x91db('0x55')]=function(_0xf48f2,_0x51324a,_0x14a150){var _0x99ee11={'raw':!![],'where':{}},_0x1fb402={},_0x304c93;return db[_0x91db('0x44')][_0x91db('0x56')]({'where':{'id':_0xf48f2['params']['id']}})[_0x91db('0x25')](handleEntityNotFound(_0x51324a,null))[_0x91db('0x25')](function(_0x335b44){if(_0x335b44){_0x304c93=_0x335b44[_0x91db('0x26')]({'plain':!![]});_0x1fb402[_0x91db('0x34')]=_[_0x91db('0x49')](db[_0x91db('0x57')][_0x91db('0x2e')]);_0x1fb402[_0x91db('0x32')]=_[_0x91db('0x49')](_0xf48f2[_0x91db('0x32')]);_0x1fb402['filters']=_[_0x91db('0x33')](_0x1fb402[_0x91db('0x34')],_0x1fb402['query']);_0x99ee11['attributes']=_[_0x91db('0x33')](_0x1fb402[_0x91db('0x34')],qs['fields'](_0xf48f2['query'][_0x91db('0x36')]));_0x99ee11[_0x91db('0x35')]=_0x99ee11['attributes'][_0x91db('0x4a')]?_0x99ee11[_0x91db('0x35')]:_0x1fb402[_0x91db('0x34')];if(!_0xf48f2['query'][_0x91db('0x37')](_0x91db('0x58'))){_0x99ee11['limit']=qs['limit'](_0xf48f2[_0x91db('0x32')]['limit']);_0x99ee11[_0x91db('0x1e')]=qs[_0x91db('0x1e')](_0xf48f2[_0x91db('0x32')][_0x91db('0x1e')]);}_0x99ee11[_0x91db('0x38')]=qs[_0x91db('0x39')](_0xf48f2[_0x91db('0x32')]['sort']);_0x99ee11[_0x91db('0x3a')]=qs[_0x91db('0x3b')](_['pick'](_0xf48f2['query'],_0x1fb402[_0x91db('0x3b')]));_0x99ee11[_0x91db('0x3a')][_0x91db('0x59')]=_0x335b44['id'];if(_0xf48f2[_0x91db('0x32')]['filter']){_0x99ee11[_0x91db('0x3a')]=_[_0x91db('0x3e')](_0x99ee11['where'],{'$or':_[_0x91db('0x2d')](_0x99ee11[_0x91db('0x35')],function(_0x2880fe){var _0x36c1eb={};_0x36c1eb[_0x2880fe]={'$like':'%'+_0xf48f2['query'][_0x91db('0x3d')]+'%'};return _0x36c1eb;})});}_0x99ee11=_[_0x91db('0x3e')]({},_0x99ee11,_0xf48f2[_0x91db('0x40')]);return db['UserSmsQueue'][_0x91db('0x45')](_0x99ee11);}})[_0x91db('0x25')](function(_0x4c6127){if(_0x4c6127){return db[_0x91db('0x5a')][_0x91db('0x5b')]({'where':{'id':_[_0x91db('0x2d')](_0x4c6127,_0x91db('0x5c')),'role':_0x91db('0x5d')},'attributes':['id','name',_0x91db('0x5e'),_0x91db('0x5f'),_0x91db('0x60')]});}})['then'](function(_0x58e92a){if(_0x58e92a){return{'count':_0x58e92a[_0x91db('0x41')],'rows':_[_0x91db('0x2d')](_0x58e92a[_0x91db('0x61')],function(_0x3d3b26){return{'membername':_0x3d3b26[_0x91db('0x2a')],'UserId':_0x3d3b26['id'],'queue_name':_0x304c93[_0x91db('0x2a')],'SmsQueueId':_0x304c93['id'],'interface':util[_0x91db('0x62')]('%s/%s',_0x91db('0x63'),_0x3d3b26[_0x91db('0x2a')]),'penalty':0x0,'paused':_0x3d3b26[_0x91db('0x5e')],'createdAt':_0x3d3b26['createdAt'],'updatedAt':_0x3d3b26['updatedAt']};})};}else{return{'count':0x0,'rows':[]};}})[_0x91db('0x25')](respondWithFilteredResult(_0x51324a,_0x99ee11))[_0x91db('0x46')](handleError(_0x51324a,null));};exports[_0x91db('0x64')]=function(_0x5a531c,_0x45ca9c,_0x44c924){var _0x3438a4={};var _0x7fe080={};var _0x1e1777;var _0x71e82a;return db[_0x91db('0x44')][_0x91db('0x56')]({'where':{'id':_0x5a531c['params']['id']}})[_0x91db('0x25')](handleEntityNotFound(_0x45ca9c,null))[_0x91db('0x25')](function(_0x1965a0){if(_0x1965a0){_0x1e1777=_0x1965a0;_0x7fe080[_0x91db('0x34')]=_['keys'](db[_0x91db('0x65')]['rawAttributes']);_0x7fe080[_0x91db('0x32')]=_[_0x91db('0x49')](_0x5a531c[_0x91db('0x32')]);_0x7fe080[_0x91db('0x3b')]=_[_0x91db('0x33')](_0x7fe080[_0x91db('0x34')],_0x7fe080['query']);_0x3438a4[_0x91db('0x35')]=_['intersection'](_0x7fe080[_0x91db('0x34')],qs['fields'](_0x5a531c[_0x91db('0x32')][_0x91db('0x36')]));_0x3438a4[_0x91db('0x35')]=_0x3438a4['attributes'][_0x91db('0x4a')]?_0x3438a4[_0x91db('0x35')]:_0x7fe080[_0x91db('0x34')];_0x3438a4[_0x91db('0x38')]=qs[_0x91db('0x39')](_0x5a531c[_0x91db('0x32')][_0x91db('0x39')]);_0x3438a4[_0x91db('0x3a')]=qs[_0x91db('0x3b')](_[_0x91db('0x3c')](_0x5a531c['query'],_0x7fe080[_0x91db('0x3b')]));if(_0x5a531c[_0x91db('0x32')][_0x91db('0x3d')]){_0x3438a4[_0x91db('0x3a')]=_[_0x91db('0x3e')](_0x3438a4['where'],{'$or':_[_0x91db('0x2d')](_0x3438a4[_0x91db('0x35')],function(_0x44209f){var _0x358115={};_0x358115[_0x44209f]={'$like':'%'+_0x5a531c[_0x91db('0x32')][_0x91db('0x3d')]+'%'};return _0x358115;})});}_0x3438a4=_[_0x91db('0x3e')]({},_0x3438a4,_0x5a531c[_0x91db('0x40')]);return _0x1e1777[_0x91db('0x64')](_0x3438a4);}})[_0x91db('0x25')](function(_0x5bc49f){if(_0x5bc49f){_0x71e82a=_0x5bc49f['length'];if(!_0x5a531c[_0x91db('0x32')][_0x91db('0x37')](_0x91db('0x58'))){_0x3438a4['limit']=qs[_0x91db('0x1f')](_0x5a531c[_0x91db('0x32')][_0x91db('0x1f')]);_0x3438a4[_0x91db('0x1e')]=qs['offset'](_0x5a531c['query']['offset']);}return _0x1e1777[_0x91db('0x64')](_0x3438a4);}})['then'](function(_0x150228){if(_0x150228){return _0x150228?{'count':_0x71e82a,'rows':_0x150228}:null;}})[_0x91db('0x25')](respondWithResult(_0x45ca9c,null))[_0x91db('0x46')](handleError(_0x45ca9c,null));};exports[_0x91db('0x66')]=function(_0x4de3b0,_0x34df43,_0x1f7556){var _0x4b34e6=_0x4de3b0[_0x91db('0x4d')][_0x91db('0x67')];return db[_0x91db('0x65')][_0x91db('0x45')]({'where':{'id':_0x4b34e6},'attributes':['id'],'include':[{'model':db[_0x91db('0x5a')],'as':'Agents','attributes':['id',_0x91db('0x2a'),_0x91db('0x68'),_0x91db('0x69'),_0x91db('0x6a')],'raw':!![]}]})[_0x91db('0x25')](function(_0x2006a3){if(_0x2006a3){var _0x469ebd=_[_0x91db('0x6b')](_0x2006a3,function(_0xa24121){var _0x2163ac=_0xa24121[_0x91db('0x26')]({'plain':!![]});return _0x2163ac[_0x91db('0x6c')];});return db[_0x91db('0x44')][_0x91db('0x4b')]({'where':{'id':_0x4de3b0['params']['id']}})[_0x91db('0x25')](function(_0x5b9fdd){return db[_0x91db('0x6d')][_0x91db('0x6e')](function(_0x290d07){return _0x5b9fdd[_0x91db('0x66')](_0x4b34e6,{'transaction':_0x290d07})[_0x91db('0x25')](function(){return BPromise['each'](_0x469ebd,function(_0x3730ab){return db['UserSmsQueue']['findOrCreate']({'where':{'UserId':_0x3730ab['id'],'SmsQueueId':_0x4de3b0[_0x91db('0x48')]['id']},'transaction':_0x290d07});});})[_0x91db('0x25')](function(){_0x469ebd[_0x91db('0x6f')](function(_0x134a9e){socket[_0x91db('0x70')]('userSmsQueue:save',{'UserId':_0x134a9e['id'],'SmsQueueId':_0x5b9fdd['id']});});});});});}})[_0x91db('0x25')](respondWithStatusCode(_0x34df43,null))['catch'](handleError(_0x34df43,null));};exports[_0x91db('0x71')]=function(_0x1baa7c,_0x12346b,_0x3b1dd6){return db['Team'][_0x91db('0x45')]({'where':{'id':_0x1baa7c['query'][_0x91db('0x67')]},'attributes':['id'],'include':[{'model':db['User'],'as':_0x91db('0x6c'),'attributes':['id'],'raw':!![]}]})[_0x91db('0x25')](handleEntityNotFound(_0x12346b,null))['then'](function(_0x20b84f){var _0x41899c=_['map'](_0x20b84f,'id');var _0x577a8b=[];var _0xe49ae8=[];var _0x10f4bb=squel[_0x91db('0x72')]();_0x10f4bb[_0x91db('0x73')](_0x91db('0x74'))[_0x91db('0x75')](_0x91db('0x76'),'tq')['join'](_0x91db('0x77'),'ut','ut.TeamId\x20=\x20tq.TeamId')[_0x91db('0x3a')](_0x91db('0x78'),_0x1baa7c[_0x91db('0x48')]['id']);for(var _0x4b2af0=0x0;_0x4b2af0<_0x20b84f[_0x91db('0x4a')];_0x4b2af0+=0x1){let _0x26a0cd=_0x20b84f[_0x4b2af0];for(var _0xdf9a32=0x0;_0xdf9a32<_0x26a0cd['Agents'][_0x91db('0x4a')];_0xdf9a32+=0x1){let _0x57764c=_0x26a0cd[_0x91db('0x6c')][_0xdf9a32];var _0x55c5c9=_0x10f4bb[_0x91db('0x79')]();_0x55c5c9[_0x91db('0x3a')](_0x91db('0x7a'),_0x57764c['id']);_0xe49ae8[_0x91db('0x7b')](db[_0x91db('0x6d')]['query'](_0x55c5c9[_0x91db('0x7c')](),{'type':db[_0x91db('0x6d')][_0x91db('0x7d')][_0x91db('0x7e')]})[_0x91db('0x25')](function(_0x40f719){if(_0x40f719['length']===0x1){return _0x57764c['id'];}else{var _0x134080=_[_0x91db('0x7f')](_[_0x91db('0x2d')](_0x40f719,_0x91db('0x80')),function(_0x2e5ea9){return _[_0x91db('0x81')](_0x41899c,_0x2e5ea9);});if(_0x134080){return _0x57764c['id'];}}}));}}return BPromise[_0x91db('0x82')](_0xe49ae8)[_0x91db('0x25')](function(_0x184b95){_0x577a8b=_(_0x577a8b)[_0x91db('0x83')](_0x184b95)[_0x91db('0x84')]()[_0x91db('0x85')]();return db[_0x91db('0x44')]['find']({'where':{'id':_0x1baa7c[_0x91db('0x48')]['id']}})[_0x91db('0x25')](function(_0x1fa857){return db[_0x91db('0x6d')][_0x91db('0x6e')](function(_0x588787){return _0x1fa857[_0x91db('0x71')](_0x1baa7c['query']['ids'],{'transaction':_0x588787})[_0x91db('0x25')](function(){if(!_[_0x91db('0x86')](_0x577a8b)){return _0x1fa857[_0x91db('0x87')](_0x577a8b,{'transaction':_0x588787});}})[_0x91db('0x25')](function(){_0x577a8b[_0x91db('0x6f')](function(_0x2073a6){socket[_0x91db('0x70')](_0x91db('0x88'),{'UserId':_0x2073a6,'SmsQueueId':_0x1fa857['id']});});});});});});})[_0x91db('0x25')](respondWithStatusCode(_0x12346b,null))[_0x91db('0x46')](handleError(_0x12346b,null));};exports[_0x91db('0x89')]=function(_0x2adc4c,_0x48f571,_0x21874d){return db[_0x91db('0x44')][_0x91db('0x4b')]({'where':{'id':_0x2adc4c[_0x91db('0x48')]['id']}})['then'](handleEntityNotFound(_0x48f571,null))[_0x91db('0x25')](function(_0x3005c6){if(_0x3005c6){return _0x3005c6[_0x91db('0x89')](_0x2adc4c[_0x91db('0x4d')][_0x91db('0x67')],_[_0x91db('0x8a')](_0x2adc4c['body'],[_0x91db('0x67'),'id'])||{})[_0x91db('0x8b')](function(_0x11d8d4){for(var _0x18b099=0x0;_0x18b099<_0x2adc4c[_0x91db('0x4d')][_0x91db('0x67')][_0x91db('0x4a')];_0x18b099+=0x1){socket[_0x91db('0x70')](_0x91db('0x8c'),{'UserId':_0x2adc4c['body'][_0x91db('0x67')][_0x18b099],'SmsQueueId':_0x2adc4c[_0x91db('0x48')]['id']});}return _0x11d8d4;});}})[_0x91db('0x25')](respondWithResult(_0x48f571,null))[_0x91db('0x46')](handleError(_0x48f571,null));};exports[_0x91db('0x87')]=function(_0x4e090b,_0x58c5ce,_0x30d3bb){return db[_0x91db('0x44')][_0x91db('0x4b')]({'where':{'id':_0x4e090b['params']['id']}})[_0x91db('0x25')](handleEntityNotFound(_0x58c5ce,null))[_0x91db('0x25')](function(_0x2ea4b1){if(_0x2ea4b1){return _0x2ea4b1[_0x91db('0x87')](_0x4e090b[_0x91db('0x32')][_0x91db('0x67')])[_0x91db('0x25')](function(){if(_[_0x91db('0x8d')](_0x4e090b[_0x91db('0x32')]['ids'])){for(var _0x51f73a=0x0;_0x51f73a<_0x4e090b[_0x91db('0x32')][_0x91db('0x67')]['length'];_0x51f73a+=0x1){socket[_0x91db('0x70')](_0x91db('0x88'),{'UserId':Number(_0x4e090b[_0x91db('0x32')][_0x91db('0x67')][_0x51f73a]),'SmsQueueId':Number(_0x4e090b['params']['id'])});}}else{socket[_0x91db('0x70')](_0x91db('0x88'),{'UserId':Number(_0x4e090b['query'][_0x91db('0x67')]),'SmsQueueId':Number(_0x4e090b[_0x91db('0x48')]['id'])});}});}})[_0x91db('0x25')](respondWithStatusCode(_0x58c5ce,null))[_0x91db('0x46')](handleError(_0x58c5ce,null));};exports[_0x91db('0x8e')]=function(_0x160b2d,_0x34d701,_0x1d6294){var _0x17aa95={};var _0x5eb2be={};var _0x440a9f;var _0x4978d9;return db['SmsQueue'][_0x91db('0x56')]({'where':{'id':_0x160b2d['params']['id']}})[_0x91db('0x25')](handleEntityNotFound(_0x34d701,null))[_0x91db('0x25')](function(_0x1c21b6){if(_0x1c21b6){_0x440a9f=_0x1c21b6;_0x5eb2be[_0x91db('0x34')]=_[_0x91db('0x49')](db[_0x91db('0x5a')]['rawAttributes']);_0x5eb2be[_0x91db('0x32')]=_['keys'](_0x160b2d[_0x91db('0x32')]);_0x5eb2be[_0x91db('0x3b')]=_[_0x91db('0x33')](_0x5eb2be['model'],_0x5eb2be['query']);_0x17aa95[_0x91db('0x35')]=_[_0x91db('0x33')](_0x5eb2be[_0x91db('0x34')],qs['fields'](_0x160b2d[_0x91db('0x32')][_0x91db('0x36')]));_0x17aa95[_0x91db('0x35')]=_0x17aa95['attributes'][_0x91db('0x4a')]?_0x17aa95[_0x91db('0x35')]:_0x5eb2be[_0x91db('0x34')];_0x17aa95[_0x91db('0x38')]=qs[_0x91db('0x39')](_0x160b2d[_0x91db('0x32')][_0x91db('0x39')]);_0x17aa95[_0x91db('0x3a')]=qs[_0x91db('0x3b')](_[_0x91db('0x3c')](_0x160b2d[_0x91db('0x32')],_0x5eb2be[_0x91db('0x3b')]));if(_0x160b2d[_0x91db('0x32')][_0x91db('0x3d')]){_0x17aa95[_0x91db('0x3a')]=_['merge'](_0x17aa95[_0x91db('0x3a')],{'$or':_['map'](_0x17aa95[_0x91db('0x35')],function(_0x2e51cd){var _0x336f77={};_0x336f77[_0x2e51cd]={'$like':'%'+_0x160b2d['query']['filter']+'%'};return _0x336f77;})});}_0x17aa95=_[_0x91db('0x3e')]({},_0x17aa95,_0x160b2d[_0x91db('0x40')]);return _0x440a9f[_0x91db('0x8e')](_0x17aa95);}})[_0x91db('0x25')](function(_0x5f5511){if(_0x5f5511){_0x4978d9=_0x5f5511['length'];if(!_0x160b2d[_0x91db('0x32')][_0x91db('0x37')](_0x91db('0x58'))){_0x17aa95[_0x91db('0x1f')]=qs[_0x91db('0x1f')](_0x160b2d[_0x91db('0x32')][_0x91db('0x1f')]);_0x17aa95[_0x91db('0x1e')]=qs['offset'](_0x160b2d[_0x91db('0x32')][_0x91db('0x1e')]);}return _0x440a9f['getAgents'](_0x17aa95);}})[_0x91db('0x25')](function(_0x178f82){if(_0x178f82){return _0x178f82?{'count':_0x4978d9,'rows':_0x178f82}:null;}})[_0x91db('0x25')](respondWithResult(_0x34d701,null))[_0x91db('0x46')](handleError(_0x34d701,null));};
\ No newline at end of file