Built motion from commit b5996064.|2.6.21
[motion2.git] / server / api / user / user.controller.js
index 12cf1da..d99ab2f 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 _0xc402=['emit','destroy','get','role','admin','Users','Agents','Telephones','telephone','filter','ignore','value','includes','find','UserProfileResource','error','name','send','User','map','fieldName','type','key','salt','resetPasswordToken','getOptions','where','query','includeAll','include','true','UserSetting','userSetting','attributes','push','findAll','rows','dataValues','sms','fax','mail','openchannel','all','catch','show','params','options','whatsapp','body','describe','ids','omit','internal','Setting','findById','securePassword','password','max','isNil','min_internal','sequelize','select\x20(select\x20IFNULL(max(internal)+1,1)\x20from\x20users\x20where\x20internal\x20<\x20md.internal)\x20as\x20\x27from\x27,\x20md.internal\x20-\x201\x20as\x20\x27to\x27\x20from\x20users\x20md\x20where\x20md.internal\x20!=\x201\x20and\x20not\x20exists\x20(select\x201\x20from\x20users\x20md2\x20where\x20md2.internal\x20=\x20md.internal\x20-\x201)','QueryTypes','SELECT','length','from','mailbox','VoiceMail','fullname','email','permissions','101','102','103','110','104','105','106','107','108','109','100','111','114','115','create','user','Unauthorized','Unauthorized.\x20You\x20must\x20be\x20an\x20administrator\x20in\x20order\x20to\x20create\x20an\x20user','Unauthorized.\x20You\x20must\x20be\x20an\x20administrator\x20in\x20order\x20to\x20create\x20another\x20administrator','checkUserLimits','settingsEnabled','userProfileId','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','bulkCreate','some','UserProfileSection','autoAssociation','compact','changePassword','oldPassword','newPassword','ValidationError','Invalid\x20body\x20format.\x20Use\x20oldPassword\x20and\x20newPassword','authenticate','Sequelize','New\x20password\x20must\x20be\x20different\x20from\x20old\x20password','Invalid\x20body\x20format.\x20Use\x20newPassword','findOne','enforcePasswordHistory','passwordHistoryLimit','validatePasswordPattern','previousPasswords','validatePasswordHistory','updatePasswordsHistory','addQueues','online','loginInPause','voicePause','interface','isValidChannel','Unknown\x20channel','capitalize','toLowerCase','penalty','spread','QueueId','Queue:save','format','SIP/%s','UserVoiceQueueRt','upsert','channel','Queues','Queue:remove','voice','addAvatar','file','filename','getAvatar','join','userpic','download','existsSync','root','server/files/images/','chat','ChatOpenTabs','createdAt','FAX','OpenchannelOpenTabs','OPENCHANNEL','MailOpenTabs','MAIL','SmsOpenTabs','SMS','WhatsappOpenTabs','WHATSAPP','User\x20with\x20id\x20%s\x20not\x20found','List','Tags','color','tag','model','Queue','rawAttributes','keys','filters','intersection','fields','sort','pick','merge','Unknown\x20role','hasOwnProperty','nolimit','order','getVoiceQueuesRt','ChatGroup','getGroups','getRecordings','VoiceRecording','UserId','getScreenRecordings','ScreenRecording','getChatInteractions','getOpenchannelInteractions','OpenchannelInteraction','getMailInteractions','MailInteraction','getSmsInteractions','SmsInteraction','getFaxInteractions','getWhatsappInteractions','WhatsappInteraction','login','phone','LOCAL/%s@from-sip/n','intrf','user:%s','user:forcelogout','headers','x-forwarded-for','connection','remoteAddress','socket','getVoiceQueues','UserVoiceQueue.penalty','MemberReport','YYYY-MM-DD\x20HH:mm:ss','LOGIN','LOGININPAUSE','resolve','logout','forEach','pause','PAUSE','updateAttributes','DEFAULT\x20PAUSE','unpause','Channel\x20parameter\x20%s\x20is\x20invalid','mailPause','chatPause','smsPause','whatsappPause','lastPauseAt','getTeams','Team','addTeams','Body\x20parameter\x20\x27ids\x27\x20is\x20required','transaction','getAssociatedQueues','flattenDeep','addAgent','getDataValue','Voice','TeamVoicePrefix','UserVoicePrefix','VoicePrefixId','removeTeams','isArray','removeAgent','getLists','CmList','getAgents','values','You\x20can\x27t\x20delete\x20yourself','addChatInteractions','user_has_chat_interactions:save','removeChatInteractions','user_has_chat_interactions:remove','addMailInteractions','user_has_mail_interactions:save','removeMailInteractions','user_has_mail_interactions:remove','addFaxInteractions','user_has_fax_interactions:save','removeFaxInteractions','user_has_fax_interactions:remove','addSmsInteractions','user_has_sms_interactions:save','removeSmsInteractions','user_has_sms_interactions:remove','addOpenchannelInteractions','removeOpenchannelInteractions','user_has_openchannel_interactions:remove','addWhatsappInteractions','user_has_whatsapp_interactions:save','removeWhatsappInteractions','getVoicePrefixes','VoicePrefix','getFaxAccounts','FaxAccount','addFaxAccounts','removeFaxAccounts','MailAccount','getMailAccounts','addMailAccounts','getOpenchannelAccounts','OpenchannelAccount','addOpenchannelAccounts','removeOpenchannelAccounts','SmsAccount','getSmsAccounts','addSmsAccounts','removeSmsAccounts','getChatWebsites','addChatWebsites','removeChatWebsites','getWhatsappAccounts','addWhatsappAccounts','removeWhatsappAccounts','getScheduledCalls','CmHopper','concat','$and','$or','$gt','$lt','$lte','$ne','$eq','$not','$between','$notBetween','$notIn','$like','$notLike','$iLike','$notILike','$overlap','$contains','$contained','firstName','lastName','Contact','dialActive','VoiceQueue','getApiKey','token','No\x20API\x20access\x20key\x20found!','You\x20don\x27t\x20have\x20sufficient\x20privileges\x20to\x20access\x20this\x20resource.','createApiKey','generateApiKey','nonce','removeApiKey','apiKeyNonce','apiKeyIat','API\x20key\x20not\x20available','whoami','Unable\x20to\x20retrieve\x20the\x20current\x20user','getUserSetting','getPresence','idle','unknown','ringing','teams','queues','inbound','flatten','toString','lower','col','asc','substring','uniqBy','offline','voiceStatus','unavailable','slice','toUpperCase','select','InteractionId','ui.createdAt','user_has_','ui.UserId\x20=\x20?','OpenTabs','messengerSoundNotification','util','path','lodash','ioredis','../../components/auth/service','../../components/contacts','../../components/parsers/qs','../../components/realtime/agents','../../config/logger','api','../../config/environment','../../config/license/util','../../errors/api','APIBadRequestError','APINotFoundError','handleError','../../mysqldb','redis','./user.socket','register','sendStatus','status','end','offset','undefined','limit','count','json','update','then','agent'];(function(_0x36b064,_0x3d09dc){var _0x367678=function(_0x32593e){while(--_0x32593e){_0x36b064['push'](_0x36b064['shift']());}};_0x367678(++_0x3d09dc);}(_0xc402,0x166));var _0x2c40=function(_0x906c25,_0x468423){_0x906c25=_0x906c25-0x0;var _0x30dc66=_0xc402[_0x906c25];return _0x30dc66;};'use strict';var moment=require('moment');var util=require(_0x2c40('0x0'));var path=require(_0x2c40('0x1'));var fs=require('fs');var _=require(_0x2c40('0x2'));var squel=require('squel');var Redis=require(_0x2c40('0x3'));var authService=require(_0x2c40('0x4'));var contacts=require(_0x2c40('0x5'));var qs=require(_0x2c40('0x6'));var rta=require(_0x2c40('0x7'));var logger=require(_0x2c40('0x8'))(_0x2c40('0x9'));var utils=require('../../config/utils');var config=require(_0x2c40('0xa'));var licenseUtil=require(_0x2c40('0xb'));var APIBadRequestError=require(_0x2c40('0xc'))[_0x2c40('0xd')];var APINotFoundError=require(_0x2c40('0xc'))[_0x2c40('0xe')];var APIHandleError=require(_0x2c40('0xc'))[_0x2c40('0xf')];var db=require(_0x2c40('0x10'))['db'];var socket=require('socket.io-emitter')(new Redis(config[_0x2c40('0x11')]));require(_0x2c40('0x12'))[_0x2c40('0x13')](socket);config[_0x2c40('0x11')]=_['defaults'](config[_0x2c40('0x11')],{'host':'localhost','port':0x18eb});var values;function respondWithStatusCode(_0x409206,_0x6a5486){_0x6a5486=_0x6a5486||0xcc;return function(_0x1e9ec2){if(_0x1e9ec2){return _0x409206[_0x2c40('0x14')](_0x6a5486);}return _0x409206[_0x2c40('0x15')](_0x6a5486)[_0x2c40('0x16')]();};}function respondWithResult(_0x5a568a,_0x3057b1){_0x3057b1=_0x3057b1||0xc8;return function(_0x5eaba3){if(_0x5eaba3){return _0x5a568a[_0x2c40('0x15')](_0x3057b1)['json'](_0x5eaba3);}};}function respondWithFilteredResult(_0x43a773,_0x19d4a5){return function(_0xb3d3f1){if(_0xb3d3f1){var _0x51e586=typeof _0x19d4a5[_0x2c40('0x17')]===_0x2c40('0x18')&&typeof _0x19d4a5[_0x2c40('0x19')]===_0x2c40('0x18');var _0x3eeb45=_0xb3d3f1[_0x2c40('0x1a')];var _0x28526e=_0x51e586?0x0:_0x19d4a5[_0x2c40('0x17')];var _0x25b1ec=_0x51e586?_0xb3d3f1[_0x2c40('0x1a')]:_0x19d4a5[_0x2c40('0x17')]+_0x19d4a5['limit'];var _0x2d042d;if(_0x25b1ec>=_0x3eeb45){_0x25b1ec=_0x3eeb45;_0x2d042d=0xc8;}else{_0x2d042d=0xce;}_0x43a773[_0x2c40('0x15')](_0x2d042d);return _0x43a773['set']('Content-Range',_0x28526e+'-'+_0x25b1ec+'/'+_0x3eeb45)[_0x2c40('0x1b')](_0xb3d3f1);}return null;};}function saveUpdates(_0x483af0){return function(_0x2799c0){if(_0x2799c0){return _0x2799c0[_0x2c40('0x1c')](_0x483af0)[_0x2c40('0x1d')](function(_0x401111){if(_0x401111['role']===_0x2c40('0x1e')){socket[_0x2c40('0x1f')]('userNotification:recalc:'+_0x401111['id'],_0x401111);}return _0x401111;});}return null;};}function removeEntity(_0x1b1ac6){return function(_0x217f9a){if(_0x217f9a){return _0x217f9a[_0x2c40('0x20')]()[_0x2c40('0x1d')](function(){var _0x2a40c1=_0x217f9a[_0x2c40('0x21')]({'plain':!![]});if(_0x2a40c1[_0x2c40('0x22')]===_0x2c40('0x23'))return;var _0x13db8b=[{'name':_0x2c40('0x24'),'value':'user','ignore':!![]},{'name':_0x2c40('0x25'),'value':_0x2c40('0x1e'),'ignore':![]},{'name':_0x2c40('0x26'),'value':_0x2c40('0x27'),'ignore':![]}];var _0xc19e77=_(_0x13db8b)[_0x2c40('0x28')](_0x2c40('0x29'))['map'](_0x2c40('0x2a'))[_0x2c40('0x2a')]();if(_[_0x2c40('0x2b')](_0xc19e77,_0x2a40c1[_0x2c40('0x22')])){return;}var _0x497e8a=_[_0x2c40('0x2c')](_0x13db8b,[_0x2c40('0x2a'),_0x2a40c1[_0x2c40('0x22')]])['name'];return db[_0x2c40('0x2d')][_0x2c40('0x20')]({'where':{'type':_0x497e8a,'resourceId':_0x2a40c1['id']}})['then'](function(){return _0x217f9a;});})[_0x2c40('0x1d')](function(){_0x1b1ac6[_0x2c40('0x15')](0xcc)[_0x2c40('0x16')]();});}};}function handleEntityNotFound(_0x5f4f59){return function(_0x25d77a){if(!_0x25d77a){_0x5f4f59[_0x2c40('0x14')](0x194);}return _0x25d77a;};}function handleError(_0x46ebbf,_0xe6f6ad){_0xe6f6ad=_0xe6f6ad||0x1f4;return function(_0x147303){logger[_0x2c40('0x2e')](_0x147303['stack']);if(_0x147303['name']){delete _0x147303[_0x2c40('0x2f')];}_0x46ebbf['status'](_0xe6f6ad)[_0x2c40('0x30')](_0x147303);};}function getUserAttributes(){return _(db[_0x2c40('0x31')]['rawAttributes'])[_0x2c40('0x32')](function(_0x2a023b){return{'name':_0x2a023b[_0x2c40('0x33')],'type':_0x2a023b[_0x2c40('0x34')][_0x2c40('0x35')]};})[_0x2c40('0x28')](function(_0x246556){return!['password',_0x2c40('0x36'),'previousPasswords',_0x2c40('0x37'),'resetPasswordExpires','md5secret'][_0x2c40('0x2b')](_0x246556['name']);})['value']();}exports['index']=function(_0x418ef3,_0x2db019){var _0x59808a={},_0x3d0345={'count':0x0,'rows':[]};var _0x583104=getUserAttributes();_0x59808a=qs[_0x2c40('0x38')](_0x583104,_0x418ef3);var _0x1825f7={'where':_0x59808a[_0x2c40('0x39')]};return db[_0x2c40('0x31')][_0x2c40('0x1a')](_0x1825f7)[_0x2c40('0x1d')](function(_0x32fb8d){_0x3d0345['count']=_0x32fb8d;if(_0x418ef3[_0x2c40('0x3a')][_0x2c40('0x3b')]){_0x59808a[_0x2c40('0x3c')]=[{'all':!![]}];}if(_0x418ef3[_0x2c40('0x3a')]['userSetting']===_0x2c40('0x3d')){_0x59808a[_0x2c40('0x3c')]=[{'model':db[_0x2c40('0x3e')],'as':_0x2c40('0x3f')}];}if(!_[_0x2c40('0x2b')](_0x59808a[_0x2c40('0x40')],'id')){_0x59808a[_0x2c40('0x40')][_0x2c40('0x41')]('id');}return db[_0x2c40('0x31')][_0x2c40('0x42')](_0x59808a);})[_0x2c40('0x1d')](function(_0x14b63c){_0x3d0345[_0x2c40('0x43')]=_0x14b63c;if(_0x418ef3['query']['openTabs']===_0x2c40('0x3d')){var _0x39eb82=[];for(var _0x1e522c=0x0;_0x1e522c<_0x3d0345[_0x2c40('0x43')]['length'];_0x1e522c++){_0x39eb82[_0x2c40('0x41')](get_open_tabs('chat',_0x3d0345['rows'][_0x1e522c][_0x2c40('0x44')]));_0x39eb82[_0x2c40('0x41')](get_open_tabs(_0x2c40('0x45'),_0x3d0345[_0x2c40('0x43')][_0x1e522c][_0x2c40('0x44')]));_0x39eb82[_0x2c40('0x41')](get_open_tabs(_0x2c40('0x46'),_0x3d0345[_0x2c40('0x43')][_0x1e522c][_0x2c40('0x44')]));_0x39eb82['push'](get_open_tabs(_0x2c40('0x47'),_0x3d0345['rows'][_0x1e522c][_0x2c40('0x44')]));_0x39eb82[_0x2c40('0x41')](get_open_tabs(_0x2c40('0x48'),_0x3d0345['rows'][_0x1e522c][_0x2c40('0x44')]));_0x39eb82[_0x2c40('0x41')](get_open_tabs('whatsapp',_0x3d0345[_0x2c40('0x43')][_0x1e522c][_0x2c40('0x44')]));}return Promise[_0x2c40('0x49')](_0x39eb82)['then'](function(){return _0x3d0345;});}else{return _0x3d0345;}})['then'](respondWithFilteredResult(_0x2db019,_0x59808a))[_0x2c40('0x4a')](handleError(_0x2db019,null));};exports[_0x2c40('0x4b')]=function(_0x5bf43e,_0xf0f5ec){var _0x46ca4e=getUserAttributes();_0x5bf43e[_0x2c40('0x3a')]['id']=_0x5bf43e[_0x2c40('0x4c')]['id'];var _0x39cac5=qs[_0x2c40('0x38')](_0x46ca4e,_0x5bf43e);if(_0x5bf43e[_0x2c40('0x3a')][_0x2c40('0x3b')]){_0x39cac5[_0x2c40('0x3c')]=[{'all':!![]}];}if(_0x5bf43e[_0x2c40('0x3a')][_0x2c40('0x3f')]==='true'){_0x39cac5['include']=[{'model':db[_0x2c40('0x3e')],'as':_0x2c40('0x3f')}];}_0x39cac5=_['merge']({},_0x39cac5,_0x5bf43e[_0x2c40('0x4d')]);if(!_[_0x2c40('0x2b')](_0x39cac5[_0x2c40('0x40')],'id')){_0x39cac5[_0x2c40('0x40')][_0x2c40('0x41')]('id');}return db['User'][_0x2c40('0x2c')](_0x39cac5)[_0x2c40('0x1d')](handleEntityNotFound(_0xf0f5ec,null))[_0x2c40('0x1d')](function(_0x5a2c6a){var _0x60609e=[];values=_0x5a2c6a;if(_0x5bf43e[_0x2c40('0x3a')]['openTabs']==='true'){_0x60609e[_0x2c40('0x41')](get_open_tabs('chat',_0x5a2c6a[_0x2c40('0x44')]));_0x60609e[_0x2c40('0x41')](get_open_tabs('sms',_0x5a2c6a[_0x2c40('0x44')]));_0x60609e[_0x2c40('0x41')](get_open_tabs(_0x2c40('0x48'),_0x5a2c6a['dataValues']));_0x60609e[_0x2c40('0x41')](get_open_tabs(_0x2c40('0x4e'),_0x5a2c6a['dataValues']));_0x60609e[_0x2c40('0x41')](get_open_tabs(_0x2c40('0x46'),_0x5a2c6a[_0x2c40('0x44')]));_0x60609e['push'](get_open_tabs(_0x2c40('0x47'),_0x5a2c6a['dataValues']));return Promise[_0x2c40('0x49')](_0x60609e);}else{return values;}})['then'](function(){return values;})['then'](respondWithResult(_0xf0f5ec,null))['catch'](handleError(_0xf0f5ec,null));};exports[_0x2c40('0x1c')]=function(_0x1fe724,_0x206eb2){if(_0x1fe724[_0x2c40('0x4f')]['id']){delete _0x1fe724[_0x2c40('0x4f')]['id'];}delete _0x1fe724[_0x2c40('0x4f')]['role'];return db[_0x2c40('0x31')][_0x2c40('0x2c')]({'where':{'id':_0x1fe724[_0x2c40('0x4c')]['id']}})[_0x2c40('0x1d')](handleEntityNotFound(_0x206eb2,null))[_0x2c40('0x1d')](saveUpdates(_0x1fe724[_0x2c40('0x4f')],null))[_0x2c40('0x1d')](respondWithResult(_0x206eb2,null))[_0x2c40('0x4a')](handleError(_0x206eb2,null));};exports[_0x2c40('0x50')]=function(_0x953a44,_0x5c8b3c){return db[_0x2c40('0x31')][_0x2c40('0x50')]()[_0x2c40('0x1d')](respondWithResult(_0x5c8b3c,null))[_0x2c40('0x4a')](handleError(_0x5c8b3c,null));};exports['addContacts']=function(_0xa6d825,_0x13ac13){return db[_0x2c40('0x31')][_0x2c40('0x2c')]({'where':{'id':_0xa6d825[_0x2c40('0x4c')]['id']}})[_0x2c40('0x1d')](handleEntityNotFound(_0x13ac13,null))['then'](function(_0x20f3ba){if(_0x20f3ba){return _0x20f3ba['addContacts'](_0xa6d825[_0x2c40('0x4f')][_0x2c40('0x51')],_[_0x2c40('0x52')](_0xa6d825['body'],['ids','id'])||{});}})[_0x2c40('0x1d')](respondWithResult(_0x13ac13,null))[_0x2c40('0x4a')](handleError(_0x13ac13,null));};function validateUser(_0x1a8bb4){return new Promise(function(_0x24ddcd,_0x5de923){if(_0x1a8bb4[_0x2c40('0x53')])return _0x24ddcd(_0x1a8bb4);return db[_0x2c40('0x54')][_0x2c40('0x55')](0x1)[_0x2c40('0x1d')](function(_0x3d7fb1){if(_0x3d7fb1[_0x2c40('0x56')])authService['validatePasswordPattern'](_0x1a8bb4[_0x2c40('0x57')]);db[_0x2c40('0x31')][_0x2c40('0x58')](_0x2c40('0x53'))[_0x2c40('0x1d')](function(_0x42e788){if(_[_0x2c40('0x59')](_0x42e788)){_0x1a8bb4['internal']=_0x3d7fb1[_0x2c40('0x5a')]||0x1;return;}if(_[_0x2c40('0x59')](_0x3d7fb1['min_internal'])||_0x3d7fb1[_0x2c40('0x5a')]===_0x42e788){_0x1a8bb4['internal']=_0x42e788+0x1;return;}if(_0x3d7fb1[_0x2c40('0x5a')]>_0x42e788){_0x1a8bb4['internal']=_0x3d7fb1[_0x2c40('0x5a')];return;}return db[_0x2c40('0x5b')]['query'](_0x2c40('0x5c'),{'type':db[_0x2c40('0x5b')][_0x2c40('0x5d')][_0x2c40('0x5e')]})[_0x2c40('0x1d')](function(_0x47e0f8){if(_0x47e0f8&&_0x47e0f8[_0x2c40('0x5f')]){for(var _0x23de9d=0x0,_0x4ea715=_0x47e0f8['length'];_0x23de9d<_0x4ea715&&_[_0x2c40('0x59')](_0x1a8bb4[_0x2c40('0x53')]);_0x23de9d++){if(_0x3d7fb1[_0x2c40('0x5a')]<=_0x47e0f8[_0x23de9d][_0x2c40('0x60')]){_0x1a8bb4['internal']=_0x47e0f8[_0x23de9d][_0x2c40('0x60')];}else if(_0x3d7fb1[_0x2c40('0x5a')]>_0x47e0f8[_0x23de9d][_0x2c40('0x60')]&&_0x3d7fb1[_0x2c40('0x5a')]<=_0x47e0f8[_0x23de9d]['to']){_0x1a8bb4['internal']=_0x3d7fb1['min_internal'];}}}if(_['isNil'](_0x1a8bb4[_0x2c40('0x53')])){_0x1a8bb4['internal']=_0x42e788+0x1;}return _0x24ddcd(_0x1a8bb4);});});})[_0x2c40('0x4a')](function(_0x78c53e){_0x5de923(_0x78c53e);});});}function updateUser(_0xde130b){return new Promise(function(_0x5ecb29,_0x224ad7){try{if(_0xde130b['voicemail']){_0xde130b[_0x2c40('0x61')]=_0xde130b[_0x2c40('0x53')];_0xde130b[_0x2c40('0x62')]={'mailbox':_0xde130b[_0x2c40('0x53')],'password':_0xde130b[_0x2c40('0x57')],'fullname':_0xde130b[_0x2c40('0x63')],'email':_0xde130b[_0x2c40('0x64')]};}if(_0xde130b[_0x2c40('0x22')]===_0x2c40('0x1e')){if(!_0xde130b[_0x2c40('0x65')])_0xde130b[_0x2c40('0x65')]=[_0x2c40('0x66'),_0x2c40('0x67'),_0x2c40('0x68'),'113',_0x2c40('0x69'),_0x2c40('0x6a'),_0x2c40('0x6b'),_0x2c40('0x6c'),_0x2c40('0x6d'),_0x2c40('0x6e'),_0x2c40('0x6f'),_0x2c40('0x70'),_0x2c40('0x71'),_0x2c40('0x72'),_0x2c40('0x73')];}_0x5ecb29(_0xde130b);}catch(_0x34f5ca){_0x224ad7(_0x34f5ca);}});}exports[_0x2c40('0x74')]=function(_0x465af8,_0x19b8cf){if(_0x465af8[_0x2c40('0x75')][_0x2c40('0x22')]==='agent')throw new Error(_0x2c40('0x76'));if(_0x465af8['body'][_0x2c40('0x22')]===_0x2c40('0x75')&&_0x465af8[_0x2c40('0x75')][_0x2c40('0x22')]!==_0x2c40('0x23')){throw new Error(_0x2c40('0x77'));}if(_0x465af8[_0x2c40('0x4f')]['role']===_0x2c40('0x23')&&_0x465af8['user'][_0x2c40('0x22')]!=='admin'){throw new Error(_0x2c40('0x78'));}return licenseUtil[_0x2c40('0x79')]([_0x465af8[_0x2c40('0x4f')]])[_0x2c40('0x1d')](function(){return validateUser(_0x465af8[_0x2c40('0x4f')]);})[_0x2c40('0x1d')](function(_0x25a2a2){return updateUser(_0x25a2a2)[_0x2c40('0x1d')](function(_0x4d908d){if(_0x4d908d[_0x2c40('0x22')]==='admin'){_0x4d908d[_0x2c40('0x7a')]=_0x465af8[_0x2c40('0x75')][_0x2c40('0x7a')];delete _0x4d908d[_0x2c40('0x7b')];}return _0x4d908d;});})[_0x2c40('0x1d')](function(_0x3e3fe2){return db['User']['create'](_0x3e3fe2,{'include':[{'model':db['VoiceMail'],'as':_0x2c40('0x62')}]});})['then'](function(_0x2a2a88){if(_0x465af8[_0x2c40('0x4f')][_0x2c40('0x22')]==='user')return _0x2a2a88;if(_0x465af8['user'][_0x2c40('0x22')]!=='user')return _0x2a2a88;return db['UserProfileSection'][_0x2c40('0x2c')]({'where':{'name':_0x2a2a88['role']===_0x2c40('0x1e')?_0x2c40('0x25'):_0x2c40('0x26'),'userProfileId':_0x465af8[_0x2c40('0x75')][_0x2c40('0x7b')]},'raw':!![]})[_0x2c40('0x1d')](function(_0x529336){if(!_0x529336||_0x529336['autoAssociation']!=0x0)return _0x2a2a88;return db[_0x2c40('0x2d')][_0x2c40('0x74')]({'name':_0x2a2a88['name'],'resourceId':_0x2a2a88['id'],'type':_0x529336[_0x2c40('0x2f')],'sectionId':_0x529336['id']},{})['then'](function(){return _0x2a2a88;});})[_0x2c40('0x4a')](function(_0x3514af){logger['error'](_0x2c40('0x7c'),_0x3514af);throw _0x3514af;});})[_0x2c40('0x1d')](respondWithResult(_0x19b8cf,0xc9))[_0x2c40('0x4a')](handleError(_0x19b8cf,null));};exports[_0x2c40('0x7d')]=function(_0x285919,_0x2d1cfb){var _0x18edfb=_0x285919[_0x2c40('0x4f')];var _0x540a72=[];if(_0x285919[_0x2c40('0x75')]['role']===_0x2c40('0x1e'))throw new Error(_0x2c40('0x76'));if(_[_0x2c40('0x7e')](_0x18edfb,['role',_0x2c40('0x75')])&&_0x285919[_0x2c40('0x75')][_0x2c40('0x22')]!==_0x2c40('0x23')){throw new Error('Unauthorized.\x20You\x20must\x20be\x20an\x20administrator\x20in\x20order\x20to\x20create\x20an\x20user');}if(_[_0x2c40('0x7e')](_0x18edfb,[_0x2c40('0x22'),_0x2c40('0x23')])&&_0x285919[_0x2c40('0x75')][_0x2c40('0x22')]!=='admin'){throw new Error('Unauthorized.\x20You\x20must\x20be\x20an\x20administrator\x20in\x20order\x20to\x20create\x20an\x20administrator');}return licenseUtil[_0x2c40('0x79')](_0x18edfb)[_0x2c40('0x1d')](function(){return validateUser(_0x18edfb[0x0]);})['then'](function(){for(var _0x483ba7=0x1;_0x483ba7<_0x18edfb['length'];_0x483ba7++){var _0x26aee3=_0x18edfb[_0x483ba7-0x1]['internal'];if(!_0x18edfb[_0x483ba7][_0x2c40('0x53')])_0x18edfb[_0x483ba7][_0x2c40('0x53')]=_0x26aee3+0x1;_0x540a72['push'](validateUser(_0x18edfb[_0x483ba7]));}return Promise[_0x2c40('0x49')](_0x540a72);})[_0x2c40('0x1d')](function(){_0x540a72=[];for(var _0x4e1fdc=0x0;_0x4e1fdc<_0x18edfb[_0x2c40('0x5f')];_0x4e1fdc++){_0x540a72[_0x2c40('0x41')](updateUser(_0x18edfb[_0x4e1fdc]));}return Promise[_0x2c40('0x49')](_0x540a72);})[_0x2c40('0x1d')](function(){_0x540a72=_0x18edfb[_0x2c40('0x32')](function(_0x59d8d1){return db[_0x2c40('0x31')][_0x2c40('0x74')](_0x59d8d1,{'include':[{'model':db[_0x2c40('0x62')],'as':_0x2c40('0x62')}]})[_0x2c40('0x1d')](function(_0x4dc666){_0x59d8d1['id']=_0x4dc666['id'];return _0x59d8d1;});});return Promise[_0x2c40('0x49')](_0x540a72);})[_0x2c40('0x1d')](function(_0x84ec34){if(_0x285919[_0x2c40('0x4f')][_0x2c40('0x22')]==='user')return _0x84ec34;if(_0x285919[_0x2c40('0x75')]['role']!==_0x2c40('0x75'))return _0x84ec34;var _0x4f823e=_[_0x2c40('0x7e')](_0x84ec34,function(_0x48b7f0){return _0x48b7f0[_0x2c40('0x22')]===_0x2c40('0x1e')||_0x48b7f0[_0x2c40('0x22')]==='telephone';});if(!_0x4f823e)return _0x84ec34;return db[_0x2c40('0x7f')]['findAll']({'where':{'name':{'$or':[_0x2c40('0x25'),_0x2c40('0x26')]},'userProfileId':_0x285919[_0x2c40('0x75')][_0x2c40('0x7b')]},'raw':!![]})[_0x2c40('0x1d')](function(_0x33ce4a){if(_['isEmpty'](_0x33ce4a)||!_[_0x2c40('0x7e')](_0x33ce4a,[_0x2c40('0x80'),0x0]))return _0x84ec34;_0x540a72=[];var _0x298dac=_(_0x33ce4a)['map'](function(_0x4aa1e2){if(_0x4aa1e2[_0x2c40('0x80')]===0x1)return;return _0x4aa1e2['name']===_0x2c40('0x25')?_0x2c40('0x1e'):'telephone';})[_0x2c40('0x81')]()['value']();for(var _0x12cf28=0x0;_0x12cf28<_0x84ec34[_0x2c40('0x5f')];_0x12cf28++){if(!_['includes'](_0x298dac,_0x84ec34[_0x12cf28][_0x2c40('0x22')]))return;var _0x32616f=_0x84ec34[_0x12cf28][_0x2c40('0x22')]===_0x2c40('0x1e')?_0x2c40('0x25'):_0x2c40('0x26');_0x540a72[_0x2c40('0x41')](db['UserProfileResource'][_0x2c40('0x74')]({'name':_0x84ec34[_0x12cf28][_0x2c40('0x2f')],'resourceId':_0x84ec34[_0x12cf28]['id'],'type':_0x32616f,'sectionId':_['find'](_0x33ce4a,[_0x2c40('0x2f'),_0x32616f])['id']},{}));}return Promise[_0x2c40('0x49')](_0x540a72);});})[_0x2c40('0x1d')](respondWithResult(_0x2d1cfb,0xc9))['catch'](handleError(_0x2d1cfb,null));};exports[_0x2c40('0x82')]=function(_0x571a4b,_0x2b05b3){if(_0x571a4b['body']['id']){delete _0x571a4b[_0x2c40('0x4f')]['id'];}return db[_0x2c40('0x31')][_0x2c40('0x2c')]({'where':{'id':_0x571a4b[_0x2c40('0x4c')]['id']}})[_0x2c40('0x1d')](function(_0x4428f2){if(!_0x4428f2)return null;if(_0x4428f2['id']===_0x571a4b[_0x2c40('0x75')]['id']){if(!_0x571a4b[_0x2c40('0x4f')][_0x2c40('0x83')]||!_0x571a4b['body'][_0x2c40('0x84')]){throw new db['Sequelize'][(_0x2c40('0x85'))](_0x2c40('0x86'));}if(!_0x4428f2[_0x2c40('0x87')](_0x571a4b['body'][_0x2c40('0x83')])){throw new db[(_0x2c40('0x88'))][(_0x2c40('0x85'))]('Wrong\x20credentials');}if(_0x571a4b[_0x2c40('0x4f')]['oldPassword']===_0x571a4b[_0x2c40('0x4f')]['newPassword']){throw new db[(_0x2c40('0x88'))][(_0x2c40('0x85'))](_0x2c40('0x89'));}}else if(_0x571a4b['user'][_0x2c40('0x22')]===_0x2c40('0x23')){if(!_0x571a4b[_0x2c40('0x4f')]['newPassword']){throw new db['Sequelize'][(_0x2c40('0x85'))](_0x2c40('0x8a'));}}else if(_0x571a4b[_0x2c40('0x75')]['role']==='user'){if(!_0x571a4b['body'][_0x2c40('0x84')]){throw new db[(_0x2c40('0x88'))][(_0x2c40('0x85'))](_0x2c40('0x8a'));}if(_0x4428f2[_0x2c40('0x22')]!==_0x2c40('0x1e')){throw new db[(_0x2c40('0x88'))][(_0x2c40('0x85'))](_0x2c40('0x76'));}}else{throw new db[(_0x2c40('0x88'))][(_0x2c40('0x85'))](_0x2c40('0x76'));}return _0x4428f2;})[_0x2c40('0x1d')](handleEntityNotFound(_0x2b05b3,null))[_0x2c40('0x1d')](function(_0x3c3419){return db['Setting'][_0x2c40('0x8b')]({'attributes':['id',_0x2c40('0x56'),_0x2c40('0x8c'),_0x2c40('0x8d')]})['then'](function(_0x3466c0){if(_0x3466c0[_0x2c40('0x56')])authService[_0x2c40('0x8e')](_0x571a4b[_0x2c40('0x4f')][_0x2c40('0x84')]);if(!_0x3466c0[_0x2c40('0x8c')]||!_0x3c3419[_0x2c40('0x8f')])return _0x3c3419;authService[_0x2c40('0x90')](_0x571a4b[_0x2c40('0x4f')]['newPassword'],_0x3c3419[_0x2c40('0x8f')],_0x3466c0[_0x2c40('0x8d')]);return _0x3c3419;})[_0x2c40('0x1d')](saveUpdates({'password':_0x571a4b[_0x2c40('0x4f')]['newPassword'],'passwordResetAt':_0x571a4b['user']['id']==_0x571a4b[_0x2c40('0x4c')]['id']?moment():null,'previousPasswords':authService[_0x2c40('0x91')](_0x571a4b[_0x2c40('0x4f')][_0x2c40('0x84')],_0x3c3419[_0x2c40('0x8f')])},null));})[_0x2c40('0x1d')](respondWithResult(_0x2b05b3,null))[_0x2c40('0x4a')](handleError(_0x2b05b3,null));};exports[_0x2c40('0x92')]=function(_0x32edd4,_0x10bca8){var _0x16129e=_0x32edd4[_0x2c40('0x4f')]['channel'];return db[_0x2c40('0x31')][_0x2c40('0x2c')]({'where':{'id':_0x32edd4['params']['id']},'attributes':['id',_0x2c40('0x2f'),_0x2c40('0x22'),_0x2c40('0x93'),_0x2c40('0x94'),_0x2c40('0x95'),_0x2c40('0x96')]})[_0x2c40('0x1d')](handleEntityNotFound(_0x10bca8,null))[_0x2c40('0x1d')](function(_0x3b9322){if(_0x3b9322){if(!utils[_0x2c40('0x97')](_0x16129e)){throw new db[(_0x2c40('0x88'))][(_0x2c40('0x85'))](_0x2c40('0x98'));}return _0x3b9322['add'+_[_0x2c40('0x99')](_0x16129e[_0x2c40('0x9a')]())+'Queues'](_0x32edd4[_0x2c40('0x4f')][_0x2c40('0x51')],{'penalty':_0x32edd4[_0x2c40('0x4f')][_0x2c40('0x9b')]||0x0})[_0x2c40('0x9c')](function(_0x2c52b9){for(var _0x143c8d=0x0;_0x143c8d<_0x32edd4[_0x2c40('0x4f')][_0x2c40('0x51')][_0x2c40('0x5f')];_0x143c8d+=0x1){var _0x1adf36={'UserId':Number(_0x32edd4[_0x2c40('0x4c')]['id'])};_0x1adf36[_[_0x2c40('0x99')](_0x16129e[_0x2c40('0x9a')]())+_0x2c40('0x9d')]=Number(_0x32edd4[_0x2c40('0x4f')][_0x2c40('0x51')][_0x143c8d]);socket[_0x2c40('0x1f')](_0x2c40('0x75')+_[_0x2c40('0x99')](_0x16129e[_0x2c40('0x9a')]())+_0x2c40('0x9e'),_0x1adf36);}return _0x2c52b9;})[_0x2c40('0x1d')](function(){if(_0x16129e==='voice'){return db['VoiceQueue']['findAll']({'where':{'id':_0x32edd4[_0x2c40('0x4f')]['ids']||[]},'raw':!![],'attributes':['id',_0x2c40('0x2f')]});}})[_0x2c40('0x1d')](function(_0x5bc24e){var _0x1a372d=_0x3b9322[_0x2c40('0x21')]({'plain':!![]});var _0x45bbbf=[];if(_0x16129e==='voice'&&_0x1a372d[_0x2c40('0x22')]===_0x2c40('0x1e')&&_0x1a372d['online']){for(let _0x47465a=0x0;_0x47465a<_0x5bc24e[_0x2c40('0x5f')];_0x47465a+=0x1){_0x45bbbf['push']({'membername':_0x1a372d[_0x2c40('0x2f')],'UserId':_0x1a372d['id'],'queue_name':_0x5bc24e[_0x47465a][_0x2c40('0x2f')],'VoiceQueueId':_0x5bc24e[_0x47465a]['id'],'interface':_[_0x2c40('0x59')](_0x1a372d['interface'])?util[_0x2c40('0x9f')](_0x2c40('0xa0'),_0x1a372d['name']):_0x1a372d[_0x2c40('0x96')],'paused':_0x1a372d[_0x2c40('0x95')]||![],'penalty':_0x32edd4[_0x2c40('0x4f')][_0x2c40('0x9b')]||0x0});}return Promise[_0x2c40('0x49')](_0x45bbbf[_0x2c40('0x32')](function(_0x30affb){return db[_0x2c40('0xa1')][_0x2c40('0xa2')](_0x30affb);}));}return _0x3b9322;});}})[_0x2c40('0x1d')](respondWithStatusCode(_0x10bca8,null))[_0x2c40('0x4a')](handleError(_0x10bca8,null));};exports['removeQueues']=function(_0x5414bd,_0xeeae4f){var _0x688861,_0x4bb7da;return db[_0x2c40('0x31')][_0x2c40('0x2c')]({'where':{'id':_0x5414bd[_0x2c40('0x4c')]['id']},'attributes':['id',_0x2c40('0x2f'),_0x2c40('0x22')]})[_0x2c40('0x1d')](handleEntityNotFound(_0xeeae4f,null))['then'](function(_0x1cd726){if(_0x1cd726){_0x688861=_0x1cd726;if(!_0x5414bd[_0x2c40('0x3a')][_0x2c40('0xa3')]||!utils[_0x2c40('0x97')](_0x5414bd[_0x2c40('0x3a')][_0x2c40('0xa3')])){throw new db[(_0x2c40('0x88'))]['ValidationError'](_0x2c40('0x98'));}return _0x1cd726['remove'+_['capitalize'](_0x5414bd['query'][_0x2c40('0xa3')][_0x2c40('0x9a')]())+_0x2c40('0xa4')](_0x5414bd[_0x2c40('0x3a')][_0x2c40('0x51')]);}})[_0x2c40('0x1d')](function(_0x54698f){if(_['isArray'](_0x5414bd['query'][_0x2c40('0x51')])){for(var _0x314ec5=0x0;_0x314ec5<_0x5414bd[_0x2c40('0x3a')]['ids'][_0x2c40('0x5f')];_0x314ec5+=0x1){_0x4bb7da={'UserId':Number(_0x5414bd['params']['id'])};_0x4bb7da[_['capitalize'](_0x5414bd[_0x2c40('0x3a')]['channel'][_0x2c40('0x9a')]())+_0x2c40('0x9d')]=Number(_0x5414bd['query'][_0x2c40('0x51')][_0x314ec5]);socket['emit'](_0x2c40('0x75')+_[_0x2c40('0x99')](_0x5414bd['query'][_0x2c40('0xa3')][_0x2c40('0x9a')]())+_0x2c40('0xa5'),_0x4bb7da);}}else{_0x4bb7da={'UserId':Number(_0x5414bd[_0x2c40('0x4c')]['id'])};_0x4bb7da[_['capitalize'](_0x5414bd[_0x2c40('0x3a')][_0x2c40('0xa3')][_0x2c40('0x9a')]())+_0x2c40('0x9d')]=Number(_0x5414bd[_0x2c40('0x3a')][_0x2c40('0x51')]);socket[_0x2c40('0x1f')](_0x2c40('0x75')+_['capitalize'](_0x5414bd[_0x2c40('0x3a')][_0x2c40('0xa3')][_0x2c40('0x9a')]())+_0x2c40('0xa5'),_0x4bb7da);}return _0x54698f;})[_0x2c40('0x1d')](function(){if(_0x5414bd['query']['channel']===_0x2c40('0xa6')){return db[_0x2c40('0xa1')]['destroy']({'where':{'UserId':_0x5414bd[_0x2c40('0x4c')]['id'],'VoiceQueueId':_0x5414bd[_0x2c40('0x3a')]['ids']},'individualHooks':!![]})['then'](function(){return _0x688861;});}return _0x688861;})['then'](respondWithStatusCode(_0xeeae4f,null))[_0x2c40('0x4a')](handleError(_0xeeae4f,null));};exports[_0x2c40('0xa7')]=function(_0x26443c,_0x49cb9e){_0x26443c['body']['userpic']=_0x26443c[_0x2c40('0xa8')][_0x2c40('0xa9')];return db['User'][_0x2c40('0x2c')]({'where':{'id':_0x26443c[_0x2c40('0x4c')]['id']}})[_0x2c40('0x1d')](handleEntityNotFound(_0x49cb9e,null))['then'](saveUpdates(_0x26443c[_0x2c40('0x4f')],null))[_0x2c40('0x1d')](respondWithResult(_0x49cb9e,null))[_0x2c40('0x4a')](handleError(_0x49cb9e,null));};exports[_0x2c40('0xaa')]=function(_0x560225,_0x217037){var _0x5f5a19=path[_0x2c40('0xab')](config['root'],'server/files/images/logos/default_profile.png');return db[_0x2c40('0x31')][_0x2c40('0x2c')]({'where':{'id':_0x560225['params']['id']},'attributes':['id',_0x2c40('0xac')],'raw':!![]})[_0x2c40('0x1d')](handleEntityNotFound(_0x217037,null))[_0x2c40('0x1d')](function(_0x4cc31a){if(_0x4cc31a){if(_[_0x2c40('0x59')](_0x4cc31a['userpic'])){return _0x217037[_0x2c40('0xad')](_0x5f5a19);}else{if(!fs[_0x2c40('0xae')](path[_0x2c40('0xab')](config[_0x2c40('0xaf')],_0x2c40('0xb0'),_0x4cc31a[_0x2c40('0xac')]))){return _0x217037['download'](_0x5f5a19);}return _0x217037[_0x2c40('0xad')](path[_0x2c40('0xab')](config[_0x2c40('0xaf')],_0x2c40('0xb0'),_0x4cc31a['userpic']));}}})[_0x2c40('0x4a')](handleError(_0x217037,null));};exports['getOpenTabs']=function(_0x390a9d,_0x1481e4){return db[_0x2c40('0x31')][_0x2c40('0x2c')]({'where':{'id':_0x390a9d['params']['id']},'attributes':['id']})[_0x2c40('0x1d')](handleEntityNotFound(_0x1481e4,null))[_0x2c40('0x1d')](function(_0x2707bd){var _0x8515e2=[];values=_0x2707bd['dataValues'];_0x8515e2[_0x2c40('0x41')](get_open_tabs(_0x2c40('0xb1'),_0x2707bd[_0x2c40('0x44')]));_0x8515e2[_0x2c40('0x41')](get_open_tabs(_0x2c40('0x45'),_0x2707bd['dataValues']));_0x8515e2[_0x2c40('0x41')](get_open_tabs(_0x2c40('0x48'),_0x2707bd['dataValues']));_0x8515e2[_0x2c40('0x41')](get_open_tabs(_0x2c40('0x4e'),_0x2707bd[_0x2c40('0x44')]));_0x8515e2[_0x2c40('0x41')](get_open_tabs(_0x2c40('0x46'),_0x2707bd['dataValues']));_0x8515e2[_0x2c40('0x41')](get_open_tabs(_0x2c40('0x47'),_0x2707bd[_0x2c40('0x44')]));return Promise['all'](_0x8515e2);})[_0x2c40('0x1d')](function(_0x2b7c1f){if(_0x2b7c1f){var _0x8d3678=_[_0x2c40('0x32')](values[_0x2c40('0xb2')],function(_0xfe90ae){return{'channel':'CHAT','id':_0xfe90ae['id'],'createdAt':_0xfe90ae[_0x2c40('0xb3')]};});var _0x373604=_[_0x2c40('0x32')](values['FaxOpenTabs'],function(_0x2f6979){return{'channel':_0x2c40('0xb4'),'id':_0x2f6979['id'],'createdAt':_0x2f6979[_0x2c40('0xb3')]};});var _0x3e6120=_['map'](values[_0x2c40('0xb5')],function(_0x21bc55){return{'channel':_0x2c40('0xb6'),'id':_0x21bc55['id'],'createdAt':_0x21bc55['createdAt']};});var _0x43c11e=_['map'](values[_0x2c40('0xb7')],function(_0x21307e){return{'channel':_0x2c40('0xb8'),'id':_0x21307e['id'],'createdAt':_0x21307e[_0x2c40('0xb3')]};});var _0x1a158b=_[_0x2c40('0x32')](values[_0x2c40('0xb9')],function(_0x5bd620){return{'channel':_0x2c40('0xba'),'id':_0x5bd620['id'],'createdAt':_0x5bd620[_0x2c40('0xb3')]};});var _0x2954b0=_[_0x2c40('0x32')](values[_0x2c40('0xbb')],function(_0xe48020){return{'channel':_0x2c40('0xbc'),'id':_0xe48020['id'],'createdAt':_0xe48020[_0x2c40('0xb3')]};});var _0x3c8b63=_['concat'](_0x8d3678,_0x373604,_0x3e6120,_0x43c11e,_0x1a158b,_0x2954b0);var _0x4c3d28={'count':_0x3c8b63[_0x2c40('0x5f')],'rows':_0x3c8b63};return _0x4c3d28;}else return null;})[_0x2c40('0x1d')](respondWithResult(_0x1481e4,null))[_0x2c40('0x4a')](handleError(_0x1481e4,null));};exports['getContacts']=function(_0x2b016e,_0x5620eb){var _0x12c43a={};return db[_0x2c40('0x31')][_0x2c40('0x8b')]({'where':{'id':_0x2b016e[_0x2c40('0x4c')]['id']}})[_0x2c40('0x1d')](function(_0x13b755){if(!_0x13b755){throw new APINotFoundError(util['format'](_0x2c40('0xbd'),_0x2b016e[_0x2c40('0x4c')]['id']));}return contacts['describe']();})[_0x2c40('0x1d')](function(_0x1927e6){_0x2b016e[_0x2c40('0x3a')][_0x2c40('0x31')]=_0x2b016e[_0x2c40('0x4c')]['id'];_0x12c43a=qs[_0x2c40('0x38')](_0x1927e6,_0x2b016e);if(_0x2b016e[_0x2c40('0x3a')]['hasOwnProperty']('includeAll')){_0x12c43a[_0x2c40('0x3c')]=[{'model':db['CmList'],'as':_0x2c40('0xbe'),'required':![]},{'model':db['Tag'],'as':_0x2c40('0xbf'),'attributes':['id',_0x2c40('0x2f'),_0x2c40('0xc0')],'where':_0x2b016e[_0x2c40('0x3a')][_0x2c40('0xc1')]?{'id':_0x2b016e[_0x2c40('0x3a')][_0x2c40('0xc1')]}:undefined,'required':_0x2b016e[_0x2c40('0x3a')]['tag']?!![]:![]}];}return contacts['findAll'](_0x2b016e[_0x2c40('0x3a')],_0x2b016e[_0x2c40('0x75')],_0x12c43a,_0x1927e6);})['then'](respondWithFilteredResult(_0x5620eb,_0x12c43a))[_0x2c40('0x4a')](APIHandleError(_0x5620eb));};exports['getQueues']=function(_0x4a41f1,_0x439d97){var _0x3b33c2;var _0x106f7d={};var _0x43cf35;return db['User']['findOne']({'where':{'id':_0x4a41f1[_0x2c40('0x4c')]['id']},'attributes':['id',_0x2c40('0x2f'),_0x2c40('0x22')]})[_0x2c40('0x1d')](handleEntityNotFound(_0x439d97,null))['then'](function(_0x34bebe){if(!utils[_0x2c40('0x97')](_0x4a41f1[_0x2c40('0x3a')][_0x2c40('0xa3')])){throw new db[(_0x2c40('0x88'))][(_0x2c40('0x85'))]('Unknown\x20channel');}_0x3b33c2=_0x34bebe;var _0x3ef36f={};_0x3ef36f[_0x2c40('0xc2')]=_['keys'](db[_['capitalize'](_0x4a41f1[_0x2c40('0x3a')][_0x2c40('0xa3')])+_0x2c40('0xc3')][_0x2c40('0xc4')]);_0x3ef36f[_0x2c40('0x3a')]=_[_0x2c40('0xc5')](_0x4a41f1[_0x2c40('0x3a')]);_0x3ef36f[_0x2c40('0xc6')]=_[_0x2c40('0xc7')](_0x3ef36f[_0x2c40('0xc2')],_0x3ef36f['query']);_0x106f7d[_0x2c40('0x40')]=_['intersection'](_0x3ef36f[_0x2c40('0xc2')],qs[_0x2c40('0xc8')](_0x4a41f1[_0x2c40('0x3a')][_0x2c40('0xc8')]));_0x106f7d[_0x2c40('0x40')]=_0x106f7d[_0x2c40('0x40')]['length']?_0x106f7d[_0x2c40('0x40')]:_0x3ef36f[_0x2c40('0xc2')];_0x106f7d['order']=qs[_0x2c40('0xc9')](_0x4a41f1[_0x2c40('0x3a')][_0x2c40('0xc9')]);_0x106f7d['where']=qs[_0x2c40('0xc6')](_[_0x2c40('0xca')](_0x4a41f1[_0x2c40('0x3a')],_0x3ef36f[_0x2c40('0xc6')]));if(_0x4a41f1['query'][_0x2c40('0x28')]){_0x106f7d[_0x2c40('0x39')]=_[_0x2c40('0xcb')](_0x106f7d[_0x2c40('0x39')],{'$or':_[_0x2c40('0x32')](_0x106f7d[_0x2c40('0x40')],function(_0x19801d){var _0x125f9f={};_0x125f9f[_0x19801d]={'$like':'%'+_0x4a41f1[_0x2c40('0x3a')][_0x2c40('0x28')]+'%'};return _0x125f9f;})});}_0x106f7d=_['merge']({},_0x106f7d,_0x4a41f1[_0x2c40('0x4d')]);switch(_0x3b33c2[_0x2c40('0x22')]){case _0x2c40('0x23'):return db[_[_0x2c40('0x99')](_0x4a41f1[_0x2c40('0x3a')][_0x2c40('0xa3')])+'Queue'][_0x2c40('0x42')](_0x106f7d);case _0x2c40('0x75'):case'agent':return _0x3b33c2['get'+_[_0x2c40('0x99')](_0x4a41f1[_0x2c40('0x3a')]['channel'])+'Queues'](_0x106f7d);default:throw new db[(_0x2c40('0x88'))][(_0x2c40('0x85'))](_0x2c40('0xcc'));}})[_0x2c40('0x1d')](function(_0x630e4){_0x43cf35=_0x630e4[_0x2c40('0x5f')];if(!_0x4a41f1['query'][_0x2c40('0xcd')](_0x2c40('0xce'))){_0x106f7d['limit']=qs['limit'](_0x4a41f1[_0x2c40('0x3a')][_0x2c40('0x19')]);_0x106f7d[_0x2c40('0x17')]=qs[_0x2c40('0x17')](_0x4a41f1[_0x2c40('0x3a')][_0x2c40('0x17')]);}switch(_0x3b33c2[_0x2c40('0x22')]){case'admin':return db[_[_0x2c40('0x99')](_0x4a41f1[_0x2c40('0x3a')][_0x2c40('0xa3')])+'Queue'][_0x2c40('0x42')](_0x106f7d);case _0x2c40('0x75'):case _0x2c40('0x1e'):return _0x3b33c2[_0x2c40('0x21')+_['capitalize'](_0x4a41f1[_0x2c40('0x3a')]['channel'])+_0x2c40('0xa4')](_0x106f7d);}})[_0x2c40('0x1d')](function(_0x3895a2){return{'count':_0x43cf35,'rows':_0x3895a2};})[_0x2c40('0x1d')](respondWithResult(_0x439d97,null))[_0x2c40('0x4a')](handleError(_0x439d97,null));};exports['getVoiceQueuesRt']=function(_0x2f0f7a,_0x213ac8){var _0x25a307={};var _0x36d429={};var _0x74f185;var _0x2b43af;return db['User'][_0x2c40('0x8b')]({'where':{'id':_0x2f0f7a[_0x2c40('0x4c')]['id']}})[_0x2c40('0x1d')](handleEntityNotFound(_0x213ac8,null))[_0x2c40('0x1d')](function(_0x35cf93){if(_0x35cf93){_0x74f185=_0x35cf93;_0x36d429[_0x2c40('0xc2')]=_['keys'](db[_0x2c40('0xa1')]['rawAttributes']);_0x36d429[_0x2c40('0x3a')]=_['keys'](_0x2f0f7a['query']);_0x36d429[_0x2c40('0xc6')]=_['intersection'](_0x36d429[_0x2c40('0xc2')],_0x36d429[_0x2c40('0x3a')]);_0x25a307[_0x2c40('0x40')]=_[_0x2c40('0xc7')](_0x36d429['model'],qs['fields'](_0x2f0f7a['query']['fields']));_0x25a307[_0x2c40('0x40')]=_0x25a307[_0x2c40('0x40')]['length']?_0x25a307[_0x2c40('0x40')]:_0x36d429[_0x2c40('0xc2')];_0x25a307[_0x2c40('0xcf')]=qs[_0x2c40('0xc9')](_0x2f0f7a[_0x2c40('0x3a')][_0x2c40('0xc9')]);_0x25a307['where']=qs[_0x2c40('0xc6')](_[_0x2c40('0xca')](_0x2f0f7a['query'],_0x36d429[_0x2c40('0xc6')]));if(_0x2f0f7a['query'][_0x2c40('0x28')]){_0x25a307[_0x2c40('0x39')]=_[_0x2c40('0xcb')](_0x25a307[_0x2c40('0x39')],{'$or':_[_0x2c40('0x32')](_0x25a307[_0x2c40('0x40')],function(_0x199e9e){var _0x2c7de8={};_0x2c7de8[_0x199e9e]={'$like':'%'+_0x2f0f7a['query']['filter']+'%'};return _0x2c7de8;})});}_0x25a307=_['merge']({},_0x25a307,_0x2f0f7a['options']);return _0x74f185['getVoiceQueuesRt'](_0x25a307);}})[_0x2c40('0x1d')](function(_0x2a493c){if(_0x2a493c){_0x2b43af=_0x2a493c[_0x2c40('0x5f')];if(!_0x2f0f7a['query'][_0x2c40('0xcd')](_0x2c40('0xce'))){_0x25a307[_0x2c40('0x19')]=qs[_0x2c40('0x19')](_0x2f0f7a[_0x2c40('0x3a')][_0x2c40('0x19')]);_0x25a307[_0x2c40('0x17')]=qs[_0x2c40('0x17')](_0x2f0f7a['query'][_0x2c40('0x17')]);}return _0x74f185[_0x2c40('0xd0')](_0x25a307);}})[_0x2c40('0x1d')](function(_0x581c90){if(_0x581c90){return _0x581c90?{'count':_0x2b43af,'rows':_0x581c90}:null;}})['then'](respondWithResult(_0x213ac8,null))[_0x2c40('0x4a')](handleError(_0x213ac8,null));};exports['getGroups']=function(_0x55812e,_0xe2908a){var _0x1b07a6={};var _0x36989a={};var _0x1db9ba;var _0x966774;return db[_0x2c40('0x31')][_0x2c40('0x8b')]({'where':{'id':_0x55812e['params']['id']}})['then'](handleEntityNotFound(_0xe2908a,null))['then'](function(_0x5378ee){if(_0x5378ee){_0x1db9ba=_0x5378ee;_0x36989a[_0x2c40('0xc2')]=_['keys'](db[_0x2c40('0xd1')][_0x2c40('0xc4')]);_0x36989a[_0x2c40('0x3a')]=_[_0x2c40('0xc5')](_0x55812e[_0x2c40('0x3a')]);_0x36989a[_0x2c40('0xc6')]=_[_0x2c40('0xc7')](_0x36989a['model'],_0x36989a[_0x2c40('0x3a')]);_0x1b07a6['attributes']=_[_0x2c40('0xc7')](_0x36989a[_0x2c40('0xc2')],qs[_0x2c40('0xc8')](_0x55812e[_0x2c40('0x3a')]['fields']));_0x1b07a6['attributes']=_0x1b07a6[_0x2c40('0x40')][_0x2c40('0x5f')]?_0x1b07a6[_0x2c40('0x40')]:_0x36989a[_0x2c40('0xc2')];_0x1b07a6['order']=qs[_0x2c40('0xc9')](_0x55812e[_0x2c40('0x3a')]['sort']);_0x1b07a6[_0x2c40('0x39')]=qs['filters'](_[_0x2c40('0xca')](_0x55812e[_0x2c40('0x3a')],_0x36989a[_0x2c40('0xc6')]));if(_0x55812e[_0x2c40('0x3a')][_0x2c40('0x28')]){_0x1b07a6[_0x2c40('0x39')]=_['merge'](_0x1b07a6['where'],{'$or':_['map'](_0x1b07a6[_0x2c40('0x40')],function(_0x111c14){var _0x281a41={};_0x281a41[_0x111c14]={'$like':'%'+_0x55812e[_0x2c40('0x3a')][_0x2c40('0x28')]+'%'};return _0x281a41;})});}_0x1b07a6=_[_0x2c40('0xcb')]({},_0x1b07a6,_0x55812e[_0x2c40('0x4d')]);return _0x1db9ba[_0x2c40('0xd2')](_0x1b07a6);}})[_0x2c40('0x1d')](function(_0x37596d){if(_0x37596d){_0x966774=_0x37596d['length'];if(!_0x55812e[_0x2c40('0x3a')]['hasOwnProperty']('nolimit')){_0x1b07a6[_0x2c40('0x19')]=qs[_0x2c40('0x19')](_0x55812e[_0x2c40('0x3a')][_0x2c40('0x19')]);_0x1b07a6[_0x2c40('0x17')]=qs[_0x2c40('0x17')](_0x55812e[_0x2c40('0x3a')][_0x2c40('0x17')]);}return _0x1db9ba[_0x2c40('0xd2')](_0x1b07a6);}})[_0x2c40('0x1d')](function(_0x15ef28){if(_0x15ef28){return _0x15ef28?{'count':_0x966774,'rows':_0x15ef28}:null;}})[_0x2c40('0x1d')](respondWithResult(_0xe2908a,null))['catch'](handleError(_0xe2908a,null));};exports[_0x2c40('0xd3')]=function(_0x44c742,_0x4bb9ab){var _0x3caa4c={'raw':!![],'where':{}};var _0x474bb6={};var _0x725bf2={'count':0x0,'rows':[]};return db['User'][_0x2c40('0x8b')]({'where':{'id':_0x44c742[_0x2c40('0x4c')]['id']}})[_0x2c40('0x1d')](handleEntityNotFound(_0x4bb9ab,null))[_0x2c40('0x1d')](function(_0x28e641){if(_0x28e641){_0x474bb6[_0x2c40('0xc2')]=_[_0x2c40('0xc5')](db[_0x2c40('0xd4')][_0x2c40('0xc4')]);_0x474bb6[_0x2c40('0x3a')]=_[_0x2c40('0xc5')](_0x44c742[_0x2c40('0x3a')]);_0x474bb6[_0x2c40('0xc6')]=_[_0x2c40('0xc7')](_0x474bb6[_0x2c40('0xc2')],_0x474bb6[_0x2c40('0x3a')]);_0x3caa4c[_0x2c40('0x40')]=_[_0x2c40('0xc7')](_0x474bb6[_0x2c40('0xc2')],qs['fields'](_0x44c742[_0x2c40('0x3a')][_0x2c40('0xc8')]));_0x3caa4c[_0x2c40('0x40')]=_0x3caa4c['attributes']['length']?_0x3caa4c[_0x2c40('0x40')]:_0x474bb6[_0x2c40('0xc2')];if(!_0x44c742['query'][_0x2c40('0xcd')](_0x2c40('0xce'))){_0x3caa4c[_0x2c40('0x19')]=qs['limit'](_0x44c742[_0x2c40('0x3a')][_0x2c40('0x19')]);_0x3caa4c[_0x2c40('0x17')]=qs[_0x2c40('0x17')](_0x44c742['query'][_0x2c40('0x17')]);}_0x3caa4c[_0x2c40('0xcf')]=qs[_0x2c40('0xc9')](_0x44c742['query'][_0x2c40('0xc9')]);_0x3caa4c['where']=qs['filters'](_[_0x2c40('0xca')](_0x44c742['query'],_0x474bb6['filters']));_0x3caa4c[_0x2c40('0x39')][_0x2c40('0xd5')]=_0x28e641['id'];if(_0x44c742['query'][_0x2c40('0x28')]){_0x3caa4c[_0x2c40('0x39')]=_[_0x2c40('0xcb')](_0x3caa4c[_0x2c40('0x39')],{'$or':_[_0x2c40('0x32')](_0x3caa4c[_0x2c40('0x40')],function(_0x5a928c){var _0x3ead25={};_0x3ead25[_0x5a928c]={'$like':'%'+_0x44c742['query'][_0x2c40('0x28')]+'%'};return _0x3ead25;})});}_0x3caa4c=_[_0x2c40('0xcb')]({},_0x3caa4c,_0x44c742[_0x2c40('0x4d')]);return db[_0x2c40('0xd4')]['count']({'where':_0x3caa4c[_0x2c40('0x39')]})['then'](function(_0x2977f0){_0x725bf2[_0x2c40('0x1a')]=_0x2977f0;if(_0x44c742['query']['includeAll']){_0x3caa4c[_0x2c40('0x3c')]=[{'all':!![]}];}return db[_0x2c40('0xd4')][_0x2c40('0x42')](_0x3caa4c);})[_0x2c40('0x1d')](function(_0x5d6aa0){_0x725bf2[_0x2c40('0x43')]=_0x5d6aa0;return _0x725bf2;});}})['then'](respondWithFilteredResult(_0x4bb9ab,_0x3caa4c))['catch'](handleError(_0x4bb9ab,null));};exports[_0x2c40('0xd6')]=function(_0x45ab54,_0x5e837f){var _0x5d38f8={'raw':!![],'where':{}};var _0x4d4952={};var _0x9b9e4e={'count':0x0,'rows':[]};return db[_0x2c40('0x31')][_0x2c40('0x8b')]({'where':{'id':_0x45ab54['params']['id']}})[_0x2c40('0x1d')](handleEntityNotFound(_0x5e837f,null))[_0x2c40('0x1d')](function(_0x4a3820){if(_0x4a3820){_0x4d4952['model']=_[_0x2c40('0xc5')](db[_0x2c40('0xd7')][_0x2c40('0xc4')]);_0x4d4952[_0x2c40('0x3a')]=_['keys'](_0x45ab54[_0x2c40('0x3a')]);_0x4d4952['filters']=_['intersection'](_0x4d4952[_0x2c40('0xc2')],_0x4d4952[_0x2c40('0x3a')]);_0x5d38f8[_0x2c40('0x40')]=_[_0x2c40('0xc7')](_0x4d4952['model'],qs[_0x2c40('0xc8')](_0x45ab54[_0x2c40('0x3a')][_0x2c40('0xc8')]));_0x5d38f8[_0x2c40('0x40')]=_0x5d38f8['attributes'][_0x2c40('0x5f')]?_0x5d38f8[_0x2c40('0x40')]:_0x4d4952[_0x2c40('0xc2')];if(!_0x45ab54[_0x2c40('0x3a')]['hasOwnProperty'](_0x2c40('0xce'))){_0x5d38f8[_0x2c40('0x19')]=qs[_0x2c40('0x19')](_0x45ab54[_0x2c40('0x3a')][_0x2c40('0x19')]);_0x5d38f8['offset']=qs['offset'](_0x45ab54[_0x2c40('0x3a')][_0x2c40('0x17')]);}_0x5d38f8['order']=qs[_0x2c40('0xc9')](_0x45ab54[_0x2c40('0x3a')][_0x2c40('0xc9')]);_0x5d38f8[_0x2c40('0x39')]=qs[_0x2c40('0xc6')](_[_0x2c40('0xca')](_0x45ab54[_0x2c40('0x3a')],_0x4d4952['filters']));_0x5d38f8[_0x2c40('0x39')][_0x2c40('0xd5')]=_0x4a3820['id'];if(_0x45ab54[_0x2c40('0x3a')]['filter']){_0x5d38f8[_0x2c40('0x39')]=_[_0x2c40('0xcb')](_0x5d38f8['where'],{'$or':_['map'](_0x5d38f8[_0x2c40('0x40')],function(_0x17a478){var _0x4c11a8={};_0x4c11a8[_0x17a478]={'$like':'%'+_0x45ab54[_0x2c40('0x3a')][_0x2c40('0x28')]+'%'};return _0x4c11a8;})});}_0x5d38f8=_[_0x2c40('0xcb')]({},_0x5d38f8,_0x45ab54['options']);return db[_0x2c40('0xd7')][_0x2c40('0x1a')]({'where':_0x5d38f8['where']})[_0x2c40('0x1d')](function(_0x49384c){_0x9b9e4e[_0x2c40('0x1a')]=_0x49384c;if(_0x45ab54[_0x2c40('0x3a')]['includeAll']){_0x5d38f8[_0x2c40('0x3c')]=[{'all':!![]}];}return db[_0x2c40('0xd7')]['findAll'](_0x5d38f8);})[_0x2c40('0x1d')](function(_0x287c70){_0x9b9e4e[_0x2c40('0x43')]=_0x287c70;return _0x9b9e4e;});}})['then'](respondWithFilteredResult(_0x5e837f,_0x5d38f8))['catch'](handleError(_0x5e837f,null));};exports[_0x2c40('0xd8')]=function(_0x12a5f4,_0x518fc7){var _0xc27969={};var _0x518db2={};var _0x1b3bb5;var _0x5bcef9;return db[_0x2c40('0x31')][_0x2c40('0x8b')]({'where':{'id':_0x12a5f4[_0x2c40('0x4c')]['id']}})[_0x2c40('0x1d')](handleEntityNotFound(_0x518fc7,null))['then'](function(_0x404f78){if(_0x404f78){_0x1b3bb5=_0x404f78;_0x518db2[_0x2c40('0xc2')]=_[_0x2c40('0xc5')](db['ChatInteraction']['rawAttributes']);_0x518db2[_0x2c40('0x3a')]=_['keys'](_0x12a5f4[_0x2c40('0x3a')]);_0x518db2[_0x2c40('0xc6')]=_[_0x2c40('0xc7')](_0x518db2[_0x2c40('0xc2')],_0x518db2[_0x2c40('0x3a')]);_0xc27969[_0x2c40('0x40')]=_[_0x2c40('0xc7')](_0x518db2[_0x2c40('0xc2')],qs[_0x2c40('0xc8')](_0x12a5f4[_0x2c40('0x3a')][_0x2c40('0xc8')]));_0xc27969[_0x2c40('0x40')]=_0xc27969[_0x2c40('0x40')][_0x2c40('0x5f')]?_0xc27969[_0x2c40('0x40')]:_0x518db2['model'];_0xc27969[_0x2c40('0xcf')]=qs[_0x2c40('0xc9')](_0x12a5f4[_0x2c40('0x3a')][_0x2c40('0xc9')]);_0xc27969['where']=qs[_0x2c40('0xc6')](_[_0x2c40('0xca')](_0x12a5f4['query'],_0x518db2['filters']));if(_0x12a5f4['query'][_0x2c40('0x28')]){_0xc27969[_0x2c40('0x39')]=_[_0x2c40('0xcb')](_0xc27969['where'],{'$or':_[_0x2c40('0x32')](_0xc27969[_0x2c40('0x40')],function(_0x203809){var _0x20478b={};_0x20478b[_0x203809]={'$like':'%'+_0x12a5f4[_0x2c40('0x3a')][_0x2c40('0x28')]+'%'};return _0x20478b;})});}_0xc27969=_[_0x2c40('0xcb')]({},_0xc27969,_0x12a5f4[_0x2c40('0x4d')]);return _0x1b3bb5[_0x2c40('0xd8')](_0xc27969);}})[_0x2c40('0x1d')](function(_0x52e1d2){if(_0x52e1d2){_0x5bcef9=_0x52e1d2[_0x2c40('0x5f')];if(!_0x12a5f4[_0x2c40('0x3a')][_0x2c40('0xcd')](_0x2c40('0xce'))){_0xc27969[_0x2c40('0x19')]=qs[_0x2c40('0x19')](_0x12a5f4[_0x2c40('0x3a')]['limit']);_0xc27969[_0x2c40('0x17')]=qs[_0x2c40('0x17')](_0x12a5f4['query'][_0x2c40('0x17')]);}return _0x1b3bb5[_0x2c40('0xd8')](_0xc27969);}})[_0x2c40('0x1d')](function(_0x825013){if(_0x825013){return _0x825013?{'count':_0x5bcef9,'rows':_0x825013}:null;}})[_0x2c40('0x1d')](respondWithResult(_0x518fc7,null))[_0x2c40('0x4a')](handleError(_0x518fc7,null));};exports[_0x2c40('0xd9')]=function(_0x505bc4,_0x4346a2){var _0x3b0be5={};var _0x11f37c={};var _0x4c7983;var _0x39ac39;return db['User'][_0x2c40('0x8b')]({'where':{'id':_0x505bc4[_0x2c40('0x4c')]['id']}})[_0x2c40('0x1d')](handleEntityNotFound(_0x4346a2,null))[_0x2c40('0x1d')](function(_0x2f7389){if(_0x2f7389){_0x4c7983=_0x2f7389;_0x11f37c[_0x2c40('0xc2')]=_['keys'](db[_0x2c40('0xda')]['rawAttributes']);_0x11f37c[_0x2c40('0x3a')]=_[_0x2c40('0xc5')](_0x505bc4['query']);_0x11f37c[_0x2c40('0xc6')]=_[_0x2c40('0xc7')](_0x11f37c[_0x2c40('0xc2')],_0x11f37c[_0x2c40('0x3a')]);_0x3b0be5[_0x2c40('0x40')]=_['intersection'](_0x11f37c[_0x2c40('0xc2')],qs[_0x2c40('0xc8')](_0x505bc4[_0x2c40('0x3a')][_0x2c40('0xc8')]));_0x3b0be5[_0x2c40('0x40')]=_0x3b0be5['attributes'][_0x2c40('0x5f')]?_0x3b0be5[_0x2c40('0x40')]:_0x11f37c[_0x2c40('0xc2')];_0x3b0be5[_0x2c40('0xcf')]=qs[_0x2c40('0xc9')](_0x505bc4['query'][_0x2c40('0xc9')]);_0x3b0be5['where']=qs[_0x2c40('0xc6')](_['pick'](_0x505bc4[_0x2c40('0x3a')],_0x11f37c[_0x2c40('0xc6')]));if(_0x505bc4[_0x2c40('0x3a')][_0x2c40('0x28')]){_0x3b0be5[_0x2c40('0x39')]=_[_0x2c40('0xcb')](_0x3b0be5['where'],{'$or':_[_0x2c40('0x32')](_0x3b0be5[_0x2c40('0x40')],function(_0x31c1a6){var _0x3f7ff8={};_0x3f7ff8[_0x31c1a6]={'$like':'%'+_0x505bc4['query'][_0x2c40('0x28')]+'%'};return _0x3f7ff8;})});}_0x3b0be5=_[_0x2c40('0xcb')]({},_0x3b0be5,_0x505bc4[_0x2c40('0x4d')]);return _0x4c7983[_0x2c40('0xd9')](_0x3b0be5);}})[_0x2c40('0x1d')](function(_0x1bd54e){if(_0x1bd54e){_0x39ac39=_0x1bd54e['length'];if(!_0x505bc4[_0x2c40('0x3a')][_0x2c40('0xcd')](_0x2c40('0xce'))){_0x3b0be5[_0x2c40('0x19')]=qs['limit'](_0x505bc4[_0x2c40('0x3a')]['limit']);_0x3b0be5[_0x2c40('0x17')]=qs[_0x2c40('0x17')](_0x505bc4[_0x2c40('0x3a')][_0x2c40('0x17')]);}return _0x4c7983['getOpenchannelInteractions'](_0x3b0be5);}})['then'](function(_0x52f5ea){if(_0x52f5ea){return _0x52f5ea?{'count':_0x39ac39,'rows':_0x52f5ea}:null;}})[_0x2c40('0x1d')](respondWithResult(_0x4346a2,null))[_0x2c40('0x4a')](handleError(_0x4346a2,null));};exports[_0x2c40('0xdb')]=function(_0x4b61bc,_0x1e394b){var _0x137d78={'raw':!![],'where':{}};var _0x1aa16c={};var _0x493320={'count':0x0,'rows':[]};return db['User']['findOne']({'where':{'id':_0x4b61bc['params']['id']}})[_0x2c40('0x1d')](handleEntityNotFound(_0x1e394b,null))[_0x2c40('0x1d')](function(_0xabaaad){if(_0xabaaad){_0x1aa16c['model']=_[_0x2c40('0xc5')](db[_0x2c40('0xdc')][_0x2c40('0xc4')]);_0x1aa16c[_0x2c40('0x3a')]=_[_0x2c40('0xc5')](_0x4b61bc[_0x2c40('0x3a')]);_0x1aa16c['filters']=_[_0x2c40('0xc7')](_0x1aa16c[_0x2c40('0xc2')],_0x1aa16c[_0x2c40('0x3a')]);_0x137d78['attributes']=_[_0x2c40('0xc7')](_0x1aa16c['model'],qs['fields'](_0x4b61bc[_0x2c40('0x3a')][_0x2c40('0xc8')]));_0x137d78['attributes']=_0x137d78[_0x2c40('0x40')][_0x2c40('0x5f')]?_0x137d78[_0x2c40('0x40')]:_0x1aa16c[_0x2c40('0xc2')];if(!_0x4b61bc[_0x2c40('0x3a')][_0x2c40('0xcd')]('nolimit')){_0x137d78['limit']=qs['limit'](_0x4b61bc[_0x2c40('0x3a')][_0x2c40('0x19')]);_0x137d78[_0x2c40('0x17')]=qs[_0x2c40('0x17')](_0x4b61bc[_0x2c40('0x3a')]['offset']);}_0x137d78[_0x2c40('0xcf')]=qs['sort'](_0x4b61bc['query'][_0x2c40('0xc9')]);_0x137d78['where']=qs[_0x2c40('0xc6')](_[_0x2c40('0xca')](_0x4b61bc[_0x2c40('0x3a')],_0x1aa16c[_0x2c40('0xc6')]));_0x137d78[_0x2c40('0x39')][_0x2c40('0xd5')]=_0xabaaad['id'];if(_0x4b61bc[_0x2c40('0x3a')][_0x2c40('0x28')]){_0x137d78[_0x2c40('0x39')]=_['merge'](_0x137d78[_0x2c40('0x39')],{'$or':_[_0x2c40('0x32')](_0x137d78['attributes'],function(_0x68c2a9){var _0x22a0da={};_0x22a0da[_0x68c2a9]={'$like':'%'+_0x4b61bc[_0x2c40('0x3a')][_0x2c40('0x28')]+'%'};return _0x22a0da;})});}_0x137d78=_['merge']({},_0x137d78,_0x4b61bc[_0x2c40('0x4d')]);return db[_0x2c40('0xdc')][_0x2c40('0x1a')]({'where':_0x137d78['where']})[_0x2c40('0x1d')](function(_0x4e04d1){_0x493320[_0x2c40('0x1a')]=_0x4e04d1;if(_0x4b61bc[_0x2c40('0x3a')][_0x2c40('0x3b')]){_0x137d78['include']=[{'all':!![]}];}return db['MailInteraction'][_0x2c40('0x42')](_0x137d78);})[_0x2c40('0x1d')](function(_0x5b0f48){_0x493320[_0x2c40('0x43')]=_0x5b0f48;return _0x493320;});}})[_0x2c40('0x1d')](respondWithFilteredResult(_0x1e394b,_0x137d78))[_0x2c40('0x4a')](handleError(_0x1e394b,null));};exports[_0x2c40('0xdd')]=function(_0x544e9b,_0xf76ae7){var _0xfee44e={};var _0x36de11={};var _0x148b4c;var _0x410fa6;return db[_0x2c40('0x31')][_0x2c40('0x8b')]({'where':{'id':_0x544e9b[_0x2c40('0x4c')]['id']}})['then'](handleEntityNotFound(_0xf76ae7,null))[_0x2c40('0x1d')](function(_0x27b65c){if(_0x27b65c){_0x148b4c=_0x27b65c;_0x36de11[_0x2c40('0xc2')]=_[_0x2c40('0xc5')](db[_0x2c40('0xde')]['rawAttributes']);_0x36de11[_0x2c40('0x3a')]=_[_0x2c40('0xc5')](_0x544e9b['query']);_0x36de11[_0x2c40('0xc6')]=_[_0x2c40('0xc7')](_0x36de11[_0x2c40('0xc2')],_0x36de11[_0x2c40('0x3a')]);_0xfee44e['attributes']=_[_0x2c40('0xc7')](_0x36de11[_0x2c40('0xc2')],qs[_0x2c40('0xc8')](_0x544e9b['query'][_0x2c40('0xc8')]));_0xfee44e['attributes']=_0xfee44e[_0x2c40('0x40')][_0x2c40('0x5f')]?_0xfee44e[_0x2c40('0x40')]:_0x36de11[_0x2c40('0xc2')];_0xfee44e[_0x2c40('0xcf')]=qs[_0x2c40('0xc9')](_0x544e9b['query']['sort']);_0xfee44e[_0x2c40('0x39')]=qs[_0x2c40('0xc6')](_[_0x2c40('0xca')](_0x544e9b[_0x2c40('0x3a')],_0x36de11[_0x2c40('0xc6')]));if(_0x544e9b[_0x2c40('0x3a')][_0x2c40('0x28')]){_0xfee44e['where']=_['merge'](_0xfee44e[_0x2c40('0x39')],{'$or':_[_0x2c40('0x32')](_0xfee44e['attributes'],function(_0x521b4a){var _0x50ff8d={};_0x50ff8d[_0x521b4a]={'$like':'%'+_0x544e9b[_0x2c40('0x3a')][_0x2c40('0x28')]+'%'};return _0x50ff8d;})});}_0xfee44e=_['merge']({},_0xfee44e,_0x544e9b[_0x2c40('0x4d')]);return _0x148b4c[_0x2c40('0xdd')](_0xfee44e);}})[_0x2c40('0x1d')](function(_0x31c607){if(_0x31c607){_0x410fa6=_0x31c607['length'];if(!_0x544e9b[_0x2c40('0x3a')][_0x2c40('0xcd')](_0x2c40('0xce'))){_0xfee44e['limit']=qs[_0x2c40('0x19')](_0x544e9b['query'][_0x2c40('0x19')]);_0xfee44e[_0x2c40('0x17')]=qs[_0x2c40('0x17')](_0x544e9b[_0x2c40('0x3a')][_0x2c40('0x17')]);}return _0x148b4c['getSmsInteractions'](_0xfee44e);}})['then'](function(_0x47bc21){if(_0x47bc21){return _0x47bc21?{'count':_0x410fa6,'rows':_0x47bc21}:null;}})['then'](respondWithResult(_0xf76ae7,null))[_0x2c40('0x4a')](handleError(_0xf76ae7,null));};exports[_0x2c40('0xdf')]=function(_0x254ee8,_0x5b05da){var _0x4941ea={};var _0x27e781={};var _0x58a7f2;var _0x31a817;return db[_0x2c40('0x31')]['findOne']({'where':{'id':_0x254ee8[_0x2c40('0x4c')]['id']}})[_0x2c40('0x1d')](handleEntityNotFound(_0x5b05da,null))['then'](function(_0x10c517){if(_0x10c517){_0x58a7f2=_0x10c517;_0x27e781[_0x2c40('0xc2')]=_[_0x2c40('0xc5')](db['FaxInteraction'][_0x2c40('0xc4')]);_0x27e781[_0x2c40('0x3a')]=_[_0x2c40('0xc5')](_0x254ee8['query']);_0x27e781[_0x2c40('0xc6')]=_['intersection'](_0x27e781[_0x2c40('0xc2')],_0x27e781[_0x2c40('0x3a')]);_0x4941ea['attributes']=_[_0x2c40('0xc7')](_0x27e781[_0x2c40('0xc2')],qs['fields'](_0x254ee8['query']['fields']));_0x4941ea[_0x2c40('0x40')]=_0x4941ea[_0x2c40('0x40')][_0x2c40('0x5f')]?_0x4941ea[_0x2c40('0x40')]:_0x27e781['model'];_0x4941ea[_0x2c40('0xcf')]=qs['sort'](_0x254ee8[_0x2c40('0x3a')][_0x2c40('0xc9')]);_0x4941ea[_0x2c40('0x39')]=qs['filters'](_[_0x2c40('0xca')](_0x254ee8[_0x2c40('0x3a')],_0x27e781[_0x2c40('0xc6')]));if(_0x254ee8['query'][_0x2c40('0x28')]){_0x4941ea[_0x2c40('0x39')]=_['merge'](_0x4941ea[_0x2c40('0x39')],{'$or':_[_0x2c40('0x32')](_0x4941ea[_0x2c40('0x40')],function(_0x21f405){var _0x3f18e1={};_0x3f18e1[_0x21f405]={'$like':'%'+_0x254ee8[_0x2c40('0x3a')][_0x2c40('0x28')]+'%'};return _0x3f18e1;})});}_0x4941ea=_['merge']({},_0x4941ea,_0x254ee8['options']);return _0x58a7f2['getFaxInteractions'](_0x4941ea);}})[_0x2c40('0x1d')](function(_0x30b39a){if(_0x30b39a){_0x31a817=_0x30b39a['length'];if(!_0x254ee8[_0x2c40('0x3a')][_0x2c40('0xcd')](_0x2c40('0xce'))){_0x4941ea[_0x2c40('0x19')]=qs[_0x2c40('0x19')](_0x254ee8[_0x2c40('0x3a')][_0x2c40('0x19')]);_0x4941ea[_0x2c40('0x17')]=qs[_0x2c40('0x17')](_0x254ee8[_0x2c40('0x3a')]['offset']);}return _0x58a7f2[_0x2c40('0xdf')](_0x4941ea);}})[_0x2c40('0x1d')](function(_0x157ac2){if(_0x157ac2){return _0x157ac2?{'count':_0x31a817,'rows':_0x157ac2}:null;}})[_0x2c40('0x1d')](respondWithResult(_0x5b05da,null))[_0x2c40('0x4a')](handleError(_0x5b05da,null));};exports[_0x2c40('0xe0')]=function(_0x1db2ca,_0x1be1c5){var _0x37c664={};var _0x3b1716={};var _0x31f324;var _0xf0e78;return db[_0x2c40('0x31')][_0x2c40('0x8b')]({'where':{'id':_0x1db2ca[_0x2c40('0x4c')]['id']}})[_0x2c40('0x1d')](handleEntityNotFound(_0x1be1c5,null))['then'](function(_0x48dbb7){if(_0x48dbb7){_0x31f324=_0x48dbb7;_0x3b1716['model']=_[_0x2c40('0xc5')](db[_0x2c40('0xe1')][_0x2c40('0xc4')]);_0x3b1716['query']=_[_0x2c40('0xc5')](_0x1db2ca[_0x2c40('0x3a')]);_0x3b1716[_0x2c40('0xc6')]=_['intersection'](_0x3b1716[_0x2c40('0xc2')],_0x3b1716[_0x2c40('0x3a')]);_0x37c664[_0x2c40('0x40')]=_[_0x2c40('0xc7')](_0x3b1716['model'],qs[_0x2c40('0xc8')](_0x1db2ca[_0x2c40('0x3a')][_0x2c40('0xc8')]));_0x37c664[_0x2c40('0x40')]=_0x37c664[_0x2c40('0x40')][_0x2c40('0x5f')]?_0x37c664[_0x2c40('0x40')]:_0x3b1716[_0x2c40('0xc2')];_0x37c664['order']=qs[_0x2c40('0xc9')](_0x1db2ca['query']['sort']);_0x37c664[_0x2c40('0x39')]=qs['filters'](_[_0x2c40('0xca')](_0x1db2ca['query'],_0x3b1716[_0x2c40('0xc6')]));if(_0x1db2ca['query'][_0x2c40('0x28')]){_0x37c664[_0x2c40('0x39')]=_[_0x2c40('0xcb')](_0x37c664['where'],{'$or':_[_0x2c40('0x32')](_0x37c664[_0x2c40('0x40')],function(_0x4557b7){var _0x283aee={};_0x283aee[_0x4557b7]={'$like':'%'+_0x1db2ca['query']['filter']+'%'};return _0x283aee;})});}_0x37c664=_[_0x2c40('0xcb')]({},_0x37c664,_0x1db2ca[_0x2c40('0x4d')]);return _0x31f324[_0x2c40('0xe0')](_0x37c664);}})[_0x2c40('0x1d')](function(_0x25dd35){if(_0x25dd35){_0xf0e78=_0x25dd35[_0x2c40('0x5f')];if(!_0x1db2ca[_0x2c40('0x3a')][_0x2c40('0xcd')](_0x2c40('0xce'))){_0x37c664[_0x2c40('0x19')]=qs[_0x2c40('0x19')](_0x1db2ca[_0x2c40('0x3a')][_0x2c40('0x19')]);_0x37c664[_0x2c40('0x17')]=qs[_0x2c40('0x17')](_0x1db2ca[_0x2c40('0x3a')]['offset']);}return _0x31f324[_0x2c40('0xe0')](_0x37c664);}})[_0x2c40('0x1d')](function(_0x1b229f){if(_0x1b229f){return _0x1b229f?{'count':_0xf0e78,'rows':_0x1b229f}:null;}})['then'](respondWithResult(_0x1be1c5,null))[_0x2c40('0x4a')](handleError(_0x1be1c5,null));};exports[_0x2c40('0xe2')]=function(_0x3fac56,_0x47b215,_0x276b54){var _0x37c309;var _0x2ecc5f;var _0xbba8e5;var _0x5bd4b7=!_[_0x2c40('0x59')](_0x3fac56['params']['id'])?_0x3fac56['params']['id']:!_['isNil'](_0x3fac56[_0x2c40('0x75')]['id'])?_0x3fac56[_0x2c40('0x75')]['id']:null;return db[_0x2c40('0x31')][_0x2c40('0x2c')]({'where':{'id':_0x5bd4b7,'role':{'$or':[_0x2c40('0x23'),_0x2c40('0x75'),_0x2c40('0x1e')]}},'attributes':['id',_0x2c40('0x2f'),_0x2c40('0xe3'),'mobile','role','internal','loginInPause']})['then'](function(_0x22fb96){if(_0x22fb96){if(_0x22fb96[_0x2c40('0x22')]===_0x2c40('0x1e')){_0x37c309=_0x22fb96;if(_0x3fac56[_0x2c40('0x4f')][_0x2c40('0x96')]){_0xbba8e5=util['format'](_0x2c40('0xe4'),_0x37c309[_0x3fac56[_0x2c40('0x4f')][_0x2c40('0x96')]]);}else if(_0x3fac56[_0x2c40('0x4f')][_0x2c40('0xe5')]){_0xbba8e5=util['format']('SIP/%s',_0x3fac56[_0x2c40('0x4f')][_0x2c40('0xe5')]);}else{_0xbba8e5=util[_0x2c40('0x9f')](_0x2c40('0xa0'),_0x37c309[_0x2c40('0x2f')]);}socket['to'](util[_0x2c40('0x9f')](_0x2c40('0xe6'),_0x37c309[_0x2c40('0x2f')]))[_0x2c40('0x1f')](_0x2c40('0xe7'),{'user':{'id':_0x37c309['id'],'name':_0x37c309[_0x2c40('0x2f')]},'ip':_0x3fac56[_0x2c40('0xe8')][_0x2c40('0xe9')]||_0x3fac56[_0x2c40('0xea')][_0x2c40('0xeb')]||_0x3fac56[_0x2c40('0xec')][_0x2c40('0xeb')]||_0x3fac56['connection'][_0x2c40('0xec')]['remoteAddress']});return db[_0x2c40('0xa1')][_0x2c40('0x20')]({'where':{'membername':_0x37c309[_0x2c40('0x2f')]},'individualHooks':!![]});}}else{throw new db[(_0x2c40('0x88'))][(_0x2c40('0x85'))]('User\x20not\x20found\x20or\x20not\x20allowed\x20to\x20perform\x20login\x20method');}})[_0x2c40('0x1d')](function(){if(_0x37c309){return _0x37c309[_0x2c40('0xed')]({'raw':!![]});}})['then'](function(_0x1bb69a){if(_0x37c309){if(_0x1bb69a){_0x2ecc5f=_0x1bb69a;if(_0x2ecc5f[_0x2c40('0x5f')]){var _0x3baf56=_0x2ecc5f[_0x2c40('0x32')](function(_0x29f37a){var _0x40cb2f={'membername':_0x37c309[_0x2c40('0x2f')],'UserId':_0x37c309['id'],'queue_name':_0x29f37a[_0x2c40('0x2f')],'VoiceQueueId':_0x29f37a['id'],'interface':_0xbba8e5,'paused':_0x37c309[_0x2c40('0x94')]||![],'penalty':_0x29f37a[_0x2c40('0xee')]||0x0};return db[_0x2c40('0xa1')][_0x2c40('0xa2')](_0x40cb2f);});return Promise[_0x2c40('0x49')](_0x3baf56);}}}})['then'](function(){if(_0x37c309){return db[_0x2c40('0xef')][_0x2c40('0x42')]({'where':{'membername':_0x37c309[_0x2c40('0x2f')],'exitAt':null}});}})[_0x2c40('0x1d')](function(_0x1b6091){if(_0x37c309){var _0xe9bff1=[];_0x1b6091['forEach'](function(_0x2c5c3e){_0xe9bff1[_0x2c40('0x41')](_0x2c5c3e[_0x2c40('0x1c')]({'exitAt':moment()[_0x2c40('0x9f')](_0x2c40('0xf0'))}));});return Promise[_0x2c40('0x49')](_0xe9bff1);}})[_0x2c40('0x1d')](function(){if(_0x37c309){var _0x727bc6=[];var _0x53fe97=[];var _0x7448fb=utils['getChannels']();var _0x5e2454={'membername':_0x37c309['name'],'interface':_0xbba8e5,'enterAt':moment()[_0x2c40('0x9f')](_0x2c40('0xf0')),'role':_0x37c309[_0x2c40('0x22')],'internal':_0x37c309['internal']};_0x7448fb['forEach'](function(_0x32bdec){_0x727bc6['push'](_[_0x2c40('0xcb')]({'channel':_0x32bdec,'type':_0x2c40('0xf1'),'data1':_0x3fac56[_0x2c40('0x4f')]['device'],'data2':_0xbba8e5},_0x5e2454));if(_0x37c309['loginInPause']){_0x53fe97[_0x2c40('0x41')](_['merge']({'channel':_0x32bdec,'type':'PAUSE','data1':_0x2c40('0xf2')},_0x5e2454));}});return db['MemberReport'][_0x2c40('0x7d')](_0x727bc6['concat'](_0x53fe97),{'individualHooks':!![]});}})[_0x2c40('0x1d')](function(){if(_0x37c309){return _0x37c309[_0x2c40('0x1c')]({'online':!![],'lastLoginAt':moment()[_0x2c40('0x9f')](_0x2c40('0xf0')),'voicePause':_0x37c309['loginInPause']||![],'mailPause':_0x37c309[_0x2c40('0x94')]||![],'chatPause':_0x37c309[_0x2c40('0x94')]||![],'faxPause':_0x37c309[_0x2c40('0x94')]||![],'smsPause':_0x37c309[_0x2c40('0x94')]||![],'openchannelPause':_0x37c309[_0x2c40('0x94')]||![],'whatsappPause':_0x37c309['loginInPause']||![],'pauseType':_0x37c309[_0x2c40('0x94')]?_0x2c40('0xf2'):null,'interface':_0xbba8e5,'lastPauseAt':moment()[_0x2c40('0x9f')](_0x2c40('0xf0'))});}})[_0x2c40('0x1d')](function(_0x263cca){if(_0x3fac56['isMiddleware']){return _0x276b54();}else{return Promise[_0x2c40('0xf3')](_0x263cca)[_0x2c40('0x1d')](respondWithResult(_0x47b215,null));}})[_0x2c40('0x4a')](handleError(_0x47b215,null));};exports[_0x2c40('0xf4')]=function(_0x521dbf,_0x2f984b){var _0x2ae2f3;return db[_0x2c40('0x31')]['find']({'where':{'id':_0x521dbf[_0x2c40('0x4c')]['id'],'role':_0x2c40('0x1e')},'attributes':['id',_0x2c40('0x2f'),'role']})[_0x2c40('0x1d')](handleEntityNotFound(_0x2f984b,null))['then'](function(_0xef6323){if(_0xef6323){_0x2ae2f3=_0xef6323;return db[_0x2c40('0xa1')]['destroy']({'where':{'membername':_0x2ae2f3['name']},'individualHooks':!![]});}})[_0x2c40('0x1d')](function(){return db[_0x2c40('0xef')][_0x2c40('0x42')]({'where':{'membername':_0x2ae2f3[_0x2c40('0x2f')],'exitAt':null}});})[_0x2c40('0x1d')](function(_0xaa032){var _0x58d1fe=[];_0xaa032[_0x2c40('0xf5')](function(_0x38a887){_0x58d1fe[_0x2c40('0x41')](_0x38a887[_0x2c40('0x1c')]({'exitAt':moment()['format'](_0x2c40('0xf0'))}));});return Promise['all'](_0x58d1fe);})[_0x2c40('0x1d')](function(){return _0x2ae2f3[_0x2c40('0x1c')]({'online':![],'voicePause':![],'mailPause':![],'chatPause':![],'faxPause':![],'smsPause':![],'openchannelPause':![],'whatsappPause':![],'interface':null});})['then'](respondWithResult(_0x2f984b,null))['catch'](handleError(_0x2f984b,null));};exports[_0x2c40('0xf6')]=function(_0x54d6dc,_0x5895ac){var _0x1f52f7;return db['UserVoiceQueueRt'][_0x2c40('0x1c')]({'paused':0x1},{'where':{'UserId':_0x54d6dc[_0x2c40('0x4c')]['id']},'individualHooks':!![]})['then'](function(){return db[_0x2c40('0x31')][_0x2c40('0x2c')]({'where':{'id':_0x54d6dc[_0x2c40('0x4c')]['id'],'role':_0x2c40('0x1e')},'attributes':['id',_0x2c40('0x2f'),_0x2c40('0x22'),_0x2c40('0x53'),_0x2c40('0x96'),_0x2c40('0x93')]});})[_0x2c40('0x1d')](handleEntityNotFound(_0x5895ac,null))[_0x2c40('0x1d')](function(_0x4b1e2d){if(_0x4b1e2d){_0x1f52f7=_0x4b1e2d;return db[_0x2c40('0xef')][_0x2c40('0x42')]({'where':{'membername':_0x1f52f7[_0x2c40('0x2f')],'type':_0x2c40('0xf7'),'exitAt':null}});}})[_0x2c40('0x1d')](function(_0x1d11c4){if(_0x1d11c4[_0x2c40('0x5f')]){var _0x4b9487=moment()['format']('YYYY-MM-DD\x20HH:mm:ss');for(var _0x68514b=0x0,_0x51e716=_0x1d11c4[_0x2c40('0x5f')];_0x68514b<_0x51e716;_0x68514b++){_0x1d11c4[_0x68514b][_0x2c40('0xf8')]({'exitAt':_0x4b9487});}}})[_0x2c40('0x1d')](function(){var _0x5780b7=[];var _0x8ca8e4=utils['getChannels']();_0x8ca8e4['forEach'](function(_0x376524){_0x5780b7['push']({'channel':_0x376524,'membername':_0x1f52f7[_0x2c40('0x2f')],'interface':_['isNil'](_0x1f52f7[_0x2c40('0x96')])?util['format'](_0x2c40('0xa0'),_0x1f52f7[_0x2c40('0x2f')]):_0x1f52f7['interface'],'type':_0x2c40('0xf7'),'enterAt':moment()[_0x2c40('0x9f')](_0x2c40('0xf0')),'data1':_0x54d6dc[_0x2c40('0x4f')][_0x2c40('0x34')]||_0x2c40('0xf9'),'role':_0x1f52f7['role'],'internal':_0x1f52f7[_0x2c40('0x53')]});});return db['MemberReport'][_0x2c40('0x7d')](_0x5780b7,{'individualHooks':!![]});})['then'](function(){return _0x1f52f7['update']({'voicePause':!![],'mailPause':!![],'chatPause':!![],'faxPause':!![],'smsPause':!![],'whatsappPause':!![],'openchannelPause':!![],'pauseType':_0x54d6dc[_0x2c40('0x4f')][_0x2c40('0x34')]||_0x2c40('0xf9'),'lastPauseAt':moment()[_0x2c40('0x9f')](_0x2c40('0xf0'))});})[_0x2c40('0x1d')](respondWithResult(_0x5895ac,null))[_0x2c40('0x4a')](handleError(_0x5895ac,null));};exports[_0x2c40('0xfa')]=function(_0x168065,_0x115d7d){if(_0x168065[_0x2c40('0x4f')][_0x2c40('0xa3')]&&!utils[_0x2c40('0x97')](_0x168065['body'][_0x2c40('0xa3')])){throw new APIBadRequestError(util[_0x2c40('0x9f')](_0x2c40('0xfb'),_0x168065[_0x2c40('0x4f')][_0x2c40('0xa3')]));}return db[_0x2c40('0x31')][_0x2c40('0x2c')]({'where':{'id':_0x168065['params']['id']},'attributes':['id',_0x2c40('0x2f'),_0x2c40('0x22'),'internal',_0x2c40('0x96'),_0x2c40('0x93'),_0x2c40('0x95'),_0x2c40('0xfc'),_0x2c40('0xfd'),'faxPause','openchannelPause',_0x2c40('0xfe'),_0x2c40('0xff'),'pauseType',_0x2c40('0x100')]})[_0x2c40('0x1d')](function(_0x4b8053){if(!_0x4b8053){throw new APINotFoundError(util[_0x2c40('0x9f')](_0x2c40('0xbd'),_0x168065[_0x2c40('0x4c')]['id']));}return _0x4b8053[_0x2c40('0xfa')](_0x168065[_0x2c40('0x4f')][_0x2c40('0xa3')]);})[_0x2c40('0x1d')](respondWithResult(_0x115d7d,null))[_0x2c40('0x4a')](APIHandleError(_0x115d7d));};exports[_0x2c40('0x101')]=function(_0x21a868,_0x5da1be){var _0x2c0fbe={};var _0x189e22={};var _0x1d8bb2;var _0x4483fd;return db[_0x2c40('0x31')][_0x2c40('0x8b')]({'where':{'id':_0x21a868[_0x2c40('0x4c')]['id']}})[_0x2c40('0x1d')](handleEntityNotFound(_0x5da1be,null))[_0x2c40('0x1d')](function(_0x3467ed){if(_0x3467ed){_0x1d8bb2=_0x3467ed;_0x189e22['model']=_[_0x2c40('0xc5')](db[_0x2c40('0x102')][_0x2c40('0xc4')]);_0x189e22[_0x2c40('0x3a')]=_[_0x2c40('0xc5')](_0x21a868['query']);_0x189e22[_0x2c40('0xc6')]=_[_0x2c40('0xc7')](_0x189e22[_0x2c40('0xc2')],_0x189e22[_0x2c40('0x3a')]);_0x2c0fbe[_0x2c40('0x40')]=_[_0x2c40('0xc7')](_0x189e22[_0x2c40('0xc2')],qs[_0x2c40('0xc8')](_0x21a868['query'][_0x2c40('0xc8')]));_0x2c0fbe[_0x2c40('0x40')]=_0x2c0fbe[_0x2c40('0x40')]['length']?_0x2c0fbe[_0x2c40('0x40')]:_0x189e22[_0x2c40('0xc2')];_0x2c0fbe['order']=qs[_0x2c40('0xc9')](_0x21a868['query'][_0x2c40('0xc9')]);_0x2c0fbe[_0x2c40('0x39')]=qs[_0x2c40('0xc6')](_[_0x2c40('0xca')](_0x21a868['query'],_0x189e22['filters']));if(_0x21a868[_0x2c40('0x3a')][_0x2c40('0x28')]){_0x2c0fbe[_0x2c40('0x39')]=_[_0x2c40('0xcb')](_0x2c0fbe[_0x2c40('0x39')],{'$or':_[_0x2c40('0x32')](_0x2c0fbe[_0x2c40('0x40')],function(_0x5ed70a){var _0x38a8d8={};_0x38a8d8[_0x5ed70a]={'$like':'%'+_0x21a868[_0x2c40('0x3a')][_0x2c40('0x28')]+'%'};return _0x38a8d8;})});}_0x2c0fbe=_[_0x2c40('0xcb')]({},_0x2c0fbe,_0x21a868[_0x2c40('0x4d')]);return _0x1d8bb2[_0x2c40('0x101')](_0x2c0fbe);}})[_0x2c40('0x1d')](function(_0x6f5beb){if(_0x6f5beb){_0x4483fd=_0x6f5beb[_0x2c40('0x5f')];if(!_0x21a868[_0x2c40('0x3a')]['hasOwnProperty'](_0x2c40('0xce'))){_0x2c0fbe[_0x2c40('0x19')]=qs[_0x2c40('0x19')](_0x21a868[_0x2c40('0x3a')]['limit']);_0x2c0fbe[_0x2c40('0x17')]=qs[_0x2c40('0x17')](_0x21a868[_0x2c40('0x3a')][_0x2c40('0x17')]);}return _0x1d8bb2['getTeams'](_0x2c0fbe);}})['then'](function(_0x5b105c){if(_0x5b105c){return _0x5b105c?{'count':_0x4483fd,'rows':_0x5b105c}:null;}})[_0x2c40('0x1d')](respondWithResult(_0x5da1be,null))['catch'](handleError(_0x5da1be,null));};exports[_0x2c40('0x103')]=function(_0x201d41,_0x3a7e3e){var _0x4618d9=_0x201d41['params']['id'];var _0x3e0ed7=_0x201d41[_0x2c40('0x4f')]?_0x201d41[_0x2c40('0x4f')]['ids']:null;var _0x50b12e=[];return Promise['resolve']()[_0x2c40('0x1d')](function(){if(!_0x3e0ed7)throw new APIBadRequestError(_0x2c40('0x104'));})['then'](function(){return db[_0x2c40('0x31')][_0x2c40('0x8b')]({'where':{'id':_0x4618d9}});})[_0x2c40('0x1d')](function(_0x14b976){if(!_0x14b976)throw new APINotFoundError(util[_0x2c40('0x9f')](_0x2c40('0xbd'),_0x201d41[_0x2c40('0x4c')]['id']));return db[_0x2c40('0x5b')][_0x2c40('0x105')](function(_0x56ab77){return _0x14b976['addTeams'](_0x3e0ed7,{'transaction':_0x56ab77})[_0x2c40('0x1d')](function(){return db[_0x2c40('0x102')][_0x2c40('0x42')]({'where':{'id':{'$in':_0x3e0ed7}}});})[_0x2c40('0x1d')](function(_0x58eec8){var _0xb126e9=_[_0x2c40('0x32')](_0x58eec8,function(_0x371392){return _0x371392[_0x2c40('0x106')]();});return Promise[_0x2c40('0x49')](_0xb126e9);})[_0x2c40('0x1d')](function(_0x16d2df){_0x50b12e=_[_0x2c40('0x107')](_0x16d2df);var _0x3df88e=_[_0x2c40('0x32')](_0x50b12e,function(_0x3311f4){return _0x3311f4[_0x2c40('0x108')](_0x14b976['id'],{'transaction':_0x56ab77});});return Promise[_0x2c40('0x49')](_0x3df88e);})[_0x2c40('0x1d')](function(){if(!_0x14b976[_0x2c40('0x93')])return;var _0x561fa0=_[_0x2c40('0x28')](_0x50b12e,function(_0x2ffc89){return _0x2ffc89[_0x2c40('0x109')](_0x2c40('0xa3'))===_0x2c40('0x10a');});var _0x5744f2=_[_0x2c40('0x32')](_0x561fa0,function(_0xd2f7b3){return db[_0x2c40('0xa1')][_0x2c40('0xa2')]({'membername':_0x14b976['name'],'UserId':_0x14b976['id'],'queue_name':_0xd2f7b3[_0x2c40('0x2f')],'VoiceQueueId':_0xd2f7b3['id'],'interface':_[_0x2c40('0x59')](_0x14b976[_0x2c40('0x96')])?util[_0x2c40('0x9f')]('SIP/%s',_0x14b976['name']):_0x14b976[_0x2c40('0x96')],'paused':_0x14b976['voicePause']||![],'penalty':_0x14b976['penalty']},{'transaction':_0x56ab77});});return Promise[_0x2c40('0x49')](_0x5744f2);})[_0x2c40('0x1d')](function(){return db[_0x2c40('0x10b')][_0x2c40('0x42')]({'where':{'teamId':{'$in':_0x3e0ed7}}});})[_0x2c40('0x1d')](function(_0x254d79){var _0x8f346=_[_0x2c40('0x32')](_0x254d79,function(_0x479387){return db[_0x2c40('0x10c')]['create']({'UserId':_0x14b976['id'],'VoicePrefixId':_0x479387[_0x2c40('0x10d')]},{'transaction':_0x56ab77});});return Promise['all'](_0x8f346);});});})['then'](function(){for(var _0xdb1c28=0x0;_0xdb1c28<_0x50b12e[_0x2c40('0x5f')];_0xdb1c28++){var _0x22e943=_0x50b12e[_0xdb1c28][_0x2c40('0x109')](_0x2c40('0xa3'));var _0x577480=_0x22e943+'QueueId';socket[_0x2c40('0x1f')](_0x2c40('0x75')+_0x22e943+_0x2c40('0x9e'),{'UserId':_0x4618d9,['queueField']:_0x50b12e[_0xdb1c28]['id']});}})[_0x2c40('0x1d')](respondWithStatusCode(_0x3a7e3e,null))['catch'](APIHandleError(_0x3a7e3e));};exports[_0x2c40('0x10e')]=function(_0x55420d,_0x2b579c){var _0x42575d=_0x55420d['params']['id'];var _0x5f666=null;if(_0x55420d[_0x2c40('0x3a')][_0x2c40('0x51')]){_0x5f666=_[_0x2c40('0x10f')](_0x55420d[_0x2c40('0x3a')][_0x2c40('0x51')])?_0x55420d[_0x2c40('0x3a')][_0x2c40('0x51')]:[_0x55420d[_0x2c40('0x3a')]['ids']];}var _0x4a43ff=[];return Promise[_0x2c40('0xf3')]()[_0x2c40('0x1d')](function(){if(!_0x5f666)throw new APIBadRequestError('Query\x20parameter\x20\x27ids\x27\x20is\x20required');})['then'](function(){return db[_0x2c40('0x31')][_0x2c40('0x8b')]({'where':{'id':_0x42575d}});})[_0x2c40('0x1d')](function(_0x32e006){if(!_0x32e006)throw new APINotFoundError(util['format']('User\x20with\x20id\x20%s\x20not\x20found',_0x55420d[_0x2c40('0x4c')]['id']));return db['sequelize'][_0x2c40('0x105')](function(_0x41d54d){return _0x32e006['removeTeams'](_0x5f666,{'transaction':_0x41d54d})[_0x2c40('0x1d')](function(){return db[_0x2c40('0x102')]['findAll']({'where':{'id':{'$in':_0x5f666}}});})[_0x2c40('0x1d')](function(_0x593b73){var _0x326b3f=_[_0x2c40('0x32')](_0x593b73,function(_0x14a70b){return _0x14a70b[_0x2c40('0x106')]();});return Promise['all'](_0x326b3f);})[_0x2c40('0x1d')](function(_0x1c880c){_0x4a43ff=_[_0x2c40('0x107')](_0x1c880c);var _0x39d3fd=_[_0x2c40('0x32')](_0x4a43ff,function(_0x147341){return _0x147341[_0x2c40('0x110')](_0x32e006['id'],{'transaction':_0x41d54d});});return Promise[_0x2c40('0x49')](_0x39d3fd);})[_0x2c40('0x1d')](function(){if(!_0x32e006[_0x2c40('0x93')])return;var _0x3d1ec5=_[_0x2c40('0x28')](_0x4a43ff,function(_0x2ada1d){return _0x2ada1d[_0x2c40('0x109')](_0x2c40('0xa3'))==='Voice';});var _0x55cd57=_[_0x2c40('0x32')](_0x3d1ec5,function(_0x4039b2){return db[_0x2c40('0xa1')][_0x2c40('0x20')]({'where':{'VoiceQueueId':_0x4039b2['id'],'UserId':_0x32e006['id']},'transaction':_0x41d54d});});return Promise[_0x2c40('0x49')](_0x55cd57);})[_0x2c40('0x1d')](function(){return db[_0x2c40('0x10b')][_0x2c40('0x42')]({'where':{'teamId':{'$in':_0x5f666}}});})[_0x2c40('0x1d')](function(_0x44e905){var _0xb37484=_[_0x2c40('0x32')](_0x44e905,function(_0x35a20b){return db['UserVoicePrefix'][_0x2c40('0x20')]({'where':{'UserId':_0x32e006['id'],'VoicePrefixId':_0x35a20b[_0x2c40('0x10d')]}},{'transaction':_0x41d54d});});return Promise[_0x2c40('0x49')](_0xb37484);});});})[_0x2c40('0x1d')](function(){for(var _0x1ddecb=0x0;_0x1ddecb<_0x4a43ff[_0x2c40('0x5f')];_0x1ddecb++){var _0x3be1e6=_0x4a43ff[_0x1ddecb]['getDataValue']('channel');var _0x2b9953=_0x3be1e6+_0x2c40('0x9d');socket['emit'](_0x2c40('0x75')+_0x3be1e6+_0x2c40('0xa5'),{'UserId':_0x42575d,['queueField']:_0x4a43ff[_0x1ddecb]['id']});}})['then'](respondWithStatusCode(_0x2b579c,null))[_0x2c40('0x4a')](APIHandleError(_0x2b579c));};exports[_0x2c40('0x111')]=function(_0x3c7778,_0x37617e){var _0x541e44={};var _0x16d666={};var _0x10877a;var _0x438191;return db[_0x2c40('0x31')][_0x2c40('0x8b')]({'where':{'id':_0x3c7778['params']['id']}})[_0x2c40('0x1d')](handleEntityNotFound(_0x37617e,null))[_0x2c40('0x1d')](function(_0x589cbe){if(_0x589cbe){_0x10877a=_0x589cbe;_0x16d666[_0x2c40('0xc2')]=_[_0x2c40('0xc5')](db[_0x2c40('0x112')][_0x2c40('0xc4')]);_0x16d666[_0x2c40('0x3a')]=_['keys'](_0x3c7778[_0x2c40('0x3a')]);_0x16d666[_0x2c40('0xc6')]=_[_0x2c40('0xc7')](_0x16d666['model'],_0x16d666[_0x2c40('0x3a')]);_0x541e44[_0x2c40('0x40')]=_[_0x2c40('0xc7')](_0x16d666[_0x2c40('0xc2')],qs[_0x2c40('0xc8')](_0x3c7778['query'][_0x2c40('0xc8')]));_0x541e44[_0x2c40('0x40')]=_0x541e44['attributes']['length']?_0x541e44[_0x2c40('0x40')]:_0x16d666['model'];_0x541e44['order']=qs['sort'](_0x3c7778[_0x2c40('0x3a')][_0x2c40('0xc9')]);_0x541e44[_0x2c40('0x39')]=qs[_0x2c40('0xc6')](_[_0x2c40('0xca')](_0x3c7778[_0x2c40('0x3a')],_0x16d666[_0x2c40('0xc6')]));if(_0x3c7778[_0x2c40('0x3a')][_0x2c40('0x28')]){_0x541e44[_0x2c40('0x39')]=_['merge'](_0x541e44[_0x2c40('0x39')],{'$or':_[_0x2c40('0x32')](_0x541e44[_0x2c40('0x40')],function(_0x5938f7){var _0x421e77={};_0x421e77[_0x5938f7]={'$like':'%'+_0x3c7778[_0x2c40('0x3a')][_0x2c40('0x28')]+'%'};return _0x421e77;})});}_0x541e44=_[_0x2c40('0xcb')]({},_0x541e44,_0x3c7778[_0x2c40('0x4d')]);return _0x10877a[_0x2c40('0x111')](_0x541e44);}})[_0x2c40('0x1d')](function(_0x399b13){if(_0x399b13){_0x438191=_0x399b13[_0x2c40('0x5f')];if(!_0x3c7778[_0x2c40('0x3a')][_0x2c40('0xcd')](_0x2c40('0xce'))){_0x541e44[_0x2c40('0x19')]=qs[_0x2c40('0x19')](_0x3c7778['query']['limit']);_0x541e44[_0x2c40('0x17')]=qs['offset'](_0x3c7778[_0x2c40('0x3a')][_0x2c40('0x17')]);}return _0x10877a[_0x2c40('0x111')](_0x541e44);}})['then'](function(_0x548c9a){if(_0x548c9a){return _0x548c9a?{'count':_0x438191,'rows':_0x548c9a}:null;}})[_0x2c40('0x1d')](respondWithResult(_0x37617e,null))[_0x2c40('0x4a')](handleError(_0x37617e,null));};exports[_0x2c40('0x113')]=function(_0x423fa4,_0x2791d0){var _0x4ea74e={};var _0x5c4db={};var _0x1d03f9;return db['User']['findOne']({'where':{'id':_0x423fa4[_0x2c40('0x4c')]['id']}})['then'](handleEntityNotFound(_0x2791d0,null))[_0x2c40('0x1d')](function(_0x5313f9){if(_0x5313f9){_0x1d03f9=_0x5313f9;_0x5c4db[_0x2c40('0xc2')]=_['keys'](db['User'][_0x2c40('0xc4')]);_0x5c4db[_0x2c40('0x3a')]=_['keys'](_0x423fa4[_0x2c40('0x3a')]);_0x5c4db[_0x2c40('0xc6')]=_[_0x2c40('0xc7')](_0x5c4db['model'],_0x5c4db[_0x2c40('0x3a')]);_0x4ea74e['attributes']=_[_0x2c40('0xc7')](_0x5c4db[_0x2c40('0xc2')],qs[_0x2c40('0xc8')](_0x423fa4[_0x2c40('0x3a')][_0x2c40('0xc8')]));_0x4ea74e['attributes']=_0x4ea74e[_0x2c40('0x40')][_0x2c40('0x5f')]?_0x4ea74e[_0x2c40('0x40')]:_0x5c4db['model'];_0x4ea74e[_0x2c40('0xcf')]=qs[_0x2c40('0xc9')](_0x423fa4[_0x2c40('0x3a')][_0x2c40('0xc9')]);_0x4ea74e['where']=qs[_0x2c40('0xc6')](_[_0x2c40('0xca')](_0x423fa4[_0x2c40('0x3a')],_0x5c4db['filters']));if(_0x423fa4[_0x2c40('0x3a')][_0x2c40('0x28')]){_0x4ea74e['where']=_[_0x2c40('0xcb')](_0x4ea74e[_0x2c40('0x39')],{'$or':_[_0x2c40('0x32')](_0x4ea74e[_0x2c40('0x40')],function(_0x3efb93){var _0x3f0456={};_0x3f0456[_0x3efb93]={'$like':'%'+_0x423fa4['query'][_0x2c40('0x28')]+'%'};return _0x3f0456;})});}_0x4ea74e[_0x2c40('0xc2')]=db['User'];_0x4ea74e['as']=_0x2c40('0x25');_0x4ea74e=_[_0x2c40('0xcb')]({},_0x4ea74e,_0x423fa4[_0x2c40('0x4d')]);return _0x1d03f9['getVoiceQueues']({'include':[_0x4ea74e]});}})[_0x2c40('0x1d')](function(_0x560e20){if(_0x560e20){var _0x3f9593={},_0x50c569=[];for(var _0x1c1d65=0x0;_0x1c1d65<_0x560e20[_0x2c40('0x5f')];_0x1c1d65+=0x1){for(var _0x1192ef=0x0,_0x35b985;_0x1192ef<_0x560e20[_0x1c1d65][_0x2c40('0x25')][_0x2c40('0x5f')];_0x1192ef+=0x1){_0x35b985=_0x560e20[_0x1c1d65][_0x2c40('0x25')][_0x1192ef][_0x2c40('0x21')]({'plain':!![]});_0x3f9593[_0x35b985['id']]=_0x35b985;}}_0x3f9593=_[_0x2c40('0x114')](_0x3f9593);for(var _0x3646cc=qs['offset'](_0x423fa4['query'][_0x2c40('0x17')]);_0x3646cc<_0x3f9593[_0x2c40('0x5f')]&&_0x50c569[_0x2c40('0x5f')]<qs[_0x2c40('0x19')](_0x423fa4['query'][_0x2c40('0x19')]);_0x3646cc+=0x1){if(_0x3f9593[_0x3646cc]){_0x50c569[_0x2c40('0x41')](_0x3f9593[_0x3646cc]);}}return{'count':_0x3f9593[_0x2c40('0x5f')],'rows':_0x50c569};}})['then'](respondWithResult(_0x2791d0,null))[_0x2c40('0x4a')](handleError(_0x2791d0,null));};exports['destroy']=function(_0x488cd8,_0x19b605){if(_0x488cd8['user']['id']==_0x488cd8['params']['id']){return _0x19b605[_0x2c40('0x15')](0x1f4)[_0x2c40('0x30')]({'message':_0x2c40('0x115')});}return db[_0x2c40('0x31')][_0x2c40('0x2c')]({'where':{'id':_0x488cd8['params']['id']}})[_0x2c40('0x1d')](handleEntityNotFound(_0x19b605,null))[_0x2c40('0x1d')](removeEntity(_0x19b605,null))[_0x2c40('0x4a')](handleError(_0x19b605,null));};exports[_0x2c40('0x116')]=function(_0x4c401b,_0x44ab36){return db[_0x2c40('0x31')][_0x2c40('0x2c')]({'where':{'id':_0x4c401b[_0x2c40('0x4c')]['id']}})['then'](handleEntityNotFound(_0x44ab36,null))[_0x2c40('0x1d')](function(_0x43e937){if(_0x43e937){return _0x43e937['addChatInteractions'](_0x4c401b[_0x2c40('0x4f')][_0x2c40('0x51')],_[_0x2c40('0x52')](_0x4c401b[_0x2c40('0x4f')],[_0x2c40('0x51'),'id'])||{})[_0x2c40('0x9c')](function(){for(var _0x4c9a87=0x0;_0x4c9a87<_0x4c401b[_0x2c40('0x4f')][_0x2c40('0x51')][_0x2c40('0x5f')];_0x4c9a87+=0x1){socket[_0x2c40('0x1f')](_0x2c40('0x117'),{'ChatInteractionId':Number(_0x4c401b[_0x2c40('0x4f')]['ids'][_0x4c9a87]),'UserId':Number(_0x4c401b['params']['id'])});}return _0x4c401b[_0x2c40('0x4f')][_0x2c40('0x51')];});}})[_0x2c40('0x1d')](respondWithResult(_0x44ab36,null))['catch'](handleError(_0x44ab36,null));};exports[_0x2c40('0x118')]=function(_0x5be68a,_0x3e0e02){return db[_0x2c40('0x31')]['find']({'where':{'id':_0x5be68a[_0x2c40('0x4c')]['id']}})[_0x2c40('0x1d')](handleEntityNotFound(_0x3e0e02,null))['then'](function(_0x42dd8c){if(_0x42dd8c){return _0x42dd8c[_0x2c40('0x118')](_0x5be68a[_0x2c40('0x3a')][_0x2c40('0x51')])['then'](function(){if(_['isArray'](_0x5be68a[_0x2c40('0x3a')]['ids'])){for(var _0xbb2d17=0x0;_0xbb2d17<_0x5be68a[_0x2c40('0x3a')][_0x2c40('0x51')][_0x2c40('0x5f')];_0xbb2d17+=0x1){socket['emit'](_0x2c40('0x119'),{'ChatInteractionId':Number(_0x5be68a[_0x2c40('0x3a')][_0x2c40('0x51')][_0xbb2d17]),'UserId':Number(_0x5be68a[_0x2c40('0x4c')]['id'])});}}else{socket[_0x2c40('0x1f')](_0x2c40('0x119'),{'ChatInteractionId':Number(_0x5be68a[_0x2c40('0x3a')]['ids']),'UserId':Number(_0x5be68a['params']['id'])});}});}})[_0x2c40('0x1d')](respondWithStatusCode(_0x3e0e02,null))['catch'](handleError(_0x3e0e02,null));};exports[_0x2c40('0x11a')]=function(_0x26395c,_0x56cfe7){return db[_0x2c40('0x31')][_0x2c40('0x2c')]({'where':{'id':_0x26395c[_0x2c40('0x4c')]['id']}})[_0x2c40('0x1d')](handleEntityNotFound(_0x56cfe7,null))[_0x2c40('0x1d')](function(_0x1f7c90){if(_0x1f7c90){return _0x1f7c90['addMailInteractions'](_0x26395c[_0x2c40('0x4f')][_0x2c40('0x51')],_[_0x2c40('0x52')](_0x26395c[_0x2c40('0x4f')],[_0x2c40('0x51'),'id'])||{})[_0x2c40('0x9c')](function(){for(var _0x131db8=0x0;_0x131db8<_0x26395c[_0x2c40('0x4f')][_0x2c40('0x51')][_0x2c40('0x5f')];_0x131db8+=0x1){socket[_0x2c40('0x1f')](_0x2c40('0x11b'),{'MailInteractionId':Number(_0x26395c[_0x2c40('0x4f')][_0x2c40('0x51')][_0x131db8]),'UserId':Number(_0x26395c[_0x2c40('0x4c')]['id'])});}return _0x26395c[_0x2c40('0x4f')][_0x2c40('0x51')];});}})[_0x2c40('0x1d')](respondWithResult(_0x56cfe7,null))[_0x2c40('0x4a')](handleError(_0x56cfe7,null));};exports['removeMailInteractions']=function(_0x3a0708,_0x3725fa){return db[_0x2c40('0x31')][_0x2c40('0x2c')]({'where':{'id':_0x3a0708['params']['id']}})[_0x2c40('0x1d')](handleEntityNotFound(_0x3725fa,null))[_0x2c40('0x1d')](function(_0xaaa812){if(_0xaaa812){return _0xaaa812[_0x2c40('0x11c')](_0x3a0708[_0x2c40('0x3a')]['ids'])[_0x2c40('0x1d')](function(){if(_[_0x2c40('0x10f')](_0x3a0708[_0x2c40('0x3a')]['ids'])){for(var _0x5df880=0x0;_0x5df880<_0x3a0708[_0x2c40('0x3a')][_0x2c40('0x51')]['length'];_0x5df880+=0x1){socket[_0x2c40('0x1f')](_0x2c40('0x11d'),{'MailInteractionId':Number(_0x3a0708[_0x2c40('0x3a')][_0x2c40('0x51')][_0x5df880]),'UserId':Number(_0x3a0708[_0x2c40('0x4c')]['id'])});}}else{socket['emit']('user_has_mail_interactions:remove',{'MailInteractionId':Number(_0x3a0708['query'][_0x2c40('0x51')]),'UserId':Number(_0x3a0708[_0x2c40('0x4c')]['id'])});}});}})[_0x2c40('0x1d')](respondWithStatusCode(_0x3725fa,null))[_0x2c40('0x4a')](handleError(_0x3725fa,null));};exports['addFaxInteractions']=function(_0x12cd24,_0x50c38d){return db[_0x2c40('0x31')][_0x2c40('0x2c')]({'where':{'id':_0x12cd24[_0x2c40('0x4c')]['id']}})[_0x2c40('0x1d')](handleEntityNotFound(_0x50c38d,null))[_0x2c40('0x1d')](function(_0x2363b7){if(_0x2363b7){return _0x2363b7[_0x2c40('0x11e')](_0x12cd24[_0x2c40('0x4f')][_0x2c40('0x51')],_[_0x2c40('0x52')](_0x12cd24[_0x2c40('0x4f')],['ids','id'])||{})['spread'](function(){for(var _0x492b83=0x0;_0x492b83<_0x12cd24['body']['ids']['length'];_0x492b83+=0x1){socket['emit'](_0x2c40('0x11f'),{'FaxInteractionId':Number(_0x12cd24[_0x2c40('0x4f')][_0x2c40('0x51')][_0x492b83]),'UserId':Number(_0x12cd24['params']['id'])});}return _0x12cd24['body'][_0x2c40('0x51')];});}})['then'](respondWithResult(_0x50c38d,null))['catch'](handleError(_0x50c38d,null));};exports[_0x2c40('0x120')]=function(_0x5531ee,_0x48f02){return db[_0x2c40('0x31')][_0x2c40('0x2c')]({'where':{'id':_0x5531ee['params']['id']}})[_0x2c40('0x1d')](handleEntityNotFound(_0x48f02,null))[_0x2c40('0x1d')](function(_0x28b343){if(_0x28b343){return _0x28b343['removeFaxInteractions'](_0x5531ee[_0x2c40('0x3a')][_0x2c40('0x51')])[_0x2c40('0x1d')](function(){if(_[_0x2c40('0x10f')](_0x5531ee['query'][_0x2c40('0x51')])){for(var _0x3a850a=0x0;_0x3a850a<_0x5531ee['query'][_0x2c40('0x51')]['length'];_0x3a850a+=0x1){socket['emit']('user_has_fax_interactions:remove',{'FaxInteractionId':Number(_0x5531ee['query'][_0x2c40('0x51')][_0x3a850a]),'UserId':Number(_0x5531ee['params']['id'])});}}else{socket[_0x2c40('0x1f')](_0x2c40('0x121'),{'FaxInteractionId':Number(_0x5531ee['query'][_0x2c40('0x51')]),'UserId':Number(_0x5531ee['params']['id'])});}});}})[_0x2c40('0x1d')](respondWithStatusCode(_0x48f02,null))[_0x2c40('0x4a')](handleError(_0x48f02,null));};exports['addSmsInteractions']=function(_0x4e7e03,_0x1c4fa1){return db['User'][_0x2c40('0x2c')]({'where':{'id':_0x4e7e03[_0x2c40('0x4c')]['id']}})[_0x2c40('0x1d')](handleEntityNotFound(_0x1c4fa1,null))['then'](function(_0x4630eb){if(_0x4630eb){return _0x4630eb[_0x2c40('0x122')](_0x4e7e03['body'][_0x2c40('0x51')],_[_0x2c40('0x52')](_0x4e7e03[_0x2c40('0x4f')],[_0x2c40('0x51'),'id'])||{})[_0x2c40('0x9c')](function(){for(var _0x20aaeb=0x0;_0x20aaeb<_0x4e7e03[_0x2c40('0x4f')][_0x2c40('0x51')]['length'];_0x20aaeb+=0x1){socket['emit'](_0x2c40('0x123'),{'SmsInteractionId':Number(_0x4e7e03[_0x2c40('0x4f')][_0x2c40('0x51')][_0x20aaeb]),'UserId':Number(_0x4e7e03['params']['id'])});}return _0x4e7e03[_0x2c40('0x4f')][_0x2c40('0x51')];});}})[_0x2c40('0x1d')](respondWithResult(_0x1c4fa1,null))[_0x2c40('0x4a')](handleError(_0x1c4fa1,null));};exports[_0x2c40('0x124')]=function(_0x3cda1f,_0x12cbc1){return db[_0x2c40('0x31')][_0x2c40('0x2c')]({'where':{'id':_0x3cda1f[_0x2c40('0x4c')]['id']}})[_0x2c40('0x1d')](handleEntityNotFound(_0x12cbc1,null))[_0x2c40('0x1d')](function(_0x29dd4c){if(_0x29dd4c){return _0x29dd4c[_0x2c40('0x124')](_0x3cda1f[_0x2c40('0x3a')][_0x2c40('0x51')])[_0x2c40('0x1d')](function(){if(_[_0x2c40('0x10f')](_0x3cda1f['query'][_0x2c40('0x51')])){for(var _0x3378fb=0x0;_0x3378fb<_0x3cda1f[_0x2c40('0x3a')][_0x2c40('0x51')]['length'];_0x3378fb+=0x1){socket[_0x2c40('0x1f')](_0x2c40('0x125'),{'SmsInteractionId':Number(_0x3cda1f[_0x2c40('0x3a')]['ids'][_0x3378fb]),'UserId':Number(_0x3cda1f['params']['id'])});}}else{socket[_0x2c40('0x1f')](_0x2c40('0x125'),{'SmsInteractionId':Number(_0x3cda1f[_0x2c40('0x3a')][_0x2c40('0x51')]),'UserId':Number(_0x3cda1f[_0x2c40('0x4c')]['id'])});}});}})[_0x2c40('0x1d')](respondWithStatusCode(_0x12cbc1,null))[_0x2c40('0x4a')](handleError(_0x12cbc1,null));};exports[_0x2c40('0x126')]=function(_0x3d528e,_0x26b019){return db[_0x2c40('0x31')][_0x2c40('0x2c')]({'where':{'id':_0x3d528e[_0x2c40('0x4c')]['id']}})[_0x2c40('0x1d')](handleEntityNotFound(_0x26b019,null))[_0x2c40('0x1d')](function(_0x1ebe38){if(_0x1ebe38){return _0x1ebe38[_0x2c40('0x126')](_0x3d528e[_0x2c40('0x4f')][_0x2c40('0x51')],_[_0x2c40('0x52')](_0x3d528e['body'],[_0x2c40('0x51'),'id'])||{})[_0x2c40('0x9c')](function(){for(var _0x46c13a=0x0;_0x46c13a<_0x3d528e['body'][_0x2c40('0x51')]['length'];_0x46c13a+=0x1){socket[_0x2c40('0x1f')]('user_has_openchannel_interactions:save',{'OpenchannelInteractionId':Number(_0x3d528e['body']['ids'][_0x46c13a]),'UserId':Number(_0x3d528e[_0x2c40('0x4c')]['id'])});}return _0x3d528e[_0x2c40('0x4f')][_0x2c40('0x51')];});}})['then'](respondWithResult(_0x26b019,null))[_0x2c40('0x4a')](handleError(_0x26b019,null));};exports['removeOpenchannelInteractions']=function(_0x2b834b,_0x2bada9){return db[_0x2c40('0x31')][_0x2c40('0x2c')]({'where':{'id':_0x2b834b[_0x2c40('0x4c')]['id']}})[_0x2c40('0x1d')](handleEntityNotFound(_0x2bada9,null))[_0x2c40('0x1d')](function(_0x329a66){if(_0x329a66){return _0x329a66[_0x2c40('0x127')](_0x2b834b['query'][_0x2c40('0x51')])[_0x2c40('0x1d')](function(){if(_[_0x2c40('0x10f')](_0x2b834b['query']['ids'])){for(var _0x559545=0x0;_0x559545<_0x2b834b['query'][_0x2c40('0x51')][_0x2c40('0x5f')];_0x559545+=0x1){socket['emit'](_0x2c40('0x128'),{'OpenchannelInteractionId':Number(_0x2b834b[_0x2c40('0x3a')][_0x2c40('0x51')][_0x559545]),'UserId':Number(_0x2b834b[_0x2c40('0x4c')]['id'])});}}else{socket[_0x2c40('0x1f')](_0x2c40('0x128'),{'OpenchannelInteractionId':Number(_0x2b834b['query'][_0x2c40('0x51')]),'UserId':Number(_0x2b834b[_0x2c40('0x4c')]['id'])});}});}})[_0x2c40('0x1d')](respondWithStatusCode(_0x2bada9,null))[_0x2c40('0x4a')](handleError(_0x2bada9,null));};exports[_0x2c40('0x129')]=function(_0x1124e1,_0x1741b3){return db[_0x2c40('0x31')]['find']({'where':{'id':_0x1124e1['params']['id']}})[_0x2c40('0x1d')](handleEntityNotFound(_0x1741b3,null))[_0x2c40('0x1d')](function(_0x49a41b){if(_0x49a41b){return _0x49a41b[_0x2c40('0x129')](_0x1124e1[_0x2c40('0x4f')][_0x2c40('0x51')],_['omit'](_0x1124e1[_0x2c40('0x4f')],['ids','id'])||{})['spread'](function(){for(var _0x2f1ade=0x0;_0x2f1ade<_0x1124e1['body'][_0x2c40('0x51')][_0x2c40('0x5f')];_0x2f1ade+=0x1){socket[_0x2c40('0x1f')](_0x2c40('0x12a'),{'WhatsappInteractionId':Number(_0x1124e1[_0x2c40('0x4f')][_0x2c40('0x51')][_0x2f1ade]),'UserId':Number(_0x1124e1[_0x2c40('0x4c')]['id'])});}return _0x1124e1[_0x2c40('0x4f')][_0x2c40('0x51')];});}})[_0x2c40('0x1d')](respondWithResult(_0x1741b3,null))['catch'](handleError(_0x1741b3,null));};exports[_0x2c40('0x12b')]=function(_0x1bec6d,_0x2c8506){return db[_0x2c40('0x31')][_0x2c40('0x2c')]({'where':{'id':_0x1bec6d['params']['id']}})[_0x2c40('0x1d')](handleEntityNotFound(_0x2c8506,null))[_0x2c40('0x1d')](function(_0x31d9e1){if(_0x31d9e1){return _0x31d9e1[_0x2c40('0x12b')](_0x1bec6d['query'][_0x2c40('0x51')]);}})[_0x2c40('0x1d')](respondWithStatusCode(_0x2c8506,null))['catch'](handleError(_0x2c8506,null));};exports[_0x2c40('0x12c')]=function(_0x41818b,_0x3159ec){var _0x4d7653={};var _0x3e1484={};var _0x53c8fc;var _0x37c13f;return db['User'][_0x2c40('0x8b')]({'where':{'id':_0x41818b['params']['id']}})[_0x2c40('0x1d')](handleEntityNotFound(_0x3159ec,null))[_0x2c40('0x1d')](function(_0x20c34f){if(_0x20c34f){_0x53c8fc=_0x20c34f;_0x3e1484[_0x2c40('0xc2')]=_['keys'](db[_0x2c40('0x12d')][_0x2c40('0xc4')]);_0x3e1484[_0x2c40('0x3a')]=_['keys'](_0x41818b[_0x2c40('0x3a')]);_0x3e1484[_0x2c40('0xc6')]=_[_0x2c40('0xc7')](_0x3e1484['model'],_0x3e1484[_0x2c40('0x3a')]);_0x4d7653['attributes']=_[_0x2c40('0xc7')](_0x3e1484['model'],qs[_0x2c40('0xc8')](_0x41818b[_0x2c40('0x3a')][_0x2c40('0xc8')]));_0x4d7653['attributes']=_0x4d7653[_0x2c40('0x40')]['length']?_0x4d7653[_0x2c40('0x40')]:_0x3e1484[_0x2c40('0xc2')];_0x4d7653['order']=qs[_0x2c40('0xc9')](_0x41818b[_0x2c40('0x3a')][_0x2c40('0xc9')]);_0x4d7653['where']=qs['filters'](_[_0x2c40('0xca')](_0x41818b['query'],_0x3e1484[_0x2c40('0xc6')]));if(_0x41818b[_0x2c40('0x3a')]['filter']){_0x4d7653[_0x2c40('0x39')]=_[_0x2c40('0xcb')](_0x4d7653[_0x2c40('0x39')],{'$or':_[_0x2c40('0x32')](_0x4d7653['attributes'],function(_0x2fa65f){var _0x22cf07={};_0x22cf07[_0x2fa65f]={'$like':'%'+_0x41818b[_0x2c40('0x3a')][_0x2c40('0x28')]+'%'};return _0x22cf07;})});}_0x4d7653=_[_0x2c40('0xcb')]({},_0x4d7653,_0x41818b[_0x2c40('0x4d')]);return _0x53c8fc[_0x2c40('0x12c')](_0x4d7653);}})[_0x2c40('0x1d')](function(_0x29a5a7){if(_0x29a5a7){_0x37c13f=_0x29a5a7[_0x2c40('0x5f')];if(!_0x41818b[_0x2c40('0x3a')][_0x2c40('0xcd')](_0x2c40('0xce'))){_0x4d7653[_0x2c40('0x19')]=qs[_0x2c40('0x19')](_0x41818b[_0x2c40('0x3a')][_0x2c40('0x19')]);_0x4d7653[_0x2c40('0x17')]=qs[_0x2c40('0x17')](_0x41818b['query'][_0x2c40('0x17')]);}return _0x53c8fc['getVoicePrefixes'](_0x4d7653);}})[_0x2c40('0x1d')](function(_0x4e6db4){if(_0x4e6db4){return _0x4e6db4?{'count':_0x37c13f,'rows':_0x4e6db4}:null;}})[_0x2c40('0x1d')](respondWithResult(_0x3159ec,null))['catch'](handleError(_0x3159ec,null));};exports[_0x2c40('0x12e')]=function(_0x352127,_0x251fb2){var _0x2e8cf8={};var _0x40eb5d={};var _0x4b7996;var _0x4dc28b;return db[_0x2c40('0x31')]['findOne']({'where':{'id':_0x352127['params']['id']}})[_0x2c40('0x1d')](handleEntityNotFound(_0x251fb2,null))[_0x2c40('0x1d')](function(_0x4edba5){if(_0x4edba5){_0x4b7996=_0x4edba5;_0x40eb5d[_0x2c40('0xc2')]=_[_0x2c40('0xc5')](db[_0x2c40('0x12f')][_0x2c40('0xc4')]);_0x40eb5d['query']=_[_0x2c40('0xc5')](_0x352127['query']);_0x40eb5d[_0x2c40('0xc6')]=_['intersection'](_0x40eb5d[_0x2c40('0xc2')],_0x40eb5d['query']);_0x2e8cf8['attributes']=_[_0x2c40('0xc7')](_0x40eb5d['model'],qs[_0x2c40('0xc8')](_0x352127[_0x2c40('0x3a')]['fields']));_0x2e8cf8[_0x2c40('0x40')]=_0x2e8cf8[_0x2c40('0x40')][_0x2c40('0x5f')]?_0x2e8cf8[_0x2c40('0x40')]:_0x40eb5d[_0x2c40('0xc2')];_0x2e8cf8[_0x2c40('0xcf')]=qs[_0x2c40('0xc9')](_0x352127[_0x2c40('0x3a')][_0x2c40('0xc9')]);_0x2e8cf8[_0x2c40('0x39')]=qs[_0x2c40('0xc6')](_['pick'](_0x352127[_0x2c40('0x3a')],_0x40eb5d['filters']));if(_0x352127['query']['filter']){_0x2e8cf8['where']=_[_0x2c40('0xcb')](_0x2e8cf8[_0x2c40('0x39')],{'$or':_[_0x2c40('0x32')](_0x2e8cf8['attributes'],function(_0xfb3fbe){var _0x1cae08={};_0x1cae08[_0xfb3fbe]={'$like':'%'+_0x352127[_0x2c40('0x3a')][_0x2c40('0x28')]+'%'};return _0x1cae08;})});}_0x2e8cf8=_[_0x2c40('0xcb')]({},_0x2e8cf8,_0x352127[_0x2c40('0x4d')]);return _0x4b7996[_0x2c40('0x12e')](_0x2e8cf8);}})['then'](function(_0x4551a1){if(_0x4551a1){_0x4dc28b=_0x4551a1[_0x2c40('0x5f')];if(!_0x352127[_0x2c40('0x3a')]['hasOwnProperty'](_0x2c40('0xce'))){_0x2e8cf8[_0x2c40('0x19')]=qs[_0x2c40('0x19')](_0x352127[_0x2c40('0x3a')][_0x2c40('0x19')]);_0x2e8cf8[_0x2c40('0x17')]=qs[_0x2c40('0x17')](_0x352127[_0x2c40('0x3a')]['offset']);}return _0x4b7996[_0x2c40('0x12e')](_0x2e8cf8);}})[_0x2c40('0x1d')](function(_0x2ec21b){if(_0x2ec21b){return _0x2ec21b?{'count':_0x4dc28b,'rows':_0x2ec21b}:null;}})[_0x2c40('0x1d')](respondWithResult(_0x251fb2,null))[_0x2c40('0x4a')](handleError(_0x251fb2,null));};exports[_0x2c40('0x130')]=function(_0x1c3dde,_0x34b547){return db['User'][_0x2c40('0x2c')]({'where':{'id':_0x1c3dde[_0x2c40('0x4c')]['id']}})[_0x2c40('0x1d')](handleEntityNotFound(_0x34b547,null))[_0x2c40('0x1d')](function(_0x575e63){if(_0x575e63){return _0x575e63[_0x2c40('0x130')](_0x1c3dde[_0x2c40('0x4f')][_0x2c40('0x51')],_[_0x2c40('0x52')](_0x1c3dde[_0x2c40('0x4f')],[_0x2c40('0x51'),'id'])||{});}})[_0x2c40('0x1d')](respondWithResult(_0x34b547,null))[_0x2c40('0x4a')](handleError(_0x34b547,null));};exports[_0x2c40('0x131')]=function(_0x3e8c77,_0x7669c2){return db[_0x2c40('0x31')][_0x2c40('0x2c')]({'where':{'id':_0x3e8c77[_0x2c40('0x4c')]['id']}})['then'](handleEntityNotFound(_0x7669c2,null))[_0x2c40('0x1d')](function(_0x1bc950){if(_0x1bc950){return _0x1bc950['removeFaxAccounts'](_0x3e8c77['query'][_0x2c40('0x51')]);}})[_0x2c40('0x1d')](respondWithStatusCode(_0x7669c2,null))[_0x2c40('0x4a')](handleError(_0x7669c2,null));};exports['getMailAccounts']=function(_0x3403c0,_0x4c3a21){var _0x95e4c={};var _0x4fbf41={};var _0x326543;var _0x3ace24;return db[_0x2c40('0x31')]['findOne']({'where':{'id':_0x3403c0[_0x2c40('0x4c')]['id']}})[_0x2c40('0x1d')](handleEntityNotFound(_0x4c3a21,null))['then'](function(_0xfd3b0){if(_0xfd3b0){_0x326543=_0xfd3b0;_0x4fbf41['model']=_['keys'](db[_0x2c40('0x132')][_0x2c40('0xc4')]);_0x4fbf41[_0x2c40('0x3a')]=_['keys'](_0x3403c0[_0x2c40('0x3a')]);_0x4fbf41[_0x2c40('0xc6')]=_['intersection'](_0x4fbf41['model'],_0x4fbf41[_0x2c40('0x3a')]);_0x95e4c[_0x2c40('0x40')]=_[_0x2c40('0xc7')](_0x4fbf41['model'],qs[_0x2c40('0xc8')](_0x3403c0[_0x2c40('0x3a')][_0x2c40('0xc8')]));_0x95e4c[_0x2c40('0x40')]=_0x95e4c[_0x2c40('0x40')][_0x2c40('0x5f')]?_0x95e4c[_0x2c40('0x40')]:_0x4fbf41['model'];_0x95e4c[_0x2c40('0xcf')]=qs['sort'](_0x3403c0['query'][_0x2c40('0xc9')]);_0x95e4c[_0x2c40('0x39')]=qs[_0x2c40('0xc6')](_[_0x2c40('0xca')](_0x3403c0[_0x2c40('0x3a')],_0x4fbf41[_0x2c40('0xc6')]));if(_0x3403c0[_0x2c40('0x3a')]['filter']){_0x95e4c[_0x2c40('0x39')]=_[_0x2c40('0xcb')](_0x95e4c[_0x2c40('0x39')],{'$or':_[_0x2c40('0x32')](_0x95e4c[_0x2c40('0x40')],function(_0x427022){var _0x161731={};_0x161731[_0x427022]={'$like':'%'+_0x3403c0[_0x2c40('0x3a')][_0x2c40('0x28')]+'%'};return _0x161731;})});}_0x95e4c=_['merge']({},_0x95e4c,_0x3403c0['options']);return _0x326543[_0x2c40('0x133')](_0x95e4c);}})[_0x2c40('0x1d')](function(_0x3c928f){if(_0x3c928f){_0x3ace24=_0x3c928f[_0x2c40('0x5f')];if(!_0x3403c0['query'][_0x2c40('0xcd')](_0x2c40('0xce'))){_0x95e4c[_0x2c40('0x19')]=qs['limit'](_0x3403c0[_0x2c40('0x3a')][_0x2c40('0x19')]);_0x95e4c[_0x2c40('0x17')]=qs[_0x2c40('0x17')](_0x3403c0[_0x2c40('0x3a')][_0x2c40('0x17')]);}return _0x326543[_0x2c40('0x133')](_0x95e4c);}})[_0x2c40('0x1d')](function(_0x59786a){if(_0x59786a){return _0x59786a?{'count':_0x3ace24,'rows':_0x59786a}:null;}})['then'](respondWithResult(_0x4c3a21,null))[_0x2c40('0x4a')](handleError(_0x4c3a21,null));};exports[_0x2c40('0x134')]=function(_0x442495,_0x53d5d4){return db['User']['find']({'where':{'id':_0x442495['params']['id']}})[_0x2c40('0x1d')](handleEntityNotFound(_0x53d5d4,null))['then'](function(_0x4abed8){if(_0x4abed8){return _0x4abed8['addMailAccounts'](_0x442495['body']['ids'],_[_0x2c40('0x52')](_0x442495[_0x2c40('0x4f')],[_0x2c40('0x51'),'id'])||{});}})[_0x2c40('0x1d')](respondWithResult(_0x53d5d4,null))[_0x2c40('0x4a')](handleError(_0x53d5d4,null));};exports['removeMailAccounts']=function(_0x48a9e1,_0x5a0e08){return db[_0x2c40('0x31')][_0x2c40('0x2c')]({'where':{'id':_0x48a9e1[_0x2c40('0x4c')]['id']}})[_0x2c40('0x1d')](handleEntityNotFound(_0x5a0e08,null))[_0x2c40('0x1d')](function(_0x199331){if(_0x199331){return _0x199331['removeMailAccounts'](_0x48a9e1[_0x2c40('0x3a')]['ids']);}})['then'](respondWithStatusCode(_0x5a0e08,null))[_0x2c40('0x4a')](handleError(_0x5a0e08,null));};exports[_0x2c40('0x135')]=function(_0x1dde19,_0x22dffc){var _0x45b78b={};var _0x4fe7b2={};var _0x152a59;var _0x1c1b24;return db['User']['findOne']({'where':{'id':_0x1dde19[_0x2c40('0x4c')]['id']}})[_0x2c40('0x1d')](handleEntityNotFound(_0x22dffc,null))['then'](function(_0x3bc772){if(_0x3bc772){_0x152a59=_0x3bc772;_0x4fe7b2[_0x2c40('0xc2')]=_[_0x2c40('0xc5')](db[_0x2c40('0x136')][_0x2c40('0xc4')]);_0x4fe7b2[_0x2c40('0x3a')]=_[_0x2c40('0xc5')](_0x1dde19[_0x2c40('0x3a')]);_0x4fe7b2[_0x2c40('0xc6')]=_[_0x2c40('0xc7')](_0x4fe7b2[_0x2c40('0xc2')],_0x4fe7b2[_0x2c40('0x3a')]);_0x45b78b[_0x2c40('0x40')]=_['intersection'](_0x4fe7b2[_0x2c40('0xc2')],qs[_0x2c40('0xc8')](_0x1dde19['query']['fields']));_0x45b78b['attributes']=_0x45b78b[_0x2c40('0x40')][_0x2c40('0x5f')]?_0x45b78b[_0x2c40('0x40')]:_0x4fe7b2[_0x2c40('0xc2')];_0x45b78b[_0x2c40('0xcf')]=qs[_0x2c40('0xc9')](_0x1dde19[_0x2c40('0x3a')][_0x2c40('0xc9')]);_0x45b78b[_0x2c40('0x39')]=qs[_0x2c40('0xc6')](_[_0x2c40('0xca')](_0x1dde19['query'],_0x4fe7b2[_0x2c40('0xc6')]));if(_0x1dde19[_0x2c40('0x3a')][_0x2c40('0x28')]){_0x45b78b[_0x2c40('0x39')]=_['merge'](_0x45b78b[_0x2c40('0x39')],{'$or':_[_0x2c40('0x32')](_0x45b78b[_0x2c40('0x40')],function(_0x54b030){var _0x330bf1={};_0x330bf1[_0x54b030]={'$like':'%'+_0x1dde19[_0x2c40('0x3a')]['filter']+'%'};return _0x330bf1;})});}_0x45b78b=_[_0x2c40('0xcb')]({},_0x45b78b,_0x1dde19[_0x2c40('0x4d')]);return _0x152a59['getOpenchannelAccounts'](_0x45b78b);}})[_0x2c40('0x1d')](function(_0x439bd7){if(_0x439bd7){_0x1c1b24=_0x439bd7['length'];if(!_0x1dde19[_0x2c40('0x3a')][_0x2c40('0xcd')](_0x2c40('0xce'))){_0x45b78b[_0x2c40('0x19')]=qs[_0x2c40('0x19')](_0x1dde19['query'][_0x2c40('0x19')]);_0x45b78b['offset']=qs[_0x2c40('0x17')](_0x1dde19[_0x2c40('0x3a')]['offset']);}return _0x152a59[_0x2c40('0x135')](_0x45b78b);}})[_0x2c40('0x1d')](function(_0xeb6950){if(_0xeb6950){return _0xeb6950?{'count':_0x1c1b24,'rows':_0xeb6950}:null;}})[_0x2c40('0x1d')](respondWithResult(_0x22dffc,null))[_0x2c40('0x4a')](handleError(_0x22dffc,null));};exports[_0x2c40('0x137')]=function(_0x25354b,_0x593499){return db['User']['find']({'where':{'id':_0x25354b[_0x2c40('0x4c')]['id']}})[_0x2c40('0x1d')](handleEntityNotFound(_0x593499,null))['then'](function(_0x4e943b){if(_0x4e943b){return _0x4e943b[_0x2c40('0x137')](_0x25354b[_0x2c40('0x4f')]['ids'],_['omit'](_0x25354b[_0x2c40('0x4f')],[_0x2c40('0x51'),'id'])||{});}})[_0x2c40('0x1d')](respondWithResult(_0x593499,null))['catch'](handleError(_0x593499,null));};exports[_0x2c40('0x138')]=function(_0x3462fc,_0x2d590a){return db[_0x2c40('0x31')][_0x2c40('0x2c')]({'where':{'id':_0x3462fc[_0x2c40('0x4c')]['id']}})['then'](handleEntityNotFound(_0x2d590a,null))[_0x2c40('0x1d')](function(_0x313418){if(_0x313418){return _0x313418['removeOpenchannelAccounts'](_0x3462fc[_0x2c40('0x3a')][_0x2c40('0x51')]);}})['then'](respondWithStatusCode(_0x2d590a,null))[_0x2c40('0x4a')](handleError(_0x2d590a,null));};exports['getSmsAccounts']=function(_0x289325,_0xc0dbc4){var _0x48667a={};var _0x5a50e5={};var _0xfb4130;var _0x3befc1;return db[_0x2c40('0x31')]['findOne']({'where':{'id':_0x289325[_0x2c40('0x4c')]['id']}})[_0x2c40('0x1d')](handleEntityNotFound(_0xc0dbc4,null))['then'](function(_0x55f590){if(_0x55f590){_0xfb4130=_0x55f590;_0x5a50e5[_0x2c40('0xc2')]=_[_0x2c40('0xc5')](db[_0x2c40('0x139')]['rawAttributes']);_0x5a50e5[_0x2c40('0x3a')]=_[_0x2c40('0xc5')](_0x289325[_0x2c40('0x3a')]);_0x5a50e5[_0x2c40('0xc6')]=_['intersection'](_0x5a50e5['model'],_0x5a50e5[_0x2c40('0x3a')]);_0x48667a[_0x2c40('0x40')]=_['intersection'](_0x5a50e5[_0x2c40('0xc2')],qs[_0x2c40('0xc8')](_0x289325['query']['fields']));_0x48667a[_0x2c40('0x40')]=_0x48667a[_0x2c40('0x40')][_0x2c40('0x5f')]?_0x48667a[_0x2c40('0x40')]:_0x5a50e5[_0x2c40('0xc2')];_0x48667a[_0x2c40('0xcf')]=qs[_0x2c40('0xc9')](_0x289325[_0x2c40('0x3a')][_0x2c40('0xc9')]);_0x48667a['where']=qs[_0x2c40('0xc6')](_[_0x2c40('0xca')](_0x289325[_0x2c40('0x3a')],_0x5a50e5[_0x2c40('0xc6')]));if(_0x289325[_0x2c40('0x3a')][_0x2c40('0x28')]){_0x48667a[_0x2c40('0x39')]=_[_0x2c40('0xcb')](_0x48667a[_0x2c40('0x39')],{'$or':_[_0x2c40('0x32')](_0x48667a['attributes'],function(_0x2cb136){var _0x51aced={};_0x51aced[_0x2cb136]={'$like':'%'+_0x289325['query'][_0x2c40('0x28')]+'%'};return _0x51aced;})});}_0x48667a=_['merge']({},_0x48667a,_0x289325[_0x2c40('0x4d')]);return _0xfb4130['getSmsAccounts'](_0x48667a);}})[_0x2c40('0x1d')](function(_0x28c6e5){if(_0x28c6e5){_0x3befc1=_0x28c6e5[_0x2c40('0x5f')];if(!_0x289325['query']['hasOwnProperty']('nolimit')){_0x48667a[_0x2c40('0x19')]=qs[_0x2c40('0x19')](_0x289325['query'][_0x2c40('0x19')]);_0x48667a[_0x2c40('0x17')]=qs['offset'](_0x289325[_0x2c40('0x3a')]['offset']);}return _0xfb4130[_0x2c40('0x13a')](_0x48667a);}})[_0x2c40('0x1d')](function(_0x1ce38a){if(_0x1ce38a){return _0x1ce38a?{'count':_0x3befc1,'rows':_0x1ce38a}:null;}})[_0x2c40('0x1d')](respondWithResult(_0xc0dbc4,null))[_0x2c40('0x4a')](handleError(_0xc0dbc4,null));};exports['addSmsAccounts']=function(_0x3ea1f3,_0x556e27){return db[_0x2c40('0x31')][_0x2c40('0x2c')]({'where':{'id':_0x3ea1f3[_0x2c40('0x4c')]['id']}})['then'](handleEntityNotFound(_0x556e27,null))['then'](function(_0x4f2400){if(_0x4f2400){return _0x4f2400[_0x2c40('0x13b')](_0x3ea1f3[_0x2c40('0x4f')][_0x2c40('0x51')],_[_0x2c40('0x52')](_0x3ea1f3[_0x2c40('0x4f')],[_0x2c40('0x51'),'id'])||{});}})[_0x2c40('0x1d')](respondWithResult(_0x556e27,null))[_0x2c40('0x4a')](handleError(_0x556e27,null));};exports[_0x2c40('0x13c')]=function(_0x16a81c,_0x43298c){return db[_0x2c40('0x31')][_0x2c40('0x2c')]({'where':{'id':_0x16a81c[_0x2c40('0x4c')]['id']}})[_0x2c40('0x1d')](handleEntityNotFound(_0x43298c,null))[_0x2c40('0x1d')](function(_0x2772c9){if(_0x2772c9){return _0x2772c9['removeSmsAccounts'](_0x16a81c['query'][_0x2c40('0x51')]);}})[_0x2c40('0x1d')](respondWithStatusCode(_0x43298c,null))[_0x2c40('0x4a')](handleError(_0x43298c,null));};exports['getChatWebsites']=function(_0x3dc93c,_0xfb93a){var _0x5056de={};var _0x3bd1ef={};var _0x5be01e;var _0x3c54e5;return db[_0x2c40('0x31')][_0x2c40('0x8b')]({'where':{'id':_0x3dc93c['params']['id']}})['then'](handleEntityNotFound(_0xfb93a,null))['then'](function(_0x2af38b){if(_0x2af38b){_0x5be01e=_0x2af38b;_0x3bd1ef[_0x2c40('0xc2')]=_['keys'](db['ChatWebsite'][_0x2c40('0xc4')]);_0x3bd1ef['query']=_[_0x2c40('0xc5')](_0x3dc93c['query']);_0x3bd1ef[_0x2c40('0xc6')]=_[_0x2c40('0xc7')](_0x3bd1ef[_0x2c40('0xc2')],_0x3bd1ef[_0x2c40('0x3a')]);_0x5056de[_0x2c40('0x40')]=_[_0x2c40('0xc7')](_0x3bd1ef[_0x2c40('0xc2')],qs[_0x2c40('0xc8')](_0x3dc93c['query']['fields']));_0x5056de[_0x2c40('0x40')]=_0x5056de['attributes'][_0x2c40('0x5f')]?_0x5056de[_0x2c40('0x40')]:_0x3bd1ef[_0x2c40('0xc2')];_0x5056de[_0x2c40('0xcf')]=qs[_0x2c40('0xc9')](_0x3dc93c['query'][_0x2c40('0xc9')]);_0x5056de[_0x2c40('0x39')]=qs[_0x2c40('0xc6')](_['pick'](_0x3dc93c[_0x2c40('0x3a')],_0x3bd1ef['filters']));if(_0x3dc93c['query'][_0x2c40('0x28')]){_0x5056de[_0x2c40('0x39')]=_[_0x2c40('0xcb')](_0x5056de[_0x2c40('0x39')],{'$or':_[_0x2c40('0x32')](_0x5056de[_0x2c40('0x40')],function(_0x54c74d){var _0x394048={};_0x394048[_0x54c74d]={'$like':'%'+_0x3dc93c['query']['filter']+'%'};return _0x394048;})});}_0x5056de=_['merge']({},_0x5056de,_0x3dc93c[_0x2c40('0x4d')]);return _0x5be01e[_0x2c40('0x13d')](_0x5056de);}})[_0x2c40('0x1d')](function(_0x35caf3){if(_0x35caf3){_0x3c54e5=_0x35caf3['length'];if(!_0x3dc93c['query']['hasOwnProperty']('nolimit')){_0x5056de[_0x2c40('0x19')]=qs[_0x2c40('0x19')](_0x3dc93c[_0x2c40('0x3a')]['limit']);_0x5056de['offset']=qs['offset'](_0x3dc93c[_0x2c40('0x3a')][_0x2c40('0x17')]);}return _0x5be01e[_0x2c40('0x13d')](_0x5056de);}})['then'](function(_0x19c4f5){if(_0x19c4f5){return _0x19c4f5?{'count':_0x3c54e5,'rows':_0x19c4f5}:null;}})[_0x2c40('0x1d')](respondWithResult(_0xfb93a,null))[_0x2c40('0x4a')](handleError(_0xfb93a,null));};exports[_0x2c40('0x13e')]=function(_0x42aea0,_0xa762c8){return db['User']['find']({'where':{'id':_0x42aea0[_0x2c40('0x4c')]['id']}})['then'](handleEntityNotFound(_0xa762c8,null))['then'](function(_0x521a90){if(_0x521a90){return _0x521a90[_0x2c40('0x13e')](_0x42aea0['body']['ids'],_[_0x2c40('0x52')](_0x42aea0['body'],['ids','id'])||{});}})['then'](respondWithResult(_0xa762c8,null))[_0x2c40('0x4a')](handleError(_0xa762c8,null));};exports[_0x2c40('0x13f')]=function(_0x456b38,_0xc12026){return db['User']['find']({'where':{'id':_0x456b38[_0x2c40('0x4c')]['id']}})[_0x2c40('0x1d')](handleEntityNotFound(_0xc12026,null))[_0x2c40('0x1d')](function(_0x393ca2){if(_0x393ca2){return _0x393ca2[_0x2c40('0x13f')](_0x456b38[_0x2c40('0x3a')][_0x2c40('0x51')]);}})[_0x2c40('0x1d')](respondWithStatusCode(_0xc12026,null))['catch'](handleError(_0xc12026,null));};exports[_0x2c40('0x140')]=function(_0x1ad8db,_0x183520){var _0x2d000f={};var _0x463400={};var _0x44584a;var _0x39cfa7;return db[_0x2c40('0x31')][_0x2c40('0x8b')]({'where':{'id':_0x1ad8db[_0x2c40('0x4c')]['id']}})[_0x2c40('0x1d')](handleEntityNotFound(_0x183520,null))['then'](function(_0x43057b){if(_0x43057b){_0x44584a=_0x43057b;_0x463400[_0x2c40('0xc2')]=_[_0x2c40('0xc5')](db['WhatsappAccount'][_0x2c40('0xc4')]);_0x463400[_0x2c40('0x3a')]=_[_0x2c40('0xc5')](_0x1ad8db['query']);_0x463400[_0x2c40('0xc6')]=_['intersection'](_0x463400['model'],_0x463400[_0x2c40('0x3a')]);_0x2d000f['attributes']=_[_0x2c40('0xc7')](_0x463400['model'],qs['fields'](_0x1ad8db[_0x2c40('0x3a')][_0x2c40('0xc8')]));_0x2d000f[_0x2c40('0x40')]=_0x2d000f[_0x2c40('0x40')][_0x2c40('0x5f')]?_0x2d000f[_0x2c40('0x40')]:_0x463400['model'];_0x2d000f[_0x2c40('0xcf')]=qs['sort'](_0x1ad8db[_0x2c40('0x3a')][_0x2c40('0xc9')]);_0x2d000f[_0x2c40('0x39')]=qs[_0x2c40('0xc6')](_[_0x2c40('0xca')](_0x1ad8db[_0x2c40('0x3a')],_0x463400[_0x2c40('0xc6')]));if(_0x1ad8db[_0x2c40('0x3a')][_0x2c40('0x28')]){_0x2d000f['where']=_[_0x2c40('0xcb')](_0x2d000f['where'],{'$or':_[_0x2c40('0x32')](_0x2d000f['attributes'],function(_0x381837){var _0x49d009={};_0x49d009[_0x381837]={'$like':'%'+_0x1ad8db['query'][_0x2c40('0x28')]+'%'};return _0x49d009;})});}_0x2d000f=_[_0x2c40('0xcb')]({},_0x2d000f,_0x1ad8db[_0x2c40('0x4d')]);return _0x44584a['getWhatsappAccounts'](_0x2d000f);}})[_0x2c40('0x1d')](function(_0x27e1c3){if(_0x27e1c3){_0x39cfa7=_0x27e1c3[_0x2c40('0x5f')];if(!_0x1ad8db['query']['hasOwnProperty'](_0x2c40('0xce'))){_0x2d000f['limit']=qs[_0x2c40('0x19')](_0x1ad8db[_0x2c40('0x3a')]['limit']);_0x2d000f[_0x2c40('0x17')]=qs['offset'](_0x1ad8db[_0x2c40('0x3a')]['offset']);}return _0x44584a[_0x2c40('0x140')](_0x2d000f);}})[_0x2c40('0x1d')](function(_0x549607){if(_0x549607){return _0x549607?{'count':_0x39cfa7,'rows':_0x549607}:null;}})[_0x2c40('0x1d')](respondWithResult(_0x183520,null))[_0x2c40('0x4a')](handleError(_0x183520,null));};exports[_0x2c40('0x141')]=function(_0x499aaf,_0x22d006){return db[_0x2c40('0x31')][_0x2c40('0x2c')]({'where':{'id':_0x499aaf[_0x2c40('0x4c')]['id']}})[_0x2c40('0x1d')](handleEntityNotFound(_0x22d006,null))[_0x2c40('0x1d')](function(_0x3ec36d){if(_0x3ec36d){return _0x3ec36d[_0x2c40('0x141')](_0x499aaf[_0x2c40('0x4f')]['ids'],_[_0x2c40('0x52')](_0x499aaf[_0x2c40('0x4f')],[_0x2c40('0x51'),'id'])||{});}})[_0x2c40('0x1d')](respondWithResult(_0x22d006,null))['catch'](handleError(_0x22d006,null));};exports['removeWhatsappAccounts']=function(_0x3617ae,_0x18064e){return db['User'][_0x2c40('0x2c')]({'where':{'id':_0x3617ae['params']['id']}})['then'](handleEntityNotFound(_0x18064e,null))[_0x2c40('0x1d')](function(_0x31e4f8){if(_0x31e4f8){return _0x31e4f8[_0x2c40('0x142')](_0x3617ae[_0x2c40('0x3a')][_0x2c40('0x51')]);}})[_0x2c40('0x1d')](respondWithStatusCode(_0x18064e,null))[_0x2c40('0x4a')](handleError(_0x18064e,null));};exports[_0x2c40('0x143')]=function(_0x494dd0,_0x57e29e){var _0x2a1abc={},_0x2fdceb={},_0x47e46d={'count':0x0,'rows':[]};var _0x5379a1=db[_0x2c40('0x144')][_0x2c40('0xc4')];_0x2fdceb[_0x2c40('0xc2')]=_['keys'](_0x5379a1);_0x2fdceb[_0x2c40('0x3a')]=_[_0x2c40('0xc5')](_0x494dd0['query']);_0x2fdceb[_0x2c40('0xc6')]=_[_0x2c40('0xc7')](_0x2fdceb[_0x2c40('0xc2')],_0x2fdceb[_0x2c40('0x3a')]);_0x2fdceb['filters']=_[_0x2c40('0x145')](_0x2fdceb[_0x2c40('0xc6')],[_0x2c40('0x146'),_0x2c40('0x147'),_0x2c40('0x148'),'$gte',_0x2c40('0x149'),_0x2c40('0x14a'),_0x2c40('0x14b'),_0x2c40('0x14c'),_0x2c40('0x14d'),_0x2c40('0x14e'),_0x2c40('0x14f'),'$in',_0x2c40('0x150'),_0x2c40('0x151'),_0x2c40('0x152'),_0x2c40('0x153'),_0x2c40('0x154'),_0x2c40('0x151'),_0x2c40('0x155'),_0x2c40('0x156'),_0x2c40('0x157'),'$any']);_0x2a1abc[_0x2c40('0x40')]=_[_0x2c40('0xc7')](_0x2fdceb[_0x2c40('0xc2')],qs[_0x2c40('0xc8')](_0x494dd0[_0x2c40('0x3a')][_0x2c40('0xc8')]));_0x2a1abc['attributes']=_0x2a1abc[_0x2c40('0x40')]['length']?_0x2a1abc[_0x2c40('0x40')]:_0x2fdceb[_0x2c40('0xc2')];if(!_0x494dd0[_0x2c40('0x3a')][_0x2c40('0xcd')](_0x2c40('0xce'))){_0x2a1abc[_0x2c40('0x19')]=qs[_0x2c40('0x19')](_0x494dd0['query'][_0x2c40('0x19')]);_0x2a1abc[_0x2c40('0x17')]=qs[_0x2c40('0x17')](_0x494dd0[_0x2c40('0x3a')][_0x2c40('0x17')]);}_0x2a1abc[_0x2c40('0xcf')]=qs['sort'](_0x494dd0[_0x2c40('0x3a')][_0x2c40('0xc9')]);_0x2a1abc[_0x2c40('0x39')]=qs['filters'](_['pick'](_0x494dd0['query'],_0x2fdceb[_0x2c40('0xc6')]));if(_0x494dd0[_0x2c40('0x3a')]['filter']){_0x2a1abc[_0x2c40('0x39')]=_[_0x2c40('0xcb')](_0x2a1abc[_0x2c40('0x39')],{'$or':_[_0x2c40('0x32')](_0x2a1abc[_0x2c40('0x40')],function(_0x2214ea){var _0xc49820={};_0xc49820[_0x2214ea]={'$like':'%'+_0x494dd0[_0x2c40('0x3a')][_0x2c40('0x28')]+'%'};return _0xc49820;})});}_0x2a1abc[_0x2c40('0x39')]={'$and':[_0x2a1abc[_0x2c40('0x39')],{'$or':[{'UserId':_0x494dd0[_0x2c40('0x4c')]['id']},{'OwnerId':_0x494dd0[_0x2c40('0x4c')]['id']}]}]};_0x2a1abc=_[_0x2c40('0xcb')]({},_0x2a1abc,_0x494dd0['options']);var _0x2f97d2={'where':_0x2a1abc[_0x2c40('0x39')]};return db[_0x2c40('0x144')][_0x2c40('0x1a')](_0x2f97d2)[_0x2c40('0x1d')](function(_0x260000){_0x47e46d[_0x2c40('0x1a')]=_0x260000;if(_0x494dd0[_0x2c40('0x3a')][_0x2c40('0x3b')]){_0x2a1abc['include']=[{'attributes':['id',_0x2c40('0x158'),_0x2c40('0x159'),_0x2c40('0xe3')],'model':db['CmContact'],'as':_0x2c40('0x15a')},{'attributes':['id',_0x2c40('0x2f'),_0x2c40('0x15b')],'model':db[_0x2c40('0x15c')],'as':_0x2c40('0xc3')}];}return db['CmHopper'][_0x2c40('0x42')](_0x2a1abc);})[_0x2c40('0x1d')](function(_0xfa2806){_0x47e46d[_0x2c40('0x43')]=_0xfa2806;return _0x47e46d;})[_0x2c40('0x1d')](respondWithFilteredResult(_0x57e29e,_0x2a1abc))[_0x2c40('0x4a')](handleError(_0x57e29e,null));};exports[_0x2c40('0x15d')]=function(_0x25f0e4,_0x2d984b){if(!_[_0x2c40('0x59')](_0x25f0e4[_0x2c40('0x75')]['id'])&&(_0x25f0e4[_0x2c40('0x75')]['role']==_0x2c40('0x23')||_0x25f0e4['user']['role']==_0x2c40('0x75'))){return db[_0x2c40('0x31')][_0x2c40('0x8b')]({'where':{'id':_0x25f0e4[_0x2c40('0x4c')]['id']},'raw':!![]})['then'](function(_0x276d1e){return authService['retrieveApiKey'](_0x276d1e);})[_0x2c40('0x1d')](function(_0x1e0ba8){if(_0x1e0ba8){return _0x2d984b[_0x2c40('0x15')](0xc8)[_0x2c40('0x1b')]({'api_key':_0x1e0ba8[_0x2c40('0x15e')]});}else{return _0x2d984b[_0x2c40('0x15')](0xcc)['json']({'message':_0x2c40('0x15f')});}})[_0x2c40('0x4a')](handleError(_0x2d984b,0x193));}else{return _0x2d984b['status'](0x191)['json']({'message':_0x2c40('0x160')});}};exports[_0x2c40('0x161')]=function(_0x38ec8e,_0x32b6f7){if(!_['isNil'](_0x38ec8e[_0x2c40('0x75')]['id'])&&(_0x38ec8e[_0x2c40('0x75')][_0x2c40('0x22')]==_0x2c40('0x23')||_0x38ec8e[_0x2c40('0x75')]['role']=='user')){return db[_0x2c40('0x31')][_0x2c40('0x2c')]({'where':{'id':_0x38ec8e[_0x2c40('0x4c')]['id']}})['then'](function(_0x442796){return authService[_0x2c40('0x162')](_0x442796);})[_0x2c40('0x1d')](function(_0x243710){return db[_0x2c40('0x31')]['update']({'apiKeyIat':_0x243710['iat'],'apiKeyNonce':_0x243710[_0x2c40('0x163')]},{'where':{'id':_0x38ec8e['params']['id']}})[_0x2c40('0x1d')](function(){return _0x32b6f7[_0x2c40('0x15')](0xc8)['json']({'api_key':_0x243710[_0x2c40('0x15e')]});});})[_0x2c40('0x4a')](handleError(_0x32b6f7,0x193));}else{return _0x32b6f7[_0x2c40('0x15')](0x191)[_0x2c40('0x1b')]({'message':_0x2c40('0x160')});}};exports[_0x2c40('0x164')]=function(_0xabfe28,_0x8065b9){if(!_['isNil'](_0xabfe28[_0x2c40('0x75')]['id'])&&(_0xabfe28[_0x2c40('0x75')]['role']==_0x2c40('0x23')||_0xabfe28[_0x2c40('0x75')]['role']==_0x2c40('0x75'))){return db[_0x2c40('0x31')]['find']({'where':{'id':_0xabfe28[_0x2c40('0x4c')]['id']}})[_0x2c40('0x1d')](handleEntityNotFound(_0x8065b9,null))[_0x2c40('0x1d')](function(_0x337f8f){if(_0x337f8f&&_0x337f8f[_0x2c40('0x165')]&&_0x337f8f[_0x2c40('0x166')])return _0x337f8f;else throw{'message':_0x2c40('0x167')};})[_0x2c40('0x1d')](function(){return db[_0x2c40('0x31')][_0x2c40('0x1c')]({'apiKeyNonce':null,'apiKeyIat':null},{'where':{'id':_0xabfe28[_0x2c40('0x4c')]['id']}});})[_0x2c40('0x1d')](respondWithStatusCode(_0x8065b9,0xc8))[_0x2c40('0x4a')](handleError(_0x8065b9,0x193));}else{return _0x8065b9[_0x2c40('0x15')](0x191)[_0x2c40('0x1b')]({'message':_0x2c40('0x160')});}};exports[_0x2c40('0x168')]=function(_0x55f8b4,_0x1ddd45){var _0x5d5038=_0x55f8b4[_0x2c40('0x75')][_0x2c40('0x21')]({'plain':!![]});if(!_0x5d5038){return _0x1ddd45['status'](0x191)[_0x2c40('0x30')](_0x2c40('0x169'));}else{Promise[_0x2c40('0xf3')]()[_0x2c40('0x1d')](function(){if(_0x55f8b4[_0x2c40('0x3a')][_0x2c40('0x3f')]!==_0x2c40('0x3d'))return;return _0x55f8b4[_0x2c40('0x75')][_0x2c40('0x16a')]();})[_0x2c40('0x1d')](function(_0x509323){if(!_0x509323)return;return _0x509323[_0x2c40('0x21')]({'plain':!![]});})[_0x2c40('0x1d')](function(_0x2c44b1){_0x5d5038[_0x2c40('0x3f')]=_0x2c44b1;return _0x1ddd45[_0x2c40('0x15')](0xc8)[_0x2c40('0x1b')](_0x5d5038);});}};exports[_0x2c40('0x16b')]=function(_0x18bdbd,_0x1afae0){var _0x539f41={'offset':0x0};var _0x43bb34={'count':0x0,'rows':[]};var _0x5b52fc=[_0x2c40('0x16c'),_0x2c40('0x16d'),_0x2c40('0x16e')];var _0x1014ee=[];var _0x499828=[];var _0x251b42=[];var _0x56e427=_0x18bdbd[_0x2c40('0x3a')][_0x2c40('0x16f')];var _0x392643=_0x18bdbd['query'][_0x2c40('0x170')];var _0x13e707=_0x18bdbd[_0x2c40('0x3a')][_0x2c40('0x28')];return Promise[_0x2c40('0xf3')]()[_0x2c40('0x1d')](function(){if(!_0x56e427){return[];}return db[_0x2c40('0x102')]['findAll']({'attributes':['id',_0x2c40('0x2f')],'where':{'id':_0x56e427}});})[_0x2c40('0x1d')](function(_0x6e23a5){_0x251b42=_0x6e23a5;if(!_0x392643){return[];}return db[_0x2c40('0x15c')][_0x2c40('0x42')]({'attributes':['id',_0x2c40('0x2f')],'type':_0x2c40('0x171'),'where':{'id':_0x392643}});})['then'](function(_0x8f7d8a){_0x499828=_0x8f7d8a;var _0x5b9074=_0x251b42['concat'](_0x499828)[_0x2c40('0x32')](function(_0x576c21){return _0x576c21[_0x2c40('0x113')]({'attributes':['id','name',_0x2c40('0x53'),_0x2c40('0x93')],'raw':!![]});});return Promise[_0x2c40('0x49')](_0x5b9074);})[_0x2c40('0x1d')](function(_0x15d319){var _0xe26b89=_[_0x2c40('0x172')](_0x15d319);if(_0x13e707){if(_0x392643||_0x56e427){return _0xe26b89[_0x2c40('0x28')](function(_0x405363){return _0x405363['name'][_0x2c40('0x9a')]()[_0x2c40('0x2b')](_0x13e707[_0x2c40('0x9a')]())||_0x405363[_0x2c40('0x53')][_0x2c40('0x173')]()['includes'](_0x13e707);});}else{return db[_0x2c40('0x31')][_0x2c40('0x42')]({'attributes':['id',_0x2c40('0x2f'),_0x2c40('0x53'),_0x2c40('0x93')],'where':{'role':_0x2c40('0x1e'),'$or':[db[_0x2c40('0x5b')][_0x2c40('0x39')](db[_0x2c40('0x5b')]['fn'](_0x2c40('0x174'),db[_0x2c40('0x5b')][_0x2c40('0x175')]('name')),{'$like':'%'+_0x13e707[_0x2c40('0x9a')]()+'%'}),{'internal':{'$like':'%'+_0x13e707+'%'}}]},'raw':!![]});}}else{return _0xe26b89;}})['then'](function(_0x462bbe){var _0x2c12e6='name';var _0x2c02e8=_0x2c40('0x176');if(_0x18bdbd['query'][_0x2c40('0xc9')]){_0x2c02e8=_0x18bdbd[_0x2c40('0x3a')]['sort'][0x0]==='-'?'desc':_0x2c40('0x176');_0x2c12e6=_0x2c02e8===_0x2c40('0x176')?_0x18bdbd['query']['sort']:_0x18bdbd[_0x2c40('0x3a')][_0x2c40('0xc9')][_0x2c40('0x177')](0x1);}return _(_0x462bbe)[_0x2c40('0x178')]('id')['orderBy']([function(_0x26d183){return _0x2c12e6===_0x2c40('0x2f')?_0x26d183[_0x2c12e6][_0x2c40('0x9a')]():_0x26d183[_0x2c12e6];}],[_0x2c02e8])[_0x2c40('0x32')](function(_0x6eb019){return _[_0x2c40('0xca')](_0x6eb019,['id',_0x2c40('0x2f'),_0x2c40('0x53'),_0x2c40('0x93')]);})[_0x2c40('0x2a')]();})[_0x2c40('0x1d')](function(_0x5213c2){_0x1014ee=_0x5213c2;return rta['getRealtimeAgents']();})[_0x2c40('0x1d')](function(_0x56dbf7){return _0x1014ee['map'](function(_0x35df21){var _0x2270ef=_[_0x2c40('0x2c')](_0x56dbf7['rows'],['id',_0x35df21['id']]);if(!_0x2270ef||!_0x35df21[_0x2c40('0x93')]){_0x35df21[_0x2c40('0x15')]=_0x2c40('0x179');}else if(_0x2270ef['voicePause']){_0x35df21[_0x2c40('0x15')]='pause';}else if(_0x2270ef[_0x2c40('0x17a')]==='unavailable'||!_0x2270ef[_0x2c40('0x17a')]){_0x35df21[_0x2c40('0x15')]=_0x2c40('0x17b');}else{_0x35df21[_0x2c40('0x15')]=_0x5b52fc[_0x2c40('0x2b')](_0x2270ef[_0x2c40('0x17a')])?_0x2c40('0x93'):'busy';}return _0x35df21;});})[_0x2c40('0x1d')](function(_0x57f69b){if(!_0x18bdbd['query'][_0x2c40('0xcd')]('nolimit')){_0x539f41[_0x2c40('0x19')]=qs['limit'](_0x18bdbd[_0x2c40('0x3a')][_0x2c40('0x19')]||0xa);_0x539f41['offset']=qs[_0x2c40('0x17')](_0x18bdbd[_0x2c40('0x3a')][_0x2c40('0x17')]);}_0x43bb34[_0x2c40('0x1a')]=_0x57f69b[_0x2c40('0x5f')];_0x43bb34[_0x2c40('0x43')]=_0x539f41[_0x2c40('0x19')]?_0x57f69b[_0x2c40('0x17c')](_0x539f41[_0x2c40('0x17')],_0x539f41[_0x2c40('0x17')]+_0x539f41['limit']):_0x57f69b;return _0x43bb34;})['then'](respondWithFilteredResult(_0x1afae0,_0x539f41))['catch'](handleError(_0x1afae0,null));};function get_open_tabs(_0x3ddfba,_0x2d0624){var _0xab33d9=_0x3ddfba['charAt'](0x0)[_0x2c40('0x17d')]()+_0x3ddfba['slice'](0x1);var _0x47c59b={'type':db[_0x2c40('0x88')][_0x2c40('0x5d')][_0x2c40('0x5e')],'raw':!![]};return new Promise(function(_0x237ee0,_0x46bee3){var _0x1170f6=squel[_0x2c40('0x17e')]()['field']('ui.'+_0xab33d9+_0x2c40('0x17f'),'id')['field'](_0x2c40('0x180'))[_0x2c40('0x60')](_0x2c40('0x181')+_0x3ddfba+'_interactions','ui')['where'](_0x2c40('0x182'),_0x2d0624['id']);return db['sequelize']['query'](_0x1170f6[_0x2c40('0x173')](),_0x47c59b)[_0x2c40('0x1d')](function(_0x2373b2){_0x2d0624[_0xab33d9+_0x2c40('0x183')]=_0x2373b2;_0x237ee0(_0x2373b2);})[_0x2c40('0x4a')](function(_0xecb741){_0x46bee3(_0xecb741);});});}exports[_0x2c40('0x184')]=function(_0x2f0cc5,_0x3ea485){var _0x5b2641=_0x2f0cc5[_0x2c40('0x4c')]['id'];var _0x5bba85=_0x2f0cc5[_0x2c40('0x4f')]['enabled'];return db['User'][_0x2c40('0x1c')]({'messengerSoundNotification':_0x5bba85},{'where':{'id':_0x5b2641}})[_0x2c40('0x1d')](respondWithStatusCode(_0x3ea485,null))[_0x2c40('0x4a')](handleError(_0x3ea485,null));};
\ No newline at end of file