Built motion from commit 97153652.|2.6.26
[motion2.git] / server / api / whatsappQueue / whatsappQueue.controller.js
index 64723ed..2cc0b6d 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xcc7d=['autoAssociation','catch','update','body','describe','UserWhatsappQueue','length','nolimit','pick','WhatsappQueueId','User','UserId','agent','whatsappPause','updatedAt','createdAt','format','%s/%s','SIP','getTeams','findOne','Team','addTeams','ids','online','voicePause','Agents','sequelize','each','findOrCreate','forEach','emit','select','tq.TeamId','from','join','ut.TeamId\x20=\x20tq.TeamId','clone','toString','QueryTypes','SELECT','every','all','union','transaction','removeTeams','userWhatsappQueue:remove','addAgents','omit','spread','userWhatsappQueue:save','removeAgents','isArray','getAgents','html-pdf','eml-format','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','to-csv','ejs','lodash','squel','jsforce','desk.js','querystring','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/environment','../../config/license/util','../../mysqldb','defaults','redis','localhost','./whatsappQueue.socket','register','sendStatus','end','status','count','offset','limit','set','Content-Range','json','apply','reject','save','then','get','destroy','error','stack','send','index','map','WhatsappQueue','rawAttributes','type','key','model','name','query','filters','intersection','fields','attributes','hasOwnProperty','order','sort','filter','where','merge','options','includeAll','include','findAll','rows','show','params','keys','find','create','role','user','WhatsappQueues','userProfileId'];(function(_0x2bd635,_0x3a8ae8){var _0x3008fa=function(_0x186b35){while(--_0x186b35){_0x2bd635['push'](_0x2bd635['shift']());}};_0x3008fa(++_0x3a8ae8);}(_0xcc7d,0x144));var _0xdcc7=function(_0x4fedcd,_0xd4c543){_0x4fedcd=_0x4fedcd-0x0;var _0x2f7374=_0xcc7d[_0x4fedcd];return _0x2f7374;};'use strict';var pdf=require(_0xdcc7('0x0'));var emlformat=require(_0xdcc7('0x1'));var rimraf=require('rimraf');var zipdir=require(_0xdcc7('0x2'));var jsonpatch=require(_0xdcc7('0x3'));var rp=require(_0xdcc7('0x4'));var moment=require(_0xdcc7('0x5'));var BPromise=require(_0xdcc7('0x6'));var Mustache=require(_0xdcc7('0x7'));var util=require(_0xdcc7('0x8'));var path=require('path');var sox=require('sox');var csv=require(_0xdcc7('0x9'));var ejs=require(_0xdcc7('0xa'));var fs=require('fs');var _=require(_0xdcc7('0xb'));var squel=require(_0xdcc7('0xc'));var crypto=require('crypto');var jsforce=require(_0xdcc7('0xd'));var deskjs=require(_0xdcc7('0xe'));var toCsv=require(_0xdcc7('0x9'));var querystring=require(_0xdcc7('0xf'));var Papa=require('papaparse');var Redis=require(_0xdcc7('0x10'));var authService=require('../../components/auth/service');var qs=require(_0xdcc7('0x11'));var as=require(_0xdcc7('0x12'));var hardwareService=require(_0xdcc7('0x13'));var logger=require(_0xdcc7('0x14'))(_0xdcc7('0x15'));var utils=require('../../config/utils');var config=require(_0xdcc7('0x16'));var licenseUtil=require(_0xdcc7('0x17'));var db=require(_0xdcc7('0x18'))['db'];config['redis']=_[_0xdcc7('0x19')](config[_0xdcc7('0x1a')],{'host':_0xdcc7('0x1b'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0xdcc7('0x1a')]));require(_0xdcc7('0x1c'))[_0xdcc7('0x1d')](socket);function respondWithStatusCode(_0x54ab5f,_0x3cde47){_0x3cde47=_0x3cde47||0xcc;return function(_0x50352a){if(_0x50352a){return _0x54ab5f[_0xdcc7('0x1e')](_0x3cde47);}return _0x54ab5f['status'](_0x3cde47)[_0xdcc7('0x1f')]();};}function respondWithResult(_0x5bc50c,_0x552d13){_0x552d13=_0x552d13||0xc8;return function(_0x47bfa4){if(_0x47bfa4){return _0x5bc50c[_0xdcc7('0x20')](_0x552d13)['json'](_0x47bfa4);}};}function respondWithFilteredResult(_0x13c2ac,_0x499d3c){return function(_0x1305ac){if(_0x1305ac){var _0x2a2aaf=_0x1305ac[_0xdcc7('0x21')],_0x25e665=_0x499d3c[_0xdcc7('0x22')],_0x1175da=_0x499d3c['offset']+_0x499d3c[_0xdcc7('0x23')],_0x292a51;if(_0x1175da>=_0x2a2aaf){_0x1175da=_0x2a2aaf;_0x292a51=0xc8;}else{_0x292a51=0xce;}_0x13c2ac[_0xdcc7('0x20')](_0x292a51);return _0x13c2ac[_0xdcc7('0x24')](_0xdcc7('0x25'),_0x25e665+'-'+_0x1175da+'/'+_0x2a2aaf)[_0xdcc7('0x26')](_0x1305ac);}return null;};}function patchUpdates(_0x23ced6){return function(_0x57a68e){try{jsonpatch[_0xdcc7('0x27')](_0x57a68e,_0x23ced6,!![]);}catch(_0x4bb5bd){return BPromise[_0xdcc7('0x28')](_0x4bb5bd);}return _0x57a68e[_0xdcc7('0x29')]();};}function saveUpdates(_0x678f14,_0x4d31df){return function(_0x1d45b2){if(_0x1d45b2){return _0x1d45b2['update'](_0x678f14)[_0xdcc7('0x2a')](function(_0x3c45d2){return _0x3c45d2;});}return null;};}function removeEntity(_0x32b7bb,_0x16fb51){return function(_0x4b6f61){if(_0x4b6f61){return _0x4b6f61['destroy']()[_0xdcc7('0x2a')](function(){var _0xa215a8=_0x4b6f61[_0xdcc7('0x2b')]({'plain':!![]});var _0xcfa15='WhatsappQueues';return db['UserProfileResource'][_0xdcc7('0x2c')]({'where':{'type':_0xcfa15,'resourceId':_0xa215a8['id']}})['then'](function(){return _0x4b6f61;});})['then'](function(){_0x32b7bb[_0xdcc7('0x20')](0xcc)[_0xdcc7('0x1f')]();});}};}function handleEntityNotFound(_0x36115b,_0x1762b8){return function(_0x4eb0c3){if(!_0x4eb0c3){_0x36115b[_0xdcc7('0x1e')](0x194);}return _0x4eb0c3;};}function handleError(_0x2d3f85,_0x4d4b93){_0x4d4b93=_0x4d4b93||0x1f4;return function(_0x1abee0){logger[_0xdcc7('0x2d')](_0x1abee0[_0xdcc7('0x2e')]);if(_0x1abee0['name']){delete _0x1abee0['name'];}_0x2d3f85['status'](_0x4d4b93)[_0xdcc7('0x2f')](_0x1abee0);};}exports[_0xdcc7('0x30')]=function(_0x425a22,_0x6fae07){var _0x4af4e9={},_0x177bfc={},_0x4c88af={'count':0x0,'rows':[]};var _0x8d002=_[_0xdcc7('0x31')](db[_0xdcc7('0x32')][_0xdcc7('0x33')],function(_0x1e9ce6){return{'name':_0x1e9ce6['fieldName'],'type':_0x1e9ce6[_0xdcc7('0x34')][_0xdcc7('0x35')]};});_0x177bfc[_0xdcc7('0x36')]=_[_0xdcc7('0x31')](_0x8d002,_0xdcc7('0x37'));_0x177bfc[_0xdcc7('0x38')]=_['keys'](_0x425a22[_0xdcc7('0x38')]);_0x177bfc[_0xdcc7('0x39')]=_[_0xdcc7('0x3a')](_0x177bfc[_0xdcc7('0x36')],_0x177bfc[_0xdcc7('0x38')]);_0x4af4e9['attributes']=_['intersection'](_0x177bfc[_0xdcc7('0x36')],qs[_0xdcc7('0x3b')](_0x425a22[_0xdcc7('0x38')]['fields']));_0x4af4e9[_0xdcc7('0x3c')]=_0x4af4e9[_0xdcc7('0x3c')]['length']?_0x4af4e9[_0xdcc7('0x3c')]:_0x177bfc['model'];if(!_0x425a22['query'][_0xdcc7('0x3d')]('nolimit')){_0x4af4e9['limit']=qs['limit'](_0x425a22[_0xdcc7('0x38')][_0xdcc7('0x23')]);_0x4af4e9['offset']=qs['offset'](_0x425a22[_0xdcc7('0x38')][_0xdcc7('0x22')]);}_0x4af4e9[_0xdcc7('0x3e')]=qs['sort'](_0x425a22['query'][_0xdcc7('0x3f')]);_0x4af4e9['where']=qs[_0xdcc7('0x39')](_['pick'](_0x425a22[_0xdcc7('0x38')],_0x177bfc['filters']),_0x8d002);if(_0x425a22['query'][_0xdcc7('0x40')]){_0x4af4e9[_0xdcc7('0x41')]=_[_0xdcc7('0x42')](_0x4af4e9[_0xdcc7('0x41')],{'$or':_[_0xdcc7('0x31')](_0x8d002,function(_0x432105){if(_0x432105[_0xdcc7('0x34')]!=='VIRTUAL'){var _0x2572c5={};_0x2572c5[_0x432105[_0xdcc7('0x37')]]={'$like':'%'+_0x425a22[_0xdcc7('0x38')]['filter']+'%'};return _0x2572c5;}})});}_0x4af4e9=_[_0xdcc7('0x42')]({},_0x4af4e9,_0x425a22[_0xdcc7('0x43')]);var _0x19c11b={'where':_0x4af4e9['where']};return db[_0xdcc7('0x32')][_0xdcc7('0x21')](_0x19c11b)[_0xdcc7('0x2a')](function(_0x1efb09){_0x4c88af['count']=_0x1efb09;if(_0x425a22[_0xdcc7('0x38')][_0xdcc7('0x44')]){_0x4af4e9[_0xdcc7('0x45')]=[{'all':!![]}];}return db[_0xdcc7('0x32')][_0xdcc7('0x46')](_0x4af4e9);})[_0xdcc7('0x2a')](function(_0x26af5b){_0x4c88af[_0xdcc7('0x47')]=_0x26af5b;return _0x4c88af;})['then'](respondWithFilteredResult(_0x6fae07,_0x4af4e9))['catch'](handleError(_0x6fae07,null));};exports[_0xdcc7('0x48')]=function(_0x57b3a7,_0x2de989){var _0x2bd5e8={'raw':!![],'where':{'id':_0x57b3a7[_0xdcc7('0x49')]['id']}},_0x49bd78={};_0x49bd78[_0xdcc7('0x36')]=_[_0xdcc7('0x4a')](db[_0xdcc7('0x32')][_0xdcc7('0x33')]);_0x49bd78['query']=_[_0xdcc7('0x4a')](_0x57b3a7['query']);_0x49bd78[_0xdcc7('0x39')]=_[_0xdcc7('0x3a')](_0x49bd78[_0xdcc7('0x36')],_0x49bd78[_0xdcc7('0x38')]);_0x2bd5e8['attributes']=_[_0xdcc7('0x3a')](_0x49bd78[_0xdcc7('0x36')],qs[_0xdcc7('0x3b')](_0x57b3a7['query'][_0xdcc7('0x3b')]));_0x2bd5e8[_0xdcc7('0x3c')]=_0x2bd5e8[_0xdcc7('0x3c')]['length']?_0x2bd5e8[_0xdcc7('0x3c')]:_0x49bd78[_0xdcc7('0x36')];if(_0x57b3a7['query'][_0xdcc7('0x44')]){_0x2bd5e8[_0xdcc7('0x45')]=[{'all':!![]}];}_0x2bd5e8=_[_0xdcc7('0x42')]({},_0x2bd5e8,_0x57b3a7[_0xdcc7('0x43')]);return db[_0xdcc7('0x32')][_0xdcc7('0x4b')](_0x2bd5e8)[_0xdcc7('0x2a')](handleEntityNotFound(_0x2de989,null))[_0xdcc7('0x2a')](respondWithResult(_0x2de989,null))['catch'](handleError(_0x2de989,null));};exports[_0xdcc7('0x4c')]=function(_0x32966e,_0x35e5da){return db[_0xdcc7('0x32')][_0xdcc7('0x4c')](_0x32966e['body'],{})['then'](function(_0x40fa1c){var _0x426565=_0x32966e['user'][_0xdcc7('0x2b')]({'plain':!![]});if(!_0x426565)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x426565[_0xdcc7('0x4d')]===_0xdcc7('0x4e')){var _0x44cff1=_0x40fa1c[_0xdcc7('0x2b')]({'plain':!![]});var _0x446552=_0xdcc7('0x4f');return db['UserProfileSection'][_0xdcc7('0x4b')]({'where':{'name':_0x446552,'userProfileId':_0x426565[_0xdcc7('0x50')]},'raw':!![]})[_0xdcc7('0x2a')](function(_0x33c86c){if(_0x33c86c&&_0x33c86c[_0xdcc7('0x51')]===0x0){return db['UserProfileResource']['create']({'name':_0x44cff1['name'],'resourceId':_0x44cff1['id'],'type':_0x33c86c[_0xdcc7('0x37')],'sectionId':_0x33c86c['id']},{})[_0xdcc7('0x2a')](function(){return _0x40fa1c;});}else{return _0x40fa1c;}})[_0xdcc7('0x52')](function(_0x47f519){logger[_0xdcc7('0x2d')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x47f519);throw _0x47f519;});}return _0x40fa1c;})[_0xdcc7('0x2a')](respondWithResult(_0x35e5da,0xc9))[_0xdcc7('0x52')](handleError(_0x35e5da,null));};exports[_0xdcc7('0x53')]=function(_0x1b1920,_0x55e7b2){if(_0x1b1920[_0xdcc7('0x54')]['id']){delete _0x1b1920['body']['id'];}return db['WhatsappQueue'][_0xdcc7('0x4b')]({'where':{'id':_0x1b1920[_0xdcc7('0x49')]['id']}})[_0xdcc7('0x2a')](handleEntityNotFound(_0x55e7b2,null))[_0xdcc7('0x2a')](saveUpdates(_0x1b1920[_0xdcc7('0x54')],null))[_0xdcc7('0x2a')](respondWithResult(_0x55e7b2,null))['catch'](handleError(_0x55e7b2,null));};exports['destroy']=function(_0x2c7807,_0x2312e7){return db[_0xdcc7('0x32')][_0xdcc7('0x4b')]({'where':{'id':_0x2c7807['params']['id']}})[_0xdcc7('0x2a')](handleEntityNotFound(_0x2312e7,null))[_0xdcc7('0x2a')](removeEntity(_0x2312e7,null))[_0xdcc7('0x52')](handleError(_0x2312e7,null));};exports[_0xdcc7('0x55')]=function(_0x5d3235,_0x2b92aa){return db['WhatsappQueue'][_0xdcc7('0x55')]()[_0xdcc7('0x2a')](respondWithResult(_0x2b92aa,null))[_0xdcc7('0x52')](handleError(_0x2b92aa,null));};exports['getMembers']=function(_0x1c335c,_0x1e5539,_0x587d11){var _0x54dfa6={'raw':!![],'where':{}},_0x3ca494={},_0x5ea5f5;return db[_0xdcc7('0x32')]['findOne']({'where':{'id':_0x1c335c['params']['id']}})['then'](handleEntityNotFound(_0x1e5539,null))[_0xdcc7('0x2a')](function(_0x5147aa){if(_0x5147aa){_0x5ea5f5=_0x5147aa[_0xdcc7('0x2b')]({'plain':!![]});_0x3ca494[_0xdcc7('0x36')]=_[_0xdcc7('0x4a')](db[_0xdcc7('0x56')][_0xdcc7('0x33')]);_0x3ca494['query']=_[_0xdcc7('0x4a')](_0x1c335c[_0xdcc7('0x38')]);_0x3ca494[_0xdcc7('0x39')]=_[_0xdcc7('0x3a')](_0x3ca494[_0xdcc7('0x36')],_0x3ca494['query']);_0x54dfa6[_0xdcc7('0x3c')]=_[_0xdcc7('0x3a')](_0x3ca494[_0xdcc7('0x36')],qs['fields'](_0x1c335c[_0xdcc7('0x38')]['fields']));_0x54dfa6[_0xdcc7('0x3c')]=_0x54dfa6[_0xdcc7('0x3c')][_0xdcc7('0x57')]?_0x54dfa6[_0xdcc7('0x3c')]:_0x3ca494['model'];if(!_0x1c335c['query'][_0xdcc7('0x3d')](_0xdcc7('0x58'))){_0x54dfa6[_0xdcc7('0x23')]=qs[_0xdcc7('0x23')](_0x1c335c['query'][_0xdcc7('0x23')]);_0x54dfa6[_0xdcc7('0x22')]=qs[_0xdcc7('0x22')](_0x1c335c[_0xdcc7('0x38')][_0xdcc7('0x22')]);}_0x54dfa6[_0xdcc7('0x3e')]=qs['sort'](_0x1c335c['query']['sort']);_0x54dfa6[_0xdcc7('0x41')]=qs['filters'](_[_0xdcc7('0x59')](_0x1c335c[_0xdcc7('0x38')],_0x3ca494[_0xdcc7('0x39')]));_0x54dfa6[_0xdcc7('0x41')][_0xdcc7('0x5a')]=_0x5147aa['id'];if(_0x1c335c[_0xdcc7('0x38')][_0xdcc7('0x40')]){_0x54dfa6['where']=_[_0xdcc7('0x42')](_0x54dfa6[_0xdcc7('0x41')],{'$or':_['map'](_0x54dfa6[_0xdcc7('0x3c')],function(_0xf8f88){var _0x47e9dc={};_0x47e9dc[_0xf8f88]={'$like':'%'+_0x1c335c[_0xdcc7('0x38')][_0xdcc7('0x40')]+'%'};return _0x47e9dc;})});}_0x54dfa6=_[_0xdcc7('0x42')]({},_0x54dfa6,_0x1c335c[_0xdcc7('0x43')]);return db[_0xdcc7('0x56')][_0xdcc7('0x46')](_0x54dfa6);}})['then'](function(_0x5a3653){if(_0x5a3653){return db[_0xdcc7('0x5b')]['findAndCountAll']({'where':{'id':_['map'](_0x5a3653,_0xdcc7('0x5c')),'role':_0xdcc7('0x5d')},'attributes':['id','name',_0xdcc7('0x5e'),_0xdcc7('0x5f'),_0xdcc7('0x60')]});}})[_0xdcc7('0x2a')](function(_0xa2d1c){if(_0xa2d1c){return{'count':_0xa2d1c['count'],'rows':_[_0xdcc7('0x31')](_0xa2d1c[_0xdcc7('0x47')],function(_0x16d088){return{'membername':_0x16d088[_0xdcc7('0x37')],'UserId':_0x16d088['id'],'queue_name':_0x5ea5f5[_0xdcc7('0x37')],'WhatsappQueueId':_0x5ea5f5['id'],'interface':util[_0xdcc7('0x61')](_0xdcc7('0x62'),_0xdcc7('0x63'),_0x16d088[_0xdcc7('0x37')]),'penalty':0x0,'paused':_0x16d088['whatsappPause'],'createdAt':_0x16d088[_0xdcc7('0x60')],'updatedAt':_0x16d088['updatedAt']};})};}else{return{'count':0x0,'rows':[]};}})['then'](respondWithFilteredResult(_0x1e5539,_0x54dfa6))[_0xdcc7('0x52')](handleError(_0x1e5539,null));};exports[_0xdcc7('0x64')]=function(_0x23f546,_0x2c5a63,_0x1b16bf){var _0x558fc2={};var _0x169308={};var _0x13c167;var _0x5af9c0;return db[_0xdcc7('0x32')][_0xdcc7('0x65')]({'where':{'id':_0x23f546[_0xdcc7('0x49')]['id']}})[_0xdcc7('0x2a')](handleEntityNotFound(_0x2c5a63,null))['then'](function(_0x199675){if(_0x199675){_0x13c167=_0x199675;_0x169308[_0xdcc7('0x36')]=_['keys'](db[_0xdcc7('0x66')][_0xdcc7('0x33')]);_0x169308['query']=_[_0xdcc7('0x4a')](_0x23f546['query']);_0x169308[_0xdcc7('0x39')]=_[_0xdcc7('0x3a')](_0x169308[_0xdcc7('0x36')],_0x169308[_0xdcc7('0x38')]);_0x558fc2['attributes']=_['intersection'](_0x169308['model'],qs[_0xdcc7('0x3b')](_0x23f546[_0xdcc7('0x38')]['fields']));_0x558fc2[_0xdcc7('0x3c')]=_0x558fc2[_0xdcc7('0x3c')][_0xdcc7('0x57')]?_0x558fc2[_0xdcc7('0x3c')]:_0x169308[_0xdcc7('0x36')];_0x558fc2[_0xdcc7('0x3e')]=qs[_0xdcc7('0x3f')](_0x23f546['query'][_0xdcc7('0x3f')]);_0x558fc2[_0xdcc7('0x41')]=qs['filters'](_[_0xdcc7('0x59')](_0x23f546[_0xdcc7('0x38')],_0x169308[_0xdcc7('0x39')]));if(_0x23f546[_0xdcc7('0x38')][_0xdcc7('0x40')]){_0x558fc2[_0xdcc7('0x41')]=_[_0xdcc7('0x42')](_0x558fc2['where'],{'$or':_['map'](_0x558fc2['attributes'],function(_0x3ce68e){var _0x1fe6c8={};_0x1fe6c8[_0x3ce68e]={'$like':'%'+_0x23f546[_0xdcc7('0x38')][_0xdcc7('0x40')]+'%'};return _0x1fe6c8;})});}_0x558fc2=_[_0xdcc7('0x42')]({},_0x558fc2,_0x23f546[_0xdcc7('0x43')]);return _0x13c167[_0xdcc7('0x64')](_0x558fc2);}})[_0xdcc7('0x2a')](function(_0xe593d3){if(_0xe593d3){_0x5af9c0=_0xe593d3['length'];if(!_0x23f546[_0xdcc7('0x38')]['hasOwnProperty'](_0xdcc7('0x58'))){_0x558fc2[_0xdcc7('0x23')]=qs[_0xdcc7('0x23')](_0x23f546['query'][_0xdcc7('0x23')]);_0x558fc2['offset']=qs[_0xdcc7('0x22')](_0x23f546['query'][_0xdcc7('0x22')]);}return _0x13c167['getTeams'](_0x558fc2);}})[_0xdcc7('0x2a')](function(_0x41c665){if(_0x41c665){return _0x41c665?{'count':_0x5af9c0,'rows':_0x41c665}:null;}})['then'](respondWithResult(_0x2c5a63,null))['catch'](handleError(_0x2c5a63,null));};exports[_0xdcc7('0x67')]=function(_0xa25292,_0x596113,_0xd984c5){var _0x95305c=_0xa25292[_0xdcc7('0x54')][_0xdcc7('0x68')];return db[_0xdcc7('0x66')][_0xdcc7('0x46')]({'where':{'id':_0x95305c},'attributes':['id'],'include':[{'model':db[_0xdcc7('0x5b')],'as':'Agents','attributes':['id',_0xdcc7('0x37'),_0xdcc7('0x69'),_0xdcc7('0x6a'),'interface'],'raw':!![]}]})[_0xdcc7('0x2a')](function(_0x21bcb5){if(_0x21bcb5){var _0x3219a5=_['flatMap'](_0x21bcb5,function(_0x244ac6){var _0x1bd43e=_0x244ac6[_0xdcc7('0x2b')]({'plain':!![]});return _0x1bd43e[_0xdcc7('0x6b')];});return db[_0xdcc7('0x32')]['find']({'where':{'id':_0xa25292[_0xdcc7('0x49')]['id']}})[_0xdcc7('0x2a')](function(_0x477ae4){return db[_0xdcc7('0x6c')]['transaction'](function(_0x4ba161){return _0x477ae4[_0xdcc7('0x67')](_0x95305c,{'transaction':_0x4ba161})[_0xdcc7('0x2a')](function(){return BPromise[_0xdcc7('0x6d')](_0x3219a5,function(_0x36686a){return db[_0xdcc7('0x56')][_0xdcc7('0x6e')]({'where':{'UserId':_0x36686a['id'],'WhatsappQueueId':_0xa25292['params']['id']},'transaction':_0x4ba161});});})[_0xdcc7('0x2a')](function(){_0x3219a5[_0xdcc7('0x6f')](function(_0x197bf1){socket[_0xdcc7('0x70')]('userWhatsappQueue:save',{'UserId':_0x197bf1['id'],'WhatsappQueueId':_0x477ae4['id']});});});});});}})['then'](respondWithStatusCode(_0x596113,null))['catch'](handleError(_0x596113,null));};exports['removeTeams']=function(_0x5da601,_0x285139,_0x4fbff7){return db[_0xdcc7('0x66')][_0xdcc7('0x46')]({'where':{'id':_0x5da601['query'][_0xdcc7('0x68')]},'attributes':['id'],'include':[{'model':db[_0xdcc7('0x5b')],'as':'Agents','attributes':['id'],'raw':!![]}]})[_0xdcc7('0x2a')](handleEntityNotFound(_0x285139,null))[_0xdcc7('0x2a')](function(_0x35092d){var _0xbb4173=_[_0xdcc7('0x31')](_0x35092d,'id');var _0x5c3d83=[];var _0x363f50=[];var _0x4372d0=squel[_0xdcc7('0x71')]();_0x4372d0['field'](_0xdcc7('0x72'))[_0xdcc7('0x73')]('team_has_whatsapp_queues','tq')[_0xdcc7('0x74')]('user_has_teams','ut',_0xdcc7('0x75'))[_0xdcc7('0x41')]('WhatsappQueueId\x20=\x20?',_0x5da601[_0xdcc7('0x49')]['id']);for(var _0x2cbb05=0x0;_0x2cbb05<_0x35092d['length'];_0x2cbb05+=0x1){let _0x10b388=_0x35092d[_0x2cbb05];for(var _0x1c69ef=0x0;_0x1c69ef<_0x10b388['Agents'][_0xdcc7('0x57')];_0x1c69ef+=0x1){let _0x1916ef=_0x10b388[_0xdcc7('0x6b')][_0x1c69ef];var _0x1f61a7=_0x4372d0[_0xdcc7('0x76')]();_0x1f61a7[_0xdcc7('0x41')]('ut.UserId\x20=\x20?',_0x1916ef['id']);_0x363f50['push'](db[_0xdcc7('0x6c')][_0xdcc7('0x38')](_0x1f61a7[_0xdcc7('0x77')](),{'type':db[_0xdcc7('0x6c')][_0xdcc7('0x78')][_0xdcc7('0x79')]})[_0xdcc7('0x2a')](function(_0x45dde8){if(_0x45dde8['length']===0x1){return _0x1916ef['id'];}else{var _0x21525d=_[_0xdcc7('0x7a')](_[_0xdcc7('0x31')](_0x45dde8,'TeamId'),function(_0x48e282){return _['includes'](_0xbb4173,_0x48e282);});if(_0x21525d){return _0x1916ef['id'];}}}));}}return BPromise[_0xdcc7('0x7b')](_0x363f50)['then'](function(_0x538719){_0x5c3d83=_(_0x5c3d83)[_0xdcc7('0x7c')](_0x538719)['compact']()['value']();return db[_0xdcc7('0x32')]['find']({'where':{'id':_0x5da601[_0xdcc7('0x49')]['id']}})['then'](function(_0x3f90ce){return db[_0xdcc7('0x6c')][_0xdcc7('0x7d')](function(_0x2b24e0){return _0x3f90ce[_0xdcc7('0x7e')](_0x5da601['query'][_0xdcc7('0x68')],{'transaction':_0x2b24e0})[_0xdcc7('0x2a')](function(){if(!_['isEmpty'](_0x5c3d83)){return _0x3f90ce['removeAgents'](_0x5c3d83,{'transaction':_0x2b24e0});}})[_0xdcc7('0x2a')](function(){_0x5c3d83[_0xdcc7('0x6f')](function(_0x3dbcab){socket[_0xdcc7('0x70')](_0xdcc7('0x7f'),{'UserId':_0x3dbcab,'WhatsappQueueId':_0x3f90ce['id']});});});});});});})['then'](respondWithStatusCode(_0x285139,null))[_0xdcc7('0x52')](handleError(_0x285139,null));};exports[_0xdcc7('0x80')]=function(_0x183abc,_0x4c5a3c,_0x1d34a4){return db['WhatsappQueue']['find']({'where':{'id':_0x183abc[_0xdcc7('0x49')]['id']}})[_0xdcc7('0x2a')](handleEntityNotFound(_0x4c5a3c,null))[_0xdcc7('0x2a')](function(_0x5ea76e){if(_0x5ea76e){return _0x5ea76e[_0xdcc7('0x80')](_0x183abc['body'][_0xdcc7('0x68')],_[_0xdcc7('0x81')](_0x183abc[_0xdcc7('0x54')],[_0xdcc7('0x68'),'id'])||{})[_0xdcc7('0x82')](function(_0x401c35){for(var _0x10b4b3=0x0;_0x10b4b3<_0x183abc['body'][_0xdcc7('0x68')][_0xdcc7('0x57')];_0x10b4b3+=0x1){socket['emit'](_0xdcc7('0x83'),{'UserId':_0x183abc[_0xdcc7('0x54')][_0xdcc7('0x68')][_0x10b4b3],'WhatsappQueueId':_0x183abc['params']['id']});}return _0x401c35;});}})['then'](respondWithResult(_0x4c5a3c,null))[_0xdcc7('0x52')](handleError(_0x4c5a3c,null));};exports[_0xdcc7('0x84')]=function(_0x2b2a98,_0xe4df6a,_0x1d86f5){return db[_0xdcc7('0x32')]['find']({'where':{'id':_0x2b2a98[_0xdcc7('0x49')]['id']}})[_0xdcc7('0x2a')](handleEntityNotFound(_0xe4df6a,null))[_0xdcc7('0x2a')](function(_0x46735a){if(_0x46735a){return _0x46735a[_0xdcc7('0x84')](_0x2b2a98['query'][_0xdcc7('0x68')])[_0xdcc7('0x2a')](function(){if(_[_0xdcc7('0x85')](_0x2b2a98[_0xdcc7('0x38')][_0xdcc7('0x68')])){for(var _0x354b01=0x0;_0x354b01<_0x2b2a98[_0xdcc7('0x38')][_0xdcc7('0x68')][_0xdcc7('0x57')];_0x354b01+=0x1){socket['emit'](_0xdcc7('0x7f'),{'UserId':Number(_0x2b2a98[_0xdcc7('0x38')][_0xdcc7('0x68')][_0x354b01]),'WhatsappQueueId':Number(_0x2b2a98[_0xdcc7('0x49')]['id'])});}}else{socket[_0xdcc7('0x70')]('userWhatsappQueue:remove',{'UserId':Number(_0x2b2a98[_0xdcc7('0x38')]['ids']),'WhatsappQueueId':Number(_0x2b2a98[_0xdcc7('0x49')]['id'])});}});}})[_0xdcc7('0x2a')](respondWithStatusCode(_0xe4df6a,null))[_0xdcc7('0x52')](handleError(_0xe4df6a,null));};exports[_0xdcc7('0x86')]=function(_0x49bc65,_0xa0718b,_0x5eb309){var _0x4d952a={};var _0x356f71={};var _0x4912aa;var _0x29c290;return db[_0xdcc7('0x32')][_0xdcc7('0x65')]({'where':{'id':_0x49bc65[_0xdcc7('0x49')]['id']}})[_0xdcc7('0x2a')](handleEntityNotFound(_0xa0718b,null))[_0xdcc7('0x2a')](function(_0x439d72){if(_0x439d72){_0x4912aa=_0x439d72;_0x356f71[_0xdcc7('0x36')]=_[_0xdcc7('0x4a')](db[_0xdcc7('0x5b')][_0xdcc7('0x33')]);_0x356f71[_0xdcc7('0x38')]=_['keys'](_0x49bc65[_0xdcc7('0x38')]);_0x356f71['filters']=_[_0xdcc7('0x3a')](_0x356f71[_0xdcc7('0x36')],_0x356f71['query']);_0x4d952a[_0xdcc7('0x3c')]=_['intersection'](_0x356f71['model'],qs['fields'](_0x49bc65[_0xdcc7('0x38')][_0xdcc7('0x3b')]));_0x4d952a[_0xdcc7('0x3c')]=_0x4d952a[_0xdcc7('0x3c')]['length']?_0x4d952a[_0xdcc7('0x3c')]:_0x356f71[_0xdcc7('0x36')];_0x4d952a['order']=qs['sort'](_0x49bc65[_0xdcc7('0x38')][_0xdcc7('0x3f')]);_0x4d952a[_0xdcc7('0x41')]=qs[_0xdcc7('0x39')](_[_0xdcc7('0x59')](_0x49bc65[_0xdcc7('0x38')],_0x356f71['filters']));if(_0x49bc65[_0xdcc7('0x38')][_0xdcc7('0x40')]){_0x4d952a[_0xdcc7('0x41')]=_[_0xdcc7('0x42')](_0x4d952a[_0xdcc7('0x41')],{'$or':_[_0xdcc7('0x31')](_0x4d952a[_0xdcc7('0x3c')],function(_0x348e1b){var _0xbf9203={};_0xbf9203[_0x348e1b]={'$like':'%'+_0x49bc65['query'][_0xdcc7('0x40')]+'%'};return _0xbf9203;})});}_0x4d952a=_[_0xdcc7('0x42')]({},_0x4d952a,_0x49bc65[_0xdcc7('0x43')]);return _0x4912aa['getAgents'](_0x4d952a);}})[_0xdcc7('0x2a')](function(_0x570e36){if(_0x570e36){_0x29c290=_0x570e36[_0xdcc7('0x57')];if(!_0x49bc65[_0xdcc7('0x38')][_0xdcc7('0x3d')](_0xdcc7('0x58'))){_0x4d952a[_0xdcc7('0x23')]=qs[_0xdcc7('0x23')](_0x49bc65[_0xdcc7('0x38')]['limit']);_0x4d952a[_0xdcc7('0x22')]=qs['offset'](_0x49bc65[_0xdcc7('0x38')][_0xdcc7('0x22')]);}return _0x4912aa[_0xdcc7('0x86')](_0x4d952a);}})[_0xdcc7('0x2a')](function(_0x3a5c0f){if(_0x3a5c0f){return _0x3a5c0f?{'count':_0x29c290,'rows':_0x3a5c0f}:null;}})['then'](respondWithResult(_0xa0718b,null))[_0xdcc7('0x52')](handleError(_0xa0718b,null));};
\ No newline at end of file
+var _0xd410=['spread','isArray','getAgents','util','squel','ioredis','../../components/parsers/qs','api','../../mysqldb','defaults','redis','./whatsappQueue.socket','sendStatus','status','json','offset','undefined','limit','count','set','Content-Range','then','get','WhatsappQueues','destroy','error','map','rawAttributes','fieldName','type','key','getOptions','where','include','query','WhatsappQueue','rows','catch','show','model','keys','intersection','attributes','fields','includeAll','merge','options','create','body','Unable\x20to\x20retrieve\x20the\x20current\x20user','UserProfileSection','find','userProfileId','autoAssociation','UserProfileResource','name','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','update','params','describe','getMembers','findOne','UserWhatsappQueue','length','hasOwnProperty','nolimit','order','sort','filters','pick','WhatsappQueueId','filter','findAll','User','findAndCountAll','UserId','agent','whatsappPause','updatedAt','createdAt','%s/%s','SIP','getTeams','Team','addTeams','ids','online','voicePause','interface','transaction','forEach','emit','userWhatsappQueue:save','Agents','select','field','join','user_has_teams','ut.TeamId\x20=\x20tq.TeamId','WhatsappQueueId\x20=\x20?','clone','ut.UserId\x20=\x20?','push','toString','sequelize','TeamId','includes','all','value','removeTeams','isEmpty','removeAgents','userWhatsappQueue:remove','addAgents','omit'];(function(_0x41c124,_0x938abf){var _0x1b8248=function(_0x5c8aef){while(--_0x5c8aef){_0x41c124['push'](_0x41c124['shift']());}};_0x1b8248(++_0x938abf);}(_0xd410,0x1cf));var _0x0d41=function(_0x2bf141,_0x31eac7){_0x2bf141=_0x2bf141-0x0;var _0x48277b=_0xd410[_0x2bf141];return _0x48277b;};'use strict';var BPromise=require('bluebird');var util=require(_0x0d41('0x0'));var _=require('lodash');var squel=require(_0x0d41('0x1'));var Redis=require(_0x0d41('0x2'));var qs=require(_0x0d41('0x3'));var logger=require('../../config/logger')(_0x0d41('0x4'));var config=require('../../config/environment');var db=require(_0x0d41('0x5'))['db'];config['redis']=_[_0x0d41('0x6')](config['redis'],{'host':'localhost','port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x0d41('0x7')]));require(_0x0d41('0x8'))['register'](socket);function respondWithStatusCode(_0x2cde70,_0x45e2c2){_0x45e2c2=_0x45e2c2||0xcc;return function(_0x2645bb){if(_0x2645bb){return _0x2cde70[_0x0d41('0x9')](_0x45e2c2);}return _0x2cde70[_0x0d41('0xa')](_0x45e2c2)['end']();};}function respondWithResult(_0x1f3edf,_0x1d781e){_0x1d781e=_0x1d781e||0xc8;return function(_0x2b08f8){if(_0x2b08f8){return _0x1f3edf['status'](_0x1d781e)[_0x0d41('0xb')](_0x2b08f8);}};}function respondWithFilteredResult(_0x2ac236,_0x5f14c2){return function(_0x4e6bac){if(_0x4e6bac){var _0x4e4f7e=typeof _0x5f14c2[_0x0d41('0xc')]===_0x0d41('0xd')&&typeof _0x5f14c2[_0x0d41('0xe')]===_0x0d41('0xd');var _0xe7d9b8=_0x4e6bac[_0x0d41('0xf')];var _0x189da1=_0x4e4f7e?0x0:_0x5f14c2[_0x0d41('0xc')];var _0x15bf2f=_0x4e4f7e?_0x4e6bac[_0x0d41('0xf')]:_0x5f14c2[_0x0d41('0xc')]+_0x5f14c2[_0x0d41('0xe')];var _0x18e35e;if(_0x15bf2f>=_0xe7d9b8){_0x15bf2f=_0xe7d9b8;_0x18e35e=0xc8;}else{_0x18e35e=0xce;}_0x2ac236[_0x0d41('0xa')](_0x18e35e);return _0x2ac236[_0x0d41('0x10')](_0x0d41('0x11'),_0x189da1+'-'+_0x15bf2f+'/'+_0xe7d9b8)[_0x0d41('0xb')](_0x4e6bac);}return null;};}function saveUpdates(_0x31c25c){return function(_0xd659ad){if(_0xd659ad){return _0xd659ad['update'](_0x31c25c)[_0x0d41('0x12')](function(_0x5c2fcb){return _0x5c2fcb;});}return null;};}function removeEntity(_0xb8c900){return function(_0x207410){if(_0x207410){return _0x207410['destroy']()[_0x0d41('0x12')](function(){var _0x1e1c70=_0x207410[_0x0d41('0x13')]({'plain':!![]});var _0x2c550f=_0x0d41('0x14');return db['UserProfileResource'][_0x0d41('0x15')]({'where':{'type':_0x2c550f,'resourceId':_0x1e1c70['id']}})[_0x0d41('0x12')](function(){return _0x207410;});})[_0x0d41('0x12')](function(){_0xb8c900[_0x0d41('0xa')](0xcc)['end']();});}};}function handleEntityNotFound(_0x58f332){return function(_0x13efef){if(!_0x13efef){_0x58f332[_0x0d41('0x9')](0x194);}return _0x13efef;};}function handleError(_0x22ba30,_0x516262){_0x516262=_0x516262||0x1f4;return function(_0x1bcfe1){logger[_0x0d41('0x16')](_0x1bcfe1['stack']);if(_0x1bcfe1['name']){delete _0x1bcfe1['name'];}_0x22ba30[_0x0d41('0xa')](_0x516262)['send'](_0x1bcfe1);};}exports['index']=function(_0x1cac7f,_0x39475f){var _0x49e960={};var _0x13147e={'count':0x0,'rows':[]};var _0x3a216c=_[_0x0d41('0x17')](db['WhatsappQueue'][_0x0d41('0x18')],function(_0x238cc1){return{'name':_0x238cc1[_0x0d41('0x19')],'type':_0x238cc1[_0x0d41('0x1a')][_0x0d41('0x1b')]};});_0x49e960=qs[_0x0d41('0x1c')](_0x3a216c,_0x1cac7f);var _0x5af429={'where':_0x49e960[_0x0d41('0x1d')]};return db['WhatsappQueue'][_0x0d41('0xf')](_0x5af429)[_0x0d41('0x12')](function(_0x267f48){_0x13147e[_0x0d41('0xf')]=_0x267f48;_0x49e960[_0x0d41('0x1e')]=qs[_0x0d41('0x1e')](_0x1cac7f[_0x0d41('0x1f')]);return db[_0x0d41('0x20')]['findAll'](_0x49e960);})[_0x0d41('0x12')](function(_0x541469){_0x13147e[_0x0d41('0x21')]=_0x541469;return _0x13147e;})[_0x0d41('0x12')](respondWithFilteredResult(_0x39475f,_0x49e960))[_0x0d41('0x22')](handleError(_0x39475f,null));};exports[_0x0d41('0x23')]=function(_0x1d816c,_0x3dd8fb){var _0x42682b={'raw':!![],'where':{'id':_0x1d816c['params']['id']}},_0x399327={};_0x399327[_0x0d41('0x24')]=_[_0x0d41('0x25')](db[_0x0d41('0x20')][_0x0d41('0x18')]);_0x399327[_0x0d41('0x1f')]=_['keys'](_0x1d816c[_0x0d41('0x1f')]);_0x399327['filters']=_[_0x0d41('0x26')](_0x399327['model'],_0x399327[_0x0d41('0x1f')]);_0x42682b[_0x0d41('0x27')]=_[_0x0d41('0x26')](_0x399327[_0x0d41('0x24')],qs[_0x0d41('0x28')](_0x1d816c[_0x0d41('0x1f')][_0x0d41('0x28')]));_0x42682b[_0x0d41('0x27')]=_0x42682b[_0x0d41('0x27')]['length']?_0x42682b[_0x0d41('0x27')]:_0x399327[_0x0d41('0x24')];if(_0x1d816c[_0x0d41('0x1f')][_0x0d41('0x29')]){_0x42682b[_0x0d41('0x1e')]=[{'all':!![]}];}_0x42682b=_[_0x0d41('0x2a')]({},_0x42682b,_0x1d816c[_0x0d41('0x2b')]);return db[_0x0d41('0x20')]['find'](_0x42682b)[_0x0d41('0x12')](handleEntityNotFound(_0x3dd8fb,null))['then'](respondWithResult(_0x3dd8fb,null))['catch'](handleError(_0x3dd8fb,null));};exports[_0x0d41('0x2c')]=function(_0x4d70ec,_0x52ea66){return db[_0x0d41('0x20')]['create'](_0x4d70ec[_0x0d41('0x2d')],{})[_0x0d41('0x12')](function(_0x205cda){var _0x20cd3b=_0x4d70ec['user'][_0x0d41('0x13')]({'plain':!![]});if(!_0x20cd3b)throw new Error(_0x0d41('0x2e'));if(_0x20cd3b['role']==='user'){var _0x58fdfa=_0x205cda[_0x0d41('0x13')]({'plain':!![]});var _0xefac87=_0x0d41('0x14');return db[_0x0d41('0x2f')][_0x0d41('0x30')]({'where':{'name':_0xefac87,'userProfileId':_0x20cd3b[_0x0d41('0x31')]},'raw':!![]})['then'](function(_0x55146b){if(_0x55146b&&_0x55146b[_0x0d41('0x32')]===0x0){return db[_0x0d41('0x33')][_0x0d41('0x2c')]({'name':_0x58fdfa[_0x0d41('0x34')],'resourceId':_0x58fdfa['id'],'type':_0x55146b[_0x0d41('0x34')],'sectionId':_0x55146b['id']},{})[_0x0d41('0x12')](function(){return _0x205cda;});}else{return _0x205cda;}})['catch'](function(_0xd8e727){logger[_0x0d41('0x16')](_0x0d41('0x35'),_0xd8e727);throw _0xd8e727;});}return _0x205cda;})['then'](respondWithResult(_0x52ea66,0xc9))[_0x0d41('0x22')](handleError(_0x52ea66,null));};exports[_0x0d41('0x36')]=function(_0x501afc,_0x3ca358){if(_0x501afc[_0x0d41('0x2d')]['id']){delete _0x501afc['body']['id'];}return db[_0x0d41('0x20')]['find']({'where':{'id':_0x501afc['params']['id']}})[_0x0d41('0x12')](handleEntityNotFound(_0x3ca358,null))['then'](saveUpdates(_0x501afc[_0x0d41('0x2d')],null))['then'](respondWithResult(_0x3ca358,null))[_0x0d41('0x22')](handleError(_0x3ca358,null));};exports['destroy']=function(_0x36bc7d,_0x4b1371){return db[_0x0d41('0x20')][_0x0d41('0x30')]({'where':{'id':_0x36bc7d[_0x0d41('0x37')]['id']}})[_0x0d41('0x12')](handleEntityNotFound(_0x4b1371,null))[_0x0d41('0x12')](removeEntity(_0x4b1371,null))[_0x0d41('0x22')](handleError(_0x4b1371,null));};exports[_0x0d41('0x38')]=function(_0x5d80e0,_0x1efbd9){return db[_0x0d41('0x20')]['describe']()[_0x0d41('0x12')](respondWithResult(_0x1efbd9,null))[_0x0d41('0x22')](handleError(_0x1efbd9,null));};exports[_0x0d41('0x39')]=function(_0x537635,_0x56eea7){var _0x49b73a={'raw':!![],'where':{}},_0x73486={},_0xdbd497;return db[_0x0d41('0x20')][_0x0d41('0x3a')]({'where':{'id':_0x537635[_0x0d41('0x37')]['id']}})[_0x0d41('0x12')](handleEntityNotFound(_0x56eea7,null))[_0x0d41('0x12')](function(_0x5de101){if(_0x5de101){_0xdbd497=_0x5de101['get']({'plain':!![]});_0x73486[_0x0d41('0x24')]=_['keys'](db[_0x0d41('0x3b')][_0x0d41('0x18')]);_0x73486[_0x0d41('0x1f')]=_[_0x0d41('0x25')](_0x537635[_0x0d41('0x1f')]);_0x73486['filters']=_[_0x0d41('0x26')](_0x73486[_0x0d41('0x24')],_0x73486[_0x0d41('0x1f')]);_0x49b73a[_0x0d41('0x27')]=_[_0x0d41('0x26')](_0x73486['model'],qs[_0x0d41('0x28')](_0x537635['query'][_0x0d41('0x28')]));_0x49b73a[_0x0d41('0x27')]=_0x49b73a['attributes'][_0x0d41('0x3c')]?_0x49b73a['attributes']:_0x73486[_0x0d41('0x24')];if(!_0x537635['query'][_0x0d41('0x3d')](_0x0d41('0x3e'))){_0x49b73a[_0x0d41('0xe')]=qs[_0x0d41('0xe')](_0x537635['query'][_0x0d41('0xe')]);_0x49b73a[_0x0d41('0xc')]=qs[_0x0d41('0xc')](_0x537635[_0x0d41('0x1f')][_0x0d41('0xc')]);}_0x49b73a[_0x0d41('0x3f')]=qs[_0x0d41('0x40')](_0x537635[_0x0d41('0x1f')][_0x0d41('0x40')]);_0x49b73a['where']=qs[_0x0d41('0x41')](_[_0x0d41('0x42')](_0x537635[_0x0d41('0x1f')],_0x73486[_0x0d41('0x41')]));_0x49b73a[_0x0d41('0x1d')][_0x0d41('0x43')]=_0x5de101['id'];if(_0x537635[_0x0d41('0x1f')]['filter']){_0x49b73a[_0x0d41('0x1d')]=_[_0x0d41('0x2a')](_0x49b73a[_0x0d41('0x1d')],{'$or':_[_0x0d41('0x17')](_0x49b73a[_0x0d41('0x27')],function(_0x4e1b0f){var _0x54b35e={};_0x54b35e[_0x4e1b0f]={'$like':'%'+_0x537635[_0x0d41('0x1f')][_0x0d41('0x44')]+'%'};return _0x54b35e;})});}_0x49b73a=_[_0x0d41('0x2a')]({},_0x49b73a,_0x537635[_0x0d41('0x2b')]);return db['UserWhatsappQueue'][_0x0d41('0x45')](_0x49b73a);}})[_0x0d41('0x12')](function(_0x3c3e07){if(_0x3c3e07){return db[_0x0d41('0x46')][_0x0d41('0x47')]({'where':{'id':_[_0x0d41('0x17')](_0x3c3e07,_0x0d41('0x48')),'role':_0x0d41('0x49')},'attributes':['id',_0x0d41('0x34'),_0x0d41('0x4a'),_0x0d41('0x4b'),_0x0d41('0x4c')]});}})[_0x0d41('0x12')](function(_0x4e6c01){if(_0x4e6c01){return{'count':_0x4e6c01[_0x0d41('0xf')],'rows':_[_0x0d41('0x17')](_0x4e6c01['rows'],function(_0x2bcfe4){return{'membername':_0x2bcfe4['name'],'UserId':_0x2bcfe4['id'],'queue_name':_0xdbd497[_0x0d41('0x34')],'WhatsappQueueId':_0xdbd497['id'],'interface':util['format'](_0x0d41('0x4d'),_0x0d41('0x4e'),_0x2bcfe4['name']),'penalty':0x0,'paused':_0x2bcfe4[_0x0d41('0x4a')],'createdAt':_0x2bcfe4[_0x0d41('0x4c')],'updatedAt':_0x2bcfe4[_0x0d41('0x4b')]};})};}else{return{'count':0x0,'rows':[]};}})['then'](respondWithFilteredResult(_0x56eea7,_0x49b73a))[_0x0d41('0x22')](handleError(_0x56eea7,null));};exports[_0x0d41('0x4f')]=function(_0x514d4b,_0x2c1693){var _0x47bc72={};var _0x1b5806={};var _0x26c782;var _0x52e7e7;return db[_0x0d41('0x20')]['findOne']({'where':{'id':_0x514d4b[_0x0d41('0x37')]['id']}})[_0x0d41('0x12')](handleEntityNotFound(_0x2c1693,null))[_0x0d41('0x12')](function(_0x275572){if(_0x275572){_0x26c782=_0x275572;_0x1b5806[_0x0d41('0x24')]=_[_0x0d41('0x25')](db[_0x0d41('0x50')][_0x0d41('0x18')]);_0x1b5806[_0x0d41('0x1f')]=_[_0x0d41('0x25')](_0x514d4b[_0x0d41('0x1f')]);_0x1b5806['filters']=_['intersection'](_0x1b5806[_0x0d41('0x24')],_0x1b5806['query']);_0x47bc72[_0x0d41('0x27')]=_[_0x0d41('0x26')](_0x1b5806['model'],qs[_0x0d41('0x28')](_0x514d4b[_0x0d41('0x1f')]['fields']));_0x47bc72[_0x0d41('0x27')]=_0x47bc72[_0x0d41('0x27')][_0x0d41('0x3c')]?_0x47bc72[_0x0d41('0x27')]:_0x1b5806[_0x0d41('0x24')];_0x47bc72['order']=qs[_0x0d41('0x40')](_0x514d4b[_0x0d41('0x1f')][_0x0d41('0x40')]);_0x47bc72[_0x0d41('0x1d')]=qs[_0x0d41('0x41')](_['pick'](_0x514d4b['query'],_0x1b5806[_0x0d41('0x41')]));if(_0x514d4b[_0x0d41('0x1f')][_0x0d41('0x44')]){_0x47bc72['where']=_[_0x0d41('0x2a')](_0x47bc72[_0x0d41('0x1d')],{'$or':_[_0x0d41('0x17')](_0x47bc72['attributes'],function(_0x3e024e){var _0x55d985={};_0x55d985[_0x3e024e]={'$like':'%'+_0x514d4b[_0x0d41('0x1f')][_0x0d41('0x44')]+'%'};return _0x55d985;})});}_0x47bc72=_['merge']({},_0x47bc72,_0x514d4b[_0x0d41('0x2b')]);return _0x26c782[_0x0d41('0x4f')](_0x47bc72);}})[_0x0d41('0x12')](function(_0x474ca7){if(_0x474ca7){_0x52e7e7=_0x474ca7['length'];if(!_0x514d4b[_0x0d41('0x1f')][_0x0d41('0x3d')](_0x0d41('0x3e'))){_0x47bc72[_0x0d41('0xe')]=qs['limit'](_0x514d4b[_0x0d41('0x1f')][_0x0d41('0xe')]);_0x47bc72[_0x0d41('0xc')]=qs['offset'](_0x514d4b[_0x0d41('0x1f')][_0x0d41('0xc')]);}return _0x26c782[_0x0d41('0x4f')](_0x47bc72);}})['then'](function(_0x2d5cf3){if(_0x2d5cf3){return _0x2d5cf3?{'count':_0x52e7e7,'rows':_0x2d5cf3}:null;}})[_0x0d41('0x12')](respondWithResult(_0x2c1693,null))[_0x0d41('0x22')](handleError(_0x2c1693,null));};exports[_0x0d41('0x51')]=function(_0xf17a9b,_0xe6a44e){var _0x1cc067=_0xf17a9b[_0x0d41('0x2d')][_0x0d41('0x52')];return db[_0x0d41('0x50')][_0x0d41('0x45')]({'where':{'id':_0x1cc067},'attributes':['id'],'include':[{'model':db[_0x0d41('0x46')],'as':'Agents','attributes':['id',_0x0d41('0x34'),_0x0d41('0x53'),_0x0d41('0x54'),_0x0d41('0x55')],'raw':!![]}]})[_0x0d41('0x12')](function(_0x2d7ab4){if(_0x2d7ab4){var _0x262b36=_['flatMap'](_0x2d7ab4,function(_0x5c6a5e){var _0x22c1a7=_0x5c6a5e[_0x0d41('0x13')]({'plain':!![]});return _0x22c1a7['Agents'];});return db[_0x0d41('0x20')]['find']({'where':{'id':_0xf17a9b['params']['id']}})[_0x0d41('0x12')](function(_0x3aafca){return db['sequelize'][_0x0d41('0x56')](function(_0x24d57c){return _0x3aafca[_0x0d41('0x51')](_0x1cc067,{'transaction':_0x24d57c})[_0x0d41('0x12')](function(){return BPromise['each'](_0x262b36,function(_0x52049b){return db[_0x0d41('0x3b')]['findOrCreate']({'where':{'UserId':_0x52049b['id'],'WhatsappQueueId':_0xf17a9b['params']['id']},'transaction':_0x24d57c});});})['then'](function(){_0x262b36[_0x0d41('0x57')](function(_0x1f1caa){socket[_0x0d41('0x58')](_0x0d41('0x59'),{'UserId':_0x1f1caa['id'],'WhatsappQueueId':_0x3aafca['id']});});});});});}})['then'](respondWithStatusCode(_0xe6a44e,null))['catch'](handleError(_0xe6a44e,null));};exports['removeTeams']=function(_0x1d2377,_0x4ce93a){return db[_0x0d41('0x50')][_0x0d41('0x45')]({'where':{'id':_0x1d2377[_0x0d41('0x1f')][_0x0d41('0x52')]},'attributes':['id'],'include':[{'model':db[_0x0d41('0x46')],'as':_0x0d41('0x5a'),'attributes':['id'],'raw':!![]}]})[_0x0d41('0x12')](handleEntityNotFound(_0x4ce93a,null))['then'](function(_0x3bf78b){var _0x324ecb=_[_0x0d41('0x17')](_0x3bf78b,'id');var _0x2a18a7=[];var _0x536040=[];var _0x2c81a8=squel[_0x0d41('0x5b')]();_0x2c81a8[_0x0d41('0x5c')]('tq.TeamId')['from']('team_has_whatsapp_queues','tq')[_0x0d41('0x5d')](_0x0d41('0x5e'),'ut',_0x0d41('0x5f'))[_0x0d41('0x1d')](_0x0d41('0x60'),_0x1d2377['params']['id']);for(var _0x4c8702=0x0;_0x4c8702<_0x3bf78b['length'];_0x4c8702+=0x1){let _0x1666b1=_0x3bf78b[_0x4c8702];for(var _0x5265d0=0x0;_0x5265d0<_0x1666b1['Agents']['length'];_0x5265d0+=0x1){let _0x596181=_0x1666b1[_0x0d41('0x5a')][_0x5265d0];var _0x7d02ac=_0x2c81a8[_0x0d41('0x61')]();_0x7d02ac['where'](_0x0d41('0x62'),_0x596181['id']);_0x536040[_0x0d41('0x63')](db['sequelize'][_0x0d41('0x1f')](_0x7d02ac[_0x0d41('0x64')](),{'type':db[_0x0d41('0x65')]['QueryTypes']['SELECT']})[_0x0d41('0x12')](function(_0x52f90d){if(_0x52f90d['length']===0x1){return _0x596181['id'];}else{var _0xff8874=_['every'](_[_0x0d41('0x17')](_0x52f90d,_0x0d41('0x66')),function(_0x5b00f8){return _[_0x0d41('0x67')](_0x324ecb,_0x5b00f8);});if(_0xff8874){return _0x596181['id'];}}}));}}return BPromise[_0x0d41('0x68')](_0x536040)['then'](function(_0x54a93e){_0x2a18a7=_(_0x2a18a7)['union'](_0x54a93e)['compact']()[_0x0d41('0x69')]();return db[_0x0d41('0x20')][_0x0d41('0x30')]({'where':{'id':_0x1d2377[_0x0d41('0x37')]['id']}})['then'](function(_0xd90fcf){return db[_0x0d41('0x65')][_0x0d41('0x56')](function(_0x936e78){return _0xd90fcf[_0x0d41('0x6a')](_0x1d2377['query'][_0x0d41('0x52')],{'transaction':_0x936e78})[_0x0d41('0x12')](function(){if(!_[_0x0d41('0x6b')](_0x2a18a7)){return _0xd90fcf[_0x0d41('0x6c')](_0x2a18a7,{'transaction':_0x936e78});}})[_0x0d41('0x12')](function(){_0x2a18a7[_0x0d41('0x57')](function(_0x41b5b3){socket[_0x0d41('0x58')](_0x0d41('0x6d'),{'UserId':_0x41b5b3,'WhatsappQueueId':_0xd90fcf['id']});});});});});});})[_0x0d41('0x12')](respondWithStatusCode(_0x4ce93a,null))[_0x0d41('0x22')](handleError(_0x4ce93a,null));};exports[_0x0d41('0x6e')]=function(_0x1fd35c,_0x29f366){return db[_0x0d41('0x20')][_0x0d41('0x30')]({'where':{'id':_0x1fd35c[_0x0d41('0x37')]['id']}})['then'](handleEntityNotFound(_0x29f366,null))[_0x0d41('0x12')](function(_0x33d190){if(_0x33d190){return _0x33d190['addAgents'](_0x1fd35c[_0x0d41('0x2d')][_0x0d41('0x52')],_[_0x0d41('0x6f')](_0x1fd35c['body'],[_0x0d41('0x52'),'id'])||{})[_0x0d41('0x70')](function(_0x18cd27){for(var _0x64df80=0x0;_0x64df80<_0x1fd35c[_0x0d41('0x2d')][_0x0d41('0x52')][_0x0d41('0x3c')];_0x64df80+=0x1){socket['emit'](_0x0d41('0x59'),{'UserId':Number(_0x1fd35c[_0x0d41('0x2d')]['ids'][_0x64df80]),'WhatsappQueueId':Number(_0x1fd35c[_0x0d41('0x37')]['id'])});}return _0x18cd27;});}})[_0x0d41('0x12')](respondWithResult(_0x29f366,null))[_0x0d41('0x22')](handleError(_0x29f366,null));};exports[_0x0d41('0x6c')]=function(_0x3645be,_0x5821f1){return db[_0x0d41('0x20')][_0x0d41('0x30')]({'where':{'id':_0x3645be['params']['id']}})[_0x0d41('0x12')](handleEntityNotFound(_0x5821f1,null))[_0x0d41('0x12')](function(_0x226214){if(_0x226214){return _0x226214[_0x0d41('0x6c')](_0x3645be[_0x0d41('0x1f')]['ids'])[_0x0d41('0x12')](function(){if(_[_0x0d41('0x71')](_0x3645be[_0x0d41('0x1f')][_0x0d41('0x52')])){for(var _0x2e8954=0x0;_0x2e8954<_0x3645be[_0x0d41('0x1f')][_0x0d41('0x52')][_0x0d41('0x3c')];_0x2e8954+=0x1){socket[_0x0d41('0x58')](_0x0d41('0x6d'),{'UserId':Number(_0x3645be[_0x0d41('0x1f')][_0x0d41('0x52')][_0x2e8954]),'WhatsappQueueId':Number(_0x3645be[_0x0d41('0x37')]['id'])});}}else{socket[_0x0d41('0x58')]('userWhatsappQueue:remove',{'UserId':Number(_0x3645be[_0x0d41('0x1f')]['ids']),'WhatsappQueueId':Number(_0x3645be[_0x0d41('0x37')]['id'])});}});}})['then'](respondWithStatusCode(_0x5821f1,null))[_0x0d41('0x22')](handleError(_0x5821f1,null));};exports[_0x0d41('0x72')]=function(_0x5bdb17,_0x450e7e){var _0x54b60d={};var _0x599e9e={};var _0x203ae3;var _0x42bab4;return db[_0x0d41('0x20')][_0x0d41('0x3a')]({'where':{'id':_0x5bdb17[_0x0d41('0x37')]['id']}})[_0x0d41('0x12')](handleEntityNotFound(_0x450e7e,null))[_0x0d41('0x12')](function(_0x258bcb){if(_0x258bcb){_0x203ae3=_0x258bcb;_0x599e9e[_0x0d41('0x24')]=_['keys'](db['User'][_0x0d41('0x18')]);_0x599e9e[_0x0d41('0x1f')]=_[_0x0d41('0x25')](_0x5bdb17[_0x0d41('0x1f')]);_0x599e9e[_0x0d41('0x41')]=_['intersection'](_0x599e9e['model'],_0x599e9e[_0x0d41('0x1f')]);_0x54b60d['attributes']=_[_0x0d41('0x26')](_0x599e9e[_0x0d41('0x24')],qs[_0x0d41('0x28')](_0x5bdb17[_0x0d41('0x1f')][_0x0d41('0x28')]));_0x54b60d[_0x0d41('0x27')]=_0x54b60d['attributes']['length']?_0x54b60d[_0x0d41('0x27')]:_0x599e9e[_0x0d41('0x24')];_0x54b60d['order']=qs[_0x0d41('0x40')](_0x5bdb17[_0x0d41('0x1f')]['sort']);_0x54b60d[_0x0d41('0x1d')]=qs[_0x0d41('0x41')](_[_0x0d41('0x42')](_0x5bdb17[_0x0d41('0x1f')],_0x599e9e['filters']));if(_0x5bdb17[_0x0d41('0x1f')][_0x0d41('0x44')]){_0x54b60d[_0x0d41('0x1d')]=_['merge'](_0x54b60d['where'],{'$or':_[_0x0d41('0x17')](_0x54b60d[_0x0d41('0x27')],function(_0x38fd1e){var _0x14cad8={};_0x14cad8[_0x38fd1e]={'$like':'%'+_0x5bdb17[_0x0d41('0x1f')][_0x0d41('0x44')]+'%'};return _0x14cad8;})});}_0x54b60d=_[_0x0d41('0x2a')]({},_0x54b60d,_0x5bdb17[_0x0d41('0x2b')]);return _0x203ae3['getAgents'](_0x54b60d);}})[_0x0d41('0x12')](function(_0x39470a){if(_0x39470a){_0x42bab4=_0x39470a[_0x0d41('0x3c')];if(!_0x5bdb17[_0x0d41('0x1f')][_0x0d41('0x3d')](_0x0d41('0x3e'))){_0x54b60d[_0x0d41('0xe')]=qs[_0x0d41('0xe')](_0x5bdb17[_0x0d41('0x1f')][_0x0d41('0xe')]);_0x54b60d[_0x0d41('0xc')]=qs[_0x0d41('0xc')](_0x5bdb17[_0x0d41('0x1f')][_0x0d41('0xc')]);}return _0x203ae3['getAgents'](_0x54b60d);}})[_0x0d41('0x12')](function(_0xf193e6){if(_0xf193e6){return _0xf193e6?{'count':_0x42bab4,'rows':_0xf193e6}:null;}})[_0x0d41('0x12')](respondWithResult(_0x450e7e,null))[_0x0d41('0x22')](handleError(_0x450e7e,null));};
\ No newline at end of file