Built motion from commit c738b9ac.|2.6.25
[motion2.git] / server / api / whatsappQueue / whatsappQueue.controller.js
index 2851fbe..5ff3fb2 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x0c80=['querystring','papaparse','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','redis','defaults','socket.io-emitter','./whatsappQueue.socket','register','status','end','json','count','offset','set','apply','save','update','then','destroy','get','WhatsappQueues','UserProfileResource','stack','name','send','index','map','WhatsappQueue','rawAttributes','fieldName','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','limit','order','sort','filter','where','merge','type','VIRTUAL','options','includeAll','include','findAll','rows','catch','params','find','create','body','user','UserProfileSection','error','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','describe','getMembers','findOne','UserWhatsappQueue','User','findAndCountAll','UserId','agent','whatsappPause','updatedAt','createdAt','format','%s/%s','SIP','getTeams','Team','pick','addTeams','Agents','online','voicePause','interface','flatMap','sequelize','transaction','findOrCreate','forEach','emit','userWhatsappQueue:save','removeTeams','ids','select','field','tq.TeamId','from','team_has_whatsapp_queues','join','user_has_teams','ut.TeamId\x20=\x20tq.TeamId','WhatsappQueueId\x20=\x20?','clone','ut.UserId\x20=\x20?','toString','QueryTypes','SELECT','every','TeamId','all','union','compact','value','isEmpty','removeAgents','addAgents','omit','spread','isArray','userWhatsappQueue:remove','getAgents','html-pdf','eml-format','rimraf','zip-dir','fast-json-patch','moment','util','path','sox','to-csv','lodash','squel','crypto','jsforce','desk.js'];(function(_0x441442,_0x14f1b1){var _0x2f96c3=function(_0x4d5686){while(--_0x4d5686){_0x441442['push'](_0x441442['shift']());}};_0x2f96c3(++_0x14f1b1);}(_0x0c80,0x192));var _0x00c8=function(_0x2641f9,_0x26715f){_0x2641f9=_0x2641f9-0x0;var _0x585741=_0x0c80[_0x2641f9];return _0x585741;};'use strict';var pdf=require(_0x00c8('0x0'));var emlformat=require(_0x00c8('0x1'));var rimraf=require(_0x00c8('0x2'));var zipdir=require(_0x00c8('0x3'));var jsonpatch=require(_0x00c8('0x4'));var rp=require('request-promise');var moment=require(_0x00c8('0x5'));var BPromise=require('bluebird');var Mustache=require('mustache');var util=require(_0x00c8('0x6'));var path=require(_0x00c8('0x7'));var sox=require(_0x00c8('0x8'));var csv=require(_0x00c8('0x9'));var ejs=require('ejs');var fs=require('fs');var _=require(_0x00c8('0xa'));var squel=require(_0x00c8('0xb'));var crypto=require(_0x00c8('0xc'));var jsforce=require(_0x00c8('0xd'));var deskjs=require(_0x00c8('0xe'));var toCsv=require(_0x00c8('0x9'));var querystring=require(_0x00c8('0xf'));var Papa=require(_0x00c8('0x10'));var Redis=require('ioredis');var authService=require('../../components/auth/service');var qs=require(_0x00c8('0x11'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x00c8('0x12'));var logger=require(_0x00c8('0x13'))(_0x00c8('0x14'));var utils=require('../../config/utils');var config=require('../../config/environment');var db=require('../../mysqldb')['db'];config[_0x00c8('0x15')]=_[_0x00c8('0x16')](config['redis'],{'host':'localhost','port':0x18eb});var socket=require(_0x00c8('0x17'))(new Redis(config['redis']));require(_0x00c8('0x18'))[_0x00c8('0x19')](socket);function respondWithStatusCode(_0x1dde0c,_0x270001){_0x270001=_0x270001||0xcc;return function(_0x233804){if(_0x233804){return _0x1dde0c['sendStatus'](_0x270001);}return _0x1dde0c[_0x00c8('0x1a')](_0x270001)[_0x00c8('0x1b')]();};}function respondWithResult(_0x34a838,_0x5e1403){_0x5e1403=_0x5e1403||0xc8;return function(_0x5d815c){if(_0x5d815c){return _0x34a838[_0x00c8('0x1a')](_0x5e1403)[_0x00c8('0x1c')](_0x5d815c);}};}function respondWithFilteredResult(_0x3d0da8,_0x26aa1a){return function(_0x4875f4){if(_0x4875f4){var _0x2c29df=_0x4875f4[_0x00c8('0x1d')],_0xc75b55=_0x26aa1a[_0x00c8('0x1e')],_0x51e21e=_0x26aa1a[_0x00c8('0x1e')]+_0x26aa1a['limit'],_0x341009;if(_0x51e21e>=_0x2c29df){_0x51e21e=_0x2c29df;_0x341009=0xc8;}else{_0x341009=0xce;}_0x3d0da8['status'](_0x341009);return _0x3d0da8[_0x00c8('0x1f')]('Content-Range',_0xc75b55+'-'+_0x51e21e+'/'+_0x2c29df)[_0x00c8('0x1c')](_0x4875f4);}return null;};}function patchUpdates(_0x588350){return function(_0x277373){try{jsonpatch[_0x00c8('0x20')](_0x277373,_0x588350,!![]);}catch(_0x12b86e){return BPromise['reject'](_0x12b86e);}return _0x277373[_0x00c8('0x21')]();};}function saveUpdates(_0x2b455c,_0xfc3fd0){return function(_0x39d05e){if(_0x39d05e){return _0x39d05e[_0x00c8('0x22')](_0x2b455c)[_0x00c8('0x23')](function(_0x259aa0){return _0x259aa0;});}return null;};}function removeEntity(_0xd282ea,_0x37618a){return function(_0x61b8a7){if(_0x61b8a7){return _0x61b8a7[_0x00c8('0x24')]()[_0x00c8('0x23')](function(){var _0x52e089=_0x61b8a7[_0x00c8('0x25')]({'plain':!![]});var _0x2b2bc8=_0x00c8('0x26');return db[_0x00c8('0x27')]['destroy']({'where':{'type':_0x2b2bc8,'resourceId':_0x52e089['id']}})[_0x00c8('0x23')](function(){return _0x61b8a7;});})[_0x00c8('0x23')](function(){_0xd282ea[_0x00c8('0x1a')](0xcc)[_0x00c8('0x1b')]();});}};}function handleEntityNotFound(_0x496272,_0x27b9a4){return function(_0xf29f31){if(!_0xf29f31){_0x496272['sendStatus'](0x194);}return _0xf29f31;};}function handleError(_0xceec5d,_0x19e899){_0x19e899=_0x19e899||0x1f4;return function(_0x10aaf7){logger['error'](_0x10aaf7[_0x00c8('0x28')]);if(_0x10aaf7[_0x00c8('0x29')]){delete _0x10aaf7[_0x00c8('0x29')];}_0xceec5d[_0x00c8('0x1a')](_0x19e899)[_0x00c8('0x2a')](_0x10aaf7);};}exports[_0x00c8('0x2b')]=function(_0x376acf,_0x4953e4){var _0x491645={},_0x1b546d={},_0xa205bf={'count':0x0,'rows':[]};var _0x1b9c3b=_[_0x00c8('0x2c')](db[_0x00c8('0x2d')][_0x00c8('0x2e')],function(_0x4deadb){return{'name':_0x4deadb[_0x00c8('0x2f')],'type':_0x4deadb['type']['key']};});_0x1b546d[_0x00c8('0x30')]=_[_0x00c8('0x2c')](_0x1b9c3b,_0x00c8('0x29'));_0x1b546d[_0x00c8('0x31')]=_[_0x00c8('0x32')](_0x376acf['query']);_0x1b546d[_0x00c8('0x33')]=_[_0x00c8('0x34')](_0x1b546d[_0x00c8('0x30')],_0x1b546d[_0x00c8('0x31')]);_0x491645[_0x00c8('0x35')]=_[_0x00c8('0x34')](_0x1b546d[_0x00c8('0x30')],qs['fields'](_0x376acf[_0x00c8('0x31')][_0x00c8('0x36')]));_0x491645[_0x00c8('0x35')]=_0x491645['attributes'][_0x00c8('0x37')]?_0x491645['attributes']:_0x1b546d['model'];if(!_0x376acf['query'][_0x00c8('0x38')](_0x00c8('0x39'))){_0x491645[_0x00c8('0x3a')]=qs[_0x00c8('0x3a')](_0x376acf['query'][_0x00c8('0x3a')]);_0x491645[_0x00c8('0x1e')]=qs[_0x00c8('0x1e')](_0x376acf['query']['offset']);}_0x491645[_0x00c8('0x3b')]=qs['sort'](_0x376acf[_0x00c8('0x31')][_0x00c8('0x3c')]);_0x491645['where']=qs[_0x00c8('0x33')](_['pick'](_0x376acf[_0x00c8('0x31')],_0x1b546d[_0x00c8('0x33')]),_0x1b9c3b);if(_0x376acf['query'][_0x00c8('0x3d')]){_0x491645[_0x00c8('0x3e')]=_[_0x00c8('0x3f')](_0x491645[_0x00c8('0x3e')],{'$or':_[_0x00c8('0x2c')](_0x1b9c3b,function(_0x12ce80){if(_0x12ce80[_0x00c8('0x40')]!==_0x00c8('0x41')){var _0x2d4763={};_0x2d4763[_0x12ce80['name']]={'$like':'%'+_0x376acf['query'][_0x00c8('0x3d')]+'%'};return _0x2d4763;}})});}_0x491645=_[_0x00c8('0x3f')]({},_0x491645,_0x376acf[_0x00c8('0x42')]);var _0x30c1b2={'where':_0x491645[_0x00c8('0x3e')]};return db[_0x00c8('0x2d')][_0x00c8('0x1d')](_0x30c1b2)['then'](function(_0x3079c9){_0xa205bf[_0x00c8('0x1d')]=_0x3079c9;if(_0x376acf[_0x00c8('0x31')][_0x00c8('0x43')]){_0x491645[_0x00c8('0x44')]=[{'all':!![]}];}return db[_0x00c8('0x2d')][_0x00c8('0x45')](_0x491645);})['then'](function(_0x959755){_0xa205bf[_0x00c8('0x46')]=_0x959755;return _0xa205bf;})[_0x00c8('0x23')](respondWithFilteredResult(_0x4953e4,_0x491645))[_0x00c8('0x47')](handleError(_0x4953e4,null));};exports['show']=function(_0x5330b3,_0x4472df){var _0x26e4da={'raw':!![],'where':{'id':_0x5330b3[_0x00c8('0x48')]['id']}},_0x3594bd={};_0x3594bd[_0x00c8('0x30')]=_[_0x00c8('0x32')](db['WhatsappQueue']['rawAttributes']);_0x3594bd[_0x00c8('0x31')]=_[_0x00c8('0x32')](_0x5330b3[_0x00c8('0x31')]);_0x3594bd[_0x00c8('0x33')]=_[_0x00c8('0x34')](_0x3594bd[_0x00c8('0x30')],_0x3594bd[_0x00c8('0x31')]);_0x26e4da[_0x00c8('0x35')]=_['intersection'](_0x3594bd[_0x00c8('0x30')],qs[_0x00c8('0x36')](_0x5330b3[_0x00c8('0x31')][_0x00c8('0x36')]));_0x26e4da[_0x00c8('0x35')]=_0x26e4da['attributes'][_0x00c8('0x37')]?_0x26e4da[_0x00c8('0x35')]:_0x3594bd['model'];if(_0x5330b3['query'][_0x00c8('0x43')]){_0x26e4da[_0x00c8('0x44')]=[{'all':!![]}];}_0x26e4da=_[_0x00c8('0x3f')]({},_0x26e4da,_0x5330b3[_0x00c8('0x42')]);return db[_0x00c8('0x2d')][_0x00c8('0x49')](_0x26e4da)['then'](handleEntityNotFound(_0x4472df,null))[_0x00c8('0x23')](respondWithResult(_0x4472df,null))[_0x00c8('0x47')](handleError(_0x4472df,null));};exports[_0x00c8('0x4a')]=function(_0x1d33b2,_0x5a83df){return db[_0x00c8('0x2d')][_0x00c8('0x4a')](_0x1d33b2[_0x00c8('0x4b')],{})[_0x00c8('0x23')](function(_0x7bdc4d){var _0x33c5c8=_0x1d33b2[_0x00c8('0x4c')]['get']({'plain':!![]});if(!_0x33c5c8)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x33c5c8['role']===_0x00c8('0x4c')){var _0x56d962=_0x7bdc4d[_0x00c8('0x25')]({'plain':!![]});var _0x1220f5=_0x00c8('0x26');return db[_0x00c8('0x4d')][_0x00c8('0x49')]({'where':{'name':_0x1220f5,'userProfileId':_0x33c5c8['userProfileId']},'raw':!![]})[_0x00c8('0x23')](function(_0x2c2f91){if(_0x2c2f91&&_0x2c2f91['autoAssociation']===0x0){return db[_0x00c8('0x27')][_0x00c8('0x4a')]({'name':_0x56d962[_0x00c8('0x29')],'resourceId':_0x56d962['id'],'type':_0x2c2f91[_0x00c8('0x29')],'sectionId':_0x2c2f91['id']},{})[_0x00c8('0x23')](function(){return _0x7bdc4d;});}else{return _0x7bdc4d;}})['catch'](function(_0x293f35){logger[_0x00c8('0x4e')](_0x00c8('0x4f'),_0x293f35);throw _0x293f35;});}return _0x7bdc4d;})[_0x00c8('0x23')](respondWithResult(_0x5a83df,0xc9))[_0x00c8('0x47')](handleError(_0x5a83df,null));};exports['update']=function(_0x4af763,_0x18654a){if(_0x4af763[_0x00c8('0x4b')]['id']){delete _0x4af763[_0x00c8('0x4b')]['id'];}return db['WhatsappQueue'][_0x00c8('0x49')]({'where':{'id':_0x4af763[_0x00c8('0x48')]['id']}})[_0x00c8('0x23')](handleEntityNotFound(_0x18654a,null))['then'](saveUpdates(_0x4af763['body'],null))[_0x00c8('0x23')](respondWithResult(_0x18654a,null))['catch'](handleError(_0x18654a,null));};exports['destroy']=function(_0x2bc6d6,_0x4989ef){return db['WhatsappQueue'][_0x00c8('0x49')]({'where':{'id':_0x2bc6d6[_0x00c8('0x48')]['id']}})['then'](handleEntityNotFound(_0x4989ef,null))[_0x00c8('0x23')](removeEntity(_0x4989ef,null))['catch'](handleError(_0x4989ef,null));};exports[_0x00c8('0x50')]=function(_0x1a198e,_0x1c0096){return db[_0x00c8('0x2d')]['describe']()[_0x00c8('0x23')](respondWithResult(_0x1c0096,null))[_0x00c8('0x47')](handleError(_0x1c0096,null));};exports[_0x00c8('0x51')]=function(_0xbf8b67,_0x24f11c,_0x2ef898){var _0x517c5f={'raw':!![],'where':{}},_0x4efcf6={},_0x12d063;return db[_0x00c8('0x2d')][_0x00c8('0x52')]({'where':{'id':_0xbf8b67[_0x00c8('0x48')]['id']}})[_0x00c8('0x23')](handleEntityNotFound(_0x24f11c,null))[_0x00c8('0x23')](function(_0x5b4648){if(_0x5b4648){_0x12d063=_0x5b4648[_0x00c8('0x25')]({'plain':!![]});_0x4efcf6[_0x00c8('0x30')]=_[_0x00c8('0x32')](db[_0x00c8('0x53')][_0x00c8('0x2e')]);_0x4efcf6[_0x00c8('0x31')]=_[_0x00c8('0x32')](_0xbf8b67['query']);_0x4efcf6[_0x00c8('0x33')]=_[_0x00c8('0x34')](_0x4efcf6[_0x00c8('0x30')],_0x4efcf6[_0x00c8('0x31')]);_0x517c5f[_0x00c8('0x35')]=_[_0x00c8('0x34')](_0x4efcf6['model'],qs[_0x00c8('0x36')](_0xbf8b67[_0x00c8('0x31')][_0x00c8('0x36')]));_0x517c5f[_0x00c8('0x35')]=_0x517c5f[_0x00c8('0x35')]['length']?_0x517c5f[_0x00c8('0x35')]:_0x4efcf6[_0x00c8('0x30')];if(!_0xbf8b67[_0x00c8('0x31')]['hasOwnProperty'](_0x00c8('0x39'))){_0x517c5f[_0x00c8('0x3a')]=qs[_0x00c8('0x3a')](_0xbf8b67[_0x00c8('0x31')][_0x00c8('0x3a')]);_0x517c5f['offset']=qs[_0x00c8('0x1e')](_0xbf8b67[_0x00c8('0x31')][_0x00c8('0x1e')]);}_0x517c5f[_0x00c8('0x3b')]=qs['sort'](_0xbf8b67[_0x00c8('0x31')][_0x00c8('0x3c')]);_0x517c5f[_0x00c8('0x3e')]=qs[_0x00c8('0x33')](_['pick'](_0xbf8b67[_0x00c8('0x31')],_0x4efcf6[_0x00c8('0x33')]));_0x517c5f[_0x00c8('0x3e')]['WhatsappQueueId']=_0x5b4648['id'];if(_0xbf8b67[_0x00c8('0x31')][_0x00c8('0x3d')]){_0x517c5f[_0x00c8('0x3e')]=_[_0x00c8('0x3f')](_0x517c5f[_0x00c8('0x3e')],{'$or':_['map'](_0x517c5f[_0x00c8('0x35')],function(_0x27254a){var _0x56e443={};_0x56e443[_0x27254a]={'$like':'%'+_0xbf8b67[_0x00c8('0x31')][_0x00c8('0x3d')]+'%'};return _0x56e443;})});}_0x517c5f=_['merge']({},_0x517c5f,_0xbf8b67['options']);return db[_0x00c8('0x53')][_0x00c8('0x45')](_0x517c5f);}})[_0x00c8('0x23')](function(_0x31ca88){if(_0x31ca88){return db[_0x00c8('0x54')][_0x00c8('0x55')]({'where':{'id':_[_0x00c8('0x2c')](_0x31ca88,_0x00c8('0x56')),'role':_0x00c8('0x57')},'attributes':['id','name',_0x00c8('0x58'),_0x00c8('0x59'),_0x00c8('0x5a')]});}})[_0x00c8('0x23')](function(_0x359a09){if(_0x359a09){return{'count':_0x359a09[_0x00c8('0x1d')],'rows':_[_0x00c8('0x2c')](_0x359a09[_0x00c8('0x46')],function(_0x437c5a){return{'membername':_0x437c5a[_0x00c8('0x29')],'UserId':_0x437c5a['id'],'queue_name':_0x12d063[_0x00c8('0x29')],'WhatsappQueueId':_0x12d063['id'],'interface':util[_0x00c8('0x5b')](_0x00c8('0x5c'),_0x00c8('0x5d'),_0x437c5a[_0x00c8('0x29')]),'penalty':0x0,'paused':_0x437c5a[_0x00c8('0x58')],'createdAt':_0x437c5a[_0x00c8('0x5a')],'updatedAt':_0x437c5a[_0x00c8('0x59')]};})};}else{return{'count':0x0,'rows':[]};}})[_0x00c8('0x23')](respondWithFilteredResult(_0x24f11c,_0x517c5f))[_0x00c8('0x47')](handleError(_0x24f11c,null));};exports[_0x00c8('0x5e')]=function(_0xd253aa,_0x249ac8,_0x107b17){var _0x1458bc={};var _0x29993e={};var _0x42182f;var _0x50249d;return db[_0x00c8('0x2d')][_0x00c8('0x52')]({'where':{'id':_0xd253aa[_0x00c8('0x48')]['id']}})[_0x00c8('0x23')](handleEntityNotFound(_0x249ac8,null))[_0x00c8('0x23')](function(_0x13051e){if(_0x13051e){_0x42182f=_0x13051e;_0x29993e[_0x00c8('0x30')]=_[_0x00c8('0x32')](db[_0x00c8('0x5f')][_0x00c8('0x2e')]);_0x29993e[_0x00c8('0x31')]=_[_0x00c8('0x32')](_0xd253aa['query']);_0x29993e[_0x00c8('0x33')]=_[_0x00c8('0x34')](_0x29993e['model'],_0x29993e[_0x00c8('0x31')]);_0x1458bc[_0x00c8('0x35')]=_[_0x00c8('0x34')](_0x29993e[_0x00c8('0x30')],qs['fields'](_0xd253aa[_0x00c8('0x31')][_0x00c8('0x36')]));_0x1458bc[_0x00c8('0x35')]=_0x1458bc[_0x00c8('0x35')][_0x00c8('0x37')]?_0x1458bc[_0x00c8('0x35')]:_0x29993e[_0x00c8('0x30')];_0x1458bc['order']=qs[_0x00c8('0x3c')](_0xd253aa[_0x00c8('0x31')][_0x00c8('0x3c')]);_0x1458bc[_0x00c8('0x3e')]=qs[_0x00c8('0x33')](_[_0x00c8('0x60')](_0xd253aa[_0x00c8('0x31')],_0x29993e[_0x00c8('0x33')]));if(_0xd253aa[_0x00c8('0x31')]['filter']){_0x1458bc['where']=_[_0x00c8('0x3f')](_0x1458bc[_0x00c8('0x3e')],{'$or':_[_0x00c8('0x2c')](_0x1458bc[_0x00c8('0x35')],function(_0x3577f7){var _0x254698={};_0x254698[_0x3577f7]={'$like':'%'+_0xd253aa[_0x00c8('0x31')]['filter']+'%'};return _0x254698;})});}_0x1458bc=_[_0x00c8('0x3f')]({},_0x1458bc,_0xd253aa[_0x00c8('0x42')]);return _0x42182f[_0x00c8('0x5e')](_0x1458bc);}})['then'](function(_0xfcee91){if(_0xfcee91){_0x50249d=_0xfcee91[_0x00c8('0x37')];if(!_0xd253aa[_0x00c8('0x31')]['hasOwnProperty']('nolimit')){_0x1458bc['limit']=qs['limit'](_0xd253aa[_0x00c8('0x31')][_0x00c8('0x3a')]);_0x1458bc[_0x00c8('0x1e')]=qs[_0x00c8('0x1e')](_0xd253aa['query'][_0x00c8('0x1e')]);}return _0x42182f[_0x00c8('0x5e')](_0x1458bc);}})[_0x00c8('0x23')](function(_0x111d66){if(_0x111d66){return _0x111d66?{'count':_0x50249d,'rows':_0x111d66}:null;}})[_0x00c8('0x23')](respondWithResult(_0x249ac8,null))[_0x00c8('0x47')](handleError(_0x249ac8,null));};exports[_0x00c8('0x61')]=function(_0x188645,_0x11241a,_0x17c061){var _0x41350f=_0x188645['body']['ids'];return db[_0x00c8('0x5f')]['findAll']({'where':{'id':_0x41350f},'attributes':['id'],'include':[{'model':db['User'],'as':_0x00c8('0x62'),'attributes':['id','name',_0x00c8('0x63'),_0x00c8('0x64'),_0x00c8('0x65')],'raw':!![]}]})['then'](function(_0x44a939){if(_0x44a939){var _0x16bcc0=_[_0x00c8('0x66')](_0x44a939,function(_0xf182b9){var _0x3c7480=_0xf182b9['get']({'plain':!![]});return _0x3c7480['Agents'];});return db[_0x00c8('0x2d')][_0x00c8('0x49')]({'where':{'id':_0x188645['params']['id']}})['then'](function(_0x51bb30){return db[_0x00c8('0x67')][_0x00c8('0x68')](function(_0x43340c){return _0x51bb30[_0x00c8('0x61')](_0x41350f,{'transaction':_0x43340c})[_0x00c8('0x23')](function(){return BPromise['each'](_0x16bcc0,function(_0xbc461f){return db[_0x00c8('0x53')][_0x00c8('0x69')]({'where':{'UserId':_0xbc461f['id'],'WhatsappQueueId':_0x188645[_0x00c8('0x48')]['id']},'transaction':_0x43340c});});})[_0x00c8('0x23')](function(){_0x16bcc0[_0x00c8('0x6a')](function(_0x10ac22){socket[_0x00c8('0x6b')](_0x00c8('0x6c'),{'UserId':_0x10ac22['id'],'WhatsappQueueId':_0x51bb30['id']});});});});});}})[_0x00c8('0x23')](respondWithStatusCode(_0x11241a,null))[_0x00c8('0x47')](handleError(_0x11241a,null));};exports[_0x00c8('0x6d')]=function(_0x322c8b,_0xd2555c,_0x46660e){return db[_0x00c8('0x5f')]['findAll']({'where':{'id':_0x322c8b[_0x00c8('0x31')][_0x00c8('0x6e')]},'attributes':['id'],'include':[{'model':db[_0x00c8('0x54')],'as':_0x00c8('0x62'),'attributes':['id'],'raw':!![]}]})[_0x00c8('0x23')](handleEntityNotFound(_0xd2555c,null))[_0x00c8('0x23')](function(_0x3bf0b8){var _0x1d80f6=_['map'](_0x3bf0b8,'id');var _0x34c6b8=[];var _0x21c6f0=[];var _0x1d6691=squel[_0x00c8('0x6f')]();_0x1d6691[_0x00c8('0x70')](_0x00c8('0x71'))[_0x00c8('0x72')](_0x00c8('0x73'),'tq')[_0x00c8('0x74')](_0x00c8('0x75'),'ut',_0x00c8('0x76'))[_0x00c8('0x3e')](_0x00c8('0x77'),_0x322c8b[_0x00c8('0x48')]['id']);for(var _0x27b659=0x0;_0x27b659<_0x3bf0b8[_0x00c8('0x37')];_0x27b659+=0x1){let _0x1b508b=_0x3bf0b8[_0x27b659];for(var _0x3ad103=0x0;_0x3ad103<_0x1b508b[_0x00c8('0x62')][_0x00c8('0x37')];_0x3ad103+=0x1){let _0x34aba7=_0x1b508b[_0x00c8('0x62')][_0x3ad103];var _0x258cba=_0x1d6691[_0x00c8('0x78')]();_0x258cba[_0x00c8('0x3e')](_0x00c8('0x79'),_0x34aba7['id']);_0x21c6f0['push'](db[_0x00c8('0x67')][_0x00c8('0x31')](_0x258cba[_0x00c8('0x7a')](),{'type':db['sequelize'][_0x00c8('0x7b')][_0x00c8('0x7c')]})[_0x00c8('0x23')](function(_0x2c5df1){if(_0x2c5df1[_0x00c8('0x37')]===0x1){return _0x34aba7['id'];}else{var _0x28efc0=_[_0x00c8('0x7d')](_['map'](_0x2c5df1,_0x00c8('0x7e')),function(_0x39dc1e){return _['includes'](_0x1d80f6,_0x39dc1e);});if(_0x28efc0){return _0x34aba7['id'];}}}));}}return BPromise[_0x00c8('0x7f')](_0x21c6f0)[_0x00c8('0x23')](function(_0x1c5339){_0x34c6b8=_(_0x34c6b8)[_0x00c8('0x80')](_0x1c5339)[_0x00c8('0x81')]()[_0x00c8('0x82')]();return db[_0x00c8('0x2d')]['find']({'where':{'id':_0x322c8b[_0x00c8('0x48')]['id']}})[_0x00c8('0x23')](function(_0x3916ec){return db[_0x00c8('0x67')]['transaction'](function(_0x23b845){return _0x3916ec[_0x00c8('0x6d')](_0x322c8b[_0x00c8('0x31')]['ids'],{'transaction':_0x23b845})[_0x00c8('0x23')](function(){if(!_[_0x00c8('0x83')](_0x34c6b8)){return _0x3916ec[_0x00c8('0x84')](_0x34c6b8,{'transaction':_0x23b845});}})[_0x00c8('0x23')](function(){_0x34c6b8[_0x00c8('0x6a')](function(_0x30fde1){socket['emit']('userWhatsappQueue:remove',{'UserId':_0x30fde1,'WhatsappQueueId':_0x3916ec['id']});});});});});});})[_0x00c8('0x23')](respondWithStatusCode(_0xd2555c,null))['catch'](handleError(_0xd2555c,null));};exports[_0x00c8('0x85')]=function(_0x5ac92e,_0x59b057,_0x4e777a){return db['WhatsappQueue'][_0x00c8('0x49')]({'where':{'id':_0x5ac92e[_0x00c8('0x48')]['id']}})[_0x00c8('0x23')](handleEntityNotFound(_0x59b057,null))['then'](function(_0x457bd3){if(_0x457bd3){return _0x457bd3[_0x00c8('0x85')](_0x5ac92e[_0x00c8('0x4b')][_0x00c8('0x6e')],_[_0x00c8('0x86')](_0x5ac92e['body'],[_0x00c8('0x6e'),'id'])||{})[_0x00c8('0x87')](function(_0x2faa30){for(var _0x33a061=0x0;_0x33a061<_0x5ac92e[_0x00c8('0x4b')][_0x00c8('0x6e')]['length'];_0x33a061+=0x1){socket['emit'](_0x00c8('0x6c'),{'UserId':_0x5ac92e['body'][_0x00c8('0x6e')][_0x33a061],'WhatsappQueueId':_0x5ac92e[_0x00c8('0x48')]['id']});}return _0x2faa30;});}})[_0x00c8('0x23')](respondWithResult(_0x59b057,null))[_0x00c8('0x47')](handleError(_0x59b057,null));};exports['removeAgents']=function(_0x4b4c2a,_0x21094b,_0x356d77){return db['WhatsappQueue'][_0x00c8('0x49')]({'where':{'id':_0x4b4c2a['params']['id']}})[_0x00c8('0x23')](handleEntityNotFound(_0x21094b,null))['then'](function(_0x26fe79){if(_0x26fe79){return _0x26fe79[_0x00c8('0x84')](_0x4b4c2a[_0x00c8('0x31')]['ids'])['then'](function(){if(_[_0x00c8('0x88')](_0x4b4c2a[_0x00c8('0x31')][_0x00c8('0x6e')])){for(var _0x47bb9f=0x0;_0x47bb9f<_0x4b4c2a[_0x00c8('0x31')]['ids']['length'];_0x47bb9f+=0x1){socket[_0x00c8('0x6b')](_0x00c8('0x89'),{'UserId':Number(_0x4b4c2a[_0x00c8('0x31')][_0x00c8('0x6e')][_0x47bb9f]),'WhatsappQueueId':Number(_0x4b4c2a[_0x00c8('0x48')]['id'])});}}else{socket[_0x00c8('0x6b')](_0x00c8('0x89'),{'UserId':Number(_0x4b4c2a[_0x00c8('0x31')][_0x00c8('0x6e')]),'WhatsappQueueId':Number(_0x4b4c2a['params']['id'])});}});}})[_0x00c8('0x23')](respondWithStatusCode(_0x21094b,null))[_0x00c8('0x47')](handleError(_0x21094b,null));};exports[_0x00c8('0x8a')]=function(_0x58851c,_0x29781a,_0x3deeaf){var _0x4e1ef0={};var _0x155b72={};var _0x58090f;var _0x46c04b;return db['WhatsappQueue'][_0x00c8('0x52')]({'where':{'id':_0x58851c[_0x00c8('0x48')]['id']}})['then'](handleEntityNotFound(_0x29781a,null))[_0x00c8('0x23')](function(_0x1d5e37){if(_0x1d5e37){_0x58090f=_0x1d5e37;_0x155b72['model']=_[_0x00c8('0x32')](db[_0x00c8('0x54')]['rawAttributes']);_0x155b72[_0x00c8('0x31')]=_[_0x00c8('0x32')](_0x58851c[_0x00c8('0x31')]);_0x155b72[_0x00c8('0x33')]=_[_0x00c8('0x34')](_0x155b72[_0x00c8('0x30')],_0x155b72[_0x00c8('0x31')]);_0x4e1ef0['attributes']=_[_0x00c8('0x34')](_0x155b72['model'],qs[_0x00c8('0x36')](_0x58851c['query']['fields']));_0x4e1ef0[_0x00c8('0x35')]=_0x4e1ef0['attributes'][_0x00c8('0x37')]?_0x4e1ef0[_0x00c8('0x35')]:_0x155b72[_0x00c8('0x30')];_0x4e1ef0[_0x00c8('0x3b')]=qs[_0x00c8('0x3c')](_0x58851c['query'][_0x00c8('0x3c')]);_0x4e1ef0['where']=qs['filters'](_[_0x00c8('0x60')](_0x58851c['query'],_0x155b72['filters']));if(_0x58851c[_0x00c8('0x31')][_0x00c8('0x3d')]){_0x4e1ef0[_0x00c8('0x3e')]=_['merge'](_0x4e1ef0[_0x00c8('0x3e')],{'$or':_[_0x00c8('0x2c')](_0x4e1ef0[_0x00c8('0x35')],function(_0x432b7e){var _0x2368a8={};_0x2368a8[_0x432b7e]={'$like':'%'+_0x58851c[_0x00c8('0x31')]['filter']+'%'};return _0x2368a8;})});}_0x4e1ef0=_[_0x00c8('0x3f')]({},_0x4e1ef0,_0x58851c[_0x00c8('0x42')]);return _0x58090f[_0x00c8('0x8a')](_0x4e1ef0);}})[_0x00c8('0x23')](function(_0x2dc0ea){if(_0x2dc0ea){_0x46c04b=_0x2dc0ea['length'];if(!_0x58851c[_0x00c8('0x31')][_0x00c8('0x38')](_0x00c8('0x39'))){_0x4e1ef0[_0x00c8('0x3a')]=qs[_0x00c8('0x3a')](_0x58851c[_0x00c8('0x31')][_0x00c8('0x3a')]);_0x4e1ef0[_0x00c8('0x1e')]=qs[_0x00c8('0x1e')](_0x58851c[_0x00c8('0x31')][_0x00c8('0x1e')]);}return _0x58090f[_0x00c8('0x8a')](_0x4e1ef0);}})[_0x00c8('0x23')](function(_0x199b46){if(_0x199b46){return _0x199b46?{'count':_0x46c04b,'rows':_0x199b46}:null;}})['then'](respondWithResult(_0x29781a,null))['catch'](handleError(_0x29781a,null));};
\ No newline at end of file
+var _0x6a2d=['flatMap','Agents','sequelize','transaction','each','findOrCreate','forEach','emit','userWhatsappQueue:save','removeTeams','Team','select','field','from','team_has_whatsapp_queues','join','user_has_teams','ut.TeamId\x20=\x20tq.TeamId','clone','ut.UserId\x20=\x20?','push','toString','QueryTypes','SELECT','every','TeamId','includes','all','compact','value','isEmpty','userWhatsappQueue:remove','addAgents','omit','spread','removeAgents','isArray','getAgents','lodash','ioredis','../../components/parsers/qs','../../config/logger','api','../../mysqldb','defaults','redis','localhost','socket.io-emitter','register','sendStatus','status','end','offset','undefined','limit','count','set','Content-Range','then','destroy','get','WhatsappQueues','UserProfileResource','stack','name','send','map','WhatsappQueue','rawAttributes','fieldName','type','key','getOptions','where','include','findAll','rows','catch','show','params','model','keys','query','filters','intersection','fields','attributes','length','includeAll','merge','options','find','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','userProfileId','error','update','describe','getMembers','findOne','UserWhatsappQueue','hasOwnProperty','nolimit','sort','pick','WhatsappQueueId','User','findAndCountAll','UserId','whatsappPause','updatedAt','createdAt','format','SIP','getTeams','filter','addTeams','ids','voicePause'];(function(_0x37c07d,_0xdbdb5f){var _0x10dadc=function(_0x2bafb7){while(--_0x2bafb7){_0x37c07d['push'](_0x37c07d['shift']());}};_0x10dadc(++_0xdbdb5f);}(_0x6a2d,0x197));var _0xd6a2=function(_0x3bf83f,_0x181cac){_0x3bf83f=_0x3bf83f-0x0;var _0x22c4a9=_0x6a2d[_0x3bf83f];return _0x22c4a9;};'use strict';var BPromise=require('bluebird');var util=require('util');var _=require(_0xd6a2('0x0'));var squel=require('squel');var Redis=require(_0xd6a2('0x1'));var qs=require(_0xd6a2('0x2'));var logger=require(_0xd6a2('0x3'))(_0xd6a2('0x4'));var config=require('../../config/environment');var db=require(_0xd6a2('0x5'))['db'];config['redis']=_[_0xd6a2('0x6')](config[_0xd6a2('0x7')],{'host':_0xd6a2('0x8'),'port':0x18eb});var socket=require(_0xd6a2('0x9'))(new Redis(config['redis']));require('./whatsappQueue.socket')[_0xd6a2('0xa')](socket);function respondWithStatusCode(_0x560686,_0x53cd2a){_0x53cd2a=_0x53cd2a||0xcc;return function(_0x290d78){if(_0x290d78){return _0x560686[_0xd6a2('0xb')](_0x53cd2a);}return _0x560686[_0xd6a2('0xc')](_0x53cd2a)[_0xd6a2('0xd')]();};}function respondWithResult(_0x262459,_0x31b63f){_0x31b63f=_0x31b63f||0xc8;return function(_0x14a38f){if(_0x14a38f){return _0x262459[_0xd6a2('0xc')](_0x31b63f)['json'](_0x14a38f);}};}function respondWithFilteredResult(_0x2b3289,_0x16e283){return function(_0xc5d101){if(_0xc5d101){var _0x46a4e4=typeof _0x16e283[_0xd6a2('0xe')]===_0xd6a2('0xf')&&typeof _0x16e283[_0xd6a2('0x10')]===_0xd6a2('0xf');var _0x5f69dd=_0xc5d101[_0xd6a2('0x11')];var _0x56b6e9=_0x46a4e4?0x0:_0x16e283[_0xd6a2('0xe')];var _0x3842a4=_0x46a4e4?_0xc5d101[_0xd6a2('0x11')]:_0x16e283[_0xd6a2('0xe')]+_0x16e283['limit'];var _0x53dbc3;if(_0x3842a4>=_0x5f69dd){_0x3842a4=_0x5f69dd;_0x53dbc3=0xc8;}else{_0x53dbc3=0xce;}_0x2b3289['status'](_0x53dbc3);return _0x2b3289[_0xd6a2('0x12')](_0xd6a2('0x13'),_0x56b6e9+'-'+_0x3842a4+'/'+_0x5f69dd)['json'](_0xc5d101);}return null;};}function saveUpdates(_0x4e1c37){return function(_0x2a4a0f){if(_0x2a4a0f){return _0x2a4a0f['update'](_0x4e1c37)[_0xd6a2('0x14')](function(_0xcdbc15){return _0xcdbc15;});}return null;};}function removeEntity(_0x559d67){return function(_0x47c72f){if(_0x47c72f){return _0x47c72f[_0xd6a2('0x15')]()[_0xd6a2('0x14')](function(){var _0x1b6540=_0x47c72f[_0xd6a2('0x16')]({'plain':!![]});var _0x52bc2b=_0xd6a2('0x17');return db[_0xd6a2('0x18')][_0xd6a2('0x15')]({'where':{'type':_0x52bc2b,'resourceId':_0x1b6540['id']}})[_0xd6a2('0x14')](function(){return _0x47c72f;});})[_0xd6a2('0x14')](function(){_0x559d67[_0xd6a2('0xc')](0xcc)[_0xd6a2('0xd')]();});}};}function handleEntityNotFound(_0x1af467){return function(_0x586a19){if(!_0x586a19){_0x1af467['sendStatus'](0x194);}return _0x586a19;};}function handleError(_0x22540c,_0xed93f0){_0xed93f0=_0xed93f0||0x1f4;return function(_0x566857){logger['error'](_0x566857[_0xd6a2('0x19')]);if(_0x566857[_0xd6a2('0x1a')]){delete _0x566857[_0xd6a2('0x1a')];}_0x22540c[_0xd6a2('0xc')](_0xed93f0)[_0xd6a2('0x1b')](_0x566857);};}exports['index']=function(_0x4b85eb,_0x5788e3){var _0x5ed4f9={};var _0x970e33={'count':0x0,'rows':[]};var _0x4058c4=_[_0xd6a2('0x1c')](db[_0xd6a2('0x1d')][_0xd6a2('0x1e')],function(_0x5ef07d){return{'name':_0x5ef07d[_0xd6a2('0x1f')],'type':_0x5ef07d[_0xd6a2('0x20')][_0xd6a2('0x21')]};});_0x5ed4f9=qs[_0xd6a2('0x22')](_0x4058c4,_0x4b85eb);var _0x3aaf85={'where':_0x5ed4f9[_0xd6a2('0x23')]};return db[_0xd6a2('0x1d')][_0xd6a2('0x11')](_0x3aaf85)[_0xd6a2('0x14')](function(_0x4915b8){_0x970e33[_0xd6a2('0x11')]=_0x4915b8;_0x5ed4f9[_0xd6a2('0x24')]=qs[_0xd6a2('0x24')](_0x4b85eb['query']);return db['WhatsappQueue'][_0xd6a2('0x25')](_0x5ed4f9);})[_0xd6a2('0x14')](function(_0xea1cb2){_0x970e33[_0xd6a2('0x26')]=_0xea1cb2;return _0x970e33;})[_0xd6a2('0x14')](respondWithFilteredResult(_0x5788e3,_0x5ed4f9))[_0xd6a2('0x27')](handleError(_0x5788e3,null));};exports[_0xd6a2('0x28')]=function(_0x19a125,_0x5b5cf0){var _0x3db39d={'raw':!![],'where':{'id':_0x19a125[_0xd6a2('0x29')]['id']}},_0x10be98={};_0x10be98[_0xd6a2('0x2a')]=_[_0xd6a2('0x2b')](db[_0xd6a2('0x1d')][_0xd6a2('0x1e')]);_0x10be98[_0xd6a2('0x2c')]=_[_0xd6a2('0x2b')](_0x19a125[_0xd6a2('0x2c')]);_0x10be98[_0xd6a2('0x2d')]=_['intersection'](_0x10be98[_0xd6a2('0x2a')],_0x10be98[_0xd6a2('0x2c')]);_0x3db39d['attributes']=_[_0xd6a2('0x2e')](_0x10be98[_0xd6a2('0x2a')],qs[_0xd6a2('0x2f')](_0x19a125[_0xd6a2('0x2c')][_0xd6a2('0x2f')]));_0x3db39d[_0xd6a2('0x30')]=_0x3db39d[_0xd6a2('0x30')][_0xd6a2('0x31')]?_0x3db39d[_0xd6a2('0x30')]:_0x10be98['model'];if(_0x19a125[_0xd6a2('0x2c')][_0xd6a2('0x32')]){_0x3db39d['include']=[{'all':!![]}];}_0x3db39d=_[_0xd6a2('0x33')]({},_0x3db39d,_0x19a125[_0xd6a2('0x34')]);return db[_0xd6a2('0x1d')][_0xd6a2('0x35')](_0x3db39d)[_0xd6a2('0x14')](handleEntityNotFound(_0x5b5cf0,null))['then'](respondWithResult(_0x5b5cf0,null))[_0xd6a2('0x27')](handleError(_0x5b5cf0,null));};exports['create']=function(_0x1c66bd,_0x29b9a3){return db['WhatsappQueue'][_0xd6a2('0x36')](_0x1c66bd[_0xd6a2('0x37')],{})[_0xd6a2('0x14')](function(_0x530bea){var _0x1f48b8=_0x1c66bd[_0xd6a2('0x38')]['get']({'plain':!![]});if(!_0x1f48b8)throw new Error(_0xd6a2('0x39'));if(_0x1f48b8[_0xd6a2('0x3a')]===_0xd6a2('0x38')){var _0x2a9f49=_0x530bea[_0xd6a2('0x16')]({'plain':!![]});var _0x1aa8c6=_0xd6a2('0x17');return db[_0xd6a2('0x3b')]['find']({'where':{'name':_0x1aa8c6,'userProfileId':_0x1f48b8[_0xd6a2('0x3c')]},'raw':!![]})['then'](function(_0x5d0d16){if(_0x5d0d16&&_0x5d0d16['autoAssociation']===0x0){return db['UserProfileResource'][_0xd6a2('0x36')]({'name':_0x2a9f49[_0xd6a2('0x1a')],'resourceId':_0x2a9f49['id'],'type':_0x5d0d16[_0xd6a2('0x1a')],'sectionId':_0x5d0d16['id']},{})[_0xd6a2('0x14')](function(){return _0x530bea;});}else{return _0x530bea;}})[_0xd6a2('0x27')](function(_0x2c46f3){logger[_0xd6a2('0x3d')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x2c46f3);throw _0x2c46f3;});}return _0x530bea;})[_0xd6a2('0x14')](respondWithResult(_0x29b9a3,0xc9))[_0xd6a2('0x27')](handleError(_0x29b9a3,null));};exports[_0xd6a2('0x3e')]=function(_0x236a92,_0x48cb71){if(_0x236a92[_0xd6a2('0x37')]['id']){delete _0x236a92[_0xd6a2('0x37')]['id'];}return db[_0xd6a2('0x1d')]['find']({'where':{'id':_0x236a92[_0xd6a2('0x29')]['id']}})[_0xd6a2('0x14')](handleEntityNotFound(_0x48cb71,null))[_0xd6a2('0x14')](saveUpdates(_0x236a92[_0xd6a2('0x37')],null))['then'](respondWithResult(_0x48cb71,null))['catch'](handleError(_0x48cb71,null));};exports[_0xd6a2('0x15')]=function(_0x38e91e,_0x2a99fa){return db['WhatsappQueue'][_0xd6a2('0x35')]({'where':{'id':_0x38e91e[_0xd6a2('0x29')]['id']}})[_0xd6a2('0x14')](handleEntityNotFound(_0x2a99fa,null))[_0xd6a2('0x14')](removeEntity(_0x2a99fa,null))[_0xd6a2('0x27')](handleError(_0x2a99fa,null));};exports[_0xd6a2('0x3f')]=function(_0x56f73c,_0xd0a8ce){return db[_0xd6a2('0x1d')][_0xd6a2('0x3f')]()['then'](respondWithResult(_0xd0a8ce,null))['catch'](handleError(_0xd0a8ce,null));};exports[_0xd6a2('0x40')]=function(_0x3edabe,_0x2f6183){var _0x22be26={'raw':!![],'where':{}},_0x261e18={},_0x48d43e;return db[_0xd6a2('0x1d')][_0xd6a2('0x41')]({'where':{'id':_0x3edabe[_0xd6a2('0x29')]['id']}})[_0xd6a2('0x14')](handleEntityNotFound(_0x2f6183,null))[_0xd6a2('0x14')](function(_0xd707b6){if(_0xd707b6){_0x48d43e=_0xd707b6[_0xd6a2('0x16')]({'plain':!![]});_0x261e18['model']=_[_0xd6a2('0x2b')](db[_0xd6a2('0x42')][_0xd6a2('0x1e')]);_0x261e18[_0xd6a2('0x2c')]=_[_0xd6a2('0x2b')](_0x3edabe[_0xd6a2('0x2c')]);_0x261e18[_0xd6a2('0x2d')]=_[_0xd6a2('0x2e')](_0x261e18['model'],_0x261e18[_0xd6a2('0x2c')]);_0x22be26[_0xd6a2('0x30')]=_[_0xd6a2('0x2e')](_0x261e18['model'],qs['fields'](_0x3edabe['query'][_0xd6a2('0x2f')]));_0x22be26[_0xd6a2('0x30')]=_0x22be26['attributes'][_0xd6a2('0x31')]?_0x22be26['attributes']:_0x261e18['model'];if(!_0x3edabe[_0xd6a2('0x2c')][_0xd6a2('0x43')](_0xd6a2('0x44'))){_0x22be26[_0xd6a2('0x10')]=qs[_0xd6a2('0x10')](_0x3edabe['query'][_0xd6a2('0x10')]);_0x22be26[_0xd6a2('0xe')]=qs[_0xd6a2('0xe')](_0x3edabe[_0xd6a2('0x2c')][_0xd6a2('0xe')]);}_0x22be26['order']=qs[_0xd6a2('0x45')](_0x3edabe['query']['sort']);_0x22be26[_0xd6a2('0x23')]=qs[_0xd6a2('0x2d')](_[_0xd6a2('0x46')](_0x3edabe['query'],_0x261e18[_0xd6a2('0x2d')]));_0x22be26['where'][_0xd6a2('0x47')]=_0xd707b6['id'];if(_0x3edabe[_0xd6a2('0x2c')]['filter']){_0x22be26['where']=_[_0xd6a2('0x33')](_0x22be26['where'],{'$or':_[_0xd6a2('0x1c')](_0x22be26[_0xd6a2('0x30')],function(_0x34cab0){var _0x48386a={};_0x48386a[_0x34cab0]={'$like':'%'+_0x3edabe[_0xd6a2('0x2c')]['filter']+'%'};return _0x48386a;})});}_0x22be26=_['merge']({},_0x22be26,_0x3edabe[_0xd6a2('0x34')]);return db['UserWhatsappQueue']['findAll'](_0x22be26);}})[_0xd6a2('0x14')](function(_0xdd0a96){if(_0xdd0a96){return db[_0xd6a2('0x48')][_0xd6a2('0x49')]({'where':{'id':_[_0xd6a2('0x1c')](_0xdd0a96,_0xd6a2('0x4a')),'role':'agent'},'attributes':['id',_0xd6a2('0x1a'),_0xd6a2('0x4b'),_0xd6a2('0x4c'),_0xd6a2('0x4d')]});}})['then'](function(_0x550301){if(_0x550301){return{'count':_0x550301[_0xd6a2('0x11')],'rows':_[_0xd6a2('0x1c')](_0x550301[_0xd6a2('0x26')],function(_0x14eb3c){return{'membername':_0x14eb3c[_0xd6a2('0x1a')],'UserId':_0x14eb3c['id'],'queue_name':_0x48d43e[_0xd6a2('0x1a')],'WhatsappQueueId':_0x48d43e['id'],'interface':util[_0xd6a2('0x4e')]('%s/%s',_0xd6a2('0x4f'),_0x14eb3c[_0xd6a2('0x1a')]),'penalty':0x0,'paused':_0x14eb3c['whatsappPause'],'createdAt':_0x14eb3c[_0xd6a2('0x4d')],'updatedAt':_0x14eb3c['updatedAt']};})};}else{return{'count':0x0,'rows':[]};}})[_0xd6a2('0x14')](respondWithFilteredResult(_0x2f6183,_0x22be26))[_0xd6a2('0x27')](handleError(_0x2f6183,null));};exports[_0xd6a2('0x50')]=function(_0x15769c,_0x5a3455){var _0x557f2c={};var _0x1d137c={};var _0x2b4a77;var _0xba5865;return db['WhatsappQueue'][_0xd6a2('0x41')]({'where':{'id':_0x15769c[_0xd6a2('0x29')]['id']}})[_0xd6a2('0x14')](handleEntityNotFound(_0x5a3455,null))[_0xd6a2('0x14')](function(_0x110cbb){if(_0x110cbb){_0x2b4a77=_0x110cbb;_0x1d137c[_0xd6a2('0x2a')]=_[_0xd6a2('0x2b')](db['Team'][_0xd6a2('0x1e')]);_0x1d137c[_0xd6a2('0x2c')]=_['keys'](_0x15769c[_0xd6a2('0x2c')]);_0x1d137c[_0xd6a2('0x2d')]=_['intersection'](_0x1d137c[_0xd6a2('0x2a')],_0x1d137c[_0xd6a2('0x2c')]);_0x557f2c['attributes']=_[_0xd6a2('0x2e')](_0x1d137c[_0xd6a2('0x2a')],qs[_0xd6a2('0x2f')](_0x15769c[_0xd6a2('0x2c')][_0xd6a2('0x2f')]));_0x557f2c[_0xd6a2('0x30')]=_0x557f2c['attributes'][_0xd6a2('0x31')]?_0x557f2c[_0xd6a2('0x30')]:_0x1d137c[_0xd6a2('0x2a')];_0x557f2c['order']=qs[_0xd6a2('0x45')](_0x15769c[_0xd6a2('0x2c')]['sort']);_0x557f2c['where']=qs[_0xd6a2('0x2d')](_[_0xd6a2('0x46')](_0x15769c[_0xd6a2('0x2c')],_0x1d137c[_0xd6a2('0x2d')]));if(_0x15769c[_0xd6a2('0x2c')][_0xd6a2('0x51')]){_0x557f2c[_0xd6a2('0x23')]=_['merge'](_0x557f2c[_0xd6a2('0x23')],{'$or':_[_0xd6a2('0x1c')](_0x557f2c['attributes'],function(_0x308a3c){var _0x59f379={};_0x59f379[_0x308a3c]={'$like':'%'+_0x15769c[_0xd6a2('0x2c')][_0xd6a2('0x51')]+'%'};return _0x59f379;})});}_0x557f2c=_[_0xd6a2('0x33')]({},_0x557f2c,_0x15769c[_0xd6a2('0x34')]);return _0x2b4a77[_0xd6a2('0x50')](_0x557f2c);}})[_0xd6a2('0x14')](function(_0x56d477){if(_0x56d477){_0xba5865=_0x56d477[_0xd6a2('0x31')];if(!_0x15769c[_0xd6a2('0x2c')][_0xd6a2('0x43')]('nolimit')){_0x557f2c[_0xd6a2('0x10')]=qs['limit'](_0x15769c[_0xd6a2('0x2c')]['limit']);_0x557f2c[_0xd6a2('0xe')]=qs['offset'](_0x15769c[_0xd6a2('0x2c')][_0xd6a2('0xe')]);}return _0x2b4a77[_0xd6a2('0x50')](_0x557f2c);}})[_0xd6a2('0x14')](function(_0x1ceeda){if(_0x1ceeda){return _0x1ceeda?{'count':_0xba5865,'rows':_0x1ceeda}:null;}})[_0xd6a2('0x14')](respondWithResult(_0x5a3455,null))[_0xd6a2('0x27')](handleError(_0x5a3455,null));};exports[_0xd6a2('0x52')]=function(_0x4ab2b3,_0x2fd62b){var _0xdcbcb6=_0x4ab2b3[_0xd6a2('0x37')][_0xd6a2('0x53')];return db['Team'][_0xd6a2('0x25')]({'where':{'id':_0xdcbcb6},'attributes':['id'],'include':[{'model':db[_0xd6a2('0x48')],'as':'Agents','attributes':['id',_0xd6a2('0x1a'),'online',_0xd6a2('0x54'),'interface'],'raw':!![]}]})[_0xd6a2('0x14')](function(_0x55f1ad){if(_0x55f1ad){var _0x4c77a5=_[_0xd6a2('0x55')](_0x55f1ad,function(_0x328f36){var _0x1d811b=_0x328f36[_0xd6a2('0x16')]({'plain':!![]});return _0x1d811b[_0xd6a2('0x56')];});return db[_0xd6a2('0x1d')][_0xd6a2('0x35')]({'where':{'id':_0x4ab2b3['params']['id']}})[_0xd6a2('0x14')](function(_0x556593){return db[_0xd6a2('0x57')][_0xd6a2('0x58')](function(_0x2a18db){return _0x556593['addTeams'](_0xdcbcb6,{'transaction':_0x2a18db})[_0xd6a2('0x14')](function(){return BPromise[_0xd6a2('0x59')](_0x4c77a5,function(_0xbf4542){return db[_0xd6a2('0x42')][_0xd6a2('0x5a')]({'where':{'UserId':_0xbf4542['id'],'WhatsappQueueId':_0x4ab2b3['params']['id']},'transaction':_0x2a18db});});})[_0xd6a2('0x14')](function(){_0x4c77a5[_0xd6a2('0x5b')](function(_0xf40937){socket[_0xd6a2('0x5c')](_0xd6a2('0x5d'),{'UserId':_0xf40937['id'],'WhatsappQueueId':_0x556593['id']});});});});});}})[_0xd6a2('0x14')](respondWithStatusCode(_0x2fd62b,null))['catch'](handleError(_0x2fd62b,null));};exports[_0xd6a2('0x5e')]=function(_0x8c24b0,_0x1dbc30){return db[_0xd6a2('0x5f')][_0xd6a2('0x25')]({'where':{'id':_0x8c24b0[_0xd6a2('0x2c')]['ids']},'attributes':['id'],'include':[{'model':db[_0xd6a2('0x48')],'as':_0xd6a2('0x56'),'attributes':['id'],'raw':!![]}]})[_0xd6a2('0x14')](handleEntityNotFound(_0x1dbc30,null))[_0xd6a2('0x14')](function(_0xee54db){var _0x3c9f12=_['map'](_0xee54db,'id');var _0x78ad42=[];var _0x1d344a=[];var _0x5b336b=squel[_0xd6a2('0x60')]();_0x5b336b[_0xd6a2('0x61')]('tq.TeamId')[_0xd6a2('0x62')](_0xd6a2('0x63'),'tq')[_0xd6a2('0x64')](_0xd6a2('0x65'),'ut',_0xd6a2('0x66'))['where']('WhatsappQueueId\x20=\x20?',_0x8c24b0[_0xd6a2('0x29')]['id']);for(var _0x1ffd2b=0x0;_0x1ffd2b<_0xee54db[_0xd6a2('0x31')];_0x1ffd2b+=0x1){let _0x47e9e7=_0xee54db[_0x1ffd2b];for(var _0x16f5d2=0x0;_0x16f5d2<_0x47e9e7['Agents']['length'];_0x16f5d2+=0x1){let _0x3f6f4e=_0x47e9e7['Agents'][_0x16f5d2];var _0x1afdb1=_0x5b336b[_0xd6a2('0x67')]();_0x1afdb1['where'](_0xd6a2('0x68'),_0x3f6f4e['id']);_0x1d344a[_0xd6a2('0x69')](db['sequelize']['query'](_0x1afdb1[_0xd6a2('0x6a')](),{'type':db['sequelize'][_0xd6a2('0x6b')][_0xd6a2('0x6c')]})[_0xd6a2('0x14')](function(_0x5e9d76){if(_0x5e9d76[_0xd6a2('0x31')]===0x1){return _0x3f6f4e['id'];}else{var _0x59e45b=_[_0xd6a2('0x6d')](_['map'](_0x5e9d76,_0xd6a2('0x6e')),function(_0x172bc2){return _[_0xd6a2('0x6f')](_0x3c9f12,_0x172bc2);});if(_0x59e45b){return _0x3f6f4e['id'];}}}));}}return BPromise[_0xd6a2('0x70')](_0x1d344a)[_0xd6a2('0x14')](function(_0x506282){_0x78ad42=_(_0x78ad42)['union'](_0x506282)[_0xd6a2('0x71')]()[_0xd6a2('0x72')]();return db[_0xd6a2('0x1d')][_0xd6a2('0x35')]({'where':{'id':_0x8c24b0['params']['id']}})['then'](function(_0x4cd37f){return db[_0xd6a2('0x57')]['transaction'](function(_0x5c0e03){return _0x4cd37f[_0xd6a2('0x5e')](_0x8c24b0[_0xd6a2('0x2c')][_0xd6a2('0x53')],{'transaction':_0x5c0e03})[_0xd6a2('0x14')](function(){if(!_[_0xd6a2('0x73')](_0x78ad42)){return _0x4cd37f['removeAgents'](_0x78ad42,{'transaction':_0x5c0e03});}})['then'](function(){_0x78ad42[_0xd6a2('0x5b')](function(_0x3efc85){socket[_0xd6a2('0x5c')](_0xd6a2('0x74'),{'UserId':_0x3efc85,'WhatsappQueueId':_0x4cd37f['id']});});});});});});})['then'](respondWithStatusCode(_0x1dbc30,null))[_0xd6a2('0x27')](handleError(_0x1dbc30,null));};exports[_0xd6a2('0x75')]=function(_0xca5ea2,_0x20b284){return db[_0xd6a2('0x1d')][_0xd6a2('0x35')]({'where':{'id':_0xca5ea2['params']['id']}})[_0xd6a2('0x14')](handleEntityNotFound(_0x20b284,null))[_0xd6a2('0x14')](function(_0x271d70){if(_0x271d70){return _0x271d70['addAgents'](_0xca5ea2['body'][_0xd6a2('0x53')],_[_0xd6a2('0x76')](_0xca5ea2['body'],['ids','id'])||{})[_0xd6a2('0x77')](function(_0x171044){for(var _0x4743e0=0x0;_0x4743e0<_0xca5ea2['body'][_0xd6a2('0x53')][_0xd6a2('0x31')];_0x4743e0+=0x1){socket[_0xd6a2('0x5c')](_0xd6a2('0x5d'),{'UserId':Number(_0xca5ea2[_0xd6a2('0x37')][_0xd6a2('0x53')][_0x4743e0]),'WhatsappQueueId':Number(_0xca5ea2[_0xd6a2('0x29')]['id'])});}return _0x171044;});}})[_0xd6a2('0x14')](respondWithResult(_0x20b284,null))[_0xd6a2('0x27')](handleError(_0x20b284,null));};exports[_0xd6a2('0x78')]=function(_0x33c8e3,_0x5756dc){return db[_0xd6a2('0x1d')][_0xd6a2('0x35')]({'where':{'id':_0x33c8e3[_0xd6a2('0x29')]['id']}})[_0xd6a2('0x14')](handleEntityNotFound(_0x5756dc,null))[_0xd6a2('0x14')](function(_0x1a0c78){if(_0x1a0c78){return _0x1a0c78['removeAgents'](_0x33c8e3[_0xd6a2('0x2c')][_0xd6a2('0x53')])[_0xd6a2('0x14')](function(){if(_[_0xd6a2('0x79')](_0x33c8e3[_0xd6a2('0x2c')]['ids'])){for(var _0x37ecca=0x0;_0x37ecca<_0x33c8e3[_0xd6a2('0x2c')][_0xd6a2('0x53')][_0xd6a2('0x31')];_0x37ecca+=0x1){socket['emit'](_0xd6a2('0x74'),{'UserId':Number(_0x33c8e3[_0xd6a2('0x2c')]['ids'][_0x37ecca]),'WhatsappQueueId':Number(_0x33c8e3['params']['id'])});}}else{socket[_0xd6a2('0x5c')](_0xd6a2('0x74'),{'UserId':Number(_0x33c8e3[_0xd6a2('0x2c')][_0xd6a2('0x53')]),'WhatsappQueueId':Number(_0x33c8e3[_0xd6a2('0x29')]['id'])});}});}})[_0xd6a2('0x14')](respondWithStatusCode(_0x5756dc,null))[_0xd6a2('0x27')](handleError(_0x5756dc,null));};exports[_0xd6a2('0x7a')]=function(_0x130f01,_0x126724){var _0x276cae={};var _0x53585d={};var _0x5d1241;var _0x1bf288;return db[_0xd6a2('0x1d')][_0xd6a2('0x41')]({'where':{'id':_0x130f01[_0xd6a2('0x29')]['id']}})[_0xd6a2('0x14')](handleEntityNotFound(_0x126724,null))[_0xd6a2('0x14')](function(_0x196fe7){if(_0x196fe7){_0x5d1241=_0x196fe7;_0x53585d[_0xd6a2('0x2a')]=_[_0xd6a2('0x2b')](db[_0xd6a2('0x48')][_0xd6a2('0x1e')]);_0x53585d['query']=_['keys'](_0x130f01[_0xd6a2('0x2c')]);_0x53585d[_0xd6a2('0x2d')]=_[_0xd6a2('0x2e')](_0x53585d[_0xd6a2('0x2a')],_0x53585d[_0xd6a2('0x2c')]);_0x276cae[_0xd6a2('0x30')]=_['intersection'](_0x53585d[_0xd6a2('0x2a')],qs[_0xd6a2('0x2f')](_0x130f01[_0xd6a2('0x2c')][_0xd6a2('0x2f')]));_0x276cae['attributes']=_0x276cae[_0xd6a2('0x30')]['length']?_0x276cae[_0xd6a2('0x30')]:_0x53585d[_0xd6a2('0x2a')];_0x276cae['order']=qs[_0xd6a2('0x45')](_0x130f01[_0xd6a2('0x2c')][_0xd6a2('0x45')]);_0x276cae['where']=qs[_0xd6a2('0x2d')](_[_0xd6a2('0x46')](_0x130f01[_0xd6a2('0x2c')],_0x53585d[_0xd6a2('0x2d')]));if(_0x130f01['query'][_0xd6a2('0x51')]){_0x276cae[_0xd6a2('0x23')]=_['merge'](_0x276cae[_0xd6a2('0x23')],{'$or':_[_0xd6a2('0x1c')](_0x276cae[_0xd6a2('0x30')],function(_0x19df25){var _0x4bbb9b={};_0x4bbb9b[_0x19df25]={'$like':'%'+_0x130f01[_0xd6a2('0x2c')]['filter']+'%'};return _0x4bbb9b;})});}_0x276cae=_['merge']({},_0x276cae,_0x130f01[_0xd6a2('0x34')]);return _0x5d1241[_0xd6a2('0x7a')](_0x276cae);}})[_0xd6a2('0x14')](function(_0x34a3b8){if(_0x34a3b8){_0x1bf288=_0x34a3b8[_0xd6a2('0x31')];if(!_0x130f01[_0xd6a2('0x2c')][_0xd6a2('0x43')](_0xd6a2('0x44'))){_0x276cae[_0xd6a2('0x10')]=qs[_0xd6a2('0x10')](_0x130f01[_0xd6a2('0x2c')][_0xd6a2('0x10')]);_0x276cae[_0xd6a2('0xe')]=qs[_0xd6a2('0xe')](_0x130f01[_0xd6a2('0x2c')][_0xd6a2('0xe')]);}return _0x5d1241[_0xd6a2('0x7a')](_0x276cae);}})[_0xd6a2('0x14')](function(_0xb62ece){if(_0xb62ece){return _0xb62ece?{'count':_0x1bf288,'rows':_0xb62ece}:null;}})[_0xd6a2('0x14')](respondWithResult(_0x126724,null))['catch'](handleError(_0x126724,null));};
\ No newline at end of file