Built motion from commit (unavailable).|2.5.11
[motion2.git] / server / api / whatsappQueue / whatsappQueue.controller.js
index 6582b31..e5ae151 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x6eb3=['UserProfileSection','find','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','describe','findOne','UserWhatsappQueue','nolimit','User','UserId','agent','updatedAt','createdAt','format','%s/%s','SIP','whatsappPause','getTeams','Team','addTeams','ids','online','voicePause','interface','Agents','transaction','findOrCreate','forEach','emit','userWhatsappQueue:save','removeTeams','select','field','tq.TeamId','from','join','user_has_teams','ut.TeamId\x20=\x20tq.TeamId','WhatsappQueueId\x20=\x20?','clone','ut.UserId\x20=\x20?','push','sequelize','toString','QueryTypes','SELECT','every','TeamId','includes','compact','value','isEmpty','removeAgents','userWhatsappQueue:remove','addAgents','omit','spread','getAgents','eml-format','rimraf','request-promise','moment','bluebird','util','path','sox','to-csv','ejs','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','redis','defaults','localhost','./whatsappQueue.socket','register','status','end','json','offset','limit','set','update','then','destroy','WhatsappQueues','UserProfileResource','error','stack','name','map','rawAttributes','model','query','keys','filters','attributes','intersection','fields','length','hasOwnProperty','order','sort','pick','where','merge','filter','options','WhatsappQueue','count','includeAll','include','findAll','rows','catch','params','create','body','user','get','Unable\x20to\x20retrieve\x20the\x20current\x20user','role'];(function(_0x1b2ced,_0x2ec70b){var _0x4f98a7=function(_0x20d40c){while(--_0x20d40c){_0x1b2ced['push'](_0x1b2ced['shift']());}};_0x4f98a7(++_0x2ec70b);}(_0x6eb3,0x1cd));var _0x36eb=function(_0xae76da,_0x539feb){_0xae76da=_0xae76da-0x0;var _0x43e8e8=_0x6eb3[_0xae76da];return _0x43e8e8;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0x36eb('0x0'));var rimraf=require(_0x36eb('0x1'));var zipdir=require('zip-dir');var jsonpatch=require('fast-json-patch');var rp=require(_0x36eb('0x2'));var moment=require(_0x36eb('0x3'));var BPromise=require(_0x36eb('0x4'));var Mustache=require('mustache');var util=require(_0x36eb('0x5'));var path=require(_0x36eb('0x6'));var sox=require(_0x36eb('0x7'));var csv=require(_0x36eb('0x8'));var ejs=require(_0x36eb('0x9'));var fs=require('fs');var _=require(_0x36eb('0xa'));var squel=require(_0x36eb('0xb'));var crypto=require(_0x36eb('0xc'));var jsforce=require(_0x36eb('0xd'));var deskjs=require(_0x36eb('0xe'));var toCsv=require(_0x36eb('0x8'));var querystring=require(_0x36eb('0xf'));var Papa=require(_0x36eb('0x10'));var Redis=require('ioredis');var authService=require(_0x36eb('0x11'));var qs=require(_0x36eb('0x12'));var as=require(_0x36eb('0x13'));var hardwareService=require(_0x36eb('0x14'));var logger=require(_0x36eb('0x15'))(_0x36eb('0x16'));var utils=require(_0x36eb('0x17'));var config=require('../../config/environment');var db=require('../../mysqldb')['db'];config[_0x36eb('0x18')]=_[_0x36eb('0x19')](config[_0x36eb('0x18')],{'host':_0x36eb('0x1a'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config['redis']));require(_0x36eb('0x1b'))[_0x36eb('0x1c')](socket);function respondWithStatusCode(_0x5b9eee,_0x289b3c){_0x289b3c=_0x289b3c||0xcc;return function(_0x30f0bc){if(_0x30f0bc){return _0x5b9eee['sendStatus'](_0x289b3c);}return _0x5b9eee[_0x36eb('0x1d')](_0x289b3c)[_0x36eb('0x1e')]();};}function respondWithResult(_0xd6498c,_0x172080){_0x172080=_0x172080||0xc8;return function(_0x2cdab2){if(_0x2cdab2){return _0xd6498c[_0x36eb('0x1d')](_0x172080)[_0x36eb('0x1f')](_0x2cdab2);}};}function respondWithFilteredResult(_0x22a023,_0x25f282){return function(_0x21f39f){if(_0x21f39f){var _0x35e31e=_0x21f39f['count'],_0x4368ca=_0x25f282[_0x36eb('0x20')],_0x1fc626=_0x25f282[_0x36eb('0x20')]+_0x25f282[_0x36eb('0x21')],_0x8d5756;if(_0x1fc626>=_0x35e31e){_0x1fc626=_0x35e31e;_0x8d5756=0xc8;}else{_0x8d5756=0xce;}_0x22a023[_0x36eb('0x1d')](_0x8d5756);return _0x22a023[_0x36eb('0x22')]('Content-Range',_0x4368ca+'-'+_0x1fc626+'/'+_0x35e31e)[_0x36eb('0x1f')](_0x21f39f);}return null;};}function patchUpdates(_0x383ab8){return function(_0x53114b){try{jsonpatch['apply'](_0x53114b,_0x383ab8,!![]);}catch(_0x52596f){return BPromise['reject'](_0x52596f);}return _0x53114b['save']();};}function saveUpdates(_0x45d5a5,_0x584a1){return function(_0x16106f){if(_0x16106f){return _0x16106f[_0x36eb('0x23')](_0x45d5a5)[_0x36eb('0x24')](function(_0x166da4){return _0x166da4;});}return null;};}function removeEntity(_0x427990,_0x4fc932){return function(_0xa1fc9f){if(_0xa1fc9f){return _0xa1fc9f[_0x36eb('0x25')]()[_0x36eb('0x24')](function(){var _0x40a377=_0xa1fc9f['get']({'plain':!![]});var _0x24c9e1=_0x36eb('0x26');return db[_0x36eb('0x27')][_0x36eb('0x25')]({'where':{'type':_0x24c9e1,'resourceId':_0x40a377['id']}})['then'](function(){return _0xa1fc9f;});})[_0x36eb('0x24')](function(){_0x427990[_0x36eb('0x1d')](0xcc)[_0x36eb('0x1e')]();});}};}function handleEntityNotFound(_0x37c81b,_0x551e13){return function(_0x7d2565){if(!_0x7d2565){_0x37c81b['sendStatus'](0x194);}return _0x7d2565;};}function handleError(_0x1a1caa,_0x39d6ec){_0x39d6ec=_0x39d6ec||0x1f4;return function(_0x5f2608){logger[_0x36eb('0x28')](_0x5f2608[_0x36eb('0x29')]);if(_0x5f2608[_0x36eb('0x2a')]){delete _0x5f2608['name'];}_0x1a1caa[_0x36eb('0x1d')](_0x39d6ec)['send'](_0x5f2608);};}exports['index']=function(_0x179ef3,_0x32e805){var _0x54b697={},_0x110a2a={},_0x36cd1a={'count':0x0,'rows':[]};var _0x508488=_[_0x36eb('0x2b')](db['WhatsappQueue'][_0x36eb('0x2c')],function(_0x232b26){return{'name':_0x232b26['fieldName'],'type':_0x232b26['type']['key']};});_0x110a2a[_0x36eb('0x2d')]=_[_0x36eb('0x2b')](_0x508488,_0x36eb('0x2a'));_0x110a2a[_0x36eb('0x2e')]=_[_0x36eb('0x2f')](_0x179ef3['query']);_0x110a2a[_0x36eb('0x30')]=_['intersection'](_0x110a2a[_0x36eb('0x2d')],_0x110a2a[_0x36eb('0x2e')]);_0x54b697[_0x36eb('0x31')]=_[_0x36eb('0x32')](_0x110a2a['model'],qs[_0x36eb('0x33')](_0x179ef3[_0x36eb('0x2e')][_0x36eb('0x33')]));_0x54b697[_0x36eb('0x31')]=_0x54b697['attributes'][_0x36eb('0x34')]?_0x54b697['attributes']:_0x110a2a['model'];if(!_0x179ef3['query'][_0x36eb('0x35')]('nolimit')){_0x54b697[_0x36eb('0x21')]=qs['limit'](_0x179ef3[_0x36eb('0x2e')]['limit']);_0x54b697[_0x36eb('0x20')]=qs[_0x36eb('0x20')](_0x179ef3[_0x36eb('0x2e')][_0x36eb('0x20')]);}_0x54b697[_0x36eb('0x36')]=qs['sort'](_0x179ef3['query'][_0x36eb('0x37')]);_0x54b697['where']=qs[_0x36eb('0x30')](_[_0x36eb('0x38')](_0x179ef3[_0x36eb('0x2e')],_0x110a2a[_0x36eb('0x30')]),_0x508488);if(_0x179ef3[_0x36eb('0x2e')]['filter']){_0x54b697[_0x36eb('0x39')]=_[_0x36eb('0x3a')](_0x54b697[_0x36eb('0x39')],{'$or':_['map'](_0x508488,function(_0x1598ff){if(_0x1598ff['type']!=='VIRTUAL'){var _0x4ae3b5={};_0x4ae3b5[_0x1598ff[_0x36eb('0x2a')]]={'$like':'%'+_0x179ef3[_0x36eb('0x2e')][_0x36eb('0x3b')]+'%'};return _0x4ae3b5;}})});}_0x54b697=_[_0x36eb('0x3a')]({},_0x54b697,_0x179ef3[_0x36eb('0x3c')]);var _0x510463={'where':_0x54b697[_0x36eb('0x39')]};return db[_0x36eb('0x3d')][_0x36eb('0x3e')](_0x510463)[_0x36eb('0x24')](function(_0xc9e68d){_0x36cd1a[_0x36eb('0x3e')]=_0xc9e68d;if(_0x179ef3[_0x36eb('0x2e')][_0x36eb('0x3f')]){_0x54b697[_0x36eb('0x40')]=[{'all':!![]}];}return db[_0x36eb('0x3d')][_0x36eb('0x41')](_0x54b697);})[_0x36eb('0x24')](function(_0x54a2c3){_0x36cd1a[_0x36eb('0x42')]=_0x54a2c3;return _0x36cd1a;})[_0x36eb('0x24')](respondWithFilteredResult(_0x32e805,_0x54b697))[_0x36eb('0x43')](handleError(_0x32e805,null));};exports['show']=function(_0x14d7ac,_0x3c1c15){var _0x2a665a={'raw':!![],'where':{'id':_0x14d7ac[_0x36eb('0x44')]['id']}},_0x5f3c7a={};_0x5f3c7a[_0x36eb('0x2d')]=_['keys'](db[_0x36eb('0x3d')][_0x36eb('0x2c')]);_0x5f3c7a[_0x36eb('0x2e')]=_['keys'](_0x14d7ac['query']);_0x5f3c7a[_0x36eb('0x30')]=_['intersection'](_0x5f3c7a['model'],_0x5f3c7a[_0x36eb('0x2e')]);_0x2a665a[_0x36eb('0x31')]=_[_0x36eb('0x32')](_0x5f3c7a[_0x36eb('0x2d')],qs[_0x36eb('0x33')](_0x14d7ac['query'][_0x36eb('0x33')]));_0x2a665a['attributes']=_0x2a665a[_0x36eb('0x31')][_0x36eb('0x34')]?_0x2a665a['attributes']:_0x5f3c7a[_0x36eb('0x2d')];if(_0x14d7ac['query'][_0x36eb('0x3f')]){_0x2a665a[_0x36eb('0x40')]=[{'all':!![]}];}_0x2a665a=_[_0x36eb('0x3a')]({},_0x2a665a,_0x14d7ac[_0x36eb('0x3c')]);return db['WhatsappQueue']['find'](_0x2a665a)['then'](handleEntityNotFound(_0x3c1c15,null))[_0x36eb('0x24')](respondWithResult(_0x3c1c15,null))[_0x36eb('0x43')](handleError(_0x3c1c15,null));};exports['create']=function(_0x11b532,_0x369a30){return db[_0x36eb('0x3d')][_0x36eb('0x45')](_0x11b532[_0x36eb('0x46')],{})[_0x36eb('0x24')](function(_0x5df3f0){var _0x57949f=_0x11b532[_0x36eb('0x47')][_0x36eb('0x48')]({'plain':!![]});if(!_0x57949f)throw new Error(_0x36eb('0x49'));if(_0x57949f[_0x36eb('0x4a')]===_0x36eb('0x47')){var _0x315f2d=_0x5df3f0[_0x36eb('0x48')]({'plain':!![]});var _0x4a363e=_0x36eb('0x26');return db[_0x36eb('0x4b')][_0x36eb('0x4c')]({'where':{'name':_0x4a363e,'userProfileId':_0x57949f[_0x36eb('0x4d')]},'raw':!![]})[_0x36eb('0x24')](function(_0x359036){if(_0x359036&&_0x359036[_0x36eb('0x4e')]===0x0){return db[_0x36eb('0x27')][_0x36eb('0x45')]({'name':_0x315f2d[_0x36eb('0x2a')],'resourceId':_0x315f2d['id'],'type':_0x359036[_0x36eb('0x2a')],'sectionId':_0x359036['id']},{})[_0x36eb('0x24')](function(){return _0x5df3f0;});}else{return _0x5df3f0;}})[_0x36eb('0x43')](function(_0xfd382){logger[_0x36eb('0x28')](_0x36eb('0x4f'),_0xfd382);throw _0xfd382;});}return _0x5df3f0;})[_0x36eb('0x24')](respondWithResult(_0x369a30,0xc9))[_0x36eb('0x43')](handleError(_0x369a30,null));};exports[_0x36eb('0x23')]=function(_0x588070,_0x57bb17){if(_0x588070[_0x36eb('0x46')]['id']){delete _0x588070[_0x36eb('0x46')]['id'];}return db[_0x36eb('0x3d')][_0x36eb('0x4c')]({'where':{'id':_0x588070[_0x36eb('0x44')]['id']}})[_0x36eb('0x24')](handleEntityNotFound(_0x57bb17,null))[_0x36eb('0x24')](saveUpdates(_0x588070[_0x36eb('0x46')],null))[_0x36eb('0x24')](respondWithResult(_0x57bb17,null))['catch'](handleError(_0x57bb17,null));};exports[_0x36eb('0x25')]=function(_0x327399,_0x50a91e){return db['WhatsappQueue'][_0x36eb('0x4c')]({'where':{'id':_0x327399[_0x36eb('0x44')]['id']}})['then'](handleEntityNotFound(_0x50a91e,null))[_0x36eb('0x24')](removeEntity(_0x50a91e,null))['catch'](handleError(_0x50a91e,null));};exports[_0x36eb('0x50')]=function(_0x10e682,_0x31f36a){return db[_0x36eb('0x3d')][_0x36eb('0x50')]()[_0x36eb('0x24')](respondWithResult(_0x31f36a,null))[_0x36eb('0x43')](handleError(_0x31f36a,null));};exports['getMembers']=function(_0x51254e,_0x212745,_0x364f53){var _0x47c123={'raw':!![],'where':{}},_0x5eadca={},_0x2a6914;return db[_0x36eb('0x3d')][_0x36eb('0x51')]({'where':{'id':_0x51254e['params']['id']}})[_0x36eb('0x24')](handleEntityNotFound(_0x212745,null))['then'](function(_0x3c2cb0){if(_0x3c2cb0){_0x2a6914=_0x3c2cb0[_0x36eb('0x48')]({'plain':!![]});_0x5eadca[_0x36eb('0x2d')]=_[_0x36eb('0x2f')](db[_0x36eb('0x52')][_0x36eb('0x2c')]);_0x5eadca[_0x36eb('0x2e')]=_[_0x36eb('0x2f')](_0x51254e['query']);_0x5eadca['filters']=_[_0x36eb('0x32')](_0x5eadca['model'],_0x5eadca[_0x36eb('0x2e')]);_0x47c123['attributes']=_['intersection'](_0x5eadca[_0x36eb('0x2d')],qs[_0x36eb('0x33')](_0x51254e[_0x36eb('0x2e')][_0x36eb('0x33')]));_0x47c123[_0x36eb('0x31')]=_0x47c123['attributes'][_0x36eb('0x34')]?_0x47c123[_0x36eb('0x31')]:_0x5eadca[_0x36eb('0x2d')];if(!_0x51254e[_0x36eb('0x2e')][_0x36eb('0x35')](_0x36eb('0x53'))){_0x47c123[_0x36eb('0x21')]=qs[_0x36eb('0x21')](_0x51254e[_0x36eb('0x2e')][_0x36eb('0x21')]);_0x47c123[_0x36eb('0x20')]=qs[_0x36eb('0x20')](_0x51254e[_0x36eb('0x2e')]['offset']);}_0x47c123[_0x36eb('0x36')]=qs[_0x36eb('0x37')](_0x51254e[_0x36eb('0x2e')][_0x36eb('0x37')]);_0x47c123[_0x36eb('0x39')]=qs[_0x36eb('0x30')](_['pick'](_0x51254e[_0x36eb('0x2e')],_0x5eadca[_0x36eb('0x30')]));_0x47c123['where']['WhatsappQueueId']=_0x3c2cb0['id'];if(_0x51254e[_0x36eb('0x2e')]['filter']){_0x47c123['where']=_['merge'](_0x47c123[_0x36eb('0x39')],{'$or':_['map'](_0x47c123[_0x36eb('0x31')],function(_0xeb195a){var _0x4cc8b4={};_0x4cc8b4[_0xeb195a]={'$like':'%'+_0x51254e[_0x36eb('0x2e')][_0x36eb('0x3b')]+'%'};return _0x4cc8b4;})});}_0x47c123=_[_0x36eb('0x3a')]({},_0x47c123,_0x51254e[_0x36eb('0x3c')]);return db[_0x36eb('0x52')][_0x36eb('0x41')](_0x47c123);}})['then'](function(_0x1426f6){if(_0x1426f6){return db[_0x36eb('0x54')]['findAndCountAll']({'where':{'id':_[_0x36eb('0x2b')](_0x1426f6,_0x36eb('0x55')),'role':_0x36eb('0x56')},'attributes':['id',_0x36eb('0x2a'),'whatsappPause',_0x36eb('0x57'),_0x36eb('0x58')]});}})['then'](function(_0x494b7f){if(_0x494b7f){return{'count':_0x494b7f[_0x36eb('0x3e')],'rows':_[_0x36eb('0x2b')](_0x494b7f['rows'],function(_0x102646){return{'membername':_0x102646[_0x36eb('0x2a')],'UserId':_0x102646['id'],'queue_name':_0x2a6914[_0x36eb('0x2a')],'WhatsappQueueId':_0x2a6914['id'],'interface':util[_0x36eb('0x59')](_0x36eb('0x5a'),_0x36eb('0x5b'),_0x102646[_0x36eb('0x2a')]),'penalty':0x0,'paused':_0x102646[_0x36eb('0x5c')],'createdAt':_0x102646[_0x36eb('0x58')],'updatedAt':_0x102646[_0x36eb('0x57')]};})};}else{return{'count':0x0,'rows':[]};}})['then'](respondWithFilteredResult(_0x212745,_0x47c123))[_0x36eb('0x43')](handleError(_0x212745,null));};exports[_0x36eb('0x5d')]=function(_0x47688d,_0x536936,_0x5e2898){var _0x1a5699={};var _0x5abfce={};var _0x10b917;var _0x329866;return db[_0x36eb('0x3d')][_0x36eb('0x51')]({'where':{'id':_0x47688d['params']['id']}})['then'](handleEntityNotFound(_0x536936,null))[_0x36eb('0x24')](function(_0x46b002){if(_0x46b002){_0x10b917=_0x46b002;_0x5abfce[_0x36eb('0x2d')]=_[_0x36eb('0x2f')](db[_0x36eb('0x5e')]['rawAttributes']);_0x5abfce['query']=_['keys'](_0x47688d[_0x36eb('0x2e')]);_0x5abfce['filters']=_[_0x36eb('0x32')](_0x5abfce[_0x36eb('0x2d')],_0x5abfce[_0x36eb('0x2e')]);_0x1a5699['attributes']=_[_0x36eb('0x32')](_0x5abfce[_0x36eb('0x2d')],qs[_0x36eb('0x33')](_0x47688d[_0x36eb('0x2e')][_0x36eb('0x33')]));_0x1a5699['attributes']=_0x1a5699[_0x36eb('0x31')][_0x36eb('0x34')]?_0x1a5699[_0x36eb('0x31')]:_0x5abfce['model'];_0x1a5699[_0x36eb('0x36')]=qs[_0x36eb('0x37')](_0x47688d['query'][_0x36eb('0x37')]);_0x1a5699[_0x36eb('0x39')]=qs[_0x36eb('0x30')](_[_0x36eb('0x38')](_0x47688d[_0x36eb('0x2e')],_0x5abfce['filters']));if(_0x47688d[_0x36eb('0x2e')]['filter']){_0x1a5699[_0x36eb('0x39')]=_[_0x36eb('0x3a')](_0x1a5699['where'],{'$or':_['map'](_0x1a5699[_0x36eb('0x31')],function(_0x4b0050){var _0x4cc316={};_0x4cc316[_0x4b0050]={'$like':'%'+_0x47688d[_0x36eb('0x2e')][_0x36eb('0x3b')]+'%'};return _0x4cc316;})});}_0x1a5699=_[_0x36eb('0x3a')]({},_0x1a5699,_0x47688d[_0x36eb('0x3c')]);return _0x10b917[_0x36eb('0x5d')](_0x1a5699);}})[_0x36eb('0x24')](function(_0x3ae435){if(_0x3ae435){_0x329866=_0x3ae435[_0x36eb('0x34')];if(!_0x47688d[_0x36eb('0x2e')]['hasOwnProperty'](_0x36eb('0x53'))){_0x1a5699['limit']=qs['limit'](_0x47688d[_0x36eb('0x2e')][_0x36eb('0x21')]);_0x1a5699[_0x36eb('0x20')]=qs[_0x36eb('0x20')](_0x47688d[_0x36eb('0x2e')]['offset']);}return _0x10b917[_0x36eb('0x5d')](_0x1a5699);}})[_0x36eb('0x24')](function(_0x109fff){if(_0x109fff){return _0x109fff?{'count':_0x329866,'rows':_0x109fff}:null;}})['then'](respondWithResult(_0x536936,null))[_0x36eb('0x43')](handleError(_0x536936,null));};exports[_0x36eb('0x5f')]=function(_0x26cf29,_0x5b3707,_0x16ad5d){var _0x5a5e2c=_0x26cf29[_0x36eb('0x46')][_0x36eb('0x60')];return db[_0x36eb('0x5e')][_0x36eb('0x41')]({'where':{'id':_0x5a5e2c},'attributes':['id'],'include':[{'model':db[_0x36eb('0x54')],'as':'Agents','attributes':['id','name',_0x36eb('0x61'),_0x36eb('0x62'),_0x36eb('0x63')],'raw':!![]}]})[_0x36eb('0x24')](function(_0x3d7afa){if(_0x3d7afa){var _0x12b5a7=_['flatMap'](_0x3d7afa,function(_0x3ec70f){var _0x2a6209=_0x3ec70f[_0x36eb('0x48')]({'plain':!![]});return _0x2a6209[_0x36eb('0x64')];});return db[_0x36eb('0x3d')][_0x36eb('0x4c')]({'where':{'id':_0x26cf29[_0x36eb('0x44')]['id']}})[_0x36eb('0x24')](function(_0x5d116a){return db['sequelize'][_0x36eb('0x65')](function(_0x58c09a){return _0x5d116a['addTeams'](_0x5a5e2c,{'transaction':_0x58c09a})[_0x36eb('0x24')](function(){return BPromise['each'](_0x12b5a7,function(_0x4772f8){return db[_0x36eb('0x52')][_0x36eb('0x66')]({'where':{'UserId':_0x4772f8['id'],'WhatsappQueueId':_0x26cf29['params']['id']},'transaction':_0x58c09a});});})[_0x36eb('0x24')](function(){_0x12b5a7[_0x36eb('0x67')](function(_0x4b8c63){socket[_0x36eb('0x68')](_0x36eb('0x69'),{'UserId':_0x4b8c63['id'],'WhatsappQueueId':_0x5d116a['id']});});});});});}})['then'](respondWithStatusCode(_0x5b3707,null))[_0x36eb('0x43')](handleError(_0x5b3707,null));};exports[_0x36eb('0x6a')]=function(_0x26d393,_0x14e515,_0x2c476f){return db[_0x36eb('0x5e')][_0x36eb('0x41')]({'where':{'id':_0x26d393[_0x36eb('0x2e')][_0x36eb('0x60')]},'attributes':['id'],'include':[{'model':db['User'],'as':_0x36eb('0x64'),'attributes':['id'],'raw':!![]}]})[_0x36eb('0x24')](handleEntityNotFound(_0x14e515,null))[_0x36eb('0x24')](function(_0x393784){var _0x1d2042=_[_0x36eb('0x2b')](_0x393784,'id');var _0x378b76=[];var _0x399bf5=[];var _0x2e404c=squel[_0x36eb('0x6b')]();_0x2e404c[_0x36eb('0x6c')](_0x36eb('0x6d'))[_0x36eb('0x6e')]('team_has_whatsapp_queues','tq')[_0x36eb('0x6f')](_0x36eb('0x70'),'ut',_0x36eb('0x71'))['where'](_0x36eb('0x72'),_0x26d393[_0x36eb('0x44')]['id']);for(var _0x3d9f09=0x0;_0x3d9f09<_0x393784[_0x36eb('0x34')];_0x3d9f09+=0x1){let _0x440115=_0x393784[_0x3d9f09];for(var _0x3c5002=0x0;_0x3c5002<_0x440115['Agents']['length'];_0x3c5002+=0x1){let _0x5b989e=_0x440115[_0x36eb('0x64')][_0x3c5002];var _0x4f6e03=_0x2e404c[_0x36eb('0x73')]();_0x4f6e03['where'](_0x36eb('0x74'),_0x5b989e['id']);_0x399bf5[_0x36eb('0x75')](db[_0x36eb('0x76')]['query'](_0x4f6e03[_0x36eb('0x77')](),{'type':db[_0x36eb('0x76')][_0x36eb('0x78')][_0x36eb('0x79')]})[_0x36eb('0x24')](function(_0x4179b4){if(_0x4179b4['length']===0x1){return _0x5b989e['id'];}else{var _0x2dc9dd=_[_0x36eb('0x7a')](_['map'](_0x4179b4,_0x36eb('0x7b')),function(_0x1ed583){return _[_0x36eb('0x7c')](_0x1d2042,_0x1ed583);});if(_0x2dc9dd){return _0x5b989e['id'];}}}));}}return BPromise['all'](_0x399bf5)['then'](function(_0x4bc1a8){_0x378b76=_(_0x378b76)['union'](_0x4bc1a8)[_0x36eb('0x7d')]()[_0x36eb('0x7e')]();return db[_0x36eb('0x3d')][_0x36eb('0x4c')]({'where':{'id':_0x26d393[_0x36eb('0x44')]['id']}})[_0x36eb('0x24')](function(_0x1fb62a){return db[_0x36eb('0x76')][_0x36eb('0x65')](function(_0x43c595){return _0x1fb62a[_0x36eb('0x6a')](_0x26d393[_0x36eb('0x2e')][_0x36eb('0x60')],{'transaction':_0x43c595})[_0x36eb('0x24')](function(){if(!_[_0x36eb('0x7f')](_0x378b76)){return _0x1fb62a[_0x36eb('0x80')](_0x378b76,{'transaction':_0x43c595});}})['then'](function(){_0x378b76[_0x36eb('0x67')](function(_0x170df1){socket[_0x36eb('0x68')](_0x36eb('0x81'),{'UserId':_0x170df1,'WhatsappQueueId':_0x1fb62a['id']});});});});});});})[_0x36eb('0x24')](respondWithStatusCode(_0x14e515,null))[_0x36eb('0x43')](handleError(_0x14e515,null));};exports[_0x36eb('0x82')]=function(_0x359560,_0x577737,_0x36f8df){return db['WhatsappQueue'][_0x36eb('0x4c')]({'where':{'id':_0x359560[_0x36eb('0x44')]['id']}})[_0x36eb('0x24')](handleEntityNotFound(_0x577737,null))[_0x36eb('0x24')](function(_0x3d5adf){if(_0x3d5adf){return _0x3d5adf[_0x36eb('0x82')](_0x359560[_0x36eb('0x46')][_0x36eb('0x60')],_[_0x36eb('0x83')](_0x359560[_0x36eb('0x46')],[_0x36eb('0x60'),'id'])||{})[_0x36eb('0x84')](function(_0x2a80ed){for(var _0x573eaa=0x0;_0x573eaa<_0x359560[_0x36eb('0x46')][_0x36eb('0x60')][_0x36eb('0x34')];_0x573eaa+=0x1){socket[_0x36eb('0x68')]('userWhatsappQueue:save',{'UserId':_0x359560[_0x36eb('0x46')]['ids'][_0x573eaa],'WhatsappQueueId':_0x359560['params']['id']});}return _0x2a80ed;});}})[_0x36eb('0x24')](respondWithResult(_0x577737,null))['catch'](handleError(_0x577737,null));};exports[_0x36eb('0x80')]=function(_0x5a9517,_0x429883,_0x455959){return db[_0x36eb('0x3d')][_0x36eb('0x4c')]({'where':{'id':_0x5a9517[_0x36eb('0x44')]['id']}})[_0x36eb('0x24')](handleEntityNotFound(_0x429883,null))['then'](function(_0x145a86){if(_0x145a86){return _0x145a86[_0x36eb('0x80')](_0x5a9517[_0x36eb('0x2e')][_0x36eb('0x60')])['then'](function(){if(_['isArray'](_0x5a9517[_0x36eb('0x2e')][_0x36eb('0x60')])){for(var _0x469826=0x0;_0x469826<_0x5a9517[_0x36eb('0x2e')][_0x36eb('0x60')]['length'];_0x469826+=0x1){socket[_0x36eb('0x68')](_0x36eb('0x81'),{'UserId':Number(_0x5a9517[_0x36eb('0x2e')][_0x36eb('0x60')][_0x469826]),'WhatsappQueueId':Number(_0x5a9517[_0x36eb('0x44')]['id'])});}}else{socket[_0x36eb('0x68')](_0x36eb('0x81'),{'UserId':Number(_0x5a9517[_0x36eb('0x2e')][_0x36eb('0x60')]),'WhatsappQueueId':Number(_0x5a9517[_0x36eb('0x44')]['id'])});}});}})['then'](respondWithStatusCode(_0x429883,null))[_0x36eb('0x43')](handleError(_0x429883,null));};exports[_0x36eb('0x85')]=function(_0x3d44b2,_0x5ad902,_0x57a999){var _0x47b2d1={};var _0x1b4190={};var _0x25f9bd;var _0x2f7a77;return db[_0x36eb('0x3d')]['findOne']({'where':{'id':_0x3d44b2[_0x36eb('0x44')]['id']}})['then'](handleEntityNotFound(_0x5ad902,null))[_0x36eb('0x24')](function(_0x4c2e7f){if(_0x4c2e7f){_0x25f9bd=_0x4c2e7f;_0x1b4190[_0x36eb('0x2d')]=_[_0x36eb('0x2f')](db[_0x36eb('0x54')][_0x36eb('0x2c')]);_0x1b4190[_0x36eb('0x2e')]=_['keys'](_0x3d44b2[_0x36eb('0x2e')]);_0x1b4190[_0x36eb('0x30')]=_['intersection'](_0x1b4190[_0x36eb('0x2d')],_0x1b4190[_0x36eb('0x2e')]);_0x47b2d1['attributes']=_['intersection'](_0x1b4190[_0x36eb('0x2d')],qs[_0x36eb('0x33')](_0x3d44b2['query']['fields']));_0x47b2d1[_0x36eb('0x31')]=_0x47b2d1[_0x36eb('0x31')][_0x36eb('0x34')]?_0x47b2d1[_0x36eb('0x31')]:_0x1b4190[_0x36eb('0x2d')];_0x47b2d1[_0x36eb('0x36')]=qs[_0x36eb('0x37')](_0x3d44b2[_0x36eb('0x2e')][_0x36eb('0x37')]);_0x47b2d1[_0x36eb('0x39')]=qs[_0x36eb('0x30')](_['pick'](_0x3d44b2['query'],_0x1b4190[_0x36eb('0x30')]));if(_0x3d44b2['query'][_0x36eb('0x3b')]){_0x47b2d1[_0x36eb('0x39')]=_[_0x36eb('0x3a')](_0x47b2d1[_0x36eb('0x39')],{'$or':_[_0x36eb('0x2b')](_0x47b2d1['attributes'],function(_0x1da6f2){var _0x178a37={};_0x178a37[_0x1da6f2]={'$like':'%'+_0x3d44b2[_0x36eb('0x2e')][_0x36eb('0x3b')]+'%'};return _0x178a37;})});}_0x47b2d1=_[_0x36eb('0x3a')]({},_0x47b2d1,_0x3d44b2[_0x36eb('0x3c')]);return _0x25f9bd[_0x36eb('0x85')](_0x47b2d1);}})[_0x36eb('0x24')](function(_0x1e4809){if(_0x1e4809){_0x2f7a77=_0x1e4809[_0x36eb('0x34')];if(!_0x3d44b2['query'][_0x36eb('0x35')](_0x36eb('0x53'))){_0x47b2d1['limit']=qs[_0x36eb('0x21')](_0x3d44b2[_0x36eb('0x2e')][_0x36eb('0x21')]);_0x47b2d1[_0x36eb('0x20')]=qs[_0x36eb('0x20')](_0x3d44b2[_0x36eb('0x2e')][_0x36eb('0x20')]);}return _0x25f9bd[_0x36eb('0x85')](_0x47b2d1);}})['then'](function(_0x5d65be){if(_0x5d65be){return _0x5d65be?{'count':_0x2f7a77,'rows':_0x5d65be}:null;}})[_0x36eb('0x24')](respondWithResult(_0x5ad902,null))[_0x36eb('0x43')](handleError(_0x5ad902,null));};
\ No newline at end of file
+var _0x6c03=['addAgents','omit','userWhatsappQueue:remove','getAgents','html-pdf','rimraf','fast-json-patch','request-promise','moment','bluebird','mustache','path','sox','to-csv','squel','jsforce','desk.js','querystring','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/utils','../../config/license/util','redis','defaults','localhost','socket.io-emitter','./whatsappQueue.socket','status','end','json','count','offset','limit','set','save','then','WhatsappQueues','UserProfileResource','destroy','sendStatus','error','stack','name','index','map','WhatsappQueue','rawAttributes','fieldName','type','key','model','query','keys','filters','intersection','attributes','fields','length','nolimit','order','sort','where','pick','VIRTUAL','filter','options','includeAll','rows','params','merge','catch','create','body','user','get','Unable\x20to\x20retrieve\x20the\x20current\x20user','UserProfileSection','find','userProfileId','autoAssociation','update','getMembers','findOne','UserWhatsappQueue','hasOwnProperty','WhatsappQueueId','findAll','findAndCountAll','UserId','agent','whatsappPause','updatedAt','format','SIP','createdAt','getTeams','Team','addTeams','User','Agents','voicePause','interface','flatMap','sequelize','transaction','findOrCreate','forEach','emit','userWhatsappQueue:save','removeTeams','ids','select','tq.TeamId','from','team_has_whatsapp_queues','join','user_has_teams','ut.TeamId\x20=\x20tq.TeamId','WhatsappQueueId\x20=\x20?','clone','ut.UserId\x20=\x20?','push','toString','SELECT','includes','all','union','value','isEmpty','removeAgents'];(function(_0x5f0089,_0x227e2c){var _0x193892=function(_0x24051f){while(--_0x24051f){_0x5f0089['push'](_0x5f0089['shift']());}};_0x193892(++_0x227e2c);}(_0x6c03,0x8a));var _0x36c0=function(_0xff1e8d,_0x2439e8){_0xff1e8d=_0xff1e8d-0x0;var _0xe07823=_0x6c03[_0xff1e8d];return _0xe07823;};'use strict';var pdf=require(_0x36c0('0x0'));var emlformat=require('eml-format');var rimraf=require(_0x36c0('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0x36c0('0x2'));var rp=require(_0x36c0('0x3'));var moment=require(_0x36c0('0x4'));var BPromise=require(_0x36c0('0x5'));var Mustache=require(_0x36c0('0x6'));var util=require('util');var path=require(_0x36c0('0x7'));var sox=require(_0x36c0('0x8'));var csv=require(_0x36c0('0x9'));var ejs=require('ejs');var fs=require('fs');var _=require('lodash');var squel=require(_0x36c0('0xa'));var crypto=require('crypto');var jsforce=require(_0x36c0('0xb'));var deskjs=require(_0x36c0('0xc'));var toCsv=require(_0x36c0('0x9'));var querystring=require(_0x36c0('0xd'));var Papa=require('papaparse');var Redis=require(_0x36c0('0xe'));var authService=require(_0x36c0('0xf'));var qs=require(_0x36c0('0x10'));var as=require(_0x36c0('0x11'));var hardwareService=require(_0x36c0('0x12'));var logger=require('../../config/logger')(_0x36c0('0x13'));var utils=require(_0x36c0('0x14'));var config=require('../../config/environment');var licenseUtil=require(_0x36c0('0x15'));var db=require('../../mysqldb')['db'];config[_0x36c0('0x16')]=_[_0x36c0('0x17')](config[_0x36c0('0x16')],{'host':_0x36c0('0x18'),'port':0x18eb});var socket=require(_0x36c0('0x19'))(new Redis(config[_0x36c0('0x16')]));require(_0x36c0('0x1a'))['register'](socket);function respondWithStatusCode(_0x1649a9,_0x323a52){_0x323a52=_0x323a52||0xcc;return function(_0x2903bf){if(_0x2903bf){return _0x1649a9['sendStatus'](_0x323a52);}return _0x1649a9[_0x36c0('0x1b')](_0x323a52)[_0x36c0('0x1c')]();};}function respondWithResult(_0x2a2977,_0x193984){_0x193984=_0x193984||0xc8;return function(_0x581087){if(_0x581087){return _0x2a2977[_0x36c0('0x1b')](_0x193984)[_0x36c0('0x1d')](_0x581087);}};}function respondWithFilteredResult(_0x4e1064,_0x2be426){return function(_0x12fd67){if(_0x12fd67){var _0xb6b642=_0x12fd67[_0x36c0('0x1e')],_0x127817=_0x2be426[_0x36c0('0x1f')],_0x5607a4=_0x2be426[_0x36c0('0x1f')]+_0x2be426[_0x36c0('0x20')],_0x2492ee;if(_0x5607a4>=_0xb6b642){_0x5607a4=_0xb6b642;_0x2492ee=0xc8;}else{_0x2492ee=0xce;}_0x4e1064['status'](_0x2492ee);return _0x4e1064[_0x36c0('0x21')]('Content-Range',_0x127817+'-'+_0x5607a4+'/'+_0xb6b642)[_0x36c0('0x1d')](_0x12fd67);}return null;};}function patchUpdates(_0x5803c4){return function(_0x2c5307){try{jsonpatch['apply'](_0x2c5307,_0x5803c4,!![]);}catch(_0x54895e){return BPromise['reject'](_0x54895e);}return _0x2c5307[_0x36c0('0x22')]();};}function saveUpdates(_0x3e9e3c,_0x43ae32){return function(_0x35c7f9){if(_0x35c7f9){return _0x35c7f9['update'](_0x3e9e3c)[_0x36c0('0x23')](function(_0x5b6db1){return _0x5b6db1;});}return null;};}function removeEntity(_0x55b161,_0xc70666){return function(_0x4212b1){if(_0x4212b1){return _0x4212b1['destroy']()[_0x36c0('0x23')](function(){var _0x103dfb=_0x4212b1['get']({'plain':!![]});var _0x45d0f7=_0x36c0('0x24');return db[_0x36c0('0x25')][_0x36c0('0x26')]({'where':{'type':_0x45d0f7,'resourceId':_0x103dfb['id']}})['then'](function(){return _0x4212b1;});})['then'](function(){_0x55b161['status'](0xcc)[_0x36c0('0x1c')]();});}};}function handleEntityNotFound(_0x37cda2,_0x389a32){return function(_0x5e66ba){if(!_0x5e66ba){_0x37cda2[_0x36c0('0x27')](0x194);}return _0x5e66ba;};}function handleError(_0x427be8,_0x2d4ff3){_0x2d4ff3=_0x2d4ff3||0x1f4;return function(_0xd6d4e){logger[_0x36c0('0x28')](_0xd6d4e[_0x36c0('0x29')]);if(_0xd6d4e[_0x36c0('0x2a')]){delete _0xd6d4e['name'];}_0x427be8[_0x36c0('0x1b')](_0x2d4ff3)['send'](_0xd6d4e);};}exports[_0x36c0('0x2b')]=function(_0xba1666,_0x38497f){var _0x4a0d3a={},_0x441964={},_0x3f53e9={'count':0x0,'rows':[]};var _0x7c0d4e=_[_0x36c0('0x2c')](db[_0x36c0('0x2d')][_0x36c0('0x2e')],function(_0x3fb8be){return{'name':_0x3fb8be[_0x36c0('0x2f')],'type':_0x3fb8be[_0x36c0('0x30')][_0x36c0('0x31')]};});_0x441964[_0x36c0('0x32')]=_[_0x36c0('0x2c')](_0x7c0d4e,_0x36c0('0x2a'));_0x441964[_0x36c0('0x33')]=_[_0x36c0('0x34')](_0xba1666[_0x36c0('0x33')]);_0x441964[_0x36c0('0x35')]=_[_0x36c0('0x36')](_0x441964[_0x36c0('0x32')],_0x441964[_0x36c0('0x33')]);_0x4a0d3a[_0x36c0('0x37')]=_[_0x36c0('0x36')](_0x441964[_0x36c0('0x32')],qs[_0x36c0('0x38')](_0xba1666[_0x36c0('0x33')][_0x36c0('0x38')]));_0x4a0d3a['attributes']=_0x4a0d3a[_0x36c0('0x37')][_0x36c0('0x39')]?_0x4a0d3a[_0x36c0('0x37')]:_0x441964[_0x36c0('0x32')];if(!_0xba1666[_0x36c0('0x33')]['hasOwnProperty'](_0x36c0('0x3a'))){_0x4a0d3a[_0x36c0('0x20')]=qs[_0x36c0('0x20')](_0xba1666[_0x36c0('0x33')][_0x36c0('0x20')]);_0x4a0d3a[_0x36c0('0x1f')]=qs[_0x36c0('0x1f')](_0xba1666[_0x36c0('0x33')][_0x36c0('0x1f')]);}_0x4a0d3a[_0x36c0('0x3b')]=qs[_0x36c0('0x3c')](_0xba1666['query']['sort']);_0x4a0d3a[_0x36c0('0x3d')]=qs['filters'](_[_0x36c0('0x3e')](_0xba1666[_0x36c0('0x33')],_0x441964[_0x36c0('0x35')]),_0x7c0d4e);if(_0xba1666[_0x36c0('0x33')]['filter']){_0x4a0d3a[_0x36c0('0x3d')]=_['merge'](_0x4a0d3a['where'],{'$or':_[_0x36c0('0x2c')](_0x7c0d4e,function(_0x26f599){if(_0x26f599[_0x36c0('0x30')]!==_0x36c0('0x3f')){var _0x33c826={};_0x33c826[_0x26f599[_0x36c0('0x2a')]]={'$like':'%'+_0xba1666[_0x36c0('0x33')][_0x36c0('0x40')]+'%'};return _0x33c826;}})});}_0x4a0d3a=_['merge']({},_0x4a0d3a,_0xba1666[_0x36c0('0x41')]);var _0x12b56c={'where':_0x4a0d3a[_0x36c0('0x3d')]};return db['WhatsappQueue'][_0x36c0('0x1e')](_0x12b56c)[_0x36c0('0x23')](function(_0xd3e3d8){_0x3f53e9['count']=_0xd3e3d8;if(_0xba1666[_0x36c0('0x33')][_0x36c0('0x42')]){_0x4a0d3a['include']=[{'all':!![]}];}return db['WhatsappQueue']['findAll'](_0x4a0d3a);})[_0x36c0('0x23')](function(_0x240340){_0x3f53e9[_0x36c0('0x43')]=_0x240340;return _0x3f53e9;})[_0x36c0('0x23')](respondWithFilteredResult(_0x38497f,_0x4a0d3a))['catch'](handleError(_0x38497f,null));};exports['show']=function(_0x3e49cb,_0x39c639){var _0xa8877e={'raw':!![],'where':{'id':_0x3e49cb[_0x36c0('0x44')]['id']}},_0x4bacbe={};_0x4bacbe['model']=_[_0x36c0('0x34')](db['WhatsappQueue'][_0x36c0('0x2e')]);_0x4bacbe[_0x36c0('0x33')]=_['keys'](_0x3e49cb[_0x36c0('0x33')]);_0x4bacbe[_0x36c0('0x35')]=_[_0x36c0('0x36')](_0x4bacbe[_0x36c0('0x32')],_0x4bacbe[_0x36c0('0x33')]);_0xa8877e['attributes']=_[_0x36c0('0x36')](_0x4bacbe[_0x36c0('0x32')],qs[_0x36c0('0x38')](_0x3e49cb[_0x36c0('0x33')][_0x36c0('0x38')]));_0xa8877e[_0x36c0('0x37')]=_0xa8877e['attributes'][_0x36c0('0x39')]?_0xa8877e[_0x36c0('0x37')]:_0x4bacbe[_0x36c0('0x32')];if(_0x3e49cb[_0x36c0('0x33')]['includeAll']){_0xa8877e['include']=[{'all':!![]}];}_0xa8877e=_[_0x36c0('0x45')]({},_0xa8877e,_0x3e49cb[_0x36c0('0x41')]);return db[_0x36c0('0x2d')]['find'](_0xa8877e)[_0x36c0('0x23')](handleEntityNotFound(_0x39c639,null))[_0x36c0('0x23')](respondWithResult(_0x39c639,null))[_0x36c0('0x46')](handleError(_0x39c639,null));};exports[_0x36c0('0x47')]=function(_0x53df9a,_0x25b4e9){return db[_0x36c0('0x2d')]['create'](_0x53df9a[_0x36c0('0x48')],{})[_0x36c0('0x23')](function(_0x1efffa){var _0x14e73a=_0x53df9a[_0x36c0('0x49')][_0x36c0('0x4a')]({'plain':!![]});if(!_0x14e73a)throw new Error(_0x36c0('0x4b'));if(_0x14e73a['role']===_0x36c0('0x49')){var _0x218c72=_0x1efffa[_0x36c0('0x4a')]({'plain':!![]});var _0x4c353a='WhatsappQueues';return db[_0x36c0('0x4c')][_0x36c0('0x4d')]({'where':{'name':_0x4c353a,'userProfileId':_0x14e73a[_0x36c0('0x4e')]},'raw':!![]})[_0x36c0('0x23')](function(_0x17713a){if(_0x17713a&&_0x17713a[_0x36c0('0x4f')]===0x0){return db[_0x36c0('0x25')][_0x36c0('0x47')]({'name':_0x218c72[_0x36c0('0x2a')],'resourceId':_0x218c72['id'],'type':_0x17713a[_0x36c0('0x2a')],'sectionId':_0x17713a['id']},{})[_0x36c0('0x23')](function(){return _0x1efffa;});}else{return _0x1efffa;}})[_0x36c0('0x46')](function(_0x19e380){logger[_0x36c0('0x28')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x19e380);throw _0x19e380;});}return _0x1efffa;})[_0x36c0('0x23')](respondWithResult(_0x25b4e9,0xc9))[_0x36c0('0x46')](handleError(_0x25b4e9,null));};exports[_0x36c0('0x50')]=function(_0x18c059,_0x48a38c){if(_0x18c059[_0x36c0('0x48')]['id']){delete _0x18c059['body']['id'];}return db['WhatsappQueue']['find']({'where':{'id':_0x18c059[_0x36c0('0x44')]['id']}})[_0x36c0('0x23')](handleEntityNotFound(_0x48a38c,null))[_0x36c0('0x23')](saveUpdates(_0x18c059[_0x36c0('0x48')],null))['then'](respondWithResult(_0x48a38c,null))[_0x36c0('0x46')](handleError(_0x48a38c,null));};exports[_0x36c0('0x26')]=function(_0x217cd4,_0x2d7c5a){return db[_0x36c0('0x2d')][_0x36c0('0x4d')]({'where':{'id':_0x217cd4[_0x36c0('0x44')]['id']}})['then'](handleEntityNotFound(_0x2d7c5a,null))[_0x36c0('0x23')](removeEntity(_0x2d7c5a,null))[_0x36c0('0x46')](handleError(_0x2d7c5a,null));};exports['describe']=function(_0x3fff23,_0x49712c){return db[_0x36c0('0x2d')]['describe']()['then'](respondWithResult(_0x49712c,null))[_0x36c0('0x46')](handleError(_0x49712c,null));};exports[_0x36c0('0x51')]=function(_0x4e6454,_0x5ff3e0,_0xe1990c){var _0x3c88ae={'raw':!![],'where':{}},_0x589405={},_0x2f0758;return db[_0x36c0('0x2d')][_0x36c0('0x52')]({'where':{'id':_0x4e6454['params']['id']}})[_0x36c0('0x23')](handleEntityNotFound(_0x5ff3e0,null))[_0x36c0('0x23')](function(_0x330a7a){if(_0x330a7a){_0x2f0758=_0x330a7a[_0x36c0('0x4a')]({'plain':!![]});_0x589405[_0x36c0('0x32')]=_['keys'](db[_0x36c0('0x53')][_0x36c0('0x2e')]);_0x589405['query']=_[_0x36c0('0x34')](_0x4e6454['query']);_0x589405[_0x36c0('0x35')]=_[_0x36c0('0x36')](_0x589405['model'],_0x589405[_0x36c0('0x33')]);_0x3c88ae[_0x36c0('0x37')]=_[_0x36c0('0x36')](_0x589405[_0x36c0('0x32')],qs[_0x36c0('0x38')](_0x4e6454[_0x36c0('0x33')]['fields']));_0x3c88ae[_0x36c0('0x37')]=_0x3c88ae['attributes']['length']?_0x3c88ae[_0x36c0('0x37')]:_0x589405[_0x36c0('0x32')];if(!_0x4e6454[_0x36c0('0x33')][_0x36c0('0x54')](_0x36c0('0x3a'))){_0x3c88ae[_0x36c0('0x20')]=qs['limit'](_0x4e6454[_0x36c0('0x33')][_0x36c0('0x20')]);_0x3c88ae[_0x36c0('0x1f')]=qs[_0x36c0('0x1f')](_0x4e6454[_0x36c0('0x33')][_0x36c0('0x1f')]);}_0x3c88ae[_0x36c0('0x3b')]=qs['sort'](_0x4e6454['query']['sort']);_0x3c88ae['where']=qs[_0x36c0('0x35')](_[_0x36c0('0x3e')](_0x4e6454[_0x36c0('0x33')],_0x589405['filters']));_0x3c88ae[_0x36c0('0x3d')][_0x36c0('0x55')]=_0x330a7a['id'];if(_0x4e6454[_0x36c0('0x33')][_0x36c0('0x40')]){_0x3c88ae[_0x36c0('0x3d')]=_[_0x36c0('0x45')](_0x3c88ae[_0x36c0('0x3d')],{'$or':_[_0x36c0('0x2c')](_0x3c88ae[_0x36c0('0x37')],function(_0x332e5b){var _0xba79ef={};_0xba79ef[_0x332e5b]={'$like':'%'+_0x4e6454[_0x36c0('0x33')][_0x36c0('0x40')]+'%'};return _0xba79ef;})});}_0x3c88ae=_['merge']({},_0x3c88ae,_0x4e6454['options']);return db['UserWhatsappQueue'][_0x36c0('0x56')](_0x3c88ae);}})['then'](function(_0x4a461d){if(_0x4a461d){return db['User'][_0x36c0('0x57')]({'where':{'id':_[_0x36c0('0x2c')](_0x4a461d,_0x36c0('0x58')),'role':_0x36c0('0x59')},'attributes':['id','name',_0x36c0('0x5a'),_0x36c0('0x5b'),'createdAt']});}})[_0x36c0('0x23')](function(_0x3ef1fa){if(_0x3ef1fa){return{'count':_0x3ef1fa[_0x36c0('0x1e')],'rows':_[_0x36c0('0x2c')](_0x3ef1fa[_0x36c0('0x43')],function(_0xe1359c){return{'membername':_0xe1359c[_0x36c0('0x2a')],'UserId':_0xe1359c['id'],'queue_name':_0x2f0758[_0x36c0('0x2a')],'WhatsappQueueId':_0x2f0758['id'],'interface':util[_0x36c0('0x5c')]('%s/%s',_0x36c0('0x5d'),_0xe1359c[_0x36c0('0x2a')]),'penalty':0x0,'paused':_0xe1359c[_0x36c0('0x5a')],'createdAt':_0xe1359c[_0x36c0('0x5e')],'updatedAt':_0xe1359c[_0x36c0('0x5b')]};})};}else{return{'count':0x0,'rows':[]};}})[_0x36c0('0x23')](respondWithFilteredResult(_0x5ff3e0,_0x3c88ae))[_0x36c0('0x46')](handleError(_0x5ff3e0,null));};exports[_0x36c0('0x5f')]=function(_0x13b75f,_0x442138,_0x2f9b15){var _0x3c2726={};var _0x234449={};var _0x2368ba;var _0x574643;return db[_0x36c0('0x2d')][_0x36c0('0x52')]({'where':{'id':_0x13b75f[_0x36c0('0x44')]['id']}})['then'](handleEntityNotFound(_0x442138,null))[_0x36c0('0x23')](function(_0x48957d){if(_0x48957d){_0x2368ba=_0x48957d;_0x234449[_0x36c0('0x32')]=_['keys'](db[_0x36c0('0x60')][_0x36c0('0x2e')]);_0x234449[_0x36c0('0x33')]=_[_0x36c0('0x34')](_0x13b75f['query']);_0x234449['filters']=_[_0x36c0('0x36')](_0x234449[_0x36c0('0x32')],_0x234449[_0x36c0('0x33')]);_0x3c2726[_0x36c0('0x37')]=_[_0x36c0('0x36')](_0x234449[_0x36c0('0x32')],qs[_0x36c0('0x38')](_0x13b75f[_0x36c0('0x33')][_0x36c0('0x38')]));_0x3c2726['attributes']=_0x3c2726[_0x36c0('0x37')][_0x36c0('0x39')]?_0x3c2726['attributes']:_0x234449[_0x36c0('0x32')];_0x3c2726[_0x36c0('0x3b')]=qs[_0x36c0('0x3c')](_0x13b75f[_0x36c0('0x33')]['sort']);_0x3c2726[_0x36c0('0x3d')]=qs[_0x36c0('0x35')](_[_0x36c0('0x3e')](_0x13b75f[_0x36c0('0x33')],_0x234449[_0x36c0('0x35')]));if(_0x13b75f[_0x36c0('0x33')][_0x36c0('0x40')]){_0x3c2726[_0x36c0('0x3d')]=_[_0x36c0('0x45')](_0x3c2726[_0x36c0('0x3d')],{'$or':_['map'](_0x3c2726[_0x36c0('0x37')],function(_0x4cfa98){var _0x117c99={};_0x117c99[_0x4cfa98]={'$like':'%'+_0x13b75f[_0x36c0('0x33')][_0x36c0('0x40')]+'%'};return _0x117c99;})});}_0x3c2726=_['merge']({},_0x3c2726,_0x13b75f[_0x36c0('0x41')]);return _0x2368ba['getTeams'](_0x3c2726);}})['then'](function(_0xc5c964){if(_0xc5c964){_0x574643=_0xc5c964[_0x36c0('0x39')];if(!_0x13b75f[_0x36c0('0x33')][_0x36c0('0x54')]('nolimit')){_0x3c2726['limit']=qs[_0x36c0('0x20')](_0x13b75f[_0x36c0('0x33')]['limit']);_0x3c2726['offset']=qs[_0x36c0('0x1f')](_0x13b75f[_0x36c0('0x33')][_0x36c0('0x1f')]);}return _0x2368ba['getTeams'](_0x3c2726);}})[_0x36c0('0x23')](function(_0x4faee6){if(_0x4faee6){return _0x4faee6?{'count':_0x574643,'rows':_0x4faee6}:null;}})[_0x36c0('0x23')](respondWithResult(_0x442138,null))[_0x36c0('0x46')](handleError(_0x442138,null));};exports[_0x36c0('0x61')]=function(_0x4ff362,_0x3574fa,_0x403843){var _0x345092=_0x4ff362['body']['ids'];return db[_0x36c0('0x60')][_0x36c0('0x56')]({'where':{'id':_0x345092},'attributes':['id'],'include':[{'model':db[_0x36c0('0x62')],'as':_0x36c0('0x63'),'attributes':['id','name','online',_0x36c0('0x64'),_0x36c0('0x65')],'raw':!![]}]})[_0x36c0('0x23')](function(_0xe49f3){if(_0xe49f3){var _0x38b6ba=_[_0x36c0('0x66')](_0xe49f3,function(_0x1aabee){var _0x41a5a7=_0x1aabee['get']({'plain':!![]});return _0x41a5a7[_0x36c0('0x63')];});return db[_0x36c0('0x2d')][_0x36c0('0x4d')]({'where':{'id':_0x4ff362[_0x36c0('0x44')]['id']}})[_0x36c0('0x23')](function(_0x9de1c9){return db[_0x36c0('0x67')][_0x36c0('0x68')](function(_0x11a8f8){return _0x9de1c9[_0x36c0('0x61')](_0x345092,{'transaction':_0x11a8f8})[_0x36c0('0x23')](function(){return BPromise['each'](_0x38b6ba,function(_0x5d468d){return db[_0x36c0('0x53')][_0x36c0('0x69')]({'where':{'UserId':_0x5d468d['id'],'WhatsappQueueId':_0x4ff362[_0x36c0('0x44')]['id']},'transaction':_0x11a8f8});});})[_0x36c0('0x23')](function(){_0x38b6ba[_0x36c0('0x6a')](function(_0x6d28c7){socket[_0x36c0('0x6b')](_0x36c0('0x6c'),{'UserId':_0x6d28c7['id'],'WhatsappQueueId':_0x9de1c9['id']});});});});});}})[_0x36c0('0x23')](respondWithStatusCode(_0x3574fa,null))[_0x36c0('0x46')](handleError(_0x3574fa,null));};exports[_0x36c0('0x6d')]=function(_0x47bcd8,_0x470ec9,_0x5b208b){return db['Team'][_0x36c0('0x56')]({'where':{'id':_0x47bcd8[_0x36c0('0x33')][_0x36c0('0x6e')]},'attributes':['id'],'include':[{'model':db[_0x36c0('0x62')],'as':_0x36c0('0x63'),'attributes':['id'],'raw':!![]}]})['then'](handleEntityNotFound(_0x470ec9,null))[_0x36c0('0x23')](function(_0x3b82ac){var _0x3c9453=_['map'](_0x3b82ac,'id');var _0x3b6ea2=[];var _0xda4dd0=[];var _0x309781=squel[_0x36c0('0x6f')]();_0x309781['field'](_0x36c0('0x70'))[_0x36c0('0x71')](_0x36c0('0x72'),'tq')[_0x36c0('0x73')](_0x36c0('0x74'),'ut',_0x36c0('0x75'))[_0x36c0('0x3d')](_0x36c0('0x76'),_0x47bcd8['params']['id']);for(var _0x3279a2=0x0;_0x3279a2<_0x3b82ac['length'];_0x3279a2+=0x1){let _0x2f50a9=_0x3b82ac[_0x3279a2];for(var _0x222eb2=0x0;_0x222eb2<_0x2f50a9[_0x36c0('0x63')][_0x36c0('0x39')];_0x222eb2+=0x1){let _0x45f324=_0x2f50a9[_0x36c0('0x63')][_0x222eb2];var _0x46f6f2=_0x309781[_0x36c0('0x77')]();_0x46f6f2[_0x36c0('0x3d')](_0x36c0('0x78'),_0x45f324['id']);_0xda4dd0[_0x36c0('0x79')](db[_0x36c0('0x67')]['query'](_0x46f6f2[_0x36c0('0x7a')](),{'type':db[_0x36c0('0x67')]['QueryTypes'][_0x36c0('0x7b')]})[_0x36c0('0x23')](function(_0x18a895){if(_0x18a895[_0x36c0('0x39')]===0x1){return _0x45f324['id'];}else{var _0x267842=_['every'](_[_0x36c0('0x2c')](_0x18a895,'TeamId'),function(_0x25b9eb){return _[_0x36c0('0x7c')](_0x3c9453,_0x25b9eb);});if(_0x267842){return _0x45f324['id'];}}}));}}return BPromise[_0x36c0('0x7d')](_0xda4dd0)[_0x36c0('0x23')](function(_0x5b3f9c){_0x3b6ea2=_(_0x3b6ea2)[_0x36c0('0x7e')](_0x5b3f9c)['compact']()[_0x36c0('0x7f')]();return db[_0x36c0('0x2d')][_0x36c0('0x4d')]({'where':{'id':_0x47bcd8[_0x36c0('0x44')]['id']}})[_0x36c0('0x23')](function(_0x4c2244){return db[_0x36c0('0x67')][_0x36c0('0x68')](function(_0x144177){return _0x4c2244['removeTeams'](_0x47bcd8['query'][_0x36c0('0x6e')],{'transaction':_0x144177})['then'](function(){if(!_[_0x36c0('0x80')](_0x3b6ea2)){return _0x4c2244[_0x36c0('0x81')](_0x3b6ea2,{'transaction':_0x144177});}})[_0x36c0('0x23')](function(){_0x3b6ea2[_0x36c0('0x6a')](function(_0xaf2f78){socket[_0x36c0('0x6b')]('userWhatsappQueue:remove',{'UserId':_0xaf2f78,'WhatsappQueueId':_0x4c2244['id']});});});});});});})[_0x36c0('0x23')](respondWithStatusCode(_0x470ec9,null))[_0x36c0('0x46')](handleError(_0x470ec9,null));};exports[_0x36c0('0x82')]=function(_0x407ca4,_0xac8680,_0x145208){return db[_0x36c0('0x2d')][_0x36c0('0x4d')]({'where':{'id':_0x407ca4['params']['id']}})[_0x36c0('0x23')](handleEntityNotFound(_0xac8680,null))[_0x36c0('0x23')](function(_0x2a0256){if(_0x2a0256){return _0x2a0256[_0x36c0('0x82')](_0x407ca4[_0x36c0('0x48')][_0x36c0('0x6e')],_[_0x36c0('0x83')](_0x407ca4[_0x36c0('0x48')],[_0x36c0('0x6e'),'id'])||{})['spread'](function(_0x3ab61f){for(var _0x8ae3b1=0x0;_0x8ae3b1<_0x407ca4[_0x36c0('0x48')][_0x36c0('0x6e')][_0x36c0('0x39')];_0x8ae3b1+=0x1){socket['emit']('userWhatsappQueue:save',{'UserId':_0x407ca4['body'][_0x36c0('0x6e')][_0x8ae3b1],'WhatsappQueueId':_0x407ca4['params']['id']});}return _0x3ab61f;});}})[_0x36c0('0x23')](respondWithResult(_0xac8680,null))[_0x36c0('0x46')](handleError(_0xac8680,null));};exports['removeAgents']=function(_0x4de33b,_0xe58ffd,_0x4eeb6f){return db[_0x36c0('0x2d')]['find']({'where':{'id':_0x4de33b[_0x36c0('0x44')]['id']}})[_0x36c0('0x23')](handleEntityNotFound(_0xe58ffd,null))[_0x36c0('0x23')](function(_0x27e591){if(_0x27e591){return _0x27e591[_0x36c0('0x81')](_0x4de33b[_0x36c0('0x33')]['ids'])[_0x36c0('0x23')](function(){if(_['isArray'](_0x4de33b[_0x36c0('0x33')][_0x36c0('0x6e')])){for(var _0x1cc7e2=0x0;_0x1cc7e2<_0x4de33b[_0x36c0('0x33')][_0x36c0('0x6e')]['length'];_0x1cc7e2+=0x1){socket['emit'](_0x36c0('0x84'),{'UserId':Number(_0x4de33b[_0x36c0('0x33')][_0x36c0('0x6e')][_0x1cc7e2]),'WhatsappQueueId':Number(_0x4de33b[_0x36c0('0x44')]['id'])});}}else{socket[_0x36c0('0x6b')](_0x36c0('0x84'),{'UserId':Number(_0x4de33b['query'][_0x36c0('0x6e')]),'WhatsappQueueId':Number(_0x4de33b[_0x36c0('0x44')]['id'])});}});}})[_0x36c0('0x23')](respondWithStatusCode(_0xe58ffd,null))['catch'](handleError(_0xe58ffd,null));};exports[_0x36c0('0x85')]=function(_0x1f2be3,_0x441072,_0x208e91){var _0x2c2c6c={};var _0x53d352={};var _0x3e8374;var _0x377400;return db['WhatsappQueue'][_0x36c0('0x52')]({'where':{'id':_0x1f2be3[_0x36c0('0x44')]['id']}})['then'](handleEntityNotFound(_0x441072,null))['then'](function(_0x19e2a1){if(_0x19e2a1){_0x3e8374=_0x19e2a1;_0x53d352[_0x36c0('0x32')]=_[_0x36c0('0x34')](db[_0x36c0('0x62')]['rawAttributes']);_0x53d352[_0x36c0('0x33')]=_[_0x36c0('0x34')](_0x1f2be3[_0x36c0('0x33')]);_0x53d352[_0x36c0('0x35')]=_['intersection'](_0x53d352[_0x36c0('0x32')],_0x53d352['query']);_0x2c2c6c[_0x36c0('0x37')]=_['intersection'](_0x53d352[_0x36c0('0x32')],qs[_0x36c0('0x38')](_0x1f2be3[_0x36c0('0x33')][_0x36c0('0x38')]));_0x2c2c6c[_0x36c0('0x37')]=_0x2c2c6c[_0x36c0('0x37')][_0x36c0('0x39')]?_0x2c2c6c[_0x36c0('0x37')]:_0x53d352[_0x36c0('0x32')];_0x2c2c6c['order']=qs[_0x36c0('0x3c')](_0x1f2be3[_0x36c0('0x33')]['sort']);_0x2c2c6c[_0x36c0('0x3d')]=qs[_0x36c0('0x35')](_[_0x36c0('0x3e')](_0x1f2be3[_0x36c0('0x33')],_0x53d352[_0x36c0('0x35')]));if(_0x1f2be3[_0x36c0('0x33')]['filter']){_0x2c2c6c[_0x36c0('0x3d')]=_[_0x36c0('0x45')](_0x2c2c6c[_0x36c0('0x3d')],{'$or':_['map'](_0x2c2c6c[_0x36c0('0x37')],function(_0x8660ea){var _0x28ace4={};_0x28ace4[_0x8660ea]={'$like':'%'+_0x1f2be3[_0x36c0('0x33')][_0x36c0('0x40')]+'%'};return _0x28ace4;})});}_0x2c2c6c=_[_0x36c0('0x45')]({},_0x2c2c6c,_0x1f2be3['options']);return _0x3e8374[_0x36c0('0x85')](_0x2c2c6c);}})['then'](function(_0x2f70d5){if(_0x2f70d5){_0x377400=_0x2f70d5[_0x36c0('0x39')];if(!_0x1f2be3[_0x36c0('0x33')][_0x36c0('0x54')](_0x36c0('0x3a'))){_0x2c2c6c[_0x36c0('0x20')]=qs[_0x36c0('0x20')](_0x1f2be3['query'][_0x36c0('0x20')]);_0x2c2c6c['offset']=qs[_0x36c0('0x1f')](_0x1f2be3[_0x36c0('0x33')][_0x36c0('0x1f')]);}return _0x3e8374[_0x36c0('0x85')](_0x2c2c6c);}})[_0x36c0('0x23')](function(_0x58d40f){if(_0x58d40f){return _0x58d40f?{'count':_0x377400,'rows':_0x58d40f}:null;}})[_0x36c0('0x23')](respondWithResult(_0x441072,null))[_0x36c0('0x46')](handleError(_0x441072,null));};
\ No newline at end of file