Built motion from commit (unavailable).|2.5.22
[motion2.git] / server / api / whatsappQueue / whatsappQueue.controller.js
index f6bb4bb..7d96e77 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x2d22=['Team','findAll','User','Agents','online','voicePause','interface','flatMap','sequelize','transaction','each','findOrCreate','forEach','emit','ids','select','field','from','join','user_has_teams','ut.TeamId\x20=\x20tq.TeamId','ut.UserId\x20=\x20?','push','toString','QueryTypes','SELECT','every','TeamId','includes','all','removeTeams','isEmpty','removeAgents','userWhatsappQueue:remove','addAgents','omit','userWhatsappQueue:save','isArray','getAgents','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','util','sox','to-csv','ejs','lodash','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/environment','../../mysqldb','redis','defaults','localhost','socket.io-emitter','register','sendStatus','status','end','count','offset','set','Content-Range','json','reject','save','update','then','destroy','WhatsappQueues','UserProfileResource','error','stack','name','send','map','WhatsappQueue','fieldName','type','model','query','keys','filters','intersection','attributes','fields','length','nolimit','limit','sort','where','pick','filter','VIRTUAL','merge','options','includeAll','include','rows','catch','show','params','rawAttributes','find','create','body','user','role','UserProfileSection','autoAssociation','describe','getMembers','findOne','get','UserWhatsappQueue','order','WhatsappQueueId','findAndCountAll','UserId','updatedAt','createdAt','format','SIP','getTeams','hasOwnProperty','addTeams'];(function(_0x580cea,_0x41fab5){var _0x5311c8=function(_0x3c654f){while(--_0x3c654f){_0x580cea['push'](_0x580cea['shift']());}};_0x5311c8(++_0x41fab5);}(_0x2d22,0x139));var _0x22d2=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0x2d22[_0x3dd15e];return _0x231fd0;};'use strict';var pdf=require('html-pdf');var emlformat=require('eml-format');var rimraf=require(_0x22d2('0x0'));var zipdir=require(_0x22d2('0x1'));var jsonpatch=require(_0x22d2('0x2'));var rp=require(_0x22d2('0x3'));var moment=require(_0x22d2('0x4'));var BPromise=require(_0x22d2('0x5'));var Mustache=require('mustache');var util=require(_0x22d2('0x6'));var path=require('path');var sox=require(_0x22d2('0x7'));var csv=require(_0x22d2('0x8'));var ejs=require(_0x22d2('0x9'));var fs=require('fs');var _=require(_0x22d2('0xa'));var squel=require('squel');var crypto=require(_0x22d2('0xb'));var jsforce=require(_0x22d2('0xc'));var deskjs=require(_0x22d2('0xd'));var toCsv=require(_0x22d2('0x8'));var querystring=require(_0x22d2('0xe'));var Papa=require(_0x22d2('0xf'));var Redis=require(_0x22d2('0x10'));var authService=require(_0x22d2('0x11'));var qs=require('../../components/parsers/qs');var as=require(_0x22d2('0x12'));var hardwareService=require(_0x22d2('0x13'));var logger=require('../../config/logger')(_0x22d2('0x14'));var utils=require('../../config/utils');var config=require(_0x22d2('0x15'));var licenseUtil=require('../../config/license/util');var db=require(_0x22d2('0x16'))['db'];config[_0x22d2('0x17')]=_[_0x22d2('0x18')](config[_0x22d2('0x17')],{'host':_0x22d2('0x19'),'port':0x18eb});var socket=require(_0x22d2('0x1a'))(new Redis(config['redis']));require('./whatsappQueue.socket')[_0x22d2('0x1b')](socket);function respondWithStatusCode(_0x2d75e6,_0x12a1c5){_0x12a1c5=_0x12a1c5||0xcc;return function(_0x570a61){if(_0x570a61){return _0x2d75e6[_0x22d2('0x1c')](_0x12a1c5);}return _0x2d75e6[_0x22d2('0x1d')](_0x12a1c5)[_0x22d2('0x1e')]();};}function respondWithResult(_0x30fda1,_0x5d1383){_0x5d1383=_0x5d1383||0xc8;return function(_0x48002b){if(_0x48002b){return _0x30fda1[_0x22d2('0x1d')](_0x5d1383)['json'](_0x48002b);}};}function respondWithFilteredResult(_0x343fcf,_0x35eb54){return function(_0x230d4d){if(_0x230d4d){var _0x18e9f9=_0x230d4d[_0x22d2('0x1f')],_0x36a027=_0x35eb54[_0x22d2('0x20')],_0x159a63=_0x35eb54[_0x22d2('0x20')]+_0x35eb54['limit'],_0x82eb16;if(_0x159a63>=_0x18e9f9){_0x159a63=_0x18e9f9;_0x82eb16=0xc8;}else{_0x82eb16=0xce;}_0x343fcf[_0x22d2('0x1d')](_0x82eb16);return _0x343fcf[_0x22d2('0x21')](_0x22d2('0x22'),_0x36a027+'-'+_0x159a63+'/'+_0x18e9f9)[_0x22d2('0x23')](_0x230d4d);}return null;};}function patchUpdates(_0x44f426){return function(_0x35de8d){try{jsonpatch['apply'](_0x35de8d,_0x44f426,!![]);}catch(_0x31355d){return BPromise[_0x22d2('0x24')](_0x31355d);}return _0x35de8d[_0x22d2('0x25')]();};}function saveUpdates(_0x5ca8f0,_0x550efb){return function(_0x1eafd){if(_0x1eafd){return _0x1eafd[_0x22d2('0x26')](_0x5ca8f0)[_0x22d2('0x27')](function(_0x2bcdcf){return _0x2bcdcf;});}return null;};}function removeEntity(_0xea614a,_0x341e7d){return function(_0x30044d){if(_0x30044d){return _0x30044d[_0x22d2('0x28')]()[_0x22d2('0x27')](function(){var _0x1e671e=_0x30044d['get']({'plain':!![]});var _0x5e2ee9=_0x22d2('0x29');return db[_0x22d2('0x2a')]['destroy']({'where':{'type':_0x5e2ee9,'resourceId':_0x1e671e['id']}})[_0x22d2('0x27')](function(){return _0x30044d;});})[_0x22d2('0x27')](function(){_0xea614a[_0x22d2('0x1d')](0xcc)[_0x22d2('0x1e')]();});}};}function handleEntityNotFound(_0x415a2f,_0x21b176){return function(_0x47c1cf){if(!_0x47c1cf){_0x415a2f[_0x22d2('0x1c')](0x194);}return _0x47c1cf;};}function handleError(_0x36d94b,_0x5afaad){_0x5afaad=_0x5afaad||0x1f4;return function(_0x3cb8ca){logger[_0x22d2('0x2b')](_0x3cb8ca[_0x22d2('0x2c')]);if(_0x3cb8ca[_0x22d2('0x2d')]){delete _0x3cb8ca[_0x22d2('0x2d')];}_0x36d94b['status'](_0x5afaad)[_0x22d2('0x2e')](_0x3cb8ca);};}exports['index']=function(_0x219ed5,_0x200d5b){var _0x3d95e0={},_0x18ea3d={},_0x2317c0={'count':0x0,'rows':[]};var _0x463e08=_[_0x22d2('0x2f')](db[_0x22d2('0x30')]['rawAttributes'],function(_0x3fe469){return{'name':_0x3fe469[_0x22d2('0x31')],'type':_0x3fe469[_0x22d2('0x32')]['key']};});_0x18ea3d[_0x22d2('0x33')]=_[_0x22d2('0x2f')](_0x463e08,_0x22d2('0x2d'));_0x18ea3d[_0x22d2('0x34')]=_[_0x22d2('0x35')](_0x219ed5['query']);_0x18ea3d[_0x22d2('0x36')]=_[_0x22d2('0x37')](_0x18ea3d[_0x22d2('0x33')],_0x18ea3d[_0x22d2('0x34')]);_0x3d95e0[_0x22d2('0x38')]=_[_0x22d2('0x37')](_0x18ea3d['model'],qs[_0x22d2('0x39')](_0x219ed5[_0x22d2('0x34')][_0x22d2('0x39')]));_0x3d95e0[_0x22d2('0x38')]=_0x3d95e0['attributes'][_0x22d2('0x3a')]?_0x3d95e0['attributes']:_0x18ea3d[_0x22d2('0x33')];if(!_0x219ed5['query']['hasOwnProperty'](_0x22d2('0x3b'))){_0x3d95e0[_0x22d2('0x3c')]=qs[_0x22d2('0x3c')](_0x219ed5['query'][_0x22d2('0x3c')]);_0x3d95e0[_0x22d2('0x20')]=qs[_0x22d2('0x20')](_0x219ed5[_0x22d2('0x34')]['offset']);}_0x3d95e0['order']=qs['sort'](_0x219ed5[_0x22d2('0x34')][_0x22d2('0x3d')]);_0x3d95e0[_0x22d2('0x3e')]=qs[_0x22d2('0x36')](_[_0x22d2('0x3f')](_0x219ed5[_0x22d2('0x34')],_0x18ea3d[_0x22d2('0x36')]),_0x463e08);if(_0x219ed5[_0x22d2('0x34')][_0x22d2('0x40')]){_0x3d95e0['where']=_['merge'](_0x3d95e0[_0x22d2('0x3e')],{'$or':_[_0x22d2('0x2f')](_0x463e08,function(_0x4b8aad){if(_0x4b8aad[_0x22d2('0x32')]!==_0x22d2('0x41')){var _0x48a44f={};_0x48a44f[_0x4b8aad['name']]={'$like':'%'+_0x219ed5['query']['filter']+'%'};return _0x48a44f;}})});}_0x3d95e0=_[_0x22d2('0x42')]({},_0x3d95e0,_0x219ed5[_0x22d2('0x43')]);var _0x503866={'where':_0x3d95e0[_0x22d2('0x3e')]};return db[_0x22d2('0x30')][_0x22d2('0x1f')](_0x503866)[_0x22d2('0x27')](function(_0x368f99){_0x2317c0[_0x22d2('0x1f')]=_0x368f99;if(_0x219ed5[_0x22d2('0x34')][_0x22d2('0x44')]){_0x3d95e0[_0x22d2('0x45')]=[{'all':!![]}];}return db[_0x22d2('0x30')]['findAll'](_0x3d95e0);})[_0x22d2('0x27')](function(_0x4724e5){_0x2317c0[_0x22d2('0x46')]=_0x4724e5;return _0x2317c0;})['then'](respondWithFilteredResult(_0x200d5b,_0x3d95e0))[_0x22d2('0x47')](handleError(_0x200d5b,null));};exports[_0x22d2('0x48')]=function(_0x509630,_0x208c14){var _0x1b23f7={'raw':!![],'where':{'id':_0x509630[_0x22d2('0x49')]['id']}},_0x7fb1cb={};_0x7fb1cb['model']=_[_0x22d2('0x35')](db[_0x22d2('0x30')][_0x22d2('0x4a')]);_0x7fb1cb['query']=_[_0x22d2('0x35')](_0x509630[_0x22d2('0x34')]);_0x7fb1cb[_0x22d2('0x36')]=_[_0x22d2('0x37')](_0x7fb1cb[_0x22d2('0x33')],_0x7fb1cb[_0x22d2('0x34')]);_0x1b23f7[_0x22d2('0x38')]=_[_0x22d2('0x37')](_0x7fb1cb[_0x22d2('0x33')],qs[_0x22d2('0x39')](_0x509630['query'][_0x22d2('0x39')]));_0x1b23f7[_0x22d2('0x38')]=_0x1b23f7['attributes'][_0x22d2('0x3a')]?_0x1b23f7[_0x22d2('0x38')]:_0x7fb1cb['model'];if(_0x509630[_0x22d2('0x34')]['includeAll']){_0x1b23f7['include']=[{'all':!![]}];}_0x1b23f7=_[_0x22d2('0x42')]({},_0x1b23f7,_0x509630[_0x22d2('0x43')]);return db['WhatsappQueue'][_0x22d2('0x4b')](_0x1b23f7)[_0x22d2('0x27')](handleEntityNotFound(_0x208c14,null))[_0x22d2('0x27')](respondWithResult(_0x208c14,null))[_0x22d2('0x47')](handleError(_0x208c14,null));};exports[_0x22d2('0x4c')]=function(_0x8c6811,_0x378833){return db[_0x22d2('0x30')][_0x22d2('0x4c')](_0x8c6811[_0x22d2('0x4d')],{})['then'](function(_0x229e23){var _0x2dca27=_0x8c6811[_0x22d2('0x4e')]['get']({'plain':!![]});if(!_0x2dca27)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x2dca27[_0x22d2('0x4f')]===_0x22d2('0x4e')){var _0x4b57b1=_0x229e23['get']({'plain':!![]});var _0x2fc48f='WhatsappQueues';return db[_0x22d2('0x50')][_0x22d2('0x4b')]({'where':{'name':_0x2fc48f,'userProfileId':_0x2dca27['userProfileId']},'raw':!![]})[_0x22d2('0x27')](function(_0x31eeb6){if(_0x31eeb6&&_0x31eeb6[_0x22d2('0x51')]===0x0){return db[_0x22d2('0x2a')][_0x22d2('0x4c')]({'name':_0x4b57b1[_0x22d2('0x2d')],'resourceId':_0x4b57b1['id'],'type':_0x31eeb6[_0x22d2('0x2d')],'sectionId':_0x31eeb6['id']},{})[_0x22d2('0x27')](function(){return _0x229e23;});}else{return _0x229e23;}})[_0x22d2('0x47')](function(_0x494b5e){logger[_0x22d2('0x2b')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x494b5e);throw _0x494b5e;});}return _0x229e23;})[_0x22d2('0x27')](respondWithResult(_0x378833,0xc9))[_0x22d2('0x47')](handleError(_0x378833,null));};exports[_0x22d2('0x26')]=function(_0x273b1,_0x3f45e6){if(_0x273b1['body']['id']){delete _0x273b1['body']['id'];}return db[_0x22d2('0x30')][_0x22d2('0x4b')]({'where':{'id':_0x273b1['params']['id']}})['then'](handleEntityNotFound(_0x3f45e6,null))[_0x22d2('0x27')](saveUpdates(_0x273b1[_0x22d2('0x4d')],null))[_0x22d2('0x27')](respondWithResult(_0x3f45e6,null))[_0x22d2('0x47')](handleError(_0x3f45e6,null));};exports[_0x22d2('0x28')]=function(_0x428c2c,_0x2561da){return db['WhatsappQueue'][_0x22d2('0x4b')]({'where':{'id':_0x428c2c[_0x22d2('0x49')]['id']}})['then'](handleEntityNotFound(_0x2561da,null))[_0x22d2('0x27')](removeEntity(_0x2561da,null))[_0x22d2('0x47')](handleError(_0x2561da,null));};exports[_0x22d2('0x52')]=function(_0x114196,_0x3e7bb8){return db[_0x22d2('0x30')][_0x22d2('0x52')]()[_0x22d2('0x27')](respondWithResult(_0x3e7bb8,null))['catch'](handleError(_0x3e7bb8,null));};exports[_0x22d2('0x53')]=function(_0xab6ab1,_0x457d29,_0x4449c0){var _0x35b4c0={'raw':!![],'where':{}},_0x53d3a1={},_0x3838e9;return db[_0x22d2('0x30')][_0x22d2('0x54')]({'where':{'id':_0xab6ab1[_0x22d2('0x49')]['id']}})[_0x22d2('0x27')](handleEntityNotFound(_0x457d29,null))[_0x22d2('0x27')](function(_0x2756ba){if(_0x2756ba){_0x3838e9=_0x2756ba[_0x22d2('0x55')]({'plain':!![]});_0x53d3a1['model']=_[_0x22d2('0x35')](db[_0x22d2('0x56')][_0x22d2('0x4a')]);_0x53d3a1[_0x22d2('0x34')]=_[_0x22d2('0x35')](_0xab6ab1['query']);_0x53d3a1[_0x22d2('0x36')]=_[_0x22d2('0x37')](_0x53d3a1['model'],_0x53d3a1[_0x22d2('0x34')]);_0x35b4c0[_0x22d2('0x38')]=_[_0x22d2('0x37')](_0x53d3a1[_0x22d2('0x33')],qs[_0x22d2('0x39')](_0xab6ab1['query'][_0x22d2('0x39')]));_0x35b4c0[_0x22d2('0x38')]=_0x35b4c0['attributes']['length']?_0x35b4c0[_0x22d2('0x38')]:_0x53d3a1[_0x22d2('0x33')];if(!_0xab6ab1[_0x22d2('0x34')]['hasOwnProperty']('nolimit')){_0x35b4c0[_0x22d2('0x3c')]=qs[_0x22d2('0x3c')](_0xab6ab1[_0x22d2('0x34')][_0x22d2('0x3c')]);_0x35b4c0[_0x22d2('0x20')]=qs[_0x22d2('0x20')](_0xab6ab1[_0x22d2('0x34')][_0x22d2('0x20')]);}_0x35b4c0[_0x22d2('0x57')]=qs[_0x22d2('0x3d')](_0xab6ab1['query'][_0x22d2('0x3d')]);_0x35b4c0['where']=qs['filters'](_['pick'](_0xab6ab1[_0x22d2('0x34')],_0x53d3a1[_0x22d2('0x36')]));_0x35b4c0[_0x22d2('0x3e')][_0x22d2('0x58')]=_0x2756ba['id'];if(_0xab6ab1[_0x22d2('0x34')]['filter']){_0x35b4c0['where']=_[_0x22d2('0x42')](_0x35b4c0[_0x22d2('0x3e')],{'$or':_['map'](_0x35b4c0[_0x22d2('0x38')],function(_0x103af4){var _0x476cce={};_0x476cce[_0x103af4]={'$like':'%'+_0xab6ab1['query'][_0x22d2('0x40')]+'%'};return _0x476cce;})});}_0x35b4c0=_[_0x22d2('0x42')]({},_0x35b4c0,_0xab6ab1[_0x22d2('0x43')]);return db['UserWhatsappQueue']['findAll'](_0x35b4c0);}})[_0x22d2('0x27')](function(_0x25774a){if(_0x25774a){return db['User'][_0x22d2('0x59')]({'where':{'id':_[_0x22d2('0x2f')](_0x25774a,_0x22d2('0x5a')),'role':'agent'},'attributes':['id',_0x22d2('0x2d'),'whatsappPause',_0x22d2('0x5b'),_0x22d2('0x5c')]});}})[_0x22d2('0x27')](function(_0x32137f){if(_0x32137f){return{'count':_0x32137f['count'],'rows':_[_0x22d2('0x2f')](_0x32137f[_0x22d2('0x46')],function(_0x53b948){return{'membername':_0x53b948[_0x22d2('0x2d')],'UserId':_0x53b948['id'],'queue_name':_0x3838e9[_0x22d2('0x2d')],'WhatsappQueueId':_0x3838e9['id'],'interface':util[_0x22d2('0x5d')]('%s/%s',_0x22d2('0x5e'),_0x53b948[_0x22d2('0x2d')]),'penalty':0x0,'paused':_0x53b948['whatsappPause'],'createdAt':_0x53b948[_0x22d2('0x5c')],'updatedAt':_0x53b948['updatedAt']};})};}else{return{'count':0x0,'rows':[]};}})[_0x22d2('0x27')](respondWithFilteredResult(_0x457d29,_0x35b4c0))[_0x22d2('0x47')](handleError(_0x457d29,null));};exports['getTeams']=function(_0x4350d4,_0x55bf56,_0x363a82){var _0x12d83a={};var _0x3ecdd8={};var _0x4f0158;var _0x53829a;return db['WhatsappQueue'][_0x22d2('0x54')]({'where':{'id':_0x4350d4[_0x22d2('0x49')]['id']}})[_0x22d2('0x27')](handleEntityNotFound(_0x55bf56,null))['then'](function(_0x278eeb){if(_0x278eeb){_0x4f0158=_0x278eeb;_0x3ecdd8['model']=_[_0x22d2('0x35')](db['Team'][_0x22d2('0x4a')]);_0x3ecdd8[_0x22d2('0x34')]=_[_0x22d2('0x35')](_0x4350d4[_0x22d2('0x34')]);_0x3ecdd8[_0x22d2('0x36')]=_['intersection'](_0x3ecdd8[_0x22d2('0x33')],_0x3ecdd8[_0x22d2('0x34')]);_0x12d83a['attributes']=_[_0x22d2('0x37')](_0x3ecdd8[_0x22d2('0x33')],qs[_0x22d2('0x39')](_0x4350d4[_0x22d2('0x34')][_0x22d2('0x39')]));_0x12d83a[_0x22d2('0x38')]=_0x12d83a[_0x22d2('0x38')][_0x22d2('0x3a')]?_0x12d83a[_0x22d2('0x38')]:_0x3ecdd8[_0x22d2('0x33')];_0x12d83a[_0x22d2('0x57')]=qs[_0x22d2('0x3d')](_0x4350d4['query']['sort']);_0x12d83a[_0x22d2('0x3e')]=qs[_0x22d2('0x36')](_[_0x22d2('0x3f')](_0x4350d4[_0x22d2('0x34')],_0x3ecdd8[_0x22d2('0x36')]));if(_0x4350d4['query'][_0x22d2('0x40')]){_0x12d83a[_0x22d2('0x3e')]=_['merge'](_0x12d83a[_0x22d2('0x3e')],{'$or':_['map'](_0x12d83a[_0x22d2('0x38')],function(_0x1aa68f){var _0x3484f={};_0x3484f[_0x1aa68f]={'$like':'%'+_0x4350d4[_0x22d2('0x34')][_0x22d2('0x40')]+'%'};return _0x3484f;})});}_0x12d83a=_[_0x22d2('0x42')]({},_0x12d83a,_0x4350d4[_0x22d2('0x43')]);return _0x4f0158[_0x22d2('0x5f')](_0x12d83a);}})['then'](function(_0x57ecc0){if(_0x57ecc0){_0x53829a=_0x57ecc0[_0x22d2('0x3a')];if(!_0x4350d4[_0x22d2('0x34')][_0x22d2('0x60')](_0x22d2('0x3b'))){_0x12d83a['limit']=qs[_0x22d2('0x3c')](_0x4350d4[_0x22d2('0x34')][_0x22d2('0x3c')]);_0x12d83a[_0x22d2('0x20')]=qs['offset'](_0x4350d4[_0x22d2('0x34')]['offset']);}return _0x4f0158['getTeams'](_0x12d83a);}})['then'](function(_0x1b5342){if(_0x1b5342){return _0x1b5342?{'count':_0x53829a,'rows':_0x1b5342}:null;}})[_0x22d2('0x27')](respondWithResult(_0x55bf56,null))[_0x22d2('0x47')](handleError(_0x55bf56,null));};exports[_0x22d2('0x61')]=function(_0x3dd759,_0x81866a,_0x1d5b0c){var _0x3c2223=_0x3dd759[_0x22d2('0x4d')]['ids'];return db[_0x22d2('0x62')][_0x22d2('0x63')]({'where':{'id':_0x3c2223},'attributes':['id'],'include':[{'model':db[_0x22d2('0x64')],'as':_0x22d2('0x65'),'attributes':['id',_0x22d2('0x2d'),_0x22d2('0x66'),_0x22d2('0x67'),_0x22d2('0x68')],'raw':!![]}]})[_0x22d2('0x27')](function(_0x4e1f8a){if(_0x4e1f8a){var _0x338ed1=_[_0x22d2('0x69')](_0x4e1f8a,function(_0x22d5ec){var _0x176457=_0x22d5ec['get']({'plain':!![]});return _0x176457[_0x22d2('0x65')];});return db[_0x22d2('0x30')][_0x22d2('0x4b')]({'where':{'id':_0x3dd759[_0x22d2('0x49')]['id']}})[_0x22d2('0x27')](function(_0x952064){return db[_0x22d2('0x6a')][_0x22d2('0x6b')](function(_0x1bede6){return _0x952064[_0x22d2('0x61')](_0x3c2223,{'transaction':_0x1bede6})[_0x22d2('0x27')](function(){return BPromise[_0x22d2('0x6c')](_0x338ed1,function(_0x4f2ba4){return db[_0x22d2('0x56')][_0x22d2('0x6d')]({'where':{'UserId':_0x4f2ba4['id'],'WhatsappQueueId':_0x3dd759['params']['id']},'transaction':_0x1bede6});});})[_0x22d2('0x27')](function(){_0x338ed1[_0x22d2('0x6e')](function(_0x4613f9){socket[_0x22d2('0x6f')]('userWhatsappQueue:save',{'UserId':_0x4613f9['id'],'WhatsappQueueId':_0x952064['id']});});});});});}})[_0x22d2('0x27')](respondWithStatusCode(_0x81866a,null))[_0x22d2('0x47')](handleError(_0x81866a,null));};exports['removeTeams']=function(_0x5502f1,_0x38a605,_0x3de207){return db[_0x22d2('0x62')][_0x22d2('0x63')]({'where':{'id':_0x5502f1[_0x22d2('0x34')][_0x22d2('0x70')]},'attributes':['id'],'include':[{'model':db[_0x22d2('0x64')],'as':_0x22d2('0x65'),'attributes':['id'],'raw':!![]}]})[_0x22d2('0x27')](handleEntityNotFound(_0x38a605,null))[_0x22d2('0x27')](function(_0x4ec50f){var _0x530c90=_[_0x22d2('0x2f')](_0x4ec50f,'id');var _0x3be5cd=[];var _0x163a36=[];var _0x3c5262=squel[_0x22d2('0x71')]();_0x3c5262[_0x22d2('0x72')]('tq.TeamId')[_0x22d2('0x73')]('team_has_whatsapp_queues','tq')[_0x22d2('0x74')](_0x22d2('0x75'),'ut',_0x22d2('0x76'))['where']('WhatsappQueueId\x20=\x20?',_0x5502f1[_0x22d2('0x49')]['id']);for(var _0x22b96a=0x0;_0x22b96a<_0x4ec50f[_0x22d2('0x3a')];_0x22b96a+=0x1){let _0x22c1d4=_0x4ec50f[_0x22b96a];for(var _0x408e58=0x0;_0x408e58<_0x22c1d4[_0x22d2('0x65')][_0x22d2('0x3a')];_0x408e58+=0x1){let _0xa032cd=_0x22c1d4[_0x22d2('0x65')][_0x408e58];var _0x23304d=_0x3c5262['clone']();_0x23304d[_0x22d2('0x3e')](_0x22d2('0x77'),_0xa032cd['id']);_0x163a36[_0x22d2('0x78')](db[_0x22d2('0x6a')]['query'](_0x23304d[_0x22d2('0x79')](),{'type':db[_0x22d2('0x6a')][_0x22d2('0x7a')][_0x22d2('0x7b')]})[_0x22d2('0x27')](function(_0x534fce){if(_0x534fce[_0x22d2('0x3a')]===0x1){return _0xa032cd['id'];}else{var _0x24c82c=_[_0x22d2('0x7c')](_[_0x22d2('0x2f')](_0x534fce,_0x22d2('0x7d')),function(_0x51c81a){return _[_0x22d2('0x7e')](_0x530c90,_0x51c81a);});if(_0x24c82c){return _0xa032cd['id'];}}}));}}return BPromise[_0x22d2('0x7f')](_0x163a36)[_0x22d2('0x27')](function(_0x14e86a){_0x3be5cd=_(_0x3be5cd)['union'](_0x14e86a)['compact']()['value']();return db['WhatsappQueue'][_0x22d2('0x4b')]({'where':{'id':_0x5502f1[_0x22d2('0x49')]['id']}})[_0x22d2('0x27')](function(_0x47145f){return db[_0x22d2('0x6a')][_0x22d2('0x6b')](function(_0x249f3e){return _0x47145f[_0x22d2('0x80')](_0x5502f1[_0x22d2('0x34')][_0x22d2('0x70')],{'transaction':_0x249f3e})[_0x22d2('0x27')](function(){if(!_[_0x22d2('0x81')](_0x3be5cd)){return _0x47145f[_0x22d2('0x82')](_0x3be5cd,{'transaction':_0x249f3e});}})[_0x22d2('0x27')](function(){_0x3be5cd[_0x22d2('0x6e')](function(_0x155cd3){socket[_0x22d2('0x6f')](_0x22d2('0x83'),{'UserId':_0x155cd3,'WhatsappQueueId':_0x47145f['id']});});});});});});})['then'](respondWithStatusCode(_0x38a605,null))['catch'](handleError(_0x38a605,null));};exports['addAgents']=function(_0x2da8c9,_0xb32e58,_0x221ada){return db[_0x22d2('0x30')]['find']({'where':{'id':_0x2da8c9[_0x22d2('0x49')]['id']}})[_0x22d2('0x27')](handleEntityNotFound(_0xb32e58,null))[_0x22d2('0x27')](function(_0x4b91ab){if(_0x4b91ab){return _0x4b91ab[_0x22d2('0x84')](_0x2da8c9[_0x22d2('0x4d')]['ids'],_[_0x22d2('0x85')](_0x2da8c9[_0x22d2('0x4d')],[_0x22d2('0x70'),'id'])||{})['spread'](function(_0x58de44){for(var _0x2f2c55=0x0;_0x2f2c55<_0x2da8c9[_0x22d2('0x4d')][_0x22d2('0x70')][_0x22d2('0x3a')];_0x2f2c55+=0x1){socket[_0x22d2('0x6f')](_0x22d2('0x86'),{'UserId':_0x2da8c9[_0x22d2('0x4d')]['ids'][_0x2f2c55],'WhatsappQueueId':_0x2da8c9[_0x22d2('0x49')]['id']});}return _0x58de44;});}})[_0x22d2('0x27')](respondWithResult(_0xb32e58,null))['catch'](handleError(_0xb32e58,null));};exports[_0x22d2('0x82')]=function(_0x5d9bb3,_0x42bdcf,_0x122288){return db[_0x22d2('0x30')][_0x22d2('0x4b')]({'where':{'id':_0x5d9bb3['params']['id']}})[_0x22d2('0x27')](handleEntityNotFound(_0x42bdcf,null))[_0x22d2('0x27')](function(_0x339e2d){if(_0x339e2d){return _0x339e2d[_0x22d2('0x82')](_0x5d9bb3[_0x22d2('0x34')]['ids'])['then'](function(){if(_[_0x22d2('0x87')](_0x5d9bb3[_0x22d2('0x34')][_0x22d2('0x70')])){for(var _0x46c707=0x0;_0x46c707<_0x5d9bb3[_0x22d2('0x34')]['ids'][_0x22d2('0x3a')];_0x46c707+=0x1){socket[_0x22d2('0x6f')](_0x22d2('0x83'),{'UserId':Number(_0x5d9bb3[_0x22d2('0x34')][_0x22d2('0x70')][_0x46c707]),'WhatsappQueueId':Number(_0x5d9bb3[_0x22d2('0x49')]['id'])});}}else{socket[_0x22d2('0x6f')]('userWhatsappQueue:remove',{'UserId':Number(_0x5d9bb3['query']['ids']),'WhatsappQueueId':Number(_0x5d9bb3[_0x22d2('0x49')]['id'])});}});}})[_0x22d2('0x27')](respondWithStatusCode(_0x42bdcf,null))['catch'](handleError(_0x42bdcf,null));};exports[_0x22d2('0x88')]=function(_0x158b34,_0x32eea6,_0x5ed392){var _0x45f451={};var _0x4bb373={};var _0x40e905;var _0x1a1939;return db[_0x22d2('0x30')]['findOne']({'where':{'id':_0x158b34[_0x22d2('0x49')]['id']}})['then'](handleEntityNotFound(_0x32eea6,null))[_0x22d2('0x27')](function(_0x38af2b){if(_0x38af2b){_0x40e905=_0x38af2b;_0x4bb373[_0x22d2('0x33')]=_[_0x22d2('0x35')](db['User'][_0x22d2('0x4a')]);_0x4bb373['query']=_[_0x22d2('0x35')](_0x158b34[_0x22d2('0x34')]);_0x4bb373[_0x22d2('0x36')]=_[_0x22d2('0x37')](_0x4bb373[_0x22d2('0x33')],_0x4bb373[_0x22d2('0x34')]);_0x45f451[_0x22d2('0x38')]=_[_0x22d2('0x37')](_0x4bb373[_0x22d2('0x33')],qs[_0x22d2('0x39')](_0x158b34[_0x22d2('0x34')][_0x22d2('0x39')]));_0x45f451['attributes']=_0x45f451['attributes'][_0x22d2('0x3a')]?_0x45f451[_0x22d2('0x38')]:_0x4bb373[_0x22d2('0x33')];_0x45f451[_0x22d2('0x57')]=qs['sort'](_0x158b34['query'][_0x22d2('0x3d')]);_0x45f451['where']=qs[_0x22d2('0x36')](_[_0x22d2('0x3f')](_0x158b34[_0x22d2('0x34')],_0x4bb373[_0x22d2('0x36')]));if(_0x158b34[_0x22d2('0x34')][_0x22d2('0x40')]){_0x45f451[_0x22d2('0x3e')]=_[_0x22d2('0x42')](_0x45f451[_0x22d2('0x3e')],{'$or':_[_0x22d2('0x2f')](_0x45f451[_0x22d2('0x38')],function(_0x2ada47){var _0x5126db={};_0x5126db[_0x2ada47]={'$like':'%'+_0x158b34[_0x22d2('0x34')][_0x22d2('0x40')]+'%'};return _0x5126db;})});}_0x45f451=_[_0x22d2('0x42')]({},_0x45f451,_0x158b34[_0x22d2('0x43')]);return _0x40e905[_0x22d2('0x88')](_0x45f451);}})['then'](function(_0x14408d){if(_0x14408d){_0x1a1939=_0x14408d[_0x22d2('0x3a')];if(!_0x158b34[_0x22d2('0x34')][_0x22d2('0x60')](_0x22d2('0x3b'))){_0x45f451[_0x22d2('0x3c')]=qs[_0x22d2('0x3c')](_0x158b34[_0x22d2('0x34')][_0x22d2('0x3c')]);_0x45f451[_0x22d2('0x20')]=qs[_0x22d2('0x20')](_0x158b34['query'][_0x22d2('0x20')]);}return _0x40e905[_0x22d2('0x88')](_0x45f451);}})[_0x22d2('0x27')](function(_0x56307e){if(_0x56307e){return _0x56307e?{'count':_0x1a1939,'rows':_0x56307e}:null;}})[_0x22d2('0x27')](respondWithResult(_0x32eea6,null))[_0x22d2('0x47')](handleError(_0x32eea6,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