Built motion from commit e0fa946e.|2.6.5
[motion2.git] / server / api / user / user.controller.js
index db84118..b2257be 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xdc60=['attributes','length','hasOwnProperty','nolimit','query','order','sort','where','pick','merge','sequelize','lower','options','User','includeAll','rows','show','salt','intersection','include','body','params','describe','addContacts','ids','omit','Setting','securePassword','max','internal','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)','QueryTypes','SELECT','from','mailbox','email','permissions','101','102','103','113','110','105','106','107','108','111','114','create','Unauthorized','admin','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','userProfileId','VoiceMail','UserProfileSection','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','push','all','each','findAll','isEmpty','compact','changePassword','oldPassword','newPassword','Invalid\x20body\x20format.\x20Use\x20oldPassword\x20and\x20newPassword','Sequelize','ValidationError','Wrong\x20credentials','New\x20password\x20must\x20be\x20different\x20from\x20old\x20password','findOne','passwordHistoryLimit','validatePasswordPattern','enforcePasswordHistory','previousPasswords','validatePasswordHistory','channel','online','loginInPause','voicePause','interface','isValidChannel','Unknown\x20channel','add','capitalize','toLowerCase','penalty','spread','QueueId','Queue:save','voice','VoiceQueue','format','SIP/%s','UserVoiceQueueRt','removeQueues','remove','Queues','emit','Queue:remove','filename','getAvatar','join','root','server/files/images/logos/default_profile.png','userpic','download','existsSync','server/files/images/','getContacts','List','Tag','color','tag','Queue','getVoiceQueuesRt','ChatGroup','getGroups','getRecordings','VoiceRecording','UserId','ScreenRecording','getChatInteractions','getOpenchannelInteractions','OpenchannelInteraction','MailInteraction','getSmsInteractions','SmsInteraction','FaxInteraction','getFaxInteractions','getWhatsappInteractions','WhatsappInteraction','login','phone','mobile','intrf','user:%s','user:forcelogout','headers','x-forwarded-for','connection','remoteAddress','socket','User\x20not\x20found\x20or\x20not\x20allowed\x20to\x20perform\x20login\x20method','getVoiceQueues','UserVoiceQueue.penalty','upsert','forEach','getChannels','YYYY-MM-DD\x20HH:mm:ss','LOGIN','device','MemberReport','concat','LOGININPAUSE','isMiddleware','resolve','logout','pause','QueuePause','PAUSE','DEFAULT\x20PAUSE','unpause','chatPause','openchannelPause','whatsapppause','pauseType','lastPauseAt','manual','mail','chat','fax','sms','whatsapp','openchannel','set','%s%s','getTeams','addTeams','Team','setDataValue','Voice','getChatQueues','Chat','Mail','getSmsQueues','getWhatsappQueues','getFaxQueues','Fax','getOpenchannelQueues','Openchannel','flatten','transaction','addAgent','getDataValue','removeTeams','getMailQueues','Whatsapp','removeAgent','getLists','CmList','getAgents','values','You\x20can\x27t\x20delete\x20yourself','addChatInteractions','user_has_chat_interactions:save','removeChatInteractions','isArray','user_has_chat_interactions:remove','addMailInteractions','user_has_mail_interactions:save','removeMailInteractions','user_has_mail_interactions:remove','addFaxInteractions','user_has_fax_interactions:save','removeFaxInteractions','user_has_fax_interactions:remove','addSmsInteractions','removeSmsInteractions','user_has_sms_interactions:remove','addOpenchannelInteractions','user_has_openchannel_interactions:save','removeOpenchannelInteractions','user_has_openchannel_interactions:remove','addWhatsappInteractions','user_has_whatsapp_interactions:save','removeWhatsappInteractions','getVoicePrefixes','VoicePrefix','getFaxAccounts','FaxAccount','addFaxAccounts','getMailAccounts','addMailAccounts','removeMailAccounts','getOpenchannelAccounts','OpenchannelAccount','addOpenchannelAccounts','removeOpenchannelAccounts','getSmsAccounts','SmsAccount','addSmsAccounts','removeSmsAccounts','getChatWebsites','ChatWebsite','addChatWebsites','removeChatWebsites','getWhatsappAccounts','WhatsappAccount','addWhatsappAccounts','SquareProject','getSquareProjects','addSquareProjects','removeSquareProjects','getScheduledCalls','CmHopper','$and','$or','$gt','$gte','$lte','$ne','$not','$notBetween','$in','$notIn','$like','$notLike','$iLike','$notILike','$overlap','$contains','$any','firstName','CmContact','dialActive','getApiKey','retrieveApiKey','token','No\x20API\x20access\x20key\x20found!','createApiKey','generateApiKey','iat','nonce','You\x20don\x27t\x20have\x20sufficient\x20privileges\x20to\x20access\x20this\x20resource.','removeApiKey','apiKeyNonce','apiKeyIat','API\x20key\x20not\x20available','whoami','Unable\x20to\x20retrieve\x20the\x20current\x20user','html-pdf','eml-format','zip-dir','fast-json-patch','request-promise','moment','bluebird','util','path','sox','to-csv','ejs','lodash','squel','crypto','jsforce','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../mysqldb','redis','socket.io-emitter','./user.socket','register','jayson/promise','client','http','request','then','info','User,\x20%s,\x20%s','request\x20sent','debug','User,\x20%s,\x20%s,\x20%s','stringify','error','message','result','catch','status','end','json','count','offset','limit','Content-Range','apply','reject','save','update','destroy','get','role','Users','user','Agents','agent','Telephones','telephone','filter','map','value','includes','find','name','UserProfileResource','sendStatus','stack','send','index','rawAttributes','fieldName','type','key','model','differenceBy','password','keys','filters','fields'];(function(_0x20a584,_0xe384a5){var _0x4b41a8=function(_0x2127c6){while(--_0x2127c6){_0x20a584['push'](_0x20a584['shift']());}};_0x4b41a8(++_0xe384a5);}(_0xdc60,0x12b));var _0x0dc6=function(_0x5f1431,_0x49bea0){_0x5f1431=_0x5f1431-0x0;var _0x165500=_0xdc60[_0x5f1431];return _0x165500;};'use strict';var pdf=require(_0x0dc6('0x0'));var emlformat=require(_0x0dc6('0x1'));var rimraf=require('rimraf');var zipdir=require(_0x0dc6('0x2'));var jsonpatch=require(_0x0dc6('0x3'));var rp=require(_0x0dc6('0x4'));var moment=require(_0x0dc6('0x5'));var BPromise=require(_0x0dc6('0x6'));var Mustache=require('mustache');var util=require(_0x0dc6('0x7'));var path=require(_0x0dc6('0x8'));var sox=require(_0x0dc6('0x9'));var csv=require(_0x0dc6('0xa'));var ejs=require(_0x0dc6('0xb'));var fs=require('fs');var _=require(_0x0dc6('0xc'));var squel=require(_0x0dc6('0xd'));var crypto=require(_0x0dc6('0xe'));var jsforce=require(_0x0dc6('0xf'));var deskjs=require('desk.js');var toCsv=require(_0x0dc6('0xa'));var querystring=require('querystring');var Papa=require('papaparse');var Redis=require(_0x0dc6('0x10'));var authService=require(_0x0dc6('0x11'));var qs=require(_0x0dc6('0x12'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x0dc6('0x13'));var logger=require(_0x0dc6('0x14'))(_0x0dc6('0x15'));var utils=require(_0x0dc6('0x16'));var config=require(_0x0dc6('0x17'));var licenseUtil=require('../../config/license/util');var db=require(_0x0dc6('0x18'))['db'];config[_0x0dc6('0x19')]=_['defaults'](config[_0x0dc6('0x19')],{'host':'localhost','port':0x18eb});var socket=require(_0x0dc6('0x1a'))(new Redis(config[_0x0dc6('0x19')]));require(_0x0dc6('0x1b'))[_0x0dc6('0x1c')](socket);var jayson=require(_0x0dc6('0x1d'));var client=jayson[_0x0dc6('0x1e')][_0x0dc6('0x1f')]({'port':0x232a});function respondWithRpcPromise(_0xebc09a,_0x30bb41,_0x337b5e,_0x472bf5){return new BPromise(function(_0x4812de,_0x4c5a26){var _0x429a2e=_0x472bf5||client;return _0x429a2e[_0x0dc6('0x20')](_0xebc09a,_0x337b5e)[_0x0dc6('0x21')](function(_0x1a7f97){logger[_0x0dc6('0x22')](_0x0dc6('0x23'),_0x30bb41,_0x0dc6('0x24'));logger[_0x0dc6('0x25')](_0x0dc6('0x26'),_0x30bb41,_0x0dc6('0x24'),JSON[_0x0dc6('0x27')](_0x1a7f97));if(_0x1a7f97['error']){if(_0x1a7f97[_0x0dc6('0x28')]['code']===0x1f4){logger[_0x0dc6('0x28')]('User,\x20%s,\x20%s',_0x30bb41,_0x1a7f97[_0x0dc6('0x28')][_0x0dc6('0x29')]);return _0x4c5a26(_0x1a7f97[_0x0dc6('0x28')][_0x0dc6('0x29')]);}logger[_0x0dc6('0x28')](_0x0dc6('0x23'),_0x30bb41,_0x1a7f97[_0x0dc6('0x28')][_0x0dc6('0x29')]);return _0x4812de(_0x1a7f97['error']['message']);}else{logger[_0x0dc6('0x22')](_0x0dc6('0x23'),_0x30bb41,_0x0dc6('0x24'));_0x4812de(_0x1a7f97[_0x0dc6('0x2a')][_0x0dc6('0x29')]);}})[_0x0dc6('0x2b')](function(_0x46d13b){logger[_0x0dc6('0x28')](_0x0dc6('0x23'),_0x30bb41,_0x46d13b);_0x4c5a26(_0x46d13b);});});}function respondWithStatusCode(_0x56b7ef,_0x5727ec){_0x5727ec=_0x5727ec||0xcc;return function(_0x41613c){if(_0x41613c){return _0x56b7ef['sendStatus'](_0x5727ec);}return _0x56b7ef[_0x0dc6('0x2c')](_0x5727ec)[_0x0dc6('0x2d')]();};}function respondWithResult(_0x5a89ec,_0x36c670){_0x36c670=_0x36c670||0xc8;return function(_0x3fae06){if(_0x3fae06){return _0x5a89ec[_0x0dc6('0x2c')](_0x36c670)[_0x0dc6('0x2e')](_0x3fae06);}};}function respondWithFilteredResult(_0x42d782,_0x8cf804){return function(_0x519241){if(_0x519241){var _0x14549c=_0x519241[_0x0dc6('0x2f')],_0x2eddbf=_0x8cf804[_0x0dc6('0x30')],_0x2c9cd7=_0x8cf804[_0x0dc6('0x30')]+_0x8cf804[_0x0dc6('0x31')],_0x4f010a;if(_0x2c9cd7>=_0x14549c){_0x2c9cd7=_0x14549c;_0x4f010a=0xc8;}else{_0x4f010a=0xce;}_0x42d782[_0x0dc6('0x2c')](_0x4f010a);return _0x42d782['set'](_0x0dc6('0x32'),_0x2eddbf+'-'+_0x2c9cd7+'/'+_0x14549c)[_0x0dc6('0x2e')](_0x519241);}return null;};}function patchUpdates(_0x42113e){return function(_0x49b503){try{jsonpatch[_0x0dc6('0x33')](_0x49b503,_0x42113e,!![]);}catch(_0x3d0594){return BPromise[_0x0dc6('0x34')](_0x3d0594);}return _0x49b503[_0x0dc6('0x35')]();};}function saveUpdates(_0x1451ce,_0x51c7a4){return function(_0x9ecf72){if(_0x9ecf72){return _0x9ecf72[_0x0dc6('0x36')](_0x1451ce)[_0x0dc6('0x21')](function(_0x15e541){return _0x15e541;});}return null;};}function removeEntity(_0x3c40af,_0x41173c){return function(_0x21ecfe){if(_0x21ecfe){return _0x21ecfe[_0x0dc6('0x37')]()[_0x0dc6('0x21')](function(){var _0x3e04bf=_0x21ecfe[_0x0dc6('0x38')]({'plain':!![]});if(_0x3e04bf[_0x0dc6('0x39')]==='admin')return;var _0x5b527a=[{'name':_0x0dc6('0x3a'),'value':_0x0dc6('0x3b'),'ignore':!![]},{'name':_0x0dc6('0x3c'),'value':_0x0dc6('0x3d'),'ignore':![]},{'name':_0x0dc6('0x3e'),'value':_0x0dc6('0x3f'),'ignore':![]}];var _0x543e61=_(_0x5b527a)[_0x0dc6('0x40')]('ignore')[_0x0dc6('0x41')](_0x0dc6('0x42'))[_0x0dc6('0x42')]();if(_[_0x0dc6('0x43')](_0x543e61,_0x3e04bf[_0x0dc6('0x39')])){return;}var _0x3bf52b=_[_0x0dc6('0x44')](_0x5b527a,[_0x0dc6('0x42'),_0x3e04bf[_0x0dc6('0x39')]])[_0x0dc6('0x45')];return db[_0x0dc6('0x46')][_0x0dc6('0x37')]({'where':{'type':_0x3bf52b,'resourceId':_0x3e04bf['id']}})[_0x0dc6('0x21')](function(){return _0x21ecfe;});})[_0x0dc6('0x21')](function(){_0x3c40af[_0x0dc6('0x2c')](0xcc)['end']();});}};}function handleEntityNotFound(_0x44de63,_0x442d28){return function(_0x969070){if(!_0x969070){_0x44de63[_0x0dc6('0x47')](0x194);}return _0x969070;};}function handleError(_0xe19e3e,_0x40a818){_0x40a818=_0x40a818||0x1f4;return function(_0x256048){logger[_0x0dc6('0x28')](_0x256048[_0x0dc6('0x48')]);if(_0x256048['name']){delete _0x256048['name'];}_0xe19e3e[_0x0dc6('0x2c')](_0x40a818)[_0x0dc6('0x49')](_0x256048);};}exports[_0x0dc6('0x4a')]=function(_0x47ffc6,_0x267c81){var _0x2aa3f4={},_0x20e51f={},_0x4fff76={'count':0x0,'rows':[]};var _0x275e77=_[_0x0dc6('0x41')](db['User'][_0x0dc6('0x4b')],function(_0x3603c5){return{'name':_0x3603c5[_0x0dc6('0x4c')],'type':_0x3603c5[_0x0dc6('0x4d')][_0x0dc6('0x4e')]};});_0x20e51f[_0x0dc6('0x4f')]=_[_0x0dc6('0x50')](_[_0x0dc6('0x41')](_0x275e77,_0x0dc6('0x45')),[_0x0dc6('0x51'),'salt']);_0x20e51f['query']=_[_0x0dc6('0x52')](_0x47ffc6['query']);_0x20e51f[_0x0dc6('0x53')]=_['intersection'](_0x20e51f[_0x0dc6('0x4f')],_0x20e51f['query']);_0x2aa3f4['attributes']=_['intersection'](_0x20e51f['model'],qs[_0x0dc6('0x54')](_0x47ffc6['query'][_0x0dc6('0x54')]));_0x2aa3f4[_0x0dc6('0x55')]=_0x2aa3f4[_0x0dc6('0x55')][_0x0dc6('0x56')]?_0x2aa3f4[_0x0dc6('0x55')]:_0x20e51f[_0x0dc6('0x4f')];if(!_0x47ffc6['query'][_0x0dc6('0x57')](_0x0dc6('0x58'))){_0x2aa3f4['limit']=qs[_0x0dc6('0x31')](_0x47ffc6[_0x0dc6('0x59')][_0x0dc6('0x31')]);_0x2aa3f4[_0x0dc6('0x30')]=qs['offset'](_0x47ffc6[_0x0dc6('0x59')]['offset']);}_0x2aa3f4[_0x0dc6('0x5a')]=qs['sort'](_0x47ffc6[_0x0dc6('0x59')][_0x0dc6('0x5b')]);_0x2aa3f4[_0x0dc6('0x5c')]=qs[_0x0dc6('0x53')](_[_0x0dc6('0x5d')](_0x47ffc6[_0x0dc6('0x59')],_0x20e51f['filters']),_0x275e77);if(_0x47ffc6['query'][_0x0dc6('0x40')]){_0x2aa3f4[_0x0dc6('0x5c')]=_[_0x0dc6('0x5e')](_0x2aa3f4[_0x0dc6('0x5c')],{'$or':_[_0x0dc6('0x41')](_0x275e77,function(_0x186118){if(_0x186118['type']!=='VIRTUAL'){return db[_0x0dc6('0x5f')][_0x0dc6('0x5c')](db[_0x0dc6('0x5f')]['fn'](_0x0dc6('0x60'),db[_0x0dc6('0x5f')]['col'](_0x186118[_0x0dc6('0x45')])),{'$like':db[_0x0dc6('0x5f')]['fn'](_0x0dc6('0x60'),'%'+_0x47ffc6['query']['filter']+'%')});}})});}_0x2aa3f4=_[_0x0dc6('0x5e')]({},_0x2aa3f4,_0x47ffc6[_0x0dc6('0x61')]);var _0x5e379b={'where':_0x2aa3f4[_0x0dc6('0x5c')]};return db[_0x0dc6('0x62')][_0x0dc6('0x2f')](_0x5e379b)[_0x0dc6('0x21')](function(_0x2c7277){_0x4fff76[_0x0dc6('0x2f')]=_0x2c7277;if(_0x47ffc6[_0x0dc6('0x59')][_0x0dc6('0x63')]){_0x2aa3f4['include']=[{'all':!![]}];}return db[_0x0dc6('0x62')]['findAll'](_0x2aa3f4);})[_0x0dc6('0x21')](function(_0x3339ea){_0x4fff76[_0x0dc6('0x64')]=_0x3339ea;return _0x4fff76;})['then'](respondWithFilteredResult(_0x267c81,_0x2aa3f4))['catch'](handleError(_0x267c81,null));};exports[_0x0dc6('0x65')]=function(_0x13dbe5,_0x55dce5){var _0x2e0232={'raw':![],'where':{'id':_0x13dbe5['params']['id']}},_0x11b5e1={};_0x11b5e1[_0x0dc6('0x4f')]=_[_0x0dc6('0x50')](_[_0x0dc6('0x52')](db[_0x0dc6('0x62')]['rawAttributes']),[_0x0dc6('0x51'),_0x0dc6('0x66')]);_0x11b5e1['query']=_[_0x0dc6('0x52')](_0x13dbe5[_0x0dc6('0x59')]);_0x11b5e1[_0x0dc6('0x53')]=_[_0x0dc6('0x67')](_0x11b5e1[_0x0dc6('0x4f')],_0x11b5e1[_0x0dc6('0x59')]);_0x2e0232[_0x0dc6('0x55')]=_[_0x0dc6('0x67')](_0x11b5e1[_0x0dc6('0x4f')],qs[_0x0dc6('0x54')](_0x13dbe5[_0x0dc6('0x59')][_0x0dc6('0x54')]));_0x2e0232['attributes']=_0x2e0232[_0x0dc6('0x55')][_0x0dc6('0x56')]?_0x2e0232[_0x0dc6('0x55')]:_0x11b5e1['model'];if(_0x13dbe5[_0x0dc6('0x59')]['includeAll']){_0x2e0232[_0x0dc6('0x68')]=[{'all':!![]}];}_0x2e0232=_[_0x0dc6('0x5e')]({},_0x2e0232,_0x13dbe5['options']);return db[_0x0dc6('0x62')][_0x0dc6('0x44')](_0x2e0232)[_0x0dc6('0x21')](handleEntityNotFound(_0x55dce5,null))['then'](respondWithResult(_0x55dce5,null))[_0x0dc6('0x2b')](handleError(_0x55dce5,null));};exports[_0x0dc6('0x36')]=function(_0x3e6222,_0x1ffc62){if(_0x3e6222[_0x0dc6('0x69')]['id']){delete _0x3e6222[_0x0dc6('0x69')]['id'];}delete _0x3e6222[_0x0dc6('0x69')][_0x0dc6('0x39')];return db['User'][_0x0dc6('0x44')]({'where':{'id':_0x3e6222[_0x0dc6('0x6a')]['id']}})['then'](handleEntityNotFound(_0x1ffc62,null))[_0x0dc6('0x21')](saveUpdates(_0x3e6222[_0x0dc6('0x69')],null))[_0x0dc6('0x21')](respondWithResult(_0x1ffc62,null))['catch'](handleError(_0x1ffc62,null));};exports['describe']=function(_0x56cee8,_0x5a85e9){return db[_0x0dc6('0x62')][_0x0dc6('0x6b')]()[_0x0dc6('0x21')](respondWithResult(_0x5a85e9,null))[_0x0dc6('0x2b')](handleError(_0x5a85e9,null));};exports['addContacts']=function(_0x160f96,_0x10e579,_0x15d376){return db[_0x0dc6('0x62')][_0x0dc6('0x44')]({'where':{'id':_0x160f96[_0x0dc6('0x6a')]['id']}})['then'](handleEntityNotFound(_0x10e579,null))[_0x0dc6('0x21')](function(_0x4688b6){if(_0x4688b6){return _0x4688b6[_0x0dc6('0x6c')](_0x160f96[_0x0dc6('0x69')][_0x0dc6('0x6d')],_[_0x0dc6('0x6e')](_0x160f96[_0x0dc6('0x69')],[_0x0dc6('0x6d'),'id'])||{});}})[_0x0dc6('0x21')](respondWithResult(_0x10e579,null))[_0x0dc6('0x2b')](handleError(_0x10e579,null));};function validateUser(_0x2cf51c){return new BPromise(function(_0x20ea47,_0x148611){if(_0x2cf51c['internal'])return _0x20ea47(_0x2cf51c);return db[_0x0dc6('0x6f')]['findById'](0x1)['then'](function(_0x4840f7){if(_0x4840f7[_0x0dc6('0x70')])authService['validatePasswordPattern'](_0x2cf51c[_0x0dc6('0x51')]);db[_0x0dc6('0x62')][_0x0dc6('0x71')](_0x0dc6('0x72'))['then'](function(_0x4137f3){if(_[_0x0dc6('0x73')](_0x4137f3)){_0x2cf51c[_0x0dc6('0x72')]=_0x4840f7[_0x0dc6('0x74')]||0x1;return;}if(_[_0x0dc6('0x73')](_0x4840f7[_0x0dc6('0x74')])||_0x4840f7[_0x0dc6('0x74')]===_0x4137f3){_0x2cf51c[_0x0dc6('0x72')]=_0x4137f3+0x1;return;}if(_0x4840f7[_0x0dc6('0x74')]>_0x4137f3){_0x2cf51c[_0x0dc6('0x72')]=_0x4840f7['min_internal'];return;}return db['sequelize']['query'](_0x0dc6('0x75'),{'type':db[_0x0dc6('0x5f')][_0x0dc6('0x76')][_0x0dc6('0x77')]})[_0x0dc6('0x21')](function(_0x4f6611){if(_0x4f6611&&_0x4f6611[_0x0dc6('0x56')]){for(var _0x3abc6d=0x0,_0x514101=_0x4f6611[_0x0dc6('0x56')];_0x3abc6d<_0x514101&&_[_0x0dc6('0x73')](_0x2cf51c[_0x0dc6('0x72')]);_0x3abc6d++){if(_0x4840f7[_0x0dc6('0x74')]<=_0x4f6611[_0x3abc6d]['from']){_0x2cf51c[_0x0dc6('0x72')]=_0x4f6611[_0x3abc6d][_0x0dc6('0x78')];}else if(_0x4840f7[_0x0dc6('0x74')]>_0x4f6611[_0x3abc6d][_0x0dc6('0x78')]&&_0x4840f7['min_internal']<=_0x4f6611[_0x3abc6d]['to']){_0x2cf51c[_0x0dc6('0x72')]=_0x4840f7[_0x0dc6('0x74')];}}}if(_['isNil'](_0x2cf51c[_0x0dc6('0x72')])){_0x2cf51c['internal']=_0x4137f3+0x1;}return _0x20ea47(_0x2cf51c);});});})[_0x0dc6('0x2b')](function(_0x2e4b02){_0x148611(_0x2e4b02);});});}function updateUser(_0x38e425){return new BPromise(function(_0x59b6df,_0x297361){try{if(_0x38e425['voicemail']){_0x38e425[_0x0dc6('0x79')]=_0x38e425[_0x0dc6('0x72')];_0x38e425['VoiceMail']={'mailbox':_0x38e425['internal'],'password':_0x38e425[_0x0dc6('0x51')],'fullname':_0x38e425['fullname'],'email':_0x38e425[_0x0dc6('0x7a')]};}if(_0x38e425[_0x0dc6('0x39')]===_0x0dc6('0x3d')){if(!_0x38e425[_0x0dc6('0x7b')])_0x38e425['permissions']=[_0x0dc6('0x7c'),_0x0dc6('0x7d'),_0x0dc6('0x7e'),_0x0dc6('0x7f'),_0x0dc6('0x80'),'104',_0x0dc6('0x81'),_0x0dc6('0x82'),_0x0dc6('0x83'),_0x0dc6('0x84'),'109','100',_0x0dc6('0x85'),_0x0dc6('0x86')];}_0x59b6df(_0x38e425);}catch(_0x2d0b92){_0x297361(_0x2d0b92);}});}exports[_0x0dc6('0x87')]=function(_0x461384,_0x442d68){if(_0x461384[_0x0dc6('0x3b')][_0x0dc6('0x39')]===_0x0dc6('0x3d'))throw new Error(_0x0dc6('0x88'));if(_0x461384[_0x0dc6('0x69')][_0x0dc6('0x39')]==='user'&&_0x461384['user'][_0x0dc6('0x39')]!==_0x0dc6('0x89')){throw new Error(_0x0dc6('0x8a'));}if(_0x461384['body'][_0x0dc6('0x39')]===_0x0dc6('0x89')&&_0x461384[_0x0dc6('0x3b')][_0x0dc6('0x39')]!==_0x0dc6('0x89')){throw new Error(_0x0dc6('0x8b'));}return licenseUtil[_0x0dc6('0x8c')]([_0x461384[_0x0dc6('0x69')]])[_0x0dc6('0x21')](function(){return validateUser(_0x461384[_0x0dc6('0x69')]);})[_0x0dc6('0x21')](function(_0xae5f9d){return updateUser(_0xae5f9d)[_0x0dc6('0x21')](function(_0x41a7e8){if(_0x41a7e8[_0x0dc6('0x39')]===_0x0dc6('0x89')){_0x41a7e8['settingsEnabled']=_0x461384[_0x0dc6('0x3b')]['settingsEnabled'];delete _0x41a7e8[_0x0dc6('0x8d')];}return _0x41a7e8;});})[_0x0dc6('0x21')](function(_0xe97213){return db[_0x0dc6('0x62')][_0x0dc6('0x87')](_0xe97213,{'include':[{'model':db[_0x0dc6('0x8e')],'as':_0x0dc6('0x8e')}]});})[_0x0dc6('0x21')](function(_0x22eb57){if(_0x461384[_0x0dc6('0x69')][_0x0dc6('0x39')]===_0x0dc6('0x3b'))return _0x22eb57;if(_0x461384[_0x0dc6('0x3b')][_0x0dc6('0x39')]!==_0x0dc6('0x3b'))return _0x22eb57;return db[_0x0dc6('0x8f')][_0x0dc6('0x44')]({'where':{'name':_0x22eb57[_0x0dc6('0x39')]===_0x0dc6('0x3d')?_0x0dc6('0x3c'):_0x0dc6('0x3e'),'userProfileId':_0x461384[_0x0dc6('0x3b')]['userProfileId']},'raw':!![]})[_0x0dc6('0x21')](function(_0x169fdd){if(!_0x169fdd||_0x169fdd[_0x0dc6('0x90')]!=0x0)return _0x22eb57;return db[_0x0dc6('0x46')]['create']({'name':_0x22eb57[_0x0dc6('0x45')],'resourceId':_0x22eb57['id'],'type':_0x169fdd[_0x0dc6('0x45')],'sectionId':_0x169fdd['id']},{})[_0x0dc6('0x21')](function(){return _0x22eb57;});})[_0x0dc6('0x2b')](function(_0x23dffc){logger[_0x0dc6('0x28')](_0x0dc6('0x91'),_0x23dffc);throw _0x23dffc;});})[_0x0dc6('0x21')](respondWithResult(_0x442d68,0xc9))['catch'](handleError(_0x442d68,null));};exports[_0x0dc6('0x92')]=function(_0xf625ee,_0x15d714){var _0x4035b2=_0xf625ee[_0x0dc6('0x69')];var _0x387498=[];if(_0xf625ee['user']['role']===_0x0dc6('0x3d'))throw new Error(_0x0dc6('0x88'));if(_['some'](_0x4035b2,[_0x0dc6('0x39'),_0x0dc6('0x3b')])&&_0xf625ee['user'][_0x0dc6('0x39')]!==_0x0dc6('0x89')){throw new Error(_0x0dc6('0x8a'));}if(_[_0x0dc6('0x93')](_0x4035b2,[_0x0dc6('0x39'),_0x0dc6('0x89')])&&_0xf625ee[_0x0dc6('0x3b')]['role']!==_0x0dc6('0x89')){throw new Error(_0x0dc6('0x94'));}return licenseUtil[_0x0dc6('0x8c')](_0x4035b2)[_0x0dc6('0x21')](function(){return validateUser(_0x4035b2[0x0]);})[_0x0dc6('0x21')](function(){for(var _0x181f15=0x1;_0x181f15<_0x4035b2[_0x0dc6('0x56')];_0x181f15++){var _0x54fef9=_0x4035b2[_0x181f15-0x1][_0x0dc6('0x72')];if(!_0x4035b2[_0x181f15][_0x0dc6('0x72')])_0x4035b2[_0x181f15]['internal']=_0x54fef9+0x1;_0x387498[_0x0dc6('0x95')](validateUser(_0x4035b2[_0x181f15]));}return BPromise[_0x0dc6('0x96')](_0x387498);})[_0x0dc6('0x21')](function(){_0x387498=[];for(var _0x149580=0x0;_0x149580<_0x4035b2[_0x0dc6('0x56')];_0x149580++){_0x387498[_0x0dc6('0x95')](updateUser(_0x4035b2[_0x149580]));}return BPromise[_0x0dc6('0x96')](_0x387498);})[_0x0dc6('0x21')](function(){return BPromise[_0x0dc6('0x97')](_0x4035b2,function(_0x307ba3){return db[_0x0dc6('0x62')]['create'](_0x307ba3,{'include':[{'model':db[_0x0dc6('0x8e')],'as':_0x0dc6('0x8e')}]})['then'](function(_0x9a5b47){_0x307ba3['id']=_0x9a5b47['id'];return _0x307ba3;});});})['then'](function(_0x43db69){if(_0xf625ee[_0x0dc6('0x69')][_0x0dc6('0x39')]==='user')return _0x43db69;if(_0xf625ee['user'][_0x0dc6('0x39')]!==_0x0dc6('0x3b'))return _0x43db69;var _0x3a0c9f=_['some'](_0x43db69,function(_0x5dbf31){return _0x5dbf31[_0x0dc6('0x39')]===_0x0dc6('0x3d')||_0x5dbf31['role']===_0x0dc6('0x3f');});if(!_0x3a0c9f)return _0x43db69;return db[_0x0dc6('0x8f')][_0x0dc6('0x98')]({'where':{'name':{'$or':[_0x0dc6('0x3c'),_0x0dc6('0x3e')]},'userProfileId':_0xf625ee[_0x0dc6('0x3b')][_0x0dc6('0x8d')]},'raw':!![]})[_0x0dc6('0x21')](function(_0x29a5a1){if(_[_0x0dc6('0x99')](_0x29a5a1)||!_[_0x0dc6('0x93')](_0x29a5a1,['autoAssociation',0x0]))return _0x43db69;_0x387498=[];var _0x1715c5=_(_0x29a5a1)[_0x0dc6('0x41')](function(_0x1a8cc7){if(_0x1a8cc7[_0x0dc6('0x90')]===0x1)return;return _0x1a8cc7[_0x0dc6('0x45')]===_0x0dc6('0x3c')?_0x0dc6('0x3d'):_0x0dc6('0x3f');})[_0x0dc6('0x9a')]()['value']();for(var _0x5d0e1b=0x0;_0x5d0e1b<_0x43db69[_0x0dc6('0x56')];_0x5d0e1b++){if(!_[_0x0dc6('0x43')](_0x1715c5,_0x43db69[_0x5d0e1b][_0x0dc6('0x39')]))return;var _0x37b05a=_0x43db69[_0x5d0e1b][_0x0dc6('0x39')]===_0x0dc6('0x3d')?_0x0dc6('0x3c'):_0x0dc6('0x3e');_0x387498['push'](db['UserProfileResource'][_0x0dc6('0x87')]({'name':_0x43db69[_0x5d0e1b][_0x0dc6('0x45')],'resourceId':_0x43db69[_0x5d0e1b]['id'],'type':_0x37b05a,'sectionId':_['find'](_0x29a5a1,[_0x0dc6('0x45'),_0x37b05a])['id']},{}));}return BPromise[_0x0dc6('0x96')](_0x387498);})[_0x0dc6('0x21')](respondWithResult(_0x15d714,0xc9))[_0x0dc6('0x2b')](handleError(_0x15d714,null));});};exports[_0x0dc6('0x9b')]=function(_0x361771,_0x24a0e7,_0x27a0ea){if(_0x361771[_0x0dc6('0x69')]['id']){delete _0x361771['body']['id'];}return db[_0x0dc6('0x62')][_0x0dc6('0x44')]({'where':{'id':_0x361771[_0x0dc6('0x6a')]['id']}})[_0x0dc6('0x21')](function(_0x494112){if(!_0x494112)return null;if(_0x494112['id']===_0x361771[_0x0dc6('0x3b')]['id']){if(!_0x361771[_0x0dc6('0x69')][_0x0dc6('0x9c')]||!_0x361771[_0x0dc6('0x69')][_0x0dc6('0x9d')]){throw new db['Sequelize']['ValidationError'](_0x0dc6('0x9e'));}if(!_0x494112['authenticate'](_0x361771['body'][_0x0dc6('0x9c')])){throw new db[(_0x0dc6('0x9f'))][(_0x0dc6('0xa0'))](_0x0dc6('0xa1'));}if(_0x361771[_0x0dc6('0x69')][_0x0dc6('0x9c')]===_0x361771['body'][_0x0dc6('0x9d')]){throw new db[(_0x0dc6('0x9f'))]['ValidationError'](_0x0dc6('0xa2'));}}else if(_0x361771[_0x0dc6('0x3b')][_0x0dc6('0x39')]===_0x0dc6('0x89')){if(!_0x361771['body'][_0x0dc6('0x9d')]){throw new db[(_0x0dc6('0x9f'))]['ValidationError']('Invalid\x20body\x20format.\x20Use\x20newPassword');}}else if(_0x361771[_0x0dc6('0x3b')][_0x0dc6('0x39')]===_0x0dc6('0x3b')){if(!_0x361771[_0x0dc6('0x69')]['newPassword']){throw new db['Sequelize'][(_0x0dc6('0xa0'))]('Invalid\x20body\x20format.\x20Use\x20newPassword');}if(_0x494112[_0x0dc6('0x39')]!==_0x0dc6('0x3d')){throw new db[(_0x0dc6('0x9f'))]['ValidationError'](_0x0dc6('0x88'));}}else{throw new db[(_0x0dc6('0x9f'))][(_0x0dc6('0xa0'))](_0x0dc6('0x88'));}return _0x494112;})[_0x0dc6('0x21')](handleEntityNotFound(_0x24a0e7,null))[_0x0dc6('0x21')](function(_0x178117){return db[_0x0dc6('0x6f')][_0x0dc6('0xa3')]({'attributes':['id',_0x0dc6('0x70'),'enforcePasswordHistory',_0x0dc6('0xa4')]})[_0x0dc6('0x21')](function(_0x34f267){if(_0x34f267[_0x0dc6('0x70')])authService[_0x0dc6('0xa5')](_0x361771[_0x0dc6('0x69')]['newPassword']);if(!_0x34f267[_0x0dc6('0xa6')]||!_0x178117[_0x0dc6('0xa7')])return _0x178117;authService[_0x0dc6('0xa8')](_0x361771[_0x0dc6('0x69')]['newPassword'],_0x178117['previousPasswords'],_0x34f267[_0x0dc6('0xa4')]);return _0x178117;})[_0x0dc6('0x21')](saveUpdates({'password':_0x361771['body']['newPassword'],'passwordResetAt':_0x361771['user']['id']==_0x361771['params']['id']?moment():null,'previousPasswords':authService['updatePasswordsHistory'](_0x361771[_0x0dc6('0x69')]['newPassword'],_0x178117['previousPasswords'])},null));})[_0x0dc6('0x21')](respondWithResult(_0x24a0e7,null))[_0x0dc6('0x2b')](handleError(_0x24a0e7,null));};exports['addQueues']=function(_0x990a04,_0x45e2ac,_0x35a06d){var _0x569cb5=_0x990a04[_0x0dc6('0x69')][_0x0dc6('0xa9')];return db[_0x0dc6('0x62')][_0x0dc6('0x44')]({'where':{'id':_0x990a04[_0x0dc6('0x6a')]['id']},'attributes':['id',_0x0dc6('0x45'),_0x0dc6('0x39'),_0x0dc6('0xaa'),_0x0dc6('0xab'),_0x0dc6('0xac'),_0x0dc6('0xad')]})[_0x0dc6('0x21')](handleEntityNotFound(_0x45e2ac,null))[_0x0dc6('0x21')](function(_0x5e733f){if(_0x5e733f){if(!utils[_0x0dc6('0xae')](_0x569cb5)){throw new db['Sequelize'][(_0x0dc6('0xa0'))](_0x0dc6('0xaf'));}return _0x5e733f[_0x0dc6('0xb0')+_[_0x0dc6('0xb1')](_0x569cb5[_0x0dc6('0xb2')]())+'Queues'](_0x990a04['body'][_0x0dc6('0x6d')],{'penalty':_0x990a04['body'][_0x0dc6('0xb3')]||0x0})[_0x0dc6('0xb4')](function(_0x2254e8){for(var _0x20740b=0x0;_0x20740b<_0x990a04[_0x0dc6('0x69')][_0x0dc6('0x6d')]['length'];_0x20740b+=0x1){var _0x5da160={'UserId':_0x990a04['params']['id']};_0x5da160[_[_0x0dc6('0xb1')](_0x569cb5['toLowerCase']())+_0x0dc6('0xb5')]=_0x990a04['body']['ids'][_0x20740b];socket['emit'](_0x0dc6('0x3b')+_[_0x0dc6('0xb1')](_0x569cb5[_0x0dc6('0xb2')]())+_0x0dc6('0xb6'),_0x5da160);}return _0x2254e8;})[_0x0dc6('0x21')](function(){if(_0x569cb5===_0x0dc6('0xb7')){return db[_0x0dc6('0xb8')][_0x0dc6('0x98')]({'where':{'id':_0x990a04[_0x0dc6('0x69')]['ids']||[]},'raw':!![],'attributes':['id',_0x0dc6('0x45')]});}})[_0x0dc6('0x21')](function(_0xaa8d7f){var _0xc32ade=_0x5e733f[_0x0dc6('0x38')]({'plain':!![]});var _0x478345=[];if(_0x569cb5===_0x0dc6('0xb7')&&_0xc32ade[_0x0dc6('0x39')]===_0x0dc6('0x3d')&&_0xc32ade[_0x0dc6('0xaa')]){for(var _0x159e44=0x0;_0x159e44<_0xaa8d7f[_0x0dc6('0x56')];_0x159e44+=0x1){_0x478345['push']({'membername':_0xc32ade['name'],'UserId':_0xc32ade['id'],'queue_name':_0xaa8d7f[_0x159e44][_0x0dc6('0x45')],'VoiceQueueId':_0xaa8d7f[_0x159e44]['id'],'interface':_['isNil'](_0xc32ade[_0x0dc6('0xad')])?util[_0x0dc6('0xb9')](_0x0dc6('0xba'),_0xc32ade[_0x0dc6('0x45')]):_0xc32ade[_0x0dc6('0xad')],'paused':_0xc32ade['voicePause']||![],'penalty':_0x990a04['body'][_0x0dc6('0xb3')]||0x0});}return BPromise[_0x0dc6('0x97')](_0x478345,function(_0x541643){return db[_0x0dc6('0xbb')]['upsert'](_0x541643);});}return _0x5e733f;});}})['then'](respondWithStatusCode(_0x45e2ac,null))[_0x0dc6('0x2b')](handleError(_0x45e2ac,null));};exports[_0x0dc6('0xbc')]=function(_0x3197f8,_0x1944c3,_0x1926dd){var _0x20e893;return db[_0x0dc6('0x62')]['find']({'where':{'id':_0x3197f8[_0x0dc6('0x6a')]['id']},'attributes':['id',_0x0dc6('0x45'),_0x0dc6('0x39')]})['then'](handleEntityNotFound(_0x1944c3,null))['then'](function(_0x34a586){if(_0x34a586){_0x20e893=_0x34a586;if(!_0x3197f8[_0x0dc6('0x59')]['channel']||!utils['isValidChannel'](_0x3197f8['query'][_0x0dc6('0xa9')])){throw new db[(_0x0dc6('0x9f'))][(_0x0dc6('0xa0'))](_0x0dc6('0xaf'));}return _0x34a586[_0x0dc6('0xbd')+_[_0x0dc6('0xb1')](_0x3197f8[_0x0dc6('0x59')][_0x0dc6('0xa9')][_0x0dc6('0xb2')]())+_0x0dc6('0xbe')](_0x3197f8[_0x0dc6('0x59')][_0x0dc6('0x6d')]);}})['then'](function(_0x31325a){for(var _0x22dd2e=0x0;_0x22dd2e<_0x3197f8[_0x0dc6('0x59')]['ids'][_0x0dc6('0x56')];_0x22dd2e+=0x1){var _0xc2051b={'UserId':_0x3197f8[_0x0dc6('0x6a')]['id']};_0xc2051b[_['capitalize'](_0x3197f8[_0x0dc6('0x59')][_0x0dc6('0xa9')][_0x0dc6('0xb2')]())+_0x0dc6('0xb5')]=_0x3197f8['query'][_0x0dc6('0x6d')][_0x22dd2e];socket[_0x0dc6('0xbf')](_0x0dc6('0x3b')+_[_0x0dc6('0xb1')](_0x3197f8['query']['channel'][_0x0dc6('0xb2')]())+_0x0dc6('0xc0'),_0xc2051b);}return _0x31325a;})[_0x0dc6('0x21')](function(){if(_0x3197f8[_0x0dc6('0x59')][_0x0dc6('0xa9')]===_0x0dc6('0xb7')){return db['UserVoiceQueueRt'][_0x0dc6('0x37')]({'where':{'UserId':_0x3197f8[_0x0dc6('0x6a')]['id'],'VoiceQueueId':_0x3197f8[_0x0dc6('0x59')][_0x0dc6('0x6d')]},'individualHooks':!![]})[_0x0dc6('0x21')](function(){return _0x20e893;});}return _0x20e893;})['then'](respondWithStatusCode(_0x1944c3,null))[_0x0dc6('0x2b')](handleError(_0x1944c3,null));};exports['addAvatar']=function(_0x5a86b9,_0x473bbf,_0x187c6e){_0x5a86b9[_0x0dc6('0x69')]['userpic']=_0x5a86b9['file'][_0x0dc6('0xc1')];return db['User'][_0x0dc6('0x44')]({'where':{'id':_0x5a86b9[_0x0dc6('0x6a')]['id']}})[_0x0dc6('0x21')](handleEntityNotFound(_0x473bbf,null))[_0x0dc6('0x21')](saveUpdates(_0x5a86b9[_0x0dc6('0x69')],null))[_0x0dc6('0x21')](respondWithResult(_0x473bbf,null))['catch'](handleError(_0x473bbf,null));};exports[_0x0dc6('0xc2')]=function(_0x3406a3,_0x29c7a4,_0x57438d){var _0xb1fba4=path[_0x0dc6('0xc3')](config[_0x0dc6('0xc4')],_0x0dc6('0xc5'));return db['User'][_0x0dc6('0x44')]({'where':{'id':_0x3406a3[_0x0dc6('0x6a')]['id']},'attributes':['id',_0x0dc6('0xc6')],'raw':!![]})['then'](handleEntityNotFound(_0x29c7a4,null))[_0x0dc6('0x21')](function(_0x1c5bba){if(_0x1c5bba){if(_[_0x0dc6('0x73')](_0x1c5bba['userpic'])){return _0x29c7a4[_0x0dc6('0xc7')](_0xb1fba4);}else{if(!fs[_0x0dc6('0xc8')](path[_0x0dc6('0xc3')](config[_0x0dc6('0xc4')],_0x0dc6('0xc9'),_0x1c5bba['userpic']))){return _0x29c7a4[_0x0dc6('0xc7')](_0xb1fba4);}return _0x29c7a4[_0x0dc6('0xc7')](path[_0x0dc6('0xc3')](config['root'],_0x0dc6('0xc9'),_0x1c5bba['userpic']));}}})[_0x0dc6('0x2b')](handleError(_0x29c7a4,null));};exports[_0x0dc6('0xca')]=function(_0x552cfc,_0x424fa7,_0x5dc8c5){var _0x262a77={};var _0x28aca5={};var _0xee3981;var _0x261497;return db['User']['findOne']({'where':{'id':_0x552cfc[_0x0dc6('0x6a')]['id']}})[_0x0dc6('0x21')](handleEntityNotFound(_0x424fa7,null))[_0x0dc6('0x21')](function(_0x12bd34){if(_0x12bd34){_0xee3981=_0x12bd34;_0x28aca5[_0x0dc6('0x4f')]=_[_0x0dc6('0x52')](db['CmContact'][_0x0dc6('0x4b')]);_0x28aca5[_0x0dc6('0x59')]=_['keys'](_0x552cfc['query']);_0x28aca5[_0x0dc6('0x53')]=_[_0x0dc6('0x67')](_0x28aca5[_0x0dc6('0x4f')],_0x28aca5[_0x0dc6('0x59')]);_0x262a77[_0x0dc6('0x55')]=_['intersection'](_0x28aca5['model'],qs['fields'](_0x552cfc[_0x0dc6('0x59')][_0x0dc6('0x54')]));_0x262a77[_0x0dc6('0x55')]=_0x262a77[_0x0dc6('0x55')]['length']?_0x262a77[_0x0dc6('0x55')]:_0x28aca5[_0x0dc6('0x4f')];_0x262a77[_0x0dc6('0x5a')]=qs[_0x0dc6('0x5b')](_0x552cfc[_0x0dc6('0x59')][_0x0dc6('0x5b')]);_0x262a77[_0x0dc6('0x5c')]=qs[_0x0dc6('0x53')](_[_0x0dc6('0x5d')](_0x552cfc[_0x0dc6('0x59')],_0x28aca5['filters']));if(_0x552cfc[_0x0dc6('0x59')]['filter']){_0x262a77[_0x0dc6('0x5c')]=_[_0x0dc6('0x5e')](_0x262a77['where'],{'$or':_[_0x0dc6('0x41')](_0x262a77[_0x0dc6('0x55')],function(_0x52e0ef){var _0x268998={};_0x268998[_0x52e0ef]={'$like':'%'+_0x552cfc[_0x0dc6('0x59')][_0x0dc6('0x40')]+'%'};return _0x268998;})});}_0x262a77=_[_0x0dc6('0x5e')]({},_0x262a77,_0x552cfc[_0x0dc6('0x61')]);return _0xee3981[_0x0dc6('0xca')](_0x262a77);}})['then'](function(_0x5796c7){if(_0x5796c7){_0x261497=_0x5796c7[_0x0dc6('0x56')];if(_0x552cfc[_0x0dc6('0x59')][_0x0dc6('0x57')](_0x0dc6('0x63'))){_0x262a77[_0x0dc6('0x68')]=[{'model':db['CmList'],'as':_0x0dc6('0xcb'),'required':![]},{'model':db[_0x0dc6('0xcc')],'as':'Tags','attributes':['id',_0x0dc6('0x45'),_0x0dc6('0xcd')],'where':_0x552cfc[_0x0dc6('0x59')][_0x0dc6('0xce')]?{'id':_0x552cfc['query'][_0x0dc6('0xce')]}:undefined,'required':_0x552cfc['query'][_0x0dc6('0xce')]?!![]:![]}];}if(!_0x552cfc['query'][_0x0dc6('0x57')](_0x0dc6('0x58'))){_0x262a77['limit']=qs['limit'](_0x552cfc[_0x0dc6('0x59')]['limit']);_0x262a77['offset']=qs[_0x0dc6('0x30')](_0x552cfc[_0x0dc6('0x59')][_0x0dc6('0x30')]);}return _0xee3981[_0x0dc6('0xca')](_0x262a77);}})[_0x0dc6('0x21')](function(_0x5d8929){if(_0x5d8929){return _0x5d8929?{'count':_0x261497,'rows':_0x5d8929}:null;}})[_0x0dc6('0x21')](respondWithResult(_0x424fa7,null))[_0x0dc6('0x2b')](handleError(_0x424fa7,null));};exports['getQueues']=function(_0xe7b6e4,_0x31aac8,_0x5f32cb){var _0x15c87c;var _0x52cb43;var _0x2ad1ff={};var _0x2986d2;return db[_0x0dc6('0x62')][_0x0dc6('0xa3')]({'where':{'id':_0xe7b6e4['params']['id']},'attributes':['id','name',_0x0dc6('0x39')]})[_0x0dc6('0x21')](handleEntityNotFound(_0x31aac8,null))[_0x0dc6('0x21')](function(_0x34001c){if(!utils['isValidChannel'](_0xe7b6e4[_0x0dc6('0x59')]['channel'])){throw new db[(_0x0dc6('0x9f'))][(_0x0dc6('0xa0'))]('Unknown\x20channel');}_0x15c87c=_0x34001c;var _0x2a06ce={};_0x2a06ce[_0x0dc6('0x4f')]=_[_0x0dc6('0x52')](db[_['capitalize'](_0xe7b6e4[_0x0dc6('0x59')][_0x0dc6('0xa9')])+'Queue'][_0x0dc6('0x4b')]);_0x2a06ce['query']=_[_0x0dc6('0x52')](_0xe7b6e4[_0x0dc6('0x59')]);_0x2a06ce[_0x0dc6('0x53')]=_[_0x0dc6('0x67')](_0x2a06ce[_0x0dc6('0x4f')],_0x2a06ce[_0x0dc6('0x59')]);_0x2ad1ff[_0x0dc6('0x55')]=_[_0x0dc6('0x67')](_0x2a06ce[_0x0dc6('0x4f')],qs[_0x0dc6('0x54')](_0xe7b6e4['query'][_0x0dc6('0x54')]));_0x2ad1ff[_0x0dc6('0x55')]=_0x2ad1ff[_0x0dc6('0x55')][_0x0dc6('0x56')]?_0x2ad1ff[_0x0dc6('0x55')]:_0x2a06ce[_0x0dc6('0x4f')];_0x2ad1ff[_0x0dc6('0x5a')]=qs['sort'](_0xe7b6e4[_0x0dc6('0x59')][_0x0dc6('0x5b')]);_0x2ad1ff[_0x0dc6('0x5c')]=qs['filters'](_[_0x0dc6('0x5d')](_0xe7b6e4[_0x0dc6('0x59')],_0x2a06ce['filters']));if(_0xe7b6e4[_0x0dc6('0x59')][_0x0dc6('0x40')]){_0x2ad1ff[_0x0dc6('0x5c')]=_[_0x0dc6('0x5e')](_0x2ad1ff[_0x0dc6('0x5c')],{'$or':_[_0x0dc6('0x41')](_0x2ad1ff[_0x0dc6('0x55')],function(_0x62d04){var _0x1cf558={};_0x1cf558[_0x62d04]={'$like':'%'+_0xe7b6e4[_0x0dc6('0x59')][_0x0dc6('0x40')]+'%'};return _0x1cf558;})});}_0x2ad1ff=_[_0x0dc6('0x5e')]({},_0x2ad1ff,_0xe7b6e4[_0x0dc6('0x61')]);switch(_0x15c87c['role']){case _0x0dc6('0x89'):return db[_[_0x0dc6('0xb1')](_0xe7b6e4[_0x0dc6('0x59')][_0x0dc6('0xa9')])+'Queue']['findAll'](_0x2ad1ff);case _0x0dc6('0x3b'):case _0x0dc6('0x3d'):return _0x15c87c[_0x0dc6('0x38')+_[_0x0dc6('0xb1')](_0xe7b6e4[_0x0dc6('0x59')][_0x0dc6('0xa9')])+_0x0dc6('0xbe')](_0x2ad1ff);default:throw new db[(_0x0dc6('0x9f'))]['ValidationError']('Unknown\x20role');}})[_0x0dc6('0x21')](function(_0x9682cb){_0x2986d2=_0x9682cb[_0x0dc6('0x56')];if(!_0xe7b6e4[_0x0dc6('0x59')][_0x0dc6('0x57')](_0x0dc6('0x58'))){_0x2ad1ff[_0x0dc6('0x31')]=qs[_0x0dc6('0x31')](_0xe7b6e4[_0x0dc6('0x59')][_0x0dc6('0x31')]);_0x2ad1ff['offset']=qs[_0x0dc6('0x30')](_0xe7b6e4['query'][_0x0dc6('0x30')]);}switch(_0x15c87c[_0x0dc6('0x39')]){case'admin':return db[_[_0x0dc6('0xb1')](_0xe7b6e4['query']['channel'])+_0x0dc6('0xcf')]['findAll'](_0x2ad1ff);case _0x0dc6('0x3b'):case _0x0dc6('0x3d'):return _0x15c87c[_0x0dc6('0x38')+_[_0x0dc6('0xb1')](_0xe7b6e4[_0x0dc6('0x59')]['channel'])+_0x0dc6('0xbe')](_0x2ad1ff);}})[_0x0dc6('0x21')](function(_0x504e10){return{'count':_0x2986d2,'rows':_0x504e10};})['then'](respondWithResult(_0x31aac8,null))[_0x0dc6('0x2b')](handleError(_0x31aac8,null));};exports[_0x0dc6('0xd0')]=function(_0x51c299,_0xebfd67,_0x2f4272){var _0x5cbc67={};var _0x4cbe69={};var _0x550650;var _0x2e06b7;return db[_0x0dc6('0x62')][_0x0dc6('0xa3')]({'where':{'id':_0x51c299[_0x0dc6('0x6a')]['id']}})[_0x0dc6('0x21')](handleEntityNotFound(_0xebfd67,null))[_0x0dc6('0x21')](function(_0x37ad9e){if(_0x37ad9e){_0x550650=_0x37ad9e;_0x4cbe69[_0x0dc6('0x4f')]=_[_0x0dc6('0x52')](db[_0x0dc6('0xbb')][_0x0dc6('0x4b')]);_0x4cbe69[_0x0dc6('0x59')]=_['keys'](_0x51c299['query']);_0x4cbe69[_0x0dc6('0x53')]=_[_0x0dc6('0x67')](_0x4cbe69[_0x0dc6('0x4f')],_0x4cbe69['query']);_0x5cbc67[_0x0dc6('0x55')]=_[_0x0dc6('0x67')](_0x4cbe69[_0x0dc6('0x4f')],qs[_0x0dc6('0x54')](_0x51c299['query'][_0x0dc6('0x54')]));_0x5cbc67[_0x0dc6('0x55')]=_0x5cbc67[_0x0dc6('0x55')][_0x0dc6('0x56')]?_0x5cbc67['attributes']:_0x4cbe69[_0x0dc6('0x4f')];_0x5cbc67[_0x0dc6('0x5a')]=qs[_0x0dc6('0x5b')](_0x51c299[_0x0dc6('0x59')][_0x0dc6('0x5b')]);_0x5cbc67['where']=qs[_0x0dc6('0x53')](_[_0x0dc6('0x5d')](_0x51c299[_0x0dc6('0x59')],_0x4cbe69[_0x0dc6('0x53')]));if(_0x51c299['query']['filter']){_0x5cbc67[_0x0dc6('0x5c')]=_[_0x0dc6('0x5e')](_0x5cbc67['where'],{'$or':_['map'](_0x5cbc67['attributes'],function(_0x4e9fce){var _0x5209f3={};_0x5209f3[_0x4e9fce]={'$like':'%'+_0x51c299['query'][_0x0dc6('0x40')]+'%'};return _0x5209f3;})});}_0x5cbc67=_[_0x0dc6('0x5e')]({},_0x5cbc67,_0x51c299[_0x0dc6('0x61')]);return _0x550650[_0x0dc6('0xd0')](_0x5cbc67);}})[_0x0dc6('0x21')](function(_0x412df1){if(_0x412df1){_0x2e06b7=_0x412df1[_0x0dc6('0x56')];if(!_0x51c299['query'][_0x0dc6('0x57')](_0x0dc6('0x58'))){_0x5cbc67[_0x0dc6('0x31')]=qs[_0x0dc6('0x31')](_0x51c299['query']['limit']);_0x5cbc67[_0x0dc6('0x30')]=qs[_0x0dc6('0x30')](_0x51c299['query']['offset']);}return _0x550650[_0x0dc6('0xd0')](_0x5cbc67);}})[_0x0dc6('0x21')](function(_0x508bdb){if(_0x508bdb){return _0x508bdb?{'count':_0x2e06b7,'rows':_0x508bdb}:null;}})[_0x0dc6('0x21')](respondWithResult(_0xebfd67,null))[_0x0dc6('0x2b')](handleError(_0xebfd67,null));};exports['getGroups']=function(_0x299727,_0x274504,_0x1ca07c){var _0x2a0d1c={};var _0x482c43={};var _0x11aabf;var _0x487562;return db['User'][_0x0dc6('0xa3')]({'where':{'id':_0x299727[_0x0dc6('0x6a')]['id']}})[_0x0dc6('0x21')](handleEntityNotFound(_0x274504,null))[_0x0dc6('0x21')](function(_0x2d2cee){if(_0x2d2cee){_0x11aabf=_0x2d2cee;_0x482c43[_0x0dc6('0x4f')]=_[_0x0dc6('0x52')](db[_0x0dc6('0xd1')][_0x0dc6('0x4b')]);_0x482c43['query']=_[_0x0dc6('0x52')](_0x299727[_0x0dc6('0x59')]);_0x482c43[_0x0dc6('0x53')]=_[_0x0dc6('0x67')](_0x482c43[_0x0dc6('0x4f')],_0x482c43[_0x0dc6('0x59')]);_0x2a0d1c[_0x0dc6('0x55')]=_[_0x0dc6('0x67')](_0x482c43[_0x0dc6('0x4f')],qs[_0x0dc6('0x54')](_0x299727['query'][_0x0dc6('0x54')]));_0x2a0d1c[_0x0dc6('0x55')]=_0x2a0d1c[_0x0dc6('0x55')][_0x0dc6('0x56')]?_0x2a0d1c[_0x0dc6('0x55')]:_0x482c43[_0x0dc6('0x4f')];_0x2a0d1c[_0x0dc6('0x5a')]=qs[_0x0dc6('0x5b')](_0x299727[_0x0dc6('0x59')][_0x0dc6('0x5b')]);_0x2a0d1c[_0x0dc6('0x5c')]=qs[_0x0dc6('0x53')](_[_0x0dc6('0x5d')](_0x299727[_0x0dc6('0x59')],_0x482c43[_0x0dc6('0x53')]));if(_0x299727[_0x0dc6('0x59')]['filter']){_0x2a0d1c[_0x0dc6('0x5c')]=_['merge'](_0x2a0d1c[_0x0dc6('0x5c')],{'$or':_[_0x0dc6('0x41')](_0x2a0d1c[_0x0dc6('0x55')],function(_0xa63ceb){var _0x3a7f2a={};_0x3a7f2a[_0xa63ceb]={'$like':'%'+_0x299727[_0x0dc6('0x59')]['filter']+'%'};return _0x3a7f2a;})});}_0x2a0d1c=_[_0x0dc6('0x5e')]({},_0x2a0d1c,_0x299727[_0x0dc6('0x61')]);return _0x11aabf['getGroups'](_0x2a0d1c);}})[_0x0dc6('0x21')](function(_0x44f317){if(_0x44f317){_0x487562=_0x44f317[_0x0dc6('0x56')];if(!_0x299727['query'][_0x0dc6('0x57')]('nolimit')){_0x2a0d1c[_0x0dc6('0x31')]=qs['limit'](_0x299727[_0x0dc6('0x59')][_0x0dc6('0x31')]);_0x2a0d1c['offset']=qs[_0x0dc6('0x30')](_0x299727['query'][_0x0dc6('0x30')]);}return _0x11aabf[_0x0dc6('0xd2')](_0x2a0d1c);}})[_0x0dc6('0x21')](function(_0x28039b){if(_0x28039b){return _0x28039b?{'count':_0x487562,'rows':_0x28039b}:null;}})['then'](respondWithResult(_0x274504,null))[_0x0dc6('0x2b')](handleError(_0x274504,null));};exports[_0x0dc6('0xd3')]=function(_0x193de2,_0x89131a,_0x52f7f6){var _0x21bf27={'raw':!![],'where':{}};var _0x4862b5={};var _0x438899={'count':0x0,'rows':[]};return db['User'][_0x0dc6('0xa3')]({'where':{'id':_0x193de2[_0x0dc6('0x6a')]['id']}})[_0x0dc6('0x21')](handleEntityNotFound(_0x89131a,null))[_0x0dc6('0x21')](function(_0x2c5e28){if(_0x2c5e28){_0x4862b5[_0x0dc6('0x4f')]=_[_0x0dc6('0x52')](db[_0x0dc6('0xd4')][_0x0dc6('0x4b')]);_0x4862b5[_0x0dc6('0x59')]=_[_0x0dc6('0x52')](_0x193de2[_0x0dc6('0x59')]);_0x4862b5[_0x0dc6('0x53')]=_[_0x0dc6('0x67')](_0x4862b5['model'],_0x4862b5['query']);_0x21bf27['attributes']=_[_0x0dc6('0x67')](_0x4862b5[_0x0dc6('0x4f')],qs[_0x0dc6('0x54')](_0x193de2[_0x0dc6('0x59')][_0x0dc6('0x54')]));_0x21bf27[_0x0dc6('0x55')]=_0x21bf27['attributes'][_0x0dc6('0x56')]?_0x21bf27[_0x0dc6('0x55')]:_0x4862b5[_0x0dc6('0x4f')];if(!_0x193de2[_0x0dc6('0x59')]['hasOwnProperty'](_0x0dc6('0x58'))){_0x21bf27[_0x0dc6('0x31')]=qs[_0x0dc6('0x31')](_0x193de2[_0x0dc6('0x59')]['limit']);_0x21bf27[_0x0dc6('0x30')]=qs[_0x0dc6('0x30')](_0x193de2[_0x0dc6('0x59')][_0x0dc6('0x30')]);}_0x21bf27[_0x0dc6('0x5a')]=qs[_0x0dc6('0x5b')](_0x193de2['query'][_0x0dc6('0x5b')]);_0x21bf27[_0x0dc6('0x5c')]=qs[_0x0dc6('0x53')](_['pick'](_0x193de2['query'],_0x4862b5[_0x0dc6('0x53')]));_0x21bf27[_0x0dc6('0x5c')][_0x0dc6('0xd5')]=_0x2c5e28['id'];if(_0x193de2[_0x0dc6('0x59')][_0x0dc6('0x40')]){_0x21bf27[_0x0dc6('0x5c')]=_[_0x0dc6('0x5e')](_0x21bf27[_0x0dc6('0x5c')],{'$or':_[_0x0dc6('0x41')](_0x21bf27[_0x0dc6('0x55')],function(_0x4bd99b){var _0x543d84={};_0x543d84[_0x4bd99b]={'$like':'%'+_0x193de2[_0x0dc6('0x59')]['filter']+'%'};return _0x543d84;})});}_0x21bf27=_[_0x0dc6('0x5e')]({},_0x21bf27,_0x193de2[_0x0dc6('0x61')]);return db[_0x0dc6('0xd4')]['count']({'where':_0x21bf27[_0x0dc6('0x5c')]})[_0x0dc6('0x21')](function(_0x489184){_0x438899[_0x0dc6('0x2f')]=_0x489184;if(_0x193de2[_0x0dc6('0x59')][_0x0dc6('0x63')]){_0x21bf27[_0x0dc6('0x68')]=[{'all':!![]}];}return db[_0x0dc6('0xd4')]['findAll'](_0x21bf27);})[_0x0dc6('0x21')](function(_0x1b6695){_0x438899[_0x0dc6('0x64')]=_0x1b6695;return _0x438899;});}})[_0x0dc6('0x21')](respondWithFilteredResult(_0x89131a,_0x21bf27))['catch'](handleError(_0x89131a,null));};exports['getScreenRecordings']=function(_0x419421,_0x570b14,_0x5a5a57){var _0x15fd63={'raw':!![],'where':{}};var _0x3fe800={};var _0x539082={'count':0x0,'rows':[]};return db[_0x0dc6('0x62')][_0x0dc6('0xa3')]({'where':{'id':_0x419421['params']['id']}})['then'](handleEntityNotFound(_0x570b14,null))[_0x0dc6('0x21')](function(_0x86a0a1){if(_0x86a0a1){_0x3fe800[_0x0dc6('0x4f')]=_[_0x0dc6('0x52')](db['ScreenRecording']['rawAttributes']);_0x3fe800[_0x0dc6('0x59')]=_[_0x0dc6('0x52')](_0x419421[_0x0dc6('0x59')]);_0x3fe800[_0x0dc6('0x53')]=_[_0x0dc6('0x67')](_0x3fe800[_0x0dc6('0x4f')],_0x3fe800[_0x0dc6('0x59')]);_0x15fd63[_0x0dc6('0x55')]=_[_0x0dc6('0x67')](_0x3fe800['model'],qs[_0x0dc6('0x54')](_0x419421[_0x0dc6('0x59')][_0x0dc6('0x54')]));_0x15fd63[_0x0dc6('0x55')]=_0x15fd63[_0x0dc6('0x55')]['length']?_0x15fd63['attributes']:_0x3fe800[_0x0dc6('0x4f')];if(!_0x419421[_0x0dc6('0x59')][_0x0dc6('0x57')](_0x0dc6('0x58'))){_0x15fd63[_0x0dc6('0x31')]=qs['limit'](_0x419421[_0x0dc6('0x59')][_0x0dc6('0x31')]);_0x15fd63[_0x0dc6('0x30')]=qs[_0x0dc6('0x30')](_0x419421['query'][_0x0dc6('0x30')]);}_0x15fd63[_0x0dc6('0x5a')]=qs[_0x0dc6('0x5b')](_0x419421[_0x0dc6('0x59')][_0x0dc6('0x5b')]);_0x15fd63[_0x0dc6('0x5c')]=qs[_0x0dc6('0x53')](_['pick'](_0x419421[_0x0dc6('0x59')],_0x3fe800[_0x0dc6('0x53')]));_0x15fd63[_0x0dc6('0x5c')][_0x0dc6('0xd5')]=_0x86a0a1['id'];if(_0x419421['query'][_0x0dc6('0x40')]){_0x15fd63[_0x0dc6('0x5c')]=_[_0x0dc6('0x5e')](_0x15fd63[_0x0dc6('0x5c')],{'$or':_['map'](_0x15fd63[_0x0dc6('0x55')],function(_0x5416f5){var _0x3da3a0={};_0x3da3a0[_0x5416f5]={'$like':'%'+_0x419421['query']['filter']+'%'};return _0x3da3a0;})});}_0x15fd63=_[_0x0dc6('0x5e')]({},_0x15fd63,_0x419421['options']);return db[_0x0dc6('0xd6')][_0x0dc6('0x2f')]({'where':_0x15fd63['where']})['then'](function(_0x1aa90c){_0x539082[_0x0dc6('0x2f')]=_0x1aa90c;if(_0x419421['query'][_0x0dc6('0x63')]){_0x15fd63[_0x0dc6('0x68')]=[{'all':!![]}];}return db[_0x0dc6('0xd6')]['findAll'](_0x15fd63);})[_0x0dc6('0x21')](function(_0x5cd764){_0x539082['rows']=_0x5cd764;return _0x539082;});}})[_0x0dc6('0x21')](respondWithFilteredResult(_0x570b14,_0x15fd63))[_0x0dc6('0x2b')](handleError(_0x570b14,null));};exports[_0x0dc6('0xd7')]=function(_0x3c4342,_0x4f215b,_0x519206){var _0xf0df11={};var _0x21f2f9={};var _0x1327f4;var _0x29fb93;return db[_0x0dc6('0x62')][_0x0dc6('0xa3')]({'where':{'id':_0x3c4342[_0x0dc6('0x6a')]['id']}})[_0x0dc6('0x21')](handleEntityNotFound(_0x4f215b,null))[_0x0dc6('0x21')](function(_0x1ab4ec){if(_0x1ab4ec){_0x1327f4=_0x1ab4ec;_0x21f2f9[_0x0dc6('0x4f')]=_['keys'](db['ChatInteraction']['rawAttributes']);_0x21f2f9['query']=_[_0x0dc6('0x52')](_0x3c4342[_0x0dc6('0x59')]);_0x21f2f9[_0x0dc6('0x53')]=_[_0x0dc6('0x67')](_0x21f2f9[_0x0dc6('0x4f')],_0x21f2f9[_0x0dc6('0x59')]);_0xf0df11[_0x0dc6('0x55')]=_[_0x0dc6('0x67')](_0x21f2f9[_0x0dc6('0x4f')],qs[_0x0dc6('0x54')](_0x3c4342[_0x0dc6('0x59')]['fields']));_0xf0df11[_0x0dc6('0x55')]=_0xf0df11[_0x0dc6('0x55')]['length']?_0xf0df11[_0x0dc6('0x55')]:_0x21f2f9[_0x0dc6('0x4f')];_0xf0df11[_0x0dc6('0x5a')]=qs[_0x0dc6('0x5b')](_0x3c4342[_0x0dc6('0x59')][_0x0dc6('0x5b')]);_0xf0df11['where']=qs[_0x0dc6('0x53')](_[_0x0dc6('0x5d')](_0x3c4342[_0x0dc6('0x59')],_0x21f2f9[_0x0dc6('0x53')]));if(_0x3c4342['query']['filter']){_0xf0df11[_0x0dc6('0x5c')]=_['merge'](_0xf0df11['where'],{'$or':_['map'](_0xf0df11[_0x0dc6('0x55')],function(_0x1514ce){var _0x1ad375={};_0x1ad375[_0x1514ce]={'$like':'%'+_0x3c4342[_0x0dc6('0x59')][_0x0dc6('0x40')]+'%'};return _0x1ad375;})});}_0xf0df11=_['merge']({},_0xf0df11,_0x3c4342[_0x0dc6('0x61')]);return _0x1327f4[_0x0dc6('0xd7')](_0xf0df11);}})[_0x0dc6('0x21')](function(_0xa515c1){if(_0xa515c1){_0x29fb93=_0xa515c1[_0x0dc6('0x56')];if(!_0x3c4342['query'][_0x0dc6('0x57')]('nolimit')){_0xf0df11[_0x0dc6('0x31')]=qs['limit'](_0x3c4342[_0x0dc6('0x59')][_0x0dc6('0x31')]);_0xf0df11['offset']=qs[_0x0dc6('0x30')](_0x3c4342['query']['offset']);}return _0x1327f4['getChatInteractions'](_0xf0df11);}})[_0x0dc6('0x21')](function(_0x45d64a){if(_0x45d64a){return _0x45d64a?{'count':_0x29fb93,'rows':_0x45d64a}:null;}})['then'](respondWithResult(_0x4f215b,null))[_0x0dc6('0x2b')](handleError(_0x4f215b,null));};exports[_0x0dc6('0xd8')]=function(_0x57943e,_0x374691,_0x1a5294){var _0x1668ef={};var _0x19f3b0={};var _0x5e5f02;var _0x54c08b;return db['User']['findOne']({'where':{'id':_0x57943e['params']['id']}})[_0x0dc6('0x21')](handleEntityNotFound(_0x374691,null))[_0x0dc6('0x21')](function(_0x31cc65){if(_0x31cc65){_0x5e5f02=_0x31cc65;_0x19f3b0[_0x0dc6('0x4f')]=_[_0x0dc6('0x52')](db[_0x0dc6('0xd9')]['rawAttributes']);_0x19f3b0[_0x0dc6('0x59')]=_[_0x0dc6('0x52')](_0x57943e['query']);_0x19f3b0['filters']=_[_0x0dc6('0x67')](_0x19f3b0[_0x0dc6('0x4f')],_0x19f3b0[_0x0dc6('0x59')]);_0x1668ef[_0x0dc6('0x55')]=_['intersection'](_0x19f3b0['model'],qs[_0x0dc6('0x54')](_0x57943e[_0x0dc6('0x59')][_0x0dc6('0x54')]));_0x1668ef['attributes']=_0x1668ef['attributes']['length']?_0x1668ef[_0x0dc6('0x55')]:_0x19f3b0[_0x0dc6('0x4f')];_0x1668ef[_0x0dc6('0x5a')]=qs[_0x0dc6('0x5b')](_0x57943e[_0x0dc6('0x59')][_0x0dc6('0x5b')]);_0x1668ef[_0x0dc6('0x5c')]=qs[_0x0dc6('0x53')](_[_0x0dc6('0x5d')](_0x57943e['query'],_0x19f3b0[_0x0dc6('0x53')]));if(_0x57943e['query'][_0x0dc6('0x40')]){_0x1668ef[_0x0dc6('0x5c')]=_[_0x0dc6('0x5e')](_0x1668ef[_0x0dc6('0x5c')],{'$or':_[_0x0dc6('0x41')](_0x1668ef['attributes'],function(_0x3057ad){var _0x56ae74={};_0x56ae74[_0x3057ad]={'$like':'%'+_0x57943e[_0x0dc6('0x59')][_0x0dc6('0x40')]+'%'};return _0x56ae74;})});}_0x1668ef=_[_0x0dc6('0x5e')]({},_0x1668ef,_0x57943e[_0x0dc6('0x61')]);return _0x5e5f02[_0x0dc6('0xd8')](_0x1668ef);}})[_0x0dc6('0x21')](function(_0x5d8209){if(_0x5d8209){_0x54c08b=_0x5d8209[_0x0dc6('0x56')];if(!_0x57943e[_0x0dc6('0x59')][_0x0dc6('0x57')]('nolimit')){_0x1668ef[_0x0dc6('0x31')]=qs[_0x0dc6('0x31')](_0x57943e['query'][_0x0dc6('0x31')]);_0x1668ef[_0x0dc6('0x30')]=qs[_0x0dc6('0x30')](_0x57943e[_0x0dc6('0x59')][_0x0dc6('0x30')]);}return _0x5e5f02[_0x0dc6('0xd8')](_0x1668ef);}})[_0x0dc6('0x21')](function(_0x520f16){if(_0x520f16){return _0x520f16?{'count':_0x54c08b,'rows':_0x520f16}:null;}})[_0x0dc6('0x21')](respondWithResult(_0x374691,null))[_0x0dc6('0x2b')](handleError(_0x374691,null));};exports['getMailInteractions']=function(_0x11fc84,_0x1f78e7,_0x3ff95e){var _0x376a1d={'raw':!![],'where':{}};var _0x56f1e0={};var _0x46fe88={'count':0x0,'rows':[]};return db[_0x0dc6('0x62')][_0x0dc6('0xa3')]({'where':{'id':_0x11fc84[_0x0dc6('0x6a')]['id']}})[_0x0dc6('0x21')](handleEntityNotFound(_0x1f78e7,null))[_0x0dc6('0x21')](function(_0x4638f6){if(_0x4638f6){_0x56f1e0[_0x0dc6('0x4f')]=_[_0x0dc6('0x52')](db['MailInteraction'][_0x0dc6('0x4b')]);_0x56f1e0[_0x0dc6('0x59')]=_[_0x0dc6('0x52')](_0x11fc84[_0x0dc6('0x59')]);_0x56f1e0[_0x0dc6('0x53')]=_[_0x0dc6('0x67')](_0x56f1e0['model'],_0x56f1e0['query']);_0x376a1d[_0x0dc6('0x55')]=_[_0x0dc6('0x67')](_0x56f1e0[_0x0dc6('0x4f')],qs['fields'](_0x11fc84[_0x0dc6('0x59')][_0x0dc6('0x54')]));_0x376a1d[_0x0dc6('0x55')]=_0x376a1d[_0x0dc6('0x55')][_0x0dc6('0x56')]?_0x376a1d['attributes']:_0x56f1e0[_0x0dc6('0x4f')];if(!_0x11fc84['query']['hasOwnProperty']('nolimit')){_0x376a1d[_0x0dc6('0x31')]=qs['limit'](_0x11fc84['query']['limit']);_0x376a1d[_0x0dc6('0x30')]=qs[_0x0dc6('0x30')](_0x11fc84[_0x0dc6('0x59')][_0x0dc6('0x30')]);}_0x376a1d[_0x0dc6('0x5a')]=qs[_0x0dc6('0x5b')](_0x11fc84[_0x0dc6('0x59')]['sort']);_0x376a1d[_0x0dc6('0x5c')]=qs[_0x0dc6('0x53')](_['pick'](_0x11fc84['query'],_0x56f1e0[_0x0dc6('0x53')]));_0x376a1d['where']['UserId']=_0x4638f6['id'];if(_0x11fc84['query'][_0x0dc6('0x40')]){_0x376a1d[_0x0dc6('0x5c')]=_[_0x0dc6('0x5e')](_0x376a1d[_0x0dc6('0x5c')],{'$or':_[_0x0dc6('0x41')](_0x376a1d[_0x0dc6('0x55')],function(_0x5a7659){var _0x5a90d8={};_0x5a90d8[_0x5a7659]={'$like':'%'+_0x11fc84[_0x0dc6('0x59')][_0x0dc6('0x40')]+'%'};return _0x5a90d8;})});}_0x376a1d=_['merge']({},_0x376a1d,_0x11fc84[_0x0dc6('0x61')]);return db[_0x0dc6('0xda')][_0x0dc6('0x2f')]({'where':_0x376a1d[_0x0dc6('0x5c')]})['then'](function(_0x5a0527){_0x46fe88[_0x0dc6('0x2f')]=_0x5a0527;if(_0x11fc84[_0x0dc6('0x59')]['includeAll']){_0x376a1d[_0x0dc6('0x68')]=[{'all':!![]}];}return db[_0x0dc6('0xda')][_0x0dc6('0x98')](_0x376a1d);})[_0x0dc6('0x21')](function(_0x101fc6){_0x46fe88[_0x0dc6('0x64')]=_0x101fc6;return _0x46fe88;});}})[_0x0dc6('0x21')](respondWithFilteredResult(_0x1f78e7,_0x376a1d))[_0x0dc6('0x2b')](handleError(_0x1f78e7,null));};exports[_0x0dc6('0xdb')]=function(_0x2ee9d6,_0x51f1e8,_0x42f40b){var _0x3c7e84={};var _0x39cd4d={};var _0x377d5b;var _0x228367;return db[_0x0dc6('0x62')]['findOne']({'where':{'id':_0x2ee9d6[_0x0dc6('0x6a')]['id']}})[_0x0dc6('0x21')](handleEntityNotFound(_0x51f1e8,null))[_0x0dc6('0x21')](function(_0x5c0482){if(_0x5c0482){_0x377d5b=_0x5c0482;_0x39cd4d['model']=_['keys'](db[_0x0dc6('0xdc')][_0x0dc6('0x4b')]);_0x39cd4d['query']=_[_0x0dc6('0x52')](_0x2ee9d6[_0x0dc6('0x59')]);_0x39cd4d[_0x0dc6('0x53')]=_[_0x0dc6('0x67')](_0x39cd4d[_0x0dc6('0x4f')],_0x39cd4d['query']);_0x3c7e84[_0x0dc6('0x55')]=_[_0x0dc6('0x67')](_0x39cd4d[_0x0dc6('0x4f')],qs[_0x0dc6('0x54')](_0x2ee9d6[_0x0dc6('0x59')][_0x0dc6('0x54')]));_0x3c7e84[_0x0dc6('0x55')]=_0x3c7e84['attributes']['length']?_0x3c7e84[_0x0dc6('0x55')]:_0x39cd4d['model'];_0x3c7e84[_0x0dc6('0x5a')]=qs[_0x0dc6('0x5b')](_0x2ee9d6[_0x0dc6('0x59')][_0x0dc6('0x5b')]);_0x3c7e84[_0x0dc6('0x5c')]=qs[_0x0dc6('0x53')](_[_0x0dc6('0x5d')](_0x2ee9d6[_0x0dc6('0x59')],_0x39cd4d[_0x0dc6('0x53')]));if(_0x2ee9d6[_0x0dc6('0x59')][_0x0dc6('0x40')]){_0x3c7e84[_0x0dc6('0x5c')]=_[_0x0dc6('0x5e')](_0x3c7e84[_0x0dc6('0x5c')],{'$or':_[_0x0dc6('0x41')](_0x3c7e84[_0x0dc6('0x55')],function(_0x519f3b){var _0x84ede={};_0x84ede[_0x519f3b]={'$like':'%'+_0x2ee9d6['query'][_0x0dc6('0x40')]+'%'};return _0x84ede;})});}_0x3c7e84=_[_0x0dc6('0x5e')]({},_0x3c7e84,_0x2ee9d6['options']);return _0x377d5b[_0x0dc6('0xdb')](_0x3c7e84);}})['then'](function(_0x44885b){if(_0x44885b){_0x228367=_0x44885b[_0x0dc6('0x56')];if(!_0x2ee9d6[_0x0dc6('0x59')][_0x0dc6('0x57')]('nolimit')){_0x3c7e84[_0x0dc6('0x31')]=qs[_0x0dc6('0x31')](_0x2ee9d6['query'][_0x0dc6('0x31')]);_0x3c7e84['offset']=qs['offset'](_0x2ee9d6['query']['offset']);}return _0x377d5b['getSmsInteractions'](_0x3c7e84);}})[_0x0dc6('0x21')](function(_0x40c1ea){if(_0x40c1ea){return _0x40c1ea?{'count':_0x228367,'rows':_0x40c1ea}:null;}})[_0x0dc6('0x21')](respondWithResult(_0x51f1e8,null))['catch'](handleError(_0x51f1e8,null));};exports['getFaxInteractions']=function(_0x5b9144,_0x2fba0d,_0x2e2da5){var _0x540d09={};var _0x164170={};var _0xf98e63;var _0x2a53b1;return db[_0x0dc6('0x62')][_0x0dc6('0xa3')]({'where':{'id':_0x5b9144[_0x0dc6('0x6a')]['id']}})[_0x0dc6('0x21')](handleEntityNotFound(_0x2fba0d,null))[_0x0dc6('0x21')](function(_0x3057a9){if(_0x3057a9){_0xf98e63=_0x3057a9;_0x164170[_0x0dc6('0x4f')]=_[_0x0dc6('0x52')](db[_0x0dc6('0xdd')][_0x0dc6('0x4b')]);_0x164170[_0x0dc6('0x59')]=_['keys'](_0x5b9144[_0x0dc6('0x59')]);_0x164170['filters']=_[_0x0dc6('0x67')](_0x164170['model'],_0x164170[_0x0dc6('0x59')]);_0x540d09['attributes']=_[_0x0dc6('0x67')](_0x164170[_0x0dc6('0x4f')],qs[_0x0dc6('0x54')](_0x5b9144[_0x0dc6('0x59')]['fields']));_0x540d09[_0x0dc6('0x55')]=_0x540d09[_0x0dc6('0x55')][_0x0dc6('0x56')]?_0x540d09[_0x0dc6('0x55')]:_0x164170['model'];_0x540d09[_0x0dc6('0x5a')]=qs['sort'](_0x5b9144[_0x0dc6('0x59')][_0x0dc6('0x5b')]);_0x540d09[_0x0dc6('0x5c')]=qs['filters'](_[_0x0dc6('0x5d')](_0x5b9144[_0x0dc6('0x59')],_0x164170[_0x0dc6('0x53')]));if(_0x5b9144[_0x0dc6('0x59')][_0x0dc6('0x40')]){_0x540d09['where']=_['merge'](_0x540d09['where'],{'$or':_['map'](_0x540d09[_0x0dc6('0x55')],function(_0xd0367d){var _0x48016a={};_0x48016a[_0xd0367d]={'$like':'%'+_0x5b9144['query'][_0x0dc6('0x40')]+'%'};return _0x48016a;})});}_0x540d09=_['merge']({},_0x540d09,_0x5b9144[_0x0dc6('0x61')]);return _0xf98e63['getFaxInteractions'](_0x540d09);}})[_0x0dc6('0x21')](function(_0x8b869d){if(_0x8b869d){_0x2a53b1=_0x8b869d['length'];if(!_0x5b9144[_0x0dc6('0x59')]['hasOwnProperty']('nolimit')){_0x540d09['limit']=qs[_0x0dc6('0x31')](_0x5b9144[_0x0dc6('0x59')][_0x0dc6('0x31')]);_0x540d09['offset']=qs[_0x0dc6('0x30')](_0x5b9144[_0x0dc6('0x59')]['offset']);}return _0xf98e63[_0x0dc6('0xde')](_0x540d09);}})['then'](function(_0x28ac95){if(_0x28ac95){return _0x28ac95?{'count':_0x2a53b1,'rows':_0x28ac95}:null;}})['then'](respondWithResult(_0x2fba0d,null))[_0x0dc6('0x2b')](handleError(_0x2fba0d,null));};exports[_0x0dc6('0xdf')]=function(_0xeedfee,_0x5904e6,_0x8f66aa){var _0x543fca={};var _0x57d62a={};var _0x5b96fe;var _0x5a0cb6;return db[_0x0dc6('0x62')][_0x0dc6('0xa3')]({'where':{'id':_0xeedfee[_0x0dc6('0x6a')]['id']}})[_0x0dc6('0x21')](handleEntityNotFound(_0x5904e6,null))[_0x0dc6('0x21')](function(_0x104be6){if(_0x104be6){_0x5b96fe=_0x104be6;_0x57d62a[_0x0dc6('0x4f')]=_[_0x0dc6('0x52')](db[_0x0dc6('0xe0')]['rawAttributes']);_0x57d62a['query']=_[_0x0dc6('0x52')](_0xeedfee[_0x0dc6('0x59')]);_0x57d62a[_0x0dc6('0x53')]=_[_0x0dc6('0x67')](_0x57d62a['model'],_0x57d62a['query']);_0x543fca['attributes']=_['intersection'](_0x57d62a[_0x0dc6('0x4f')],qs[_0x0dc6('0x54')](_0xeedfee[_0x0dc6('0x59')][_0x0dc6('0x54')]));_0x543fca['attributes']=_0x543fca['attributes'][_0x0dc6('0x56')]?_0x543fca[_0x0dc6('0x55')]:_0x57d62a[_0x0dc6('0x4f')];_0x543fca[_0x0dc6('0x5a')]=qs['sort'](_0xeedfee[_0x0dc6('0x59')][_0x0dc6('0x5b')]);_0x543fca['where']=qs['filters'](_[_0x0dc6('0x5d')](_0xeedfee[_0x0dc6('0x59')],_0x57d62a[_0x0dc6('0x53')]));if(_0xeedfee[_0x0dc6('0x59')][_0x0dc6('0x40')]){_0x543fca[_0x0dc6('0x5c')]=_['merge'](_0x543fca[_0x0dc6('0x5c')],{'$or':_[_0x0dc6('0x41')](_0x543fca[_0x0dc6('0x55')],function(_0xff7df1){var _0x58aba6={};_0x58aba6[_0xff7df1]={'$like':'%'+_0xeedfee[_0x0dc6('0x59')]['filter']+'%'};return _0x58aba6;})});}_0x543fca=_[_0x0dc6('0x5e')]({},_0x543fca,_0xeedfee['options']);return _0x5b96fe[_0x0dc6('0xdf')](_0x543fca);}})[_0x0dc6('0x21')](function(_0x57073f){if(_0x57073f){_0x5a0cb6=_0x57073f[_0x0dc6('0x56')];if(!_0xeedfee[_0x0dc6('0x59')]['hasOwnProperty']('nolimit')){_0x543fca[_0x0dc6('0x31')]=qs[_0x0dc6('0x31')](_0xeedfee[_0x0dc6('0x59')][_0x0dc6('0x31')]);_0x543fca['offset']=qs[_0x0dc6('0x30')](_0xeedfee[_0x0dc6('0x59')][_0x0dc6('0x30')]);}return _0x5b96fe[_0x0dc6('0xdf')](_0x543fca);}})[_0x0dc6('0x21')](function(_0xae488f){if(_0xae488f){return _0xae488f?{'count':_0x5a0cb6,'rows':_0xae488f}:null;}})[_0x0dc6('0x21')](respondWithResult(_0x5904e6,null))[_0x0dc6('0x2b')](handleError(_0x5904e6,null));};exports[_0x0dc6('0xe1')]=function(_0x331395,_0x4728d9,_0x530ede){var _0x8aaf92;var _0x1b8673;var _0x354b63;var _0x33fe39=!_[_0x0dc6('0x73')](_0x331395['params']['id'])?_0x331395[_0x0dc6('0x6a')]['id']:!_[_0x0dc6('0x73')](_0x331395['user']['id'])?_0x331395['user']['id']:null;return db['User'][_0x0dc6('0x44')]({'where':{'id':_0x33fe39,'role':{'$or':[_0x0dc6('0x89'),_0x0dc6('0x3b'),_0x0dc6('0x3d')]}},'attributes':['id','name',_0x0dc6('0xe2'),_0x0dc6('0xe3'),_0x0dc6('0x39'),_0x0dc6('0x72'),_0x0dc6('0xab')]})[_0x0dc6('0x21')](function(_0x464367){if(_0x464367){if(_0x464367[_0x0dc6('0x39')]===_0x0dc6('0x3d')){_0x8aaf92=_0x464367;if(_0x331395[_0x0dc6('0x69')][_0x0dc6('0xad')]){_0x354b63=util[_0x0dc6('0xb9')]('LOCAL/%s@from-sip/n',_0x8aaf92[_0x331395[_0x0dc6('0x69')][_0x0dc6('0xad')]]);}else if(_0x331395[_0x0dc6('0x69')][_0x0dc6('0xe4')]){_0x354b63=util[_0x0dc6('0xb9')](_0x0dc6('0xba'),_0x331395['body'][_0x0dc6('0xe4')]);}else{_0x354b63=util[_0x0dc6('0xb9')](_0x0dc6('0xba'),_0x8aaf92[_0x0dc6('0x45')]);}socket['to'](util[_0x0dc6('0xb9')](_0x0dc6('0xe5'),_0x8aaf92['name']))[_0x0dc6('0xbf')](_0x0dc6('0xe6'),{'ip':_0x331395[_0x0dc6('0xe7')][_0x0dc6('0xe8')]||_0x331395[_0x0dc6('0xe9')][_0x0dc6('0xea')]||_0x331395[_0x0dc6('0xeb')]['remoteAddress']||_0x331395[_0x0dc6('0xe9')]['socket'][_0x0dc6('0xea')]});return db[_0x0dc6('0xbb')][_0x0dc6('0x37')]({'where':{'membername':_0x8aaf92[_0x0dc6('0x45')]},'individualHooks':!![]});}}else{throw new db[(_0x0dc6('0x9f'))][(_0x0dc6('0xa0'))](_0x0dc6('0xec'));}})['then'](function(){if(_0x8aaf92){return _0x8aaf92[_0x0dc6('0xed')]({'raw':!![]});}})['then'](function(_0x5d25bc){if(_0x8aaf92){var _0x13b046=[];if(_0x5d25bc){_0x1b8673=_0x5d25bc;if(_0x1b8673['length']){for(var _0x3a2524=0x0;_0x3a2524<_0x1b8673[_0x0dc6('0x56')];_0x3a2524++){_0x13b046['push']({'membername':_0x8aaf92[_0x0dc6('0x45')],'UserId':_0x8aaf92['id'],'queue_name':_0x1b8673[_0x3a2524][_0x0dc6('0x45')],'VoiceQueueId':_0x1b8673[_0x3a2524]['id'],'interface':_0x354b63,'paused':_0x8aaf92['loginInPause']||![],'penalty':_0x1b8673[_0x3a2524][_0x0dc6('0xee')]||0x0});}return BPromise[_0x0dc6('0x97')](_0x13b046,function(_0x1b42c5){return db['UserVoiceQueueRt'][_0x0dc6('0xef')](_0x1b42c5);});}}}})[_0x0dc6('0x21')](function(){if(_0x8aaf92){return db['MemberReport'][_0x0dc6('0x98')]({'where':{'membername':_0x8aaf92[_0x0dc6('0x45')],'exitAt':null}});}})['then'](function(_0x13054f){if(_0x8aaf92){var _0x3d7312=[];_0x13054f[_0x0dc6('0xf0')](function(_0x3ff9d3){_0x3d7312[_0x0dc6('0x95')](_0x3ff9d3['update']({'exitAt':moment()[_0x0dc6('0xb9')]('YYYY-MM-DD\x20HH:mm:ss')}));});return BPromise[_0x0dc6('0x96')](_0x3d7312);}})[_0x0dc6('0x21')](function(){if(_0x8aaf92){var _0x374a67=[];var _0x1cc61e=[];var _0x5d61f9=utils[_0x0dc6('0xf1')]();var _0x13ced9={'membername':_0x8aaf92[_0x0dc6('0x45')],'interface':_0x354b63,'enterAt':moment()[_0x0dc6('0xb9')](_0x0dc6('0xf2')),'role':_0x8aaf92[_0x0dc6('0x39')],'internal':_0x8aaf92[_0x0dc6('0x72')]};_0x5d61f9[_0x0dc6('0xf0')](function(_0x3459b4){_0x374a67['push'](_[_0x0dc6('0x5e')]({'channel':_0x3459b4,'type':_0x0dc6('0xf3'),'data1':_0x331395[_0x0dc6('0x69')][_0x0dc6('0xf4')],'data2':_0x354b63},_0x13ced9));if(_0x8aaf92[_0x0dc6('0xab')]){_0x1cc61e[_0x0dc6('0x95')](_[_0x0dc6('0x5e')]({'channel':_0x3459b4,'type':'PAUSE','data1':'LOGININPAUSE'},_0x13ced9));}});return db[_0x0dc6('0xf5')][_0x0dc6('0x92')](_0x374a67[_0x0dc6('0xf6')](_0x1cc61e),{'individualHooks':!![]});}})[_0x0dc6('0x21')](function(){if(_0x8aaf92){return _0x8aaf92[_0x0dc6('0x36')]({'online':!![],'lastLoginAt':moment()['format'](_0x0dc6('0xf2')),'voicePause':_0x8aaf92[_0x0dc6('0xab')]||![],'mailPause':_0x8aaf92['loginInPause']||![],'chatPause':_0x8aaf92[_0x0dc6('0xab')]||![],'faxPause':_0x8aaf92[_0x0dc6('0xab')]||![],'smsPause':_0x8aaf92['loginInPause']||![],'openchannelPause':_0x8aaf92[_0x0dc6('0xab')]||![],'whatsappPause':_0x8aaf92[_0x0dc6('0xab')]||![],'pauseType':_0x8aaf92[_0x0dc6('0xab')]?_0x0dc6('0xf7'):null,'interface':_0x354b63,'lastPauseAt':moment()[_0x0dc6('0xb9')](_0x0dc6('0xf2'))});}})['then'](function(_0xa2bb7){if(_0x331395[_0x0dc6('0xf8')]){return _0x530ede();}else{return BPromise[_0x0dc6('0xf9')](_0xa2bb7)[_0x0dc6('0x21')](respondWithResult(_0x4728d9,null));}})[_0x0dc6('0x2b')](handleError(_0x4728d9,null));};exports[_0x0dc6('0xfa')]=function(_0x506b1b,_0x1618dd,_0x1f8e7f){var _0x12db77;return db[_0x0dc6('0x62')][_0x0dc6('0x44')]({'where':{'id':_0x506b1b['params']['id'],'role':_0x0dc6('0x3d')},'attributes':['id',_0x0dc6('0x45'),_0x0dc6('0x39')]})[_0x0dc6('0x21')](handleEntityNotFound(_0x1618dd,null))['then'](function(_0x3c6183){if(_0x3c6183){_0x12db77=_0x3c6183;return db['UserVoiceQueueRt'][_0x0dc6('0x37')]({'where':{'membername':_0x12db77[_0x0dc6('0x45')]},'individualHooks':!![]});}})[_0x0dc6('0x21')](function(){return db[_0x0dc6('0xf5')][_0x0dc6('0x98')]({'where':{'membername':_0x12db77[_0x0dc6('0x45')],'exitAt':null}});})['then'](function(_0x68966d){var _0x11d76e=[];_0x68966d['forEach'](function(_0x36955d){_0x11d76e['push'](_0x36955d[_0x0dc6('0x36')]({'exitAt':moment()[_0x0dc6('0xb9')](_0x0dc6('0xf2'))}));});return BPromise[_0x0dc6('0x96')](_0x11d76e);})[_0x0dc6('0x21')](function(){return _0x12db77[_0x0dc6('0x36')]({'online':![],'lastLoginAt':null,'voicePause':![],'mailPause':![],'chatPause':![],'faxPause':![],'smsPause':![],'openchannelPause':![],'whatsappPause':![],'interface':null});})[_0x0dc6('0x21')](respondWithResult(_0x1618dd,null))['catch'](handleError(_0x1618dd,null));};exports[_0x0dc6('0xfb')]=function(_0x39af74,_0x3c2616,_0x3aa968){var _0x2a274e;return db[_0x0dc6('0xbb')][_0x0dc6('0x36')]({'paused':0x1},{'where':{'UserId':_0x39af74[_0x0dc6('0x6a')]['id']},'individualHooks':!![]})[_0x0dc6('0x21')](function(){return db[_0x0dc6('0x62')][_0x0dc6('0x44')]({'where':{'id':_0x39af74['params']['id'],'role':'agent'},'attributes':['id','name','role',_0x0dc6('0x72'),_0x0dc6('0xad')]});})['then'](handleEntityNotFound(_0x3c2616,null))[_0x0dc6('0x21')](function(_0xb7a37b){if(_0xb7a37b){_0x2a274e=_0xb7a37b;return respondWithRpcPromise(_0x0dc6('0xfc'),'pause',{'id':_0x2a274e['id'],'name':_0x2a274e['name'],'pause':!![]});}})[_0x0dc6('0x21')](function(){if(_0x2a274e){return db['MemberReport'][_0x0dc6('0x98')]({'where':{'membername':_0x2a274e[_0x0dc6('0x45')],'type':_0x0dc6('0xfd'),'exitAt':null}});}})['then'](function(_0x42b023){if(_0x42b023[_0x0dc6('0x56')]){var _0x1f8597=moment()[_0x0dc6('0xb9')]('YYYY-MM-DD\x20HH:mm:ss');for(var _0x582d0c=0x0,_0x46d047=_0x42b023[_0x0dc6('0x56')];_0x582d0c<_0x46d047;_0x582d0c++){_0x42b023[_0x582d0c]['updateAttributes']({'exitAt':_0x1f8597});}}})[_0x0dc6('0x21')](function(){var _0x8bef52=[];var _0x5eed71=utils['getChannels']();_0x5eed71[_0x0dc6('0xf0')](function(_0x37c0f1){_0x8bef52[_0x0dc6('0x95')]({'channel':_0x37c0f1,'membername':_0x2a274e[_0x0dc6('0x45')],'interface':_[_0x0dc6('0x73')](_0x2a274e[_0x0dc6('0xad')])?util[_0x0dc6('0xb9')](_0x0dc6('0xba'),_0x2a274e[_0x0dc6('0x45')]):_0x2a274e['interface'],'type':_0x0dc6('0xfd'),'enterAt':moment()[_0x0dc6('0xb9')](_0x0dc6('0xf2')),'data1':_0x39af74[_0x0dc6('0x69')][_0x0dc6('0x4d')]||_0x0dc6('0xfe'),'role':_0x2a274e[_0x0dc6('0x39')],'internal':_0x2a274e[_0x0dc6('0x72')]});});return db[_0x0dc6('0xf5')]['bulkCreate'](_0x8bef52,{'individualHooks':!![]});})[_0x0dc6('0x21')](function(){return _0x2a274e[_0x0dc6('0x36')]({'voicePause':!![],'mailPause':!![],'chatPause':!![],'faxPause':!![],'smsPause':!![],'whatsappPause':!![],'openchannelPause':!![],'pauseType':_0x39af74[_0x0dc6('0x69')][_0x0dc6('0x4d')]||_0x0dc6('0xfe'),'lastPauseAt':moment()[_0x0dc6('0xb9')](_0x0dc6('0xf2'))});})['then'](respondWithResult(_0x3c2616,null))['catch'](handleError(_0x3c2616,null));};exports[_0x0dc6('0xff')]=function(_0xb8d224,_0x767aa5,_0x26e981){var _0x5cd266;return db[_0x0dc6('0x62')][_0x0dc6('0x44')]({'where':{'id':_0xb8d224[_0x0dc6('0x6a')]['id']},'attributes':['id','name',_0x0dc6('0x39'),'voicePause','mailPause',_0x0dc6('0x100'),'faxPause',_0x0dc6('0x101'),'smsPause',_0x0dc6('0x102'),_0x0dc6('0x103'),_0x0dc6('0x104')]})[_0x0dc6('0x21')](handleEntityNotFound(_0x767aa5,null))[_0x0dc6('0x21')](function(_0x290817){if(_0x290817){_0x5cd266=_0x290817;if(_0xb8d224[_0x0dc6('0x69')][_0x0dc6('0xa9')]&&!utils[_0x0dc6('0xae')](_0xb8d224['body'][_0x0dc6('0xa9')])){throw new db[(_0x0dc6('0x9f'))]['ValidationError'](_0x0dc6('0xaf'));}switch(_0xb8d224[_0x0dc6('0x69')][_0x0dc6('0xa9')]){case'voice':return respondWithRpcPromise('QueuePause',_0x0dc6('0xff'),{'id':_0x5cd266['id'],'name':_0x5cd266[_0x0dc6('0x45')],'pause':![]})[_0x0dc6('0x21')](function(){return db[_0x0dc6('0xbb')][_0x0dc6('0x36')]({'paused':0x0},{'where':{'UserId':_0x5cd266['id']},'individualHooks':!![]});})[_0x0dc6('0x21')](function(){return db[_0x0dc6('0xf5')]['find']({'where':{'channel':_0xb8d224[_0x0dc6('0x69')][_0x0dc6('0xa9')],'membername':_0x5cd266[_0x0dc6('0x45')],'type':_0x0dc6('0xfd'),'exitAt':null}});})['then'](function(_0x525776){if(_0x525776){return _0x525776['update']({'exitAt':moment()[_0x0dc6('0xb9')](_0x0dc6('0xf2')),'data2':_0x0dc6('0x105')},{'individualHooks':!![]});}return null;})[_0x0dc6('0x21')](function(){return _0x5cd266[_0x0dc6('0x36')]({'voicePause':![]});});case _0x0dc6('0x106'):case _0x0dc6('0x107'):case _0x0dc6('0x108'):case _0x0dc6('0x109'):case _0x0dc6('0x10a'):case _0x0dc6('0x10b'):return db[_0x0dc6('0xf5')]['find']({'where':{'channel':_0xb8d224[_0x0dc6('0x69')][_0x0dc6('0xa9')],'membername':_0x5cd266[_0x0dc6('0x45')],'type':_0x0dc6('0xfd'),'exitAt':null}})[_0x0dc6('0x21')](function(_0x55d276){if(_0x55d276){return _0x55d276[_0x0dc6('0x36')]({'exitAt':moment()[_0x0dc6('0xb9')](_0x0dc6('0xf2')),'data2':_0x0dc6('0x105')},{'individualHooks':!![]});}return null;})[_0x0dc6('0x21')](function(){var _0x496eed={};_[_0x0dc6('0x10c')](_0x496eed,util[_0x0dc6('0xb9')](_0x0dc6('0x10d'),_0xb8d224[_0x0dc6('0x69')]['channel'],'Pause'),![]);return _0x5cd266[_0x0dc6('0x36')](_0x496eed);});default:return respondWithRpcPromise(_0x0dc6('0xfc'),_0x0dc6('0xff'),{'id':_0x5cd266['id'],'name':_0x5cd266['name'],'pause':![]})[_0x0dc6('0x21')](function(){return db[_0x0dc6('0xbb')][_0x0dc6('0x36')]({'paused':0x0},{'where':{'UserId':_0x5cd266['id']}});})['then'](function(){return db[_0x0dc6('0xf5')]['findAll']({'where':{'membername':_0x5cd266[_0x0dc6('0x45')],'type':_0x0dc6('0xfd'),'exitAt':null}});})[_0x0dc6('0x21')](function(_0x2e4ad3){var _0x3e28f6=[];_0x2e4ad3[_0x0dc6('0xf0')](function(_0x1186be){_0x3e28f6[_0x0dc6('0x95')](_0x1186be[_0x0dc6('0x36')]({'exitAt':moment()[_0x0dc6('0xb9')](_0x0dc6('0xf2')),'data2':_0x0dc6('0x105')}));});return BPromise[_0x0dc6('0x96')](_0x3e28f6);})[_0x0dc6('0x21')](function(){return _0x5cd266['update']({'voicePause':![],'mailPause':![],'chatPause':![],'faxPause':![],'smsPause':![],'whatsappPause':![],'openchannelPause':![]});});}}})[_0x0dc6('0x21')](respondWithResult(_0x767aa5,null))[_0x0dc6('0x2b')](handleError(_0x767aa5,null));};exports[_0x0dc6('0x10e')]=function(_0x2b860b,_0x5b9912,_0x5001b0){var _0x8cddbd={};var _0x3c0e68={};var _0x1e1712;var _0x152484;return db[_0x0dc6('0x62')][_0x0dc6('0xa3')]({'where':{'id':_0x2b860b[_0x0dc6('0x6a')]['id']}})[_0x0dc6('0x21')](handleEntityNotFound(_0x5b9912,null))[_0x0dc6('0x21')](function(_0x369bf9){if(_0x369bf9){_0x1e1712=_0x369bf9;_0x3c0e68[_0x0dc6('0x4f')]=_[_0x0dc6('0x52')](db['Team'][_0x0dc6('0x4b')]);_0x3c0e68['query']=_[_0x0dc6('0x52')](_0x2b860b[_0x0dc6('0x59')]);_0x3c0e68[_0x0dc6('0x53')]=_['intersection'](_0x3c0e68['model'],_0x3c0e68[_0x0dc6('0x59')]);_0x8cddbd[_0x0dc6('0x55')]=_[_0x0dc6('0x67')](_0x3c0e68[_0x0dc6('0x4f')],qs['fields'](_0x2b860b[_0x0dc6('0x59')][_0x0dc6('0x54')]));_0x8cddbd[_0x0dc6('0x55')]=_0x8cddbd[_0x0dc6('0x55')][_0x0dc6('0x56')]?_0x8cddbd[_0x0dc6('0x55')]:_0x3c0e68[_0x0dc6('0x4f')];_0x8cddbd[_0x0dc6('0x5a')]=qs['sort'](_0x2b860b['query']['sort']);_0x8cddbd[_0x0dc6('0x5c')]=qs[_0x0dc6('0x53')](_[_0x0dc6('0x5d')](_0x2b860b[_0x0dc6('0x59')],_0x3c0e68['filters']));if(_0x2b860b[_0x0dc6('0x59')][_0x0dc6('0x40')]){_0x8cddbd[_0x0dc6('0x5c')]=_['merge'](_0x8cddbd['where'],{'$or':_[_0x0dc6('0x41')](_0x8cddbd[_0x0dc6('0x55')],function(_0x339af5){var _0x591d21={};_0x591d21[_0x339af5]={'$like':'%'+_0x2b860b['query'][_0x0dc6('0x40')]+'%'};return _0x591d21;})});}_0x8cddbd=_[_0x0dc6('0x5e')]({},_0x8cddbd,_0x2b860b[_0x0dc6('0x61')]);return _0x1e1712[_0x0dc6('0x10e')](_0x8cddbd);}})[_0x0dc6('0x21')](function(_0x1a12da){if(_0x1a12da){_0x152484=_0x1a12da[_0x0dc6('0x56')];if(!_0x2b860b[_0x0dc6('0x59')]['hasOwnProperty'](_0x0dc6('0x58'))){_0x8cddbd['limit']=qs[_0x0dc6('0x31')](_0x2b860b[_0x0dc6('0x59')][_0x0dc6('0x31')]);_0x8cddbd[_0x0dc6('0x30')]=qs[_0x0dc6('0x30')](_0x2b860b['query'][_0x0dc6('0x30')]);}return _0x1e1712['getTeams'](_0x8cddbd);}})[_0x0dc6('0x21')](function(_0x53d4cb){if(_0x53d4cb){return _0x53d4cb?{'count':_0x152484,'rows':_0x53d4cb}:null;}})[_0x0dc6('0x21')](respondWithResult(_0x5b9912,null))['catch'](handleError(_0x5b9912,null));};exports['addTeams']=function(_0x268480,_0x170b17){return db[_0x0dc6('0x62')][_0x0dc6('0x44')]({'where':{'id':_0x268480[_0x0dc6('0x6a')]['id']}})[_0x0dc6('0x21')](handleEntityNotFound(_0x170b17,null))[_0x0dc6('0x21')](function(_0x40d0df){if(_0x40d0df){var _0x48cd1a=_0x40d0df[_0x0dc6('0x38')]({'plain':!![]});return _0x40d0df[_0x0dc6('0x10f')](_0x268480[_0x0dc6('0x69')][_0x0dc6('0x6d')],_['omit'](_0x268480['body'],[_0x0dc6('0x6d'),'id'])||{})[_0x0dc6('0x21')](function(){for(var _0xf5b7be=0x0;_0xf5b7be<_0x268480['body']['ids'][_0x0dc6('0x56')];_0xf5b7be++){var _0x2ad9ff=[];db[_0x0dc6('0x110')][_0x0dc6('0xa3')]({'where':{'id':_0x268480['body'][_0x0dc6('0x6d')][_0xf5b7be]}})[_0x0dc6('0x21')](function(_0x4e759d){_0x2ad9ff[_0x0dc6('0x95')](_0x4e759d[_0x0dc6('0xed')]()[_0x0dc6('0x21')](function(_0xacff8a){for(var _0x4deb61=0x0;_0x4deb61<_0xacff8a['length'];_0x4deb61++){_0xacff8a[_0x4deb61][_0x0dc6('0x111')](_0x0dc6('0xa9'),_0x0dc6('0x112'));}return _0xacff8a;}));_0x2ad9ff[_0x0dc6('0x95')](_0x4e759d[_0x0dc6('0x113')]()[_0x0dc6('0x21')](function(_0x3c5ea7){for(var _0x15c34c=0x0;_0x15c34c<_0x3c5ea7[_0x0dc6('0x56')];_0x15c34c++){_0x3c5ea7[_0x15c34c]['setDataValue'](_0x0dc6('0xa9'),_0x0dc6('0x114'));}return _0x3c5ea7;}));_0x2ad9ff[_0x0dc6('0x95')](_0x4e759d['getMailQueues']()['then'](function(_0x20ffd0){for(var _0x10976c=0x0;_0x10976c<_0x20ffd0[_0x0dc6('0x56')];_0x10976c++){_0x20ffd0[_0x10976c][_0x0dc6('0x111')](_0x0dc6('0xa9'),_0x0dc6('0x115'));}return _0x20ffd0;}));_0x2ad9ff[_0x0dc6('0x95')](_0x4e759d[_0x0dc6('0x116')]()[_0x0dc6('0x21')](function(_0x3ad000){for(var _0x5d8f9c=0x0;_0x5d8f9c<_0x3ad000[_0x0dc6('0x56')];_0x5d8f9c++){_0x3ad000[_0x5d8f9c][_0x0dc6('0x111')](_0x0dc6('0xa9'),'Sms');}return _0x3ad000;}));_0x2ad9ff['push'](_0x4e759d[_0x0dc6('0x117')]()[_0x0dc6('0x21')](function(_0x421d3b){for(var _0xf044fd=0x0;_0xf044fd<_0x421d3b[_0x0dc6('0x56')];_0xf044fd++){_0x421d3b[_0xf044fd][_0x0dc6('0x111')](_0x0dc6('0xa9'),'Whatsapp');}return _0x421d3b;}));_0x2ad9ff[_0x0dc6('0x95')](_0x4e759d[_0x0dc6('0x118')]()[_0x0dc6('0x21')](function(_0x35ae15){for(var _0x12cc5d=0x0;_0x12cc5d<_0x35ae15[_0x0dc6('0x56')];_0x12cc5d++){_0x35ae15[_0x12cc5d][_0x0dc6('0x111')](_0x0dc6('0xa9'),_0x0dc6('0x119'));}return _0x35ae15;}));_0x2ad9ff[_0x0dc6('0x95')](_0x4e759d[_0x0dc6('0x11a')]()[_0x0dc6('0x21')](function(_0x326793){for(var _0x30c128=0x0;_0x30c128<_0x326793['length'];_0x30c128++){_0x326793[_0x30c128]['setDataValue']('channel',_0x0dc6('0x11b'));}return _0x326793;}));return BPromise['all'](_0x2ad9ff);})[_0x0dc6('0x21')](function(_0x3ca842){var _0xbf3fb9=_[_0x0dc6('0x11c')](_0x3ca842);_0x2ad9ff=[];return db[_0x0dc6('0x5f')][_0x0dc6('0x11d')](function(_0xd67589){for(var _0x17edb5=0x0;_0x17edb5<_0xbf3fb9[_0x0dc6('0x56')];_0x17edb5++){_0x2ad9ff[_0x0dc6('0x95')](_0xbf3fb9[_0x17edb5][_0x0dc6('0x11e')](_0x48cd1a['id']),{'transaction':_0xd67589});}return BPromise[_0x0dc6('0x96')](_0x2ad9ff)[_0x0dc6('0x21')](function(){if(_0x48cd1a[_0x0dc6('0xaa')]){return BPromise[_0x0dc6('0x97')](_[_0x0dc6('0x40')](_0xbf3fb9,function(_0x4e2e7e){return _0x4e2e7e[_0x0dc6('0x11f')](_0x0dc6('0xa9'))===_0x0dc6('0x112');}),function(_0x334e9c){return db[_0x0dc6('0xbb')]['upsert']({'membername':_0x48cd1a[_0x0dc6('0x45')],'UserId':_0x48cd1a['id'],'queue_name':_0x334e9c[_0x0dc6('0x45')],'VoiceQueueId':_0x334e9c['id'],'interface':_[_0x0dc6('0x73')](_0x48cd1a[_0x0dc6('0xad')])?util[_0x0dc6('0xb9')]('SIP/%s',_0x48cd1a['name']):_0x48cd1a[_0x0dc6('0xad')],'paused':_0x48cd1a[_0x0dc6('0xac')]||![],'penalty':_0x48cd1a['penalty']},{'transaction':_0xd67589});});}else{return;}})[_0x0dc6('0x21')](function(){for(var _0x47f69f=0x0;_0x47f69f<_0xbf3fb9[_0x0dc6('0x56')];_0x47f69f++){var _0x240ffd=_0xbf3fb9[_0x47f69f][_0x0dc6('0x11f')](_0x0dc6('0xa9'));var _0x483b28=_0x240ffd+'QueueId';socket[_0x0dc6('0xbf')]('user'+_0x240ffd+'Queue:save',{'UserId':_0x48cd1a['id'],['queueField']:_0xbf3fb9[_0x47f69f]['id']});}});});});}});}})['then'](respondWithStatusCode(_0x170b17,null))[_0x0dc6('0x2b')](handleError(_0x170b17,null));};exports[_0x0dc6('0x120')]=function(_0xa833ea,_0x4acd80){return db['User']['findOne']({'where':{'id':_0xa833ea[_0x0dc6('0x6a')]['id']}})[_0x0dc6('0x21')](handleEntityNotFound(_0x4acd80,null))['then'](function(_0x5a8082){if(_0x5a8082){var _0x20f028=_0x5a8082['get']({'plain':!![]});var _0x138865=_0xa833ea[_0x0dc6('0x59')][_0x0dc6('0x6d')];return _0x5a8082[_0x0dc6('0x120')](_0x138865)[_0x0dc6('0x21')](function(){for(var _0x442ca8=0x0;_0x442ca8<_0x138865[_0x0dc6('0x56')];_0x442ca8++){var _0x358381=[];db['Team'][_0x0dc6('0xa3')]({'where':{'id':_0x138865[_0x442ca8]}})['then'](function(_0x327da7){_0x358381[_0x0dc6('0x95')](_0x327da7[_0x0dc6('0xed')]()[_0x0dc6('0x21')](function(_0x52d5bc){for(var _0xcf1623=0x0;_0xcf1623<_0x52d5bc['length'];_0xcf1623++){_0x52d5bc[_0xcf1623][_0x0dc6('0x111')](_0x0dc6('0xa9'),_0x0dc6('0x112'));}return _0x52d5bc;}));_0x358381[_0x0dc6('0x95')](_0x327da7['getChatQueues']()[_0x0dc6('0x21')](function(_0x1aeac5){for(var _0x24a49f=0x0;_0x24a49f<_0x1aeac5['length'];_0x24a49f++){_0x1aeac5[_0x24a49f]['setDataValue'](_0x0dc6('0xa9'),'Chat');}return _0x1aeac5;}));_0x358381[_0x0dc6('0x95')](_0x327da7[_0x0dc6('0x121')]()[_0x0dc6('0x21')](function(_0x571395){for(var _0x4b4722=0x0;_0x4b4722<_0x571395[_0x0dc6('0x56')];_0x4b4722++){_0x571395[_0x4b4722][_0x0dc6('0x111')](_0x0dc6('0xa9'),_0x0dc6('0x115'));}return _0x571395;}));_0x358381[_0x0dc6('0x95')](_0x327da7['getSmsQueues']()[_0x0dc6('0x21')](function(_0x1b2822){for(var _0x19ea77=0x0;_0x19ea77<_0x1b2822[_0x0dc6('0x56')];_0x19ea77++){_0x1b2822[_0x19ea77][_0x0dc6('0x111')](_0x0dc6('0xa9'),'Sms');}return _0x1b2822;}));_0x358381[_0x0dc6('0x95')](_0x327da7[_0x0dc6('0x117')]()[_0x0dc6('0x21')](function(_0x4cac62){for(var _0x10ee78=0x0;_0x10ee78<_0x4cac62['length'];_0x10ee78++){_0x4cac62[_0x10ee78]['setDataValue'](_0x0dc6('0xa9'),_0x0dc6('0x122'));}return _0x4cac62;}));_0x358381[_0x0dc6('0x95')](_0x327da7[_0x0dc6('0x118')]()['then'](function(_0x1ce28d){for(var _0xf2f433=0x0;_0xf2f433<_0x1ce28d[_0x0dc6('0x56')];_0xf2f433++){_0x1ce28d[_0xf2f433][_0x0dc6('0x111')]('channel',_0x0dc6('0x119'));}return _0x1ce28d;}));_0x358381[_0x0dc6('0x95')](_0x327da7[_0x0dc6('0x11a')]()[_0x0dc6('0x21')](function(_0x457522){for(var _0x5adac5=0x0;_0x5adac5<_0x457522[_0x0dc6('0x56')];_0x5adac5++){_0x457522[_0x5adac5][_0x0dc6('0x111')](_0x0dc6('0xa9'),_0x0dc6('0x11b'));}return _0x457522;}));return BPromise[_0x0dc6('0x96')](_0x358381);})[_0x0dc6('0x21')](function(_0x392d33){var _0x1a5378=_[_0x0dc6('0x11c')](_0x392d33);_0x358381=[];return db[_0x0dc6('0x5f')][_0x0dc6('0x11d')](function(_0x3a87f3){for(var _0x1dce07=0x0;_0x1dce07<_0x1a5378[_0x0dc6('0x56')];_0x1dce07++){_0x358381[_0x0dc6('0x95')](_0x1a5378[_0x1dce07][_0x0dc6('0x123')](_0x20f028['id']),{'transaction':_0x3a87f3});}return BPromise[_0x0dc6('0x96')](_0x358381)[_0x0dc6('0x21')](function(){if(_0x20f028[_0x0dc6('0xaa')]){return BPromise['each'](_['filter'](_0x1a5378,function(_0x3258fc){return _0x3258fc[_0x0dc6('0x11f')]('channel')===_0x0dc6('0x112');}),function(_0x385966){return db[_0x0dc6('0xbb')]['destroy']({'where':{'VoiceQueueId':_0x385966['id'],'UserId':_0x20f028['id']},'transaction':_0x3a87f3});});}else{return;}})['then'](function(){for(var _0x257068=0x0;_0x257068<_0x1a5378[_0x0dc6('0x56')];_0x257068++){var _0xa2d17=_0x1a5378[_0x257068]['getDataValue']('channel');var _0x3fc7cc=_0xa2d17+'QueueId';socket['emit']('user'+_0xa2d17+_0x0dc6('0xc0'),{'UserId':_0x20f028['id'],['queueField']:_0x1a5378[_0x257068]['id']});}});});});}});}})['then'](respondWithStatusCode(_0x4acd80,null))[_0x0dc6('0x2b')](handleError(_0x4acd80,null));};exports[_0x0dc6('0x124')]=function(_0x46e306,_0x2eac1f,_0x35bced){var _0x559362={};var _0x516ebd={};var _0x133e2c;var _0x58116c;return db[_0x0dc6('0x62')][_0x0dc6('0xa3')]({'where':{'id':_0x46e306['params']['id']}})[_0x0dc6('0x21')](handleEntityNotFound(_0x2eac1f,null))[_0x0dc6('0x21')](function(_0x1ba4c0){if(_0x1ba4c0){_0x133e2c=_0x1ba4c0;_0x516ebd[_0x0dc6('0x4f')]=_[_0x0dc6('0x52')](db[_0x0dc6('0x125')]['rawAttributes']);_0x516ebd[_0x0dc6('0x59')]=_['keys'](_0x46e306[_0x0dc6('0x59')]);_0x516ebd['filters']=_['intersection'](_0x516ebd[_0x0dc6('0x4f')],_0x516ebd[_0x0dc6('0x59')]);_0x559362[_0x0dc6('0x55')]=_[_0x0dc6('0x67')](_0x516ebd[_0x0dc6('0x4f')],qs['fields'](_0x46e306['query']['fields']));_0x559362[_0x0dc6('0x55')]=_0x559362[_0x0dc6('0x55')][_0x0dc6('0x56')]?_0x559362[_0x0dc6('0x55')]:_0x516ebd['model'];_0x559362[_0x0dc6('0x5a')]=qs[_0x0dc6('0x5b')](_0x46e306[_0x0dc6('0x59')][_0x0dc6('0x5b')]);_0x559362[_0x0dc6('0x5c')]=qs[_0x0dc6('0x53')](_[_0x0dc6('0x5d')](_0x46e306['query'],_0x516ebd['filters']));if(_0x46e306[_0x0dc6('0x59')]['filter']){_0x559362[_0x0dc6('0x5c')]=_[_0x0dc6('0x5e')](_0x559362[_0x0dc6('0x5c')],{'$or':_['map'](_0x559362[_0x0dc6('0x55')],function(_0x1388fb){var _0x17e6f4={};_0x17e6f4[_0x1388fb]={'$like':'%'+_0x46e306[_0x0dc6('0x59')][_0x0dc6('0x40')]+'%'};return _0x17e6f4;})});}_0x559362=_[_0x0dc6('0x5e')]({},_0x559362,_0x46e306[_0x0dc6('0x61')]);return _0x133e2c['getLists'](_0x559362);}})[_0x0dc6('0x21')](function(_0x48ffdc){if(_0x48ffdc){_0x58116c=_0x48ffdc[_0x0dc6('0x56')];if(!_0x46e306[_0x0dc6('0x59')]['hasOwnProperty'](_0x0dc6('0x58'))){_0x559362['limit']=qs[_0x0dc6('0x31')](_0x46e306[_0x0dc6('0x59')][_0x0dc6('0x31')]);_0x559362['offset']=qs['offset'](_0x46e306[_0x0dc6('0x59')][_0x0dc6('0x30')]);}return _0x133e2c['getLists'](_0x559362);}})['then'](function(_0x59d339){if(_0x59d339){return _0x59d339?{'count':_0x58116c,'rows':_0x59d339}:null;}})[_0x0dc6('0x21')](respondWithResult(_0x2eac1f,null))[_0x0dc6('0x2b')](handleError(_0x2eac1f,null));};exports[_0x0dc6('0x126')]=function(_0x50e502,_0x1e130f,_0x34e7e8){var _0x290e2a={};var _0xf34b35={};var _0x4ceb05;var _0x586fe2;return db['User'][_0x0dc6('0xa3')]({'where':{'id':_0x50e502['params']['id']}})[_0x0dc6('0x21')](handleEntityNotFound(_0x1e130f,null))[_0x0dc6('0x21')](function(_0x1f72b7){if(_0x1f72b7){_0x4ceb05=_0x1f72b7;_0xf34b35[_0x0dc6('0x4f')]=_[_0x0dc6('0x52')](db[_0x0dc6('0x62')]['rawAttributes']);_0xf34b35[_0x0dc6('0x59')]=_[_0x0dc6('0x52')](_0x50e502[_0x0dc6('0x59')]);_0xf34b35[_0x0dc6('0x53')]=_[_0x0dc6('0x67')](_0xf34b35['model'],_0xf34b35[_0x0dc6('0x59')]);_0x290e2a[_0x0dc6('0x55')]=_[_0x0dc6('0x67')](_0xf34b35[_0x0dc6('0x4f')],qs[_0x0dc6('0x54')](_0x50e502[_0x0dc6('0x59')][_0x0dc6('0x54')]));_0x290e2a['attributes']=_0x290e2a[_0x0dc6('0x55')]['length']?_0x290e2a['attributes']:_0xf34b35[_0x0dc6('0x4f')];_0x290e2a[_0x0dc6('0x5a')]=qs[_0x0dc6('0x5b')](_0x50e502[_0x0dc6('0x59')][_0x0dc6('0x5b')]);_0x290e2a[_0x0dc6('0x5c')]=qs[_0x0dc6('0x53')](_['pick'](_0x50e502[_0x0dc6('0x59')],_0xf34b35[_0x0dc6('0x53')]));if(_0x50e502[_0x0dc6('0x59')][_0x0dc6('0x40')]){_0x290e2a[_0x0dc6('0x5c')]=_[_0x0dc6('0x5e')](_0x290e2a[_0x0dc6('0x5c')],{'$or':_[_0x0dc6('0x41')](_0x290e2a['attributes'],function(_0xd06bb9){var _0x39e720={};_0x39e720[_0xd06bb9]={'$like':'%'+_0x50e502[_0x0dc6('0x59')]['filter']+'%'};return _0x39e720;})});}_0x290e2a[_0x0dc6('0x4f')]=db['User'];_0x290e2a['as']=_0x0dc6('0x3c');_0x290e2a=_[_0x0dc6('0x5e')]({},_0x290e2a,_0x50e502[_0x0dc6('0x61')]);return _0x4ceb05[_0x0dc6('0xed')]({'include':[_0x290e2a]});}})[_0x0dc6('0x21')](function(_0x2422e6){if(_0x2422e6){var _0x1d77ed={},_0x2cc153=[],_0x5b3c67=0x0;for(var _0x2cc8ac=0x0;_0x2cc8ac<_0x2422e6[_0x0dc6('0x56')];_0x2cc8ac+=0x1){for(var _0x1af3a1=0x0,_0x48d710;_0x1af3a1<_0x2422e6[_0x2cc8ac][_0x0dc6('0x3c')][_0x0dc6('0x56')];_0x1af3a1+=0x1){_0x48d710=_0x2422e6[_0x2cc8ac]['Agents'][_0x1af3a1][_0x0dc6('0x38')]({'plain':!![]});_0x1d77ed[_0x48d710['id']]=_0x48d710;}}_0x1d77ed=_[_0x0dc6('0x127')](_0x1d77ed);for(var _0x7840dc=qs[_0x0dc6('0x30')](_0x50e502[_0x0dc6('0x59')][_0x0dc6('0x30')]);_0x7840dc<_0x1d77ed[_0x0dc6('0x56')]&&_0x2cc153[_0x0dc6('0x56')]<qs[_0x0dc6('0x31')](_0x50e502[_0x0dc6('0x59')][_0x0dc6('0x31')]);_0x7840dc+=0x1){if(_0x1d77ed[_0x7840dc]){_0x2cc153['push'](_0x1d77ed[_0x7840dc]);}}return{'count':_0x1d77ed[_0x0dc6('0x56')],'rows':_0x2cc153};}})['then'](respondWithResult(_0x1e130f,null))[_0x0dc6('0x2b')](handleError(_0x1e130f,null));};exports['destroy']=function(_0x514d93,_0x1e0057){if(_0x514d93[_0x0dc6('0x3b')]['id']==_0x514d93['params']['id']){return _0x1e0057[_0x0dc6('0x2c')](0x1f4)[_0x0dc6('0x49')]({'message':_0x0dc6('0x128')});}return db[_0x0dc6('0x62')][_0x0dc6('0x44')]({'where':{'id':_0x514d93[_0x0dc6('0x6a')]['id']}})[_0x0dc6('0x21')](handleEntityNotFound(_0x1e0057,null))[_0x0dc6('0x21')](removeEntity(_0x1e0057,null))['catch'](handleError(_0x1e0057,null));};exports[_0x0dc6('0x129')]=function(_0x997481,_0x134eb4,_0x5353d8){return db['User'][_0x0dc6('0x44')]({'where':{'id':_0x997481[_0x0dc6('0x6a')]['id']}})[_0x0dc6('0x21')](handleEntityNotFound(_0x134eb4,null))[_0x0dc6('0x21')](function(_0x20c107){if(_0x20c107){return _0x20c107['addChatInteractions'](_0x997481['body'][_0x0dc6('0x6d')],_[_0x0dc6('0x6e')](_0x997481[_0x0dc6('0x69')],['ids','id'])||{})[_0x0dc6('0xb4')](function(){for(var _0x58231d=0x0;_0x58231d<_0x997481[_0x0dc6('0x69')][_0x0dc6('0x6d')]['length'];_0x58231d+=0x1){socket[_0x0dc6('0xbf')](_0x0dc6('0x12a'),{'ChatInteractionId':Number(_0x997481[_0x0dc6('0x69')][_0x0dc6('0x6d')][_0x58231d]),'UserId':Number(_0x997481[_0x0dc6('0x6a')]['id'])});}return _0x997481['body'][_0x0dc6('0x6d')];});}})[_0x0dc6('0x21')](respondWithResult(_0x134eb4,null))['catch'](handleError(_0x134eb4,null));};exports[_0x0dc6('0x12b')]=function(_0x56782a,_0xb3b93e,_0xe8e5c4){return db[_0x0dc6('0x62')][_0x0dc6('0x44')]({'where':{'id':_0x56782a[_0x0dc6('0x6a')]['id']}})[_0x0dc6('0x21')](handleEntityNotFound(_0xb3b93e,null))['then'](function(_0x3ba4ce){if(_0x3ba4ce){return _0x3ba4ce[_0x0dc6('0x12b')](_0x56782a[_0x0dc6('0x59')][_0x0dc6('0x6d')])[_0x0dc6('0x21')](function(){if(_[_0x0dc6('0x12c')](_0x56782a[_0x0dc6('0x59')][_0x0dc6('0x6d')])){for(var _0x79878c=0x0;_0x79878c<_0x56782a[_0x0dc6('0x59')][_0x0dc6('0x6d')][_0x0dc6('0x56')];_0x79878c+=0x1){socket[_0x0dc6('0xbf')](_0x0dc6('0x12d'),{'ChatInteractionId':Number(_0x56782a['query'][_0x0dc6('0x6d')][_0x79878c]),'UserId':Number(_0x56782a[_0x0dc6('0x6a')]['id'])});}}else{socket[_0x0dc6('0xbf')](_0x0dc6('0x12d'),{'ChatInteractionId':Number(_0x56782a['query'][_0x0dc6('0x6d')]),'UserId':Number(_0x56782a['params']['id'])});}});}})[_0x0dc6('0x21')](respondWithStatusCode(_0xb3b93e,null))[_0x0dc6('0x2b')](handleError(_0xb3b93e,null));};exports['addMailInteractions']=function(_0x336be4,_0x2d8071,_0x1a516d){return db['User'][_0x0dc6('0x44')]({'where':{'id':_0x336be4[_0x0dc6('0x6a')]['id']}})[_0x0dc6('0x21')](handleEntityNotFound(_0x2d8071,null))['then'](function(_0xf0f712){if(_0xf0f712){return _0xf0f712[_0x0dc6('0x12e')](_0x336be4[_0x0dc6('0x69')][_0x0dc6('0x6d')],_[_0x0dc6('0x6e')](_0x336be4['body'],[_0x0dc6('0x6d'),'id'])||{})[_0x0dc6('0xb4')](function(){for(var _0x340bce=0x0;_0x340bce<_0x336be4[_0x0dc6('0x69')][_0x0dc6('0x6d')]['length'];_0x340bce+=0x1){socket[_0x0dc6('0xbf')](_0x0dc6('0x12f'),{'MailInteractionId':Number(_0x336be4['body'][_0x0dc6('0x6d')][_0x340bce]),'UserId':Number(_0x336be4[_0x0dc6('0x6a')]['id'])});}return _0x336be4[_0x0dc6('0x69')][_0x0dc6('0x6d')];});}})['then'](respondWithResult(_0x2d8071,null))[_0x0dc6('0x2b')](handleError(_0x2d8071,null));};exports[_0x0dc6('0x130')]=function(_0x3a36af,_0x138f5e,_0x593d9b){return db['User'][_0x0dc6('0x44')]({'where':{'id':_0x3a36af['params']['id']}})[_0x0dc6('0x21')](handleEntityNotFound(_0x138f5e,null))['then'](function(_0x27a755){if(_0x27a755){return _0x27a755[_0x0dc6('0x130')](_0x3a36af['query']['ids'])['then'](function(){if(_[_0x0dc6('0x12c')](_0x3a36af[_0x0dc6('0x59')][_0x0dc6('0x6d')])){for(var _0x53431d=0x0;_0x53431d<_0x3a36af[_0x0dc6('0x59')][_0x0dc6('0x6d')]['length'];_0x53431d+=0x1){socket[_0x0dc6('0xbf')]('user_has_mail_interactions:remove',{'MailInteractionId':Number(_0x3a36af[_0x0dc6('0x59')][_0x0dc6('0x6d')][_0x53431d]),'UserId':Number(_0x3a36af[_0x0dc6('0x6a')]['id'])});}}else{socket[_0x0dc6('0xbf')](_0x0dc6('0x131'),{'MailInteractionId':Number(_0x3a36af['query'][_0x0dc6('0x6d')]),'UserId':Number(_0x3a36af[_0x0dc6('0x6a')]['id'])});}});}})[_0x0dc6('0x21')](respondWithStatusCode(_0x138f5e,null))['catch'](handleError(_0x138f5e,null));};exports[_0x0dc6('0x132')]=function(_0x38a799,_0x2d5547,_0x54b5f7){return db[_0x0dc6('0x62')][_0x0dc6('0x44')]({'where':{'id':_0x38a799[_0x0dc6('0x6a')]['id']}})[_0x0dc6('0x21')](handleEntityNotFound(_0x2d5547,null))[_0x0dc6('0x21')](function(_0x38e20b){if(_0x38e20b){return _0x38e20b[_0x0dc6('0x132')](_0x38a799[_0x0dc6('0x69')][_0x0dc6('0x6d')],_['omit'](_0x38a799[_0x0dc6('0x69')],['ids','id'])||{})[_0x0dc6('0xb4')](function(){for(var _0xa55dd4=0x0;_0xa55dd4<_0x38a799[_0x0dc6('0x69')][_0x0dc6('0x6d')][_0x0dc6('0x56')];_0xa55dd4+=0x1){socket[_0x0dc6('0xbf')](_0x0dc6('0x133'),{'FaxInteractionId':Number(_0x38a799[_0x0dc6('0x69')]['ids'][_0xa55dd4]),'UserId':Number(_0x38a799['params']['id'])});}return _0x38a799[_0x0dc6('0x69')]['ids'];});}})['then'](respondWithResult(_0x2d5547,null))[_0x0dc6('0x2b')](handleError(_0x2d5547,null));};exports[_0x0dc6('0x134')]=function(_0x57901d,_0x1e7194,_0x37a7df){return db['User'][_0x0dc6('0x44')]({'where':{'id':_0x57901d['params']['id']}})[_0x0dc6('0x21')](handleEntityNotFound(_0x1e7194,null))['then'](function(_0x53a40d){if(_0x53a40d){return _0x53a40d[_0x0dc6('0x134')](_0x57901d['query'][_0x0dc6('0x6d')])[_0x0dc6('0x21')](function(){if(_[_0x0dc6('0x12c')](_0x57901d[_0x0dc6('0x59')][_0x0dc6('0x6d')])){for(var _0x1703b0=0x0;_0x1703b0<_0x57901d[_0x0dc6('0x59')][_0x0dc6('0x6d')][_0x0dc6('0x56')];_0x1703b0+=0x1){socket[_0x0dc6('0xbf')](_0x0dc6('0x135'),{'FaxInteractionId':Number(_0x57901d[_0x0dc6('0x59')][_0x0dc6('0x6d')][_0x1703b0]),'UserId':Number(_0x57901d['params']['id'])});}}else{socket[_0x0dc6('0xbf')](_0x0dc6('0x135'),{'FaxInteractionId':Number(_0x57901d['query']['ids']),'UserId':Number(_0x57901d[_0x0dc6('0x6a')]['id'])});}});}})[_0x0dc6('0x21')](respondWithStatusCode(_0x1e7194,null))['catch'](handleError(_0x1e7194,null));};exports[_0x0dc6('0x136')]=function(_0x44b65f,_0x245073,_0x1a655d){return db[_0x0dc6('0x62')][_0x0dc6('0x44')]({'where':{'id':_0x44b65f['params']['id']}})[_0x0dc6('0x21')](handleEntityNotFound(_0x245073,null))['then'](function(_0x224a1b){if(_0x224a1b){return _0x224a1b[_0x0dc6('0x136')](_0x44b65f[_0x0dc6('0x69')][_0x0dc6('0x6d')],_[_0x0dc6('0x6e')](_0x44b65f['body'],[_0x0dc6('0x6d'),'id'])||{})[_0x0dc6('0xb4')](function(){for(var _0x2c2f11=0x0;_0x2c2f11<_0x44b65f[_0x0dc6('0x69')][_0x0dc6('0x6d')][_0x0dc6('0x56')];_0x2c2f11+=0x1){socket[_0x0dc6('0xbf')]('user_has_sms_interactions:save',{'SmsInteractionId':Number(_0x44b65f['body'][_0x0dc6('0x6d')][_0x2c2f11]),'UserId':Number(_0x44b65f['params']['id'])});}return _0x44b65f[_0x0dc6('0x69')][_0x0dc6('0x6d')];});}})['then'](respondWithResult(_0x245073,null))[_0x0dc6('0x2b')](handleError(_0x245073,null));};exports[_0x0dc6('0x137')]=function(_0x410c99,_0x2702d8,_0x1b19b0){return db[_0x0dc6('0x62')][_0x0dc6('0x44')]({'where':{'id':_0x410c99[_0x0dc6('0x6a')]['id']}})[_0x0dc6('0x21')](handleEntityNotFound(_0x2702d8,null))[_0x0dc6('0x21')](function(_0x349a45){if(_0x349a45){return _0x349a45[_0x0dc6('0x137')](_0x410c99[_0x0dc6('0x59')]['ids'])['then'](function(){if(_[_0x0dc6('0x12c')](_0x410c99[_0x0dc6('0x59')]['ids'])){for(var _0x9e5bc6=0x0;_0x9e5bc6<_0x410c99['query'][_0x0dc6('0x6d')][_0x0dc6('0x56')];_0x9e5bc6+=0x1){socket[_0x0dc6('0xbf')](_0x0dc6('0x138'),{'SmsInteractionId':Number(_0x410c99[_0x0dc6('0x59')]['ids'][_0x9e5bc6]),'UserId':Number(_0x410c99[_0x0dc6('0x6a')]['id'])});}}else{socket[_0x0dc6('0xbf')](_0x0dc6('0x138'),{'SmsInteractionId':Number(_0x410c99[_0x0dc6('0x59')][_0x0dc6('0x6d')]),'UserId':Number(_0x410c99['params']['id'])});}});}})[_0x0dc6('0x21')](respondWithStatusCode(_0x2702d8,null))[_0x0dc6('0x2b')](handleError(_0x2702d8,null));};exports[_0x0dc6('0x139')]=function(_0x4f22a9,_0x4ea3a0,_0x4ac873){return db['User']['find']({'where':{'id':_0x4f22a9['params']['id']}})[_0x0dc6('0x21')](handleEntityNotFound(_0x4ea3a0,null))[_0x0dc6('0x21')](function(_0x7ec3b4){if(_0x7ec3b4){return _0x7ec3b4['addOpenchannelInteractions'](_0x4f22a9['body'][_0x0dc6('0x6d')],_[_0x0dc6('0x6e')](_0x4f22a9[_0x0dc6('0x69')],[_0x0dc6('0x6d'),'id'])||{})[_0x0dc6('0xb4')](function(){for(var _0x402d69=0x0;_0x402d69<_0x4f22a9[_0x0dc6('0x69')][_0x0dc6('0x6d')][_0x0dc6('0x56')];_0x402d69+=0x1){socket[_0x0dc6('0xbf')](_0x0dc6('0x13a'),{'OpenchannelInteractionId':Number(_0x4f22a9[_0x0dc6('0x69')][_0x0dc6('0x6d')][_0x402d69]),'UserId':Number(_0x4f22a9['params']['id'])});}return _0x4f22a9[_0x0dc6('0x69')][_0x0dc6('0x6d')];});}})[_0x0dc6('0x21')](respondWithResult(_0x4ea3a0,null))[_0x0dc6('0x2b')](handleError(_0x4ea3a0,null));};exports['removeOpenchannelInteractions']=function(_0x27abb7,_0xb2ad6e,_0x176d95){return db['User'][_0x0dc6('0x44')]({'where':{'id':_0x27abb7['params']['id']}})[_0x0dc6('0x21')](handleEntityNotFound(_0xb2ad6e,null))[_0x0dc6('0x21')](function(_0x12cae4){if(_0x12cae4){return _0x12cae4[_0x0dc6('0x13b')](_0x27abb7['query'][_0x0dc6('0x6d')])[_0x0dc6('0x21')](function(){if(_['isArray'](_0x27abb7['query']['ids'])){for(var _0x2c7c91=0x0;_0x2c7c91<_0x27abb7[_0x0dc6('0x59')][_0x0dc6('0x6d')][_0x0dc6('0x56')];_0x2c7c91+=0x1){socket['emit'](_0x0dc6('0x13c'),{'OpenchannelInteractionId':Number(_0x27abb7[_0x0dc6('0x59')][_0x0dc6('0x6d')][_0x2c7c91]),'UserId':Number(_0x27abb7['params']['id'])});}}else{socket[_0x0dc6('0xbf')](_0x0dc6('0x13c'),{'OpenchannelInteractionId':Number(_0x27abb7[_0x0dc6('0x59')][_0x0dc6('0x6d')]),'UserId':Number(_0x27abb7[_0x0dc6('0x6a')]['id'])});}});}})[_0x0dc6('0x21')](respondWithStatusCode(_0xb2ad6e,null))[_0x0dc6('0x2b')](handleError(_0xb2ad6e,null));};exports['addWhatsappInteractions']=function(_0x515d59,_0x2de9f6,_0xdaba2){return db['User'][_0x0dc6('0x44')]({'where':{'id':_0x515d59['params']['id']}})[_0x0dc6('0x21')](handleEntityNotFound(_0x2de9f6,null))[_0x0dc6('0x21')](function(_0x4e0c95){if(_0x4e0c95){return _0x4e0c95[_0x0dc6('0x13d')](_0x515d59[_0x0dc6('0x69')][_0x0dc6('0x6d')],_[_0x0dc6('0x6e')](_0x515d59[_0x0dc6('0x69')],[_0x0dc6('0x6d'),'id'])||{})[_0x0dc6('0xb4')](function(){for(var _0x38ea45=0x0;_0x38ea45<_0x515d59['body']['ids'][_0x0dc6('0x56')];_0x38ea45+=0x1){socket[_0x0dc6('0xbf')](_0x0dc6('0x13e'),{'WhatsappInteractionId':Number(_0x515d59[_0x0dc6('0x69')]['ids'][_0x38ea45]),'UserId':Number(_0x515d59[_0x0dc6('0x6a')]['id'])});}return _0x515d59[_0x0dc6('0x69')]['ids'];});}})[_0x0dc6('0x21')](respondWithResult(_0x2de9f6,null))[_0x0dc6('0x2b')](handleError(_0x2de9f6,null));};exports[_0x0dc6('0x13f')]=function(_0xf5d08e,_0x81bfc5,_0x3cc3fc){return db[_0x0dc6('0x62')]['find']({'where':{'id':_0xf5d08e[_0x0dc6('0x6a')]['id']}})[_0x0dc6('0x21')](handleEntityNotFound(_0x81bfc5,null))['then'](function(_0x2c436e){if(_0x2c436e){return _0x2c436e[_0x0dc6('0x13f')](_0xf5d08e[_0x0dc6('0x59')]['ids']);}})[_0x0dc6('0x21')](respondWithStatusCode(_0x81bfc5,null))['catch'](handleError(_0x81bfc5,null));};exports[_0x0dc6('0x140')]=function(_0x4f0bc2,_0xace716,_0x407e63){var _0x12e2df={};var _0x47fb4d={};var _0x15d7b0;var _0x5e3e8e;return db[_0x0dc6('0x62')][_0x0dc6('0xa3')]({'where':{'id':_0x4f0bc2[_0x0dc6('0x6a')]['id']}})[_0x0dc6('0x21')](handleEntityNotFound(_0xace716,null))[_0x0dc6('0x21')](function(_0x3d04e2){if(_0x3d04e2){_0x15d7b0=_0x3d04e2;_0x47fb4d[_0x0dc6('0x4f')]=_[_0x0dc6('0x52')](db[_0x0dc6('0x141')][_0x0dc6('0x4b')]);_0x47fb4d['query']=_[_0x0dc6('0x52')](_0x4f0bc2[_0x0dc6('0x59')]);_0x47fb4d['filters']=_[_0x0dc6('0x67')](_0x47fb4d['model'],_0x47fb4d[_0x0dc6('0x59')]);_0x12e2df['attributes']=_[_0x0dc6('0x67')](_0x47fb4d[_0x0dc6('0x4f')],qs[_0x0dc6('0x54')](_0x4f0bc2[_0x0dc6('0x59')][_0x0dc6('0x54')]));_0x12e2df[_0x0dc6('0x55')]=_0x12e2df[_0x0dc6('0x55')][_0x0dc6('0x56')]?_0x12e2df[_0x0dc6('0x55')]:_0x47fb4d['model'];_0x12e2df['order']=qs[_0x0dc6('0x5b')](_0x4f0bc2[_0x0dc6('0x59')]['sort']);_0x12e2df[_0x0dc6('0x5c')]=qs['filters'](_[_0x0dc6('0x5d')](_0x4f0bc2[_0x0dc6('0x59')],_0x47fb4d[_0x0dc6('0x53')]));if(_0x4f0bc2[_0x0dc6('0x59')][_0x0dc6('0x40')]){_0x12e2df['where']=_[_0x0dc6('0x5e')](_0x12e2df['where'],{'$or':_[_0x0dc6('0x41')](_0x12e2df[_0x0dc6('0x55')],function(_0x3ca706){var _0x35a121={};_0x35a121[_0x3ca706]={'$like':'%'+_0x4f0bc2['query'][_0x0dc6('0x40')]+'%'};return _0x35a121;})});}_0x12e2df=_[_0x0dc6('0x5e')]({},_0x12e2df,_0x4f0bc2['options']);return _0x15d7b0['getVoicePrefixes'](_0x12e2df);}})[_0x0dc6('0x21')](function(_0x4b23ba){if(_0x4b23ba){_0x5e3e8e=_0x4b23ba['length'];if(!_0x4f0bc2['query'][_0x0dc6('0x57')](_0x0dc6('0x58'))){_0x12e2df['limit']=qs['limit'](_0x4f0bc2[_0x0dc6('0x59')]['limit']);_0x12e2df[_0x0dc6('0x30')]=qs[_0x0dc6('0x30')](_0x4f0bc2[_0x0dc6('0x59')]['offset']);}return _0x15d7b0[_0x0dc6('0x140')](_0x12e2df);}})[_0x0dc6('0x21')](function(_0x178e43){if(_0x178e43){return _0x178e43?{'count':_0x5e3e8e,'rows':_0x178e43}:null;}})[_0x0dc6('0x21')](respondWithResult(_0xace716,null))[_0x0dc6('0x2b')](handleError(_0xace716,null));};exports[_0x0dc6('0x142')]=function(_0x32a215,_0xe6b5fe,_0x505501){var _0x5096b4={};var _0xc9e3c={};var _0x3cbe1a;var _0x40b969;return db[_0x0dc6('0x62')][_0x0dc6('0xa3')]({'where':{'id':_0x32a215[_0x0dc6('0x6a')]['id']}})[_0x0dc6('0x21')](handleEntityNotFound(_0xe6b5fe,null))['then'](function(_0x2735b0){if(_0x2735b0){_0x3cbe1a=_0x2735b0;_0xc9e3c['model']=_[_0x0dc6('0x52')](db[_0x0dc6('0x143')][_0x0dc6('0x4b')]);_0xc9e3c[_0x0dc6('0x59')]=_[_0x0dc6('0x52')](_0x32a215['query']);_0xc9e3c[_0x0dc6('0x53')]=_[_0x0dc6('0x67')](_0xc9e3c[_0x0dc6('0x4f')],_0xc9e3c[_0x0dc6('0x59')]);_0x5096b4[_0x0dc6('0x55')]=_['intersection'](_0xc9e3c[_0x0dc6('0x4f')],qs[_0x0dc6('0x54')](_0x32a215[_0x0dc6('0x59')][_0x0dc6('0x54')]));_0x5096b4[_0x0dc6('0x55')]=_0x5096b4[_0x0dc6('0x55')][_0x0dc6('0x56')]?_0x5096b4['attributes']:_0xc9e3c[_0x0dc6('0x4f')];_0x5096b4[_0x0dc6('0x5a')]=qs[_0x0dc6('0x5b')](_0x32a215['query'][_0x0dc6('0x5b')]);_0x5096b4[_0x0dc6('0x5c')]=qs[_0x0dc6('0x53')](_[_0x0dc6('0x5d')](_0x32a215[_0x0dc6('0x59')],_0xc9e3c['filters']));if(_0x32a215[_0x0dc6('0x59')]['filter']){_0x5096b4[_0x0dc6('0x5c')]=_[_0x0dc6('0x5e')](_0x5096b4[_0x0dc6('0x5c')],{'$or':_['map'](_0x5096b4[_0x0dc6('0x55')],function(_0x3a47c7){var _0x3d2b8f={};_0x3d2b8f[_0x3a47c7]={'$like':'%'+_0x32a215[_0x0dc6('0x59')][_0x0dc6('0x40')]+'%'};return _0x3d2b8f;})});}_0x5096b4=_['merge']({},_0x5096b4,_0x32a215['options']);return _0x3cbe1a[_0x0dc6('0x142')](_0x5096b4);}})['then'](function(_0x47bc2a){if(_0x47bc2a){_0x40b969=_0x47bc2a[_0x0dc6('0x56')];if(!_0x32a215[_0x0dc6('0x59')][_0x0dc6('0x57')]('nolimit')){_0x5096b4['limit']=qs[_0x0dc6('0x31')](_0x32a215[_0x0dc6('0x59')][_0x0dc6('0x31')]);_0x5096b4[_0x0dc6('0x30')]=qs[_0x0dc6('0x30')](_0x32a215[_0x0dc6('0x59')][_0x0dc6('0x30')]);}return _0x3cbe1a[_0x0dc6('0x142')](_0x5096b4);}})[_0x0dc6('0x21')](function(_0x257a9e){if(_0x257a9e){return _0x257a9e?{'count':_0x40b969,'rows':_0x257a9e}:null;}})[_0x0dc6('0x21')](respondWithResult(_0xe6b5fe,null))[_0x0dc6('0x2b')](handleError(_0xe6b5fe,null));};exports[_0x0dc6('0x144')]=function(_0x2c00cb,_0x5b35f4,_0x75d070){return db[_0x0dc6('0x62')]['find']({'where':{'id':_0x2c00cb['params']['id']}})['then'](handleEntityNotFound(_0x5b35f4,null))[_0x0dc6('0x21')](function(_0x1269f7){if(_0x1269f7){return _0x1269f7[_0x0dc6('0x144')](_0x2c00cb[_0x0dc6('0x69')]['ids'],_[_0x0dc6('0x6e')](_0x2c00cb['body'],['ids','id'])||{});}})[_0x0dc6('0x21')](respondWithResult(_0x5b35f4,null))['catch'](handleError(_0x5b35f4,null));};exports['removeFaxAccounts']=function(_0x2b9514,_0x32060e,_0x40cbca){return db[_0x0dc6('0x62')][_0x0dc6('0x44')]({'where':{'id':_0x2b9514['params']['id']}})['then'](handleEntityNotFound(_0x32060e,null))['then'](function(_0x545640){if(_0x545640){return _0x545640['removeFaxAccounts'](_0x2b9514[_0x0dc6('0x59')][_0x0dc6('0x6d')]);}})[_0x0dc6('0x21')](respondWithStatusCode(_0x32060e,null))[_0x0dc6('0x2b')](handleError(_0x32060e,null));};exports[_0x0dc6('0x145')]=function(_0xc0e877,_0x534c4b,_0x339ca3){var _0x7d9664={};var _0xeeb29={};var _0x77beab;var _0x21bd9a;return db[_0x0dc6('0x62')][_0x0dc6('0xa3')]({'where':{'id':_0xc0e877[_0x0dc6('0x6a')]['id']}})['then'](handleEntityNotFound(_0x534c4b,null))[_0x0dc6('0x21')](function(_0x41339d){if(_0x41339d){_0x77beab=_0x41339d;_0xeeb29['model']=_[_0x0dc6('0x52')](db['MailAccount']['rawAttributes']);_0xeeb29['query']=_[_0x0dc6('0x52')](_0xc0e877[_0x0dc6('0x59')]);_0xeeb29[_0x0dc6('0x53')]=_[_0x0dc6('0x67')](_0xeeb29['model'],_0xeeb29['query']);_0x7d9664['attributes']=_['intersection'](_0xeeb29['model'],qs['fields'](_0xc0e877[_0x0dc6('0x59')][_0x0dc6('0x54')]));_0x7d9664[_0x0dc6('0x55')]=_0x7d9664['attributes'][_0x0dc6('0x56')]?_0x7d9664[_0x0dc6('0x55')]:_0xeeb29[_0x0dc6('0x4f')];_0x7d9664['order']=qs[_0x0dc6('0x5b')](_0xc0e877[_0x0dc6('0x59')][_0x0dc6('0x5b')]);_0x7d9664[_0x0dc6('0x5c')]=qs[_0x0dc6('0x53')](_[_0x0dc6('0x5d')](_0xc0e877[_0x0dc6('0x59')],_0xeeb29['filters']));if(_0xc0e877[_0x0dc6('0x59')][_0x0dc6('0x40')]){_0x7d9664[_0x0dc6('0x5c')]=_['merge'](_0x7d9664[_0x0dc6('0x5c')],{'$or':_[_0x0dc6('0x41')](_0x7d9664['attributes'],function(_0x19b5cf){var _0x3ddb56={};_0x3ddb56[_0x19b5cf]={'$like':'%'+_0xc0e877[_0x0dc6('0x59')][_0x0dc6('0x40')]+'%'};return _0x3ddb56;})});}_0x7d9664=_[_0x0dc6('0x5e')]({},_0x7d9664,_0xc0e877[_0x0dc6('0x61')]);return _0x77beab[_0x0dc6('0x145')](_0x7d9664);}})[_0x0dc6('0x21')](function(_0x385f45){if(_0x385f45){_0x21bd9a=_0x385f45[_0x0dc6('0x56')];if(!_0xc0e877[_0x0dc6('0x59')]['hasOwnProperty'](_0x0dc6('0x58'))){_0x7d9664[_0x0dc6('0x31')]=qs['limit'](_0xc0e877[_0x0dc6('0x59')][_0x0dc6('0x31')]);_0x7d9664[_0x0dc6('0x30')]=qs[_0x0dc6('0x30')](_0xc0e877[_0x0dc6('0x59')][_0x0dc6('0x30')]);}return _0x77beab[_0x0dc6('0x145')](_0x7d9664);}})[_0x0dc6('0x21')](function(_0x2629bb){if(_0x2629bb){return _0x2629bb?{'count':_0x21bd9a,'rows':_0x2629bb}:null;}})[_0x0dc6('0x21')](respondWithResult(_0x534c4b,null))[_0x0dc6('0x2b')](handleError(_0x534c4b,null));};exports[_0x0dc6('0x146')]=function(_0x5c3f7a,_0x22badf,_0x288e35){return db[_0x0dc6('0x62')][_0x0dc6('0x44')]({'where':{'id':_0x5c3f7a[_0x0dc6('0x6a')]['id']}})['then'](handleEntityNotFound(_0x22badf,null))[_0x0dc6('0x21')](function(_0x9965cc){if(_0x9965cc){return _0x9965cc['addMailAccounts'](_0x5c3f7a[_0x0dc6('0x69')][_0x0dc6('0x6d')],_[_0x0dc6('0x6e')](_0x5c3f7a[_0x0dc6('0x69')],[_0x0dc6('0x6d'),'id'])||{});}})['then'](respondWithResult(_0x22badf,null))['catch'](handleError(_0x22badf,null));};exports[_0x0dc6('0x147')]=function(_0x528e11,_0x2dc12e,_0x2a768e){return db[_0x0dc6('0x62')][_0x0dc6('0x44')]({'where':{'id':_0x528e11[_0x0dc6('0x6a')]['id']}})[_0x0dc6('0x21')](handleEntityNotFound(_0x2dc12e,null))[_0x0dc6('0x21')](function(_0x2fc9f9){if(_0x2fc9f9){return _0x2fc9f9['removeMailAccounts'](_0x528e11[_0x0dc6('0x59')][_0x0dc6('0x6d')]);}})[_0x0dc6('0x21')](respondWithStatusCode(_0x2dc12e,null))[_0x0dc6('0x2b')](handleError(_0x2dc12e,null));};exports[_0x0dc6('0x148')]=function(_0x3d0b2c,_0x383574,_0x51a057){var _0x959d76={};var _0x54edc4={};var _0x398701;var _0x3ae55c;return db['User']['findOne']({'where':{'id':_0x3d0b2c[_0x0dc6('0x6a')]['id']}})[_0x0dc6('0x21')](handleEntityNotFound(_0x383574,null))[_0x0dc6('0x21')](function(_0x3e6d9c){if(_0x3e6d9c){_0x398701=_0x3e6d9c;_0x54edc4[_0x0dc6('0x4f')]=_[_0x0dc6('0x52')](db[_0x0dc6('0x149')]['rawAttributes']);_0x54edc4['query']=_[_0x0dc6('0x52')](_0x3d0b2c[_0x0dc6('0x59')]);_0x54edc4[_0x0dc6('0x53')]=_[_0x0dc6('0x67')](_0x54edc4['model'],_0x54edc4[_0x0dc6('0x59')]);_0x959d76[_0x0dc6('0x55')]=_['intersection'](_0x54edc4[_0x0dc6('0x4f')],qs[_0x0dc6('0x54')](_0x3d0b2c['query'][_0x0dc6('0x54')]));_0x959d76[_0x0dc6('0x55')]=_0x959d76[_0x0dc6('0x55')]['length']?_0x959d76['attributes']:_0x54edc4[_0x0dc6('0x4f')];_0x959d76[_0x0dc6('0x5a')]=qs[_0x0dc6('0x5b')](_0x3d0b2c[_0x0dc6('0x59')][_0x0dc6('0x5b')]);_0x959d76[_0x0dc6('0x5c')]=qs[_0x0dc6('0x53')](_['pick'](_0x3d0b2c['query'],_0x54edc4['filters']));if(_0x3d0b2c[_0x0dc6('0x59')]['filter']){_0x959d76[_0x0dc6('0x5c')]=_['merge'](_0x959d76[_0x0dc6('0x5c')],{'$or':_[_0x0dc6('0x41')](_0x959d76[_0x0dc6('0x55')],function(_0x3335ae){var _0x339bcc={};_0x339bcc[_0x3335ae]={'$like':'%'+_0x3d0b2c[_0x0dc6('0x59')][_0x0dc6('0x40')]+'%'};return _0x339bcc;})});}_0x959d76=_[_0x0dc6('0x5e')]({},_0x959d76,_0x3d0b2c[_0x0dc6('0x61')]);return _0x398701[_0x0dc6('0x148')](_0x959d76);}})['then'](function(_0x3c3064){if(_0x3c3064){_0x3ae55c=_0x3c3064[_0x0dc6('0x56')];if(!_0x3d0b2c['query'][_0x0dc6('0x57')](_0x0dc6('0x58'))){_0x959d76[_0x0dc6('0x31')]=qs[_0x0dc6('0x31')](_0x3d0b2c['query']['limit']);_0x959d76['offset']=qs['offset'](_0x3d0b2c[_0x0dc6('0x59')][_0x0dc6('0x30')]);}return _0x398701[_0x0dc6('0x148')](_0x959d76);}})[_0x0dc6('0x21')](function(_0xca9981){if(_0xca9981){return _0xca9981?{'count':_0x3ae55c,'rows':_0xca9981}:null;}})[_0x0dc6('0x21')](respondWithResult(_0x383574,null))[_0x0dc6('0x2b')](handleError(_0x383574,null));};exports['addOpenchannelAccounts']=function(_0x3a558d,_0x2ed083,_0x4b283d){return db[_0x0dc6('0x62')][_0x0dc6('0x44')]({'where':{'id':_0x3a558d['params']['id']}})[_0x0dc6('0x21')](handleEntityNotFound(_0x2ed083,null))['then'](function(_0x56484f){if(_0x56484f){return _0x56484f[_0x0dc6('0x14a')](_0x3a558d['body']['ids'],_[_0x0dc6('0x6e')](_0x3a558d['body'],[_0x0dc6('0x6d'),'id'])||{});}})[_0x0dc6('0x21')](respondWithResult(_0x2ed083,null))[_0x0dc6('0x2b')](handleError(_0x2ed083,null));};exports['removeOpenchannelAccounts']=function(_0x39182b,_0x2f26ee,_0x40765f){return db['User'][_0x0dc6('0x44')]({'where':{'id':_0x39182b[_0x0dc6('0x6a')]['id']}})[_0x0dc6('0x21')](handleEntityNotFound(_0x2f26ee,null))[_0x0dc6('0x21')](function(_0x467d33){if(_0x467d33){return _0x467d33[_0x0dc6('0x14b')](_0x39182b[_0x0dc6('0x59')][_0x0dc6('0x6d')]);}})[_0x0dc6('0x21')](respondWithStatusCode(_0x2f26ee,null))[_0x0dc6('0x2b')](handleError(_0x2f26ee,null));};exports[_0x0dc6('0x14c')]=function(_0x56002,_0x63dc1,_0x361c17){var _0x26a755={};var _0x374cc5={};var _0x41852e;var _0x123da9;return db[_0x0dc6('0x62')][_0x0dc6('0xa3')]({'where':{'id':_0x56002[_0x0dc6('0x6a')]['id']}})[_0x0dc6('0x21')](handleEntityNotFound(_0x63dc1,null))['then'](function(_0x1eff11){if(_0x1eff11){_0x41852e=_0x1eff11;_0x374cc5[_0x0dc6('0x4f')]=_[_0x0dc6('0x52')](db[_0x0dc6('0x14d')][_0x0dc6('0x4b')]);_0x374cc5[_0x0dc6('0x59')]=_[_0x0dc6('0x52')](_0x56002[_0x0dc6('0x59')]);_0x374cc5[_0x0dc6('0x53')]=_[_0x0dc6('0x67')](_0x374cc5[_0x0dc6('0x4f')],_0x374cc5[_0x0dc6('0x59')]);_0x26a755[_0x0dc6('0x55')]=_[_0x0dc6('0x67')](_0x374cc5['model'],qs['fields'](_0x56002[_0x0dc6('0x59')][_0x0dc6('0x54')]));_0x26a755[_0x0dc6('0x55')]=_0x26a755['attributes'][_0x0dc6('0x56')]?_0x26a755[_0x0dc6('0x55')]:_0x374cc5['model'];_0x26a755[_0x0dc6('0x5a')]=qs[_0x0dc6('0x5b')](_0x56002['query']['sort']);_0x26a755[_0x0dc6('0x5c')]=qs[_0x0dc6('0x53')](_[_0x0dc6('0x5d')](_0x56002['query'],_0x374cc5['filters']));if(_0x56002['query']['filter']){_0x26a755[_0x0dc6('0x5c')]=_[_0x0dc6('0x5e')](_0x26a755['where'],{'$or':_[_0x0dc6('0x41')](_0x26a755['attributes'],function(_0x9185c5){var _0x4e13e1={};_0x4e13e1[_0x9185c5]={'$like':'%'+_0x56002[_0x0dc6('0x59')][_0x0dc6('0x40')]+'%'};return _0x4e13e1;})});}_0x26a755=_['merge']({},_0x26a755,_0x56002['options']);return _0x41852e[_0x0dc6('0x14c')](_0x26a755);}})[_0x0dc6('0x21')](function(_0x510d97){if(_0x510d97){_0x123da9=_0x510d97[_0x0dc6('0x56')];if(!_0x56002['query']['hasOwnProperty'](_0x0dc6('0x58'))){_0x26a755[_0x0dc6('0x31')]=qs[_0x0dc6('0x31')](_0x56002[_0x0dc6('0x59')][_0x0dc6('0x31')]);_0x26a755[_0x0dc6('0x30')]=qs[_0x0dc6('0x30')](_0x56002['query']['offset']);}return _0x41852e[_0x0dc6('0x14c')](_0x26a755);}})[_0x0dc6('0x21')](function(_0xfb47e6){if(_0xfb47e6){return _0xfb47e6?{'count':_0x123da9,'rows':_0xfb47e6}:null;}})['then'](respondWithResult(_0x63dc1,null))[_0x0dc6('0x2b')](handleError(_0x63dc1,null));};exports['addSmsAccounts']=function(_0x34cc4e,_0x27905f,_0x340801){return db['User'][_0x0dc6('0x44')]({'where':{'id':_0x34cc4e[_0x0dc6('0x6a')]['id']}})['then'](handleEntityNotFound(_0x27905f,null))[_0x0dc6('0x21')](function(_0x481c5e){if(_0x481c5e){return _0x481c5e[_0x0dc6('0x14e')](_0x34cc4e[_0x0dc6('0x69')][_0x0dc6('0x6d')],_[_0x0dc6('0x6e')](_0x34cc4e['body'],[_0x0dc6('0x6d'),'id'])||{});}})[_0x0dc6('0x21')](respondWithResult(_0x27905f,null))[_0x0dc6('0x2b')](handleError(_0x27905f,null));};exports[_0x0dc6('0x14f')]=function(_0x3d8837,_0x13468f,_0x591eb3){return db['User']['find']({'where':{'id':_0x3d8837[_0x0dc6('0x6a')]['id']}})[_0x0dc6('0x21')](handleEntityNotFound(_0x13468f,null))[_0x0dc6('0x21')](function(_0x31de54){if(_0x31de54){return _0x31de54['removeSmsAccounts'](_0x3d8837[_0x0dc6('0x59')]['ids']);}})[_0x0dc6('0x21')](respondWithStatusCode(_0x13468f,null))[_0x0dc6('0x2b')](handleError(_0x13468f,null));};exports[_0x0dc6('0x150')]=function(_0x3ca4ec,_0x22725e,_0x41bf92){var _0x4d6fde={};var _0x1884cd={};var _0x566594;var _0x28a7bd;return db[_0x0dc6('0x62')]['findOne']({'where':{'id':_0x3ca4ec[_0x0dc6('0x6a')]['id']}})['then'](handleEntityNotFound(_0x22725e,null))[_0x0dc6('0x21')](function(_0x4f2f91){if(_0x4f2f91){_0x566594=_0x4f2f91;_0x1884cd[_0x0dc6('0x4f')]=_[_0x0dc6('0x52')](db[_0x0dc6('0x151')][_0x0dc6('0x4b')]);_0x1884cd[_0x0dc6('0x59')]=_[_0x0dc6('0x52')](_0x3ca4ec['query']);_0x1884cd[_0x0dc6('0x53')]=_[_0x0dc6('0x67')](_0x1884cd[_0x0dc6('0x4f')],_0x1884cd[_0x0dc6('0x59')]);_0x4d6fde[_0x0dc6('0x55')]=_['intersection'](_0x1884cd[_0x0dc6('0x4f')],qs[_0x0dc6('0x54')](_0x3ca4ec[_0x0dc6('0x59')][_0x0dc6('0x54')]));_0x4d6fde[_0x0dc6('0x55')]=_0x4d6fde[_0x0dc6('0x55')]['length']?_0x4d6fde[_0x0dc6('0x55')]:_0x1884cd[_0x0dc6('0x4f')];_0x4d6fde[_0x0dc6('0x5a')]=qs[_0x0dc6('0x5b')](_0x3ca4ec['query'][_0x0dc6('0x5b')]);_0x4d6fde[_0x0dc6('0x5c')]=qs['filters'](_[_0x0dc6('0x5d')](_0x3ca4ec[_0x0dc6('0x59')],_0x1884cd['filters']));if(_0x3ca4ec['query'][_0x0dc6('0x40')]){_0x4d6fde[_0x0dc6('0x5c')]=_[_0x0dc6('0x5e')](_0x4d6fde['where'],{'$or':_[_0x0dc6('0x41')](_0x4d6fde[_0x0dc6('0x55')],function(_0x131d92){var _0x29933f={};_0x29933f[_0x131d92]={'$like':'%'+_0x3ca4ec['query']['filter']+'%'};return _0x29933f;})});}_0x4d6fde=_[_0x0dc6('0x5e')]({},_0x4d6fde,_0x3ca4ec[_0x0dc6('0x61')]);return _0x566594[_0x0dc6('0x150')](_0x4d6fde);}})[_0x0dc6('0x21')](function(_0x13727f){if(_0x13727f){_0x28a7bd=_0x13727f[_0x0dc6('0x56')];if(!_0x3ca4ec[_0x0dc6('0x59')][_0x0dc6('0x57')](_0x0dc6('0x58'))){_0x4d6fde[_0x0dc6('0x31')]=qs[_0x0dc6('0x31')](_0x3ca4ec[_0x0dc6('0x59')][_0x0dc6('0x31')]);_0x4d6fde[_0x0dc6('0x30')]=qs[_0x0dc6('0x30')](_0x3ca4ec[_0x0dc6('0x59')][_0x0dc6('0x30')]);}return _0x566594[_0x0dc6('0x150')](_0x4d6fde);}})[_0x0dc6('0x21')](function(_0x248c76){if(_0x248c76){return _0x248c76?{'count':_0x28a7bd,'rows':_0x248c76}:null;}})[_0x0dc6('0x21')](respondWithResult(_0x22725e,null))[_0x0dc6('0x2b')](handleError(_0x22725e,null));};exports[_0x0dc6('0x152')]=function(_0x4487d3,_0x12abf0,_0x53ab60){return db['User'][_0x0dc6('0x44')]({'where':{'id':_0x4487d3[_0x0dc6('0x6a')]['id']}})[_0x0dc6('0x21')](handleEntityNotFound(_0x12abf0,null))[_0x0dc6('0x21')](function(_0x4451c3){if(_0x4451c3){return _0x4451c3[_0x0dc6('0x152')](_0x4487d3['body'][_0x0dc6('0x6d')],_[_0x0dc6('0x6e')](_0x4487d3['body'],[_0x0dc6('0x6d'),'id'])||{});}})[_0x0dc6('0x21')](respondWithResult(_0x12abf0,null))[_0x0dc6('0x2b')](handleError(_0x12abf0,null));};exports[_0x0dc6('0x153')]=function(_0x3cd5a8,_0x4b2f5b,_0x2aef95){return db[_0x0dc6('0x62')][_0x0dc6('0x44')]({'where':{'id':_0x3cd5a8[_0x0dc6('0x6a')]['id']}})['then'](handleEntityNotFound(_0x4b2f5b,null))[_0x0dc6('0x21')](function(_0x1b1a37){if(_0x1b1a37){return _0x1b1a37[_0x0dc6('0x153')](_0x3cd5a8['query'][_0x0dc6('0x6d')]);}})['then'](respondWithStatusCode(_0x4b2f5b,null))[_0x0dc6('0x2b')](handleError(_0x4b2f5b,null));};exports[_0x0dc6('0x154')]=function(_0x5a96a0,_0x52b27d,_0x19accb){var _0x3acb54={};var _0x34a0db={};var _0x3d33fe;var _0x40056a;return db[_0x0dc6('0x62')][_0x0dc6('0xa3')]({'where':{'id':_0x5a96a0['params']['id']}})[_0x0dc6('0x21')](handleEntityNotFound(_0x52b27d,null))[_0x0dc6('0x21')](function(_0x11b3bf){if(_0x11b3bf){_0x3d33fe=_0x11b3bf;_0x34a0db[_0x0dc6('0x4f')]=_[_0x0dc6('0x52')](db[_0x0dc6('0x155')][_0x0dc6('0x4b')]);_0x34a0db[_0x0dc6('0x59')]=_[_0x0dc6('0x52')](_0x5a96a0['query']);_0x34a0db[_0x0dc6('0x53')]=_['intersection'](_0x34a0db['model'],_0x34a0db[_0x0dc6('0x59')]);_0x3acb54[_0x0dc6('0x55')]=_[_0x0dc6('0x67')](_0x34a0db['model'],qs[_0x0dc6('0x54')](_0x5a96a0[_0x0dc6('0x59')]['fields']));_0x3acb54[_0x0dc6('0x55')]=_0x3acb54['attributes'][_0x0dc6('0x56')]?_0x3acb54[_0x0dc6('0x55')]:_0x34a0db[_0x0dc6('0x4f')];_0x3acb54[_0x0dc6('0x5a')]=qs[_0x0dc6('0x5b')](_0x5a96a0[_0x0dc6('0x59')]['sort']);_0x3acb54[_0x0dc6('0x5c')]=qs['filters'](_['pick'](_0x5a96a0[_0x0dc6('0x59')],_0x34a0db[_0x0dc6('0x53')]));if(_0x5a96a0[_0x0dc6('0x59')][_0x0dc6('0x40')]){_0x3acb54[_0x0dc6('0x5c')]=_[_0x0dc6('0x5e')](_0x3acb54['where'],{'$or':_['map'](_0x3acb54['attributes'],function(_0x1a772a){var _0x36d5d2={};_0x36d5d2[_0x1a772a]={'$like':'%'+_0x5a96a0['query'][_0x0dc6('0x40')]+'%'};return _0x36d5d2;})});}_0x3acb54=_['merge']({},_0x3acb54,_0x5a96a0[_0x0dc6('0x61')]);return _0x3d33fe[_0x0dc6('0x154')](_0x3acb54);}})[_0x0dc6('0x21')](function(_0x26a8cb){if(_0x26a8cb){_0x40056a=_0x26a8cb[_0x0dc6('0x56')];if(!_0x5a96a0[_0x0dc6('0x59')][_0x0dc6('0x57')](_0x0dc6('0x58'))){_0x3acb54[_0x0dc6('0x31')]=qs[_0x0dc6('0x31')](_0x5a96a0[_0x0dc6('0x59')][_0x0dc6('0x31')]);_0x3acb54[_0x0dc6('0x30')]=qs[_0x0dc6('0x30')](_0x5a96a0['query'][_0x0dc6('0x30')]);}return _0x3d33fe[_0x0dc6('0x154')](_0x3acb54);}})[_0x0dc6('0x21')](function(_0x481f98){if(_0x481f98){return _0x481f98?{'count':_0x40056a,'rows':_0x481f98}:null;}})[_0x0dc6('0x21')](respondWithResult(_0x52b27d,null))[_0x0dc6('0x2b')](handleError(_0x52b27d,null));};exports[_0x0dc6('0x156')]=function(_0x2c3219,_0x22fc1a,_0x11177e){return db[_0x0dc6('0x62')][_0x0dc6('0x44')]({'where':{'id':_0x2c3219['params']['id']}})['then'](handleEntityNotFound(_0x22fc1a,null))[_0x0dc6('0x21')](function(_0x1c6e71){if(_0x1c6e71){return _0x1c6e71[_0x0dc6('0x156')](_0x2c3219[_0x0dc6('0x69')]['ids'],_['omit'](_0x2c3219[_0x0dc6('0x69')],['ids','id'])||{});}})[_0x0dc6('0x21')](respondWithResult(_0x22fc1a,null))[_0x0dc6('0x2b')](handleError(_0x22fc1a,null));};exports['removeWhatsappAccounts']=function(_0x190143,_0x2bb684,_0x2a7966){return db['User'][_0x0dc6('0x44')]({'where':{'id':_0x190143['params']['id']}})[_0x0dc6('0x21')](handleEntityNotFound(_0x2bb684,null))['then'](function(_0x19f193){if(_0x19f193){return _0x19f193['removeWhatsappAccounts'](_0x190143[_0x0dc6('0x59')][_0x0dc6('0x6d')]);}})[_0x0dc6('0x21')](respondWithStatusCode(_0x2bb684,null))[_0x0dc6('0x2b')](handleError(_0x2bb684,null));};exports['getSquareProjects']=function(_0x54f97b,_0x328cf4,_0x109b5e){var _0x17231c={};var _0x5775d2={};var _0x13cd43;var _0x20e896;return db[_0x0dc6('0x62')][_0x0dc6('0xa3')]({'where':{'id':_0x54f97b[_0x0dc6('0x6a')]['id']}})[_0x0dc6('0x21')](handleEntityNotFound(_0x328cf4,null))[_0x0dc6('0x21')](function(_0xc1bc3b){if(_0xc1bc3b){_0x13cd43=_0xc1bc3b;_0x5775d2[_0x0dc6('0x4f')]=_[_0x0dc6('0x52')](db[_0x0dc6('0x157')]['rawAttributes']);_0x5775d2[_0x0dc6('0x59')]=_['keys'](_0x54f97b['query']);_0x5775d2['filters']=_[_0x0dc6('0x67')](_0x5775d2[_0x0dc6('0x4f')],_0x5775d2['query']);_0x17231c[_0x0dc6('0x55')]=_[_0x0dc6('0x67')](_0x5775d2[_0x0dc6('0x4f')],qs[_0x0dc6('0x54')](_0x54f97b[_0x0dc6('0x59')][_0x0dc6('0x54')]));_0x17231c[_0x0dc6('0x55')]=_0x17231c[_0x0dc6('0x55')][_0x0dc6('0x56')]?_0x17231c[_0x0dc6('0x55')]:_0x5775d2[_0x0dc6('0x4f')];_0x17231c['order']=qs[_0x0dc6('0x5b')](_0x54f97b[_0x0dc6('0x59')][_0x0dc6('0x5b')]);_0x17231c[_0x0dc6('0x5c')]=qs[_0x0dc6('0x53')](_[_0x0dc6('0x5d')](_0x54f97b[_0x0dc6('0x59')],_0x5775d2[_0x0dc6('0x53')]));if(_0x54f97b[_0x0dc6('0x59')][_0x0dc6('0x40')]){_0x17231c['where']=_[_0x0dc6('0x5e')](_0x17231c[_0x0dc6('0x5c')],{'$or':_['map'](_0x17231c[_0x0dc6('0x55')],function(_0x300b44){var _0x40d7c5={};_0x40d7c5[_0x300b44]={'$like':'%'+_0x54f97b[_0x0dc6('0x59')][_0x0dc6('0x40')]+'%'};return _0x40d7c5;})});}_0x17231c=_[_0x0dc6('0x5e')]({},_0x17231c,_0x54f97b['options']);return _0x13cd43[_0x0dc6('0x158')](_0x17231c);}})['then'](function(_0x1e73d5){if(_0x1e73d5){_0x20e896=_0x1e73d5[_0x0dc6('0x56')];if(!_0x54f97b[_0x0dc6('0x59')][_0x0dc6('0x57')](_0x0dc6('0x58'))){_0x17231c[_0x0dc6('0x31')]=qs['limit'](_0x54f97b[_0x0dc6('0x59')][_0x0dc6('0x31')]);_0x17231c[_0x0dc6('0x30')]=qs[_0x0dc6('0x30')](_0x54f97b[_0x0dc6('0x59')]['offset']);}return _0x13cd43[_0x0dc6('0x158')](_0x17231c);}})['then'](function(_0x233e6d){if(_0x233e6d){return _0x233e6d?{'count':_0x20e896,'rows':_0x233e6d}:null;}})['then'](respondWithResult(_0x328cf4,null))['catch'](handleError(_0x328cf4,null));};exports[_0x0dc6('0x159')]=function(_0x506f99,_0x36ae4e,_0x4285e8){return db['User']['find']({'where':{'id':_0x506f99[_0x0dc6('0x6a')]['id']}})[_0x0dc6('0x21')](handleEntityNotFound(_0x36ae4e,null))['then'](function(_0x3ffa6e){if(_0x3ffa6e){return _0x3ffa6e[_0x0dc6('0x159')](_0x506f99['body'][_0x0dc6('0x6d')],_[_0x0dc6('0x6e')](_0x506f99[_0x0dc6('0x69')],[_0x0dc6('0x6d'),'id'])||{});}})[_0x0dc6('0x21')](respondWithResult(_0x36ae4e,null))['catch'](handleError(_0x36ae4e,null));};exports[_0x0dc6('0x15a')]=function(_0x54b8cf,_0x3017c0,_0x4ce934){return db[_0x0dc6('0x62')][_0x0dc6('0x44')]({'where':{'id':_0x54b8cf[_0x0dc6('0x6a')]['id']}})[_0x0dc6('0x21')](handleEntityNotFound(_0x3017c0,null))['then'](function(_0x4ff3bd){if(_0x4ff3bd){return _0x4ff3bd[_0x0dc6('0x15a')](_0x54b8cf['query'][_0x0dc6('0x6d')]);}})['then'](respondWithStatusCode(_0x3017c0,null))['catch'](handleError(_0x3017c0,null));};exports[_0x0dc6('0x15b')]=function(_0x355e13,_0x32cfc6){var _0x535b86={},_0x38ac19={},_0x5c445d={'count':0x0,'rows':[]};var _0x3084b6=db[_0x0dc6('0x15c')][_0x0dc6('0x4b')];_0x38ac19[_0x0dc6('0x4f')]=_[_0x0dc6('0x52')](_0x3084b6);_0x38ac19['query']=_[_0x0dc6('0x52')](_0x355e13['query']);_0x38ac19[_0x0dc6('0x53')]=_[_0x0dc6('0x67')](_0x38ac19[_0x0dc6('0x4f')],_0x38ac19[_0x0dc6('0x59')]);_0x38ac19[_0x0dc6('0x53')]=_['concat'](_0x38ac19[_0x0dc6('0x53')],[_0x0dc6('0x15d'),_0x0dc6('0x15e'),_0x0dc6('0x15f'),_0x0dc6('0x160'),'$lt',_0x0dc6('0x161'),_0x0dc6('0x162'),'$eq',_0x0dc6('0x163'),'$between',_0x0dc6('0x164'),_0x0dc6('0x165'),_0x0dc6('0x166'),_0x0dc6('0x167'),_0x0dc6('0x168'),_0x0dc6('0x169'),_0x0dc6('0x16a'),_0x0dc6('0x167'),_0x0dc6('0x16b'),_0x0dc6('0x16c'),'$contained',_0x0dc6('0x16d')]);_0x535b86[_0x0dc6('0x55')]=_['intersection'](_0x38ac19[_0x0dc6('0x4f')],qs[_0x0dc6('0x54')](_0x355e13[_0x0dc6('0x59')]['fields']));_0x535b86[_0x0dc6('0x55')]=_0x535b86[_0x0dc6('0x55')][_0x0dc6('0x56')]?_0x535b86[_0x0dc6('0x55')]:_0x38ac19[_0x0dc6('0x4f')];if(!_0x355e13[_0x0dc6('0x59')][_0x0dc6('0x57')]('nolimit')){_0x535b86[_0x0dc6('0x31')]=qs[_0x0dc6('0x31')](_0x355e13[_0x0dc6('0x59')]['limit']);_0x535b86['offset']=qs['offset'](_0x355e13[_0x0dc6('0x59')]['offset']);}_0x535b86[_0x0dc6('0x5a')]=qs['sort'](_0x355e13[_0x0dc6('0x59')][_0x0dc6('0x5b')]);_0x535b86[_0x0dc6('0x5c')]=qs[_0x0dc6('0x53')](_[_0x0dc6('0x5d')](_0x355e13[_0x0dc6('0x59')],_0x38ac19['filters']));if(_0x355e13[_0x0dc6('0x59')][_0x0dc6('0x40')]){_0x535b86[_0x0dc6('0x5c')]=_[_0x0dc6('0x5e')](_0x535b86[_0x0dc6('0x5c')],{'$or':_['map'](_0x535b86['attributes'],function(_0xa0693a){var _0x24c8d1={};_0x24c8d1[_0xa0693a]={'$like':'%'+_0x355e13[_0x0dc6('0x59')][_0x0dc6('0x40')]+'%'};return _0x24c8d1;})});}_0x535b86[_0x0dc6('0x5c')]={'$and':[_0x535b86[_0x0dc6('0x5c')],{'$or':[{'UserId':_0x355e13[_0x0dc6('0x6a')]['id']},{'OwnerId':_0x355e13['params']['id']}]}]};_0x535b86=_[_0x0dc6('0x5e')]({},_0x535b86,_0x355e13[_0x0dc6('0x61')]);var _0x3f1d39={'where':_0x535b86['where']};return db[_0x0dc6('0x15c')][_0x0dc6('0x2f')](_0x3f1d39)['then'](function(_0x3f84ce){_0x5c445d[_0x0dc6('0x2f')]=_0x3f84ce;if(_0x355e13['query'][_0x0dc6('0x63')]){_0x535b86['include']=[{'attributes':['id',_0x0dc6('0x16e'),'lastName',_0x0dc6('0xe2')],'model':db[_0x0dc6('0x16f')],'as':'Contact'},{'attributes':['id',_0x0dc6('0x45'),_0x0dc6('0x170')],'model':db['VoiceQueue'],'as':'Queue'}];}return db[_0x0dc6('0x15c')][_0x0dc6('0x98')](_0x535b86);})[_0x0dc6('0x21')](function(_0x17a250){_0x5c445d[_0x0dc6('0x64')]=_0x17a250;return _0x5c445d;})[_0x0dc6('0x21')](respondWithFilteredResult(_0x32cfc6,_0x535b86))[_0x0dc6('0x2b')](handleError(_0x32cfc6,null));};exports[_0x0dc6('0x171')]=function(_0x55f4bf,_0x33309b,_0x5847f6){if(!_[_0x0dc6('0x73')](_0x55f4bf[_0x0dc6('0x3b')]['id'])&&(_0x55f4bf[_0x0dc6('0x3b')]['role']==_0x0dc6('0x89')||_0x55f4bf[_0x0dc6('0x3b')][_0x0dc6('0x39')]==_0x0dc6('0x3b'))){return db[_0x0dc6('0x62')][_0x0dc6('0xa3')]({'where':{'id':_0x55f4bf[_0x0dc6('0x6a')]['id']},'raw':!![]})[_0x0dc6('0x21')](function(_0x49fe75){return authService[_0x0dc6('0x172')](_0x49fe75);})[_0x0dc6('0x21')](function(_0x170b8c){if(_0x170b8c){return _0x33309b[_0x0dc6('0x2c')](0xc8)[_0x0dc6('0x2e')]({'api_key':_0x170b8c[_0x0dc6('0x173')]});}else{return _0x33309b[_0x0dc6('0x2c')](0xcc)[_0x0dc6('0x2e')]({'message':_0x0dc6('0x174')});}})[_0x0dc6('0x2b')](handleError(_0x33309b,0x193));}else{return _0x33309b[_0x0dc6('0x2c')](0x191)[_0x0dc6('0x2e')]({'message':'You\x20don\x27t\x20have\x20sufficient\x20privileges\x20to\x20access\x20this\x20resource.'});}};exports[_0x0dc6('0x175')]=function(_0x5ce695,_0x3aed7d,_0x595f6e){if(!_[_0x0dc6('0x73')](_0x5ce695[_0x0dc6('0x3b')]['id'])&&(_0x5ce695['user']['role']=='admin'||_0x5ce695[_0x0dc6('0x3b')][_0x0dc6('0x39')]==_0x0dc6('0x3b'))){return db[_0x0dc6('0x62')]['find']({'where':{'id':_0x5ce695[_0x0dc6('0x6a')]['id']}})[_0x0dc6('0x21')](function(_0x77e0cb){return authService[_0x0dc6('0x176')](_0x77e0cb);})[_0x0dc6('0x21')](function(_0x3e6bb2){return db['User'][_0x0dc6('0x36')]({'apiKeyIat':_0x3e6bb2[_0x0dc6('0x177')],'apiKeyNonce':_0x3e6bb2[_0x0dc6('0x178')]},{'where':{'id':_0x5ce695[_0x0dc6('0x6a')]['id']}})[_0x0dc6('0x21')](function(){return _0x3aed7d[_0x0dc6('0x2c')](0xc8)['json']({'api_key':_0x3e6bb2[_0x0dc6('0x173')]});});})[_0x0dc6('0x2b')](handleError(_0x3aed7d,0x193));}else{return _0x3aed7d[_0x0dc6('0x2c')](0x191)[_0x0dc6('0x2e')]({'message':_0x0dc6('0x179')});}};exports[_0x0dc6('0x17a')]=function(_0x2f552f,_0x41a311,_0x1aab41){if(!_[_0x0dc6('0x73')](_0x2f552f[_0x0dc6('0x3b')]['id'])&&(_0x2f552f[_0x0dc6('0x3b')][_0x0dc6('0x39')]==_0x0dc6('0x89')||_0x2f552f[_0x0dc6('0x3b')][_0x0dc6('0x39')]=='user')){return db[_0x0dc6('0x62')][_0x0dc6('0x44')]({'where':{'id':_0x2f552f['params']['id']}})['then'](handleEntityNotFound(_0x41a311,null))[_0x0dc6('0x21')](function(_0x340f43){if(_0x340f43&&_0x340f43[_0x0dc6('0x17b')]&&_0x340f43[_0x0dc6('0x17c')])return _0x340f43;else throw{'message':_0x0dc6('0x17d')};})[_0x0dc6('0x21')](function(_0x1fd6d5){return db[_0x0dc6('0x62')][_0x0dc6('0x36')]({'apiKeyNonce':null,'apiKeyIat':null},{'where':{'id':_0x2f552f[_0x0dc6('0x6a')]['id']}});})[_0x0dc6('0x21')](respondWithStatusCode(_0x41a311,0xc8))[_0x0dc6('0x2b')](handleError(_0x41a311,0x193));}else{return _0x41a311['status'](0x191)['json']({'message':_0x0dc6('0x179')});}};exports[_0x0dc6('0x17e')]=function(_0x42ffdc,_0x4005f8){var _0x449c7d=_0x42ffdc[_0x0dc6('0x3b')][_0x0dc6('0x38')]({'plain':!![]});if(!_0x449c7d){return _0x4005f8[_0x0dc6('0x2c')](0x191)[_0x0dc6('0x49')](_0x0dc6('0x17f'));}else{return _0x4005f8[_0x0dc6('0x2c')](0xc8)[_0x0dc6('0x2e')](_0x449c7d);}};
\ No newline at end of file
+var _0x5b55=['MailInteraction','SmsInteraction','getSmsInteractions','getFaxInteractions','FaxInteraction','getWhatsappInteractions','login','phone','mobile','LOCAL/%s@from-sip/n','intrf','user:%s','user:forcelogout','x-forwarded-for','connection','remoteAddress','socket','User\x20not\x20found\x20or\x20not\x20allowed\x20to\x20perform\x20login\x20method','UserVoiceQueue.penalty','MemberReport','forEach','YYYY-MM-DD\x20HH:mm:ss','getChannels','LOGIN','device','PAUSE','LOGININPAUSE','bulkCreate','isMiddleware','resolve','logout','pause','QueuePause','unpause','mailPause','faxPause','openchannelPause','smsPause','pauseType','lastPauseAt','isValidChannel','manual','set','%s%s','Pause','Team','getTeams','addTeams','Body\x20parameter\x20\x27ids\x27\x20is\x20required','User\x20with\x20id\x20%s\x20not\x20found','transaction','getAssociatedQueues','flattenDeep','addAgent','getDataValue','Voice','TeamVoicePrefix','VoicePrefixId','removeTeams','Query\x20parameter\x20\x27ids\x27\x20is\x20required','removeAgent','UserVoicePrefix','getLists','getVoiceQueues','values','send','You\x20can\x27t\x20delete\x20yourself','addChatInteractions','user_has_chat_interactions:save','removeChatInteractions','user_has_chat_interactions:remove','addMailInteractions','user_has_mail_interactions:save','removeMailInteractions','user_has_mail_interactions:remove','addFaxInteractions','user_has_fax_interactions:save','removeFaxInteractions','user_has_fax_interactions:remove','addSmsInteractions','user_has_sms_interactions:save','removeSmsInteractions','user_has_sms_interactions:remove','addOpenchannelInteractions','removeOpenchannelInteractions','user_has_openchannel_interactions:remove','addWhatsappInteractions','user_has_whatsapp_interactions:save','removeWhatsappInteractions','getVoicePrefixes','VoicePrefix','getFaxAccounts','FaxAccount','addFaxAccounts','removeFaxAccounts','MailAccount','getMailAccounts','addMailAccounts','getOpenchannelAccounts','addOpenchannelAccounts','removeOpenchannelAccounts','getSmsAccounts','SmsAccount','addSmsAccounts','removeSmsAccounts','getChatWebsites','addChatWebsites','removeChatWebsites','getWhatsappAccounts','WhatsappAccount','addWhatsappAccounts','removeWhatsappAccounts','getSquareProjects','addSquareProjects','removeSquareProjects','CmHopper','$gt','$lt','$lte','$ne','$eq','$not','$between','$in','$notIn','$like','$notLike','$iLike','$contains','$contained','$any','lastName','Contact','dialActive','getApiKey','retrieveApiKey','json','token','generateApiKey','iat','nonce','You\x20don\x27t\x20have\x20sufficient\x20privileges\x20to\x20access\x20this\x20resource.','removeApiKey','apiKeyNonce','apiKeyIat','API\x20key\x20not\x20available','whoami','getPresence','queues','teams','inbound','flatten','getAgents','lower','col','toString','asc','desc','substring','uniqBy','orderBy','Unable\x20to\x20retrieve\x20RPC\x20agents\x20(AMI)','http','idle','unknown','slice','toUpperCase','QueryTypes','select','ui.','InteractionId','field','user_has_','_interactions','OpenTabs','moment','util','path','lodash','squel','jayson/promise','../../components/auth/service','../../components/parsers/qs','../../config/logger','../../config/environment','../../config/license/util','../../errors/api','APIBadRequestError','APINotFoundError','handleError','../../mysqldb','redis','./user.socket','localhost','client','request','then','info','User,\x20%s,\x20%s','request\x20sent','User,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','offset','undefined','limit','count','status','Content-Range','update','emit','role','admin','Users','Agents','filter','value','includes','name','UserProfileResource','destroy','end','sendStatus','stack','index','map','fieldName','type','key','password','salt','getOptions','User','query','include','userSetting','UserSetting','attributes','push','rows','openTabs','chat','dataValues','fax','mail','whatsapp','show','params','model','differenceBy','keys','rawAttributes','filters','fields','length','includeAll','options','find','true','sms','openchannel','all','body','describe','addContacts','omit','ids','internal','Setting','findById','validatePasswordPattern','isNil','min_internal','sequelize','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','VoiceMail','fullname','agent','permissions','101','102','110','104','105','106','107','100','create','user','Unauthorized.\x20You\x20must\x20be\x20an\x20administrator\x20in\x20order\x20to\x20create\x20another\x20administrator','checkUserLimits','settingsEnabled','UserProfileSection','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','Unauthorized','some','Unauthorized.\x20You\x20must\x20be\x20an\x20administrator\x20in\x20order\x20to\x20create\x20an\x20administrator','each','telephone','findAll','isEmpty','compact','Telephones','changePassword','oldPassword','newPassword','Sequelize','Invalid\x20body\x20format.\x20Use\x20oldPassword\x20and\x20newPassword','authenticate','ValidationError','Wrong\x20credentials','New\x20password\x20must\x20be\x20different\x20from\x20old\x20password','Invalid\x20body\x20format.\x20Use\x20newPassword','findOne','securePassword','enforcePasswordHistory','previousPasswords','validatePasswordHistory','passwordHistoryLimit','updatePasswordsHistory','addQueues','channel','online','loginInPause','voicePause','interface','Unknown\x20channel','toLowerCase','Queues','penalty','spread','capitalize','voice','VoiceQueue','get','format','SIP/%s','UserVoiceQueueRt','upsert','remove','isArray','QueueId','Queue:remove','addAvatar','userpic','file','filename','getAvatar','root','server/files/images/logos/default_profile.png','existsSync','join','server/files/images/','download','ChatOpenTabs','CHAT','createdAt','FaxOpenTabs','FAX','OpenchannelOpenTabs','OPENCHANNEL','MAIL','SmsOpenTabs','WhatsappOpenTabs','WHATSAPP','concat','getContacts','CmContact','intersection','order','sort','pick','merge','where','hasOwnProperty','CmList','Tag','Tags','color','tag','nolimit','getQueues','Queue','getVoiceQueuesRt','ChatGroup','getGroups','VoiceRecording','UserId','getScreenRecordings','ScreenRecording','getChatInteractions','ChatInteraction','getOpenchannelInteractions','OpenchannelInteraction'];(function(_0x303028,_0x45d68d){var _0x34ca68=function(_0x1aa657){while(--_0x1aa657){_0x303028['push'](_0x303028['shift']());}};_0x34ca68(++_0x45d68d);}(_0x5b55,0xaf));var _0x55b5=function(_0x5eee1c,_0x3817d8){_0x5eee1c=_0x5eee1c-0x0;var _0x5f2ea1=_0x5b55[_0x5eee1c];return _0x5f2ea1;};'use strict';var moment=require(_0x55b5('0x0'));var BPromise=require('bluebird');var util=require(_0x55b5('0x1'));var path=require(_0x55b5('0x2'));var fs=require('fs');var _=require(_0x55b5('0x3'));var squel=require(_0x55b5('0x4'));var jayson=require(_0x55b5('0x5'));var Redis=require('ioredis');var authService=require(_0x55b5('0x6'));var qs=require(_0x55b5('0x7'));var logger=require(_0x55b5('0x8'))('api');var utils=require('../../config/utils');var config=require(_0x55b5('0x9'));var licenseUtil=require(_0x55b5('0xa'));var APIBadRequestError=require(_0x55b5('0xb'))[_0x55b5('0xc')];var APINotFoundError=require(_0x55b5('0xb'))[_0x55b5('0xd')];var APIHandleError=require(_0x55b5('0xb'))[_0x55b5('0xe')];var db=require(_0x55b5('0xf'))['db'];var socket=require('socket.io-emitter')(new Redis(config[_0x55b5('0x10')]));require(_0x55b5('0x11'))['register'](socket);config[_0x55b5('0x10')]=_['defaults'](config['redis'],{'host':_0x55b5('0x12'),'port':0x18eb});var client=jayson[_0x55b5('0x13')]['http']({'port':0x232a});var values;function respondWithRpcPromise(_0x5ce4f8,_0x4a9e09,_0x388a01,_0x4863bf){return new BPromise(function(_0x45f38e,_0x4139a6){var _0x3177ed=_0x4863bf||client;return _0x3177ed[_0x55b5('0x14')](_0x5ce4f8,_0x388a01)[_0x55b5('0x15')](function(_0x599d28){logger[_0x55b5('0x16')](_0x55b5('0x17'),_0x4a9e09,_0x55b5('0x18'));logger['debug'](_0x55b5('0x19'),_0x4a9e09,_0x55b5('0x18'),JSON[_0x55b5('0x1a')](_0x599d28));if(_0x599d28['error']){if(_0x599d28[_0x55b5('0x1b')][_0x55b5('0x1c')]===0x1f4){logger[_0x55b5('0x1b')](_0x55b5('0x17'),_0x4a9e09,_0x599d28[_0x55b5('0x1b')][_0x55b5('0x1d')]);return _0x4139a6(_0x599d28[_0x55b5('0x1b')]['message']);}logger[_0x55b5('0x1b')](_0x55b5('0x17'),_0x4a9e09,_0x599d28[_0x55b5('0x1b')]['message']);return _0x45f38e(_0x599d28[_0x55b5('0x1b')][_0x55b5('0x1d')]);}else{logger[_0x55b5('0x16')](_0x55b5('0x17'),_0x4a9e09,_0x55b5('0x18'));_0x45f38e(_0x599d28[_0x55b5('0x1e')]['message']);}})[_0x55b5('0x1f')](function(_0x33d1da){logger['error'](_0x55b5('0x17'),_0x4a9e09,_0x33d1da);_0x4139a6(_0x33d1da);});});}function respondWithStatusCode(_0x295779,_0xe2aaab){_0xe2aaab=_0xe2aaab||0xcc;return function(_0x5d0c20){if(_0x5d0c20){return _0x295779['sendStatus'](_0xe2aaab);}return _0x295779['status'](_0xe2aaab)['end']();};}function respondWithResult(_0x504cb7,_0x47fff7){_0x47fff7=_0x47fff7||0xc8;return function(_0x5ea629){if(_0x5ea629){return _0x504cb7['status'](_0x47fff7)['json'](_0x5ea629);}};}function respondWithFilteredResult(_0x427c03,_0x522225){return function(_0x259fc1){if(_0x259fc1){var _0x1a2b50=typeof _0x522225[_0x55b5('0x20')]===_0x55b5('0x21')&&typeof _0x522225[_0x55b5('0x22')]==='undefined';var _0x4fe1d6=_0x259fc1[_0x55b5('0x23')];var _0x2795b5=_0x1a2b50?0x0:_0x522225[_0x55b5('0x20')];var _0x55fd2b=_0x1a2b50?_0x259fc1['count']:_0x522225[_0x55b5('0x20')]+_0x522225[_0x55b5('0x22')];var _0xab205f;if(_0x55fd2b>=_0x4fe1d6){_0x55fd2b=_0x4fe1d6;_0xab205f=0xc8;}else{_0xab205f=0xce;}_0x427c03[_0x55b5('0x24')](_0xab205f);return _0x427c03['set'](_0x55b5('0x25'),_0x2795b5+'-'+_0x55fd2b+'/'+_0x4fe1d6)['json'](_0x259fc1);}return null;};}function saveUpdates(_0x20ddf8){return function(_0x4f5f5e){if(_0x4f5f5e){return _0x4f5f5e[_0x55b5('0x26')](_0x20ddf8)['then'](function(_0x4585a0){socket[_0x55b5('0x27')]('userNotification:recalc:'+_0x4585a0['id'],{});return _0x4585a0;});}return null;};}function removeEntity(_0x2cc1a1){return function(_0x1ca4b7){if(_0x1ca4b7){return _0x1ca4b7['destroy']()[_0x55b5('0x15')](function(){var _0x4aed69=_0x1ca4b7['get']({'plain':!![]});if(_0x4aed69[_0x55b5('0x28')]===_0x55b5('0x29'))return;var _0x135144=[{'name':_0x55b5('0x2a'),'value':'user','ignore':!![]},{'name':_0x55b5('0x2b'),'value':'agent','ignore':![]},{'name':'Telephones','value':'telephone','ignore':![]}];var _0x38d485=_(_0x135144)[_0x55b5('0x2c')]('ignore')['map']('value')[_0x55b5('0x2d')]();if(_[_0x55b5('0x2e')](_0x38d485,_0x4aed69[_0x55b5('0x28')])){return;}var _0x61d07d=_['find'](_0x135144,[_0x55b5('0x2d'),_0x4aed69[_0x55b5('0x28')]])[_0x55b5('0x2f')];return db[_0x55b5('0x30')][_0x55b5('0x31')]({'where':{'type':_0x61d07d,'resourceId':_0x4aed69['id']}})[_0x55b5('0x15')](function(){return _0x1ca4b7;});})['then'](function(){_0x2cc1a1[_0x55b5('0x24')](0xcc)[_0x55b5('0x32')]();});}};}function handleEntityNotFound(_0x5f5c7e){return function(_0x5adcb4){if(!_0x5adcb4){_0x5f5c7e[_0x55b5('0x33')](0x194);}return _0x5adcb4;};}function handleError(_0x345f62,_0xdada45){_0xdada45=_0xdada45||0x1f4;return function(_0x4e843d){logger['error'](_0x4e843d[_0x55b5('0x34')]);if(_0x4e843d[_0x55b5('0x2f')]){delete _0x4e843d['name'];}_0x345f62['status'](_0xdada45)['send'](_0x4e843d);};}exports[_0x55b5('0x35')]=function(_0x5c964e,_0x10b504){var _0x155856={},_0x25bbcd={'count':0x0,'rows':[]};var _0x1655b=_(db['User']['rawAttributes'])[_0x55b5('0x36')](function(_0x4d03c5){return{'name':_0x4d03c5[_0x55b5('0x37')],'type':_0x4d03c5[_0x55b5('0x38')][_0x55b5('0x39')]};})[_0x55b5('0x2c')](function(_0x4e9db9){return!_['includes']([_0x55b5('0x3a'),_0x55b5('0x3b')],_0x4e9db9[_0x55b5('0x2f')]);})[_0x55b5('0x2d')]();_0x155856=qs[_0x55b5('0x3c')](_0x1655b,_0x5c964e);var _0xb1fd09={'where':_0x155856['where']};return db[_0x55b5('0x3d')]['count'](_0xb1fd09)[_0x55b5('0x15')](function(_0x7c5abd){_0x25bbcd[_0x55b5('0x23')]=_0x7c5abd;if(_0x5c964e[_0x55b5('0x3e')]['includeAll']){_0x155856[_0x55b5('0x3f')]=[{'all':!![]}];}if(_0x5c964e[_0x55b5('0x3e')][_0x55b5('0x40')]==='true'){_0x155856[_0x55b5('0x3f')]=[{'model':db[_0x55b5('0x41')],'as':_0x55b5('0x40')}];}if(!_['includes'](_0x155856[_0x55b5('0x42')],'id')){_0x155856[_0x55b5('0x42')][_0x55b5('0x43')]('id');}return db['User']['findAll'](_0x155856);})[_0x55b5('0x15')](function(_0x56643f){_0x25bbcd[_0x55b5('0x44')]=_0x56643f;if(_0x5c964e[_0x55b5('0x3e')][_0x55b5('0x45')]==='true'){var _0x22423f=[];for(var _0x36143d=0x0;_0x36143d<_0x25bbcd[_0x55b5('0x44')]['length'];_0x36143d++){_0x22423f[_0x55b5('0x43')](get_open_tabs(_0x55b5('0x46'),_0x25bbcd[_0x55b5('0x44')][_0x36143d][_0x55b5('0x47')]));_0x22423f[_0x55b5('0x43')](get_open_tabs('sms',_0x25bbcd[_0x55b5('0x44')][_0x36143d]['dataValues']));_0x22423f[_0x55b5('0x43')](get_open_tabs(_0x55b5('0x48'),_0x25bbcd[_0x55b5('0x44')][_0x36143d][_0x55b5('0x47')]));_0x22423f[_0x55b5('0x43')](get_open_tabs(_0x55b5('0x49'),_0x25bbcd[_0x55b5('0x44')][_0x36143d][_0x55b5('0x47')]));_0x22423f[_0x55b5('0x43')](get_open_tabs('openchannel',_0x25bbcd[_0x55b5('0x44')][_0x36143d][_0x55b5('0x47')]));_0x22423f[_0x55b5('0x43')](get_open_tabs(_0x55b5('0x4a'),_0x25bbcd[_0x55b5('0x44')][_0x36143d][_0x55b5('0x47')]));}return BPromise['all'](_0x22423f)['then'](function(){return _0x25bbcd;});}else{return _0x25bbcd;}})['then'](respondWithFilteredResult(_0x10b504,_0x155856))[_0x55b5('0x1f')](handleError(_0x10b504,null));};exports[_0x55b5('0x4b')]=function(_0xa05906,_0x216c37){var _0x12eae2={'raw':![],'where':{'id':_0xa05906[_0x55b5('0x4c')]['id']}},_0x2f0f6b={};_0x2f0f6b[_0x55b5('0x4d')]=_[_0x55b5('0x4e')](_[_0x55b5('0x4f')](db[_0x55b5('0x3d')][_0x55b5('0x50')]),['password','salt']);_0x2f0f6b[_0x55b5('0x3e')]=_['keys'](_0xa05906[_0x55b5('0x3e')]);_0x2f0f6b[_0x55b5('0x51')]=_['intersection'](_0x2f0f6b[_0x55b5('0x4d')],_0x2f0f6b['query']);_0x12eae2[_0x55b5('0x42')]=_['intersection'](_0x2f0f6b[_0x55b5('0x4d')],qs[_0x55b5('0x52')](_0xa05906[_0x55b5('0x3e')]['fields']));_0x12eae2[_0x55b5('0x42')]=_0x12eae2[_0x55b5('0x42')][_0x55b5('0x53')]?_0x12eae2[_0x55b5('0x42')]:_0x2f0f6b[_0x55b5('0x4d')];if(_0xa05906[_0x55b5('0x3e')][_0x55b5('0x54')]){_0x12eae2['include']=[{'all':!![]}];}if(_0xa05906[_0x55b5('0x3e')][_0x55b5('0x40')]==='true'){_0x12eae2['include']=[{'model':db[_0x55b5('0x41')],'as':_0x55b5('0x40')}];}_0x12eae2=_['merge']({},_0x12eae2,_0xa05906[_0x55b5('0x55')]);if(!_[_0x55b5('0x2e')](_0x12eae2[_0x55b5('0x42')],'id')){_0x12eae2[_0x55b5('0x42')]['push']('id');}return db[_0x55b5('0x3d')][_0x55b5('0x56')](_0x12eae2)[_0x55b5('0x15')](handleEntityNotFound(_0x216c37,null))[_0x55b5('0x15')](function(_0xc4054d){var _0x134633=[];values=_0xc4054d;if(_0xa05906[_0x55b5('0x3e')]['openTabs']===_0x55b5('0x57')){_0x134633[_0x55b5('0x43')](get_open_tabs(_0x55b5('0x46'),_0xc4054d[_0x55b5('0x47')]));_0x134633[_0x55b5('0x43')](get_open_tabs(_0x55b5('0x58'),_0xc4054d['dataValues']));_0x134633[_0x55b5('0x43')](get_open_tabs(_0x55b5('0x59'),_0xc4054d['dataValues']));_0x134633[_0x55b5('0x43')](get_open_tabs(_0x55b5('0x4a'),_0xc4054d[_0x55b5('0x47')]));_0x134633['push'](get_open_tabs('fax',_0xc4054d[_0x55b5('0x47')]));_0x134633['push'](get_open_tabs('mail',_0xc4054d[_0x55b5('0x47')]));return BPromise[_0x55b5('0x5a')](_0x134633);}else{return values;}})['then'](function(){return values;})[_0x55b5('0x15')](respondWithResult(_0x216c37,null))[_0x55b5('0x1f')](handleError(_0x216c37,null));};exports[_0x55b5('0x26')]=function(_0xad9203,_0x114b66){if(_0xad9203[_0x55b5('0x5b')]['id']){delete _0xad9203[_0x55b5('0x5b')]['id'];}delete _0xad9203[_0x55b5('0x5b')][_0x55b5('0x28')];return db[_0x55b5('0x3d')]['find']({'where':{'id':_0xad9203[_0x55b5('0x4c')]['id']}})['then'](handleEntityNotFound(_0x114b66,null))[_0x55b5('0x15')](saveUpdates(_0xad9203['body'],null))[_0x55b5('0x15')](respondWithResult(_0x114b66,null))[_0x55b5('0x1f')](handleError(_0x114b66,null));};exports[_0x55b5('0x5c')]=function(_0x308b51,_0x3cc0fb){return db['User'][_0x55b5('0x5c')]()[_0x55b5('0x15')](respondWithResult(_0x3cc0fb,null))[_0x55b5('0x1f')](handleError(_0x3cc0fb,null));};exports[_0x55b5('0x5d')]=function(_0x1a3d3c,_0x3d8f1d){return db[_0x55b5('0x3d')][_0x55b5('0x56')]({'where':{'id':_0x1a3d3c['params']['id']}})[_0x55b5('0x15')](handleEntityNotFound(_0x3d8f1d,null))['then'](function(_0x50680e){if(_0x50680e){return _0x50680e[_0x55b5('0x5d')](_0x1a3d3c[_0x55b5('0x5b')]['ids'],_[_0x55b5('0x5e')](_0x1a3d3c[_0x55b5('0x5b')],[_0x55b5('0x5f'),'id'])||{});}})['then'](respondWithResult(_0x3d8f1d,null))[_0x55b5('0x1f')](handleError(_0x3d8f1d,null));};function validateUser(_0x283642){return new BPromise(function(_0x4daa21,_0x473543){if(_0x283642[_0x55b5('0x60')])return _0x4daa21(_0x283642);return db[_0x55b5('0x61')][_0x55b5('0x62')](0x1)['then'](function(_0xdba9c0){if(_0xdba9c0['securePassword'])authService[_0x55b5('0x63')](_0x283642[_0x55b5('0x3a')]);db['User']['max']('internal')[_0x55b5('0x15')](function(_0x2441b2){if(_[_0x55b5('0x64')](_0x2441b2)){_0x283642[_0x55b5('0x60')]=_0xdba9c0['min_internal']||0x1;return;}if(_['isNil'](_0xdba9c0[_0x55b5('0x65')])||_0xdba9c0[_0x55b5('0x65')]===_0x2441b2){_0x283642[_0x55b5('0x60')]=_0x2441b2+0x1;return;}if(_0xdba9c0[_0x55b5('0x65')]>_0x2441b2){_0x283642[_0x55b5('0x60')]=_0xdba9c0[_0x55b5('0x65')];return;}return db[_0x55b5('0x66')][_0x55b5('0x3e')](_0x55b5('0x67'),{'type':db[_0x55b5('0x66')]['QueryTypes'][_0x55b5('0x68')]})['then'](function(_0x4cd6c6){if(_0x4cd6c6&&_0x4cd6c6[_0x55b5('0x53')]){for(var _0x3d6e19=0x0,_0x3ac9f1=_0x4cd6c6[_0x55b5('0x53')];_0x3d6e19<_0x3ac9f1&&_[_0x55b5('0x64')](_0x283642[_0x55b5('0x60')]);_0x3d6e19++){if(_0xdba9c0['min_internal']<=_0x4cd6c6[_0x3d6e19][_0x55b5('0x69')]){_0x283642[_0x55b5('0x60')]=_0x4cd6c6[_0x3d6e19][_0x55b5('0x69')];}else if(_0xdba9c0[_0x55b5('0x65')]>_0x4cd6c6[_0x3d6e19][_0x55b5('0x69')]&&_0xdba9c0[_0x55b5('0x65')]<=_0x4cd6c6[_0x3d6e19]['to']){_0x283642['internal']=_0xdba9c0[_0x55b5('0x65')];}}}if(_[_0x55b5('0x64')](_0x283642['internal'])){_0x283642[_0x55b5('0x60')]=_0x2441b2+0x1;}return _0x4daa21(_0x283642);});});})['catch'](function(_0x5774e9){_0x473543(_0x5774e9);});});}function updateUser(_0x47de59){return new BPromise(function(_0x19e3c6,_0x2c80b4){try{if(_0x47de59[_0x55b5('0x6a')]){_0x47de59['mailbox']=_0x47de59[_0x55b5('0x60')];_0x47de59[_0x55b5('0x6b')]={'mailbox':_0x47de59[_0x55b5('0x60')],'password':_0x47de59[_0x55b5('0x3a')],'fullname':_0x47de59[_0x55b5('0x6c')],'email':_0x47de59['email']};}if(_0x47de59[_0x55b5('0x28')]===_0x55b5('0x6d')){if(!_0x47de59[_0x55b5('0x6e')])_0x47de59[_0x55b5('0x6e')]=[_0x55b5('0x6f'),_0x55b5('0x70'),'103','113',_0x55b5('0x71'),_0x55b5('0x72'),_0x55b5('0x73'),_0x55b5('0x74'),_0x55b5('0x75'),'108','109',_0x55b5('0x76'),'111','114','115'];}_0x19e3c6(_0x47de59);}catch(_0x58a2a5){_0x2c80b4(_0x58a2a5);}});}exports[_0x55b5('0x77')]=function(_0x3a6ad5,_0x1f3233){if(_0x3a6ad5[_0x55b5('0x78')]['role']===_0x55b5('0x6d'))throw new Error('Unauthorized');if(_0x3a6ad5['body'][_0x55b5('0x28')]===_0x55b5('0x78')&&_0x3a6ad5['user']['role']!=='admin'){throw new Error('Unauthorized.\x20You\x20must\x20be\x20an\x20administrator\x20in\x20order\x20to\x20create\x20an\x20user');}if(_0x3a6ad5[_0x55b5('0x5b')]['role']===_0x55b5('0x29')&&_0x3a6ad5[_0x55b5('0x78')][_0x55b5('0x28')]!==_0x55b5('0x29')){throw new Error(_0x55b5('0x79'));}return licenseUtil[_0x55b5('0x7a')]([_0x3a6ad5[_0x55b5('0x5b')]])[_0x55b5('0x15')](function(){return validateUser(_0x3a6ad5[_0x55b5('0x5b')]);})[_0x55b5('0x15')](function(_0x3b908c){return updateUser(_0x3b908c)[_0x55b5('0x15')](function(_0x1edb6a){if(_0x1edb6a['role']===_0x55b5('0x29')){_0x1edb6a[_0x55b5('0x7b')]=_0x3a6ad5[_0x55b5('0x78')][_0x55b5('0x7b')];delete _0x1edb6a['userProfileId'];}return _0x1edb6a;});})[_0x55b5('0x15')](function(_0x321f84){return db[_0x55b5('0x3d')][_0x55b5('0x77')](_0x321f84,{'include':[{'model':db[_0x55b5('0x6b')],'as':'VoiceMail'}]});})[_0x55b5('0x15')](function(_0x414d9c){if(_0x3a6ad5[_0x55b5('0x5b')][_0x55b5('0x28')]===_0x55b5('0x78'))return _0x414d9c;if(_0x3a6ad5[_0x55b5('0x78')][_0x55b5('0x28')]!==_0x55b5('0x78'))return _0x414d9c;return db[_0x55b5('0x7c')]['find']({'where':{'name':_0x414d9c[_0x55b5('0x28')]==='agent'?_0x55b5('0x2b'):'Telephones','userProfileId':_0x3a6ad5[_0x55b5('0x78')][_0x55b5('0x7d')]},'raw':!![]})['then'](function(_0x5d2c6e){if(!_0x5d2c6e||_0x5d2c6e[_0x55b5('0x7e')]!=0x0)return _0x414d9c;return db[_0x55b5('0x30')][_0x55b5('0x77')]({'name':_0x414d9c[_0x55b5('0x2f')],'resourceId':_0x414d9c['id'],'type':_0x5d2c6e[_0x55b5('0x2f')],'sectionId':_0x5d2c6e['id']},{})[_0x55b5('0x15')](function(){return _0x414d9c;});})['catch'](function(_0x2d67ff){logger[_0x55b5('0x1b')](_0x55b5('0x7f'),_0x2d67ff);throw _0x2d67ff;});})['then'](respondWithResult(_0x1f3233,0xc9))['catch'](handleError(_0x1f3233,null));};exports['bulkCreate']=function(_0x4b946e,_0x198566){var _0x233449=_0x4b946e[_0x55b5('0x5b')];var _0x3bd4d3=[];if(_0x4b946e[_0x55b5('0x78')][_0x55b5('0x28')]===_0x55b5('0x6d'))throw new Error(_0x55b5('0x80'));if(_['some'](_0x233449,['role',_0x55b5('0x78')])&&_0x4b946e[_0x55b5('0x78')]['role']!=='admin'){throw new Error('Unauthorized.\x20You\x20must\x20be\x20an\x20administrator\x20in\x20order\x20to\x20create\x20an\x20user');}if(_[_0x55b5('0x81')](_0x233449,[_0x55b5('0x28'),_0x55b5('0x29')])&&_0x4b946e[_0x55b5('0x78')][_0x55b5('0x28')]!==_0x55b5('0x29')){throw new Error(_0x55b5('0x82'));}return licenseUtil[_0x55b5('0x7a')](_0x233449)['then'](function(){return validateUser(_0x233449[0x0]);})[_0x55b5('0x15')](function(){for(var _0x1bb883=0x1;_0x1bb883<_0x233449[_0x55b5('0x53')];_0x1bb883++){var _0x272347=_0x233449[_0x1bb883-0x1][_0x55b5('0x60')];if(!_0x233449[_0x1bb883]['internal'])_0x233449[_0x1bb883]['internal']=_0x272347+0x1;_0x3bd4d3['push'](validateUser(_0x233449[_0x1bb883]));}return BPromise[_0x55b5('0x5a')](_0x3bd4d3);})[_0x55b5('0x15')](function(){_0x3bd4d3=[];for(var _0x560895=0x0;_0x560895<_0x233449[_0x55b5('0x53')];_0x560895++){_0x3bd4d3[_0x55b5('0x43')](updateUser(_0x233449[_0x560895]));}return BPromise[_0x55b5('0x5a')](_0x3bd4d3);})[_0x55b5('0x15')](function(){return BPromise[_0x55b5('0x83')](_0x233449,function(_0x2c3b9d){return db[_0x55b5('0x3d')][_0x55b5('0x77')](_0x2c3b9d,{'include':[{'model':db['VoiceMail'],'as':'VoiceMail'}]})['then'](function(_0x36f9ad){_0x2c3b9d['id']=_0x36f9ad['id'];return _0x2c3b9d;});});})[_0x55b5('0x15')](function(_0x445562){if(_0x4b946e[_0x55b5('0x5b')][_0x55b5('0x28')]==='user')return _0x445562;if(_0x4b946e[_0x55b5('0x78')][_0x55b5('0x28')]!==_0x55b5('0x78'))return _0x445562;var _0x539744=_[_0x55b5('0x81')](_0x445562,function(_0x196b96){return _0x196b96[_0x55b5('0x28')]==='agent'||_0x196b96['role']===_0x55b5('0x84');});if(!_0x539744)return _0x445562;return db[_0x55b5('0x7c')][_0x55b5('0x85')]({'where':{'name':{'$or':[_0x55b5('0x2b'),'Telephones']},'userProfileId':_0x4b946e[_0x55b5('0x78')][_0x55b5('0x7d')]},'raw':!![]})['then'](function(_0x28f9d0){if(_[_0x55b5('0x86')](_0x28f9d0)||!_[_0x55b5('0x81')](_0x28f9d0,[_0x55b5('0x7e'),0x0]))return _0x445562;_0x3bd4d3=[];var _0x1a9751=_(_0x28f9d0)[_0x55b5('0x36')](function(_0x2f2019){if(_0x2f2019['autoAssociation']===0x1)return;return _0x2f2019['name']==='Agents'?_0x55b5('0x6d'):'telephone';})[_0x55b5('0x87')]()[_0x55b5('0x2d')]();for(var _0x27e5b7=0x0;_0x27e5b7<_0x445562[_0x55b5('0x53')];_0x27e5b7++){if(!_[_0x55b5('0x2e')](_0x1a9751,_0x445562[_0x27e5b7][_0x55b5('0x28')]))return;var _0x805384=_0x445562[_0x27e5b7][_0x55b5('0x28')]===_0x55b5('0x6d')?'Agents':_0x55b5('0x88');_0x3bd4d3[_0x55b5('0x43')](db['UserProfileResource'][_0x55b5('0x77')]({'name':_0x445562[_0x27e5b7][_0x55b5('0x2f')],'resourceId':_0x445562[_0x27e5b7]['id'],'type':_0x805384,'sectionId':_['find'](_0x28f9d0,[_0x55b5('0x2f'),_0x805384])['id']},{}));}return BPromise['all'](_0x3bd4d3);});})[_0x55b5('0x15')](respondWithResult(_0x198566,0xc9))[_0x55b5('0x1f')](handleError(_0x198566,null));};exports[_0x55b5('0x89')]=function(_0x40e1d5,_0x587ea8){if(_0x40e1d5[_0x55b5('0x5b')]['id']){delete _0x40e1d5[_0x55b5('0x5b')]['id'];}return db[_0x55b5('0x3d')][_0x55b5('0x56')]({'where':{'id':_0x40e1d5[_0x55b5('0x4c')]['id']}})[_0x55b5('0x15')](function(_0x1ed4ac){if(!_0x1ed4ac)return null;if(_0x1ed4ac['id']===_0x40e1d5[_0x55b5('0x78')]['id']){if(!_0x40e1d5[_0x55b5('0x5b')][_0x55b5('0x8a')]||!_0x40e1d5[_0x55b5('0x5b')][_0x55b5('0x8b')]){throw new db[(_0x55b5('0x8c'))]['ValidationError'](_0x55b5('0x8d'));}if(!_0x1ed4ac[_0x55b5('0x8e')](_0x40e1d5[_0x55b5('0x5b')][_0x55b5('0x8a')])){throw new db[(_0x55b5('0x8c'))][(_0x55b5('0x8f'))](_0x55b5('0x90'));}if(_0x40e1d5[_0x55b5('0x5b')][_0x55b5('0x8a')]===_0x40e1d5['body']['newPassword']){throw new db[(_0x55b5('0x8c'))][(_0x55b5('0x8f'))](_0x55b5('0x91'));}}else if(_0x40e1d5[_0x55b5('0x78')][_0x55b5('0x28')]===_0x55b5('0x29')){if(!_0x40e1d5[_0x55b5('0x5b')][_0x55b5('0x8b')]){throw new db[(_0x55b5('0x8c'))][(_0x55b5('0x8f'))](_0x55b5('0x92'));}}else if(_0x40e1d5[_0x55b5('0x78')][_0x55b5('0x28')]===_0x55b5('0x78')){if(!_0x40e1d5['body'][_0x55b5('0x8b')]){throw new db[(_0x55b5('0x8c'))][(_0x55b5('0x8f'))](_0x55b5('0x92'));}if(_0x1ed4ac[_0x55b5('0x28')]!==_0x55b5('0x6d')){throw new db[(_0x55b5('0x8c'))]['ValidationError'](_0x55b5('0x80'));}}else{throw new db[(_0x55b5('0x8c'))][(_0x55b5('0x8f'))](_0x55b5('0x80'));}return _0x1ed4ac;})['then'](handleEntityNotFound(_0x587ea8,null))[_0x55b5('0x15')](function(_0x24794f){return db[_0x55b5('0x61')][_0x55b5('0x93')]({'attributes':['id',_0x55b5('0x94'),_0x55b5('0x95'),'passwordHistoryLimit']})[_0x55b5('0x15')](function(_0x361f86){if(_0x361f86['securePassword'])authService[_0x55b5('0x63')](_0x40e1d5[_0x55b5('0x5b')][_0x55b5('0x8b')]);if(!_0x361f86[_0x55b5('0x95')]||!_0x24794f[_0x55b5('0x96')])return _0x24794f;authService[_0x55b5('0x97')](_0x40e1d5[_0x55b5('0x5b')][_0x55b5('0x8b')],_0x24794f[_0x55b5('0x96')],_0x361f86[_0x55b5('0x98')]);return _0x24794f;})[_0x55b5('0x15')](saveUpdates({'password':_0x40e1d5['body'][_0x55b5('0x8b')],'passwordResetAt':_0x40e1d5[_0x55b5('0x78')]['id']==_0x40e1d5[_0x55b5('0x4c')]['id']?moment():null,'previousPasswords':authService[_0x55b5('0x99')](_0x40e1d5[_0x55b5('0x5b')]['newPassword'],_0x24794f['previousPasswords'])},null));})[_0x55b5('0x15')](respondWithResult(_0x587ea8,null))[_0x55b5('0x1f')](handleError(_0x587ea8,null));};exports[_0x55b5('0x9a')]=function(_0x5d24af,_0x133ded){var _0x5e1ac7=_0x5d24af[_0x55b5('0x5b')][_0x55b5('0x9b')];return db[_0x55b5('0x3d')]['find']({'where':{'id':_0x5d24af[_0x55b5('0x4c')]['id']},'attributes':['id',_0x55b5('0x2f'),_0x55b5('0x28'),_0x55b5('0x9c'),_0x55b5('0x9d'),_0x55b5('0x9e'),_0x55b5('0x9f')]})[_0x55b5('0x15')](handleEntityNotFound(_0x133ded,null))['then'](function(_0x4b45b4){if(_0x4b45b4){if(!utils['isValidChannel'](_0x5e1ac7)){throw new db[(_0x55b5('0x8c'))][(_0x55b5('0x8f'))](_0x55b5('0xa0'));}return _0x4b45b4['add'+_['capitalize'](_0x5e1ac7[_0x55b5('0xa1')]())+_0x55b5('0xa2')](_0x5d24af[_0x55b5('0x5b')][_0x55b5('0x5f')],{'penalty':_0x5d24af[_0x55b5('0x5b')][_0x55b5('0xa3')]||0x0})[_0x55b5('0xa4')](function(_0x3018a1){for(var _0x2ba09d=0x0;_0x2ba09d<_0x5d24af[_0x55b5('0x5b')][_0x55b5('0x5f')]['length'];_0x2ba09d+=0x1){var _0x40b41a={'UserId':Number(_0x5d24af['params']['id'])};_0x40b41a[_[_0x55b5('0xa5')](_0x5e1ac7[_0x55b5('0xa1')]())+'QueueId']=Number(_0x5d24af[_0x55b5('0x5b')][_0x55b5('0x5f')][_0x2ba09d]);socket['emit'](_0x55b5('0x78')+_['capitalize'](_0x5e1ac7[_0x55b5('0xa1')]())+'Queue:save',_0x40b41a);}return _0x3018a1;})[_0x55b5('0x15')](function(){if(_0x5e1ac7===_0x55b5('0xa6')){return db[_0x55b5('0xa7')]['findAll']({'where':{'id':_0x5d24af[_0x55b5('0x5b')][_0x55b5('0x5f')]||[]},'raw':!![],'attributes':['id','name']});}})[_0x55b5('0x15')](function(_0x382850){var _0x5a805c=_0x4b45b4[_0x55b5('0xa8')]({'plain':!![]});var _0x500b27=[];if(_0x5e1ac7===_0x55b5('0xa6')&&_0x5a805c[_0x55b5('0x28')]===_0x55b5('0x6d')&&_0x5a805c['online']){for(var _0x4812af=0x0;_0x4812af<_0x382850['length'];_0x4812af+=0x1){_0x500b27[_0x55b5('0x43')]({'membername':_0x5a805c[_0x55b5('0x2f')],'UserId':_0x5a805c['id'],'queue_name':_0x382850[_0x4812af]['name'],'VoiceQueueId':_0x382850[_0x4812af]['id'],'interface':_[_0x55b5('0x64')](_0x5a805c[_0x55b5('0x9f')])?util[_0x55b5('0xa9')](_0x55b5('0xaa'),_0x5a805c[_0x55b5('0x2f')]):_0x5a805c[_0x55b5('0x9f')],'paused':_0x5a805c['voicePause']||![],'penalty':_0x5d24af['body']['penalty']||0x0});}return BPromise[_0x55b5('0x83')](_0x500b27,function(_0x2880dc){return db[_0x55b5('0xab')][_0x55b5('0xac')](_0x2880dc);});}return _0x4b45b4;});}})[_0x55b5('0x15')](respondWithStatusCode(_0x133ded,null))[_0x55b5('0x1f')](handleError(_0x133ded,null));};exports['removeQueues']=function(_0x34048f,_0xf11e09){var _0x3dcc06,_0x5502f2;return db[_0x55b5('0x3d')][_0x55b5('0x56')]({'where':{'id':_0x34048f[_0x55b5('0x4c')]['id']},'attributes':['id',_0x55b5('0x2f'),'role']})[_0x55b5('0x15')](handleEntityNotFound(_0xf11e09,null))[_0x55b5('0x15')](function(_0x512de7){if(_0x512de7){_0x3dcc06=_0x512de7;if(!_0x34048f[_0x55b5('0x3e')][_0x55b5('0x9b')]||!utils['isValidChannel'](_0x34048f[_0x55b5('0x3e')][_0x55b5('0x9b')])){throw new db[(_0x55b5('0x8c'))][(_0x55b5('0x8f'))](_0x55b5('0xa0'));}return _0x512de7[_0x55b5('0xad')+_[_0x55b5('0xa5')](_0x34048f[_0x55b5('0x3e')][_0x55b5('0x9b')]['toLowerCase']())+'Queues'](_0x34048f['query']['ids']);}})[_0x55b5('0x15')](function(_0x582047){if(_[_0x55b5('0xae')](_0x34048f['query'][_0x55b5('0x5f')])){for(var _0x32e9ec=0x0;_0x32e9ec<_0x34048f[_0x55b5('0x3e')][_0x55b5('0x5f')]['length'];_0x32e9ec+=0x1){_0x5502f2={'UserId':Number(_0x34048f[_0x55b5('0x4c')]['id'])};_0x5502f2[_['capitalize'](_0x34048f[_0x55b5('0x3e')]['channel'][_0x55b5('0xa1')]())+_0x55b5('0xaf')]=Number(_0x34048f['query']['ids'][_0x32e9ec]);socket[_0x55b5('0x27')]('user'+_[_0x55b5('0xa5')](_0x34048f[_0x55b5('0x3e')][_0x55b5('0x9b')]['toLowerCase']())+_0x55b5('0xb0'),_0x5502f2);}}else{_0x5502f2={'UserId':Number(_0x34048f[_0x55b5('0x4c')]['id'])};_0x5502f2[_['capitalize'](_0x34048f[_0x55b5('0x3e')]['channel'][_0x55b5('0xa1')]())+_0x55b5('0xaf')]=Number(_0x34048f[_0x55b5('0x3e')]['ids']);socket[_0x55b5('0x27')](_0x55b5('0x78')+_['capitalize'](_0x34048f[_0x55b5('0x3e')][_0x55b5('0x9b')]['toLowerCase']())+_0x55b5('0xb0'),_0x5502f2);}return _0x582047;})[_0x55b5('0x15')](function(){if(_0x34048f[_0x55b5('0x3e')]['channel']===_0x55b5('0xa6')){return db[_0x55b5('0xab')][_0x55b5('0x31')]({'where':{'UserId':_0x34048f[_0x55b5('0x4c')]['id'],'VoiceQueueId':_0x34048f[_0x55b5('0x3e')][_0x55b5('0x5f')]},'individualHooks':!![]})['then'](function(){return _0x3dcc06;});}return _0x3dcc06;})['then'](respondWithStatusCode(_0xf11e09,null))[_0x55b5('0x1f')](handleError(_0xf11e09,null));};exports[_0x55b5('0xb1')]=function(_0xc319f1,_0x5177ed){_0xc319f1[_0x55b5('0x5b')][_0x55b5('0xb2')]=_0xc319f1[_0x55b5('0xb3')][_0x55b5('0xb4')];return db[_0x55b5('0x3d')][_0x55b5('0x56')]({'where':{'id':_0xc319f1['params']['id']}})[_0x55b5('0x15')](handleEntityNotFound(_0x5177ed,null))[_0x55b5('0x15')](saveUpdates(_0xc319f1[_0x55b5('0x5b')],null))[_0x55b5('0x15')](respondWithResult(_0x5177ed,null))[_0x55b5('0x1f')](handleError(_0x5177ed,null));};exports[_0x55b5('0xb5')]=function(_0x5e1cfd,_0x571cdd){var _0x1f5dda=path['join'](config[_0x55b5('0xb6')],_0x55b5('0xb7'));return db[_0x55b5('0x3d')][_0x55b5('0x56')]({'where':{'id':_0x5e1cfd['params']['id']},'attributes':['id',_0x55b5('0xb2')],'raw':!![]})['then'](handleEntityNotFound(_0x571cdd,null))['then'](function(_0x1303df){if(_0x1303df){if(_[_0x55b5('0x64')](_0x1303df['userpic'])){return _0x571cdd['download'](_0x1f5dda);}else{if(!fs[_0x55b5('0xb8')](path[_0x55b5('0xb9')](config[_0x55b5('0xb6')],_0x55b5('0xba'),_0x1303df[_0x55b5('0xb2')]))){return _0x571cdd['download'](_0x1f5dda);}return _0x571cdd[_0x55b5('0xbb')](path[_0x55b5('0xb9')](config['root'],'server/files/images/',_0x1303df[_0x55b5('0xb2')]));}}})[_0x55b5('0x1f')](handleError(_0x571cdd,null));};exports['getOpenTabs']=function(_0x59cb97,_0x21b368){return db['User'][_0x55b5('0x56')]({'where':{'id':_0x59cb97['params']['id']},'attributes':['id']})[_0x55b5('0x15')](handleEntityNotFound(_0x21b368,null))[_0x55b5('0x15')](function(_0x4024f7){var _0x47d521=[];values=_0x4024f7[_0x55b5('0x47')];_0x47d521['push'](get_open_tabs(_0x55b5('0x46'),_0x4024f7[_0x55b5('0x47')]));_0x47d521[_0x55b5('0x43')](get_open_tabs('sms',_0x4024f7[_0x55b5('0x47')]));_0x47d521[_0x55b5('0x43')](get_open_tabs('openchannel',_0x4024f7[_0x55b5('0x47')]));_0x47d521['push'](get_open_tabs(_0x55b5('0x4a'),_0x4024f7[_0x55b5('0x47')]));_0x47d521['push'](get_open_tabs('fax',_0x4024f7[_0x55b5('0x47')]));_0x47d521['push'](get_open_tabs('mail',_0x4024f7['dataValues']));return BPromise[_0x55b5('0x5a')](_0x47d521);})['then'](function(_0x2f1021){if(_0x2f1021){var _0x529b43=_[_0x55b5('0x36')](values[_0x55b5('0xbc')],function(_0x115eab){return{'channel':_0x55b5('0xbd'),'id':_0x115eab['id'],'createdAt':_0x115eab[_0x55b5('0xbe')]};});var _0x5754b9=_[_0x55b5('0x36')](values[_0x55b5('0xbf')],function(_0x3ff477){return{'channel':_0x55b5('0xc0'),'id':_0x3ff477['id'],'createdAt':_0x3ff477[_0x55b5('0xbe')]};});var _0x48913c=_[_0x55b5('0x36')](values[_0x55b5('0xc1')],function(_0x59507d){return{'channel':_0x55b5('0xc2'),'id':_0x59507d['id'],'createdAt':_0x59507d[_0x55b5('0xbe')]};});var _0x823530=_[_0x55b5('0x36')](values['MailOpenTabs'],function(_0x2f3b35){return{'channel':_0x55b5('0xc3'),'id':_0x2f3b35['id'],'createdAt':_0x2f3b35[_0x55b5('0xbe')]};});var _0x18b708=_['map'](values[_0x55b5('0xc4')],function(_0x3b85e6){return{'channel':'SMS','id':_0x3b85e6['id'],'createdAt':_0x3b85e6['createdAt']};});var _0x26606b=_[_0x55b5('0x36')](values[_0x55b5('0xc5')],function(_0x15bd37){return{'channel':_0x55b5('0xc6'),'id':_0x15bd37['id'],'createdAt':_0x15bd37[_0x55b5('0xbe')]};});var _0x2c35fe=_[_0x55b5('0xc7')](_0x529b43,_0x5754b9,_0x48913c,_0x823530,_0x18b708,_0x26606b);var _0x8333a4={'count':_0x2c35fe['length'],'rows':_0x2c35fe};return _0x8333a4;}else return null;})[_0x55b5('0x15')](respondWithResult(_0x21b368,null))[_0x55b5('0x1f')](handleError(_0x21b368,null));};exports[_0x55b5('0xc8')]=function(_0x66b54b,_0xd83f2e){var _0x17f00f={};var _0x4ec6df={};var _0x317c3e;var _0x1b55f5;return db[_0x55b5('0x3d')][_0x55b5('0x93')]({'where':{'id':_0x66b54b[_0x55b5('0x4c')]['id']}})['then'](handleEntityNotFound(_0xd83f2e,null))['then'](function(_0xbe4c36){if(_0xbe4c36){_0x317c3e=_0xbe4c36;_0x4ec6df['model']=_[_0x55b5('0x4f')](db[_0x55b5('0xc9')][_0x55b5('0x50')]);_0x4ec6df[_0x55b5('0x3e')]=_['keys'](_0x66b54b['query']);_0x4ec6df['filters']=_[_0x55b5('0xca')](_0x4ec6df[_0x55b5('0x4d')],_0x4ec6df['query']);_0x17f00f[_0x55b5('0x42')]=_[_0x55b5('0xca')](_0x4ec6df[_0x55b5('0x4d')],qs[_0x55b5('0x52')](_0x66b54b[_0x55b5('0x3e')]['fields']));_0x17f00f[_0x55b5('0x42')]=_0x17f00f['attributes']['length']?_0x17f00f[_0x55b5('0x42')]:_0x4ec6df[_0x55b5('0x4d')];_0x17f00f[_0x55b5('0xcb')]=qs[_0x55b5('0xcc')](_0x66b54b[_0x55b5('0x3e')][_0x55b5('0xcc')]);_0x17f00f['where']=qs[_0x55b5('0x51')](_[_0x55b5('0xcd')](_0x66b54b[_0x55b5('0x3e')],_0x4ec6df[_0x55b5('0x51')]));if(_0x66b54b[_0x55b5('0x3e')][_0x55b5('0x2c')]){_0x17f00f['where']=_[_0x55b5('0xce')](_0x17f00f[_0x55b5('0xcf')],{'$or':_[_0x55b5('0x36')](_0x17f00f[_0x55b5('0x42')],function(_0x6ec71a){var _0x524351={};_0x524351[_0x6ec71a]={'$like':'%'+_0x66b54b[_0x55b5('0x3e')][_0x55b5('0x2c')]+'%'};return _0x524351;})});}_0x17f00f=_['merge']({},_0x17f00f,_0x66b54b['options']);return _0x317c3e[_0x55b5('0xc8')](_0x17f00f);}})[_0x55b5('0x15')](function(_0x2b724e){if(_0x2b724e){_0x1b55f5=_0x2b724e[_0x55b5('0x53')];if(_0x66b54b[_0x55b5('0x3e')][_0x55b5('0xd0')](_0x55b5('0x54'))){_0x17f00f['include']=[{'model':db[_0x55b5('0xd1')],'as':'List','required':![]},{'model':db[_0x55b5('0xd2')],'as':_0x55b5('0xd3'),'attributes':['id','name',_0x55b5('0xd4')],'where':_0x66b54b['query'][_0x55b5('0xd5')]?{'id':_0x66b54b[_0x55b5('0x3e')][_0x55b5('0xd5')]}:undefined,'required':_0x66b54b['query'][_0x55b5('0xd5')]?!![]:![]}];}if(!_0x66b54b[_0x55b5('0x3e')][_0x55b5('0xd0')](_0x55b5('0xd6'))){_0x17f00f['limit']=qs[_0x55b5('0x22')](_0x66b54b[_0x55b5('0x3e')]['limit']);_0x17f00f['offset']=qs['offset'](_0x66b54b['query'][_0x55b5('0x20')]);}return _0x317c3e['getContacts'](_0x17f00f);}})['then'](function(_0x4275d5){if(_0x4275d5){return _0x4275d5?{'count':_0x1b55f5,'rows':_0x4275d5}:null;}})['then'](respondWithResult(_0xd83f2e,null))[_0x55b5('0x1f')](handleError(_0xd83f2e,null));};exports[_0x55b5('0xd7')]=function(_0x31030c,_0x5a141f){var _0x15156a;var _0xf35d30={};var _0x5d8698;return db[_0x55b5('0x3d')][_0x55b5('0x93')]({'where':{'id':_0x31030c[_0x55b5('0x4c')]['id']},'attributes':['id','name','role']})['then'](handleEntityNotFound(_0x5a141f,null))[_0x55b5('0x15')](function(_0x184f7b){if(!utils['isValidChannel'](_0x31030c['query'][_0x55b5('0x9b')])){throw new db[(_0x55b5('0x8c'))][(_0x55b5('0x8f'))](_0x55b5('0xa0'));}_0x15156a=_0x184f7b;var _0x52be2b={};_0x52be2b[_0x55b5('0x4d')]=_[_0x55b5('0x4f')](db[_[_0x55b5('0xa5')](_0x31030c[_0x55b5('0x3e')][_0x55b5('0x9b')])+_0x55b5('0xd8')][_0x55b5('0x50')]);_0x52be2b[_0x55b5('0x3e')]=_['keys'](_0x31030c[_0x55b5('0x3e')]);_0x52be2b['filters']=_[_0x55b5('0xca')](_0x52be2b[_0x55b5('0x4d')],_0x52be2b[_0x55b5('0x3e')]);_0xf35d30[_0x55b5('0x42')]=_[_0x55b5('0xca')](_0x52be2b[_0x55b5('0x4d')],qs[_0x55b5('0x52')](_0x31030c[_0x55b5('0x3e')][_0x55b5('0x52')]));_0xf35d30[_0x55b5('0x42')]=_0xf35d30['attributes']['length']?_0xf35d30[_0x55b5('0x42')]:_0x52be2b[_0x55b5('0x4d')];_0xf35d30[_0x55b5('0xcb')]=qs[_0x55b5('0xcc')](_0x31030c[_0x55b5('0x3e')][_0x55b5('0xcc')]);_0xf35d30[_0x55b5('0xcf')]=qs[_0x55b5('0x51')](_[_0x55b5('0xcd')](_0x31030c[_0x55b5('0x3e')],_0x52be2b[_0x55b5('0x51')]));if(_0x31030c[_0x55b5('0x3e')][_0x55b5('0x2c')]){_0xf35d30[_0x55b5('0xcf')]=_['merge'](_0xf35d30[_0x55b5('0xcf')],{'$or':_['map'](_0xf35d30[_0x55b5('0x42')],function(_0x245afa){var _0x39408f={};_0x39408f[_0x245afa]={'$like':'%'+_0x31030c[_0x55b5('0x3e')][_0x55b5('0x2c')]+'%'};return _0x39408f;})});}_0xf35d30=_[_0x55b5('0xce')]({},_0xf35d30,_0x31030c['options']);switch(_0x15156a['role']){case _0x55b5('0x29'):return db[_[_0x55b5('0xa5')](_0x31030c[_0x55b5('0x3e')][_0x55b5('0x9b')])+'Queue']['findAll'](_0xf35d30);case _0x55b5('0x78'):case'agent':return _0x15156a[_0x55b5('0xa8')+_[_0x55b5('0xa5')](_0x31030c[_0x55b5('0x3e')][_0x55b5('0x9b')])+'Queues'](_0xf35d30);default:throw new db[(_0x55b5('0x8c'))][(_0x55b5('0x8f'))]('Unknown\x20role');}})[_0x55b5('0x15')](function(_0x194d28){_0x5d8698=_0x194d28[_0x55b5('0x53')];if(!_0x31030c[_0x55b5('0x3e')][_0x55b5('0xd0')](_0x55b5('0xd6'))){_0xf35d30[_0x55b5('0x22')]=qs[_0x55b5('0x22')](_0x31030c['query'][_0x55b5('0x22')]);_0xf35d30['offset']=qs['offset'](_0x31030c[_0x55b5('0x3e')]['offset']);}switch(_0x15156a[_0x55b5('0x28')]){case _0x55b5('0x29'):return db[_['capitalize'](_0x31030c['query'][_0x55b5('0x9b')])+_0x55b5('0xd8')][_0x55b5('0x85')](_0xf35d30);case _0x55b5('0x78'):case _0x55b5('0x6d'):return _0x15156a[_0x55b5('0xa8')+_[_0x55b5('0xa5')](_0x31030c['query'][_0x55b5('0x9b')])+_0x55b5('0xa2')](_0xf35d30);}})['then'](function(_0x50a53f){return{'count':_0x5d8698,'rows':_0x50a53f};})[_0x55b5('0x15')](respondWithResult(_0x5a141f,null))[_0x55b5('0x1f')](handleError(_0x5a141f,null));};exports[_0x55b5('0xd9')]=function(_0x3df211,_0x410eae){var _0x5f5bd3={};var _0x3f40bd={};var _0x420213;var _0x235631;return db['User'][_0x55b5('0x93')]({'where':{'id':_0x3df211[_0x55b5('0x4c')]['id']}})[_0x55b5('0x15')](handleEntityNotFound(_0x410eae,null))[_0x55b5('0x15')](function(_0x41a77e){if(_0x41a77e){_0x420213=_0x41a77e;_0x3f40bd[_0x55b5('0x4d')]=_[_0x55b5('0x4f')](db[_0x55b5('0xab')][_0x55b5('0x50')]);_0x3f40bd['query']=_[_0x55b5('0x4f')](_0x3df211[_0x55b5('0x3e')]);_0x3f40bd[_0x55b5('0x51')]=_['intersection'](_0x3f40bd[_0x55b5('0x4d')],_0x3f40bd[_0x55b5('0x3e')]);_0x5f5bd3[_0x55b5('0x42')]=_['intersection'](_0x3f40bd[_0x55b5('0x4d')],qs[_0x55b5('0x52')](_0x3df211['query']['fields']));_0x5f5bd3[_0x55b5('0x42')]=_0x5f5bd3[_0x55b5('0x42')][_0x55b5('0x53')]?_0x5f5bd3[_0x55b5('0x42')]:_0x3f40bd[_0x55b5('0x4d')];_0x5f5bd3[_0x55b5('0xcb')]=qs[_0x55b5('0xcc')](_0x3df211['query']['sort']);_0x5f5bd3[_0x55b5('0xcf')]=qs[_0x55b5('0x51')](_[_0x55b5('0xcd')](_0x3df211[_0x55b5('0x3e')],_0x3f40bd[_0x55b5('0x51')]));if(_0x3df211[_0x55b5('0x3e')][_0x55b5('0x2c')]){_0x5f5bd3[_0x55b5('0xcf')]=_[_0x55b5('0xce')](_0x5f5bd3[_0x55b5('0xcf')],{'$or':_[_0x55b5('0x36')](_0x5f5bd3[_0x55b5('0x42')],function(_0x30d65f){var _0x3a2c7d={};_0x3a2c7d[_0x30d65f]={'$like':'%'+_0x3df211[_0x55b5('0x3e')][_0x55b5('0x2c')]+'%'};return _0x3a2c7d;})});}_0x5f5bd3=_[_0x55b5('0xce')]({},_0x5f5bd3,_0x3df211[_0x55b5('0x55')]);return _0x420213[_0x55b5('0xd9')](_0x5f5bd3);}})['then'](function(_0x34acf4){if(_0x34acf4){_0x235631=_0x34acf4[_0x55b5('0x53')];if(!_0x3df211[_0x55b5('0x3e')]['hasOwnProperty'](_0x55b5('0xd6'))){_0x5f5bd3[_0x55b5('0x22')]=qs[_0x55b5('0x22')](_0x3df211[_0x55b5('0x3e')]['limit']);_0x5f5bd3[_0x55b5('0x20')]=qs[_0x55b5('0x20')](_0x3df211[_0x55b5('0x3e')]['offset']);}return _0x420213['getVoiceQueuesRt'](_0x5f5bd3);}})[_0x55b5('0x15')](function(_0x3dfabe){if(_0x3dfabe){return _0x3dfabe?{'count':_0x235631,'rows':_0x3dfabe}:null;}})[_0x55b5('0x15')](respondWithResult(_0x410eae,null))[_0x55b5('0x1f')](handleError(_0x410eae,null));};exports['getGroups']=function(_0x3095a7,_0x1e8c55){var _0x3a7f1f={};var _0x2c8917={};var _0x2428a0;var _0x73a19c;return db[_0x55b5('0x3d')][_0x55b5('0x93')]({'where':{'id':_0x3095a7[_0x55b5('0x4c')]['id']}})['then'](handleEntityNotFound(_0x1e8c55,null))[_0x55b5('0x15')](function(_0x40b42b){if(_0x40b42b){_0x2428a0=_0x40b42b;_0x2c8917[_0x55b5('0x4d')]=_['keys'](db[_0x55b5('0xda')][_0x55b5('0x50')]);_0x2c8917['query']=_[_0x55b5('0x4f')](_0x3095a7[_0x55b5('0x3e')]);_0x2c8917[_0x55b5('0x51')]=_[_0x55b5('0xca')](_0x2c8917[_0x55b5('0x4d')],_0x2c8917[_0x55b5('0x3e')]);_0x3a7f1f['attributes']=_[_0x55b5('0xca')](_0x2c8917['model'],qs[_0x55b5('0x52')](_0x3095a7[_0x55b5('0x3e')][_0x55b5('0x52')]));_0x3a7f1f[_0x55b5('0x42')]=_0x3a7f1f[_0x55b5('0x42')][_0x55b5('0x53')]?_0x3a7f1f[_0x55b5('0x42')]:_0x2c8917[_0x55b5('0x4d')];_0x3a7f1f[_0x55b5('0xcb')]=qs[_0x55b5('0xcc')](_0x3095a7[_0x55b5('0x3e')][_0x55b5('0xcc')]);_0x3a7f1f[_0x55b5('0xcf')]=qs[_0x55b5('0x51')](_[_0x55b5('0xcd')](_0x3095a7[_0x55b5('0x3e')],_0x2c8917['filters']));if(_0x3095a7[_0x55b5('0x3e')][_0x55b5('0x2c')]){_0x3a7f1f[_0x55b5('0xcf')]=_[_0x55b5('0xce')](_0x3a7f1f[_0x55b5('0xcf')],{'$or':_[_0x55b5('0x36')](_0x3a7f1f['attributes'],function(_0x3a2b30){var _0x5d866e={};_0x5d866e[_0x3a2b30]={'$like':'%'+_0x3095a7[_0x55b5('0x3e')]['filter']+'%'};return _0x5d866e;})});}_0x3a7f1f=_[_0x55b5('0xce')]({},_0x3a7f1f,_0x3095a7[_0x55b5('0x55')]);return _0x2428a0[_0x55b5('0xdb')](_0x3a7f1f);}})[_0x55b5('0x15')](function(_0x21d8bd){if(_0x21d8bd){_0x73a19c=_0x21d8bd[_0x55b5('0x53')];if(!_0x3095a7[_0x55b5('0x3e')]['hasOwnProperty']('nolimit')){_0x3a7f1f[_0x55b5('0x22')]=qs['limit'](_0x3095a7[_0x55b5('0x3e')][_0x55b5('0x22')]);_0x3a7f1f[_0x55b5('0x20')]=qs['offset'](_0x3095a7[_0x55b5('0x3e')][_0x55b5('0x20')]);}return _0x2428a0['getGroups'](_0x3a7f1f);}})['then'](function(_0x361e34){if(_0x361e34){return _0x361e34?{'count':_0x73a19c,'rows':_0x361e34}:null;}})[_0x55b5('0x15')](respondWithResult(_0x1e8c55,null))[_0x55b5('0x1f')](handleError(_0x1e8c55,null));};exports['getRecordings']=function(_0x27efd8,_0x5ac3cc){var _0x3a8aa0={'raw':!![],'where':{}};var _0x529ce9={};var _0x18c5d2={'count':0x0,'rows':[]};return db[_0x55b5('0x3d')][_0x55b5('0x93')]({'where':{'id':_0x27efd8['params']['id']}})[_0x55b5('0x15')](handleEntityNotFound(_0x5ac3cc,null))[_0x55b5('0x15')](function(_0x1d95ff){if(_0x1d95ff){_0x529ce9[_0x55b5('0x4d')]=_[_0x55b5('0x4f')](db[_0x55b5('0xdc')]['rawAttributes']);_0x529ce9[_0x55b5('0x3e')]=_[_0x55b5('0x4f')](_0x27efd8[_0x55b5('0x3e')]);_0x529ce9[_0x55b5('0x51')]=_[_0x55b5('0xca')](_0x529ce9[_0x55b5('0x4d')],_0x529ce9[_0x55b5('0x3e')]);_0x3a8aa0[_0x55b5('0x42')]=_['intersection'](_0x529ce9[_0x55b5('0x4d')],qs[_0x55b5('0x52')](_0x27efd8['query'][_0x55b5('0x52')]));_0x3a8aa0[_0x55b5('0x42')]=_0x3a8aa0[_0x55b5('0x42')][_0x55b5('0x53')]?_0x3a8aa0['attributes']:_0x529ce9[_0x55b5('0x4d')];if(!_0x27efd8['query'][_0x55b5('0xd0')]('nolimit')){_0x3a8aa0[_0x55b5('0x22')]=qs[_0x55b5('0x22')](_0x27efd8[_0x55b5('0x3e')][_0x55b5('0x22')]);_0x3a8aa0[_0x55b5('0x20')]=qs[_0x55b5('0x20')](_0x27efd8[_0x55b5('0x3e')][_0x55b5('0x20')]);}_0x3a8aa0[_0x55b5('0xcb')]=qs[_0x55b5('0xcc')](_0x27efd8['query'][_0x55b5('0xcc')]);_0x3a8aa0[_0x55b5('0xcf')]=qs[_0x55b5('0x51')](_[_0x55b5('0xcd')](_0x27efd8['query'],_0x529ce9['filters']));_0x3a8aa0[_0x55b5('0xcf')][_0x55b5('0xdd')]=_0x1d95ff['id'];if(_0x27efd8[_0x55b5('0x3e')][_0x55b5('0x2c')]){_0x3a8aa0[_0x55b5('0xcf')]=_[_0x55b5('0xce')](_0x3a8aa0['where'],{'$or':_[_0x55b5('0x36')](_0x3a8aa0['attributes'],function(_0x4bf53){var _0x1eacd0={};_0x1eacd0[_0x4bf53]={'$like':'%'+_0x27efd8[_0x55b5('0x3e')]['filter']+'%'};return _0x1eacd0;})});}_0x3a8aa0=_[_0x55b5('0xce')]({},_0x3a8aa0,_0x27efd8[_0x55b5('0x55')]);return db['VoiceRecording'][_0x55b5('0x23')]({'where':_0x3a8aa0['where']})['then'](function(_0x3306fe){_0x18c5d2[_0x55b5('0x23')]=_0x3306fe;if(_0x27efd8[_0x55b5('0x3e')][_0x55b5('0x54')]){_0x3a8aa0[_0x55b5('0x3f')]=[{'all':!![]}];}return db[_0x55b5('0xdc')][_0x55b5('0x85')](_0x3a8aa0);})['then'](function(_0x35a3c7){_0x18c5d2[_0x55b5('0x44')]=_0x35a3c7;return _0x18c5d2;});}})[_0x55b5('0x15')](respondWithFilteredResult(_0x5ac3cc,_0x3a8aa0))[_0x55b5('0x1f')](handleError(_0x5ac3cc,null));};exports[_0x55b5('0xde')]=function(_0x3bdd28,_0x3fef9c){var _0x245c83={'raw':!![],'where':{}};var _0x2e79f9={};var _0x36dae8={'count':0x0,'rows':[]};return db[_0x55b5('0x3d')][_0x55b5('0x93')]({'where':{'id':_0x3bdd28['params']['id']}})['then'](handleEntityNotFound(_0x3fef9c,null))['then'](function(_0x4a3a2a){if(_0x4a3a2a){_0x2e79f9[_0x55b5('0x4d')]=_[_0x55b5('0x4f')](db['ScreenRecording']['rawAttributes']);_0x2e79f9[_0x55b5('0x3e')]=_[_0x55b5('0x4f')](_0x3bdd28['query']);_0x2e79f9[_0x55b5('0x51')]=_[_0x55b5('0xca')](_0x2e79f9[_0x55b5('0x4d')],_0x2e79f9[_0x55b5('0x3e')]);_0x245c83[_0x55b5('0x42')]=_[_0x55b5('0xca')](_0x2e79f9[_0x55b5('0x4d')],qs[_0x55b5('0x52')](_0x3bdd28['query']['fields']));_0x245c83['attributes']=_0x245c83[_0x55b5('0x42')][_0x55b5('0x53')]?_0x245c83[_0x55b5('0x42')]:_0x2e79f9['model'];if(!_0x3bdd28['query'][_0x55b5('0xd0')]('nolimit')){_0x245c83[_0x55b5('0x22')]=qs[_0x55b5('0x22')](_0x3bdd28['query'][_0x55b5('0x22')]);_0x245c83[_0x55b5('0x20')]=qs[_0x55b5('0x20')](_0x3bdd28['query'][_0x55b5('0x20')]);}_0x245c83[_0x55b5('0xcb')]=qs[_0x55b5('0xcc')](_0x3bdd28[_0x55b5('0x3e')][_0x55b5('0xcc')]);_0x245c83[_0x55b5('0xcf')]=qs[_0x55b5('0x51')](_[_0x55b5('0xcd')](_0x3bdd28[_0x55b5('0x3e')],_0x2e79f9[_0x55b5('0x51')]));_0x245c83[_0x55b5('0xcf')]['UserId']=_0x4a3a2a['id'];if(_0x3bdd28[_0x55b5('0x3e')]['filter']){_0x245c83[_0x55b5('0xcf')]=_[_0x55b5('0xce')](_0x245c83['where'],{'$or':_['map'](_0x245c83['attributes'],function(_0x205d19){var _0x432865={};_0x432865[_0x205d19]={'$like':'%'+_0x3bdd28[_0x55b5('0x3e')][_0x55b5('0x2c')]+'%'};return _0x432865;})});}_0x245c83=_[_0x55b5('0xce')]({},_0x245c83,_0x3bdd28[_0x55b5('0x55')]);return db[_0x55b5('0xdf')][_0x55b5('0x23')]({'where':_0x245c83[_0x55b5('0xcf')]})[_0x55b5('0x15')](function(_0x738d6e){_0x36dae8[_0x55b5('0x23')]=_0x738d6e;if(_0x3bdd28['query']['includeAll']){_0x245c83[_0x55b5('0x3f')]=[{'all':!![]}];}return db[_0x55b5('0xdf')][_0x55b5('0x85')](_0x245c83);})[_0x55b5('0x15')](function(_0x1ab905){_0x36dae8[_0x55b5('0x44')]=_0x1ab905;return _0x36dae8;});}})[_0x55b5('0x15')](respondWithFilteredResult(_0x3fef9c,_0x245c83))[_0x55b5('0x1f')](handleError(_0x3fef9c,null));};exports[_0x55b5('0xe0')]=function(_0x3511ad,_0x39e9c2){var _0xcc6531={};var _0x49a898={};var _0x491c33;var _0x462790;return db[_0x55b5('0x3d')][_0x55b5('0x93')]({'where':{'id':_0x3511ad[_0x55b5('0x4c')]['id']}})[_0x55b5('0x15')](handleEntityNotFound(_0x39e9c2,null))[_0x55b5('0x15')](function(_0x596c07){if(_0x596c07){_0x491c33=_0x596c07;_0x49a898[_0x55b5('0x4d')]=_[_0x55b5('0x4f')](db[_0x55b5('0xe1')][_0x55b5('0x50')]);_0x49a898['query']=_[_0x55b5('0x4f')](_0x3511ad[_0x55b5('0x3e')]);_0x49a898[_0x55b5('0x51')]=_[_0x55b5('0xca')](_0x49a898['model'],_0x49a898[_0x55b5('0x3e')]);_0xcc6531[_0x55b5('0x42')]=_[_0x55b5('0xca')](_0x49a898['model'],qs[_0x55b5('0x52')](_0x3511ad[_0x55b5('0x3e')][_0x55b5('0x52')]));_0xcc6531[_0x55b5('0x42')]=_0xcc6531[_0x55b5('0x42')]['length']?_0xcc6531['attributes']:_0x49a898[_0x55b5('0x4d')];_0xcc6531[_0x55b5('0xcb')]=qs[_0x55b5('0xcc')](_0x3511ad[_0x55b5('0x3e')]['sort']);_0xcc6531[_0x55b5('0xcf')]=qs['filters'](_[_0x55b5('0xcd')](_0x3511ad['query'],_0x49a898[_0x55b5('0x51')]));if(_0x3511ad[_0x55b5('0x3e')][_0x55b5('0x2c')]){_0xcc6531[_0x55b5('0xcf')]=_[_0x55b5('0xce')](_0xcc6531[_0x55b5('0xcf')],{'$or':_['map'](_0xcc6531[_0x55b5('0x42')],function(_0x2942cc){var _0x182be1={};_0x182be1[_0x2942cc]={'$like':'%'+_0x3511ad[_0x55b5('0x3e')][_0x55b5('0x2c')]+'%'};return _0x182be1;})});}_0xcc6531=_[_0x55b5('0xce')]({},_0xcc6531,_0x3511ad['options']);return _0x491c33[_0x55b5('0xe0')](_0xcc6531);}})['then'](function(_0x125e12){if(_0x125e12){_0x462790=_0x125e12[_0x55b5('0x53')];if(!_0x3511ad[_0x55b5('0x3e')][_0x55b5('0xd0')](_0x55b5('0xd6'))){_0xcc6531[_0x55b5('0x22')]=qs[_0x55b5('0x22')](_0x3511ad[_0x55b5('0x3e')][_0x55b5('0x22')]);_0xcc6531['offset']=qs[_0x55b5('0x20')](_0x3511ad[_0x55b5('0x3e')][_0x55b5('0x20')]);}return _0x491c33[_0x55b5('0xe0')](_0xcc6531);}})['then'](function(_0xc5e356){if(_0xc5e356){return _0xc5e356?{'count':_0x462790,'rows':_0xc5e356}:null;}})['then'](respondWithResult(_0x39e9c2,null))['catch'](handleError(_0x39e9c2,null));};exports[_0x55b5('0xe2')]=function(_0x160076,_0xd621e2){var _0x59e42d={};var _0x1c2a76={};var _0x19b3b9;var _0x2e212b;return db[_0x55b5('0x3d')][_0x55b5('0x93')]({'where':{'id':_0x160076['params']['id']}})[_0x55b5('0x15')](handleEntityNotFound(_0xd621e2,null))['then'](function(_0x2296a1){if(_0x2296a1){_0x19b3b9=_0x2296a1;_0x1c2a76[_0x55b5('0x4d')]=_[_0x55b5('0x4f')](db[_0x55b5('0xe3')][_0x55b5('0x50')]);_0x1c2a76[_0x55b5('0x3e')]=_[_0x55b5('0x4f')](_0x160076[_0x55b5('0x3e')]);_0x1c2a76[_0x55b5('0x51')]=_[_0x55b5('0xca')](_0x1c2a76['model'],_0x1c2a76['query']);_0x59e42d[_0x55b5('0x42')]=_[_0x55b5('0xca')](_0x1c2a76[_0x55b5('0x4d')],qs[_0x55b5('0x52')](_0x160076['query'][_0x55b5('0x52')]));_0x59e42d['attributes']=_0x59e42d[_0x55b5('0x42')][_0x55b5('0x53')]?_0x59e42d[_0x55b5('0x42')]:_0x1c2a76[_0x55b5('0x4d')];_0x59e42d['order']=qs[_0x55b5('0xcc')](_0x160076[_0x55b5('0x3e')]['sort']);_0x59e42d[_0x55b5('0xcf')]=qs[_0x55b5('0x51')](_[_0x55b5('0xcd')](_0x160076['query'],_0x1c2a76[_0x55b5('0x51')]));if(_0x160076[_0x55b5('0x3e')][_0x55b5('0x2c')]){_0x59e42d['where']=_['merge'](_0x59e42d['where'],{'$or':_[_0x55b5('0x36')](_0x59e42d[_0x55b5('0x42')],function(_0x1a61e5){var _0x3e3f0b={};_0x3e3f0b[_0x1a61e5]={'$like':'%'+_0x160076['query'][_0x55b5('0x2c')]+'%'};return _0x3e3f0b;})});}_0x59e42d=_[_0x55b5('0xce')]({},_0x59e42d,_0x160076['options']);return _0x19b3b9[_0x55b5('0xe2')](_0x59e42d);}})['then'](function(_0x2e2b40){if(_0x2e2b40){_0x2e212b=_0x2e2b40[_0x55b5('0x53')];if(!_0x160076[_0x55b5('0x3e')][_0x55b5('0xd0')]('nolimit')){_0x59e42d['limit']=qs[_0x55b5('0x22')](_0x160076['query']['limit']);_0x59e42d['offset']=qs[_0x55b5('0x20')](_0x160076[_0x55b5('0x3e')][_0x55b5('0x20')]);}return _0x19b3b9[_0x55b5('0xe2')](_0x59e42d);}})['then'](function(_0x31c678){if(_0x31c678){return _0x31c678?{'count':_0x2e212b,'rows':_0x31c678}:null;}})[_0x55b5('0x15')](respondWithResult(_0xd621e2,null))[_0x55b5('0x1f')](handleError(_0xd621e2,null));};exports['getMailInteractions']=function(_0x549271,_0x17153f){var _0x1c398e={'raw':!![],'where':{}};var _0x2a85df={};var _0x35f1f1={'count':0x0,'rows':[]};return db[_0x55b5('0x3d')][_0x55b5('0x93')]({'where':{'id':_0x549271[_0x55b5('0x4c')]['id']}})['then'](handleEntityNotFound(_0x17153f,null))[_0x55b5('0x15')](function(_0x36491f){if(_0x36491f){_0x2a85df['model']=_[_0x55b5('0x4f')](db['MailInteraction'][_0x55b5('0x50')]);_0x2a85df[_0x55b5('0x3e')]=_[_0x55b5('0x4f')](_0x549271[_0x55b5('0x3e')]);_0x2a85df[_0x55b5('0x51')]=_[_0x55b5('0xca')](_0x2a85df[_0x55b5('0x4d')],_0x2a85df[_0x55b5('0x3e')]);_0x1c398e[_0x55b5('0x42')]=_[_0x55b5('0xca')](_0x2a85df[_0x55b5('0x4d')],qs[_0x55b5('0x52')](_0x549271[_0x55b5('0x3e')][_0x55b5('0x52')]));_0x1c398e[_0x55b5('0x42')]=_0x1c398e[_0x55b5('0x42')]['length']?_0x1c398e[_0x55b5('0x42')]:_0x2a85df['model'];if(!_0x549271[_0x55b5('0x3e')][_0x55b5('0xd0')](_0x55b5('0xd6'))){_0x1c398e['limit']=qs['limit'](_0x549271['query']['limit']);_0x1c398e[_0x55b5('0x20')]=qs['offset'](_0x549271[_0x55b5('0x3e')][_0x55b5('0x20')]);}_0x1c398e[_0x55b5('0xcb')]=qs['sort'](_0x549271[_0x55b5('0x3e')]['sort']);_0x1c398e[_0x55b5('0xcf')]=qs[_0x55b5('0x51')](_[_0x55b5('0xcd')](_0x549271[_0x55b5('0x3e')],_0x2a85df[_0x55b5('0x51')]));_0x1c398e[_0x55b5('0xcf')]['UserId']=_0x36491f['id'];if(_0x549271['query'][_0x55b5('0x2c')]){_0x1c398e[_0x55b5('0xcf')]=_[_0x55b5('0xce')](_0x1c398e['where'],{'$or':_[_0x55b5('0x36')](_0x1c398e['attributes'],function(_0x5d46f8){var _0x5cca23={};_0x5cca23[_0x5d46f8]={'$like':'%'+_0x549271[_0x55b5('0x3e')][_0x55b5('0x2c')]+'%'};return _0x5cca23;})});}_0x1c398e=_[_0x55b5('0xce')]({},_0x1c398e,_0x549271['options']);return db[_0x55b5('0xe4')][_0x55b5('0x23')]({'where':_0x1c398e[_0x55b5('0xcf')]})[_0x55b5('0x15')](function(_0x2ea536){_0x35f1f1[_0x55b5('0x23')]=_0x2ea536;if(_0x549271[_0x55b5('0x3e')][_0x55b5('0x54')]){_0x1c398e[_0x55b5('0x3f')]=[{'all':!![]}];}return db['MailInteraction'][_0x55b5('0x85')](_0x1c398e);})[_0x55b5('0x15')](function(_0x5f22b4){_0x35f1f1['rows']=_0x5f22b4;return _0x35f1f1;});}})[_0x55b5('0x15')](respondWithFilteredResult(_0x17153f,_0x1c398e))[_0x55b5('0x1f')](handleError(_0x17153f,null));};exports['getSmsInteractions']=function(_0x577f53,_0x515d0d){var _0xeeecc8={};var _0x3cb1e3={};var _0x290f1d;var _0x807559;return db['User']['findOne']({'where':{'id':_0x577f53['params']['id']}})[_0x55b5('0x15')](handleEntityNotFound(_0x515d0d,null))[_0x55b5('0x15')](function(_0xc6c58){if(_0xc6c58){_0x290f1d=_0xc6c58;_0x3cb1e3[_0x55b5('0x4d')]=_[_0x55b5('0x4f')](db[_0x55b5('0xe5')][_0x55b5('0x50')]);_0x3cb1e3[_0x55b5('0x3e')]=_[_0x55b5('0x4f')](_0x577f53[_0x55b5('0x3e')]);_0x3cb1e3[_0x55b5('0x51')]=_[_0x55b5('0xca')](_0x3cb1e3[_0x55b5('0x4d')],_0x3cb1e3['query']);_0xeeecc8['attributes']=_['intersection'](_0x3cb1e3[_0x55b5('0x4d')],qs[_0x55b5('0x52')](_0x577f53[_0x55b5('0x3e')][_0x55b5('0x52')]));_0xeeecc8['attributes']=_0xeeecc8['attributes']['length']?_0xeeecc8[_0x55b5('0x42')]:_0x3cb1e3['model'];_0xeeecc8[_0x55b5('0xcb')]=qs[_0x55b5('0xcc')](_0x577f53['query'][_0x55b5('0xcc')]);_0xeeecc8[_0x55b5('0xcf')]=qs[_0x55b5('0x51')](_[_0x55b5('0xcd')](_0x577f53[_0x55b5('0x3e')],_0x3cb1e3[_0x55b5('0x51')]));if(_0x577f53[_0x55b5('0x3e')][_0x55b5('0x2c')]){_0xeeecc8[_0x55b5('0xcf')]=_[_0x55b5('0xce')](_0xeeecc8[_0x55b5('0xcf')],{'$or':_['map'](_0xeeecc8['attributes'],function(_0x225db6){var _0x9405a1={};_0x9405a1[_0x225db6]={'$like':'%'+_0x577f53[_0x55b5('0x3e')][_0x55b5('0x2c')]+'%'};return _0x9405a1;})});}_0xeeecc8=_[_0x55b5('0xce')]({},_0xeeecc8,_0x577f53[_0x55b5('0x55')]);return _0x290f1d[_0x55b5('0xe6')](_0xeeecc8);}})[_0x55b5('0x15')](function(_0x32a7ae){if(_0x32a7ae){_0x807559=_0x32a7ae[_0x55b5('0x53')];if(!_0x577f53['query'][_0x55b5('0xd0')]('nolimit')){_0xeeecc8['limit']=qs['limit'](_0x577f53[_0x55b5('0x3e')]['limit']);_0xeeecc8[_0x55b5('0x20')]=qs[_0x55b5('0x20')](_0x577f53[_0x55b5('0x3e')][_0x55b5('0x20')]);}return _0x290f1d['getSmsInteractions'](_0xeeecc8);}})['then'](function(_0x426c15){if(_0x426c15){return _0x426c15?{'count':_0x807559,'rows':_0x426c15}:null;}})['then'](respondWithResult(_0x515d0d,null))['catch'](handleError(_0x515d0d,null));};exports[_0x55b5('0xe7')]=function(_0x240644,_0x30c936){var _0x2cc6e9={};var _0x1b35a3={};var _0x194b4f;var _0x21c1cd;return db[_0x55b5('0x3d')][_0x55b5('0x93')]({'where':{'id':_0x240644['params']['id']}})[_0x55b5('0x15')](handleEntityNotFound(_0x30c936,null))['then'](function(_0x5dd46a){if(_0x5dd46a){_0x194b4f=_0x5dd46a;_0x1b35a3[_0x55b5('0x4d')]=_[_0x55b5('0x4f')](db[_0x55b5('0xe8')][_0x55b5('0x50')]);_0x1b35a3[_0x55b5('0x3e')]=_[_0x55b5('0x4f')](_0x240644[_0x55b5('0x3e')]);_0x1b35a3['filters']=_[_0x55b5('0xca')](_0x1b35a3[_0x55b5('0x4d')],_0x1b35a3['query']);_0x2cc6e9['attributes']=_['intersection'](_0x1b35a3[_0x55b5('0x4d')],qs['fields'](_0x240644[_0x55b5('0x3e')][_0x55b5('0x52')]));_0x2cc6e9[_0x55b5('0x42')]=_0x2cc6e9[_0x55b5('0x42')]['length']?_0x2cc6e9['attributes']:_0x1b35a3[_0x55b5('0x4d')];_0x2cc6e9[_0x55b5('0xcb')]=qs[_0x55b5('0xcc')](_0x240644[_0x55b5('0x3e')][_0x55b5('0xcc')]);_0x2cc6e9[_0x55b5('0xcf')]=qs['filters'](_[_0x55b5('0xcd')](_0x240644[_0x55b5('0x3e')],_0x1b35a3[_0x55b5('0x51')]));if(_0x240644[_0x55b5('0x3e')]['filter']){_0x2cc6e9['where']=_[_0x55b5('0xce')](_0x2cc6e9[_0x55b5('0xcf')],{'$or':_['map'](_0x2cc6e9['attributes'],function(_0x17b907){var _0x52a73c={};_0x52a73c[_0x17b907]={'$like':'%'+_0x240644[_0x55b5('0x3e')][_0x55b5('0x2c')]+'%'};return _0x52a73c;})});}_0x2cc6e9=_['merge']({},_0x2cc6e9,_0x240644[_0x55b5('0x55')]);return _0x194b4f['getFaxInteractions'](_0x2cc6e9);}})[_0x55b5('0x15')](function(_0x1916f2){if(_0x1916f2){_0x21c1cd=_0x1916f2[_0x55b5('0x53')];if(!_0x240644[_0x55b5('0x3e')][_0x55b5('0xd0')](_0x55b5('0xd6'))){_0x2cc6e9[_0x55b5('0x22')]=qs['limit'](_0x240644['query'][_0x55b5('0x22')]);_0x2cc6e9[_0x55b5('0x20')]=qs[_0x55b5('0x20')](_0x240644[_0x55b5('0x3e')]['offset']);}return _0x194b4f[_0x55b5('0xe7')](_0x2cc6e9);}})[_0x55b5('0x15')](function(_0x572dbf){if(_0x572dbf){return _0x572dbf?{'count':_0x21c1cd,'rows':_0x572dbf}:null;}})['then'](respondWithResult(_0x30c936,null))['catch'](handleError(_0x30c936,null));};exports['getWhatsappInteractions']=function(_0x269f14,_0x15e81a){var _0x342bb9={};var _0x42b0e6={};var _0x2a60b5;var _0x3bc61b;return db[_0x55b5('0x3d')][_0x55b5('0x93')]({'where':{'id':_0x269f14[_0x55b5('0x4c')]['id']}})['then'](handleEntityNotFound(_0x15e81a,null))[_0x55b5('0x15')](function(_0x49567c){if(_0x49567c){_0x2a60b5=_0x49567c;_0x42b0e6['model']=_[_0x55b5('0x4f')](db['WhatsappInteraction']['rawAttributes']);_0x42b0e6[_0x55b5('0x3e')]=_[_0x55b5('0x4f')](_0x269f14[_0x55b5('0x3e')]);_0x42b0e6['filters']=_[_0x55b5('0xca')](_0x42b0e6[_0x55b5('0x4d')],_0x42b0e6[_0x55b5('0x3e')]);_0x342bb9[_0x55b5('0x42')]=_['intersection'](_0x42b0e6[_0x55b5('0x4d')],qs[_0x55b5('0x52')](_0x269f14[_0x55b5('0x3e')]['fields']));_0x342bb9[_0x55b5('0x42')]=_0x342bb9[_0x55b5('0x42')][_0x55b5('0x53')]?_0x342bb9[_0x55b5('0x42')]:_0x42b0e6[_0x55b5('0x4d')];_0x342bb9[_0x55b5('0xcb')]=qs['sort'](_0x269f14[_0x55b5('0x3e')][_0x55b5('0xcc')]);_0x342bb9[_0x55b5('0xcf')]=qs[_0x55b5('0x51')](_['pick'](_0x269f14[_0x55b5('0x3e')],_0x42b0e6[_0x55b5('0x51')]));if(_0x269f14[_0x55b5('0x3e')][_0x55b5('0x2c')]){_0x342bb9[_0x55b5('0xcf')]=_[_0x55b5('0xce')](_0x342bb9[_0x55b5('0xcf')],{'$or':_[_0x55b5('0x36')](_0x342bb9[_0x55b5('0x42')],function(_0x4e50cb){var _0x358cfd={};_0x358cfd[_0x4e50cb]={'$like':'%'+_0x269f14[_0x55b5('0x3e')][_0x55b5('0x2c')]+'%'};return _0x358cfd;})});}_0x342bb9=_[_0x55b5('0xce')]({},_0x342bb9,_0x269f14[_0x55b5('0x55')]);return _0x2a60b5['getWhatsappInteractions'](_0x342bb9);}})[_0x55b5('0x15')](function(_0x5abe20){if(_0x5abe20){_0x3bc61b=_0x5abe20[_0x55b5('0x53')];if(!_0x269f14['query']['hasOwnProperty'](_0x55b5('0xd6'))){_0x342bb9['limit']=qs[_0x55b5('0x22')](_0x269f14[_0x55b5('0x3e')][_0x55b5('0x22')]);_0x342bb9[_0x55b5('0x20')]=qs[_0x55b5('0x20')](_0x269f14[_0x55b5('0x3e')][_0x55b5('0x20')]);}return _0x2a60b5[_0x55b5('0xe9')](_0x342bb9);}})[_0x55b5('0x15')](function(_0x5729e3){if(_0x5729e3){return _0x5729e3?{'count':_0x3bc61b,'rows':_0x5729e3}:null;}})[_0x55b5('0x15')](respondWithResult(_0x15e81a,null))['catch'](handleError(_0x15e81a,null));};exports[_0x55b5('0xea')]=function(_0x594afc,_0x1d0813,_0x321155){var _0x42808f;var _0x199a8e;var _0x36d557;var _0x342c96=!_[_0x55b5('0x64')](_0x594afc[_0x55b5('0x4c')]['id'])?_0x594afc[_0x55b5('0x4c')]['id']:!_[_0x55b5('0x64')](_0x594afc[_0x55b5('0x78')]['id'])?_0x594afc[_0x55b5('0x78')]['id']:null;return db[_0x55b5('0x3d')][_0x55b5('0x56')]({'where':{'id':_0x342c96,'role':{'$or':[_0x55b5('0x29'),_0x55b5('0x78'),'agent']}},'attributes':['id','name',_0x55b5('0xeb'),_0x55b5('0xec'),_0x55b5('0x28'),'internal',_0x55b5('0x9d')]})['then'](function(_0x419c45){if(_0x419c45){if(_0x419c45[_0x55b5('0x28')]===_0x55b5('0x6d')){_0x42808f=_0x419c45;if(_0x594afc[_0x55b5('0x5b')]['interface']){_0x36d557=util[_0x55b5('0xa9')](_0x55b5('0xed'),_0x42808f[_0x594afc['body'][_0x55b5('0x9f')]]);}else if(_0x594afc['body'][_0x55b5('0xee')]){_0x36d557=util['format'](_0x55b5('0xaa'),_0x594afc[_0x55b5('0x5b')][_0x55b5('0xee')]);}else{_0x36d557=util['format'](_0x55b5('0xaa'),_0x42808f[_0x55b5('0x2f')]);}socket['to'](util['format'](_0x55b5('0xef'),_0x42808f[_0x55b5('0x2f')]))[_0x55b5('0x27')](_0x55b5('0xf0'),{'user':{'id':_0x42808f['id'],'name':_0x42808f['name']},'ip':_0x594afc['headers'][_0x55b5('0xf1')]||_0x594afc[_0x55b5('0xf2')][_0x55b5('0xf3')]||_0x594afc[_0x55b5('0xf4')][_0x55b5('0xf3')]||_0x594afc[_0x55b5('0xf2')][_0x55b5('0xf4')][_0x55b5('0xf3')]});return db['UserVoiceQueueRt']['destroy']({'where':{'membername':_0x42808f[_0x55b5('0x2f')]},'individualHooks':!![]});}}else{throw new db[(_0x55b5('0x8c'))]['ValidationError'](_0x55b5('0xf5'));}})[_0x55b5('0x15')](function(){if(_0x42808f){return _0x42808f['getVoiceQueues']({'raw':!![]});}})[_0x55b5('0x15')](function(_0x35ef93){if(_0x42808f){var _0x33b8f6=[];if(_0x35ef93){_0x199a8e=_0x35ef93;if(_0x199a8e[_0x55b5('0x53')]){for(var _0x12a860=0x0;_0x12a860<_0x199a8e['length'];_0x12a860++){_0x33b8f6['push']({'membername':_0x42808f['name'],'UserId':_0x42808f['id'],'queue_name':_0x199a8e[_0x12a860][_0x55b5('0x2f')],'VoiceQueueId':_0x199a8e[_0x12a860]['id'],'interface':_0x36d557,'paused':_0x42808f[_0x55b5('0x9d')]||![],'penalty':_0x199a8e[_0x12a860][_0x55b5('0xf6')]||0x0});}return BPromise[_0x55b5('0x83')](_0x33b8f6,function(_0x4cc2b2){return db[_0x55b5('0xab')][_0x55b5('0xac')](_0x4cc2b2);});}}}})[_0x55b5('0x15')](function(){if(_0x42808f){return db[_0x55b5('0xf7')][_0x55b5('0x85')]({'where':{'membername':_0x42808f[_0x55b5('0x2f')],'exitAt':null}});}})[_0x55b5('0x15')](function(_0x750ecc){if(_0x42808f){var _0x3566b8=[];_0x750ecc[_0x55b5('0xf8')](function(_0x20ddb6){_0x3566b8[_0x55b5('0x43')](_0x20ddb6[_0x55b5('0x26')]({'exitAt':moment()[_0x55b5('0xa9')](_0x55b5('0xf9'))}));});return BPromise[_0x55b5('0x5a')](_0x3566b8);}})[_0x55b5('0x15')](function(){if(_0x42808f){var _0xbfda54=[];var _0x3edd1f=[];var _0x1f095f=utils[_0x55b5('0xfa')]();var _0x571a1a={'membername':_0x42808f[_0x55b5('0x2f')],'interface':_0x36d557,'enterAt':moment()[_0x55b5('0xa9')](_0x55b5('0xf9')),'role':_0x42808f[_0x55b5('0x28')],'internal':_0x42808f[_0x55b5('0x60')]};_0x1f095f[_0x55b5('0xf8')](function(_0x4f7db0){_0xbfda54[_0x55b5('0x43')](_['merge']({'channel':_0x4f7db0,'type':_0x55b5('0xfb'),'data1':_0x594afc[_0x55b5('0x5b')][_0x55b5('0xfc')],'data2':_0x36d557},_0x571a1a));if(_0x42808f['loginInPause']){_0x3edd1f[_0x55b5('0x43')](_['merge']({'channel':_0x4f7db0,'type':_0x55b5('0xfd'),'data1':_0x55b5('0xfe')},_0x571a1a));}});return db['MemberReport'][_0x55b5('0xff')](_0xbfda54[_0x55b5('0xc7')](_0x3edd1f),{'individualHooks':!![]});}})[_0x55b5('0x15')](function(){if(_0x42808f){return _0x42808f[_0x55b5('0x26')]({'online':!![],'lastLoginAt':moment()[_0x55b5('0xa9')]('YYYY-MM-DD\x20HH:mm:ss'),'voicePause':_0x42808f['loginInPause']||![],'mailPause':_0x42808f[_0x55b5('0x9d')]||![],'chatPause':_0x42808f['loginInPause']||![],'faxPause':_0x42808f[_0x55b5('0x9d')]||![],'smsPause':_0x42808f[_0x55b5('0x9d')]||![],'openchannelPause':_0x42808f[_0x55b5('0x9d')]||![],'whatsappPause':_0x42808f[_0x55b5('0x9d')]||![],'pauseType':_0x42808f[_0x55b5('0x9d')]?_0x55b5('0xfe'):null,'interface':_0x36d557,'lastPauseAt':moment()[_0x55b5('0xa9')]('YYYY-MM-DD\x20HH:mm:ss')});}})['then'](function(_0x4bdb04){if(_0x594afc[_0x55b5('0x100')]){return _0x321155();}else{return BPromise[_0x55b5('0x101')](_0x4bdb04)[_0x55b5('0x15')](respondWithResult(_0x1d0813,null));}})[_0x55b5('0x1f')](handleError(_0x1d0813,null));};exports[_0x55b5('0x102')]=function(_0x315eaa,_0xea0654){var _0x5edd1d;return db[_0x55b5('0x3d')]['find']({'where':{'id':_0x315eaa[_0x55b5('0x4c')]['id'],'role':_0x55b5('0x6d')},'attributes':['id',_0x55b5('0x2f'),_0x55b5('0x28')]})[_0x55b5('0x15')](handleEntityNotFound(_0xea0654,null))[_0x55b5('0x15')](function(_0x37b031){if(_0x37b031){_0x5edd1d=_0x37b031;return db[_0x55b5('0xab')]['destroy']({'where':{'membername':_0x5edd1d[_0x55b5('0x2f')]},'individualHooks':!![]});}})[_0x55b5('0x15')](function(){return db[_0x55b5('0xf7')]['findAll']({'where':{'membername':_0x5edd1d[_0x55b5('0x2f')],'exitAt':null}});})[_0x55b5('0x15')](function(_0x51dc46){var _0x1752c9=[];_0x51dc46[_0x55b5('0xf8')](function(_0x593781){_0x1752c9[_0x55b5('0x43')](_0x593781[_0x55b5('0x26')]({'exitAt':moment()[_0x55b5('0xa9')](_0x55b5('0xf9'))}));});return BPromise[_0x55b5('0x5a')](_0x1752c9);})[_0x55b5('0x15')](function(){return _0x5edd1d[_0x55b5('0x26')]({'online':![],'voicePause':![],'mailPause':![],'chatPause':![],'faxPause':![],'smsPause':![],'openchannelPause':![],'whatsappPause':![],'interface':null});})[_0x55b5('0x15')](respondWithResult(_0xea0654,null))[_0x55b5('0x1f')](handleError(_0xea0654,null));};exports[_0x55b5('0x103')]=function(_0x4ecf37,_0x141124){var _0x4567fd;return db[_0x55b5('0xab')][_0x55b5('0x26')]({'paused':0x1},{'where':{'UserId':_0x4ecf37[_0x55b5('0x4c')]['id']},'individualHooks':!![]})[_0x55b5('0x15')](function(){return db[_0x55b5('0x3d')][_0x55b5('0x56')]({'where':{'id':_0x4ecf37[_0x55b5('0x4c')]['id'],'role':_0x55b5('0x6d')},'attributes':['id',_0x55b5('0x2f'),_0x55b5('0x28'),_0x55b5('0x60'),'interface']});})['then'](handleEntityNotFound(_0x141124,null))['then'](function(_0x1bcff2){if(_0x1bcff2){_0x4567fd=_0x1bcff2;return respondWithRpcPromise(_0x55b5('0x104'),_0x55b5('0x103'),{'id':_0x4567fd['id'],'name':_0x4567fd['name'],'pause':!![]});}})[_0x55b5('0x15')](function(){if(_0x4567fd){return db['MemberReport']['findAll']({'where':{'membername':_0x4567fd[_0x55b5('0x2f')],'type':'PAUSE','exitAt':null}});}})[_0x55b5('0x15')](function(_0x4da6ab){if(_0x4da6ab[_0x55b5('0x53')]){var _0x18e1d6=moment()[_0x55b5('0xa9')]('YYYY-MM-DD\x20HH:mm:ss');for(var _0x363cdd=0x0,_0x198114=_0x4da6ab[_0x55b5('0x53')];_0x363cdd<_0x198114;_0x363cdd++){_0x4da6ab[_0x363cdd]['updateAttributes']({'exitAt':_0x18e1d6});}}})[_0x55b5('0x15')](function(){var _0x3e69c3=[];var _0x4850ff=utils[_0x55b5('0xfa')]();_0x4850ff[_0x55b5('0xf8')](function(_0x1c21b5){_0x3e69c3['push']({'channel':_0x1c21b5,'membername':_0x4567fd['name'],'interface':_[_0x55b5('0x64')](_0x4567fd[_0x55b5('0x9f')])?util[_0x55b5('0xa9')]('SIP/%s',_0x4567fd[_0x55b5('0x2f')]):_0x4567fd[_0x55b5('0x9f')],'type':_0x55b5('0xfd'),'enterAt':moment()[_0x55b5('0xa9')](_0x55b5('0xf9')),'data1':_0x4ecf37[_0x55b5('0x5b')][_0x55b5('0x38')]||'DEFAULT\x20PAUSE','role':_0x4567fd['role'],'internal':_0x4567fd[_0x55b5('0x60')]});});return db[_0x55b5('0xf7')][_0x55b5('0xff')](_0x3e69c3,{'individualHooks':!![]});})['then'](function(){return _0x4567fd['update']({'voicePause':!![],'mailPause':!![],'chatPause':!![],'faxPause':!![],'smsPause':!![],'whatsappPause':!![],'openchannelPause':!![],'pauseType':_0x4ecf37[_0x55b5('0x5b')][_0x55b5('0x38')]||'DEFAULT\x20PAUSE','lastPauseAt':moment()['format'](_0x55b5('0xf9'))});})[_0x55b5('0x15')](respondWithResult(_0x141124,null))[_0x55b5('0x1f')](handleError(_0x141124,null));};exports[_0x55b5('0x105')]=function(_0x56a3fe,_0x191b5e){var _0xf1888b;return db[_0x55b5('0x3d')][_0x55b5('0x56')]({'where':{'id':_0x56a3fe[_0x55b5('0x4c')]['id']},'attributes':['id',_0x55b5('0x2f'),_0x55b5('0x28'),_0x55b5('0x9e'),_0x55b5('0x106'),'chatPause',_0x55b5('0x107'),_0x55b5('0x108'),_0x55b5('0x109'),'whatsapppause',_0x55b5('0x10a'),_0x55b5('0x10b')]})[_0x55b5('0x15')](handleEntityNotFound(_0x191b5e,null))[_0x55b5('0x15')](function(_0x2bf7bb){if(_0x2bf7bb){_0xf1888b=_0x2bf7bb;if(_0x56a3fe[_0x55b5('0x5b')][_0x55b5('0x9b')]&&!utils[_0x55b5('0x10c')](_0x56a3fe[_0x55b5('0x5b')]['channel'])){throw new db['Sequelize']['ValidationError'](_0x55b5('0xa0'));}switch(_0x56a3fe[_0x55b5('0x5b')][_0x55b5('0x9b')]){case'voice':return respondWithRpcPromise(_0x55b5('0x104'),'unpause',{'id':_0xf1888b['id'],'name':_0xf1888b[_0x55b5('0x2f')],'pause':![]})[_0x55b5('0x15')](function(){return db[_0x55b5('0xab')][_0x55b5('0x26')]({'paused':0x0},{'where':{'UserId':_0xf1888b['id']},'individualHooks':!![]});})['then'](function(){return db[_0x55b5('0xf7')][_0x55b5('0x56')]({'where':{'channel':_0x56a3fe[_0x55b5('0x5b')][_0x55b5('0x9b')],'membername':_0xf1888b['name'],'type':_0x55b5('0xfd'),'exitAt':null}});})[_0x55b5('0x15')](function(_0x28ddb2){if(_0x28ddb2){return _0x28ddb2['update']({'exitAt':moment()[_0x55b5('0xa9')](_0x55b5('0xf9')),'data2':_0x55b5('0x10d')},{'individualHooks':!![]});}return null;})['then'](function(){return _0xf1888b['update']({'voicePause':![]});});case _0x55b5('0x49'):case _0x55b5('0x46'):case _0x55b5('0x48'):case _0x55b5('0x58'):case _0x55b5('0x4a'):case _0x55b5('0x59'):return db[_0x55b5('0xf7')]['find']({'where':{'channel':_0x56a3fe[_0x55b5('0x5b')][_0x55b5('0x9b')],'membername':_0xf1888b['name'],'type':_0x55b5('0xfd'),'exitAt':null}})[_0x55b5('0x15')](function(_0x2e2f2e){if(_0x2e2f2e){return _0x2e2f2e['update']({'exitAt':moment()[_0x55b5('0xa9')](_0x55b5('0xf9')),'data2':_0x55b5('0x10d')},{'individualHooks':!![]});}return null;})[_0x55b5('0x15')](function(){var _0x356842={};_[_0x55b5('0x10e')](_0x356842,util['format'](_0x55b5('0x10f'),_0x56a3fe['body'][_0x55b5('0x9b')],_0x55b5('0x110')),![]);return _0xf1888b['update'](_0x356842);});default:return respondWithRpcPromise(_0x55b5('0x104'),_0x55b5('0x105'),{'id':_0xf1888b['id'],'name':_0xf1888b[_0x55b5('0x2f')],'pause':![]})[_0x55b5('0x15')](function(){return db[_0x55b5('0xab')][_0x55b5('0x26')]({'paused':0x0},{'where':{'UserId':_0xf1888b['id']}});})['then'](function(){return db[_0x55b5('0xf7')][_0x55b5('0x85')]({'where':{'membername':_0xf1888b[_0x55b5('0x2f')],'type':_0x55b5('0xfd'),'exitAt':null}});})[_0x55b5('0x15')](function(_0x3d390a){var _0x26003f=[];_0x3d390a['forEach'](function(_0x301a96){_0x26003f[_0x55b5('0x43')](_0x301a96[_0x55b5('0x26')]({'exitAt':moment()['format']('YYYY-MM-DD\x20HH:mm:ss'),'data2':_0x55b5('0x10d')}));});return BPromise[_0x55b5('0x5a')](_0x26003f);})[_0x55b5('0x15')](function(){return _0xf1888b[_0x55b5('0x26')]({'voicePause':![],'mailPause':![],'chatPause':![],'faxPause':![],'smsPause':![],'whatsappPause':![],'openchannelPause':![]});});}}})[_0x55b5('0x15')](respondWithResult(_0x191b5e,null))[_0x55b5('0x1f')](handleError(_0x191b5e,null));};exports['getTeams']=function(_0x3b8ddf,_0x5d8e7d){var _0x49db23={};var _0x5c56b8={};var _0x19163d;var _0x189156;return db[_0x55b5('0x3d')][_0x55b5('0x93')]({'where':{'id':_0x3b8ddf[_0x55b5('0x4c')]['id']}})['then'](handleEntityNotFound(_0x5d8e7d,null))['then'](function(_0x3d690e){if(_0x3d690e){_0x19163d=_0x3d690e;_0x5c56b8[_0x55b5('0x4d')]=_['keys'](db[_0x55b5('0x111')][_0x55b5('0x50')]);_0x5c56b8[_0x55b5('0x3e')]=_[_0x55b5('0x4f')](_0x3b8ddf['query']);_0x5c56b8[_0x55b5('0x51')]=_[_0x55b5('0xca')](_0x5c56b8[_0x55b5('0x4d')],_0x5c56b8[_0x55b5('0x3e')]);_0x49db23['attributes']=_['intersection'](_0x5c56b8[_0x55b5('0x4d')],qs[_0x55b5('0x52')](_0x3b8ddf[_0x55b5('0x3e')][_0x55b5('0x52')]));_0x49db23[_0x55b5('0x42')]=_0x49db23[_0x55b5('0x42')][_0x55b5('0x53')]?_0x49db23[_0x55b5('0x42')]:_0x5c56b8[_0x55b5('0x4d')];_0x49db23['order']=qs['sort'](_0x3b8ddf[_0x55b5('0x3e')]['sort']);_0x49db23[_0x55b5('0xcf')]=qs['filters'](_[_0x55b5('0xcd')](_0x3b8ddf[_0x55b5('0x3e')],_0x5c56b8['filters']));if(_0x3b8ddf[_0x55b5('0x3e')][_0x55b5('0x2c')]){_0x49db23[_0x55b5('0xcf')]=_[_0x55b5('0xce')](_0x49db23['where'],{'$or':_[_0x55b5('0x36')](_0x49db23['attributes'],function(_0x3a12cb){var _0x422097={};_0x422097[_0x3a12cb]={'$like':'%'+_0x3b8ddf['query']['filter']+'%'};return _0x422097;})});}_0x49db23=_[_0x55b5('0xce')]({},_0x49db23,_0x3b8ddf[_0x55b5('0x55')]);return _0x19163d['getTeams'](_0x49db23);}})[_0x55b5('0x15')](function(_0x3a39c9){if(_0x3a39c9){_0x189156=_0x3a39c9[_0x55b5('0x53')];if(!_0x3b8ddf[_0x55b5('0x3e')]['hasOwnProperty'](_0x55b5('0xd6'))){_0x49db23[_0x55b5('0x22')]=qs[_0x55b5('0x22')](_0x3b8ddf[_0x55b5('0x3e')][_0x55b5('0x22')]);_0x49db23[_0x55b5('0x20')]=qs['offset'](_0x3b8ddf[_0x55b5('0x3e')][_0x55b5('0x20')]);}return _0x19163d[_0x55b5('0x112')](_0x49db23);}})[_0x55b5('0x15')](function(_0x59c8a6){if(_0x59c8a6){return _0x59c8a6?{'count':_0x189156,'rows':_0x59c8a6}:null;}})[_0x55b5('0x15')](respondWithResult(_0x5d8e7d,null))[_0x55b5('0x1f')](handleError(_0x5d8e7d,null));};exports[_0x55b5('0x113')]=function(_0xdc9e71,_0x1fe7cf){var _0x4de5da=_0xdc9e71[_0x55b5('0x4c')]['id'];var _0x368285=_0xdc9e71['body']?_0xdc9e71[_0x55b5('0x5b')]['ids']:null;var _0x4134b7=[];return Promise[_0x55b5('0x101')]()[_0x55b5('0x15')](function(){if(!_0x368285)throw new APIBadRequestError(_0x55b5('0x114'));})['then'](function(){return db[_0x55b5('0x3d')][_0x55b5('0x93')]({'where':{'id':_0x4de5da}});})[_0x55b5('0x15')](function(_0x4fee35){if(!_0x4fee35)throw new APINotFoundError(util[_0x55b5('0xa9')](_0x55b5('0x115'),_0xdc9e71[_0x55b5('0x4c')]['id']));return db[_0x55b5('0x66')][_0x55b5('0x116')](function(_0xfb0621){return _0x4fee35[_0x55b5('0x113')](_0x368285,{'transaction':_0xfb0621})[_0x55b5('0x15')](function(){return db[_0x55b5('0x111')][_0x55b5('0x85')]({'where':{'id':{'$in':_0x368285}}});})[_0x55b5('0x15')](function(_0x1cdbe3){var _0x5f5ac2=_[_0x55b5('0x36')](_0x1cdbe3,function(_0x3585db){return _0x3585db[_0x55b5('0x117')]();});return Promise['all'](_0x5f5ac2);})['then'](function(_0x3012b8){_0x4134b7=_[_0x55b5('0x118')](_0x3012b8);var _0x4877c7=_[_0x55b5('0x36')](_0x4134b7,function(_0x1d0a83){return _0x1d0a83[_0x55b5('0x119')](_0x4fee35['id'],{'transaction':_0xfb0621});});return Promise[_0x55b5('0x5a')](_0x4877c7);})[_0x55b5('0x15')](function(){if(!_0x4fee35['online'])return;var _0x187f18=_[_0x55b5('0x2c')](_0x4134b7,function(_0x3f0c3a){return _0x3f0c3a[_0x55b5('0x11a')]('channel')===_0x55b5('0x11b');});var _0x5805a1=_[_0x55b5('0x36')](_0x187f18,function(_0x10b76e){return db[_0x55b5('0xab')]['upsert']({'membername':_0x4fee35[_0x55b5('0x2f')],'UserId':_0x4fee35['id'],'queue_name':_0x10b76e[_0x55b5('0x2f')],'VoiceQueueId':_0x10b76e['id'],'interface':_['isNil'](_0x4fee35['interface'])?util[_0x55b5('0xa9')](_0x55b5('0xaa'),_0x4fee35['name']):_0x4fee35[_0x55b5('0x9f')],'paused':_0x4fee35[_0x55b5('0x9e')]||![],'penalty':_0x4fee35[_0x55b5('0xa3')]},{'transaction':_0xfb0621});});return Promise[_0x55b5('0x5a')](_0x5805a1);})['then'](function(){return db[_0x55b5('0x11c')][_0x55b5('0x85')]({'where':{'teamId':{'$in':_0x368285}}});})[_0x55b5('0x15')](function(_0x4f486e){var _0x27d7ba=_['map'](_0x4f486e,function(_0x13e664){return db['UserVoicePrefix'][_0x55b5('0x77')]({'UserId':_0x4fee35['id'],'VoicePrefixId':_0x13e664[_0x55b5('0x11d')]},{'transaction':_0xfb0621});});return Promise[_0x55b5('0x5a')](_0x27d7ba);});});})[_0x55b5('0x15')](function(){for(var _0x201736=0x0;_0x201736<_0x4134b7[_0x55b5('0x53')];_0x201736++){var _0x342aad=_0x4134b7[_0x201736][_0x55b5('0x11a')](_0x55b5('0x9b'));var _0x145013=_0x342aad+_0x55b5('0xaf');socket[_0x55b5('0x27')]('user'+_0x342aad+'Queue:save',{'UserId':_0x4de5da,['queueField']:_0x4134b7[_0x201736]['id']});}})[_0x55b5('0x15')](respondWithStatusCode(_0x1fe7cf,null))[_0x55b5('0x1f')](APIHandleError(_0x1fe7cf));};exports[_0x55b5('0x11e')]=function(_0x15f135,_0x77a72e){var _0x156bb8=_0x15f135[_0x55b5('0x4c')]['id'];var _0x445b61=null;if(_0x15f135['query'][_0x55b5('0x5f')]){_0x445b61=_[_0x55b5('0xae')](_0x15f135[_0x55b5('0x3e')][_0x55b5('0x5f')])?_0x15f135[_0x55b5('0x3e')]['ids']:[_0x15f135[_0x55b5('0x3e')][_0x55b5('0x5f')]];}var _0x8b743b=[];return Promise[_0x55b5('0x101')]()[_0x55b5('0x15')](function(){if(!_0x445b61)throw new APIBadRequestError(_0x55b5('0x11f'));})['then'](function(){return db['User']['findOne']({'where':{'id':_0x156bb8}});})[_0x55b5('0x15')](function(_0x5b103b){if(!_0x5b103b)throw new APINotFoundError(util[_0x55b5('0xa9')]('User\x20with\x20id\x20%s\x20not\x20found',_0x15f135[_0x55b5('0x4c')]['id']));return db[_0x55b5('0x66')][_0x55b5('0x116')](function(_0x3fbe3e){return _0x5b103b['removeTeams'](_0x445b61,{'transaction':_0x3fbe3e})[_0x55b5('0x15')](function(){return db[_0x55b5('0x111')]['findAll']({'where':{'id':{'$in':_0x445b61}}});})[_0x55b5('0x15')](function(_0x3bf6cf){var _0x57cac4=_[_0x55b5('0x36')](_0x3bf6cf,function(_0x27e1c8){return _0x27e1c8[_0x55b5('0x117')]();});return Promise[_0x55b5('0x5a')](_0x57cac4);})[_0x55b5('0x15')](function(_0x3d604e){_0x8b743b=_[_0x55b5('0x118')](_0x3d604e);var _0x3aa102=_['map'](_0x8b743b,function(_0x2b49b2){return _0x2b49b2[_0x55b5('0x120')](_0x5b103b['id'],{'transaction':_0x3fbe3e});});return Promise['all'](_0x3aa102);})[_0x55b5('0x15')](function(){if(!_0x5b103b[_0x55b5('0x9c')])return;var _0x316657=_[_0x55b5('0x2c')](_0x8b743b,function(_0x2a7cb5){return _0x2a7cb5[_0x55b5('0x11a')](_0x55b5('0x9b'))==='Voice';});var _0x1db558=_[_0x55b5('0x36')](_0x316657,function(_0x4a51e3){return db[_0x55b5('0xab')][_0x55b5('0x31')]({'where':{'VoiceQueueId':_0x4a51e3['id'],'UserId':_0x5b103b['id']},'transaction':_0x3fbe3e});});return Promise[_0x55b5('0x5a')](_0x1db558);})[_0x55b5('0x15')](function(){return db[_0x55b5('0x11c')][_0x55b5('0x85')]({'where':{'teamId':{'$in':_0x445b61}}});})[_0x55b5('0x15')](function(_0x3e8b32){var _0x31ac3e=_[_0x55b5('0x36')](_0x3e8b32,function(_0x3a9f6e){return db[_0x55b5('0x121')][_0x55b5('0x31')]({'where':{'UserId':_0x5b103b['id'],'VoicePrefixId':_0x3a9f6e['VoicePrefixId']}},{'transaction':_0x3fbe3e});});return Promise[_0x55b5('0x5a')](_0x31ac3e);});});})['then'](function(){for(var _0x2684f6=0x0;_0x2684f6<_0x8b743b['length'];_0x2684f6++){var _0x590cd1=_0x8b743b[_0x2684f6][_0x55b5('0x11a')](_0x55b5('0x9b'));var _0x2f54c5=_0x590cd1+_0x55b5('0xaf');socket[_0x55b5('0x27')]('user'+_0x590cd1+_0x55b5('0xb0'),{'UserId':_0x156bb8,['queueField']:_0x8b743b[_0x2684f6]['id']});}})[_0x55b5('0x15')](respondWithStatusCode(_0x77a72e,null))['catch'](APIHandleError(_0x77a72e));};exports[_0x55b5('0x122')]=function(_0x5b8bb1,_0x1748fa){var _0x250db9={};var _0x5ba320={};var _0x3cd02c;var _0x514cb7;return db[_0x55b5('0x3d')]['findOne']({'where':{'id':_0x5b8bb1[_0x55b5('0x4c')]['id']}})[_0x55b5('0x15')](handleEntityNotFound(_0x1748fa,null))['then'](function(_0x4baf70){if(_0x4baf70){_0x3cd02c=_0x4baf70;_0x5ba320['model']=_[_0x55b5('0x4f')](db['CmList'][_0x55b5('0x50')]);_0x5ba320[_0x55b5('0x3e')]=_[_0x55b5('0x4f')](_0x5b8bb1[_0x55b5('0x3e')]);_0x5ba320[_0x55b5('0x51')]=_[_0x55b5('0xca')](_0x5ba320['model'],_0x5ba320['query']);_0x250db9[_0x55b5('0x42')]=_[_0x55b5('0xca')](_0x5ba320[_0x55b5('0x4d')],qs[_0x55b5('0x52')](_0x5b8bb1[_0x55b5('0x3e')]['fields']));_0x250db9[_0x55b5('0x42')]=_0x250db9[_0x55b5('0x42')][_0x55b5('0x53')]?_0x250db9['attributes']:_0x5ba320[_0x55b5('0x4d')];_0x250db9[_0x55b5('0xcb')]=qs[_0x55b5('0xcc')](_0x5b8bb1['query'][_0x55b5('0xcc')]);_0x250db9[_0x55b5('0xcf')]=qs['filters'](_[_0x55b5('0xcd')](_0x5b8bb1['query'],_0x5ba320[_0x55b5('0x51')]));if(_0x5b8bb1['query'][_0x55b5('0x2c')]){_0x250db9[_0x55b5('0xcf')]=_['merge'](_0x250db9[_0x55b5('0xcf')],{'$or':_['map'](_0x250db9['attributes'],function(_0x52166b){var _0x1b7072={};_0x1b7072[_0x52166b]={'$like':'%'+_0x5b8bb1[_0x55b5('0x3e')][_0x55b5('0x2c')]+'%'};return _0x1b7072;})});}_0x250db9=_['merge']({},_0x250db9,_0x5b8bb1[_0x55b5('0x55')]);return _0x3cd02c[_0x55b5('0x122')](_0x250db9);}})[_0x55b5('0x15')](function(_0x10043e){if(_0x10043e){_0x514cb7=_0x10043e[_0x55b5('0x53')];if(!_0x5b8bb1[_0x55b5('0x3e')][_0x55b5('0xd0')](_0x55b5('0xd6'))){_0x250db9[_0x55b5('0x22')]=qs[_0x55b5('0x22')](_0x5b8bb1['query'][_0x55b5('0x22')]);_0x250db9[_0x55b5('0x20')]=qs['offset'](_0x5b8bb1['query'][_0x55b5('0x20')]);}return _0x3cd02c['getLists'](_0x250db9);}})[_0x55b5('0x15')](function(_0x3d0622){if(_0x3d0622){return _0x3d0622?{'count':_0x514cb7,'rows':_0x3d0622}:null;}})[_0x55b5('0x15')](respondWithResult(_0x1748fa,null))[_0x55b5('0x1f')](handleError(_0x1748fa,null));};exports['getAgents']=function(_0x5f3153,_0x518fac){var _0x11124e={};var _0x329edd={};var _0x82ccd9;return db[_0x55b5('0x3d')][_0x55b5('0x93')]({'where':{'id':_0x5f3153[_0x55b5('0x4c')]['id']}})[_0x55b5('0x15')](handleEntityNotFound(_0x518fac,null))[_0x55b5('0x15')](function(_0x2f124d){if(_0x2f124d){_0x82ccd9=_0x2f124d;_0x329edd['model']=_[_0x55b5('0x4f')](db[_0x55b5('0x3d')][_0x55b5('0x50')]);_0x329edd[_0x55b5('0x3e')]=_[_0x55b5('0x4f')](_0x5f3153[_0x55b5('0x3e')]);_0x329edd[_0x55b5('0x51')]=_['intersection'](_0x329edd['model'],_0x329edd[_0x55b5('0x3e')]);_0x11124e[_0x55b5('0x42')]=_[_0x55b5('0xca')](_0x329edd[_0x55b5('0x4d')],qs[_0x55b5('0x52')](_0x5f3153[_0x55b5('0x3e')][_0x55b5('0x52')]));_0x11124e['attributes']=_0x11124e[_0x55b5('0x42')]['length']?_0x11124e[_0x55b5('0x42')]:_0x329edd['model'];_0x11124e[_0x55b5('0xcb')]=qs['sort'](_0x5f3153[_0x55b5('0x3e')][_0x55b5('0xcc')]);_0x11124e[_0x55b5('0xcf')]=qs['filters'](_[_0x55b5('0xcd')](_0x5f3153[_0x55b5('0x3e')],_0x329edd['filters']));if(_0x5f3153[_0x55b5('0x3e')][_0x55b5('0x2c')]){_0x11124e[_0x55b5('0xcf')]=_[_0x55b5('0xce')](_0x11124e['where'],{'$or':_[_0x55b5('0x36')](_0x11124e['attributes'],function(_0x359fc9){var _0x41cb8e={};_0x41cb8e[_0x359fc9]={'$like':'%'+_0x5f3153[_0x55b5('0x3e')][_0x55b5('0x2c')]+'%'};return _0x41cb8e;})});}_0x11124e['model']=db[_0x55b5('0x3d')];_0x11124e['as']=_0x55b5('0x2b');_0x11124e=_[_0x55b5('0xce')]({},_0x11124e,_0x5f3153[_0x55b5('0x55')]);return _0x82ccd9[_0x55b5('0x123')]({'include':[_0x11124e]});}})['then'](function(_0x3b9494){if(_0x3b9494){var _0x3df3fa={},_0xccf7fd=[];for(var _0x28cfa9=0x0;_0x28cfa9<_0x3b9494['length'];_0x28cfa9+=0x1){for(var _0x3cb6c4=0x0,_0x3d5bd3;_0x3cb6c4<_0x3b9494[_0x28cfa9][_0x55b5('0x2b')][_0x55b5('0x53')];_0x3cb6c4+=0x1){_0x3d5bd3=_0x3b9494[_0x28cfa9][_0x55b5('0x2b')][_0x3cb6c4][_0x55b5('0xa8')]({'plain':!![]});_0x3df3fa[_0x3d5bd3['id']]=_0x3d5bd3;}}_0x3df3fa=_[_0x55b5('0x124')](_0x3df3fa);for(var _0x33ca0d=qs[_0x55b5('0x20')](_0x5f3153[_0x55b5('0x3e')]['offset']);_0x33ca0d<_0x3df3fa['length']&&_0xccf7fd[_0x55b5('0x53')]<qs[_0x55b5('0x22')](_0x5f3153[_0x55b5('0x3e')][_0x55b5('0x22')]);_0x33ca0d+=0x1){if(_0x3df3fa[_0x33ca0d]){_0xccf7fd[_0x55b5('0x43')](_0x3df3fa[_0x33ca0d]);}}return{'count':_0x3df3fa[_0x55b5('0x53')],'rows':_0xccf7fd};}})[_0x55b5('0x15')](respondWithResult(_0x518fac,null))[_0x55b5('0x1f')](handleError(_0x518fac,null));};exports[_0x55b5('0x31')]=function(_0x1f38d5,_0x899058){if(_0x1f38d5[_0x55b5('0x78')]['id']==_0x1f38d5[_0x55b5('0x4c')]['id']){return _0x899058['status'](0x1f4)[_0x55b5('0x125')]({'message':_0x55b5('0x126')});}return db[_0x55b5('0x3d')][_0x55b5('0x56')]({'where':{'id':_0x1f38d5['params']['id']}})[_0x55b5('0x15')](handleEntityNotFound(_0x899058,null))[_0x55b5('0x15')](removeEntity(_0x899058,null))['catch'](handleError(_0x899058,null));};exports[_0x55b5('0x127')]=function(_0x1c84af,_0x152502){return db[_0x55b5('0x3d')][_0x55b5('0x56')]({'where':{'id':_0x1c84af['params']['id']}})[_0x55b5('0x15')](handleEntityNotFound(_0x152502,null))[_0x55b5('0x15')](function(_0x80bc56){if(_0x80bc56){return _0x80bc56[_0x55b5('0x127')](_0x1c84af['body'][_0x55b5('0x5f')],_[_0x55b5('0x5e')](_0x1c84af[_0x55b5('0x5b')],[_0x55b5('0x5f'),'id'])||{})[_0x55b5('0xa4')](function(){for(var _0x398132=0x0;_0x398132<_0x1c84af[_0x55b5('0x5b')]['ids']['length'];_0x398132+=0x1){socket[_0x55b5('0x27')](_0x55b5('0x128'),{'ChatInteractionId':Number(_0x1c84af[_0x55b5('0x5b')][_0x55b5('0x5f')][_0x398132]),'UserId':Number(_0x1c84af[_0x55b5('0x4c')]['id'])});}return _0x1c84af[_0x55b5('0x5b')]['ids'];});}})[_0x55b5('0x15')](respondWithResult(_0x152502,null))[_0x55b5('0x1f')](handleError(_0x152502,null));};exports[_0x55b5('0x129')]=function(_0x23c3b0,_0x13a5f5){return db[_0x55b5('0x3d')][_0x55b5('0x56')]({'where':{'id':_0x23c3b0['params']['id']}})[_0x55b5('0x15')](handleEntityNotFound(_0x13a5f5,null))[_0x55b5('0x15')](function(_0x463d48){if(_0x463d48){return _0x463d48[_0x55b5('0x129')](_0x23c3b0[_0x55b5('0x3e')]['ids'])[_0x55b5('0x15')](function(){if(_['isArray'](_0x23c3b0['query'][_0x55b5('0x5f')])){for(var _0x35532f=0x0;_0x35532f<_0x23c3b0['query']['ids'][_0x55b5('0x53')];_0x35532f+=0x1){socket[_0x55b5('0x27')]('user_has_chat_interactions:remove',{'ChatInteractionId':Number(_0x23c3b0[_0x55b5('0x3e')][_0x55b5('0x5f')][_0x35532f]),'UserId':Number(_0x23c3b0[_0x55b5('0x4c')]['id'])});}}else{socket[_0x55b5('0x27')](_0x55b5('0x12a'),{'ChatInteractionId':Number(_0x23c3b0['query'][_0x55b5('0x5f')]),'UserId':Number(_0x23c3b0[_0x55b5('0x4c')]['id'])});}});}})['then'](respondWithStatusCode(_0x13a5f5,null))[_0x55b5('0x1f')](handleError(_0x13a5f5,null));};exports[_0x55b5('0x12b')]=function(_0x1e7e6e,_0x4c0c65){return db[_0x55b5('0x3d')][_0x55b5('0x56')]({'where':{'id':_0x1e7e6e[_0x55b5('0x4c')]['id']}})[_0x55b5('0x15')](handleEntityNotFound(_0x4c0c65,null))[_0x55b5('0x15')](function(_0x5bdbe6){if(_0x5bdbe6){return _0x5bdbe6[_0x55b5('0x12b')](_0x1e7e6e['body'][_0x55b5('0x5f')],_[_0x55b5('0x5e')](_0x1e7e6e[_0x55b5('0x5b')],[_0x55b5('0x5f'),'id'])||{})[_0x55b5('0xa4')](function(){for(var _0x55e2bc=0x0;_0x55e2bc<_0x1e7e6e[_0x55b5('0x5b')][_0x55b5('0x5f')]['length'];_0x55e2bc+=0x1){socket['emit'](_0x55b5('0x12c'),{'MailInteractionId':Number(_0x1e7e6e[_0x55b5('0x5b')][_0x55b5('0x5f')][_0x55e2bc]),'UserId':Number(_0x1e7e6e[_0x55b5('0x4c')]['id'])});}return _0x1e7e6e[_0x55b5('0x5b')]['ids'];});}})[_0x55b5('0x15')](respondWithResult(_0x4c0c65,null))['catch'](handleError(_0x4c0c65,null));};exports[_0x55b5('0x12d')]=function(_0x3b72c6,_0xda43bf){return db[_0x55b5('0x3d')][_0x55b5('0x56')]({'where':{'id':_0x3b72c6[_0x55b5('0x4c')]['id']}})['then'](handleEntityNotFound(_0xda43bf,null))[_0x55b5('0x15')](function(_0x543589){if(_0x543589){return _0x543589[_0x55b5('0x12d')](_0x3b72c6['query'][_0x55b5('0x5f')])[_0x55b5('0x15')](function(){if(_[_0x55b5('0xae')](_0x3b72c6['query']['ids'])){for(var _0xbb7cf0=0x0;_0xbb7cf0<_0x3b72c6[_0x55b5('0x3e')][_0x55b5('0x5f')][_0x55b5('0x53')];_0xbb7cf0+=0x1){socket[_0x55b5('0x27')](_0x55b5('0x12e'),{'MailInteractionId':Number(_0x3b72c6[_0x55b5('0x3e')][_0x55b5('0x5f')][_0xbb7cf0]),'UserId':Number(_0x3b72c6['params']['id'])});}}else{socket['emit'](_0x55b5('0x12e'),{'MailInteractionId':Number(_0x3b72c6[_0x55b5('0x3e')][_0x55b5('0x5f')]),'UserId':Number(_0x3b72c6['params']['id'])});}});}})[_0x55b5('0x15')](respondWithStatusCode(_0xda43bf,null))[_0x55b5('0x1f')](handleError(_0xda43bf,null));};exports[_0x55b5('0x12f')]=function(_0x4e44d1,_0x426c88){return db['User'][_0x55b5('0x56')]({'where':{'id':_0x4e44d1[_0x55b5('0x4c')]['id']}})[_0x55b5('0x15')](handleEntityNotFound(_0x426c88,null))[_0x55b5('0x15')](function(_0x47d098){if(_0x47d098){return _0x47d098[_0x55b5('0x12f')](_0x4e44d1[_0x55b5('0x5b')][_0x55b5('0x5f')],_[_0x55b5('0x5e')](_0x4e44d1[_0x55b5('0x5b')],[_0x55b5('0x5f'),'id'])||{})[_0x55b5('0xa4')](function(){for(var _0x455176=0x0;_0x455176<_0x4e44d1[_0x55b5('0x5b')][_0x55b5('0x5f')][_0x55b5('0x53')];_0x455176+=0x1){socket[_0x55b5('0x27')](_0x55b5('0x130'),{'FaxInteractionId':Number(_0x4e44d1[_0x55b5('0x5b')][_0x55b5('0x5f')][_0x455176]),'UserId':Number(_0x4e44d1['params']['id'])});}return _0x4e44d1['body']['ids'];});}})[_0x55b5('0x15')](respondWithResult(_0x426c88,null))['catch'](handleError(_0x426c88,null));};exports[_0x55b5('0x131')]=function(_0xd85214,_0x18a2e7){return db[_0x55b5('0x3d')][_0x55b5('0x56')]({'where':{'id':_0xd85214['params']['id']}})[_0x55b5('0x15')](handleEntityNotFound(_0x18a2e7,null))[_0x55b5('0x15')](function(_0x33372e){if(_0x33372e){return _0x33372e[_0x55b5('0x131')](_0xd85214[_0x55b5('0x3e')][_0x55b5('0x5f')])[_0x55b5('0x15')](function(){if(_[_0x55b5('0xae')](_0xd85214[_0x55b5('0x3e')][_0x55b5('0x5f')])){for(var _0x46a68b=0x0;_0x46a68b<_0xd85214[_0x55b5('0x3e')][_0x55b5('0x5f')][_0x55b5('0x53')];_0x46a68b+=0x1){socket[_0x55b5('0x27')](_0x55b5('0x132'),{'FaxInteractionId':Number(_0xd85214[_0x55b5('0x3e')]['ids'][_0x46a68b]),'UserId':Number(_0xd85214[_0x55b5('0x4c')]['id'])});}}else{socket[_0x55b5('0x27')](_0x55b5('0x132'),{'FaxInteractionId':Number(_0xd85214[_0x55b5('0x3e')][_0x55b5('0x5f')]),'UserId':Number(_0xd85214['params']['id'])});}});}})[_0x55b5('0x15')](respondWithStatusCode(_0x18a2e7,null))[_0x55b5('0x1f')](handleError(_0x18a2e7,null));};exports[_0x55b5('0x133')]=function(_0x4ef042,_0x142087){return db[_0x55b5('0x3d')][_0x55b5('0x56')]({'where':{'id':_0x4ef042[_0x55b5('0x4c')]['id']}})[_0x55b5('0x15')](handleEntityNotFound(_0x142087,null))[_0x55b5('0x15')](function(_0x5e5a70){if(_0x5e5a70){return _0x5e5a70[_0x55b5('0x133')](_0x4ef042[_0x55b5('0x5b')][_0x55b5('0x5f')],_[_0x55b5('0x5e')](_0x4ef042[_0x55b5('0x5b')],[_0x55b5('0x5f'),'id'])||{})[_0x55b5('0xa4')](function(){for(var _0x21e2c1=0x0;_0x21e2c1<_0x4ef042[_0x55b5('0x5b')]['ids'][_0x55b5('0x53')];_0x21e2c1+=0x1){socket[_0x55b5('0x27')](_0x55b5('0x134'),{'SmsInteractionId':Number(_0x4ef042[_0x55b5('0x5b')][_0x55b5('0x5f')][_0x21e2c1]),'UserId':Number(_0x4ef042[_0x55b5('0x4c')]['id'])});}return _0x4ef042[_0x55b5('0x5b')][_0x55b5('0x5f')];});}})['then'](respondWithResult(_0x142087,null))[_0x55b5('0x1f')](handleError(_0x142087,null));};exports['removeSmsInteractions']=function(_0x86e0f9,_0x15c3e3){return db[_0x55b5('0x3d')][_0x55b5('0x56')]({'where':{'id':_0x86e0f9[_0x55b5('0x4c')]['id']}})[_0x55b5('0x15')](handleEntityNotFound(_0x15c3e3,null))[_0x55b5('0x15')](function(_0x4baee7){if(_0x4baee7){return _0x4baee7[_0x55b5('0x135')](_0x86e0f9[_0x55b5('0x3e')][_0x55b5('0x5f')])[_0x55b5('0x15')](function(){if(_[_0x55b5('0xae')](_0x86e0f9[_0x55b5('0x3e')][_0x55b5('0x5f')])){for(var _0x2e6194=0x0;_0x2e6194<_0x86e0f9[_0x55b5('0x3e')][_0x55b5('0x5f')]['length'];_0x2e6194+=0x1){socket[_0x55b5('0x27')](_0x55b5('0x136'),{'SmsInteractionId':Number(_0x86e0f9[_0x55b5('0x3e')][_0x55b5('0x5f')][_0x2e6194]),'UserId':Number(_0x86e0f9[_0x55b5('0x4c')]['id'])});}}else{socket[_0x55b5('0x27')]('user_has_sms_interactions:remove',{'SmsInteractionId':Number(_0x86e0f9['query'][_0x55b5('0x5f')]),'UserId':Number(_0x86e0f9[_0x55b5('0x4c')]['id'])});}});}})[_0x55b5('0x15')](respondWithStatusCode(_0x15c3e3,null))[_0x55b5('0x1f')](handleError(_0x15c3e3,null));};exports[_0x55b5('0x137')]=function(_0x33c34e,_0x154d03){return db[_0x55b5('0x3d')][_0x55b5('0x56')]({'where':{'id':_0x33c34e[_0x55b5('0x4c')]['id']}})['then'](handleEntityNotFound(_0x154d03,null))[_0x55b5('0x15')](function(_0x382c5e){if(_0x382c5e){return _0x382c5e[_0x55b5('0x137')](_0x33c34e[_0x55b5('0x5b')]['ids'],_['omit'](_0x33c34e[_0x55b5('0x5b')],[_0x55b5('0x5f'),'id'])||{})[_0x55b5('0xa4')](function(){for(var _0x334d3d=0x0;_0x334d3d<_0x33c34e[_0x55b5('0x5b')]['ids']['length'];_0x334d3d+=0x1){socket[_0x55b5('0x27')]('user_has_openchannel_interactions:save',{'OpenchannelInteractionId':Number(_0x33c34e[_0x55b5('0x5b')][_0x55b5('0x5f')][_0x334d3d]),'UserId':Number(_0x33c34e['params']['id'])});}return _0x33c34e[_0x55b5('0x5b')]['ids'];});}})[_0x55b5('0x15')](respondWithResult(_0x154d03,null))[_0x55b5('0x1f')](handleError(_0x154d03,null));};exports['removeOpenchannelInteractions']=function(_0x433e77,_0x3e1ce8){return db[_0x55b5('0x3d')][_0x55b5('0x56')]({'where':{'id':_0x433e77[_0x55b5('0x4c')]['id']}})[_0x55b5('0x15')](handleEntityNotFound(_0x3e1ce8,null))[_0x55b5('0x15')](function(_0x45bb7c){if(_0x45bb7c){return _0x45bb7c[_0x55b5('0x138')](_0x433e77[_0x55b5('0x3e')][_0x55b5('0x5f')])[_0x55b5('0x15')](function(){if(_[_0x55b5('0xae')](_0x433e77[_0x55b5('0x3e')]['ids'])){for(var _0x3007b1=0x0;_0x3007b1<_0x433e77['query'][_0x55b5('0x5f')][_0x55b5('0x53')];_0x3007b1+=0x1){socket[_0x55b5('0x27')](_0x55b5('0x139'),{'OpenchannelInteractionId':Number(_0x433e77[_0x55b5('0x3e')][_0x55b5('0x5f')][_0x3007b1]),'UserId':Number(_0x433e77[_0x55b5('0x4c')]['id'])});}}else{socket['emit']('user_has_openchannel_interactions:remove',{'OpenchannelInteractionId':Number(_0x433e77[_0x55b5('0x3e')][_0x55b5('0x5f')]),'UserId':Number(_0x433e77['params']['id'])});}});}})['then'](respondWithStatusCode(_0x3e1ce8,null))[_0x55b5('0x1f')](handleError(_0x3e1ce8,null));};exports[_0x55b5('0x13a')]=function(_0x4aaaae,_0x2314e){return db[_0x55b5('0x3d')][_0x55b5('0x56')]({'where':{'id':_0x4aaaae[_0x55b5('0x4c')]['id']}})[_0x55b5('0x15')](handleEntityNotFound(_0x2314e,null))[_0x55b5('0x15')](function(_0x136242){if(_0x136242){return _0x136242['addWhatsappInteractions'](_0x4aaaae['body'][_0x55b5('0x5f')],_[_0x55b5('0x5e')](_0x4aaaae[_0x55b5('0x5b')],[_0x55b5('0x5f'),'id'])||{})[_0x55b5('0xa4')](function(){for(var _0x35dbc4=0x0;_0x35dbc4<_0x4aaaae[_0x55b5('0x5b')][_0x55b5('0x5f')]['length'];_0x35dbc4+=0x1){socket['emit'](_0x55b5('0x13b'),{'WhatsappInteractionId':Number(_0x4aaaae['body']['ids'][_0x35dbc4]),'UserId':Number(_0x4aaaae['params']['id'])});}return _0x4aaaae[_0x55b5('0x5b')][_0x55b5('0x5f')];});}})['then'](respondWithResult(_0x2314e,null))[_0x55b5('0x1f')](handleError(_0x2314e,null));};exports[_0x55b5('0x13c')]=function(_0x5e13af,_0x35ca81){return db['User'][_0x55b5('0x56')]({'where':{'id':_0x5e13af[_0x55b5('0x4c')]['id']}})[_0x55b5('0x15')](handleEntityNotFound(_0x35ca81,null))[_0x55b5('0x15')](function(_0x343fb7){if(_0x343fb7){return _0x343fb7[_0x55b5('0x13c')](_0x5e13af[_0x55b5('0x3e')]['ids']);}})[_0x55b5('0x15')](respondWithStatusCode(_0x35ca81,null))[_0x55b5('0x1f')](handleError(_0x35ca81,null));};exports[_0x55b5('0x13d')]=function(_0xaf3a40,_0x132a8d){var _0x561dbe={};var _0x4dc572={};var _0x74f68;var _0x5e1eaa;return db['User'][_0x55b5('0x93')]({'where':{'id':_0xaf3a40[_0x55b5('0x4c')]['id']}})[_0x55b5('0x15')](handleEntityNotFound(_0x132a8d,null))[_0x55b5('0x15')](function(_0xd8e2df){if(_0xd8e2df){_0x74f68=_0xd8e2df;_0x4dc572['model']=_[_0x55b5('0x4f')](db[_0x55b5('0x13e')][_0x55b5('0x50')]);_0x4dc572['query']=_['keys'](_0xaf3a40[_0x55b5('0x3e')]);_0x4dc572[_0x55b5('0x51')]=_[_0x55b5('0xca')](_0x4dc572[_0x55b5('0x4d')],_0x4dc572[_0x55b5('0x3e')]);_0x561dbe[_0x55b5('0x42')]=_[_0x55b5('0xca')](_0x4dc572[_0x55b5('0x4d')],qs['fields'](_0xaf3a40[_0x55b5('0x3e')][_0x55b5('0x52')]));_0x561dbe[_0x55b5('0x42')]=_0x561dbe[_0x55b5('0x42')]['length']?_0x561dbe[_0x55b5('0x42')]:_0x4dc572[_0x55b5('0x4d')];_0x561dbe[_0x55b5('0xcb')]=qs[_0x55b5('0xcc')](_0xaf3a40['query']['sort']);_0x561dbe['where']=qs[_0x55b5('0x51')](_[_0x55b5('0xcd')](_0xaf3a40[_0x55b5('0x3e')],_0x4dc572[_0x55b5('0x51')]));if(_0xaf3a40[_0x55b5('0x3e')][_0x55b5('0x2c')]){_0x561dbe['where']=_[_0x55b5('0xce')](_0x561dbe[_0x55b5('0xcf')],{'$or':_[_0x55b5('0x36')](_0x561dbe[_0x55b5('0x42')],function(_0x567c07){var _0x24357a={};_0x24357a[_0x567c07]={'$like':'%'+_0xaf3a40[_0x55b5('0x3e')][_0x55b5('0x2c')]+'%'};return _0x24357a;})});}_0x561dbe=_[_0x55b5('0xce')]({},_0x561dbe,_0xaf3a40[_0x55b5('0x55')]);return _0x74f68[_0x55b5('0x13d')](_0x561dbe);}})['then'](function(_0x5aae24){if(_0x5aae24){_0x5e1eaa=_0x5aae24[_0x55b5('0x53')];if(!_0xaf3a40[_0x55b5('0x3e')][_0x55b5('0xd0')]('nolimit')){_0x561dbe[_0x55b5('0x22')]=qs['limit'](_0xaf3a40[_0x55b5('0x3e')]['limit']);_0x561dbe[_0x55b5('0x20')]=qs[_0x55b5('0x20')](_0xaf3a40[_0x55b5('0x3e')][_0x55b5('0x20')]);}return _0x74f68[_0x55b5('0x13d')](_0x561dbe);}})[_0x55b5('0x15')](function(_0x1169af){if(_0x1169af){return _0x1169af?{'count':_0x5e1eaa,'rows':_0x1169af}:null;}})[_0x55b5('0x15')](respondWithResult(_0x132a8d,null))[_0x55b5('0x1f')](handleError(_0x132a8d,null));};exports[_0x55b5('0x13f')]=function(_0x376853,_0x375445){var _0x434446={};var _0xa81aa5={};var _0x27a78e;var _0x37e229;return db[_0x55b5('0x3d')]['findOne']({'where':{'id':_0x376853[_0x55b5('0x4c')]['id']}})[_0x55b5('0x15')](handleEntityNotFound(_0x375445,null))['then'](function(_0x2666e1){if(_0x2666e1){_0x27a78e=_0x2666e1;_0xa81aa5[_0x55b5('0x4d')]=_[_0x55b5('0x4f')](db[_0x55b5('0x140')][_0x55b5('0x50')]);_0xa81aa5['query']=_['keys'](_0x376853[_0x55b5('0x3e')]);_0xa81aa5[_0x55b5('0x51')]=_[_0x55b5('0xca')](_0xa81aa5[_0x55b5('0x4d')],_0xa81aa5[_0x55b5('0x3e')]);_0x434446[_0x55b5('0x42')]=_[_0x55b5('0xca')](_0xa81aa5[_0x55b5('0x4d')],qs[_0x55b5('0x52')](_0x376853[_0x55b5('0x3e')][_0x55b5('0x52')]));_0x434446[_0x55b5('0x42')]=_0x434446[_0x55b5('0x42')][_0x55b5('0x53')]?_0x434446['attributes']:_0xa81aa5['model'];_0x434446[_0x55b5('0xcb')]=qs[_0x55b5('0xcc')](_0x376853['query'][_0x55b5('0xcc')]);_0x434446[_0x55b5('0xcf')]=qs['filters'](_[_0x55b5('0xcd')](_0x376853[_0x55b5('0x3e')],_0xa81aa5['filters']));if(_0x376853[_0x55b5('0x3e')][_0x55b5('0x2c')]){_0x434446[_0x55b5('0xcf')]=_['merge'](_0x434446['where'],{'$or':_[_0x55b5('0x36')](_0x434446[_0x55b5('0x42')],function(_0x158d50){var _0x2cbed1={};_0x2cbed1[_0x158d50]={'$like':'%'+_0x376853['query'][_0x55b5('0x2c')]+'%'};return _0x2cbed1;})});}_0x434446=_['merge']({},_0x434446,_0x376853['options']);return _0x27a78e['getFaxAccounts'](_0x434446);}})[_0x55b5('0x15')](function(_0x1977b1){if(_0x1977b1){_0x37e229=_0x1977b1[_0x55b5('0x53')];if(!_0x376853['query']['hasOwnProperty']('nolimit')){_0x434446[_0x55b5('0x22')]=qs['limit'](_0x376853[_0x55b5('0x3e')][_0x55b5('0x22')]);_0x434446[_0x55b5('0x20')]=qs[_0x55b5('0x20')](_0x376853[_0x55b5('0x3e')][_0x55b5('0x20')]);}return _0x27a78e[_0x55b5('0x13f')](_0x434446);}})[_0x55b5('0x15')](function(_0x54ebde){if(_0x54ebde){return _0x54ebde?{'count':_0x37e229,'rows':_0x54ebde}:null;}})[_0x55b5('0x15')](respondWithResult(_0x375445,null))[_0x55b5('0x1f')](handleError(_0x375445,null));};exports[_0x55b5('0x141')]=function(_0x2f753d,_0x208201){return db[_0x55b5('0x3d')][_0x55b5('0x56')]({'where':{'id':_0x2f753d[_0x55b5('0x4c')]['id']}})[_0x55b5('0x15')](handleEntityNotFound(_0x208201,null))['then'](function(_0x5d687f){if(_0x5d687f){return _0x5d687f['addFaxAccounts'](_0x2f753d['body'][_0x55b5('0x5f')],_['omit'](_0x2f753d['body'],[_0x55b5('0x5f'),'id'])||{});}})[_0x55b5('0x15')](respondWithResult(_0x208201,null))[_0x55b5('0x1f')](handleError(_0x208201,null));};exports[_0x55b5('0x142')]=function(_0x143c5c,_0x2dc628){return db[_0x55b5('0x3d')][_0x55b5('0x56')]({'where':{'id':_0x143c5c[_0x55b5('0x4c')]['id']}})[_0x55b5('0x15')](handleEntityNotFound(_0x2dc628,null))[_0x55b5('0x15')](function(_0x5a73de){if(_0x5a73de){return _0x5a73de[_0x55b5('0x142')](_0x143c5c[_0x55b5('0x3e')]['ids']);}})[_0x55b5('0x15')](respondWithStatusCode(_0x2dc628,null))[_0x55b5('0x1f')](handleError(_0x2dc628,null));};exports['getMailAccounts']=function(_0x346550,_0x2ea9f9){var _0x2a468d={};var _0x28e66f={};var _0x340300;var _0x295a3b;return db[_0x55b5('0x3d')][_0x55b5('0x93')]({'where':{'id':_0x346550[_0x55b5('0x4c')]['id']}})[_0x55b5('0x15')](handleEntityNotFound(_0x2ea9f9,null))[_0x55b5('0x15')](function(_0x4035af){if(_0x4035af){_0x340300=_0x4035af;_0x28e66f[_0x55b5('0x4d')]=_[_0x55b5('0x4f')](db[_0x55b5('0x143')]['rawAttributes']);_0x28e66f['query']=_[_0x55b5('0x4f')](_0x346550[_0x55b5('0x3e')]);_0x28e66f[_0x55b5('0x51')]=_['intersection'](_0x28e66f[_0x55b5('0x4d')],_0x28e66f[_0x55b5('0x3e')]);_0x2a468d[_0x55b5('0x42')]=_['intersection'](_0x28e66f['model'],qs[_0x55b5('0x52')](_0x346550['query'][_0x55b5('0x52')]));_0x2a468d[_0x55b5('0x42')]=_0x2a468d[_0x55b5('0x42')][_0x55b5('0x53')]?_0x2a468d[_0x55b5('0x42')]:_0x28e66f[_0x55b5('0x4d')];_0x2a468d[_0x55b5('0xcb')]=qs[_0x55b5('0xcc')](_0x346550[_0x55b5('0x3e')][_0x55b5('0xcc')]);_0x2a468d[_0x55b5('0xcf')]=qs['filters'](_[_0x55b5('0xcd')](_0x346550[_0x55b5('0x3e')],_0x28e66f[_0x55b5('0x51')]));if(_0x346550['query']['filter']){_0x2a468d[_0x55b5('0xcf')]=_[_0x55b5('0xce')](_0x2a468d['where'],{'$or':_[_0x55b5('0x36')](_0x2a468d[_0x55b5('0x42')],function(_0x2d2e0d){var _0x361ec8={};_0x361ec8[_0x2d2e0d]={'$like':'%'+_0x346550[_0x55b5('0x3e')][_0x55b5('0x2c')]+'%'};return _0x361ec8;})});}_0x2a468d=_[_0x55b5('0xce')]({},_0x2a468d,_0x346550[_0x55b5('0x55')]);return _0x340300[_0x55b5('0x144')](_0x2a468d);}})[_0x55b5('0x15')](function(_0x14f97f){if(_0x14f97f){_0x295a3b=_0x14f97f[_0x55b5('0x53')];if(!_0x346550[_0x55b5('0x3e')][_0x55b5('0xd0')]('nolimit')){_0x2a468d[_0x55b5('0x22')]=qs['limit'](_0x346550[_0x55b5('0x3e')]['limit']);_0x2a468d[_0x55b5('0x20')]=qs[_0x55b5('0x20')](_0x346550['query'][_0x55b5('0x20')]);}return _0x340300[_0x55b5('0x144')](_0x2a468d);}})[_0x55b5('0x15')](function(_0x45214d){if(_0x45214d){return _0x45214d?{'count':_0x295a3b,'rows':_0x45214d}:null;}})[_0x55b5('0x15')](respondWithResult(_0x2ea9f9,null))['catch'](handleError(_0x2ea9f9,null));};exports[_0x55b5('0x145')]=function(_0xc767eb,_0x49f522){return db[_0x55b5('0x3d')][_0x55b5('0x56')]({'where':{'id':_0xc767eb[_0x55b5('0x4c')]['id']}})['then'](handleEntityNotFound(_0x49f522,null))[_0x55b5('0x15')](function(_0x538e59){if(_0x538e59){return _0x538e59[_0x55b5('0x145')](_0xc767eb['body'][_0x55b5('0x5f')],_[_0x55b5('0x5e')](_0xc767eb[_0x55b5('0x5b')],[_0x55b5('0x5f'),'id'])||{});}})[_0x55b5('0x15')](respondWithResult(_0x49f522,null))[_0x55b5('0x1f')](handleError(_0x49f522,null));};exports['removeMailAccounts']=function(_0x21d10e,_0x2c863d){return db[_0x55b5('0x3d')]['find']({'where':{'id':_0x21d10e[_0x55b5('0x4c')]['id']}})[_0x55b5('0x15')](handleEntityNotFound(_0x2c863d,null))[_0x55b5('0x15')](function(_0x2b6333){if(_0x2b6333){return _0x2b6333['removeMailAccounts'](_0x21d10e[_0x55b5('0x3e')][_0x55b5('0x5f')]);}})[_0x55b5('0x15')](respondWithStatusCode(_0x2c863d,null))['catch'](handleError(_0x2c863d,null));};exports[_0x55b5('0x146')]=function(_0x510607,_0x29ef99){var _0x13fa1c={};var _0x2b2cc2={};var _0x279542;var _0xc92233;return db[_0x55b5('0x3d')][_0x55b5('0x93')]({'where':{'id':_0x510607[_0x55b5('0x4c')]['id']}})[_0x55b5('0x15')](handleEntityNotFound(_0x29ef99,null))['then'](function(_0x5652ac){if(_0x5652ac){_0x279542=_0x5652ac;_0x2b2cc2['model']=_[_0x55b5('0x4f')](db['OpenchannelAccount'][_0x55b5('0x50')]);_0x2b2cc2[_0x55b5('0x3e')]=_[_0x55b5('0x4f')](_0x510607[_0x55b5('0x3e')]);_0x2b2cc2[_0x55b5('0x51')]=_[_0x55b5('0xca')](_0x2b2cc2[_0x55b5('0x4d')],_0x2b2cc2[_0x55b5('0x3e')]);_0x13fa1c[_0x55b5('0x42')]=_['intersection'](_0x2b2cc2[_0x55b5('0x4d')],qs['fields'](_0x510607[_0x55b5('0x3e')][_0x55b5('0x52')]));_0x13fa1c[_0x55b5('0x42')]=_0x13fa1c[_0x55b5('0x42')][_0x55b5('0x53')]?_0x13fa1c[_0x55b5('0x42')]:_0x2b2cc2[_0x55b5('0x4d')];_0x13fa1c[_0x55b5('0xcb')]=qs['sort'](_0x510607[_0x55b5('0x3e')][_0x55b5('0xcc')]);_0x13fa1c[_0x55b5('0xcf')]=qs[_0x55b5('0x51')](_[_0x55b5('0xcd')](_0x510607[_0x55b5('0x3e')],_0x2b2cc2[_0x55b5('0x51')]));if(_0x510607[_0x55b5('0x3e')]['filter']){_0x13fa1c[_0x55b5('0xcf')]=_['merge'](_0x13fa1c[_0x55b5('0xcf')],{'$or':_['map'](_0x13fa1c[_0x55b5('0x42')],function(_0x31ce98){var _0x8922ef={};_0x8922ef[_0x31ce98]={'$like':'%'+_0x510607[_0x55b5('0x3e')][_0x55b5('0x2c')]+'%'};return _0x8922ef;})});}_0x13fa1c=_[_0x55b5('0xce')]({},_0x13fa1c,_0x510607[_0x55b5('0x55')]);return _0x279542['getOpenchannelAccounts'](_0x13fa1c);}})[_0x55b5('0x15')](function(_0x1abe3c){if(_0x1abe3c){_0xc92233=_0x1abe3c[_0x55b5('0x53')];if(!_0x510607['query'][_0x55b5('0xd0')](_0x55b5('0xd6'))){_0x13fa1c[_0x55b5('0x22')]=qs[_0x55b5('0x22')](_0x510607[_0x55b5('0x3e')]['limit']);_0x13fa1c[_0x55b5('0x20')]=qs['offset'](_0x510607['query'][_0x55b5('0x20')]);}return _0x279542[_0x55b5('0x146')](_0x13fa1c);}})[_0x55b5('0x15')](function(_0x34b9dc){if(_0x34b9dc){return _0x34b9dc?{'count':_0xc92233,'rows':_0x34b9dc}:null;}})[_0x55b5('0x15')](respondWithResult(_0x29ef99,null))[_0x55b5('0x1f')](handleError(_0x29ef99,null));};exports[_0x55b5('0x147')]=function(_0x1427ad,_0x5a5190){return db[_0x55b5('0x3d')]['find']({'where':{'id':_0x1427ad[_0x55b5('0x4c')]['id']}})[_0x55b5('0x15')](handleEntityNotFound(_0x5a5190,null))['then'](function(_0x54b778){if(_0x54b778){return _0x54b778[_0x55b5('0x147')](_0x1427ad[_0x55b5('0x5b')][_0x55b5('0x5f')],_[_0x55b5('0x5e')](_0x1427ad['body'],['ids','id'])||{});}})[_0x55b5('0x15')](respondWithResult(_0x5a5190,null))['catch'](handleError(_0x5a5190,null));};exports['removeOpenchannelAccounts']=function(_0x14d0ba,_0x4d4a04){return db[_0x55b5('0x3d')][_0x55b5('0x56')]({'where':{'id':_0x14d0ba[_0x55b5('0x4c')]['id']}})['then'](handleEntityNotFound(_0x4d4a04,null))[_0x55b5('0x15')](function(_0x100f3c){if(_0x100f3c){return _0x100f3c[_0x55b5('0x148')](_0x14d0ba[_0x55b5('0x3e')][_0x55b5('0x5f')]);}})['then'](respondWithStatusCode(_0x4d4a04,null))[_0x55b5('0x1f')](handleError(_0x4d4a04,null));};exports[_0x55b5('0x149')]=function(_0x40a626,_0x203e07){var _0xe1486a={};var _0x3061dc={};var _0x335743;var _0x2056e9;return db[_0x55b5('0x3d')][_0x55b5('0x93')]({'where':{'id':_0x40a626[_0x55b5('0x4c')]['id']}})[_0x55b5('0x15')](handleEntityNotFound(_0x203e07,null))['then'](function(_0x166a3d){if(_0x166a3d){_0x335743=_0x166a3d;_0x3061dc['model']=_[_0x55b5('0x4f')](db[_0x55b5('0x14a')][_0x55b5('0x50')]);_0x3061dc['query']=_['keys'](_0x40a626[_0x55b5('0x3e')]);_0x3061dc['filters']=_[_0x55b5('0xca')](_0x3061dc[_0x55b5('0x4d')],_0x3061dc[_0x55b5('0x3e')]);_0xe1486a['attributes']=_[_0x55b5('0xca')](_0x3061dc['model'],qs['fields'](_0x40a626['query']['fields']));_0xe1486a[_0x55b5('0x42')]=_0xe1486a['attributes'][_0x55b5('0x53')]?_0xe1486a[_0x55b5('0x42')]:_0x3061dc['model'];_0xe1486a[_0x55b5('0xcb')]=qs['sort'](_0x40a626['query']['sort']);_0xe1486a['where']=qs[_0x55b5('0x51')](_['pick'](_0x40a626[_0x55b5('0x3e')],_0x3061dc['filters']));if(_0x40a626[_0x55b5('0x3e')][_0x55b5('0x2c')]){_0xe1486a[_0x55b5('0xcf')]=_[_0x55b5('0xce')](_0xe1486a[_0x55b5('0xcf')],{'$or':_[_0x55b5('0x36')](_0xe1486a[_0x55b5('0x42')],function(_0xecf210){var _0x322d31={};_0x322d31[_0xecf210]={'$like':'%'+_0x40a626[_0x55b5('0x3e')]['filter']+'%'};return _0x322d31;})});}_0xe1486a=_[_0x55b5('0xce')]({},_0xe1486a,_0x40a626[_0x55b5('0x55')]);return _0x335743['getSmsAccounts'](_0xe1486a);}})[_0x55b5('0x15')](function(_0x30b202){if(_0x30b202){_0x2056e9=_0x30b202[_0x55b5('0x53')];if(!_0x40a626[_0x55b5('0x3e')]['hasOwnProperty']('nolimit')){_0xe1486a[_0x55b5('0x22')]=qs[_0x55b5('0x22')](_0x40a626[_0x55b5('0x3e')][_0x55b5('0x22')]);_0xe1486a[_0x55b5('0x20')]=qs['offset'](_0x40a626[_0x55b5('0x3e')][_0x55b5('0x20')]);}return _0x335743[_0x55b5('0x149')](_0xe1486a);}})[_0x55b5('0x15')](function(_0x2109b3){if(_0x2109b3){return _0x2109b3?{'count':_0x2056e9,'rows':_0x2109b3}:null;}})[_0x55b5('0x15')](respondWithResult(_0x203e07,null))[_0x55b5('0x1f')](handleError(_0x203e07,null));};exports[_0x55b5('0x14b')]=function(_0x5a8058,_0x12941d){return db[_0x55b5('0x3d')][_0x55b5('0x56')]({'where':{'id':_0x5a8058[_0x55b5('0x4c')]['id']}})[_0x55b5('0x15')](handleEntityNotFound(_0x12941d,null))[_0x55b5('0x15')](function(_0x35a136){if(_0x35a136){return _0x35a136[_0x55b5('0x14b')](_0x5a8058[_0x55b5('0x5b')]['ids'],_[_0x55b5('0x5e')](_0x5a8058[_0x55b5('0x5b')],[_0x55b5('0x5f'),'id'])||{});}})[_0x55b5('0x15')](respondWithResult(_0x12941d,null))[_0x55b5('0x1f')](handleError(_0x12941d,null));};exports[_0x55b5('0x14c')]=function(_0xb6167b,_0x38724d){return db[_0x55b5('0x3d')][_0x55b5('0x56')]({'where':{'id':_0xb6167b[_0x55b5('0x4c')]['id']}})[_0x55b5('0x15')](handleEntityNotFound(_0x38724d,null))['then'](function(_0x205119){if(_0x205119){return _0x205119[_0x55b5('0x14c')](_0xb6167b[_0x55b5('0x3e')][_0x55b5('0x5f')]);}})[_0x55b5('0x15')](respondWithStatusCode(_0x38724d,null))['catch'](handleError(_0x38724d,null));};exports[_0x55b5('0x14d')]=function(_0x516800,_0x50a536){var _0x3bb1bc={};var _0xef468c={};var _0x17e322;var _0x593472;return db[_0x55b5('0x3d')][_0x55b5('0x93')]({'where':{'id':_0x516800[_0x55b5('0x4c')]['id']}})[_0x55b5('0x15')](handleEntityNotFound(_0x50a536,null))[_0x55b5('0x15')](function(_0x41882a){if(_0x41882a){_0x17e322=_0x41882a;_0xef468c[_0x55b5('0x4d')]=_[_0x55b5('0x4f')](db['ChatWebsite'][_0x55b5('0x50')]);_0xef468c['query']=_[_0x55b5('0x4f')](_0x516800[_0x55b5('0x3e')]);_0xef468c['filters']=_[_0x55b5('0xca')](_0xef468c[_0x55b5('0x4d')],_0xef468c[_0x55b5('0x3e')]);_0x3bb1bc['attributes']=_[_0x55b5('0xca')](_0xef468c[_0x55b5('0x4d')],qs['fields'](_0x516800[_0x55b5('0x3e')][_0x55b5('0x52')]));_0x3bb1bc[_0x55b5('0x42')]=_0x3bb1bc[_0x55b5('0x42')][_0x55b5('0x53')]?_0x3bb1bc[_0x55b5('0x42')]:_0xef468c[_0x55b5('0x4d')];_0x3bb1bc[_0x55b5('0xcb')]=qs[_0x55b5('0xcc')](_0x516800['query'][_0x55b5('0xcc')]);_0x3bb1bc[_0x55b5('0xcf')]=qs[_0x55b5('0x51')](_[_0x55b5('0xcd')](_0x516800[_0x55b5('0x3e')],_0xef468c[_0x55b5('0x51')]));if(_0x516800[_0x55b5('0x3e')][_0x55b5('0x2c')]){_0x3bb1bc['where']=_[_0x55b5('0xce')](_0x3bb1bc[_0x55b5('0xcf')],{'$or':_[_0x55b5('0x36')](_0x3bb1bc['attributes'],function(_0x5e8e1d){var _0x252196={};_0x252196[_0x5e8e1d]={'$like':'%'+_0x516800[_0x55b5('0x3e')][_0x55b5('0x2c')]+'%'};return _0x252196;})});}_0x3bb1bc=_[_0x55b5('0xce')]({},_0x3bb1bc,_0x516800[_0x55b5('0x55')]);return _0x17e322['getChatWebsites'](_0x3bb1bc);}})['then'](function(_0xb35f84){if(_0xb35f84){_0x593472=_0xb35f84['length'];if(!_0x516800[_0x55b5('0x3e')]['hasOwnProperty']('nolimit')){_0x3bb1bc[_0x55b5('0x22')]=qs['limit'](_0x516800['query']['limit']);_0x3bb1bc['offset']=qs['offset'](_0x516800[_0x55b5('0x3e')][_0x55b5('0x20')]);}return _0x17e322[_0x55b5('0x14d')](_0x3bb1bc);}})[_0x55b5('0x15')](function(_0xfa7daa){if(_0xfa7daa){return _0xfa7daa?{'count':_0x593472,'rows':_0xfa7daa}:null;}})[_0x55b5('0x15')](respondWithResult(_0x50a536,null))[_0x55b5('0x1f')](handleError(_0x50a536,null));};exports[_0x55b5('0x14e')]=function(_0x49d21c,_0x11a765){return db['User'][_0x55b5('0x56')]({'where':{'id':_0x49d21c['params']['id']}})[_0x55b5('0x15')](handleEntityNotFound(_0x11a765,null))[_0x55b5('0x15')](function(_0x4426b7){if(_0x4426b7){return _0x4426b7[_0x55b5('0x14e')](_0x49d21c[_0x55b5('0x5b')][_0x55b5('0x5f')],_['omit'](_0x49d21c['body'],[_0x55b5('0x5f'),'id'])||{});}})['then'](respondWithResult(_0x11a765,null))[_0x55b5('0x1f')](handleError(_0x11a765,null));};exports[_0x55b5('0x14f')]=function(_0x3d4f39,_0x938ede){return db[_0x55b5('0x3d')][_0x55b5('0x56')]({'where':{'id':_0x3d4f39[_0x55b5('0x4c')]['id']}})[_0x55b5('0x15')](handleEntityNotFound(_0x938ede,null))[_0x55b5('0x15')](function(_0x1ee8a4){if(_0x1ee8a4){return _0x1ee8a4['removeChatWebsites'](_0x3d4f39[_0x55b5('0x3e')][_0x55b5('0x5f')]);}})[_0x55b5('0x15')](respondWithStatusCode(_0x938ede,null))[_0x55b5('0x1f')](handleError(_0x938ede,null));};exports[_0x55b5('0x150')]=function(_0x322632,_0x40f002){var _0x576325={};var _0x56f27d={};var _0x103187;var _0x803732;return db['User'][_0x55b5('0x93')]({'where':{'id':_0x322632[_0x55b5('0x4c')]['id']}})[_0x55b5('0x15')](handleEntityNotFound(_0x40f002,null))[_0x55b5('0x15')](function(_0x46bbc0){if(_0x46bbc0){_0x103187=_0x46bbc0;_0x56f27d[_0x55b5('0x4d')]=_[_0x55b5('0x4f')](db[_0x55b5('0x151')][_0x55b5('0x50')]);_0x56f27d['query']=_[_0x55b5('0x4f')](_0x322632[_0x55b5('0x3e')]);_0x56f27d[_0x55b5('0x51')]=_[_0x55b5('0xca')](_0x56f27d['model'],_0x56f27d[_0x55b5('0x3e')]);_0x576325['attributes']=_[_0x55b5('0xca')](_0x56f27d[_0x55b5('0x4d')],qs['fields'](_0x322632[_0x55b5('0x3e')][_0x55b5('0x52')]));_0x576325[_0x55b5('0x42')]=_0x576325[_0x55b5('0x42')]['length']?_0x576325['attributes']:_0x56f27d['model'];_0x576325[_0x55b5('0xcb')]=qs[_0x55b5('0xcc')](_0x322632[_0x55b5('0x3e')][_0x55b5('0xcc')]);_0x576325['where']=qs[_0x55b5('0x51')](_['pick'](_0x322632['query'],_0x56f27d['filters']));if(_0x322632['query'][_0x55b5('0x2c')]){_0x576325[_0x55b5('0xcf')]=_[_0x55b5('0xce')](_0x576325[_0x55b5('0xcf')],{'$or':_['map'](_0x576325[_0x55b5('0x42')],function(_0x5431aa){var _0x4e55fa={};_0x4e55fa[_0x5431aa]={'$like':'%'+_0x322632[_0x55b5('0x3e')]['filter']+'%'};return _0x4e55fa;})});}_0x576325=_['merge']({},_0x576325,_0x322632['options']);return _0x103187['getWhatsappAccounts'](_0x576325);}})[_0x55b5('0x15')](function(_0xab25fa){if(_0xab25fa){_0x803732=_0xab25fa[_0x55b5('0x53')];if(!_0x322632[_0x55b5('0x3e')][_0x55b5('0xd0')](_0x55b5('0xd6'))){_0x576325[_0x55b5('0x22')]=qs[_0x55b5('0x22')](_0x322632[_0x55b5('0x3e')][_0x55b5('0x22')]);_0x576325[_0x55b5('0x20')]=qs[_0x55b5('0x20')](_0x322632[_0x55b5('0x3e')][_0x55b5('0x20')]);}return _0x103187[_0x55b5('0x150')](_0x576325);}})[_0x55b5('0x15')](function(_0x2f2f04){if(_0x2f2f04){return _0x2f2f04?{'count':_0x803732,'rows':_0x2f2f04}:null;}})[_0x55b5('0x15')](respondWithResult(_0x40f002,null))['catch'](handleError(_0x40f002,null));};exports[_0x55b5('0x152')]=function(_0x896148,_0x4259a6){return db[_0x55b5('0x3d')][_0x55b5('0x56')]({'where':{'id':_0x896148['params']['id']}})[_0x55b5('0x15')](handleEntityNotFound(_0x4259a6,null))[_0x55b5('0x15')](function(_0x5e0db2){if(_0x5e0db2){return _0x5e0db2['addWhatsappAccounts'](_0x896148[_0x55b5('0x5b')]['ids'],_['omit'](_0x896148[_0x55b5('0x5b')],[_0x55b5('0x5f'),'id'])||{});}})[_0x55b5('0x15')](respondWithResult(_0x4259a6,null))[_0x55b5('0x1f')](handleError(_0x4259a6,null));};exports[_0x55b5('0x153')]=function(_0x46991c,_0x3f1cf4){return db[_0x55b5('0x3d')][_0x55b5('0x56')]({'where':{'id':_0x46991c[_0x55b5('0x4c')]['id']}})['then'](handleEntityNotFound(_0x3f1cf4,null))[_0x55b5('0x15')](function(_0x32e381){if(_0x32e381){return _0x32e381[_0x55b5('0x153')](_0x46991c[_0x55b5('0x3e')]['ids']);}})[_0x55b5('0x15')](respondWithStatusCode(_0x3f1cf4,null))[_0x55b5('0x1f')](handleError(_0x3f1cf4,null));};exports['getSquareProjects']=function(_0x3fb9dc,_0x1ff6b5){var _0x18b196={};var _0x4d5fde={};var _0x542d94;var _0x56e0f0;return db[_0x55b5('0x3d')][_0x55b5('0x93')]({'where':{'id':_0x3fb9dc[_0x55b5('0x4c')]['id']}})[_0x55b5('0x15')](handleEntityNotFound(_0x1ff6b5,null))['then'](function(_0x543d84){if(_0x543d84){_0x542d94=_0x543d84;_0x4d5fde[_0x55b5('0x4d')]=_[_0x55b5('0x4f')](db['SquareProject'][_0x55b5('0x50')]);_0x4d5fde[_0x55b5('0x3e')]=_[_0x55b5('0x4f')](_0x3fb9dc[_0x55b5('0x3e')]);_0x4d5fde[_0x55b5('0x51')]=_[_0x55b5('0xca')](_0x4d5fde[_0x55b5('0x4d')],_0x4d5fde['query']);_0x18b196[_0x55b5('0x42')]=_[_0x55b5('0xca')](_0x4d5fde[_0x55b5('0x4d')],qs[_0x55b5('0x52')](_0x3fb9dc['query']['fields']));_0x18b196[_0x55b5('0x42')]=_0x18b196[_0x55b5('0x42')][_0x55b5('0x53')]?_0x18b196[_0x55b5('0x42')]:_0x4d5fde[_0x55b5('0x4d')];_0x18b196['order']=qs[_0x55b5('0xcc')](_0x3fb9dc['query'][_0x55b5('0xcc')]);_0x18b196['where']=qs[_0x55b5('0x51')](_[_0x55b5('0xcd')](_0x3fb9dc['query'],_0x4d5fde['filters']));if(_0x3fb9dc[_0x55b5('0x3e')]['filter']){_0x18b196[_0x55b5('0xcf')]=_[_0x55b5('0xce')](_0x18b196[_0x55b5('0xcf')],{'$or':_[_0x55b5('0x36')](_0x18b196[_0x55b5('0x42')],function(_0x109ea4){var _0x19c0fd={};_0x19c0fd[_0x109ea4]={'$like':'%'+_0x3fb9dc[_0x55b5('0x3e')][_0x55b5('0x2c')]+'%'};return _0x19c0fd;})});}_0x18b196=_[_0x55b5('0xce')]({},_0x18b196,_0x3fb9dc[_0x55b5('0x55')]);return _0x542d94[_0x55b5('0x154')](_0x18b196);}})['then'](function(_0x4e7f84){if(_0x4e7f84){_0x56e0f0=_0x4e7f84[_0x55b5('0x53')];if(!_0x3fb9dc['query'][_0x55b5('0xd0')](_0x55b5('0xd6'))){_0x18b196[_0x55b5('0x22')]=qs['limit'](_0x3fb9dc[_0x55b5('0x3e')][_0x55b5('0x22')]);_0x18b196[_0x55b5('0x20')]=qs[_0x55b5('0x20')](_0x3fb9dc['query'][_0x55b5('0x20')]);}return _0x542d94[_0x55b5('0x154')](_0x18b196);}})['then'](function(_0xc8e9da){if(_0xc8e9da){return _0xc8e9da?{'count':_0x56e0f0,'rows':_0xc8e9da}:null;}})[_0x55b5('0x15')](respondWithResult(_0x1ff6b5,null))[_0x55b5('0x1f')](handleError(_0x1ff6b5,null));};exports[_0x55b5('0x155')]=function(_0x5c0790,_0xdbb8d6){return db['User']['find']({'where':{'id':_0x5c0790[_0x55b5('0x4c')]['id']}})[_0x55b5('0x15')](handleEntityNotFound(_0xdbb8d6,null))[_0x55b5('0x15')](function(_0x1ef664){if(_0x1ef664){return _0x1ef664[_0x55b5('0x155')](_0x5c0790[_0x55b5('0x5b')][_0x55b5('0x5f')],_[_0x55b5('0x5e')](_0x5c0790['body'],[_0x55b5('0x5f'),'id'])||{});}})[_0x55b5('0x15')](respondWithResult(_0xdbb8d6,null))['catch'](handleError(_0xdbb8d6,null));};exports[_0x55b5('0x156')]=function(_0x22d479,_0x49d2e8){return db[_0x55b5('0x3d')]['find']({'where':{'id':_0x22d479['params']['id']}})[_0x55b5('0x15')](handleEntityNotFound(_0x49d2e8,null))[_0x55b5('0x15')](function(_0x1ca299){if(_0x1ca299){return _0x1ca299['removeSquareProjects'](_0x22d479[_0x55b5('0x3e')][_0x55b5('0x5f')]);}})['then'](respondWithStatusCode(_0x49d2e8,null))['catch'](handleError(_0x49d2e8,null));};exports['getScheduledCalls']=function(_0x41f0fa,_0x37378c){var _0x2fc76d={},_0x4ab020={},_0x51223d={'count':0x0,'rows':[]};var _0x21a024=db[_0x55b5('0x157')][_0x55b5('0x50')];_0x4ab020['model']=_['keys'](_0x21a024);_0x4ab020[_0x55b5('0x3e')]=_[_0x55b5('0x4f')](_0x41f0fa['query']);_0x4ab020[_0x55b5('0x51')]=_[_0x55b5('0xca')](_0x4ab020[_0x55b5('0x4d')],_0x4ab020[_0x55b5('0x3e')]);_0x4ab020[_0x55b5('0x51')]=_[_0x55b5('0xc7')](_0x4ab020[_0x55b5('0x51')],['$and','$or',_0x55b5('0x158'),'$gte',_0x55b5('0x159'),_0x55b5('0x15a'),_0x55b5('0x15b'),_0x55b5('0x15c'),_0x55b5('0x15d'),_0x55b5('0x15e'),'$notBetween',_0x55b5('0x15f'),_0x55b5('0x160'),_0x55b5('0x161'),_0x55b5('0x162'),_0x55b5('0x163'),'$notILike',_0x55b5('0x161'),'$overlap',_0x55b5('0x164'),_0x55b5('0x165'),_0x55b5('0x166')]);_0x2fc76d[_0x55b5('0x42')]=_['intersection'](_0x4ab020[_0x55b5('0x4d')],qs[_0x55b5('0x52')](_0x41f0fa['query'][_0x55b5('0x52')]));_0x2fc76d['attributes']=_0x2fc76d[_0x55b5('0x42')][_0x55b5('0x53')]?_0x2fc76d[_0x55b5('0x42')]:_0x4ab020['model'];if(!_0x41f0fa['query'][_0x55b5('0xd0')](_0x55b5('0xd6'))){_0x2fc76d[_0x55b5('0x22')]=qs[_0x55b5('0x22')](_0x41f0fa[_0x55b5('0x3e')]['limit']);_0x2fc76d[_0x55b5('0x20')]=qs[_0x55b5('0x20')](_0x41f0fa[_0x55b5('0x3e')]['offset']);}_0x2fc76d[_0x55b5('0xcb')]=qs[_0x55b5('0xcc')](_0x41f0fa[_0x55b5('0x3e')][_0x55b5('0xcc')]);_0x2fc76d[_0x55b5('0xcf')]=qs['filters'](_[_0x55b5('0xcd')](_0x41f0fa[_0x55b5('0x3e')],_0x4ab020[_0x55b5('0x51')]));if(_0x41f0fa[_0x55b5('0x3e')][_0x55b5('0x2c')]){_0x2fc76d[_0x55b5('0xcf')]=_['merge'](_0x2fc76d[_0x55b5('0xcf')],{'$or':_['map'](_0x2fc76d[_0x55b5('0x42')],function(_0x4b66e5){var _0x2de659={};_0x2de659[_0x4b66e5]={'$like':'%'+_0x41f0fa[_0x55b5('0x3e')]['filter']+'%'};return _0x2de659;})});}_0x2fc76d[_0x55b5('0xcf')]={'$and':[_0x2fc76d[_0x55b5('0xcf')],{'$or':[{'UserId':_0x41f0fa[_0x55b5('0x4c')]['id']},{'OwnerId':_0x41f0fa[_0x55b5('0x4c')]['id']}]}]};_0x2fc76d=_[_0x55b5('0xce')]({},_0x2fc76d,_0x41f0fa[_0x55b5('0x55')]);var _0x4e2ae7={'where':_0x2fc76d['where']};return db[_0x55b5('0x157')][_0x55b5('0x23')](_0x4e2ae7)['then'](function(_0x410d5d){_0x51223d[_0x55b5('0x23')]=_0x410d5d;if(_0x41f0fa['query'][_0x55b5('0x54')]){_0x2fc76d[_0x55b5('0x3f')]=[{'attributes':['id','firstName',_0x55b5('0x167'),_0x55b5('0xeb')],'model':db['CmContact'],'as':_0x55b5('0x168')},{'attributes':['id',_0x55b5('0x2f'),_0x55b5('0x169')],'model':db['VoiceQueue'],'as':'Queue'}];}return db[_0x55b5('0x157')]['findAll'](_0x2fc76d);})[_0x55b5('0x15')](function(_0x3959e5){_0x51223d[_0x55b5('0x44')]=_0x3959e5;return _0x51223d;})[_0x55b5('0x15')](respondWithFilteredResult(_0x37378c,_0x2fc76d))[_0x55b5('0x1f')](handleError(_0x37378c,null));};exports[_0x55b5('0x16a')]=function(_0x2e0039,_0x559cca){if(!_['isNil'](_0x2e0039['user']['id'])&&(_0x2e0039[_0x55b5('0x78')][_0x55b5('0x28')]=='admin'||_0x2e0039['user'][_0x55b5('0x28')]=='user')){return db['User']['findOne']({'where':{'id':_0x2e0039['params']['id']},'raw':!![]})['then'](function(_0x5c414a){return authService[_0x55b5('0x16b')](_0x5c414a);})[_0x55b5('0x15')](function(_0x5248d2){if(_0x5248d2){return _0x559cca[_0x55b5('0x24')](0xc8)[_0x55b5('0x16c')]({'api_key':_0x5248d2[_0x55b5('0x16d')]});}else{return _0x559cca[_0x55b5('0x24')](0xcc)[_0x55b5('0x16c')]({'message':'No\x20API\x20access\x20key\x20found!'});}})[_0x55b5('0x1f')](handleError(_0x559cca,0x193));}else{return _0x559cca['status'](0x191)[_0x55b5('0x16c')]({'message':'You\x20don\x27t\x20have\x20sufficient\x20privileges\x20to\x20access\x20this\x20resource.'});}};exports['createApiKey']=function(_0x1cdf89,_0x23fedc){if(!_[_0x55b5('0x64')](_0x1cdf89[_0x55b5('0x78')]['id'])&&(_0x1cdf89[_0x55b5('0x78')]['role']==_0x55b5('0x29')||_0x1cdf89[_0x55b5('0x78')][_0x55b5('0x28')]=='user')){return db[_0x55b5('0x3d')][_0x55b5('0x56')]({'where':{'id':_0x1cdf89[_0x55b5('0x4c')]['id']}})[_0x55b5('0x15')](function(_0x47fae4){return authService[_0x55b5('0x16e')](_0x47fae4);})[_0x55b5('0x15')](function(_0x564d04){return db[_0x55b5('0x3d')][_0x55b5('0x26')]({'apiKeyIat':_0x564d04[_0x55b5('0x16f')],'apiKeyNonce':_0x564d04[_0x55b5('0x170')]},{'where':{'id':_0x1cdf89[_0x55b5('0x4c')]['id']}})['then'](function(){return _0x23fedc['status'](0xc8)[_0x55b5('0x16c')]({'api_key':_0x564d04[_0x55b5('0x16d')]});});})[_0x55b5('0x1f')](handleError(_0x23fedc,0x193));}else{return _0x23fedc['status'](0x191)[_0x55b5('0x16c')]({'message':_0x55b5('0x171')});}};exports[_0x55b5('0x172')]=function(_0x1d19f1,_0x1ce4eb){if(!_[_0x55b5('0x64')](_0x1d19f1[_0x55b5('0x78')]['id'])&&(_0x1d19f1['user'][_0x55b5('0x28')]==_0x55b5('0x29')||_0x1d19f1[_0x55b5('0x78')][_0x55b5('0x28')]=='user')){return db[_0x55b5('0x3d')][_0x55b5('0x56')]({'where':{'id':_0x1d19f1['params']['id']}})[_0x55b5('0x15')](handleEntityNotFound(_0x1ce4eb,null))[_0x55b5('0x15')](function(_0x2cb200){if(_0x2cb200&&_0x2cb200[_0x55b5('0x173')]&&_0x2cb200[_0x55b5('0x174')])return _0x2cb200;else throw{'message':_0x55b5('0x175')};})[_0x55b5('0x15')](function(){return db[_0x55b5('0x3d')][_0x55b5('0x26')]({'apiKeyNonce':null,'apiKeyIat':null},{'where':{'id':_0x1d19f1[_0x55b5('0x4c')]['id']}});})[_0x55b5('0x15')](respondWithStatusCode(_0x1ce4eb,0xc8))['catch'](handleError(_0x1ce4eb,0x193));}else{return _0x1ce4eb['status'](0x191)[_0x55b5('0x16c')]({'message':_0x55b5('0x171')});}};exports[_0x55b5('0x176')]=function(_0x3f07b8,_0x14dba1){var _0x73ebad=_0x3f07b8[_0x55b5('0x78')]['get']({'plain':!![]});if(!_0x73ebad){return _0x14dba1['status'](0x191)['send']('Unable\x20to\x20retrieve\x20the\x20current\x20user');}else{Promise[_0x55b5('0x101')]()[_0x55b5('0x15')](function(){if(_0x3f07b8[_0x55b5('0x3e')][_0x55b5('0x40')]!==_0x55b5('0x57'))return;return _0x3f07b8[_0x55b5('0x78')]['getUserSetting']();})[_0x55b5('0x15')](function(_0x2d8036){if(!_0x2d8036)return;return _0x2d8036['get']({'plain':!![]});})[_0x55b5('0x15')](function(_0x3e018c){_0x73ebad['userSetting']=_0x3e018c;return _0x14dba1[_0x55b5('0x24')](0xc8)['json'](_0x73ebad);});}};exports[_0x55b5('0x177')]=function(_0x1ecc12,_0x494f92){var _0x6e97b0={'offset':0x0},_0x1254c0={'count':0x0,'rows':[]};Promise[_0x55b5('0x101')]()[_0x55b5('0x15')](function(){if(!_0x1ecc12['query']['filter']&&!_0x1ecc12[_0x55b5('0x3e')]['teams']&&!_0x1ecc12[_0x55b5('0x3e')][_0x55b5('0x178')])return[];return Promise[_0x55b5('0x101')]()['then'](function(){var _0x1aaac1=[];if(!_['isEmpty'](_0x1ecc12['query'][_0x55b5('0x179')])){_0x1aaac1[_0x55b5('0x43')](db[_0x55b5('0x111')][_0x55b5('0x85')]({'attributes':['id',_0x55b5('0x2f')],'where':{'id':_0x1ecc12['query'][_0x55b5('0x179')]}}));}if(!_[_0x55b5('0x86')](_0x1ecc12['query'][_0x55b5('0x178')])){_0x1aaac1[_0x55b5('0x43')](db['VoiceQueue'][_0x55b5('0x85')]({'attributes':['id',_0x55b5('0x2f')],'type':_0x55b5('0x17a'),'where':{'id':_0x1ecc12['query'][_0x55b5('0x178')]}}));}return Promise[_0x55b5('0x5a')](_0x1aaac1);})[_0x55b5('0x15')](function(_0x30f3d8){var _0x1a787f=_[_0x55b5('0x17b')](_0x30f3d8)[_0x55b5('0x36')](function(_0xea86a1){return _0xea86a1[_0x55b5('0x17c')]({'attributes':['id',_0x55b5('0x2f'),_0x55b5('0x60'),_0x55b5('0x9c')],'raw':!![]});});return Promise[_0x55b5('0x5a')](_0x1a787f);})[_0x55b5('0x15')](function(_0x52a125){var _0xcf5ad0=_['flatten'](_0x52a125);if(!_0x1ecc12['query'][_0x55b5('0x2c')])return _0xcf5ad0;if(_[_0x55b5('0x86')](_0xcf5ad0)){return db[_0x55b5('0x3d')]['findAll']({'attributes':['id',_0x55b5('0x2f'),_0x55b5('0x60'),_0x55b5('0x9c')],'where':{'role':'agent','$or':[db['sequelize'][_0x55b5('0xcf')](db[_0x55b5('0x66')]['fn'](_0x55b5('0x17d'),db['sequelize'][_0x55b5('0x17e')](_0x55b5('0x2f'))),{'$like':'%'+_0x1ecc12[_0x55b5('0x3e')][_0x55b5('0x2c')][_0x55b5('0xa1')]()+'%'}),{'internal':{'$like':'%'+_0x1ecc12[_0x55b5('0x3e')][_0x55b5('0x2c')]+'%'}}]},'raw':!![]});}else{return _(_0xcf5ad0)['flatten']()[_0x55b5('0x2c')](function(_0x252e66){return _0x252e66[_0x55b5('0x2f')][_0x55b5('0xa1')]()['includes'](_0x1ecc12[_0x55b5('0x3e')][_0x55b5('0x2c')][_0x55b5('0xa1')]())||_0x252e66[_0x55b5('0x60')][_0x55b5('0x17f')]()[_0x55b5('0x2e')](_0x1ecc12[_0x55b5('0x3e')]['filter']);})[_0x55b5('0x2d')]();}})['then'](function(_0x560276){var _0x1fa8fb=_0x55b5('0x2f');var _0x39e3b3=_0x55b5('0x180');if(_0x1ecc12['query'][_0x55b5('0xcc')]){_0x39e3b3=_0x1ecc12[_0x55b5('0x3e')][_0x55b5('0xcc')][0x0]==='-'?_0x55b5('0x181'):_0x55b5('0x180');_0x1fa8fb=_0x39e3b3===_0x55b5('0x180')?_0x1ecc12['query'][_0x55b5('0xcc')]:_0x1ecc12[_0x55b5('0x3e')][_0x55b5('0xcc')][_0x55b5('0x182')](0x1);}return _(_0x560276)[_0x55b5('0x183')]('id')[_0x55b5('0x184')]([function(_0x39c37c){return _0x1fa8fb===_0x55b5('0x2f')?_0x39c37c[_0x1fa8fb]['toLowerCase']():_0x39c37c[_0x1fa8fb];}],[_0x39e3b3])[_0x55b5('0x36')](function(_0x534175){return _['pick'](_0x534175,['id',_0x55b5('0x2f'),_0x55b5('0x60'),_0x55b5('0x9c')]);})['value']();})['then'](function(_0x47a782){return client['request']('Agents',_0x1ecc12)[_0x55b5('0x15')](function(_0x1947e7){if(_0x1947e7['error'])throw new Error(_0x55b5('0x185'));var _0x46c6fe=_0x1947e7[_0x55b5('0x1e')];var _0x4e6834=jayson[_0x55b5('0x13')][_0x55b5('0x186')]({'port':0x232c});return _0x4e6834[_0x55b5('0x14')]('Agents',_0x1ecc12)[_0x55b5('0x15')](function(_0x134cc5){if(_0x134cc5[_0x55b5('0x1b')])throw new Error('Unable\x20to\x20retrieve\x20RPC\x20agents\x20(Routing)');var _0x3e6ed2=_0x134cc5['result'];return _[_0x55b5('0xce')]({},_0x3e6ed2,_0x46c6fe);});})[_0x55b5('0x15')](function(_0x4c2c58){return _[_0x55b5('0x36')](_0x47a782,function(_0x496b83){var _0xc97619=_[_0x55b5('0x56')](_0x4c2c58[_0x55b5('0x44')],['id',_0x496b83['id']]);if(!_0xc97619||!_0x496b83[_0x55b5('0x9c')]){_0x496b83[_0x55b5('0x24')]='offline';}else if(_0xc97619['voicePause']){_0x496b83[_0x55b5('0x24')]='pause';}else{_0x496b83['status']=_[_0x55b5('0x2e')]([_0x55b5('0x187'),_0x55b5('0x188'),'unavailable','ringing',null,undefined],_0xc97619['voiceStatus'])?_0x55b5('0x9c'):'busy';}return _0x496b83;});});});})[_0x55b5('0x15')](function(_0x935fdd){if(!_0x1ecc12[_0x55b5('0x3e')]['hasOwnProperty']('nolimit')){_0x6e97b0[_0x55b5('0x22')]=qs['limit'](_0x1ecc12[_0x55b5('0x3e')][_0x55b5('0x22')]||0xa);_0x6e97b0['offset']=qs[_0x55b5('0x20')](_0x1ecc12[_0x55b5('0x3e')]['offset']);}_0x1254c0['count']=_0x935fdd[_0x55b5('0x53')];_0x1254c0[_0x55b5('0x44')]=_0x6e97b0[_0x55b5('0x22')]?_0x935fdd[_0x55b5('0x189')](_0x6e97b0[_0x55b5('0x20')],_0x6e97b0[_0x55b5('0x20')]+_0x6e97b0[_0x55b5('0x22')]):_0x935fdd;return _0x1254c0;})['then'](respondWithFilteredResult(_0x494f92,_0x6e97b0))[_0x55b5('0x1f')](handleError(_0x494f92,null));};function get_open_tabs(_0x5111a0,_0x5d0ec6){var _0x4fbad7=_0x5111a0['charAt'](0x0)[_0x55b5('0x18a')]()+_0x5111a0[_0x55b5('0x189')](0x1);var _0x1d3ce6={'type':db[_0x55b5('0x8c')][_0x55b5('0x18b')][_0x55b5('0x68')],'raw':!![]};return new BPromise(function(_0x3d71c4,_0x5259b9){var _0x5357b6=squel[_0x55b5('0x18c')]()['field'](_0x55b5('0x18d')+_0x4fbad7+_0x55b5('0x18e'),'id')[_0x55b5('0x18f')]('ui.createdAt')[_0x55b5('0x69')](_0x55b5('0x190')+_0x5111a0+_0x55b5('0x191'),'ui')['where']('ui.UserId\x20=\x20?',_0x5d0ec6['id']);return db[_0x55b5('0x66')][_0x55b5('0x3e')](_0x5357b6[_0x55b5('0x17f')](),_0x1d3ce6)[_0x55b5('0x15')](function(_0x200447){_0x5d0ec6[_0x4fbad7+_0x55b5('0x192')]=_0x200447;_0x3d71c4(_0x200447);})[_0x55b5('0x1f')](function(_0x4555ac){_0x5259b9(_0x4555ac);});});}
\ No newline at end of file