Built motion from commit 9d7072cc.|2.5.39
[motion2.git] / server / api / user / user.controller.js
index 12cf1da..9d2573f 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x7f27=['changePassword','findOne','oldPassword','newPassword','authenticate','Wrong\x20credentials','New\x20password\x20must\x20be\x20different\x20from\x20old\x20password','Invalid\x20body\x20format.\x20Use\x20newPassword','Unauthorized','addQueues','channel','online','voicePause','interface','Unknown\x20channel','add','capitalize','toLowerCase','Queues','penalty','spread','QueueId','emit','voice','VoiceQueue','findAll','push','SIP/%s','UserVoiceQueueRt','upsert','removeQueues','isValidChannel','remove','Queue:remove','addAvatar','userpic','file','filename','getAvatar','join','root','server/files/images/logos/default_profile.png','download','existsSync','server/files/images/','CmContact','getContacts','CmList','List','Tags','tag','getQueues','Queue','getVoiceQueuesRt','getGroups','getRecordings','VoiceRecording','UserId','ScreenRecording','ChatInteraction','getChatInteractions','getOpenchannelInteractions','getMailInteractions','MailInteraction','SmsInteraction','getSmsInteractions','getFaxInteractions','FaxInteraction','WhatsappInteraction','getWhatsappInteractions','login','phone','mobile','loginInPause','LOCAL/%s@from-sip/n','intrf','user:%s','headers','x-forwarded-for','connection','remoteAddress','socket','User\x20not\x20found\x20or\x20not\x20allowed\x20to\x20perform\x20login\x20method','getVoiceQueues','UserVoiceQueue.penalty','each','MemberReport','forEach','YYYY-MM-DD\x20HH:mm:ss','getChannels','LOGIN','device','PAUSE','LOGININPAUSE','concat','isMiddleware','pause','QueuePause','updateAttributes','DEFAULT\x20PAUSE','unpause','mailPause','chatPause','faxPause','openchannelPause','whatsapppause','pauseType','chat','fax','sms','whatsapp','manual','set','getTeams','Team','addTeams','setDataValue','Voice','getMailQueues','Mail','getSmsQueues','getWhatsappQueues','Whatsapp','Openchannel','all','flatten','transaction','getDataValue','Queue:save','removeTeams','Sms','Fax','getOpenchannelQueues','getLists','getAgents','values','send','addChatInteractions','user_has_chat_interactions:save','removeChatInteractions','user_has_chat_interactions:remove','addMailInteractions','removeMailInteractions','isArray','user_has_mail_interactions:remove','addFaxInteractions','user_has_fax_interactions:save','removeFaxInteractions','user_has_fax_interactions:remove','addSmsInteractions','user_has_sms_interactions:save','removeSmsInteractions','user_has_sms_interactions:remove','addOpenchannelInteractions','user_has_openchannel_interactions:save','removeOpenchannelInteractions','user_has_openchannel_interactions:remove','addWhatsappInteractions','getVoicePrefixes','VoicePrefix','getFaxAccounts','FaxAccount','addFaxAccounts','removeFaxAccounts','getMailAccounts','addMailAccounts','removeMailAccounts','getOpenchannelAccounts','OpenchannelAccount','addOpenchannelAccounts','removeOpenchannelAccounts','SmsAccount','getSmsAccounts','addSmsAccounts','removeSmsAccounts','getChatWebsites','ChatWebsite','addChatWebsites','removeChatWebsites','WhatsappAccount','getWhatsappAccounts','addWhatsappAccounts','removeWhatsappAccounts','getSquareProjects','SquareProject','addSquareProjects','removeSquareProjects','getScheduledCalls','CmHopper','$and','$or','$gt','$lt','$lte','$ne','$eq','$not','$between','$notBetween','$in','$notIn','$like','$notLike','$iLike','$notILike','$contains','$contained','firstName','lastName','dialActive','getApiKey','token','No\x20API\x20access\x20key\x20found!','You\x20don\x27t\x20have\x20sufficient\x20privileges\x20to\x20access\x20this\x20resource.','generateApiKey','iat','nonce','removeApiKey','apiKeyNonce','apiKeyIat','API\x20key\x20not\x20available','whoami','html-pdf','eml-format','zip-dir','fast-json-patch','request-promise','moment','mustache','util','path','to-csv','ejs','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','../../components/auth/service','../../config/license/hardware','api','../../config/utils','../../config/environment','../../mysqldb','defaults','redis','localhost','register','jayson/promise','client','http','Sequelize','ValidationError','request','then','info','User,\x20%s,\x20%s','request\x20sent','debug','User,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','sendStatus','status','end','json','offset','limit','Content-Range','apply','save','update','destroy','Users','user','Agents','Telephones','ignore','map','value','includes','find','role','UserProfileResource','stack','name','User','rawAttributes','fieldName','type','key','model','differenceBy','password','salt','query','keys','filters','attributes','intersection','fields','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','VIRTUAL','sequelize','lower','count','includeAll','include','rows','params','length','options','bulkCreate','body','describe','addContacts','ids','omit','agent','agent\x20role','telephone','admin','../../config/license/util','getLicense','users','License\x20limit\x20reached','format','count\x20%s:\x20%s','create','Setting','findById','securePassword','max','internal','isNil','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','VoiceMail','fullname','email','permissions','101','102','103','113','110','105','100','111','114','get','Unable\x20to\x20retrieve\x20the\x20current\x20user','UserProfileSection','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0x7f27,0xde));var _0x77f2=function(_0x94283b,_0x3dc1d6){_0x94283b=_0x94283b-0x0;var _0x8edef4=_0x7f27[_0x94283b];return _0x8edef4;};'use strict';var pdf=require(_0x77f2('0x0'));var emlformat=require(_0x77f2('0x1'));var rimraf=require('rimraf');var zipdir=require(_0x77f2('0x2'));var jsonpatch=require(_0x77f2('0x3'));var rp=require(_0x77f2('0x4'));var moment=require(_0x77f2('0x5'));var BPromise=require('bluebird');var Mustache=require(_0x77f2('0x6'));var util=require(_0x77f2('0x7'));var path=require(_0x77f2('0x8'));var sox=require('sox');var csv=require(_0x77f2('0x9'));var ejs=require(_0x77f2('0xa'));var fs=require('fs');var _=require(_0x77f2('0xb'));var squel=require(_0x77f2('0xc'));var crypto=require(_0x77f2('0xd'));var jsforce=require(_0x77f2('0xe'));var deskjs=require(_0x77f2('0xf'));var toCsv=require(_0x77f2('0x9'));var querystring=require(_0x77f2('0x10'));var Papa=require(_0x77f2('0x11'));var Redis=require('ioredis');var authService=require(_0x77f2('0x12'));var qs=require('../../components/parsers/qs');var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x77f2('0x13'));var logger=require('../../config/logger')(_0x77f2('0x14'));var utils=require(_0x77f2('0x15'));var config=require(_0x77f2('0x16'));var db=require(_0x77f2('0x17'))['db'];config['redis']=_[_0x77f2('0x18')](config[_0x77f2('0x19')],{'host':_0x77f2('0x1a'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config['redis']));require('./user.socket')[_0x77f2('0x1b')](socket);var jayson=require(_0x77f2('0x1c'));var client=jayson[_0x77f2('0x1d')][_0x77f2('0x1e')]({'port':0x232a});function checkPasswordPattern(_0x2e1a1f,_0x1046c0,_0x99808f){if(_0x99808f){var _0x31b691=new RegExp(/(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[?!@#\$%\^&\*~\-_=+[{\]\}])(?=.{8,})/);if(_0x31b691['test'](_0x1046c0)){return _0x2e1a1f;}else{throw new db[(_0x77f2('0x1f'))][(_0x77f2('0x20'))]('The\x20password\x20must\x20be\x20at\x20least\x208\x20characters\x20long\x20and\x20have\x201\x20lowercase\x20character,\x201\x20uppercase\x20character,\x201\x20number\x20and\x201\x20special\x20character\x20~!@#$%^&-_=+[{]}.');}}else{return _0x2e1a1f;}}function respondWithRpcPromise(_0x73907c,_0x1f6296,_0x38109c,_0x51d558){return new BPromise(function(_0x4565bf,_0x1e00da){var _0x274300=_0x51d558||client;return _0x274300[_0x77f2('0x21')](_0x73907c,_0x38109c)[_0x77f2('0x22')](function(_0x1bbaeb){logger[_0x77f2('0x23')](_0x77f2('0x24'),_0x1f6296,_0x77f2('0x25'));logger[_0x77f2('0x26')](_0x77f2('0x27'),_0x1f6296,_0x77f2('0x25'),JSON[_0x77f2('0x28')](_0x1bbaeb));if(_0x1bbaeb[_0x77f2('0x29')]){if(_0x1bbaeb[_0x77f2('0x29')][_0x77f2('0x2a')]===0x1f4){logger[_0x77f2('0x29')](_0x77f2('0x24'),_0x1f6296,_0x1bbaeb[_0x77f2('0x29')]['message']);return _0x1e00da(_0x1bbaeb[_0x77f2('0x29')][_0x77f2('0x2b')]);}logger['error']('User,\x20%s,\x20%s',_0x1f6296,_0x1bbaeb[_0x77f2('0x29')][_0x77f2('0x2b')]);return _0x4565bf(_0x1bbaeb[_0x77f2('0x29')][_0x77f2('0x2b')]);}else{logger[_0x77f2('0x23')](_0x77f2('0x24'),_0x1f6296,_0x77f2('0x25'));_0x4565bf(_0x1bbaeb[_0x77f2('0x2c')][_0x77f2('0x2b')]);}})[_0x77f2('0x2d')](function(_0x1b99c){logger['error'](_0x77f2('0x24'),_0x1f6296,_0x1b99c);_0x1e00da(_0x1b99c);});});}function respondWithStatusCode(_0x4ad81c,_0x5b9140){_0x5b9140=_0x5b9140||0xcc;return function(_0x21a2e0){if(_0x21a2e0){return _0x4ad81c[_0x77f2('0x2e')](_0x5b9140);}return _0x4ad81c[_0x77f2('0x2f')](_0x5b9140)[_0x77f2('0x30')]();};}function respondWithResult(_0x1c1c8e,_0x4ce763){_0x4ce763=_0x4ce763||0xc8;return function(_0x580466){if(_0x580466){return _0x1c1c8e['status'](_0x4ce763)[_0x77f2('0x31')](_0x580466);}};}function respondWithFilteredResult(_0x1f2b3c,_0xdfc64d){return function(_0x1a7086){if(_0x1a7086){var _0x1228a3=_0x1a7086['count'],_0x1659bb=_0xdfc64d[_0x77f2('0x32')],_0x10da28=_0xdfc64d['offset']+_0xdfc64d[_0x77f2('0x33')],_0x4ae745;if(_0x10da28>=_0x1228a3){_0x10da28=_0x1228a3;_0x4ae745=0xc8;}else{_0x4ae745=0xce;}_0x1f2b3c[_0x77f2('0x2f')](_0x4ae745);return _0x1f2b3c['set'](_0x77f2('0x34'),_0x1659bb+'-'+_0x10da28+'/'+_0x1228a3)[_0x77f2('0x31')](_0x1a7086);}return null;};}function patchUpdates(_0x47df82){return function(_0x2bc72b){try{jsonpatch[_0x77f2('0x35')](_0x2bc72b,_0x47df82,!![]);}catch(_0x401d82){return BPromise['reject'](_0x401d82);}return _0x2bc72b[_0x77f2('0x36')]();};}function saveUpdates(_0x18aa74,_0x3ecf5e){return function(_0x5b3873){if(_0x5b3873){return _0x5b3873[_0x77f2('0x37')](_0x18aa74)['then'](function(_0x65a485){return _0x65a485;});}return null;};}function removeEntity(_0x4696dc,_0x9fdb0b){return function(_0x5cfa82){if(_0x5cfa82){return _0x5cfa82[_0x77f2('0x38')]()[_0x77f2('0x22')](function(){var _0x4e943c=_0x5cfa82['get']({'plain':!![]});var _0x25c45a=[{'name':_0x77f2('0x39'),'value':_0x77f2('0x3a'),'ignore':!![]},{'name':_0x77f2('0x3b'),'value':'agent','ignore':![]},{'name':_0x77f2('0x3c'),'value':'telephone','ignore':![]}];var _0x257b5b=_(_0x25c45a)['filter'](_0x77f2('0x3d'))[_0x77f2('0x3e')]('value')[_0x77f2('0x3f')]();if(_[_0x77f2('0x40')](_0x257b5b,_0x4e943c['role'])){return;}var _0x156c98=_[_0x77f2('0x41')](_0x25c45a,[_0x77f2('0x3f'),_0x4e943c[_0x77f2('0x42')]])['name'];return db[_0x77f2('0x43')][_0x77f2('0x38')]({'where':{'type':_0x156c98,'resourceId':_0x4e943c['id']}})[_0x77f2('0x22')](function(){return _0x5cfa82;});})[_0x77f2('0x22')](function(){_0x4696dc[_0x77f2('0x2f')](0xcc)[_0x77f2('0x30')]();});}};}function handleEntityNotFound(_0x3e953b,_0x3bbb1e){return function(_0x58f218){if(!_0x58f218){_0x3e953b[_0x77f2('0x2e')](0x194);}return _0x58f218;};}function handleError(_0x376471,_0x3ab074){_0x3ab074=_0x3ab074||0x1f4;return function(_0x4651b2){logger[_0x77f2('0x29')](_0x4651b2[_0x77f2('0x44')]);if(_0x4651b2[_0x77f2('0x45')]){delete _0x4651b2[_0x77f2('0x45')];}_0x376471[_0x77f2('0x2f')](_0x3ab074)['send'](_0x4651b2);};}exports['index']=function(_0x5566d2,_0x14a14a){var _0x29c47d={},_0x1957cc={},_0x5c2050={'count':0x0,'rows':[]};var _0x517027=_[_0x77f2('0x3e')](db[_0x77f2('0x46')][_0x77f2('0x47')],function(_0x4eb947){return{'name':_0x4eb947[_0x77f2('0x48')],'type':_0x4eb947[_0x77f2('0x49')][_0x77f2('0x4a')]};});_0x1957cc[_0x77f2('0x4b')]=_[_0x77f2('0x4c')](_[_0x77f2('0x3e')](_0x517027,_0x77f2('0x45')),[_0x77f2('0x4d'),_0x77f2('0x4e')]);_0x1957cc[_0x77f2('0x4f')]=_[_0x77f2('0x50')](_0x5566d2[_0x77f2('0x4f')]);_0x1957cc[_0x77f2('0x51')]=_['intersection'](_0x1957cc[_0x77f2('0x4b')],_0x1957cc[_0x77f2('0x4f')]);_0x29c47d[_0x77f2('0x52')]=_[_0x77f2('0x53')](_0x1957cc['model'],qs[_0x77f2('0x54')](_0x5566d2[_0x77f2('0x4f')][_0x77f2('0x54')]));_0x29c47d['attributes']=_0x29c47d[_0x77f2('0x52')]['length']?_0x29c47d[_0x77f2('0x52')]:_0x1957cc[_0x77f2('0x4b')];if(!_0x5566d2[_0x77f2('0x4f')][_0x77f2('0x55')](_0x77f2('0x56'))){_0x29c47d['limit']=qs[_0x77f2('0x33')](_0x5566d2[_0x77f2('0x4f')]['limit']);_0x29c47d[_0x77f2('0x32')]=qs[_0x77f2('0x32')](_0x5566d2[_0x77f2('0x4f')][_0x77f2('0x32')]);}_0x29c47d[_0x77f2('0x57')]=qs[_0x77f2('0x58')](_0x5566d2[_0x77f2('0x4f')][_0x77f2('0x58')]);_0x29c47d[_0x77f2('0x59')]=qs['filters'](_[_0x77f2('0x5a')](_0x5566d2[_0x77f2('0x4f')],_0x1957cc[_0x77f2('0x51')]),_0x517027);if(_0x5566d2[_0x77f2('0x4f')][_0x77f2('0x5b')]){_0x29c47d[_0x77f2('0x59')]=_[_0x77f2('0x5c')](_0x29c47d['where'],{'$or':_['map'](_0x517027,function(_0x3367b0){if(_0x3367b0[_0x77f2('0x49')]!==_0x77f2('0x5d')){return db[_0x77f2('0x5e')][_0x77f2('0x59')](db[_0x77f2('0x5e')]['fn']('lower',db[_0x77f2('0x5e')]['col'](_0x3367b0[_0x77f2('0x45')])),{'$like':db[_0x77f2('0x5e')]['fn'](_0x77f2('0x5f'),'%'+_0x5566d2[_0x77f2('0x4f')][_0x77f2('0x5b')]+'%')});}})});}_0x29c47d=_[_0x77f2('0x5c')]({},_0x29c47d,_0x5566d2['options']);var _0x44b0eb={'where':_0x29c47d[_0x77f2('0x59')]};return db[_0x77f2('0x46')]['count'](_0x44b0eb)[_0x77f2('0x22')](function(_0x49528f){_0x5c2050[_0x77f2('0x60')]=_0x49528f;if(_0x5566d2[_0x77f2('0x4f')][_0x77f2('0x61')]){_0x29c47d[_0x77f2('0x62')]=[{'all':!![]}];}return db['User']['findAll'](_0x29c47d);})[_0x77f2('0x22')](function(_0x27b98d){_0x5c2050[_0x77f2('0x63')]=_0x27b98d;return _0x5c2050;})[_0x77f2('0x22')](respondWithFilteredResult(_0x14a14a,_0x29c47d))['catch'](handleError(_0x14a14a,null));};exports['show']=function(_0x567462,_0xbfb48e){var _0x45bae4={'raw':![],'where':{'id':_0x567462[_0x77f2('0x64')]['id']}},_0x27f4d4={};_0x27f4d4[_0x77f2('0x4b')]=_['differenceBy'](_[_0x77f2('0x50')](db[_0x77f2('0x46')][_0x77f2('0x47')]),['password',_0x77f2('0x4e')]);_0x27f4d4[_0x77f2('0x4f')]=_[_0x77f2('0x50')](_0x567462[_0x77f2('0x4f')]);_0x27f4d4[_0x77f2('0x51')]=_['intersection'](_0x27f4d4[_0x77f2('0x4b')],_0x27f4d4[_0x77f2('0x4f')]);_0x45bae4[_0x77f2('0x52')]=_[_0x77f2('0x53')](_0x27f4d4['model'],qs[_0x77f2('0x54')](_0x567462['query'][_0x77f2('0x54')]));_0x45bae4['attributes']=_0x45bae4[_0x77f2('0x52')][_0x77f2('0x65')]?_0x45bae4[_0x77f2('0x52')]:_0x27f4d4['model'];if(_0x567462[_0x77f2('0x4f')][_0x77f2('0x61')]){_0x45bae4[_0x77f2('0x62')]=[{'all':!![]}];}_0x45bae4=_[_0x77f2('0x5c')]({},_0x45bae4,_0x567462[_0x77f2('0x66')]);return db[_0x77f2('0x46')][_0x77f2('0x41')](_0x45bae4)[_0x77f2('0x22')](handleEntityNotFound(_0xbfb48e,null))[_0x77f2('0x22')](respondWithResult(_0xbfb48e,null))[_0x77f2('0x2d')](handleError(_0xbfb48e,null));};exports[_0x77f2('0x67')]=function(_0x1c60c1,_0x20492c){return db[_0x77f2('0x46')][_0x77f2('0x67')](_0x1c60c1[_0x77f2('0x68')],{'raw':![],'individualHooks':!![]})[_0x77f2('0x22')](respondWithResult(_0x20492c,0xc9))['catch'](handleError(_0x20492c,null));};exports[_0x77f2('0x37')]=function(_0x56e137,_0x1f04a6){if(_0x56e137[_0x77f2('0x68')]['id']){delete _0x56e137[_0x77f2('0x68')]['id'];}delete _0x56e137[_0x77f2('0x68')]['role'];return db[_0x77f2('0x46')][_0x77f2('0x41')]({'where':{'id':_0x56e137[_0x77f2('0x64')]['id']}})[_0x77f2('0x22')](handleEntityNotFound(_0x1f04a6,null))[_0x77f2('0x22')](saveUpdates(_0x56e137[_0x77f2('0x68')],null))[_0x77f2('0x22')](respondWithResult(_0x1f04a6,null))[_0x77f2('0x2d')](handleError(_0x1f04a6,null));};exports['describe']=function(_0x4cffc7,_0x46510f){return db[_0x77f2('0x46')][_0x77f2('0x69')]()[_0x77f2('0x22')](respondWithResult(_0x46510f,null))[_0x77f2('0x2d')](handleError(_0x46510f,null));};exports[_0x77f2('0x6a')]=function(_0x35117c,_0x5c4c29,_0x583f6d){return db[_0x77f2('0x46')]['find']({'where':{'id':_0x35117c['params']['id']}})[_0x77f2('0x22')](handleEntityNotFound(_0x5c4c29,null))[_0x77f2('0x22')](function(_0x30baba){if(_0x30baba){return _0x30baba[_0x77f2('0x6a')](_0x35117c[_0x77f2('0x68')][_0x77f2('0x6b')],_[_0x77f2('0x6c')](_0x35117c[_0x77f2('0x68')],['ids','id'])||{});}})[_0x77f2('0x22')](respondWithResult(_0x5c4c29,null))['catch'](handleError(_0x5c4c29,null));};var getLicense=function(_0x4c5a2e){return new BPromise(function(_0xcc96bd,_0x564164){var _0x189dca=0x0;_0x4c5a2e[_0x77f2('0x68')][_0x77f2('0x42')]===_0x77f2('0x6d')&&_0xcc96bd(_0x77f2('0x6e'));return db[_0x77f2('0x46')]['count']({'where':{'$or':[{'role':_0x4c5a2e['body'][_0x77f2('0x42')]===_0x77f2('0x6f')?_0x77f2('0x6f'):[_0x77f2('0x70'),'user']}]}})[_0x77f2('0x22')](function(_0x430d77){_0x189dca=_0x430d77;return require(_0x77f2('0x71'))[_0x77f2('0x72')]();})[_0x77f2('0x22')](function(_0x2a515b){var _0x4bff44=_0x4c5a2e[_0x77f2('0x68')][_0x77f2('0x42')]===_0x77f2('0x6f')?'telephones':_0x77f2('0x73');if(!_['isNil'](_0x2a515b[_0x4bff44])&&_0x189dca>=_0x2a515b[_0x4bff44]){return _0x564164({'message':_0x77f2('0x74')});}return _0xcc96bd(util[_0x77f2('0x75')](_0x77f2('0x76'),_0x4bff44,_0x189dca));})[_0x77f2('0x2d')](function(_0xfadaf8){return _0x564164(_0xfadaf8);});});};exports[_0x77f2('0x77')]=function(_0x331a82,_0x57f9f8){return getLicense(_0x331a82)[_0x77f2('0x22')](function(_0x1f2a28){if(!_0x331a82['body']['internal']){var _0x2d08ba;return db[_0x77f2('0x78')][_0x77f2('0x79')](0x1)[_0x77f2('0x22')](function(_0x334aa0){return checkPasswordPattern(_0x334aa0,_0x331a82['body']['password'],_0x334aa0[_0x77f2('0x7a')]);})[_0x77f2('0x22')](function(_0x39f975){_0x2d08ba=_0x39f975['min_internal'];return db[_0x77f2('0x46')][_0x77f2('0x7b')](_0x77f2('0x7c'));})[_0x77f2('0x22')](function(_0x5bef86){if(_[_0x77f2('0x7d')](_0x5bef86)){if(_0x2d08ba){_0x331a82[_0x77f2('0x68')]['internal']=_0x2d08ba;}else{_0x331a82[_0x77f2('0x68')][_0x77f2('0x7c')]=0x1;}}else{if(_[_0x77f2('0x7d')](_0x2d08ba)||_0x2d08ba==_0x5bef86){_0x331a82[_0x77f2('0x68')]['internal']=_0x5bef86+0x1;}else if(_0x2d08ba>_0x5bef86){_0x331a82['body'][_0x77f2('0x7c')]=_0x2d08ba;}else{return db[_0x77f2('0x5e')][_0x77f2('0x4f')](_0x77f2('0x7e'),{'type':db[_0x77f2('0x5e')][_0x77f2('0x7f')][_0x77f2('0x80')]})[_0x77f2('0x22')](function(_0x4ac515){if(_0x4ac515&&_0x4ac515[_0x77f2('0x65')]){for(var _0x5004af=0x0,_0x5eb455=_0x4ac515[_0x77f2('0x65')];_0x5004af<_0x5eb455&&_[_0x77f2('0x7d')](_0x331a82['body'][_0x77f2('0x7c')]);_0x5004af++){if(_0x2d08ba<=_0x4ac515[_0x5004af][_0x77f2('0x81')]){_0x331a82[_0x77f2('0x68')][_0x77f2('0x7c')]=_0x4ac515[_0x5004af][_0x77f2('0x81')];}else if(_0x2d08ba>_0x4ac515[_0x5004af][_0x77f2('0x81')]&&_0x2d08ba<=_0x4ac515[_0x5004af]['to']){_0x331a82[_0x77f2('0x68')][_0x77f2('0x7c')]=_0x2d08ba;}}}if(_['isNil'](_0x331a82[_0x77f2('0x68')][_0x77f2('0x7c')])){_0x331a82['body']['internal']=_0x5bef86+0x1;}});}}});}})[_0x77f2('0x22')](function(){if(_0x331a82['body'][_0x77f2('0x82')]){_0x331a82['body']['mailbox']=_0x331a82[_0x77f2('0x68')][_0x77f2('0x7c')];_0x331a82[_0x77f2('0x68')][_0x77f2('0x83')]={'mailbox':_0x331a82[_0x77f2('0x68')][_0x77f2('0x7c')],'password':_0x331a82[_0x77f2('0x68')]['password'],'fullname':_0x331a82[_0x77f2('0x68')][_0x77f2('0x84')],'email':_0x331a82['body'][_0x77f2('0x85')]};}if(_0x331a82[_0x77f2('0x68')]&&_0x331a82[_0x77f2('0x68')][_0x77f2('0x42')]===_0x77f2('0x6d')){if(!_0x331a82['body']['permissions']){_0x331a82[_0x77f2('0x68')][_0x77f2('0x86')]=[_0x77f2('0x87'),_0x77f2('0x88'),_0x77f2('0x89'),_0x77f2('0x8a'),_0x77f2('0x8b'),'104',_0x77f2('0x8c'),'106','107','108','109',_0x77f2('0x8d'),_0x77f2('0x8e'),_0x77f2('0x8f')];}}return db[_0x77f2('0x46')][_0x77f2('0x77')](_0x331a82[_0x77f2('0x68')],{'include':[{'model':db[_0x77f2('0x83')],'as':_0x77f2('0x83')}]});})[_0x77f2('0x22')](function(_0x334264){if(_0x331a82[_0x77f2('0x68')]['role']===_0x77f2('0x3a'))return _0x334264;var _0xac0d40=_0x331a82[_0x77f2('0x3a')][_0x77f2('0x90')]({'plain':!![]});if(!_0xac0d40)throw new Error(_0x77f2('0x91'));if(_0xac0d40[_0x77f2('0x42')]===_0x77f2('0x3a')){var _0xa18b6e=_0x334264[_0x77f2('0x90')]({'plain':!![]});var _0x10bfa4=[{'name':_0x77f2('0x3b'),'value':_0x77f2('0x6d')},{'name':'Telephones','value':_0x77f2('0x6f')}];var _0xcd1879=_[_0x77f2('0x41')](_0x10bfa4,[_0x77f2('0x3f'),_0xa18b6e['role']])[_0x77f2('0x45')];return db[_0x77f2('0x92')]['find']({'where':{'name':_0xcd1879,'userProfileId':_0xac0d40[_0x77f2('0x93')]},'raw':!![]})[_0x77f2('0x22')](function(_0x230c3f){if(_0x230c3f&&_0x230c3f[_0x77f2('0x94')]===0x0){return db[_0x77f2('0x43')][_0x77f2('0x77')]({'name':_0xa18b6e[_0x77f2('0x45')],'resourceId':_0xa18b6e['id'],'type':_0x230c3f[_0x77f2('0x45')],'sectionId':_0x230c3f['id']},{})[_0x77f2('0x22')](function(){return _0x334264;});}else{return _0x334264;}})[_0x77f2('0x2d')](function(_0x3df5f2){logger[_0x77f2('0x29')](_0x77f2('0x95'),_0x3df5f2);throw _0x3df5f2;});}return _0x334264;})[_0x77f2('0x22')](respondWithResult(_0x57f9f8,0xc9))[_0x77f2('0x2d')](handleError(_0x57f9f8,null));};exports[_0x77f2('0x96')]=function(_0x50cba1,_0x68765f,_0x1402a9){var _0x3ba126=![];if(_0x50cba1[_0x77f2('0x68')]['id']){delete _0x50cba1[_0x77f2('0x68')]['id'];}return db['Setting'][_0x77f2('0x97')]({'attributes':['id',_0x77f2('0x7a')]})['then'](function(_0x30a920){_0x3ba126=_0x30a920[_0x77f2('0x7a')];return db[_0x77f2('0x46')][_0x77f2('0x41')]({'where':{'id':_0x50cba1[_0x77f2('0x64')]['id']}});})[_0x77f2('0x22')](function(_0x65a1c7){if(_0x65a1c7){if(_0x65a1c7['id']==_0x50cba1[_0x77f2('0x3a')]['id']){if(!_0x50cba1[_0x77f2('0x68')][_0x77f2('0x98')]||!_0x50cba1['body'][_0x77f2('0x99')]){throw new db[(_0x77f2('0x1f'))][(_0x77f2('0x20'))]('Invalid\x20body\x20format.\x20Use\x20oldPassord\x20and\x20newPassword');}if(!_0x65a1c7[_0x77f2('0x9a')](_0x50cba1[_0x77f2('0x68')][_0x77f2('0x98')])){throw new db[(_0x77f2('0x1f'))]['ValidationError'](_0x77f2('0x9b'));}if(_0x50cba1[_0x77f2('0x68')]['oldPassword']==_0x50cba1['body']['newPassword']){throw new db['Sequelize'][(_0x77f2('0x20'))](_0x77f2('0x9c'));}return _0x65a1c7;}else if(_0x50cba1[_0x77f2('0x3a')]['role']=='admin'){if(!_0x50cba1[_0x77f2('0x68')][_0x77f2('0x99')]){throw new db['Sequelize'][(_0x77f2('0x20'))]('Invalid\x20body\x20format.\x20Use\x20newPassword');}return _0x65a1c7;}else if(_0x50cba1['user'][_0x77f2('0x42')]==_0x77f2('0x3a')){if(!_0x50cba1[_0x77f2('0x68')][_0x77f2('0x99')]){throw new db[(_0x77f2('0x1f'))][(_0x77f2('0x20'))](_0x77f2('0x9d'));}if(_0x65a1c7[_0x77f2('0x42')]!='agent'){throw new db['Sequelize'][(_0x77f2('0x20'))](_0x77f2('0x9e'));}return _0x65a1c7;}else{throw new db[(_0x77f2('0x1f'))][(_0x77f2('0x20'))]('Unauthorized');}}return null;})[_0x77f2('0x22')](handleEntityNotFound(_0x68765f,null))[_0x77f2('0x22')](function(_0x88d988){return checkPasswordPattern(_0x88d988,_0x50cba1[_0x77f2('0x68')]['newPassword'],_0x3ba126);})[_0x77f2('0x22')](saveUpdates({'password':_0x50cba1[_0x77f2('0x68')][_0x77f2('0x99')],'passwordResetAt':_0x50cba1[_0x77f2('0x3a')]['id']==_0x50cba1[_0x77f2('0x64')]['id']?moment():null},null))[_0x77f2('0x22')](respondWithResult(_0x68765f,null))[_0x77f2('0x2d')](handleError(_0x68765f,null));};exports[_0x77f2('0x9f')]=function(_0x559e28,_0x25ba64,_0x4f5094){var _0x29b70c=_0x559e28[_0x77f2('0x68')][_0x77f2('0xa0')];return db[_0x77f2('0x46')]['find']({'where':{'id':_0x559e28[_0x77f2('0x64')]['id']},'attributes':['id','name',_0x77f2('0x42'),_0x77f2('0xa1'),'loginInPause',_0x77f2('0xa2'),_0x77f2('0xa3')]})[_0x77f2('0x22')](handleEntityNotFound(_0x25ba64,null))['then'](function(_0x5c0142){if(_0x5c0142){if(!utils['isValidChannel'](_0x29b70c)){throw new db[(_0x77f2('0x1f'))][(_0x77f2('0x20'))](_0x77f2('0xa4'));}return _0x5c0142[_0x77f2('0xa5')+_[_0x77f2('0xa6')](_0x29b70c[_0x77f2('0xa7')]())+_0x77f2('0xa8')](_0x559e28[_0x77f2('0x68')][_0x77f2('0x6b')],{'penalty':_0x559e28[_0x77f2('0x68')][_0x77f2('0xa9')]||0x0})[_0x77f2('0xaa')](function(_0x3960ed){for(var _0x145c0f=0x0;_0x145c0f<_0x559e28[_0x77f2('0x68')]['ids']['length'];_0x145c0f+=0x1){var _0x98a0b6={'UserId':_0x559e28[_0x77f2('0x64')]['id']};_0x98a0b6[_['capitalize'](_0x29b70c[_0x77f2('0xa7')]())+_0x77f2('0xab')]=_0x559e28['body']['ids'][_0x145c0f];socket[_0x77f2('0xac')](_0x77f2('0x3a')+_[_0x77f2('0xa6')](_0x29b70c['toLowerCase']())+'Queue:save',_0x98a0b6);}return _0x3960ed;})[_0x77f2('0x22')](function(){if(_0x29b70c===_0x77f2('0xad')){return db[_0x77f2('0xae')][_0x77f2('0xaf')]({'where':{'id':_0x559e28[_0x77f2('0x68')]['ids']||[]},'raw':!![],'attributes':['id',_0x77f2('0x45')]});}})[_0x77f2('0x22')](function(_0x1d2bcc){var _0x4fb5e3=_0x5c0142[_0x77f2('0x90')]({'plain':!![]});var _0x3e7208=[];if(_0x29b70c===_0x77f2('0xad')&&_0x4fb5e3[_0x77f2('0x42')]===_0x77f2('0x6d')&&_0x4fb5e3['online']){for(var _0x2c54d1=0x0;_0x2c54d1<_0x1d2bcc['length'];_0x2c54d1+=0x1){_0x3e7208[_0x77f2('0xb0')]({'membername':_0x4fb5e3['name'],'UserId':_0x4fb5e3['id'],'queue_name':_0x1d2bcc[_0x2c54d1][_0x77f2('0x45')],'VoiceQueueId':_0x1d2bcc[_0x2c54d1]['id'],'interface':_[_0x77f2('0x7d')](_0x4fb5e3[_0x77f2('0xa3')])?util['format'](_0x77f2('0xb1'),_0x4fb5e3['name']):_0x4fb5e3[_0x77f2('0xa3')],'paused':_0x4fb5e3['voicePause']||![],'penalty':_0x559e28[_0x77f2('0x68')][_0x77f2('0xa9')]||0x0});}return BPromise['each'](_0x3e7208,function(_0x139102){return db[_0x77f2('0xb2')][_0x77f2('0xb3')](_0x139102);});}return _0x5c0142;});}})[_0x77f2('0x22')](respondWithStatusCode(_0x25ba64,null))[_0x77f2('0x2d')](handleError(_0x25ba64,null));};exports[_0x77f2('0xb4')]=function(_0x2591fa,_0x15ae54,_0x2ed98e){var _0xc6cd28;return db['User'][_0x77f2('0x41')]({'where':{'id':_0x2591fa['params']['id']},'attributes':['id','name',_0x77f2('0x42')]})[_0x77f2('0x22')](handleEntityNotFound(_0x15ae54,null))[_0x77f2('0x22')](function(_0x2072d){if(_0x2072d){_0xc6cd28=_0x2072d;if(!_0x2591fa[_0x77f2('0x4f')][_0x77f2('0xa0')]||!utils[_0x77f2('0xb5')](_0x2591fa[_0x77f2('0x4f')]['channel'])){throw new db[(_0x77f2('0x1f'))]['ValidationError'](_0x77f2('0xa4'));}return _0x2072d[_0x77f2('0xb6')+_[_0x77f2('0xa6')](_0x2591fa[_0x77f2('0x4f')][_0x77f2('0xa0')][_0x77f2('0xa7')]())+'Queues'](_0x2591fa[_0x77f2('0x4f')]['ids']);}})[_0x77f2('0x22')](function(_0x132237){for(var _0x34c6f3=0x0;_0x34c6f3<_0x2591fa['query']['ids'][_0x77f2('0x65')];_0x34c6f3+=0x1){var _0x43eb82={'UserId':_0x2591fa[_0x77f2('0x64')]['id']};_0x43eb82[_[_0x77f2('0xa6')](_0x2591fa[_0x77f2('0x4f')][_0x77f2('0xa0')][_0x77f2('0xa7')]())+_0x77f2('0xab')]=_0x2591fa[_0x77f2('0x4f')][_0x77f2('0x6b')][_0x34c6f3];socket[_0x77f2('0xac')]('user'+_[_0x77f2('0xa6')](_0x2591fa[_0x77f2('0x4f')][_0x77f2('0xa0')][_0x77f2('0xa7')]())+_0x77f2('0xb7'),_0x43eb82);}return _0x132237;})[_0x77f2('0x22')](function(){if(_0x2591fa[_0x77f2('0x4f')][_0x77f2('0xa0')]==='voice'){return db[_0x77f2('0xb2')][_0x77f2('0x38')]({'where':{'UserId':_0x2591fa['params']['id'],'VoiceQueueId':_0x2591fa[_0x77f2('0x4f')][_0x77f2('0x6b')]},'individualHooks':!![]})['then'](function(){return _0xc6cd28;});}return _0xc6cd28;})[_0x77f2('0x22')](respondWithStatusCode(_0x15ae54,null))[_0x77f2('0x2d')](handleError(_0x15ae54,null));};exports[_0x77f2('0xb8')]=function(_0x2e018d,_0x1c455d,_0x197742){_0x2e018d['body'][_0x77f2('0xb9')]=_0x2e018d[_0x77f2('0xba')][_0x77f2('0xbb')];return db[_0x77f2('0x46')]['find']({'where':{'id':_0x2e018d[_0x77f2('0x64')]['id']}})[_0x77f2('0x22')](handleEntityNotFound(_0x1c455d,null))['then'](saveUpdates(_0x2e018d[_0x77f2('0x68')],null))[_0x77f2('0x22')](respondWithResult(_0x1c455d,null))[_0x77f2('0x2d')](handleError(_0x1c455d,null));};exports[_0x77f2('0xbc')]=function(_0x1df6b1,_0x277394,_0x32918d){var _0x19a0f8=path[_0x77f2('0xbd')](config[_0x77f2('0xbe')],_0x77f2('0xbf'));return db[_0x77f2('0x46')]['find']({'where':{'id':_0x1df6b1['params']['id']},'attributes':['id',_0x77f2('0xb9')],'raw':!![]})[_0x77f2('0x22')](handleEntityNotFound(_0x277394,null))[_0x77f2('0x22')](function(_0x6f7e49){if(_0x6f7e49){if(_[_0x77f2('0x7d')](_0x6f7e49[_0x77f2('0xb9')])){return _0x277394[_0x77f2('0xc0')](_0x19a0f8);}else{if(!fs[_0x77f2('0xc1')](path['join'](config['root'],_0x77f2('0xc2'),_0x6f7e49[_0x77f2('0xb9')]))){return _0x277394[_0x77f2('0xc0')](_0x19a0f8);}return _0x277394['download'](path[_0x77f2('0xbd')](config[_0x77f2('0xbe')],_0x77f2('0xc2'),_0x6f7e49[_0x77f2('0xb9')]));}}})[_0x77f2('0x2d')](handleError(_0x277394,null));};exports['getContacts']=function(_0x2e5300,_0x4afb67,_0x170fbd){var _0x15dcc3={};var _0x489400={};var _0xa7adf3;var _0x36cc41;return db[_0x77f2('0x46')]['findOne']({'where':{'id':_0x2e5300['params']['id']}})[_0x77f2('0x22')](handleEntityNotFound(_0x4afb67,null))[_0x77f2('0x22')](function(_0x34c8f9){if(_0x34c8f9){_0xa7adf3=_0x34c8f9;_0x489400[_0x77f2('0x4b')]=_[_0x77f2('0x50')](db[_0x77f2('0xc3')][_0x77f2('0x47')]);_0x489400['query']=_[_0x77f2('0x50')](_0x2e5300[_0x77f2('0x4f')]);_0x489400[_0x77f2('0x51')]=_[_0x77f2('0x53')](_0x489400['model'],_0x489400[_0x77f2('0x4f')]);_0x15dcc3[_0x77f2('0x52')]=_['intersection'](_0x489400[_0x77f2('0x4b')],qs[_0x77f2('0x54')](_0x2e5300[_0x77f2('0x4f')][_0x77f2('0x54')]));_0x15dcc3['attributes']=_0x15dcc3['attributes'][_0x77f2('0x65')]?_0x15dcc3['attributes']:_0x489400[_0x77f2('0x4b')];_0x15dcc3[_0x77f2('0x57')]=qs[_0x77f2('0x58')](_0x2e5300['query']['sort']);_0x15dcc3[_0x77f2('0x59')]=qs['filters'](_['pick'](_0x2e5300['query'],_0x489400[_0x77f2('0x51')]));if(_0x2e5300['query'][_0x77f2('0x5b')]){_0x15dcc3['where']=_[_0x77f2('0x5c')](_0x15dcc3['where'],{'$or':_['map'](_0x15dcc3[_0x77f2('0x52')],function(_0x153d9a){var _0x4f8a70={};_0x4f8a70[_0x153d9a]={'$like':'%'+_0x2e5300[_0x77f2('0x4f')]['filter']+'%'};return _0x4f8a70;})});}_0x15dcc3=_[_0x77f2('0x5c')]({},_0x15dcc3,_0x2e5300['options']);return _0xa7adf3[_0x77f2('0xc4')](_0x15dcc3);}})['then'](function(_0x17c80b){if(_0x17c80b){_0x36cc41=_0x17c80b[_0x77f2('0x65')];if(_0x2e5300[_0x77f2('0x4f')][_0x77f2('0x55')](_0x77f2('0x61'))){_0x15dcc3[_0x77f2('0x62')]=[{'model':db[_0x77f2('0xc5')],'as':_0x77f2('0xc6'),'required':![]},{'model':db['Tag'],'as':_0x77f2('0xc7'),'attributes':['id',_0x77f2('0x45'),'color'],'where':_0x2e5300['query'][_0x77f2('0xc8')]?{'id':_0x2e5300['query']['tag']}:undefined,'required':_0x2e5300[_0x77f2('0x4f')][_0x77f2('0xc8')]?!![]:![]}];}if(!_0x2e5300['query'][_0x77f2('0x55')](_0x77f2('0x56'))){_0x15dcc3[_0x77f2('0x33')]=qs[_0x77f2('0x33')](_0x2e5300['query'][_0x77f2('0x33')]);_0x15dcc3[_0x77f2('0x32')]=qs['offset'](_0x2e5300[_0x77f2('0x4f')]['offset']);}return _0xa7adf3['getContacts'](_0x15dcc3);}})[_0x77f2('0x22')](function(_0x35e8da){if(_0x35e8da){return _0x35e8da?{'count':_0x36cc41,'rows':_0x35e8da}:null;}})[_0x77f2('0x22')](respondWithResult(_0x4afb67,null))[_0x77f2('0x2d')](handleError(_0x4afb67,null));};exports[_0x77f2('0xc9')]=function(_0x5751e4,_0x4c225b,_0x46257b){var _0x3c156b;var _0x581802;var _0x5bd0f3={};var _0x2630fb;return db['User'][_0x77f2('0x97')]({'where':{'id':_0x5751e4['params']['id']},'attributes':['id',_0x77f2('0x45'),_0x77f2('0x42')]})[_0x77f2('0x22')](handleEntityNotFound(_0x4c225b,null))[_0x77f2('0x22')](function(_0x4b254c){if(!utils[_0x77f2('0xb5')](_0x5751e4[_0x77f2('0x4f')][_0x77f2('0xa0')])){throw new db[(_0x77f2('0x1f'))][(_0x77f2('0x20'))](_0x77f2('0xa4'));}_0x3c156b=_0x4b254c;var _0x2132fa={};_0x2132fa['model']=_[_0x77f2('0x50')](db[_[_0x77f2('0xa6')](_0x5751e4[_0x77f2('0x4f')][_0x77f2('0xa0')])+_0x77f2('0xca')]['rawAttributes']);_0x2132fa[_0x77f2('0x4f')]=_['keys'](_0x5751e4[_0x77f2('0x4f')]);_0x2132fa[_0x77f2('0x51')]=_[_0x77f2('0x53')](_0x2132fa[_0x77f2('0x4b')],_0x2132fa[_0x77f2('0x4f')]);_0x5bd0f3[_0x77f2('0x52')]=_[_0x77f2('0x53')](_0x2132fa['model'],qs[_0x77f2('0x54')](_0x5751e4['query'][_0x77f2('0x54')]));_0x5bd0f3[_0x77f2('0x52')]=_0x5bd0f3[_0x77f2('0x52')][_0x77f2('0x65')]?_0x5bd0f3['attributes']:_0x2132fa['model'];_0x5bd0f3[_0x77f2('0x57')]=qs[_0x77f2('0x58')](_0x5751e4[_0x77f2('0x4f')]['sort']);_0x5bd0f3[_0x77f2('0x59')]=qs[_0x77f2('0x51')](_[_0x77f2('0x5a')](_0x5751e4['query'],_0x2132fa[_0x77f2('0x51')]));if(_0x5751e4['query']['filter']){_0x5bd0f3['where']=_[_0x77f2('0x5c')](_0x5bd0f3[_0x77f2('0x59')],{'$or':_[_0x77f2('0x3e')](_0x5bd0f3[_0x77f2('0x52')],function(_0x18c51d){var _0x50ed79={};_0x50ed79[_0x18c51d]={'$like':'%'+_0x5751e4[_0x77f2('0x4f')]['filter']+'%'};return _0x50ed79;})});}_0x5bd0f3=_[_0x77f2('0x5c')]({},_0x5bd0f3,_0x5751e4['options']);switch(_0x3c156b[_0x77f2('0x42')]){case _0x77f2('0x70'):return db[_[_0x77f2('0xa6')](_0x5751e4[_0x77f2('0x4f')][_0x77f2('0xa0')])+_0x77f2('0xca')][_0x77f2('0xaf')](_0x5bd0f3);case _0x77f2('0x3a'):case'agent':return _0x3c156b[_0x77f2('0x90')+_['capitalize'](_0x5751e4['query']['channel'])+'Queues'](_0x5bd0f3);default:throw new db['Sequelize']['ValidationError']('Unknown\x20role');}})[_0x77f2('0x22')](function(_0x4410a4){_0x2630fb=_0x4410a4[_0x77f2('0x65')];if(!_0x5751e4[_0x77f2('0x4f')][_0x77f2('0x55')](_0x77f2('0x56'))){_0x5bd0f3['limit']=qs[_0x77f2('0x33')](_0x5751e4[_0x77f2('0x4f')]['limit']);_0x5bd0f3[_0x77f2('0x32')]=qs[_0x77f2('0x32')](_0x5751e4['query']['offset']);}switch(_0x3c156b[_0x77f2('0x42')]){case _0x77f2('0x70'):return db[_['capitalize'](_0x5751e4['query'][_0x77f2('0xa0')])+'Queue'][_0x77f2('0xaf')](_0x5bd0f3);case _0x77f2('0x3a'):case'agent':return _0x3c156b[_0x77f2('0x90')+_[_0x77f2('0xa6')](_0x5751e4['query'][_0x77f2('0xa0')])+'Queues'](_0x5bd0f3);}})[_0x77f2('0x22')](function(_0x5da5e0){return{'count':_0x2630fb,'rows':_0x5da5e0};})[_0x77f2('0x22')](respondWithResult(_0x4c225b,null))[_0x77f2('0x2d')](handleError(_0x4c225b,null));};exports['getVoiceQueuesRt']=function(_0x4e4d0f,_0x4bb815,_0x45deaf){var _0x5e4448={};var _0xfcbb2d={};var _0x29fbc7;var _0x4b91e6;return db[_0x77f2('0x46')][_0x77f2('0x97')]({'where':{'id':_0x4e4d0f[_0x77f2('0x64')]['id']}})[_0x77f2('0x22')](handleEntityNotFound(_0x4bb815,null))[_0x77f2('0x22')](function(_0x5499a8){if(_0x5499a8){_0x29fbc7=_0x5499a8;_0xfcbb2d[_0x77f2('0x4b')]=_[_0x77f2('0x50')](db['UserVoiceQueueRt']['rawAttributes']);_0xfcbb2d[_0x77f2('0x4f')]=_['keys'](_0x4e4d0f[_0x77f2('0x4f')]);_0xfcbb2d[_0x77f2('0x51')]=_[_0x77f2('0x53')](_0xfcbb2d[_0x77f2('0x4b')],_0xfcbb2d[_0x77f2('0x4f')]);_0x5e4448[_0x77f2('0x52')]=_[_0x77f2('0x53')](_0xfcbb2d['model'],qs[_0x77f2('0x54')](_0x4e4d0f[_0x77f2('0x4f')][_0x77f2('0x54')]));_0x5e4448[_0x77f2('0x52')]=_0x5e4448[_0x77f2('0x52')][_0x77f2('0x65')]?_0x5e4448['attributes']:_0xfcbb2d['model'];_0x5e4448[_0x77f2('0x57')]=qs['sort'](_0x4e4d0f['query'][_0x77f2('0x58')]);_0x5e4448['where']=qs[_0x77f2('0x51')](_['pick'](_0x4e4d0f[_0x77f2('0x4f')],_0xfcbb2d[_0x77f2('0x51')]));if(_0x4e4d0f[_0x77f2('0x4f')]['filter']){_0x5e4448['where']=_[_0x77f2('0x5c')](_0x5e4448['where'],{'$or':_[_0x77f2('0x3e')](_0x5e4448['attributes'],function(_0xb0f742){var _0x558ece={};_0x558ece[_0xb0f742]={'$like':'%'+_0x4e4d0f[_0x77f2('0x4f')][_0x77f2('0x5b')]+'%'};return _0x558ece;})});}_0x5e4448=_[_0x77f2('0x5c')]({},_0x5e4448,_0x4e4d0f[_0x77f2('0x66')]);return _0x29fbc7[_0x77f2('0xcb')](_0x5e4448);}})['then'](function(_0x4001b){if(_0x4001b){_0x4b91e6=_0x4001b[_0x77f2('0x65')];if(!_0x4e4d0f[_0x77f2('0x4f')]['hasOwnProperty'](_0x77f2('0x56'))){_0x5e4448[_0x77f2('0x33')]=qs[_0x77f2('0x33')](_0x4e4d0f[_0x77f2('0x4f')]['limit']);_0x5e4448[_0x77f2('0x32')]=qs[_0x77f2('0x32')](_0x4e4d0f[_0x77f2('0x4f')]['offset']);}return _0x29fbc7[_0x77f2('0xcb')](_0x5e4448);}})[_0x77f2('0x22')](function(_0x193bd3){if(_0x193bd3){return _0x193bd3?{'count':_0x4b91e6,'rows':_0x193bd3}:null;}})[_0x77f2('0x22')](respondWithResult(_0x4bb815,null))[_0x77f2('0x2d')](handleError(_0x4bb815,null));};exports[_0x77f2('0xcc')]=function(_0x46bb8f,_0x1eeba9,_0x3f7b72){var _0x58c6bb={};var _0x3272d7={};var _0x17c8f3;var _0x445adf;return db[_0x77f2('0x46')][_0x77f2('0x97')]({'where':{'id':_0x46bb8f['params']['id']}})[_0x77f2('0x22')](handleEntityNotFound(_0x1eeba9,null))['then'](function(_0x2c013b){if(_0x2c013b){_0x17c8f3=_0x2c013b;_0x3272d7[_0x77f2('0x4b')]=_[_0x77f2('0x50')](db['ChatGroup'][_0x77f2('0x47')]);_0x3272d7['query']=_[_0x77f2('0x50')](_0x46bb8f[_0x77f2('0x4f')]);_0x3272d7[_0x77f2('0x51')]=_['intersection'](_0x3272d7['model'],_0x3272d7[_0x77f2('0x4f')]);_0x58c6bb['attributes']=_[_0x77f2('0x53')](_0x3272d7['model'],qs['fields'](_0x46bb8f[_0x77f2('0x4f')][_0x77f2('0x54')]));_0x58c6bb[_0x77f2('0x52')]=_0x58c6bb[_0x77f2('0x52')][_0x77f2('0x65')]?_0x58c6bb[_0x77f2('0x52')]:_0x3272d7[_0x77f2('0x4b')];_0x58c6bb[_0x77f2('0x57')]=qs[_0x77f2('0x58')](_0x46bb8f[_0x77f2('0x4f')]['sort']);_0x58c6bb[_0x77f2('0x59')]=qs[_0x77f2('0x51')](_[_0x77f2('0x5a')](_0x46bb8f[_0x77f2('0x4f')],_0x3272d7['filters']));if(_0x46bb8f[_0x77f2('0x4f')][_0x77f2('0x5b')]){_0x58c6bb[_0x77f2('0x59')]=_[_0x77f2('0x5c')](_0x58c6bb[_0x77f2('0x59')],{'$or':_[_0x77f2('0x3e')](_0x58c6bb[_0x77f2('0x52')],function(_0x149cc0){var _0x45bd6e={};_0x45bd6e[_0x149cc0]={'$like':'%'+_0x46bb8f[_0x77f2('0x4f')][_0x77f2('0x5b')]+'%'};return _0x45bd6e;})});}_0x58c6bb=_['merge']({},_0x58c6bb,_0x46bb8f[_0x77f2('0x66')]);return _0x17c8f3['getGroups'](_0x58c6bb);}})[_0x77f2('0x22')](function(_0x5f10f1){if(_0x5f10f1){_0x445adf=_0x5f10f1[_0x77f2('0x65')];if(!_0x46bb8f['query']['hasOwnProperty'](_0x77f2('0x56'))){_0x58c6bb[_0x77f2('0x33')]=qs[_0x77f2('0x33')](_0x46bb8f[_0x77f2('0x4f')]['limit']);_0x58c6bb[_0x77f2('0x32')]=qs[_0x77f2('0x32')](_0x46bb8f['query'][_0x77f2('0x32')]);}return _0x17c8f3['getGroups'](_0x58c6bb);}})[_0x77f2('0x22')](function(_0x212354){if(_0x212354){return _0x212354?{'count':_0x445adf,'rows':_0x212354}:null;}})[_0x77f2('0x22')](respondWithResult(_0x1eeba9,null))[_0x77f2('0x2d')](handleError(_0x1eeba9,null));};exports[_0x77f2('0xcd')]=function(_0x1307eb,_0xd8fc4c,_0x2a7ab1){var _0x25c8de={'raw':!![],'where':{}};var _0x53a18b={};var _0x32edc4={'count':0x0,'rows':[]};return db[_0x77f2('0x46')]['findOne']({'where':{'id':_0x1307eb[_0x77f2('0x64')]['id']}})[_0x77f2('0x22')](handleEntityNotFound(_0xd8fc4c,null))[_0x77f2('0x22')](function(_0x2a2c49){if(_0x2a2c49){_0x53a18b['model']=_[_0x77f2('0x50')](db[_0x77f2('0xce')]['rawAttributes']);_0x53a18b['query']=_[_0x77f2('0x50')](_0x1307eb[_0x77f2('0x4f')]);_0x53a18b['filters']=_[_0x77f2('0x53')](_0x53a18b[_0x77f2('0x4b')],_0x53a18b[_0x77f2('0x4f')]);_0x25c8de['attributes']=_[_0x77f2('0x53')](_0x53a18b[_0x77f2('0x4b')],qs[_0x77f2('0x54')](_0x1307eb['query'][_0x77f2('0x54')]));_0x25c8de[_0x77f2('0x52')]=_0x25c8de[_0x77f2('0x52')][_0x77f2('0x65')]?_0x25c8de[_0x77f2('0x52')]:_0x53a18b[_0x77f2('0x4b')];if(!_0x1307eb[_0x77f2('0x4f')][_0x77f2('0x55')](_0x77f2('0x56'))){_0x25c8de[_0x77f2('0x33')]=qs[_0x77f2('0x33')](_0x1307eb[_0x77f2('0x4f')][_0x77f2('0x33')]);_0x25c8de[_0x77f2('0x32')]=qs[_0x77f2('0x32')](_0x1307eb[_0x77f2('0x4f')][_0x77f2('0x32')]);}_0x25c8de[_0x77f2('0x57')]=qs[_0x77f2('0x58')](_0x1307eb[_0x77f2('0x4f')][_0x77f2('0x58')]);_0x25c8de[_0x77f2('0x59')]=qs[_0x77f2('0x51')](_[_0x77f2('0x5a')](_0x1307eb['query'],_0x53a18b[_0x77f2('0x51')]));_0x25c8de['where'][_0x77f2('0xcf')]=_0x2a2c49['id'];if(_0x1307eb[_0x77f2('0x4f')][_0x77f2('0x5b')]){_0x25c8de[_0x77f2('0x59')]=_['merge'](_0x25c8de['where'],{'$or':_['map'](_0x25c8de[_0x77f2('0x52')],function(_0x2180ff){var _0xbd1f6c={};_0xbd1f6c[_0x2180ff]={'$like':'%'+_0x1307eb['query'][_0x77f2('0x5b')]+'%'};return _0xbd1f6c;})});}_0x25c8de=_[_0x77f2('0x5c')]({},_0x25c8de,_0x1307eb[_0x77f2('0x66')]);return db['VoiceRecording'][_0x77f2('0x60')]({'where':_0x25c8de[_0x77f2('0x59')]})['then'](function(_0x2fe3bc){_0x32edc4[_0x77f2('0x60')]=_0x2fe3bc;if(_0x1307eb[_0x77f2('0x4f')][_0x77f2('0x61')]){_0x25c8de[_0x77f2('0x62')]=[{'all':!![]}];}return db[_0x77f2('0xce')][_0x77f2('0xaf')](_0x25c8de);})[_0x77f2('0x22')](function(_0x71ba58){_0x32edc4[_0x77f2('0x63')]=_0x71ba58;return _0x32edc4;});}})['then'](respondWithFilteredResult(_0xd8fc4c,_0x25c8de))[_0x77f2('0x2d')](handleError(_0xd8fc4c,null));};exports['getScreenRecordings']=function(_0x2a74b9,_0x3cf025,_0x233acf){var _0x960e63={'raw':!![],'where':{}};var _0x195257={};var _0x5ea1f9={'count':0x0,'rows':[]};return db[_0x77f2('0x46')][_0x77f2('0x97')]({'where':{'id':_0x2a74b9[_0x77f2('0x64')]['id']}})[_0x77f2('0x22')](handleEntityNotFound(_0x3cf025,null))[_0x77f2('0x22')](function(_0x530bb0){if(_0x530bb0){_0x195257[_0x77f2('0x4b')]=_[_0x77f2('0x50')](db[_0x77f2('0xd0')]['rawAttributes']);_0x195257['query']=_['keys'](_0x2a74b9['query']);_0x195257['filters']=_[_0x77f2('0x53')](_0x195257[_0x77f2('0x4b')],_0x195257[_0x77f2('0x4f')]);_0x960e63[_0x77f2('0x52')]=_[_0x77f2('0x53')](_0x195257['model'],qs[_0x77f2('0x54')](_0x2a74b9[_0x77f2('0x4f')][_0x77f2('0x54')]));_0x960e63[_0x77f2('0x52')]=_0x960e63[_0x77f2('0x52')]['length']?_0x960e63['attributes']:_0x195257[_0x77f2('0x4b')];if(!_0x2a74b9['query'][_0x77f2('0x55')]('nolimit')){_0x960e63[_0x77f2('0x33')]=qs[_0x77f2('0x33')](_0x2a74b9['query']['limit']);_0x960e63[_0x77f2('0x32')]=qs['offset'](_0x2a74b9[_0x77f2('0x4f')]['offset']);}_0x960e63[_0x77f2('0x57')]=qs[_0x77f2('0x58')](_0x2a74b9[_0x77f2('0x4f')][_0x77f2('0x58')]);_0x960e63['where']=qs['filters'](_[_0x77f2('0x5a')](_0x2a74b9[_0x77f2('0x4f')],_0x195257[_0x77f2('0x51')]));_0x960e63[_0x77f2('0x59')]['UserId']=_0x530bb0['id'];if(_0x2a74b9[_0x77f2('0x4f')][_0x77f2('0x5b')]){_0x960e63['where']=_['merge'](_0x960e63[_0x77f2('0x59')],{'$or':_[_0x77f2('0x3e')](_0x960e63['attributes'],function(_0x3173b4){var _0x5c5cba={};_0x5c5cba[_0x3173b4]={'$like':'%'+_0x2a74b9[_0x77f2('0x4f')]['filter']+'%'};return _0x5c5cba;})});}_0x960e63=_[_0x77f2('0x5c')]({},_0x960e63,_0x2a74b9[_0x77f2('0x66')]);return db[_0x77f2('0xd0')][_0x77f2('0x60')]({'where':_0x960e63[_0x77f2('0x59')]})['then'](function(_0x15d3d8){_0x5ea1f9[_0x77f2('0x60')]=_0x15d3d8;if(_0x2a74b9[_0x77f2('0x4f')]['includeAll']){_0x960e63[_0x77f2('0x62')]=[{'all':!![]}];}return db[_0x77f2('0xd0')]['findAll'](_0x960e63);})[_0x77f2('0x22')](function(_0xe7bd4d){_0x5ea1f9[_0x77f2('0x63')]=_0xe7bd4d;return _0x5ea1f9;});}})[_0x77f2('0x22')](respondWithFilteredResult(_0x3cf025,_0x960e63))[_0x77f2('0x2d')](handleError(_0x3cf025,null));};exports['getChatInteractions']=function(_0x3080d5,_0x47d368,_0x35ede4){var _0x5e3c1e={};var _0x1eb83c={};var _0x3e8738;var _0x5d9346;return db['User'][_0x77f2('0x97')]({'where':{'id':_0x3080d5['params']['id']}})['then'](handleEntityNotFound(_0x47d368,null))[_0x77f2('0x22')](function(_0x23c0e6){if(_0x23c0e6){_0x3e8738=_0x23c0e6;_0x1eb83c[_0x77f2('0x4b')]=_['keys'](db[_0x77f2('0xd1')][_0x77f2('0x47')]);_0x1eb83c['query']=_[_0x77f2('0x50')](_0x3080d5['query']);_0x1eb83c[_0x77f2('0x51')]=_[_0x77f2('0x53')](_0x1eb83c[_0x77f2('0x4b')],_0x1eb83c[_0x77f2('0x4f')]);_0x5e3c1e[_0x77f2('0x52')]=_[_0x77f2('0x53')](_0x1eb83c[_0x77f2('0x4b')],qs[_0x77f2('0x54')](_0x3080d5['query'][_0x77f2('0x54')]));_0x5e3c1e[_0x77f2('0x52')]=_0x5e3c1e[_0x77f2('0x52')][_0x77f2('0x65')]?_0x5e3c1e[_0x77f2('0x52')]:_0x1eb83c[_0x77f2('0x4b')];_0x5e3c1e['order']=qs[_0x77f2('0x58')](_0x3080d5[_0x77f2('0x4f')][_0x77f2('0x58')]);_0x5e3c1e[_0x77f2('0x59')]=qs[_0x77f2('0x51')](_[_0x77f2('0x5a')](_0x3080d5[_0x77f2('0x4f')],_0x1eb83c['filters']));if(_0x3080d5[_0x77f2('0x4f')][_0x77f2('0x5b')]){_0x5e3c1e['where']=_[_0x77f2('0x5c')](_0x5e3c1e[_0x77f2('0x59')],{'$or':_[_0x77f2('0x3e')](_0x5e3c1e[_0x77f2('0x52')],function(_0x16edb1){var _0x50f4c9={};_0x50f4c9[_0x16edb1]={'$like':'%'+_0x3080d5[_0x77f2('0x4f')]['filter']+'%'};return _0x50f4c9;})});}_0x5e3c1e=_[_0x77f2('0x5c')]({},_0x5e3c1e,_0x3080d5[_0x77f2('0x66')]);return _0x3e8738[_0x77f2('0xd2')](_0x5e3c1e);}})[_0x77f2('0x22')](function(_0x1e3d68){if(_0x1e3d68){_0x5d9346=_0x1e3d68['length'];if(!_0x3080d5[_0x77f2('0x4f')][_0x77f2('0x55')](_0x77f2('0x56'))){_0x5e3c1e[_0x77f2('0x33')]=qs[_0x77f2('0x33')](_0x3080d5[_0x77f2('0x4f')][_0x77f2('0x33')]);_0x5e3c1e['offset']=qs[_0x77f2('0x32')](_0x3080d5[_0x77f2('0x4f')][_0x77f2('0x32')]);}return _0x3e8738['getChatInteractions'](_0x5e3c1e);}})[_0x77f2('0x22')](function(_0x35bc3c){if(_0x35bc3c){return _0x35bc3c?{'count':_0x5d9346,'rows':_0x35bc3c}:null;}})['then'](respondWithResult(_0x47d368,null))[_0x77f2('0x2d')](handleError(_0x47d368,null));};exports['getOpenchannelInteractions']=function(_0x552f57,_0xf78f11,_0x2d5b82){var _0x4fefde={};var _0x5a452d={};var _0x4ee714;var _0x51069e;return db[_0x77f2('0x46')]['findOne']({'where':{'id':_0x552f57[_0x77f2('0x64')]['id']}})[_0x77f2('0x22')](handleEntityNotFound(_0xf78f11,null))[_0x77f2('0x22')](function(_0x50d80b){if(_0x50d80b){_0x4ee714=_0x50d80b;_0x5a452d[_0x77f2('0x4b')]=_['keys'](db['OpenchannelInteraction'][_0x77f2('0x47')]);_0x5a452d[_0x77f2('0x4f')]=_[_0x77f2('0x50')](_0x552f57[_0x77f2('0x4f')]);_0x5a452d[_0x77f2('0x51')]=_[_0x77f2('0x53')](_0x5a452d[_0x77f2('0x4b')],_0x5a452d[_0x77f2('0x4f')]);_0x4fefde[_0x77f2('0x52')]=_['intersection'](_0x5a452d['model'],qs[_0x77f2('0x54')](_0x552f57[_0x77f2('0x4f')][_0x77f2('0x54')]));_0x4fefde['attributes']=_0x4fefde[_0x77f2('0x52')][_0x77f2('0x65')]?_0x4fefde[_0x77f2('0x52')]:_0x5a452d[_0x77f2('0x4b')];_0x4fefde[_0x77f2('0x57')]=qs[_0x77f2('0x58')](_0x552f57[_0x77f2('0x4f')][_0x77f2('0x58')]);_0x4fefde[_0x77f2('0x59')]=qs[_0x77f2('0x51')](_[_0x77f2('0x5a')](_0x552f57[_0x77f2('0x4f')],_0x5a452d[_0x77f2('0x51')]));if(_0x552f57[_0x77f2('0x4f')][_0x77f2('0x5b')]){_0x4fefde[_0x77f2('0x59')]=_[_0x77f2('0x5c')](_0x4fefde[_0x77f2('0x59')],{'$or':_[_0x77f2('0x3e')](_0x4fefde['attributes'],function(_0x513983){var _0x17d354={};_0x17d354[_0x513983]={'$like':'%'+_0x552f57[_0x77f2('0x4f')][_0x77f2('0x5b')]+'%'};return _0x17d354;})});}_0x4fefde=_[_0x77f2('0x5c')]({},_0x4fefde,_0x552f57[_0x77f2('0x66')]);return _0x4ee714['getOpenchannelInteractions'](_0x4fefde);}})[_0x77f2('0x22')](function(_0x5b5c65){if(_0x5b5c65){_0x51069e=_0x5b5c65['length'];if(!_0x552f57[_0x77f2('0x4f')][_0x77f2('0x55')](_0x77f2('0x56'))){_0x4fefde['limit']=qs['limit'](_0x552f57[_0x77f2('0x4f')]['limit']);_0x4fefde[_0x77f2('0x32')]=qs[_0x77f2('0x32')](_0x552f57[_0x77f2('0x4f')][_0x77f2('0x32')]);}return _0x4ee714[_0x77f2('0xd3')](_0x4fefde);}})['then'](function(_0x151e2e){if(_0x151e2e){return _0x151e2e?{'count':_0x51069e,'rows':_0x151e2e}:null;}})['then'](respondWithResult(_0xf78f11,null))[_0x77f2('0x2d')](handleError(_0xf78f11,null));};exports[_0x77f2('0xd4')]=function(_0x12b877,_0x6179ad,_0x59f018){var _0x24b124={'raw':!![],'where':{}};var _0x3d155b={};var _0xf169fe={'count':0x0,'rows':[]};return db[_0x77f2('0x46')][_0x77f2('0x97')]({'where':{'id':_0x12b877['params']['id']}})['then'](handleEntityNotFound(_0x6179ad,null))[_0x77f2('0x22')](function(_0x4f1898){if(_0x4f1898){_0x3d155b[_0x77f2('0x4b')]=_['keys'](db[_0x77f2('0xd5')][_0x77f2('0x47')]);_0x3d155b['query']=_[_0x77f2('0x50')](_0x12b877[_0x77f2('0x4f')]);_0x3d155b['filters']=_[_0x77f2('0x53')](_0x3d155b[_0x77f2('0x4b')],_0x3d155b[_0x77f2('0x4f')]);_0x24b124[_0x77f2('0x52')]=_[_0x77f2('0x53')](_0x3d155b[_0x77f2('0x4b')],qs[_0x77f2('0x54')](_0x12b877[_0x77f2('0x4f')][_0x77f2('0x54')]));_0x24b124['attributes']=_0x24b124[_0x77f2('0x52')]['length']?_0x24b124[_0x77f2('0x52')]:_0x3d155b[_0x77f2('0x4b')];if(!_0x12b877[_0x77f2('0x4f')][_0x77f2('0x55')](_0x77f2('0x56'))){_0x24b124[_0x77f2('0x33')]=qs[_0x77f2('0x33')](_0x12b877[_0x77f2('0x4f')]['limit']);_0x24b124[_0x77f2('0x32')]=qs[_0x77f2('0x32')](_0x12b877[_0x77f2('0x4f')][_0x77f2('0x32')]);}_0x24b124[_0x77f2('0x57')]=qs['sort'](_0x12b877[_0x77f2('0x4f')][_0x77f2('0x58')]);_0x24b124[_0x77f2('0x59')]=qs['filters'](_[_0x77f2('0x5a')](_0x12b877[_0x77f2('0x4f')],_0x3d155b[_0x77f2('0x51')]));_0x24b124['where'][_0x77f2('0xcf')]=_0x4f1898['id'];if(_0x12b877[_0x77f2('0x4f')][_0x77f2('0x5b')]){_0x24b124[_0x77f2('0x59')]=_['merge'](_0x24b124[_0x77f2('0x59')],{'$or':_[_0x77f2('0x3e')](_0x24b124['attributes'],function(_0x34deaf){var _0x4b6cfe={};_0x4b6cfe[_0x34deaf]={'$like':'%'+_0x12b877[_0x77f2('0x4f')][_0x77f2('0x5b')]+'%'};return _0x4b6cfe;})});}_0x24b124=_[_0x77f2('0x5c')]({},_0x24b124,_0x12b877[_0x77f2('0x66')]);return db['MailInteraction'][_0x77f2('0x60')]({'where':_0x24b124[_0x77f2('0x59')]})[_0x77f2('0x22')](function(_0x453ef5){_0xf169fe[_0x77f2('0x60')]=_0x453ef5;if(_0x12b877[_0x77f2('0x4f')][_0x77f2('0x61')]){_0x24b124['include']=[{'all':!![]}];}return db['MailInteraction']['findAll'](_0x24b124);})[_0x77f2('0x22')](function(_0x1f8435){_0xf169fe['rows']=_0x1f8435;return _0xf169fe;});}})['then'](respondWithFilteredResult(_0x6179ad,_0x24b124))[_0x77f2('0x2d')](handleError(_0x6179ad,null));};exports['getSmsInteractions']=function(_0x5bb281,_0x374c54,_0x4111d6){var _0x217f70={};var _0x5a8afa={};var _0x1e5e2e;var _0x8060f1;return db[_0x77f2('0x46')]['findOne']({'where':{'id':_0x5bb281[_0x77f2('0x64')]['id']}})[_0x77f2('0x22')](handleEntityNotFound(_0x374c54,null))['then'](function(_0x39f025){if(_0x39f025){_0x1e5e2e=_0x39f025;_0x5a8afa[_0x77f2('0x4b')]=_[_0x77f2('0x50')](db[_0x77f2('0xd6')][_0x77f2('0x47')]);_0x5a8afa[_0x77f2('0x4f')]=_[_0x77f2('0x50')](_0x5bb281['query']);_0x5a8afa['filters']=_['intersection'](_0x5a8afa[_0x77f2('0x4b')],_0x5a8afa['query']);_0x217f70[_0x77f2('0x52')]=_['intersection'](_0x5a8afa[_0x77f2('0x4b')],qs[_0x77f2('0x54')](_0x5bb281[_0x77f2('0x4f')]['fields']));_0x217f70['attributes']=_0x217f70[_0x77f2('0x52')][_0x77f2('0x65')]?_0x217f70[_0x77f2('0x52')]:_0x5a8afa[_0x77f2('0x4b')];_0x217f70[_0x77f2('0x57')]=qs[_0x77f2('0x58')](_0x5bb281['query'][_0x77f2('0x58')]);_0x217f70[_0x77f2('0x59')]=qs[_0x77f2('0x51')](_[_0x77f2('0x5a')](_0x5bb281[_0x77f2('0x4f')],_0x5a8afa[_0x77f2('0x51')]));if(_0x5bb281[_0x77f2('0x4f')]['filter']){_0x217f70[_0x77f2('0x59')]=_[_0x77f2('0x5c')](_0x217f70['where'],{'$or':_[_0x77f2('0x3e')](_0x217f70[_0x77f2('0x52')],function(_0x4b7a95){var _0x5b15a2={};_0x5b15a2[_0x4b7a95]={'$like':'%'+_0x5bb281[_0x77f2('0x4f')][_0x77f2('0x5b')]+'%'};return _0x5b15a2;})});}_0x217f70=_[_0x77f2('0x5c')]({},_0x217f70,_0x5bb281[_0x77f2('0x66')]);return _0x1e5e2e['getSmsInteractions'](_0x217f70);}})[_0x77f2('0x22')](function(_0xee6854){if(_0xee6854){_0x8060f1=_0xee6854['length'];if(!_0x5bb281[_0x77f2('0x4f')][_0x77f2('0x55')](_0x77f2('0x56'))){_0x217f70[_0x77f2('0x33')]=qs[_0x77f2('0x33')](_0x5bb281[_0x77f2('0x4f')]['limit']);_0x217f70['offset']=qs[_0x77f2('0x32')](_0x5bb281['query'][_0x77f2('0x32')]);}return _0x1e5e2e[_0x77f2('0xd7')](_0x217f70);}})[_0x77f2('0x22')](function(_0x368861){if(_0x368861){return _0x368861?{'count':_0x8060f1,'rows':_0x368861}:null;}})['then'](respondWithResult(_0x374c54,null))[_0x77f2('0x2d')](handleError(_0x374c54,null));};exports[_0x77f2('0xd8')]=function(_0xda7d7,_0x1752d0,_0x17467a){var _0xf0c3e2={};var _0x47c03d={};var _0x298f5f;var _0x219695;return db[_0x77f2('0x46')][_0x77f2('0x97')]({'where':{'id':_0xda7d7[_0x77f2('0x64')]['id']}})[_0x77f2('0x22')](handleEntityNotFound(_0x1752d0,null))['then'](function(_0x3b645a){if(_0x3b645a){_0x298f5f=_0x3b645a;_0x47c03d[_0x77f2('0x4b')]=_[_0x77f2('0x50')](db[_0x77f2('0xd9')][_0x77f2('0x47')]);_0x47c03d[_0x77f2('0x4f')]=_[_0x77f2('0x50')](_0xda7d7[_0x77f2('0x4f')]);_0x47c03d[_0x77f2('0x51')]=_['intersection'](_0x47c03d[_0x77f2('0x4b')],_0x47c03d[_0x77f2('0x4f')]);_0xf0c3e2['attributes']=_[_0x77f2('0x53')](_0x47c03d[_0x77f2('0x4b')],qs['fields'](_0xda7d7[_0x77f2('0x4f')][_0x77f2('0x54')]));_0xf0c3e2[_0x77f2('0x52')]=_0xf0c3e2[_0x77f2('0x52')][_0x77f2('0x65')]?_0xf0c3e2['attributes']:_0x47c03d[_0x77f2('0x4b')];_0xf0c3e2['order']=qs['sort'](_0xda7d7['query'][_0x77f2('0x58')]);_0xf0c3e2[_0x77f2('0x59')]=qs[_0x77f2('0x51')](_['pick'](_0xda7d7['query'],_0x47c03d[_0x77f2('0x51')]));if(_0xda7d7[_0x77f2('0x4f')][_0x77f2('0x5b')]){_0xf0c3e2[_0x77f2('0x59')]=_[_0x77f2('0x5c')](_0xf0c3e2[_0x77f2('0x59')],{'$or':_[_0x77f2('0x3e')](_0xf0c3e2['attributes'],function(_0xaa8b4b){var _0x4e449d={};_0x4e449d[_0xaa8b4b]={'$like':'%'+_0xda7d7[_0x77f2('0x4f')][_0x77f2('0x5b')]+'%'};return _0x4e449d;})});}_0xf0c3e2=_[_0x77f2('0x5c')]({},_0xf0c3e2,_0xda7d7[_0x77f2('0x66')]);return _0x298f5f[_0x77f2('0xd8')](_0xf0c3e2);}})[_0x77f2('0x22')](function(_0x6bb171){if(_0x6bb171){_0x219695=_0x6bb171[_0x77f2('0x65')];if(!_0xda7d7['query'][_0x77f2('0x55')](_0x77f2('0x56'))){_0xf0c3e2['limit']=qs[_0x77f2('0x33')](_0xda7d7[_0x77f2('0x4f')][_0x77f2('0x33')]);_0xf0c3e2[_0x77f2('0x32')]=qs[_0x77f2('0x32')](_0xda7d7['query'][_0x77f2('0x32')]);}return _0x298f5f[_0x77f2('0xd8')](_0xf0c3e2);}})[_0x77f2('0x22')](function(_0x3f0b91){if(_0x3f0b91){return _0x3f0b91?{'count':_0x219695,'rows':_0x3f0b91}:null;}})[_0x77f2('0x22')](respondWithResult(_0x1752d0,null))[_0x77f2('0x2d')](handleError(_0x1752d0,null));};exports['getWhatsappInteractions']=function(_0xf2c45b,_0x3e26e1,_0x481753){var _0x47a9d6={};var _0x150768={};var _0x2fee91;var _0x13178e;return db[_0x77f2('0x46')][_0x77f2('0x97')]({'where':{'id':_0xf2c45b['params']['id']}})['then'](handleEntityNotFound(_0x3e26e1,null))['then'](function(_0x5ea5f5){if(_0x5ea5f5){_0x2fee91=_0x5ea5f5;_0x150768[_0x77f2('0x4b')]=_[_0x77f2('0x50')](db[_0x77f2('0xda')][_0x77f2('0x47')]);_0x150768['query']=_['keys'](_0xf2c45b['query']);_0x150768[_0x77f2('0x51')]=_[_0x77f2('0x53')](_0x150768[_0x77f2('0x4b')],_0x150768[_0x77f2('0x4f')]);_0x47a9d6[_0x77f2('0x52')]=_[_0x77f2('0x53')](_0x150768[_0x77f2('0x4b')],qs[_0x77f2('0x54')](_0xf2c45b[_0x77f2('0x4f')]['fields']));_0x47a9d6['attributes']=_0x47a9d6['attributes'][_0x77f2('0x65')]?_0x47a9d6[_0x77f2('0x52')]:_0x150768[_0x77f2('0x4b')];_0x47a9d6[_0x77f2('0x57')]=qs['sort'](_0xf2c45b['query'][_0x77f2('0x58')]);_0x47a9d6[_0x77f2('0x59')]=qs['filters'](_['pick'](_0xf2c45b[_0x77f2('0x4f')],_0x150768[_0x77f2('0x51')]));if(_0xf2c45b[_0x77f2('0x4f')][_0x77f2('0x5b')]){_0x47a9d6[_0x77f2('0x59')]=_[_0x77f2('0x5c')](_0x47a9d6[_0x77f2('0x59')],{'$or':_[_0x77f2('0x3e')](_0x47a9d6['attributes'],function(_0x29d682){var _0x26204c={};_0x26204c[_0x29d682]={'$like':'%'+_0xf2c45b['query'][_0x77f2('0x5b')]+'%'};return _0x26204c;})});}_0x47a9d6=_[_0x77f2('0x5c')]({},_0x47a9d6,_0xf2c45b[_0x77f2('0x66')]);return _0x2fee91[_0x77f2('0xdb')](_0x47a9d6);}})['then'](function(_0x399ec6){if(_0x399ec6){_0x13178e=_0x399ec6['length'];if(!_0xf2c45b['query'][_0x77f2('0x55')](_0x77f2('0x56'))){_0x47a9d6[_0x77f2('0x33')]=qs['limit'](_0xf2c45b['query'][_0x77f2('0x33')]);_0x47a9d6[_0x77f2('0x32')]=qs['offset'](_0xf2c45b[_0x77f2('0x4f')]['offset']);}return _0x2fee91[_0x77f2('0xdb')](_0x47a9d6);}})[_0x77f2('0x22')](function(_0x5f39d4){if(_0x5f39d4){return _0x5f39d4?{'count':_0x13178e,'rows':_0x5f39d4}:null;}})[_0x77f2('0x22')](respondWithResult(_0x3e26e1,null))[_0x77f2('0x2d')](handleError(_0x3e26e1,null));};exports[_0x77f2('0xdc')]=function(_0x12cfbf,_0xf4c5a2,_0x151f7b){var _0x55efd6;var _0x47c449;var _0xc63413;var _0x1f7e28=!_['isNil'](_0x12cfbf[_0x77f2('0x64')]['id'])?_0x12cfbf[_0x77f2('0x64')]['id']:!_[_0x77f2('0x7d')](_0x12cfbf['user']['id'])?_0x12cfbf[_0x77f2('0x3a')]['id']:null;return db[_0x77f2('0x46')][_0x77f2('0x41')]({'where':{'id':_0x1f7e28,'role':{'$or':[_0x77f2('0x70'),_0x77f2('0x3a'),_0x77f2('0x6d')]}},'attributes':['id',_0x77f2('0x45'),_0x77f2('0xdd'),_0x77f2('0xde'),_0x77f2('0x42'),'internal',_0x77f2('0xdf')]})[_0x77f2('0x22')](function(_0x102ba3){if(_0x102ba3){if(_0x102ba3[_0x77f2('0x42')]===_0x77f2('0x6d')){_0x55efd6=_0x102ba3;if(_0x12cfbf['body']['interface']){_0xc63413=util['format'](_0x77f2('0xe0'),_0x55efd6[_0x12cfbf[_0x77f2('0x68')][_0x77f2('0xa3')]]);}else if(_0x12cfbf[_0x77f2('0x68')][_0x77f2('0xe1')]){_0xc63413=util[_0x77f2('0x75')](_0x77f2('0xb1'),_0x12cfbf[_0x77f2('0x68')]['intrf']);}else{_0xc63413=util[_0x77f2('0x75')](_0x77f2('0xb1'),_0x55efd6[_0x77f2('0x45')]);}socket['to'](util[_0x77f2('0x75')](_0x77f2('0xe2'),_0x55efd6[_0x77f2('0x45')]))['emit']('user:forcelogout',{'ip':_0x12cfbf[_0x77f2('0xe3')][_0x77f2('0xe4')]||_0x12cfbf[_0x77f2('0xe5')][_0x77f2('0xe6')]||_0x12cfbf[_0x77f2('0xe7')][_0x77f2('0xe6')]||_0x12cfbf[_0x77f2('0xe5')][_0x77f2('0xe7')][_0x77f2('0xe6')]});return db[_0x77f2('0xb2')][_0x77f2('0x38')]({'where':{'membername':_0x55efd6[_0x77f2('0x45')]},'individualHooks':!![]});}}else{throw new db[(_0x77f2('0x1f'))][(_0x77f2('0x20'))](_0x77f2('0xe8'));}})[_0x77f2('0x22')](function(){if(_0x55efd6){return _0x55efd6[_0x77f2('0xe9')]({'raw':!![]});}})['then'](function(_0x9e02f2){if(_0x55efd6){var _0x1b28fc=[];if(_0x9e02f2){_0x47c449=_0x9e02f2;if(_0x47c449['length']){for(var _0x226a77=0x0;_0x226a77<_0x47c449['length'];_0x226a77++){_0x1b28fc['push']({'membername':_0x55efd6[_0x77f2('0x45')],'UserId':_0x55efd6['id'],'queue_name':_0x47c449[_0x226a77]['name'],'VoiceQueueId':_0x47c449[_0x226a77]['id'],'interface':_0xc63413,'paused':_0x55efd6[_0x77f2('0xdf')]||![],'penalty':_0x47c449[_0x226a77][_0x77f2('0xea')]||0x0});}return BPromise[_0x77f2('0xeb')](_0x1b28fc,function(_0x4dd603){return db[_0x77f2('0xb2')][_0x77f2('0xb3')](_0x4dd603);});}}}})[_0x77f2('0x22')](function(){if(_0x55efd6){return db[_0x77f2('0xec')][_0x77f2('0xaf')]({'where':{'membername':_0x55efd6[_0x77f2('0x45')],'exitAt':null}});}})['then'](function(_0x43e6cb){if(_0x55efd6){var _0x222a52=[];_0x43e6cb[_0x77f2('0xed')](function(_0x38a541){_0x222a52[_0x77f2('0xb0')](_0x38a541['update']({'exitAt':moment()[_0x77f2('0x75')](_0x77f2('0xee'))}));});return BPromise['all'](_0x222a52);}})[_0x77f2('0x22')](function(){if(_0x55efd6){var _0x193600=[];var _0x3bdde2=[];var _0x1f290d=utils[_0x77f2('0xef')]();var _0x517b72={'membername':_0x55efd6[_0x77f2('0x45')],'interface':_0xc63413,'enterAt':moment()[_0x77f2('0x75')]('YYYY-MM-DD\x20HH:mm:ss'),'role':_0x55efd6[_0x77f2('0x42')],'internal':_0x55efd6[_0x77f2('0x7c')]};_0x1f290d[_0x77f2('0xed')](function(_0x2a44c0){_0x193600[_0x77f2('0xb0')](_[_0x77f2('0x5c')]({'channel':_0x2a44c0,'type':_0x77f2('0xf0'),'data1':_0x12cfbf[_0x77f2('0x68')][_0x77f2('0xf1')],'data2':_0xc63413},_0x517b72));if(_0x55efd6['loginInPause']){_0x3bdde2[_0x77f2('0xb0')](_[_0x77f2('0x5c')]({'channel':_0x2a44c0,'type':_0x77f2('0xf2'),'data1':_0x77f2('0xf3')},_0x517b72));}});return db[_0x77f2('0xec')]['bulkCreate'](_0x193600[_0x77f2('0xf4')](_0x3bdde2),{'individualHooks':!![]});}})[_0x77f2('0x22')](function(){if(_0x55efd6){return _0x55efd6[_0x77f2('0x37')]({'online':!![],'lastLoginAt':moment()['format'](_0x77f2('0xee')),'voicePause':_0x55efd6[_0x77f2('0xdf')]||![],'mailPause':_0x55efd6[_0x77f2('0xdf')]||![],'chatPause':_0x55efd6[_0x77f2('0xdf')]||![],'faxPause':_0x55efd6['loginInPause']||![],'smsPause':_0x55efd6['loginInPause']||![],'openchannelPause':_0x55efd6[_0x77f2('0xdf')]||![],'whatsappPause':_0x55efd6['loginInPause']||![],'pauseType':_0x55efd6[_0x77f2('0xdf')]?'LOGININPAUSE':null,'interface':_0xc63413,'lastPauseAt':moment()[_0x77f2('0x75')](_0x77f2('0xee'))});}})[_0x77f2('0x22')](function(_0x44a4dd){if(_0x12cfbf[_0x77f2('0xf5')]){return _0x151f7b();}else{return BPromise['resolve'](_0x44a4dd)[_0x77f2('0x22')](respondWithResult(_0xf4c5a2,null));}})['catch'](handleError(_0xf4c5a2,null));};exports['logout']=function(_0x311a9b,_0x5f07d,_0x39b22c){var _0x4ccf84;return db['User'][_0x77f2('0x41')]({'where':{'id':_0x311a9b[_0x77f2('0x64')]['id'],'role':_0x77f2('0x6d')},'attributes':['id',_0x77f2('0x45'),_0x77f2('0x42')]})['then'](handleEntityNotFound(_0x5f07d,null))[_0x77f2('0x22')](function(_0x50270f){if(_0x50270f){_0x4ccf84=_0x50270f;return db[_0x77f2('0xb2')][_0x77f2('0x38')]({'where':{'membername':_0x4ccf84[_0x77f2('0x45')]},'individualHooks':!![]});}})[_0x77f2('0x22')](function(){return db[_0x77f2('0xec')]['findAll']({'where':{'membername':_0x4ccf84[_0x77f2('0x45')],'exitAt':null}});})[_0x77f2('0x22')](function(_0x137ed5){var _0x3911a4=[];_0x137ed5[_0x77f2('0xed')](function(_0x1bea1c){_0x3911a4[_0x77f2('0xb0')](_0x1bea1c[_0x77f2('0x37')]({'exitAt':moment()[_0x77f2('0x75')](_0x77f2('0xee'))}));});return BPromise['all'](_0x3911a4);})[_0x77f2('0x22')](function(){return _0x4ccf84[_0x77f2('0x37')]({'online':![],'lastLoginAt':null,'voicePause':![],'mailPause':![],'chatPause':![],'faxPause':![],'smsPause':![],'openchannelPause':![],'whatsappPause':![],'interface':null});})[_0x77f2('0x22')](respondWithResult(_0x5f07d,null))[_0x77f2('0x2d')](handleError(_0x5f07d,null));};exports[_0x77f2('0xf6')]=function(_0xbbb6f6,_0x130294,_0x5edb3c){var _0x4bb115;return db[_0x77f2('0xb2')][_0x77f2('0x37')]({'paused':0x1},{'where':{'UserId':_0xbbb6f6['params']['id']},'individualHooks':!![]})[_0x77f2('0x22')](function(){return db[_0x77f2('0x46')]['find']({'where':{'id':_0xbbb6f6[_0x77f2('0x64')]['id'],'role':_0x77f2('0x6d')},'attributes':['id',_0x77f2('0x45'),_0x77f2('0x42'),_0x77f2('0x7c'),_0x77f2('0xa3')]});})[_0x77f2('0x22')](handleEntityNotFound(_0x130294,null))[_0x77f2('0x22')](function(_0x22f0a5){if(_0x22f0a5){_0x4bb115=_0x22f0a5;return respondWithRpcPromise(_0x77f2('0xf7'),_0x77f2('0xf6'),{'id':_0x4bb115['id'],'name':_0x4bb115[_0x77f2('0x45')],'pause':!![]});}})[_0x77f2('0x22')](function(){if(_0x4bb115){return db[_0x77f2('0xec')][_0x77f2('0xaf')]({'where':{'membername':_0x4bb115[_0x77f2('0x45')],'type':_0x77f2('0xf2'),'exitAt':null}});}})['then'](function(_0x31dbb6){if(_0x31dbb6[_0x77f2('0x65')]){var _0x56f65f=moment()[_0x77f2('0x75')](_0x77f2('0xee'));for(var _0x4619fe=0x0,_0x5a0611=_0x31dbb6[_0x77f2('0x65')];_0x4619fe<_0x5a0611;_0x4619fe++){_0x31dbb6[_0x4619fe][_0x77f2('0xf8')]({'exitAt':_0x56f65f});}}})[_0x77f2('0x22')](function(){var _0x1ff535=[];var _0x5325f8=utils[_0x77f2('0xef')]();_0x5325f8[_0x77f2('0xed')](function(_0x542a78){_0x1ff535[_0x77f2('0xb0')]({'channel':_0x542a78,'membername':_0x4bb115[_0x77f2('0x45')],'interface':_[_0x77f2('0x7d')](_0x4bb115[_0x77f2('0xa3')])?util['format'](_0x77f2('0xb1'),_0x4bb115[_0x77f2('0x45')]):_0x4bb115[_0x77f2('0xa3')],'type':'PAUSE','enterAt':moment()[_0x77f2('0x75')]('YYYY-MM-DD\x20HH:mm:ss'),'data1':_0xbbb6f6[_0x77f2('0x68')][_0x77f2('0x49')]||_0x77f2('0xf9'),'role':_0x4bb115['role'],'internal':_0x4bb115[_0x77f2('0x7c')]});});return db['MemberReport'][_0x77f2('0x67')](_0x1ff535,{'individualHooks':!![]});})[_0x77f2('0x22')](function(){return _0x4bb115[_0x77f2('0x37')]({'voicePause':!![],'mailPause':!![],'chatPause':!![],'faxPause':!![],'smsPause':!![],'whatsappPause':!![],'openchannelPause':!![],'pauseType':_0xbbb6f6[_0x77f2('0x68')][_0x77f2('0x49')]||_0x77f2('0xf9'),'lastPauseAt':moment()[_0x77f2('0x75')](_0x77f2('0xee'))});})[_0x77f2('0x22')](respondWithResult(_0x130294,null))[_0x77f2('0x2d')](handleError(_0x130294,null));};exports[_0x77f2('0xfa')]=function(_0x29d9c0,_0x506a81,_0x47ebb7){var _0x196c8a;return db['User'][_0x77f2('0x41')]({'where':{'id':_0x29d9c0[_0x77f2('0x64')]['id']},'attributes':['id','name',_0x77f2('0x42'),_0x77f2('0xa2'),_0x77f2('0xfb'),_0x77f2('0xfc'),_0x77f2('0xfd'),_0x77f2('0xfe'),'smsPause',_0x77f2('0xff'),_0x77f2('0x100'),'lastPauseAt']})[_0x77f2('0x22')](handleEntityNotFound(_0x506a81,null))[_0x77f2('0x22')](function(_0x1dd410){if(_0x1dd410){_0x196c8a=_0x1dd410;if(_0x29d9c0['body']['channel']&&!utils[_0x77f2('0xb5')](_0x29d9c0[_0x77f2('0x68')][_0x77f2('0xa0')])){throw new db['Sequelize'][(_0x77f2('0x20'))]('Unknown\x20channel');}switch(_0x29d9c0['body'][_0x77f2('0xa0')]){case _0x77f2('0xad'):return respondWithRpcPromise(_0x77f2('0xf7'),_0x77f2('0xfa'),{'id':_0x196c8a['id'],'name':_0x196c8a[_0x77f2('0x45')],'pause':![]})[_0x77f2('0x22')](function(){return db[_0x77f2('0xb2')][_0x77f2('0x37')]({'paused':0x0},{'where':{'UserId':_0x196c8a['id']},'individualHooks':!![]});})['then'](function(){return db[_0x77f2('0xec')][_0x77f2('0x41')]({'where':{'channel':_0x29d9c0[_0x77f2('0x68')]['channel'],'membername':_0x196c8a[_0x77f2('0x45')],'type':_0x77f2('0xf2'),'exitAt':null}});})['then'](function(_0x1a81cf){if(_0x1a81cf){return _0x1a81cf[_0x77f2('0x37')]({'exitAt':moment()[_0x77f2('0x75')]('YYYY-MM-DD\x20HH:mm:ss'),'data2':'manual'},{'individualHooks':!![]});}return null;})[_0x77f2('0x22')](function(){return _0x196c8a[_0x77f2('0x37')]({'voicePause':![]});});case'mail':case _0x77f2('0x101'):case _0x77f2('0x102'):case _0x77f2('0x103'):case _0x77f2('0x104'):case'openchannel':return db['MemberReport'][_0x77f2('0x41')]({'where':{'channel':_0x29d9c0['body'][_0x77f2('0xa0')],'membername':_0x196c8a[_0x77f2('0x45')],'type':_0x77f2('0xf2'),'exitAt':null}})['then'](function(_0x310368){if(_0x310368){return _0x310368['update']({'exitAt':moment()[_0x77f2('0x75')](_0x77f2('0xee')),'data2':_0x77f2('0x105')},{'individualHooks':!![]});}return null;})[_0x77f2('0x22')](function(){var _0x591bdf={};_[_0x77f2('0x106')](_0x591bdf,util[_0x77f2('0x75')]('%s%s',_0x29d9c0[_0x77f2('0x68')][_0x77f2('0xa0')],'Pause'),![]);return _0x196c8a[_0x77f2('0x37')](_0x591bdf);});default:return respondWithRpcPromise(_0x77f2('0xf7'),_0x77f2('0xfa'),{'id':_0x196c8a['id'],'name':_0x196c8a[_0x77f2('0x45')],'pause':![]})[_0x77f2('0x22')](function(){return db[_0x77f2('0xb2')][_0x77f2('0x37')]({'paused':0x0},{'where':{'UserId':_0x196c8a['id']}});})[_0x77f2('0x22')](function(){return db[_0x77f2('0xec')][_0x77f2('0xaf')]({'where':{'membername':_0x196c8a[_0x77f2('0x45')],'type':_0x77f2('0xf2'),'exitAt':null}});})['then'](function(_0x14b23f){var _0x3069d1=[];_0x14b23f[_0x77f2('0xed')](function(_0x35602c){_0x3069d1['push'](_0x35602c['update']({'exitAt':moment()[_0x77f2('0x75')](_0x77f2('0xee')),'data2':_0x77f2('0x105')}));});return BPromise['all'](_0x3069d1);})[_0x77f2('0x22')](function(){return _0x196c8a[_0x77f2('0x37')]({'voicePause':![],'mailPause':![],'chatPause':![],'faxPause':![],'smsPause':![],'whatsappPause':![],'openchannelPause':![]});});}}})['then'](respondWithResult(_0x506a81,null))[_0x77f2('0x2d')](handleError(_0x506a81,null));};exports[_0x77f2('0x107')]=function(_0x2902c6,_0x5812d1,_0x42d9dd){var _0x3545c2={};var _0x21154d={};var _0x18c8c1;var _0x594cf2;return db[_0x77f2('0x46')][_0x77f2('0x97')]({'where':{'id':_0x2902c6[_0x77f2('0x64')]['id']}})[_0x77f2('0x22')](handleEntityNotFound(_0x5812d1,null))[_0x77f2('0x22')](function(_0x4c6c40){if(_0x4c6c40){_0x18c8c1=_0x4c6c40;_0x21154d[_0x77f2('0x4b')]=_[_0x77f2('0x50')](db[_0x77f2('0x108')][_0x77f2('0x47')]);_0x21154d[_0x77f2('0x4f')]=_[_0x77f2('0x50')](_0x2902c6[_0x77f2('0x4f')]);_0x21154d['filters']=_[_0x77f2('0x53')](_0x21154d[_0x77f2('0x4b')],_0x21154d[_0x77f2('0x4f')]);_0x3545c2[_0x77f2('0x52')]=_[_0x77f2('0x53')](_0x21154d[_0x77f2('0x4b')],qs[_0x77f2('0x54')](_0x2902c6['query'][_0x77f2('0x54')]));_0x3545c2[_0x77f2('0x52')]=_0x3545c2[_0x77f2('0x52')][_0x77f2('0x65')]?_0x3545c2[_0x77f2('0x52')]:_0x21154d['model'];_0x3545c2['order']=qs[_0x77f2('0x58')](_0x2902c6['query'][_0x77f2('0x58')]);_0x3545c2[_0x77f2('0x59')]=qs[_0x77f2('0x51')](_[_0x77f2('0x5a')](_0x2902c6[_0x77f2('0x4f')],_0x21154d['filters']));if(_0x2902c6['query'][_0x77f2('0x5b')]){_0x3545c2['where']=_['merge'](_0x3545c2[_0x77f2('0x59')],{'$or':_[_0x77f2('0x3e')](_0x3545c2['attributes'],function(_0x4aae79){var _0x411cd0={};_0x411cd0[_0x4aae79]={'$like':'%'+_0x2902c6[_0x77f2('0x4f')]['filter']+'%'};return _0x411cd0;})});}_0x3545c2=_[_0x77f2('0x5c')]({},_0x3545c2,_0x2902c6[_0x77f2('0x66')]);return _0x18c8c1['getTeams'](_0x3545c2);}})[_0x77f2('0x22')](function(_0x34fba3){if(_0x34fba3){_0x594cf2=_0x34fba3['length'];if(!_0x2902c6[_0x77f2('0x4f')][_0x77f2('0x55')]('nolimit')){_0x3545c2[_0x77f2('0x33')]=qs[_0x77f2('0x33')](_0x2902c6[_0x77f2('0x4f')][_0x77f2('0x33')]);_0x3545c2[_0x77f2('0x32')]=qs[_0x77f2('0x32')](_0x2902c6[_0x77f2('0x4f')][_0x77f2('0x32')]);}return _0x18c8c1['getTeams'](_0x3545c2);}})['then'](function(_0x130341){if(_0x130341){return _0x130341?{'count':_0x594cf2,'rows':_0x130341}:null;}})[_0x77f2('0x22')](respondWithResult(_0x5812d1,null))['catch'](handleError(_0x5812d1,null));};exports[_0x77f2('0x109')]=function(_0x4b001f,_0x287823){return db['User'][_0x77f2('0x41')]({'where':{'id':_0x4b001f[_0x77f2('0x64')]['id']}})[_0x77f2('0x22')](handleEntityNotFound(_0x287823,null))['then'](function(_0x4761fc){if(_0x4761fc){var _0x32d2a3=_0x4761fc[_0x77f2('0x90')]({'plain':!![]});return _0x4761fc[_0x77f2('0x109')](_0x4b001f['body'][_0x77f2('0x6b')],_[_0x77f2('0x6c')](_0x4b001f[_0x77f2('0x68')],[_0x77f2('0x6b'),'id'])||{})['then'](function(){for(var _0x57df96=0x0;_0x57df96<_0x4b001f[_0x77f2('0x68')]['ids'][_0x77f2('0x65')];_0x57df96++){var _0x39ef10=[];db[_0x77f2('0x108')][_0x77f2('0x97')]({'where':{'id':_0x4b001f[_0x77f2('0x68')]['ids'][_0x57df96]}})['then'](function(_0x5160d1){_0x39ef10[_0x77f2('0xb0')](_0x5160d1[_0x77f2('0xe9')]()[_0x77f2('0x22')](function(_0x4aaa18){for(var _0x1e66a4=0x0;_0x1e66a4<_0x4aaa18[_0x77f2('0x65')];_0x1e66a4++){_0x4aaa18[_0x1e66a4][_0x77f2('0x10a')](_0x77f2('0xa0'),_0x77f2('0x10b'));}return _0x4aaa18;}));_0x39ef10['push'](_0x5160d1['getChatQueues']()['then'](function(_0x2fa4e7){for(var _0x21afa0=0x0;_0x21afa0<_0x2fa4e7[_0x77f2('0x65')];_0x21afa0++){_0x2fa4e7[_0x21afa0]['setDataValue'](_0x77f2('0xa0'),'Chat');}return _0x2fa4e7;}));_0x39ef10['push'](_0x5160d1[_0x77f2('0x10c')]()[_0x77f2('0x22')](function(_0x9c1316){for(var _0x50a332=0x0;_0x50a332<_0x9c1316['length'];_0x50a332++){_0x9c1316[_0x50a332][_0x77f2('0x10a')](_0x77f2('0xa0'),_0x77f2('0x10d'));}return _0x9c1316;}));_0x39ef10[_0x77f2('0xb0')](_0x5160d1[_0x77f2('0x10e')]()['then'](function(_0x1e018f){for(var _0x15a899=0x0;_0x15a899<_0x1e018f[_0x77f2('0x65')];_0x15a899++){_0x1e018f[_0x15a899][_0x77f2('0x10a')](_0x77f2('0xa0'),'Sms');}return _0x1e018f;}));_0x39ef10[_0x77f2('0xb0')](_0x5160d1[_0x77f2('0x10f')]()[_0x77f2('0x22')](function(_0x193d0a){for(var _0x54a4e1=0x0;_0x54a4e1<_0x193d0a[_0x77f2('0x65')];_0x54a4e1++){_0x193d0a[_0x54a4e1]['setDataValue'](_0x77f2('0xa0'),_0x77f2('0x110'));}return _0x193d0a;}));_0x39ef10[_0x77f2('0xb0')](_0x5160d1['getFaxQueues']()[_0x77f2('0x22')](function(_0x27ec19){for(var _0x314861=0x0;_0x314861<_0x27ec19[_0x77f2('0x65')];_0x314861++){_0x27ec19[_0x314861][_0x77f2('0x10a')](_0x77f2('0xa0'),'Fax');}return _0x27ec19;}));_0x39ef10[_0x77f2('0xb0')](_0x5160d1['getOpenchannelQueues']()[_0x77f2('0x22')](function(_0x33b138){for(var _0x483b02=0x0;_0x483b02<_0x33b138['length'];_0x483b02++){_0x33b138[_0x483b02][_0x77f2('0x10a')](_0x77f2('0xa0'),_0x77f2('0x111'));}return _0x33b138;}));return BPromise[_0x77f2('0x112')](_0x39ef10);})[_0x77f2('0x22')](function(_0xa8672e){var _0x12c004=_[_0x77f2('0x113')](_0xa8672e);_0x39ef10=[];return db[_0x77f2('0x5e')][_0x77f2('0x114')](function(_0x2efafe){for(var _0x3af6ab=0x0;_0x3af6ab<_0x12c004[_0x77f2('0x65')];_0x3af6ab++){_0x39ef10['push'](_0x12c004[_0x3af6ab]['addAgent'](_0x32d2a3['id']),{'transaction':_0x2efafe});}return BPromise[_0x77f2('0x112')](_0x39ef10)[_0x77f2('0x22')](function(){if(_0x32d2a3[_0x77f2('0xa1')]){return BPromise[_0x77f2('0xeb')](_['filter'](_0x12c004,function(_0x4b87b4){return _0x4b87b4['getDataValue']('channel')===_0x77f2('0x10b');}),function(_0x3773fc){return db[_0x77f2('0xb2')][_0x77f2('0xb3')]({'membername':_0x32d2a3[_0x77f2('0x45')],'UserId':_0x32d2a3['id'],'queue_name':_0x3773fc[_0x77f2('0x45')],'VoiceQueueId':_0x3773fc['id'],'interface':_['isNil'](_0x32d2a3[_0x77f2('0xa3')])?util[_0x77f2('0x75')](_0x77f2('0xb1'),_0x32d2a3[_0x77f2('0x45')]):_0x32d2a3['interface'],'paused':_0x32d2a3[_0x77f2('0xa2')]||![],'penalty':_0x32d2a3[_0x77f2('0xa9')]},{'transaction':_0x2efafe});});}else{return;}})[_0x77f2('0x22')](function(){for(var _0x1a6a26=0x0;_0x1a6a26<_0x12c004[_0x77f2('0x65')];_0x1a6a26++){var _0x269de0=_0x12c004[_0x1a6a26][_0x77f2('0x115')](_0x77f2('0xa0'));var _0x1488e4=_0x269de0+'QueueId';socket[_0x77f2('0xac')]('user'+_0x269de0+_0x77f2('0x116'),{'UserId':_0x32d2a3['id'],['queueField']:_0x12c004[_0x1a6a26]['id']});}});});});}});}})[_0x77f2('0x22')](respondWithStatusCode(_0x287823,null))['catch'](handleError(_0x287823,null));};exports[_0x77f2('0x117')]=function(_0x3f2bf9,_0x354374){return db[_0x77f2('0x46')][_0x77f2('0x97')]({'where':{'id':_0x3f2bf9[_0x77f2('0x64')]['id']}})[_0x77f2('0x22')](handleEntityNotFound(_0x354374,null))[_0x77f2('0x22')](function(_0xbba1){if(_0xbba1){var _0x560196=_0xbba1[_0x77f2('0x90')]({'plain':!![]});var _0x1066e2=_0x3f2bf9[_0x77f2('0x4f')][_0x77f2('0x6b')];return _0xbba1['removeTeams'](_0x1066e2)['then'](function(){for(var _0x23641d=0x0;_0x23641d<_0x1066e2[_0x77f2('0x65')];_0x23641d++){var _0x3d1423=[];db[_0x77f2('0x108')]['findOne']({'where':{'id':_0x1066e2[_0x23641d]}})[_0x77f2('0x22')](function(_0x306e4c){_0x3d1423[_0x77f2('0xb0')](_0x306e4c[_0x77f2('0xe9')]()['then'](function(_0x385971){for(var _0x30ebd4=0x0;_0x30ebd4<_0x385971['length'];_0x30ebd4++){_0x385971[_0x30ebd4][_0x77f2('0x10a')](_0x77f2('0xa0'),_0x77f2('0x10b'));}return _0x385971;}));_0x3d1423['push'](_0x306e4c['getChatQueues']()[_0x77f2('0x22')](function(_0x5709c5){for(var _0x523496=0x0;_0x523496<_0x5709c5['length'];_0x523496++){_0x5709c5[_0x523496][_0x77f2('0x10a')]('channel','Chat');}return _0x5709c5;}));_0x3d1423['push'](_0x306e4c[_0x77f2('0x10c')]()['then'](function(_0x1652bc){for(var _0x367cc8=0x0;_0x367cc8<_0x1652bc[_0x77f2('0x65')];_0x367cc8++){_0x1652bc[_0x367cc8][_0x77f2('0x10a')]('channel',_0x77f2('0x10d'));}return _0x1652bc;}));_0x3d1423[_0x77f2('0xb0')](_0x306e4c[_0x77f2('0x10e')]()[_0x77f2('0x22')](function(_0x2f57af){for(var _0x4d6b4d=0x0;_0x4d6b4d<_0x2f57af['length'];_0x4d6b4d++){_0x2f57af[_0x4d6b4d][_0x77f2('0x10a')](_0x77f2('0xa0'),_0x77f2('0x118'));}return _0x2f57af;}));_0x3d1423[_0x77f2('0xb0')](_0x306e4c[_0x77f2('0x10f')]()[_0x77f2('0x22')](function(_0x42cdf4){for(var _0x4fda72=0x0;_0x4fda72<_0x42cdf4[_0x77f2('0x65')];_0x4fda72++){_0x42cdf4[_0x4fda72]['setDataValue'](_0x77f2('0xa0'),_0x77f2('0x110'));}return _0x42cdf4;}));_0x3d1423[_0x77f2('0xb0')](_0x306e4c['getFaxQueues']()['then'](function(_0x538eae){for(var _0x2c431d=0x0;_0x2c431d<_0x538eae[_0x77f2('0x65')];_0x2c431d++){_0x538eae[_0x2c431d][_0x77f2('0x10a')]('channel',_0x77f2('0x119'));}return _0x538eae;}));_0x3d1423[_0x77f2('0xb0')](_0x306e4c[_0x77f2('0x11a')]()[_0x77f2('0x22')](function(_0x486455){for(var _0x272dba=0x0;_0x272dba<_0x486455[_0x77f2('0x65')];_0x272dba++){_0x486455[_0x272dba][_0x77f2('0x10a')](_0x77f2('0xa0'),'Openchannel');}return _0x486455;}));return BPromise[_0x77f2('0x112')](_0x3d1423);})[_0x77f2('0x22')](function(_0x3e9141){var _0x3c51c6=_['flatten'](_0x3e9141);_0x3d1423=[];return db[_0x77f2('0x5e')]['transaction'](function(_0x1e5fa6){for(var _0x5894d4=0x0;_0x5894d4<_0x3c51c6[_0x77f2('0x65')];_0x5894d4++){_0x3d1423[_0x77f2('0xb0')](_0x3c51c6[_0x5894d4]['removeAgent'](_0x560196['id']),{'transaction':_0x1e5fa6});}return BPromise['all'](_0x3d1423)['then'](function(){if(_0x560196['online']){return BPromise[_0x77f2('0xeb')](_[_0x77f2('0x5b')](_0x3c51c6,function(_0x4f56f3){return _0x4f56f3[_0x77f2('0x115')](_0x77f2('0xa0'))===_0x77f2('0x10b');}),function(_0x15e95e){return db[_0x77f2('0xb2')]['destroy']({'where':{'VoiceQueueId':_0x15e95e['id'],'UserId':_0x560196['id']},'transaction':_0x1e5fa6});});}else{return;}})[_0x77f2('0x22')](function(){for(var _0x3afc82=0x0;_0x3afc82<_0x3c51c6[_0x77f2('0x65')];_0x3afc82++){var _0x110c40=_0x3c51c6[_0x3afc82]['getDataValue'](_0x77f2('0xa0'));var _0x44e40e=_0x110c40+_0x77f2('0xab');socket[_0x77f2('0xac')](_0x77f2('0x3a')+_0x110c40+_0x77f2('0xb7'),{'UserId':_0x560196['id'],['queueField']:_0x3c51c6[_0x3afc82]['id']});}});});});}});}})[_0x77f2('0x22')](respondWithStatusCode(_0x354374,null))['catch'](handleError(_0x354374,null));};exports[_0x77f2('0x11b')]=function(_0x4e88d0,_0x4d3f36,_0x55ed75){var _0x32b388={};var _0x535490={};var _0x410f68;var _0x137b1d;return db[_0x77f2('0x46')]['findOne']({'where':{'id':_0x4e88d0['params']['id']}})[_0x77f2('0x22')](handleEntityNotFound(_0x4d3f36,null))[_0x77f2('0x22')](function(_0x22e255){if(_0x22e255){_0x410f68=_0x22e255;_0x535490[_0x77f2('0x4b')]=_[_0x77f2('0x50')](db[_0x77f2('0xc5')][_0x77f2('0x47')]);_0x535490[_0x77f2('0x4f')]=_[_0x77f2('0x50')](_0x4e88d0[_0x77f2('0x4f')]);_0x535490[_0x77f2('0x51')]=_[_0x77f2('0x53')](_0x535490[_0x77f2('0x4b')],_0x535490[_0x77f2('0x4f')]);_0x32b388[_0x77f2('0x52')]=_[_0x77f2('0x53')](_0x535490[_0x77f2('0x4b')],qs[_0x77f2('0x54')](_0x4e88d0[_0x77f2('0x4f')][_0x77f2('0x54')]));_0x32b388[_0x77f2('0x52')]=_0x32b388[_0x77f2('0x52')][_0x77f2('0x65')]?_0x32b388['attributes']:_0x535490['model'];_0x32b388[_0x77f2('0x57')]=qs[_0x77f2('0x58')](_0x4e88d0[_0x77f2('0x4f')][_0x77f2('0x58')]);_0x32b388['where']=qs[_0x77f2('0x51')](_['pick'](_0x4e88d0[_0x77f2('0x4f')],_0x535490[_0x77f2('0x51')]));if(_0x4e88d0[_0x77f2('0x4f')][_0x77f2('0x5b')]){_0x32b388['where']=_[_0x77f2('0x5c')](_0x32b388['where'],{'$or':_[_0x77f2('0x3e')](_0x32b388[_0x77f2('0x52')],function(_0x1b23db){var _0xc511fa={};_0xc511fa[_0x1b23db]={'$like':'%'+_0x4e88d0['query'][_0x77f2('0x5b')]+'%'};return _0xc511fa;})});}_0x32b388=_[_0x77f2('0x5c')]({},_0x32b388,_0x4e88d0['options']);return _0x410f68[_0x77f2('0x11b')](_0x32b388);}})[_0x77f2('0x22')](function(_0x345100){if(_0x345100){_0x137b1d=_0x345100[_0x77f2('0x65')];if(!_0x4e88d0['query']['hasOwnProperty'](_0x77f2('0x56'))){_0x32b388[_0x77f2('0x33')]=qs[_0x77f2('0x33')](_0x4e88d0[_0x77f2('0x4f')][_0x77f2('0x33')]);_0x32b388[_0x77f2('0x32')]=qs[_0x77f2('0x32')](_0x4e88d0[_0x77f2('0x4f')][_0x77f2('0x32')]);}return _0x410f68[_0x77f2('0x11b')](_0x32b388);}})[_0x77f2('0x22')](function(_0x404d4f){if(_0x404d4f){return _0x404d4f?{'count':_0x137b1d,'rows':_0x404d4f}:null;}})['then'](respondWithResult(_0x4d3f36,null))['catch'](handleError(_0x4d3f36,null));};exports[_0x77f2('0x11c')]=function(_0x303a7d,_0x233bce,_0x46b97e){var _0x2f7241={};var _0xf861b={};var _0x480269;var _0x425599;return db['User'][_0x77f2('0x97')]({'where':{'id':_0x303a7d[_0x77f2('0x64')]['id']}})[_0x77f2('0x22')](handleEntityNotFound(_0x233bce,null))['then'](function(_0x27812b){if(_0x27812b){_0x480269=_0x27812b;_0xf861b[_0x77f2('0x4b')]=_[_0x77f2('0x50')](db['User'][_0x77f2('0x47')]);_0xf861b[_0x77f2('0x4f')]=_[_0x77f2('0x50')](_0x303a7d['query']);_0xf861b[_0x77f2('0x51')]=_['intersection'](_0xf861b['model'],_0xf861b[_0x77f2('0x4f')]);_0x2f7241[_0x77f2('0x52')]=_['intersection'](_0xf861b[_0x77f2('0x4b')],qs['fields'](_0x303a7d[_0x77f2('0x4f')][_0x77f2('0x54')]));_0x2f7241[_0x77f2('0x52')]=_0x2f7241['attributes'][_0x77f2('0x65')]?_0x2f7241[_0x77f2('0x52')]:_0xf861b[_0x77f2('0x4b')];_0x2f7241[_0x77f2('0x57')]=qs[_0x77f2('0x58')](_0x303a7d[_0x77f2('0x4f')][_0x77f2('0x58')]);_0x2f7241[_0x77f2('0x59')]=qs['filters'](_[_0x77f2('0x5a')](_0x303a7d[_0x77f2('0x4f')],_0xf861b[_0x77f2('0x51')]));if(_0x303a7d[_0x77f2('0x4f')][_0x77f2('0x5b')]){_0x2f7241['where']=_[_0x77f2('0x5c')](_0x2f7241[_0x77f2('0x59')],{'$or':_[_0x77f2('0x3e')](_0x2f7241[_0x77f2('0x52')],function(_0x14d921){var _0x223314={};_0x223314[_0x14d921]={'$like':'%'+_0x303a7d[_0x77f2('0x4f')][_0x77f2('0x5b')]+'%'};return _0x223314;})});}_0x2f7241[_0x77f2('0x4b')]=db['User'];_0x2f7241['as']=_0x77f2('0x3b');_0x2f7241=_['merge']({},_0x2f7241,_0x303a7d[_0x77f2('0x66')]);return _0x480269['getVoiceQueues']({'include':[_0x2f7241]});}})['then'](function(_0x4a0811){if(_0x4a0811){var _0x2b2344={},_0x21335e=[],_0x51df22=0x0;for(var _0x78daf=0x0;_0x78daf<_0x4a0811[_0x77f2('0x65')];_0x78daf+=0x1){for(var _0x2b45aa=0x0,_0x34881d;_0x2b45aa<_0x4a0811[_0x78daf][_0x77f2('0x3b')]['length'];_0x2b45aa+=0x1){_0x34881d=_0x4a0811[_0x78daf][_0x77f2('0x3b')][_0x2b45aa][_0x77f2('0x90')]({'plain':!![]});_0x2b2344[_0x34881d['id']]=_0x34881d;}}_0x2b2344=_[_0x77f2('0x11d')](_0x2b2344);for(var _0x3c2274=qs[_0x77f2('0x32')](_0x303a7d[_0x77f2('0x4f')][_0x77f2('0x32')]);_0x3c2274<_0x2b2344[_0x77f2('0x65')]&&_0x21335e[_0x77f2('0x65')]<qs[_0x77f2('0x33')](_0x303a7d[_0x77f2('0x4f')][_0x77f2('0x33')]);_0x3c2274+=0x1){if(_0x2b2344[_0x3c2274]){_0x21335e[_0x77f2('0xb0')](_0x2b2344[_0x3c2274]);}}return{'count':_0x2b2344[_0x77f2('0x65')],'rows':_0x21335e};}})[_0x77f2('0x22')](respondWithResult(_0x233bce,null))['catch'](handleError(_0x233bce,null));};exports['destroy']=function(_0xbeb828,_0x46c353){if(_0xbeb828[_0x77f2('0x3a')]['id']==_0xbeb828[_0x77f2('0x64')]['id']){return _0x46c353[_0x77f2('0x2f')](0x1f4)[_0x77f2('0x11e')]({'message':'You\x20can\x27t\x20delete\x20yourself'});}return db[_0x77f2('0x46')][_0x77f2('0x41')]({'where':{'id':_0xbeb828[_0x77f2('0x64')]['id']}})[_0x77f2('0x22')](handleEntityNotFound(_0x46c353,null))[_0x77f2('0x22')](removeEntity(_0x46c353,null))[_0x77f2('0x2d')](handleError(_0x46c353,null));};exports[_0x77f2('0x11f')]=function(_0xf7a548,_0x1e20c2,_0xcc33b3){return db[_0x77f2('0x46')][_0x77f2('0x41')]({'where':{'id':_0xf7a548[_0x77f2('0x64')]['id']}})[_0x77f2('0x22')](handleEntityNotFound(_0x1e20c2,null))[_0x77f2('0x22')](function(_0x3ad273){if(_0x3ad273){return _0x3ad273['addChatInteractions'](_0xf7a548[_0x77f2('0x68')][_0x77f2('0x6b')],_[_0x77f2('0x6c')](_0xf7a548[_0x77f2('0x68')],[_0x77f2('0x6b'),'id'])||{})['spread'](function(){for(var _0x45212d=0x0;_0x45212d<_0xf7a548[_0x77f2('0x68')]['ids'][_0x77f2('0x65')];_0x45212d+=0x1){socket[_0x77f2('0xac')](_0x77f2('0x120'),{'ChatInteractionId':Number(_0xf7a548[_0x77f2('0x68')]['ids'][_0x45212d]),'UserId':Number(_0xf7a548['params']['id'])});}return _0xf7a548[_0x77f2('0x68')][_0x77f2('0x6b')];});}})['then'](respondWithResult(_0x1e20c2,null))['catch'](handleError(_0x1e20c2,null));};exports[_0x77f2('0x121')]=function(_0x5db2cb,_0x242b78,_0x4a6037){return db[_0x77f2('0x46')]['find']({'where':{'id':_0x5db2cb['params']['id']}})[_0x77f2('0x22')](handleEntityNotFound(_0x242b78,null))[_0x77f2('0x22')](function(_0x2b7325){if(_0x2b7325){return _0x2b7325[_0x77f2('0x121')](_0x5db2cb[_0x77f2('0x4f')]['ids'])[_0x77f2('0x22')](function(){if(_['isArray'](_0x5db2cb['query'][_0x77f2('0x6b')])){for(var _0x5b1929=0x0;_0x5b1929<_0x5db2cb[_0x77f2('0x4f')]['ids'][_0x77f2('0x65')];_0x5b1929+=0x1){socket[_0x77f2('0xac')](_0x77f2('0x122'),{'ChatInteractionId':Number(_0x5db2cb['query'][_0x77f2('0x6b')][_0x5b1929]),'UserId':Number(_0x5db2cb[_0x77f2('0x64')]['id'])});}}else{socket[_0x77f2('0xac')](_0x77f2('0x122'),{'ChatInteractionId':Number(_0x5db2cb[_0x77f2('0x4f')]['ids']),'UserId':Number(_0x5db2cb[_0x77f2('0x64')]['id'])});}});}})[_0x77f2('0x22')](respondWithStatusCode(_0x242b78,null))[_0x77f2('0x2d')](handleError(_0x242b78,null));};exports[_0x77f2('0x123')]=function(_0x183d9b,_0x54cedc,_0x2bec6a){return db[_0x77f2('0x46')][_0x77f2('0x41')]({'where':{'id':_0x183d9b[_0x77f2('0x64')]['id']}})[_0x77f2('0x22')](handleEntityNotFound(_0x54cedc,null))[_0x77f2('0x22')](function(_0x34df4b){if(_0x34df4b){return _0x34df4b[_0x77f2('0x123')](_0x183d9b[_0x77f2('0x68')][_0x77f2('0x6b')],_['omit'](_0x183d9b[_0x77f2('0x68')],[_0x77f2('0x6b'),'id'])||{})['spread'](function(){for(var _0x5c358f=0x0;_0x5c358f<_0x183d9b[_0x77f2('0x68')][_0x77f2('0x6b')]['length'];_0x5c358f+=0x1){socket[_0x77f2('0xac')]('user_has_mail_interactions:save',{'MailInteractionId':Number(_0x183d9b[_0x77f2('0x68')][_0x77f2('0x6b')][_0x5c358f]),'UserId':Number(_0x183d9b[_0x77f2('0x64')]['id'])});}return _0x183d9b['body'][_0x77f2('0x6b')];});}})[_0x77f2('0x22')](respondWithResult(_0x54cedc,null))[_0x77f2('0x2d')](handleError(_0x54cedc,null));};exports[_0x77f2('0x124')]=function(_0x11b229,_0xbffe82,_0x315b30){return db[_0x77f2('0x46')][_0x77f2('0x41')]({'where':{'id':_0x11b229['params']['id']}})[_0x77f2('0x22')](handleEntityNotFound(_0xbffe82,null))[_0x77f2('0x22')](function(_0x23f484){if(_0x23f484){return _0x23f484[_0x77f2('0x124')](_0x11b229[_0x77f2('0x4f')][_0x77f2('0x6b')])[_0x77f2('0x22')](function(){if(_[_0x77f2('0x125')](_0x11b229[_0x77f2('0x4f')][_0x77f2('0x6b')])){for(var _0x2c74b3=0x0;_0x2c74b3<_0x11b229[_0x77f2('0x4f')][_0x77f2('0x6b')][_0x77f2('0x65')];_0x2c74b3+=0x1){socket[_0x77f2('0xac')](_0x77f2('0x126'),{'MailInteractionId':Number(_0x11b229[_0x77f2('0x4f')][_0x77f2('0x6b')][_0x2c74b3]),'UserId':Number(_0x11b229['params']['id'])});}}else{socket[_0x77f2('0xac')](_0x77f2('0x126'),{'MailInteractionId':Number(_0x11b229[_0x77f2('0x4f')]['ids']),'UserId':Number(_0x11b229[_0x77f2('0x64')]['id'])});}});}})[_0x77f2('0x22')](respondWithStatusCode(_0xbffe82,null))[_0x77f2('0x2d')](handleError(_0xbffe82,null));};exports[_0x77f2('0x127')]=function(_0x5ae6d6,_0x11ad10,_0xa11bf6){return db[_0x77f2('0x46')][_0x77f2('0x41')]({'where':{'id':_0x5ae6d6['params']['id']}})['then'](handleEntityNotFound(_0x11ad10,null))[_0x77f2('0x22')](function(_0x3bfe3b){if(_0x3bfe3b){return _0x3bfe3b[_0x77f2('0x127')](_0x5ae6d6['body']['ids'],_[_0x77f2('0x6c')](_0x5ae6d6['body'],['ids','id'])||{})['spread'](function(){for(var _0x1c4e15=0x0;_0x1c4e15<_0x5ae6d6['body']['ids'][_0x77f2('0x65')];_0x1c4e15+=0x1){socket['emit'](_0x77f2('0x128'),{'FaxInteractionId':Number(_0x5ae6d6[_0x77f2('0x68')][_0x77f2('0x6b')][_0x1c4e15]),'UserId':Number(_0x5ae6d6[_0x77f2('0x64')]['id'])});}return _0x5ae6d6[_0x77f2('0x68')]['ids'];});}})[_0x77f2('0x22')](respondWithResult(_0x11ad10,null))['catch'](handleError(_0x11ad10,null));};exports[_0x77f2('0x129')]=function(_0x1c8bb9,_0x2542ac,_0x1a4d93){return db[_0x77f2('0x46')][_0x77f2('0x41')]({'where':{'id':_0x1c8bb9[_0x77f2('0x64')]['id']}})['then'](handleEntityNotFound(_0x2542ac,null))[_0x77f2('0x22')](function(_0x4a9d1d){if(_0x4a9d1d){return _0x4a9d1d['removeFaxInteractions'](_0x1c8bb9[_0x77f2('0x4f')]['ids'])['then'](function(){if(_[_0x77f2('0x125')](_0x1c8bb9['query']['ids'])){for(var _0x166166=0x0;_0x166166<_0x1c8bb9['query'][_0x77f2('0x6b')]['length'];_0x166166+=0x1){socket[_0x77f2('0xac')](_0x77f2('0x12a'),{'FaxInteractionId':Number(_0x1c8bb9[_0x77f2('0x4f')]['ids'][_0x166166]),'UserId':Number(_0x1c8bb9[_0x77f2('0x64')]['id'])});}}else{socket[_0x77f2('0xac')](_0x77f2('0x12a'),{'FaxInteractionId':Number(_0x1c8bb9[_0x77f2('0x4f')][_0x77f2('0x6b')]),'UserId':Number(_0x1c8bb9[_0x77f2('0x64')]['id'])});}});}})[_0x77f2('0x22')](respondWithStatusCode(_0x2542ac,null))[_0x77f2('0x2d')](handleError(_0x2542ac,null));};exports[_0x77f2('0x12b')]=function(_0x3de626,_0x59e903,_0x5b89c6){return db[_0x77f2('0x46')][_0x77f2('0x41')]({'where':{'id':_0x3de626[_0x77f2('0x64')]['id']}})[_0x77f2('0x22')](handleEntityNotFound(_0x59e903,null))[_0x77f2('0x22')](function(_0x294186){if(_0x294186){return _0x294186[_0x77f2('0x12b')](_0x3de626['body'][_0x77f2('0x6b')],_[_0x77f2('0x6c')](_0x3de626[_0x77f2('0x68')],[_0x77f2('0x6b'),'id'])||{})[_0x77f2('0xaa')](function(){for(var _0x460994=0x0;_0x460994<_0x3de626[_0x77f2('0x68')]['ids'][_0x77f2('0x65')];_0x460994+=0x1){socket[_0x77f2('0xac')](_0x77f2('0x12c'),{'SmsInteractionId':Number(_0x3de626['body']['ids'][_0x460994]),'UserId':Number(_0x3de626['params']['id'])});}return _0x3de626[_0x77f2('0x68')][_0x77f2('0x6b')];});}})[_0x77f2('0x22')](respondWithResult(_0x59e903,null))[_0x77f2('0x2d')](handleError(_0x59e903,null));};exports['removeSmsInteractions']=function(_0x15601e,_0x3b99fa,_0x45ec28){return db['User']['find']({'where':{'id':_0x15601e[_0x77f2('0x64')]['id']}})[_0x77f2('0x22')](handleEntityNotFound(_0x3b99fa,null))[_0x77f2('0x22')](function(_0x197d62){if(_0x197d62){return _0x197d62[_0x77f2('0x12d')](_0x15601e[_0x77f2('0x4f')]['ids'])[_0x77f2('0x22')](function(){if(_['isArray'](_0x15601e[_0x77f2('0x4f')][_0x77f2('0x6b')])){for(var _0x13e76a=0x0;_0x13e76a<_0x15601e[_0x77f2('0x4f')]['ids'][_0x77f2('0x65')];_0x13e76a+=0x1){socket[_0x77f2('0xac')](_0x77f2('0x12e'),{'SmsInteractionId':Number(_0x15601e[_0x77f2('0x4f')][_0x77f2('0x6b')][_0x13e76a]),'UserId':Number(_0x15601e['params']['id'])});}}else{socket['emit']('user_has_sms_interactions:remove',{'SmsInteractionId':Number(_0x15601e[_0x77f2('0x4f')][_0x77f2('0x6b')]),'UserId':Number(_0x15601e[_0x77f2('0x64')]['id'])});}});}})[_0x77f2('0x22')](respondWithStatusCode(_0x3b99fa,null))[_0x77f2('0x2d')](handleError(_0x3b99fa,null));};exports[_0x77f2('0x12f')]=function(_0x4bf511,_0x461b8a,_0x542c1a){return db[_0x77f2('0x46')]['find']({'where':{'id':_0x4bf511[_0x77f2('0x64')]['id']}})[_0x77f2('0x22')](handleEntityNotFound(_0x461b8a,null))['then'](function(_0x318c3a){if(_0x318c3a){return _0x318c3a[_0x77f2('0x12f')](_0x4bf511[_0x77f2('0x68')][_0x77f2('0x6b')],_['omit'](_0x4bf511['body'],[_0x77f2('0x6b'),'id'])||{})[_0x77f2('0xaa')](function(){for(var _0x40c571=0x0;_0x40c571<_0x4bf511['body'][_0x77f2('0x6b')][_0x77f2('0x65')];_0x40c571+=0x1){socket[_0x77f2('0xac')](_0x77f2('0x130'),{'OpenchannelInteractionId':Number(_0x4bf511[_0x77f2('0x68')][_0x77f2('0x6b')][_0x40c571]),'UserId':Number(_0x4bf511[_0x77f2('0x64')]['id'])});}return _0x4bf511[_0x77f2('0x68')][_0x77f2('0x6b')];});}})[_0x77f2('0x22')](respondWithResult(_0x461b8a,null))[_0x77f2('0x2d')](handleError(_0x461b8a,null));};exports[_0x77f2('0x131')]=function(_0x4b555b,_0x4190b1,_0x4f8afd){return db[_0x77f2('0x46')][_0x77f2('0x41')]({'where':{'id':_0x4b555b[_0x77f2('0x64')]['id']}})[_0x77f2('0x22')](handleEntityNotFound(_0x4190b1,null))[_0x77f2('0x22')](function(_0x1be5bd){if(_0x1be5bd){return _0x1be5bd['removeOpenchannelInteractions'](_0x4b555b['query']['ids'])[_0x77f2('0x22')](function(){if(_[_0x77f2('0x125')](_0x4b555b['query']['ids'])){for(var _0x86111f=0x0;_0x86111f<_0x4b555b[_0x77f2('0x4f')][_0x77f2('0x6b')][_0x77f2('0x65')];_0x86111f+=0x1){socket[_0x77f2('0xac')](_0x77f2('0x132'),{'OpenchannelInteractionId':Number(_0x4b555b['query'][_0x77f2('0x6b')][_0x86111f]),'UserId':Number(_0x4b555b[_0x77f2('0x64')]['id'])});}}else{socket['emit'](_0x77f2('0x132'),{'OpenchannelInteractionId':Number(_0x4b555b[_0x77f2('0x4f')]['ids']),'UserId':Number(_0x4b555b[_0x77f2('0x64')]['id'])});}});}})[_0x77f2('0x22')](respondWithStatusCode(_0x4190b1,null))[_0x77f2('0x2d')](handleError(_0x4190b1,null));};exports[_0x77f2('0x133')]=function(_0xf6536c,_0x1d40f7,_0x560fff){return db['User']['find']({'where':{'id':_0xf6536c[_0x77f2('0x64')]['id']}})[_0x77f2('0x22')](handleEntityNotFound(_0x1d40f7,null))[_0x77f2('0x22')](function(_0x2924a3){if(_0x2924a3){return _0x2924a3[_0x77f2('0x133')](_0xf6536c['body'][_0x77f2('0x6b')],_[_0x77f2('0x6c')](_0xf6536c[_0x77f2('0x68')],[_0x77f2('0x6b'),'id'])||{})[_0x77f2('0xaa')](function(){for(var _0xff1e7=0x0;_0xff1e7<_0xf6536c[_0x77f2('0x68')]['ids'][_0x77f2('0x65')];_0xff1e7+=0x1){socket[_0x77f2('0xac')]('user_has_whatsapp_interactions:save',{'WhatsappInteractionId':Number(_0xf6536c[_0x77f2('0x68')][_0x77f2('0x6b')][_0xff1e7]),'UserId':Number(_0xf6536c[_0x77f2('0x64')]['id'])});}return _0xf6536c[_0x77f2('0x68')][_0x77f2('0x6b')];});}})['then'](respondWithResult(_0x1d40f7,null))[_0x77f2('0x2d')](handleError(_0x1d40f7,null));};exports['removeWhatsappInteractions']=function(_0x555192,_0x590ceb,_0x2348f9){return db[_0x77f2('0x46')]['find']({'where':{'id':_0x555192[_0x77f2('0x64')]['id']}})['then'](handleEntityNotFound(_0x590ceb,null))[_0x77f2('0x22')](function(_0x16599d){if(_0x16599d){return _0x16599d['removeWhatsappInteractions'](_0x555192['query'][_0x77f2('0x6b')]);}})[_0x77f2('0x22')](respondWithStatusCode(_0x590ceb,null))[_0x77f2('0x2d')](handleError(_0x590ceb,null));};exports[_0x77f2('0x134')]=function(_0x511e42,_0x13b93a,_0x24e2e2){var _0x1564c3={};var _0x4dfea1={};var _0x33436f;var _0x4bcc26;return db['User'][_0x77f2('0x97')]({'where':{'id':_0x511e42[_0x77f2('0x64')]['id']}})[_0x77f2('0x22')](handleEntityNotFound(_0x13b93a,null))[_0x77f2('0x22')](function(_0x32859f){if(_0x32859f){_0x33436f=_0x32859f;_0x4dfea1['model']=_[_0x77f2('0x50')](db[_0x77f2('0x135')][_0x77f2('0x47')]);_0x4dfea1[_0x77f2('0x4f')]=_[_0x77f2('0x50')](_0x511e42[_0x77f2('0x4f')]);_0x4dfea1['filters']=_[_0x77f2('0x53')](_0x4dfea1[_0x77f2('0x4b')],_0x4dfea1[_0x77f2('0x4f')]);_0x1564c3[_0x77f2('0x52')]=_[_0x77f2('0x53')](_0x4dfea1[_0x77f2('0x4b')],qs[_0x77f2('0x54')](_0x511e42[_0x77f2('0x4f')][_0x77f2('0x54')]));_0x1564c3[_0x77f2('0x52')]=_0x1564c3[_0x77f2('0x52')][_0x77f2('0x65')]?_0x1564c3['attributes']:_0x4dfea1[_0x77f2('0x4b')];_0x1564c3[_0x77f2('0x57')]=qs[_0x77f2('0x58')](_0x511e42[_0x77f2('0x4f')][_0x77f2('0x58')]);_0x1564c3[_0x77f2('0x59')]=qs['filters'](_['pick'](_0x511e42['query'],_0x4dfea1[_0x77f2('0x51')]));if(_0x511e42[_0x77f2('0x4f')]['filter']){_0x1564c3[_0x77f2('0x59')]=_[_0x77f2('0x5c')](_0x1564c3[_0x77f2('0x59')],{'$or':_[_0x77f2('0x3e')](_0x1564c3[_0x77f2('0x52')],function(_0x5831ff){var _0x9d4dc2={};_0x9d4dc2[_0x5831ff]={'$like':'%'+_0x511e42[_0x77f2('0x4f')]['filter']+'%'};return _0x9d4dc2;})});}_0x1564c3=_[_0x77f2('0x5c')]({},_0x1564c3,_0x511e42[_0x77f2('0x66')]);return _0x33436f[_0x77f2('0x134')](_0x1564c3);}})['then'](function(_0x173815){if(_0x173815){_0x4bcc26=_0x173815[_0x77f2('0x65')];if(!_0x511e42[_0x77f2('0x4f')][_0x77f2('0x55')](_0x77f2('0x56'))){_0x1564c3[_0x77f2('0x33')]=qs[_0x77f2('0x33')](_0x511e42[_0x77f2('0x4f')][_0x77f2('0x33')]);_0x1564c3['offset']=qs[_0x77f2('0x32')](_0x511e42[_0x77f2('0x4f')]['offset']);}return _0x33436f['getVoicePrefixes'](_0x1564c3);}})['then'](function(_0x2c5a2e){if(_0x2c5a2e){return _0x2c5a2e?{'count':_0x4bcc26,'rows':_0x2c5a2e}:null;}})['then'](respondWithResult(_0x13b93a,null))[_0x77f2('0x2d')](handleError(_0x13b93a,null));};exports[_0x77f2('0x136')]=function(_0x251f1b,_0x5731f5,_0x11ff3a){var _0x48e335={};var _0x57ef68={};var _0x536b78;var _0xefecff;return db[_0x77f2('0x46')][_0x77f2('0x97')]({'where':{'id':_0x251f1b[_0x77f2('0x64')]['id']}})[_0x77f2('0x22')](handleEntityNotFound(_0x5731f5,null))[_0x77f2('0x22')](function(_0x574cc8){if(_0x574cc8){_0x536b78=_0x574cc8;_0x57ef68[_0x77f2('0x4b')]=_[_0x77f2('0x50')](db[_0x77f2('0x137')]['rawAttributes']);_0x57ef68[_0x77f2('0x4f')]=_[_0x77f2('0x50')](_0x251f1b['query']);_0x57ef68[_0x77f2('0x51')]=_['intersection'](_0x57ef68[_0x77f2('0x4b')],_0x57ef68[_0x77f2('0x4f')]);_0x48e335[_0x77f2('0x52')]=_['intersection'](_0x57ef68[_0x77f2('0x4b')],qs[_0x77f2('0x54')](_0x251f1b[_0x77f2('0x4f')][_0x77f2('0x54')]));_0x48e335[_0x77f2('0x52')]=_0x48e335[_0x77f2('0x52')]['length']?_0x48e335['attributes']:_0x57ef68['model'];_0x48e335[_0x77f2('0x57')]=qs['sort'](_0x251f1b[_0x77f2('0x4f')][_0x77f2('0x58')]);_0x48e335[_0x77f2('0x59')]=qs[_0x77f2('0x51')](_[_0x77f2('0x5a')](_0x251f1b['query'],_0x57ef68[_0x77f2('0x51')]));if(_0x251f1b[_0x77f2('0x4f')][_0x77f2('0x5b')]){_0x48e335[_0x77f2('0x59')]=_[_0x77f2('0x5c')](_0x48e335[_0x77f2('0x59')],{'$or':_[_0x77f2('0x3e')](_0x48e335['attributes'],function(_0x299863){var _0x1237d7={};_0x1237d7[_0x299863]={'$like':'%'+_0x251f1b[_0x77f2('0x4f')][_0x77f2('0x5b')]+'%'};return _0x1237d7;})});}_0x48e335=_[_0x77f2('0x5c')]({},_0x48e335,_0x251f1b[_0x77f2('0x66')]);return _0x536b78[_0x77f2('0x136')](_0x48e335);}})[_0x77f2('0x22')](function(_0x554a32){if(_0x554a32){_0xefecff=_0x554a32['length'];if(!_0x251f1b['query'][_0x77f2('0x55')]('nolimit')){_0x48e335[_0x77f2('0x33')]=qs[_0x77f2('0x33')](_0x251f1b[_0x77f2('0x4f')]['limit']);_0x48e335[_0x77f2('0x32')]=qs[_0x77f2('0x32')](_0x251f1b[_0x77f2('0x4f')][_0x77f2('0x32')]);}return _0x536b78[_0x77f2('0x136')](_0x48e335);}})[_0x77f2('0x22')](function(_0x1a5ae0){if(_0x1a5ae0){return _0x1a5ae0?{'count':_0xefecff,'rows':_0x1a5ae0}:null;}})['then'](respondWithResult(_0x5731f5,null))[_0x77f2('0x2d')](handleError(_0x5731f5,null));};exports[_0x77f2('0x138')]=function(_0x4b2d32,_0x18fbb5,_0xcfe27a){return db['User'][_0x77f2('0x41')]({'where':{'id':_0x4b2d32[_0x77f2('0x64')]['id']}})[_0x77f2('0x22')](handleEntityNotFound(_0x18fbb5,null))[_0x77f2('0x22')](function(_0x3179b6){if(_0x3179b6){return _0x3179b6[_0x77f2('0x138')](_0x4b2d32[_0x77f2('0x68')][_0x77f2('0x6b')],_['omit'](_0x4b2d32[_0x77f2('0x68')],[_0x77f2('0x6b'),'id'])||{});}})[_0x77f2('0x22')](respondWithResult(_0x18fbb5,null))[_0x77f2('0x2d')](handleError(_0x18fbb5,null));};exports[_0x77f2('0x139')]=function(_0x2ec3b0,_0xe7c1fa,_0x5bc855){return db[_0x77f2('0x46')][_0x77f2('0x41')]({'where':{'id':_0x2ec3b0['params']['id']}})[_0x77f2('0x22')](handleEntityNotFound(_0xe7c1fa,null))['then'](function(_0x43e4d7){if(_0x43e4d7){return _0x43e4d7[_0x77f2('0x139')](_0x2ec3b0[_0x77f2('0x4f')][_0x77f2('0x6b')]);}})[_0x77f2('0x22')](respondWithStatusCode(_0xe7c1fa,null))['catch'](handleError(_0xe7c1fa,null));};exports[_0x77f2('0x13a')]=function(_0x112246,_0x34a563,_0x2e9daa){var _0x369166={};var _0x53bfd2={};var _0x2a938c;var _0x63f0f9;return db[_0x77f2('0x46')]['findOne']({'where':{'id':_0x112246[_0x77f2('0x64')]['id']}})[_0x77f2('0x22')](handleEntityNotFound(_0x34a563,null))[_0x77f2('0x22')](function(_0x5a9aab){if(_0x5a9aab){_0x2a938c=_0x5a9aab;_0x53bfd2[_0x77f2('0x4b')]=_[_0x77f2('0x50')](db['MailAccount']['rawAttributes']);_0x53bfd2[_0x77f2('0x4f')]=_[_0x77f2('0x50')](_0x112246[_0x77f2('0x4f')]);_0x53bfd2['filters']=_['intersection'](_0x53bfd2['model'],_0x53bfd2['query']);_0x369166[_0x77f2('0x52')]=_[_0x77f2('0x53')](_0x53bfd2[_0x77f2('0x4b')],qs[_0x77f2('0x54')](_0x112246[_0x77f2('0x4f')]['fields']));_0x369166[_0x77f2('0x52')]=_0x369166[_0x77f2('0x52')][_0x77f2('0x65')]?_0x369166[_0x77f2('0x52')]:_0x53bfd2['model'];_0x369166[_0x77f2('0x57')]=qs[_0x77f2('0x58')](_0x112246[_0x77f2('0x4f')][_0x77f2('0x58')]);_0x369166[_0x77f2('0x59')]=qs[_0x77f2('0x51')](_[_0x77f2('0x5a')](_0x112246[_0x77f2('0x4f')],_0x53bfd2['filters']));if(_0x112246[_0x77f2('0x4f')][_0x77f2('0x5b')]){_0x369166[_0x77f2('0x59')]=_[_0x77f2('0x5c')](_0x369166[_0x77f2('0x59')],{'$or':_['map'](_0x369166['attributes'],function(_0x44739c){var _0x3dfb80={};_0x3dfb80[_0x44739c]={'$like':'%'+_0x112246[_0x77f2('0x4f')][_0x77f2('0x5b')]+'%'};return _0x3dfb80;})});}_0x369166=_['merge']({},_0x369166,_0x112246[_0x77f2('0x66')]);return _0x2a938c[_0x77f2('0x13a')](_0x369166);}})['then'](function(_0x1454ca){if(_0x1454ca){_0x63f0f9=_0x1454ca['length'];if(!_0x112246['query']['hasOwnProperty'](_0x77f2('0x56'))){_0x369166['limit']=qs[_0x77f2('0x33')](_0x112246['query'][_0x77f2('0x33')]);_0x369166[_0x77f2('0x32')]=qs[_0x77f2('0x32')](_0x112246[_0x77f2('0x4f')][_0x77f2('0x32')]);}return _0x2a938c[_0x77f2('0x13a')](_0x369166);}})[_0x77f2('0x22')](function(_0x5ca3f7){if(_0x5ca3f7){return _0x5ca3f7?{'count':_0x63f0f9,'rows':_0x5ca3f7}:null;}})[_0x77f2('0x22')](respondWithResult(_0x34a563,null))[_0x77f2('0x2d')](handleError(_0x34a563,null));};exports['addMailAccounts']=function(_0x4ef50d,_0x493540,_0x519c4c){return db[_0x77f2('0x46')][_0x77f2('0x41')]({'where':{'id':_0x4ef50d[_0x77f2('0x64')]['id']}})[_0x77f2('0x22')](handleEntityNotFound(_0x493540,null))[_0x77f2('0x22')](function(_0x179e8f){if(_0x179e8f){return _0x179e8f[_0x77f2('0x13b')](_0x4ef50d[_0x77f2('0x68')][_0x77f2('0x6b')],_['omit'](_0x4ef50d[_0x77f2('0x68')],['ids','id'])||{});}})[_0x77f2('0x22')](respondWithResult(_0x493540,null))[_0x77f2('0x2d')](handleError(_0x493540,null));};exports[_0x77f2('0x13c')]=function(_0x1c7bca,_0xeda301,_0x492e39){return db['User'][_0x77f2('0x41')]({'where':{'id':_0x1c7bca[_0x77f2('0x64')]['id']}})['then'](handleEntityNotFound(_0xeda301,null))['then'](function(_0x2a35b1){if(_0x2a35b1){return _0x2a35b1[_0x77f2('0x13c')](_0x1c7bca['query']['ids']);}})[_0x77f2('0x22')](respondWithStatusCode(_0xeda301,null))[_0x77f2('0x2d')](handleError(_0xeda301,null));};exports[_0x77f2('0x13d')]=function(_0x5dada7,_0xd33472,_0x50ac46){var _0x30d78b={};var _0x25793e={};var _0x5aa4c6;var _0xe59e;return db[_0x77f2('0x46')]['findOne']({'where':{'id':_0x5dada7[_0x77f2('0x64')]['id']}})[_0x77f2('0x22')](handleEntityNotFound(_0xd33472,null))[_0x77f2('0x22')](function(_0x4a6c02){if(_0x4a6c02){_0x5aa4c6=_0x4a6c02;_0x25793e[_0x77f2('0x4b')]=_[_0x77f2('0x50')](db[_0x77f2('0x13e')][_0x77f2('0x47')]);_0x25793e[_0x77f2('0x4f')]=_[_0x77f2('0x50')](_0x5dada7[_0x77f2('0x4f')]);_0x25793e[_0x77f2('0x51')]=_[_0x77f2('0x53')](_0x25793e[_0x77f2('0x4b')],_0x25793e[_0x77f2('0x4f')]);_0x30d78b[_0x77f2('0x52')]=_[_0x77f2('0x53')](_0x25793e[_0x77f2('0x4b')],qs[_0x77f2('0x54')](_0x5dada7['query'][_0x77f2('0x54')]));_0x30d78b[_0x77f2('0x52')]=_0x30d78b[_0x77f2('0x52')][_0x77f2('0x65')]?_0x30d78b[_0x77f2('0x52')]:_0x25793e['model'];_0x30d78b['order']=qs[_0x77f2('0x58')](_0x5dada7['query'][_0x77f2('0x58')]);_0x30d78b[_0x77f2('0x59')]=qs[_0x77f2('0x51')](_['pick'](_0x5dada7[_0x77f2('0x4f')],_0x25793e[_0x77f2('0x51')]));if(_0x5dada7[_0x77f2('0x4f')][_0x77f2('0x5b')]){_0x30d78b[_0x77f2('0x59')]=_[_0x77f2('0x5c')](_0x30d78b['where'],{'$or':_['map'](_0x30d78b[_0x77f2('0x52')],function(_0x15b06c){var _0x29f636={};_0x29f636[_0x15b06c]={'$like':'%'+_0x5dada7[_0x77f2('0x4f')][_0x77f2('0x5b')]+'%'};return _0x29f636;})});}_0x30d78b=_['merge']({},_0x30d78b,_0x5dada7['options']);return _0x5aa4c6[_0x77f2('0x13d')](_0x30d78b);}})[_0x77f2('0x22')](function(_0x1002c1){if(_0x1002c1){_0xe59e=_0x1002c1[_0x77f2('0x65')];if(!_0x5dada7['query'][_0x77f2('0x55')](_0x77f2('0x56'))){_0x30d78b[_0x77f2('0x33')]=qs['limit'](_0x5dada7[_0x77f2('0x4f')][_0x77f2('0x33')]);_0x30d78b['offset']=qs[_0x77f2('0x32')](_0x5dada7['query'][_0x77f2('0x32')]);}return _0x5aa4c6[_0x77f2('0x13d')](_0x30d78b);}})[_0x77f2('0x22')](function(_0x2ece1a){if(_0x2ece1a){return _0x2ece1a?{'count':_0xe59e,'rows':_0x2ece1a}:null;}})['then'](respondWithResult(_0xd33472,null))['catch'](handleError(_0xd33472,null));};exports[_0x77f2('0x13f')]=function(_0x5e8ab8,_0x55694c,_0x269b6f){return db[_0x77f2('0x46')]['find']({'where':{'id':_0x5e8ab8[_0x77f2('0x64')]['id']}})[_0x77f2('0x22')](handleEntityNotFound(_0x55694c,null))['then'](function(_0x355500){if(_0x355500){return _0x355500['addOpenchannelAccounts'](_0x5e8ab8[_0x77f2('0x68')][_0x77f2('0x6b')],_['omit'](_0x5e8ab8['body'],[_0x77f2('0x6b'),'id'])||{});}})['then'](respondWithResult(_0x55694c,null))[_0x77f2('0x2d')](handleError(_0x55694c,null));};exports[_0x77f2('0x140')]=function(_0x565b61,_0x18a83a,_0x3c5e73){return db['User'][_0x77f2('0x41')]({'where':{'id':_0x565b61[_0x77f2('0x64')]['id']}})[_0x77f2('0x22')](handleEntityNotFound(_0x18a83a,null))[_0x77f2('0x22')](function(_0x56d6ad){if(_0x56d6ad){return _0x56d6ad[_0x77f2('0x140')](_0x565b61[_0x77f2('0x4f')][_0x77f2('0x6b')]);}})[_0x77f2('0x22')](respondWithStatusCode(_0x18a83a,null))[_0x77f2('0x2d')](handleError(_0x18a83a,null));};exports['getSmsAccounts']=function(_0x1acf17,_0x50fb34,_0x2531db){var _0x3a700c={};var _0x48d0cc={};var _0x81eeeb;var _0x2418f4;return db['User']['findOne']({'where':{'id':_0x1acf17['params']['id']}})[_0x77f2('0x22')](handleEntityNotFound(_0x50fb34,null))[_0x77f2('0x22')](function(_0xa3b848){if(_0xa3b848){_0x81eeeb=_0xa3b848;_0x48d0cc[_0x77f2('0x4b')]=_[_0x77f2('0x50')](db[_0x77f2('0x141')][_0x77f2('0x47')]);_0x48d0cc[_0x77f2('0x4f')]=_[_0x77f2('0x50')](_0x1acf17[_0x77f2('0x4f')]);_0x48d0cc[_0x77f2('0x51')]=_[_0x77f2('0x53')](_0x48d0cc['model'],_0x48d0cc['query']);_0x3a700c[_0x77f2('0x52')]=_[_0x77f2('0x53')](_0x48d0cc[_0x77f2('0x4b')],qs['fields'](_0x1acf17[_0x77f2('0x4f')][_0x77f2('0x54')]));_0x3a700c[_0x77f2('0x52')]=_0x3a700c[_0x77f2('0x52')][_0x77f2('0x65')]?_0x3a700c[_0x77f2('0x52')]:_0x48d0cc[_0x77f2('0x4b')];_0x3a700c[_0x77f2('0x57')]=qs[_0x77f2('0x58')](_0x1acf17[_0x77f2('0x4f')][_0x77f2('0x58')]);_0x3a700c[_0x77f2('0x59')]=qs[_0x77f2('0x51')](_[_0x77f2('0x5a')](_0x1acf17[_0x77f2('0x4f')],_0x48d0cc[_0x77f2('0x51')]));if(_0x1acf17[_0x77f2('0x4f')][_0x77f2('0x5b')]){_0x3a700c[_0x77f2('0x59')]=_[_0x77f2('0x5c')](_0x3a700c['where'],{'$or':_['map'](_0x3a700c[_0x77f2('0x52')],function(_0x5d1f8b){var _0x1b003d={};_0x1b003d[_0x5d1f8b]={'$like':'%'+_0x1acf17[_0x77f2('0x4f')][_0x77f2('0x5b')]+'%'};return _0x1b003d;})});}_0x3a700c=_[_0x77f2('0x5c')]({},_0x3a700c,_0x1acf17['options']);return _0x81eeeb[_0x77f2('0x142')](_0x3a700c);}})[_0x77f2('0x22')](function(_0xaf207e){if(_0xaf207e){_0x2418f4=_0xaf207e['length'];if(!_0x1acf17[_0x77f2('0x4f')]['hasOwnProperty']('nolimit')){_0x3a700c[_0x77f2('0x33')]=qs[_0x77f2('0x33')](_0x1acf17['query'][_0x77f2('0x33')]);_0x3a700c[_0x77f2('0x32')]=qs[_0x77f2('0x32')](_0x1acf17[_0x77f2('0x4f')]['offset']);}return _0x81eeeb[_0x77f2('0x142')](_0x3a700c);}})[_0x77f2('0x22')](function(_0x86abb5){if(_0x86abb5){return _0x86abb5?{'count':_0x2418f4,'rows':_0x86abb5}:null;}})[_0x77f2('0x22')](respondWithResult(_0x50fb34,null))['catch'](handleError(_0x50fb34,null));};exports[_0x77f2('0x143')]=function(_0x44b1f0,_0x41cd5c,_0x1860e6){return db[_0x77f2('0x46')]['find']({'where':{'id':_0x44b1f0[_0x77f2('0x64')]['id']}})[_0x77f2('0x22')](handleEntityNotFound(_0x41cd5c,null))[_0x77f2('0x22')](function(_0x467c26){if(_0x467c26){return _0x467c26[_0x77f2('0x143')](_0x44b1f0['body']['ids'],_[_0x77f2('0x6c')](_0x44b1f0[_0x77f2('0x68')],[_0x77f2('0x6b'),'id'])||{});}})[_0x77f2('0x22')](respondWithResult(_0x41cd5c,null))['catch'](handleError(_0x41cd5c,null));};exports[_0x77f2('0x144')]=function(_0x5ec7ef,_0x196613,_0x2a99a2){return db[_0x77f2('0x46')][_0x77f2('0x41')]({'where':{'id':_0x5ec7ef[_0x77f2('0x64')]['id']}})['then'](handleEntityNotFound(_0x196613,null))[_0x77f2('0x22')](function(_0x2c8887){if(_0x2c8887){return _0x2c8887[_0x77f2('0x144')](_0x5ec7ef[_0x77f2('0x4f')][_0x77f2('0x6b')]);}})[_0x77f2('0x22')](respondWithStatusCode(_0x196613,null))[_0x77f2('0x2d')](handleError(_0x196613,null));};exports[_0x77f2('0x145')]=function(_0x3b1ad1,_0x5e2223,_0x5e4eeb){var _0x46046f={};var _0x11a673={};var _0x412a3f;var _0x2ad220;return db[_0x77f2('0x46')]['findOne']({'where':{'id':_0x3b1ad1[_0x77f2('0x64')]['id']}})[_0x77f2('0x22')](handleEntityNotFound(_0x5e2223,null))[_0x77f2('0x22')](function(_0xf08989){if(_0xf08989){_0x412a3f=_0xf08989;_0x11a673[_0x77f2('0x4b')]=_['keys'](db[_0x77f2('0x146')][_0x77f2('0x47')]);_0x11a673[_0x77f2('0x4f')]=_[_0x77f2('0x50')](_0x3b1ad1[_0x77f2('0x4f')]);_0x11a673[_0x77f2('0x51')]=_[_0x77f2('0x53')](_0x11a673[_0x77f2('0x4b')],_0x11a673[_0x77f2('0x4f')]);_0x46046f[_0x77f2('0x52')]=_['intersection'](_0x11a673[_0x77f2('0x4b')],qs[_0x77f2('0x54')](_0x3b1ad1[_0x77f2('0x4f')]['fields']));_0x46046f[_0x77f2('0x52')]=_0x46046f[_0x77f2('0x52')]['length']?_0x46046f[_0x77f2('0x52')]:_0x11a673[_0x77f2('0x4b')];_0x46046f['order']=qs['sort'](_0x3b1ad1[_0x77f2('0x4f')][_0x77f2('0x58')]);_0x46046f['where']=qs[_0x77f2('0x51')](_[_0x77f2('0x5a')](_0x3b1ad1[_0x77f2('0x4f')],_0x11a673['filters']));if(_0x3b1ad1[_0x77f2('0x4f')][_0x77f2('0x5b')]){_0x46046f[_0x77f2('0x59')]=_['merge'](_0x46046f['where'],{'$or':_[_0x77f2('0x3e')](_0x46046f[_0x77f2('0x52')],function(_0x1c0914){var _0x335ed6={};_0x335ed6[_0x1c0914]={'$like':'%'+_0x3b1ad1[_0x77f2('0x4f')][_0x77f2('0x5b')]+'%'};return _0x335ed6;})});}_0x46046f=_['merge']({},_0x46046f,_0x3b1ad1['options']);return _0x412a3f[_0x77f2('0x145')](_0x46046f);}})['then'](function(_0x344b1c){if(_0x344b1c){_0x2ad220=_0x344b1c[_0x77f2('0x65')];if(!_0x3b1ad1['query']['hasOwnProperty']('nolimit')){_0x46046f[_0x77f2('0x33')]=qs[_0x77f2('0x33')](_0x3b1ad1[_0x77f2('0x4f')][_0x77f2('0x33')]);_0x46046f[_0x77f2('0x32')]=qs[_0x77f2('0x32')](_0x3b1ad1['query'][_0x77f2('0x32')]);}return _0x412a3f[_0x77f2('0x145')](_0x46046f);}})[_0x77f2('0x22')](function(_0x3d8018){if(_0x3d8018){return _0x3d8018?{'count':_0x2ad220,'rows':_0x3d8018}:null;}})[_0x77f2('0x22')](respondWithResult(_0x5e2223,null))[_0x77f2('0x2d')](handleError(_0x5e2223,null));};exports['addChatWebsites']=function(_0x52dad9,_0x17d4eb,_0xab9bea){return db[_0x77f2('0x46')]['find']({'where':{'id':_0x52dad9[_0x77f2('0x64')]['id']}})[_0x77f2('0x22')](handleEntityNotFound(_0x17d4eb,null))[_0x77f2('0x22')](function(_0x9aa128){if(_0x9aa128){return _0x9aa128[_0x77f2('0x147')](_0x52dad9[_0x77f2('0x68')][_0x77f2('0x6b')],_['omit'](_0x52dad9['body'],['ids','id'])||{});}})[_0x77f2('0x22')](respondWithResult(_0x17d4eb,null))[_0x77f2('0x2d')](handleError(_0x17d4eb,null));};exports[_0x77f2('0x148')]=function(_0x22704e,_0x3abb53,_0x3dfff8){return db['User'][_0x77f2('0x41')]({'where':{'id':_0x22704e['params']['id']}})[_0x77f2('0x22')](handleEntityNotFound(_0x3abb53,null))['then'](function(_0x11373a){if(_0x11373a){return _0x11373a[_0x77f2('0x148')](_0x22704e[_0x77f2('0x4f')][_0x77f2('0x6b')]);}})[_0x77f2('0x22')](respondWithStatusCode(_0x3abb53,null))[_0x77f2('0x2d')](handleError(_0x3abb53,null));};exports['getWhatsappAccounts']=function(_0x23cdaa,_0x6a168b,_0xbcfbd){var _0x57d1b8={};var _0x12b25c={};var _0x373edf;var _0x49f0e6;return db[_0x77f2('0x46')][_0x77f2('0x97')]({'where':{'id':_0x23cdaa[_0x77f2('0x64')]['id']}})[_0x77f2('0x22')](handleEntityNotFound(_0x6a168b,null))[_0x77f2('0x22')](function(_0x6f265){if(_0x6f265){_0x373edf=_0x6f265;_0x12b25c[_0x77f2('0x4b')]=_['keys'](db[_0x77f2('0x149')][_0x77f2('0x47')]);_0x12b25c[_0x77f2('0x4f')]=_[_0x77f2('0x50')](_0x23cdaa['query']);_0x12b25c[_0x77f2('0x51')]=_[_0x77f2('0x53')](_0x12b25c[_0x77f2('0x4b')],_0x12b25c['query']);_0x57d1b8[_0x77f2('0x52')]=_[_0x77f2('0x53')](_0x12b25c[_0x77f2('0x4b')],qs['fields'](_0x23cdaa[_0x77f2('0x4f')][_0x77f2('0x54')]));_0x57d1b8[_0x77f2('0x52')]=_0x57d1b8[_0x77f2('0x52')][_0x77f2('0x65')]?_0x57d1b8[_0x77f2('0x52')]:_0x12b25c[_0x77f2('0x4b')];_0x57d1b8[_0x77f2('0x57')]=qs[_0x77f2('0x58')](_0x23cdaa[_0x77f2('0x4f')][_0x77f2('0x58')]);_0x57d1b8[_0x77f2('0x59')]=qs['filters'](_[_0x77f2('0x5a')](_0x23cdaa[_0x77f2('0x4f')],_0x12b25c['filters']));if(_0x23cdaa['query'][_0x77f2('0x5b')]){_0x57d1b8['where']=_[_0x77f2('0x5c')](_0x57d1b8[_0x77f2('0x59')],{'$or':_[_0x77f2('0x3e')](_0x57d1b8[_0x77f2('0x52')],function(_0xf03281){var _0xaebd30={};_0xaebd30[_0xf03281]={'$like':'%'+_0x23cdaa[_0x77f2('0x4f')][_0x77f2('0x5b')]+'%'};return _0xaebd30;})});}_0x57d1b8=_[_0x77f2('0x5c')]({},_0x57d1b8,_0x23cdaa[_0x77f2('0x66')]);return _0x373edf[_0x77f2('0x14a')](_0x57d1b8);}})[_0x77f2('0x22')](function(_0x51a9be){if(_0x51a9be){_0x49f0e6=_0x51a9be[_0x77f2('0x65')];if(!_0x23cdaa[_0x77f2('0x4f')]['hasOwnProperty'](_0x77f2('0x56'))){_0x57d1b8[_0x77f2('0x33')]=qs[_0x77f2('0x33')](_0x23cdaa['query'][_0x77f2('0x33')]);_0x57d1b8[_0x77f2('0x32')]=qs['offset'](_0x23cdaa[_0x77f2('0x4f')]['offset']);}return _0x373edf[_0x77f2('0x14a')](_0x57d1b8);}})[_0x77f2('0x22')](function(_0x15947f){if(_0x15947f){return _0x15947f?{'count':_0x49f0e6,'rows':_0x15947f}:null;}})['then'](respondWithResult(_0x6a168b,null))[_0x77f2('0x2d')](handleError(_0x6a168b,null));};exports['addWhatsappAccounts']=function(_0x4d80ef,_0x2b51b3,_0x131e02){return db[_0x77f2('0x46')][_0x77f2('0x41')]({'where':{'id':_0x4d80ef[_0x77f2('0x64')]['id']}})[_0x77f2('0x22')](handleEntityNotFound(_0x2b51b3,null))['then'](function(_0x5aba7d){if(_0x5aba7d){return _0x5aba7d[_0x77f2('0x14b')](_0x4d80ef[_0x77f2('0x68')][_0x77f2('0x6b')],_[_0x77f2('0x6c')](_0x4d80ef['body'],[_0x77f2('0x6b'),'id'])||{});}})[_0x77f2('0x22')](respondWithResult(_0x2b51b3,null))[_0x77f2('0x2d')](handleError(_0x2b51b3,null));};exports[_0x77f2('0x14c')]=function(_0xfaccb0,_0x387f63,_0x7ab92d){return db['User'][_0x77f2('0x41')]({'where':{'id':_0xfaccb0[_0x77f2('0x64')]['id']}})['then'](handleEntityNotFound(_0x387f63,null))['then'](function(_0x5ad471){if(_0x5ad471){return _0x5ad471[_0x77f2('0x14c')](_0xfaccb0[_0x77f2('0x4f')]['ids']);}})[_0x77f2('0x22')](respondWithStatusCode(_0x387f63,null))['catch'](handleError(_0x387f63,null));};exports[_0x77f2('0x14d')]=function(_0x17308c,_0x289fd8,_0x3402f2){var _0x199f91={};var _0x28efb1={};var _0x2ccc51;var _0x567b6b;return db[_0x77f2('0x46')][_0x77f2('0x97')]({'where':{'id':_0x17308c[_0x77f2('0x64')]['id']}})[_0x77f2('0x22')](handleEntityNotFound(_0x289fd8,null))[_0x77f2('0x22')](function(_0x422059){if(_0x422059){_0x2ccc51=_0x422059;_0x28efb1[_0x77f2('0x4b')]=_[_0x77f2('0x50')](db[_0x77f2('0x14e')][_0x77f2('0x47')]);_0x28efb1[_0x77f2('0x4f')]=_[_0x77f2('0x50')](_0x17308c[_0x77f2('0x4f')]);_0x28efb1[_0x77f2('0x51')]=_[_0x77f2('0x53')](_0x28efb1[_0x77f2('0x4b')],_0x28efb1['query']);_0x199f91['attributes']=_[_0x77f2('0x53')](_0x28efb1[_0x77f2('0x4b')],qs[_0x77f2('0x54')](_0x17308c[_0x77f2('0x4f')][_0x77f2('0x54')]));_0x199f91[_0x77f2('0x52')]=_0x199f91['attributes'][_0x77f2('0x65')]?_0x199f91[_0x77f2('0x52')]:_0x28efb1[_0x77f2('0x4b')];_0x199f91[_0x77f2('0x57')]=qs['sort'](_0x17308c[_0x77f2('0x4f')][_0x77f2('0x58')]);_0x199f91[_0x77f2('0x59')]=qs[_0x77f2('0x51')](_[_0x77f2('0x5a')](_0x17308c[_0x77f2('0x4f')],_0x28efb1['filters']));if(_0x17308c[_0x77f2('0x4f')][_0x77f2('0x5b')]){_0x199f91[_0x77f2('0x59')]=_['merge'](_0x199f91[_0x77f2('0x59')],{'$or':_[_0x77f2('0x3e')](_0x199f91['attributes'],function(_0x4529e4){var _0x93a74b={};_0x93a74b[_0x4529e4]={'$like':'%'+_0x17308c[_0x77f2('0x4f')][_0x77f2('0x5b')]+'%'};return _0x93a74b;})});}_0x199f91=_['merge']({},_0x199f91,_0x17308c[_0x77f2('0x66')]);return _0x2ccc51[_0x77f2('0x14d')](_0x199f91);}})['then'](function(_0x4cf1d6){if(_0x4cf1d6){_0x567b6b=_0x4cf1d6[_0x77f2('0x65')];if(!_0x17308c[_0x77f2('0x4f')][_0x77f2('0x55')](_0x77f2('0x56'))){_0x199f91[_0x77f2('0x33')]=qs[_0x77f2('0x33')](_0x17308c[_0x77f2('0x4f')][_0x77f2('0x33')]);_0x199f91[_0x77f2('0x32')]=qs[_0x77f2('0x32')](_0x17308c['query'][_0x77f2('0x32')]);}return _0x2ccc51[_0x77f2('0x14d')](_0x199f91);}})[_0x77f2('0x22')](function(_0x40a0f0){if(_0x40a0f0){return _0x40a0f0?{'count':_0x567b6b,'rows':_0x40a0f0}:null;}})[_0x77f2('0x22')](respondWithResult(_0x289fd8,null))[_0x77f2('0x2d')](handleError(_0x289fd8,null));};exports[_0x77f2('0x14f')]=function(_0x48681d,_0x464232,_0x2f1dc2){return db[_0x77f2('0x46')]['find']({'where':{'id':_0x48681d['params']['id']}})[_0x77f2('0x22')](handleEntityNotFound(_0x464232,null))[_0x77f2('0x22')](function(_0x4e3841){if(_0x4e3841){return _0x4e3841['addSquareProjects'](_0x48681d[_0x77f2('0x68')][_0x77f2('0x6b')],_[_0x77f2('0x6c')](_0x48681d['body'],['ids','id'])||{});}})[_0x77f2('0x22')](respondWithResult(_0x464232,null))[_0x77f2('0x2d')](handleError(_0x464232,null));};exports[_0x77f2('0x150')]=function(_0x352728,_0x31a122,_0x4be71f){return db[_0x77f2('0x46')][_0x77f2('0x41')]({'where':{'id':_0x352728[_0x77f2('0x64')]['id']}})[_0x77f2('0x22')](handleEntityNotFound(_0x31a122,null))[_0x77f2('0x22')](function(_0x45c255){if(_0x45c255){return _0x45c255[_0x77f2('0x150')](_0x352728[_0x77f2('0x4f')][_0x77f2('0x6b')]);}})[_0x77f2('0x22')](respondWithStatusCode(_0x31a122,null))[_0x77f2('0x2d')](handleError(_0x31a122,null));};exports[_0x77f2('0x151')]=function(_0x4ed02f,_0x55fe1d){var _0x450fc1={},_0xccc89d={},_0x19992b={'count':0x0,'rows':[]};var _0x32fe96=db[_0x77f2('0x152')][_0x77f2('0x47')];_0xccc89d[_0x77f2('0x4b')]=_[_0x77f2('0x50')](_0x32fe96);_0xccc89d[_0x77f2('0x4f')]=_[_0x77f2('0x50')](_0x4ed02f[_0x77f2('0x4f')]);_0xccc89d[_0x77f2('0x51')]=_[_0x77f2('0x53')](_0xccc89d['model'],_0xccc89d[_0x77f2('0x4f')]);_0xccc89d[_0x77f2('0x51')]=_['concat'](_0xccc89d[_0x77f2('0x51')],[_0x77f2('0x153'),_0x77f2('0x154'),_0x77f2('0x155'),'$gte',_0x77f2('0x156'),_0x77f2('0x157'),_0x77f2('0x158'),_0x77f2('0x159'),_0x77f2('0x15a'),_0x77f2('0x15b'),_0x77f2('0x15c'),_0x77f2('0x15d'),_0x77f2('0x15e'),_0x77f2('0x15f'),_0x77f2('0x160'),_0x77f2('0x161'),_0x77f2('0x162'),_0x77f2('0x15f'),'$overlap',_0x77f2('0x163'),_0x77f2('0x164'),'$any']);_0x450fc1[_0x77f2('0x52')]=_[_0x77f2('0x53')](_0xccc89d[_0x77f2('0x4b')],qs['fields'](_0x4ed02f[_0x77f2('0x4f')][_0x77f2('0x54')]));_0x450fc1[_0x77f2('0x52')]=_0x450fc1[_0x77f2('0x52')][_0x77f2('0x65')]?_0x450fc1[_0x77f2('0x52')]:_0xccc89d['model'];if(!_0x4ed02f[_0x77f2('0x4f')]['hasOwnProperty'](_0x77f2('0x56'))){_0x450fc1['limit']=qs[_0x77f2('0x33')](_0x4ed02f['query'][_0x77f2('0x33')]);_0x450fc1[_0x77f2('0x32')]=qs['offset'](_0x4ed02f[_0x77f2('0x4f')]['offset']);}_0x450fc1['order']=qs[_0x77f2('0x58')](_0x4ed02f[_0x77f2('0x4f')]['sort']);_0x450fc1[_0x77f2('0x59')]=qs[_0x77f2('0x51')](_[_0x77f2('0x5a')](_0x4ed02f[_0x77f2('0x4f')],_0xccc89d[_0x77f2('0x51')]));if(_0x4ed02f[_0x77f2('0x4f')][_0x77f2('0x5b')]){_0x450fc1[_0x77f2('0x59')]=_[_0x77f2('0x5c')](_0x450fc1['where'],{'$or':_['map'](_0x450fc1['attributes'],function(_0x2af693){var _0x269e96={};_0x269e96[_0x2af693]={'$like':'%'+_0x4ed02f[_0x77f2('0x4f')][_0x77f2('0x5b')]+'%'};return _0x269e96;})});}_0x450fc1['where']={'$and':[_0x450fc1['where'],{'$or':[{'UserId':_0x4ed02f[_0x77f2('0x64')]['id']},{'OwnerId':_0x4ed02f['params']['id']}]}]};_0x450fc1=_['merge']({},_0x450fc1,_0x4ed02f[_0x77f2('0x66')]);var _0x600cbe={'where':_0x450fc1[_0x77f2('0x59')]};return db['CmHopper']['count'](_0x600cbe)[_0x77f2('0x22')](function(_0x39b27e){_0x19992b[_0x77f2('0x60')]=_0x39b27e;if(_0x4ed02f[_0x77f2('0x4f')][_0x77f2('0x61')]){_0x450fc1[_0x77f2('0x62')]=[{'attributes':['id',_0x77f2('0x165'),_0x77f2('0x166'),_0x77f2('0xdd')],'model':db[_0x77f2('0xc3')],'as':'Contact'},{'attributes':['id','name',_0x77f2('0x167')],'model':db[_0x77f2('0xae')],'as':_0x77f2('0xca')}];}return db[_0x77f2('0x152')]['findAll'](_0x450fc1);})['then'](function(_0x18c14b){_0x19992b[_0x77f2('0x63')]=_0x18c14b;return _0x19992b;})[_0x77f2('0x22')](respondWithFilteredResult(_0x55fe1d,_0x450fc1))[_0x77f2('0x2d')](handleError(_0x55fe1d,null));};exports[_0x77f2('0x168')]=function(_0x3c3265,_0xdaffab,_0x592830){if(!_[_0x77f2('0x7d')](_0x3c3265['user']['id'])&&(_0x3c3265['user']['role']=='admin'||_0x3c3265[_0x77f2('0x3a')]['role']==_0x77f2('0x3a'))){return db[_0x77f2('0x46')]['findOne']({'where':{'id':_0x3c3265[_0x77f2('0x64')]['id']},'raw':!![]})[_0x77f2('0x22')](function(_0x3bd838){return authService['retrieveApiKey'](_0x3bd838);})['then'](function(_0x1f8cb9){if(_0x1f8cb9){return _0xdaffab['status'](0xc8)[_0x77f2('0x31')]({'api_key':_0x1f8cb9[_0x77f2('0x169')]});}else{return _0xdaffab[_0x77f2('0x2f')](0xcc)[_0x77f2('0x31')]({'message':_0x77f2('0x16a')});}})[_0x77f2('0x2d')](handleError(_0xdaffab,0x193));}else{return _0xdaffab[_0x77f2('0x2f')](0x191)[_0x77f2('0x31')]({'message':_0x77f2('0x16b')});}};exports['createApiKey']=function(_0x3c9672,_0x1392e7,_0x5d1eb4){if(!_[_0x77f2('0x7d')](_0x3c9672['user']['id'])&&(_0x3c9672[_0x77f2('0x3a')][_0x77f2('0x42')]==_0x77f2('0x70')||_0x3c9672[_0x77f2('0x3a')]['role']=='user')){return db[_0x77f2('0x46')][_0x77f2('0x41')]({'where':{'id':_0x3c9672[_0x77f2('0x64')]['id']}})[_0x77f2('0x22')](function(_0xdb5570){return authService[_0x77f2('0x16c')](_0xdb5570);})[_0x77f2('0x22')](function(_0x4ff6fb){return db['User'][_0x77f2('0x37')]({'apiKeyIat':_0x4ff6fb[_0x77f2('0x16d')],'apiKeyNonce':_0x4ff6fb[_0x77f2('0x16e')]},{'where':{'id':_0x3c9672[_0x77f2('0x64')]['id']}})[_0x77f2('0x22')](function(){return _0x1392e7[_0x77f2('0x2f')](0xc8)[_0x77f2('0x31')]({'api_key':_0x4ff6fb[_0x77f2('0x169')]});});})[_0x77f2('0x2d')](handleError(_0x1392e7,0x193));}else{return _0x1392e7[_0x77f2('0x2f')](0x191)['json']({'message':'You\x20don\x27t\x20have\x20sufficient\x20privileges\x20to\x20access\x20this\x20resource.'});}};exports[_0x77f2('0x16f')]=function(_0x3a062c,_0x28a514,_0x59b506){if(!_[_0x77f2('0x7d')](_0x3a062c[_0x77f2('0x3a')]['id'])&&(_0x3a062c['user'][_0x77f2('0x42')]==_0x77f2('0x70')||_0x3a062c[_0x77f2('0x3a')]['role']==_0x77f2('0x3a'))){return db[_0x77f2('0x46')]['find']({'where':{'id':_0x3a062c['params']['id']}})['then'](handleEntityNotFound(_0x28a514,null))[_0x77f2('0x22')](function(_0x44c60d){if(_0x44c60d&&_0x44c60d[_0x77f2('0x170')]&&_0x44c60d[_0x77f2('0x171')])return _0x44c60d;else throw{'message':_0x77f2('0x172')};})[_0x77f2('0x22')](function(_0x2a3dcf){return db['User']['update']({'apiKeyNonce':null,'apiKeyIat':null},{'where':{'id':_0x3a062c[_0x77f2('0x64')]['id']}});})[_0x77f2('0x22')](respondWithStatusCode(_0x28a514,0xc8))['catch'](handleError(_0x28a514,0x193));}else{return _0x28a514[_0x77f2('0x2f')](0x191)[_0x77f2('0x31')]({'message':_0x77f2('0x16b')});}};exports[_0x77f2('0x173')]=function(_0x31c161,_0x3555cd){var _0x3c7c5c=_0x31c161[_0x77f2('0x3a')][_0x77f2('0x90')]({'plain':!![]});if(!_0x3c7c5c){return _0x3555cd[_0x77f2('0x2f')](0x191)[_0x77f2('0x11e')](_0x77f2('0x91'));}else{return _0x3555cd[_0x77f2('0x2f')](0xc8)['json'](_0x3c7c5c);}};
\ No newline at end of file
+var _0x4c60=['order','pick','UserVoiceQueueRt','getVoiceQueuesRt','getGroups','ChatGroup','VoiceRecording','UserId','getScreenRecordings','ScreenRecording','getChatInteractions','ChatInteraction','getOpenchannelInteractions','OpenchannelInteraction','getMailInteractions','MailInteraction','getSmsInteractions','SmsInteraction','getFaxInteractions','getWhatsappInteractions','login','mobile','format','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','device','PAUSE','LOGININPAUSE','YYYY-MM-DD\x20HH:mm:ss','logout','pause','QueuePause','updateAttributes','getChannels','forEach','type','DEFAULT\x20PAUSE','unpause','mailPause','chatPause','faxPause','openchannelPause','pauseType','lastPauseAt','manual','%s%s','Pause','getTeams','addTeams','getVoiceQueues','setDataValue','getChatQueues','getMailQueues','getSmsQueues','getWhatsappQueues','Whatsapp','getFaxQueues','Fax','getOpenchannelQueues','Openchannel','flatten','transaction','addAgent','getDataValue','Voice','TeamVoicePrefix','UserVoicePrefix','removeTeams','Chat','Mail','Sms','removeAgent','Queue:remove','getLists','getAgents','values','You\x20can\x27t\x20delete\x20yourself','addChatInteractions','spread','user_has_chat_interactions:save','removeChatInteractions','user_has_chat_interactions:remove','addMailInteractions','user_has_mail_interactions:save','removeMailInteractions','user_has_mail_interactions:remove','removeFaxInteractions','user_has_fax_interactions:remove','addSmsInteractions','user_has_sms_interactions:save','user_has_sms_interactions:remove','addOpenchannelInteractions','removeOpenchannelInteractions','user_has_openchannel_interactions:remove','addWhatsappInteractions','removeWhatsappInteractions','getVoicePrefixes','VoicePrefix','getFaxAccounts','addFaxAccounts','removeFaxAccounts','MailAccount','getMailAccounts','addMailAccounts','removeMailAccounts','getOpenchannelAccounts','OpenchannelAccount','addOpenchannelAccounts','removeOpenchannelAccounts','getSmsAccounts','removeSmsAccounts','getChatWebsites','addChatWebsites','removeChatWebsites','getWhatsappAccounts','WhatsappAccount','addWhatsappAccounts','removeWhatsappAccounts','getSquareProjects','SquareProject','addSquareProjects','removeSquareProjects','getScheduledCalls','CmHopper','$and','$or','$gt','$gte','$lt','$ne','$eq','$not','$between','$notBetween','$in','$like','$overlap','$contains','$any','firstName','phone','dialActive','getApiKey','retrieveApiKey','No\x20API\x20access\x20key\x20found!','You\x20don\x27t\x20have\x20sufficient\x20privileges\x20to\x20access\x20this\x20resource.','createApiKey','iat','nonce','token','apiKeyNonce','apiKeyIat','API\x20key\x20not\x20available','whoami','getPresence','resolve','queues','teams','inbound','isEmpty','lower','col','toString','desc','asc','substring','uniqBy','Unable\x20to\x20retrieve\x20RPC\x20agents\x20(AMI)','result','client','Unable\x20to\x20retrieve\x20RPC\x20agents\x20(Routing)','idle','unavailable','voiceStatus','QueryTypes','SELECT','select','InteractionId','field','ui.createdAt','user_has_','_interactions','ui.UserId\x20=\x20?','OpenTabs','moment','bluebird','util','path','squel','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','socket.io-emitter','./user.socket','register','redis','defaults','http','request','info','User,\x20%s,\x20%s','debug','User,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','catch','status','end','offset','undefined','limit','count','Content-Range','json','update','then','destroy','role','Users','Agents','agent','Telephones','telephone','filter','ignore','map','value','includes','find','name','UserProfileResource','send','rawAttributes','fieldName','password','getOptions','where','User','query','include','attributes','push','findAll','rows','length','dataValues','sms','mail','openchannel','whatsapp','all','show','params','differenceBy','keys','salt','intersection','model','fields','includeAll','options','openTabs','true','chat','body','describe','addContacts','ids','omit','internal','Setting','findById','securePassword','validatePasswordPattern','max','isNil','min_internal','sequelize','from','voicemail','mailbox','VoiceMail','fullname','email','permissions','101','103','113','110','104','105','107','109','111','114','115','create','user','Unauthorized','admin','Unauthorized.\x20You\x20must\x20be\x20an\x20administrator\x20in\x20order\x20to\x20create\x20another\x20administrator','checkUserLimits','settingsEnabled','userProfileId','UserProfileSection','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','bulkCreate','some','Unauthorized.\x20You\x20must\x20be\x20an\x20administrator\x20in\x20order\x20to\x20create\x20an\x20user','Unauthorized.\x20You\x20must\x20be\x20an\x20administrator\x20in\x20order\x20to\x20create\x20an\x20administrator','each','compact','changePassword','oldPassword','newPassword','ValidationError','Invalid\x20body\x20format.\x20Use\x20oldPassword\x20and\x20newPassword','Sequelize','Wrong\x20credentials','New\x20password\x20must\x20be\x20different\x20from\x20old\x20password','Invalid\x20body\x20format.\x20Use\x20newPassword','findOne','previousPasswords','validatePasswordHistory','addQueues','channel','online','loginInPause','interface','isValidChannel','Unknown\x20channel','add','capitalize','toLowerCase','Queues','penalty','QueueId','emit','Queue:save','voice','VoiceQueue','get','SIP/%s','voicePause','upsert','remove','isArray','addAvatar','userpic','getAvatar','root','server/files/images/logos/default_profile.png','download','existsSync','join','server/files/images/','getOpenTabs','fax','ChatOpenTabs','CHAT','FaxOpenTabs','createdAt','OpenchannelOpenTabs','OPENCHANNEL','MailOpenTabs','MAIL','SmsOpenTabs','SMS','WhatsappOpenTabs','WHATSAPP','getContacts','CmContact','filters','sort','merge','hasOwnProperty','CmList','List','Tag','Tags','nolimit','getQueues','Queue'];(function(_0x389e3a,_0x42dd3e){var _0x1f5a26=function(_0x146e68){while(--_0x146e68){_0x389e3a['push'](_0x389e3a['shift']());}};_0x1f5a26(++_0x42dd3e);}(_0x4c60,0xc1));var _0x04c6=function(_0x19673a,_0x29e78e){_0x19673a=_0x19673a-0x0;var _0x44a3a6=_0x4c60[_0x19673a];return _0x44a3a6;};'use strict';var moment=require(_0x04c6('0x0'));var BPromise=require(_0x04c6('0x1'));var util=require(_0x04c6('0x2'));var path=require(_0x04c6('0x3'));var fs=require('fs');var _=require('lodash');var squel=require(_0x04c6('0x4'));var jayson=require('jayson/promise');var Redis=require('ioredis');var authService=require('../../components/auth/service');var qs=require('../../components/parsers/qs');var logger=require(_0x04c6('0x5'))(_0x04c6('0x6'));var utils=require(_0x04c6('0x7'));var config=require(_0x04c6('0x8'));var licenseUtil=require(_0x04c6('0x9'));var db=require(_0x04c6('0xa'))['db'];var socket=require(_0x04c6('0xb'))(new Redis(config['redis']));require(_0x04c6('0xc'))[_0x04c6('0xd')](socket);config[_0x04c6('0xe')]=_[_0x04c6('0xf')](config['redis'],{'host':'localhost','port':0x18eb});var client=jayson['client'][_0x04c6('0x10')]({'port':0x232a});var values;function respondWithRpcPromise(_0x5584cd,_0x15d31a,_0x2772fa,_0x5236c8){return new BPromise(function(_0x4316f8,_0x19eb01){var _0x119187=_0x5236c8||client;return _0x119187[_0x04c6('0x11')](_0x5584cd,_0x2772fa)['then'](function(_0x257a0a){logger[_0x04c6('0x12')](_0x04c6('0x13'),_0x15d31a,'request\x20sent');logger[_0x04c6('0x14')](_0x04c6('0x15'),_0x15d31a,_0x04c6('0x16'),JSON[_0x04c6('0x17')](_0x257a0a));if(_0x257a0a[_0x04c6('0x18')]){if(_0x257a0a[_0x04c6('0x18')][_0x04c6('0x19')]===0x1f4){logger[_0x04c6('0x18')]('User,\x20%s,\x20%s',_0x15d31a,_0x257a0a[_0x04c6('0x18')][_0x04c6('0x1a')]);return _0x19eb01(_0x257a0a[_0x04c6('0x18')][_0x04c6('0x1a')]);}logger[_0x04c6('0x18')](_0x04c6('0x13'),_0x15d31a,_0x257a0a[_0x04c6('0x18')][_0x04c6('0x1a')]);return _0x4316f8(_0x257a0a['error'][_0x04c6('0x1a')]);}else{logger[_0x04c6('0x12')](_0x04c6('0x13'),_0x15d31a,'request\x20sent');_0x4316f8(_0x257a0a['result']['message']);}})[_0x04c6('0x1b')](function(_0xb997e0){logger['error']('User,\x20%s,\x20%s',_0x15d31a,_0xb997e0);_0x19eb01(_0xb997e0);});});}function respondWithStatusCode(_0x1e6854,_0x2eed94){_0x2eed94=_0x2eed94||0xcc;return function(_0x3cd448){if(_0x3cd448){return _0x1e6854['sendStatus'](_0x2eed94);}return _0x1e6854[_0x04c6('0x1c')](_0x2eed94)[_0x04c6('0x1d')]();};}function respondWithResult(_0x9d41f8,_0x49c179){_0x49c179=_0x49c179||0xc8;return function(_0x2d3277){if(_0x2d3277){return _0x9d41f8[_0x04c6('0x1c')](_0x49c179)['json'](_0x2d3277);}};}function respondWithFilteredResult(_0x54a8b0,_0x4c8d72){return function(_0x348ea3){if(_0x348ea3){var _0x3a2014=typeof _0x4c8d72[_0x04c6('0x1e')]===_0x04c6('0x1f')&&typeof _0x4c8d72[_0x04c6('0x20')]==='undefined';var _0x562952=_0x348ea3[_0x04c6('0x21')];var _0x2ab1d2=_0x3a2014?0x0:_0x4c8d72[_0x04c6('0x1e')];var _0x3233d7=_0x3a2014?_0x348ea3[_0x04c6('0x21')]:_0x4c8d72[_0x04c6('0x1e')]+_0x4c8d72['limit'];var _0x1d0d3f;if(_0x3233d7>=_0x562952){_0x3233d7=_0x562952;_0x1d0d3f=0xc8;}else{_0x1d0d3f=0xce;}_0x54a8b0[_0x04c6('0x1c')](_0x1d0d3f);return _0x54a8b0['set'](_0x04c6('0x22'),_0x2ab1d2+'-'+_0x3233d7+'/'+_0x562952)[_0x04c6('0x23')](_0x348ea3);}return null;};}function saveUpdates(_0x5f1331){return function(_0x5c9003){if(_0x5c9003){return _0x5c9003[_0x04c6('0x24')](_0x5f1331)[_0x04c6('0x25')](function(_0x2a191f){return _0x2a191f;});}return null;};}function removeEntity(_0xbb9e81){return function(_0x23c500){if(_0x23c500){return _0x23c500[_0x04c6('0x26')]()['then'](function(){var _0x5d8c88=_0x23c500['get']({'plain':!![]});if(_0x5d8c88[_0x04c6('0x27')]==='admin')return;var _0x1e76e2=[{'name':_0x04c6('0x28'),'value':'user','ignore':!![]},{'name':_0x04c6('0x29'),'value':_0x04c6('0x2a'),'ignore':![]},{'name':_0x04c6('0x2b'),'value':_0x04c6('0x2c'),'ignore':![]}];var _0x5b2056=_(_0x1e76e2)[_0x04c6('0x2d')](_0x04c6('0x2e'))[_0x04c6('0x2f')](_0x04c6('0x30'))[_0x04c6('0x30')]();if(_[_0x04c6('0x31')](_0x5b2056,_0x5d8c88[_0x04c6('0x27')])){return;}var _0x46380e=_[_0x04c6('0x32')](_0x1e76e2,[_0x04c6('0x30'),_0x5d8c88[_0x04c6('0x27')]])[_0x04c6('0x33')];return db[_0x04c6('0x34')][_0x04c6('0x26')]({'where':{'type':_0x46380e,'resourceId':_0x5d8c88['id']}})[_0x04c6('0x25')](function(){return _0x23c500;});})['then'](function(){_0xbb9e81[_0x04c6('0x1c')](0xcc)[_0x04c6('0x1d')]();});}};}function handleEntityNotFound(_0x332811){return function(_0x206e32){if(!_0x206e32){_0x332811['sendStatus'](0x194);}return _0x206e32;};}function handleError(_0x181736,_0x31de0f){_0x31de0f=_0x31de0f||0x1f4;return function(_0x4e1cfa){logger['error'](_0x4e1cfa['stack']);if(_0x4e1cfa[_0x04c6('0x33')]){delete _0x4e1cfa[_0x04c6('0x33')];}_0x181736['status'](_0x31de0f)[_0x04c6('0x35')](_0x4e1cfa);};}exports['index']=function(_0x15c270,_0x1373ca){var _0x3806ea={},_0x2b28cd={'count':0x0,'rows':[]};var _0x5144f5=_(db['User'][_0x04c6('0x36')])[_0x04c6('0x2f')](function(_0x50041f){return{'name':_0x50041f[_0x04c6('0x37')],'type':_0x50041f['type']['key']};})[_0x04c6('0x2d')](function(_0x5aede6){return!_[_0x04c6('0x31')]([_0x04c6('0x38'),'salt'],_0x5aede6[_0x04c6('0x33')]);})['value']();_0x3806ea=qs[_0x04c6('0x39')](_0x5144f5,_0x15c270);var _0x39513d={'where':_0x3806ea[_0x04c6('0x3a')]};return db[_0x04c6('0x3b')][_0x04c6('0x21')](_0x39513d)['then'](function(_0x297b25){_0x2b28cd['count']=_0x297b25;if(_0x15c270[_0x04c6('0x3c')]['includeAll']){_0x3806ea[_0x04c6('0x3d')]=[{'all':!![]}];}if(!_[_0x04c6('0x31')](_0x3806ea[_0x04c6('0x3e')],'id')){_0x3806ea[_0x04c6('0x3e')][_0x04c6('0x3f')]('id');}return db[_0x04c6('0x3b')][_0x04c6('0x40')](_0x3806ea);})['then'](function(_0xdfdc34){_0x2b28cd['rows']=_0xdfdc34;if(_0x15c270[_0x04c6('0x3c')]['openTabs']==='true'){var _0x463222=[];for(var _0x58a9ad=0x0;_0x58a9ad<_0x2b28cd[_0x04c6('0x41')][_0x04c6('0x42')];_0x58a9ad++){_0x463222[_0x04c6('0x3f')](get_open_tabs('chat',_0x2b28cd[_0x04c6('0x41')][_0x58a9ad][_0x04c6('0x43')]));_0x463222[_0x04c6('0x3f')](get_open_tabs(_0x04c6('0x44'),_0x2b28cd[_0x04c6('0x41')][_0x58a9ad][_0x04c6('0x43')]));_0x463222[_0x04c6('0x3f')](get_open_tabs('fax',_0x2b28cd['rows'][_0x58a9ad][_0x04c6('0x43')]));_0x463222[_0x04c6('0x3f')](get_open_tabs(_0x04c6('0x45'),_0x2b28cd['rows'][_0x58a9ad][_0x04c6('0x43')]));_0x463222[_0x04c6('0x3f')](get_open_tabs(_0x04c6('0x46'),_0x2b28cd['rows'][_0x58a9ad]['dataValues']));_0x463222['push'](get_open_tabs(_0x04c6('0x47'),_0x2b28cd[_0x04c6('0x41')][_0x58a9ad]['dataValues']));}return BPromise[_0x04c6('0x48')](_0x463222)[_0x04c6('0x25')](function(_0x2bd045){return _0x2b28cd;});}else{return _0x2b28cd;}})['then'](respondWithFilteredResult(_0x1373ca,_0x3806ea))[_0x04c6('0x1b')](handleError(_0x1373ca,null));};exports[_0x04c6('0x49')]=function(_0x5e68e0,_0x25a6fc){var _0x203943={'raw':![],'where':{'id':_0x5e68e0[_0x04c6('0x4a')]['id']}},_0x2472ed={};_0x2472ed['model']=_[_0x04c6('0x4b')](_[_0x04c6('0x4c')](db[_0x04c6('0x3b')][_0x04c6('0x36')]),['password',_0x04c6('0x4d')]);_0x2472ed[_0x04c6('0x3c')]=_[_0x04c6('0x4c')](_0x5e68e0[_0x04c6('0x3c')]);_0x2472ed['filters']=_[_0x04c6('0x4e')](_0x2472ed[_0x04c6('0x4f')],_0x2472ed[_0x04c6('0x3c')]);_0x203943['attributes']=_[_0x04c6('0x4e')](_0x2472ed[_0x04c6('0x4f')],qs[_0x04c6('0x50')](_0x5e68e0[_0x04c6('0x3c')][_0x04c6('0x50')]));_0x203943[_0x04c6('0x3e')]=_0x203943[_0x04c6('0x3e')][_0x04c6('0x42')]?_0x203943[_0x04c6('0x3e')]:_0x2472ed[_0x04c6('0x4f')];if(_0x5e68e0[_0x04c6('0x3c')][_0x04c6('0x51')]){_0x203943[_0x04c6('0x3d')]=[{'all':!![]}];}_0x203943=_['merge']({},_0x203943,_0x5e68e0[_0x04c6('0x52')]);if(!_[_0x04c6('0x31')](_0x203943[_0x04c6('0x3e')],'id')){_0x203943[_0x04c6('0x3e')][_0x04c6('0x3f')]('id');}return db['User'][_0x04c6('0x32')](_0x203943)[_0x04c6('0x25')](handleEntityNotFound(_0x25a6fc,null))[_0x04c6('0x25')](function(_0x32d5e8){var _0x28dfd0=[];values=_0x32d5e8;if(_0x5e68e0[_0x04c6('0x3c')][_0x04c6('0x53')]===_0x04c6('0x54')){_0x28dfd0[_0x04c6('0x3f')](get_open_tabs(_0x04c6('0x55'),_0x32d5e8['dataValues']));_0x28dfd0['push'](get_open_tabs('sms',_0x32d5e8['dataValues']));_0x28dfd0[_0x04c6('0x3f')](get_open_tabs('openchannel',_0x32d5e8[_0x04c6('0x43')]));_0x28dfd0['push'](get_open_tabs(_0x04c6('0x47'),_0x32d5e8[_0x04c6('0x43')]));_0x28dfd0['push'](get_open_tabs('fax',_0x32d5e8[_0x04c6('0x43')]));_0x28dfd0[_0x04c6('0x3f')](get_open_tabs(_0x04c6('0x45'),_0x32d5e8[_0x04c6('0x43')]));return BPromise['all'](_0x28dfd0);}else{return values;}})[_0x04c6('0x25')](function(_0xf4e9d6){return values;})[_0x04c6('0x25')](respondWithResult(_0x25a6fc,null))[_0x04c6('0x1b')](handleError(_0x25a6fc,null));};exports[_0x04c6('0x24')]=function(_0x29c72f,_0x145854){if(_0x29c72f['body']['id']){delete _0x29c72f[_0x04c6('0x56')]['id'];}delete _0x29c72f['body'][_0x04c6('0x27')];return db[_0x04c6('0x3b')]['find']({'where':{'id':_0x29c72f[_0x04c6('0x4a')]['id']}})[_0x04c6('0x25')](handleEntityNotFound(_0x145854,null))[_0x04c6('0x25')](saveUpdates(_0x29c72f[_0x04c6('0x56')],null))[_0x04c6('0x25')](respondWithResult(_0x145854,null))[_0x04c6('0x1b')](handleError(_0x145854,null));};exports[_0x04c6('0x57')]=function(_0x3333a4,_0x5c51dc){return db[_0x04c6('0x3b')]['describe']()[_0x04c6('0x25')](respondWithResult(_0x5c51dc,null))[_0x04c6('0x1b')](handleError(_0x5c51dc,null));};exports['addContacts']=function(_0x503426,_0x2e649d){return db['User'][_0x04c6('0x32')]({'where':{'id':_0x503426[_0x04c6('0x4a')]['id']}})['then'](handleEntityNotFound(_0x2e649d,null))[_0x04c6('0x25')](function(_0x4520f0){if(_0x4520f0){return _0x4520f0[_0x04c6('0x58')](_0x503426[_0x04c6('0x56')][_0x04c6('0x59')],_[_0x04c6('0x5a')](_0x503426[_0x04c6('0x56')],[_0x04c6('0x59'),'id'])||{});}})[_0x04c6('0x25')](respondWithResult(_0x2e649d,null))[_0x04c6('0x1b')](handleError(_0x2e649d,null));};function validateUser(_0x2c9c36){return new BPromise(function(_0x52413f,_0x3aaa1e){if(_0x2c9c36[_0x04c6('0x5b')])return _0x52413f(_0x2c9c36);return db[_0x04c6('0x5c')][_0x04c6('0x5d')](0x1)['then'](function(_0x1598f0){if(_0x1598f0[_0x04c6('0x5e')])authService[_0x04c6('0x5f')](_0x2c9c36['password']);db['User'][_0x04c6('0x60')](_0x04c6('0x5b'))[_0x04c6('0x25')](function(_0x396f79){if(_[_0x04c6('0x61')](_0x396f79)){_0x2c9c36[_0x04c6('0x5b')]=_0x1598f0['min_internal']||0x1;return;}if(_[_0x04c6('0x61')](_0x1598f0[_0x04c6('0x62')])||_0x1598f0[_0x04c6('0x62')]===_0x396f79){_0x2c9c36['internal']=_0x396f79+0x1;return;}if(_0x1598f0['min_internal']>_0x396f79){_0x2c9c36[_0x04c6('0x5b')]=_0x1598f0[_0x04c6('0x62')];return;}return db[_0x04c6('0x63')][_0x04c6('0x3c')]('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[_0x04c6('0x63')]['QueryTypes']['SELECT']})[_0x04c6('0x25')](function(_0xe178dd){if(_0xe178dd&&_0xe178dd[_0x04c6('0x42')]){for(var _0x1904d4=0x0,_0x43260e=_0xe178dd[_0x04c6('0x42')];_0x1904d4<_0x43260e&&_[_0x04c6('0x61')](_0x2c9c36['internal']);_0x1904d4++){if(_0x1598f0[_0x04c6('0x62')]<=_0xe178dd[_0x1904d4][_0x04c6('0x64')]){_0x2c9c36[_0x04c6('0x5b')]=_0xe178dd[_0x1904d4][_0x04c6('0x64')];}else if(_0x1598f0[_0x04c6('0x62')]>_0xe178dd[_0x1904d4]['from']&&_0x1598f0['min_internal']<=_0xe178dd[_0x1904d4]['to']){_0x2c9c36[_0x04c6('0x5b')]=_0x1598f0[_0x04c6('0x62')];}}}if(_[_0x04c6('0x61')](_0x2c9c36['internal'])){_0x2c9c36[_0x04c6('0x5b')]=_0x396f79+0x1;}return _0x52413f(_0x2c9c36);});});})[_0x04c6('0x1b')](function(_0x4c9507){_0x3aaa1e(_0x4c9507);});});}function updateUser(_0x12d92e){return new BPromise(function(_0x866829,_0x152a00){try{if(_0x12d92e[_0x04c6('0x65')]){_0x12d92e[_0x04c6('0x66')]=_0x12d92e[_0x04c6('0x5b')];_0x12d92e[_0x04c6('0x67')]={'mailbox':_0x12d92e[_0x04c6('0x5b')],'password':_0x12d92e[_0x04c6('0x38')],'fullname':_0x12d92e[_0x04c6('0x68')],'email':_0x12d92e[_0x04c6('0x69')]};}if(_0x12d92e[_0x04c6('0x27')]===_0x04c6('0x2a')){if(!_0x12d92e['permissions'])_0x12d92e[_0x04c6('0x6a')]=[_0x04c6('0x6b'),'102',_0x04c6('0x6c'),_0x04c6('0x6d'),_0x04c6('0x6e'),_0x04c6('0x6f'),_0x04c6('0x70'),'106',_0x04c6('0x71'),'108',_0x04c6('0x72'),'100',_0x04c6('0x73'),_0x04c6('0x74'),_0x04c6('0x75')];}_0x866829(_0x12d92e);}catch(_0x23ce75){_0x152a00(_0x23ce75);}});}exports[_0x04c6('0x76')]=function(_0x150639,_0x34f7a6){if(_0x150639[_0x04c6('0x77')][_0x04c6('0x27')]==='agent')throw new Error(_0x04c6('0x78'));if(_0x150639[_0x04c6('0x56')]['role']===_0x04c6('0x77')&&_0x150639['user'][_0x04c6('0x27')]!==_0x04c6('0x79')){throw new Error('Unauthorized.\x20You\x20must\x20be\x20an\x20administrator\x20in\x20order\x20to\x20create\x20an\x20user');}if(_0x150639[_0x04c6('0x56')][_0x04c6('0x27')]==='admin'&&_0x150639[_0x04c6('0x77')][_0x04c6('0x27')]!=='admin'){throw new Error(_0x04c6('0x7a'));}return licenseUtil[_0x04c6('0x7b')]([_0x150639['body']])[_0x04c6('0x25')](function(){return validateUser(_0x150639[_0x04c6('0x56')]);})['then'](function(_0x5314ee){return updateUser(_0x5314ee)['then'](function(_0x37d3e0){if(_0x37d3e0[_0x04c6('0x27')]===_0x04c6('0x79')){_0x37d3e0[_0x04c6('0x7c')]=_0x150639[_0x04c6('0x77')]['settingsEnabled'];delete _0x37d3e0[_0x04c6('0x7d')];}return _0x37d3e0;});})[_0x04c6('0x25')](function(_0x1a5356){return db[_0x04c6('0x3b')][_0x04c6('0x76')](_0x1a5356,{'include':[{'model':db[_0x04c6('0x67')],'as':_0x04c6('0x67')}]});})['then'](function(_0x22e182){if(_0x150639['body'][_0x04c6('0x27')]==='user')return _0x22e182;if(_0x150639['user'][_0x04c6('0x27')]!=='user')return _0x22e182;return db[_0x04c6('0x7e')][_0x04c6('0x32')]({'where':{'name':_0x22e182[_0x04c6('0x27')]===_0x04c6('0x2a')?_0x04c6('0x29'):'Telephones','userProfileId':_0x150639['user'][_0x04c6('0x7d')]},'raw':!![]})[_0x04c6('0x25')](function(_0x38d8b2){if(!_0x38d8b2||_0x38d8b2[_0x04c6('0x7f')]!=0x0)return _0x22e182;return db[_0x04c6('0x34')][_0x04c6('0x76')]({'name':_0x22e182['name'],'resourceId':_0x22e182['id'],'type':_0x38d8b2[_0x04c6('0x33')],'sectionId':_0x38d8b2['id']},{})['then'](function(){return _0x22e182;});})['catch'](function(_0x866f47){logger[_0x04c6('0x18')](_0x04c6('0x80'),_0x866f47);throw _0x866f47;});})[_0x04c6('0x25')](respondWithResult(_0x34f7a6,0xc9))[_0x04c6('0x1b')](handleError(_0x34f7a6,null));};exports[_0x04c6('0x81')]=function(_0x2e65f0,_0x243553){var _0x338e58=_0x2e65f0[_0x04c6('0x56')];var _0x21dc7c=[];if(_0x2e65f0['user'][_0x04c6('0x27')]==='agent')throw new Error('Unauthorized');if(_[_0x04c6('0x82')](_0x338e58,[_0x04c6('0x27'),_0x04c6('0x77')])&&_0x2e65f0[_0x04c6('0x77')][_0x04c6('0x27')]!==_0x04c6('0x79')){throw new Error(_0x04c6('0x83'));}if(_[_0x04c6('0x82')](_0x338e58,[_0x04c6('0x27'),_0x04c6('0x79')])&&_0x2e65f0[_0x04c6('0x77')]['role']!=='admin'){throw new Error(_0x04c6('0x84'));}return licenseUtil[_0x04c6('0x7b')](_0x338e58)['then'](function(){return validateUser(_0x338e58[0x0]);})[_0x04c6('0x25')](function(){for(var _0x3addb1=0x1;_0x3addb1<_0x338e58['length'];_0x3addb1++){var _0x4504fc=_0x338e58[_0x3addb1-0x1][_0x04c6('0x5b')];if(!_0x338e58[_0x3addb1][_0x04c6('0x5b')])_0x338e58[_0x3addb1][_0x04c6('0x5b')]=_0x4504fc+0x1;_0x21dc7c[_0x04c6('0x3f')](validateUser(_0x338e58[_0x3addb1]));}return BPromise[_0x04c6('0x48')](_0x21dc7c);})[_0x04c6('0x25')](function(){_0x21dc7c=[];for(var _0x5efcc8=0x0;_0x5efcc8<_0x338e58['length'];_0x5efcc8++){_0x21dc7c[_0x04c6('0x3f')](updateUser(_0x338e58[_0x5efcc8]));}return BPromise['all'](_0x21dc7c);})[_0x04c6('0x25')](function(){return BPromise[_0x04c6('0x85')](_0x338e58,function(_0x23b79a){return db[_0x04c6('0x3b')][_0x04c6('0x76')](_0x23b79a,{'include':[{'model':db[_0x04c6('0x67')],'as':'VoiceMail'}]})[_0x04c6('0x25')](function(_0x1b7cec){_0x23b79a['id']=_0x1b7cec['id'];return _0x23b79a;});});})[_0x04c6('0x25')](function(_0x54fe47){if(_0x2e65f0['body']['role']===_0x04c6('0x77'))return _0x54fe47;if(_0x2e65f0[_0x04c6('0x77')]['role']!==_0x04c6('0x77'))return _0x54fe47;var _0x29461e=_[_0x04c6('0x82')](_0x54fe47,function(_0x5c47a4){return _0x5c47a4[_0x04c6('0x27')]==='agent'||_0x5c47a4[_0x04c6('0x27')]===_0x04c6('0x2c');});if(!_0x29461e)return _0x54fe47;return db[_0x04c6('0x7e')]['findAll']({'where':{'name':{'$or':['Agents',_0x04c6('0x2b')]},'userProfileId':_0x2e65f0[_0x04c6('0x77')][_0x04c6('0x7d')]},'raw':!![]})[_0x04c6('0x25')](function(_0x546f5d){if(_['isEmpty'](_0x546f5d)||!_[_0x04c6('0x82')](_0x546f5d,[_0x04c6('0x7f'),0x0]))return _0x54fe47;_0x21dc7c=[];var _0x91f883=_(_0x546f5d)['map'](function(_0x2c1536){if(_0x2c1536[_0x04c6('0x7f')]===0x1)return;return _0x2c1536[_0x04c6('0x33')]===_0x04c6('0x29')?_0x04c6('0x2a'):_0x04c6('0x2c');})[_0x04c6('0x86')]()[_0x04c6('0x30')]();for(var _0x2192ff=0x0;_0x2192ff<_0x54fe47[_0x04c6('0x42')];_0x2192ff++){if(!_['includes'](_0x91f883,_0x54fe47[_0x2192ff][_0x04c6('0x27')]))return;var _0x388811=_0x54fe47[_0x2192ff][_0x04c6('0x27')]===_0x04c6('0x2a')?_0x04c6('0x29'):_0x04c6('0x2b');_0x21dc7c[_0x04c6('0x3f')](db['UserProfileResource'][_0x04c6('0x76')]({'name':_0x54fe47[_0x2192ff][_0x04c6('0x33')],'resourceId':_0x54fe47[_0x2192ff]['id'],'type':_0x388811,'sectionId':_[_0x04c6('0x32')](_0x546f5d,[_0x04c6('0x33'),_0x388811])['id']},{}));}return BPromise[_0x04c6('0x48')](_0x21dc7c);});})[_0x04c6('0x25')](respondWithResult(_0x243553,0xc9))[_0x04c6('0x1b')](handleError(_0x243553,null));};exports[_0x04c6('0x87')]=function(_0x4bfb6c,_0x203630){if(_0x4bfb6c[_0x04c6('0x56')]['id']){delete _0x4bfb6c['body']['id'];}return db[_0x04c6('0x3b')][_0x04c6('0x32')]({'where':{'id':_0x4bfb6c[_0x04c6('0x4a')]['id']}})[_0x04c6('0x25')](function(_0x29b5f2){if(!_0x29b5f2)return null;if(_0x29b5f2['id']===_0x4bfb6c['user']['id']){if(!_0x4bfb6c['body'][_0x04c6('0x88')]||!_0x4bfb6c[_0x04c6('0x56')][_0x04c6('0x89')]){throw new db['Sequelize'][(_0x04c6('0x8a'))](_0x04c6('0x8b'));}if(!_0x29b5f2['authenticate'](_0x4bfb6c['body'][_0x04c6('0x88')])){throw new db[(_0x04c6('0x8c'))]['ValidationError'](_0x04c6('0x8d'));}if(_0x4bfb6c[_0x04c6('0x56')][_0x04c6('0x88')]===_0x4bfb6c[_0x04c6('0x56')]['newPassword']){throw new db[(_0x04c6('0x8c'))][(_0x04c6('0x8a'))](_0x04c6('0x8e'));}}else if(_0x4bfb6c[_0x04c6('0x77')][_0x04c6('0x27')]===_0x04c6('0x79')){if(!_0x4bfb6c['body'][_0x04c6('0x89')]){throw new db[(_0x04c6('0x8c'))][(_0x04c6('0x8a'))](_0x04c6('0x8f'));}}else if(_0x4bfb6c[_0x04c6('0x77')][_0x04c6('0x27')]===_0x04c6('0x77')){if(!_0x4bfb6c[_0x04c6('0x56')]['newPassword']){throw new db['Sequelize'][(_0x04c6('0x8a'))](_0x04c6('0x8f'));}if(_0x29b5f2[_0x04c6('0x27')]!=='agent'){throw new db[(_0x04c6('0x8c'))][(_0x04c6('0x8a'))](_0x04c6('0x78'));}}else{throw new db['Sequelize']['ValidationError'](_0x04c6('0x78'));}return _0x29b5f2;})[_0x04c6('0x25')](handleEntityNotFound(_0x203630,null))[_0x04c6('0x25')](function(_0x414e80){return db[_0x04c6('0x5c')][_0x04c6('0x90')]({'attributes':['id','securePassword','enforcePasswordHistory','passwordHistoryLimit']})[_0x04c6('0x25')](function(_0x531c75){if(_0x531c75['securePassword'])authService[_0x04c6('0x5f')](_0x4bfb6c[_0x04c6('0x56')][_0x04c6('0x89')]);if(!_0x531c75['enforcePasswordHistory']||!_0x414e80[_0x04c6('0x91')])return _0x414e80;authService[_0x04c6('0x92')](_0x4bfb6c[_0x04c6('0x56')][_0x04c6('0x89')],_0x414e80['previousPasswords'],_0x531c75['passwordHistoryLimit']);return _0x414e80;})['then'](saveUpdates({'password':_0x4bfb6c[_0x04c6('0x56')][_0x04c6('0x89')],'passwordResetAt':_0x4bfb6c['user']['id']==_0x4bfb6c['params']['id']?moment():null,'previousPasswords':authService['updatePasswordsHistory'](_0x4bfb6c[_0x04c6('0x56')]['newPassword'],_0x414e80[_0x04c6('0x91')])},null));})[_0x04c6('0x25')](respondWithResult(_0x203630,null))[_0x04c6('0x1b')](handleError(_0x203630,null));};exports[_0x04c6('0x93')]=function(_0x3906b2,_0x410bc2){var _0x59a97f=_0x3906b2[_0x04c6('0x56')][_0x04c6('0x94')];return db[_0x04c6('0x3b')][_0x04c6('0x32')]({'where':{'id':_0x3906b2[_0x04c6('0x4a')]['id']},'attributes':['id','name',_0x04c6('0x27'),_0x04c6('0x95'),_0x04c6('0x96'),'voicePause',_0x04c6('0x97')]})[_0x04c6('0x25')](handleEntityNotFound(_0x410bc2,null))[_0x04c6('0x25')](function(_0x5ee1d3){if(_0x5ee1d3){if(!utils[_0x04c6('0x98')](_0x59a97f)){throw new db[(_0x04c6('0x8c'))][(_0x04c6('0x8a'))](_0x04c6('0x99'));}return _0x5ee1d3[_0x04c6('0x9a')+_[_0x04c6('0x9b')](_0x59a97f[_0x04c6('0x9c')]())+_0x04c6('0x9d')](_0x3906b2['body'][_0x04c6('0x59')],{'penalty':_0x3906b2[_0x04c6('0x56')][_0x04c6('0x9e')]||0x0})['spread'](function(_0x55f0b9){for(var _0x4dfaa4=0x0;_0x4dfaa4<_0x3906b2[_0x04c6('0x56')][_0x04c6('0x59')][_0x04c6('0x42')];_0x4dfaa4+=0x1){var _0x579168={'UserId':Number(_0x3906b2[_0x04c6('0x4a')]['id'])};_0x579168[_[_0x04c6('0x9b')](_0x59a97f[_0x04c6('0x9c')]())+_0x04c6('0x9f')]=Number(_0x3906b2['body'][_0x04c6('0x59')][_0x4dfaa4]);socket[_0x04c6('0xa0')](_0x04c6('0x77')+_[_0x04c6('0x9b')](_0x59a97f['toLowerCase']())+_0x04c6('0xa1'),_0x579168);}return _0x55f0b9;})['then'](function(){if(_0x59a97f===_0x04c6('0xa2')){return db[_0x04c6('0xa3')]['findAll']({'where':{'id':_0x3906b2[_0x04c6('0x56')][_0x04c6('0x59')]||[]},'raw':!![],'attributes':['id',_0x04c6('0x33')]});}})['then'](function(_0x39985f){var _0x2e71fa=_0x5ee1d3[_0x04c6('0xa4')]({'plain':!![]});var _0x4fb402=[];if(_0x59a97f===_0x04c6('0xa2')&&_0x2e71fa[_0x04c6('0x27')]==='agent'&&_0x2e71fa['online']){for(var _0x487c2a=0x0;_0x487c2a<_0x39985f['length'];_0x487c2a+=0x1){_0x4fb402[_0x04c6('0x3f')]({'membername':_0x2e71fa[_0x04c6('0x33')],'UserId':_0x2e71fa['id'],'queue_name':_0x39985f[_0x487c2a]['name'],'VoiceQueueId':_0x39985f[_0x487c2a]['id'],'interface':_[_0x04c6('0x61')](_0x2e71fa[_0x04c6('0x97')])?util['format'](_0x04c6('0xa5'),_0x2e71fa[_0x04c6('0x33')]):_0x2e71fa['interface'],'paused':_0x2e71fa[_0x04c6('0xa6')]||![],'penalty':_0x3906b2[_0x04c6('0x56')][_0x04c6('0x9e')]||0x0});}return BPromise['each'](_0x4fb402,function(_0x4c616d){return db['UserVoiceQueueRt'][_0x04c6('0xa7')](_0x4c616d);});}return _0x5ee1d3;});}})[_0x04c6('0x25')](respondWithStatusCode(_0x410bc2,null))[_0x04c6('0x1b')](handleError(_0x410bc2,null));};exports['removeQueues']=function(_0x4ed0a4,_0x55c939){var _0x29e5b4;return db['User']['find']({'where':{'id':_0x4ed0a4[_0x04c6('0x4a')]['id']},'attributes':['id','name',_0x04c6('0x27')]})[_0x04c6('0x25')](handleEntityNotFound(_0x55c939,null))[_0x04c6('0x25')](function(_0x287fa8){if(_0x287fa8){_0x29e5b4=_0x287fa8;if(!_0x4ed0a4[_0x04c6('0x3c')]['channel']||!utils['isValidChannel'](_0x4ed0a4[_0x04c6('0x3c')][_0x04c6('0x94')])){throw new db[(_0x04c6('0x8c'))][(_0x04c6('0x8a'))](_0x04c6('0x99'));}return _0x287fa8[_0x04c6('0xa8')+_['capitalize'](_0x4ed0a4['query'][_0x04c6('0x94')][_0x04c6('0x9c')]())+'Queues'](_0x4ed0a4[_0x04c6('0x3c')]['ids']);}})['then'](function(_0x3a9b88){if(_[_0x04c6('0xa9')](_0x4ed0a4['query'][_0x04c6('0x59')])){for(var _0x314e68=0x0;_0x314e68<_0x4ed0a4[_0x04c6('0x3c')]['ids'][_0x04c6('0x42')];_0x314e68+=0x1){var _0x7b32e6={'UserId':Number(_0x4ed0a4[_0x04c6('0x4a')]['id'])};_0x7b32e6[_[_0x04c6('0x9b')](_0x4ed0a4[_0x04c6('0x3c')][_0x04c6('0x94')][_0x04c6('0x9c')]())+_0x04c6('0x9f')]=Number(_0x4ed0a4['query'][_0x04c6('0x59')][_0x314e68]);socket['emit'](_0x04c6('0x77')+_[_0x04c6('0x9b')](_0x4ed0a4[_0x04c6('0x3c')][_0x04c6('0x94')][_0x04c6('0x9c')]())+'Queue:remove',_0x7b32e6);}}else{var _0x7b32e6={'UserId':Number(_0x4ed0a4[_0x04c6('0x4a')]['id'])};_0x7b32e6[_['capitalize'](_0x4ed0a4[_0x04c6('0x3c')][_0x04c6('0x94')][_0x04c6('0x9c')]())+'QueueId']=Number(_0x4ed0a4[_0x04c6('0x3c')]['ids']);socket['emit'](_0x04c6('0x77')+_['capitalize'](_0x4ed0a4[_0x04c6('0x3c')][_0x04c6('0x94')][_0x04c6('0x9c')]())+'Queue:remove',_0x7b32e6);}return _0x3a9b88;})[_0x04c6('0x25')](function(){if(_0x4ed0a4['query'][_0x04c6('0x94')]==='voice'){return db['UserVoiceQueueRt'][_0x04c6('0x26')]({'where':{'UserId':_0x4ed0a4['params']['id'],'VoiceQueueId':_0x4ed0a4[_0x04c6('0x3c')][_0x04c6('0x59')]},'individualHooks':!![]})[_0x04c6('0x25')](function(){return _0x29e5b4;});}return _0x29e5b4;})[_0x04c6('0x25')](respondWithStatusCode(_0x55c939,null))[_0x04c6('0x1b')](handleError(_0x55c939,null));};exports[_0x04c6('0xaa')]=function(_0x257524,_0x81e27b){_0x257524[_0x04c6('0x56')][_0x04c6('0xab')]=_0x257524['file']['filename'];return db[_0x04c6('0x3b')][_0x04c6('0x32')]({'where':{'id':_0x257524[_0x04c6('0x4a')]['id']}})['then'](handleEntityNotFound(_0x81e27b,null))[_0x04c6('0x25')](saveUpdates(_0x257524['body'],null))['then'](respondWithResult(_0x81e27b,null))[_0x04c6('0x1b')](handleError(_0x81e27b,null));};exports[_0x04c6('0xac')]=function(_0x3a3d48,_0xeca2d9){var _0x4bf86a=path['join'](config[_0x04c6('0xad')],_0x04c6('0xae'));return db['User'][_0x04c6('0x32')]({'where':{'id':_0x3a3d48[_0x04c6('0x4a')]['id']},'attributes':['id',_0x04c6('0xab')],'raw':!![]})['then'](handleEntityNotFound(_0xeca2d9,null))['then'](function(_0x37fbde){if(_0x37fbde){if(_[_0x04c6('0x61')](_0x37fbde[_0x04c6('0xab')])){return _0xeca2d9[_0x04c6('0xaf')](_0x4bf86a);}else{if(!fs[_0x04c6('0xb0')](path[_0x04c6('0xb1')](config[_0x04c6('0xad')],_0x04c6('0xb2'),_0x37fbde['userpic']))){return _0xeca2d9['download'](_0x4bf86a);}return _0xeca2d9['download'](path[_0x04c6('0xb1')](config[_0x04c6('0xad')],_0x04c6('0xb2'),_0x37fbde[_0x04c6('0xab')]));}}})[_0x04c6('0x1b')](handleError(_0xeca2d9,null));};exports[_0x04c6('0xb3')]=function(_0xc7dfe5,_0x53982d){return db[_0x04c6('0x3b')]['find']({'where':{'id':_0xc7dfe5['params']['id']},'attributes':['id']})[_0x04c6('0x25')](handleEntityNotFound(_0x53982d,null))[_0x04c6('0x25')](function(_0x3eac1f){var _0x10a9ae=[];values=_0x3eac1f[_0x04c6('0x43')];_0x10a9ae[_0x04c6('0x3f')](get_open_tabs(_0x04c6('0x55'),_0x3eac1f['dataValues']));_0x10a9ae['push'](get_open_tabs(_0x04c6('0x44'),_0x3eac1f[_0x04c6('0x43')]));_0x10a9ae[_0x04c6('0x3f')](get_open_tabs('openchannel',_0x3eac1f[_0x04c6('0x43')]));_0x10a9ae[_0x04c6('0x3f')](get_open_tabs(_0x04c6('0x47'),_0x3eac1f[_0x04c6('0x43')]));_0x10a9ae['push'](get_open_tabs(_0x04c6('0xb4'),_0x3eac1f[_0x04c6('0x43')]));_0x10a9ae[_0x04c6('0x3f')](get_open_tabs('mail',_0x3eac1f[_0x04c6('0x43')]));return BPromise[_0x04c6('0x48')](_0x10a9ae);})[_0x04c6('0x25')](function(_0x2cc0d2){var _0x3d6281=[];if(_0x2cc0d2){for(var _0x24e786=0x0;_0x24e786<values[_0x04c6('0xb5')][_0x04c6('0x42')];_0x24e786++){var _0x35ea4b=values[_0x04c6('0xb5')][_0x24e786];_0x3d6281['push']({'channel':_0x04c6('0xb6'),'id':_0x35ea4b['id'],'createdAt':_0x35ea4b['createdAt']});}for(var _0x24e786=0x0;_0x24e786<values[_0x04c6('0xb7')][_0x04c6('0x42')];_0x24e786++){var _0x35ea4b=values[_0x04c6('0xb7')][_0x24e786];_0x3d6281[_0x04c6('0x3f')]({'channel':'FAX','id':_0x35ea4b['id'],'createdAt':_0x35ea4b[_0x04c6('0xb8')]});}for(var _0x24e786=0x0;_0x24e786<values[_0x04c6('0xb9')][_0x04c6('0x42')];_0x24e786++){var _0x35ea4b=values[_0x04c6('0xb9')][_0x24e786];_0x3d6281[_0x04c6('0x3f')]({'channel':_0x04c6('0xba'),'id':_0x35ea4b['id'],'createdAt':_0x35ea4b[_0x04c6('0xb8')]});}for(var _0x24e786=0x0;_0x24e786<values[_0x04c6('0xbb')][_0x04c6('0x42')];_0x24e786++){var _0x35ea4b=values[_0x04c6('0xbb')][_0x24e786];_0x3d6281[_0x04c6('0x3f')]({'channel':_0x04c6('0xbc'),'id':_0x35ea4b['id'],'createdAt':_0x35ea4b[_0x04c6('0xb8')]});}for(var _0x24e786=0x0;_0x24e786<values[_0x04c6('0xbd')][_0x04c6('0x42')];_0x24e786++){var _0x35ea4b=values[_0x04c6('0xbd')][_0x24e786];_0x3d6281[_0x04c6('0x3f')]({'channel':_0x04c6('0xbe'),'id':_0x35ea4b['id'],'createdAt':_0x35ea4b[_0x04c6('0xb8')]});}for(var _0x24e786=0x0;_0x24e786<values[_0x04c6('0xbf')][_0x04c6('0x42')];_0x24e786++){var _0x35ea4b=values['WhatsappOpenTabs'][_0x24e786];_0x3d6281[_0x04c6('0x3f')]({'channel':_0x04c6('0xc0'),'id':_0x35ea4b['id'],'createdAt':_0x35ea4b[_0x04c6('0xb8')]});}var _0x4ceace={'count':_0x3d6281[_0x04c6('0x42')],'rows':_0x3d6281};return _0x4ceace;}else return null;})[_0x04c6('0x25')](respondWithResult(_0x53982d,null))[_0x04c6('0x1b')](handleError(_0x53982d,null));};exports[_0x04c6('0xc1')]=function(_0x13dc47,_0x2668f6){var _0xfd8c8a={};var _0x35ff44={};var _0x2f12bd;var _0x5c775c;return db['User']['findOne']({'where':{'id':_0x13dc47['params']['id']}})[_0x04c6('0x25')](handleEntityNotFound(_0x2668f6,null))['then'](function(_0x7fe8c5){if(_0x7fe8c5){_0x2f12bd=_0x7fe8c5;_0x35ff44['model']=_[_0x04c6('0x4c')](db[_0x04c6('0xc2')][_0x04c6('0x36')]);_0x35ff44[_0x04c6('0x3c')]=_['keys'](_0x13dc47['query']);_0x35ff44[_0x04c6('0xc3')]=_['intersection'](_0x35ff44['model'],_0x35ff44[_0x04c6('0x3c')]);_0xfd8c8a[_0x04c6('0x3e')]=_['intersection'](_0x35ff44['model'],qs[_0x04c6('0x50')](_0x13dc47[_0x04c6('0x3c')][_0x04c6('0x50')]));_0xfd8c8a[_0x04c6('0x3e')]=_0xfd8c8a[_0x04c6('0x3e')][_0x04c6('0x42')]?_0xfd8c8a[_0x04c6('0x3e')]:_0x35ff44[_0x04c6('0x4f')];_0xfd8c8a['order']=qs['sort'](_0x13dc47['query'][_0x04c6('0xc4')]);_0xfd8c8a[_0x04c6('0x3a')]=qs[_0x04c6('0xc3')](_['pick'](_0x13dc47[_0x04c6('0x3c')],_0x35ff44[_0x04c6('0xc3')]));if(_0x13dc47[_0x04c6('0x3c')][_0x04c6('0x2d')]){_0xfd8c8a[_0x04c6('0x3a')]=_[_0x04c6('0xc5')](_0xfd8c8a['where'],{'$or':_['map'](_0xfd8c8a[_0x04c6('0x3e')],function(_0x422d18){var _0x4e6968={};_0x4e6968[_0x422d18]={'$like':'%'+_0x13dc47[_0x04c6('0x3c')][_0x04c6('0x2d')]+'%'};return _0x4e6968;})});}_0xfd8c8a=_[_0x04c6('0xc5')]({},_0xfd8c8a,_0x13dc47[_0x04c6('0x52')]);return _0x2f12bd[_0x04c6('0xc1')](_0xfd8c8a);}})['then'](function(_0x38050c){if(_0x38050c){_0x5c775c=_0x38050c[_0x04c6('0x42')];if(_0x13dc47[_0x04c6('0x3c')][_0x04c6('0xc6')](_0x04c6('0x51'))){_0xfd8c8a[_0x04c6('0x3d')]=[{'model':db[_0x04c6('0xc7')],'as':_0x04c6('0xc8'),'required':![]},{'model':db[_0x04c6('0xc9')],'as':_0x04c6('0xca'),'attributes':['id','name','color'],'where':_0x13dc47[_0x04c6('0x3c')]['tag']?{'id':_0x13dc47[_0x04c6('0x3c')]['tag']}:undefined,'required':_0x13dc47['query']['tag']?!![]:![]}];}if(!_0x13dc47[_0x04c6('0x3c')][_0x04c6('0xc6')](_0x04c6('0xcb'))){_0xfd8c8a['limit']=qs[_0x04c6('0x20')](_0x13dc47[_0x04c6('0x3c')]['limit']);_0xfd8c8a[_0x04c6('0x1e')]=qs['offset'](_0x13dc47[_0x04c6('0x3c')]['offset']);}return _0x2f12bd[_0x04c6('0xc1')](_0xfd8c8a);}})[_0x04c6('0x25')](function(_0x39ccbd){if(_0x39ccbd){return _0x39ccbd?{'count':_0x5c775c,'rows':_0x39ccbd}:null;}})[_0x04c6('0x25')](respondWithResult(_0x2668f6,null))['catch'](handleError(_0x2668f6,null));};exports[_0x04c6('0xcc')]=function(_0x597535,_0x480659){var _0x3216ac;var _0x259937;var _0xa2a344={};var _0x2e6490;return db[_0x04c6('0x3b')][_0x04c6('0x90')]({'where':{'id':_0x597535[_0x04c6('0x4a')]['id']},'attributes':['id',_0x04c6('0x33'),'role']})[_0x04c6('0x25')](handleEntityNotFound(_0x480659,null))[_0x04c6('0x25')](function(_0x2d0ef5){if(!utils[_0x04c6('0x98')](_0x597535[_0x04c6('0x3c')][_0x04c6('0x94')])){throw new db[(_0x04c6('0x8c'))][(_0x04c6('0x8a'))](_0x04c6('0x99'));}_0x3216ac=_0x2d0ef5;var _0x3de7f9={};_0x3de7f9[_0x04c6('0x4f')]=_['keys'](db[_[_0x04c6('0x9b')](_0x597535['query'][_0x04c6('0x94')])+_0x04c6('0xcd')]['rawAttributes']);_0x3de7f9[_0x04c6('0x3c')]=_[_0x04c6('0x4c')](_0x597535[_0x04c6('0x3c')]);_0x3de7f9[_0x04c6('0xc3')]=_['intersection'](_0x3de7f9['model'],_0x3de7f9[_0x04c6('0x3c')]);_0xa2a344[_0x04c6('0x3e')]=_[_0x04c6('0x4e')](_0x3de7f9[_0x04c6('0x4f')],qs['fields'](_0x597535[_0x04c6('0x3c')]['fields']));_0xa2a344['attributes']=_0xa2a344[_0x04c6('0x3e')][_0x04c6('0x42')]?_0xa2a344[_0x04c6('0x3e')]:_0x3de7f9[_0x04c6('0x4f')];_0xa2a344[_0x04c6('0xce')]=qs[_0x04c6('0xc4')](_0x597535[_0x04c6('0x3c')]['sort']);_0xa2a344[_0x04c6('0x3a')]=qs[_0x04c6('0xc3')](_[_0x04c6('0xcf')](_0x597535[_0x04c6('0x3c')],_0x3de7f9[_0x04c6('0xc3')]));if(_0x597535['query'][_0x04c6('0x2d')]){_0xa2a344[_0x04c6('0x3a')]=_[_0x04c6('0xc5')](_0xa2a344[_0x04c6('0x3a')],{'$or':_['map'](_0xa2a344[_0x04c6('0x3e')],function(_0x1905b2){var _0x25d18e={};_0x25d18e[_0x1905b2]={'$like':'%'+_0x597535['query'][_0x04c6('0x2d')]+'%'};return _0x25d18e;})});}_0xa2a344=_[_0x04c6('0xc5')]({},_0xa2a344,_0x597535[_0x04c6('0x52')]);switch(_0x3216ac[_0x04c6('0x27')]){case'admin':return db[_[_0x04c6('0x9b')](_0x597535['query']['channel'])+_0x04c6('0xcd')][_0x04c6('0x40')](_0xa2a344);case'user':case _0x04c6('0x2a'):return _0x3216ac[_0x04c6('0xa4')+_[_0x04c6('0x9b')](_0x597535[_0x04c6('0x3c')]['channel'])+_0x04c6('0x9d')](_0xa2a344);default:throw new db[(_0x04c6('0x8c'))][(_0x04c6('0x8a'))]('Unknown\x20role');}})[_0x04c6('0x25')](function(_0x1ae46a){_0x2e6490=_0x1ae46a[_0x04c6('0x42')];if(!_0x597535[_0x04c6('0x3c')][_0x04c6('0xc6')](_0x04c6('0xcb'))){_0xa2a344[_0x04c6('0x20')]=qs[_0x04c6('0x20')](_0x597535['query'][_0x04c6('0x20')]);_0xa2a344[_0x04c6('0x1e')]=qs[_0x04c6('0x1e')](_0x597535[_0x04c6('0x3c')]['offset']);}switch(_0x3216ac[_0x04c6('0x27')]){case _0x04c6('0x79'):return db[_[_0x04c6('0x9b')](_0x597535[_0x04c6('0x3c')]['channel'])+_0x04c6('0xcd')][_0x04c6('0x40')](_0xa2a344);case _0x04c6('0x77'):case _0x04c6('0x2a'):return _0x3216ac[_0x04c6('0xa4')+_[_0x04c6('0x9b')](_0x597535['query'][_0x04c6('0x94')])+_0x04c6('0x9d')](_0xa2a344);}})['then'](function(_0x43a29b){return{'count':_0x2e6490,'rows':_0x43a29b};})[_0x04c6('0x25')](respondWithResult(_0x480659,null))['catch'](handleError(_0x480659,null));};exports['getVoiceQueuesRt']=function(_0xf637c5,_0x4c95a4){var _0x40ba28={};var _0x2d0a7f={};var _0x178e25;var _0x2d5dbd;return db[_0x04c6('0x3b')]['findOne']({'where':{'id':_0xf637c5[_0x04c6('0x4a')]['id']}})[_0x04c6('0x25')](handleEntityNotFound(_0x4c95a4,null))[_0x04c6('0x25')](function(_0x218dc2){if(_0x218dc2){_0x178e25=_0x218dc2;_0x2d0a7f[_0x04c6('0x4f')]=_['keys'](db[_0x04c6('0xd0')][_0x04c6('0x36')]);_0x2d0a7f[_0x04c6('0x3c')]=_[_0x04c6('0x4c')](_0xf637c5[_0x04c6('0x3c')]);_0x2d0a7f[_0x04c6('0xc3')]=_['intersection'](_0x2d0a7f[_0x04c6('0x4f')],_0x2d0a7f[_0x04c6('0x3c')]);_0x40ba28['attributes']=_[_0x04c6('0x4e')](_0x2d0a7f[_0x04c6('0x4f')],qs[_0x04c6('0x50')](_0xf637c5[_0x04c6('0x3c')][_0x04c6('0x50')]));_0x40ba28['attributes']=_0x40ba28[_0x04c6('0x3e')][_0x04c6('0x42')]?_0x40ba28[_0x04c6('0x3e')]:_0x2d0a7f['model'];_0x40ba28['order']=qs[_0x04c6('0xc4')](_0xf637c5[_0x04c6('0x3c')][_0x04c6('0xc4')]);_0x40ba28[_0x04c6('0x3a')]=qs[_0x04c6('0xc3')](_[_0x04c6('0xcf')](_0xf637c5[_0x04c6('0x3c')],_0x2d0a7f[_0x04c6('0xc3')]));if(_0xf637c5[_0x04c6('0x3c')][_0x04c6('0x2d')]){_0x40ba28['where']=_[_0x04c6('0xc5')](_0x40ba28[_0x04c6('0x3a')],{'$or':_['map'](_0x40ba28['attributes'],function(_0x3a55f4){var _0x5b411e={};_0x5b411e[_0x3a55f4]={'$like':'%'+_0xf637c5[_0x04c6('0x3c')]['filter']+'%'};return _0x5b411e;})});}_0x40ba28=_['merge']({},_0x40ba28,_0xf637c5[_0x04c6('0x52')]);return _0x178e25[_0x04c6('0xd1')](_0x40ba28);}})['then'](function(_0x593f75){if(_0x593f75){_0x2d5dbd=_0x593f75['length'];if(!_0xf637c5[_0x04c6('0x3c')][_0x04c6('0xc6')](_0x04c6('0xcb'))){_0x40ba28['limit']=qs[_0x04c6('0x20')](_0xf637c5[_0x04c6('0x3c')][_0x04c6('0x20')]);_0x40ba28[_0x04c6('0x1e')]=qs[_0x04c6('0x1e')](_0xf637c5['query'][_0x04c6('0x1e')]);}return _0x178e25[_0x04c6('0xd1')](_0x40ba28);}})[_0x04c6('0x25')](function(_0x24a354){if(_0x24a354){return _0x24a354?{'count':_0x2d5dbd,'rows':_0x24a354}:null;}})[_0x04c6('0x25')](respondWithResult(_0x4c95a4,null))[_0x04c6('0x1b')](handleError(_0x4c95a4,null));};exports[_0x04c6('0xd2')]=function(_0x2bd911,_0x211aaa){var _0x2541a7={};var _0x417974={};var _0x16f32d;var _0x3eeaf4;return db[_0x04c6('0x3b')][_0x04c6('0x90')]({'where':{'id':_0x2bd911[_0x04c6('0x4a')]['id']}})[_0x04c6('0x25')](handleEntityNotFound(_0x211aaa,null))['then'](function(_0x26a4cb){if(_0x26a4cb){_0x16f32d=_0x26a4cb;_0x417974[_0x04c6('0x4f')]=_[_0x04c6('0x4c')](db[_0x04c6('0xd3')][_0x04c6('0x36')]);_0x417974[_0x04c6('0x3c')]=_[_0x04c6('0x4c')](_0x2bd911['query']);_0x417974[_0x04c6('0xc3')]=_[_0x04c6('0x4e')](_0x417974['model'],_0x417974['query']);_0x2541a7['attributes']=_['intersection'](_0x417974[_0x04c6('0x4f')],qs['fields'](_0x2bd911['query'][_0x04c6('0x50')]));_0x2541a7[_0x04c6('0x3e')]=_0x2541a7[_0x04c6('0x3e')][_0x04c6('0x42')]?_0x2541a7[_0x04c6('0x3e')]:_0x417974[_0x04c6('0x4f')];_0x2541a7['order']=qs[_0x04c6('0xc4')](_0x2bd911[_0x04c6('0x3c')][_0x04c6('0xc4')]);_0x2541a7[_0x04c6('0x3a')]=qs['filters'](_['pick'](_0x2bd911['query'],_0x417974[_0x04c6('0xc3')]));if(_0x2bd911[_0x04c6('0x3c')][_0x04c6('0x2d')]){_0x2541a7[_0x04c6('0x3a')]=_[_0x04c6('0xc5')](_0x2541a7['where'],{'$or':_[_0x04c6('0x2f')](_0x2541a7['attributes'],function(_0x436973){var _0x488a62={};_0x488a62[_0x436973]={'$like':'%'+_0x2bd911['query'][_0x04c6('0x2d')]+'%'};return _0x488a62;})});}_0x2541a7=_[_0x04c6('0xc5')]({},_0x2541a7,_0x2bd911['options']);return _0x16f32d[_0x04c6('0xd2')](_0x2541a7);}})[_0x04c6('0x25')](function(_0x364a8e){if(_0x364a8e){_0x3eeaf4=_0x364a8e[_0x04c6('0x42')];if(!_0x2bd911[_0x04c6('0x3c')]['hasOwnProperty'](_0x04c6('0xcb'))){_0x2541a7[_0x04c6('0x20')]=qs['limit'](_0x2bd911[_0x04c6('0x3c')]['limit']);_0x2541a7[_0x04c6('0x1e')]=qs[_0x04c6('0x1e')](_0x2bd911[_0x04c6('0x3c')][_0x04c6('0x1e')]);}return _0x16f32d[_0x04c6('0xd2')](_0x2541a7);}})[_0x04c6('0x25')](function(_0x325f72){if(_0x325f72){return _0x325f72?{'count':_0x3eeaf4,'rows':_0x325f72}:null;}})[_0x04c6('0x25')](respondWithResult(_0x211aaa,null))[_0x04c6('0x1b')](handleError(_0x211aaa,null));};exports['getRecordings']=function(_0x89b522,_0x6d21be){var _0x1f191f={'raw':!![],'where':{}};var _0x44fb02={};var _0x4309da={'count':0x0,'rows':[]};return db[_0x04c6('0x3b')]['findOne']({'where':{'id':_0x89b522['params']['id']}})[_0x04c6('0x25')](handleEntityNotFound(_0x6d21be,null))[_0x04c6('0x25')](function(_0x467924){if(_0x467924){_0x44fb02[_0x04c6('0x4f')]=_[_0x04c6('0x4c')](db[_0x04c6('0xd4')]['rawAttributes']);_0x44fb02[_0x04c6('0x3c')]=_[_0x04c6('0x4c')](_0x89b522[_0x04c6('0x3c')]);_0x44fb02[_0x04c6('0xc3')]=_['intersection'](_0x44fb02[_0x04c6('0x4f')],_0x44fb02['query']);_0x1f191f[_0x04c6('0x3e')]=_[_0x04c6('0x4e')](_0x44fb02['model'],qs[_0x04c6('0x50')](_0x89b522['query'][_0x04c6('0x50')]));_0x1f191f[_0x04c6('0x3e')]=_0x1f191f['attributes'][_0x04c6('0x42')]?_0x1f191f[_0x04c6('0x3e')]:_0x44fb02['model'];if(!_0x89b522['query'][_0x04c6('0xc6')](_0x04c6('0xcb'))){_0x1f191f[_0x04c6('0x20')]=qs[_0x04c6('0x20')](_0x89b522[_0x04c6('0x3c')][_0x04c6('0x20')]);_0x1f191f[_0x04c6('0x1e')]=qs[_0x04c6('0x1e')](_0x89b522[_0x04c6('0x3c')]['offset']);}_0x1f191f[_0x04c6('0xce')]=qs[_0x04c6('0xc4')](_0x89b522[_0x04c6('0x3c')][_0x04c6('0xc4')]);_0x1f191f[_0x04c6('0x3a')]=qs[_0x04c6('0xc3')](_[_0x04c6('0xcf')](_0x89b522[_0x04c6('0x3c')],_0x44fb02['filters']));_0x1f191f[_0x04c6('0x3a')][_0x04c6('0xd5')]=_0x467924['id'];if(_0x89b522['query']['filter']){_0x1f191f[_0x04c6('0x3a')]=_['merge'](_0x1f191f[_0x04c6('0x3a')],{'$or':_[_0x04c6('0x2f')](_0x1f191f[_0x04c6('0x3e')],function(_0x40f30e){var _0x429352={};_0x429352[_0x40f30e]={'$like':'%'+_0x89b522[_0x04c6('0x3c')][_0x04c6('0x2d')]+'%'};return _0x429352;})});}_0x1f191f=_[_0x04c6('0xc5')]({},_0x1f191f,_0x89b522[_0x04c6('0x52')]);return db[_0x04c6('0xd4')]['count']({'where':_0x1f191f[_0x04c6('0x3a')]})['then'](function(_0x5b9c66){_0x4309da['count']=_0x5b9c66;if(_0x89b522[_0x04c6('0x3c')][_0x04c6('0x51')]){_0x1f191f[_0x04c6('0x3d')]=[{'all':!![]}];}return db[_0x04c6('0xd4')][_0x04c6('0x40')](_0x1f191f);})[_0x04c6('0x25')](function(_0x3b6f92){_0x4309da[_0x04c6('0x41')]=_0x3b6f92;return _0x4309da;});}})[_0x04c6('0x25')](respondWithFilteredResult(_0x6d21be,_0x1f191f))[_0x04c6('0x1b')](handleError(_0x6d21be,null));};exports[_0x04c6('0xd6')]=function(_0x53ac56,_0x3a1fac){var _0x1cdccf={'raw':!![],'where':{}};var _0x1c144c={};var _0x45674a={'count':0x0,'rows':[]};return db[_0x04c6('0x3b')][_0x04c6('0x90')]({'where':{'id':_0x53ac56[_0x04c6('0x4a')]['id']}})[_0x04c6('0x25')](handleEntityNotFound(_0x3a1fac,null))['then'](function(_0x10c063){if(_0x10c063){_0x1c144c[_0x04c6('0x4f')]=_[_0x04c6('0x4c')](db[_0x04c6('0xd7')]['rawAttributes']);_0x1c144c[_0x04c6('0x3c')]=_['keys'](_0x53ac56['query']);_0x1c144c['filters']=_[_0x04c6('0x4e')](_0x1c144c[_0x04c6('0x4f')],_0x1c144c[_0x04c6('0x3c')]);_0x1cdccf[_0x04c6('0x3e')]=_[_0x04c6('0x4e')](_0x1c144c[_0x04c6('0x4f')],qs[_0x04c6('0x50')](_0x53ac56['query'][_0x04c6('0x50')]));_0x1cdccf[_0x04c6('0x3e')]=_0x1cdccf[_0x04c6('0x3e')][_0x04c6('0x42')]?_0x1cdccf['attributes']:_0x1c144c['model'];if(!_0x53ac56[_0x04c6('0x3c')]['hasOwnProperty'](_0x04c6('0xcb'))){_0x1cdccf[_0x04c6('0x20')]=qs['limit'](_0x53ac56['query'][_0x04c6('0x20')]);_0x1cdccf[_0x04c6('0x1e')]=qs['offset'](_0x53ac56[_0x04c6('0x3c')][_0x04c6('0x1e')]);}_0x1cdccf[_0x04c6('0xce')]=qs[_0x04c6('0xc4')](_0x53ac56[_0x04c6('0x3c')][_0x04c6('0xc4')]);_0x1cdccf[_0x04c6('0x3a')]=qs[_0x04c6('0xc3')](_['pick'](_0x53ac56['query'],_0x1c144c['filters']));_0x1cdccf[_0x04c6('0x3a')]['UserId']=_0x10c063['id'];if(_0x53ac56['query'][_0x04c6('0x2d')]){_0x1cdccf[_0x04c6('0x3a')]=_[_0x04c6('0xc5')](_0x1cdccf[_0x04c6('0x3a')],{'$or':_[_0x04c6('0x2f')](_0x1cdccf[_0x04c6('0x3e')],function(_0x363847){var _0x4a86a4={};_0x4a86a4[_0x363847]={'$like':'%'+_0x53ac56[_0x04c6('0x3c')][_0x04c6('0x2d')]+'%'};return _0x4a86a4;})});}_0x1cdccf=_[_0x04c6('0xc5')]({},_0x1cdccf,_0x53ac56['options']);return db[_0x04c6('0xd7')]['count']({'where':_0x1cdccf[_0x04c6('0x3a')]})[_0x04c6('0x25')](function(_0x1de956){_0x45674a['count']=_0x1de956;if(_0x53ac56[_0x04c6('0x3c')][_0x04c6('0x51')]){_0x1cdccf[_0x04c6('0x3d')]=[{'all':!![]}];}return db['ScreenRecording'][_0x04c6('0x40')](_0x1cdccf);})[_0x04c6('0x25')](function(_0x535f41){_0x45674a[_0x04c6('0x41')]=_0x535f41;return _0x45674a;});}})[_0x04c6('0x25')](respondWithFilteredResult(_0x3a1fac,_0x1cdccf))[_0x04c6('0x1b')](handleError(_0x3a1fac,null));};exports[_0x04c6('0xd8')]=function(_0x1498fc,_0x5e0ba3){var _0x1e1c56={};var _0x301635={};var _0x281dc1;var _0x396351;return db[_0x04c6('0x3b')]['findOne']({'where':{'id':_0x1498fc[_0x04c6('0x4a')]['id']}})['then'](handleEntityNotFound(_0x5e0ba3,null))[_0x04c6('0x25')](function(_0x4804f6){if(_0x4804f6){_0x281dc1=_0x4804f6;_0x301635[_0x04c6('0x4f')]=_['keys'](db[_0x04c6('0xd9')][_0x04c6('0x36')]);_0x301635['query']=_[_0x04c6('0x4c')](_0x1498fc[_0x04c6('0x3c')]);_0x301635[_0x04c6('0xc3')]=_['intersection'](_0x301635[_0x04c6('0x4f')],_0x301635[_0x04c6('0x3c')]);_0x1e1c56[_0x04c6('0x3e')]=_[_0x04c6('0x4e')](_0x301635['model'],qs['fields'](_0x1498fc['query'][_0x04c6('0x50')]));_0x1e1c56[_0x04c6('0x3e')]=_0x1e1c56[_0x04c6('0x3e')][_0x04c6('0x42')]?_0x1e1c56[_0x04c6('0x3e')]:_0x301635[_0x04c6('0x4f')];_0x1e1c56[_0x04c6('0xce')]=qs['sort'](_0x1498fc[_0x04c6('0x3c')]['sort']);_0x1e1c56[_0x04c6('0x3a')]=qs['filters'](_[_0x04c6('0xcf')](_0x1498fc[_0x04c6('0x3c')],_0x301635[_0x04c6('0xc3')]));if(_0x1498fc[_0x04c6('0x3c')][_0x04c6('0x2d')]){_0x1e1c56[_0x04c6('0x3a')]=_[_0x04c6('0xc5')](_0x1e1c56[_0x04c6('0x3a')],{'$or':_['map'](_0x1e1c56[_0x04c6('0x3e')],function(_0x11754d){var _0x22bd8a={};_0x22bd8a[_0x11754d]={'$like':'%'+_0x1498fc[_0x04c6('0x3c')][_0x04c6('0x2d')]+'%'};return _0x22bd8a;})});}_0x1e1c56=_[_0x04c6('0xc5')]({},_0x1e1c56,_0x1498fc['options']);return _0x281dc1[_0x04c6('0xd8')](_0x1e1c56);}})[_0x04c6('0x25')](function(_0x1ea3d1){if(_0x1ea3d1){_0x396351=_0x1ea3d1[_0x04c6('0x42')];if(!_0x1498fc[_0x04c6('0x3c')][_0x04c6('0xc6')](_0x04c6('0xcb'))){_0x1e1c56[_0x04c6('0x20')]=qs[_0x04c6('0x20')](_0x1498fc[_0x04c6('0x3c')][_0x04c6('0x20')]);_0x1e1c56[_0x04c6('0x1e')]=qs[_0x04c6('0x1e')](_0x1498fc['query'][_0x04c6('0x1e')]);}return _0x281dc1['getChatInteractions'](_0x1e1c56);}})[_0x04c6('0x25')](function(_0x2e095f){if(_0x2e095f){return _0x2e095f?{'count':_0x396351,'rows':_0x2e095f}:null;}})[_0x04c6('0x25')](respondWithResult(_0x5e0ba3,null))[_0x04c6('0x1b')](handleError(_0x5e0ba3,null));};exports[_0x04c6('0xda')]=function(_0x3552ff,_0x3f2230){var _0x1a54c8={};var _0x2ef949={};var _0xffbe1b;var _0x4a37a9;return db['User'][_0x04c6('0x90')]({'where':{'id':_0x3552ff['params']['id']}})[_0x04c6('0x25')](handleEntityNotFound(_0x3f2230,null))[_0x04c6('0x25')](function(_0x290541){if(_0x290541){_0xffbe1b=_0x290541;_0x2ef949[_0x04c6('0x4f')]=_['keys'](db[_0x04c6('0xdb')]['rawAttributes']);_0x2ef949[_0x04c6('0x3c')]=_[_0x04c6('0x4c')](_0x3552ff[_0x04c6('0x3c')]);_0x2ef949[_0x04c6('0xc3')]=_[_0x04c6('0x4e')](_0x2ef949['model'],_0x2ef949[_0x04c6('0x3c')]);_0x1a54c8[_0x04c6('0x3e')]=_[_0x04c6('0x4e')](_0x2ef949[_0x04c6('0x4f')],qs[_0x04c6('0x50')](_0x3552ff[_0x04c6('0x3c')][_0x04c6('0x50')]));_0x1a54c8[_0x04c6('0x3e')]=_0x1a54c8[_0x04c6('0x3e')]['length']?_0x1a54c8[_0x04c6('0x3e')]:_0x2ef949[_0x04c6('0x4f')];_0x1a54c8[_0x04c6('0xce')]=qs[_0x04c6('0xc4')](_0x3552ff[_0x04c6('0x3c')][_0x04c6('0xc4')]);_0x1a54c8[_0x04c6('0x3a')]=qs[_0x04c6('0xc3')](_[_0x04c6('0xcf')](_0x3552ff[_0x04c6('0x3c')],_0x2ef949[_0x04c6('0xc3')]));if(_0x3552ff['query'][_0x04c6('0x2d')]){_0x1a54c8[_0x04c6('0x3a')]=_['merge'](_0x1a54c8[_0x04c6('0x3a')],{'$or':_[_0x04c6('0x2f')](_0x1a54c8[_0x04c6('0x3e')],function(_0x1ce667){var _0x549484={};_0x549484[_0x1ce667]={'$like':'%'+_0x3552ff['query'][_0x04c6('0x2d')]+'%'};return _0x549484;})});}_0x1a54c8=_[_0x04c6('0xc5')]({},_0x1a54c8,_0x3552ff[_0x04c6('0x52')]);return _0xffbe1b['getOpenchannelInteractions'](_0x1a54c8);}})[_0x04c6('0x25')](function(_0x70772e){if(_0x70772e){_0x4a37a9=_0x70772e['length'];if(!_0x3552ff[_0x04c6('0x3c')][_0x04c6('0xc6')](_0x04c6('0xcb'))){_0x1a54c8['limit']=qs[_0x04c6('0x20')](_0x3552ff[_0x04c6('0x3c')]['limit']);_0x1a54c8['offset']=qs[_0x04c6('0x1e')](_0x3552ff[_0x04c6('0x3c')][_0x04c6('0x1e')]);}return _0xffbe1b[_0x04c6('0xda')](_0x1a54c8);}})['then'](function(_0x495d45){if(_0x495d45){return _0x495d45?{'count':_0x4a37a9,'rows':_0x495d45}:null;}})['then'](respondWithResult(_0x3f2230,null))[_0x04c6('0x1b')](handleError(_0x3f2230,null));};exports[_0x04c6('0xdc')]=function(_0x56618b,_0xb6b6ef){var _0x59e0ba={'raw':!![],'where':{}};var _0x47cf0a={};var _0x98aca7={'count':0x0,'rows':[]};return db[_0x04c6('0x3b')]['findOne']({'where':{'id':_0x56618b[_0x04c6('0x4a')]['id']}})[_0x04c6('0x25')](handleEntityNotFound(_0xb6b6ef,null))['then'](function(_0xc89cb5){if(_0xc89cb5){_0x47cf0a[_0x04c6('0x4f')]=_[_0x04c6('0x4c')](db[_0x04c6('0xdd')][_0x04c6('0x36')]);_0x47cf0a[_0x04c6('0x3c')]=_[_0x04c6('0x4c')](_0x56618b['query']);_0x47cf0a[_0x04c6('0xc3')]=_[_0x04c6('0x4e')](_0x47cf0a[_0x04c6('0x4f')],_0x47cf0a[_0x04c6('0x3c')]);_0x59e0ba[_0x04c6('0x3e')]=_[_0x04c6('0x4e')](_0x47cf0a['model'],qs['fields'](_0x56618b[_0x04c6('0x3c')][_0x04c6('0x50')]));_0x59e0ba[_0x04c6('0x3e')]=_0x59e0ba[_0x04c6('0x3e')][_0x04c6('0x42')]?_0x59e0ba[_0x04c6('0x3e')]:_0x47cf0a['model'];if(!_0x56618b[_0x04c6('0x3c')][_0x04c6('0xc6')](_0x04c6('0xcb'))){_0x59e0ba['limit']=qs[_0x04c6('0x20')](_0x56618b[_0x04c6('0x3c')][_0x04c6('0x20')]);_0x59e0ba[_0x04c6('0x1e')]=qs[_0x04c6('0x1e')](_0x56618b[_0x04c6('0x3c')][_0x04c6('0x1e')]);}_0x59e0ba[_0x04c6('0xce')]=qs[_0x04c6('0xc4')](_0x56618b[_0x04c6('0x3c')]['sort']);_0x59e0ba[_0x04c6('0x3a')]=qs[_0x04c6('0xc3')](_[_0x04c6('0xcf')](_0x56618b[_0x04c6('0x3c')],_0x47cf0a[_0x04c6('0xc3')]));_0x59e0ba[_0x04c6('0x3a')]['UserId']=_0xc89cb5['id'];if(_0x56618b[_0x04c6('0x3c')][_0x04c6('0x2d')]){_0x59e0ba[_0x04c6('0x3a')]=_[_0x04c6('0xc5')](_0x59e0ba['where'],{'$or':_[_0x04c6('0x2f')](_0x59e0ba[_0x04c6('0x3e')],function(_0x11cca8){var _0x54e67a={};_0x54e67a[_0x11cca8]={'$like':'%'+_0x56618b[_0x04c6('0x3c')]['filter']+'%'};return _0x54e67a;})});}_0x59e0ba=_[_0x04c6('0xc5')]({},_0x59e0ba,_0x56618b[_0x04c6('0x52')]);return db[_0x04c6('0xdd')][_0x04c6('0x21')]({'where':_0x59e0ba[_0x04c6('0x3a')]})[_0x04c6('0x25')](function(_0x2c37f6){_0x98aca7[_0x04c6('0x21')]=_0x2c37f6;if(_0x56618b[_0x04c6('0x3c')]['includeAll']){_0x59e0ba['include']=[{'all':!![]}];}return db[_0x04c6('0xdd')][_0x04c6('0x40')](_0x59e0ba);})[_0x04c6('0x25')](function(_0x26beae){_0x98aca7['rows']=_0x26beae;return _0x98aca7;});}})[_0x04c6('0x25')](respondWithFilteredResult(_0xb6b6ef,_0x59e0ba))[_0x04c6('0x1b')](handleError(_0xb6b6ef,null));};exports[_0x04c6('0xde')]=function(_0x45a544,_0x285e41){var _0x2d6edb={};var _0x32599d={};var _0x1acaf6;var _0x61d39c;return db[_0x04c6('0x3b')][_0x04c6('0x90')]({'where':{'id':_0x45a544['params']['id']}})['then'](handleEntityNotFound(_0x285e41,null))['then'](function(_0x233cba){if(_0x233cba){_0x1acaf6=_0x233cba;_0x32599d['model']=_['keys'](db[_0x04c6('0xdf')][_0x04c6('0x36')]);_0x32599d[_0x04c6('0x3c')]=_[_0x04c6('0x4c')](_0x45a544['query']);_0x32599d['filters']=_[_0x04c6('0x4e')](_0x32599d['model'],_0x32599d[_0x04c6('0x3c')]);_0x2d6edb[_0x04c6('0x3e')]=_[_0x04c6('0x4e')](_0x32599d[_0x04c6('0x4f')],qs[_0x04c6('0x50')](_0x45a544[_0x04c6('0x3c')][_0x04c6('0x50')]));_0x2d6edb['attributes']=_0x2d6edb['attributes'][_0x04c6('0x42')]?_0x2d6edb['attributes']:_0x32599d['model'];_0x2d6edb[_0x04c6('0xce')]=qs[_0x04c6('0xc4')](_0x45a544['query']['sort']);_0x2d6edb[_0x04c6('0x3a')]=qs[_0x04c6('0xc3')](_[_0x04c6('0xcf')](_0x45a544[_0x04c6('0x3c')],_0x32599d[_0x04c6('0xc3')]));if(_0x45a544[_0x04c6('0x3c')][_0x04c6('0x2d')]){_0x2d6edb[_0x04c6('0x3a')]=_['merge'](_0x2d6edb['where'],{'$or':_[_0x04c6('0x2f')](_0x2d6edb[_0x04c6('0x3e')],function(_0x4e4872){var _0x1717b0={};_0x1717b0[_0x4e4872]={'$like':'%'+_0x45a544[_0x04c6('0x3c')][_0x04c6('0x2d')]+'%'};return _0x1717b0;})});}_0x2d6edb=_['merge']({},_0x2d6edb,_0x45a544[_0x04c6('0x52')]);return _0x1acaf6[_0x04c6('0xde')](_0x2d6edb);}})[_0x04c6('0x25')](function(_0x33c83e){if(_0x33c83e){_0x61d39c=_0x33c83e['length'];if(!_0x45a544[_0x04c6('0x3c')][_0x04c6('0xc6')]('nolimit')){_0x2d6edb[_0x04c6('0x20')]=qs[_0x04c6('0x20')](_0x45a544[_0x04c6('0x3c')][_0x04c6('0x20')]);_0x2d6edb['offset']=qs[_0x04c6('0x1e')](_0x45a544[_0x04c6('0x3c')][_0x04c6('0x1e')]);}return _0x1acaf6[_0x04c6('0xde')](_0x2d6edb);}})[_0x04c6('0x25')](function(_0x30e12e){if(_0x30e12e){return _0x30e12e?{'count':_0x61d39c,'rows':_0x30e12e}:null;}})[_0x04c6('0x25')](respondWithResult(_0x285e41,null))['catch'](handleError(_0x285e41,null));};exports[_0x04c6('0xe0')]=function(_0x429211,_0x268372){var _0x56e1b8={};var _0x3b8ecc={};var _0x2a043b;var _0x5b0b8b;return db['User'][_0x04c6('0x90')]({'where':{'id':_0x429211[_0x04c6('0x4a')]['id']}})[_0x04c6('0x25')](handleEntityNotFound(_0x268372,null))['then'](function(_0x8d7a75){if(_0x8d7a75){_0x2a043b=_0x8d7a75;_0x3b8ecc[_0x04c6('0x4f')]=_['keys'](db['FaxInteraction'][_0x04c6('0x36')]);_0x3b8ecc[_0x04c6('0x3c')]=_['keys'](_0x429211[_0x04c6('0x3c')]);_0x3b8ecc['filters']=_[_0x04c6('0x4e')](_0x3b8ecc[_0x04c6('0x4f')],_0x3b8ecc[_0x04c6('0x3c')]);_0x56e1b8[_0x04c6('0x3e')]=_['intersection'](_0x3b8ecc[_0x04c6('0x4f')],qs[_0x04c6('0x50')](_0x429211[_0x04c6('0x3c')]['fields']));_0x56e1b8[_0x04c6('0x3e')]=_0x56e1b8[_0x04c6('0x3e')][_0x04c6('0x42')]?_0x56e1b8[_0x04c6('0x3e')]:_0x3b8ecc[_0x04c6('0x4f')];_0x56e1b8[_0x04c6('0xce')]=qs[_0x04c6('0xc4')](_0x429211[_0x04c6('0x3c')][_0x04c6('0xc4')]);_0x56e1b8[_0x04c6('0x3a')]=qs[_0x04c6('0xc3')](_[_0x04c6('0xcf')](_0x429211[_0x04c6('0x3c')],_0x3b8ecc[_0x04c6('0xc3')]));if(_0x429211[_0x04c6('0x3c')][_0x04c6('0x2d')]){_0x56e1b8[_0x04c6('0x3a')]=_['merge'](_0x56e1b8[_0x04c6('0x3a')],{'$or':_[_0x04c6('0x2f')](_0x56e1b8[_0x04c6('0x3e')],function(_0x31c07e){var _0x383993={};_0x383993[_0x31c07e]={'$like':'%'+_0x429211['query'][_0x04c6('0x2d')]+'%'};return _0x383993;})});}_0x56e1b8=_[_0x04c6('0xc5')]({},_0x56e1b8,_0x429211[_0x04c6('0x52')]);return _0x2a043b['getFaxInteractions'](_0x56e1b8);}})[_0x04c6('0x25')](function(_0x5546a9){if(_0x5546a9){_0x5b0b8b=_0x5546a9[_0x04c6('0x42')];if(!_0x429211['query'][_0x04c6('0xc6')](_0x04c6('0xcb'))){_0x56e1b8['limit']=qs[_0x04c6('0x20')](_0x429211['query'][_0x04c6('0x20')]);_0x56e1b8['offset']=qs[_0x04c6('0x1e')](_0x429211[_0x04c6('0x3c')][_0x04c6('0x1e')]);}return _0x2a043b[_0x04c6('0xe0')](_0x56e1b8);}})[_0x04c6('0x25')](function(_0x5ecaac){if(_0x5ecaac){return _0x5ecaac?{'count':_0x5b0b8b,'rows':_0x5ecaac}:null;}})['then'](respondWithResult(_0x268372,null))['catch'](handleError(_0x268372,null));};exports[_0x04c6('0xe1')]=function(_0x35f834,_0x4e389e){var _0x248972={};var _0x59ced9={};var _0x4580ac;var _0x512bb5;return db[_0x04c6('0x3b')][_0x04c6('0x90')]({'where':{'id':_0x35f834[_0x04c6('0x4a')]['id']}})[_0x04c6('0x25')](handleEntityNotFound(_0x4e389e,null))[_0x04c6('0x25')](function(_0x23cdee){if(_0x23cdee){_0x4580ac=_0x23cdee;_0x59ced9[_0x04c6('0x4f')]=_[_0x04c6('0x4c')](db['WhatsappInteraction'][_0x04c6('0x36')]);_0x59ced9[_0x04c6('0x3c')]=_[_0x04c6('0x4c')](_0x35f834[_0x04c6('0x3c')]);_0x59ced9[_0x04c6('0xc3')]=_[_0x04c6('0x4e')](_0x59ced9['model'],_0x59ced9['query']);_0x248972[_0x04c6('0x3e')]=_[_0x04c6('0x4e')](_0x59ced9[_0x04c6('0x4f')],qs[_0x04c6('0x50')](_0x35f834[_0x04c6('0x3c')]['fields']));_0x248972[_0x04c6('0x3e')]=_0x248972[_0x04c6('0x3e')][_0x04c6('0x42')]?_0x248972['attributes']:_0x59ced9[_0x04c6('0x4f')];_0x248972[_0x04c6('0xce')]=qs[_0x04c6('0xc4')](_0x35f834[_0x04c6('0x3c')][_0x04c6('0xc4')]);_0x248972[_0x04c6('0x3a')]=qs[_0x04c6('0xc3')](_[_0x04c6('0xcf')](_0x35f834[_0x04c6('0x3c')],_0x59ced9[_0x04c6('0xc3')]));if(_0x35f834[_0x04c6('0x3c')][_0x04c6('0x2d')]){_0x248972['where']=_[_0x04c6('0xc5')](_0x248972['where'],{'$or':_[_0x04c6('0x2f')](_0x248972[_0x04c6('0x3e')],function(_0x15a29e){var _0x4f8706={};_0x4f8706[_0x15a29e]={'$like':'%'+_0x35f834['query'][_0x04c6('0x2d')]+'%'};return _0x4f8706;})});}_0x248972=_[_0x04c6('0xc5')]({},_0x248972,_0x35f834[_0x04c6('0x52')]);return _0x4580ac['getWhatsappInteractions'](_0x248972);}})[_0x04c6('0x25')](function(_0x45388b){if(_0x45388b){_0x512bb5=_0x45388b[_0x04c6('0x42')];if(!_0x35f834[_0x04c6('0x3c')][_0x04c6('0xc6')](_0x04c6('0xcb'))){_0x248972[_0x04c6('0x20')]=qs[_0x04c6('0x20')](_0x35f834[_0x04c6('0x3c')][_0x04c6('0x20')]);_0x248972[_0x04c6('0x1e')]=qs[_0x04c6('0x1e')](_0x35f834[_0x04c6('0x3c')][_0x04c6('0x1e')]);}return _0x4580ac[_0x04c6('0xe1')](_0x248972);}})['then'](function(_0x875669){if(_0x875669){return _0x875669?{'count':_0x512bb5,'rows':_0x875669}:null;}})[_0x04c6('0x25')](respondWithResult(_0x4e389e,null))[_0x04c6('0x1b')](handleError(_0x4e389e,null));};exports[_0x04c6('0xe2')]=function(_0x4ae92a,_0x530c28,_0x31bcf1){var _0x4b46a1;var _0x1f9ee9;var _0x2813e7;var _0x4e9790=!_[_0x04c6('0x61')](_0x4ae92a[_0x04c6('0x4a')]['id'])?_0x4ae92a[_0x04c6('0x4a')]['id']:!_[_0x04c6('0x61')](_0x4ae92a[_0x04c6('0x77')]['id'])?_0x4ae92a['user']['id']:null;return db[_0x04c6('0x3b')][_0x04c6('0x32')]({'where':{'id':_0x4e9790,'role':{'$or':[_0x04c6('0x79'),'user',_0x04c6('0x2a')]}},'attributes':['id',_0x04c6('0x33'),'phone',_0x04c6('0xe3'),_0x04c6('0x27'),'internal',_0x04c6('0x96')]})[_0x04c6('0x25')](function(_0x3e0015){if(_0x3e0015){if(_0x3e0015[_0x04c6('0x27')]===_0x04c6('0x2a')){_0x4b46a1=_0x3e0015;if(_0x4ae92a[_0x04c6('0x56')][_0x04c6('0x97')]){_0x2813e7=util[_0x04c6('0xe4')](_0x04c6('0xe5'),_0x4b46a1[_0x4ae92a[_0x04c6('0x56')]['interface']]);}else if(_0x4ae92a[_0x04c6('0x56')][_0x04c6('0xe6')]){_0x2813e7=util[_0x04c6('0xe4')](_0x04c6('0xa5'),_0x4ae92a[_0x04c6('0x56')]['intrf']);}else{_0x2813e7=util[_0x04c6('0xe4')](_0x04c6('0xa5'),_0x4b46a1[_0x04c6('0x33')]);}socket['to'](util[_0x04c6('0xe4')](_0x04c6('0xe7'),_0x4b46a1[_0x04c6('0x33')]))[_0x04c6('0xa0')](_0x04c6('0xe8'),{'user':{'id':_0x4b46a1['id'],'name':_0x4b46a1[_0x04c6('0x33')]},'ip':_0x4ae92a[_0x04c6('0xe9')][_0x04c6('0xea')]||_0x4ae92a[_0x04c6('0xeb')][_0x04c6('0xec')]||_0x4ae92a[_0x04c6('0xed')][_0x04c6('0xec')]||_0x4ae92a['connection'][_0x04c6('0xed')]['remoteAddress']});return db[_0x04c6('0xd0')]['destroy']({'where':{'membername':_0x4b46a1[_0x04c6('0x33')]},'individualHooks':!![]});}}else{throw new db[(_0x04c6('0x8c'))][(_0x04c6('0x8a'))](_0x04c6('0xee'));}})[_0x04c6('0x25')](function(){if(_0x4b46a1){return _0x4b46a1['getVoiceQueues']({'raw':!![]});}})['then'](function(_0x5dc6b8){if(_0x4b46a1){var _0x3d07dd=[];if(_0x5dc6b8){_0x1f9ee9=_0x5dc6b8;if(_0x1f9ee9[_0x04c6('0x42')]){for(var _0x5a644a=0x0;_0x5a644a<_0x1f9ee9['length'];_0x5a644a++){_0x3d07dd[_0x04c6('0x3f')]({'membername':_0x4b46a1[_0x04c6('0x33')],'UserId':_0x4b46a1['id'],'queue_name':_0x1f9ee9[_0x5a644a]['name'],'VoiceQueueId':_0x1f9ee9[_0x5a644a]['id'],'interface':_0x2813e7,'paused':_0x4b46a1[_0x04c6('0x96')]||![],'penalty':_0x1f9ee9[_0x5a644a]['UserVoiceQueue.penalty']||0x0});}return BPromise[_0x04c6('0x85')](_0x3d07dd,function(_0x9c43f3){return db[_0x04c6('0xd0')][_0x04c6('0xa7')](_0x9c43f3);});}}}})[_0x04c6('0x25')](function(){if(_0x4b46a1){return db[_0x04c6('0xef')][_0x04c6('0x40')]({'where':{'membername':_0x4b46a1[_0x04c6('0x33')],'exitAt':null}});}})[_0x04c6('0x25')](function(_0x334d36){if(_0x4b46a1){var _0x3a3a67=[];_0x334d36['forEach'](function(_0x35e565){_0x3a3a67[_0x04c6('0x3f')](_0x35e565['update']({'exitAt':moment()['format']('YYYY-MM-DD\x20HH:mm:ss')}));});return BPromise['all'](_0x3a3a67);}})['then'](function(){if(_0x4b46a1){var _0x48f4ef=[];var _0x140eae=[];var _0x5e94a7=utils['getChannels']();var _0x3a79df={'membername':_0x4b46a1[_0x04c6('0x33')],'interface':_0x2813e7,'enterAt':moment()[_0x04c6('0xe4')]('YYYY-MM-DD\x20HH:mm:ss'),'role':_0x4b46a1[_0x04c6('0x27')],'internal':_0x4b46a1[_0x04c6('0x5b')]};_0x5e94a7['forEach'](function(_0xb858dc){_0x48f4ef[_0x04c6('0x3f')](_[_0x04c6('0xc5')]({'channel':_0xb858dc,'type':'LOGIN','data1':_0x4ae92a['body'][_0x04c6('0xf0')],'data2':_0x2813e7},_0x3a79df));if(_0x4b46a1[_0x04c6('0x96')]){_0x140eae[_0x04c6('0x3f')](_[_0x04c6('0xc5')]({'channel':_0xb858dc,'type':_0x04c6('0xf1'),'data1':_0x04c6('0xf2')},_0x3a79df));}});return db[_0x04c6('0xef')][_0x04c6('0x81')](_0x48f4ef['concat'](_0x140eae),{'individualHooks':!![]});}})[_0x04c6('0x25')](function(){if(_0x4b46a1){return _0x4b46a1[_0x04c6('0x24')]({'online':!![],'lastLoginAt':moment()['format'](_0x04c6('0xf3')),'voicePause':_0x4b46a1['loginInPause']||![],'mailPause':_0x4b46a1[_0x04c6('0x96')]||![],'chatPause':_0x4b46a1[_0x04c6('0x96')]||![],'faxPause':_0x4b46a1['loginInPause']||![],'smsPause':_0x4b46a1[_0x04c6('0x96')]||![],'openchannelPause':_0x4b46a1['loginInPause']||![],'whatsappPause':_0x4b46a1[_0x04c6('0x96')]||![],'pauseType':_0x4b46a1['loginInPause']?_0x04c6('0xf2'):null,'interface':_0x2813e7,'lastPauseAt':moment()['format'](_0x04c6('0xf3'))});}})[_0x04c6('0x25')](function(_0x234479){if(_0x4ae92a['isMiddleware']){return _0x31bcf1();}else{return BPromise['resolve'](_0x234479)[_0x04c6('0x25')](respondWithResult(_0x530c28,null));}})[_0x04c6('0x1b')](handleError(_0x530c28,null));};exports[_0x04c6('0xf4')]=function(_0x163d9b,_0x1d83b5){var _0x1abb88;return db[_0x04c6('0x3b')][_0x04c6('0x32')]({'where':{'id':_0x163d9b[_0x04c6('0x4a')]['id'],'role':_0x04c6('0x2a')},'attributes':['id',_0x04c6('0x33'),_0x04c6('0x27')]})['then'](handleEntityNotFound(_0x1d83b5,null))[_0x04c6('0x25')](function(_0x4724ee){if(_0x4724ee){_0x1abb88=_0x4724ee;return db[_0x04c6('0xd0')][_0x04c6('0x26')]({'where':{'membername':_0x1abb88['name']},'individualHooks':!![]});}})['then'](function(){return db[_0x04c6('0xef')][_0x04c6('0x40')]({'where':{'membername':_0x1abb88[_0x04c6('0x33')],'exitAt':null}});})['then'](function(_0x50e40f){var _0x46cc4a=[];_0x50e40f['forEach'](function(_0x896d0a){_0x46cc4a['push'](_0x896d0a[_0x04c6('0x24')]({'exitAt':moment()[_0x04c6('0xe4')](_0x04c6('0xf3'))}));});return BPromise[_0x04c6('0x48')](_0x46cc4a);})[_0x04c6('0x25')](function(){return _0x1abb88[_0x04c6('0x24')]({'online':![],'voicePause':![],'mailPause':![],'chatPause':![],'faxPause':![],'smsPause':![],'openchannelPause':![],'whatsappPause':![],'interface':null});})['then'](respondWithResult(_0x1d83b5,null))[_0x04c6('0x1b')](handleError(_0x1d83b5,null));};exports[_0x04c6('0xf5')]=function(_0x515eec,_0x5016dd){var _0x46ef53;return db['UserVoiceQueueRt'][_0x04c6('0x24')]({'paused':0x1},{'where':{'UserId':_0x515eec[_0x04c6('0x4a')]['id']},'individualHooks':!![]})[_0x04c6('0x25')](function(){return db[_0x04c6('0x3b')]['find']({'where':{'id':_0x515eec[_0x04c6('0x4a')]['id'],'role':_0x04c6('0x2a')},'attributes':['id',_0x04c6('0x33'),'role','internal',_0x04c6('0x97')]});})[_0x04c6('0x25')](handleEntityNotFound(_0x5016dd,null))[_0x04c6('0x25')](function(_0x5c3548){if(_0x5c3548){_0x46ef53=_0x5c3548;return respondWithRpcPromise(_0x04c6('0xf6'),_0x04c6('0xf5'),{'id':_0x46ef53['id'],'name':_0x46ef53[_0x04c6('0x33')],'pause':!![]});}})[_0x04c6('0x25')](function(){if(_0x46ef53){return db[_0x04c6('0xef')][_0x04c6('0x40')]({'where':{'membername':_0x46ef53[_0x04c6('0x33')],'type':'PAUSE','exitAt':null}});}})['then'](function(_0x5da0fa){if(_0x5da0fa[_0x04c6('0x42')]){var _0x557c0a=moment()['format'](_0x04c6('0xf3'));for(var _0x4a4aaf=0x0,_0x20c1ab=_0x5da0fa[_0x04c6('0x42')];_0x4a4aaf<_0x20c1ab;_0x4a4aaf++){_0x5da0fa[_0x4a4aaf][_0x04c6('0xf7')]({'exitAt':_0x557c0a});}}})[_0x04c6('0x25')](function(){var _0x595646=[];var _0x3d9951=utils[_0x04c6('0xf8')]();_0x3d9951[_0x04c6('0xf9')](function(_0x54bdc6){_0x595646[_0x04c6('0x3f')]({'channel':_0x54bdc6,'membername':_0x46ef53['name'],'interface':_['isNil'](_0x46ef53[_0x04c6('0x97')])?util['format'](_0x04c6('0xa5'),_0x46ef53[_0x04c6('0x33')]):_0x46ef53[_0x04c6('0x97')],'type':_0x04c6('0xf1'),'enterAt':moment()[_0x04c6('0xe4')]('YYYY-MM-DD\x20HH:mm:ss'),'data1':_0x515eec[_0x04c6('0x56')][_0x04c6('0xfa')]||_0x04c6('0xfb'),'role':_0x46ef53[_0x04c6('0x27')],'internal':_0x46ef53[_0x04c6('0x5b')]});});return db[_0x04c6('0xef')]['bulkCreate'](_0x595646,{'individualHooks':!![]});})[_0x04c6('0x25')](function(){return _0x46ef53[_0x04c6('0x24')]({'voicePause':!![],'mailPause':!![],'chatPause':!![],'faxPause':!![],'smsPause':!![],'whatsappPause':!![],'openchannelPause':!![],'pauseType':_0x515eec['body'][_0x04c6('0xfa')]||_0x04c6('0xfb'),'lastPauseAt':moment()[_0x04c6('0xe4')]('YYYY-MM-DD\x20HH:mm:ss')});})[_0x04c6('0x25')](respondWithResult(_0x5016dd,null))[_0x04c6('0x1b')](handleError(_0x5016dd,null));};exports[_0x04c6('0xfc')]=function(_0x5c3e83,_0x35a35e){var _0x4637f0;return db[_0x04c6('0x3b')][_0x04c6('0x32')]({'where':{'id':_0x5c3e83['params']['id']},'attributes':['id','name',_0x04c6('0x27'),_0x04c6('0xa6'),_0x04c6('0xfd'),_0x04c6('0xfe'),_0x04c6('0xff'),_0x04c6('0x100'),'smsPause','whatsapppause',_0x04c6('0x101'),_0x04c6('0x102')]})[_0x04c6('0x25')](handleEntityNotFound(_0x35a35e,null))['then'](function(_0x2b0917){if(_0x2b0917){_0x4637f0=_0x2b0917;if(_0x5c3e83[_0x04c6('0x56')][_0x04c6('0x94')]&&!utils[_0x04c6('0x98')](_0x5c3e83[_0x04c6('0x56')][_0x04c6('0x94')])){throw new db['Sequelize'][(_0x04c6('0x8a'))](_0x04c6('0x99'));}switch(_0x5c3e83[_0x04c6('0x56')]['channel']){case _0x04c6('0xa2'):return respondWithRpcPromise('QueuePause',_0x04c6('0xfc'),{'id':_0x4637f0['id'],'name':_0x4637f0[_0x04c6('0x33')],'pause':![]})[_0x04c6('0x25')](function(){return db[_0x04c6('0xd0')][_0x04c6('0x24')]({'paused':0x0},{'where':{'UserId':_0x4637f0['id']},'individualHooks':!![]});})[_0x04c6('0x25')](function(){return db[_0x04c6('0xef')][_0x04c6('0x32')]({'where':{'channel':_0x5c3e83[_0x04c6('0x56')][_0x04c6('0x94')],'membername':_0x4637f0[_0x04c6('0x33')],'type':'PAUSE','exitAt':null}});})[_0x04c6('0x25')](function(_0x5a873a){if(_0x5a873a){return _0x5a873a['update']({'exitAt':moment()[_0x04c6('0xe4')]('YYYY-MM-DD\x20HH:mm:ss'),'data2':'manual'},{'individualHooks':!![]});}return null;})['then'](function(){return _0x4637f0[_0x04c6('0x24')]({'voicePause':![]});});case _0x04c6('0x45'):case _0x04c6('0x55'):case _0x04c6('0xb4'):case'sms':case _0x04c6('0x47'):case'openchannel':return db[_0x04c6('0xef')][_0x04c6('0x32')]({'where':{'channel':_0x5c3e83[_0x04c6('0x56')][_0x04c6('0x94')],'membername':_0x4637f0['name'],'type':'PAUSE','exitAt':null}})[_0x04c6('0x25')](function(_0x1d5d7b){if(_0x1d5d7b){return _0x1d5d7b[_0x04c6('0x24')]({'exitAt':moment()[_0x04c6('0xe4')](_0x04c6('0xf3')),'data2':_0x04c6('0x103')},{'individualHooks':!![]});}return null;})[_0x04c6('0x25')](function(){var _0x4575ed={};_['set'](_0x4575ed,util[_0x04c6('0xe4')](_0x04c6('0x104'),_0x5c3e83[_0x04c6('0x56')]['channel'],_0x04c6('0x105')),![]);return _0x4637f0[_0x04c6('0x24')](_0x4575ed);});default:return respondWithRpcPromise(_0x04c6('0xf6'),_0x04c6('0xfc'),{'id':_0x4637f0['id'],'name':_0x4637f0[_0x04c6('0x33')],'pause':![]})['then'](function(){return db[_0x04c6('0xd0')][_0x04c6('0x24')]({'paused':0x0},{'where':{'UserId':_0x4637f0['id']}});})['then'](function(){return db['MemberReport']['findAll']({'where':{'membername':_0x4637f0[_0x04c6('0x33')],'type':_0x04c6('0xf1'),'exitAt':null}});})[_0x04c6('0x25')](function(_0x9a335){var _0x432b31=[];_0x9a335['forEach'](function(_0x48d96d){_0x432b31[_0x04c6('0x3f')](_0x48d96d[_0x04c6('0x24')]({'exitAt':moment()[_0x04c6('0xe4')](_0x04c6('0xf3')),'data2':_0x04c6('0x103')}));});return BPromise[_0x04c6('0x48')](_0x432b31);})[_0x04c6('0x25')](function(){return _0x4637f0[_0x04c6('0x24')]({'voicePause':![],'mailPause':![],'chatPause':![],'faxPause':![],'smsPause':![],'whatsappPause':![],'openchannelPause':![]});});}}})[_0x04c6('0x25')](respondWithResult(_0x35a35e,null))['catch'](handleError(_0x35a35e,null));};exports[_0x04c6('0x106')]=function(_0x40ec66,_0x2f4d57){var _0x272da1={};var _0x749a94={};var _0x25ab73;var _0xaf01e4;return db[_0x04c6('0x3b')][_0x04c6('0x90')]({'where':{'id':_0x40ec66[_0x04c6('0x4a')]['id']}})[_0x04c6('0x25')](handleEntityNotFound(_0x2f4d57,null))[_0x04c6('0x25')](function(_0x4a1524){if(_0x4a1524){_0x25ab73=_0x4a1524;_0x749a94['model']=_[_0x04c6('0x4c')](db['Team']['rawAttributes']);_0x749a94[_0x04c6('0x3c')]=_[_0x04c6('0x4c')](_0x40ec66[_0x04c6('0x3c')]);_0x749a94[_0x04c6('0xc3')]=_[_0x04c6('0x4e')](_0x749a94[_0x04c6('0x4f')],_0x749a94[_0x04c6('0x3c')]);_0x272da1[_0x04c6('0x3e')]=_['intersection'](_0x749a94[_0x04c6('0x4f')],qs[_0x04c6('0x50')](_0x40ec66['query']['fields']));_0x272da1[_0x04c6('0x3e')]=_0x272da1[_0x04c6('0x3e')]['length']?_0x272da1['attributes']:_0x749a94[_0x04c6('0x4f')];_0x272da1[_0x04c6('0xce')]=qs['sort'](_0x40ec66[_0x04c6('0x3c')]['sort']);_0x272da1[_0x04c6('0x3a')]=qs[_0x04c6('0xc3')](_[_0x04c6('0xcf')](_0x40ec66[_0x04c6('0x3c')],_0x749a94['filters']));if(_0x40ec66[_0x04c6('0x3c')]['filter']){_0x272da1[_0x04c6('0x3a')]=_['merge'](_0x272da1['where'],{'$or':_['map'](_0x272da1[_0x04c6('0x3e')],function(_0x34f13c){var _0x3d1240={};_0x3d1240[_0x34f13c]={'$like':'%'+_0x40ec66[_0x04c6('0x3c')][_0x04c6('0x2d')]+'%'};return _0x3d1240;})});}_0x272da1=_[_0x04c6('0xc5')]({},_0x272da1,_0x40ec66[_0x04c6('0x52')]);return _0x25ab73[_0x04c6('0x106')](_0x272da1);}})['then'](function(_0x2658f6){if(_0x2658f6){_0xaf01e4=_0x2658f6['length'];if(!_0x40ec66[_0x04c6('0x3c')]['hasOwnProperty'](_0x04c6('0xcb'))){_0x272da1[_0x04c6('0x20')]=qs['limit'](_0x40ec66[_0x04c6('0x3c')][_0x04c6('0x20')]);_0x272da1['offset']=qs[_0x04c6('0x1e')](_0x40ec66[_0x04c6('0x3c')][_0x04c6('0x1e')]);}return _0x25ab73[_0x04c6('0x106')](_0x272da1);}})[_0x04c6('0x25')](function(_0x574ef5){if(_0x574ef5){return _0x574ef5?{'count':_0xaf01e4,'rows':_0x574ef5}:null;}})[_0x04c6('0x25')](respondWithResult(_0x2f4d57,null))[_0x04c6('0x1b')](handleError(_0x2f4d57,null));};exports[_0x04c6('0x107')]=function(_0x4cfd38,_0x2205f2){return db[_0x04c6('0x3b')][_0x04c6('0x32')]({'where':{'id':_0x4cfd38[_0x04c6('0x4a')]['id']}})[_0x04c6('0x25')](handleEntityNotFound(_0x2205f2,null))[_0x04c6('0x25')](function(_0x65ed79){if(_0x65ed79){var _0x4a09f0=_0x65ed79[_0x04c6('0xa4')]({'plain':!![]});return _0x65ed79[_0x04c6('0x107')](_0x4cfd38['body'][_0x04c6('0x59')],_['omit'](_0x4cfd38[_0x04c6('0x56')],[_0x04c6('0x59'),'id'])||{})[_0x04c6('0x25')](function(){for(var _0x3f1b83=0x0;_0x3f1b83<_0x4cfd38[_0x04c6('0x56')][_0x04c6('0x59')][_0x04c6('0x42')];_0x3f1b83++){var _0x40226e=[];var _0x1de9ca={};db['Team']['findOne']({'where':{'id':_0x4cfd38[_0x04c6('0x56')][_0x04c6('0x59')][_0x3f1b83]}})[_0x04c6('0x25')](function(_0x127a60){_0x1de9ca=_0x127a60['dataValues'];_0x40226e[_0x04c6('0x3f')](_0x127a60[_0x04c6('0x108')]()['then'](function(_0x408eb5){for(var _0x8d995a=0x0;_0x8d995a<_0x408eb5[_0x04c6('0x42')];_0x8d995a++){_0x408eb5[_0x8d995a][_0x04c6('0x109')](_0x04c6('0x94'),'Voice');}return _0x408eb5;}));_0x40226e[_0x04c6('0x3f')](_0x127a60[_0x04c6('0x10a')]()[_0x04c6('0x25')](function(_0x23dc08){for(var _0x261357=0x0;_0x261357<_0x23dc08[_0x04c6('0x42')];_0x261357++){_0x23dc08[_0x261357][_0x04c6('0x109')](_0x04c6('0x94'),'Chat');}return _0x23dc08;}));_0x40226e[_0x04c6('0x3f')](_0x127a60[_0x04c6('0x10b')]()[_0x04c6('0x25')](function(_0x3557d9){for(var _0x3de8fb=0x0;_0x3de8fb<_0x3557d9['length'];_0x3de8fb++){_0x3557d9[_0x3de8fb]['setDataValue'](_0x04c6('0x94'),'Mail');}return _0x3557d9;}));_0x40226e[_0x04c6('0x3f')](_0x127a60[_0x04c6('0x10c')]()[_0x04c6('0x25')](function(_0x4c25aa){for(var _0x44f846=0x0;_0x44f846<_0x4c25aa[_0x04c6('0x42')];_0x44f846++){_0x4c25aa[_0x44f846][_0x04c6('0x109')](_0x04c6('0x94'),'Sms');}return _0x4c25aa;}));_0x40226e[_0x04c6('0x3f')](_0x127a60[_0x04c6('0x10d')]()[_0x04c6('0x25')](function(_0x563282){for(var _0x53688d=0x0;_0x53688d<_0x563282['length'];_0x53688d++){_0x563282[_0x53688d]['setDataValue'](_0x04c6('0x94'),_0x04c6('0x10e'));}return _0x563282;}));_0x40226e[_0x04c6('0x3f')](_0x127a60[_0x04c6('0x10f')]()[_0x04c6('0x25')](function(_0x384df4){for(var _0x397ade=0x0;_0x397ade<_0x384df4[_0x04c6('0x42')];_0x397ade++){_0x384df4[_0x397ade]['setDataValue'](_0x04c6('0x94'),_0x04c6('0x110'));}return _0x384df4;}));_0x40226e[_0x04c6('0x3f')](_0x127a60[_0x04c6('0x111')]()[_0x04c6('0x25')](function(_0x21a086){for(var _0x4310f3=0x0;_0x4310f3<_0x21a086[_0x04c6('0x42')];_0x4310f3++){_0x21a086[_0x4310f3][_0x04c6('0x109')](_0x04c6('0x94'),_0x04c6('0x112'));}return _0x21a086;}));return BPromise[_0x04c6('0x48')](_0x40226e);})['then'](function(_0x55ff8e){var _0x251f5e=_[_0x04c6('0x113')](_0x55ff8e);_0x40226e=[];return db[_0x04c6('0x63')][_0x04c6('0x114')](function(_0x4d7416){for(var _0x1e919c=0x0;_0x1e919c<_0x251f5e[_0x04c6('0x42')];_0x1e919c++){_0x40226e[_0x04c6('0x3f')](_0x251f5e[_0x1e919c][_0x04c6('0x115')](_0x4a09f0['id']),{'transaction':_0x4d7416});}return BPromise[_0x04c6('0x48')](_0x40226e)['then'](function(){if(_0x4a09f0[_0x04c6('0x95')]){return BPromise[_0x04c6('0x85')](_['filter'](_0x251f5e,function(_0x4bd411){return _0x4bd411[_0x04c6('0x116')](_0x04c6('0x94'))===_0x04c6('0x117');}),function(_0x16dbe9){return db[_0x04c6('0xd0')][_0x04c6('0xa7')]({'membername':_0x4a09f0[_0x04c6('0x33')],'UserId':_0x4a09f0['id'],'queue_name':_0x16dbe9['name'],'VoiceQueueId':_0x16dbe9['id'],'interface':_[_0x04c6('0x61')](_0x4a09f0[_0x04c6('0x97')])?util[_0x04c6('0xe4')](_0x04c6('0xa5'),_0x4a09f0[_0x04c6('0x33')]):_0x4a09f0[_0x04c6('0x97')],'paused':_0x4a09f0[_0x04c6('0xa6')]||![],'penalty':_0x4a09f0[_0x04c6('0x9e')]},{'transaction':_0x4d7416});});}else{return;}})[_0x04c6('0x25')](function(){for(var _0x351e46=0x0;_0x351e46<_0x251f5e[_0x04c6('0x42')];_0x351e46++){var _0x54d462=_0x251f5e[_0x351e46][_0x04c6('0x116')](_0x04c6('0x94'));var _0x31a401=_0x54d462+'QueueId';socket[_0x04c6('0xa0')](_0x04c6('0x77')+_0x54d462+_0x04c6('0xa1'),{'UserId':_0x4a09f0['id'],['queueField']:_0x251f5e[_0x351e46]['id']});}});});})['then'](function(){db[_0x04c6('0x118')]['findOne']({'where':{'teamId':_0x1de9ca['id']}})[_0x04c6('0x25')](function(_0x5f530a){if(_0x5f530a){db[_0x04c6('0x119')][_0x04c6('0x76')]({'UserId':_0x4cfd38['params']['id'],'VoicePrefixId':_0x5f530a['VoicePrefixId']});}});});}});}})[_0x04c6('0x25')](respondWithStatusCode(_0x2205f2,null))['catch'](handleError(_0x2205f2,null));};exports['removeTeams']=function(_0x3cd37a,_0x5de073){return db[_0x04c6('0x3b')][_0x04c6('0x90')]({'where':{'id':_0x3cd37a[_0x04c6('0x4a')]['id']}})[_0x04c6('0x25')](handleEntityNotFound(_0x5de073,null))[_0x04c6('0x25')](function(_0x2da2aa){if(_0x2da2aa){var _0x137099=_0x2da2aa[_0x04c6('0xa4')]({'plain':!![]});var _0x496ec1=_0x3cd37a['query']['ids'];return _0x2da2aa[_0x04c6('0x11a')](_0x496ec1)[_0x04c6('0x25')](function(){for(var _0x215f1d=0x0;_0x215f1d<_0x496ec1[_0x04c6('0x42')];_0x215f1d++){var _0x7ea927=[];var _0x500d16={};db['Team'][_0x04c6('0x90')]({'where':{'id':_0x496ec1[_0x215f1d]}})[_0x04c6('0x25')](function(_0x4455a6){_0x500d16=_0x4455a6[_0x04c6('0x43')];_0x7ea927['push'](_0x4455a6[_0x04c6('0x108')]()['then'](function(_0x12a111){for(var _0x4b013d=0x0;_0x4b013d<_0x12a111[_0x04c6('0x42')];_0x4b013d++){_0x12a111[_0x4b013d]['setDataValue']('channel','Voice');}return _0x12a111;}));_0x7ea927[_0x04c6('0x3f')](_0x4455a6[_0x04c6('0x10a')]()[_0x04c6('0x25')](function(_0x51ea16){for(var _0x577fc3=0x0;_0x577fc3<_0x51ea16[_0x04c6('0x42')];_0x577fc3++){_0x51ea16[_0x577fc3][_0x04c6('0x109')](_0x04c6('0x94'),_0x04c6('0x11b'));}return _0x51ea16;}));_0x7ea927[_0x04c6('0x3f')](_0x4455a6[_0x04c6('0x10b')]()[_0x04c6('0x25')](function(_0x193789){for(var _0x542d95=0x0;_0x542d95<_0x193789[_0x04c6('0x42')];_0x542d95++){_0x193789[_0x542d95][_0x04c6('0x109')](_0x04c6('0x94'),_0x04c6('0x11c'));}return _0x193789;}));_0x7ea927[_0x04c6('0x3f')](_0x4455a6[_0x04c6('0x10c')]()['then'](function(_0x27d934){for(var _0x1c62d5=0x0;_0x1c62d5<_0x27d934[_0x04c6('0x42')];_0x1c62d5++){_0x27d934[_0x1c62d5]['setDataValue'](_0x04c6('0x94'),_0x04c6('0x11d'));}return _0x27d934;}));_0x7ea927[_0x04c6('0x3f')](_0x4455a6[_0x04c6('0x10d')]()[_0x04c6('0x25')](function(_0x4f6c3b){for(var _0x1dce72=0x0;_0x1dce72<_0x4f6c3b[_0x04c6('0x42')];_0x1dce72++){_0x4f6c3b[_0x1dce72][_0x04c6('0x109')]('channel','Whatsapp');}return _0x4f6c3b;}));_0x7ea927[_0x04c6('0x3f')](_0x4455a6[_0x04c6('0x10f')]()['then'](function(_0x47c9d5){for(var _0x3d1eb9=0x0;_0x3d1eb9<_0x47c9d5[_0x04c6('0x42')];_0x3d1eb9++){_0x47c9d5[_0x3d1eb9][_0x04c6('0x109')](_0x04c6('0x94'),'Fax');}return _0x47c9d5;}));_0x7ea927['push'](_0x4455a6['getOpenchannelQueues']()[_0x04c6('0x25')](function(_0x293f03){for(var _0x36d285=0x0;_0x36d285<_0x293f03[_0x04c6('0x42')];_0x36d285++){_0x293f03[_0x36d285][_0x04c6('0x109')]('channel',_0x04c6('0x112'));}return _0x293f03;}));return BPromise['all'](_0x7ea927);})[_0x04c6('0x25')](function(_0xefcf3e){var _0x2e6480=_[_0x04c6('0x113')](_0xefcf3e);_0x7ea927=[];return db[_0x04c6('0x63')][_0x04c6('0x114')](function(_0x23087d){for(var _0x17c4eb=0x0;_0x17c4eb<_0x2e6480[_0x04c6('0x42')];_0x17c4eb++){_0x7ea927[_0x04c6('0x3f')](_0x2e6480[_0x17c4eb][_0x04c6('0x11e')](_0x137099['id']),{'transaction':_0x23087d});}return BPromise['all'](_0x7ea927)[_0x04c6('0x25')](function(){if(_0x137099['online']){return BPromise[_0x04c6('0x85')](_[_0x04c6('0x2d')](_0x2e6480,function(_0xc2e557){return _0xc2e557[_0x04c6('0x116')](_0x04c6('0x94'))===_0x04c6('0x117');}),function(_0x4a7d8d){return db['UserVoiceQueueRt'][_0x04c6('0x26')]({'where':{'VoiceQueueId':_0x4a7d8d['id'],'UserId':_0x137099['id']},'transaction':_0x23087d});});}else{return;}})[_0x04c6('0x25')](function(){db['TeamVoicePrefix'][_0x04c6('0x90')]({'where':{'teamId':_0x500d16['id']}})[_0x04c6('0x25')](function(_0x3b325d){if(_0x3b325d){return db[_0x04c6('0x119')][_0x04c6('0x26')]({'where':{'UserId':_0x137099['id'],'VoicePrefixId':_0x3b325d[_0x04c6('0x43')]['VoicePrefixId']}});}});})[_0x04c6('0x25')](function(){for(var _0x2a1f87=0x0;_0x2a1f87<_0x2e6480[_0x04c6('0x42')];_0x2a1f87++){var _0x50367d=_0x2e6480[_0x2a1f87][_0x04c6('0x116')](_0x04c6('0x94'));var _0x163616=_0x50367d+'QueueId';socket[_0x04c6('0xa0')](_0x04c6('0x77')+_0x50367d+_0x04c6('0x11f'),{'UserId':_0x137099['id'],['queueField']:_0x2e6480[_0x2a1f87]['id']});}});});});}});}})[_0x04c6('0x25')](respondWithStatusCode(_0x5de073,null))[_0x04c6('0x1b')](handleError(_0x5de073,null));};exports[_0x04c6('0x120')]=function(_0xd5652c,_0x480e6f){var _0x278584={};var _0x51e29e={};var _0x58c0b9;var _0x11e09d;return db['User']['findOne']({'where':{'id':_0xd5652c[_0x04c6('0x4a')]['id']}})[_0x04c6('0x25')](handleEntityNotFound(_0x480e6f,null))[_0x04c6('0x25')](function(_0x74d818){if(_0x74d818){_0x58c0b9=_0x74d818;_0x51e29e[_0x04c6('0x4f')]=_[_0x04c6('0x4c')](db['CmList'][_0x04c6('0x36')]);_0x51e29e[_0x04c6('0x3c')]=_[_0x04c6('0x4c')](_0xd5652c[_0x04c6('0x3c')]);_0x51e29e[_0x04c6('0xc3')]=_['intersection'](_0x51e29e[_0x04c6('0x4f')],_0x51e29e[_0x04c6('0x3c')]);_0x278584[_0x04c6('0x3e')]=_[_0x04c6('0x4e')](_0x51e29e[_0x04c6('0x4f')],qs[_0x04c6('0x50')](_0xd5652c[_0x04c6('0x3c')][_0x04c6('0x50')]));_0x278584[_0x04c6('0x3e')]=_0x278584[_0x04c6('0x3e')][_0x04c6('0x42')]?_0x278584[_0x04c6('0x3e')]:_0x51e29e[_0x04c6('0x4f')];_0x278584['order']=qs[_0x04c6('0xc4')](_0xd5652c[_0x04c6('0x3c')][_0x04c6('0xc4')]);_0x278584['where']=qs['filters'](_[_0x04c6('0xcf')](_0xd5652c['query'],_0x51e29e['filters']));if(_0xd5652c['query'][_0x04c6('0x2d')]){_0x278584['where']=_[_0x04c6('0xc5')](_0x278584['where'],{'$or':_[_0x04c6('0x2f')](_0x278584[_0x04c6('0x3e')],function(_0x3be619){var _0x1b548d={};_0x1b548d[_0x3be619]={'$like':'%'+_0xd5652c[_0x04c6('0x3c')][_0x04c6('0x2d')]+'%'};return _0x1b548d;})});}_0x278584=_['merge']({},_0x278584,_0xd5652c[_0x04c6('0x52')]);return _0x58c0b9['getLists'](_0x278584);}})['then'](function(_0x19a46d){if(_0x19a46d){_0x11e09d=_0x19a46d[_0x04c6('0x42')];if(!_0xd5652c[_0x04c6('0x3c')]['hasOwnProperty'](_0x04c6('0xcb'))){_0x278584[_0x04c6('0x20')]=qs[_0x04c6('0x20')](_0xd5652c[_0x04c6('0x3c')][_0x04c6('0x20')]);_0x278584['offset']=qs[_0x04c6('0x1e')](_0xd5652c[_0x04c6('0x3c')][_0x04c6('0x1e')]);}return _0x58c0b9[_0x04c6('0x120')](_0x278584);}})[_0x04c6('0x25')](function(_0x1d9f41){if(_0x1d9f41){return _0x1d9f41?{'count':_0x11e09d,'rows':_0x1d9f41}:null;}})['then'](respondWithResult(_0x480e6f,null))['catch'](handleError(_0x480e6f,null));};exports[_0x04c6('0x121')]=function(_0x4702ed,_0x4d33ab){var _0x5cf2e1={};var _0x30245f={};var _0x13d07e;var _0x18883a;return db[_0x04c6('0x3b')][_0x04c6('0x90')]({'where':{'id':_0x4702ed[_0x04c6('0x4a')]['id']}})['then'](handleEntityNotFound(_0x4d33ab,null))[_0x04c6('0x25')](function(_0x28fa74){if(_0x28fa74){_0x13d07e=_0x28fa74;_0x30245f[_0x04c6('0x4f')]=_['keys'](db[_0x04c6('0x3b')]['rawAttributes']);_0x30245f[_0x04c6('0x3c')]=_[_0x04c6('0x4c')](_0x4702ed[_0x04c6('0x3c')]);_0x30245f[_0x04c6('0xc3')]=_['intersection'](_0x30245f[_0x04c6('0x4f')],_0x30245f[_0x04c6('0x3c')]);_0x5cf2e1['attributes']=_[_0x04c6('0x4e')](_0x30245f[_0x04c6('0x4f')],qs[_0x04c6('0x50')](_0x4702ed['query'][_0x04c6('0x50')]));_0x5cf2e1[_0x04c6('0x3e')]=_0x5cf2e1[_0x04c6('0x3e')][_0x04c6('0x42')]?_0x5cf2e1[_0x04c6('0x3e')]:_0x30245f[_0x04c6('0x4f')];_0x5cf2e1[_0x04c6('0xce')]=qs[_0x04c6('0xc4')](_0x4702ed[_0x04c6('0x3c')]['sort']);_0x5cf2e1[_0x04c6('0x3a')]=qs[_0x04c6('0xc3')](_[_0x04c6('0xcf')](_0x4702ed[_0x04c6('0x3c')],_0x30245f[_0x04c6('0xc3')]));if(_0x4702ed[_0x04c6('0x3c')][_0x04c6('0x2d')]){_0x5cf2e1[_0x04c6('0x3a')]=_['merge'](_0x5cf2e1['where'],{'$or':_['map'](_0x5cf2e1[_0x04c6('0x3e')],function(_0x14004b){var _0x65c68f={};_0x65c68f[_0x14004b]={'$like':'%'+_0x4702ed[_0x04c6('0x3c')][_0x04c6('0x2d')]+'%'};return _0x65c68f;})});}_0x5cf2e1[_0x04c6('0x4f')]=db[_0x04c6('0x3b')];_0x5cf2e1['as']=_0x04c6('0x29');_0x5cf2e1=_['merge']({},_0x5cf2e1,_0x4702ed[_0x04c6('0x52')]);return _0x13d07e[_0x04c6('0x108')]({'include':[_0x5cf2e1]});}})[_0x04c6('0x25')](function(_0x2931a3){if(_0x2931a3){var _0x14da05={},_0x2fc7aa=[],_0x23a515=0x0;for(var _0xb2e4a1=0x0;_0xb2e4a1<_0x2931a3['length'];_0xb2e4a1+=0x1){for(var _0x5da4de=0x0,_0x4a812e;_0x5da4de<_0x2931a3[_0xb2e4a1][_0x04c6('0x29')][_0x04c6('0x42')];_0x5da4de+=0x1){_0x4a812e=_0x2931a3[_0xb2e4a1][_0x04c6('0x29')][_0x5da4de][_0x04c6('0xa4')]({'plain':!![]});_0x14da05[_0x4a812e['id']]=_0x4a812e;}}_0x14da05=_[_0x04c6('0x122')](_0x14da05);for(var _0x268cfe=qs[_0x04c6('0x1e')](_0x4702ed[_0x04c6('0x3c')][_0x04c6('0x1e')]);_0x268cfe<_0x14da05['length']&&_0x2fc7aa['length']<qs[_0x04c6('0x20')](_0x4702ed['query'][_0x04c6('0x20')]);_0x268cfe+=0x1){if(_0x14da05[_0x268cfe]){_0x2fc7aa[_0x04c6('0x3f')](_0x14da05[_0x268cfe]);}}return{'count':_0x14da05[_0x04c6('0x42')],'rows':_0x2fc7aa};}})[_0x04c6('0x25')](respondWithResult(_0x4d33ab,null))[_0x04c6('0x1b')](handleError(_0x4d33ab,null));};exports[_0x04c6('0x26')]=function(_0x1f0f92,_0x228b58){if(_0x1f0f92['user']['id']==_0x1f0f92[_0x04c6('0x4a')]['id']){return _0x228b58[_0x04c6('0x1c')](0x1f4)[_0x04c6('0x35')]({'message':_0x04c6('0x123')});}return db[_0x04c6('0x3b')][_0x04c6('0x32')]({'where':{'id':_0x1f0f92[_0x04c6('0x4a')]['id']}})[_0x04c6('0x25')](handleEntityNotFound(_0x228b58,null))['then'](removeEntity(_0x228b58,null))[_0x04c6('0x1b')](handleError(_0x228b58,null));};exports['addChatInteractions']=function(_0x123446,_0x3bcc2a){return db[_0x04c6('0x3b')][_0x04c6('0x32')]({'where':{'id':_0x123446[_0x04c6('0x4a')]['id']}})[_0x04c6('0x25')](handleEntityNotFound(_0x3bcc2a,null))[_0x04c6('0x25')](function(_0x5296ab){if(_0x5296ab){return _0x5296ab[_0x04c6('0x124')](_0x123446[_0x04c6('0x56')]['ids'],_[_0x04c6('0x5a')](_0x123446[_0x04c6('0x56')],[_0x04c6('0x59'),'id'])||{})[_0x04c6('0x125')](function(){for(var _0x105a2d=0x0;_0x105a2d<_0x123446[_0x04c6('0x56')][_0x04c6('0x59')][_0x04c6('0x42')];_0x105a2d+=0x1){socket['emit'](_0x04c6('0x126'),{'ChatInteractionId':Number(_0x123446['body'][_0x04c6('0x59')][_0x105a2d]),'UserId':Number(_0x123446['params']['id'])});}return _0x123446['body'][_0x04c6('0x59')];});}})[_0x04c6('0x25')](respondWithResult(_0x3bcc2a,null))[_0x04c6('0x1b')](handleError(_0x3bcc2a,null));};exports[_0x04c6('0x127')]=function(_0x46bcaa,_0x509f5b){return db[_0x04c6('0x3b')]['find']({'where':{'id':_0x46bcaa[_0x04c6('0x4a')]['id']}})[_0x04c6('0x25')](handleEntityNotFound(_0x509f5b,null))[_0x04c6('0x25')](function(_0x6f4cc9){if(_0x6f4cc9){return _0x6f4cc9[_0x04c6('0x127')](_0x46bcaa[_0x04c6('0x3c')][_0x04c6('0x59')])[_0x04c6('0x25')](function(){if(_[_0x04c6('0xa9')](_0x46bcaa[_0x04c6('0x3c')][_0x04c6('0x59')])){for(var _0x1b9fe1=0x0;_0x1b9fe1<_0x46bcaa[_0x04c6('0x3c')][_0x04c6('0x59')]['length'];_0x1b9fe1+=0x1){socket[_0x04c6('0xa0')]('user_has_chat_interactions:remove',{'ChatInteractionId':Number(_0x46bcaa['query'][_0x04c6('0x59')][_0x1b9fe1]),'UserId':Number(_0x46bcaa[_0x04c6('0x4a')]['id'])});}}else{socket['emit'](_0x04c6('0x128'),{'ChatInteractionId':Number(_0x46bcaa[_0x04c6('0x3c')][_0x04c6('0x59')]),'UserId':Number(_0x46bcaa[_0x04c6('0x4a')]['id'])});}});}})[_0x04c6('0x25')](respondWithStatusCode(_0x509f5b,null))['catch'](handleError(_0x509f5b,null));};exports[_0x04c6('0x129')]=function(_0x1e646b,_0x224e4c){return db[_0x04c6('0x3b')]['find']({'where':{'id':_0x1e646b['params']['id']}})[_0x04c6('0x25')](handleEntityNotFound(_0x224e4c,null))[_0x04c6('0x25')](function(_0x43edf2){if(_0x43edf2){return _0x43edf2[_0x04c6('0x129')](_0x1e646b[_0x04c6('0x56')][_0x04c6('0x59')],_[_0x04c6('0x5a')](_0x1e646b[_0x04c6('0x56')],['ids','id'])||{})[_0x04c6('0x125')](function(){for(var _0x3dc7bd=0x0;_0x3dc7bd<_0x1e646b[_0x04c6('0x56')][_0x04c6('0x59')][_0x04c6('0x42')];_0x3dc7bd+=0x1){socket[_0x04c6('0xa0')](_0x04c6('0x12a'),{'MailInteractionId':Number(_0x1e646b[_0x04c6('0x56')][_0x04c6('0x59')][_0x3dc7bd]),'UserId':Number(_0x1e646b[_0x04c6('0x4a')]['id'])});}return _0x1e646b[_0x04c6('0x56')]['ids'];});}})[_0x04c6('0x25')](respondWithResult(_0x224e4c,null))[_0x04c6('0x1b')](handleError(_0x224e4c,null));};exports['removeMailInteractions']=function(_0x46ec5e,_0x37d524){return db[_0x04c6('0x3b')]['find']({'where':{'id':_0x46ec5e[_0x04c6('0x4a')]['id']}})[_0x04c6('0x25')](handleEntityNotFound(_0x37d524,null))[_0x04c6('0x25')](function(_0x52899a){if(_0x52899a){return _0x52899a[_0x04c6('0x12b')](_0x46ec5e[_0x04c6('0x3c')][_0x04c6('0x59')])['then'](function(){if(_[_0x04c6('0xa9')](_0x46ec5e[_0x04c6('0x3c')][_0x04c6('0x59')])){for(var _0x52ef80=0x0;_0x52ef80<_0x46ec5e[_0x04c6('0x3c')][_0x04c6('0x59')][_0x04c6('0x42')];_0x52ef80+=0x1){socket[_0x04c6('0xa0')](_0x04c6('0x12c'),{'MailInteractionId':Number(_0x46ec5e[_0x04c6('0x3c')][_0x04c6('0x59')][_0x52ef80]),'UserId':Number(_0x46ec5e[_0x04c6('0x4a')]['id'])});}}else{socket[_0x04c6('0xa0')](_0x04c6('0x12c'),{'MailInteractionId':Number(_0x46ec5e['query'][_0x04c6('0x59')]),'UserId':Number(_0x46ec5e['params']['id'])});}});}})[_0x04c6('0x25')](respondWithStatusCode(_0x37d524,null))['catch'](handleError(_0x37d524,null));};exports['addFaxInteractions']=function(_0x1b57e4,_0x3e8a59){return db[_0x04c6('0x3b')][_0x04c6('0x32')]({'where':{'id':_0x1b57e4[_0x04c6('0x4a')]['id']}})['then'](handleEntityNotFound(_0x3e8a59,null))['then'](function(_0x358c72){if(_0x358c72){return _0x358c72['addFaxInteractions'](_0x1b57e4[_0x04c6('0x56')][_0x04c6('0x59')],_['omit'](_0x1b57e4[_0x04c6('0x56')],[_0x04c6('0x59'),'id'])||{})[_0x04c6('0x125')](function(){for(var _0xc9f8d4=0x0;_0xc9f8d4<_0x1b57e4['body'][_0x04c6('0x59')]['length'];_0xc9f8d4+=0x1){socket[_0x04c6('0xa0')]('user_has_fax_interactions:save',{'FaxInteractionId':Number(_0x1b57e4[_0x04c6('0x56')][_0x04c6('0x59')][_0xc9f8d4]),'UserId':Number(_0x1b57e4['params']['id'])});}return _0x1b57e4[_0x04c6('0x56')][_0x04c6('0x59')];});}})['then'](respondWithResult(_0x3e8a59,null))[_0x04c6('0x1b')](handleError(_0x3e8a59,null));};exports[_0x04c6('0x12d')]=function(_0x1b8b32,_0x4313eb){return db['User']['find']({'where':{'id':_0x1b8b32[_0x04c6('0x4a')]['id']}})['then'](handleEntityNotFound(_0x4313eb,null))[_0x04c6('0x25')](function(_0x4b2ec3){if(_0x4b2ec3){return _0x4b2ec3['removeFaxInteractions'](_0x1b8b32[_0x04c6('0x3c')][_0x04c6('0x59')])[_0x04c6('0x25')](function(){if(_[_0x04c6('0xa9')](_0x1b8b32['query'][_0x04c6('0x59')])){for(var _0x3dbc0a=0x0;_0x3dbc0a<_0x1b8b32[_0x04c6('0x3c')]['ids'][_0x04c6('0x42')];_0x3dbc0a+=0x1){socket[_0x04c6('0xa0')](_0x04c6('0x12e'),{'FaxInteractionId':Number(_0x1b8b32[_0x04c6('0x3c')][_0x04c6('0x59')][_0x3dbc0a]),'UserId':Number(_0x1b8b32[_0x04c6('0x4a')]['id'])});}}else{socket[_0x04c6('0xa0')](_0x04c6('0x12e'),{'FaxInteractionId':Number(_0x1b8b32['query'][_0x04c6('0x59')]),'UserId':Number(_0x1b8b32[_0x04c6('0x4a')]['id'])});}});}})[_0x04c6('0x25')](respondWithStatusCode(_0x4313eb,null))['catch'](handleError(_0x4313eb,null));};exports[_0x04c6('0x12f')]=function(_0x49045e,_0x240d17){return db['User'][_0x04c6('0x32')]({'where':{'id':_0x49045e[_0x04c6('0x4a')]['id']}})[_0x04c6('0x25')](handleEntityNotFound(_0x240d17,null))['then'](function(_0x4088e2){if(_0x4088e2){return _0x4088e2['addSmsInteractions'](_0x49045e[_0x04c6('0x56')]['ids'],_[_0x04c6('0x5a')](_0x49045e[_0x04c6('0x56')],[_0x04c6('0x59'),'id'])||{})[_0x04c6('0x125')](function(){for(var _0x1b0116=0x0;_0x1b0116<_0x49045e['body'][_0x04c6('0x59')][_0x04c6('0x42')];_0x1b0116+=0x1){socket['emit'](_0x04c6('0x130'),{'SmsInteractionId':Number(_0x49045e[_0x04c6('0x56')][_0x04c6('0x59')][_0x1b0116]),'UserId':Number(_0x49045e['params']['id'])});}return _0x49045e['body'][_0x04c6('0x59')];});}})[_0x04c6('0x25')](respondWithResult(_0x240d17,null))[_0x04c6('0x1b')](handleError(_0x240d17,null));};exports['removeSmsInteractions']=function(_0x197b3a,_0x531cb9){return db['User'][_0x04c6('0x32')]({'where':{'id':_0x197b3a['params']['id']}})[_0x04c6('0x25')](handleEntityNotFound(_0x531cb9,null))[_0x04c6('0x25')](function(_0x2670ce){if(_0x2670ce){return _0x2670ce['removeSmsInteractions'](_0x197b3a[_0x04c6('0x3c')][_0x04c6('0x59')])[_0x04c6('0x25')](function(){if(_[_0x04c6('0xa9')](_0x197b3a[_0x04c6('0x3c')][_0x04c6('0x59')])){for(var _0x1091bb=0x0;_0x1091bb<_0x197b3a[_0x04c6('0x3c')][_0x04c6('0x59')][_0x04c6('0x42')];_0x1091bb+=0x1){socket[_0x04c6('0xa0')](_0x04c6('0x131'),{'SmsInteractionId':Number(_0x197b3a[_0x04c6('0x3c')][_0x04c6('0x59')][_0x1091bb]),'UserId':Number(_0x197b3a[_0x04c6('0x4a')]['id'])});}}else{socket['emit'](_0x04c6('0x131'),{'SmsInteractionId':Number(_0x197b3a[_0x04c6('0x3c')][_0x04c6('0x59')]),'UserId':Number(_0x197b3a['params']['id'])});}});}})['then'](respondWithStatusCode(_0x531cb9,null))[_0x04c6('0x1b')](handleError(_0x531cb9,null));};exports[_0x04c6('0x132')]=function(_0x4a3b7a,_0x3a6736){return db['User'][_0x04c6('0x32')]({'where':{'id':_0x4a3b7a[_0x04c6('0x4a')]['id']}})[_0x04c6('0x25')](handleEntityNotFound(_0x3a6736,null))[_0x04c6('0x25')](function(_0x563464){if(_0x563464){return _0x563464['addOpenchannelInteractions'](_0x4a3b7a['body'][_0x04c6('0x59')],_[_0x04c6('0x5a')](_0x4a3b7a[_0x04c6('0x56')],[_0x04c6('0x59'),'id'])||{})['spread'](function(){for(var _0xe62b08=0x0;_0xe62b08<_0x4a3b7a[_0x04c6('0x56')][_0x04c6('0x59')][_0x04c6('0x42')];_0xe62b08+=0x1){socket[_0x04c6('0xa0')]('user_has_openchannel_interactions:save',{'OpenchannelInteractionId':Number(_0x4a3b7a[_0x04c6('0x56')][_0x04c6('0x59')][_0xe62b08]),'UserId':Number(_0x4a3b7a[_0x04c6('0x4a')]['id'])});}return _0x4a3b7a['body'][_0x04c6('0x59')];});}})[_0x04c6('0x25')](respondWithResult(_0x3a6736,null))[_0x04c6('0x1b')](handleError(_0x3a6736,null));};exports[_0x04c6('0x133')]=function(_0x29275b,_0x38c816){return db['User'][_0x04c6('0x32')]({'where':{'id':_0x29275b[_0x04c6('0x4a')]['id']}})[_0x04c6('0x25')](handleEntityNotFound(_0x38c816,null))[_0x04c6('0x25')](function(_0x442929){if(_0x442929){return _0x442929[_0x04c6('0x133')](_0x29275b[_0x04c6('0x3c')][_0x04c6('0x59')])[_0x04c6('0x25')](function(){if(_[_0x04c6('0xa9')](_0x29275b['query'][_0x04c6('0x59')])){for(var _0x214f4a=0x0;_0x214f4a<_0x29275b[_0x04c6('0x3c')][_0x04c6('0x59')][_0x04c6('0x42')];_0x214f4a+=0x1){socket[_0x04c6('0xa0')](_0x04c6('0x134'),{'OpenchannelInteractionId':Number(_0x29275b['query'][_0x04c6('0x59')][_0x214f4a]),'UserId':Number(_0x29275b[_0x04c6('0x4a')]['id'])});}}else{socket[_0x04c6('0xa0')](_0x04c6('0x134'),{'OpenchannelInteractionId':Number(_0x29275b[_0x04c6('0x3c')][_0x04c6('0x59')]),'UserId':Number(_0x29275b[_0x04c6('0x4a')]['id'])});}});}})[_0x04c6('0x25')](respondWithStatusCode(_0x38c816,null))[_0x04c6('0x1b')](handleError(_0x38c816,null));};exports['addWhatsappInteractions']=function(_0x1db717,_0x4d3045){return db[_0x04c6('0x3b')][_0x04c6('0x32')]({'where':{'id':_0x1db717[_0x04c6('0x4a')]['id']}})[_0x04c6('0x25')](handleEntityNotFound(_0x4d3045,null))[_0x04c6('0x25')](function(_0x254d48){if(_0x254d48){return _0x254d48[_0x04c6('0x135')](_0x1db717[_0x04c6('0x56')]['ids'],_[_0x04c6('0x5a')](_0x1db717[_0x04c6('0x56')],[_0x04c6('0x59'),'id'])||{})['spread'](function(){for(var _0x1c4547=0x0;_0x1c4547<_0x1db717[_0x04c6('0x56')]['ids'][_0x04c6('0x42')];_0x1c4547+=0x1){socket[_0x04c6('0xa0')]('user_has_whatsapp_interactions:save',{'WhatsappInteractionId':Number(_0x1db717[_0x04c6('0x56')]['ids'][_0x1c4547]),'UserId':Number(_0x1db717[_0x04c6('0x4a')]['id'])});}return _0x1db717[_0x04c6('0x56')]['ids'];});}})[_0x04c6('0x25')](respondWithResult(_0x4d3045,null))[_0x04c6('0x1b')](handleError(_0x4d3045,null));};exports['removeWhatsappInteractions']=function(_0x8134c6,_0x292bd1){return db[_0x04c6('0x3b')]['find']({'where':{'id':_0x8134c6[_0x04c6('0x4a')]['id']}})[_0x04c6('0x25')](handleEntityNotFound(_0x292bd1,null))[_0x04c6('0x25')](function(_0x1ac0c6){if(_0x1ac0c6){return _0x1ac0c6[_0x04c6('0x136')](_0x8134c6['query'][_0x04c6('0x59')]);}})[_0x04c6('0x25')](respondWithStatusCode(_0x292bd1,null))[_0x04c6('0x1b')](handleError(_0x292bd1,null));};exports[_0x04c6('0x137')]=function(_0x489297,_0x2e6c16){var _0x327ceb={};var _0x200c74={};var _0x1219f5;var _0x2ddc5e;return db[_0x04c6('0x3b')]['findOne']({'where':{'id':_0x489297['params']['id']}})[_0x04c6('0x25')](handleEntityNotFound(_0x2e6c16,null))['then'](function(_0xe03110){if(_0xe03110){_0x1219f5=_0xe03110;_0x200c74[_0x04c6('0x4f')]=_[_0x04c6('0x4c')](db[_0x04c6('0x138')][_0x04c6('0x36')]);_0x200c74[_0x04c6('0x3c')]=_[_0x04c6('0x4c')](_0x489297[_0x04c6('0x3c')]);_0x200c74[_0x04c6('0xc3')]=_[_0x04c6('0x4e')](_0x200c74[_0x04c6('0x4f')],_0x200c74[_0x04c6('0x3c')]);_0x327ceb[_0x04c6('0x3e')]=_[_0x04c6('0x4e')](_0x200c74[_0x04c6('0x4f')],qs[_0x04c6('0x50')](_0x489297[_0x04c6('0x3c')][_0x04c6('0x50')]));_0x327ceb[_0x04c6('0x3e')]=_0x327ceb[_0x04c6('0x3e')]['length']?_0x327ceb[_0x04c6('0x3e')]:_0x200c74[_0x04c6('0x4f')];_0x327ceb[_0x04c6('0xce')]=qs[_0x04c6('0xc4')](_0x489297[_0x04c6('0x3c')]['sort']);_0x327ceb[_0x04c6('0x3a')]=qs['filters'](_['pick'](_0x489297[_0x04c6('0x3c')],_0x200c74[_0x04c6('0xc3')]));if(_0x489297[_0x04c6('0x3c')][_0x04c6('0x2d')]){_0x327ceb[_0x04c6('0x3a')]=_[_0x04c6('0xc5')](_0x327ceb['where'],{'$or':_['map'](_0x327ceb[_0x04c6('0x3e')],function(_0x35d2bb){var _0x28abec={};_0x28abec[_0x35d2bb]={'$like':'%'+_0x489297[_0x04c6('0x3c')][_0x04c6('0x2d')]+'%'};return _0x28abec;})});}_0x327ceb=_[_0x04c6('0xc5')]({},_0x327ceb,_0x489297[_0x04c6('0x52')]);return _0x1219f5['getVoicePrefixes'](_0x327ceb);}})[_0x04c6('0x25')](function(_0x53d0b5){if(_0x53d0b5){_0x2ddc5e=_0x53d0b5[_0x04c6('0x42')];if(!_0x489297[_0x04c6('0x3c')][_0x04c6('0xc6')](_0x04c6('0xcb'))){_0x327ceb[_0x04c6('0x20')]=qs[_0x04c6('0x20')](_0x489297[_0x04c6('0x3c')][_0x04c6('0x20')]);_0x327ceb[_0x04c6('0x1e')]=qs['offset'](_0x489297[_0x04c6('0x3c')][_0x04c6('0x1e')]);}return _0x1219f5[_0x04c6('0x137')](_0x327ceb);}})[_0x04c6('0x25')](function(_0x28a7d2){if(_0x28a7d2){return _0x28a7d2?{'count':_0x2ddc5e,'rows':_0x28a7d2}:null;}})[_0x04c6('0x25')](respondWithResult(_0x2e6c16,null))[_0x04c6('0x1b')](handleError(_0x2e6c16,null));};exports[_0x04c6('0x139')]=function(_0x2d337e,_0x1512e3){var _0x3d1548={};var _0x343f52={};var _0x45cad2;var _0xa40fc9;return db[_0x04c6('0x3b')][_0x04c6('0x90')]({'where':{'id':_0x2d337e['params']['id']}})[_0x04c6('0x25')](handleEntityNotFound(_0x1512e3,null))['then'](function(_0x1cf542){if(_0x1cf542){_0x45cad2=_0x1cf542;_0x343f52[_0x04c6('0x4f')]=_[_0x04c6('0x4c')](db['FaxAccount'][_0x04c6('0x36')]);_0x343f52['query']=_[_0x04c6('0x4c')](_0x2d337e['query']);_0x343f52[_0x04c6('0xc3')]=_[_0x04c6('0x4e')](_0x343f52[_0x04c6('0x4f')],_0x343f52['query']);_0x3d1548[_0x04c6('0x3e')]=_['intersection'](_0x343f52[_0x04c6('0x4f')],qs['fields'](_0x2d337e[_0x04c6('0x3c')]['fields']));_0x3d1548[_0x04c6('0x3e')]=_0x3d1548[_0x04c6('0x3e')][_0x04c6('0x42')]?_0x3d1548['attributes']:_0x343f52[_0x04c6('0x4f')];_0x3d1548['order']=qs['sort'](_0x2d337e[_0x04c6('0x3c')][_0x04c6('0xc4')]);_0x3d1548[_0x04c6('0x3a')]=qs['filters'](_[_0x04c6('0xcf')](_0x2d337e['query'],_0x343f52[_0x04c6('0xc3')]));if(_0x2d337e['query'][_0x04c6('0x2d')]){_0x3d1548[_0x04c6('0x3a')]=_[_0x04c6('0xc5')](_0x3d1548[_0x04c6('0x3a')],{'$or':_[_0x04c6('0x2f')](_0x3d1548['attributes'],function(_0x2ee15b){var _0x4351d8={};_0x4351d8[_0x2ee15b]={'$like':'%'+_0x2d337e[_0x04c6('0x3c')][_0x04c6('0x2d')]+'%'};return _0x4351d8;})});}_0x3d1548=_[_0x04c6('0xc5')]({},_0x3d1548,_0x2d337e['options']);return _0x45cad2['getFaxAccounts'](_0x3d1548);}})[_0x04c6('0x25')](function(_0x7e9073){if(_0x7e9073){_0xa40fc9=_0x7e9073[_0x04c6('0x42')];if(!_0x2d337e['query'][_0x04c6('0xc6')](_0x04c6('0xcb'))){_0x3d1548[_0x04c6('0x20')]=qs[_0x04c6('0x20')](_0x2d337e[_0x04c6('0x3c')][_0x04c6('0x20')]);_0x3d1548[_0x04c6('0x1e')]=qs[_0x04c6('0x1e')](_0x2d337e[_0x04c6('0x3c')][_0x04c6('0x1e')]);}return _0x45cad2[_0x04c6('0x139')](_0x3d1548);}})[_0x04c6('0x25')](function(_0x5a18cf){if(_0x5a18cf){return _0x5a18cf?{'count':_0xa40fc9,'rows':_0x5a18cf}:null;}})[_0x04c6('0x25')](respondWithResult(_0x1512e3,null))['catch'](handleError(_0x1512e3,null));};exports['addFaxAccounts']=function(_0x46553a,_0x3dd4b6){return db[_0x04c6('0x3b')][_0x04c6('0x32')]({'where':{'id':_0x46553a[_0x04c6('0x4a')]['id']}})[_0x04c6('0x25')](handleEntityNotFound(_0x3dd4b6,null))[_0x04c6('0x25')](function(_0x2750d0){if(_0x2750d0){return _0x2750d0[_0x04c6('0x13a')](_0x46553a[_0x04c6('0x56')][_0x04c6('0x59')],_[_0x04c6('0x5a')](_0x46553a['body'],[_0x04c6('0x59'),'id'])||{});}})[_0x04c6('0x25')](respondWithResult(_0x3dd4b6,null))[_0x04c6('0x1b')](handleError(_0x3dd4b6,null));};exports['removeFaxAccounts']=function(_0x4a8a94,_0x5027a9){return db[_0x04c6('0x3b')][_0x04c6('0x32')]({'where':{'id':_0x4a8a94[_0x04c6('0x4a')]['id']}})[_0x04c6('0x25')](handleEntityNotFound(_0x5027a9,null))[_0x04c6('0x25')](function(_0x296650){if(_0x296650){return _0x296650[_0x04c6('0x13b')](_0x4a8a94[_0x04c6('0x3c')]['ids']);}})['then'](respondWithStatusCode(_0x5027a9,null))[_0x04c6('0x1b')](handleError(_0x5027a9,null));};exports['getMailAccounts']=function(_0x4ce89a,_0x451745){var _0x1a2fca={};var _0x14d015={};var _0x6c4510;var _0x19f8cc;return db[_0x04c6('0x3b')][_0x04c6('0x90')]({'where':{'id':_0x4ce89a[_0x04c6('0x4a')]['id']}})[_0x04c6('0x25')](handleEntityNotFound(_0x451745,null))[_0x04c6('0x25')](function(_0x49ae12){if(_0x49ae12){_0x6c4510=_0x49ae12;_0x14d015[_0x04c6('0x4f')]=_[_0x04c6('0x4c')](db[_0x04c6('0x13c')][_0x04c6('0x36')]);_0x14d015['query']=_[_0x04c6('0x4c')](_0x4ce89a[_0x04c6('0x3c')]);_0x14d015[_0x04c6('0xc3')]=_[_0x04c6('0x4e')](_0x14d015[_0x04c6('0x4f')],_0x14d015[_0x04c6('0x3c')]);_0x1a2fca[_0x04c6('0x3e')]=_[_0x04c6('0x4e')](_0x14d015[_0x04c6('0x4f')],qs['fields'](_0x4ce89a['query']['fields']));_0x1a2fca['attributes']=_0x1a2fca[_0x04c6('0x3e')][_0x04c6('0x42')]?_0x1a2fca[_0x04c6('0x3e')]:_0x14d015[_0x04c6('0x4f')];_0x1a2fca[_0x04c6('0xce')]=qs[_0x04c6('0xc4')](_0x4ce89a[_0x04c6('0x3c')][_0x04c6('0xc4')]);_0x1a2fca[_0x04c6('0x3a')]=qs[_0x04c6('0xc3')](_['pick'](_0x4ce89a[_0x04c6('0x3c')],_0x14d015[_0x04c6('0xc3')]));if(_0x4ce89a[_0x04c6('0x3c')]['filter']){_0x1a2fca['where']=_[_0x04c6('0xc5')](_0x1a2fca[_0x04c6('0x3a')],{'$or':_[_0x04c6('0x2f')](_0x1a2fca['attributes'],function(_0x182ddd){var _0x216e78={};_0x216e78[_0x182ddd]={'$like':'%'+_0x4ce89a[_0x04c6('0x3c')][_0x04c6('0x2d')]+'%'};return _0x216e78;})});}_0x1a2fca=_[_0x04c6('0xc5')]({},_0x1a2fca,_0x4ce89a['options']);return _0x6c4510[_0x04c6('0x13d')](_0x1a2fca);}})[_0x04c6('0x25')](function(_0x3a9e02){if(_0x3a9e02){_0x19f8cc=_0x3a9e02[_0x04c6('0x42')];if(!_0x4ce89a[_0x04c6('0x3c')]['hasOwnProperty'](_0x04c6('0xcb'))){_0x1a2fca['limit']=qs['limit'](_0x4ce89a[_0x04c6('0x3c')]['limit']);_0x1a2fca['offset']=qs[_0x04c6('0x1e')](_0x4ce89a[_0x04c6('0x3c')][_0x04c6('0x1e')]);}return _0x6c4510[_0x04c6('0x13d')](_0x1a2fca);}})[_0x04c6('0x25')](function(_0x1d4c0e){if(_0x1d4c0e){return _0x1d4c0e?{'count':_0x19f8cc,'rows':_0x1d4c0e}:null;}})['then'](respondWithResult(_0x451745,null))[_0x04c6('0x1b')](handleError(_0x451745,null));};exports[_0x04c6('0x13e')]=function(_0x304ee6,_0x482acf){return db['User'][_0x04c6('0x32')]({'where':{'id':_0x304ee6[_0x04c6('0x4a')]['id']}})[_0x04c6('0x25')](handleEntityNotFound(_0x482acf,null))[_0x04c6('0x25')](function(_0x43df91){if(_0x43df91){return _0x43df91[_0x04c6('0x13e')](_0x304ee6['body'][_0x04c6('0x59')],_[_0x04c6('0x5a')](_0x304ee6[_0x04c6('0x56')],[_0x04c6('0x59'),'id'])||{});}})[_0x04c6('0x25')](respondWithResult(_0x482acf,null))['catch'](handleError(_0x482acf,null));};exports[_0x04c6('0x13f')]=function(_0xa59bc,_0x2f10ee){return db[_0x04c6('0x3b')][_0x04c6('0x32')]({'where':{'id':_0xa59bc['params']['id']}})[_0x04c6('0x25')](handleEntityNotFound(_0x2f10ee,null))['then'](function(_0x2cd618){if(_0x2cd618){return _0x2cd618[_0x04c6('0x13f')](_0xa59bc[_0x04c6('0x3c')][_0x04c6('0x59')]);}})['then'](respondWithStatusCode(_0x2f10ee,null))[_0x04c6('0x1b')](handleError(_0x2f10ee,null));};exports[_0x04c6('0x140')]=function(_0x5baad2,_0x58bddd){var _0xb8dfc0={};var _0x412d32={};var _0x30b20e;var _0x4342a0;return db[_0x04c6('0x3b')][_0x04c6('0x90')]({'where':{'id':_0x5baad2[_0x04c6('0x4a')]['id']}})[_0x04c6('0x25')](handleEntityNotFound(_0x58bddd,null))[_0x04c6('0x25')](function(_0x5732fc){if(_0x5732fc){_0x30b20e=_0x5732fc;_0x412d32['model']=_['keys'](db[_0x04c6('0x141')][_0x04c6('0x36')]);_0x412d32[_0x04c6('0x3c')]=_['keys'](_0x5baad2[_0x04c6('0x3c')]);_0x412d32['filters']=_[_0x04c6('0x4e')](_0x412d32[_0x04c6('0x4f')],_0x412d32[_0x04c6('0x3c')]);_0xb8dfc0[_0x04c6('0x3e')]=_[_0x04c6('0x4e')](_0x412d32[_0x04c6('0x4f')],qs['fields'](_0x5baad2[_0x04c6('0x3c')][_0x04c6('0x50')]));_0xb8dfc0[_0x04c6('0x3e')]=_0xb8dfc0[_0x04c6('0x3e')]['length']?_0xb8dfc0[_0x04c6('0x3e')]:_0x412d32[_0x04c6('0x4f')];_0xb8dfc0[_0x04c6('0xce')]=qs['sort'](_0x5baad2[_0x04c6('0x3c')][_0x04c6('0xc4')]);_0xb8dfc0['where']=qs[_0x04c6('0xc3')](_['pick'](_0x5baad2['query'],_0x412d32[_0x04c6('0xc3')]));if(_0x5baad2[_0x04c6('0x3c')][_0x04c6('0x2d')]){_0xb8dfc0[_0x04c6('0x3a')]=_[_0x04c6('0xc5')](_0xb8dfc0[_0x04c6('0x3a')],{'$or':_['map'](_0xb8dfc0[_0x04c6('0x3e')],function(_0x397f53){var _0x1cded0={};_0x1cded0[_0x397f53]={'$like':'%'+_0x5baad2['query'][_0x04c6('0x2d')]+'%'};return _0x1cded0;})});}_0xb8dfc0=_['merge']({},_0xb8dfc0,_0x5baad2[_0x04c6('0x52')]);return _0x30b20e[_0x04c6('0x140')](_0xb8dfc0);}})[_0x04c6('0x25')](function(_0x1af0c6){if(_0x1af0c6){_0x4342a0=_0x1af0c6[_0x04c6('0x42')];if(!_0x5baad2[_0x04c6('0x3c')][_0x04c6('0xc6')](_0x04c6('0xcb'))){_0xb8dfc0[_0x04c6('0x20')]=qs['limit'](_0x5baad2[_0x04c6('0x3c')][_0x04c6('0x20')]);_0xb8dfc0[_0x04c6('0x1e')]=qs[_0x04c6('0x1e')](_0x5baad2[_0x04c6('0x3c')][_0x04c6('0x1e')]);}return _0x30b20e[_0x04c6('0x140')](_0xb8dfc0);}})[_0x04c6('0x25')](function(_0x2a204d){if(_0x2a204d){return _0x2a204d?{'count':_0x4342a0,'rows':_0x2a204d}:null;}})[_0x04c6('0x25')](respondWithResult(_0x58bddd,null))[_0x04c6('0x1b')](handleError(_0x58bddd,null));};exports['addOpenchannelAccounts']=function(_0x4c298f,_0x3f80f7){return db['User'][_0x04c6('0x32')]({'where':{'id':_0x4c298f['params']['id']}})[_0x04c6('0x25')](handleEntityNotFound(_0x3f80f7,null))['then'](function(_0x337f15){if(_0x337f15){return _0x337f15[_0x04c6('0x142')](_0x4c298f['body']['ids'],_[_0x04c6('0x5a')](_0x4c298f[_0x04c6('0x56')],[_0x04c6('0x59'),'id'])||{});}})[_0x04c6('0x25')](respondWithResult(_0x3f80f7,null))[_0x04c6('0x1b')](handleError(_0x3f80f7,null));};exports[_0x04c6('0x143')]=function(_0x3291ce,_0x399cb6){return db['User'][_0x04c6('0x32')]({'where':{'id':_0x3291ce[_0x04c6('0x4a')]['id']}})[_0x04c6('0x25')](handleEntityNotFound(_0x399cb6,null))['then'](function(_0xe50c26){if(_0xe50c26){return _0xe50c26[_0x04c6('0x143')](_0x3291ce[_0x04c6('0x3c')][_0x04c6('0x59')]);}})[_0x04c6('0x25')](respondWithStatusCode(_0x399cb6,null))['catch'](handleError(_0x399cb6,null));};exports['getSmsAccounts']=function(_0x3b9b53,_0x2c8baf){var _0x85847d={};var _0x206d85={};var _0x42ed35;var _0x533184;return db['User'][_0x04c6('0x90')]({'where':{'id':_0x3b9b53[_0x04c6('0x4a')]['id']}})['then'](handleEntityNotFound(_0x2c8baf,null))[_0x04c6('0x25')](function(_0xe74e00){if(_0xe74e00){_0x42ed35=_0xe74e00;_0x206d85[_0x04c6('0x4f')]=_[_0x04c6('0x4c')](db['SmsAccount'][_0x04c6('0x36')]);_0x206d85[_0x04c6('0x3c')]=_[_0x04c6('0x4c')](_0x3b9b53['query']);_0x206d85[_0x04c6('0xc3')]=_[_0x04c6('0x4e')](_0x206d85['model'],_0x206d85['query']);_0x85847d[_0x04c6('0x3e')]=_[_0x04c6('0x4e')](_0x206d85[_0x04c6('0x4f')],qs['fields'](_0x3b9b53['query'][_0x04c6('0x50')]));_0x85847d[_0x04c6('0x3e')]=_0x85847d[_0x04c6('0x3e')][_0x04c6('0x42')]?_0x85847d[_0x04c6('0x3e')]:_0x206d85[_0x04c6('0x4f')];_0x85847d[_0x04c6('0xce')]=qs['sort'](_0x3b9b53[_0x04c6('0x3c')][_0x04c6('0xc4')]);_0x85847d['where']=qs['filters'](_[_0x04c6('0xcf')](_0x3b9b53[_0x04c6('0x3c')],_0x206d85['filters']));if(_0x3b9b53[_0x04c6('0x3c')][_0x04c6('0x2d')]){_0x85847d[_0x04c6('0x3a')]=_['merge'](_0x85847d[_0x04c6('0x3a')],{'$or':_[_0x04c6('0x2f')](_0x85847d[_0x04c6('0x3e')],function(_0x25aff2){var _0x3da51d={};_0x3da51d[_0x25aff2]={'$like':'%'+_0x3b9b53[_0x04c6('0x3c')][_0x04c6('0x2d')]+'%'};return _0x3da51d;})});}_0x85847d=_[_0x04c6('0xc5')]({},_0x85847d,_0x3b9b53[_0x04c6('0x52')]);return _0x42ed35[_0x04c6('0x144')](_0x85847d);}})[_0x04c6('0x25')](function(_0x156f61){if(_0x156f61){_0x533184=_0x156f61[_0x04c6('0x42')];if(!_0x3b9b53[_0x04c6('0x3c')][_0x04c6('0xc6')]('nolimit')){_0x85847d['limit']=qs[_0x04c6('0x20')](_0x3b9b53[_0x04c6('0x3c')][_0x04c6('0x20')]);_0x85847d[_0x04c6('0x1e')]=qs[_0x04c6('0x1e')](_0x3b9b53[_0x04c6('0x3c')][_0x04c6('0x1e')]);}return _0x42ed35[_0x04c6('0x144')](_0x85847d);}})[_0x04c6('0x25')](function(_0x324d68){if(_0x324d68){return _0x324d68?{'count':_0x533184,'rows':_0x324d68}:null;}})[_0x04c6('0x25')](respondWithResult(_0x2c8baf,null))['catch'](handleError(_0x2c8baf,null));};exports['addSmsAccounts']=function(_0x115071,_0x23a6c1){return db[_0x04c6('0x3b')]['find']({'where':{'id':_0x115071[_0x04c6('0x4a')]['id']}})['then'](handleEntityNotFound(_0x23a6c1,null))[_0x04c6('0x25')](function(_0x3c08c7){if(_0x3c08c7){return _0x3c08c7['addSmsAccounts'](_0x115071['body'][_0x04c6('0x59')],_['omit'](_0x115071['body'],[_0x04c6('0x59'),'id'])||{});}})[_0x04c6('0x25')](respondWithResult(_0x23a6c1,null))[_0x04c6('0x1b')](handleError(_0x23a6c1,null));};exports[_0x04c6('0x145')]=function(_0x5cc534,_0x12738d){return db[_0x04c6('0x3b')][_0x04c6('0x32')]({'where':{'id':_0x5cc534['params']['id']}})[_0x04c6('0x25')](handleEntityNotFound(_0x12738d,null))[_0x04c6('0x25')](function(_0x14bf0b){if(_0x14bf0b){return _0x14bf0b['removeSmsAccounts'](_0x5cc534[_0x04c6('0x3c')]['ids']);}})[_0x04c6('0x25')](respondWithStatusCode(_0x12738d,null))['catch'](handleError(_0x12738d,null));};exports[_0x04c6('0x146')]=function(_0x1fbfe6,_0x2fceb9){var _0x26cf22={};var _0xa7db14={};var _0x44ca0d;var _0x28a8a4;return db[_0x04c6('0x3b')][_0x04c6('0x90')]({'where':{'id':_0x1fbfe6[_0x04c6('0x4a')]['id']}})['then'](handleEntityNotFound(_0x2fceb9,null))['then'](function(_0x26586e){if(_0x26586e){_0x44ca0d=_0x26586e;_0xa7db14[_0x04c6('0x4f')]=_[_0x04c6('0x4c')](db['ChatWebsite'][_0x04c6('0x36')]);_0xa7db14['query']=_[_0x04c6('0x4c')](_0x1fbfe6[_0x04c6('0x3c')]);_0xa7db14[_0x04c6('0xc3')]=_[_0x04c6('0x4e')](_0xa7db14[_0x04c6('0x4f')],_0xa7db14[_0x04c6('0x3c')]);_0x26cf22[_0x04c6('0x3e')]=_[_0x04c6('0x4e')](_0xa7db14['model'],qs[_0x04c6('0x50')](_0x1fbfe6['query'][_0x04c6('0x50')]));_0x26cf22[_0x04c6('0x3e')]=_0x26cf22[_0x04c6('0x3e')][_0x04c6('0x42')]?_0x26cf22[_0x04c6('0x3e')]:_0xa7db14[_0x04c6('0x4f')];_0x26cf22[_0x04c6('0xce')]=qs[_0x04c6('0xc4')](_0x1fbfe6[_0x04c6('0x3c')][_0x04c6('0xc4')]);_0x26cf22[_0x04c6('0x3a')]=qs[_0x04c6('0xc3')](_['pick'](_0x1fbfe6['query'],_0xa7db14[_0x04c6('0xc3')]));if(_0x1fbfe6[_0x04c6('0x3c')][_0x04c6('0x2d')]){_0x26cf22[_0x04c6('0x3a')]=_[_0x04c6('0xc5')](_0x26cf22[_0x04c6('0x3a')],{'$or':_['map'](_0x26cf22[_0x04c6('0x3e')],function(_0x550431){var _0x1d5f0f={};_0x1d5f0f[_0x550431]={'$like':'%'+_0x1fbfe6[_0x04c6('0x3c')]['filter']+'%'};return _0x1d5f0f;})});}_0x26cf22=_['merge']({},_0x26cf22,_0x1fbfe6[_0x04c6('0x52')]);return _0x44ca0d[_0x04c6('0x146')](_0x26cf22);}})[_0x04c6('0x25')](function(_0x3a036b){if(_0x3a036b){_0x28a8a4=_0x3a036b[_0x04c6('0x42')];if(!_0x1fbfe6[_0x04c6('0x3c')][_0x04c6('0xc6')](_0x04c6('0xcb'))){_0x26cf22[_0x04c6('0x20')]=qs['limit'](_0x1fbfe6[_0x04c6('0x3c')][_0x04c6('0x20')]);_0x26cf22[_0x04c6('0x1e')]=qs['offset'](_0x1fbfe6[_0x04c6('0x3c')]['offset']);}return _0x44ca0d[_0x04c6('0x146')](_0x26cf22);}})[_0x04c6('0x25')](function(_0x38c101){if(_0x38c101){return _0x38c101?{'count':_0x28a8a4,'rows':_0x38c101}:null;}})[_0x04c6('0x25')](respondWithResult(_0x2fceb9,null))[_0x04c6('0x1b')](handleError(_0x2fceb9,null));};exports[_0x04c6('0x147')]=function(_0x4e3a42,_0x22e437){return db[_0x04c6('0x3b')]['find']({'where':{'id':_0x4e3a42[_0x04c6('0x4a')]['id']}})[_0x04c6('0x25')](handleEntityNotFound(_0x22e437,null))[_0x04c6('0x25')](function(_0x463649){if(_0x463649){return _0x463649[_0x04c6('0x147')](_0x4e3a42['body'][_0x04c6('0x59')],_[_0x04c6('0x5a')](_0x4e3a42[_0x04c6('0x56')],['ids','id'])||{});}})[_0x04c6('0x25')](respondWithResult(_0x22e437,null))[_0x04c6('0x1b')](handleError(_0x22e437,null));};exports[_0x04c6('0x148')]=function(_0x4defb2,_0x5911d9){return db[_0x04c6('0x3b')][_0x04c6('0x32')]({'where':{'id':_0x4defb2[_0x04c6('0x4a')]['id']}})[_0x04c6('0x25')](handleEntityNotFound(_0x5911d9,null))['then'](function(_0x5d5273){if(_0x5d5273){return _0x5d5273[_0x04c6('0x148')](_0x4defb2[_0x04c6('0x3c')]['ids']);}})['then'](respondWithStatusCode(_0x5911d9,null))[_0x04c6('0x1b')](handleError(_0x5911d9,null));};exports[_0x04c6('0x149')]=function(_0x3da6e3,_0x13a7ad){var _0x2fef5d={};var _0x2728c7={};var _0x1b8f72;var _0x13b2e7;return db['User'][_0x04c6('0x90')]({'where':{'id':_0x3da6e3[_0x04c6('0x4a')]['id']}})[_0x04c6('0x25')](handleEntityNotFound(_0x13a7ad,null))[_0x04c6('0x25')](function(_0x31cbc0){if(_0x31cbc0){_0x1b8f72=_0x31cbc0;_0x2728c7[_0x04c6('0x4f')]=_[_0x04c6('0x4c')](db[_0x04c6('0x14a')][_0x04c6('0x36')]);_0x2728c7[_0x04c6('0x3c')]=_[_0x04c6('0x4c')](_0x3da6e3[_0x04c6('0x3c')]);_0x2728c7[_0x04c6('0xc3')]=_[_0x04c6('0x4e')](_0x2728c7[_0x04c6('0x4f')],_0x2728c7[_0x04c6('0x3c')]);_0x2fef5d['attributes']=_[_0x04c6('0x4e')](_0x2728c7[_0x04c6('0x4f')],qs[_0x04c6('0x50')](_0x3da6e3[_0x04c6('0x3c')][_0x04c6('0x50')]));_0x2fef5d[_0x04c6('0x3e')]=_0x2fef5d[_0x04c6('0x3e')]['length']?_0x2fef5d[_0x04c6('0x3e')]:_0x2728c7[_0x04c6('0x4f')];_0x2fef5d[_0x04c6('0xce')]=qs[_0x04c6('0xc4')](_0x3da6e3[_0x04c6('0x3c')]['sort']);_0x2fef5d[_0x04c6('0x3a')]=qs[_0x04c6('0xc3')](_[_0x04c6('0xcf')](_0x3da6e3[_0x04c6('0x3c')],_0x2728c7[_0x04c6('0xc3')]));if(_0x3da6e3[_0x04c6('0x3c')][_0x04c6('0x2d')]){_0x2fef5d['where']=_[_0x04c6('0xc5')](_0x2fef5d['where'],{'$or':_[_0x04c6('0x2f')](_0x2fef5d['attributes'],function(_0x76c283){var _0x2acc5e={};_0x2acc5e[_0x76c283]={'$like':'%'+_0x3da6e3[_0x04c6('0x3c')]['filter']+'%'};return _0x2acc5e;})});}_0x2fef5d=_[_0x04c6('0xc5')]({},_0x2fef5d,_0x3da6e3[_0x04c6('0x52')]);return _0x1b8f72[_0x04c6('0x149')](_0x2fef5d);}})[_0x04c6('0x25')](function(_0x28ef57){if(_0x28ef57){_0x13b2e7=_0x28ef57['length'];if(!_0x3da6e3[_0x04c6('0x3c')][_0x04c6('0xc6')](_0x04c6('0xcb'))){_0x2fef5d['limit']=qs[_0x04c6('0x20')](_0x3da6e3[_0x04c6('0x3c')][_0x04c6('0x20')]);_0x2fef5d[_0x04c6('0x1e')]=qs[_0x04c6('0x1e')](_0x3da6e3[_0x04c6('0x3c')][_0x04c6('0x1e')]);}return _0x1b8f72[_0x04c6('0x149')](_0x2fef5d);}})[_0x04c6('0x25')](function(_0x1cb1ea){if(_0x1cb1ea){return _0x1cb1ea?{'count':_0x13b2e7,'rows':_0x1cb1ea}:null;}})['then'](respondWithResult(_0x13a7ad,null))[_0x04c6('0x1b')](handleError(_0x13a7ad,null));};exports[_0x04c6('0x14b')]=function(_0x4c56e4,_0x520280){return db[_0x04c6('0x3b')][_0x04c6('0x32')]({'where':{'id':_0x4c56e4[_0x04c6('0x4a')]['id']}})[_0x04c6('0x25')](handleEntityNotFound(_0x520280,null))[_0x04c6('0x25')](function(_0x2fd2ec){if(_0x2fd2ec){return _0x2fd2ec[_0x04c6('0x14b')](_0x4c56e4['body'][_0x04c6('0x59')],_['omit'](_0x4c56e4[_0x04c6('0x56')],[_0x04c6('0x59'),'id'])||{});}})[_0x04c6('0x25')](respondWithResult(_0x520280,null))['catch'](handleError(_0x520280,null));};exports[_0x04c6('0x14c')]=function(_0x324b0e,_0x5a1976){return db[_0x04c6('0x3b')][_0x04c6('0x32')]({'where':{'id':_0x324b0e[_0x04c6('0x4a')]['id']}})[_0x04c6('0x25')](handleEntityNotFound(_0x5a1976,null))[_0x04c6('0x25')](function(_0x1bd7e){if(_0x1bd7e){return _0x1bd7e[_0x04c6('0x14c')](_0x324b0e[_0x04c6('0x3c')][_0x04c6('0x59')]);}})[_0x04c6('0x25')](respondWithStatusCode(_0x5a1976,null))[_0x04c6('0x1b')](handleError(_0x5a1976,null));};exports[_0x04c6('0x14d')]=function(_0x1e3a1f,_0x4c663d){var _0x1f9a1c={};var _0x23e8c3={};var _0x383e85;var _0x31c87a;return db['User'][_0x04c6('0x90')]({'where':{'id':_0x1e3a1f['params']['id']}})[_0x04c6('0x25')](handleEntityNotFound(_0x4c663d,null))[_0x04c6('0x25')](function(_0x5a32b3){if(_0x5a32b3){_0x383e85=_0x5a32b3;_0x23e8c3[_0x04c6('0x4f')]=_[_0x04c6('0x4c')](db[_0x04c6('0x14e')][_0x04c6('0x36')]);_0x23e8c3[_0x04c6('0x3c')]=_[_0x04c6('0x4c')](_0x1e3a1f[_0x04c6('0x3c')]);_0x23e8c3[_0x04c6('0xc3')]=_[_0x04c6('0x4e')](_0x23e8c3[_0x04c6('0x4f')],_0x23e8c3[_0x04c6('0x3c')]);_0x1f9a1c['attributes']=_['intersection'](_0x23e8c3['model'],qs[_0x04c6('0x50')](_0x1e3a1f[_0x04c6('0x3c')]['fields']));_0x1f9a1c['attributes']=_0x1f9a1c['attributes'][_0x04c6('0x42')]?_0x1f9a1c[_0x04c6('0x3e')]:_0x23e8c3[_0x04c6('0x4f')];_0x1f9a1c[_0x04c6('0xce')]=qs[_0x04c6('0xc4')](_0x1e3a1f[_0x04c6('0x3c')][_0x04c6('0xc4')]);_0x1f9a1c[_0x04c6('0x3a')]=qs[_0x04c6('0xc3')](_[_0x04c6('0xcf')](_0x1e3a1f[_0x04c6('0x3c')],_0x23e8c3[_0x04c6('0xc3')]));if(_0x1e3a1f[_0x04c6('0x3c')]['filter']){_0x1f9a1c[_0x04c6('0x3a')]=_['merge'](_0x1f9a1c[_0x04c6('0x3a')],{'$or':_[_0x04c6('0x2f')](_0x1f9a1c[_0x04c6('0x3e')],function(_0x3ff705){var _0x1cf35c={};_0x1cf35c[_0x3ff705]={'$like':'%'+_0x1e3a1f['query']['filter']+'%'};return _0x1cf35c;})});}_0x1f9a1c=_[_0x04c6('0xc5')]({},_0x1f9a1c,_0x1e3a1f[_0x04c6('0x52')]);return _0x383e85['getSquareProjects'](_0x1f9a1c);}})[_0x04c6('0x25')](function(_0x2e5bfa){if(_0x2e5bfa){_0x31c87a=_0x2e5bfa[_0x04c6('0x42')];if(!_0x1e3a1f[_0x04c6('0x3c')]['hasOwnProperty'](_0x04c6('0xcb'))){_0x1f9a1c[_0x04c6('0x20')]=qs[_0x04c6('0x20')](_0x1e3a1f[_0x04c6('0x3c')][_0x04c6('0x20')]);_0x1f9a1c[_0x04c6('0x1e')]=qs[_0x04c6('0x1e')](_0x1e3a1f[_0x04c6('0x3c')][_0x04c6('0x1e')]);}return _0x383e85[_0x04c6('0x14d')](_0x1f9a1c);}})[_0x04c6('0x25')](function(_0x586630){if(_0x586630){return _0x586630?{'count':_0x31c87a,'rows':_0x586630}:null;}})['then'](respondWithResult(_0x4c663d,null))['catch'](handleError(_0x4c663d,null));};exports['addSquareProjects']=function(_0x198413,_0x30e53e){return db[_0x04c6('0x3b')]['find']({'where':{'id':_0x198413[_0x04c6('0x4a')]['id']}})[_0x04c6('0x25')](handleEntityNotFound(_0x30e53e,null))[_0x04c6('0x25')](function(_0x2872f5){if(_0x2872f5){return _0x2872f5[_0x04c6('0x14f')](_0x198413[_0x04c6('0x56')][_0x04c6('0x59')],_[_0x04c6('0x5a')](_0x198413[_0x04c6('0x56')],[_0x04c6('0x59'),'id'])||{});}})[_0x04c6('0x25')](respondWithResult(_0x30e53e,null))['catch'](handleError(_0x30e53e,null));};exports[_0x04c6('0x150')]=function(_0x21086f,_0x2822a4){return db['User'][_0x04c6('0x32')]({'where':{'id':_0x21086f[_0x04c6('0x4a')]['id']}})[_0x04c6('0x25')](handleEntityNotFound(_0x2822a4,null))[_0x04c6('0x25')](function(_0x212f8e){if(_0x212f8e){return _0x212f8e['removeSquareProjects'](_0x21086f['query']['ids']);}})[_0x04c6('0x25')](respondWithStatusCode(_0x2822a4,null))['catch'](handleError(_0x2822a4,null));};exports[_0x04c6('0x151')]=function(_0x3eb0cd,_0x5df996){var _0x5082b6={},_0x767b2e={},_0x144c48={'count':0x0,'rows':[]};var _0x4cbcfc=db[_0x04c6('0x152')]['rawAttributes'];_0x767b2e[_0x04c6('0x4f')]=_['keys'](_0x4cbcfc);_0x767b2e[_0x04c6('0x3c')]=_[_0x04c6('0x4c')](_0x3eb0cd[_0x04c6('0x3c')]);_0x767b2e[_0x04c6('0xc3')]=_[_0x04c6('0x4e')](_0x767b2e[_0x04c6('0x4f')],_0x767b2e[_0x04c6('0x3c')]);_0x767b2e['filters']=_['concat'](_0x767b2e[_0x04c6('0xc3')],[_0x04c6('0x153'),_0x04c6('0x154'),_0x04c6('0x155'),_0x04c6('0x156'),_0x04c6('0x157'),'$lte',_0x04c6('0x158'),_0x04c6('0x159'),_0x04c6('0x15a'),_0x04c6('0x15b'),_0x04c6('0x15c'),_0x04c6('0x15d'),'$notIn',_0x04c6('0x15e'),'$notLike','$iLike','$notILike',_0x04c6('0x15e'),_0x04c6('0x15f'),_0x04c6('0x160'),'$contained',_0x04c6('0x161')]);_0x5082b6[_0x04c6('0x3e')]=_[_0x04c6('0x4e')](_0x767b2e[_0x04c6('0x4f')],qs[_0x04c6('0x50')](_0x3eb0cd[_0x04c6('0x3c')][_0x04c6('0x50')]));_0x5082b6[_0x04c6('0x3e')]=_0x5082b6[_0x04c6('0x3e')][_0x04c6('0x42')]?_0x5082b6[_0x04c6('0x3e')]:_0x767b2e[_0x04c6('0x4f')];if(!_0x3eb0cd[_0x04c6('0x3c')][_0x04c6('0xc6')]('nolimit')){_0x5082b6['limit']=qs[_0x04c6('0x20')](_0x3eb0cd[_0x04c6('0x3c')][_0x04c6('0x20')]);_0x5082b6['offset']=qs[_0x04c6('0x1e')](_0x3eb0cd['query'][_0x04c6('0x1e')]);}_0x5082b6[_0x04c6('0xce')]=qs[_0x04c6('0xc4')](_0x3eb0cd['query'][_0x04c6('0xc4')]);_0x5082b6['where']=qs[_0x04c6('0xc3')](_[_0x04c6('0xcf')](_0x3eb0cd[_0x04c6('0x3c')],_0x767b2e['filters']));if(_0x3eb0cd['query']['filter']){_0x5082b6[_0x04c6('0x3a')]=_['merge'](_0x5082b6[_0x04c6('0x3a')],{'$or':_[_0x04c6('0x2f')](_0x5082b6[_0x04c6('0x3e')],function(_0x551949){var _0x343ae3={};_0x343ae3[_0x551949]={'$like':'%'+_0x3eb0cd[_0x04c6('0x3c')][_0x04c6('0x2d')]+'%'};return _0x343ae3;})});}_0x5082b6[_0x04c6('0x3a')]={'$and':[_0x5082b6['where'],{'$or':[{'UserId':_0x3eb0cd[_0x04c6('0x4a')]['id']},{'OwnerId':_0x3eb0cd['params']['id']}]}]};_0x5082b6=_[_0x04c6('0xc5')]({},_0x5082b6,_0x3eb0cd[_0x04c6('0x52')]);var _0x705f14={'where':_0x5082b6['where']};return db[_0x04c6('0x152')][_0x04c6('0x21')](_0x705f14)[_0x04c6('0x25')](function(_0x4fde5b){_0x144c48['count']=_0x4fde5b;if(_0x3eb0cd[_0x04c6('0x3c')][_0x04c6('0x51')]){_0x5082b6[_0x04c6('0x3d')]=[{'attributes':['id',_0x04c6('0x162'),'lastName',_0x04c6('0x163')],'model':db[_0x04c6('0xc2')],'as':'Contact'},{'attributes':['id',_0x04c6('0x33'),_0x04c6('0x164')],'model':db[_0x04c6('0xa3')],'as':_0x04c6('0xcd')}];}return db[_0x04c6('0x152')][_0x04c6('0x40')](_0x5082b6);})[_0x04c6('0x25')](function(_0x22493d){_0x144c48['rows']=_0x22493d;return _0x144c48;})[_0x04c6('0x25')](respondWithFilteredResult(_0x5df996,_0x5082b6))[_0x04c6('0x1b')](handleError(_0x5df996,null));};exports[_0x04c6('0x165')]=function(_0x7f0185,_0x45abeb){if(!_[_0x04c6('0x61')](_0x7f0185['user']['id'])&&(_0x7f0185[_0x04c6('0x77')]['role']==_0x04c6('0x79')||_0x7f0185[_0x04c6('0x77')][_0x04c6('0x27')]==_0x04c6('0x77'))){return db[_0x04c6('0x3b')][_0x04c6('0x90')]({'where':{'id':_0x7f0185[_0x04c6('0x4a')]['id']},'raw':!![]})['then'](function(_0x40ae96){return authService[_0x04c6('0x166')](_0x40ae96);})[_0x04c6('0x25')](function(_0xcc442f){if(_0xcc442f){return _0x45abeb['status'](0xc8)[_0x04c6('0x23')]({'api_key':_0xcc442f['token']});}else{return _0x45abeb['status'](0xcc)[_0x04c6('0x23')]({'message':_0x04c6('0x167')});}})[_0x04c6('0x1b')](handleError(_0x45abeb,0x193));}else{return _0x45abeb[_0x04c6('0x1c')](0x191)[_0x04c6('0x23')]({'message':_0x04c6('0x168')});}};exports[_0x04c6('0x169')]=function(_0x5a26f3,_0x20b001){if(!_['isNil'](_0x5a26f3[_0x04c6('0x77')]['id'])&&(_0x5a26f3[_0x04c6('0x77')][_0x04c6('0x27')]=='admin'||_0x5a26f3[_0x04c6('0x77')][_0x04c6('0x27')]==_0x04c6('0x77'))){return db[_0x04c6('0x3b')][_0x04c6('0x32')]({'where':{'id':_0x5a26f3[_0x04c6('0x4a')]['id']}})[_0x04c6('0x25')](function(_0x466f1c){return authService['generateApiKey'](_0x466f1c);})[_0x04c6('0x25')](function(_0x12685d){return db[_0x04c6('0x3b')][_0x04c6('0x24')]({'apiKeyIat':_0x12685d[_0x04c6('0x16a')],'apiKeyNonce':_0x12685d[_0x04c6('0x16b')]},{'where':{'id':_0x5a26f3['params']['id']}})[_0x04c6('0x25')](function(){return _0x20b001[_0x04c6('0x1c')](0xc8)[_0x04c6('0x23')]({'api_key':_0x12685d[_0x04c6('0x16c')]});});})['catch'](handleError(_0x20b001,0x193));}else{return _0x20b001[_0x04c6('0x1c')](0x191)[_0x04c6('0x23')]({'message':_0x04c6('0x168')});}};exports['removeApiKey']=function(_0x225295,_0x28a859){if(!_['isNil'](_0x225295[_0x04c6('0x77')]['id'])&&(_0x225295[_0x04c6('0x77')]['role']==_0x04c6('0x79')||_0x225295[_0x04c6('0x77')][_0x04c6('0x27')]==_0x04c6('0x77'))){return db['User']['find']({'where':{'id':_0x225295[_0x04c6('0x4a')]['id']}})[_0x04c6('0x25')](handleEntityNotFound(_0x28a859,null))[_0x04c6('0x25')](function(_0x29945a){if(_0x29945a&&_0x29945a[_0x04c6('0x16d')]&&_0x29945a[_0x04c6('0x16e')])return _0x29945a;else throw{'message':_0x04c6('0x16f')};})[_0x04c6('0x25')](function(_0x540785){return db['User'][_0x04c6('0x24')]({'apiKeyNonce':null,'apiKeyIat':null},{'where':{'id':_0x225295[_0x04c6('0x4a')]['id']}});})['then'](respondWithStatusCode(_0x28a859,0xc8))[_0x04c6('0x1b')](handleError(_0x28a859,0x193));}else{return _0x28a859['status'](0x191)[_0x04c6('0x23')]({'message':_0x04c6('0x168')});}};exports[_0x04c6('0x170')]=function(_0x5c233c,_0x1b2ff4){var _0xf5c99=_0x5c233c[_0x04c6('0x77')]['get']({'plain':!![]});if(!_0xf5c99){return _0x1b2ff4[_0x04c6('0x1c')](0x191)[_0x04c6('0x35')]('Unable\x20to\x20retrieve\x20the\x20current\x20user');}else{return _0x1b2ff4['status'](0xc8)[_0x04c6('0x23')](_0xf5c99);}};exports[_0x04c6('0x171')]=function(_0x3159e0,_0x54dc1f){var _0x78cb6d={'offset':0x0},_0xa2fe3d={'count':0x0,'rows':[]};Promise[_0x04c6('0x172')]()[_0x04c6('0x25')](function(){if(!_0x3159e0[_0x04c6('0x3c')][_0x04c6('0x2d')]&&!_0x3159e0[_0x04c6('0x3c')]['teams']&&!_0x3159e0[_0x04c6('0x3c')][_0x04c6('0x173')])return[];return Promise['resolve']()[_0x04c6('0x25')](function(){var _0x834dff=[];if(!_['isEmpty'](_0x3159e0['query']['teams'])){_0x834dff['push'](db['Team']['findAll']({'attributes':['id',_0x04c6('0x33')],'where':{'id':_0x3159e0['query'][_0x04c6('0x174')]}}));}if(!_['isEmpty'](_0x3159e0[_0x04c6('0x3c')][_0x04c6('0x173')])){_0x834dff[_0x04c6('0x3f')](db[_0x04c6('0xa3')][_0x04c6('0x40')]({'attributes':['id',_0x04c6('0x33')],'type':_0x04c6('0x175'),'where':{'id':_0x3159e0[_0x04c6('0x3c')][_0x04c6('0x173')]}}));}return Promise[_0x04c6('0x48')](_0x834dff);})[_0x04c6('0x25')](function(_0x2ed3bd){var _0x1717f7=_[_0x04c6('0x113')](_0x2ed3bd)[_0x04c6('0x2f')](function(_0x3c0fa0){return _0x3c0fa0[_0x04c6('0x121')]({'attributes':['id',_0x04c6('0x33'),_0x04c6('0x5b'),'online'],'raw':!![]});});return Promise[_0x04c6('0x48')](_0x1717f7);})[_0x04c6('0x25')](function(_0x58fc2e){var _0x2b3531=_[_0x04c6('0x113')](_0x58fc2e);if(!_0x3159e0[_0x04c6('0x3c')]['filter'])return _0x2b3531;if(_[_0x04c6('0x176')](_0x2b3531)){return db[_0x04c6('0x3b')][_0x04c6('0x40')]({'attributes':['id',_0x04c6('0x33'),'internal',_0x04c6('0x95')],'where':{'role':_0x04c6('0x2a'),'$or':[db[_0x04c6('0x63')][_0x04c6('0x3a')](db[_0x04c6('0x63')]['fn'](_0x04c6('0x177'),db[_0x04c6('0x63')][_0x04c6('0x178')](_0x04c6('0x33'))),{'$like':'%'+_0x3159e0[_0x04c6('0x3c')][_0x04c6('0x2d')]['toLowerCase']()+'%'}),{'internal':{'$like':'%'+_0x3159e0['query'][_0x04c6('0x2d')]+'%'}}]},'raw':!![]});}else{return _(_0x2b3531)[_0x04c6('0x113')]()[_0x04c6('0x2d')](function(_0x4a7bd3){return _0x4a7bd3[_0x04c6('0x33')][_0x04c6('0x9c')]()['includes'](_0x3159e0['query'][_0x04c6('0x2d')][_0x04c6('0x9c')]())||_0x4a7bd3[_0x04c6('0x5b')][_0x04c6('0x179')]()['includes'](_0x3159e0[_0x04c6('0x3c')][_0x04c6('0x2d')]);})[_0x04c6('0x30')]();}})[_0x04c6('0x25')](function(_0x1c1c24){var _0x4d65be='name';var _0x513d61='asc';if(_0x3159e0['query'][_0x04c6('0xc4')]){var _0x513d61=_0x3159e0[_0x04c6('0x3c')][_0x04c6('0xc4')][0x0]==='-'?_0x04c6('0x17a'):_0x04c6('0x17b');var _0x4d65be=_0x513d61===_0x04c6('0x17b')?_0x3159e0[_0x04c6('0x3c')][_0x04c6('0xc4')]:_0x3159e0[_0x04c6('0x3c')][_0x04c6('0xc4')][_0x04c6('0x17c')](0x1);}return _(_0x1c1c24)[_0x04c6('0x17d')]('id')['orderBy']([function(_0x54b060){return _0x4d65be===_0x04c6('0x33')?_0x54b060[_0x4d65be][_0x04c6('0x9c')]():_0x54b060[_0x4d65be];}],[_0x513d61])[_0x04c6('0x2f')](function(_0x115770){return _[_0x04c6('0xcf')](_0x115770,['id',_0x04c6('0x33'),_0x04c6('0x5b'),_0x04c6('0x95')]);})[_0x04c6('0x30')]();})[_0x04c6('0x25')](function(_0x4eb944){return client['request'](_0x04c6('0x29'),_0x3159e0)[_0x04c6('0x25')](function(_0x552291){if(_0x552291['error'])throw new Error(_0x04c6('0x17e'));var _0x20a551=_0x552291[_0x04c6('0x17f')];var _0x4304bf=jayson[_0x04c6('0x180')][_0x04c6('0x10')]({'port':0x232c});return _0x4304bf[_0x04c6('0x11')](_0x04c6('0x29'),_0x3159e0)['then'](function(_0x1fb26d){if(_0x1fb26d['error'])throw new Error(_0x04c6('0x181'));var _0x2fd72a=_0x1fb26d[_0x04c6('0x17f')];return _['merge']({},_0x2fd72a,_0x20a551);});})[_0x04c6('0x25')](function(_0x4471ec){return _[_0x04c6('0x2f')](_0x4eb944,function(_0x116458){var _0x2746e5=_['find'](_0x4471ec[_0x04c6('0x41')],['id',_0x116458['id']]);if(!_0x2746e5||!_0x116458['online']){_0x116458[_0x04c6('0x1c')]='offline';}else if(_0x2746e5[_0x04c6('0xa6')]){_0x116458['status']=_0x04c6('0xf5');}else{_0x116458[_0x04c6('0x1c')]=_[_0x04c6('0x31')]([_0x04c6('0x182'),'unknown',_0x04c6('0x183'),'ringing',null,undefined],_0x2746e5[_0x04c6('0x184')])?_0x04c6('0x95'):'busy';}return _0x116458;});});});})[_0x04c6('0x25')](function(_0x42cd18){if(!_0x3159e0['query'][_0x04c6('0xc6')]('nolimit')){_0x78cb6d['limit']=qs['limit'](_0x3159e0[_0x04c6('0x3c')][_0x04c6('0x20')]||0xa);_0x78cb6d[_0x04c6('0x1e')]=qs[_0x04c6('0x1e')](_0x3159e0[_0x04c6('0x3c')][_0x04c6('0x1e')]);}_0xa2fe3d[_0x04c6('0x21')]=_0x42cd18[_0x04c6('0x42')];_0xa2fe3d[_0x04c6('0x41')]=_0x78cb6d[_0x04c6('0x20')]?_0x42cd18['slice'](_0x78cb6d[_0x04c6('0x1e')],_0x78cb6d[_0x04c6('0x1e')]+_0x78cb6d[_0x04c6('0x20')]):_0x42cd18;return _0xa2fe3d;})['then'](respondWithFilteredResult(_0x54dc1f,_0x78cb6d))[_0x04c6('0x1b')](handleError(_0x54dc1f,null));};function get_open_tabs(_0x31f312,_0x598e1c){var _0x49296b=_0x31f312['charAt'](0x0)['toUpperCase']()+_0x31f312['slice'](0x1);var _0x23d12e={'type':db[_0x04c6('0x8c')][_0x04c6('0x185')][_0x04c6('0x186')],'raw':!![]};return new BPromise(function(_0x31059d,_0x19cf65){var _0x255d00=squel[_0x04c6('0x187')]()['field']('ui.'+_0x49296b+_0x04c6('0x188'),'id')[_0x04c6('0x189')](_0x04c6('0x18a'))['from'](_0x04c6('0x18b')+_0x31f312+_0x04c6('0x18c'),'ui')['where'](_0x04c6('0x18d'),_0x598e1c['id']);return db[_0x04c6('0x63')][_0x04c6('0x3c')](_0x255d00[_0x04c6('0x179')](),_0x23d12e)['then'](function(_0x2b6697){_0x598e1c[_0x49296b+_0x04c6('0x18e')]=_0x2b6697;_0x31059d(_0x2b6697);})['catch'](function(_0x34d74f){_0x19cf65(_0x34d74f);});});};
\ No newline at end of file