Built motion from commit (unavailable).|2.5.22
[motion2.git] / server / api / user / user.controller.js
index dcf082f..c235a14 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 _0x4ff3=['uniqBy','orderBy','Unable\x20to\x20retrieve\x20RPC\x20agents\x20(AMI)','http','Unable\x20to\x20retrieve\x20RPC\x20agents\x20(Routing)','offline','idle','unknown','ringing','voiceStatus','busy','slice','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','ejs','lodash','desk.js','querystring','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/utils','redis','defaults','localhost','socket.io-emitter','register','client','request','info','User,\x20%s,\x20%s','request\x20sent','debug','User,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','sendStatus','status','end','count','offset','limit','set','json','apply','reject','save','update','then','destroy','get','admin','Users','user','Agents','telephone','filter','ignore','map','value','find','role','name','UserProfileResource','stack','send','index','User','rawAttributes','fieldName','type','model','differenceBy','query','keys','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','filters','pick','merge','sequelize','lower','col','options','includeAll','include','findAll','rows','show','password','body','params','describe','ids','omit','internal','Setting','findById','securePassword','validatePasswordPattern','isNil','min_internal','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)','SELECT','from','voicemail','mailbox','VoiceMail','fullname','email','agent','permissions','102','103','110','104','105','106','107','108','109','111','114','115','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','checkUserLimits','settingsEnabled','create','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','bulkCreate','some','Unauthorized.\x20You\x20must\x20be\x20an\x20administrator\x20in\x20order\x20to\x20create\x20an\x20administrator','all','push','each','UserProfileSection','Telephones','isEmpty','compact','includes','changePassword','oldPassword','newPassword','Sequelize','ValidationError','Invalid\x20body\x20format.\x20Use\x20oldPassword\x20and\x20newPassword','authenticate','Wrong\x20credentials','New\x20password\x20must\x20be\x20different\x20from\x20old\x20password','Invalid\x20body\x20format.\x20Use\x20newPassword','enforcePasswordHistory','passwordHistoryLimit','previousPasswords','updatePasswordsHistory','addQueues','channel','online','loginInPause','voicePause','interface','isValidChannel','add','capitalize','toLowerCase','Queues','penalty','spread','emit','Queue:save','voice','VoiceQueue','format','UserVoiceQueueRt','upsert','removeQueues','Unknown\x20channel','remove','QueueId','Queue:remove','userpic','file','filename','getAvatar','join','download','existsSync','root','server/files/images/','getContacts','findOne','CmContact','Tag','Tags','color','tag','getQueues','Queue','Unknown\x20role','getVoiceQueuesRt','getGroups','ChatGroup','getRecordings','VoiceRecording','UserId','getScreenRecordings','ScreenRecording','ChatInteraction','getChatInteractions','getOpenchannelInteractions','OpenchannelInteraction','getMailInteractions','MailInteraction','getSmsInteractions','getFaxInteractions','FaxInteraction','getWhatsappInteractions','phone','mobile','intrf','SIP/%s','user:%s','user:forcelogout','headers','x-forwarded-for','remoteAddress','socket','connection','UserVoiceQueue.penalty','MemberReport','YYYY-MM-DD\x20HH:mm:ss','getChannels','LOGIN','device','PAUSE','LOGININPAUSE','concat','resolve','forEach','pause','DEFAULT\x20PAUSE','unpause','mailPause','chatPause','openchannelPause','whatsapppause','pauseType','lastPauseAt','QueuePause','manual','mail','chat','fax','sms','whatsapp','openchannel','%s%s','getTeams','addTeams','Team','getVoiceQueues','setDataValue','Voice','getChatQueues','Chat','getMailQueues','Mail','Whatsapp','getFaxQueues','getOpenchannelQueues','Openchannel','flatten','transaction','addAgent','getDataValue','removeTeams','getSmsQueues','getWhatsappQueues','Fax','removeAgent','getLists','CmList','values','You\x20can\x27t\x20delete\x20yourself','addChatInteractions','user_has_chat_interactions:save','isArray','user_has_chat_interactions:remove','addMailInteractions','removeMailInteractions','user_has_mail_interactions:remove','removeFaxInteractions','addSmsInteractions','removeSmsInteractions','user_has_sms_interactions:remove','addOpenchannelInteractions','user_has_openchannel_interactions:save','removeOpenchannelInteractions','user_has_openchannel_interactions:remove','addWhatsappInteractions','user_has_whatsapp_interactions:save','removeWhatsappInteractions','getVoicePrefixes','VoicePrefix','FaxAccount','getFaxAccounts','addFaxAccounts','removeFaxAccounts','MailAccount','getMailAccounts','addMailAccounts','removeMailAccounts','getOpenchannelAccounts','OpenchannelAccount','removeOpenchannelAccounts','getSmsAccounts','addSmsAccounts','removeSmsAccounts','getChatWebsites','ChatWebsite','addChatWebsites','removeChatWebsites','getWhatsappAccounts','WhatsappAccount','addWhatsappAccounts','removeWhatsappAccounts','getSquareProjects','SquareProject','addSquareProjects','removeSquareProjects','getScheduledCalls','CmHopper','$and','$or','$gt','$gte','$lt','$ne','$eq','$not','$notBetween','$notIn','$notLike','$like','$overlap','$contains','$contained','$any','firstName','lastName','dialActive','getApiKey','retrieveApiKey','token','No\x20API\x20access\x20key\x20found!','generateApiKey','iat','nonce','apiKeyNonce','apiKeyIat','You\x20don\x27t\x20have\x20sufficient\x20privileges\x20to\x20access\x20this\x20resource.','Unable\x20to\x20retrieve\x20the\x20current\x20user','getPresence','teams','queues','getAgents','toString','asc','substring'];(function(_0x32e6d3,_0x22a43c){var _0xb71ca=function(_0xd5f2f4){while(--_0xd5f2f4){_0x32e6d3['push'](_0x32e6d3['shift']());}};_0xb71ca(++_0x22a43c);}(_0x4ff3,0x198));var _0x34ff=function(_0x20c331,_0x40c3b1){_0x20c331=_0x20c331-0x0;var _0x30e9af=_0x4ff3[_0x20c331];return _0x30e9af;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0x34ff('0x0'));var rimraf=require(_0x34ff('0x1'));var zipdir=require(_0x34ff('0x2'));var jsonpatch=require(_0x34ff('0x3'));var rp=require(_0x34ff('0x4'));var moment=require(_0x34ff('0x5'));var BPromise=require(_0x34ff('0x6'));var Mustache=require(_0x34ff('0x7'));var util=require(_0x34ff('0x8'));var path=require(_0x34ff('0x9'));var sox=require(_0x34ff('0xa'));var csv=require(_0x34ff('0xb'));var ejs=require(_0x34ff('0xc'));var fs=require('fs');var _=require(_0x34ff('0xd'));var squel=require('squel');var crypto=require('crypto');var jsforce=require('jsforce');var deskjs=require(_0x34ff('0xe'));var toCsv=require('to-csv');var querystring=require(_0x34ff('0xf'));var Papa=require(_0x34ff('0x10'));var Redis=require(_0x34ff('0x11'));var authService=require('../../components/auth/service');var qs=require(_0x34ff('0x12'));var as=require(_0x34ff('0x13'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x34ff('0x14'))(_0x34ff('0x15'));var utils=require(_0x34ff('0x16'));var config=require('../../config/environment');var licenseUtil=require('../../config/license/util');var db=require('../../mysqldb')['db'];config[_0x34ff('0x17')]=_[_0x34ff('0x18')](config[_0x34ff('0x17')],{'host':_0x34ff('0x19'),'port':0x18eb});var socket=require(_0x34ff('0x1a'))(new Redis(config[_0x34ff('0x17')]));require('./user.socket')[_0x34ff('0x1b')](socket);var jayson=require('jayson/promise');var client=jayson[_0x34ff('0x1c')]['http']({'port':0x232a});function respondWithRpcPromise(_0x469005,_0x543114,_0x39851f,_0x4956ad){return new BPromise(function(_0x5ab3b8,_0x55e94c){var _0x4ba298=_0x4956ad||client;return _0x4ba298[_0x34ff('0x1d')](_0x469005,_0x39851f)['then'](function(_0x2a1ee9){logger[_0x34ff('0x1e')](_0x34ff('0x1f'),_0x543114,_0x34ff('0x20'));logger[_0x34ff('0x21')](_0x34ff('0x22'),_0x543114,'request\x20sent',JSON[_0x34ff('0x23')](_0x2a1ee9));if(_0x2a1ee9[_0x34ff('0x24')]){if(_0x2a1ee9[_0x34ff('0x24')][_0x34ff('0x25')]===0x1f4){logger['error'](_0x34ff('0x1f'),_0x543114,_0x2a1ee9[_0x34ff('0x24')][_0x34ff('0x26')]);return _0x55e94c(_0x2a1ee9[_0x34ff('0x24')][_0x34ff('0x26')]);}logger['error']('User,\x20%s,\x20%s',_0x543114,_0x2a1ee9['error'][_0x34ff('0x26')]);return _0x5ab3b8(_0x2a1ee9[_0x34ff('0x24')]['message']);}else{logger['info'](_0x34ff('0x1f'),_0x543114,_0x34ff('0x20'));_0x5ab3b8(_0x2a1ee9[_0x34ff('0x27')][_0x34ff('0x26')]);}})[_0x34ff('0x28')](function(_0x521a5b){logger[_0x34ff('0x24')](_0x34ff('0x1f'),_0x543114,_0x521a5b);_0x55e94c(_0x521a5b);});});}function respondWithStatusCode(_0x66488d,_0x5c5565){_0x5c5565=_0x5c5565||0xcc;return function(_0x2812ec){if(_0x2812ec){return _0x66488d[_0x34ff('0x29')](_0x5c5565);}return _0x66488d[_0x34ff('0x2a')](_0x5c5565)[_0x34ff('0x2b')]();};}function respondWithResult(_0x575709,_0x5ab799){_0x5ab799=_0x5ab799||0xc8;return function(_0x4f8a91){if(_0x4f8a91){return _0x575709[_0x34ff('0x2a')](_0x5ab799)['json'](_0x4f8a91);}};}function respondWithFilteredResult(_0x3c6766,_0x1f55e0){return function(_0x58d575){if(_0x58d575){var _0x189c9a=_0x58d575[_0x34ff('0x2c')],_0x263168=_0x1f55e0[_0x34ff('0x2d')],_0x1a3981=_0x1f55e0[_0x34ff('0x2d')]+_0x1f55e0[_0x34ff('0x2e')],_0x3e3673;if(_0x1a3981>=_0x189c9a){_0x1a3981=_0x189c9a;_0x3e3673=0xc8;}else{_0x3e3673=0xce;}_0x3c6766['status'](_0x3e3673);return _0x3c6766[_0x34ff('0x2f')]('Content-Range',_0x263168+'-'+_0x1a3981+'/'+_0x189c9a)[_0x34ff('0x30')](_0x58d575);}return null;};}function patchUpdates(_0x1fba1e){return function(_0xaed5b0){try{jsonpatch[_0x34ff('0x31')](_0xaed5b0,_0x1fba1e,!![]);}catch(_0x26ea45){return BPromise[_0x34ff('0x32')](_0x26ea45);}return _0xaed5b0[_0x34ff('0x33')]();};}function saveUpdates(_0x106377,_0x3f2cde){return function(_0x43dac0){if(_0x43dac0){return _0x43dac0[_0x34ff('0x34')](_0x106377)[_0x34ff('0x35')](function(_0x2d4a03){return _0x2d4a03;});}return null;};}function removeEntity(_0x951e7b,_0x246168){return function(_0x13fa61){if(_0x13fa61){return _0x13fa61[_0x34ff('0x36')]()[_0x34ff('0x35')](function(){var _0x3eb0f1=_0x13fa61[_0x34ff('0x37')]({'plain':!![]});if(_0x3eb0f1['role']===_0x34ff('0x38'))return;var _0x316799=[{'name':_0x34ff('0x39'),'value':_0x34ff('0x3a'),'ignore':!![]},{'name':_0x34ff('0x3b'),'value':'agent','ignore':![]},{'name':'Telephones','value':_0x34ff('0x3c'),'ignore':![]}];var _0x166d26=_(_0x316799)[_0x34ff('0x3d')](_0x34ff('0x3e'))[_0x34ff('0x3f')](_0x34ff('0x40'))[_0x34ff('0x40')]();if(_['includes'](_0x166d26,_0x3eb0f1['role'])){return;}var _0x965989=_[_0x34ff('0x41')](_0x316799,[_0x34ff('0x40'),_0x3eb0f1[_0x34ff('0x42')]])[_0x34ff('0x43')];return db[_0x34ff('0x44')][_0x34ff('0x36')]({'where':{'type':_0x965989,'resourceId':_0x3eb0f1['id']}})[_0x34ff('0x35')](function(){return _0x13fa61;});})[_0x34ff('0x35')](function(){_0x951e7b[_0x34ff('0x2a')](0xcc)[_0x34ff('0x2b')]();});}};}function handleEntityNotFound(_0x2e9762,_0x15038c){return function(_0x5bc8db){if(!_0x5bc8db){_0x2e9762[_0x34ff('0x29')](0x194);}return _0x5bc8db;};}function handleError(_0x132710,_0x538591){_0x538591=_0x538591||0x1f4;return function(_0x293719){logger['error'](_0x293719[_0x34ff('0x45')]);if(_0x293719[_0x34ff('0x43')]){delete _0x293719[_0x34ff('0x43')];}_0x132710[_0x34ff('0x2a')](_0x538591)[_0x34ff('0x46')](_0x293719);};}exports[_0x34ff('0x47')]=function(_0xd4ed6b,_0x1ddcc8){var _0x4340c5={},_0xaec066={},_0x25ebb5={'count':0x0,'rows':[]};var _0x564c5e=_[_0x34ff('0x3f')](db[_0x34ff('0x48')][_0x34ff('0x49')],function(_0x566b46){return{'name':_0x566b46[_0x34ff('0x4a')],'type':_0x566b46[_0x34ff('0x4b')]['key']};});_0xaec066[_0x34ff('0x4c')]=_[_0x34ff('0x4d')](_[_0x34ff('0x3f')](_0x564c5e,'name'),['password','salt']);_0xaec066[_0x34ff('0x4e')]=_[_0x34ff('0x4f')](_0xd4ed6b[_0x34ff('0x4e')]);_0xaec066['filters']=_[_0x34ff('0x50')](_0xaec066['model'],_0xaec066['query']);_0x4340c5[_0x34ff('0x51')]=_[_0x34ff('0x50')](_0xaec066[_0x34ff('0x4c')],qs[_0x34ff('0x52')](_0xd4ed6b[_0x34ff('0x4e')][_0x34ff('0x52')]));_0x4340c5[_0x34ff('0x51')]=_0x4340c5['attributes'][_0x34ff('0x53')]?_0x4340c5['attributes']:_0xaec066[_0x34ff('0x4c')];if(!_0xd4ed6b[_0x34ff('0x4e')][_0x34ff('0x54')](_0x34ff('0x55'))){_0x4340c5['limit']=qs[_0x34ff('0x2e')](_0xd4ed6b[_0x34ff('0x4e')][_0x34ff('0x2e')]);_0x4340c5[_0x34ff('0x2d')]=qs['offset'](_0xd4ed6b[_0x34ff('0x4e')][_0x34ff('0x2d')]);}_0x4340c5[_0x34ff('0x56')]=qs[_0x34ff('0x57')](_0xd4ed6b['query'][_0x34ff('0x57')]);_0x4340c5[_0x34ff('0x58')]=qs[_0x34ff('0x59')](_[_0x34ff('0x5a')](_0xd4ed6b['query'],_0xaec066[_0x34ff('0x59')]),_0x564c5e);if(_0xd4ed6b[_0x34ff('0x4e')][_0x34ff('0x3d')]){_0x4340c5[_0x34ff('0x58')]=_[_0x34ff('0x5b')](_0x4340c5[_0x34ff('0x58')],{'$or':_[_0x34ff('0x3f')](_0x564c5e,function(_0x288238){if(_0x288238[_0x34ff('0x4b')]!=='VIRTUAL'){return db[_0x34ff('0x5c')]['where'](db[_0x34ff('0x5c')]['fn'](_0x34ff('0x5d'),db[_0x34ff('0x5c')][_0x34ff('0x5e')](_0x288238['name'])),{'$like':db[_0x34ff('0x5c')]['fn'](_0x34ff('0x5d'),'%'+_0xd4ed6b[_0x34ff('0x4e')][_0x34ff('0x3d')]+'%')});}})});}_0x4340c5=_[_0x34ff('0x5b')]({},_0x4340c5,_0xd4ed6b[_0x34ff('0x5f')]);var _0x4da062={'where':_0x4340c5['where']};return db[_0x34ff('0x48')][_0x34ff('0x2c')](_0x4da062)[_0x34ff('0x35')](function(_0x12fe98){_0x25ebb5[_0x34ff('0x2c')]=_0x12fe98;if(_0xd4ed6b[_0x34ff('0x4e')][_0x34ff('0x60')]){_0x4340c5[_0x34ff('0x61')]=[{'all':!![]}];}return db[_0x34ff('0x48')][_0x34ff('0x62')](_0x4340c5);})['then'](function(_0x5c044d){_0x25ebb5[_0x34ff('0x63')]=_0x5c044d;return _0x25ebb5;})[_0x34ff('0x35')](respondWithFilteredResult(_0x1ddcc8,_0x4340c5))[_0x34ff('0x28')](handleError(_0x1ddcc8,null));};exports[_0x34ff('0x64')]=function(_0x55c004,_0x890674){var _0x503604={'raw':![],'where':{'id':_0x55c004['params']['id']}},_0x1a7184={};_0x1a7184['model']=_['differenceBy'](_['keys'](db[_0x34ff('0x48')][_0x34ff('0x49')]),[_0x34ff('0x65'),'salt']);_0x1a7184[_0x34ff('0x4e')]=_[_0x34ff('0x4f')](_0x55c004[_0x34ff('0x4e')]);_0x1a7184[_0x34ff('0x59')]=_['intersection'](_0x1a7184[_0x34ff('0x4c')],_0x1a7184['query']);_0x503604[_0x34ff('0x51')]=_['intersection'](_0x1a7184['model'],qs['fields'](_0x55c004[_0x34ff('0x4e')][_0x34ff('0x52')]));_0x503604[_0x34ff('0x51')]=_0x503604['attributes']['length']?_0x503604[_0x34ff('0x51')]:_0x1a7184[_0x34ff('0x4c')];if(_0x55c004[_0x34ff('0x4e')][_0x34ff('0x60')]){_0x503604['include']=[{'all':!![]}];}_0x503604=_[_0x34ff('0x5b')]({},_0x503604,_0x55c004[_0x34ff('0x5f')]);return db[_0x34ff('0x48')][_0x34ff('0x41')](_0x503604)[_0x34ff('0x35')](handleEntityNotFound(_0x890674,null))[_0x34ff('0x35')](respondWithResult(_0x890674,null))[_0x34ff('0x28')](handleError(_0x890674,null));};exports['update']=function(_0x6ab254,_0x406f16){if(_0x6ab254[_0x34ff('0x66')]['id']){delete _0x6ab254[_0x34ff('0x66')]['id'];}delete _0x6ab254[_0x34ff('0x66')]['role'];return db[_0x34ff('0x48')]['find']({'where':{'id':_0x6ab254[_0x34ff('0x67')]['id']}})['then'](handleEntityNotFound(_0x406f16,null))['then'](saveUpdates(_0x6ab254[_0x34ff('0x66')],null))[_0x34ff('0x35')](respondWithResult(_0x406f16,null))[_0x34ff('0x28')](handleError(_0x406f16,null));};exports[_0x34ff('0x68')]=function(_0x5ae056,_0x44a5ca){return db[_0x34ff('0x48')][_0x34ff('0x68')]()[_0x34ff('0x35')](respondWithResult(_0x44a5ca,null))[_0x34ff('0x28')](handleError(_0x44a5ca,null));};exports['addContacts']=function(_0x5266b8,_0x5d652a,_0x526834){return db[_0x34ff('0x48')][_0x34ff('0x41')]({'where':{'id':_0x5266b8[_0x34ff('0x67')]['id']}})[_0x34ff('0x35')](handleEntityNotFound(_0x5d652a,null))[_0x34ff('0x35')](function(_0x9f7d77){if(_0x9f7d77){return _0x9f7d77['addContacts'](_0x5266b8[_0x34ff('0x66')][_0x34ff('0x69')],_[_0x34ff('0x6a')](_0x5266b8[_0x34ff('0x66')],[_0x34ff('0x69'),'id'])||{});}})[_0x34ff('0x35')](respondWithResult(_0x5d652a,null))[_0x34ff('0x28')](handleError(_0x5d652a,null));};function validateUser(_0x2b3e09){return new BPromise(function(_0x1840d0,_0xb8496b){if(_0x2b3e09[_0x34ff('0x6b')])return _0x1840d0(_0x2b3e09);return db[_0x34ff('0x6c')][_0x34ff('0x6d')](0x1)['then'](function(_0x4e7ad8){if(_0x4e7ad8[_0x34ff('0x6e')])authService[_0x34ff('0x6f')](_0x2b3e09[_0x34ff('0x65')]);db[_0x34ff('0x48')]['max'](_0x34ff('0x6b'))[_0x34ff('0x35')](function(_0x322a4e){if(_[_0x34ff('0x70')](_0x322a4e)){_0x2b3e09[_0x34ff('0x6b')]=_0x4e7ad8[_0x34ff('0x71')]||0x1;return;}if(_[_0x34ff('0x70')](_0x4e7ad8[_0x34ff('0x71')])||_0x4e7ad8[_0x34ff('0x71')]===_0x322a4e){_0x2b3e09[_0x34ff('0x6b')]=_0x322a4e+0x1;return;}if(_0x4e7ad8[_0x34ff('0x71')]>_0x322a4e){_0x2b3e09['internal']=_0x4e7ad8[_0x34ff('0x71')];return;}return db[_0x34ff('0x5c')]['query'](_0x34ff('0x72'),{'type':db[_0x34ff('0x5c')]['QueryTypes'][_0x34ff('0x73')]})[_0x34ff('0x35')](function(_0x257480){if(_0x257480&&_0x257480[_0x34ff('0x53')]){for(var _0x25a509=0x0,_0x5a122c=_0x257480['length'];_0x25a509<_0x5a122c&&_[_0x34ff('0x70')](_0x2b3e09['internal']);_0x25a509++){if(_0x4e7ad8[_0x34ff('0x71')]<=_0x257480[_0x25a509][_0x34ff('0x74')]){_0x2b3e09['internal']=_0x257480[_0x25a509][_0x34ff('0x74')];}else if(_0x4e7ad8[_0x34ff('0x71')]>_0x257480[_0x25a509][_0x34ff('0x74')]&&_0x4e7ad8['min_internal']<=_0x257480[_0x25a509]['to']){_0x2b3e09[_0x34ff('0x6b')]=_0x4e7ad8['min_internal'];}}}if(_['isNil'](_0x2b3e09['internal'])){_0x2b3e09['internal']=_0x322a4e+0x1;}return _0x1840d0(_0x2b3e09);});});})[_0x34ff('0x28')](function(_0x1ba212){_0xb8496b(_0x1ba212);});});}function updateUser(_0x5a8733){return new BPromise(function(_0x1720ed,_0xda2f77){try{if(_0x5a8733[_0x34ff('0x75')]){_0x5a8733[_0x34ff('0x76')]=_0x5a8733['internal'];_0x5a8733[_0x34ff('0x77')]={'mailbox':_0x5a8733[_0x34ff('0x6b')],'password':_0x5a8733[_0x34ff('0x65')],'fullname':_0x5a8733[_0x34ff('0x78')],'email':_0x5a8733[_0x34ff('0x79')]};}if(_0x5a8733['role']===_0x34ff('0x7a')){if(!_0x5a8733[_0x34ff('0x7b')])_0x5a8733[_0x34ff('0x7b')]=['101',_0x34ff('0x7c'),_0x34ff('0x7d'),'113',_0x34ff('0x7e'),_0x34ff('0x7f'),_0x34ff('0x80'),_0x34ff('0x81'),_0x34ff('0x82'),_0x34ff('0x83'),_0x34ff('0x84'),'100',_0x34ff('0x85'),_0x34ff('0x86'),_0x34ff('0x87')];}_0x1720ed(_0x5a8733);}catch(_0x34492f){_0xda2f77(_0x34492f);}});}exports['create']=function(_0x2dcb8f,_0x20cff2){if(_0x2dcb8f[_0x34ff('0x3a')]['role']===_0x34ff('0x7a'))throw new Error(_0x34ff('0x88'));if(_0x2dcb8f['body']['role']===_0x34ff('0x3a')&&_0x2dcb8f[_0x34ff('0x3a')]['role']!=='admin'){throw new Error(_0x34ff('0x89'));}if(_0x2dcb8f['body']['role']==='admin'&&_0x2dcb8f['user'][_0x34ff('0x42')]!==_0x34ff('0x38')){throw new Error(_0x34ff('0x8a'));}return licenseUtil[_0x34ff('0x8b')]([_0x2dcb8f[_0x34ff('0x66')]])[_0x34ff('0x35')](function(){return validateUser(_0x2dcb8f['body']);})[_0x34ff('0x35')](function(_0x1093c7){return updateUser(_0x1093c7)[_0x34ff('0x35')](function(_0x2844e2){if(_0x2844e2['role']===_0x34ff('0x38')){_0x2844e2[_0x34ff('0x8c')]=_0x2dcb8f['user'][_0x34ff('0x8c')];delete _0x2844e2['userProfileId'];}return _0x2844e2;});})[_0x34ff('0x35')](function(_0x564474){return db[_0x34ff('0x48')][_0x34ff('0x8d')](_0x564474,{'include':[{'model':db[_0x34ff('0x77')],'as':_0x34ff('0x77')}]});})[_0x34ff('0x35')](function(_0x1e6ad4){if(_0x2dcb8f[_0x34ff('0x66')][_0x34ff('0x42')]===_0x34ff('0x3a'))return _0x1e6ad4;if(_0x2dcb8f[_0x34ff('0x3a')]['role']!==_0x34ff('0x3a'))return _0x1e6ad4;return db['UserProfileSection'][_0x34ff('0x41')]({'where':{'name':_0x1e6ad4['role']===_0x34ff('0x7a')?_0x34ff('0x3b'):'Telephones','userProfileId':_0x2dcb8f['user'][_0x34ff('0x8e')]},'raw':!![]})[_0x34ff('0x35')](function(_0x32276f){if(!_0x32276f||_0x32276f[_0x34ff('0x8f')]!=0x0)return _0x1e6ad4;return db[_0x34ff('0x44')]['create']({'name':_0x1e6ad4[_0x34ff('0x43')],'resourceId':_0x1e6ad4['id'],'type':_0x32276f[_0x34ff('0x43')],'sectionId':_0x32276f['id']},{})[_0x34ff('0x35')](function(){return _0x1e6ad4;});})['catch'](function(_0x2d327e){logger[_0x34ff('0x24')](_0x34ff('0x90'),_0x2d327e);throw _0x2d327e;});})[_0x34ff('0x35')](respondWithResult(_0x20cff2,0xc9))[_0x34ff('0x28')](handleError(_0x20cff2,null));};exports[_0x34ff('0x91')]=function(_0x2e9c9b,_0x781180){var _0x2c5c33=_0x2e9c9b[_0x34ff('0x66')];var _0x4220e1=[];if(_0x2e9c9b['user']['role']===_0x34ff('0x7a'))throw new Error(_0x34ff('0x88'));if(_[_0x34ff('0x92')](_0x2c5c33,[_0x34ff('0x42'),'user'])&&_0x2e9c9b[_0x34ff('0x3a')]['role']!==_0x34ff('0x38')){throw new Error(_0x34ff('0x89'));}if(_[_0x34ff('0x92')](_0x2c5c33,[_0x34ff('0x42'),_0x34ff('0x38')])&&_0x2e9c9b['user'][_0x34ff('0x42')]!=='admin'){throw new Error(_0x34ff('0x93'));}return licenseUtil[_0x34ff('0x8b')](_0x2c5c33)[_0x34ff('0x35')](function(){return validateUser(_0x2c5c33[0x0]);})[_0x34ff('0x35')](function(){for(var _0x563159=0x1;_0x563159<_0x2c5c33[_0x34ff('0x53')];_0x563159++){var _0x56f26f=_0x2c5c33[_0x563159-0x1][_0x34ff('0x6b')];if(!_0x2c5c33[_0x563159][_0x34ff('0x6b')])_0x2c5c33[_0x563159][_0x34ff('0x6b')]=_0x56f26f+0x1;_0x4220e1['push'](validateUser(_0x2c5c33[_0x563159]));}return BPromise[_0x34ff('0x94')](_0x4220e1);})[_0x34ff('0x35')](function(){_0x4220e1=[];for(var _0x27841a=0x0;_0x27841a<_0x2c5c33[_0x34ff('0x53')];_0x27841a++){_0x4220e1[_0x34ff('0x95')](updateUser(_0x2c5c33[_0x27841a]));}return BPromise[_0x34ff('0x94')](_0x4220e1);})[_0x34ff('0x35')](function(){return BPromise[_0x34ff('0x96')](_0x2c5c33,function(_0x608996){return db[_0x34ff('0x48')][_0x34ff('0x8d')](_0x608996,{'include':[{'model':db[_0x34ff('0x77')],'as':'VoiceMail'}]})[_0x34ff('0x35')](function(_0x120b3b){_0x608996['id']=_0x120b3b['id'];return _0x608996;});});})['then'](function(_0x4912e3){if(_0x2e9c9b[_0x34ff('0x66')][_0x34ff('0x42')]==='user')return _0x4912e3;if(_0x2e9c9b[_0x34ff('0x3a')]['role']!==_0x34ff('0x3a'))return _0x4912e3;var _0x10b2a5=_[_0x34ff('0x92')](_0x4912e3,function(_0x22009b){return _0x22009b[_0x34ff('0x42')]==='agent'||_0x22009b[_0x34ff('0x42')]===_0x34ff('0x3c');});if(!_0x10b2a5)return _0x4912e3;return db[_0x34ff('0x97')][_0x34ff('0x62')]({'where':{'name':{'$or':['Agents',_0x34ff('0x98')]},'userProfileId':_0x2e9c9b[_0x34ff('0x3a')][_0x34ff('0x8e')]},'raw':!![]})[_0x34ff('0x35')](function(_0x1fb7f5){if(_[_0x34ff('0x99')](_0x1fb7f5)||!_['some'](_0x1fb7f5,['autoAssociation',0x0]))return _0x4912e3;_0x4220e1=[];var _0x15c905=_(_0x1fb7f5)['map'](function(_0x59dfdb){if(_0x59dfdb['autoAssociation']===0x1)return;return _0x59dfdb[_0x34ff('0x43')]==='Agents'?_0x34ff('0x7a'):'telephone';})[_0x34ff('0x9a')]()[_0x34ff('0x40')]();for(var _0x1848e2=0x0;_0x1848e2<_0x4912e3['length'];_0x1848e2++){if(!_[_0x34ff('0x9b')](_0x15c905,_0x4912e3[_0x1848e2][_0x34ff('0x42')]))return;var _0x54c074=_0x4912e3[_0x1848e2][_0x34ff('0x42')]===_0x34ff('0x7a')?_0x34ff('0x3b'):_0x34ff('0x98');_0x4220e1[_0x34ff('0x95')](db[_0x34ff('0x44')][_0x34ff('0x8d')]({'name':_0x4912e3[_0x1848e2][_0x34ff('0x43')],'resourceId':_0x4912e3[_0x1848e2]['id'],'type':_0x54c074,'sectionId':_[_0x34ff('0x41')](_0x1fb7f5,[_0x34ff('0x43'),_0x54c074])['id']},{}));}return BPromise['all'](_0x4220e1);});})[_0x34ff('0x35')](respondWithResult(_0x781180,0xc9))[_0x34ff('0x28')](handleError(_0x781180,null));};exports[_0x34ff('0x9c')]=function(_0x52aa74,_0x3713b4,_0x4a1c90){if(_0x52aa74['body']['id']){delete _0x52aa74[_0x34ff('0x66')]['id'];}return db['User'][_0x34ff('0x41')]({'where':{'id':_0x52aa74['params']['id']}})[_0x34ff('0x35')](function(_0x3d2984){if(!_0x3d2984)return null;if(_0x3d2984['id']===_0x52aa74[_0x34ff('0x3a')]['id']){if(!_0x52aa74[_0x34ff('0x66')][_0x34ff('0x9d')]||!_0x52aa74['body'][_0x34ff('0x9e')]){throw new db[(_0x34ff('0x9f'))][(_0x34ff('0xa0'))](_0x34ff('0xa1'));}if(!_0x3d2984[_0x34ff('0xa2')](_0x52aa74[_0x34ff('0x66')]['oldPassword'])){throw new db[(_0x34ff('0x9f'))][(_0x34ff('0xa0'))](_0x34ff('0xa3'));}if(_0x52aa74[_0x34ff('0x66')]['oldPassword']===_0x52aa74[_0x34ff('0x66')]['newPassword']){throw new db['Sequelize'][(_0x34ff('0xa0'))](_0x34ff('0xa4'));}}else if(_0x52aa74['user'][_0x34ff('0x42')]===_0x34ff('0x38')){if(!_0x52aa74[_0x34ff('0x66')][_0x34ff('0x9e')]){throw new db[(_0x34ff('0x9f'))][(_0x34ff('0xa0'))](_0x34ff('0xa5'));}}else if(_0x52aa74[_0x34ff('0x3a')][_0x34ff('0x42')]===_0x34ff('0x3a')){if(!_0x52aa74[_0x34ff('0x66')][_0x34ff('0x9e')]){throw new db[(_0x34ff('0x9f'))][(_0x34ff('0xa0'))](_0x34ff('0xa5'));}if(_0x3d2984[_0x34ff('0x42')]!==_0x34ff('0x7a')){throw new db[(_0x34ff('0x9f'))][(_0x34ff('0xa0'))](_0x34ff('0x88'));}}else{throw new db[(_0x34ff('0x9f'))][(_0x34ff('0xa0'))](_0x34ff('0x88'));}return _0x3d2984;})[_0x34ff('0x35')](handleEntityNotFound(_0x3713b4,null))[_0x34ff('0x35')](function(_0xa5422a){return db[_0x34ff('0x6c')]['findOne']({'attributes':['id',_0x34ff('0x6e'),_0x34ff('0xa6'),_0x34ff('0xa7')]})[_0x34ff('0x35')](function(_0x516052){if(_0x516052[_0x34ff('0x6e')])authService[_0x34ff('0x6f')](_0x52aa74['body'][_0x34ff('0x9e')]);if(!_0x516052[_0x34ff('0xa6')]||!_0xa5422a[_0x34ff('0xa8')])return _0xa5422a;authService['validatePasswordHistory'](_0x52aa74[_0x34ff('0x66')][_0x34ff('0x9e')],_0xa5422a[_0x34ff('0xa8')],_0x516052[_0x34ff('0xa7')]);return _0xa5422a;})['then'](saveUpdates({'password':_0x52aa74[_0x34ff('0x66')][_0x34ff('0x9e')],'passwordResetAt':_0x52aa74[_0x34ff('0x3a')]['id']==_0x52aa74['params']['id']?moment():null,'previousPasswords':authService[_0x34ff('0xa9')](_0x52aa74[_0x34ff('0x66')][_0x34ff('0x9e')],_0xa5422a['previousPasswords'])},null));})[_0x34ff('0x35')](respondWithResult(_0x3713b4,null))[_0x34ff('0x28')](handleError(_0x3713b4,null));};exports[_0x34ff('0xaa')]=function(_0x467089,_0x54ae89,_0x528ca6){var _0xfe4aa3=_0x467089['body'][_0x34ff('0xab')];return db[_0x34ff('0x48')][_0x34ff('0x41')]({'where':{'id':_0x467089[_0x34ff('0x67')]['id']},'attributes':['id',_0x34ff('0x43'),_0x34ff('0x42'),_0x34ff('0xac'),_0x34ff('0xad'),_0x34ff('0xae'),_0x34ff('0xaf')]})['then'](handleEntityNotFound(_0x54ae89,null))['then'](function(_0x3b0c78){if(_0x3b0c78){if(!utils[_0x34ff('0xb0')](_0xfe4aa3)){throw new db[(_0x34ff('0x9f'))][(_0x34ff('0xa0'))]('Unknown\x20channel');}return _0x3b0c78[_0x34ff('0xb1')+_[_0x34ff('0xb2')](_0xfe4aa3[_0x34ff('0xb3')]())+_0x34ff('0xb4')](_0x467089['body'][_0x34ff('0x69')],{'penalty':_0x467089[_0x34ff('0x66')][_0x34ff('0xb5')]||0x0})[_0x34ff('0xb6')](function(_0x5c9cc2){for(var _0x139163=0x0;_0x139163<_0x467089[_0x34ff('0x66')][_0x34ff('0x69')][_0x34ff('0x53')];_0x139163+=0x1){var _0x1d1a6e={'UserId':_0x467089[_0x34ff('0x67')]['id']};_0x1d1a6e[_['capitalize'](_0xfe4aa3['toLowerCase']())+'QueueId']=_0x467089[_0x34ff('0x66')][_0x34ff('0x69')][_0x139163];socket[_0x34ff('0xb7')](_0x34ff('0x3a')+_[_0x34ff('0xb2')](_0xfe4aa3[_0x34ff('0xb3')]())+_0x34ff('0xb8'),_0x1d1a6e);}return _0x5c9cc2;})[_0x34ff('0x35')](function(){if(_0xfe4aa3===_0x34ff('0xb9')){return db[_0x34ff('0xba')][_0x34ff('0x62')]({'where':{'id':_0x467089[_0x34ff('0x66')]['ids']||[]},'raw':!![],'attributes':['id','name']});}})[_0x34ff('0x35')](function(_0x47eaca){var _0x354ed3=_0x3b0c78[_0x34ff('0x37')]({'plain':!![]});var _0x5c8cb7=[];if(_0xfe4aa3===_0x34ff('0xb9')&&_0x354ed3[_0x34ff('0x42')]===_0x34ff('0x7a')&&_0x354ed3[_0x34ff('0xac')]){for(var _0x16323a=0x0;_0x16323a<_0x47eaca[_0x34ff('0x53')];_0x16323a+=0x1){_0x5c8cb7['push']({'membername':_0x354ed3[_0x34ff('0x43')],'UserId':_0x354ed3['id'],'queue_name':_0x47eaca[_0x16323a][_0x34ff('0x43')],'VoiceQueueId':_0x47eaca[_0x16323a]['id'],'interface':_[_0x34ff('0x70')](_0x354ed3[_0x34ff('0xaf')])?util[_0x34ff('0xbb')]('SIP/%s',_0x354ed3[_0x34ff('0x43')]):_0x354ed3[_0x34ff('0xaf')],'paused':_0x354ed3[_0x34ff('0xae')]||![],'penalty':_0x467089[_0x34ff('0x66')]['penalty']||0x0});}return BPromise[_0x34ff('0x96')](_0x5c8cb7,function(_0x570e32){return db[_0x34ff('0xbc')][_0x34ff('0xbd')](_0x570e32);});}return _0x3b0c78;});}})[_0x34ff('0x35')](respondWithStatusCode(_0x54ae89,null))[_0x34ff('0x28')](handleError(_0x54ae89,null));};exports[_0x34ff('0xbe')]=function(_0x492506,_0x564e41,_0x737948){var _0x34b6a4;return db[_0x34ff('0x48')][_0x34ff('0x41')]({'where':{'id':_0x492506[_0x34ff('0x67')]['id']},'attributes':['id',_0x34ff('0x43'),_0x34ff('0x42')]})[_0x34ff('0x35')](handleEntityNotFound(_0x564e41,null))[_0x34ff('0x35')](function(_0x4f1aa1){if(_0x4f1aa1){_0x34b6a4=_0x4f1aa1;if(!_0x492506['query'][_0x34ff('0xab')]||!utils[_0x34ff('0xb0')](_0x492506[_0x34ff('0x4e')][_0x34ff('0xab')])){throw new db[(_0x34ff('0x9f'))]['ValidationError'](_0x34ff('0xbf'));}return _0x4f1aa1[_0x34ff('0xc0')+_[_0x34ff('0xb2')](_0x492506[_0x34ff('0x4e')][_0x34ff('0xab')][_0x34ff('0xb3')]())+'Queues'](_0x492506[_0x34ff('0x4e')][_0x34ff('0x69')]);}})[_0x34ff('0x35')](function(_0x518579){for(var _0x19a45d=0x0;_0x19a45d<_0x492506[_0x34ff('0x4e')]['ids'][_0x34ff('0x53')];_0x19a45d+=0x1){var _0x143b86={'UserId':_0x492506['params']['id']};_0x143b86[_[_0x34ff('0xb2')](_0x492506[_0x34ff('0x4e')][_0x34ff('0xab')][_0x34ff('0xb3')]())+_0x34ff('0xc1')]=_0x492506['query']['ids'][_0x19a45d];socket[_0x34ff('0xb7')](_0x34ff('0x3a')+_['capitalize'](_0x492506[_0x34ff('0x4e')][_0x34ff('0xab')][_0x34ff('0xb3')]())+_0x34ff('0xc2'),_0x143b86);}return _0x518579;})[_0x34ff('0x35')](function(){if(_0x492506[_0x34ff('0x4e')][_0x34ff('0xab')]==='voice'){return db[_0x34ff('0xbc')][_0x34ff('0x36')]({'where':{'UserId':_0x492506[_0x34ff('0x67')]['id'],'VoiceQueueId':_0x492506[_0x34ff('0x4e')][_0x34ff('0x69')]},'individualHooks':!![]})['then'](function(){return _0x34b6a4;});}return _0x34b6a4;})['then'](respondWithStatusCode(_0x564e41,null))[_0x34ff('0x28')](handleError(_0x564e41,null));};exports['addAvatar']=function(_0x1bfbea,_0x2820da,_0x285919){_0x1bfbea[_0x34ff('0x66')][_0x34ff('0xc3')]=_0x1bfbea[_0x34ff('0xc4')][_0x34ff('0xc5')];return db[_0x34ff('0x48')][_0x34ff('0x41')]({'where':{'id':_0x1bfbea['params']['id']}})['then'](handleEntityNotFound(_0x2820da,null))[_0x34ff('0x35')](saveUpdates(_0x1bfbea['body'],null))[_0x34ff('0x35')](respondWithResult(_0x2820da,null))[_0x34ff('0x28')](handleError(_0x2820da,null));};exports[_0x34ff('0xc6')]=function(_0x22d44b,_0x5a7300,_0x36bb35){var _0x510f5a=path[_0x34ff('0xc7')](config['root'],'server/files/images/logos/default_profile.png');return db[_0x34ff('0x48')][_0x34ff('0x41')]({'where':{'id':_0x22d44b[_0x34ff('0x67')]['id']},'attributes':['id',_0x34ff('0xc3')],'raw':!![]})[_0x34ff('0x35')](handleEntityNotFound(_0x5a7300,null))[_0x34ff('0x35')](function(_0x1d4769){if(_0x1d4769){if(_[_0x34ff('0x70')](_0x1d4769['userpic'])){return _0x5a7300[_0x34ff('0xc8')](_0x510f5a);}else{if(!fs[_0x34ff('0xc9')](path['join'](config[_0x34ff('0xca')],_0x34ff('0xcb'),_0x1d4769[_0x34ff('0xc3')]))){return _0x5a7300['download'](_0x510f5a);}return _0x5a7300[_0x34ff('0xc8')](path[_0x34ff('0xc7')](config[_0x34ff('0xca')],_0x34ff('0xcb'),_0x1d4769[_0x34ff('0xc3')]));}}})[_0x34ff('0x28')](handleError(_0x5a7300,null));};exports[_0x34ff('0xcc')]=function(_0x2ab64b,_0x5eb8c2,_0x3e52cd){var _0x570bbc={};var _0xe48f16={};var _0x55bd14;var _0x567bab;return db[_0x34ff('0x48')][_0x34ff('0xcd')]({'where':{'id':_0x2ab64b[_0x34ff('0x67')]['id']}})[_0x34ff('0x35')](handleEntityNotFound(_0x5eb8c2,null))[_0x34ff('0x35')](function(_0x4ab3ed){if(_0x4ab3ed){_0x55bd14=_0x4ab3ed;_0xe48f16[_0x34ff('0x4c')]=_[_0x34ff('0x4f')](db[_0x34ff('0xce')][_0x34ff('0x49')]);_0xe48f16[_0x34ff('0x4e')]=_[_0x34ff('0x4f')](_0x2ab64b[_0x34ff('0x4e')]);_0xe48f16['filters']=_[_0x34ff('0x50')](_0xe48f16[_0x34ff('0x4c')],_0xe48f16[_0x34ff('0x4e')]);_0x570bbc['attributes']=_[_0x34ff('0x50')](_0xe48f16[_0x34ff('0x4c')],qs[_0x34ff('0x52')](_0x2ab64b[_0x34ff('0x4e')][_0x34ff('0x52')]));_0x570bbc['attributes']=_0x570bbc[_0x34ff('0x51')][_0x34ff('0x53')]?_0x570bbc[_0x34ff('0x51')]:_0xe48f16[_0x34ff('0x4c')];_0x570bbc[_0x34ff('0x56')]=qs[_0x34ff('0x57')](_0x2ab64b[_0x34ff('0x4e')]['sort']);_0x570bbc['where']=qs[_0x34ff('0x59')](_[_0x34ff('0x5a')](_0x2ab64b[_0x34ff('0x4e')],_0xe48f16[_0x34ff('0x59')]));if(_0x2ab64b[_0x34ff('0x4e')][_0x34ff('0x3d')]){_0x570bbc[_0x34ff('0x58')]=_['merge'](_0x570bbc[_0x34ff('0x58')],{'$or':_[_0x34ff('0x3f')](_0x570bbc[_0x34ff('0x51')],function(_0x2d6e65){var _0x2480df={};_0x2480df[_0x2d6e65]={'$like':'%'+_0x2ab64b[_0x34ff('0x4e')][_0x34ff('0x3d')]+'%'};return _0x2480df;})});}_0x570bbc=_[_0x34ff('0x5b')]({},_0x570bbc,_0x2ab64b[_0x34ff('0x5f')]);return _0x55bd14[_0x34ff('0xcc')](_0x570bbc);}})[_0x34ff('0x35')](function(_0xc98a84){if(_0xc98a84){_0x567bab=_0xc98a84[_0x34ff('0x53')];if(_0x2ab64b[_0x34ff('0x4e')][_0x34ff('0x54')]('includeAll')){_0x570bbc[_0x34ff('0x61')]=[{'model':db['CmList'],'as':'List','required':![]},{'model':db[_0x34ff('0xcf')],'as':_0x34ff('0xd0'),'attributes':['id',_0x34ff('0x43'),_0x34ff('0xd1')],'where':_0x2ab64b[_0x34ff('0x4e')][_0x34ff('0xd2')]?{'id':_0x2ab64b[_0x34ff('0x4e')][_0x34ff('0xd2')]}:undefined,'required':_0x2ab64b[_0x34ff('0x4e')][_0x34ff('0xd2')]?!![]:![]}];}if(!_0x2ab64b[_0x34ff('0x4e')][_0x34ff('0x54')](_0x34ff('0x55'))){_0x570bbc[_0x34ff('0x2e')]=qs[_0x34ff('0x2e')](_0x2ab64b['query'][_0x34ff('0x2e')]);_0x570bbc[_0x34ff('0x2d')]=qs['offset'](_0x2ab64b[_0x34ff('0x4e')][_0x34ff('0x2d')]);}return _0x55bd14[_0x34ff('0xcc')](_0x570bbc);}})['then'](function(_0x1744cc){if(_0x1744cc){return _0x1744cc?{'count':_0x567bab,'rows':_0x1744cc}:null;}})['then'](respondWithResult(_0x5eb8c2,null))[_0x34ff('0x28')](handleError(_0x5eb8c2,null));};exports[_0x34ff('0xd3')]=function(_0x22f596,_0x4e7cdc,_0x5aa339){var _0x3ecf65;var _0x5cd6b2;var _0x5987c6={};var _0xd7679b;return db[_0x34ff('0x48')][_0x34ff('0xcd')]({'where':{'id':_0x22f596[_0x34ff('0x67')]['id']},'attributes':['id',_0x34ff('0x43'),_0x34ff('0x42')]})['then'](handleEntityNotFound(_0x4e7cdc,null))[_0x34ff('0x35')](function(_0x3fde6d){if(!utils[_0x34ff('0xb0')](_0x22f596['query']['channel'])){throw new db[(_0x34ff('0x9f'))]['ValidationError']('Unknown\x20channel');}_0x3ecf65=_0x3fde6d;var _0x26ee21={};_0x26ee21['model']=_[_0x34ff('0x4f')](db[_[_0x34ff('0xb2')](_0x22f596[_0x34ff('0x4e')][_0x34ff('0xab')])+_0x34ff('0xd4')]['rawAttributes']);_0x26ee21[_0x34ff('0x4e')]=_[_0x34ff('0x4f')](_0x22f596['query']);_0x26ee21['filters']=_[_0x34ff('0x50')](_0x26ee21['model'],_0x26ee21[_0x34ff('0x4e')]);_0x5987c6[_0x34ff('0x51')]=_[_0x34ff('0x50')](_0x26ee21[_0x34ff('0x4c')],qs['fields'](_0x22f596[_0x34ff('0x4e')][_0x34ff('0x52')]));_0x5987c6[_0x34ff('0x51')]=_0x5987c6[_0x34ff('0x51')][_0x34ff('0x53')]?_0x5987c6[_0x34ff('0x51')]:_0x26ee21[_0x34ff('0x4c')];_0x5987c6[_0x34ff('0x56')]=qs[_0x34ff('0x57')](_0x22f596['query']['sort']);_0x5987c6['where']=qs['filters'](_[_0x34ff('0x5a')](_0x22f596['query'],_0x26ee21[_0x34ff('0x59')]));if(_0x22f596[_0x34ff('0x4e')][_0x34ff('0x3d')]){_0x5987c6[_0x34ff('0x58')]=_[_0x34ff('0x5b')](_0x5987c6[_0x34ff('0x58')],{'$or':_[_0x34ff('0x3f')](_0x5987c6[_0x34ff('0x51')],function(_0x1aa2dd){var _0x5252f4={};_0x5252f4[_0x1aa2dd]={'$like':'%'+_0x22f596['query'][_0x34ff('0x3d')]+'%'};return _0x5252f4;})});}_0x5987c6=_[_0x34ff('0x5b')]({},_0x5987c6,_0x22f596['options']);switch(_0x3ecf65[_0x34ff('0x42')]){case _0x34ff('0x38'):return db[_[_0x34ff('0xb2')](_0x22f596[_0x34ff('0x4e')][_0x34ff('0xab')])+_0x34ff('0xd4')][_0x34ff('0x62')](_0x5987c6);case _0x34ff('0x3a'):case'agent':return _0x3ecf65['get'+_['capitalize'](_0x22f596[_0x34ff('0x4e')][_0x34ff('0xab')])+_0x34ff('0xb4')](_0x5987c6);default:throw new db['Sequelize'][(_0x34ff('0xa0'))](_0x34ff('0xd5'));}})['then'](function(_0x341be2){_0xd7679b=_0x341be2['length'];if(!_0x22f596[_0x34ff('0x4e')][_0x34ff('0x54')](_0x34ff('0x55'))){_0x5987c6['limit']=qs[_0x34ff('0x2e')](_0x22f596[_0x34ff('0x4e')]['limit']);_0x5987c6['offset']=qs[_0x34ff('0x2d')](_0x22f596[_0x34ff('0x4e')][_0x34ff('0x2d')]);}switch(_0x3ecf65['role']){case'admin':return db[_['capitalize'](_0x22f596[_0x34ff('0x4e')][_0x34ff('0xab')])+_0x34ff('0xd4')][_0x34ff('0x62')](_0x5987c6);case _0x34ff('0x3a'):case _0x34ff('0x7a'):return _0x3ecf65[_0x34ff('0x37')+_[_0x34ff('0xb2')](_0x22f596[_0x34ff('0x4e')]['channel'])+'Queues'](_0x5987c6);}})[_0x34ff('0x35')](function(_0x1753a8){return{'count':_0xd7679b,'rows':_0x1753a8};})[_0x34ff('0x35')](respondWithResult(_0x4e7cdc,null))[_0x34ff('0x28')](handleError(_0x4e7cdc,null));};exports[_0x34ff('0xd6')]=function(_0x2bd4f3,_0x368064,_0xe267b9){var _0x31fd93={};var _0x241a6f={};var _0x3941aa;var _0x367fdb;return db[_0x34ff('0x48')][_0x34ff('0xcd')]({'where':{'id':_0x2bd4f3[_0x34ff('0x67')]['id']}})[_0x34ff('0x35')](handleEntityNotFound(_0x368064,null))[_0x34ff('0x35')](function(_0x34269c){if(_0x34269c){_0x3941aa=_0x34269c;_0x241a6f['model']=_[_0x34ff('0x4f')](db['UserVoiceQueueRt'][_0x34ff('0x49')]);_0x241a6f[_0x34ff('0x4e')]=_[_0x34ff('0x4f')](_0x2bd4f3[_0x34ff('0x4e')]);_0x241a6f[_0x34ff('0x59')]=_[_0x34ff('0x50')](_0x241a6f[_0x34ff('0x4c')],_0x241a6f[_0x34ff('0x4e')]);_0x31fd93['attributes']=_[_0x34ff('0x50')](_0x241a6f[_0x34ff('0x4c')],qs[_0x34ff('0x52')](_0x2bd4f3[_0x34ff('0x4e')][_0x34ff('0x52')]));_0x31fd93[_0x34ff('0x51')]=_0x31fd93[_0x34ff('0x51')][_0x34ff('0x53')]?_0x31fd93['attributes']:_0x241a6f[_0x34ff('0x4c')];_0x31fd93[_0x34ff('0x56')]=qs[_0x34ff('0x57')](_0x2bd4f3['query'][_0x34ff('0x57')]);_0x31fd93[_0x34ff('0x58')]=qs[_0x34ff('0x59')](_['pick'](_0x2bd4f3[_0x34ff('0x4e')],_0x241a6f[_0x34ff('0x59')]));if(_0x2bd4f3[_0x34ff('0x4e')][_0x34ff('0x3d')]){_0x31fd93[_0x34ff('0x58')]=_[_0x34ff('0x5b')](_0x31fd93[_0x34ff('0x58')],{'$or':_[_0x34ff('0x3f')](_0x31fd93[_0x34ff('0x51')],function(_0x3e9ee3){var _0xea28eb={};_0xea28eb[_0x3e9ee3]={'$like':'%'+_0x2bd4f3[_0x34ff('0x4e')]['filter']+'%'};return _0xea28eb;})});}_0x31fd93=_[_0x34ff('0x5b')]({},_0x31fd93,_0x2bd4f3[_0x34ff('0x5f')]);return _0x3941aa[_0x34ff('0xd6')](_0x31fd93);}})[_0x34ff('0x35')](function(_0x2ae04a){if(_0x2ae04a){_0x367fdb=_0x2ae04a[_0x34ff('0x53')];if(!_0x2bd4f3[_0x34ff('0x4e')]['hasOwnProperty'](_0x34ff('0x55'))){_0x31fd93[_0x34ff('0x2e')]=qs['limit'](_0x2bd4f3[_0x34ff('0x4e')]['limit']);_0x31fd93[_0x34ff('0x2d')]=qs['offset'](_0x2bd4f3[_0x34ff('0x4e')][_0x34ff('0x2d')]);}return _0x3941aa[_0x34ff('0xd6')](_0x31fd93);}})[_0x34ff('0x35')](function(_0x35fab0){if(_0x35fab0){return _0x35fab0?{'count':_0x367fdb,'rows':_0x35fab0}:null;}})[_0x34ff('0x35')](respondWithResult(_0x368064,null))['catch'](handleError(_0x368064,null));};exports[_0x34ff('0xd7')]=function(_0x2c0361,_0x1cc35c,_0x441449){var _0x17c055={};var _0x2537a4={};var _0x18166d;var _0xbd709a;return db[_0x34ff('0x48')][_0x34ff('0xcd')]({'where':{'id':_0x2c0361['params']['id']}})[_0x34ff('0x35')](handleEntityNotFound(_0x1cc35c,null))[_0x34ff('0x35')](function(_0x2116a1){if(_0x2116a1){_0x18166d=_0x2116a1;_0x2537a4[_0x34ff('0x4c')]=_[_0x34ff('0x4f')](db[_0x34ff('0xd8')][_0x34ff('0x49')]);_0x2537a4[_0x34ff('0x4e')]=_[_0x34ff('0x4f')](_0x2c0361[_0x34ff('0x4e')]);_0x2537a4['filters']=_['intersection'](_0x2537a4[_0x34ff('0x4c')],_0x2537a4[_0x34ff('0x4e')]);_0x17c055[_0x34ff('0x51')]=_['intersection'](_0x2537a4[_0x34ff('0x4c')],qs['fields'](_0x2c0361[_0x34ff('0x4e')]['fields']));_0x17c055[_0x34ff('0x51')]=_0x17c055[_0x34ff('0x51')][_0x34ff('0x53')]?_0x17c055[_0x34ff('0x51')]:_0x2537a4[_0x34ff('0x4c')];_0x17c055[_0x34ff('0x56')]=qs[_0x34ff('0x57')](_0x2c0361[_0x34ff('0x4e')][_0x34ff('0x57')]);_0x17c055['where']=qs[_0x34ff('0x59')](_[_0x34ff('0x5a')](_0x2c0361[_0x34ff('0x4e')],_0x2537a4[_0x34ff('0x59')]));if(_0x2c0361['query']['filter']){_0x17c055[_0x34ff('0x58')]=_[_0x34ff('0x5b')](_0x17c055[_0x34ff('0x58')],{'$or':_[_0x34ff('0x3f')](_0x17c055[_0x34ff('0x51')],function(_0x4f1f4d){var _0x3cdb83={};_0x3cdb83[_0x4f1f4d]={'$like':'%'+_0x2c0361[_0x34ff('0x4e')][_0x34ff('0x3d')]+'%'};return _0x3cdb83;})});}_0x17c055=_[_0x34ff('0x5b')]({},_0x17c055,_0x2c0361[_0x34ff('0x5f')]);return _0x18166d[_0x34ff('0xd7')](_0x17c055);}})[_0x34ff('0x35')](function(_0x494373){if(_0x494373){_0xbd709a=_0x494373[_0x34ff('0x53')];if(!_0x2c0361['query']['hasOwnProperty'](_0x34ff('0x55'))){_0x17c055[_0x34ff('0x2e')]=qs[_0x34ff('0x2e')](_0x2c0361[_0x34ff('0x4e')][_0x34ff('0x2e')]);_0x17c055['offset']=qs[_0x34ff('0x2d')](_0x2c0361[_0x34ff('0x4e')][_0x34ff('0x2d')]);}return _0x18166d['getGroups'](_0x17c055);}})[_0x34ff('0x35')](function(_0xb5e46f){if(_0xb5e46f){return _0xb5e46f?{'count':_0xbd709a,'rows':_0xb5e46f}:null;}})[_0x34ff('0x35')](respondWithResult(_0x1cc35c,null))[_0x34ff('0x28')](handleError(_0x1cc35c,null));};exports[_0x34ff('0xd9')]=function(_0x552e3c,_0x25e620,_0x3b476a){var _0x239abe={'raw':!![],'where':{}};var _0x4ea330={};var _0x151e8b={'count':0x0,'rows':[]};return db['User'][_0x34ff('0xcd')]({'where':{'id':_0x552e3c[_0x34ff('0x67')]['id']}})[_0x34ff('0x35')](handleEntityNotFound(_0x25e620,null))['then'](function(_0x168240){if(_0x168240){_0x4ea330[_0x34ff('0x4c')]=_[_0x34ff('0x4f')](db[_0x34ff('0xda')][_0x34ff('0x49')]);_0x4ea330[_0x34ff('0x4e')]=_[_0x34ff('0x4f')](_0x552e3c['query']);_0x4ea330[_0x34ff('0x59')]=_[_0x34ff('0x50')](_0x4ea330[_0x34ff('0x4c')],_0x4ea330[_0x34ff('0x4e')]);_0x239abe[_0x34ff('0x51')]=_[_0x34ff('0x50')](_0x4ea330[_0x34ff('0x4c')],qs[_0x34ff('0x52')](_0x552e3c[_0x34ff('0x4e')][_0x34ff('0x52')]));_0x239abe[_0x34ff('0x51')]=_0x239abe[_0x34ff('0x51')][_0x34ff('0x53')]?_0x239abe[_0x34ff('0x51')]:_0x4ea330['model'];if(!_0x552e3c[_0x34ff('0x4e')][_0x34ff('0x54')](_0x34ff('0x55'))){_0x239abe[_0x34ff('0x2e')]=qs[_0x34ff('0x2e')](_0x552e3c[_0x34ff('0x4e')]['limit']);_0x239abe[_0x34ff('0x2d')]=qs[_0x34ff('0x2d')](_0x552e3c['query'][_0x34ff('0x2d')]);}_0x239abe[_0x34ff('0x56')]=qs[_0x34ff('0x57')](_0x552e3c[_0x34ff('0x4e')][_0x34ff('0x57')]);_0x239abe[_0x34ff('0x58')]=qs[_0x34ff('0x59')](_[_0x34ff('0x5a')](_0x552e3c['query'],_0x4ea330[_0x34ff('0x59')]));_0x239abe[_0x34ff('0x58')][_0x34ff('0xdb')]=_0x168240['id'];if(_0x552e3c[_0x34ff('0x4e')][_0x34ff('0x3d')]){_0x239abe[_0x34ff('0x58')]=_[_0x34ff('0x5b')](_0x239abe[_0x34ff('0x58')],{'$or':_[_0x34ff('0x3f')](_0x239abe[_0x34ff('0x51')],function(_0x2c4eba){var _0x280776={};_0x280776[_0x2c4eba]={'$like':'%'+_0x552e3c[_0x34ff('0x4e')][_0x34ff('0x3d')]+'%'};return _0x280776;})});}_0x239abe=_['merge']({},_0x239abe,_0x552e3c[_0x34ff('0x5f')]);return db[_0x34ff('0xda')][_0x34ff('0x2c')]({'where':_0x239abe['where']})[_0x34ff('0x35')](function(_0x56f23e){_0x151e8b[_0x34ff('0x2c')]=_0x56f23e;if(_0x552e3c['query'][_0x34ff('0x60')]){_0x239abe['include']=[{'all':!![]}];}return db[_0x34ff('0xda')]['findAll'](_0x239abe);})['then'](function(_0xe46cb8){_0x151e8b[_0x34ff('0x63')]=_0xe46cb8;return _0x151e8b;});}})[_0x34ff('0x35')](respondWithFilteredResult(_0x25e620,_0x239abe))[_0x34ff('0x28')](handleError(_0x25e620,null));};exports[_0x34ff('0xdc')]=function(_0x22756a,_0x4fe225,_0x1f7092){var _0x397f1a={'raw':!![],'where':{}};var _0x454b31={};var _0x41a04b={'count':0x0,'rows':[]};return db[_0x34ff('0x48')]['findOne']({'where':{'id':_0x22756a[_0x34ff('0x67')]['id']}})[_0x34ff('0x35')](handleEntityNotFound(_0x4fe225,null))[_0x34ff('0x35')](function(_0x3c1a3a){if(_0x3c1a3a){_0x454b31['model']=_[_0x34ff('0x4f')](db[_0x34ff('0xdd')][_0x34ff('0x49')]);_0x454b31['query']=_[_0x34ff('0x4f')](_0x22756a['query']);_0x454b31['filters']=_['intersection'](_0x454b31[_0x34ff('0x4c')],_0x454b31[_0x34ff('0x4e')]);_0x397f1a[_0x34ff('0x51')]=_['intersection'](_0x454b31['model'],qs['fields'](_0x22756a[_0x34ff('0x4e')][_0x34ff('0x52')]));_0x397f1a[_0x34ff('0x51')]=_0x397f1a['attributes'][_0x34ff('0x53')]?_0x397f1a[_0x34ff('0x51')]:_0x454b31[_0x34ff('0x4c')];if(!_0x22756a[_0x34ff('0x4e')]['hasOwnProperty']('nolimit')){_0x397f1a[_0x34ff('0x2e')]=qs[_0x34ff('0x2e')](_0x22756a[_0x34ff('0x4e')][_0x34ff('0x2e')]);_0x397f1a['offset']=qs[_0x34ff('0x2d')](_0x22756a[_0x34ff('0x4e')][_0x34ff('0x2d')]);}_0x397f1a[_0x34ff('0x56')]=qs['sort'](_0x22756a[_0x34ff('0x4e')]['sort']);_0x397f1a[_0x34ff('0x58')]=qs[_0x34ff('0x59')](_[_0x34ff('0x5a')](_0x22756a[_0x34ff('0x4e')],_0x454b31[_0x34ff('0x59')]));_0x397f1a['where']['UserId']=_0x3c1a3a['id'];if(_0x22756a[_0x34ff('0x4e')][_0x34ff('0x3d')]){_0x397f1a[_0x34ff('0x58')]=_[_0x34ff('0x5b')](_0x397f1a[_0x34ff('0x58')],{'$or':_[_0x34ff('0x3f')](_0x397f1a[_0x34ff('0x51')],function(_0x2fa9c5){var _0x201bc3={};_0x201bc3[_0x2fa9c5]={'$like':'%'+_0x22756a[_0x34ff('0x4e')]['filter']+'%'};return _0x201bc3;})});}_0x397f1a=_[_0x34ff('0x5b')]({},_0x397f1a,_0x22756a['options']);return db[_0x34ff('0xdd')][_0x34ff('0x2c')]({'where':_0x397f1a[_0x34ff('0x58')]})[_0x34ff('0x35')](function(_0x168028){_0x41a04b[_0x34ff('0x2c')]=_0x168028;if(_0x22756a['query'][_0x34ff('0x60')]){_0x397f1a['include']=[{'all':!![]}];}return db[_0x34ff('0xdd')][_0x34ff('0x62')](_0x397f1a);})[_0x34ff('0x35')](function(_0x5f4895){_0x41a04b[_0x34ff('0x63')]=_0x5f4895;return _0x41a04b;});}})[_0x34ff('0x35')](respondWithFilteredResult(_0x4fe225,_0x397f1a))[_0x34ff('0x28')](handleError(_0x4fe225,null));};exports['getChatInteractions']=function(_0x378367,_0xedd66b,_0x2fc5e4){var _0x5d8337={};var _0x428214={};var _0x125677;var _0x65b502;return db[_0x34ff('0x48')][_0x34ff('0xcd')]({'where':{'id':_0x378367[_0x34ff('0x67')]['id']}})[_0x34ff('0x35')](handleEntityNotFound(_0xedd66b,null))[_0x34ff('0x35')](function(_0x3986fe){if(_0x3986fe){_0x125677=_0x3986fe;_0x428214[_0x34ff('0x4c')]=_[_0x34ff('0x4f')](db[_0x34ff('0xde')][_0x34ff('0x49')]);_0x428214[_0x34ff('0x4e')]=_['keys'](_0x378367[_0x34ff('0x4e')]);_0x428214[_0x34ff('0x59')]=_['intersection'](_0x428214[_0x34ff('0x4c')],_0x428214['query']);_0x5d8337[_0x34ff('0x51')]=_[_0x34ff('0x50')](_0x428214[_0x34ff('0x4c')],qs[_0x34ff('0x52')](_0x378367[_0x34ff('0x4e')][_0x34ff('0x52')]));_0x5d8337[_0x34ff('0x51')]=_0x5d8337[_0x34ff('0x51')][_0x34ff('0x53')]?_0x5d8337[_0x34ff('0x51')]:_0x428214[_0x34ff('0x4c')];_0x5d8337[_0x34ff('0x56')]=qs[_0x34ff('0x57')](_0x378367[_0x34ff('0x4e')]['sort']);_0x5d8337['where']=qs[_0x34ff('0x59')](_['pick'](_0x378367['query'],_0x428214[_0x34ff('0x59')]));if(_0x378367['query'][_0x34ff('0x3d')]){_0x5d8337[_0x34ff('0x58')]=_['merge'](_0x5d8337['where'],{'$or':_[_0x34ff('0x3f')](_0x5d8337['attributes'],function(_0x464a3e){var _0x34dfe5={};_0x34dfe5[_0x464a3e]={'$like':'%'+_0x378367['query']['filter']+'%'};return _0x34dfe5;})});}_0x5d8337=_['merge']({},_0x5d8337,_0x378367[_0x34ff('0x5f')]);return _0x125677[_0x34ff('0xdf')](_0x5d8337);}})[_0x34ff('0x35')](function(_0x17293e){if(_0x17293e){_0x65b502=_0x17293e[_0x34ff('0x53')];if(!_0x378367['query'][_0x34ff('0x54')](_0x34ff('0x55'))){_0x5d8337[_0x34ff('0x2e')]=qs[_0x34ff('0x2e')](_0x378367[_0x34ff('0x4e')][_0x34ff('0x2e')]);_0x5d8337['offset']=qs['offset'](_0x378367['query'][_0x34ff('0x2d')]);}return _0x125677[_0x34ff('0xdf')](_0x5d8337);}})[_0x34ff('0x35')](function(_0x3ac4d1){if(_0x3ac4d1){return _0x3ac4d1?{'count':_0x65b502,'rows':_0x3ac4d1}:null;}})[_0x34ff('0x35')](respondWithResult(_0xedd66b,null))[_0x34ff('0x28')](handleError(_0xedd66b,null));};exports[_0x34ff('0xe0')]=function(_0x266193,_0x59dfa2,_0x15ec0d){var _0x13509c={};var _0xee9d1f={};var _0x226e48;var _0x2315d3;return db[_0x34ff('0x48')]['findOne']({'where':{'id':_0x266193[_0x34ff('0x67')]['id']}})[_0x34ff('0x35')](handleEntityNotFound(_0x59dfa2,null))[_0x34ff('0x35')](function(_0x37f707){if(_0x37f707){_0x226e48=_0x37f707;_0xee9d1f[_0x34ff('0x4c')]=_[_0x34ff('0x4f')](db[_0x34ff('0xe1')][_0x34ff('0x49')]);_0xee9d1f[_0x34ff('0x4e')]=_[_0x34ff('0x4f')](_0x266193[_0x34ff('0x4e')]);_0xee9d1f[_0x34ff('0x59')]=_[_0x34ff('0x50')](_0xee9d1f['model'],_0xee9d1f[_0x34ff('0x4e')]);_0x13509c['attributes']=_[_0x34ff('0x50')](_0xee9d1f[_0x34ff('0x4c')],qs[_0x34ff('0x52')](_0x266193[_0x34ff('0x4e')][_0x34ff('0x52')]));_0x13509c[_0x34ff('0x51')]=_0x13509c[_0x34ff('0x51')][_0x34ff('0x53')]?_0x13509c[_0x34ff('0x51')]:_0xee9d1f[_0x34ff('0x4c')];_0x13509c['order']=qs['sort'](_0x266193['query'][_0x34ff('0x57')]);_0x13509c['where']=qs[_0x34ff('0x59')](_['pick'](_0x266193[_0x34ff('0x4e')],_0xee9d1f[_0x34ff('0x59')]));if(_0x266193[_0x34ff('0x4e')][_0x34ff('0x3d')]){_0x13509c[_0x34ff('0x58')]=_[_0x34ff('0x5b')](_0x13509c[_0x34ff('0x58')],{'$or':_[_0x34ff('0x3f')](_0x13509c['attributes'],function(_0x4d8df0){var _0x1d5b23={};_0x1d5b23[_0x4d8df0]={'$like':'%'+_0x266193[_0x34ff('0x4e')]['filter']+'%'};return _0x1d5b23;})});}_0x13509c=_[_0x34ff('0x5b')]({},_0x13509c,_0x266193[_0x34ff('0x5f')]);return _0x226e48[_0x34ff('0xe0')](_0x13509c);}})[_0x34ff('0x35')](function(_0x179959){if(_0x179959){_0x2315d3=_0x179959[_0x34ff('0x53')];if(!_0x266193[_0x34ff('0x4e')]['hasOwnProperty']('nolimit')){_0x13509c['limit']=qs[_0x34ff('0x2e')](_0x266193[_0x34ff('0x4e')][_0x34ff('0x2e')]);_0x13509c[_0x34ff('0x2d')]=qs['offset'](_0x266193[_0x34ff('0x4e')][_0x34ff('0x2d')]);}return _0x226e48[_0x34ff('0xe0')](_0x13509c);}})['then'](function(_0x385847){if(_0x385847){return _0x385847?{'count':_0x2315d3,'rows':_0x385847}:null;}})[_0x34ff('0x35')](respondWithResult(_0x59dfa2,null))[_0x34ff('0x28')](handleError(_0x59dfa2,null));};exports[_0x34ff('0xe2')]=function(_0x5a6de4,_0x230431,_0x450bdd){var _0x317809={'raw':!![],'where':{}};var _0x3c088d={};var _0x45ab9f={'count':0x0,'rows':[]};return db['User']['findOne']({'where':{'id':_0x5a6de4[_0x34ff('0x67')]['id']}})[_0x34ff('0x35')](handleEntityNotFound(_0x230431,null))[_0x34ff('0x35')](function(_0x534070){if(_0x534070){_0x3c088d[_0x34ff('0x4c')]=_['keys'](db['MailInteraction'][_0x34ff('0x49')]);_0x3c088d[_0x34ff('0x4e')]=_[_0x34ff('0x4f')](_0x5a6de4['query']);_0x3c088d[_0x34ff('0x59')]=_[_0x34ff('0x50')](_0x3c088d['model'],_0x3c088d[_0x34ff('0x4e')]);_0x317809[_0x34ff('0x51')]=_[_0x34ff('0x50')](_0x3c088d['model'],qs[_0x34ff('0x52')](_0x5a6de4[_0x34ff('0x4e')][_0x34ff('0x52')]));_0x317809['attributes']=_0x317809[_0x34ff('0x51')][_0x34ff('0x53')]?_0x317809[_0x34ff('0x51')]:_0x3c088d[_0x34ff('0x4c')];if(!_0x5a6de4[_0x34ff('0x4e')][_0x34ff('0x54')](_0x34ff('0x55'))){_0x317809[_0x34ff('0x2e')]=qs[_0x34ff('0x2e')](_0x5a6de4[_0x34ff('0x4e')][_0x34ff('0x2e')]);_0x317809['offset']=qs[_0x34ff('0x2d')](_0x5a6de4[_0x34ff('0x4e')][_0x34ff('0x2d')]);}_0x317809['order']=qs[_0x34ff('0x57')](_0x5a6de4['query'][_0x34ff('0x57')]);_0x317809['where']=qs[_0x34ff('0x59')](_[_0x34ff('0x5a')](_0x5a6de4[_0x34ff('0x4e')],_0x3c088d[_0x34ff('0x59')]));_0x317809['where']['UserId']=_0x534070['id'];if(_0x5a6de4[_0x34ff('0x4e')][_0x34ff('0x3d')]){_0x317809[_0x34ff('0x58')]=_['merge'](_0x317809[_0x34ff('0x58')],{'$or':_['map'](_0x317809['attributes'],function(_0x3e685e){var _0x27116d={};_0x27116d[_0x3e685e]={'$like':'%'+_0x5a6de4[_0x34ff('0x4e')][_0x34ff('0x3d')]+'%'};return _0x27116d;})});}_0x317809=_[_0x34ff('0x5b')]({},_0x317809,_0x5a6de4[_0x34ff('0x5f')]);return db[_0x34ff('0xe3')][_0x34ff('0x2c')]({'where':_0x317809[_0x34ff('0x58')]})['then'](function(_0x103fd7){_0x45ab9f[_0x34ff('0x2c')]=_0x103fd7;if(_0x5a6de4['query'][_0x34ff('0x60')]){_0x317809[_0x34ff('0x61')]=[{'all':!![]}];}return db[_0x34ff('0xe3')]['findAll'](_0x317809);})[_0x34ff('0x35')](function(_0x34dee2){_0x45ab9f[_0x34ff('0x63')]=_0x34dee2;return _0x45ab9f;});}})[_0x34ff('0x35')](respondWithFilteredResult(_0x230431,_0x317809))[_0x34ff('0x28')](handleError(_0x230431,null));};exports[_0x34ff('0xe4')]=function(_0x15cff5,_0x31ce4e,_0xf90997){var _0x369474={};var _0x49c8ec={};var _0xf56b7d;var _0x512ef5;return db[_0x34ff('0x48')]['findOne']({'where':{'id':_0x15cff5['params']['id']}})['then'](handleEntityNotFound(_0x31ce4e,null))['then'](function(_0x58320e){if(_0x58320e){_0xf56b7d=_0x58320e;_0x49c8ec['model']=_[_0x34ff('0x4f')](db['SmsInteraction'][_0x34ff('0x49')]);_0x49c8ec[_0x34ff('0x4e')]=_['keys'](_0x15cff5[_0x34ff('0x4e')]);_0x49c8ec[_0x34ff('0x59')]=_['intersection'](_0x49c8ec[_0x34ff('0x4c')],_0x49c8ec[_0x34ff('0x4e')]);_0x369474['attributes']=_[_0x34ff('0x50')](_0x49c8ec['model'],qs[_0x34ff('0x52')](_0x15cff5[_0x34ff('0x4e')][_0x34ff('0x52')]));_0x369474['attributes']=_0x369474[_0x34ff('0x51')][_0x34ff('0x53')]?_0x369474['attributes']:_0x49c8ec[_0x34ff('0x4c')];_0x369474[_0x34ff('0x56')]=qs[_0x34ff('0x57')](_0x15cff5[_0x34ff('0x4e')][_0x34ff('0x57')]);_0x369474['where']=qs[_0x34ff('0x59')](_[_0x34ff('0x5a')](_0x15cff5[_0x34ff('0x4e')],_0x49c8ec[_0x34ff('0x59')]));if(_0x15cff5[_0x34ff('0x4e')][_0x34ff('0x3d')]){_0x369474[_0x34ff('0x58')]=_[_0x34ff('0x5b')](_0x369474['where'],{'$or':_['map'](_0x369474[_0x34ff('0x51')],function(_0x3041f3){var _0x556000={};_0x556000[_0x3041f3]={'$like':'%'+_0x15cff5[_0x34ff('0x4e')][_0x34ff('0x3d')]+'%'};return _0x556000;})});}_0x369474=_['merge']({},_0x369474,_0x15cff5[_0x34ff('0x5f')]);return _0xf56b7d[_0x34ff('0xe4')](_0x369474);}})[_0x34ff('0x35')](function(_0x3cee04){if(_0x3cee04){_0x512ef5=_0x3cee04[_0x34ff('0x53')];if(!_0x15cff5['query'][_0x34ff('0x54')](_0x34ff('0x55'))){_0x369474[_0x34ff('0x2e')]=qs['limit'](_0x15cff5[_0x34ff('0x4e')][_0x34ff('0x2e')]);_0x369474[_0x34ff('0x2d')]=qs[_0x34ff('0x2d')](_0x15cff5[_0x34ff('0x4e')][_0x34ff('0x2d')]);}return _0xf56b7d['getSmsInteractions'](_0x369474);}})[_0x34ff('0x35')](function(_0x54da52){if(_0x54da52){return _0x54da52?{'count':_0x512ef5,'rows':_0x54da52}:null;}})[_0x34ff('0x35')](respondWithResult(_0x31ce4e,null))[_0x34ff('0x28')](handleError(_0x31ce4e,null));};exports[_0x34ff('0xe5')]=function(_0x4be364,_0x1fe894,_0x4b5978){var _0xc4936e={};var _0x237a8f={};var _0x5abe3b;var _0x229c68;return db[_0x34ff('0x48')]['findOne']({'where':{'id':_0x4be364['params']['id']}})['then'](handleEntityNotFound(_0x1fe894,null))[_0x34ff('0x35')](function(_0x1df12f){if(_0x1df12f){_0x5abe3b=_0x1df12f;_0x237a8f[_0x34ff('0x4c')]=_[_0x34ff('0x4f')](db[_0x34ff('0xe6')]['rawAttributes']);_0x237a8f[_0x34ff('0x4e')]=_[_0x34ff('0x4f')](_0x4be364[_0x34ff('0x4e')]);_0x237a8f[_0x34ff('0x59')]=_['intersection'](_0x237a8f[_0x34ff('0x4c')],_0x237a8f[_0x34ff('0x4e')]);_0xc4936e[_0x34ff('0x51')]=_[_0x34ff('0x50')](_0x237a8f['model'],qs[_0x34ff('0x52')](_0x4be364['query']['fields']));_0xc4936e[_0x34ff('0x51')]=_0xc4936e[_0x34ff('0x51')]['length']?_0xc4936e[_0x34ff('0x51')]:_0x237a8f[_0x34ff('0x4c')];_0xc4936e['order']=qs[_0x34ff('0x57')](_0x4be364[_0x34ff('0x4e')]['sort']);_0xc4936e[_0x34ff('0x58')]=qs[_0x34ff('0x59')](_[_0x34ff('0x5a')](_0x4be364[_0x34ff('0x4e')],_0x237a8f[_0x34ff('0x59')]));if(_0x4be364['query'][_0x34ff('0x3d')]){_0xc4936e[_0x34ff('0x58')]=_[_0x34ff('0x5b')](_0xc4936e[_0x34ff('0x58')],{'$or':_['map'](_0xc4936e['attributes'],function(_0x58aa2e){var _0x3f2b8f={};_0x3f2b8f[_0x58aa2e]={'$like':'%'+_0x4be364[_0x34ff('0x4e')][_0x34ff('0x3d')]+'%'};return _0x3f2b8f;})});}_0xc4936e=_[_0x34ff('0x5b')]({},_0xc4936e,_0x4be364[_0x34ff('0x5f')]);return _0x5abe3b[_0x34ff('0xe5')](_0xc4936e);}})[_0x34ff('0x35')](function(_0x17e86c){if(_0x17e86c){_0x229c68=_0x17e86c[_0x34ff('0x53')];if(!_0x4be364[_0x34ff('0x4e')]['hasOwnProperty'](_0x34ff('0x55'))){_0xc4936e['limit']=qs[_0x34ff('0x2e')](_0x4be364[_0x34ff('0x4e')][_0x34ff('0x2e')]);_0xc4936e[_0x34ff('0x2d')]=qs[_0x34ff('0x2d')](_0x4be364['query'][_0x34ff('0x2d')]);}return _0x5abe3b[_0x34ff('0xe5')](_0xc4936e);}})['then'](function(_0x5ab3f7){if(_0x5ab3f7){return _0x5ab3f7?{'count':_0x229c68,'rows':_0x5ab3f7}:null;}})[_0x34ff('0x35')](respondWithResult(_0x1fe894,null))[_0x34ff('0x28')](handleError(_0x1fe894,null));};exports[_0x34ff('0xe7')]=function(_0x9381b4,_0x4dc64f,_0x4f756d){var _0x8df001={};var _0x202edd={};var _0x440d2e;var _0x32494c;return db[_0x34ff('0x48')]['findOne']({'where':{'id':_0x9381b4[_0x34ff('0x67')]['id']}})[_0x34ff('0x35')](handleEntityNotFound(_0x4dc64f,null))['then'](function(_0x5abd50){if(_0x5abd50){_0x440d2e=_0x5abd50;_0x202edd[_0x34ff('0x4c')]=_[_0x34ff('0x4f')](db['WhatsappInteraction'][_0x34ff('0x49')]);_0x202edd[_0x34ff('0x4e')]=_['keys'](_0x9381b4[_0x34ff('0x4e')]);_0x202edd[_0x34ff('0x59')]=_[_0x34ff('0x50')](_0x202edd[_0x34ff('0x4c')],_0x202edd[_0x34ff('0x4e')]);_0x8df001[_0x34ff('0x51')]=_['intersection'](_0x202edd['model'],qs[_0x34ff('0x52')](_0x9381b4[_0x34ff('0x4e')][_0x34ff('0x52')]));_0x8df001[_0x34ff('0x51')]=_0x8df001[_0x34ff('0x51')][_0x34ff('0x53')]?_0x8df001[_0x34ff('0x51')]:_0x202edd['model'];_0x8df001[_0x34ff('0x56')]=qs[_0x34ff('0x57')](_0x9381b4[_0x34ff('0x4e')][_0x34ff('0x57')]);_0x8df001[_0x34ff('0x58')]=qs['filters'](_['pick'](_0x9381b4[_0x34ff('0x4e')],_0x202edd['filters']));if(_0x9381b4[_0x34ff('0x4e')]['filter']){_0x8df001['where']=_['merge'](_0x8df001[_0x34ff('0x58')],{'$or':_[_0x34ff('0x3f')](_0x8df001['attributes'],function(_0x4dee89){var _0x2862f1={};_0x2862f1[_0x4dee89]={'$like':'%'+_0x9381b4['query'][_0x34ff('0x3d')]+'%'};return _0x2862f1;})});}_0x8df001=_[_0x34ff('0x5b')]({},_0x8df001,_0x9381b4[_0x34ff('0x5f')]);return _0x440d2e['getWhatsappInteractions'](_0x8df001);}})[_0x34ff('0x35')](function(_0x2a4060){if(_0x2a4060){_0x32494c=_0x2a4060[_0x34ff('0x53')];if(!_0x9381b4['query']['hasOwnProperty'](_0x34ff('0x55'))){_0x8df001[_0x34ff('0x2e')]=qs[_0x34ff('0x2e')](_0x9381b4[_0x34ff('0x4e')][_0x34ff('0x2e')]);_0x8df001[_0x34ff('0x2d')]=qs[_0x34ff('0x2d')](_0x9381b4[_0x34ff('0x4e')][_0x34ff('0x2d')]);}return _0x440d2e[_0x34ff('0xe7')](_0x8df001);}})[_0x34ff('0x35')](function(_0x5b969c){if(_0x5b969c){return _0x5b969c?{'count':_0x32494c,'rows':_0x5b969c}:null;}})[_0x34ff('0x35')](respondWithResult(_0x4dc64f,null))['catch'](handleError(_0x4dc64f,null));};exports['login']=function(_0x236ef0,_0x34fc4b,_0xee6ab4){var _0x5ae568;var _0x433134;var _0x1eff77;var _0x2b8955=!_[_0x34ff('0x70')](_0x236ef0['params']['id'])?_0x236ef0['params']['id']:!_['isNil'](_0x236ef0[_0x34ff('0x3a')]['id'])?_0x236ef0[_0x34ff('0x3a')]['id']:null;return db[_0x34ff('0x48')][_0x34ff('0x41')]({'where':{'id':_0x2b8955,'role':{'$or':[_0x34ff('0x38'),'user',_0x34ff('0x7a')]}},'attributes':['id',_0x34ff('0x43'),_0x34ff('0xe8'),_0x34ff('0xe9'),'role',_0x34ff('0x6b'),_0x34ff('0xad')]})[_0x34ff('0x35')](function(_0x57cdd6){if(_0x57cdd6){if(_0x57cdd6['role']===_0x34ff('0x7a')){_0x5ae568=_0x57cdd6;if(_0x236ef0[_0x34ff('0x66')][_0x34ff('0xaf')]){_0x1eff77=util[_0x34ff('0xbb')]('LOCAL/%s@from-sip/n',_0x5ae568[_0x236ef0[_0x34ff('0x66')][_0x34ff('0xaf')]]);}else if(_0x236ef0['body'][_0x34ff('0xea')]){_0x1eff77=util[_0x34ff('0xbb')](_0x34ff('0xeb'),_0x236ef0[_0x34ff('0x66')][_0x34ff('0xea')]);}else{_0x1eff77=util[_0x34ff('0xbb')](_0x34ff('0xeb'),_0x5ae568['name']);}socket['to'](util['format'](_0x34ff('0xec'),_0x5ae568[_0x34ff('0x43')]))[_0x34ff('0xb7')](_0x34ff('0xed'),{'user':{'id':_0x5ae568['id'],'name':_0x5ae568['name']},'ip':_0x236ef0[_0x34ff('0xee')][_0x34ff('0xef')]||_0x236ef0['connection'][_0x34ff('0xf0')]||_0x236ef0[_0x34ff('0xf1')]['remoteAddress']||_0x236ef0[_0x34ff('0xf2')][_0x34ff('0xf1')][_0x34ff('0xf0')]});return db[_0x34ff('0xbc')][_0x34ff('0x36')]({'where':{'membername':_0x5ae568[_0x34ff('0x43')]},'individualHooks':!![]});}}else{throw new db[(_0x34ff('0x9f'))][(_0x34ff('0xa0'))]('User\x20not\x20found\x20or\x20not\x20allowed\x20to\x20perform\x20login\x20method');}})[_0x34ff('0x35')](function(){if(_0x5ae568){return _0x5ae568['getVoiceQueues']({'raw':!![]});}})[_0x34ff('0x35')](function(_0x54d60c){if(_0x5ae568){var _0x5b8927=[];if(_0x54d60c){_0x433134=_0x54d60c;if(_0x433134['length']){for(var _0x412d83=0x0;_0x412d83<_0x433134[_0x34ff('0x53')];_0x412d83++){_0x5b8927[_0x34ff('0x95')]({'membername':_0x5ae568['name'],'UserId':_0x5ae568['id'],'queue_name':_0x433134[_0x412d83]['name'],'VoiceQueueId':_0x433134[_0x412d83]['id'],'interface':_0x1eff77,'paused':_0x5ae568[_0x34ff('0xad')]||![],'penalty':_0x433134[_0x412d83][_0x34ff('0xf3')]||0x0});}return BPromise[_0x34ff('0x96')](_0x5b8927,function(_0x4310ea){return db[_0x34ff('0xbc')][_0x34ff('0xbd')](_0x4310ea);});}}}})[_0x34ff('0x35')](function(){if(_0x5ae568){return db[_0x34ff('0xf4')][_0x34ff('0x62')]({'where':{'membername':_0x5ae568[_0x34ff('0x43')],'exitAt':null}});}})[_0x34ff('0x35')](function(_0x150193){if(_0x5ae568){var _0x2ba416=[];_0x150193['forEach'](function(_0x37c228){_0x2ba416[_0x34ff('0x95')](_0x37c228[_0x34ff('0x34')]({'exitAt':moment()[_0x34ff('0xbb')](_0x34ff('0xf5'))}));});return BPromise[_0x34ff('0x94')](_0x2ba416);}})[_0x34ff('0x35')](function(){if(_0x5ae568){var _0x589938=[];var _0x453287=[];var _0x46c2ed=utils[_0x34ff('0xf6')]();var _0x5d3af6={'membername':_0x5ae568[_0x34ff('0x43')],'interface':_0x1eff77,'enterAt':moment()[_0x34ff('0xbb')]('YYYY-MM-DD\x20HH:mm:ss'),'role':_0x5ae568['role'],'internal':_0x5ae568['internal']};_0x46c2ed['forEach'](function(_0x3e2ab5){_0x589938['push'](_[_0x34ff('0x5b')]({'channel':_0x3e2ab5,'type':_0x34ff('0xf7'),'data1':_0x236ef0[_0x34ff('0x66')][_0x34ff('0xf8')],'data2':_0x1eff77},_0x5d3af6));if(_0x5ae568[_0x34ff('0xad')]){_0x453287[_0x34ff('0x95')](_[_0x34ff('0x5b')]({'channel':_0x3e2ab5,'type':_0x34ff('0xf9'),'data1':_0x34ff('0xfa')},_0x5d3af6));}});return db[_0x34ff('0xf4')][_0x34ff('0x91')](_0x589938[_0x34ff('0xfb')](_0x453287),{'individualHooks':!![]});}})[_0x34ff('0x35')](function(){if(_0x5ae568){return _0x5ae568['update']({'online':!![],'lastLoginAt':moment()[_0x34ff('0xbb')](_0x34ff('0xf5')),'voicePause':_0x5ae568['loginInPause']||![],'mailPause':_0x5ae568[_0x34ff('0xad')]||![],'chatPause':_0x5ae568[_0x34ff('0xad')]||![],'faxPause':_0x5ae568['loginInPause']||![],'smsPause':_0x5ae568[_0x34ff('0xad')]||![],'openchannelPause':_0x5ae568[_0x34ff('0xad')]||![],'whatsappPause':_0x5ae568[_0x34ff('0xad')]||![],'pauseType':_0x5ae568[_0x34ff('0xad')]?_0x34ff('0xfa'):null,'interface':_0x1eff77,'lastPauseAt':moment()['format'](_0x34ff('0xf5'))});}})['then'](function(_0x55f1e9){if(_0x236ef0['isMiddleware']){return _0xee6ab4();}else{return BPromise[_0x34ff('0xfc')](_0x55f1e9)['then'](respondWithResult(_0x34fc4b,null));}})['catch'](handleError(_0x34fc4b,null));};exports['logout']=function(_0x30a12b,_0x4e76d3,_0x39fa41){var _0xc490f2;return db[_0x34ff('0x48')]['find']({'where':{'id':_0x30a12b[_0x34ff('0x67')]['id'],'role':_0x34ff('0x7a')},'attributes':['id','name',_0x34ff('0x42')]})[_0x34ff('0x35')](handleEntityNotFound(_0x4e76d3,null))[_0x34ff('0x35')](function(_0x1584e9){if(_0x1584e9){_0xc490f2=_0x1584e9;return db[_0x34ff('0xbc')]['destroy']({'where':{'membername':_0xc490f2[_0x34ff('0x43')]},'individualHooks':!![]});}})['then'](function(){return db[_0x34ff('0xf4')][_0x34ff('0x62')]({'where':{'membername':_0xc490f2[_0x34ff('0x43')],'exitAt':null}});})[_0x34ff('0x35')](function(_0x1d5f17){var _0x300200=[];_0x1d5f17[_0x34ff('0xfd')](function(_0xb84122){_0x300200[_0x34ff('0x95')](_0xb84122[_0x34ff('0x34')]({'exitAt':moment()[_0x34ff('0xbb')]('YYYY-MM-DD\x20HH:mm:ss')}));});return BPromise[_0x34ff('0x94')](_0x300200);})['then'](function(){return _0xc490f2[_0x34ff('0x34')]({'online':![],'lastLoginAt':null,'voicePause':![],'mailPause':![],'chatPause':![],'faxPause':![],'smsPause':![],'openchannelPause':![],'whatsappPause':![],'interface':null});})['then'](respondWithResult(_0x4e76d3,null))[_0x34ff('0x28')](handleError(_0x4e76d3,null));};exports[_0x34ff('0xfe')]=function(_0x1276f2,_0x133122,_0x672b0f){var _0xc5cf1b;return db[_0x34ff('0xbc')]['update']({'paused':0x1},{'where':{'UserId':_0x1276f2[_0x34ff('0x67')]['id']},'individualHooks':!![]})[_0x34ff('0x35')](function(){return db['User'][_0x34ff('0x41')]({'where':{'id':_0x1276f2[_0x34ff('0x67')]['id'],'role':_0x34ff('0x7a')},'attributes':['id',_0x34ff('0x43'),_0x34ff('0x42'),_0x34ff('0x6b'),'interface']});})[_0x34ff('0x35')](handleEntityNotFound(_0x133122,null))[_0x34ff('0x35')](function(_0x249217){if(_0x249217){_0xc5cf1b=_0x249217;return respondWithRpcPromise('QueuePause','pause',{'id':_0xc5cf1b['id'],'name':_0xc5cf1b[_0x34ff('0x43')],'pause':!![]});}})[_0x34ff('0x35')](function(){if(_0xc5cf1b){return db[_0x34ff('0xf4')][_0x34ff('0x62')]({'where':{'membername':_0xc5cf1b[_0x34ff('0x43')],'type':_0x34ff('0xf9'),'exitAt':null}});}})[_0x34ff('0x35')](function(_0x475762){if(_0x475762[_0x34ff('0x53')]){var _0x238b57=moment()['format']('YYYY-MM-DD\x20HH:mm:ss');for(var _0x19b507=0x0,_0x234afe=_0x475762['length'];_0x19b507<_0x234afe;_0x19b507++){_0x475762[_0x19b507]['updateAttributes']({'exitAt':_0x238b57});}}})[_0x34ff('0x35')](function(){var _0x7a5624=[];var _0x54800c=utils[_0x34ff('0xf6')]();_0x54800c[_0x34ff('0xfd')](function(_0x13a08f){_0x7a5624['push']({'channel':_0x13a08f,'membername':_0xc5cf1b[_0x34ff('0x43')],'interface':_[_0x34ff('0x70')](_0xc5cf1b['interface'])?util[_0x34ff('0xbb')]('SIP/%s',_0xc5cf1b[_0x34ff('0x43')]):_0xc5cf1b[_0x34ff('0xaf')],'type':_0x34ff('0xf9'),'enterAt':moment()[_0x34ff('0xbb')](_0x34ff('0xf5')),'data1':_0x1276f2[_0x34ff('0x66')][_0x34ff('0x4b')]||'DEFAULT\x20PAUSE','role':_0xc5cf1b[_0x34ff('0x42')],'internal':_0xc5cf1b[_0x34ff('0x6b')]});});return db[_0x34ff('0xf4')][_0x34ff('0x91')](_0x7a5624,{'individualHooks':!![]});})[_0x34ff('0x35')](function(){return _0xc5cf1b[_0x34ff('0x34')]({'voicePause':!![],'mailPause':!![],'chatPause':!![],'faxPause':!![],'smsPause':!![],'whatsappPause':!![],'openchannelPause':!![],'pauseType':_0x1276f2[_0x34ff('0x66')]['type']||_0x34ff('0xff'),'lastPauseAt':moment()['format'](_0x34ff('0xf5'))});})[_0x34ff('0x35')](respondWithResult(_0x133122,null))['catch'](handleError(_0x133122,null));};exports[_0x34ff('0x100')]=function(_0xb01827,_0x140b0c,_0x22eca4){var _0x2dff30;return db['User'][_0x34ff('0x41')]({'where':{'id':_0xb01827['params']['id']},'attributes':['id',_0x34ff('0x43'),_0x34ff('0x42'),_0x34ff('0xae'),_0x34ff('0x101'),_0x34ff('0x102'),'faxPause',_0x34ff('0x103'),'smsPause',_0x34ff('0x104'),_0x34ff('0x105'),_0x34ff('0x106')]})[_0x34ff('0x35')](handleEntityNotFound(_0x140b0c,null))[_0x34ff('0x35')](function(_0x17d73c){if(_0x17d73c){_0x2dff30=_0x17d73c;if(_0xb01827[_0x34ff('0x66')][_0x34ff('0xab')]&&!utils[_0x34ff('0xb0')](_0xb01827[_0x34ff('0x66')]['channel'])){throw new db[(_0x34ff('0x9f'))][(_0x34ff('0xa0'))]('Unknown\x20channel');}switch(_0xb01827[_0x34ff('0x66')][_0x34ff('0xab')]){case _0x34ff('0xb9'):return respondWithRpcPromise(_0x34ff('0x107'),'unpause',{'id':_0x2dff30['id'],'name':_0x2dff30[_0x34ff('0x43')],'pause':![]})[_0x34ff('0x35')](function(){return db[_0x34ff('0xbc')][_0x34ff('0x34')]({'paused':0x0},{'where':{'UserId':_0x2dff30['id']},'individualHooks':!![]});})[_0x34ff('0x35')](function(){return db['MemberReport'][_0x34ff('0x41')]({'where':{'channel':_0xb01827['body'][_0x34ff('0xab')],'membername':_0x2dff30[_0x34ff('0x43')],'type':_0x34ff('0xf9'),'exitAt':null}});})['then'](function(_0x9c8283){if(_0x9c8283){return _0x9c8283[_0x34ff('0x34')]({'exitAt':moment()[_0x34ff('0xbb')](_0x34ff('0xf5')),'data2':_0x34ff('0x108')},{'individualHooks':!![]});}return null;})['then'](function(){return _0x2dff30[_0x34ff('0x34')]({'voicePause':![]});});case _0x34ff('0x109'):case _0x34ff('0x10a'):case _0x34ff('0x10b'):case _0x34ff('0x10c'):case _0x34ff('0x10d'):case _0x34ff('0x10e'):return db['MemberReport'][_0x34ff('0x41')]({'where':{'channel':_0xb01827[_0x34ff('0x66')][_0x34ff('0xab')],'membername':_0x2dff30[_0x34ff('0x43')],'type':_0x34ff('0xf9'),'exitAt':null}})[_0x34ff('0x35')](function(_0x2b66a3){if(_0x2b66a3){return _0x2b66a3['update']({'exitAt':moment()[_0x34ff('0xbb')](_0x34ff('0xf5')),'data2':'manual'},{'individualHooks':!![]});}return null;})[_0x34ff('0x35')](function(){var _0x274758={};_[_0x34ff('0x2f')](_0x274758,util['format'](_0x34ff('0x10f'),_0xb01827[_0x34ff('0x66')][_0x34ff('0xab')],'Pause'),![]);return _0x2dff30[_0x34ff('0x34')](_0x274758);});default:return respondWithRpcPromise('QueuePause','unpause',{'id':_0x2dff30['id'],'name':_0x2dff30[_0x34ff('0x43')],'pause':![]})['then'](function(){return db[_0x34ff('0xbc')][_0x34ff('0x34')]({'paused':0x0},{'where':{'UserId':_0x2dff30['id']}});})['then'](function(){return db['MemberReport']['findAll']({'where':{'membername':_0x2dff30[_0x34ff('0x43')],'type':_0x34ff('0xf9'),'exitAt':null}});})['then'](function(_0x201625){var _0x57f2e0=[];_0x201625[_0x34ff('0xfd')](function(_0x432a40){_0x57f2e0[_0x34ff('0x95')](_0x432a40[_0x34ff('0x34')]({'exitAt':moment()[_0x34ff('0xbb')](_0x34ff('0xf5')),'data2':_0x34ff('0x108')}));});return BPromise['all'](_0x57f2e0);})['then'](function(){return _0x2dff30['update']({'voicePause':![],'mailPause':![],'chatPause':![],'faxPause':![],'smsPause':![],'whatsappPause':![],'openchannelPause':![]});});}}})[_0x34ff('0x35')](respondWithResult(_0x140b0c,null))[_0x34ff('0x28')](handleError(_0x140b0c,null));};exports[_0x34ff('0x110')]=function(_0x50ba34,_0x2bc848,_0x5ecdc8){var _0x30c2cd={};var _0x1b8517={};var _0x3758e0;var _0x2cadfb;return db[_0x34ff('0x48')][_0x34ff('0xcd')]({'where':{'id':_0x50ba34['params']['id']}})[_0x34ff('0x35')](handleEntityNotFound(_0x2bc848,null))[_0x34ff('0x35')](function(_0x267d53){if(_0x267d53){_0x3758e0=_0x267d53;_0x1b8517[_0x34ff('0x4c')]=_[_0x34ff('0x4f')](db['Team'][_0x34ff('0x49')]);_0x1b8517[_0x34ff('0x4e')]=_[_0x34ff('0x4f')](_0x50ba34['query']);_0x1b8517[_0x34ff('0x59')]=_[_0x34ff('0x50')](_0x1b8517[_0x34ff('0x4c')],_0x1b8517[_0x34ff('0x4e')]);_0x30c2cd[_0x34ff('0x51')]=_[_0x34ff('0x50')](_0x1b8517['model'],qs[_0x34ff('0x52')](_0x50ba34['query']['fields']));_0x30c2cd[_0x34ff('0x51')]=_0x30c2cd[_0x34ff('0x51')][_0x34ff('0x53')]?_0x30c2cd[_0x34ff('0x51')]:_0x1b8517[_0x34ff('0x4c')];_0x30c2cd[_0x34ff('0x56')]=qs[_0x34ff('0x57')](_0x50ba34[_0x34ff('0x4e')][_0x34ff('0x57')]);_0x30c2cd[_0x34ff('0x58')]=qs['filters'](_['pick'](_0x50ba34[_0x34ff('0x4e')],_0x1b8517['filters']));if(_0x50ba34[_0x34ff('0x4e')][_0x34ff('0x3d')]){_0x30c2cd[_0x34ff('0x58')]=_['merge'](_0x30c2cd[_0x34ff('0x58')],{'$or':_['map'](_0x30c2cd['attributes'],function(_0x2ab659){var _0x487bab={};_0x487bab[_0x2ab659]={'$like':'%'+_0x50ba34[_0x34ff('0x4e')]['filter']+'%'};return _0x487bab;})});}_0x30c2cd=_[_0x34ff('0x5b')]({},_0x30c2cd,_0x50ba34[_0x34ff('0x5f')]);return _0x3758e0['getTeams'](_0x30c2cd);}})[_0x34ff('0x35')](function(_0x61bcaf){if(_0x61bcaf){_0x2cadfb=_0x61bcaf['length'];if(!_0x50ba34[_0x34ff('0x4e')][_0x34ff('0x54')](_0x34ff('0x55'))){_0x30c2cd[_0x34ff('0x2e')]=qs['limit'](_0x50ba34[_0x34ff('0x4e')][_0x34ff('0x2e')]);_0x30c2cd[_0x34ff('0x2d')]=qs[_0x34ff('0x2d')](_0x50ba34[_0x34ff('0x4e')][_0x34ff('0x2d')]);}return _0x3758e0[_0x34ff('0x110')](_0x30c2cd);}})[_0x34ff('0x35')](function(_0x22fc3a){if(_0x22fc3a){return _0x22fc3a?{'count':_0x2cadfb,'rows':_0x22fc3a}:null;}})[_0x34ff('0x35')](respondWithResult(_0x2bc848,null))[_0x34ff('0x28')](handleError(_0x2bc848,null));};exports[_0x34ff('0x111')]=function(_0x406518,_0x5ce8d8){return db[_0x34ff('0x48')][_0x34ff('0x41')]({'where':{'id':_0x406518[_0x34ff('0x67')]['id']}})[_0x34ff('0x35')](handleEntityNotFound(_0x5ce8d8,null))[_0x34ff('0x35')](function(_0xc7db96){if(_0xc7db96){var _0x57f789=_0xc7db96['get']({'plain':!![]});return _0xc7db96['addTeams'](_0x406518['body'][_0x34ff('0x69')],_['omit'](_0x406518[_0x34ff('0x66')],[_0x34ff('0x69'),'id'])||{})[_0x34ff('0x35')](function(){for(var _0x33ef6d=0x0;_0x33ef6d<_0x406518[_0x34ff('0x66')][_0x34ff('0x69')][_0x34ff('0x53')];_0x33ef6d++){var _0x45e527=[];db[_0x34ff('0x112')][_0x34ff('0xcd')]({'where':{'id':_0x406518[_0x34ff('0x66')]['ids'][_0x33ef6d]}})[_0x34ff('0x35')](function(_0xd53943){_0x45e527[_0x34ff('0x95')](_0xd53943[_0x34ff('0x113')]()[_0x34ff('0x35')](function(_0x1a4dee){for(var _0x5e1408=0x0;_0x5e1408<_0x1a4dee[_0x34ff('0x53')];_0x5e1408++){_0x1a4dee[_0x5e1408][_0x34ff('0x114')](_0x34ff('0xab'),_0x34ff('0x115'));}return _0x1a4dee;}));_0x45e527[_0x34ff('0x95')](_0xd53943[_0x34ff('0x116')]()['then'](function(_0xd084ab){for(var _0x2c731a=0x0;_0x2c731a<_0xd084ab[_0x34ff('0x53')];_0x2c731a++){_0xd084ab[_0x2c731a]['setDataValue']('channel',_0x34ff('0x117'));}return _0xd084ab;}));_0x45e527['push'](_0xd53943[_0x34ff('0x118')]()[_0x34ff('0x35')](function(_0x26bc2f){for(var _0x4412f6=0x0;_0x4412f6<_0x26bc2f[_0x34ff('0x53')];_0x4412f6++){_0x26bc2f[_0x4412f6][_0x34ff('0x114')](_0x34ff('0xab'),_0x34ff('0x119'));}return _0x26bc2f;}));_0x45e527[_0x34ff('0x95')](_0xd53943['getSmsQueues']()[_0x34ff('0x35')](function(_0x3f0951){for(var _0x140a01=0x0;_0x140a01<_0x3f0951[_0x34ff('0x53')];_0x140a01++){_0x3f0951[_0x140a01]['setDataValue']('channel','Sms');}return _0x3f0951;}));_0x45e527[_0x34ff('0x95')](_0xd53943['getWhatsappQueues']()[_0x34ff('0x35')](function(_0x536839){for(var _0x31dc59=0x0;_0x31dc59<_0x536839['length'];_0x31dc59++){_0x536839[_0x31dc59][_0x34ff('0x114')](_0x34ff('0xab'),_0x34ff('0x11a'));}return _0x536839;}));_0x45e527['push'](_0xd53943[_0x34ff('0x11b')]()[_0x34ff('0x35')](function(_0x56a5e0){for(var _0x4dfb8a=0x0;_0x4dfb8a<_0x56a5e0[_0x34ff('0x53')];_0x4dfb8a++){_0x56a5e0[_0x4dfb8a][_0x34ff('0x114')]('channel','Fax');}return _0x56a5e0;}));_0x45e527[_0x34ff('0x95')](_0xd53943[_0x34ff('0x11c')]()[_0x34ff('0x35')](function(_0x41bf39){for(var _0x4dd06f=0x0;_0x4dd06f<_0x41bf39[_0x34ff('0x53')];_0x4dd06f++){_0x41bf39[_0x4dd06f]['setDataValue']('channel',_0x34ff('0x11d'));}return _0x41bf39;}));return BPromise[_0x34ff('0x94')](_0x45e527);})[_0x34ff('0x35')](function(_0x435821){var _0xb43183=_[_0x34ff('0x11e')](_0x435821);_0x45e527=[];return db['sequelize'][_0x34ff('0x11f')](function(_0x59a51a){for(var _0x5edfdc=0x0;_0x5edfdc<_0xb43183[_0x34ff('0x53')];_0x5edfdc++){_0x45e527[_0x34ff('0x95')](_0xb43183[_0x5edfdc][_0x34ff('0x120')](_0x57f789['id']),{'transaction':_0x59a51a});}return BPromise[_0x34ff('0x94')](_0x45e527)['then'](function(){if(_0x57f789[_0x34ff('0xac')]){return BPromise[_0x34ff('0x96')](_[_0x34ff('0x3d')](_0xb43183,function(_0x27a15b){return _0x27a15b[_0x34ff('0x121')]('channel')===_0x34ff('0x115');}),function(_0x30b947){return db['UserVoiceQueueRt'][_0x34ff('0xbd')]({'membername':_0x57f789['name'],'UserId':_0x57f789['id'],'queue_name':_0x30b947[_0x34ff('0x43')],'VoiceQueueId':_0x30b947['id'],'interface':_[_0x34ff('0x70')](_0x57f789[_0x34ff('0xaf')])?util['format'](_0x34ff('0xeb'),_0x57f789['name']):_0x57f789[_0x34ff('0xaf')],'paused':_0x57f789[_0x34ff('0xae')]||![],'penalty':_0x57f789['penalty']},{'transaction':_0x59a51a});});}else{return;}})[_0x34ff('0x35')](function(){for(var _0x51b2ca=0x0;_0x51b2ca<_0xb43183['length'];_0x51b2ca++){var _0x138515=_0xb43183[_0x51b2ca]['getDataValue'](_0x34ff('0xab'));var _0x1bfe47=_0x138515+_0x34ff('0xc1');socket['emit'](_0x34ff('0x3a')+_0x138515+'Queue:save',{'UserId':_0x57f789['id'],['queueField']:_0xb43183[_0x51b2ca]['id']});}});});});}});}})[_0x34ff('0x35')](respondWithStatusCode(_0x5ce8d8,null))[_0x34ff('0x28')](handleError(_0x5ce8d8,null));};exports['removeTeams']=function(_0x36efbc,_0x1cbe99){return db[_0x34ff('0x48')][_0x34ff('0xcd')]({'where':{'id':_0x36efbc[_0x34ff('0x67')]['id']}})['then'](handleEntityNotFound(_0x1cbe99,null))[_0x34ff('0x35')](function(_0x1c33b1){if(_0x1c33b1){var _0x1fbdba=_0x1c33b1[_0x34ff('0x37')]({'plain':!![]});var _0x5805ac=_0x36efbc[_0x34ff('0x4e')]['ids'];return _0x1c33b1[_0x34ff('0x122')](_0x5805ac)[_0x34ff('0x35')](function(){for(var _0x1729c5=0x0;_0x1729c5<_0x5805ac[_0x34ff('0x53')];_0x1729c5++){var _0x5e2fb6=[];db[_0x34ff('0x112')][_0x34ff('0xcd')]({'where':{'id':_0x5805ac[_0x1729c5]}})['then'](function(_0x55ccc5){_0x5e2fb6[_0x34ff('0x95')](_0x55ccc5[_0x34ff('0x113')]()['then'](function(_0x4577b0){for(var _0x32baa3=0x0;_0x32baa3<_0x4577b0[_0x34ff('0x53')];_0x32baa3++){_0x4577b0[_0x32baa3][_0x34ff('0x114')](_0x34ff('0xab'),_0x34ff('0x115'));}return _0x4577b0;}));_0x5e2fb6[_0x34ff('0x95')](_0x55ccc5[_0x34ff('0x116')]()[_0x34ff('0x35')](function(_0x4c2143){for(var _0x76636f=0x0;_0x76636f<_0x4c2143[_0x34ff('0x53')];_0x76636f++){_0x4c2143[_0x76636f][_0x34ff('0x114')](_0x34ff('0xab'),_0x34ff('0x117'));}return _0x4c2143;}));_0x5e2fb6[_0x34ff('0x95')](_0x55ccc5[_0x34ff('0x118')]()[_0x34ff('0x35')](function(_0x20ed0a){for(var _0x6e718b=0x0;_0x6e718b<_0x20ed0a['length'];_0x6e718b++){_0x20ed0a[_0x6e718b]['setDataValue'](_0x34ff('0xab'),_0x34ff('0x119'));}return _0x20ed0a;}));_0x5e2fb6[_0x34ff('0x95')](_0x55ccc5[_0x34ff('0x123')]()[_0x34ff('0x35')](function(_0x1051bf){for(var _0x3288b9=0x0;_0x3288b9<_0x1051bf[_0x34ff('0x53')];_0x3288b9++){_0x1051bf[_0x3288b9][_0x34ff('0x114')](_0x34ff('0xab'),'Sms');}return _0x1051bf;}));_0x5e2fb6[_0x34ff('0x95')](_0x55ccc5[_0x34ff('0x124')]()[_0x34ff('0x35')](function(_0x17faef){for(var _0x3281d0=0x0;_0x3281d0<_0x17faef['length'];_0x3281d0++){_0x17faef[_0x3281d0][_0x34ff('0x114')]('channel',_0x34ff('0x11a'));}return _0x17faef;}));_0x5e2fb6[_0x34ff('0x95')](_0x55ccc5[_0x34ff('0x11b')]()[_0x34ff('0x35')](function(_0xf1ccff){for(var _0x33be08=0x0;_0x33be08<_0xf1ccff[_0x34ff('0x53')];_0x33be08++){_0xf1ccff[_0x33be08][_0x34ff('0x114')](_0x34ff('0xab'),_0x34ff('0x125'));}return _0xf1ccff;}));_0x5e2fb6[_0x34ff('0x95')](_0x55ccc5['getOpenchannelQueues']()['then'](function(_0x4776b5){for(var _0x539c83=0x0;_0x539c83<_0x4776b5['length'];_0x539c83++){_0x4776b5[_0x539c83][_0x34ff('0x114')](_0x34ff('0xab'),_0x34ff('0x11d'));}return _0x4776b5;}));return BPromise['all'](_0x5e2fb6);})[_0x34ff('0x35')](function(_0x22e645){var _0x25f34c=_[_0x34ff('0x11e')](_0x22e645);_0x5e2fb6=[];return db[_0x34ff('0x5c')]['transaction'](function(_0x28f0dd){for(var _0x179746=0x0;_0x179746<_0x25f34c[_0x34ff('0x53')];_0x179746++){_0x5e2fb6[_0x34ff('0x95')](_0x25f34c[_0x179746][_0x34ff('0x126')](_0x1fbdba['id']),{'transaction':_0x28f0dd});}return BPromise[_0x34ff('0x94')](_0x5e2fb6)[_0x34ff('0x35')](function(){if(_0x1fbdba[_0x34ff('0xac')]){return BPromise['each'](_[_0x34ff('0x3d')](_0x25f34c,function(_0x56aec8){return _0x56aec8[_0x34ff('0x121')]('channel')==='Voice';}),function(_0x3cf827){return db[_0x34ff('0xbc')][_0x34ff('0x36')]({'where':{'VoiceQueueId':_0x3cf827['id'],'UserId':_0x1fbdba['id']},'transaction':_0x28f0dd});});}else{return;}})['then'](function(){for(var _0x3084e0=0x0;_0x3084e0<_0x25f34c[_0x34ff('0x53')];_0x3084e0++){var _0x174fe0=_0x25f34c[_0x3084e0][_0x34ff('0x121')](_0x34ff('0xab'));var _0x3ba446=_0x174fe0+'QueueId';socket['emit'](_0x34ff('0x3a')+_0x174fe0+'Queue:remove',{'UserId':_0x1fbdba['id'],['queueField']:_0x25f34c[_0x3084e0]['id']});}});});});}});}})['then'](respondWithStatusCode(_0x1cbe99,null))[_0x34ff('0x28')](handleError(_0x1cbe99,null));};exports[_0x34ff('0x127')]=function(_0x5fb111,_0x4311dc,_0x6d8a86){var _0x49c564={};var _0x39f705={};var _0x588874;var _0xee094f;return db[_0x34ff('0x48')]['findOne']({'where':{'id':_0x5fb111[_0x34ff('0x67')]['id']}})[_0x34ff('0x35')](handleEntityNotFound(_0x4311dc,null))[_0x34ff('0x35')](function(_0x51e413){if(_0x51e413){_0x588874=_0x51e413;_0x39f705[_0x34ff('0x4c')]=_['keys'](db[_0x34ff('0x128')]['rawAttributes']);_0x39f705['query']=_[_0x34ff('0x4f')](_0x5fb111[_0x34ff('0x4e')]);_0x39f705[_0x34ff('0x59')]=_[_0x34ff('0x50')](_0x39f705['model'],_0x39f705[_0x34ff('0x4e')]);_0x49c564['attributes']=_['intersection'](_0x39f705['model'],qs[_0x34ff('0x52')](_0x5fb111[_0x34ff('0x4e')][_0x34ff('0x52')]));_0x49c564[_0x34ff('0x51')]=_0x49c564[_0x34ff('0x51')][_0x34ff('0x53')]?_0x49c564[_0x34ff('0x51')]:_0x39f705['model'];_0x49c564[_0x34ff('0x56')]=qs['sort'](_0x5fb111[_0x34ff('0x4e')][_0x34ff('0x57')]);_0x49c564[_0x34ff('0x58')]=qs[_0x34ff('0x59')](_[_0x34ff('0x5a')](_0x5fb111[_0x34ff('0x4e')],_0x39f705[_0x34ff('0x59')]));if(_0x5fb111[_0x34ff('0x4e')][_0x34ff('0x3d')]){_0x49c564[_0x34ff('0x58')]=_[_0x34ff('0x5b')](_0x49c564[_0x34ff('0x58')],{'$or':_['map'](_0x49c564[_0x34ff('0x51')],function(_0x4e34ca){var _0x2ddef1={};_0x2ddef1[_0x4e34ca]={'$like':'%'+_0x5fb111['query'][_0x34ff('0x3d')]+'%'};return _0x2ddef1;})});}_0x49c564=_[_0x34ff('0x5b')]({},_0x49c564,_0x5fb111[_0x34ff('0x5f')]);return _0x588874[_0x34ff('0x127')](_0x49c564);}})[_0x34ff('0x35')](function(_0x36af8f){if(_0x36af8f){_0xee094f=_0x36af8f[_0x34ff('0x53')];if(!_0x5fb111[_0x34ff('0x4e')][_0x34ff('0x54')]('nolimit')){_0x49c564[_0x34ff('0x2e')]=qs[_0x34ff('0x2e')](_0x5fb111['query'][_0x34ff('0x2e')]);_0x49c564[_0x34ff('0x2d')]=qs[_0x34ff('0x2d')](_0x5fb111['query'][_0x34ff('0x2d')]);}return _0x588874[_0x34ff('0x127')](_0x49c564);}})[_0x34ff('0x35')](function(_0x19b07d){if(_0x19b07d){return _0x19b07d?{'count':_0xee094f,'rows':_0x19b07d}:null;}})[_0x34ff('0x35')](respondWithResult(_0x4311dc,null))[_0x34ff('0x28')](handleError(_0x4311dc,null));};exports['getAgents']=function(_0x317617,_0x14a558,_0xac90b1){var _0x360725={};var _0x25a11c={};var _0x1b11d7;var _0x3d6eb8;return db[_0x34ff('0x48')]['findOne']({'where':{'id':_0x317617['params']['id']}})[_0x34ff('0x35')](handleEntityNotFound(_0x14a558,null))['then'](function(_0x461221){if(_0x461221){_0x1b11d7=_0x461221;_0x25a11c['model']=_[_0x34ff('0x4f')](db['User']['rawAttributes']);_0x25a11c[_0x34ff('0x4e')]=_[_0x34ff('0x4f')](_0x317617[_0x34ff('0x4e')]);_0x25a11c[_0x34ff('0x59')]=_[_0x34ff('0x50')](_0x25a11c['model'],_0x25a11c[_0x34ff('0x4e')]);_0x360725['attributes']=_[_0x34ff('0x50')](_0x25a11c[_0x34ff('0x4c')],qs['fields'](_0x317617[_0x34ff('0x4e')][_0x34ff('0x52')]));_0x360725[_0x34ff('0x51')]=_0x360725['attributes'][_0x34ff('0x53')]?_0x360725[_0x34ff('0x51')]:_0x25a11c['model'];_0x360725[_0x34ff('0x56')]=qs[_0x34ff('0x57')](_0x317617[_0x34ff('0x4e')]['sort']);_0x360725['where']=qs[_0x34ff('0x59')](_[_0x34ff('0x5a')](_0x317617['query'],_0x25a11c[_0x34ff('0x59')]));if(_0x317617[_0x34ff('0x4e')][_0x34ff('0x3d')]){_0x360725['where']=_[_0x34ff('0x5b')](_0x360725[_0x34ff('0x58')],{'$or':_['map'](_0x360725['attributes'],function(_0x805435){var _0x11e692={};_0x11e692[_0x805435]={'$like':'%'+_0x317617[_0x34ff('0x4e')][_0x34ff('0x3d')]+'%'};return _0x11e692;})});}_0x360725[_0x34ff('0x4c')]=db[_0x34ff('0x48')];_0x360725['as']='Agents';_0x360725=_[_0x34ff('0x5b')]({},_0x360725,_0x317617[_0x34ff('0x5f')]);return _0x1b11d7[_0x34ff('0x113')]({'include':[_0x360725]});}})['then'](function(_0xf7174d){if(_0xf7174d){var _0x1d0b81={},_0xfbaaf4=[],_0xb7e83c=0x0;for(var _0x13b1ed=0x0;_0x13b1ed<_0xf7174d[_0x34ff('0x53')];_0x13b1ed+=0x1){for(var _0x503fa2=0x0,_0x1e7fad;_0x503fa2<_0xf7174d[_0x13b1ed][_0x34ff('0x3b')][_0x34ff('0x53')];_0x503fa2+=0x1){_0x1e7fad=_0xf7174d[_0x13b1ed]['Agents'][_0x503fa2][_0x34ff('0x37')]({'plain':!![]});_0x1d0b81[_0x1e7fad['id']]=_0x1e7fad;}}_0x1d0b81=_[_0x34ff('0x129')](_0x1d0b81);for(var _0x5342a2=qs[_0x34ff('0x2d')](_0x317617[_0x34ff('0x4e')][_0x34ff('0x2d')]);_0x5342a2<_0x1d0b81['length']&&_0xfbaaf4[_0x34ff('0x53')]<qs['limit'](_0x317617[_0x34ff('0x4e')][_0x34ff('0x2e')]);_0x5342a2+=0x1){if(_0x1d0b81[_0x5342a2]){_0xfbaaf4[_0x34ff('0x95')](_0x1d0b81[_0x5342a2]);}}return{'count':_0x1d0b81[_0x34ff('0x53')],'rows':_0xfbaaf4};}})[_0x34ff('0x35')](respondWithResult(_0x14a558,null))[_0x34ff('0x28')](handleError(_0x14a558,null));};exports['destroy']=function(_0x373590,_0x2d979c){if(_0x373590[_0x34ff('0x3a')]['id']==_0x373590[_0x34ff('0x67')]['id']){return _0x2d979c[_0x34ff('0x2a')](0x1f4)['send']({'message':_0x34ff('0x12a')});}return db[_0x34ff('0x48')][_0x34ff('0x41')]({'where':{'id':_0x373590[_0x34ff('0x67')]['id']}})[_0x34ff('0x35')](handleEntityNotFound(_0x2d979c,null))[_0x34ff('0x35')](removeEntity(_0x2d979c,null))[_0x34ff('0x28')](handleError(_0x2d979c,null));};exports[_0x34ff('0x12b')]=function(_0x5b7317,_0x4d5204,_0x13aec1){return db['User']['find']({'where':{'id':_0x5b7317[_0x34ff('0x67')]['id']}})[_0x34ff('0x35')](handleEntityNotFound(_0x4d5204,null))[_0x34ff('0x35')](function(_0x53c99d){if(_0x53c99d){return _0x53c99d['addChatInteractions'](_0x5b7317['body'][_0x34ff('0x69')],_[_0x34ff('0x6a')](_0x5b7317[_0x34ff('0x66')],[_0x34ff('0x69'),'id'])||{})[_0x34ff('0xb6')](function(){for(var _0x14665a=0x0;_0x14665a<_0x5b7317['body'][_0x34ff('0x69')]['length'];_0x14665a+=0x1){socket[_0x34ff('0xb7')](_0x34ff('0x12c'),{'ChatInteractionId':Number(_0x5b7317['body'][_0x34ff('0x69')][_0x14665a]),'UserId':Number(_0x5b7317[_0x34ff('0x67')]['id'])});}return _0x5b7317[_0x34ff('0x66')][_0x34ff('0x69')];});}})['then'](respondWithResult(_0x4d5204,null))[_0x34ff('0x28')](handleError(_0x4d5204,null));};exports['removeChatInteractions']=function(_0x402439,_0x4ee21f,_0x4ed1a1){return db[_0x34ff('0x48')][_0x34ff('0x41')]({'where':{'id':_0x402439[_0x34ff('0x67')]['id']}})[_0x34ff('0x35')](handleEntityNotFound(_0x4ee21f,null))['then'](function(_0x4f669a){if(_0x4f669a){return _0x4f669a['removeChatInteractions'](_0x402439[_0x34ff('0x4e')][_0x34ff('0x69')])['then'](function(){if(_[_0x34ff('0x12d')](_0x402439[_0x34ff('0x4e')]['ids'])){for(var _0x33c676=0x0;_0x33c676<_0x402439[_0x34ff('0x4e')]['ids'][_0x34ff('0x53')];_0x33c676+=0x1){socket[_0x34ff('0xb7')]('user_has_chat_interactions:remove',{'ChatInteractionId':Number(_0x402439[_0x34ff('0x4e')][_0x34ff('0x69')][_0x33c676]),'UserId':Number(_0x402439[_0x34ff('0x67')]['id'])});}}else{socket['emit'](_0x34ff('0x12e'),{'ChatInteractionId':Number(_0x402439[_0x34ff('0x4e')][_0x34ff('0x69')]),'UserId':Number(_0x402439['params']['id'])});}});}})[_0x34ff('0x35')](respondWithStatusCode(_0x4ee21f,null))[_0x34ff('0x28')](handleError(_0x4ee21f,null));};exports[_0x34ff('0x12f')]=function(_0x268234,_0xeb7668,_0x3b70ba){return db[_0x34ff('0x48')][_0x34ff('0x41')]({'where':{'id':_0x268234[_0x34ff('0x67')]['id']}})[_0x34ff('0x35')](handleEntityNotFound(_0xeb7668,null))[_0x34ff('0x35')](function(_0x36d183){if(_0x36d183){return _0x36d183[_0x34ff('0x12f')](_0x268234[_0x34ff('0x66')][_0x34ff('0x69')],_[_0x34ff('0x6a')](_0x268234[_0x34ff('0x66')],[_0x34ff('0x69'),'id'])||{})[_0x34ff('0xb6')](function(){for(var _0x16c46c=0x0;_0x16c46c<_0x268234[_0x34ff('0x66')][_0x34ff('0x69')]['length'];_0x16c46c+=0x1){socket[_0x34ff('0xb7')]('user_has_mail_interactions:save',{'MailInteractionId':Number(_0x268234[_0x34ff('0x66')][_0x34ff('0x69')][_0x16c46c]),'UserId':Number(_0x268234[_0x34ff('0x67')]['id'])});}return _0x268234['body'][_0x34ff('0x69')];});}})[_0x34ff('0x35')](respondWithResult(_0xeb7668,null))[_0x34ff('0x28')](handleError(_0xeb7668,null));};exports[_0x34ff('0x130')]=function(_0x294867,_0x28f910,_0x24511a){return db[_0x34ff('0x48')][_0x34ff('0x41')]({'where':{'id':_0x294867['params']['id']}})[_0x34ff('0x35')](handleEntityNotFound(_0x28f910,null))[_0x34ff('0x35')](function(_0x591b2a){if(_0x591b2a){return _0x591b2a[_0x34ff('0x130')](_0x294867[_0x34ff('0x4e')]['ids'])[_0x34ff('0x35')](function(){if(_[_0x34ff('0x12d')](_0x294867['query'][_0x34ff('0x69')])){for(var _0x2982e8=0x0;_0x2982e8<_0x294867['query']['ids'][_0x34ff('0x53')];_0x2982e8+=0x1){socket['emit'](_0x34ff('0x131'),{'MailInteractionId':Number(_0x294867[_0x34ff('0x4e')][_0x34ff('0x69')][_0x2982e8]),'UserId':Number(_0x294867[_0x34ff('0x67')]['id'])});}}else{socket['emit'](_0x34ff('0x131'),{'MailInteractionId':Number(_0x294867[_0x34ff('0x4e')][_0x34ff('0x69')]),'UserId':Number(_0x294867[_0x34ff('0x67')]['id'])});}});}})[_0x34ff('0x35')](respondWithStatusCode(_0x28f910,null))[_0x34ff('0x28')](handleError(_0x28f910,null));};exports['addFaxInteractions']=function(_0x4e63f7,_0x5026d9,_0x147969){return db['User'][_0x34ff('0x41')]({'where':{'id':_0x4e63f7[_0x34ff('0x67')]['id']}})[_0x34ff('0x35')](handleEntityNotFound(_0x5026d9,null))[_0x34ff('0x35')](function(_0x7f08c0){if(_0x7f08c0){return _0x7f08c0['addFaxInteractions'](_0x4e63f7[_0x34ff('0x66')][_0x34ff('0x69')],_[_0x34ff('0x6a')](_0x4e63f7[_0x34ff('0x66')],[_0x34ff('0x69'),'id'])||{})[_0x34ff('0xb6')](function(){for(var _0x45e6b3=0x0;_0x45e6b3<_0x4e63f7['body'][_0x34ff('0x69')][_0x34ff('0x53')];_0x45e6b3+=0x1){socket['emit']('user_has_fax_interactions:save',{'FaxInteractionId':Number(_0x4e63f7[_0x34ff('0x66')][_0x34ff('0x69')][_0x45e6b3]),'UserId':Number(_0x4e63f7['params']['id'])});}return _0x4e63f7['body'][_0x34ff('0x69')];});}})[_0x34ff('0x35')](respondWithResult(_0x5026d9,null))['catch'](handleError(_0x5026d9,null));};exports[_0x34ff('0x132')]=function(_0x3ef354,_0x10b50f,_0x365ef4){return db[_0x34ff('0x48')]['find']({'where':{'id':_0x3ef354[_0x34ff('0x67')]['id']}})['then'](handleEntityNotFound(_0x10b50f,null))['then'](function(_0x42f47f){if(_0x42f47f){return _0x42f47f[_0x34ff('0x132')](_0x3ef354[_0x34ff('0x4e')]['ids'])[_0x34ff('0x35')](function(){if(_[_0x34ff('0x12d')](_0x3ef354['query'][_0x34ff('0x69')])){for(var _0x490fd4=0x0;_0x490fd4<_0x3ef354[_0x34ff('0x4e')]['ids'][_0x34ff('0x53')];_0x490fd4+=0x1){socket[_0x34ff('0xb7')]('user_has_fax_interactions:remove',{'FaxInteractionId':Number(_0x3ef354[_0x34ff('0x4e')][_0x34ff('0x69')][_0x490fd4]),'UserId':Number(_0x3ef354[_0x34ff('0x67')]['id'])});}}else{socket['emit']('user_has_fax_interactions:remove',{'FaxInteractionId':Number(_0x3ef354[_0x34ff('0x4e')][_0x34ff('0x69')]),'UserId':Number(_0x3ef354[_0x34ff('0x67')]['id'])});}});}})['then'](respondWithStatusCode(_0x10b50f,null))[_0x34ff('0x28')](handleError(_0x10b50f,null));};exports[_0x34ff('0x133')]=function(_0x5b7db8,_0x53883d,_0x311a22){return db[_0x34ff('0x48')][_0x34ff('0x41')]({'where':{'id':_0x5b7db8[_0x34ff('0x67')]['id']}})[_0x34ff('0x35')](handleEntityNotFound(_0x53883d,null))[_0x34ff('0x35')](function(_0xdf5e69){if(_0xdf5e69){return _0xdf5e69[_0x34ff('0x133')](_0x5b7db8[_0x34ff('0x66')][_0x34ff('0x69')],_[_0x34ff('0x6a')](_0x5b7db8['body'],[_0x34ff('0x69'),'id'])||{})[_0x34ff('0xb6')](function(){for(var _0x2f4ab6=0x0;_0x2f4ab6<_0x5b7db8[_0x34ff('0x66')][_0x34ff('0x69')][_0x34ff('0x53')];_0x2f4ab6+=0x1){socket[_0x34ff('0xb7')]('user_has_sms_interactions:save',{'SmsInteractionId':Number(_0x5b7db8[_0x34ff('0x66')][_0x34ff('0x69')][_0x2f4ab6]),'UserId':Number(_0x5b7db8['params']['id'])});}return _0x5b7db8[_0x34ff('0x66')]['ids'];});}})['then'](respondWithResult(_0x53883d,null))[_0x34ff('0x28')](handleError(_0x53883d,null));};exports[_0x34ff('0x134')]=function(_0xc06598,_0x248ad1,_0x2ecd21){return db[_0x34ff('0x48')]['find']({'where':{'id':_0xc06598['params']['id']}})[_0x34ff('0x35')](handleEntityNotFound(_0x248ad1,null))[_0x34ff('0x35')](function(_0x1f6553){if(_0x1f6553){return _0x1f6553[_0x34ff('0x134')](_0xc06598['query'][_0x34ff('0x69')])['then'](function(){if(_[_0x34ff('0x12d')](_0xc06598[_0x34ff('0x4e')]['ids'])){for(var _0x508a4c=0x0;_0x508a4c<_0xc06598[_0x34ff('0x4e')][_0x34ff('0x69')]['length'];_0x508a4c+=0x1){socket['emit'](_0x34ff('0x135'),{'SmsInteractionId':Number(_0xc06598['query'][_0x34ff('0x69')][_0x508a4c]),'UserId':Number(_0xc06598['params']['id'])});}}else{socket[_0x34ff('0xb7')](_0x34ff('0x135'),{'SmsInteractionId':Number(_0xc06598[_0x34ff('0x4e')][_0x34ff('0x69')]),'UserId':Number(_0xc06598['params']['id'])});}});}})['then'](respondWithStatusCode(_0x248ad1,null))['catch'](handleError(_0x248ad1,null));};exports[_0x34ff('0x136')]=function(_0x259037,_0x3279a7,_0x11e3c5){return db[_0x34ff('0x48')][_0x34ff('0x41')]({'where':{'id':_0x259037[_0x34ff('0x67')]['id']}})['then'](handleEntityNotFound(_0x3279a7,null))[_0x34ff('0x35')](function(_0x121bf9){if(_0x121bf9){return _0x121bf9[_0x34ff('0x136')](_0x259037[_0x34ff('0x66')]['ids'],_[_0x34ff('0x6a')](_0x259037[_0x34ff('0x66')],[_0x34ff('0x69'),'id'])||{})[_0x34ff('0xb6')](function(){for(var _0x34fc9b=0x0;_0x34fc9b<_0x259037[_0x34ff('0x66')][_0x34ff('0x69')]['length'];_0x34fc9b+=0x1){socket[_0x34ff('0xb7')](_0x34ff('0x137'),{'OpenchannelInteractionId':Number(_0x259037['body']['ids'][_0x34fc9b]),'UserId':Number(_0x259037[_0x34ff('0x67')]['id'])});}return _0x259037[_0x34ff('0x66')][_0x34ff('0x69')];});}})[_0x34ff('0x35')](respondWithResult(_0x3279a7,null))[_0x34ff('0x28')](handleError(_0x3279a7,null));};exports[_0x34ff('0x138')]=function(_0x2f9256,_0x1cc7cd,_0x3a487c){return db[_0x34ff('0x48')]['find']({'where':{'id':_0x2f9256[_0x34ff('0x67')]['id']}})[_0x34ff('0x35')](handleEntityNotFound(_0x1cc7cd,null))[_0x34ff('0x35')](function(_0x511af3){if(_0x511af3){return _0x511af3['removeOpenchannelInteractions'](_0x2f9256[_0x34ff('0x4e')][_0x34ff('0x69')])[_0x34ff('0x35')](function(){if(_['isArray'](_0x2f9256[_0x34ff('0x4e')][_0x34ff('0x69')])){for(var _0xaf0087=0x0;_0xaf0087<_0x2f9256[_0x34ff('0x4e')][_0x34ff('0x69')]['length'];_0xaf0087+=0x1){socket[_0x34ff('0xb7')](_0x34ff('0x139'),{'OpenchannelInteractionId':Number(_0x2f9256[_0x34ff('0x4e')][_0x34ff('0x69')][_0xaf0087]),'UserId':Number(_0x2f9256[_0x34ff('0x67')]['id'])});}}else{socket[_0x34ff('0xb7')](_0x34ff('0x139'),{'OpenchannelInteractionId':Number(_0x2f9256['query'][_0x34ff('0x69')]),'UserId':Number(_0x2f9256['params']['id'])});}});}})[_0x34ff('0x35')](respondWithStatusCode(_0x1cc7cd,null))[_0x34ff('0x28')](handleError(_0x1cc7cd,null));};exports[_0x34ff('0x13a')]=function(_0x118aea,_0x5ce2cf,_0x520702){return db['User']['find']({'where':{'id':_0x118aea[_0x34ff('0x67')]['id']}})[_0x34ff('0x35')](handleEntityNotFound(_0x5ce2cf,null))['then'](function(_0x239749){if(_0x239749){return _0x239749['addWhatsappInteractions'](_0x118aea[_0x34ff('0x66')][_0x34ff('0x69')],_[_0x34ff('0x6a')](_0x118aea[_0x34ff('0x66')],['ids','id'])||{})[_0x34ff('0xb6')](function(){for(var _0x58660a=0x0;_0x58660a<_0x118aea[_0x34ff('0x66')][_0x34ff('0x69')][_0x34ff('0x53')];_0x58660a+=0x1){socket[_0x34ff('0xb7')](_0x34ff('0x13b'),{'WhatsappInteractionId':Number(_0x118aea[_0x34ff('0x66')][_0x34ff('0x69')][_0x58660a]),'UserId':Number(_0x118aea[_0x34ff('0x67')]['id'])});}return _0x118aea[_0x34ff('0x66')]['ids'];});}})['then'](respondWithResult(_0x5ce2cf,null))[_0x34ff('0x28')](handleError(_0x5ce2cf,null));};exports[_0x34ff('0x13c')]=function(_0x165893,_0x443014,_0x321424){return db[_0x34ff('0x48')][_0x34ff('0x41')]({'where':{'id':_0x165893[_0x34ff('0x67')]['id']}})['then'](handleEntityNotFound(_0x443014,null))['then'](function(_0x18a982){if(_0x18a982){return _0x18a982[_0x34ff('0x13c')](_0x165893[_0x34ff('0x4e')][_0x34ff('0x69')]);}})['then'](respondWithStatusCode(_0x443014,null))['catch'](handleError(_0x443014,null));};exports[_0x34ff('0x13d')]=function(_0x50f736,_0xe013e3,_0x1d6421){var _0x3d9253={};var _0x4224ff={};var _0x3c4514;var _0x656c38;return db['User']['findOne']({'where':{'id':_0x50f736[_0x34ff('0x67')]['id']}})[_0x34ff('0x35')](handleEntityNotFound(_0xe013e3,null))[_0x34ff('0x35')](function(_0x29ddde){if(_0x29ddde){_0x3c4514=_0x29ddde;_0x4224ff[_0x34ff('0x4c')]=_['keys'](db[_0x34ff('0x13e')][_0x34ff('0x49')]);_0x4224ff['query']=_[_0x34ff('0x4f')](_0x50f736[_0x34ff('0x4e')]);_0x4224ff[_0x34ff('0x59')]=_[_0x34ff('0x50')](_0x4224ff[_0x34ff('0x4c')],_0x4224ff[_0x34ff('0x4e')]);_0x3d9253[_0x34ff('0x51')]=_[_0x34ff('0x50')](_0x4224ff['model'],qs[_0x34ff('0x52')](_0x50f736[_0x34ff('0x4e')][_0x34ff('0x52')]));_0x3d9253['attributes']=_0x3d9253['attributes'][_0x34ff('0x53')]?_0x3d9253[_0x34ff('0x51')]:_0x4224ff[_0x34ff('0x4c')];_0x3d9253[_0x34ff('0x56')]=qs[_0x34ff('0x57')](_0x50f736[_0x34ff('0x4e')][_0x34ff('0x57')]);_0x3d9253[_0x34ff('0x58')]=qs['filters'](_['pick'](_0x50f736[_0x34ff('0x4e')],_0x4224ff[_0x34ff('0x59')]));if(_0x50f736['query'][_0x34ff('0x3d')]){_0x3d9253[_0x34ff('0x58')]=_[_0x34ff('0x5b')](_0x3d9253['where'],{'$or':_[_0x34ff('0x3f')](_0x3d9253[_0x34ff('0x51')],function(_0x301754){var _0x16693b={};_0x16693b[_0x301754]={'$like':'%'+_0x50f736[_0x34ff('0x4e')][_0x34ff('0x3d')]+'%'};return _0x16693b;})});}_0x3d9253=_[_0x34ff('0x5b')]({},_0x3d9253,_0x50f736[_0x34ff('0x5f')]);return _0x3c4514[_0x34ff('0x13d')](_0x3d9253);}})[_0x34ff('0x35')](function(_0x1f0bf2){if(_0x1f0bf2){_0x656c38=_0x1f0bf2['length'];if(!_0x50f736[_0x34ff('0x4e')][_0x34ff('0x54')](_0x34ff('0x55'))){_0x3d9253[_0x34ff('0x2e')]=qs[_0x34ff('0x2e')](_0x50f736['query'][_0x34ff('0x2e')]);_0x3d9253[_0x34ff('0x2d')]=qs[_0x34ff('0x2d')](_0x50f736[_0x34ff('0x4e')]['offset']);}return _0x3c4514[_0x34ff('0x13d')](_0x3d9253);}})[_0x34ff('0x35')](function(_0x296a80){if(_0x296a80){return _0x296a80?{'count':_0x656c38,'rows':_0x296a80}:null;}})[_0x34ff('0x35')](respondWithResult(_0xe013e3,null))['catch'](handleError(_0xe013e3,null));};exports['getFaxAccounts']=function(_0x4eda48,_0x57d757,_0x1a9616){var _0x2696bb={};var _0xaf44b3={};var _0x18c5a6;var _0x33f6ba;return db[_0x34ff('0x48')][_0x34ff('0xcd')]({'where':{'id':_0x4eda48[_0x34ff('0x67')]['id']}})[_0x34ff('0x35')](handleEntityNotFound(_0x57d757,null))[_0x34ff('0x35')](function(_0x18f872){if(_0x18f872){_0x18c5a6=_0x18f872;_0xaf44b3['model']=_[_0x34ff('0x4f')](db[_0x34ff('0x13f')]['rawAttributes']);_0xaf44b3[_0x34ff('0x4e')]=_[_0x34ff('0x4f')](_0x4eda48[_0x34ff('0x4e')]);_0xaf44b3[_0x34ff('0x59')]=_[_0x34ff('0x50')](_0xaf44b3['model'],_0xaf44b3[_0x34ff('0x4e')]);_0x2696bb[_0x34ff('0x51')]=_[_0x34ff('0x50')](_0xaf44b3['model'],qs[_0x34ff('0x52')](_0x4eda48[_0x34ff('0x4e')][_0x34ff('0x52')]));_0x2696bb[_0x34ff('0x51')]=_0x2696bb[_0x34ff('0x51')][_0x34ff('0x53')]?_0x2696bb[_0x34ff('0x51')]:_0xaf44b3[_0x34ff('0x4c')];_0x2696bb[_0x34ff('0x56')]=qs[_0x34ff('0x57')](_0x4eda48[_0x34ff('0x4e')][_0x34ff('0x57')]);_0x2696bb[_0x34ff('0x58')]=qs[_0x34ff('0x59')](_[_0x34ff('0x5a')](_0x4eda48[_0x34ff('0x4e')],_0xaf44b3[_0x34ff('0x59')]));if(_0x4eda48[_0x34ff('0x4e')][_0x34ff('0x3d')]){_0x2696bb['where']=_[_0x34ff('0x5b')](_0x2696bb['where'],{'$or':_['map'](_0x2696bb[_0x34ff('0x51')],function(_0x46777a){var _0x1af17c={};_0x1af17c[_0x46777a]={'$like':'%'+_0x4eda48[_0x34ff('0x4e')][_0x34ff('0x3d')]+'%'};return _0x1af17c;})});}_0x2696bb=_['merge']({},_0x2696bb,_0x4eda48[_0x34ff('0x5f')]);return _0x18c5a6['getFaxAccounts'](_0x2696bb);}})[_0x34ff('0x35')](function(_0x200f30){if(_0x200f30){_0x33f6ba=_0x200f30[_0x34ff('0x53')];if(!_0x4eda48[_0x34ff('0x4e')][_0x34ff('0x54')]('nolimit')){_0x2696bb[_0x34ff('0x2e')]=qs['limit'](_0x4eda48[_0x34ff('0x4e')][_0x34ff('0x2e')]);_0x2696bb[_0x34ff('0x2d')]=qs[_0x34ff('0x2d')](_0x4eda48[_0x34ff('0x4e')][_0x34ff('0x2d')]);}return _0x18c5a6[_0x34ff('0x140')](_0x2696bb);}})['then'](function(_0x49e277){if(_0x49e277){return _0x49e277?{'count':_0x33f6ba,'rows':_0x49e277}:null;}})[_0x34ff('0x35')](respondWithResult(_0x57d757,null))[_0x34ff('0x28')](handleError(_0x57d757,null));};exports[_0x34ff('0x141')]=function(_0x416b2d,_0x470f96,_0x375d99){return db[_0x34ff('0x48')][_0x34ff('0x41')]({'where':{'id':_0x416b2d[_0x34ff('0x67')]['id']}})[_0x34ff('0x35')](handleEntityNotFound(_0x470f96,null))[_0x34ff('0x35')](function(_0x1688d7){if(_0x1688d7){return _0x1688d7[_0x34ff('0x141')](_0x416b2d[_0x34ff('0x66')][_0x34ff('0x69')],_[_0x34ff('0x6a')](_0x416b2d[_0x34ff('0x66')],['ids','id'])||{});}})[_0x34ff('0x35')](respondWithResult(_0x470f96,null))[_0x34ff('0x28')](handleError(_0x470f96,null));};exports[_0x34ff('0x142')]=function(_0x5e40a5,_0x2e24ed,_0x28a9fe){return db[_0x34ff('0x48')][_0x34ff('0x41')]({'where':{'id':_0x5e40a5[_0x34ff('0x67')]['id']}})[_0x34ff('0x35')](handleEntityNotFound(_0x2e24ed,null))[_0x34ff('0x35')](function(_0x1812b6){if(_0x1812b6){return _0x1812b6[_0x34ff('0x142')](_0x5e40a5[_0x34ff('0x4e')][_0x34ff('0x69')]);}})[_0x34ff('0x35')](respondWithStatusCode(_0x2e24ed,null))[_0x34ff('0x28')](handleError(_0x2e24ed,null));};exports['getMailAccounts']=function(_0x541856,_0x3ea9b6,_0x54267d){var _0x10ee90={};var _0x5abc9c={};var _0x4c0961;var _0x4d20d2;return db[_0x34ff('0x48')][_0x34ff('0xcd')]({'where':{'id':_0x541856[_0x34ff('0x67')]['id']}})['then'](handleEntityNotFound(_0x3ea9b6,null))['then'](function(_0x491618){if(_0x491618){_0x4c0961=_0x491618;_0x5abc9c[_0x34ff('0x4c')]=_[_0x34ff('0x4f')](db[_0x34ff('0x143')][_0x34ff('0x49')]);_0x5abc9c['query']=_[_0x34ff('0x4f')](_0x541856[_0x34ff('0x4e')]);_0x5abc9c[_0x34ff('0x59')]=_['intersection'](_0x5abc9c[_0x34ff('0x4c')],_0x5abc9c[_0x34ff('0x4e')]);_0x10ee90[_0x34ff('0x51')]=_[_0x34ff('0x50')](_0x5abc9c[_0x34ff('0x4c')],qs['fields'](_0x541856[_0x34ff('0x4e')][_0x34ff('0x52')]));_0x10ee90[_0x34ff('0x51')]=_0x10ee90[_0x34ff('0x51')][_0x34ff('0x53')]?_0x10ee90[_0x34ff('0x51')]:_0x5abc9c[_0x34ff('0x4c')];_0x10ee90[_0x34ff('0x56')]=qs[_0x34ff('0x57')](_0x541856[_0x34ff('0x4e')][_0x34ff('0x57')]);_0x10ee90[_0x34ff('0x58')]=qs[_0x34ff('0x59')](_[_0x34ff('0x5a')](_0x541856[_0x34ff('0x4e')],_0x5abc9c['filters']));if(_0x541856[_0x34ff('0x4e')]['filter']){_0x10ee90[_0x34ff('0x58')]=_[_0x34ff('0x5b')](_0x10ee90['where'],{'$or':_[_0x34ff('0x3f')](_0x10ee90['attributes'],function(_0x5a343b){var _0x37c71f={};_0x37c71f[_0x5a343b]={'$like':'%'+_0x541856[_0x34ff('0x4e')]['filter']+'%'};return _0x37c71f;})});}_0x10ee90=_[_0x34ff('0x5b')]({},_0x10ee90,_0x541856[_0x34ff('0x5f')]);return _0x4c0961['getMailAccounts'](_0x10ee90);}})['then'](function(_0x5332b2){if(_0x5332b2){_0x4d20d2=_0x5332b2[_0x34ff('0x53')];if(!_0x541856[_0x34ff('0x4e')][_0x34ff('0x54')](_0x34ff('0x55'))){_0x10ee90[_0x34ff('0x2e')]=qs[_0x34ff('0x2e')](_0x541856['query'][_0x34ff('0x2e')]);_0x10ee90[_0x34ff('0x2d')]=qs[_0x34ff('0x2d')](_0x541856['query'][_0x34ff('0x2d')]);}return _0x4c0961[_0x34ff('0x144')](_0x10ee90);}})['then'](function(_0x28b5fd){if(_0x28b5fd){return _0x28b5fd?{'count':_0x4d20d2,'rows':_0x28b5fd}:null;}})['then'](respondWithResult(_0x3ea9b6,null))[_0x34ff('0x28')](handleError(_0x3ea9b6,null));};exports['addMailAccounts']=function(_0x20d784,_0x982860,_0x5e339b){return db[_0x34ff('0x48')]['find']({'where':{'id':_0x20d784[_0x34ff('0x67')]['id']}})[_0x34ff('0x35')](handleEntityNotFound(_0x982860,null))[_0x34ff('0x35')](function(_0x3bfcf7){if(_0x3bfcf7){return _0x3bfcf7[_0x34ff('0x145')](_0x20d784[_0x34ff('0x66')][_0x34ff('0x69')],_[_0x34ff('0x6a')](_0x20d784['body'],[_0x34ff('0x69'),'id'])||{});}})[_0x34ff('0x35')](respondWithResult(_0x982860,null))['catch'](handleError(_0x982860,null));};exports[_0x34ff('0x146')]=function(_0x5e886b,_0x46cdec,_0x53c1bd){return db['User'][_0x34ff('0x41')]({'where':{'id':_0x5e886b[_0x34ff('0x67')]['id']}})[_0x34ff('0x35')](handleEntityNotFound(_0x46cdec,null))['then'](function(_0x198815){if(_0x198815){return _0x198815[_0x34ff('0x146')](_0x5e886b[_0x34ff('0x4e')][_0x34ff('0x69')]);}})[_0x34ff('0x35')](respondWithStatusCode(_0x46cdec,null))[_0x34ff('0x28')](handleError(_0x46cdec,null));};exports[_0x34ff('0x147')]=function(_0x1f6175,_0x58a923,_0x5ba05a){var _0x2d1f76={};var _0x3059b9={};var _0x1561c9;var _0x56fff8;return db[_0x34ff('0x48')][_0x34ff('0xcd')]({'where':{'id':_0x1f6175['params']['id']}})[_0x34ff('0x35')](handleEntityNotFound(_0x58a923,null))['then'](function(_0x45bbc2){if(_0x45bbc2){_0x1561c9=_0x45bbc2;_0x3059b9[_0x34ff('0x4c')]=_[_0x34ff('0x4f')](db[_0x34ff('0x148')][_0x34ff('0x49')]);_0x3059b9[_0x34ff('0x4e')]=_[_0x34ff('0x4f')](_0x1f6175[_0x34ff('0x4e')]);_0x3059b9[_0x34ff('0x59')]=_[_0x34ff('0x50')](_0x3059b9[_0x34ff('0x4c')],_0x3059b9[_0x34ff('0x4e')]);_0x2d1f76[_0x34ff('0x51')]=_[_0x34ff('0x50')](_0x3059b9[_0x34ff('0x4c')],qs[_0x34ff('0x52')](_0x1f6175[_0x34ff('0x4e')]['fields']));_0x2d1f76[_0x34ff('0x51')]=_0x2d1f76[_0x34ff('0x51')]['length']?_0x2d1f76[_0x34ff('0x51')]:_0x3059b9[_0x34ff('0x4c')];_0x2d1f76[_0x34ff('0x56')]=qs[_0x34ff('0x57')](_0x1f6175[_0x34ff('0x4e')][_0x34ff('0x57')]);_0x2d1f76[_0x34ff('0x58')]=qs['filters'](_['pick'](_0x1f6175['query'],_0x3059b9['filters']));if(_0x1f6175['query'][_0x34ff('0x3d')]){_0x2d1f76[_0x34ff('0x58')]=_['merge'](_0x2d1f76[_0x34ff('0x58')],{'$or':_[_0x34ff('0x3f')](_0x2d1f76[_0x34ff('0x51')],function(_0x9d73c7){var _0x32c8e5={};_0x32c8e5[_0x9d73c7]={'$like':'%'+_0x1f6175[_0x34ff('0x4e')]['filter']+'%'};return _0x32c8e5;})});}_0x2d1f76=_[_0x34ff('0x5b')]({},_0x2d1f76,_0x1f6175['options']);return _0x1561c9[_0x34ff('0x147')](_0x2d1f76);}})[_0x34ff('0x35')](function(_0x4d0add){if(_0x4d0add){_0x56fff8=_0x4d0add[_0x34ff('0x53')];if(!_0x1f6175[_0x34ff('0x4e')]['hasOwnProperty']('nolimit')){_0x2d1f76[_0x34ff('0x2e')]=qs[_0x34ff('0x2e')](_0x1f6175[_0x34ff('0x4e')][_0x34ff('0x2e')]);_0x2d1f76[_0x34ff('0x2d')]=qs[_0x34ff('0x2d')](_0x1f6175[_0x34ff('0x4e')][_0x34ff('0x2d')]);}return _0x1561c9['getOpenchannelAccounts'](_0x2d1f76);}})['then'](function(_0x5c0cae){if(_0x5c0cae){return _0x5c0cae?{'count':_0x56fff8,'rows':_0x5c0cae}:null;}})[_0x34ff('0x35')](respondWithResult(_0x58a923,null))[_0x34ff('0x28')](handleError(_0x58a923,null));};exports['addOpenchannelAccounts']=function(_0x4de3e0,_0x346d6e,_0x371367){return db[_0x34ff('0x48')][_0x34ff('0x41')]({'where':{'id':_0x4de3e0['params']['id']}})[_0x34ff('0x35')](handleEntityNotFound(_0x346d6e,null))['then'](function(_0x70834b){if(_0x70834b){return _0x70834b['addOpenchannelAccounts'](_0x4de3e0['body'][_0x34ff('0x69')],_['omit'](_0x4de3e0[_0x34ff('0x66')],[_0x34ff('0x69'),'id'])||{});}})[_0x34ff('0x35')](respondWithResult(_0x346d6e,null))[_0x34ff('0x28')](handleError(_0x346d6e,null));};exports[_0x34ff('0x149')]=function(_0xee75c8,_0x4652b5,_0x155aee){return db['User']['find']({'where':{'id':_0xee75c8['params']['id']}})[_0x34ff('0x35')](handleEntityNotFound(_0x4652b5,null))[_0x34ff('0x35')](function(_0x42d907){if(_0x42d907){return _0x42d907[_0x34ff('0x149')](_0xee75c8[_0x34ff('0x4e')][_0x34ff('0x69')]);}})[_0x34ff('0x35')](respondWithStatusCode(_0x4652b5,null))[_0x34ff('0x28')](handleError(_0x4652b5,null));};exports[_0x34ff('0x14a')]=function(_0x218c2b,_0xdec550,_0x55deac){var _0x54af89={};var _0x3eb095={};var _0x56e1cb;var _0x4d2dfe;return db['User'][_0x34ff('0xcd')]({'where':{'id':_0x218c2b[_0x34ff('0x67')]['id']}})[_0x34ff('0x35')](handleEntityNotFound(_0xdec550,null))[_0x34ff('0x35')](function(_0x30d913){if(_0x30d913){_0x56e1cb=_0x30d913;_0x3eb095['model']=_[_0x34ff('0x4f')](db['SmsAccount'][_0x34ff('0x49')]);_0x3eb095[_0x34ff('0x4e')]=_[_0x34ff('0x4f')](_0x218c2b['query']);_0x3eb095[_0x34ff('0x59')]=_[_0x34ff('0x50')](_0x3eb095['model'],_0x3eb095[_0x34ff('0x4e')]);_0x54af89[_0x34ff('0x51')]=_[_0x34ff('0x50')](_0x3eb095[_0x34ff('0x4c')],qs[_0x34ff('0x52')](_0x218c2b[_0x34ff('0x4e')][_0x34ff('0x52')]));_0x54af89[_0x34ff('0x51')]=_0x54af89[_0x34ff('0x51')][_0x34ff('0x53')]?_0x54af89[_0x34ff('0x51')]:_0x3eb095[_0x34ff('0x4c')];_0x54af89[_0x34ff('0x56')]=qs[_0x34ff('0x57')](_0x218c2b['query'][_0x34ff('0x57')]);_0x54af89[_0x34ff('0x58')]=qs[_0x34ff('0x59')](_['pick'](_0x218c2b[_0x34ff('0x4e')],_0x3eb095[_0x34ff('0x59')]));if(_0x218c2b[_0x34ff('0x4e')]['filter']){_0x54af89[_0x34ff('0x58')]=_['merge'](_0x54af89[_0x34ff('0x58')],{'$or':_[_0x34ff('0x3f')](_0x54af89['attributes'],function(_0x2148d3){var _0x50fdfc={};_0x50fdfc[_0x2148d3]={'$like':'%'+_0x218c2b[_0x34ff('0x4e')][_0x34ff('0x3d')]+'%'};return _0x50fdfc;})});}_0x54af89=_['merge']({},_0x54af89,_0x218c2b[_0x34ff('0x5f')]);return _0x56e1cb['getSmsAccounts'](_0x54af89);}})[_0x34ff('0x35')](function(_0x4a6adb){if(_0x4a6adb){_0x4d2dfe=_0x4a6adb['length'];if(!_0x218c2b[_0x34ff('0x4e')]['hasOwnProperty'](_0x34ff('0x55'))){_0x54af89[_0x34ff('0x2e')]=qs[_0x34ff('0x2e')](_0x218c2b[_0x34ff('0x4e')][_0x34ff('0x2e')]);_0x54af89[_0x34ff('0x2d')]=qs['offset'](_0x218c2b[_0x34ff('0x4e')]['offset']);}return _0x56e1cb['getSmsAccounts'](_0x54af89);}})[_0x34ff('0x35')](function(_0x344eb4){if(_0x344eb4){return _0x344eb4?{'count':_0x4d2dfe,'rows':_0x344eb4}:null;}})[_0x34ff('0x35')](respondWithResult(_0xdec550,null))['catch'](handleError(_0xdec550,null));};exports[_0x34ff('0x14b')]=function(_0x32ca10,_0x3f3aa9,_0x21b151){return db[_0x34ff('0x48')]['find']({'where':{'id':_0x32ca10[_0x34ff('0x67')]['id']}})[_0x34ff('0x35')](handleEntityNotFound(_0x3f3aa9,null))[_0x34ff('0x35')](function(_0x3f8361){if(_0x3f8361){return _0x3f8361[_0x34ff('0x14b')](_0x32ca10[_0x34ff('0x66')][_0x34ff('0x69')],_[_0x34ff('0x6a')](_0x32ca10[_0x34ff('0x66')],[_0x34ff('0x69'),'id'])||{});}})['then'](respondWithResult(_0x3f3aa9,null))[_0x34ff('0x28')](handleError(_0x3f3aa9,null));};exports[_0x34ff('0x14c')]=function(_0x3db97f,_0x56967a,_0x66fc45){return db[_0x34ff('0x48')][_0x34ff('0x41')]({'where':{'id':_0x3db97f[_0x34ff('0x67')]['id']}})[_0x34ff('0x35')](handleEntityNotFound(_0x56967a,null))[_0x34ff('0x35')](function(_0x303a40){if(_0x303a40){return _0x303a40[_0x34ff('0x14c')](_0x3db97f[_0x34ff('0x4e')][_0x34ff('0x69')]);}})['then'](respondWithStatusCode(_0x56967a,null))['catch'](handleError(_0x56967a,null));};exports[_0x34ff('0x14d')]=function(_0x473cc1,_0x3d0ab1,_0x4f8789){var _0x51b78e={};var _0x229a39={};var _0x2fb681;var _0x161e7e;return db['User'][_0x34ff('0xcd')]({'where':{'id':_0x473cc1[_0x34ff('0x67')]['id']}})['then'](handleEntityNotFound(_0x3d0ab1,null))[_0x34ff('0x35')](function(_0x1729ab){if(_0x1729ab){_0x2fb681=_0x1729ab;_0x229a39['model']=_['keys'](db[_0x34ff('0x14e')][_0x34ff('0x49')]);_0x229a39[_0x34ff('0x4e')]=_['keys'](_0x473cc1[_0x34ff('0x4e')]);_0x229a39[_0x34ff('0x59')]=_[_0x34ff('0x50')](_0x229a39[_0x34ff('0x4c')],_0x229a39[_0x34ff('0x4e')]);_0x51b78e[_0x34ff('0x51')]=_['intersection'](_0x229a39[_0x34ff('0x4c')],qs[_0x34ff('0x52')](_0x473cc1[_0x34ff('0x4e')][_0x34ff('0x52')]));_0x51b78e['attributes']=_0x51b78e[_0x34ff('0x51')][_0x34ff('0x53')]?_0x51b78e['attributes']:_0x229a39[_0x34ff('0x4c')];_0x51b78e['order']=qs[_0x34ff('0x57')](_0x473cc1[_0x34ff('0x4e')][_0x34ff('0x57')]);_0x51b78e[_0x34ff('0x58')]=qs[_0x34ff('0x59')](_[_0x34ff('0x5a')](_0x473cc1[_0x34ff('0x4e')],_0x229a39[_0x34ff('0x59')]));if(_0x473cc1[_0x34ff('0x4e')][_0x34ff('0x3d')]){_0x51b78e[_0x34ff('0x58')]=_[_0x34ff('0x5b')](_0x51b78e[_0x34ff('0x58')],{'$or':_[_0x34ff('0x3f')](_0x51b78e[_0x34ff('0x51')],function(_0x57e2ea){var _0x27a3be={};_0x27a3be[_0x57e2ea]={'$like':'%'+_0x473cc1[_0x34ff('0x4e')][_0x34ff('0x3d')]+'%'};return _0x27a3be;})});}_0x51b78e=_['merge']({},_0x51b78e,_0x473cc1[_0x34ff('0x5f')]);return _0x2fb681[_0x34ff('0x14d')](_0x51b78e);}})[_0x34ff('0x35')](function(_0x11ff65){if(_0x11ff65){_0x161e7e=_0x11ff65[_0x34ff('0x53')];if(!_0x473cc1[_0x34ff('0x4e')]['hasOwnProperty'](_0x34ff('0x55'))){_0x51b78e[_0x34ff('0x2e')]=qs[_0x34ff('0x2e')](_0x473cc1[_0x34ff('0x4e')][_0x34ff('0x2e')]);_0x51b78e[_0x34ff('0x2d')]=qs[_0x34ff('0x2d')](_0x473cc1[_0x34ff('0x4e')][_0x34ff('0x2d')]);}return _0x2fb681[_0x34ff('0x14d')](_0x51b78e);}})[_0x34ff('0x35')](function(_0x395488){if(_0x395488){return _0x395488?{'count':_0x161e7e,'rows':_0x395488}:null;}})[_0x34ff('0x35')](respondWithResult(_0x3d0ab1,null))[_0x34ff('0x28')](handleError(_0x3d0ab1,null));};exports[_0x34ff('0x14f')]=function(_0x54918d,_0x35b888,_0x424daa){return db[_0x34ff('0x48')][_0x34ff('0x41')]({'where':{'id':_0x54918d['params']['id']}})['then'](handleEntityNotFound(_0x35b888,null))[_0x34ff('0x35')](function(_0x5601f9){if(_0x5601f9){return _0x5601f9['addChatWebsites'](_0x54918d[_0x34ff('0x66')]['ids'],_['omit'](_0x54918d['body'],['ids','id'])||{});}})[_0x34ff('0x35')](respondWithResult(_0x35b888,null))['catch'](handleError(_0x35b888,null));};exports[_0x34ff('0x150')]=function(_0x1ccfd4,_0x22a60f,_0x278ed5){return db[_0x34ff('0x48')]['find']({'where':{'id':_0x1ccfd4[_0x34ff('0x67')]['id']}})[_0x34ff('0x35')](handleEntityNotFound(_0x22a60f,null))['then'](function(_0x3b5522){if(_0x3b5522){return _0x3b5522[_0x34ff('0x150')](_0x1ccfd4['query'][_0x34ff('0x69')]);}})[_0x34ff('0x35')](respondWithStatusCode(_0x22a60f,null))[_0x34ff('0x28')](handleError(_0x22a60f,null));};exports[_0x34ff('0x151')]=function(_0x2b3c6c,_0x2bea52,_0x398914){var _0x9e0d5={};var _0xa94b15={};var _0x1a79a0;var _0x38e9d9;return db[_0x34ff('0x48')][_0x34ff('0xcd')]({'where':{'id':_0x2b3c6c[_0x34ff('0x67')]['id']}})['then'](handleEntityNotFound(_0x2bea52,null))['then'](function(_0x283a27){if(_0x283a27){_0x1a79a0=_0x283a27;_0xa94b15[_0x34ff('0x4c')]=_['keys'](db[_0x34ff('0x152')][_0x34ff('0x49')]);_0xa94b15[_0x34ff('0x4e')]=_['keys'](_0x2b3c6c[_0x34ff('0x4e')]);_0xa94b15['filters']=_[_0x34ff('0x50')](_0xa94b15[_0x34ff('0x4c')],_0xa94b15[_0x34ff('0x4e')]);_0x9e0d5[_0x34ff('0x51')]=_[_0x34ff('0x50')](_0xa94b15['model'],qs[_0x34ff('0x52')](_0x2b3c6c[_0x34ff('0x4e')][_0x34ff('0x52')]));_0x9e0d5[_0x34ff('0x51')]=_0x9e0d5[_0x34ff('0x51')][_0x34ff('0x53')]?_0x9e0d5[_0x34ff('0x51')]:_0xa94b15[_0x34ff('0x4c')];_0x9e0d5[_0x34ff('0x56')]=qs[_0x34ff('0x57')](_0x2b3c6c[_0x34ff('0x4e')][_0x34ff('0x57')]);_0x9e0d5[_0x34ff('0x58')]=qs[_0x34ff('0x59')](_[_0x34ff('0x5a')](_0x2b3c6c['query'],_0xa94b15[_0x34ff('0x59')]));if(_0x2b3c6c[_0x34ff('0x4e')][_0x34ff('0x3d')]){_0x9e0d5[_0x34ff('0x58')]=_[_0x34ff('0x5b')](_0x9e0d5[_0x34ff('0x58')],{'$or':_[_0x34ff('0x3f')](_0x9e0d5[_0x34ff('0x51')],function(_0x47f254){var _0x3857ba={};_0x3857ba[_0x47f254]={'$like':'%'+_0x2b3c6c[_0x34ff('0x4e')][_0x34ff('0x3d')]+'%'};return _0x3857ba;})});}_0x9e0d5=_[_0x34ff('0x5b')]({},_0x9e0d5,_0x2b3c6c[_0x34ff('0x5f')]);return _0x1a79a0['getWhatsappAccounts'](_0x9e0d5);}})[_0x34ff('0x35')](function(_0x5da9e2){if(_0x5da9e2){_0x38e9d9=_0x5da9e2[_0x34ff('0x53')];if(!_0x2b3c6c[_0x34ff('0x4e')]['hasOwnProperty'](_0x34ff('0x55'))){_0x9e0d5[_0x34ff('0x2e')]=qs[_0x34ff('0x2e')](_0x2b3c6c['query'][_0x34ff('0x2e')]);_0x9e0d5['offset']=qs[_0x34ff('0x2d')](_0x2b3c6c[_0x34ff('0x4e')][_0x34ff('0x2d')]);}return _0x1a79a0['getWhatsappAccounts'](_0x9e0d5);}})[_0x34ff('0x35')](function(_0x4a52f3){if(_0x4a52f3){return _0x4a52f3?{'count':_0x38e9d9,'rows':_0x4a52f3}:null;}})[_0x34ff('0x35')](respondWithResult(_0x2bea52,null))[_0x34ff('0x28')](handleError(_0x2bea52,null));};exports['addWhatsappAccounts']=function(_0x43fe93,_0x1a87e7,_0x5087ac){return db[_0x34ff('0x48')]['find']({'where':{'id':_0x43fe93[_0x34ff('0x67')]['id']}})['then'](handleEntityNotFound(_0x1a87e7,null))[_0x34ff('0x35')](function(_0x123ea4){if(_0x123ea4){return _0x123ea4[_0x34ff('0x153')](_0x43fe93[_0x34ff('0x66')][_0x34ff('0x69')],_['omit'](_0x43fe93[_0x34ff('0x66')],['ids','id'])||{});}})['then'](respondWithResult(_0x1a87e7,null))[_0x34ff('0x28')](handleError(_0x1a87e7,null));};exports['removeWhatsappAccounts']=function(_0x3f95a9,_0x3c89f4,_0x17f507){return db[_0x34ff('0x48')][_0x34ff('0x41')]({'where':{'id':_0x3f95a9[_0x34ff('0x67')]['id']}})[_0x34ff('0x35')](handleEntityNotFound(_0x3c89f4,null))[_0x34ff('0x35')](function(_0x120016){if(_0x120016){return _0x120016[_0x34ff('0x154')](_0x3f95a9['query'][_0x34ff('0x69')]);}})[_0x34ff('0x35')](respondWithStatusCode(_0x3c89f4,null))[_0x34ff('0x28')](handleError(_0x3c89f4,null));};exports[_0x34ff('0x155')]=function(_0x3bb08a,_0xe2b165,_0x4e128a){var _0x735f76={};var _0x536c81={};var _0x54f760;var _0x3c0a94;return db[_0x34ff('0x48')]['findOne']({'where':{'id':_0x3bb08a[_0x34ff('0x67')]['id']}})[_0x34ff('0x35')](handleEntityNotFound(_0xe2b165,null))[_0x34ff('0x35')](function(_0x5178a0){if(_0x5178a0){_0x54f760=_0x5178a0;_0x536c81[_0x34ff('0x4c')]=_[_0x34ff('0x4f')](db[_0x34ff('0x156')][_0x34ff('0x49')]);_0x536c81[_0x34ff('0x4e')]=_['keys'](_0x3bb08a['query']);_0x536c81[_0x34ff('0x59')]=_[_0x34ff('0x50')](_0x536c81[_0x34ff('0x4c')],_0x536c81[_0x34ff('0x4e')]);_0x735f76['attributes']=_[_0x34ff('0x50')](_0x536c81[_0x34ff('0x4c')],qs[_0x34ff('0x52')](_0x3bb08a[_0x34ff('0x4e')][_0x34ff('0x52')]));_0x735f76[_0x34ff('0x51')]=_0x735f76[_0x34ff('0x51')]['length']?_0x735f76[_0x34ff('0x51')]:_0x536c81['model'];_0x735f76[_0x34ff('0x56')]=qs[_0x34ff('0x57')](_0x3bb08a[_0x34ff('0x4e')][_0x34ff('0x57')]);_0x735f76[_0x34ff('0x58')]=qs['filters'](_[_0x34ff('0x5a')](_0x3bb08a[_0x34ff('0x4e')],_0x536c81['filters']));if(_0x3bb08a['query']['filter']){_0x735f76[_0x34ff('0x58')]=_['merge'](_0x735f76[_0x34ff('0x58')],{'$or':_['map'](_0x735f76['attributes'],function(_0x4db511){var _0x32d993={};_0x32d993[_0x4db511]={'$like':'%'+_0x3bb08a['query'][_0x34ff('0x3d')]+'%'};return _0x32d993;})});}_0x735f76=_[_0x34ff('0x5b')]({},_0x735f76,_0x3bb08a['options']);return _0x54f760['getSquareProjects'](_0x735f76);}})[_0x34ff('0x35')](function(_0xfb92bc){if(_0xfb92bc){_0x3c0a94=_0xfb92bc['length'];if(!_0x3bb08a[_0x34ff('0x4e')][_0x34ff('0x54')](_0x34ff('0x55'))){_0x735f76['limit']=qs['limit'](_0x3bb08a[_0x34ff('0x4e')][_0x34ff('0x2e')]);_0x735f76[_0x34ff('0x2d')]=qs['offset'](_0x3bb08a[_0x34ff('0x4e')][_0x34ff('0x2d')]);}return _0x54f760[_0x34ff('0x155')](_0x735f76);}})[_0x34ff('0x35')](function(_0x27531d){if(_0x27531d){return _0x27531d?{'count':_0x3c0a94,'rows':_0x27531d}:null;}})[_0x34ff('0x35')](respondWithResult(_0xe2b165,null))[_0x34ff('0x28')](handleError(_0xe2b165,null));};exports[_0x34ff('0x157')]=function(_0xa4ba62,_0x40ec43,_0xee32b6){return db[_0x34ff('0x48')][_0x34ff('0x41')]({'where':{'id':_0xa4ba62[_0x34ff('0x67')]['id']}})[_0x34ff('0x35')](handleEntityNotFound(_0x40ec43,null))[_0x34ff('0x35')](function(_0x27507b){if(_0x27507b){return _0x27507b[_0x34ff('0x157')](_0xa4ba62[_0x34ff('0x66')]['ids'],_[_0x34ff('0x6a')](_0xa4ba62[_0x34ff('0x66')],[_0x34ff('0x69'),'id'])||{});}})[_0x34ff('0x35')](respondWithResult(_0x40ec43,null))[_0x34ff('0x28')](handleError(_0x40ec43,null));};exports[_0x34ff('0x158')]=function(_0x5759b0,_0x5b7df3,_0x1b98b0){return db['User'][_0x34ff('0x41')]({'where':{'id':_0x5759b0[_0x34ff('0x67')]['id']}})[_0x34ff('0x35')](handleEntityNotFound(_0x5b7df3,null))[_0x34ff('0x35')](function(_0x1b0563){if(_0x1b0563){return _0x1b0563[_0x34ff('0x158')](_0x5759b0['query'][_0x34ff('0x69')]);}})[_0x34ff('0x35')](respondWithStatusCode(_0x5b7df3,null))[_0x34ff('0x28')](handleError(_0x5b7df3,null));};exports[_0x34ff('0x159')]=function(_0x32b131,_0x2138c0){var _0x65e9b7={},_0x149baa={},_0x220d27={'count':0x0,'rows':[]};var _0x30a14c=db[_0x34ff('0x15a')][_0x34ff('0x49')];_0x149baa[_0x34ff('0x4c')]=_['keys'](_0x30a14c);_0x149baa[_0x34ff('0x4e')]=_['keys'](_0x32b131['query']);_0x149baa[_0x34ff('0x59')]=_[_0x34ff('0x50')](_0x149baa['model'],_0x149baa[_0x34ff('0x4e')]);_0x149baa[_0x34ff('0x59')]=_[_0x34ff('0xfb')](_0x149baa[_0x34ff('0x59')],[_0x34ff('0x15b'),_0x34ff('0x15c'),_0x34ff('0x15d'),_0x34ff('0x15e'),_0x34ff('0x15f'),'$lte',_0x34ff('0x160'),_0x34ff('0x161'),_0x34ff('0x162'),'$between',_0x34ff('0x163'),'$in',_0x34ff('0x164'),'$like',_0x34ff('0x165'),'$iLike','$notILike',_0x34ff('0x166'),_0x34ff('0x167'),_0x34ff('0x168'),_0x34ff('0x169'),_0x34ff('0x16a')]);_0x65e9b7[_0x34ff('0x51')]=_[_0x34ff('0x50')](_0x149baa['model'],qs[_0x34ff('0x52')](_0x32b131[_0x34ff('0x4e')][_0x34ff('0x52')]));_0x65e9b7[_0x34ff('0x51')]=_0x65e9b7[_0x34ff('0x51')][_0x34ff('0x53')]?_0x65e9b7[_0x34ff('0x51')]:_0x149baa[_0x34ff('0x4c')];if(!_0x32b131[_0x34ff('0x4e')][_0x34ff('0x54')](_0x34ff('0x55'))){_0x65e9b7[_0x34ff('0x2e')]=qs[_0x34ff('0x2e')](_0x32b131[_0x34ff('0x4e')][_0x34ff('0x2e')]);_0x65e9b7[_0x34ff('0x2d')]=qs[_0x34ff('0x2d')](_0x32b131[_0x34ff('0x4e')][_0x34ff('0x2d')]);}_0x65e9b7['order']=qs[_0x34ff('0x57')](_0x32b131[_0x34ff('0x4e')][_0x34ff('0x57')]);_0x65e9b7[_0x34ff('0x58')]=qs[_0x34ff('0x59')](_[_0x34ff('0x5a')](_0x32b131[_0x34ff('0x4e')],_0x149baa[_0x34ff('0x59')]));if(_0x32b131[_0x34ff('0x4e')][_0x34ff('0x3d')]){_0x65e9b7[_0x34ff('0x58')]=_['merge'](_0x65e9b7[_0x34ff('0x58')],{'$or':_[_0x34ff('0x3f')](_0x65e9b7['attributes'],function(_0x518676){var _0x2ca550={};_0x2ca550[_0x518676]={'$like':'%'+_0x32b131['query'][_0x34ff('0x3d')]+'%'};return _0x2ca550;})});}_0x65e9b7[_0x34ff('0x58')]={'$and':[_0x65e9b7['where'],{'$or':[{'UserId':_0x32b131[_0x34ff('0x67')]['id']},{'OwnerId':_0x32b131[_0x34ff('0x67')]['id']}]}]};_0x65e9b7=_[_0x34ff('0x5b')]({},_0x65e9b7,_0x32b131[_0x34ff('0x5f')]);var _0xdaf7d1={'where':_0x65e9b7['where']};return db['CmHopper'][_0x34ff('0x2c')](_0xdaf7d1)[_0x34ff('0x35')](function(_0x36e80d){_0x220d27[_0x34ff('0x2c')]=_0x36e80d;if(_0x32b131['query']['includeAll']){_0x65e9b7[_0x34ff('0x61')]=[{'attributes':['id',_0x34ff('0x16b'),_0x34ff('0x16c'),_0x34ff('0xe8')],'model':db[_0x34ff('0xce')],'as':'Contact'},{'attributes':['id',_0x34ff('0x43'),_0x34ff('0x16d')],'model':db['VoiceQueue'],'as':_0x34ff('0xd4')}];}return db[_0x34ff('0x15a')]['findAll'](_0x65e9b7);})['then'](function(_0x115303){_0x220d27[_0x34ff('0x63')]=_0x115303;return _0x220d27;})[_0x34ff('0x35')](respondWithFilteredResult(_0x2138c0,_0x65e9b7))[_0x34ff('0x28')](handleError(_0x2138c0,null));};exports[_0x34ff('0x16e')]=function(_0x4888c2,_0x3075de,_0x433b46){if(!_[_0x34ff('0x70')](_0x4888c2[_0x34ff('0x3a')]['id'])&&(_0x4888c2[_0x34ff('0x3a')][_0x34ff('0x42')]==_0x34ff('0x38')||_0x4888c2['user'][_0x34ff('0x42')]==_0x34ff('0x3a'))){return db['User'][_0x34ff('0xcd')]({'where':{'id':_0x4888c2[_0x34ff('0x67')]['id']},'raw':!![]})['then'](function(_0x155f95){return authService[_0x34ff('0x16f')](_0x155f95);})[_0x34ff('0x35')](function(_0x15a748){if(_0x15a748){return _0x3075de[_0x34ff('0x2a')](0xc8)[_0x34ff('0x30')]({'api_key':_0x15a748[_0x34ff('0x170')]});}else{return _0x3075de[_0x34ff('0x2a')](0xcc)['json']({'message':_0x34ff('0x171')});}})[_0x34ff('0x28')](handleError(_0x3075de,0x193));}else{return _0x3075de[_0x34ff('0x2a')](0x191)['json']({'message':'You\x20don\x27t\x20have\x20sufficient\x20privileges\x20to\x20access\x20this\x20resource.'});}};exports['createApiKey']=function(_0x61e7c9,_0x274b23,_0x3f5b8c){if(!_[_0x34ff('0x70')](_0x61e7c9['user']['id'])&&(_0x61e7c9[_0x34ff('0x3a')][_0x34ff('0x42')]=='admin'||_0x61e7c9[_0x34ff('0x3a')][_0x34ff('0x42')]=='user')){return db[_0x34ff('0x48')][_0x34ff('0x41')]({'where':{'id':_0x61e7c9[_0x34ff('0x67')]['id']}})[_0x34ff('0x35')](function(_0x2ef9cc){return authService[_0x34ff('0x172')](_0x2ef9cc);})[_0x34ff('0x35')](function(_0x56ae1d){return db['User'][_0x34ff('0x34')]({'apiKeyIat':_0x56ae1d[_0x34ff('0x173')],'apiKeyNonce':_0x56ae1d[_0x34ff('0x174')]},{'where':{'id':_0x61e7c9[_0x34ff('0x67')]['id']}})[_0x34ff('0x35')](function(){return _0x274b23[_0x34ff('0x2a')](0xc8)[_0x34ff('0x30')]({'api_key':_0x56ae1d['token']});});})[_0x34ff('0x28')](handleError(_0x274b23,0x193));}else{return _0x274b23['status'](0x191)[_0x34ff('0x30')]({'message':'You\x20don\x27t\x20have\x20sufficient\x20privileges\x20to\x20access\x20this\x20resource.'});}};exports['removeApiKey']=function(_0x581a34,_0x2a70f7,_0x503dc9){if(!_[_0x34ff('0x70')](_0x581a34[_0x34ff('0x3a')]['id'])&&(_0x581a34[_0x34ff('0x3a')][_0x34ff('0x42')]==_0x34ff('0x38')||_0x581a34[_0x34ff('0x3a')][_0x34ff('0x42')]==_0x34ff('0x3a'))){return db[_0x34ff('0x48')][_0x34ff('0x41')]({'where':{'id':_0x581a34['params']['id']}})[_0x34ff('0x35')](handleEntityNotFound(_0x2a70f7,null))[_0x34ff('0x35')](function(_0x25c5a9){if(_0x25c5a9&&_0x25c5a9[_0x34ff('0x175')]&&_0x25c5a9[_0x34ff('0x176')])return _0x25c5a9;else throw{'message':'API\x20key\x20not\x20available'};})[_0x34ff('0x35')](function(_0x43e577){return db[_0x34ff('0x48')]['update']({'apiKeyNonce':null,'apiKeyIat':null},{'where':{'id':_0x581a34[_0x34ff('0x67')]['id']}});})[_0x34ff('0x35')](respondWithStatusCode(_0x2a70f7,0xc8))[_0x34ff('0x28')](handleError(_0x2a70f7,0x193));}else{return _0x2a70f7[_0x34ff('0x2a')](0x191)[_0x34ff('0x30')]({'message':_0x34ff('0x177')});}};exports['whoami']=function(_0x21677e,_0x57f894){var _0x1f7539=_0x21677e['user'][_0x34ff('0x37')]({'plain':!![]});if(!_0x1f7539){return _0x57f894[_0x34ff('0x2a')](0x191)['send'](_0x34ff('0x178'));}else{return _0x57f894[_0x34ff('0x2a')](0xc8)['json'](_0x1f7539);}};exports[_0x34ff('0x179')]=function(_0x2c78d2,_0x5b6a59){var _0x91c2c2={'offset':0x0},_0x265d1c={'count':0x0,'rows':[]};Promise['resolve']()['then'](function(){if(!_0x2c78d2[_0x34ff('0x4e')][_0x34ff('0x3d')]&&!_0x2c78d2[_0x34ff('0x4e')][_0x34ff('0x17a')]&&!_0x2c78d2[_0x34ff('0x4e')]['queues'])return[];return Promise['resolve']()[_0x34ff('0x35')](function(){var _0x3e8e86=[];if(!_[_0x34ff('0x99')](_0x2c78d2['query'][_0x34ff('0x17a')])){_0x3e8e86[_0x34ff('0x95')](db['Team']['findAll']({'attributes':['id',_0x34ff('0x43')],'where':{'id':_0x2c78d2['query'][_0x34ff('0x17a')]}}));}if(!_[_0x34ff('0x99')](_0x2c78d2[_0x34ff('0x4e')]['queues'])){_0x3e8e86[_0x34ff('0x95')](db[_0x34ff('0xba')][_0x34ff('0x62')]({'attributes':['id',_0x34ff('0x43')],'type':'inbound','where':{'id':_0x2c78d2[_0x34ff('0x4e')][_0x34ff('0x17b')]}}));}return Promise[_0x34ff('0x94')](_0x3e8e86);})[_0x34ff('0x35')](function(_0x1db9e4){var _0x36bf27=_[_0x34ff('0x11e')](_0x1db9e4)[_0x34ff('0x3f')](function(_0x1e70aa){return _0x1e70aa[_0x34ff('0x17c')]({'attributes':['id',_0x34ff('0x43'),_0x34ff('0x6b'),_0x34ff('0xac')],'raw':!![]});});return Promise['all'](_0x36bf27);})[_0x34ff('0x35')](function(_0xe1037f){var _0x231660=_[_0x34ff('0x11e')](_0xe1037f);if(!_0x2c78d2[_0x34ff('0x4e')]['filter'])return _0x231660;if(_['isEmpty'](_0x231660)){return db[_0x34ff('0x48')]['findAll']({'attributes':['id',_0x34ff('0x43'),'internal',_0x34ff('0xac')],'where':{'role':_0x34ff('0x7a'),'$or':[db[_0x34ff('0x5c')][_0x34ff('0x58')](db[_0x34ff('0x5c')]['fn'](_0x34ff('0x5d'),db[_0x34ff('0x5c')][_0x34ff('0x5e')]('name')),{'$like':'%'+_0x2c78d2[_0x34ff('0x4e')]['filter'][_0x34ff('0xb3')]()+'%'}),{'internal':{'$like':'%'+_0x2c78d2[_0x34ff('0x4e')][_0x34ff('0x3d')]+'%'}}]},'raw':!![]});}else{return _(_0x231660)[_0x34ff('0x11e')]()[_0x34ff('0x3d')](function(_0x40640a){return _0x40640a[_0x34ff('0x43')]['toLowerCase']()[_0x34ff('0x9b')](_0x2c78d2['query'][_0x34ff('0x3d')][_0x34ff('0xb3')]())||_0x40640a[_0x34ff('0x6b')][_0x34ff('0x17d')]()[_0x34ff('0x9b')](_0x2c78d2['query']['filter']);})['value']();}})[_0x34ff('0x35')](function(_0x302e04){var _0x4b51d0=_0x34ff('0x43');var _0x1fa9ab=_0x34ff('0x17e');if(_0x2c78d2[_0x34ff('0x4e')][_0x34ff('0x57')]){var _0x1fa9ab=_0x2c78d2['query']['sort'][0x0]==='-'?'desc':'asc';var _0x4b51d0=_0x1fa9ab===_0x34ff('0x17e')?_0x2c78d2['query'][_0x34ff('0x57')]:_0x2c78d2[_0x34ff('0x4e')][_0x34ff('0x57')][_0x34ff('0x17f')](0x1);}return _(_0x302e04)[_0x34ff('0x180')]('id')[_0x34ff('0x181')]([function(_0x503c11){return _0x4b51d0===_0x34ff('0x43')?_0x503c11[_0x4b51d0][_0x34ff('0xb3')]():_0x503c11[_0x4b51d0];}],[_0x1fa9ab])[_0x34ff('0x3f')](function(_0x42bb7f){return _[_0x34ff('0x5a')](_0x42bb7f,['id',_0x34ff('0x43'),_0x34ff('0x6b'),_0x34ff('0xac')]);})[_0x34ff('0x40')]();})[_0x34ff('0x35')](function(_0x4eb9c1){return client['request']('Agents',_0x2c78d2)[_0x34ff('0x35')](function(_0x1dc222){if(_0x1dc222[_0x34ff('0x24')])throw new Error(_0x34ff('0x182'));var _0x138ce0=_0x1dc222['result'];var _0x5f469b=jayson[_0x34ff('0x1c')][_0x34ff('0x183')]({'port':0x232c});return _0x5f469b[_0x34ff('0x1d')]('Agents',_0x2c78d2)[_0x34ff('0x35')](function(_0x8438eb){if(_0x8438eb[_0x34ff('0x24')])throw new Error(_0x34ff('0x184'));var _0x4f02aa=_0x8438eb[_0x34ff('0x27')];return _['merge']({},_0x4f02aa,_0x138ce0);});})[_0x34ff('0x35')](function(_0x110c5e){return _['map'](_0x4eb9c1,function(_0x248b3b){var _0x4ee683=_['find'](_0x110c5e[_0x34ff('0x63')],['id',_0x248b3b['id']]);if(!_0x4ee683||!_0x248b3b[_0x34ff('0xac')]){_0x248b3b[_0x34ff('0x2a')]=_0x34ff('0x185');}else if(_0x4ee683[_0x34ff('0xae')]){_0x248b3b['status']=_0x34ff('0xfe');}else{_0x248b3b[_0x34ff('0x2a')]=_['includes']([_0x34ff('0x186'),_0x34ff('0x187'),'unavailable',_0x34ff('0x188'),null,undefined],_0x4ee683[_0x34ff('0x189')])?'online':_0x34ff('0x18a');}return _0x248b3b;});});});})[_0x34ff('0x35')](function(_0x4152f1){if(!_0x2c78d2[_0x34ff('0x4e')][_0x34ff('0x54')]('nolimit')){_0x91c2c2[_0x34ff('0x2e')]=qs[_0x34ff('0x2e')](_0x2c78d2[_0x34ff('0x4e')][_0x34ff('0x2e')]||0xa);_0x91c2c2[_0x34ff('0x2d')]=qs[_0x34ff('0x2d')](_0x2c78d2[_0x34ff('0x4e')]['offset']);}_0x265d1c[_0x34ff('0x2c')]=_0x4152f1[_0x34ff('0x53')];_0x265d1c[_0x34ff('0x63')]=_0x91c2c2['limit']?_0x4152f1[_0x34ff('0x18b')](_0x91c2c2[_0x34ff('0x2d')],_0x91c2c2[_0x34ff('0x2d')]+_0x91c2c2[_0x34ff('0x2e')]):_0x4152f1;return _0x265d1c;})['then'](respondWithFilteredResult(_0x5b6a59,_0x91c2c2))[_0x34ff('0x28')](handleError(_0x5b6a59,null));};
\ No newline at end of file