Built motion from commit 10af8726.|2.6.34
[motion2.git] / server / api / smsQueue / smsQueue.controller.js
index b9456ba..c998908 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xcd59=['emit','removeTeams','select','field','tq.TeamId','from','team_has_sms_queues','join','user_has_teams','ut.TeamId\x20=\x20tq.TeamId','SmsQueueId\x20=\x20?','clone','ut.UserId\x20=\x20?','toString','QueryTypes','SELECT','every','TeamId','includes','all','union','compact','value','transaction','isEmpty','removeAgents','userSmsQueue:remove','omit','spread','userSmsQueue:save','getAgents','html-pdf','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','bluebird','mustache','util','path','sox','to-csv','ejs','lodash','squel','crypto','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/utils','../../config/environment','redis','defaults','localhost','socket.io-emitter','register','end','status','json','offset','limit','set','apply','reject','save','update','then','destroy','get','SmsQueues','sendStatus','error','stack','name','send','index','map','rawAttributes','key','model','query','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','filter','merge','type','VIRTUAL','options','SmsQueue','count','include','findAll','rows','show','params','keys','includeAll','find','catch','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','UserProfileSection','userProfileId','autoAssociation','UserProfileResource','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','describe','getMembers','findOne','UserSmsQueue','pick','SmsQueueId','User','findAndCountAll','agent','smsPause','updatedAt','createdAt','format','%s/%s','SIP','getTeams','addTeams','ids','Team','Agents','online','voicePause','flatMap','sequelize','each','findOrCreate','forEach'];(function(_0x599f41,_0x4db732){var _0x2e4d58=function(_0x14c882){while(--_0x14c882){_0x599f41['push'](_0x599f41['shift']());}};_0x2e4d58(++_0x4db732);}(_0xcd59,0x14b));var _0x9cd5=function(_0x338b15,_0x3202d8){_0x338b15=_0x338b15-0x0;var _0x466e43=_0xcd59[_0x338b15];return _0x466e43;};'use strict';var pdf=require(_0x9cd5('0x0'));var emlformat=require(_0x9cd5('0x1'));var rimraf=require(_0x9cd5('0x2'));var zipdir=require(_0x9cd5('0x3'));var jsonpatch=require(_0x9cd5('0x4'));var rp=require(_0x9cd5('0x5'));var moment=require('moment');var BPromise=require(_0x9cd5('0x6'));var Mustache=require(_0x9cd5('0x7'));var util=require(_0x9cd5('0x8'));var path=require(_0x9cd5('0x9'));var sox=require(_0x9cd5('0xa'));var csv=require(_0x9cd5('0xb'));var ejs=require(_0x9cd5('0xc'));var fs=require('fs');var _=require(_0x9cd5('0xd'));var squel=require(_0x9cd5('0xe'));var crypto=require(_0x9cd5('0xf'));var jsforce=require('jsforce');var deskjs=require(_0x9cd5('0x10'));var toCsv=require(_0x9cd5('0xb'));var querystring=require(_0x9cd5('0x11'));var Papa=require(_0x9cd5('0x12'));var Redis=require(_0x9cd5('0x13'));var authService=require(_0x9cd5('0x14'));var qs=require(_0x9cd5('0x15'));var as=require(_0x9cd5('0x16'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x9cd5('0x17'))(_0x9cd5('0x18'));var utils=require(_0x9cd5('0x19'));var config=require(_0x9cd5('0x1a'));var licenseUtil=require('../../config/license/util');var db=require('../../mysqldb')['db'];config[_0x9cd5('0x1b')]=_[_0x9cd5('0x1c')](config[_0x9cd5('0x1b')],{'host':_0x9cd5('0x1d'),'port':0x18eb});var socket=require(_0x9cd5('0x1e'))(new Redis(config[_0x9cd5('0x1b')]));require('./smsQueue.socket')[_0x9cd5('0x1f')](socket);function respondWithStatusCode(_0x1445c0,_0x21d768){_0x21d768=_0x21d768||0xcc;return function(_0x4b9ac8){if(_0x4b9ac8){return _0x1445c0['sendStatus'](_0x21d768);}return _0x1445c0['status'](_0x21d768)[_0x9cd5('0x20')]();};}function respondWithResult(_0x1ea3f7,_0x565db7){_0x565db7=_0x565db7||0xc8;return function(_0x24c233){if(_0x24c233){return _0x1ea3f7[_0x9cd5('0x21')](_0x565db7)[_0x9cd5('0x22')](_0x24c233);}};}function respondWithFilteredResult(_0x57b986,_0x1e921c){return function(_0x2d1863){if(_0x2d1863){var _0x3a364f=_0x2d1863['count'],_0x3a6f01=_0x1e921c[_0x9cd5('0x23')],_0x21da57=_0x1e921c[_0x9cd5('0x23')]+_0x1e921c[_0x9cd5('0x24')],_0x1ff788;if(_0x21da57>=_0x3a364f){_0x21da57=_0x3a364f;_0x1ff788=0xc8;}else{_0x1ff788=0xce;}_0x57b986[_0x9cd5('0x21')](_0x1ff788);return _0x57b986[_0x9cd5('0x25')]('Content-Range',_0x3a6f01+'-'+_0x21da57+'/'+_0x3a364f)[_0x9cd5('0x22')](_0x2d1863);}return null;};}function patchUpdates(_0x271444){return function(_0x3f1f5c){try{jsonpatch[_0x9cd5('0x26')](_0x3f1f5c,_0x271444,!![]);}catch(_0x2ce1ae){return BPromise[_0x9cd5('0x27')](_0x2ce1ae);}return _0x3f1f5c[_0x9cd5('0x28')]();};}function saveUpdates(_0x2238ec,_0x384dd1){return function(_0x4f0771){if(_0x4f0771){return _0x4f0771[_0x9cd5('0x29')](_0x2238ec)[_0x9cd5('0x2a')](function(_0x1a88e3){return _0x1a88e3;});}return null;};}function removeEntity(_0x43f47d,_0x56c05d){return function(_0x24ae67){if(_0x24ae67){return _0x24ae67[_0x9cd5('0x2b')]()[_0x9cd5('0x2a')](function(){var _0xe36f86=_0x24ae67[_0x9cd5('0x2c')]({'plain':!![]});var _0x4509e7=_0x9cd5('0x2d');return db['UserProfileResource'][_0x9cd5('0x2b')]({'where':{'type':_0x4509e7,'resourceId':_0xe36f86['id']}})[_0x9cd5('0x2a')](function(){return _0x24ae67;});})[_0x9cd5('0x2a')](function(){_0x43f47d['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0x2e45a3,_0x502257){return function(_0x52ef5d){if(!_0x52ef5d){_0x2e45a3[_0x9cd5('0x2e')](0x194);}return _0x52ef5d;};}function handleError(_0x2a20d2,_0x13e0d3){_0x13e0d3=_0x13e0d3||0x1f4;return function(_0x5184b9){logger[_0x9cd5('0x2f')](_0x5184b9[_0x9cd5('0x30')]);if(_0x5184b9[_0x9cd5('0x31')]){delete _0x5184b9[_0x9cd5('0x31')];}_0x2a20d2[_0x9cd5('0x21')](_0x13e0d3)[_0x9cd5('0x32')](_0x5184b9);};}exports[_0x9cd5('0x33')]=function(_0x9d054d,_0x36b0ad){var _0x1c81fd={},_0x3dc2c0={},_0x4287bd={'count':0x0,'rows':[]};var _0x32c4b7=_[_0x9cd5('0x34')](db['SmsQueue'][_0x9cd5('0x35')],function(_0x2a6a34){return{'name':_0x2a6a34['fieldName'],'type':_0x2a6a34['type'][_0x9cd5('0x36')]};});_0x3dc2c0[_0x9cd5('0x37')]=_['map'](_0x32c4b7,_0x9cd5('0x31'));_0x3dc2c0['query']=_['keys'](_0x9d054d[_0x9cd5('0x38')]);_0x3dc2c0[_0x9cd5('0x39')]=_[_0x9cd5('0x3a')](_0x3dc2c0[_0x9cd5('0x37')],_0x3dc2c0['query']);_0x1c81fd[_0x9cd5('0x3b')]=_[_0x9cd5('0x3a')](_0x3dc2c0[_0x9cd5('0x37')],qs['fields'](_0x9d054d[_0x9cd5('0x38')][_0x9cd5('0x3c')]));_0x1c81fd[_0x9cd5('0x3b')]=_0x1c81fd[_0x9cd5('0x3b')][_0x9cd5('0x3d')]?_0x1c81fd[_0x9cd5('0x3b')]:_0x3dc2c0[_0x9cd5('0x37')];if(!_0x9d054d[_0x9cd5('0x38')][_0x9cd5('0x3e')](_0x9cd5('0x3f'))){_0x1c81fd[_0x9cd5('0x24')]=qs['limit'](_0x9d054d[_0x9cd5('0x38')]['limit']);_0x1c81fd['offset']=qs[_0x9cd5('0x23')](_0x9d054d[_0x9cd5('0x38')][_0x9cd5('0x23')]);}_0x1c81fd[_0x9cd5('0x40')]=qs['sort'](_0x9d054d[_0x9cd5('0x38')][_0x9cd5('0x41')]);_0x1c81fd[_0x9cd5('0x42')]=qs[_0x9cd5('0x39')](_['pick'](_0x9d054d[_0x9cd5('0x38')],_0x3dc2c0[_0x9cd5('0x39')]),_0x32c4b7);if(_0x9d054d[_0x9cd5('0x38')][_0x9cd5('0x43')]){_0x1c81fd[_0x9cd5('0x42')]=_[_0x9cd5('0x44')](_0x1c81fd['where'],{'$or':_[_0x9cd5('0x34')](_0x32c4b7,function(_0x2cbc5f){if(_0x2cbc5f[_0x9cd5('0x45')]!==_0x9cd5('0x46')){var _0x3fe472={};_0x3fe472[_0x2cbc5f[_0x9cd5('0x31')]]={'$like':'%'+_0x9d054d[_0x9cd5('0x38')][_0x9cd5('0x43')]+'%'};return _0x3fe472;}})});}_0x1c81fd=_[_0x9cd5('0x44')]({},_0x1c81fd,_0x9d054d[_0x9cd5('0x47')]);var _0xe11308={'where':_0x1c81fd[_0x9cd5('0x42')]};return db[_0x9cd5('0x48')][_0x9cd5('0x49')](_0xe11308)[_0x9cd5('0x2a')](function(_0x1c84a4){_0x4287bd[_0x9cd5('0x49')]=_0x1c84a4;if(_0x9d054d[_0x9cd5('0x38')]['includeAll']){_0x1c81fd[_0x9cd5('0x4a')]=[{'all':!![]}];}return db['SmsQueue'][_0x9cd5('0x4b')](_0x1c81fd);})[_0x9cd5('0x2a')](function(_0xaa50a){_0x4287bd[_0x9cd5('0x4c')]=_0xaa50a;return _0x4287bd;})[_0x9cd5('0x2a')](respondWithFilteredResult(_0x36b0ad,_0x1c81fd))['catch'](handleError(_0x36b0ad,null));};exports[_0x9cd5('0x4d')]=function(_0x41a07e,_0x3ccc0e){var _0x54ffdf={'raw':!![],'where':{'id':_0x41a07e[_0x9cd5('0x4e')]['id']}},_0xd3303a={};_0xd3303a[_0x9cd5('0x37')]=_[_0x9cd5('0x4f')](db['SmsQueue'][_0x9cd5('0x35')]);_0xd3303a[_0x9cd5('0x38')]=_[_0x9cd5('0x4f')](_0x41a07e[_0x9cd5('0x38')]);_0xd3303a[_0x9cd5('0x39')]=_[_0x9cd5('0x3a')](_0xd3303a[_0x9cd5('0x37')],_0xd3303a[_0x9cd5('0x38')]);_0x54ffdf[_0x9cd5('0x3b')]=_[_0x9cd5('0x3a')](_0xd3303a[_0x9cd5('0x37')],qs[_0x9cd5('0x3c')](_0x41a07e[_0x9cd5('0x38')][_0x9cd5('0x3c')]));_0x54ffdf[_0x9cd5('0x3b')]=_0x54ffdf[_0x9cd5('0x3b')][_0x9cd5('0x3d')]?_0x54ffdf[_0x9cd5('0x3b')]:_0xd3303a['model'];if(_0x41a07e[_0x9cd5('0x38')][_0x9cd5('0x50')]){_0x54ffdf[_0x9cd5('0x4a')]=[{'all':!![]}];}_0x54ffdf=_[_0x9cd5('0x44')]({},_0x54ffdf,_0x41a07e['options']);return db[_0x9cd5('0x48')][_0x9cd5('0x51')](_0x54ffdf)['then'](handleEntityNotFound(_0x3ccc0e,null))[_0x9cd5('0x2a')](respondWithResult(_0x3ccc0e,null))[_0x9cd5('0x52')](handleError(_0x3ccc0e,null));};exports[_0x9cd5('0x53')]=function(_0x26b4c8,_0x16afe8){return db[_0x9cd5('0x48')][_0x9cd5('0x53')](_0x26b4c8[_0x9cd5('0x54')],{})['then'](function(_0x48be3a){var _0x1f2278=_0x26b4c8[_0x9cd5('0x55')][_0x9cd5('0x2c')]({'plain':!![]});if(!_0x1f2278)throw new Error(_0x9cd5('0x56'));if(_0x1f2278['role']===_0x9cd5('0x55')){var _0x55ac13=_0x48be3a['get']({'plain':!![]});var _0x46842b=_0x9cd5('0x2d');return db[_0x9cd5('0x57')]['find']({'where':{'name':_0x46842b,'userProfileId':_0x1f2278[_0x9cd5('0x58')]},'raw':!![]})[_0x9cd5('0x2a')](function(_0x310e4a){if(_0x310e4a&&_0x310e4a[_0x9cd5('0x59')]===0x0){return db[_0x9cd5('0x5a')][_0x9cd5('0x53')]({'name':_0x55ac13['name'],'resourceId':_0x55ac13['id'],'type':_0x310e4a['name'],'sectionId':_0x310e4a['id']},{})[_0x9cd5('0x2a')](function(){return _0x48be3a;});}else{return _0x48be3a;}})[_0x9cd5('0x52')](function(_0xcf0a9a){logger[_0x9cd5('0x2f')](_0x9cd5('0x5b'),_0xcf0a9a);throw _0xcf0a9a;});}return _0x48be3a;})['then'](respondWithResult(_0x16afe8,0xc9))['catch'](handleError(_0x16afe8,null));};exports['update']=function(_0x4cb835,_0xe8c694){if(_0x4cb835[_0x9cd5('0x54')]['id']){delete _0x4cb835[_0x9cd5('0x54')]['id'];}return db[_0x9cd5('0x48')][_0x9cd5('0x51')]({'where':{'id':_0x4cb835[_0x9cd5('0x4e')]['id']}})[_0x9cd5('0x2a')](handleEntityNotFound(_0xe8c694,null))[_0x9cd5('0x2a')](saveUpdates(_0x4cb835[_0x9cd5('0x54')],null))[_0x9cd5('0x2a')](respondWithResult(_0xe8c694,null))[_0x9cd5('0x52')](handleError(_0xe8c694,null));};exports[_0x9cd5('0x2b')]=function(_0x39b81b,_0x3a15af){return db['SmsQueue'][_0x9cd5('0x51')]({'where':{'id':_0x39b81b[_0x9cd5('0x4e')]['id']}})['then'](handleEntityNotFound(_0x3a15af,null))[_0x9cd5('0x2a')](removeEntity(_0x3a15af,null))[_0x9cd5('0x52')](handleError(_0x3a15af,null));};exports[_0x9cd5('0x5c')]=function(_0x1c1812,_0x1af451){return db[_0x9cd5('0x48')][_0x9cd5('0x5c')]()['then'](respondWithResult(_0x1af451,null))['catch'](handleError(_0x1af451,null));};exports[_0x9cd5('0x5d')]=function(_0x472456,_0xe987d2,_0x9d1492){var _0x17b678={'raw':!![],'where':{}},_0x464e60={},_0xcdd656;return db[_0x9cd5('0x48')][_0x9cd5('0x5e')]({'where':{'id':_0x472456[_0x9cd5('0x4e')]['id']}})[_0x9cd5('0x2a')](handleEntityNotFound(_0xe987d2,null))[_0x9cd5('0x2a')](function(_0x70eb05){if(_0x70eb05){_0xcdd656=_0x70eb05[_0x9cd5('0x2c')]({'plain':!![]});_0x464e60['model']=_['keys'](db[_0x9cd5('0x5f')][_0x9cd5('0x35')]);_0x464e60[_0x9cd5('0x38')]=_['keys'](_0x472456[_0x9cd5('0x38')]);_0x464e60['filters']=_[_0x9cd5('0x3a')](_0x464e60[_0x9cd5('0x37')],_0x464e60[_0x9cd5('0x38')]);_0x17b678['attributes']=_[_0x9cd5('0x3a')](_0x464e60[_0x9cd5('0x37')],qs[_0x9cd5('0x3c')](_0x472456[_0x9cd5('0x38')][_0x9cd5('0x3c')]));_0x17b678['attributes']=_0x17b678[_0x9cd5('0x3b')]['length']?_0x17b678[_0x9cd5('0x3b')]:_0x464e60['model'];if(!_0x472456[_0x9cd5('0x38')][_0x9cd5('0x3e')](_0x9cd5('0x3f'))){_0x17b678[_0x9cd5('0x24')]=qs['limit'](_0x472456[_0x9cd5('0x38')][_0x9cd5('0x24')]);_0x17b678[_0x9cd5('0x23')]=qs[_0x9cd5('0x23')](_0x472456['query'][_0x9cd5('0x23')]);}_0x17b678[_0x9cd5('0x40')]=qs['sort'](_0x472456[_0x9cd5('0x38')][_0x9cd5('0x41')]);_0x17b678[_0x9cd5('0x42')]=qs[_0x9cd5('0x39')](_[_0x9cd5('0x60')](_0x472456['query'],_0x464e60[_0x9cd5('0x39')]));_0x17b678[_0x9cd5('0x42')][_0x9cd5('0x61')]=_0x70eb05['id'];if(_0x472456[_0x9cd5('0x38')][_0x9cd5('0x43')]){_0x17b678[_0x9cd5('0x42')]=_[_0x9cd5('0x44')](_0x17b678[_0x9cd5('0x42')],{'$or':_[_0x9cd5('0x34')](_0x17b678['attributes'],function(_0x1b00d4){var _0x3b715e={};_0x3b715e[_0x1b00d4]={'$like':'%'+_0x472456['query']['filter']+'%'};return _0x3b715e;})});}_0x17b678=_[_0x9cd5('0x44')]({},_0x17b678,_0x472456[_0x9cd5('0x47')]);return db['UserSmsQueue']['findAll'](_0x17b678);}})[_0x9cd5('0x2a')](function(_0x478175){if(_0x478175){return db[_0x9cd5('0x62')][_0x9cd5('0x63')]({'where':{'id':_['map'](_0x478175,'UserId'),'role':_0x9cd5('0x64')},'attributes':['id',_0x9cd5('0x31'),_0x9cd5('0x65'),_0x9cd5('0x66'),_0x9cd5('0x67')]});}})[_0x9cd5('0x2a')](function(_0x3a6ce6){if(_0x3a6ce6){return{'count':_0x3a6ce6[_0x9cd5('0x49')],'rows':_[_0x9cd5('0x34')](_0x3a6ce6['rows'],function(_0x1e2089){return{'membername':_0x1e2089['name'],'UserId':_0x1e2089['id'],'queue_name':_0xcdd656[_0x9cd5('0x31')],'SmsQueueId':_0xcdd656['id'],'interface':util[_0x9cd5('0x68')](_0x9cd5('0x69'),_0x9cd5('0x6a'),_0x1e2089['name']),'penalty':0x0,'paused':_0x1e2089[_0x9cd5('0x65')],'createdAt':_0x1e2089['createdAt'],'updatedAt':_0x1e2089[_0x9cd5('0x66')]};})};}else{return{'count':0x0,'rows':[]};}})[_0x9cd5('0x2a')](respondWithFilteredResult(_0xe987d2,_0x17b678))[_0x9cd5('0x52')](handleError(_0xe987d2,null));};exports[_0x9cd5('0x6b')]=function(_0x5ece56,_0x3c7cc4,_0x31f8da){var _0x573e6c={};var _0x76403a={};var _0x59b3bd;var _0x3b2f0f;return db['SmsQueue']['findOne']({'where':{'id':_0x5ece56[_0x9cd5('0x4e')]['id']}})[_0x9cd5('0x2a')](handleEntityNotFound(_0x3c7cc4,null))[_0x9cd5('0x2a')](function(_0x1a9cf3){if(_0x1a9cf3){_0x59b3bd=_0x1a9cf3;_0x76403a[_0x9cd5('0x37')]=_[_0x9cd5('0x4f')](db['Team'][_0x9cd5('0x35')]);_0x76403a[_0x9cd5('0x38')]=_[_0x9cd5('0x4f')](_0x5ece56['query']);_0x76403a['filters']=_[_0x9cd5('0x3a')](_0x76403a[_0x9cd5('0x37')],_0x76403a[_0x9cd5('0x38')]);_0x573e6c[_0x9cd5('0x3b')]=_[_0x9cd5('0x3a')](_0x76403a[_0x9cd5('0x37')],qs[_0x9cd5('0x3c')](_0x5ece56[_0x9cd5('0x38')][_0x9cd5('0x3c')]));_0x573e6c[_0x9cd5('0x3b')]=_0x573e6c['attributes'][_0x9cd5('0x3d')]?_0x573e6c['attributes']:_0x76403a[_0x9cd5('0x37')];_0x573e6c[_0x9cd5('0x40')]=qs[_0x9cd5('0x41')](_0x5ece56['query'][_0x9cd5('0x41')]);_0x573e6c['where']=qs['filters'](_[_0x9cd5('0x60')](_0x5ece56[_0x9cd5('0x38')],_0x76403a[_0x9cd5('0x39')]));if(_0x5ece56[_0x9cd5('0x38')][_0x9cd5('0x43')]){_0x573e6c[_0x9cd5('0x42')]=_['merge'](_0x573e6c[_0x9cd5('0x42')],{'$or':_[_0x9cd5('0x34')](_0x573e6c[_0x9cd5('0x3b')],function(_0x4540ad){var _0x48bfca={};_0x48bfca[_0x4540ad]={'$like':'%'+_0x5ece56[_0x9cd5('0x38')][_0x9cd5('0x43')]+'%'};return _0x48bfca;})});}_0x573e6c=_[_0x9cd5('0x44')]({},_0x573e6c,_0x5ece56[_0x9cd5('0x47')]);return _0x59b3bd[_0x9cd5('0x6b')](_0x573e6c);}})['then'](function(_0x5c8b16){if(_0x5c8b16){_0x3b2f0f=_0x5c8b16[_0x9cd5('0x3d')];if(!_0x5ece56[_0x9cd5('0x38')][_0x9cd5('0x3e')]('nolimit')){_0x573e6c[_0x9cd5('0x24')]=qs[_0x9cd5('0x24')](_0x5ece56[_0x9cd5('0x38')][_0x9cd5('0x24')]);_0x573e6c[_0x9cd5('0x23')]=qs[_0x9cd5('0x23')](_0x5ece56['query'][_0x9cd5('0x23')]);}return _0x59b3bd['getTeams'](_0x573e6c);}})[_0x9cd5('0x2a')](function(_0x50fde3){if(_0x50fde3){return _0x50fde3?{'count':_0x3b2f0f,'rows':_0x50fde3}:null;}})[_0x9cd5('0x2a')](respondWithResult(_0x3c7cc4,null))[_0x9cd5('0x52')](handleError(_0x3c7cc4,null));};exports[_0x9cd5('0x6c')]=function(_0x4e7805,_0x2c16f3,_0x582e86){var _0x52b0ae=_0x4e7805[_0x9cd5('0x54')][_0x9cd5('0x6d')];return db[_0x9cd5('0x6e')]['findAll']({'where':{'id':_0x52b0ae},'attributes':['id'],'include':[{'model':db[_0x9cd5('0x62')],'as':_0x9cd5('0x6f'),'attributes':['id',_0x9cd5('0x31'),_0x9cd5('0x70'),_0x9cd5('0x71'),'interface'],'raw':!![]}]})[_0x9cd5('0x2a')](function(_0x24f895){if(_0x24f895){var _0x5f2ed6=_[_0x9cd5('0x72')](_0x24f895,function(_0x495240){var _0x382791=_0x495240[_0x9cd5('0x2c')]({'plain':!![]});return _0x382791[_0x9cd5('0x6f')];});return db['SmsQueue'][_0x9cd5('0x51')]({'where':{'id':_0x4e7805[_0x9cd5('0x4e')]['id']}})['then'](function(_0x4c87ab){return db[_0x9cd5('0x73')]['transaction'](function(_0x80796e){return _0x4c87ab['addTeams'](_0x52b0ae,{'transaction':_0x80796e})[_0x9cd5('0x2a')](function(){return BPromise[_0x9cd5('0x74')](_0x5f2ed6,function(_0x25c960){return db['UserSmsQueue'][_0x9cd5('0x75')]({'where':{'UserId':_0x25c960['id'],'SmsQueueId':_0x4e7805['params']['id']},'transaction':_0x80796e});});})[_0x9cd5('0x2a')](function(){_0x5f2ed6[_0x9cd5('0x76')](function(_0x42b383){socket[_0x9cd5('0x77')]('userSmsQueue:save',{'UserId':_0x42b383['id'],'SmsQueueId':_0x4c87ab['id']});});});});});}})['then'](respondWithStatusCode(_0x2c16f3,null))[_0x9cd5('0x52')](handleError(_0x2c16f3,null));};exports[_0x9cd5('0x78')]=function(_0x4232ec,_0x440023,_0x2e3de3){return db['Team']['findAll']({'where':{'id':_0x4232ec[_0x9cd5('0x38')]['ids']},'attributes':['id'],'include':[{'model':db['User'],'as':_0x9cd5('0x6f'),'attributes':['id'],'raw':!![]}]})['then'](handleEntityNotFound(_0x440023,null))[_0x9cd5('0x2a')](function(_0x592f36){var _0x40bffd=_[_0x9cd5('0x34')](_0x592f36,'id');var _0x3b7524=[];var _0x16fe69=[];var _0x369625=squel[_0x9cd5('0x79')]();_0x369625[_0x9cd5('0x7a')](_0x9cd5('0x7b'))[_0x9cd5('0x7c')](_0x9cd5('0x7d'),'tq')[_0x9cd5('0x7e')](_0x9cd5('0x7f'),'ut',_0x9cd5('0x80'))[_0x9cd5('0x42')](_0x9cd5('0x81'),_0x4232ec['params']['id']);for(var _0x301b01=0x0;_0x301b01<_0x592f36[_0x9cd5('0x3d')];_0x301b01+=0x1){let _0x5c450f=_0x592f36[_0x301b01];for(var _0x2c771b=0x0;_0x2c771b<_0x5c450f[_0x9cd5('0x6f')][_0x9cd5('0x3d')];_0x2c771b+=0x1){let _0x1466ef=_0x5c450f[_0x9cd5('0x6f')][_0x2c771b];var _0x1f737e=_0x369625[_0x9cd5('0x82')]();_0x1f737e['where'](_0x9cd5('0x83'),_0x1466ef['id']);_0x16fe69['push'](db['sequelize'][_0x9cd5('0x38')](_0x1f737e[_0x9cd5('0x84')](),{'type':db[_0x9cd5('0x73')][_0x9cd5('0x85')][_0x9cd5('0x86')]})[_0x9cd5('0x2a')](function(_0x4fb541){if(_0x4fb541[_0x9cd5('0x3d')]===0x1){return _0x1466ef['id'];}else{var _0xdb65a2=_[_0x9cd5('0x87')](_[_0x9cd5('0x34')](_0x4fb541,_0x9cd5('0x88')),function(_0x108d73){return _[_0x9cd5('0x89')](_0x40bffd,_0x108d73);});if(_0xdb65a2){return _0x1466ef['id'];}}}));}}return BPromise[_0x9cd5('0x8a')](_0x16fe69)['then'](function(_0x440dfb){_0x3b7524=_(_0x3b7524)[_0x9cd5('0x8b')](_0x440dfb)[_0x9cd5('0x8c')]()[_0x9cd5('0x8d')]();return db[_0x9cd5('0x48')][_0x9cd5('0x51')]({'where':{'id':_0x4232ec['params']['id']}})[_0x9cd5('0x2a')](function(_0x59a9a1){return db['sequelize'][_0x9cd5('0x8e')](function(_0x188cc1){return _0x59a9a1['removeTeams'](_0x4232ec[_0x9cd5('0x38')][_0x9cd5('0x6d')],{'transaction':_0x188cc1})[_0x9cd5('0x2a')](function(){if(!_[_0x9cd5('0x8f')](_0x3b7524)){return _0x59a9a1[_0x9cd5('0x90')](_0x3b7524,{'transaction':_0x188cc1});}})[_0x9cd5('0x2a')](function(){_0x3b7524[_0x9cd5('0x76')](function(_0x3ba3ad){socket[_0x9cd5('0x77')](_0x9cd5('0x91'),{'UserId':_0x3ba3ad,'SmsQueueId':_0x59a9a1['id']});});});});});});})[_0x9cd5('0x2a')](respondWithStatusCode(_0x440023,null))[_0x9cd5('0x52')](handleError(_0x440023,null));};exports['addAgents']=function(_0x53aa4a,_0x111c4e,_0x40695e){return db['SmsQueue'][_0x9cd5('0x51')]({'where':{'id':_0x53aa4a['params']['id']}})[_0x9cd5('0x2a')](handleEntityNotFound(_0x111c4e,null))[_0x9cd5('0x2a')](function(_0x5a7993){if(_0x5a7993){return _0x5a7993['addAgents'](_0x53aa4a[_0x9cd5('0x54')][_0x9cd5('0x6d')],_[_0x9cd5('0x92')](_0x53aa4a[_0x9cd5('0x54')],['ids','id'])||{})[_0x9cd5('0x93')](function(_0x4ac4d9){for(var _0x263875=0x0;_0x263875<_0x53aa4a[_0x9cd5('0x54')][_0x9cd5('0x6d')]['length'];_0x263875+=0x1){socket['emit'](_0x9cd5('0x94'),{'UserId':_0x53aa4a[_0x9cd5('0x54')][_0x9cd5('0x6d')][_0x263875],'SmsQueueId':_0x53aa4a['params']['id']});}return _0x4ac4d9;});}})[_0x9cd5('0x2a')](respondWithResult(_0x111c4e,null))[_0x9cd5('0x52')](handleError(_0x111c4e,null));};exports[_0x9cd5('0x90')]=function(_0xaf568b,_0x2d651d,_0x2e335a){return db['SmsQueue'][_0x9cd5('0x51')]({'where':{'id':_0xaf568b['params']['id']}})[_0x9cd5('0x2a')](handleEntityNotFound(_0x2d651d,null))[_0x9cd5('0x2a')](function(_0x468ec4){if(_0x468ec4){return _0x468ec4['removeAgents'](_0xaf568b['query'][_0x9cd5('0x6d')])[_0x9cd5('0x2a')](function(){if(_['isArray'](_0xaf568b[_0x9cd5('0x38')][_0x9cd5('0x6d')])){for(var _0x584bcd=0x0;_0x584bcd<_0xaf568b[_0x9cd5('0x38')][_0x9cd5('0x6d')][_0x9cd5('0x3d')];_0x584bcd+=0x1){socket[_0x9cd5('0x77')]('userSmsQueue:remove',{'UserId':Number(_0xaf568b[_0x9cd5('0x38')]['ids'][_0x584bcd]),'SmsQueueId':Number(_0xaf568b['params']['id'])});}}else{socket[_0x9cd5('0x77')]('userSmsQueue:remove',{'UserId':Number(_0xaf568b[_0x9cd5('0x38')][_0x9cd5('0x6d')]),'SmsQueueId':Number(_0xaf568b['params']['id'])});}});}})[_0x9cd5('0x2a')](respondWithStatusCode(_0x2d651d,null))['catch'](handleError(_0x2d651d,null));};exports[_0x9cd5('0x95')]=function(_0x463607,_0x3bb4f0,_0x491aa6){var _0x11e7e9={};var _0x1134d1={};var _0x4ba8e9;var _0x196cc7;return db[_0x9cd5('0x48')][_0x9cd5('0x5e')]({'where':{'id':_0x463607['params']['id']}})['then'](handleEntityNotFound(_0x3bb4f0,null))[_0x9cd5('0x2a')](function(_0x52ac48){if(_0x52ac48){_0x4ba8e9=_0x52ac48;_0x1134d1['model']=_[_0x9cd5('0x4f')](db['User'][_0x9cd5('0x35')]);_0x1134d1[_0x9cd5('0x38')]=_['keys'](_0x463607['query']);_0x1134d1['filters']=_[_0x9cd5('0x3a')](_0x1134d1[_0x9cd5('0x37')],_0x1134d1['query']);_0x11e7e9[_0x9cd5('0x3b')]=_[_0x9cd5('0x3a')](_0x1134d1[_0x9cd5('0x37')],qs[_0x9cd5('0x3c')](_0x463607[_0x9cd5('0x38')][_0x9cd5('0x3c')]));_0x11e7e9['attributes']=_0x11e7e9['attributes'][_0x9cd5('0x3d')]?_0x11e7e9[_0x9cd5('0x3b')]:_0x1134d1['model'];_0x11e7e9[_0x9cd5('0x40')]=qs[_0x9cd5('0x41')](_0x463607['query'][_0x9cd5('0x41')]);_0x11e7e9['where']=qs[_0x9cd5('0x39')](_['pick'](_0x463607['query'],_0x1134d1[_0x9cd5('0x39')]));if(_0x463607['query']['filter']){_0x11e7e9['where']=_['merge'](_0x11e7e9[_0x9cd5('0x42')],{'$or':_['map'](_0x11e7e9[_0x9cd5('0x3b')],function(_0x3d32f0){var _0x19347f={};_0x19347f[_0x3d32f0]={'$like':'%'+_0x463607[_0x9cd5('0x38')]['filter']+'%'};return _0x19347f;})});}_0x11e7e9=_[_0x9cd5('0x44')]({},_0x11e7e9,_0x463607['options']);return _0x4ba8e9[_0x9cd5('0x95')](_0x11e7e9);}})[_0x9cd5('0x2a')](function(_0x25756b){if(_0x25756b){_0x196cc7=_0x25756b[_0x9cd5('0x3d')];if(!_0x463607['query'][_0x9cd5('0x3e')](_0x9cd5('0x3f'))){_0x11e7e9[_0x9cd5('0x24')]=qs[_0x9cd5('0x24')](_0x463607[_0x9cd5('0x38')][_0x9cd5('0x24')]);_0x11e7e9[_0x9cd5('0x23')]=qs['offset'](_0x463607['query'][_0x9cd5('0x23')]);}return _0x4ba8e9['getAgents'](_0x11e7e9);}})[_0x9cd5('0x2a')](function(_0xcbbb18){if(_0xcbbb18){return _0xcbbb18?{'count':_0x196cc7,'rows':_0xcbbb18}:null;}})['then'](respondWithResult(_0x3bb4f0,null))['catch'](handleError(_0x3bb4f0,null));};
\ No newline at end of file
+var _0x5f66=['show','params','model','keys','intersection','attributes','fields','includeAll','merge','options','create','body','user','get','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','SmsQueues','find','userProfileId','error','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','describe','rawAttributes','filters','hasOwnProperty','order','sort','pick','map','UserSmsQueue','User','findAndCountAll','UserId','agent','smsPause','updatedAt','createdAt','%s/%s','SIP','getTeams','length','filter','nolimit','ids','Team','Agents','interface','flatMap','sequelize','transaction','addTeams','forEach','emit','userSmsQueue:save','removeTeams','select','tq.TeamId','team_has_sms_queues','user_has_teams','ut.TeamId\x20=\x20tq.TeamId','clone','ut.UserId\x20=\x20?','toString','QueryTypes','SELECT','includes','all','compact','value','isEmpty','removeAgents','userSmsQueue:remove','addAgents','spread','isArray','findOne','getAgents','util','squel','ioredis','../../components/parsers/qs','../../config/logger','api','../../mysqldb','defaults','redis','./smsQueue.socket','register','end','json','offset','limit','undefined','count','status','update','then','UserProfileResource','destroy','sendStatus','stack','name','send','index','fieldName','key','getOptions','where','SmsQueue','include','query','findAll','catch'];(function(_0x4d62ae,_0x1509f5){var _0x54d4b7=function(_0x492d51){while(--_0x492d51){_0x4d62ae['push'](_0x4d62ae['shift']());}};_0x54d4b7(++_0x1509f5);}(_0x5f66,0x1a0));var _0x65f6=function(_0x3947c9,_0x4d6c97){_0x3947c9=_0x3947c9-0x0;var _0x2e7871=_0x5f66[_0x3947c9];return _0x2e7871;};'use strict';var BPromise=require('bluebird');var util=require(_0x65f6('0x0'));var _=require('lodash');var squel=require(_0x65f6('0x1'));var Redis=require(_0x65f6('0x2'));var qs=require(_0x65f6('0x3'));var logger=require(_0x65f6('0x4'))(_0x65f6('0x5'));var config=require('../../config/environment');var db=require(_0x65f6('0x6'))['db'];config['redis']=_[_0x65f6('0x7')](config[_0x65f6('0x8')],{'host':'localhost','port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x65f6('0x8')]));require(_0x65f6('0x9'))[_0x65f6('0xa')](socket);function respondWithStatusCode(_0x8f6451,_0xc44c70){_0xc44c70=_0xc44c70||0xcc;return function(_0x14f4c7){if(_0x14f4c7){return _0x8f6451['sendStatus'](_0xc44c70);}return _0x8f6451['status'](_0xc44c70)[_0x65f6('0xb')]();};}function respondWithResult(_0x2f6d5b,_0x264647){_0x264647=_0x264647||0xc8;return function(_0x25c416){if(_0x25c416){return _0x2f6d5b['status'](_0x264647)[_0x65f6('0xc')](_0x25c416);}};}function respondWithFilteredResult(_0x571436,_0x497cf3){return function(_0x2d2dfa){if(_0x2d2dfa){var _0x576875=typeof _0x497cf3[_0x65f6('0xd')]==='undefined'&&typeof _0x497cf3[_0x65f6('0xe')]===_0x65f6('0xf');var _0x2c4ee5=_0x2d2dfa[_0x65f6('0x10')];var _0x369f96=_0x576875?0x0:_0x497cf3[_0x65f6('0xd')];var _0x44144b=_0x576875?_0x2d2dfa[_0x65f6('0x10')]:_0x497cf3[_0x65f6('0xd')]+_0x497cf3[_0x65f6('0xe')];var _0x59154e;if(_0x44144b>=_0x2c4ee5){_0x44144b=_0x2c4ee5;_0x59154e=0xc8;}else{_0x59154e=0xce;}_0x571436[_0x65f6('0x11')](_0x59154e);return _0x571436['set']('Content-Range',_0x369f96+'-'+_0x44144b+'/'+_0x2c4ee5)[_0x65f6('0xc')](_0x2d2dfa);}return null;};}function saveUpdates(_0x5c69f8){return function(_0x37330d){if(_0x37330d){return _0x37330d[_0x65f6('0x12')](_0x5c69f8)[_0x65f6('0x13')](function(_0x1f974c){return _0x1f974c;});}return null;};}function removeEntity(_0xc8660c){return function(_0x18380e){if(_0x18380e){return _0x18380e['destroy']()['then'](function(){var _0x2d538c=_0x18380e['get']({'plain':!![]});var _0x4c81f3='SmsQueues';return db[_0x65f6('0x14')][_0x65f6('0x15')]({'where':{'type':_0x4c81f3,'resourceId':_0x2d538c['id']}})['then'](function(){return _0x18380e;});})[_0x65f6('0x13')](function(){_0xc8660c[_0x65f6('0x11')](0xcc)[_0x65f6('0xb')]();});}};}function handleEntityNotFound(_0x3876ed){return function(_0x219ab2){if(!_0x219ab2){_0x3876ed[_0x65f6('0x16')](0x194);}return _0x219ab2;};}function handleError(_0x581374,_0x197a49){_0x197a49=_0x197a49||0x1f4;return function(_0x4bb39e){logger['error'](_0x4bb39e[_0x65f6('0x17')]);if(_0x4bb39e[_0x65f6('0x18')]){delete _0x4bb39e['name'];}_0x581374[_0x65f6('0x11')](_0x197a49)[_0x65f6('0x19')](_0x4bb39e);};}exports[_0x65f6('0x1a')]=function(_0x2774a1,_0x4f5a69){var _0x9d7bb0={};var _0x59ea32={'count':0x0,'rows':[]};var _0x20a161=_['map'](db['SmsQueue']['rawAttributes'],function(_0x29abdb){return{'name':_0x29abdb[_0x65f6('0x1b')],'type':_0x29abdb['type'][_0x65f6('0x1c')]};});_0x9d7bb0=qs[_0x65f6('0x1d')](_0x20a161,_0x2774a1);var _0x52277c={'where':_0x9d7bb0[_0x65f6('0x1e')]};return db[_0x65f6('0x1f')][_0x65f6('0x10')](_0x52277c)['then'](function(_0x4ac04b){_0x59ea32['count']=_0x4ac04b;_0x9d7bb0[_0x65f6('0x20')]=qs[_0x65f6('0x20')](_0x2774a1[_0x65f6('0x21')]);return db[_0x65f6('0x1f')][_0x65f6('0x22')](_0x9d7bb0);})[_0x65f6('0x13')](function(_0x144e55){_0x59ea32['rows']=_0x144e55;return _0x59ea32;})['then'](respondWithFilteredResult(_0x4f5a69,_0x9d7bb0))[_0x65f6('0x23')](handleError(_0x4f5a69,null));};exports[_0x65f6('0x24')]=function(_0x5878bc,_0x4e50c0){var _0x10b368={'raw':!![],'where':{'id':_0x5878bc[_0x65f6('0x25')]['id']}},_0x1ce43c={};_0x1ce43c[_0x65f6('0x26')]=_[_0x65f6('0x27')](db[_0x65f6('0x1f')]['rawAttributes']);_0x1ce43c[_0x65f6('0x21')]=_[_0x65f6('0x27')](_0x5878bc[_0x65f6('0x21')]);_0x1ce43c['filters']=_[_0x65f6('0x28')](_0x1ce43c[_0x65f6('0x26')],_0x1ce43c[_0x65f6('0x21')]);_0x10b368[_0x65f6('0x29')]=_[_0x65f6('0x28')](_0x1ce43c[_0x65f6('0x26')],qs['fields'](_0x5878bc[_0x65f6('0x21')][_0x65f6('0x2a')]));_0x10b368['attributes']=_0x10b368[_0x65f6('0x29')]['length']?_0x10b368[_0x65f6('0x29')]:_0x1ce43c['model'];if(_0x5878bc[_0x65f6('0x21')][_0x65f6('0x2b')]){_0x10b368['include']=[{'all':!![]}];}_0x10b368=_[_0x65f6('0x2c')]({},_0x10b368,_0x5878bc[_0x65f6('0x2d')]);return db[_0x65f6('0x1f')]['find'](_0x10b368)['then'](handleEntityNotFound(_0x4e50c0,null))[_0x65f6('0x13')](respondWithResult(_0x4e50c0,null))['catch'](handleError(_0x4e50c0,null));};exports[_0x65f6('0x2e')]=function(_0x4e6653,_0x22d760){return db[_0x65f6('0x1f')]['create'](_0x4e6653[_0x65f6('0x2f')],{})['then'](function(_0x5edd04){var _0x71b16b=_0x4e6653[_0x65f6('0x30')][_0x65f6('0x31')]({'plain':!![]});if(!_0x71b16b)throw new Error(_0x65f6('0x32'));if(_0x71b16b[_0x65f6('0x33')]===_0x65f6('0x30')){var _0x1a55da=_0x5edd04[_0x65f6('0x31')]({'plain':!![]});var _0x4f933b=_0x65f6('0x34');return db['UserProfileSection'][_0x65f6('0x35')]({'where':{'name':_0x4f933b,'userProfileId':_0x71b16b[_0x65f6('0x36')]},'raw':!![]})[_0x65f6('0x13')](function(_0x2ea7f7){if(_0x2ea7f7&&_0x2ea7f7['autoAssociation']===0x0){return db[_0x65f6('0x14')][_0x65f6('0x2e')]({'name':_0x1a55da[_0x65f6('0x18')],'resourceId':_0x1a55da['id'],'type':_0x2ea7f7[_0x65f6('0x18')],'sectionId':_0x2ea7f7['id']},{})[_0x65f6('0x13')](function(){return _0x5edd04;});}else{return _0x5edd04;}})[_0x65f6('0x23')](function(_0xed4c96){logger[_0x65f6('0x37')](_0x65f6('0x38'),_0xed4c96);throw _0xed4c96;});}return _0x5edd04;})['then'](respondWithResult(_0x22d760,0xc9))[_0x65f6('0x23')](handleError(_0x22d760,null));};exports[_0x65f6('0x12')]=function(_0x377ae5,_0x181798){if(_0x377ae5[_0x65f6('0x2f')]['id']){delete _0x377ae5[_0x65f6('0x2f')]['id'];}return db[_0x65f6('0x1f')][_0x65f6('0x35')]({'where':{'id':_0x377ae5[_0x65f6('0x25')]['id']}})[_0x65f6('0x13')](handleEntityNotFound(_0x181798,null))[_0x65f6('0x13')](saveUpdates(_0x377ae5[_0x65f6('0x2f')],null))[_0x65f6('0x13')](respondWithResult(_0x181798,null))[_0x65f6('0x23')](handleError(_0x181798,null));};exports[_0x65f6('0x15')]=function(_0x2cb38d,_0x5119ee){return db[_0x65f6('0x1f')][_0x65f6('0x35')]({'where':{'id':_0x2cb38d[_0x65f6('0x25')]['id']}})[_0x65f6('0x13')](handleEntityNotFound(_0x5119ee,null))['then'](removeEntity(_0x5119ee,null))[_0x65f6('0x23')](handleError(_0x5119ee,null));};exports[_0x65f6('0x39')]=function(_0x2b01eb,_0x5e69b4){return db[_0x65f6('0x1f')][_0x65f6('0x39')]()[_0x65f6('0x13')](respondWithResult(_0x5e69b4,null))[_0x65f6('0x23')](handleError(_0x5e69b4,null));};exports['getMembers']=function(_0x2ec114,_0x512527){var _0x3f1baa={'raw':!![],'where':{}},_0x6968b={},_0x577c93;return db[_0x65f6('0x1f')]['findOne']({'where':{'id':_0x2ec114[_0x65f6('0x25')]['id']}})[_0x65f6('0x13')](handleEntityNotFound(_0x512527,null))[_0x65f6('0x13')](function(_0xc0db01){if(_0xc0db01){_0x577c93=_0xc0db01[_0x65f6('0x31')]({'plain':!![]});_0x6968b[_0x65f6('0x26')]=_['keys'](db['UserSmsQueue'][_0x65f6('0x3a')]);_0x6968b[_0x65f6('0x21')]=_[_0x65f6('0x27')](_0x2ec114[_0x65f6('0x21')]);_0x6968b[_0x65f6('0x3b')]=_[_0x65f6('0x28')](_0x6968b[_0x65f6('0x26')],_0x6968b[_0x65f6('0x21')]);_0x3f1baa[_0x65f6('0x29')]=_['intersection'](_0x6968b[_0x65f6('0x26')],qs[_0x65f6('0x2a')](_0x2ec114[_0x65f6('0x21')]['fields']));_0x3f1baa[_0x65f6('0x29')]=_0x3f1baa[_0x65f6('0x29')]['length']?_0x3f1baa[_0x65f6('0x29')]:_0x6968b[_0x65f6('0x26')];if(!_0x2ec114['query'][_0x65f6('0x3c')]('nolimit')){_0x3f1baa[_0x65f6('0xe')]=qs[_0x65f6('0xe')](_0x2ec114[_0x65f6('0x21')]['limit']);_0x3f1baa[_0x65f6('0xd')]=qs[_0x65f6('0xd')](_0x2ec114['query'][_0x65f6('0xd')]);}_0x3f1baa[_0x65f6('0x3d')]=qs['sort'](_0x2ec114[_0x65f6('0x21')][_0x65f6('0x3e')]);_0x3f1baa[_0x65f6('0x1e')]=qs[_0x65f6('0x3b')](_[_0x65f6('0x3f')](_0x2ec114[_0x65f6('0x21')],_0x6968b[_0x65f6('0x3b')]));_0x3f1baa[_0x65f6('0x1e')]['SmsQueueId']=_0xc0db01['id'];if(_0x2ec114['query']['filter']){_0x3f1baa[_0x65f6('0x1e')]=_[_0x65f6('0x2c')](_0x3f1baa[_0x65f6('0x1e')],{'$or':_[_0x65f6('0x40')](_0x3f1baa['attributes'],function(_0x183c08){var _0x2032b9={};_0x2032b9[_0x183c08]={'$like':'%'+_0x2ec114[_0x65f6('0x21')]['filter']+'%'};return _0x2032b9;})});}_0x3f1baa=_[_0x65f6('0x2c')]({},_0x3f1baa,_0x2ec114[_0x65f6('0x2d')]);return db[_0x65f6('0x41')]['findAll'](_0x3f1baa);}})['then'](function(_0x1d337d){if(_0x1d337d){return db[_0x65f6('0x42')][_0x65f6('0x43')]({'where':{'id':_[_0x65f6('0x40')](_0x1d337d,_0x65f6('0x44')),'role':_0x65f6('0x45')},'attributes':['id',_0x65f6('0x18'),_0x65f6('0x46'),_0x65f6('0x47'),_0x65f6('0x48')]});}})[_0x65f6('0x13')](function(_0x141fcc){if(_0x141fcc){return{'count':_0x141fcc[_0x65f6('0x10')],'rows':_[_0x65f6('0x40')](_0x141fcc['rows'],function(_0x47610a){return{'membername':_0x47610a[_0x65f6('0x18')],'UserId':_0x47610a['id'],'queue_name':_0x577c93[_0x65f6('0x18')],'SmsQueueId':_0x577c93['id'],'interface':util['format'](_0x65f6('0x49'),_0x65f6('0x4a'),_0x47610a[_0x65f6('0x18')]),'penalty':0x0,'paused':_0x47610a[_0x65f6('0x46')],'createdAt':_0x47610a['createdAt'],'updatedAt':_0x47610a[_0x65f6('0x47')]};})};}else{return{'count':0x0,'rows':[]};}})[_0x65f6('0x13')](respondWithFilteredResult(_0x512527,_0x3f1baa))[_0x65f6('0x23')](handleError(_0x512527,null));};exports[_0x65f6('0x4b')]=function(_0x553ff0,_0x2923ff){var _0x2fc20f={};var _0x5c55e4={};var _0x28682b;var _0x26481e;return db[_0x65f6('0x1f')]['findOne']({'where':{'id':_0x553ff0[_0x65f6('0x25')]['id']}})[_0x65f6('0x13')](handleEntityNotFound(_0x2923ff,null))[_0x65f6('0x13')](function(_0x3c23e3){if(_0x3c23e3){_0x28682b=_0x3c23e3;_0x5c55e4[_0x65f6('0x26')]=_[_0x65f6('0x27')](db['Team']['rawAttributes']);_0x5c55e4['query']=_[_0x65f6('0x27')](_0x553ff0[_0x65f6('0x21')]);_0x5c55e4[_0x65f6('0x3b')]=_[_0x65f6('0x28')](_0x5c55e4[_0x65f6('0x26')],_0x5c55e4[_0x65f6('0x21')]);_0x2fc20f['attributes']=_[_0x65f6('0x28')](_0x5c55e4[_0x65f6('0x26')],qs['fields'](_0x553ff0[_0x65f6('0x21')][_0x65f6('0x2a')]));_0x2fc20f[_0x65f6('0x29')]=_0x2fc20f['attributes'][_0x65f6('0x4c')]?_0x2fc20f[_0x65f6('0x29')]:_0x5c55e4['model'];_0x2fc20f[_0x65f6('0x3d')]=qs[_0x65f6('0x3e')](_0x553ff0[_0x65f6('0x21')][_0x65f6('0x3e')]);_0x2fc20f[_0x65f6('0x1e')]=qs[_0x65f6('0x3b')](_[_0x65f6('0x3f')](_0x553ff0['query'],_0x5c55e4['filters']));if(_0x553ff0[_0x65f6('0x21')][_0x65f6('0x4d')]){_0x2fc20f['where']=_[_0x65f6('0x2c')](_0x2fc20f['where'],{'$or':_[_0x65f6('0x40')](_0x2fc20f['attributes'],function(_0x440df1){var _0xdc8989={};_0xdc8989[_0x440df1]={'$like':'%'+_0x553ff0[_0x65f6('0x21')][_0x65f6('0x4d')]+'%'};return _0xdc8989;})});}_0x2fc20f=_[_0x65f6('0x2c')]({},_0x2fc20f,_0x553ff0[_0x65f6('0x2d')]);return _0x28682b[_0x65f6('0x4b')](_0x2fc20f);}})[_0x65f6('0x13')](function(_0x2405a7){if(_0x2405a7){_0x26481e=_0x2405a7['length'];if(!_0x553ff0['query'][_0x65f6('0x3c')](_0x65f6('0x4e'))){_0x2fc20f[_0x65f6('0xe')]=qs['limit'](_0x553ff0['query'][_0x65f6('0xe')]);_0x2fc20f[_0x65f6('0xd')]=qs[_0x65f6('0xd')](_0x553ff0[_0x65f6('0x21')][_0x65f6('0xd')]);}return _0x28682b[_0x65f6('0x4b')](_0x2fc20f);}})['then'](function(_0x4f42ae){if(_0x4f42ae){return _0x4f42ae?{'count':_0x26481e,'rows':_0x4f42ae}:null;}})[_0x65f6('0x13')](respondWithResult(_0x2923ff,null))[_0x65f6('0x23')](handleError(_0x2923ff,null));};exports['addTeams']=function(_0x219bf8,_0x4a8b60){var _0x254e9f=_0x219bf8[_0x65f6('0x2f')][_0x65f6('0x4f')];return db[_0x65f6('0x50')]['findAll']({'where':{'id':_0x254e9f},'attributes':['id'],'include':[{'model':db[_0x65f6('0x42')],'as':_0x65f6('0x51'),'attributes':['id',_0x65f6('0x18'),'online','voicePause',_0x65f6('0x52')],'raw':!![]}]})['then'](function(_0x305967){if(_0x305967){var _0xf6de=_[_0x65f6('0x53')](_0x305967,function(_0x354b90){var _0x512776=_0x354b90['get']({'plain':!![]});return _0x512776['Agents'];});return db[_0x65f6('0x1f')][_0x65f6('0x35')]({'where':{'id':_0x219bf8[_0x65f6('0x25')]['id']}})['then'](function(_0x46cbde){return db[_0x65f6('0x54')][_0x65f6('0x55')](function(_0x49cee2){return _0x46cbde[_0x65f6('0x56')](_0x254e9f,{'transaction':_0x49cee2})[_0x65f6('0x13')](function(){return BPromise['each'](_0xf6de,function(_0x758e80){return db[_0x65f6('0x41')]['findOrCreate']({'where':{'UserId':_0x758e80['id'],'SmsQueueId':_0x219bf8[_0x65f6('0x25')]['id']},'transaction':_0x49cee2});});})['then'](function(){_0xf6de[_0x65f6('0x57')](function(_0x55ea91){socket[_0x65f6('0x58')](_0x65f6('0x59'),{'UserId':_0x55ea91['id'],'SmsQueueId':_0x46cbde['id']});});});});});}})['then'](respondWithStatusCode(_0x4a8b60,null))[_0x65f6('0x23')](handleError(_0x4a8b60,null));};exports[_0x65f6('0x5a')]=function(_0x2a700b,_0x299b85){return db[_0x65f6('0x50')][_0x65f6('0x22')]({'where':{'id':_0x2a700b[_0x65f6('0x21')][_0x65f6('0x4f')]},'attributes':['id'],'include':[{'model':db[_0x65f6('0x42')],'as':_0x65f6('0x51'),'attributes':['id'],'raw':!![]}]})[_0x65f6('0x13')](handleEntityNotFound(_0x299b85,null))['then'](function(_0x10a661){var _0x1cf1bd=_[_0x65f6('0x40')](_0x10a661,'id');var _0x219e42=[];var _0x5694f9=[];var _0x453080=squel[_0x65f6('0x5b')]();_0x453080['field'](_0x65f6('0x5c'))['from'](_0x65f6('0x5d'),'tq')['join'](_0x65f6('0x5e'),'ut',_0x65f6('0x5f'))['where']('SmsQueueId\x20=\x20?',_0x2a700b[_0x65f6('0x25')]['id']);for(var _0x413c21=0x0;_0x413c21<_0x10a661['length'];_0x413c21+=0x1){let _0x2d86c8=_0x10a661[_0x413c21];for(var _0x3b3bd5=0x0;_0x3b3bd5<_0x2d86c8[_0x65f6('0x51')]['length'];_0x3b3bd5+=0x1){let _0x1348ec=_0x2d86c8[_0x65f6('0x51')][_0x3b3bd5];var _0x5889dc=_0x453080[_0x65f6('0x60')]();_0x5889dc['where'](_0x65f6('0x61'),_0x1348ec['id']);_0x5694f9['push'](db['sequelize'][_0x65f6('0x21')](_0x5889dc[_0x65f6('0x62')](),{'type':db[_0x65f6('0x54')][_0x65f6('0x63')][_0x65f6('0x64')]})[_0x65f6('0x13')](function(_0x1ac46f){if(_0x1ac46f[_0x65f6('0x4c')]===0x1){return _0x1348ec['id'];}else{var _0x4d66fe=_['every'](_[_0x65f6('0x40')](_0x1ac46f,'TeamId'),function(_0x1ee28a){return _[_0x65f6('0x65')](_0x1cf1bd,_0x1ee28a);});if(_0x4d66fe){return _0x1348ec['id'];}}}));}}return BPromise[_0x65f6('0x66')](_0x5694f9)[_0x65f6('0x13')](function(_0x43127b){_0x219e42=_(_0x219e42)['union'](_0x43127b)[_0x65f6('0x67')]()[_0x65f6('0x68')]();return db[_0x65f6('0x1f')]['find']({'where':{'id':_0x2a700b[_0x65f6('0x25')]['id']}})[_0x65f6('0x13')](function(_0x4254c2){return db[_0x65f6('0x54')][_0x65f6('0x55')](function(_0x16bf93){return _0x4254c2['removeTeams'](_0x2a700b['query'][_0x65f6('0x4f')],{'transaction':_0x16bf93})[_0x65f6('0x13')](function(){if(!_[_0x65f6('0x69')](_0x219e42)){return _0x4254c2[_0x65f6('0x6a')](_0x219e42,{'transaction':_0x16bf93});}})['then'](function(){_0x219e42['forEach'](function(_0x336076){socket[_0x65f6('0x58')](_0x65f6('0x6b'),{'UserId':_0x336076,'SmsQueueId':_0x4254c2['id']});});});});});});})[_0x65f6('0x13')](respondWithStatusCode(_0x299b85,null))[_0x65f6('0x23')](handleError(_0x299b85,null));};exports[_0x65f6('0x6c')]=function(_0x5daaf4,_0x4d607a){return db['SmsQueue'][_0x65f6('0x35')]({'where':{'id':_0x5daaf4[_0x65f6('0x25')]['id']}})[_0x65f6('0x13')](handleEntityNotFound(_0x4d607a,null))[_0x65f6('0x13')](function(_0x53b11c){if(_0x53b11c){return _0x53b11c['addAgents'](_0x5daaf4[_0x65f6('0x2f')][_0x65f6('0x4f')],_['omit'](_0x5daaf4[_0x65f6('0x2f')],['ids','id'])||{})[_0x65f6('0x6d')](function(_0x4f3ef8){for(var _0x3a30ed=0x0;_0x3a30ed<_0x5daaf4[_0x65f6('0x2f')]['ids'][_0x65f6('0x4c')];_0x3a30ed+=0x1){socket[_0x65f6('0x58')](_0x65f6('0x59'),{'UserId':Number(_0x5daaf4[_0x65f6('0x2f')][_0x65f6('0x4f')][_0x3a30ed]),'SmsQueueId':Number(_0x5daaf4[_0x65f6('0x25')]['id'])});}return _0x4f3ef8;});}})['then'](respondWithResult(_0x4d607a,null))[_0x65f6('0x23')](handleError(_0x4d607a,null));};exports['removeAgents']=function(_0x24495c,_0x56336a){return db[_0x65f6('0x1f')][_0x65f6('0x35')]({'where':{'id':_0x24495c[_0x65f6('0x25')]['id']}})[_0x65f6('0x13')](handleEntityNotFound(_0x56336a,null))['then'](function(_0x2b6f98){if(_0x2b6f98){return _0x2b6f98[_0x65f6('0x6a')](_0x24495c[_0x65f6('0x21')]['ids'])['then'](function(){if(_[_0x65f6('0x6e')](_0x24495c[_0x65f6('0x21')]['ids'])){for(var _0x180cde=0x0;_0x180cde<_0x24495c[_0x65f6('0x21')][_0x65f6('0x4f')]['length'];_0x180cde+=0x1){socket[_0x65f6('0x58')](_0x65f6('0x6b'),{'UserId':Number(_0x24495c['query'][_0x65f6('0x4f')][_0x180cde]),'SmsQueueId':Number(_0x24495c[_0x65f6('0x25')]['id'])});}}else{socket[_0x65f6('0x58')]('userSmsQueue:remove',{'UserId':Number(_0x24495c[_0x65f6('0x21')][_0x65f6('0x4f')]),'SmsQueueId':Number(_0x24495c[_0x65f6('0x25')]['id'])});}});}})['then'](respondWithStatusCode(_0x56336a,null))[_0x65f6('0x23')](handleError(_0x56336a,null));};exports['getAgents']=function(_0x1beaa7,_0x87a9e4){var _0x31ec61={};var _0x22be6e={};var _0x29b2de;var _0x430fb8;return db['SmsQueue'][_0x65f6('0x6f')]({'where':{'id':_0x1beaa7[_0x65f6('0x25')]['id']}})[_0x65f6('0x13')](handleEntityNotFound(_0x87a9e4,null))[_0x65f6('0x13')](function(_0x207d15){if(_0x207d15){_0x29b2de=_0x207d15;_0x22be6e['model']=_['keys'](db['User'][_0x65f6('0x3a')]);_0x22be6e[_0x65f6('0x21')]=_[_0x65f6('0x27')](_0x1beaa7['query']);_0x22be6e[_0x65f6('0x3b')]=_['intersection'](_0x22be6e['model'],_0x22be6e[_0x65f6('0x21')]);_0x31ec61[_0x65f6('0x29')]=_['intersection'](_0x22be6e[_0x65f6('0x26')],qs[_0x65f6('0x2a')](_0x1beaa7[_0x65f6('0x21')][_0x65f6('0x2a')]));_0x31ec61[_0x65f6('0x29')]=_0x31ec61[_0x65f6('0x29')][_0x65f6('0x4c')]?_0x31ec61[_0x65f6('0x29')]:_0x22be6e[_0x65f6('0x26')];_0x31ec61[_0x65f6('0x3d')]=qs[_0x65f6('0x3e')](_0x1beaa7[_0x65f6('0x21')]['sort']);_0x31ec61[_0x65f6('0x1e')]=qs['filters'](_['pick'](_0x1beaa7[_0x65f6('0x21')],_0x22be6e[_0x65f6('0x3b')]));if(_0x1beaa7[_0x65f6('0x21')][_0x65f6('0x4d')]){_0x31ec61['where']=_[_0x65f6('0x2c')](_0x31ec61['where'],{'$or':_['map'](_0x31ec61[_0x65f6('0x29')],function(_0x99fe6e){var _0x1a7e52={};_0x1a7e52[_0x99fe6e]={'$like':'%'+_0x1beaa7[_0x65f6('0x21')][_0x65f6('0x4d')]+'%'};return _0x1a7e52;})});}_0x31ec61=_[_0x65f6('0x2c')]({},_0x31ec61,_0x1beaa7['options']);return _0x29b2de[_0x65f6('0x70')](_0x31ec61);}})['then'](function(_0x1ef2a0){if(_0x1ef2a0){_0x430fb8=_0x1ef2a0[_0x65f6('0x4c')];if(!_0x1beaa7[_0x65f6('0x21')]['hasOwnProperty'](_0x65f6('0x4e'))){_0x31ec61['limit']=qs['limit'](_0x1beaa7[_0x65f6('0x21')][_0x65f6('0xe')]);_0x31ec61[_0x65f6('0xd')]=qs[_0x65f6('0xd')](_0x1beaa7[_0x65f6('0x21')]['offset']);}return _0x29b2de[_0x65f6('0x70')](_0x31ec61);}})[_0x65f6('0x13')](function(_0x3bebe3){if(_0x3bebe3){return _0x3bebe3?{'count':_0x430fb8,'rows':_0x3bebe3}:null;}})[_0x65f6('0x13')](respondWithResult(_0x87a9e4,null))['catch'](handleError(_0x87a9e4,null));};
\ No newline at end of file