Built motion from commit 775e2a94.|2.6.3
[motion2.git] / server / api / user / user.controller.js
index fdb859e..cfac375 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x24bb=['getFaxAccounts','FaxAccount','addFaxAccounts','removeFaxAccounts','getMailAccounts','addMailAccounts','removeMailAccounts','getOpenchannelAccounts','OpenchannelAccount','addOpenchannelAccounts','removeOpenchannelAccounts','getSmsAccounts','SmsAccount','addSmsAccounts','removeSmsAccounts','getChatWebsites','ChatWebsite','addChatWebsites','removeChatWebsites','SquareProject','getSquareProjects','addSquareProjects','removeSquareProjects','getScheduledCalls','CmHopper','concat','$or','$gt','$gte','$lt','$lte','$ne','$eq','$not','$between','$notBetween','$in','$notIn','$like','$notILike','$overlap','$contained','$any','firstName','CmContact','Contact','dialActive','getApiKey','retrieveApiKey','token','No\x20API\x20access\x20key\x20found!','You\x20don\x27t\x20have\x20sufficient\x20privileges\x20to\x20access\x20this\x20resource.','generateApiKey','nonce','removeApiKey','apiKeyNonce','apiKeyIat','whoami','html-pdf','rimraf','fast-json-patch','request-promise','bluebird','path','sox','to-csv','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/environment','../../mysqldb','defaults','redis','localhost','./user.socket','jayson/promise','client','http','test','Sequelize','ValidationError','The\x20password\x20must\x20be\x20at\x20least\x208\x20characters\x20long\x20and\x20have\x201\x20lowercase\x20character,\x201\x20uppercase\x20character,\x201\x20number\x20and\x201\x20special\x20character\x20~!@#$%^&-_=+[{]}.','request','then','info','User,\x20%s,\x20%s','request\x20sent','debug','User,\x20%s,\x20%s,\x20%s','error','code','message','result','catch','status','end','json','count','offset','limit','set','Content-Range','reject','save','update','get','Users','Agents','Telephones','telephone','filter','ignore','value','role','find','name','UserProfileResource','destroy','sendStatus','stack','send','map','fieldName','type','key','model','password','salt','query','keys','filters','intersection','fields','attributes','hasOwnProperty','nolimit','order','sort','where','pick','merge','VIRTUAL','sequelize','lower','col','options','User','includeAll','include','findAll','rows','show','params','rawAttributes','bulkCreate','body','describe','addContacts','ids','omit','agent\x20role','admin','../../config/license/util','getLicense','telephones','users','isNil','License\x20limit\x20reached','format','count\x20%s:\x20%s','create','internal','Setting','securePassword','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','voicemail','mailbox','fullname','email','agent','permissions','101','102','103','110','104','106','107','109','100','111','VoiceMail','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','UserProfileSection','userProfileId','autoAssociation','changePassword','findOne','oldPassword','newPassword','authenticate','Wrong\x20credentials','New\x20password\x20must\x20be\x20different\x20from\x20old\x20password','Invalid\x20body\x20format.\x20Use\x20newPassword','addQueues','channel','loginInPause','voicePause','interface','isValidChannel','Unknown\x20channel','add','capitalize','penalty','spread','length','QueueId','emit','toLowerCase','Queue:save','voice','VoiceQueue','online','push','SIP/%s','each','upsert','removeQueues','Queues','Queue:remove','UserVoiceQueueRt','userpic','getAvatar','join','root','server/files/images/logos/default_profile.png','download','existsSync','server/files/images/','getContacts','CmList','List','Tag','Tags','color','tag','getQueues','Queue','Unknown\x20role','getVoiceQueuesRt','getGroups','VoiceRecording','UserId','getScreenRecordings','ScreenRecording','getChatInteractions','getOpenchannelInteractions','getMailInteractions','MailInteraction','getSmsInteractions','SmsInteraction','getFaxInteractions','phone','mobile','LOCAL/%s@from-sip/n','intrf','user:%s','user:forcelogout','headers','x-forwarded-for','connection','remoteAddress','socket','User\x20not\x20found\x20or\x20not\x20allowed\x20to\x20perform\x20login\x20method','MemberReport','forEach','YYYY-MM-DD\x20HH:mm:ss','all','LOGIN','device','PAUSE','LOGININPAUSE','resolve','logout','QueuePause','pause','getChannels','DEFAULT\x20PAUSE','unpause','openchannelPause','smsPause','pauseType','lastPauseAt','manual','mail','fax','openchannel','%s%s','getTeams','Team','addTeams','setDataValue','getChatQueues','Chat','getMailQueues','Mail','getSmsQueues','Sms','getFaxQueues','getOpenchannelQueues','Openchannel','flatten','transaction','getDataValue','removeTeams','getVoiceQueues','Voice','Fax','removeAgent','getLists','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','user_has_sms_interactions:save','removeSmsInteractions','addOpenchannelInteractions','removeOpenchannelInteractions','user_has_openchannel_interactions:remove','getVoicePrefixes','VoicePrefix'];(function(_0x51e559,_0x145275){var _0x169eb1=function(_0x142c28){while(--_0x142c28){_0x51e559['push'](_0x51e559['shift']());}};_0x169eb1(++_0x145275);}(_0x24bb,0x19f));var _0xb24b=function(_0x5acafb,_0x3ecb2e){_0x5acafb=_0x5acafb-0x0;var _0x4a7024=_0x24bb[_0x5acafb];return _0x4a7024;};'use strict';var pdf=require(_0xb24b('0x0'));var emlformat=require('eml-format');var rimraf=require(_0xb24b('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0xb24b('0x2'));var rp=require(_0xb24b('0x3'));var moment=require('moment');var BPromise=require(_0xb24b('0x4'));var Mustache=require('mustache');var util=require('util');var path=require(_0xb24b('0x5'));var sox=require(_0xb24b('0x6'));var csv=require(_0xb24b('0x7'));var ejs=require('ejs');var fs=require('fs');var _=require('lodash');var squel=require(_0xb24b('0x8'));var crypto=require(_0xb24b('0x9'));var jsforce=require(_0xb24b('0xa'));var deskjs=require(_0xb24b('0xb'));var toCsv=require(_0xb24b('0x7'));var querystring=require(_0xb24b('0xc'));var Papa=require(_0xb24b('0xd'));var Redis=require(_0xb24b('0xe'));var authService=require('../../components/auth/service');var qs=require(_0xb24b('0xf'));var as=require(_0xb24b('0x10'));var hardwareService=require(_0xb24b('0x11'));var logger=require(_0xb24b('0x12'))('api');var utils=require('../../config/utils');var config=require(_0xb24b('0x13'));var db=require(_0xb24b('0x14'))['db'];config['redis']=_[_0xb24b('0x15')](config[_0xb24b('0x16')],{'host':_0xb24b('0x17'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0xb24b('0x16')]));require(_0xb24b('0x18'))['register'](socket);var jayson=require(_0xb24b('0x19'));var client=jayson[_0xb24b('0x1a')][_0xb24b('0x1b')]({'port':0x232a});function checkPasswordPattern(_0x2f89f5,_0x3a2d7a,_0x4e95c8){if(_0x4e95c8){var _0x3f3676=new RegExp(/(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[?!@#\$%\^&\*~\-_=+[{\]\}])(?=.{8,})/);if(_0x3f3676[_0xb24b('0x1c')](_0x3a2d7a)){return _0x2f89f5;}else{throw new db[(_0xb24b('0x1d'))][(_0xb24b('0x1e'))](_0xb24b('0x1f'));}}else{return _0x2f89f5;}}function respondWithRpcPromise(_0x3d5a32,_0x2c7b9a,_0x5cf988,_0x3285c4){return new BPromise(function(_0x245b61,_0x292c4a){var _0x594b38=_0x3285c4||client;return _0x594b38[_0xb24b('0x20')](_0x3d5a32,_0x5cf988)[_0xb24b('0x21')](function(_0x54eb8a){logger[_0xb24b('0x22')](_0xb24b('0x23'),_0x2c7b9a,_0xb24b('0x24'));logger[_0xb24b('0x25')](_0xb24b('0x26'),_0x2c7b9a,_0xb24b('0x24'),JSON['stringify'](_0x54eb8a));if(_0x54eb8a[_0xb24b('0x27')]){if(_0x54eb8a[_0xb24b('0x27')][_0xb24b('0x28')]===0x1f4){logger[_0xb24b('0x27')](_0xb24b('0x23'),_0x2c7b9a,_0x54eb8a['error'][_0xb24b('0x29')]);return _0x292c4a(_0x54eb8a[_0xb24b('0x27')][_0xb24b('0x29')]);}logger[_0xb24b('0x27')]('User,\x20%s,\x20%s',_0x2c7b9a,_0x54eb8a[_0xb24b('0x27')]['message']);return _0x245b61(_0x54eb8a['error'][_0xb24b('0x29')]);}else{logger[_0xb24b('0x22')]('User,\x20%s,\x20%s',_0x2c7b9a,_0xb24b('0x24'));_0x245b61(_0x54eb8a[_0xb24b('0x2a')][_0xb24b('0x29')]);}})[_0xb24b('0x2b')](function(_0x4d2c51){logger['error']('User,\x20%s,\x20%s',_0x2c7b9a,_0x4d2c51);_0x292c4a(_0x4d2c51);});});}function respondWithStatusCode(_0x383b63,_0x65b1d9){_0x65b1d9=_0x65b1d9||0xcc;return function(_0x38975f){if(_0x38975f){return _0x383b63['sendStatus'](_0x65b1d9);}return _0x383b63[_0xb24b('0x2c')](_0x65b1d9)[_0xb24b('0x2d')]();};}function respondWithResult(_0xd8dbbd,_0x53888d){_0x53888d=_0x53888d||0xc8;return function(_0x112c4d){if(_0x112c4d){return _0xd8dbbd[_0xb24b('0x2c')](_0x53888d)[_0xb24b('0x2e')](_0x112c4d);}};}function respondWithFilteredResult(_0x5de4f0,_0xf53d92){return function(_0x33a389){if(_0x33a389){var _0x7e4166=_0x33a389[_0xb24b('0x2f')],_0x36c97e=_0xf53d92['offset'],_0x4561b9=_0xf53d92[_0xb24b('0x30')]+_0xf53d92[_0xb24b('0x31')],_0x41d4d7;if(_0x4561b9>=_0x7e4166){_0x4561b9=_0x7e4166;_0x41d4d7=0xc8;}else{_0x41d4d7=0xce;}_0x5de4f0[_0xb24b('0x2c')](_0x41d4d7);return _0x5de4f0[_0xb24b('0x32')](_0xb24b('0x33'),_0x36c97e+'-'+_0x4561b9+'/'+_0x7e4166)[_0xb24b('0x2e')](_0x33a389);}return null;};}function patchUpdates(_0x5151ca){return function(_0x2fd3fe){try{jsonpatch['apply'](_0x2fd3fe,_0x5151ca,!![]);}catch(_0x2a46f1){return BPromise[_0xb24b('0x34')](_0x2a46f1);}return _0x2fd3fe[_0xb24b('0x35')]();};}function saveUpdates(_0x4c04ab,_0x5cc2d1){return function(_0x96a958){if(_0x96a958){return _0x96a958[_0xb24b('0x36')](_0x4c04ab)[_0xb24b('0x21')](function(_0xbddbb6){return _0xbddbb6;});}return null;};}function removeEntity(_0x195ced,_0x3893eb){return function(_0x418312){if(_0x418312){return _0x418312['destroy']()[_0xb24b('0x21')](function(){var _0x5107ff=_0x418312[_0xb24b('0x37')]({'plain':!![]});var _0x81e4d9=[{'name':_0xb24b('0x38'),'value':'user','ignore':!![]},{'name':_0xb24b('0x39'),'value':'agent','ignore':![]},{'name':_0xb24b('0x3a'),'value':_0xb24b('0x3b'),'ignore':![]}];var _0x3e5bc6=_(_0x81e4d9)[_0xb24b('0x3c')](_0xb24b('0x3d'))['map'](_0xb24b('0x3e'))[_0xb24b('0x3e')]();if(_['includes'](_0x3e5bc6,_0x5107ff[_0xb24b('0x3f')])){return;}var _0x2c87da=_[_0xb24b('0x40')](_0x81e4d9,['value',_0x5107ff['role']])[_0xb24b('0x41')];return db[_0xb24b('0x42')][_0xb24b('0x43')]({'where':{'type':_0x2c87da,'resourceId':_0x5107ff['id']}})[_0xb24b('0x21')](function(){return _0x418312;});})[_0xb24b('0x21')](function(){_0x195ced[_0xb24b('0x2c')](0xcc)[_0xb24b('0x2d')]();});}};}function handleEntityNotFound(_0x24bd42,_0xac04f3){return function(_0x18fe6a){if(!_0x18fe6a){_0x24bd42[_0xb24b('0x44')](0x194);}return _0x18fe6a;};}function handleError(_0x3bb563,_0x509ccd){_0x509ccd=_0x509ccd||0x1f4;return function(_0x5e97cb){logger['error'](_0x5e97cb[_0xb24b('0x45')]);if(_0x5e97cb[_0xb24b('0x41')]){delete _0x5e97cb['name'];}_0x3bb563[_0xb24b('0x2c')](_0x509ccd)[_0xb24b('0x46')](_0x5e97cb);};}exports['index']=function(_0x41c740,_0x5a6b99){var _0x191bff={},_0x56c7f8={},_0x3a8ec0={'count':0x0,'rows':[]};var _0x302ab3=_[_0xb24b('0x47')](db['User']['rawAttributes'],function(_0x2fbe1b){return{'name':_0x2fbe1b[_0xb24b('0x48')],'type':_0x2fbe1b[_0xb24b('0x49')][_0xb24b('0x4a')]};});_0x56c7f8[_0xb24b('0x4b')]=_['differenceBy'](_[_0xb24b('0x47')](_0x302ab3,'name'),[_0xb24b('0x4c'),_0xb24b('0x4d')]);_0x56c7f8[_0xb24b('0x4e')]=_[_0xb24b('0x4f')](_0x41c740['query']);_0x56c7f8[_0xb24b('0x50')]=_['intersection'](_0x56c7f8[_0xb24b('0x4b')],_0x56c7f8[_0xb24b('0x4e')]);_0x191bff['attributes']=_[_0xb24b('0x51')](_0x56c7f8[_0xb24b('0x4b')],qs[_0xb24b('0x52')](_0x41c740[_0xb24b('0x4e')]['fields']));_0x191bff[_0xb24b('0x53')]=_0x191bff[_0xb24b('0x53')]['length']?_0x191bff[_0xb24b('0x53')]:_0x56c7f8[_0xb24b('0x4b')];if(!_0x41c740[_0xb24b('0x4e')][_0xb24b('0x54')](_0xb24b('0x55'))){_0x191bff[_0xb24b('0x31')]=qs['limit'](_0x41c740['query'][_0xb24b('0x31')]);_0x191bff['offset']=qs[_0xb24b('0x30')](_0x41c740['query'][_0xb24b('0x30')]);}_0x191bff[_0xb24b('0x56')]=qs[_0xb24b('0x57')](_0x41c740[_0xb24b('0x4e')][_0xb24b('0x57')]);_0x191bff[_0xb24b('0x58')]=qs[_0xb24b('0x50')](_[_0xb24b('0x59')](_0x41c740[_0xb24b('0x4e')],_0x56c7f8[_0xb24b('0x50')]));if(_0x41c740[_0xb24b('0x4e')][_0xb24b('0x3c')]){_0x191bff[_0xb24b('0x58')]=_[_0xb24b('0x5a')](_0x191bff[_0xb24b('0x58')],{'$or':_['map'](_0x302ab3,function(_0x45c828){if(_0x45c828[_0xb24b('0x49')]!==_0xb24b('0x5b')){return db['sequelize'][_0xb24b('0x58')](db[_0xb24b('0x5c')]['fn'](_0xb24b('0x5d'),db[_0xb24b('0x5c')][_0xb24b('0x5e')](_0x45c828[_0xb24b('0x41')])),{'$like':db['sequelize']['fn']('lower','%'+_0x41c740[_0xb24b('0x4e')][_0xb24b('0x3c')]+'%')});}})});}_0x191bff=_['merge']({},_0x191bff,_0x41c740[_0xb24b('0x5f')]);var _0x3f6110={'where':_0x191bff[_0xb24b('0x58')]};return db[_0xb24b('0x60')][_0xb24b('0x2f')](_0x3f6110)['then'](function(_0x22fbd1){_0x3a8ec0[_0xb24b('0x2f')]=_0x22fbd1;if(_0x41c740[_0xb24b('0x4e')][_0xb24b('0x61')]){_0x191bff[_0xb24b('0x62')]=[{'all':!![]}];}return db[_0xb24b('0x60')][_0xb24b('0x63')](_0x191bff);})['then'](function(_0x156058){_0x3a8ec0[_0xb24b('0x64')]=_0x156058;return _0x3a8ec0;})[_0xb24b('0x21')](respondWithFilteredResult(_0x5a6b99,_0x191bff))['catch'](handleError(_0x5a6b99,null));};exports[_0xb24b('0x65')]=function(_0x4a61e6,_0x25d8c2){var _0x28a8b3={'raw':![],'where':{'id':_0x4a61e6[_0xb24b('0x66')]['id']}},_0x10af08={};_0x10af08[_0xb24b('0x4b')]=_['differenceBy'](_[_0xb24b('0x4f')](db[_0xb24b('0x60')][_0xb24b('0x67')]),[_0xb24b('0x4c'),_0xb24b('0x4d')]);_0x10af08['query']=_[_0xb24b('0x4f')](_0x4a61e6[_0xb24b('0x4e')]);_0x10af08[_0xb24b('0x50')]=_['intersection'](_0x10af08[_0xb24b('0x4b')],_0x10af08[_0xb24b('0x4e')]);_0x28a8b3[_0xb24b('0x53')]=_[_0xb24b('0x51')](_0x10af08[_0xb24b('0x4b')],qs[_0xb24b('0x52')](_0x4a61e6[_0xb24b('0x4e')][_0xb24b('0x52')]));_0x28a8b3[_0xb24b('0x53')]=_0x28a8b3[_0xb24b('0x53')]['length']?_0x28a8b3[_0xb24b('0x53')]:_0x10af08[_0xb24b('0x4b')];if(_0x4a61e6[_0xb24b('0x4e')][_0xb24b('0x61')]){_0x28a8b3['include']=[{'all':!![]}];}_0x28a8b3=_[_0xb24b('0x5a')]({},_0x28a8b3,_0x4a61e6[_0xb24b('0x5f')]);return db[_0xb24b('0x60')][_0xb24b('0x40')](_0x28a8b3)[_0xb24b('0x21')](handleEntityNotFound(_0x25d8c2,null))['then'](respondWithResult(_0x25d8c2,null))['catch'](handleError(_0x25d8c2,null));};exports['bulkCreate']=function(_0x4f3ec4,_0x5cdb18){return db[_0xb24b('0x60')][_0xb24b('0x68')](_0x4f3ec4['body'],{'raw':![],'individualHooks':!![]})[_0xb24b('0x21')](respondWithResult(_0x5cdb18,0xc9))[_0xb24b('0x2b')](handleError(_0x5cdb18,null));};exports[_0xb24b('0x36')]=function(_0xb92961,_0x3d8b2a){if(_0xb92961[_0xb24b('0x69')]['id']){delete _0xb92961['body']['id'];}delete _0xb92961[_0xb24b('0x69')][_0xb24b('0x3f')];return db['User']['find']({'where':{'id':_0xb92961[_0xb24b('0x66')]['id']}})['then'](handleEntityNotFound(_0x3d8b2a,null))[_0xb24b('0x21')](saveUpdates(_0xb92961[_0xb24b('0x69')],null))[_0xb24b('0x21')](respondWithResult(_0x3d8b2a,null))[_0xb24b('0x2b')](handleError(_0x3d8b2a,null));};exports[_0xb24b('0x6a')]=function(_0x18e372,_0x102965){return db['User'][_0xb24b('0x6a')]()[_0xb24b('0x21')](respondWithResult(_0x102965,null))[_0xb24b('0x2b')](handleError(_0x102965,null));};exports[_0xb24b('0x6b')]=function(_0x42cdea,_0x4775b7,_0x57759c){return db[_0xb24b('0x60')][_0xb24b('0x40')]({'where':{'id':_0x42cdea['params']['id']}})[_0xb24b('0x21')](handleEntityNotFound(_0x4775b7,null))[_0xb24b('0x21')](function(_0x291d6a){if(_0x291d6a){return _0x291d6a[_0xb24b('0x6b')](_0x42cdea[_0xb24b('0x69')][_0xb24b('0x6c')],_[_0xb24b('0x6d')](_0x42cdea[_0xb24b('0x69')],[_0xb24b('0x6c'),'id'])||{});}})[_0xb24b('0x21')](respondWithResult(_0x4775b7,null))[_0xb24b('0x2b')](handleError(_0x4775b7,null));};var getLicense=function(_0x3501e1){return new BPromise(function(_0x577cf0,_0x3ac5c8){var _0x5da05f=0x0;_0x3501e1[_0xb24b('0x69')][_0xb24b('0x3f')]==='agent'&&_0x577cf0(_0xb24b('0x6e'));return db[_0xb24b('0x60')]['count']({'where':{'$or':[{'role':_0x3501e1[_0xb24b('0x69')][_0xb24b('0x3f')]===_0xb24b('0x3b')?_0xb24b('0x3b'):[_0xb24b('0x6f'),'user']}]}})['then'](function(_0x248b71){_0x5da05f=_0x248b71;return require(_0xb24b('0x70'))[_0xb24b('0x71')]();})[_0xb24b('0x21')](function(_0x9534a8){var _0x5ee710=_0x3501e1[_0xb24b('0x69')][_0xb24b('0x3f')]===_0xb24b('0x3b')?_0xb24b('0x72'):_0xb24b('0x73');if(!_[_0xb24b('0x74')](_0x9534a8[_0x5ee710])&&_0x5da05f>=_0x9534a8[_0x5ee710]){return _0x3ac5c8({'message':_0xb24b('0x75')});}return _0x577cf0(util[_0xb24b('0x76')](_0xb24b('0x77'),_0x5ee710,_0x5da05f));})[_0xb24b('0x2b')](function(_0x1d6d30){return _0x3ac5c8(_0x1d6d30);});});};exports[_0xb24b('0x78')]=function(_0x14e1f8,_0x39c6f9){return getLicense(_0x14e1f8)[_0xb24b('0x21')](function(_0x1c1a1d){if(!_0x14e1f8[_0xb24b('0x69')][_0xb24b('0x79')]){var _0x5f4d55;return db[_0xb24b('0x7a')]['findById'](0x1)[_0xb24b('0x21')](function(_0x242260){return checkPasswordPattern(_0x242260,_0x14e1f8[_0xb24b('0x69')][_0xb24b('0x4c')],_0x242260[_0xb24b('0x7b')]);})[_0xb24b('0x21')](function(_0x56e83b){_0x5f4d55=_0x56e83b[_0xb24b('0x7c')];return db['User']['max'](_0xb24b('0x79'));})[_0xb24b('0x21')](function(_0x1266a8){if(_[_0xb24b('0x74')](_0x1266a8)){if(_0x5f4d55){_0x14e1f8['body'][_0xb24b('0x79')]=_0x5f4d55;}else{_0x14e1f8[_0xb24b('0x69')]['internal']=0x1;}}else{if(_[_0xb24b('0x74')](_0x5f4d55)||_0x5f4d55==_0x1266a8){_0x14e1f8['body'][_0xb24b('0x79')]=_0x1266a8+0x1;}else if(_0x5f4d55>_0x1266a8){_0x14e1f8[_0xb24b('0x69')]['internal']=_0x5f4d55;}else{return db[_0xb24b('0x5c')][_0xb24b('0x4e')](_0xb24b('0x7d'),{'type':db[_0xb24b('0x5c')][_0xb24b('0x7e')][_0xb24b('0x7f')]})[_0xb24b('0x21')](function(_0x47e7b5){if(_0x47e7b5&&_0x47e7b5['length']){for(var _0x903fad=0x0,_0x335b4d=_0x47e7b5['length'];_0x903fad<_0x335b4d&&_[_0xb24b('0x74')](_0x14e1f8[_0xb24b('0x69')][_0xb24b('0x79')]);_0x903fad++){if(_0x5f4d55<=_0x47e7b5[_0x903fad][_0xb24b('0x80')]){_0x14e1f8[_0xb24b('0x69')]['internal']=_0x47e7b5[_0x903fad][_0xb24b('0x80')];}else if(_0x5f4d55>_0x47e7b5[_0x903fad]['from']&&_0x5f4d55<=_0x47e7b5[_0x903fad]['to']){_0x14e1f8[_0xb24b('0x69')][_0xb24b('0x79')]=_0x5f4d55;}}}if(_[_0xb24b('0x74')](_0x14e1f8['body'][_0xb24b('0x79')])){_0x14e1f8[_0xb24b('0x69')]['internal']=_0x1266a8+0x1;}});}}});}})[_0xb24b('0x21')](function(){if(_0x14e1f8['body'][_0xb24b('0x81')]){_0x14e1f8['body'][_0xb24b('0x82')]=_0x14e1f8[_0xb24b('0x69')]['internal'];_0x14e1f8['body']['VoiceMail']={'mailbox':_0x14e1f8[_0xb24b('0x69')]['internal'],'password':_0x14e1f8[_0xb24b('0x69')][_0xb24b('0x4c')],'fullname':_0x14e1f8[_0xb24b('0x69')][_0xb24b('0x83')],'email':_0x14e1f8['body'][_0xb24b('0x84')]};}if(_0x14e1f8[_0xb24b('0x69')]&&_0x14e1f8[_0xb24b('0x69')][_0xb24b('0x3f')]===_0xb24b('0x85')){_0x14e1f8[_0xb24b('0x69')][_0xb24b('0x86')]=[_0xb24b('0x87'),_0xb24b('0x88'),_0xb24b('0x89'),_0xb24b('0x8a'),_0xb24b('0x8b'),'105',_0xb24b('0x8c'),_0xb24b('0x8d'),'108',_0xb24b('0x8e'),_0xb24b('0x8f'),_0xb24b('0x90')];}return db[_0xb24b('0x60')]['create'](_0x14e1f8[_0xb24b('0x69')],{'include':[{'model':db['VoiceMail'],'as':_0xb24b('0x91')}]});})[_0xb24b('0x21')](function(_0x325489){if(_0x14e1f8[_0xb24b('0x69')][_0xb24b('0x3f')]===_0xb24b('0x92'))return _0x325489;var _0x55436a=_0x14e1f8[_0xb24b('0x92')][_0xb24b('0x37')]({'plain':!![]});if(!_0x55436a)throw new Error(_0xb24b('0x93'));if(_0x55436a[_0xb24b('0x3f')]==='user'){var _0x9c00c3=_0x325489[_0xb24b('0x37')]({'plain':!![]});var _0xfbae11=[{'name':_0xb24b('0x39'),'value':_0xb24b('0x85')},{'name':_0xb24b('0x3a'),'value':_0xb24b('0x3b')}];var _0x134f23=_[_0xb24b('0x40')](_0xfbae11,[_0xb24b('0x3e'),_0x9c00c3[_0xb24b('0x3f')]])['name'];return db[_0xb24b('0x94')][_0xb24b('0x40')]({'where':{'name':_0x134f23,'userProfileId':_0x55436a[_0xb24b('0x95')]},'raw':!![]})['then'](function(_0x35fb69){if(_0x35fb69&&_0x35fb69[_0xb24b('0x96')]===0x0){return db[_0xb24b('0x42')][_0xb24b('0x78')]({'name':_0x9c00c3[_0xb24b('0x41')],'resourceId':_0x9c00c3['id'],'type':_0x35fb69[_0xb24b('0x41')],'sectionId':_0x35fb69['id']},{})[_0xb24b('0x21')](function(){return _0x325489;});}else{return _0x325489;}})[_0xb24b('0x2b')](function(_0x330505){logger[_0xb24b('0x27')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x330505);throw _0x330505;});}return _0x325489;})['then'](respondWithResult(_0x39c6f9,0xc9))[_0xb24b('0x2b')](handleError(_0x39c6f9,null));};exports[_0xb24b('0x97')]=function(_0x5e5ce5,_0x461f6e,_0x92b501){var _0x13569a=![];if(_0x5e5ce5[_0xb24b('0x69')]['id']){delete _0x5e5ce5[_0xb24b('0x69')]['id'];}return db[_0xb24b('0x7a')][_0xb24b('0x98')]({'attributes':['id',_0xb24b('0x7b')]})[_0xb24b('0x21')](function(_0x1cb19e){_0x13569a=_0x1cb19e[_0xb24b('0x7b')];return db[_0xb24b('0x60')][_0xb24b('0x40')]({'where':{'id':_0x5e5ce5[_0xb24b('0x66')]['id']}});})[_0xb24b('0x21')](function(_0x328e39){if(_0x328e39){if(_0x328e39['id']==_0x5e5ce5['user']['id']){if(!_0x5e5ce5[_0xb24b('0x69')][_0xb24b('0x99')]||!_0x5e5ce5['body'][_0xb24b('0x9a')]){throw new db['Sequelize'][(_0xb24b('0x1e'))]('Invalid\x20body\x20format.\x20Use\x20oldPassord\x20and\x20newPassword');}if(!_0x328e39[_0xb24b('0x9b')](_0x5e5ce5[_0xb24b('0x69')][_0xb24b('0x99')])){throw new db[(_0xb24b('0x1d'))][(_0xb24b('0x1e'))](_0xb24b('0x9c'));}if(_0x5e5ce5[_0xb24b('0x69')][_0xb24b('0x99')]==_0x5e5ce5[_0xb24b('0x69')][_0xb24b('0x9a')]){throw new db['Sequelize'][(_0xb24b('0x1e'))](_0xb24b('0x9d'));}return _0x328e39;}else if(_0x5e5ce5[_0xb24b('0x92')][_0xb24b('0x3f')]=='admin'){if(!_0x5e5ce5[_0xb24b('0x69')]['newPassword']){throw new db[(_0xb24b('0x1d'))]['ValidationError'](_0xb24b('0x9e'));}return _0x328e39;}else if(_0x5e5ce5[_0xb24b('0x92')][_0xb24b('0x3f')]=='user'){if(!_0x5e5ce5[_0xb24b('0x69')][_0xb24b('0x9a')]){throw new db[(_0xb24b('0x1d'))][(_0xb24b('0x1e'))](_0xb24b('0x9e'));}if(_0x328e39[_0xb24b('0x3f')]!=_0xb24b('0x85')){throw new db[(_0xb24b('0x1d'))][(_0xb24b('0x1e'))]('Unauthorized');}return _0x328e39;}else{throw new db[(_0xb24b('0x1d'))][(_0xb24b('0x1e'))]('Unauthorized');}}return null;})['then'](handleEntityNotFound(_0x461f6e,null))[_0xb24b('0x21')](function(_0x36f89c){return checkPasswordPattern(_0x36f89c,_0x5e5ce5['body']['newPassword'],_0x13569a);})[_0xb24b('0x21')](saveUpdates({'password':_0x5e5ce5[_0xb24b('0x69')][_0xb24b('0x9a')],'passwordResetAt':_0x5e5ce5[_0xb24b('0x92')]['id']==_0x5e5ce5[_0xb24b('0x66')]['id']?moment():null},null))[_0xb24b('0x21')](respondWithResult(_0x461f6e,null))['catch'](handleError(_0x461f6e,null));};exports[_0xb24b('0x9f')]=function(_0x16561e,_0xaa68f4,_0x536558){var _0x30d517=_0x16561e[_0xb24b('0x69')][_0xb24b('0xa0')];return db[_0xb24b('0x60')]['find']({'where':{'id':_0x16561e['params']['id']},'attributes':['id','name',_0xb24b('0x3f'),'online',_0xb24b('0xa1'),_0xb24b('0xa2'),_0xb24b('0xa3')]})[_0xb24b('0x21')](handleEntityNotFound(_0xaa68f4,null))[_0xb24b('0x21')](function(_0x11abcc){if(_0x11abcc){if(!utils[_0xb24b('0xa4')](_0x30d517)){throw new db[(_0xb24b('0x1d'))][(_0xb24b('0x1e'))](_0xb24b('0xa5'));}return _0x11abcc[_0xb24b('0xa6')+_[_0xb24b('0xa7')](_0x30d517['toLowerCase']())+'Queues'](_0x16561e[_0xb24b('0x69')]['ids'],{'penalty':_0x16561e[_0xb24b('0x69')][_0xb24b('0xa8')]||0x0})[_0xb24b('0xa9')](function(_0x4b0f48){for(var _0x24d088=0x0;_0x24d088<_0x16561e[_0xb24b('0x69')]['ids'][_0xb24b('0xaa')];_0x24d088+=0x1){var _0x1af5c8={'UserId':_0x16561e[_0xb24b('0x66')]['id']};_0x1af5c8[_[_0xb24b('0xa7')](_0x30d517['toLowerCase']())+_0xb24b('0xab')]=_0x16561e['body'][_0xb24b('0x6c')][_0x24d088];socket[_0xb24b('0xac')]('user'+_['capitalize'](_0x30d517[_0xb24b('0xad')]())+_0xb24b('0xae'),_0x1af5c8);}return _0x4b0f48;})[_0xb24b('0x21')](function(){if(_0x30d517===_0xb24b('0xaf')){return db[_0xb24b('0xb0')][_0xb24b('0x63')]({'where':{'id':_0x16561e[_0xb24b('0x69')][_0xb24b('0x6c')]||[]},'raw':!![],'attributes':['id',_0xb24b('0x41')]});}})[_0xb24b('0x21')](function(_0x28e394){var _0x104fc9=_0x11abcc['get']({'plain':!![]});var _0x1c6b2c=[];if(_0x30d517==='voice'&&_0x104fc9[_0xb24b('0x3f')]==='agent'&&_0x104fc9[_0xb24b('0xb1')]){for(var _0x2307e4=0x0;_0x2307e4<_0x28e394[_0xb24b('0xaa')];_0x2307e4+=0x1){_0x1c6b2c[_0xb24b('0xb2')]({'membername':_0x104fc9['name'],'UserId':_0x104fc9['id'],'queue_name':_0x28e394[_0x2307e4]['name'],'VoiceQueueId':_0x28e394[_0x2307e4]['id'],'interface':_[_0xb24b('0x74')](_0x104fc9['interface'])?util['format'](_0xb24b('0xb3'),_0x104fc9[_0xb24b('0x41')]):_0x104fc9[_0xb24b('0xa3')],'paused':_0x104fc9[_0xb24b('0xa2')]||![],'penalty':_0x16561e[_0xb24b('0x69')][_0xb24b('0xa8')]||0x0});}return BPromise[_0xb24b('0xb4')](_0x1c6b2c,function(_0x325f0d){return db['UserVoiceQueueRt'][_0xb24b('0xb5')](_0x325f0d);});}return _0x11abcc;});}})[_0xb24b('0x21')](respondWithStatusCode(_0xaa68f4,null))['catch'](handleError(_0xaa68f4,null));};exports[_0xb24b('0xb6')]=function(_0x1b37e7,_0x506a38,_0xb71a06){var _0x51b083;return db[_0xb24b('0x60')]['find']({'where':{'id':_0x1b37e7[_0xb24b('0x66')]['id']},'attributes':['id','name','role']})['then'](handleEntityNotFound(_0x506a38,null))[_0xb24b('0x21')](function(_0x3f3d2c){if(_0x3f3d2c){_0x51b083=_0x3f3d2c;if(!_0x1b37e7[_0xb24b('0x4e')][_0xb24b('0xa0')]||!utils[_0xb24b('0xa4')](_0x1b37e7[_0xb24b('0x4e')][_0xb24b('0xa0')])){throw new db['Sequelize'][(_0xb24b('0x1e'))]('Unknown\x20channel');}return _0x3f3d2c['remove'+_[_0xb24b('0xa7')](_0x1b37e7['query'][_0xb24b('0xa0')][_0xb24b('0xad')]())+_0xb24b('0xb7')](_0x1b37e7['query'][_0xb24b('0x6c')]);}})[_0xb24b('0x21')](function(_0x3ce62d){for(var _0x62520c=0x0;_0x62520c<_0x1b37e7['query'][_0xb24b('0x6c')][_0xb24b('0xaa')];_0x62520c+=0x1){var _0x18df95={'UserId':_0x1b37e7[_0xb24b('0x66')]['id']};_0x18df95[_[_0xb24b('0xa7')](_0x1b37e7[_0xb24b('0x4e')][_0xb24b('0xa0')][_0xb24b('0xad')]())+_0xb24b('0xab')]=_0x1b37e7[_0xb24b('0x4e')][_0xb24b('0x6c')][_0x62520c];socket[_0xb24b('0xac')](_0xb24b('0x92')+_[_0xb24b('0xa7')](_0x1b37e7[_0xb24b('0x4e')][_0xb24b('0xa0')][_0xb24b('0xad')]())+_0xb24b('0xb8'),_0x18df95);}return _0x3ce62d;})[_0xb24b('0x21')](function(){if(_0x1b37e7[_0xb24b('0x4e')][_0xb24b('0xa0')]===_0xb24b('0xaf')){return db[_0xb24b('0xb9')][_0xb24b('0x43')]({'where':{'UserId':_0x1b37e7[_0xb24b('0x66')]['id'],'VoiceQueueId':_0x1b37e7[_0xb24b('0x4e')][_0xb24b('0x6c')]},'individualHooks':!![]})['then'](function(){return _0x51b083;});}return _0x51b083;})[_0xb24b('0x21')](respondWithStatusCode(_0x506a38,null))[_0xb24b('0x2b')](handleError(_0x506a38,null));};exports['addAvatar']=function(_0x55aa95,_0x47f4f4,_0x1fd17f){_0x55aa95[_0xb24b('0x69')][_0xb24b('0xba')]=_0x55aa95['file']['filename'];return db[_0xb24b('0x60')][_0xb24b('0x40')]({'where':{'id':_0x55aa95[_0xb24b('0x66')]['id']}})[_0xb24b('0x21')](handleEntityNotFound(_0x47f4f4,null))['then'](saveUpdates(_0x55aa95['body'],null))['then'](respondWithResult(_0x47f4f4,null))[_0xb24b('0x2b')](handleError(_0x47f4f4,null));};exports[_0xb24b('0xbb')]=function(_0x3bb947,_0x4cfaf8,_0x3da302){var _0x5c7337=path[_0xb24b('0xbc')](config[_0xb24b('0xbd')],_0xb24b('0xbe'));return db[_0xb24b('0x60')][_0xb24b('0x40')]({'where':{'id':_0x3bb947[_0xb24b('0x66')]['id']},'attributes':['id',_0xb24b('0xba')],'raw':!![]})[_0xb24b('0x21')](handleEntityNotFound(_0x4cfaf8,null))[_0xb24b('0x21')](function(_0xa0f0fe){if(_0xa0f0fe){if(_['isNil'](_0xa0f0fe[_0xb24b('0xba')])){return _0x4cfaf8[_0xb24b('0xbf')](_0x5c7337);}else{if(!fs[_0xb24b('0xc0')](path[_0xb24b('0xbc')](config[_0xb24b('0xbd')],_0xb24b('0xc1'),_0xa0f0fe[_0xb24b('0xba')]))){return _0x4cfaf8[_0xb24b('0xbf')](_0x5c7337);}return _0x4cfaf8[_0xb24b('0xbf')](path['join'](config[_0xb24b('0xbd')],_0xb24b('0xc1'),_0xa0f0fe[_0xb24b('0xba')]));}}})[_0xb24b('0x2b')](handleError(_0x4cfaf8,null));};exports[_0xb24b('0xc2')]=function(_0x1f674d,_0x57e294,_0x306631){var _0x229c0e={};var _0x2c26fd={};var _0x3f326a;var _0x34b101;return db[_0xb24b('0x60')][_0xb24b('0x98')]({'where':{'id':_0x1f674d[_0xb24b('0x66')]['id']}})[_0xb24b('0x21')](handleEntityNotFound(_0x57e294,null))[_0xb24b('0x21')](function(_0x2c5ac8){if(_0x2c5ac8){_0x3f326a=_0x2c5ac8;_0x2c26fd['model']=_[_0xb24b('0x4f')](db['CmContact'][_0xb24b('0x67')]);_0x2c26fd['query']=_['keys'](_0x1f674d['query']);_0x2c26fd[_0xb24b('0x50')]=_[_0xb24b('0x51')](_0x2c26fd[_0xb24b('0x4b')],_0x2c26fd[_0xb24b('0x4e')]);_0x229c0e[_0xb24b('0x53')]=_['intersection'](_0x2c26fd[_0xb24b('0x4b')],qs[_0xb24b('0x52')](_0x1f674d[_0xb24b('0x4e')][_0xb24b('0x52')]));_0x229c0e[_0xb24b('0x53')]=_0x229c0e['attributes']['length']?_0x229c0e[_0xb24b('0x53')]:_0x2c26fd[_0xb24b('0x4b')];_0x229c0e[_0xb24b('0x56')]=qs[_0xb24b('0x57')](_0x1f674d['query'][_0xb24b('0x57')]);_0x229c0e['where']=qs[_0xb24b('0x50')](_[_0xb24b('0x59')](_0x1f674d[_0xb24b('0x4e')],_0x2c26fd[_0xb24b('0x50')]));if(_0x1f674d[_0xb24b('0x4e')][_0xb24b('0x3c')]){_0x229c0e['where']=_[_0xb24b('0x5a')](_0x229c0e[_0xb24b('0x58')],{'$or':_[_0xb24b('0x47')](_0x229c0e[_0xb24b('0x53')],function(_0xb64cef){var _0x38486e={};_0x38486e[_0xb64cef]={'$like':'%'+_0x1f674d[_0xb24b('0x4e')][_0xb24b('0x3c')]+'%'};return _0x38486e;})});}_0x229c0e=_[_0xb24b('0x5a')]({},_0x229c0e,_0x1f674d['options']);return _0x3f326a[_0xb24b('0xc2')](_0x229c0e);}})['then'](function(_0x13f1f8){if(_0x13f1f8){_0x34b101=_0x13f1f8['length'];if(_0x1f674d['query'][_0xb24b('0x54')](_0xb24b('0x61'))){_0x229c0e[_0xb24b('0x62')]=[{'model':db[_0xb24b('0xc3')],'as':_0xb24b('0xc4'),'required':![]},{'model':db[_0xb24b('0xc5')],'as':_0xb24b('0xc6'),'attributes':['id',_0xb24b('0x41'),_0xb24b('0xc7')],'where':_0x1f674d['query'][_0xb24b('0xc8')]?{'id':_0x1f674d[_0xb24b('0x4e')][_0xb24b('0xc8')]}:undefined,'required':_0x1f674d[_0xb24b('0x4e')][_0xb24b('0xc8')]?!![]:![]}];}if(!_0x1f674d[_0xb24b('0x4e')][_0xb24b('0x54')](_0xb24b('0x55'))){_0x229c0e[_0xb24b('0x31')]=qs[_0xb24b('0x31')](_0x1f674d[_0xb24b('0x4e')]['limit']);_0x229c0e[_0xb24b('0x30')]=qs[_0xb24b('0x30')](_0x1f674d['query'][_0xb24b('0x30')]);}return _0x3f326a[_0xb24b('0xc2')](_0x229c0e);}})[_0xb24b('0x21')](function(_0x362728){if(_0x362728){return _0x362728?{'count':_0x34b101,'rows':_0x362728}:null;}})[_0xb24b('0x21')](respondWithResult(_0x57e294,null))[_0xb24b('0x2b')](handleError(_0x57e294,null));};exports[_0xb24b('0xc9')]=function(_0x434ab5,_0x3ffd32,_0x56aec9){var _0x31a7b2;var _0x3f9e0a;var _0x20cdf5={};var _0x2025ea;return db['User'][_0xb24b('0x98')]({'where':{'id':_0x434ab5[_0xb24b('0x66')]['id']},'attributes':['id',_0xb24b('0x41'),_0xb24b('0x3f')]})[_0xb24b('0x21')](handleEntityNotFound(_0x3ffd32,null))['then'](function(_0x9b80a7){if(!utils[_0xb24b('0xa4')](_0x434ab5[_0xb24b('0x4e')]['channel'])){throw new db['Sequelize'][(_0xb24b('0x1e'))]('Unknown\x20channel');}_0x31a7b2=_0x9b80a7;var _0x5453fb={};_0x5453fb['model']=_[_0xb24b('0x4f')](db[_[_0xb24b('0xa7')](_0x434ab5[_0xb24b('0x4e')][_0xb24b('0xa0')])+_0xb24b('0xca')][_0xb24b('0x67')]);_0x5453fb[_0xb24b('0x4e')]=_['keys'](_0x434ab5['query']);_0x5453fb[_0xb24b('0x50')]=_[_0xb24b('0x51')](_0x5453fb[_0xb24b('0x4b')],_0x5453fb[_0xb24b('0x4e')]);_0x20cdf5[_0xb24b('0x53')]=_['intersection'](_0x5453fb[_0xb24b('0x4b')],qs[_0xb24b('0x52')](_0x434ab5['query'][_0xb24b('0x52')]));_0x20cdf5[_0xb24b('0x53')]=_0x20cdf5['attributes'][_0xb24b('0xaa')]?_0x20cdf5[_0xb24b('0x53')]:_0x5453fb[_0xb24b('0x4b')];_0x20cdf5['order']=qs[_0xb24b('0x57')](_0x434ab5[_0xb24b('0x4e')][_0xb24b('0x57')]);_0x20cdf5['where']=qs[_0xb24b('0x50')](_[_0xb24b('0x59')](_0x434ab5[_0xb24b('0x4e')],_0x5453fb[_0xb24b('0x50')]));if(_0x434ab5['query']['filter']){_0x20cdf5['where']=_[_0xb24b('0x5a')](_0x20cdf5['where'],{'$or':_[_0xb24b('0x47')](_0x20cdf5[_0xb24b('0x53')],function(_0x4f11d2){var _0x3b17aa={};_0x3b17aa[_0x4f11d2]={'$like':'%'+_0x434ab5[_0xb24b('0x4e')][_0xb24b('0x3c')]+'%'};return _0x3b17aa;})});}_0x20cdf5=_[_0xb24b('0x5a')]({},_0x20cdf5,_0x434ab5['options']);switch(_0x31a7b2[_0xb24b('0x3f')]){case'admin':return db[_[_0xb24b('0xa7')](_0x434ab5['query'][_0xb24b('0xa0')])+'Queue'][_0xb24b('0x63')](_0x20cdf5);case'user':case'agent':return _0x31a7b2[_0xb24b('0x37')+_[_0xb24b('0xa7')](_0x434ab5[_0xb24b('0x4e')]['channel'])+_0xb24b('0xb7')](_0x20cdf5);default:throw new db[(_0xb24b('0x1d'))][(_0xb24b('0x1e'))](_0xb24b('0xcb'));}})[_0xb24b('0x21')](function(_0x2be155){_0x2025ea=_0x2be155[_0xb24b('0xaa')];if(!_0x434ab5[_0xb24b('0x4e')]['hasOwnProperty'](_0xb24b('0x55'))){_0x20cdf5[_0xb24b('0x31')]=qs[_0xb24b('0x31')](_0x434ab5[_0xb24b('0x4e')]['limit']);_0x20cdf5[_0xb24b('0x30')]=qs[_0xb24b('0x30')](_0x434ab5[_0xb24b('0x4e')][_0xb24b('0x30')]);}switch(_0x31a7b2[_0xb24b('0x3f')]){case'admin':return db[_[_0xb24b('0xa7')](_0x434ab5['query']['channel'])+_0xb24b('0xca')][_0xb24b('0x63')](_0x20cdf5);case _0xb24b('0x92'):case _0xb24b('0x85'):return _0x31a7b2[_0xb24b('0x37')+_[_0xb24b('0xa7')](_0x434ab5[_0xb24b('0x4e')][_0xb24b('0xa0')])+_0xb24b('0xb7')](_0x20cdf5);}})['then'](function(_0x3d69ca){return{'count':_0x2025ea,'rows':_0x3d69ca};})[_0xb24b('0x21')](respondWithResult(_0x3ffd32,null))['catch'](handleError(_0x3ffd32,null));};exports[_0xb24b('0xcc')]=function(_0x5c2e1d,_0x188352,_0x4f51c0){var _0x239951={};var _0x4a2cc1={};var _0x2bd655;var _0x503a1a;return db[_0xb24b('0x60')][_0xb24b('0x98')]({'where':{'id':_0x5c2e1d['params']['id']}})[_0xb24b('0x21')](handleEntityNotFound(_0x188352,null))['then'](function(_0x3e79db){if(_0x3e79db){_0x2bd655=_0x3e79db;_0x4a2cc1[_0xb24b('0x4b')]=_[_0xb24b('0x4f')](db[_0xb24b('0xb9')][_0xb24b('0x67')]);_0x4a2cc1[_0xb24b('0x4e')]=_[_0xb24b('0x4f')](_0x5c2e1d[_0xb24b('0x4e')]);_0x4a2cc1[_0xb24b('0x50')]=_[_0xb24b('0x51')](_0x4a2cc1['model'],_0x4a2cc1[_0xb24b('0x4e')]);_0x239951[_0xb24b('0x53')]=_['intersection'](_0x4a2cc1[_0xb24b('0x4b')],qs[_0xb24b('0x52')](_0x5c2e1d['query'][_0xb24b('0x52')]));_0x239951['attributes']=_0x239951['attributes'][_0xb24b('0xaa')]?_0x239951[_0xb24b('0x53')]:_0x4a2cc1[_0xb24b('0x4b')];_0x239951['order']=qs[_0xb24b('0x57')](_0x5c2e1d[_0xb24b('0x4e')][_0xb24b('0x57')]);_0x239951[_0xb24b('0x58')]=qs[_0xb24b('0x50')](_[_0xb24b('0x59')](_0x5c2e1d[_0xb24b('0x4e')],_0x4a2cc1[_0xb24b('0x50')]));if(_0x5c2e1d[_0xb24b('0x4e')][_0xb24b('0x3c')]){_0x239951[_0xb24b('0x58')]=_[_0xb24b('0x5a')](_0x239951['where'],{'$or':_['map'](_0x239951[_0xb24b('0x53')],function(_0x37163f){var _0xda96f1={};_0xda96f1[_0x37163f]={'$like':'%'+_0x5c2e1d[_0xb24b('0x4e')][_0xb24b('0x3c')]+'%'};return _0xda96f1;})});}_0x239951=_['merge']({},_0x239951,_0x5c2e1d[_0xb24b('0x5f')]);return _0x2bd655[_0xb24b('0xcc')](_0x239951);}})[_0xb24b('0x21')](function(_0x5df5cc){if(_0x5df5cc){_0x503a1a=_0x5df5cc['length'];if(!_0x5c2e1d[_0xb24b('0x4e')]['hasOwnProperty'](_0xb24b('0x55'))){_0x239951['limit']=qs[_0xb24b('0x31')](_0x5c2e1d[_0xb24b('0x4e')][_0xb24b('0x31')]);_0x239951[_0xb24b('0x30')]=qs[_0xb24b('0x30')](_0x5c2e1d[_0xb24b('0x4e')]['offset']);}return _0x2bd655[_0xb24b('0xcc')](_0x239951);}})[_0xb24b('0x21')](function(_0x4b9d54){if(_0x4b9d54){return _0x4b9d54?{'count':_0x503a1a,'rows':_0x4b9d54}:null;}})[_0xb24b('0x21')](respondWithResult(_0x188352,null))['catch'](handleError(_0x188352,null));};exports[_0xb24b('0xcd')]=function(_0x4c3b02,_0x33160a,_0x4e58e3){var _0x129627={};var _0x15d91a={};var _0x370d09;var _0x1fc1ca;return db[_0xb24b('0x60')][_0xb24b('0x98')]({'where':{'id':_0x4c3b02[_0xb24b('0x66')]['id']}})[_0xb24b('0x21')](handleEntityNotFound(_0x33160a,null))[_0xb24b('0x21')](function(_0x3d5a2b){if(_0x3d5a2b){_0x370d09=_0x3d5a2b;_0x15d91a[_0xb24b('0x4b')]=_[_0xb24b('0x4f')](db['ChatGroup']['rawAttributes']);_0x15d91a[_0xb24b('0x4e')]=_['keys'](_0x4c3b02[_0xb24b('0x4e')]);_0x15d91a[_0xb24b('0x50')]=_[_0xb24b('0x51')](_0x15d91a[_0xb24b('0x4b')],_0x15d91a[_0xb24b('0x4e')]);_0x129627[_0xb24b('0x53')]=_[_0xb24b('0x51')](_0x15d91a['model'],qs['fields'](_0x4c3b02[_0xb24b('0x4e')]['fields']));_0x129627[_0xb24b('0x53')]=_0x129627[_0xb24b('0x53')]['length']?_0x129627['attributes']:_0x15d91a[_0xb24b('0x4b')];_0x129627[_0xb24b('0x56')]=qs['sort'](_0x4c3b02[_0xb24b('0x4e')][_0xb24b('0x57')]);_0x129627['where']=qs['filters'](_[_0xb24b('0x59')](_0x4c3b02[_0xb24b('0x4e')],_0x15d91a[_0xb24b('0x50')]));if(_0x4c3b02[_0xb24b('0x4e')][_0xb24b('0x3c')]){_0x129627[_0xb24b('0x58')]=_['merge'](_0x129627[_0xb24b('0x58')],{'$or':_[_0xb24b('0x47')](_0x129627['attributes'],function(_0xe656e4){var _0x12286d={};_0x12286d[_0xe656e4]={'$like':'%'+_0x4c3b02[_0xb24b('0x4e')]['filter']+'%'};return _0x12286d;})});}_0x129627=_[_0xb24b('0x5a')]({},_0x129627,_0x4c3b02['options']);return _0x370d09[_0xb24b('0xcd')](_0x129627);}})[_0xb24b('0x21')](function(_0x305ed4){if(_0x305ed4){_0x1fc1ca=_0x305ed4[_0xb24b('0xaa')];if(!_0x4c3b02[_0xb24b('0x4e')][_0xb24b('0x54')](_0xb24b('0x55'))){_0x129627[_0xb24b('0x31')]=qs[_0xb24b('0x31')](_0x4c3b02[_0xb24b('0x4e')][_0xb24b('0x31')]);_0x129627[_0xb24b('0x30')]=qs[_0xb24b('0x30')](_0x4c3b02['query']['offset']);}return _0x370d09['getGroups'](_0x129627);}})[_0xb24b('0x21')](function(_0x1301e0){if(_0x1301e0){return _0x1301e0?{'count':_0x1fc1ca,'rows':_0x1301e0}:null;}})[_0xb24b('0x21')](respondWithResult(_0x33160a,null))[_0xb24b('0x2b')](handleError(_0x33160a,null));};exports['getRecordings']=function(_0x5519a9,_0x3bd478,_0x4aac63){var _0x3b714f={'raw':!![],'where':{}};var _0xdaae5a={};var _0x154248={'count':0x0,'rows':[]};return db[_0xb24b('0x60')]['findOne']({'where':{'id':_0x5519a9[_0xb24b('0x66')]['id']}})['then'](handleEntityNotFound(_0x3bd478,null))['then'](function(_0x5aad4d){if(_0x5aad4d){_0xdaae5a[_0xb24b('0x4b')]=_['keys'](db[_0xb24b('0xce')]['rawAttributes']);_0xdaae5a[_0xb24b('0x4e')]=_[_0xb24b('0x4f')](_0x5519a9['query']);_0xdaae5a[_0xb24b('0x50')]=_['intersection'](_0xdaae5a['model'],_0xdaae5a[_0xb24b('0x4e')]);_0x3b714f['attributes']=_[_0xb24b('0x51')](_0xdaae5a[_0xb24b('0x4b')],qs['fields'](_0x5519a9[_0xb24b('0x4e')][_0xb24b('0x52')]));_0x3b714f['attributes']=_0x3b714f[_0xb24b('0x53')][_0xb24b('0xaa')]?_0x3b714f[_0xb24b('0x53')]:_0xdaae5a['model'];if(!_0x5519a9[_0xb24b('0x4e')][_0xb24b('0x54')]('nolimit')){_0x3b714f[_0xb24b('0x31')]=qs[_0xb24b('0x31')](_0x5519a9[_0xb24b('0x4e')]['limit']);_0x3b714f['offset']=qs[_0xb24b('0x30')](_0x5519a9[_0xb24b('0x4e')]['offset']);}_0x3b714f[_0xb24b('0x56')]=qs[_0xb24b('0x57')](_0x5519a9[_0xb24b('0x4e')][_0xb24b('0x57')]);_0x3b714f['where']=qs[_0xb24b('0x50')](_[_0xb24b('0x59')](_0x5519a9[_0xb24b('0x4e')],_0xdaae5a[_0xb24b('0x50')]));_0x3b714f[_0xb24b('0x58')][_0xb24b('0xcf')]=_0x5aad4d['id'];if(_0x5519a9['query'][_0xb24b('0x3c')]){_0x3b714f[_0xb24b('0x58')]=_[_0xb24b('0x5a')](_0x3b714f[_0xb24b('0x58')],{'$or':_['map'](_0x3b714f[_0xb24b('0x53')],function(_0xa13311){var _0x68c1c3={};_0x68c1c3[_0xa13311]={'$like':'%'+_0x5519a9[_0xb24b('0x4e')]['filter']+'%'};return _0x68c1c3;})});}_0x3b714f=_[_0xb24b('0x5a')]({},_0x3b714f,_0x5519a9['options']);return db[_0xb24b('0xce')][_0xb24b('0x2f')]({'where':_0x3b714f[_0xb24b('0x58')]})[_0xb24b('0x21')](function(_0x46592b){_0x154248[_0xb24b('0x2f')]=_0x46592b;if(_0x5519a9[_0xb24b('0x4e')]['includeAll']){_0x3b714f[_0xb24b('0x62')]=[{'all':!![]}];}return db[_0xb24b('0xce')]['findAll'](_0x3b714f);})[_0xb24b('0x21')](function(_0x3ea4ee){_0x154248[_0xb24b('0x64')]=_0x3ea4ee;return _0x154248;});}})['then'](respondWithFilteredResult(_0x3bd478,_0x3b714f))['catch'](handleError(_0x3bd478,null));};exports[_0xb24b('0xd0')]=function(_0x582295,_0xc2fa98,_0x1df404){var _0x91192d={'raw':!![],'where':{}};var _0x5ba7f9={};var _0x985785={'count':0x0,'rows':[]};return db[_0xb24b('0x60')][_0xb24b('0x98')]({'where':{'id':_0x582295[_0xb24b('0x66')]['id']}})[_0xb24b('0x21')](handleEntityNotFound(_0xc2fa98,null))[_0xb24b('0x21')](function(_0x36b10a){if(_0x36b10a){_0x5ba7f9[_0xb24b('0x4b')]=_['keys'](db[_0xb24b('0xd1')]['rawAttributes']);_0x5ba7f9[_0xb24b('0x4e')]=_['keys'](_0x582295[_0xb24b('0x4e')]);_0x5ba7f9['filters']=_['intersection'](_0x5ba7f9[_0xb24b('0x4b')],_0x5ba7f9['query']);_0x91192d[_0xb24b('0x53')]=_[_0xb24b('0x51')](_0x5ba7f9[_0xb24b('0x4b')],qs[_0xb24b('0x52')](_0x582295[_0xb24b('0x4e')][_0xb24b('0x52')]));_0x91192d['attributes']=_0x91192d[_0xb24b('0x53')][_0xb24b('0xaa')]?_0x91192d['attributes']:_0x5ba7f9[_0xb24b('0x4b')];if(!_0x582295['query'][_0xb24b('0x54')](_0xb24b('0x55'))){_0x91192d[_0xb24b('0x31')]=qs[_0xb24b('0x31')](_0x582295[_0xb24b('0x4e')][_0xb24b('0x31')]);_0x91192d[_0xb24b('0x30')]=qs[_0xb24b('0x30')](_0x582295['query'][_0xb24b('0x30')]);}_0x91192d[_0xb24b('0x56')]=qs[_0xb24b('0x57')](_0x582295[_0xb24b('0x4e')]['sort']);_0x91192d[_0xb24b('0x58')]=qs['filters'](_['pick'](_0x582295[_0xb24b('0x4e')],_0x5ba7f9[_0xb24b('0x50')]));_0x91192d[_0xb24b('0x58')][_0xb24b('0xcf')]=_0x36b10a['id'];if(_0x582295[_0xb24b('0x4e')][_0xb24b('0x3c')]){_0x91192d[_0xb24b('0x58')]=_[_0xb24b('0x5a')](_0x91192d[_0xb24b('0x58')],{'$or':_[_0xb24b('0x47')](_0x91192d[_0xb24b('0x53')],function(_0x120fff){var _0x25e0be={};_0x25e0be[_0x120fff]={'$like':'%'+_0x582295[_0xb24b('0x4e')][_0xb24b('0x3c')]+'%'};return _0x25e0be;})});}_0x91192d=_[_0xb24b('0x5a')]({},_0x91192d,_0x582295[_0xb24b('0x5f')]);return db[_0xb24b('0xd1')][_0xb24b('0x2f')]({'where':_0x91192d[_0xb24b('0x58')]})[_0xb24b('0x21')](function(_0x2f4e10){_0x985785[_0xb24b('0x2f')]=_0x2f4e10;if(_0x582295[_0xb24b('0x4e')]['includeAll']){_0x91192d[_0xb24b('0x62')]=[{'all':!![]}];}return db[_0xb24b('0xd1')]['findAll'](_0x91192d);})[_0xb24b('0x21')](function(_0x5f1f2c){_0x985785[_0xb24b('0x64')]=_0x5f1f2c;return _0x985785;});}})[_0xb24b('0x21')](respondWithFilteredResult(_0xc2fa98,_0x91192d))['catch'](handleError(_0xc2fa98,null));};exports[_0xb24b('0xd2')]=function(_0x2aaf39,_0x15b09f,_0x43459b){var _0x23f591={};var _0x31ca53={};var _0x71e014;var _0x333bef;return db[_0xb24b('0x60')][_0xb24b('0x98')]({'where':{'id':_0x2aaf39[_0xb24b('0x66')]['id']}})['then'](handleEntityNotFound(_0x15b09f,null))[_0xb24b('0x21')](function(_0x265b82){if(_0x265b82){_0x71e014=_0x265b82;_0x31ca53[_0xb24b('0x4b')]=_[_0xb24b('0x4f')](db['ChatInteraction'][_0xb24b('0x67')]);_0x31ca53[_0xb24b('0x4e')]=_[_0xb24b('0x4f')](_0x2aaf39[_0xb24b('0x4e')]);_0x31ca53[_0xb24b('0x50')]=_[_0xb24b('0x51')](_0x31ca53[_0xb24b('0x4b')],_0x31ca53[_0xb24b('0x4e')]);_0x23f591[_0xb24b('0x53')]=_[_0xb24b('0x51')](_0x31ca53[_0xb24b('0x4b')],qs[_0xb24b('0x52')](_0x2aaf39[_0xb24b('0x4e')]['fields']));_0x23f591[_0xb24b('0x53')]=_0x23f591[_0xb24b('0x53')][_0xb24b('0xaa')]?_0x23f591[_0xb24b('0x53')]:_0x31ca53['model'];_0x23f591[_0xb24b('0x56')]=qs['sort'](_0x2aaf39[_0xb24b('0x4e')][_0xb24b('0x57')]);_0x23f591[_0xb24b('0x58')]=qs[_0xb24b('0x50')](_[_0xb24b('0x59')](_0x2aaf39[_0xb24b('0x4e')],_0x31ca53[_0xb24b('0x50')]));if(_0x2aaf39['query'][_0xb24b('0x3c')]){_0x23f591[_0xb24b('0x58')]=_[_0xb24b('0x5a')](_0x23f591['where'],{'$or':_[_0xb24b('0x47')](_0x23f591[_0xb24b('0x53')],function(_0x384556){var _0x3d22e6={};_0x3d22e6[_0x384556]={'$like':'%'+_0x2aaf39[_0xb24b('0x4e')][_0xb24b('0x3c')]+'%'};return _0x3d22e6;})});}_0x23f591=_[_0xb24b('0x5a')]({},_0x23f591,_0x2aaf39['options']);return _0x71e014['getChatInteractions'](_0x23f591);}})[_0xb24b('0x21')](function(_0x5b2cb3){if(_0x5b2cb3){_0x333bef=_0x5b2cb3[_0xb24b('0xaa')];if(!_0x2aaf39[_0xb24b('0x4e')][_0xb24b('0x54')](_0xb24b('0x55'))){_0x23f591[_0xb24b('0x31')]=qs[_0xb24b('0x31')](_0x2aaf39[_0xb24b('0x4e')][_0xb24b('0x31')]);_0x23f591[_0xb24b('0x30')]=qs[_0xb24b('0x30')](_0x2aaf39[_0xb24b('0x4e')][_0xb24b('0x30')]);}return _0x71e014[_0xb24b('0xd2')](_0x23f591);}})[_0xb24b('0x21')](function(_0x194093){if(_0x194093){return _0x194093?{'count':_0x333bef,'rows':_0x194093}:null;}})['then'](respondWithResult(_0x15b09f,null))[_0xb24b('0x2b')](handleError(_0x15b09f,null));};exports[_0xb24b('0xd3')]=function(_0x287f7d,_0x41f7f5,_0x9b6f99){var _0x517fa1={};var _0xec2f1e={};var _0x3f903c;var _0x19d4ff;return db[_0xb24b('0x60')][_0xb24b('0x98')]({'where':{'id':_0x287f7d['params']['id']}})['then'](handleEntityNotFound(_0x41f7f5,null))['then'](function(_0x285dc8){if(_0x285dc8){_0x3f903c=_0x285dc8;_0xec2f1e['model']=_['keys'](db['OpenchannelInteraction'][_0xb24b('0x67')]);_0xec2f1e[_0xb24b('0x4e')]=_[_0xb24b('0x4f')](_0x287f7d['query']);_0xec2f1e[_0xb24b('0x50')]=_['intersection'](_0xec2f1e[_0xb24b('0x4b')],_0xec2f1e[_0xb24b('0x4e')]);_0x517fa1[_0xb24b('0x53')]=_[_0xb24b('0x51')](_0xec2f1e['model'],qs[_0xb24b('0x52')](_0x287f7d[_0xb24b('0x4e')]['fields']));_0x517fa1[_0xb24b('0x53')]=_0x517fa1[_0xb24b('0x53')][_0xb24b('0xaa')]?_0x517fa1[_0xb24b('0x53')]:_0xec2f1e[_0xb24b('0x4b')];_0x517fa1['order']=qs['sort'](_0x287f7d[_0xb24b('0x4e')][_0xb24b('0x57')]);_0x517fa1[_0xb24b('0x58')]=qs[_0xb24b('0x50')](_[_0xb24b('0x59')](_0x287f7d[_0xb24b('0x4e')],_0xec2f1e['filters']));if(_0x287f7d[_0xb24b('0x4e')][_0xb24b('0x3c')]){_0x517fa1['where']=_[_0xb24b('0x5a')](_0x517fa1[_0xb24b('0x58')],{'$or':_['map'](_0x517fa1[_0xb24b('0x53')],function(_0x1d8e53){var _0x47a454={};_0x47a454[_0x1d8e53]={'$like':'%'+_0x287f7d[_0xb24b('0x4e')][_0xb24b('0x3c')]+'%'};return _0x47a454;})});}_0x517fa1=_[_0xb24b('0x5a')]({},_0x517fa1,_0x287f7d['options']);return _0x3f903c[_0xb24b('0xd3')](_0x517fa1);}})[_0xb24b('0x21')](function(_0x282f77){if(_0x282f77){_0x19d4ff=_0x282f77[_0xb24b('0xaa')];if(!_0x287f7d[_0xb24b('0x4e')][_0xb24b('0x54')](_0xb24b('0x55'))){_0x517fa1['limit']=qs['limit'](_0x287f7d[_0xb24b('0x4e')]['limit']);_0x517fa1[_0xb24b('0x30')]=qs[_0xb24b('0x30')](_0x287f7d['query'][_0xb24b('0x30')]);}return _0x3f903c['getOpenchannelInteractions'](_0x517fa1);}})[_0xb24b('0x21')](function(_0x28d5d3){if(_0x28d5d3){return _0x28d5d3?{'count':_0x19d4ff,'rows':_0x28d5d3}:null;}})[_0xb24b('0x21')](respondWithResult(_0x41f7f5,null))[_0xb24b('0x2b')](handleError(_0x41f7f5,null));};exports[_0xb24b('0xd4')]=function(_0x367512,_0x41e3b6,_0x59ce81){var _0x55976a={'raw':!![],'where':{}};var _0x368282={};var _0x28b80b={'count':0x0,'rows':[]};return db['User'][_0xb24b('0x98')]({'where':{'id':_0x367512[_0xb24b('0x66')]['id']}})[_0xb24b('0x21')](handleEntityNotFound(_0x41e3b6,null))[_0xb24b('0x21')](function(_0x9a764c){if(_0x9a764c){_0x368282[_0xb24b('0x4b')]=_[_0xb24b('0x4f')](db[_0xb24b('0xd5')][_0xb24b('0x67')]);_0x368282[_0xb24b('0x4e')]=_[_0xb24b('0x4f')](_0x367512['query']);_0x368282[_0xb24b('0x50')]=_[_0xb24b('0x51')](_0x368282[_0xb24b('0x4b')],_0x368282[_0xb24b('0x4e')]);_0x55976a['attributes']=_[_0xb24b('0x51')](_0x368282[_0xb24b('0x4b')],qs['fields'](_0x367512[_0xb24b('0x4e')][_0xb24b('0x52')]));_0x55976a[_0xb24b('0x53')]=_0x55976a['attributes']['length']?_0x55976a['attributes']:_0x368282[_0xb24b('0x4b')];if(!_0x367512[_0xb24b('0x4e')][_0xb24b('0x54')](_0xb24b('0x55'))){_0x55976a['limit']=qs['limit'](_0x367512['query'][_0xb24b('0x31')]);_0x55976a['offset']=qs[_0xb24b('0x30')](_0x367512[_0xb24b('0x4e')][_0xb24b('0x30')]);}_0x55976a[_0xb24b('0x56')]=qs[_0xb24b('0x57')](_0x367512[_0xb24b('0x4e')][_0xb24b('0x57')]);_0x55976a[_0xb24b('0x58')]=qs[_0xb24b('0x50')](_[_0xb24b('0x59')](_0x367512[_0xb24b('0x4e')],_0x368282['filters']));_0x55976a[_0xb24b('0x58')]['UserId']=_0x9a764c['id'];if(_0x367512[_0xb24b('0x4e')][_0xb24b('0x3c')]){_0x55976a[_0xb24b('0x58')]=_['merge'](_0x55976a[_0xb24b('0x58')],{'$or':_['map'](_0x55976a[_0xb24b('0x53')],function(_0x2cccaf){var _0x111575={};_0x111575[_0x2cccaf]={'$like':'%'+_0x367512[_0xb24b('0x4e')][_0xb24b('0x3c')]+'%'};return _0x111575;})});}_0x55976a=_[_0xb24b('0x5a')]({},_0x55976a,_0x367512['options']);return db[_0xb24b('0xd5')][_0xb24b('0x2f')]({'where':_0x55976a[_0xb24b('0x58')]})[_0xb24b('0x21')](function(_0x19db22){_0x28b80b[_0xb24b('0x2f')]=_0x19db22;if(_0x367512[_0xb24b('0x4e')][_0xb24b('0x61')]){_0x55976a[_0xb24b('0x62')]=[{'all':!![]}];}return db[_0xb24b('0xd5')][_0xb24b('0x63')](_0x55976a);})['then'](function(_0x1bd96d){_0x28b80b[_0xb24b('0x64')]=_0x1bd96d;return _0x28b80b;});}})[_0xb24b('0x21')](respondWithFilteredResult(_0x41e3b6,_0x55976a))['catch'](handleError(_0x41e3b6,null));};exports[_0xb24b('0xd6')]=function(_0x5dc12d,_0x1e2586,_0x45cbcd){var _0x2d88ac={};var _0x30fd63={};var _0x4e1b3d;var _0x327e28;return db['User'][_0xb24b('0x98')]({'where':{'id':_0x5dc12d[_0xb24b('0x66')]['id']}})['then'](handleEntityNotFound(_0x1e2586,null))['then'](function(_0x58525b){if(_0x58525b){_0x4e1b3d=_0x58525b;_0x30fd63[_0xb24b('0x4b')]=_[_0xb24b('0x4f')](db[_0xb24b('0xd7')][_0xb24b('0x67')]);_0x30fd63[_0xb24b('0x4e')]=_[_0xb24b('0x4f')](_0x5dc12d[_0xb24b('0x4e')]);_0x30fd63[_0xb24b('0x50')]=_['intersection'](_0x30fd63[_0xb24b('0x4b')],_0x30fd63['query']);_0x2d88ac[_0xb24b('0x53')]=_[_0xb24b('0x51')](_0x30fd63[_0xb24b('0x4b')],qs[_0xb24b('0x52')](_0x5dc12d[_0xb24b('0x4e')][_0xb24b('0x52')]));_0x2d88ac['attributes']=_0x2d88ac[_0xb24b('0x53')][_0xb24b('0xaa')]?_0x2d88ac[_0xb24b('0x53')]:_0x30fd63[_0xb24b('0x4b')];_0x2d88ac['order']=qs[_0xb24b('0x57')](_0x5dc12d[_0xb24b('0x4e')][_0xb24b('0x57')]);_0x2d88ac['where']=qs['filters'](_[_0xb24b('0x59')](_0x5dc12d[_0xb24b('0x4e')],_0x30fd63['filters']));if(_0x5dc12d['query']['filter']){_0x2d88ac[_0xb24b('0x58')]=_[_0xb24b('0x5a')](_0x2d88ac[_0xb24b('0x58')],{'$or':_['map'](_0x2d88ac[_0xb24b('0x53')],function(_0x30ef35){var _0x11e873={};_0x11e873[_0x30ef35]={'$like':'%'+_0x5dc12d[_0xb24b('0x4e')][_0xb24b('0x3c')]+'%'};return _0x11e873;})});}_0x2d88ac=_[_0xb24b('0x5a')]({},_0x2d88ac,_0x5dc12d[_0xb24b('0x5f')]);return _0x4e1b3d[_0xb24b('0xd6')](_0x2d88ac);}})[_0xb24b('0x21')](function(_0x21a017){if(_0x21a017){_0x327e28=_0x21a017['length'];if(!_0x5dc12d[_0xb24b('0x4e')][_0xb24b('0x54')](_0xb24b('0x55'))){_0x2d88ac[_0xb24b('0x31')]=qs[_0xb24b('0x31')](_0x5dc12d[_0xb24b('0x4e')]['limit']);_0x2d88ac[_0xb24b('0x30')]=qs[_0xb24b('0x30')](_0x5dc12d['query'][_0xb24b('0x30')]);}return _0x4e1b3d[_0xb24b('0xd6')](_0x2d88ac);}})[_0xb24b('0x21')](function(_0xb6b445){if(_0xb6b445){return _0xb6b445?{'count':_0x327e28,'rows':_0xb6b445}:null;}})[_0xb24b('0x21')](respondWithResult(_0x1e2586,null))['catch'](handleError(_0x1e2586,null));};exports['getFaxInteractions']=function(_0x512999,_0x452414,_0x127946){var _0x39c6f5={};var _0x2573c2={};var _0x59165e;var _0x28ffd5;return db[_0xb24b('0x60')]['findOne']({'where':{'id':_0x512999[_0xb24b('0x66')]['id']}})[_0xb24b('0x21')](handleEntityNotFound(_0x452414,null))['then'](function(_0x2fec11){if(_0x2fec11){_0x59165e=_0x2fec11;_0x2573c2['model']=_[_0xb24b('0x4f')](db['FaxInteraction'][_0xb24b('0x67')]);_0x2573c2[_0xb24b('0x4e')]=_[_0xb24b('0x4f')](_0x512999[_0xb24b('0x4e')]);_0x2573c2['filters']=_[_0xb24b('0x51')](_0x2573c2[_0xb24b('0x4b')],_0x2573c2[_0xb24b('0x4e')]);_0x39c6f5['attributes']=_[_0xb24b('0x51')](_0x2573c2[_0xb24b('0x4b')],qs['fields'](_0x512999[_0xb24b('0x4e')][_0xb24b('0x52')]));_0x39c6f5[_0xb24b('0x53')]=_0x39c6f5[_0xb24b('0x53')][_0xb24b('0xaa')]?_0x39c6f5[_0xb24b('0x53')]:_0x2573c2[_0xb24b('0x4b')];_0x39c6f5[_0xb24b('0x56')]=qs[_0xb24b('0x57')](_0x512999['query'][_0xb24b('0x57')]);_0x39c6f5['where']=qs[_0xb24b('0x50')](_[_0xb24b('0x59')](_0x512999[_0xb24b('0x4e')],_0x2573c2['filters']));if(_0x512999['query'][_0xb24b('0x3c')]){_0x39c6f5['where']=_['merge'](_0x39c6f5[_0xb24b('0x58')],{'$or':_['map'](_0x39c6f5[_0xb24b('0x53')],function(_0x3ff649){var _0x30c753={};_0x30c753[_0x3ff649]={'$like':'%'+_0x512999[_0xb24b('0x4e')]['filter']+'%'};return _0x30c753;})});}_0x39c6f5=_[_0xb24b('0x5a')]({},_0x39c6f5,_0x512999[_0xb24b('0x5f')]);return _0x59165e[_0xb24b('0xd8')](_0x39c6f5);}})[_0xb24b('0x21')](function(_0x45abad){if(_0x45abad){_0x28ffd5=_0x45abad[_0xb24b('0xaa')];if(!_0x512999[_0xb24b('0x4e')][_0xb24b('0x54')](_0xb24b('0x55'))){_0x39c6f5[_0xb24b('0x31')]=qs[_0xb24b('0x31')](_0x512999['query'][_0xb24b('0x31')]);_0x39c6f5['offset']=qs['offset'](_0x512999[_0xb24b('0x4e')]['offset']);}return _0x59165e[_0xb24b('0xd8')](_0x39c6f5);}})['then'](function(_0x1badb2){if(_0x1badb2){return _0x1badb2?{'count':_0x28ffd5,'rows':_0x1badb2}:null;}})[_0xb24b('0x21')](respondWithResult(_0x452414,null))[_0xb24b('0x2b')](handleError(_0x452414,null));};exports['login']=function(_0x200129,_0x59d28b,_0x16eef3){var _0x267b98;var _0x3e56d4;var _0x10ce86;var _0xe504d8=!_[_0xb24b('0x74')](_0x200129[_0xb24b('0x66')]['id'])?_0x200129[_0xb24b('0x66')]['id']:!_[_0xb24b('0x74')](_0x200129['user']['id'])?_0x200129[_0xb24b('0x92')]['id']:null;return db[_0xb24b('0x60')][_0xb24b('0x40')]({'where':{'id':_0xe504d8,'role':{'$or':[_0xb24b('0x6f'),_0xb24b('0x92'),'agent']}},'attributes':['id',_0xb24b('0x41'),_0xb24b('0xd9'),_0xb24b('0xda'),'role',_0xb24b('0x79'),_0xb24b('0xa1')]})[_0xb24b('0x21')](function(_0x37cbad){if(_0x37cbad){if(_0x37cbad[_0xb24b('0x3f')]===_0xb24b('0x85')){_0x267b98=_0x37cbad;if(_0x200129[_0xb24b('0x69')][_0xb24b('0xa3')]){_0x10ce86=util[_0xb24b('0x76')](_0xb24b('0xdb'),_0x267b98[_0x200129[_0xb24b('0x69')][_0xb24b('0xa3')]]);}else if(_0x200129[_0xb24b('0x69')][_0xb24b('0xdc')]){_0x10ce86=util[_0xb24b('0x76')](_0xb24b('0xb3'),_0x200129[_0xb24b('0x69')]['intrf']);}else{_0x10ce86=util[_0xb24b('0x76')](_0xb24b('0xb3'),_0x267b98['name']);}socket['to'](util[_0xb24b('0x76')](_0xb24b('0xdd'),_0x267b98[_0xb24b('0x41')]))['emit'](_0xb24b('0xde'),{'ip':_0x200129[_0xb24b('0xdf')][_0xb24b('0xe0')]||_0x200129[_0xb24b('0xe1')][_0xb24b('0xe2')]||_0x200129[_0xb24b('0xe3')][_0xb24b('0xe2')]||_0x200129[_0xb24b('0xe1')][_0xb24b('0xe3')][_0xb24b('0xe2')]});return db[_0xb24b('0xb9')]['destroy']({'where':{'membername':_0x267b98['name']},'individualHooks':!![]});}}else{throw new db[(_0xb24b('0x1d'))][(_0xb24b('0x1e'))](_0xb24b('0xe4'));}})[_0xb24b('0x21')](function(){if(_0x267b98){return _0x267b98['getVoiceQueues']({'raw':!![]});}})['then'](function(_0x34c522){if(_0x267b98){var _0x426625=[];if(_0x34c522){_0x3e56d4=_0x34c522;if(_0x3e56d4[_0xb24b('0xaa')]){for(var _0x3e053e=0x0;_0x3e053e<_0x3e56d4['length'];_0x3e053e++){_0x426625['push']({'membername':_0x267b98[_0xb24b('0x41')],'UserId':_0x267b98['id'],'queue_name':_0x3e56d4[_0x3e053e][_0xb24b('0x41')],'VoiceQueueId':_0x3e56d4[_0x3e053e]['id'],'interface':_0x10ce86,'paused':_0x267b98[_0xb24b('0xa1')]||![],'penalty':_0x3e56d4[_0x3e053e]['UserVoiceQueue.penalty']||0x0});}return BPromise[_0xb24b('0xb4')](_0x426625,function(_0x5d321f){return db[_0xb24b('0xb9')][_0xb24b('0xb5')](_0x5d321f);});}}}})['then'](function(){if(_0x267b98){return db[_0xb24b('0xe5')][_0xb24b('0x63')]({'where':{'membername':_0x267b98['name'],'exitAt':null}});}})[_0xb24b('0x21')](function(_0x1b8395){if(_0x267b98){var _0x24454b=[];_0x1b8395[_0xb24b('0xe6')](function(_0x1a76ad){_0x24454b[_0xb24b('0xb2')](_0x1a76ad[_0xb24b('0x36')]({'exitAt':moment()[_0xb24b('0x76')](_0xb24b('0xe7'))}));});return BPromise[_0xb24b('0xe8')](_0x24454b);}})[_0xb24b('0x21')](function(){if(_0x267b98){var _0x286b65=[];var _0x4b47b1=[];var _0xa1549e=utils['getChannels']();var _0x5beac2={'membername':_0x267b98['name'],'interface':_0x10ce86,'enterAt':moment()[_0xb24b('0x76')]('YYYY-MM-DD\x20HH:mm:ss'),'role':_0x267b98[_0xb24b('0x3f')],'internal':_0x267b98[_0xb24b('0x79')]};_0xa1549e[_0xb24b('0xe6')](function(_0x228ec6){_0x286b65['push'](_[_0xb24b('0x5a')]({'channel':_0x228ec6,'type':_0xb24b('0xe9'),'data1':_0x200129[_0xb24b('0x69')][_0xb24b('0xea')],'data2':_0x10ce86},_0x5beac2));if(_0x267b98[_0xb24b('0xa1')]){_0x4b47b1[_0xb24b('0xb2')](_[_0xb24b('0x5a')]({'channel':_0x228ec6,'type':_0xb24b('0xeb'),'data1':'LOGININPAUSE'},_0x5beac2));}});return db[_0xb24b('0xe5')][_0xb24b('0x68')](_0x286b65['concat'](_0x4b47b1),{'individualHooks':!![]});}})[_0xb24b('0x21')](function(){if(_0x267b98){return _0x267b98[_0xb24b('0x36')]({'online':!![],'lastLoginAt':moment()[_0xb24b('0x76')](_0xb24b('0xe7')),'voicePause':_0x267b98[_0xb24b('0xa1')]||![],'mailPause':_0x267b98['loginInPause']||![],'chatPause':_0x267b98['loginInPause']||![],'faxPause':_0x267b98[_0xb24b('0xa1')]||![],'smsPause':_0x267b98[_0xb24b('0xa1')]||![],'openchannelPause':_0x267b98[_0xb24b('0xa1')]||![],'pauseType':_0x267b98[_0xb24b('0xa1')]?_0xb24b('0xec'):null,'interface':_0x10ce86,'lastPauseAt':moment()[_0xb24b('0x76')]('YYYY-MM-DD\x20HH:mm:ss')});}})[_0xb24b('0x21')](function(_0x48390e){if(_0x200129['isMiddleware']){return _0x16eef3();}else{return BPromise[_0xb24b('0xed')](_0x48390e)['then'](respondWithResult(_0x59d28b,null));}})[_0xb24b('0x2b')](handleError(_0x59d28b,null));};exports[_0xb24b('0xee')]=function(_0x4f3a8b,_0x16359b,_0x4a3fe5){var _0x56cf78;return db[_0xb24b('0x60')][_0xb24b('0x40')]({'where':{'id':_0x4f3a8b[_0xb24b('0x66')]['id'],'role':_0xb24b('0x85')},'attributes':['id','name',_0xb24b('0x3f')]})[_0xb24b('0x21')](handleEntityNotFound(_0x16359b,null))[_0xb24b('0x21')](function(_0x343003){if(_0x343003){_0x56cf78=_0x343003;return db[_0xb24b('0xb9')][_0xb24b('0x43')]({'where':{'membername':_0x56cf78[_0xb24b('0x41')]},'individualHooks':!![]});}})['then'](function(){return db[_0xb24b('0xe5')][_0xb24b('0x63')]({'where':{'membername':_0x56cf78[_0xb24b('0x41')],'exitAt':null}});})[_0xb24b('0x21')](function(_0x17b3c1){var _0x2ea0a0=[];_0x17b3c1[_0xb24b('0xe6')](function(_0x773416){_0x2ea0a0[_0xb24b('0xb2')](_0x773416['update']({'exitAt':moment()[_0xb24b('0x76')](_0xb24b('0xe7'))}));});return BPromise[_0xb24b('0xe8')](_0x2ea0a0);})[_0xb24b('0x21')](function(){return _0x56cf78[_0xb24b('0x36')]({'online':![],'lastLoginAt':null,'voicePause':![],'mailPause':![],'chatPause':![],'faxPause':![],'smsPause':![],'openchannelPause':![],'interface':null});})[_0xb24b('0x21')](respondWithResult(_0x16359b,null))['catch'](handleError(_0x16359b,null));};exports['pause']=function(_0x4d7501,_0x571c75,_0x29094a){var _0xb503b8;return db[_0xb24b('0xb9')][_0xb24b('0x36')]({'paused':0x1},{'where':{'UserId':_0x4d7501[_0xb24b('0x66')]['id']},'individualHooks':!![]})[_0xb24b('0x21')](function(){return db['User'][_0xb24b('0x40')]({'where':{'id':_0x4d7501[_0xb24b('0x66')]['id'],'role':'agent'},'attributes':['id',_0xb24b('0x41'),_0xb24b('0x3f'),_0xb24b('0x79'),'interface']});})['then'](handleEntityNotFound(_0x571c75,null))[_0xb24b('0x21')](function(_0x47a66d){if(_0x47a66d){_0xb503b8=_0x47a66d;return respondWithRpcPromise(_0xb24b('0xef'),_0xb24b('0xf0'),{'id':_0xb503b8['id'],'name':_0xb503b8['name'],'pause':!![]});}})['then'](function(){if(_0xb503b8){return db[_0xb24b('0xe5')][_0xb24b('0x63')]({'where':{'membername':_0xb503b8[_0xb24b('0x41')],'type':_0xb24b('0xeb'),'exitAt':null}});}})[_0xb24b('0x21')](function(_0x26f4f2){if(_0x26f4f2[_0xb24b('0xaa')]){var _0x314228=moment()[_0xb24b('0x76')](_0xb24b('0xe7'));for(var _0x3d9287=0x0,_0x213b9b=_0x26f4f2[_0xb24b('0xaa')];_0x3d9287<_0x213b9b;_0x3d9287++){_0x26f4f2[_0x3d9287]['updateAttributes']({'exitAt':_0x314228});}}})[_0xb24b('0x21')](function(){var _0x3c3f06=[];var _0x24e850=utils[_0xb24b('0xf1')]();_0x24e850[_0xb24b('0xe6')](function(_0x4f2bc5){_0x3c3f06[_0xb24b('0xb2')]({'channel':_0x4f2bc5,'membername':_0xb503b8[_0xb24b('0x41')],'interface':_['isNil'](_0xb503b8['interface'])?util[_0xb24b('0x76')]('SIP/%s',_0xb503b8[_0xb24b('0x41')]):_0xb503b8[_0xb24b('0xa3')],'type':_0xb24b('0xeb'),'enterAt':moment()[_0xb24b('0x76')]('YYYY-MM-DD\x20HH:mm:ss'),'data1':_0x4d7501[_0xb24b('0x69')][_0xb24b('0x49')]||'DEFAULT\x20PAUSE','role':_0xb503b8[_0xb24b('0x3f')],'internal':_0xb503b8[_0xb24b('0x79')]});});return db[_0xb24b('0xe5')][_0xb24b('0x68')](_0x3c3f06,{'individualHooks':!![]});})[_0xb24b('0x21')](function(){return _0xb503b8['update']({'voicePause':!![],'mailPause':!![],'chatPause':!![],'faxPause':!![],'smsPause':!![],'openchannelPause':!![],'pauseType':_0x4d7501['body']['type']||_0xb24b('0xf2'),'lastPauseAt':moment()[_0xb24b('0x76')](_0xb24b('0xe7'))});})[_0xb24b('0x21')](respondWithResult(_0x571c75,null))[_0xb24b('0x2b')](handleError(_0x571c75,null));};exports[_0xb24b('0xf3')]=function(_0x4f0a39,_0x1d23b7,_0x13acfe){var _0x21fce1;return db[_0xb24b('0x60')][_0xb24b('0x40')]({'where':{'id':_0x4f0a39['params']['id']},'attributes':['id',_0xb24b('0x41'),'role',_0xb24b('0xa2'),'mailPause','chatPause','faxPause',_0xb24b('0xf4'),_0xb24b('0xf5'),_0xb24b('0xf6'),_0xb24b('0xf7')]})['then'](handleEntityNotFound(_0x1d23b7,null))[_0xb24b('0x21')](function(_0x1cd997){if(_0x1cd997){_0x21fce1=_0x1cd997;if(_0x4f0a39[_0xb24b('0x69')][_0xb24b('0xa0')]&&!utils[_0xb24b('0xa4')](_0x4f0a39['body'][_0xb24b('0xa0')])){throw new db[(_0xb24b('0x1d'))][(_0xb24b('0x1e'))](_0xb24b('0xa5'));}switch(_0x4f0a39[_0xb24b('0x69')][_0xb24b('0xa0')]){case'voice':return respondWithRpcPromise(_0xb24b('0xef'),_0xb24b('0xf3'),{'id':_0x21fce1['id'],'name':_0x21fce1[_0xb24b('0x41')],'pause':![]})[_0xb24b('0x21')](function(){return db[_0xb24b('0xb9')][_0xb24b('0x36')]({'paused':0x0},{'where':{'UserId':_0x21fce1['id']},'individualHooks':!![]});})[_0xb24b('0x21')](function(){return db[_0xb24b('0xe5')][_0xb24b('0x40')]({'where':{'channel':_0x4f0a39[_0xb24b('0x69')][_0xb24b('0xa0')],'membername':_0x21fce1[_0xb24b('0x41')],'type':_0xb24b('0xeb'),'exitAt':null}});})['then'](function(_0x19ae0e){if(_0x19ae0e){return _0x19ae0e['update']({'exitAt':moment()[_0xb24b('0x76')]('YYYY-MM-DD\x20HH:mm:ss'),'data2':_0xb24b('0xf8')},{'individualHooks':!![]});}return null;})['then'](function(){return _0x21fce1[_0xb24b('0x36')]({'voicePause':![]});});case _0xb24b('0xf9'):case'chat':case _0xb24b('0xfa'):case'sms':case _0xb24b('0xfb'):return db[_0xb24b('0xe5')][_0xb24b('0x40')]({'where':{'channel':_0x4f0a39[_0xb24b('0x69')]['channel'],'membername':_0x21fce1[_0xb24b('0x41')],'type':_0xb24b('0xeb'),'exitAt':null}})['then'](function(_0x2296d1){if(_0x2296d1){return _0x2296d1[_0xb24b('0x36')]({'exitAt':moment()[_0xb24b('0x76')](_0xb24b('0xe7')),'data2':'manual'},{'individualHooks':!![]});}return null;})['then'](function(){var _0x33560b={};_['set'](_0x33560b,util[_0xb24b('0x76')](_0xb24b('0xfc'),_0x4f0a39[_0xb24b('0x69')][_0xb24b('0xa0')],'Pause'),![]);return _0x21fce1['update'](_0x33560b);});default:return respondWithRpcPromise('QueuePause',_0xb24b('0xf3'),{'id':_0x21fce1['id'],'name':_0x21fce1[_0xb24b('0x41')],'pause':![]})[_0xb24b('0x21')](function(){return db[_0xb24b('0xb9')][_0xb24b('0x36')]({'paused':0x0},{'where':{'UserId':_0x21fce1['id']}});})[_0xb24b('0x21')](function(){return db[_0xb24b('0xe5')]['findAll']({'where':{'membername':_0x21fce1[_0xb24b('0x41')],'type':_0xb24b('0xeb'),'exitAt':null}});})['then'](function(_0x319709){var _0x3e005b=[];_0x319709[_0xb24b('0xe6')](function(_0x3df524){_0x3e005b[_0xb24b('0xb2')](_0x3df524[_0xb24b('0x36')]({'exitAt':moment()[_0xb24b('0x76')](_0xb24b('0xe7')),'data2':_0xb24b('0xf8')}));});return BPromise[_0xb24b('0xe8')](_0x3e005b);})[_0xb24b('0x21')](function(){return _0x21fce1[_0xb24b('0x36')]({'voicePause':![],'mailPause':![],'chatPause':![],'faxPause':![],'smsPause':![],'openchannelPause':![]});});}}})[_0xb24b('0x21')](respondWithResult(_0x1d23b7,null))[_0xb24b('0x2b')](handleError(_0x1d23b7,null));};exports[_0xb24b('0xfd')]=function(_0x3ac304,_0x3d847d,_0x176cea){var _0x1bc7d2={};var _0x6419bf={};var _0x5b965f;var _0x33024f;return db[_0xb24b('0x60')][_0xb24b('0x98')]({'where':{'id':_0x3ac304[_0xb24b('0x66')]['id']}})[_0xb24b('0x21')](handleEntityNotFound(_0x3d847d,null))[_0xb24b('0x21')](function(_0x448630){if(_0x448630){_0x5b965f=_0x448630;_0x6419bf[_0xb24b('0x4b')]=_[_0xb24b('0x4f')](db[_0xb24b('0xfe')][_0xb24b('0x67')]);_0x6419bf[_0xb24b('0x4e')]=_[_0xb24b('0x4f')](_0x3ac304[_0xb24b('0x4e')]);_0x6419bf[_0xb24b('0x50')]=_[_0xb24b('0x51')](_0x6419bf[_0xb24b('0x4b')],_0x6419bf[_0xb24b('0x4e')]);_0x1bc7d2[_0xb24b('0x53')]=_['intersection'](_0x6419bf['model'],qs[_0xb24b('0x52')](_0x3ac304[_0xb24b('0x4e')][_0xb24b('0x52')]));_0x1bc7d2['attributes']=_0x1bc7d2[_0xb24b('0x53')][_0xb24b('0xaa')]?_0x1bc7d2[_0xb24b('0x53')]:_0x6419bf[_0xb24b('0x4b')];_0x1bc7d2['order']=qs[_0xb24b('0x57')](_0x3ac304[_0xb24b('0x4e')][_0xb24b('0x57')]);_0x1bc7d2[_0xb24b('0x58')]=qs[_0xb24b('0x50')](_[_0xb24b('0x59')](_0x3ac304['query'],_0x6419bf[_0xb24b('0x50')]));if(_0x3ac304[_0xb24b('0x4e')][_0xb24b('0x3c')]){_0x1bc7d2[_0xb24b('0x58')]=_[_0xb24b('0x5a')](_0x1bc7d2[_0xb24b('0x58')],{'$or':_[_0xb24b('0x47')](_0x1bc7d2[_0xb24b('0x53')],function(_0x10f823){var _0x335d9f={};_0x335d9f[_0x10f823]={'$like':'%'+_0x3ac304[_0xb24b('0x4e')][_0xb24b('0x3c')]+'%'};return _0x335d9f;})});}_0x1bc7d2=_[_0xb24b('0x5a')]({},_0x1bc7d2,_0x3ac304[_0xb24b('0x5f')]);return _0x5b965f[_0xb24b('0xfd')](_0x1bc7d2);}})['then'](function(_0x3447f8){if(_0x3447f8){_0x33024f=_0x3447f8['length'];if(!_0x3ac304[_0xb24b('0x4e')][_0xb24b('0x54')](_0xb24b('0x55'))){_0x1bc7d2[_0xb24b('0x31')]=qs['limit'](_0x3ac304['query'][_0xb24b('0x31')]);_0x1bc7d2[_0xb24b('0x30')]=qs[_0xb24b('0x30')](_0x3ac304[_0xb24b('0x4e')][_0xb24b('0x30')]);}return _0x5b965f['getTeams'](_0x1bc7d2);}})['then'](function(_0x3899b0){if(_0x3899b0){return _0x3899b0?{'count':_0x33024f,'rows':_0x3899b0}:null;}})[_0xb24b('0x21')](respondWithResult(_0x3d847d,null))[_0xb24b('0x2b')](handleError(_0x3d847d,null));};exports[_0xb24b('0xff')]=function(_0x45e537,_0x4f40d0){return db[_0xb24b('0x60')][_0xb24b('0x40')]({'where':{'id':_0x45e537['params']['id']}})[_0xb24b('0x21')](handleEntityNotFound(_0x4f40d0,null))[_0xb24b('0x21')](function(_0x2ecea1){if(_0x2ecea1){var _0x589338=_0x2ecea1[_0xb24b('0x37')]({'plain':!![]});return _0x2ecea1[_0xb24b('0xff')](_0x45e537[_0xb24b('0x69')][_0xb24b('0x6c')],_[_0xb24b('0x6d')](_0x45e537[_0xb24b('0x69')],[_0xb24b('0x6c'),'id'])||{})[_0xb24b('0x21')](function(){for(var _0x1038a7=0x0;_0x1038a7<_0x45e537[_0xb24b('0x69')][_0xb24b('0x6c')]['length'];_0x1038a7++){var _0x101bfc=[];db['Team'][_0xb24b('0x98')]({'where':{'id':_0x45e537[_0xb24b('0x69')][_0xb24b('0x6c')][_0x1038a7]}})['then'](function(_0x53297f){_0x101bfc[_0xb24b('0xb2')](_0x53297f['getVoiceQueues']()[_0xb24b('0x21')](function(_0x5997bd){for(var _0x435e3e=0x0;_0x435e3e<_0x5997bd['length'];_0x435e3e++){_0x5997bd[_0x435e3e][_0xb24b('0x100')]('channel','Voice');}return _0x5997bd;}));_0x101bfc[_0xb24b('0xb2')](_0x53297f[_0xb24b('0x101')]()[_0xb24b('0x21')](function(_0x19a571){for(var _0x38df3c=0x0;_0x38df3c<_0x19a571['length'];_0x38df3c++){_0x19a571[_0x38df3c]['setDataValue'](_0xb24b('0xa0'),_0xb24b('0x102'));}return _0x19a571;}));_0x101bfc[_0xb24b('0xb2')](_0x53297f[_0xb24b('0x103')]()['then'](function(_0x501160){for(var _0x422a3f=0x0;_0x422a3f<_0x501160[_0xb24b('0xaa')];_0x422a3f++){_0x501160[_0x422a3f][_0xb24b('0x100')](_0xb24b('0xa0'),_0xb24b('0x104'));}return _0x501160;}));_0x101bfc[_0xb24b('0xb2')](_0x53297f[_0xb24b('0x105')]()['then'](function(_0x3136bb){for(var _0x484a33=0x0;_0x484a33<_0x3136bb[_0xb24b('0xaa')];_0x484a33++){_0x3136bb[_0x484a33][_0xb24b('0x100')](_0xb24b('0xa0'),_0xb24b('0x106'));}return _0x3136bb;}));_0x101bfc[_0xb24b('0xb2')](_0x53297f[_0xb24b('0x107')]()[_0xb24b('0x21')](function(_0x3d7eb5){for(var _0x40679c=0x0;_0x40679c<_0x3d7eb5[_0xb24b('0xaa')];_0x40679c++){_0x3d7eb5[_0x40679c]['setDataValue'](_0xb24b('0xa0'),'Fax');}return _0x3d7eb5;}));_0x101bfc[_0xb24b('0xb2')](_0x53297f[_0xb24b('0x108')]()['then'](function(_0x59b3f2){for(var _0x5f38d4=0x0;_0x5f38d4<_0x59b3f2[_0xb24b('0xaa')];_0x5f38d4++){_0x59b3f2[_0x5f38d4][_0xb24b('0x100')]('channel',_0xb24b('0x109'));}return _0x59b3f2;}));return BPromise[_0xb24b('0xe8')](_0x101bfc);})['then'](function(_0x2b4d0d){var _0x46259a=_[_0xb24b('0x10a')](_0x2b4d0d);_0x101bfc=[];return db[_0xb24b('0x5c')][_0xb24b('0x10b')](function(_0x5292d3){for(var _0x16d1bb=0x0;_0x16d1bb<_0x46259a['length'];_0x16d1bb++){_0x101bfc['push'](_0x46259a[_0x16d1bb]['addAgent'](_0x589338['id']),{'transaction':_0x5292d3});}return BPromise['all'](_0x101bfc)['then'](function(){if(_0x589338[_0xb24b('0xb1')]){return BPromise[_0xb24b('0xb4')](_[_0xb24b('0x3c')](_0x46259a,function(_0x4b5317){return _0x4b5317[_0xb24b('0x10c')]('channel')==='Voice';}),function(_0x3274e5){return db[_0xb24b('0xb9')]['upsert']({'membername':_0x589338[_0xb24b('0x41')],'UserId':_0x589338['id'],'queue_name':_0x3274e5[_0xb24b('0x41')],'VoiceQueueId':_0x3274e5['id'],'interface':_[_0xb24b('0x74')](_0x589338[_0xb24b('0xa3')])?util['format'](_0xb24b('0xb3'),_0x589338[_0xb24b('0x41')]):_0x589338[_0xb24b('0xa3')],'paused':_0x589338[_0xb24b('0xa2')]||![],'penalty':_0x589338[_0xb24b('0xa8')]},{'transaction':_0x5292d3});});}else{return;}})[_0xb24b('0x21')](function(){for(var _0x14532a=0x0;_0x14532a<_0x46259a[_0xb24b('0xaa')];_0x14532a++){var _0x4fdf4e=_0x46259a[_0x14532a]['getDataValue'](_0xb24b('0xa0'));var _0x406b46=_0x4fdf4e+_0xb24b('0xab');socket[_0xb24b('0xac')](_0xb24b('0x92')+_0x4fdf4e+_0xb24b('0xae'),{'UserId':_0x589338['id'],['queueField']:_0x46259a[_0x14532a]['id']});}});});});}});}})[_0xb24b('0x21')](respondWithStatusCode(_0x4f40d0,null))[_0xb24b('0x2b')](handleError(_0x4f40d0,null));};exports[_0xb24b('0x10d')]=function(_0x137bf5,_0x32ef1a){return db[_0xb24b('0x60')][_0xb24b('0x98')]({'where':{'id':_0x137bf5[_0xb24b('0x66')]['id']}})[_0xb24b('0x21')](handleEntityNotFound(_0x32ef1a,null))['then'](function(_0xc89e8){if(_0xc89e8){var _0x28d5ca=_0xc89e8[_0xb24b('0x37')]({'plain':!![]});var _0x4d827b=_0x137bf5[_0xb24b('0x4e')][_0xb24b('0x6c')];return _0xc89e8[_0xb24b('0x10d')](_0x4d827b)[_0xb24b('0x21')](function(){for(var _0x5cd84b=0x0;_0x5cd84b<_0x4d827b[_0xb24b('0xaa')];_0x5cd84b++){var _0x4bf5bd=[];db[_0xb24b('0xfe')][_0xb24b('0x98')]({'where':{'id':_0x4d827b[_0x5cd84b]}})[_0xb24b('0x21')](function(_0x2bb174){_0x4bf5bd[_0xb24b('0xb2')](_0x2bb174[_0xb24b('0x10e')]()['then'](function(_0x2f1410){for(var _0x5b9e99=0x0;_0x5b9e99<_0x2f1410['length'];_0x5b9e99++){_0x2f1410[_0x5b9e99]['setDataValue'](_0xb24b('0xa0'),_0xb24b('0x10f'));}return _0x2f1410;}));_0x4bf5bd['push'](_0x2bb174[_0xb24b('0x101')]()[_0xb24b('0x21')](function(_0x4f3b33){for(var _0x2ce853=0x0;_0x2ce853<_0x4f3b33[_0xb24b('0xaa')];_0x2ce853++){_0x4f3b33[_0x2ce853][_0xb24b('0x100')](_0xb24b('0xa0'),_0xb24b('0x102'));}return _0x4f3b33;}));_0x4bf5bd[_0xb24b('0xb2')](_0x2bb174[_0xb24b('0x103')]()['then'](function(_0x1f7dbe){for(var _0x5e7b10=0x0;_0x5e7b10<_0x1f7dbe[_0xb24b('0xaa')];_0x5e7b10++){_0x1f7dbe[_0x5e7b10]['setDataValue'](_0xb24b('0xa0'),_0xb24b('0x104'));}return _0x1f7dbe;}));_0x4bf5bd[_0xb24b('0xb2')](_0x2bb174[_0xb24b('0x105')]()['then'](function(_0x11b7ce){for(var _0x465eae=0x0;_0x465eae<_0x11b7ce['length'];_0x465eae++){_0x11b7ce[_0x465eae][_0xb24b('0x100')](_0xb24b('0xa0'),_0xb24b('0x106'));}return _0x11b7ce;}));_0x4bf5bd[_0xb24b('0xb2')](_0x2bb174['getFaxQueues']()[_0xb24b('0x21')](function(_0x439d61){for(var _0x50da94=0x0;_0x50da94<_0x439d61[_0xb24b('0xaa')];_0x50da94++){_0x439d61[_0x50da94][_0xb24b('0x100')]('channel',_0xb24b('0x110'));}return _0x439d61;}));_0x4bf5bd['push'](_0x2bb174[_0xb24b('0x108')]()['then'](function(_0x39af51){for(var _0x131db=0x0;_0x131db<_0x39af51[_0xb24b('0xaa')];_0x131db++){_0x39af51[_0x131db]['setDataValue'](_0xb24b('0xa0'),'Openchannel');}return _0x39af51;}));return BPromise[_0xb24b('0xe8')](_0x4bf5bd);})['then'](function(_0x40f8cb){var _0x404550=_[_0xb24b('0x10a')](_0x40f8cb);_0x4bf5bd=[];return db['sequelize'][_0xb24b('0x10b')](function(_0x13ae2b){for(var _0x315a57=0x0;_0x315a57<_0x404550[_0xb24b('0xaa')];_0x315a57++){_0x4bf5bd['push'](_0x404550[_0x315a57][_0xb24b('0x111')](_0x28d5ca['id']),{'transaction':_0x13ae2b});}return BPromise[_0xb24b('0xe8')](_0x4bf5bd)['then'](function(){if(_0x28d5ca['online']){return BPromise['each'](_[_0xb24b('0x3c')](_0x404550,function(_0x43932c){return _0x43932c[_0xb24b('0x10c')](_0xb24b('0xa0'))===_0xb24b('0x10f');}),function(_0x5d2359){return db[_0xb24b('0xb9')][_0xb24b('0x43')]({'where':{'VoiceQueueId':_0x5d2359['id'],'UserId':_0x28d5ca['id']},'transaction':_0x13ae2b});});}else{return;}})[_0xb24b('0x21')](function(){for(var _0x177369=0x0;_0x177369<_0x404550['length'];_0x177369++){var _0x16db40=_0x404550[_0x177369][_0xb24b('0x10c')](_0xb24b('0xa0'));var _0x56590d=_0x16db40+_0xb24b('0xab');socket[_0xb24b('0xac')]('user'+_0x16db40+_0xb24b('0xb8'),{'UserId':_0x28d5ca['id'],['queueField']:_0x404550[_0x177369]['id']});}});});});}});}})[_0xb24b('0x21')](respondWithStatusCode(_0x32ef1a,null))[_0xb24b('0x2b')](handleError(_0x32ef1a,null));};exports[_0xb24b('0x112')]=function(_0x5e8004,_0x2f6922,_0x4f350c){var _0x464ef1={};var _0x33d3ef={};var _0x2ac0d2;var _0x333d11;return db[_0xb24b('0x60')][_0xb24b('0x98')]({'where':{'id':_0x5e8004['params']['id']}})[_0xb24b('0x21')](handleEntityNotFound(_0x2f6922,null))[_0xb24b('0x21')](function(_0x303485){if(_0x303485){_0x2ac0d2=_0x303485;_0x33d3ef['model']=_['keys'](db[_0xb24b('0xc3')][_0xb24b('0x67')]);_0x33d3ef[_0xb24b('0x4e')]=_['keys'](_0x5e8004[_0xb24b('0x4e')]);_0x33d3ef[_0xb24b('0x50')]=_[_0xb24b('0x51')](_0x33d3ef[_0xb24b('0x4b')],_0x33d3ef[_0xb24b('0x4e')]);_0x464ef1[_0xb24b('0x53')]=_['intersection'](_0x33d3ef[_0xb24b('0x4b')],qs[_0xb24b('0x52')](_0x5e8004['query']['fields']));_0x464ef1['attributes']=_0x464ef1[_0xb24b('0x53')][_0xb24b('0xaa')]?_0x464ef1[_0xb24b('0x53')]:_0x33d3ef[_0xb24b('0x4b')];_0x464ef1['order']=qs[_0xb24b('0x57')](_0x5e8004[_0xb24b('0x4e')]['sort']);_0x464ef1['where']=qs['filters'](_['pick'](_0x5e8004['query'],_0x33d3ef['filters']));if(_0x5e8004[_0xb24b('0x4e')]['filter']){_0x464ef1['where']=_[_0xb24b('0x5a')](_0x464ef1['where'],{'$or':_[_0xb24b('0x47')](_0x464ef1[_0xb24b('0x53')],function(_0xf55774){var _0x2b84de={};_0x2b84de[_0xf55774]={'$like':'%'+_0x5e8004[_0xb24b('0x4e')][_0xb24b('0x3c')]+'%'};return _0x2b84de;})});}_0x464ef1=_[_0xb24b('0x5a')]({},_0x464ef1,_0x5e8004['options']);return _0x2ac0d2[_0xb24b('0x112')](_0x464ef1);}})[_0xb24b('0x21')](function(_0x52f4da){if(_0x52f4da){_0x333d11=_0x52f4da[_0xb24b('0xaa')];if(!_0x5e8004[_0xb24b('0x4e')][_0xb24b('0x54')](_0xb24b('0x55'))){_0x464ef1[_0xb24b('0x31')]=qs[_0xb24b('0x31')](_0x5e8004['query'][_0xb24b('0x31')]);_0x464ef1[_0xb24b('0x30')]=qs[_0xb24b('0x30')](_0x5e8004[_0xb24b('0x4e')][_0xb24b('0x30')]);}return _0x2ac0d2[_0xb24b('0x112')](_0x464ef1);}})[_0xb24b('0x21')](function(_0x3fc8f8){if(_0x3fc8f8){return _0x3fc8f8?{'count':_0x333d11,'rows':_0x3fc8f8}:null;}})[_0xb24b('0x21')](respondWithResult(_0x2f6922,null))[_0xb24b('0x2b')](handleError(_0x2f6922,null));};exports[_0xb24b('0x113')]=function(_0x195271,_0x3cd364,_0x314adb){var _0x9a8ad6={};var _0x4460cf={};var _0x56f8bc;var _0x53a96a;return db['User'][_0xb24b('0x98')]({'where':{'id':_0x195271[_0xb24b('0x66')]['id']}})[_0xb24b('0x21')](handleEntityNotFound(_0x3cd364,null))[_0xb24b('0x21')](function(_0x1424cf){if(_0x1424cf){_0x56f8bc=_0x1424cf;_0x4460cf['model']=_[_0xb24b('0x4f')](db[_0xb24b('0x60')][_0xb24b('0x67')]);_0x4460cf['query']=_[_0xb24b('0x4f')](_0x195271[_0xb24b('0x4e')]);_0x4460cf[_0xb24b('0x50')]=_[_0xb24b('0x51')](_0x4460cf[_0xb24b('0x4b')],_0x4460cf[_0xb24b('0x4e')]);_0x9a8ad6[_0xb24b('0x53')]=_[_0xb24b('0x51')](_0x4460cf[_0xb24b('0x4b')],qs[_0xb24b('0x52')](_0x195271['query'][_0xb24b('0x52')]));_0x9a8ad6[_0xb24b('0x53')]=_0x9a8ad6[_0xb24b('0x53')][_0xb24b('0xaa')]?_0x9a8ad6[_0xb24b('0x53')]:_0x4460cf['model'];_0x9a8ad6[_0xb24b('0x56')]=qs[_0xb24b('0x57')](_0x195271[_0xb24b('0x4e')][_0xb24b('0x57')]);_0x9a8ad6[_0xb24b('0x58')]=qs[_0xb24b('0x50')](_[_0xb24b('0x59')](_0x195271['query'],_0x4460cf[_0xb24b('0x50')]));if(_0x195271['query'][_0xb24b('0x3c')]){_0x9a8ad6['where']=_[_0xb24b('0x5a')](_0x9a8ad6[_0xb24b('0x58')],{'$or':_[_0xb24b('0x47')](_0x9a8ad6[_0xb24b('0x53')],function(_0x4be2ba){var _0xa3574a={};_0xa3574a[_0x4be2ba]={'$like':'%'+_0x195271['query']['filter']+'%'};return _0xa3574a;})});}_0x9a8ad6[_0xb24b('0x4b')]=db[_0xb24b('0x60')];_0x9a8ad6['as']=_0xb24b('0x39');_0x9a8ad6=_[_0xb24b('0x5a')]({},_0x9a8ad6,_0x195271[_0xb24b('0x5f')]);return _0x56f8bc[_0xb24b('0x10e')]({'include':[_0x9a8ad6]});}})['then'](function(_0x5e5c24){if(_0x5e5c24){var _0x1b4bb8={},_0x12cf10=[],_0x22c96e=0x0;for(var _0x223452=0x0;_0x223452<_0x5e5c24[_0xb24b('0xaa')];_0x223452+=0x1){for(var _0x5b2335=0x0,_0x51ab77;_0x5b2335<_0x5e5c24[_0x223452][_0xb24b('0x39')]['length'];_0x5b2335+=0x1){_0x51ab77=_0x5e5c24[_0x223452][_0xb24b('0x39')][_0x5b2335][_0xb24b('0x37')]({'plain':!![]});_0x1b4bb8[_0x51ab77['id']]=_0x51ab77;}}_0x1b4bb8=_[_0xb24b('0x114')](_0x1b4bb8);for(var _0x33aeee=qs[_0xb24b('0x30')](_0x195271[_0xb24b('0x4e')]['offset']);_0x33aeee<_0x1b4bb8['length']&&_0x12cf10[_0xb24b('0xaa')]<qs['limit'](_0x195271[_0xb24b('0x4e')][_0xb24b('0x31')]);_0x33aeee+=0x1){if(_0x1b4bb8[_0x33aeee]){_0x12cf10[_0xb24b('0xb2')](_0x1b4bb8[_0x33aeee]);}}return{'count':_0x1b4bb8[_0xb24b('0xaa')],'rows':_0x12cf10};}})[_0xb24b('0x21')](respondWithResult(_0x3cd364,null))[_0xb24b('0x2b')](handleError(_0x3cd364,null));};exports[_0xb24b('0x43')]=function(_0x515c43,_0x9962be){if(_0x515c43[_0xb24b('0x92')]['id']==_0x515c43[_0xb24b('0x66')]['id']){return _0x9962be[_0xb24b('0x2c')](0x1f4)[_0xb24b('0x46')]({'message':_0xb24b('0x115')});}return db[_0xb24b('0x60')]['find']({'where':{'id':_0x515c43[_0xb24b('0x66')]['id']}})[_0xb24b('0x21')](handleEntityNotFound(_0x9962be,null))[_0xb24b('0x21')](removeEntity(_0x9962be,null))[_0xb24b('0x2b')](handleError(_0x9962be,null));};exports[_0xb24b('0x116')]=function(_0x5b55eb,_0x587e75,_0x402484){return db[_0xb24b('0x60')][_0xb24b('0x40')]({'where':{'id':_0x5b55eb[_0xb24b('0x66')]['id']}})['then'](handleEntityNotFound(_0x587e75,null))[_0xb24b('0x21')](function(_0x418f2f){if(_0x418f2f){return _0x418f2f['addChatInteractions'](_0x5b55eb[_0xb24b('0x69')][_0xb24b('0x6c')],_[_0xb24b('0x6d')](_0x5b55eb['body'],['ids','id'])||{})[_0xb24b('0xa9')](function(){for(var _0x434015=0x0;_0x434015<_0x5b55eb[_0xb24b('0x69')][_0xb24b('0x6c')][_0xb24b('0xaa')];_0x434015+=0x1){socket[_0xb24b('0xac')](_0xb24b('0x117'),{'ChatInteractionId':Number(_0x5b55eb['body'][_0xb24b('0x6c')][_0x434015]),'UserId':Number(_0x5b55eb[_0xb24b('0x66')]['id'])});}return _0x5b55eb[_0xb24b('0x69')]['ids'];});}})[_0xb24b('0x21')](respondWithResult(_0x587e75,null))[_0xb24b('0x2b')](handleError(_0x587e75,null));};exports[_0xb24b('0x118')]=function(_0x3fe1e5,_0x4042a5,_0x479067){return db[_0xb24b('0x60')][_0xb24b('0x40')]({'where':{'id':_0x3fe1e5[_0xb24b('0x66')]['id']}})[_0xb24b('0x21')](handleEntityNotFound(_0x4042a5,null))['then'](function(_0x3f49f0){if(_0x3f49f0){return _0x3f49f0[_0xb24b('0x118')](_0x3fe1e5[_0xb24b('0x4e')][_0xb24b('0x6c')])[_0xb24b('0x21')](function(){if(_[_0xb24b('0x119')](_0x3fe1e5[_0xb24b('0x4e')][_0xb24b('0x6c')])){for(var _0x9506a5=0x0;_0x9506a5<_0x3fe1e5[_0xb24b('0x4e')][_0xb24b('0x6c')]['length'];_0x9506a5+=0x1){socket[_0xb24b('0xac')]('user_has_chat_interactions:remove',{'ChatInteractionId':Number(_0x3fe1e5['query'][_0xb24b('0x6c')][_0x9506a5]),'UserId':Number(_0x3fe1e5['params']['id'])});}}else{socket[_0xb24b('0xac')](_0xb24b('0x11a'),{'ChatInteractionId':Number(_0x3fe1e5[_0xb24b('0x4e')]['ids']),'UserId':Number(_0x3fe1e5[_0xb24b('0x66')]['id'])});}});}})[_0xb24b('0x21')](respondWithStatusCode(_0x4042a5,null))[_0xb24b('0x2b')](handleError(_0x4042a5,null));};exports[_0xb24b('0x11b')]=function(_0x45c38f,_0x2e0e8c,_0x1a1a96){return db['User']['find']({'where':{'id':_0x45c38f['params']['id']}})[_0xb24b('0x21')](handleEntityNotFound(_0x2e0e8c,null))[_0xb24b('0x21')](function(_0x390c2d){if(_0x390c2d){return _0x390c2d['addMailInteractions'](_0x45c38f[_0xb24b('0x69')]['ids'],_[_0xb24b('0x6d')](_0x45c38f['body'],[_0xb24b('0x6c'),'id'])||{})[_0xb24b('0xa9')](function(){for(var _0x52eb76=0x0;_0x52eb76<_0x45c38f['body'][_0xb24b('0x6c')][_0xb24b('0xaa')];_0x52eb76+=0x1){socket['emit'](_0xb24b('0x11c'),{'MailInteractionId':Number(_0x45c38f[_0xb24b('0x69')][_0xb24b('0x6c')][_0x52eb76]),'UserId':Number(_0x45c38f['params']['id'])});}return _0x45c38f['body'][_0xb24b('0x6c')];});}})[_0xb24b('0x21')](respondWithResult(_0x2e0e8c,null))[_0xb24b('0x2b')](handleError(_0x2e0e8c,null));};exports[_0xb24b('0x11d')]=function(_0x4ec993,_0x49ac9f,_0x307a5d){return db['User']['find']({'where':{'id':_0x4ec993[_0xb24b('0x66')]['id']}})[_0xb24b('0x21')](handleEntityNotFound(_0x49ac9f,null))[_0xb24b('0x21')](function(_0x2c150c){if(_0x2c150c){return _0x2c150c[_0xb24b('0x11d')](_0x4ec993[_0xb24b('0x4e')][_0xb24b('0x6c')])[_0xb24b('0x21')](function(){if(_[_0xb24b('0x119')](_0x4ec993[_0xb24b('0x4e')][_0xb24b('0x6c')])){for(var _0x1da053=0x0;_0x1da053<_0x4ec993['query'][_0xb24b('0x6c')]['length'];_0x1da053+=0x1){socket[_0xb24b('0xac')](_0xb24b('0x11e'),{'MailInteractionId':Number(_0x4ec993[_0xb24b('0x4e')]['ids'][_0x1da053]),'UserId':Number(_0x4ec993[_0xb24b('0x66')]['id'])});}}else{socket['emit']('user_has_mail_interactions:remove',{'MailInteractionId':Number(_0x4ec993[_0xb24b('0x4e')]['ids']),'UserId':Number(_0x4ec993[_0xb24b('0x66')]['id'])});}});}})[_0xb24b('0x21')](respondWithStatusCode(_0x49ac9f,null))[_0xb24b('0x2b')](handleError(_0x49ac9f,null));};exports[_0xb24b('0x11f')]=function(_0xae8018,_0x428ce2,_0x4f0ac0){return db[_0xb24b('0x60')][_0xb24b('0x40')]({'where':{'id':_0xae8018['params']['id']}})[_0xb24b('0x21')](handleEntityNotFound(_0x428ce2,null))['then'](function(_0x581d41){if(_0x581d41){return _0x581d41['addFaxInteractions'](_0xae8018[_0xb24b('0x69')][_0xb24b('0x6c')],_[_0xb24b('0x6d')](_0xae8018[_0xb24b('0x69')],[_0xb24b('0x6c'),'id'])||{})[_0xb24b('0xa9')](function(){for(var _0x704ae7=0x0;_0x704ae7<_0xae8018[_0xb24b('0x69')][_0xb24b('0x6c')][_0xb24b('0xaa')];_0x704ae7+=0x1){socket[_0xb24b('0xac')](_0xb24b('0x120'),{'FaxInteractionId':Number(_0xae8018[_0xb24b('0x69')][_0xb24b('0x6c')][_0x704ae7]),'UserId':Number(_0xae8018[_0xb24b('0x66')]['id'])});}return _0xae8018[_0xb24b('0x69')][_0xb24b('0x6c')];});}})[_0xb24b('0x21')](respondWithResult(_0x428ce2,null))[_0xb24b('0x2b')](handleError(_0x428ce2,null));};exports[_0xb24b('0x121')]=function(_0x34d6a3,_0xb89dec,_0x326505){return db['User'][_0xb24b('0x40')]({'where':{'id':_0x34d6a3[_0xb24b('0x66')]['id']}})[_0xb24b('0x21')](handleEntityNotFound(_0xb89dec,null))['then'](function(_0xda6b03){if(_0xda6b03){return _0xda6b03[_0xb24b('0x121')](_0x34d6a3[_0xb24b('0x4e')]['ids'])[_0xb24b('0x21')](function(){if(_['isArray'](_0x34d6a3[_0xb24b('0x4e')][_0xb24b('0x6c')])){for(var _0x469109=0x0;_0x469109<_0x34d6a3['query']['ids'][_0xb24b('0xaa')];_0x469109+=0x1){socket['emit'](_0xb24b('0x122'),{'FaxInteractionId':Number(_0x34d6a3['query'][_0xb24b('0x6c')][_0x469109]),'UserId':Number(_0x34d6a3['params']['id'])});}}else{socket['emit'](_0xb24b('0x122'),{'FaxInteractionId':Number(_0x34d6a3[_0xb24b('0x4e')][_0xb24b('0x6c')]),'UserId':Number(_0x34d6a3[_0xb24b('0x66')]['id'])});}});}})[_0xb24b('0x21')](respondWithStatusCode(_0xb89dec,null))['catch'](handleError(_0xb89dec,null));};exports['addSmsInteractions']=function(_0x38e1a6,_0xe59aef,_0x42723d){return db[_0xb24b('0x60')][_0xb24b('0x40')]({'where':{'id':_0x38e1a6[_0xb24b('0x66')]['id']}})[_0xb24b('0x21')](handleEntityNotFound(_0xe59aef,null))[_0xb24b('0x21')](function(_0x48bc17){if(_0x48bc17){return _0x48bc17[_0xb24b('0x123')](_0x38e1a6[_0xb24b('0x69')][_0xb24b('0x6c')],_['omit'](_0x38e1a6[_0xb24b('0x69')],[_0xb24b('0x6c'),'id'])||{})['spread'](function(){for(var _0x169517=0x0;_0x169517<_0x38e1a6[_0xb24b('0x69')]['ids'][_0xb24b('0xaa')];_0x169517+=0x1){socket[_0xb24b('0xac')](_0xb24b('0x124'),{'SmsInteractionId':Number(_0x38e1a6['body'][_0xb24b('0x6c')][_0x169517]),'UserId':Number(_0x38e1a6[_0xb24b('0x66')]['id'])});}return _0x38e1a6[_0xb24b('0x69')][_0xb24b('0x6c')];});}})[_0xb24b('0x21')](respondWithResult(_0xe59aef,null))[_0xb24b('0x2b')](handleError(_0xe59aef,null));};exports[_0xb24b('0x125')]=function(_0x1479a2,_0x1721cf,_0x9316b){return db[_0xb24b('0x60')][_0xb24b('0x40')]({'where':{'id':_0x1479a2['params']['id']}})[_0xb24b('0x21')](handleEntityNotFound(_0x1721cf,null))[_0xb24b('0x21')](function(_0x1f94c2){if(_0x1f94c2){return _0x1f94c2[_0xb24b('0x125')](_0x1479a2['query']['ids'])[_0xb24b('0x21')](function(){if(_[_0xb24b('0x119')](_0x1479a2['query'][_0xb24b('0x6c')])){for(var _0x460b65=0x0;_0x460b65<_0x1479a2['query'][_0xb24b('0x6c')][_0xb24b('0xaa')];_0x460b65+=0x1){socket[_0xb24b('0xac')]('user_has_sms_interactions:remove',{'SmsInteractionId':Number(_0x1479a2[_0xb24b('0x4e')][_0xb24b('0x6c')][_0x460b65]),'UserId':Number(_0x1479a2[_0xb24b('0x66')]['id'])});}}else{socket[_0xb24b('0xac')]('user_has_sms_interactions:remove',{'SmsInteractionId':Number(_0x1479a2['query'][_0xb24b('0x6c')]),'UserId':Number(_0x1479a2['params']['id'])});}});}})[_0xb24b('0x21')](respondWithStatusCode(_0x1721cf,null))[_0xb24b('0x2b')](handleError(_0x1721cf,null));};exports[_0xb24b('0x126')]=function(_0x55f750,_0x216163,_0x2ae9c4){return db[_0xb24b('0x60')][_0xb24b('0x40')]({'where':{'id':_0x55f750[_0xb24b('0x66')]['id']}})[_0xb24b('0x21')](handleEntityNotFound(_0x216163,null))[_0xb24b('0x21')](function(_0x11e87e){if(_0x11e87e){return _0x11e87e[_0xb24b('0x126')](_0x55f750[_0xb24b('0x69')]['ids'],_[_0xb24b('0x6d')](_0x55f750[_0xb24b('0x69')],[_0xb24b('0x6c'),'id'])||{})[_0xb24b('0xa9')](function(){for(var _0x58ba5b=0x0;_0x58ba5b<_0x55f750[_0xb24b('0x69')]['ids']['length'];_0x58ba5b+=0x1){socket[_0xb24b('0xac')]('user_has_openchannel_interactions:save',{'OpenchannelInteractionId':Number(_0x55f750[_0xb24b('0x69')][_0xb24b('0x6c')][_0x58ba5b]),'UserId':Number(_0x55f750[_0xb24b('0x66')]['id'])});}return _0x55f750[_0xb24b('0x69')]['ids'];});}})[_0xb24b('0x21')](respondWithResult(_0x216163,null))[_0xb24b('0x2b')](handleError(_0x216163,null));};exports['removeOpenchannelInteractions']=function(_0xde8a93,_0x10c757,_0x24dde3){return db[_0xb24b('0x60')][_0xb24b('0x40')]({'where':{'id':_0xde8a93[_0xb24b('0x66')]['id']}})[_0xb24b('0x21')](handleEntityNotFound(_0x10c757,null))[_0xb24b('0x21')](function(_0x1e95d2){if(_0x1e95d2){return _0x1e95d2[_0xb24b('0x127')](_0xde8a93[_0xb24b('0x4e')][_0xb24b('0x6c')])['then'](function(){if(_[_0xb24b('0x119')](_0xde8a93[_0xb24b('0x4e')][_0xb24b('0x6c')])){for(var _0x1023c5=0x0;_0x1023c5<_0xde8a93[_0xb24b('0x4e')][_0xb24b('0x6c')][_0xb24b('0xaa')];_0x1023c5+=0x1){socket[_0xb24b('0xac')](_0xb24b('0x128'),{'OpenchannelInteractionId':Number(_0xde8a93['query'][_0xb24b('0x6c')][_0x1023c5]),'UserId':Number(_0xde8a93[_0xb24b('0x66')]['id'])});}}else{socket[_0xb24b('0xac')](_0xb24b('0x128'),{'OpenchannelInteractionId':Number(_0xde8a93['query'][_0xb24b('0x6c')]),'UserId':Number(_0xde8a93[_0xb24b('0x66')]['id'])});}});}})[_0xb24b('0x21')](respondWithStatusCode(_0x10c757,null))[_0xb24b('0x2b')](handleError(_0x10c757,null));};exports[_0xb24b('0x129')]=function(_0x4a081d,_0x2d9055,_0x48cc60){var _0x494d0f={};var _0x6feba7={};var _0x49d322;var _0x4398a3;return db[_0xb24b('0x60')][_0xb24b('0x98')]({'where':{'id':_0x4a081d[_0xb24b('0x66')]['id']}})[_0xb24b('0x21')](handleEntityNotFound(_0x2d9055,null))[_0xb24b('0x21')](function(_0x2618df){if(_0x2618df){_0x49d322=_0x2618df;_0x6feba7['model']=_['keys'](db[_0xb24b('0x12a')][_0xb24b('0x67')]);_0x6feba7[_0xb24b('0x4e')]=_[_0xb24b('0x4f')](_0x4a081d['query']);_0x6feba7[_0xb24b('0x50')]=_[_0xb24b('0x51')](_0x6feba7[_0xb24b('0x4b')],_0x6feba7['query']);_0x494d0f[_0xb24b('0x53')]=_[_0xb24b('0x51')](_0x6feba7['model'],qs[_0xb24b('0x52')](_0x4a081d[_0xb24b('0x4e')][_0xb24b('0x52')]));_0x494d0f[_0xb24b('0x53')]=_0x494d0f[_0xb24b('0x53')]['length']?_0x494d0f[_0xb24b('0x53')]:_0x6feba7['model'];_0x494d0f['order']=qs[_0xb24b('0x57')](_0x4a081d['query'][_0xb24b('0x57')]);_0x494d0f[_0xb24b('0x58')]=qs['filters'](_[_0xb24b('0x59')](_0x4a081d['query'],_0x6feba7[_0xb24b('0x50')]));if(_0x4a081d[_0xb24b('0x4e')][_0xb24b('0x3c')]){_0x494d0f['where']=_['merge'](_0x494d0f[_0xb24b('0x58')],{'$or':_['map'](_0x494d0f['attributes'],function(_0x491770){var _0x5e05e9={};_0x5e05e9[_0x491770]={'$like':'%'+_0x4a081d[_0xb24b('0x4e')]['filter']+'%'};return _0x5e05e9;})});}_0x494d0f=_[_0xb24b('0x5a')]({},_0x494d0f,_0x4a081d[_0xb24b('0x5f')]);return _0x49d322['getVoicePrefixes'](_0x494d0f);}})[_0xb24b('0x21')](function(_0xa28f40){if(_0xa28f40){_0x4398a3=_0xa28f40[_0xb24b('0xaa')];if(!_0x4a081d[_0xb24b('0x4e')][_0xb24b('0x54')](_0xb24b('0x55'))){_0x494d0f[_0xb24b('0x31')]=qs[_0xb24b('0x31')](_0x4a081d[_0xb24b('0x4e')][_0xb24b('0x31')]);_0x494d0f[_0xb24b('0x30')]=qs['offset'](_0x4a081d[_0xb24b('0x4e')][_0xb24b('0x30')]);}return _0x49d322[_0xb24b('0x129')](_0x494d0f);}})[_0xb24b('0x21')](function(_0x2b342b){if(_0x2b342b){return _0x2b342b?{'count':_0x4398a3,'rows':_0x2b342b}:null;}})[_0xb24b('0x21')](respondWithResult(_0x2d9055,null))[_0xb24b('0x2b')](handleError(_0x2d9055,null));};exports[_0xb24b('0x12b')]=function(_0x16360e,_0x315fc8,_0x14d638){var _0xf37b11={};var _0x573c7d={};var _0x4f8131;var _0x37ee96;return db['User'][_0xb24b('0x98')]({'where':{'id':_0x16360e[_0xb24b('0x66')]['id']}})['then'](handleEntityNotFound(_0x315fc8,null))[_0xb24b('0x21')](function(_0x6ffce2){if(_0x6ffce2){_0x4f8131=_0x6ffce2;_0x573c7d[_0xb24b('0x4b')]=_['keys'](db[_0xb24b('0x12c')]['rawAttributes']);_0x573c7d[_0xb24b('0x4e')]=_[_0xb24b('0x4f')](_0x16360e[_0xb24b('0x4e')]);_0x573c7d[_0xb24b('0x50')]=_[_0xb24b('0x51')](_0x573c7d[_0xb24b('0x4b')],_0x573c7d[_0xb24b('0x4e')]);_0xf37b11[_0xb24b('0x53')]=_[_0xb24b('0x51')](_0x573c7d[_0xb24b('0x4b')],qs[_0xb24b('0x52')](_0x16360e[_0xb24b('0x4e')]['fields']));_0xf37b11[_0xb24b('0x53')]=_0xf37b11[_0xb24b('0x53')][_0xb24b('0xaa')]?_0xf37b11[_0xb24b('0x53')]:_0x573c7d[_0xb24b('0x4b')];_0xf37b11[_0xb24b('0x56')]=qs['sort'](_0x16360e[_0xb24b('0x4e')][_0xb24b('0x57')]);_0xf37b11['where']=qs[_0xb24b('0x50')](_[_0xb24b('0x59')](_0x16360e[_0xb24b('0x4e')],_0x573c7d[_0xb24b('0x50')]));if(_0x16360e[_0xb24b('0x4e')][_0xb24b('0x3c')]){_0xf37b11['where']=_[_0xb24b('0x5a')](_0xf37b11[_0xb24b('0x58')],{'$or':_[_0xb24b('0x47')](_0xf37b11[_0xb24b('0x53')],function(_0x4d0f0d){var _0x192d90={};_0x192d90[_0x4d0f0d]={'$like':'%'+_0x16360e['query']['filter']+'%'};return _0x192d90;})});}_0xf37b11=_[_0xb24b('0x5a')]({},_0xf37b11,_0x16360e[_0xb24b('0x5f')]);return _0x4f8131['getFaxAccounts'](_0xf37b11);}})[_0xb24b('0x21')](function(_0x143fb5){if(_0x143fb5){_0x37ee96=_0x143fb5[_0xb24b('0xaa')];if(!_0x16360e['query'][_0xb24b('0x54')]('nolimit')){_0xf37b11[_0xb24b('0x31')]=qs[_0xb24b('0x31')](_0x16360e[_0xb24b('0x4e')][_0xb24b('0x31')]);_0xf37b11[_0xb24b('0x30')]=qs[_0xb24b('0x30')](_0x16360e['query'][_0xb24b('0x30')]);}return _0x4f8131['getFaxAccounts'](_0xf37b11);}})['then'](function(_0x1003d0){if(_0x1003d0){return _0x1003d0?{'count':_0x37ee96,'rows':_0x1003d0}:null;}})['then'](respondWithResult(_0x315fc8,null))[_0xb24b('0x2b')](handleError(_0x315fc8,null));};exports['addFaxAccounts']=function(_0x28a5eb,_0x16c70f,_0x2c0dc4){return db[_0xb24b('0x60')]['find']({'where':{'id':_0x28a5eb[_0xb24b('0x66')]['id']}})[_0xb24b('0x21')](handleEntityNotFound(_0x16c70f,null))[_0xb24b('0x21')](function(_0x22c4ae){if(_0x22c4ae){return _0x22c4ae[_0xb24b('0x12d')](_0x28a5eb[_0xb24b('0x69')][_0xb24b('0x6c')],_[_0xb24b('0x6d')](_0x28a5eb[_0xb24b('0x69')],[_0xb24b('0x6c'),'id'])||{});}})[_0xb24b('0x21')](respondWithResult(_0x16c70f,null))[_0xb24b('0x2b')](handleError(_0x16c70f,null));};exports[_0xb24b('0x12e')]=function(_0x3050dd,_0x551714,_0x5d3af1){return db[_0xb24b('0x60')][_0xb24b('0x40')]({'where':{'id':_0x3050dd['params']['id']}})[_0xb24b('0x21')](handleEntityNotFound(_0x551714,null))['then'](function(_0x1ab2ff){if(_0x1ab2ff){return _0x1ab2ff[_0xb24b('0x12e')](_0x3050dd[_0xb24b('0x4e')]['ids']);}})[_0xb24b('0x21')](respondWithStatusCode(_0x551714,null))['catch'](handleError(_0x551714,null));};exports[_0xb24b('0x12f')]=function(_0x43477e,_0x40c40d,_0x2110a0){var _0x4c43a4={};var _0x25c355={};var _0x3f1de5;var _0x3a9020;return db[_0xb24b('0x60')][_0xb24b('0x98')]({'where':{'id':_0x43477e['params']['id']}})[_0xb24b('0x21')](handleEntityNotFound(_0x40c40d,null))[_0xb24b('0x21')](function(_0x3692ec){if(_0x3692ec){_0x3f1de5=_0x3692ec;_0x25c355[_0xb24b('0x4b')]=_[_0xb24b('0x4f')](db['MailAccount']['rawAttributes']);_0x25c355['query']=_['keys'](_0x43477e['query']);_0x25c355[_0xb24b('0x50')]=_[_0xb24b('0x51')](_0x25c355['model'],_0x25c355['query']);_0x4c43a4['attributes']=_[_0xb24b('0x51')](_0x25c355['model'],qs[_0xb24b('0x52')](_0x43477e[_0xb24b('0x4e')][_0xb24b('0x52')]));_0x4c43a4[_0xb24b('0x53')]=_0x4c43a4[_0xb24b('0x53')][_0xb24b('0xaa')]?_0x4c43a4['attributes']:_0x25c355['model'];_0x4c43a4[_0xb24b('0x56')]=qs[_0xb24b('0x57')](_0x43477e['query']['sort']);_0x4c43a4[_0xb24b('0x58')]=qs['filters'](_[_0xb24b('0x59')](_0x43477e[_0xb24b('0x4e')],_0x25c355[_0xb24b('0x50')]));if(_0x43477e[_0xb24b('0x4e')][_0xb24b('0x3c')]){_0x4c43a4[_0xb24b('0x58')]=_['merge'](_0x4c43a4[_0xb24b('0x58')],{'$or':_[_0xb24b('0x47')](_0x4c43a4['attributes'],function(_0x15a382){var _0x1283cb={};_0x1283cb[_0x15a382]={'$like':'%'+_0x43477e[_0xb24b('0x4e')]['filter']+'%'};return _0x1283cb;})});}_0x4c43a4=_['merge']({},_0x4c43a4,_0x43477e[_0xb24b('0x5f')]);return _0x3f1de5[_0xb24b('0x12f')](_0x4c43a4);}})[_0xb24b('0x21')](function(_0x2be13a){if(_0x2be13a){_0x3a9020=_0x2be13a['length'];if(!_0x43477e[_0xb24b('0x4e')][_0xb24b('0x54')](_0xb24b('0x55'))){_0x4c43a4[_0xb24b('0x31')]=qs['limit'](_0x43477e['query']['limit']);_0x4c43a4[_0xb24b('0x30')]=qs[_0xb24b('0x30')](_0x43477e[_0xb24b('0x4e')][_0xb24b('0x30')]);}return _0x3f1de5[_0xb24b('0x12f')](_0x4c43a4);}})[_0xb24b('0x21')](function(_0x138e49){if(_0x138e49){return _0x138e49?{'count':_0x3a9020,'rows':_0x138e49}:null;}})[_0xb24b('0x21')](respondWithResult(_0x40c40d,null))[_0xb24b('0x2b')](handleError(_0x40c40d,null));};exports['addMailAccounts']=function(_0x5680a3,_0xcc39f8,_0x192aa3){return db[_0xb24b('0x60')][_0xb24b('0x40')]({'where':{'id':_0x5680a3[_0xb24b('0x66')]['id']}})[_0xb24b('0x21')](handleEntityNotFound(_0xcc39f8,null))[_0xb24b('0x21')](function(_0x3ebb3d){if(_0x3ebb3d){return _0x3ebb3d[_0xb24b('0x130')](_0x5680a3['body']['ids'],_['omit'](_0x5680a3[_0xb24b('0x69')],[_0xb24b('0x6c'),'id'])||{});}})['then'](respondWithResult(_0xcc39f8,null))[_0xb24b('0x2b')](handleError(_0xcc39f8,null));};exports[_0xb24b('0x131')]=function(_0x50f9d1,_0x207dc3,_0x40098a){return db[_0xb24b('0x60')]['find']({'where':{'id':_0x50f9d1[_0xb24b('0x66')]['id']}})['then'](handleEntityNotFound(_0x207dc3,null))[_0xb24b('0x21')](function(_0x38f982){if(_0x38f982){return _0x38f982['removeMailAccounts'](_0x50f9d1[_0xb24b('0x4e')][_0xb24b('0x6c')]);}})['then'](respondWithStatusCode(_0x207dc3,null))[_0xb24b('0x2b')](handleError(_0x207dc3,null));};exports[_0xb24b('0x132')]=function(_0x9fe134,_0x4bf36f,_0xe05621){var _0x2e1f3c={};var _0x5ea87f={};var _0x2e1abe;var _0x1bf750;return db['User'][_0xb24b('0x98')]({'where':{'id':_0x9fe134['params']['id']}})[_0xb24b('0x21')](handleEntityNotFound(_0x4bf36f,null))['then'](function(_0x43ff84){if(_0x43ff84){_0x2e1abe=_0x43ff84;_0x5ea87f[_0xb24b('0x4b')]=_[_0xb24b('0x4f')](db[_0xb24b('0x133')][_0xb24b('0x67')]);_0x5ea87f[_0xb24b('0x4e')]=_[_0xb24b('0x4f')](_0x9fe134[_0xb24b('0x4e')]);_0x5ea87f[_0xb24b('0x50')]=_[_0xb24b('0x51')](_0x5ea87f[_0xb24b('0x4b')],_0x5ea87f['query']);_0x2e1f3c[_0xb24b('0x53')]=_[_0xb24b('0x51')](_0x5ea87f[_0xb24b('0x4b')],qs[_0xb24b('0x52')](_0x9fe134[_0xb24b('0x4e')][_0xb24b('0x52')]));_0x2e1f3c['attributes']=_0x2e1f3c[_0xb24b('0x53')]['length']?_0x2e1f3c[_0xb24b('0x53')]:_0x5ea87f[_0xb24b('0x4b')];_0x2e1f3c[_0xb24b('0x56')]=qs[_0xb24b('0x57')](_0x9fe134[_0xb24b('0x4e')][_0xb24b('0x57')]);_0x2e1f3c[_0xb24b('0x58')]=qs['filters'](_[_0xb24b('0x59')](_0x9fe134['query'],_0x5ea87f[_0xb24b('0x50')]));if(_0x9fe134[_0xb24b('0x4e')][_0xb24b('0x3c')]){_0x2e1f3c[_0xb24b('0x58')]=_[_0xb24b('0x5a')](_0x2e1f3c['where'],{'$or':_[_0xb24b('0x47')](_0x2e1f3c[_0xb24b('0x53')],function(_0x3eb8be){var _0x4960e2={};_0x4960e2[_0x3eb8be]={'$like':'%'+_0x9fe134[_0xb24b('0x4e')][_0xb24b('0x3c')]+'%'};return _0x4960e2;})});}_0x2e1f3c=_[_0xb24b('0x5a')]({},_0x2e1f3c,_0x9fe134[_0xb24b('0x5f')]);return _0x2e1abe[_0xb24b('0x132')](_0x2e1f3c);}})[_0xb24b('0x21')](function(_0x3fe60e){if(_0x3fe60e){_0x1bf750=_0x3fe60e['length'];if(!_0x9fe134[_0xb24b('0x4e')][_0xb24b('0x54')](_0xb24b('0x55'))){_0x2e1f3c[_0xb24b('0x31')]=qs[_0xb24b('0x31')](_0x9fe134['query'][_0xb24b('0x31')]);_0x2e1f3c[_0xb24b('0x30')]=qs['offset'](_0x9fe134['query'][_0xb24b('0x30')]);}return _0x2e1abe['getOpenchannelAccounts'](_0x2e1f3c);}})[_0xb24b('0x21')](function(_0x28cf92){if(_0x28cf92){return _0x28cf92?{'count':_0x1bf750,'rows':_0x28cf92}:null;}})['then'](respondWithResult(_0x4bf36f,null))['catch'](handleError(_0x4bf36f,null));};exports[_0xb24b('0x134')]=function(_0x3ac587,_0x1473ad,_0x2b2264){return db[_0xb24b('0x60')][_0xb24b('0x40')]({'where':{'id':_0x3ac587['params']['id']}})[_0xb24b('0x21')](handleEntityNotFound(_0x1473ad,null))[_0xb24b('0x21')](function(_0x5c8807){if(_0x5c8807){return _0x5c8807[_0xb24b('0x134')](_0x3ac587[_0xb24b('0x69')][_0xb24b('0x6c')],_[_0xb24b('0x6d')](_0x3ac587['body'],[_0xb24b('0x6c'),'id'])||{});}})['then'](respondWithResult(_0x1473ad,null))[_0xb24b('0x2b')](handleError(_0x1473ad,null));};exports[_0xb24b('0x135')]=function(_0x50e6d0,_0x258866,_0x2a8c5a){return db[_0xb24b('0x60')]['find']({'where':{'id':_0x50e6d0['params']['id']}})[_0xb24b('0x21')](handleEntityNotFound(_0x258866,null))[_0xb24b('0x21')](function(_0x589125){if(_0x589125){return _0x589125['removeOpenchannelAccounts'](_0x50e6d0[_0xb24b('0x4e')][_0xb24b('0x6c')]);}})[_0xb24b('0x21')](respondWithStatusCode(_0x258866,null))[_0xb24b('0x2b')](handleError(_0x258866,null));};exports[_0xb24b('0x136')]=function(_0x4da996,_0x34aadb,_0x25a8b8){var _0x2ab475={};var _0x5d8576={};var _0xeee0c2;var _0x113025;return db[_0xb24b('0x60')][_0xb24b('0x98')]({'where':{'id':_0x4da996['params']['id']}})[_0xb24b('0x21')](handleEntityNotFound(_0x34aadb,null))[_0xb24b('0x21')](function(_0x43933c){if(_0x43933c){_0xeee0c2=_0x43933c;_0x5d8576[_0xb24b('0x4b')]=_[_0xb24b('0x4f')](db[_0xb24b('0x137')][_0xb24b('0x67')]);_0x5d8576[_0xb24b('0x4e')]=_['keys'](_0x4da996[_0xb24b('0x4e')]);_0x5d8576['filters']=_['intersection'](_0x5d8576['model'],_0x5d8576[_0xb24b('0x4e')]);_0x2ab475['attributes']=_[_0xb24b('0x51')](_0x5d8576[_0xb24b('0x4b')],qs[_0xb24b('0x52')](_0x4da996[_0xb24b('0x4e')][_0xb24b('0x52')]));_0x2ab475[_0xb24b('0x53')]=_0x2ab475[_0xb24b('0x53')][_0xb24b('0xaa')]?_0x2ab475[_0xb24b('0x53')]:_0x5d8576[_0xb24b('0x4b')];_0x2ab475['order']=qs[_0xb24b('0x57')](_0x4da996[_0xb24b('0x4e')][_0xb24b('0x57')]);_0x2ab475[_0xb24b('0x58')]=qs[_0xb24b('0x50')](_[_0xb24b('0x59')](_0x4da996[_0xb24b('0x4e')],_0x5d8576[_0xb24b('0x50')]));if(_0x4da996['query']['filter']){_0x2ab475[_0xb24b('0x58')]=_[_0xb24b('0x5a')](_0x2ab475['where'],{'$or':_['map'](_0x2ab475['attributes'],function(_0x52e67b){var _0x488a82={};_0x488a82[_0x52e67b]={'$like':'%'+_0x4da996[_0xb24b('0x4e')][_0xb24b('0x3c')]+'%'};return _0x488a82;})});}_0x2ab475=_[_0xb24b('0x5a')]({},_0x2ab475,_0x4da996[_0xb24b('0x5f')]);return _0xeee0c2[_0xb24b('0x136')](_0x2ab475);}})['then'](function(_0x428fd7){if(_0x428fd7){_0x113025=_0x428fd7[_0xb24b('0xaa')];if(!_0x4da996[_0xb24b('0x4e')][_0xb24b('0x54')](_0xb24b('0x55'))){_0x2ab475[_0xb24b('0x31')]=qs[_0xb24b('0x31')](_0x4da996[_0xb24b('0x4e')][_0xb24b('0x31')]);_0x2ab475[_0xb24b('0x30')]=qs[_0xb24b('0x30')](_0x4da996['query'][_0xb24b('0x30')]);}return _0xeee0c2['getSmsAccounts'](_0x2ab475);}})[_0xb24b('0x21')](function(_0x399e11){if(_0x399e11){return _0x399e11?{'count':_0x113025,'rows':_0x399e11}:null;}})[_0xb24b('0x21')](respondWithResult(_0x34aadb,null))[_0xb24b('0x2b')](handleError(_0x34aadb,null));};exports[_0xb24b('0x138')]=function(_0x134641,_0x371e25,_0x4ac8a1){return db['User'][_0xb24b('0x40')]({'where':{'id':_0x134641['params']['id']}})[_0xb24b('0x21')](handleEntityNotFound(_0x371e25,null))['then'](function(_0xfa3c9e){if(_0xfa3c9e){return _0xfa3c9e['addSmsAccounts'](_0x134641[_0xb24b('0x69')]['ids'],_['omit'](_0x134641['body'],[_0xb24b('0x6c'),'id'])||{});}})[_0xb24b('0x21')](respondWithResult(_0x371e25,null))[_0xb24b('0x2b')](handleError(_0x371e25,null));};exports[_0xb24b('0x139')]=function(_0x540d45,_0x1a5a47,_0x5abace){return db[_0xb24b('0x60')][_0xb24b('0x40')]({'where':{'id':_0x540d45[_0xb24b('0x66')]['id']}})[_0xb24b('0x21')](handleEntityNotFound(_0x1a5a47,null))[_0xb24b('0x21')](function(_0x3de17b){if(_0x3de17b){return _0x3de17b[_0xb24b('0x139')](_0x540d45['query'][_0xb24b('0x6c')]);}})[_0xb24b('0x21')](respondWithStatusCode(_0x1a5a47,null))[_0xb24b('0x2b')](handleError(_0x1a5a47,null));};exports[_0xb24b('0x13a')]=function(_0x54e04c,_0x6c76ef,_0x2e1df7){var _0x54bf95={};var _0x5ebf86={};var _0x14a31e;var _0x2f2b99;return db[_0xb24b('0x60')][_0xb24b('0x98')]({'where':{'id':_0x54e04c['params']['id']}})[_0xb24b('0x21')](handleEntityNotFound(_0x6c76ef,null))['then'](function(_0x19b50a){if(_0x19b50a){_0x14a31e=_0x19b50a;_0x5ebf86['model']=_['keys'](db[_0xb24b('0x13b')][_0xb24b('0x67')]);_0x5ebf86[_0xb24b('0x4e')]=_['keys'](_0x54e04c[_0xb24b('0x4e')]);_0x5ebf86[_0xb24b('0x50')]=_['intersection'](_0x5ebf86[_0xb24b('0x4b')],_0x5ebf86[_0xb24b('0x4e')]);_0x54bf95[_0xb24b('0x53')]=_[_0xb24b('0x51')](_0x5ebf86['model'],qs[_0xb24b('0x52')](_0x54e04c[_0xb24b('0x4e')][_0xb24b('0x52')]));_0x54bf95[_0xb24b('0x53')]=_0x54bf95['attributes'][_0xb24b('0xaa')]?_0x54bf95[_0xb24b('0x53')]:_0x5ebf86[_0xb24b('0x4b')];_0x54bf95['order']=qs['sort'](_0x54e04c[_0xb24b('0x4e')][_0xb24b('0x57')]);_0x54bf95[_0xb24b('0x58')]=qs[_0xb24b('0x50')](_[_0xb24b('0x59')](_0x54e04c['query'],_0x5ebf86[_0xb24b('0x50')]));if(_0x54e04c[_0xb24b('0x4e')]['filter']){_0x54bf95[_0xb24b('0x58')]=_[_0xb24b('0x5a')](_0x54bf95[_0xb24b('0x58')],{'$or':_[_0xb24b('0x47')](_0x54bf95[_0xb24b('0x53')],function(_0x21625f){var _0x2d1510={};_0x2d1510[_0x21625f]={'$like':'%'+_0x54e04c[_0xb24b('0x4e')]['filter']+'%'};return _0x2d1510;})});}_0x54bf95=_[_0xb24b('0x5a')]({},_0x54bf95,_0x54e04c['options']);return _0x14a31e[_0xb24b('0x13a')](_0x54bf95);}})[_0xb24b('0x21')](function(_0x436cb2){if(_0x436cb2){_0x2f2b99=_0x436cb2[_0xb24b('0xaa')];if(!_0x54e04c['query']['hasOwnProperty'](_0xb24b('0x55'))){_0x54bf95['limit']=qs[_0xb24b('0x31')](_0x54e04c[_0xb24b('0x4e')][_0xb24b('0x31')]);_0x54bf95['offset']=qs[_0xb24b('0x30')](_0x54e04c[_0xb24b('0x4e')][_0xb24b('0x30')]);}return _0x14a31e[_0xb24b('0x13a')](_0x54bf95);}})[_0xb24b('0x21')](function(_0x32cf54){if(_0x32cf54){return _0x32cf54?{'count':_0x2f2b99,'rows':_0x32cf54}:null;}})[_0xb24b('0x21')](respondWithResult(_0x6c76ef,null))[_0xb24b('0x2b')](handleError(_0x6c76ef,null));};exports[_0xb24b('0x13c')]=function(_0x3d7ae6,_0x25fb3d,_0xf91f7e){return db[_0xb24b('0x60')][_0xb24b('0x40')]({'where':{'id':_0x3d7ae6[_0xb24b('0x66')]['id']}})['then'](handleEntityNotFound(_0x25fb3d,null))['then'](function(_0x199aa3){if(_0x199aa3){return _0x199aa3['addChatWebsites'](_0x3d7ae6[_0xb24b('0x69')][_0xb24b('0x6c')],_[_0xb24b('0x6d')](_0x3d7ae6['body'],[_0xb24b('0x6c'),'id'])||{});}})[_0xb24b('0x21')](respondWithResult(_0x25fb3d,null))['catch'](handleError(_0x25fb3d,null));};exports[_0xb24b('0x13d')]=function(_0x843212,_0x43f56b,_0x3ef0e0){return db['User'][_0xb24b('0x40')]({'where':{'id':_0x843212[_0xb24b('0x66')]['id']}})[_0xb24b('0x21')](handleEntityNotFound(_0x43f56b,null))[_0xb24b('0x21')](function(_0x24655b){if(_0x24655b){return _0x24655b[_0xb24b('0x13d')](_0x843212[_0xb24b('0x4e')][_0xb24b('0x6c')]);}})[_0xb24b('0x21')](respondWithStatusCode(_0x43f56b,null))['catch'](handleError(_0x43f56b,null));};exports['getSquareProjects']=function(_0x1afd6c,_0xe8ac80,_0x2843f4){var _0x21f362={};var _0x5c24c3={};var _0x5dca99;var _0x3106a1;return db[_0xb24b('0x60')][_0xb24b('0x98')]({'where':{'id':_0x1afd6c['params']['id']}})['then'](handleEntityNotFound(_0xe8ac80,null))[_0xb24b('0x21')](function(_0x3495f6){if(_0x3495f6){_0x5dca99=_0x3495f6;_0x5c24c3['model']=_[_0xb24b('0x4f')](db[_0xb24b('0x13e')][_0xb24b('0x67')]);_0x5c24c3[_0xb24b('0x4e')]=_[_0xb24b('0x4f')](_0x1afd6c[_0xb24b('0x4e')]);_0x5c24c3['filters']=_['intersection'](_0x5c24c3['model'],_0x5c24c3[_0xb24b('0x4e')]);_0x21f362[_0xb24b('0x53')]=_[_0xb24b('0x51')](_0x5c24c3[_0xb24b('0x4b')],qs[_0xb24b('0x52')](_0x1afd6c[_0xb24b('0x4e')][_0xb24b('0x52')]));_0x21f362[_0xb24b('0x53')]=_0x21f362[_0xb24b('0x53')]['length']?_0x21f362[_0xb24b('0x53')]:_0x5c24c3[_0xb24b('0x4b')];_0x21f362['order']=qs[_0xb24b('0x57')](_0x1afd6c[_0xb24b('0x4e')][_0xb24b('0x57')]);_0x21f362[_0xb24b('0x58')]=qs['filters'](_['pick'](_0x1afd6c[_0xb24b('0x4e')],_0x5c24c3['filters']));if(_0x1afd6c[_0xb24b('0x4e')][_0xb24b('0x3c')]){_0x21f362['where']=_[_0xb24b('0x5a')](_0x21f362[_0xb24b('0x58')],{'$or':_[_0xb24b('0x47')](_0x21f362['attributes'],function(_0x35c73b){var _0x512bd0={};_0x512bd0[_0x35c73b]={'$like':'%'+_0x1afd6c[_0xb24b('0x4e')][_0xb24b('0x3c')]+'%'};return _0x512bd0;})});}_0x21f362=_['merge']({},_0x21f362,_0x1afd6c['options']);return _0x5dca99[_0xb24b('0x13f')](_0x21f362);}})['then'](function(_0x1ef8ee){if(_0x1ef8ee){_0x3106a1=_0x1ef8ee[_0xb24b('0xaa')];if(!_0x1afd6c[_0xb24b('0x4e')][_0xb24b('0x54')]('nolimit')){_0x21f362[_0xb24b('0x31')]=qs[_0xb24b('0x31')](_0x1afd6c['query']['limit']);_0x21f362[_0xb24b('0x30')]=qs[_0xb24b('0x30')](_0x1afd6c[_0xb24b('0x4e')][_0xb24b('0x30')]);}return _0x5dca99[_0xb24b('0x13f')](_0x21f362);}})[_0xb24b('0x21')](function(_0x26c8f9){if(_0x26c8f9){return _0x26c8f9?{'count':_0x3106a1,'rows':_0x26c8f9}:null;}})[_0xb24b('0x21')](respondWithResult(_0xe8ac80,null))['catch'](handleError(_0xe8ac80,null));};exports[_0xb24b('0x140')]=function(_0x525706,_0x26acf3,_0x397db2){return db[_0xb24b('0x60')][_0xb24b('0x40')]({'where':{'id':_0x525706[_0xb24b('0x66')]['id']}})[_0xb24b('0x21')](handleEntityNotFound(_0x26acf3,null))[_0xb24b('0x21')](function(_0x54de2c){if(_0x54de2c){return _0x54de2c[_0xb24b('0x140')](_0x525706[_0xb24b('0x69')][_0xb24b('0x6c')],_['omit'](_0x525706[_0xb24b('0x69')],[_0xb24b('0x6c'),'id'])||{});}})[_0xb24b('0x21')](respondWithResult(_0x26acf3,null))[_0xb24b('0x2b')](handleError(_0x26acf3,null));};exports[_0xb24b('0x141')]=function(_0x3d2acc,_0x30290a,_0x11c170){return db[_0xb24b('0x60')][_0xb24b('0x40')]({'where':{'id':_0x3d2acc[_0xb24b('0x66')]['id']}})[_0xb24b('0x21')](handleEntityNotFound(_0x30290a,null))[_0xb24b('0x21')](function(_0x125c3c){if(_0x125c3c){return _0x125c3c['removeSquareProjects'](_0x3d2acc['query'][_0xb24b('0x6c')]);}})[_0xb24b('0x21')](respondWithStatusCode(_0x30290a,null))[_0xb24b('0x2b')](handleError(_0x30290a,null));};exports[_0xb24b('0x142')]=function(_0x3b99e8,_0x7abaa2){var _0x3824c3={},_0x251a39={},_0x4186f5={'count':0x0,'rows':[]};var _0x9bbef9=db[_0xb24b('0x143')][_0xb24b('0x67')];_0x251a39['model']=_[_0xb24b('0x4f')](_0x9bbef9);_0x251a39[_0xb24b('0x4e')]=_['keys'](_0x3b99e8[_0xb24b('0x4e')]);_0x251a39[_0xb24b('0x50')]=_['intersection'](_0x251a39[_0xb24b('0x4b')],_0x251a39['query']);_0x251a39[_0xb24b('0x50')]=_[_0xb24b('0x144')](_0x251a39[_0xb24b('0x50')],['$and',_0xb24b('0x145'),_0xb24b('0x146'),_0xb24b('0x147'),_0xb24b('0x148'),_0xb24b('0x149'),_0xb24b('0x14a'),_0xb24b('0x14b'),_0xb24b('0x14c'),_0xb24b('0x14d'),_0xb24b('0x14e'),_0xb24b('0x14f'),_0xb24b('0x150'),_0xb24b('0x151'),'$notLike','$iLike',_0xb24b('0x152'),_0xb24b('0x151'),_0xb24b('0x153'),'$contains',_0xb24b('0x154'),_0xb24b('0x155')]);_0x3824c3[_0xb24b('0x53')]=_['intersection'](_0x251a39['model'],qs[_0xb24b('0x52')](_0x3b99e8[_0xb24b('0x4e')][_0xb24b('0x52')]));_0x3824c3[_0xb24b('0x53')]=_0x3824c3[_0xb24b('0x53')][_0xb24b('0xaa')]?_0x3824c3[_0xb24b('0x53')]:_0x251a39['model'];if(!_0x3b99e8[_0xb24b('0x4e')][_0xb24b('0x54')](_0xb24b('0x55'))){_0x3824c3['limit']=qs[_0xb24b('0x31')](_0x3b99e8[_0xb24b('0x4e')][_0xb24b('0x31')]);_0x3824c3[_0xb24b('0x30')]=qs[_0xb24b('0x30')](_0x3b99e8[_0xb24b('0x4e')][_0xb24b('0x30')]);}_0x3824c3[_0xb24b('0x56')]=qs[_0xb24b('0x57')](_0x3b99e8['query'][_0xb24b('0x57')]);_0x3824c3[_0xb24b('0x58')]=qs[_0xb24b('0x50')](_[_0xb24b('0x59')](_0x3b99e8[_0xb24b('0x4e')],_0x251a39[_0xb24b('0x50')]));if(_0x3b99e8[_0xb24b('0x4e')][_0xb24b('0x3c')]){_0x3824c3[_0xb24b('0x58')]=_['merge'](_0x3824c3[_0xb24b('0x58')],{'$or':_[_0xb24b('0x47')](_0x3824c3[_0xb24b('0x53')],function(_0x5a8e4c){var _0x34597e={};_0x34597e[_0x5a8e4c]={'$like':'%'+_0x3b99e8['query'][_0xb24b('0x3c')]+'%'};return _0x34597e;})});}_0x3824c3[_0xb24b('0x58')]={'$and':[_0x3824c3[_0xb24b('0x58')],{'$or':[{'UserId':_0x3b99e8[_0xb24b('0x66')]['id']},{'OwnerId':_0x3b99e8[_0xb24b('0x66')]['id']}]}]};_0x3824c3=_[_0xb24b('0x5a')]({},_0x3824c3,_0x3b99e8['options']);var _0x1fc282={'where':_0x3824c3['where']};return db[_0xb24b('0x143')][_0xb24b('0x2f')](_0x1fc282)[_0xb24b('0x21')](function(_0x495780){_0x4186f5[_0xb24b('0x2f')]=_0x495780;if(_0x3b99e8['query'][_0xb24b('0x61')]){_0x3824c3[_0xb24b('0x62')]=[{'attributes':['id',_0xb24b('0x156'),'lastName','phone'],'model':db[_0xb24b('0x157')],'as':_0xb24b('0x158')},{'attributes':['id',_0xb24b('0x41'),_0xb24b('0x159')],'model':db[_0xb24b('0xb0')],'as':_0xb24b('0xca')}];}return db[_0xb24b('0x143')][_0xb24b('0x63')](_0x3824c3);})['then'](function(_0x19a536){_0x4186f5[_0xb24b('0x64')]=_0x19a536;return _0x4186f5;})[_0xb24b('0x21')](respondWithFilteredResult(_0x7abaa2,_0x3824c3))[_0xb24b('0x2b')](handleError(_0x7abaa2,null));};exports[_0xb24b('0x15a')]=function(_0x579d44,_0xf3ba34,_0x3bde69){if(!_[_0xb24b('0x74')](_0x579d44[_0xb24b('0x92')]['id'])&&(_0x579d44['user'][_0xb24b('0x3f')]==_0xb24b('0x6f')||_0x579d44['user'][_0xb24b('0x3f')]==_0xb24b('0x92'))){return db['User'][_0xb24b('0x98')]({'where':{'id':_0x579d44[_0xb24b('0x66')]['id']},'raw':!![]})[_0xb24b('0x21')](function(_0x162ec1){return authService[_0xb24b('0x15b')](_0x162ec1);})['then'](function(_0x464b44){if(_0x464b44){return _0xf3ba34['status'](0xc8)[_0xb24b('0x2e')]({'api_key':_0x464b44[_0xb24b('0x15c')]});}else{return _0xf3ba34[_0xb24b('0x2c')](0xcc)[_0xb24b('0x2e')]({'message':_0xb24b('0x15d')});}})[_0xb24b('0x2b')](handleError(_0xf3ba34,0x193));}else{return _0xf3ba34[_0xb24b('0x2c')](0x191)['json']({'message':_0xb24b('0x15e')});}};exports['createApiKey']=function(_0x179753,_0xd16807,_0x1c235b){if(!_[_0xb24b('0x74')](_0x179753[_0xb24b('0x92')]['id'])&&(_0x179753['user'][_0xb24b('0x3f')]==_0xb24b('0x6f')||_0x179753['user'][_0xb24b('0x3f')]==_0xb24b('0x92'))){return db['User']['find']({'where':{'id':_0x179753[_0xb24b('0x66')]['id']}})['then'](function(_0x5d4786){return authService[_0xb24b('0x15f')](_0x5d4786);})['then'](function(_0x48c6bf){return db[_0xb24b('0x60')][_0xb24b('0x36')]({'apiKeyIat':_0x48c6bf['iat'],'apiKeyNonce':_0x48c6bf[_0xb24b('0x160')]},{'where':{'id':_0x179753[_0xb24b('0x66')]['id']}})[_0xb24b('0x21')](function(){return _0xd16807['status'](0xc8)['json']({'api_key':_0x48c6bf[_0xb24b('0x15c')]});});})['catch'](handleError(_0xd16807,0x193));}else{return _0xd16807['status'](0x191)[_0xb24b('0x2e')]({'message':_0xb24b('0x15e')});}};exports[_0xb24b('0x161')]=function(_0x547018,_0x301bab,_0x5b2862){if(!_[_0xb24b('0x74')](_0x547018[_0xb24b('0x92')]['id'])&&(_0x547018[_0xb24b('0x92')]['role']==_0xb24b('0x6f')||_0x547018[_0xb24b('0x92')][_0xb24b('0x3f')]==_0xb24b('0x92'))){return db[_0xb24b('0x60')]['find']({'where':{'id':_0x547018[_0xb24b('0x66')]['id']}})[_0xb24b('0x21')](handleEntityNotFound(_0x301bab,null))[_0xb24b('0x21')](function(_0x48b60a){if(_0x48b60a&&_0x48b60a[_0xb24b('0x162')]&&_0x48b60a[_0xb24b('0x163')])return _0x48b60a;else throw{'message':'API\x20key\x20not\x20available'};})['then'](function(_0xfedacb){return db['User'][_0xb24b('0x36')]({'apiKeyNonce':null,'apiKeyIat':null},{'where':{'id':_0x547018[_0xb24b('0x66')]['id']}});})[_0xb24b('0x21')](respondWithStatusCode(_0x301bab,0xc8))[_0xb24b('0x2b')](handleError(_0x301bab,0x193));}else{return _0x301bab[_0xb24b('0x2c')](0x191)[_0xb24b('0x2e')]({'message':_0xb24b('0x15e')});}};exports[_0xb24b('0x164')]=function(_0x25009e,_0x18e93b){var _0x44f722=_0x25009e[_0xb24b('0x92')][_0xb24b('0x37')]({'plain':!![]});if(!_0x44f722){return _0x18e93b[_0xb24b('0x2c')](0x191)[_0xb24b('0x46')]('Unable\x20to\x20retrieve\x20the\x20current\x20user');}else{return _0x18e93b[_0xb24b('0x2c')](0xc8)[_0xb24b('0x2e')](_0x44f722);}};
\ No newline at end of file
+var _0x89be=['ui.createdAt','user_has_','_interactions','ui.UserId\x20=\x20?','toString','moment','bluebird','util','path','lodash','squel','jayson/promise','ioredis','../../components/auth/service','../../config/logger','api','../../config/utils','APIBadRequestError','../../errors/api','APINotFoundError','handleError','../../mysqldb','socket.io-emitter','redis','./user.socket','register','defaults','localhost','client','http','request','then','request\x20sent','debug','stringify','error','code','message','User,\x20%s,\x20%s','result','status','end','offset','undefined','limit','count','set','Content-Range','json','update','userNotification:recalc:','destroy','role','admin','user','Agents','agent','telephone','ignore','value','name','UserProfileResource','sendStatus','stack','send','index','rawAttributes','map','type','filter','includes','password','salt','getOptions','where','User','query','userSetting','true','include','attributes','findAll','rows','length','push','chat','dataValues','fax','mail','whatsapp','all','show','params','model','differenceBy','keys','filters','intersection','fields','includeAll','UserSetting','merge','options','find','sms','openchannel','catch','body','describe','addContacts','ids','omit','internal','Setting','findById','securePassword','validatePasswordPattern','isNil','min_internal','sequelize','QueryTypes','SELECT','from','mailbox','VoiceMail','fullname','permissions','101','102','113','104','105','107','109','111','114','115','create','Unauthorized','Unauthorized.\x20You\x20must\x20be\x20an\x20administrator\x20in\x20order\x20to\x20create\x20an\x20user','Unauthorized.\x20You\x20must\x20be\x20an\x20administrator\x20in\x20order\x20to\x20create\x20another\x20administrator','checkUserLimits','settingsEnabled','UserProfileSection','Telephones','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','each','isEmpty','autoAssociation','compact','changePassword','oldPassword','newPassword','Sequelize','ValidationError','Invalid\x20body\x20format.\x20Use\x20oldPassword\x20and\x20newPassword','Invalid\x20body\x20format.\x20Use\x20newPassword','enforcePasswordHistory','passwordHistoryLimit','previousPasswords','validatePasswordHistory','updatePasswordsHistory','channel','loginInPause','interface','isValidChannel','capitalize','toLowerCase','Queues','penalty','spread','QueueId','emit','Queue:save','voice','VoiceQueue','get','format','SIP/%s','voicePause','UserVoiceQueueRt','removeQueues','Unknown\x20channel','Queue:remove','addAvatar','userpic','file','filename','getAvatar','root','server/files/images/logos/default_profile.png','download','existsSync','join','server/files/images/','getOpenTabs','ChatOpenTabs','CHAT','createdAt','FaxOpenTabs','FAX','OpenchannelOpenTabs','MailOpenTabs','MAIL','SmsOpenTabs','SMS','concat','findOne','CmContact','sort','pick','getContacts','hasOwnProperty','CmList','List','Tag','Tags','tag','nolimit','order','Queue','Unknown\x20role','getVoiceQueuesRt','ChatGroup','getGroups','VoiceRecording','getScreenRecordings','UserId','ScreenRecording','getChatInteractions','ChatInteraction','getOpenchannelInteractions','OpenchannelInteraction','getMailInteractions','MailInteraction','getSmsInteractions','SmsInteraction','getFaxInteractions','FaxInteraction','getWhatsappInteractions','WhatsappInteraction','login','phone','mobile','LOCAL/%s@from-sip/n','user:%s','headers','x-forwarded-for','remoteAddress','socket','connection','User\x20not\x20found\x20or\x20not\x20allowed\x20to\x20perform\x20login\x20method','getVoiceQueues','UserVoiceQueue.penalty','upsert','MemberReport','forEach','YYYY-MM-DD\x20HH:mm:ss','LOGIN','device','PAUSE','LOGININPAUSE','isMiddleware','resolve','logout','pause','QueuePause','getChannels','DEFAULT\x20PAUSE','unpause','mailPause','chatPause','faxPause','smsPause','whatsapppause','lastPauseAt','manual','%s%s','Pause','Team','getTeams','Body\x20parameter\x20\x27ids\x27\x20is\x20required','User\x20with\x20id\x20%s\x20not\x20found','transaction','addTeams','getAssociatedQueues','addAgent','getDataValue','TeamVoicePrefix','UserVoicePrefix','removeTeams','isArray','flattenDeep','online','Voice','getLists','getAgents','values','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','removeFaxInteractions','user_has_fax_interactions:remove','user_has_sms_interactions:save','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','getFaxAccounts','addFaxAccounts','removeFaxAccounts','getMailAccounts','addMailAccounts','removeMailAccounts','getOpenchannelAccounts','addOpenchannelAccounts','removeOpenchannelAccounts','getSmsAccounts','SmsAccount','addSmsAccounts','removeSmsAccounts','getChatWebsites','ChatWebsite','addChatWebsites','removeChatWebsites','WhatsappAccount','getWhatsappAccounts','addWhatsappAccounts','removeWhatsappAccounts','getSquareProjects','SquareProject','addSquareProjects','removeSquareProjects','getScheduledCalls','CmHopper','$and','$gt','$lt','$lte','$ne','$eq','$not','$between','$notBetween','$in','$notIn','$like','$notLike','$iLike','$notILike','$overlap','$contained','$any','firstName','lastName','getApiKey','retrieveApiKey','token','You\x20don\x27t\x20have\x20sufficient\x20privileges\x20to\x20access\x20this\x20resource.','iat','nonce','apiKeyNonce','API\x20key\x20not\x20available','whoami','Unable\x20to\x20retrieve\x20the\x20current\x20user','getUserSetting','getPresence','teams','queues','inbound','flatten','col','asc','desc','orderBy','Unable\x20to\x20retrieve\x20RPC\x20agents\x20(AMI)','Unable\x20to\x20retrieve\x20RPC\x20agents\x20(Routing)','offline','idle','unknown','unavailable','ringing','voiceStatus','busy','slice','charAt','field','ui.'];(function(_0x205c39,_0x5cca7f){var _0xa57bb5=function(_0x27cf00){while(--_0x27cf00){_0x205c39['push'](_0x205c39['shift']());}};_0xa57bb5(++_0x5cca7f);}(_0x89be,0x198));var _0xe89b=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0x89be[_0x3dd15e];return _0x231fd0;};'use strict';var moment=require(_0xe89b('0x0'));var BPromise=require(_0xe89b('0x1'));var util=require(_0xe89b('0x2'));var path=require(_0xe89b('0x3'));var fs=require('fs');var _=require(_0xe89b('0x4'));var squel=require(_0xe89b('0x5'));var jayson=require(_0xe89b('0x6'));var Redis=require(_0xe89b('0x7'));var authService=require(_0xe89b('0x8'));var qs=require('../../components/parsers/qs');var logger=require(_0xe89b('0x9'))(_0xe89b('0xa'));var utils=require(_0xe89b('0xb'));var config=require('../../config/environment');var licenseUtil=require('../../config/license/util');var APIBadRequestError=require('../../errors/api')[_0xe89b('0xc')];var APINotFoundError=require(_0xe89b('0xd'))[_0xe89b('0xe')];var APIHandleError=require('../../errors/api')[_0xe89b('0xf')];var db=require(_0xe89b('0x10'))['db'];var socket=require(_0xe89b('0x11'))(new Redis(config[_0xe89b('0x12')]));require(_0xe89b('0x13'))[_0xe89b('0x14')](socket);config[_0xe89b('0x12')]=_[_0xe89b('0x15')](config[_0xe89b('0x12')],{'host':_0xe89b('0x16'),'port':0x18eb});var client=jayson[_0xe89b('0x17')][_0xe89b('0x18')]({'port':0x232a});var values;function respondWithRpcPromise(_0x3de879,_0x5bb656,_0x2266d3,_0x4d8be4){return new BPromise(function(_0x4875e7,_0x47ce6c){var _0x31ccaa=_0x4d8be4||client;return _0x31ccaa[_0xe89b('0x19')](_0x3de879,_0x2266d3)[_0xe89b('0x1a')](function(_0x3e083f){logger['info']('User,\x20%s,\x20%s',_0x5bb656,_0xe89b('0x1b'));logger[_0xe89b('0x1c')]('User,\x20%s,\x20%s,\x20%s',_0x5bb656,_0xe89b('0x1b'),JSON[_0xe89b('0x1d')](_0x3e083f));if(_0x3e083f[_0xe89b('0x1e')]){if(_0x3e083f[_0xe89b('0x1e')][_0xe89b('0x1f')]===0x1f4){logger['error']('User,\x20%s,\x20%s',_0x5bb656,_0x3e083f[_0xe89b('0x1e')]['message']);return _0x47ce6c(_0x3e083f[_0xe89b('0x1e')][_0xe89b('0x20')]);}logger[_0xe89b('0x1e')](_0xe89b('0x21'),_0x5bb656,_0x3e083f['error'][_0xe89b('0x20')]);return _0x4875e7(_0x3e083f[_0xe89b('0x1e')][_0xe89b('0x20')]);}else{logger['info']('User,\x20%s,\x20%s',_0x5bb656,'request\x20sent');_0x4875e7(_0x3e083f[_0xe89b('0x22')][_0xe89b('0x20')]);}})['catch'](function(_0x4429c4){logger['error'](_0xe89b('0x21'),_0x5bb656,_0x4429c4);_0x47ce6c(_0x4429c4);});});}function respondWithStatusCode(_0x1ca52a,_0x1a0887){_0x1a0887=_0x1a0887||0xcc;return function(_0x12d4b4){if(_0x12d4b4){return _0x1ca52a['sendStatus'](_0x1a0887);}return _0x1ca52a[_0xe89b('0x23')](_0x1a0887)[_0xe89b('0x24')]();};}function respondWithResult(_0x3bd703,_0x3cb0a9){_0x3cb0a9=_0x3cb0a9||0xc8;return function(_0x5939c5){if(_0x5939c5){return _0x3bd703[_0xe89b('0x23')](_0x3cb0a9)['json'](_0x5939c5);}};}function respondWithFilteredResult(_0x321e7a,_0x4b729b){return function(_0x19f093){if(_0x19f093){var _0x2abd29=typeof _0x4b729b[_0xe89b('0x25')]===_0xe89b('0x26')&&typeof _0x4b729b[_0xe89b('0x27')]===_0xe89b('0x26');var _0x277c3b=_0x19f093[_0xe89b('0x28')];var _0x2680ce=_0x2abd29?0x0:_0x4b729b[_0xe89b('0x25')];var _0x5ed1a7=_0x2abd29?_0x19f093[_0xe89b('0x28')]:_0x4b729b[_0xe89b('0x25')]+_0x4b729b['limit'];var _0x440067;if(_0x5ed1a7>=_0x277c3b){_0x5ed1a7=_0x277c3b;_0x440067=0xc8;}else{_0x440067=0xce;}_0x321e7a[_0xe89b('0x23')](_0x440067);return _0x321e7a[_0xe89b('0x29')](_0xe89b('0x2a'),_0x2680ce+'-'+_0x5ed1a7+'/'+_0x277c3b)[_0xe89b('0x2b')](_0x19f093);}return null;};}function saveUpdates(_0x5a4d83){return function(_0x509e84){if(_0x509e84){return _0x509e84[_0xe89b('0x2c')](_0x5a4d83)['then'](function(_0x5463d8){socket['emit'](_0xe89b('0x2d')+_0x5463d8['id'],{});return _0x5463d8;});}return null;};}function removeEntity(_0x3e7e91){return function(_0x5e210e){if(_0x5e210e){return _0x5e210e[_0xe89b('0x2e')]()[_0xe89b('0x1a')](function(){var _0x256bd9=_0x5e210e['get']({'plain':!![]});if(_0x256bd9[_0xe89b('0x2f')]===_0xe89b('0x30'))return;var _0x17f78a=[{'name':'Users','value':_0xe89b('0x31'),'ignore':!![]},{'name':_0xe89b('0x32'),'value':_0xe89b('0x33'),'ignore':![]},{'name':'Telephones','value':_0xe89b('0x34'),'ignore':![]}];var _0x28af90=_(_0x17f78a)['filter'](_0xe89b('0x35'))['map']('value')[_0xe89b('0x36')]();if(_['includes'](_0x28af90,_0x256bd9[_0xe89b('0x2f')])){return;}var _0x115d6f=_['find'](_0x17f78a,[_0xe89b('0x36'),_0x256bd9[_0xe89b('0x2f')]])[_0xe89b('0x37')];return db[_0xe89b('0x38')]['destroy']({'where':{'type':_0x115d6f,'resourceId':_0x256bd9['id']}})['then'](function(){return _0x5e210e;});})[_0xe89b('0x1a')](function(){_0x3e7e91['status'](0xcc)[_0xe89b('0x24')]();});}};}function handleEntityNotFound(_0x4c9e2e){return function(_0xa75b7a){if(!_0xa75b7a){_0x4c9e2e[_0xe89b('0x39')](0x194);}return _0xa75b7a;};}function handleError(_0x5637dd,_0x462bd8){_0x462bd8=_0x462bd8||0x1f4;return function(_0x4b5834){logger[_0xe89b('0x1e')](_0x4b5834[_0xe89b('0x3a')]);if(_0x4b5834[_0xe89b('0x37')]){delete _0x4b5834[_0xe89b('0x37')];}_0x5637dd[_0xe89b('0x23')](_0x462bd8)[_0xe89b('0x3b')](_0x4b5834);};}exports[_0xe89b('0x3c')]=function(_0x1843df,_0x5cfd90){var _0x12eec7={},_0x4dfe27={'count':0x0,'rows':[]};var _0x54d15c=_(db['User'][_0xe89b('0x3d')])[_0xe89b('0x3e')](function(_0x39da2a){return{'name':_0x39da2a['fieldName'],'type':_0x39da2a[_0xe89b('0x3f')]['key']};})[_0xe89b('0x40')](function(_0x619f33){return!_[_0xe89b('0x41')]([_0xe89b('0x42'),_0xe89b('0x43')],_0x619f33['name']);})[_0xe89b('0x36')]();_0x12eec7=qs[_0xe89b('0x44')](_0x54d15c,_0x1843df);var _0x110dae={'where':_0x12eec7[_0xe89b('0x45')]};return db[_0xe89b('0x46')][_0xe89b('0x28')](_0x110dae)['then'](function(_0x222c4b){_0x4dfe27['count']=_0x222c4b;if(_0x1843df[_0xe89b('0x47')]['includeAll']){_0x12eec7['include']=[{'all':!![]}];}if(_0x1843df[_0xe89b('0x47')][_0xe89b('0x48')]===_0xe89b('0x49')){_0x12eec7[_0xe89b('0x4a')]=[{'model':db['UserSetting'],'as':_0xe89b('0x48')}];}if(!_[_0xe89b('0x41')](_0x12eec7['attributes'],'id')){_0x12eec7[_0xe89b('0x4b')]['push']('id');}return db[_0xe89b('0x46')][_0xe89b('0x4c')](_0x12eec7);})['then'](function(_0x27b3a4){_0x4dfe27[_0xe89b('0x4d')]=_0x27b3a4;if(_0x1843df[_0xe89b('0x47')]['openTabs']===_0xe89b('0x49')){var _0xfb0b18=[];for(var _0x5efe4b=0x0;_0x5efe4b<_0x4dfe27['rows'][_0xe89b('0x4e')];_0x5efe4b++){_0xfb0b18[_0xe89b('0x4f')](get_open_tabs(_0xe89b('0x50'),_0x4dfe27['rows'][_0x5efe4b][_0xe89b('0x51')]));_0xfb0b18[_0xe89b('0x4f')](get_open_tabs('sms',_0x4dfe27[_0xe89b('0x4d')][_0x5efe4b][_0xe89b('0x51')]));_0xfb0b18[_0xe89b('0x4f')](get_open_tabs(_0xe89b('0x52'),_0x4dfe27['rows'][_0x5efe4b][_0xe89b('0x51')]));_0xfb0b18[_0xe89b('0x4f')](get_open_tabs(_0xe89b('0x53'),_0x4dfe27['rows'][_0x5efe4b][_0xe89b('0x51')]));_0xfb0b18[_0xe89b('0x4f')](get_open_tabs('openchannel',_0x4dfe27['rows'][_0x5efe4b][_0xe89b('0x51')]));_0xfb0b18['push'](get_open_tabs(_0xe89b('0x54'),_0x4dfe27[_0xe89b('0x4d')][_0x5efe4b][_0xe89b('0x51')]));}return BPromise[_0xe89b('0x55')](_0xfb0b18)[_0xe89b('0x1a')](function(){return _0x4dfe27;});}else{return _0x4dfe27;}})[_0xe89b('0x1a')](respondWithFilteredResult(_0x5cfd90,_0x12eec7))['catch'](handleError(_0x5cfd90,null));};exports[_0xe89b('0x56')]=function(_0x362c71,_0x2e7259){var _0x139b43={'raw':![],'where':{'id':_0x362c71[_0xe89b('0x57')]['id']}},_0x1e109b={};_0x1e109b[_0xe89b('0x58')]=_[_0xe89b('0x59')](_[_0xe89b('0x5a')](db[_0xe89b('0x46')][_0xe89b('0x3d')]),['password',_0xe89b('0x43')]);_0x1e109b[_0xe89b('0x47')]=_['keys'](_0x362c71[_0xe89b('0x47')]);_0x1e109b[_0xe89b('0x5b')]=_[_0xe89b('0x5c')](_0x1e109b['model'],_0x1e109b['query']);_0x139b43[_0xe89b('0x4b')]=_[_0xe89b('0x5c')](_0x1e109b[_0xe89b('0x58')],qs[_0xe89b('0x5d')](_0x362c71[_0xe89b('0x47')][_0xe89b('0x5d')]));_0x139b43[_0xe89b('0x4b')]=_0x139b43[_0xe89b('0x4b')][_0xe89b('0x4e')]?_0x139b43[_0xe89b('0x4b')]:_0x1e109b[_0xe89b('0x58')];if(_0x362c71['query'][_0xe89b('0x5e')]){_0x139b43['include']=[{'all':!![]}];}if(_0x362c71[_0xe89b('0x47')][_0xe89b('0x48')]==='true'){_0x139b43[_0xe89b('0x4a')]=[{'model':db[_0xe89b('0x5f')],'as':_0xe89b('0x48')}];}_0x139b43=_[_0xe89b('0x60')]({},_0x139b43,_0x362c71[_0xe89b('0x61')]);if(!_['includes'](_0x139b43[_0xe89b('0x4b')],'id')){_0x139b43[_0xe89b('0x4b')][_0xe89b('0x4f')]('id');}return db[_0xe89b('0x46')][_0xe89b('0x62')](_0x139b43)[_0xe89b('0x1a')](handleEntityNotFound(_0x2e7259,null))[_0xe89b('0x1a')](function(_0xbf8453){var _0x53adcb=[];values=_0xbf8453;if(_0x362c71[_0xe89b('0x47')]['openTabs']==='true'){_0x53adcb[_0xe89b('0x4f')](get_open_tabs(_0xe89b('0x50'),_0xbf8453[_0xe89b('0x51')]));_0x53adcb[_0xe89b('0x4f')](get_open_tabs(_0xe89b('0x63'),_0xbf8453[_0xe89b('0x51')]));_0x53adcb[_0xe89b('0x4f')](get_open_tabs(_0xe89b('0x64'),_0xbf8453[_0xe89b('0x51')]));_0x53adcb['push'](get_open_tabs(_0xe89b('0x54'),_0xbf8453[_0xe89b('0x51')]));_0x53adcb[_0xe89b('0x4f')](get_open_tabs(_0xe89b('0x52'),_0xbf8453[_0xe89b('0x51')]));_0x53adcb[_0xe89b('0x4f')](get_open_tabs('mail',_0xbf8453['dataValues']));return BPromise['all'](_0x53adcb);}else{return values;}})[_0xe89b('0x1a')](function(){return values;})[_0xe89b('0x1a')](respondWithResult(_0x2e7259,null))[_0xe89b('0x65')](handleError(_0x2e7259,null));};exports[_0xe89b('0x2c')]=function(_0x222542,_0x32e430){if(_0x222542[_0xe89b('0x66')]['id']){delete _0x222542[_0xe89b('0x66')]['id'];}delete _0x222542[_0xe89b('0x66')]['role'];return db['User'][_0xe89b('0x62')]({'where':{'id':_0x222542['params']['id']}})[_0xe89b('0x1a')](handleEntityNotFound(_0x32e430,null))[_0xe89b('0x1a')](saveUpdates(_0x222542[_0xe89b('0x66')],null))[_0xe89b('0x1a')](respondWithResult(_0x32e430,null))[_0xe89b('0x65')](handleError(_0x32e430,null));};exports[_0xe89b('0x67')]=function(_0x3d89a6,_0x146c07){return db[_0xe89b('0x46')][_0xe89b('0x67')]()[_0xe89b('0x1a')](respondWithResult(_0x146c07,null))[_0xe89b('0x65')](handleError(_0x146c07,null));};exports[_0xe89b('0x68')]=function(_0x5e7684,_0x48fe15){return db[_0xe89b('0x46')][_0xe89b('0x62')]({'where':{'id':_0x5e7684['params']['id']}})['then'](handleEntityNotFound(_0x48fe15,null))[_0xe89b('0x1a')](function(_0x4df584){if(_0x4df584){return _0x4df584[_0xe89b('0x68')](_0x5e7684[_0xe89b('0x66')][_0xe89b('0x69')],_[_0xe89b('0x6a')](_0x5e7684[_0xe89b('0x66')],[_0xe89b('0x69'),'id'])||{});}})[_0xe89b('0x1a')](respondWithResult(_0x48fe15,null))[_0xe89b('0x65')](handleError(_0x48fe15,null));};function validateUser(_0x22de51){return new BPromise(function(_0x1da9d5,_0x1f6e7d){if(_0x22de51[_0xe89b('0x6b')])return _0x1da9d5(_0x22de51);return db[_0xe89b('0x6c')][_0xe89b('0x6d')](0x1)[_0xe89b('0x1a')](function(_0x211702){if(_0x211702[_0xe89b('0x6e')])authService[_0xe89b('0x6f')](_0x22de51[_0xe89b('0x42')]);db[_0xe89b('0x46')]['max'](_0xe89b('0x6b'))[_0xe89b('0x1a')](function(_0x5edbf1){if(_[_0xe89b('0x70')](_0x5edbf1)){_0x22de51[_0xe89b('0x6b')]=_0x211702['min_internal']||0x1;return;}if(_[_0xe89b('0x70')](_0x211702[_0xe89b('0x71')])||_0x211702[_0xe89b('0x71')]===_0x5edbf1){_0x22de51[_0xe89b('0x6b')]=_0x5edbf1+0x1;return;}if(_0x211702[_0xe89b('0x71')]>_0x5edbf1){_0x22de51['internal']=_0x211702['min_internal'];return;}return db[_0xe89b('0x72')][_0xe89b('0x47')]('select\x20(select\x20IFNULL(max(internal)+1,1)\x20from\x20users\x20where\x20internal\x20<\x20md.internal)\x20as\x20\x27from\x27,\x20md.internal\x20-\x201\x20as\x20\x27to\x27\x20from\x20users\x20md\x20where\x20md.internal\x20!=\x201\x20and\x20not\x20exists\x20(select\x201\x20from\x20users\x20md2\x20where\x20md2.internal\x20=\x20md.internal\x20-\x201)',{'type':db[_0xe89b('0x72')][_0xe89b('0x73')][_0xe89b('0x74')]})[_0xe89b('0x1a')](function(_0x4034f6){if(_0x4034f6&&_0x4034f6[_0xe89b('0x4e')]){for(var _0x4716fa=0x0,_0x20d13f=_0x4034f6[_0xe89b('0x4e')];_0x4716fa<_0x20d13f&&_['isNil'](_0x22de51[_0xe89b('0x6b')]);_0x4716fa++){if(_0x211702[_0xe89b('0x71')]<=_0x4034f6[_0x4716fa][_0xe89b('0x75')]){_0x22de51[_0xe89b('0x6b')]=_0x4034f6[_0x4716fa][_0xe89b('0x75')];}else if(_0x211702[_0xe89b('0x71')]>_0x4034f6[_0x4716fa][_0xe89b('0x75')]&&_0x211702['min_internal']<=_0x4034f6[_0x4716fa]['to']){_0x22de51[_0xe89b('0x6b')]=_0x211702[_0xe89b('0x71')];}}}if(_['isNil'](_0x22de51['internal'])){_0x22de51[_0xe89b('0x6b')]=_0x5edbf1+0x1;}return _0x1da9d5(_0x22de51);});});})[_0xe89b('0x65')](function(_0x2eabc4){_0x1f6e7d(_0x2eabc4);});});}function updateUser(_0x590fbd){return new BPromise(function(_0x26320c,_0x44d7c7){try{if(_0x590fbd['voicemail']){_0x590fbd[_0xe89b('0x76')]=_0x590fbd[_0xe89b('0x6b')];_0x590fbd[_0xe89b('0x77')]={'mailbox':_0x590fbd['internal'],'password':_0x590fbd[_0xe89b('0x42')],'fullname':_0x590fbd[_0xe89b('0x78')],'email':_0x590fbd['email']};}if(_0x590fbd[_0xe89b('0x2f')]===_0xe89b('0x33')){if(!_0x590fbd[_0xe89b('0x79')])_0x590fbd[_0xe89b('0x79')]=[_0xe89b('0x7a'),_0xe89b('0x7b'),'103',_0xe89b('0x7c'),'110',_0xe89b('0x7d'),_0xe89b('0x7e'),'106',_0xe89b('0x7f'),'108',_0xe89b('0x80'),'100',_0xe89b('0x81'),_0xe89b('0x82'),_0xe89b('0x83')];}_0x26320c(_0x590fbd);}catch(_0xf3bf23){_0x44d7c7(_0xf3bf23);}});}exports[_0xe89b('0x84')]=function(_0x459fb5,_0x3be938){if(_0x459fb5['user'][_0xe89b('0x2f')]===_0xe89b('0x33'))throw new Error(_0xe89b('0x85'));if(_0x459fb5[_0xe89b('0x66')][_0xe89b('0x2f')]===_0xe89b('0x31')&&_0x459fb5[_0xe89b('0x31')]['role']!=='admin'){throw new Error(_0xe89b('0x86'));}if(_0x459fb5['body'][_0xe89b('0x2f')]==='admin'&&_0x459fb5['user']['role']!==_0xe89b('0x30')){throw new Error(_0xe89b('0x87'));}return licenseUtil[_0xe89b('0x88')]([_0x459fb5[_0xe89b('0x66')]])[_0xe89b('0x1a')](function(){return validateUser(_0x459fb5[_0xe89b('0x66')]);})[_0xe89b('0x1a')](function(_0x273801){return updateUser(_0x273801)['then'](function(_0x183ba1){if(_0x183ba1[_0xe89b('0x2f')]===_0xe89b('0x30')){_0x183ba1[_0xe89b('0x89')]=_0x459fb5['user']['settingsEnabled'];delete _0x183ba1['userProfileId'];}return _0x183ba1;});})['then'](function(_0x2e7c94){return db['User'][_0xe89b('0x84')](_0x2e7c94,{'include':[{'model':db[_0xe89b('0x77')],'as':'VoiceMail'}]});})[_0xe89b('0x1a')](function(_0x3085fc){if(_0x459fb5[_0xe89b('0x66')]['role']===_0xe89b('0x31'))return _0x3085fc;if(_0x459fb5[_0xe89b('0x31')]['role']!==_0xe89b('0x31'))return _0x3085fc;return db[_0xe89b('0x8a')][_0xe89b('0x62')]({'where':{'name':_0x3085fc[_0xe89b('0x2f')]===_0xe89b('0x33')?_0xe89b('0x32'):_0xe89b('0x8b'),'userProfileId':_0x459fb5[_0xe89b('0x31')]['userProfileId']},'raw':!![]})['then'](function(_0x5c16e2){if(!_0x5c16e2||_0x5c16e2['autoAssociation']!=0x0)return _0x3085fc;return db[_0xe89b('0x38')][_0xe89b('0x84')]({'name':_0x3085fc[_0xe89b('0x37')],'resourceId':_0x3085fc['id'],'type':_0x5c16e2[_0xe89b('0x37')],'sectionId':_0x5c16e2['id']},{})['then'](function(){return _0x3085fc;});})['catch'](function(_0x42c26b){logger[_0xe89b('0x1e')](_0xe89b('0x8c'),_0x42c26b);throw _0x42c26b;});})[_0xe89b('0x1a')](respondWithResult(_0x3be938,0xc9))['catch'](handleError(_0x3be938,null));};exports[_0xe89b('0x8d')]=function(_0x5d305f,_0x398c13){var _0x459c29=_0x5d305f[_0xe89b('0x66')];var _0x1430c6=[];if(_0x5d305f['user'][_0xe89b('0x2f')]===_0xe89b('0x33'))throw new Error(_0xe89b('0x85'));if(_['some'](_0x459c29,[_0xe89b('0x2f'),'user'])&&_0x5d305f['user'][_0xe89b('0x2f')]!==_0xe89b('0x30')){throw new Error(_0xe89b('0x86'));}if(_[_0xe89b('0x8e')](_0x459c29,['role',_0xe89b('0x30')])&&_0x5d305f[_0xe89b('0x31')][_0xe89b('0x2f')]!==_0xe89b('0x30')){throw new Error(_0xe89b('0x8f'));}return licenseUtil[_0xe89b('0x88')](_0x459c29)[_0xe89b('0x1a')](function(){return validateUser(_0x459c29[0x0]);})[_0xe89b('0x1a')](function(){for(var _0x45662c=0x1;_0x45662c<_0x459c29[_0xe89b('0x4e')];_0x45662c++){var _0x1dad5d=_0x459c29[_0x45662c-0x1][_0xe89b('0x6b')];if(!_0x459c29[_0x45662c][_0xe89b('0x6b')])_0x459c29[_0x45662c]['internal']=_0x1dad5d+0x1;_0x1430c6[_0xe89b('0x4f')](validateUser(_0x459c29[_0x45662c]));}return BPromise[_0xe89b('0x55')](_0x1430c6);})[_0xe89b('0x1a')](function(){_0x1430c6=[];for(var _0x1b3631=0x0;_0x1b3631<_0x459c29[_0xe89b('0x4e')];_0x1b3631++){_0x1430c6[_0xe89b('0x4f')](updateUser(_0x459c29[_0x1b3631]));}return BPromise['all'](_0x1430c6);})['then'](function(){return BPromise[_0xe89b('0x90')](_0x459c29,function(_0x77f06b){return db[_0xe89b('0x46')]['create'](_0x77f06b,{'include':[{'model':db[_0xe89b('0x77')],'as':_0xe89b('0x77')}]})['then'](function(_0x16833b){_0x77f06b['id']=_0x16833b['id'];return _0x77f06b;});});})[_0xe89b('0x1a')](function(_0x5ce84b){if(_0x5d305f['body'][_0xe89b('0x2f')]==='user')return _0x5ce84b;if(_0x5d305f[_0xe89b('0x31')][_0xe89b('0x2f')]!==_0xe89b('0x31'))return _0x5ce84b;var _0x23706a=_[_0xe89b('0x8e')](_0x5ce84b,function(_0xa28721){return _0xa28721[_0xe89b('0x2f')]===_0xe89b('0x33')||_0xa28721[_0xe89b('0x2f')]==='telephone';});if(!_0x23706a)return _0x5ce84b;return db[_0xe89b('0x8a')]['findAll']({'where':{'name':{'$or':['Agents',_0xe89b('0x8b')]},'userProfileId':_0x5d305f['user']['userProfileId']},'raw':!![]})[_0xe89b('0x1a')](function(_0x21f2cd){if(_[_0xe89b('0x91')](_0x21f2cd)||!_[_0xe89b('0x8e')](_0x21f2cd,[_0xe89b('0x92'),0x0]))return _0x5ce84b;_0x1430c6=[];var _0x30619b=_(_0x21f2cd)[_0xe89b('0x3e')](function(_0xd0d6b0){if(_0xd0d6b0[_0xe89b('0x92')]===0x1)return;return _0xd0d6b0[_0xe89b('0x37')]==='Agents'?_0xe89b('0x33'):_0xe89b('0x34');})[_0xe89b('0x93')]()[_0xe89b('0x36')]();for(var _0x345788=0x0;_0x345788<_0x5ce84b[_0xe89b('0x4e')];_0x345788++){if(!_['includes'](_0x30619b,_0x5ce84b[_0x345788]['role']))return;var _0x1188e3=_0x5ce84b[_0x345788][_0xe89b('0x2f')]===_0xe89b('0x33')?'Agents':'Telephones';_0x1430c6[_0xe89b('0x4f')](db[_0xe89b('0x38')][_0xe89b('0x84')]({'name':_0x5ce84b[_0x345788][_0xe89b('0x37')],'resourceId':_0x5ce84b[_0x345788]['id'],'type':_0x1188e3,'sectionId':_[_0xe89b('0x62')](_0x21f2cd,[_0xe89b('0x37'),_0x1188e3])['id']},{}));}return BPromise[_0xe89b('0x55')](_0x1430c6);});})[_0xe89b('0x1a')](respondWithResult(_0x398c13,0xc9))['catch'](handleError(_0x398c13,null));};exports[_0xe89b('0x94')]=function(_0x3a321b,_0x58756e){if(_0x3a321b[_0xe89b('0x66')]['id']){delete _0x3a321b['body']['id'];}return db[_0xe89b('0x46')]['find']({'where':{'id':_0x3a321b[_0xe89b('0x57')]['id']}})[_0xe89b('0x1a')](function(_0x15e6c2){if(!_0x15e6c2)return null;if(_0x15e6c2['id']===_0x3a321b[_0xe89b('0x31')]['id']){if(!_0x3a321b[_0xe89b('0x66')][_0xe89b('0x95')]||!_0x3a321b[_0xe89b('0x66')][_0xe89b('0x96')]){throw new db[(_0xe89b('0x97'))][(_0xe89b('0x98'))](_0xe89b('0x99'));}if(!_0x15e6c2['authenticate'](_0x3a321b['body'][_0xe89b('0x95')])){throw new db[(_0xe89b('0x97'))][(_0xe89b('0x98'))]('Wrong\x20credentials');}if(_0x3a321b[_0xe89b('0x66')][_0xe89b('0x95')]===_0x3a321b[_0xe89b('0x66')][_0xe89b('0x96')]){throw new db[(_0xe89b('0x97'))][(_0xe89b('0x98'))]('New\x20password\x20must\x20be\x20different\x20from\x20old\x20password');}}else if(_0x3a321b['user']['role']===_0xe89b('0x30')){if(!_0x3a321b[_0xe89b('0x66')][_0xe89b('0x96')]){throw new db[(_0xe89b('0x97'))][(_0xe89b('0x98'))]('Invalid\x20body\x20format.\x20Use\x20newPassword');}}else if(_0x3a321b[_0xe89b('0x31')][_0xe89b('0x2f')]===_0xe89b('0x31')){if(!_0x3a321b[_0xe89b('0x66')][_0xe89b('0x96')]){throw new db[(_0xe89b('0x97'))][(_0xe89b('0x98'))](_0xe89b('0x9a'));}if(_0x15e6c2[_0xe89b('0x2f')]!=='agent'){throw new db[(_0xe89b('0x97'))][(_0xe89b('0x98'))]('Unauthorized');}}else{throw new db['Sequelize'][(_0xe89b('0x98'))](_0xe89b('0x85'));}return _0x15e6c2;})[_0xe89b('0x1a')](handleEntityNotFound(_0x58756e,null))[_0xe89b('0x1a')](function(_0x3449b5){return db[_0xe89b('0x6c')]['findOne']({'attributes':['id',_0xe89b('0x6e'),_0xe89b('0x9b'),_0xe89b('0x9c')]})[_0xe89b('0x1a')](function(_0x796cd5){if(_0x796cd5[_0xe89b('0x6e')])authService[_0xe89b('0x6f')](_0x3a321b[_0xe89b('0x66')]['newPassword']);if(!_0x796cd5[_0xe89b('0x9b')]||!_0x3449b5[_0xe89b('0x9d')])return _0x3449b5;authService[_0xe89b('0x9e')](_0x3a321b['body']['newPassword'],_0x3449b5[_0xe89b('0x9d')],_0x796cd5[_0xe89b('0x9c')]);return _0x3449b5;})['then'](saveUpdates({'password':_0x3a321b[_0xe89b('0x66')]['newPassword'],'passwordResetAt':_0x3a321b[_0xe89b('0x31')]['id']==_0x3a321b[_0xe89b('0x57')]['id']?moment():null,'previousPasswords':authService[_0xe89b('0x9f')](_0x3a321b[_0xe89b('0x66')]['newPassword'],_0x3449b5[_0xe89b('0x9d')])},null));})[_0xe89b('0x1a')](respondWithResult(_0x58756e,null))[_0xe89b('0x65')](handleError(_0x58756e,null));};exports['addQueues']=function(_0x228973,_0x2a23e3){var _0x379721=_0x228973[_0xe89b('0x66')][_0xe89b('0xa0')];return db['User'][_0xe89b('0x62')]({'where':{'id':_0x228973[_0xe89b('0x57')]['id']},'attributes':['id',_0xe89b('0x37'),_0xe89b('0x2f'),'online',_0xe89b('0xa1'),'voicePause',_0xe89b('0xa2')]})[_0xe89b('0x1a')](handleEntityNotFound(_0x2a23e3,null))[_0xe89b('0x1a')](function(_0x3a6e7a){if(_0x3a6e7a){if(!utils[_0xe89b('0xa3')](_0x379721)){throw new db[(_0xe89b('0x97'))][(_0xe89b('0x98'))]('Unknown\x20channel');}return _0x3a6e7a['add'+_[_0xe89b('0xa4')](_0x379721[_0xe89b('0xa5')]())+_0xe89b('0xa6')](_0x228973[_0xe89b('0x66')][_0xe89b('0x69')],{'penalty':_0x228973[_0xe89b('0x66')][_0xe89b('0xa7')]||0x0})[_0xe89b('0xa8')](function(_0x4c35af){for(var _0x2e9406=0x0;_0x2e9406<_0x228973[_0xe89b('0x66')][_0xe89b('0x69')]['length'];_0x2e9406+=0x1){var _0x4953c3={'UserId':Number(_0x228973['params']['id'])};_0x4953c3[_[_0xe89b('0xa4')](_0x379721[_0xe89b('0xa5')]())+_0xe89b('0xa9')]=Number(_0x228973[_0xe89b('0x66')][_0xe89b('0x69')][_0x2e9406]);socket[_0xe89b('0xaa')]('user'+_[_0xe89b('0xa4')](_0x379721[_0xe89b('0xa5')]())+_0xe89b('0xab'),_0x4953c3);}return _0x4c35af;})[_0xe89b('0x1a')](function(){if(_0x379721===_0xe89b('0xac')){return db[_0xe89b('0xad')][_0xe89b('0x4c')]({'where':{'id':_0x228973[_0xe89b('0x66')][_0xe89b('0x69')]||[]},'raw':!![],'attributes':['id','name']});}})[_0xe89b('0x1a')](function(_0x69b710){var _0x40e149=_0x3a6e7a[_0xe89b('0xae')]({'plain':!![]});var _0x4448b3=[];if(_0x379721===_0xe89b('0xac')&&_0x40e149['role']==='agent'&&_0x40e149['online']){for(var _0x4cc5be=0x0;_0x4cc5be<_0x69b710[_0xe89b('0x4e')];_0x4cc5be+=0x1){_0x4448b3[_0xe89b('0x4f')]({'membername':_0x40e149['name'],'UserId':_0x40e149['id'],'queue_name':_0x69b710[_0x4cc5be]['name'],'VoiceQueueId':_0x69b710[_0x4cc5be]['id'],'interface':_['isNil'](_0x40e149['interface'])?util[_0xe89b('0xaf')](_0xe89b('0xb0'),_0x40e149[_0xe89b('0x37')]):_0x40e149['interface'],'paused':_0x40e149[_0xe89b('0xb1')]||![],'penalty':_0x228973['body']['penalty']||0x0});}return BPromise[_0xe89b('0x90')](_0x4448b3,function(_0x4cc560){return db[_0xe89b('0xb2')]['upsert'](_0x4cc560);});}return _0x3a6e7a;});}})['then'](respondWithStatusCode(_0x2a23e3,null))[_0xe89b('0x65')](handleError(_0x2a23e3,null));};exports[_0xe89b('0xb3')]=function(_0x459ed3,_0x28818c){var _0x26c9d9,_0x78e1c;return db['User'][_0xe89b('0x62')]({'where':{'id':_0x459ed3['params']['id']},'attributes':['id',_0xe89b('0x37'),_0xe89b('0x2f')]})[_0xe89b('0x1a')](handleEntityNotFound(_0x28818c,null))[_0xe89b('0x1a')](function(_0x4ea846){if(_0x4ea846){_0x26c9d9=_0x4ea846;if(!_0x459ed3['query'][_0xe89b('0xa0')]||!utils[_0xe89b('0xa3')](_0x459ed3['query'][_0xe89b('0xa0')])){throw new db[(_0xe89b('0x97'))][(_0xe89b('0x98'))](_0xe89b('0xb4'));}return _0x4ea846['remove'+_['capitalize'](_0x459ed3['query'][_0xe89b('0xa0')][_0xe89b('0xa5')]())+_0xe89b('0xa6')](_0x459ed3['query'][_0xe89b('0x69')]);}})['then'](function(_0x4bfa52){if(_['isArray'](_0x459ed3['query']['ids'])){for(var _0x1b94f2=0x0;_0x1b94f2<_0x459ed3['query'][_0xe89b('0x69')][_0xe89b('0x4e')];_0x1b94f2+=0x1){_0x78e1c={'UserId':Number(_0x459ed3[_0xe89b('0x57')]['id'])};_0x78e1c[_[_0xe89b('0xa4')](_0x459ed3[_0xe89b('0x47')][_0xe89b('0xa0')][_0xe89b('0xa5')]())+_0xe89b('0xa9')]=Number(_0x459ed3[_0xe89b('0x47')]['ids'][_0x1b94f2]);socket[_0xe89b('0xaa')]('user'+_[_0xe89b('0xa4')](_0x459ed3[_0xe89b('0x47')][_0xe89b('0xa0')][_0xe89b('0xa5')]())+_0xe89b('0xb5'),_0x78e1c);}}else{_0x78e1c={'UserId':Number(_0x459ed3[_0xe89b('0x57')]['id'])};_0x78e1c[_[_0xe89b('0xa4')](_0x459ed3[_0xe89b('0x47')][_0xe89b('0xa0')][_0xe89b('0xa5')]())+_0xe89b('0xa9')]=Number(_0x459ed3[_0xe89b('0x47')][_0xe89b('0x69')]);socket[_0xe89b('0xaa')](_0xe89b('0x31')+_[_0xe89b('0xa4')](_0x459ed3['query']['channel']['toLowerCase']())+_0xe89b('0xb5'),_0x78e1c);}return _0x4bfa52;})[_0xe89b('0x1a')](function(){if(_0x459ed3['query'][_0xe89b('0xa0')]===_0xe89b('0xac')){return db[_0xe89b('0xb2')][_0xe89b('0x2e')]({'where':{'UserId':_0x459ed3[_0xe89b('0x57')]['id'],'VoiceQueueId':_0x459ed3[_0xe89b('0x47')][_0xe89b('0x69')]},'individualHooks':!![]})[_0xe89b('0x1a')](function(){return _0x26c9d9;});}return _0x26c9d9;})[_0xe89b('0x1a')](respondWithStatusCode(_0x28818c,null))[_0xe89b('0x65')](handleError(_0x28818c,null));};exports[_0xe89b('0xb6')]=function(_0x5f8851,_0x3d66fb){_0x5f8851[_0xe89b('0x66')][_0xe89b('0xb7')]=_0x5f8851[_0xe89b('0xb8')][_0xe89b('0xb9')];return db[_0xe89b('0x46')][_0xe89b('0x62')]({'where':{'id':_0x5f8851[_0xe89b('0x57')]['id']}})[_0xe89b('0x1a')](handleEntityNotFound(_0x3d66fb,null))[_0xe89b('0x1a')](saveUpdates(_0x5f8851[_0xe89b('0x66')],null))['then'](respondWithResult(_0x3d66fb,null))[_0xe89b('0x65')](handleError(_0x3d66fb,null));};exports[_0xe89b('0xba')]=function(_0x503ab7,_0x33f8a2){var _0x10d839=path['join'](config[_0xe89b('0xbb')],_0xe89b('0xbc'));return db[_0xe89b('0x46')][_0xe89b('0x62')]({'where':{'id':_0x503ab7[_0xe89b('0x57')]['id']},'attributes':['id',_0xe89b('0xb7')],'raw':!![]})['then'](handleEntityNotFound(_0x33f8a2,null))[_0xe89b('0x1a')](function(_0x4d0356){if(_0x4d0356){if(_['isNil'](_0x4d0356['userpic'])){return _0x33f8a2[_0xe89b('0xbd')](_0x10d839);}else{if(!fs[_0xe89b('0xbe')](path[_0xe89b('0xbf')](config[_0xe89b('0xbb')],_0xe89b('0xc0'),_0x4d0356['userpic']))){return _0x33f8a2[_0xe89b('0xbd')](_0x10d839);}return _0x33f8a2['download'](path[_0xe89b('0xbf')](config[_0xe89b('0xbb')],_0xe89b('0xc0'),_0x4d0356[_0xe89b('0xb7')]));}}})['catch'](handleError(_0x33f8a2,null));};exports[_0xe89b('0xc1')]=function(_0x5883bf,_0x16ef02){return db[_0xe89b('0x46')][_0xe89b('0x62')]({'where':{'id':_0x5883bf[_0xe89b('0x57')]['id']},'attributes':['id']})[_0xe89b('0x1a')](handleEntityNotFound(_0x16ef02,null))[_0xe89b('0x1a')](function(_0x20ef50){var _0x3a96c9=[];values=_0x20ef50['dataValues'];_0x3a96c9['push'](get_open_tabs(_0xe89b('0x50'),_0x20ef50[_0xe89b('0x51')]));_0x3a96c9['push'](get_open_tabs('sms',_0x20ef50[_0xe89b('0x51')]));_0x3a96c9[_0xe89b('0x4f')](get_open_tabs(_0xe89b('0x64'),_0x20ef50['dataValues']));_0x3a96c9['push'](get_open_tabs(_0xe89b('0x54'),_0x20ef50[_0xe89b('0x51')]));_0x3a96c9[_0xe89b('0x4f')](get_open_tabs(_0xe89b('0x52'),_0x20ef50[_0xe89b('0x51')]));_0x3a96c9[_0xe89b('0x4f')](get_open_tabs('mail',_0x20ef50[_0xe89b('0x51')]));return BPromise[_0xe89b('0x55')](_0x3a96c9);})[_0xe89b('0x1a')](function(_0x25c3b2){if(_0x25c3b2){var _0x523957=_['map'](values[_0xe89b('0xc2')],function(_0x2070e0){return{'channel':_0xe89b('0xc3'),'id':_0x2070e0['id'],'createdAt':_0x2070e0[_0xe89b('0xc4')]};});var _0x11f366=_[_0xe89b('0x3e')](values[_0xe89b('0xc5')],function(_0x25dd95){return{'channel':_0xe89b('0xc6'),'id':_0x25dd95['id'],'createdAt':_0x25dd95['createdAt']};});var _0x3ce763=_[_0xe89b('0x3e')](values[_0xe89b('0xc7')],function(_0x52b53c){return{'channel':'OPENCHANNEL','id':_0x52b53c['id'],'createdAt':_0x52b53c['createdAt']};});var _0x4ac32d=_['map'](values[_0xe89b('0xc8')],function(_0x4e2a4c){return{'channel':_0xe89b('0xc9'),'id':_0x4e2a4c['id'],'createdAt':_0x4e2a4c[_0xe89b('0xc4')]};});var _0x1b5e5e=_[_0xe89b('0x3e')](values[_0xe89b('0xca')],function(_0x5b1e0d){return{'channel':_0xe89b('0xcb'),'id':_0x5b1e0d['id'],'createdAt':_0x5b1e0d['createdAt']};});var _0x2efb0f=_[_0xe89b('0x3e')](values['WhatsappOpenTabs'],function(_0x1bb37d){return{'channel':'WHATSAPP','id':_0x1bb37d['id'],'createdAt':_0x1bb37d[_0xe89b('0xc4')]};});var _0x2da5f8=_[_0xe89b('0xcc')](_0x523957,_0x11f366,_0x3ce763,_0x4ac32d,_0x1b5e5e,_0x2efb0f);var _0x1bddf0={'count':_0x2da5f8[_0xe89b('0x4e')],'rows':_0x2da5f8};return _0x1bddf0;}else return null;})[_0xe89b('0x1a')](respondWithResult(_0x16ef02,null))['catch'](handleError(_0x16ef02,null));};exports['getContacts']=function(_0x1740fa,_0xf2ffd1){var _0x477b56={};var _0x42bf1c={};var _0x1c1dc2;var _0x554db5;return db[_0xe89b('0x46')][_0xe89b('0xcd')]({'where':{'id':_0x1740fa[_0xe89b('0x57')]['id']}})[_0xe89b('0x1a')](handleEntityNotFound(_0xf2ffd1,null))[_0xe89b('0x1a')](function(_0x4ffcdc){if(_0x4ffcdc){_0x1c1dc2=_0x4ffcdc;_0x42bf1c[_0xe89b('0x58')]=_['keys'](db[_0xe89b('0xce')][_0xe89b('0x3d')]);_0x42bf1c[_0xe89b('0x47')]=_[_0xe89b('0x5a')](_0x1740fa[_0xe89b('0x47')]);_0x42bf1c[_0xe89b('0x5b')]=_[_0xe89b('0x5c')](_0x42bf1c[_0xe89b('0x58')],_0x42bf1c[_0xe89b('0x47')]);_0x477b56[_0xe89b('0x4b')]=_['intersection'](_0x42bf1c[_0xe89b('0x58')],qs['fields'](_0x1740fa[_0xe89b('0x47')]['fields']));_0x477b56['attributes']=_0x477b56[_0xe89b('0x4b')][_0xe89b('0x4e')]?_0x477b56[_0xe89b('0x4b')]:_0x42bf1c['model'];_0x477b56['order']=qs[_0xe89b('0xcf')](_0x1740fa[_0xe89b('0x47')]['sort']);_0x477b56[_0xe89b('0x45')]=qs[_0xe89b('0x5b')](_[_0xe89b('0xd0')](_0x1740fa[_0xe89b('0x47')],_0x42bf1c[_0xe89b('0x5b')]));if(_0x1740fa['query'][_0xe89b('0x40')]){_0x477b56[_0xe89b('0x45')]=_[_0xe89b('0x60')](_0x477b56[_0xe89b('0x45')],{'$or':_[_0xe89b('0x3e')](_0x477b56[_0xe89b('0x4b')],function(_0x70af56){var _0x42a9ed={};_0x42a9ed[_0x70af56]={'$like':'%'+_0x1740fa['query'][_0xe89b('0x40')]+'%'};return _0x42a9ed;})});}_0x477b56=_[_0xe89b('0x60')]({},_0x477b56,_0x1740fa['options']);return _0x1c1dc2[_0xe89b('0xd1')](_0x477b56);}})[_0xe89b('0x1a')](function(_0x2abe9c){if(_0x2abe9c){_0x554db5=_0x2abe9c[_0xe89b('0x4e')];if(_0x1740fa['query'][_0xe89b('0xd2')]('includeAll')){_0x477b56[_0xe89b('0x4a')]=[{'model':db[_0xe89b('0xd3')],'as':_0xe89b('0xd4'),'required':![]},{'model':db[_0xe89b('0xd5')],'as':_0xe89b('0xd6'),'attributes':['id',_0xe89b('0x37'),'color'],'where':_0x1740fa[_0xe89b('0x47')]['tag']?{'id':_0x1740fa['query'][_0xe89b('0xd7')]}:undefined,'required':_0x1740fa[_0xe89b('0x47')][_0xe89b('0xd7')]?!![]:![]}];}if(!_0x1740fa[_0xe89b('0x47')][_0xe89b('0xd2')](_0xe89b('0xd8'))){_0x477b56[_0xe89b('0x27')]=qs[_0xe89b('0x27')](_0x1740fa[_0xe89b('0x47')][_0xe89b('0x27')]);_0x477b56['offset']=qs[_0xe89b('0x25')](_0x1740fa[_0xe89b('0x47')][_0xe89b('0x25')]);}return _0x1c1dc2[_0xe89b('0xd1')](_0x477b56);}})['then'](function(_0x2c74ac){if(_0x2c74ac){return _0x2c74ac?{'count':_0x554db5,'rows':_0x2c74ac}:null;}})['then'](respondWithResult(_0xf2ffd1,null))['catch'](handleError(_0xf2ffd1,null));};exports['getQueues']=function(_0x59691f,_0x3a3af3){var _0x1834c0;var _0x17966f={};var _0x50313c;return db[_0xe89b('0x46')][_0xe89b('0xcd')]({'where':{'id':_0x59691f[_0xe89b('0x57')]['id']},'attributes':['id',_0xe89b('0x37'),_0xe89b('0x2f')]})[_0xe89b('0x1a')](handleEntityNotFound(_0x3a3af3,null))['then'](function(_0x5494e6){if(!utils['isValidChannel'](_0x59691f[_0xe89b('0x47')][_0xe89b('0xa0')])){throw new db[(_0xe89b('0x97'))]['ValidationError'](_0xe89b('0xb4'));}_0x1834c0=_0x5494e6;var _0x105647={};_0x105647[_0xe89b('0x58')]=_['keys'](db[_[_0xe89b('0xa4')](_0x59691f[_0xe89b('0x47')][_0xe89b('0xa0')])+'Queue'][_0xe89b('0x3d')]);_0x105647[_0xe89b('0x47')]=_[_0xe89b('0x5a')](_0x59691f['query']);_0x105647['filters']=_[_0xe89b('0x5c')](_0x105647['model'],_0x105647[_0xe89b('0x47')]);_0x17966f['attributes']=_[_0xe89b('0x5c')](_0x105647[_0xe89b('0x58')],qs['fields'](_0x59691f['query'][_0xe89b('0x5d')]));_0x17966f[_0xe89b('0x4b')]=_0x17966f['attributes'][_0xe89b('0x4e')]?_0x17966f[_0xe89b('0x4b')]:_0x105647[_0xe89b('0x58')];_0x17966f[_0xe89b('0xd9')]=qs[_0xe89b('0xcf')](_0x59691f['query'][_0xe89b('0xcf')]);_0x17966f[_0xe89b('0x45')]=qs[_0xe89b('0x5b')](_[_0xe89b('0xd0')](_0x59691f[_0xe89b('0x47')],_0x105647['filters']));if(_0x59691f[_0xe89b('0x47')][_0xe89b('0x40')]){_0x17966f[_0xe89b('0x45')]=_[_0xe89b('0x60')](_0x17966f[_0xe89b('0x45')],{'$or':_[_0xe89b('0x3e')](_0x17966f[_0xe89b('0x4b')],function(_0xf2aeee){var _0x4f8935={};_0x4f8935[_0xf2aeee]={'$like':'%'+_0x59691f['query'][_0xe89b('0x40')]+'%'};return _0x4f8935;})});}_0x17966f=_[_0xe89b('0x60')]({},_0x17966f,_0x59691f[_0xe89b('0x61')]);switch(_0x1834c0['role']){case _0xe89b('0x30'):return db[_[_0xe89b('0xa4')](_0x59691f[_0xe89b('0x47')][_0xe89b('0xa0')])+_0xe89b('0xda')][_0xe89b('0x4c')](_0x17966f);case _0xe89b('0x31'):case _0xe89b('0x33'):return _0x1834c0[_0xe89b('0xae')+_[_0xe89b('0xa4')](_0x59691f[_0xe89b('0x47')][_0xe89b('0xa0')])+'Queues'](_0x17966f);default:throw new db['Sequelize']['ValidationError'](_0xe89b('0xdb'));}})[_0xe89b('0x1a')](function(_0x30a70c){_0x50313c=_0x30a70c[_0xe89b('0x4e')];if(!_0x59691f['query'][_0xe89b('0xd2')](_0xe89b('0xd8'))){_0x17966f['limit']=qs[_0xe89b('0x27')](_0x59691f[_0xe89b('0x47')][_0xe89b('0x27')]);_0x17966f[_0xe89b('0x25')]=qs[_0xe89b('0x25')](_0x59691f[_0xe89b('0x47')]['offset']);}switch(_0x1834c0[_0xe89b('0x2f')]){case'admin':return db[_['capitalize'](_0x59691f[_0xe89b('0x47')][_0xe89b('0xa0')])+_0xe89b('0xda')][_0xe89b('0x4c')](_0x17966f);case'user':case _0xe89b('0x33'):return _0x1834c0[_0xe89b('0xae')+_[_0xe89b('0xa4')](_0x59691f[_0xe89b('0x47')][_0xe89b('0xa0')])+_0xe89b('0xa6')](_0x17966f);}})[_0xe89b('0x1a')](function(_0x2c7dd9){return{'count':_0x50313c,'rows':_0x2c7dd9};})[_0xe89b('0x1a')](respondWithResult(_0x3a3af3,null))['catch'](handleError(_0x3a3af3,null));};exports[_0xe89b('0xdc')]=function(_0x21025e,_0x42b5f5){var _0x2727db={};var _0x2add26={};var _0x584d1b;var _0x2eeaf5;return db[_0xe89b('0x46')][_0xe89b('0xcd')]({'where':{'id':_0x21025e[_0xe89b('0x57')]['id']}})[_0xe89b('0x1a')](handleEntityNotFound(_0x42b5f5,null))[_0xe89b('0x1a')](function(_0x3fa099){if(_0x3fa099){_0x584d1b=_0x3fa099;_0x2add26[_0xe89b('0x58')]=_[_0xe89b('0x5a')](db[_0xe89b('0xb2')]['rawAttributes']);_0x2add26[_0xe89b('0x47')]=_[_0xe89b('0x5a')](_0x21025e['query']);_0x2add26[_0xe89b('0x5b')]=_['intersection'](_0x2add26[_0xe89b('0x58')],_0x2add26[_0xe89b('0x47')]);_0x2727db[_0xe89b('0x4b')]=_[_0xe89b('0x5c')](_0x2add26['model'],qs[_0xe89b('0x5d')](_0x21025e['query'][_0xe89b('0x5d')]));_0x2727db['attributes']=_0x2727db[_0xe89b('0x4b')][_0xe89b('0x4e')]?_0x2727db[_0xe89b('0x4b')]:_0x2add26[_0xe89b('0x58')];_0x2727db[_0xe89b('0xd9')]=qs[_0xe89b('0xcf')](_0x21025e[_0xe89b('0x47')]['sort']);_0x2727db[_0xe89b('0x45')]=qs['filters'](_['pick'](_0x21025e[_0xe89b('0x47')],_0x2add26['filters']));if(_0x21025e[_0xe89b('0x47')][_0xe89b('0x40')]){_0x2727db['where']=_[_0xe89b('0x60')](_0x2727db[_0xe89b('0x45')],{'$or':_[_0xe89b('0x3e')](_0x2727db[_0xe89b('0x4b')],function(_0x2c7e34){var _0x2c2ba4={};_0x2c2ba4[_0x2c7e34]={'$like':'%'+_0x21025e['query'][_0xe89b('0x40')]+'%'};return _0x2c2ba4;})});}_0x2727db=_['merge']({},_0x2727db,_0x21025e[_0xe89b('0x61')]);return _0x584d1b['getVoiceQueuesRt'](_0x2727db);}})['then'](function(_0x382248){if(_0x382248){_0x2eeaf5=_0x382248['length'];if(!_0x21025e['query']['hasOwnProperty'](_0xe89b('0xd8'))){_0x2727db['limit']=qs[_0xe89b('0x27')](_0x21025e['query']['limit']);_0x2727db[_0xe89b('0x25')]=qs[_0xe89b('0x25')](_0x21025e[_0xe89b('0x47')][_0xe89b('0x25')]);}return _0x584d1b['getVoiceQueuesRt'](_0x2727db);}})[_0xe89b('0x1a')](function(_0x2e5495){if(_0x2e5495){return _0x2e5495?{'count':_0x2eeaf5,'rows':_0x2e5495}:null;}})[_0xe89b('0x1a')](respondWithResult(_0x42b5f5,null))[_0xe89b('0x65')](handleError(_0x42b5f5,null));};exports['getGroups']=function(_0x489c22,_0x2ad0ec){var _0x2d7f77={};var _0x44a141={};var _0x3bdaca;var _0x5236ec;return db[_0xe89b('0x46')][_0xe89b('0xcd')]({'where':{'id':_0x489c22[_0xe89b('0x57')]['id']}})[_0xe89b('0x1a')](handleEntityNotFound(_0x2ad0ec,null))[_0xe89b('0x1a')](function(_0x329e4f){if(_0x329e4f){_0x3bdaca=_0x329e4f;_0x44a141['model']=_[_0xe89b('0x5a')](db[_0xe89b('0xdd')][_0xe89b('0x3d')]);_0x44a141[_0xe89b('0x47')]=_[_0xe89b('0x5a')](_0x489c22[_0xe89b('0x47')]);_0x44a141[_0xe89b('0x5b')]=_[_0xe89b('0x5c')](_0x44a141['model'],_0x44a141['query']);_0x2d7f77[_0xe89b('0x4b')]=_[_0xe89b('0x5c')](_0x44a141[_0xe89b('0x58')],qs[_0xe89b('0x5d')](_0x489c22[_0xe89b('0x47')][_0xe89b('0x5d')]));_0x2d7f77[_0xe89b('0x4b')]=_0x2d7f77[_0xe89b('0x4b')]['length']?_0x2d7f77[_0xe89b('0x4b')]:_0x44a141[_0xe89b('0x58')];_0x2d7f77[_0xe89b('0xd9')]=qs['sort'](_0x489c22[_0xe89b('0x47')][_0xe89b('0xcf')]);_0x2d7f77[_0xe89b('0x45')]=qs['filters'](_['pick'](_0x489c22[_0xe89b('0x47')],_0x44a141[_0xe89b('0x5b')]));if(_0x489c22[_0xe89b('0x47')][_0xe89b('0x40')]){_0x2d7f77[_0xe89b('0x45')]=_[_0xe89b('0x60')](_0x2d7f77[_0xe89b('0x45')],{'$or':_[_0xe89b('0x3e')](_0x2d7f77[_0xe89b('0x4b')],function(_0x4250c9){var _0x29278b={};_0x29278b[_0x4250c9]={'$like':'%'+_0x489c22['query']['filter']+'%'};return _0x29278b;})});}_0x2d7f77=_['merge']({},_0x2d7f77,_0x489c22[_0xe89b('0x61')]);return _0x3bdaca[_0xe89b('0xde')](_0x2d7f77);}})[_0xe89b('0x1a')](function(_0x9a3bbf){if(_0x9a3bbf){_0x5236ec=_0x9a3bbf['length'];if(!_0x489c22[_0xe89b('0x47')][_0xe89b('0xd2')](_0xe89b('0xd8'))){_0x2d7f77[_0xe89b('0x27')]=qs['limit'](_0x489c22[_0xe89b('0x47')][_0xe89b('0x27')]);_0x2d7f77[_0xe89b('0x25')]=qs['offset'](_0x489c22[_0xe89b('0x47')][_0xe89b('0x25')]);}return _0x3bdaca[_0xe89b('0xde')](_0x2d7f77);}})[_0xe89b('0x1a')](function(_0x427a7b){if(_0x427a7b){return _0x427a7b?{'count':_0x5236ec,'rows':_0x427a7b}:null;}})[_0xe89b('0x1a')](respondWithResult(_0x2ad0ec,null))[_0xe89b('0x65')](handleError(_0x2ad0ec,null));};exports['getRecordings']=function(_0x5deb3d,_0x390acd){var _0x5075da={'raw':!![],'where':{}};var _0x2a929d={};var _0x5ac402={'count':0x0,'rows':[]};return db[_0xe89b('0x46')][_0xe89b('0xcd')]({'where':{'id':_0x5deb3d[_0xe89b('0x57')]['id']}})[_0xe89b('0x1a')](handleEntityNotFound(_0x390acd,null))[_0xe89b('0x1a')](function(_0x995422){if(_0x995422){_0x2a929d['model']=_[_0xe89b('0x5a')](db[_0xe89b('0xdf')][_0xe89b('0x3d')]);_0x2a929d['query']=_[_0xe89b('0x5a')](_0x5deb3d[_0xe89b('0x47')]);_0x2a929d[_0xe89b('0x5b')]=_[_0xe89b('0x5c')](_0x2a929d[_0xe89b('0x58')],_0x2a929d[_0xe89b('0x47')]);_0x5075da[_0xe89b('0x4b')]=_[_0xe89b('0x5c')](_0x2a929d[_0xe89b('0x58')],qs[_0xe89b('0x5d')](_0x5deb3d['query'][_0xe89b('0x5d')]));_0x5075da[_0xe89b('0x4b')]=_0x5075da['attributes'][_0xe89b('0x4e')]?_0x5075da[_0xe89b('0x4b')]:_0x2a929d[_0xe89b('0x58')];if(!_0x5deb3d[_0xe89b('0x47')]['hasOwnProperty'](_0xe89b('0xd8'))){_0x5075da['limit']=qs[_0xe89b('0x27')](_0x5deb3d[_0xe89b('0x47')][_0xe89b('0x27')]);_0x5075da[_0xe89b('0x25')]=qs[_0xe89b('0x25')](_0x5deb3d[_0xe89b('0x47')][_0xe89b('0x25')]);}_0x5075da[_0xe89b('0xd9')]=qs['sort'](_0x5deb3d[_0xe89b('0x47')][_0xe89b('0xcf')]);_0x5075da[_0xe89b('0x45')]=qs[_0xe89b('0x5b')](_['pick'](_0x5deb3d[_0xe89b('0x47')],_0x2a929d[_0xe89b('0x5b')]));_0x5075da[_0xe89b('0x45')]['UserId']=_0x995422['id'];if(_0x5deb3d[_0xe89b('0x47')][_0xe89b('0x40')]){_0x5075da[_0xe89b('0x45')]=_[_0xe89b('0x60')](_0x5075da[_0xe89b('0x45')],{'$or':_[_0xe89b('0x3e')](_0x5075da[_0xe89b('0x4b')],function(_0x71f2f4){var _0xc6c7f2={};_0xc6c7f2[_0x71f2f4]={'$like':'%'+_0x5deb3d[_0xe89b('0x47')][_0xe89b('0x40')]+'%'};return _0xc6c7f2;})});}_0x5075da=_['merge']({},_0x5075da,_0x5deb3d[_0xe89b('0x61')]);return db[_0xe89b('0xdf')]['count']({'where':_0x5075da['where']})[_0xe89b('0x1a')](function(_0x4e26ae){_0x5ac402[_0xe89b('0x28')]=_0x4e26ae;if(_0x5deb3d[_0xe89b('0x47')]['includeAll']){_0x5075da[_0xe89b('0x4a')]=[{'all':!![]}];}return db[_0xe89b('0xdf')][_0xe89b('0x4c')](_0x5075da);})['then'](function(_0x6822e8){_0x5ac402[_0xe89b('0x4d')]=_0x6822e8;return _0x5ac402;});}})['then'](respondWithFilteredResult(_0x390acd,_0x5075da))[_0xe89b('0x65')](handleError(_0x390acd,null));};exports[_0xe89b('0xe0')]=function(_0x2083b5,_0x18354d){var _0x5844b5={'raw':!![],'where':{}};var _0x30b0f8={};var _0x2be346={'count':0x0,'rows':[]};return db[_0xe89b('0x46')][_0xe89b('0xcd')]({'where':{'id':_0x2083b5[_0xe89b('0x57')]['id']}})[_0xe89b('0x1a')](handleEntityNotFound(_0x18354d,null))[_0xe89b('0x1a')](function(_0x2bf252){if(_0x2bf252){_0x30b0f8[_0xe89b('0x58')]=_[_0xe89b('0x5a')](db['ScreenRecording'][_0xe89b('0x3d')]);_0x30b0f8[_0xe89b('0x47')]=_[_0xe89b('0x5a')](_0x2083b5[_0xe89b('0x47')]);_0x30b0f8[_0xe89b('0x5b')]=_[_0xe89b('0x5c')](_0x30b0f8[_0xe89b('0x58')],_0x30b0f8[_0xe89b('0x47')]);_0x5844b5[_0xe89b('0x4b')]=_['intersection'](_0x30b0f8[_0xe89b('0x58')],qs['fields'](_0x2083b5[_0xe89b('0x47')][_0xe89b('0x5d')]));_0x5844b5[_0xe89b('0x4b')]=_0x5844b5[_0xe89b('0x4b')][_0xe89b('0x4e')]?_0x5844b5[_0xe89b('0x4b')]:_0x30b0f8[_0xe89b('0x58')];if(!_0x2083b5[_0xe89b('0x47')][_0xe89b('0xd2')](_0xe89b('0xd8'))){_0x5844b5[_0xe89b('0x27')]=qs['limit'](_0x2083b5[_0xe89b('0x47')]['limit']);_0x5844b5['offset']=qs['offset'](_0x2083b5[_0xe89b('0x47')][_0xe89b('0x25')]);}_0x5844b5[_0xe89b('0xd9')]=qs['sort'](_0x2083b5[_0xe89b('0x47')][_0xe89b('0xcf')]);_0x5844b5[_0xe89b('0x45')]=qs[_0xe89b('0x5b')](_[_0xe89b('0xd0')](_0x2083b5['query'],_0x30b0f8[_0xe89b('0x5b')]));_0x5844b5[_0xe89b('0x45')][_0xe89b('0xe1')]=_0x2bf252['id'];if(_0x2083b5[_0xe89b('0x47')]['filter']){_0x5844b5[_0xe89b('0x45')]=_[_0xe89b('0x60')](_0x5844b5[_0xe89b('0x45')],{'$or':_[_0xe89b('0x3e')](_0x5844b5[_0xe89b('0x4b')],function(_0xcfd0bd){var _0x2e8fda={};_0x2e8fda[_0xcfd0bd]={'$like':'%'+_0x2083b5[_0xe89b('0x47')][_0xe89b('0x40')]+'%'};return _0x2e8fda;})});}_0x5844b5=_['merge']({},_0x5844b5,_0x2083b5[_0xe89b('0x61')]);return db[_0xe89b('0xe2')][_0xe89b('0x28')]({'where':_0x5844b5['where']})[_0xe89b('0x1a')](function(_0x4b50be){_0x2be346[_0xe89b('0x28')]=_0x4b50be;if(_0x2083b5[_0xe89b('0x47')]['includeAll']){_0x5844b5['include']=[{'all':!![]}];}return db['ScreenRecording'][_0xe89b('0x4c')](_0x5844b5);})[_0xe89b('0x1a')](function(_0x51fdc0){_0x2be346[_0xe89b('0x4d')]=_0x51fdc0;return _0x2be346;});}})[_0xe89b('0x1a')](respondWithFilteredResult(_0x18354d,_0x5844b5))[_0xe89b('0x65')](handleError(_0x18354d,null));};exports[_0xe89b('0xe3')]=function(_0x2d2c69,_0x1e2eac){var _0x37831a={};var _0xa88eb0={};var _0x3657aa;var _0x316b6a;return db[_0xe89b('0x46')]['findOne']({'where':{'id':_0x2d2c69[_0xe89b('0x57')]['id']}})[_0xe89b('0x1a')](handleEntityNotFound(_0x1e2eac,null))[_0xe89b('0x1a')](function(_0x412d8b){if(_0x412d8b){_0x3657aa=_0x412d8b;_0xa88eb0[_0xe89b('0x58')]=_[_0xe89b('0x5a')](db[_0xe89b('0xe4')][_0xe89b('0x3d')]);_0xa88eb0[_0xe89b('0x47')]=_['keys'](_0x2d2c69['query']);_0xa88eb0[_0xe89b('0x5b')]=_[_0xe89b('0x5c')](_0xa88eb0[_0xe89b('0x58')],_0xa88eb0[_0xe89b('0x47')]);_0x37831a[_0xe89b('0x4b')]=_[_0xe89b('0x5c')](_0xa88eb0['model'],qs['fields'](_0x2d2c69[_0xe89b('0x47')][_0xe89b('0x5d')]));_0x37831a[_0xe89b('0x4b')]=_0x37831a[_0xe89b('0x4b')][_0xe89b('0x4e')]?_0x37831a['attributes']:_0xa88eb0['model'];_0x37831a[_0xe89b('0xd9')]=qs['sort'](_0x2d2c69[_0xe89b('0x47')][_0xe89b('0xcf')]);_0x37831a[_0xe89b('0x45')]=qs[_0xe89b('0x5b')](_[_0xe89b('0xd0')](_0x2d2c69['query'],_0xa88eb0[_0xe89b('0x5b')]));if(_0x2d2c69['query'][_0xe89b('0x40')]){_0x37831a[_0xe89b('0x45')]=_[_0xe89b('0x60')](_0x37831a['where'],{'$or':_[_0xe89b('0x3e')](_0x37831a['attributes'],function(_0x35cad6){var _0x162fe3={};_0x162fe3[_0x35cad6]={'$like':'%'+_0x2d2c69[_0xe89b('0x47')][_0xe89b('0x40')]+'%'};return _0x162fe3;})});}_0x37831a=_[_0xe89b('0x60')]({},_0x37831a,_0x2d2c69[_0xe89b('0x61')]);return _0x3657aa[_0xe89b('0xe3')](_0x37831a);}})['then'](function(_0x1c185b){if(_0x1c185b){_0x316b6a=_0x1c185b[_0xe89b('0x4e')];if(!_0x2d2c69[_0xe89b('0x47')][_0xe89b('0xd2')](_0xe89b('0xd8'))){_0x37831a[_0xe89b('0x27')]=qs[_0xe89b('0x27')](_0x2d2c69[_0xe89b('0x47')]['limit']);_0x37831a[_0xe89b('0x25')]=qs[_0xe89b('0x25')](_0x2d2c69[_0xe89b('0x47')]['offset']);}return _0x3657aa[_0xe89b('0xe3')](_0x37831a);}})[_0xe89b('0x1a')](function(_0xcd9722){if(_0xcd9722){return _0xcd9722?{'count':_0x316b6a,'rows':_0xcd9722}:null;}})[_0xe89b('0x1a')](respondWithResult(_0x1e2eac,null))[_0xe89b('0x65')](handleError(_0x1e2eac,null));};exports[_0xe89b('0xe5')]=function(_0x949b72,_0x3a7e9d){var _0x15920e={};var _0x29963f={};var _0x5c9f7b;var _0x2b13f9;return db[_0xe89b('0x46')][_0xe89b('0xcd')]({'where':{'id':_0x949b72[_0xe89b('0x57')]['id']}})[_0xe89b('0x1a')](handleEntityNotFound(_0x3a7e9d,null))['then'](function(_0x41e490){if(_0x41e490){_0x5c9f7b=_0x41e490;_0x29963f['model']=_['keys'](db[_0xe89b('0xe6')]['rawAttributes']);_0x29963f[_0xe89b('0x47')]=_['keys'](_0x949b72[_0xe89b('0x47')]);_0x29963f[_0xe89b('0x5b')]=_['intersection'](_0x29963f[_0xe89b('0x58')],_0x29963f[_0xe89b('0x47')]);_0x15920e[_0xe89b('0x4b')]=_[_0xe89b('0x5c')](_0x29963f[_0xe89b('0x58')],qs['fields'](_0x949b72[_0xe89b('0x47')][_0xe89b('0x5d')]));_0x15920e[_0xe89b('0x4b')]=_0x15920e[_0xe89b('0x4b')]['length']?_0x15920e['attributes']:_0x29963f['model'];_0x15920e[_0xe89b('0xd9')]=qs[_0xe89b('0xcf')](_0x949b72['query'][_0xe89b('0xcf')]);_0x15920e[_0xe89b('0x45')]=qs[_0xe89b('0x5b')](_[_0xe89b('0xd0')](_0x949b72[_0xe89b('0x47')],_0x29963f[_0xe89b('0x5b')]));if(_0x949b72[_0xe89b('0x47')][_0xe89b('0x40')]){_0x15920e[_0xe89b('0x45')]=_[_0xe89b('0x60')](_0x15920e['where'],{'$or':_[_0xe89b('0x3e')](_0x15920e['attributes'],function(_0x3fc956){var _0x19184a={};_0x19184a[_0x3fc956]={'$like':'%'+_0x949b72[_0xe89b('0x47')][_0xe89b('0x40')]+'%'};return _0x19184a;})});}_0x15920e=_[_0xe89b('0x60')]({},_0x15920e,_0x949b72[_0xe89b('0x61')]);return _0x5c9f7b['getOpenchannelInteractions'](_0x15920e);}})[_0xe89b('0x1a')](function(_0x2cb664){if(_0x2cb664){_0x2b13f9=_0x2cb664[_0xe89b('0x4e')];if(!_0x949b72[_0xe89b('0x47')][_0xe89b('0xd2')]('nolimit')){_0x15920e[_0xe89b('0x27')]=qs[_0xe89b('0x27')](_0x949b72[_0xe89b('0x47')][_0xe89b('0x27')]);_0x15920e[_0xe89b('0x25')]=qs[_0xe89b('0x25')](_0x949b72['query']['offset']);}return _0x5c9f7b[_0xe89b('0xe5')](_0x15920e);}})[_0xe89b('0x1a')](function(_0x3f3d65){if(_0x3f3d65){return _0x3f3d65?{'count':_0x2b13f9,'rows':_0x3f3d65}:null;}})[_0xe89b('0x1a')](respondWithResult(_0x3a7e9d,null))[_0xe89b('0x65')](handleError(_0x3a7e9d,null));};exports[_0xe89b('0xe7')]=function(_0x3d59d5,_0x249ac3){var _0x4fd135={'raw':!![],'where':{}};var _0x5e35f2={};var _0x1c74ae={'count':0x0,'rows':[]};return db['User'][_0xe89b('0xcd')]({'where':{'id':_0x3d59d5['params']['id']}})['then'](handleEntityNotFound(_0x249ac3,null))[_0xe89b('0x1a')](function(_0x614e7c){if(_0x614e7c){_0x5e35f2[_0xe89b('0x58')]=_[_0xe89b('0x5a')](db[_0xe89b('0xe8')][_0xe89b('0x3d')]);_0x5e35f2[_0xe89b('0x47')]=_['keys'](_0x3d59d5['query']);_0x5e35f2[_0xe89b('0x5b')]=_[_0xe89b('0x5c')](_0x5e35f2['model'],_0x5e35f2[_0xe89b('0x47')]);_0x4fd135[_0xe89b('0x4b')]=_[_0xe89b('0x5c')](_0x5e35f2['model'],qs['fields'](_0x3d59d5['query'][_0xe89b('0x5d')]));_0x4fd135[_0xe89b('0x4b')]=_0x4fd135[_0xe89b('0x4b')][_0xe89b('0x4e')]?_0x4fd135[_0xe89b('0x4b')]:_0x5e35f2[_0xe89b('0x58')];if(!_0x3d59d5['query']['hasOwnProperty']('nolimit')){_0x4fd135[_0xe89b('0x27')]=qs[_0xe89b('0x27')](_0x3d59d5[_0xe89b('0x47')][_0xe89b('0x27')]);_0x4fd135['offset']=qs['offset'](_0x3d59d5['query'][_0xe89b('0x25')]);}_0x4fd135['order']=qs['sort'](_0x3d59d5[_0xe89b('0x47')]['sort']);_0x4fd135[_0xe89b('0x45')]=qs[_0xe89b('0x5b')](_[_0xe89b('0xd0')](_0x3d59d5[_0xe89b('0x47')],_0x5e35f2[_0xe89b('0x5b')]));_0x4fd135['where'][_0xe89b('0xe1')]=_0x614e7c['id'];if(_0x3d59d5[_0xe89b('0x47')][_0xe89b('0x40')]){_0x4fd135[_0xe89b('0x45')]=_[_0xe89b('0x60')](_0x4fd135[_0xe89b('0x45')],{'$or':_[_0xe89b('0x3e')](_0x4fd135[_0xe89b('0x4b')],function(_0x483497){var _0x455bf2={};_0x455bf2[_0x483497]={'$like':'%'+_0x3d59d5['query'][_0xe89b('0x40')]+'%'};return _0x455bf2;})});}_0x4fd135=_[_0xe89b('0x60')]({},_0x4fd135,_0x3d59d5[_0xe89b('0x61')]);return db['MailInteraction'][_0xe89b('0x28')]({'where':_0x4fd135[_0xe89b('0x45')]})['then'](function(_0x57b541){_0x1c74ae[_0xe89b('0x28')]=_0x57b541;if(_0x3d59d5['query'][_0xe89b('0x5e')]){_0x4fd135[_0xe89b('0x4a')]=[{'all':!![]}];}return db['MailInteraction']['findAll'](_0x4fd135);})['then'](function(_0x10ccba){_0x1c74ae['rows']=_0x10ccba;return _0x1c74ae;});}})[_0xe89b('0x1a')](respondWithFilteredResult(_0x249ac3,_0x4fd135))[_0xe89b('0x65')](handleError(_0x249ac3,null));};exports[_0xe89b('0xe9')]=function(_0x2b2274,_0x4d42a3){var _0x48fdbc={};var _0x39b20f={};var _0xce62ed;var _0x4f6172;return db[_0xe89b('0x46')][_0xe89b('0xcd')]({'where':{'id':_0x2b2274[_0xe89b('0x57')]['id']}})['then'](handleEntityNotFound(_0x4d42a3,null))['then'](function(_0x3cfa8f){if(_0x3cfa8f){_0xce62ed=_0x3cfa8f;_0x39b20f['model']=_[_0xe89b('0x5a')](db[_0xe89b('0xea')][_0xe89b('0x3d')]);_0x39b20f[_0xe89b('0x47')]=_[_0xe89b('0x5a')](_0x2b2274[_0xe89b('0x47')]);_0x39b20f['filters']=_[_0xe89b('0x5c')](_0x39b20f[_0xe89b('0x58')],_0x39b20f[_0xe89b('0x47')]);_0x48fdbc[_0xe89b('0x4b')]=_[_0xe89b('0x5c')](_0x39b20f[_0xe89b('0x58')],qs['fields'](_0x2b2274[_0xe89b('0x47')]['fields']));_0x48fdbc['attributes']=_0x48fdbc[_0xe89b('0x4b')][_0xe89b('0x4e')]?_0x48fdbc['attributes']:_0x39b20f['model'];_0x48fdbc[_0xe89b('0xd9')]=qs[_0xe89b('0xcf')](_0x2b2274['query']['sort']);_0x48fdbc[_0xe89b('0x45')]=qs[_0xe89b('0x5b')](_[_0xe89b('0xd0')](_0x2b2274[_0xe89b('0x47')],_0x39b20f['filters']));if(_0x2b2274[_0xe89b('0x47')][_0xe89b('0x40')]){_0x48fdbc[_0xe89b('0x45')]=_[_0xe89b('0x60')](_0x48fdbc['where'],{'$or':_['map'](_0x48fdbc[_0xe89b('0x4b')],function(_0x2b7c80){var _0x2dc290={};_0x2dc290[_0x2b7c80]={'$like':'%'+_0x2b2274[_0xe89b('0x47')][_0xe89b('0x40')]+'%'};return _0x2dc290;})});}_0x48fdbc=_['merge']({},_0x48fdbc,_0x2b2274['options']);return _0xce62ed[_0xe89b('0xe9')](_0x48fdbc);}})[_0xe89b('0x1a')](function(_0x2bf8e4){if(_0x2bf8e4){_0x4f6172=_0x2bf8e4[_0xe89b('0x4e')];if(!_0x2b2274[_0xe89b('0x47')][_0xe89b('0xd2')](_0xe89b('0xd8'))){_0x48fdbc[_0xe89b('0x27')]=qs[_0xe89b('0x27')](_0x2b2274[_0xe89b('0x47')][_0xe89b('0x27')]);_0x48fdbc[_0xe89b('0x25')]=qs[_0xe89b('0x25')](_0x2b2274[_0xe89b('0x47')]['offset']);}return _0xce62ed[_0xe89b('0xe9')](_0x48fdbc);}})[_0xe89b('0x1a')](function(_0x444a56){if(_0x444a56){return _0x444a56?{'count':_0x4f6172,'rows':_0x444a56}:null;}})[_0xe89b('0x1a')](respondWithResult(_0x4d42a3,null))[_0xe89b('0x65')](handleError(_0x4d42a3,null));};exports[_0xe89b('0xeb')]=function(_0x57023c,_0x4d3a13){var _0x515a22={};var _0x39d9ea={};var _0x470255;var _0x317b69;return db['User'][_0xe89b('0xcd')]({'where':{'id':_0x57023c['params']['id']}})[_0xe89b('0x1a')](handleEntityNotFound(_0x4d3a13,null))[_0xe89b('0x1a')](function(_0x144a4b){if(_0x144a4b){_0x470255=_0x144a4b;_0x39d9ea['model']=_[_0xe89b('0x5a')](db[_0xe89b('0xec')][_0xe89b('0x3d')]);_0x39d9ea[_0xe89b('0x47')]=_[_0xe89b('0x5a')](_0x57023c['query']);_0x39d9ea['filters']=_[_0xe89b('0x5c')](_0x39d9ea['model'],_0x39d9ea[_0xe89b('0x47')]);_0x515a22[_0xe89b('0x4b')]=_[_0xe89b('0x5c')](_0x39d9ea[_0xe89b('0x58')],qs[_0xe89b('0x5d')](_0x57023c[_0xe89b('0x47')][_0xe89b('0x5d')]));_0x515a22['attributes']=_0x515a22['attributes']['length']?_0x515a22[_0xe89b('0x4b')]:_0x39d9ea[_0xe89b('0x58')];_0x515a22[_0xe89b('0xd9')]=qs[_0xe89b('0xcf')](_0x57023c[_0xe89b('0x47')][_0xe89b('0xcf')]);_0x515a22[_0xe89b('0x45')]=qs['filters'](_['pick'](_0x57023c[_0xe89b('0x47')],_0x39d9ea['filters']));if(_0x57023c['query'][_0xe89b('0x40')]){_0x515a22[_0xe89b('0x45')]=_[_0xe89b('0x60')](_0x515a22['where'],{'$or':_[_0xe89b('0x3e')](_0x515a22[_0xe89b('0x4b')],function(_0x37a2da){var _0xf2d4e={};_0xf2d4e[_0x37a2da]={'$like':'%'+_0x57023c[_0xe89b('0x47')][_0xe89b('0x40')]+'%'};return _0xf2d4e;})});}_0x515a22=_[_0xe89b('0x60')]({},_0x515a22,_0x57023c[_0xe89b('0x61')]);return _0x470255[_0xe89b('0xeb')](_0x515a22);}})[_0xe89b('0x1a')](function(_0x25dcac){if(_0x25dcac){_0x317b69=_0x25dcac[_0xe89b('0x4e')];if(!_0x57023c[_0xe89b('0x47')][_0xe89b('0xd2')](_0xe89b('0xd8'))){_0x515a22['limit']=qs[_0xe89b('0x27')](_0x57023c[_0xe89b('0x47')]['limit']);_0x515a22['offset']=qs[_0xe89b('0x25')](_0x57023c['query'][_0xe89b('0x25')]);}return _0x470255[_0xe89b('0xeb')](_0x515a22);}})[_0xe89b('0x1a')](function(_0x6dc3ab){if(_0x6dc3ab){return _0x6dc3ab?{'count':_0x317b69,'rows':_0x6dc3ab}:null;}})[_0xe89b('0x1a')](respondWithResult(_0x4d3a13,null))[_0xe89b('0x65')](handleError(_0x4d3a13,null));};exports[_0xe89b('0xed')]=function(_0x295a5f,_0x234fe9){var _0x4f144c={};var _0x557ccb={};var _0x198a8e;var _0x3a1e98;return db[_0xe89b('0x46')][_0xe89b('0xcd')]({'where':{'id':_0x295a5f[_0xe89b('0x57')]['id']}})[_0xe89b('0x1a')](handleEntityNotFound(_0x234fe9,null))[_0xe89b('0x1a')](function(_0x16a7c5){if(_0x16a7c5){_0x198a8e=_0x16a7c5;_0x557ccb['model']=_['keys'](db[_0xe89b('0xee')][_0xe89b('0x3d')]);_0x557ccb[_0xe89b('0x47')]=_['keys'](_0x295a5f[_0xe89b('0x47')]);_0x557ccb['filters']=_[_0xe89b('0x5c')](_0x557ccb[_0xe89b('0x58')],_0x557ccb[_0xe89b('0x47')]);_0x4f144c['attributes']=_[_0xe89b('0x5c')](_0x557ccb['model'],qs[_0xe89b('0x5d')](_0x295a5f['query'][_0xe89b('0x5d')]));_0x4f144c[_0xe89b('0x4b')]=_0x4f144c[_0xe89b('0x4b')][_0xe89b('0x4e')]?_0x4f144c['attributes']:_0x557ccb[_0xe89b('0x58')];_0x4f144c[_0xe89b('0xd9')]=qs[_0xe89b('0xcf')](_0x295a5f['query'][_0xe89b('0xcf')]);_0x4f144c[_0xe89b('0x45')]=qs['filters'](_['pick'](_0x295a5f[_0xe89b('0x47')],_0x557ccb[_0xe89b('0x5b')]));if(_0x295a5f[_0xe89b('0x47')][_0xe89b('0x40')]){_0x4f144c['where']=_[_0xe89b('0x60')](_0x4f144c['where'],{'$or':_['map'](_0x4f144c['attributes'],function(_0x65a4d0){var _0x23ee36={};_0x23ee36[_0x65a4d0]={'$like':'%'+_0x295a5f[_0xe89b('0x47')][_0xe89b('0x40')]+'%'};return _0x23ee36;})});}_0x4f144c=_['merge']({},_0x4f144c,_0x295a5f[_0xe89b('0x61')]);return _0x198a8e[_0xe89b('0xed')](_0x4f144c);}})[_0xe89b('0x1a')](function(_0x3058a3){if(_0x3058a3){_0x3a1e98=_0x3058a3[_0xe89b('0x4e')];if(!_0x295a5f[_0xe89b('0x47')][_0xe89b('0xd2')](_0xe89b('0xd8'))){_0x4f144c[_0xe89b('0x27')]=qs[_0xe89b('0x27')](_0x295a5f[_0xe89b('0x47')][_0xe89b('0x27')]);_0x4f144c['offset']=qs[_0xe89b('0x25')](_0x295a5f['query'][_0xe89b('0x25')]);}return _0x198a8e[_0xe89b('0xed')](_0x4f144c);}})[_0xe89b('0x1a')](function(_0x420051){if(_0x420051){return _0x420051?{'count':_0x3a1e98,'rows':_0x420051}:null;}})[_0xe89b('0x1a')](respondWithResult(_0x234fe9,null))[_0xe89b('0x65')](handleError(_0x234fe9,null));};exports[_0xe89b('0xef')]=function(_0x45dd25,_0x379b90,_0xc2369c){var _0x469b80;var _0x20f3f6;var _0x4dfbaf;var _0x974ee=!_[_0xe89b('0x70')](_0x45dd25[_0xe89b('0x57')]['id'])?_0x45dd25[_0xe89b('0x57')]['id']:!_[_0xe89b('0x70')](_0x45dd25[_0xe89b('0x31')]['id'])?_0x45dd25[_0xe89b('0x31')]['id']:null;return db['User'][_0xe89b('0x62')]({'where':{'id':_0x974ee,'role':{'$or':[_0xe89b('0x30'),_0xe89b('0x31'),_0xe89b('0x33')]}},'attributes':['id',_0xe89b('0x37'),_0xe89b('0xf0'),_0xe89b('0xf1'),_0xe89b('0x2f'),'internal',_0xe89b('0xa1')]})[_0xe89b('0x1a')](function(_0x7410bd){if(_0x7410bd){if(_0x7410bd['role']===_0xe89b('0x33')){_0x469b80=_0x7410bd;if(_0x45dd25[_0xe89b('0x66')][_0xe89b('0xa2')]){_0x4dfbaf=util['format'](_0xe89b('0xf2'),_0x469b80[_0x45dd25[_0xe89b('0x66')][_0xe89b('0xa2')]]);}else if(_0x45dd25['body']['intrf']){_0x4dfbaf=util['format'](_0xe89b('0xb0'),_0x45dd25[_0xe89b('0x66')]['intrf']);}else{_0x4dfbaf=util[_0xe89b('0xaf')](_0xe89b('0xb0'),_0x469b80[_0xe89b('0x37')]);}socket['to'](util['format'](_0xe89b('0xf3'),_0x469b80['name']))[_0xe89b('0xaa')]('user:forcelogout',{'user':{'id':_0x469b80['id'],'name':_0x469b80[_0xe89b('0x37')]},'ip':_0x45dd25[_0xe89b('0xf4')][_0xe89b('0xf5')]||_0x45dd25['connection'][_0xe89b('0xf6')]||_0x45dd25[_0xe89b('0xf7')][_0xe89b('0xf6')]||_0x45dd25[_0xe89b('0xf8')][_0xe89b('0xf7')][_0xe89b('0xf6')]});return db[_0xe89b('0xb2')]['destroy']({'where':{'membername':_0x469b80['name']},'individualHooks':!![]});}}else{throw new db[(_0xe89b('0x97'))]['ValidationError'](_0xe89b('0xf9'));}})[_0xe89b('0x1a')](function(){if(_0x469b80){return _0x469b80[_0xe89b('0xfa')]({'raw':!![]});}})[_0xe89b('0x1a')](function(_0x418230){if(_0x469b80){var _0x4de1e4=[];if(_0x418230){_0x20f3f6=_0x418230;if(_0x20f3f6[_0xe89b('0x4e')]){for(var _0x37d4c3=0x0;_0x37d4c3<_0x20f3f6[_0xe89b('0x4e')];_0x37d4c3++){_0x4de1e4['push']({'membername':_0x469b80['name'],'UserId':_0x469b80['id'],'queue_name':_0x20f3f6[_0x37d4c3][_0xe89b('0x37')],'VoiceQueueId':_0x20f3f6[_0x37d4c3]['id'],'interface':_0x4dfbaf,'paused':_0x469b80[_0xe89b('0xa1')]||![],'penalty':_0x20f3f6[_0x37d4c3][_0xe89b('0xfb')]||0x0});}return BPromise['each'](_0x4de1e4,function(_0x43392f){return db[_0xe89b('0xb2')][_0xe89b('0xfc')](_0x43392f);});}}}})[_0xe89b('0x1a')](function(){if(_0x469b80){return db[_0xe89b('0xfd')][_0xe89b('0x4c')]({'where':{'membername':_0x469b80[_0xe89b('0x37')],'exitAt':null}});}})[_0xe89b('0x1a')](function(_0x214c65){if(_0x469b80){var _0x1dd474=[];_0x214c65[_0xe89b('0xfe')](function(_0x2f90f4){_0x1dd474['push'](_0x2f90f4[_0xe89b('0x2c')]({'exitAt':moment()[_0xe89b('0xaf')]('YYYY-MM-DD\x20HH:mm:ss')}));});return BPromise[_0xe89b('0x55')](_0x1dd474);}})[_0xe89b('0x1a')](function(){if(_0x469b80){var _0x187e11=[];var _0x70fb37=[];var _0x5f4de6=utils['getChannels']();var _0x495268={'membername':_0x469b80[_0xe89b('0x37')],'interface':_0x4dfbaf,'enterAt':moment()[_0xe89b('0xaf')](_0xe89b('0xff')),'role':_0x469b80['role'],'internal':_0x469b80[_0xe89b('0x6b')]};_0x5f4de6[_0xe89b('0xfe')](function(_0xfa5819){_0x187e11[_0xe89b('0x4f')](_[_0xe89b('0x60')]({'channel':_0xfa5819,'type':_0xe89b('0x100'),'data1':_0x45dd25[_0xe89b('0x66')][_0xe89b('0x101')],'data2':_0x4dfbaf},_0x495268));if(_0x469b80[_0xe89b('0xa1')]){_0x70fb37[_0xe89b('0x4f')](_[_0xe89b('0x60')]({'channel':_0xfa5819,'type':_0xe89b('0x102'),'data1':_0xe89b('0x103')},_0x495268));}});return db[_0xe89b('0xfd')]['bulkCreate'](_0x187e11[_0xe89b('0xcc')](_0x70fb37),{'individualHooks':!![]});}})[_0xe89b('0x1a')](function(){if(_0x469b80){return _0x469b80['update']({'online':!![],'lastLoginAt':moment()[_0xe89b('0xaf')]('YYYY-MM-DD\x20HH:mm:ss'),'voicePause':_0x469b80[_0xe89b('0xa1')]||![],'mailPause':_0x469b80[_0xe89b('0xa1')]||![],'chatPause':_0x469b80[_0xe89b('0xa1')]||![],'faxPause':_0x469b80[_0xe89b('0xa1')]||![],'smsPause':_0x469b80[_0xe89b('0xa1')]||![],'openchannelPause':_0x469b80[_0xe89b('0xa1')]||![],'whatsappPause':_0x469b80[_0xe89b('0xa1')]||![],'pauseType':_0x469b80[_0xe89b('0xa1')]?_0xe89b('0x103'):null,'interface':_0x4dfbaf,'lastPauseAt':moment()[_0xe89b('0xaf')](_0xe89b('0xff'))});}})[_0xe89b('0x1a')](function(_0x41c35b){if(_0x45dd25[_0xe89b('0x104')]){return _0xc2369c();}else{return BPromise[_0xe89b('0x105')](_0x41c35b)['then'](respondWithResult(_0x379b90,null));}})[_0xe89b('0x65')](handleError(_0x379b90,null));};exports[_0xe89b('0x106')]=function(_0x184201,_0x50f65b){var _0x3c967f;return db[_0xe89b('0x46')][_0xe89b('0x62')]({'where':{'id':_0x184201['params']['id'],'role':_0xe89b('0x33')},'attributes':['id',_0xe89b('0x37'),'role']})[_0xe89b('0x1a')](handleEntityNotFound(_0x50f65b,null))[_0xe89b('0x1a')](function(_0x1dec8a){if(_0x1dec8a){_0x3c967f=_0x1dec8a;return db[_0xe89b('0xb2')][_0xe89b('0x2e')]({'where':{'membername':_0x3c967f[_0xe89b('0x37')]},'individualHooks':!![]});}})[_0xe89b('0x1a')](function(){return db['MemberReport']['findAll']({'where':{'membername':_0x3c967f['name'],'exitAt':null}});})[_0xe89b('0x1a')](function(_0x5dcd98){var _0x5320ea=[];_0x5dcd98['forEach'](function(_0x1f4cc5){_0x5320ea[_0xe89b('0x4f')](_0x1f4cc5[_0xe89b('0x2c')]({'exitAt':moment()['format'](_0xe89b('0xff'))}));});return BPromise['all'](_0x5320ea);})[_0xe89b('0x1a')](function(){return _0x3c967f[_0xe89b('0x2c')]({'online':![],'voicePause':![],'mailPause':![],'chatPause':![],'faxPause':![],'smsPause':![],'openchannelPause':![],'whatsappPause':![],'interface':null});})[_0xe89b('0x1a')](respondWithResult(_0x50f65b,null))[_0xe89b('0x65')](handleError(_0x50f65b,null));};exports[_0xe89b('0x107')]=function(_0x2fdcef,_0x4b85c6){var _0xd1aea4;return db[_0xe89b('0xb2')][_0xe89b('0x2c')]({'paused':0x1},{'where':{'UserId':_0x2fdcef[_0xe89b('0x57')]['id']},'individualHooks':!![]})[_0xe89b('0x1a')](function(){return db[_0xe89b('0x46')]['find']({'where':{'id':_0x2fdcef['params']['id'],'role':_0xe89b('0x33')},'attributes':['id',_0xe89b('0x37'),'role',_0xe89b('0x6b'),_0xe89b('0xa2')]});})[_0xe89b('0x1a')](handleEntityNotFound(_0x4b85c6,null))[_0xe89b('0x1a')](function(_0x19457b){if(_0x19457b){_0xd1aea4=_0x19457b;return respondWithRpcPromise(_0xe89b('0x108'),_0xe89b('0x107'),{'id':_0xd1aea4['id'],'name':_0xd1aea4['name'],'pause':!![]});}})[_0xe89b('0x1a')](function(){if(_0xd1aea4){return db['MemberReport']['findAll']({'where':{'membername':_0xd1aea4['name'],'type':'PAUSE','exitAt':null}});}})[_0xe89b('0x1a')](function(_0x5db2cb){if(_0x5db2cb[_0xe89b('0x4e')]){var _0x5c6990=moment()[_0xe89b('0xaf')](_0xe89b('0xff'));for(var _0x119859=0x0,_0x186569=_0x5db2cb[_0xe89b('0x4e')];_0x119859<_0x186569;_0x119859++){_0x5db2cb[_0x119859]['updateAttributes']({'exitAt':_0x5c6990});}}})['then'](function(){var _0x358eed=[];var _0x9b5280=utils[_0xe89b('0x109')]();_0x9b5280[_0xe89b('0xfe')](function(_0xde7c59){_0x358eed[_0xe89b('0x4f')]({'channel':_0xde7c59,'membername':_0xd1aea4['name'],'interface':_['isNil'](_0xd1aea4[_0xe89b('0xa2')])?util[_0xe89b('0xaf')](_0xe89b('0xb0'),_0xd1aea4['name']):_0xd1aea4[_0xe89b('0xa2')],'type':_0xe89b('0x102'),'enterAt':moment()[_0xe89b('0xaf')](_0xe89b('0xff')),'data1':_0x2fdcef[_0xe89b('0x66')][_0xe89b('0x3f')]||_0xe89b('0x10a'),'role':_0xd1aea4[_0xe89b('0x2f')],'internal':_0xd1aea4[_0xe89b('0x6b')]});});return db[_0xe89b('0xfd')]['bulkCreate'](_0x358eed,{'individualHooks':!![]});})['then'](function(){return _0xd1aea4[_0xe89b('0x2c')]({'voicePause':!![],'mailPause':!![],'chatPause':!![],'faxPause':!![],'smsPause':!![],'whatsappPause':!![],'openchannelPause':!![],'pauseType':_0x2fdcef['body']['type']||_0xe89b('0x10a'),'lastPauseAt':moment()[_0xe89b('0xaf')]('YYYY-MM-DD\x20HH:mm:ss')});})[_0xe89b('0x1a')](respondWithResult(_0x4b85c6,null))['catch'](handleError(_0x4b85c6,null));};exports[_0xe89b('0x10b')]=function(_0x198848,_0x2c472b){var _0x41598c;return db['User'][_0xe89b('0x62')]({'where':{'id':_0x198848[_0xe89b('0x57')]['id']},'attributes':['id',_0xe89b('0x37'),_0xe89b('0x2f'),'voicePause',_0xe89b('0x10c'),_0xe89b('0x10d'),_0xe89b('0x10e'),'openchannelPause',_0xe89b('0x10f'),_0xe89b('0x110'),'pauseType',_0xe89b('0x111')]})[_0xe89b('0x1a')](handleEntityNotFound(_0x2c472b,null))[_0xe89b('0x1a')](function(_0x20926f){if(_0x20926f){_0x41598c=_0x20926f;if(_0x198848[_0xe89b('0x66')][_0xe89b('0xa0')]&&!utils[_0xe89b('0xa3')](_0x198848[_0xe89b('0x66')][_0xe89b('0xa0')])){throw new db[(_0xe89b('0x97'))]['ValidationError'](_0xe89b('0xb4'));}switch(_0x198848[_0xe89b('0x66')][_0xe89b('0xa0')]){case _0xe89b('0xac'):return respondWithRpcPromise(_0xe89b('0x108'),_0xe89b('0x10b'),{'id':_0x41598c['id'],'name':_0x41598c[_0xe89b('0x37')],'pause':![]})[_0xe89b('0x1a')](function(){return db[_0xe89b('0xb2')][_0xe89b('0x2c')]({'paused':0x0},{'where':{'UserId':_0x41598c['id']},'individualHooks':!![]});})[_0xe89b('0x1a')](function(){return db[_0xe89b('0xfd')][_0xe89b('0x62')]({'where':{'channel':_0x198848[_0xe89b('0x66')][_0xe89b('0xa0')],'membername':_0x41598c[_0xe89b('0x37')],'type':_0xe89b('0x102'),'exitAt':null}});})[_0xe89b('0x1a')](function(_0x100203){if(_0x100203){return _0x100203['update']({'exitAt':moment()[_0xe89b('0xaf')](_0xe89b('0xff')),'data2':'manual'},{'individualHooks':!![]});}return null;})[_0xe89b('0x1a')](function(){return _0x41598c['update']({'voicePause':![]});});case _0xe89b('0x53'):case _0xe89b('0x50'):case _0xe89b('0x52'):case'sms':case _0xe89b('0x54'):case _0xe89b('0x64'):return db['MemberReport']['find']({'where':{'channel':_0x198848['body']['channel'],'membername':_0x41598c[_0xe89b('0x37')],'type':_0xe89b('0x102'),'exitAt':null}})[_0xe89b('0x1a')](function(_0x35d7e0){if(_0x35d7e0){return _0x35d7e0[_0xe89b('0x2c')]({'exitAt':moment()[_0xe89b('0xaf')](_0xe89b('0xff')),'data2':_0xe89b('0x112')},{'individualHooks':!![]});}return null;})['then'](function(){var _0x5552c9={};_[_0xe89b('0x29')](_0x5552c9,util['format'](_0xe89b('0x113'),_0x198848['body']['channel'],_0xe89b('0x114')),![]);return _0x41598c[_0xe89b('0x2c')](_0x5552c9);});default:return respondWithRpcPromise('QueuePause',_0xe89b('0x10b'),{'id':_0x41598c['id'],'name':_0x41598c['name'],'pause':![]})['then'](function(){return db[_0xe89b('0xb2')][_0xe89b('0x2c')]({'paused':0x0},{'where':{'UserId':_0x41598c['id']}});})['then'](function(){return db[_0xe89b('0xfd')][_0xe89b('0x4c')]({'where':{'membername':_0x41598c[_0xe89b('0x37')],'type':_0xe89b('0x102'),'exitAt':null}});})[_0xe89b('0x1a')](function(_0x474310){var _0x23fcbf=[];_0x474310[_0xe89b('0xfe')](function(_0x2b3b18){_0x23fcbf[_0xe89b('0x4f')](_0x2b3b18['update']({'exitAt':moment()[_0xe89b('0xaf')]('YYYY-MM-DD\x20HH:mm:ss'),'data2':_0xe89b('0x112')}));});return BPromise[_0xe89b('0x55')](_0x23fcbf);})[_0xe89b('0x1a')](function(){return _0x41598c[_0xe89b('0x2c')]({'voicePause':![],'mailPause':![],'chatPause':![],'faxPause':![],'smsPause':![],'whatsappPause':![],'openchannelPause':![]});});}}})[_0xe89b('0x1a')](respondWithResult(_0x2c472b,null))['catch'](handleError(_0x2c472b,null));};exports['getTeams']=function(_0x30214b,_0x128bc3){var _0x46457d={};var _0x376048={};var _0x123a5b;var _0x555ef0;return db[_0xe89b('0x46')]['findOne']({'where':{'id':_0x30214b['params']['id']}})['then'](handleEntityNotFound(_0x128bc3,null))[_0xe89b('0x1a')](function(_0x3e0a5a){if(_0x3e0a5a){_0x123a5b=_0x3e0a5a;_0x376048['model']=_['keys'](db[_0xe89b('0x115')][_0xe89b('0x3d')]);_0x376048[_0xe89b('0x47')]=_[_0xe89b('0x5a')](_0x30214b[_0xe89b('0x47')]);_0x376048['filters']=_[_0xe89b('0x5c')](_0x376048[_0xe89b('0x58')],_0x376048[_0xe89b('0x47')]);_0x46457d['attributes']=_[_0xe89b('0x5c')](_0x376048[_0xe89b('0x58')],qs[_0xe89b('0x5d')](_0x30214b[_0xe89b('0x47')][_0xe89b('0x5d')]));_0x46457d[_0xe89b('0x4b')]=_0x46457d[_0xe89b('0x4b')][_0xe89b('0x4e')]?_0x46457d['attributes']:_0x376048[_0xe89b('0x58')];_0x46457d['order']=qs[_0xe89b('0xcf')](_0x30214b[_0xe89b('0x47')][_0xe89b('0xcf')]);_0x46457d[_0xe89b('0x45')]=qs['filters'](_[_0xe89b('0xd0')](_0x30214b[_0xe89b('0x47')],_0x376048[_0xe89b('0x5b')]));if(_0x30214b[_0xe89b('0x47')][_0xe89b('0x40')]){_0x46457d[_0xe89b('0x45')]=_[_0xe89b('0x60')](_0x46457d[_0xe89b('0x45')],{'$or':_[_0xe89b('0x3e')](_0x46457d[_0xe89b('0x4b')],function(_0x12b017){var _0x2fe6f3={};_0x2fe6f3[_0x12b017]={'$like':'%'+_0x30214b[_0xe89b('0x47')][_0xe89b('0x40')]+'%'};return _0x2fe6f3;})});}_0x46457d=_[_0xe89b('0x60')]({},_0x46457d,_0x30214b[_0xe89b('0x61')]);return _0x123a5b[_0xe89b('0x116')](_0x46457d);}})['then'](function(_0x520dd0){if(_0x520dd0){_0x555ef0=_0x520dd0['length'];if(!_0x30214b[_0xe89b('0x47')]['hasOwnProperty'](_0xe89b('0xd8'))){_0x46457d[_0xe89b('0x27')]=qs[_0xe89b('0x27')](_0x30214b[_0xe89b('0x47')][_0xe89b('0x27')]);_0x46457d[_0xe89b('0x25')]=qs[_0xe89b('0x25')](_0x30214b[_0xe89b('0x47')]['offset']);}return _0x123a5b['getTeams'](_0x46457d);}})[_0xe89b('0x1a')](function(_0x16d945){if(_0x16d945){return _0x16d945?{'count':_0x555ef0,'rows':_0x16d945}:null;}})[_0xe89b('0x1a')](respondWithResult(_0x128bc3,null))[_0xe89b('0x65')](handleError(_0x128bc3,null));};exports['addTeams']=function(_0x17549a,_0x345181){var _0x4184fc=_0x17549a[_0xe89b('0x57')]['id'];var _0xa60a26=_0x17549a[_0xe89b('0x66')]?_0x17549a[_0xe89b('0x66')][_0xe89b('0x69')]:null;var _0x25f13f=[];return Promise['resolve']()[_0xe89b('0x1a')](function(){if(!_0xa60a26)throw new APIBadRequestError(_0xe89b('0x117'));})[_0xe89b('0x1a')](function(){return db[_0xe89b('0x46')][_0xe89b('0xcd')]({'where':{'id':_0x4184fc}});})[_0xe89b('0x1a')](function(_0x2f6322){if(!_0x2f6322)throw new APINotFoundError(util[_0xe89b('0xaf')](_0xe89b('0x118'),_0x17549a['params']['id']));return db[_0xe89b('0x72')][_0xe89b('0x119')](function(_0x110446){return _0x2f6322[_0xe89b('0x11a')](_0xa60a26,{'transaction':_0x110446})[_0xe89b('0x1a')](function(){return db[_0xe89b('0x115')]['findAll']({'where':{'id':{'$in':_0xa60a26}}});})[_0xe89b('0x1a')](function(_0x42b653){var _0x5178a8=_[_0xe89b('0x3e')](_0x42b653,function(_0x5202d0){return _0x5202d0[_0xe89b('0x11b')]();});return Promise['all'](_0x5178a8);})[_0xe89b('0x1a')](function(_0x23359e){_0x25f13f=_['flattenDeep'](_0x23359e);var _0x330239=_[_0xe89b('0x3e')](_0x25f13f,function(_0xa64294){return _0xa64294[_0xe89b('0x11c')](_0x2f6322['id'],{'transaction':_0x110446});});return Promise[_0xe89b('0x55')](_0x330239);})[_0xe89b('0x1a')](function(){if(!_0x2f6322['online'])return;var _0xec6793=_[_0xe89b('0x40')](_0x25f13f,function(_0x32b252){return _0x32b252[_0xe89b('0x11d')](_0xe89b('0xa0'))==='Voice';});var _0x103e30=_[_0xe89b('0x3e')](_0xec6793,function(_0x134245){return db[_0xe89b('0xb2')][_0xe89b('0xfc')]({'membername':_0x2f6322[_0xe89b('0x37')],'UserId':_0x2f6322['id'],'queue_name':_0x134245[_0xe89b('0x37')],'VoiceQueueId':_0x134245['id'],'interface':_['isNil'](_0x2f6322[_0xe89b('0xa2')])?util[_0xe89b('0xaf')](_0xe89b('0xb0'),_0x2f6322[_0xe89b('0x37')]):_0x2f6322[_0xe89b('0xa2')],'paused':_0x2f6322['voicePause']||![],'penalty':_0x2f6322['penalty']},{'transaction':_0x110446});});return Promise[_0xe89b('0x55')](_0x103e30);})[_0xe89b('0x1a')](function(){return db[_0xe89b('0x11e')][_0xe89b('0x4c')]({'where':{'teamId':{'$in':_0xa60a26}}});})['then'](function(_0x4ca66b){var _0x180e7b=_[_0xe89b('0x3e')](_0x4ca66b,function(_0x3f7f36){return db[_0xe89b('0x11f')]['create']({'UserId':_0x2f6322['id'],'VoicePrefixId':_0x3f7f36['VoicePrefixId']},{'transaction':_0x110446});});return Promise['all'](_0x180e7b);});});})[_0xe89b('0x1a')](function(){for(var _0x4c2f11=0x0;_0x4c2f11<_0x25f13f[_0xe89b('0x4e')];_0x4c2f11++){var _0x193a6c=_0x25f13f[_0x4c2f11][_0xe89b('0x11d')](_0xe89b('0xa0'));var _0x191396=_0x193a6c+_0xe89b('0xa9');socket[_0xe89b('0xaa')](_0xe89b('0x31')+_0x193a6c+'Queue:save',{'UserId':_0x4184fc,['queueField']:_0x25f13f[_0x4c2f11]['id']});}})[_0xe89b('0x1a')](respondWithStatusCode(_0x345181,null))[_0xe89b('0x65')](APIHandleError(_0x345181));};exports[_0xe89b('0x120')]=function(_0x3ecb65,_0x58d1de){var _0x1463ef=_0x3ecb65[_0xe89b('0x57')]['id'];var _0x389d23=null;if(_0x3ecb65[_0xe89b('0x47')]['ids']){_0x389d23=_[_0xe89b('0x121')](_0x3ecb65[_0xe89b('0x47')][_0xe89b('0x69')])?_0x3ecb65[_0xe89b('0x47')]['ids']:[_0x3ecb65[_0xe89b('0x47')][_0xe89b('0x69')]];}var _0x5b6de6=[];return Promise['resolve']()['then'](function(){if(!_0x389d23)throw new APIBadRequestError('Query\x20parameter\x20\x27ids\x27\x20is\x20required');})[_0xe89b('0x1a')](function(){return db[_0xe89b('0x46')]['findOne']({'where':{'id':_0x1463ef}});})[_0xe89b('0x1a')](function(_0x590de){if(!_0x590de)throw new APINotFoundError(util[_0xe89b('0xaf')](_0xe89b('0x118'),_0x3ecb65[_0xe89b('0x57')]['id']));return db[_0xe89b('0x72')][_0xe89b('0x119')](function(_0x225567){return _0x590de['removeTeams'](_0x389d23,{'transaction':_0x225567})[_0xe89b('0x1a')](function(){return db[_0xe89b('0x115')]['findAll']({'where':{'id':{'$in':_0x389d23}}});})[_0xe89b('0x1a')](function(_0x3338b5){var _0x34aab1=_[_0xe89b('0x3e')](_0x3338b5,function(_0x2456eb){return _0x2456eb[_0xe89b('0x11b')]();});return Promise[_0xe89b('0x55')](_0x34aab1);})[_0xe89b('0x1a')](function(_0x40552b){_0x5b6de6=_[_0xe89b('0x122')](_0x40552b);var _0x232aad=_['map'](_0x5b6de6,function(_0x11d9eb){return _0x11d9eb['removeAgent'](_0x590de['id'],{'transaction':_0x225567});});return Promise[_0xe89b('0x55')](_0x232aad);})[_0xe89b('0x1a')](function(){if(!_0x590de[_0xe89b('0x123')])return;var _0x2e4258=_[_0xe89b('0x40')](_0x5b6de6,function(_0x364db1){return _0x364db1[_0xe89b('0x11d')](_0xe89b('0xa0'))===_0xe89b('0x124');});var _0x20d7ff=_[_0xe89b('0x3e')](_0x2e4258,function(_0x28b432){return db[_0xe89b('0xb2')][_0xe89b('0x2e')]({'where':{'VoiceQueueId':_0x28b432['id'],'UserId':_0x590de['id']},'transaction':_0x225567});});return Promise['all'](_0x20d7ff);})[_0xe89b('0x1a')](function(){return db[_0xe89b('0x11e')][_0xe89b('0x4c')]({'where':{'teamId':{'$in':_0x389d23}}});})[_0xe89b('0x1a')](function(_0x51551a){var _0x243fba=_[_0xe89b('0x3e')](_0x51551a,function(_0xd58996){return db[_0xe89b('0x11f')][_0xe89b('0x2e')]({'where':{'UserId':_0x590de['id'],'VoicePrefixId':_0xd58996['VoicePrefixId']}},{'transaction':_0x225567});});return Promise['all'](_0x243fba);});});})[_0xe89b('0x1a')](function(){for(var _0x3e1b35=0x0;_0x3e1b35<_0x5b6de6[_0xe89b('0x4e')];_0x3e1b35++){var _0x538a7c=_0x5b6de6[_0x3e1b35]['getDataValue'](_0xe89b('0xa0'));var _0x53e5d8=_0x538a7c+_0xe89b('0xa9');socket[_0xe89b('0xaa')]('user'+_0x538a7c+_0xe89b('0xb5'),{'UserId':_0x1463ef,['queueField']:_0x5b6de6[_0x3e1b35]['id']});}})['then'](respondWithStatusCode(_0x58d1de,null))['catch'](APIHandleError(_0x58d1de));};exports[_0xe89b('0x125')]=function(_0x29946c,_0x218444){var _0x3d320d={};var _0x3a019b={};var _0x4d17e3;var _0x19f42e;return db[_0xe89b('0x46')]['findOne']({'where':{'id':_0x29946c[_0xe89b('0x57')]['id']}})[_0xe89b('0x1a')](handleEntityNotFound(_0x218444,null))[_0xe89b('0x1a')](function(_0x42969d){if(_0x42969d){_0x4d17e3=_0x42969d;_0x3a019b[_0xe89b('0x58')]=_[_0xe89b('0x5a')](db[_0xe89b('0xd3')][_0xe89b('0x3d')]);_0x3a019b[_0xe89b('0x47')]=_['keys'](_0x29946c[_0xe89b('0x47')]);_0x3a019b[_0xe89b('0x5b')]=_['intersection'](_0x3a019b['model'],_0x3a019b[_0xe89b('0x47')]);_0x3d320d[_0xe89b('0x4b')]=_[_0xe89b('0x5c')](_0x3a019b[_0xe89b('0x58')],qs[_0xe89b('0x5d')](_0x29946c[_0xe89b('0x47')][_0xe89b('0x5d')]));_0x3d320d[_0xe89b('0x4b')]=_0x3d320d['attributes'][_0xe89b('0x4e')]?_0x3d320d['attributes']:_0x3a019b[_0xe89b('0x58')];_0x3d320d[_0xe89b('0xd9')]=qs[_0xe89b('0xcf')](_0x29946c[_0xe89b('0x47')]['sort']);_0x3d320d[_0xe89b('0x45')]=qs['filters'](_[_0xe89b('0xd0')](_0x29946c['query'],_0x3a019b[_0xe89b('0x5b')]));if(_0x29946c[_0xe89b('0x47')][_0xe89b('0x40')]){_0x3d320d['where']=_['merge'](_0x3d320d[_0xe89b('0x45')],{'$or':_[_0xe89b('0x3e')](_0x3d320d[_0xe89b('0x4b')],function(_0x45bcea){var _0x542504={};_0x542504[_0x45bcea]={'$like':'%'+_0x29946c[_0xe89b('0x47')]['filter']+'%'};return _0x542504;})});}_0x3d320d=_[_0xe89b('0x60')]({},_0x3d320d,_0x29946c[_0xe89b('0x61')]);return _0x4d17e3[_0xe89b('0x125')](_0x3d320d);}})[_0xe89b('0x1a')](function(_0x474b9a){if(_0x474b9a){_0x19f42e=_0x474b9a['length'];if(!_0x29946c[_0xe89b('0x47')][_0xe89b('0xd2')](_0xe89b('0xd8'))){_0x3d320d[_0xe89b('0x27')]=qs[_0xe89b('0x27')](_0x29946c[_0xe89b('0x47')][_0xe89b('0x27')]);_0x3d320d[_0xe89b('0x25')]=qs[_0xe89b('0x25')](_0x29946c[_0xe89b('0x47')][_0xe89b('0x25')]);}return _0x4d17e3['getLists'](_0x3d320d);}})[_0xe89b('0x1a')](function(_0x3e43f5){if(_0x3e43f5){return _0x3e43f5?{'count':_0x19f42e,'rows':_0x3e43f5}:null;}})[_0xe89b('0x1a')](respondWithResult(_0x218444,null))[_0xe89b('0x65')](handleError(_0x218444,null));};exports[_0xe89b('0x126')]=function(_0x5133ed,_0x57f4bb){var _0x961cc8={};var _0x517f34={};var _0x38d19f;return db[_0xe89b('0x46')][_0xe89b('0xcd')]({'where':{'id':_0x5133ed['params']['id']}})[_0xe89b('0x1a')](handleEntityNotFound(_0x57f4bb,null))[_0xe89b('0x1a')](function(_0x398e78){if(_0x398e78){_0x38d19f=_0x398e78;_0x517f34[_0xe89b('0x58')]=_[_0xe89b('0x5a')](db[_0xe89b('0x46')][_0xe89b('0x3d')]);_0x517f34[_0xe89b('0x47')]=_[_0xe89b('0x5a')](_0x5133ed['query']);_0x517f34[_0xe89b('0x5b')]=_['intersection'](_0x517f34[_0xe89b('0x58')],_0x517f34[_0xe89b('0x47')]);_0x961cc8[_0xe89b('0x4b')]=_['intersection'](_0x517f34[_0xe89b('0x58')],qs[_0xe89b('0x5d')](_0x5133ed[_0xe89b('0x47')][_0xe89b('0x5d')]));_0x961cc8[_0xe89b('0x4b')]=_0x961cc8[_0xe89b('0x4b')][_0xe89b('0x4e')]?_0x961cc8['attributes']:_0x517f34[_0xe89b('0x58')];_0x961cc8[_0xe89b('0xd9')]=qs['sort'](_0x5133ed[_0xe89b('0x47')]['sort']);_0x961cc8[_0xe89b('0x45')]=qs[_0xe89b('0x5b')](_[_0xe89b('0xd0')](_0x5133ed[_0xe89b('0x47')],_0x517f34['filters']));if(_0x5133ed[_0xe89b('0x47')][_0xe89b('0x40')]){_0x961cc8[_0xe89b('0x45')]=_[_0xe89b('0x60')](_0x961cc8['where'],{'$or':_[_0xe89b('0x3e')](_0x961cc8[_0xe89b('0x4b')],function(_0x239d15){var _0x1b6923={};_0x1b6923[_0x239d15]={'$like':'%'+_0x5133ed[_0xe89b('0x47')]['filter']+'%'};return _0x1b6923;})});}_0x961cc8[_0xe89b('0x58')]=db[_0xe89b('0x46')];_0x961cc8['as']=_0xe89b('0x32');_0x961cc8=_[_0xe89b('0x60')]({},_0x961cc8,_0x5133ed[_0xe89b('0x61')]);return _0x38d19f[_0xe89b('0xfa')]({'include':[_0x961cc8]});}})['then'](function(_0x3281d7){if(_0x3281d7){var _0x161db7={},_0x828568=[];for(var _0x581415=0x0;_0x581415<_0x3281d7['length'];_0x581415+=0x1){for(var _0x3c8a39=0x0,_0x2b7b21;_0x3c8a39<_0x3281d7[_0x581415]['Agents']['length'];_0x3c8a39+=0x1){_0x2b7b21=_0x3281d7[_0x581415][_0xe89b('0x32')][_0x3c8a39]['get']({'plain':!![]});_0x161db7[_0x2b7b21['id']]=_0x2b7b21;}}_0x161db7=_[_0xe89b('0x127')](_0x161db7);for(var _0x374a56=qs[_0xe89b('0x25')](_0x5133ed[_0xe89b('0x47')][_0xe89b('0x25')]);_0x374a56<_0x161db7['length']&&_0x828568[_0xe89b('0x4e')]<qs[_0xe89b('0x27')](_0x5133ed['query'][_0xe89b('0x27')]);_0x374a56+=0x1){if(_0x161db7[_0x374a56]){_0x828568[_0xe89b('0x4f')](_0x161db7[_0x374a56]);}}return{'count':_0x161db7[_0xe89b('0x4e')],'rows':_0x828568};}})[_0xe89b('0x1a')](respondWithResult(_0x57f4bb,null))[_0xe89b('0x65')](handleError(_0x57f4bb,null));};exports['destroy']=function(_0x447ebc,_0x392dfa){if(_0x447ebc[_0xe89b('0x31')]['id']==_0x447ebc[_0xe89b('0x57')]['id']){return _0x392dfa['status'](0x1f4)[_0xe89b('0x3b')]({'message':'You\x20can\x27t\x20delete\x20yourself'});}return db[_0xe89b('0x46')][_0xe89b('0x62')]({'where':{'id':_0x447ebc[_0xe89b('0x57')]['id']}})[_0xe89b('0x1a')](handleEntityNotFound(_0x392dfa,null))[_0xe89b('0x1a')](removeEntity(_0x392dfa,null))[_0xe89b('0x65')](handleError(_0x392dfa,null));};exports[_0xe89b('0x128')]=function(_0xe9dcc6,_0x181ab7){return db[_0xe89b('0x46')]['find']({'where':{'id':_0xe9dcc6[_0xe89b('0x57')]['id']}})['then'](handleEntityNotFound(_0x181ab7,null))[_0xe89b('0x1a')](function(_0x2566e2){if(_0x2566e2){return _0x2566e2[_0xe89b('0x128')](_0xe9dcc6[_0xe89b('0x66')][_0xe89b('0x69')],_[_0xe89b('0x6a')](_0xe9dcc6['body'],['ids','id'])||{})[_0xe89b('0xa8')](function(){for(var _0x18b14d=0x0;_0x18b14d<_0xe9dcc6['body'][_0xe89b('0x69')][_0xe89b('0x4e')];_0x18b14d+=0x1){socket[_0xe89b('0xaa')](_0xe89b('0x129'),{'ChatInteractionId':Number(_0xe9dcc6['body']['ids'][_0x18b14d]),'UserId':Number(_0xe9dcc6[_0xe89b('0x57')]['id'])});}return _0xe9dcc6['body'][_0xe89b('0x69')];});}})[_0xe89b('0x1a')](respondWithResult(_0x181ab7,null))[_0xe89b('0x65')](handleError(_0x181ab7,null));};exports[_0xe89b('0x12a')]=function(_0x3904e5,_0x42f6e7){return db[_0xe89b('0x46')]['find']({'where':{'id':_0x3904e5[_0xe89b('0x57')]['id']}})[_0xe89b('0x1a')](handleEntityNotFound(_0x42f6e7,null))[_0xe89b('0x1a')](function(_0x52a853){if(_0x52a853){return _0x52a853['removeChatInteractions'](_0x3904e5['query']['ids'])[_0xe89b('0x1a')](function(){if(_[_0xe89b('0x121')](_0x3904e5[_0xe89b('0x47')][_0xe89b('0x69')])){for(var _0x4e917c=0x0;_0x4e917c<_0x3904e5['query'][_0xe89b('0x69')][_0xe89b('0x4e')];_0x4e917c+=0x1){socket['emit']('user_has_chat_interactions:remove',{'ChatInteractionId':Number(_0x3904e5['query']['ids'][_0x4e917c]),'UserId':Number(_0x3904e5[_0xe89b('0x57')]['id'])});}}else{socket[_0xe89b('0xaa')](_0xe89b('0x12b'),{'ChatInteractionId':Number(_0x3904e5[_0xe89b('0x47')][_0xe89b('0x69')]),'UserId':Number(_0x3904e5[_0xe89b('0x57')]['id'])});}});}})[_0xe89b('0x1a')](respondWithStatusCode(_0x42f6e7,null))[_0xe89b('0x65')](handleError(_0x42f6e7,null));};exports['addMailInteractions']=function(_0x2525aa,_0xc9942a){return db[_0xe89b('0x46')][_0xe89b('0x62')]({'where':{'id':_0x2525aa[_0xe89b('0x57')]['id']}})['then'](handleEntityNotFound(_0xc9942a,null))[_0xe89b('0x1a')](function(_0x309857){if(_0x309857){return _0x309857[_0xe89b('0x12c')](_0x2525aa[_0xe89b('0x66')][_0xe89b('0x69')],_[_0xe89b('0x6a')](_0x2525aa[_0xe89b('0x66')],['ids','id'])||{})[_0xe89b('0xa8')](function(){for(var _0x46953b=0x0;_0x46953b<_0x2525aa[_0xe89b('0x66')][_0xe89b('0x69')]['length'];_0x46953b+=0x1){socket[_0xe89b('0xaa')](_0xe89b('0x12d'),{'MailInteractionId':Number(_0x2525aa[_0xe89b('0x66')][_0xe89b('0x69')][_0x46953b]),'UserId':Number(_0x2525aa[_0xe89b('0x57')]['id'])});}return _0x2525aa[_0xe89b('0x66')][_0xe89b('0x69')];});}})['then'](respondWithResult(_0xc9942a,null))[_0xe89b('0x65')](handleError(_0xc9942a,null));};exports[_0xe89b('0x12e')]=function(_0x1525d2,_0x23f8fc){return db['User'][_0xe89b('0x62')]({'where':{'id':_0x1525d2[_0xe89b('0x57')]['id']}})['then'](handleEntityNotFound(_0x23f8fc,null))[_0xe89b('0x1a')](function(_0x381c26){if(_0x381c26){return _0x381c26[_0xe89b('0x12e')](_0x1525d2[_0xe89b('0x47')][_0xe89b('0x69')])[_0xe89b('0x1a')](function(){if(_[_0xe89b('0x121')](_0x1525d2[_0xe89b('0x47')][_0xe89b('0x69')])){for(var _0x427bca=0x0;_0x427bca<_0x1525d2[_0xe89b('0x47')]['ids'][_0xe89b('0x4e')];_0x427bca+=0x1){socket['emit'](_0xe89b('0x12f'),{'MailInteractionId':Number(_0x1525d2['query']['ids'][_0x427bca]),'UserId':Number(_0x1525d2[_0xe89b('0x57')]['id'])});}}else{socket[_0xe89b('0xaa')]('user_has_mail_interactions:remove',{'MailInteractionId':Number(_0x1525d2[_0xe89b('0x47')][_0xe89b('0x69')]),'UserId':Number(_0x1525d2['params']['id'])});}});}})[_0xe89b('0x1a')](respondWithStatusCode(_0x23f8fc,null))['catch'](handleError(_0x23f8fc,null));};exports[_0xe89b('0x130')]=function(_0x9fe87e,_0x3303dc){return db[_0xe89b('0x46')]['find']({'where':{'id':_0x9fe87e['params']['id']}})[_0xe89b('0x1a')](handleEntityNotFound(_0x3303dc,null))[_0xe89b('0x1a')](function(_0x1b6bb5){if(_0x1b6bb5){return _0x1b6bb5[_0xe89b('0x130')](_0x9fe87e[_0xe89b('0x66')][_0xe89b('0x69')],_['omit'](_0x9fe87e['body'],[_0xe89b('0x69'),'id'])||{})['spread'](function(){for(var _0x3a1939=0x0;_0x3a1939<_0x9fe87e['body'][_0xe89b('0x69')]['length'];_0x3a1939+=0x1){socket[_0xe89b('0xaa')]('user_has_fax_interactions:save',{'FaxInteractionId':Number(_0x9fe87e['body'][_0xe89b('0x69')][_0x3a1939]),'UserId':Number(_0x9fe87e['params']['id'])});}return _0x9fe87e[_0xe89b('0x66')][_0xe89b('0x69')];});}})[_0xe89b('0x1a')](respondWithResult(_0x3303dc,null))[_0xe89b('0x65')](handleError(_0x3303dc,null));};exports['removeFaxInteractions']=function(_0x388d3b,_0x307892){return db[_0xe89b('0x46')][_0xe89b('0x62')]({'where':{'id':_0x388d3b[_0xe89b('0x57')]['id']}})[_0xe89b('0x1a')](handleEntityNotFound(_0x307892,null))[_0xe89b('0x1a')](function(_0x2513a1){if(_0x2513a1){return _0x2513a1[_0xe89b('0x131')](_0x388d3b[_0xe89b('0x47')][_0xe89b('0x69')])['then'](function(){if(_[_0xe89b('0x121')](_0x388d3b[_0xe89b('0x47')][_0xe89b('0x69')])){for(var _0xee1978=0x0;_0xee1978<_0x388d3b['query'][_0xe89b('0x69')][_0xe89b('0x4e')];_0xee1978+=0x1){socket[_0xe89b('0xaa')](_0xe89b('0x132'),{'FaxInteractionId':Number(_0x388d3b[_0xe89b('0x47')]['ids'][_0xee1978]),'UserId':Number(_0x388d3b[_0xe89b('0x57')]['id'])});}}else{socket[_0xe89b('0xaa')]('user_has_fax_interactions:remove',{'FaxInteractionId':Number(_0x388d3b[_0xe89b('0x47')]['ids']),'UserId':Number(_0x388d3b[_0xe89b('0x57')]['id'])});}});}})[_0xe89b('0x1a')](respondWithStatusCode(_0x307892,null))['catch'](handleError(_0x307892,null));};exports['addSmsInteractions']=function(_0x239b45,_0x10de9f){return db['User'][_0xe89b('0x62')]({'where':{'id':_0x239b45[_0xe89b('0x57')]['id']}})[_0xe89b('0x1a')](handleEntityNotFound(_0x10de9f,null))[_0xe89b('0x1a')](function(_0x4c9ae3){if(_0x4c9ae3){return _0x4c9ae3['addSmsInteractions'](_0x239b45['body']['ids'],_['omit'](_0x239b45[_0xe89b('0x66')],[_0xe89b('0x69'),'id'])||{})[_0xe89b('0xa8')](function(){for(var _0x44e241=0x0;_0x44e241<_0x239b45[_0xe89b('0x66')]['ids'][_0xe89b('0x4e')];_0x44e241+=0x1){socket[_0xe89b('0xaa')](_0xe89b('0x133'),{'SmsInteractionId':Number(_0x239b45[_0xe89b('0x66')][_0xe89b('0x69')][_0x44e241]),'UserId':Number(_0x239b45[_0xe89b('0x57')]['id'])});}return _0x239b45[_0xe89b('0x66')][_0xe89b('0x69')];});}})[_0xe89b('0x1a')](respondWithResult(_0x10de9f,null))[_0xe89b('0x65')](handleError(_0x10de9f,null));};exports[_0xe89b('0x134')]=function(_0x351b73,_0x4dbba4){return db[_0xe89b('0x46')]['find']({'where':{'id':_0x351b73[_0xe89b('0x57')]['id']}})[_0xe89b('0x1a')](handleEntityNotFound(_0x4dbba4,null))[_0xe89b('0x1a')](function(_0x4eaf13){if(_0x4eaf13){return _0x4eaf13['removeSmsInteractions'](_0x351b73[_0xe89b('0x47')][_0xe89b('0x69')])[_0xe89b('0x1a')](function(){if(_[_0xe89b('0x121')](_0x351b73[_0xe89b('0x47')][_0xe89b('0x69')])){for(var _0x242674=0x0;_0x242674<_0x351b73[_0xe89b('0x47')][_0xe89b('0x69')]['length'];_0x242674+=0x1){socket[_0xe89b('0xaa')](_0xe89b('0x135'),{'SmsInteractionId':Number(_0x351b73[_0xe89b('0x47')][_0xe89b('0x69')][_0x242674]),'UserId':Number(_0x351b73[_0xe89b('0x57')]['id'])});}}else{socket[_0xe89b('0xaa')](_0xe89b('0x135'),{'SmsInteractionId':Number(_0x351b73['query'][_0xe89b('0x69')]),'UserId':Number(_0x351b73[_0xe89b('0x57')]['id'])});}});}})[_0xe89b('0x1a')](respondWithStatusCode(_0x4dbba4,null))[_0xe89b('0x65')](handleError(_0x4dbba4,null));};exports[_0xe89b('0x136')]=function(_0x4f707f,_0x50a5b8){return db[_0xe89b('0x46')]['find']({'where':{'id':_0x4f707f[_0xe89b('0x57')]['id']}})['then'](handleEntityNotFound(_0x50a5b8,null))[_0xe89b('0x1a')](function(_0x417637){if(_0x417637){return _0x417637[_0xe89b('0x136')](_0x4f707f['body'][_0xe89b('0x69')],_[_0xe89b('0x6a')](_0x4f707f[_0xe89b('0x66')],[_0xe89b('0x69'),'id'])||{})[_0xe89b('0xa8')](function(){for(var _0x46f8f7=0x0;_0x46f8f7<_0x4f707f[_0xe89b('0x66')][_0xe89b('0x69')][_0xe89b('0x4e')];_0x46f8f7+=0x1){socket[_0xe89b('0xaa')](_0xe89b('0x137'),{'OpenchannelInteractionId':Number(_0x4f707f[_0xe89b('0x66')][_0xe89b('0x69')][_0x46f8f7]),'UserId':Number(_0x4f707f[_0xe89b('0x57')]['id'])});}return _0x4f707f[_0xe89b('0x66')]['ids'];});}})['then'](respondWithResult(_0x50a5b8,null))[_0xe89b('0x65')](handleError(_0x50a5b8,null));};exports[_0xe89b('0x138')]=function(_0xc95a62,_0x236bf7){return db[_0xe89b('0x46')][_0xe89b('0x62')]({'where':{'id':_0xc95a62[_0xe89b('0x57')]['id']}})[_0xe89b('0x1a')](handleEntityNotFound(_0x236bf7,null))[_0xe89b('0x1a')](function(_0x40c86d){if(_0x40c86d){return _0x40c86d['removeOpenchannelInteractions'](_0xc95a62[_0xe89b('0x47')][_0xe89b('0x69')])[_0xe89b('0x1a')](function(){if(_[_0xe89b('0x121')](_0xc95a62[_0xe89b('0x47')][_0xe89b('0x69')])){for(var _0x139dbb=0x0;_0x139dbb<_0xc95a62[_0xe89b('0x47')][_0xe89b('0x69')][_0xe89b('0x4e')];_0x139dbb+=0x1){socket[_0xe89b('0xaa')]('user_has_openchannel_interactions:remove',{'OpenchannelInteractionId':Number(_0xc95a62[_0xe89b('0x47')][_0xe89b('0x69')][_0x139dbb]),'UserId':Number(_0xc95a62['params']['id'])});}}else{socket['emit'](_0xe89b('0x139'),{'OpenchannelInteractionId':Number(_0xc95a62[_0xe89b('0x47')]['ids']),'UserId':Number(_0xc95a62['params']['id'])});}});}})['then'](respondWithStatusCode(_0x236bf7,null))[_0xe89b('0x65')](handleError(_0x236bf7,null));};exports[_0xe89b('0x13a')]=function(_0x493bfa,_0x188501){return db['User'][_0xe89b('0x62')]({'where':{'id':_0x493bfa[_0xe89b('0x57')]['id']}})[_0xe89b('0x1a')](handleEntityNotFound(_0x188501,null))[_0xe89b('0x1a')](function(_0x3faa15){if(_0x3faa15){return _0x3faa15['addWhatsappInteractions'](_0x493bfa[_0xe89b('0x66')][_0xe89b('0x69')],_[_0xe89b('0x6a')](_0x493bfa[_0xe89b('0x66')],['ids','id'])||{})[_0xe89b('0xa8')](function(){for(var _0x2181fb=0x0;_0x2181fb<_0x493bfa[_0xe89b('0x66')][_0xe89b('0x69')][_0xe89b('0x4e')];_0x2181fb+=0x1){socket['emit'](_0xe89b('0x13b'),{'WhatsappInteractionId':Number(_0x493bfa[_0xe89b('0x66')][_0xe89b('0x69')][_0x2181fb]),'UserId':Number(_0x493bfa[_0xe89b('0x57')]['id'])});}return _0x493bfa['body'][_0xe89b('0x69')];});}})[_0xe89b('0x1a')](respondWithResult(_0x188501,null))['catch'](handleError(_0x188501,null));};exports[_0xe89b('0x13c')]=function(_0xbec60a,_0x59d14a){return db[_0xe89b('0x46')][_0xe89b('0x62')]({'where':{'id':_0xbec60a[_0xe89b('0x57')]['id']}})[_0xe89b('0x1a')](handleEntityNotFound(_0x59d14a,null))[_0xe89b('0x1a')](function(_0x53f95a){if(_0x53f95a){return _0x53f95a['removeWhatsappInteractions'](_0xbec60a[_0xe89b('0x47')]['ids']);}})['then'](respondWithStatusCode(_0x59d14a,null))[_0xe89b('0x65')](handleError(_0x59d14a,null));};exports['getVoicePrefixes']=function(_0x5693b6,_0x5b60ed){var _0x1c03d8={};var _0x40954f={};var _0x32e898;var _0x15c309;return db[_0xe89b('0x46')]['findOne']({'where':{'id':_0x5693b6['params']['id']}})[_0xe89b('0x1a')](handleEntityNotFound(_0x5b60ed,null))[_0xe89b('0x1a')](function(_0xcd8ae9){if(_0xcd8ae9){_0x32e898=_0xcd8ae9;_0x40954f[_0xe89b('0x58')]=_[_0xe89b('0x5a')](db['VoicePrefix'][_0xe89b('0x3d')]);_0x40954f[_0xe89b('0x47')]=_['keys'](_0x5693b6[_0xe89b('0x47')]);_0x40954f[_0xe89b('0x5b')]=_[_0xe89b('0x5c')](_0x40954f[_0xe89b('0x58')],_0x40954f[_0xe89b('0x47')]);_0x1c03d8[_0xe89b('0x4b')]=_[_0xe89b('0x5c')](_0x40954f[_0xe89b('0x58')],qs[_0xe89b('0x5d')](_0x5693b6[_0xe89b('0x47')]['fields']));_0x1c03d8[_0xe89b('0x4b')]=_0x1c03d8[_0xe89b('0x4b')][_0xe89b('0x4e')]?_0x1c03d8['attributes']:_0x40954f[_0xe89b('0x58')];_0x1c03d8[_0xe89b('0xd9')]=qs[_0xe89b('0xcf')](_0x5693b6[_0xe89b('0x47')][_0xe89b('0xcf')]);_0x1c03d8[_0xe89b('0x45')]=qs[_0xe89b('0x5b')](_[_0xe89b('0xd0')](_0x5693b6['query'],_0x40954f[_0xe89b('0x5b')]));if(_0x5693b6[_0xe89b('0x47')][_0xe89b('0x40')]){_0x1c03d8[_0xe89b('0x45')]=_[_0xe89b('0x60')](_0x1c03d8[_0xe89b('0x45')],{'$or':_[_0xe89b('0x3e')](_0x1c03d8[_0xe89b('0x4b')],function(_0x2ac1ec){var _0x209aaa={};_0x209aaa[_0x2ac1ec]={'$like':'%'+_0x5693b6[_0xe89b('0x47')][_0xe89b('0x40')]+'%'};return _0x209aaa;})});}_0x1c03d8=_[_0xe89b('0x60')]({},_0x1c03d8,_0x5693b6['options']);return _0x32e898['getVoicePrefixes'](_0x1c03d8);}})[_0xe89b('0x1a')](function(_0x27538e){if(_0x27538e){_0x15c309=_0x27538e[_0xe89b('0x4e')];if(!_0x5693b6[_0xe89b('0x47')]['hasOwnProperty'](_0xe89b('0xd8'))){_0x1c03d8[_0xe89b('0x27')]=qs[_0xe89b('0x27')](_0x5693b6[_0xe89b('0x47')][_0xe89b('0x27')]);_0x1c03d8[_0xe89b('0x25')]=qs[_0xe89b('0x25')](_0x5693b6['query'][_0xe89b('0x25')]);}return _0x32e898[_0xe89b('0x13d')](_0x1c03d8);}})[_0xe89b('0x1a')](function(_0x669c4){if(_0x669c4){return _0x669c4?{'count':_0x15c309,'rows':_0x669c4}:null;}})['then'](respondWithResult(_0x5b60ed,null))['catch'](handleError(_0x5b60ed,null));};exports[_0xe89b('0x13e')]=function(_0x117d6e,_0x4344d1){var _0x3355ee={};var _0x2b1033={};var _0x59727a;var _0x1b2acc;return db[_0xe89b('0x46')]['findOne']({'where':{'id':_0x117d6e[_0xe89b('0x57')]['id']}})['then'](handleEntityNotFound(_0x4344d1,null))[_0xe89b('0x1a')](function(_0x209de1){if(_0x209de1){_0x59727a=_0x209de1;_0x2b1033['model']=_['keys'](db['FaxAccount'][_0xe89b('0x3d')]);_0x2b1033[_0xe89b('0x47')]=_[_0xe89b('0x5a')](_0x117d6e[_0xe89b('0x47')]);_0x2b1033[_0xe89b('0x5b')]=_['intersection'](_0x2b1033['model'],_0x2b1033[_0xe89b('0x47')]);_0x3355ee[_0xe89b('0x4b')]=_['intersection'](_0x2b1033[_0xe89b('0x58')],qs['fields'](_0x117d6e['query'][_0xe89b('0x5d')]));_0x3355ee['attributes']=_0x3355ee[_0xe89b('0x4b')][_0xe89b('0x4e')]?_0x3355ee['attributes']:_0x2b1033[_0xe89b('0x58')];_0x3355ee[_0xe89b('0xd9')]=qs['sort'](_0x117d6e[_0xe89b('0x47')]['sort']);_0x3355ee[_0xe89b('0x45')]=qs[_0xe89b('0x5b')](_['pick'](_0x117d6e['query'],_0x2b1033[_0xe89b('0x5b')]));if(_0x117d6e[_0xe89b('0x47')][_0xe89b('0x40')]){_0x3355ee[_0xe89b('0x45')]=_['merge'](_0x3355ee['where'],{'$or':_[_0xe89b('0x3e')](_0x3355ee[_0xe89b('0x4b')],function(_0x2172f1){var _0x2db47={};_0x2db47[_0x2172f1]={'$like':'%'+_0x117d6e[_0xe89b('0x47')][_0xe89b('0x40')]+'%'};return _0x2db47;})});}_0x3355ee=_[_0xe89b('0x60')]({},_0x3355ee,_0x117d6e[_0xe89b('0x61')]);return _0x59727a[_0xe89b('0x13e')](_0x3355ee);}})[_0xe89b('0x1a')](function(_0x4e09c9){if(_0x4e09c9){_0x1b2acc=_0x4e09c9[_0xe89b('0x4e')];if(!_0x117d6e[_0xe89b('0x47')][_0xe89b('0xd2')]('nolimit')){_0x3355ee[_0xe89b('0x27')]=qs[_0xe89b('0x27')](_0x117d6e['query'][_0xe89b('0x27')]);_0x3355ee['offset']=qs[_0xe89b('0x25')](_0x117d6e['query']['offset']);}return _0x59727a['getFaxAccounts'](_0x3355ee);}})[_0xe89b('0x1a')](function(_0x404595){if(_0x404595){return _0x404595?{'count':_0x1b2acc,'rows':_0x404595}:null;}})[_0xe89b('0x1a')](respondWithResult(_0x4344d1,null))[_0xe89b('0x65')](handleError(_0x4344d1,null));};exports[_0xe89b('0x13f')]=function(_0x59eaac,_0x15de44){return db['User']['find']({'where':{'id':_0x59eaac[_0xe89b('0x57')]['id']}})[_0xe89b('0x1a')](handleEntityNotFound(_0x15de44,null))[_0xe89b('0x1a')](function(_0x5aa1cf){if(_0x5aa1cf){return _0x5aa1cf[_0xe89b('0x13f')](_0x59eaac[_0xe89b('0x66')]['ids'],_[_0xe89b('0x6a')](_0x59eaac['body'],['ids','id'])||{});}})[_0xe89b('0x1a')](respondWithResult(_0x15de44,null))[_0xe89b('0x65')](handleError(_0x15de44,null));};exports[_0xe89b('0x140')]=function(_0x253bb0,_0x7a9122){return db['User']['find']({'where':{'id':_0x253bb0[_0xe89b('0x57')]['id']}})[_0xe89b('0x1a')](handleEntityNotFound(_0x7a9122,null))[_0xe89b('0x1a')](function(_0x117f05){if(_0x117f05){return _0x117f05[_0xe89b('0x140')](_0x253bb0[_0xe89b('0x47')]['ids']);}})[_0xe89b('0x1a')](respondWithStatusCode(_0x7a9122,null))[_0xe89b('0x65')](handleError(_0x7a9122,null));};exports[_0xe89b('0x141')]=function(_0x25195e,_0x42bc7f){var _0x3333de={};var _0x59167e={};var _0x14dd22;var _0x4cb20c;return db[_0xe89b('0x46')][_0xe89b('0xcd')]({'where':{'id':_0x25195e[_0xe89b('0x57')]['id']}})[_0xe89b('0x1a')](handleEntityNotFound(_0x42bc7f,null))[_0xe89b('0x1a')](function(_0x5c9347){if(_0x5c9347){_0x14dd22=_0x5c9347;_0x59167e[_0xe89b('0x58')]=_[_0xe89b('0x5a')](db['MailAccount'][_0xe89b('0x3d')]);_0x59167e['query']=_[_0xe89b('0x5a')](_0x25195e[_0xe89b('0x47')]);_0x59167e[_0xe89b('0x5b')]=_[_0xe89b('0x5c')](_0x59167e[_0xe89b('0x58')],_0x59167e[_0xe89b('0x47')]);_0x3333de['attributes']=_[_0xe89b('0x5c')](_0x59167e['model'],qs['fields'](_0x25195e[_0xe89b('0x47')][_0xe89b('0x5d')]));_0x3333de[_0xe89b('0x4b')]=_0x3333de[_0xe89b('0x4b')]['length']?_0x3333de[_0xe89b('0x4b')]:_0x59167e['model'];_0x3333de[_0xe89b('0xd9')]=qs[_0xe89b('0xcf')](_0x25195e[_0xe89b('0x47')][_0xe89b('0xcf')]);_0x3333de[_0xe89b('0x45')]=qs['filters'](_[_0xe89b('0xd0')](_0x25195e['query'],_0x59167e[_0xe89b('0x5b')]));if(_0x25195e[_0xe89b('0x47')]['filter']){_0x3333de['where']=_[_0xe89b('0x60')](_0x3333de[_0xe89b('0x45')],{'$or':_[_0xe89b('0x3e')](_0x3333de[_0xe89b('0x4b')],function(_0x2e49f8){var _0x2d05ea={};_0x2d05ea[_0x2e49f8]={'$like':'%'+_0x25195e[_0xe89b('0x47')]['filter']+'%'};return _0x2d05ea;})});}_0x3333de=_[_0xe89b('0x60')]({},_0x3333de,_0x25195e[_0xe89b('0x61')]);return _0x14dd22[_0xe89b('0x141')](_0x3333de);}})[_0xe89b('0x1a')](function(_0x4c2e05){if(_0x4c2e05){_0x4cb20c=_0x4c2e05[_0xe89b('0x4e')];if(!_0x25195e[_0xe89b('0x47')][_0xe89b('0xd2')]('nolimit')){_0x3333de[_0xe89b('0x27')]=qs[_0xe89b('0x27')](_0x25195e[_0xe89b('0x47')][_0xe89b('0x27')]);_0x3333de[_0xe89b('0x25')]=qs[_0xe89b('0x25')](_0x25195e[_0xe89b('0x47')][_0xe89b('0x25')]);}return _0x14dd22['getMailAccounts'](_0x3333de);}})[_0xe89b('0x1a')](function(_0x292dcc){if(_0x292dcc){return _0x292dcc?{'count':_0x4cb20c,'rows':_0x292dcc}:null;}})[_0xe89b('0x1a')](respondWithResult(_0x42bc7f,null))[_0xe89b('0x65')](handleError(_0x42bc7f,null));};exports[_0xe89b('0x142')]=function(_0x53cb7a,_0x45cb95){return db['User']['find']({'where':{'id':_0x53cb7a[_0xe89b('0x57')]['id']}})[_0xe89b('0x1a')](handleEntityNotFound(_0x45cb95,null))[_0xe89b('0x1a')](function(_0x4aa44f){if(_0x4aa44f){return _0x4aa44f['addMailAccounts'](_0x53cb7a[_0xe89b('0x66')][_0xe89b('0x69')],_['omit'](_0x53cb7a[_0xe89b('0x66')],[_0xe89b('0x69'),'id'])||{});}})[_0xe89b('0x1a')](respondWithResult(_0x45cb95,null))[_0xe89b('0x65')](handleError(_0x45cb95,null));};exports['removeMailAccounts']=function(_0x2e135b,_0x3af04b){return db[_0xe89b('0x46')]['find']({'where':{'id':_0x2e135b[_0xe89b('0x57')]['id']}})[_0xe89b('0x1a')](handleEntityNotFound(_0x3af04b,null))[_0xe89b('0x1a')](function(_0x36c4e2){if(_0x36c4e2){return _0x36c4e2[_0xe89b('0x143')](_0x2e135b[_0xe89b('0x47')][_0xe89b('0x69')]);}})[_0xe89b('0x1a')](respondWithStatusCode(_0x3af04b,null))[_0xe89b('0x65')](handleError(_0x3af04b,null));};exports[_0xe89b('0x144')]=function(_0x574a1a,_0x57b84d){var _0x998847={};var _0x99eeaf={};var _0x50be65;var _0x89d91a;return db['User'][_0xe89b('0xcd')]({'where':{'id':_0x574a1a[_0xe89b('0x57')]['id']}})['then'](handleEntityNotFound(_0x57b84d,null))[_0xe89b('0x1a')](function(_0xb44431){if(_0xb44431){_0x50be65=_0xb44431;_0x99eeaf['model']=_[_0xe89b('0x5a')](db['OpenchannelAccount'][_0xe89b('0x3d')]);_0x99eeaf['query']=_[_0xe89b('0x5a')](_0x574a1a['query']);_0x99eeaf[_0xe89b('0x5b')]=_[_0xe89b('0x5c')](_0x99eeaf[_0xe89b('0x58')],_0x99eeaf[_0xe89b('0x47')]);_0x998847[_0xe89b('0x4b')]=_[_0xe89b('0x5c')](_0x99eeaf[_0xe89b('0x58')],qs[_0xe89b('0x5d')](_0x574a1a['query']['fields']));_0x998847[_0xe89b('0x4b')]=_0x998847['attributes']['length']?_0x998847[_0xe89b('0x4b')]:_0x99eeaf[_0xe89b('0x58')];_0x998847[_0xe89b('0xd9')]=qs[_0xe89b('0xcf')](_0x574a1a['query']['sort']);_0x998847['where']=qs['filters'](_[_0xe89b('0xd0')](_0x574a1a[_0xe89b('0x47')],_0x99eeaf[_0xe89b('0x5b')]));if(_0x574a1a['query']['filter']){_0x998847['where']=_[_0xe89b('0x60')](_0x998847['where'],{'$or':_[_0xe89b('0x3e')](_0x998847[_0xe89b('0x4b')],function(_0x2fc776){var _0x2a3b38={};_0x2a3b38[_0x2fc776]={'$like':'%'+_0x574a1a['query'][_0xe89b('0x40')]+'%'};return _0x2a3b38;})});}_0x998847=_[_0xe89b('0x60')]({},_0x998847,_0x574a1a['options']);return _0x50be65[_0xe89b('0x144')](_0x998847);}})[_0xe89b('0x1a')](function(_0x526a95){if(_0x526a95){_0x89d91a=_0x526a95[_0xe89b('0x4e')];if(!_0x574a1a['query'][_0xe89b('0xd2')](_0xe89b('0xd8'))){_0x998847[_0xe89b('0x27')]=qs[_0xe89b('0x27')](_0x574a1a[_0xe89b('0x47')][_0xe89b('0x27')]);_0x998847[_0xe89b('0x25')]=qs['offset'](_0x574a1a[_0xe89b('0x47')][_0xe89b('0x25')]);}return _0x50be65['getOpenchannelAccounts'](_0x998847);}})[_0xe89b('0x1a')](function(_0x1e8dac){if(_0x1e8dac){return _0x1e8dac?{'count':_0x89d91a,'rows':_0x1e8dac}:null;}})[_0xe89b('0x1a')](respondWithResult(_0x57b84d,null))[_0xe89b('0x65')](handleError(_0x57b84d,null));};exports[_0xe89b('0x145')]=function(_0x4a4f41,_0x5782b3){return db[_0xe89b('0x46')][_0xe89b('0x62')]({'where':{'id':_0x4a4f41[_0xe89b('0x57')]['id']}})['then'](handleEntityNotFound(_0x5782b3,null))[_0xe89b('0x1a')](function(_0x1864a5){if(_0x1864a5){return _0x1864a5[_0xe89b('0x145')](_0x4a4f41['body'][_0xe89b('0x69')],_['omit'](_0x4a4f41[_0xe89b('0x66')],[_0xe89b('0x69'),'id'])||{});}})[_0xe89b('0x1a')](respondWithResult(_0x5782b3,null))['catch'](handleError(_0x5782b3,null));};exports['removeOpenchannelAccounts']=function(_0x22f6fc,_0x388905){return db[_0xe89b('0x46')][_0xe89b('0x62')]({'where':{'id':_0x22f6fc[_0xe89b('0x57')]['id']}})[_0xe89b('0x1a')](handleEntityNotFound(_0x388905,null))['then'](function(_0x17fe5c){if(_0x17fe5c){return _0x17fe5c[_0xe89b('0x146')](_0x22f6fc[_0xe89b('0x47')][_0xe89b('0x69')]);}})['then'](respondWithStatusCode(_0x388905,null))[_0xe89b('0x65')](handleError(_0x388905,null));};exports[_0xe89b('0x147')]=function(_0x5630de,_0x331311){var _0x59c5d5={};var _0x4c609c={};var _0x4d4242;var _0x2517c8;return db['User'][_0xe89b('0xcd')]({'where':{'id':_0x5630de['params']['id']}})['then'](handleEntityNotFound(_0x331311,null))[_0xe89b('0x1a')](function(_0x412be7){if(_0x412be7){_0x4d4242=_0x412be7;_0x4c609c[_0xe89b('0x58')]=_[_0xe89b('0x5a')](db[_0xe89b('0x148')]['rawAttributes']);_0x4c609c[_0xe89b('0x47')]=_['keys'](_0x5630de[_0xe89b('0x47')]);_0x4c609c[_0xe89b('0x5b')]=_[_0xe89b('0x5c')](_0x4c609c['model'],_0x4c609c[_0xe89b('0x47')]);_0x59c5d5['attributes']=_['intersection'](_0x4c609c[_0xe89b('0x58')],qs[_0xe89b('0x5d')](_0x5630de['query'][_0xe89b('0x5d')]));_0x59c5d5[_0xe89b('0x4b')]=_0x59c5d5['attributes'][_0xe89b('0x4e')]?_0x59c5d5['attributes']:_0x4c609c['model'];_0x59c5d5[_0xe89b('0xd9')]=qs[_0xe89b('0xcf')](_0x5630de[_0xe89b('0x47')]['sort']);_0x59c5d5[_0xe89b('0x45')]=qs[_0xe89b('0x5b')](_['pick'](_0x5630de['query'],_0x4c609c[_0xe89b('0x5b')]));if(_0x5630de[_0xe89b('0x47')][_0xe89b('0x40')]){_0x59c5d5['where']=_[_0xe89b('0x60')](_0x59c5d5['where'],{'$or':_[_0xe89b('0x3e')](_0x59c5d5[_0xe89b('0x4b')],function(_0x1a7fc8){var _0x48efe3={};_0x48efe3[_0x1a7fc8]={'$like':'%'+_0x5630de[_0xe89b('0x47')][_0xe89b('0x40')]+'%'};return _0x48efe3;})});}_0x59c5d5=_[_0xe89b('0x60')]({},_0x59c5d5,_0x5630de['options']);return _0x4d4242[_0xe89b('0x147')](_0x59c5d5);}})[_0xe89b('0x1a')](function(_0x364b58){if(_0x364b58){_0x2517c8=_0x364b58['length'];if(!_0x5630de[_0xe89b('0x47')]['hasOwnProperty'](_0xe89b('0xd8'))){_0x59c5d5['limit']=qs[_0xe89b('0x27')](_0x5630de[_0xe89b('0x47')][_0xe89b('0x27')]);_0x59c5d5[_0xe89b('0x25')]=qs['offset'](_0x5630de[_0xe89b('0x47')]['offset']);}return _0x4d4242[_0xe89b('0x147')](_0x59c5d5);}})[_0xe89b('0x1a')](function(_0x583393){if(_0x583393){return _0x583393?{'count':_0x2517c8,'rows':_0x583393}:null;}})[_0xe89b('0x1a')](respondWithResult(_0x331311,null))[_0xe89b('0x65')](handleError(_0x331311,null));};exports[_0xe89b('0x149')]=function(_0x3a756b,_0x4e8a1a){return db['User'][_0xe89b('0x62')]({'where':{'id':_0x3a756b[_0xe89b('0x57')]['id']}})[_0xe89b('0x1a')](handleEntityNotFound(_0x4e8a1a,null))[_0xe89b('0x1a')](function(_0x3abd34){if(_0x3abd34){return _0x3abd34[_0xe89b('0x149')](_0x3a756b[_0xe89b('0x66')][_0xe89b('0x69')],_[_0xe89b('0x6a')](_0x3a756b['body'],['ids','id'])||{});}})[_0xe89b('0x1a')](respondWithResult(_0x4e8a1a,null))['catch'](handleError(_0x4e8a1a,null));};exports[_0xe89b('0x14a')]=function(_0x3601e0,_0x2a8659){return db[_0xe89b('0x46')][_0xe89b('0x62')]({'where':{'id':_0x3601e0[_0xe89b('0x57')]['id']}})[_0xe89b('0x1a')](handleEntityNotFound(_0x2a8659,null))[_0xe89b('0x1a')](function(_0xa3dc4f){if(_0xa3dc4f){return _0xa3dc4f[_0xe89b('0x14a')](_0x3601e0[_0xe89b('0x47')][_0xe89b('0x69')]);}})[_0xe89b('0x1a')](respondWithStatusCode(_0x2a8659,null))[_0xe89b('0x65')](handleError(_0x2a8659,null));};exports[_0xe89b('0x14b')]=function(_0x3c85bf,_0x33cbdb){var _0x139894={};var _0x1c9849={};var _0x4be0f5;var _0x507e17;return db[_0xe89b('0x46')][_0xe89b('0xcd')]({'where':{'id':_0x3c85bf['params']['id']}})[_0xe89b('0x1a')](handleEntityNotFound(_0x33cbdb,null))['then'](function(_0x41b2b5){if(_0x41b2b5){_0x4be0f5=_0x41b2b5;_0x1c9849[_0xe89b('0x58')]=_[_0xe89b('0x5a')](db[_0xe89b('0x14c')][_0xe89b('0x3d')]);_0x1c9849[_0xe89b('0x47')]=_[_0xe89b('0x5a')](_0x3c85bf['query']);_0x1c9849['filters']=_[_0xe89b('0x5c')](_0x1c9849[_0xe89b('0x58')],_0x1c9849[_0xe89b('0x47')]);_0x139894[_0xe89b('0x4b')]=_[_0xe89b('0x5c')](_0x1c9849['model'],qs[_0xe89b('0x5d')](_0x3c85bf[_0xe89b('0x47')][_0xe89b('0x5d')]));_0x139894[_0xe89b('0x4b')]=_0x139894['attributes']['length']?_0x139894[_0xe89b('0x4b')]:_0x1c9849[_0xe89b('0x58')];_0x139894['order']=qs[_0xe89b('0xcf')](_0x3c85bf['query'][_0xe89b('0xcf')]);_0x139894[_0xe89b('0x45')]=qs[_0xe89b('0x5b')](_[_0xe89b('0xd0')](_0x3c85bf[_0xe89b('0x47')],_0x1c9849[_0xe89b('0x5b')]));if(_0x3c85bf['query'][_0xe89b('0x40')]){_0x139894['where']=_[_0xe89b('0x60')](_0x139894[_0xe89b('0x45')],{'$or':_[_0xe89b('0x3e')](_0x139894[_0xe89b('0x4b')],function(_0x596d54){var _0x29f8ab={};_0x29f8ab[_0x596d54]={'$like':'%'+_0x3c85bf[_0xe89b('0x47')][_0xe89b('0x40')]+'%'};return _0x29f8ab;})});}_0x139894=_[_0xe89b('0x60')]({},_0x139894,_0x3c85bf[_0xe89b('0x61')]);return _0x4be0f5[_0xe89b('0x14b')](_0x139894);}})[_0xe89b('0x1a')](function(_0x3dbe60){if(_0x3dbe60){_0x507e17=_0x3dbe60[_0xe89b('0x4e')];if(!_0x3c85bf['query']['hasOwnProperty'](_0xe89b('0xd8'))){_0x139894[_0xe89b('0x27')]=qs['limit'](_0x3c85bf[_0xe89b('0x47')]['limit']);_0x139894['offset']=qs[_0xe89b('0x25')](_0x3c85bf['query']['offset']);}return _0x4be0f5['getChatWebsites'](_0x139894);}})[_0xe89b('0x1a')](function(_0x4981d6){if(_0x4981d6){return _0x4981d6?{'count':_0x507e17,'rows':_0x4981d6}:null;}})[_0xe89b('0x1a')](respondWithResult(_0x33cbdb,null))[_0xe89b('0x65')](handleError(_0x33cbdb,null));};exports[_0xe89b('0x14d')]=function(_0x3dfa2d,_0x4e8dc3){return db[_0xe89b('0x46')][_0xe89b('0x62')]({'where':{'id':_0x3dfa2d[_0xe89b('0x57')]['id']}})['then'](handleEntityNotFound(_0x4e8dc3,null))[_0xe89b('0x1a')](function(_0x40b5ac){if(_0x40b5ac){return _0x40b5ac[_0xe89b('0x14d')](_0x3dfa2d['body'][_0xe89b('0x69')],_['omit'](_0x3dfa2d[_0xe89b('0x66')],[_0xe89b('0x69'),'id'])||{});}})[_0xe89b('0x1a')](respondWithResult(_0x4e8dc3,null))[_0xe89b('0x65')](handleError(_0x4e8dc3,null));};exports[_0xe89b('0x14e')]=function(_0x393494,_0x41e5e3){return db[_0xe89b('0x46')][_0xe89b('0x62')]({'where':{'id':_0x393494['params']['id']}})[_0xe89b('0x1a')](handleEntityNotFound(_0x41e5e3,null))[_0xe89b('0x1a')](function(_0x6a391){if(_0x6a391){return _0x6a391[_0xe89b('0x14e')](_0x393494[_0xe89b('0x47')][_0xe89b('0x69')]);}})[_0xe89b('0x1a')](respondWithStatusCode(_0x41e5e3,null))['catch'](handleError(_0x41e5e3,null));};exports['getWhatsappAccounts']=function(_0x544adc,_0x5685db){var _0x396d2d={};var _0x2b7541={};var _0x285464;var _0x43381f;return db[_0xe89b('0x46')][_0xe89b('0xcd')]({'where':{'id':_0x544adc[_0xe89b('0x57')]['id']}})[_0xe89b('0x1a')](handleEntityNotFound(_0x5685db,null))[_0xe89b('0x1a')](function(_0x57246e){if(_0x57246e){_0x285464=_0x57246e;_0x2b7541[_0xe89b('0x58')]=_[_0xe89b('0x5a')](db[_0xe89b('0x14f')][_0xe89b('0x3d')]);_0x2b7541[_0xe89b('0x47')]=_[_0xe89b('0x5a')](_0x544adc['query']);_0x2b7541['filters']=_[_0xe89b('0x5c')](_0x2b7541[_0xe89b('0x58')],_0x2b7541[_0xe89b('0x47')]);_0x396d2d[_0xe89b('0x4b')]=_[_0xe89b('0x5c')](_0x2b7541['model'],qs[_0xe89b('0x5d')](_0x544adc[_0xe89b('0x47')][_0xe89b('0x5d')]));_0x396d2d['attributes']=_0x396d2d[_0xe89b('0x4b')][_0xe89b('0x4e')]?_0x396d2d[_0xe89b('0x4b')]:_0x2b7541['model'];_0x396d2d['order']=qs['sort'](_0x544adc['query'][_0xe89b('0xcf')]);_0x396d2d[_0xe89b('0x45')]=qs['filters'](_[_0xe89b('0xd0')](_0x544adc['query'],_0x2b7541[_0xe89b('0x5b')]));if(_0x544adc[_0xe89b('0x47')][_0xe89b('0x40')]){_0x396d2d[_0xe89b('0x45')]=_[_0xe89b('0x60')](_0x396d2d[_0xe89b('0x45')],{'$or':_[_0xe89b('0x3e')](_0x396d2d['attributes'],function(_0x2e0d96){var _0x30c810={};_0x30c810[_0x2e0d96]={'$like':'%'+_0x544adc[_0xe89b('0x47')][_0xe89b('0x40')]+'%'};return _0x30c810;})});}_0x396d2d=_[_0xe89b('0x60')]({},_0x396d2d,_0x544adc[_0xe89b('0x61')]);return _0x285464[_0xe89b('0x150')](_0x396d2d);}})[_0xe89b('0x1a')](function(_0x30d416){if(_0x30d416){_0x43381f=_0x30d416[_0xe89b('0x4e')];if(!_0x544adc[_0xe89b('0x47')][_0xe89b('0xd2')](_0xe89b('0xd8'))){_0x396d2d['limit']=qs[_0xe89b('0x27')](_0x544adc[_0xe89b('0x47')][_0xe89b('0x27')]);_0x396d2d[_0xe89b('0x25')]=qs[_0xe89b('0x25')](_0x544adc[_0xe89b('0x47')]['offset']);}return _0x285464['getWhatsappAccounts'](_0x396d2d);}})['then'](function(_0x5dddb0){if(_0x5dddb0){return _0x5dddb0?{'count':_0x43381f,'rows':_0x5dddb0}:null;}})[_0xe89b('0x1a')](respondWithResult(_0x5685db,null))[_0xe89b('0x65')](handleError(_0x5685db,null));};exports[_0xe89b('0x151')]=function(_0x2c9f0a,_0x453ec3){return db[_0xe89b('0x46')][_0xe89b('0x62')]({'where':{'id':_0x2c9f0a[_0xe89b('0x57')]['id']}})[_0xe89b('0x1a')](handleEntityNotFound(_0x453ec3,null))[_0xe89b('0x1a')](function(_0x1cd266){if(_0x1cd266){return _0x1cd266['addWhatsappAccounts'](_0x2c9f0a['body'][_0xe89b('0x69')],_[_0xe89b('0x6a')](_0x2c9f0a[_0xe89b('0x66')],['ids','id'])||{});}})[_0xe89b('0x1a')](respondWithResult(_0x453ec3,null))[_0xe89b('0x65')](handleError(_0x453ec3,null));};exports[_0xe89b('0x152')]=function(_0x249932,_0x3822c1){return db[_0xe89b('0x46')]['find']({'where':{'id':_0x249932[_0xe89b('0x57')]['id']}})[_0xe89b('0x1a')](handleEntityNotFound(_0x3822c1,null))['then'](function(_0x142b3e){if(_0x142b3e){return _0x142b3e['removeWhatsappAccounts'](_0x249932['query']['ids']);}})[_0xe89b('0x1a')](respondWithStatusCode(_0x3822c1,null))[_0xe89b('0x65')](handleError(_0x3822c1,null));};exports[_0xe89b('0x153')]=function(_0x56e067,_0x520a78){var _0x543dfd={};var _0x56c9a3={};var _0x1c708c;var _0x348217;return db[_0xe89b('0x46')]['findOne']({'where':{'id':_0x56e067[_0xe89b('0x57')]['id']}})[_0xe89b('0x1a')](handleEntityNotFound(_0x520a78,null))['then'](function(_0x1fa967){if(_0x1fa967){_0x1c708c=_0x1fa967;_0x56c9a3[_0xe89b('0x58')]=_[_0xe89b('0x5a')](db[_0xe89b('0x154')][_0xe89b('0x3d')]);_0x56c9a3['query']=_['keys'](_0x56e067[_0xe89b('0x47')]);_0x56c9a3['filters']=_[_0xe89b('0x5c')](_0x56c9a3[_0xe89b('0x58')],_0x56c9a3[_0xe89b('0x47')]);_0x543dfd[_0xe89b('0x4b')]=_[_0xe89b('0x5c')](_0x56c9a3[_0xe89b('0x58')],qs[_0xe89b('0x5d')](_0x56e067[_0xe89b('0x47')][_0xe89b('0x5d')]));_0x543dfd[_0xe89b('0x4b')]=_0x543dfd[_0xe89b('0x4b')][_0xe89b('0x4e')]?_0x543dfd['attributes']:_0x56c9a3[_0xe89b('0x58')];_0x543dfd['order']=qs[_0xe89b('0xcf')](_0x56e067['query'][_0xe89b('0xcf')]);_0x543dfd[_0xe89b('0x45')]=qs[_0xe89b('0x5b')](_[_0xe89b('0xd0')](_0x56e067[_0xe89b('0x47')],_0x56c9a3[_0xe89b('0x5b')]));if(_0x56e067[_0xe89b('0x47')][_0xe89b('0x40')]){_0x543dfd[_0xe89b('0x45')]=_[_0xe89b('0x60')](_0x543dfd[_0xe89b('0x45')],{'$or':_[_0xe89b('0x3e')](_0x543dfd[_0xe89b('0x4b')],function(_0x3b0b1c){var _0x2025d6={};_0x2025d6[_0x3b0b1c]={'$like':'%'+_0x56e067[_0xe89b('0x47')]['filter']+'%'};return _0x2025d6;})});}_0x543dfd=_[_0xe89b('0x60')]({},_0x543dfd,_0x56e067[_0xe89b('0x61')]);return _0x1c708c['getSquareProjects'](_0x543dfd);}})[_0xe89b('0x1a')](function(_0x5435d1){if(_0x5435d1){_0x348217=_0x5435d1[_0xe89b('0x4e')];if(!_0x56e067['query']['hasOwnProperty'](_0xe89b('0xd8'))){_0x543dfd[_0xe89b('0x27')]=qs[_0xe89b('0x27')](_0x56e067[_0xe89b('0x47')]['limit']);_0x543dfd[_0xe89b('0x25')]=qs['offset'](_0x56e067[_0xe89b('0x47')][_0xe89b('0x25')]);}return _0x1c708c[_0xe89b('0x153')](_0x543dfd);}})[_0xe89b('0x1a')](function(_0x44b6a3){if(_0x44b6a3){return _0x44b6a3?{'count':_0x348217,'rows':_0x44b6a3}:null;}})['then'](respondWithResult(_0x520a78,null))[_0xe89b('0x65')](handleError(_0x520a78,null));};exports['addSquareProjects']=function(_0x1a3f70,_0x41adab){return db[_0xe89b('0x46')][_0xe89b('0x62')]({'where':{'id':_0x1a3f70[_0xe89b('0x57')]['id']}})[_0xe89b('0x1a')](handleEntityNotFound(_0x41adab,null))[_0xe89b('0x1a')](function(_0x41621b){if(_0x41621b){return _0x41621b[_0xe89b('0x155')](_0x1a3f70[_0xe89b('0x66')][_0xe89b('0x69')],_[_0xe89b('0x6a')](_0x1a3f70[_0xe89b('0x66')],[_0xe89b('0x69'),'id'])||{});}})[_0xe89b('0x1a')](respondWithResult(_0x41adab,null))[_0xe89b('0x65')](handleError(_0x41adab,null));};exports[_0xe89b('0x156')]=function(_0x131891,_0x2b6983){return db[_0xe89b('0x46')]['find']({'where':{'id':_0x131891[_0xe89b('0x57')]['id']}})[_0xe89b('0x1a')](handleEntityNotFound(_0x2b6983,null))['then'](function(_0xcb87a1){if(_0xcb87a1){return _0xcb87a1[_0xe89b('0x156')](_0x131891[_0xe89b('0x47')][_0xe89b('0x69')]);}})[_0xe89b('0x1a')](respondWithStatusCode(_0x2b6983,null))[_0xe89b('0x65')](handleError(_0x2b6983,null));};exports[_0xe89b('0x157')]=function(_0xb31fd1,_0xae244a){var _0x582046={},_0x54957c={},_0x5c0ae1={'count':0x0,'rows':[]};var _0x19d34d=db[_0xe89b('0x158')][_0xe89b('0x3d')];_0x54957c[_0xe89b('0x58')]=_[_0xe89b('0x5a')](_0x19d34d);_0x54957c[_0xe89b('0x47')]=_['keys'](_0xb31fd1[_0xe89b('0x47')]);_0x54957c[_0xe89b('0x5b')]=_[_0xe89b('0x5c')](_0x54957c[_0xe89b('0x58')],_0x54957c[_0xe89b('0x47')]);_0x54957c['filters']=_[_0xe89b('0xcc')](_0x54957c[_0xe89b('0x5b')],[_0xe89b('0x159'),'$or',_0xe89b('0x15a'),'$gte',_0xe89b('0x15b'),_0xe89b('0x15c'),_0xe89b('0x15d'),_0xe89b('0x15e'),_0xe89b('0x15f'),_0xe89b('0x160'),_0xe89b('0x161'),_0xe89b('0x162'),_0xe89b('0x163'),_0xe89b('0x164'),_0xe89b('0x165'),_0xe89b('0x166'),_0xe89b('0x167'),'$like',_0xe89b('0x168'),'$contains',_0xe89b('0x169'),_0xe89b('0x16a')]);_0x582046['attributes']=_[_0xe89b('0x5c')](_0x54957c['model'],qs[_0xe89b('0x5d')](_0xb31fd1[_0xe89b('0x47')][_0xe89b('0x5d')]));_0x582046[_0xe89b('0x4b')]=_0x582046[_0xe89b('0x4b')][_0xe89b('0x4e')]?_0x582046['attributes']:_0x54957c[_0xe89b('0x58')];if(!_0xb31fd1[_0xe89b('0x47')][_0xe89b('0xd2')]('nolimit')){_0x582046['limit']=qs[_0xe89b('0x27')](_0xb31fd1[_0xe89b('0x47')][_0xe89b('0x27')]);_0x582046[_0xe89b('0x25')]=qs[_0xe89b('0x25')](_0xb31fd1['query'][_0xe89b('0x25')]);}_0x582046['order']=qs[_0xe89b('0xcf')](_0xb31fd1[_0xe89b('0x47')][_0xe89b('0xcf')]);_0x582046[_0xe89b('0x45')]=qs[_0xe89b('0x5b')](_[_0xe89b('0xd0')](_0xb31fd1['query'],_0x54957c['filters']));if(_0xb31fd1['query'][_0xe89b('0x40')]){_0x582046[_0xe89b('0x45')]=_[_0xe89b('0x60')](_0x582046[_0xe89b('0x45')],{'$or':_[_0xe89b('0x3e')](_0x582046[_0xe89b('0x4b')],function(_0x441d70){var _0x21fc40={};_0x21fc40[_0x441d70]={'$like':'%'+_0xb31fd1[_0xe89b('0x47')]['filter']+'%'};return _0x21fc40;})});}_0x582046[_0xe89b('0x45')]={'$and':[_0x582046[_0xe89b('0x45')],{'$or':[{'UserId':_0xb31fd1[_0xe89b('0x57')]['id']},{'OwnerId':_0xb31fd1[_0xe89b('0x57')]['id']}]}]};_0x582046=_[_0xe89b('0x60')]({},_0x582046,_0xb31fd1['options']);var _0x3d9ab7={'where':_0x582046[_0xe89b('0x45')]};return db[_0xe89b('0x158')][_0xe89b('0x28')](_0x3d9ab7)[_0xe89b('0x1a')](function(_0x3fb49e){_0x5c0ae1[_0xe89b('0x28')]=_0x3fb49e;if(_0xb31fd1[_0xe89b('0x47')][_0xe89b('0x5e')]){_0x582046[_0xe89b('0x4a')]=[{'attributes':['id',_0xe89b('0x16b'),_0xe89b('0x16c'),'phone'],'model':db['CmContact'],'as':'Contact'},{'attributes':['id',_0xe89b('0x37'),'dialActive'],'model':db[_0xe89b('0xad')],'as':_0xe89b('0xda')}];}return db[_0xe89b('0x158')][_0xe89b('0x4c')](_0x582046);})['then'](function(_0x124b0a){_0x5c0ae1[_0xe89b('0x4d')]=_0x124b0a;return _0x5c0ae1;})[_0xe89b('0x1a')](respondWithFilteredResult(_0xae244a,_0x582046))['catch'](handleError(_0xae244a,null));};exports[_0xe89b('0x16d')]=function(_0x112804,_0x38ce60){if(!_[_0xe89b('0x70')](_0x112804[_0xe89b('0x31')]['id'])&&(_0x112804[_0xe89b('0x31')][_0xe89b('0x2f')]==_0xe89b('0x30')||_0x112804[_0xe89b('0x31')][_0xe89b('0x2f')]==_0xe89b('0x31'))){return db[_0xe89b('0x46')][_0xe89b('0xcd')]({'where':{'id':_0x112804[_0xe89b('0x57')]['id']},'raw':!![]})[_0xe89b('0x1a')](function(_0x4e35f1){return authService[_0xe89b('0x16e')](_0x4e35f1);})[_0xe89b('0x1a')](function(_0x507c1c){if(_0x507c1c){return _0x38ce60[_0xe89b('0x23')](0xc8)[_0xe89b('0x2b')]({'api_key':_0x507c1c[_0xe89b('0x16f')]});}else{return _0x38ce60[_0xe89b('0x23')](0xcc)[_0xe89b('0x2b')]({'message':'No\x20API\x20access\x20key\x20found!'});}})['catch'](handleError(_0x38ce60,0x193));}else{return _0x38ce60[_0xe89b('0x23')](0x191)[_0xe89b('0x2b')]({'message':_0xe89b('0x170')});}};exports['createApiKey']=function(_0x469eb9,_0x15a83c){if(!_[_0xe89b('0x70')](_0x469eb9['user']['id'])&&(_0x469eb9['user']['role']==_0xe89b('0x30')||_0x469eb9[_0xe89b('0x31')]['role']==_0xe89b('0x31'))){return db[_0xe89b('0x46')]['find']({'where':{'id':_0x469eb9[_0xe89b('0x57')]['id']}})[_0xe89b('0x1a')](function(_0x3b2e6d){return authService['generateApiKey'](_0x3b2e6d);})[_0xe89b('0x1a')](function(_0x1ecb3a){return db[_0xe89b('0x46')][_0xe89b('0x2c')]({'apiKeyIat':_0x1ecb3a[_0xe89b('0x171')],'apiKeyNonce':_0x1ecb3a[_0xe89b('0x172')]},{'where':{'id':_0x469eb9[_0xe89b('0x57')]['id']}})[_0xe89b('0x1a')](function(){return _0x15a83c['status'](0xc8)[_0xe89b('0x2b')]({'api_key':_0x1ecb3a[_0xe89b('0x16f')]});});})[_0xe89b('0x65')](handleError(_0x15a83c,0x193));}else{return _0x15a83c['status'](0x191)['json']({'message':_0xe89b('0x170')});}};exports['removeApiKey']=function(_0x2430a8,_0x4b3549){if(!_['isNil'](_0x2430a8[_0xe89b('0x31')]['id'])&&(_0x2430a8[_0xe89b('0x31')][_0xe89b('0x2f')]==_0xe89b('0x30')||_0x2430a8[_0xe89b('0x31')]['role']=='user')){return db[_0xe89b('0x46')][_0xe89b('0x62')]({'where':{'id':_0x2430a8[_0xe89b('0x57')]['id']}})[_0xe89b('0x1a')](handleEntityNotFound(_0x4b3549,null))[_0xe89b('0x1a')](function(_0x2e6d8c){if(_0x2e6d8c&&_0x2e6d8c[_0xe89b('0x173')]&&_0x2e6d8c['apiKeyIat'])return _0x2e6d8c;else throw{'message':_0xe89b('0x174')};})[_0xe89b('0x1a')](function(){return db['User'][_0xe89b('0x2c')]({'apiKeyNonce':null,'apiKeyIat':null},{'where':{'id':_0x2430a8[_0xe89b('0x57')]['id']}});})[_0xe89b('0x1a')](respondWithStatusCode(_0x4b3549,0xc8))['catch'](handleError(_0x4b3549,0x193));}else{return _0x4b3549[_0xe89b('0x23')](0x191)[_0xe89b('0x2b')]({'message':'You\x20don\x27t\x20have\x20sufficient\x20privileges\x20to\x20access\x20this\x20resource.'});}};exports[_0xe89b('0x175')]=function(_0x49f750,_0x342ab6){var _0x30738a=_0x49f750[_0xe89b('0x31')][_0xe89b('0xae')]({'plain':!![]});if(!_0x30738a){return _0x342ab6['status'](0x191)[_0xe89b('0x3b')](_0xe89b('0x176'));}else{Promise[_0xe89b('0x105')]()[_0xe89b('0x1a')](function(){if(_0x49f750[_0xe89b('0x47')][_0xe89b('0x48')]!==_0xe89b('0x49'))return;return _0x49f750[_0xe89b('0x31')][_0xe89b('0x177')]();})[_0xe89b('0x1a')](function(_0x230ec){if(!_0x230ec)return;return _0x230ec[_0xe89b('0xae')]({'plain':!![]});})['then'](function(_0x5e5fea){_0x30738a[_0xe89b('0x48')]=_0x5e5fea;return _0x342ab6[_0xe89b('0x23')](0xc8)[_0xe89b('0x2b')](_0x30738a);});}};exports[_0xe89b('0x178')]=function(_0x15bdc3,_0x4d3d7f){var _0x407b3d={'offset':0x0},_0x34c37a={'count':0x0,'rows':[]};Promise[_0xe89b('0x105')]()[_0xe89b('0x1a')](function(){if(!_0x15bdc3[_0xe89b('0x47')]['filter']&&!_0x15bdc3[_0xe89b('0x47')][_0xe89b('0x179')]&&!_0x15bdc3[_0xe89b('0x47')][_0xe89b('0x17a')])return[];return Promise['resolve']()[_0xe89b('0x1a')](function(){var _0x2f4ab0=[];if(!_[_0xe89b('0x91')](_0x15bdc3[_0xe89b('0x47')][_0xe89b('0x179')])){_0x2f4ab0[_0xe89b('0x4f')](db[_0xe89b('0x115')]['findAll']({'attributes':['id','name'],'where':{'id':_0x15bdc3[_0xe89b('0x47')][_0xe89b('0x179')]}}));}if(!_['isEmpty'](_0x15bdc3[_0xe89b('0x47')]['queues'])){_0x2f4ab0[_0xe89b('0x4f')](db[_0xe89b('0xad')]['findAll']({'attributes':['id','name'],'type':_0xe89b('0x17b'),'where':{'id':_0x15bdc3['query'][_0xe89b('0x17a')]}}));}return Promise[_0xe89b('0x55')](_0x2f4ab0);})[_0xe89b('0x1a')](function(_0x569b58){var _0x24b90e=_[_0xe89b('0x17c')](_0x569b58)[_0xe89b('0x3e')](function(_0x68041c){return _0x68041c[_0xe89b('0x126')]({'attributes':['id',_0xe89b('0x37'),_0xe89b('0x6b'),'online'],'raw':!![]});});return Promise[_0xe89b('0x55')](_0x24b90e);})[_0xe89b('0x1a')](function(_0x4c786b){var _0x28e898=_['flatten'](_0x4c786b);if(!_0x15bdc3[_0xe89b('0x47')][_0xe89b('0x40')])return _0x28e898;if(_[_0xe89b('0x91')](_0x28e898)){return db['User'][_0xe89b('0x4c')]({'attributes':['id','name',_0xe89b('0x6b'),_0xe89b('0x123')],'where':{'role':'agent','$or':[db[_0xe89b('0x72')][_0xe89b('0x45')](db[_0xe89b('0x72')]['fn']('lower',db[_0xe89b('0x72')][_0xe89b('0x17d')](_0xe89b('0x37'))),{'$like':'%'+_0x15bdc3[_0xe89b('0x47')][_0xe89b('0x40')][_0xe89b('0xa5')]()+'%'}),{'internal':{'$like':'%'+_0x15bdc3[_0xe89b('0x47')][_0xe89b('0x40')]+'%'}}]},'raw':!![]});}else{return _(_0x28e898)[_0xe89b('0x17c')]()['filter'](function(_0x278a85){return _0x278a85[_0xe89b('0x37')][_0xe89b('0xa5')]()['includes'](_0x15bdc3[_0xe89b('0x47')]['filter'][_0xe89b('0xa5')]())||_0x278a85[_0xe89b('0x6b')]['toString']()['includes'](_0x15bdc3['query']['filter']);})['value']();}})[_0xe89b('0x1a')](function(_0xeeb294){var _0x531931=_0xe89b('0x37');var _0x41af93=_0xe89b('0x17e');if(_0x15bdc3[_0xe89b('0x47')][_0xe89b('0xcf')]){_0x41af93=_0x15bdc3['query'][_0xe89b('0xcf')][0x0]==='-'?_0xe89b('0x17f'):_0xe89b('0x17e');_0x531931=_0x41af93===_0xe89b('0x17e')?_0x15bdc3[_0xe89b('0x47')][_0xe89b('0xcf')]:_0x15bdc3[_0xe89b('0x47')][_0xe89b('0xcf')]['substring'](0x1);}return _(_0xeeb294)['uniqBy']('id')[_0xe89b('0x180')]([function(_0x3be384){return _0x531931===_0xe89b('0x37')?_0x3be384[_0x531931][_0xe89b('0xa5')]():_0x3be384[_0x531931];}],[_0x41af93])[_0xe89b('0x3e')](function(_0x5cda15){return _['pick'](_0x5cda15,['id','name',_0xe89b('0x6b'),_0xe89b('0x123')]);})[_0xe89b('0x36')]();})['then'](function(_0x3587f5){return client['request']('Agents',_0x15bdc3)[_0xe89b('0x1a')](function(_0x410e39){if(_0x410e39[_0xe89b('0x1e')])throw new Error(_0xe89b('0x181'));var _0x1ccfe4=_0x410e39[_0xe89b('0x22')];var _0x4a8332=jayson[_0xe89b('0x17')][_0xe89b('0x18')]({'port':0x232c});return _0x4a8332['request'](_0xe89b('0x32'),_0x15bdc3)[_0xe89b('0x1a')](function(_0xda8e00){if(_0xda8e00[_0xe89b('0x1e')])throw new Error(_0xe89b('0x182'));var _0x4aa752=_0xda8e00[_0xe89b('0x22')];return _[_0xe89b('0x60')]({},_0x4aa752,_0x1ccfe4);});})[_0xe89b('0x1a')](function(_0x4cd11d){return _[_0xe89b('0x3e')](_0x3587f5,function(_0x283856){var _0x39c34c=_[_0xe89b('0x62')](_0x4cd11d[_0xe89b('0x4d')],['id',_0x283856['id']]);if(!_0x39c34c||!_0x283856[_0xe89b('0x123')]){_0x283856[_0xe89b('0x23')]=_0xe89b('0x183');}else if(_0x39c34c[_0xe89b('0xb1')]){_0x283856[_0xe89b('0x23')]=_0xe89b('0x107');}else{_0x283856[_0xe89b('0x23')]=_[_0xe89b('0x41')]([_0xe89b('0x184'),_0xe89b('0x185'),_0xe89b('0x186'),_0xe89b('0x187'),null,undefined],_0x39c34c[_0xe89b('0x188')])?_0xe89b('0x123'):_0xe89b('0x189');}return _0x283856;});});});})['then'](function(_0x184f6a){if(!_0x15bdc3[_0xe89b('0x47')][_0xe89b('0xd2')](_0xe89b('0xd8'))){_0x407b3d['limit']=qs[_0xe89b('0x27')](_0x15bdc3[_0xe89b('0x47')][_0xe89b('0x27')]||0xa);_0x407b3d[_0xe89b('0x25')]=qs[_0xe89b('0x25')](_0x15bdc3[_0xe89b('0x47')]['offset']);}_0x34c37a[_0xe89b('0x28')]=_0x184f6a[_0xe89b('0x4e')];_0x34c37a[_0xe89b('0x4d')]=_0x407b3d['limit']?_0x184f6a[_0xe89b('0x18a')](_0x407b3d['offset'],_0x407b3d[_0xe89b('0x25')]+_0x407b3d[_0xe89b('0x27')]):_0x184f6a;return _0x34c37a;})[_0xe89b('0x1a')](respondWithFilteredResult(_0x4d3d7f,_0x407b3d))[_0xe89b('0x65')](handleError(_0x4d3d7f,null));};function get_open_tabs(_0x1ae776,_0x5b6929){var _0x1053bd=_0x1ae776[_0xe89b('0x18b')](0x0)['toUpperCase']()+_0x1ae776[_0xe89b('0x18a')](0x1);var _0x1a576d={'type':db[_0xe89b('0x97')][_0xe89b('0x73')][_0xe89b('0x74')],'raw':!![]};return new BPromise(function(_0x4f783d,_0x2ad901){var _0x1a0ddd=squel['select']()[_0xe89b('0x18c')](_0xe89b('0x18d')+_0x1053bd+'InteractionId','id')[_0xe89b('0x18c')](_0xe89b('0x18e'))[_0xe89b('0x75')](_0xe89b('0x18f')+_0x1ae776+_0xe89b('0x190'),'ui')[_0xe89b('0x45')](_0xe89b('0x191'),_0x5b6929['id']);return db[_0xe89b('0x72')][_0xe89b('0x47')](_0x1a0ddd[_0xe89b('0x192')](),_0x1a576d)[_0xe89b('0x1a')](function(_0xa4854e){_0x5b6929[_0x1053bd+'OpenTabs']=_0xa4854e;_0x4f783d(_0xa4854e);})['catch'](function(_0x15b141){_0x2ad901(_0x15b141);});});}
\ No newline at end of file