Built motion from commit ddca4d0d.|2.5.47
[motion2.git] / server / api / whatsappQueue / whatsappQueue.controller.js
index 0d745b2..7054531 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xf543=['includeAll','include','findAll','rows','catch','show','params','intersection','length','options','body','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','user','UserProfileSection','userProfileId','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','find','describe','getMembers','findOne','UserWhatsappQueue','WhatsappQueueId','User','findAndCountAll','UserId','agent','whatsappPause','updatedAt','createdAt','%s/%s','SIP','getTeams','Team','addTeams','ids','online','voicePause','interface','flatMap','transaction','each','findOrCreate','forEach','emit','userWhatsappQueue:save','removeTeams','Agents','field','tq.TeamId','from','join','user_has_teams','ut.TeamId\x20=\x20tq.TeamId','WhatsappQueueId\x20=\x20?','clone','ut.UserId\x20=\x20?','push','sequelize','toString','SELECT','every','TeamId','includes','all','union','compact','value','isEmpty','userWhatsappQueue:remove','addAgents','omit','spread','removeAgents','isArray','getAgents','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','util','path','to-csv','ejs','lodash','crypto','jsforce','desk.js','papaparse','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/utils','../../config/environment','defaults','redis','localhost','socket.io-emitter','./whatsappQueue.socket','register','sendStatus','status','end','json','count','offset','limit','set','Content-Range','apply','reject','save','then','destroy','get','WhatsappQueues','UserProfileResource','error','stack','name','send','index','map','WhatsappQueue','rawAttributes','fieldName','type','key','model','query','keys','filters','attributes','fields','hasOwnProperty','nolimit','order','sort','where','pick','merge','VIRTUAL','filter'];(function(_0x1c24c9,_0x1852cf){var _0x1a44c8=function(_0x570336){while(--_0x570336){_0x1c24c9['push'](_0x1c24c9['shift']());}};_0x1a44c8(++_0x1852cf);}(_0xf543,0x170));var _0x3f54=function(_0x31c138,_0x40f6f7){_0x31c138=_0x31c138-0x0;var _0x42921d=_0xf543[_0x31c138];return _0x42921d;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0x3f54('0x0'));var rimraf=require(_0x3f54('0x1'));var zipdir=require(_0x3f54('0x2'));var jsonpatch=require(_0x3f54('0x3'));var rp=require(_0x3f54('0x4'));var moment=require(_0x3f54('0x5'));var BPromise=require('bluebird');var Mustache=require('mustache');var util=require(_0x3f54('0x6'));var path=require(_0x3f54('0x7'));var sox=require('sox');var csv=require(_0x3f54('0x8'));var ejs=require(_0x3f54('0x9'));var fs=require('fs');var _=require(_0x3f54('0xa'));var squel=require('squel');var crypto=require(_0x3f54('0xb'));var jsforce=require(_0x3f54('0xc'));var deskjs=require(_0x3f54('0xd'));var toCsv=require(_0x3f54('0x8'));var querystring=require('querystring');var Papa=require(_0x3f54('0xe'));var Redis=require('ioredis');var authService=require('../../components/auth/service');var qs=require(_0x3f54('0xf'));var as=require(_0x3f54('0x10'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x3f54('0x11'))(_0x3f54('0x12'));var utils=require(_0x3f54('0x13'));var config=require(_0x3f54('0x14'));var licenseUtil=require('../../config/license/util');var db=require('../../mysqldb')['db'];config['redis']=_[_0x3f54('0x15')](config[_0x3f54('0x16')],{'host':_0x3f54('0x17'),'port':0x18eb});var socket=require(_0x3f54('0x18'))(new Redis(config[_0x3f54('0x16')]));require(_0x3f54('0x19'))[_0x3f54('0x1a')](socket);function respondWithStatusCode(_0x35a6d7,_0x1f109c){_0x1f109c=_0x1f109c||0xcc;return function(_0x1250fc){if(_0x1250fc){return _0x35a6d7[_0x3f54('0x1b')](_0x1f109c);}return _0x35a6d7[_0x3f54('0x1c')](_0x1f109c)[_0x3f54('0x1d')]();};}function respondWithResult(_0x1acdbb,_0x59b77b){_0x59b77b=_0x59b77b||0xc8;return function(_0x41cd93){if(_0x41cd93){return _0x1acdbb[_0x3f54('0x1c')](_0x59b77b)[_0x3f54('0x1e')](_0x41cd93);}};}function respondWithFilteredResult(_0x16c936,_0xfecae2){return function(_0x4661db){if(_0x4661db){var _0x1ccd24=_0x4661db[_0x3f54('0x1f')],_0x50b5ac=_0xfecae2['offset'],_0x44172b=_0xfecae2[_0x3f54('0x20')]+_0xfecae2[_0x3f54('0x21')],_0x244fd9;if(_0x44172b>=_0x1ccd24){_0x44172b=_0x1ccd24;_0x244fd9=0xc8;}else{_0x244fd9=0xce;}_0x16c936[_0x3f54('0x1c')](_0x244fd9);return _0x16c936[_0x3f54('0x22')](_0x3f54('0x23'),_0x50b5ac+'-'+_0x44172b+'/'+_0x1ccd24)['json'](_0x4661db);}return null;};}function patchUpdates(_0x157522){return function(_0x486ed5){try{jsonpatch[_0x3f54('0x24')](_0x486ed5,_0x157522,!![]);}catch(_0x2e16ba){return BPromise[_0x3f54('0x25')](_0x2e16ba);}return _0x486ed5[_0x3f54('0x26')]();};}function saveUpdates(_0x57cfe6,_0x16f853){return function(_0x828ccf){if(_0x828ccf){return _0x828ccf['update'](_0x57cfe6)[_0x3f54('0x27')](function(_0x278618){return _0x278618;});}return null;};}function removeEntity(_0x282f8d,_0x5cc174){return function(_0x882819){if(_0x882819){return _0x882819[_0x3f54('0x28')]()[_0x3f54('0x27')](function(){var _0x370b1a=_0x882819[_0x3f54('0x29')]({'plain':!![]});var _0x1a97f7=_0x3f54('0x2a');return db[_0x3f54('0x2b')][_0x3f54('0x28')]({'where':{'type':_0x1a97f7,'resourceId':_0x370b1a['id']}})[_0x3f54('0x27')](function(){return _0x882819;});})[_0x3f54('0x27')](function(){_0x282f8d[_0x3f54('0x1c')](0xcc)[_0x3f54('0x1d')]();});}};}function handleEntityNotFound(_0x5b5e6d,_0x1a3a69){return function(_0x3984ef){if(!_0x3984ef){_0x5b5e6d[_0x3f54('0x1b')](0x194);}return _0x3984ef;};}function handleError(_0x83f987,_0xd3a40e){_0xd3a40e=_0xd3a40e||0x1f4;return function(_0x32cab7){logger[_0x3f54('0x2c')](_0x32cab7[_0x3f54('0x2d')]);if(_0x32cab7['name']){delete _0x32cab7[_0x3f54('0x2e')];}_0x83f987['status'](_0xd3a40e)[_0x3f54('0x2f')](_0x32cab7);};}exports[_0x3f54('0x30')]=function(_0x4c0d8c,_0xf773ec){var _0x2a2d8c={},_0x4bf206={},_0x2d89a6={'count':0x0,'rows':[]};var _0x1ddcca=_[_0x3f54('0x31')](db[_0x3f54('0x32')][_0x3f54('0x33')],function(_0x16d3f9){return{'name':_0x16d3f9[_0x3f54('0x34')],'type':_0x16d3f9[_0x3f54('0x35')][_0x3f54('0x36')]};});_0x4bf206[_0x3f54('0x37')]=_[_0x3f54('0x31')](_0x1ddcca,_0x3f54('0x2e'));_0x4bf206[_0x3f54('0x38')]=_[_0x3f54('0x39')](_0x4c0d8c[_0x3f54('0x38')]);_0x4bf206[_0x3f54('0x3a')]=_['intersection'](_0x4bf206[_0x3f54('0x37')],_0x4bf206['query']);_0x2a2d8c[_0x3f54('0x3b')]=_['intersection'](_0x4bf206[_0x3f54('0x37')],qs['fields'](_0x4c0d8c['query'][_0x3f54('0x3c')]));_0x2a2d8c[_0x3f54('0x3b')]=_0x2a2d8c[_0x3f54('0x3b')]['length']?_0x2a2d8c['attributes']:_0x4bf206[_0x3f54('0x37')];if(!_0x4c0d8c[_0x3f54('0x38')][_0x3f54('0x3d')](_0x3f54('0x3e'))){_0x2a2d8c[_0x3f54('0x21')]=qs['limit'](_0x4c0d8c['query'][_0x3f54('0x21')]);_0x2a2d8c['offset']=qs[_0x3f54('0x20')](_0x4c0d8c[_0x3f54('0x38')][_0x3f54('0x20')]);}_0x2a2d8c[_0x3f54('0x3f')]=qs[_0x3f54('0x40')](_0x4c0d8c[_0x3f54('0x38')][_0x3f54('0x40')]);_0x2a2d8c[_0x3f54('0x41')]=qs[_0x3f54('0x3a')](_[_0x3f54('0x42')](_0x4c0d8c['query'],_0x4bf206[_0x3f54('0x3a')]),_0x1ddcca);if(_0x4c0d8c[_0x3f54('0x38')]['filter']){_0x2a2d8c['where']=_[_0x3f54('0x43')](_0x2a2d8c[_0x3f54('0x41')],{'$or':_['map'](_0x1ddcca,function(_0x54c01d){if(_0x54c01d[_0x3f54('0x35')]!==_0x3f54('0x44')){var _0xa2d9c={};_0xa2d9c[_0x54c01d['name']]={'$like':'%'+_0x4c0d8c[_0x3f54('0x38')][_0x3f54('0x45')]+'%'};return _0xa2d9c;}})});}_0x2a2d8c=_[_0x3f54('0x43')]({},_0x2a2d8c,_0x4c0d8c['options']);var _0x1f8600={'where':_0x2a2d8c[_0x3f54('0x41')]};return db[_0x3f54('0x32')][_0x3f54('0x1f')](_0x1f8600)[_0x3f54('0x27')](function(_0x58bde1){_0x2d89a6['count']=_0x58bde1;if(_0x4c0d8c[_0x3f54('0x38')][_0x3f54('0x46')]){_0x2a2d8c[_0x3f54('0x47')]=[{'all':!![]}];}return db[_0x3f54('0x32')][_0x3f54('0x48')](_0x2a2d8c);})[_0x3f54('0x27')](function(_0x26f476){_0x2d89a6[_0x3f54('0x49')]=_0x26f476;return _0x2d89a6;})[_0x3f54('0x27')](respondWithFilteredResult(_0xf773ec,_0x2a2d8c))[_0x3f54('0x4a')](handleError(_0xf773ec,null));};exports[_0x3f54('0x4b')]=function(_0x522f42,_0x3a7f90){var _0x3c6d7b={'raw':!![],'where':{'id':_0x522f42[_0x3f54('0x4c')]['id']}},_0x28d0b9={};_0x28d0b9[_0x3f54('0x37')]=_[_0x3f54('0x39')](db[_0x3f54('0x32')][_0x3f54('0x33')]);_0x28d0b9[_0x3f54('0x38')]=_['keys'](_0x522f42[_0x3f54('0x38')]);_0x28d0b9[_0x3f54('0x3a')]=_['intersection'](_0x28d0b9['model'],_0x28d0b9[_0x3f54('0x38')]);_0x3c6d7b['attributes']=_[_0x3f54('0x4d')](_0x28d0b9[_0x3f54('0x37')],qs[_0x3f54('0x3c')](_0x522f42[_0x3f54('0x38')][_0x3f54('0x3c')]));_0x3c6d7b[_0x3f54('0x3b')]=_0x3c6d7b[_0x3f54('0x3b')][_0x3f54('0x4e')]?_0x3c6d7b[_0x3f54('0x3b')]:_0x28d0b9[_0x3f54('0x37')];if(_0x522f42['query'][_0x3f54('0x46')]){_0x3c6d7b[_0x3f54('0x47')]=[{'all':!![]}];}_0x3c6d7b=_[_0x3f54('0x43')]({},_0x3c6d7b,_0x522f42[_0x3f54('0x4f')]);return db[_0x3f54('0x32')]['find'](_0x3c6d7b)[_0x3f54('0x27')](handleEntityNotFound(_0x3a7f90,null))[_0x3f54('0x27')](respondWithResult(_0x3a7f90,null))[_0x3f54('0x4a')](handleError(_0x3a7f90,null));};exports['create']=function(_0x482186,_0x3e8926){return db[_0x3f54('0x32')]['create'](_0x482186[_0x3f54('0x50')],{})['then'](function(_0x59ace4){var _0x1d4593=_0x482186['user'][_0x3f54('0x29')]({'plain':!![]});if(!_0x1d4593)throw new Error(_0x3f54('0x51'));if(_0x1d4593[_0x3f54('0x52')]===_0x3f54('0x53')){var _0x52ed67=_0x59ace4['get']({'plain':!![]});var _0x23da75=_0x3f54('0x2a');return db[_0x3f54('0x54')]['find']({'where':{'name':_0x23da75,'userProfileId':_0x1d4593[_0x3f54('0x55')]},'raw':!![]})['then'](function(_0x556ac9){if(_0x556ac9&&_0x556ac9['autoAssociation']===0x0){return db['UserProfileResource']['create']({'name':_0x52ed67[_0x3f54('0x2e')],'resourceId':_0x52ed67['id'],'type':_0x556ac9['name'],'sectionId':_0x556ac9['id']},{})[_0x3f54('0x27')](function(){return _0x59ace4;});}else{return _0x59ace4;}})[_0x3f54('0x4a')](function(_0x1ad7de){logger[_0x3f54('0x2c')](_0x3f54('0x56'),_0x1ad7de);throw _0x1ad7de;});}return _0x59ace4;})[_0x3f54('0x27')](respondWithResult(_0x3e8926,0xc9))['catch'](handleError(_0x3e8926,null));};exports['update']=function(_0x298bf9,_0x4418b2){if(_0x298bf9[_0x3f54('0x50')]['id']){delete _0x298bf9[_0x3f54('0x50')]['id'];}return db[_0x3f54('0x32')][_0x3f54('0x57')]({'where':{'id':_0x298bf9[_0x3f54('0x4c')]['id']}})[_0x3f54('0x27')](handleEntityNotFound(_0x4418b2,null))['then'](saveUpdates(_0x298bf9[_0x3f54('0x50')],null))['then'](respondWithResult(_0x4418b2,null))['catch'](handleError(_0x4418b2,null));};exports[_0x3f54('0x28')]=function(_0x31d21b,_0x4b8e51){return db['WhatsappQueue'][_0x3f54('0x57')]({'where':{'id':_0x31d21b[_0x3f54('0x4c')]['id']}})[_0x3f54('0x27')](handleEntityNotFound(_0x4b8e51,null))['then'](removeEntity(_0x4b8e51,null))['catch'](handleError(_0x4b8e51,null));};exports['describe']=function(_0x219bf1,_0x1aab4a){return db[_0x3f54('0x32')][_0x3f54('0x58')]()['then'](respondWithResult(_0x1aab4a,null))[_0x3f54('0x4a')](handleError(_0x1aab4a,null));};exports[_0x3f54('0x59')]=function(_0x2e3d19,_0x295326,_0xf1c602){var _0x2c9534={'raw':!![],'where':{}},_0x139976={},_0x4df4ce;return db[_0x3f54('0x32')][_0x3f54('0x5a')]({'where':{'id':_0x2e3d19['params']['id']}})[_0x3f54('0x27')](handleEntityNotFound(_0x295326,null))[_0x3f54('0x27')](function(_0x19d34a){if(_0x19d34a){_0x4df4ce=_0x19d34a[_0x3f54('0x29')]({'plain':!![]});_0x139976[_0x3f54('0x37')]=_['keys'](db[_0x3f54('0x5b')][_0x3f54('0x33')]);_0x139976['query']=_[_0x3f54('0x39')](_0x2e3d19['query']);_0x139976[_0x3f54('0x3a')]=_[_0x3f54('0x4d')](_0x139976[_0x3f54('0x37')],_0x139976[_0x3f54('0x38')]);_0x2c9534[_0x3f54('0x3b')]=_[_0x3f54('0x4d')](_0x139976[_0x3f54('0x37')],qs[_0x3f54('0x3c')](_0x2e3d19[_0x3f54('0x38')]['fields']));_0x2c9534['attributes']=_0x2c9534[_0x3f54('0x3b')][_0x3f54('0x4e')]?_0x2c9534[_0x3f54('0x3b')]:_0x139976[_0x3f54('0x37')];if(!_0x2e3d19['query']['hasOwnProperty'](_0x3f54('0x3e'))){_0x2c9534[_0x3f54('0x21')]=qs['limit'](_0x2e3d19['query'][_0x3f54('0x21')]);_0x2c9534[_0x3f54('0x20')]=qs['offset'](_0x2e3d19[_0x3f54('0x38')][_0x3f54('0x20')]);}_0x2c9534[_0x3f54('0x3f')]=qs[_0x3f54('0x40')](_0x2e3d19['query']['sort']);_0x2c9534['where']=qs[_0x3f54('0x3a')](_[_0x3f54('0x42')](_0x2e3d19[_0x3f54('0x38')],_0x139976[_0x3f54('0x3a')]));_0x2c9534['where'][_0x3f54('0x5c')]=_0x19d34a['id'];if(_0x2e3d19['query']['filter']){_0x2c9534['where']=_[_0x3f54('0x43')](_0x2c9534[_0x3f54('0x41')],{'$or':_[_0x3f54('0x31')](_0x2c9534['attributes'],function(_0x172ed0){var _0x3dab64={};_0x3dab64[_0x172ed0]={'$like':'%'+_0x2e3d19[_0x3f54('0x38')][_0x3f54('0x45')]+'%'};return _0x3dab64;})});}_0x2c9534=_[_0x3f54('0x43')]({},_0x2c9534,_0x2e3d19['options']);return db['UserWhatsappQueue'][_0x3f54('0x48')](_0x2c9534);}})[_0x3f54('0x27')](function(_0x101e64){if(_0x101e64){return db[_0x3f54('0x5d')][_0x3f54('0x5e')]({'where':{'id':_[_0x3f54('0x31')](_0x101e64,_0x3f54('0x5f')),'role':_0x3f54('0x60')},'attributes':['id',_0x3f54('0x2e'),_0x3f54('0x61'),_0x3f54('0x62'),_0x3f54('0x63')]});}})['then'](function(_0x37357e){if(_0x37357e){return{'count':_0x37357e[_0x3f54('0x1f')],'rows':_[_0x3f54('0x31')](_0x37357e[_0x3f54('0x49')],function(_0x20cf22){return{'membername':_0x20cf22[_0x3f54('0x2e')],'UserId':_0x20cf22['id'],'queue_name':_0x4df4ce['name'],'WhatsappQueueId':_0x4df4ce['id'],'interface':util['format'](_0x3f54('0x64'),_0x3f54('0x65'),_0x20cf22['name']),'penalty':0x0,'paused':_0x20cf22[_0x3f54('0x61')],'createdAt':_0x20cf22['createdAt'],'updatedAt':_0x20cf22['updatedAt']};})};}else{return{'count':0x0,'rows':[]};}})[_0x3f54('0x27')](respondWithFilteredResult(_0x295326,_0x2c9534))[_0x3f54('0x4a')](handleError(_0x295326,null));};exports[_0x3f54('0x66')]=function(_0x287249,_0x1acf31,_0x426273){var _0xa90fbb={};var _0x2b816c={};var _0x585fc9;var _0x4efd3c;return db[_0x3f54('0x32')]['findOne']({'where':{'id':_0x287249[_0x3f54('0x4c')]['id']}})[_0x3f54('0x27')](handleEntityNotFound(_0x1acf31,null))[_0x3f54('0x27')](function(_0x2bf0a8){if(_0x2bf0a8){_0x585fc9=_0x2bf0a8;_0x2b816c[_0x3f54('0x37')]=_[_0x3f54('0x39')](db[_0x3f54('0x67')]['rawAttributes']);_0x2b816c[_0x3f54('0x38')]=_['keys'](_0x287249[_0x3f54('0x38')]);_0x2b816c[_0x3f54('0x3a')]=_[_0x3f54('0x4d')](_0x2b816c['model'],_0x2b816c['query']);_0xa90fbb[_0x3f54('0x3b')]=_['intersection'](_0x2b816c['model'],qs['fields'](_0x287249[_0x3f54('0x38')]['fields']));_0xa90fbb['attributes']=_0xa90fbb[_0x3f54('0x3b')][_0x3f54('0x4e')]?_0xa90fbb[_0x3f54('0x3b')]:_0x2b816c['model'];_0xa90fbb[_0x3f54('0x3f')]=qs[_0x3f54('0x40')](_0x287249[_0x3f54('0x38')]['sort']);_0xa90fbb[_0x3f54('0x41')]=qs['filters'](_['pick'](_0x287249[_0x3f54('0x38')],_0x2b816c[_0x3f54('0x3a')]));if(_0x287249[_0x3f54('0x38')][_0x3f54('0x45')]){_0xa90fbb[_0x3f54('0x41')]=_[_0x3f54('0x43')](_0xa90fbb[_0x3f54('0x41')],{'$or':_[_0x3f54('0x31')](_0xa90fbb['attributes'],function(_0x59eb88){var _0x2e39b8={};_0x2e39b8[_0x59eb88]={'$like':'%'+_0x287249[_0x3f54('0x38')][_0x3f54('0x45')]+'%'};return _0x2e39b8;})});}_0xa90fbb=_['merge']({},_0xa90fbb,_0x287249[_0x3f54('0x4f')]);return _0x585fc9[_0x3f54('0x66')](_0xa90fbb);}})[_0x3f54('0x27')](function(_0x155838){if(_0x155838){_0x4efd3c=_0x155838[_0x3f54('0x4e')];if(!_0x287249['query'][_0x3f54('0x3d')](_0x3f54('0x3e'))){_0xa90fbb['limit']=qs['limit'](_0x287249['query'][_0x3f54('0x21')]);_0xa90fbb[_0x3f54('0x20')]=qs[_0x3f54('0x20')](_0x287249[_0x3f54('0x38')][_0x3f54('0x20')]);}return _0x585fc9[_0x3f54('0x66')](_0xa90fbb);}})[_0x3f54('0x27')](function(_0x5ddea0){if(_0x5ddea0){return _0x5ddea0?{'count':_0x4efd3c,'rows':_0x5ddea0}:null;}})[_0x3f54('0x27')](respondWithResult(_0x1acf31,null))[_0x3f54('0x4a')](handleError(_0x1acf31,null));};exports[_0x3f54('0x68')]=function(_0x3f0bbe,_0x3b0133,_0xeca017){var _0x50fb7a=_0x3f0bbe['body'][_0x3f54('0x69')];return db['Team'][_0x3f54('0x48')]({'where':{'id':_0x50fb7a},'attributes':['id'],'include':[{'model':db[_0x3f54('0x5d')],'as':'Agents','attributes':['id',_0x3f54('0x2e'),_0x3f54('0x6a'),_0x3f54('0x6b'),_0x3f54('0x6c')],'raw':!![]}]})[_0x3f54('0x27')](function(_0x1de223){if(_0x1de223){var _0xb94f9=_[_0x3f54('0x6d')](_0x1de223,function(_0xaeb41b){var _0x5cab08=_0xaeb41b[_0x3f54('0x29')]({'plain':!![]});return _0x5cab08['Agents'];});return db[_0x3f54('0x32')][_0x3f54('0x57')]({'where':{'id':_0x3f0bbe[_0x3f54('0x4c')]['id']}})['then'](function(_0x1a282a){return db['sequelize'][_0x3f54('0x6e')](function(_0x1817d4){return _0x1a282a['addTeams'](_0x50fb7a,{'transaction':_0x1817d4})['then'](function(){return BPromise[_0x3f54('0x6f')](_0xb94f9,function(_0x105d01){return db[_0x3f54('0x5b')][_0x3f54('0x70')]({'where':{'UserId':_0x105d01['id'],'WhatsappQueueId':_0x3f0bbe['params']['id']},'transaction':_0x1817d4});});})[_0x3f54('0x27')](function(){_0xb94f9[_0x3f54('0x71')](function(_0x577852){socket[_0x3f54('0x72')](_0x3f54('0x73'),{'UserId':_0x577852['id'],'WhatsappQueueId':_0x1a282a['id']});});});});});}})['then'](respondWithStatusCode(_0x3b0133,null))[_0x3f54('0x4a')](handleError(_0x3b0133,null));};exports[_0x3f54('0x74')]=function(_0xb76406,_0x26a96f,_0x3a608b){return db[_0x3f54('0x67')][_0x3f54('0x48')]({'where':{'id':_0xb76406['query'][_0x3f54('0x69')]},'attributes':['id'],'include':[{'model':db[_0x3f54('0x5d')],'as':_0x3f54('0x75'),'attributes':['id'],'raw':!![]}]})['then'](handleEntityNotFound(_0x26a96f,null))['then'](function(_0x3fe6a4){var _0x3eee21=_['map'](_0x3fe6a4,'id');var _0x57583c=[];var _0x56cd5f=[];var _0x467948=squel['select']();_0x467948[_0x3f54('0x76')](_0x3f54('0x77'))[_0x3f54('0x78')]('team_has_whatsapp_queues','tq')[_0x3f54('0x79')](_0x3f54('0x7a'),'ut',_0x3f54('0x7b'))[_0x3f54('0x41')](_0x3f54('0x7c'),_0xb76406[_0x3f54('0x4c')]['id']);for(var _0x937fb1=0x0;_0x937fb1<_0x3fe6a4[_0x3f54('0x4e')];_0x937fb1+=0x1){let _0x40f796=_0x3fe6a4[_0x937fb1];for(var _0x5adcfc=0x0;_0x5adcfc<_0x40f796['Agents'][_0x3f54('0x4e')];_0x5adcfc+=0x1){let _0x1b94b1=_0x40f796['Agents'][_0x5adcfc];var _0x46198c=_0x467948[_0x3f54('0x7d')]();_0x46198c['where'](_0x3f54('0x7e'),_0x1b94b1['id']);_0x56cd5f[_0x3f54('0x7f')](db[_0x3f54('0x80')]['query'](_0x46198c[_0x3f54('0x81')](),{'type':db['sequelize']['QueryTypes'][_0x3f54('0x82')]})[_0x3f54('0x27')](function(_0x1bdc09){if(_0x1bdc09['length']===0x1){return _0x1b94b1['id'];}else{var _0x2fac5f=_[_0x3f54('0x83')](_[_0x3f54('0x31')](_0x1bdc09,_0x3f54('0x84')),function(_0x51d532){return _[_0x3f54('0x85')](_0x3eee21,_0x51d532);});if(_0x2fac5f){return _0x1b94b1['id'];}}}));}}return BPromise[_0x3f54('0x86')](_0x56cd5f)[_0x3f54('0x27')](function(_0x3700d8){_0x57583c=_(_0x57583c)[_0x3f54('0x87')](_0x3700d8)[_0x3f54('0x88')]()[_0x3f54('0x89')]();return db[_0x3f54('0x32')][_0x3f54('0x57')]({'where':{'id':_0xb76406['params']['id']}})['then'](function(_0x4f7676){return db[_0x3f54('0x80')]['transaction'](function(_0x20d160){return _0x4f7676['removeTeams'](_0xb76406[_0x3f54('0x38')]['ids'],{'transaction':_0x20d160})[_0x3f54('0x27')](function(){if(!_[_0x3f54('0x8a')](_0x57583c)){return _0x4f7676['removeAgents'](_0x57583c,{'transaction':_0x20d160});}})[_0x3f54('0x27')](function(){_0x57583c[_0x3f54('0x71')](function(_0x5b2fdc){socket['emit'](_0x3f54('0x8b'),{'UserId':_0x5b2fdc,'WhatsappQueueId':_0x4f7676['id']});});});});});});})[_0x3f54('0x27')](respondWithStatusCode(_0x26a96f,null))[_0x3f54('0x4a')](handleError(_0x26a96f,null));};exports[_0x3f54('0x8c')]=function(_0xd30d5,_0xec0b70,_0x5c65af){return db[_0x3f54('0x32')][_0x3f54('0x57')]({'where':{'id':_0xd30d5[_0x3f54('0x4c')]['id']}})[_0x3f54('0x27')](handleEntityNotFound(_0xec0b70,null))['then'](function(_0x48af66){if(_0x48af66){return _0x48af66[_0x3f54('0x8c')](_0xd30d5['body'][_0x3f54('0x69')],_[_0x3f54('0x8d')](_0xd30d5['body'],[_0x3f54('0x69'),'id'])||{})[_0x3f54('0x8e')](function(_0x4fb0b8){for(var _0x181d78=0x0;_0x181d78<_0xd30d5[_0x3f54('0x50')][_0x3f54('0x69')][_0x3f54('0x4e')];_0x181d78+=0x1){socket['emit'](_0x3f54('0x73'),{'UserId':_0xd30d5[_0x3f54('0x50')][_0x3f54('0x69')][_0x181d78],'WhatsappQueueId':_0xd30d5[_0x3f54('0x4c')]['id']});}return _0x4fb0b8;});}})[_0x3f54('0x27')](respondWithResult(_0xec0b70,null))[_0x3f54('0x4a')](handleError(_0xec0b70,null));};exports[_0x3f54('0x8f')]=function(_0x808cc2,_0x2a4cc3,_0x23ef9e){return db[_0x3f54('0x32')][_0x3f54('0x57')]({'where':{'id':_0x808cc2['params']['id']}})[_0x3f54('0x27')](handleEntityNotFound(_0x2a4cc3,null))[_0x3f54('0x27')](function(_0x4c181d){if(_0x4c181d){return _0x4c181d[_0x3f54('0x8f')](_0x808cc2['query']['ids'])[_0x3f54('0x27')](function(){if(_[_0x3f54('0x90')](_0x808cc2['query'][_0x3f54('0x69')])){for(var _0x1b2333=0x0;_0x1b2333<_0x808cc2['query'][_0x3f54('0x69')][_0x3f54('0x4e')];_0x1b2333+=0x1){socket['emit'](_0x3f54('0x8b'),{'UserId':Number(_0x808cc2[_0x3f54('0x38')][_0x3f54('0x69')][_0x1b2333]),'WhatsappQueueId':Number(_0x808cc2['params']['id'])});}}else{socket[_0x3f54('0x72')](_0x3f54('0x8b'),{'UserId':Number(_0x808cc2[_0x3f54('0x38')]['ids']),'WhatsappQueueId':Number(_0x808cc2[_0x3f54('0x4c')]['id'])});}});}})[_0x3f54('0x27')](respondWithStatusCode(_0x2a4cc3,null))[_0x3f54('0x4a')](handleError(_0x2a4cc3,null));};exports['getAgents']=function(_0x22f515,_0x5387b7,_0x118526){var _0x1f0883={};var _0x9f4d1={};var _0x158209;var _0x253453;return db[_0x3f54('0x32')][_0x3f54('0x5a')]({'where':{'id':_0x22f515['params']['id']}})[_0x3f54('0x27')](handleEntityNotFound(_0x5387b7,null))[_0x3f54('0x27')](function(_0x141bf7){if(_0x141bf7){_0x158209=_0x141bf7;_0x9f4d1[_0x3f54('0x37')]=_[_0x3f54('0x39')](db['User']['rawAttributes']);_0x9f4d1[_0x3f54('0x38')]=_[_0x3f54('0x39')](_0x22f515[_0x3f54('0x38')]);_0x9f4d1['filters']=_[_0x3f54('0x4d')](_0x9f4d1[_0x3f54('0x37')],_0x9f4d1[_0x3f54('0x38')]);_0x1f0883[_0x3f54('0x3b')]=_[_0x3f54('0x4d')](_0x9f4d1[_0x3f54('0x37')],qs['fields'](_0x22f515[_0x3f54('0x38')][_0x3f54('0x3c')]));_0x1f0883[_0x3f54('0x3b')]=_0x1f0883[_0x3f54('0x3b')][_0x3f54('0x4e')]?_0x1f0883[_0x3f54('0x3b')]:_0x9f4d1[_0x3f54('0x37')];_0x1f0883[_0x3f54('0x3f')]=qs['sort'](_0x22f515[_0x3f54('0x38')][_0x3f54('0x40')]);_0x1f0883[_0x3f54('0x41')]=qs[_0x3f54('0x3a')](_[_0x3f54('0x42')](_0x22f515[_0x3f54('0x38')],_0x9f4d1[_0x3f54('0x3a')]));if(_0x22f515[_0x3f54('0x38')][_0x3f54('0x45')]){_0x1f0883[_0x3f54('0x41')]=_['merge'](_0x1f0883['where'],{'$or':_[_0x3f54('0x31')](_0x1f0883[_0x3f54('0x3b')],function(_0x3cc281){var _0x4928d3={};_0x4928d3[_0x3cc281]={'$like':'%'+_0x22f515[_0x3f54('0x38')]['filter']+'%'};return _0x4928d3;})});}_0x1f0883=_['merge']({},_0x1f0883,_0x22f515[_0x3f54('0x4f')]);return _0x158209[_0x3f54('0x91')](_0x1f0883);}})[_0x3f54('0x27')](function(_0x2e14c2){if(_0x2e14c2){_0x253453=_0x2e14c2[_0x3f54('0x4e')];if(!_0x22f515[_0x3f54('0x38')][_0x3f54('0x3d')](_0x3f54('0x3e'))){_0x1f0883[_0x3f54('0x21')]=qs[_0x3f54('0x21')](_0x22f515[_0x3f54('0x38')][_0x3f54('0x21')]);_0x1f0883[_0x3f54('0x20')]=qs['offset'](_0x22f515[_0x3f54('0x38')][_0x3f54('0x20')]);}return _0x158209['getAgents'](_0x1f0883);}})[_0x3f54('0x27')](function(_0xa384e5){if(_0xa384e5){return _0xa384e5?{'count':_0x253453,'rows':_0xa384e5}:null;}})[_0x3f54('0x27')](respondWithResult(_0x5387b7,null))[_0x3f54('0x4a')](handleError(_0x5387b7,null));};
\ No newline at end of file
+var _0x3e9a=['sox','to-csv','fs-extra','squel','crypto','jsforce','desk.js','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/environment','../../config/license/util','../../mysqldb','redis','defaults','localhost','socket.io-emitter','register','sendStatus','status','offset','undefined','limit','count','set','json','apply','reject','save','then','destroy','get','WhatsappQueues','UserProfileResource','end','error','stack','name','send','index','map','fieldName','type','key','model','query','keys','intersection','fields','attributes','length','hasOwnProperty','nolimit','sort','where','filters','pick','filter','VIRTUAL','WhatsappQueue','includeAll','findAll','rows','catch','show','params','rawAttributes','include','merge','options','find','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','update','describe','getMembers','findOne','order','UserWhatsappQueue','User','findAndCountAll','UserId','agent','whatsappPause','updatedAt','createdAt','format','getTeams','Team','addTeams','Agents','interface','flatMap','sequelize','each','forEach','emit','userWhatsappQueue:save','removeTeams','field','tq.TeamId','from','join','user_has_teams','ut.TeamId\x20=\x20tq.TeamId','WhatsappQueueId\x20=\x20?','clone','push','toString','QueryTypes','every','TeamId','includes','all','union','compact','value','isEmpty','removeAgents','userWhatsappQueue:remove','addAgents','ids','omit','spread','isArray','getAgents','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache'];(function(_0x122ef9,_0x451d2a){var _0x42fba0=function(_0x17c9d3){while(--_0x17c9d3){_0x122ef9['push'](_0x122ef9['shift']());}};_0x42fba0(++_0x451d2a);}(_0x3e9a,0x1ab));var _0xa3e9=function(_0x19f5ad,_0xb7bc88){_0x19f5ad=_0x19f5ad-0x0;var _0x3c1507=_0x3e9a[_0x19f5ad];return _0x3c1507;};'use strict';var emlformat=require(_0xa3e9('0x0'));var rimraf=require(_0xa3e9('0x1'));var zipdir=require(_0xa3e9('0x2'));var jsonpatch=require(_0xa3e9('0x3'));var rp=require(_0xa3e9('0x4'));var moment=require(_0xa3e9('0x5'));var BPromise=require(_0xa3e9('0x6'));var Mustache=require(_0xa3e9('0x7'));var util=require('util');var path=require('path');var sox=require(_0xa3e9('0x8'));var csv=require(_0xa3e9('0x9'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0xa3e9('0xa'));var _=require('lodash');var squel=require(_0xa3e9('0xb'));var crypto=require(_0xa3e9('0xc'));var jsforce=require(_0xa3e9('0xd'));var deskjs=require(_0xa3e9('0xe'));var toCsv=require(_0xa3e9('0x9'));var querystring=require('querystring');var Papa=require(_0xa3e9('0xf'));var Redis=require(_0xa3e9('0x10'));var authService=require(_0xa3e9('0x11'));var qs=require(_0xa3e9('0x12'));var as=require(_0xa3e9('0x13'));var hardwareService=require(_0xa3e9('0x14'));var logger=require('../../config/logger')(_0xa3e9('0x15'));var utils=require('../../config/utils');var config=require(_0xa3e9('0x16'));var licenseUtil=require(_0xa3e9('0x17'));var db=require(_0xa3e9('0x18'))['db'];config[_0xa3e9('0x19')]=_[_0xa3e9('0x1a')](config[_0xa3e9('0x19')],{'host':_0xa3e9('0x1b'),'port':0x18eb});var socket=require(_0xa3e9('0x1c'))(new Redis(config[_0xa3e9('0x19')]));require('./whatsappQueue.socket')[_0xa3e9('0x1d')](socket);function respondWithStatusCode(_0x3f110e,_0x537339){_0x537339=_0x537339||0xcc;return function(_0x2dc1c5){if(_0x2dc1c5){return _0x3f110e[_0xa3e9('0x1e')](_0x537339);}return _0x3f110e[_0xa3e9('0x1f')](_0x537339)['end']();};}function respondWithResult(_0x5d49d0,_0x3131cd){_0x3131cd=_0x3131cd||0xc8;return function(_0x3f445d){if(_0x3f445d){return _0x5d49d0[_0xa3e9('0x1f')](_0x3131cd)['json'](_0x3f445d);}};}function respondWithFilteredResult(_0x4219e0,_0x4835ca){return function(_0x254ccc){if(_0x254ccc){var _0x43c65e=typeof _0x4835ca[_0xa3e9('0x20')]===_0xa3e9('0x21')&&typeof _0x4835ca[_0xa3e9('0x22')]==='undefined';var _0x466a42=_0x254ccc['count'];var _0x564816=_0x43c65e?0x0:_0x4835ca[_0xa3e9('0x20')];var _0x1d1726=_0x43c65e?_0x254ccc[_0xa3e9('0x23')]:_0x4835ca[_0xa3e9('0x20')]+_0x4835ca[_0xa3e9('0x22')];var _0xb5be2b;if(_0x1d1726>=_0x466a42){_0x1d1726=_0x466a42;_0xb5be2b=0xc8;}else{_0xb5be2b=0xce;}_0x4219e0['status'](_0xb5be2b);return _0x4219e0[_0xa3e9('0x24')]('Content-Range',_0x564816+'-'+_0x1d1726+'/'+_0x466a42)[_0xa3e9('0x25')](_0x254ccc);}return null;};}function patchUpdates(_0x20d5a8){return function(_0x161c39){try{jsonpatch[_0xa3e9('0x26')](_0x161c39,_0x20d5a8,!![]);}catch(_0x260e23){return BPromise[_0xa3e9('0x27')](_0x260e23);}return _0x161c39[_0xa3e9('0x28')]();};}function saveUpdates(_0x80db6f,_0x1d358b){return function(_0xb796e1){if(_0xb796e1){return _0xb796e1['update'](_0x80db6f)[_0xa3e9('0x29')](function(_0x402298){return _0x402298;});}return null;};}function removeEntity(_0x3eb476,_0xe6444a){return function(_0x44b0ab){if(_0x44b0ab){return _0x44b0ab[_0xa3e9('0x2a')]()[_0xa3e9('0x29')](function(){var _0x3c4347=_0x44b0ab[_0xa3e9('0x2b')]({'plain':!![]});var _0x3700ad=_0xa3e9('0x2c');return db[_0xa3e9('0x2d')][_0xa3e9('0x2a')]({'where':{'type':_0x3700ad,'resourceId':_0x3c4347['id']}})[_0xa3e9('0x29')](function(){return _0x44b0ab;});})[_0xa3e9('0x29')](function(){_0x3eb476[_0xa3e9('0x1f')](0xcc)[_0xa3e9('0x2e')]();});}};}function handleEntityNotFound(_0x6dd181,_0xbd8819){return function(_0x156ade){if(!_0x156ade){_0x6dd181[_0xa3e9('0x1e')](0x194);}return _0x156ade;};}function handleError(_0x4c0f78,_0x233393){_0x233393=_0x233393||0x1f4;return function(_0x52f2fe){logger[_0xa3e9('0x2f')](_0x52f2fe[_0xa3e9('0x30')]);if(_0x52f2fe[_0xa3e9('0x31')]){delete _0x52f2fe[_0xa3e9('0x31')];}_0x4c0f78['status'](_0x233393)[_0xa3e9('0x32')](_0x52f2fe);};}exports[_0xa3e9('0x33')]=function(_0x3c674c,_0x2977d8){var _0x23ed26={},_0x5d1258={},_0x2a3972={'count':0x0,'rows':[]};var _0x3cefab=_[_0xa3e9('0x34')](db['WhatsappQueue']['rawAttributes'],function(_0x542ce6){return{'name':_0x542ce6[_0xa3e9('0x35')],'type':_0x542ce6[_0xa3e9('0x36')][_0xa3e9('0x37')]};});_0x5d1258[_0xa3e9('0x38')]=_[_0xa3e9('0x34')](_0x3cefab,_0xa3e9('0x31'));_0x5d1258[_0xa3e9('0x39')]=_[_0xa3e9('0x3a')](_0x3c674c[_0xa3e9('0x39')]);_0x5d1258['filters']=_['intersection'](_0x5d1258[_0xa3e9('0x38')],_0x5d1258['query']);_0x23ed26['attributes']=_[_0xa3e9('0x3b')](_0x5d1258[_0xa3e9('0x38')],qs[_0xa3e9('0x3c')](_0x3c674c[_0xa3e9('0x39')][_0xa3e9('0x3c')]));_0x23ed26[_0xa3e9('0x3d')]=_0x23ed26[_0xa3e9('0x3d')][_0xa3e9('0x3e')]?_0x23ed26['attributes']:_0x5d1258['model'];if(!_0x3c674c[_0xa3e9('0x39')][_0xa3e9('0x3f')](_0xa3e9('0x40'))){_0x23ed26['limit']=qs[_0xa3e9('0x22')](_0x3c674c[_0xa3e9('0x39')]['limit']);_0x23ed26['offset']=qs[_0xa3e9('0x20')](_0x3c674c[_0xa3e9('0x39')]['offset']);}_0x23ed26['order']=qs['sort'](_0x3c674c[_0xa3e9('0x39')][_0xa3e9('0x41')]);_0x23ed26[_0xa3e9('0x42')]=qs[_0xa3e9('0x43')](_[_0xa3e9('0x44')](_0x3c674c[_0xa3e9('0x39')],_0x5d1258[_0xa3e9('0x43')]),_0x3cefab);if(_0x3c674c[_0xa3e9('0x39')][_0xa3e9('0x45')]){_0x23ed26[_0xa3e9('0x42')]=_['merge'](_0x23ed26[_0xa3e9('0x42')],{'$or':_[_0xa3e9('0x34')](_0x3cefab,function(_0x1c78b5){if(_0x1c78b5[_0xa3e9('0x36')]!==_0xa3e9('0x46')){var _0x5e4576={};_0x5e4576[_0x1c78b5[_0xa3e9('0x31')]]={'$like':'%'+_0x3c674c[_0xa3e9('0x39')][_0xa3e9('0x45')]+'%'};return _0x5e4576;}})});}_0x23ed26=_['merge']({},_0x23ed26,_0x3c674c['options']);var _0x101b23={'where':_0x23ed26[_0xa3e9('0x42')]};return db[_0xa3e9('0x47')][_0xa3e9('0x23')](_0x101b23)[_0xa3e9('0x29')](function(_0x50da97){_0x2a3972[_0xa3e9('0x23')]=_0x50da97;if(_0x3c674c[_0xa3e9('0x39')][_0xa3e9('0x48')]){_0x23ed26['include']=[{'all':!![]}];}return db['WhatsappQueue'][_0xa3e9('0x49')](_0x23ed26);})[_0xa3e9('0x29')](function(_0x431154){_0x2a3972[_0xa3e9('0x4a')]=_0x431154;return _0x2a3972;})[_0xa3e9('0x29')](respondWithFilteredResult(_0x2977d8,_0x23ed26))[_0xa3e9('0x4b')](handleError(_0x2977d8,null));};exports[_0xa3e9('0x4c')]=function(_0x1096e5,_0xa4348){var _0x21b691={'raw':!![],'where':{'id':_0x1096e5[_0xa3e9('0x4d')]['id']}},_0x35f42f={};_0x35f42f[_0xa3e9('0x38')]=_['keys'](db[_0xa3e9('0x47')][_0xa3e9('0x4e')]);_0x35f42f[_0xa3e9('0x39')]=_[_0xa3e9('0x3a')](_0x1096e5[_0xa3e9('0x39')]);_0x35f42f[_0xa3e9('0x43')]=_[_0xa3e9('0x3b')](_0x35f42f[_0xa3e9('0x38')],_0x35f42f[_0xa3e9('0x39')]);_0x21b691[_0xa3e9('0x3d')]=_[_0xa3e9('0x3b')](_0x35f42f[_0xa3e9('0x38')],qs[_0xa3e9('0x3c')](_0x1096e5[_0xa3e9('0x39')][_0xa3e9('0x3c')]));_0x21b691[_0xa3e9('0x3d')]=_0x21b691[_0xa3e9('0x3d')][_0xa3e9('0x3e')]?_0x21b691[_0xa3e9('0x3d')]:_0x35f42f[_0xa3e9('0x38')];if(_0x1096e5[_0xa3e9('0x39')][_0xa3e9('0x48')]){_0x21b691[_0xa3e9('0x4f')]=[{'all':!![]}];}_0x21b691=_[_0xa3e9('0x50')]({},_0x21b691,_0x1096e5[_0xa3e9('0x51')]);return db[_0xa3e9('0x47')][_0xa3e9('0x52')](_0x21b691)[_0xa3e9('0x29')](handleEntityNotFound(_0xa4348,null))[_0xa3e9('0x29')](respondWithResult(_0xa4348,null))[_0xa3e9('0x4b')](handleError(_0xa4348,null));};exports['create']=function(_0x5d4bec,_0x5c8d16){return db[_0xa3e9('0x47')][_0xa3e9('0x53')](_0x5d4bec[_0xa3e9('0x54')],{})['then'](function(_0x1331a7){var _0xa19221=_0x5d4bec[_0xa3e9('0x55')][_0xa3e9('0x2b')]({'plain':!![]});if(!_0xa19221)throw new Error(_0xa3e9('0x56'));if(_0xa19221[_0xa3e9('0x57')]===_0xa3e9('0x55')){var _0x37ed50=_0x1331a7[_0xa3e9('0x2b')]({'plain':!![]});var _0x158826=_0xa3e9('0x2c');return db[_0xa3e9('0x58')]['find']({'where':{'name':_0x158826,'userProfileId':_0xa19221[_0xa3e9('0x59')]},'raw':!![]})[_0xa3e9('0x29')](function(_0x318b73){if(_0x318b73&&_0x318b73[_0xa3e9('0x5a')]===0x0){return db[_0xa3e9('0x2d')][_0xa3e9('0x53')]({'name':_0x37ed50[_0xa3e9('0x31')],'resourceId':_0x37ed50['id'],'type':_0x318b73['name'],'sectionId':_0x318b73['id']},{})[_0xa3e9('0x29')](function(){return _0x1331a7;});}else{return _0x1331a7;}})[_0xa3e9('0x4b')](function(_0x3d1bf8){logger[_0xa3e9('0x2f')](_0xa3e9('0x5b'),_0x3d1bf8);throw _0x3d1bf8;});}return _0x1331a7;})[_0xa3e9('0x29')](respondWithResult(_0x5c8d16,0xc9))[_0xa3e9('0x4b')](handleError(_0x5c8d16,null));};exports[_0xa3e9('0x5c')]=function(_0x4e7a01,_0x50e91c){if(_0x4e7a01[_0xa3e9('0x54')]['id']){delete _0x4e7a01[_0xa3e9('0x54')]['id'];}return db[_0xa3e9('0x47')]['find']({'where':{'id':_0x4e7a01[_0xa3e9('0x4d')]['id']}})[_0xa3e9('0x29')](handleEntityNotFound(_0x50e91c,null))[_0xa3e9('0x29')](saveUpdates(_0x4e7a01[_0xa3e9('0x54')],null))[_0xa3e9('0x29')](respondWithResult(_0x50e91c,null))[_0xa3e9('0x4b')](handleError(_0x50e91c,null));};exports[_0xa3e9('0x2a')]=function(_0x509625,_0xec476e){return db['WhatsappQueue'][_0xa3e9('0x52')]({'where':{'id':_0x509625[_0xa3e9('0x4d')]['id']}})[_0xa3e9('0x29')](handleEntityNotFound(_0xec476e,null))[_0xa3e9('0x29')](removeEntity(_0xec476e,null))[_0xa3e9('0x4b')](handleError(_0xec476e,null));};exports['describe']=function(_0x36f952,_0xeadc3e){return db['WhatsappQueue'][_0xa3e9('0x5d')]()[_0xa3e9('0x29')](respondWithResult(_0xeadc3e,null))['catch'](handleError(_0xeadc3e,null));};exports[_0xa3e9('0x5e')]=function(_0x31f886,_0x17eb28,_0x59aabb){var _0x1e05e8={'raw':!![],'where':{}},_0x49f669={},_0x18caae;return db[_0xa3e9('0x47')][_0xa3e9('0x5f')]({'where':{'id':_0x31f886[_0xa3e9('0x4d')]['id']}})['then'](handleEntityNotFound(_0x17eb28,null))['then'](function(_0x3f6964){if(_0x3f6964){_0x18caae=_0x3f6964[_0xa3e9('0x2b')]({'plain':!![]});_0x49f669['model']=_[_0xa3e9('0x3a')](db['UserWhatsappQueue']['rawAttributes']);_0x49f669[_0xa3e9('0x39')]=_['keys'](_0x31f886[_0xa3e9('0x39')]);_0x49f669['filters']=_[_0xa3e9('0x3b')](_0x49f669[_0xa3e9('0x38')],_0x49f669[_0xa3e9('0x39')]);_0x1e05e8[_0xa3e9('0x3d')]=_[_0xa3e9('0x3b')](_0x49f669['model'],qs[_0xa3e9('0x3c')](_0x31f886['query'][_0xa3e9('0x3c')]));_0x1e05e8[_0xa3e9('0x3d')]=_0x1e05e8['attributes'][_0xa3e9('0x3e')]?_0x1e05e8[_0xa3e9('0x3d')]:_0x49f669['model'];if(!_0x31f886[_0xa3e9('0x39')]['hasOwnProperty'](_0xa3e9('0x40'))){_0x1e05e8[_0xa3e9('0x22')]=qs[_0xa3e9('0x22')](_0x31f886[_0xa3e9('0x39')][_0xa3e9('0x22')]);_0x1e05e8[_0xa3e9('0x20')]=qs[_0xa3e9('0x20')](_0x31f886[_0xa3e9('0x39')][_0xa3e9('0x20')]);}_0x1e05e8[_0xa3e9('0x60')]=qs[_0xa3e9('0x41')](_0x31f886[_0xa3e9('0x39')][_0xa3e9('0x41')]);_0x1e05e8[_0xa3e9('0x42')]=qs['filters'](_[_0xa3e9('0x44')](_0x31f886[_0xa3e9('0x39')],_0x49f669[_0xa3e9('0x43')]));_0x1e05e8[_0xa3e9('0x42')]['WhatsappQueueId']=_0x3f6964['id'];if(_0x31f886[_0xa3e9('0x39')]['filter']){_0x1e05e8[_0xa3e9('0x42')]=_[_0xa3e9('0x50')](_0x1e05e8[_0xa3e9('0x42')],{'$or':_[_0xa3e9('0x34')](_0x1e05e8[_0xa3e9('0x3d')],function(_0x2e3ae1){var _0x5bf86c={};_0x5bf86c[_0x2e3ae1]={'$like':'%'+_0x31f886[_0xa3e9('0x39')]['filter']+'%'};return _0x5bf86c;})});}_0x1e05e8=_[_0xa3e9('0x50')]({},_0x1e05e8,_0x31f886[_0xa3e9('0x51')]);return db[_0xa3e9('0x61')]['findAll'](_0x1e05e8);}})['then'](function(_0x2412f5){if(_0x2412f5){return db[_0xa3e9('0x62')][_0xa3e9('0x63')]({'where':{'id':_['map'](_0x2412f5,_0xa3e9('0x64')),'role':_0xa3e9('0x65')},'attributes':['id',_0xa3e9('0x31'),_0xa3e9('0x66'),_0xa3e9('0x67'),_0xa3e9('0x68')]});}})[_0xa3e9('0x29')](function(_0x42a8d8){if(_0x42a8d8){return{'count':_0x42a8d8['count'],'rows':_[_0xa3e9('0x34')](_0x42a8d8['rows'],function(_0x3b2ca0){return{'membername':_0x3b2ca0[_0xa3e9('0x31')],'UserId':_0x3b2ca0['id'],'queue_name':_0x18caae[_0xa3e9('0x31')],'WhatsappQueueId':_0x18caae['id'],'interface':util[_0xa3e9('0x69')]('%s/%s','SIP',_0x3b2ca0[_0xa3e9('0x31')]),'penalty':0x0,'paused':_0x3b2ca0[_0xa3e9('0x66')],'createdAt':_0x3b2ca0['createdAt'],'updatedAt':_0x3b2ca0[_0xa3e9('0x67')]};})};}else{return{'count':0x0,'rows':[]};}})['then'](respondWithFilteredResult(_0x17eb28,_0x1e05e8))[_0xa3e9('0x4b')](handleError(_0x17eb28,null));};exports[_0xa3e9('0x6a')]=function(_0x5cea9c,_0x4903aa,_0x4be8cd){var _0x15f713={};var _0x2ff27a={};var _0x38dd7f;var _0x4b5ecd;return db[_0xa3e9('0x47')][_0xa3e9('0x5f')]({'where':{'id':_0x5cea9c['params']['id']}})[_0xa3e9('0x29')](handleEntityNotFound(_0x4903aa,null))[_0xa3e9('0x29')](function(_0x52bd29){if(_0x52bd29){_0x38dd7f=_0x52bd29;_0x2ff27a['model']=_['keys'](db[_0xa3e9('0x6b')][_0xa3e9('0x4e')]);_0x2ff27a[_0xa3e9('0x39')]=_['keys'](_0x5cea9c['query']);_0x2ff27a[_0xa3e9('0x43')]=_['intersection'](_0x2ff27a['model'],_0x2ff27a[_0xa3e9('0x39')]);_0x15f713[_0xa3e9('0x3d')]=_[_0xa3e9('0x3b')](_0x2ff27a[_0xa3e9('0x38')],qs[_0xa3e9('0x3c')](_0x5cea9c['query'][_0xa3e9('0x3c')]));_0x15f713[_0xa3e9('0x3d')]=_0x15f713[_0xa3e9('0x3d')][_0xa3e9('0x3e')]?_0x15f713[_0xa3e9('0x3d')]:_0x2ff27a[_0xa3e9('0x38')];_0x15f713[_0xa3e9('0x60')]=qs[_0xa3e9('0x41')](_0x5cea9c[_0xa3e9('0x39')][_0xa3e9('0x41')]);_0x15f713['where']=qs['filters'](_[_0xa3e9('0x44')](_0x5cea9c[_0xa3e9('0x39')],_0x2ff27a[_0xa3e9('0x43')]));if(_0x5cea9c[_0xa3e9('0x39')][_0xa3e9('0x45')]){_0x15f713['where']=_[_0xa3e9('0x50')](_0x15f713[_0xa3e9('0x42')],{'$or':_[_0xa3e9('0x34')](_0x15f713[_0xa3e9('0x3d')],function(_0xcd16a6){var _0x15d689={};_0x15d689[_0xcd16a6]={'$like':'%'+_0x5cea9c[_0xa3e9('0x39')][_0xa3e9('0x45')]+'%'};return _0x15d689;})});}_0x15f713=_['merge']({},_0x15f713,_0x5cea9c['options']);return _0x38dd7f[_0xa3e9('0x6a')](_0x15f713);}})[_0xa3e9('0x29')](function(_0xebe9fe){if(_0xebe9fe){_0x4b5ecd=_0xebe9fe[_0xa3e9('0x3e')];if(!_0x5cea9c[_0xa3e9('0x39')][_0xa3e9('0x3f')](_0xa3e9('0x40'))){_0x15f713[_0xa3e9('0x22')]=qs[_0xa3e9('0x22')](_0x5cea9c[_0xa3e9('0x39')][_0xa3e9('0x22')]);_0x15f713[_0xa3e9('0x20')]=qs[_0xa3e9('0x20')](_0x5cea9c[_0xa3e9('0x39')][_0xa3e9('0x20')]);}return _0x38dd7f[_0xa3e9('0x6a')](_0x15f713);}})[_0xa3e9('0x29')](function(_0x13459b){if(_0x13459b){return _0x13459b?{'count':_0x4b5ecd,'rows':_0x13459b}:null;}})['then'](respondWithResult(_0x4903aa,null))[_0xa3e9('0x4b')](handleError(_0x4903aa,null));};exports[_0xa3e9('0x6c')]=function(_0x18a880,_0x4257e4,_0x174ebc){var _0x3c4d9b=_0x18a880[_0xa3e9('0x54')]['ids'];return db[_0xa3e9('0x6b')][_0xa3e9('0x49')]({'where':{'id':_0x3c4d9b},'attributes':['id'],'include':[{'model':db['User'],'as':_0xa3e9('0x6d'),'attributes':['id',_0xa3e9('0x31'),'online','voicePause',_0xa3e9('0x6e')],'raw':!![]}]})[_0xa3e9('0x29')](function(_0xee0bb8){if(_0xee0bb8){var _0x7f98dc=_[_0xa3e9('0x6f')](_0xee0bb8,function(_0x913220){var _0x312c8a=_0x913220['get']({'plain':!![]});return _0x312c8a[_0xa3e9('0x6d')];});return db[_0xa3e9('0x47')][_0xa3e9('0x52')]({'where':{'id':_0x18a880['params']['id']}})[_0xa3e9('0x29')](function(_0x42c5da){return db[_0xa3e9('0x70')]['transaction'](function(_0x20ed7b){return _0x42c5da[_0xa3e9('0x6c')](_0x3c4d9b,{'transaction':_0x20ed7b})[_0xa3e9('0x29')](function(){return BPromise[_0xa3e9('0x71')](_0x7f98dc,function(_0x126dd4){return db[_0xa3e9('0x61')]['findOrCreate']({'where':{'UserId':_0x126dd4['id'],'WhatsappQueueId':_0x18a880[_0xa3e9('0x4d')]['id']},'transaction':_0x20ed7b});});})[_0xa3e9('0x29')](function(){_0x7f98dc[_0xa3e9('0x72')](function(_0xac69be){socket[_0xa3e9('0x73')](_0xa3e9('0x74'),{'UserId':_0xac69be['id'],'WhatsappQueueId':_0x42c5da['id']});});});});});}})['then'](respondWithStatusCode(_0x4257e4,null))['catch'](handleError(_0x4257e4,null));};exports[_0xa3e9('0x75')]=function(_0x322a49,_0x7f9a6a,_0x3984f7){return db[_0xa3e9('0x6b')][_0xa3e9('0x49')]({'where':{'id':_0x322a49[_0xa3e9('0x39')]['ids']},'attributes':['id'],'include':[{'model':db[_0xa3e9('0x62')],'as':_0xa3e9('0x6d'),'attributes':['id'],'raw':!![]}]})[_0xa3e9('0x29')](handleEntityNotFound(_0x7f9a6a,null))[_0xa3e9('0x29')](function(_0x53950b){var _0x36cdfe=_['map'](_0x53950b,'id');var _0x456ece=[];var _0x404662=[];var _0x3ecab7=squel['select']();_0x3ecab7[_0xa3e9('0x76')](_0xa3e9('0x77'))[_0xa3e9('0x78')]('team_has_whatsapp_queues','tq')[_0xa3e9('0x79')](_0xa3e9('0x7a'),'ut',_0xa3e9('0x7b'))[_0xa3e9('0x42')](_0xa3e9('0x7c'),_0x322a49[_0xa3e9('0x4d')]['id']);for(var _0x2ba00e=0x0;_0x2ba00e<_0x53950b['length'];_0x2ba00e+=0x1){let _0x5f3e1a=_0x53950b[_0x2ba00e];for(var _0x3b2f97=0x0;_0x3b2f97<_0x5f3e1a[_0xa3e9('0x6d')][_0xa3e9('0x3e')];_0x3b2f97+=0x1){let _0x993a5f=_0x5f3e1a[_0xa3e9('0x6d')][_0x3b2f97];var _0x45f959=_0x3ecab7[_0xa3e9('0x7d')]();_0x45f959[_0xa3e9('0x42')]('ut.UserId\x20=\x20?',_0x993a5f['id']);_0x404662[_0xa3e9('0x7e')](db[_0xa3e9('0x70')][_0xa3e9('0x39')](_0x45f959[_0xa3e9('0x7f')](),{'type':db[_0xa3e9('0x70')][_0xa3e9('0x80')]['SELECT']})['then'](function(_0x598b72){if(_0x598b72[_0xa3e9('0x3e')]===0x1){return _0x993a5f['id'];}else{var _0x8316a3=_[_0xa3e9('0x81')](_['map'](_0x598b72,_0xa3e9('0x82')),function(_0x378966){return _[_0xa3e9('0x83')](_0x36cdfe,_0x378966);});if(_0x8316a3){return _0x993a5f['id'];}}}));}}return BPromise[_0xa3e9('0x84')](_0x404662)[_0xa3e9('0x29')](function(_0x2db90c){_0x456ece=_(_0x456ece)[_0xa3e9('0x85')](_0x2db90c)[_0xa3e9('0x86')]()[_0xa3e9('0x87')]();return db[_0xa3e9('0x47')][_0xa3e9('0x52')]({'where':{'id':_0x322a49['params']['id']}})[_0xa3e9('0x29')](function(_0x250b67){return db['sequelize']['transaction'](function(_0x2682e8){return _0x250b67[_0xa3e9('0x75')](_0x322a49[_0xa3e9('0x39')]['ids'],{'transaction':_0x2682e8})[_0xa3e9('0x29')](function(){if(!_[_0xa3e9('0x88')](_0x456ece)){return _0x250b67[_0xa3e9('0x89')](_0x456ece,{'transaction':_0x2682e8});}})[_0xa3e9('0x29')](function(){_0x456ece[_0xa3e9('0x72')](function(_0x4fe77d){socket['emit'](_0xa3e9('0x8a'),{'UserId':_0x4fe77d,'WhatsappQueueId':_0x250b67['id']});});});});});});})[_0xa3e9('0x29')](respondWithStatusCode(_0x7f9a6a,null))[_0xa3e9('0x4b')](handleError(_0x7f9a6a,null));};exports[_0xa3e9('0x8b')]=function(_0x661b3b,_0x1f04b1,_0x212662){return db['WhatsappQueue']['find']({'where':{'id':_0x661b3b[_0xa3e9('0x4d')]['id']}})['then'](handleEntityNotFound(_0x1f04b1,null))[_0xa3e9('0x29')](function(_0x1d30ac){if(_0x1d30ac){return _0x1d30ac[_0xa3e9('0x8b')](_0x661b3b[_0xa3e9('0x54')][_0xa3e9('0x8c')],_[_0xa3e9('0x8d')](_0x661b3b[_0xa3e9('0x54')],[_0xa3e9('0x8c'),'id'])||{})[_0xa3e9('0x8e')](function(_0x5826df){for(var _0x1c758b=0x0;_0x1c758b<_0x661b3b[_0xa3e9('0x54')]['ids']['length'];_0x1c758b+=0x1){socket[_0xa3e9('0x73')]('userWhatsappQueue:save',{'UserId':Number(_0x661b3b[_0xa3e9('0x54')][_0xa3e9('0x8c')][_0x1c758b]),'WhatsappQueueId':Number(_0x661b3b[_0xa3e9('0x4d')]['id'])});}return _0x5826df;});}})[_0xa3e9('0x29')](respondWithResult(_0x1f04b1,null))['catch'](handleError(_0x1f04b1,null));};exports[_0xa3e9('0x89')]=function(_0x457c04,_0x37176d,_0x5271c1){return db[_0xa3e9('0x47')][_0xa3e9('0x52')]({'where':{'id':_0x457c04[_0xa3e9('0x4d')]['id']}})['then'](handleEntityNotFound(_0x37176d,null))[_0xa3e9('0x29')](function(_0x19a197){if(_0x19a197){return _0x19a197[_0xa3e9('0x89')](_0x457c04[_0xa3e9('0x39')][_0xa3e9('0x8c')])[_0xa3e9('0x29')](function(){if(_[_0xa3e9('0x8f')](_0x457c04[_0xa3e9('0x39')][_0xa3e9('0x8c')])){for(var _0x120ee0=0x0;_0x120ee0<_0x457c04[_0xa3e9('0x39')][_0xa3e9('0x8c')][_0xa3e9('0x3e')];_0x120ee0+=0x1){socket[_0xa3e9('0x73')](_0xa3e9('0x8a'),{'UserId':Number(_0x457c04['query'][_0xa3e9('0x8c')][_0x120ee0]),'WhatsappQueueId':Number(_0x457c04['params']['id'])});}}else{socket[_0xa3e9('0x73')](_0xa3e9('0x8a'),{'UserId':Number(_0x457c04[_0xa3e9('0x39')][_0xa3e9('0x8c')]),'WhatsappQueueId':Number(_0x457c04[_0xa3e9('0x4d')]['id'])});}});}})['then'](respondWithStatusCode(_0x37176d,null))['catch'](handleError(_0x37176d,null));};exports[_0xa3e9('0x90')]=function(_0x2434cf,_0x2ed9f3,_0x257b0a){var _0x3fa2be={};var _0x147f1a={};var _0x201863;var _0x59b95a;return db[_0xa3e9('0x47')]['findOne']({'where':{'id':_0x2434cf[_0xa3e9('0x4d')]['id']}})[_0xa3e9('0x29')](handleEntityNotFound(_0x2ed9f3,null))['then'](function(_0x570df2){if(_0x570df2){_0x201863=_0x570df2;_0x147f1a['model']=_[_0xa3e9('0x3a')](db[_0xa3e9('0x62')][_0xa3e9('0x4e')]);_0x147f1a[_0xa3e9('0x39')]=_[_0xa3e9('0x3a')](_0x2434cf['query']);_0x147f1a['filters']=_[_0xa3e9('0x3b')](_0x147f1a[_0xa3e9('0x38')],_0x147f1a[_0xa3e9('0x39')]);_0x3fa2be[_0xa3e9('0x3d')]=_[_0xa3e9('0x3b')](_0x147f1a[_0xa3e9('0x38')],qs[_0xa3e9('0x3c')](_0x2434cf[_0xa3e9('0x39')]['fields']));_0x3fa2be['attributes']=_0x3fa2be[_0xa3e9('0x3d')][_0xa3e9('0x3e')]?_0x3fa2be[_0xa3e9('0x3d')]:_0x147f1a[_0xa3e9('0x38')];_0x3fa2be['order']=qs[_0xa3e9('0x41')](_0x2434cf[_0xa3e9('0x39')][_0xa3e9('0x41')]);_0x3fa2be[_0xa3e9('0x42')]=qs[_0xa3e9('0x43')](_['pick'](_0x2434cf[_0xa3e9('0x39')],_0x147f1a[_0xa3e9('0x43')]));if(_0x2434cf[_0xa3e9('0x39')][_0xa3e9('0x45')]){_0x3fa2be[_0xa3e9('0x42')]=_['merge'](_0x3fa2be[_0xa3e9('0x42')],{'$or':_['map'](_0x3fa2be['attributes'],function(_0x2571ce){var _0x56cf45={};_0x56cf45[_0x2571ce]={'$like':'%'+_0x2434cf[_0xa3e9('0x39')][_0xa3e9('0x45')]+'%'};return _0x56cf45;})});}_0x3fa2be=_[_0xa3e9('0x50')]({},_0x3fa2be,_0x2434cf[_0xa3e9('0x51')]);return _0x201863['getAgents'](_0x3fa2be);}})[_0xa3e9('0x29')](function(_0x1e76ae){if(_0x1e76ae){_0x59b95a=_0x1e76ae[_0xa3e9('0x3e')];if(!_0x2434cf[_0xa3e9('0x39')][_0xa3e9('0x3f')](_0xa3e9('0x40'))){_0x3fa2be[_0xa3e9('0x22')]=qs[_0xa3e9('0x22')](_0x2434cf[_0xa3e9('0x39')][_0xa3e9('0x22')]);_0x3fa2be[_0xa3e9('0x20')]=qs[_0xa3e9('0x20')](_0x2434cf[_0xa3e9('0x39')]['offset']);}return _0x201863[_0xa3e9('0x90')](_0x3fa2be);}})[_0xa3e9('0x29')](function(_0x9690ef){if(_0x9690ef){return _0x9690ef?{'count':_0x59b95a,'rows':_0x9690ef}:null;}})[_0xa3e9('0x29')](respondWithResult(_0x2ed9f3,null))[_0xa3e9('0x4b')](handleError(_0x2ed9f3,null));};
\ No newline at end of file