Built motion from commit 753c950e.|2.5.42
[motion2.git] / server / api / smsQueue / smsQueue.controller.js
index b7db66e..5aaed97 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x3f74=['removeAgents','addAgents','omit','spread','isArray','userSmsQueue:remove','getAgents','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','path','sox','fs-extra','squel','jsforce','desk.js','to-csv','querystring','papaparse','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/utils','../../config/environment','../../mysqldb','redis','defaults','localhost','socket.io-emitter','./smsQueue.socket','register','sendStatus','status','end','json','offset','undefined','limit','count','set','Content-Range','apply','reject','update','destroy','then','get','SmsQueues','UserProfileResource','stack','name','send','index','map','SmsQueue','rawAttributes','fieldName','type','model','query','keys','filters','fields','attributes','length','hasOwnProperty','nolimit','order','sort','where','merge','VIRTUAL','filter','options','include','findAll','rows','catch','show','params','intersection','create','body','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','user','UserProfileSection','find','userProfileId','autoAssociation','error','describe','findOne','UserSmsQueue','pick','SmsQueueId','User','UserId','agent','smsPause','updatedAt','format','%s/%s','SIP','createdAt','getTeams','addTeams','ids','Team','Agents','online','interface','sequelize','findOrCreate','emit','userSmsQueue:save','team_has_sms_queues','join','user_has_teams','ut.TeamId\x20=\x20tq.TeamId','SmsQueueId\x20=\x20?','ut.UserId\x20=\x20?','push','QueryTypes','SELECT','every','TeamId','includes','all','union','compact','value','transaction','removeTeams','isEmpty'];(function(_0x47f7ec,_0x369f9d){var _0x415101=function(_0x41317a){while(--_0x41317a){_0x47f7ec['push'](_0x47f7ec['shift']());}};_0x415101(++_0x369f9d);}(_0x3f74,0x121));var _0x43f7=function(_0x1bee5e,_0x5ca559){_0x1bee5e=_0x1bee5e-0x0;var _0x130815=_0x3f74[_0x1bee5e];return _0x130815;};'use strict';var emlformat=require(_0x43f7('0x0'));var rimraf=require(_0x43f7('0x1'));var zipdir=require(_0x43f7('0x2'));var jsonpatch=require(_0x43f7('0x3'));var rp=require(_0x43f7('0x4'));var moment=require(_0x43f7('0x5'));var BPromise=require(_0x43f7('0x6'));var Mustache=require(_0x43f7('0x7'));var util=require('util');var path=require(_0x43f7('0x8'));var sox=require(_0x43f7('0x9'));var csv=require('to-csv');var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x43f7('0xa'));var _=require('lodash');var squel=require(_0x43f7('0xb'));var crypto=require('crypto');var jsforce=require(_0x43f7('0xc'));var deskjs=require(_0x43f7('0xd'));var toCsv=require(_0x43f7('0xe'));var querystring=require(_0x43f7('0xf'));var Papa=require(_0x43f7('0x10'));var Redis=require('ioredis');var authService=require(_0x43f7('0x11'));var qs=require('../../components/parsers/qs');var as=require(_0x43f7('0x12'));var hardwareService=require(_0x43f7('0x13'));var logger=require('../../config/logger')(_0x43f7('0x14'));var utils=require(_0x43f7('0x15'));var config=require(_0x43f7('0x16'));var licenseUtil=require('../../config/license/util');var db=require(_0x43f7('0x17'))['db'];config[_0x43f7('0x18')]=_[_0x43f7('0x19')](config[_0x43f7('0x18')],{'host':_0x43f7('0x1a'),'port':0x18eb});var socket=require(_0x43f7('0x1b'))(new Redis(config[_0x43f7('0x18')]));require(_0x43f7('0x1c'))[_0x43f7('0x1d')](socket);function respondWithStatusCode(_0x1ba361,_0x158fe9){_0x158fe9=_0x158fe9||0xcc;return function(_0x30856b){if(_0x30856b){return _0x1ba361[_0x43f7('0x1e')](_0x158fe9);}return _0x1ba361[_0x43f7('0x1f')](_0x158fe9)[_0x43f7('0x20')]();};}function respondWithResult(_0x2316fa,_0x41d7d9){_0x41d7d9=_0x41d7d9||0xc8;return function(_0x155bdc){if(_0x155bdc){return _0x2316fa['status'](_0x41d7d9)[_0x43f7('0x21')](_0x155bdc);}};}function respondWithFilteredResult(_0x5a558e,_0x58e380){return function(_0x3d8571){if(_0x3d8571){var _0x5ce4ed=typeof _0x58e380[_0x43f7('0x22')]===_0x43f7('0x23')&&typeof _0x58e380[_0x43f7('0x24')]===_0x43f7('0x23');var _0x294dce=_0x3d8571['count'];var _0x83d922=_0x5ce4ed?0x0:_0x58e380[_0x43f7('0x22')];var _0x57c1bb=_0x5ce4ed?_0x3d8571[_0x43f7('0x25')]:_0x58e380['offset']+_0x58e380[_0x43f7('0x24')];var _0x246e06;if(_0x57c1bb>=_0x294dce){_0x57c1bb=_0x294dce;_0x246e06=0xc8;}else{_0x246e06=0xce;}_0x5a558e[_0x43f7('0x1f')](_0x246e06);return _0x5a558e[_0x43f7('0x26')](_0x43f7('0x27'),_0x83d922+'-'+_0x57c1bb+'/'+_0x294dce)[_0x43f7('0x21')](_0x3d8571);}return null;};}function patchUpdates(_0x1d15e9){return function(_0x19a2f5){try{jsonpatch[_0x43f7('0x28')](_0x19a2f5,_0x1d15e9,!![]);}catch(_0x422bbd){return BPromise[_0x43f7('0x29')](_0x422bbd);}return _0x19a2f5['save']();};}function saveUpdates(_0x313965,_0x2ca45a){return function(_0x2b805d){if(_0x2b805d){return _0x2b805d[_0x43f7('0x2a')](_0x313965)['then'](function(_0x2d7b3a){return _0x2d7b3a;});}return null;};}function removeEntity(_0x4cdc92,_0x173cf9){return function(_0xbe9127){if(_0xbe9127){return _0xbe9127[_0x43f7('0x2b')]()[_0x43f7('0x2c')](function(){var _0x339775=_0xbe9127[_0x43f7('0x2d')]({'plain':!![]});var _0x2b0a06=_0x43f7('0x2e');return db[_0x43f7('0x2f')][_0x43f7('0x2b')]({'where':{'type':_0x2b0a06,'resourceId':_0x339775['id']}})[_0x43f7('0x2c')](function(){return _0xbe9127;});})[_0x43f7('0x2c')](function(){_0x4cdc92['status'](0xcc)[_0x43f7('0x20')]();});}};}function handleEntityNotFound(_0x1bdd3c,_0x16f48c){return function(_0x4472cc){if(!_0x4472cc){_0x1bdd3c[_0x43f7('0x1e')](0x194);}return _0x4472cc;};}function handleError(_0x4ae453,_0x3d6e5d){_0x3d6e5d=_0x3d6e5d||0x1f4;return function(_0x4f44f2){logger['error'](_0x4f44f2[_0x43f7('0x30')]);if(_0x4f44f2[_0x43f7('0x31')]){delete _0x4f44f2['name'];}_0x4ae453['status'](_0x3d6e5d)[_0x43f7('0x32')](_0x4f44f2);};}exports[_0x43f7('0x33')]=function(_0x12d956,_0x6e9e82){var _0x12afa5={},_0x36e043={},_0x421178={'count':0x0,'rows':[]};var _0x5e5292=_[_0x43f7('0x34')](db[_0x43f7('0x35')][_0x43f7('0x36')],function(_0x5ffd9){return{'name':_0x5ffd9[_0x43f7('0x37')],'type':_0x5ffd9[_0x43f7('0x38')]['key']};});_0x36e043[_0x43f7('0x39')]=_[_0x43f7('0x34')](_0x5e5292,_0x43f7('0x31'));_0x36e043[_0x43f7('0x3a')]=_[_0x43f7('0x3b')](_0x12d956[_0x43f7('0x3a')]);_0x36e043[_0x43f7('0x3c')]=_['intersection'](_0x36e043[_0x43f7('0x39')],_0x36e043[_0x43f7('0x3a')]);_0x12afa5['attributes']=_['intersection'](_0x36e043['model'],qs[_0x43f7('0x3d')](_0x12d956['query'][_0x43f7('0x3d')]));_0x12afa5[_0x43f7('0x3e')]=_0x12afa5[_0x43f7('0x3e')][_0x43f7('0x3f')]?_0x12afa5['attributes']:_0x36e043[_0x43f7('0x39')];if(!_0x12d956[_0x43f7('0x3a')][_0x43f7('0x40')](_0x43f7('0x41'))){_0x12afa5[_0x43f7('0x24')]=qs[_0x43f7('0x24')](_0x12d956[_0x43f7('0x3a')][_0x43f7('0x24')]);_0x12afa5[_0x43f7('0x22')]=qs[_0x43f7('0x22')](_0x12d956[_0x43f7('0x3a')][_0x43f7('0x22')]);}_0x12afa5[_0x43f7('0x42')]=qs[_0x43f7('0x43')](_0x12d956[_0x43f7('0x3a')][_0x43f7('0x43')]);_0x12afa5[_0x43f7('0x44')]=qs[_0x43f7('0x3c')](_['pick'](_0x12d956['query'],_0x36e043[_0x43f7('0x3c')]),_0x5e5292);if(_0x12d956[_0x43f7('0x3a')]['filter']){_0x12afa5[_0x43f7('0x44')]=_[_0x43f7('0x45')](_0x12afa5[_0x43f7('0x44')],{'$or':_['map'](_0x5e5292,function(_0x229aff){if(_0x229aff[_0x43f7('0x38')]!==_0x43f7('0x46')){var _0x27978b={};_0x27978b[_0x229aff[_0x43f7('0x31')]]={'$like':'%'+_0x12d956[_0x43f7('0x3a')][_0x43f7('0x47')]+'%'};return _0x27978b;}})});}_0x12afa5=_[_0x43f7('0x45')]({},_0x12afa5,_0x12d956[_0x43f7('0x48')]);var _0x3ebb19={'where':_0x12afa5['where']};return db[_0x43f7('0x35')][_0x43f7('0x25')](_0x3ebb19)[_0x43f7('0x2c')](function(_0x2eff54){_0x421178[_0x43f7('0x25')]=_0x2eff54;if(_0x12d956[_0x43f7('0x3a')]['includeAll']){_0x12afa5[_0x43f7('0x49')]=[{'all':!![]}];}return db[_0x43f7('0x35')][_0x43f7('0x4a')](_0x12afa5);})[_0x43f7('0x2c')](function(_0xfdb614){_0x421178[_0x43f7('0x4b')]=_0xfdb614;return _0x421178;})[_0x43f7('0x2c')](respondWithFilteredResult(_0x6e9e82,_0x12afa5))[_0x43f7('0x4c')](handleError(_0x6e9e82,null));};exports[_0x43f7('0x4d')]=function(_0x371322,_0x307b9e){var _0x57ea86={'raw':!![],'where':{'id':_0x371322[_0x43f7('0x4e')]['id']}},_0x496fa7={};_0x496fa7[_0x43f7('0x39')]=_[_0x43f7('0x3b')](db[_0x43f7('0x35')][_0x43f7('0x36')]);_0x496fa7[_0x43f7('0x3a')]=_[_0x43f7('0x3b')](_0x371322['query']);_0x496fa7[_0x43f7('0x3c')]=_[_0x43f7('0x4f')](_0x496fa7['model'],_0x496fa7['query']);_0x57ea86[_0x43f7('0x3e')]=_[_0x43f7('0x4f')](_0x496fa7[_0x43f7('0x39')],qs[_0x43f7('0x3d')](_0x371322[_0x43f7('0x3a')][_0x43f7('0x3d')]));_0x57ea86[_0x43f7('0x3e')]=_0x57ea86[_0x43f7('0x3e')]['length']?_0x57ea86[_0x43f7('0x3e')]:_0x496fa7[_0x43f7('0x39')];if(_0x371322[_0x43f7('0x3a')]['includeAll']){_0x57ea86[_0x43f7('0x49')]=[{'all':!![]}];}_0x57ea86=_[_0x43f7('0x45')]({},_0x57ea86,_0x371322['options']);return db[_0x43f7('0x35')]['find'](_0x57ea86)[_0x43f7('0x2c')](handleEntityNotFound(_0x307b9e,null))[_0x43f7('0x2c')](respondWithResult(_0x307b9e,null))['catch'](handleError(_0x307b9e,null));};exports[_0x43f7('0x50')]=function(_0x15fecf,_0x462cb0){return db['SmsQueue'][_0x43f7('0x50')](_0x15fecf[_0x43f7('0x51')],{})['then'](function(_0x5a394f){var _0x3a65d6=_0x15fecf['user'][_0x43f7('0x2d')]({'plain':!![]});if(!_0x3a65d6)throw new Error(_0x43f7('0x52'));if(_0x3a65d6[_0x43f7('0x53')]===_0x43f7('0x54')){var _0x280f19=_0x5a394f[_0x43f7('0x2d')]({'plain':!![]});var _0x19fffd=_0x43f7('0x2e');return db[_0x43f7('0x55')][_0x43f7('0x56')]({'where':{'name':_0x19fffd,'userProfileId':_0x3a65d6[_0x43f7('0x57')]},'raw':!![]})[_0x43f7('0x2c')](function(_0x2fe9fc){if(_0x2fe9fc&&_0x2fe9fc[_0x43f7('0x58')]===0x0){return db[_0x43f7('0x2f')]['create']({'name':_0x280f19[_0x43f7('0x31')],'resourceId':_0x280f19['id'],'type':_0x2fe9fc[_0x43f7('0x31')],'sectionId':_0x2fe9fc['id']},{})[_0x43f7('0x2c')](function(){return _0x5a394f;});}else{return _0x5a394f;}})['catch'](function(_0x3466e6){logger[_0x43f7('0x59')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x3466e6);throw _0x3466e6;});}return _0x5a394f;})[_0x43f7('0x2c')](respondWithResult(_0x462cb0,0xc9))[_0x43f7('0x4c')](handleError(_0x462cb0,null));};exports['update']=function(_0xfe5869,_0xdb7840){if(_0xfe5869[_0x43f7('0x51')]['id']){delete _0xfe5869[_0x43f7('0x51')]['id'];}return db['SmsQueue'][_0x43f7('0x56')]({'where':{'id':_0xfe5869['params']['id']}})[_0x43f7('0x2c')](handleEntityNotFound(_0xdb7840,null))['then'](saveUpdates(_0xfe5869[_0x43f7('0x51')],null))['then'](respondWithResult(_0xdb7840,null))[_0x43f7('0x4c')](handleError(_0xdb7840,null));};exports[_0x43f7('0x2b')]=function(_0x2cb787,_0x4d5aa1){return db[_0x43f7('0x35')]['find']({'where':{'id':_0x2cb787[_0x43f7('0x4e')]['id']}})['then'](handleEntityNotFound(_0x4d5aa1,null))['then'](removeEntity(_0x4d5aa1,null))[_0x43f7('0x4c')](handleError(_0x4d5aa1,null));};exports['describe']=function(_0x5dd67a,_0x17bcdd){return db['SmsQueue'][_0x43f7('0x5a')]()[_0x43f7('0x2c')](respondWithResult(_0x17bcdd,null))['catch'](handleError(_0x17bcdd,null));};exports['getMembers']=function(_0x3fc345,_0x350548,_0x2f6a3f){var _0x1782a6={'raw':!![],'where':{}},_0x98530e={},_0x47ed29;return db[_0x43f7('0x35')][_0x43f7('0x5b')]({'where':{'id':_0x3fc345[_0x43f7('0x4e')]['id']}})[_0x43f7('0x2c')](handleEntityNotFound(_0x350548,null))['then'](function(_0x1fae81){if(_0x1fae81){_0x47ed29=_0x1fae81[_0x43f7('0x2d')]({'plain':!![]});_0x98530e[_0x43f7('0x39')]=_['keys'](db[_0x43f7('0x5c')][_0x43f7('0x36')]);_0x98530e['query']=_[_0x43f7('0x3b')](_0x3fc345[_0x43f7('0x3a')]);_0x98530e[_0x43f7('0x3c')]=_[_0x43f7('0x4f')](_0x98530e[_0x43f7('0x39')],_0x98530e['query']);_0x1782a6[_0x43f7('0x3e')]=_[_0x43f7('0x4f')](_0x98530e[_0x43f7('0x39')],qs[_0x43f7('0x3d')](_0x3fc345['query']['fields']));_0x1782a6[_0x43f7('0x3e')]=_0x1782a6[_0x43f7('0x3e')][_0x43f7('0x3f')]?_0x1782a6['attributes']:_0x98530e[_0x43f7('0x39')];if(!_0x3fc345[_0x43f7('0x3a')][_0x43f7('0x40')](_0x43f7('0x41'))){_0x1782a6[_0x43f7('0x24')]=qs[_0x43f7('0x24')](_0x3fc345[_0x43f7('0x3a')][_0x43f7('0x24')]);_0x1782a6[_0x43f7('0x22')]=qs['offset'](_0x3fc345[_0x43f7('0x3a')][_0x43f7('0x22')]);}_0x1782a6[_0x43f7('0x42')]=qs[_0x43f7('0x43')](_0x3fc345['query'][_0x43f7('0x43')]);_0x1782a6[_0x43f7('0x44')]=qs[_0x43f7('0x3c')](_[_0x43f7('0x5d')](_0x3fc345['query'],_0x98530e['filters']));_0x1782a6[_0x43f7('0x44')][_0x43f7('0x5e')]=_0x1fae81['id'];if(_0x3fc345['query'][_0x43f7('0x47')]){_0x1782a6['where']=_[_0x43f7('0x45')](_0x1782a6['where'],{'$or':_[_0x43f7('0x34')](_0x1782a6[_0x43f7('0x3e')],function(_0x2a9fe0){var _0x4e526a={};_0x4e526a[_0x2a9fe0]={'$like':'%'+_0x3fc345[_0x43f7('0x3a')][_0x43f7('0x47')]+'%'};return _0x4e526a;})});}_0x1782a6=_[_0x43f7('0x45')]({},_0x1782a6,_0x3fc345[_0x43f7('0x48')]);return db[_0x43f7('0x5c')]['findAll'](_0x1782a6);}})[_0x43f7('0x2c')](function(_0x236482){if(_0x236482){return db[_0x43f7('0x5f')]['findAndCountAll']({'where':{'id':_[_0x43f7('0x34')](_0x236482,_0x43f7('0x60')),'role':_0x43f7('0x61')},'attributes':['id','name',_0x43f7('0x62'),_0x43f7('0x63'),'createdAt']});}})['then'](function(_0x2054cf){if(_0x2054cf){return{'count':_0x2054cf[_0x43f7('0x25')],'rows':_[_0x43f7('0x34')](_0x2054cf[_0x43f7('0x4b')],function(_0x1098a5){return{'membername':_0x1098a5[_0x43f7('0x31')],'UserId':_0x1098a5['id'],'queue_name':_0x47ed29['name'],'SmsQueueId':_0x47ed29['id'],'interface':util[_0x43f7('0x64')](_0x43f7('0x65'),_0x43f7('0x66'),_0x1098a5[_0x43f7('0x31')]),'penalty':0x0,'paused':_0x1098a5['smsPause'],'createdAt':_0x1098a5[_0x43f7('0x67')],'updatedAt':_0x1098a5[_0x43f7('0x63')]};})};}else{return{'count':0x0,'rows':[]};}})['then'](respondWithFilteredResult(_0x350548,_0x1782a6))[_0x43f7('0x4c')](handleError(_0x350548,null));};exports[_0x43f7('0x68')]=function(_0x24f543,_0x4e40b3,_0x3e6591){var _0x7b1dc1={};var _0x3f7cdd={};var _0x52776f;var _0x5dc9a5;return db[_0x43f7('0x35')]['findOne']({'where':{'id':_0x24f543['params']['id']}})[_0x43f7('0x2c')](handleEntityNotFound(_0x4e40b3,null))[_0x43f7('0x2c')](function(_0x41eca4){if(_0x41eca4){_0x52776f=_0x41eca4;_0x3f7cdd[_0x43f7('0x39')]=_[_0x43f7('0x3b')](db['Team'][_0x43f7('0x36')]);_0x3f7cdd[_0x43f7('0x3a')]=_['keys'](_0x24f543[_0x43f7('0x3a')]);_0x3f7cdd[_0x43f7('0x3c')]=_[_0x43f7('0x4f')](_0x3f7cdd['model'],_0x3f7cdd[_0x43f7('0x3a')]);_0x7b1dc1[_0x43f7('0x3e')]=_[_0x43f7('0x4f')](_0x3f7cdd[_0x43f7('0x39')],qs[_0x43f7('0x3d')](_0x24f543['query'][_0x43f7('0x3d')]));_0x7b1dc1[_0x43f7('0x3e')]=_0x7b1dc1[_0x43f7('0x3e')]['length']?_0x7b1dc1['attributes']:_0x3f7cdd[_0x43f7('0x39')];_0x7b1dc1[_0x43f7('0x42')]=qs[_0x43f7('0x43')](_0x24f543[_0x43f7('0x3a')][_0x43f7('0x43')]);_0x7b1dc1[_0x43f7('0x44')]=qs['filters'](_[_0x43f7('0x5d')](_0x24f543[_0x43f7('0x3a')],_0x3f7cdd[_0x43f7('0x3c')]));if(_0x24f543['query'][_0x43f7('0x47')]){_0x7b1dc1['where']=_['merge'](_0x7b1dc1[_0x43f7('0x44')],{'$or':_[_0x43f7('0x34')](_0x7b1dc1['attributes'],function(_0x3e59be){var _0x301ce0={};_0x301ce0[_0x3e59be]={'$like':'%'+_0x24f543['query'][_0x43f7('0x47')]+'%'};return _0x301ce0;})});}_0x7b1dc1=_[_0x43f7('0x45')]({},_0x7b1dc1,_0x24f543[_0x43f7('0x48')]);return _0x52776f[_0x43f7('0x68')](_0x7b1dc1);}})['then'](function(_0x4a058c){if(_0x4a058c){_0x5dc9a5=_0x4a058c[_0x43f7('0x3f')];if(!_0x24f543[_0x43f7('0x3a')][_0x43f7('0x40')](_0x43f7('0x41'))){_0x7b1dc1[_0x43f7('0x24')]=qs[_0x43f7('0x24')](_0x24f543[_0x43f7('0x3a')][_0x43f7('0x24')]);_0x7b1dc1[_0x43f7('0x22')]=qs[_0x43f7('0x22')](_0x24f543[_0x43f7('0x3a')]['offset']);}return _0x52776f['getTeams'](_0x7b1dc1);}})[_0x43f7('0x2c')](function(_0x44226c){if(_0x44226c){return _0x44226c?{'count':_0x5dc9a5,'rows':_0x44226c}:null;}})[_0x43f7('0x2c')](respondWithResult(_0x4e40b3,null))[_0x43f7('0x4c')](handleError(_0x4e40b3,null));};exports[_0x43f7('0x69')]=function(_0x1602c8,_0x544be1,_0x40a9fc){var _0x487883=_0x1602c8[_0x43f7('0x51')][_0x43f7('0x6a')];return db[_0x43f7('0x6b')][_0x43f7('0x4a')]({'where':{'id':_0x487883},'attributes':['id'],'include':[{'model':db['User'],'as':_0x43f7('0x6c'),'attributes':['id',_0x43f7('0x31'),_0x43f7('0x6d'),'voicePause',_0x43f7('0x6e')],'raw':!![]}]})[_0x43f7('0x2c')](function(_0x37850c){if(_0x37850c){var _0x383d8d=_['flatMap'](_0x37850c,function(_0x25f130){var _0x425246=_0x25f130[_0x43f7('0x2d')]({'plain':!![]});return _0x425246[_0x43f7('0x6c')];});return db['SmsQueue'][_0x43f7('0x56')]({'where':{'id':_0x1602c8[_0x43f7('0x4e')]['id']}})['then'](function(_0x5028a7){return db[_0x43f7('0x6f')]['transaction'](function(_0x1c713d){return _0x5028a7[_0x43f7('0x69')](_0x487883,{'transaction':_0x1c713d})['then'](function(){return BPromise['each'](_0x383d8d,function(_0x40c744){return db[_0x43f7('0x5c')][_0x43f7('0x70')]({'where':{'UserId':_0x40c744['id'],'SmsQueueId':_0x1602c8[_0x43f7('0x4e')]['id']},'transaction':_0x1c713d});});})[_0x43f7('0x2c')](function(){_0x383d8d['forEach'](function(_0x1778c3){socket[_0x43f7('0x71')](_0x43f7('0x72'),{'UserId':_0x1778c3['id'],'SmsQueueId':_0x5028a7['id']});});});});});}})[_0x43f7('0x2c')](respondWithStatusCode(_0x544be1,null))[_0x43f7('0x4c')](handleError(_0x544be1,null));};exports['removeTeams']=function(_0x3469b7,_0x36cdc7,_0x383ee3){return db['Team'][_0x43f7('0x4a')]({'where':{'id':_0x3469b7[_0x43f7('0x3a')][_0x43f7('0x6a')]},'attributes':['id'],'include':[{'model':db['User'],'as':_0x43f7('0x6c'),'attributes':['id'],'raw':!![]}]})['then'](handleEntityNotFound(_0x36cdc7,null))['then'](function(_0x108bed){var _0x2e382a=_[_0x43f7('0x34')](_0x108bed,'id');var _0x54de74=[];var _0x272c7f=[];var _0x55e17c=squel['select']();_0x55e17c['field']('tq.TeamId')['from'](_0x43f7('0x73'),'tq')[_0x43f7('0x74')](_0x43f7('0x75'),'ut',_0x43f7('0x76'))[_0x43f7('0x44')](_0x43f7('0x77'),_0x3469b7[_0x43f7('0x4e')]['id']);for(var _0x177431=0x0;_0x177431<_0x108bed[_0x43f7('0x3f')];_0x177431+=0x1){let _0x368020=_0x108bed[_0x177431];for(var _0x2016e5=0x0;_0x2016e5<_0x368020['Agents'][_0x43f7('0x3f')];_0x2016e5+=0x1){let _0x156b54=_0x368020[_0x43f7('0x6c')][_0x2016e5];var _0x362930=_0x55e17c['clone']();_0x362930[_0x43f7('0x44')](_0x43f7('0x78'),_0x156b54['id']);_0x272c7f[_0x43f7('0x79')](db[_0x43f7('0x6f')][_0x43f7('0x3a')](_0x362930['toString'](),{'type':db['sequelize'][_0x43f7('0x7a')][_0x43f7('0x7b')]})['then'](function(_0x372fe2){if(_0x372fe2['length']===0x1){return _0x156b54['id'];}else{var _0x62cc2b=_[_0x43f7('0x7c')](_[_0x43f7('0x34')](_0x372fe2,_0x43f7('0x7d')),function(_0x267e26){return _[_0x43f7('0x7e')](_0x2e382a,_0x267e26);});if(_0x62cc2b){return _0x156b54['id'];}}}));}}return BPromise[_0x43f7('0x7f')](_0x272c7f)['then'](function(_0x36b0c3){_0x54de74=_(_0x54de74)[_0x43f7('0x80')](_0x36b0c3)[_0x43f7('0x81')]()[_0x43f7('0x82')]();return db[_0x43f7('0x35')]['find']({'where':{'id':_0x3469b7['params']['id']}})[_0x43f7('0x2c')](function(_0x100bea){return db[_0x43f7('0x6f')][_0x43f7('0x83')](function(_0xbc6131){return _0x100bea[_0x43f7('0x84')](_0x3469b7[_0x43f7('0x3a')][_0x43f7('0x6a')],{'transaction':_0xbc6131})['then'](function(){if(!_[_0x43f7('0x85')](_0x54de74)){return _0x100bea[_0x43f7('0x86')](_0x54de74,{'transaction':_0xbc6131});}})[_0x43f7('0x2c')](function(){_0x54de74['forEach'](function(_0xe4ad81){socket[_0x43f7('0x71')]('userSmsQueue:remove',{'UserId':_0xe4ad81,'SmsQueueId':_0x100bea['id']});});});});});});})[_0x43f7('0x2c')](respondWithStatusCode(_0x36cdc7,null))[_0x43f7('0x4c')](handleError(_0x36cdc7,null));};exports[_0x43f7('0x87')]=function(_0x38ae3c,_0x48e3a9,_0x22d4b6){return db[_0x43f7('0x35')][_0x43f7('0x56')]({'where':{'id':_0x38ae3c[_0x43f7('0x4e')]['id']}})[_0x43f7('0x2c')](handleEntityNotFound(_0x48e3a9,null))[_0x43f7('0x2c')](function(_0x37d6ed){if(_0x37d6ed){return _0x37d6ed[_0x43f7('0x87')](_0x38ae3c['body'][_0x43f7('0x6a')],_[_0x43f7('0x88')](_0x38ae3c[_0x43f7('0x51')],['ids','id'])||{})[_0x43f7('0x89')](function(_0x198ae5){for(var _0x177010=0x0;_0x177010<_0x38ae3c[_0x43f7('0x51')]['ids'][_0x43f7('0x3f')];_0x177010+=0x1){socket[_0x43f7('0x71')]('userSmsQueue:save',{'UserId':Number(_0x38ae3c['body'][_0x43f7('0x6a')][_0x177010]),'SmsQueueId':Number(_0x38ae3c[_0x43f7('0x4e')]['id'])});}return _0x198ae5;});}})[_0x43f7('0x2c')](respondWithResult(_0x48e3a9,null))['catch'](handleError(_0x48e3a9,null));};exports[_0x43f7('0x86')]=function(_0x3d3d4b,_0x3757c5,_0x92a94e){return db[_0x43f7('0x35')][_0x43f7('0x56')]({'where':{'id':_0x3d3d4b[_0x43f7('0x4e')]['id']}})[_0x43f7('0x2c')](handleEntityNotFound(_0x3757c5,null))[_0x43f7('0x2c')](function(_0x19972c){if(_0x19972c){return _0x19972c[_0x43f7('0x86')](_0x3d3d4b['query'][_0x43f7('0x6a')])['then'](function(){if(_[_0x43f7('0x8a')](_0x3d3d4b[_0x43f7('0x3a')][_0x43f7('0x6a')])){for(var _0x5bff25=0x0;_0x5bff25<_0x3d3d4b[_0x43f7('0x3a')][_0x43f7('0x6a')][_0x43f7('0x3f')];_0x5bff25+=0x1){socket[_0x43f7('0x71')](_0x43f7('0x8b'),{'UserId':Number(_0x3d3d4b[_0x43f7('0x3a')][_0x43f7('0x6a')][_0x5bff25]),'SmsQueueId':Number(_0x3d3d4b[_0x43f7('0x4e')]['id'])});}}else{socket['emit']('userSmsQueue:remove',{'UserId':Number(_0x3d3d4b[_0x43f7('0x3a')][_0x43f7('0x6a')]),'SmsQueueId':Number(_0x3d3d4b[_0x43f7('0x4e')]['id'])});}});}})[_0x43f7('0x2c')](respondWithStatusCode(_0x3757c5,null))['catch'](handleError(_0x3757c5,null));};exports['getAgents']=function(_0x4741e6,_0x4303fe,_0x2e9961){var _0x41c636={};var _0x2bf70d={};var _0x4a135a;var _0x207e1a;return db[_0x43f7('0x35')][_0x43f7('0x5b')]({'where':{'id':_0x4741e6['params']['id']}})[_0x43f7('0x2c')](handleEntityNotFound(_0x4303fe,null))['then'](function(_0x5db804){if(_0x5db804){_0x4a135a=_0x5db804;_0x2bf70d['model']=_['keys'](db[_0x43f7('0x5f')]['rawAttributes']);_0x2bf70d[_0x43f7('0x3a')]=_['keys'](_0x4741e6['query']);_0x2bf70d[_0x43f7('0x3c')]=_[_0x43f7('0x4f')](_0x2bf70d['model'],_0x2bf70d[_0x43f7('0x3a')]);_0x41c636[_0x43f7('0x3e')]=_[_0x43f7('0x4f')](_0x2bf70d[_0x43f7('0x39')],qs['fields'](_0x4741e6[_0x43f7('0x3a')]['fields']));_0x41c636[_0x43f7('0x3e')]=_0x41c636[_0x43f7('0x3e')][_0x43f7('0x3f')]?_0x41c636[_0x43f7('0x3e')]:_0x2bf70d[_0x43f7('0x39')];_0x41c636[_0x43f7('0x42')]=qs[_0x43f7('0x43')](_0x4741e6['query'][_0x43f7('0x43')]);_0x41c636[_0x43f7('0x44')]=qs[_0x43f7('0x3c')](_['pick'](_0x4741e6[_0x43f7('0x3a')],_0x2bf70d[_0x43f7('0x3c')]));if(_0x4741e6[_0x43f7('0x3a')][_0x43f7('0x47')]){_0x41c636[_0x43f7('0x44')]=_[_0x43f7('0x45')](_0x41c636[_0x43f7('0x44')],{'$or':_[_0x43f7('0x34')](_0x41c636[_0x43f7('0x3e')],function(_0x5ac23f){var _0x3d46e6={};_0x3d46e6[_0x5ac23f]={'$like':'%'+_0x4741e6[_0x43f7('0x3a')][_0x43f7('0x47')]+'%'};return _0x3d46e6;})});}_0x41c636=_[_0x43f7('0x45')]({},_0x41c636,_0x4741e6[_0x43f7('0x48')]);return _0x4a135a['getAgents'](_0x41c636);}})[_0x43f7('0x2c')](function(_0xe1eb32){if(_0xe1eb32){_0x207e1a=_0xe1eb32['length'];if(!_0x4741e6[_0x43f7('0x3a')][_0x43f7('0x40')]('nolimit')){_0x41c636[_0x43f7('0x24')]=qs['limit'](_0x4741e6[_0x43f7('0x3a')][_0x43f7('0x24')]);_0x41c636['offset']=qs['offset'](_0x4741e6['query'][_0x43f7('0x22')]);}return _0x4a135a[_0x43f7('0x8c')](_0x41c636);}})[_0x43f7('0x2c')](function(_0x20ccf2){if(_0x20ccf2){return _0x20ccf2?{'count':_0x207e1a,'rows':_0x20ccf2}:null;}})[_0x43f7('0x2c')](respondWithResult(_0x4303fe,null))[_0x43f7('0x4c')](handleError(_0x4303fe,null));};
\ No newline at end of file
+var _0xbb35=['body','describe','getMembers','findOne','UserSmsQueue','SmsQueueId','User','UserId','agent','smsPause','createdAt','%s/%s','SIP','getTeams','addTeams','ids','Team','Agents','online','voicePause','interface','sequelize','transaction','each','findOrCreate','emit','userSmsQueue:save','removeTeams','select','field','team_has_sms_queues','join','ut.TeamId\x20=\x20tq.TeamId','push','toString','QueryTypes','SELECT','includes','all','union','compact','value','isEmpty','removeAgents','forEach','userSmsQueue:remove','addAgents','omit','spread','getAgents','rimraf','zip-dir','fast-json-patch','request-promise','moment','mustache','util','path','sox','to-csv','ejs','fs-extra','lodash','squel','jsforce','desk.js','querystring','ioredis','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../mysqldb','redis','defaults','localhost','socket.io-emitter','./smsQueue.socket','register','status','json','offset','undefined','count','limit','Content-Range','apply','reject','save','then','destroy','get','SmsQueues','error','name','send','index','map','SmsQueue','type','key','model','keys','query','filters','intersection','fields','attributes','length','hasOwnProperty','nolimit','order','sort','where','pick','merge','VIRTUAL','filter','includeAll','include','findAll','rows','catch','show','params','rawAttributes','options','find','create','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','UserProfileSection','userProfileId','autoAssociation','UserProfileResource','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','update'];(function(_0x2ea183,_0x3cff11){var _0x47c16c=function(_0x3d91e5){while(--_0x3d91e5){_0x2ea183['push'](_0x2ea183['shift']());}};_0x47c16c(++_0x3cff11);}(_0xbb35,0x1d3));var _0x5bb3=function(_0x42ce84,_0x5b67bd){_0x42ce84=_0x42ce84-0x0;var _0x4ad7f4=_0xbb35[_0x42ce84];return _0x4ad7f4;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x5bb3('0x0'));var zipdir=require(_0x5bb3('0x1'));var jsonpatch=require(_0x5bb3('0x2'));var rp=require(_0x5bb3('0x3'));var moment=require(_0x5bb3('0x4'));var BPromise=require('bluebird');var Mustache=require(_0x5bb3('0x5'));var util=require(_0x5bb3('0x6'));var path=require(_0x5bb3('0x7'));var sox=require(_0x5bb3('0x8'));var csv=require(_0x5bb3('0x9'));var ejs=require(_0x5bb3('0xa'));var fs=require('fs');var fs_extra=require(_0x5bb3('0xb'));var _=require(_0x5bb3('0xc'));var squel=require(_0x5bb3('0xd'));var crypto=require('crypto');var jsforce=require(_0x5bb3('0xe'));var deskjs=require(_0x5bb3('0xf'));var toCsv=require(_0x5bb3('0x9'));var querystring=require(_0x5bb3('0x10'));var Papa=require('papaparse');var Redis=require(_0x5bb3('0x11'));var authService=require('../../components/auth/service');var qs=require(_0x5bb3('0x12'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x5bb3('0x13'));var logger=require(_0x5bb3('0x14'))(_0x5bb3('0x15'));var utils=require(_0x5bb3('0x16'));var config=require(_0x5bb3('0x17'));var licenseUtil=require('../../config/license/util');var db=require(_0x5bb3('0x18'))['db'];config[_0x5bb3('0x19')]=_[_0x5bb3('0x1a')](config['redis'],{'host':_0x5bb3('0x1b'),'port':0x18eb});var socket=require(_0x5bb3('0x1c'))(new Redis(config[_0x5bb3('0x19')]));require(_0x5bb3('0x1d'))[_0x5bb3('0x1e')](socket);function respondWithStatusCode(_0x2835b1,_0x230dbf){_0x230dbf=_0x230dbf||0xcc;return function(_0x171369){if(_0x171369){return _0x2835b1['sendStatus'](_0x230dbf);}return _0x2835b1['status'](_0x230dbf)['end']();};}function respondWithResult(_0x3722f3,_0x1da0b6){_0x1da0b6=_0x1da0b6||0xc8;return function(_0x388802){if(_0x388802){return _0x3722f3[_0x5bb3('0x1f')](_0x1da0b6)[_0x5bb3('0x20')](_0x388802);}};}function respondWithFilteredResult(_0x24bd58,_0x364b86){return function(_0xbbaf0){if(_0xbbaf0){var _0x107dbb=typeof _0x364b86[_0x5bb3('0x21')]==='undefined'&&typeof _0x364b86['limit']===_0x5bb3('0x22');var _0x41c9a5=_0xbbaf0[_0x5bb3('0x23')];var _0x442ee2=_0x107dbb?0x0:_0x364b86[_0x5bb3('0x21')];var _0x3fe551=_0x107dbb?_0xbbaf0[_0x5bb3('0x23')]:_0x364b86['offset']+_0x364b86[_0x5bb3('0x24')];var _0x3b1325;if(_0x3fe551>=_0x41c9a5){_0x3fe551=_0x41c9a5;_0x3b1325=0xc8;}else{_0x3b1325=0xce;}_0x24bd58[_0x5bb3('0x1f')](_0x3b1325);return _0x24bd58['set'](_0x5bb3('0x25'),_0x442ee2+'-'+_0x3fe551+'/'+_0x41c9a5)['json'](_0xbbaf0);}return null;};}function patchUpdates(_0xa16d6e){return function(_0x4be614){try{jsonpatch[_0x5bb3('0x26')](_0x4be614,_0xa16d6e,!![]);}catch(_0x384f57){return BPromise[_0x5bb3('0x27')](_0x384f57);}return _0x4be614[_0x5bb3('0x28')]();};}function saveUpdates(_0x2f9ca3,_0x904ca3){return function(_0x2fa05b){if(_0x2fa05b){return _0x2fa05b['update'](_0x2f9ca3)[_0x5bb3('0x29')](function(_0x41e28f){return _0x41e28f;});}return null;};}function removeEntity(_0x4c4a7a,_0x439ee4){return function(_0x256a5f){if(_0x256a5f){return _0x256a5f[_0x5bb3('0x2a')]()[_0x5bb3('0x29')](function(){var _0x21da73=_0x256a5f[_0x5bb3('0x2b')]({'plain':!![]});var _0x405eea=_0x5bb3('0x2c');return db['UserProfileResource']['destroy']({'where':{'type':_0x405eea,'resourceId':_0x21da73['id']}})[_0x5bb3('0x29')](function(){return _0x256a5f;});})['then'](function(){_0x4c4a7a[_0x5bb3('0x1f')](0xcc)['end']();});}};}function handleEntityNotFound(_0x831fd4,_0xbdc0b5){return function(_0x104efe){if(!_0x104efe){_0x831fd4['sendStatus'](0x194);}return _0x104efe;};}function handleError(_0x28c825,_0x29a442){_0x29a442=_0x29a442||0x1f4;return function(_0x461109){logger[_0x5bb3('0x2d')](_0x461109['stack']);if(_0x461109['name']){delete _0x461109[_0x5bb3('0x2e')];}_0x28c825['status'](_0x29a442)[_0x5bb3('0x2f')](_0x461109);};}exports[_0x5bb3('0x30')]=function(_0x5217ca,_0x321834){var _0xd935a7={},_0x3d7115={},_0xe5981a={'count':0x0,'rows':[]};var _0x46ba29=_[_0x5bb3('0x31')](db[_0x5bb3('0x32')]['rawAttributes'],function(_0x554fc0){return{'name':_0x554fc0['fieldName'],'type':_0x554fc0[_0x5bb3('0x33')][_0x5bb3('0x34')]};});_0x3d7115[_0x5bb3('0x35')]=_[_0x5bb3('0x31')](_0x46ba29,'name');_0x3d7115['query']=_[_0x5bb3('0x36')](_0x5217ca[_0x5bb3('0x37')]);_0x3d7115[_0x5bb3('0x38')]=_[_0x5bb3('0x39')](_0x3d7115[_0x5bb3('0x35')],_0x3d7115[_0x5bb3('0x37')]);_0xd935a7['attributes']=_[_0x5bb3('0x39')](_0x3d7115[_0x5bb3('0x35')],qs[_0x5bb3('0x3a')](_0x5217ca[_0x5bb3('0x37')][_0x5bb3('0x3a')]));_0xd935a7['attributes']=_0xd935a7[_0x5bb3('0x3b')][_0x5bb3('0x3c')]?_0xd935a7[_0x5bb3('0x3b')]:_0x3d7115[_0x5bb3('0x35')];if(!_0x5217ca[_0x5bb3('0x37')][_0x5bb3('0x3d')](_0x5bb3('0x3e'))){_0xd935a7[_0x5bb3('0x24')]=qs[_0x5bb3('0x24')](_0x5217ca[_0x5bb3('0x37')]['limit']);_0xd935a7[_0x5bb3('0x21')]=qs[_0x5bb3('0x21')](_0x5217ca[_0x5bb3('0x37')][_0x5bb3('0x21')]);}_0xd935a7[_0x5bb3('0x3f')]=qs[_0x5bb3('0x40')](_0x5217ca[_0x5bb3('0x37')][_0x5bb3('0x40')]);_0xd935a7[_0x5bb3('0x41')]=qs[_0x5bb3('0x38')](_[_0x5bb3('0x42')](_0x5217ca['query'],_0x3d7115[_0x5bb3('0x38')]),_0x46ba29);if(_0x5217ca[_0x5bb3('0x37')]['filter']){_0xd935a7[_0x5bb3('0x41')]=_[_0x5bb3('0x43')](_0xd935a7[_0x5bb3('0x41')],{'$or':_[_0x5bb3('0x31')](_0x46ba29,function(_0x3a9858){if(_0x3a9858['type']!==_0x5bb3('0x44')){var _0x11a482={};_0x11a482[_0x3a9858[_0x5bb3('0x2e')]]={'$like':'%'+_0x5217ca[_0x5bb3('0x37')][_0x5bb3('0x45')]+'%'};return _0x11a482;}})});}_0xd935a7=_[_0x5bb3('0x43')]({},_0xd935a7,_0x5217ca['options']);var _0x6d6c39={'where':_0xd935a7['where']};return db[_0x5bb3('0x32')][_0x5bb3('0x23')](_0x6d6c39)['then'](function(_0x2f20c7){_0xe5981a['count']=_0x2f20c7;if(_0x5217ca[_0x5bb3('0x37')][_0x5bb3('0x46')]){_0xd935a7[_0x5bb3('0x47')]=[{'all':!![]}];}return db[_0x5bb3('0x32')][_0x5bb3('0x48')](_0xd935a7);})[_0x5bb3('0x29')](function(_0x58969c){_0xe5981a[_0x5bb3('0x49')]=_0x58969c;return _0xe5981a;})[_0x5bb3('0x29')](respondWithFilteredResult(_0x321834,_0xd935a7))[_0x5bb3('0x4a')](handleError(_0x321834,null));};exports[_0x5bb3('0x4b')]=function(_0x47cad3,_0x29f54f){var _0x36bdaf={'raw':!![],'where':{'id':_0x47cad3[_0x5bb3('0x4c')]['id']}},_0x3f46c8={};_0x3f46c8[_0x5bb3('0x35')]=_[_0x5bb3('0x36')](db[_0x5bb3('0x32')][_0x5bb3('0x4d')]);_0x3f46c8[_0x5bb3('0x37')]=_['keys'](_0x47cad3[_0x5bb3('0x37')]);_0x3f46c8[_0x5bb3('0x38')]=_[_0x5bb3('0x39')](_0x3f46c8[_0x5bb3('0x35')],_0x3f46c8[_0x5bb3('0x37')]);_0x36bdaf[_0x5bb3('0x3b')]=_[_0x5bb3('0x39')](_0x3f46c8[_0x5bb3('0x35')],qs[_0x5bb3('0x3a')](_0x47cad3[_0x5bb3('0x37')][_0x5bb3('0x3a')]));_0x36bdaf[_0x5bb3('0x3b')]=_0x36bdaf[_0x5bb3('0x3b')][_0x5bb3('0x3c')]?_0x36bdaf[_0x5bb3('0x3b')]:_0x3f46c8[_0x5bb3('0x35')];if(_0x47cad3[_0x5bb3('0x37')][_0x5bb3('0x46')]){_0x36bdaf[_0x5bb3('0x47')]=[{'all':!![]}];}_0x36bdaf=_[_0x5bb3('0x43')]({},_0x36bdaf,_0x47cad3[_0x5bb3('0x4e')]);return db[_0x5bb3('0x32')][_0x5bb3('0x4f')](_0x36bdaf)[_0x5bb3('0x29')](handleEntityNotFound(_0x29f54f,null))[_0x5bb3('0x29')](respondWithResult(_0x29f54f,null))[_0x5bb3('0x4a')](handleError(_0x29f54f,null));};exports[_0x5bb3('0x50')]=function(_0x444733,_0x24756a){return db[_0x5bb3('0x32')][_0x5bb3('0x50')](_0x444733['body'],{})[_0x5bb3('0x29')](function(_0x35be5e){var _0x531652=_0x444733[_0x5bb3('0x51')][_0x5bb3('0x2b')]({'plain':!![]});if(!_0x531652)throw new Error(_0x5bb3('0x52'));if(_0x531652['role']===_0x5bb3('0x51')){var _0xa2e5ca=_0x35be5e[_0x5bb3('0x2b')]({'plain':!![]});var _0x44e6df=_0x5bb3('0x2c');return db[_0x5bb3('0x53')]['find']({'where':{'name':_0x44e6df,'userProfileId':_0x531652[_0x5bb3('0x54')]},'raw':!![]})['then'](function(_0xffa73e){if(_0xffa73e&&_0xffa73e[_0x5bb3('0x55')]===0x0){return db[_0x5bb3('0x56')][_0x5bb3('0x50')]({'name':_0xa2e5ca['name'],'resourceId':_0xa2e5ca['id'],'type':_0xffa73e['name'],'sectionId':_0xffa73e['id']},{})[_0x5bb3('0x29')](function(){return _0x35be5e;});}else{return _0x35be5e;}})[_0x5bb3('0x4a')](function(_0x5747dc){logger['error'](_0x5bb3('0x57'),_0x5747dc);throw _0x5747dc;});}return _0x35be5e;})[_0x5bb3('0x29')](respondWithResult(_0x24756a,0xc9))[_0x5bb3('0x4a')](handleError(_0x24756a,null));};exports[_0x5bb3('0x58')]=function(_0x592b58,_0x2122d1){if(_0x592b58[_0x5bb3('0x59')]['id']){delete _0x592b58[_0x5bb3('0x59')]['id'];}return db[_0x5bb3('0x32')]['find']({'where':{'id':_0x592b58[_0x5bb3('0x4c')]['id']}})[_0x5bb3('0x29')](handleEntityNotFound(_0x2122d1,null))[_0x5bb3('0x29')](saveUpdates(_0x592b58[_0x5bb3('0x59')],null))[_0x5bb3('0x29')](respondWithResult(_0x2122d1,null))[_0x5bb3('0x4a')](handleError(_0x2122d1,null));};exports[_0x5bb3('0x2a')]=function(_0x52c3de,_0x35de29){return db['SmsQueue'][_0x5bb3('0x4f')]({'where':{'id':_0x52c3de[_0x5bb3('0x4c')]['id']}})['then'](handleEntityNotFound(_0x35de29,null))[_0x5bb3('0x29')](removeEntity(_0x35de29,null))[_0x5bb3('0x4a')](handleError(_0x35de29,null));};exports['describe']=function(_0x5be32c,_0x431cb9){return db[_0x5bb3('0x32')][_0x5bb3('0x5a')]()[_0x5bb3('0x29')](respondWithResult(_0x431cb9,null))[_0x5bb3('0x4a')](handleError(_0x431cb9,null));};exports[_0x5bb3('0x5b')]=function(_0x5ae3e0,_0x2f44ad,_0x2959b3){var _0x43b153={'raw':!![],'where':{}},_0x455232={},_0x153341;return db[_0x5bb3('0x32')][_0x5bb3('0x5c')]({'where':{'id':_0x5ae3e0[_0x5bb3('0x4c')]['id']}})['then'](handleEntityNotFound(_0x2f44ad,null))[_0x5bb3('0x29')](function(_0x51fb55){if(_0x51fb55){_0x153341=_0x51fb55[_0x5bb3('0x2b')]({'plain':!![]});_0x455232[_0x5bb3('0x35')]=_[_0x5bb3('0x36')](db[_0x5bb3('0x5d')]['rawAttributes']);_0x455232[_0x5bb3('0x37')]=_['keys'](_0x5ae3e0[_0x5bb3('0x37')]);_0x455232[_0x5bb3('0x38')]=_['intersection'](_0x455232[_0x5bb3('0x35')],_0x455232[_0x5bb3('0x37')]);_0x43b153[_0x5bb3('0x3b')]=_[_0x5bb3('0x39')](_0x455232[_0x5bb3('0x35')],qs[_0x5bb3('0x3a')](_0x5ae3e0[_0x5bb3('0x37')][_0x5bb3('0x3a')]));_0x43b153['attributes']=_0x43b153['attributes'][_0x5bb3('0x3c')]?_0x43b153[_0x5bb3('0x3b')]:_0x455232[_0x5bb3('0x35')];if(!_0x5ae3e0['query'][_0x5bb3('0x3d')](_0x5bb3('0x3e'))){_0x43b153[_0x5bb3('0x24')]=qs[_0x5bb3('0x24')](_0x5ae3e0[_0x5bb3('0x37')]['limit']);_0x43b153[_0x5bb3('0x21')]=qs[_0x5bb3('0x21')](_0x5ae3e0['query'][_0x5bb3('0x21')]);}_0x43b153[_0x5bb3('0x3f')]=qs[_0x5bb3('0x40')](_0x5ae3e0[_0x5bb3('0x37')]['sort']);_0x43b153[_0x5bb3('0x41')]=qs[_0x5bb3('0x38')](_[_0x5bb3('0x42')](_0x5ae3e0[_0x5bb3('0x37')],_0x455232[_0x5bb3('0x38')]));_0x43b153[_0x5bb3('0x41')][_0x5bb3('0x5e')]=_0x51fb55['id'];if(_0x5ae3e0['query'][_0x5bb3('0x45')]){_0x43b153[_0x5bb3('0x41')]=_[_0x5bb3('0x43')](_0x43b153[_0x5bb3('0x41')],{'$or':_[_0x5bb3('0x31')](_0x43b153[_0x5bb3('0x3b')],function(_0x657d98){var _0x2194fd={};_0x2194fd[_0x657d98]={'$like':'%'+_0x5ae3e0[_0x5bb3('0x37')][_0x5bb3('0x45')]+'%'};return _0x2194fd;})});}_0x43b153=_[_0x5bb3('0x43')]({},_0x43b153,_0x5ae3e0[_0x5bb3('0x4e')]);return db['UserSmsQueue'][_0x5bb3('0x48')](_0x43b153);}})[_0x5bb3('0x29')](function(_0x2c3616){if(_0x2c3616){return db[_0x5bb3('0x5f')]['findAndCountAll']({'where':{'id':_[_0x5bb3('0x31')](_0x2c3616,_0x5bb3('0x60')),'role':_0x5bb3('0x61')},'attributes':['id',_0x5bb3('0x2e'),_0x5bb3('0x62'),'updatedAt',_0x5bb3('0x63')]});}})[_0x5bb3('0x29')](function(_0xf48593){if(_0xf48593){return{'count':_0xf48593['count'],'rows':_['map'](_0xf48593[_0x5bb3('0x49')],function(_0x197fa9){return{'membername':_0x197fa9[_0x5bb3('0x2e')],'UserId':_0x197fa9['id'],'queue_name':_0x153341[_0x5bb3('0x2e')],'SmsQueueId':_0x153341['id'],'interface':util['format'](_0x5bb3('0x64'),_0x5bb3('0x65'),_0x197fa9[_0x5bb3('0x2e')]),'penalty':0x0,'paused':_0x197fa9['smsPause'],'createdAt':_0x197fa9[_0x5bb3('0x63')],'updatedAt':_0x197fa9['updatedAt']};})};}else{return{'count':0x0,'rows':[]};}})['then'](respondWithFilteredResult(_0x2f44ad,_0x43b153))[_0x5bb3('0x4a')](handleError(_0x2f44ad,null));};exports['getTeams']=function(_0x3e7fde,_0x39ce15,_0x528f54){var _0x4f66fb={};var _0x5983e5={};var _0x53ff47;var _0x4f21c2;return db[_0x5bb3('0x32')][_0x5bb3('0x5c')]({'where':{'id':_0x3e7fde['params']['id']}})[_0x5bb3('0x29')](handleEntityNotFound(_0x39ce15,null))[_0x5bb3('0x29')](function(_0x4d12c2){if(_0x4d12c2){_0x53ff47=_0x4d12c2;_0x5983e5[_0x5bb3('0x35')]=_[_0x5bb3('0x36')](db['Team'][_0x5bb3('0x4d')]);_0x5983e5['query']=_[_0x5bb3('0x36')](_0x3e7fde[_0x5bb3('0x37')]);_0x5983e5[_0x5bb3('0x38')]=_[_0x5bb3('0x39')](_0x5983e5[_0x5bb3('0x35')],_0x5983e5[_0x5bb3('0x37')]);_0x4f66fb[_0x5bb3('0x3b')]=_[_0x5bb3('0x39')](_0x5983e5[_0x5bb3('0x35')],qs[_0x5bb3('0x3a')](_0x3e7fde[_0x5bb3('0x37')][_0x5bb3('0x3a')]));_0x4f66fb[_0x5bb3('0x3b')]=_0x4f66fb['attributes']['length']?_0x4f66fb[_0x5bb3('0x3b')]:_0x5983e5[_0x5bb3('0x35')];_0x4f66fb[_0x5bb3('0x3f')]=qs[_0x5bb3('0x40')](_0x3e7fde[_0x5bb3('0x37')][_0x5bb3('0x40')]);_0x4f66fb[_0x5bb3('0x41')]=qs[_0x5bb3('0x38')](_[_0x5bb3('0x42')](_0x3e7fde[_0x5bb3('0x37')],_0x5983e5[_0x5bb3('0x38')]));if(_0x3e7fde[_0x5bb3('0x37')][_0x5bb3('0x45')]){_0x4f66fb[_0x5bb3('0x41')]=_[_0x5bb3('0x43')](_0x4f66fb['where'],{'$or':_[_0x5bb3('0x31')](_0x4f66fb['attributes'],function(_0x27a6e2){var _0x1c5642={};_0x1c5642[_0x27a6e2]={'$like':'%'+_0x3e7fde[_0x5bb3('0x37')][_0x5bb3('0x45')]+'%'};return _0x1c5642;})});}_0x4f66fb=_[_0x5bb3('0x43')]({},_0x4f66fb,_0x3e7fde['options']);return _0x53ff47[_0x5bb3('0x66')](_0x4f66fb);}})['then'](function(_0x348766){if(_0x348766){_0x4f21c2=_0x348766[_0x5bb3('0x3c')];if(!_0x3e7fde[_0x5bb3('0x37')][_0x5bb3('0x3d')](_0x5bb3('0x3e'))){_0x4f66fb[_0x5bb3('0x24')]=qs['limit'](_0x3e7fde[_0x5bb3('0x37')][_0x5bb3('0x24')]);_0x4f66fb[_0x5bb3('0x21')]=qs[_0x5bb3('0x21')](_0x3e7fde[_0x5bb3('0x37')]['offset']);}return _0x53ff47[_0x5bb3('0x66')](_0x4f66fb);}})[_0x5bb3('0x29')](function(_0x5d961a){if(_0x5d961a){return _0x5d961a?{'count':_0x4f21c2,'rows':_0x5d961a}:null;}})[_0x5bb3('0x29')](respondWithResult(_0x39ce15,null))[_0x5bb3('0x4a')](handleError(_0x39ce15,null));};exports[_0x5bb3('0x67')]=function(_0x19464d,_0x1acdd5,_0x5bdc5f){var _0x37c28f=_0x19464d[_0x5bb3('0x59')][_0x5bb3('0x68')];return db[_0x5bb3('0x69')]['findAll']({'where':{'id':_0x37c28f},'attributes':['id'],'include':[{'model':db['User'],'as':_0x5bb3('0x6a'),'attributes':['id',_0x5bb3('0x2e'),_0x5bb3('0x6b'),_0x5bb3('0x6c'),_0x5bb3('0x6d')],'raw':!![]}]})['then'](function(_0x152a66){if(_0x152a66){var _0x374e44=_['flatMap'](_0x152a66,function(_0x1c1e7f){var _0x4e5f5a=_0x1c1e7f['get']({'plain':!![]});return _0x4e5f5a[_0x5bb3('0x6a')];});return db[_0x5bb3('0x32')][_0x5bb3('0x4f')]({'where':{'id':_0x19464d[_0x5bb3('0x4c')]['id']}})[_0x5bb3('0x29')](function(_0x42559e){return db[_0x5bb3('0x6e')][_0x5bb3('0x6f')](function(_0x3f3f57){return _0x42559e[_0x5bb3('0x67')](_0x37c28f,{'transaction':_0x3f3f57})[_0x5bb3('0x29')](function(){return BPromise[_0x5bb3('0x70')](_0x374e44,function(_0x30352d){return db['UserSmsQueue'][_0x5bb3('0x71')]({'where':{'UserId':_0x30352d['id'],'SmsQueueId':_0x19464d[_0x5bb3('0x4c')]['id']},'transaction':_0x3f3f57});});})[_0x5bb3('0x29')](function(){_0x374e44['forEach'](function(_0x1389b2){socket[_0x5bb3('0x72')](_0x5bb3('0x73'),{'UserId':_0x1389b2['id'],'SmsQueueId':_0x42559e['id']});});});});});}})['then'](respondWithStatusCode(_0x1acdd5,null))['catch'](handleError(_0x1acdd5,null));};exports[_0x5bb3('0x74')]=function(_0x251432,_0xb50e40,_0x3dd97f){return db[_0x5bb3('0x69')]['findAll']({'where':{'id':_0x251432[_0x5bb3('0x37')][_0x5bb3('0x68')]},'attributes':['id'],'include':[{'model':db['User'],'as':_0x5bb3('0x6a'),'attributes':['id'],'raw':!![]}]})[_0x5bb3('0x29')](handleEntityNotFound(_0xb50e40,null))['then'](function(_0x5f0234){var _0x579f7b=_['map'](_0x5f0234,'id');var _0x2db4b6=[];var _0x4effe3=[];var _0x200b21=squel[_0x5bb3('0x75')]();_0x200b21[_0x5bb3('0x76')]('tq.TeamId')['from'](_0x5bb3('0x77'),'tq')[_0x5bb3('0x78')]('user_has_teams','ut',_0x5bb3('0x79'))[_0x5bb3('0x41')]('SmsQueueId\x20=\x20?',_0x251432[_0x5bb3('0x4c')]['id']);for(var _0x19b3c6=0x0;_0x19b3c6<_0x5f0234[_0x5bb3('0x3c')];_0x19b3c6+=0x1){let _0x302eb9=_0x5f0234[_0x19b3c6];for(var _0x2cb0ec=0x0;_0x2cb0ec<_0x302eb9[_0x5bb3('0x6a')][_0x5bb3('0x3c')];_0x2cb0ec+=0x1){let _0x588b7e=_0x302eb9[_0x5bb3('0x6a')][_0x2cb0ec];var _0x3b20a3=_0x200b21['clone']();_0x3b20a3[_0x5bb3('0x41')]('ut.UserId\x20=\x20?',_0x588b7e['id']);_0x4effe3[_0x5bb3('0x7a')](db[_0x5bb3('0x6e')][_0x5bb3('0x37')](_0x3b20a3[_0x5bb3('0x7b')](),{'type':db['sequelize'][_0x5bb3('0x7c')][_0x5bb3('0x7d')]})['then'](function(_0x50a44b){if(_0x50a44b['length']===0x1){return _0x588b7e['id'];}else{var _0x4d8683=_['every'](_[_0x5bb3('0x31')](_0x50a44b,'TeamId'),function(_0xd83db8){return _[_0x5bb3('0x7e')](_0x579f7b,_0xd83db8);});if(_0x4d8683){return _0x588b7e['id'];}}}));}}return BPromise[_0x5bb3('0x7f')](_0x4effe3)[_0x5bb3('0x29')](function(_0x1ba8fb){_0x2db4b6=_(_0x2db4b6)[_0x5bb3('0x80')](_0x1ba8fb)[_0x5bb3('0x81')]()[_0x5bb3('0x82')]();return db[_0x5bb3('0x32')]['find']({'where':{'id':_0x251432[_0x5bb3('0x4c')]['id']}})[_0x5bb3('0x29')](function(_0xbd0914){return db['sequelize'][_0x5bb3('0x6f')](function(_0x45bd9d){return _0xbd0914[_0x5bb3('0x74')](_0x251432[_0x5bb3('0x37')][_0x5bb3('0x68')],{'transaction':_0x45bd9d})[_0x5bb3('0x29')](function(){if(!_[_0x5bb3('0x83')](_0x2db4b6)){return _0xbd0914[_0x5bb3('0x84')](_0x2db4b6,{'transaction':_0x45bd9d});}})['then'](function(){_0x2db4b6[_0x5bb3('0x85')](function(_0x156351){socket['emit'](_0x5bb3('0x86'),{'UserId':_0x156351,'SmsQueueId':_0xbd0914['id']});});});});});});})[_0x5bb3('0x29')](respondWithStatusCode(_0xb50e40,null))[_0x5bb3('0x4a')](handleError(_0xb50e40,null));};exports[_0x5bb3('0x87')]=function(_0x3ee41c,_0x16bf70,_0x320afc){return db[_0x5bb3('0x32')][_0x5bb3('0x4f')]({'where':{'id':_0x3ee41c['params']['id']}})['then'](handleEntityNotFound(_0x16bf70,null))[_0x5bb3('0x29')](function(_0x1b5a4c){if(_0x1b5a4c){return _0x1b5a4c[_0x5bb3('0x87')](_0x3ee41c[_0x5bb3('0x59')][_0x5bb3('0x68')],_[_0x5bb3('0x88')](_0x3ee41c['body'],[_0x5bb3('0x68'),'id'])||{})[_0x5bb3('0x89')](function(_0x3ce8cd){for(var _0x67ac4c=0x0;_0x67ac4c<_0x3ee41c['body'][_0x5bb3('0x68')][_0x5bb3('0x3c')];_0x67ac4c+=0x1){socket[_0x5bb3('0x72')]('userSmsQueue:save',{'UserId':Number(_0x3ee41c[_0x5bb3('0x59')][_0x5bb3('0x68')][_0x67ac4c]),'SmsQueueId':Number(_0x3ee41c[_0x5bb3('0x4c')]['id'])});}return _0x3ce8cd;});}})[_0x5bb3('0x29')](respondWithResult(_0x16bf70,null))['catch'](handleError(_0x16bf70,null));};exports[_0x5bb3('0x84')]=function(_0x750eab,_0x27f139,_0x116cb4){return db['SmsQueue'][_0x5bb3('0x4f')]({'where':{'id':_0x750eab['params']['id']}})[_0x5bb3('0x29')](handleEntityNotFound(_0x27f139,null))[_0x5bb3('0x29')](function(_0x518b2a){if(_0x518b2a){return _0x518b2a[_0x5bb3('0x84')](_0x750eab[_0x5bb3('0x37')][_0x5bb3('0x68')])['then'](function(){if(_['isArray'](_0x750eab[_0x5bb3('0x37')][_0x5bb3('0x68')])){for(var _0x21f45c=0x0;_0x21f45c<_0x750eab[_0x5bb3('0x37')][_0x5bb3('0x68')][_0x5bb3('0x3c')];_0x21f45c+=0x1){socket['emit'](_0x5bb3('0x86'),{'UserId':Number(_0x750eab[_0x5bb3('0x37')][_0x5bb3('0x68')][_0x21f45c]),'SmsQueueId':Number(_0x750eab[_0x5bb3('0x4c')]['id'])});}}else{socket[_0x5bb3('0x72')](_0x5bb3('0x86'),{'UserId':Number(_0x750eab[_0x5bb3('0x37')][_0x5bb3('0x68')]),'SmsQueueId':Number(_0x750eab[_0x5bb3('0x4c')]['id'])});}});}})['then'](respondWithStatusCode(_0x27f139,null))[_0x5bb3('0x4a')](handleError(_0x27f139,null));};exports[_0x5bb3('0x8a')]=function(_0x3c0c9a,_0x74e7c2,_0x335f9e){var _0x4fb940={};var _0x1cd0eb={};var _0x57de9f;var _0x4696be;return db['SmsQueue']['findOne']({'where':{'id':_0x3c0c9a['params']['id']}})['then'](handleEntityNotFound(_0x74e7c2,null))[_0x5bb3('0x29')](function(_0x35ad11){if(_0x35ad11){_0x57de9f=_0x35ad11;_0x1cd0eb['model']=_[_0x5bb3('0x36')](db['User']['rawAttributes']);_0x1cd0eb['query']=_[_0x5bb3('0x36')](_0x3c0c9a['query']);_0x1cd0eb[_0x5bb3('0x38')]=_[_0x5bb3('0x39')](_0x1cd0eb[_0x5bb3('0x35')],_0x1cd0eb['query']);_0x4fb940[_0x5bb3('0x3b')]=_[_0x5bb3('0x39')](_0x1cd0eb[_0x5bb3('0x35')],qs[_0x5bb3('0x3a')](_0x3c0c9a[_0x5bb3('0x37')][_0x5bb3('0x3a')]));_0x4fb940['attributes']=_0x4fb940[_0x5bb3('0x3b')][_0x5bb3('0x3c')]?_0x4fb940[_0x5bb3('0x3b')]:_0x1cd0eb[_0x5bb3('0x35')];_0x4fb940[_0x5bb3('0x3f')]=qs[_0x5bb3('0x40')](_0x3c0c9a[_0x5bb3('0x37')][_0x5bb3('0x40')]);_0x4fb940[_0x5bb3('0x41')]=qs[_0x5bb3('0x38')](_[_0x5bb3('0x42')](_0x3c0c9a[_0x5bb3('0x37')],_0x1cd0eb[_0x5bb3('0x38')]));if(_0x3c0c9a[_0x5bb3('0x37')][_0x5bb3('0x45')]){_0x4fb940[_0x5bb3('0x41')]=_[_0x5bb3('0x43')](_0x4fb940[_0x5bb3('0x41')],{'$or':_[_0x5bb3('0x31')](_0x4fb940[_0x5bb3('0x3b')],function(_0x43b1cb){var _0x44e537={};_0x44e537[_0x43b1cb]={'$like':'%'+_0x3c0c9a['query'][_0x5bb3('0x45')]+'%'};return _0x44e537;})});}_0x4fb940=_[_0x5bb3('0x43')]({},_0x4fb940,_0x3c0c9a[_0x5bb3('0x4e')]);return _0x57de9f[_0x5bb3('0x8a')](_0x4fb940);}})[_0x5bb3('0x29')](function(_0x51c9b4){if(_0x51c9b4){_0x4696be=_0x51c9b4[_0x5bb3('0x3c')];if(!_0x3c0c9a[_0x5bb3('0x37')][_0x5bb3('0x3d')]('nolimit')){_0x4fb940[_0x5bb3('0x24')]=qs[_0x5bb3('0x24')](_0x3c0c9a[_0x5bb3('0x37')]['limit']);_0x4fb940[_0x5bb3('0x21')]=qs['offset'](_0x3c0c9a[_0x5bb3('0x37')][_0x5bb3('0x21')]);}return _0x57de9f['getAgents'](_0x4fb940);}})[_0x5bb3('0x29')](function(_0x53e8b2){if(_0x53e8b2){return _0x53e8b2?{'count':_0x4696be,'rows':_0x53e8b2}:null;}})['then'](respondWithResult(_0x74e7c2,null))['catch'](handleError(_0x74e7c2,null));};
\ No newline at end of file