Built motion from commit 00bf23f6.|2.6.16
[motion2.git] / server / api / user / user.controller.js
index dcf082f..09bbbd5 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xca5b=['mail','chat','fax','sms','openchannel','%s%s','Pause','getTeams','Team','addTeams','getChatQueues','Chat','getMailQueues','setDataValue','Mail','Sms','getWhatsappQueues','Whatsapp','getFaxQueues','Fax','getOpenchannelQueues','Openchannel','transaction','getDataValue','removeTeams','Voice','getSmsQueues','flatten','removeAgent','Queue:remove','getLists','getAgents','values','You\x20can\x27t\x20delete\x20yourself','addChatInteractions','removeChatInteractions','isArray','user_has_chat_interactions:remove','addMailInteractions','user_has_mail_interactions:save','removeMailInteractions','addFaxInteractions','removeFaxInteractions','user_has_fax_interactions:remove','addSmsInteractions','user_has_sms_interactions:save','removeSmsInteractions','user_has_sms_interactions:remove','addOpenchannelInteractions','user_has_openchannel_interactions:save','removeOpenchannelInteractions','user_has_openchannel_interactions:remove','addWhatsappInteractions','removeWhatsappInteractions','getVoicePrefixes','VoicePrefix','FaxAccount','getFaxAccounts','addFaxAccounts','removeFaxAccounts','getMailAccounts','MailAccount','addMailAccounts','addOpenchannelAccounts','removeOpenchannelAccounts','getSmsAccounts','SmsAccount','addSmsAccounts','removeSmsAccounts','getChatWebsites','ChatWebsite','addChatWebsites','removeChatWebsites','getWhatsappAccounts','WhatsappAccount','removeWhatsappAccounts','getSquareProjects','SquareProject','addSquareProjects','removeSquareProjects','getScheduledCalls','CmHopper','$and','$or','$gt','$gte','$lt','$ne','$eq','$not','$between','$in','$notIn','$like','$iLike','$notILike','$overlap','$contains','$contained','firstName','lastName','Contact','dialActive','VoiceQueue','getApiKey','retrieveApiKey','token','No\x20API\x20access\x20key\x20found!','You\x20don\x27t\x20have\x20sufficient\x20privileges\x20to\x20access\x20this\x20resource.','createApiKey','generateApiKey','iat','nonce','removeApiKey','apiKeyNonce','apiKeyIat','API\x20key\x20not\x20available','Unable\x20to\x20retrieve\x20the\x20current\x20user','html-pdf','fast-json-patch','request-promise','moment','bluebird','path','sox','to-csv','ejs','lodash','crypto','jsforce','desk.js','ioredis','../../components/auth/service','../../config/license/hardware','../../config/logger','../../config/utils','../../config/license/util','../../mysqldb','defaults','localhost','socket.io-emitter','redis','./user.socket','register','client','http','request','then','User,\x20%s,\x20%s','request\x20sent','debug','User,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','end','count','offset','limit','set','Content-Range','json','reject','save','destroy','get','role','admin','Users','user','Agents','telephone','filter','ignore','map','value','includes','find','name','UserProfileResource','status','stack','send','index','User','rawAttributes','fieldName','key','differenceBy','password','keys','query','filters','intersection','attributes','fields','length','model','hasOwnProperty','nolimit','order','sort','where','merge','VIRTUAL','sequelize','lower','col','options','includeAll','include','findAll','rows','show','salt','update','body','params','describe','addContacts','ids','omit','internal','Setting','securePassword','validatePasswordPattern','max','min_internal','isNil','QueryTypes','SELECT','from','voicemail','mailbox','VoiceMail','email','agent','permissions','101','102','105','106','107','108','100','114','Unauthorized','Unauthorized.\x20You\x20must\x20be\x20an\x20administrator\x20in\x20order\x20to\x20create\x20an\x20user','Unauthorized.\x20You\x20must\x20be\x20an\x20administrator\x20in\x20order\x20to\x20create\x20another\x20administrator','create','UserProfileSection','Telephones','userProfileId','autoAssociation','bulkCreate','some','Unauthorized.\x20You\x20must\x20be\x20an\x20administrator\x20in\x20order\x20to\x20create\x20an\x20administrator','checkUserLimits','push','all','isEmpty','compact','newPassword','ValidationError','Invalid\x20body\x20format.\x20Use\x20oldPassword\x20and\x20newPassword','authenticate','Sequelize','Wrong\x20credentials','Invalid\x20body\x20format.\x20Use\x20newPassword','findOne','enforcePasswordHistory','previousPasswords','validatePasswordHistory','updatePasswordsHistory','addQueues','channel','online','voicePause','isValidChannel','Unknown\x20channel','add','Queues','penalty','spread','capitalize','toLowerCase','QueueId','Queue:save','voice','format','SIP/%s','each','UserVoiceQueueRt','upsert','removeQueues','emit','addAvatar','userpic','filename','getAvatar','join','download','root','server/files/images/','getContacts','CmContact','pick','CmList','List','Tag','color','tag','getQueues','Unknown\x20role','Queue','getVoiceQueuesRt','ChatGroup','getGroups','getRecordings','VoiceRecording','UserId','getScreenRecordings','ScreenRecording','getChatInteractions','ChatInteraction','getOpenchannelInteractions','OpenchannelInteraction','getMailInteractions','MailInteraction','getSmsInteractions','SmsInteraction','getFaxInteractions','getWhatsappInteractions','login','phone','mobile','interface','LOCAL/%s@from-sip/n','intrf','user:forcelogout','headers','x-forwarded-for','remoteAddress','connection','socket','User\x20not\x20found\x20or\x20not\x20allowed\x20to\x20perform\x20login\x20method','getVoiceQueues','loginInPause','MemberReport','forEach','YYYY-MM-DD\x20HH:mm:ss','getChannels','LOGIN','device','PAUSE','concat','LOGININPAUSE','resolve','logout','pause','QueuePause','updateAttributes','DEFAULT\x20PAUSE','type','unpause','mailPause','faxPause','openchannelPause','smsPause','pauseType','lastPauseAt','manual'];(function(_0x5e392b,_0x52366b){var _0x4b8457=function(_0x3c7727){while(--_0x3c7727){_0x5e392b['push'](_0x5e392b['shift']());}};_0x4b8457(++_0x52366b);}(_0xca5b,0x1ed));var _0xbca5=function(_0x331c72,_0x5a6428){_0x331c72=_0x331c72-0x0;var _0x2fe82b=_0xca5b[_0x331c72];return _0x2fe82b;};'use strict';var pdf=require(_0xbca5('0x0'));var emlformat=require('eml-format');var rimraf=require('rimraf');var zipdir=require('zip-dir');var jsonpatch=require(_0xbca5('0x1'));var rp=require(_0xbca5('0x2'));var moment=require(_0xbca5('0x3'));var BPromise=require(_0xbca5('0x4'));var Mustache=require('mustache');var util=require('util');var path=require(_0xbca5('0x5'));var sox=require(_0xbca5('0x6'));var csv=require(_0xbca5('0x7'));var ejs=require(_0xbca5('0x8'));var fs=require('fs');var _=require(_0xbca5('0x9'));var squel=require('squel');var crypto=require(_0xbca5('0xa'));var jsforce=require(_0xbca5('0xb'));var deskjs=require(_0xbca5('0xc'));var toCsv=require(_0xbca5('0x7'));var querystring=require('querystring');var Papa=require('papaparse');var Redis=require(_0xbca5('0xd'));var authService=require(_0xbca5('0xe'));var qs=require('../../components/parsers/qs');var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xbca5('0xf'));var logger=require(_0xbca5('0x10'))('api');var utils=require(_0xbca5('0x11'));var config=require('../../config/environment');var licenseUtil=require(_0xbca5('0x12'));var db=require(_0xbca5('0x13'))['db'];config['redis']=_[_0xbca5('0x14')](config['redis'],{'host':_0xbca5('0x15'),'port':0x18eb});var socket=require(_0xbca5('0x16'))(new Redis(config[_0xbca5('0x17')]));require(_0xbca5('0x18'))[_0xbca5('0x19')](socket);var jayson=require('jayson/promise');var client=jayson[_0xbca5('0x1a')][_0xbca5('0x1b')]({'port':0x232a});function respondWithRpcPromise(_0x379565,_0x28b70f,_0x5189fb,_0x83dc7b){return new BPromise(function(_0x5a19ae,_0x1780e9){var _0x23fa33=_0x83dc7b||client;return _0x23fa33[_0xbca5('0x1c')](_0x379565,_0x5189fb)[_0xbca5('0x1d')](function(_0x22c4af){logger['info'](_0xbca5('0x1e'),_0x28b70f,_0xbca5('0x1f'));logger[_0xbca5('0x20')](_0xbca5('0x21'),_0x28b70f,_0xbca5('0x1f'),JSON[_0xbca5('0x22')](_0x22c4af));if(_0x22c4af[_0xbca5('0x23')]){if(_0x22c4af[_0xbca5('0x23')][_0xbca5('0x24')]===0x1f4){logger[_0xbca5('0x23')](_0xbca5('0x1e'),_0x28b70f,_0x22c4af['error'][_0xbca5('0x25')]);return _0x1780e9(_0x22c4af['error'][_0xbca5('0x25')]);}logger[_0xbca5('0x23')](_0xbca5('0x1e'),_0x28b70f,_0x22c4af[_0xbca5('0x23')][_0xbca5('0x25')]);return _0x5a19ae(_0x22c4af[_0xbca5('0x23')][_0xbca5('0x25')]);}else{logger['info'](_0xbca5('0x1e'),_0x28b70f,_0xbca5('0x1f'));_0x5a19ae(_0x22c4af[_0xbca5('0x26')]['message']);}})[_0xbca5('0x27')](function(_0x5c3ef6){logger[_0xbca5('0x23')](_0xbca5('0x1e'),_0x28b70f,_0x5c3ef6);_0x1780e9(_0x5c3ef6);});});}function respondWithStatusCode(_0x1ce33b,_0x30da3e){_0x30da3e=_0x30da3e||0xcc;return function(_0x44bfe4){if(_0x44bfe4){return _0x1ce33b['sendStatus'](_0x30da3e);}return _0x1ce33b['status'](_0x30da3e)[_0xbca5('0x28')]();};}function respondWithResult(_0x2b2e55,_0x4565ce){_0x4565ce=_0x4565ce||0xc8;return function(_0x429190){if(_0x429190){return _0x2b2e55['status'](_0x4565ce)['json'](_0x429190);}};}function respondWithFilteredResult(_0x41e2ec,_0x13a22e){return function(_0x591108){if(_0x591108){var _0x3f5e11=_0x591108[_0xbca5('0x29')],_0x217dee=_0x13a22e[_0xbca5('0x2a')],_0x249a99=_0x13a22e[_0xbca5('0x2a')]+_0x13a22e[_0xbca5('0x2b')],_0x1ea38a;if(_0x249a99>=_0x3f5e11){_0x249a99=_0x3f5e11;_0x1ea38a=0xc8;}else{_0x1ea38a=0xce;}_0x41e2ec['status'](_0x1ea38a);return _0x41e2ec[_0xbca5('0x2c')](_0xbca5('0x2d'),_0x217dee+'-'+_0x249a99+'/'+_0x3f5e11)[_0xbca5('0x2e')](_0x591108);}return null;};}function patchUpdates(_0x4f66a){return function(_0x20476c){try{jsonpatch['apply'](_0x20476c,_0x4f66a,!![]);}catch(_0x4a4ffc){return BPromise[_0xbca5('0x2f')](_0x4a4ffc);}return _0x20476c[_0xbca5('0x30')]();};}function saveUpdates(_0x2c9c3f,_0x454319){return function(_0x4991ef){if(_0x4991ef){return _0x4991ef['update'](_0x2c9c3f)[_0xbca5('0x1d')](function(_0xbda3a9){return _0xbda3a9;});}return null;};}function removeEntity(_0x295cbf,_0x5f23f4){return function(_0x5a8cd7){if(_0x5a8cd7){return _0x5a8cd7[_0xbca5('0x31')]()[_0xbca5('0x1d')](function(){var _0x50eedd=_0x5a8cd7[_0xbca5('0x32')]({'plain':!![]});if(_0x50eedd[_0xbca5('0x33')]===_0xbca5('0x34'))return;var _0x29867e=[{'name':_0xbca5('0x35'),'value':_0xbca5('0x36'),'ignore':!![]},{'name':_0xbca5('0x37'),'value':'agent','ignore':![]},{'name':'Telephones','value':_0xbca5('0x38'),'ignore':![]}];var _0x218c61=_(_0x29867e)[_0xbca5('0x39')](_0xbca5('0x3a'))[_0xbca5('0x3b')]('value')[_0xbca5('0x3c')]();if(_[_0xbca5('0x3d')](_0x218c61,_0x50eedd[_0xbca5('0x33')])){return;}var _0x1a50a7=_[_0xbca5('0x3e')](_0x29867e,[_0xbca5('0x3c'),_0x50eedd[_0xbca5('0x33')]])[_0xbca5('0x3f')];return db[_0xbca5('0x40')]['destroy']({'where':{'type':_0x1a50a7,'resourceId':_0x50eedd['id']}})[_0xbca5('0x1d')](function(){return _0x5a8cd7;});})[_0xbca5('0x1d')](function(){_0x295cbf[_0xbca5('0x41')](0xcc)[_0xbca5('0x28')]();});}};}function handleEntityNotFound(_0x24fbe1,_0x294880){return function(_0x28654){if(!_0x28654){_0x24fbe1['sendStatus'](0x194);}return _0x28654;};}function handleError(_0xffd163,_0x241847){_0x241847=_0x241847||0x1f4;return function(_0x186511){logger[_0xbca5('0x23')](_0x186511[_0xbca5('0x42')]);if(_0x186511[_0xbca5('0x3f')]){delete _0x186511[_0xbca5('0x3f')];}_0xffd163[_0xbca5('0x41')](_0x241847)[_0xbca5('0x43')](_0x186511);};}exports[_0xbca5('0x44')]=function(_0x39c5e6,_0x2a1737){var _0x25f538={},_0x57cf71={},_0x24f06d={'count':0x0,'rows':[]};var _0x19edcc=_[_0xbca5('0x3b')](db[_0xbca5('0x45')][_0xbca5('0x46')],function(_0x46880){return{'name':_0x46880[_0xbca5('0x47')],'type':_0x46880['type'][_0xbca5('0x48')]};});_0x57cf71['model']=_[_0xbca5('0x49')](_[_0xbca5('0x3b')](_0x19edcc,'name'),[_0xbca5('0x4a'),'salt']);_0x57cf71['query']=_[_0xbca5('0x4b')](_0x39c5e6[_0xbca5('0x4c')]);_0x57cf71[_0xbca5('0x4d')]=_[_0xbca5('0x4e')](_0x57cf71['model'],_0x57cf71[_0xbca5('0x4c')]);_0x25f538[_0xbca5('0x4f')]=_['intersection'](_0x57cf71['model'],qs[_0xbca5('0x50')](_0x39c5e6[_0xbca5('0x4c')][_0xbca5('0x50')]));_0x25f538[_0xbca5('0x4f')]=_0x25f538[_0xbca5('0x4f')][_0xbca5('0x51')]?_0x25f538[_0xbca5('0x4f')]:_0x57cf71[_0xbca5('0x52')];if(!_0x39c5e6[_0xbca5('0x4c')][_0xbca5('0x53')](_0xbca5('0x54'))){_0x25f538[_0xbca5('0x2b')]=qs['limit'](_0x39c5e6[_0xbca5('0x4c')][_0xbca5('0x2b')]);_0x25f538['offset']=qs[_0xbca5('0x2a')](_0x39c5e6[_0xbca5('0x4c')]['offset']);}_0x25f538[_0xbca5('0x55')]=qs[_0xbca5('0x56')](_0x39c5e6['query']['sort']);_0x25f538[_0xbca5('0x57')]=qs[_0xbca5('0x4d')](_['pick'](_0x39c5e6[_0xbca5('0x4c')],_0x57cf71['filters']),_0x19edcc);if(_0x39c5e6[_0xbca5('0x4c')]['filter']){_0x25f538[_0xbca5('0x57')]=_[_0xbca5('0x58')](_0x25f538[_0xbca5('0x57')],{'$or':_['map'](_0x19edcc,function(_0x1a18d8){if(_0x1a18d8['type']!==_0xbca5('0x59')){return db[_0xbca5('0x5a')][_0xbca5('0x57')](db[_0xbca5('0x5a')]['fn'](_0xbca5('0x5b'),db[_0xbca5('0x5a')][_0xbca5('0x5c')](_0x1a18d8['name'])),{'$like':db['sequelize']['fn'](_0xbca5('0x5b'),'%'+_0x39c5e6[_0xbca5('0x4c')][_0xbca5('0x39')]+'%')});}})});}_0x25f538=_[_0xbca5('0x58')]({},_0x25f538,_0x39c5e6[_0xbca5('0x5d')]);var _0xa0d6f3={'where':_0x25f538[_0xbca5('0x57')]};return db[_0xbca5('0x45')][_0xbca5('0x29')](_0xa0d6f3)[_0xbca5('0x1d')](function(_0x331233){_0x24f06d[_0xbca5('0x29')]=_0x331233;if(_0x39c5e6[_0xbca5('0x4c')][_0xbca5('0x5e')]){_0x25f538[_0xbca5('0x5f')]=[{'all':!![]}];}return db[_0xbca5('0x45')][_0xbca5('0x60')](_0x25f538);})[_0xbca5('0x1d')](function(_0x334bd3){_0x24f06d[_0xbca5('0x61')]=_0x334bd3;return _0x24f06d;})['then'](respondWithFilteredResult(_0x2a1737,_0x25f538))[_0xbca5('0x27')](handleError(_0x2a1737,null));};exports[_0xbca5('0x62')]=function(_0x1d7a55,_0x3d0440){var _0x5149d9={'raw':![],'where':{'id':_0x1d7a55['params']['id']}},_0x2fde69={};_0x2fde69[_0xbca5('0x52')]=_[_0xbca5('0x49')](_[_0xbca5('0x4b')](db['User']['rawAttributes']),['password',_0xbca5('0x63')]);_0x2fde69[_0xbca5('0x4c')]=_['keys'](_0x1d7a55[_0xbca5('0x4c')]);_0x2fde69['filters']=_[_0xbca5('0x4e')](_0x2fde69[_0xbca5('0x52')],_0x2fde69['query']);_0x5149d9['attributes']=_[_0xbca5('0x4e')](_0x2fde69[_0xbca5('0x52')],qs[_0xbca5('0x50')](_0x1d7a55[_0xbca5('0x4c')][_0xbca5('0x50')]));_0x5149d9['attributes']=_0x5149d9[_0xbca5('0x4f')][_0xbca5('0x51')]?_0x5149d9['attributes']:_0x2fde69[_0xbca5('0x52')];if(_0x1d7a55['query'][_0xbca5('0x5e')]){_0x5149d9['include']=[{'all':!![]}];}_0x5149d9=_[_0xbca5('0x58')]({},_0x5149d9,_0x1d7a55[_0xbca5('0x5d')]);return db[_0xbca5('0x45')][_0xbca5('0x3e')](_0x5149d9)['then'](handleEntityNotFound(_0x3d0440,null))[_0xbca5('0x1d')](respondWithResult(_0x3d0440,null))[_0xbca5('0x27')](handleError(_0x3d0440,null));};exports[_0xbca5('0x64')]=function(_0x44c14c,_0x25d81a){if(_0x44c14c['body']['id']){delete _0x44c14c[_0xbca5('0x65')]['id'];}delete _0x44c14c[_0xbca5('0x65')][_0xbca5('0x33')];return db['User']['find']({'where':{'id':_0x44c14c[_0xbca5('0x66')]['id']}})['then'](handleEntityNotFound(_0x25d81a,null))[_0xbca5('0x1d')](saveUpdates(_0x44c14c[_0xbca5('0x65')],null))[_0xbca5('0x1d')](respondWithResult(_0x25d81a,null))[_0xbca5('0x27')](handleError(_0x25d81a,null));};exports[_0xbca5('0x67')]=function(_0x15b300,_0x1cf151){return db[_0xbca5('0x45')]['describe']()[_0xbca5('0x1d')](respondWithResult(_0x1cf151,null))[_0xbca5('0x27')](handleError(_0x1cf151,null));};exports[_0xbca5('0x68')]=function(_0x5b7cd1,_0x3ba85d,_0x1bfcca){return db[_0xbca5('0x45')]['find']({'where':{'id':_0x5b7cd1[_0xbca5('0x66')]['id']}})['then'](handleEntityNotFound(_0x3ba85d,null))['then'](function(_0x13217c){if(_0x13217c){return _0x13217c[_0xbca5('0x68')](_0x5b7cd1[_0xbca5('0x65')][_0xbca5('0x69')],_[_0xbca5('0x6a')](_0x5b7cd1[_0xbca5('0x65')],[_0xbca5('0x69'),'id'])||{});}})['then'](respondWithResult(_0x3ba85d,null))[_0xbca5('0x27')](handleError(_0x3ba85d,null));};function validateUser(_0x17bb4f){return new BPromise(function(_0x19a208,_0xdb07e5){if(_0x17bb4f[_0xbca5('0x6b')])return _0x19a208(_0x17bb4f);return db[_0xbca5('0x6c')]['findById'](0x1)[_0xbca5('0x1d')](function(_0x596dd9){if(_0x596dd9[_0xbca5('0x6d')])authService[_0xbca5('0x6e')](_0x17bb4f[_0xbca5('0x4a')]);db[_0xbca5('0x45')][_0xbca5('0x6f')]('internal')[_0xbca5('0x1d')](function(_0x43ebaa){if(_['isNil'](_0x43ebaa)){_0x17bb4f['internal']=_0x596dd9[_0xbca5('0x70')]||0x1;return;}if(_[_0xbca5('0x71')](_0x596dd9[_0xbca5('0x70')])||_0x596dd9['min_internal']===_0x43ebaa){_0x17bb4f['internal']=_0x43ebaa+0x1;return;}if(_0x596dd9[_0xbca5('0x70')]>_0x43ebaa){_0x17bb4f[_0xbca5('0x6b')]=_0x596dd9[_0xbca5('0x70')];return;}return db[_0xbca5('0x5a')][_0xbca5('0x4c')]('select\x20(select\x20IFNULL(max(internal)+1,1)\x20from\x20users\x20where\x20internal\x20<\x20md.internal)\x20as\x20\x27from\x27,\x20md.internal\x20-\x201\x20as\x20\x27to\x27\x20from\x20users\x20md\x20where\x20md.internal\x20!=\x201\x20and\x20not\x20exists\x20(select\x201\x20from\x20users\x20md2\x20where\x20md2.internal\x20=\x20md.internal\x20-\x201)',{'type':db['sequelize'][_0xbca5('0x72')][_0xbca5('0x73')]})['then'](function(_0x2d7bc6){if(_0x2d7bc6&&_0x2d7bc6[_0xbca5('0x51')]){for(var _0x26573f=0x0,_0x23d30b=_0x2d7bc6['length'];_0x26573f<_0x23d30b&&_[_0xbca5('0x71')](_0x17bb4f['internal']);_0x26573f++){if(_0x596dd9[_0xbca5('0x70')]<=_0x2d7bc6[_0x26573f][_0xbca5('0x74')]){_0x17bb4f[_0xbca5('0x6b')]=_0x2d7bc6[_0x26573f]['from'];}else if(_0x596dd9['min_internal']>_0x2d7bc6[_0x26573f][_0xbca5('0x74')]&&_0x596dd9[_0xbca5('0x70')]<=_0x2d7bc6[_0x26573f]['to']){_0x17bb4f[_0xbca5('0x6b')]=_0x596dd9[_0xbca5('0x70')];}}}if(_[_0xbca5('0x71')](_0x17bb4f[_0xbca5('0x6b')])){_0x17bb4f['internal']=_0x43ebaa+0x1;}return _0x19a208(_0x17bb4f);});});})[_0xbca5('0x27')](function(_0x15f682){_0xdb07e5(_0x15f682);});});}function updateUser(_0x5eb5d9){return new BPromise(function(_0x304cac,_0xa2f7e5){try{if(_0x5eb5d9[_0xbca5('0x75')]){_0x5eb5d9[_0xbca5('0x76')]=_0x5eb5d9['internal'];_0x5eb5d9[_0xbca5('0x77')]={'mailbox':_0x5eb5d9[_0xbca5('0x6b')],'password':_0x5eb5d9[_0xbca5('0x4a')],'fullname':_0x5eb5d9['fullname'],'email':_0x5eb5d9[_0xbca5('0x78')]};}if(_0x5eb5d9[_0xbca5('0x33')]===_0xbca5('0x79')){if(!_0x5eb5d9[_0xbca5('0x7a')])_0x5eb5d9['permissions']=[_0xbca5('0x7b'),_0xbca5('0x7c'),'103','113','110','104',_0xbca5('0x7d'),_0xbca5('0x7e'),_0xbca5('0x7f'),_0xbca5('0x80'),'109',_0xbca5('0x81'),'111',_0xbca5('0x82')];}_0x304cac(_0x5eb5d9);}catch(_0x442952){_0xa2f7e5(_0x442952);}});}exports['create']=function(_0x20405c,_0x1ddad5){if(_0x20405c[_0xbca5('0x36')][_0xbca5('0x33')]===_0xbca5('0x79'))throw new Error(_0xbca5('0x83'));if(_0x20405c[_0xbca5('0x65')][_0xbca5('0x33')]===_0xbca5('0x36')&&_0x20405c['user'][_0xbca5('0x33')]!==_0xbca5('0x34')){throw new Error(_0xbca5('0x84'));}if(_0x20405c[_0xbca5('0x65')]['role']===_0xbca5('0x34')&&_0x20405c[_0xbca5('0x36')]['role']!=='admin'){throw new Error(_0xbca5('0x85'));}return licenseUtil['checkUserLimits']([_0x20405c[_0xbca5('0x65')]])[_0xbca5('0x1d')](function(){return validateUser(_0x20405c[_0xbca5('0x65')]);})['then'](function(_0x32dd57){return updateUser(_0x32dd57)[_0xbca5('0x1d')](function(_0x1f3795){if(_0x1f3795[_0xbca5('0x33')]==='admin'){_0x1f3795['settingsEnabled']=_0x20405c[_0xbca5('0x36')]['settingsEnabled'];delete _0x1f3795['userProfileId'];}return _0x1f3795;});})[_0xbca5('0x1d')](function(_0x2e79bd){return db[_0xbca5('0x45')][_0xbca5('0x86')](_0x2e79bd,{'include':[{'model':db[_0xbca5('0x77')],'as':'VoiceMail'}]});})['then'](function(_0x21e6e3){if(_0x20405c['body'][_0xbca5('0x33')]===_0xbca5('0x36'))return _0x21e6e3;if(_0x20405c['user']['role']!==_0xbca5('0x36'))return _0x21e6e3;return db[_0xbca5('0x87')][_0xbca5('0x3e')]({'where':{'name':_0x21e6e3[_0xbca5('0x33')]===_0xbca5('0x79')?_0xbca5('0x37'):_0xbca5('0x88'),'userProfileId':_0x20405c[_0xbca5('0x36')][_0xbca5('0x89')]},'raw':!![]})[_0xbca5('0x1d')](function(_0x490853){if(!_0x490853||_0x490853[_0xbca5('0x8a')]!=0x0)return _0x21e6e3;return db[_0xbca5('0x40')][_0xbca5('0x86')]({'name':_0x21e6e3[_0xbca5('0x3f')],'resourceId':_0x21e6e3['id'],'type':_0x490853['name'],'sectionId':_0x490853['id']},{})[_0xbca5('0x1d')](function(){return _0x21e6e3;});})[_0xbca5('0x27')](function(_0x2835fb){logger[_0xbca5('0x23')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x2835fb);throw _0x2835fb;});})[_0xbca5('0x1d')](respondWithResult(_0x1ddad5,0xc9))[_0xbca5('0x27')](handleError(_0x1ddad5,null));};exports[_0xbca5('0x8b')]=function(_0x5f8eb7,_0x265161){var _0x24e511=_0x5f8eb7[_0xbca5('0x65')];var _0x2bf95e=[];if(_0x5f8eb7['user'][_0xbca5('0x33')]==='agent')throw new Error(_0xbca5('0x83'));if(_['some'](_0x24e511,[_0xbca5('0x33'),'user'])&&_0x5f8eb7[_0xbca5('0x36')][_0xbca5('0x33')]!=='admin'){throw new Error(_0xbca5('0x84'));}if(_[_0xbca5('0x8c')](_0x24e511,[_0xbca5('0x33'),_0xbca5('0x34')])&&_0x5f8eb7[_0xbca5('0x36')][_0xbca5('0x33')]!=='admin'){throw new Error(_0xbca5('0x8d'));}return licenseUtil[_0xbca5('0x8e')](_0x24e511)[_0xbca5('0x1d')](function(){return validateUser(_0x24e511[0x0]);})[_0xbca5('0x1d')](function(){for(var _0x114d6e=0x1;_0x114d6e<_0x24e511[_0xbca5('0x51')];_0x114d6e++){var _0x2dcb8c=_0x24e511[_0x114d6e-0x1][_0xbca5('0x6b')];if(!_0x24e511[_0x114d6e][_0xbca5('0x6b')])_0x24e511[_0x114d6e][_0xbca5('0x6b')]=_0x2dcb8c+0x1;_0x2bf95e[_0xbca5('0x8f')](validateUser(_0x24e511[_0x114d6e]));}return BPromise['all'](_0x2bf95e);})['then'](function(){_0x2bf95e=[];for(var _0x4c8cdf=0x0;_0x4c8cdf<_0x24e511[_0xbca5('0x51')];_0x4c8cdf++){_0x2bf95e['push'](updateUser(_0x24e511[_0x4c8cdf]));}return BPromise[_0xbca5('0x90')](_0x2bf95e);})[_0xbca5('0x1d')](function(){return BPromise['each'](_0x24e511,function(_0x5aff2d){return db[_0xbca5('0x45')][_0xbca5('0x86')](_0x5aff2d,{'include':[{'model':db['VoiceMail'],'as':_0xbca5('0x77')}]})[_0xbca5('0x1d')](function(_0x564fa6){_0x5aff2d['id']=_0x564fa6['id'];return _0x5aff2d;});});})[_0xbca5('0x1d')](function(_0x51ac98){if(_0x5f8eb7[_0xbca5('0x65')][_0xbca5('0x33')]===_0xbca5('0x36'))return _0x51ac98;if(_0x5f8eb7['user'][_0xbca5('0x33')]!==_0xbca5('0x36'))return _0x51ac98;var _0x2430a4=_['some'](_0x51ac98,function(_0xe839a5){return _0xe839a5[_0xbca5('0x33')]===_0xbca5('0x79')||_0xe839a5[_0xbca5('0x33')]==='telephone';});if(!_0x2430a4)return _0x51ac98;return db[_0xbca5('0x87')][_0xbca5('0x60')]({'where':{'name':{'$or':[_0xbca5('0x37'),'Telephones']},'userProfileId':_0x5f8eb7['user'][_0xbca5('0x89')]},'raw':!![]})[_0xbca5('0x1d')](function(_0x473989){if(_[_0xbca5('0x91')](_0x473989)||!_[_0xbca5('0x8c')](_0x473989,[_0xbca5('0x8a'),0x0]))return _0x51ac98;_0x2bf95e=[];var _0x51c3b2=_(_0x473989)[_0xbca5('0x3b')](function(_0x2273b7){if(_0x2273b7[_0xbca5('0x8a')]===0x1)return;return _0x2273b7[_0xbca5('0x3f')]===_0xbca5('0x37')?_0xbca5('0x79'):_0xbca5('0x38');})[_0xbca5('0x92')]()[_0xbca5('0x3c')]();for(var _0x1d88e2=0x0;_0x1d88e2<_0x51ac98[_0xbca5('0x51')];_0x1d88e2++){if(!_['includes'](_0x51c3b2,_0x51ac98[_0x1d88e2]['role']))return;var _0x7f36b1=_0x51ac98[_0x1d88e2][_0xbca5('0x33')]===_0xbca5('0x79')?_0xbca5('0x37'):'Telephones';_0x2bf95e[_0xbca5('0x8f')](db[_0xbca5('0x40')][_0xbca5('0x86')]({'name':_0x51ac98[_0x1d88e2][_0xbca5('0x3f')],'resourceId':_0x51ac98[_0x1d88e2]['id'],'type':_0x7f36b1,'sectionId':_[_0xbca5('0x3e')](_0x473989,[_0xbca5('0x3f'),_0x7f36b1])['id']},{}));}return BPromise[_0xbca5('0x90')](_0x2bf95e);})[_0xbca5('0x1d')](respondWithResult(_0x265161,0xc9))[_0xbca5('0x27')](handleError(_0x265161,null));});};exports['changePassword']=function(_0x4c5dfb,_0xdfb8bb,_0x2dfe04){if(_0x4c5dfb['body']['id']){delete _0x4c5dfb[_0xbca5('0x65')]['id'];}return db[_0xbca5('0x45')]['find']({'where':{'id':_0x4c5dfb[_0xbca5('0x66')]['id']}})['then'](function(_0x3c2708){if(!_0x3c2708)return null;if(_0x3c2708['id']===_0x4c5dfb[_0xbca5('0x36')]['id']){if(!_0x4c5dfb[_0xbca5('0x65')]['oldPassword']||!_0x4c5dfb[_0xbca5('0x65')][_0xbca5('0x93')]){throw new db['Sequelize'][(_0xbca5('0x94'))](_0xbca5('0x95'));}if(!_0x3c2708[_0xbca5('0x96')](_0x4c5dfb[_0xbca5('0x65')]['oldPassword'])){throw new db[(_0xbca5('0x97'))][(_0xbca5('0x94'))](_0xbca5('0x98'));}if(_0x4c5dfb[_0xbca5('0x65')]['oldPassword']===_0x4c5dfb[_0xbca5('0x65')][_0xbca5('0x93')]){throw new db[(_0xbca5('0x97'))][(_0xbca5('0x94'))]('New\x20password\x20must\x20be\x20different\x20from\x20old\x20password');}}else if(_0x4c5dfb[_0xbca5('0x36')][_0xbca5('0x33')]===_0xbca5('0x34')){if(!_0x4c5dfb[_0xbca5('0x65')][_0xbca5('0x93')]){throw new db[(_0xbca5('0x97'))][(_0xbca5('0x94'))](_0xbca5('0x99'));}}else if(_0x4c5dfb[_0xbca5('0x36')][_0xbca5('0x33')]===_0xbca5('0x36')){if(!_0x4c5dfb[_0xbca5('0x65')]['newPassword']){throw new db[(_0xbca5('0x97'))]['ValidationError']('Invalid\x20body\x20format.\x20Use\x20newPassword');}if(_0x3c2708[_0xbca5('0x33')]!==_0xbca5('0x79')){throw new db[(_0xbca5('0x97'))][(_0xbca5('0x94'))](_0xbca5('0x83'));}}else{throw new db[(_0xbca5('0x97'))][(_0xbca5('0x94'))](_0xbca5('0x83'));}return _0x3c2708;})[_0xbca5('0x1d')](handleEntityNotFound(_0xdfb8bb,null))[_0xbca5('0x1d')](function(_0x49d774){return db[_0xbca5('0x6c')][_0xbca5('0x9a')]({'attributes':['id',_0xbca5('0x6d'),'enforcePasswordHistory','passwordHistoryLimit']})[_0xbca5('0x1d')](function(_0x2717da){if(_0x2717da[_0xbca5('0x6d')])authService[_0xbca5('0x6e')](_0x4c5dfb[_0xbca5('0x65')]['newPassword']);if(!_0x2717da[_0xbca5('0x9b')]||!_0x49d774[_0xbca5('0x9c')])return _0x49d774;authService[_0xbca5('0x9d')](_0x4c5dfb['body'][_0xbca5('0x93')],_0x49d774[_0xbca5('0x9c')],_0x2717da['passwordHistoryLimit']);return _0x49d774;})[_0xbca5('0x1d')](saveUpdates({'password':_0x4c5dfb[_0xbca5('0x65')]['newPassword'],'passwordResetAt':_0x4c5dfb[_0xbca5('0x36')]['id']==_0x4c5dfb['params']['id']?moment():null,'previousPasswords':authService[_0xbca5('0x9e')](_0x4c5dfb[_0xbca5('0x65')][_0xbca5('0x93')],_0x49d774[_0xbca5('0x9c')])},null));})[_0xbca5('0x1d')](respondWithResult(_0xdfb8bb,null))[_0xbca5('0x27')](handleError(_0xdfb8bb,null));};exports[_0xbca5('0x9f')]=function(_0x4480ad,_0x2bfc8a,_0x31414){var _0x35d660=_0x4480ad['body'][_0xbca5('0xa0')];return db[_0xbca5('0x45')][_0xbca5('0x3e')]({'where':{'id':_0x4480ad[_0xbca5('0x66')]['id']},'attributes':['id',_0xbca5('0x3f'),_0xbca5('0x33'),_0xbca5('0xa1'),'loginInPause',_0xbca5('0xa2'),'interface']})['then'](handleEntityNotFound(_0x2bfc8a,null))[_0xbca5('0x1d')](function(_0x543a46){if(_0x543a46){if(!utils[_0xbca5('0xa3')](_0x35d660)){throw new db[(_0xbca5('0x97'))]['ValidationError'](_0xbca5('0xa4'));}return _0x543a46[_0xbca5('0xa5')+_['capitalize'](_0x35d660['toLowerCase']())+_0xbca5('0xa6')](_0x4480ad[_0xbca5('0x65')][_0xbca5('0x69')],{'penalty':_0x4480ad['body'][_0xbca5('0xa7')]||0x0})[_0xbca5('0xa8')](function(_0x2dc4c9){for(var _0x4ebc11=0x0;_0x4ebc11<_0x4480ad['body'][_0xbca5('0x69')]['length'];_0x4ebc11+=0x1){var _0x2dfc8b={'UserId':_0x4480ad[_0xbca5('0x66')]['id']};_0x2dfc8b[_[_0xbca5('0xa9')](_0x35d660[_0xbca5('0xaa')]())+_0xbca5('0xab')]=_0x4480ad[_0xbca5('0x65')][_0xbca5('0x69')][_0x4ebc11];socket['emit']('user'+_[_0xbca5('0xa9')](_0x35d660['toLowerCase']())+_0xbca5('0xac'),_0x2dfc8b);}return _0x2dc4c9;})[_0xbca5('0x1d')](function(){if(_0x35d660===_0xbca5('0xad')){return db['VoiceQueue'][_0xbca5('0x60')]({'where':{'id':_0x4480ad[_0xbca5('0x65')][_0xbca5('0x69')]||[]},'raw':!![],'attributes':['id',_0xbca5('0x3f')]});}})[_0xbca5('0x1d')](function(_0x2a829f){var _0xa0518e=_0x543a46[_0xbca5('0x32')]({'plain':!![]});var _0x3223fc=[];if(_0x35d660===_0xbca5('0xad')&&_0xa0518e['role']===_0xbca5('0x79')&&_0xa0518e[_0xbca5('0xa1')]){for(var _0x3d5171=0x0;_0x3d5171<_0x2a829f[_0xbca5('0x51')];_0x3d5171+=0x1){_0x3223fc['push']({'membername':_0xa0518e[_0xbca5('0x3f')],'UserId':_0xa0518e['id'],'queue_name':_0x2a829f[_0x3d5171][_0xbca5('0x3f')],'VoiceQueueId':_0x2a829f[_0x3d5171]['id'],'interface':_[_0xbca5('0x71')](_0xa0518e['interface'])?util[_0xbca5('0xae')](_0xbca5('0xaf'),_0xa0518e['name']):_0xa0518e['interface'],'paused':_0xa0518e[_0xbca5('0xa2')]||![],'penalty':_0x4480ad[_0xbca5('0x65')][_0xbca5('0xa7')]||0x0});}return BPromise[_0xbca5('0xb0')](_0x3223fc,function(_0x5662cc){return db[_0xbca5('0xb1')][_0xbca5('0xb2')](_0x5662cc);});}return _0x543a46;});}})['then'](respondWithStatusCode(_0x2bfc8a,null))[_0xbca5('0x27')](handleError(_0x2bfc8a,null));};exports[_0xbca5('0xb3')]=function(_0x36a837,_0x3d8c75,_0x10e4a5){var _0x4ca0d1;return db[_0xbca5('0x45')][_0xbca5('0x3e')]({'where':{'id':_0x36a837[_0xbca5('0x66')]['id']},'attributes':['id',_0xbca5('0x3f'),_0xbca5('0x33')]})[_0xbca5('0x1d')](handleEntityNotFound(_0x3d8c75,null))['then'](function(_0x344ea1){if(_0x344ea1){_0x4ca0d1=_0x344ea1;if(!_0x36a837[_0xbca5('0x4c')]['channel']||!utils[_0xbca5('0xa3')](_0x36a837[_0xbca5('0x4c')][_0xbca5('0xa0')])){throw new db[(_0xbca5('0x97'))][(_0xbca5('0x94'))]('Unknown\x20channel');}return _0x344ea1['remove'+_[_0xbca5('0xa9')](_0x36a837[_0xbca5('0x4c')][_0xbca5('0xa0')]['toLowerCase']())+'Queues'](_0x36a837['query']['ids']);}})[_0xbca5('0x1d')](function(_0xabc945){for(var _0x42e16e=0x0;_0x42e16e<_0x36a837['query'][_0xbca5('0x69')][_0xbca5('0x51')];_0x42e16e+=0x1){var _0x2ea179={'UserId':_0x36a837[_0xbca5('0x66')]['id']};_0x2ea179[_[_0xbca5('0xa9')](_0x36a837[_0xbca5('0x4c')]['channel']['toLowerCase']())+'QueueId']=_0x36a837[_0xbca5('0x4c')][_0xbca5('0x69')][_0x42e16e];socket[_0xbca5('0xb4')](_0xbca5('0x36')+_[_0xbca5('0xa9')](_0x36a837['query']['channel'][_0xbca5('0xaa')]())+'Queue:remove',_0x2ea179);}return _0xabc945;})[_0xbca5('0x1d')](function(){if(_0x36a837[_0xbca5('0x4c')][_0xbca5('0xa0')]==='voice'){return db[_0xbca5('0xb1')][_0xbca5('0x31')]({'where':{'UserId':_0x36a837[_0xbca5('0x66')]['id'],'VoiceQueueId':_0x36a837[_0xbca5('0x4c')][_0xbca5('0x69')]},'individualHooks':!![]})[_0xbca5('0x1d')](function(){return _0x4ca0d1;});}return _0x4ca0d1;})[_0xbca5('0x1d')](respondWithStatusCode(_0x3d8c75,null))[_0xbca5('0x27')](handleError(_0x3d8c75,null));};exports[_0xbca5('0xb5')]=function(_0x2e52f8,_0x58f768,_0x3e4155){_0x2e52f8[_0xbca5('0x65')][_0xbca5('0xb6')]=_0x2e52f8['file'][_0xbca5('0xb7')];return db[_0xbca5('0x45')][_0xbca5('0x3e')]({'where':{'id':_0x2e52f8['params']['id']}})[_0xbca5('0x1d')](handleEntityNotFound(_0x58f768,null))[_0xbca5('0x1d')](saveUpdates(_0x2e52f8[_0xbca5('0x65')],null))[_0xbca5('0x1d')](respondWithResult(_0x58f768,null))['catch'](handleError(_0x58f768,null));};exports[_0xbca5('0xb8')]=function(_0x42e17c,_0x3c80a2,_0x3d7b58){var _0xae48bf=path[_0xbca5('0xb9')](config['root'],'server/files/images/logos/default_profile.png');return db['User']['find']({'where':{'id':_0x42e17c[_0xbca5('0x66')]['id']},'attributes':['id','userpic'],'raw':!![]})['then'](handleEntityNotFound(_0x3c80a2,null))['then'](function(_0x23276f){if(_0x23276f){if(_[_0xbca5('0x71')](_0x23276f['userpic'])){return _0x3c80a2[_0xbca5('0xba')](_0xae48bf);}else{if(!fs['existsSync'](path[_0xbca5('0xb9')](config[_0xbca5('0xbb')],_0xbca5('0xbc'),_0x23276f['userpic']))){return _0x3c80a2[_0xbca5('0xba')](_0xae48bf);}return _0x3c80a2[_0xbca5('0xba')](path[_0xbca5('0xb9')](config['root'],_0xbca5('0xbc'),_0x23276f[_0xbca5('0xb6')]));}}})['catch'](handleError(_0x3c80a2,null));};exports[_0xbca5('0xbd')]=function(_0x17fddb,_0x157100,_0x2d6fc7){var _0x6aeae4={};var _0x56c8d1={};var _0xc7a1e3;var _0x72d2eb;return db[_0xbca5('0x45')][_0xbca5('0x9a')]({'where':{'id':_0x17fddb['params']['id']}})[_0xbca5('0x1d')](handleEntityNotFound(_0x157100,null))[_0xbca5('0x1d')](function(_0x560a7c){if(_0x560a7c){_0xc7a1e3=_0x560a7c;_0x56c8d1[_0xbca5('0x52')]=_[_0xbca5('0x4b')](db[_0xbca5('0xbe')]['rawAttributes']);_0x56c8d1[_0xbca5('0x4c')]=_[_0xbca5('0x4b')](_0x17fddb['query']);_0x56c8d1['filters']=_[_0xbca5('0x4e')](_0x56c8d1[_0xbca5('0x52')],_0x56c8d1[_0xbca5('0x4c')]);_0x6aeae4['attributes']=_[_0xbca5('0x4e')](_0x56c8d1[_0xbca5('0x52')],qs[_0xbca5('0x50')](_0x17fddb[_0xbca5('0x4c')][_0xbca5('0x50')]));_0x6aeae4[_0xbca5('0x4f')]=_0x6aeae4[_0xbca5('0x4f')][_0xbca5('0x51')]?_0x6aeae4[_0xbca5('0x4f')]:_0x56c8d1['model'];_0x6aeae4['order']=qs[_0xbca5('0x56')](_0x17fddb[_0xbca5('0x4c')][_0xbca5('0x56')]);_0x6aeae4[_0xbca5('0x57')]=qs[_0xbca5('0x4d')](_[_0xbca5('0xbf')](_0x17fddb[_0xbca5('0x4c')],_0x56c8d1['filters']));if(_0x17fddb['query']['filter']){_0x6aeae4[_0xbca5('0x57')]=_['merge'](_0x6aeae4['where'],{'$or':_[_0xbca5('0x3b')](_0x6aeae4[_0xbca5('0x4f')],function(_0x362658){var _0x1edb2b={};_0x1edb2b[_0x362658]={'$like':'%'+_0x17fddb[_0xbca5('0x4c')][_0xbca5('0x39')]+'%'};return _0x1edb2b;})});}_0x6aeae4=_[_0xbca5('0x58')]({},_0x6aeae4,_0x17fddb['options']);return _0xc7a1e3[_0xbca5('0xbd')](_0x6aeae4);}})['then'](function(_0x3d230e){if(_0x3d230e){_0x72d2eb=_0x3d230e['length'];if(_0x17fddb['query']['hasOwnProperty'](_0xbca5('0x5e'))){_0x6aeae4[_0xbca5('0x5f')]=[{'model':db[_0xbca5('0xc0')],'as':_0xbca5('0xc1'),'required':![]},{'model':db[_0xbca5('0xc2')],'as':'Tags','attributes':['id','name',_0xbca5('0xc3')],'where':_0x17fddb['query'][_0xbca5('0xc4')]?{'id':_0x17fddb[_0xbca5('0x4c')][_0xbca5('0xc4')]}:undefined,'required':_0x17fddb[_0xbca5('0x4c')][_0xbca5('0xc4')]?!![]:![]}];}if(!_0x17fddb[_0xbca5('0x4c')][_0xbca5('0x53')](_0xbca5('0x54'))){_0x6aeae4[_0xbca5('0x2b')]=qs[_0xbca5('0x2b')](_0x17fddb[_0xbca5('0x4c')]['limit']);_0x6aeae4[_0xbca5('0x2a')]=qs[_0xbca5('0x2a')](_0x17fddb[_0xbca5('0x4c')][_0xbca5('0x2a')]);}return _0xc7a1e3[_0xbca5('0xbd')](_0x6aeae4);}})[_0xbca5('0x1d')](function(_0x471241){if(_0x471241){return _0x471241?{'count':_0x72d2eb,'rows':_0x471241}:null;}})[_0xbca5('0x1d')](respondWithResult(_0x157100,null))['catch'](handleError(_0x157100,null));};exports[_0xbca5('0xc5')]=function(_0x444ac5,_0x3a2765,_0x2738eb){var _0x40fe3f;var _0x47d163;var _0x40ab7f={};var _0x1b61a4;return db['User'][_0xbca5('0x9a')]({'where':{'id':_0x444ac5[_0xbca5('0x66')]['id']},'attributes':['id',_0xbca5('0x3f'),_0xbca5('0x33')]})[_0xbca5('0x1d')](handleEntityNotFound(_0x3a2765,null))[_0xbca5('0x1d')](function(_0x40c5af){if(!utils[_0xbca5('0xa3')](_0x444ac5[_0xbca5('0x4c')][_0xbca5('0xa0')])){throw new db['Sequelize'][(_0xbca5('0x94'))](_0xbca5('0xa4'));}_0x40fe3f=_0x40c5af;var _0x3f72cb={};_0x3f72cb[_0xbca5('0x52')]=_[_0xbca5('0x4b')](db[_['capitalize'](_0x444ac5['query'][_0xbca5('0xa0')])+'Queue'][_0xbca5('0x46')]);_0x3f72cb[_0xbca5('0x4c')]=_[_0xbca5('0x4b')](_0x444ac5[_0xbca5('0x4c')]);_0x3f72cb[_0xbca5('0x4d')]=_[_0xbca5('0x4e')](_0x3f72cb[_0xbca5('0x52')],_0x3f72cb[_0xbca5('0x4c')]);_0x40ab7f[_0xbca5('0x4f')]=_['intersection'](_0x3f72cb[_0xbca5('0x52')],qs[_0xbca5('0x50')](_0x444ac5[_0xbca5('0x4c')]['fields']));_0x40ab7f[_0xbca5('0x4f')]=_0x40ab7f[_0xbca5('0x4f')][_0xbca5('0x51')]?_0x40ab7f['attributes']:_0x3f72cb[_0xbca5('0x52')];_0x40ab7f['order']=qs[_0xbca5('0x56')](_0x444ac5['query']['sort']);_0x40ab7f[_0xbca5('0x57')]=qs[_0xbca5('0x4d')](_['pick'](_0x444ac5['query'],_0x3f72cb[_0xbca5('0x4d')]));if(_0x444ac5['query'][_0xbca5('0x39')]){_0x40ab7f[_0xbca5('0x57')]=_[_0xbca5('0x58')](_0x40ab7f[_0xbca5('0x57')],{'$or':_[_0xbca5('0x3b')](_0x40ab7f[_0xbca5('0x4f')],function(_0x460f51){var _0x1dd5a8={};_0x1dd5a8[_0x460f51]={'$like':'%'+_0x444ac5[_0xbca5('0x4c')]['filter']+'%'};return _0x1dd5a8;})});}_0x40ab7f=_[_0xbca5('0x58')]({},_0x40ab7f,_0x444ac5[_0xbca5('0x5d')]);switch(_0x40fe3f['role']){case _0xbca5('0x34'):return db[_['capitalize'](_0x444ac5[_0xbca5('0x4c')]['channel'])+'Queue'][_0xbca5('0x60')](_0x40ab7f);case _0xbca5('0x36'):case _0xbca5('0x79'):return _0x40fe3f[_0xbca5('0x32')+_[_0xbca5('0xa9')](_0x444ac5[_0xbca5('0x4c')][_0xbca5('0xa0')])+_0xbca5('0xa6')](_0x40ab7f);default:throw new db['Sequelize']['ValidationError'](_0xbca5('0xc6'));}})[_0xbca5('0x1d')](function(_0x254fe5){_0x1b61a4=_0x254fe5[_0xbca5('0x51')];if(!_0x444ac5['query']['hasOwnProperty'](_0xbca5('0x54'))){_0x40ab7f[_0xbca5('0x2b')]=qs[_0xbca5('0x2b')](_0x444ac5[_0xbca5('0x4c')][_0xbca5('0x2b')]);_0x40ab7f[_0xbca5('0x2a')]=qs[_0xbca5('0x2a')](_0x444ac5[_0xbca5('0x4c')][_0xbca5('0x2a')]);}switch(_0x40fe3f['role']){case'admin':return db[_[_0xbca5('0xa9')](_0x444ac5[_0xbca5('0x4c')][_0xbca5('0xa0')])+_0xbca5('0xc7')]['findAll'](_0x40ab7f);case _0xbca5('0x36'):case _0xbca5('0x79'):return _0x40fe3f[_0xbca5('0x32')+_[_0xbca5('0xa9')](_0x444ac5[_0xbca5('0x4c')][_0xbca5('0xa0')])+'Queues'](_0x40ab7f);}})[_0xbca5('0x1d')](function(_0x526749){return{'count':_0x1b61a4,'rows':_0x526749};})[_0xbca5('0x1d')](respondWithResult(_0x3a2765,null))['catch'](handleError(_0x3a2765,null));};exports[_0xbca5('0xc8')]=function(_0x2d1ca6,_0x8b2002,_0x511cde){var _0x34138d={};var _0x2999f0={};var _0x27f64a;var _0x37363c;return db['User'][_0xbca5('0x9a')]({'where':{'id':_0x2d1ca6['params']['id']}})[_0xbca5('0x1d')](handleEntityNotFound(_0x8b2002,null))[_0xbca5('0x1d')](function(_0x4c0892){if(_0x4c0892){_0x27f64a=_0x4c0892;_0x2999f0[_0xbca5('0x52')]=_[_0xbca5('0x4b')](db[_0xbca5('0xb1')][_0xbca5('0x46')]);_0x2999f0[_0xbca5('0x4c')]=_[_0xbca5('0x4b')](_0x2d1ca6[_0xbca5('0x4c')]);_0x2999f0[_0xbca5('0x4d')]=_[_0xbca5('0x4e')](_0x2999f0[_0xbca5('0x52')],_0x2999f0[_0xbca5('0x4c')]);_0x34138d[_0xbca5('0x4f')]=_[_0xbca5('0x4e')](_0x2999f0['model'],qs['fields'](_0x2d1ca6[_0xbca5('0x4c')][_0xbca5('0x50')]));_0x34138d['attributes']=_0x34138d['attributes'][_0xbca5('0x51')]?_0x34138d['attributes']:_0x2999f0[_0xbca5('0x52')];_0x34138d[_0xbca5('0x55')]=qs[_0xbca5('0x56')](_0x2d1ca6[_0xbca5('0x4c')][_0xbca5('0x56')]);_0x34138d[_0xbca5('0x57')]=qs[_0xbca5('0x4d')](_['pick'](_0x2d1ca6[_0xbca5('0x4c')],_0x2999f0[_0xbca5('0x4d')]));if(_0x2d1ca6[_0xbca5('0x4c')][_0xbca5('0x39')]){_0x34138d['where']=_['merge'](_0x34138d[_0xbca5('0x57')],{'$or':_['map'](_0x34138d[_0xbca5('0x4f')],function(_0x1dddad){var _0x782a9e={};_0x782a9e[_0x1dddad]={'$like':'%'+_0x2d1ca6[_0xbca5('0x4c')][_0xbca5('0x39')]+'%'};return _0x782a9e;})});}_0x34138d=_[_0xbca5('0x58')]({},_0x34138d,_0x2d1ca6[_0xbca5('0x5d')]);return _0x27f64a[_0xbca5('0xc8')](_0x34138d);}})[_0xbca5('0x1d')](function(_0x812d03){if(_0x812d03){_0x37363c=_0x812d03['length'];if(!_0x2d1ca6[_0xbca5('0x4c')]['hasOwnProperty']('nolimit')){_0x34138d[_0xbca5('0x2b')]=qs[_0xbca5('0x2b')](_0x2d1ca6[_0xbca5('0x4c')][_0xbca5('0x2b')]);_0x34138d[_0xbca5('0x2a')]=qs['offset'](_0x2d1ca6[_0xbca5('0x4c')]['offset']);}return _0x27f64a[_0xbca5('0xc8')](_0x34138d);}})['then'](function(_0x4c1dc1){if(_0x4c1dc1){return _0x4c1dc1?{'count':_0x37363c,'rows':_0x4c1dc1}:null;}})['then'](respondWithResult(_0x8b2002,null))[_0xbca5('0x27')](handleError(_0x8b2002,null));};exports['getGroups']=function(_0x5557f8,_0x399c8c,_0x5f4141){var _0x1f8a63={};var _0x55c821={};var _0x1b478a;var _0x47891d;return db[_0xbca5('0x45')]['findOne']({'where':{'id':_0x5557f8[_0xbca5('0x66')]['id']}})[_0xbca5('0x1d')](handleEntityNotFound(_0x399c8c,null))[_0xbca5('0x1d')](function(_0x330bbc){if(_0x330bbc){_0x1b478a=_0x330bbc;_0x55c821['model']=_['keys'](db[_0xbca5('0xc9')][_0xbca5('0x46')]);_0x55c821['query']=_[_0xbca5('0x4b')](_0x5557f8['query']);_0x55c821[_0xbca5('0x4d')]=_[_0xbca5('0x4e')](_0x55c821[_0xbca5('0x52')],_0x55c821['query']);_0x1f8a63[_0xbca5('0x4f')]=_[_0xbca5('0x4e')](_0x55c821[_0xbca5('0x52')],qs[_0xbca5('0x50')](_0x5557f8['query']['fields']));_0x1f8a63[_0xbca5('0x4f')]=_0x1f8a63[_0xbca5('0x4f')][_0xbca5('0x51')]?_0x1f8a63[_0xbca5('0x4f')]:_0x55c821['model'];_0x1f8a63[_0xbca5('0x55')]=qs['sort'](_0x5557f8[_0xbca5('0x4c')]['sort']);_0x1f8a63[_0xbca5('0x57')]=qs['filters'](_['pick'](_0x5557f8[_0xbca5('0x4c')],_0x55c821[_0xbca5('0x4d')]));if(_0x5557f8['query'][_0xbca5('0x39')]){_0x1f8a63['where']=_[_0xbca5('0x58')](_0x1f8a63[_0xbca5('0x57')],{'$or':_[_0xbca5('0x3b')](_0x1f8a63[_0xbca5('0x4f')],function(_0x2c1156){var _0x5253d8={};_0x5253d8[_0x2c1156]={'$like':'%'+_0x5557f8[_0xbca5('0x4c')]['filter']+'%'};return _0x5253d8;})});}_0x1f8a63=_[_0xbca5('0x58')]({},_0x1f8a63,_0x5557f8['options']);return _0x1b478a[_0xbca5('0xca')](_0x1f8a63);}})[_0xbca5('0x1d')](function(_0x479626){if(_0x479626){_0x47891d=_0x479626['length'];if(!_0x5557f8[_0xbca5('0x4c')][_0xbca5('0x53')]('nolimit')){_0x1f8a63[_0xbca5('0x2b')]=qs[_0xbca5('0x2b')](_0x5557f8['query']['limit']);_0x1f8a63['offset']=qs[_0xbca5('0x2a')](_0x5557f8[_0xbca5('0x4c')][_0xbca5('0x2a')]);}return _0x1b478a[_0xbca5('0xca')](_0x1f8a63);}})[_0xbca5('0x1d')](function(_0x4892f9){if(_0x4892f9){return _0x4892f9?{'count':_0x47891d,'rows':_0x4892f9}:null;}})['then'](respondWithResult(_0x399c8c,null))['catch'](handleError(_0x399c8c,null));};exports[_0xbca5('0xcb')]=function(_0x18481d,_0x3d2800,_0x272f84){var _0x15e1da={'raw':!![],'where':{}};var _0x4aeb10={};var _0x3fae91={'count':0x0,'rows':[]};return db['User'][_0xbca5('0x9a')]({'where':{'id':_0x18481d['params']['id']}})[_0xbca5('0x1d')](handleEntityNotFound(_0x3d2800,null))[_0xbca5('0x1d')](function(_0x2d39a0){if(_0x2d39a0){_0x4aeb10['model']=_[_0xbca5('0x4b')](db[_0xbca5('0xcc')]['rawAttributes']);_0x4aeb10[_0xbca5('0x4c')]=_[_0xbca5('0x4b')](_0x18481d[_0xbca5('0x4c')]);_0x4aeb10[_0xbca5('0x4d')]=_[_0xbca5('0x4e')](_0x4aeb10[_0xbca5('0x52')],_0x4aeb10[_0xbca5('0x4c')]);_0x15e1da[_0xbca5('0x4f')]=_[_0xbca5('0x4e')](_0x4aeb10['model'],qs[_0xbca5('0x50')](_0x18481d['query'][_0xbca5('0x50')]));_0x15e1da[_0xbca5('0x4f')]=_0x15e1da['attributes'][_0xbca5('0x51')]?_0x15e1da[_0xbca5('0x4f')]:_0x4aeb10[_0xbca5('0x52')];if(!_0x18481d[_0xbca5('0x4c')][_0xbca5('0x53')]('nolimit')){_0x15e1da[_0xbca5('0x2b')]=qs[_0xbca5('0x2b')](_0x18481d[_0xbca5('0x4c')][_0xbca5('0x2b')]);_0x15e1da['offset']=qs[_0xbca5('0x2a')](_0x18481d[_0xbca5('0x4c')][_0xbca5('0x2a')]);}_0x15e1da[_0xbca5('0x55')]=qs['sort'](_0x18481d[_0xbca5('0x4c')][_0xbca5('0x56')]);_0x15e1da['where']=qs[_0xbca5('0x4d')](_['pick'](_0x18481d[_0xbca5('0x4c')],_0x4aeb10[_0xbca5('0x4d')]));_0x15e1da[_0xbca5('0x57')][_0xbca5('0xcd')]=_0x2d39a0['id'];if(_0x18481d[_0xbca5('0x4c')][_0xbca5('0x39')]){_0x15e1da[_0xbca5('0x57')]=_[_0xbca5('0x58')](_0x15e1da[_0xbca5('0x57')],{'$or':_['map'](_0x15e1da[_0xbca5('0x4f')],function(_0x44bfe9){var _0x1bbb86={};_0x1bbb86[_0x44bfe9]={'$like':'%'+_0x18481d['query'][_0xbca5('0x39')]+'%'};return _0x1bbb86;})});}_0x15e1da=_[_0xbca5('0x58')]({},_0x15e1da,_0x18481d['options']);return db[_0xbca5('0xcc')][_0xbca5('0x29')]({'where':_0x15e1da[_0xbca5('0x57')]})[_0xbca5('0x1d')](function(_0xcc1f03){_0x3fae91[_0xbca5('0x29')]=_0xcc1f03;if(_0x18481d[_0xbca5('0x4c')][_0xbca5('0x5e')]){_0x15e1da[_0xbca5('0x5f')]=[{'all':!![]}];}return db[_0xbca5('0xcc')][_0xbca5('0x60')](_0x15e1da);})[_0xbca5('0x1d')](function(_0x458239){_0x3fae91[_0xbca5('0x61')]=_0x458239;return _0x3fae91;});}})[_0xbca5('0x1d')](respondWithFilteredResult(_0x3d2800,_0x15e1da))[_0xbca5('0x27')](handleError(_0x3d2800,null));};exports[_0xbca5('0xce')]=function(_0x37ee9c,_0x3d2853,_0x542176){var _0x2575be={'raw':!![],'where':{}};var _0x4db54c={};var _0x88301e={'count':0x0,'rows':[]};return db[_0xbca5('0x45')][_0xbca5('0x9a')]({'where':{'id':_0x37ee9c['params']['id']}})['then'](handleEntityNotFound(_0x3d2853,null))[_0xbca5('0x1d')](function(_0x320dfd){if(_0x320dfd){_0x4db54c['model']=_[_0xbca5('0x4b')](db[_0xbca5('0xcf')][_0xbca5('0x46')]);_0x4db54c[_0xbca5('0x4c')]=_[_0xbca5('0x4b')](_0x37ee9c['query']);_0x4db54c[_0xbca5('0x4d')]=_[_0xbca5('0x4e')](_0x4db54c[_0xbca5('0x52')],_0x4db54c[_0xbca5('0x4c')]);_0x2575be[_0xbca5('0x4f')]=_[_0xbca5('0x4e')](_0x4db54c[_0xbca5('0x52')],qs[_0xbca5('0x50')](_0x37ee9c[_0xbca5('0x4c')][_0xbca5('0x50')]));_0x2575be[_0xbca5('0x4f')]=_0x2575be[_0xbca5('0x4f')][_0xbca5('0x51')]?_0x2575be[_0xbca5('0x4f')]:_0x4db54c[_0xbca5('0x52')];if(!_0x37ee9c[_0xbca5('0x4c')][_0xbca5('0x53')](_0xbca5('0x54'))){_0x2575be[_0xbca5('0x2b')]=qs[_0xbca5('0x2b')](_0x37ee9c[_0xbca5('0x4c')]['limit']);_0x2575be[_0xbca5('0x2a')]=qs['offset'](_0x37ee9c['query'][_0xbca5('0x2a')]);}_0x2575be[_0xbca5('0x55')]=qs['sort'](_0x37ee9c['query'][_0xbca5('0x56')]);_0x2575be[_0xbca5('0x57')]=qs[_0xbca5('0x4d')](_['pick'](_0x37ee9c['query'],_0x4db54c[_0xbca5('0x4d')]));_0x2575be['where']['UserId']=_0x320dfd['id'];if(_0x37ee9c[_0xbca5('0x4c')][_0xbca5('0x39')]){_0x2575be[_0xbca5('0x57')]=_[_0xbca5('0x58')](_0x2575be['where'],{'$or':_[_0xbca5('0x3b')](_0x2575be[_0xbca5('0x4f')],function(_0x2a4043){var _0x3fab4c={};_0x3fab4c[_0x2a4043]={'$like':'%'+_0x37ee9c[_0xbca5('0x4c')][_0xbca5('0x39')]+'%'};return _0x3fab4c;})});}_0x2575be=_['merge']({},_0x2575be,_0x37ee9c[_0xbca5('0x5d')]);return db[_0xbca5('0xcf')]['count']({'where':_0x2575be[_0xbca5('0x57')]})[_0xbca5('0x1d')](function(_0x2def59){_0x88301e[_0xbca5('0x29')]=_0x2def59;if(_0x37ee9c[_0xbca5('0x4c')][_0xbca5('0x5e')]){_0x2575be[_0xbca5('0x5f')]=[{'all':!![]}];}return db[_0xbca5('0xcf')][_0xbca5('0x60')](_0x2575be);})[_0xbca5('0x1d')](function(_0x4c0db3){_0x88301e[_0xbca5('0x61')]=_0x4c0db3;return _0x88301e;});}})['then'](respondWithFilteredResult(_0x3d2853,_0x2575be))[_0xbca5('0x27')](handleError(_0x3d2853,null));};exports[_0xbca5('0xd0')]=function(_0x3d90f5,_0x366e49,_0xf37831){var _0x5e26bd={};var _0x13f8fc={};var _0x17d8e1;var _0x3bc474;return db[_0xbca5('0x45')][_0xbca5('0x9a')]({'where':{'id':_0x3d90f5['params']['id']}})[_0xbca5('0x1d')](handleEntityNotFound(_0x366e49,null))[_0xbca5('0x1d')](function(_0x181adf){if(_0x181adf){_0x17d8e1=_0x181adf;_0x13f8fc['model']=_[_0xbca5('0x4b')](db[_0xbca5('0xd1')][_0xbca5('0x46')]);_0x13f8fc[_0xbca5('0x4c')]=_[_0xbca5('0x4b')](_0x3d90f5['query']);_0x13f8fc[_0xbca5('0x4d')]=_['intersection'](_0x13f8fc[_0xbca5('0x52')],_0x13f8fc[_0xbca5('0x4c')]);_0x5e26bd[_0xbca5('0x4f')]=_['intersection'](_0x13f8fc['model'],qs['fields'](_0x3d90f5[_0xbca5('0x4c')][_0xbca5('0x50')]));_0x5e26bd[_0xbca5('0x4f')]=_0x5e26bd[_0xbca5('0x4f')][_0xbca5('0x51')]?_0x5e26bd[_0xbca5('0x4f')]:_0x13f8fc[_0xbca5('0x52')];_0x5e26bd[_0xbca5('0x55')]=qs[_0xbca5('0x56')](_0x3d90f5[_0xbca5('0x4c')]['sort']);_0x5e26bd[_0xbca5('0x57')]=qs[_0xbca5('0x4d')](_[_0xbca5('0xbf')](_0x3d90f5['query'],_0x13f8fc[_0xbca5('0x4d')]));if(_0x3d90f5['query'][_0xbca5('0x39')]){_0x5e26bd[_0xbca5('0x57')]=_[_0xbca5('0x58')](_0x5e26bd[_0xbca5('0x57')],{'$or':_['map'](_0x5e26bd['attributes'],function(_0x285d28){var _0x14c468={};_0x14c468[_0x285d28]={'$like':'%'+_0x3d90f5['query'][_0xbca5('0x39')]+'%'};return _0x14c468;})});}_0x5e26bd=_[_0xbca5('0x58')]({},_0x5e26bd,_0x3d90f5[_0xbca5('0x5d')]);return _0x17d8e1[_0xbca5('0xd0')](_0x5e26bd);}})[_0xbca5('0x1d')](function(_0x4c6d05){if(_0x4c6d05){_0x3bc474=_0x4c6d05[_0xbca5('0x51')];if(!_0x3d90f5[_0xbca5('0x4c')][_0xbca5('0x53')](_0xbca5('0x54'))){_0x5e26bd[_0xbca5('0x2b')]=qs[_0xbca5('0x2b')](_0x3d90f5[_0xbca5('0x4c')][_0xbca5('0x2b')]);_0x5e26bd['offset']=qs[_0xbca5('0x2a')](_0x3d90f5[_0xbca5('0x4c')]['offset']);}return _0x17d8e1[_0xbca5('0xd0')](_0x5e26bd);}})[_0xbca5('0x1d')](function(_0x4fa239){if(_0x4fa239){return _0x4fa239?{'count':_0x3bc474,'rows':_0x4fa239}:null;}})[_0xbca5('0x1d')](respondWithResult(_0x366e49,null))[_0xbca5('0x27')](handleError(_0x366e49,null));};exports[_0xbca5('0xd2')]=function(_0x41f41c,_0x5a3e20,_0x34e1c4){var _0x3f1520={};var _0x1a47dc={};var _0x38c0c8;var _0x3da123;return db[_0xbca5('0x45')]['findOne']({'where':{'id':_0x41f41c[_0xbca5('0x66')]['id']}})[_0xbca5('0x1d')](handleEntityNotFound(_0x5a3e20,null))[_0xbca5('0x1d')](function(_0x1f3370){if(_0x1f3370){_0x38c0c8=_0x1f3370;_0x1a47dc[_0xbca5('0x52')]=_[_0xbca5('0x4b')](db[_0xbca5('0xd3')][_0xbca5('0x46')]);_0x1a47dc[_0xbca5('0x4c')]=_[_0xbca5('0x4b')](_0x41f41c['query']);_0x1a47dc[_0xbca5('0x4d')]=_[_0xbca5('0x4e')](_0x1a47dc[_0xbca5('0x52')],_0x1a47dc['query']);_0x3f1520['attributes']=_['intersection'](_0x1a47dc[_0xbca5('0x52')],qs[_0xbca5('0x50')](_0x41f41c['query'][_0xbca5('0x50')]));_0x3f1520[_0xbca5('0x4f')]=_0x3f1520[_0xbca5('0x4f')][_0xbca5('0x51')]?_0x3f1520[_0xbca5('0x4f')]:_0x1a47dc['model'];_0x3f1520[_0xbca5('0x55')]=qs[_0xbca5('0x56')](_0x41f41c['query'][_0xbca5('0x56')]);_0x3f1520[_0xbca5('0x57')]=qs['filters'](_['pick'](_0x41f41c['query'],_0x1a47dc['filters']));if(_0x41f41c[_0xbca5('0x4c')][_0xbca5('0x39')]){_0x3f1520[_0xbca5('0x57')]=_[_0xbca5('0x58')](_0x3f1520[_0xbca5('0x57')],{'$or':_[_0xbca5('0x3b')](_0x3f1520[_0xbca5('0x4f')],function(_0x459c60){var _0x59c71c={};_0x59c71c[_0x459c60]={'$like':'%'+_0x41f41c['query'][_0xbca5('0x39')]+'%'};return _0x59c71c;})});}_0x3f1520=_[_0xbca5('0x58')]({},_0x3f1520,_0x41f41c[_0xbca5('0x5d')]);return _0x38c0c8[_0xbca5('0xd2')](_0x3f1520);}})[_0xbca5('0x1d')](function(_0x416752){if(_0x416752){_0x3da123=_0x416752['length'];if(!_0x41f41c['query'][_0xbca5('0x53')](_0xbca5('0x54'))){_0x3f1520[_0xbca5('0x2b')]=qs[_0xbca5('0x2b')](_0x41f41c[_0xbca5('0x4c')][_0xbca5('0x2b')]);_0x3f1520[_0xbca5('0x2a')]=qs[_0xbca5('0x2a')](_0x41f41c[_0xbca5('0x4c')][_0xbca5('0x2a')]);}return _0x38c0c8[_0xbca5('0xd2')](_0x3f1520);}})['then'](function(_0x30e1bd){if(_0x30e1bd){return _0x30e1bd?{'count':_0x3da123,'rows':_0x30e1bd}:null;}})[_0xbca5('0x1d')](respondWithResult(_0x5a3e20,null))[_0xbca5('0x27')](handleError(_0x5a3e20,null));};exports[_0xbca5('0xd4')]=function(_0x3e4d54,_0x23c36b,_0x2d1e68){var _0x23aabc={'raw':!![],'where':{}};var _0x3499ab={};var _0x1a0db6={'count':0x0,'rows':[]};return db[_0xbca5('0x45')][_0xbca5('0x9a')]({'where':{'id':_0x3e4d54[_0xbca5('0x66')]['id']}})[_0xbca5('0x1d')](handleEntityNotFound(_0x23c36b,null))[_0xbca5('0x1d')](function(_0x560e18){if(_0x560e18){_0x3499ab[_0xbca5('0x52')]=_[_0xbca5('0x4b')](db[_0xbca5('0xd5')][_0xbca5('0x46')]);_0x3499ab[_0xbca5('0x4c')]=_[_0xbca5('0x4b')](_0x3e4d54[_0xbca5('0x4c')]);_0x3499ab[_0xbca5('0x4d')]=_[_0xbca5('0x4e')](_0x3499ab[_0xbca5('0x52')],_0x3499ab[_0xbca5('0x4c')]);_0x23aabc[_0xbca5('0x4f')]=_['intersection'](_0x3499ab[_0xbca5('0x52')],qs[_0xbca5('0x50')](_0x3e4d54[_0xbca5('0x4c')][_0xbca5('0x50')]));_0x23aabc[_0xbca5('0x4f')]=_0x23aabc['attributes'][_0xbca5('0x51')]?_0x23aabc['attributes']:_0x3499ab[_0xbca5('0x52')];if(!_0x3e4d54['query'][_0xbca5('0x53')](_0xbca5('0x54'))){_0x23aabc[_0xbca5('0x2b')]=qs[_0xbca5('0x2b')](_0x3e4d54[_0xbca5('0x4c')][_0xbca5('0x2b')]);_0x23aabc['offset']=qs[_0xbca5('0x2a')](_0x3e4d54[_0xbca5('0x4c')][_0xbca5('0x2a')]);}_0x23aabc['order']=qs[_0xbca5('0x56')](_0x3e4d54[_0xbca5('0x4c')][_0xbca5('0x56')]);_0x23aabc[_0xbca5('0x57')]=qs[_0xbca5('0x4d')](_[_0xbca5('0xbf')](_0x3e4d54[_0xbca5('0x4c')],_0x3499ab[_0xbca5('0x4d')]));_0x23aabc[_0xbca5('0x57')][_0xbca5('0xcd')]=_0x560e18['id'];if(_0x3e4d54['query'][_0xbca5('0x39')]){_0x23aabc[_0xbca5('0x57')]=_[_0xbca5('0x58')](_0x23aabc['where'],{'$or':_['map'](_0x23aabc[_0xbca5('0x4f')],function(_0x4412a6){var _0x515497={};_0x515497[_0x4412a6]={'$like':'%'+_0x3e4d54[_0xbca5('0x4c')]['filter']+'%'};return _0x515497;})});}_0x23aabc=_[_0xbca5('0x58')]({},_0x23aabc,_0x3e4d54[_0xbca5('0x5d')]);return db[_0xbca5('0xd5')]['count']({'where':_0x23aabc['where']})['then'](function(_0x198627){_0x1a0db6[_0xbca5('0x29')]=_0x198627;if(_0x3e4d54[_0xbca5('0x4c')][_0xbca5('0x5e')]){_0x23aabc[_0xbca5('0x5f')]=[{'all':!![]}];}return db[_0xbca5('0xd5')][_0xbca5('0x60')](_0x23aabc);})['then'](function(_0x2ec746){_0x1a0db6[_0xbca5('0x61')]=_0x2ec746;return _0x1a0db6;});}})[_0xbca5('0x1d')](respondWithFilteredResult(_0x23c36b,_0x23aabc))[_0xbca5('0x27')](handleError(_0x23c36b,null));};exports[_0xbca5('0xd6')]=function(_0x1350dd,_0x4c150a,_0x3a2fa1){var _0x3e9a6a={};var _0x5c288f={};var _0x19117d;var _0x5b187e;return db['User']['findOne']({'where':{'id':_0x1350dd['params']['id']}})[_0xbca5('0x1d')](handleEntityNotFound(_0x4c150a,null))[_0xbca5('0x1d')](function(_0x23aefc){if(_0x23aefc){_0x19117d=_0x23aefc;_0x5c288f[_0xbca5('0x52')]=_[_0xbca5('0x4b')](db[_0xbca5('0xd7')]['rawAttributes']);_0x5c288f[_0xbca5('0x4c')]=_['keys'](_0x1350dd['query']);_0x5c288f[_0xbca5('0x4d')]=_['intersection'](_0x5c288f[_0xbca5('0x52')],_0x5c288f[_0xbca5('0x4c')]);_0x3e9a6a[_0xbca5('0x4f')]=_[_0xbca5('0x4e')](_0x5c288f['model'],qs[_0xbca5('0x50')](_0x1350dd['query']['fields']));_0x3e9a6a[_0xbca5('0x4f')]=_0x3e9a6a[_0xbca5('0x4f')][_0xbca5('0x51')]?_0x3e9a6a[_0xbca5('0x4f')]:_0x5c288f[_0xbca5('0x52')];_0x3e9a6a[_0xbca5('0x55')]=qs[_0xbca5('0x56')](_0x1350dd[_0xbca5('0x4c')][_0xbca5('0x56')]);_0x3e9a6a[_0xbca5('0x57')]=qs[_0xbca5('0x4d')](_[_0xbca5('0xbf')](_0x1350dd[_0xbca5('0x4c')],_0x5c288f[_0xbca5('0x4d')]));if(_0x1350dd[_0xbca5('0x4c')][_0xbca5('0x39')]){_0x3e9a6a['where']=_[_0xbca5('0x58')](_0x3e9a6a[_0xbca5('0x57')],{'$or':_[_0xbca5('0x3b')](_0x3e9a6a[_0xbca5('0x4f')],function(_0x433265){var _0x128560={};_0x128560[_0x433265]={'$like':'%'+_0x1350dd[_0xbca5('0x4c')]['filter']+'%'};return _0x128560;})});}_0x3e9a6a=_[_0xbca5('0x58')]({},_0x3e9a6a,_0x1350dd[_0xbca5('0x5d')]);return _0x19117d[_0xbca5('0xd6')](_0x3e9a6a);}})[_0xbca5('0x1d')](function(_0x91b7ad){if(_0x91b7ad){_0x5b187e=_0x91b7ad[_0xbca5('0x51')];if(!_0x1350dd[_0xbca5('0x4c')][_0xbca5('0x53')](_0xbca5('0x54'))){_0x3e9a6a['limit']=qs[_0xbca5('0x2b')](_0x1350dd[_0xbca5('0x4c')][_0xbca5('0x2b')]);_0x3e9a6a[_0xbca5('0x2a')]=qs[_0xbca5('0x2a')](_0x1350dd[_0xbca5('0x4c')][_0xbca5('0x2a')]);}return _0x19117d['getSmsInteractions'](_0x3e9a6a);}})[_0xbca5('0x1d')](function(_0x1c3672){if(_0x1c3672){return _0x1c3672?{'count':_0x5b187e,'rows':_0x1c3672}:null;}})['then'](respondWithResult(_0x4c150a,null))['catch'](handleError(_0x4c150a,null));};exports[_0xbca5('0xd8')]=function(_0x568de0,_0xacd5b4,_0x4daa20){var _0x3a72bb={};var _0x5cb18c={};var _0x1e4fc8;var _0x2de048;return db['User'][_0xbca5('0x9a')]({'where':{'id':_0x568de0['params']['id']}})[_0xbca5('0x1d')](handleEntityNotFound(_0xacd5b4,null))[_0xbca5('0x1d')](function(_0x36f203){if(_0x36f203){_0x1e4fc8=_0x36f203;_0x5cb18c[_0xbca5('0x52')]=_[_0xbca5('0x4b')](db['FaxInteraction']['rawAttributes']);_0x5cb18c[_0xbca5('0x4c')]=_[_0xbca5('0x4b')](_0x568de0[_0xbca5('0x4c')]);_0x5cb18c[_0xbca5('0x4d')]=_[_0xbca5('0x4e')](_0x5cb18c[_0xbca5('0x52')],_0x5cb18c[_0xbca5('0x4c')]);_0x3a72bb[_0xbca5('0x4f')]=_['intersection'](_0x5cb18c[_0xbca5('0x52')],qs[_0xbca5('0x50')](_0x568de0[_0xbca5('0x4c')][_0xbca5('0x50')]));_0x3a72bb[_0xbca5('0x4f')]=_0x3a72bb[_0xbca5('0x4f')][_0xbca5('0x51')]?_0x3a72bb[_0xbca5('0x4f')]:_0x5cb18c[_0xbca5('0x52')];_0x3a72bb['order']=qs['sort'](_0x568de0[_0xbca5('0x4c')]['sort']);_0x3a72bb[_0xbca5('0x57')]=qs[_0xbca5('0x4d')](_[_0xbca5('0xbf')](_0x568de0[_0xbca5('0x4c')],_0x5cb18c['filters']));if(_0x568de0[_0xbca5('0x4c')]['filter']){_0x3a72bb[_0xbca5('0x57')]=_[_0xbca5('0x58')](_0x3a72bb[_0xbca5('0x57')],{'$or':_[_0xbca5('0x3b')](_0x3a72bb[_0xbca5('0x4f')],function(_0x329ec6){var _0x581ac5={};_0x581ac5[_0x329ec6]={'$like':'%'+_0x568de0[_0xbca5('0x4c')][_0xbca5('0x39')]+'%'};return _0x581ac5;})});}_0x3a72bb=_[_0xbca5('0x58')]({},_0x3a72bb,_0x568de0[_0xbca5('0x5d')]);return _0x1e4fc8[_0xbca5('0xd8')](_0x3a72bb);}})[_0xbca5('0x1d')](function(_0x226e09){if(_0x226e09){_0x2de048=_0x226e09[_0xbca5('0x51')];if(!_0x568de0['query'][_0xbca5('0x53')](_0xbca5('0x54'))){_0x3a72bb[_0xbca5('0x2b')]=qs[_0xbca5('0x2b')](_0x568de0[_0xbca5('0x4c')]['limit']);_0x3a72bb['offset']=qs['offset'](_0x568de0[_0xbca5('0x4c')]['offset']);}return _0x1e4fc8['getFaxInteractions'](_0x3a72bb);}})['then'](function(_0x3f29fa){if(_0x3f29fa){return _0x3f29fa?{'count':_0x2de048,'rows':_0x3f29fa}:null;}})[_0xbca5('0x1d')](respondWithResult(_0xacd5b4,null))[_0xbca5('0x27')](handleError(_0xacd5b4,null));};exports[_0xbca5('0xd9')]=function(_0x3fe2a7,_0x8f6445,_0x581835){var _0x15ba0d={};var _0xc18cfc={};var _0xe32181;var _0x37377e;return db[_0xbca5('0x45')][_0xbca5('0x9a')]({'where':{'id':_0x3fe2a7[_0xbca5('0x66')]['id']}})[_0xbca5('0x1d')](handleEntityNotFound(_0x8f6445,null))[_0xbca5('0x1d')](function(_0x1acf9a){if(_0x1acf9a){_0xe32181=_0x1acf9a;_0xc18cfc[_0xbca5('0x52')]=_[_0xbca5('0x4b')](db['WhatsappInteraction'][_0xbca5('0x46')]);_0xc18cfc[_0xbca5('0x4c')]=_[_0xbca5('0x4b')](_0x3fe2a7[_0xbca5('0x4c')]);_0xc18cfc[_0xbca5('0x4d')]=_['intersection'](_0xc18cfc[_0xbca5('0x52')],_0xc18cfc['query']);_0x15ba0d[_0xbca5('0x4f')]=_['intersection'](_0xc18cfc[_0xbca5('0x52')],qs[_0xbca5('0x50')](_0x3fe2a7[_0xbca5('0x4c')]['fields']));_0x15ba0d['attributes']=_0x15ba0d['attributes'][_0xbca5('0x51')]?_0x15ba0d[_0xbca5('0x4f')]:_0xc18cfc[_0xbca5('0x52')];_0x15ba0d[_0xbca5('0x55')]=qs[_0xbca5('0x56')](_0x3fe2a7['query'][_0xbca5('0x56')]);_0x15ba0d[_0xbca5('0x57')]=qs['filters'](_[_0xbca5('0xbf')](_0x3fe2a7[_0xbca5('0x4c')],_0xc18cfc['filters']));if(_0x3fe2a7[_0xbca5('0x4c')][_0xbca5('0x39')]){_0x15ba0d[_0xbca5('0x57')]=_[_0xbca5('0x58')](_0x15ba0d[_0xbca5('0x57')],{'$or':_[_0xbca5('0x3b')](_0x15ba0d[_0xbca5('0x4f')],function(_0xc0f7a){var _0x276967={};_0x276967[_0xc0f7a]={'$like':'%'+_0x3fe2a7[_0xbca5('0x4c')]['filter']+'%'};return _0x276967;})});}_0x15ba0d=_[_0xbca5('0x58')]({},_0x15ba0d,_0x3fe2a7[_0xbca5('0x5d')]);return _0xe32181[_0xbca5('0xd9')](_0x15ba0d);}})[_0xbca5('0x1d')](function(_0x6a66f7){if(_0x6a66f7){_0x37377e=_0x6a66f7[_0xbca5('0x51')];if(!_0x3fe2a7[_0xbca5('0x4c')][_0xbca5('0x53')](_0xbca5('0x54'))){_0x15ba0d[_0xbca5('0x2b')]=qs[_0xbca5('0x2b')](_0x3fe2a7[_0xbca5('0x4c')][_0xbca5('0x2b')]);_0x15ba0d[_0xbca5('0x2a')]=qs[_0xbca5('0x2a')](_0x3fe2a7[_0xbca5('0x4c')][_0xbca5('0x2a')]);}return _0xe32181[_0xbca5('0xd9')](_0x15ba0d);}})[_0xbca5('0x1d')](function(_0x287818){if(_0x287818){return _0x287818?{'count':_0x37377e,'rows':_0x287818}:null;}})[_0xbca5('0x1d')](respondWithResult(_0x8f6445,null))[_0xbca5('0x27')](handleError(_0x8f6445,null));};exports[_0xbca5('0xda')]=function(_0x272255,_0xcffdbc,_0x5bc072){var _0x5e1ae4;var _0x466422;var _0x4e5fb7;var _0xed9b9b=!_[_0xbca5('0x71')](_0x272255[_0xbca5('0x66')]['id'])?_0x272255[_0xbca5('0x66')]['id']:!_[_0xbca5('0x71')](_0x272255[_0xbca5('0x36')]['id'])?_0x272255[_0xbca5('0x36')]['id']:null;return db[_0xbca5('0x45')][_0xbca5('0x3e')]({'where':{'id':_0xed9b9b,'role':{'$or':[_0xbca5('0x34'),_0xbca5('0x36'),_0xbca5('0x79')]}},'attributes':['id',_0xbca5('0x3f'),_0xbca5('0xdb'),_0xbca5('0xdc'),_0xbca5('0x33'),'internal','loginInPause']})['then'](function(_0x328483){if(_0x328483){if(_0x328483[_0xbca5('0x33')]===_0xbca5('0x79')){_0x5e1ae4=_0x328483;if(_0x272255[_0xbca5('0x65')][_0xbca5('0xdd')]){_0x4e5fb7=util[_0xbca5('0xae')](_0xbca5('0xde'),_0x5e1ae4[_0x272255[_0xbca5('0x65')]['interface']]);}else if(_0x272255[_0xbca5('0x65')][_0xbca5('0xdf')]){_0x4e5fb7=util['format'](_0xbca5('0xaf'),_0x272255[_0xbca5('0x65')][_0xbca5('0xdf')]);}else{_0x4e5fb7=util[_0xbca5('0xae')]('SIP/%s',_0x5e1ae4['name']);}socket['to'](util[_0xbca5('0xae')]('user:%s',_0x5e1ae4['name']))[_0xbca5('0xb4')](_0xbca5('0xe0'),{'ip':_0x272255[_0xbca5('0xe1')][_0xbca5('0xe2')]||_0x272255['connection']['remoteAddress']||_0x272255['socket'][_0xbca5('0xe3')]||_0x272255[_0xbca5('0xe4')][_0xbca5('0xe5')]['remoteAddress']});return db[_0xbca5('0xb1')]['destroy']({'where':{'membername':_0x5e1ae4[_0xbca5('0x3f')]},'individualHooks':!![]});}}else{throw new db['Sequelize'][(_0xbca5('0x94'))](_0xbca5('0xe6'));}})['then'](function(){if(_0x5e1ae4){return _0x5e1ae4[_0xbca5('0xe7')]({'raw':!![]});}})[_0xbca5('0x1d')](function(_0x458627){if(_0x5e1ae4){var _0x72596f=[];if(_0x458627){_0x466422=_0x458627;if(_0x466422[_0xbca5('0x51')]){for(var _0x40b9ae=0x0;_0x40b9ae<_0x466422[_0xbca5('0x51')];_0x40b9ae++){_0x72596f[_0xbca5('0x8f')]({'membername':_0x5e1ae4[_0xbca5('0x3f')],'UserId':_0x5e1ae4['id'],'queue_name':_0x466422[_0x40b9ae][_0xbca5('0x3f')],'VoiceQueueId':_0x466422[_0x40b9ae]['id'],'interface':_0x4e5fb7,'paused':_0x5e1ae4[_0xbca5('0xe8')]||![],'penalty':_0x466422[_0x40b9ae]['UserVoiceQueue.penalty']||0x0});}return BPromise[_0xbca5('0xb0')](_0x72596f,function(_0xc4a55c){return db[_0xbca5('0xb1')]['upsert'](_0xc4a55c);});}}}})[_0xbca5('0x1d')](function(){if(_0x5e1ae4){return db[_0xbca5('0xe9')]['findAll']({'where':{'membername':_0x5e1ae4[_0xbca5('0x3f')],'exitAt':null}});}})[_0xbca5('0x1d')](function(_0x3a2378){if(_0x5e1ae4){var _0x105a7c=[];_0x3a2378[_0xbca5('0xea')](function(_0x57dcf3){_0x105a7c['push'](_0x57dcf3[_0xbca5('0x64')]({'exitAt':moment()[_0xbca5('0xae')](_0xbca5('0xeb'))}));});return BPromise['all'](_0x105a7c);}})['then'](function(){if(_0x5e1ae4){var _0x3e87f2=[];var _0x494ea2=[];var _0x5eb699=utils[_0xbca5('0xec')]();var _0x54b381={'membername':_0x5e1ae4[_0xbca5('0x3f')],'interface':_0x4e5fb7,'enterAt':moment()['format'](_0xbca5('0xeb')),'role':_0x5e1ae4[_0xbca5('0x33')],'internal':_0x5e1ae4[_0xbca5('0x6b')]};_0x5eb699[_0xbca5('0xea')](function(_0x225b9c){_0x3e87f2['push'](_[_0xbca5('0x58')]({'channel':_0x225b9c,'type':_0xbca5('0xed'),'data1':_0x272255['body'][_0xbca5('0xee')],'data2':_0x4e5fb7},_0x54b381));if(_0x5e1ae4[_0xbca5('0xe8')]){_0x494ea2[_0xbca5('0x8f')](_[_0xbca5('0x58')]({'channel':_0x225b9c,'type':_0xbca5('0xef'),'data1':'LOGININPAUSE'},_0x54b381));}});return db[_0xbca5('0xe9')][_0xbca5('0x8b')](_0x3e87f2[_0xbca5('0xf0')](_0x494ea2),{'individualHooks':!![]});}})[_0xbca5('0x1d')](function(){if(_0x5e1ae4){return _0x5e1ae4[_0xbca5('0x64')]({'online':!![],'lastLoginAt':moment()[_0xbca5('0xae')](_0xbca5('0xeb')),'voicePause':_0x5e1ae4[_0xbca5('0xe8')]||![],'mailPause':_0x5e1ae4[_0xbca5('0xe8')]||![],'chatPause':_0x5e1ae4['loginInPause']||![],'faxPause':_0x5e1ae4[_0xbca5('0xe8')]||![],'smsPause':_0x5e1ae4[_0xbca5('0xe8')]||![],'openchannelPause':_0x5e1ae4[_0xbca5('0xe8')]||![],'whatsappPause':_0x5e1ae4[_0xbca5('0xe8')]||![],'pauseType':_0x5e1ae4[_0xbca5('0xe8')]?_0xbca5('0xf1'):null,'interface':_0x4e5fb7,'lastPauseAt':moment()[_0xbca5('0xae')](_0xbca5('0xeb'))});}})[_0xbca5('0x1d')](function(_0x1911ce){if(_0x272255['isMiddleware']){return _0x5bc072();}else{return BPromise[_0xbca5('0xf2')](_0x1911ce)[_0xbca5('0x1d')](respondWithResult(_0xcffdbc,null));}})[_0xbca5('0x27')](handleError(_0xcffdbc,null));};exports[_0xbca5('0xf3')]=function(_0x59d6cb,_0xb5000d,_0x2cee23){var _0x24d7ab;return db[_0xbca5('0x45')]['find']({'where':{'id':_0x59d6cb['params']['id'],'role':'agent'},'attributes':['id',_0xbca5('0x3f'),_0xbca5('0x33')]})['then'](handleEntityNotFound(_0xb5000d,null))[_0xbca5('0x1d')](function(_0x3ef959){if(_0x3ef959){_0x24d7ab=_0x3ef959;return db[_0xbca5('0xb1')][_0xbca5('0x31')]({'where':{'membername':_0x24d7ab['name']},'individualHooks':!![]});}})[_0xbca5('0x1d')](function(){return db[_0xbca5('0xe9')][_0xbca5('0x60')]({'where':{'membername':_0x24d7ab[_0xbca5('0x3f')],'exitAt':null}});})[_0xbca5('0x1d')](function(_0x33dafc){var _0x47c292=[];_0x33dafc[_0xbca5('0xea')](function(_0x4c9cc4){_0x47c292[_0xbca5('0x8f')](_0x4c9cc4[_0xbca5('0x64')]({'exitAt':moment()[_0xbca5('0xae')](_0xbca5('0xeb'))}));});return BPromise['all'](_0x47c292);})[_0xbca5('0x1d')](function(){return _0x24d7ab[_0xbca5('0x64')]({'online':![],'lastLoginAt':null,'voicePause':![],'mailPause':![],'chatPause':![],'faxPause':![],'smsPause':![],'openchannelPause':![],'whatsappPause':![],'interface':null});})[_0xbca5('0x1d')](respondWithResult(_0xb5000d,null))[_0xbca5('0x27')](handleError(_0xb5000d,null));};exports[_0xbca5('0xf4')]=function(_0x412e80,_0x3e6b52,_0xd025c3){var _0x1f4e22;return db['UserVoiceQueueRt'][_0xbca5('0x64')]({'paused':0x1},{'where':{'UserId':_0x412e80[_0xbca5('0x66')]['id']},'individualHooks':!![]})[_0xbca5('0x1d')](function(){return db['User'][_0xbca5('0x3e')]({'where':{'id':_0x412e80[_0xbca5('0x66')]['id'],'role':_0xbca5('0x79')},'attributes':['id',_0xbca5('0x3f'),_0xbca5('0x33'),_0xbca5('0x6b'),'interface']});})[_0xbca5('0x1d')](handleEntityNotFound(_0x3e6b52,null))[_0xbca5('0x1d')](function(_0x50ea01){if(_0x50ea01){_0x1f4e22=_0x50ea01;return respondWithRpcPromise(_0xbca5('0xf5'),'pause',{'id':_0x1f4e22['id'],'name':_0x1f4e22[_0xbca5('0x3f')],'pause':!![]});}})[_0xbca5('0x1d')](function(){if(_0x1f4e22){return db[_0xbca5('0xe9')][_0xbca5('0x60')]({'where':{'membername':_0x1f4e22[_0xbca5('0x3f')],'type':_0xbca5('0xef'),'exitAt':null}});}})[_0xbca5('0x1d')](function(_0x19b3e6){if(_0x19b3e6[_0xbca5('0x51')]){var _0x51f310=moment()[_0xbca5('0xae')](_0xbca5('0xeb'));for(var _0x1fd745=0x0,_0xf4fb14=_0x19b3e6['length'];_0x1fd745<_0xf4fb14;_0x1fd745++){_0x19b3e6[_0x1fd745][_0xbca5('0xf6')]({'exitAt':_0x51f310});}}})[_0xbca5('0x1d')](function(){var _0x1a86c2=[];var _0x42aee9=utils['getChannels']();_0x42aee9[_0xbca5('0xea')](function(_0x1d9cd4){_0x1a86c2[_0xbca5('0x8f')]({'channel':_0x1d9cd4,'membername':_0x1f4e22[_0xbca5('0x3f')],'interface':_[_0xbca5('0x71')](_0x1f4e22[_0xbca5('0xdd')])?util[_0xbca5('0xae')](_0xbca5('0xaf'),_0x1f4e22[_0xbca5('0x3f')]):_0x1f4e22[_0xbca5('0xdd')],'type':_0xbca5('0xef'),'enterAt':moment()[_0xbca5('0xae')](_0xbca5('0xeb')),'data1':_0x412e80[_0xbca5('0x65')]['type']||_0xbca5('0xf7'),'role':_0x1f4e22[_0xbca5('0x33')],'internal':_0x1f4e22[_0xbca5('0x6b')]});});return db[_0xbca5('0xe9')][_0xbca5('0x8b')](_0x1a86c2,{'individualHooks':!![]});})[_0xbca5('0x1d')](function(){return _0x1f4e22[_0xbca5('0x64')]({'voicePause':!![],'mailPause':!![],'chatPause':!![],'faxPause':!![],'smsPause':!![],'whatsappPause':!![],'openchannelPause':!![],'pauseType':_0x412e80[_0xbca5('0x65')][_0xbca5('0xf8')]||_0xbca5('0xf7'),'lastPauseAt':moment()[_0xbca5('0xae')](_0xbca5('0xeb'))});})[_0xbca5('0x1d')](respondWithResult(_0x3e6b52,null))['catch'](handleError(_0x3e6b52,null));};exports[_0xbca5('0xf9')]=function(_0x53d3da,_0x3a1426,_0x26a05d){var _0x4d5db1;return db[_0xbca5('0x45')][_0xbca5('0x3e')]({'where':{'id':_0x53d3da['params']['id']},'attributes':['id',_0xbca5('0x3f'),'role',_0xbca5('0xa2'),_0xbca5('0xfa'),'chatPause',_0xbca5('0xfb'),_0xbca5('0xfc'),_0xbca5('0xfd'),'whatsapppause',_0xbca5('0xfe'),_0xbca5('0xff')]})[_0xbca5('0x1d')](handleEntityNotFound(_0x3a1426,null))[_0xbca5('0x1d')](function(_0x155a3c){if(_0x155a3c){_0x4d5db1=_0x155a3c;if(_0x53d3da[_0xbca5('0x65')][_0xbca5('0xa0')]&&!utils[_0xbca5('0xa3')](_0x53d3da[_0xbca5('0x65')][_0xbca5('0xa0')])){throw new db[(_0xbca5('0x97'))]['ValidationError']('Unknown\x20channel');}switch(_0x53d3da[_0xbca5('0x65')]['channel']){case _0xbca5('0xad'):return respondWithRpcPromise(_0xbca5('0xf5'),_0xbca5('0xf9'),{'id':_0x4d5db1['id'],'name':_0x4d5db1[_0xbca5('0x3f')],'pause':![]})[_0xbca5('0x1d')](function(){return db[_0xbca5('0xb1')][_0xbca5('0x64')]({'paused':0x0},{'where':{'UserId':_0x4d5db1['id']},'individualHooks':!![]});})['then'](function(){return db[_0xbca5('0xe9')][_0xbca5('0x3e')]({'where':{'channel':_0x53d3da[_0xbca5('0x65')][_0xbca5('0xa0')],'membername':_0x4d5db1[_0xbca5('0x3f')],'type':_0xbca5('0xef'),'exitAt':null}});})[_0xbca5('0x1d')](function(_0xda2aa7){if(_0xda2aa7){return _0xda2aa7[_0xbca5('0x64')]({'exitAt':moment()[_0xbca5('0xae')]('YYYY-MM-DD\x20HH:mm:ss'),'data2':_0xbca5('0x100')},{'individualHooks':!![]});}return null;})[_0xbca5('0x1d')](function(){return _0x4d5db1[_0xbca5('0x64')]({'voicePause':![]});});case _0xbca5('0x101'):case _0xbca5('0x102'):case _0xbca5('0x103'):case _0xbca5('0x104'):case'whatsapp':case _0xbca5('0x105'):return db[_0xbca5('0xe9')][_0xbca5('0x3e')]({'where':{'channel':_0x53d3da[_0xbca5('0x65')][_0xbca5('0xa0')],'membername':_0x4d5db1[_0xbca5('0x3f')],'type':_0xbca5('0xef'),'exitAt':null}})['then'](function(_0x82dc1d){if(_0x82dc1d){return _0x82dc1d[_0xbca5('0x64')]({'exitAt':moment()['format'](_0xbca5('0xeb')),'data2':_0xbca5('0x100')},{'individualHooks':!![]});}return null;})[_0xbca5('0x1d')](function(){var _0x2b5a93={};_[_0xbca5('0x2c')](_0x2b5a93,util['format'](_0xbca5('0x106'),_0x53d3da[_0xbca5('0x65')][_0xbca5('0xa0')],_0xbca5('0x107')),![]);return _0x4d5db1[_0xbca5('0x64')](_0x2b5a93);});default:return respondWithRpcPromise(_0xbca5('0xf5'),'unpause',{'id':_0x4d5db1['id'],'name':_0x4d5db1[_0xbca5('0x3f')],'pause':![]})[_0xbca5('0x1d')](function(){return db[_0xbca5('0xb1')][_0xbca5('0x64')]({'paused':0x0},{'where':{'UserId':_0x4d5db1['id']}});})[_0xbca5('0x1d')](function(){return db[_0xbca5('0xe9')][_0xbca5('0x60')]({'where':{'membername':_0x4d5db1['name'],'type':_0xbca5('0xef'),'exitAt':null}});})[_0xbca5('0x1d')](function(_0x2eca59){var _0x4b7de9=[];_0x2eca59[_0xbca5('0xea')](function(_0x371ba9){_0x4b7de9[_0xbca5('0x8f')](_0x371ba9[_0xbca5('0x64')]({'exitAt':moment()[_0xbca5('0xae')](_0xbca5('0xeb')),'data2':_0xbca5('0x100')}));});return BPromise[_0xbca5('0x90')](_0x4b7de9);})[_0xbca5('0x1d')](function(){return _0x4d5db1[_0xbca5('0x64')]({'voicePause':![],'mailPause':![],'chatPause':![],'faxPause':![],'smsPause':![],'whatsappPause':![],'openchannelPause':![]});});}}})[_0xbca5('0x1d')](respondWithResult(_0x3a1426,null))[_0xbca5('0x27')](handleError(_0x3a1426,null));};exports[_0xbca5('0x108')]=function(_0x37dc5c,_0x3dbb3e,_0x4b2fd4){var _0x7af63e={};var _0x233097={};var _0x3dc045;var _0x10a4d0;return db['User'][_0xbca5('0x9a')]({'where':{'id':_0x37dc5c[_0xbca5('0x66')]['id']}})[_0xbca5('0x1d')](handleEntityNotFound(_0x3dbb3e,null))[_0xbca5('0x1d')](function(_0x40cbed){if(_0x40cbed){_0x3dc045=_0x40cbed;_0x233097['model']=_['keys'](db[_0xbca5('0x109')][_0xbca5('0x46')]);_0x233097[_0xbca5('0x4c')]=_[_0xbca5('0x4b')](_0x37dc5c['query']);_0x233097[_0xbca5('0x4d')]=_[_0xbca5('0x4e')](_0x233097[_0xbca5('0x52')],_0x233097[_0xbca5('0x4c')]);_0x7af63e['attributes']=_[_0xbca5('0x4e')](_0x233097['model'],qs[_0xbca5('0x50')](_0x37dc5c[_0xbca5('0x4c')][_0xbca5('0x50')]));_0x7af63e['attributes']=_0x7af63e[_0xbca5('0x4f')]['length']?_0x7af63e['attributes']:_0x233097[_0xbca5('0x52')];_0x7af63e['order']=qs['sort'](_0x37dc5c[_0xbca5('0x4c')][_0xbca5('0x56')]);_0x7af63e[_0xbca5('0x57')]=qs[_0xbca5('0x4d')](_[_0xbca5('0xbf')](_0x37dc5c[_0xbca5('0x4c')],_0x233097['filters']));if(_0x37dc5c[_0xbca5('0x4c')][_0xbca5('0x39')]){_0x7af63e['where']=_[_0xbca5('0x58')](_0x7af63e[_0xbca5('0x57')],{'$or':_[_0xbca5('0x3b')](_0x7af63e[_0xbca5('0x4f')],function(_0x25b38c){var _0x205c97={};_0x205c97[_0x25b38c]={'$like':'%'+_0x37dc5c[_0xbca5('0x4c')][_0xbca5('0x39')]+'%'};return _0x205c97;})});}_0x7af63e=_['merge']({},_0x7af63e,_0x37dc5c[_0xbca5('0x5d')]);return _0x3dc045[_0xbca5('0x108')](_0x7af63e);}})[_0xbca5('0x1d')](function(_0x62fb7b){if(_0x62fb7b){_0x10a4d0=_0x62fb7b[_0xbca5('0x51')];if(!_0x37dc5c[_0xbca5('0x4c')]['hasOwnProperty'](_0xbca5('0x54'))){_0x7af63e[_0xbca5('0x2b')]=qs[_0xbca5('0x2b')](_0x37dc5c['query'][_0xbca5('0x2b')]);_0x7af63e[_0xbca5('0x2a')]=qs[_0xbca5('0x2a')](_0x37dc5c[_0xbca5('0x4c')][_0xbca5('0x2a')]);}return _0x3dc045[_0xbca5('0x108')](_0x7af63e);}})[_0xbca5('0x1d')](function(_0x2242e9){if(_0x2242e9){return _0x2242e9?{'count':_0x10a4d0,'rows':_0x2242e9}:null;}})[_0xbca5('0x1d')](respondWithResult(_0x3dbb3e,null))[_0xbca5('0x27')](handleError(_0x3dbb3e,null));};exports[_0xbca5('0x10a')]=function(_0x169bf9,_0x2dce39){return db[_0xbca5('0x45')][_0xbca5('0x3e')]({'where':{'id':_0x169bf9[_0xbca5('0x66')]['id']}})['then'](handleEntityNotFound(_0x2dce39,null))[_0xbca5('0x1d')](function(_0x2ec2ad){if(_0x2ec2ad){var _0x8de16b=_0x2ec2ad[_0xbca5('0x32')]({'plain':!![]});return _0x2ec2ad[_0xbca5('0x10a')](_0x169bf9['body'][_0xbca5('0x69')],_['omit'](_0x169bf9['body'],[_0xbca5('0x69'),'id'])||{})[_0xbca5('0x1d')](function(){for(var _0x547664=0x0;_0x547664<_0x169bf9[_0xbca5('0x65')][_0xbca5('0x69')][_0xbca5('0x51')];_0x547664++){var _0x1aa46b=[];db[_0xbca5('0x109')][_0xbca5('0x9a')]({'where':{'id':_0x169bf9['body'][_0xbca5('0x69')][_0x547664]}})[_0xbca5('0x1d')](function(_0x561cee){_0x1aa46b['push'](_0x561cee[_0xbca5('0xe7')]()['then'](function(_0x4b1557){for(var _0x3be87c=0x0;_0x3be87c<_0x4b1557['length'];_0x3be87c++){_0x4b1557[_0x3be87c]['setDataValue']('channel','Voice');}return _0x4b1557;}));_0x1aa46b[_0xbca5('0x8f')](_0x561cee[_0xbca5('0x10b')]()[_0xbca5('0x1d')](function(_0x53146c){for(var _0x295069=0x0;_0x295069<_0x53146c[_0xbca5('0x51')];_0x295069++){_0x53146c[_0x295069]['setDataValue'](_0xbca5('0xa0'),_0xbca5('0x10c'));}return _0x53146c;}));_0x1aa46b[_0xbca5('0x8f')](_0x561cee[_0xbca5('0x10d')]()[_0xbca5('0x1d')](function(_0x3d0933){for(var _0x5b2a48=0x0;_0x5b2a48<_0x3d0933['length'];_0x5b2a48++){_0x3d0933[_0x5b2a48][_0xbca5('0x10e')]('channel',_0xbca5('0x10f'));}return _0x3d0933;}));_0x1aa46b[_0xbca5('0x8f')](_0x561cee['getSmsQueues']()[_0xbca5('0x1d')](function(_0x4e98c1){for(var _0x2788d6=0x0;_0x2788d6<_0x4e98c1[_0xbca5('0x51')];_0x2788d6++){_0x4e98c1[_0x2788d6][_0xbca5('0x10e')](_0xbca5('0xa0'),_0xbca5('0x110'));}return _0x4e98c1;}));_0x1aa46b[_0xbca5('0x8f')](_0x561cee[_0xbca5('0x111')]()[_0xbca5('0x1d')](function(_0x452f58){for(var _0x227baa=0x0;_0x227baa<_0x452f58[_0xbca5('0x51')];_0x227baa++){_0x452f58[_0x227baa]['setDataValue'](_0xbca5('0xa0'),_0xbca5('0x112'));}return _0x452f58;}));_0x1aa46b[_0xbca5('0x8f')](_0x561cee[_0xbca5('0x113')]()['then'](function(_0xd2a6cb){for(var _0x1756e7=0x0;_0x1756e7<_0xd2a6cb['length'];_0x1756e7++){_0xd2a6cb[_0x1756e7]['setDataValue']('channel',_0xbca5('0x114'));}return _0xd2a6cb;}));_0x1aa46b[_0xbca5('0x8f')](_0x561cee[_0xbca5('0x115')]()[_0xbca5('0x1d')](function(_0x2a2e25){for(var _0x42743a=0x0;_0x42743a<_0x2a2e25[_0xbca5('0x51')];_0x42743a++){_0x2a2e25[_0x42743a][_0xbca5('0x10e')]('channel',_0xbca5('0x116'));}return _0x2a2e25;}));return BPromise[_0xbca5('0x90')](_0x1aa46b);})[_0xbca5('0x1d')](function(_0x4f9d12){var _0x49bba=_['flatten'](_0x4f9d12);_0x1aa46b=[];return db[_0xbca5('0x5a')][_0xbca5('0x117')](function(_0x3f5f11){for(var _0x31da05=0x0;_0x31da05<_0x49bba['length'];_0x31da05++){_0x1aa46b['push'](_0x49bba[_0x31da05]['addAgent'](_0x8de16b['id']),{'transaction':_0x3f5f11});}return BPromise[_0xbca5('0x90')](_0x1aa46b)[_0xbca5('0x1d')](function(){if(_0x8de16b[_0xbca5('0xa1')]){return BPromise['each'](_[_0xbca5('0x39')](_0x49bba,function(_0x64ff58){return _0x64ff58[_0xbca5('0x118')](_0xbca5('0xa0'))==='Voice';}),function(_0x505463){return db[_0xbca5('0xb1')][_0xbca5('0xb2')]({'membername':_0x8de16b[_0xbca5('0x3f')],'UserId':_0x8de16b['id'],'queue_name':_0x505463[_0xbca5('0x3f')],'VoiceQueueId':_0x505463['id'],'interface':_[_0xbca5('0x71')](_0x8de16b[_0xbca5('0xdd')])?util[_0xbca5('0xae')](_0xbca5('0xaf'),_0x8de16b[_0xbca5('0x3f')]):_0x8de16b[_0xbca5('0xdd')],'paused':_0x8de16b['voicePause']||![],'penalty':_0x8de16b[_0xbca5('0xa7')]},{'transaction':_0x3f5f11});});}else{return;}})[_0xbca5('0x1d')](function(){for(var _0x1a7559=0x0;_0x1a7559<_0x49bba[_0xbca5('0x51')];_0x1a7559++){var _0x44fdd5=_0x49bba[_0x1a7559][_0xbca5('0x118')](_0xbca5('0xa0'));var _0x418f1a=_0x44fdd5+_0xbca5('0xab');socket[_0xbca5('0xb4')](_0xbca5('0x36')+_0x44fdd5+'Queue:save',{'UserId':_0x8de16b['id'],['queueField']:_0x49bba[_0x1a7559]['id']});}});});});}});}})['then'](respondWithStatusCode(_0x2dce39,null))['catch'](handleError(_0x2dce39,null));};exports[_0xbca5('0x119')]=function(_0x1ccae5,_0x4ed2f3){return db[_0xbca5('0x45')][_0xbca5('0x9a')]({'where':{'id':_0x1ccae5['params']['id']}})['then'](handleEntityNotFound(_0x4ed2f3,null))[_0xbca5('0x1d')](function(_0x54945c){if(_0x54945c){var _0xc4ad3b=_0x54945c['get']({'plain':!![]});var _0x2c6533=_0x1ccae5[_0xbca5('0x4c')]['ids'];return _0x54945c[_0xbca5('0x119')](_0x2c6533)[_0xbca5('0x1d')](function(){for(var _0x21e34a=0x0;_0x21e34a<_0x2c6533[_0xbca5('0x51')];_0x21e34a++){var _0x24e8a4=[];db[_0xbca5('0x109')][_0xbca5('0x9a')]({'where':{'id':_0x2c6533[_0x21e34a]}})['then'](function(_0x296799){_0x24e8a4['push'](_0x296799[_0xbca5('0xe7')]()['then'](function(_0x23cc84){for(var _0x1c7c7e=0x0;_0x1c7c7e<_0x23cc84[_0xbca5('0x51')];_0x1c7c7e++){_0x23cc84[_0x1c7c7e][_0xbca5('0x10e')](_0xbca5('0xa0'),_0xbca5('0x11a'));}return _0x23cc84;}));_0x24e8a4[_0xbca5('0x8f')](_0x296799[_0xbca5('0x10b')]()[_0xbca5('0x1d')](function(_0x814b53){for(var _0x5f1449=0x0;_0x5f1449<_0x814b53['length'];_0x5f1449++){_0x814b53[_0x5f1449][_0xbca5('0x10e')](_0xbca5('0xa0'),'Chat');}return _0x814b53;}));_0x24e8a4[_0xbca5('0x8f')](_0x296799['getMailQueues']()['then'](function(_0x1870cb){for(var _0x909764=0x0;_0x909764<_0x1870cb[_0xbca5('0x51')];_0x909764++){_0x1870cb[_0x909764][_0xbca5('0x10e')](_0xbca5('0xa0'),_0xbca5('0x10f'));}return _0x1870cb;}));_0x24e8a4[_0xbca5('0x8f')](_0x296799[_0xbca5('0x11b')]()[_0xbca5('0x1d')](function(_0x1faf61){for(var _0x11321c=0x0;_0x11321c<_0x1faf61[_0xbca5('0x51')];_0x11321c++){_0x1faf61[_0x11321c]['setDataValue'](_0xbca5('0xa0'),_0xbca5('0x110'));}return _0x1faf61;}));_0x24e8a4['push'](_0x296799['getWhatsappQueues']()[_0xbca5('0x1d')](function(_0x53b21a){for(var _0x12d33d=0x0;_0x12d33d<_0x53b21a[_0xbca5('0x51')];_0x12d33d++){_0x53b21a[_0x12d33d][_0xbca5('0x10e')](_0xbca5('0xa0'),_0xbca5('0x112'));}return _0x53b21a;}));_0x24e8a4[_0xbca5('0x8f')](_0x296799[_0xbca5('0x113')]()['then'](function(_0x316330){for(var _0x39cad1=0x0;_0x39cad1<_0x316330[_0xbca5('0x51')];_0x39cad1++){_0x316330[_0x39cad1][_0xbca5('0x10e')](_0xbca5('0xa0'),_0xbca5('0x114'));}return _0x316330;}));_0x24e8a4[_0xbca5('0x8f')](_0x296799['getOpenchannelQueues']()[_0xbca5('0x1d')](function(_0x1bd3bd){for(var _0x3d6433=0x0;_0x3d6433<_0x1bd3bd['length'];_0x3d6433++){_0x1bd3bd[_0x3d6433][_0xbca5('0x10e')](_0xbca5('0xa0'),'Openchannel');}return _0x1bd3bd;}));return BPromise[_0xbca5('0x90')](_0x24e8a4);})[_0xbca5('0x1d')](function(_0x286c50){var _0x25bdf6=_[_0xbca5('0x11c')](_0x286c50);_0x24e8a4=[];return db[_0xbca5('0x5a')][_0xbca5('0x117')](function(_0x2c13b6){for(var _0x219863=0x0;_0x219863<_0x25bdf6[_0xbca5('0x51')];_0x219863++){_0x24e8a4[_0xbca5('0x8f')](_0x25bdf6[_0x219863][_0xbca5('0x11d')](_0xc4ad3b['id']),{'transaction':_0x2c13b6});}return BPromise['all'](_0x24e8a4)['then'](function(){if(_0xc4ad3b[_0xbca5('0xa1')]){return BPromise[_0xbca5('0xb0')](_[_0xbca5('0x39')](_0x25bdf6,function(_0x1f0fb0){return _0x1f0fb0['getDataValue'](_0xbca5('0xa0'))===_0xbca5('0x11a');}),function(_0x38a498){return db[_0xbca5('0xb1')]['destroy']({'where':{'VoiceQueueId':_0x38a498['id'],'UserId':_0xc4ad3b['id']},'transaction':_0x2c13b6});});}else{return;}})['then'](function(){for(var _0x5715e8=0x0;_0x5715e8<_0x25bdf6['length'];_0x5715e8++){var _0x3599e6=_0x25bdf6[_0x5715e8][_0xbca5('0x118')](_0xbca5('0xa0'));var _0x4c5ae1=_0x3599e6+_0xbca5('0xab');socket[_0xbca5('0xb4')](_0xbca5('0x36')+_0x3599e6+_0xbca5('0x11e'),{'UserId':_0xc4ad3b['id'],['queueField']:_0x25bdf6[_0x5715e8]['id']});}});});});}});}})[_0xbca5('0x1d')](respondWithStatusCode(_0x4ed2f3,null))[_0xbca5('0x27')](handleError(_0x4ed2f3,null));};exports[_0xbca5('0x11f')]=function(_0x1a0473,_0x4d933f,_0x1ae3bb){var _0x14791f={};var _0x2ce3ec={};var _0x1c0222;var _0x44f440;return db[_0xbca5('0x45')][_0xbca5('0x9a')]({'where':{'id':_0x1a0473[_0xbca5('0x66')]['id']}})[_0xbca5('0x1d')](handleEntityNotFound(_0x4d933f,null))['then'](function(_0x16bc3f){if(_0x16bc3f){_0x1c0222=_0x16bc3f;_0x2ce3ec['model']=_['keys'](db['CmList'][_0xbca5('0x46')]);_0x2ce3ec[_0xbca5('0x4c')]=_['keys'](_0x1a0473['query']);_0x2ce3ec[_0xbca5('0x4d')]=_[_0xbca5('0x4e')](_0x2ce3ec[_0xbca5('0x52')],_0x2ce3ec[_0xbca5('0x4c')]);_0x14791f['attributes']=_[_0xbca5('0x4e')](_0x2ce3ec[_0xbca5('0x52')],qs[_0xbca5('0x50')](_0x1a0473[_0xbca5('0x4c')]['fields']));_0x14791f[_0xbca5('0x4f')]=_0x14791f[_0xbca5('0x4f')]['length']?_0x14791f['attributes']:_0x2ce3ec[_0xbca5('0x52')];_0x14791f['order']=qs['sort'](_0x1a0473[_0xbca5('0x4c')]['sort']);_0x14791f[_0xbca5('0x57')]=qs[_0xbca5('0x4d')](_[_0xbca5('0xbf')](_0x1a0473[_0xbca5('0x4c')],_0x2ce3ec[_0xbca5('0x4d')]));if(_0x1a0473[_0xbca5('0x4c')]['filter']){_0x14791f['where']=_['merge'](_0x14791f[_0xbca5('0x57')],{'$or':_[_0xbca5('0x3b')](_0x14791f[_0xbca5('0x4f')],function(_0x3914b7){var _0x25ec08={};_0x25ec08[_0x3914b7]={'$like':'%'+_0x1a0473[_0xbca5('0x4c')][_0xbca5('0x39')]+'%'};return _0x25ec08;})});}_0x14791f=_[_0xbca5('0x58')]({},_0x14791f,_0x1a0473[_0xbca5('0x5d')]);return _0x1c0222['getLists'](_0x14791f);}})[_0xbca5('0x1d')](function(_0x4be90e){if(_0x4be90e){_0x44f440=_0x4be90e[_0xbca5('0x51')];if(!_0x1a0473[_0xbca5('0x4c')][_0xbca5('0x53')]('nolimit')){_0x14791f[_0xbca5('0x2b')]=qs[_0xbca5('0x2b')](_0x1a0473[_0xbca5('0x4c')]['limit']);_0x14791f[_0xbca5('0x2a')]=qs[_0xbca5('0x2a')](_0x1a0473[_0xbca5('0x4c')][_0xbca5('0x2a')]);}return _0x1c0222[_0xbca5('0x11f')](_0x14791f);}})['then'](function(_0x4e0b45){if(_0x4e0b45){return _0x4e0b45?{'count':_0x44f440,'rows':_0x4e0b45}:null;}})[_0xbca5('0x1d')](respondWithResult(_0x4d933f,null))['catch'](handleError(_0x4d933f,null));};exports[_0xbca5('0x120')]=function(_0x5e275c,_0x326d51,_0x47a39b){var _0x56a172={};var _0x562404={};var _0x1a7da8;var _0x169a2c;return db[_0xbca5('0x45')][_0xbca5('0x9a')]({'where':{'id':_0x5e275c[_0xbca5('0x66')]['id']}})['then'](handleEntityNotFound(_0x326d51,null))['then'](function(_0x1ff9dd){if(_0x1ff9dd){_0x1a7da8=_0x1ff9dd;_0x562404[_0xbca5('0x52')]=_[_0xbca5('0x4b')](db['User'][_0xbca5('0x46')]);_0x562404['query']=_['keys'](_0x5e275c[_0xbca5('0x4c')]);_0x562404[_0xbca5('0x4d')]=_[_0xbca5('0x4e')](_0x562404[_0xbca5('0x52')],_0x562404[_0xbca5('0x4c')]);_0x56a172[_0xbca5('0x4f')]=_[_0xbca5('0x4e')](_0x562404[_0xbca5('0x52')],qs[_0xbca5('0x50')](_0x5e275c[_0xbca5('0x4c')]['fields']));_0x56a172[_0xbca5('0x4f')]=_0x56a172['attributes'][_0xbca5('0x51')]?_0x56a172[_0xbca5('0x4f')]:_0x562404[_0xbca5('0x52')];_0x56a172['order']=qs[_0xbca5('0x56')](_0x5e275c[_0xbca5('0x4c')][_0xbca5('0x56')]);_0x56a172[_0xbca5('0x57')]=qs[_0xbca5('0x4d')](_[_0xbca5('0xbf')](_0x5e275c['query'],_0x562404[_0xbca5('0x4d')]));if(_0x5e275c['query'][_0xbca5('0x39')]){_0x56a172[_0xbca5('0x57')]=_[_0xbca5('0x58')](_0x56a172[_0xbca5('0x57')],{'$or':_['map'](_0x56a172[_0xbca5('0x4f')],function(_0x1b1a6c){var _0x43ba14={};_0x43ba14[_0x1b1a6c]={'$like':'%'+_0x5e275c[_0xbca5('0x4c')][_0xbca5('0x39')]+'%'};return _0x43ba14;})});}_0x56a172['model']=db[_0xbca5('0x45')];_0x56a172['as']='Agents';_0x56a172=_[_0xbca5('0x58')]({},_0x56a172,_0x5e275c[_0xbca5('0x5d')]);return _0x1a7da8[_0xbca5('0xe7')]({'include':[_0x56a172]});}})[_0xbca5('0x1d')](function(_0x90a12a){if(_0x90a12a){var _0xdf419b={},_0x338bb7=[],_0x462c0d=0x0;for(var _0x4a5011=0x0;_0x4a5011<_0x90a12a[_0xbca5('0x51')];_0x4a5011+=0x1){for(var _0x47efa1=0x0,_0x48fa1a;_0x47efa1<_0x90a12a[_0x4a5011][_0xbca5('0x37')][_0xbca5('0x51')];_0x47efa1+=0x1){_0x48fa1a=_0x90a12a[_0x4a5011][_0xbca5('0x37')][_0x47efa1][_0xbca5('0x32')]({'plain':!![]});_0xdf419b[_0x48fa1a['id']]=_0x48fa1a;}}_0xdf419b=_[_0xbca5('0x121')](_0xdf419b);for(var _0x35686e=qs[_0xbca5('0x2a')](_0x5e275c['query']['offset']);_0x35686e<_0xdf419b[_0xbca5('0x51')]&&_0x338bb7[_0xbca5('0x51')]<qs['limit'](_0x5e275c[_0xbca5('0x4c')][_0xbca5('0x2b')]);_0x35686e+=0x1){if(_0xdf419b[_0x35686e]){_0x338bb7[_0xbca5('0x8f')](_0xdf419b[_0x35686e]);}}return{'count':_0xdf419b[_0xbca5('0x51')],'rows':_0x338bb7};}})[_0xbca5('0x1d')](respondWithResult(_0x326d51,null))[_0xbca5('0x27')](handleError(_0x326d51,null));};exports[_0xbca5('0x31')]=function(_0x39d88a,_0x1590ee){if(_0x39d88a[_0xbca5('0x36')]['id']==_0x39d88a[_0xbca5('0x66')]['id']){return _0x1590ee[_0xbca5('0x41')](0x1f4)[_0xbca5('0x43')]({'message':_0xbca5('0x122')});}return db['User'][_0xbca5('0x3e')]({'where':{'id':_0x39d88a[_0xbca5('0x66')]['id']}})['then'](handleEntityNotFound(_0x1590ee,null))['then'](removeEntity(_0x1590ee,null))[_0xbca5('0x27')](handleError(_0x1590ee,null));};exports[_0xbca5('0x123')]=function(_0x57f86a,_0x2a0bad,_0x403dc0){return db[_0xbca5('0x45')][_0xbca5('0x3e')]({'where':{'id':_0x57f86a[_0xbca5('0x66')]['id']}})[_0xbca5('0x1d')](handleEntityNotFound(_0x2a0bad,null))[_0xbca5('0x1d')](function(_0x525805){if(_0x525805){return _0x525805[_0xbca5('0x123')](_0x57f86a[_0xbca5('0x65')][_0xbca5('0x69')],_['omit'](_0x57f86a[_0xbca5('0x65')],[_0xbca5('0x69'),'id'])||{})['spread'](function(){for(var _0x475baa=0x0;_0x475baa<_0x57f86a[_0xbca5('0x65')][_0xbca5('0x69')][_0xbca5('0x51')];_0x475baa+=0x1){socket['emit']('user_has_chat_interactions:save',{'ChatInteractionId':Number(_0x57f86a['body'][_0xbca5('0x69')][_0x475baa]),'UserId':Number(_0x57f86a[_0xbca5('0x66')]['id'])});}return _0x57f86a[_0xbca5('0x65')][_0xbca5('0x69')];});}})[_0xbca5('0x1d')](respondWithResult(_0x2a0bad,null))[_0xbca5('0x27')](handleError(_0x2a0bad,null));};exports['removeChatInteractions']=function(_0x320f12,_0xcb56c6,_0x1beb8e){return db['User'][_0xbca5('0x3e')]({'where':{'id':_0x320f12['params']['id']}})[_0xbca5('0x1d')](handleEntityNotFound(_0xcb56c6,null))[_0xbca5('0x1d')](function(_0x46f5b2){if(_0x46f5b2){return _0x46f5b2[_0xbca5('0x124')](_0x320f12[_0xbca5('0x4c')][_0xbca5('0x69')])[_0xbca5('0x1d')](function(){if(_[_0xbca5('0x125')](_0x320f12[_0xbca5('0x4c')][_0xbca5('0x69')])){for(var _0x9bdddd=0x0;_0x9bdddd<_0x320f12['query'][_0xbca5('0x69')]['length'];_0x9bdddd+=0x1){socket[_0xbca5('0xb4')]('user_has_chat_interactions:remove',{'ChatInteractionId':Number(_0x320f12['query'][_0xbca5('0x69')][_0x9bdddd]),'UserId':Number(_0x320f12[_0xbca5('0x66')]['id'])});}}else{socket[_0xbca5('0xb4')](_0xbca5('0x126'),{'ChatInteractionId':Number(_0x320f12[_0xbca5('0x4c')][_0xbca5('0x69')]),'UserId':Number(_0x320f12[_0xbca5('0x66')]['id'])});}});}})[_0xbca5('0x1d')](respondWithStatusCode(_0xcb56c6,null))[_0xbca5('0x27')](handleError(_0xcb56c6,null));};exports[_0xbca5('0x127')]=function(_0xb65711,_0x101f10,_0x5aadaa){return db[_0xbca5('0x45')]['find']({'where':{'id':_0xb65711[_0xbca5('0x66')]['id']}})[_0xbca5('0x1d')](handleEntityNotFound(_0x101f10,null))['then'](function(_0x5cde2b){if(_0x5cde2b){return _0x5cde2b[_0xbca5('0x127')](_0xb65711[_0xbca5('0x65')][_0xbca5('0x69')],_[_0xbca5('0x6a')](_0xb65711['body'],[_0xbca5('0x69'),'id'])||{})['spread'](function(){for(var _0x1d646e=0x0;_0x1d646e<_0xb65711['body']['ids'][_0xbca5('0x51')];_0x1d646e+=0x1){socket[_0xbca5('0xb4')](_0xbca5('0x128'),{'MailInteractionId':Number(_0xb65711[_0xbca5('0x65')][_0xbca5('0x69')][_0x1d646e]),'UserId':Number(_0xb65711['params']['id'])});}return _0xb65711[_0xbca5('0x65')][_0xbca5('0x69')];});}})['then'](respondWithResult(_0x101f10,null))['catch'](handleError(_0x101f10,null));};exports[_0xbca5('0x129')]=function(_0x56dcfa,_0x487bae,_0x375b20){return db[_0xbca5('0x45')][_0xbca5('0x3e')]({'where':{'id':_0x56dcfa[_0xbca5('0x66')]['id']}})[_0xbca5('0x1d')](handleEntityNotFound(_0x487bae,null))[_0xbca5('0x1d')](function(_0x5cbacc){if(_0x5cbacc){return _0x5cbacc[_0xbca5('0x129')](_0x56dcfa[_0xbca5('0x4c')][_0xbca5('0x69')])[_0xbca5('0x1d')](function(){if(_[_0xbca5('0x125')](_0x56dcfa[_0xbca5('0x4c')][_0xbca5('0x69')])){for(var _0x1d426d=0x0;_0x1d426d<_0x56dcfa[_0xbca5('0x4c')][_0xbca5('0x69')]['length'];_0x1d426d+=0x1){socket['emit']('user_has_mail_interactions:remove',{'MailInteractionId':Number(_0x56dcfa['query'][_0xbca5('0x69')][_0x1d426d]),'UserId':Number(_0x56dcfa[_0xbca5('0x66')]['id'])});}}else{socket[_0xbca5('0xb4')]('user_has_mail_interactions:remove',{'MailInteractionId':Number(_0x56dcfa['query'][_0xbca5('0x69')]),'UserId':Number(_0x56dcfa['params']['id'])});}});}})['then'](respondWithStatusCode(_0x487bae,null))[_0xbca5('0x27')](handleError(_0x487bae,null));};exports[_0xbca5('0x12a')]=function(_0x203a5b,_0x195cf0,_0x1b2b5f){return db[_0xbca5('0x45')][_0xbca5('0x3e')]({'where':{'id':_0x203a5b[_0xbca5('0x66')]['id']}})[_0xbca5('0x1d')](handleEntityNotFound(_0x195cf0,null))[_0xbca5('0x1d')](function(_0x4a6dc0){if(_0x4a6dc0){return _0x4a6dc0['addFaxInteractions'](_0x203a5b[_0xbca5('0x65')][_0xbca5('0x69')],_[_0xbca5('0x6a')](_0x203a5b[_0xbca5('0x65')],[_0xbca5('0x69'),'id'])||{})[_0xbca5('0xa8')](function(){for(var _0x2eea8d=0x0;_0x2eea8d<_0x203a5b['body'][_0xbca5('0x69')][_0xbca5('0x51')];_0x2eea8d+=0x1){socket['emit']('user_has_fax_interactions:save',{'FaxInteractionId':Number(_0x203a5b[_0xbca5('0x65')][_0xbca5('0x69')][_0x2eea8d]),'UserId':Number(_0x203a5b['params']['id'])});}return _0x203a5b[_0xbca5('0x65')][_0xbca5('0x69')];});}})['then'](respondWithResult(_0x195cf0,null))[_0xbca5('0x27')](handleError(_0x195cf0,null));};exports[_0xbca5('0x12b')]=function(_0x5b319e,_0x3e5df5,_0x430e73){return db[_0xbca5('0x45')]['find']({'where':{'id':_0x5b319e['params']['id']}})[_0xbca5('0x1d')](handleEntityNotFound(_0x3e5df5,null))[_0xbca5('0x1d')](function(_0x2b2739){if(_0x2b2739){return _0x2b2739[_0xbca5('0x12b')](_0x5b319e[_0xbca5('0x4c')][_0xbca5('0x69')])[_0xbca5('0x1d')](function(){if(_[_0xbca5('0x125')](_0x5b319e[_0xbca5('0x4c')]['ids'])){for(var _0x34ab09=0x0;_0x34ab09<_0x5b319e[_0xbca5('0x4c')][_0xbca5('0x69')][_0xbca5('0x51')];_0x34ab09+=0x1){socket['emit'](_0xbca5('0x12c'),{'FaxInteractionId':Number(_0x5b319e[_0xbca5('0x4c')][_0xbca5('0x69')][_0x34ab09]),'UserId':Number(_0x5b319e[_0xbca5('0x66')]['id'])});}}else{socket['emit']('user_has_fax_interactions:remove',{'FaxInteractionId':Number(_0x5b319e[_0xbca5('0x4c')][_0xbca5('0x69')]),'UserId':Number(_0x5b319e[_0xbca5('0x66')]['id'])});}});}})['then'](respondWithStatusCode(_0x3e5df5,null))[_0xbca5('0x27')](handleError(_0x3e5df5,null));};exports[_0xbca5('0x12d')]=function(_0x1d2fd2,_0x4d8d20,_0x7108c){return db[_0xbca5('0x45')][_0xbca5('0x3e')]({'where':{'id':_0x1d2fd2[_0xbca5('0x66')]['id']}})[_0xbca5('0x1d')](handleEntityNotFound(_0x4d8d20,null))[_0xbca5('0x1d')](function(_0x218824){if(_0x218824){return _0x218824['addSmsInteractions'](_0x1d2fd2['body'][_0xbca5('0x69')],_[_0xbca5('0x6a')](_0x1d2fd2[_0xbca5('0x65')],['ids','id'])||{})[_0xbca5('0xa8')](function(){for(var _0x4d1eee=0x0;_0x4d1eee<_0x1d2fd2['body'][_0xbca5('0x69')]['length'];_0x4d1eee+=0x1){socket[_0xbca5('0xb4')](_0xbca5('0x12e'),{'SmsInteractionId':Number(_0x1d2fd2[_0xbca5('0x65')][_0xbca5('0x69')][_0x4d1eee]),'UserId':Number(_0x1d2fd2[_0xbca5('0x66')]['id'])});}return _0x1d2fd2[_0xbca5('0x65')][_0xbca5('0x69')];});}})[_0xbca5('0x1d')](respondWithResult(_0x4d8d20,null))[_0xbca5('0x27')](handleError(_0x4d8d20,null));};exports['removeSmsInteractions']=function(_0x2834a1,_0x2bfe98,_0x1b6645){return db['User'][_0xbca5('0x3e')]({'where':{'id':_0x2834a1[_0xbca5('0x66')]['id']}})['then'](handleEntityNotFound(_0x2bfe98,null))[_0xbca5('0x1d')](function(_0x303422){if(_0x303422){return _0x303422[_0xbca5('0x12f')](_0x2834a1[_0xbca5('0x4c')]['ids'])[_0xbca5('0x1d')](function(){if(_['isArray'](_0x2834a1[_0xbca5('0x4c')][_0xbca5('0x69')])){for(var _0x11579a=0x0;_0x11579a<_0x2834a1[_0xbca5('0x4c')]['ids']['length'];_0x11579a+=0x1){socket[_0xbca5('0xb4')](_0xbca5('0x130'),{'SmsInteractionId':Number(_0x2834a1[_0xbca5('0x4c')][_0xbca5('0x69')][_0x11579a]),'UserId':Number(_0x2834a1[_0xbca5('0x66')]['id'])});}}else{socket[_0xbca5('0xb4')](_0xbca5('0x130'),{'SmsInteractionId':Number(_0x2834a1[_0xbca5('0x4c')][_0xbca5('0x69')]),'UserId':Number(_0x2834a1[_0xbca5('0x66')]['id'])});}});}})['then'](respondWithStatusCode(_0x2bfe98,null))[_0xbca5('0x27')](handleError(_0x2bfe98,null));};exports[_0xbca5('0x131')]=function(_0x3b5558,_0x4e04e3,_0x5314c8){return db['User'][_0xbca5('0x3e')]({'where':{'id':_0x3b5558[_0xbca5('0x66')]['id']}})['then'](handleEntityNotFound(_0x4e04e3,null))[_0xbca5('0x1d')](function(_0x3a66ad){if(_0x3a66ad){return _0x3a66ad[_0xbca5('0x131')](_0x3b5558[_0xbca5('0x65')]['ids'],_[_0xbca5('0x6a')](_0x3b5558['body'],[_0xbca5('0x69'),'id'])||{})[_0xbca5('0xa8')](function(){for(var _0xfbbfe9=0x0;_0xfbbfe9<_0x3b5558[_0xbca5('0x65')][_0xbca5('0x69')][_0xbca5('0x51')];_0xfbbfe9+=0x1){socket['emit'](_0xbca5('0x132'),{'OpenchannelInteractionId':Number(_0x3b5558[_0xbca5('0x65')][_0xbca5('0x69')][_0xfbbfe9]),'UserId':Number(_0x3b5558[_0xbca5('0x66')]['id'])});}return _0x3b5558['body'][_0xbca5('0x69')];});}})['then'](respondWithResult(_0x4e04e3,null))['catch'](handleError(_0x4e04e3,null));};exports[_0xbca5('0x133')]=function(_0x596be0,_0x2afa15,_0xbe947c){return db[_0xbca5('0x45')][_0xbca5('0x3e')]({'where':{'id':_0x596be0['params']['id']}})['then'](handleEntityNotFound(_0x2afa15,null))[_0xbca5('0x1d')](function(_0x7d4492){if(_0x7d4492){return _0x7d4492[_0xbca5('0x133')](_0x596be0[_0xbca5('0x4c')]['ids'])[_0xbca5('0x1d')](function(){if(_[_0xbca5('0x125')](_0x596be0[_0xbca5('0x4c')]['ids'])){for(var _0x145963=0x0;_0x145963<_0x596be0['query'][_0xbca5('0x69')][_0xbca5('0x51')];_0x145963+=0x1){socket[_0xbca5('0xb4')]('user_has_openchannel_interactions:remove',{'OpenchannelInteractionId':Number(_0x596be0[_0xbca5('0x4c')][_0xbca5('0x69')][_0x145963]),'UserId':Number(_0x596be0['params']['id'])});}}else{socket[_0xbca5('0xb4')](_0xbca5('0x134'),{'OpenchannelInteractionId':Number(_0x596be0['query'][_0xbca5('0x69')]),'UserId':Number(_0x596be0[_0xbca5('0x66')]['id'])});}});}})[_0xbca5('0x1d')](respondWithStatusCode(_0x2afa15,null))[_0xbca5('0x27')](handleError(_0x2afa15,null));};exports[_0xbca5('0x135')]=function(_0x385e03,_0x2883d8,_0x537f51){return db[_0xbca5('0x45')][_0xbca5('0x3e')]({'where':{'id':_0x385e03[_0xbca5('0x66')]['id']}})[_0xbca5('0x1d')](handleEntityNotFound(_0x2883d8,null))['then'](function(_0x294265){if(_0x294265){return _0x294265[_0xbca5('0x135')](_0x385e03['body'][_0xbca5('0x69')],_[_0xbca5('0x6a')](_0x385e03[_0xbca5('0x65')],['ids','id'])||{})[_0xbca5('0xa8')](function(){for(var _0x209fcd=0x0;_0x209fcd<_0x385e03[_0xbca5('0x65')]['ids'][_0xbca5('0x51')];_0x209fcd+=0x1){socket['emit']('user_has_whatsapp_interactions:save',{'WhatsappInteractionId':Number(_0x385e03['body'][_0xbca5('0x69')][_0x209fcd]),'UserId':Number(_0x385e03['params']['id'])});}return _0x385e03[_0xbca5('0x65')]['ids'];});}})['then'](respondWithResult(_0x2883d8,null))['catch'](handleError(_0x2883d8,null));};exports[_0xbca5('0x136')]=function(_0x10dd78,_0x321be5,_0x3701f0){return db[_0xbca5('0x45')][_0xbca5('0x3e')]({'where':{'id':_0x10dd78[_0xbca5('0x66')]['id']}})[_0xbca5('0x1d')](handleEntityNotFound(_0x321be5,null))['then'](function(_0x3616e9){if(_0x3616e9){return _0x3616e9[_0xbca5('0x136')](_0x10dd78['query']['ids']);}})['then'](respondWithStatusCode(_0x321be5,null))[_0xbca5('0x27')](handleError(_0x321be5,null));};exports[_0xbca5('0x137')]=function(_0x21661e,_0x1e5b63,_0x473c95){var _0x19dd80={};var _0x52f1d7={};var _0x4ae4f6;var _0x450e57;return db[_0xbca5('0x45')][_0xbca5('0x9a')]({'where':{'id':_0x21661e[_0xbca5('0x66')]['id']}})['then'](handleEntityNotFound(_0x1e5b63,null))[_0xbca5('0x1d')](function(_0x3ac765){if(_0x3ac765){_0x4ae4f6=_0x3ac765;_0x52f1d7[_0xbca5('0x52')]=_[_0xbca5('0x4b')](db[_0xbca5('0x138')]['rawAttributes']);_0x52f1d7[_0xbca5('0x4c')]=_['keys'](_0x21661e[_0xbca5('0x4c')]);_0x52f1d7['filters']=_[_0xbca5('0x4e')](_0x52f1d7['model'],_0x52f1d7[_0xbca5('0x4c')]);_0x19dd80['attributes']=_[_0xbca5('0x4e')](_0x52f1d7[_0xbca5('0x52')],qs[_0xbca5('0x50')](_0x21661e[_0xbca5('0x4c')]['fields']));_0x19dd80['attributes']=_0x19dd80[_0xbca5('0x4f')][_0xbca5('0x51')]?_0x19dd80['attributes']:_0x52f1d7[_0xbca5('0x52')];_0x19dd80[_0xbca5('0x55')]=qs[_0xbca5('0x56')](_0x21661e[_0xbca5('0x4c')]['sort']);_0x19dd80[_0xbca5('0x57')]=qs['filters'](_[_0xbca5('0xbf')](_0x21661e[_0xbca5('0x4c')],_0x52f1d7[_0xbca5('0x4d')]));if(_0x21661e[_0xbca5('0x4c')][_0xbca5('0x39')]){_0x19dd80[_0xbca5('0x57')]=_[_0xbca5('0x58')](_0x19dd80['where'],{'$or':_[_0xbca5('0x3b')](_0x19dd80[_0xbca5('0x4f')],function(_0x6b657b){var _0x3db3e6={};_0x3db3e6[_0x6b657b]={'$like':'%'+_0x21661e[_0xbca5('0x4c')]['filter']+'%'};return _0x3db3e6;})});}_0x19dd80=_[_0xbca5('0x58')]({},_0x19dd80,_0x21661e[_0xbca5('0x5d')]);return _0x4ae4f6[_0xbca5('0x137')](_0x19dd80);}})['then'](function(_0x598d29){if(_0x598d29){_0x450e57=_0x598d29[_0xbca5('0x51')];if(!_0x21661e['query'][_0xbca5('0x53')](_0xbca5('0x54'))){_0x19dd80[_0xbca5('0x2b')]=qs[_0xbca5('0x2b')](_0x21661e[_0xbca5('0x4c')][_0xbca5('0x2b')]);_0x19dd80['offset']=qs[_0xbca5('0x2a')](_0x21661e['query'][_0xbca5('0x2a')]);}return _0x4ae4f6[_0xbca5('0x137')](_0x19dd80);}})[_0xbca5('0x1d')](function(_0x44d790){if(_0x44d790){return _0x44d790?{'count':_0x450e57,'rows':_0x44d790}:null;}})[_0xbca5('0x1d')](respondWithResult(_0x1e5b63,null))['catch'](handleError(_0x1e5b63,null));};exports['getFaxAccounts']=function(_0x2c34ea,_0x34cae2,_0x417ae9){var _0x2ee621={};var _0x4bad7f={};var _0x14ab62;var _0x341ac2;return db['User']['findOne']({'where':{'id':_0x2c34ea[_0xbca5('0x66')]['id']}})[_0xbca5('0x1d')](handleEntityNotFound(_0x34cae2,null))[_0xbca5('0x1d')](function(_0x475455){if(_0x475455){_0x14ab62=_0x475455;_0x4bad7f['model']=_[_0xbca5('0x4b')](db[_0xbca5('0x139')][_0xbca5('0x46')]);_0x4bad7f[_0xbca5('0x4c')]=_[_0xbca5('0x4b')](_0x2c34ea['query']);_0x4bad7f[_0xbca5('0x4d')]=_['intersection'](_0x4bad7f[_0xbca5('0x52')],_0x4bad7f['query']);_0x2ee621['attributes']=_['intersection'](_0x4bad7f['model'],qs[_0xbca5('0x50')](_0x2c34ea[_0xbca5('0x4c')][_0xbca5('0x50')]));_0x2ee621['attributes']=_0x2ee621[_0xbca5('0x4f')][_0xbca5('0x51')]?_0x2ee621['attributes']:_0x4bad7f[_0xbca5('0x52')];_0x2ee621[_0xbca5('0x55')]=qs[_0xbca5('0x56')](_0x2c34ea[_0xbca5('0x4c')][_0xbca5('0x56')]);_0x2ee621[_0xbca5('0x57')]=qs[_0xbca5('0x4d')](_[_0xbca5('0xbf')](_0x2c34ea[_0xbca5('0x4c')],_0x4bad7f['filters']));if(_0x2c34ea['query']['filter']){_0x2ee621[_0xbca5('0x57')]=_[_0xbca5('0x58')](_0x2ee621[_0xbca5('0x57')],{'$or':_[_0xbca5('0x3b')](_0x2ee621[_0xbca5('0x4f')],function(_0x17e4a5){var _0x983815={};_0x983815[_0x17e4a5]={'$like':'%'+_0x2c34ea['query'][_0xbca5('0x39')]+'%'};return _0x983815;})});}_0x2ee621=_[_0xbca5('0x58')]({},_0x2ee621,_0x2c34ea[_0xbca5('0x5d')]);return _0x14ab62[_0xbca5('0x13a')](_0x2ee621);}})[_0xbca5('0x1d')](function(_0x1499fb){if(_0x1499fb){_0x341ac2=_0x1499fb[_0xbca5('0x51')];if(!_0x2c34ea['query'][_0xbca5('0x53')](_0xbca5('0x54'))){_0x2ee621['limit']=qs[_0xbca5('0x2b')](_0x2c34ea[_0xbca5('0x4c')][_0xbca5('0x2b')]);_0x2ee621[_0xbca5('0x2a')]=qs[_0xbca5('0x2a')](_0x2c34ea[_0xbca5('0x4c')][_0xbca5('0x2a')]);}return _0x14ab62['getFaxAccounts'](_0x2ee621);}})[_0xbca5('0x1d')](function(_0x4cdc04){if(_0x4cdc04){return _0x4cdc04?{'count':_0x341ac2,'rows':_0x4cdc04}:null;}})[_0xbca5('0x1d')](respondWithResult(_0x34cae2,null))['catch'](handleError(_0x34cae2,null));};exports[_0xbca5('0x13b')]=function(_0xb6f86e,_0x21360,_0x25d711){return db[_0xbca5('0x45')]['find']({'where':{'id':_0xb6f86e[_0xbca5('0x66')]['id']}})[_0xbca5('0x1d')](handleEntityNotFound(_0x21360,null))[_0xbca5('0x1d')](function(_0x7ecd31){if(_0x7ecd31){return _0x7ecd31[_0xbca5('0x13b')](_0xb6f86e[_0xbca5('0x65')][_0xbca5('0x69')],_['omit'](_0xb6f86e[_0xbca5('0x65')],[_0xbca5('0x69'),'id'])||{});}})['then'](respondWithResult(_0x21360,null))[_0xbca5('0x27')](handleError(_0x21360,null));};exports['removeFaxAccounts']=function(_0x3656b6,_0x4b4eec,_0x45a561){return db[_0xbca5('0x45')][_0xbca5('0x3e')]({'where':{'id':_0x3656b6['params']['id']}})[_0xbca5('0x1d')](handleEntityNotFound(_0x4b4eec,null))[_0xbca5('0x1d')](function(_0xee8d58){if(_0xee8d58){return _0xee8d58[_0xbca5('0x13c')](_0x3656b6[_0xbca5('0x4c')][_0xbca5('0x69')]);}})[_0xbca5('0x1d')](respondWithStatusCode(_0x4b4eec,null))['catch'](handleError(_0x4b4eec,null));};exports[_0xbca5('0x13d')]=function(_0x16b638,_0x3ae462,_0x25a5c6){var _0x4baf7b={};var _0x12cac3={};var _0x3cd573;var _0x28aa56;return db['User']['findOne']({'where':{'id':_0x16b638['params']['id']}})[_0xbca5('0x1d')](handleEntityNotFound(_0x3ae462,null))[_0xbca5('0x1d')](function(_0xc9f1b2){if(_0xc9f1b2){_0x3cd573=_0xc9f1b2;_0x12cac3[_0xbca5('0x52')]=_[_0xbca5('0x4b')](db[_0xbca5('0x13e')][_0xbca5('0x46')]);_0x12cac3['query']=_['keys'](_0x16b638[_0xbca5('0x4c')]);_0x12cac3[_0xbca5('0x4d')]=_[_0xbca5('0x4e')](_0x12cac3['model'],_0x12cac3[_0xbca5('0x4c')]);_0x4baf7b[_0xbca5('0x4f')]=_[_0xbca5('0x4e')](_0x12cac3[_0xbca5('0x52')],qs['fields'](_0x16b638[_0xbca5('0x4c')][_0xbca5('0x50')]));_0x4baf7b[_0xbca5('0x4f')]=_0x4baf7b[_0xbca5('0x4f')][_0xbca5('0x51')]?_0x4baf7b[_0xbca5('0x4f')]:_0x12cac3[_0xbca5('0x52')];_0x4baf7b[_0xbca5('0x55')]=qs[_0xbca5('0x56')](_0x16b638['query'][_0xbca5('0x56')]);_0x4baf7b[_0xbca5('0x57')]=qs[_0xbca5('0x4d')](_[_0xbca5('0xbf')](_0x16b638[_0xbca5('0x4c')],_0x12cac3[_0xbca5('0x4d')]));if(_0x16b638[_0xbca5('0x4c')][_0xbca5('0x39')]){_0x4baf7b[_0xbca5('0x57')]=_[_0xbca5('0x58')](_0x4baf7b[_0xbca5('0x57')],{'$or':_['map'](_0x4baf7b[_0xbca5('0x4f')],function(_0x1c1b4e){var _0x32bdac={};_0x32bdac[_0x1c1b4e]={'$like':'%'+_0x16b638[_0xbca5('0x4c')][_0xbca5('0x39')]+'%'};return _0x32bdac;})});}_0x4baf7b=_[_0xbca5('0x58')]({},_0x4baf7b,_0x16b638['options']);return _0x3cd573['getMailAccounts'](_0x4baf7b);}})[_0xbca5('0x1d')](function(_0x1551a7){if(_0x1551a7){_0x28aa56=_0x1551a7[_0xbca5('0x51')];if(!_0x16b638[_0xbca5('0x4c')][_0xbca5('0x53')](_0xbca5('0x54'))){_0x4baf7b['limit']=qs[_0xbca5('0x2b')](_0x16b638['query'][_0xbca5('0x2b')]);_0x4baf7b[_0xbca5('0x2a')]=qs[_0xbca5('0x2a')](_0x16b638[_0xbca5('0x4c')]['offset']);}return _0x3cd573[_0xbca5('0x13d')](_0x4baf7b);}})[_0xbca5('0x1d')](function(_0x3bbaf6){if(_0x3bbaf6){return _0x3bbaf6?{'count':_0x28aa56,'rows':_0x3bbaf6}:null;}})[_0xbca5('0x1d')](respondWithResult(_0x3ae462,null))[_0xbca5('0x27')](handleError(_0x3ae462,null));};exports[_0xbca5('0x13f')]=function(_0x39b9cd,_0x468bf6,_0x34ef58){return db[_0xbca5('0x45')][_0xbca5('0x3e')]({'where':{'id':_0x39b9cd[_0xbca5('0x66')]['id']}})[_0xbca5('0x1d')](handleEntityNotFound(_0x468bf6,null))[_0xbca5('0x1d')](function(_0xc7ccba){if(_0xc7ccba){return _0xc7ccba[_0xbca5('0x13f')](_0x39b9cd[_0xbca5('0x65')]['ids'],_[_0xbca5('0x6a')](_0x39b9cd[_0xbca5('0x65')],['ids','id'])||{});}})[_0xbca5('0x1d')](respondWithResult(_0x468bf6,null))['catch'](handleError(_0x468bf6,null));};exports['removeMailAccounts']=function(_0x4a1b7c,_0x2583e5,_0x1ca19e){return db[_0xbca5('0x45')][_0xbca5('0x3e')]({'where':{'id':_0x4a1b7c[_0xbca5('0x66')]['id']}})[_0xbca5('0x1d')](handleEntityNotFound(_0x2583e5,null))['then'](function(_0x49713a){if(_0x49713a){return _0x49713a['removeMailAccounts'](_0x4a1b7c['query'][_0xbca5('0x69')]);}})[_0xbca5('0x1d')](respondWithStatusCode(_0x2583e5,null))['catch'](handleError(_0x2583e5,null));};exports['getOpenchannelAccounts']=function(_0x1e313c,_0x295931,_0x1a090e){var _0x540ca9={};var _0x5139cc={};var _0x56530d;var _0x3b360b;return db[_0xbca5('0x45')][_0xbca5('0x9a')]({'where':{'id':_0x1e313c['params']['id']}})[_0xbca5('0x1d')](handleEntityNotFound(_0x295931,null))[_0xbca5('0x1d')](function(_0x3b77eb){if(_0x3b77eb){_0x56530d=_0x3b77eb;_0x5139cc[_0xbca5('0x52')]=_[_0xbca5('0x4b')](db['OpenchannelAccount'][_0xbca5('0x46')]);_0x5139cc[_0xbca5('0x4c')]=_[_0xbca5('0x4b')](_0x1e313c['query']);_0x5139cc[_0xbca5('0x4d')]=_[_0xbca5('0x4e')](_0x5139cc[_0xbca5('0x52')],_0x5139cc[_0xbca5('0x4c')]);_0x540ca9[_0xbca5('0x4f')]=_[_0xbca5('0x4e')](_0x5139cc[_0xbca5('0x52')],qs[_0xbca5('0x50')](_0x1e313c['query'][_0xbca5('0x50')]));_0x540ca9[_0xbca5('0x4f')]=_0x540ca9['attributes'][_0xbca5('0x51')]?_0x540ca9[_0xbca5('0x4f')]:_0x5139cc['model'];_0x540ca9[_0xbca5('0x55')]=qs[_0xbca5('0x56')](_0x1e313c[_0xbca5('0x4c')]['sort']);_0x540ca9['where']=qs['filters'](_[_0xbca5('0xbf')](_0x1e313c['query'],_0x5139cc[_0xbca5('0x4d')]));if(_0x1e313c['query'][_0xbca5('0x39')]){_0x540ca9[_0xbca5('0x57')]=_[_0xbca5('0x58')](_0x540ca9[_0xbca5('0x57')],{'$or':_['map'](_0x540ca9['attributes'],function(_0xe84c82){var _0x32ee03={};_0x32ee03[_0xe84c82]={'$like':'%'+_0x1e313c[_0xbca5('0x4c')][_0xbca5('0x39')]+'%'};return _0x32ee03;})});}_0x540ca9=_[_0xbca5('0x58')]({},_0x540ca9,_0x1e313c[_0xbca5('0x5d')]);return _0x56530d['getOpenchannelAccounts'](_0x540ca9);}})['then'](function(_0x433a6f){if(_0x433a6f){_0x3b360b=_0x433a6f[_0xbca5('0x51')];if(!_0x1e313c['query']['hasOwnProperty']('nolimit')){_0x540ca9[_0xbca5('0x2b')]=qs[_0xbca5('0x2b')](_0x1e313c['query'][_0xbca5('0x2b')]);_0x540ca9['offset']=qs['offset'](_0x1e313c[_0xbca5('0x4c')][_0xbca5('0x2a')]);}return _0x56530d['getOpenchannelAccounts'](_0x540ca9);}})['then'](function(_0x288456){if(_0x288456){return _0x288456?{'count':_0x3b360b,'rows':_0x288456}:null;}})['then'](respondWithResult(_0x295931,null))[_0xbca5('0x27')](handleError(_0x295931,null));};exports[_0xbca5('0x140')]=function(_0x51f7a6,_0x4fdffd,_0xef8f9c){return db['User'][_0xbca5('0x3e')]({'where':{'id':_0x51f7a6[_0xbca5('0x66')]['id']}})[_0xbca5('0x1d')](handleEntityNotFound(_0x4fdffd,null))['then'](function(_0x32930f){if(_0x32930f){return _0x32930f[_0xbca5('0x140')](_0x51f7a6[_0xbca5('0x65')]['ids'],_['omit'](_0x51f7a6[_0xbca5('0x65')],[_0xbca5('0x69'),'id'])||{});}})[_0xbca5('0x1d')](respondWithResult(_0x4fdffd,null))[_0xbca5('0x27')](handleError(_0x4fdffd,null));};exports[_0xbca5('0x141')]=function(_0x9451a3,_0x21f6d9,_0x3e735b){return db[_0xbca5('0x45')][_0xbca5('0x3e')]({'where':{'id':_0x9451a3['params']['id']}})['then'](handleEntityNotFound(_0x21f6d9,null))[_0xbca5('0x1d')](function(_0x220786){if(_0x220786){return _0x220786[_0xbca5('0x141')](_0x9451a3['query'][_0xbca5('0x69')]);}})['then'](respondWithStatusCode(_0x21f6d9,null))['catch'](handleError(_0x21f6d9,null));};exports[_0xbca5('0x142')]=function(_0x1d81b6,_0x194023,_0x3fd9f0){var _0x11b427={};var _0x30ff5f={};var _0x142385;var _0x1be386;return db[_0xbca5('0x45')][_0xbca5('0x9a')]({'where':{'id':_0x1d81b6['params']['id']}})[_0xbca5('0x1d')](handleEntityNotFound(_0x194023,null))[_0xbca5('0x1d')](function(_0x1dbc37){if(_0x1dbc37){_0x142385=_0x1dbc37;_0x30ff5f[_0xbca5('0x52')]=_[_0xbca5('0x4b')](db[_0xbca5('0x143')]['rawAttributes']);_0x30ff5f['query']=_[_0xbca5('0x4b')](_0x1d81b6[_0xbca5('0x4c')]);_0x30ff5f[_0xbca5('0x4d')]=_[_0xbca5('0x4e')](_0x30ff5f['model'],_0x30ff5f[_0xbca5('0x4c')]);_0x11b427[_0xbca5('0x4f')]=_[_0xbca5('0x4e')](_0x30ff5f[_0xbca5('0x52')],qs[_0xbca5('0x50')](_0x1d81b6[_0xbca5('0x4c')]['fields']));_0x11b427[_0xbca5('0x4f')]=_0x11b427[_0xbca5('0x4f')][_0xbca5('0x51')]?_0x11b427[_0xbca5('0x4f')]:_0x30ff5f[_0xbca5('0x52')];_0x11b427[_0xbca5('0x55')]=qs[_0xbca5('0x56')](_0x1d81b6[_0xbca5('0x4c')][_0xbca5('0x56')]);_0x11b427[_0xbca5('0x57')]=qs['filters'](_[_0xbca5('0xbf')](_0x1d81b6[_0xbca5('0x4c')],_0x30ff5f['filters']));if(_0x1d81b6['query'][_0xbca5('0x39')]){_0x11b427[_0xbca5('0x57')]=_[_0xbca5('0x58')](_0x11b427[_0xbca5('0x57')],{'$or':_[_0xbca5('0x3b')](_0x11b427['attributes'],function(_0x5d084b){var _0x3b65c9={};_0x3b65c9[_0x5d084b]={'$like':'%'+_0x1d81b6[_0xbca5('0x4c')][_0xbca5('0x39')]+'%'};return _0x3b65c9;})});}_0x11b427=_[_0xbca5('0x58')]({},_0x11b427,_0x1d81b6[_0xbca5('0x5d')]);return _0x142385[_0xbca5('0x142')](_0x11b427);}})[_0xbca5('0x1d')](function(_0x550f5c){if(_0x550f5c){_0x1be386=_0x550f5c['length'];if(!_0x1d81b6[_0xbca5('0x4c')][_0xbca5('0x53')](_0xbca5('0x54'))){_0x11b427['limit']=qs['limit'](_0x1d81b6[_0xbca5('0x4c')][_0xbca5('0x2b')]);_0x11b427[_0xbca5('0x2a')]=qs[_0xbca5('0x2a')](_0x1d81b6['query'][_0xbca5('0x2a')]);}return _0x142385['getSmsAccounts'](_0x11b427);}})[_0xbca5('0x1d')](function(_0x18dfdc){if(_0x18dfdc){return _0x18dfdc?{'count':_0x1be386,'rows':_0x18dfdc}:null;}})[_0xbca5('0x1d')](respondWithResult(_0x194023,null))[_0xbca5('0x27')](handleError(_0x194023,null));};exports['addSmsAccounts']=function(_0x5df29b,_0x205867,_0x18b576){return db[_0xbca5('0x45')]['find']({'where':{'id':_0x5df29b[_0xbca5('0x66')]['id']}})[_0xbca5('0x1d')](handleEntityNotFound(_0x205867,null))[_0xbca5('0x1d')](function(_0x59e5da){if(_0x59e5da){return _0x59e5da[_0xbca5('0x144')](_0x5df29b[_0xbca5('0x65')][_0xbca5('0x69')],_[_0xbca5('0x6a')](_0x5df29b[_0xbca5('0x65')],[_0xbca5('0x69'),'id'])||{});}})[_0xbca5('0x1d')](respondWithResult(_0x205867,null))[_0xbca5('0x27')](handleError(_0x205867,null));};exports[_0xbca5('0x145')]=function(_0x4cde24,_0x1809b5,_0x5cb30a){return db[_0xbca5('0x45')][_0xbca5('0x3e')]({'where':{'id':_0x4cde24[_0xbca5('0x66')]['id']}})[_0xbca5('0x1d')](handleEntityNotFound(_0x1809b5,null))[_0xbca5('0x1d')](function(_0x5c1ea9){if(_0x5c1ea9){return _0x5c1ea9[_0xbca5('0x145')](_0x4cde24[_0xbca5('0x4c')][_0xbca5('0x69')]);}})[_0xbca5('0x1d')](respondWithStatusCode(_0x1809b5,null))[_0xbca5('0x27')](handleError(_0x1809b5,null));};exports[_0xbca5('0x146')]=function(_0x2c0dd3,_0x29ac91,_0x57b486){var _0x5f2a75={};var _0x3d47d0={};var _0x288506;var _0x4a6395;return db['User'][_0xbca5('0x9a')]({'where':{'id':_0x2c0dd3[_0xbca5('0x66')]['id']}})['then'](handleEntityNotFound(_0x29ac91,null))[_0xbca5('0x1d')](function(_0x5ccda1){if(_0x5ccda1){_0x288506=_0x5ccda1;_0x3d47d0[_0xbca5('0x52')]=_[_0xbca5('0x4b')](db[_0xbca5('0x147')][_0xbca5('0x46')]);_0x3d47d0[_0xbca5('0x4c')]=_['keys'](_0x2c0dd3['query']);_0x3d47d0[_0xbca5('0x4d')]=_['intersection'](_0x3d47d0[_0xbca5('0x52')],_0x3d47d0[_0xbca5('0x4c')]);_0x5f2a75['attributes']=_[_0xbca5('0x4e')](_0x3d47d0[_0xbca5('0x52')],qs[_0xbca5('0x50')](_0x2c0dd3['query'][_0xbca5('0x50')]));_0x5f2a75[_0xbca5('0x4f')]=_0x5f2a75[_0xbca5('0x4f')][_0xbca5('0x51')]?_0x5f2a75[_0xbca5('0x4f')]:_0x3d47d0[_0xbca5('0x52')];_0x5f2a75['order']=qs[_0xbca5('0x56')](_0x2c0dd3['query']['sort']);_0x5f2a75[_0xbca5('0x57')]=qs[_0xbca5('0x4d')](_[_0xbca5('0xbf')](_0x2c0dd3[_0xbca5('0x4c')],_0x3d47d0['filters']));if(_0x2c0dd3[_0xbca5('0x4c')][_0xbca5('0x39')]){_0x5f2a75[_0xbca5('0x57')]=_[_0xbca5('0x58')](_0x5f2a75[_0xbca5('0x57')],{'$or':_[_0xbca5('0x3b')](_0x5f2a75['attributes'],function(_0x2c258f){var _0x229a78={};_0x229a78[_0x2c258f]={'$like':'%'+_0x2c0dd3[_0xbca5('0x4c')][_0xbca5('0x39')]+'%'};return _0x229a78;})});}_0x5f2a75=_[_0xbca5('0x58')]({},_0x5f2a75,_0x2c0dd3[_0xbca5('0x5d')]);return _0x288506[_0xbca5('0x146')](_0x5f2a75);}})['then'](function(_0x450ea5){if(_0x450ea5){_0x4a6395=_0x450ea5['length'];if(!_0x2c0dd3[_0xbca5('0x4c')][_0xbca5('0x53')](_0xbca5('0x54'))){_0x5f2a75[_0xbca5('0x2b')]=qs['limit'](_0x2c0dd3[_0xbca5('0x4c')][_0xbca5('0x2b')]);_0x5f2a75['offset']=qs[_0xbca5('0x2a')](_0x2c0dd3[_0xbca5('0x4c')][_0xbca5('0x2a')]);}return _0x288506[_0xbca5('0x146')](_0x5f2a75);}})['then'](function(_0x21189c){if(_0x21189c){return _0x21189c?{'count':_0x4a6395,'rows':_0x21189c}:null;}})[_0xbca5('0x1d')](respondWithResult(_0x29ac91,null))[_0xbca5('0x27')](handleError(_0x29ac91,null));};exports[_0xbca5('0x148')]=function(_0x2dae82,_0x1c43d4,_0x5e5465){return db[_0xbca5('0x45')][_0xbca5('0x3e')]({'where':{'id':_0x2dae82[_0xbca5('0x66')]['id']}})[_0xbca5('0x1d')](handleEntityNotFound(_0x1c43d4,null))['then'](function(_0x54dc69){if(_0x54dc69){return _0x54dc69[_0xbca5('0x148')](_0x2dae82['body'][_0xbca5('0x69')],_[_0xbca5('0x6a')](_0x2dae82[_0xbca5('0x65')],[_0xbca5('0x69'),'id'])||{});}})[_0xbca5('0x1d')](respondWithResult(_0x1c43d4,null))[_0xbca5('0x27')](handleError(_0x1c43d4,null));};exports[_0xbca5('0x149')]=function(_0x35a737,_0x1a0948,_0x3390a1){return db[_0xbca5('0x45')][_0xbca5('0x3e')]({'where':{'id':_0x35a737['params']['id']}})[_0xbca5('0x1d')](handleEntityNotFound(_0x1a0948,null))['then'](function(_0x1f2e78){if(_0x1f2e78){return _0x1f2e78[_0xbca5('0x149')](_0x35a737['query'][_0xbca5('0x69')]);}})[_0xbca5('0x1d')](respondWithStatusCode(_0x1a0948,null))[_0xbca5('0x27')](handleError(_0x1a0948,null));};exports[_0xbca5('0x14a')]=function(_0x361758,_0x49ef49,_0xadef44){var _0x3321c7={};var _0x582c7c={};var _0x33ffb6;var _0x3ebbcf;return db[_0xbca5('0x45')][_0xbca5('0x9a')]({'where':{'id':_0x361758[_0xbca5('0x66')]['id']}})['then'](handleEntityNotFound(_0x49ef49,null))['then'](function(_0x56bb74){if(_0x56bb74){_0x33ffb6=_0x56bb74;_0x582c7c[_0xbca5('0x52')]=_[_0xbca5('0x4b')](db[_0xbca5('0x14b')][_0xbca5('0x46')]);_0x582c7c[_0xbca5('0x4c')]=_[_0xbca5('0x4b')](_0x361758[_0xbca5('0x4c')]);_0x582c7c['filters']=_['intersection'](_0x582c7c['model'],_0x582c7c[_0xbca5('0x4c')]);_0x3321c7[_0xbca5('0x4f')]=_[_0xbca5('0x4e')](_0x582c7c['model'],qs[_0xbca5('0x50')](_0x361758[_0xbca5('0x4c')][_0xbca5('0x50')]));_0x3321c7[_0xbca5('0x4f')]=_0x3321c7[_0xbca5('0x4f')][_0xbca5('0x51')]?_0x3321c7[_0xbca5('0x4f')]:_0x582c7c[_0xbca5('0x52')];_0x3321c7['order']=qs[_0xbca5('0x56')](_0x361758[_0xbca5('0x4c')][_0xbca5('0x56')]);_0x3321c7[_0xbca5('0x57')]=qs[_0xbca5('0x4d')](_[_0xbca5('0xbf')](_0x361758[_0xbca5('0x4c')],_0x582c7c['filters']));if(_0x361758[_0xbca5('0x4c')][_0xbca5('0x39')]){_0x3321c7['where']=_[_0xbca5('0x58')](_0x3321c7[_0xbca5('0x57')],{'$or':_[_0xbca5('0x3b')](_0x3321c7['attributes'],function(_0x34abd3){var _0xe86f3b={};_0xe86f3b[_0x34abd3]={'$like':'%'+_0x361758[_0xbca5('0x4c')][_0xbca5('0x39')]+'%'};return _0xe86f3b;})});}_0x3321c7=_[_0xbca5('0x58')]({},_0x3321c7,_0x361758[_0xbca5('0x5d')]);return _0x33ffb6['getWhatsappAccounts'](_0x3321c7);}})[_0xbca5('0x1d')](function(_0x3df5ed){if(_0x3df5ed){_0x3ebbcf=_0x3df5ed[_0xbca5('0x51')];if(!_0x361758[_0xbca5('0x4c')]['hasOwnProperty'](_0xbca5('0x54'))){_0x3321c7[_0xbca5('0x2b')]=qs[_0xbca5('0x2b')](_0x361758[_0xbca5('0x4c')][_0xbca5('0x2b')]);_0x3321c7[_0xbca5('0x2a')]=qs['offset'](_0x361758[_0xbca5('0x4c')]['offset']);}return _0x33ffb6[_0xbca5('0x14a')](_0x3321c7);}})['then'](function(_0x18b388){if(_0x18b388){return _0x18b388?{'count':_0x3ebbcf,'rows':_0x18b388}:null;}})['then'](respondWithResult(_0x49ef49,null))[_0xbca5('0x27')](handleError(_0x49ef49,null));};exports['addWhatsappAccounts']=function(_0x4f4f87,_0x1dfb2b,_0x5434f1){return db['User']['find']({'where':{'id':_0x4f4f87['params']['id']}})[_0xbca5('0x1d')](handleEntityNotFound(_0x1dfb2b,null))[_0xbca5('0x1d')](function(_0x40e686){if(_0x40e686){return _0x40e686['addWhatsappAccounts'](_0x4f4f87[_0xbca5('0x65')]['ids'],_[_0xbca5('0x6a')](_0x4f4f87[_0xbca5('0x65')],[_0xbca5('0x69'),'id'])||{});}})[_0xbca5('0x1d')](respondWithResult(_0x1dfb2b,null))[_0xbca5('0x27')](handleError(_0x1dfb2b,null));};exports['removeWhatsappAccounts']=function(_0x421304,_0x1d1334,_0x2cec87){return db[_0xbca5('0x45')]['find']({'where':{'id':_0x421304['params']['id']}})[_0xbca5('0x1d')](handleEntityNotFound(_0x1d1334,null))[_0xbca5('0x1d')](function(_0x507b55){if(_0x507b55){return _0x507b55[_0xbca5('0x14c')](_0x421304['query'][_0xbca5('0x69')]);}})[_0xbca5('0x1d')](respondWithStatusCode(_0x1d1334,null))[_0xbca5('0x27')](handleError(_0x1d1334,null));};exports[_0xbca5('0x14d')]=function(_0x545ff1,_0x47efff,_0x346a00){var _0xfa4c34={};var _0x19fce6={};var _0x1098d0;var _0x12d76b;return db[_0xbca5('0x45')]['findOne']({'where':{'id':_0x545ff1[_0xbca5('0x66')]['id']}})['then'](handleEntityNotFound(_0x47efff,null))[_0xbca5('0x1d')](function(_0x260abe){if(_0x260abe){_0x1098d0=_0x260abe;_0x19fce6[_0xbca5('0x52')]=_[_0xbca5('0x4b')](db[_0xbca5('0x14e')][_0xbca5('0x46')]);_0x19fce6[_0xbca5('0x4c')]=_[_0xbca5('0x4b')](_0x545ff1['query']);_0x19fce6[_0xbca5('0x4d')]=_[_0xbca5('0x4e')](_0x19fce6['model'],_0x19fce6[_0xbca5('0x4c')]);_0xfa4c34['attributes']=_['intersection'](_0x19fce6['model'],qs[_0xbca5('0x50')](_0x545ff1[_0xbca5('0x4c')][_0xbca5('0x50')]));_0xfa4c34[_0xbca5('0x4f')]=_0xfa4c34['attributes']['length']?_0xfa4c34[_0xbca5('0x4f')]:_0x19fce6[_0xbca5('0x52')];_0xfa4c34[_0xbca5('0x55')]=qs[_0xbca5('0x56')](_0x545ff1[_0xbca5('0x4c')][_0xbca5('0x56')]);_0xfa4c34['where']=qs[_0xbca5('0x4d')](_['pick'](_0x545ff1[_0xbca5('0x4c')],_0x19fce6[_0xbca5('0x4d')]));if(_0x545ff1['query']['filter']){_0xfa4c34['where']=_[_0xbca5('0x58')](_0xfa4c34['where'],{'$or':_[_0xbca5('0x3b')](_0xfa4c34[_0xbca5('0x4f')],function(_0x86991f){var _0x1ef0f0={};_0x1ef0f0[_0x86991f]={'$like':'%'+_0x545ff1[_0xbca5('0x4c')][_0xbca5('0x39')]+'%'};return _0x1ef0f0;})});}_0xfa4c34=_['merge']({},_0xfa4c34,_0x545ff1[_0xbca5('0x5d')]);return _0x1098d0[_0xbca5('0x14d')](_0xfa4c34);}})[_0xbca5('0x1d')](function(_0x56bfa4){if(_0x56bfa4){_0x12d76b=_0x56bfa4['length'];if(!_0x545ff1['query']['hasOwnProperty'](_0xbca5('0x54'))){_0xfa4c34[_0xbca5('0x2b')]=qs['limit'](_0x545ff1[_0xbca5('0x4c')][_0xbca5('0x2b')]);_0xfa4c34['offset']=qs['offset'](_0x545ff1[_0xbca5('0x4c')][_0xbca5('0x2a')]);}return _0x1098d0['getSquareProjects'](_0xfa4c34);}})['then'](function(_0x51c01f){if(_0x51c01f){return _0x51c01f?{'count':_0x12d76b,'rows':_0x51c01f}:null;}})[_0xbca5('0x1d')](respondWithResult(_0x47efff,null))[_0xbca5('0x27')](handleError(_0x47efff,null));};exports[_0xbca5('0x14f')]=function(_0x4f126f,_0x1355ef,_0x15cdcc){return db[_0xbca5('0x45')][_0xbca5('0x3e')]({'where':{'id':_0x4f126f['params']['id']}})[_0xbca5('0x1d')](handleEntityNotFound(_0x1355ef,null))['then'](function(_0x186485){if(_0x186485){return _0x186485[_0xbca5('0x14f')](_0x4f126f[_0xbca5('0x65')][_0xbca5('0x69')],_[_0xbca5('0x6a')](_0x4f126f[_0xbca5('0x65')],[_0xbca5('0x69'),'id'])||{});}})[_0xbca5('0x1d')](respondWithResult(_0x1355ef,null))[_0xbca5('0x27')](handleError(_0x1355ef,null));};exports[_0xbca5('0x150')]=function(_0x56b83d,_0x5c4e1f,_0x5a5db1){return db['User'][_0xbca5('0x3e')]({'where':{'id':_0x56b83d[_0xbca5('0x66')]['id']}})[_0xbca5('0x1d')](handleEntityNotFound(_0x5c4e1f,null))[_0xbca5('0x1d')](function(_0x2c0fe6){if(_0x2c0fe6){return _0x2c0fe6['removeSquareProjects'](_0x56b83d[_0xbca5('0x4c')][_0xbca5('0x69')]);}})[_0xbca5('0x1d')](respondWithStatusCode(_0x5c4e1f,null))['catch'](handleError(_0x5c4e1f,null));};exports[_0xbca5('0x151')]=function(_0x472f32,_0x42a67a){var _0x4db569={},_0x4d954e={},_0x470ebe={'count':0x0,'rows':[]};var _0x59d6a7=db[_0xbca5('0x152')][_0xbca5('0x46')];_0x4d954e[_0xbca5('0x52')]=_[_0xbca5('0x4b')](_0x59d6a7);_0x4d954e['query']=_['keys'](_0x472f32[_0xbca5('0x4c')]);_0x4d954e[_0xbca5('0x4d')]=_['intersection'](_0x4d954e[_0xbca5('0x52')],_0x4d954e[_0xbca5('0x4c')]);_0x4d954e['filters']=_['concat'](_0x4d954e[_0xbca5('0x4d')],[_0xbca5('0x153'),_0xbca5('0x154'),_0xbca5('0x155'),_0xbca5('0x156'),_0xbca5('0x157'),'$lte',_0xbca5('0x158'),_0xbca5('0x159'),_0xbca5('0x15a'),_0xbca5('0x15b'),'$notBetween',_0xbca5('0x15c'),_0xbca5('0x15d'),_0xbca5('0x15e'),'$notLike',_0xbca5('0x15f'),_0xbca5('0x160'),_0xbca5('0x15e'),_0xbca5('0x161'),_0xbca5('0x162'),_0xbca5('0x163'),'$any']);_0x4db569[_0xbca5('0x4f')]=_['intersection'](_0x4d954e[_0xbca5('0x52')],qs[_0xbca5('0x50')](_0x472f32[_0xbca5('0x4c')][_0xbca5('0x50')]));_0x4db569[_0xbca5('0x4f')]=_0x4db569[_0xbca5('0x4f')][_0xbca5('0x51')]?_0x4db569[_0xbca5('0x4f')]:_0x4d954e[_0xbca5('0x52')];if(!_0x472f32[_0xbca5('0x4c')][_0xbca5('0x53')](_0xbca5('0x54'))){_0x4db569[_0xbca5('0x2b')]=qs[_0xbca5('0x2b')](_0x472f32['query'][_0xbca5('0x2b')]);_0x4db569['offset']=qs[_0xbca5('0x2a')](_0x472f32[_0xbca5('0x4c')]['offset']);}_0x4db569[_0xbca5('0x55')]=qs[_0xbca5('0x56')](_0x472f32['query']['sort']);_0x4db569[_0xbca5('0x57')]=qs['filters'](_['pick'](_0x472f32[_0xbca5('0x4c')],_0x4d954e[_0xbca5('0x4d')]));if(_0x472f32['query'][_0xbca5('0x39')]){_0x4db569[_0xbca5('0x57')]=_[_0xbca5('0x58')](_0x4db569[_0xbca5('0x57')],{'$or':_[_0xbca5('0x3b')](_0x4db569['attributes'],function(_0x445955){var _0x1214b0={};_0x1214b0[_0x445955]={'$like':'%'+_0x472f32[_0xbca5('0x4c')][_0xbca5('0x39')]+'%'};return _0x1214b0;})});}_0x4db569[_0xbca5('0x57')]={'$and':[_0x4db569[_0xbca5('0x57')],{'$or':[{'UserId':_0x472f32['params']['id']},{'OwnerId':_0x472f32[_0xbca5('0x66')]['id']}]}]};_0x4db569=_[_0xbca5('0x58')]({},_0x4db569,_0x472f32[_0xbca5('0x5d')]);var _0x5be984={'where':_0x4db569[_0xbca5('0x57')]};return db['CmHopper'][_0xbca5('0x29')](_0x5be984)[_0xbca5('0x1d')](function(_0x3e68fd){_0x470ebe['count']=_0x3e68fd;if(_0x472f32['query'][_0xbca5('0x5e')]){_0x4db569[_0xbca5('0x5f')]=[{'attributes':['id',_0xbca5('0x164'),_0xbca5('0x165'),_0xbca5('0xdb')],'model':db[_0xbca5('0xbe')],'as':_0xbca5('0x166')},{'attributes':['id',_0xbca5('0x3f'),_0xbca5('0x167')],'model':db[_0xbca5('0x168')],'as':_0xbca5('0xc7')}];}return db['CmHopper']['findAll'](_0x4db569);})[_0xbca5('0x1d')](function(_0x11ff69){_0x470ebe['rows']=_0x11ff69;return _0x470ebe;})[_0xbca5('0x1d')](respondWithFilteredResult(_0x42a67a,_0x4db569))['catch'](handleError(_0x42a67a,null));};exports[_0xbca5('0x169')]=function(_0x4704e7,_0x43c404,_0x2bf6aa){if(!_[_0xbca5('0x71')](_0x4704e7['user']['id'])&&(_0x4704e7[_0xbca5('0x36')][_0xbca5('0x33')]==_0xbca5('0x34')||_0x4704e7[_0xbca5('0x36')][_0xbca5('0x33')]==_0xbca5('0x36'))){return db[_0xbca5('0x45')][_0xbca5('0x9a')]({'where':{'id':_0x4704e7[_0xbca5('0x66')]['id']},'raw':!![]})[_0xbca5('0x1d')](function(_0x5d2339){return authService[_0xbca5('0x16a')](_0x5d2339);})[_0xbca5('0x1d')](function(_0x3924e5){if(_0x3924e5){return _0x43c404[_0xbca5('0x41')](0xc8)[_0xbca5('0x2e')]({'api_key':_0x3924e5[_0xbca5('0x16b')]});}else{return _0x43c404['status'](0xcc)[_0xbca5('0x2e')]({'message':_0xbca5('0x16c')});}})[_0xbca5('0x27')](handleError(_0x43c404,0x193));}else{return _0x43c404[_0xbca5('0x41')](0x191)[_0xbca5('0x2e')]({'message':_0xbca5('0x16d')});}};exports[_0xbca5('0x16e')]=function(_0x48f035,_0x174c06,_0x2b2338){if(!_['isNil'](_0x48f035[_0xbca5('0x36')]['id'])&&(_0x48f035[_0xbca5('0x36')][_0xbca5('0x33')]=='admin'||_0x48f035[_0xbca5('0x36')][_0xbca5('0x33')]==_0xbca5('0x36'))){return db[_0xbca5('0x45')][_0xbca5('0x3e')]({'where':{'id':_0x48f035['params']['id']}})['then'](function(_0x2b0b7b){return authService[_0xbca5('0x16f')](_0x2b0b7b);})[_0xbca5('0x1d')](function(_0x2a1f2c){return db[_0xbca5('0x45')][_0xbca5('0x64')]({'apiKeyIat':_0x2a1f2c[_0xbca5('0x170')],'apiKeyNonce':_0x2a1f2c[_0xbca5('0x171')]},{'where':{'id':_0x48f035['params']['id']}})[_0xbca5('0x1d')](function(){return _0x174c06['status'](0xc8)[_0xbca5('0x2e')]({'api_key':_0x2a1f2c[_0xbca5('0x16b')]});});})[_0xbca5('0x27')](handleError(_0x174c06,0x193));}else{return _0x174c06[_0xbca5('0x41')](0x191)['json']({'message':'You\x20don\x27t\x20have\x20sufficient\x20privileges\x20to\x20access\x20this\x20resource.'});}};exports[_0xbca5('0x172')]=function(_0x1e71a1,_0x446d4e,_0x6328e){if(!_[_0xbca5('0x71')](_0x1e71a1['user']['id'])&&(_0x1e71a1[_0xbca5('0x36')]['role']==_0xbca5('0x34')||_0x1e71a1[_0xbca5('0x36')]['role']==_0xbca5('0x36'))){return db[_0xbca5('0x45')][_0xbca5('0x3e')]({'where':{'id':_0x1e71a1[_0xbca5('0x66')]['id']}})[_0xbca5('0x1d')](handleEntityNotFound(_0x446d4e,null))[_0xbca5('0x1d')](function(_0x3b2b02){if(_0x3b2b02&&_0x3b2b02[_0xbca5('0x173')]&&_0x3b2b02[_0xbca5('0x174')])return _0x3b2b02;else throw{'message':_0xbca5('0x175')};})['then'](function(_0x38da01){return db[_0xbca5('0x45')][_0xbca5('0x64')]({'apiKeyNonce':null,'apiKeyIat':null},{'where':{'id':_0x1e71a1[_0xbca5('0x66')]['id']}});})['then'](respondWithStatusCode(_0x446d4e,0xc8))[_0xbca5('0x27')](handleError(_0x446d4e,0x193));}else{return _0x446d4e[_0xbca5('0x41')](0x191)[_0xbca5('0x2e')]({'message':_0xbca5('0x16d')});}};exports['whoami']=function(_0x492708,_0x5b0e68){var _0x5a3ac3=_0x492708['user'][_0xbca5('0x32')]({'plain':!![]});if(!_0x5a3ac3){return _0x5b0e68[_0xbca5('0x41')](0x191)[_0xbca5('0x43')](_0xbca5('0x176'));}else{return _0x5b0e68[_0xbca5('0x41')](0xc8)[_0xbca5('0x2e')](_0x5a3ac3);}};
\ No newline at end of file
+var _0x98b4=['../../components/contacts','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../errors/api','APIBadRequestError','handleError','../../mysqldb','socket.io-emitter','redis','./user.socket','register','defaults','localhost','client','http','sendStatus','status','end','json','offset','limit','count','set','update','then','role','agent','emit','userNotification:recalc:','destroy','get','admin','Users','user','Agents','Telephones','telephone','filter','value','name','UserProfileResource','error','send','rawAttributes','fieldName','type','key','salt','resetPasswordExpires','md5secret','includes','index','where','User','includeAll','userSetting','true','include','attributes','rows','openTabs','length','push','dataValues','sms','fax','mail','all','catch','show','query','params','getOptions','merge','find','chat','openchannel','body','describe','addContacts','findById','validatePasswordPattern','password','max','internal','isNil','min_internal','sequelize','SELECT','from','voicemail','mailbox','fullname','email','permissions','101','102','113','110','104','106','109','100','114','create','Unauthorized.\x20You\x20must\x20be\x20an\x20administrator\x20in\x20order\x20to\x20create\x20an\x20user','Unauthorized.\x20You\x20must\x20be\x20an\x20administrator\x20in\x20order\x20to\x20create\x20another\x20administrator','settingsEnabled','userProfileId','VoiceMail','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','some','Unauthorized.\x20You\x20must\x20be\x20an\x20administrator\x20in\x20order\x20to\x20create\x20an\x20administrator','UserProfileSection','isEmpty','map','compact','changePassword','oldPassword','newPassword','ValidationError','Sequelize','New\x20password\x20must\x20be\x20different\x20from\x20old\x20password','Invalid\x20body\x20format.\x20Use\x20newPassword','Unauthorized','Setting','securePassword','enforcePasswordHistory','passwordHistoryLimit','previousPasswords','validatePasswordHistory','updatePasswordsHistory','channel','loginInPause','voicePause','interface','isValidChannel','Unknown\x20channel','add','capitalize','Queues','ids','penalty','toLowerCase','QueueId','Queue:save','voice','VoiceQueue','findAll','online','format','SIP/%s','UserVoiceQueueRt','removeQueues','remove','Queue:remove','addAvatar','userpic','file','join','server/files/images/logos/default_profile.png','root','server/files/images/','download','getOpenTabs','whatsapp','ChatOpenTabs','CHAT','createdAt','FaxOpenTabs','FAX','OpenchannelOpenTabs','OPENCHANNEL','MailOpenTabs','MAIL','SMS','concat','getContacts','findOne','User\x20with\x20id\x20%s\x20not\x20found','hasOwnProperty','CmList','List','Tag','Tags','color','tag','keys','Queue','intersection','model','fields','order','sort','filters','pick','options','Unknown\x20role','getVoiceQueuesRt','getGroups','ChatGroup','nolimit','VoiceRecording','getScreenRecordings','ScreenRecording','ChatInteraction','getChatInteractions','OpenchannelInteraction','getOpenchannelInteractions','getMailInteractions','MailInteraction','UserId','getSmsInteractions','SmsInteraction','getFaxInteractions','FaxInteraction','getWhatsappInteractions','WhatsappInteraction','phone','mobile','LOCAL/%s@from-sip/n','intrf','user:%s','user:forcelogout','headers','x-forwarded-for','connection','remoteAddress','socket','User\x20not\x20found\x20or\x20not\x20allowed\x20to\x20perform\x20login\x20method','getVoiceQueues','MemberReport','YYYY-MM-DD\x20HH:mm:ss','getChannels','device','PAUSE','bulkCreate','LOGININPAUSE','isMiddleware','resolve','logout','forEach','pause','updateAttributes','DEFAULT\x20PAUSE','unpause','Channel\x20parameter\x20%s\x20is\x20invalid','mailPause','chatPause','faxPause','openchannelPause','smsPause','pauseType','Team','addTeams','Body\x20parameter\x20\x27ids\x27\x20is\x20required','getAssociatedQueues','flattenDeep','addAgent','Voice','upsert','UserVoicePrefix','getDataValue','removeTeams','isArray','Query\x20parameter\x20\x27ids\x27\x20is\x20required','transaction','removeAgent','VoicePrefixId','getLists','getAgents','values','addChatInteractions','omit','spread','user_has_chat_interactions:save','removeChatInteractions','user_has_chat_interactions:remove','removeMailInteractions','addFaxInteractions','removeFaxInteractions','user_has_fax_interactions:remove','addSmsInteractions','removeSmsInteractions','user_has_sms_interactions:remove','addOpenchannelInteractions','user_has_openchannel_interactions:save','removeOpenchannelInteractions','user_has_openchannel_interactions:remove','addWhatsappInteractions','removeWhatsappInteractions','getVoicePrefixes','VoicePrefix','getFaxAccounts','FaxAccount','addFaxAccounts','removeFaxAccounts','getMailAccounts','MailAccount','addMailAccounts','removeMailAccounts','getOpenchannelAccounts','addOpenchannelAccounts','removeOpenchannelAccounts','SmsAccount','getSmsAccounts','addSmsAccounts','removeSmsAccounts','getChatWebsites','ChatWebsite','addChatWebsites','getWhatsappAccounts','WhatsappAccount','addWhatsappAccounts','removeWhatsappAccounts','getScheduledCalls','$and','$gt','$gte','$lte','$eq','$between','$notBetween','$in','$notIn','$like','$notLike','$iLike','$notILike','$overlap','$contains','$any','CmHopper','firstName','lastName','CmContact','Contact','dialActive','getApiKey','retrieveApiKey','You\x20don\x27t\x20have\x20sufficient\x20privileges\x20to\x20access\x20this\x20resource.','generateApiKey','nonce','apiKeyNonce','apiKeyIat','API\x20key\x20not\x20available','Unable\x20to\x20retrieve\x20the\x20current\x20user','getUserSetting','getPresence','queues','teams','inbound','flatten','lower','col','toString','asc','request','result','Unable\x20to\x20retrieve\x20RPC\x20agents\x20(Routing)','offline','idle','unknown','unavailable','ringing','voiceStatus','slice','QueryTypes','select','ui.','InteractionId','ui.createdAt','user_has_','_interactions','ui.UserId\x20=\x20?','moment','path','squel','jayson/promise','../../components/auth/service'];(function(_0x291981,_0x5a951c){var _0x31a8fe=function(_0x4eca83){while(--_0x4eca83){_0x291981['push'](_0x291981['shift']());}};_0x31a8fe(++_0x5a951c);}(_0x98b4,0x17b));var _0x498b=function(_0x344a3f,_0x579a22){_0x344a3f=_0x344a3f-0x0;var _0x264712=_0x98b4[_0x344a3f];return _0x264712;};'use strict';var moment=require(_0x498b('0x0'));var util=require('util');var path=require(_0x498b('0x1'));var fs=require('fs');var _=require('lodash');var squel=require(_0x498b('0x2'));var jayson=require(_0x498b('0x3'));var Redis=require('ioredis');var authService=require(_0x498b('0x4'));var contacts=require(_0x498b('0x5'));var qs=require('../../components/parsers/qs');var logger=require(_0x498b('0x6'))(_0x498b('0x7'));var utils=require(_0x498b('0x8'));var config=require(_0x498b('0x9'));var licenseUtil=require(_0x498b('0xa'));var APIBadRequestError=require(_0x498b('0xb'))[_0x498b('0xc')];var APINotFoundError=require('../../errors/api')['APINotFoundError'];var APIHandleError=require('../../errors/api')[_0x498b('0xd')];var db=require(_0x498b('0xe'))['db'];var socket=require(_0x498b('0xf'))(new Redis(config[_0x498b('0x10')]));require(_0x498b('0x11'))[_0x498b('0x12')](socket);config[_0x498b('0x10')]=_[_0x498b('0x13')](config[_0x498b('0x10')],{'host':_0x498b('0x14'),'port':0x18eb});var amiClient=jayson[_0x498b('0x15')][_0x498b('0x16')]({'port':0x232a});var values;function respondWithStatusCode(_0x3d691b,_0x1db60c){_0x1db60c=_0x1db60c||0xcc;return function(_0x5e3238){if(_0x5e3238){return _0x3d691b[_0x498b('0x17')](_0x1db60c);}return _0x3d691b[_0x498b('0x18')](_0x1db60c)[_0x498b('0x19')]();};}function respondWithResult(_0x38a0da,_0x38c77c){_0x38c77c=_0x38c77c||0xc8;return function(_0xc8cff5){if(_0xc8cff5){return _0x38a0da[_0x498b('0x18')](_0x38c77c)[_0x498b('0x1a')](_0xc8cff5);}};}function respondWithFilteredResult(_0x1c1df4,_0x39125a){return function(_0x544114){if(_0x544114){var _0x5a8f90=typeof _0x39125a[_0x498b('0x1b')]==='undefined'&&typeof _0x39125a[_0x498b('0x1c')]==='undefined';var _0xa14442=_0x544114[_0x498b('0x1d')];var _0x52f0e6=_0x5a8f90?0x0:_0x39125a['offset'];var _0x460a22=_0x5a8f90?_0x544114['count']:_0x39125a['offset']+_0x39125a[_0x498b('0x1c')];var _0x3a4eac;if(_0x460a22>=_0xa14442){_0x460a22=_0xa14442;_0x3a4eac=0xc8;}else{_0x3a4eac=0xce;}_0x1c1df4[_0x498b('0x18')](_0x3a4eac);return _0x1c1df4[_0x498b('0x1e')]('Content-Range',_0x52f0e6+'-'+_0x460a22+'/'+_0xa14442)[_0x498b('0x1a')](_0x544114);}return null;};}function saveUpdates(_0xc880ab){return function(_0x441217){if(_0x441217){return _0x441217[_0x498b('0x1f')](_0xc880ab)[_0x498b('0x20')](function(_0x452a22){if(_0x452a22[_0x498b('0x21')]===_0x498b('0x22')){socket[_0x498b('0x23')](_0x498b('0x24')+_0x452a22['id'],_0x452a22);}return _0x452a22;});}return null;};}function removeEntity(_0x220f19){return function(_0x599477){if(_0x599477){return _0x599477[_0x498b('0x25')]()[_0x498b('0x20')](function(){var _0x2a9ad2=_0x599477[_0x498b('0x26')]({'plain':!![]});if(_0x2a9ad2[_0x498b('0x21')]===_0x498b('0x27'))return;var _0x35ff58=[{'name':_0x498b('0x28'),'value':_0x498b('0x29'),'ignore':!![]},{'name':_0x498b('0x2a'),'value':_0x498b('0x22'),'ignore':![]},{'name':_0x498b('0x2b'),'value':_0x498b('0x2c'),'ignore':![]}];var _0x5c3567=_(_0x35ff58)[_0x498b('0x2d')]('ignore')['map'](_0x498b('0x2e'))[_0x498b('0x2e')]();if(_['includes'](_0x5c3567,_0x2a9ad2[_0x498b('0x21')])){return;}var _0x2f331b=_['find'](_0x35ff58,[_0x498b('0x2e'),_0x2a9ad2[_0x498b('0x21')]])[_0x498b('0x2f')];return db[_0x498b('0x30')][_0x498b('0x25')]({'where':{'type':_0x2f331b,'resourceId':_0x2a9ad2['id']}})[_0x498b('0x20')](function(){return _0x599477;});})[_0x498b('0x20')](function(){_0x220f19[_0x498b('0x18')](0xcc)[_0x498b('0x19')]();});}};}function handleEntityNotFound(_0xd63ec0){return function(_0x4c27a4){if(!_0x4c27a4){_0xd63ec0[_0x498b('0x17')](0x194);}return _0x4c27a4;};}function handleError(_0x234502,_0xb2d349){_0xb2d349=_0xb2d349||0x1f4;return function(_0x2851f9){logger[_0x498b('0x31')](_0x2851f9['stack']);if(_0x2851f9['name']){delete _0x2851f9['name'];}_0x234502[_0x498b('0x18')](_0xb2d349)[_0x498b('0x32')](_0x2851f9);};}function getUserAttributes(){return _(db['User'][_0x498b('0x33')])['map'](function(_0x3a0619){return{'name':_0x3a0619[_0x498b('0x34')],'type':_0x3a0619[_0x498b('0x35')][_0x498b('0x36')]};})['filter'](function(_0x2b7cb0){return!['password',_0x498b('0x37'),'previousPasswords','resetPasswordToken',_0x498b('0x38'),_0x498b('0x39')][_0x498b('0x3a')](_0x2b7cb0['name']);})[_0x498b('0x2e')]();}exports[_0x498b('0x3b')]=function(_0x366a09,_0x5b67f7){var _0x512423={},_0x5e635c={'count':0x0,'rows':[]};var _0x50600d=getUserAttributes();_0x512423=qs['getOptions'](_0x50600d,_0x366a09);var _0x5ae302={'where':_0x512423[_0x498b('0x3c')]};return db[_0x498b('0x3d')][_0x498b('0x1d')](_0x5ae302)[_0x498b('0x20')](function(_0x5c15a9){_0x5e635c['count']=_0x5c15a9;if(_0x366a09['query'][_0x498b('0x3e')]){_0x512423['include']=[{'all':!![]}];}if(_0x366a09['query'][_0x498b('0x3f')]===_0x498b('0x40')){_0x512423[_0x498b('0x41')]=[{'model':db['UserSetting'],'as':'userSetting'}];}if(!_[_0x498b('0x3a')](_0x512423[_0x498b('0x42')],'id')){_0x512423['attributes']['push']('id');}return db['User']['findAll'](_0x512423);})[_0x498b('0x20')](function(_0x3f8a6e){_0x5e635c[_0x498b('0x43')]=_0x3f8a6e;if(_0x366a09['query'][_0x498b('0x44')]===_0x498b('0x40')){var _0x5d5b76=[];for(var _0x5a772c=0x0;_0x5a772c<_0x5e635c[_0x498b('0x43')][_0x498b('0x45')];_0x5a772c++){_0x5d5b76[_0x498b('0x46')](get_open_tabs('chat',_0x5e635c[_0x498b('0x43')][_0x5a772c][_0x498b('0x47')]));_0x5d5b76['push'](get_open_tabs(_0x498b('0x48'),_0x5e635c[_0x498b('0x43')][_0x5a772c]['dataValues']));_0x5d5b76[_0x498b('0x46')](get_open_tabs(_0x498b('0x49'),_0x5e635c['rows'][_0x5a772c][_0x498b('0x47')]));_0x5d5b76[_0x498b('0x46')](get_open_tabs(_0x498b('0x4a'),_0x5e635c['rows'][_0x5a772c]['dataValues']));_0x5d5b76[_0x498b('0x46')](get_open_tabs('openchannel',_0x5e635c[_0x498b('0x43')][_0x5a772c][_0x498b('0x47')]));_0x5d5b76['push'](get_open_tabs('whatsapp',_0x5e635c['rows'][_0x5a772c]['dataValues']));}return Promise[_0x498b('0x4b')](_0x5d5b76)[_0x498b('0x20')](function(){return _0x5e635c;});}else{return _0x5e635c;}})[_0x498b('0x20')](respondWithFilteredResult(_0x5b67f7,_0x512423))[_0x498b('0x4c')](handleError(_0x5b67f7,null));};exports[_0x498b('0x4d')]=function(_0x39dbde,_0x54647e){var _0xa9d504=getUserAttributes();_0x39dbde[_0x498b('0x4e')]['id']=_0x39dbde[_0x498b('0x4f')]['id'];var _0x46f152=qs[_0x498b('0x50')](_0xa9d504,_0x39dbde);if(_0x39dbde[_0x498b('0x4e')][_0x498b('0x3e')]){_0x46f152['include']=[{'all':!![]}];}if(_0x39dbde[_0x498b('0x4e')][_0x498b('0x3f')]==='true'){_0x46f152[_0x498b('0x41')]=[{'model':db['UserSetting'],'as':_0x498b('0x3f')}];}_0x46f152=_[_0x498b('0x51')]({},_0x46f152,_0x39dbde['options']);if(!_[_0x498b('0x3a')](_0x46f152[_0x498b('0x42')],'id')){_0x46f152[_0x498b('0x42')][_0x498b('0x46')]('id');}return db['User'][_0x498b('0x52')](_0x46f152)[_0x498b('0x20')](handleEntityNotFound(_0x54647e,null))[_0x498b('0x20')](function(_0x4e1622){var _0x184b48=[];values=_0x4e1622;if(_0x39dbde[_0x498b('0x4e')]['openTabs']===_0x498b('0x40')){_0x184b48['push'](get_open_tabs(_0x498b('0x53'),_0x4e1622['dataValues']));_0x184b48[_0x498b('0x46')](get_open_tabs(_0x498b('0x48'),_0x4e1622['dataValues']));_0x184b48[_0x498b('0x46')](get_open_tabs(_0x498b('0x54'),_0x4e1622['dataValues']));_0x184b48['push'](get_open_tabs('whatsapp',_0x4e1622[_0x498b('0x47')]));_0x184b48[_0x498b('0x46')](get_open_tabs('fax',_0x4e1622[_0x498b('0x47')]));_0x184b48[_0x498b('0x46')](get_open_tabs(_0x498b('0x4a'),_0x4e1622[_0x498b('0x47')]));return Promise['all'](_0x184b48);}else{return values;}})[_0x498b('0x20')](function(){return values;})['then'](respondWithResult(_0x54647e,null))['catch'](handleError(_0x54647e,null));};exports[_0x498b('0x1f')]=function(_0x26654c,_0x522fe0){if(_0x26654c[_0x498b('0x55')]['id']){delete _0x26654c[_0x498b('0x55')]['id'];}delete _0x26654c[_0x498b('0x55')][_0x498b('0x21')];return db[_0x498b('0x3d')]['find']({'where':{'id':_0x26654c[_0x498b('0x4f')]['id']}})[_0x498b('0x20')](handleEntityNotFound(_0x522fe0,null))[_0x498b('0x20')](saveUpdates(_0x26654c[_0x498b('0x55')],null))[_0x498b('0x20')](respondWithResult(_0x522fe0,null))['catch'](handleError(_0x522fe0,null));};exports[_0x498b('0x56')]=function(_0x403c0d,_0x5c03e5){return db[_0x498b('0x3d')][_0x498b('0x56')]()[_0x498b('0x20')](respondWithResult(_0x5c03e5,null))[_0x498b('0x4c')](handleError(_0x5c03e5,null));};exports[_0x498b('0x57')]=function(_0x131557,_0x264d9d){return db['User'][_0x498b('0x52')]({'where':{'id':_0x131557['params']['id']}})[_0x498b('0x20')](handleEntityNotFound(_0x264d9d,null))[_0x498b('0x20')](function(_0x17f0d8){if(_0x17f0d8){return _0x17f0d8[_0x498b('0x57')](_0x131557[_0x498b('0x55')]['ids'],_['omit'](_0x131557[_0x498b('0x55')],['ids','id'])||{});}})[_0x498b('0x20')](respondWithResult(_0x264d9d,null))[_0x498b('0x4c')](handleError(_0x264d9d,null));};function validateUser(_0x111883){return new Promise(function(_0x14ff8d,_0x6af4ee){if(_0x111883['internal'])return _0x14ff8d(_0x111883);return db['Setting'][_0x498b('0x58')](0x1)[_0x498b('0x20')](function(_0x5e1e18){if(_0x5e1e18['securePassword'])authService[_0x498b('0x59')](_0x111883[_0x498b('0x5a')]);db[_0x498b('0x3d')][_0x498b('0x5b')](_0x498b('0x5c'))[_0x498b('0x20')](function(_0x3c46f2){if(_[_0x498b('0x5d')](_0x3c46f2)){_0x111883[_0x498b('0x5c')]=_0x5e1e18['min_internal']||0x1;return;}if(_['isNil'](_0x5e1e18[_0x498b('0x5e')])||_0x5e1e18['min_internal']===_0x3c46f2){_0x111883[_0x498b('0x5c')]=_0x3c46f2+0x1;return;}if(_0x5e1e18[_0x498b('0x5e')]>_0x3c46f2){_0x111883[_0x498b('0x5c')]=_0x5e1e18['min_internal'];return;}return db[_0x498b('0x5f')]['query']('select\x20(select\x20IFNULL(max(internal)+1,1)\x20from\x20users\x20where\x20internal\x20<\x20md.internal)\x20as\x20\x27from\x27,\x20md.internal\x20-\x201\x20as\x20\x27to\x27\x20from\x20users\x20md\x20where\x20md.internal\x20!=\x201\x20and\x20not\x20exists\x20(select\x201\x20from\x20users\x20md2\x20where\x20md2.internal\x20=\x20md.internal\x20-\x201)',{'type':db['sequelize']['QueryTypes'][_0x498b('0x60')]})['then'](function(_0x1f7fb8){if(_0x1f7fb8&&_0x1f7fb8[_0x498b('0x45')]){for(var _0x4c9780=0x0,_0x56dc4c=_0x1f7fb8[_0x498b('0x45')];_0x4c9780<_0x56dc4c&&_[_0x498b('0x5d')](_0x111883['internal']);_0x4c9780++){if(_0x5e1e18[_0x498b('0x5e')]<=_0x1f7fb8[_0x4c9780][_0x498b('0x61')]){_0x111883[_0x498b('0x5c')]=_0x1f7fb8[_0x4c9780][_0x498b('0x61')];}else if(_0x5e1e18['min_internal']>_0x1f7fb8[_0x4c9780][_0x498b('0x61')]&&_0x5e1e18['min_internal']<=_0x1f7fb8[_0x4c9780]['to']){_0x111883[_0x498b('0x5c')]=_0x5e1e18[_0x498b('0x5e')];}}}if(_[_0x498b('0x5d')](_0x111883[_0x498b('0x5c')])){_0x111883['internal']=_0x3c46f2+0x1;}return _0x14ff8d(_0x111883);});});})[_0x498b('0x4c')](function(_0x3f1a6e){_0x6af4ee(_0x3f1a6e);});});}function updateUser(_0x54a4f9){return new Promise(function(_0x1245a5,_0x5f1ffa){try{if(_0x54a4f9[_0x498b('0x62')]){_0x54a4f9[_0x498b('0x63')]=_0x54a4f9[_0x498b('0x5c')];_0x54a4f9['VoiceMail']={'mailbox':_0x54a4f9[_0x498b('0x5c')],'password':_0x54a4f9['password'],'fullname':_0x54a4f9[_0x498b('0x64')],'email':_0x54a4f9[_0x498b('0x65')]};}if(_0x54a4f9[_0x498b('0x21')]==='agent'){if(!_0x54a4f9[_0x498b('0x66')])_0x54a4f9['permissions']=[_0x498b('0x67'),_0x498b('0x68'),'103',_0x498b('0x69'),_0x498b('0x6a'),_0x498b('0x6b'),'105',_0x498b('0x6c'),'107','108',_0x498b('0x6d'),_0x498b('0x6e'),'111',_0x498b('0x6f'),'115'];}_0x1245a5(_0x54a4f9);}catch(_0x5e4d26){_0x5f1ffa(_0x5e4d26);}});}exports[_0x498b('0x70')]=function(_0x6f7317,_0x46571f){if(_0x6f7317[_0x498b('0x29')][_0x498b('0x21')]===_0x498b('0x22'))throw new Error('Unauthorized');if(_0x6f7317['body'][_0x498b('0x21')]==='user'&&_0x6f7317[_0x498b('0x29')][_0x498b('0x21')]!==_0x498b('0x27')){throw new Error(_0x498b('0x71'));}if(_0x6f7317[_0x498b('0x55')]['role']===_0x498b('0x27')&&_0x6f7317[_0x498b('0x29')][_0x498b('0x21')]!=='admin'){throw new Error(_0x498b('0x72'));}return licenseUtil['checkUserLimits']([_0x6f7317[_0x498b('0x55')]])[_0x498b('0x20')](function(){return validateUser(_0x6f7317[_0x498b('0x55')]);})[_0x498b('0x20')](function(_0x38d3b5){return updateUser(_0x38d3b5)[_0x498b('0x20')](function(_0x4b5329){if(_0x4b5329[_0x498b('0x21')]===_0x498b('0x27')){_0x4b5329[_0x498b('0x73')]=_0x6f7317[_0x498b('0x29')]['settingsEnabled'];delete _0x4b5329[_0x498b('0x74')];}return _0x4b5329;});})[_0x498b('0x20')](function(_0x1a484b){return db[_0x498b('0x3d')][_0x498b('0x70')](_0x1a484b,{'include':[{'model':db[_0x498b('0x75')],'as':_0x498b('0x75')}]});})['then'](function(_0x37161b){if(_0x6f7317[_0x498b('0x55')][_0x498b('0x21')]==='user')return _0x37161b;if(_0x6f7317['user'][_0x498b('0x21')]!==_0x498b('0x29'))return _0x37161b;return db['UserProfileSection'][_0x498b('0x52')]({'where':{'name':_0x37161b[_0x498b('0x21')]==='agent'?'Agents':_0x498b('0x2b'),'userProfileId':_0x6f7317[_0x498b('0x29')][_0x498b('0x74')]},'raw':!![]})[_0x498b('0x20')](function(_0x64a453){if(!_0x64a453||_0x64a453[_0x498b('0x76')]!=0x0)return _0x37161b;return db[_0x498b('0x30')]['create']({'name':_0x37161b[_0x498b('0x2f')],'resourceId':_0x37161b['id'],'type':_0x64a453[_0x498b('0x2f')],'sectionId':_0x64a453['id']},{})[_0x498b('0x20')](function(){return _0x37161b;});})[_0x498b('0x4c')](function(_0x3771e6){logger[_0x498b('0x31')](_0x498b('0x77'),_0x3771e6);throw _0x3771e6;});})[_0x498b('0x20')](respondWithResult(_0x46571f,0xc9))['catch'](handleError(_0x46571f,null));};exports['bulkCreate']=function(_0x20dbe8,_0x1cd3dc){var _0xb28ccb=_0x20dbe8['body'];var _0x546a2f=[];if(_0x20dbe8[_0x498b('0x29')][_0x498b('0x21')]===_0x498b('0x22'))throw new Error('Unauthorized');if(_['some'](_0xb28ccb,[_0x498b('0x21'),_0x498b('0x29')])&&_0x20dbe8[_0x498b('0x29')][_0x498b('0x21')]!==_0x498b('0x27')){throw new Error(_0x498b('0x71'));}if(_[_0x498b('0x78')](_0xb28ccb,['role',_0x498b('0x27')])&&_0x20dbe8[_0x498b('0x29')]['role']!==_0x498b('0x27')){throw new Error(_0x498b('0x79'));}return licenseUtil['checkUserLimits'](_0xb28ccb)[_0x498b('0x20')](function(){return validateUser(_0xb28ccb[0x0]);})[_0x498b('0x20')](function(){for(var _0x4d0e6e=0x1;_0x4d0e6e<_0xb28ccb[_0x498b('0x45')];_0x4d0e6e++){var _0x20d44c=_0xb28ccb[_0x4d0e6e-0x1][_0x498b('0x5c')];if(!_0xb28ccb[_0x4d0e6e]['internal'])_0xb28ccb[_0x4d0e6e][_0x498b('0x5c')]=_0x20d44c+0x1;_0x546a2f[_0x498b('0x46')](validateUser(_0xb28ccb[_0x4d0e6e]));}return Promise[_0x498b('0x4b')](_0x546a2f);})[_0x498b('0x20')](function(){_0x546a2f=[];for(var _0x50b79d=0x0;_0x50b79d<_0xb28ccb['length'];_0x50b79d++){_0x546a2f['push'](updateUser(_0xb28ccb[_0x50b79d]));}return Promise['all'](_0x546a2f);})[_0x498b('0x20')](function(){_0x546a2f=_0xb28ccb['map'](function(_0x2c68de){return db[_0x498b('0x3d')]['create'](_0x2c68de,{'include':[{'model':db[_0x498b('0x75')],'as':'VoiceMail'}]})['then'](function(_0x5951e5){_0x2c68de['id']=_0x5951e5['id'];return _0x2c68de;});});return Promise['all'](_0x546a2f);})[_0x498b('0x20')](function(_0x717bed){if(_0x20dbe8[_0x498b('0x55')][_0x498b('0x21')]===_0x498b('0x29'))return _0x717bed;if(_0x20dbe8[_0x498b('0x29')]['role']!==_0x498b('0x29'))return _0x717bed;var _0x2eeb58=_['some'](_0x717bed,function(_0x145789){return _0x145789[_0x498b('0x21')]==='agent'||_0x145789[_0x498b('0x21')]===_0x498b('0x2c');});if(!_0x2eeb58)return _0x717bed;return db[_0x498b('0x7a')]['findAll']({'where':{'name':{'$or':[_0x498b('0x2a'),_0x498b('0x2b')]},'userProfileId':_0x20dbe8['user'][_0x498b('0x74')]},'raw':!![]})[_0x498b('0x20')](function(_0x1a576d){if(_[_0x498b('0x7b')](_0x1a576d)||!_[_0x498b('0x78')](_0x1a576d,[_0x498b('0x76'),0x0]))return _0x717bed;_0x546a2f=[];var _0x47f5b4=_(_0x1a576d)[_0x498b('0x7c')](function(_0x9e9006){if(_0x9e9006[_0x498b('0x76')]===0x1)return;return _0x9e9006[_0x498b('0x2f')]==='Agents'?_0x498b('0x22'):_0x498b('0x2c');})[_0x498b('0x7d')]()[_0x498b('0x2e')]();for(var _0x175864=0x0;_0x175864<_0x717bed[_0x498b('0x45')];_0x175864++){if(!_[_0x498b('0x3a')](_0x47f5b4,_0x717bed[_0x175864]['role']))return;var _0x5c8ff5=_0x717bed[_0x175864]['role']===_0x498b('0x22')?_0x498b('0x2a'):'Telephones';_0x546a2f[_0x498b('0x46')](db[_0x498b('0x30')][_0x498b('0x70')]({'name':_0x717bed[_0x175864][_0x498b('0x2f')],'resourceId':_0x717bed[_0x175864]['id'],'type':_0x5c8ff5,'sectionId':_[_0x498b('0x52')](_0x1a576d,['name',_0x5c8ff5])['id']},{}));}return Promise[_0x498b('0x4b')](_0x546a2f);});})[_0x498b('0x20')](respondWithResult(_0x1cd3dc,0xc9))[_0x498b('0x4c')](handleError(_0x1cd3dc,null));};exports[_0x498b('0x7e')]=function(_0x351733,_0x136994){if(_0x351733[_0x498b('0x55')]['id']){delete _0x351733[_0x498b('0x55')]['id'];}return db[_0x498b('0x3d')][_0x498b('0x52')]({'where':{'id':_0x351733[_0x498b('0x4f')]['id']}})[_0x498b('0x20')](function(_0x4330a8){if(!_0x4330a8)return null;if(_0x4330a8['id']===_0x351733[_0x498b('0x29')]['id']){if(!_0x351733[_0x498b('0x55')][_0x498b('0x7f')]||!_0x351733[_0x498b('0x55')][_0x498b('0x80')]){throw new db['Sequelize']['ValidationError']('Invalid\x20body\x20format.\x20Use\x20oldPassword\x20and\x20newPassword');}if(!_0x4330a8['authenticate'](_0x351733[_0x498b('0x55')][_0x498b('0x7f')])){throw new db['Sequelize'][(_0x498b('0x81'))]('Wrong\x20credentials');}if(_0x351733[_0x498b('0x55')][_0x498b('0x7f')]===_0x351733[_0x498b('0x55')][_0x498b('0x80')]){throw new db[(_0x498b('0x82'))]['ValidationError'](_0x498b('0x83'));}}else if(_0x351733[_0x498b('0x29')]['role']===_0x498b('0x27')){if(!_0x351733['body'][_0x498b('0x80')]){throw new db['Sequelize'][(_0x498b('0x81'))](_0x498b('0x84'));}}else if(_0x351733[_0x498b('0x29')][_0x498b('0x21')]===_0x498b('0x29')){if(!_0x351733[_0x498b('0x55')][_0x498b('0x80')]){throw new db[(_0x498b('0x82'))][(_0x498b('0x81'))]('Invalid\x20body\x20format.\x20Use\x20newPassword');}if(_0x4330a8['role']!=='agent'){throw new db[(_0x498b('0x82'))][(_0x498b('0x81'))](_0x498b('0x85'));}}else{throw new db['Sequelize'][(_0x498b('0x81'))]('Unauthorized');}return _0x4330a8;})[_0x498b('0x20')](handleEntityNotFound(_0x136994,null))['then'](function(_0x11b510){return db[_0x498b('0x86')]['findOne']({'attributes':['id',_0x498b('0x87'),_0x498b('0x88'),_0x498b('0x89')]})[_0x498b('0x20')](function(_0x539963){if(_0x539963[_0x498b('0x87')])authService['validatePasswordPattern'](_0x351733[_0x498b('0x55')][_0x498b('0x80')]);if(!_0x539963[_0x498b('0x88')]||!_0x11b510[_0x498b('0x8a')])return _0x11b510;authService[_0x498b('0x8b')](_0x351733['body']['newPassword'],_0x11b510[_0x498b('0x8a')],_0x539963[_0x498b('0x89')]);return _0x11b510;})[_0x498b('0x20')](saveUpdates({'password':_0x351733[_0x498b('0x55')][_0x498b('0x80')],'passwordResetAt':_0x351733[_0x498b('0x29')]['id']==_0x351733[_0x498b('0x4f')]['id']?moment():null,'previousPasswords':authService[_0x498b('0x8c')](_0x351733[_0x498b('0x55')][_0x498b('0x80')],_0x11b510[_0x498b('0x8a')])},null));})[_0x498b('0x20')](respondWithResult(_0x136994,null))['catch'](handleError(_0x136994,null));};exports['addQueues']=function(_0x34ef8e,_0x58960c){var _0x24af49=_0x34ef8e[_0x498b('0x55')][_0x498b('0x8d')];return db['User'][_0x498b('0x52')]({'where':{'id':_0x34ef8e[_0x498b('0x4f')]['id']},'attributes':['id',_0x498b('0x2f'),_0x498b('0x21'),'online',_0x498b('0x8e'),_0x498b('0x8f'),_0x498b('0x90')]})['then'](handleEntityNotFound(_0x58960c,null))[_0x498b('0x20')](function(_0x3de06e){if(_0x3de06e){if(!utils[_0x498b('0x91')](_0x24af49)){throw new db['Sequelize'][(_0x498b('0x81'))](_0x498b('0x92'));}return _0x3de06e[_0x498b('0x93')+_[_0x498b('0x94')](_0x24af49['toLowerCase']())+_0x498b('0x95')](_0x34ef8e[_0x498b('0x55')][_0x498b('0x96')],{'penalty':_0x34ef8e[_0x498b('0x55')][_0x498b('0x97')]||0x0})['spread'](function(_0x2960d8){for(var _0x3b7819=0x0;_0x3b7819<_0x34ef8e[_0x498b('0x55')][_0x498b('0x96')][_0x498b('0x45')];_0x3b7819+=0x1){var _0x56a606={'UserId':Number(_0x34ef8e[_0x498b('0x4f')]['id'])};_0x56a606[_[_0x498b('0x94')](_0x24af49[_0x498b('0x98')]())+_0x498b('0x99')]=Number(_0x34ef8e[_0x498b('0x55')]['ids'][_0x3b7819]);socket[_0x498b('0x23')](_0x498b('0x29')+_[_0x498b('0x94')](_0x24af49[_0x498b('0x98')]())+_0x498b('0x9a'),_0x56a606);}return _0x2960d8;})[_0x498b('0x20')](function(){if(_0x24af49===_0x498b('0x9b')){return db[_0x498b('0x9c')][_0x498b('0x9d')]({'where':{'id':_0x34ef8e[_0x498b('0x55')]['ids']||[]},'raw':!![],'attributes':['id',_0x498b('0x2f')]});}})['then'](function(_0x43e43a){var _0x3ccbb1=_0x3de06e[_0x498b('0x26')]({'plain':!![]});var _0x4d138e=[];if(_0x24af49===_0x498b('0x9b')&&_0x3ccbb1[_0x498b('0x21')]==='agent'&&_0x3ccbb1[_0x498b('0x9e')]){for(let _0x11bf67=0x0;_0x11bf67<_0x43e43a[_0x498b('0x45')];_0x11bf67+=0x1){_0x4d138e[_0x498b('0x46')]({'membername':_0x3ccbb1[_0x498b('0x2f')],'UserId':_0x3ccbb1['id'],'queue_name':_0x43e43a[_0x11bf67][_0x498b('0x2f')],'VoiceQueueId':_0x43e43a[_0x11bf67]['id'],'interface':_[_0x498b('0x5d')](_0x3ccbb1['interface'])?util[_0x498b('0x9f')](_0x498b('0xa0'),_0x3ccbb1[_0x498b('0x2f')]):_0x3ccbb1['interface'],'paused':_0x3ccbb1[_0x498b('0x8f')]||![],'penalty':_0x34ef8e['body']['penalty']||0x0});}return Promise[_0x498b('0x4b')](_0x4d138e[_0x498b('0x7c')](function(_0x28d7e5){return db[_0x498b('0xa1')]['upsert'](_0x28d7e5);}));}return _0x3de06e;});}})[_0x498b('0x20')](respondWithStatusCode(_0x58960c,null))['catch'](handleError(_0x58960c,null));};exports[_0x498b('0xa2')]=function(_0x462d6c,_0x3e427e){var _0x5750a8,_0x131218;return db['User'][_0x498b('0x52')]({'where':{'id':_0x462d6c[_0x498b('0x4f')]['id']},'attributes':['id','name','role']})[_0x498b('0x20')](handleEntityNotFound(_0x3e427e,null))[_0x498b('0x20')](function(_0x1cbef9){if(_0x1cbef9){_0x5750a8=_0x1cbef9;if(!_0x462d6c[_0x498b('0x4e')]['channel']||!utils[_0x498b('0x91')](_0x462d6c[_0x498b('0x4e')][_0x498b('0x8d')])){throw new db[(_0x498b('0x82'))][(_0x498b('0x81'))]('Unknown\x20channel');}return _0x1cbef9[_0x498b('0xa3')+_[_0x498b('0x94')](_0x462d6c[_0x498b('0x4e')][_0x498b('0x8d')][_0x498b('0x98')]())+'Queues'](_0x462d6c[_0x498b('0x4e')][_0x498b('0x96')]);}})['then'](function(_0x13369c){if(_['isArray'](_0x462d6c['query'][_0x498b('0x96')])){for(var _0x427103=0x0;_0x427103<_0x462d6c[_0x498b('0x4e')][_0x498b('0x96')][_0x498b('0x45')];_0x427103+=0x1){_0x131218={'UserId':Number(_0x462d6c['params']['id'])};_0x131218[_[_0x498b('0x94')](_0x462d6c[_0x498b('0x4e')][_0x498b('0x8d')]['toLowerCase']())+_0x498b('0x99')]=Number(_0x462d6c[_0x498b('0x4e')][_0x498b('0x96')][_0x427103]);socket[_0x498b('0x23')](_0x498b('0x29')+_[_0x498b('0x94')](_0x462d6c[_0x498b('0x4e')][_0x498b('0x8d')][_0x498b('0x98')]())+_0x498b('0xa4'),_0x131218);}}else{_0x131218={'UserId':Number(_0x462d6c['params']['id'])};_0x131218[_['capitalize'](_0x462d6c[_0x498b('0x4e')][_0x498b('0x8d')][_0x498b('0x98')]())+'QueueId']=Number(_0x462d6c[_0x498b('0x4e')][_0x498b('0x96')]);socket['emit'](_0x498b('0x29')+_[_0x498b('0x94')](_0x462d6c[_0x498b('0x4e')][_0x498b('0x8d')][_0x498b('0x98')]())+_0x498b('0xa4'),_0x131218);}return _0x13369c;})['then'](function(){if(_0x462d6c[_0x498b('0x4e')][_0x498b('0x8d')]==='voice'){return db[_0x498b('0xa1')][_0x498b('0x25')]({'where':{'UserId':_0x462d6c['params']['id'],'VoiceQueueId':_0x462d6c[_0x498b('0x4e')]['ids']},'individualHooks':!![]})[_0x498b('0x20')](function(){return _0x5750a8;});}return _0x5750a8;})[_0x498b('0x20')](respondWithStatusCode(_0x3e427e,null))[_0x498b('0x4c')](handleError(_0x3e427e,null));};exports[_0x498b('0xa5')]=function(_0x6f5ca9,_0x5a51f0){_0x6f5ca9[_0x498b('0x55')][_0x498b('0xa6')]=_0x6f5ca9[_0x498b('0xa7')]['filename'];return db[_0x498b('0x3d')][_0x498b('0x52')]({'where':{'id':_0x6f5ca9[_0x498b('0x4f')]['id']}})[_0x498b('0x20')](handleEntityNotFound(_0x5a51f0,null))[_0x498b('0x20')](saveUpdates(_0x6f5ca9[_0x498b('0x55')],null))[_0x498b('0x20')](respondWithResult(_0x5a51f0,null))[_0x498b('0x4c')](handleError(_0x5a51f0,null));};exports['getAvatar']=function(_0x6d1bdb,_0x5698f4){var _0x3985b4=path[_0x498b('0xa8')](config['root'],_0x498b('0xa9'));return db[_0x498b('0x3d')][_0x498b('0x52')]({'where':{'id':_0x6d1bdb[_0x498b('0x4f')]['id']},'attributes':['id',_0x498b('0xa6')],'raw':!![]})[_0x498b('0x20')](handleEntityNotFound(_0x5698f4,null))['then'](function(_0x17df18){if(_0x17df18){if(_[_0x498b('0x5d')](_0x17df18['userpic'])){return _0x5698f4['download'](_0x3985b4);}else{if(!fs['existsSync'](path[_0x498b('0xa8')](config[_0x498b('0xaa')],_0x498b('0xab'),_0x17df18['userpic']))){return _0x5698f4[_0x498b('0xac')](_0x3985b4);}return _0x5698f4[_0x498b('0xac')](path[_0x498b('0xa8')](config[_0x498b('0xaa')],_0x498b('0xab'),_0x17df18[_0x498b('0xa6')]));}}})['catch'](handleError(_0x5698f4,null));};exports[_0x498b('0xad')]=function(_0x39f9df,_0x4bbb11){return db[_0x498b('0x3d')][_0x498b('0x52')]({'where':{'id':_0x39f9df[_0x498b('0x4f')]['id']},'attributes':['id']})['then'](handleEntityNotFound(_0x4bbb11,null))[_0x498b('0x20')](function(_0xe9d8ca){var _0x1727c5=[];values=_0xe9d8ca[_0x498b('0x47')];_0x1727c5[_0x498b('0x46')](get_open_tabs('chat',_0xe9d8ca[_0x498b('0x47')]));_0x1727c5['push'](get_open_tabs('sms',_0xe9d8ca[_0x498b('0x47')]));_0x1727c5[_0x498b('0x46')](get_open_tabs(_0x498b('0x54'),_0xe9d8ca['dataValues']));_0x1727c5[_0x498b('0x46')](get_open_tabs(_0x498b('0xae'),_0xe9d8ca[_0x498b('0x47')]));_0x1727c5[_0x498b('0x46')](get_open_tabs(_0x498b('0x49'),_0xe9d8ca['dataValues']));_0x1727c5['push'](get_open_tabs(_0x498b('0x4a'),_0xe9d8ca[_0x498b('0x47')]));return Promise[_0x498b('0x4b')](_0x1727c5);})[_0x498b('0x20')](function(_0x795e44){if(_0x795e44){var _0x3df7cf=_['map'](values[_0x498b('0xaf')],function(_0x5d6b31){return{'channel':_0x498b('0xb0'),'id':_0x5d6b31['id'],'createdAt':_0x5d6b31[_0x498b('0xb1')]};});var _0xcce6ea=_['map'](values[_0x498b('0xb2')],function(_0x1e30d6){return{'channel':_0x498b('0xb3'),'id':_0x1e30d6['id'],'createdAt':_0x1e30d6[_0x498b('0xb1')]};});var _0x22eb22=_[_0x498b('0x7c')](values[_0x498b('0xb4')],function(_0x39d61f){return{'channel':_0x498b('0xb5'),'id':_0x39d61f['id'],'createdAt':_0x39d61f[_0x498b('0xb1')]};});var _0x163524=_['map'](values[_0x498b('0xb6')],function(_0x477dd5){return{'channel':_0x498b('0xb7'),'id':_0x477dd5['id'],'createdAt':_0x477dd5[_0x498b('0xb1')]};});var _0x1de1f4=_[_0x498b('0x7c')](values['SmsOpenTabs'],function(_0x290e46){return{'channel':_0x498b('0xb8'),'id':_0x290e46['id'],'createdAt':_0x290e46[_0x498b('0xb1')]};});var _0x4390bb=_[_0x498b('0x7c')](values['WhatsappOpenTabs'],function(_0x316c21){return{'channel':'WHATSAPP','id':_0x316c21['id'],'createdAt':_0x316c21[_0x498b('0xb1')]};});var _0x3a5abc=_[_0x498b('0xb9')](_0x3df7cf,_0xcce6ea,_0x22eb22,_0x163524,_0x1de1f4,_0x4390bb);var _0x1bdac5={'count':_0x3a5abc[_0x498b('0x45')],'rows':_0x3a5abc};return _0x1bdac5;}else return null;})[_0x498b('0x20')](respondWithResult(_0x4bbb11,null))['catch'](handleError(_0x4bbb11,null));};exports[_0x498b('0xba')]=function(_0x4f4332,_0x5b99a9){var _0x505311={};return db[_0x498b('0x3d')][_0x498b('0xbb')]({'where':{'id':_0x4f4332[_0x498b('0x4f')]['id']}})[_0x498b('0x20')](function(_0x1c22e0){if(!_0x1c22e0){throw new APINotFoundError(util[_0x498b('0x9f')](_0x498b('0xbc'),_0x4f4332[_0x498b('0x4f')]['id']));}return contacts['describe']();})[_0x498b('0x20')](function(_0x50a462){_0x4f4332[_0x498b('0x4e')]['User']=_0x4f4332[_0x498b('0x4f')]['id'];_0x505311=qs[_0x498b('0x50')](_0x50a462,_0x4f4332);if(_0x4f4332['query'][_0x498b('0xbd')](_0x498b('0x3e'))){_0x505311[_0x498b('0x41')]=[{'model':db[_0x498b('0xbe')],'as':_0x498b('0xbf'),'required':![]},{'model':db[_0x498b('0xc0')],'as':_0x498b('0xc1'),'attributes':['id',_0x498b('0x2f'),_0x498b('0xc2')],'where':_0x4f4332[_0x498b('0x4e')][_0x498b('0xc3')]?{'id':_0x4f4332[_0x498b('0x4e')][_0x498b('0xc3')]}:undefined,'required':_0x4f4332[_0x498b('0x4e')][_0x498b('0xc3')]?!![]:![]}];}return contacts['findAll'](_0x4f4332['query'],_0x4f4332[_0x498b('0x29')],_0x505311,_0x50a462);})[_0x498b('0x20')](respondWithFilteredResult(_0x5b99a9,_0x505311))['catch'](APIHandleError(_0x5b99a9));};exports['getQueues']=function(_0x14e999,_0x3f977e){var _0x2a7e71;var _0x6e0ebe={};var _0x5c446d;return db[_0x498b('0x3d')][_0x498b('0xbb')]({'where':{'id':_0x14e999[_0x498b('0x4f')]['id']},'attributes':['id',_0x498b('0x2f'),_0x498b('0x21')]})[_0x498b('0x20')](handleEntityNotFound(_0x3f977e,null))[_0x498b('0x20')](function(_0x5c7930){if(!utils[_0x498b('0x91')](_0x14e999['query'][_0x498b('0x8d')])){throw new db[(_0x498b('0x82'))][(_0x498b('0x81'))](_0x498b('0x92'));}_0x2a7e71=_0x5c7930;var _0x2ca2={};_0x2ca2['model']=_[_0x498b('0xc4')](db[_[_0x498b('0x94')](_0x14e999[_0x498b('0x4e')][_0x498b('0x8d')])+_0x498b('0xc5')][_0x498b('0x33')]);_0x2ca2['query']=_['keys'](_0x14e999['query']);_0x2ca2['filters']=_['intersection'](_0x2ca2['model'],_0x2ca2['query']);_0x6e0ebe[_0x498b('0x42')]=_[_0x498b('0xc6')](_0x2ca2[_0x498b('0xc7')],qs[_0x498b('0xc8')](_0x14e999[_0x498b('0x4e')][_0x498b('0xc8')]));_0x6e0ebe['attributes']=_0x6e0ebe[_0x498b('0x42')][_0x498b('0x45')]?_0x6e0ebe[_0x498b('0x42')]:_0x2ca2[_0x498b('0xc7')];_0x6e0ebe[_0x498b('0xc9')]=qs[_0x498b('0xca')](_0x14e999['query'][_0x498b('0xca')]);_0x6e0ebe[_0x498b('0x3c')]=qs[_0x498b('0xcb')](_[_0x498b('0xcc')](_0x14e999[_0x498b('0x4e')],_0x2ca2[_0x498b('0xcb')]));if(_0x14e999[_0x498b('0x4e')][_0x498b('0x2d')]){_0x6e0ebe[_0x498b('0x3c')]=_[_0x498b('0x51')](_0x6e0ebe['where'],{'$or':_[_0x498b('0x7c')](_0x6e0ebe[_0x498b('0x42')],function(_0x2d98f1){var _0x27109d={};_0x27109d[_0x2d98f1]={'$like':'%'+_0x14e999[_0x498b('0x4e')][_0x498b('0x2d')]+'%'};return _0x27109d;})});}_0x6e0ebe=_[_0x498b('0x51')]({},_0x6e0ebe,_0x14e999[_0x498b('0xcd')]);switch(_0x2a7e71[_0x498b('0x21')]){case'admin':return db[_[_0x498b('0x94')](_0x14e999['query'][_0x498b('0x8d')])+_0x498b('0xc5')][_0x498b('0x9d')](_0x6e0ebe);case _0x498b('0x29'):case'agent':return _0x2a7e71['get'+_[_0x498b('0x94')](_0x14e999[_0x498b('0x4e')]['channel'])+'Queues'](_0x6e0ebe);default:throw new db['Sequelize'][(_0x498b('0x81'))](_0x498b('0xce'));}})['then'](function(_0xab27b0){_0x5c446d=_0xab27b0[_0x498b('0x45')];if(!_0x14e999[_0x498b('0x4e')][_0x498b('0xbd')]('nolimit')){_0x6e0ebe[_0x498b('0x1c')]=qs[_0x498b('0x1c')](_0x14e999['query'][_0x498b('0x1c')]);_0x6e0ebe[_0x498b('0x1b')]=qs[_0x498b('0x1b')](_0x14e999['query']['offset']);}switch(_0x2a7e71[_0x498b('0x21')]){case'admin':return db[_[_0x498b('0x94')](_0x14e999[_0x498b('0x4e')][_0x498b('0x8d')])+_0x498b('0xc5')][_0x498b('0x9d')](_0x6e0ebe);case'user':case _0x498b('0x22'):return _0x2a7e71[_0x498b('0x26')+_['capitalize'](_0x14e999[_0x498b('0x4e')][_0x498b('0x8d')])+_0x498b('0x95')](_0x6e0ebe);}})[_0x498b('0x20')](function(_0x151186){return{'count':_0x5c446d,'rows':_0x151186};})[_0x498b('0x20')](respondWithResult(_0x3f977e,null))[_0x498b('0x4c')](handleError(_0x3f977e,null));};exports[_0x498b('0xcf')]=function(_0x50d5a5,_0x3b2aee){var _0x1d8621={};var _0x20e1e6={};var _0x4d3e74;var _0x435f6e;return db['User'][_0x498b('0xbb')]({'where':{'id':_0x50d5a5[_0x498b('0x4f')]['id']}})[_0x498b('0x20')](handleEntityNotFound(_0x3b2aee,null))[_0x498b('0x20')](function(_0x371471){if(_0x371471){_0x4d3e74=_0x371471;_0x20e1e6[_0x498b('0xc7')]=_['keys'](db[_0x498b('0xa1')][_0x498b('0x33')]);_0x20e1e6[_0x498b('0x4e')]=_[_0x498b('0xc4')](_0x50d5a5['query']);_0x20e1e6[_0x498b('0xcb')]=_[_0x498b('0xc6')](_0x20e1e6[_0x498b('0xc7')],_0x20e1e6[_0x498b('0x4e')]);_0x1d8621['attributes']=_[_0x498b('0xc6')](_0x20e1e6[_0x498b('0xc7')],qs[_0x498b('0xc8')](_0x50d5a5[_0x498b('0x4e')][_0x498b('0xc8')]));_0x1d8621[_0x498b('0x42')]=_0x1d8621['attributes'][_0x498b('0x45')]?_0x1d8621['attributes']:_0x20e1e6['model'];_0x1d8621[_0x498b('0xc9')]=qs['sort'](_0x50d5a5[_0x498b('0x4e')][_0x498b('0xca')]);_0x1d8621[_0x498b('0x3c')]=qs[_0x498b('0xcb')](_[_0x498b('0xcc')](_0x50d5a5['query'],_0x20e1e6[_0x498b('0xcb')]));if(_0x50d5a5[_0x498b('0x4e')][_0x498b('0x2d')]){_0x1d8621[_0x498b('0x3c')]=_[_0x498b('0x51')](_0x1d8621['where'],{'$or':_[_0x498b('0x7c')](_0x1d8621[_0x498b('0x42')],function(_0x71547b){var _0x437cd3={};_0x437cd3[_0x71547b]={'$like':'%'+_0x50d5a5[_0x498b('0x4e')]['filter']+'%'};return _0x437cd3;})});}_0x1d8621=_[_0x498b('0x51')]({},_0x1d8621,_0x50d5a5[_0x498b('0xcd')]);return _0x4d3e74['getVoiceQueuesRt'](_0x1d8621);}})['then'](function(_0x41729f){if(_0x41729f){_0x435f6e=_0x41729f[_0x498b('0x45')];if(!_0x50d5a5[_0x498b('0x4e')]['hasOwnProperty']('nolimit')){_0x1d8621['limit']=qs[_0x498b('0x1c')](_0x50d5a5['query'][_0x498b('0x1c')]);_0x1d8621[_0x498b('0x1b')]=qs[_0x498b('0x1b')](_0x50d5a5['query']['offset']);}return _0x4d3e74[_0x498b('0xcf')](_0x1d8621);}})[_0x498b('0x20')](function(_0x1f71e4){if(_0x1f71e4){return _0x1f71e4?{'count':_0x435f6e,'rows':_0x1f71e4}:null;}})[_0x498b('0x20')](respondWithResult(_0x3b2aee,null))[_0x498b('0x4c')](handleError(_0x3b2aee,null));};exports[_0x498b('0xd0')]=function(_0x534628,_0x487fc8){var _0x429861={};var _0x42c12a={};var _0x410ef3;var _0x1f178f;return db[_0x498b('0x3d')]['findOne']({'where':{'id':_0x534628[_0x498b('0x4f')]['id']}})[_0x498b('0x20')](handleEntityNotFound(_0x487fc8,null))[_0x498b('0x20')](function(_0x3557bc){if(_0x3557bc){_0x410ef3=_0x3557bc;_0x42c12a[_0x498b('0xc7')]=_[_0x498b('0xc4')](db[_0x498b('0xd1')][_0x498b('0x33')]);_0x42c12a[_0x498b('0x4e')]=_[_0x498b('0xc4')](_0x534628[_0x498b('0x4e')]);_0x42c12a['filters']=_['intersection'](_0x42c12a[_0x498b('0xc7')],_0x42c12a[_0x498b('0x4e')]);_0x429861[_0x498b('0x42')]=_['intersection'](_0x42c12a[_0x498b('0xc7')],qs[_0x498b('0xc8')](_0x534628[_0x498b('0x4e')]['fields']));_0x429861[_0x498b('0x42')]=_0x429861['attributes'][_0x498b('0x45')]?_0x429861[_0x498b('0x42')]:_0x42c12a[_0x498b('0xc7')];_0x429861[_0x498b('0xc9')]=qs[_0x498b('0xca')](_0x534628[_0x498b('0x4e')]['sort']);_0x429861['where']=qs['filters'](_['pick'](_0x534628[_0x498b('0x4e')],_0x42c12a[_0x498b('0xcb')]));if(_0x534628[_0x498b('0x4e')]['filter']){_0x429861[_0x498b('0x3c')]=_[_0x498b('0x51')](_0x429861[_0x498b('0x3c')],{'$or':_[_0x498b('0x7c')](_0x429861[_0x498b('0x42')],function(_0x5d7122){var _0x52a1d9={};_0x52a1d9[_0x5d7122]={'$like':'%'+_0x534628['query'][_0x498b('0x2d')]+'%'};return _0x52a1d9;})});}_0x429861=_[_0x498b('0x51')]({},_0x429861,_0x534628[_0x498b('0xcd')]);return _0x410ef3['getGroups'](_0x429861);}})[_0x498b('0x20')](function(_0x117763){if(_0x117763){_0x1f178f=_0x117763[_0x498b('0x45')];if(!_0x534628[_0x498b('0x4e')][_0x498b('0xbd')](_0x498b('0xd2'))){_0x429861[_0x498b('0x1c')]=qs[_0x498b('0x1c')](_0x534628[_0x498b('0x4e')][_0x498b('0x1c')]);_0x429861[_0x498b('0x1b')]=qs[_0x498b('0x1b')](_0x534628[_0x498b('0x4e')][_0x498b('0x1b')]);}return _0x410ef3[_0x498b('0xd0')](_0x429861);}})[_0x498b('0x20')](function(_0x2c90e5){if(_0x2c90e5){return _0x2c90e5?{'count':_0x1f178f,'rows':_0x2c90e5}:null;}})['then'](respondWithResult(_0x487fc8,null))[_0x498b('0x4c')](handleError(_0x487fc8,null));};exports['getRecordings']=function(_0x5ca9ee,_0x59a9b0){var _0x28bbac={'raw':!![],'where':{}};var _0x3d4a40={};var _0x26fe2f={'count':0x0,'rows':[]};return db[_0x498b('0x3d')][_0x498b('0xbb')]({'where':{'id':_0x5ca9ee['params']['id']}})['then'](handleEntityNotFound(_0x59a9b0,null))[_0x498b('0x20')](function(_0x51cd66){if(_0x51cd66){_0x3d4a40[_0x498b('0xc7')]=_[_0x498b('0xc4')](db[_0x498b('0xd3')][_0x498b('0x33')]);_0x3d4a40['query']=_['keys'](_0x5ca9ee[_0x498b('0x4e')]);_0x3d4a40[_0x498b('0xcb')]=_[_0x498b('0xc6')](_0x3d4a40['model'],_0x3d4a40['query']);_0x28bbac['attributes']=_['intersection'](_0x3d4a40[_0x498b('0xc7')],qs[_0x498b('0xc8')](_0x5ca9ee['query'][_0x498b('0xc8')]));_0x28bbac[_0x498b('0x42')]=_0x28bbac[_0x498b('0x42')]['length']?_0x28bbac['attributes']:_0x3d4a40[_0x498b('0xc7')];if(!_0x5ca9ee[_0x498b('0x4e')][_0x498b('0xbd')](_0x498b('0xd2'))){_0x28bbac[_0x498b('0x1c')]=qs[_0x498b('0x1c')](_0x5ca9ee[_0x498b('0x4e')][_0x498b('0x1c')]);_0x28bbac['offset']=qs[_0x498b('0x1b')](_0x5ca9ee['query']['offset']);}_0x28bbac['order']=qs[_0x498b('0xca')](_0x5ca9ee[_0x498b('0x4e')]['sort']);_0x28bbac[_0x498b('0x3c')]=qs[_0x498b('0xcb')](_[_0x498b('0xcc')](_0x5ca9ee[_0x498b('0x4e')],_0x3d4a40[_0x498b('0xcb')]));_0x28bbac[_0x498b('0x3c')]['UserId']=_0x51cd66['id'];if(_0x5ca9ee['query']['filter']){_0x28bbac[_0x498b('0x3c')]=_[_0x498b('0x51')](_0x28bbac[_0x498b('0x3c')],{'$or':_[_0x498b('0x7c')](_0x28bbac[_0x498b('0x42')],function(_0x36ea35){var _0x2aa228={};_0x2aa228[_0x36ea35]={'$like':'%'+_0x5ca9ee['query'][_0x498b('0x2d')]+'%'};return _0x2aa228;})});}_0x28bbac=_[_0x498b('0x51')]({},_0x28bbac,_0x5ca9ee[_0x498b('0xcd')]);return db[_0x498b('0xd3')]['count']({'where':_0x28bbac[_0x498b('0x3c')]})['then'](function(_0x1a7039){_0x26fe2f[_0x498b('0x1d')]=_0x1a7039;if(_0x5ca9ee[_0x498b('0x4e')][_0x498b('0x3e')]){_0x28bbac['include']=[{'all':!![]}];}return db['VoiceRecording']['findAll'](_0x28bbac);})[_0x498b('0x20')](function(_0x380b60){_0x26fe2f[_0x498b('0x43')]=_0x380b60;return _0x26fe2f;});}})['then'](respondWithFilteredResult(_0x59a9b0,_0x28bbac))['catch'](handleError(_0x59a9b0,null));};exports[_0x498b('0xd4')]=function(_0x55c1a0,_0x108f6d){var _0xc2957f={'raw':!![],'where':{}};var _0x19f7c6={};var _0x4d8329={'count':0x0,'rows':[]};return db[_0x498b('0x3d')][_0x498b('0xbb')]({'where':{'id':_0x55c1a0['params']['id']}})[_0x498b('0x20')](handleEntityNotFound(_0x108f6d,null))[_0x498b('0x20')](function(_0x5294bc){if(_0x5294bc){_0x19f7c6['model']=_['keys'](db[_0x498b('0xd5')][_0x498b('0x33')]);_0x19f7c6['query']=_[_0x498b('0xc4')](_0x55c1a0[_0x498b('0x4e')]);_0x19f7c6[_0x498b('0xcb')]=_[_0x498b('0xc6')](_0x19f7c6[_0x498b('0xc7')],_0x19f7c6[_0x498b('0x4e')]);_0xc2957f[_0x498b('0x42')]=_['intersection'](_0x19f7c6[_0x498b('0xc7')],qs[_0x498b('0xc8')](_0x55c1a0['query'][_0x498b('0xc8')]));_0xc2957f['attributes']=_0xc2957f[_0x498b('0x42')][_0x498b('0x45')]?_0xc2957f['attributes']:_0x19f7c6['model'];if(!_0x55c1a0[_0x498b('0x4e')][_0x498b('0xbd')](_0x498b('0xd2'))){_0xc2957f[_0x498b('0x1c')]=qs[_0x498b('0x1c')](_0x55c1a0['query'][_0x498b('0x1c')]);_0xc2957f[_0x498b('0x1b')]=qs['offset'](_0x55c1a0[_0x498b('0x4e')][_0x498b('0x1b')]);}_0xc2957f[_0x498b('0xc9')]=qs[_0x498b('0xca')](_0x55c1a0[_0x498b('0x4e')][_0x498b('0xca')]);_0xc2957f[_0x498b('0x3c')]=qs[_0x498b('0xcb')](_['pick'](_0x55c1a0[_0x498b('0x4e')],_0x19f7c6[_0x498b('0xcb')]));_0xc2957f[_0x498b('0x3c')]['UserId']=_0x5294bc['id'];if(_0x55c1a0['query']['filter']){_0xc2957f[_0x498b('0x3c')]=_[_0x498b('0x51')](_0xc2957f['where'],{'$or':_[_0x498b('0x7c')](_0xc2957f[_0x498b('0x42')],function(_0x4f3738){var _0x581363={};_0x581363[_0x4f3738]={'$like':'%'+_0x55c1a0['query'][_0x498b('0x2d')]+'%'};return _0x581363;})});}_0xc2957f=_[_0x498b('0x51')]({},_0xc2957f,_0x55c1a0['options']);return db[_0x498b('0xd5')][_0x498b('0x1d')]({'where':_0xc2957f[_0x498b('0x3c')]})[_0x498b('0x20')](function(_0x320ecf){_0x4d8329[_0x498b('0x1d')]=_0x320ecf;if(_0x55c1a0[_0x498b('0x4e')][_0x498b('0x3e')]){_0xc2957f['include']=[{'all':!![]}];}return db[_0x498b('0xd5')][_0x498b('0x9d')](_0xc2957f);})[_0x498b('0x20')](function(_0x53bac8){_0x4d8329[_0x498b('0x43')]=_0x53bac8;return _0x4d8329;});}})[_0x498b('0x20')](respondWithFilteredResult(_0x108f6d,_0xc2957f))['catch'](handleError(_0x108f6d,null));};exports['getChatInteractions']=function(_0x565444,_0x592a31){var _0x2e545f={};var _0x5d67fb={};var _0x4fff55;var _0x190987;return db[_0x498b('0x3d')]['findOne']({'where':{'id':_0x565444[_0x498b('0x4f')]['id']}})[_0x498b('0x20')](handleEntityNotFound(_0x592a31,null))['then'](function(_0x1a7016){if(_0x1a7016){_0x4fff55=_0x1a7016;_0x5d67fb[_0x498b('0xc7')]=_['keys'](db[_0x498b('0xd6')]['rawAttributes']);_0x5d67fb[_0x498b('0x4e')]=_[_0x498b('0xc4')](_0x565444['query']);_0x5d67fb[_0x498b('0xcb')]=_[_0x498b('0xc6')](_0x5d67fb['model'],_0x5d67fb[_0x498b('0x4e')]);_0x2e545f[_0x498b('0x42')]=_[_0x498b('0xc6')](_0x5d67fb[_0x498b('0xc7')],qs[_0x498b('0xc8')](_0x565444[_0x498b('0x4e')][_0x498b('0xc8')]));_0x2e545f[_0x498b('0x42')]=_0x2e545f[_0x498b('0x42')][_0x498b('0x45')]?_0x2e545f[_0x498b('0x42')]:_0x5d67fb['model'];_0x2e545f[_0x498b('0xc9')]=qs[_0x498b('0xca')](_0x565444[_0x498b('0x4e')]['sort']);_0x2e545f[_0x498b('0x3c')]=qs[_0x498b('0xcb')](_[_0x498b('0xcc')](_0x565444[_0x498b('0x4e')],_0x5d67fb[_0x498b('0xcb')]));if(_0x565444[_0x498b('0x4e')][_0x498b('0x2d')]){_0x2e545f[_0x498b('0x3c')]=_[_0x498b('0x51')](_0x2e545f['where'],{'$or':_[_0x498b('0x7c')](_0x2e545f[_0x498b('0x42')],function(_0x248074){var _0x1b6f81={};_0x1b6f81[_0x248074]={'$like':'%'+_0x565444[_0x498b('0x4e')][_0x498b('0x2d')]+'%'};return _0x1b6f81;})});}_0x2e545f=_['merge']({},_0x2e545f,_0x565444[_0x498b('0xcd')]);return _0x4fff55['getChatInteractions'](_0x2e545f);}})[_0x498b('0x20')](function(_0x714aac){if(_0x714aac){_0x190987=_0x714aac[_0x498b('0x45')];if(!_0x565444[_0x498b('0x4e')][_0x498b('0xbd')]('nolimit')){_0x2e545f[_0x498b('0x1c')]=qs[_0x498b('0x1c')](_0x565444['query']['limit']);_0x2e545f[_0x498b('0x1b')]=qs[_0x498b('0x1b')](_0x565444[_0x498b('0x4e')][_0x498b('0x1b')]);}return _0x4fff55[_0x498b('0xd7')](_0x2e545f);}})[_0x498b('0x20')](function(_0x5b7076){if(_0x5b7076){return _0x5b7076?{'count':_0x190987,'rows':_0x5b7076}:null;}})[_0x498b('0x20')](respondWithResult(_0x592a31,null))[_0x498b('0x4c')](handleError(_0x592a31,null));};exports['getOpenchannelInteractions']=function(_0x9e3b07,_0x2ee17f){var _0x111b32={};var _0x116498={};var _0x3424bd;var _0x1a9980;return db[_0x498b('0x3d')][_0x498b('0xbb')]({'where':{'id':_0x9e3b07[_0x498b('0x4f')]['id']}})['then'](handleEntityNotFound(_0x2ee17f,null))['then'](function(_0xd77245){if(_0xd77245){_0x3424bd=_0xd77245;_0x116498[_0x498b('0xc7')]=_['keys'](db[_0x498b('0xd8')][_0x498b('0x33')]);_0x116498[_0x498b('0x4e')]=_[_0x498b('0xc4')](_0x9e3b07[_0x498b('0x4e')]);_0x116498['filters']=_['intersection'](_0x116498[_0x498b('0xc7')],_0x116498[_0x498b('0x4e')]);_0x111b32[_0x498b('0x42')]=_['intersection'](_0x116498['model'],qs[_0x498b('0xc8')](_0x9e3b07['query'][_0x498b('0xc8')]));_0x111b32[_0x498b('0x42')]=_0x111b32['attributes'][_0x498b('0x45')]?_0x111b32[_0x498b('0x42')]:_0x116498[_0x498b('0xc7')];_0x111b32[_0x498b('0xc9')]=qs[_0x498b('0xca')](_0x9e3b07[_0x498b('0x4e')]['sort']);_0x111b32[_0x498b('0x3c')]=qs[_0x498b('0xcb')](_[_0x498b('0xcc')](_0x9e3b07[_0x498b('0x4e')],_0x116498[_0x498b('0xcb')]));if(_0x9e3b07['query']['filter']){_0x111b32[_0x498b('0x3c')]=_[_0x498b('0x51')](_0x111b32[_0x498b('0x3c')],{'$or':_[_0x498b('0x7c')](_0x111b32[_0x498b('0x42')],function(_0x235c21){var _0x430e88={};_0x430e88[_0x235c21]={'$like':'%'+_0x9e3b07[_0x498b('0x4e')]['filter']+'%'};return _0x430e88;})});}_0x111b32=_[_0x498b('0x51')]({},_0x111b32,_0x9e3b07[_0x498b('0xcd')]);return _0x3424bd[_0x498b('0xd9')](_0x111b32);}})['then'](function(_0x5e9aa8){if(_0x5e9aa8){_0x1a9980=_0x5e9aa8[_0x498b('0x45')];if(!_0x9e3b07['query'][_0x498b('0xbd')](_0x498b('0xd2'))){_0x111b32[_0x498b('0x1c')]=qs[_0x498b('0x1c')](_0x9e3b07[_0x498b('0x4e')]['limit']);_0x111b32[_0x498b('0x1b')]=qs['offset'](_0x9e3b07[_0x498b('0x4e')][_0x498b('0x1b')]);}return _0x3424bd[_0x498b('0xd9')](_0x111b32);}})[_0x498b('0x20')](function(_0x5a9b99){if(_0x5a9b99){return _0x5a9b99?{'count':_0x1a9980,'rows':_0x5a9b99}:null;}})[_0x498b('0x20')](respondWithResult(_0x2ee17f,null))[_0x498b('0x4c')](handleError(_0x2ee17f,null));};exports[_0x498b('0xda')]=function(_0x42d830,_0xc237ef){var _0x21e826={'raw':!![],'where':{}};var _0x483901={};var _0x2b7fe2={'count':0x0,'rows':[]};return db[_0x498b('0x3d')]['findOne']({'where':{'id':_0x42d830[_0x498b('0x4f')]['id']}})[_0x498b('0x20')](handleEntityNotFound(_0xc237ef,null))[_0x498b('0x20')](function(_0x49e2dc){if(_0x49e2dc){_0x483901[_0x498b('0xc7')]=_['keys'](db[_0x498b('0xdb')][_0x498b('0x33')]);_0x483901[_0x498b('0x4e')]=_[_0x498b('0xc4')](_0x42d830[_0x498b('0x4e')]);_0x483901['filters']=_[_0x498b('0xc6')](_0x483901['model'],_0x483901['query']);_0x21e826[_0x498b('0x42')]=_[_0x498b('0xc6')](_0x483901[_0x498b('0xc7')],qs[_0x498b('0xc8')](_0x42d830[_0x498b('0x4e')]['fields']));_0x21e826[_0x498b('0x42')]=_0x21e826[_0x498b('0x42')][_0x498b('0x45')]?_0x21e826['attributes']:_0x483901[_0x498b('0xc7')];if(!_0x42d830[_0x498b('0x4e')]['hasOwnProperty']('nolimit')){_0x21e826[_0x498b('0x1c')]=qs[_0x498b('0x1c')](_0x42d830[_0x498b('0x4e')][_0x498b('0x1c')]);_0x21e826['offset']=qs['offset'](_0x42d830[_0x498b('0x4e')][_0x498b('0x1b')]);}_0x21e826['order']=qs['sort'](_0x42d830[_0x498b('0x4e')][_0x498b('0xca')]);_0x21e826[_0x498b('0x3c')]=qs[_0x498b('0xcb')](_[_0x498b('0xcc')](_0x42d830[_0x498b('0x4e')],_0x483901[_0x498b('0xcb')]));_0x21e826[_0x498b('0x3c')][_0x498b('0xdc')]=_0x49e2dc['id'];if(_0x42d830[_0x498b('0x4e')][_0x498b('0x2d')]){_0x21e826[_0x498b('0x3c')]=_[_0x498b('0x51')](_0x21e826[_0x498b('0x3c')],{'$or':_[_0x498b('0x7c')](_0x21e826[_0x498b('0x42')],function(_0x5abcae){var _0x5d01e2={};_0x5d01e2[_0x5abcae]={'$like':'%'+_0x42d830[_0x498b('0x4e')][_0x498b('0x2d')]+'%'};return _0x5d01e2;})});}_0x21e826=_['merge']({},_0x21e826,_0x42d830['options']);return db[_0x498b('0xdb')][_0x498b('0x1d')]({'where':_0x21e826[_0x498b('0x3c')]})[_0x498b('0x20')](function(_0x145e0f){_0x2b7fe2[_0x498b('0x1d')]=_0x145e0f;if(_0x42d830[_0x498b('0x4e')][_0x498b('0x3e')]){_0x21e826[_0x498b('0x41')]=[{'all':!![]}];}return db[_0x498b('0xdb')][_0x498b('0x9d')](_0x21e826);})['then'](function(_0x1762ff){_0x2b7fe2[_0x498b('0x43')]=_0x1762ff;return _0x2b7fe2;});}})[_0x498b('0x20')](respondWithFilteredResult(_0xc237ef,_0x21e826))[_0x498b('0x4c')](handleError(_0xc237ef,null));};exports[_0x498b('0xdd')]=function(_0x3fe023,_0x391331){var _0x41830c={};var _0x5ef6a1={};var _0x4a4ad7;var _0x52351f;return db[_0x498b('0x3d')]['findOne']({'where':{'id':_0x3fe023['params']['id']}})['then'](handleEntityNotFound(_0x391331,null))[_0x498b('0x20')](function(_0x439259){if(_0x439259){_0x4a4ad7=_0x439259;_0x5ef6a1[_0x498b('0xc7')]=_[_0x498b('0xc4')](db[_0x498b('0xde')][_0x498b('0x33')]);_0x5ef6a1[_0x498b('0x4e')]=_[_0x498b('0xc4')](_0x3fe023[_0x498b('0x4e')]);_0x5ef6a1[_0x498b('0xcb')]=_['intersection'](_0x5ef6a1[_0x498b('0xc7')],_0x5ef6a1[_0x498b('0x4e')]);_0x41830c[_0x498b('0x42')]=_['intersection'](_0x5ef6a1['model'],qs['fields'](_0x3fe023['query']['fields']));_0x41830c[_0x498b('0x42')]=_0x41830c[_0x498b('0x42')][_0x498b('0x45')]?_0x41830c[_0x498b('0x42')]:_0x5ef6a1[_0x498b('0xc7')];_0x41830c[_0x498b('0xc9')]=qs[_0x498b('0xca')](_0x3fe023['query'][_0x498b('0xca')]);_0x41830c['where']=qs[_0x498b('0xcb')](_['pick'](_0x3fe023['query'],_0x5ef6a1['filters']));if(_0x3fe023[_0x498b('0x4e')][_0x498b('0x2d')]){_0x41830c[_0x498b('0x3c')]=_[_0x498b('0x51')](_0x41830c[_0x498b('0x3c')],{'$or':_['map'](_0x41830c[_0x498b('0x42')],function(_0x3a4956){var _0x1e1bf1={};_0x1e1bf1[_0x3a4956]={'$like':'%'+_0x3fe023[_0x498b('0x4e')][_0x498b('0x2d')]+'%'};return _0x1e1bf1;})});}_0x41830c=_[_0x498b('0x51')]({},_0x41830c,_0x3fe023[_0x498b('0xcd')]);return _0x4a4ad7[_0x498b('0xdd')](_0x41830c);}})[_0x498b('0x20')](function(_0x1cfd72){if(_0x1cfd72){_0x52351f=_0x1cfd72[_0x498b('0x45')];if(!_0x3fe023['query'][_0x498b('0xbd')](_0x498b('0xd2'))){_0x41830c[_0x498b('0x1c')]=qs[_0x498b('0x1c')](_0x3fe023[_0x498b('0x4e')][_0x498b('0x1c')]);_0x41830c[_0x498b('0x1b')]=qs['offset'](_0x3fe023[_0x498b('0x4e')][_0x498b('0x1b')]);}return _0x4a4ad7['getSmsInteractions'](_0x41830c);}})['then'](function(_0x3bc8d4){if(_0x3bc8d4){return _0x3bc8d4?{'count':_0x52351f,'rows':_0x3bc8d4}:null;}})[_0x498b('0x20')](respondWithResult(_0x391331,null))[_0x498b('0x4c')](handleError(_0x391331,null));};exports[_0x498b('0xdf')]=function(_0x2369e4,_0x316ed6){var _0x5996ca={};var _0x4b761e={};var _0x1f6149;var _0x195b8e;return db[_0x498b('0x3d')][_0x498b('0xbb')]({'where':{'id':_0x2369e4[_0x498b('0x4f')]['id']}})[_0x498b('0x20')](handleEntityNotFound(_0x316ed6,null))[_0x498b('0x20')](function(_0x1f77cd){if(_0x1f77cd){_0x1f6149=_0x1f77cd;_0x4b761e[_0x498b('0xc7')]=_['keys'](db[_0x498b('0xe0')][_0x498b('0x33')]);_0x4b761e['query']=_[_0x498b('0xc4')](_0x2369e4[_0x498b('0x4e')]);_0x4b761e['filters']=_[_0x498b('0xc6')](_0x4b761e['model'],_0x4b761e[_0x498b('0x4e')]);_0x5996ca['attributes']=_['intersection'](_0x4b761e[_0x498b('0xc7')],qs[_0x498b('0xc8')](_0x2369e4[_0x498b('0x4e')][_0x498b('0xc8')]));_0x5996ca[_0x498b('0x42')]=_0x5996ca[_0x498b('0x42')]['length']?_0x5996ca[_0x498b('0x42')]:_0x4b761e[_0x498b('0xc7')];_0x5996ca[_0x498b('0xc9')]=qs[_0x498b('0xca')](_0x2369e4['query'][_0x498b('0xca')]);_0x5996ca[_0x498b('0x3c')]=qs[_0x498b('0xcb')](_['pick'](_0x2369e4[_0x498b('0x4e')],_0x4b761e[_0x498b('0xcb')]));if(_0x2369e4[_0x498b('0x4e')]['filter']){_0x5996ca[_0x498b('0x3c')]=_[_0x498b('0x51')](_0x5996ca[_0x498b('0x3c')],{'$or':_[_0x498b('0x7c')](_0x5996ca['attributes'],function(_0x2a73d6){var _0x58dcb9={};_0x58dcb9[_0x2a73d6]={'$like':'%'+_0x2369e4[_0x498b('0x4e')]['filter']+'%'};return _0x58dcb9;})});}_0x5996ca=_[_0x498b('0x51')]({},_0x5996ca,_0x2369e4[_0x498b('0xcd')]);return _0x1f6149['getFaxInteractions'](_0x5996ca);}})[_0x498b('0x20')](function(_0x136be3){if(_0x136be3){_0x195b8e=_0x136be3[_0x498b('0x45')];if(!_0x2369e4['query'][_0x498b('0xbd')](_0x498b('0xd2'))){_0x5996ca[_0x498b('0x1c')]=qs[_0x498b('0x1c')](_0x2369e4[_0x498b('0x4e')][_0x498b('0x1c')]);_0x5996ca['offset']=qs[_0x498b('0x1b')](_0x2369e4[_0x498b('0x4e')][_0x498b('0x1b')]);}return _0x1f6149[_0x498b('0xdf')](_0x5996ca);}})[_0x498b('0x20')](function(_0x5bcf68){if(_0x5bcf68){return _0x5bcf68?{'count':_0x195b8e,'rows':_0x5bcf68}:null;}})[_0x498b('0x20')](respondWithResult(_0x316ed6,null))['catch'](handleError(_0x316ed6,null));};exports[_0x498b('0xe1')]=function(_0x4b27ea,_0x148298){var _0x4c94e5={};var _0x2cbcef={};var _0xdd8534;var _0x23214d;return db[_0x498b('0x3d')][_0x498b('0xbb')]({'where':{'id':_0x4b27ea[_0x498b('0x4f')]['id']}})['then'](handleEntityNotFound(_0x148298,null))[_0x498b('0x20')](function(_0x37ac21){if(_0x37ac21){_0xdd8534=_0x37ac21;_0x2cbcef[_0x498b('0xc7')]=_['keys'](db[_0x498b('0xe2')][_0x498b('0x33')]);_0x2cbcef[_0x498b('0x4e')]=_[_0x498b('0xc4')](_0x4b27ea[_0x498b('0x4e')]);_0x2cbcef[_0x498b('0xcb')]=_[_0x498b('0xc6')](_0x2cbcef[_0x498b('0xc7')],_0x2cbcef['query']);_0x4c94e5[_0x498b('0x42')]=_[_0x498b('0xc6')](_0x2cbcef[_0x498b('0xc7')],qs[_0x498b('0xc8')](_0x4b27ea[_0x498b('0x4e')][_0x498b('0xc8')]));_0x4c94e5['attributes']=_0x4c94e5[_0x498b('0x42')]['length']?_0x4c94e5[_0x498b('0x42')]:_0x2cbcef['model'];_0x4c94e5[_0x498b('0xc9')]=qs['sort'](_0x4b27ea['query'][_0x498b('0xca')]);_0x4c94e5['where']=qs[_0x498b('0xcb')](_[_0x498b('0xcc')](_0x4b27ea[_0x498b('0x4e')],_0x2cbcef['filters']));if(_0x4b27ea[_0x498b('0x4e')][_0x498b('0x2d')]){_0x4c94e5[_0x498b('0x3c')]=_[_0x498b('0x51')](_0x4c94e5[_0x498b('0x3c')],{'$or':_['map'](_0x4c94e5[_0x498b('0x42')],function(_0x2b02af){var _0x21d187={};_0x21d187[_0x2b02af]={'$like':'%'+_0x4b27ea[_0x498b('0x4e')][_0x498b('0x2d')]+'%'};return _0x21d187;})});}_0x4c94e5=_[_0x498b('0x51')]({},_0x4c94e5,_0x4b27ea[_0x498b('0xcd')]);return _0xdd8534[_0x498b('0xe1')](_0x4c94e5);}})[_0x498b('0x20')](function(_0x4d4ffe){if(_0x4d4ffe){_0x23214d=_0x4d4ffe[_0x498b('0x45')];if(!_0x4b27ea[_0x498b('0x4e')][_0x498b('0xbd')](_0x498b('0xd2'))){_0x4c94e5[_0x498b('0x1c')]=qs[_0x498b('0x1c')](_0x4b27ea[_0x498b('0x4e')][_0x498b('0x1c')]);_0x4c94e5['offset']=qs[_0x498b('0x1b')](_0x4b27ea['query']['offset']);}return _0xdd8534['getWhatsappInteractions'](_0x4c94e5);}})[_0x498b('0x20')](function(_0x4d3d66){if(_0x4d3d66){return _0x4d3d66?{'count':_0x23214d,'rows':_0x4d3d66}:null;}})[_0x498b('0x20')](respondWithResult(_0x148298,null))[_0x498b('0x4c')](handleError(_0x148298,null));};exports['login']=function(_0x15f9bd,_0x144a7e,_0x4cdac7){var _0x26fcdf;var _0x321d30;var _0x1c845e;var _0x46601e=!_[_0x498b('0x5d')](_0x15f9bd[_0x498b('0x4f')]['id'])?_0x15f9bd[_0x498b('0x4f')]['id']:!_[_0x498b('0x5d')](_0x15f9bd[_0x498b('0x29')]['id'])?_0x15f9bd[_0x498b('0x29')]['id']:null;return db[_0x498b('0x3d')][_0x498b('0x52')]({'where':{'id':_0x46601e,'role':{'$or':[_0x498b('0x27'),_0x498b('0x29'),_0x498b('0x22')]}},'attributes':['id','name',_0x498b('0xe3'),_0x498b('0xe4'),'role',_0x498b('0x5c'),_0x498b('0x8e')]})['then'](function(_0x128685){if(_0x128685){if(_0x128685[_0x498b('0x21')]===_0x498b('0x22')){_0x26fcdf=_0x128685;if(_0x15f9bd[_0x498b('0x55')][_0x498b('0x90')]){_0x1c845e=util[_0x498b('0x9f')](_0x498b('0xe5'),_0x26fcdf[_0x15f9bd['body']['interface']]);}else if(_0x15f9bd[_0x498b('0x55')][_0x498b('0xe6')]){_0x1c845e=util[_0x498b('0x9f')](_0x498b('0xa0'),_0x15f9bd['body']['intrf']);}else{_0x1c845e=util[_0x498b('0x9f')](_0x498b('0xa0'),_0x26fcdf['name']);}socket['to'](util[_0x498b('0x9f')](_0x498b('0xe7'),_0x26fcdf[_0x498b('0x2f')]))[_0x498b('0x23')](_0x498b('0xe8'),{'user':{'id':_0x26fcdf['id'],'name':_0x26fcdf['name']},'ip':_0x15f9bd[_0x498b('0xe9')][_0x498b('0xea')]||_0x15f9bd[_0x498b('0xeb')][_0x498b('0xec')]||_0x15f9bd[_0x498b('0xed')]['remoteAddress']||_0x15f9bd[_0x498b('0xeb')][_0x498b('0xed')][_0x498b('0xec')]});return db[_0x498b('0xa1')][_0x498b('0x25')]({'where':{'membername':_0x26fcdf[_0x498b('0x2f')]},'individualHooks':!![]});}}else{throw new db['Sequelize']['ValidationError'](_0x498b('0xee'));}})[_0x498b('0x20')](function(){if(_0x26fcdf){return _0x26fcdf[_0x498b('0xef')]({'raw':!![]});}})[_0x498b('0x20')](function(_0x522143){if(_0x26fcdf){if(_0x522143){_0x321d30=_0x522143;if(_0x321d30['length']){var _0x5e2cc4=_0x321d30[_0x498b('0x7c')](function(_0x3c92e3){var _0x4d8cd9={'membername':_0x26fcdf[_0x498b('0x2f')],'UserId':_0x26fcdf['id'],'queue_name':_0x3c92e3[_0x498b('0x2f')],'VoiceQueueId':_0x3c92e3['id'],'interface':_0x1c845e,'paused':_0x26fcdf[_0x498b('0x8e')]||![],'penalty':_0x3c92e3['UserVoiceQueue.penalty']||0x0};return db[_0x498b('0xa1')]['upsert'](_0x4d8cd9);});return Promise[_0x498b('0x4b')](_0x5e2cc4);}}}})[_0x498b('0x20')](function(){if(_0x26fcdf){return db[_0x498b('0xf0')][_0x498b('0x9d')]({'where':{'membername':_0x26fcdf[_0x498b('0x2f')],'exitAt':null}});}})[_0x498b('0x20')](function(_0x382f5c){if(_0x26fcdf){var _0x177819=[];_0x382f5c['forEach'](function(_0x45833f){_0x177819['push'](_0x45833f['update']({'exitAt':moment()[_0x498b('0x9f')](_0x498b('0xf1'))}));});return Promise[_0x498b('0x4b')](_0x177819);}})['then'](function(){if(_0x26fcdf){var _0x518a90=[];var _0x2d4ea0=[];var _0x123fec=utils[_0x498b('0xf2')]();var _0x1fff36={'membername':_0x26fcdf['name'],'interface':_0x1c845e,'enterAt':moment()[_0x498b('0x9f')](_0x498b('0xf1')),'role':_0x26fcdf[_0x498b('0x21')],'internal':_0x26fcdf[_0x498b('0x5c')]};_0x123fec['forEach'](function(_0x226219){_0x518a90[_0x498b('0x46')](_[_0x498b('0x51')]({'channel':_0x226219,'type':'LOGIN','data1':_0x15f9bd[_0x498b('0x55')][_0x498b('0xf3')],'data2':_0x1c845e},_0x1fff36));if(_0x26fcdf[_0x498b('0x8e')]){_0x2d4ea0[_0x498b('0x46')](_[_0x498b('0x51')]({'channel':_0x226219,'type':_0x498b('0xf4'),'data1':'LOGININPAUSE'},_0x1fff36));}});return db[_0x498b('0xf0')][_0x498b('0xf5')](_0x518a90['concat'](_0x2d4ea0),{'individualHooks':!![]});}})[_0x498b('0x20')](function(){if(_0x26fcdf){return _0x26fcdf[_0x498b('0x1f')]({'online':!![],'lastLoginAt':moment()[_0x498b('0x9f')](_0x498b('0xf1')),'voicePause':_0x26fcdf[_0x498b('0x8e')]||![],'mailPause':_0x26fcdf[_0x498b('0x8e')]||![],'chatPause':_0x26fcdf[_0x498b('0x8e')]||![],'faxPause':_0x26fcdf[_0x498b('0x8e')]||![],'smsPause':_0x26fcdf[_0x498b('0x8e')]||![],'openchannelPause':_0x26fcdf[_0x498b('0x8e')]||![],'whatsappPause':_0x26fcdf[_0x498b('0x8e')]||![],'pauseType':_0x26fcdf['loginInPause']?_0x498b('0xf6'):null,'interface':_0x1c845e,'lastPauseAt':moment()['format'](_0x498b('0xf1'))});}})[_0x498b('0x20')](function(_0x2b839f){if(_0x15f9bd[_0x498b('0xf7')]){return _0x4cdac7();}else{return Promise[_0x498b('0xf8')](_0x2b839f)[_0x498b('0x20')](respondWithResult(_0x144a7e,null));}})[_0x498b('0x4c')](handleError(_0x144a7e,null));};exports[_0x498b('0xf9')]=function(_0x4c37c3,_0x5579cc){var _0x551b5e;return db[_0x498b('0x3d')][_0x498b('0x52')]({'where':{'id':_0x4c37c3['params']['id'],'role':_0x498b('0x22')},'attributes':['id',_0x498b('0x2f'),_0x498b('0x21')]})[_0x498b('0x20')](handleEntityNotFound(_0x5579cc,null))[_0x498b('0x20')](function(_0x412b12){if(_0x412b12){_0x551b5e=_0x412b12;return db['UserVoiceQueueRt'][_0x498b('0x25')]({'where':{'membername':_0x551b5e[_0x498b('0x2f')]},'individualHooks':!![]});}})[_0x498b('0x20')](function(){return db[_0x498b('0xf0')][_0x498b('0x9d')]({'where':{'membername':_0x551b5e[_0x498b('0x2f')],'exitAt':null}});})['then'](function(_0x54267c){var _0x634422=[];_0x54267c[_0x498b('0xfa')](function(_0x41b238){_0x634422[_0x498b('0x46')](_0x41b238[_0x498b('0x1f')]({'exitAt':moment()[_0x498b('0x9f')](_0x498b('0xf1'))}));});return Promise[_0x498b('0x4b')](_0x634422);})[_0x498b('0x20')](function(){return _0x551b5e[_0x498b('0x1f')]({'online':![],'voicePause':![],'mailPause':![],'chatPause':![],'faxPause':![],'smsPause':![],'openchannelPause':![],'whatsappPause':![],'interface':null});})['then'](respondWithResult(_0x5579cc,null))['catch'](handleError(_0x5579cc,null));};exports[_0x498b('0xfb')]=function(_0x2f9084,_0x58ab21){var _0xbfccbe;return db[_0x498b('0xa1')]['update']({'paused':0x1},{'where':{'UserId':_0x2f9084['params']['id']},'individualHooks':!![]})[_0x498b('0x20')](function(){return db[_0x498b('0x3d')][_0x498b('0x52')]({'where':{'id':_0x2f9084[_0x498b('0x4f')]['id'],'role':'agent'},'attributes':['id',_0x498b('0x2f'),_0x498b('0x21'),_0x498b('0x5c'),_0x498b('0x90'),_0x498b('0x9e')]});})[_0x498b('0x20')](handleEntityNotFound(_0x58ab21,null))[_0x498b('0x20')](function(_0x30273e){if(_0x30273e){_0xbfccbe=_0x30273e;return db[_0x498b('0xf0')]['findAll']({'where':{'membername':_0xbfccbe[_0x498b('0x2f')],'type':_0x498b('0xf4'),'exitAt':null}});}})[_0x498b('0x20')](function(_0x2ed1f6){if(_0x2ed1f6[_0x498b('0x45')]){var _0x45dc50=moment()[_0x498b('0x9f')](_0x498b('0xf1'));for(var _0x4d4111=0x0,_0x5692c8=_0x2ed1f6['length'];_0x4d4111<_0x5692c8;_0x4d4111++){_0x2ed1f6[_0x4d4111][_0x498b('0xfc')]({'exitAt':_0x45dc50});}}})[_0x498b('0x20')](function(){var _0x40b597=[];var _0x2c213e=utils[_0x498b('0xf2')]();_0x2c213e['forEach'](function(_0x2c9430){_0x40b597[_0x498b('0x46')]({'channel':_0x2c9430,'membername':_0xbfccbe['name'],'interface':_[_0x498b('0x5d')](_0xbfccbe[_0x498b('0x90')])?util[_0x498b('0x9f')](_0x498b('0xa0'),_0xbfccbe[_0x498b('0x2f')]):_0xbfccbe['interface'],'type':_0x498b('0xf4'),'enterAt':moment()['format'](_0x498b('0xf1')),'data1':_0x2f9084[_0x498b('0x55')][_0x498b('0x35')]||_0x498b('0xfd'),'role':_0xbfccbe[_0x498b('0x21')],'internal':_0xbfccbe['internal']});});return db[_0x498b('0xf0')][_0x498b('0xf5')](_0x40b597,{'individualHooks':!![]});})[_0x498b('0x20')](function(){return _0xbfccbe[_0x498b('0x1f')]({'voicePause':!![],'mailPause':!![],'chatPause':!![],'faxPause':!![],'smsPause':!![],'whatsappPause':!![],'openchannelPause':!![],'pauseType':_0x2f9084[_0x498b('0x55')][_0x498b('0x35')]||'DEFAULT\x20PAUSE','lastPauseAt':moment()[_0x498b('0x9f')]('YYYY-MM-DD\x20HH:mm:ss')});})[_0x498b('0x20')](respondWithResult(_0x58ab21,null))[_0x498b('0x4c')](handleError(_0x58ab21,null));};exports[_0x498b('0xfe')]=function(_0x16dae8,_0x5596bd){if(_0x16dae8['body'][_0x498b('0x8d')]&&!utils['isValidChannel'](_0x16dae8[_0x498b('0x55')][_0x498b('0x8d')])){throw new APIBadRequestError(util['format'](_0x498b('0xff'),_0x16dae8[_0x498b('0x55')][_0x498b('0x8d')]));}return db[_0x498b('0x3d')][_0x498b('0x52')]({'where':{'id':_0x16dae8['params']['id']},'attributes':['id','name','role',_0x498b('0x5c'),_0x498b('0x90'),_0x498b('0x9e'),_0x498b('0x8f'),_0x498b('0x100'),_0x498b('0x101'),_0x498b('0x102'),_0x498b('0x103'),_0x498b('0x104'),'whatsappPause',_0x498b('0x105'),'lastPauseAt']})[_0x498b('0x20')](function(_0x4a49c5){if(!_0x4a49c5){throw new APINotFoundError(util[_0x498b('0x9f')](_0x498b('0xbc'),_0x16dae8[_0x498b('0x4f')]['id']));}return _0x4a49c5[_0x498b('0xfe')](_0x16dae8[_0x498b('0x55')]['channel']);})[_0x498b('0x20')](respondWithResult(_0x5596bd,null))[_0x498b('0x4c')](APIHandleError(_0x5596bd));};exports['getTeams']=function(_0x535d90,_0x29a65d){var _0x4fe114={};var _0x4a5340={};var _0x3f1ce2;var _0x33249f;return db[_0x498b('0x3d')][_0x498b('0xbb')]({'where':{'id':_0x535d90[_0x498b('0x4f')]['id']}})[_0x498b('0x20')](handleEntityNotFound(_0x29a65d,null))[_0x498b('0x20')](function(_0x4c100c){if(_0x4c100c){_0x3f1ce2=_0x4c100c;_0x4a5340['model']=_[_0x498b('0xc4')](db[_0x498b('0x106')]['rawAttributes']);_0x4a5340[_0x498b('0x4e')]=_['keys'](_0x535d90[_0x498b('0x4e')]);_0x4a5340[_0x498b('0xcb')]=_[_0x498b('0xc6')](_0x4a5340[_0x498b('0xc7')],_0x4a5340[_0x498b('0x4e')]);_0x4fe114['attributes']=_['intersection'](_0x4a5340[_0x498b('0xc7')],qs['fields'](_0x535d90[_0x498b('0x4e')][_0x498b('0xc8')]));_0x4fe114[_0x498b('0x42')]=_0x4fe114[_0x498b('0x42')][_0x498b('0x45')]?_0x4fe114['attributes']:_0x4a5340[_0x498b('0xc7')];_0x4fe114[_0x498b('0xc9')]=qs[_0x498b('0xca')](_0x535d90[_0x498b('0x4e')][_0x498b('0xca')]);_0x4fe114[_0x498b('0x3c')]=qs[_0x498b('0xcb')](_['pick'](_0x535d90['query'],_0x4a5340[_0x498b('0xcb')]));if(_0x535d90['query'][_0x498b('0x2d')]){_0x4fe114['where']=_[_0x498b('0x51')](_0x4fe114[_0x498b('0x3c')],{'$or':_[_0x498b('0x7c')](_0x4fe114[_0x498b('0x42')],function(_0x1a8e13){var _0x285ff6={};_0x285ff6[_0x1a8e13]={'$like':'%'+_0x535d90[_0x498b('0x4e')][_0x498b('0x2d')]+'%'};return _0x285ff6;})});}_0x4fe114=_[_0x498b('0x51')]({},_0x4fe114,_0x535d90[_0x498b('0xcd')]);return _0x3f1ce2['getTeams'](_0x4fe114);}})[_0x498b('0x20')](function(_0x28dbb0){if(_0x28dbb0){_0x33249f=_0x28dbb0['length'];if(!_0x535d90[_0x498b('0x4e')][_0x498b('0xbd')]('nolimit')){_0x4fe114['limit']=qs[_0x498b('0x1c')](_0x535d90[_0x498b('0x4e')]['limit']);_0x4fe114['offset']=qs[_0x498b('0x1b')](_0x535d90[_0x498b('0x4e')]['offset']);}return _0x3f1ce2['getTeams'](_0x4fe114);}})[_0x498b('0x20')](function(_0x10f87a){if(_0x10f87a){return _0x10f87a?{'count':_0x33249f,'rows':_0x10f87a}:null;}})['then'](respondWithResult(_0x29a65d,null))[_0x498b('0x4c')](handleError(_0x29a65d,null));};exports[_0x498b('0x107')]=function(_0x2ee48a,_0x4557fd){var _0x4514e8=_0x2ee48a[_0x498b('0x4f')]['id'];var _0xf0ce7f=_0x2ee48a['body']?_0x2ee48a['body'][_0x498b('0x96')]:null;var _0x4386ad=[];return Promise[_0x498b('0xf8')]()[_0x498b('0x20')](function(){if(!_0xf0ce7f)throw new APIBadRequestError(_0x498b('0x108'));})['then'](function(){return db[_0x498b('0x3d')][_0x498b('0xbb')]({'where':{'id':_0x4514e8}});})['then'](function(_0x3541df){if(!_0x3541df)throw new APINotFoundError(util['format'](_0x498b('0xbc'),_0x2ee48a[_0x498b('0x4f')]['id']));return db['sequelize']['transaction'](function(_0x252fb6){return _0x3541df[_0x498b('0x107')](_0xf0ce7f,{'transaction':_0x252fb6})[_0x498b('0x20')](function(){return db[_0x498b('0x106')][_0x498b('0x9d')]({'where':{'id':{'$in':_0xf0ce7f}}});})[_0x498b('0x20')](function(_0x3ffc7f){var _0xd4464a=_['map'](_0x3ffc7f,function(_0x86c0aa){return _0x86c0aa[_0x498b('0x109')]();});return Promise[_0x498b('0x4b')](_0xd4464a);})['then'](function(_0x18a80a){_0x4386ad=_[_0x498b('0x10a')](_0x18a80a);var _0x1ee2e4=_[_0x498b('0x7c')](_0x4386ad,function(_0x45fa88){return _0x45fa88[_0x498b('0x10b')](_0x3541df['id'],{'transaction':_0x252fb6});});return Promise['all'](_0x1ee2e4);})[_0x498b('0x20')](function(){if(!_0x3541df['online'])return;var _0x5ba3c6=_[_0x498b('0x2d')](_0x4386ad,function(_0x1297ca){return _0x1297ca['getDataValue'](_0x498b('0x8d'))===_0x498b('0x10c');});var _0x1f4d12=_[_0x498b('0x7c')](_0x5ba3c6,function(_0x509c65){return db['UserVoiceQueueRt'][_0x498b('0x10d')]({'membername':_0x3541df[_0x498b('0x2f')],'UserId':_0x3541df['id'],'queue_name':_0x509c65[_0x498b('0x2f')],'VoiceQueueId':_0x509c65['id'],'interface':_[_0x498b('0x5d')](_0x3541df['interface'])?util['format']('SIP/%s',_0x3541df[_0x498b('0x2f')]):_0x3541df[_0x498b('0x90')],'paused':_0x3541df['voicePause']||![],'penalty':_0x3541df[_0x498b('0x97')]},{'transaction':_0x252fb6});});return Promise['all'](_0x1f4d12);})[_0x498b('0x20')](function(){return db['TeamVoicePrefix']['findAll']({'where':{'teamId':{'$in':_0xf0ce7f}}});})['then'](function(_0x541125){var _0x159497=_[_0x498b('0x7c')](_0x541125,function(_0x461a9e){return db[_0x498b('0x10e')]['create']({'UserId':_0x3541df['id'],'VoicePrefixId':_0x461a9e['VoicePrefixId']},{'transaction':_0x252fb6});});return Promise['all'](_0x159497);});});})[_0x498b('0x20')](function(){for(var _0x42d124=0x0;_0x42d124<_0x4386ad[_0x498b('0x45')];_0x42d124++){var _0x595f5c=_0x4386ad[_0x42d124][_0x498b('0x10f')]('channel');var _0x4fe41c=_0x595f5c+_0x498b('0x99');socket['emit'](_0x498b('0x29')+_0x595f5c+_0x498b('0x9a'),{'UserId':_0x4514e8,['queueField']:_0x4386ad[_0x42d124]['id']});}})[_0x498b('0x20')](respondWithStatusCode(_0x4557fd,null))['catch'](APIHandleError(_0x4557fd));};exports[_0x498b('0x110')]=function(_0x2584ed,_0x5d763f){var _0x4d5825=_0x2584ed[_0x498b('0x4f')]['id'];var _0x320dcb=null;if(_0x2584ed[_0x498b('0x4e')][_0x498b('0x96')]){_0x320dcb=_[_0x498b('0x111')](_0x2584ed[_0x498b('0x4e')]['ids'])?_0x2584ed['query'][_0x498b('0x96')]:[_0x2584ed['query']['ids']];}var _0xd9823a=[];return Promise[_0x498b('0xf8')]()[_0x498b('0x20')](function(){if(!_0x320dcb)throw new APIBadRequestError(_0x498b('0x112'));})[_0x498b('0x20')](function(){return db[_0x498b('0x3d')][_0x498b('0xbb')]({'where':{'id':_0x4d5825}});})[_0x498b('0x20')](function(_0x3f3f98){if(!_0x3f3f98)throw new APINotFoundError(util[_0x498b('0x9f')](_0x498b('0xbc'),_0x2584ed[_0x498b('0x4f')]['id']));return db[_0x498b('0x5f')][_0x498b('0x113')](function(_0x5b5ae0){return _0x3f3f98['removeTeams'](_0x320dcb,{'transaction':_0x5b5ae0})[_0x498b('0x20')](function(){return db['Team'][_0x498b('0x9d')]({'where':{'id':{'$in':_0x320dcb}}});})[_0x498b('0x20')](function(_0x5b076f){var _0x2ffd81=_['map'](_0x5b076f,function(_0x901271){return _0x901271[_0x498b('0x109')]();});return Promise['all'](_0x2ffd81);})['then'](function(_0x8601bd){_0xd9823a=_[_0x498b('0x10a')](_0x8601bd);var _0x1369f8=_['map'](_0xd9823a,function(_0x259258){return _0x259258[_0x498b('0x114')](_0x3f3f98['id'],{'transaction':_0x5b5ae0});});return Promise[_0x498b('0x4b')](_0x1369f8);})[_0x498b('0x20')](function(){if(!_0x3f3f98[_0x498b('0x9e')])return;var _0x2ddc36=_['filter'](_0xd9823a,function(_0xb9d928){return _0xb9d928[_0x498b('0x10f')]('channel')===_0x498b('0x10c');});var _0x577d29=_[_0x498b('0x7c')](_0x2ddc36,function(_0x12e803){return db[_0x498b('0xa1')][_0x498b('0x25')]({'where':{'VoiceQueueId':_0x12e803['id'],'UserId':_0x3f3f98['id']},'transaction':_0x5b5ae0});});return Promise[_0x498b('0x4b')](_0x577d29);})['then'](function(){return db['TeamVoicePrefix'][_0x498b('0x9d')]({'where':{'teamId':{'$in':_0x320dcb}}});})[_0x498b('0x20')](function(_0x2c2553){var _0x53fd37=_[_0x498b('0x7c')](_0x2c2553,function(_0x3fbbce){return db[_0x498b('0x10e')]['destroy']({'where':{'UserId':_0x3f3f98['id'],'VoicePrefixId':_0x3fbbce[_0x498b('0x115')]}},{'transaction':_0x5b5ae0});});return Promise[_0x498b('0x4b')](_0x53fd37);});});})[_0x498b('0x20')](function(){for(var _0x1732a1=0x0;_0x1732a1<_0xd9823a['length'];_0x1732a1++){var _0x49de6a=_0xd9823a[_0x1732a1][_0x498b('0x10f')]('channel');var _0x15de1e=_0x49de6a+'QueueId';socket[_0x498b('0x23')](_0x498b('0x29')+_0x49de6a+_0x498b('0xa4'),{'UserId':_0x4d5825,['queueField']:_0xd9823a[_0x1732a1]['id']});}})['then'](respondWithStatusCode(_0x5d763f,null))[_0x498b('0x4c')](APIHandleError(_0x5d763f));};exports[_0x498b('0x116')]=function(_0x140173,_0xda9725){var _0x4f929c={};var _0x1e8f63={};var _0x50bd77;var _0x4da8a7;return db[_0x498b('0x3d')]['findOne']({'where':{'id':_0x140173['params']['id']}})[_0x498b('0x20')](handleEntityNotFound(_0xda9725,null))[_0x498b('0x20')](function(_0x1548d1){if(_0x1548d1){_0x50bd77=_0x1548d1;_0x1e8f63[_0x498b('0xc7')]=_[_0x498b('0xc4')](db[_0x498b('0xbe')][_0x498b('0x33')]);_0x1e8f63[_0x498b('0x4e')]=_['keys'](_0x140173[_0x498b('0x4e')]);_0x1e8f63['filters']=_['intersection'](_0x1e8f63[_0x498b('0xc7')],_0x1e8f63[_0x498b('0x4e')]);_0x4f929c[_0x498b('0x42')]=_['intersection'](_0x1e8f63[_0x498b('0xc7')],qs[_0x498b('0xc8')](_0x140173[_0x498b('0x4e')]['fields']));_0x4f929c[_0x498b('0x42')]=_0x4f929c[_0x498b('0x42')][_0x498b('0x45')]?_0x4f929c[_0x498b('0x42')]:_0x1e8f63[_0x498b('0xc7')];_0x4f929c['order']=qs['sort'](_0x140173[_0x498b('0x4e')][_0x498b('0xca')]);_0x4f929c[_0x498b('0x3c')]=qs[_0x498b('0xcb')](_['pick'](_0x140173['query'],_0x1e8f63[_0x498b('0xcb')]));if(_0x140173['query'][_0x498b('0x2d')]){_0x4f929c[_0x498b('0x3c')]=_[_0x498b('0x51')](_0x4f929c[_0x498b('0x3c')],{'$or':_[_0x498b('0x7c')](_0x4f929c[_0x498b('0x42')],function(_0x4c50cd){var _0x3f2ece={};_0x3f2ece[_0x4c50cd]={'$like':'%'+_0x140173['query'][_0x498b('0x2d')]+'%'};return _0x3f2ece;})});}_0x4f929c=_['merge']({},_0x4f929c,_0x140173['options']);return _0x50bd77[_0x498b('0x116')](_0x4f929c);}})[_0x498b('0x20')](function(_0xc451d4){if(_0xc451d4){_0x4da8a7=_0xc451d4[_0x498b('0x45')];if(!_0x140173[_0x498b('0x4e')][_0x498b('0xbd')](_0x498b('0xd2'))){_0x4f929c[_0x498b('0x1c')]=qs[_0x498b('0x1c')](_0x140173[_0x498b('0x4e')]['limit']);_0x4f929c[_0x498b('0x1b')]=qs['offset'](_0x140173['query'][_0x498b('0x1b')]);}return _0x50bd77[_0x498b('0x116')](_0x4f929c);}})[_0x498b('0x20')](function(_0x59361a){if(_0x59361a){return _0x59361a?{'count':_0x4da8a7,'rows':_0x59361a}:null;}})['then'](respondWithResult(_0xda9725,null))['catch'](handleError(_0xda9725,null));};exports[_0x498b('0x117')]=function(_0x329681,_0x24c83a){var _0x4e103c={};var _0x50dce6={};var _0x192f87;return db[_0x498b('0x3d')][_0x498b('0xbb')]({'where':{'id':_0x329681['params']['id']}})[_0x498b('0x20')](handleEntityNotFound(_0x24c83a,null))[_0x498b('0x20')](function(_0x4f9aec){if(_0x4f9aec){_0x192f87=_0x4f9aec;_0x50dce6[_0x498b('0xc7')]=_[_0x498b('0xc4')](db[_0x498b('0x3d')][_0x498b('0x33')]);_0x50dce6['query']=_[_0x498b('0xc4')](_0x329681[_0x498b('0x4e')]);_0x50dce6[_0x498b('0xcb')]=_[_0x498b('0xc6')](_0x50dce6['model'],_0x50dce6[_0x498b('0x4e')]);_0x4e103c[_0x498b('0x42')]=_[_0x498b('0xc6')](_0x50dce6[_0x498b('0xc7')],qs['fields'](_0x329681['query']['fields']));_0x4e103c[_0x498b('0x42')]=_0x4e103c[_0x498b('0x42')]['length']?_0x4e103c[_0x498b('0x42')]:_0x50dce6[_0x498b('0xc7')];_0x4e103c['order']=qs[_0x498b('0xca')](_0x329681['query'][_0x498b('0xca')]);_0x4e103c[_0x498b('0x3c')]=qs['filters'](_[_0x498b('0xcc')](_0x329681[_0x498b('0x4e')],_0x50dce6[_0x498b('0xcb')]));if(_0x329681[_0x498b('0x4e')]['filter']){_0x4e103c[_0x498b('0x3c')]=_[_0x498b('0x51')](_0x4e103c[_0x498b('0x3c')],{'$or':_[_0x498b('0x7c')](_0x4e103c[_0x498b('0x42')],function(_0x52c52a){var _0x2f862e={};_0x2f862e[_0x52c52a]={'$like':'%'+_0x329681[_0x498b('0x4e')]['filter']+'%'};return _0x2f862e;})});}_0x4e103c[_0x498b('0xc7')]=db[_0x498b('0x3d')];_0x4e103c['as']=_0x498b('0x2a');_0x4e103c=_[_0x498b('0x51')]({},_0x4e103c,_0x329681[_0x498b('0xcd')]);return _0x192f87['getVoiceQueues']({'include':[_0x4e103c]});}})[_0x498b('0x20')](function(_0x500c35){if(_0x500c35){var _0x2990a7={},_0x2644fe=[];for(var _0x35bdd7=0x0;_0x35bdd7<_0x500c35[_0x498b('0x45')];_0x35bdd7+=0x1){for(var _0x464392=0x0,_0x3566b7;_0x464392<_0x500c35[_0x35bdd7][_0x498b('0x2a')][_0x498b('0x45')];_0x464392+=0x1){_0x3566b7=_0x500c35[_0x35bdd7][_0x498b('0x2a')][_0x464392][_0x498b('0x26')]({'plain':!![]});_0x2990a7[_0x3566b7['id']]=_0x3566b7;}}_0x2990a7=_[_0x498b('0x118')](_0x2990a7);for(var _0x25219d=qs['offset'](_0x329681['query'][_0x498b('0x1b')]);_0x25219d<_0x2990a7['length']&&_0x2644fe['length']<qs[_0x498b('0x1c')](_0x329681[_0x498b('0x4e')][_0x498b('0x1c')]);_0x25219d+=0x1){if(_0x2990a7[_0x25219d]){_0x2644fe[_0x498b('0x46')](_0x2990a7[_0x25219d]);}}return{'count':_0x2990a7[_0x498b('0x45')],'rows':_0x2644fe};}})['then'](respondWithResult(_0x24c83a,null))[_0x498b('0x4c')](handleError(_0x24c83a,null));};exports[_0x498b('0x25')]=function(_0x274451,_0x2899f3){if(_0x274451['user']['id']==_0x274451[_0x498b('0x4f')]['id']){return _0x2899f3['status'](0x1f4)[_0x498b('0x32')]({'message':'You\x20can\x27t\x20delete\x20yourself'});}return db[_0x498b('0x3d')][_0x498b('0x52')]({'where':{'id':_0x274451[_0x498b('0x4f')]['id']}})[_0x498b('0x20')](handleEntityNotFound(_0x2899f3,null))[_0x498b('0x20')](removeEntity(_0x2899f3,null))[_0x498b('0x4c')](handleError(_0x2899f3,null));};exports['addChatInteractions']=function(_0x248c3d,_0x3ffb8c){return db['User'][_0x498b('0x52')]({'where':{'id':_0x248c3d['params']['id']}})[_0x498b('0x20')](handleEntityNotFound(_0x3ffb8c,null))['then'](function(_0x1fc9e0){if(_0x1fc9e0){return _0x1fc9e0[_0x498b('0x119')](_0x248c3d[_0x498b('0x55')]['ids'],_[_0x498b('0x11a')](_0x248c3d[_0x498b('0x55')],['ids','id'])||{})[_0x498b('0x11b')](function(){for(var _0x551636=0x0;_0x551636<_0x248c3d[_0x498b('0x55')][_0x498b('0x96')][_0x498b('0x45')];_0x551636+=0x1){socket[_0x498b('0x23')](_0x498b('0x11c'),{'ChatInteractionId':Number(_0x248c3d[_0x498b('0x55')][_0x498b('0x96')][_0x551636]),'UserId':Number(_0x248c3d[_0x498b('0x4f')]['id'])});}return _0x248c3d[_0x498b('0x55')][_0x498b('0x96')];});}})['then'](respondWithResult(_0x3ffb8c,null))[_0x498b('0x4c')](handleError(_0x3ffb8c,null));};exports['removeChatInteractions']=function(_0x2a8980,_0x5f126d){return db[_0x498b('0x3d')][_0x498b('0x52')]({'where':{'id':_0x2a8980['params']['id']}})[_0x498b('0x20')](handleEntityNotFound(_0x5f126d,null))[_0x498b('0x20')](function(_0xaccc0){if(_0xaccc0){return _0xaccc0[_0x498b('0x11d')](_0x2a8980[_0x498b('0x4e')][_0x498b('0x96')])['then'](function(){if(_[_0x498b('0x111')](_0x2a8980[_0x498b('0x4e')][_0x498b('0x96')])){for(var _0x21fda6=0x0;_0x21fda6<_0x2a8980[_0x498b('0x4e')]['ids'][_0x498b('0x45')];_0x21fda6+=0x1){socket[_0x498b('0x23')](_0x498b('0x11e'),{'ChatInteractionId':Number(_0x2a8980[_0x498b('0x4e')][_0x498b('0x96')][_0x21fda6]),'UserId':Number(_0x2a8980[_0x498b('0x4f')]['id'])});}}else{socket[_0x498b('0x23')]('user_has_chat_interactions:remove',{'ChatInteractionId':Number(_0x2a8980[_0x498b('0x4e')][_0x498b('0x96')]),'UserId':Number(_0x2a8980[_0x498b('0x4f')]['id'])});}});}})[_0x498b('0x20')](respondWithStatusCode(_0x5f126d,null))[_0x498b('0x4c')](handleError(_0x5f126d,null));};exports['addMailInteractions']=function(_0x19ca0c,_0x5a6f99){return db[_0x498b('0x3d')][_0x498b('0x52')]({'where':{'id':_0x19ca0c[_0x498b('0x4f')]['id']}})[_0x498b('0x20')](handleEntityNotFound(_0x5a6f99,null))[_0x498b('0x20')](function(_0xe5197a){if(_0xe5197a){return _0xe5197a['addMailInteractions'](_0x19ca0c[_0x498b('0x55')][_0x498b('0x96')],_['omit'](_0x19ca0c[_0x498b('0x55')],[_0x498b('0x96'),'id'])||{})['spread'](function(){for(var _0x1ee158=0x0;_0x1ee158<_0x19ca0c[_0x498b('0x55')]['ids'][_0x498b('0x45')];_0x1ee158+=0x1){socket[_0x498b('0x23')]('user_has_mail_interactions:save',{'MailInteractionId':Number(_0x19ca0c['body'][_0x498b('0x96')][_0x1ee158]),'UserId':Number(_0x19ca0c[_0x498b('0x4f')]['id'])});}return _0x19ca0c[_0x498b('0x55')][_0x498b('0x96')];});}})[_0x498b('0x20')](respondWithResult(_0x5a6f99,null))[_0x498b('0x4c')](handleError(_0x5a6f99,null));};exports[_0x498b('0x11f')]=function(_0x5f542b,_0x36c0c7){return db[_0x498b('0x3d')]['find']({'where':{'id':_0x5f542b[_0x498b('0x4f')]['id']}})[_0x498b('0x20')](handleEntityNotFound(_0x36c0c7,null))['then'](function(_0x421a67){if(_0x421a67){return _0x421a67[_0x498b('0x11f')](_0x5f542b[_0x498b('0x4e')][_0x498b('0x96')])[_0x498b('0x20')](function(){if(_['isArray'](_0x5f542b[_0x498b('0x4e')]['ids'])){for(var _0xea565b=0x0;_0xea565b<_0x5f542b['query'][_0x498b('0x96')][_0x498b('0x45')];_0xea565b+=0x1){socket[_0x498b('0x23')]('user_has_mail_interactions:remove',{'MailInteractionId':Number(_0x5f542b['query'][_0x498b('0x96')][_0xea565b]),'UserId':Number(_0x5f542b['params']['id'])});}}else{socket[_0x498b('0x23')]('user_has_mail_interactions:remove',{'MailInteractionId':Number(_0x5f542b[_0x498b('0x4e')][_0x498b('0x96')]),'UserId':Number(_0x5f542b['params']['id'])});}});}})[_0x498b('0x20')](respondWithStatusCode(_0x36c0c7,null))[_0x498b('0x4c')](handleError(_0x36c0c7,null));};exports[_0x498b('0x120')]=function(_0x13dc0a,_0x50617a){return db['User'][_0x498b('0x52')]({'where':{'id':_0x13dc0a[_0x498b('0x4f')]['id']}})[_0x498b('0x20')](handleEntityNotFound(_0x50617a,null))['then'](function(_0x1269c5){if(_0x1269c5){return _0x1269c5[_0x498b('0x120')](_0x13dc0a['body'][_0x498b('0x96')],_[_0x498b('0x11a')](_0x13dc0a[_0x498b('0x55')],[_0x498b('0x96'),'id'])||{})[_0x498b('0x11b')](function(){for(var _0x2de4b5=0x0;_0x2de4b5<_0x13dc0a[_0x498b('0x55')][_0x498b('0x96')]['length'];_0x2de4b5+=0x1){socket['emit']('user_has_fax_interactions:save',{'FaxInteractionId':Number(_0x13dc0a[_0x498b('0x55')][_0x498b('0x96')][_0x2de4b5]),'UserId':Number(_0x13dc0a[_0x498b('0x4f')]['id'])});}return _0x13dc0a[_0x498b('0x55')][_0x498b('0x96')];});}})[_0x498b('0x20')](respondWithResult(_0x50617a,null))[_0x498b('0x4c')](handleError(_0x50617a,null));};exports[_0x498b('0x121')]=function(_0x3e8a95,_0x5f0a56){return db[_0x498b('0x3d')]['find']({'where':{'id':_0x3e8a95[_0x498b('0x4f')]['id']}})[_0x498b('0x20')](handleEntityNotFound(_0x5f0a56,null))[_0x498b('0x20')](function(_0x30cf90){if(_0x30cf90){return _0x30cf90[_0x498b('0x121')](_0x3e8a95[_0x498b('0x4e')][_0x498b('0x96')])['then'](function(){if(_['isArray'](_0x3e8a95[_0x498b('0x4e')][_0x498b('0x96')])){for(var _0x5069b3=0x0;_0x5069b3<_0x3e8a95[_0x498b('0x4e')][_0x498b('0x96')][_0x498b('0x45')];_0x5069b3+=0x1){socket[_0x498b('0x23')](_0x498b('0x122'),{'FaxInteractionId':Number(_0x3e8a95['query'][_0x498b('0x96')][_0x5069b3]),'UserId':Number(_0x3e8a95[_0x498b('0x4f')]['id'])});}}else{socket[_0x498b('0x23')](_0x498b('0x122'),{'FaxInteractionId':Number(_0x3e8a95[_0x498b('0x4e')][_0x498b('0x96')]),'UserId':Number(_0x3e8a95[_0x498b('0x4f')]['id'])});}});}})['then'](respondWithStatusCode(_0x5f0a56,null))[_0x498b('0x4c')](handleError(_0x5f0a56,null));};exports[_0x498b('0x123')]=function(_0x5016df,_0x5f1702){return db[_0x498b('0x3d')][_0x498b('0x52')]({'where':{'id':_0x5016df['params']['id']}})['then'](handleEntityNotFound(_0x5f1702,null))[_0x498b('0x20')](function(_0x303b37){if(_0x303b37){return _0x303b37[_0x498b('0x123')](_0x5016df['body']['ids'],_[_0x498b('0x11a')](_0x5016df[_0x498b('0x55')],[_0x498b('0x96'),'id'])||{})[_0x498b('0x11b')](function(){for(var _0x3185fb=0x0;_0x3185fb<_0x5016df[_0x498b('0x55')][_0x498b('0x96')][_0x498b('0x45')];_0x3185fb+=0x1){socket['emit']('user_has_sms_interactions:save',{'SmsInteractionId':Number(_0x5016df[_0x498b('0x55')][_0x498b('0x96')][_0x3185fb]),'UserId':Number(_0x5016df['params']['id'])});}return _0x5016df[_0x498b('0x55')]['ids'];});}})['then'](respondWithResult(_0x5f1702,null))[_0x498b('0x4c')](handleError(_0x5f1702,null));};exports[_0x498b('0x124')]=function(_0x51e0a4,_0x8835cc){return db[_0x498b('0x3d')][_0x498b('0x52')]({'where':{'id':_0x51e0a4['params']['id']}})[_0x498b('0x20')](handleEntityNotFound(_0x8835cc,null))[_0x498b('0x20')](function(_0x4e59ab){if(_0x4e59ab){return _0x4e59ab['removeSmsInteractions'](_0x51e0a4[_0x498b('0x4e')][_0x498b('0x96')])[_0x498b('0x20')](function(){if(_[_0x498b('0x111')](_0x51e0a4['query'][_0x498b('0x96')])){for(var _0xd276ac=0x0;_0xd276ac<_0x51e0a4[_0x498b('0x4e')][_0x498b('0x96')][_0x498b('0x45')];_0xd276ac+=0x1){socket[_0x498b('0x23')](_0x498b('0x125'),{'SmsInteractionId':Number(_0x51e0a4['query'][_0x498b('0x96')][_0xd276ac]),'UserId':Number(_0x51e0a4[_0x498b('0x4f')]['id'])});}}else{socket['emit'](_0x498b('0x125'),{'SmsInteractionId':Number(_0x51e0a4['query'][_0x498b('0x96')]),'UserId':Number(_0x51e0a4[_0x498b('0x4f')]['id'])});}});}})[_0x498b('0x20')](respondWithStatusCode(_0x8835cc,null))[_0x498b('0x4c')](handleError(_0x8835cc,null));};exports['addOpenchannelInteractions']=function(_0x164452,_0x41419b){return db['User'][_0x498b('0x52')]({'where':{'id':_0x164452['params']['id']}})['then'](handleEntityNotFound(_0x41419b,null))[_0x498b('0x20')](function(_0x54b5da){if(_0x54b5da){return _0x54b5da[_0x498b('0x126')](_0x164452[_0x498b('0x55')][_0x498b('0x96')],_[_0x498b('0x11a')](_0x164452[_0x498b('0x55')],['ids','id'])||{})[_0x498b('0x11b')](function(){for(var _0x45ca23=0x0;_0x45ca23<_0x164452[_0x498b('0x55')][_0x498b('0x96')][_0x498b('0x45')];_0x45ca23+=0x1){socket[_0x498b('0x23')](_0x498b('0x127'),{'OpenchannelInteractionId':Number(_0x164452[_0x498b('0x55')][_0x498b('0x96')][_0x45ca23]),'UserId':Number(_0x164452['params']['id'])});}return _0x164452[_0x498b('0x55')]['ids'];});}})[_0x498b('0x20')](respondWithResult(_0x41419b,null))['catch'](handleError(_0x41419b,null));};exports[_0x498b('0x128')]=function(_0x32fb68,_0x562341){return db['User'][_0x498b('0x52')]({'where':{'id':_0x32fb68['params']['id']}})[_0x498b('0x20')](handleEntityNotFound(_0x562341,null))[_0x498b('0x20')](function(_0x1c39cb){if(_0x1c39cb){return _0x1c39cb[_0x498b('0x128')](_0x32fb68[_0x498b('0x4e')]['ids'])[_0x498b('0x20')](function(){if(_['isArray'](_0x32fb68[_0x498b('0x4e')][_0x498b('0x96')])){for(var _0x22069a=0x0;_0x22069a<_0x32fb68[_0x498b('0x4e')][_0x498b('0x96')][_0x498b('0x45')];_0x22069a+=0x1){socket['emit']('user_has_openchannel_interactions:remove',{'OpenchannelInteractionId':Number(_0x32fb68[_0x498b('0x4e')][_0x498b('0x96')][_0x22069a]),'UserId':Number(_0x32fb68[_0x498b('0x4f')]['id'])});}}else{socket[_0x498b('0x23')](_0x498b('0x129'),{'OpenchannelInteractionId':Number(_0x32fb68[_0x498b('0x4e')][_0x498b('0x96')]),'UserId':Number(_0x32fb68[_0x498b('0x4f')]['id'])});}});}})[_0x498b('0x20')](respondWithStatusCode(_0x562341,null))[_0x498b('0x4c')](handleError(_0x562341,null));};exports[_0x498b('0x12a')]=function(_0x509a73,_0x1a9d67){return db[_0x498b('0x3d')][_0x498b('0x52')]({'where':{'id':_0x509a73['params']['id']}})[_0x498b('0x20')](handleEntityNotFound(_0x1a9d67,null))['then'](function(_0x3c0e20){if(_0x3c0e20){return _0x3c0e20[_0x498b('0x12a')](_0x509a73[_0x498b('0x55')][_0x498b('0x96')],_['omit'](_0x509a73['body'],['ids','id'])||{})[_0x498b('0x11b')](function(){for(var _0x289d2e=0x0;_0x289d2e<_0x509a73['body'][_0x498b('0x96')]['length'];_0x289d2e+=0x1){socket[_0x498b('0x23')]('user_has_whatsapp_interactions:save',{'WhatsappInteractionId':Number(_0x509a73[_0x498b('0x55')][_0x498b('0x96')][_0x289d2e]),'UserId':Number(_0x509a73[_0x498b('0x4f')]['id'])});}return _0x509a73[_0x498b('0x55')]['ids'];});}})[_0x498b('0x20')](respondWithResult(_0x1a9d67,null))['catch'](handleError(_0x1a9d67,null));};exports[_0x498b('0x12b')]=function(_0x2f617d,_0x4a63eb){return db[_0x498b('0x3d')][_0x498b('0x52')]({'where':{'id':_0x2f617d[_0x498b('0x4f')]['id']}})['then'](handleEntityNotFound(_0x4a63eb,null))[_0x498b('0x20')](function(_0x1f47bb){if(_0x1f47bb){return _0x1f47bb[_0x498b('0x12b')](_0x2f617d['query']['ids']);}})['then'](respondWithStatusCode(_0x4a63eb,null))[_0x498b('0x4c')](handleError(_0x4a63eb,null));};exports[_0x498b('0x12c')]=function(_0x5d4138,_0xb63da4){var _0x2b2570={};var _0x682ebd={};var _0x59ffcf;var _0x1a2f20;return db['User'][_0x498b('0xbb')]({'where':{'id':_0x5d4138['params']['id']}})[_0x498b('0x20')](handleEntityNotFound(_0xb63da4,null))[_0x498b('0x20')](function(_0x36c927){if(_0x36c927){_0x59ffcf=_0x36c927;_0x682ebd[_0x498b('0xc7')]=_[_0x498b('0xc4')](db[_0x498b('0x12d')][_0x498b('0x33')]);_0x682ebd['query']=_[_0x498b('0xc4')](_0x5d4138[_0x498b('0x4e')]);_0x682ebd[_0x498b('0xcb')]=_[_0x498b('0xc6')](_0x682ebd[_0x498b('0xc7')],_0x682ebd[_0x498b('0x4e')]);_0x2b2570['attributes']=_[_0x498b('0xc6')](_0x682ebd[_0x498b('0xc7')],qs[_0x498b('0xc8')](_0x5d4138[_0x498b('0x4e')]['fields']));_0x2b2570[_0x498b('0x42')]=_0x2b2570[_0x498b('0x42')]['length']?_0x2b2570[_0x498b('0x42')]:_0x682ebd[_0x498b('0xc7')];_0x2b2570[_0x498b('0xc9')]=qs['sort'](_0x5d4138[_0x498b('0x4e')][_0x498b('0xca')]);_0x2b2570['where']=qs['filters'](_[_0x498b('0xcc')](_0x5d4138[_0x498b('0x4e')],_0x682ebd[_0x498b('0xcb')]));if(_0x5d4138[_0x498b('0x4e')][_0x498b('0x2d')]){_0x2b2570[_0x498b('0x3c')]=_[_0x498b('0x51')](_0x2b2570[_0x498b('0x3c')],{'$or':_[_0x498b('0x7c')](_0x2b2570['attributes'],function(_0x6f7f6d){var _0x5a5066={};_0x5a5066[_0x6f7f6d]={'$like':'%'+_0x5d4138[_0x498b('0x4e')][_0x498b('0x2d')]+'%'};return _0x5a5066;})});}_0x2b2570=_['merge']({},_0x2b2570,_0x5d4138['options']);return _0x59ffcf[_0x498b('0x12c')](_0x2b2570);}})['then'](function(_0x476a2c){if(_0x476a2c){_0x1a2f20=_0x476a2c[_0x498b('0x45')];if(!_0x5d4138['query']['hasOwnProperty'](_0x498b('0xd2'))){_0x2b2570['limit']=qs[_0x498b('0x1c')](_0x5d4138[_0x498b('0x4e')][_0x498b('0x1c')]);_0x2b2570[_0x498b('0x1b')]=qs[_0x498b('0x1b')](_0x5d4138['query'][_0x498b('0x1b')]);}return _0x59ffcf[_0x498b('0x12c')](_0x2b2570);}})[_0x498b('0x20')](function(_0x40bb68){if(_0x40bb68){return _0x40bb68?{'count':_0x1a2f20,'rows':_0x40bb68}:null;}})[_0x498b('0x20')](respondWithResult(_0xb63da4,null))[_0x498b('0x4c')](handleError(_0xb63da4,null));};exports[_0x498b('0x12e')]=function(_0x4db15a,_0x29390b){var _0xde9101={};var _0x509856={};var _0x511425;var _0x5f7c6b;return db['User']['findOne']({'where':{'id':_0x4db15a[_0x498b('0x4f')]['id']}})[_0x498b('0x20')](handleEntityNotFound(_0x29390b,null))[_0x498b('0x20')](function(_0x1fcae0){if(_0x1fcae0){_0x511425=_0x1fcae0;_0x509856[_0x498b('0xc7')]=_[_0x498b('0xc4')](db[_0x498b('0x12f')][_0x498b('0x33')]);_0x509856[_0x498b('0x4e')]=_['keys'](_0x4db15a[_0x498b('0x4e')]);_0x509856[_0x498b('0xcb')]=_[_0x498b('0xc6')](_0x509856[_0x498b('0xc7')],_0x509856['query']);_0xde9101[_0x498b('0x42')]=_[_0x498b('0xc6')](_0x509856[_0x498b('0xc7')],qs[_0x498b('0xc8')](_0x4db15a[_0x498b('0x4e')]['fields']));_0xde9101[_0x498b('0x42')]=_0xde9101['attributes'][_0x498b('0x45')]?_0xde9101[_0x498b('0x42')]:_0x509856[_0x498b('0xc7')];_0xde9101['order']=qs['sort'](_0x4db15a[_0x498b('0x4e')][_0x498b('0xca')]);_0xde9101[_0x498b('0x3c')]=qs[_0x498b('0xcb')](_[_0x498b('0xcc')](_0x4db15a[_0x498b('0x4e')],_0x509856[_0x498b('0xcb')]));if(_0x4db15a['query'][_0x498b('0x2d')]){_0xde9101['where']=_['merge'](_0xde9101[_0x498b('0x3c')],{'$or':_['map'](_0xde9101[_0x498b('0x42')],function(_0x1f54ba){var _0x677192={};_0x677192[_0x1f54ba]={'$like':'%'+_0x4db15a[_0x498b('0x4e')][_0x498b('0x2d')]+'%'};return _0x677192;})});}_0xde9101=_[_0x498b('0x51')]({},_0xde9101,_0x4db15a[_0x498b('0xcd')]);return _0x511425[_0x498b('0x12e')](_0xde9101);}})[_0x498b('0x20')](function(_0x2dfe08){if(_0x2dfe08){_0x5f7c6b=_0x2dfe08[_0x498b('0x45')];if(!_0x4db15a[_0x498b('0x4e')][_0x498b('0xbd')](_0x498b('0xd2'))){_0xde9101['limit']=qs[_0x498b('0x1c')](_0x4db15a[_0x498b('0x4e')][_0x498b('0x1c')]);_0xde9101[_0x498b('0x1b')]=qs[_0x498b('0x1b')](_0x4db15a['query'][_0x498b('0x1b')]);}return _0x511425[_0x498b('0x12e')](_0xde9101);}})[_0x498b('0x20')](function(_0x24b069){if(_0x24b069){return _0x24b069?{'count':_0x5f7c6b,'rows':_0x24b069}:null;}})['then'](respondWithResult(_0x29390b,null))['catch'](handleError(_0x29390b,null));};exports['addFaxAccounts']=function(_0xa2fa4,_0x411058){return db['User'][_0x498b('0x52')]({'where':{'id':_0xa2fa4[_0x498b('0x4f')]['id']}})['then'](handleEntityNotFound(_0x411058,null))[_0x498b('0x20')](function(_0x584a84){if(_0x584a84){return _0x584a84[_0x498b('0x130')](_0xa2fa4['body'][_0x498b('0x96')],_[_0x498b('0x11a')](_0xa2fa4[_0x498b('0x55')],['ids','id'])||{});}})[_0x498b('0x20')](respondWithResult(_0x411058,null))[_0x498b('0x4c')](handleError(_0x411058,null));};exports[_0x498b('0x131')]=function(_0x4a5d9b,_0x40f76f){return db[_0x498b('0x3d')][_0x498b('0x52')]({'where':{'id':_0x4a5d9b[_0x498b('0x4f')]['id']}})[_0x498b('0x20')](handleEntityNotFound(_0x40f76f,null))['then'](function(_0x35e823){if(_0x35e823){return _0x35e823['removeFaxAccounts'](_0x4a5d9b['query'][_0x498b('0x96')]);}})[_0x498b('0x20')](respondWithStatusCode(_0x40f76f,null))[_0x498b('0x4c')](handleError(_0x40f76f,null));};exports[_0x498b('0x132')]=function(_0x11a82a,_0x5444b8){var _0x5eeeca={};var _0xa42995={};var _0x302767;var _0x42e15c;return db[_0x498b('0x3d')][_0x498b('0xbb')]({'where':{'id':_0x11a82a['params']['id']}})['then'](handleEntityNotFound(_0x5444b8,null))[_0x498b('0x20')](function(_0x48fe80){if(_0x48fe80){_0x302767=_0x48fe80;_0xa42995[_0x498b('0xc7')]=_[_0x498b('0xc4')](db[_0x498b('0x133')]['rawAttributes']);_0xa42995[_0x498b('0x4e')]=_[_0x498b('0xc4')](_0x11a82a[_0x498b('0x4e')]);_0xa42995[_0x498b('0xcb')]=_[_0x498b('0xc6')](_0xa42995[_0x498b('0xc7')],_0xa42995['query']);_0x5eeeca[_0x498b('0x42')]=_['intersection'](_0xa42995[_0x498b('0xc7')],qs[_0x498b('0xc8')](_0x11a82a[_0x498b('0x4e')][_0x498b('0xc8')]));_0x5eeeca[_0x498b('0x42')]=_0x5eeeca[_0x498b('0x42')][_0x498b('0x45')]?_0x5eeeca[_0x498b('0x42')]:_0xa42995[_0x498b('0xc7')];_0x5eeeca[_0x498b('0xc9')]=qs['sort'](_0x11a82a[_0x498b('0x4e')][_0x498b('0xca')]);_0x5eeeca[_0x498b('0x3c')]=qs[_0x498b('0xcb')](_[_0x498b('0xcc')](_0x11a82a[_0x498b('0x4e')],_0xa42995[_0x498b('0xcb')]));if(_0x11a82a[_0x498b('0x4e')][_0x498b('0x2d')]){_0x5eeeca['where']=_[_0x498b('0x51')](_0x5eeeca['where'],{'$or':_['map'](_0x5eeeca[_0x498b('0x42')],function(_0x121ef3){var _0x3b6dd9={};_0x3b6dd9[_0x121ef3]={'$like':'%'+_0x11a82a[_0x498b('0x4e')][_0x498b('0x2d')]+'%'};return _0x3b6dd9;})});}_0x5eeeca=_[_0x498b('0x51')]({},_0x5eeeca,_0x11a82a[_0x498b('0xcd')]);return _0x302767[_0x498b('0x132')](_0x5eeeca);}})[_0x498b('0x20')](function(_0x102509){if(_0x102509){_0x42e15c=_0x102509['length'];if(!_0x11a82a['query']['hasOwnProperty'](_0x498b('0xd2'))){_0x5eeeca['limit']=qs['limit'](_0x11a82a[_0x498b('0x4e')][_0x498b('0x1c')]);_0x5eeeca[_0x498b('0x1b')]=qs[_0x498b('0x1b')](_0x11a82a[_0x498b('0x4e')][_0x498b('0x1b')]);}return _0x302767[_0x498b('0x132')](_0x5eeeca);}})['then'](function(_0x25d2d5){if(_0x25d2d5){return _0x25d2d5?{'count':_0x42e15c,'rows':_0x25d2d5}:null;}})[_0x498b('0x20')](respondWithResult(_0x5444b8,null))[_0x498b('0x4c')](handleError(_0x5444b8,null));};exports[_0x498b('0x134')]=function(_0xa0e036,_0x32cda0){return db['User'][_0x498b('0x52')]({'where':{'id':_0xa0e036[_0x498b('0x4f')]['id']}})[_0x498b('0x20')](handleEntityNotFound(_0x32cda0,null))[_0x498b('0x20')](function(_0x2921a6){if(_0x2921a6){return _0x2921a6[_0x498b('0x134')](_0xa0e036[_0x498b('0x55')][_0x498b('0x96')],_[_0x498b('0x11a')](_0xa0e036[_0x498b('0x55')],[_0x498b('0x96'),'id'])||{});}})['then'](respondWithResult(_0x32cda0,null))[_0x498b('0x4c')](handleError(_0x32cda0,null));};exports[_0x498b('0x135')]=function(_0x4d548d,_0x26e1d6){return db['User'][_0x498b('0x52')]({'where':{'id':_0x4d548d[_0x498b('0x4f')]['id']}})[_0x498b('0x20')](handleEntityNotFound(_0x26e1d6,null))[_0x498b('0x20')](function(_0x5a6431){if(_0x5a6431){return _0x5a6431[_0x498b('0x135')](_0x4d548d[_0x498b('0x4e')][_0x498b('0x96')]);}})[_0x498b('0x20')](respondWithStatusCode(_0x26e1d6,null))['catch'](handleError(_0x26e1d6,null));};exports[_0x498b('0x136')]=function(_0x47308b,_0x51d6b0){var _0x5d5fe7={};var _0x4e816d={};var _0x497e9c;var _0x39cd28;return db[_0x498b('0x3d')]['findOne']({'where':{'id':_0x47308b[_0x498b('0x4f')]['id']}})[_0x498b('0x20')](handleEntityNotFound(_0x51d6b0,null))['then'](function(_0x294692){if(_0x294692){_0x497e9c=_0x294692;_0x4e816d[_0x498b('0xc7')]=_[_0x498b('0xc4')](db['OpenchannelAccount'][_0x498b('0x33')]);_0x4e816d[_0x498b('0x4e')]=_[_0x498b('0xc4')](_0x47308b['query']);_0x4e816d[_0x498b('0xcb')]=_[_0x498b('0xc6')](_0x4e816d[_0x498b('0xc7')],_0x4e816d['query']);_0x5d5fe7[_0x498b('0x42')]=_[_0x498b('0xc6')](_0x4e816d[_0x498b('0xc7')],qs[_0x498b('0xc8')](_0x47308b[_0x498b('0x4e')][_0x498b('0xc8')]));_0x5d5fe7[_0x498b('0x42')]=_0x5d5fe7[_0x498b('0x42')][_0x498b('0x45')]?_0x5d5fe7[_0x498b('0x42')]:_0x4e816d[_0x498b('0xc7')];_0x5d5fe7[_0x498b('0xc9')]=qs[_0x498b('0xca')](_0x47308b[_0x498b('0x4e')][_0x498b('0xca')]);_0x5d5fe7['where']=qs[_0x498b('0xcb')](_[_0x498b('0xcc')](_0x47308b[_0x498b('0x4e')],_0x4e816d[_0x498b('0xcb')]));if(_0x47308b[_0x498b('0x4e')][_0x498b('0x2d')]){_0x5d5fe7[_0x498b('0x3c')]=_[_0x498b('0x51')](_0x5d5fe7[_0x498b('0x3c')],{'$or':_['map'](_0x5d5fe7[_0x498b('0x42')],function(_0x1177e9){var _0x5ad01a={};_0x5ad01a[_0x1177e9]={'$like':'%'+_0x47308b[_0x498b('0x4e')][_0x498b('0x2d')]+'%'};return _0x5ad01a;})});}_0x5d5fe7=_[_0x498b('0x51')]({},_0x5d5fe7,_0x47308b[_0x498b('0xcd')]);return _0x497e9c['getOpenchannelAccounts'](_0x5d5fe7);}})[_0x498b('0x20')](function(_0x280100){if(_0x280100){_0x39cd28=_0x280100[_0x498b('0x45')];if(!_0x47308b[_0x498b('0x4e')][_0x498b('0xbd')]('nolimit')){_0x5d5fe7['limit']=qs['limit'](_0x47308b['query'][_0x498b('0x1c')]);_0x5d5fe7[_0x498b('0x1b')]=qs[_0x498b('0x1b')](_0x47308b[_0x498b('0x4e')]['offset']);}return _0x497e9c['getOpenchannelAccounts'](_0x5d5fe7);}})[_0x498b('0x20')](function(_0xf7279){if(_0xf7279){return _0xf7279?{'count':_0x39cd28,'rows':_0xf7279}:null;}})[_0x498b('0x20')](respondWithResult(_0x51d6b0,null))[_0x498b('0x4c')](handleError(_0x51d6b0,null));};exports[_0x498b('0x137')]=function(_0x30dfea,_0x52f011){return db[_0x498b('0x3d')][_0x498b('0x52')]({'where':{'id':_0x30dfea['params']['id']}})[_0x498b('0x20')](handleEntityNotFound(_0x52f011,null))[_0x498b('0x20')](function(_0x4b22a2){if(_0x4b22a2){return _0x4b22a2[_0x498b('0x137')](_0x30dfea['body'][_0x498b('0x96')],_[_0x498b('0x11a')](_0x30dfea[_0x498b('0x55')],[_0x498b('0x96'),'id'])||{});}})[_0x498b('0x20')](respondWithResult(_0x52f011,null))[_0x498b('0x4c')](handleError(_0x52f011,null));};exports['removeOpenchannelAccounts']=function(_0x43a3ee,_0x2eb4f1){return db[_0x498b('0x3d')][_0x498b('0x52')]({'where':{'id':_0x43a3ee[_0x498b('0x4f')]['id']}})[_0x498b('0x20')](handleEntityNotFound(_0x2eb4f1,null))[_0x498b('0x20')](function(_0x5b724d){if(_0x5b724d){return _0x5b724d[_0x498b('0x138')](_0x43a3ee['query'][_0x498b('0x96')]);}})[_0x498b('0x20')](respondWithStatusCode(_0x2eb4f1,null))[_0x498b('0x4c')](handleError(_0x2eb4f1,null));};exports['getSmsAccounts']=function(_0x9df1db,_0x21d4e8){var _0x8cc445={};var _0x3ed99e={};var _0x4249e2;var _0x475e44;return db[_0x498b('0x3d')][_0x498b('0xbb')]({'where':{'id':_0x9df1db[_0x498b('0x4f')]['id']}})['then'](handleEntityNotFound(_0x21d4e8,null))[_0x498b('0x20')](function(_0x169c9f){if(_0x169c9f){_0x4249e2=_0x169c9f;_0x3ed99e[_0x498b('0xc7')]=_['keys'](db[_0x498b('0x139')][_0x498b('0x33')]);_0x3ed99e[_0x498b('0x4e')]=_[_0x498b('0xc4')](_0x9df1db[_0x498b('0x4e')]);_0x3ed99e[_0x498b('0xcb')]=_[_0x498b('0xc6')](_0x3ed99e[_0x498b('0xc7')],_0x3ed99e[_0x498b('0x4e')]);_0x8cc445['attributes']=_[_0x498b('0xc6')](_0x3ed99e[_0x498b('0xc7')],qs[_0x498b('0xc8')](_0x9df1db[_0x498b('0x4e')][_0x498b('0xc8')]));_0x8cc445[_0x498b('0x42')]=_0x8cc445['attributes'][_0x498b('0x45')]?_0x8cc445[_0x498b('0x42')]:_0x3ed99e[_0x498b('0xc7')];_0x8cc445[_0x498b('0xc9')]=qs[_0x498b('0xca')](_0x9df1db[_0x498b('0x4e')][_0x498b('0xca')]);_0x8cc445['where']=qs[_0x498b('0xcb')](_[_0x498b('0xcc')](_0x9df1db[_0x498b('0x4e')],_0x3ed99e[_0x498b('0xcb')]));if(_0x9df1db[_0x498b('0x4e')]['filter']){_0x8cc445[_0x498b('0x3c')]=_[_0x498b('0x51')](_0x8cc445['where'],{'$or':_[_0x498b('0x7c')](_0x8cc445[_0x498b('0x42')],function(_0x592e39){var _0x829762={};_0x829762[_0x592e39]={'$like':'%'+_0x9df1db[_0x498b('0x4e')][_0x498b('0x2d')]+'%'};return _0x829762;})});}_0x8cc445=_['merge']({},_0x8cc445,_0x9df1db[_0x498b('0xcd')]);return _0x4249e2[_0x498b('0x13a')](_0x8cc445);}})[_0x498b('0x20')](function(_0xf7373e){if(_0xf7373e){_0x475e44=_0xf7373e[_0x498b('0x45')];if(!_0x9df1db['query']['hasOwnProperty']('nolimit')){_0x8cc445[_0x498b('0x1c')]=qs[_0x498b('0x1c')](_0x9df1db[_0x498b('0x4e')]['limit']);_0x8cc445[_0x498b('0x1b')]=qs['offset'](_0x9df1db[_0x498b('0x4e')][_0x498b('0x1b')]);}return _0x4249e2[_0x498b('0x13a')](_0x8cc445);}})[_0x498b('0x20')](function(_0x2976dc){if(_0x2976dc){return _0x2976dc?{'count':_0x475e44,'rows':_0x2976dc}:null;}})['then'](respondWithResult(_0x21d4e8,null))[_0x498b('0x4c')](handleError(_0x21d4e8,null));};exports[_0x498b('0x13b')]=function(_0x1a2027,_0x3d7c33){return db[_0x498b('0x3d')]['find']({'where':{'id':_0x1a2027[_0x498b('0x4f')]['id']}})[_0x498b('0x20')](handleEntityNotFound(_0x3d7c33,null))[_0x498b('0x20')](function(_0x43ffdb){if(_0x43ffdb){return _0x43ffdb[_0x498b('0x13b')](_0x1a2027[_0x498b('0x55')][_0x498b('0x96')],_[_0x498b('0x11a')](_0x1a2027[_0x498b('0x55')],['ids','id'])||{});}})[_0x498b('0x20')](respondWithResult(_0x3d7c33,null))['catch'](handleError(_0x3d7c33,null));};exports[_0x498b('0x13c')]=function(_0x127c7b,_0xa0f33f){return db[_0x498b('0x3d')][_0x498b('0x52')]({'where':{'id':_0x127c7b[_0x498b('0x4f')]['id']}})[_0x498b('0x20')](handleEntityNotFound(_0xa0f33f,null))[_0x498b('0x20')](function(_0x2861fe){if(_0x2861fe){return _0x2861fe[_0x498b('0x13c')](_0x127c7b[_0x498b('0x4e')][_0x498b('0x96')]);}})[_0x498b('0x20')](respondWithStatusCode(_0xa0f33f,null))[_0x498b('0x4c')](handleError(_0xa0f33f,null));};exports[_0x498b('0x13d')]=function(_0x2f3289,_0x251dc4){var _0x2c4c88={};var _0x30d861={};var _0x2cd820;var _0x3fb32a;return db[_0x498b('0x3d')][_0x498b('0xbb')]({'where':{'id':_0x2f3289[_0x498b('0x4f')]['id']}})['then'](handleEntityNotFound(_0x251dc4,null))[_0x498b('0x20')](function(_0x145607){if(_0x145607){_0x2cd820=_0x145607;_0x30d861['model']=_[_0x498b('0xc4')](db[_0x498b('0x13e')][_0x498b('0x33')]);_0x30d861[_0x498b('0x4e')]=_['keys'](_0x2f3289['query']);_0x30d861[_0x498b('0xcb')]=_[_0x498b('0xc6')](_0x30d861['model'],_0x30d861['query']);_0x2c4c88[_0x498b('0x42')]=_[_0x498b('0xc6')](_0x30d861[_0x498b('0xc7')],qs[_0x498b('0xc8')](_0x2f3289[_0x498b('0x4e')][_0x498b('0xc8')]));_0x2c4c88[_0x498b('0x42')]=_0x2c4c88[_0x498b('0x42')][_0x498b('0x45')]?_0x2c4c88['attributes']:_0x30d861[_0x498b('0xc7')];_0x2c4c88[_0x498b('0xc9')]=qs['sort'](_0x2f3289[_0x498b('0x4e')][_0x498b('0xca')]);_0x2c4c88[_0x498b('0x3c')]=qs[_0x498b('0xcb')](_[_0x498b('0xcc')](_0x2f3289[_0x498b('0x4e')],_0x30d861['filters']));if(_0x2f3289[_0x498b('0x4e')]['filter']){_0x2c4c88['where']=_[_0x498b('0x51')](_0x2c4c88[_0x498b('0x3c')],{'$or':_['map'](_0x2c4c88[_0x498b('0x42')],function(_0x8b1ae9){var _0x5815d5={};_0x5815d5[_0x8b1ae9]={'$like':'%'+_0x2f3289[_0x498b('0x4e')][_0x498b('0x2d')]+'%'};return _0x5815d5;})});}_0x2c4c88=_[_0x498b('0x51')]({},_0x2c4c88,_0x2f3289['options']);return _0x2cd820['getChatWebsites'](_0x2c4c88);}})[_0x498b('0x20')](function(_0x5ea543){if(_0x5ea543){_0x3fb32a=_0x5ea543['length'];if(!_0x2f3289['query']['hasOwnProperty'](_0x498b('0xd2'))){_0x2c4c88[_0x498b('0x1c')]=qs[_0x498b('0x1c')](_0x2f3289[_0x498b('0x4e')]['limit']);_0x2c4c88[_0x498b('0x1b')]=qs['offset'](_0x2f3289[_0x498b('0x4e')]['offset']);}return _0x2cd820['getChatWebsites'](_0x2c4c88);}})[_0x498b('0x20')](function(_0x4dd234){if(_0x4dd234){return _0x4dd234?{'count':_0x3fb32a,'rows':_0x4dd234}:null;}})['then'](respondWithResult(_0x251dc4,null))[_0x498b('0x4c')](handleError(_0x251dc4,null));};exports[_0x498b('0x13f')]=function(_0x4089ec,_0xb51835){return db[_0x498b('0x3d')][_0x498b('0x52')]({'where':{'id':_0x4089ec[_0x498b('0x4f')]['id']}})[_0x498b('0x20')](handleEntityNotFound(_0xb51835,null))[_0x498b('0x20')](function(_0x75c300){if(_0x75c300){return _0x75c300['addChatWebsites'](_0x4089ec[_0x498b('0x55')][_0x498b('0x96')],_['omit'](_0x4089ec[_0x498b('0x55')],['ids','id'])||{});}})[_0x498b('0x20')](respondWithResult(_0xb51835,null))['catch'](handleError(_0xb51835,null));};exports['removeChatWebsites']=function(_0x187943,_0x14fe76){return db[_0x498b('0x3d')][_0x498b('0x52')]({'where':{'id':_0x187943[_0x498b('0x4f')]['id']}})[_0x498b('0x20')](handleEntityNotFound(_0x14fe76,null))[_0x498b('0x20')](function(_0xa0867c){if(_0xa0867c){return _0xa0867c['removeChatWebsites'](_0x187943[_0x498b('0x4e')][_0x498b('0x96')]);}})[_0x498b('0x20')](respondWithStatusCode(_0x14fe76,null))[_0x498b('0x4c')](handleError(_0x14fe76,null));};exports[_0x498b('0x140')]=function(_0x160d53,_0xd49a98){var _0x250eec={};var _0x3c1d3d={};var _0x385729;var _0x2b58e5;return db[_0x498b('0x3d')][_0x498b('0xbb')]({'where':{'id':_0x160d53[_0x498b('0x4f')]['id']}})[_0x498b('0x20')](handleEntityNotFound(_0xd49a98,null))[_0x498b('0x20')](function(_0x38df56){if(_0x38df56){_0x385729=_0x38df56;_0x3c1d3d[_0x498b('0xc7')]=_['keys'](db[_0x498b('0x141')][_0x498b('0x33')]);_0x3c1d3d['query']=_[_0x498b('0xc4')](_0x160d53[_0x498b('0x4e')]);_0x3c1d3d[_0x498b('0xcb')]=_[_0x498b('0xc6')](_0x3c1d3d[_0x498b('0xc7')],_0x3c1d3d['query']);_0x250eec[_0x498b('0x42')]=_['intersection'](_0x3c1d3d['model'],qs[_0x498b('0xc8')](_0x160d53['query'][_0x498b('0xc8')]));_0x250eec['attributes']=_0x250eec[_0x498b('0x42')][_0x498b('0x45')]?_0x250eec[_0x498b('0x42')]:_0x3c1d3d[_0x498b('0xc7')];_0x250eec['order']=qs[_0x498b('0xca')](_0x160d53[_0x498b('0x4e')][_0x498b('0xca')]);_0x250eec['where']=qs['filters'](_['pick'](_0x160d53[_0x498b('0x4e')],_0x3c1d3d[_0x498b('0xcb')]));if(_0x160d53[_0x498b('0x4e')][_0x498b('0x2d')]){_0x250eec[_0x498b('0x3c')]=_[_0x498b('0x51')](_0x250eec['where'],{'$or':_[_0x498b('0x7c')](_0x250eec['attributes'],function(_0x7d7c60){var _0x32ad60={};_0x32ad60[_0x7d7c60]={'$like':'%'+_0x160d53[_0x498b('0x4e')][_0x498b('0x2d')]+'%'};return _0x32ad60;})});}_0x250eec=_[_0x498b('0x51')]({},_0x250eec,_0x160d53[_0x498b('0xcd')]);return _0x385729[_0x498b('0x140')](_0x250eec);}})['then'](function(_0x4ef89f){if(_0x4ef89f){_0x2b58e5=_0x4ef89f['length'];if(!_0x160d53[_0x498b('0x4e')]['hasOwnProperty'](_0x498b('0xd2'))){_0x250eec[_0x498b('0x1c')]=qs[_0x498b('0x1c')](_0x160d53[_0x498b('0x4e')][_0x498b('0x1c')]);_0x250eec[_0x498b('0x1b')]=qs['offset'](_0x160d53[_0x498b('0x4e')][_0x498b('0x1b')]);}return _0x385729[_0x498b('0x140')](_0x250eec);}})[_0x498b('0x20')](function(_0x268ea6){if(_0x268ea6){return _0x268ea6?{'count':_0x2b58e5,'rows':_0x268ea6}:null;}})[_0x498b('0x20')](respondWithResult(_0xd49a98,null))[_0x498b('0x4c')](handleError(_0xd49a98,null));};exports['addWhatsappAccounts']=function(_0x4874ab,_0x5740f4){return db[_0x498b('0x3d')]['find']({'where':{'id':_0x4874ab[_0x498b('0x4f')]['id']}})[_0x498b('0x20')](handleEntityNotFound(_0x5740f4,null))[_0x498b('0x20')](function(_0x254d68){if(_0x254d68){return _0x254d68[_0x498b('0x142')](_0x4874ab['body'][_0x498b('0x96')],_[_0x498b('0x11a')](_0x4874ab[_0x498b('0x55')],['ids','id'])||{});}})['then'](respondWithResult(_0x5740f4,null))[_0x498b('0x4c')](handleError(_0x5740f4,null));};exports['removeWhatsappAccounts']=function(_0x30bb74,_0x5257b2){return db['User'][_0x498b('0x52')]({'where':{'id':_0x30bb74[_0x498b('0x4f')]['id']}})['then'](handleEntityNotFound(_0x5257b2,null))[_0x498b('0x20')](function(_0x1632f7){if(_0x1632f7){return _0x1632f7[_0x498b('0x143')](_0x30bb74[_0x498b('0x4e')][_0x498b('0x96')]);}})[_0x498b('0x20')](respondWithStatusCode(_0x5257b2,null))['catch'](handleError(_0x5257b2,null));};exports[_0x498b('0x144')]=function(_0x19bc2e,_0x23a252){var _0x3d38c9={},_0x41b7e0={},_0x2fa55f={'count':0x0,'rows':[]};var _0x45e9b2=db['CmHopper'][_0x498b('0x33')];_0x41b7e0[_0x498b('0xc7')]=_[_0x498b('0xc4')](_0x45e9b2);_0x41b7e0[_0x498b('0x4e')]=_[_0x498b('0xc4')](_0x19bc2e[_0x498b('0x4e')]);_0x41b7e0[_0x498b('0xcb')]=_['intersection'](_0x41b7e0[_0x498b('0xc7')],_0x41b7e0[_0x498b('0x4e')]);_0x41b7e0['filters']=_[_0x498b('0xb9')](_0x41b7e0[_0x498b('0xcb')],[_0x498b('0x145'),'$or',_0x498b('0x146'),_0x498b('0x147'),'$lt',_0x498b('0x148'),'$ne',_0x498b('0x149'),'$not',_0x498b('0x14a'),_0x498b('0x14b'),_0x498b('0x14c'),_0x498b('0x14d'),_0x498b('0x14e'),_0x498b('0x14f'),_0x498b('0x150'),_0x498b('0x151'),_0x498b('0x14e'),_0x498b('0x152'),_0x498b('0x153'),'$contained',_0x498b('0x154')]);_0x3d38c9[_0x498b('0x42')]=_[_0x498b('0xc6')](_0x41b7e0[_0x498b('0xc7')],qs[_0x498b('0xc8')](_0x19bc2e['query'][_0x498b('0xc8')]));_0x3d38c9['attributes']=_0x3d38c9[_0x498b('0x42')]['length']?_0x3d38c9[_0x498b('0x42')]:_0x41b7e0[_0x498b('0xc7')];if(!_0x19bc2e[_0x498b('0x4e')][_0x498b('0xbd')](_0x498b('0xd2'))){_0x3d38c9['limit']=qs[_0x498b('0x1c')](_0x19bc2e[_0x498b('0x4e')]['limit']);_0x3d38c9[_0x498b('0x1b')]=qs[_0x498b('0x1b')](_0x19bc2e[_0x498b('0x4e')]['offset']);}_0x3d38c9[_0x498b('0xc9')]=qs[_0x498b('0xca')](_0x19bc2e[_0x498b('0x4e')][_0x498b('0xca')]);_0x3d38c9['where']=qs[_0x498b('0xcb')](_[_0x498b('0xcc')](_0x19bc2e['query'],_0x41b7e0[_0x498b('0xcb')]));if(_0x19bc2e[_0x498b('0x4e')][_0x498b('0x2d')]){_0x3d38c9['where']=_[_0x498b('0x51')](_0x3d38c9['where'],{'$or':_[_0x498b('0x7c')](_0x3d38c9[_0x498b('0x42')],function(_0x1fd8a0){var _0x5b18f9={};_0x5b18f9[_0x1fd8a0]={'$like':'%'+_0x19bc2e[_0x498b('0x4e')][_0x498b('0x2d')]+'%'};return _0x5b18f9;})});}_0x3d38c9[_0x498b('0x3c')]={'$and':[_0x3d38c9[_0x498b('0x3c')],{'$or':[{'UserId':_0x19bc2e[_0x498b('0x4f')]['id']},{'OwnerId':_0x19bc2e['params']['id']}]}]};_0x3d38c9=_[_0x498b('0x51')]({},_0x3d38c9,_0x19bc2e[_0x498b('0xcd')]);var _0x4cdb80={'where':_0x3d38c9[_0x498b('0x3c')]};return db[_0x498b('0x155')][_0x498b('0x1d')](_0x4cdb80)[_0x498b('0x20')](function(_0x1b38c0){_0x2fa55f['count']=_0x1b38c0;if(_0x19bc2e[_0x498b('0x4e')][_0x498b('0x3e')]){_0x3d38c9[_0x498b('0x41')]=[{'attributes':['id',_0x498b('0x156'),_0x498b('0x157'),_0x498b('0xe3')],'model':db[_0x498b('0x158')],'as':_0x498b('0x159')},{'attributes':['id',_0x498b('0x2f'),_0x498b('0x15a')],'model':db[_0x498b('0x9c')],'as':'Queue'}];}return db['CmHopper'][_0x498b('0x9d')](_0x3d38c9);})[_0x498b('0x20')](function(_0x54fe13){_0x2fa55f['rows']=_0x54fe13;return _0x2fa55f;})[_0x498b('0x20')](respondWithFilteredResult(_0x23a252,_0x3d38c9))['catch'](handleError(_0x23a252,null));};exports[_0x498b('0x15b')]=function(_0x1751fe,_0x26f484){if(!_[_0x498b('0x5d')](_0x1751fe['user']['id'])&&(_0x1751fe[_0x498b('0x29')][_0x498b('0x21')]==_0x498b('0x27')||_0x1751fe[_0x498b('0x29')][_0x498b('0x21')]==_0x498b('0x29'))){return db[_0x498b('0x3d')][_0x498b('0xbb')]({'where':{'id':_0x1751fe[_0x498b('0x4f')]['id']},'raw':!![]})[_0x498b('0x20')](function(_0xfcae25){return authService[_0x498b('0x15c')](_0xfcae25);})[_0x498b('0x20')](function(_0x1a595a){if(_0x1a595a){return _0x26f484['status'](0xc8)['json']({'api_key':_0x1a595a['token']});}else{return _0x26f484['status'](0xcc)[_0x498b('0x1a')]({'message':'No\x20API\x20access\x20key\x20found!'});}})[_0x498b('0x4c')](handleError(_0x26f484,0x193));}else{return _0x26f484[_0x498b('0x18')](0x191)[_0x498b('0x1a')]({'message':_0x498b('0x15d')});}};exports['createApiKey']=function(_0x42ddde,_0x2e3a12){if(!_[_0x498b('0x5d')](_0x42ddde['user']['id'])&&(_0x42ddde['user']['role']==_0x498b('0x27')||_0x42ddde[_0x498b('0x29')][_0x498b('0x21')]==_0x498b('0x29'))){return db[_0x498b('0x3d')][_0x498b('0x52')]({'where':{'id':_0x42ddde[_0x498b('0x4f')]['id']}})[_0x498b('0x20')](function(_0x49cdaf){return authService[_0x498b('0x15e')](_0x49cdaf);})[_0x498b('0x20')](function(_0x47f909){return db[_0x498b('0x3d')]['update']({'apiKeyIat':_0x47f909['iat'],'apiKeyNonce':_0x47f909[_0x498b('0x15f')]},{'where':{'id':_0x42ddde[_0x498b('0x4f')]['id']}})[_0x498b('0x20')](function(){return _0x2e3a12['status'](0xc8)[_0x498b('0x1a')]({'api_key':_0x47f909['token']});});})[_0x498b('0x4c')](handleError(_0x2e3a12,0x193));}else{return _0x2e3a12['status'](0x191)[_0x498b('0x1a')]({'message':_0x498b('0x15d')});}};exports['removeApiKey']=function(_0x2bd28,_0x55b8df){if(!_[_0x498b('0x5d')](_0x2bd28['user']['id'])&&(_0x2bd28['user'][_0x498b('0x21')]==_0x498b('0x27')||_0x2bd28[_0x498b('0x29')][_0x498b('0x21')]==_0x498b('0x29'))){return db[_0x498b('0x3d')][_0x498b('0x52')]({'where':{'id':_0x2bd28['params']['id']}})[_0x498b('0x20')](handleEntityNotFound(_0x55b8df,null))[_0x498b('0x20')](function(_0x23a250){if(_0x23a250&&_0x23a250[_0x498b('0x160')]&&_0x23a250[_0x498b('0x161')])return _0x23a250;else throw{'message':_0x498b('0x162')};})[_0x498b('0x20')](function(){return db[_0x498b('0x3d')][_0x498b('0x1f')]({'apiKeyNonce':null,'apiKeyIat':null},{'where':{'id':_0x2bd28[_0x498b('0x4f')]['id']}});})[_0x498b('0x20')](respondWithStatusCode(_0x55b8df,0xc8))['catch'](handleError(_0x55b8df,0x193));}else{return _0x55b8df['status'](0x191)[_0x498b('0x1a')]({'message':_0x498b('0x15d')});}};exports['whoami']=function(_0x96e804,_0x50253b){var _0x409ac0=_0x96e804[_0x498b('0x29')][_0x498b('0x26')]({'plain':!![]});if(!_0x409ac0){return _0x50253b[_0x498b('0x18')](0x191)[_0x498b('0x32')](_0x498b('0x163'));}else{Promise[_0x498b('0xf8')]()[_0x498b('0x20')](function(){if(_0x96e804[_0x498b('0x4e')][_0x498b('0x3f')]!=='true')return;return _0x96e804[_0x498b('0x29')][_0x498b('0x164')]();})[_0x498b('0x20')](function(_0x4ce4ed){if(!_0x4ce4ed)return;return _0x4ce4ed[_0x498b('0x26')]({'plain':!![]});})[_0x498b('0x20')](function(_0x3e5294){_0x409ac0[_0x498b('0x3f')]=_0x3e5294;return _0x50253b[_0x498b('0x18')](0xc8)[_0x498b('0x1a')](_0x409ac0);});}};exports[_0x498b('0x165')]=function(_0x2f4514,_0xd7dc15){var _0x2407b1={'offset':0x0},_0xb9df46={'count':0x0,'rows':[]};Promise[_0x498b('0xf8')]()[_0x498b('0x20')](function(){if(!_0x2f4514[_0x498b('0x4e')][_0x498b('0x2d')]&&!_0x2f4514[_0x498b('0x4e')]['teams']&&!_0x2f4514[_0x498b('0x4e')][_0x498b('0x166')])return[];return Promise[_0x498b('0xf8')]()[_0x498b('0x20')](function(){var _0x50d88d=[];if(!_[_0x498b('0x7b')](_0x2f4514[_0x498b('0x4e')][_0x498b('0x167')])){_0x50d88d[_0x498b('0x46')](db[_0x498b('0x106')][_0x498b('0x9d')]({'attributes':['id',_0x498b('0x2f')],'where':{'id':_0x2f4514[_0x498b('0x4e')][_0x498b('0x167')]}}));}if(!_['isEmpty'](_0x2f4514[_0x498b('0x4e')]['queues'])){_0x50d88d[_0x498b('0x46')](db[_0x498b('0x9c')][_0x498b('0x9d')]({'attributes':['id',_0x498b('0x2f')],'type':_0x498b('0x168'),'where':{'id':_0x2f4514[_0x498b('0x4e')][_0x498b('0x166')]}}));}return Promise['all'](_0x50d88d);})[_0x498b('0x20')](function(_0x5f12ea){var _0x283635=_[_0x498b('0x169')](_0x5f12ea)['map'](function(_0x4c40d3){return _0x4c40d3[_0x498b('0x117')]({'attributes':['id',_0x498b('0x2f'),_0x498b('0x5c'),_0x498b('0x9e')],'raw':!![]});});return Promise[_0x498b('0x4b')](_0x283635);})['then'](function(_0x15c4da){var _0x24e7d8=_[_0x498b('0x169')](_0x15c4da);if(!_0x2f4514['query']['filter'])return _0x24e7d8;if(_[_0x498b('0x7b')](_0x24e7d8)){return db['User'][_0x498b('0x9d')]({'attributes':['id',_0x498b('0x2f'),'internal','online'],'where':{'role':_0x498b('0x22'),'$or':[db['sequelize'][_0x498b('0x3c')](db[_0x498b('0x5f')]['fn'](_0x498b('0x16a'),db['sequelize'][_0x498b('0x16b')](_0x498b('0x2f'))),{'$like':'%'+_0x2f4514[_0x498b('0x4e')][_0x498b('0x2d')][_0x498b('0x98')]()+'%'}),{'internal':{'$like':'%'+_0x2f4514['query'][_0x498b('0x2d')]+'%'}}]},'raw':!![]});}else{return _(_0x24e7d8)['flatten']()[_0x498b('0x2d')](function(_0x35e9a8){return _0x35e9a8[_0x498b('0x2f')][_0x498b('0x98')]()['includes'](_0x2f4514['query'][_0x498b('0x2d')][_0x498b('0x98')]())||_0x35e9a8[_0x498b('0x5c')][_0x498b('0x16c')]()[_0x498b('0x3a')](_0x2f4514[_0x498b('0x4e')][_0x498b('0x2d')]);})[_0x498b('0x2e')]();}})[_0x498b('0x20')](function(_0x1f48a8){var _0x18cccd=_0x498b('0x2f');var _0x578b27=_0x498b('0x16d');if(_0x2f4514[_0x498b('0x4e')][_0x498b('0xca')]){_0x578b27=_0x2f4514['query'][_0x498b('0xca')][0x0]==='-'?'desc':'asc';_0x18cccd=_0x578b27===_0x498b('0x16d')?_0x2f4514[_0x498b('0x4e')]['sort']:_0x2f4514[_0x498b('0x4e')][_0x498b('0xca')]['substring'](0x1);}return _(_0x1f48a8)['uniqBy']('id')['orderBy']([function(_0x58aea4){return _0x18cccd==='name'?_0x58aea4[_0x18cccd][_0x498b('0x98')]():_0x58aea4[_0x18cccd];}],[_0x578b27])[_0x498b('0x7c')](function(_0x34a54c){return _[_0x498b('0xcc')](_0x34a54c,['id',_0x498b('0x2f'),'internal',_0x498b('0x9e')]);})[_0x498b('0x2e')]();})[_0x498b('0x20')](function(_0x3e9c3b){return amiClient[_0x498b('0x16e')](_0x498b('0x2a'),_0x2f4514)[_0x498b('0x20')](function(_0x53002d){if(_0x53002d[_0x498b('0x31')])throw new Error('Unable\x20to\x20retrieve\x20RPC\x20agents\x20(AMI)');var _0x11c2dc=_0x53002d[_0x498b('0x16f')];var _0xb12c26=jayson[_0x498b('0x15')][_0x498b('0x16')]({'port':0x232c});return _0xb12c26[_0x498b('0x16e')](_0x498b('0x2a'),_0x2f4514)[_0x498b('0x20')](function(_0x1dae2a){if(_0x1dae2a[_0x498b('0x31')])throw new Error(_0x498b('0x170'));var _0x4e7755=_0x1dae2a[_0x498b('0x16f')];return _[_0x498b('0x51')]({},_0x4e7755,_0x11c2dc);});})[_0x498b('0x20')](function(_0x48e7f4){return _['map'](_0x3e9c3b,function(_0x17f2b6){var _0x2ca77d=_[_0x498b('0x52')](_0x48e7f4[_0x498b('0x43')],['id',_0x17f2b6['id']]);if(!_0x2ca77d||!_0x17f2b6['online']){_0x17f2b6[_0x498b('0x18')]=_0x498b('0x171');}else if(_0x2ca77d['voicePause']){_0x17f2b6[_0x498b('0x18')]='pause';}else{_0x17f2b6[_0x498b('0x18')]=_[_0x498b('0x3a')]([_0x498b('0x172'),_0x498b('0x173'),_0x498b('0x174'),_0x498b('0x175'),null,undefined],_0x2ca77d[_0x498b('0x176')])?_0x498b('0x9e'):'busy';}return _0x17f2b6;});});});})[_0x498b('0x20')](function(_0x3678b3){if(!_0x2f4514[_0x498b('0x4e')]['hasOwnProperty']('nolimit')){_0x2407b1[_0x498b('0x1c')]=qs[_0x498b('0x1c')](_0x2f4514[_0x498b('0x4e')][_0x498b('0x1c')]||0xa);_0x2407b1[_0x498b('0x1b')]=qs[_0x498b('0x1b')](_0x2f4514['query'][_0x498b('0x1b')]);}_0xb9df46[_0x498b('0x1d')]=_0x3678b3['length'];_0xb9df46['rows']=_0x2407b1['limit']?_0x3678b3[_0x498b('0x177')](_0x2407b1['offset'],_0x2407b1[_0x498b('0x1b')]+_0x2407b1['limit']):_0x3678b3;return _0xb9df46;})[_0x498b('0x20')](respondWithFilteredResult(_0xd7dc15,_0x2407b1))[_0x498b('0x4c')](handleError(_0xd7dc15,null));};function get_open_tabs(_0x4fca2a,_0x5ed306){var _0x408639=_0x4fca2a['charAt'](0x0)['toUpperCase']()+_0x4fca2a[_0x498b('0x177')](0x1);var _0x123a8f={'type':db[_0x498b('0x82')][_0x498b('0x178')][_0x498b('0x60')],'raw':!![]};return new Promise(function(_0x36c107,_0x2c2a7f){var _0x46c696=squel[_0x498b('0x179')]()['field'](_0x498b('0x17a')+_0x408639+_0x498b('0x17b'),'id')['field'](_0x498b('0x17c'))[_0x498b('0x61')](_0x498b('0x17d')+_0x4fca2a+_0x498b('0x17e'),'ui')[_0x498b('0x3c')](_0x498b('0x17f'),_0x5ed306['id']);return db[_0x498b('0x5f')][_0x498b('0x4e')](_0x46c696[_0x498b('0x16c')](),_0x123a8f)[_0x498b('0x20')](function(_0x103c54){_0x5ed306[_0x408639+'OpenTabs']=_0x103c54;_0x36c107(_0x103c54);})[_0x498b('0x4c')](function(_0x4c1ef9){_0x2c2a7f(_0x4c1ef9);});});}
\ No newline at end of file