Built motion from commit d1eab355.|2.6.28
[motion2.git] / server / api / smsQueue / smsQueue.controller.js
index af93e00..4007293 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x5430=['../../config/environment','../../config/license/util','../../mysqldb','redis','defaults','localhost','socket.io-emitter','register','sendStatus','status','end','json','offset','limit','count','set','Content-Range','apply','update','then','destroy','SmsQueues','UserProfileResource','stack','name','send','index','map','SmsQueue','rawAttributes','fieldName','key','model','keys','filters','intersection','query','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','filter','type','VIRTUAL','merge','options','includeAll','include','findAll','catch','show','find','create','body','get','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','user','UserProfileSection','userProfileId','autoAssociation','error','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','params','describe','getMembers','findOne','UserSmsQueue','SmsQueueId','User','findAndCountAll','UserId','smsPause','updatedAt','createdAt','rows','%s/%s','SIP','getTeams','pick','addTeams','ids','Team','online','voicePause','flatMap','Agents','sequelize','each','findOrCreate','forEach','emit','userSmsQueue:save','removeTeams','select','field','from','team_has_sms_queues','join','user_has_teams','SmsQueueId\x20=\x20?','clone','ut.UserId\x20=\x20?','toString','QueryTypes','SELECT','every','TeamId','includes','all','union','transaction','removeAgents','userSmsQueue:remove','addAgents','omit','spread','isArray','getAgents','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','util','to-csv','ejs','fs-extra','lodash','squel','jsforce','desk.js','querystring','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/utils'];(function(_0x35c5a8,_0x8ecb48){var _0x34782c=function(_0x1b23ec){while(--_0x1b23ec){_0x35c5a8['push'](_0x35c5a8['shift']());}};_0x34782c(++_0x8ecb48);}(_0x5430,0x10c));var _0x0543=function(_0x226daf,_0x1dd1d8){_0x226daf=_0x226daf-0x0;var _0x510165=_0x5430[_0x226daf];return _0x510165;};'use strict';var emlformat=require(_0x0543('0x0'));var rimraf=require(_0x0543('0x1'));var zipdir=require(_0x0543('0x2'));var jsonpatch=require(_0x0543('0x3'));var rp=require(_0x0543('0x4'));var moment=require(_0x0543('0x5'));var BPromise=require('bluebird');var Mustache=require('mustache');var util=require(_0x0543('0x6'));var path=require('path');var sox=require('sox');var csv=require(_0x0543('0x7'));var ejs=require(_0x0543('0x8'));var fs=require('fs');var fs_extra=require(_0x0543('0x9'));var _=require(_0x0543('0xa'));var squel=require(_0x0543('0xb'));var crypto=require('crypto');var jsforce=require(_0x0543('0xc'));var deskjs=require(_0x0543('0xd'));var toCsv=require(_0x0543('0x7'));var querystring=require(_0x0543('0xe'));var Papa=require(_0x0543('0xf'));var Redis=require(_0x0543('0x10'));var authService=require('../../components/auth/service');var qs=require(_0x0543('0x11'));var as=require(_0x0543('0x12'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x0543('0x13'))(_0x0543('0x14'));var utils=require(_0x0543('0x15'));var config=require(_0x0543('0x16'));var licenseUtil=require(_0x0543('0x17'));var db=require(_0x0543('0x18'))['db'];config[_0x0543('0x19')]=_[_0x0543('0x1a')](config[_0x0543('0x19')],{'host':_0x0543('0x1b'),'port':0x18eb});var socket=require(_0x0543('0x1c'))(new Redis(config[_0x0543('0x19')]));require('./smsQueue.socket')[_0x0543('0x1d')](socket);function respondWithStatusCode(_0x21e9ac,_0x4d2a27){_0x4d2a27=_0x4d2a27||0xcc;return function(_0x4c4763){if(_0x4c4763){return _0x21e9ac[_0x0543('0x1e')](_0x4d2a27);}return _0x21e9ac[_0x0543('0x1f')](_0x4d2a27)[_0x0543('0x20')]();};}function respondWithResult(_0x1cfadf,_0x38a32e){_0x38a32e=_0x38a32e||0xc8;return function(_0x50d504){if(_0x50d504){return _0x1cfadf[_0x0543('0x1f')](_0x38a32e)[_0x0543('0x21')](_0x50d504);}};}function respondWithFilteredResult(_0x2dd5cb,_0x25254e){return function(_0x20b396){if(_0x20b396){var _0x285080=typeof _0x25254e[_0x0543('0x22')]==='undefined'&&typeof _0x25254e[_0x0543('0x23')]==='undefined';var _0x50ea84=_0x20b396[_0x0543('0x24')];var _0x419913=_0x285080?0x0:_0x25254e[_0x0543('0x22')];var _0x52eb53=_0x285080?_0x20b396[_0x0543('0x24')]:_0x25254e['offset']+_0x25254e[_0x0543('0x23')];var _0x411ec2;if(_0x52eb53>=_0x50ea84){_0x52eb53=_0x50ea84;_0x411ec2=0xc8;}else{_0x411ec2=0xce;}_0x2dd5cb['status'](_0x411ec2);return _0x2dd5cb[_0x0543('0x25')](_0x0543('0x26'),_0x419913+'-'+_0x52eb53+'/'+_0x50ea84)[_0x0543('0x21')](_0x20b396);}return null;};}function patchUpdates(_0x110060){return function(_0x37347e){try{jsonpatch[_0x0543('0x27')](_0x37347e,_0x110060,!![]);}catch(_0x4adba7){return BPromise['reject'](_0x4adba7);}return _0x37347e['save']();};}function saveUpdates(_0xbfe5dc,_0x25b3a1){return function(_0x15ebeb){if(_0x15ebeb){return _0x15ebeb[_0x0543('0x28')](_0xbfe5dc)[_0x0543('0x29')](function(_0x26e500){return _0x26e500;});}return null;};}function removeEntity(_0x36d824,_0x17a3de){return function(_0x1fca8a){if(_0x1fca8a){return _0x1fca8a[_0x0543('0x2a')]()[_0x0543('0x29')](function(){var _0x21fc63=_0x1fca8a['get']({'plain':!![]});var _0x25e6f1=_0x0543('0x2b');return db[_0x0543('0x2c')]['destroy']({'where':{'type':_0x25e6f1,'resourceId':_0x21fc63['id']}})[_0x0543('0x29')](function(){return _0x1fca8a;});})[_0x0543('0x29')](function(){_0x36d824[_0x0543('0x1f')](0xcc)[_0x0543('0x20')]();});}};}function handleEntityNotFound(_0x5dd789,_0x1732be){return function(_0x10b9f3){if(!_0x10b9f3){_0x5dd789['sendStatus'](0x194);}return _0x10b9f3;};}function handleError(_0x576084,_0x3b71f0){_0x3b71f0=_0x3b71f0||0x1f4;return function(_0x16165c){logger['error'](_0x16165c[_0x0543('0x2d')]);if(_0x16165c[_0x0543('0x2e')]){delete _0x16165c[_0x0543('0x2e')];}_0x576084[_0x0543('0x1f')](_0x3b71f0)[_0x0543('0x2f')](_0x16165c);};}exports[_0x0543('0x30')]=function(_0x164bbf,_0x4f9b63){var _0x45ac71={},_0x4f6ded={},_0x2819b8={'count':0x0,'rows':[]};var _0x282787=_[_0x0543('0x31')](db[_0x0543('0x32')][_0x0543('0x33')],function(_0x57aaa2){return{'name':_0x57aaa2[_0x0543('0x34')],'type':_0x57aaa2['type'][_0x0543('0x35')]};});_0x4f6ded[_0x0543('0x36')]=_[_0x0543('0x31')](_0x282787,_0x0543('0x2e'));_0x4f6ded['query']=_[_0x0543('0x37')](_0x164bbf['query']);_0x4f6ded[_0x0543('0x38')]=_[_0x0543('0x39')](_0x4f6ded[_0x0543('0x36')],_0x4f6ded[_0x0543('0x3a')]);_0x45ac71[_0x0543('0x3b')]=_[_0x0543('0x39')](_0x4f6ded[_0x0543('0x36')],qs[_0x0543('0x3c')](_0x164bbf[_0x0543('0x3a')][_0x0543('0x3c')]));_0x45ac71['attributes']=_0x45ac71[_0x0543('0x3b')][_0x0543('0x3d')]?_0x45ac71['attributes']:_0x4f6ded[_0x0543('0x36')];if(!_0x164bbf['query'][_0x0543('0x3e')](_0x0543('0x3f'))){_0x45ac71['limit']=qs['limit'](_0x164bbf[_0x0543('0x3a')][_0x0543('0x23')]);_0x45ac71['offset']=qs[_0x0543('0x22')](_0x164bbf[_0x0543('0x3a')]['offset']);}_0x45ac71[_0x0543('0x40')]=qs[_0x0543('0x41')](_0x164bbf[_0x0543('0x3a')][_0x0543('0x41')]);_0x45ac71[_0x0543('0x42')]=qs['filters'](_['pick'](_0x164bbf['query'],_0x4f6ded[_0x0543('0x38')]),_0x282787);if(_0x164bbf[_0x0543('0x3a')][_0x0543('0x43')]){_0x45ac71[_0x0543('0x42')]=_['merge'](_0x45ac71[_0x0543('0x42')],{'$or':_[_0x0543('0x31')](_0x282787,function(_0xe3936f){if(_0xe3936f[_0x0543('0x44')]!==_0x0543('0x45')){var _0x714fa8={};_0x714fa8[_0xe3936f[_0x0543('0x2e')]]={'$like':'%'+_0x164bbf['query'][_0x0543('0x43')]+'%'};return _0x714fa8;}})});}_0x45ac71=_[_0x0543('0x46')]({},_0x45ac71,_0x164bbf[_0x0543('0x47')]);var _0x1b38bc={'where':_0x45ac71[_0x0543('0x42')]};return db[_0x0543('0x32')]['count'](_0x1b38bc)['then'](function(_0x44116a){_0x2819b8[_0x0543('0x24')]=_0x44116a;if(_0x164bbf[_0x0543('0x3a')][_0x0543('0x48')]){_0x45ac71[_0x0543('0x49')]=[{'all':!![]}];}return db[_0x0543('0x32')][_0x0543('0x4a')](_0x45ac71);})[_0x0543('0x29')](function(_0x1df75e){_0x2819b8['rows']=_0x1df75e;return _0x2819b8;})['then'](respondWithFilteredResult(_0x4f9b63,_0x45ac71))[_0x0543('0x4b')](handleError(_0x4f9b63,null));};exports[_0x0543('0x4c')]=function(_0x5058f2,_0x48a18a){var _0x14d7b2={'raw':!![],'where':{'id':_0x5058f2['params']['id']}},_0x2e16c4={};_0x2e16c4[_0x0543('0x36')]=_['keys'](db[_0x0543('0x32')][_0x0543('0x33')]);_0x2e16c4['query']=_['keys'](_0x5058f2[_0x0543('0x3a')]);_0x2e16c4['filters']=_[_0x0543('0x39')](_0x2e16c4[_0x0543('0x36')],_0x2e16c4[_0x0543('0x3a')]);_0x14d7b2[_0x0543('0x3b')]=_[_0x0543('0x39')](_0x2e16c4[_0x0543('0x36')],qs['fields'](_0x5058f2[_0x0543('0x3a')][_0x0543('0x3c')]));_0x14d7b2[_0x0543('0x3b')]=_0x14d7b2[_0x0543('0x3b')][_0x0543('0x3d')]?_0x14d7b2['attributes']:_0x2e16c4[_0x0543('0x36')];if(_0x5058f2['query'][_0x0543('0x48')]){_0x14d7b2[_0x0543('0x49')]=[{'all':!![]}];}_0x14d7b2=_[_0x0543('0x46')]({},_0x14d7b2,_0x5058f2[_0x0543('0x47')]);return db[_0x0543('0x32')][_0x0543('0x4d')](_0x14d7b2)['then'](handleEntityNotFound(_0x48a18a,null))['then'](respondWithResult(_0x48a18a,null))['catch'](handleError(_0x48a18a,null));};exports[_0x0543('0x4e')]=function(_0x2177b8,_0x4964ba){return db[_0x0543('0x32')][_0x0543('0x4e')](_0x2177b8[_0x0543('0x4f')],{})[_0x0543('0x29')](function(_0x90dd22){var _0x4038a6=_0x2177b8['user'][_0x0543('0x50')]({'plain':!![]});if(!_0x4038a6)throw new Error(_0x0543('0x51'));if(_0x4038a6[_0x0543('0x52')]===_0x0543('0x53')){var _0x2d36bf=_0x90dd22[_0x0543('0x50')]({'plain':!![]});var _0x265bc1=_0x0543('0x2b');return db[_0x0543('0x54')][_0x0543('0x4d')]({'where':{'name':_0x265bc1,'userProfileId':_0x4038a6[_0x0543('0x55')]},'raw':!![]})[_0x0543('0x29')](function(_0x222047){if(_0x222047&&_0x222047[_0x0543('0x56')]===0x0){return db['UserProfileResource'][_0x0543('0x4e')]({'name':_0x2d36bf[_0x0543('0x2e')],'resourceId':_0x2d36bf['id'],'type':_0x222047[_0x0543('0x2e')],'sectionId':_0x222047['id']},{})[_0x0543('0x29')](function(){return _0x90dd22;});}else{return _0x90dd22;}})[_0x0543('0x4b')](function(_0x2980ad){logger[_0x0543('0x57')](_0x0543('0x58'),_0x2980ad);throw _0x2980ad;});}return _0x90dd22;})[_0x0543('0x29')](respondWithResult(_0x4964ba,0xc9))[_0x0543('0x4b')](handleError(_0x4964ba,null));};exports[_0x0543('0x28')]=function(_0x100300,_0x8e8ac9){if(_0x100300[_0x0543('0x4f')]['id']){delete _0x100300[_0x0543('0x4f')]['id'];}return db['SmsQueue'][_0x0543('0x4d')]({'where':{'id':_0x100300[_0x0543('0x59')]['id']}})['then'](handleEntityNotFound(_0x8e8ac9,null))[_0x0543('0x29')](saveUpdates(_0x100300[_0x0543('0x4f')],null))[_0x0543('0x29')](respondWithResult(_0x8e8ac9,null))['catch'](handleError(_0x8e8ac9,null));};exports[_0x0543('0x2a')]=function(_0x57165c,_0x294a38){return db['SmsQueue'][_0x0543('0x4d')]({'where':{'id':_0x57165c['params']['id']}})[_0x0543('0x29')](handleEntityNotFound(_0x294a38,null))[_0x0543('0x29')](removeEntity(_0x294a38,null))[_0x0543('0x4b')](handleError(_0x294a38,null));};exports['describe']=function(_0x117466,_0x1a569b){return db[_0x0543('0x32')][_0x0543('0x5a')]()[_0x0543('0x29')](respondWithResult(_0x1a569b,null))[_0x0543('0x4b')](handleError(_0x1a569b,null));};exports[_0x0543('0x5b')]=function(_0x774cf7,_0x2bf1f9,_0x21ec88){var _0x8a3879={'raw':!![],'where':{}},_0x2ff23a={},_0x378566;return db[_0x0543('0x32')][_0x0543('0x5c')]({'where':{'id':_0x774cf7['params']['id']}})['then'](handleEntityNotFound(_0x2bf1f9,null))[_0x0543('0x29')](function(_0x685f15){if(_0x685f15){_0x378566=_0x685f15[_0x0543('0x50')]({'plain':!![]});_0x2ff23a[_0x0543('0x36')]=_[_0x0543('0x37')](db[_0x0543('0x5d')][_0x0543('0x33')]);_0x2ff23a[_0x0543('0x3a')]=_[_0x0543('0x37')](_0x774cf7['query']);_0x2ff23a[_0x0543('0x38')]=_[_0x0543('0x39')](_0x2ff23a[_0x0543('0x36')],_0x2ff23a[_0x0543('0x3a')]);_0x8a3879['attributes']=_[_0x0543('0x39')](_0x2ff23a[_0x0543('0x36')],qs[_0x0543('0x3c')](_0x774cf7['query']['fields']));_0x8a3879[_0x0543('0x3b')]=_0x8a3879[_0x0543('0x3b')][_0x0543('0x3d')]?_0x8a3879['attributes']:_0x2ff23a[_0x0543('0x36')];if(!_0x774cf7[_0x0543('0x3a')][_0x0543('0x3e')]('nolimit')){_0x8a3879[_0x0543('0x23')]=qs[_0x0543('0x23')](_0x774cf7[_0x0543('0x3a')][_0x0543('0x23')]);_0x8a3879[_0x0543('0x22')]=qs[_0x0543('0x22')](_0x774cf7[_0x0543('0x3a')][_0x0543('0x22')]);}_0x8a3879[_0x0543('0x40')]=qs[_0x0543('0x41')](_0x774cf7[_0x0543('0x3a')][_0x0543('0x41')]);_0x8a3879[_0x0543('0x42')]=qs[_0x0543('0x38')](_['pick'](_0x774cf7['query'],_0x2ff23a[_0x0543('0x38')]));_0x8a3879[_0x0543('0x42')][_0x0543('0x5e')]=_0x685f15['id'];if(_0x774cf7[_0x0543('0x3a')]['filter']){_0x8a3879[_0x0543('0x42')]=_['merge'](_0x8a3879[_0x0543('0x42')],{'$or':_[_0x0543('0x31')](_0x8a3879[_0x0543('0x3b')],function(_0x5bd53d){var _0x5cb8ce={};_0x5cb8ce[_0x5bd53d]={'$like':'%'+_0x774cf7[_0x0543('0x3a')]['filter']+'%'};return _0x5cb8ce;})});}_0x8a3879=_['merge']({},_0x8a3879,_0x774cf7[_0x0543('0x47')]);return db[_0x0543('0x5d')][_0x0543('0x4a')](_0x8a3879);}})[_0x0543('0x29')](function(_0x338c62){if(_0x338c62){return db[_0x0543('0x5f')][_0x0543('0x60')]({'where':{'id':_[_0x0543('0x31')](_0x338c62,_0x0543('0x61')),'role':'agent'},'attributes':['id',_0x0543('0x2e'),_0x0543('0x62'),_0x0543('0x63'),_0x0543('0x64')]});}})[_0x0543('0x29')](function(_0x53f0f3){if(_0x53f0f3){return{'count':_0x53f0f3[_0x0543('0x24')],'rows':_['map'](_0x53f0f3[_0x0543('0x65')],function(_0x85a666){return{'membername':_0x85a666[_0x0543('0x2e')],'UserId':_0x85a666['id'],'queue_name':_0x378566[_0x0543('0x2e')],'SmsQueueId':_0x378566['id'],'interface':util['format'](_0x0543('0x66'),_0x0543('0x67'),_0x85a666[_0x0543('0x2e')]),'penalty':0x0,'paused':_0x85a666['smsPause'],'createdAt':_0x85a666[_0x0543('0x64')],'updatedAt':_0x85a666['updatedAt']};})};}else{return{'count':0x0,'rows':[]};}})[_0x0543('0x29')](respondWithFilteredResult(_0x2bf1f9,_0x8a3879))[_0x0543('0x4b')](handleError(_0x2bf1f9,null));};exports[_0x0543('0x68')]=function(_0x916a51,_0x25aecd,_0x21c920){var _0x54f120={};var _0x59f214={};var _0x5e6a72;var _0x387334;return db[_0x0543('0x32')][_0x0543('0x5c')]({'where':{'id':_0x916a51[_0x0543('0x59')]['id']}})[_0x0543('0x29')](handleEntityNotFound(_0x25aecd,null))[_0x0543('0x29')](function(_0x15a605){if(_0x15a605){_0x5e6a72=_0x15a605;_0x59f214[_0x0543('0x36')]=_['keys'](db['Team'][_0x0543('0x33')]);_0x59f214[_0x0543('0x3a')]=_['keys'](_0x916a51[_0x0543('0x3a')]);_0x59f214['filters']=_[_0x0543('0x39')](_0x59f214[_0x0543('0x36')],_0x59f214[_0x0543('0x3a')]);_0x54f120[_0x0543('0x3b')]=_[_0x0543('0x39')](_0x59f214['model'],qs[_0x0543('0x3c')](_0x916a51[_0x0543('0x3a')]['fields']));_0x54f120[_0x0543('0x3b')]=_0x54f120[_0x0543('0x3b')][_0x0543('0x3d')]?_0x54f120['attributes']:_0x59f214[_0x0543('0x36')];_0x54f120[_0x0543('0x40')]=qs[_0x0543('0x41')](_0x916a51['query'][_0x0543('0x41')]);_0x54f120[_0x0543('0x42')]=qs[_0x0543('0x38')](_[_0x0543('0x69')](_0x916a51['query'],_0x59f214[_0x0543('0x38')]));if(_0x916a51[_0x0543('0x3a')][_0x0543('0x43')]){_0x54f120[_0x0543('0x42')]=_[_0x0543('0x46')](_0x54f120[_0x0543('0x42')],{'$or':_[_0x0543('0x31')](_0x54f120[_0x0543('0x3b')],function(_0x420b02){var _0xa8ab55={};_0xa8ab55[_0x420b02]={'$like':'%'+_0x916a51[_0x0543('0x3a')][_0x0543('0x43')]+'%'};return _0xa8ab55;})});}_0x54f120=_[_0x0543('0x46')]({},_0x54f120,_0x916a51[_0x0543('0x47')]);return _0x5e6a72[_0x0543('0x68')](_0x54f120);}})[_0x0543('0x29')](function(_0x1bbba9){if(_0x1bbba9){_0x387334=_0x1bbba9['length'];if(!_0x916a51[_0x0543('0x3a')][_0x0543('0x3e')](_0x0543('0x3f'))){_0x54f120[_0x0543('0x23')]=qs[_0x0543('0x23')](_0x916a51[_0x0543('0x3a')][_0x0543('0x23')]);_0x54f120[_0x0543('0x22')]=qs[_0x0543('0x22')](_0x916a51[_0x0543('0x3a')][_0x0543('0x22')]);}return _0x5e6a72['getTeams'](_0x54f120);}})[_0x0543('0x29')](function(_0xe296e0){if(_0xe296e0){return _0xe296e0?{'count':_0x387334,'rows':_0xe296e0}:null;}})[_0x0543('0x29')](respondWithResult(_0x25aecd,null))['catch'](handleError(_0x25aecd,null));};exports[_0x0543('0x6a')]=function(_0x4d9d96,_0x47d08b,_0x46ab3c){var _0x587f56=_0x4d9d96[_0x0543('0x4f')][_0x0543('0x6b')];return db[_0x0543('0x6c')][_0x0543('0x4a')]({'where':{'id':_0x587f56},'attributes':['id'],'include':[{'model':db['User'],'as':'Agents','attributes':['id',_0x0543('0x2e'),_0x0543('0x6d'),_0x0543('0x6e'),'interface'],'raw':!![]}]})[_0x0543('0x29')](function(_0xdfd945){if(_0xdfd945){var _0x4cf0ca=_[_0x0543('0x6f')](_0xdfd945,function(_0x146062){var _0x5979d4=_0x146062['get']({'plain':!![]});return _0x5979d4[_0x0543('0x70')];});return db[_0x0543('0x32')][_0x0543('0x4d')]({'where':{'id':_0x4d9d96['params']['id']}})[_0x0543('0x29')](function(_0x37f54b){return db[_0x0543('0x71')]['transaction'](function(_0x57d27a){return _0x37f54b[_0x0543('0x6a')](_0x587f56,{'transaction':_0x57d27a})[_0x0543('0x29')](function(){return BPromise[_0x0543('0x72')](_0x4cf0ca,function(_0x51c8ee){return db[_0x0543('0x5d')][_0x0543('0x73')]({'where':{'UserId':_0x51c8ee['id'],'SmsQueueId':_0x4d9d96[_0x0543('0x59')]['id']},'transaction':_0x57d27a});});})[_0x0543('0x29')](function(){_0x4cf0ca[_0x0543('0x74')](function(_0x2a024f){socket[_0x0543('0x75')](_0x0543('0x76'),{'UserId':_0x2a024f['id'],'SmsQueueId':_0x37f54b['id']});});});});});}})[_0x0543('0x29')](respondWithStatusCode(_0x47d08b,null))[_0x0543('0x4b')](handleError(_0x47d08b,null));};exports[_0x0543('0x77')]=function(_0xe38301,_0x243e3a,_0x3d9f3d){return db[_0x0543('0x6c')][_0x0543('0x4a')]({'where':{'id':_0xe38301[_0x0543('0x3a')]['ids']},'attributes':['id'],'include':[{'model':db[_0x0543('0x5f')],'as':_0x0543('0x70'),'attributes':['id'],'raw':!![]}]})[_0x0543('0x29')](handleEntityNotFound(_0x243e3a,null))[_0x0543('0x29')](function(_0x4f2319){var _0x3411c1=_[_0x0543('0x31')](_0x4f2319,'id');var _0xdd4d2d=[];var _0x11ec91=[];var _0x5eb668=squel[_0x0543('0x78')]();_0x5eb668[_0x0543('0x79')]('tq.TeamId')[_0x0543('0x7a')](_0x0543('0x7b'),'tq')[_0x0543('0x7c')](_0x0543('0x7d'),'ut','ut.TeamId\x20=\x20tq.TeamId')[_0x0543('0x42')](_0x0543('0x7e'),_0xe38301[_0x0543('0x59')]['id']);for(var _0x24fca2=0x0;_0x24fca2<_0x4f2319[_0x0543('0x3d')];_0x24fca2+=0x1){let _0x57130c=_0x4f2319[_0x24fca2];for(var _0x25d634=0x0;_0x25d634<_0x57130c[_0x0543('0x70')]['length'];_0x25d634+=0x1){let _0x1407e0=_0x57130c['Agents'][_0x25d634];var _0x1db117=_0x5eb668[_0x0543('0x7f')]();_0x1db117[_0x0543('0x42')](_0x0543('0x80'),_0x1407e0['id']);_0x11ec91['push'](db[_0x0543('0x71')]['query'](_0x1db117[_0x0543('0x81')](),{'type':db[_0x0543('0x71')][_0x0543('0x82')][_0x0543('0x83')]})[_0x0543('0x29')](function(_0x343786){if(_0x343786[_0x0543('0x3d')]===0x1){return _0x1407e0['id'];}else{var _0x2d1390=_[_0x0543('0x84')](_[_0x0543('0x31')](_0x343786,_0x0543('0x85')),function(_0x57aa7e){return _[_0x0543('0x86')](_0x3411c1,_0x57aa7e);});if(_0x2d1390){return _0x1407e0['id'];}}}));}}return BPromise[_0x0543('0x87')](_0x11ec91)[_0x0543('0x29')](function(_0x508a19){_0xdd4d2d=_(_0xdd4d2d)[_0x0543('0x88')](_0x508a19)['compact']()['value']();return db[_0x0543('0x32')]['find']({'where':{'id':_0xe38301['params']['id']}})[_0x0543('0x29')](function(_0x3b6a72){return db[_0x0543('0x71')][_0x0543('0x89')](function(_0x389c0d){return _0x3b6a72[_0x0543('0x77')](_0xe38301['query']['ids'],{'transaction':_0x389c0d})['then'](function(){if(!_['isEmpty'](_0xdd4d2d)){return _0x3b6a72[_0x0543('0x8a')](_0xdd4d2d,{'transaction':_0x389c0d});}})[_0x0543('0x29')](function(){_0xdd4d2d[_0x0543('0x74')](function(_0x328526){socket['emit'](_0x0543('0x8b'),{'UserId':_0x328526,'SmsQueueId':_0x3b6a72['id']});});});});});});})[_0x0543('0x29')](respondWithStatusCode(_0x243e3a,null))[_0x0543('0x4b')](handleError(_0x243e3a,null));};exports[_0x0543('0x8c')]=function(_0x2a2e53,_0x2d9734,_0x2cead1){return db[_0x0543('0x32')][_0x0543('0x4d')]({'where':{'id':_0x2a2e53[_0x0543('0x59')]['id']}})['then'](handleEntityNotFound(_0x2d9734,null))[_0x0543('0x29')](function(_0x9c8391){if(_0x9c8391){return _0x9c8391[_0x0543('0x8c')](_0x2a2e53[_0x0543('0x4f')][_0x0543('0x6b')],_[_0x0543('0x8d')](_0x2a2e53['body'],[_0x0543('0x6b'),'id'])||{})[_0x0543('0x8e')](function(_0x4ae078){for(var _0x47e524=0x0;_0x47e524<_0x2a2e53[_0x0543('0x4f')][_0x0543('0x6b')][_0x0543('0x3d')];_0x47e524+=0x1){socket['emit'](_0x0543('0x76'),{'UserId':Number(_0x2a2e53['body']['ids'][_0x47e524]),'SmsQueueId':Number(_0x2a2e53[_0x0543('0x59')]['id'])});}return _0x4ae078;});}})['then'](respondWithResult(_0x2d9734,null))[_0x0543('0x4b')](handleError(_0x2d9734,null));};exports[_0x0543('0x8a')]=function(_0x4dffcb,_0x347404,_0x55bd20){return db[_0x0543('0x32')][_0x0543('0x4d')]({'where':{'id':_0x4dffcb[_0x0543('0x59')]['id']}})['then'](handleEntityNotFound(_0x347404,null))[_0x0543('0x29')](function(_0x53ac8a){if(_0x53ac8a){return _0x53ac8a[_0x0543('0x8a')](_0x4dffcb[_0x0543('0x3a')]['ids'])[_0x0543('0x29')](function(){if(_[_0x0543('0x8f')](_0x4dffcb[_0x0543('0x3a')]['ids'])){for(var _0x4fd84c=0x0;_0x4fd84c<_0x4dffcb[_0x0543('0x3a')]['ids'][_0x0543('0x3d')];_0x4fd84c+=0x1){socket[_0x0543('0x75')](_0x0543('0x8b'),{'UserId':Number(_0x4dffcb[_0x0543('0x3a')]['ids'][_0x4fd84c]),'SmsQueueId':Number(_0x4dffcb[_0x0543('0x59')]['id'])});}}else{socket['emit'](_0x0543('0x8b'),{'UserId':Number(_0x4dffcb[_0x0543('0x3a')][_0x0543('0x6b')]),'SmsQueueId':Number(_0x4dffcb['params']['id'])});}});}})[_0x0543('0x29')](respondWithStatusCode(_0x347404,null))[_0x0543('0x4b')](handleError(_0x347404,null));};exports['getAgents']=function(_0x1f4c5b,_0x5574f5,_0x1c00f7){var _0x11337c={};var _0x40e16c={};var _0x3a4c40;var _0x547fd9;return db[_0x0543('0x32')][_0x0543('0x5c')]({'where':{'id':_0x1f4c5b[_0x0543('0x59')]['id']}})[_0x0543('0x29')](handleEntityNotFound(_0x5574f5,null))[_0x0543('0x29')](function(_0x50b193){if(_0x50b193){_0x3a4c40=_0x50b193;_0x40e16c[_0x0543('0x36')]=_[_0x0543('0x37')](db['User']['rawAttributes']);_0x40e16c[_0x0543('0x3a')]=_['keys'](_0x1f4c5b[_0x0543('0x3a')]);_0x40e16c[_0x0543('0x38')]=_[_0x0543('0x39')](_0x40e16c[_0x0543('0x36')],_0x40e16c['query']);_0x11337c[_0x0543('0x3b')]=_[_0x0543('0x39')](_0x40e16c[_0x0543('0x36')],qs[_0x0543('0x3c')](_0x1f4c5b['query']['fields']));_0x11337c['attributes']=_0x11337c[_0x0543('0x3b')]['length']?_0x11337c[_0x0543('0x3b')]:_0x40e16c[_0x0543('0x36')];_0x11337c[_0x0543('0x40')]=qs['sort'](_0x1f4c5b[_0x0543('0x3a')][_0x0543('0x41')]);_0x11337c[_0x0543('0x42')]=qs['filters'](_[_0x0543('0x69')](_0x1f4c5b[_0x0543('0x3a')],_0x40e16c[_0x0543('0x38')]));if(_0x1f4c5b[_0x0543('0x3a')]['filter']){_0x11337c[_0x0543('0x42')]=_['merge'](_0x11337c[_0x0543('0x42')],{'$or':_[_0x0543('0x31')](_0x11337c[_0x0543('0x3b')],function(_0x32020b){var _0x23b43c={};_0x23b43c[_0x32020b]={'$like':'%'+_0x1f4c5b[_0x0543('0x3a')]['filter']+'%'};return _0x23b43c;})});}_0x11337c=_['merge']({},_0x11337c,_0x1f4c5b[_0x0543('0x47')]);return _0x3a4c40[_0x0543('0x90')](_0x11337c);}})[_0x0543('0x29')](function(_0x31b03c){if(_0x31b03c){_0x547fd9=_0x31b03c[_0x0543('0x3d')];if(!_0x1f4c5b[_0x0543('0x3a')][_0x0543('0x3e')](_0x0543('0x3f'))){_0x11337c[_0x0543('0x23')]=qs[_0x0543('0x23')](_0x1f4c5b['query']['limit']);_0x11337c[_0x0543('0x22')]=qs[_0x0543('0x22')](_0x1f4c5b['query'][_0x0543('0x22')]);}return _0x3a4c40[_0x0543('0x90')](_0x11337c);}})[_0x0543('0x29')](function(_0x120148){if(_0x120148){return _0x120148?{'count':_0x547fd9,'rows':_0x120148}:null;}})['then'](respondWithResult(_0x5574f5,null))[_0x0543('0x4b')](handleError(_0x5574f5,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