Built motion from commit d1eab355.|2.6.28
[motion2.git] / server / api / smsQueue / smsQueue.controller.js
index 0b06920..4007293 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x1bc9=['../../config/logger','api','../../config/utils','../../config/environment','../../mysqldb','redis','defaults','localhost','register','sendStatus','status','json','count','offset','limit','Content-Range','apply','save','then','destroy','get','end','error','stack','name','send','index','map','rawAttributes','fieldName','type','model','keys','query','filters','intersection','fields','length','attributes','hasOwnProperty','order','sort','pick','filter','merge','where','VIRTUAL','SmsQueue','includeAll','findAll','rows','catch','params','include','find','create','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','user','SmsQueues','update','body','describe','findOne','UserSmsQueue','nolimit','SmsQueueId','options','User','findAndCountAll','UserId','agent','smsPause','updatedAt','createdAt','format','%s/%s','SIP','Team','getTeams','addTeams','ids','online','voicePause','interface','flatMap','Agents','sequelize','transaction','findOrCreate','removeTeams','field','tq.TeamId','from','team_has_sms_queues','join','user_has_teams','SmsQueueId\x20=\x20?','clone','ut.UserId\x20=\x20?','SELECT','every','TeamId','includes','all','union','compact','value','removeAgents','emit','userSmsQueue:remove','addAgents','spread','userSmsQueue:save','getAgents','html-pdf','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','sox','ejs','lodash','squel','crypto','jsforce','desk.js','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch'];(function(_0x270dba,_0x1817d2){var _0x36b83b=function(_0x15a276){while(--_0x15a276){_0x270dba['push'](_0x270dba['shift']());}};_0x36b83b(++_0x1817d2);}(_0x1bc9,0xfb));var _0x91bc=function(_0x4a8bfd,_0x2849a8){_0x4a8bfd=_0x4a8bfd-0x0;var _0x562bd9=_0x1bc9[_0x4a8bfd];return _0x562bd9;};'use strict';var pdf=require(_0x91bc('0x0'));var emlformat=require(_0x91bc('0x1'));var rimraf=require(_0x91bc('0x2'));var zipdir=require(_0x91bc('0x3'));var jsonpatch=require(_0x91bc('0x4'));var rp=require(_0x91bc('0x5'));var moment=require(_0x91bc('0x6'));var BPromise=require(_0x91bc('0x7'));var Mustache=require(_0x91bc('0x8'));var util=require('util');var path=require('path');var sox=require(_0x91bc('0x9'));var csv=require('to-csv');var ejs=require(_0x91bc('0xa'));var fs=require('fs');var _=require(_0x91bc('0xb'));var squel=require(_0x91bc('0xc'));var crypto=require(_0x91bc('0xd'));var jsforce=require(_0x91bc('0xe'));var deskjs=require(_0x91bc('0xf'));var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require(_0x91bc('0x10'));var Redis=require(_0x91bc('0x11'));var authService=require(_0x91bc('0x12'));var qs=require(_0x91bc('0x13'));var as=require(_0x91bc('0x14'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x91bc('0x15'))(_0x91bc('0x16'));var utils=require(_0x91bc('0x17'));var config=require(_0x91bc('0x18'));var db=require(_0x91bc('0x19'))['db'];config[_0x91bc('0x1a')]=_[_0x91bc('0x1b')](config[_0x91bc('0x1a')],{'host':_0x91bc('0x1c'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x91bc('0x1a')]));require('./smsQueue.socket')[_0x91bc('0x1d')](socket);function respondWithStatusCode(_0xc3c238,_0x247304){_0x247304=_0x247304||0xcc;return function(_0x5d319f){if(_0x5d319f){return _0xc3c238[_0x91bc('0x1e')](_0x247304);}return _0xc3c238[_0x91bc('0x1f')](_0x247304)['end']();};}function respondWithResult(_0x1b77f8,_0x4f9be8){_0x4f9be8=_0x4f9be8||0xc8;return function(_0x4a72c9){if(_0x4a72c9){return _0x1b77f8['status'](_0x4f9be8)[_0x91bc('0x20')](_0x4a72c9);}};}function respondWithFilteredResult(_0x356c24,_0x22f335){return function(_0x31d1ca){if(_0x31d1ca){var _0x5e4f8e=_0x31d1ca[_0x91bc('0x21')],_0x13fac4=_0x22f335[_0x91bc('0x22')],_0x46a2f4=_0x22f335['offset']+_0x22f335[_0x91bc('0x23')],_0x2e3f47;if(_0x46a2f4>=_0x5e4f8e){_0x46a2f4=_0x5e4f8e;_0x2e3f47=0xc8;}else{_0x2e3f47=0xce;}_0x356c24[_0x91bc('0x1f')](_0x2e3f47);return _0x356c24['set'](_0x91bc('0x24'),_0x13fac4+'-'+_0x46a2f4+'/'+_0x5e4f8e)[_0x91bc('0x20')](_0x31d1ca);}return null;};}function patchUpdates(_0x218e1a){return function(_0x1106c4){try{jsonpatch[_0x91bc('0x25')](_0x1106c4,_0x218e1a,!![]);}catch(_0x14003c){return BPromise['reject'](_0x14003c);}return _0x1106c4[_0x91bc('0x26')]();};}function saveUpdates(_0x5ad2fc,_0x9d4488){return function(_0x17154a){if(_0x17154a){return _0x17154a['update'](_0x5ad2fc)[_0x91bc('0x27')](function(_0x5b260e){return _0x5b260e;});}return null;};}function removeEntity(_0x1b9d29,_0x40cec5){return function(_0x9bfa0f){if(_0x9bfa0f){return _0x9bfa0f[_0x91bc('0x28')]()[_0x91bc('0x27')](function(){var _0x3ba807=_0x9bfa0f[_0x91bc('0x29')]({'plain':!![]});var _0x161c0a='SmsQueues';return db['UserProfileResource'][_0x91bc('0x28')]({'where':{'type':_0x161c0a,'resourceId':_0x3ba807['id']}})[_0x91bc('0x27')](function(){return _0x9bfa0f;});})[_0x91bc('0x27')](function(){_0x1b9d29['status'](0xcc)[_0x91bc('0x2a')]();});}};}function handleEntityNotFound(_0xb8ded4,_0x2bd801){return function(_0x4f5cb6){if(!_0x4f5cb6){_0xb8ded4[_0x91bc('0x1e')](0x194);}return _0x4f5cb6;};}function handleError(_0x4ebfec,_0x2c9a50){_0x2c9a50=_0x2c9a50||0x1f4;return function(_0x423e6a){logger[_0x91bc('0x2b')](_0x423e6a[_0x91bc('0x2c')]);if(_0x423e6a[_0x91bc('0x2d')]){delete _0x423e6a[_0x91bc('0x2d')];}_0x4ebfec['status'](_0x2c9a50)[_0x91bc('0x2e')](_0x423e6a);};}exports[_0x91bc('0x2f')]=function(_0x262ac5,_0x4e4062){var _0x1cc31e={},_0x512eb2={},_0x49090b={'count':0x0,'rows':[]};var _0x8b0994=_[_0x91bc('0x30')](db['SmsQueue'][_0x91bc('0x31')],function(_0x509ea8){return{'name':_0x509ea8[_0x91bc('0x32')],'type':_0x509ea8[_0x91bc('0x33')]['key']};});_0x512eb2[_0x91bc('0x34')]=_[_0x91bc('0x30')](_0x8b0994,'name');_0x512eb2['query']=_[_0x91bc('0x35')](_0x262ac5[_0x91bc('0x36')]);_0x512eb2[_0x91bc('0x37')]=_['intersection'](_0x512eb2['model'],_0x512eb2[_0x91bc('0x36')]);_0x1cc31e['attributes']=_[_0x91bc('0x38')](_0x512eb2[_0x91bc('0x34')],qs[_0x91bc('0x39')](_0x262ac5['query'][_0x91bc('0x39')]));_0x1cc31e['attributes']=_0x1cc31e['attributes'][_0x91bc('0x3a')]?_0x1cc31e[_0x91bc('0x3b')]:_0x512eb2[_0x91bc('0x34')];if(!_0x262ac5[_0x91bc('0x36')][_0x91bc('0x3c')]('nolimit')){_0x1cc31e['limit']=qs['limit'](_0x262ac5['query']['limit']);_0x1cc31e[_0x91bc('0x22')]=qs[_0x91bc('0x22')](_0x262ac5['query']['offset']);}_0x1cc31e[_0x91bc('0x3d')]=qs[_0x91bc('0x3e')](_0x262ac5[_0x91bc('0x36')]['sort']);_0x1cc31e['where']=qs[_0x91bc('0x37')](_[_0x91bc('0x3f')](_0x262ac5[_0x91bc('0x36')],_0x512eb2[_0x91bc('0x37')]),_0x8b0994);if(_0x262ac5['query'][_0x91bc('0x40')]){_0x1cc31e['where']=_[_0x91bc('0x41')](_0x1cc31e[_0x91bc('0x42')],{'$or':_[_0x91bc('0x30')](_0x8b0994,function(_0x263673){if(_0x263673[_0x91bc('0x33')]!==_0x91bc('0x43')){var _0x3d5ba8={};_0x3d5ba8[_0x263673[_0x91bc('0x2d')]]={'$like':'%'+_0x262ac5['query'][_0x91bc('0x40')]+'%'};return _0x3d5ba8;}})});}_0x1cc31e=_[_0x91bc('0x41')]({},_0x1cc31e,_0x262ac5['options']);var _0x537d82={'where':_0x1cc31e[_0x91bc('0x42')]};return db[_0x91bc('0x44')][_0x91bc('0x21')](_0x537d82)[_0x91bc('0x27')](function(_0x4440e6){_0x49090b[_0x91bc('0x21')]=_0x4440e6;if(_0x262ac5[_0x91bc('0x36')][_0x91bc('0x45')]){_0x1cc31e['include']=[{'all':!![]}];}return db[_0x91bc('0x44')][_0x91bc('0x46')](_0x1cc31e);})[_0x91bc('0x27')](function(_0x29bdcd){_0x49090b[_0x91bc('0x47')]=_0x29bdcd;return _0x49090b;})['then'](respondWithFilteredResult(_0x4e4062,_0x1cc31e))[_0x91bc('0x48')](handleError(_0x4e4062,null));};exports['show']=function(_0x425ce0,_0x27e414){var _0x3e93fa={'raw':!![],'where':{'id':_0x425ce0[_0x91bc('0x49')]['id']}},_0x525983={};_0x525983['model']=_['keys'](db[_0x91bc('0x44')][_0x91bc('0x31')]);_0x525983[_0x91bc('0x36')]=_[_0x91bc('0x35')](_0x425ce0[_0x91bc('0x36')]);_0x525983['filters']=_['intersection'](_0x525983['model'],_0x525983[_0x91bc('0x36')]);_0x3e93fa[_0x91bc('0x3b')]=_['intersection'](_0x525983[_0x91bc('0x34')],qs[_0x91bc('0x39')](_0x425ce0[_0x91bc('0x36')][_0x91bc('0x39')]));_0x3e93fa['attributes']=_0x3e93fa['attributes'][_0x91bc('0x3a')]?_0x3e93fa['attributes']:_0x525983[_0x91bc('0x34')];if(_0x425ce0[_0x91bc('0x36')][_0x91bc('0x45')]){_0x3e93fa[_0x91bc('0x4a')]=[{'all':!![]}];}_0x3e93fa=_[_0x91bc('0x41')]({},_0x3e93fa,_0x425ce0['options']);return db['SmsQueue'][_0x91bc('0x4b')](_0x3e93fa)[_0x91bc('0x27')](handleEntityNotFound(_0x27e414,null))[_0x91bc('0x27')](respondWithResult(_0x27e414,null))[_0x91bc('0x48')](handleError(_0x27e414,null));};exports[_0x91bc('0x4c')]=function(_0xdfa3bc,_0x5ac7c4){return db[_0x91bc('0x44')][_0x91bc('0x4c')](_0xdfa3bc['body'],{})['then'](function(_0x205607){var _0x3ed5c7=_0xdfa3bc['user'][_0x91bc('0x29')]({'plain':!![]});if(!_0x3ed5c7)throw new Error(_0x91bc('0x4d'));if(_0x3ed5c7[_0x91bc('0x4e')]===_0x91bc('0x4f')){var _0x315513=_0x205607[_0x91bc('0x29')]({'plain':!![]});var _0x115128=_0x91bc('0x50');return db['UserProfileSection'][_0x91bc('0x4b')]({'where':{'name':_0x115128,'userProfileId':_0x3ed5c7['userProfileId']},'raw':!![]})['then'](function(_0x18ec5e){if(_0x18ec5e&&_0x18ec5e['autoAssociation']===0x0){return db['UserProfileResource'][_0x91bc('0x4c')]({'name':_0x315513[_0x91bc('0x2d')],'resourceId':_0x315513['id'],'type':_0x18ec5e[_0x91bc('0x2d')],'sectionId':_0x18ec5e['id']},{})['then'](function(){return _0x205607;});}else{return _0x205607;}})['catch'](function(_0x4588f1){logger[_0x91bc('0x2b')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x4588f1);throw _0x4588f1;});}return _0x205607;})[_0x91bc('0x27')](respondWithResult(_0x5ac7c4,0xc9))['catch'](handleError(_0x5ac7c4,null));};exports[_0x91bc('0x51')]=function(_0x2e8208,_0x23c75f){if(_0x2e8208[_0x91bc('0x52')]['id']){delete _0x2e8208['body']['id'];}return db[_0x91bc('0x44')][_0x91bc('0x4b')]({'where':{'id':_0x2e8208[_0x91bc('0x49')]['id']}})[_0x91bc('0x27')](handleEntityNotFound(_0x23c75f,null))[_0x91bc('0x27')](saveUpdates(_0x2e8208[_0x91bc('0x52')],null))[_0x91bc('0x27')](respondWithResult(_0x23c75f,null))[_0x91bc('0x48')](handleError(_0x23c75f,null));};exports[_0x91bc('0x28')]=function(_0x1fc717,_0x598777){return db[_0x91bc('0x44')]['find']({'where':{'id':_0x1fc717[_0x91bc('0x49')]['id']}})[_0x91bc('0x27')](handleEntityNotFound(_0x598777,null))[_0x91bc('0x27')](removeEntity(_0x598777,null))[_0x91bc('0x48')](handleError(_0x598777,null));};exports[_0x91bc('0x53')]=function(_0x13ca87,_0x22459f){return db[_0x91bc('0x44')][_0x91bc('0x53')]()[_0x91bc('0x27')](respondWithResult(_0x22459f,null))[_0x91bc('0x48')](handleError(_0x22459f,null));};exports['getMembers']=function(_0x34b0e3,_0x5d285a,_0x34428f){var _0x5af259={'raw':!![],'where':{}},_0x48c5d8={},_0x1d8988;return db[_0x91bc('0x44')][_0x91bc('0x54')]({'where':{'id':_0x34b0e3[_0x91bc('0x49')]['id']}})['then'](handleEntityNotFound(_0x5d285a,null))[_0x91bc('0x27')](function(_0x38f3da){if(_0x38f3da){_0x1d8988=_0x38f3da[_0x91bc('0x29')]({'plain':!![]});_0x48c5d8[_0x91bc('0x34')]=_['keys'](db[_0x91bc('0x55')][_0x91bc('0x31')]);_0x48c5d8[_0x91bc('0x36')]=_['keys'](_0x34b0e3[_0x91bc('0x36')]);_0x48c5d8[_0x91bc('0x37')]=_[_0x91bc('0x38')](_0x48c5d8['model'],_0x48c5d8[_0x91bc('0x36')]);_0x5af259[_0x91bc('0x3b')]=_[_0x91bc('0x38')](_0x48c5d8[_0x91bc('0x34')],qs[_0x91bc('0x39')](_0x34b0e3['query'][_0x91bc('0x39')]));_0x5af259['attributes']=_0x5af259[_0x91bc('0x3b')][_0x91bc('0x3a')]?_0x5af259['attributes']:_0x48c5d8[_0x91bc('0x34')];if(!_0x34b0e3[_0x91bc('0x36')][_0x91bc('0x3c')](_0x91bc('0x56'))){_0x5af259[_0x91bc('0x23')]=qs[_0x91bc('0x23')](_0x34b0e3[_0x91bc('0x36')][_0x91bc('0x23')]);_0x5af259[_0x91bc('0x22')]=qs['offset'](_0x34b0e3[_0x91bc('0x36')][_0x91bc('0x22')]);}_0x5af259[_0x91bc('0x3d')]=qs[_0x91bc('0x3e')](_0x34b0e3['query']['sort']);_0x5af259[_0x91bc('0x42')]=qs['filters'](_[_0x91bc('0x3f')](_0x34b0e3[_0x91bc('0x36')],_0x48c5d8[_0x91bc('0x37')]));_0x5af259['where'][_0x91bc('0x57')]=_0x38f3da['id'];if(_0x34b0e3[_0x91bc('0x36')]['filter']){_0x5af259[_0x91bc('0x42')]=_['merge'](_0x5af259[_0x91bc('0x42')],{'$or':_['map'](_0x5af259[_0x91bc('0x3b')],function(_0x3ee36d){var _0x1d45bf={};_0x1d45bf[_0x3ee36d]={'$like':'%'+_0x34b0e3[_0x91bc('0x36')][_0x91bc('0x40')]+'%'};return _0x1d45bf;})});}_0x5af259=_['merge']({},_0x5af259,_0x34b0e3[_0x91bc('0x58')]);return db[_0x91bc('0x55')][_0x91bc('0x46')](_0x5af259);}})[_0x91bc('0x27')](function(_0x497fc2){if(_0x497fc2){return db[_0x91bc('0x59')][_0x91bc('0x5a')]({'where':{'id':_[_0x91bc('0x30')](_0x497fc2,_0x91bc('0x5b')),'role':_0x91bc('0x5c')},'attributes':['id',_0x91bc('0x2d'),_0x91bc('0x5d'),_0x91bc('0x5e'),_0x91bc('0x5f')]});}})[_0x91bc('0x27')](function(_0x44bea0){if(_0x44bea0){return{'count':_0x44bea0[_0x91bc('0x21')],'rows':_[_0x91bc('0x30')](_0x44bea0[_0x91bc('0x47')],function(_0x521df6){return{'membername':_0x521df6[_0x91bc('0x2d')],'UserId':_0x521df6['id'],'queue_name':_0x1d8988[_0x91bc('0x2d')],'SmsQueueId':_0x1d8988['id'],'interface':util[_0x91bc('0x60')](_0x91bc('0x61'),_0x91bc('0x62'),_0x521df6[_0x91bc('0x2d')]),'penalty':0x0,'paused':_0x521df6[_0x91bc('0x5d')],'createdAt':_0x521df6[_0x91bc('0x5f')],'updatedAt':_0x521df6[_0x91bc('0x5e')]};})};}else{return{'count':0x0,'rows':[]};}})[_0x91bc('0x27')](respondWithFilteredResult(_0x5d285a,_0x5af259))[_0x91bc('0x48')](handleError(_0x5d285a,null));};exports['getTeams']=function(_0x518c22,_0x259d2e,_0x273d06){var _0x4052d6={};var _0x15ac09={};var _0x261f1c;var _0x10914d;return db[_0x91bc('0x44')][_0x91bc('0x54')]({'where':{'id':_0x518c22['params']['id']}})[_0x91bc('0x27')](handleEntityNotFound(_0x259d2e,null))[_0x91bc('0x27')](function(_0x243e04){if(_0x243e04){_0x261f1c=_0x243e04;_0x15ac09[_0x91bc('0x34')]=_['keys'](db[_0x91bc('0x63')]['rawAttributes']);_0x15ac09[_0x91bc('0x36')]=_[_0x91bc('0x35')](_0x518c22[_0x91bc('0x36')]);_0x15ac09[_0x91bc('0x37')]=_[_0x91bc('0x38')](_0x15ac09[_0x91bc('0x34')],_0x15ac09['query']);_0x4052d6[_0x91bc('0x3b')]=_['intersection'](_0x15ac09[_0x91bc('0x34')],qs['fields'](_0x518c22[_0x91bc('0x36')][_0x91bc('0x39')]));_0x4052d6[_0x91bc('0x3b')]=_0x4052d6['attributes'][_0x91bc('0x3a')]?_0x4052d6[_0x91bc('0x3b')]:_0x15ac09[_0x91bc('0x34')];_0x4052d6[_0x91bc('0x3d')]=qs[_0x91bc('0x3e')](_0x518c22['query'][_0x91bc('0x3e')]);_0x4052d6[_0x91bc('0x42')]=qs[_0x91bc('0x37')](_[_0x91bc('0x3f')](_0x518c22[_0x91bc('0x36')],_0x15ac09[_0x91bc('0x37')]));if(_0x518c22[_0x91bc('0x36')][_0x91bc('0x40')]){_0x4052d6[_0x91bc('0x42')]=_[_0x91bc('0x41')](_0x4052d6[_0x91bc('0x42')],{'$or':_['map'](_0x4052d6[_0x91bc('0x3b')],function(_0x443ac5){var _0x13c451={};_0x13c451[_0x443ac5]={'$like':'%'+_0x518c22[_0x91bc('0x36')]['filter']+'%'};return _0x13c451;})});}_0x4052d6=_[_0x91bc('0x41')]({},_0x4052d6,_0x518c22[_0x91bc('0x58')]);return _0x261f1c['getTeams'](_0x4052d6);}})['then'](function(_0xc41eaa){if(_0xc41eaa){_0x10914d=_0xc41eaa['length'];if(!_0x518c22[_0x91bc('0x36')][_0x91bc('0x3c')](_0x91bc('0x56'))){_0x4052d6[_0x91bc('0x23')]=qs[_0x91bc('0x23')](_0x518c22[_0x91bc('0x36')][_0x91bc('0x23')]);_0x4052d6['offset']=qs[_0x91bc('0x22')](_0x518c22[_0x91bc('0x36')][_0x91bc('0x22')]);}return _0x261f1c[_0x91bc('0x64')](_0x4052d6);}})[_0x91bc('0x27')](function(_0x2592cd){if(_0x2592cd){return _0x2592cd?{'count':_0x10914d,'rows':_0x2592cd}:null;}})['then'](respondWithResult(_0x259d2e,null))[_0x91bc('0x48')](handleError(_0x259d2e,null));};exports[_0x91bc('0x65')]=function(_0x445d61,_0xf5206,_0x57d4ed){var _0x43b619=_0x445d61[_0x91bc('0x52')][_0x91bc('0x66')];return db[_0x91bc('0x63')][_0x91bc('0x46')]({'where':{'id':_0x43b619},'attributes':['id'],'include':[{'model':db['User'],'as':'Agents','attributes':['id',_0x91bc('0x2d'),_0x91bc('0x67'),_0x91bc('0x68'),_0x91bc('0x69')],'raw':!![]}]})[_0x91bc('0x27')](function(_0x306106){if(_0x306106){var _0x24e9c9=_[_0x91bc('0x6a')](_0x306106,function(_0x34f26e){var _0x2ccb28=_0x34f26e['get']({'plain':!![]});return _0x2ccb28[_0x91bc('0x6b')];});return db['SmsQueue']['find']({'where':{'id':_0x445d61[_0x91bc('0x49')]['id']}})[_0x91bc('0x27')](function(_0xdf47b){return db[_0x91bc('0x6c')][_0x91bc('0x6d')](function(_0x5802f8){return _0xdf47b['addTeams'](_0x43b619,{'transaction':_0x5802f8})['then'](function(){return BPromise['each'](_0x24e9c9,function(_0x311e2e){return db['UserSmsQueue'][_0x91bc('0x6e')]({'where':{'UserId':_0x311e2e['id'],'SmsQueueId':_0x445d61[_0x91bc('0x49')]['id']},'transaction':_0x5802f8});});})[_0x91bc('0x27')](function(){_0x24e9c9['forEach'](function(_0x5df5cc){socket['emit']('userSmsQueue:save',{'UserId':_0x5df5cc['id'],'SmsQueueId':_0xdf47b['id']});});});});});}})['then'](respondWithStatusCode(_0xf5206,null))[_0x91bc('0x48')](handleError(_0xf5206,null));};exports[_0x91bc('0x6f')]=function(_0x374ebb,_0x21e8e7,_0x531c6b){return db['Team'][_0x91bc('0x46')]({'where':{'id':_0x374ebb[_0x91bc('0x36')][_0x91bc('0x66')]},'attributes':['id'],'include':[{'model':db[_0x91bc('0x59')],'as':'Agents','attributes':['id'],'raw':!![]}]})[_0x91bc('0x27')](handleEntityNotFound(_0x21e8e7,null))['then'](function(_0x404204){var _0x1a2506=_[_0x91bc('0x30')](_0x404204,'id');var _0x242966=[];var _0x41d8c1=[];var _0x24ff53=squel['select']();_0x24ff53[_0x91bc('0x70')](_0x91bc('0x71'))[_0x91bc('0x72')](_0x91bc('0x73'),'tq')[_0x91bc('0x74')](_0x91bc('0x75'),'ut','ut.TeamId\x20=\x20tq.TeamId')[_0x91bc('0x42')](_0x91bc('0x76'),_0x374ebb[_0x91bc('0x49')]['id']);for(var _0x597b59=0x0;_0x597b59<_0x404204[_0x91bc('0x3a')];_0x597b59+=0x1){let _0x400da0=_0x404204[_0x597b59];for(var _0x1fd6c6=0x0;_0x1fd6c6<_0x400da0[_0x91bc('0x6b')][_0x91bc('0x3a')];_0x1fd6c6+=0x1){let _0x1a07ad=_0x400da0[_0x91bc('0x6b')][_0x1fd6c6];var _0x590950=_0x24ff53[_0x91bc('0x77')]();_0x590950['where'](_0x91bc('0x78'),_0x1a07ad['id']);_0x41d8c1['push'](db[_0x91bc('0x6c')][_0x91bc('0x36')](_0x590950['toString'](),{'type':db[_0x91bc('0x6c')]['QueryTypes'][_0x91bc('0x79')]})[_0x91bc('0x27')](function(_0x4c63f0){if(_0x4c63f0[_0x91bc('0x3a')]===0x1){return _0x1a07ad['id'];}else{var _0xeb9a39=_[_0x91bc('0x7a')](_[_0x91bc('0x30')](_0x4c63f0,_0x91bc('0x7b')),function(_0x252b04){return _[_0x91bc('0x7c')](_0x1a2506,_0x252b04);});if(_0xeb9a39){return _0x1a07ad['id'];}}}));}}return BPromise[_0x91bc('0x7d')](_0x41d8c1)[_0x91bc('0x27')](function(_0x308992){_0x242966=_(_0x242966)[_0x91bc('0x7e')](_0x308992)[_0x91bc('0x7f')]()[_0x91bc('0x80')]();return db[_0x91bc('0x44')][_0x91bc('0x4b')]({'where':{'id':_0x374ebb[_0x91bc('0x49')]['id']}})['then'](function(_0x3fc5ab){return db[_0x91bc('0x6c')][_0x91bc('0x6d')](function(_0xedd79b){return _0x3fc5ab[_0x91bc('0x6f')](_0x374ebb[_0x91bc('0x36')][_0x91bc('0x66')],{'transaction':_0xedd79b})[_0x91bc('0x27')](function(){if(!_['isEmpty'](_0x242966)){return _0x3fc5ab[_0x91bc('0x81')](_0x242966,{'transaction':_0xedd79b});}})[_0x91bc('0x27')](function(){_0x242966['forEach'](function(_0x10cbd4){socket[_0x91bc('0x82')](_0x91bc('0x83'),{'UserId':_0x10cbd4,'SmsQueueId':_0x3fc5ab['id']});});});});});});})[_0x91bc('0x27')](respondWithStatusCode(_0x21e8e7,null))['catch'](handleError(_0x21e8e7,null));};exports[_0x91bc('0x84')]=function(_0xdcc1dc,_0xefd3b7,_0x260fee){return db[_0x91bc('0x44')]['find']({'where':{'id':_0xdcc1dc[_0x91bc('0x49')]['id']}})[_0x91bc('0x27')](handleEntityNotFound(_0xefd3b7,null))['then'](function(_0x387915){if(_0x387915){return _0x387915[_0x91bc('0x84')](_0xdcc1dc[_0x91bc('0x52')][_0x91bc('0x66')],_['omit'](_0xdcc1dc['body'],[_0x91bc('0x66'),'id'])||{})[_0x91bc('0x85')](function(_0x2ef610){for(var _0x39f04f=0x0;_0x39f04f<_0xdcc1dc[_0x91bc('0x52')][_0x91bc('0x66')][_0x91bc('0x3a')];_0x39f04f+=0x1){socket['emit'](_0x91bc('0x86'),{'UserId':_0xdcc1dc[_0x91bc('0x52')]['ids'][_0x39f04f],'SmsQueueId':_0xdcc1dc[_0x91bc('0x49')]['id']});}return _0x2ef610;});}})[_0x91bc('0x27')](respondWithResult(_0xefd3b7,null))['catch'](handleError(_0xefd3b7,null));};exports[_0x91bc('0x81')]=function(_0x496719,_0x52519d,_0xe7a2cb){return db[_0x91bc('0x44')][_0x91bc('0x4b')]({'where':{'id':_0x496719[_0x91bc('0x49')]['id']}})[_0x91bc('0x27')](handleEntityNotFound(_0x52519d,null))[_0x91bc('0x27')](function(_0x3ff648){if(_0x3ff648){return _0x3ff648[_0x91bc('0x81')](_0x496719['query']['ids'])[_0x91bc('0x27')](function(){if(_['isArray'](_0x496719[_0x91bc('0x36')][_0x91bc('0x66')])){for(var _0xb63358=0x0;_0xb63358<_0x496719[_0x91bc('0x36')]['ids'][_0x91bc('0x3a')];_0xb63358+=0x1){socket[_0x91bc('0x82')](_0x91bc('0x83'),{'UserId':Number(_0x496719[_0x91bc('0x36')][_0x91bc('0x66')][_0xb63358]),'SmsQueueId':Number(_0x496719[_0x91bc('0x49')]['id'])});}}else{socket[_0x91bc('0x82')](_0x91bc('0x83'),{'UserId':Number(_0x496719[_0x91bc('0x36')][_0x91bc('0x66')]),'SmsQueueId':Number(_0x496719[_0x91bc('0x49')]['id'])});}});}})['then'](respondWithStatusCode(_0x52519d,null))['catch'](handleError(_0x52519d,null));};exports['getAgents']=function(_0x288040,_0x420e42,_0x5c6b66){var _0xb6a2de={};var _0x3978c5={};var _0x2bb7d4;var _0x3d26d1;return db['SmsQueue'][_0x91bc('0x54')]({'where':{'id':_0x288040[_0x91bc('0x49')]['id']}})[_0x91bc('0x27')](handleEntityNotFound(_0x420e42,null))[_0x91bc('0x27')](function(_0x21d136){if(_0x21d136){_0x2bb7d4=_0x21d136;_0x3978c5[_0x91bc('0x34')]=_['keys'](db[_0x91bc('0x59')][_0x91bc('0x31')]);_0x3978c5['query']=_[_0x91bc('0x35')](_0x288040[_0x91bc('0x36')]);_0x3978c5[_0x91bc('0x37')]=_['intersection'](_0x3978c5[_0x91bc('0x34')],_0x3978c5['query']);_0xb6a2de[_0x91bc('0x3b')]=_[_0x91bc('0x38')](_0x3978c5['model'],qs[_0x91bc('0x39')](_0x288040['query'][_0x91bc('0x39')]));_0xb6a2de[_0x91bc('0x3b')]=_0xb6a2de['attributes'][_0x91bc('0x3a')]?_0xb6a2de[_0x91bc('0x3b')]:_0x3978c5['model'];_0xb6a2de[_0x91bc('0x3d')]=qs[_0x91bc('0x3e')](_0x288040['query'][_0x91bc('0x3e')]);_0xb6a2de['where']=qs[_0x91bc('0x37')](_[_0x91bc('0x3f')](_0x288040[_0x91bc('0x36')],_0x3978c5[_0x91bc('0x37')]));if(_0x288040[_0x91bc('0x36')][_0x91bc('0x40')]){_0xb6a2de[_0x91bc('0x42')]=_[_0x91bc('0x41')](_0xb6a2de['where'],{'$or':_[_0x91bc('0x30')](_0xb6a2de[_0x91bc('0x3b')],function(_0x18f0f1){var _0x21e133={};_0x21e133[_0x18f0f1]={'$like':'%'+_0x288040['query'][_0x91bc('0x40')]+'%'};return _0x21e133;})});}_0xb6a2de=_[_0x91bc('0x41')]({},_0xb6a2de,_0x288040[_0x91bc('0x58')]);return _0x2bb7d4[_0x91bc('0x87')](_0xb6a2de);}})[_0x91bc('0x27')](function(_0x301b30){if(_0x301b30){_0x3d26d1=_0x301b30[_0x91bc('0x3a')];if(!_0x288040[_0x91bc('0x36')][_0x91bc('0x3c')]('nolimit')){_0xb6a2de[_0x91bc('0x23')]=qs[_0x91bc('0x23')](_0x288040[_0x91bc('0x36')][_0x91bc('0x23')]);_0xb6a2de[_0x91bc('0x22')]=qs[_0x91bc('0x22')](_0x288040[_0x91bc('0x36')][_0x91bc('0x22')]);}return _0x2bb7d4['getAgents'](_0xb6a2de);}})['then'](function(_0x22923b){if(_0x22923b){return _0x22923b?{'count':_0x3d26d1,'rows':_0x22923b}:null;}})[_0x91bc('0x27')](respondWithResult(_0x420e42,null))[_0x91bc('0x48')](handleError(_0x420e42,null));};
\ No newline at end of file
+var _0x5f66=['show','params','model','keys','intersection','attributes','fields','includeAll','merge','options','create','body','user','get','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','SmsQueues','find','userProfileId','error','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','describe','rawAttributes','filters','hasOwnProperty','order','sort','pick','map','UserSmsQueue','User','findAndCountAll','UserId','agent','smsPause','updatedAt','createdAt','%s/%s','SIP','getTeams','length','filter','nolimit','ids','Team','Agents','interface','flatMap','sequelize','transaction','addTeams','forEach','emit','userSmsQueue:save','removeTeams','select','tq.TeamId','team_has_sms_queues','user_has_teams','ut.TeamId\x20=\x20tq.TeamId','clone','ut.UserId\x20=\x20?','toString','QueryTypes','SELECT','includes','all','compact','value','isEmpty','removeAgents','userSmsQueue:remove','addAgents','spread','isArray','findOne','getAgents','util','squel','ioredis','../../components/parsers/qs','../../config/logger','api','../../mysqldb','defaults','redis','./smsQueue.socket','register','end','json','offset','limit','undefined','count','status','update','then','UserProfileResource','destroy','sendStatus','stack','name','send','index','fieldName','key','getOptions','where','SmsQueue','include','query','findAll','catch'];(function(_0x3b2395,_0x1cf2c1){var _0x2e6751=function(_0x4ea274){while(--_0x4ea274){_0x3b2395['push'](_0x3b2395['shift']());}};_0x2e6751(++_0x1cf2c1);}(_0x5f66,0x1a0));var _0x65f6=function(_0x3e5086,_0x48f4a2){_0x3e5086=_0x3e5086-0x0;var _0xfeb102=_0x5f66[_0x3e5086];return _0xfeb102;};'use strict';var BPromise=require('bluebird');var util=require(_0x65f6('0x0'));var _=require('lodash');var squel=require(_0x65f6('0x1'));var Redis=require(_0x65f6('0x2'));var qs=require(_0x65f6('0x3'));var logger=require(_0x65f6('0x4'))(_0x65f6('0x5'));var config=require('../../config/environment');var db=require(_0x65f6('0x6'))['db'];config['redis']=_[_0x65f6('0x7')](config[_0x65f6('0x8')],{'host':'localhost','port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x65f6('0x8')]));require(_0x65f6('0x9'))[_0x65f6('0xa')](socket);function respondWithStatusCode(_0x8f6451,_0xc44c70){_0xc44c70=_0xc44c70||0xcc;return function(_0x14f4c7){if(_0x14f4c7){return _0x8f6451['sendStatus'](_0xc44c70);}return _0x8f6451['status'](_0xc44c70)[_0x65f6('0xb')]();};}function respondWithResult(_0x2f6d5b,_0x264647){_0x264647=_0x264647||0xc8;return function(_0x25c416){if(_0x25c416){return _0x2f6d5b['status'](_0x264647)[_0x65f6('0xc')](_0x25c416);}};}function respondWithFilteredResult(_0x571436,_0x497cf3){return function(_0x2d2dfa){if(_0x2d2dfa){var _0x576875=typeof _0x497cf3[_0x65f6('0xd')]==='undefined'&&typeof _0x497cf3[_0x65f6('0xe')]===_0x65f6('0xf');var _0x2c4ee5=_0x2d2dfa[_0x65f6('0x10')];var _0x369f96=_0x576875?0x0:_0x497cf3[_0x65f6('0xd')];var _0x44144b=_0x576875?_0x2d2dfa[_0x65f6('0x10')]:_0x497cf3[_0x65f6('0xd')]+_0x497cf3[_0x65f6('0xe')];var _0x59154e;if(_0x44144b>=_0x2c4ee5){_0x44144b=_0x2c4ee5;_0x59154e=0xc8;}else{_0x59154e=0xce;}_0x571436[_0x65f6('0x11')](_0x59154e);return _0x571436['set']('Content-Range',_0x369f96+'-'+_0x44144b+'/'+_0x2c4ee5)[_0x65f6('0xc')](_0x2d2dfa);}return null;};}function saveUpdates(_0x5c69f8){return function(_0x37330d){if(_0x37330d){return _0x37330d[_0x65f6('0x12')](_0x5c69f8)[_0x65f6('0x13')](function(_0x1f974c){return _0x1f974c;});}return null;};}function removeEntity(_0xc8660c){return function(_0x18380e){if(_0x18380e){return _0x18380e['destroy']()['then'](function(){var _0x2d538c=_0x18380e['get']({'plain':!![]});var _0x4c81f3='SmsQueues';return db[_0x65f6('0x14')][_0x65f6('0x15')]({'where':{'type':_0x4c81f3,'resourceId':_0x2d538c['id']}})['then'](function(){return _0x18380e;});})[_0x65f6('0x13')](function(){_0xc8660c[_0x65f6('0x11')](0xcc)[_0x65f6('0xb')]();});}};}function handleEntityNotFound(_0x3876ed){return function(_0x219ab2){if(!_0x219ab2){_0x3876ed[_0x65f6('0x16')](0x194);}return _0x219ab2;};}function handleError(_0x581374,_0x197a49){_0x197a49=_0x197a49||0x1f4;return function(_0x4bb39e){logger['error'](_0x4bb39e[_0x65f6('0x17')]);if(_0x4bb39e[_0x65f6('0x18')]){delete _0x4bb39e['name'];}_0x581374[_0x65f6('0x11')](_0x197a49)[_0x65f6('0x19')](_0x4bb39e);};}exports[_0x65f6('0x1a')]=function(_0x2774a1,_0x4f5a69){var _0x9d7bb0={};var _0x59ea32={'count':0x0,'rows':[]};var _0x20a161=_['map'](db['SmsQueue']['rawAttributes'],function(_0x29abdb){return{'name':_0x29abdb[_0x65f6('0x1b')],'type':_0x29abdb['type'][_0x65f6('0x1c')]};});_0x9d7bb0=qs[_0x65f6('0x1d')](_0x20a161,_0x2774a1);var _0x52277c={'where':_0x9d7bb0[_0x65f6('0x1e')]};return db[_0x65f6('0x1f')][_0x65f6('0x10')](_0x52277c)['then'](function(_0x4ac04b){_0x59ea32['count']=_0x4ac04b;_0x9d7bb0[_0x65f6('0x20')]=qs[_0x65f6('0x20')](_0x2774a1[_0x65f6('0x21')]);return db[_0x65f6('0x1f')][_0x65f6('0x22')](_0x9d7bb0);})[_0x65f6('0x13')](function(_0x144e55){_0x59ea32['rows']=_0x144e55;return _0x59ea32;})['then'](respondWithFilteredResult(_0x4f5a69,_0x9d7bb0))[_0x65f6('0x23')](handleError(_0x4f5a69,null));};exports[_0x65f6('0x24')]=function(_0x5878bc,_0x4e50c0){var _0x10b368={'raw':!![],'where':{'id':_0x5878bc[_0x65f6('0x25')]['id']}},_0x1ce43c={};_0x1ce43c[_0x65f6('0x26')]=_[_0x65f6('0x27')](db[_0x65f6('0x1f')]['rawAttributes']);_0x1ce43c[_0x65f6('0x21')]=_[_0x65f6('0x27')](_0x5878bc[_0x65f6('0x21')]);_0x1ce43c['filters']=_[_0x65f6('0x28')](_0x1ce43c[_0x65f6('0x26')],_0x1ce43c[_0x65f6('0x21')]);_0x10b368[_0x65f6('0x29')]=_[_0x65f6('0x28')](_0x1ce43c[_0x65f6('0x26')],qs['fields'](_0x5878bc[_0x65f6('0x21')][_0x65f6('0x2a')]));_0x10b368['attributes']=_0x10b368[_0x65f6('0x29')]['length']?_0x10b368[_0x65f6('0x29')]:_0x1ce43c['model'];if(_0x5878bc[_0x65f6('0x21')][_0x65f6('0x2b')]){_0x10b368['include']=[{'all':!![]}];}_0x10b368=_[_0x65f6('0x2c')]({},_0x10b368,_0x5878bc[_0x65f6('0x2d')]);return db[_0x65f6('0x1f')]['find'](_0x10b368)['then'](handleEntityNotFound(_0x4e50c0,null))[_0x65f6('0x13')](respondWithResult(_0x4e50c0,null))['catch'](handleError(_0x4e50c0,null));};exports[_0x65f6('0x2e')]=function(_0x4e6653,_0x22d760){return db[_0x65f6('0x1f')]['create'](_0x4e6653[_0x65f6('0x2f')],{})['then'](function(_0x5edd04){var _0x71b16b=_0x4e6653[_0x65f6('0x30')][_0x65f6('0x31')]({'plain':!![]});if(!_0x71b16b)throw new Error(_0x65f6('0x32'));if(_0x71b16b[_0x65f6('0x33')]===_0x65f6('0x30')){var _0x1a55da=_0x5edd04[_0x65f6('0x31')]({'plain':!![]});var _0x4f933b=_0x65f6('0x34');return db['UserProfileSection'][_0x65f6('0x35')]({'where':{'name':_0x4f933b,'userProfileId':_0x71b16b[_0x65f6('0x36')]},'raw':!![]})[_0x65f6('0x13')](function(_0x2ea7f7){if(_0x2ea7f7&&_0x2ea7f7['autoAssociation']===0x0){return db[_0x65f6('0x14')][_0x65f6('0x2e')]({'name':_0x1a55da[_0x65f6('0x18')],'resourceId':_0x1a55da['id'],'type':_0x2ea7f7[_0x65f6('0x18')],'sectionId':_0x2ea7f7['id']},{})[_0x65f6('0x13')](function(){return _0x5edd04;});}else{return _0x5edd04;}})[_0x65f6('0x23')](function(_0xed4c96){logger[_0x65f6('0x37')](_0x65f6('0x38'),_0xed4c96);throw _0xed4c96;});}return _0x5edd04;})['then'](respondWithResult(_0x22d760,0xc9))[_0x65f6('0x23')](handleError(_0x22d760,null));};exports[_0x65f6('0x12')]=function(_0x377ae5,_0x181798){if(_0x377ae5[_0x65f6('0x2f')]['id']){delete _0x377ae5[_0x65f6('0x2f')]['id'];}return db[_0x65f6('0x1f')][_0x65f6('0x35')]({'where':{'id':_0x377ae5[_0x65f6('0x25')]['id']}})[_0x65f6('0x13')](handleEntityNotFound(_0x181798,null))[_0x65f6('0x13')](saveUpdates(_0x377ae5[_0x65f6('0x2f')],null))[_0x65f6('0x13')](respondWithResult(_0x181798,null))[_0x65f6('0x23')](handleError(_0x181798,null));};exports[_0x65f6('0x15')]=function(_0x2cb38d,_0x5119ee){return db[_0x65f6('0x1f')][_0x65f6('0x35')]({'where':{'id':_0x2cb38d[_0x65f6('0x25')]['id']}})[_0x65f6('0x13')](handleEntityNotFound(_0x5119ee,null))['then'](removeEntity(_0x5119ee,null))[_0x65f6('0x23')](handleError(_0x5119ee,null));};exports[_0x65f6('0x39')]=function(_0x2b01eb,_0x5e69b4){return db[_0x65f6('0x1f')][_0x65f6('0x39')]()[_0x65f6('0x13')](respondWithResult(_0x5e69b4,null))[_0x65f6('0x23')](handleError(_0x5e69b4,null));};exports['getMembers']=function(_0x2ec114,_0x512527){var _0x3f1baa={'raw':!![],'where':{}},_0x6968b={},_0x577c93;return db[_0x65f6('0x1f')]['findOne']({'where':{'id':_0x2ec114[_0x65f6('0x25')]['id']}})[_0x65f6('0x13')](handleEntityNotFound(_0x512527,null))[_0x65f6('0x13')](function(_0xc0db01){if(_0xc0db01){_0x577c93=_0xc0db01[_0x65f6('0x31')]({'plain':!![]});_0x6968b[_0x65f6('0x26')]=_['keys'](db['UserSmsQueue'][_0x65f6('0x3a')]);_0x6968b[_0x65f6('0x21')]=_[_0x65f6('0x27')](_0x2ec114[_0x65f6('0x21')]);_0x6968b[_0x65f6('0x3b')]=_[_0x65f6('0x28')](_0x6968b[_0x65f6('0x26')],_0x6968b[_0x65f6('0x21')]);_0x3f1baa[_0x65f6('0x29')]=_['intersection'](_0x6968b[_0x65f6('0x26')],qs[_0x65f6('0x2a')](_0x2ec114[_0x65f6('0x21')]['fields']));_0x3f1baa[_0x65f6('0x29')]=_0x3f1baa[_0x65f6('0x29')]['length']?_0x3f1baa[_0x65f6('0x29')]:_0x6968b[_0x65f6('0x26')];if(!_0x2ec114['query'][_0x65f6('0x3c')]('nolimit')){_0x3f1baa[_0x65f6('0xe')]=qs[_0x65f6('0xe')](_0x2ec114[_0x65f6('0x21')]['limit']);_0x3f1baa[_0x65f6('0xd')]=qs[_0x65f6('0xd')](_0x2ec114['query'][_0x65f6('0xd')]);}_0x3f1baa[_0x65f6('0x3d')]=qs['sort'](_0x2ec114[_0x65f6('0x21')][_0x65f6('0x3e')]);_0x3f1baa[_0x65f6('0x1e')]=qs[_0x65f6('0x3b')](_[_0x65f6('0x3f')](_0x2ec114[_0x65f6('0x21')],_0x6968b[_0x65f6('0x3b')]));_0x3f1baa[_0x65f6('0x1e')]['SmsQueueId']=_0xc0db01['id'];if(_0x2ec114['query']['filter']){_0x3f1baa[_0x65f6('0x1e')]=_[_0x65f6('0x2c')](_0x3f1baa[_0x65f6('0x1e')],{'$or':_[_0x65f6('0x40')](_0x3f1baa['attributes'],function(_0x183c08){var _0x2032b9={};_0x2032b9[_0x183c08]={'$like':'%'+_0x2ec114[_0x65f6('0x21')]['filter']+'%'};return _0x2032b9;})});}_0x3f1baa=_[_0x65f6('0x2c')]({},_0x3f1baa,_0x2ec114[_0x65f6('0x2d')]);return db[_0x65f6('0x41')]['findAll'](_0x3f1baa);}})['then'](function(_0x1d337d){if(_0x1d337d){return db[_0x65f6('0x42')][_0x65f6('0x43')]({'where':{'id':_[_0x65f6('0x40')](_0x1d337d,_0x65f6('0x44')),'role':_0x65f6('0x45')},'attributes':['id',_0x65f6('0x18'),_0x65f6('0x46'),_0x65f6('0x47'),_0x65f6('0x48')]});}})[_0x65f6('0x13')](function(_0x141fcc){if(_0x141fcc){return{'count':_0x141fcc[_0x65f6('0x10')],'rows':_[_0x65f6('0x40')](_0x141fcc['rows'],function(_0x47610a){return{'membername':_0x47610a[_0x65f6('0x18')],'UserId':_0x47610a['id'],'queue_name':_0x577c93[_0x65f6('0x18')],'SmsQueueId':_0x577c93['id'],'interface':util['format'](_0x65f6('0x49'),_0x65f6('0x4a'),_0x47610a[_0x65f6('0x18')]),'penalty':0x0,'paused':_0x47610a[_0x65f6('0x46')],'createdAt':_0x47610a['createdAt'],'updatedAt':_0x47610a[_0x65f6('0x47')]};})};}else{return{'count':0x0,'rows':[]};}})[_0x65f6('0x13')](respondWithFilteredResult(_0x512527,_0x3f1baa))[_0x65f6('0x23')](handleError(_0x512527,null));};exports[_0x65f6('0x4b')]=function(_0x553ff0,_0x2923ff){var _0x2fc20f={};var _0x5c55e4={};var _0x28682b;var _0x26481e;return db[_0x65f6('0x1f')]['findOne']({'where':{'id':_0x553ff0[_0x65f6('0x25')]['id']}})[_0x65f6('0x13')](handleEntityNotFound(_0x2923ff,null))[_0x65f6('0x13')](function(_0x3c23e3){if(_0x3c23e3){_0x28682b=_0x3c23e3;_0x5c55e4[_0x65f6('0x26')]=_[_0x65f6('0x27')](db['Team']['rawAttributes']);_0x5c55e4['query']=_[_0x65f6('0x27')](_0x553ff0[_0x65f6('0x21')]);_0x5c55e4[_0x65f6('0x3b')]=_[_0x65f6('0x28')](_0x5c55e4[_0x65f6('0x26')],_0x5c55e4[_0x65f6('0x21')]);_0x2fc20f['attributes']=_[_0x65f6('0x28')](_0x5c55e4[_0x65f6('0x26')],qs['fields'](_0x553ff0[_0x65f6('0x21')][_0x65f6('0x2a')]));_0x2fc20f[_0x65f6('0x29')]=_0x2fc20f['attributes'][_0x65f6('0x4c')]?_0x2fc20f[_0x65f6('0x29')]:_0x5c55e4['model'];_0x2fc20f[_0x65f6('0x3d')]=qs[_0x65f6('0x3e')](_0x553ff0[_0x65f6('0x21')][_0x65f6('0x3e')]);_0x2fc20f[_0x65f6('0x1e')]=qs[_0x65f6('0x3b')](_[_0x65f6('0x3f')](_0x553ff0['query'],_0x5c55e4['filters']));if(_0x553ff0[_0x65f6('0x21')][_0x65f6('0x4d')]){_0x2fc20f['where']=_[_0x65f6('0x2c')](_0x2fc20f['where'],{'$or':_[_0x65f6('0x40')](_0x2fc20f['attributes'],function(_0x440df1){var _0xdc8989={};_0xdc8989[_0x440df1]={'$like':'%'+_0x553ff0[_0x65f6('0x21')][_0x65f6('0x4d')]+'%'};return _0xdc8989;})});}_0x2fc20f=_[_0x65f6('0x2c')]({},_0x2fc20f,_0x553ff0[_0x65f6('0x2d')]);return _0x28682b[_0x65f6('0x4b')](_0x2fc20f);}})[_0x65f6('0x13')](function(_0x2405a7){if(_0x2405a7){_0x26481e=_0x2405a7['length'];if(!_0x553ff0['query'][_0x65f6('0x3c')](_0x65f6('0x4e'))){_0x2fc20f[_0x65f6('0xe')]=qs['limit'](_0x553ff0['query'][_0x65f6('0xe')]);_0x2fc20f[_0x65f6('0xd')]=qs[_0x65f6('0xd')](_0x553ff0[_0x65f6('0x21')][_0x65f6('0xd')]);}return _0x28682b[_0x65f6('0x4b')](_0x2fc20f);}})['then'](function(_0x4f42ae){if(_0x4f42ae){return _0x4f42ae?{'count':_0x26481e,'rows':_0x4f42ae}:null;}})[_0x65f6('0x13')](respondWithResult(_0x2923ff,null))[_0x65f6('0x23')](handleError(_0x2923ff,null));};exports['addTeams']=function(_0x219bf8,_0x4a8b60){var _0x254e9f=_0x219bf8[_0x65f6('0x2f')][_0x65f6('0x4f')];return db[_0x65f6('0x50')]['findAll']({'where':{'id':_0x254e9f},'attributes':['id'],'include':[{'model':db[_0x65f6('0x42')],'as':_0x65f6('0x51'),'attributes':['id',_0x65f6('0x18'),'online','voicePause',_0x65f6('0x52')],'raw':!![]}]})['then'](function(_0x305967){if(_0x305967){var _0xf6de=_[_0x65f6('0x53')](_0x305967,function(_0x354b90){var _0x512776=_0x354b90['get']({'plain':!![]});return _0x512776['Agents'];});return db[_0x65f6('0x1f')][_0x65f6('0x35')]({'where':{'id':_0x219bf8[_0x65f6('0x25')]['id']}})['then'](function(_0x46cbde){return db[_0x65f6('0x54')][_0x65f6('0x55')](function(_0x49cee2){return _0x46cbde[_0x65f6('0x56')](_0x254e9f,{'transaction':_0x49cee2})[_0x65f6('0x13')](function(){return BPromise['each'](_0xf6de,function(_0x758e80){return db[_0x65f6('0x41')]['findOrCreate']({'where':{'UserId':_0x758e80['id'],'SmsQueueId':_0x219bf8[_0x65f6('0x25')]['id']},'transaction':_0x49cee2});});})['then'](function(){_0xf6de[_0x65f6('0x57')](function(_0x55ea91){socket[_0x65f6('0x58')](_0x65f6('0x59'),{'UserId':_0x55ea91['id'],'SmsQueueId':_0x46cbde['id']});});});});});}})['then'](respondWithStatusCode(_0x4a8b60,null))[_0x65f6('0x23')](handleError(_0x4a8b60,null));};exports[_0x65f6('0x5a')]=function(_0x2a700b,_0x299b85){return db[_0x65f6('0x50')][_0x65f6('0x22')]({'where':{'id':_0x2a700b[_0x65f6('0x21')][_0x65f6('0x4f')]},'attributes':['id'],'include':[{'model':db[_0x65f6('0x42')],'as':_0x65f6('0x51'),'attributes':['id'],'raw':!![]}]})[_0x65f6('0x13')](handleEntityNotFound(_0x299b85,null))['then'](function(_0x10a661){var _0x1cf1bd=_[_0x65f6('0x40')](_0x10a661,'id');var _0x219e42=[];var _0x5694f9=[];var _0x453080=squel[_0x65f6('0x5b')]();_0x453080['field'](_0x65f6('0x5c'))['from'](_0x65f6('0x5d'),'tq')['join'](_0x65f6('0x5e'),'ut',_0x65f6('0x5f'))['where']('SmsQueueId\x20=\x20?',_0x2a700b[_0x65f6('0x25')]['id']);for(var _0x413c21=0x0;_0x413c21<_0x10a661['length'];_0x413c21+=0x1){let _0x2d86c8=_0x10a661[_0x413c21];for(var _0x3b3bd5=0x0;_0x3b3bd5<_0x2d86c8[_0x65f6('0x51')]['length'];_0x3b3bd5+=0x1){let _0x1348ec=_0x2d86c8[_0x65f6('0x51')][_0x3b3bd5];var _0x5889dc=_0x453080[_0x65f6('0x60')]();_0x5889dc['where'](_0x65f6('0x61'),_0x1348ec['id']);_0x5694f9['push'](db['sequelize'][_0x65f6('0x21')](_0x5889dc[_0x65f6('0x62')](),{'type':db[_0x65f6('0x54')][_0x65f6('0x63')][_0x65f6('0x64')]})[_0x65f6('0x13')](function(_0x1ac46f){if(_0x1ac46f[_0x65f6('0x4c')]===0x1){return _0x1348ec['id'];}else{var _0x4d66fe=_['every'](_[_0x65f6('0x40')](_0x1ac46f,'TeamId'),function(_0x1ee28a){return _[_0x65f6('0x65')](_0x1cf1bd,_0x1ee28a);});if(_0x4d66fe){return _0x1348ec['id'];}}}));}}return BPromise[_0x65f6('0x66')](_0x5694f9)[_0x65f6('0x13')](function(_0x43127b){_0x219e42=_(_0x219e42)['union'](_0x43127b)[_0x65f6('0x67')]()[_0x65f6('0x68')]();return db[_0x65f6('0x1f')]['find']({'where':{'id':_0x2a700b[_0x65f6('0x25')]['id']}})[_0x65f6('0x13')](function(_0x4254c2){return db[_0x65f6('0x54')][_0x65f6('0x55')](function(_0x16bf93){return _0x4254c2['removeTeams'](_0x2a700b['query'][_0x65f6('0x4f')],{'transaction':_0x16bf93})[_0x65f6('0x13')](function(){if(!_[_0x65f6('0x69')](_0x219e42)){return _0x4254c2[_0x65f6('0x6a')](_0x219e42,{'transaction':_0x16bf93});}})['then'](function(){_0x219e42['forEach'](function(_0x336076){socket[_0x65f6('0x58')](_0x65f6('0x6b'),{'UserId':_0x336076,'SmsQueueId':_0x4254c2['id']});});});});});});})[_0x65f6('0x13')](respondWithStatusCode(_0x299b85,null))[_0x65f6('0x23')](handleError(_0x299b85,null));};exports[_0x65f6('0x6c')]=function(_0x5daaf4,_0x4d607a){return db['SmsQueue'][_0x65f6('0x35')]({'where':{'id':_0x5daaf4[_0x65f6('0x25')]['id']}})[_0x65f6('0x13')](handleEntityNotFound(_0x4d607a,null))[_0x65f6('0x13')](function(_0x53b11c){if(_0x53b11c){return _0x53b11c['addAgents'](_0x5daaf4[_0x65f6('0x2f')][_0x65f6('0x4f')],_['omit'](_0x5daaf4[_0x65f6('0x2f')],['ids','id'])||{})[_0x65f6('0x6d')](function(_0x4f3ef8){for(var _0x3a30ed=0x0;_0x3a30ed<_0x5daaf4[_0x65f6('0x2f')]['ids'][_0x65f6('0x4c')];_0x3a30ed+=0x1){socket[_0x65f6('0x58')](_0x65f6('0x59'),{'UserId':Number(_0x5daaf4[_0x65f6('0x2f')][_0x65f6('0x4f')][_0x3a30ed]),'SmsQueueId':Number(_0x5daaf4[_0x65f6('0x25')]['id'])});}return _0x4f3ef8;});}})['then'](respondWithResult(_0x4d607a,null))[_0x65f6('0x23')](handleError(_0x4d607a,null));};exports['removeAgents']=function(_0x24495c,_0x56336a){return db[_0x65f6('0x1f')][_0x65f6('0x35')]({'where':{'id':_0x24495c[_0x65f6('0x25')]['id']}})[_0x65f6('0x13')](handleEntityNotFound(_0x56336a,null))['then'](function(_0x2b6f98){if(_0x2b6f98){return _0x2b6f98[_0x65f6('0x6a')](_0x24495c[_0x65f6('0x21')]['ids'])['then'](function(){if(_[_0x65f6('0x6e')](_0x24495c[_0x65f6('0x21')]['ids'])){for(var _0x180cde=0x0;_0x180cde<_0x24495c[_0x65f6('0x21')][_0x65f6('0x4f')]['length'];_0x180cde+=0x1){socket[_0x65f6('0x58')](_0x65f6('0x6b'),{'UserId':Number(_0x24495c['query'][_0x65f6('0x4f')][_0x180cde]),'SmsQueueId':Number(_0x24495c[_0x65f6('0x25')]['id'])});}}else{socket[_0x65f6('0x58')]('userSmsQueue:remove',{'UserId':Number(_0x24495c[_0x65f6('0x21')][_0x65f6('0x4f')]),'SmsQueueId':Number(_0x24495c[_0x65f6('0x25')]['id'])});}});}})['then'](respondWithStatusCode(_0x56336a,null))[_0x65f6('0x23')](handleError(_0x56336a,null));};exports['getAgents']=function(_0x1beaa7,_0x87a9e4){var _0x31ec61={};var _0x22be6e={};var _0x29b2de;var _0x430fb8;return db['SmsQueue'][_0x65f6('0x6f')]({'where':{'id':_0x1beaa7[_0x65f6('0x25')]['id']}})[_0x65f6('0x13')](handleEntityNotFound(_0x87a9e4,null))[_0x65f6('0x13')](function(_0x207d15){if(_0x207d15){_0x29b2de=_0x207d15;_0x22be6e['model']=_['keys'](db['User'][_0x65f6('0x3a')]);_0x22be6e[_0x65f6('0x21')]=_[_0x65f6('0x27')](_0x1beaa7['query']);_0x22be6e[_0x65f6('0x3b')]=_['intersection'](_0x22be6e['model'],_0x22be6e[_0x65f6('0x21')]);_0x31ec61[_0x65f6('0x29')]=_['intersection'](_0x22be6e[_0x65f6('0x26')],qs[_0x65f6('0x2a')](_0x1beaa7[_0x65f6('0x21')][_0x65f6('0x2a')]));_0x31ec61[_0x65f6('0x29')]=_0x31ec61[_0x65f6('0x29')][_0x65f6('0x4c')]?_0x31ec61[_0x65f6('0x29')]:_0x22be6e[_0x65f6('0x26')];_0x31ec61[_0x65f6('0x3d')]=qs[_0x65f6('0x3e')](_0x1beaa7[_0x65f6('0x21')]['sort']);_0x31ec61[_0x65f6('0x1e')]=qs['filters'](_['pick'](_0x1beaa7[_0x65f6('0x21')],_0x22be6e[_0x65f6('0x3b')]));if(_0x1beaa7[_0x65f6('0x21')][_0x65f6('0x4d')]){_0x31ec61['where']=_[_0x65f6('0x2c')](_0x31ec61['where'],{'$or':_['map'](_0x31ec61[_0x65f6('0x29')],function(_0x99fe6e){var _0x1a7e52={};_0x1a7e52[_0x99fe6e]={'$like':'%'+_0x1beaa7[_0x65f6('0x21')][_0x65f6('0x4d')]+'%'};return _0x1a7e52;})});}_0x31ec61=_[_0x65f6('0x2c')]({},_0x31ec61,_0x1beaa7['options']);return _0x29b2de[_0x65f6('0x70')](_0x31ec61);}})['then'](function(_0x1ef2a0){if(_0x1ef2a0){_0x430fb8=_0x1ef2a0[_0x65f6('0x4c')];if(!_0x1beaa7[_0x65f6('0x21')]['hasOwnProperty'](_0x65f6('0x4e'))){_0x31ec61['limit']=qs['limit'](_0x1beaa7[_0x65f6('0x21')][_0x65f6('0xe')]);_0x31ec61[_0x65f6('0xd')]=qs[_0x65f6('0xd')](_0x1beaa7[_0x65f6('0x21')]['offset']);}return _0x29b2de[_0x65f6('0x70')](_0x31ec61);}})[_0x65f6('0x13')](function(_0x3bebe3){if(_0x3bebe3){return _0x3bebe3?{'count':_0x430fb8,'rows':_0x3bebe3}:null;}})[_0x65f6('0x13')](respondWithResult(_0x87a9e4,null))['catch'](handleError(_0x87a9e4,null));};
\ No newline at end of file