Built motion from commit 10af8726.|2.6.34
[motion2.git] / server / api / smsQueue / smsQueue.controller.js
index a7745fe..c998908 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xc0a7=['UserProfileResource','error','stack','name','send','map','rawAttributes','fieldName','type','key','model','keys','query','filters','intersection','fields','attributes','nolimit','order','pick','where','filter','merge','options','includeAll','include','SmsQueue','findAll','rows','catch','show','params','length','find','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','describe','getMembers','findOne','UserSmsQueue','sort','SmsQueueId','User','findAndCountAll','smsPause','updatedAt','format','%s/%s','SIP','createdAt','getTeams','Team','hasOwnProperty','addTeams','ids','voicePause','interface','flatMap','Agents','transaction','each','findOrCreate','forEach','emit','userSmsQueue:save','removeTeams','select','tq.TeamId','team_has_sms_queues','join','user_has_teams','SmsQueueId\x20=\x20?','clone','ut.UserId\x20=\x20?','push','sequelize','QueryTypes','SELECT','TeamId','all','union','compact','isEmpty','removeAgents','userSmsQueue:remove','addAgents','omit','spread','isArray','getAgents','eml-format','rimraf','zip-dir','request-promise','moment','bluebird','mustache','path','sox','to-csv','ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','defaults','register','sendStatus','end','status','json','offset','undefined','limit','count','set','Content-Range','apply','update','then','destroy','get','SmsQueues'];(function(_0x252620,_0x3d76b9){var _0x538f61=function(_0x4cbc6f){while(--_0x4cbc6f){_0x252620['push'](_0x252620['shift']());}};_0x538f61(++_0x3d76b9);}(_0xc0a7,0xee));var _0x7c0a=function(_0x530b18,_0x319614){_0x530b18=_0x530b18-0x0;var _0x2f305e=_0xc0a7[_0x530b18];return _0x2f305e;};'use strict';var emlformat=require(_0x7c0a('0x0'));var rimraf=require(_0x7c0a('0x1'));var zipdir=require(_0x7c0a('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0x7c0a('0x3'));var moment=require(_0x7c0a('0x4'));var BPromise=require(_0x7c0a('0x5'));var Mustache=require(_0x7c0a('0x6'));var util=require('util');var path=require(_0x7c0a('0x7'));var sox=require(_0x7c0a('0x8'));var csv=require(_0x7c0a('0x9'));var ejs=require(_0x7c0a('0xa'));var fs=require('fs');var fs_extra=require(_0x7c0a('0xb'));var _=require(_0x7c0a('0xc'));var squel=require(_0x7c0a('0xd'));var crypto=require(_0x7c0a('0xe'));var jsforce=require(_0x7c0a('0xf'));var deskjs=require(_0x7c0a('0x10'));var toCsv=require(_0x7c0a('0x9'));var querystring=require(_0x7c0a('0x11'));var Papa=require(_0x7c0a('0x12'));var Redis=require('ioredis');var authService=require(_0x7c0a('0x13'));var qs=require(_0x7c0a('0x14'));var as=require(_0x7c0a('0x15'));var hardwareService=require(_0x7c0a('0x16'));var logger=require(_0x7c0a('0x17'))(_0x7c0a('0x18'));var utils=require(_0x7c0a('0x19'));var config=require(_0x7c0a('0x1a'));var licenseUtil=require(_0x7c0a('0x1b'));var db=require(_0x7c0a('0x1c'))['db'];config[_0x7c0a('0x1d')]=_[_0x7c0a('0x1e')](config[_0x7c0a('0x1d')],{'host':'localhost','port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x7c0a('0x1d')]));require('./smsQueue.socket')[_0x7c0a('0x1f')](socket);function respondWithStatusCode(_0x255911,_0x80b70e){_0x80b70e=_0x80b70e||0xcc;return function(_0x119594){if(_0x119594){return _0x255911[_0x7c0a('0x20')](_0x80b70e);}return _0x255911['status'](_0x80b70e)[_0x7c0a('0x21')]();};}function respondWithResult(_0x7828fb,_0xcb7e63){_0xcb7e63=_0xcb7e63||0xc8;return function(_0x32032c){if(_0x32032c){return _0x7828fb[_0x7c0a('0x22')](_0xcb7e63)[_0x7c0a('0x23')](_0x32032c);}};}function respondWithFilteredResult(_0x52aa9e,_0x534962){return function(_0x1ecb2a){if(_0x1ecb2a){var _0x46cafb=typeof _0x534962[_0x7c0a('0x24')]===_0x7c0a('0x25')&&typeof _0x534962[_0x7c0a('0x26')]==='undefined';var _0x1d6427=_0x1ecb2a[_0x7c0a('0x27')];var _0x546ac8=_0x46cafb?0x0:_0x534962[_0x7c0a('0x24')];var _0x53da9f=_0x46cafb?_0x1ecb2a['count']:_0x534962[_0x7c0a('0x24')]+_0x534962['limit'];var _0x3ecf07;if(_0x53da9f>=_0x1d6427){_0x53da9f=_0x1d6427;_0x3ecf07=0xc8;}else{_0x3ecf07=0xce;}_0x52aa9e['status'](_0x3ecf07);return _0x52aa9e[_0x7c0a('0x28')](_0x7c0a('0x29'),_0x546ac8+'-'+_0x53da9f+'/'+_0x1d6427)[_0x7c0a('0x23')](_0x1ecb2a);}return null;};}function patchUpdates(_0xa9c1b6){return function(_0x5632f3){try{jsonpatch[_0x7c0a('0x2a')](_0x5632f3,_0xa9c1b6,!![]);}catch(_0x51e810){return BPromise['reject'](_0x51e810);}return _0x5632f3['save']();};}function saveUpdates(_0x588544,_0x1eaea9){return function(_0x127ac4){if(_0x127ac4){return _0x127ac4[_0x7c0a('0x2b')](_0x588544)[_0x7c0a('0x2c')](function(_0x3ddbe0){return _0x3ddbe0;});}return null;};}function removeEntity(_0x15bc46,_0x4bfa38){return function(_0x1fd876){if(_0x1fd876){return _0x1fd876[_0x7c0a('0x2d')]()[_0x7c0a('0x2c')](function(){var _0x247fed=_0x1fd876[_0x7c0a('0x2e')]({'plain':!![]});var _0x961dcd=_0x7c0a('0x2f');return db[_0x7c0a('0x30')][_0x7c0a('0x2d')]({'where':{'type':_0x961dcd,'resourceId':_0x247fed['id']}})[_0x7c0a('0x2c')](function(){return _0x1fd876;});})[_0x7c0a('0x2c')](function(){_0x15bc46['status'](0xcc)[_0x7c0a('0x21')]();});}};}function handleEntityNotFound(_0x351af1,_0x304fde){return function(_0x55aacf){if(!_0x55aacf){_0x351af1['sendStatus'](0x194);}return _0x55aacf;};}function handleError(_0x4d2360,_0x5e04cb){_0x5e04cb=_0x5e04cb||0x1f4;return function(_0x4d5f98){logger[_0x7c0a('0x31')](_0x4d5f98[_0x7c0a('0x32')]);if(_0x4d5f98[_0x7c0a('0x33')]){delete _0x4d5f98[_0x7c0a('0x33')];}_0x4d2360[_0x7c0a('0x22')](_0x5e04cb)[_0x7c0a('0x34')](_0x4d5f98);};}exports['index']=function(_0x332dcb,_0x22de87){var _0x484145={},_0x4d03d8={},_0x1d1ce7={'count':0x0,'rows':[]};var _0x20d144=_[_0x7c0a('0x35')](db['SmsQueue'][_0x7c0a('0x36')],function(_0x506a7a){return{'name':_0x506a7a[_0x7c0a('0x37')],'type':_0x506a7a[_0x7c0a('0x38')][_0x7c0a('0x39')]};});_0x4d03d8[_0x7c0a('0x3a')]=_[_0x7c0a('0x35')](_0x20d144,_0x7c0a('0x33'));_0x4d03d8['query']=_[_0x7c0a('0x3b')](_0x332dcb[_0x7c0a('0x3c')]);_0x4d03d8[_0x7c0a('0x3d')]=_[_0x7c0a('0x3e')](_0x4d03d8['model'],_0x4d03d8[_0x7c0a('0x3c')]);_0x484145['attributes']=_[_0x7c0a('0x3e')](_0x4d03d8['model'],qs['fields'](_0x332dcb[_0x7c0a('0x3c')][_0x7c0a('0x3f')]));_0x484145[_0x7c0a('0x40')]=_0x484145[_0x7c0a('0x40')]['length']?_0x484145['attributes']:_0x4d03d8[_0x7c0a('0x3a')];if(!_0x332dcb['query']['hasOwnProperty'](_0x7c0a('0x41'))){_0x484145[_0x7c0a('0x26')]=qs[_0x7c0a('0x26')](_0x332dcb[_0x7c0a('0x3c')][_0x7c0a('0x26')]);_0x484145[_0x7c0a('0x24')]=qs[_0x7c0a('0x24')](_0x332dcb[_0x7c0a('0x3c')][_0x7c0a('0x24')]);}_0x484145[_0x7c0a('0x42')]=qs['sort'](_0x332dcb[_0x7c0a('0x3c')]['sort']);_0x484145['where']=qs[_0x7c0a('0x3d')](_[_0x7c0a('0x43')](_0x332dcb[_0x7c0a('0x3c')],_0x4d03d8[_0x7c0a('0x3d')]),_0x20d144);if(_0x332dcb[_0x7c0a('0x3c')]['filter']){_0x484145[_0x7c0a('0x44')]=_['merge'](_0x484145[_0x7c0a('0x44')],{'$or':_[_0x7c0a('0x35')](_0x20d144,function(_0xeedde5){if(_0xeedde5[_0x7c0a('0x38')]!=='VIRTUAL'){var _0x24d6fc={};_0x24d6fc[_0xeedde5[_0x7c0a('0x33')]]={'$like':'%'+_0x332dcb[_0x7c0a('0x3c')][_0x7c0a('0x45')]+'%'};return _0x24d6fc;}})});}_0x484145=_[_0x7c0a('0x46')]({},_0x484145,_0x332dcb[_0x7c0a('0x47')]);var _0x765253={'where':_0x484145[_0x7c0a('0x44')]};return db['SmsQueue'][_0x7c0a('0x27')](_0x765253)[_0x7c0a('0x2c')](function(_0x233896){_0x1d1ce7[_0x7c0a('0x27')]=_0x233896;if(_0x332dcb[_0x7c0a('0x3c')][_0x7c0a('0x48')]){_0x484145[_0x7c0a('0x49')]=[{'all':!![]}];}return db[_0x7c0a('0x4a')][_0x7c0a('0x4b')](_0x484145);})[_0x7c0a('0x2c')](function(_0x34fb49){_0x1d1ce7[_0x7c0a('0x4c')]=_0x34fb49;return _0x1d1ce7;})[_0x7c0a('0x2c')](respondWithFilteredResult(_0x22de87,_0x484145))[_0x7c0a('0x4d')](handleError(_0x22de87,null));};exports[_0x7c0a('0x4e')]=function(_0x384db7,_0x544b4d){var _0x32eb63={'raw':!![],'where':{'id':_0x384db7[_0x7c0a('0x4f')]['id']}},_0x14f66c={};_0x14f66c[_0x7c0a('0x3a')]=_[_0x7c0a('0x3b')](db['SmsQueue'][_0x7c0a('0x36')]);_0x14f66c[_0x7c0a('0x3c')]=_['keys'](_0x384db7[_0x7c0a('0x3c')]);_0x14f66c['filters']=_['intersection'](_0x14f66c[_0x7c0a('0x3a')],_0x14f66c['query']);_0x32eb63[_0x7c0a('0x40')]=_['intersection'](_0x14f66c[_0x7c0a('0x3a')],qs[_0x7c0a('0x3f')](_0x384db7[_0x7c0a('0x3c')][_0x7c0a('0x3f')]));_0x32eb63[_0x7c0a('0x40')]=_0x32eb63['attributes'][_0x7c0a('0x50')]?_0x32eb63['attributes']:_0x14f66c['model'];if(_0x384db7[_0x7c0a('0x3c')]['includeAll']){_0x32eb63['include']=[{'all':!![]}];}_0x32eb63=_[_0x7c0a('0x46')]({},_0x32eb63,_0x384db7[_0x7c0a('0x47')]);return db[_0x7c0a('0x4a')][_0x7c0a('0x51')](_0x32eb63)[_0x7c0a('0x2c')](handleEntityNotFound(_0x544b4d,null))['then'](respondWithResult(_0x544b4d,null))[_0x7c0a('0x4d')](handleError(_0x544b4d,null));};exports[_0x7c0a('0x52')]=function(_0x4d2d4e,_0x55f68c){return db[_0x7c0a('0x4a')]['create'](_0x4d2d4e[_0x7c0a('0x53')],{})['then'](function(_0x2b64e9){var _0x599d80=_0x4d2d4e[_0x7c0a('0x54')][_0x7c0a('0x2e')]({'plain':!![]});if(!_0x599d80)throw new Error(_0x7c0a('0x55'));if(_0x599d80[_0x7c0a('0x56')]===_0x7c0a('0x54')){var _0x4231f2=_0x2b64e9[_0x7c0a('0x2e')]({'plain':!![]});var _0x3dfc08=_0x7c0a('0x2f');return db[_0x7c0a('0x57')][_0x7c0a('0x51')]({'where':{'name':_0x3dfc08,'userProfileId':_0x599d80['userProfileId']},'raw':!![]})['then'](function(_0x39f358){if(_0x39f358&&_0x39f358['autoAssociation']===0x0){return db['UserProfileResource'][_0x7c0a('0x52')]({'name':_0x4231f2[_0x7c0a('0x33')],'resourceId':_0x4231f2['id'],'type':_0x39f358[_0x7c0a('0x33')],'sectionId':_0x39f358['id']},{})['then'](function(){return _0x2b64e9;});}else{return _0x2b64e9;}})[_0x7c0a('0x4d')](function(_0x63570b){logger[_0x7c0a('0x31')](_0x7c0a('0x58'),_0x63570b);throw _0x63570b;});}return _0x2b64e9;})[_0x7c0a('0x2c')](respondWithResult(_0x55f68c,0xc9))[_0x7c0a('0x4d')](handleError(_0x55f68c,null));};exports['update']=function(_0x539d42,_0x2071a5){if(_0x539d42[_0x7c0a('0x53')]['id']){delete _0x539d42['body']['id'];}return db['SmsQueue']['find']({'where':{'id':_0x539d42[_0x7c0a('0x4f')]['id']}})[_0x7c0a('0x2c')](handleEntityNotFound(_0x2071a5,null))['then'](saveUpdates(_0x539d42[_0x7c0a('0x53')],null))[_0x7c0a('0x2c')](respondWithResult(_0x2071a5,null))['catch'](handleError(_0x2071a5,null));};exports[_0x7c0a('0x2d')]=function(_0x12b5af,_0x43e23b){return db['SmsQueue'][_0x7c0a('0x51')]({'where':{'id':_0x12b5af[_0x7c0a('0x4f')]['id']}})[_0x7c0a('0x2c')](handleEntityNotFound(_0x43e23b,null))['then'](removeEntity(_0x43e23b,null))[_0x7c0a('0x4d')](handleError(_0x43e23b,null));};exports['describe']=function(_0x3b92ae,_0xa82894){return db[_0x7c0a('0x4a')][_0x7c0a('0x59')]()[_0x7c0a('0x2c')](respondWithResult(_0xa82894,null))[_0x7c0a('0x4d')](handleError(_0xa82894,null));};exports[_0x7c0a('0x5a')]=function(_0xabbe3d,_0x23912f,_0x512778){var _0x182b53={'raw':!![],'where':{}},_0x296f62={},_0x26e720;return db['SmsQueue'][_0x7c0a('0x5b')]({'where':{'id':_0xabbe3d['params']['id']}})['then'](handleEntityNotFound(_0x23912f,null))['then'](function(_0x2f66f7){if(_0x2f66f7){_0x26e720=_0x2f66f7['get']({'plain':!![]});_0x296f62[_0x7c0a('0x3a')]=_['keys'](db[_0x7c0a('0x5c')][_0x7c0a('0x36')]);_0x296f62[_0x7c0a('0x3c')]=_[_0x7c0a('0x3b')](_0xabbe3d[_0x7c0a('0x3c')]);_0x296f62[_0x7c0a('0x3d')]=_['intersection'](_0x296f62[_0x7c0a('0x3a')],_0x296f62[_0x7c0a('0x3c')]);_0x182b53['attributes']=_[_0x7c0a('0x3e')](_0x296f62[_0x7c0a('0x3a')],qs[_0x7c0a('0x3f')](_0xabbe3d[_0x7c0a('0x3c')]['fields']));_0x182b53['attributes']=_0x182b53[_0x7c0a('0x40')][_0x7c0a('0x50')]?_0x182b53[_0x7c0a('0x40')]:_0x296f62[_0x7c0a('0x3a')];if(!_0xabbe3d[_0x7c0a('0x3c')]['hasOwnProperty'](_0x7c0a('0x41'))){_0x182b53[_0x7c0a('0x26')]=qs['limit'](_0xabbe3d[_0x7c0a('0x3c')][_0x7c0a('0x26')]);_0x182b53[_0x7c0a('0x24')]=qs[_0x7c0a('0x24')](_0xabbe3d[_0x7c0a('0x3c')][_0x7c0a('0x24')]);}_0x182b53['order']=qs[_0x7c0a('0x5d')](_0xabbe3d[_0x7c0a('0x3c')][_0x7c0a('0x5d')]);_0x182b53[_0x7c0a('0x44')]=qs['filters'](_[_0x7c0a('0x43')](_0xabbe3d[_0x7c0a('0x3c')],_0x296f62[_0x7c0a('0x3d')]));_0x182b53[_0x7c0a('0x44')][_0x7c0a('0x5e')]=_0x2f66f7['id'];if(_0xabbe3d['query'][_0x7c0a('0x45')]){_0x182b53['where']=_[_0x7c0a('0x46')](_0x182b53[_0x7c0a('0x44')],{'$or':_[_0x7c0a('0x35')](_0x182b53[_0x7c0a('0x40')],function(_0x1a4bd6){var _0x2c8a46={};_0x2c8a46[_0x1a4bd6]={'$like':'%'+_0xabbe3d[_0x7c0a('0x3c')][_0x7c0a('0x45')]+'%'};return _0x2c8a46;})});}_0x182b53=_[_0x7c0a('0x46')]({},_0x182b53,_0xabbe3d['options']);return db[_0x7c0a('0x5c')][_0x7c0a('0x4b')](_0x182b53);}})[_0x7c0a('0x2c')](function(_0x33170b){if(_0x33170b){return db[_0x7c0a('0x5f')][_0x7c0a('0x60')]({'where':{'id':_[_0x7c0a('0x35')](_0x33170b,'UserId'),'role':'agent'},'attributes':['id',_0x7c0a('0x33'),_0x7c0a('0x61'),_0x7c0a('0x62'),'createdAt']});}})[_0x7c0a('0x2c')](function(_0x3765ac){if(_0x3765ac){return{'count':_0x3765ac[_0x7c0a('0x27')],'rows':_[_0x7c0a('0x35')](_0x3765ac[_0x7c0a('0x4c')],function(_0x135d18){return{'membername':_0x135d18[_0x7c0a('0x33')],'UserId':_0x135d18['id'],'queue_name':_0x26e720[_0x7c0a('0x33')],'SmsQueueId':_0x26e720['id'],'interface':util[_0x7c0a('0x63')](_0x7c0a('0x64'),_0x7c0a('0x65'),_0x135d18[_0x7c0a('0x33')]),'penalty':0x0,'paused':_0x135d18[_0x7c0a('0x61')],'createdAt':_0x135d18[_0x7c0a('0x66')],'updatedAt':_0x135d18[_0x7c0a('0x62')]};})};}else{return{'count':0x0,'rows':[]};}})[_0x7c0a('0x2c')](respondWithFilteredResult(_0x23912f,_0x182b53))['catch'](handleError(_0x23912f,null));};exports[_0x7c0a('0x67')]=function(_0x4ca183,_0x68b58,_0x51677f){var _0x501d2f={};var _0x594739={};var _0x3ef210;var _0x44a6fa;return db[_0x7c0a('0x4a')][_0x7c0a('0x5b')]({'where':{'id':_0x4ca183[_0x7c0a('0x4f')]['id']}})['then'](handleEntityNotFound(_0x68b58,null))[_0x7c0a('0x2c')](function(_0x125bcd){if(_0x125bcd){_0x3ef210=_0x125bcd;_0x594739[_0x7c0a('0x3a')]=_[_0x7c0a('0x3b')](db[_0x7c0a('0x68')][_0x7c0a('0x36')]);_0x594739[_0x7c0a('0x3c')]=_[_0x7c0a('0x3b')](_0x4ca183[_0x7c0a('0x3c')]);_0x594739[_0x7c0a('0x3d')]=_['intersection'](_0x594739['model'],_0x594739['query']);_0x501d2f[_0x7c0a('0x40')]=_[_0x7c0a('0x3e')](_0x594739[_0x7c0a('0x3a')],qs[_0x7c0a('0x3f')](_0x4ca183[_0x7c0a('0x3c')][_0x7c0a('0x3f')]));_0x501d2f['attributes']=_0x501d2f[_0x7c0a('0x40')][_0x7c0a('0x50')]?_0x501d2f[_0x7c0a('0x40')]:_0x594739[_0x7c0a('0x3a')];_0x501d2f[_0x7c0a('0x42')]=qs['sort'](_0x4ca183['query']['sort']);_0x501d2f['where']=qs[_0x7c0a('0x3d')](_[_0x7c0a('0x43')](_0x4ca183[_0x7c0a('0x3c')],_0x594739[_0x7c0a('0x3d')]));if(_0x4ca183['query'][_0x7c0a('0x45')]){_0x501d2f['where']=_[_0x7c0a('0x46')](_0x501d2f['where'],{'$or':_['map'](_0x501d2f[_0x7c0a('0x40')],function(_0x4d908e){var _0x33a504={};_0x33a504[_0x4d908e]={'$like':'%'+_0x4ca183[_0x7c0a('0x3c')][_0x7c0a('0x45')]+'%'};return _0x33a504;})});}_0x501d2f=_['merge']({},_0x501d2f,_0x4ca183[_0x7c0a('0x47')]);return _0x3ef210[_0x7c0a('0x67')](_0x501d2f);}})[_0x7c0a('0x2c')](function(_0x2b14f6){if(_0x2b14f6){_0x44a6fa=_0x2b14f6['length'];if(!_0x4ca183[_0x7c0a('0x3c')][_0x7c0a('0x69')]('nolimit')){_0x501d2f['limit']=qs['limit'](_0x4ca183[_0x7c0a('0x3c')][_0x7c0a('0x26')]);_0x501d2f[_0x7c0a('0x24')]=qs[_0x7c0a('0x24')](_0x4ca183[_0x7c0a('0x3c')][_0x7c0a('0x24')]);}return _0x3ef210[_0x7c0a('0x67')](_0x501d2f);}})[_0x7c0a('0x2c')](function(_0x4e03a9){if(_0x4e03a9){return _0x4e03a9?{'count':_0x44a6fa,'rows':_0x4e03a9}:null;}})[_0x7c0a('0x2c')](respondWithResult(_0x68b58,null))['catch'](handleError(_0x68b58,null));};exports[_0x7c0a('0x6a')]=function(_0x56040,_0x2e83dc,_0x2a41fb){var _0x528930=_0x56040[_0x7c0a('0x53')][_0x7c0a('0x6b')];return db[_0x7c0a('0x68')][_0x7c0a('0x4b')]({'where':{'id':_0x528930},'attributes':['id'],'include':[{'model':db[_0x7c0a('0x5f')],'as':'Agents','attributes':['id',_0x7c0a('0x33'),'online',_0x7c0a('0x6c'),_0x7c0a('0x6d')],'raw':!![]}]})[_0x7c0a('0x2c')](function(_0x232d32){if(_0x232d32){var _0x3b16ce=_[_0x7c0a('0x6e')](_0x232d32,function(_0x3f353c){var _0x5bdc6f=_0x3f353c[_0x7c0a('0x2e')]({'plain':!![]});return _0x5bdc6f[_0x7c0a('0x6f')];});return db[_0x7c0a('0x4a')][_0x7c0a('0x51')]({'where':{'id':_0x56040['params']['id']}})['then'](function(_0x2b0f3e){return db['sequelize'][_0x7c0a('0x70')](function(_0xe5510b){return _0x2b0f3e[_0x7c0a('0x6a')](_0x528930,{'transaction':_0xe5510b})[_0x7c0a('0x2c')](function(){return BPromise[_0x7c0a('0x71')](_0x3b16ce,function(_0x278ef6){return db['UserSmsQueue'][_0x7c0a('0x72')]({'where':{'UserId':_0x278ef6['id'],'SmsQueueId':_0x56040[_0x7c0a('0x4f')]['id']},'transaction':_0xe5510b});});})[_0x7c0a('0x2c')](function(){_0x3b16ce[_0x7c0a('0x73')](function(_0x418403){socket[_0x7c0a('0x74')](_0x7c0a('0x75'),{'UserId':_0x418403['id'],'SmsQueueId':_0x2b0f3e['id']});});});});});}})[_0x7c0a('0x2c')](respondWithStatusCode(_0x2e83dc,null))[_0x7c0a('0x4d')](handleError(_0x2e83dc,null));};exports[_0x7c0a('0x76')]=function(_0x4ad83d,_0x3c6c11,_0x36e6b0){return db['Team'][_0x7c0a('0x4b')]({'where':{'id':_0x4ad83d[_0x7c0a('0x3c')][_0x7c0a('0x6b')]},'attributes':['id'],'include':[{'model':db[_0x7c0a('0x5f')],'as':_0x7c0a('0x6f'),'attributes':['id'],'raw':!![]}]})[_0x7c0a('0x2c')](handleEntityNotFound(_0x3c6c11,null))['then'](function(_0x130dd6){var _0x2e56ad=_[_0x7c0a('0x35')](_0x130dd6,'id');var _0x8ac2b9=[];var _0x34587e=[];var _0x4ba03c=squel[_0x7c0a('0x77')]();_0x4ba03c['field'](_0x7c0a('0x78'))['from'](_0x7c0a('0x79'),'tq')[_0x7c0a('0x7a')](_0x7c0a('0x7b'),'ut','ut.TeamId\x20=\x20tq.TeamId')[_0x7c0a('0x44')](_0x7c0a('0x7c'),_0x4ad83d[_0x7c0a('0x4f')]['id']);for(var _0x330031=0x0;_0x330031<_0x130dd6[_0x7c0a('0x50')];_0x330031+=0x1){let _0x1207c2=_0x130dd6[_0x330031];for(var _0x1b68f8=0x0;_0x1b68f8<_0x1207c2[_0x7c0a('0x6f')][_0x7c0a('0x50')];_0x1b68f8+=0x1){let _0x565246=_0x1207c2['Agents'][_0x1b68f8];var _0x28e061=_0x4ba03c[_0x7c0a('0x7d')]();_0x28e061['where'](_0x7c0a('0x7e'),_0x565246['id']);_0x34587e[_0x7c0a('0x7f')](db[_0x7c0a('0x80')][_0x7c0a('0x3c')](_0x28e061['toString'](),{'type':db[_0x7c0a('0x80')][_0x7c0a('0x81')][_0x7c0a('0x82')]})['then'](function(_0x3c337b){if(_0x3c337b['length']===0x1){return _0x565246['id'];}else{var _0x5acb84=_['every'](_[_0x7c0a('0x35')](_0x3c337b,_0x7c0a('0x83')),function(_0x3eb4e4){return _['includes'](_0x2e56ad,_0x3eb4e4);});if(_0x5acb84){return _0x565246['id'];}}}));}}return BPromise[_0x7c0a('0x84')](_0x34587e)[_0x7c0a('0x2c')](function(_0x5b5504){_0x8ac2b9=_(_0x8ac2b9)[_0x7c0a('0x85')](_0x5b5504)[_0x7c0a('0x86')]()['value']();return db[_0x7c0a('0x4a')][_0x7c0a('0x51')]({'where':{'id':_0x4ad83d['params']['id']}})['then'](function(_0x5bc4a3){return db['sequelize'][_0x7c0a('0x70')](function(_0x3c295d){return _0x5bc4a3[_0x7c0a('0x76')](_0x4ad83d[_0x7c0a('0x3c')][_0x7c0a('0x6b')],{'transaction':_0x3c295d})[_0x7c0a('0x2c')](function(){if(!_[_0x7c0a('0x87')](_0x8ac2b9)){return _0x5bc4a3[_0x7c0a('0x88')](_0x8ac2b9,{'transaction':_0x3c295d});}})[_0x7c0a('0x2c')](function(){_0x8ac2b9[_0x7c0a('0x73')](function(_0x3c02b9){socket[_0x7c0a('0x74')](_0x7c0a('0x89'),{'UserId':_0x3c02b9,'SmsQueueId':_0x5bc4a3['id']});});});});});});})['then'](respondWithStatusCode(_0x3c6c11,null))[_0x7c0a('0x4d')](handleError(_0x3c6c11,null));};exports[_0x7c0a('0x8a')]=function(_0x111894,_0x3fe5d6,_0x366272){return db['SmsQueue'][_0x7c0a('0x51')]({'where':{'id':_0x111894[_0x7c0a('0x4f')]['id']}})['then'](handleEntityNotFound(_0x3fe5d6,null))['then'](function(_0x3c488a){if(_0x3c488a){return _0x3c488a[_0x7c0a('0x8a')](_0x111894[_0x7c0a('0x53')][_0x7c0a('0x6b')],_[_0x7c0a('0x8b')](_0x111894[_0x7c0a('0x53')],[_0x7c0a('0x6b'),'id'])||{})[_0x7c0a('0x8c')](function(_0x29067a){for(var _0x1dd30f=0x0;_0x1dd30f<_0x111894[_0x7c0a('0x53')][_0x7c0a('0x6b')][_0x7c0a('0x50')];_0x1dd30f+=0x1){socket['emit'](_0x7c0a('0x75'),{'UserId':Number(_0x111894[_0x7c0a('0x53')]['ids'][_0x1dd30f]),'SmsQueueId':Number(_0x111894[_0x7c0a('0x4f')]['id'])});}return _0x29067a;});}})[_0x7c0a('0x2c')](respondWithResult(_0x3fe5d6,null))[_0x7c0a('0x4d')](handleError(_0x3fe5d6,null));};exports[_0x7c0a('0x88')]=function(_0x55ceac,_0x1e7f83,_0x531070){return db[_0x7c0a('0x4a')][_0x7c0a('0x51')]({'where':{'id':_0x55ceac[_0x7c0a('0x4f')]['id']}})[_0x7c0a('0x2c')](handleEntityNotFound(_0x1e7f83,null))[_0x7c0a('0x2c')](function(_0x2927d2){if(_0x2927d2){return _0x2927d2[_0x7c0a('0x88')](_0x55ceac[_0x7c0a('0x3c')][_0x7c0a('0x6b')])[_0x7c0a('0x2c')](function(){if(_[_0x7c0a('0x8d')](_0x55ceac[_0x7c0a('0x3c')]['ids'])){for(var _0x217901=0x0;_0x217901<_0x55ceac[_0x7c0a('0x3c')][_0x7c0a('0x6b')][_0x7c0a('0x50')];_0x217901+=0x1){socket[_0x7c0a('0x74')](_0x7c0a('0x89'),{'UserId':Number(_0x55ceac[_0x7c0a('0x3c')][_0x7c0a('0x6b')][_0x217901]),'SmsQueueId':Number(_0x55ceac[_0x7c0a('0x4f')]['id'])});}}else{socket['emit'](_0x7c0a('0x89'),{'UserId':Number(_0x55ceac['query'][_0x7c0a('0x6b')]),'SmsQueueId':Number(_0x55ceac[_0x7c0a('0x4f')]['id'])});}});}})[_0x7c0a('0x2c')](respondWithStatusCode(_0x1e7f83,null))['catch'](handleError(_0x1e7f83,null));};exports[_0x7c0a('0x8e')]=function(_0x36f536,_0x527dd9,_0x3abae9){var _0x126a3d={};var _0x236039={};var _0x343089;var _0x38816f;return db[_0x7c0a('0x4a')][_0x7c0a('0x5b')]({'where':{'id':_0x36f536['params']['id']}})['then'](handleEntityNotFound(_0x527dd9,null))[_0x7c0a('0x2c')](function(_0x55c505){if(_0x55c505){_0x343089=_0x55c505;_0x236039[_0x7c0a('0x3a')]=_[_0x7c0a('0x3b')](db[_0x7c0a('0x5f')][_0x7c0a('0x36')]);_0x236039[_0x7c0a('0x3c')]=_['keys'](_0x36f536[_0x7c0a('0x3c')]);_0x236039[_0x7c0a('0x3d')]=_[_0x7c0a('0x3e')](_0x236039[_0x7c0a('0x3a')],_0x236039[_0x7c0a('0x3c')]);_0x126a3d['attributes']=_[_0x7c0a('0x3e')](_0x236039[_0x7c0a('0x3a')],qs[_0x7c0a('0x3f')](_0x36f536[_0x7c0a('0x3c')][_0x7c0a('0x3f')]));_0x126a3d['attributes']=_0x126a3d['attributes'][_0x7c0a('0x50')]?_0x126a3d[_0x7c0a('0x40')]:_0x236039['model'];_0x126a3d[_0x7c0a('0x42')]=qs[_0x7c0a('0x5d')](_0x36f536[_0x7c0a('0x3c')][_0x7c0a('0x5d')]);_0x126a3d[_0x7c0a('0x44')]=qs['filters'](_[_0x7c0a('0x43')](_0x36f536[_0x7c0a('0x3c')],_0x236039[_0x7c0a('0x3d')]));if(_0x36f536[_0x7c0a('0x3c')][_0x7c0a('0x45')]){_0x126a3d[_0x7c0a('0x44')]=_[_0x7c0a('0x46')](_0x126a3d[_0x7c0a('0x44')],{'$or':_[_0x7c0a('0x35')](_0x126a3d[_0x7c0a('0x40')],function(_0x43bf7a){var _0x531eb8={};_0x531eb8[_0x43bf7a]={'$like':'%'+_0x36f536[_0x7c0a('0x3c')][_0x7c0a('0x45')]+'%'};return _0x531eb8;})});}_0x126a3d=_[_0x7c0a('0x46')]({},_0x126a3d,_0x36f536['options']);return _0x343089['getAgents'](_0x126a3d);}})[_0x7c0a('0x2c')](function(_0x56e2bb){if(_0x56e2bb){_0x38816f=_0x56e2bb[_0x7c0a('0x50')];if(!_0x36f536[_0x7c0a('0x3c')][_0x7c0a('0x69')](_0x7c0a('0x41'))){_0x126a3d[_0x7c0a('0x26')]=qs[_0x7c0a('0x26')](_0x36f536[_0x7c0a('0x3c')]['limit']);_0x126a3d['offset']=qs['offset'](_0x36f536['query'][_0x7c0a('0x24')]);}return _0x343089[_0x7c0a('0x8e')](_0x126a3d);}})[_0x7c0a('0x2c')](function(_0x422bd9){if(_0x422bd9){return _0x422bd9?{'count':_0x38816f,'rows':_0x422bd9}:null;}})[_0x7c0a('0x2c')](respondWithResult(_0x527dd9,null))['catch'](handleError(_0x527dd9,null));};
\ No newline at end of file
+var _0x5f66=['show','params','model','keys','intersection','attributes','fields','includeAll','merge','options','create','body','user','get','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','SmsQueues','find','userProfileId','error','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','describe','rawAttributes','filters','hasOwnProperty','order','sort','pick','map','UserSmsQueue','User','findAndCountAll','UserId','agent','smsPause','updatedAt','createdAt','%s/%s','SIP','getTeams','length','filter','nolimit','ids','Team','Agents','interface','flatMap','sequelize','transaction','addTeams','forEach','emit','userSmsQueue:save','removeTeams','select','tq.TeamId','team_has_sms_queues','user_has_teams','ut.TeamId\x20=\x20tq.TeamId','clone','ut.UserId\x20=\x20?','toString','QueryTypes','SELECT','includes','all','compact','value','isEmpty','removeAgents','userSmsQueue:remove','addAgents','spread','isArray','findOne','getAgents','util','squel','ioredis','../../components/parsers/qs','../../config/logger','api','../../mysqldb','defaults','redis','./smsQueue.socket','register','end','json','offset','limit','undefined','count','status','update','then','UserProfileResource','destroy','sendStatus','stack','name','send','index','fieldName','key','getOptions','where','SmsQueue','include','query','findAll','catch'];(function(_0x4d62ae,_0x1509f5){var _0x54d4b7=function(_0x492d51){while(--_0x492d51){_0x4d62ae['push'](_0x4d62ae['shift']());}};_0x54d4b7(++_0x1509f5);}(_0x5f66,0x1a0));var _0x65f6=function(_0x3947c9,_0x4d6c97){_0x3947c9=_0x3947c9-0x0;var _0x2e7871=_0x5f66[_0x3947c9];return _0x2e7871;};'use strict';var BPromise=require('bluebird');var util=require(_0x65f6('0x0'));var _=require('lodash');var squel=require(_0x65f6('0x1'));var Redis=require(_0x65f6('0x2'));var qs=require(_0x65f6('0x3'));var logger=require(_0x65f6('0x4'))(_0x65f6('0x5'));var config=require('../../config/environment');var db=require(_0x65f6('0x6'))['db'];config['redis']=_[_0x65f6('0x7')](config[_0x65f6('0x8')],{'host':'localhost','port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x65f6('0x8')]));require(_0x65f6('0x9'))[_0x65f6('0xa')](socket);function respondWithStatusCode(_0x8f6451,_0xc44c70){_0xc44c70=_0xc44c70||0xcc;return function(_0x14f4c7){if(_0x14f4c7){return _0x8f6451['sendStatus'](_0xc44c70);}return _0x8f6451['status'](_0xc44c70)[_0x65f6('0xb')]();};}function respondWithResult(_0x2f6d5b,_0x264647){_0x264647=_0x264647||0xc8;return function(_0x25c416){if(_0x25c416){return _0x2f6d5b['status'](_0x264647)[_0x65f6('0xc')](_0x25c416);}};}function respondWithFilteredResult(_0x571436,_0x497cf3){return function(_0x2d2dfa){if(_0x2d2dfa){var _0x576875=typeof _0x497cf3[_0x65f6('0xd')]==='undefined'&&typeof _0x497cf3[_0x65f6('0xe')]===_0x65f6('0xf');var _0x2c4ee5=_0x2d2dfa[_0x65f6('0x10')];var _0x369f96=_0x576875?0x0:_0x497cf3[_0x65f6('0xd')];var _0x44144b=_0x576875?_0x2d2dfa[_0x65f6('0x10')]:_0x497cf3[_0x65f6('0xd')]+_0x497cf3[_0x65f6('0xe')];var _0x59154e;if(_0x44144b>=_0x2c4ee5){_0x44144b=_0x2c4ee5;_0x59154e=0xc8;}else{_0x59154e=0xce;}_0x571436[_0x65f6('0x11')](_0x59154e);return _0x571436['set']('Content-Range',_0x369f96+'-'+_0x44144b+'/'+_0x2c4ee5)[_0x65f6('0xc')](_0x2d2dfa);}return null;};}function saveUpdates(_0x5c69f8){return function(_0x37330d){if(_0x37330d){return _0x37330d[_0x65f6('0x12')](_0x5c69f8)[_0x65f6('0x13')](function(_0x1f974c){return _0x1f974c;});}return null;};}function removeEntity(_0xc8660c){return function(_0x18380e){if(_0x18380e){return _0x18380e['destroy']()['then'](function(){var _0x2d538c=_0x18380e['get']({'plain':!![]});var _0x4c81f3='SmsQueues';return db[_0x65f6('0x14')][_0x65f6('0x15')]({'where':{'type':_0x4c81f3,'resourceId':_0x2d538c['id']}})['then'](function(){return _0x18380e;});})[_0x65f6('0x13')](function(){_0xc8660c[_0x65f6('0x11')](0xcc)[_0x65f6('0xb')]();});}};}function handleEntityNotFound(_0x3876ed){return function(_0x219ab2){if(!_0x219ab2){_0x3876ed[_0x65f6('0x16')](0x194);}return _0x219ab2;};}function handleError(_0x581374,_0x197a49){_0x197a49=_0x197a49||0x1f4;return function(_0x4bb39e){logger['error'](_0x4bb39e[_0x65f6('0x17')]);if(_0x4bb39e[_0x65f6('0x18')]){delete _0x4bb39e['name'];}_0x581374[_0x65f6('0x11')](_0x197a49)[_0x65f6('0x19')](_0x4bb39e);};}exports[_0x65f6('0x1a')]=function(_0x2774a1,_0x4f5a69){var _0x9d7bb0={};var _0x59ea32={'count':0x0,'rows':[]};var _0x20a161=_['map'](db['SmsQueue']['rawAttributes'],function(_0x29abdb){return{'name':_0x29abdb[_0x65f6('0x1b')],'type':_0x29abdb['type'][_0x65f6('0x1c')]};});_0x9d7bb0=qs[_0x65f6('0x1d')](_0x20a161,_0x2774a1);var _0x52277c={'where':_0x9d7bb0[_0x65f6('0x1e')]};return db[_0x65f6('0x1f')][_0x65f6('0x10')](_0x52277c)['then'](function(_0x4ac04b){_0x59ea32['count']=_0x4ac04b;_0x9d7bb0[_0x65f6('0x20')]=qs[_0x65f6('0x20')](_0x2774a1[_0x65f6('0x21')]);return db[_0x65f6('0x1f')][_0x65f6('0x22')](_0x9d7bb0);})[_0x65f6('0x13')](function(_0x144e55){_0x59ea32['rows']=_0x144e55;return _0x59ea32;})['then'](respondWithFilteredResult(_0x4f5a69,_0x9d7bb0))[_0x65f6('0x23')](handleError(_0x4f5a69,null));};exports[_0x65f6('0x24')]=function(_0x5878bc,_0x4e50c0){var _0x10b368={'raw':!![],'where':{'id':_0x5878bc[_0x65f6('0x25')]['id']}},_0x1ce43c={};_0x1ce43c[_0x65f6('0x26')]=_[_0x65f6('0x27')](db[_0x65f6('0x1f')]['rawAttributes']);_0x1ce43c[_0x65f6('0x21')]=_[_0x65f6('0x27')](_0x5878bc[_0x65f6('0x21')]);_0x1ce43c['filters']=_[_0x65f6('0x28')](_0x1ce43c[_0x65f6('0x26')],_0x1ce43c[_0x65f6('0x21')]);_0x10b368[_0x65f6('0x29')]=_[_0x65f6('0x28')](_0x1ce43c[_0x65f6('0x26')],qs['fields'](_0x5878bc[_0x65f6('0x21')][_0x65f6('0x2a')]));_0x10b368['attributes']=_0x10b368[_0x65f6('0x29')]['length']?_0x10b368[_0x65f6('0x29')]:_0x1ce43c['model'];if(_0x5878bc[_0x65f6('0x21')][_0x65f6('0x2b')]){_0x10b368['include']=[{'all':!![]}];}_0x10b368=_[_0x65f6('0x2c')]({},_0x10b368,_0x5878bc[_0x65f6('0x2d')]);return db[_0x65f6('0x1f')]['find'](_0x10b368)['then'](handleEntityNotFound(_0x4e50c0,null))[_0x65f6('0x13')](respondWithResult(_0x4e50c0,null))['catch'](handleError(_0x4e50c0,null));};exports[_0x65f6('0x2e')]=function(_0x4e6653,_0x22d760){return db[_0x65f6('0x1f')]['create'](_0x4e6653[_0x65f6('0x2f')],{})['then'](function(_0x5edd04){var _0x71b16b=_0x4e6653[_0x65f6('0x30')][_0x65f6('0x31')]({'plain':!![]});if(!_0x71b16b)throw new Error(_0x65f6('0x32'));if(_0x71b16b[_0x65f6('0x33')]===_0x65f6('0x30')){var _0x1a55da=_0x5edd04[_0x65f6('0x31')]({'plain':!![]});var _0x4f933b=_0x65f6('0x34');return db['UserProfileSection'][_0x65f6('0x35')]({'where':{'name':_0x4f933b,'userProfileId':_0x71b16b[_0x65f6('0x36')]},'raw':!![]})[_0x65f6('0x13')](function(_0x2ea7f7){if(_0x2ea7f7&&_0x2ea7f7['autoAssociation']===0x0){return db[_0x65f6('0x14')][_0x65f6('0x2e')]({'name':_0x1a55da[_0x65f6('0x18')],'resourceId':_0x1a55da['id'],'type':_0x2ea7f7[_0x65f6('0x18')],'sectionId':_0x2ea7f7['id']},{})[_0x65f6('0x13')](function(){return _0x5edd04;});}else{return _0x5edd04;}})[_0x65f6('0x23')](function(_0xed4c96){logger[_0x65f6('0x37')](_0x65f6('0x38'),_0xed4c96);throw _0xed4c96;});}return _0x5edd04;})['then'](respondWithResult(_0x22d760,0xc9))[_0x65f6('0x23')](handleError(_0x22d760,null));};exports[_0x65f6('0x12')]=function(_0x377ae5,_0x181798){if(_0x377ae5[_0x65f6('0x2f')]['id']){delete _0x377ae5[_0x65f6('0x2f')]['id'];}return db[_0x65f6('0x1f')][_0x65f6('0x35')]({'where':{'id':_0x377ae5[_0x65f6('0x25')]['id']}})[_0x65f6('0x13')](handleEntityNotFound(_0x181798,null))[_0x65f6('0x13')](saveUpdates(_0x377ae5[_0x65f6('0x2f')],null))[_0x65f6('0x13')](respondWithResult(_0x181798,null))[_0x65f6('0x23')](handleError(_0x181798,null));};exports[_0x65f6('0x15')]=function(_0x2cb38d,_0x5119ee){return db[_0x65f6('0x1f')][_0x65f6('0x35')]({'where':{'id':_0x2cb38d[_0x65f6('0x25')]['id']}})[_0x65f6('0x13')](handleEntityNotFound(_0x5119ee,null))['then'](removeEntity(_0x5119ee,null))[_0x65f6('0x23')](handleError(_0x5119ee,null));};exports[_0x65f6('0x39')]=function(_0x2b01eb,_0x5e69b4){return db[_0x65f6('0x1f')][_0x65f6('0x39')]()[_0x65f6('0x13')](respondWithResult(_0x5e69b4,null))[_0x65f6('0x23')](handleError(_0x5e69b4,null));};exports['getMembers']=function(_0x2ec114,_0x512527){var _0x3f1baa={'raw':!![],'where':{}},_0x6968b={},_0x577c93;return db[_0x65f6('0x1f')]['findOne']({'where':{'id':_0x2ec114[_0x65f6('0x25')]['id']}})[_0x65f6('0x13')](handleEntityNotFound(_0x512527,null))[_0x65f6('0x13')](function(_0xc0db01){if(_0xc0db01){_0x577c93=_0xc0db01[_0x65f6('0x31')]({'plain':!![]});_0x6968b[_0x65f6('0x26')]=_['keys'](db['UserSmsQueue'][_0x65f6('0x3a')]);_0x6968b[_0x65f6('0x21')]=_[_0x65f6('0x27')](_0x2ec114[_0x65f6('0x21')]);_0x6968b[_0x65f6('0x3b')]=_[_0x65f6('0x28')](_0x6968b[_0x65f6('0x26')],_0x6968b[_0x65f6('0x21')]);_0x3f1baa[_0x65f6('0x29')]=_['intersection'](_0x6968b[_0x65f6('0x26')],qs[_0x65f6('0x2a')](_0x2ec114[_0x65f6('0x21')]['fields']));_0x3f1baa[_0x65f6('0x29')]=_0x3f1baa[_0x65f6('0x29')]['length']?_0x3f1baa[_0x65f6('0x29')]:_0x6968b[_0x65f6('0x26')];if(!_0x2ec114['query'][_0x65f6('0x3c')]('nolimit')){_0x3f1baa[_0x65f6('0xe')]=qs[_0x65f6('0xe')](_0x2ec114[_0x65f6('0x21')]['limit']);_0x3f1baa[_0x65f6('0xd')]=qs[_0x65f6('0xd')](_0x2ec114['query'][_0x65f6('0xd')]);}_0x3f1baa[_0x65f6('0x3d')]=qs['sort'](_0x2ec114[_0x65f6('0x21')][_0x65f6('0x3e')]);_0x3f1baa[_0x65f6('0x1e')]=qs[_0x65f6('0x3b')](_[_0x65f6('0x3f')](_0x2ec114[_0x65f6('0x21')],_0x6968b[_0x65f6('0x3b')]));_0x3f1baa[_0x65f6('0x1e')]['SmsQueueId']=_0xc0db01['id'];if(_0x2ec114['query']['filter']){_0x3f1baa[_0x65f6('0x1e')]=_[_0x65f6('0x2c')](_0x3f1baa[_0x65f6('0x1e')],{'$or':_[_0x65f6('0x40')](_0x3f1baa['attributes'],function(_0x183c08){var _0x2032b9={};_0x2032b9[_0x183c08]={'$like':'%'+_0x2ec114[_0x65f6('0x21')]['filter']+'%'};return _0x2032b9;})});}_0x3f1baa=_[_0x65f6('0x2c')]({},_0x3f1baa,_0x2ec114[_0x65f6('0x2d')]);return db[_0x65f6('0x41')]['findAll'](_0x3f1baa);}})['then'](function(_0x1d337d){if(_0x1d337d){return db[_0x65f6('0x42')][_0x65f6('0x43')]({'where':{'id':_[_0x65f6('0x40')](_0x1d337d,_0x65f6('0x44')),'role':_0x65f6('0x45')},'attributes':['id',_0x65f6('0x18'),_0x65f6('0x46'),_0x65f6('0x47'),_0x65f6('0x48')]});}})[_0x65f6('0x13')](function(_0x141fcc){if(_0x141fcc){return{'count':_0x141fcc[_0x65f6('0x10')],'rows':_[_0x65f6('0x40')](_0x141fcc['rows'],function(_0x47610a){return{'membername':_0x47610a[_0x65f6('0x18')],'UserId':_0x47610a['id'],'queue_name':_0x577c93[_0x65f6('0x18')],'SmsQueueId':_0x577c93['id'],'interface':util['format'](_0x65f6('0x49'),_0x65f6('0x4a'),_0x47610a[_0x65f6('0x18')]),'penalty':0x0,'paused':_0x47610a[_0x65f6('0x46')],'createdAt':_0x47610a['createdAt'],'updatedAt':_0x47610a[_0x65f6('0x47')]};})};}else{return{'count':0x0,'rows':[]};}})[_0x65f6('0x13')](respondWithFilteredResult(_0x512527,_0x3f1baa))[_0x65f6('0x23')](handleError(_0x512527,null));};exports[_0x65f6('0x4b')]=function(_0x553ff0,_0x2923ff){var _0x2fc20f={};var _0x5c55e4={};var _0x28682b;var _0x26481e;return db[_0x65f6('0x1f')]['findOne']({'where':{'id':_0x553ff0[_0x65f6('0x25')]['id']}})[_0x65f6('0x13')](handleEntityNotFound(_0x2923ff,null))[_0x65f6('0x13')](function(_0x3c23e3){if(_0x3c23e3){_0x28682b=_0x3c23e3;_0x5c55e4[_0x65f6('0x26')]=_[_0x65f6('0x27')](db['Team']['rawAttributes']);_0x5c55e4['query']=_[_0x65f6('0x27')](_0x553ff0[_0x65f6('0x21')]);_0x5c55e4[_0x65f6('0x3b')]=_[_0x65f6('0x28')](_0x5c55e4[_0x65f6('0x26')],_0x5c55e4[_0x65f6('0x21')]);_0x2fc20f['attributes']=_[_0x65f6('0x28')](_0x5c55e4[_0x65f6('0x26')],qs['fields'](_0x553ff0[_0x65f6('0x21')][_0x65f6('0x2a')]));_0x2fc20f[_0x65f6('0x29')]=_0x2fc20f['attributes'][_0x65f6('0x4c')]?_0x2fc20f[_0x65f6('0x29')]:_0x5c55e4['model'];_0x2fc20f[_0x65f6('0x3d')]=qs[_0x65f6('0x3e')](_0x553ff0[_0x65f6('0x21')][_0x65f6('0x3e')]);_0x2fc20f[_0x65f6('0x1e')]=qs[_0x65f6('0x3b')](_[_0x65f6('0x3f')](_0x553ff0['query'],_0x5c55e4['filters']));if(_0x553ff0[_0x65f6('0x21')][_0x65f6('0x4d')]){_0x2fc20f['where']=_[_0x65f6('0x2c')](_0x2fc20f['where'],{'$or':_[_0x65f6('0x40')](_0x2fc20f['attributes'],function(_0x440df1){var _0xdc8989={};_0xdc8989[_0x440df1]={'$like':'%'+_0x553ff0[_0x65f6('0x21')][_0x65f6('0x4d')]+'%'};return _0xdc8989;})});}_0x2fc20f=_[_0x65f6('0x2c')]({},_0x2fc20f,_0x553ff0[_0x65f6('0x2d')]);return _0x28682b[_0x65f6('0x4b')](_0x2fc20f);}})[_0x65f6('0x13')](function(_0x2405a7){if(_0x2405a7){_0x26481e=_0x2405a7['length'];if(!_0x553ff0['query'][_0x65f6('0x3c')](_0x65f6('0x4e'))){_0x2fc20f[_0x65f6('0xe')]=qs['limit'](_0x553ff0['query'][_0x65f6('0xe')]);_0x2fc20f[_0x65f6('0xd')]=qs[_0x65f6('0xd')](_0x553ff0[_0x65f6('0x21')][_0x65f6('0xd')]);}return _0x28682b[_0x65f6('0x4b')](_0x2fc20f);}})['then'](function(_0x4f42ae){if(_0x4f42ae){return _0x4f42ae?{'count':_0x26481e,'rows':_0x4f42ae}:null;}})[_0x65f6('0x13')](respondWithResult(_0x2923ff,null))[_0x65f6('0x23')](handleError(_0x2923ff,null));};exports['addTeams']=function(_0x219bf8,_0x4a8b60){var _0x254e9f=_0x219bf8[_0x65f6('0x2f')][_0x65f6('0x4f')];return db[_0x65f6('0x50')]['findAll']({'where':{'id':_0x254e9f},'attributes':['id'],'include':[{'model':db[_0x65f6('0x42')],'as':_0x65f6('0x51'),'attributes':['id',_0x65f6('0x18'),'online','voicePause',_0x65f6('0x52')],'raw':!![]}]})['then'](function(_0x305967){if(_0x305967){var _0xf6de=_[_0x65f6('0x53')](_0x305967,function(_0x354b90){var _0x512776=_0x354b90['get']({'plain':!![]});return _0x512776['Agents'];});return db[_0x65f6('0x1f')][_0x65f6('0x35')]({'where':{'id':_0x219bf8[_0x65f6('0x25')]['id']}})['then'](function(_0x46cbde){return db[_0x65f6('0x54')][_0x65f6('0x55')](function(_0x49cee2){return _0x46cbde[_0x65f6('0x56')](_0x254e9f,{'transaction':_0x49cee2})[_0x65f6('0x13')](function(){return BPromise['each'](_0xf6de,function(_0x758e80){return db[_0x65f6('0x41')]['findOrCreate']({'where':{'UserId':_0x758e80['id'],'SmsQueueId':_0x219bf8[_0x65f6('0x25')]['id']},'transaction':_0x49cee2});});})['then'](function(){_0xf6de[_0x65f6('0x57')](function(_0x55ea91){socket[_0x65f6('0x58')](_0x65f6('0x59'),{'UserId':_0x55ea91['id'],'SmsQueueId':_0x46cbde['id']});});});});});}})['then'](respondWithStatusCode(_0x4a8b60,null))[_0x65f6('0x23')](handleError(_0x4a8b60,null));};exports[_0x65f6('0x5a')]=function(_0x2a700b,_0x299b85){return db[_0x65f6('0x50')][_0x65f6('0x22')]({'where':{'id':_0x2a700b[_0x65f6('0x21')][_0x65f6('0x4f')]},'attributes':['id'],'include':[{'model':db[_0x65f6('0x42')],'as':_0x65f6('0x51'),'attributes':['id'],'raw':!![]}]})[_0x65f6('0x13')](handleEntityNotFound(_0x299b85,null))['then'](function(_0x10a661){var _0x1cf1bd=_[_0x65f6('0x40')](_0x10a661,'id');var _0x219e42=[];var _0x5694f9=[];var _0x453080=squel[_0x65f6('0x5b')]();_0x453080['field'](_0x65f6('0x5c'))['from'](_0x65f6('0x5d'),'tq')['join'](_0x65f6('0x5e'),'ut',_0x65f6('0x5f'))['where']('SmsQueueId\x20=\x20?',_0x2a700b[_0x65f6('0x25')]['id']);for(var _0x413c21=0x0;_0x413c21<_0x10a661['length'];_0x413c21+=0x1){let _0x2d86c8=_0x10a661[_0x413c21];for(var _0x3b3bd5=0x0;_0x3b3bd5<_0x2d86c8[_0x65f6('0x51')]['length'];_0x3b3bd5+=0x1){let _0x1348ec=_0x2d86c8[_0x65f6('0x51')][_0x3b3bd5];var _0x5889dc=_0x453080[_0x65f6('0x60')]();_0x5889dc['where'](_0x65f6('0x61'),_0x1348ec['id']);_0x5694f9['push'](db['sequelize'][_0x65f6('0x21')](_0x5889dc[_0x65f6('0x62')](),{'type':db[_0x65f6('0x54')][_0x65f6('0x63')][_0x65f6('0x64')]})[_0x65f6('0x13')](function(_0x1ac46f){if(_0x1ac46f[_0x65f6('0x4c')]===0x1){return _0x1348ec['id'];}else{var _0x4d66fe=_['every'](_[_0x65f6('0x40')](_0x1ac46f,'TeamId'),function(_0x1ee28a){return _[_0x65f6('0x65')](_0x1cf1bd,_0x1ee28a);});if(_0x4d66fe){return _0x1348ec['id'];}}}));}}return BPromise[_0x65f6('0x66')](_0x5694f9)[_0x65f6('0x13')](function(_0x43127b){_0x219e42=_(_0x219e42)['union'](_0x43127b)[_0x65f6('0x67')]()[_0x65f6('0x68')]();return db[_0x65f6('0x1f')]['find']({'where':{'id':_0x2a700b[_0x65f6('0x25')]['id']}})[_0x65f6('0x13')](function(_0x4254c2){return db[_0x65f6('0x54')][_0x65f6('0x55')](function(_0x16bf93){return _0x4254c2['removeTeams'](_0x2a700b['query'][_0x65f6('0x4f')],{'transaction':_0x16bf93})[_0x65f6('0x13')](function(){if(!_[_0x65f6('0x69')](_0x219e42)){return _0x4254c2[_0x65f6('0x6a')](_0x219e42,{'transaction':_0x16bf93});}})['then'](function(){_0x219e42['forEach'](function(_0x336076){socket[_0x65f6('0x58')](_0x65f6('0x6b'),{'UserId':_0x336076,'SmsQueueId':_0x4254c2['id']});});});});});});})[_0x65f6('0x13')](respondWithStatusCode(_0x299b85,null))[_0x65f6('0x23')](handleError(_0x299b85,null));};exports[_0x65f6('0x6c')]=function(_0x5daaf4,_0x4d607a){return db['SmsQueue'][_0x65f6('0x35')]({'where':{'id':_0x5daaf4[_0x65f6('0x25')]['id']}})[_0x65f6('0x13')](handleEntityNotFound(_0x4d607a,null))[_0x65f6('0x13')](function(_0x53b11c){if(_0x53b11c){return _0x53b11c['addAgents'](_0x5daaf4[_0x65f6('0x2f')][_0x65f6('0x4f')],_['omit'](_0x5daaf4[_0x65f6('0x2f')],['ids','id'])||{})[_0x65f6('0x6d')](function(_0x4f3ef8){for(var _0x3a30ed=0x0;_0x3a30ed<_0x5daaf4[_0x65f6('0x2f')]['ids'][_0x65f6('0x4c')];_0x3a30ed+=0x1){socket[_0x65f6('0x58')](_0x65f6('0x59'),{'UserId':Number(_0x5daaf4[_0x65f6('0x2f')][_0x65f6('0x4f')][_0x3a30ed]),'SmsQueueId':Number(_0x5daaf4[_0x65f6('0x25')]['id'])});}return _0x4f3ef8;});}})['then'](respondWithResult(_0x4d607a,null))[_0x65f6('0x23')](handleError(_0x4d607a,null));};exports['removeAgents']=function(_0x24495c,_0x56336a){return db[_0x65f6('0x1f')][_0x65f6('0x35')]({'where':{'id':_0x24495c[_0x65f6('0x25')]['id']}})[_0x65f6('0x13')](handleEntityNotFound(_0x56336a,null))['then'](function(_0x2b6f98){if(_0x2b6f98){return _0x2b6f98[_0x65f6('0x6a')](_0x24495c[_0x65f6('0x21')]['ids'])['then'](function(){if(_[_0x65f6('0x6e')](_0x24495c[_0x65f6('0x21')]['ids'])){for(var _0x180cde=0x0;_0x180cde<_0x24495c[_0x65f6('0x21')][_0x65f6('0x4f')]['length'];_0x180cde+=0x1){socket[_0x65f6('0x58')](_0x65f6('0x6b'),{'UserId':Number(_0x24495c['query'][_0x65f6('0x4f')][_0x180cde]),'SmsQueueId':Number(_0x24495c[_0x65f6('0x25')]['id'])});}}else{socket[_0x65f6('0x58')]('userSmsQueue:remove',{'UserId':Number(_0x24495c[_0x65f6('0x21')][_0x65f6('0x4f')]),'SmsQueueId':Number(_0x24495c[_0x65f6('0x25')]['id'])});}});}})['then'](respondWithStatusCode(_0x56336a,null))[_0x65f6('0x23')](handleError(_0x56336a,null));};exports['getAgents']=function(_0x1beaa7,_0x87a9e4){var _0x31ec61={};var _0x22be6e={};var _0x29b2de;var _0x430fb8;return db['SmsQueue'][_0x65f6('0x6f')]({'where':{'id':_0x1beaa7[_0x65f6('0x25')]['id']}})[_0x65f6('0x13')](handleEntityNotFound(_0x87a9e4,null))[_0x65f6('0x13')](function(_0x207d15){if(_0x207d15){_0x29b2de=_0x207d15;_0x22be6e['model']=_['keys'](db['User'][_0x65f6('0x3a')]);_0x22be6e[_0x65f6('0x21')]=_[_0x65f6('0x27')](_0x1beaa7['query']);_0x22be6e[_0x65f6('0x3b')]=_['intersection'](_0x22be6e['model'],_0x22be6e[_0x65f6('0x21')]);_0x31ec61[_0x65f6('0x29')]=_['intersection'](_0x22be6e[_0x65f6('0x26')],qs[_0x65f6('0x2a')](_0x1beaa7[_0x65f6('0x21')][_0x65f6('0x2a')]));_0x31ec61[_0x65f6('0x29')]=_0x31ec61[_0x65f6('0x29')][_0x65f6('0x4c')]?_0x31ec61[_0x65f6('0x29')]:_0x22be6e[_0x65f6('0x26')];_0x31ec61[_0x65f6('0x3d')]=qs[_0x65f6('0x3e')](_0x1beaa7[_0x65f6('0x21')]['sort']);_0x31ec61[_0x65f6('0x1e')]=qs['filters'](_['pick'](_0x1beaa7[_0x65f6('0x21')],_0x22be6e[_0x65f6('0x3b')]));if(_0x1beaa7[_0x65f6('0x21')][_0x65f6('0x4d')]){_0x31ec61['where']=_[_0x65f6('0x2c')](_0x31ec61['where'],{'$or':_['map'](_0x31ec61[_0x65f6('0x29')],function(_0x99fe6e){var _0x1a7e52={};_0x1a7e52[_0x99fe6e]={'$like':'%'+_0x1beaa7[_0x65f6('0x21')][_0x65f6('0x4d')]+'%'};return _0x1a7e52;})});}_0x31ec61=_[_0x65f6('0x2c')]({},_0x31ec61,_0x1beaa7['options']);return _0x29b2de[_0x65f6('0x70')](_0x31ec61);}})['then'](function(_0x1ef2a0){if(_0x1ef2a0){_0x430fb8=_0x1ef2a0[_0x65f6('0x4c')];if(!_0x1beaa7[_0x65f6('0x21')]['hasOwnProperty'](_0x65f6('0x4e'))){_0x31ec61['limit']=qs['limit'](_0x1beaa7[_0x65f6('0x21')][_0x65f6('0xe')]);_0x31ec61[_0x65f6('0xd')]=qs[_0x65f6('0xd')](_0x1beaa7[_0x65f6('0x21')]['offset']);}return _0x29b2de[_0x65f6('0x70')](_0x31ec61);}})[_0x65f6('0x13')](function(_0x3bebe3){if(_0x3bebe3){return _0x3bebe3?{'count':_0x430fb8,'rows':_0x3bebe3}:null;}})[_0x65f6('0x13')](respondWithResult(_0x87a9e4,null))['catch'](handleError(_0x87a9e4,null));};
\ No newline at end of file