Built motion from commit (unavailable).|2.5.22
[motion2.git] / server / api / whatsappQueue / whatsappQueue.controller.js
index 81d22e1..7d96e77 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x77d2=['userProfileId','autoAssociation','UserProfileResource','body','describe','getMembers','findOne','UserWhatsappQueue','length','User','UserId','agent','whatsappPause','updatedAt','createdAt','rows','format','%s/%s','getTeams','Team','pick','addTeams','ids','findAll','Agents','online','voicePause','flatMap','sequelize','each','findOrCreate','forEach','emit','userWhatsappQueue:save','removeTeams','select','field','from','team_has_whatsapp_queues','join','user_has_teams','WhatsappQueueId\x20=\x20?','clone','ut.UserId\x20=\x20?','toString','every','TeamId','includes','all','union','compact','value','transaction','isEmpty','removeAgents','addAgents','omit','spread','userWhatsappQueue:remove','order','html-pdf','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','mustache','util','path','sox','to-csv','ejs','lodash','squel','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','redis','defaults','socket.io-emitter','./whatsappQueue.socket','register','sendStatus','status','json','count','offset','limit','set','apply','reject','save','update','then','destroy','get','end','error','stack','name','send','index','map','rawAttributes','fieldName','key','model','filters','intersection','attributes','fields','query','hasOwnProperty','nolimit','sort','where','filter','merge','type','VIRTUAL','options','WhatsappQueue','include','catch','show','params','keys','find','create','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','WhatsappQueues','UserProfileSection'];(function(_0x673722,_0x275d7e){var _0x21249c=function(_0x25b4e7){while(--_0x25b4e7){_0x673722['push'](_0x673722['shift']());}};_0x21249c(++_0x275d7e);}(_0x77d2,0xcc));var _0x277d=function(_0x4e676e,_0x2a7c6d){_0x4e676e=_0x4e676e-0x0;var _0x336a3c=_0x77d2[_0x4e676e];return _0x336a3c;};'use strict';var pdf=require(_0x277d('0x0'));var emlformat=require(_0x277d('0x1'));var rimraf=require(_0x277d('0x2'));var zipdir=require(_0x277d('0x3'));var jsonpatch=require(_0x277d('0x4'));var rp=require(_0x277d('0x5'));var moment=require(_0x277d('0x6'));var BPromise=require('bluebird');var Mustache=require(_0x277d('0x7'));var util=require(_0x277d('0x8'));var path=require(_0x277d('0x9'));var sox=require(_0x277d('0xa'));var csv=require(_0x277d('0xb'));var ejs=require(_0x277d('0xc'));var fs=require('fs');var _=require(_0x277d('0xd'));var squel=require(_0x277d('0xe'));var crypto=require('crypto');var jsforce=require('jsforce');var deskjs=require(_0x277d('0xf'));var toCsv=require(_0x277d('0xb'));var querystring=require(_0x277d('0x10'));var Papa=require(_0x277d('0x11'));var Redis=require(_0x277d('0x12'));var authService=require(_0x277d('0x13'));var qs=require(_0x277d('0x14'));var as=require(_0x277d('0x15'));var hardwareService=require(_0x277d('0x16'));var logger=require(_0x277d('0x17'))(_0x277d('0x18'));var utils=require(_0x277d('0x19'));var config=require(_0x277d('0x1a'));var db=require('../../mysqldb')['db'];config[_0x277d('0x1b')]=_[_0x277d('0x1c')](config[_0x277d('0x1b')],{'host':'localhost','port':0x18eb});var socket=require(_0x277d('0x1d'))(new Redis(config['redis']));require(_0x277d('0x1e'))[_0x277d('0x1f')](socket);function respondWithStatusCode(_0x3c464f,_0x3d320b){_0x3d320b=_0x3d320b||0xcc;return function(_0x212c6b){if(_0x212c6b){return _0x3c464f[_0x277d('0x20')](_0x3d320b);}return _0x3c464f[_0x277d('0x21')](_0x3d320b)['end']();};}function respondWithResult(_0x3f8bca,_0x1b5b47){_0x1b5b47=_0x1b5b47||0xc8;return function(_0x59f606){if(_0x59f606){return _0x3f8bca['status'](_0x1b5b47)[_0x277d('0x22')](_0x59f606);}};}function respondWithFilteredResult(_0x2b05be,_0x3da173){return function(_0x5c18e8){if(_0x5c18e8){var _0x44ccee=_0x5c18e8[_0x277d('0x23')],_0x3543f7=_0x3da173[_0x277d('0x24')],_0x30ca76=_0x3da173[_0x277d('0x24')]+_0x3da173[_0x277d('0x25')],_0x11a692;if(_0x30ca76>=_0x44ccee){_0x30ca76=_0x44ccee;_0x11a692=0xc8;}else{_0x11a692=0xce;}_0x2b05be[_0x277d('0x21')](_0x11a692);return _0x2b05be[_0x277d('0x26')]('Content-Range',_0x3543f7+'-'+_0x30ca76+'/'+_0x44ccee)['json'](_0x5c18e8);}return null;};}function patchUpdates(_0xb5fcd1){return function(_0x488ecf){try{jsonpatch[_0x277d('0x27')](_0x488ecf,_0xb5fcd1,!![]);}catch(_0x3eb675){return BPromise[_0x277d('0x28')](_0x3eb675);}return _0x488ecf[_0x277d('0x29')]();};}function saveUpdates(_0xa6725d,_0x322648){return function(_0x4d3367){if(_0x4d3367){return _0x4d3367[_0x277d('0x2a')](_0xa6725d)[_0x277d('0x2b')](function(_0x12f773){return _0x12f773;});}return null;};}function removeEntity(_0x58016e,_0x3844c6){return function(_0x451553){if(_0x451553){return _0x451553[_0x277d('0x2c')]()[_0x277d('0x2b')](function(){var _0x5fb3ea=_0x451553[_0x277d('0x2d')]({'plain':!![]});var _0x1aa87d='WhatsappQueues';return db['UserProfileResource'][_0x277d('0x2c')]({'where':{'type':_0x1aa87d,'resourceId':_0x5fb3ea['id']}})[_0x277d('0x2b')](function(){return _0x451553;});})[_0x277d('0x2b')](function(){_0x58016e[_0x277d('0x21')](0xcc)[_0x277d('0x2e')]();});}};}function handleEntityNotFound(_0x404496,_0x121ee9){return function(_0x365cc1){if(!_0x365cc1){_0x404496[_0x277d('0x20')](0x194);}return _0x365cc1;};}function handleError(_0xbf5e9b,_0x442b1b){_0x442b1b=_0x442b1b||0x1f4;return function(_0x2f3317){logger[_0x277d('0x2f')](_0x2f3317[_0x277d('0x30')]);if(_0x2f3317[_0x277d('0x31')]){delete _0x2f3317[_0x277d('0x31')];}_0xbf5e9b['status'](_0x442b1b)[_0x277d('0x32')](_0x2f3317);};}exports[_0x277d('0x33')]=function(_0x29cef9,_0x348f12){var _0x2233de={},_0x279115={},_0xf0d0f8={'count':0x0,'rows':[]};var _0x5ec257=_[_0x277d('0x34')](db['WhatsappQueue'][_0x277d('0x35')],function(_0x58ca15){return{'name':_0x58ca15[_0x277d('0x36')],'type':_0x58ca15['type'][_0x277d('0x37')]};});_0x279115[_0x277d('0x38')]=_['map'](_0x5ec257,_0x277d('0x31'));_0x279115['query']=_['keys'](_0x29cef9['query']);_0x279115[_0x277d('0x39')]=_[_0x277d('0x3a')](_0x279115[_0x277d('0x38')],_0x279115['query']);_0x2233de[_0x277d('0x3b')]=_[_0x277d('0x3a')](_0x279115['model'],qs[_0x277d('0x3c')](_0x29cef9[_0x277d('0x3d')][_0x277d('0x3c')]));_0x2233de['attributes']=_0x2233de[_0x277d('0x3b')]['length']?_0x2233de[_0x277d('0x3b')]:_0x279115['model'];if(!_0x29cef9[_0x277d('0x3d')][_0x277d('0x3e')](_0x277d('0x3f'))){_0x2233de[_0x277d('0x25')]=qs['limit'](_0x29cef9[_0x277d('0x3d')]['limit']);_0x2233de[_0x277d('0x24')]=qs[_0x277d('0x24')](_0x29cef9[_0x277d('0x3d')][_0x277d('0x24')]);}_0x2233de['order']=qs[_0x277d('0x40')](_0x29cef9[_0x277d('0x3d')][_0x277d('0x40')]);_0x2233de[_0x277d('0x41')]=qs[_0x277d('0x39')](_['pick'](_0x29cef9[_0x277d('0x3d')],_0x279115[_0x277d('0x39')]),_0x5ec257);if(_0x29cef9[_0x277d('0x3d')][_0x277d('0x42')]){_0x2233de['where']=_[_0x277d('0x43')](_0x2233de[_0x277d('0x41')],{'$or':_[_0x277d('0x34')](_0x5ec257,function(_0x29da5b){if(_0x29da5b[_0x277d('0x44')]!==_0x277d('0x45')){var _0x43b15c={};_0x43b15c[_0x29da5b[_0x277d('0x31')]]={'$like':'%'+_0x29cef9[_0x277d('0x3d')][_0x277d('0x42')]+'%'};return _0x43b15c;}})});}_0x2233de=_['merge']({},_0x2233de,_0x29cef9[_0x277d('0x46')]);var _0x2a6831={'where':_0x2233de['where']};return db[_0x277d('0x47')][_0x277d('0x23')](_0x2a6831)[_0x277d('0x2b')](function(_0x3e9a9f){_0xf0d0f8['count']=_0x3e9a9f;if(_0x29cef9[_0x277d('0x3d')]['includeAll']){_0x2233de[_0x277d('0x48')]=[{'all':!![]}];}return db[_0x277d('0x47')]['findAll'](_0x2233de);})[_0x277d('0x2b')](function(_0x36a293){_0xf0d0f8['rows']=_0x36a293;return _0xf0d0f8;})[_0x277d('0x2b')](respondWithFilteredResult(_0x348f12,_0x2233de))[_0x277d('0x49')](handleError(_0x348f12,null));};exports[_0x277d('0x4a')]=function(_0x3210f6,_0x151b27){var _0x2d74a6={'raw':!![],'where':{'id':_0x3210f6[_0x277d('0x4b')]['id']}},_0x3f6853={};_0x3f6853[_0x277d('0x38')]=_['keys'](db[_0x277d('0x47')][_0x277d('0x35')]);_0x3f6853['query']=_[_0x277d('0x4c')](_0x3210f6[_0x277d('0x3d')]);_0x3f6853[_0x277d('0x39')]=_[_0x277d('0x3a')](_0x3f6853[_0x277d('0x38')],_0x3f6853[_0x277d('0x3d')]);_0x2d74a6[_0x277d('0x3b')]=_['intersection'](_0x3f6853[_0x277d('0x38')],qs[_0x277d('0x3c')](_0x3210f6[_0x277d('0x3d')]['fields']));_0x2d74a6[_0x277d('0x3b')]=_0x2d74a6['attributes']['length']?_0x2d74a6[_0x277d('0x3b')]:_0x3f6853[_0x277d('0x38')];if(_0x3210f6['query']['includeAll']){_0x2d74a6[_0x277d('0x48')]=[{'all':!![]}];}_0x2d74a6=_['merge']({},_0x2d74a6,_0x3210f6['options']);return db['WhatsappQueue'][_0x277d('0x4d')](_0x2d74a6)[_0x277d('0x2b')](handleEntityNotFound(_0x151b27,null))[_0x277d('0x2b')](respondWithResult(_0x151b27,null))[_0x277d('0x49')](handleError(_0x151b27,null));};exports[_0x277d('0x4e')]=function(_0x2732d5,_0x8aa6fe){return db['WhatsappQueue'][_0x277d('0x4e')](_0x2732d5['body'],{})[_0x277d('0x2b')](function(_0x58b462){var _0x4924e5=_0x2732d5[_0x277d('0x4f')][_0x277d('0x2d')]({'plain':!![]});if(!_0x4924e5)throw new Error(_0x277d('0x50'));if(_0x4924e5[_0x277d('0x51')]===_0x277d('0x4f')){var _0x28f2d8=_0x58b462[_0x277d('0x2d')]({'plain':!![]});var _0x11662d=_0x277d('0x52');return db[_0x277d('0x53')][_0x277d('0x4d')]({'where':{'name':_0x11662d,'userProfileId':_0x4924e5[_0x277d('0x54')]},'raw':!![]})[_0x277d('0x2b')](function(_0x3729b5){if(_0x3729b5&&_0x3729b5[_0x277d('0x55')]===0x0){return db[_0x277d('0x56')]['create']({'name':_0x28f2d8[_0x277d('0x31')],'resourceId':_0x28f2d8['id'],'type':_0x3729b5[_0x277d('0x31')],'sectionId':_0x3729b5['id']},{})[_0x277d('0x2b')](function(){return _0x58b462;});}else{return _0x58b462;}})[_0x277d('0x49')](function(_0x1ba706){logger[_0x277d('0x2f')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x1ba706);throw _0x1ba706;});}return _0x58b462;})[_0x277d('0x2b')](respondWithResult(_0x8aa6fe,0xc9))[_0x277d('0x49')](handleError(_0x8aa6fe,null));};exports[_0x277d('0x2a')]=function(_0x26adc2,_0x311a25){if(_0x26adc2[_0x277d('0x57')]['id']){delete _0x26adc2[_0x277d('0x57')]['id'];}return db['WhatsappQueue'][_0x277d('0x4d')]({'where':{'id':_0x26adc2[_0x277d('0x4b')]['id']}})[_0x277d('0x2b')](handleEntityNotFound(_0x311a25,null))[_0x277d('0x2b')](saveUpdates(_0x26adc2[_0x277d('0x57')],null))['then'](respondWithResult(_0x311a25,null))[_0x277d('0x49')](handleError(_0x311a25,null));};exports[_0x277d('0x2c')]=function(_0x250fb5,_0x5c1ab0){return db[_0x277d('0x47')][_0x277d('0x4d')]({'where':{'id':_0x250fb5[_0x277d('0x4b')]['id']}})['then'](handleEntityNotFound(_0x5c1ab0,null))['then'](removeEntity(_0x5c1ab0,null))['catch'](handleError(_0x5c1ab0,null));};exports[_0x277d('0x58')]=function(_0x43818e,_0x4339d2){return db['WhatsappQueue'][_0x277d('0x58')]()[_0x277d('0x2b')](respondWithResult(_0x4339d2,null))[_0x277d('0x49')](handleError(_0x4339d2,null));};exports[_0x277d('0x59')]=function(_0x2225d2,_0x2eb2fa,_0x40b818){var _0xef0bc8={'raw':!![],'where':{}},_0x460b28={},_0x4b9dd5;return db[_0x277d('0x47')][_0x277d('0x5a')]({'where':{'id':_0x2225d2[_0x277d('0x4b')]['id']}})[_0x277d('0x2b')](handleEntityNotFound(_0x2eb2fa,null))['then'](function(_0x28d07d){if(_0x28d07d){_0x4b9dd5=_0x28d07d[_0x277d('0x2d')]({'plain':!![]});_0x460b28[_0x277d('0x38')]=_[_0x277d('0x4c')](db[_0x277d('0x5b')][_0x277d('0x35')]);_0x460b28[_0x277d('0x3d')]=_[_0x277d('0x4c')](_0x2225d2[_0x277d('0x3d')]);_0x460b28[_0x277d('0x39')]=_[_0x277d('0x3a')](_0x460b28[_0x277d('0x38')],_0x460b28[_0x277d('0x3d')]);_0xef0bc8[_0x277d('0x3b')]=_[_0x277d('0x3a')](_0x460b28[_0x277d('0x38')],qs[_0x277d('0x3c')](_0x2225d2[_0x277d('0x3d')][_0x277d('0x3c')]));_0xef0bc8[_0x277d('0x3b')]=_0xef0bc8[_0x277d('0x3b')][_0x277d('0x5c')]?_0xef0bc8[_0x277d('0x3b')]:_0x460b28[_0x277d('0x38')];if(!_0x2225d2[_0x277d('0x3d')][_0x277d('0x3e')](_0x277d('0x3f'))){_0xef0bc8['limit']=qs['limit'](_0x2225d2[_0x277d('0x3d')]['limit']);_0xef0bc8[_0x277d('0x24')]=qs[_0x277d('0x24')](_0x2225d2[_0x277d('0x3d')][_0x277d('0x24')]);}_0xef0bc8['order']=qs[_0x277d('0x40')](_0x2225d2[_0x277d('0x3d')][_0x277d('0x40')]);_0xef0bc8[_0x277d('0x41')]=qs[_0x277d('0x39')](_['pick'](_0x2225d2['query'],_0x460b28['filters']));_0xef0bc8[_0x277d('0x41')]['WhatsappQueueId']=_0x28d07d['id'];if(_0x2225d2[_0x277d('0x3d')][_0x277d('0x42')]){_0xef0bc8[_0x277d('0x41')]=_[_0x277d('0x43')](_0xef0bc8[_0x277d('0x41')],{'$or':_[_0x277d('0x34')](_0xef0bc8['attributes'],function(_0x5c57f3){var _0x4470c6={};_0x4470c6[_0x5c57f3]={'$like':'%'+_0x2225d2[_0x277d('0x3d')][_0x277d('0x42')]+'%'};return _0x4470c6;})});}_0xef0bc8=_[_0x277d('0x43')]({},_0xef0bc8,_0x2225d2[_0x277d('0x46')]);return db[_0x277d('0x5b')]['findAll'](_0xef0bc8);}})['then'](function(_0x3eef45){if(_0x3eef45){return db[_0x277d('0x5d')]['findAndCountAll']({'where':{'id':_[_0x277d('0x34')](_0x3eef45,_0x277d('0x5e')),'role':_0x277d('0x5f')},'attributes':['id',_0x277d('0x31'),_0x277d('0x60'),_0x277d('0x61'),_0x277d('0x62')]});}})[_0x277d('0x2b')](function(_0x3cbd36){if(_0x3cbd36){return{'count':_0x3cbd36['count'],'rows':_[_0x277d('0x34')](_0x3cbd36[_0x277d('0x63')],function(_0x5d0657){return{'membername':_0x5d0657['name'],'UserId':_0x5d0657['id'],'queue_name':_0x4b9dd5[_0x277d('0x31')],'WhatsappQueueId':_0x4b9dd5['id'],'interface':util[_0x277d('0x64')](_0x277d('0x65'),'SIP',_0x5d0657[_0x277d('0x31')]),'penalty':0x0,'paused':_0x5d0657[_0x277d('0x60')],'createdAt':_0x5d0657[_0x277d('0x62')],'updatedAt':_0x5d0657[_0x277d('0x61')]};})};}else{return{'count':0x0,'rows':[]};}})['then'](respondWithFilteredResult(_0x2eb2fa,_0xef0bc8))[_0x277d('0x49')](handleError(_0x2eb2fa,null));};exports[_0x277d('0x66')]=function(_0x1bcacb,_0x172750,_0x521853){var _0xd07d6f={};var _0x47628d={};var _0x3a6d58;var _0xd89510;return db[_0x277d('0x47')][_0x277d('0x5a')]({'where':{'id':_0x1bcacb[_0x277d('0x4b')]['id']}})[_0x277d('0x2b')](handleEntityNotFound(_0x172750,null))[_0x277d('0x2b')](function(_0x14b559){if(_0x14b559){_0x3a6d58=_0x14b559;_0x47628d[_0x277d('0x38')]=_[_0x277d('0x4c')](db[_0x277d('0x67')]['rawAttributes']);_0x47628d['query']=_[_0x277d('0x4c')](_0x1bcacb[_0x277d('0x3d')]);_0x47628d[_0x277d('0x39')]=_[_0x277d('0x3a')](_0x47628d[_0x277d('0x38')],_0x47628d['query']);_0xd07d6f[_0x277d('0x3b')]=_[_0x277d('0x3a')](_0x47628d[_0x277d('0x38')],qs[_0x277d('0x3c')](_0x1bcacb[_0x277d('0x3d')][_0x277d('0x3c')]));_0xd07d6f[_0x277d('0x3b')]=_0xd07d6f[_0x277d('0x3b')][_0x277d('0x5c')]?_0xd07d6f[_0x277d('0x3b')]:_0x47628d[_0x277d('0x38')];_0xd07d6f['order']=qs[_0x277d('0x40')](_0x1bcacb['query'][_0x277d('0x40')]);_0xd07d6f[_0x277d('0x41')]=qs['filters'](_[_0x277d('0x68')](_0x1bcacb[_0x277d('0x3d')],_0x47628d['filters']));if(_0x1bcacb[_0x277d('0x3d')][_0x277d('0x42')]){_0xd07d6f['where']=_[_0x277d('0x43')](_0xd07d6f[_0x277d('0x41')],{'$or':_[_0x277d('0x34')](_0xd07d6f[_0x277d('0x3b')],function(_0x38e25d){var _0x15adb3={};_0x15adb3[_0x38e25d]={'$like':'%'+_0x1bcacb[_0x277d('0x3d')][_0x277d('0x42')]+'%'};return _0x15adb3;})});}_0xd07d6f=_[_0x277d('0x43')]({},_0xd07d6f,_0x1bcacb['options']);return _0x3a6d58[_0x277d('0x66')](_0xd07d6f);}})[_0x277d('0x2b')](function(_0x410337){if(_0x410337){_0xd89510=_0x410337[_0x277d('0x5c')];if(!_0x1bcacb[_0x277d('0x3d')][_0x277d('0x3e')]('nolimit')){_0xd07d6f['limit']=qs[_0x277d('0x25')](_0x1bcacb[_0x277d('0x3d')][_0x277d('0x25')]);_0xd07d6f['offset']=qs['offset'](_0x1bcacb[_0x277d('0x3d')][_0x277d('0x24')]);}return _0x3a6d58[_0x277d('0x66')](_0xd07d6f);}})[_0x277d('0x2b')](function(_0x2c6f36){if(_0x2c6f36){return _0x2c6f36?{'count':_0xd89510,'rows':_0x2c6f36}:null;}})['then'](respondWithResult(_0x172750,null))['catch'](handleError(_0x172750,null));};exports[_0x277d('0x69')]=function(_0x37a170,_0x5aaf40,_0x2fc948){var _0x999e6d=_0x37a170[_0x277d('0x57')][_0x277d('0x6a')];return db[_0x277d('0x67')][_0x277d('0x6b')]({'where':{'id':_0x999e6d},'attributes':['id'],'include':[{'model':db[_0x277d('0x5d')],'as':_0x277d('0x6c'),'attributes':['id',_0x277d('0x31'),_0x277d('0x6d'),_0x277d('0x6e'),'interface'],'raw':!![]}]})['then'](function(_0x39ed87){if(_0x39ed87){var _0xe61947=_[_0x277d('0x6f')](_0x39ed87,function(_0x17b0d0){var _0x10e5ff=_0x17b0d0['get']({'plain':!![]});return _0x10e5ff[_0x277d('0x6c')];});return db['WhatsappQueue'][_0x277d('0x4d')]({'where':{'id':_0x37a170[_0x277d('0x4b')]['id']}})[_0x277d('0x2b')](function(_0x5f3e3b){return db[_0x277d('0x70')]['transaction'](function(_0x14fe6c){return _0x5f3e3b['addTeams'](_0x999e6d,{'transaction':_0x14fe6c})[_0x277d('0x2b')](function(){return BPromise[_0x277d('0x71')](_0xe61947,function(_0x430ced){return db[_0x277d('0x5b')][_0x277d('0x72')]({'where':{'UserId':_0x430ced['id'],'WhatsappQueueId':_0x37a170[_0x277d('0x4b')]['id']},'transaction':_0x14fe6c});});})[_0x277d('0x2b')](function(){_0xe61947[_0x277d('0x73')](function(_0x36245b){socket[_0x277d('0x74')](_0x277d('0x75'),{'UserId':_0x36245b['id'],'WhatsappQueueId':_0x5f3e3b['id']});});});});});}})[_0x277d('0x2b')](respondWithStatusCode(_0x5aaf40,null))[_0x277d('0x49')](handleError(_0x5aaf40,null));};exports[_0x277d('0x76')]=function(_0x57b0c4,_0x2c6975,_0x3646f2){return db['Team'][_0x277d('0x6b')]({'where':{'id':_0x57b0c4['query'][_0x277d('0x6a')]},'attributes':['id'],'include':[{'model':db[_0x277d('0x5d')],'as':_0x277d('0x6c'),'attributes':['id'],'raw':!![]}]})[_0x277d('0x2b')](handleEntityNotFound(_0x2c6975,null))[_0x277d('0x2b')](function(_0x4af720){var _0x337d0f=_['map'](_0x4af720,'id');var _0x3e781f=[];var _0x4b578a=[];var _0x40e7ab=squel[_0x277d('0x77')]();_0x40e7ab[_0x277d('0x78')]('tq.TeamId')[_0x277d('0x79')](_0x277d('0x7a'),'tq')[_0x277d('0x7b')](_0x277d('0x7c'),'ut','ut.TeamId\x20=\x20tq.TeamId')['where'](_0x277d('0x7d'),_0x57b0c4[_0x277d('0x4b')]['id']);for(var _0x4f5896=0x0;_0x4f5896<_0x4af720[_0x277d('0x5c')];_0x4f5896+=0x1){let _0x2aeffc=_0x4af720[_0x4f5896];for(var _0x36fe55=0x0;_0x36fe55<_0x2aeffc[_0x277d('0x6c')][_0x277d('0x5c')];_0x36fe55+=0x1){let _0x2e9930=_0x2aeffc[_0x277d('0x6c')][_0x36fe55];var _0x1ed57d=_0x40e7ab[_0x277d('0x7e')]();_0x1ed57d[_0x277d('0x41')](_0x277d('0x7f'),_0x2e9930['id']);_0x4b578a['push'](db[_0x277d('0x70')][_0x277d('0x3d')](_0x1ed57d[_0x277d('0x80')](),{'type':db[_0x277d('0x70')]['QueryTypes']['SELECT']})[_0x277d('0x2b')](function(_0x56f3c7){if(_0x56f3c7[_0x277d('0x5c')]===0x1){return _0x2e9930['id'];}else{var _0x4421b5=_[_0x277d('0x81')](_[_0x277d('0x34')](_0x56f3c7,_0x277d('0x82')),function(_0x29cf5c){return _[_0x277d('0x83')](_0x337d0f,_0x29cf5c);});if(_0x4421b5){return _0x2e9930['id'];}}}));}}return BPromise[_0x277d('0x84')](_0x4b578a)[_0x277d('0x2b')](function(_0x43c1ad){_0x3e781f=_(_0x3e781f)[_0x277d('0x85')](_0x43c1ad)[_0x277d('0x86')]()[_0x277d('0x87')]();return db[_0x277d('0x47')][_0x277d('0x4d')]({'where':{'id':_0x57b0c4[_0x277d('0x4b')]['id']}})['then'](function(_0x2cb65b){return db[_0x277d('0x70')][_0x277d('0x88')](function(_0x3c7cb5){return _0x2cb65b[_0x277d('0x76')](_0x57b0c4[_0x277d('0x3d')][_0x277d('0x6a')],{'transaction':_0x3c7cb5})[_0x277d('0x2b')](function(){if(!_[_0x277d('0x89')](_0x3e781f)){return _0x2cb65b[_0x277d('0x8a')](_0x3e781f,{'transaction':_0x3c7cb5});}})['then'](function(){_0x3e781f[_0x277d('0x73')](function(_0x5b1a17){socket[_0x277d('0x74')]('userWhatsappQueue:remove',{'UserId':_0x5b1a17,'WhatsappQueueId':_0x2cb65b['id']});});});});});});})[_0x277d('0x2b')](respondWithStatusCode(_0x2c6975,null))[_0x277d('0x49')](handleError(_0x2c6975,null));};exports['addAgents']=function(_0x24cdd7,_0x1c43e7,_0x2b54ed){return db[_0x277d('0x47')][_0x277d('0x4d')]({'where':{'id':_0x24cdd7[_0x277d('0x4b')]['id']}})[_0x277d('0x2b')](handleEntityNotFound(_0x1c43e7,null))['then'](function(_0x3ea42a){if(_0x3ea42a){return _0x3ea42a[_0x277d('0x8b')](_0x24cdd7[_0x277d('0x57')][_0x277d('0x6a')],_[_0x277d('0x8c')](_0x24cdd7[_0x277d('0x57')],[_0x277d('0x6a'),'id'])||{})[_0x277d('0x8d')](function(_0x468c10){for(var _0x5880e0=0x0;_0x5880e0<_0x24cdd7[_0x277d('0x57')][_0x277d('0x6a')][_0x277d('0x5c')];_0x5880e0+=0x1){socket[_0x277d('0x74')]('userWhatsappQueue:save',{'UserId':_0x24cdd7[_0x277d('0x57')][_0x277d('0x6a')][_0x5880e0],'WhatsappQueueId':_0x24cdd7[_0x277d('0x4b')]['id']});}return _0x468c10;});}})[_0x277d('0x2b')](respondWithResult(_0x1c43e7,null))[_0x277d('0x49')](handleError(_0x1c43e7,null));};exports['removeAgents']=function(_0x51e32d,_0x14754a,_0x4c4e22){return db['WhatsappQueue'][_0x277d('0x4d')]({'where':{'id':_0x51e32d[_0x277d('0x4b')]['id']}})['then'](handleEntityNotFound(_0x14754a,null))['then'](function(_0x38c92c){if(_0x38c92c){return _0x38c92c['removeAgents'](_0x51e32d[_0x277d('0x3d')][_0x277d('0x6a')])['then'](function(){if(_['isArray'](_0x51e32d[_0x277d('0x3d')][_0x277d('0x6a')])){for(var _0x189ad2=0x0;_0x189ad2<_0x51e32d['query'][_0x277d('0x6a')][_0x277d('0x5c')];_0x189ad2+=0x1){socket[_0x277d('0x74')](_0x277d('0x8e'),{'UserId':Number(_0x51e32d['query'][_0x277d('0x6a')][_0x189ad2]),'WhatsappQueueId':Number(_0x51e32d[_0x277d('0x4b')]['id'])});}}else{socket[_0x277d('0x74')](_0x277d('0x8e'),{'UserId':Number(_0x51e32d[_0x277d('0x3d')][_0x277d('0x6a')]),'WhatsappQueueId':Number(_0x51e32d[_0x277d('0x4b')]['id'])});}});}})[_0x277d('0x2b')](respondWithStatusCode(_0x14754a,null))['catch'](handleError(_0x14754a,null));};exports['getAgents']=function(_0x560c64,_0x466f0d,_0x365af4){var _0x415962={};var _0x4295fb={};var _0x55ac46;var _0x4347eb;return db[_0x277d('0x47')][_0x277d('0x5a')]({'where':{'id':_0x560c64[_0x277d('0x4b')]['id']}})[_0x277d('0x2b')](handleEntityNotFound(_0x466f0d,null))[_0x277d('0x2b')](function(_0x2ea5bd){if(_0x2ea5bd){_0x55ac46=_0x2ea5bd;_0x4295fb[_0x277d('0x38')]=_[_0x277d('0x4c')](db[_0x277d('0x5d')][_0x277d('0x35')]);_0x4295fb[_0x277d('0x3d')]=_[_0x277d('0x4c')](_0x560c64[_0x277d('0x3d')]);_0x4295fb[_0x277d('0x39')]=_[_0x277d('0x3a')](_0x4295fb[_0x277d('0x38')],_0x4295fb['query']);_0x415962[_0x277d('0x3b')]=_[_0x277d('0x3a')](_0x4295fb[_0x277d('0x38')],qs[_0x277d('0x3c')](_0x560c64[_0x277d('0x3d')]['fields']));_0x415962[_0x277d('0x3b')]=_0x415962[_0x277d('0x3b')][_0x277d('0x5c')]?_0x415962['attributes']:_0x4295fb[_0x277d('0x38')];_0x415962[_0x277d('0x8f')]=qs[_0x277d('0x40')](_0x560c64[_0x277d('0x3d')][_0x277d('0x40')]);_0x415962[_0x277d('0x41')]=qs[_0x277d('0x39')](_[_0x277d('0x68')](_0x560c64[_0x277d('0x3d')],_0x4295fb[_0x277d('0x39')]));if(_0x560c64[_0x277d('0x3d')][_0x277d('0x42')]){_0x415962[_0x277d('0x41')]=_[_0x277d('0x43')](_0x415962[_0x277d('0x41')],{'$or':_[_0x277d('0x34')](_0x415962[_0x277d('0x3b')],function(_0x2ce3b7){var _0x235038={};_0x235038[_0x2ce3b7]={'$like':'%'+_0x560c64[_0x277d('0x3d')][_0x277d('0x42')]+'%'};return _0x235038;})});}_0x415962=_[_0x277d('0x43')]({},_0x415962,_0x560c64[_0x277d('0x46')]);return _0x55ac46['getAgents'](_0x415962);}})['then'](function(_0x54edcb){if(_0x54edcb){_0x4347eb=_0x54edcb[_0x277d('0x5c')];if(!_0x560c64[_0x277d('0x3d')][_0x277d('0x3e')](_0x277d('0x3f'))){_0x415962[_0x277d('0x25')]=qs[_0x277d('0x25')](_0x560c64[_0x277d('0x3d')]['limit']);_0x415962['offset']=qs[_0x277d('0x24')](_0x560c64['query'][_0x277d('0x24')]);}return _0x55ac46['getAgents'](_0x415962);}})['then'](function(_0x126d5c){if(_0x126d5c){return _0x126d5c?{'count':_0x4347eb,'rows':_0x126d5c}:null;}})[_0x277d('0x2b')](respondWithResult(_0x466f0d,null))[_0x277d('0x49')](handleError(_0x466f0d,null));};
\ No newline at end of file
+var _0xbd1b=['removeAgents','forEach','userWhatsappQueue:remove','addAgents','omit','spread','isArray','eml-format','zip-dir','fast-json-patch','request-promise','mustache','util','sox','to-csv','ejs','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/license/util','../../mysqldb','redis','defaults','localhost','socket.io-emitter','./whatsappQueue.socket','register','sendStatus','status','end','count','offset','limit','set','Content-Range','json','apply','save','update','destroy','then','WhatsappQueues','UserProfileResource','error','stack','name','send','index','WhatsappQueue','fieldName','key','model','query','keys','filters','attributes','intersection','fields','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','map','type','VIRTUAL','include','findAll','rows','catch','show','params','rawAttributes','length','options','find','create','body','user','get','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','describe','getMembers','findOne','UserWhatsappQueue','WhatsappQueueId','User','findAndCountAll','agent','whatsappPause','updatedAt','format','SIP','createdAt','Team','getTeams','addTeams','ids','Agents','voicePause','interface','flatMap','sequelize','each','findOrCreate','emit','userWhatsappQueue:save','select','field','tq.TeamId','from','join','user_has_teams','ut.TeamId\x20=\x20tq.TeamId','clone','ut.UserId\x20=\x20?','push','toString','QueryTypes','SELECT','every','TeamId','includes','all','union','value','transaction','removeTeams','isEmpty'];(function(_0x49e11c,_0x13a573){var _0x4c6ef3=function(_0x151e95){while(--_0x151e95){_0x49e11c['push'](_0x49e11c['shift']());}};_0x4c6ef3(++_0x13a573);}(_0xbd1b,0x125));var _0xbbd1=function(_0x3475a6,_0xf36f21){_0x3475a6=_0x3475a6-0x0;var _0x556b92=_0xbd1b[_0x3475a6];return _0x556b92;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0xbbd1('0x0'));var rimraf=require('rimraf');var zipdir=require(_0xbbd1('0x1'));var jsonpatch=require(_0xbbd1('0x2'));var rp=require(_0xbbd1('0x3'));var moment=require('moment');var BPromise=require('bluebird');var Mustache=require(_0xbbd1('0x4'));var util=require(_0xbbd1('0x5'));var path=require('path');var sox=require(_0xbbd1('0x6'));var csv=require(_0xbbd1('0x7'));var ejs=require(_0xbbd1('0x8'));var fs=require('fs');var _=require(_0xbbd1('0x9'));var squel=require(_0xbbd1('0xa'));var crypto=require(_0xbbd1('0xb'));var jsforce=require(_0xbbd1('0xc'));var deskjs=require(_0xbbd1('0xd'));var toCsv=require('to-csv');var querystring=require(_0xbbd1('0xe'));var Papa=require(_0xbbd1('0xf'));var Redis=require(_0xbbd1('0x10'));var authService=require('../../components/auth/service');var qs=require(_0xbbd1('0x11'));var as=require(_0xbbd1('0x12'));var hardwareService=require(_0xbbd1('0x13'));var logger=require('../../config/logger')(_0xbbd1('0x14'));var utils=require('../../config/utils');var config=require('../../config/environment');var licenseUtil=require(_0xbbd1('0x15'));var db=require(_0xbbd1('0x16'))['db'];config[_0xbbd1('0x17')]=_[_0xbbd1('0x18')](config[_0xbbd1('0x17')],{'host':_0xbbd1('0x19'),'port':0x18eb});var socket=require(_0xbbd1('0x1a'))(new Redis(config['redis']));require(_0xbbd1('0x1b'))[_0xbbd1('0x1c')](socket);function respondWithStatusCode(_0x17edda,_0x122fbf){_0x122fbf=_0x122fbf||0xcc;return function(_0x2ea67d){if(_0x2ea67d){return _0x17edda[_0xbbd1('0x1d')](_0x122fbf);}return _0x17edda[_0xbbd1('0x1e')](_0x122fbf)[_0xbbd1('0x1f')]();};}function respondWithResult(_0x19fcf8,_0x4b680a){_0x4b680a=_0x4b680a||0xc8;return function(_0x2df861){if(_0x2df861){return _0x19fcf8[_0xbbd1('0x1e')](_0x4b680a)['json'](_0x2df861);}};}function respondWithFilteredResult(_0x287c35,_0x5bd7ea){return function(_0x1fc670){if(_0x1fc670){var _0x5622f6=_0x1fc670[_0xbbd1('0x20')],_0x49fd9c=_0x5bd7ea[_0xbbd1('0x21')],_0x3f0749=_0x5bd7ea[_0xbbd1('0x21')]+_0x5bd7ea[_0xbbd1('0x22')],_0x369ba5;if(_0x3f0749>=_0x5622f6){_0x3f0749=_0x5622f6;_0x369ba5=0xc8;}else{_0x369ba5=0xce;}_0x287c35['status'](_0x369ba5);return _0x287c35[_0xbbd1('0x23')](_0xbbd1('0x24'),_0x49fd9c+'-'+_0x3f0749+'/'+_0x5622f6)[_0xbbd1('0x25')](_0x1fc670);}return null;};}function patchUpdates(_0x3c46fd){return function(_0x4fa20a){try{jsonpatch[_0xbbd1('0x26')](_0x4fa20a,_0x3c46fd,!![]);}catch(_0x168af7){return BPromise['reject'](_0x168af7);}return _0x4fa20a[_0xbbd1('0x27')]();};}function saveUpdates(_0x49a36e,_0x30f12c){return function(_0x1b7fa1){if(_0x1b7fa1){return _0x1b7fa1[_0xbbd1('0x28')](_0x49a36e)['then'](function(_0x453186){return _0x453186;});}return null;};}function removeEntity(_0x10c155,_0x3cd5d0){return function(_0x3d9a32){if(_0x3d9a32){return _0x3d9a32[_0xbbd1('0x29')]()[_0xbbd1('0x2a')](function(){var _0x4b11b2=_0x3d9a32['get']({'plain':!![]});var _0x2f9370=_0xbbd1('0x2b');return db[_0xbbd1('0x2c')][_0xbbd1('0x29')]({'where':{'type':_0x2f9370,'resourceId':_0x4b11b2['id']}})['then'](function(){return _0x3d9a32;});})[_0xbbd1('0x2a')](function(){_0x10c155[_0xbbd1('0x1e')](0xcc)[_0xbbd1('0x1f')]();});}};}function handleEntityNotFound(_0x1a3b85,_0x37d14d){return function(_0x15172a){if(!_0x15172a){_0x1a3b85[_0xbbd1('0x1d')](0x194);}return _0x15172a;};}function handleError(_0x52b24e,_0x5c608e){_0x5c608e=_0x5c608e||0x1f4;return function(_0x5c9325){logger[_0xbbd1('0x2d')](_0x5c9325[_0xbbd1('0x2e')]);if(_0x5c9325[_0xbbd1('0x2f')]){delete _0x5c9325[_0xbbd1('0x2f')];}_0x52b24e[_0xbbd1('0x1e')](_0x5c608e)[_0xbbd1('0x30')](_0x5c9325);};}exports[_0xbbd1('0x31')]=function(_0x47db1b,_0x1f2a3f){var _0x5694a5={},_0x2b5597={},_0x1729d6={'count':0x0,'rows':[]};var _0x474b83=_['map'](db[_0xbbd1('0x32')]['rawAttributes'],function(_0x3a7de0){return{'name':_0x3a7de0[_0xbbd1('0x33')],'type':_0x3a7de0['type'][_0xbbd1('0x34')]};});_0x2b5597[_0xbbd1('0x35')]=_['map'](_0x474b83,_0xbbd1('0x2f'));_0x2b5597[_0xbbd1('0x36')]=_[_0xbbd1('0x37')](_0x47db1b[_0xbbd1('0x36')]);_0x2b5597[_0xbbd1('0x38')]=_['intersection'](_0x2b5597[_0xbbd1('0x35')],_0x2b5597[_0xbbd1('0x36')]);_0x5694a5[_0xbbd1('0x39')]=_[_0xbbd1('0x3a')](_0x2b5597['model'],qs['fields'](_0x47db1b[_0xbbd1('0x36')][_0xbbd1('0x3b')]));_0x5694a5[_0xbbd1('0x39')]=_0x5694a5[_0xbbd1('0x39')]['length']?_0x5694a5[_0xbbd1('0x39')]:_0x2b5597[_0xbbd1('0x35')];if(!_0x47db1b['query'][_0xbbd1('0x3c')](_0xbbd1('0x3d'))){_0x5694a5[_0xbbd1('0x22')]=qs['limit'](_0x47db1b[_0xbbd1('0x36')][_0xbbd1('0x22')]);_0x5694a5[_0xbbd1('0x21')]=qs[_0xbbd1('0x21')](_0x47db1b[_0xbbd1('0x36')][_0xbbd1('0x21')]);}_0x5694a5[_0xbbd1('0x3e')]=qs[_0xbbd1('0x3f')](_0x47db1b['query'][_0xbbd1('0x3f')]);_0x5694a5[_0xbbd1('0x40')]=qs['filters'](_[_0xbbd1('0x41')](_0x47db1b[_0xbbd1('0x36')],_0x2b5597['filters']),_0x474b83);if(_0x47db1b[_0xbbd1('0x36')][_0xbbd1('0x42')]){_0x5694a5[_0xbbd1('0x40')]=_[_0xbbd1('0x43')](_0x5694a5[_0xbbd1('0x40')],{'$or':_[_0xbbd1('0x44')](_0x474b83,function(_0x3d2d71){if(_0x3d2d71[_0xbbd1('0x45')]!==_0xbbd1('0x46')){var _0x5c2c1b={};_0x5c2c1b[_0x3d2d71[_0xbbd1('0x2f')]]={'$like':'%'+_0x47db1b[_0xbbd1('0x36')][_0xbbd1('0x42')]+'%'};return _0x5c2c1b;}})});}_0x5694a5=_['merge']({},_0x5694a5,_0x47db1b['options']);var _0x56f83b={'where':_0x5694a5['where']};return db[_0xbbd1('0x32')][_0xbbd1('0x20')](_0x56f83b)['then'](function(_0x195a62){_0x1729d6['count']=_0x195a62;if(_0x47db1b[_0xbbd1('0x36')]['includeAll']){_0x5694a5[_0xbbd1('0x47')]=[{'all':!![]}];}return db[_0xbbd1('0x32')][_0xbbd1('0x48')](_0x5694a5);})['then'](function(_0x473162){_0x1729d6[_0xbbd1('0x49')]=_0x473162;return _0x1729d6;})[_0xbbd1('0x2a')](respondWithFilteredResult(_0x1f2a3f,_0x5694a5))[_0xbbd1('0x4a')](handleError(_0x1f2a3f,null));};exports[_0xbbd1('0x4b')]=function(_0x16a0e8,_0x2ee878){var _0x20ac8e={'raw':!![],'where':{'id':_0x16a0e8[_0xbbd1('0x4c')]['id']}},_0x526a47={};_0x526a47['model']=_[_0xbbd1('0x37')](db['WhatsappQueue'][_0xbbd1('0x4d')]);_0x526a47['query']=_[_0xbbd1('0x37')](_0x16a0e8[_0xbbd1('0x36')]);_0x526a47[_0xbbd1('0x38')]=_[_0xbbd1('0x3a')](_0x526a47[_0xbbd1('0x35')],_0x526a47[_0xbbd1('0x36')]);_0x20ac8e[_0xbbd1('0x39')]=_[_0xbbd1('0x3a')](_0x526a47[_0xbbd1('0x35')],qs[_0xbbd1('0x3b')](_0x16a0e8[_0xbbd1('0x36')][_0xbbd1('0x3b')]));_0x20ac8e['attributes']=_0x20ac8e[_0xbbd1('0x39')][_0xbbd1('0x4e')]?_0x20ac8e[_0xbbd1('0x39')]:_0x526a47[_0xbbd1('0x35')];if(_0x16a0e8[_0xbbd1('0x36')]['includeAll']){_0x20ac8e[_0xbbd1('0x47')]=[{'all':!![]}];}_0x20ac8e=_['merge']({},_0x20ac8e,_0x16a0e8[_0xbbd1('0x4f')]);return db[_0xbbd1('0x32')][_0xbbd1('0x50')](_0x20ac8e)['then'](handleEntityNotFound(_0x2ee878,null))['then'](respondWithResult(_0x2ee878,null))[_0xbbd1('0x4a')](handleError(_0x2ee878,null));};exports['create']=function(_0x1e3189,_0x2dccf0){return db[_0xbbd1('0x32')][_0xbbd1('0x51')](_0x1e3189[_0xbbd1('0x52')],{})[_0xbbd1('0x2a')](function(_0xb87d7){var _0x36bbbc=_0x1e3189[_0xbbd1('0x53')][_0xbbd1('0x54')]({'plain':!![]});if(!_0x36bbbc)throw new Error(_0xbbd1('0x55'));if(_0x36bbbc[_0xbbd1('0x56')]==='user'){var _0x275387=_0xb87d7[_0xbbd1('0x54')]({'plain':!![]});var _0x3483ee=_0xbbd1('0x2b');return db['UserProfileSection'][_0xbbd1('0x50')]({'where':{'name':_0x3483ee,'userProfileId':_0x36bbbc['userProfileId']},'raw':!![]})['then'](function(_0x391008){if(_0x391008&&_0x391008['autoAssociation']===0x0){return db['UserProfileResource']['create']({'name':_0x275387[_0xbbd1('0x2f')],'resourceId':_0x275387['id'],'type':_0x391008[_0xbbd1('0x2f')],'sectionId':_0x391008['id']},{})[_0xbbd1('0x2a')](function(){return _0xb87d7;});}else{return _0xb87d7;}})[_0xbbd1('0x4a')](function(_0x3db5a2){logger[_0xbbd1('0x2d')](_0xbbd1('0x57'),_0x3db5a2);throw _0x3db5a2;});}return _0xb87d7;})[_0xbbd1('0x2a')](respondWithResult(_0x2dccf0,0xc9))['catch'](handleError(_0x2dccf0,null));};exports['update']=function(_0x5e069e,_0x19e9d8){if(_0x5e069e['body']['id']){delete _0x5e069e['body']['id'];}return db['WhatsappQueue'][_0xbbd1('0x50')]({'where':{'id':_0x5e069e[_0xbbd1('0x4c')]['id']}})[_0xbbd1('0x2a')](handleEntityNotFound(_0x19e9d8,null))[_0xbbd1('0x2a')](saveUpdates(_0x5e069e['body'],null))['then'](respondWithResult(_0x19e9d8,null))[_0xbbd1('0x4a')](handleError(_0x19e9d8,null));};exports[_0xbbd1('0x29')]=function(_0x4f87ab,_0x19d92f){return db[_0xbbd1('0x32')]['find']({'where':{'id':_0x4f87ab[_0xbbd1('0x4c')]['id']}})[_0xbbd1('0x2a')](handleEntityNotFound(_0x19d92f,null))[_0xbbd1('0x2a')](removeEntity(_0x19d92f,null))[_0xbbd1('0x4a')](handleError(_0x19d92f,null));};exports['describe']=function(_0x5079d7,_0x281e67){return db[_0xbbd1('0x32')][_0xbbd1('0x58')]()[_0xbbd1('0x2a')](respondWithResult(_0x281e67,null))['catch'](handleError(_0x281e67,null));};exports[_0xbbd1('0x59')]=function(_0x220e02,_0x1aedfc,_0x18dc05){var _0x5b969d={'raw':!![],'where':{}},_0x2d3c25={},_0x216e21;return db[_0xbbd1('0x32')][_0xbbd1('0x5a')]({'where':{'id':_0x220e02[_0xbbd1('0x4c')]['id']}})[_0xbbd1('0x2a')](handleEntityNotFound(_0x1aedfc,null))[_0xbbd1('0x2a')](function(_0x302c8c){if(_0x302c8c){_0x216e21=_0x302c8c[_0xbbd1('0x54')]({'plain':!![]});_0x2d3c25[_0xbbd1('0x35')]=_[_0xbbd1('0x37')](db[_0xbbd1('0x5b')]['rawAttributes']);_0x2d3c25[_0xbbd1('0x36')]=_['keys'](_0x220e02[_0xbbd1('0x36')]);_0x2d3c25[_0xbbd1('0x38')]=_[_0xbbd1('0x3a')](_0x2d3c25[_0xbbd1('0x35')],_0x2d3c25[_0xbbd1('0x36')]);_0x5b969d[_0xbbd1('0x39')]=_[_0xbbd1('0x3a')](_0x2d3c25[_0xbbd1('0x35')],qs[_0xbbd1('0x3b')](_0x220e02[_0xbbd1('0x36')][_0xbbd1('0x3b')]));_0x5b969d[_0xbbd1('0x39')]=_0x5b969d[_0xbbd1('0x39')][_0xbbd1('0x4e')]?_0x5b969d['attributes']:_0x2d3c25[_0xbbd1('0x35')];if(!_0x220e02[_0xbbd1('0x36')][_0xbbd1('0x3c')](_0xbbd1('0x3d'))){_0x5b969d[_0xbbd1('0x22')]=qs[_0xbbd1('0x22')](_0x220e02[_0xbbd1('0x36')][_0xbbd1('0x22')]);_0x5b969d[_0xbbd1('0x21')]=qs[_0xbbd1('0x21')](_0x220e02[_0xbbd1('0x36')]['offset']);}_0x5b969d[_0xbbd1('0x3e')]=qs['sort'](_0x220e02[_0xbbd1('0x36')][_0xbbd1('0x3f')]);_0x5b969d['where']=qs[_0xbbd1('0x38')](_[_0xbbd1('0x41')](_0x220e02['query'],_0x2d3c25[_0xbbd1('0x38')]));_0x5b969d[_0xbbd1('0x40')][_0xbbd1('0x5c')]=_0x302c8c['id'];if(_0x220e02[_0xbbd1('0x36')][_0xbbd1('0x42')]){_0x5b969d[_0xbbd1('0x40')]=_[_0xbbd1('0x43')](_0x5b969d['where'],{'$or':_[_0xbbd1('0x44')](_0x5b969d[_0xbbd1('0x39')],function(_0x15cf45){var _0x3b6b9f={};_0x3b6b9f[_0x15cf45]={'$like':'%'+_0x220e02['query'][_0xbbd1('0x42')]+'%'};return _0x3b6b9f;})});}_0x5b969d=_[_0xbbd1('0x43')]({},_0x5b969d,_0x220e02[_0xbbd1('0x4f')]);return db[_0xbbd1('0x5b')][_0xbbd1('0x48')](_0x5b969d);}})[_0xbbd1('0x2a')](function(_0x2abe8a){if(_0x2abe8a){return db[_0xbbd1('0x5d')][_0xbbd1('0x5e')]({'where':{'id':_[_0xbbd1('0x44')](_0x2abe8a,'UserId'),'role':_0xbbd1('0x5f')},'attributes':['id',_0xbbd1('0x2f'),_0xbbd1('0x60'),_0xbbd1('0x61'),'createdAt']});}})[_0xbbd1('0x2a')](function(_0x20d2ab){if(_0x20d2ab){return{'count':_0x20d2ab[_0xbbd1('0x20')],'rows':_['map'](_0x20d2ab[_0xbbd1('0x49')],function(_0x1452be){return{'membername':_0x1452be['name'],'UserId':_0x1452be['id'],'queue_name':_0x216e21[_0xbbd1('0x2f')],'WhatsappQueueId':_0x216e21['id'],'interface':util[_0xbbd1('0x62')]('%s/%s',_0xbbd1('0x63'),_0x1452be[_0xbbd1('0x2f')]),'penalty':0x0,'paused':_0x1452be[_0xbbd1('0x60')],'createdAt':_0x1452be[_0xbbd1('0x64')],'updatedAt':_0x1452be['updatedAt']};})};}else{return{'count':0x0,'rows':[]};}})[_0xbbd1('0x2a')](respondWithFilteredResult(_0x1aedfc,_0x5b969d))['catch'](handleError(_0x1aedfc,null));};exports['getTeams']=function(_0x587b03,_0x162d47,_0xfa4ba7){var _0x4d4339={};var _0x135494={};var _0x184e1b;var _0x29e92e;return db[_0xbbd1('0x32')][_0xbbd1('0x5a')]({'where':{'id':_0x587b03[_0xbbd1('0x4c')]['id']}})[_0xbbd1('0x2a')](handleEntityNotFound(_0x162d47,null))[_0xbbd1('0x2a')](function(_0xf054ec){if(_0xf054ec){_0x184e1b=_0xf054ec;_0x135494[_0xbbd1('0x35')]=_['keys'](db[_0xbbd1('0x65')][_0xbbd1('0x4d')]);_0x135494[_0xbbd1('0x36')]=_[_0xbbd1('0x37')](_0x587b03[_0xbbd1('0x36')]);_0x135494[_0xbbd1('0x38')]=_['intersection'](_0x135494[_0xbbd1('0x35')],_0x135494[_0xbbd1('0x36')]);_0x4d4339['attributes']=_[_0xbbd1('0x3a')](_0x135494[_0xbbd1('0x35')],qs[_0xbbd1('0x3b')](_0x587b03['query'][_0xbbd1('0x3b')]));_0x4d4339[_0xbbd1('0x39')]=_0x4d4339['attributes'][_0xbbd1('0x4e')]?_0x4d4339['attributes']:_0x135494[_0xbbd1('0x35')];_0x4d4339[_0xbbd1('0x3e')]=qs[_0xbbd1('0x3f')](_0x587b03[_0xbbd1('0x36')][_0xbbd1('0x3f')]);_0x4d4339[_0xbbd1('0x40')]=qs['filters'](_[_0xbbd1('0x41')](_0x587b03['query'],_0x135494[_0xbbd1('0x38')]));if(_0x587b03[_0xbbd1('0x36')][_0xbbd1('0x42')]){_0x4d4339[_0xbbd1('0x40')]=_['merge'](_0x4d4339[_0xbbd1('0x40')],{'$or':_[_0xbbd1('0x44')](_0x4d4339[_0xbbd1('0x39')],function(_0x2ad570){var _0x342ba6={};_0x342ba6[_0x2ad570]={'$like':'%'+_0x587b03[_0xbbd1('0x36')][_0xbbd1('0x42')]+'%'};return _0x342ba6;})});}_0x4d4339=_[_0xbbd1('0x43')]({},_0x4d4339,_0x587b03[_0xbbd1('0x4f')]);return _0x184e1b[_0xbbd1('0x66')](_0x4d4339);}})[_0xbbd1('0x2a')](function(_0x464cfd){if(_0x464cfd){_0x29e92e=_0x464cfd[_0xbbd1('0x4e')];if(!_0x587b03['query'][_0xbbd1('0x3c')]('nolimit')){_0x4d4339[_0xbbd1('0x22')]=qs[_0xbbd1('0x22')](_0x587b03[_0xbbd1('0x36')][_0xbbd1('0x22')]);_0x4d4339[_0xbbd1('0x21')]=qs[_0xbbd1('0x21')](_0x587b03['query'][_0xbbd1('0x21')]);}return _0x184e1b['getTeams'](_0x4d4339);}})['then'](function(_0x4d2665){if(_0x4d2665){return _0x4d2665?{'count':_0x29e92e,'rows':_0x4d2665}:null;}})[_0xbbd1('0x2a')](respondWithResult(_0x162d47,null))[_0xbbd1('0x4a')](handleError(_0x162d47,null));};exports[_0xbbd1('0x67')]=function(_0xa012b2,_0x18b791,_0x345009){var _0x25960b=_0xa012b2[_0xbbd1('0x52')][_0xbbd1('0x68')];return db[_0xbbd1('0x65')][_0xbbd1('0x48')]({'where':{'id':_0x25960b},'attributes':['id'],'include':[{'model':db[_0xbbd1('0x5d')],'as':_0xbbd1('0x69'),'attributes':['id',_0xbbd1('0x2f'),'online',_0xbbd1('0x6a'),_0xbbd1('0x6b')],'raw':!![]}]})[_0xbbd1('0x2a')](function(_0x5d39be){if(_0x5d39be){var _0x211f26=_[_0xbbd1('0x6c')](_0x5d39be,function(_0x4ea4e4){var _0x2a64f8=_0x4ea4e4[_0xbbd1('0x54')]({'plain':!![]});return _0x2a64f8[_0xbbd1('0x69')];});return db[_0xbbd1('0x32')][_0xbbd1('0x50')]({'where':{'id':_0xa012b2[_0xbbd1('0x4c')]['id']}})[_0xbbd1('0x2a')](function(_0x4e86fe){return db[_0xbbd1('0x6d')]['transaction'](function(_0x33e52a){return _0x4e86fe[_0xbbd1('0x67')](_0x25960b,{'transaction':_0x33e52a})['then'](function(){return BPromise[_0xbbd1('0x6e')](_0x211f26,function(_0x46af33){return db[_0xbbd1('0x5b')][_0xbbd1('0x6f')]({'where':{'UserId':_0x46af33['id'],'WhatsappQueueId':_0xa012b2[_0xbbd1('0x4c')]['id']},'transaction':_0x33e52a});});})['then'](function(){_0x211f26['forEach'](function(_0x19c016){socket[_0xbbd1('0x70')](_0xbbd1('0x71'),{'UserId':_0x19c016['id'],'WhatsappQueueId':_0x4e86fe['id']});});});});});}})['then'](respondWithStatusCode(_0x18b791,null))['catch'](handleError(_0x18b791,null));};exports['removeTeams']=function(_0x3858f4,_0x5122c8,_0x5ded7b){return db['Team']['findAll']({'where':{'id':_0x3858f4[_0xbbd1('0x36')][_0xbbd1('0x68')]},'attributes':['id'],'include':[{'model':db[_0xbbd1('0x5d')],'as':_0xbbd1('0x69'),'attributes':['id'],'raw':!![]}]})['then'](handleEntityNotFound(_0x5122c8,null))[_0xbbd1('0x2a')](function(_0x3cc6fe){var _0x423648=_[_0xbbd1('0x44')](_0x3cc6fe,'id');var _0x405068=[];var _0x1cd7b1=[];var _0x169275=squel[_0xbbd1('0x72')]();_0x169275[_0xbbd1('0x73')](_0xbbd1('0x74'))[_0xbbd1('0x75')]('team_has_whatsapp_queues','tq')[_0xbbd1('0x76')](_0xbbd1('0x77'),'ut',_0xbbd1('0x78'))[_0xbbd1('0x40')]('WhatsappQueueId\x20=\x20?',_0x3858f4[_0xbbd1('0x4c')]['id']);for(var _0x34eca6=0x0;_0x34eca6<_0x3cc6fe['length'];_0x34eca6+=0x1){let _0x4c2a6f=_0x3cc6fe[_0x34eca6];for(var _0x12efc7=0x0;_0x12efc7<_0x4c2a6f[_0xbbd1('0x69')][_0xbbd1('0x4e')];_0x12efc7+=0x1){let _0x523a88=_0x4c2a6f[_0xbbd1('0x69')][_0x12efc7];var _0x5c4746=_0x169275[_0xbbd1('0x79')]();_0x5c4746[_0xbbd1('0x40')](_0xbbd1('0x7a'),_0x523a88['id']);_0x1cd7b1[_0xbbd1('0x7b')](db[_0xbbd1('0x6d')][_0xbbd1('0x36')](_0x5c4746[_0xbbd1('0x7c')](),{'type':db['sequelize'][_0xbbd1('0x7d')][_0xbbd1('0x7e')]})[_0xbbd1('0x2a')](function(_0x2f4f74){if(_0x2f4f74[_0xbbd1('0x4e')]===0x1){return _0x523a88['id'];}else{var _0x193f97=_[_0xbbd1('0x7f')](_[_0xbbd1('0x44')](_0x2f4f74,_0xbbd1('0x80')),function(_0x466f69){return _[_0xbbd1('0x81')](_0x423648,_0x466f69);});if(_0x193f97){return _0x523a88['id'];}}}));}}return BPromise[_0xbbd1('0x82')](_0x1cd7b1)[_0xbbd1('0x2a')](function(_0x2a6ec4){_0x405068=_(_0x405068)[_0xbbd1('0x83')](_0x2a6ec4)['compact']()[_0xbbd1('0x84')]();return db[_0xbbd1('0x32')][_0xbbd1('0x50')]({'where':{'id':_0x3858f4[_0xbbd1('0x4c')]['id']}})['then'](function(_0x55b4a8){return db[_0xbbd1('0x6d')][_0xbbd1('0x85')](function(_0x526fac){return _0x55b4a8[_0xbbd1('0x86')](_0x3858f4['query'][_0xbbd1('0x68')],{'transaction':_0x526fac})[_0xbbd1('0x2a')](function(){if(!_[_0xbbd1('0x87')](_0x405068)){return _0x55b4a8[_0xbbd1('0x88')](_0x405068,{'transaction':_0x526fac});}})['then'](function(){_0x405068[_0xbbd1('0x89')](function(_0x24061e){socket[_0xbbd1('0x70')](_0xbbd1('0x8a'),{'UserId':_0x24061e,'WhatsappQueueId':_0x55b4a8['id']});});});});});});})[_0xbbd1('0x2a')](respondWithStatusCode(_0x5122c8,null))[_0xbbd1('0x4a')](handleError(_0x5122c8,null));};exports[_0xbbd1('0x8b')]=function(_0xaab2a3,_0x589dd2,_0x12fcaf){return db[_0xbbd1('0x32')][_0xbbd1('0x50')]({'where':{'id':_0xaab2a3[_0xbbd1('0x4c')]['id']}})[_0xbbd1('0x2a')](handleEntityNotFound(_0x589dd2,null))[_0xbbd1('0x2a')](function(_0x491c1b){if(_0x491c1b){return _0x491c1b['addAgents'](_0xaab2a3[_0xbbd1('0x52')][_0xbbd1('0x68')],_[_0xbbd1('0x8c')](_0xaab2a3[_0xbbd1('0x52')],['ids','id'])||{})[_0xbbd1('0x8d')](function(_0x279edb){for(var _0x11b32a=0x0;_0x11b32a<_0xaab2a3[_0xbbd1('0x52')][_0xbbd1('0x68')][_0xbbd1('0x4e')];_0x11b32a+=0x1){socket['emit'](_0xbbd1('0x71'),{'UserId':_0xaab2a3[_0xbbd1('0x52')]['ids'][_0x11b32a],'WhatsappQueueId':_0xaab2a3[_0xbbd1('0x4c')]['id']});}return _0x279edb;});}})['then'](respondWithResult(_0x589dd2,null))['catch'](handleError(_0x589dd2,null));};exports['removeAgents']=function(_0x4cbe58,_0x411eba,_0x1ee267){return db['WhatsappQueue']['find']({'where':{'id':_0x4cbe58[_0xbbd1('0x4c')]['id']}})['then'](handleEntityNotFound(_0x411eba,null))['then'](function(_0x375d11){if(_0x375d11){return _0x375d11[_0xbbd1('0x88')](_0x4cbe58['query'][_0xbbd1('0x68')])[_0xbbd1('0x2a')](function(){if(_[_0xbbd1('0x8e')](_0x4cbe58['query'][_0xbbd1('0x68')])){for(var _0x221af4=0x0;_0x221af4<_0x4cbe58['query'][_0xbbd1('0x68')]['length'];_0x221af4+=0x1){socket[_0xbbd1('0x70')](_0xbbd1('0x8a'),{'UserId':Number(_0x4cbe58[_0xbbd1('0x36')]['ids'][_0x221af4]),'WhatsappQueueId':Number(_0x4cbe58['params']['id'])});}}else{socket['emit'](_0xbbd1('0x8a'),{'UserId':Number(_0x4cbe58[_0xbbd1('0x36')]['ids']),'WhatsappQueueId':Number(_0x4cbe58[_0xbbd1('0x4c')]['id'])});}});}})[_0xbbd1('0x2a')](respondWithStatusCode(_0x411eba,null))[_0xbbd1('0x4a')](handleError(_0x411eba,null));};exports['getAgents']=function(_0x403d3e,_0x229eee,_0x447e7a){var _0x259067={};var _0x4f985b={};var _0x4112ee;var _0x5231a4;return db['WhatsappQueue'][_0xbbd1('0x5a')]({'where':{'id':_0x403d3e['params']['id']}})['then'](handleEntityNotFound(_0x229eee,null))[_0xbbd1('0x2a')](function(_0x3b3926){if(_0x3b3926){_0x4112ee=_0x3b3926;_0x4f985b['model']=_[_0xbbd1('0x37')](db[_0xbbd1('0x5d')][_0xbbd1('0x4d')]);_0x4f985b[_0xbbd1('0x36')]=_['keys'](_0x403d3e[_0xbbd1('0x36')]);_0x4f985b[_0xbbd1('0x38')]=_[_0xbbd1('0x3a')](_0x4f985b[_0xbbd1('0x35')],_0x4f985b[_0xbbd1('0x36')]);_0x259067[_0xbbd1('0x39')]=_[_0xbbd1('0x3a')](_0x4f985b['model'],qs['fields'](_0x403d3e[_0xbbd1('0x36')][_0xbbd1('0x3b')]));_0x259067[_0xbbd1('0x39')]=_0x259067[_0xbbd1('0x39')][_0xbbd1('0x4e')]?_0x259067[_0xbbd1('0x39')]:_0x4f985b['model'];_0x259067[_0xbbd1('0x3e')]=qs['sort'](_0x403d3e[_0xbbd1('0x36')]['sort']);_0x259067[_0xbbd1('0x40')]=qs['filters'](_[_0xbbd1('0x41')](_0x403d3e[_0xbbd1('0x36')],_0x4f985b['filters']));if(_0x403d3e[_0xbbd1('0x36')][_0xbbd1('0x42')]){_0x259067[_0xbbd1('0x40')]=_['merge'](_0x259067[_0xbbd1('0x40')],{'$or':_[_0xbbd1('0x44')](_0x259067[_0xbbd1('0x39')],function(_0x144be9){var _0x3d70b8={};_0x3d70b8[_0x144be9]={'$like':'%'+_0x403d3e['query']['filter']+'%'};return _0x3d70b8;})});}_0x259067=_['merge']({},_0x259067,_0x403d3e[_0xbbd1('0x4f')]);return _0x4112ee['getAgents'](_0x259067);}})['then'](function(_0x14193b){if(_0x14193b){_0x5231a4=_0x14193b[_0xbbd1('0x4e')];if(!_0x403d3e[_0xbbd1('0x36')][_0xbbd1('0x3c')](_0xbbd1('0x3d'))){_0x259067[_0xbbd1('0x22')]=qs[_0xbbd1('0x22')](_0x403d3e[_0xbbd1('0x36')][_0xbbd1('0x22')]);_0x259067[_0xbbd1('0x21')]=qs['offset'](_0x403d3e['query'][_0xbbd1('0x21')]);}return _0x4112ee['getAgents'](_0x259067);}})[_0xbbd1('0x2a')](function(_0x376472){if(_0x376472){return _0x376472?{'count':_0x5231a4,'rows':_0x376472}:null;}})['then'](respondWithResult(_0x229eee,null))['catch'](handleError(_0x229eee,null));};
\ No newline at end of file