Built motion from commit (unavailable).|2.5.1
[motion2.git] / server / api / chatQueue / chatQueue.controller.js
index 4618676..85b8d17 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x0c75=['result','catch','status','end','json','offset','set','Content-Range','apply','reject','update','destroy','get','ChatQueues','UserProfileResource','sendStatus','stack','name','send','map','ChatQueue','rawAttributes','key','model','query','keys','intersection','attributes','fields','nolimit','limit','order','sort','where','filters','pick','merge','type','VIRTUAL','filter','include','rows','params','length','includeAll','options','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','UserProfileSection','find','describe','getMembers','hasOwnProperty','ChatQueueId','UserChatQueue','User','findAndCountAll','UserId','agent','updatedAt','createdAt','%s/%s','SIP','chatPause','findOne','getTeams','addTeams','ids','Team','findAll','Agents','online','voicePause','flatMap','transaction','findOrCreate','forEach','userChatQueue:save','removeTeams','select','tq.TeamId','from','team_has_chat_queues','ut.TeamId\x20=\x20tq.TeamId','ChatQueueId\x20=\x20?','clone','ut.UserId\x20=\x20?','push','sequelize','toString','QueryTypes','every','TeamId','compact','value','isEmpty','removeAgents','userChatQueue:remove','addAgents','omit','spread','emit','isArray','getAgents','eml-format','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','sox','ejs','squel','crypto','jsforce','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/utils','../../config/environment','../../mysqldb','defaults','redis','localhost','socket.io-emitter','jayson/promise','client','Sequelize','ValidationError','The\x20password\x20must\x20be\x20at\x20least\x208\x20characters\x20long\x20and\x20have\x201\x20lowercase\x20character,\x201\x20uppercase\x20character,\x201\x20number\x20and\x201\x20special\x20character\x20~!@#$%^&-_=+[{]}.','request','then','info','request\x20sent','debug','ChatQueue,\x20%s,\x20%s,\x20%s','stringify','error','code','ChatQueue,\x20%s,\x20%s','message'];(function(_0x3f9948,_0x553195){var _0x52de54=function(_0x25271e){while(--_0x25271e){_0x3f9948['push'](_0x3f9948['shift']());}};_0x52de54(++_0x553195);}(_0x0c75,0x6a));var _0x50c7=function(_0x321bb2,_0x202794){_0x321bb2=_0x321bb2-0x0;var _0x9c12ed=_0x0c75[_0x321bb2];return _0x9c12ed;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0x50c7('0x0'));var rimraf=require('rimraf');var zipdir=require(_0x50c7('0x1'));var jsonpatch=require(_0x50c7('0x2'));var rp=require(_0x50c7('0x3'));var moment=require(_0x50c7('0x4'));var BPromise=require(_0x50c7('0x5'));var Mustache=require(_0x50c7('0x6'));var util=require(_0x50c7('0x7'));var path=require('path');var sox=require(_0x50c7('0x8'));var csv=require('to-csv');var ejs=require(_0x50c7('0x9'));var fs=require('fs');var _=require('lodash');var squel=require(_0x50c7('0xa'));var crypto=require(_0x50c7('0xb'));var jsforce=require(_0x50c7('0xc'));var deskjs=require('desk.js');var toCsv=require('to-csv');var querystring=require(_0x50c7('0xd'));var Papa=require(_0x50c7('0xe'));var Redis=require(_0x50c7('0xf'));var authService=require(_0x50c7('0x10'));var qs=require(_0x50c7('0x11'));var as=require(_0x50c7('0x12'));var hardwareService=require(_0x50c7('0x13'));var logger=require('../../config/logger')('api');var utils=require(_0x50c7('0x14'));var config=require(_0x50c7('0x15'));var db=require(_0x50c7('0x16'))['db'];config['redis']=_[_0x50c7('0x17')](config[_0x50c7('0x18')],{'host':_0x50c7('0x19'),'port':0x18eb});var socket=require(_0x50c7('0x1a'))(new Redis(config[_0x50c7('0x18')]));require('./chatQueue.socket')['register'](socket);var jayson=require(_0x50c7('0x1b'));var client=jayson[_0x50c7('0x1c')]['http']({'port':0x232a});function checkPasswordPattern(_0x19b580,_0x1f1db1,_0x19ce5e){if(_0x19ce5e){var _0x4f092a=new RegExp(/(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[?!@#\$%\^&\*~\-_=+[{\]\}])(?=.{8,})/);if(_0x4f092a['test'](_0x1f1db1)){return _0x19b580;}else{throw new db[(_0x50c7('0x1d'))][(_0x50c7('0x1e'))](_0x50c7('0x1f'));}}else{return _0x19b580;}}function respondWithRpcPromise(_0x50639c,_0x473375,_0x41024d,_0x42a89b){return new BPromise(function(_0x5d30db,_0xd5b365){var _0x4e5651=_0x42a89b||client;return _0x4e5651[_0x50c7('0x20')](_0x50639c,_0x41024d)[_0x50c7('0x21')](function(_0x3187ab){logger[_0x50c7('0x22')]('ChatQueue,\x20%s,\x20%s',_0x473375,_0x50c7('0x23'));logger[_0x50c7('0x24')](_0x50c7('0x25'),_0x473375,_0x50c7('0x23'),JSON[_0x50c7('0x26')](_0x3187ab));if(_0x3187ab[_0x50c7('0x27')]){if(_0x3187ab['error'][_0x50c7('0x28')]===0x1f4){logger[_0x50c7('0x27')](_0x50c7('0x29'),_0x473375,_0x3187ab[_0x50c7('0x27')]['message']);return _0xd5b365(_0x3187ab[_0x50c7('0x27')]['message']);}logger[_0x50c7('0x27')](_0x50c7('0x29'),_0x473375,_0x3187ab[_0x50c7('0x27')]['message']);return _0x5d30db(_0x3187ab['error'][_0x50c7('0x2a')]);}else{logger[_0x50c7('0x22')](_0x50c7('0x29'),_0x473375,_0x50c7('0x23'));_0x5d30db(_0x3187ab[_0x50c7('0x2b')]['message']);}})[_0x50c7('0x2c')](function(_0x2820bc){logger['error'](_0x50c7('0x29'),_0x473375,_0x2820bc);_0xd5b365(_0x2820bc);});});}function respondWithStatusCode(_0x3bd031,_0x42411c){_0x42411c=_0x42411c||0xcc;return function(_0x1586cb){if(_0x1586cb){return _0x3bd031['sendStatus'](_0x42411c);}return _0x3bd031[_0x50c7('0x2d')](_0x42411c)[_0x50c7('0x2e')]();};}function respondWithResult(_0x255087,_0x2d4417){_0x2d4417=_0x2d4417||0xc8;return function(_0x1e339d){if(_0x1e339d){return _0x255087[_0x50c7('0x2d')](_0x2d4417)[_0x50c7('0x2f')](_0x1e339d);}};}function respondWithFilteredResult(_0x59045e,_0x32d048){return function(_0x21e72e){if(_0x21e72e){var _0x2636e3=_0x21e72e['count'],_0x23d2ee=_0x32d048[_0x50c7('0x30')],_0x244f02=_0x32d048['offset']+_0x32d048['limit'],_0x181e3e;if(_0x244f02>=_0x2636e3){_0x244f02=_0x2636e3;_0x181e3e=0xc8;}else{_0x181e3e=0xce;}_0x59045e['status'](_0x181e3e);return _0x59045e[_0x50c7('0x31')](_0x50c7('0x32'),_0x23d2ee+'-'+_0x244f02+'/'+_0x2636e3)[_0x50c7('0x2f')](_0x21e72e);}return null;};}function patchUpdates(_0x4ae5c2){return function(_0xa81bc8){try{jsonpatch[_0x50c7('0x33')](_0xa81bc8,_0x4ae5c2,!![]);}catch(_0xde61c4){return BPromise[_0x50c7('0x34')](_0xde61c4);}return _0xa81bc8['save']();};}function saveUpdates(_0x52f70f,_0x3f43d4){return function(_0x1b18dc){if(_0x1b18dc){return _0x1b18dc[_0x50c7('0x35')](_0x52f70f)[_0x50c7('0x21')](function(_0x380ec4){return _0x380ec4;});}return null;};}function removeEntity(_0x40d735,_0x11a82b){return function(_0xec60dd){if(_0xec60dd){return _0xec60dd[_0x50c7('0x36')]()['then'](function(){var _0x50aaf0=_0xec60dd[_0x50c7('0x37')]({'plain':!![]});var _0x728325=_0x50c7('0x38');return db[_0x50c7('0x39')]['destroy']({'where':{'type':_0x728325,'resourceId':_0x50aaf0['id']}})['then'](function(){return _0xec60dd;});})[_0x50c7('0x21')](function(){_0x40d735[_0x50c7('0x2d')](0xcc)['end']();});}};}function handleEntityNotFound(_0x21dea3,_0x2617ba){return function(_0x2c6e3d){if(!_0x2c6e3d){_0x21dea3[_0x50c7('0x3a')](0x194);}return _0x2c6e3d;};}function handleError(_0x39599b,_0x266a69){_0x266a69=_0x266a69||0x1f4;return function(_0x4e602e){logger[_0x50c7('0x27')](_0x4e602e[_0x50c7('0x3b')]);if(_0x4e602e[_0x50c7('0x3c')]){delete _0x4e602e[_0x50c7('0x3c')];}_0x39599b['status'](_0x266a69)[_0x50c7('0x3d')](_0x4e602e);};}exports['index']=function(_0x3c9ecc,_0x4f5e55){var _0x1237d9={},_0x2daf59={},_0x5b00ce={'count':0x0,'rows':[]};var _0x432be3=_[_0x50c7('0x3e')](db[_0x50c7('0x3f')][_0x50c7('0x40')],function(_0x36d64c){return{'name':_0x36d64c['fieldName'],'type':_0x36d64c['type'][_0x50c7('0x41')]};});_0x2daf59[_0x50c7('0x42')]=_[_0x50c7('0x3e')](_0x432be3,'name');_0x2daf59[_0x50c7('0x43')]=_[_0x50c7('0x44')](_0x3c9ecc[_0x50c7('0x43')]);_0x2daf59['filters']=_[_0x50c7('0x45')](_0x2daf59[_0x50c7('0x42')],_0x2daf59[_0x50c7('0x43')]);_0x1237d9[_0x50c7('0x46')]=_[_0x50c7('0x45')](_0x2daf59[_0x50c7('0x42')],qs['fields'](_0x3c9ecc[_0x50c7('0x43')][_0x50c7('0x47')]));_0x1237d9[_0x50c7('0x46')]=_0x1237d9[_0x50c7('0x46')]['length']?_0x1237d9[_0x50c7('0x46')]:_0x2daf59[_0x50c7('0x42')];if(!_0x3c9ecc[_0x50c7('0x43')]['hasOwnProperty'](_0x50c7('0x48'))){_0x1237d9[_0x50c7('0x49')]=qs['limit'](_0x3c9ecc[_0x50c7('0x43')][_0x50c7('0x49')]);_0x1237d9[_0x50c7('0x30')]=qs[_0x50c7('0x30')](_0x3c9ecc['query'][_0x50c7('0x30')]);}_0x1237d9[_0x50c7('0x4a')]=qs[_0x50c7('0x4b')](_0x3c9ecc[_0x50c7('0x43')][_0x50c7('0x4b')]);_0x1237d9[_0x50c7('0x4c')]=qs[_0x50c7('0x4d')](_[_0x50c7('0x4e')](_0x3c9ecc[_0x50c7('0x43')],_0x2daf59[_0x50c7('0x4d')]));if(_0x3c9ecc[_0x50c7('0x43')]['filter']){_0x1237d9['where']=_[_0x50c7('0x4f')](_0x1237d9[_0x50c7('0x4c')],{'$or':_[_0x50c7('0x3e')](_0x432be3,function(_0x2ac267){if(_0x2ac267[_0x50c7('0x50')]!==_0x50c7('0x51')){var _0xc12494={};_0xc12494[_0x2ac267[_0x50c7('0x3c')]]={'$like':'%'+_0x3c9ecc['query'][_0x50c7('0x52')]+'%'};return _0xc12494;}})});}_0x1237d9=_[_0x50c7('0x4f')]({},_0x1237d9,_0x3c9ecc['options']);var _0x5d980e={'where':_0x1237d9[_0x50c7('0x4c')]};return db[_0x50c7('0x3f')]['count'](_0x5d980e)[_0x50c7('0x21')](function(_0x5f0b69){_0x5b00ce['count']=_0x5f0b69;if(_0x3c9ecc[_0x50c7('0x43')]['includeAll']){_0x1237d9[_0x50c7('0x53')]=[{'all':!![]}];}return db[_0x50c7('0x3f')]['findAll'](_0x1237d9);})[_0x50c7('0x21')](function(_0x120586){_0x5b00ce[_0x50c7('0x54')]=_0x120586;return _0x5b00ce;})[_0x50c7('0x21')](respondWithFilteredResult(_0x4f5e55,_0x1237d9))[_0x50c7('0x2c')](handleError(_0x4f5e55,null));};exports['show']=function(_0x3095bd,_0x21c38d){var _0x15922d={'raw':!![],'where':{'id':_0x3095bd[_0x50c7('0x55')]['id']}},_0x5afc50={};_0x5afc50[_0x50c7('0x42')]=_[_0x50c7('0x44')](db[_0x50c7('0x3f')]['rawAttributes']);_0x5afc50['query']=_[_0x50c7('0x44')](_0x3095bd['query']);_0x5afc50[_0x50c7('0x4d')]=_[_0x50c7('0x45')](_0x5afc50[_0x50c7('0x42')],_0x5afc50[_0x50c7('0x43')]);_0x15922d['attributes']=_['intersection'](_0x5afc50['model'],qs[_0x50c7('0x47')](_0x3095bd['query']['fields']));_0x15922d[_0x50c7('0x46')]=_0x15922d['attributes'][_0x50c7('0x56')]?_0x15922d[_0x50c7('0x46')]:_0x5afc50[_0x50c7('0x42')];if(_0x3095bd[_0x50c7('0x43')][_0x50c7('0x57')]){_0x15922d[_0x50c7('0x53')]=[{'all':!![]}];}_0x15922d=_[_0x50c7('0x4f')]({},_0x15922d,_0x3095bd[_0x50c7('0x58')]);return db[_0x50c7('0x3f')]['find'](_0x15922d)[_0x50c7('0x21')](handleEntityNotFound(_0x21c38d,null))['then'](respondWithResult(_0x21c38d,null))[_0x50c7('0x2c')](handleError(_0x21c38d,null));};exports['create']=function(_0x3936dd,_0x411c4f){return db[_0x50c7('0x3f')][_0x50c7('0x59')](_0x3936dd[_0x50c7('0x5a')],{})[_0x50c7('0x21')](function(_0x511a17){var _0x2334db=_0x3936dd[_0x50c7('0x5b')][_0x50c7('0x37')]({'plain':!![]});if(!_0x2334db)throw new Error(_0x50c7('0x5c'));if(_0x2334db['role']===_0x50c7('0x5b')){var _0x308635=_0x511a17[_0x50c7('0x37')]({'plain':!![]});var _0x2f5ad9=_0x50c7('0x38');return db[_0x50c7('0x5d')][_0x50c7('0x5e')]({'where':{'name':_0x2f5ad9,'userProfileId':_0x2334db['userProfileId']},'raw':!![]})[_0x50c7('0x21')](function(_0x48f222){if(_0x48f222&&_0x48f222['autoAssociation']===0x0){return db[_0x50c7('0x39')]['create']({'name':_0x308635[_0x50c7('0x3c')],'resourceId':_0x308635['id'],'type':_0x48f222[_0x50c7('0x3c')],'sectionId':_0x48f222['id']},{})[_0x50c7('0x21')](function(){return _0x511a17;});}else{return _0x511a17;}})[_0x50c7('0x2c')](function(_0xde1312){logger[_0x50c7('0x27')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0xde1312);throw _0xde1312;});}return _0x511a17;})[_0x50c7('0x21')](respondWithResult(_0x411c4f,0xc9))[_0x50c7('0x2c')](handleError(_0x411c4f,null));};exports[_0x50c7('0x35')]=function(_0x28036c,_0x319aee){if(_0x28036c[_0x50c7('0x5a')]['id']){delete _0x28036c[_0x50c7('0x5a')]['id'];}return db[_0x50c7('0x3f')]['find']({'where':{'id':_0x28036c['params']['id']}})[_0x50c7('0x21')](handleEntityNotFound(_0x319aee,null))[_0x50c7('0x21')](saveUpdates(_0x28036c[_0x50c7('0x5a')],null))[_0x50c7('0x21')](respondWithResult(_0x319aee,null))[_0x50c7('0x2c')](handleError(_0x319aee,null));};exports[_0x50c7('0x36')]=function(_0x46cef2,_0x508aab){return db['ChatQueue'][_0x50c7('0x5e')]({'where':{'id':_0x46cef2['params']['id']}})[_0x50c7('0x21')](handleEntityNotFound(_0x508aab,null))[_0x50c7('0x21')](removeEntity(_0x508aab,null))['catch'](handleError(_0x508aab,null));};exports[_0x50c7('0x5f')]=function(_0x12d5ee,_0x359f60){return db[_0x50c7('0x3f')][_0x50c7('0x5f')]()[_0x50c7('0x21')](respondWithResult(_0x359f60,null))[_0x50c7('0x2c')](handleError(_0x359f60,null));};exports[_0x50c7('0x60')]=function(_0x289d5d,_0x452a23,_0x8d66f8){var _0x5d53fc={'raw':!![],'where':{}},_0x4b7d2f={},_0x1ae8d8;return db[_0x50c7('0x3f')]['findOne']({'where':{'id':_0x289d5d[_0x50c7('0x55')]['id']}})[_0x50c7('0x21')](handleEntityNotFound(_0x452a23,null))[_0x50c7('0x21')](function(_0x30a21a){if(_0x30a21a){_0x1ae8d8=_0x30a21a[_0x50c7('0x37')]({'plain':!![]});_0x4b7d2f[_0x50c7('0x42')]=_[_0x50c7('0x44')](db['UserChatQueue']['rawAttributes']);_0x4b7d2f[_0x50c7('0x43')]=_[_0x50c7('0x44')](_0x289d5d[_0x50c7('0x43')]);_0x4b7d2f[_0x50c7('0x4d')]=_[_0x50c7('0x45')](_0x4b7d2f[_0x50c7('0x42')],_0x4b7d2f[_0x50c7('0x43')]);_0x5d53fc['attributes']=_[_0x50c7('0x45')](_0x4b7d2f['model'],qs['fields'](_0x289d5d[_0x50c7('0x43')]['fields']));_0x5d53fc[_0x50c7('0x46')]=_0x5d53fc[_0x50c7('0x46')]['length']?_0x5d53fc[_0x50c7('0x46')]:_0x4b7d2f[_0x50c7('0x42')];if(!_0x289d5d['query'][_0x50c7('0x61')](_0x50c7('0x48'))){_0x5d53fc['limit']=qs[_0x50c7('0x49')](_0x289d5d['query'][_0x50c7('0x49')]);_0x5d53fc[_0x50c7('0x30')]=qs[_0x50c7('0x30')](_0x289d5d[_0x50c7('0x43')]['offset']);}_0x5d53fc['order']=qs['sort'](_0x289d5d[_0x50c7('0x43')][_0x50c7('0x4b')]);_0x5d53fc[_0x50c7('0x4c')]=qs[_0x50c7('0x4d')](_['pick'](_0x289d5d[_0x50c7('0x43')],_0x4b7d2f[_0x50c7('0x4d')]));_0x5d53fc['where'][_0x50c7('0x62')]=_0x30a21a['id'];if(_0x289d5d[_0x50c7('0x43')]['filter']){_0x5d53fc['where']=_[_0x50c7('0x4f')](_0x5d53fc[_0x50c7('0x4c')],{'$or':_[_0x50c7('0x3e')](_0x5d53fc['attributes'],function(_0x3b7876){var _0x2fd70e={};_0x2fd70e[_0x3b7876]={'$like':'%'+_0x289d5d['query'][_0x50c7('0x52')]+'%'};return _0x2fd70e;})});}_0x5d53fc=_[_0x50c7('0x4f')]({},_0x5d53fc,_0x289d5d[_0x50c7('0x58')]);return db[_0x50c7('0x63')]['findAll'](_0x5d53fc);}})[_0x50c7('0x21')](function(_0x1dc20e){if(_0x1dc20e){return db[_0x50c7('0x64')][_0x50c7('0x65')]({'where':{'id':_[_0x50c7('0x3e')](_0x1dc20e,_0x50c7('0x66')),'role':_0x50c7('0x67')},'attributes':['id',_0x50c7('0x3c'),'chatPause',_0x50c7('0x68'),_0x50c7('0x69')]});}})[_0x50c7('0x21')](function(_0x3944a0){if(_0x3944a0){return{'count':_0x3944a0['count'],'rows':_['map'](_0x3944a0[_0x50c7('0x54')],function(_0x5b6a5a){return{'membername':_0x5b6a5a['name'],'UserId':_0x5b6a5a['id'],'queue_name':_0x1ae8d8[_0x50c7('0x3c')],'ChatQueueId':_0x1ae8d8['id'],'interface':util['format'](_0x50c7('0x6a'),_0x50c7('0x6b'),_0x5b6a5a[_0x50c7('0x3c')]),'penalty':0x0,'paused':_0x5b6a5a[_0x50c7('0x6c')],'createdAt':_0x5b6a5a[_0x50c7('0x69')],'updatedAt':_0x5b6a5a[_0x50c7('0x68')]};})};}else{return{'count':0x0,'rows':[]};}})['then'](respondWithFilteredResult(_0x452a23,_0x5d53fc))[_0x50c7('0x2c')](handleError(_0x452a23,null));};exports['getTeams']=function(_0x13ba4d,_0x1788e5,_0x890dcd){var _0x2eda10={};var _0x278702={};var _0x3fab99;var _0x2e5ff9;return db[_0x50c7('0x3f')][_0x50c7('0x6d')]({'where':{'id':_0x13ba4d['params']['id']}})[_0x50c7('0x21')](handleEntityNotFound(_0x1788e5,null))[_0x50c7('0x21')](function(_0x25b912){if(_0x25b912){_0x3fab99=_0x25b912;_0x278702[_0x50c7('0x42')]=_[_0x50c7('0x44')](db['Team'][_0x50c7('0x40')]);_0x278702[_0x50c7('0x43')]=_[_0x50c7('0x44')](_0x13ba4d['query']);_0x278702[_0x50c7('0x4d')]=_[_0x50c7('0x45')](_0x278702[_0x50c7('0x42')],_0x278702[_0x50c7('0x43')]);_0x2eda10[_0x50c7('0x46')]=_[_0x50c7('0x45')](_0x278702[_0x50c7('0x42')],qs[_0x50c7('0x47')](_0x13ba4d[_0x50c7('0x43')][_0x50c7('0x47')]));_0x2eda10['attributes']=_0x2eda10['attributes'][_0x50c7('0x56')]?_0x2eda10['attributes']:_0x278702[_0x50c7('0x42')];_0x2eda10['order']=qs[_0x50c7('0x4b')](_0x13ba4d['query']['sort']);_0x2eda10[_0x50c7('0x4c')]=qs[_0x50c7('0x4d')](_[_0x50c7('0x4e')](_0x13ba4d[_0x50c7('0x43')],_0x278702[_0x50c7('0x4d')]));if(_0x13ba4d[_0x50c7('0x43')]['filter']){_0x2eda10['where']=_[_0x50c7('0x4f')](_0x2eda10['where'],{'$or':_[_0x50c7('0x3e')](_0x2eda10[_0x50c7('0x46')],function(_0x538779){var _0x29b33d={};_0x29b33d[_0x538779]={'$like':'%'+_0x13ba4d[_0x50c7('0x43')][_0x50c7('0x52')]+'%'};return _0x29b33d;})});}_0x2eda10=_[_0x50c7('0x4f')]({},_0x2eda10,_0x13ba4d['options']);return _0x3fab99[_0x50c7('0x6e')](_0x2eda10);}})[_0x50c7('0x21')](function(_0x59b61c){if(_0x59b61c){_0x2e5ff9=_0x59b61c[_0x50c7('0x56')];if(!_0x13ba4d['query'][_0x50c7('0x61')](_0x50c7('0x48'))){_0x2eda10['limit']=qs[_0x50c7('0x49')](_0x13ba4d[_0x50c7('0x43')][_0x50c7('0x49')]);_0x2eda10[_0x50c7('0x30')]=qs['offset'](_0x13ba4d[_0x50c7('0x43')][_0x50c7('0x30')]);}return _0x3fab99[_0x50c7('0x6e')](_0x2eda10);}})[_0x50c7('0x21')](function(_0x3c0ade){if(_0x3c0ade){return _0x3c0ade?{'count':_0x2e5ff9,'rows':_0x3c0ade}:null;}})['then'](respondWithResult(_0x1788e5,null))['catch'](handleError(_0x1788e5,null));};exports[_0x50c7('0x6f')]=function(_0x1b7459,_0x881cc0,_0x14f588){var _0x126c4b=_0x1b7459[_0x50c7('0x5a')][_0x50c7('0x70')];return db[_0x50c7('0x71')][_0x50c7('0x72')]({'where':{'id':_0x126c4b},'attributes':['id'],'include':[{'model':db[_0x50c7('0x64')],'as':_0x50c7('0x73'),'attributes':['id',_0x50c7('0x3c'),_0x50c7('0x74'),_0x50c7('0x75'),'interface'],'raw':!![]}]})['then'](function(_0x4e8700){if(_0x4e8700){var _0x382346=_[_0x50c7('0x76')](_0x4e8700,function(_0x4d7cb8){var _0x56ade0=_0x4d7cb8[_0x50c7('0x37')]({'plain':!![]});return _0x56ade0[_0x50c7('0x73')];});return db['ChatQueue']['find']({'where':{'id':_0x1b7459[_0x50c7('0x55')]['id']}})[_0x50c7('0x21')](function(_0x2653c1){return db['sequelize'][_0x50c7('0x77')](function(_0x2cb73e){return _0x2653c1[_0x50c7('0x6f')](_0x126c4b,{'transaction':_0x2cb73e})[_0x50c7('0x21')](function(){return BPromise['each'](_0x382346,function(_0x531ff9){return db[_0x50c7('0x63')][_0x50c7('0x78')]({'where':{'UserId':_0x531ff9['id'],'ChatQueueId':_0x1b7459['params']['id']},'transaction':_0x2cb73e});});})[_0x50c7('0x21')](function(){_0x382346[_0x50c7('0x79')](function(_0xf7181a){socket['emit'](_0x50c7('0x7a'),{'UserId':_0xf7181a['id'],'ChatQueueId':_0x2653c1['id']});});});});});}})['then'](respondWithStatusCode(_0x881cc0,null))[_0x50c7('0x2c')](handleError(_0x881cc0,null));};exports[_0x50c7('0x7b')]=function(_0x358e95,_0x3ba1ba,_0xddc78c){return db[_0x50c7('0x71')][_0x50c7('0x72')]({'where':{'id':_0x358e95[_0x50c7('0x43')]['ids']},'attributes':['id'],'include':[{'model':db[_0x50c7('0x64')],'as':_0x50c7('0x73'),'attributes':['id'],'raw':!![]}]})[_0x50c7('0x21')](handleEntityNotFound(_0x3ba1ba,null))[_0x50c7('0x21')](function(_0x42b2b2){var _0xead7d0=_[_0x50c7('0x3e')](_0x42b2b2,'id');var _0x3158a9=[];var _0x599a8f=[];var _0x5d4a2a=squel[_0x50c7('0x7c')]();_0x5d4a2a['field'](_0x50c7('0x7d'))[_0x50c7('0x7e')](_0x50c7('0x7f'),'tq')['join']('user_has_teams','ut',_0x50c7('0x80'))[_0x50c7('0x4c')](_0x50c7('0x81'),_0x358e95[_0x50c7('0x55')]['id']);for(var _0x35e40b=0x0;_0x35e40b<_0x42b2b2[_0x50c7('0x56')];_0x35e40b+=0x1){let _0x3e7885=_0x42b2b2[_0x35e40b];for(var _0x1ec139=0x0;_0x1ec139<_0x3e7885[_0x50c7('0x73')][_0x50c7('0x56')];_0x1ec139+=0x1){let _0x5070dd=_0x3e7885[_0x50c7('0x73')][_0x1ec139];var _0x1dbda4=_0x5d4a2a[_0x50c7('0x82')]();_0x1dbda4[_0x50c7('0x4c')](_0x50c7('0x83'),_0x5070dd['id']);_0x599a8f[_0x50c7('0x84')](db[_0x50c7('0x85')]['query'](_0x1dbda4[_0x50c7('0x86')](),{'type':db['sequelize'][_0x50c7('0x87')]['SELECT']})[_0x50c7('0x21')](function(_0x5bbfd6){if(_0x5bbfd6[_0x50c7('0x56')]===0x1){return _0x5070dd['id'];}else{var _0x2ba9f4=_[_0x50c7('0x88')](_[_0x50c7('0x3e')](_0x5bbfd6,_0x50c7('0x89')),function(_0x46f4a1){return _['includes'](_0xead7d0,_0x46f4a1);});if(_0x2ba9f4){return _0x5070dd['id'];}}}));}}return BPromise['all'](_0x599a8f)[_0x50c7('0x21')](function(_0x39e37c){_0x3158a9=_(_0x3158a9)['union'](_0x39e37c)[_0x50c7('0x8a')]()[_0x50c7('0x8b')]();return db[_0x50c7('0x3f')]['find']({'where':{'id':_0x358e95[_0x50c7('0x55')]['id']}})['then'](function(_0x16222a){return db[_0x50c7('0x85')][_0x50c7('0x77')](function(_0x52db96){return _0x16222a['removeTeams'](_0x358e95['query'][_0x50c7('0x70')],{'transaction':_0x52db96})[_0x50c7('0x21')](function(){if(!_[_0x50c7('0x8c')](_0x3158a9)){return _0x16222a[_0x50c7('0x8d')](_0x3158a9,{'transaction':_0x52db96});}})['then'](function(){_0x3158a9[_0x50c7('0x79')](function(_0x295a19){socket['emit'](_0x50c7('0x8e'),{'UserId':_0x295a19,'ChatQueueId':_0x16222a['id']});});});});});});})['then'](respondWithStatusCode(_0x3ba1ba,null))[_0x50c7('0x2c')](handleError(_0x3ba1ba,null));};exports[_0x50c7('0x8f')]=function(_0x3a2ace,_0xae6d63,_0x2e5216){return db[_0x50c7('0x3f')]['find']({'where':{'id':_0x3a2ace['params']['id']}})['then'](handleEntityNotFound(_0xae6d63,null))['then'](function(_0x37f839){if(_0x37f839){return _0x37f839[_0x50c7('0x8f')](_0x3a2ace['body']['ids'],_[_0x50c7('0x90')](_0x3a2ace['body'],['ids','id'])||{})[_0x50c7('0x91')](function(_0xf2e99){for(var _0x420d4d=0x0;_0x420d4d<_0x3a2ace[_0x50c7('0x5a')][_0x50c7('0x70')][_0x50c7('0x56')];_0x420d4d+=0x1){socket[_0x50c7('0x92')]('userChatQueue:save',{'UserId':_0x3a2ace['body'][_0x50c7('0x70')][_0x420d4d],'ChatQueueId':_0x3a2ace[_0x50c7('0x55')]['id']});}return _0xf2e99;});}})[_0x50c7('0x21')](respondWithResult(_0xae6d63,null))['catch'](handleError(_0xae6d63,null));};exports['removeAgents']=function(_0x1fbf8a,_0x17a7fe,_0x1656a2){return db[_0x50c7('0x3f')][_0x50c7('0x5e')]({'where':{'id':_0x1fbf8a[_0x50c7('0x55')]['id']}})['then'](handleEntityNotFound(_0x17a7fe,null))[_0x50c7('0x21')](function(_0x40cd13){if(_0x40cd13){return _0x40cd13[_0x50c7('0x8d')](_0x1fbf8a[_0x50c7('0x43')][_0x50c7('0x70')])[_0x50c7('0x21')](function(){if(_[_0x50c7('0x93')](_0x1fbf8a[_0x50c7('0x43')][_0x50c7('0x70')])){for(var _0x1d7858=0x0;_0x1d7858<_0x1fbf8a[_0x50c7('0x43')][_0x50c7('0x70')]['length'];_0x1d7858+=0x1){socket[_0x50c7('0x92')](_0x50c7('0x8e'),{'UserId':Number(_0x1fbf8a[_0x50c7('0x43')][_0x50c7('0x70')][_0x1d7858]),'ChatQueueId':Number(_0x1fbf8a[_0x50c7('0x55')]['id'])});}}else{socket[_0x50c7('0x92')](_0x50c7('0x8e'),{'UserId':Number(_0x1fbf8a[_0x50c7('0x43')][_0x50c7('0x70')]),'ChatQueueId':Number(_0x1fbf8a[_0x50c7('0x55')]['id'])});}});}})[_0x50c7('0x21')](respondWithStatusCode(_0x17a7fe,null))[_0x50c7('0x2c')](handleError(_0x17a7fe,null));};exports[_0x50c7('0x94')]=function(_0x5939bb,_0x3d4ec1,_0x253383){var _0x40e2aa={};var _0x48b5b9={};var _0x31b0c3;var _0x5876;return db[_0x50c7('0x3f')][_0x50c7('0x6d')]({'where':{'id':_0x5939bb['params']['id']}})[_0x50c7('0x21')](handleEntityNotFound(_0x3d4ec1,null))[_0x50c7('0x21')](function(_0x414d49){if(_0x414d49){_0x31b0c3=_0x414d49;_0x48b5b9[_0x50c7('0x42')]=_[_0x50c7('0x44')](db[_0x50c7('0x64')]['rawAttributes']);_0x48b5b9['query']=_[_0x50c7('0x44')](_0x5939bb[_0x50c7('0x43')]);_0x48b5b9['filters']=_[_0x50c7('0x45')](_0x48b5b9[_0x50c7('0x42')],_0x48b5b9[_0x50c7('0x43')]);_0x40e2aa['attributes']=_[_0x50c7('0x45')](_0x48b5b9['model'],qs[_0x50c7('0x47')](_0x5939bb[_0x50c7('0x43')][_0x50c7('0x47')]));_0x40e2aa[_0x50c7('0x46')]=_0x40e2aa['attributes']['length']?_0x40e2aa[_0x50c7('0x46')]:_0x48b5b9[_0x50c7('0x42')];_0x40e2aa[_0x50c7('0x4a')]=qs['sort'](_0x5939bb[_0x50c7('0x43')][_0x50c7('0x4b')]);_0x40e2aa[_0x50c7('0x4c')]=qs['filters'](_[_0x50c7('0x4e')](_0x5939bb['query'],_0x48b5b9[_0x50c7('0x4d')]));if(_0x5939bb[_0x50c7('0x43')][_0x50c7('0x52')]){_0x40e2aa[_0x50c7('0x4c')]=_['merge'](_0x40e2aa[_0x50c7('0x4c')],{'$or':_[_0x50c7('0x3e')](_0x40e2aa[_0x50c7('0x46')],function(_0x17bbd7){var _0x2af45d={};_0x2af45d[_0x17bbd7]={'$like':'%'+_0x5939bb['query'][_0x50c7('0x52')]+'%'};return _0x2af45d;})});}_0x40e2aa=_[_0x50c7('0x4f')]({},_0x40e2aa,_0x5939bb[_0x50c7('0x58')]);return _0x31b0c3['getAgents'](_0x40e2aa);}})['then'](function(_0x244940){if(_0x244940){_0x5876=_0x244940[_0x50c7('0x56')];if(!_0x5939bb[_0x50c7('0x43')]['hasOwnProperty'](_0x50c7('0x48'))){_0x40e2aa[_0x50c7('0x49')]=qs[_0x50c7('0x49')](_0x5939bb['query']['limit']);_0x40e2aa[_0x50c7('0x30')]=qs[_0x50c7('0x30')](_0x5939bb[_0x50c7('0x43')]['offset']);}return _0x31b0c3[_0x50c7('0x94')](_0x40e2aa);}})['then'](function(_0x5bb39a){if(_0x5bb39a){return _0x5bb39a?{'count':_0x5876,'rows':_0x5bb39a}:null;}})[_0x50c7('0x21')](respondWithResult(_0x3d4ec1,null))[_0x50c7('0x2c')](handleError(_0x3d4ec1,null));};
\ No newline at end of file
+var _0x173f=['register','jayson/promise','client','http','test','Sequelize','request','then','info','ChatQueue,\x20%s,\x20%s','request\x20sent','ChatQueue,\x20%s,\x20%s,\x20%s','stringify','error','message','result','catch','sendStatus','status','end','json','count','offset','limit','set','apply','save','UserProfileResource','destroy','stack','name','send','index','map','ChatQueue','key','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','type','VIRTUAL','merge','includeAll','include','rows','show','rawAttributes','options','find','create','body','get','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','user','ChatQueues','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','update','params','describe','findOne','UserChatQueue','ChatQueueId','findAll','User','findAndCountAll','UserId','updatedAt','createdAt','format','%s/%s','SIP','chatPause','Team','getTeams','ids','Agents','voicePause','interface','flatMap','transaction','addTeams','each','findOrCreate','userChatQueue:save','removeTeams','select','field','tq.TeamId','team_has_chat_queues','join','user_has_teams','ut.TeamId\x20=\x20tq.TeamId','clone','ut.UserId\x20=\x20?','push','sequelize','toString','every','TeamId','includes','all','compact','value','removeAgents','forEach','emit','userChatQueue:remove','addAgents','getAgents','eml-format','zip-dir','request-promise','moment','mustache','util','sox','to-csv','ejs','jsforce','desk.js','querystring','ioredis','../../components/auth/service','../../config/logger','../../config/environment','../../mysqldb','redis','defaults','localhost','socket.io-emitter'];(function(_0x4146b4,_0x274b03){var _0x5133de=function(_0x12c37e){while(--_0x12c37e){_0x4146b4['push'](_0x4146b4['shift']());}};_0x5133de(++_0x274b03);}(_0x173f,0x19b));var _0xf173=function(_0x53ccf2,_0x13cb67){_0x53ccf2=_0x53ccf2-0x0;var _0x5a2964=_0x173f[_0x53ccf2];return _0x5a2964;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0xf173('0x0'));var rimraf=require('rimraf');var zipdir=require(_0xf173('0x1'));var jsonpatch=require('fast-json-patch');var rp=require(_0xf173('0x2'));var moment=require(_0xf173('0x3'));var BPromise=require('bluebird');var Mustache=require(_0xf173('0x4'));var util=require(_0xf173('0x5'));var path=require('path');var sox=require(_0xf173('0x6'));var csv=require(_0xf173('0x7'));var ejs=require(_0xf173('0x8'));var fs=require('fs');var _=require('lodash');var squel=require('squel');var crypto=require('crypto');var jsforce=require(_0xf173('0x9'));var deskjs=require(_0xf173('0xa'));var toCsv=require(_0xf173('0x7'));var querystring=require(_0xf173('0xb'));var Papa=require('papaparse');var Redis=require(_0xf173('0xc'));var authService=require(_0xf173('0xd'));var qs=require('../../components/parsers/qs');var as=require('../../components/parsers/advancedSearch');var hardwareService=require('../../config/license/hardware');var logger=require(_0xf173('0xe'))('api');var utils=require('../../config/utils');var config=require(_0xf173('0xf'));var db=require(_0xf173('0x10'))['db'];config[_0xf173('0x11')]=_[_0xf173('0x12')](config['redis'],{'host':_0xf173('0x13'),'port':0x18eb});var socket=require(_0xf173('0x14'))(new Redis(config[_0xf173('0x11')]));require('./chatQueue.socket')[_0xf173('0x15')](socket);var jayson=require(_0xf173('0x16'));var client=jayson[_0xf173('0x17')][_0xf173('0x18')]({'port':0x232a});function checkPasswordPattern(_0x28d1e5,_0xcb07db,_0x52b763){if(_0x52b763){var _0x3f4269=new RegExp(/(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[?!@#\$%\^&\*~\-_=+[{\]\}])(?=.{8,})/);if(_0x3f4269[_0xf173('0x19')](_0xcb07db)){return _0x28d1e5;}else{throw new db[(_0xf173('0x1a'))]['ValidationError']('The\x20password\x20must\x20be\x20at\x20least\x208\x20characters\x20long\x20and\x20have\x201\x20lowercase\x20character,\x201\x20uppercase\x20character,\x201\x20number\x20and\x201\x20special\x20character\x20~!@#$%^&-_=+[{]}.');}}else{return _0x28d1e5;}}function respondWithRpcPromise(_0x21efe1,_0x2db2e4,_0x230262,_0x335dbd){return new BPromise(function(_0x353338,_0x2438ce){var _0x159278=_0x335dbd||client;return _0x159278[_0xf173('0x1b')](_0x21efe1,_0x230262)[_0xf173('0x1c')](function(_0x43f603){logger[_0xf173('0x1d')](_0xf173('0x1e'),_0x2db2e4,_0xf173('0x1f'));logger['debug'](_0xf173('0x20'),_0x2db2e4,_0xf173('0x1f'),JSON[_0xf173('0x21')](_0x43f603));if(_0x43f603[_0xf173('0x22')]){if(_0x43f603[_0xf173('0x22')]['code']===0x1f4){logger[_0xf173('0x22')](_0xf173('0x1e'),_0x2db2e4,_0x43f603[_0xf173('0x22')][_0xf173('0x23')]);return _0x2438ce(_0x43f603[_0xf173('0x22')][_0xf173('0x23')]);}logger['error']('ChatQueue,\x20%s,\x20%s',_0x2db2e4,_0x43f603['error'][_0xf173('0x23')]);return _0x353338(_0x43f603[_0xf173('0x22')]['message']);}else{logger[_0xf173('0x1d')](_0xf173('0x1e'),_0x2db2e4,_0xf173('0x1f'));_0x353338(_0x43f603[_0xf173('0x24')][_0xf173('0x23')]);}})[_0xf173('0x25')](function(_0x573e43){logger[_0xf173('0x22')]('ChatQueue,\x20%s,\x20%s',_0x2db2e4,_0x573e43);_0x2438ce(_0x573e43);});});}function respondWithStatusCode(_0x317d91,_0x5ab8ef){_0x5ab8ef=_0x5ab8ef||0xcc;return function(_0x57be37){if(_0x57be37){return _0x317d91[_0xf173('0x26')](_0x5ab8ef);}return _0x317d91[_0xf173('0x27')](_0x5ab8ef)[_0xf173('0x28')]();};}function respondWithResult(_0x4103c8,_0x3b07ca){_0x3b07ca=_0x3b07ca||0xc8;return function(_0x4a3a1a){if(_0x4a3a1a){return _0x4103c8[_0xf173('0x27')](_0x3b07ca)[_0xf173('0x29')](_0x4a3a1a);}};}function respondWithFilteredResult(_0xc96af5,_0xaee760){return function(_0x37d97d){if(_0x37d97d){var _0xa0b406=_0x37d97d[_0xf173('0x2a')],_0x32a2fe=_0xaee760[_0xf173('0x2b')],_0x56854a=_0xaee760[_0xf173('0x2b')]+_0xaee760[_0xf173('0x2c')],_0x2cc2c7;if(_0x56854a>=_0xa0b406){_0x56854a=_0xa0b406;_0x2cc2c7=0xc8;}else{_0x2cc2c7=0xce;}_0xc96af5['status'](_0x2cc2c7);return _0xc96af5[_0xf173('0x2d')]('Content-Range',_0x32a2fe+'-'+_0x56854a+'/'+_0xa0b406)['json'](_0x37d97d);}return null;};}function patchUpdates(_0x2b35ba){return function(_0x415f52){try{jsonpatch[_0xf173('0x2e')](_0x415f52,_0x2b35ba,!![]);}catch(_0x18fd56){return BPromise['reject'](_0x18fd56);}return _0x415f52[_0xf173('0x2f')]();};}function saveUpdates(_0x1195f9,_0x1b78ae){return function(_0x2765c3){if(_0x2765c3){return _0x2765c3['update'](_0x1195f9)[_0xf173('0x1c')](function(_0x4fff7c){return _0x4fff7c;});}return null;};}function removeEntity(_0xef0d36,_0x2e476b){return function(_0x2f4f60){if(_0x2f4f60){return _0x2f4f60['destroy']()['then'](function(){var _0x47c569=_0x2f4f60['get']({'plain':!![]});var _0x3fc4e4='ChatQueues';return db[_0xf173('0x30')][_0xf173('0x31')]({'where':{'type':_0x3fc4e4,'resourceId':_0x47c569['id']}})[_0xf173('0x1c')](function(){return _0x2f4f60;});})[_0xf173('0x1c')](function(){_0xef0d36['status'](0xcc)[_0xf173('0x28')]();});}};}function handleEntityNotFound(_0x4eda49,_0x5d1ef7){return function(_0x1896d2){if(!_0x1896d2){_0x4eda49[_0xf173('0x26')](0x194);}return _0x1896d2;};}function handleError(_0x430603,_0x1c9a0d){_0x1c9a0d=_0x1c9a0d||0x1f4;return function(_0x34952e){logger[_0xf173('0x22')](_0x34952e[_0xf173('0x32')]);if(_0x34952e[_0xf173('0x33')]){delete _0x34952e[_0xf173('0x33')];}_0x430603[_0xf173('0x27')](_0x1c9a0d)[_0xf173('0x34')](_0x34952e);};}exports[_0xf173('0x35')]=function(_0x3f5972,_0x58e33d){var _0x3f3002={},_0x413feb={},_0x291458={'count':0x0,'rows':[]};var _0x5cde5f=_[_0xf173('0x36')](db[_0xf173('0x37')]['rawAttributes'],function(_0x1c4cd8){return{'name':_0x1c4cd8['fieldName'],'type':_0x1c4cd8['type'][_0xf173('0x38')]};});_0x413feb[_0xf173('0x39')]=_['map'](_0x5cde5f,_0xf173('0x33'));_0x413feb[_0xf173('0x3a')]=_[_0xf173('0x3b')](_0x3f5972[_0xf173('0x3a')]);_0x413feb[_0xf173('0x3c')]=_[_0xf173('0x3d')](_0x413feb[_0xf173('0x39')],_0x413feb['query']);_0x3f3002[_0xf173('0x3e')]=_[_0xf173('0x3d')](_0x413feb[_0xf173('0x39')],qs[_0xf173('0x3f')](_0x3f5972[_0xf173('0x3a')]['fields']));_0x3f3002[_0xf173('0x3e')]=_0x3f3002[_0xf173('0x3e')][_0xf173('0x40')]?_0x3f3002[_0xf173('0x3e')]:_0x413feb[_0xf173('0x39')];if(!_0x3f5972[_0xf173('0x3a')][_0xf173('0x41')](_0xf173('0x42'))){_0x3f3002[_0xf173('0x2c')]=qs[_0xf173('0x2c')](_0x3f5972['query'][_0xf173('0x2c')]);_0x3f3002[_0xf173('0x2b')]=qs[_0xf173('0x2b')](_0x3f5972['query'][_0xf173('0x2b')]);}_0x3f3002[_0xf173('0x43')]=qs[_0xf173('0x44')](_0x3f5972[_0xf173('0x3a')][_0xf173('0x44')]);_0x3f3002[_0xf173('0x45')]=qs[_0xf173('0x3c')](_[_0xf173('0x46')](_0x3f5972['query'],_0x413feb['filters']),_0x5cde5f);if(_0x3f5972[_0xf173('0x3a')][_0xf173('0x47')]){_0x3f3002[_0xf173('0x45')]=_['merge'](_0x3f3002[_0xf173('0x45')],{'$or':_[_0xf173('0x36')](_0x5cde5f,function(_0x4001a9){if(_0x4001a9[_0xf173('0x48')]!==_0xf173('0x49')){var _0x25cb6a={};_0x25cb6a[_0x4001a9['name']]={'$like':'%'+_0x3f5972[_0xf173('0x3a')][_0xf173('0x47')]+'%'};return _0x25cb6a;}})});}_0x3f3002=_[_0xf173('0x4a')]({},_0x3f3002,_0x3f5972['options']);var _0x541bc1={'where':_0x3f3002['where']};return db[_0xf173('0x37')][_0xf173('0x2a')](_0x541bc1)[_0xf173('0x1c')](function(_0x1ca7f6){_0x291458['count']=_0x1ca7f6;if(_0x3f5972[_0xf173('0x3a')][_0xf173('0x4b')]){_0x3f3002[_0xf173('0x4c')]=[{'all':!![]}];}return db[_0xf173('0x37')]['findAll'](_0x3f3002);})['then'](function(_0x4856a1){_0x291458[_0xf173('0x4d')]=_0x4856a1;return _0x291458;})[_0xf173('0x1c')](respondWithFilteredResult(_0x58e33d,_0x3f3002))['catch'](handleError(_0x58e33d,null));};exports[_0xf173('0x4e')]=function(_0x5dfbd2,_0x26f537){var _0x3706a2={'raw':!![],'where':{'id':_0x5dfbd2['params']['id']}},_0x47ad3d={};_0x47ad3d[_0xf173('0x39')]=_[_0xf173('0x3b')](db[_0xf173('0x37')][_0xf173('0x4f')]);_0x47ad3d[_0xf173('0x3a')]=_[_0xf173('0x3b')](_0x5dfbd2['query']);_0x47ad3d[_0xf173('0x3c')]=_[_0xf173('0x3d')](_0x47ad3d[_0xf173('0x39')],_0x47ad3d[_0xf173('0x3a')]);_0x3706a2[_0xf173('0x3e')]=_['intersection'](_0x47ad3d[_0xf173('0x39')],qs[_0xf173('0x3f')](_0x5dfbd2[_0xf173('0x3a')][_0xf173('0x3f')]));_0x3706a2[_0xf173('0x3e')]=_0x3706a2[_0xf173('0x3e')]['length']?_0x3706a2[_0xf173('0x3e')]:_0x47ad3d[_0xf173('0x39')];if(_0x5dfbd2[_0xf173('0x3a')][_0xf173('0x4b')]){_0x3706a2[_0xf173('0x4c')]=[{'all':!![]}];}_0x3706a2=_[_0xf173('0x4a')]({},_0x3706a2,_0x5dfbd2[_0xf173('0x50')]);return db['ChatQueue'][_0xf173('0x51')](_0x3706a2)[_0xf173('0x1c')](handleEntityNotFound(_0x26f537,null))[_0xf173('0x1c')](respondWithResult(_0x26f537,null))[_0xf173('0x25')](handleError(_0x26f537,null));};exports[_0xf173('0x52')]=function(_0x3b059d,_0x478d56){return db[_0xf173('0x37')][_0xf173('0x52')](_0x3b059d[_0xf173('0x53')],{})[_0xf173('0x1c')](function(_0x214d4a){var _0x3484ee=_0x3b059d['user'][_0xf173('0x54')]({'plain':!![]});if(!_0x3484ee)throw new Error(_0xf173('0x55'));if(_0x3484ee[_0xf173('0x56')]===_0xf173('0x57')){var _0x2407a2=_0x214d4a[_0xf173('0x54')]({'plain':!![]});var _0x4e9546=_0xf173('0x58');return db['UserProfileSection'][_0xf173('0x51')]({'where':{'name':_0x4e9546,'userProfileId':_0x3484ee['userProfileId']},'raw':!![]})[_0xf173('0x1c')](function(_0x398ac8){if(_0x398ac8&&_0x398ac8[_0xf173('0x59')]===0x0){return db[_0xf173('0x30')][_0xf173('0x52')]({'name':_0x2407a2[_0xf173('0x33')],'resourceId':_0x2407a2['id'],'type':_0x398ac8['name'],'sectionId':_0x398ac8['id']},{})['then'](function(){return _0x214d4a;});}else{return _0x214d4a;}})[_0xf173('0x25')](function(_0xb5a9ef){logger[_0xf173('0x22')](_0xf173('0x5a'),_0xb5a9ef);throw _0xb5a9ef;});}return _0x214d4a;})[_0xf173('0x1c')](respondWithResult(_0x478d56,0xc9))[_0xf173('0x25')](handleError(_0x478d56,null));};exports[_0xf173('0x5b')]=function(_0x47b54d,_0x3c9d68){if(_0x47b54d[_0xf173('0x53')]['id']){delete _0x47b54d[_0xf173('0x53')]['id'];}return db['ChatQueue'][_0xf173('0x51')]({'where':{'id':_0x47b54d[_0xf173('0x5c')]['id']}})['then'](handleEntityNotFound(_0x3c9d68,null))['then'](saveUpdates(_0x47b54d[_0xf173('0x53')],null))[_0xf173('0x1c')](respondWithResult(_0x3c9d68,null))['catch'](handleError(_0x3c9d68,null));};exports['destroy']=function(_0x5ed73b,_0x26788a){return db[_0xf173('0x37')][_0xf173('0x51')]({'where':{'id':_0x5ed73b['params']['id']}})[_0xf173('0x1c')](handleEntityNotFound(_0x26788a,null))['then'](removeEntity(_0x26788a,null))['catch'](handleError(_0x26788a,null));};exports[_0xf173('0x5d')]=function(_0x1516b3,_0xf47e80){return db[_0xf173('0x37')]['describe']()[_0xf173('0x1c')](respondWithResult(_0xf47e80,null))['catch'](handleError(_0xf47e80,null));};exports['getMembers']=function(_0x4a3201,_0x476830,_0x3de514){var _0x4ccb6a={'raw':!![],'where':{}},_0x37165d={},_0x202557;return db['ChatQueue'][_0xf173('0x5e')]({'where':{'id':_0x4a3201[_0xf173('0x5c')]['id']}})[_0xf173('0x1c')](handleEntityNotFound(_0x476830,null))[_0xf173('0x1c')](function(_0x3d4b08){if(_0x3d4b08){_0x202557=_0x3d4b08['get']({'plain':!![]});_0x37165d[_0xf173('0x39')]=_['keys'](db[_0xf173('0x5f')]['rawAttributes']);_0x37165d[_0xf173('0x3a')]=_[_0xf173('0x3b')](_0x4a3201[_0xf173('0x3a')]);_0x37165d['filters']=_['intersection'](_0x37165d[_0xf173('0x39')],_0x37165d[_0xf173('0x3a')]);_0x4ccb6a['attributes']=_[_0xf173('0x3d')](_0x37165d[_0xf173('0x39')],qs[_0xf173('0x3f')](_0x4a3201[_0xf173('0x3a')][_0xf173('0x3f')]));_0x4ccb6a[_0xf173('0x3e')]=_0x4ccb6a['attributes']['length']?_0x4ccb6a[_0xf173('0x3e')]:_0x37165d[_0xf173('0x39')];if(!_0x4a3201[_0xf173('0x3a')][_0xf173('0x41')](_0xf173('0x42'))){_0x4ccb6a[_0xf173('0x2c')]=qs['limit'](_0x4a3201[_0xf173('0x3a')][_0xf173('0x2c')]);_0x4ccb6a[_0xf173('0x2b')]=qs[_0xf173('0x2b')](_0x4a3201[_0xf173('0x3a')][_0xf173('0x2b')]);}_0x4ccb6a[_0xf173('0x43')]=qs['sort'](_0x4a3201[_0xf173('0x3a')]['sort']);_0x4ccb6a[_0xf173('0x45')]=qs['filters'](_[_0xf173('0x46')](_0x4a3201[_0xf173('0x3a')],_0x37165d[_0xf173('0x3c')]));_0x4ccb6a[_0xf173('0x45')][_0xf173('0x60')]=_0x3d4b08['id'];if(_0x4a3201[_0xf173('0x3a')][_0xf173('0x47')]){_0x4ccb6a[_0xf173('0x45')]=_[_0xf173('0x4a')](_0x4ccb6a[_0xf173('0x45')],{'$or':_[_0xf173('0x36')](_0x4ccb6a['attributes'],function(_0x3cc0da){var _0x2e37df={};_0x2e37df[_0x3cc0da]={'$like':'%'+_0x4a3201['query']['filter']+'%'};return _0x2e37df;})});}_0x4ccb6a=_[_0xf173('0x4a')]({},_0x4ccb6a,_0x4a3201[_0xf173('0x50')]);return db[_0xf173('0x5f')][_0xf173('0x61')](_0x4ccb6a);}})[_0xf173('0x1c')](function(_0x369f38){if(_0x369f38){return db[_0xf173('0x62')][_0xf173('0x63')]({'where':{'id':_['map'](_0x369f38,_0xf173('0x64')),'role':'agent'},'attributes':['id',_0xf173('0x33'),'chatPause',_0xf173('0x65'),_0xf173('0x66')]});}})[_0xf173('0x1c')](function(_0x28064c){if(_0x28064c){return{'count':_0x28064c['count'],'rows':_[_0xf173('0x36')](_0x28064c['rows'],function(_0x41f948){return{'membername':_0x41f948[_0xf173('0x33')],'UserId':_0x41f948['id'],'queue_name':_0x202557[_0xf173('0x33')],'ChatQueueId':_0x202557['id'],'interface':util[_0xf173('0x67')](_0xf173('0x68'),_0xf173('0x69'),_0x41f948[_0xf173('0x33')]),'penalty':0x0,'paused':_0x41f948[_0xf173('0x6a')],'createdAt':_0x41f948[_0xf173('0x66')],'updatedAt':_0x41f948[_0xf173('0x65')]};})};}else{return{'count':0x0,'rows':[]};}})[_0xf173('0x1c')](respondWithFilteredResult(_0x476830,_0x4ccb6a))[_0xf173('0x25')](handleError(_0x476830,null));};exports['getTeams']=function(_0x941fa8,_0x74e19c,_0xffc10a){var _0xaa29f7={};var _0x172b30={};var _0x2bf823;var _0x32d416;return db[_0xf173('0x37')][_0xf173('0x5e')]({'where':{'id':_0x941fa8[_0xf173('0x5c')]['id']}})[_0xf173('0x1c')](handleEntityNotFound(_0x74e19c,null))[_0xf173('0x1c')](function(_0x4b93c8){if(_0x4b93c8){_0x2bf823=_0x4b93c8;_0x172b30[_0xf173('0x39')]=_[_0xf173('0x3b')](db[_0xf173('0x6b')][_0xf173('0x4f')]);_0x172b30['query']=_[_0xf173('0x3b')](_0x941fa8['query']);_0x172b30['filters']=_[_0xf173('0x3d')](_0x172b30[_0xf173('0x39')],_0x172b30[_0xf173('0x3a')]);_0xaa29f7[_0xf173('0x3e')]=_[_0xf173('0x3d')](_0x172b30[_0xf173('0x39')],qs[_0xf173('0x3f')](_0x941fa8[_0xf173('0x3a')][_0xf173('0x3f')]));_0xaa29f7[_0xf173('0x3e')]=_0xaa29f7['attributes'][_0xf173('0x40')]?_0xaa29f7[_0xf173('0x3e')]:_0x172b30[_0xf173('0x39')];_0xaa29f7[_0xf173('0x43')]=qs[_0xf173('0x44')](_0x941fa8[_0xf173('0x3a')][_0xf173('0x44')]);_0xaa29f7[_0xf173('0x45')]=qs[_0xf173('0x3c')](_[_0xf173('0x46')](_0x941fa8[_0xf173('0x3a')],_0x172b30[_0xf173('0x3c')]));if(_0x941fa8['query'][_0xf173('0x47')]){_0xaa29f7['where']=_[_0xf173('0x4a')](_0xaa29f7['where'],{'$or':_[_0xf173('0x36')](_0xaa29f7[_0xf173('0x3e')],function(_0x29ad1a){var _0x3c66d9={};_0x3c66d9[_0x29ad1a]={'$like':'%'+_0x941fa8[_0xf173('0x3a')][_0xf173('0x47')]+'%'};return _0x3c66d9;})});}_0xaa29f7=_[_0xf173('0x4a')]({},_0xaa29f7,_0x941fa8[_0xf173('0x50')]);return _0x2bf823[_0xf173('0x6c')](_0xaa29f7);}})[_0xf173('0x1c')](function(_0x453bef){if(_0x453bef){_0x32d416=_0x453bef[_0xf173('0x40')];if(!_0x941fa8[_0xf173('0x3a')]['hasOwnProperty'](_0xf173('0x42'))){_0xaa29f7[_0xf173('0x2c')]=qs[_0xf173('0x2c')](_0x941fa8[_0xf173('0x3a')][_0xf173('0x2c')]);_0xaa29f7[_0xf173('0x2b')]=qs['offset'](_0x941fa8[_0xf173('0x3a')]['offset']);}return _0x2bf823[_0xf173('0x6c')](_0xaa29f7);}})['then'](function(_0x3202e2){if(_0x3202e2){return _0x3202e2?{'count':_0x32d416,'rows':_0x3202e2}:null;}})[_0xf173('0x1c')](respondWithResult(_0x74e19c,null))[_0xf173('0x25')](handleError(_0x74e19c,null));};exports['addTeams']=function(_0x1be031,_0x50de82,_0x475b46){var _0x2ad2d1=_0x1be031[_0xf173('0x53')][_0xf173('0x6d')];return db[_0xf173('0x6b')][_0xf173('0x61')]({'where':{'id':_0x2ad2d1},'attributes':['id'],'include':[{'model':db['User'],'as':_0xf173('0x6e'),'attributes':['id',_0xf173('0x33'),'online',_0xf173('0x6f'),_0xf173('0x70')],'raw':!![]}]})['then'](function(_0x9cb5ce){if(_0x9cb5ce){var _0xb00c7f=_[_0xf173('0x71')](_0x9cb5ce,function(_0x542002){var _0x3485ab=_0x542002['get']({'plain':!![]});return _0x3485ab['Agents'];});return db[_0xf173('0x37')][_0xf173('0x51')]({'where':{'id':_0x1be031[_0xf173('0x5c')]['id']}})['then'](function(_0x3e9c7a){return db['sequelize'][_0xf173('0x72')](function(_0x56c7cf){return _0x3e9c7a[_0xf173('0x73')](_0x2ad2d1,{'transaction':_0x56c7cf})[_0xf173('0x1c')](function(){return BPromise[_0xf173('0x74')](_0xb00c7f,function(_0x2d773c){return db[_0xf173('0x5f')][_0xf173('0x75')]({'where':{'UserId':_0x2d773c['id'],'ChatQueueId':_0x1be031[_0xf173('0x5c')]['id']},'transaction':_0x56c7cf});});})[_0xf173('0x1c')](function(){_0xb00c7f['forEach'](function(_0x52e5b7){socket['emit'](_0xf173('0x76'),{'UserId':_0x52e5b7['id'],'ChatQueueId':_0x3e9c7a['id']});});});});});}})[_0xf173('0x1c')](respondWithStatusCode(_0x50de82,null))[_0xf173('0x25')](handleError(_0x50de82,null));};exports[_0xf173('0x77')]=function(_0x20327e,_0x246b1b,_0xd5f277){return db['Team'][_0xf173('0x61')]({'where':{'id':_0x20327e[_0xf173('0x3a')][_0xf173('0x6d')]},'attributes':['id'],'include':[{'model':db[_0xf173('0x62')],'as':_0xf173('0x6e'),'attributes':['id'],'raw':!![]}]})['then'](handleEntityNotFound(_0x246b1b,null))['then'](function(_0x3b92b6){var _0x48cbb0=_['map'](_0x3b92b6,'id');var _0x44500e=[];var _0x5940ac=[];var _0x2f9ab6=squel[_0xf173('0x78')]();_0x2f9ab6[_0xf173('0x79')](_0xf173('0x7a'))['from'](_0xf173('0x7b'),'tq')[_0xf173('0x7c')](_0xf173('0x7d'),'ut',_0xf173('0x7e'))[_0xf173('0x45')]('ChatQueueId\x20=\x20?',_0x20327e['params']['id']);for(var _0xb86386=0x0;_0xb86386<_0x3b92b6[_0xf173('0x40')];_0xb86386+=0x1){let _0x504f47=_0x3b92b6[_0xb86386];for(var _0x579015=0x0;_0x579015<_0x504f47[_0xf173('0x6e')][_0xf173('0x40')];_0x579015+=0x1){let _0x5e08ff=_0x504f47['Agents'][_0x579015];var _0x1a463c=_0x2f9ab6[_0xf173('0x7f')]();_0x1a463c[_0xf173('0x45')](_0xf173('0x80'),_0x5e08ff['id']);_0x5940ac[_0xf173('0x81')](db[_0xf173('0x82')][_0xf173('0x3a')](_0x1a463c[_0xf173('0x83')](),{'type':db[_0xf173('0x82')]['QueryTypes']['SELECT']})['then'](function(_0x3a5101){if(_0x3a5101[_0xf173('0x40')]===0x1){return _0x5e08ff['id'];}else{var _0x4ef5ec=_[_0xf173('0x84')](_['map'](_0x3a5101,_0xf173('0x85')),function(_0x4d265f){return _[_0xf173('0x86')](_0x48cbb0,_0x4d265f);});if(_0x4ef5ec){return _0x5e08ff['id'];}}}));}}return BPromise[_0xf173('0x87')](_0x5940ac)[_0xf173('0x1c')](function(_0x3d00b4){_0x44500e=_(_0x44500e)['union'](_0x3d00b4)[_0xf173('0x88')]()[_0xf173('0x89')]();return db[_0xf173('0x37')][_0xf173('0x51')]({'where':{'id':_0x20327e[_0xf173('0x5c')]['id']}})[_0xf173('0x1c')](function(_0x3392c1){return db[_0xf173('0x82')]['transaction'](function(_0x173070){return _0x3392c1[_0xf173('0x77')](_0x20327e[_0xf173('0x3a')]['ids'],{'transaction':_0x173070})[_0xf173('0x1c')](function(){if(!_['isEmpty'](_0x44500e)){return _0x3392c1[_0xf173('0x8a')](_0x44500e,{'transaction':_0x173070});}})[_0xf173('0x1c')](function(){_0x44500e[_0xf173('0x8b')](function(_0x3deea3){socket[_0xf173('0x8c')](_0xf173('0x8d'),{'UserId':_0x3deea3,'ChatQueueId':_0x3392c1['id']});});});});});});})[_0xf173('0x1c')](respondWithStatusCode(_0x246b1b,null))[_0xf173('0x25')](handleError(_0x246b1b,null));};exports[_0xf173('0x8e')]=function(_0x657807,_0x4e7679,_0x522c2d){return db[_0xf173('0x37')][_0xf173('0x51')]({'where':{'id':_0x657807[_0xf173('0x5c')]['id']}})[_0xf173('0x1c')](handleEntityNotFound(_0x4e7679,null))[_0xf173('0x1c')](function(_0x4830a4){if(_0x4830a4){return _0x4830a4['addAgents'](_0x657807[_0xf173('0x53')][_0xf173('0x6d')],_['omit'](_0x657807[_0xf173('0x53')],[_0xf173('0x6d'),'id'])||{})['spread'](function(_0x20cbc5){for(var _0x421885=0x0;_0x421885<_0x657807[_0xf173('0x53')][_0xf173('0x6d')][_0xf173('0x40')];_0x421885+=0x1){socket['emit'](_0xf173('0x76'),{'UserId':_0x657807[_0xf173('0x53')][_0xf173('0x6d')][_0x421885],'ChatQueueId':_0x657807['params']['id']});}return _0x20cbc5;});}})[_0xf173('0x1c')](respondWithResult(_0x4e7679,null))[_0xf173('0x25')](handleError(_0x4e7679,null));};exports[_0xf173('0x8a')]=function(_0x379d59,_0x192a7b,_0x146f44){return db[_0xf173('0x37')][_0xf173('0x51')]({'where':{'id':_0x379d59[_0xf173('0x5c')]['id']}})[_0xf173('0x1c')](handleEntityNotFound(_0x192a7b,null))['then'](function(_0x412421){if(_0x412421){return _0x412421[_0xf173('0x8a')](_0x379d59['query'][_0xf173('0x6d')])[_0xf173('0x1c')](function(){if(_['isArray'](_0x379d59[_0xf173('0x3a')][_0xf173('0x6d')])){for(var _0x55910e=0x0;_0x55910e<_0x379d59[_0xf173('0x3a')][_0xf173('0x6d')][_0xf173('0x40')];_0x55910e+=0x1){socket[_0xf173('0x8c')](_0xf173('0x8d'),{'UserId':Number(_0x379d59[_0xf173('0x3a')]['ids'][_0x55910e]),'ChatQueueId':Number(_0x379d59[_0xf173('0x5c')]['id'])});}}else{socket['emit']('userChatQueue:remove',{'UserId':Number(_0x379d59[_0xf173('0x3a')][_0xf173('0x6d')]),'ChatQueueId':Number(_0x379d59[_0xf173('0x5c')]['id'])});}});}})[_0xf173('0x1c')](respondWithStatusCode(_0x192a7b,null))[_0xf173('0x25')](handleError(_0x192a7b,null));};exports['getAgents']=function(_0x4ae11c,_0x511720,_0x4df1b6){var _0x51d26b={};var _0x28e4a3={};var _0x1c240d;var _0x1b49df;return db[_0xf173('0x37')][_0xf173('0x5e')]({'where':{'id':_0x4ae11c[_0xf173('0x5c')]['id']}})[_0xf173('0x1c')](handleEntityNotFound(_0x511720,null))[_0xf173('0x1c')](function(_0x332233){if(_0x332233){_0x1c240d=_0x332233;_0x28e4a3['model']=_[_0xf173('0x3b')](db['User']['rawAttributes']);_0x28e4a3[_0xf173('0x3a')]=_[_0xf173('0x3b')](_0x4ae11c[_0xf173('0x3a')]);_0x28e4a3[_0xf173('0x3c')]=_[_0xf173('0x3d')](_0x28e4a3[_0xf173('0x39')],_0x28e4a3['query']);_0x51d26b[_0xf173('0x3e')]=_[_0xf173('0x3d')](_0x28e4a3[_0xf173('0x39')],qs[_0xf173('0x3f')](_0x4ae11c['query'][_0xf173('0x3f')]));_0x51d26b[_0xf173('0x3e')]=_0x51d26b[_0xf173('0x3e')][_0xf173('0x40')]?_0x51d26b['attributes']:_0x28e4a3[_0xf173('0x39')];_0x51d26b[_0xf173('0x43')]=qs[_0xf173('0x44')](_0x4ae11c[_0xf173('0x3a')][_0xf173('0x44')]);_0x51d26b[_0xf173('0x45')]=qs[_0xf173('0x3c')](_['pick'](_0x4ae11c[_0xf173('0x3a')],_0x28e4a3[_0xf173('0x3c')]));if(_0x4ae11c['query'][_0xf173('0x47')]){_0x51d26b[_0xf173('0x45')]=_[_0xf173('0x4a')](_0x51d26b['where'],{'$or':_[_0xf173('0x36')](_0x51d26b[_0xf173('0x3e')],function(_0x11b2a0){var _0x18f63b={};_0x18f63b[_0x11b2a0]={'$like':'%'+_0x4ae11c[_0xf173('0x3a')][_0xf173('0x47')]+'%'};return _0x18f63b;})});}_0x51d26b=_['merge']({},_0x51d26b,_0x4ae11c['options']);return _0x1c240d[_0xf173('0x8f')](_0x51d26b);}})['then'](function(_0x3f1cd8){if(_0x3f1cd8){_0x1b49df=_0x3f1cd8['length'];if(!_0x4ae11c['query'][_0xf173('0x41')](_0xf173('0x42'))){_0x51d26b[_0xf173('0x2c')]=qs['limit'](_0x4ae11c['query'][_0xf173('0x2c')]);_0x51d26b[_0xf173('0x2b')]=qs[_0xf173('0x2b')](_0x4ae11c[_0xf173('0x3a')][_0xf173('0x2b')]);}return _0x1c240d[_0xf173('0x8f')](_0x51d26b);}})[_0xf173('0x1c')](function(_0x912cfa){if(_0x912cfa){return _0x912cfa?{'count':_0x1b49df,'rows':_0x912cfa}:null;}})[_0xf173('0x1c')](respondWithResult(_0x511720,null))[_0xf173('0x25')](handleError(_0x511720,null));};
\ No newline at end of file