Built motion from commit b5413ace.|2.6.9
[motion2.git] / server / api / user / user.controller.js
index fdb859e..1d1262d 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x24bb=['getFaxAccounts','FaxAccount','addFaxAccounts','removeFaxAccounts','getMailAccounts','addMailAccounts','removeMailAccounts','getOpenchannelAccounts','OpenchannelAccount','addOpenchannelAccounts','removeOpenchannelAccounts','getSmsAccounts','SmsAccount','addSmsAccounts','removeSmsAccounts','getChatWebsites','ChatWebsite','addChatWebsites','removeChatWebsites','SquareProject','getSquareProjects','addSquareProjects','removeSquareProjects','getScheduledCalls','CmHopper','concat','$or','$gt','$gte','$lt','$lte','$ne','$eq','$not','$between','$notBetween','$in','$notIn','$like','$notILike','$overlap','$contained','$any','firstName','CmContact','Contact','dialActive','getApiKey','retrieveApiKey','token','No\x20API\x20access\x20key\x20found!','You\x20don\x27t\x20have\x20sufficient\x20privileges\x20to\x20access\x20this\x20resource.','generateApiKey','nonce','removeApiKey','apiKeyNonce','apiKeyIat','whoami','html-pdf','rimraf','fast-json-patch','request-promise','bluebird','path','sox','to-csv','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/environment','../../mysqldb','defaults','redis','localhost','./user.socket','jayson/promise','client','http','test','Sequelize','ValidationError','The\x20password\x20must\x20be\x20at\x20least\x208\x20characters\x20long\x20and\x20have\x201\x20lowercase\x20character,\x201\x20uppercase\x20character,\x201\x20number\x20and\x201\x20special\x20character\x20~!@#$%^&-_=+[{]}.','request','then','info','User,\x20%s,\x20%s','request\x20sent','debug','User,\x20%s,\x20%s,\x20%s','error','code','message','result','catch','status','end','json','count','offset','limit','set','Content-Range','reject','save','update','get','Users','Agents','Telephones','telephone','filter','ignore','value','role','find','name','UserProfileResource','destroy','sendStatus','stack','send','map','fieldName','type','key','model','password','salt','query','keys','filters','intersection','fields','attributes','hasOwnProperty','nolimit','order','sort','where','pick','merge','VIRTUAL','sequelize','lower','col','options','User','includeAll','include','findAll','rows','show','params','rawAttributes','bulkCreate','body','describe','addContacts','ids','omit','agent\x20role','admin','../../config/license/util','getLicense','telephones','users','isNil','License\x20limit\x20reached','format','count\x20%s:\x20%s','create','internal','Setting','securePassword','min_internal','select\x20(select\x20IFNULL(max(internal)+1,1)\x20from\x20users\x20where\x20internal\x20<\x20md.internal)\x20as\x20\x27from\x27,\x20md.internal\x20-\x201\x20as\x20\x27to\x27\x20from\x20users\x20md\x20where\x20md.internal\x20!=\x201\x20and\x20not\x20exists\x20(select\x201\x20from\x20users\x20md2\x20where\x20md2.internal\x20=\x20md.internal\x20-\x201)','QueryTypes','SELECT','from','voicemail','mailbox','fullname','email','agent','permissions','101','102','103','110','104','106','107','109','100','111','VoiceMail','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','UserProfileSection','userProfileId','autoAssociation','changePassword','findOne','oldPassword','newPassword','authenticate','Wrong\x20credentials','New\x20password\x20must\x20be\x20different\x20from\x20old\x20password','Invalid\x20body\x20format.\x20Use\x20newPassword','addQueues','channel','loginInPause','voicePause','interface','isValidChannel','Unknown\x20channel','add','capitalize','penalty','spread','length','QueueId','emit','toLowerCase','Queue:save','voice','VoiceQueue','online','push','SIP/%s','each','upsert','removeQueues','Queues','Queue:remove','UserVoiceQueueRt','userpic','getAvatar','join','root','server/files/images/logos/default_profile.png','download','existsSync','server/files/images/','getContacts','CmList','List','Tag','Tags','color','tag','getQueues','Queue','Unknown\x20role','getVoiceQueuesRt','getGroups','VoiceRecording','UserId','getScreenRecordings','ScreenRecording','getChatInteractions','getOpenchannelInteractions','getMailInteractions','MailInteraction','getSmsInteractions','SmsInteraction','getFaxInteractions','phone','mobile','LOCAL/%s@from-sip/n','intrf','user:%s','user:forcelogout','headers','x-forwarded-for','connection','remoteAddress','socket','User\x20not\x20found\x20or\x20not\x20allowed\x20to\x20perform\x20login\x20method','MemberReport','forEach','YYYY-MM-DD\x20HH:mm:ss','all','LOGIN','device','PAUSE','LOGININPAUSE','resolve','logout','QueuePause','pause','getChannels','DEFAULT\x20PAUSE','unpause','openchannelPause','smsPause','pauseType','lastPauseAt','manual','mail','fax','openchannel','%s%s','getTeams','Team','addTeams','setDataValue','getChatQueues','Chat','getMailQueues','Mail','getSmsQueues','Sms','getFaxQueues','getOpenchannelQueues','Openchannel','flatten','transaction','getDataValue','removeTeams','getVoiceQueues','Voice','Fax','removeAgent','getLists','getAgents','values','You\x20can\x27t\x20delete\x20yourself','addChatInteractions','user_has_chat_interactions:save','removeChatInteractions','isArray','user_has_chat_interactions:remove','addMailInteractions','user_has_mail_interactions:save','removeMailInteractions','user_has_mail_interactions:remove','addFaxInteractions','user_has_fax_interactions:save','removeFaxInteractions','user_has_fax_interactions:remove','addSmsInteractions','user_has_sms_interactions:save','removeSmsInteractions','addOpenchannelInteractions','removeOpenchannelInteractions','user_has_openchannel_interactions:remove','getVoicePrefixes','VoicePrefix'];(function(_0x51e559,_0x145275){var _0x169eb1=function(_0x142c28){while(--_0x142c28){_0x51e559['push'](_0x51e559['shift']());}};_0x169eb1(++_0x145275);}(_0x24bb,0x19f));var _0xb24b=function(_0x5acafb,_0x3ecb2e){_0x5acafb=_0x5acafb-0x0;var _0x4a7024=_0x24bb[_0x5acafb];return _0x4a7024;};'use strict';var pdf=require(_0xb24b('0x0'));var emlformat=require('eml-format');var rimraf=require(_0xb24b('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0xb24b('0x2'));var rp=require(_0xb24b('0x3'));var moment=require('moment');var BPromise=require(_0xb24b('0x4'));var Mustache=require('mustache');var util=require('util');var path=require(_0xb24b('0x5'));var sox=require(_0xb24b('0x6'));var csv=require(_0xb24b('0x7'));var ejs=require('ejs');var fs=require('fs');var _=require('lodash');var squel=require(_0xb24b('0x8'));var crypto=require(_0xb24b('0x9'));var jsforce=require(_0xb24b('0xa'));var deskjs=require(_0xb24b('0xb'));var toCsv=require(_0xb24b('0x7'));var querystring=require(_0xb24b('0xc'));var Papa=require(_0xb24b('0xd'));var Redis=require(_0xb24b('0xe'));var authService=require('../../components/auth/service');var qs=require(_0xb24b('0xf'));var as=require(_0xb24b('0x10'));var hardwareService=require(_0xb24b('0x11'));var logger=require(_0xb24b('0x12'))('api');var utils=require('../../config/utils');var config=require(_0xb24b('0x13'));var db=require(_0xb24b('0x14'))['db'];config['redis']=_[_0xb24b('0x15')](config[_0xb24b('0x16')],{'host':_0xb24b('0x17'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0xb24b('0x16')]));require(_0xb24b('0x18'))['register'](socket);var jayson=require(_0xb24b('0x19'));var client=jayson[_0xb24b('0x1a')][_0xb24b('0x1b')]({'port':0x232a});function checkPasswordPattern(_0x2f89f5,_0x3a2d7a,_0x4e95c8){if(_0x4e95c8){var _0x3f3676=new RegExp(/(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[?!@#\$%\^&\*~\-_=+[{\]\}])(?=.{8,})/);if(_0x3f3676[_0xb24b('0x1c')](_0x3a2d7a)){return _0x2f89f5;}else{throw new db[(_0xb24b('0x1d'))][(_0xb24b('0x1e'))](_0xb24b('0x1f'));}}else{return _0x2f89f5;}}function respondWithRpcPromise(_0x3d5a32,_0x2c7b9a,_0x5cf988,_0x3285c4){return new BPromise(function(_0x245b61,_0x292c4a){var _0x594b38=_0x3285c4||client;return _0x594b38[_0xb24b('0x20')](_0x3d5a32,_0x5cf988)[_0xb24b('0x21')](function(_0x54eb8a){logger[_0xb24b('0x22')](_0xb24b('0x23'),_0x2c7b9a,_0xb24b('0x24'));logger[_0xb24b('0x25')](_0xb24b('0x26'),_0x2c7b9a,_0xb24b('0x24'),JSON['stringify'](_0x54eb8a));if(_0x54eb8a[_0xb24b('0x27')]){if(_0x54eb8a[_0xb24b('0x27')][_0xb24b('0x28')]===0x1f4){logger[_0xb24b('0x27')](_0xb24b('0x23'),_0x2c7b9a,_0x54eb8a['error'][_0xb24b('0x29')]);return _0x292c4a(_0x54eb8a[_0xb24b('0x27')][_0xb24b('0x29')]);}logger[_0xb24b('0x27')]('User,\x20%s,\x20%s',_0x2c7b9a,_0x54eb8a[_0xb24b('0x27')]['message']);return _0x245b61(_0x54eb8a['error'][_0xb24b('0x29')]);}else{logger[_0xb24b('0x22')]('User,\x20%s,\x20%s',_0x2c7b9a,_0xb24b('0x24'));_0x245b61(_0x54eb8a[_0xb24b('0x2a')][_0xb24b('0x29')]);}})[_0xb24b('0x2b')](function(_0x4d2c51){logger['error']('User,\x20%s,\x20%s',_0x2c7b9a,_0x4d2c51);_0x292c4a(_0x4d2c51);});});}function respondWithStatusCode(_0x383b63,_0x65b1d9){_0x65b1d9=_0x65b1d9||0xcc;return function(_0x38975f){if(_0x38975f){return _0x383b63['sendStatus'](_0x65b1d9);}return _0x383b63[_0xb24b('0x2c')](_0x65b1d9)[_0xb24b('0x2d')]();};}function respondWithResult(_0xd8dbbd,_0x53888d){_0x53888d=_0x53888d||0xc8;return function(_0x112c4d){if(_0x112c4d){return _0xd8dbbd[_0xb24b('0x2c')](_0x53888d)[_0xb24b('0x2e')](_0x112c4d);}};}function respondWithFilteredResult(_0x5de4f0,_0xf53d92){return function(_0x33a389){if(_0x33a389){var _0x7e4166=_0x33a389[_0xb24b('0x2f')],_0x36c97e=_0xf53d92['offset'],_0x4561b9=_0xf53d92[_0xb24b('0x30')]+_0xf53d92[_0xb24b('0x31')],_0x41d4d7;if(_0x4561b9>=_0x7e4166){_0x4561b9=_0x7e4166;_0x41d4d7=0xc8;}else{_0x41d4d7=0xce;}_0x5de4f0[_0xb24b('0x2c')](_0x41d4d7);return _0x5de4f0[_0xb24b('0x32')](_0xb24b('0x33'),_0x36c97e+'-'+_0x4561b9+'/'+_0x7e4166)[_0xb24b('0x2e')](_0x33a389);}return null;};}function patchUpdates(_0x5151ca){return function(_0x2fd3fe){try{jsonpatch['apply'](_0x2fd3fe,_0x5151ca,!![]);}catch(_0x2a46f1){return BPromise[_0xb24b('0x34')](_0x2a46f1);}return _0x2fd3fe[_0xb24b('0x35')]();};}function saveUpdates(_0x4c04ab,_0x5cc2d1){return function(_0x96a958){if(_0x96a958){return _0x96a958[_0xb24b('0x36')](_0x4c04ab)[_0xb24b('0x21')](function(_0xbddbb6){return _0xbddbb6;});}return null;};}function removeEntity(_0x195ced,_0x3893eb){return function(_0x418312){if(_0x418312){return _0x418312['destroy']()[_0xb24b('0x21')](function(){var _0x5107ff=_0x418312[_0xb24b('0x37')]({'plain':!![]});var _0x81e4d9=[{'name':_0xb24b('0x38'),'value':'user','ignore':!![]},{'name':_0xb24b('0x39'),'value':'agent','ignore':![]},{'name':_0xb24b('0x3a'),'value':_0xb24b('0x3b'),'ignore':![]}];var _0x3e5bc6=_(_0x81e4d9)[_0xb24b('0x3c')](_0xb24b('0x3d'))['map'](_0xb24b('0x3e'))[_0xb24b('0x3e')]();if(_['includes'](_0x3e5bc6,_0x5107ff[_0xb24b('0x3f')])){return;}var _0x2c87da=_[_0xb24b('0x40')](_0x81e4d9,['value',_0x5107ff['role']])[_0xb24b('0x41')];return db[_0xb24b('0x42')][_0xb24b('0x43')]({'where':{'type':_0x2c87da,'resourceId':_0x5107ff['id']}})[_0xb24b('0x21')](function(){return _0x418312;});})[_0xb24b('0x21')](function(){_0x195ced[_0xb24b('0x2c')](0xcc)[_0xb24b('0x2d')]();});}};}function handleEntityNotFound(_0x24bd42,_0xac04f3){return function(_0x18fe6a){if(!_0x18fe6a){_0x24bd42[_0xb24b('0x44')](0x194);}return _0x18fe6a;};}function handleError(_0x3bb563,_0x509ccd){_0x509ccd=_0x509ccd||0x1f4;return function(_0x5e97cb){logger['error'](_0x5e97cb[_0xb24b('0x45')]);if(_0x5e97cb[_0xb24b('0x41')]){delete _0x5e97cb['name'];}_0x3bb563[_0xb24b('0x2c')](_0x509ccd)[_0xb24b('0x46')](_0x5e97cb);};}exports['index']=function(_0x41c740,_0x5a6b99){var _0x191bff={},_0x56c7f8={},_0x3a8ec0={'count':0x0,'rows':[]};var _0x302ab3=_[_0xb24b('0x47')](db['User']['rawAttributes'],function(_0x2fbe1b){return{'name':_0x2fbe1b[_0xb24b('0x48')],'type':_0x2fbe1b[_0xb24b('0x49')][_0xb24b('0x4a')]};});_0x56c7f8[_0xb24b('0x4b')]=_['differenceBy'](_[_0xb24b('0x47')](_0x302ab3,'name'),[_0xb24b('0x4c'),_0xb24b('0x4d')]);_0x56c7f8[_0xb24b('0x4e')]=_[_0xb24b('0x4f')](_0x41c740['query']);_0x56c7f8[_0xb24b('0x50')]=_['intersection'](_0x56c7f8[_0xb24b('0x4b')],_0x56c7f8[_0xb24b('0x4e')]);_0x191bff['attributes']=_[_0xb24b('0x51')](_0x56c7f8[_0xb24b('0x4b')],qs[_0xb24b('0x52')](_0x41c740[_0xb24b('0x4e')]['fields']));_0x191bff[_0xb24b('0x53')]=_0x191bff[_0xb24b('0x53')]['length']?_0x191bff[_0xb24b('0x53')]:_0x56c7f8[_0xb24b('0x4b')];if(!_0x41c740[_0xb24b('0x4e')][_0xb24b('0x54')](_0xb24b('0x55'))){_0x191bff[_0xb24b('0x31')]=qs['limit'](_0x41c740['query'][_0xb24b('0x31')]);_0x191bff['offset']=qs[_0xb24b('0x30')](_0x41c740['query'][_0xb24b('0x30')]);}_0x191bff[_0xb24b('0x56')]=qs[_0xb24b('0x57')](_0x41c740[_0xb24b('0x4e')][_0xb24b('0x57')]);_0x191bff[_0xb24b('0x58')]=qs[_0xb24b('0x50')](_[_0xb24b('0x59')](_0x41c740[_0xb24b('0x4e')],_0x56c7f8[_0xb24b('0x50')]));if(_0x41c740[_0xb24b('0x4e')][_0xb24b('0x3c')]){_0x191bff[_0xb24b('0x58')]=_[_0xb24b('0x5a')](_0x191bff[_0xb24b('0x58')],{'$or':_['map'](_0x302ab3,function(_0x45c828){if(_0x45c828[_0xb24b('0x49')]!==_0xb24b('0x5b')){return db['sequelize'][_0xb24b('0x58')](db[_0xb24b('0x5c')]['fn'](_0xb24b('0x5d'),db[_0xb24b('0x5c')][_0xb24b('0x5e')](_0x45c828[_0xb24b('0x41')])),{'$like':db['sequelize']['fn']('lower','%'+_0x41c740[_0xb24b('0x4e')][_0xb24b('0x3c')]+'%')});}})});}_0x191bff=_['merge']({},_0x191bff,_0x41c740[_0xb24b('0x5f')]);var _0x3f6110={'where':_0x191bff[_0xb24b('0x58')]};return db[_0xb24b('0x60')][_0xb24b('0x2f')](_0x3f6110)['then'](function(_0x22fbd1){_0x3a8ec0[_0xb24b('0x2f')]=_0x22fbd1;if(_0x41c740[_0xb24b('0x4e')][_0xb24b('0x61')]){_0x191bff[_0xb24b('0x62')]=[{'all':!![]}];}return db[_0xb24b('0x60')][_0xb24b('0x63')](_0x191bff);})['then'](function(_0x156058){_0x3a8ec0[_0xb24b('0x64')]=_0x156058;return _0x3a8ec0;})[_0xb24b('0x21')](respondWithFilteredResult(_0x5a6b99,_0x191bff))['catch'](handleError(_0x5a6b99,null));};exports[_0xb24b('0x65')]=function(_0x4a61e6,_0x25d8c2){var _0x28a8b3={'raw':![],'where':{'id':_0x4a61e6[_0xb24b('0x66')]['id']}},_0x10af08={};_0x10af08[_0xb24b('0x4b')]=_['differenceBy'](_[_0xb24b('0x4f')](db[_0xb24b('0x60')][_0xb24b('0x67')]),[_0xb24b('0x4c'),_0xb24b('0x4d')]);_0x10af08['query']=_[_0xb24b('0x4f')](_0x4a61e6[_0xb24b('0x4e')]);_0x10af08[_0xb24b('0x50')]=_['intersection'](_0x10af08[_0xb24b('0x4b')],_0x10af08[_0xb24b('0x4e')]);_0x28a8b3[_0xb24b('0x53')]=_[_0xb24b('0x51')](_0x10af08[_0xb24b('0x4b')],qs[_0xb24b('0x52')](_0x4a61e6[_0xb24b('0x4e')][_0xb24b('0x52')]));_0x28a8b3[_0xb24b('0x53')]=_0x28a8b3[_0xb24b('0x53')]['length']?_0x28a8b3[_0xb24b('0x53')]:_0x10af08[_0xb24b('0x4b')];if(_0x4a61e6[_0xb24b('0x4e')][_0xb24b('0x61')]){_0x28a8b3['include']=[{'all':!![]}];}_0x28a8b3=_[_0xb24b('0x5a')]({},_0x28a8b3,_0x4a61e6[_0xb24b('0x5f')]);return db[_0xb24b('0x60')][_0xb24b('0x40')](_0x28a8b3)[_0xb24b('0x21')](handleEntityNotFound(_0x25d8c2,null))['then'](respondWithResult(_0x25d8c2,null))['catch'](handleError(_0x25d8c2,null));};exports['bulkCreate']=function(_0x4f3ec4,_0x5cdb18){return db[_0xb24b('0x60')][_0xb24b('0x68')](_0x4f3ec4['body'],{'raw':![],'individualHooks':!![]})[_0xb24b('0x21')](respondWithResult(_0x5cdb18,0xc9))[_0xb24b('0x2b')](handleError(_0x5cdb18,null));};exports[_0xb24b('0x36')]=function(_0xb92961,_0x3d8b2a){if(_0xb92961[_0xb24b('0x69')]['id']){delete _0xb92961['body']['id'];}delete _0xb92961[_0xb24b('0x69')][_0xb24b('0x3f')];return db['User']['find']({'where':{'id':_0xb92961[_0xb24b('0x66')]['id']}})['then'](handleEntityNotFound(_0x3d8b2a,null))[_0xb24b('0x21')](saveUpdates(_0xb92961[_0xb24b('0x69')],null))[_0xb24b('0x21')](respondWithResult(_0x3d8b2a,null))[_0xb24b('0x2b')](handleError(_0x3d8b2a,null));};exports[_0xb24b('0x6a')]=function(_0x18e372,_0x102965){return db['User'][_0xb24b('0x6a')]()[_0xb24b('0x21')](respondWithResult(_0x102965,null))[_0xb24b('0x2b')](handleError(_0x102965,null));};exports[_0xb24b('0x6b')]=function(_0x42cdea,_0x4775b7,_0x57759c){return db[_0xb24b('0x60')][_0xb24b('0x40')]({'where':{'id':_0x42cdea['params']['id']}})[_0xb24b('0x21')](handleEntityNotFound(_0x4775b7,null))[_0xb24b('0x21')](function(_0x291d6a){if(_0x291d6a){return _0x291d6a[_0xb24b('0x6b')](_0x42cdea[_0xb24b('0x69')][_0xb24b('0x6c')],_[_0xb24b('0x6d')](_0x42cdea[_0xb24b('0x69')],[_0xb24b('0x6c'),'id'])||{});}})[_0xb24b('0x21')](respondWithResult(_0x4775b7,null))[_0xb24b('0x2b')](handleError(_0x4775b7,null));};var getLicense=function(_0x3501e1){return new BPromise(function(_0x577cf0,_0x3ac5c8){var _0x5da05f=0x0;_0x3501e1[_0xb24b('0x69')][_0xb24b('0x3f')]==='agent'&&_0x577cf0(_0xb24b('0x6e'));return db[_0xb24b('0x60')]['count']({'where':{'$or':[{'role':_0x3501e1[_0xb24b('0x69')][_0xb24b('0x3f')]===_0xb24b('0x3b')?_0xb24b('0x3b'):[_0xb24b('0x6f'),'user']}]}})['then'](function(_0x248b71){_0x5da05f=_0x248b71;return require(_0xb24b('0x70'))[_0xb24b('0x71')]();})[_0xb24b('0x21')](function(_0x9534a8){var _0x5ee710=_0x3501e1[_0xb24b('0x69')][_0xb24b('0x3f')]===_0xb24b('0x3b')?_0xb24b('0x72'):_0xb24b('0x73');if(!_[_0xb24b('0x74')](_0x9534a8[_0x5ee710])&&_0x5da05f>=_0x9534a8[_0x5ee710]){return _0x3ac5c8({'message':_0xb24b('0x75')});}return _0x577cf0(util[_0xb24b('0x76')](_0xb24b('0x77'),_0x5ee710,_0x5da05f));})[_0xb24b('0x2b')](function(_0x1d6d30){return _0x3ac5c8(_0x1d6d30);});});};exports[_0xb24b('0x78')]=function(_0x14e1f8,_0x39c6f9){return getLicense(_0x14e1f8)[_0xb24b('0x21')](function(_0x1c1a1d){if(!_0x14e1f8[_0xb24b('0x69')][_0xb24b('0x79')]){var _0x5f4d55;return db[_0xb24b('0x7a')]['findById'](0x1)[_0xb24b('0x21')](function(_0x242260){return checkPasswordPattern(_0x242260,_0x14e1f8[_0xb24b('0x69')][_0xb24b('0x4c')],_0x242260[_0xb24b('0x7b')]);})[_0xb24b('0x21')](function(_0x56e83b){_0x5f4d55=_0x56e83b[_0xb24b('0x7c')];return db['User']['max'](_0xb24b('0x79'));})[_0xb24b('0x21')](function(_0x1266a8){if(_[_0xb24b('0x74')](_0x1266a8)){if(_0x5f4d55){_0x14e1f8['body'][_0xb24b('0x79')]=_0x5f4d55;}else{_0x14e1f8[_0xb24b('0x69')]['internal']=0x1;}}else{if(_[_0xb24b('0x74')](_0x5f4d55)||_0x5f4d55==_0x1266a8){_0x14e1f8['body'][_0xb24b('0x79')]=_0x1266a8+0x1;}else if(_0x5f4d55>_0x1266a8){_0x14e1f8[_0xb24b('0x69')]['internal']=_0x5f4d55;}else{return db[_0xb24b('0x5c')][_0xb24b('0x4e')](_0xb24b('0x7d'),{'type':db[_0xb24b('0x5c')][_0xb24b('0x7e')][_0xb24b('0x7f')]})[_0xb24b('0x21')](function(_0x47e7b5){if(_0x47e7b5&&_0x47e7b5['length']){for(var _0x903fad=0x0,_0x335b4d=_0x47e7b5['length'];_0x903fad<_0x335b4d&&_[_0xb24b('0x74')](_0x14e1f8[_0xb24b('0x69')][_0xb24b('0x79')]);_0x903fad++){if(_0x5f4d55<=_0x47e7b5[_0x903fad][_0xb24b('0x80')]){_0x14e1f8[_0xb24b('0x69')]['internal']=_0x47e7b5[_0x903fad][_0xb24b('0x80')];}else if(_0x5f4d55>_0x47e7b5[_0x903fad]['from']&&_0x5f4d55<=_0x47e7b5[_0x903fad]['to']){_0x14e1f8[_0xb24b('0x69')][_0xb24b('0x79')]=_0x5f4d55;}}}if(_[_0xb24b('0x74')](_0x14e1f8['body'][_0xb24b('0x79')])){_0x14e1f8[_0xb24b('0x69')]['internal']=_0x1266a8+0x1;}});}}});}})[_0xb24b('0x21')](function(){if(_0x14e1f8['body'][_0xb24b('0x81')]){_0x14e1f8['body'][_0xb24b('0x82')]=_0x14e1f8[_0xb24b('0x69')]['internal'];_0x14e1f8['body']['VoiceMail']={'mailbox':_0x14e1f8[_0xb24b('0x69')]['internal'],'password':_0x14e1f8[_0xb24b('0x69')][_0xb24b('0x4c')],'fullname':_0x14e1f8[_0xb24b('0x69')][_0xb24b('0x83')],'email':_0x14e1f8['body'][_0xb24b('0x84')]};}if(_0x14e1f8[_0xb24b('0x69')]&&_0x14e1f8[_0xb24b('0x69')][_0xb24b('0x3f')]===_0xb24b('0x85')){_0x14e1f8[_0xb24b('0x69')][_0xb24b('0x86')]=[_0xb24b('0x87'),_0xb24b('0x88'),_0xb24b('0x89'),_0xb24b('0x8a'),_0xb24b('0x8b'),'105',_0xb24b('0x8c'),_0xb24b('0x8d'),'108',_0xb24b('0x8e'),_0xb24b('0x8f'),_0xb24b('0x90')];}return db[_0xb24b('0x60')]['create'](_0x14e1f8[_0xb24b('0x69')],{'include':[{'model':db['VoiceMail'],'as':_0xb24b('0x91')}]});})[_0xb24b('0x21')](function(_0x325489){if(_0x14e1f8[_0xb24b('0x69')][_0xb24b('0x3f')]===_0xb24b('0x92'))return _0x325489;var _0x55436a=_0x14e1f8[_0xb24b('0x92')][_0xb24b('0x37')]({'plain':!![]});if(!_0x55436a)throw new Error(_0xb24b('0x93'));if(_0x55436a[_0xb24b('0x3f')]==='user'){var _0x9c00c3=_0x325489[_0xb24b('0x37')]({'plain':!![]});var _0xfbae11=[{'name':_0xb24b('0x39'),'value':_0xb24b('0x85')},{'name':_0xb24b('0x3a'),'value':_0xb24b('0x3b')}];var _0x134f23=_[_0xb24b('0x40')](_0xfbae11,[_0xb24b('0x3e'),_0x9c00c3[_0xb24b('0x3f')]])['name'];return db[_0xb24b('0x94')][_0xb24b('0x40')]({'where':{'name':_0x134f23,'userProfileId':_0x55436a[_0xb24b('0x95')]},'raw':!![]})['then'](function(_0x35fb69){if(_0x35fb69&&_0x35fb69[_0xb24b('0x96')]===0x0){return db[_0xb24b('0x42')][_0xb24b('0x78')]({'name':_0x9c00c3[_0xb24b('0x41')],'resourceId':_0x9c00c3['id'],'type':_0x35fb69[_0xb24b('0x41')],'sectionId':_0x35fb69['id']},{})[_0xb24b('0x21')](function(){return _0x325489;});}else{return _0x325489;}})[_0xb24b('0x2b')](function(_0x330505){logger[_0xb24b('0x27')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x330505);throw _0x330505;});}return _0x325489;})['then'](respondWithResult(_0x39c6f9,0xc9))[_0xb24b('0x2b')](handleError(_0x39c6f9,null));};exports[_0xb24b('0x97')]=function(_0x5e5ce5,_0x461f6e,_0x92b501){var _0x13569a=![];if(_0x5e5ce5[_0xb24b('0x69')]['id']){delete _0x5e5ce5[_0xb24b('0x69')]['id'];}return db[_0xb24b('0x7a')][_0xb24b('0x98')]({'attributes':['id',_0xb24b('0x7b')]})[_0xb24b('0x21')](function(_0x1cb19e){_0x13569a=_0x1cb19e[_0xb24b('0x7b')];return db[_0xb24b('0x60')][_0xb24b('0x40')]({'where':{'id':_0x5e5ce5[_0xb24b('0x66')]['id']}});})[_0xb24b('0x21')](function(_0x328e39){if(_0x328e39){if(_0x328e39['id']==_0x5e5ce5['user']['id']){if(!_0x5e5ce5[_0xb24b('0x69')][_0xb24b('0x99')]||!_0x5e5ce5['body'][_0xb24b('0x9a')]){throw new db['Sequelize'][(_0xb24b('0x1e'))]('Invalid\x20body\x20format.\x20Use\x20oldPassord\x20and\x20newPassword');}if(!_0x328e39[_0xb24b('0x9b')](_0x5e5ce5[_0xb24b('0x69')][_0xb24b('0x99')])){throw new db[(_0xb24b('0x1d'))][(_0xb24b('0x1e'))](_0xb24b('0x9c'));}if(_0x5e5ce5[_0xb24b('0x69')][_0xb24b('0x99')]==_0x5e5ce5[_0xb24b('0x69')][_0xb24b('0x9a')]){throw new db['Sequelize'][(_0xb24b('0x1e'))](_0xb24b('0x9d'));}return _0x328e39;}else if(_0x5e5ce5[_0xb24b('0x92')][_0xb24b('0x3f')]=='admin'){if(!_0x5e5ce5[_0xb24b('0x69')]['newPassword']){throw new db[(_0xb24b('0x1d'))]['ValidationError'](_0xb24b('0x9e'));}return _0x328e39;}else if(_0x5e5ce5[_0xb24b('0x92')][_0xb24b('0x3f')]=='user'){if(!_0x5e5ce5[_0xb24b('0x69')][_0xb24b('0x9a')]){throw new db[(_0xb24b('0x1d'))][(_0xb24b('0x1e'))](_0xb24b('0x9e'));}if(_0x328e39[_0xb24b('0x3f')]!=_0xb24b('0x85')){throw new db[(_0xb24b('0x1d'))][(_0xb24b('0x1e'))]('Unauthorized');}return _0x328e39;}else{throw new db[(_0xb24b('0x1d'))][(_0xb24b('0x1e'))]('Unauthorized');}}return null;})['then'](handleEntityNotFound(_0x461f6e,null))[_0xb24b('0x21')](function(_0x36f89c){return checkPasswordPattern(_0x36f89c,_0x5e5ce5['body']['newPassword'],_0x13569a);})[_0xb24b('0x21')](saveUpdates({'password':_0x5e5ce5[_0xb24b('0x69')][_0xb24b('0x9a')],'passwordResetAt':_0x5e5ce5[_0xb24b('0x92')]['id']==_0x5e5ce5[_0xb24b('0x66')]['id']?moment():null},null))[_0xb24b('0x21')](respondWithResult(_0x461f6e,null))['catch'](handleError(_0x461f6e,null));};exports[_0xb24b('0x9f')]=function(_0x16561e,_0xaa68f4,_0x536558){var _0x30d517=_0x16561e[_0xb24b('0x69')][_0xb24b('0xa0')];return db[_0xb24b('0x60')]['find']({'where':{'id':_0x16561e['params']['id']},'attributes':['id','name',_0xb24b('0x3f'),'online',_0xb24b('0xa1'),_0xb24b('0xa2'),_0xb24b('0xa3')]})[_0xb24b('0x21')](handleEntityNotFound(_0xaa68f4,null))[_0xb24b('0x21')](function(_0x11abcc){if(_0x11abcc){if(!utils[_0xb24b('0xa4')](_0x30d517)){throw new db[(_0xb24b('0x1d'))][(_0xb24b('0x1e'))](_0xb24b('0xa5'));}return _0x11abcc[_0xb24b('0xa6')+_[_0xb24b('0xa7')](_0x30d517['toLowerCase']())+'Queues'](_0x16561e[_0xb24b('0x69')]['ids'],{'penalty':_0x16561e[_0xb24b('0x69')][_0xb24b('0xa8')]||0x0})[_0xb24b('0xa9')](function(_0x4b0f48){for(var _0x24d088=0x0;_0x24d088<_0x16561e[_0xb24b('0x69')]['ids'][_0xb24b('0xaa')];_0x24d088+=0x1){var _0x1af5c8={'UserId':_0x16561e[_0xb24b('0x66')]['id']};_0x1af5c8[_[_0xb24b('0xa7')](_0x30d517['toLowerCase']())+_0xb24b('0xab')]=_0x16561e['body'][_0xb24b('0x6c')][_0x24d088];socket[_0xb24b('0xac')]('user'+_['capitalize'](_0x30d517[_0xb24b('0xad')]())+_0xb24b('0xae'),_0x1af5c8);}return _0x4b0f48;})[_0xb24b('0x21')](function(){if(_0x30d517===_0xb24b('0xaf')){return db[_0xb24b('0xb0')][_0xb24b('0x63')]({'where':{'id':_0x16561e[_0xb24b('0x69')][_0xb24b('0x6c')]||[]},'raw':!![],'attributes':['id',_0xb24b('0x41')]});}})[_0xb24b('0x21')](function(_0x28e394){var _0x104fc9=_0x11abcc['get']({'plain':!![]});var _0x1c6b2c=[];if(_0x30d517==='voice'&&_0x104fc9[_0xb24b('0x3f')]==='agent'&&_0x104fc9[_0xb24b('0xb1')]){for(var _0x2307e4=0x0;_0x2307e4<_0x28e394[_0xb24b('0xaa')];_0x2307e4+=0x1){_0x1c6b2c[_0xb24b('0xb2')]({'membername':_0x104fc9['name'],'UserId':_0x104fc9['id'],'queue_name':_0x28e394[_0x2307e4]['name'],'VoiceQueueId':_0x28e394[_0x2307e4]['id'],'interface':_[_0xb24b('0x74')](_0x104fc9['interface'])?util['format'](_0xb24b('0xb3'),_0x104fc9[_0xb24b('0x41')]):_0x104fc9[_0xb24b('0xa3')],'paused':_0x104fc9[_0xb24b('0xa2')]||![],'penalty':_0x16561e[_0xb24b('0x69')][_0xb24b('0xa8')]||0x0});}return BPromise[_0xb24b('0xb4')](_0x1c6b2c,function(_0x325f0d){return db['UserVoiceQueueRt'][_0xb24b('0xb5')](_0x325f0d);});}return _0x11abcc;});}})[_0xb24b('0x21')](respondWithStatusCode(_0xaa68f4,null))['catch'](handleError(_0xaa68f4,null));};exports[_0xb24b('0xb6')]=function(_0x1b37e7,_0x506a38,_0xb71a06){var _0x51b083;return db[_0xb24b('0x60')]['find']({'where':{'id':_0x1b37e7[_0xb24b('0x66')]['id']},'attributes':['id','name','role']})['then'](handleEntityNotFound(_0x506a38,null))[_0xb24b('0x21')](function(_0x3f3d2c){if(_0x3f3d2c){_0x51b083=_0x3f3d2c;if(!_0x1b37e7[_0xb24b('0x4e')][_0xb24b('0xa0')]||!utils[_0xb24b('0xa4')](_0x1b37e7[_0xb24b('0x4e')][_0xb24b('0xa0')])){throw new db['Sequelize'][(_0xb24b('0x1e'))]('Unknown\x20channel');}return _0x3f3d2c['remove'+_[_0xb24b('0xa7')](_0x1b37e7['query'][_0xb24b('0xa0')][_0xb24b('0xad')]())+_0xb24b('0xb7')](_0x1b37e7['query'][_0xb24b('0x6c')]);}})[_0xb24b('0x21')](function(_0x3ce62d){for(var _0x62520c=0x0;_0x62520c<_0x1b37e7['query'][_0xb24b('0x6c')][_0xb24b('0xaa')];_0x62520c+=0x1){var _0x18df95={'UserId':_0x1b37e7[_0xb24b('0x66')]['id']};_0x18df95[_[_0xb24b('0xa7')](_0x1b37e7[_0xb24b('0x4e')][_0xb24b('0xa0')][_0xb24b('0xad')]())+_0xb24b('0xab')]=_0x1b37e7[_0xb24b('0x4e')][_0xb24b('0x6c')][_0x62520c];socket[_0xb24b('0xac')](_0xb24b('0x92')+_[_0xb24b('0xa7')](_0x1b37e7[_0xb24b('0x4e')][_0xb24b('0xa0')][_0xb24b('0xad')]())+_0xb24b('0xb8'),_0x18df95);}return _0x3ce62d;})[_0xb24b('0x21')](function(){if(_0x1b37e7[_0xb24b('0x4e')][_0xb24b('0xa0')]===_0xb24b('0xaf')){return db[_0xb24b('0xb9')][_0xb24b('0x43')]({'where':{'UserId':_0x1b37e7[_0xb24b('0x66')]['id'],'VoiceQueueId':_0x1b37e7[_0xb24b('0x4e')][_0xb24b('0x6c')]},'individualHooks':!![]})['then'](function(){return _0x51b083;});}return _0x51b083;})[_0xb24b('0x21')](respondWithStatusCode(_0x506a38,null))[_0xb24b('0x2b')](handleError(_0x506a38,null));};exports['addAvatar']=function(_0x55aa95,_0x47f4f4,_0x1fd17f){_0x55aa95[_0xb24b('0x69')][_0xb24b('0xba')]=_0x55aa95['file']['filename'];return db[_0xb24b('0x60')][_0xb24b('0x40')]({'where':{'id':_0x55aa95[_0xb24b('0x66')]['id']}})[_0xb24b('0x21')](handleEntityNotFound(_0x47f4f4,null))['then'](saveUpdates(_0x55aa95['body'],null))['then'](respondWithResult(_0x47f4f4,null))[_0xb24b('0x2b')](handleError(_0x47f4f4,null));};exports[_0xb24b('0xbb')]=function(_0x3bb947,_0x4cfaf8,_0x3da302){var _0x5c7337=path[_0xb24b('0xbc')](config[_0xb24b('0xbd')],_0xb24b('0xbe'));return db[_0xb24b('0x60')][_0xb24b('0x40')]({'where':{'id':_0x3bb947[_0xb24b('0x66')]['id']},'attributes':['id',_0xb24b('0xba')],'raw':!![]})[_0xb24b('0x21')](handleEntityNotFound(_0x4cfaf8,null))[_0xb24b('0x21')](function(_0xa0f0fe){if(_0xa0f0fe){if(_['isNil'](_0xa0f0fe[_0xb24b('0xba')])){return _0x4cfaf8[_0xb24b('0xbf')](_0x5c7337);}else{if(!fs[_0xb24b('0xc0')](path[_0xb24b('0xbc')](config[_0xb24b('0xbd')],_0xb24b('0xc1'),_0xa0f0fe[_0xb24b('0xba')]))){return _0x4cfaf8[_0xb24b('0xbf')](_0x5c7337);}return _0x4cfaf8[_0xb24b('0xbf')](path['join'](config[_0xb24b('0xbd')],_0xb24b('0xc1'),_0xa0f0fe[_0xb24b('0xba')]));}}})[_0xb24b('0x2b')](handleError(_0x4cfaf8,null));};exports[_0xb24b('0xc2')]=function(_0x1f674d,_0x57e294,_0x306631){var _0x229c0e={};var _0x2c26fd={};var _0x3f326a;var _0x34b101;return db[_0xb24b('0x60')][_0xb24b('0x98')]({'where':{'id':_0x1f674d[_0xb24b('0x66')]['id']}})[_0xb24b('0x21')](handleEntityNotFound(_0x57e294,null))[_0xb24b('0x21')](function(_0x2c5ac8){if(_0x2c5ac8){_0x3f326a=_0x2c5ac8;_0x2c26fd['model']=_[_0xb24b('0x4f')](db['CmContact'][_0xb24b('0x67')]);_0x2c26fd['query']=_['keys'](_0x1f674d['query']);_0x2c26fd[_0xb24b('0x50')]=_[_0xb24b('0x51')](_0x2c26fd[_0xb24b('0x4b')],_0x2c26fd[_0xb24b('0x4e')]);_0x229c0e[_0xb24b('0x53')]=_['intersection'](_0x2c26fd[_0xb24b('0x4b')],qs[_0xb24b('0x52')](_0x1f674d[_0xb24b('0x4e')][_0xb24b('0x52')]));_0x229c0e[_0xb24b('0x53')]=_0x229c0e['attributes']['length']?_0x229c0e[_0xb24b('0x53')]:_0x2c26fd[_0xb24b('0x4b')];_0x229c0e[_0xb24b('0x56')]=qs[_0xb24b('0x57')](_0x1f674d['query'][_0xb24b('0x57')]);_0x229c0e['where']=qs[_0xb24b('0x50')](_[_0xb24b('0x59')](_0x1f674d[_0xb24b('0x4e')],_0x2c26fd[_0xb24b('0x50')]));if(_0x1f674d[_0xb24b('0x4e')][_0xb24b('0x3c')]){_0x229c0e['where']=_[_0xb24b('0x5a')](_0x229c0e[_0xb24b('0x58')],{'$or':_[_0xb24b('0x47')](_0x229c0e[_0xb24b('0x53')],function(_0xb64cef){var _0x38486e={};_0x38486e[_0xb64cef]={'$like':'%'+_0x1f674d[_0xb24b('0x4e')][_0xb24b('0x3c')]+'%'};return _0x38486e;})});}_0x229c0e=_[_0xb24b('0x5a')]({},_0x229c0e,_0x1f674d['options']);return _0x3f326a[_0xb24b('0xc2')](_0x229c0e);}})['then'](function(_0x13f1f8){if(_0x13f1f8){_0x34b101=_0x13f1f8['length'];if(_0x1f674d['query'][_0xb24b('0x54')](_0xb24b('0x61'))){_0x229c0e[_0xb24b('0x62')]=[{'model':db[_0xb24b('0xc3')],'as':_0xb24b('0xc4'),'required':![]},{'model':db[_0xb24b('0xc5')],'as':_0xb24b('0xc6'),'attributes':['id',_0xb24b('0x41'),_0xb24b('0xc7')],'where':_0x1f674d['query'][_0xb24b('0xc8')]?{'id':_0x1f674d[_0xb24b('0x4e')][_0xb24b('0xc8')]}:undefined,'required':_0x1f674d[_0xb24b('0x4e')][_0xb24b('0xc8')]?!![]:![]}];}if(!_0x1f674d[_0xb24b('0x4e')][_0xb24b('0x54')](_0xb24b('0x55'))){_0x229c0e[_0xb24b('0x31')]=qs[_0xb24b('0x31')](_0x1f674d[_0xb24b('0x4e')]['limit']);_0x229c0e[_0xb24b('0x30')]=qs[_0xb24b('0x30')](_0x1f674d['query'][_0xb24b('0x30')]);}return _0x3f326a[_0xb24b('0xc2')](_0x229c0e);}})[_0xb24b('0x21')](function(_0x362728){if(_0x362728){return _0x362728?{'count':_0x34b101,'rows':_0x362728}:null;}})[_0xb24b('0x21')](respondWithResult(_0x57e294,null))[_0xb24b('0x2b')](handleError(_0x57e294,null));};exports[_0xb24b('0xc9')]=function(_0x434ab5,_0x3ffd32,_0x56aec9){var _0x31a7b2;var _0x3f9e0a;var _0x20cdf5={};var _0x2025ea;return db['User'][_0xb24b('0x98')]({'where':{'id':_0x434ab5[_0xb24b('0x66')]['id']},'attributes':['id',_0xb24b('0x41'),_0xb24b('0x3f')]})[_0xb24b('0x21')](handleEntityNotFound(_0x3ffd32,null))['then'](function(_0x9b80a7){if(!utils[_0xb24b('0xa4')](_0x434ab5[_0xb24b('0x4e')]['channel'])){throw new db['Sequelize'][(_0xb24b('0x1e'))]('Unknown\x20channel');}_0x31a7b2=_0x9b80a7;var _0x5453fb={};_0x5453fb['model']=_[_0xb24b('0x4f')](db[_[_0xb24b('0xa7')](_0x434ab5[_0xb24b('0x4e')][_0xb24b('0xa0')])+_0xb24b('0xca')][_0xb24b('0x67')]);_0x5453fb[_0xb24b('0x4e')]=_['keys'](_0x434ab5['query']);_0x5453fb[_0xb24b('0x50')]=_[_0xb24b('0x51')](_0x5453fb[_0xb24b('0x4b')],_0x5453fb[_0xb24b('0x4e')]);_0x20cdf5[_0xb24b('0x53')]=_['intersection'](_0x5453fb[_0xb24b('0x4b')],qs[_0xb24b('0x52')](_0x434ab5['query'][_0xb24b('0x52')]));_0x20cdf5[_0xb24b('0x53')]=_0x20cdf5['attributes'][_0xb24b('0xaa')]?_0x20cdf5[_0xb24b('0x53')]:_0x5453fb[_0xb24b('0x4b')];_0x20cdf5['order']=qs[_0xb24b('0x57')](_0x434ab5[_0xb24b('0x4e')][_0xb24b('0x57')]);_0x20cdf5['where']=qs[_0xb24b('0x50')](_[_0xb24b('0x59')](_0x434ab5[_0xb24b('0x4e')],_0x5453fb[_0xb24b('0x50')]));if(_0x434ab5['query']['filter']){_0x20cdf5['where']=_[_0xb24b('0x5a')](_0x20cdf5['where'],{'$or':_[_0xb24b('0x47')](_0x20cdf5[_0xb24b('0x53')],function(_0x4f11d2){var _0x3b17aa={};_0x3b17aa[_0x4f11d2]={'$like':'%'+_0x434ab5[_0xb24b('0x4e')][_0xb24b('0x3c')]+'%'};return _0x3b17aa;})});}_0x20cdf5=_[_0xb24b('0x5a')]({},_0x20cdf5,_0x434ab5['options']);switch(_0x31a7b2[_0xb24b('0x3f')]){case'admin':return db[_[_0xb24b('0xa7')](_0x434ab5['query'][_0xb24b('0xa0')])+'Queue'][_0xb24b('0x63')](_0x20cdf5);case'user':case'agent':return _0x31a7b2[_0xb24b('0x37')+_[_0xb24b('0xa7')](_0x434ab5[_0xb24b('0x4e')]['channel'])+_0xb24b('0xb7')](_0x20cdf5);default:throw new db[(_0xb24b('0x1d'))][(_0xb24b('0x1e'))](_0xb24b('0xcb'));}})[_0xb24b('0x21')](function(_0x2be155){_0x2025ea=_0x2be155[_0xb24b('0xaa')];if(!_0x434ab5[_0xb24b('0x4e')]['hasOwnProperty'](_0xb24b('0x55'))){_0x20cdf5[_0xb24b('0x31')]=qs[_0xb24b('0x31')](_0x434ab5[_0xb24b('0x4e')]['limit']);_0x20cdf5[_0xb24b('0x30')]=qs[_0xb24b('0x30')](_0x434ab5[_0xb24b('0x4e')][_0xb24b('0x30')]);}switch(_0x31a7b2[_0xb24b('0x3f')]){case'admin':return db[_[_0xb24b('0xa7')](_0x434ab5['query']['channel'])+_0xb24b('0xca')][_0xb24b('0x63')](_0x20cdf5);case _0xb24b('0x92'):case _0xb24b('0x85'):return _0x31a7b2[_0xb24b('0x37')+_[_0xb24b('0xa7')](_0x434ab5[_0xb24b('0x4e')][_0xb24b('0xa0')])+_0xb24b('0xb7')](_0x20cdf5);}})['then'](function(_0x3d69ca){return{'count':_0x2025ea,'rows':_0x3d69ca};})[_0xb24b('0x21')](respondWithResult(_0x3ffd32,null))['catch'](handleError(_0x3ffd32,null));};exports[_0xb24b('0xcc')]=function(_0x5c2e1d,_0x188352,_0x4f51c0){var _0x239951={};var _0x4a2cc1={};var _0x2bd655;var _0x503a1a;return db[_0xb24b('0x60')][_0xb24b('0x98')]({'where':{'id':_0x5c2e1d['params']['id']}})[_0xb24b('0x21')](handleEntityNotFound(_0x188352,null))['then'](function(_0x3e79db){if(_0x3e79db){_0x2bd655=_0x3e79db;_0x4a2cc1[_0xb24b('0x4b')]=_[_0xb24b('0x4f')](db[_0xb24b('0xb9')][_0xb24b('0x67')]);_0x4a2cc1[_0xb24b('0x4e')]=_[_0xb24b('0x4f')](_0x5c2e1d[_0xb24b('0x4e')]);_0x4a2cc1[_0xb24b('0x50')]=_[_0xb24b('0x51')](_0x4a2cc1['model'],_0x4a2cc1[_0xb24b('0x4e')]);_0x239951[_0xb24b('0x53')]=_['intersection'](_0x4a2cc1[_0xb24b('0x4b')],qs[_0xb24b('0x52')](_0x5c2e1d['query'][_0xb24b('0x52')]));_0x239951['attributes']=_0x239951['attributes'][_0xb24b('0xaa')]?_0x239951[_0xb24b('0x53')]:_0x4a2cc1[_0xb24b('0x4b')];_0x239951['order']=qs[_0xb24b('0x57')](_0x5c2e1d[_0xb24b('0x4e')][_0xb24b('0x57')]);_0x239951[_0xb24b('0x58')]=qs[_0xb24b('0x50')](_[_0xb24b('0x59')](_0x5c2e1d[_0xb24b('0x4e')],_0x4a2cc1[_0xb24b('0x50')]));if(_0x5c2e1d[_0xb24b('0x4e')][_0xb24b('0x3c')]){_0x239951[_0xb24b('0x58')]=_[_0xb24b('0x5a')](_0x239951['where'],{'$or':_['map'](_0x239951[_0xb24b('0x53')],function(_0x37163f){var _0xda96f1={};_0xda96f1[_0x37163f]={'$like':'%'+_0x5c2e1d[_0xb24b('0x4e')][_0xb24b('0x3c')]+'%'};return _0xda96f1;})});}_0x239951=_['merge']({},_0x239951,_0x5c2e1d[_0xb24b('0x5f')]);return _0x2bd655[_0xb24b('0xcc')](_0x239951);}})[_0xb24b('0x21')](function(_0x5df5cc){if(_0x5df5cc){_0x503a1a=_0x5df5cc['length'];if(!_0x5c2e1d[_0xb24b('0x4e')]['hasOwnProperty'](_0xb24b('0x55'))){_0x239951['limit']=qs[_0xb24b('0x31')](_0x5c2e1d[_0xb24b('0x4e')][_0xb24b('0x31')]);_0x239951[_0xb24b('0x30')]=qs[_0xb24b('0x30')](_0x5c2e1d[_0xb24b('0x4e')]['offset']);}return _0x2bd655[_0xb24b('0xcc')](_0x239951);}})[_0xb24b('0x21')](function(_0x4b9d54){if(_0x4b9d54){return _0x4b9d54?{'count':_0x503a1a,'rows':_0x4b9d54}:null;}})[_0xb24b('0x21')](respondWithResult(_0x188352,null))['catch'](handleError(_0x188352,null));};exports[_0xb24b('0xcd')]=function(_0x4c3b02,_0x33160a,_0x4e58e3){var _0x129627={};var _0x15d91a={};var _0x370d09;var _0x1fc1ca;return db[_0xb24b('0x60')][_0xb24b('0x98')]({'where':{'id':_0x4c3b02[_0xb24b('0x66')]['id']}})[_0xb24b('0x21')](handleEntityNotFound(_0x33160a,null))[_0xb24b('0x21')](function(_0x3d5a2b){if(_0x3d5a2b){_0x370d09=_0x3d5a2b;_0x15d91a[_0xb24b('0x4b')]=_[_0xb24b('0x4f')](db['ChatGroup']['rawAttributes']);_0x15d91a[_0xb24b('0x4e')]=_['keys'](_0x4c3b02[_0xb24b('0x4e')]);_0x15d91a[_0xb24b('0x50')]=_[_0xb24b('0x51')](_0x15d91a[_0xb24b('0x4b')],_0x15d91a[_0xb24b('0x4e')]);_0x129627[_0xb24b('0x53')]=_[_0xb24b('0x51')](_0x15d91a['model'],qs['fields'](_0x4c3b02[_0xb24b('0x4e')]['fields']));_0x129627[_0xb24b('0x53')]=_0x129627[_0xb24b('0x53')]['length']?_0x129627['attributes']:_0x15d91a[_0xb24b('0x4b')];_0x129627[_0xb24b('0x56')]=qs['sort'](_0x4c3b02[_0xb24b('0x4e')][_0xb24b('0x57')]);_0x129627['where']=qs['filters'](_[_0xb24b('0x59')](_0x4c3b02[_0xb24b('0x4e')],_0x15d91a[_0xb24b('0x50')]));if(_0x4c3b02[_0xb24b('0x4e')][_0xb24b('0x3c')]){_0x129627[_0xb24b('0x58')]=_['merge'](_0x129627[_0xb24b('0x58')],{'$or':_[_0xb24b('0x47')](_0x129627['attributes'],function(_0xe656e4){var _0x12286d={};_0x12286d[_0xe656e4]={'$like':'%'+_0x4c3b02[_0xb24b('0x4e')]['filter']+'%'};return _0x12286d;})});}_0x129627=_[_0xb24b('0x5a')]({},_0x129627,_0x4c3b02['options']);return _0x370d09[_0xb24b('0xcd')](_0x129627);}})[_0xb24b('0x21')](function(_0x305ed4){if(_0x305ed4){_0x1fc1ca=_0x305ed4[_0xb24b('0xaa')];if(!_0x4c3b02[_0xb24b('0x4e')][_0xb24b('0x54')](_0xb24b('0x55'))){_0x129627[_0xb24b('0x31')]=qs[_0xb24b('0x31')](_0x4c3b02[_0xb24b('0x4e')][_0xb24b('0x31')]);_0x129627[_0xb24b('0x30')]=qs[_0xb24b('0x30')](_0x4c3b02['query']['offset']);}return _0x370d09['getGroups'](_0x129627);}})[_0xb24b('0x21')](function(_0x1301e0){if(_0x1301e0){return _0x1301e0?{'count':_0x1fc1ca,'rows':_0x1301e0}:null;}})[_0xb24b('0x21')](respondWithResult(_0x33160a,null))[_0xb24b('0x2b')](handleError(_0x33160a,null));};exports['getRecordings']=function(_0x5519a9,_0x3bd478,_0x4aac63){var _0x3b714f={'raw':!![],'where':{}};var _0xdaae5a={};var _0x154248={'count':0x0,'rows':[]};return db[_0xb24b('0x60')]['findOne']({'where':{'id':_0x5519a9[_0xb24b('0x66')]['id']}})['then'](handleEntityNotFound(_0x3bd478,null))['then'](function(_0x5aad4d){if(_0x5aad4d){_0xdaae5a[_0xb24b('0x4b')]=_['keys'](db[_0xb24b('0xce')]['rawAttributes']);_0xdaae5a[_0xb24b('0x4e')]=_[_0xb24b('0x4f')](_0x5519a9['query']);_0xdaae5a[_0xb24b('0x50')]=_['intersection'](_0xdaae5a['model'],_0xdaae5a[_0xb24b('0x4e')]);_0x3b714f['attributes']=_[_0xb24b('0x51')](_0xdaae5a[_0xb24b('0x4b')],qs['fields'](_0x5519a9[_0xb24b('0x4e')][_0xb24b('0x52')]));_0x3b714f['attributes']=_0x3b714f[_0xb24b('0x53')][_0xb24b('0xaa')]?_0x3b714f[_0xb24b('0x53')]:_0xdaae5a['model'];if(!_0x5519a9[_0xb24b('0x4e')][_0xb24b('0x54')]('nolimit')){_0x3b714f[_0xb24b('0x31')]=qs[_0xb24b('0x31')](_0x5519a9[_0xb24b('0x4e')]['limit']);_0x3b714f['offset']=qs[_0xb24b('0x30')](_0x5519a9[_0xb24b('0x4e')]['offset']);}_0x3b714f[_0xb24b('0x56')]=qs[_0xb24b('0x57')](_0x5519a9[_0xb24b('0x4e')][_0xb24b('0x57')]);_0x3b714f['where']=qs[_0xb24b('0x50')](_[_0xb24b('0x59')](_0x5519a9[_0xb24b('0x4e')],_0xdaae5a[_0xb24b('0x50')]));_0x3b714f[_0xb24b('0x58')][_0xb24b('0xcf')]=_0x5aad4d['id'];if(_0x5519a9['query'][_0xb24b('0x3c')]){_0x3b714f[_0xb24b('0x58')]=_[_0xb24b('0x5a')](_0x3b714f[_0xb24b('0x58')],{'$or':_['map'](_0x3b714f[_0xb24b('0x53')],function(_0xa13311){var _0x68c1c3={};_0x68c1c3[_0xa13311]={'$like':'%'+_0x5519a9[_0xb24b('0x4e')]['filter']+'%'};return _0x68c1c3;})});}_0x3b714f=_[_0xb24b('0x5a')]({},_0x3b714f,_0x5519a9['options']);return db[_0xb24b('0xce')][_0xb24b('0x2f')]({'where':_0x3b714f[_0xb24b('0x58')]})[_0xb24b('0x21')](function(_0x46592b){_0x154248[_0xb24b('0x2f')]=_0x46592b;if(_0x5519a9[_0xb24b('0x4e')]['includeAll']){_0x3b714f[_0xb24b('0x62')]=[{'all':!![]}];}return db[_0xb24b('0xce')]['findAll'](_0x3b714f);})[_0xb24b('0x21')](function(_0x3ea4ee){_0x154248[_0xb24b('0x64')]=_0x3ea4ee;return _0x154248;});}})['then'](respondWithFilteredResult(_0x3bd478,_0x3b714f))['catch'](handleError(_0x3bd478,null));};exports[_0xb24b('0xd0')]=function(_0x582295,_0xc2fa98,_0x1df404){var _0x91192d={'raw':!![],'where':{}};var _0x5ba7f9={};var _0x985785={'count':0x0,'rows':[]};return db[_0xb24b('0x60')][_0xb24b('0x98')]({'where':{'id':_0x582295[_0xb24b('0x66')]['id']}})[_0xb24b('0x21')](handleEntityNotFound(_0xc2fa98,null))[_0xb24b('0x21')](function(_0x36b10a){if(_0x36b10a){_0x5ba7f9[_0xb24b('0x4b')]=_['keys'](db[_0xb24b('0xd1')]['rawAttributes']);_0x5ba7f9[_0xb24b('0x4e')]=_['keys'](_0x582295[_0xb24b('0x4e')]);_0x5ba7f9['filters']=_['intersection'](_0x5ba7f9[_0xb24b('0x4b')],_0x5ba7f9['query']);_0x91192d[_0xb24b('0x53')]=_[_0xb24b('0x51')](_0x5ba7f9[_0xb24b('0x4b')],qs[_0xb24b('0x52')](_0x582295[_0xb24b('0x4e')][_0xb24b('0x52')]));_0x91192d['attributes']=_0x91192d[_0xb24b('0x53')][_0xb24b('0xaa')]?_0x91192d['attributes']:_0x5ba7f9[_0xb24b('0x4b')];if(!_0x582295['query'][_0xb24b('0x54')](_0xb24b('0x55'))){_0x91192d[_0xb24b('0x31')]=qs[_0xb24b('0x31')](_0x582295[_0xb24b('0x4e')][_0xb24b('0x31')]);_0x91192d[_0xb24b('0x30')]=qs[_0xb24b('0x30')](_0x582295['query'][_0xb24b('0x30')]);}_0x91192d[_0xb24b('0x56')]=qs[_0xb24b('0x57')](_0x582295[_0xb24b('0x4e')]['sort']);_0x91192d[_0xb24b('0x58')]=qs['filters'](_['pick'](_0x582295[_0xb24b('0x4e')],_0x5ba7f9[_0xb24b('0x50')]));_0x91192d[_0xb24b('0x58')][_0xb24b('0xcf')]=_0x36b10a['id'];if(_0x582295[_0xb24b('0x4e')][_0xb24b('0x3c')]){_0x91192d[_0xb24b('0x58')]=_[_0xb24b('0x5a')](_0x91192d[_0xb24b('0x58')],{'$or':_[_0xb24b('0x47')](_0x91192d[_0xb24b('0x53')],function(_0x120fff){var _0x25e0be={};_0x25e0be[_0x120fff]={'$like':'%'+_0x582295[_0xb24b('0x4e')][_0xb24b('0x3c')]+'%'};return _0x25e0be;})});}_0x91192d=_[_0xb24b('0x5a')]({},_0x91192d,_0x582295[_0xb24b('0x5f')]);return db[_0xb24b('0xd1')][_0xb24b('0x2f')]({'where':_0x91192d[_0xb24b('0x58')]})[_0xb24b('0x21')](function(_0x2f4e10){_0x985785[_0xb24b('0x2f')]=_0x2f4e10;if(_0x582295[_0xb24b('0x4e')]['includeAll']){_0x91192d[_0xb24b('0x62')]=[{'all':!![]}];}return db[_0xb24b('0xd1')]['findAll'](_0x91192d);})[_0xb24b('0x21')](function(_0x5f1f2c){_0x985785[_0xb24b('0x64')]=_0x5f1f2c;return _0x985785;});}})[_0xb24b('0x21')](respondWithFilteredResult(_0xc2fa98,_0x91192d))['catch'](handleError(_0xc2fa98,null));};exports[_0xb24b('0xd2')]=function(_0x2aaf39,_0x15b09f,_0x43459b){var _0x23f591={};var _0x31ca53={};var _0x71e014;var _0x333bef;return db[_0xb24b('0x60')][_0xb24b('0x98')]({'where':{'id':_0x2aaf39[_0xb24b('0x66')]['id']}})['then'](handleEntityNotFound(_0x15b09f,null))[_0xb24b('0x21')](function(_0x265b82){if(_0x265b82){_0x71e014=_0x265b82;_0x31ca53[_0xb24b('0x4b')]=_[_0xb24b('0x4f')](db['ChatInteraction'][_0xb24b('0x67')]);_0x31ca53[_0xb24b('0x4e')]=_[_0xb24b('0x4f')](_0x2aaf39[_0xb24b('0x4e')]);_0x31ca53[_0xb24b('0x50')]=_[_0xb24b('0x51')](_0x31ca53[_0xb24b('0x4b')],_0x31ca53[_0xb24b('0x4e')]);_0x23f591[_0xb24b('0x53')]=_[_0xb24b('0x51')](_0x31ca53[_0xb24b('0x4b')],qs[_0xb24b('0x52')](_0x2aaf39[_0xb24b('0x4e')]['fields']));_0x23f591[_0xb24b('0x53')]=_0x23f591[_0xb24b('0x53')][_0xb24b('0xaa')]?_0x23f591[_0xb24b('0x53')]:_0x31ca53['model'];_0x23f591[_0xb24b('0x56')]=qs['sort'](_0x2aaf39[_0xb24b('0x4e')][_0xb24b('0x57')]);_0x23f591[_0xb24b('0x58')]=qs[_0xb24b('0x50')](_[_0xb24b('0x59')](_0x2aaf39[_0xb24b('0x4e')],_0x31ca53[_0xb24b('0x50')]));if(_0x2aaf39['query'][_0xb24b('0x3c')]){_0x23f591[_0xb24b('0x58')]=_[_0xb24b('0x5a')](_0x23f591['where'],{'$or':_[_0xb24b('0x47')](_0x23f591[_0xb24b('0x53')],function(_0x384556){var _0x3d22e6={};_0x3d22e6[_0x384556]={'$like':'%'+_0x2aaf39[_0xb24b('0x4e')][_0xb24b('0x3c')]+'%'};return _0x3d22e6;})});}_0x23f591=_[_0xb24b('0x5a')]({},_0x23f591,_0x2aaf39['options']);return _0x71e014['getChatInteractions'](_0x23f591);}})[_0xb24b('0x21')](function(_0x5b2cb3){if(_0x5b2cb3){_0x333bef=_0x5b2cb3[_0xb24b('0xaa')];if(!_0x2aaf39[_0xb24b('0x4e')][_0xb24b('0x54')](_0xb24b('0x55'))){_0x23f591[_0xb24b('0x31')]=qs[_0xb24b('0x31')](_0x2aaf39[_0xb24b('0x4e')][_0xb24b('0x31')]);_0x23f591[_0xb24b('0x30')]=qs[_0xb24b('0x30')](_0x2aaf39[_0xb24b('0x4e')][_0xb24b('0x30')]);}return _0x71e014[_0xb24b('0xd2')](_0x23f591);}})[_0xb24b('0x21')](function(_0x194093){if(_0x194093){return _0x194093?{'count':_0x333bef,'rows':_0x194093}:null;}})['then'](respondWithResult(_0x15b09f,null))[_0xb24b('0x2b')](handleError(_0x15b09f,null));};exports[_0xb24b('0xd3')]=function(_0x287f7d,_0x41f7f5,_0x9b6f99){var _0x517fa1={};var _0xec2f1e={};var _0x3f903c;var _0x19d4ff;return db[_0xb24b('0x60')][_0xb24b('0x98')]({'where':{'id':_0x287f7d['params']['id']}})['then'](handleEntityNotFound(_0x41f7f5,null))['then'](function(_0x285dc8){if(_0x285dc8){_0x3f903c=_0x285dc8;_0xec2f1e['model']=_['keys'](db['OpenchannelInteraction'][_0xb24b('0x67')]);_0xec2f1e[_0xb24b('0x4e')]=_[_0xb24b('0x4f')](_0x287f7d['query']);_0xec2f1e[_0xb24b('0x50')]=_['intersection'](_0xec2f1e[_0xb24b('0x4b')],_0xec2f1e[_0xb24b('0x4e')]);_0x517fa1[_0xb24b('0x53')]=_[_0xb24b('0x51')](_0xec2f1e['model'],qs[_0xb24b('0x52')](_0x287f7d[_0xb24b('0x4e')]['fields']));_0x517fa1[_0xb24b('0x53')]=_0x517fa1[_0xb24b('0x53')][_0xb24b('0xaa')]?_0x517fa1[_0xb24b('0x53')]:_0xec2f1e[_0xb24b('0x4b')];_0x517fa1['order']=qs['sort'](_0x287f7d[_0xb24b('0x4e')][_0xb24b('0x57')]);_0x517fa1[_0xb24b('0x58')]=qs[_0xb24b('0x50')](_[_0xb24b('0x59')](_0x287f7d[_0xb24b('0x4e')],_0xec2f1e['filters']));if(_0x287f7d[_0xb24b('0x4e')][_0xb24b('0x3c')]){_0x517fa1['where']=_[_0xb24b('0x5a')](_0x517fa1[_0xb24b('0x58')],{'$or':_['map'](_0x517fa1[_0xb24b('0x53')],function(_0x1d8e53){var _0x47a454={};_0x47a454[_0x1d8e53]={'$like':'%'+_0x287f7d[_0xb24b('0x4e')][_0xb24b('0x3c')]+'%'};return _0x47a454;})});}_0x517fa1=_[_0xb24b('0x5a')]({},_0x517fa1,_0x287f7d['options']);return _0x3f903c[_0xb24b('0xd3')](_0x517fa1);}})[_0xb24b('0x21')](function(_0x282f77){if(_0x282f77){_0x19d4ff=_0x282f77[_0xb24b('0xaa')];if(!_0x287f7d[_0xb24b('0x4e')][_0xb24b('0x54')](_0xb24b('0x55'))){_0x517fa1['limit']=qs['limit'](_0x287f7d[_0xb24b('0x4e')]['limit']);_0x517fa1[_0xb24b('0x30')]=qs[_0xb24b('0x30')](_0x287f7d['query'][_0xb24b('0x30')]);}return _0x3f903c['getOpenchannelInteractions'](_0x517fa1);}})[_0xb24b('0x21')](function(_0x28d5d3){if(_0x28d5d3){return _0x28d5d3?{'count':_0x19d4ff,'rows':_0x28d5d3}:null;}})[_0xb24b('0x21')](respondWithResult(_0x41f7f5,null))[_0xb24b('0x2b')](handleError(_0x41f7f5,null));};exports[_0xb24b('0xd4')]=function(_0x367512,_0x41e3b6,_0x59ce81){var _0x55976a={'raw':!![],'where':{}};var _0x368282={};var _0x28b80b={'count':0x0,'rows':[]};return db['User'][_0xb24b('0x98')]({'where':{'id':_0x367512[_0xb24b('0x66')]['id']}})[_0xb24b('0x21')](handleEntityNotFound(_0x41e3b6,null))[_0xb24b('0x21')](function(_0x9a764c){if(_0x9a764c){_0x368282[_0xb24b('0x4b')]=_[_0xb24b('0x4f')](db[_0xb24b('0xd5')][_0xb24b('0x67')]);_0x368282[_0xb24b('0x4e')]=_[_0xb24b('0x4f')](_0x367512['query']);_0x368282[_0xb24b('0x50')]=_[_0xb24b('0x51')](_0x368282[_0xb24b('0x4b')],_0x368282[_0xb24b('0x4e')]);_0x55976a['attributes']=_[_0xb24b('0x51')](_0x368282[_0xb24b('0x4b')],qs['fields'](_0x367512[_0xb24b('0x4e')][_0xb24b('0x52')]));_0x55976a[_0xb24b('0x53')]=_0x55976a['attributes']['length']?_0x55976a['attributes']:_0x368282[_0xb24b('0x4b')];if(!_0x367512[_0xb24b('0x4e')][_0xb24b('0x54')](_0xb24b('0x55'))){_0x55976a['limit']=qs['limit'](_0x367512['query'][_0xb24b('0x31')]);_0x55976a['offset']=qs[_0xb24b('0x30')](_0x367512[_0xb24b('0x4e')][_0xb24b('0x30')]);}_0x55976a[_0xb24b('0x56')]=qs[_0xb24b('0x57')](_0x367512[_0xb24b('0x4e')][_0xb24b('0x57')]);_0x55976a[_0xb24b('0x58')]=qs[_0xb24b('0x50')](_[_0xb24b('0x59')](_0x367512[_0xb24b('0x4e')],_0x368282['filters']));_0x55976a[_0xb24b('0x58')]['UserId']=_0x9a764c['id'];if(_0x367512[_0xb24b('0x4e')][_0xb24b('0x3c')]){_0x55976a[_0xb24b('0x58')]=_['merge'](_0x55976a[_0xb24b('0x58')],{'$or':_['map'](_0x55976a[_0xb24b('0x53')],function(_0x2cccaf){var _0x111575={};_0x111575[_0x2cccaf]={'$like':'%'+_0x367512[_0xb24b('0x4e')][_0xb24b('0x3c')]+'%'};return _0x111575;})});}_0x55976a=_[_0xb24b('0x5a')]({},_0x55976a,_0x367512['options']);return db[_0xb24b('0xd5')][_0xb24b('0x2f')]({'where':_0x55976a[_0xb24b('0x58')]})[_0xb24b('0x21')](function(_0x19db22){_0x28b80b[_0xb24b('0x2f')]=_0x19db22;if(_0x367512[_0xb24b('0x4e')][_0xb24b('0x61')]){_0x55976a[_0xb24b('0x62')]=[{'all':!![]}];}return db[_0xb24b('0xd5')][_0xb24b('0x63')](_0x55976a);})['then'](function(_0x1bd96d){_0x28b80b[_0xb24b('0x64')]=_0x1bd96d;return _0x28b80b;});}})[_0xb24b('0x21')](respondWithFilteredResult(_0x41e3b6,_0x55976a))['catch'](handleError(_0x41e3b6,null));};exports[_0xb24b('0xd6')]=function(_0x5dc12d,_0x1e2586,_0x45cbcd){var _0x2d88ac={};var _0x30fd63={};var _0x4e1b3d;var _0x327e28;return db['User'][_0xb24b('0x98')]({'where':{'id':_0x5dc12d[_0xb24b('0x66')]['id']}})['then'](handleEntityNotFound(_0x1e2586,null))['then'](function(_0x58525b){if(_0x58525b){_0x4e1b3d=_0x58525b;_0x30fd63[_0xb24b('0x4b')]=_[_0xb24b('0x4f')](db[_0xb24b('0xd7')][_0xb24b('0x67')]);_0x30fd63[_0xb24b('0x4e')]=_[_0xb24b('0x4f')](_0x5dc12d[_0xb24b('0x4e')]);_0x30fd63[_0xb24b('0x50')]=_['intersection'](_0x30fd63[_0xb24b('0x4b')],_0x30fd63['query']);_0x2d88ac[_0xb24b('0x53')]=_[_0xb24b('0x51')](_0x30fd63[_0xb24b('0x4b')],qs[_0xb24b('0x52')](_0x5dc12d[_0xb24b('0x4e')][_0xb24b('0x52')]));_0x2d88ac['attributes']=_0x2d88ac[_0xb24b('0x53')][_0xb24b('0xaa')]?_0x2d88ac[_0xb24b('0x53')]:_0x30fd63[_0xb24b('0x4b')];_0x2d88ac['order']=qs[_0xb24b('0x57')](_0x5dc12d[_0xb24b('0x4e')][_0xb24b('0x57')]);_0x2d88ac['where']=qs['filters'](_[_0xb24b('0x59')](_0x5dc12d[_0xb24b('0x4e')],_0x30fd63['filters']));if(_0x5dc12d['query']['filter']){_0x2d88ac[_0xb24b('0x58')]=_[_0xb24b('0x5a')](_0x2d88ac[_0xb24b('0x58')],{'$or':_['map'](_0x2d88ac[_0xb24b('0x53')],function(_0x30ef35){var _0x11e873={};_0x11e873[_0x30ef35]={'$like':'%'+_0x5dc12d[_0xb24b('0x4e')][_0xb24b('0x3c')]+'%'};return _0x11e873;})});}_0x2d88ac=_[_0xb24b('0x5a')]({},_0x2d88ac,_0x5dc12d[_0xb24b('0x5f')]);return _0x4e1b3d[_0xb24b('0xd6')](_0x2d88ac);}})[_0xb24b('0x21')](function(_0x21a017){if(_0x21a017){_0x327e28=_0x21a017['length'];if(!_0x5dc12d[_0xb24b('0x4e')][_0xb24b('0x54')](_0xb24b('0x55'))){_0x2d88ac[_0xb24b('0x31')]=qs[_0xb24b('0x31')](_0x5dc12d[_0xb24b('0x4e')]['limit']);_0x2d88ac[_0xb24b('0x30')]=qs[_0xb24b('0x30')](_0x5dc12d['query'][_0xb24b('0x30')]);}return _0x4e1b3d[_0xb24b('0xd6')](_0x2d88ac);}})[_0xb24b('0x21')](function(_0xb6b445){if(_0xb6b445){return _0xb6b445?{'count':_0x327e28,'rows':_0xb6b445}:null;}})[_0xb24b('0x21')](respondWithResult(_0x1e2586,null))['catch'](handleError(_0x1e2586,null));};exports['getFaxInteractions']=function(_0x512999,_0x452414,_0x127946){var _0x39c6f5={};var _0x2573c2={};var _0x59165e;var _0x28ffd5;return db[_0xb24b('0x60')]['findOne']({'where':{'id':_0x512999[_0xb24b('0x66')]['id']}})[_0xb24b('0x21')](handleEntityNotFound(_0x452414,null))['then'](function(_0x2fec11){if(_0x2fec11){_0x59165e=_0x2fec11;_0x2573c2['model']=_[_0xb24b('0x4f')](db['FaxInteraction'][_0xb24b('0x67')]);_0x2573c2[_0xb24b('0x4e')]=_[_0xb24b('0x4f')](_0x512999[_0xb24b('0x4e')]);_0x2573c2['filters']=_[_0xb24b('0x51')](_0x2573c2[_0xb24b('0x4b')],_0x2573c2[_0xb24b('0x4e')]);_0x39c6f5['attributes']=_[_0xb24b('0x51')](_0x2573c2[_0xb24b('0x4b')],qs['fields'](_0x512999[_0xb24b('0x4e')][_0xb24b('0x52')]));_0x39c6f5[_0xb24b('0x53')]=_0x39c6f5[_0xb24b('0x53')][_0xb24b('0xaa')]?_0x39c6f5[_0xb24b('0x53')]:_0x2573c2[_0xb24b('0x4b')];_0x39c6f5[_0xb24b('0x56')]=qs[_0xb24b('0x57')](_0x512999['query'][_0xb24b('0x57')]);_0x39c6f5['where']=qs[_0xb24b('0x50')](_[_0xb24b('0x59')](_0x512999[_0xb24b('0x4e')],_0x2573c2['filters']));if(_0x512999['query'][_0xb24b('0x3c')]){_0x39c6f5['where']=_['merge'](_0x39c6f5[_0xb24b('0x58')],{'$or':_['map'](_0x39c6f5[_0xb24b('0x53')],function(_0x3ff649){var _0x30c753={};_0x30c753[_0x3ff649]={'$like':'%'+_0x512999[_0xb24b('0x4e')]['filter']+'%'};return _0x30c753;})});}_0x39c6f5=_[_0xb24b('0x5a')]({},_0x39c6f5,_0x512999[_0xb24b('0x5f')]);return _0x59165e[_0xb24b('0xd8')](_0x39c6f5);}})[_0xb24b('0x21')](function(_0x45abad){if(_0x45abad){_0x28ffd5=_0x45abad[_0xb24b('0xaa')];if(!_0x512999[_0xb24b('0x4e')][_0xb24b('0x54')](_0xb24b('0x55'))){_0x39c6f5[_0xb24b('0x31')]=qs[_0xb24b('0x31')](_0x512999['query'][_0xb24b('0x31')]);_0x39c6f5['offset']=qs['offset'](_0x512999[_0xb24b('0x4e')]['offset']);}return _0x59165e[_0xb24b('0xd8')](_0x39c6f5);}})['then'](function(_0x1badb2){if(_0x1badb2){return _0x1badb2?{'count':_0x28ffd5,'rows':_0x1badb2}:null;}})[_0xb24b('0x21')](respondWithResult(_0x452414,null))[_0xb24b('0x2b')](handleError(_0x452414,null));};exports['login']=function(_0x200129,_0x59d28b,_0x16eef3){var _0x267b98;var _0x3e56d4;var _0x10ce86;var _0xe504d8=!_[_0xb24b('0x74')](_0x200129[_0xb24b('0x66')]['id'])?_0x200129[_0xb24b('0x66')]['id']:!_[_0xb24b('0x74')](_0x200129['user']['id'])?_0x200129[_0xb24b('0x92')]['id']:null;return db[_0xb24b('0x60')][_0xb24b('0x40')]({'where':{'id':_0xe504d8,'role':{'$or':[_0xb24b('0x6f'),_0xb24b('0x92'),'agent']}},'attributes':['id',_0xb24b('0x41'),_0xb24b('0xd9'),_0xb24b('0xda'),'role',_0xb24b('0x79'),_0xb24b('0xa1')]})[_0xb24b('0x21')](function(_0x37cbad){if(_0x37cbad){if(_0x37cbad[_0xb24b('0x3f')]===_0xb24b('0x85')){_0x267b98=_0x37cbad;if(_0x200129[_0xb24b('0x69')][_0xb24b('0xa3')]){_0x10ce86=util[_0xb24b('0x76')](_0xb24b('0xdb'),_0x267b98[_0x200129[_0xb24b('0x69')][_0xb24b('0xa3')]]);}else if(_0x200129[_0xb24b('0x69')][_0xb24b('0xdc')]){_0x10ce86=util[_0xb24b('0x76')](_0xb24b('0xb3'),_0x200129[_0xb24b('0x69')]['intrf']);}else{_0x10ce86=util[_0xb24b('0x76')](_0xb24b('0xb3'),_0x267b98['name']);}socket['to'](util[_0xb24b('0x76')](_0xb24b('0xdd'),_0x267b98[_0xb24b('0x41')]))['emit'](_0xb24b('0xde'),{'ip':_0x200129[_0xb24b('0xdf')][_0xb24b('0xe0')]||_0x200129[_0xb24b('0xe1')][_0xb24b('0xe2')]||_0x200129[_0xb24b('0xe3')][_0xb24b('0xe2')]||_0x200129[_0xb24b('0xe1')][_0xb24b('0xe3')][_0xb24b('0xe2')]});return db[_0xb24b('0xb9')]['destroy']({'where':{'membername':_0x267b98['name']},'individualHooks':!![]});}}else{throw new db[(_0xb24b('0x1d'))][(_0xb24b('0x1e'))](_0xb24b('0xe4'));}})[_0xb24b('0x21')](function(){if(_0x267b98){return _0x267b98['getVoiceQueues']({'raw':!![]});}})['then'](function(_0x34c522){if(_0x267b98){var _0x426625=[];if(_0x34c522){_0x3e56d4=_0x34c522;if(_0x3e56d4[_0xb24b('0xaa')]){for(var _0x3e053e=0x0;_0x3e053e<_0x3e56d4['length'];_0x3e053e++){_0x426625['push']({'membername':_0x267b98[_0xb24b('0x41')],'UserId':_0x267b98['id'],'queue_name':_0x3e56d4[_0x3e053e][_0xb24b('0x41')],'VoiceQueueId':_0x3e56d4[_0x3e053e]['id'],'interface':_0x10ce86,'paused':_0x267b98[_0xb24b('0xa1')]||![],'penalty':_0x3e56d4[_0x3e053e]['UserVoiceQueue.penalty']||0x0});}return BPromise[_0xb24b('0xb4')](_0x426625,function(_0x5d321f){return db[_0xb24b('0xb9')][_0xb24b('0xb5')](_0x5d321f);});}}}})['then'](function(){if(_0x267b98){return db[_0xb24b('0xe5')][_0xb24b('0x63')]({'where':{'membername':_0x267b98['name'],'exitAt':null}});}})[_0xb24b('0x21')](function(_0x1b8395){if(_0x267b98){var _0x24454b=[];_0x1b8395[_0xb24b('0xe6')](function(_0x1a76ad){_0x24454b[_0xb24b('0xb2')](_0x1a76ad[_0xb24b('0x36')]({'exitAt':moment()[_0xb24b('0x76')](_0xb24b('0xe7'))}));});return BPromise[_0xb24b('0xe8')](_0x24454b);}})[_0xb24b('0x21')](function(){if(_0x267b98){var _0x286b65=[];var _0x4b47b1=[];var _0xa1549e=utils['getChannels']();var _0x5beac2={'membername':_0x267b98['name'],'interface':_0x10ce86,'enterAt':moment()[_0xb24b('0x76')]('YYYY-MM-DD\x20HH:mm:ss'),'role':_0x267b98[_0xb24b('0x3f')],'internal':_0x267b98[_0xb24b('0x79')]};_0xa1549e[_0xb24b('0xe6')](function(_0x228ec6){_0x286b65['push'](_[_0xb24b('0x5a')]({'channel':_0x228ec6,'type':_0xb24b('0xe9'),'data1':_0x200129[_0xb24b('0x69')][_0xb24b('0xea')],'data2':_0x10ce86},_0x5beac2));if(_0x267b98[_0xb24b('0xa1')]){_0x4b47b1[_0xb24b('0xb2')](_[_0xb24b('0x5a')]({'channel':_0x228ec6,'type':_0xb24b('0xeb'),'data1':'LOGININPAUSE'},_0x5beac2));}});return db[_0xb24b('0xe5')][_0xb24b('0x68')](_0x286b65['concat'](_0x4b47b1),{'individualHooks':!![]});}})[_0xb24b('0x21')](function(){if(_0x267b98){return _0x267b98[_0xb24b('0x36')]({'online':!![],'lastLoginAt':moment()[_0xb24b('0x76')](_0xb24b('0xe7')),'voicePause':_0x267b98[_0xb24b('0xa1')]||![],'mailPause':_0x267b98['loginInPause']||![],'chatPause':_0x267b98['loginInPause']||![],'faxPause':_0x267b98[_0xb24b('0xa1')]||![],'smsPause':_0x267b98[_0xb24b('0xa1')]||![],'openchannelPause':_0x267b98[_0xb24b('0xa1')]||![],'pauseType':_0x267b98[_0xb24b('0xa1')]?_0xb24b('0xec'):null,'interface':_0x10ce86,'lastPauseAt':moment()[_0xb24b('0x76')]('YYYY-MM-DD\x20HH:mm:ss')});}})[_0xb24b('0x21')](function(_0x48390e){if(_0x200129['isMiddleware']){return _0x16eef3();}else{return BPromise[_0xb24b('0xed')](_0x48390e)['then'](respondWithResult(_0x59d28b,null));}})[_0xb24b('0x2b')](handleError(_0x59d28b,null));};exports[_0xb24b('0xee')]=function(_0x4f3a8b,_0x16359b,_0x4a3fe5){var _0x56cf78;return db[_0xb24b('0x60')][_0xb24b('0x40')]({'where':{'id':_0x4f3a8b[_0xb24b('0x66')]['id'],'role':_0xb24b('0x85')},'attributes':['id','name',_0xb24b('0x3f')]})[_0xb24b('0x21')](handleEntityNotFound(_0x16359b,null))[_0xb24b('0x21')](function(_0x343003){if(_0x343003){_0x56cf78=_0x343003;return db[_0xb24b('0xb9')][_0xb24b('0x43')]({'where':{'membername':_0x56cf78[_0xb24b('0x41')]},'individualHooks':!![]});}})['then'](function(){return db[_0xb24b('0xe5')][_0xb24b('0x63')]({'where':{'membername':_0x56cf78[_0xb24b('0x41')],'exitAt':null}});})[_0xb24b('0x21')](function(_0x17b3c1){var _0x2ea0a0=[];_0x17b3c1[_0xb24b('0xe6')](function(_0x773416){_0x2ea0a0[_0xb24b('0xb2')](_0x773416['update']({'exitAt':moment()[_0xb24b('0x76')](_0xb24b('0xe7'))}));});return BPromise[_0xb24b('0xe8')](_0x2ea0a0);})[_0xb24b('0x21')](function(){return _0x56cf78[_0xb24b('0x36')]({'online':![],'lastLoginAt':null,'voicePause':![],'mailPause':![],'chatPause':![],'faxPause':![],'smsPause':![],'openchannelPause':![],'interface':null});})[_0xb24b('0x21')](respondWithResult(_0x16359b,null))['catch'](handleError(_0x16359b,null));};exports['pause']=function(_0x4d7501,_0x571c75,_0x29094a){var _0xb503b8;return db[_0xb24b('0xb9')][_0xb24b('0x36')]({'paused':0x1},{'where':{'UserId':_0x4d7501[_0xb24b('0x66')]['id']},'individualHooks':!![]})[_0xb24b('0x21')](function(){return db['User'][_0xb24b('0x40')]({'where':{'id':_0x4d7501[_0xb24b('0x66')]['id'],'role':'agent'},'attributes':['id',_0xb24b('0x41'),_0xb24b('0x3f'),_0xb24b('0x79'),'interface']});})['then'](handleEntityNotFound(_0x571c75,null))[_0xb24b('0x21')](function(_0x47a66d){if(_0x47a66d){_0xb503b8=_0x47a66d;return respondWithRpcPromise(_0xb24b('0xef'),_0xb24b('0xf0'),{'id':_0xb503b8['id'],'name':_0xb503b8['name'],'pause':!![]});}})['then'](function(){if(_0xb503b8){return db[_0xb24b('0xe5')][_0xb24b('0x63')]({'where':{'membername':_0xb503b8[_0xb24b('0x41')],'type':_0xb24b('0xeb'),'exitAt':null}});}})[_0xb24b('0x21')](function(_0x26f4f2){if(_0x26f4f2[_0xb24b('0xaa')]){var _0x314228=moment()[_0xb24b('0x76')](_0xb24b('0xe7'));for(var _0x3d9287=0x0,_0x213b9b=_0x26f4f2[_0xb24b('0xaa')];_0x3d9287<_0x213b9b;_0x3d9287++){_0x26f4f2[_0x3d9287]['updateAttributes']({'exitAt':_0x314228});}}})[_0xb24b('0x21')](function(){var _0x3c3f06=[];var _0x24e850=utils[_0xb24b('0xf1')]();_0x24e850[_0xb24b('0xe6')](function(_0x4f2bc5){_0x3c3f06[_0xb24b('0xb2')]({'channel':_0x4f2bc5,'membername':_0xb503b8[_0xb24b('0x41')],'interface':_['isNil'](_0xb503b8['interface'])?util[_0xb24b('0x76')]('SIP/%s',_0xb503b8[_0xb24b('0x41')]):_0xb503b8[_0xb24b('0xa3')],'type':_0xb24b('0xeb'),'enterAt':moment()[_0xb24b('0x76')]('YYYY-MM-DD\x20HH:mm:ss'),'data1':_0x4d7501[_0xb24b('0x69')][_0xb24b('0x49')]||'DEFAULT\x20PAUSE','role':_0xb503b8[_0xb24b('0x3f')],'internal':_0xb503b8[_0xb24b('0x79')]});});return db[_0xb24b('0xe5')][_0xb24b('0x68')](_0x3c3f06,{'individualHooks':!![]});})[_0xb24b('0x21')](function(){return _0xb503b8['update']({'voicePause':!![],'mailPause':!![],'chatPause':!![],'faxPause':!![],'smsPause':!![],'openchannelPause':!![],'pauseType':_0x4d7501['body']['type']||_0xb24b('0xf2'),'lastPauseAt':moment()[_0xb24b('0x76')](_0xb24b('0xe7'))});})[_0xb24b('0x21')](respondWithResult(_0x571c75,null))[_0xb24b('0x2b')](handleError(_0x571c75,null));};exports[_0xb24b('0xf3')]=function(_0x4f0a39,_0x1d23b7,_0x13acfe){var _0x21fce1;return db[_0xb24b('0x60')][_0xb24b('0x40')]({'where':{'id':_0x4f0a39['params']['id']},'attributes':['id',_0xb24b('0x41'),'role',_0xb24b('0xa2'),'mailPause','chatPause','faxPause',_0xb24b('0xf4'),_0xb24b('0xf5'),_0xb24b('0xf6'),_0xb24b('0xf7')]})['then'](handleEntityNotFound(_0x1d23b7,null))[_0xb24b('0x21')](function(_0x1cd997){if(_0x1cd997){_0x21fce1=_0x1cd997;if(_0x4f0a39[_0xb24b('0x69')][_0xb24b('0xa0')]&&!utils[_0xb24b('0xa4')](_0x4f0a39['body'][_0xb24b('0xa0')])){throw new db[(_0xb24b('0x1d'))][(_0xb24b('0x1e'))](_0xb24b('0xa5'));}switch(_0x4f0a39[_0xb24b('0x69')][_0xb24b('0xa0')]){case'voice':return respondWithRpcPromise(_0xb24b('0xef'),_0xb24b('0xf3'),{'id':_0x21fce1['id'],'name':_0x21fce1[_0xb24b('0x41')],'pause':![]})[_0xb24b('0x21')](function(){return db[_0xb24b('0xb9')][_0xb24b('0x36')]({'paused':0x0},{'where':{'UserId':_0x21fce1['id']},'individualHooks':!![]});})[_0xb24b('0x21')](function(){return db[_0xb24b('0xe5')][_0xb24b('0x40')]({'where':{'channel':_0x4f0a39[_0xb24b('0x69')][_0xb24b('0xa0')],'membername':_0x21fce1[_0xb24b('0x41')],'type':_0xb24b('0xeb'),'exitAt':null}});})['then'](function(_0x19ae0e){if(_0x19ae0e){return _0x19ae0e['update']({'exitAt':moment()[_0xb24b('0x76')]('YYYY-MM-DD\x20HH:mm:ss'),'data2':_0xb24b('0xf8')},{'individualHooks':!![]});}return null;})['then'](function(){return _0x21fce1[_0xb24b('0x36')]({'voicePause':![]});});case _0xb24b('0xf9'):case'chat':case _0xb24b('0xfa'):case'sms':case _0xb24b('0xfb'):return db[_0xb24b('0xe5')][_0xb24b('0x40')]({'where':{'channel':_0x4f0a39[_0xb24b('0x69')]['channel'],'membername':_0x21fce1[_0xb24b('0x41')],'type':_0xb24b('0xeb'),'exitAt':null}})['then'](function(_0x2296d1){if(_0x2296d1){return _0x2296d1[_0xb24b('0x36')]({'exitAt':moment()[_0xb24b('0x76')](_0xb24b('0xe7')),'data2':'manual'},{'individualHooks':!![]});}return null;})['then'](function(){var _0x33560b={};_['set'](_0x33560b,util[_0xb24b('0x76')](_0xb24b('0xfc'),_0x4f0a39[_0xb24b('0x69')][_0xb24b('0xa0')],'Pause'),![]);return _0x21fce1['update'](_0x33560b);});default:return respondWithRpcPromise('QueuePause',_0xb24b('0xf3'),{'id':_0x21fce1['id'],'name':_0x21fce1[_0xb24b('0x41')],'pause':![]})[_0xb24b('0x21')](function(){return db[_0xb24b('0xb9')][_0xb24b('0x36')]({'paused':0x0},{'where':{'UserId':_0x21fce1['id']}});})[_0xb24b('0x21')](function(){return db[_0xb24b('0xe5')]['findAll']({'where':{'membername':_0x21fce1[_0xb24b('0x41')],'type':_0xb24b('0xeb'),'exitAt':null}});})['then'](function(_0x319709){var _0x3e005b=[];_0x319709[_0xb24b('0xe6')](function(_0x3df524){_0x3e005b[_0xb24b('0xb2')](_0x3df524[_0xb24b('0x36')]({'exitAt':moment()[_0xb24b('0x76')](_0xb24b('0xe7')),'data2':_0xb24b('0xf8')}));});return BPromise[_0xb24b('0xe8')](_0x3e005b);})[_0xb24b('0x21')](function(){return _0x21fce1[_0xb24b('0x36')]({'voicePause':![],'mailPause':![],'chatPause':![],'faxPause':![],'smsPause':![],'openchannelPause':![]});});}}})[_0xb24b('0x21')](respondWithResult(_0x1d23b7,null))[_0xb24b('0x2b')](handleError(_0x1d23b7,null));};exports[_0xb24b('0xfd')]=function(_0x3ac304,_0x3d847d,_0x176cea){var _0x1bc7d2={};var _0x6419bf={};var _0x5b965f;var _0x33024f;return db[_0xb24b('0x60')][_0xb24b('0x98')]({'where':{'id':_0x3ac304[_0xb24b('0x66')]['id']}})[_0xb24b('0x21')](handleEntityNotFound(_0x3d847d,null))[_0xb24b('0x21')](function(_0x448630){if(_0x448630){_0x5b965f=_0x448630;_0x6419bf[_0xb24b('0x4b')]=_[_0xb24b('0x4f')](db[_0xb24b('0xfe')][_0xb24b('0x67')]);_0x6419bf[_0xb24b('0x4e')]=_[_0xb24b('0x4f')](_0x3ac304[_0xb24b('0x4e')]);_0x6419bf[_0xb24b('0x50')]=_[_0xb24b('0x51')](_0x6419bf[_0xb24b('0x4b')],_0x6419bf[_0xb24b('0x4e')]);_0x1bc7d2[_0xb24b('0x53')]=_['intersection'](_0x6419bf['model'],qs[_0xb24b('0x52')](_0x3ac304[_0xb24b('0x4e')][_0xb24b('0x52')]));_0x1bc7d2['attributes']=_0x1bc7d2[_0xb24b('0x53')][_0xb24b('0xaa')]?_0x1bc7d2[_0xb24b('0x53')]:_0x6419bf[_0xb24b('0x4b')];_0x1bc7d2['order']=qs[_0xb24b('0x57')](_0x3ac304[_0xb24b('0x4e')][_0xb24b('0x57')]);_0x1bc7d2[_0xb24b('0x58')]=qs[_0xb24b('0x50')](_[_0xb24b('0x59')](_0x3ac304['query'],_0x6419bf[_0xb24b('0x50')]));if(_0x3ac304[_0xb24b('0x4e')][_0xb24b('0x3c')]){_0x1bc7d2[_0xb24b('0x58')]=_[_0xb24b('0x5a')](_0x1bc7d2[_0xb24b('0x58')],{'$or':_[_0xb24b('0x47')](_0x1bc7d2[_0xb24b('0x53')],function(_0x10f823){var _0x335d9f={};_0x335d9f[_0x10f823]={'$like':'%'+_0x3ac304[_0xb24b('0x4e')][_0xb24b('0x3c')]+'%'};return _0x335d9f;})});}_0x1bc7d2=_[_0xb24b('0x5a')]({},_0x1bc7d2,_0x3ac304[_0xb24b('0x5f')]);return _0x5b965f[_0xb24b('0xfd')](_0x1bc7d2);}})['then'](function(_0x3447f8){if(_0x3447f8){_0x33024f=_0x3447f8['length'];if(!_0x3ac304[_0xb24b('0x4e')][_0xb24b('0x54')](_0xb24b('0x55'))){_0x1bc7d2[_0xb24b('0x31')]=qs['limit'](_0x3ac304['query'][_0xb24b('0x31')]);_0x1bc7d2[_0xb24b('0x30')]=qs[_0xb24b('0x30')](_0x3ac304[_0xb24b('0x4e')][_0xb24b('0x30')]);}return _0x5b965f['getTeams'](_0x1bc7d2);}})['then'](function(_0x3899b0){if(_0x3899b0){return _0x3899b0?{'count':_0x33024f,'rows':_0x3899b0}:null;}})[_0xb24b('0x21')](respondWithResult(_0x3d847d,null))[_0xb24b('0x2b')](handleError(_0x3d847d,null));};exports[_0xb24b('0xff')]=function(_0x45e537,_0x4f40d0){return db[_0xb24b('0x60')][_0xb24b('0x40')]({'where':{'id':_0x45e537['params']['id']}})[_0xb24b('0x21')](handleEntityNotFound(_0x4f40d0,null))[_0xb24b('0x21')](function(_0x2ecea1){if(_0x2ecea1){var _0x589338=_0x2ecea1[_0xb24b('0x37')]({'plain':!![]});return _0x2ecea1[_0xb24b('0xff')](_0x45e537[_0xb24b('0x69')][_0xb24b('0x6c')],_[_0xb24b('0x6d')](_0x45e537[_0xb24b('0x69')],[_0xb24b('0x6c'),'id'])||{})[_0xb24b('0x21')](function(){for(var _0x1038a7=0x0;_0x1038a7<_0x45e537[_0xb24b('0x69')][_0xb24b('0x6c')]['length'];_0x1038a7++){var _0x101bfc=[];db['Team'][_0xb24b('0x98')]({'where':{'id':_0x45e537[_0xb24b('0x69')][_0xb24b('0x6c')][_0x1038a7]}})['then'](function(_0x53297f){_0x101bfc[_0xb24b('0xb2')](_0x53297f['getVoiceQueues']()[_0xb24b('0x21')](function(_0x5997bd){for(var _0x435e3e=0x0;_0x435e3e<_0x5997bd['length'];_0x435e3e++){_0x5997bd[_0x435e3e][_0xb24b('0x100')]('channel','Voice');}return _0x5997bd;}));_0x101bfc[_0xb24b('0xb2')](_0x53297f[_0xb24b('0x101')]()[_0xb24b('0x21')](function(_0x19a571){for(var _0x38df3c=0x0;_0x38df3c<_0x19a571['length'];_0x38df3c++){_0x19a571[_0x38df3c]['setDataValue'](_0xb24b('0xa0'),_0xb24b('0x102'));}return _0x19a571;}));_0x101bfc[_0xb24b('0xb2')](_0x53297f[_0xb24b('0x103')]()['then'](function(_0x501160){for(var _0x422a3f=0x0;_0x422a3f<_0x501160[_0xb24b('0xaa')];_0x422a3f++){_0x501160[_0x422a3f][_0xb24b('0x100')](_0xb24b('0xa0'),_0xb24b('0x104'));}return _0x501160;}));_0x101bfc[_0xb24b('0xb2')](_0x53297f[_0xb24b('0x105')]()['then'](function(_0x3136bb){for(var _0x484a33=0x0;_0x484a33<_0x3136bb[_0xb24b('0xaa')];_0x484a33++){_0x3136bb[_0x484a33][_0xb24b('0x100')](_0xb24b('0xa0'),_0xb24b('0x106'));}return _0x3136bb;}));_0x101bfc[_0xb24b('0xb2')](_0x53297f[_0xb24b('0x107')]()[_0xb24b('0x21')](function(_0x3d7eb5){for(var _0x40679c=0x0;_0x40679c<_0x3d7eb5[_0xb24b('0xaa')];_0x40679c++){_0x3d7eb5[_0x40679c]['setDataValue'](_0xb24b('0xa0'),'Fax');}return _0x3d7eb5;}));_0x101bfc[_0xb24b('0xb2')](_0x53297f[_0xb24b('0x108')]()['then'](function(_0x59b3f2){for(var _0x5f38d4=0x0;_0x5f38d4<_0x59b3f2[_0xb24b('0xaa')];_0x5f38d4++){_0x59b3f2[_0x5f38d4][_0xb24b('0x100')]('channel',_0xb24b('0x109'));}return _0x59b3f2;}));return BPromise[_0xb24b('0xe8')](_0x101bfc);})['then'](function(_0x2b4d0d){var _0x46259a=_[_0xb24b('0x10a')](_0x2b4d0d);_0x101bfc=[];return db[_0xb24b('0x5c')][_0xb24b('0x10b')](function(_0x5292d3){for(var _0x16d1bb=0x0;_0x16d1bb<_0x46259a['length'];_0x16d1bb++){_0x101bfc['push'](_0x46259a[_0x16d1bb]['addAgent'](_0x589338['id']),{'transaction':_0x5292d3});}return BPromise['all'](_0x101bfc)['then'](function(){if(_0x589338[_0xb24b('0xb1')]){return BPromise[_0xb24b('0xb4')](_[_0xb24b('0x3c')](_0x46259a,function(_0x4b5317){return _0x4b5317[_0xb24b('0x10c')]('channel')==='Voice';}),function(_0x3274e5){return db[_0xb24b('0xb9')]['upsert']({'membername':_0x589338[_0xb24b('0x41')],'UserId':_0x589338['id'],'queue_name':_0x3274e5[_0xb24b('0x41')],'VoiceQueueId':_0x3274e5['id'],'interface':_[_0xb24b('0x74')](_0x589338[_0xb24b('0xa3')])?util['format'](_0xb24b('0xb3'),_0x589338[_0xb24b('0x41')]):_0x589338[_0xb24b('0xa3')],'paused':_0x589338[_0xb24b('0xa2')]||![],'penalty':_0x589338[_0xb24b('0xa8')]},{'transaction':_0x5292d3});});}else{return;}})[_0xb24b('0x21')](function(){for(var _0x14532a=0x0;_0x14532a<_0x46259a[_0xb24b('0xaa')];_0x14532a++){var _0x4fdf4e=_0x46259a[_0x14532a]['getDataValue'](_0xb24b('0xa0'));var _0x406b46=_0x4fdf4e+_0xb24b('0xab');socket[_0xb24b('0xac')](_0xb24b('0x92')+_0x4fdf4e+_0xb24b('0xae'),{'UserId':_0x589338['id'],['queueField']:_0x46259a[_0x14532a]['id']});}});});});}});}})[_0xb24b('0x21')](respondWithStatusCode(_0x4f40d0,null))[_0xb24b('0x2b')](handleError(_0x4f40d0,null));};exports[_0xb24b('0x10d')]=function(_0x137bf5,_0x32ef1a){return db[_0xb24b('0x60')][_0xb24b('0x98')]({'where':{'id':_0x137bf5[_0xb24b('0x66')]['id']}})[_0xb24b('0x21')](handleEntityNotFound(_0x32ef1a,null))['then'](function(_0xc89e8){if(_0xc89e8){var _0x28d5ca=_0xc89e8[_0xb24b('0x37')]({'plain':!![]});var _0x4d827b=_0x137bf5[_0xb24b('0x4e')][_0xb24b('0x6c')];return _0xc89e8[_0xb24b('0x10d')](_0x4d827b)[_0xb24b('0x21')](function(){for(var _0x5cd84b=0x0;_0x5cd84b<_0x4d827b[_0xb24b('0xaa')];_0x5cd84b++){var _0x4bf5bd=[];db[_0xb24b('0xfe')][_0xb24b('0x98')]({'where':{'id':_0x4d827b[_0x5cd84b]}})[_0xb24b('0x21')](function(_0x2bb174){_0x4bf5bd[_0xb24b('0xb2')](_0x2bb174[_0xb24b('0x10e')]()['then'](function(_0x2f1410){for(var _0x5b9e99=0x0;_0x5b9e99<_0x2f1410['length'];_0x5b9e99++){_0x2f1410[_0x5b9e99]['setDataValue'](_0xb24b('0xa0'),_0xb24b('0x10f'));}return _0x2f1410;}));_0x4bf5bd['push'](_0x2bb174[_0xb24b('0x101')]()[_0xb24b('0x21')](function(_0x4f3b33){for(var _0x2ce853=0x0;_0x2ce853<_0x4f3b33[_0xb24b('0xaa')];_0x2ce853++){_0x4f3b33[_0x2ce853][_0xb24b('0x100')](_0xb24b('0xa0'),_0xb24b('0x102'));}return _0x4f3b33;}));_0x4bf5bd[_0xb24b('0xb2')](_0x2bb174[_0xb24b('0x103')]()['then'](function(_0x1f7dbe){for(var _0x5e7b10=0x0;_0x5e7b10<_0x1f7dbe[_0xb24b('0xaa')];_0x5e7b10++){_0x1f7dbe[_0x5e7b10]['setDataValue'](_0xb24b('0xa0'),_0xb24b('0x104'));}return _0x1f7dbe;}));_0x4bf5bd[_0xb24b('0xb2')](_0x2bb174[_0xb24b('0x105')]()['then'](function(_0x11b7ce){for(var _0x465eae=0x0;_0x465eae<_0x11b7ce['length'];_0x465eae++){_0x11b7ce[_0x465eae][_0xb24b('0x100')](_0xb24b('0xa0'),_0xb24b('0x106'));}return _0x11b7ce;}));_0x4bf5bd[_0xb24b('0xb2')](_0x2bb174['getFaxQueues']()[_0xb24b('0x21')](function(_0x439d61){for(var _0x50da94=0x0;_0x50da94<_0x439d61[_0xb24b('0xaa')];_0x50da94++){_0x439d61[_0x50da94][_0xb24b('0x100')]('channel',_0xb24b('0x110'));}return _0x439d61;}));_0x4bf5bd['push'](_0x2bb174[_0xb24b('0x108')]()['then'](function(_0x39af51){for(var _0x131db=0x0;_0x131db<_0x39af51[_0xb24b('0xaa')];_0x131db++){_0x39af51[_0x131db]['setDataValue'](_0xb24b('0xa0'),'Openchannel');}return _0x39af51;}));return BPromise[_0xb24b('0xe8')](_0x4bf5bd);})['then'](function(_0x40f8cb){var _0x404550=_[_0xb24b('0x10a')](_0x40f8cb);_0x4bf5bd=[];return db['sequelize'][_0xb24b('0x10b')](function(_0x13ae2b){for(var _0x315a57=0x0;_0x315a57<_0x404550[_0xb24b('0xaa')];_0x315a57++){_0x4bf5bd['push'](_0x404550[_0x315a57][_0xb24b('0x111')](_0x28d5ca['id']),{'transaction':_0x13ae2b});}return BPromise[_0xb24b('0xe8')](_0x4bf5bd)['then'](function(){if(_0x28d5ca['online']){return BPromise['each'](_[_0xb24b('0x3c')](_0x404550,function(_0x43932c){return _0x43932c[_0xb24b('0x10c')](_0xb24b('0xa0'))===_0xb24b('0x10f');}),function(_0x5d2359){return db[_0xb24b('0xb9')][_0xb24b('0x43')]({'where':{'VoiceQueueId':_0x5d2359['id'],'UserId':_0x28d5ca['id']},'transaction':_0x13ae2b});});}else{return;}})[_0xb24b('0x21')](function(){for(var _0x177369=0x0;_0x177369<_0x404550['length'];_0x177369++){var _0x16db40=_0x404550[_0x177369][_0xb24b('0x10c')](_0xb24b('0xa0'));var _0x56590d=_0x16db40+_0xb24b('0xab');socket[_0xb24b('0xac')]('user'+_0x16db40+_0xb24b('0xb8'),{'UserId':_0x28d5ca['id'],['queueField']:_0x404550[_0x177369]['id']});}});});});}});}})[_0xb24b('0x21')](respondWithStatusCode(_0x32ef1a,null))[_0xb24b('0x2b')](handleError(_0x32ef1a,null));};exports[_0xb24b('0x112')]=function(_0x5e8004,_0x2f6922,_0x4f350c){var _0x464ef1={};var _0x33d3ef={};var _0x2ac0d2;var _0x333d11;return db[_0xb24b('0x60')][_0xb24b('0x98')]({'where':{'id':_0x5e8004['params']['id']}})[_0xb24b('0x21')](handleEntityNotFound(_0x2f6922,null))[_0xb24b('0x21')](function(_0x303485){if(_0x303485){_0x2ac0d2=_0x303485;_0x33d3ef['model']=_['keys'](db[_0xb24b('0xc3')][_0xb24b('0x67')]);_0x33d3ef[_0xb24b('0x4e')]=_['keys'](_0x5e8004[_0xb24b('0x4e')]);_0x33d3ef[_0xb24b('0x50')]=_[_0xb24b('0x51')](_0x33d3ef[_0xb24b('0x4b')],_0x33d3ef[_0xb24b('0x4e')]);_0x464ef1[_0xb24b('0x53')]=_['intersection'](_0x33d3ef[_0xb24b('0x4b')],qs[_0xb24b('0x52')](_0x5e8004['query']['fields']));_0x464ef1['attributes']=_0x464ef1[_0xb24b('0x53')][_0xb24b('0xaa')]?_0x464ef1[_0xb24b('0x53')]:_0x33d3ef[_0xb24b('0x4b')];_0x464ef1['order']=qs[_0xb24b('0x57')](_0x5e8004[_0xb24b('0x4e')]['sort']);_0x464ef1['where']=qs['filters'](_['pick'](_0x5e8004['query'],_0x33d3ef['filters']));if(_0x5e8004[_0xb24b('0x4e')]['filter']){_0x464ef1['where']=_[_0xb24b('0x5a')](_0x464ef1['where'],{'$or':_[_0xb24b('0x47')](_0x464ef1[_0xb24b('0x53')],function(_0xf55774){var _0x2b84de={};_0x2b84de[_0xf55774]={'$like':'%'+_0x5e8004[_0xb24b('0x4e')][_0xb24b('0x3c')]+'%'};return _0x2b84de;})});}_0x464ef1=_[_0xb24b('0x5a')]({},_0x464ef1,_0x5e8004['options']);return _0x2ac0d2[_0xb24b('0x112')](_0x464ef1);}})[_0xb24b('0x21')](function(_0x52f4da){if(_0x52f4da){_0x333d11=_0x52f4da[_0xb24b('0xaa')];if(!_0x5e8004[_0xb24b('0x4e')][_0xb24b('0x54')](_0xb24b('0x55'))){_0x464ef1[_0xb24b('0x31')]=qs[_0xb24b('0x31')](_0x5e8004['query'][_0xb24b('0x31')]);_0x464ef1[_0xb24b('0x30')]=qs[_0xb24b('0x30')](_0x5e8004[_0xb24b('0x4e')][_0xb24b('0x30')]);}return _0x2ac0d2[_0xb24b('0x112')](_0x464ef1);}})[_0xb24b('0x21')](function(_0x3fc8f8){if(_0x3fc8f8){return _0x3fc8f8?{'count':_0x333d11,'rows':_0x3fc8f8}:null;}})[_0xb24b('0x21')](respondWithResult(_0x2f6922,null))[_0xb24b('0x2b')](handleError(_0x2f6922,null));};exports[_0xb24b('0x113')]=function(_0x195271,_0x3cd364,_0x314adb){var _0x9a8ad6={};var _0x4460cf={};var _0x56f8bc;var _0x53a96a;return db['User'][_0xb24b('0x98')]({'where':{'id':_0x195271[_0xb24b('0x66')]['id']}})[_0xb24b('0x21')](handleEntityNotFound(_0x3cd364,null))[_0xb24b('0x21')](function(_0x1424cf){if(_0x1424cf){_0x56f8bc=_0x1424cf;_0x4460cf['model']=_[_0xb24b('0x4f')](db[_0xb24b('0x60')][_0xb24b('0x67')]);_0x4460cf['query']=_[_0xb24b('0x4f')](_0x195271[_0xb24b('0x4e')]);_0x4460cf[_0xb24b('0x50')]=_[_0xb24b('0x51')](_0x4460cf[_0xb24b('0x4b')],_0x4460cf[_0xb24b('0x4e')]);_0x9a8ad6[_0xb24b('0x53')]=_[_0xb24b('0x51')](_0x4460cf[_0xb24b('0x4b')],qs[_0xb24b('0x52')](_0x195271['query'][_0xb24b('0x52')]));_0x9a8ad6[_0xb24b('0x53')]=_0x9a8ad6[_0xb24b('0x53')][_0xb24b('0xaa')]?_0x9a8ad6[_0xb24b('0x53')]:_0x4460cf['model'];_0x9a8ad6[_0xb24b('0x56')]=qs[_0xb24b('0x57')](_0x195271[_0xb24b('0x4e')][_0xb24b('0x57')]);_0x9a8ad6[_0xb24b('0x58')]=qs[_0xb24b('0x50')](_[_0xb24b('0x59')](_0x195271['query'],_0x4460cf[_0xb24b('0x50')]));if(_0x195271['query'][_0xb24b('0x3c')]){_0x9a8ad6['where']=_[_0xb24b('0x5a')](_0x9a8ad6[_0xb24b('0x58')],{'$or':_[_0xb24b('0x47')](_0x9a8ad6[_0xb24b('0x53')],function(_0x4be2ba){var _0xa3574a={};_0xa3574a[_0x4be2ba]={'$like':'%'+_0x195271['query']['filter']+'%'};return _0xa3574a;})});}_0x9a8ad6[_0xb24b('0x4b')]=db[_0xb24b('0x60')];_0x9a8ad6['as']=_0xb24b('0x39');_0x9a8ad6=_[_0xb24b('0x5a')]({},_0x9a8ad6,_0x195271[_0xb24b('0x5f')]);return _0x56f8bc[_0xb24b('0x10e')]({'include':[_0x9a8ad6]});}})['then'](function(_0x5e5c24){if(_0x5e5c24){var _0x1b4bb8={},_0x12cf10=[],_0x22c96e=0x0;for(var _0x223452=0x0;_0x223452<_0x5e5c24[_0xb24b('0xaa')];_0x223452+=0x1){for(var _0x5b2335=0x0,_0x51ab77;_0x5b2335<_0x5e5c24[_0x223452][_0xb24b('0x39')]['length'];_0x5b2335+=0x1){_0x51ab77=_0x5e5c24[_0x223452][_0xb24b('0x39')][_0x5b2335][_0xb24b('0x37')]({'plain':!![]});_0x1b4bb8[_0x51ab77['id']]=_0x51ab77;}}_0x1b4bb8=_[_0xb24b('0x114')](_0x1b4bb8);for(var _0x33aeee=qs[_0xb24b('0x30')](_0x195271[_0xb24b('0x4e')]['offset']);_0x33aeee<_0x1b4bb8['length']&&_0x12cf10[_0xb24b('0xaa')]<qs['limit'](_0x195271[_0xb24b('0x4e')][_0xb24b('0x31')]);_0x33aeee+=0x1){if(_0x1b4bb8[_0x33aeee]){_0x12cf10[_0xb24b('0xb2')](_0x1b4bb8[_0x33aeee]);}}return{'count':_0x1b4bb8[_0xb24b('0xaa')],'rows':_0x12cf10};}})[_0xb24b('0x21')](respondWithResult(_0x3cd364,null))[_0xb24b('0x2b')](handleError(_0x3cd364,null));};exports[_0xb24b('0x43')]=function(_0x515c43,_0x9962be){if(_0x515c43[_0xb24b('0x92')]['id']==_0x515c43[_0xb24b('0x66')]['id']){return _0x9962be[_0xb24b('0x2c')](0x1f4)[_0xb24b('0x46')]({'message':_0xb24b('0x115')});}return db[_0xb24b('0x60')]['find']({'where':{'id':_0x515c43[_0xb24b('0x66')]['id']}})[_0xb24b('0x21')](handleEntityNotFound(_0x9962be,null))[_0xb24b('0x21')](removeEntity(_0x9962be,null))[_0xb24b('0x2b')](handleError(_0x9962be,null));};exports[_0xb24b('0x116')]=function(_0x5b55eb,_0x587e75,_0x402484){return db[_0xb24b('0x60')][_0xb24b('0x40')]({'where':{'id':_0x5b55eb[_0xb24b('0x66')]['id']}})['then'](handleEntityNotFound(_0x587e75,null))[_0xb24b('0x21')](function(_0x418f2f){if(_0x418f2f){return _0x418f2f['addChatInteractions'](_0x5b55eb[_0xb24b('0x69')][_0xb24b('0x6c')],_[_0xb24b('0x6d')](_0x5b55eb['body'],['ids','id'])||{})[_0xb24b('0xa9')](function(){for(var _0x434015=0x0;_0x434015<_0x5b55eb[_0xb24b('0x69')][_0xb24b('0x6c')][_0xb24b('0xaa')];_0x434015+=0x1){socket[_0xb24b('0xac')](_0xb24b('0x117'),{'ChatInteractionId':Number(_0x5b55eb['body'][_0xb24b('0x6c')][_0x434015]),'UserId':Number(_0x5b55eb[_0xb24b('0x66')]['id'])});}return _0x5b55eb[_0xb24b('0x69')]['ids'];});}})[_0xb24b('0x21')](respondWithResult(_0x587e75,null))[_0xb24b('0x2b')](handleError(_0x587e75,null));};exports[_0xb24b('0x118')]=function(_0x3fe1e5,_0x4042a5,_0x479067){return db[_0xb24b('0x60')][_0xb24b('0x40')]({'where':{'id':_0x3fe1e5[_0xb24b('0x66')]['id']}})[_0xb24b('0x21')](handleEntityNotFound(_0x4042a5,null))['then'](function(_0x3f49f0){if(_0x3f49f0){return _0x3f49f0[_0xb24b('0x118')](_0x3fe1e5[_0xb24b('0x4e')][_0xb24b('0x6c')])[_0xb24b('0x21')](function(){if(_[_0xb24b('0x119')](_0x3fe1e5[_0xb24b('0x4e')][_0xb24b('0x6c')])){for(var _0x9506a5=0x0;_0x9506a5<_0x3fe1e5[_0xb24b('0x4e')][_0xb24b('0x6c')]['length'];_0x9506a5+=0x1){socket[_0xb24b('0xac')]('user_has_chat_interactions:remove',{'ChatInteractionId':Number(_0x3fe1e5['query'][_0xb24b('0x6c')][_0x9506a5]),'UserId':Number(_0x3fe1e5['params']['id'])});}}else{socket[_0xb24b('0xac')](_0xb24b('0x11a'),{'ChatInteractionId':Number(_0x3fe1e5[_0xb24b('0x4e')]['ids']),'UserId':Number(_0x3fe1e5[_0xb24b('0x66')]['id'])});}});}})[_0xb24b('0x21')](respondWithStatusCode(_0x4042a5,null))[_0xb24b('0x2b')](handleError(_0x4042a5,null));};exports[_0xb24b('0x11b')]=function(_0x45c38f,_0x2e0e8c,_0x1a1a96){return db['User']['find']({'where':{'id':_0x45c38f['params']['id']}})[_0xb24b('0x21')](handleEntityNotFound(_0x2e0e8c,null))[_0xb24b('0x21')](function(_0x390c2d){if(_0x390c2d){return _0x390c2d['addMailInteractions'](_0x45c38f[_0xb24b('0x69')]['ids'],_[_0xb24b('0x6d')](_0x45c38f['body'],[_0xb24b('0x6c'),'id'])||{})[_0xb24b('0xa9')](function(){for(var _0x52eb76=0x0;_0x52eb76<_0x45c38f['body'][_0xb24b('0x6c')][_0xb24b('0xaa')];_0x52eb76+=0x1){socket['emit'](_0xb24b('0x11c'),{'MailInteractionId':Number(_0x45c38f[_0xb24b('0x69')][_0xb24b('0x6c')][_0x52eb76]),'UserId':Number(_0x45c38f['params']['id'])});}return _0x45c38f['body'][_0xb24b('0x6c')];});}})[_0xb24b('0x21')](respondWithResult(_0x2e0e8c,null))[_0xb24b('0x2b')](handleError(_0x2e0e8c,null));};exports[_0xb24b('0x11d')]=function(_0x4ec993,_0x49ac9f,_0x307a5d){return db['User']['find']({'where':{'id':_0x4ec993[_0xb24b('0x66')]['id']}})[_0xb24b('0x21')](handleEntityNotFound(_0x49ac9f,null))[_0xb24b('0x21')](function(_0x2c150c){if(_0x2c150c){return _0x2c150c[_0xb24b('0x11d')](_0x4ec993[_0xb24b('0x4e')][_0xb24b('0x6c')])[_0xb24b('0x21')](function(){if(_[_0xb24b('0x119')](_0x4ec993[_0xb24b('0x4e')][_0xb24b('0x6c')])){for(var _0x1da053=0x0;_0x1da053<_0x4ec993['query'][_0xb24b('0x6c')]['length'];_0x1da053+=0x1){socket[_0xb24b('0xac')](_0xb24b('0x11e'),{'MailInteractionId':Number(_0x4ec993[_0xb24b('0x4e')]['ids'][_0x1da053]),'UserId':Number(_0x4ec993[_0xb24b('0x66')]['id'])});}}else{socket['emit']('user_has_mail_interactions:remove',{'MailInteractionId':Number(_0x4ec993[_0xb24b('0x4e')]['ids']),'UserId':Number(_0x4ec993[_0xb24b('0x66')]['id'])});}});}})[_0xb24b('0x21')](respondWithStatusCode(_0x49ac9f,null))[_0xb24b('0x2b')](handleError(_0x49ac9f,null));};exports[_0xb24b('0x11f')]=function(_0xae8018,_0x428ce2,_0x4f0ac0){return db[_0xb24b('0x60')][_0xb24b('0x40')]({'where':{'id':_0xae8018['params']['id']}})[_0xb24b('0x21')](handleEntityNotFound(_0x428ce2,null))['then'](function(_0x581d41){if(_0x581d41){return _0x581d41['addFaxInteractions'](_0xae8018[_0xb24b('0x69')][_0xb24b('0x6c')],_[_0xb24b('0x6d')](_0xae8018[_0xb24b('0x69')],[_0xb24b('0x6c'),'id'])||{})[_0xb24b('0xa9')](function(){for(var _0x704ae7=0x0;_0x704ae7<_0xae8018[_0xb24b('0x69')][_0xb24b('0x6c')][_0xb24b('0xaa')];_0x704ae7+=0x1){socket[_0xb24b('0xac')](_0xb24b('0x120'),{'FaxInteractionId':Number(_0xae8018[_0xb24b('0x69')][_0xb24b('0x6c')][_0x704ae7]),'UserId':Number(_0xae8018[_0xb24b('0x66')]['id'])});}return _0xae8018[_0xb24b('0x69')][_0xb24b('0x6c')];});}})[_0xb24b('0x21')](respondWithResult(_0x428ce2,null))[_0xb24b('0x2b')](handleError(_0x428ce2,null));};exports[_0xb24b('0x121')]=function(_0x34d6a3,_0xb89dec,_0x326505){return db['User'][_0xb24b('0x40')]({'where':{'id':_0x34d6a3[_0xb24b('0x66')]['id']}})[_0xb24b('0x21')](handleEntityNotFound(_0xb89dec,null))['then'](function(_0xda6b03){if(_0xda6b03){return _0xda6b03[_0xb24b('0x121')](_0x34d6a3[_0xb24b('0x4e')]['ids'])[_0xb24b('0x21')](function(){if(_['isArray'](_0x34d6a3[_0xb24b('0x4e')][_0xb24b('0x6c')])){for(var _0x469109=0x0;_0x469109<_0x34d6a3['query']['ids'][_0xb24b('0xaa')];_0x469109+=0x1){socket['emit'](_0xb24b('0x122'),{'FaxInteractionId':Number(_0x34d6a3['query'][_0xb24b('0x6c')][_0x469109]),'UserId':Number(_0x34d6a3['params']['id'])});}}else{socket['emit'](_0xb24b('0x122'),{'FaxInteractionId':Number(_0x34d6a3[_0xb24b('0x4e')][_0xb24b('0x6c')]),'UserId':Number(_0x34d6a3[_0xb24b('0x66')]['id'])});}});}})[_0xb24b('0x21')](respondWithStatusCode(_0xb89dec,null))['catch'](handleError(_0xb89dec,null));};exports['addSmsInteractions']=function(_0x38e1a6,_0xe59aef,_0x42723d){return db[_0xb24b('0x60')][_0xb24b('0x40')]({'where':{'id':_0x38e1a6[_0xb24b('0x66')]['id']}})[_0xb24b('0x21')](handleEntityNotFound(_0xe59aef,null))[_0xb24b('0x21')](function(_0x48bc17){if(_0x48bc17){return _0x48bc17[_0xb24b('0x123')](_0x38e1a6[_0xb24b('0x69')][_0xb24b('0x6c')],_['omit'](_0x38e1a6[_0xb24b('0x69')],[_0xb24b('0x6c'),'id'])||{})['spread'](function(){for(var _0x169517=0x0;_0x169517<_0x38e1a6[_0xb24b('0x69')]['ids'][_0xb24b('0xaa')];_0x169517+=0x1){socket[_0xb24b('0xac')](_0xb24b('0x124'),{'SmsInteractionId':Number(_0x38e1a6['body'][_0xb24b('0x6c')][_0x169517]),'UserId':Number(_0x38e1a6[_0xb24b('0x66')]['id'])});}return _0x38e1a6[_0xb24b('0x69')][_0xb24b('0x6c')];});}})[_0xb24b('0x21')](respondWithResult(_0xe59aef,null))[_0xb24b('0x2b')](handleError(_0xe59aef,null));};exports[_0xb24b('0x125')]=function(_0x1479a2,_0x1721cf,_0x9316b){return db[_0xb24b('0x60')][_0xb24b('0x40')]({'where':{'id':_0x1479a2['params']['id']}})[_0xb24b('0x21')](handleEntityNotFound(_0x1721cf,null))[_0xb24b('0x21')](function(_0x1f94c2){if(_0x1f94c2){return _0x1f94c2[_0xb24b('0x125')](_0x1479a2['query']['ids'])[_0xb24b('0x21')](function(){if(_[_0xb24b('0x119')](_0x1479a2['query'][_0xb24b('0x6c')])){for(var _0x460b65=0x0;_0x460b65<_0x1479a2['query'][_0xb24b('0x6c')][_0xb24b('0xaa')];_0x460b65+=0x1){socket[_0xb24b('0xac')]('user_has_sms_interactions:remove',{'SmsInteractionId':Number(_0x1479a2[_0xb24b('0x4e')][_0xb24b('0x6c')][_0x460b65]),'UserId':Number(_0x1479a2[_0xb24b('0x66')]['id'])});}}else{socket[_0xb24b('0xac')]('user_has_sms_interactions:remove',{'SmsInteractionId':Number(_0x1479a2['query'][_0xb24b('0x6c')]),'UserId':Number(_0x1479a2['params']['id'])});}});}})[_0xb24b('0x21')](respondWithStatusCode(_0x1721cf,null))[_0xb24b('0x2b')](handleError(_0x1721cf,null));};exports[_0xb24b('0x126')]=function(_0x55f750,_0x216163,_0x2ae9c4){return db[_0xb24b('0x60')][_0xb24b('0x40')]({'where':{'id':_0x55f750[_0xb24b('0x66')]['id']}})[_0xb24b('0x21')](handleEntityNotFound(_0x216163,null))[_0xb24b('0x21')](function(_0x11e87e){if(_0x11e87e){return _0x11e87e[_0xb24b('0x126')](_0x55f750[_0xb24b('0x69')]['ids'],_[_0xb24b('0x6d')](_0x55f750[_0xb24b('0x69')],[_0xb24b('0x6c'),'id'])||{})[_0xb24b('0xa9')](function(){for(var _0x58ba5b=0x0;_0x58ba5b<_0x55f750[_0xb24b('0x69')]['ids']['length'];_0x58ba5b+=0x1){socket[_0xb24b('0xac')]('user_has_openchannel_interactions:save',{'OpenchannelInteractionId':Number(_0x55f750[_0xb24b('0x69')][_0xb24b('0x6c')][_0x58ba5b]),'UserId':Number(_0x55f750[_0xb24b('0x66')]['id'])});}return _0x55f750[_0xb24b('0x69')]['ids'];});}})[_0xb24b('0x21')](respondWithResult(_0x216163,null))[_0xb24b('0x2b')](handleError(_0x216163,null));};exports['removeOpenchannelInteractions']=function(_0xde8a93,_0x10c757,_0x24dde3){return db[_0xb24b('0x60')][_0xb24b('0x40')]({'where':{'id':_0xde8a93[_0xb24b('0x66')]['id']}})[_0xb24b('0x21')](handleEntityNotFound(_0x10c757,null))[_0xb24b('0x21')](function(_0x1e95d2){if(_0x1e95d2){return _0x1e95d2[_0xb24b('0x127')](_0xde8a93[_0xb24b('0x4e')][_0xb24b('0x6c')])['then'](function(){if(_[_0xb24b('0x119')](_0xde8a93[_0xb24b('0x4e')][_0xb24b('0x6c')])){for(var _0x1023c5=0x0;_0x1023c5<_0xde8a93[_0xb24b('0x4e')][_0xb24b('0x6c')][_0xb24b('0xaa')];_0x1023c5+=0x1){socket[_0xb24b('0xac')](_0xb24b('0x128'),{'OpenchannelInteractionId':Number(_0xde8a93['query'][_0xb24b('0x6c')][_0x1023c5]),'UserId':Number(_0xde8a93[_0xb24b('0x66')]['id'])});}}else{socket[_0xb24b('0xac')](_0xb24b('0x128'),{'OpenchannelInteractionId':Number(_0xde8a93['query'][_0xb24b('0x6c')]),'UserId':Number(_0xde8a93[_0xb24b('0x66')]['id'])});}});}})[_0xb24b('0x21')](respondWithStatusCode(_0x10c757,null))[_0xb24b('0x2b')](handleError(_0x10c757,null));};exports[_0xb24b('0x129')]=function(_0x4a081d,_0x2d9055,_0x48cc60){var _0x494d0f={};var _0x6feba7={};var _0x49d322;var _0x4398a3;return db[_0xb24b('0x60')][_0xb24b('0x98')]({'where':{'id':_0x4a081d[_0xb24b('0x66')]['id']}})[_0xb24b('0x21')](handleEntityNotFound(_0x2d9055,null))[_0xb24b('0x21')](function(_0x2618df){if(_0x2618df){_0x49d322=_0x2618df;_0x6feba7['model']=_['keys'](db[_0xb24b('0x12a')][_0xb24b('0x67')]);_0x6feba7[_0xb24b('0x4e')]=_[_0xb24b('0x4f')](_0x4a081d['query']);_0x6feba7[_0xb24b('0x50')]=_[_0xb24b('0x51')](_0x6feba7[_0xb24b('0x4b')],_0x6feba7['query']);_0x494d0f[_0xb24b('0x53')]=_[_0xb24b('0x51')](_0x6feba7['model'],qs[_0xb24b('0x52')](_0x4a081d[_0xb24b('0x4e')][_0xb24b('0x52')]));_0x494d0f[_0xb24b('0x53')]=_0x494d0f[_0xb24b('0x53')]['length']?_0x494d0f[_0xb24b('0x53')]:_0x6feba7['model'];_0x494d0f['order']=qs[_0xb24b('0x57')](_0x4a081d['query'][_0xb24b('0x57')]);_0x494d0f[_0xb24b('0x58')]=qs['filters'](_[_0xb24b('0x59')](_0x4a081d['query'],_0x6feba7[_0xb24b('0x50')]));if(_0x4a081d[_0xb24b('0x4e')][_0xb24b('0x3c')]){_0x494d0f['where']=_['merge'](_0x494d0f[_0xb24b('0x58')],{'$or':_['map'](_0x494d0f['attributes'],function(_0x491770){var _0x5e05e9={};_0x5e05e9[_0x491770]={'$like':'%'+_0x4a081d[_0xb24b('0x4e')]['filter']+'%'};return _0x5e05e9;})});}_0x494d0f=_[_0xb24b('0x5a')]({},_0x494d0f,_0x4a081d[_0xb24b('0x5f')]);return _0x49d322['getVoicePrefixes'](_0x494d0f);}})[_0xb24b('0x21')](function(_0xa28f40){if(_0xa28f40){_0x4398a3=_0xa28f40[_0xb24b('0xaa')];if(!_0x4a081d[_0xb24b('0x4e')][_0xb24b('0x54')](_0xb24b('0x55'))){_0x494d0f[_0xb24b('0x31')]=qs[_0xb24b('0x31')](_0x4a081d[_0xb24b('0x4e')][_0xb24b('0x31')]);_0x494d0f[_0xb24b('0x30')]=qs['offset'](_0x4a081d[_0xb24b('0x4e')][_0xb24b('0x30')]);}return _0x49d322[_0xb24b('0x129')](_0x494d0f);}})[_0xb24b('0x21')](function(_0x2b342b){if(_0x2b342b){return _0x2b342b?{'count':_0x4398a3,'rows':_0x2b342b}:null;}})[_0xb24b('0x21')](respondWithResult(_0x2d9055,null))[_0xb24b('0x2b')](handleError(_0x2d9055,null));};exports[_0xb24b('0x12b')]=function(_0x16360e,_0x315fc8,_0x14d638){var _0xf37b11={};var _0x573c7d={};var _0x4f8131;var _0x37ee96;return db['User'][_0xb24b('0x98')]({'where':{'id':_0x16360e[_0xb24b('0x66')]['id']}})['then'](handleEntityNotFound(_0x315fc8,null))[_0xb24b('0x21')](function(_0x6ffce2){if(_0x6ffce2){_0x4f8131=_0x6ffce2;_0x573c7d[_0xb24b('0x4b')]=_['keys'](db[_0xb24b('0x12c')]['rawAttributes']);_0x573c7d[_0xb24b('0x4e')]=_[_0xb24b('0x4f')](_0x16360e[_0xb24b('0x4e')]);_0x573c7d[_0xb24b('0x50')]=_[_0xb24b('0x51')](_0x573c7d[_0xb24b('0x4b')],_0x573c7d[_0xb24b('0x4e')]);_0xf37b11[_0xb24b('0x53')]=_[_0xb24b('0x51')](_0x573c7d[_0xb24b('0x4b')],qs[_0xb24b('0x52')](_0x16360e[_0xb24b('0x4e')]['fields']));_0xf37b11[_0xb24b('0x53')]=_0xf37b11[_0xb24b('0x53')][_0xb24b('0xaa')]?_0xf37b11[_0xb24b('0x53')]:_0x573c7d[_0xb24b('0x4b')];_0xf37b11[_0xb24b('0x56')]=qs['sort'](_0x16360e[_0xb24b('0x4e')][_0xb24b('0x57')]);_0xf37b11['where']=qs[_0xb24b('0x50')](_[_0xb24b('0x59')](_0x16360e[_0xb24b('0x4e')],_0x573c7d[_0xb24b('0x50')]));if(_0x16360e[_0xb24b('0x4e')][_0xb24b('0x3c')]){_0xf37b11['where']=_[_0xb24b('0x5a')](_0xf37b11[_0xb24b('0x58')],{'$or':_[_0xb24b('0x47')](_0xf37b11[_0xb24b('0x53')],function(_0x4d0f0d){var _0x192d90={};_0x192d90[_0x4d0f0d]={'$like':'%'+_0x16360e['query']['filter']+'%'};return _0x192d90;})});}_0xf37b11=_[_0xb24b('0x5a')]({},_0xf37b11,_0x16360e[_0xb24b('0x5f')]);return _0x4f8131['getFaxAccounts'](_0xf37b11);}})[_0xb24b('0x21')](function(_0x143fb5){if(_0x143fb5){_0x37ee96=_0x143fb5[_0xb24b('0xaa')];if(!_0x16360e['query'][_0xb24b('0x54')]('nolimit')){_0xf37b11[_0xb24b('0x31')]=qs[_0xb24b('0x31')](_0x16360e[_0xb24b('0x4e')][_0xb24b('0x31')]);_0xf37b11[_0xb24b('0x30')]=qs[_0xb24b('0x30')](_0x16360e['query'][_0xb24b('0x30')]);}return _0x4f8131['getFaxAccounts'](_0xf37b11);}})['then'](function(_0x1003d0){if(_0x1003d0){return _0x1003d0?{'count':_0x37ee96,'rows':_0x1003d0}:null;}})['then'](respondWithResult(_0x315fc8,null))[_0xb24b('0x2b')](handleError(_0x315fc8,null));};exports['addFaxAccounts']=function(_0x28a5eb,_0x16c70f,_0x2c0dc4){return db[_0xb24b('0x60')]['find']({'where':{'id':_0x28a5eb[_0xb24b('0x66')]['id']}})[_0xb24b('0x21')](handleEntityNotFound(_0x16c70f,null))[_0xb24b('0x21')](function(_0x22c4ae){if(_0x22c4ae){return _0x22c4ae[_0xb24b('0x12d')](_0x28a5eb[_0xb24b('0x69')][_0xb24b('0x6c')],_[_0xb24b('0x6d')](_0x28a5eb[_0xb24b('0x69')],[_0xb24b('0x6c'),'id'])||{});}})[_0xb24b('0x21')](respondWithResult(_0x16c70f,null))[_0xb24b('0x2b')](handleError(_0x16c70f,null));};exports[_0xb24b('0x12e')]=function(_0x3050dd,_0x551714,_0x5d3af1){return db[_0xb24b('0x60')][_0xb24b('0x40')]({'where':{'id':_0x3050dd['params']['id']}})[_0xb24b('0x21')](handleEntityNotFound(_0x551714,null))['then'](function(_0x1ab2ff){if(_0x1ab2ff){return _0x1ab2ff[_0xb24b('0x12e')](_0x3050dd[_0xb24b('0x4e')]['ids']);}})[_0xb24b('0x21')](respondWithStatusCode(_0x551714,null))['catch'](handleError(_0x551714,null));};exports[_0xb24b('0x12f')]=function(_0x43477e,_0x40c40d,_0x2110a0){var _0x4c43a4={};var _0x25c355={};var _0x3f1de5;var _0x3a9020;return db[_0xb24b('0x60')][_0xb24b('0x98')]({'where':{'id':_0x43477e['params']['id']}})[_0xb24b('0x21')](handleEntityNotFound(_0x40c40d,null))[_0xb24b('0x21')](function(_0x3692ec){if(_0x3692ec){_0x3f1de5=_0x3692ec;_0x25c355[_0xb24b('0x4b')]=_[_0xb24b('0x4f')](db['MailAccount']['rawAttributes']);_0x25c355['query']=_['keys'](_0x43477e['query']);_0x25c355[_0xb24b('0x50')]=_[_0xb24b('0x51')](_0x25c355['model'],_0x25c355['query']);_0x4c43a4['attributes']=_[_0xb24b('0x51')](_0x25c355['model'],qs[_0xb24b('0x52')](_0x43477e[_0xb24b('0x4e')][_0xb24b('0x52')]));_0x4c43a4[_0xb24b('0x53')]=_0x4c43a4[_0xb24b('0x53')][_0xb24b('0xaa')]?_0x4c43a4['attributes']:_0x25c355['model'];_0x4c43a4[_0xb24b('0x56')]=qs[_0xb24b('0x57')](_0x43477e['query']['sort']);_0x4c43a4[_0xb24b('0x58')]=qs['filters'](_[_0xb24b('0x59')](_0x43477e[_0xb24b('0x4e')],_0x25c355[_0xb24b('0x50')]));if(_0x43477e[_0xb24b('0x4e')][_0xb24b('0x3c')]){_0x4c43a4[_0xb24b('0x58')]=_['merge'](_0x4c43a4[_0xb24b('0x58')],{'$or':_[_0xb24b('0x47')](_0x4c43a4['attributes'],function(_0x15a382){var _0x1283cb={};_0x1283cb[_0x15a382]={'$like':'%'+_0x43477e[_0xb24b('0x4e')]['filter']+'%'};return _0x1283cb;})});}_0x4c43a4=_['merge']({},_0x4c43a4,_0x43477e[_0xb24b('0x5f')]);return _0x3f1de5[_0xb24b('0x12f')](_0x4c43a4);}})[_0xb24b('0x21')](function(_0x2be13a){if(_0x2be13a){_0x3a9020=_0x2be13a['length'];if(!_0x43477e[_0xb24b('0x4e')][_0xb24b('0x54')](_0xb24b('0x55'))){_0x4c43a4[_0xb24b('0x31')]=qs['limit'](_0x43477e['query']['limit']);_0x4c43a4[_0xb24b('0x30')]=qs[_0xb24b('0x30')](_0x43477e[_0xb24b('0x4e')][_0xb24b('0x30')]);}return _0x3f1de5[_0xb24b('0x12f')](_0x4c43a4);}})[_0xb24b('0x21')](function(_0x138e49){if(_0x138e49){return _0x138e49?{'count':_0x3a9020,'rows':_0x138e49}:null;}})[_0xb24b('0x21')](respondWithResult(_0x40c40d,null))[_0xb24b('0x2b')](handleError(_0x40c40d,null));};exports['addMailAccounts']=function(_0x5680a3,_0xcc39f8,_0x192aa3){return db[_0xb24b('0x60')][_0xb24b('0x40')]({'where':{'id':_0x5680a3[_0xb24b('0x66')]['id']}})[_0xb24b('0x21')](handleEntityNotFound(_0xcc39f8,null))[_0xb24b('0x21')](function(_0x3ebb3d){if(_0x3ebb3d){return _0x3ebb3d[_0xb24b('0x130')](_0x5680a3['body']['ids'],_['omit'](_0x5680a3[_0xb24b('0x69')],[_0xb24b('0x6c'),'id'])||{});}})['then'](respondWithResult(_0xcc39f8,null))[_0xb24b('0x2b')](handleError(_0xcc39f8,null));};exports[_0xb24b('0x131')]=function(_0x50f9d1,_0x207dc3,_0x40098a){return db[_0xb24b('0x60')]['find']({'where':{'id':_0x50f9d1[_0xb24b('0x66')]['id']}})['then'](handleEntityNotFound(_0x207dc3,null))[_0xb24b('0x21')](function(_0x38f982){if(_0x38f982){return _0x38f982['removeMailAccounts'](_0x50f9d1[_0xb24b('0x4e')][_0xb24b('0x6c')]);}})['then'](respondWithStatusCode(_0x207dc3,null))[_0xb24b('0x2b')](handleError(_0x207dc3,null));};exports[_0xb24b('0x132')]=function(_0x9fe134,_0x4bf36f,_0xe05621){var _0x2e1f3c={};var _0x5ea87f={};var _0x2e1abe;var _0x1bf750;return db['User'][_0xb24b('0x98')]({'where':{'id':_0x9fe134['params']['id']}})[_0xb24b('0x21')](handleEntityNotFound(_0x4bf36f,null))['then'](function(_0x43ff84){if(_0x43ff84){_0x2e1abe=_0x43ff84;_0x5ea87f[_0xb24b('0x4b')]=_[_0xb24b('0x4f')](db[_0xb24b('0x133')][_0xb24b('0x67')]);_0x5ea87f[_0xb24b('0x4e')]=_[_0xb24b('0x4f')](_0x9fe134[_0xb24b('0x4e')]);_0x5ea87f[_0xb24b('0x50')]=_[_0xb24b('0x51')](_0x5ea87f[_0xb24b('0x4b')],_0x5ea87f['query']);_0x2e1f3c[_0xb24b('0x53')]=_[_0xb24b('0x51')](_0x5ea87f[_0xb24b('0x4b')],qs[_0xb24b('0x52')](_0x9fe134[_0xb24b('0x4e')][_0xb24b('0x52')]));_0x2e1f3c['attributes']=_0x2e1f3c[_0xb24b('0x53')]['length']?_0x2e1f3c[_0xb24b('0x53')]:_0x5ea87f[_0xb24b('0x4b')];_0x2e1f3c[_0xb24b('0x56')]=qs[_0xb24b('0x57')](_0x9fe134[_0xb24b('0x4e')][_0xb24b('0x57')]);_0x2e1f3c[_0xb24b('0x58')]=qs['filters'](_[_0xb24b('0x59')](_0x9fe134['query'],_0x5ea87f[_0xb24b('0x50')]));if(_0x9fe134[_0xb24b('0x4e')][_0xb24b('0x3c')]){_0x2e1f3c[_0xb24b('0x58')]=_[_0xb24b('0x5a')](_0x2e1f3c['where'],{'$or':_[_0xb24b('0x47')](_0x2e1f3c[_0xb24b('0x53')],function(_0x3eb8be){var _0x4960e2={};_0x4960e2[_0x3eb8be]={'$like':'%'+_0x9fe134[_0xb24b('0x4e')][_0xb24b('0x3c')]+'%'};return _0x4960e2;})});}_0x2e1f3c=_[_0xb24b('0x5a')]({},_0x2e1f3c,_0x9fe134[_0xb24b('0x5f')]);return _0x2e1abe[_0xb24b('0x132')](_0x2e1f3c);}})[_0xb24b('0x21')](function(_0x3fe60e){if(_0x3fe60e){_0x1bf750=_0x3fe60e['length'];if(!_0x9fe134[_0xb24b('0x4e')][_0xb24b('0x54')](_0xb24b('0x55'))){_0x2e1f3c[_0xb24b('0x31')]=qs[_0xb24b('0x31')](_0x9fe134['query'][_0xb24b('0x31')]);_0x2e1f3c[_0xb24b('0x30')]=qs['offset'](_0x9fe134['query'][_0xb24b('0x30')]);}return _0x2e1abe['getOpenchannelAccounts'](_0x2e1f3c);}})[_0xb24b('0x21')](function(_0x28cf92){if(_0x28cf92){return _0x28cf92?{'count':_0x1bf750,'rows':_0x28cf92}:null;}})['then'](respondWithResult(_0x4bf36f,null))['catch'](handleError(_0x4bf36f,null));};exports[_0xb24b('0x134')]=function(_0x3ac587,_0x1473ad,_0x2b2264){return db[_0xb24b('0x60')][_0xb24b('0x40')]({'where':{'id':_0x3ac587['params']['id']}})[_0xb24b('0x21')](handleEntityNotFound(_0x1473ad,null))[_0xb24b('0x21')](function(_0x5c8807){if(_0x5c8807){return _0x5c8807[_0xb24b('0x134')](_0x3ac587[_0xb24b('0x69')][_0xb24b('0x6c')],_[_0xb24b('0x6d')](_0x3ac587['body'],[_0xb24b('0x6c'),'id'])||{});}})['then'](respondWithResult(_0x1473ad,null))[_0xb24b('0x2b')](handleError(_0x1473ad,null));};exports[_0xb24b('0x135')]=function(_0x50e6d0,_0x258866,_0x2a8c5a){return db[_0xb24b('0x60')]['find']({'where':{'id':_0x50e6d0['params']['id']}})[_0xb24b('0x21')](handleEntityNotFound(_0x258866,null))[_0xb24b('0x21')](function(_0x589125){if(_0x589125){return _0x589125['removeOpenchannelAccounts'](_0x50e6d0[_0xb24b('0x4e')][_0xb24b('0x6c')]);}})[_0xb24b('0x21')](respondWithStatusCode(_0x258866,null))[_0xb24b('0x2b')](handleError(_0x258866,null));};exports[_0xb24b('0x136')]=function(_0x4da996,_0x34aadb,_0x25a8b8){var _0x2ab475={};var _0x5d8576={};var _0xeee0c2;var _0x113025;return db[_0xb24b('0x60')][_0xb24b('0x98')]({'where':{'id':_0x4da996['params']['id']}})[_0xb24b('0x21')](handleEntityNotFound(_0x34aadb,null))[_0xb24b('0x21')](function(_0x43933c){if(_0x43933c){_0xeee0c2=_0x43933c;_0x5d8576[_0xb24b('0x4b')]=_[_0xb24b('0x4f')](db[_0xb24b('0x137')][_0xb24b('0x67')]);_0x5d8576[_0xb24b('0x4e')]=_['keys'](_0x4da996[_0xb24b('0x4e')]);_0x5d8576['filters']=_['intersection'](_0x5d8576['model'],_0x5d8576[_0xb24b('0x4e')]);_0x2ab475['attributes']=_[_0xb24b('0x51')](_0x5d8576[_0xb24b('0x4b')],qs[_0xb24b('0x52')](_0x4da996[_0xb24b('0x4e')][_0xb24b('0x52')]));_0x2ab475[_0xb24b('0x53')]=_0x2ab475[_0xb24b('0x53')][_0xb24b('0xaa')]?_0x2ab475[_0xb24b('0x53')]:_0x5d8576[_0xb24b('0x4b')];_0x2ab475['order']=qs[_0xb24b('0x57')](_0x4da996[_0xb24b('0x4e')][_0xb24b('0x57')]);_0x2ab475[_0xb24b('0x58')]=qs[_0xb24b('0x50')](_[_0xb24b('0x59')](_0x4da996[_0xb24b('0x4e')],_0x5d8576[_0xb24b('0x50')]));if(_0x4da996['query']['filter']){_0x2ab475[_0xb24b('0x58')]=_[_0xb24b('0x5a')](_0x2ab475['where'],{'$or':_['map'](_0x2ab475['attributes'],function(_0x52e67b){var _0x488a82={};_0x488a82[_0x52e67b]={'$like':'%'+_0x4da996[_0xb24b('0x4e')][_0xb24b('0x3c')]+'%'};return _0x488a82;})});}_0x2ab475=_[_0xb24b('0x5a')]({},_0x2ab475,_0x4da996[_0xb24b('0x5f')]);return _0xeee0c2[_0xb24b('0x136')](_0x2ab475);}})['then'](function(_0x428fd7){if(_0x428fd7){_0x113025=_0x428fd7[_0xb24b('0xaa')];if(!_0x4da996[_0xb24b('0x4e')][_0xb24b('0x54')](_0xb24b('0x55'))){_0x2ab475[_0xb24b('0x31')]=qs[_0xb24b('0x31')](_0x4da996[_0xb24b('0x4e')][_0xb24b('0x31')]);_0x2ab475[_0xb24b('0x30')]=qs[_0xb24b('0x30')](_0x4da996['query'][_0xb24b('0x30')]);}return _0xeee0c2['getSmsAccounts'](_0x2ab475);}})[_0xb24b('0x21')](function(_0x399e11){if(_0x399e11){return _0x399e11?{'count':_0x113025,'rows':_0x399e11}:null;}})[_0xb24b('0x21')](respondWithResult(_0x34aadb,null))[_0xb24b('0x2b')](handleError(_0x34aadb,null));};exports[_0xb24b('0x138')]=function(_0x134641,_0x371e25,_0x4ac8a1){return db['User'][_0xb24b('0x40')]({'where':{'id':_0x134641['params']['id']}})[_0xb24b('0x21')](handleEntityNotFound(_0x371e25,null))['then'](function(_0xfa3c9e){if(_0xfa3c9e){return _0xfa3c9e['addSmsAccounts'](_0x134641[_0xb24b('0x69')]['ids'],_['omit'](_0x134641['body'],[_0xb24b('0x6c'),'id'])||{});}})[_0xb24b('0x21')](respondWithResult(_0x371e25,null))[_0xb24b('0x2b')](handleError(_0x371e25,null));};exports[_0xb24b('0x139')]=function(_0x540d45,_0x1a5a47,_0x5abace){return db[_0xb24b('0x60')][_0xb24b('0x40')]({'where':{'id':_0x540d45[_0xb24b('0x66')]['id']}})[_0xb24b('0x21')](handleEntityNotFound(_0x1a5a47,null))[_0xb24b('0x21')](function(_0x3de17b){if(_0x3de17b){return _0x3de17b[_0xb24b('0x139')](_0x540d45['query'][_0xb24b('0x6c')]);}})[_0xb24b('0x21')](respondWithStatusCode(_0x1a5a47,null))[_0xb24b('0x2b')](handleError(_0x1a5a47,null));};exports[_0xb24b('0x13a')]=function(_0x54e04c,_0x6c76ef,_0x2e1df7){var _0x54bf95={};var _0x5ebf86={};var _0x14a31e;var _0x2f2b99;return db[_0xb24b('0x60')][_0xb24b('0x98')]({'where':{'id':_0x54e04c['params']['id']}})[_0xb24b('0x21')](handleEntityNotFound(_0x6c76ef,null))['then'](function(_0x19b50a){if(_0x19b50a){_0x14a31e=_0x19b50a;_0x5ebf86['model']=_['keys'](db[_0xb24b('0x13b')][_0xb24b('0x67')]);_0x5ebf86[_0xb24b('0x4e')]=_['keys'](_0x54e04c[_0xb24b('0x4e')]);_0x5ebf86[_0xb24b('0x50')]=_['intersection'](_0x5ebf86[_0xb24b('0x4b')],_0x5ebf86[_0xb24b('0x4e')]);_0x54bf95[_0xb24b('0x53')]=_[_0xb24b('0x51')](_0x5ebf86['model'],qs[_0xb24b('0x52')](_0x54e04c[_0xb24b('0x4e')][_0xb24b('0x52')]));_0x54bf95[_0xb24b('0x53')]=_0x54bf95['attributes'][_0xb24b('0xaa')]?_0x54bf95[_0xb24b('0x53')]:_0x5ebf86[_0xb24b('0x4b')];_0x54bf95['order']=qs['sort'](_0x54e04c[_0xb24b('0x4e')][_0xb24b('0x57')]);_0x54bf95[_0xb24b('0x58')]=qs[_0xb24b('0x50')](_[_0xb24b('0x59')](_0x54e04c['query'],_0x5ebf86[_0xb24b('0x50')]));if(_0x54e04c[_0xb24b('0x4e')]['filter']){_0x54bf95[_0xb24b('0x58')]=_[_0xb24b('0x5a')](_0x54bf95[_0xb24b('0x58')],{'$or':_[_0xb24b('0x47')](_0x54bf95[_0xb24b('0x53')],function(_0x21625f){var _0x2d1510={};_0x2d1510[_0x21625f]={'$like':'%'+_0x54e04c[_0xb24b('0x4e')]['filter']+'%'};return _0x2d1510;})});}_0x54bf95=_[_0xb24b('0x5a')]({},_0x54bf95,_0x54e04c['options']);return _0x14a31e[_0xb24b('0x13a')](_0x54bf95);}})[_0xb24b('0x21')](function(_0x436cb2){if(_0x436cb2){_0x2f2b99=_0x436cb2[_0xb24b('0xaa')];if(!_0x54e04c['query']['hasOwnProperty'](_0xb24b('0x55'))){_0x54bf95['limit']=qs[_0xb24b('0x31')](_0x54e04c[_0xb24b('0x4e')][_0xb24b('0x31')]);_0x54bf95['offset']=qs[_0xb24b('0x30')](_0x54e04c[_0xb24b('0x4e')][_0xb24b('0x30')]);}return _0x14a31e[_0xb24b('0x13a')](_0x54bf95);}})[_0xb24b('0x21')](function(_0x32cf54){if(_0x32cf54){return _0x32cf54?{'count':_0x2f2b99,'rows':_0x32cf54}:null;}})[_0xb24b('0x21')](respondWithResult(_0x6c76ef,null))[_0xb24b('0x2b')](handleError(_0x6c76ef,null));};exports[_0xb24b('0x13c')]=function(_0x3d7ae6,_0x25fb3d,_0xf91f7e){return db[_0xb24b('0x60')][_0xb24b('0x40')]({'where':{'id':_0x3d7ae6[_0xb24b('0x66')]['id']}})['then'](handleEntityNotFound(_0x25fb3d,null))['then'](function(_0x199aa3){if(_0x199aa3){return _0x199aa3['addChatWebsites'](_0x3d7ae6[_0xb24b('0x69')][_0xb24b('0x6c')],_[_0xb24b('0x6d')](_0x3d7ae6['body'],[_0xb24b('0x6c'),'id'])||{});}})[_0xb24b('0x21')](respondWithResult(_0x25fb3d,null))['catch'](handleError(_0x25fb3d,null));};exports[_0xb24b('0x13d')]=function(_0x843212,_0x43f56b,_0x3ef0e0){return db['User'][_0xb24b('0x40')]({'where':{'id':_0x843212[_0xb24b('0x66')]['id']}})[_0xb24b('0x21')](handleEntityNotFound(_0x43f56b,null))[_0xb24b('0x21')](function(_0x24655b){if(_0x24655b){return _0x24655b[_0xb24b('0x13d')](_0x843212[_0xb24b('0x4e')][_0xb24b('0x6c')]);}})[_0xb24b('0x21')](respondWithStatusCode(_0x43f56b,null))['catch'](handleError(_0x43f56b,null));};exports['getSquareProjects']=function(_0x1afd6c,_0xe8ac80,_0x2843f4){var _0x21f362={};var _0x5c24c3={};var _0x5dca99;var _0x3106a1;return db[_0xb24b('0x60')][_0xb24b('0x98')]({'where':{'id':_0x1afd6c['params']['id']}})['then'](handleEntityNotFound(_0xe8ac80,null))[_0xb24b('0x21')](function(_0x3495f6){if(_0x3495f6){_0x5dca99=_0x3495f6;_0x5c24c3['model']=_[_0xb24b('0x4f')](db[_0xb24b('0x13e')][_0xb24b('0x67')]);_0x5c24c3[_0xb24b('0x4e')]=_[_0xb24b('0x4f')](_0x1afd6c[_0xb24b('0x4e')]);_0x5c24c3['filters']=_['intersection'](_0x5c24c3['model'],_0x5c24c3[_0xb24b('0x4e')]);_0x21f362[_0xb24b('0x53')]=_[_0xb24b('0x51')](_0x5c24c3[_0xb24b('0x4b')],qs[_0xb24b('0x52')](_0x1afd6c[_0xb24b('0x4e')][_0xb24b('0x52')]));_0x21f362[_0xb24b('0x53')]=_0x21f362[_0xb24b('0x53')]['length']?_0x21f362[_0xb24b('0x53')]:_0x5c24c3[_0xb24b('0x4b')];_0x21f362['order']=qs[_0xb24b('0x57')](_0x1afd6c[_0xb24b('0x4e')][_0xb24b('0x57')]);_0x21f362[_0xb24b('0x58')]=qs['filters'](_['pick'](_0x1afd6c[_0xb24b('0x4e')],_0x5c24c3['filters']));if(_0x1afd6c[_0xb24b('0x4e')][_0xb24b('0x3c')]){_0x21f362['where']=_[_0xb24b('0x5a')](_0x21f362[_0xb24b('0x58')],{'$or':_[_0xb24b('0x47')](_0x21f362['attributes'],function(_0x35c73b){var _0x512bd0={};_0x512bd0[_0x35c73b]={'$like':'%'+_0x1afd6c[_0xb24b('0x4e')][_0xb24b('0x3c')]+'%'};return _0x512bd0;})});}_0x21f362=_['merge']({},_0x21f362,_0x1afd6c['options']);return _0x5dca99[_0xb24b('0x13f')](_0x21f362);}})['then'](function(_0x1ef8ee){if(_0x1ef8ee){_0x3106a1=_0x1ef8ee[_0xb24b('0xaa')];if(!_0x1afd6c[_0xb24b('0x4e')][_0xb24b('0x54')]('nolimit')){_0x21f362[_0xb24b('0x31')]=qs[_0xb24b('0x31')](_0x1afd6c['query']['limit']);_0x21f362[_0xb24b('0x30')]=qs[_0xb24b('0x30')](_0x1afd6c[_0xb24b('0x4e')][_0xb24b('0x30')]);}return _0x5dca99[_0xb24b('0x13f')](_0x21f362);}})[_0xb24b('0x21')](function(_0x26c8f9){if(_0x26c8f9){return _0x26c8f9?{'count':_0x3106a1,'rows':_0x26c8f9}:null;}})[_0xb24b('0x21')](respondWithResult(_0xe8ac80,null))['catch'](handleError(_0xe8ac80,null));};exports[_0xb24b('0x140')]=function(_0x525706,_0x26acf3,_0x397db2){return db[_0xb24b('0x60')][_0xb24b('0x40')]({'where':{'id':_0x525706[_0xb24b('0x66')]['id']}})[_0xb24b('0x21')](handleEntityNotFound(_0x26acf3,null))[_0xb24b('0x21')](function(_0x54de2c){if(_0x54de2c){return _0x54de2c[_0xb24b('0x140')](_0x525706[_0xb24b('0x69')][_0xb24b('0x6c')],_['omit'](_0x525706[_0xb24b('0x69')],[_0xb24b('0x6c'),'id'])||{});}})[_0xb24b('0x21')](respondWithResult(_0x26acf3,null))[_0xb24b('0x2b')](handleError(_0x26acf3,null));};exports[_0xb24b('0x141')]=function(_0x3d2acc,_0x30290a,_0x11c170){return db[_0xb24b('0x60')][_0xb24b('0x40')]({'where':{'id':_0x3d2acc[_0xb24b('0x66')]['id']}})[_0xb24b('0x21')](handleEntityNotFound(_0x30290a,null))[_0xb24b('0x21')](function(_0x125c3c){if(_0x125c3c){return _0x125c3c['removeSquareProjects'](_0x3d2acc['query'][_0xb24b('0x6c')]);}})[_0xb24b('0x21')](respondWithStatusCode(_0x30290a,null))[_0xb24b('0x2b')](handleError(_0x30290a,null));};exports[_0xb24b('0x142')]=function(_0x3b99e8,_0x7abaa2){var _0x3824c3={},_0x251a39={},_0x4186f5={'count':0x0,'rows':[]};var _0x9bbef9=db[_0xb24b('0x143')][_0xb24b('0x67')];_0x251a39['model']=_[_0xb24b('0x4f')](_0x9bbef9);_0x251a39[_0xb24b('0x4e')]=_['keys'](_0x3b99e8[_0xb24b('0x4e')]);_0x251a39[_0xb24b('0x50')]=_['intersection'](_0x251a39[_0xb24b('0x4b')],_0x251a39['query']);_0x251a39[_0xb24b('0x50')]=_[_0xb24b('0x144')](_0x251a39[_0xb24b('0x50')],['$and',_0xb24b('0x145'),_0xb24b('0x146'),_0xb24b('0x147'),_0xb24b('0x148'),_0xb24b('0x149'),_0xb24b('0x14a'),_0xb24b('0x14b'),_0xb24b('0x14c'),_0xb24b('0x14d'),_0xb24b('0x14e'),_0xb24b('0x14f'),_0xb24b('0x150'),_0xb24b('0x151'),'$notLike','$iLike',_0xb24b('0x152'),_0xb24b('0x151'),_0xb24b('0x153'),'$contains',_0xb24b('0x154'),_0xb24b('0x155')]);_0x3824c3[_0xb24b('0x53')]=_['intersection'](_0x251a39['model'],qs[_0xb24b('0x52')](_0x3b99e8[_0xb24b('0x4e')][_0xb24b('0x52')]));_0x3824c3[_0xb24b('0x53')]=_0x3824c3[_0xb24b('0x53')][_0xb24b('0xaa')]?_0x3824c3[_0xb24b('0x53')]:_0x251a39['model'];if(!_0x3b99e8[_0xb24b('0x4e')][_0xb24b('0x54')](_0xb24b('0x55'))){_0x3824c3['limit']=qs[_0xb24b('0x31')](_0x3b99e8[_0xb24b('0x4e')][_0xb24b('0x31')]);_0x3824c3[_0xb24b('0x30')]=qs[_0xb24b('0x30')](_0x3b99e8[_0xb24b('0x4e')][_0xb24b('0x30')]);}_0x3824c3[_0xb24b('0x56')]=qs[_0xb24b('0x57')](_0x3b99e8['query'][_0xb24b('0x57')]);_0x3824c3[_0xb24b('0x58')]=qs[_0xb24b('0x50')](_[_0xb24b('0x59')](_0x3b99e8[_0xb24b('0x4e')],_0x251a39[_0xb24b('0x50')]));if(_0x3b99e8[_0xb24b('0x4e')][_0xb24b('0x3c')]){_0x3824c3[_0xb24b('0x58')]=_['merge'](_0x3824c3[_0xb24b('0x58')],{'$or':_[_0xb24b('0x47')](_0x3824c3[_0xb24b('0x53')],function(_0x5a8e4c){var _0x34597e={};_0x34597e[_0x5a8e4c]={'$like':'%'+_0x3b99e8['query'][_0xb24b('0x3c')]+'%'};return _0x34597e;})});}_0x3824c3[_0xb24b('0x58')]={'$and':[_0x3824c3[_0xb24b('0x58')],{'$or':[{'UserId':_0x3b99e8[_0xb24b('0x66')]['id']},{'OwnerId':_0x3b99e8[_0xb24b('0x66')]['id']}]}]};_0x3824c3=_[_0xb24b('0x5a')]({},_0x3824c3,_0x3b99e8['options']);var _0x1fc282={'where':_0x3824c3['where']};return db[_0xb24b('0x143')][_0xb24b('0x2f')](_0x1fc282)[_0xb24b('0x21')](function(_0x495780){_0x4186f5[_0xb24b('0x2f')]=_0x495780;if(_0x3b99e8['query'][_0xb24b('0x61')]){_0x3824c3[_0xb24b('0x62')]=[{'attributes':['id',_0xb24b('0x156'),'lastName','phone'],'model':db[_0xb24b('0x157')],'as':_0xb24b('0x158')},{'attributes':['id',_0xb24b('0x41'),_0xb24b('0x159')],'model':db[_0xb24b('0xb0')],'as':_0xb24b('0xca')}];}return db[_0xb24b('0x143')][_0xb24b('0x63')](_0x3824c3);})['then'](function(_0x19a536){_0x4186f5[_0xb24b('0x64')]=_0x19a536;return _0x4186f5;})[_0xb24b('0x21')](respondWithFilteredResult(_0x7abaa2,_0x3824c3))[_0xb24b('0x2b')](handleError(_0x7abaa2,null));};exports[_0xb24b('0x15a')]=function(_0x579d44,_0xf3ba34,_0x3bde69){if(!_[_0xb24b('0x74')](_0x579d44[_0xb24b('0x92')]['id'])&&(_0x579d44['user'][_0xb24b('0x3f')]==_0xb24b('0x6f')||_0x579d44['user'][_0xb24b('0x3f')]==_0xb24b('0x92'))){return db['User'][_0xb24b('0x98')]({'where':{'id':_0x579d44[_0xb24b('0x66')]['id']},'raw':!![]})[_0xb24b('0x21')](function(_0x162ec1){return authService[_0xb24b('0x15b')](_0x162ec1);})['then'](function(_0x464b44){if(_0x464b44){return _0xf3ba34['status'](0xc8)[_0xb24b('0x2e')]({'api_key':_0x464b44[_0xb24b('0x15c')]});}else{return _0xf3ba34[_0xb24b('0x2c')](0xcc)[_0xb24b('0x2e')]({'message':_0xb24b('0x15d')});}})[_0xb24b('0x2b')](handleError(_0xf3ba34,0x193));}else{return _0xf3ba34[_0xb24b('0x2c')](0x191)['json']({'message':_0xb24b('0x15e')});}};exports['createApiKey']=function(_0x179753,_0xd16807,_0x1c235b){if(!_[_0xb24b('0x74')](_0x179753[_0xb24b('0x92')]['id'])&&(_0x179753['user'][_0xb24b('0x3f')]==_0xb24b('0x6f')||_0x179753['user'][_0xb24b('0x3f')]==_0xb24b('0x92'))){return db['User']['find']({'where':{'id':_0x179753[_0xb24b('0x66')]['id']}})['then'](function(_0x5d4786){return authService[_0xb24b('0x15f')](_0x5d4786);})['then'](function(_0x48c6bf){return db[_0xb24b('0x60')][_0xb24b('0x36')]({'apiKeyIat':_0x48c6bf['iat'],'apiKeyNonce':_0x48c6bf[_0xb24b('0x160')]},{'where':{'id':_0x179753[_0xb24b('0x66')]['id']}})[_0xb24b('0x21')](function(){return _0xd16807['status'](0xc8)['json']({'api_key':_0x48c6bf[_0xb24b('0x15c')]});});})['catch'](handleError(_0xd16807,0x193));}else{return _0xd16807['status'](0x191)[_0xb24b('0x2e')]({'message':_0xb24b('0x15e')});}};exports[_0xb24b('0x161')]=function(_0x547018,_0x301bab,_0x5b2862){if(!_[_0xb24b('0x74')](_0x547018[_0xb24b('0x92')]['id'])&&(_0x547018[_0xb24b('0x92')]['role']==_0xb24b('0x6f')||_0x547018[_0xb24b('0x92')][_0xb24b('0x3f')]==_0xb24b('0x92'))){return db[_0xb24b('0x60')]['find']({'where':{'id':_0x547018[_0xb24b('0x66')]['id']}})[_0xb24b('0x21')](handleEntityNotFound(_0x301bab,null))[_0xb24b('0x21')](function(_0x48b60a){if(_0x48b60a&&_0x48b60a[_0xb24b('0x162')]&&_0x48b60a[_0xb24b('0x163')])return _0x48b60a;else throw{'message':'API\x20key\x20not\x20available'};})['then'](function(_0xfedacb){return db['User'][_0xb24b('0x36')]({'apiKeyNonce':null,'apiKeyIat':null},{'where':{'id':_0x547018[_0xb24b('0x66')]['id']}});})[_0xb24b('0x21')](respondWithStatusCode(_0x301bab,0xc8))[_0xb24b('0x2b')](handleError(_0x301bab,0x193));}else{return _0x301bab[_0xb24b('0x2c')](0x191)[_0xb24b('0x2e')]({'message':_0xb24b('0x15e')});}};exports[_0xb24b('0x164')]=function(_0x25009e,_0x18e93b){var _0x44f722=_0x25009e[_0xb24b('0x92')][_0xb24b('0x37')]({'plain':!![]});if(!_0x44f722){return _0x18e93b[_0xb24b('0x2c')](0x191)[_0xb24b('0x46')]('Unable\x20to\x20retrieve\x20the\x20current\x20user');}else{return _0x18e93b[_0xb24b('0x2c')](0xc8)[_0xb24b('0x2e')](_0x44f722);}};
\ No newline at end of file
+var _0x788d=['$notIn','$like','$notLike','$iLike','$notILike','$contained','$any','firstName','lastName','Contact','dialActive','getApiKey','retrieveApiKey','json','token','No\x20API\x20access\x20key\x20found!','You\x20don\x27t\x20have\x20sufficient\x20privileges\x20to\x20access\x20this\x20resource.','generateApiKey','iat','nonce','removeApiKey','apiKeyNonce','apiKeyIat','whoami','getUserSetting','teams','isEmpty','inbound','queues','lower','flatten','toString','asc','substring','uniqBy','orderBy','Unable\x20to\x20retrieve\x20RPC\x20agents\x20(AMI)','http','Unable\x20to\x20retrieve\x20RPC\x20agents\x20(Routing)','offline','idle','unknown','unavailable','voiceStatus','busy','slice','charAt','toUpperCase','field','ui.','InteractionId','ui.createdAt','user_has_','_interactions','OpenTabs','moment','util','lodash','jayson/promise','ioredis','../../components/parsers/qs','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../errors/api','APIBadRequestError','APINotFoundError','../../mysqldb','socket.io-emitter','redis','register','defaults','localhost','client','request','then','info','User,\x20%s,\x20%s','debug','request\x20sent','stringify','error','code','message','result','sendStatus','status','offset','undefined','limit','count','Content-Range','update','emit','userNotification:recalc:','destroy','get','role','admin','Users','user','Agents','agent','Telephones','telephone','ignore','map','value','includes','find','UserProfileResource','end','stack','name','send','User','fieldName','type','filter','password','salt','getOptions','query','include','userSetting','attributes','findAll','rows','openTabs','true','length','push','chat','dataValues','sms','fax','mail','openchannel','whatsapp','all','keys','rawAttributes','filters','intersection','fields','model','UserSetting','merge','options','catch','body','params','describe','addContacts','omit','internal','Setting','findById','securePassword','validatePasswordPattern','max','min_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)','sequelize','QueryTypes','SELECT','from','voicemail','mailbox','VoiceMail','email','permissions','101','102','103','113','110','104','105','106','107','108','109','100','111','114','115','create','Unauthorized','Unauthorized.\x20You\x20must\x20be\x20an\x20administrator\x20in\x20order\x20to\x20create\x20an\x20user','checkUserLimits','settingsEnabled','userProfileId','UserProfileSection','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','bulkCreate','some','Unauthorized.\x20You\x20must\x20be\x20an\x20administrator\x20in\x20order\x20to\x20create\x20an\x20administrator','changePassword','newPassword','Sequelize','ValidationError','Invalid\x20body\x20format.\x20Use\x20oldPassword\x20and\x20newPassword','authenticate','oldPassword','Wrong\x20credentials','New\x20password\x20must\x20be\x20different\x20from\x20old\x20password','Invalid\x20body\x20format.\x20Use\x20newPassword','findOne','passwordHistoryLimit','enforcePasswordHistory','previousPasswords','validatePasswordHistory','addQueues','channel','loginInPause','voicePause','interface','isValidChannel','Unknown\x20channel','add','capitalize','toLowerCase','Queues','ids','penalty','QueueId','Queue:save','voice','VoiceQueue','format','SIP/%s','UserVoiceQueueRt','upsert','removeQueues','remove','Queue:remove','addAvatar','userpic','file','filename','getAvatar','root','join','download','server/files/images/','getOpenTabs','ChatOpenTabs','CHAT','createdAt','OpenchannelOpenTabs','OPENCHANNEL','MailOpenTabs','SmsOpenTabs','WhatsappOpenTabs','CmContact','order','sort','pick','where','includeAll','CmList','Tag','tag','hasOwnProperty','nolimit','getContacts','Queue','Unknown\x20role','getVoiceQueuesRt','getGroups','ChatGroup','getRecordings','VoiceRecording','UserId','ScreenRecording','getChatInteractions','ChatInteraction','getOpenchannelInteractions','OpenchannelInteraction','MailInteraction','getSmsInteractions','SmsInteraction','getFaxInteractions','FaxInteraction','getWhatsappInteractions','WhatsappInteraction','login','phone','LOCAL/%s@from-sip/n','intrf','user:%s','user:forcelogout','headers','x-forwarded-for','connection','socket','remoteAddress','User\x20not\x20found\x20or\x20not\x20allowed\x20to\x20perform\x20login\x20method','getVoiceQueues','MemberReport','forEach','YYYY-MM-DD\x20HH:mm:ss','LOGIN','PAUSE','LOGININPAUSE','concat','logout','pause','online','QueuePause','updateAttributes','getChannels','DEFAULT\x20PAUSE','unpause','mailPause','chatPause','faxPause','smsPause','whatsappPause','pauseType','lastPauseAt','User\x20with\x20id\x20%s\x20not\x20found','getTeams','addTeams','resolve','Body\x20parameter\x20\x27ids\x27\x20is\x20required','transaction','Team','getAssociatedQueues','addAgent','getDataValue','Voice','UserVoicePrefix','VoicePrefixId','removeTeams','isArray','Query\x20parameter\x20\x27ids\x27\x20is\x20required','flattenDeep','removeAgent','TeamVoicePrefix','getLists','getAgents','values','addChatInteractions','removeChatInteractions','user_has_chat_interactions:remove','spread','user_has_mail_interactions:save','removeMailInteractions','user_has_mail_interactions:remove','addFaxInteractions','user_has_fax_interactions:save','removeFaxInteractions','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','user_has_whatsapp_interactions:save','removeWhatsappInteractions','VoicePrefix','getVoicePrefixes','getFaxAccounts','FaxAccount','addFaxAccounts','removeFaxAccounts','getMailAccounts','MailAccount','addMailAccounts','removeMailAccounts','getOpenchannelAccounts','OpenchannelAccount','addOpenchannelAccounts','removeOpenchannelAccounts','getSmsAccounts','SmsAccount','addSmsAccounts','removeSmsAccounts','getChatWebsites','ChatWebsite','addChatWebsites','removeChatWebsites','getWhatsappAccounts','WhatsappAccount','addWhatsappAccounts','removeWhatsappAccounts','getScheduledCalls','CmHopper','$and','$or','$gt','$gte','$lt','$lte','$eq','$not','$notBetween'];(function(_0x280438,_0x1a2b94){var _0x26c9d6=function(_0x1d369a){while(--_0x1d369a){_0x280438['push'](_0x280438['shift']());}};_0x26c9d6(++_0x1a2b94);}(_0x788d,0x1cd));var _0xd788=function(_0x58e797,_0xad6fd9){_0x58e797=_0x58e797-0x0;var _0x2b19fb=_0x788d[_0x58e797];return _0x2b19fb;};'use strict';var moment=require(_0xd788('0x0'));var util=require(_0xd788('0x1'));var path=require('path');var fs=require('fs');var _=require(_0xd788('0x2'));var squel=require('squel');var jayson=require(_0xd788('0x3'));var Redis=require(_0xd788('0x4'));var authService=require('../../components/auth/service');var qs=require(_0xd788('0x5'));var logger=require(_0xd788('0x6'))(_0xd788('0x7'));var utils=require(_0xd788('0x8'));var config=require(_0xd788('0x9'));var licenseUtil=require(_0xd788('0xa'));var APIBadRequestError=require(_0xd788('0xb'))[_0xd788('0xc')];var APINotFoundError=require(_0xd788('0xb'))[_0xd788('0xd')];var APIHandleError=require(_0xd788('0xb'))['handleError'];var db=require(_0xd788('0xe'))['db'];var socket=require(_0xd788('0xf'))(new Redis(config[_0xd788('0x10')]));require('./user.socket')[_0xd788('0x11')](socket);config[_0xd788('0x10')]=_[_0xd788('0x12')](config['redis'],{'host':_0xd788('0x13'),'port':0x18eb});var amiClient=jayson[_0xd788('0x14')]['http']({'port':0x232a});var values;function respondWithRpcPromise(_0x3b2d4d,_0x59efb5,_0x4fa31c,_0x2172dd){return new Promise(function(_0x2f5eeb,_0xcc278){var _0x319f96=_0x2172dd||amiClient;return _0x319f96[_0xd788('0x15')](_0x3b2d4d,_0x4fa31c)[_0xd788('0x16')](function(_0x57b20d){logger[_0xd788('0x17')](_0xd788('0x18'),_0x59efb5,'request\x20sent');logger[_0xd788('0x19')]('User,\x20%s,\x20%s,\x20%s',_0x59efb5,_0xd788('0x1a'),JSON[_0xd788('0x1b')](_0x57b20d));if(_0x57b20d[_0xd788('0x1c')]){if(_0x57b20d[_0xd788('0x1c')][_0xd788('0x1d')]===0x1f4){logger['error'](_0xd788('0x18'),_0x59efb5,_0x57b20d['error'][_0xd788('0x1e')]);return _0xcc278(_0x57b20d[_0xd788('0x1c')][_0xd788('0x1e')]);}logger[_0xd788('0x1c')](_0xd788('0x18'),_0x59efb5,_0x57b20d[_0xd788('0x1c')][_0xd788('0x1e')]);return _0x2f5eeb(_0x57b20d['error'][_0xd788('0x1e')]);}else{logger[_0xd788('0x17')]('User,\x20%s,\x20%s',_0x59efb5,'request\x20sent');_0x2f5eeb(_0x57b20d[_0xd788('0x1f')][_0xd788('0x1e')]);}})['catch'](function(_0x2e20dd){logger[_0xd788('0x1c')](_0xd788('0x18'),_0x59efb5,_0x2e20dd);_0xcc278(_0x2e20dd);});});}function respondWithStatusCode(_0x2f8b3b,_0x599aa1){_0x599aa1=_0x599aa1||0xcc;return function(_0x3d32ee){if(_0x3d32ee){return _0x2f8b3b[_0xd788('0x20')](_0x599aa1);}return _0x2f8b3b[_0xd788('0x21')](_0x599aa1)['end']();};}function respondWithResult(_0x5eedc2,_0x203b0f){_0x203b0f=_0x203b0f||0xc8;return function(_0x39fa20){if(_0x39fa20){return _0x5eedc2[_0xd788('0x21')](_0x203b0f)['json'](_0x39fa20);}};}function respondWithFilteredResult(_0x3a0635,_0x4028cb){return function(_0x207870){if(_0x207870){var _0x5912b9=typeof _0x4028cb[_0xd788('0x22')]===_0xd788('0x23')&&typeof _0x4028cb[_0xd788('0x24')]===_0xd788('0x23');var _0x1648e0=_0x207870[_0xd788('0x25')];var _0x4fa8d5=_0x5912b9?0x0:_0x4028cb[_0xd788('0x22')];var _0x4f80e3=_0x5912b9?_0x207870[_0xd788('0x25')]:_0x4028cb[_0xd788('0x22')]+_0x4028cb['limit'];var _0x4e8944;if(_0x4f80e3>=_0x1648e0){_0x4f80e3=_0x1648e0;_0x4e8944=0xc8;}else{_0x4e8944=0xce;}_0x3a0635['status'](_0x4e8944);return _0x3a0635['set'](_0xd788('0x26'),_0x4fa8d5+'-'+_0x4f80e3+'/'+_0x1648e0)['json'](_0x207870);}return null;};}function saveUpdates(_0xbc9e78){return function(_0x294cbc){if(_0x294cbc){return _0x294cbc[_0xd788('0x27')](_0xbc9e78)['then'](function(_0x508bef){socket[_0xd788('0x28')](_0xd788('0x29')+_0x508bef['id'],{});return _0x508bef;});}return null;};}function removeEntity(_0x4868de){return function(_0x1f3dea){if(_0x1f3dea){return _0x1f3dea[_0xd788('0x2a')]()[_0xd788('0x16')](function(){var _0x13c9ef=_0x1f3dea[_0xd788('0x2b')]({'plain':!![]});if(_0x13c9ef[_0xd788('0x2c')]===_0xd788('0x2d'))return;var _0x40c74a=[{'name':_0xd788('0x2e'),'value':_0xd788('0x2f'),'ignore':!![]},{'name':_0xd788('0x30'),'value':_0xd788('0x31'),'ignore':![]},{'name':_0xd788('0x32'),'value':_0xd788('0x33'),'ignore':![]}];var _0x1120d6=_(_0x40c74a)['filter'](_0xd788('0x34'))[_0xd788('0x35')](_0xd788('0x36'))[_0xd788('0x36')]();if(_[_0xd788('0x37')](_0x1120d6,_0x13c9ef[_0xd788('0x2c')])){return;}var _0xe34103=_[_0xd788('0x38')](_0x40c74a,[_0xd788('0x36'),_0x13c9ef['role']])['name'];return db[_0xd788('0x39')]['destroy']({'where':{'type':_0xe34103,'resourceId':_0x13c9ef['id']}})[_0xd788('0x16')](function(){return _0x1f3dea;});})[_0xd788('0x16')](function(){_0x4868de[_0xd788('0x21')](0xcc)[_0xd788('0x3a')]();});}};}function handleEntityNotFound(_0x278795){return function(_0x2a1ef6){if(!_0x2a1ef6){_0x278795['sendStatus'](0x194);}return _0x2a1ef6;};}function handleError(_0x1e8a60,_0x30a09f){_0x30a09f=_0x30a09f||0x1f4;return function(_0x4508b8){logger[_0xd788('0x1c')](_0x4508b8[_0xd788('0x3b')]);if(_0x4508b8[_0xd788('0x3c')]){delete _0x4508b8[_0xd788('0x3c')];}_0x1e8a60[_0xd788('0x21')](_0x30a09f)[_0xd788('0x3d')](_0x4508b8);};}exports['index']=function(_0x315c30,_0x2551af){var _0xe14e49={},_0x2c4e09={'count':0x0,'rows':[]};var _0x2e2f24=_(db[_0xd788('0x3e')]['rawAttributes'])[_0xd788('0x35')](function(_0x5a5e6f){return{'name':_0x5a5e6f[_0xd788('0x3f')],'type':_0x5a5e6f[_0xd788('0x40')]['key']};})[_0xd788('0x41')](function(_0x4369bd){return!_['includes']([_0xd788('0x42'),_0xd788('0x43')],_0x4369bd[_0xd788('0x3c')]);})['value']();_0xe14e49=qs[_0xd788('0x44')](_0x2e2f24,_0x315c30);var _0x246c53={'where':_0xe14e49['where']};return db[_0xd788('0x3e')][_0xd788('0x25')](_0x246c53)[_0xd788('0x16')](function(_0x383baf){_0x2c4e09[_0xd788('0x25')]=_0x383baf;if(_0x315c30[_0xd788('0x45')]['includeAll']){_0xe14e49[_0xd788('0x46')]=[{'all':!![]}];}if(_0x315c30[_0xd788('0x45')][_0xd788('0x47')]==='true'){_0xe14e49[_0xd788('0x46')]=[{'model':db['UserSetting'],'as':_0xd788('0x47')}];}if(!_['includes'](_0xe14e49['attributes'],'id')){_0xe14e49[_0xd788('0x48')]['push']('id');}return db[_0xd788('0x3e')][_0xd788('0x49')](_0xe14e49);})[_0xd788('0x16')](function(_0x29a489){_0x2c4e09[_0xd788('0x4a')]=_0x29a489;if(_0x315c30[_0xd788('0x45')][_0xd788('0x4b')]===_0xd788('0x4c')){var _0x3a6975=[];for(var _0x4b1934=0x0;_0x4b1934<_0x2c4e09[_0xd788('0x4a')][_0xd788('0x4d')];_0x4b1934++){_0x3a6975[_0xd788('0x4e')](get_open_tabs(_0xd788('0x4f'),_0x2c4e09[_0xd788('0x4a')][_0x4b1934][_0xd788('0x50')]));_0x3a6975[_0xd788('0x4e')](get_open_tabs(_0xd788('0x51'),_0x2c4e09[_0xd788('0x4a')][_0x4b1934][_0xd788('0x50')]));_0x3a6975['push'](get_open_tabs(_0xd788('0x52'),_0x2c4e09[_0xd788('0x4a')][_0x4b1934][_0xd788('0x50')]));_0x3a6975[_0xd788('0x4e')](get_open_tabs(_0xd788('0x53'),_0x2c4e09[_0xd788('0x4a')][_0x4b1934][_0xd788('0x50')]));_0x3a6975[_0xd788('0x4e')](get_open_tabs(_0xd788('0x54'),_0x2c4e09[_0xd788('0x4a')][_0x4b1934][_0xd788('0x50')]));_0x3a6975['push'](get_open_tabs(_0xd788('0x55'),_0x2c4e09[_0xd788('0x4a')][_0x4b1934][_0xd788('0x50')]));}return Promise[_0xd788('0x56')](_0x3a6975)['then'](function(){return _0x2c4e09;});}else{return _0x2c4e09;}})[_0xd788('0x16')](respondWithFilteredResult(_0x2551af,_0xe14e49))['catch'](handleError(_0x2551af,null));};exports['show']=function(_0x4bf98c,_0x5c793f){var _0x23877c={'raw':![],'where':{'id':_0x4bf98c['params']['id']}},_0x546cd5={};_0x546cd5['model']=_['differenceBy'](_[_0xd788('0x57')](db[_0xd788('0x3e')][_0xd788('0x58')]),[_0xd788('0x42'),_0xd788('0x43')]);_0x546cd5['query']=_['keys'](_0x4bf98c[_0xd788('0x45')]);_0x546cd5[_0xd788('0x59')]=_[_0xd788('0x5a')](_0x546cd5['model'],_0x546cd5[_0xd788('0x45')]);_0x23877c['attributes']=_['intersection'](_0x546cd5['model'],qs[_0xd788('0x5b')](_0x4bf98c['query'][_0xd788('0x5b')]));_0x23877c['attributes']=_0x23877c['attributes'][_0xd788('0x4d')]?_0x23877c[_0xd788('0x48')]:_0x546cd5[_0xd788('0x5c')];if(_0x4bf98c[_0xd788('0x45')]['includeAll']){_0x23877c['include']=[{'all':!![]}];}if(_0x4bf98c['query'][_0xd788('0x47')]===_0xd788('0x4c')){_0x23877c[_0xd788('0x46')]=[{'model':db[_0xd788('0x5d')],'as':_0xd788('0x47')}];}_0x23877c=_[_0xd788('0x5e')]({},_0x23877c,_0x4bf98c[_0xd788('0x5f')]);if(!_[_0xd788('0x37')](_0x23877c[_0xd788('0x48')],'id')){_0x23877c['attributes']['push']('id');}return db['User'][_0xd788('0x38')](_0x23877c)[_0xd788('0x16')](handleEntityNotFound(_0x5c793f,null))[_0xd788('0x16')](function(_0x30b2b7){var _0x14186f=[];values=_0x30b2b7;if(_0x4bf98c[_0xd788('0x45')]['openTabs']===_0xd788('0x4c')){_0x14186f[_0xd788('0x4e')](get_open_tabs(_0xd788('0x4f'),_0x30b2b7[_0xd788('0x50')]));_0x14186f['push'](get_open_tabs(_0xd788('0x51'),_0x30b2b7[_0xd788('0x50')]));_0x14186f[_0xd788('0x4e')](get_open_tabs('openchannel',_0x30b2b7[_0xd788('0x50')]));_0x14186f[_0xd788('0x4e')](get_open_tabs(_0xd788('0x55'),_0x30b2b7[_0xd788('0x50')]));_0x14186f[_0xd788('0x4e')](get_open_tabs(_0xd788('0x52'),_0x30b2b7[_0xd788('0x50')]));_0x14186f['push'](get_open_tabs(_0xd788('0x53'),_0x30b2b7['dataValues']));return Promise[_0xd788('0x56')](_0x14186f);}else{return values;}})[_0xd788('0x16')](function(){return values;})[_0xd788('0x16')](respondWithResult(_0x5c793f,null))[_0xd788('0x60')](handleError(_0x5c793f,null));};exports['update']=function(_0x477a74,_0x45a7cd){if(_0x477a74['body']['id']){delete _0x477a74[_0xd788('0x61')]['id'];}delete _0x477a74[_0xd788('0x61')]['role'];return db[_0xd788('0x3e')][_0xd788('0x38')]({'where':{'id':_0x477a74[_0xd788('0x62')]['id']}})[_0xd788('0x16')](handleEntityNotFound(_0x45a7cd,null))[_0xd788('0x16')](saveUpdates(_0x477a74[_0xd788('0x61')],null))[_0xd788('0x16')](respondWithResult(_0x45a7cd,null))['catch'](handleError(_0x45a7cd,null));};exports['describe']=function(_0x3fed17,_0xbdcc59){return db[_0xd788('0x3e')][_0xd788('0x63')]()[_0xd788('0x16')](respondWithResult(_0xbdcc59,null))[_0xd788('0x60')](handleError(_0xbdcc59,null));};exports[_0xd788('0x64')]=function(_0x159029,_0x4b4e39){return db[_0xd788('0x3e')]['find']({'where':{'id':_0x159029['params']['id']}})['then'](handleEntityNotFound(_0x4b4e39,null))['then'](function(_0x17462){if(_0x17462){return _0x17462['addContacts'](_0x159029[_0xd788('0x61')]['ids'],_[_0xd788('0x65')](_0x159029['body'],['ids','id'])||{});}})['then'](respondWithResult(_0x4b4e39,null))[_0xd788('0x60')](handleError(_0x4b4e39,null));};function validateUser(_0x498cf8){return new Promise(function(_0x4da1bb,_0x5e2bf9){if(_0x498cf8[_0xd788('0x66')])return _0x4da1bb(_0x498cf8);return db[_0xd788('0x67')][_0xd788('0x68')](0x1)[_0xd788('0x16')](function(_0x57654e){if(_0x57654e[_0xd788('0x69')])authService[_0xd788('0x6a')](_0x498cf8[_0xd788('0x42')]);db[_0xd788('0x3e')][_0xd788('0x6b')](_0xd788('0x66'))[_0xd788('0x16')](function(_0x4bb679){if(_['isNil'](_0x4bb679)){_0x498cf8[_0xd788('0x66')]=_0x57654e[_0xd788('0x6c')]||0x1;return;}if(_[_0xd788('0x6d')](_0x57654e[_0xd788('0x6c')])||_0x57654e['min_internal']===_0x4bb679){_0x498cf8[_0xd788('0x66')]=_0x4bb679+0x1;return;}if(_0x57654e[_0xd788('0x6c')]>_0x4bb679){_0x498cf8['internal']=_0x57654e[_0xd788('0x6c')];return;}return db['sequelize']['query'](_0xd788('0x6e'),{'type':db[_0xd788('0x6f')][_0xd788('0x70')][_0xd788('0x71')]})[_0xd788('0x16')](function(_0x249d67){if(_0x249d67&&_0x249d67[_0xd788('0x4d')]){for(var _0x2c80c5=0x0,_0x46e5e0=_0x249d67[_0xd788('0x4d')];_0x2c80c5<_0x46e5e0&&_[_0xd788('0x6d')](_0x498cf8['internal']);_0x2c80c5++){if(_0x57654e[_0xd788('0x6c')]<=_0x249d67[_0x2c80c5][_0xd788('0x72')]){_0x498cf8[_0xd788('0x66')]=_0x249d67[_0x2c80c5][_0xd788('0x72')];}else if(_0x57654e[_0xd788('0x6c')]>_0x249d67[_0x2c80c5][_0xd788('0x72')]&&_0x57654e[_0xd788('0x6c')]<=_0x249d67[_0x2c80c5]['to']){_0x498cf8[_0xd788('0x66')]=_0x57654e[_0xd788('0x6c')];}}}if(_[_0xd788('0x6d')](_0x498cf8[_0xd788('0x66')])){_0x498cf8[_0xd788('0x66')]=_0x4bb679+0x1;}return _0x4da1bb(_0x498cf8);});});})[_0xd788('0x60')](function(_0x440022){_0x5e2bf9(_0x440022);});});}function updateUser(_0x371285){return new Promise(function(_0x5889d7,_0x29eb47){try{if(_0x371285[_0xd788('0x73')]){_0x371285[_0xd788('0x74')]=_0x371285[_0xd788('0x66')];_0x371285[_0xd788('0x75')]={'mailbox':_0x371285[_0xd788('0x66')],'password':_0x371285[_0xd788('0x42')],'fullname':_0x371285['fullname'],'email':_0x371285[_0xd788('0x76')]};}if(_0x371285[_0xd788('0x2c')]===_0xd788('0x31')){if(!_0x371285[_0xd788('0x77')])_0x371285[_0xd788('0x77')]=[_0xd788('0x78'),_0xd788('0x79'),_0xd788('0x7a'),_0xd788('0x7b'),_0xd788('0x7c'),_0xd788('0x7d'),_0xd788('0x7e'),_0xd788('0x7f'),_0xd788('0x80'),_0xd788('0x81'),_0xd788('0x82'),_0xd788('0x83'),_0xd788('0x84'),_0xd788('0x85'),_0xd788('0x86')];}_0x5889d7(_0x371285);}catch(_0x1f7681){_0x29eb47(_0x1f7681);}});}exports[_0xd788('0x87')]=function(_0x5e7f1f,_0x1e14e9){if(_0x5e7f1f['user'][_0xd788('0x2c')]===_0xd788('0x31'))throw new Error(_0xd788('0x88'));if(_0x5e7f1f['body'][_0xd788('0x2c')]===_0xd788('0x2f')&&_0x5e7f1f[_0xd788('0x2f')][_0xd788('0x2c')]!==_0xd788('0x2d')){throw new Error(_0xd788('0x89'));}if(_0x5e7f1f['body']['role']==='admin'&&_0x5e7f1f['user'][_0xd788('0x2c')]!==_0xd788('0x2d')){throw new Error('Unauthorized.\x20You\x20must\x20be\x20an\x20administrator\x20in\x20order\x20to\x20create\x20another\x20administrator');}return licenseUtil[_0xd788('0x8a')]([_0x5e7f1f[_0xd788('0x61')]])[_0xd788('0x16')](function(){return validateUser(_0x5e7f1f['body']);})[_0xd788('0x16')](function(_0x27401f){return updateUser(_0x27401f)[_0xd788('0x16')](function(_0x4cd5b6){if(_0x4cd5b6[_0xd788('0x2c')]===_0xd788('0x2d')){_0x4cd5b6[_0xd788('0x8b')]=_0x5e7f1f['user']['settingsEnabled'];delete _0x4cd5b6[_0xd788('0x8c')];}return _0x4cd5b6;});})[_0xd788('0x16')](function(_0x4ba90e){return db[_0xd788('0x3e')]['create'](_0x4ba90e,{'include':[{'model':db[_0xd788('0x75')],'as':_0xd788('0x75')}]});})[_0xd788('0x16')](function(_0x11a695){if(_0x5e7f1f[_0xd788('0x61')][_0xd788('0x2c')]===_0xd788('0x2f'))return _0x11a695;if(_0x5e7f1f[_0xd788('0x2f')][_0xd788('0x2c')]!==_0xd788('0x2f'))return _0x11a695;return db[_0xd788('0x8d')][_0xd788('0x38')]({'where':{'name':_0x11a695[_0xd788('0x2c')]===_0xd788('0x31')?_0xd788('0x30'):_0xd788('0x32'),'userProfileId':_0x5e7f1f[_0xd788('0x2f')]['userProfileId']},'raw':!![]})['then'](function(_0x4bc18a){if(!_0x4bc18a||_0x4bc18a[_0xd788('0x8e')]!=0x0)return _0x11a695;return db[_0xd788('0x39')]['create']({'name':_0x11a695[_0xd788('0x3c')],'resourceId':_0x11a695['id'],'type':_0x4bc18a[_0xd788('0x3c')],'sectionId':_0x4bc18a['id']},{})['then'](function(){return _0x11a695;});})['catch'](function(_0x5c5145){logger['error'](_0xd788('0x8f'),_0x5c5145);throw _0x5c5145;});})[_0xd788('0x16')](respondWithResult(_0x1e14e9,0xc9))['catch'](handleError(_0x1e14e9,null));};exports[_0xd788('0x90')]=function(_0x2f4c31,_0x19e57d){var _0x3683da=_0x2f4c31['body'];var _0x3e9a7d=[];if(_0x2f4c31[_0xd788('0x2f')][_0xd788('0x2c')]===_0xd788('0x31'))throw new Error(_0xd788('0x88'));if(_[_0xd788('0x91')](_0x3683da,[_0xd788('0x2c'),_0xd788('0x2f')])&&_0x2f4c31[_0xd788('0x2f')][_0xd788('0x2c')]!=='admin'){throw new Error(_0xd788('0x89'));}if(_[_0xd788('0x91')](_0x3683da,[_0xd788('0x2c'),_0xd788('0x2d')])&&_0x2f4c31[_0xd788('0x2f')][_0xd788('0x2c')]!==_0xd788('0x2d')){throw new Error(_0xd788('0x92'));}return licenseUtil[_0xd788('0x8a')](_0x3683da)[_0xd788('0x16')](function(){return validateUser(_0x3683da[0x0]);})[_0xd788('0x16')](function(){for(var _0x1dfbc3=0x1;_0x1dfbc3<_0x3683da['length'];_0x1dfbc3++){var _0x4aa703=_0x3683da[_0x1dfbc3-0x1][_0xd788('0x66')];if(!_0x3683da[_0x1dfbc3][_0xd788('0x66')])_0x3683da[_0x1dfbc3][_0xd788('0x66')]=_0x4aa703+0x1;_0x3e9a7d['push'](validateUser(_0x3683da[_0x1dfbc3]));}return Promise['all'](_0x3e9a7d);})[_0xd788('0x16')](function(){_0x3e9a7d=[];for(var _0x2ebaec=0x0;_0x2ebaec<_0x3683da[_0xd788('0x4d')];_0x2ebaec++){_0x3e9a7d[_0xd788('0x4e')](updateUser(_0x3683da[_0x2ebaec]));}return Promise[_0xd788('0x56')](_0x3e9a7d);})[_0xd788('0x16')](function(){_0x3e9a7d=_0x3683da[_0xd788('0x35')](function(_0x257316){return db['User'][_0xd788('0x87')](_0x257316,{'include':[{'model':db[_0xd788('0x75')],'as':'VoiceMail'}]})['then'](function(_0x31789b){_0x257316['id']=_0x31789b['id'];return _0x257316;});});return Promise[_0xd788('0x56')](_0x3e9a7d);})['then'](function(_0x52d15f){if(_0x2f4c31[_0xd788('0x61')][_0xd788('0x2c')]===_0xd788('0x2f'))return _0x52d15f;if(_0x2f4c31[_0xd788('0x2f')][_0xd788('0x2c')]!==_0xd788('0x2f'))return _0x52d15f;var _0x3f1414=_[_0xd788('0x91')](_0x52d15f,function(_0x8a4ae0){return _0x8a4ae0[_0xd788('0x2c')]===_0xd788('0x31')||_0x8a4ae0['role']===_0xd788('0x33');});if(!_0x3f1414)return _0x52d15f;return db[_0xd788('0x8d')][_0xd788('0x49')]({'where':{'name':{'$or':['Agents','Telephones']},'userProfileId':_0x2f4c31[_0xd788('0x2f')]['userProfileId']},'raw':!![]})[_0xd788('0x16')](function(_0x1df4f3){if(_['isEmpty'](_0x1df4f3)||!_[_0xd788('0x91')](_0x1df4f3,[_0xd788('0x8e'),0x0]))return _0x52d15f;_0x3e9a7d=[];var _0x29e678=_(_0x1df4f3)[_0xd788('0x35')](function(_0x3355ce){if(_0x3355ce['autoAssociation']===0x1)return;return _0x3355ce['name']==='Agents'?_0xd788('0x31'):_0xd788('0x33');})['compact']()[_0xd788('0x36')]();for(var _0x58accd=0x0;_0x58accd<_0x52d15f[_0xd788('0x4d')];_0x58accd++){if(!_[_0xd788('0x37')](_0x29e678,_0x52d15f[_0x58accd][_0xd788('0x2c')]))return;var _0x24a9ce=_0x52d15f[_0x58accd][_0xd788('0x2c')]===_0xd788('0x31')?'Agents':_0xd788('0x32');_0x3e9a7d[_0xd788('0x4e')](db[_0xd788('0x39')][_0xd788('0x87')]({'name':_0x52d15f[_0x58accd]['name'],'resourceId':_0x52d15f[_0x58accd]['id'],'type':_0x24a9ce,'sectionId':_['find'](_0x1df4f3,[_0xd788('0x3c'),_0x24a9ce])['id']},{}));}return Promise['all'](_0x3e9a7d);});})[_0xd788('0x16')](respondWithResult(_0x19e57d,0xc9))['catch'](handleError(_0x19e57d,null));};exports[_0xd788('0x93')]=function(_0x1f2beb,_0x4f07c8){if(_0x1f2beb[_0xd788('0x61')]['id']){delete _0x1f2beb[_0xd788('0x61')]['id'];}return db[_0xd788('0x3e')][_0xd788('0x38')]({'where':{'id':_0x1f2beb[_0xd788('0x62')]['id']}})[_0xd788('0x16')](function(_0x5542a7){if(!_0x5542a7)return null;if(_0x5542a7['id']===_0x1f2beb[_0xd788('0x2f')]['id']){if(!_0x1f2beb[_0xd788('0x61')]['oldPassword']||!_0x1f2beb['body'][_0xd788('0x94')]){throw new db[(_0xd788('0x95'))][(_0xd788('0x96'))](_0xd788('0x97'));}if(!_0x5542a7[_0xd788('0x98')](_0x1f2beb['body'][_0xd788('0x99')])){throw new db[(_0xd788('0x95'))][(_0xd788('0x96'))](_0xd788('0x9a'));}if(_0x1f2beb[_0xd788('0x61')]['oldPassword']===_0x1f2beb[_0xd788('0x61')][_0xd788('0x94')]){throw new db[(_0xd788('0x95'))][(_0xd788('0x96'))](_0xd788('0x9b'));}}else if(_0x1f2beb[_0xd788('0x2f')][_0xd788('0x2c')]===_0xd788('0x2d')){if(!_0x1f2beb[_0xd788('0x61')]['newPassword']){throw new db[(_0xd788('0x95'))][(_0xd788('0x96'))]('Invalid\x20body\x20format.\x20Use\x20newPassword');}}else if(_0x1f2beb[_0xd788('0x2f')][_0xd788('0x2c')]===_0xd788('0x2f')){if(!_0x1f2beb[_0xd788('0x61')][_0xd788('0x94')]){throw new db[(_0xd788('0x95'))][(_0xd788('0x96'))](_0xd788('0x9c'));}if(_0x5542a7['role']!==_0xd788('0x31')){throw new db[(_0xd788('0x95'))][(_0xd788('0x96'))](_0xd788('0x88'));}}else{throw new db[(_0xd788('0x95'))][(_0xd788('0x96'))]('Unauthorized');}return _0x5542a7;})[_0xd788('0x16')](handleEntityNotFound(_0x4f07c8,null))[_0xd788('0x16')](function(_0x34802e){return db['Setting'][_0xd788('0x9d')]({'attributes':['id',_0xd788('0x69'),'enforcePasswordHistory',_0xd788('0x9e')]})['then'](function(_0x5a0515){if(_0x5a0515[_0xd788('0x69')])authService['validatePasswordPattern'](_0x1f2beb[_0xd788('0x61')][_0xd788('0x94')]);if(!_0x5a0515[_0xd788('0x9f')]||!_0x34802e[_0xd788('0xa0')])return _0x34802e;authService[_0xd788('0xa1')](_0x1f2beb[_0xd788('0x61')][_0xd788('0x94')],_0x34802e[_0xd788('0xa0')],_0x5a0515[_0xd788('0x9e')]);return _0x34802e;})[_0xd788('0x16')](saveUpdates({'password':_0x1f2beb[_0xd788('0x61')][_0xd788('0x94')],'passwordResetAt':_0x1f2beb[_0xd788('0x2f')]['id']==_0x1f2beb['params']['id']?moment():null,'previousPasswords':authService['updatePasswordsHistory'](_0x1f2beb[_0xd788('0x61')][_0xd788('0x94')],_0x34802e[_0xd788('0xa0')])},null));})['then'](respondWithResult(_0x4f07c8,null))[_0xd788('0x60')](handleError(_0x4f07c8,null));};exports[_0xd788('0xa2')]=function(_0x25713d,_0x1e55f9){var _0x31f88f=_0x25713d[_0xd788('0x61')][_0xd788('0xa3')];return db[_0xd788('0x3e')][_0xd788('0x38')]({'where':{'id':_0x25713d['params']['id']},'attributes':['id',_0xd788('0x3c'),_0xd788('0x2c'),'online',_0xd788('0xa4'),_0xd788('0xa5'),_0xd788('0xa6')]})[_0xd788('0x16')](handleEntityNotFound(_0x1e55f9,null))[_0xd788('0x16')](function(_0x3d125a){if(_0x3d125a){if(!utils[_0xd788('0xa7')](_0x31f88f)){throw new db['Sequelize'][(_0xd788('0x96'))](_0xd788('0xa8'));}return _0x3d125a[_0xd788('0xa9')+_[_0xd788('0xaa')](_0x31f88f[_0xd788('0xab')]())+_0xd788('0xac')](_0x25713d[_0xd788('0x61')][_0xd788('0xad')],{'penalty':_0x25713d[_0xd788('0x61')][_0xd788('0xae')]||0x0})['spread'](function(_0xf9ed56){for(var _0x422408=0x0;_0x422408<_0x25713d['body'][_0xd788('0xad')][_0xd788('0x4d')];_0x422408+=0x1){var _0x2fb381={'UserId':Number(_0x25713d[_0xd788('0x62')]['id'])};_0x2fb381[_[_0xd788('0xaa')](_0x31f88f[_0xd788('0xab')]())+_0xd788('0xaf')]=Number(_0x25713d[_0xd788('0x61')][_0xd788('0xad')][_0x422408]);socket[_0xd788('0x28')](_0xd788('0x2f')+_['capitalize'](_0x31f88f[_0xd788('0xab')]())+_0xd788('0xb0'),_0x2fb381);}return _0xf9ed56;})[_0xd788('0x16')](function(){if(_0x31f88f===_0xd788('0xb1')){return db[_0xd788('0xb2')][_0xd788('0x49')]({'where':{'id':_0x25713d[_0xd788('0x61')][_0xd788('0xad')]||[]},'raw':!![],'attributes':['id',_0xd788('0x3c')]});}})[_0xd788('0x16')](function(_0x4cfb7e){var _0x2c657b=_0x3d125a[_0xd788('0x2b')]({'plain':!![]});var _0x53046f=[];if(_0x31f88f===_0xd788('0xb1')&&_0x2c657b[_0xd788('0x2c')]===_0xd788('0x31')&&_0x2c657b['online']){for(let _0x40c5c6=0x0;_0x40c5c6<_0x4cfb7e[_0xd788('0x4d')];_0x40c5c6+=0x1){_0x53046f[_0xd788('0x4e')]({'membername':_0x2c657b[_0xd788('0x3c')],'UserId':_0x2c657b['id'],'queue_name':_0x4cfb7e[_0x40c5c6]['name'],'VoiceQueueId':_0x4cfb7e[_0x40c5c6]['id'],'interface':_[_0xd788('0x6d')](_0x2c657b[_0xd788('0xa6')])?util[_0xd788('0xb3')](_0xd788('0xb4'),_0x2c657b[_0xd788('0x3c')]):_0x2c657b[_0xd788('0xa6')],'paused':_0x2c657b[_0xd788('0xa5')]||![],'penalty':_0x25713d['body'][_0xd788('0xae')]||0x0});}return Promise['all'](_0x53046f['map'](function(_0x70e18c){return db[_0xd788('0xb5')][_0xd788('0xb6')](_0x70e18c);}));}return _0x3d125a;});}})[_0xd788('0x16')](respondWithStatusCode(_0x1e55f9,null))['catch'](handleError(_0x1e55f9,null));};exports[_0xd788('0xb7')]=function(_0x546054,_0x234cb8){var _0x2b51ab,_0x283a3e;return db[_0xd788('0x3e')][_0xd788('0x38')]({'where':{'id':_0x546054['params']['id']},'attributes':['id',_0xd788('0x3c'),_0xd788('0x2c')]})[_0xd788('0x16')](handleEntityNotFound(_0x234cb8,null))[_0xd788('0x16')](function(_0x33ec08){if(_0x33ec08){_0x2b51ab=_0x33ec08;if(!_0x546054[_0xd788('0x45')][_0xd788('0xa3')]||!utils[_0xd788('0xa7')](_0x546054[_0xd788('0x45')][_0xd788('0xa3')])){throw new db[(_0xd788('0x95'))][(_0xd788('0x96'))](_0xd788('0xa8'));}return _0x33ec08[_0xd788('0xb8')+_['capitalize'](_0x546054['query'][_0xd788('0xa3')][_0xd788('0xab')]())+_0xd788('0xac')](_0x546054[_0xd788('0x45')][_0xd788('0xad')]);}})[_0xd788('0x16')](function(_0x57a943){if(_['isArray'](_0x546054[_0xd788('0x45')][_0xd788('0xad')])){for(var _0x1a2230=0x0;_0x1a2230<_0x546054[_0xd788('0x45')][_0xd788('0xad')][_0xd788('0x4d')];_0x1a2230+=0x1){_0x283a3e={'UserId':Number(_0x546054[_0xd788('0x62')]['id'])};_0x283a3e[_[_0xd788('0xaa')](_0x546054['query'][_0xd788('0xa3')][_0xd788('0xab')]())+_0xd788('0xaf')]=Number(_0x546054[_0xd788('0x45')][_0xd788('0xad')][_0x1a2230]);socket[_0xd788('0x28')](_0xd788('0x2f')+_[_0xd788('0xaa')](_0x546054[_0xd788('0x45')][_0xd788('0xa3')]['toLowerCase']())+_0xd788('0xb9'),_0x283a3e);}}else{_0x283a3e={'UserId':Number(_0x546054['params']['id'])};_0x283a3e[_['capitalize'](_0x546054[_0xd788('0x45')][_0xd788('0xa3')][_0xd788('0xab')]())+_0xd788('0xaf')]=Number(_0x546054[_0xd788('0x45')]['ids']);socket[_0xd788('0x28')](_0xd788('0x2f')+_[_0xd788('0xaa')](_0x546054[_0xd788('0x45')][_0xd788('0xa3')][_0xd788('0xab')]())+_0xd788('0xb9'),_0x283a3e);}return _0x57a943;})['then'](function(){if(_0x546054[_0xd788('0x45')]['channel']==='voice'){return db[_0xd788('0xb5')]['destroy']({'where':{'UserId':_0x546054[_0xd788('0x62')]['id'],'VoiceQueueId':_0x546054[_0xd788('0x45')]['ids']},'individualHooks':!![]})[_0xd788('0x16')](function(){return _0x2b51ab;});}return _0x2b51ab;})[_0xd788('0x16')](respondWithStatusCode(_0x234cb8,null))[_0xd788('0x60')](handleError(_0x234cb8,null));};exports[_0xd788('0xba')]=function(_0x219fbe,_0x3d3a2a){_0x219fbe[_0xd788('0x61')][_0xd788('0xbb')]=_0x219fbe[_0xd788('0xbc')][_0xd788('0xbd')];return db['User'][_0xd788('0x38')]({'where':{'id':_0x219fbe[_0xd788('0x62')]['id']}})[_0xd788('0x16')](handleEntityNotFound(_0x3d3a2a,null))[_0xd788('0x16')](saveUpdates(_0x219fbe['body'],null))[_0xd788('0x16')](respondWithResult(_0x3d3a2a,null))[_0xd788('0x60')](handleError(_0x3d3a2a,null));};exports[_0xd788('0xbe')]=function(_0x3b1b18,_0x28ec72){var _0x4ac0ec=path['join'](config[_0xd788('0xbf')],'server/files/images/logos/default_profile.png');return db[_0xd788('0x3e')][_0xd788('0x38')]({'where':{'id':_0x3b1b18[_0xd788('0x62')]['id']},'attributes':['id','userpic'],'raw':!![]})['then'](handleEntityNotFound(_0x28ec72,null))[_0xd788('0x16')](function(_0x1ec37d){if(_0x1ec37d){if(_[_0xd788('0x6d')](_0x1ec37d[_0xd788('0xbb')])){return _0x28ec72['download'](_0x4ac0ec);}else{if(!fs['existsSync'](path[_0xd788('0xc0')](config['root'],'server/files/images/',_0x1ec37d[_0xd788('0xbb')]))){return _0x28ec72['download'](_0x4ac0ec);}return _0x28ec72[_0xd788('0xc1')](path[_0xd788('0xc0')](config[_0xd788('0xbf')],_0xd788('0xc2'),_0x1ec37d[_0xd788('0xbb')]));}}})[_0xd788('0x60')](handleError(_0x28ec72,null));};exports[_0xd788('0xc3')]=function(_0x188df2,_0x4d0ee3){return db[_0xd788('0x3e')][_0xd788('0x38')]({'where':{'id':_0x188df2[_0xd788('0x62')]['id']},'attributes':['id']})[_0xd788('0x16')](handleEntityNotFound(_0x4d0ee3,null))[_0xd788('0x16')](function(_0x3d362a){var _0x3e72a4=[];values=_0x3d362a[_0xd788('0x50')];_0x3e72a4[_0xd788('0x4e')](get_open_tabs(_0xd788('0x4f'),_0x3d362a[_0xd788('0x50')]));_0x3e72a4[_0xd788('0x4e')](get_open_tabs(_0xd788('0x51'),_0x3d362a[_0xd788('0x50')]));_0x3e72a4[_0xd788('0x4e')](get_open_tabs('openchannel',_0x3d362a[_0xd788('0x50')]));_0x3e72a4[_0xd788('0x4e')](get_open_tabs(_0xd788('0x55'),_0x3d362a['dataValues']));_0x3e72a4[_0xd788('0x4e')](get_open_tabs(_0xd788('0x52'),_0x3d362a[_0xd788('0x50')]));_0x3e72a4['push'](get_open_tabs(_0xd788('0x53'),_0x3d362a['dataValues']));return Promise[_0xd788('0x56')](_0x3e72a4);})[_0xd788('0x16')](function(_0x3ad186){if(_0x3ad186){var _0x171def=_[_0xd788('0x35')](values[_0xd788('0xc4')],function(_0x1f4dc1){return{'channel':_0xd788('0xc5'),'id':_0x1f4dc1['id'],'createdAt':_0x1f4dc1[_0xd788('0xc6')]};});var _0x4464c9=_[_0xd788('0x35')](values['FaxOpenTabs'],function(_0x380ac0){return{'channel':'FAX','id':_0x380ac0['id'],'createdAt':_0x380ac0[_0xd788('0xc6')]};});var _0x483cf2=_[_0xd788('0x35')](values[_0xd788('0xc7')],function(_0x37d14f){return{'channel':_0xd788('0xc8'),'id':_0x37d14f['id'],'createdAt':_0x37d14f[_0xd788('0xc6')]};});var _0x4482d4=_[_0xd788('0x35')](values[_0xd788('0xc9')],function(_0x5f5d28){return{'channel':'MAIL','id':_0x5f5d28['id'],'createdAt':_0x5f5d28[_0xd788('0xc6')]};});var _0x2104bb=_[_0xd788('0x35')](values[_0xd788('0xca')],function(_0x24bd85){return{'channel':'SMS','id':_0x24bd85['id'],'createdAt':_0x24bd85[_0xd788('0xc6')]};});var _0x1c108a=_['map'](values[_0xd788('0xcb')],function(_0xd88ad0){return{'channel':'WHATSAPP','id':_0xd88ad0['id'],'createdAt':_0xd88ad0[_0xd788('0xc6')]};});var _0x26f7a6=_['concat'](_0x171def,_0x4464c9,_0x483cf2,_0x4482d4,_0x2104bb,_0x1c108a);var _0x55d0fc={'count':_0x26f7a6[_0xd788('0x4d')],'rows':_0x26f7a6};return _0x55d0fc;}else return null;})[_0xd788('0x16')](respondWithResult(_0x4d0ee3,null))[_0xd788('0x60')](handleError(_0x4d0ee3,null));};exports['getContacts']=function(_0x29eb33,_0x1a7708){var _0x4a7686={};var _0x351a92={};var _0xda768c;var _0x437850;return db[_0xd788('0x3e')][_0xd788('0x9d')]({'where':{'id':_0x29eb33['params']['id']}})['then'](handleEntityNotFound(_0x1a7708,null))[_0xd788('0x16')](function(_0x39b233){if(_0x39b233){_0xda768c=_0x39b233;_0x351a92[_0xd788('0x5c')]=_[_0xd788('0x57')](db[_0xd788('0xcc')][_0xd788('0x58')]);_0x351a92[_0xd788('0x45')]=_['keys'](_0x29eb33['query']);_0x351a92['filters']=_[_0xd788('0x5a')](_0x351a92['model'],_0x351a92['query']);_0x4a7686[_0xd788('0x48')]=_[_0xd788('0x5a')](_0x351a92['model'],qs[_0xd788('0x5b')](_0x29eb33[_0xd788('0x45')][_0xd788('0x5b')]));_0x4a7686[_0xd788('0x48')]=_0x4a7686[_0xd788('0x48')][_0xd788('0x4d')]?_0x4a7686[_0xd788('0x48')]:_0x351a92['model'];_0x4a7686[_0xd788('0xcd')]=qs[_0xd788('0xce')](_0x29eb33['query'][_0xd788('0xce')]);_0x4a7686['where']=qs[_0xd788('0x59')](_[_0xd788('0xcf')](_0x29eb33[_0xd788('0x45')],_0x351a92[_0xd788('0x59')]));if(_0x29eb33['query'][_0xd788('0x41')]){_0x4a7686[_0xd788('0xd0')]=_[_0xd788('0x5e')](_0x4a7686[_0xd788('0xd0')],{'$or':_[_0xd788('0x35')](_0x4a7686['attributes'],function(_0x19262c){var _0xaecd42={};_0xaecd42[_0x19262c]={'$like':'%'+_0x29eb33[_0xd788('0x45')]['filter']+'%'};return _0xaecd42;})});}_0x4a7686=_[_0xd788('0x5e')]({},_0x4a7686,_0x29eb33[_0xd788('0x5f')]);return _0xda768c['getContacts'](_0x4a7686);}})['then'](function(_0x5b52c9){if(_0x5b52c9){_0x437850=_0x5b52c9[_0xd788('0x4d')];if(_0x29eb33['query']['hasOwnProperty'](_0xd788('0xd1'))){_0x4a7686['include']=[{'model':db[_0xd788('0xd2')],'as':'List','required':![]},{'model':db[_0xd788('0xd3')],'as':'Tags','attributes':['id',_0xd788('0x3c'),'color'],'where':_0x29eb33[_0xd788('0x45')][_0xd788('0xd4')]?{'id':_0x29eb33['query'][_0xd788('0xd4')]}:undefined,'required':_0x29eb33[_0xd788('0x45')]['tag']?!![]:![]}];}if(!_0x29eb33[_0xd788('0x45')][_0xd788('0xd5')](_0xd788('0xd6'))){_0x4a7686[_0xd788('0x24')]=qs[_0xd788('0x24')](_0x29eb33['query'][_0xd788('0x24')]);_0x4a7686[_0xd788('0x22')]=qs[_0xd788('0x22')](_0x29eb33[_0xd788('0x45')]['offset']);}return _0xda768c[_0xd788('0xd7')](_0x4a7686);}})[_0xd788('0x16')](function(_0x398eab){if(_0x398eab){return _0x398eab?{'count':_0x437850,'rows':_0x398eab}:null;}})[_0xd788('0x16')](respondWithResult(_0x1a7708,null))['catch'](handleError(_0x1a7708,null));};exports['getQueues']=function(_0x5bf23f,_0x472316){var _0x9e19fe;var _0x252ff4={};var _0x3ecf8b;return db['User'][_0xd788('0x9d')]({'where':{'id':_0x5bf23f['params']['id']},'attributes':['id',_0xd788('0x3c'),_0xd788('0x2c')]})['then'](handleEntityNotFound(_0x472316,null))[_0xd788('0x16')](function(_0x54dbde){if(!utils['isValidChannel'](_0x5bf23f[_0xd788('0x45')]['channel'])){throw new db['Sequelize'][(_0xd788('0x96'))](_0xd788('0xa8'));}_0x9e19fe=_0x54dbde;var _0x3fb6ac={};_0x3fb6ac[_0xd788('0x5c')]=_[_0xd788('0x57')](db[_['capitalize'](_0x5bf23f[_0xd788('0x45')][_0xd788('0xa3')])+_0xd788('0xd8')][_0xd788('0x58')]);_0x3fb6ac[_0xd788('0x45')]=_[_0xd788('0x57')](_0x5bf23f['query']);_0x3fb6ac[_0xd788('0x59')]=_['intersection'](_0x3fb6ac['model'],_0x3fb6ac[_0xd788('0x45')]);_0x252ff4['attributes']=_[_0xd788('0x5a')](_0x3fb6ac['model'],qs[_0xd788('0x5b')](_0x5bf23f[_0xd788('0x45')][_0xd788('0x5b')]));_0x252ff4[_0xd788('0x48')]=_0x252ff4[_0xd788('0x48')][_0xd788('0x4d')]?_0x252ff4['attributes']:_0x3fb6ac[_0xd788('0x5c')];_0x252ff4[_0xd788('0xcd')]=qs[_0xd788('0xce')](_0x5bf23f['query'][_0xd788('0xce')]);_0x252ff4['where']=qs[_0xd788('0x59')](_[_0xd788('0xcf')](_0x5bf23f['query'],_0x3fb6ac[_0xd788('0x59')]));if(_0x5bf23f[_0xd788('0x45')][_0xd788('0x41')]){_0x252ff4[_0xd788('0xd0')]=_[_0xd788('0x5e')](_0x252ff4[_0xd788('0xd0')],{'$or':_['map'](_0x252ff4[_0xd788('0x48')],function(_0x527ed0){var _0x57beb7={};_0x57beb7[_0x527ed0]={'$like':'%'+_0x5bf23f[_0xd788('0x45')][_0xd788('0x41')]+'%'};return _0x57beb7;})});}_0x252ff4=_[_0xd788('0x5e')]({},_0x252ff4,_0x5bf23f[_0xd788('0x5f')]);switch(_0x9e19fe[_0xd788('0x2c')]){case _0xd788('0x2d'):return db[_[_0xd788('0xaa')](_0x5bf23f[_0xd788('0x45')][_0xd788('0xa3')])+_0xd788('0xd8')]['findAll'](_0x252ff4);case'user':case'agent':return _0x9e19fe[_0xd788('0x2b')+_[_0xd788('0xaa')](_0x5bf23f[_0xd788('0x45')][_0xd788('0xa3')])+_0xd788('0xac')](_0x252ff4);default:throw new db[(_0xd788('0x95'))][(_0xd788('0x96'))](_0xd788('0xd9'));}})['then'](function(_0x2638d3){_0x3ecf8b=_0x2638d3['length'];if(!_0x5bf23f[_0xd788('0x45')]['hasOwnProperty'](_0xd788('0xd6'))){_0x252ff4[_0xd788('0x24')]=qs['limit'](_0x5bf23f['query'][_0xd788('0x24')]);_0x252ff4[_0xd788('0x22')]=qs[_0xd788('0x22')](_0x5bf23f['query'][_0xd788('0x22')]);}switch(_0x9e19fe[_0xd788('0x2c')]){case'admin':return db[_[_0xd788('0xaa')](_0x5bf23f[_0xd788('0x45')][_0xd788('0xa3')])+_0xd788('0xd8')][_0xd788('0x49')](_0x252ff4);case'user':case _0xd788('0x31'):return _0x9e19fe[_0xd788('0x2b')+_[_0xd788('0xaa')](_0x5bf23f[_0xd788('0x45')][_0xd788('0xa3')])+_0xd788('0xac')](_0x252ff4);}})[_0xd788('0x16')](function(_0x142754){return{'count':_0x3ecf8b,'rows':_0x142754};})[_0xd788('0x16')](respondWithResult(_0x472316,null))[_0xd788('0x60')](handleError(_0x472316,null));};exports[_0xd788('0xda')]=function(_0x14aba4,_0x2b8bbc){var _0x5a2461={};var _0x2b5a4d={};var _0x21b72e;var _0x22f4c8;return db[_0xd788('0x3e')][_0xd788('0x9d')]({'where':{'id':_0x14aba4[_0xd788('0x62')]['id']}})['then'](handleEntityNotFound(_0x2b8bbc,null))[_0xd788('0x16')](function(_0x5dcc80){if(_0x5dcc80){_0x21b72e=_0x5dcc80;_0x2b5a4d[_0xd788('0x5c')]=_['keys'](db[_0xd788('0xb5')][_0xd788('0x58')]);_0x2b5a4d[_0xd788('0x45')]=_['keys'](_0x14aba4[_0xd788('0x45')]);_0x2b5a4d[_0xd788('0x59')]=_[_0xd788('0x5a')](_0x2b5a4d['model'],_0x2b5a4d[_0xd788('0x45')]);_0x5a2461['attributes']=_['intersection'](_0x2b5a4d[_0xd788('0x5c')],qs[_0xd788('0x5b')](_0x14aba4['query'][_0xd788('0x5b')]));_0x5a2461['attributes']=_0x5a2461['attributes']['length']?_0x5a2461[_0xd788('0x48')]:_0x2b5a4d['model'];_0x5a2461[_0xd788('0xcd')]=qs[_0xd788('0xce')](_0x14aba4[_0xd788('0x45')]['sort']);_0x5a2461[_0xd788('0xd0')]=qs[_0xd788('0x59')](_[_0xd788('0xcf')](_0x14aba4[_0xd788('0x45')],_0x2b5a4d[_0xd788('0x59')]));if(_0x14aba4[_0xd788('0x45')]['filter']){_0x5a2461[_0xd788('0xd0')]=_[_0xd788('0x5e')](_0x5a2461[_0xd788('0xd0')],{'$or':_[_0xd788('0x35')](_0x5a2461['attributes'],function(_0x153042){var _0x361da6={};_0x361da6[_0x153042]={'$like':'%'+_0x14aba4[_0xd788('0x45')][_0xd788('0x41')]+'%'};return _0x361da6;})});}_0x5a2461=_[_0xd788('0x5e')]({},_0x5a2461,_0x14aba4['options']);return _0x21b72e[_0xd788('0xda')](_0x5a2461);}})[_0xd788('0x16')](function(_0x383de7){if(_0x383de7){_0x22f4c8=_0x383de7[_0xd788('0x4d')];if(!_0x14aba4[_0xd788('0x45')][_0xd788('0xd5')](_0xd788('0xd6'))){_0x5a2461[_0xd788('0x24')]=qs['limit'](_0x14aba4[_0xd788('0x45')][_0xd788('0x24')]);_0x5a2461[_0xd788('0x22')]=qs[_0xd788('0x22')](_0x14aba4[_0xd788('0x45')][_0xd788('0x22')]);}return _0x21b72e[_0xd788('0xda')](_0x5a2461);}})[_0xd788('0x16')](function(_0x256bbe){if(_0x256bbe){return _0x256bbe?{'count':_0x22f4c8,'rows':_0x256bbe}:null;}})[_0xd788('0x16')](respondWithResult(_0x2b8bbc,null))[_0xd788('0x60')](handleError(_0x2b8bbc,null));};exports[_0xd788('0xdb')]=function(_0x31b437,_0x3f5dad){var _0xe6a76b={};var _0x113254={};var _0x37cef5;var _0x4e8575;return db[_0xd788('0x3e')][_0xd788('0x9d')]({'where':{'id':_0x31b437[_0xd788('0x62')]['id']}})[_0xd788('0x16')](handleEntityNotFound(_0x3f5dad,null))[_0xd788('0x16')](function(_0x3a4fd6){if(_0x3a4fd6){_0x37cef5=_0x3a4fd6;_0x113254[_0xd788('0x5c')]=_[_0xd788('0x57')](db[_0xd788('0xdc')]['rawAttributes']);_0x113254[_0xd788('0x45')]=_[_0xd788('0x57')](_0x31b437['query']);_0x113254[_0xd788('0x59')]=_['intersection'](_0x113254[_0xd788('0x5c')],_0x113254['query']);_0xe6a76b[_0xd788('0x48')]=_[_0xd788('0x5a')](_0x113254[_0xd788('0x5c')],qs[_0xd788('0x5b')](_0x31b437[_0xd788('0x45')][_0xd788('0x5b')]));_0xe6a76b[_0xd788('0x48')]=_0xe6a76b[_0xd788('0x48')]['length']?_0xe6a76b[_0xd788('0x48')]:_0x113254[_0xd788('0x5c')];_0xe6a76b['order']=qs['sort'](_0x31b437[_0xd788('0x45')][_0xd788('0xce')]);_0xe6a76b[_0xd788('0xd0')]=qs['filters'](_['pick'](_0x31b437['query'],_0x113254['filters']));if(_0x31b437[_0xd788('0x45')][_0xd788('0x41')]){_0xe6a76b['where']=_[_0xd788('0x5e')](_0xe6a76b[_0xd788('0xd0')],{'$or':_[_0xd788('0x35')](_0xe6a76b[_0xd788('0x48')],function(_0x27053e){var _0x704f59={};_0x704f59[_0x27053e]={'$like':'%'+_0x31b437[_0xd788('0x45')][_0xd788('0x41')]+'%'};return _0x704f59;})});}_0xe6a76b=_[_0xd788('0x5e')]({},_0xe6a76b,_0x31b437[_0xd788('0x5f')]);return _0x37cef5[_0xd788('0xdb')](_0xe6a76b);}})[_0xd788('0x16')](function(_0x375dfd){if(_0x375dfd){_0x4e8575=_0x375dfd[_0xd788('0x4d')];if(!_0x31b437['query'][_0xd788('0xd5')](_0xd788('0xd6'))){_0xe6a76b[_0xd788('0x24')]=qs[_0xd788('0x24')](_0x31b437['query'][_0xd788('0x24')]);_0xe6a76b['offset']=qs[_0xd788('0x22')](_0x31b437[_0xd788('0x45')][_0xd788('0x22')]);}return _0x37cef5[_0xd788('0xdb')](_0xe6a76b);}})[_0xd788('0x16')](function(_0x1e5bd6){if(_0x1e5bd6){return _0x1e5bd6?{'count':_0x4e8575,'rows':_0x1e5bd6}:null;}})[_0xd788('0x16')](respondWithResult(_0x3f5dad,null))[_0xd788('0x60')](handleError(_0x3f5dad,null));};exports[_0xd788('0xdd')]=function(_0x2512ea,_0x18f5e0){var _0x1154dd={'raw':!![],'where':{}};var _0x34a6dd={};var _0x3b6367={'count':0x0,'rows':[]};return db['User']['findOne']({'where':{'id':_0x2512ea[_0xd788('0x62')]['id']}})[_0xd788('0x16')](handleEntityNotFound(_0x18f5e0,null))['then'](function(_0x3ed3b1){if(_0x3ed3b1){_0x34a6dd[_0xd788('0x5c')]=_[_0xd788('0x57')](db[_0xd788('0xde')]['rawAttributes']);_0x34a6dd['query']=_[_0xd788('0x57')](_0x2512ea['query']);_0x34a6dd[_0xd788('0x59')]=_[_0xd788('0x5a')](_0x34a6dd[_0xd788('0x5c')],_0x34a6dd[_0xd788('0x45')]);_0x1154dd['attributes']=_[_0xd788('0x5a')](_0x34a6dd[_0xd788('0x5c')],qs['fields'](_0x2512ea[_0xd788('0x45')][_0xd788('0x5b')]));_0x1154dd[_0xd788('0x48')]=_0x1154dd['attributes'][_0xd788('0x4d')]?_0x1154dd[_0xd788('0x48')]:_0x34a6dd[_0xd788('0x5c')];if(!_0x2512ea[_0xd788('0x45')][_0xd788('0xd5')](_0xd788('0xd6'))){_0x1154dd[_0xd788('0x24')]=qs[_0xd788('0x24')](_0x2512ea['query'][_0xd788('0x24')]);_0x1154dd[_0xd788('0x22')]=qs[_0xd788('0x22')](_0x2512ea[_0xd788('0x45')][_0xd788('0x22')]);}_0x1154dd['order']=qs[_0xd788('0xce')](_0x2512ea['query'][_0xd788('0xce')]);_0x1154dd['where']=qs[_0xd788('0x59')](_[_0xd788('0xcf')](_0x2512ea[_0xd788('0x45')],_0x34a6dd['filters']));_0x1154dd[_0xd788('0xd0')][_0xd788('0xdf')]=_0x3ed3b1['id'];if(_0x2512ea[_0xd788('0x45')][_0xd788('0x41')]){_0x1154dd['where']=_[_0xd788('0x5e')](_0x1154dd[_0xd788('0xd0')],{'$or':_['map'](_0x1154dd[_0xd788('0x48')],function(_0x3cc139){var _0x97e2d2={};_0x97e2d2[_0x3cc139]={'$like':'%'+_0x2512ea['query'][_0xd788('0x41')]+'%'};return _0x97e2d2;})});}_0x1154dd=_[_0xd788('0x5e')]({},_0x1154dd,_0x2512ea[_0xd788('0x5f')]);return db[_0xd788('0xde')][_0xd788('0x25')]({'where':_0x1154dd[_0xd788('0xd0')]})[_0xd788('0x16')](function(_0xbb5b90){_0x3b6367['count']=_0xbb5b90;if(_0x2512ea[_0xd788('0x45')][_0xd788('0xd1')]){_0x1154dd['include']=[{'all':!![]}];}return db[_0xd788('0xde')]['findAll'](_0x1154dd);})[_0xd788('0x16')](function(_0x3d4bb0){_0x3b6367[_0xd788('0x4a')]=_0x3d4bb0;return _0x3b6367;});}})[_0xd788('0x16')](respondWithFilteredResult(_0x18f5e0,_0x1154dd))[_0xd788('0x60')](handleError(_0x18f5e0,null));};exports['getScreenRecordings']=function(_0x560544,_0x55f8e8){var _0x133638={'raw':!![],'where':{}};var _0x59ca27={};var _0x4754f4={'count':0x0,'rows':[]};return db[_0xd788('0x3e')][_0xd788('0x9d')]({'where':{'id':_0x560544[_0xd788('0x62')]['id']}})[_0xd788('0x16')](handleEntityNotFound(_0x55f8e8,null))[_0xd788('0x16')](function(_0x35a69b){if(_0x35a69b){_0x59ca27[_0xd788('0x5c')]=_['keys'](db[_0xd788('0xe0')][_0xd788('0x58')]);_0x59ca27[_0xd788('0x45')]=_['keys'](_0x560544[_0xd788('0x45')]);_0x59ca27[_0xd788('0x59')]=_[_0xd788('0x5a')](_0x59ca27[_0xd788('0x5c')],_0x59ca27[_0xd788('0x45')]);_0x133638['attributes']=_[_0xd788('0x5a')](_0x59ca27[_0xd788('0x5c')],qs['fields'](_0x560544[_0xd788('0x45')]['fields']));_0x133638['attributes']=_0x133638['attributes'][_0xd788('0x4d')]?_0x133638[_0xd788('0x48')]:_0x59ca27['model'];if(!_0x560544[_0xd788('0x45')]['hasOwnProperty'](_0xd788('0xd6'))){_0x133638[_0xd788('0x24')]=qs['limit'](_0x560544[_0xd788('0x45')][_0xd788('0x24')]);_0x133638[_0xd788('0x22')]=qs[_0xd788('0x22')](_0x560544[_0xd788('0x45')][_0xd788('0x22')]);}_0x133638[_0xd788('0xcd')]=qs[_0xd788('0xce')](_0x560544[_0xd788('0x45')][_0xd788('0xce')]);_0x133638['where']=qs[_0xd788('0x59')](_['pick'](_0x560544[_0xd788('0x45')],_0x59ca27[_0xd788('0x59')]));_0x133638[_0xd788('0xd0')]['UserId']=_0x35a69b['id'];if(_0x560544[_0xd788('0x45')][_0xd788('0x41')]){_0x133638[_0xd788('0xd0')]=_[_0xd788('0x5e')](_0x133638[_0xd788('0xd0')],{'$or':_[_0xd788('0x35')](_0x133638[_0xd788('0x48')],function(_0x20e3ff){var _0x2ed39f={};_0x2ed39f[_0x20e3ff]={'$like':'%'+_0x560544[_0xd788('0x45')]['filter']+'%'};return _0x2ed39f;})});}_0x133638=_[_0xd788('0x5e')]({},_0x133638,_0x560544[_0xd788('0x5f')]);return db[_0xd788('0xe0')]['count']({'where':_0x133638[_0xd788('0xd0')]})[_0xd788('0x16')](function(_0x4a7939){_0x4754f4[_0xd788('0x25')]=_0x4a7939;if(_0x560544[_0xd788('0x45')]['includeAll']){_0x133638['include']=[{'all':!![]}];}return db['ScreenRecording']['findAll'](_0x133638);})[_0xd788('0x16')](function(_0x25b0b7){_0x4754f4[_0xd788('0x4a')]=_0x25b0b7;return _0x4754f4;});}})['then'](respondWithFilteredResult(_0x55f8e8,_0x133638))[_0xd788('0x60')](handleError(_0x55f8e8,null));};exports[_0xd788('0xe1')]=function(_0x257c87,_0x2e4290){var _0x137a36={};var _0x119fcf={};var _0x2bec90;var _0x246329;return db[_0xd788('0x3e')][_0xd788('0x9d')]({'where':{'id':_0x257c87['params']['id']}})[_0xd788('0x16')](handleEntityNotFound(_0x2e4290,null))[_0xd788('0x16')](function(_0x21c89c){if(_0x21c89c){_0x2bec90=_0x21c89c;_0x119fcf['model']=_[_0xd788('0x57')](db[_0xd788('0xe2')]['rawAttributes']);_0x119fcf[_0xd788('0x45')]=_[_0xd788('0x57')](_0x257c87['query']);_0x119fcf['filters']=_['intersection'](_0x119fcf[_0xd788('0x5c')],_0x119fcf[_0xd788('0x45')]);_0x137a36['attributes']=_[_0xd788('0x5a')](_0x119fcf['model'],qs[_0xd788('0x5b')](_0x257c87['query'][_0xd788('0x5b')]));_0x137a36['attributes']=_0x137a36['attributes'][_0xd788('0x4d')]?_0x137a36[_0xd788('0x48')]:_0x119fcf[_0xd788('0x5c')];_0x137a36['order']=qs[_0xd788('0xce')](_0x257c87[_0xd788('0x45')][_0xd788('0xce')]);_0x137a36['where']=qs[_0xd788('0x59')](_[_0xd788('0xcf')](_0x257c87[_0xd788('0x45')],_0x119fcf[_0xd788('0x59')]));if(_0x257c87['query'][_0xd788('0x41')]){_0x137a36[_0xd788('0xd0')]=_[_0xd788('0x5e')](_0x137a36[_0xd788('0xd0')],{'$or':_[_0xd788('0x35')](_0x137a36['attributes'],function(_0xa16c80){var _0x140d09={};_0x140d09[_0xa16c80]={'$like':'%'+_0x257c87[_0xd788('0x45')][_0xd788('0x41')]+'%'};return _0x140d09;})});}_0x137a36=_['merge']({},_0x137a36,_0x257c87['options']);return _0x2bec90['getChatInteractions'](_0x137a36);}})[_0xd788('0x16')](function(_0x1987a6){if(_0x1987a6){_0x246329=_0x1987a6['length'];if(!_0x257c87[_0xd788('0x45')][_0xd788('0xd5')]('nolimit')){_0x137a36[_0xd788('0x24')]=qs[_0xd788('0x24')](_0x257c87[_0xd788('0x45')][_0xd788('0x24')]);_0x137a36[_0xd788('0x22')]=qs['offset'](_0x257c87['query'][_0xd788('0x22')]);}return _0x2bec90[_0xd788('0xe1')](_0x137a36);}})['then'](function(_0x42f29f){if(_0x42f29f){return _0x42f29f?{'count':_0x246329,'rows':_0x42f29f}:null;}})[_0xd788('0x16')](respondWithResult(_0x2e4290,null))[_0xd788('0x60')](handleError(_0x2e4290,null));};exports[_0xd788('0xe3')]=function(_0x2abf14,_0x44d7b0){var _0xfe87f3={};var _0x41b595={};var _0x40b263;var _0x2777ef;return db[_0xd788('0x3e')][_0xd788('0x9d')]({'where':{'id':_0x2abf14[_0xd788('0x62')]['id']}})[_0xd788('0x16')](handleEntityNotFound(_0x44d7b0,null))[_0xd788('0x16')](function(_0x40d0d3){if(_0x40d0d3){_0x40b263=_0x40d0d3;_0x41b595['model']=_['keys'](db[_0xd788('0xe4')][_0xd788('0x58')]);_0x41b595[_0xd788('0x45')]=_['keys'](_0x2abf14[_0xd788('0x45')]);_0x41b595[_0xd788('0x59')]=_[_0xd788('0x5a')](_0x41b595[_0xd788('0x5c')],_0x41b595[_0xd788('0x45')]);_0xfe87f3[_0xd788('0x48')]=_[_0xd788('0x5a')](_0x41b595[_0xd788('0x5c')],qs[_0xd788('0x5b')](_0x2abf14[_0xd788('0x45')][_0xd788('0x5b')]));_0xfe87f3[_0xd788('0x48')]=_0xfe87f3[_0xd788('0x48')]['length']?_0xfe87f3[_0xd788('0x48')]:_0x41b595['model'];_0xfe87f3[_0xd788('0xcd')]=qs['sort'](_0x2abf14[_0xd788('0x45')][_0xd788('0xce')]);_0xfe87f3[_0xd788('0xd0')]=qs[_0xd788('0x59')](_[_0xd788('0xcf')](_0x2abf14[_0xd788('0x45')],_0x41b595[_0xd788('0x59')]));if(_0x2abf14[_0xd788('0x45')][_0xd788('0x41')]){_0xfe87f3[_0xd788('0xd0')]=_[_0xd788('0x5e')](_0xfe87f3[_0xd788('0xd0')],{'$or':_['map'](_0xfe87f3[_0xd788('0x48')],function(_0x6273eb){var _0x234cf6={};_0x234cf6[_0x6273eb]={'$like':'%'+_0x2abf14['query']['filter']+'%'};return _0x234cf6;})});}_0xfe87f3=_[_0xd788('0x5e')]({},_0xfe87f3,_0x2abf14[_0xd788('0x5f')]);return _0x40b263[_0xd788('0xe3')](_0xfe87f3);}})[_0xd788('0x16')](function(_0x4fae6b){if(_0x4fae6b){_0x2777ef=_0x4fae6b[_0xd788('0x4d')];if(!_0x2abf14[_0xd788('0x45')]['hasOwnProperty'](_0xd788('0xd6'))){_0xfe87f3[_0xd788('0x24')]=qs[_0xd788('0x24')](_0x2abf14[_0xd788('0x45')][_0xd788('0x24')]);_0xfe87f3[_0xd788('0x22')]=qs[_0xd788('0x22')](_0x2abf14['query'][_0xd788('0x22')]);}return _0x40b263[_0xd788('0xe3')](_0xfe87f3);}})[_0xd788('0x16')](function(_0x58d9a1){if(_0x58d9a1){return _0x58d9a1?{'count':_0x2777ef,'rows':_0x58d9a1}:null;}})[_0xd788('0x16')](respondWithResult(_0x44d7b0,null))[_0xd788('0x60')](handleError(_0x44d7b0,null));};exports['getMailInteractions']=function(_0x10f8a2,_0x1457ea){var _0x24d820={'raw':!![],'where':{}};var _0x220d79={};var _0x2823d8={'count':0x0,'rows':[]};return db['User'][_0xd788('0x9d')]({'where':{'id':_0x10f8a2[_0xd788('0x62')]['id']}})['then'](handleEntityNotFound(_0x1457ea,null))[_0xd788('0x16')](function(_0x130c67){if(_0x130c67){_0x220d79[_0xd788('0x5c')]=_[_0xd788('0x57')](db[_0xd788('0xe5')][_0xd788('0x58')]);_0x220d79[_0xd788('0x45')]=_[_0xd788('0x57')](_0x10f8a2['query']);_0x220d79[_0xd788('0x59')]=_[_0xd788('0x5a')](_0x220d79[_0xd788('0x5c')],_0x220d79[_0xd788('0x45')]);_0x24d820['attributes']=_[_0xd788('0x5a')](_0x220d79['model'],qs[_0xd788('0x5b')](_0x10f8a2[_0xd788('0x45')]['fields']));_0x24d820[_0xd788('0x48')]=_0x24d820[_0xd788('0x48')]['length']?_0x24d820[_0xd788('0x48')]:_0x220d79[_0xd788('0x5c')];if(!_0x10f8a2[_0xd788('0x45')]['hasOwnProperty'](_0xd788('0xd6'))){_0x24d820['limit']=qs[_0xd788('0x24')](_0x10f8a2[_0xd788('0x45')]['limit']);_0x24d820['offset']=qs[_0xd788('0x22')](_0x10f8a2[_0xd788('0x45')][_0xd788('0x22')]);}_0x24d820[_0xd788('0xcd')]=qs[_0xd788('0xce')](_0x10f8a2[_0xd788('0x45')][_0xd788('0xce')]);_0x24d820[_0xd788('0xd0')]=qs[_0xd788('0x59')](_[_0xd788('0xcf')](_0x10f8a2[_0xd788('0x45')],_0x220d79[_0xd788('0x59')]));_0x24d820[_0xd788('0xd0')][_0xd788('0xdf')]=_0x130c67['id'];if(_0x10f8a2[_0xd788('0x45')][_0xd788('0x41')]){_0x24d820[_0xd788('0xd0')]=_[_0xd788('0x5e')](_0x24d820[_0xd788('0xd0')],{'$or':_[_0xd788('0x35')](_0x24d820[_0xd788('0x48')],function(_0x424992){var _0x535627={};_0x535627[_0x424992]={'$like':'%'+_0x10f8a2['query']['filter']+'%'};return _0x535627;})});}_0x24d820=_['merge']({},_0x24d820,_0x10f8a2[_0xd788('0x5f')]);return db['MailInteraction'][_0xd788('0x25')]({'where':_0x24d820[_0xd788('0xd0')]})['then'](function(_0x2cac43){_0x2823d8[_0xd788('0x25')]=_0x2cac43;if(_0x10f8a2[_0xd788('0x45')]['includeAll']){_0x24d820[_0xd788('0x46')]=[{'all':!![]}];}return db[_0xd788('0xe5')][_0xd788('0x49')](_0x24d820);})[_0xd788('0x16')](function(_0x528408){_0x2823d8[_0xd788('0x4a')]=_0x528408;return _0x2823d8;});}})['then'](respondWithFilteredResult(_0x1457ea,_0x24d820))['catch'](handleError(_0x1457ea,null));};exports[_0xd788('0xe6')]=function(_0x24f0e4,_0x381dd0){var _0x55373e={};var _0x540103={};var _0x70b48a;var _0x2f2a4d;return db[_0xd788('0x3e')][_0xd788('0x9d')]({'where':{'id':_0x24f0e4[_0xd788('0x62')]['id']}})[_0xd788('0x16')](handleEntityNotFound(_0x381dd0,null))['then'](function(_0x31ef07){if(_0x31ef07){_0x70b48a=_0x31ef07;_0x540103['model']=_[_0xd788('0x57')](db[_0xd788('0xe7')][_0xd788('0x58')]);_0x540103[_0xd788('0x45')]=_[_0xd788('0x57')](_0x24f0e4['query']);_0x540103[_0xd788('0x59')]=_[_0xd788('0x5a')](_0x540103['model'],_0x540103[_0xd788('0x45')]);_0x55373e[_0xd788('0x48')]=_[_0xd788('0x5a')](_0x540103['model'],qs[_0xd788('0x5b')](_0x24f0e4[_0xd788('0x45')]['fields']));_0x55373e[_0xd788('0x48')]=_0x55373e[_0xd788('0x48')][_0xd788('0x4d')]?_0x55373e[_0xd788('0x48')]:_0x540103[_0xd788('0x5c')];_0x55373e['order']=qs[_0xd788('0xce')](_0x24f0e4[_0xd788('0x45')][_0xd788('0xce')]);_0x55373e[_0xd788('0xd0')]=qs[_0xd788('0x59')](_[_0xd788('0xcf')](_0x24f0e4[_0xd788('0x45')],_0x540103[_0xd788('0x59')]));if(_0x24f0e4[_0xd788('0x45')]['filter']){_0x55373e['where']=_[_0xd788('0x5e')](_0x55373e[_0xd788('0xd0')],{'$or':_['map'](_0x55373e[_0xd788('0x48')],function(_0x3d965e){var _0x50d9b0={};_0x50d9b0[_0x3d965e]={'$like':'%'+_0x24f0e4[_0xd788('0x45')]['filter']+'%'};return _0x50d9b0;})});}_0x55373e=_['merge']({},_0x55373e,_0x24f0e4[_0xd788('0x5f')]);return _0x70b48a[_0xd788('0xe6')](_0x55373e);}})[_0xd788('0x16')](function(_0x47db69){if(_0x47db69){_0x2f2a4d=_0x47db69['length'];if(!_0x24f0e4[_0xd788('0x45')][_0xd788('0xd5')]('nolimit')){_0x55373e['limit']=qs['limit'](_0x24f0e4[_0xd788('0x45')]['limit']);_0x55373e[_0xd788('0x22')]=qs['offset'](_0x24f0e4[_0xd788('0x45')]['offset']);}return _0x70b48a[_0xd788('0xe6')](_0x55373e);}})[_0xd788('0x16')](function(_0x14ed78){if(_0x14ed78){return _0x14ed78?{'count':_0x2f2a4d,'rows':_0x14ed78}:null;}})[_0xd788('0x16')](respondWithResult(_0x381dd0,null))[_0xd788('0x60')](handleError(_0x381dd0,null));};exports[_0xd788('0xe8')]=function(_0x16fc47,_0x3c4ab4){var _0x2f580c={};var _0x52fccd={};var _0x4cd01d;var _0x3da1f6;return db[_0xd788('0x3e')][_0xd788('0x9d')]({'where':{'id':_0x16fc47[_0xd788('0x62')]['id']}})[_0xd788('0x16')](handleEntityNotFound(_0x3c4ab4,null))[_0xd788('0x16')](function(_0x4b979e){if(_0x4b979e){_0x4cd01d=_0x4b979e;_0x52fccd[_0xd788('0x5c')]=_[_0xd788('0x57')](db[_0xd788('0xe9')][_0xd788('0x58')]);_0x52fccd[_0xd788('0x45')]=_[_0xd788('0x57')](_0x16fc47['query']);_0x52fccd['filters']=_[_0xd788('0x5a')](_0x52fccd[_0xd788('0x5c')],_0x52fccd[_0xd788('0x45')]);_0x2f580c[_0xd788('0x48')]=_[_0xd788('0x5a')](_0x52fccd['model'],qs['fields'](_0x16fc47[_0xd788('0x45')]['fields']));_0x2f580c[_0xd788('0x48')]=_0x2f580c[_0xd788('0x48')][_0xd788('0x4d')]?_0x2f580c[_0xd788('0x48')]:_0x52fccd[_0xd788('0x5c')];_0x2f580c[_0xd788('0xcd')]=qs['sort'](_0x16fc47[_0xd788('0x45')][_0xd788('0xce')]);_0x2f580c[_0xd788('0xd0')]=qs['filters'](_['pick'](_0x16fc47[_0xd788('0x45')],_0x52fccd[_0xd788('0x59')]));if(_0x16fc47[_0xd788('0x45')][_0xd788('0x41')]){_0x2f580c[_0xd788('0xd0')]=_[_0xd788('0x5e')](_0x2f580c[_0xd788('0xd0')],{'$or':_[_0xd788('0x35')](_0x2f580c['attributes'],function(_0x9253){var _0x5d1843={};_0x5d1843[_0x9253]={'$like':'%'+_0x16fc47[_0xd788('0x45')][_0xd788('0x41')]+'%'};return _0x5d1843;})});}_0x2f580c=_[_0xd788('0x5e')]({},_0x2f580c,_0x16fc47['options']);return _0x4cd01d[_0xd788('0xe8')](_0x2f580c);}})[_0xd788('0x16')](function(_0xa80fdd){if(_0xa80fdd){_0x3da1f6=_0xa80fdd[_0xd788('0x4d')];if(!_0x16fc47['query']['hasOwnProperty'](_0xd788('0xd6'))){_0x2f580c['limit']=qs[_0xd788('0x24')](_0x16fc47[_0xd788('0x45')][_0xd788('0x24')]);_0x2f580c[_0xd788('0x22')]=qs[_0xd788('0x22')](_0x16fc47[_0xd788('0x45')][_0xd788('0x22')]);}return _0x4cd01d[_0xd788('0xe8')](_0x2f580c);}})['then'](function(_0x1d77e6){if(_0x1d77e6){return _0x1d77e6?{'count':_0x3da1f6,'rows':_0x1d77e6}:null;}})[_0xd788('0x16')](respondWithResult(_0x3c4ab4,null))[_0xd788('0x60')](handleError(_0x3c4ab4,null));};exports[_0xd788('0xea')]=function(_0x2fb978,_0x2e1feb){var _0xf8624b={};var _0x4cc292={};var _0x27e8c1;var _0x6d94e0;return db['User'][_0xd788('0x9d')]({'where':{'id':_0x2fb978[_0xd788('0x62')]['id']}})[_0xd788('0x16')](handleEntityNotFound(_0x2e1feb,null))['then'](function(_0x5db2e1){if(_0x5db2e1){_0x27e8c1=_0x5db2e1;_0x4cc292[_0xd788('0x5c')]=_[_0xd788('0x57')](db[_0xd788('0xeb')][_0xd788('0x58')]);_0x4cc292[_0xd788('0x45')]=_[_0xd788('0x57')](_0x2fb978['query']);_0x4cc292[_0xd788('0x59')]=_[_0xd788('0x5a')](_0x4cc292[_0xd788('0x5c')],_0x4cc292['query']);_0xf8624b[_0xd788('0x48')]=_[_0xd788('0x5a')](_0x4cc292[_0xd788('0x5c')],qs[_0xd788('0x5b')](_0x2fb978[_0xd788('0x45')][_0xd788('0x5b')]));_0xf8624b[_0xd788('0x48')]=_0xf8624b[_0xd788('0x48')]['length']?_0xf8624b[_0xd788('0x48')]:_0x4cc292[_0xd788('0x5c')];_0xf8624b[_0xd788('0xcd')]=qs[_0xd788('0xce')](_0x2fb978[_0xd788('0x45')][_0xd788('0xce')]);_0xf8624b[_0xd788('0xd0')]=qs['filters'](_[_0xd788('0xcf')](_0x2fb978[_0xd788('0x45')],_0x4cc292['filters']));if(_0x2fb978[_0xd788('0x45')][_0xd788('0x41')]){_0xf8624b[_0xd788('0xd0')]=_['merge'](_0xf8624b[_0xd788('0xd0')],{'$or':_[_0xd788('0x35')](_0xf8624b[_0xd788('0x48')],function(_0x462a4a){var _0x46a5bb={};_0x46a5bb[_0x462a4a]={'$like':'%'+_0x2fb978[_0xd788('0x45')]['filter']+'%'};return _0x46a5bb;})});}_0xf8624b=_[_0xd788('0x5e')]({},_0xf8624b,_0x2fb978[_0xd788('0x5f')]);return _0x27e8c1[_0xd788('0xea')](_0xf8624b);}})[_0xd788('0x16')](function(_0x16de44){if(_0x16de44){_0x6d94e0=_0x16de44[_0xd788('0x4d')];if(!_0x2fb978[_0xd788('0x45')][_0xd788('0xd5')](_0xd788('0xd6'))){_0xf8624b[_0xd788('0x24')]=qs[_0xd788('0x24')](_0x2fb978['query'][_0xd788('0x24')]);_0xf8624b[_0xd788('0x22')]=qs['offset'](_0x2fb978[_0xd788('0x45')][_0xd788('0x22')]);}return _0x27e8c1[_0xd788('0xea')](_0xf8624b);}})[_0xd788('0x16')](function(_0xd1ada8){if(_0xd1ada8){return _0xd1ada8?{'count':_0x6d94e0,'rows':_0xd1ada8}:null;}})[_0xd788('0x16')](respondWithResult(_0x2e1feb,null))[_0xd788('0x60')](handleError(_0x2e1feb,null));};exports[_0xd788('0xec')]=function(_0x3410fa,_0x1edfa4,_0x48e265){var _0x120cae;var _0x3c9c71;var _0x3ae28f;var _0x4aad99=!_[_0xd788('0x6d')](_0x3410fa[_0xd788('0x62')]['id'])?_0x3410fa[_0xd788('0x62')]['id']:!_[_0xd788('0x6d')](_0x3410fa['user']['id'])?_0x3410fa[_0xd788('0x2f')]['id']:null;return db[_0xd788('0x3e')]['find']({'where':{'id':_0x4aad99,'role':{'$or':[_0xd788('0x2d'),_0xd788('0x2f'),_0xd788('0x31')]}},'attributes':['id',_0xd788('0x3c'),_0xd788('0xed'),'mobile',_0xd788('0x2c'),_0xd788('0x66'),_0xd788('0xa4')]})[_0xd788('0x16')](function(_0x358ba0){if(_0x358ba0){if(_0x358ba0[_0xd788('0x2c')]===_0xd788('0x31')){_0x120cae=_0x358ba0;if(_0x3410fa[_0xd788('0x61')]['interface']){_0x3ae28f=util[_0xd788('0xb3')](_0xd788('0xee'),_0x120cae[_0x3410fa['body'][_0xd788('0xa6')]]);}else if(_0x3410fa[_0xd788('0x61')][_0xd788('0xef')]){_0x3ae28f=util[_0xd788('0xb3')]('SIP/%s',_0x3410fa[_0xd788('0x61')]['intrf']);}else{_0x3ae28f=util[_0xd788('0xb3')](_0xd788('0xb4'),_0x120cae['name']);}socket['to'](util['format'](_0xd788('0xf0'),_0x120cae['name']))[_0xd788('0x28')](_0xd788('0xf1'),{'user':{'id':_0x120cae['id'],'name':_0x120cae[_0xd788('0x3c')]},'ip':_0x3410fa[_0xd788('0xf2')][_0xd788('0xf3')]||_0x3410fa[_0xd788('0xf4')]['remoteAddress']||_0x3410fa[_0xd788('0xf5')][_0xd788('0xf6')]||_0x3410fa['connection'][_0xd788('0xf5')]['remoteAddress']});return db['UserVoiceQueueRt'][_0xd788('0x2a')]({'where':{'membername':_0x120cae[_0xd788('0x3c')]},'individualHooks':!![]});}}else{throw new db[(_0xd788('0x95'))][(_0xd788('0x96'))](_0xd788('0xf7'));}})['then'](function(){if(_0x120cae){return _0x120cae[_0xd788('0xf8')]({'raw':!![]});}})[_0xd788('0x16')](function(_0x47211c){if(_0x120cae){if(_0x47211c){_0x3c9c71=_0x47211c;if(_0x3c9c71[_0xd788('0x4d')]){var _0x45ded2=_0x3c9c71['map'](function(_0x200f59){var _0x509c48={'membername':_0x120cae[_0xd788('0x3c')],'UserId':_0x120cae['id'],'queue_name':_0x200f59[_0xd788('0x3c')],'VoiceQueueId':_0x200f59['id'],'interface':_0x3ae28f,'paused':_0x120cae[_0xd788('0xa4')]||![],'penalty':_0x200f59['UserVoiceQueue.penalty']||0x0};return db[_0xd788('0xb5')][_0xd788('0xb6')](_0x509c48);});return Promise[_0xd788('0x56')](_0x45ded2);}}}})['then'](function(){if(_0x120cae){return db[_0xd788('0xf9')][_0xd788('0x49')]({'where':{'membername':_0x120cae[_0xd788('0x3c')],'exitAt':null}});}})[_0xd788('0x16')](function(_0x970ab7){if(_0x120cae){var _0x55907d=[];_0x970ab7[_0xd788('0xfa')](function(_0xb332cc){_0x55907d[_0xd788('0x4e')](_0xb332cc[_0xd788('0x27')]({'exitAt':moment()[_0xd788('0xb3')](_0xd788('0xfb'))}));});return Promise[_0xd788('0x56')](_0x55907d);}})['then'](function(){if(_0x120cae){var _0x24c581=[];var _0x603b14=[];var _0x14a2e9=utils['getChannels']();var _0x1c4165={'membername':_0x120cae[_0xd788('0x3c')],'interface':_0x3ae28f,'enterAt':moment()[_0xd788('0xb3')](_0xd788('0xfb')),'role':_0x120cae['role'],'internal':_0x120cae['internal']};_0x14a2e9[_0xd788('0xfa')](function(_0x57afda){_0x24c581[_0xd788('0x4e')](_[_0xd788('0x5e')]({'channel':_0x57afda,'type':_0xd788('0xfc'),'data1':_0x3410fa[_0xd788('0x61')]['device'],'data2':_0x3ae28f},_0x1c4165));if(_0x120cae[_0xd788('0xa4')]){_0x603b14[_0xd788('0x4e')](_[_0xd788('0x5e')]({'channel':_0x57afda,'type':_0xd788('0xfd'),'data1':_0xd788('0xfe')},_0x1c4165));}});return db[_0xd788('0xf9')][_0xd788('0x90')](_0x24c581[_0xd788('0xff')](_0x603b14),{'individualHooks':!![]});}})[_0xd788('0x16')](function(){if(_0x120cae){return _0x120cae[_0xd788('0x27')]({'online':!![],'lastLoginAt':moment()[_0xd788('0xb3')]('YYYY-MM-DD\x20HH:mm:ss'),'voicePause':_0x120cae[_0xd788('0xa4')]||![],'mailPause':_0x120cae[_0xd788('0xa4')]||![],'chatPause':_0x120cae['loginInPause']||![],'faxPause':_0x120cae[_0xd788('0xa4')]||![],'smsPause':_0x120cae[_0xd788('0xa4')]||![],'openchannelPause':_0x120cae[_0xd788('0xa4')]||![],'whatsappPause':_0x120cae[_0xd788('0xa4')]||![],'pauseType':_0x120cae['loginInPause']?_0xd788('0xfe'):null,'interface':_0x3ae28f,'lastPauseAt':moment()['format']('YYYY-MM-DD\x20HH:mm:ss')});}})['then'](function(_0x387f39){if(_0x3410fa['isMiddleware']){return _0x48e265();}else{return Promise['resolve'](_0x387f39)['then'](respondWithResult(_0x1edfa4,null));}})['catch'](handleError(_0x1edfa4,null));};exports[_0xd788('0x100')]=function(_0x459228,_0x4ae6eb){var _0x161e35;return db[_0xd788('0x3e')][_0xd788('0x38')]({'where':{'id':_0x459228[_0xd788('0x62')]['id'],'role':'agent'},'attributes':['id',_0xd788('0x3c'),_0xd788('0x2c')]})[_0xd788('0x16')](handleEntityNotFound(_0x4ae6eb,null))[_0xd788('0x16')](function(_0x18d9c6){if(_0x18d9c6){_0x161e35=_0x18d9c6;return db['UserVoiceQueueRt'][_0xd788('0x2a')]({'where':{'membername':_0x161e35[_0xd788('0x3c')]},'individualHooks':!![]});}})['then'](function(){return db[_0xd788('0xf9')][_0xd788('0x49')]({'where':{'membername':_0x161e35[_0xd788('0x3c')],'exitAt':null}});})[_0xd788('0x16')](function(_0x2f2678){var _0x27939b=[];_0x2f2678[_0xd788('0xfa')](function(_0x376031){_0x27939b['push'](_0x376031[_0xd788('0x27')]({'exitAt':moment()['format'](_0xd788('0xfb'))}));});return Promise['all'](_0x27939b);})[_0xd788('0x16')](function(){return _0x161e35[_0xd788('0x27')]({'online':![],'voicePause':![],'mailPause':![],'chatPause':![],'faxPause':![],'smsPause':![],'openchannelPause':![],'whatsappPause':![],'interface':null});})[_0xd788('0x16')](respondWithResult(_0x4ae6eb,null))[_0xd788('0x60')](handleError(_0x4ae6eb,null));};exports[_0xd788('0x101')]=function(_0x12751f,_0x2ddd1c){var _0x13587c;return db[_0xd788('0xb5')][_0xd788('0x27')]({'paused':0x1},{'where':{'UserId':_0x12751f['params']['id']},'individualHooks':!![]})[_0xd788('0x16')](function(){return db[_0xd788('0x3e')][_0xd788('0x38')]({'where':{'id':_0x12751f[_0xd788('0x62')]['id'],'role':_0xd788('0x31')},'attributes':['id',_0xd788('0x3c'),_0xd788('0x2c'),_0xd788('0x66'),_0xd788('0xa6'),_0xd788('0x102')]});})[_0xd788('0x16')](handleEntityNotFound(_0x2ddd1c,null))[_0xd788('0x16')](function(_0x239a00){if(_0x239a00){_0x13587c=_0x239a00;return respondWithRpcPromise(_0xd788('0x103'),_0xd788('0x101'),{'id':_0x13587c['id'],'name':_0x13587c[_0xd788('0x3c')],'pause':!![]});}})[_0xd788('0x16')](function(){if(_0x13587c){return db[_0xd788('0xf9')][_0xd788('0x49')]({'where':{'membername':_0x13587c[_0xd788('0x3c')],'type':_0xd788('0xfd'),'exitAt':null}});}})[_0xd788('0x16')](function(_0x3c9e38){if(_0x3c9e38[_0xd788('0x4d')]){var _0x509e6b=moment()[_0xd788('0xb3')](_0xd788('0xfb'));for(var _0x1ecc1e=0x0,_0x1b7a2b=_0x3c9e38[_0xd788('0x4d')];_0x1ecc1e<_0x1b7a2b;_0x1ecc1e++){_0x3c9e38[_0x1ecc1e][_0xd788('0x104')]({'exitAt':_0x509e6b});}}})['then'](function(){var _0x411218=[];var _0x2dd38c=utils[_0xd788('0x105')]();_0x2dd38c['forEach'](function(_0x13b62e){_0x411218['push']({'channel':_0x13b62e,'membername':_0x13587c['name'],'interface':_[_0xd788('0x6d')](_0x13587c[_0xd788('0xa6')])?util[_0xd788('0xb3')](_0xd788('0xb4'),_0x13587c[_0xd788('0x3c')]):_0x13587c[_0xd788('0xa6')],'type':_0xd788('0xfd'),'enterAt':moment()[_0xd788('0xb3')](_0xd788('0xfb')),'data1':_0x12751f['body'][_0xd788('0x40')]||_0xd788('0x106'),'role':_0x13587c[_0xd788('0x2c')],'internal':_0x13587c['internal']});});return db[_0xd788('0xf9')][_0xd788('0x90')](_0x411218,{'individualHooks':!![]});})[_0xd788('0x16')](function(){return _0x13587c[_0xd788('0x27')]({'voicePause':!![],'mailPause':!![],'chatPause':!![],'faxPause':!![],'smsPause':!![],'whatsappPause':!![],'openchannelPause':!![],'pauseType':_0x12751f['body'][_0xd788('0x40')]||_0xd788('0x106'),'lastPauseAt':moment()[_0xd788('0xb3')](_0xd788('0xfb'))});})[_0xd788('0x16')](respondWithResult(_0x2ddd1c,null))['catch'](handleError(_0x2ddd1c,null));};exports[_0xd788('0x107')]=function(_0x42c462,_0x57c04f){if(_0x42c462['body']['channel']&&!utils[_0xd788('0xa7')](_0x42c462['body'][_0xd788('0xa3')])){throw new APIBadRequestError(util['format']('Channel\x20parameter\x20%s\x20is\x20invalid',_0x42c462[_0xd788('0x61')][_0xd788('0xa3')]));}return db[_0xd788('0x3e')][_0xd788('0x38')]({'where':{'id':_0x42c462['params']['id']},'attributes':['id',_0xd788('0x3c'),_0xd788('0x2c'),_0xd788('0x66'),'interface','online','voicePause',_0xd788('0x108'),_0xd788('0x109'),_0xd788('0x10a'),'openchannelPause',_0xd788('0x10b'),_0xd788('0x10c'),_0xd788('0x10d'),_0xd788('0x10e')]})['then'](function(_0xcbe51e){if(!_0xcbe51e){throw new APINotFoundError(util[_0xd788('0xb3')](_0xd788('0x10f'),_0x42c462[_0xd788('0x62')]['id']));}return _0xcbe51e[_0xd788('0x107')](_0x42c462[_0xd788('0x61')][_0xd788('0xa3')]);})[_0xd788('0x16')](respondWithResult(_0x57c04f,null))['catch'](APIHandleError(_0x57c04f));};exports[_0xd788('0x110')]=function(_0x5e146e,_0x3c2abf){var _0x4095e2={};var _0x5de1cf={};var _0x20adff;var _0x147767;return db[_0xd788('0x3e')]['findOne']({'where':{'id':_0x5e146e[_0xd788('0x62')]['id']}})['then'](handleEntityNotFound(_0x3c2abf,null))[_0xd788('0x16')](function(_0x57b5fd){if(_0x57b5fd){_0x20adff=_0x57b5fd;_0x5de1cf[_0xd788('0x5c')]=_[_0xd788('0x57')](db['Team'][_0xd788('0x58')]);_0x5de1cf[_0xd788('0x45')]=_[_0xd788('0x57')](_0x5e146e[_0xd788('0x45')]);_0x5de1cf[_0xd788('0x59')]=_[_0xd788('0x5a')](_0x5de1cf[_0xd788('0x5c')],_0x5de1cf[_0xd788('0x45')]);_0x4095e2[_0xd788('0x48')]=_[_0xd788('0x5a')](_0x5de1cf['model'],qs[_0xd788('0x5b')](_0x5e146e['query'][_0xd788('0x5b')]));_0x4095e2[_0xd788('0x48')]=_0x4095e2[_0xd788('0x48')][_0xd788('0x4d')]?_0x4095e2['attributes']:_0x5de1cf[_0xd788('0x5c')];_0x4095e2[_0xd788('0xcd')]=qs[_0xd788('0xce')](_0x5e146e[_0xd788('0x45')][_0xd788('0xce')]);_0x4095e2[_0xd788('0xd0')]=qs[_0xd788('0x59')](_[_0xd788('0xcf')](_0x5e146e['query'],_0x5de1cf['filters']));if(_0x5e146e['query'][_0xd788('0x41')]){_0x4095e2[_0xd788('0xd0')]=_['merge'](_0x4095e2[_0xd788('0xd0')],{'$or':_['map'](_0x4095e2[_0xd788('0x48')],function(_0x5e5571){var _0x2a4c50={};_0x2a4c50[_0x5e5571]={'$like':'%'+_0x5e146e[_0xd788('0x45')]['filter']+'%'};return _0x2a4c50;})});}_0x4095e2=_[_0xd788('0x5e')]({},_0x4095e2,_0x5e146e[_0xd788('0x5f')]);return _0x20adff[_0xd788('0x110')](_0x4095e2);}})['then'](function(_0x3da744){if(_0x3da744){_0x147767=_0x3da744[_0xd788('0x4d')];if(!_0x5e146e['query']['hasOwnProperty']('nolimit')){_0x4095e2[_0xd788('0x24')]=qs[_0xd788('0x24')](_0x5e146e[_0xd788('0x45')]['limit']);_0x4095e2[_0xd788('0x22')]=qs[_0xd788('0x22')](_0x5e146e[_0xd788('0x45')][_0xd788('0x22')]);}return _0x20adff[_0xd788('0x110')](_0x4095e2);}})[_0xd788('0x16')](function(_0x24bf67){if(_0x24bf67){return _0x24bf67?{'count':_0x147767,'rows':_0x24bf67}:null;}})[_0xd788('0x16')](respondWithResult(_0x3c2abf,null))['catch'](handleError(_0x3c2abf,null));};exports[_0xd788('0x111')]=function(_0x125351,_0x541a3b){var _0x1f783e=_0x125351[_0xd788('0x62')]['id'];var _0xd67d04=_0x125351[_0xd788('0x61')]?_0x125351[_0xd788('0x61')][_0xd788('0xad')]:null;var _0x31cf30=[];return Promise[_0xd788('0x112')]()[_0xd788('0x16')](function(){if(!_0xd67d04)throw new APIBadRequestError(_0xd788('0x113'));})[_0xd788('0x16')](function(){return db[_0xd788('0x3e')][_0xd788('0x9d')]({'where':{'id':_0x1f783e}});})[_0xd788('0x16')](function(_0x41316d){if(!_0x41316d)throw new APINotFoundError(util[_0xd788('0xb3')](_0xd788('0x10f'),_0x125351[_0xd788('0x62')]['id']));return db['sequelize'][_0xd788('0x114')](function(_0x55e55d){return _0x41316d[_0xd788('0x111')](_0xd67d04,{'transaction':_0x55e55d})[_0xd788('0x16')](function(){return db[_0xd788('0x115')][_0xd788('0x49')]({'where':{'id':{'$in':_0xd67d04}}});})['then'](function(_0x196d7f){var _0x8e00df=_[_0xd788('0x35')](_0x196d7f,function(_0x58f6f7){return _0x58f6f7[_0xd788('0x116')]();});return Promise[_0xd788('0x56')](_0x8e00df);})['then'](function(_0x3ef87d){_0x31cf30=_['flattenDeep'](_0x3ef87d);var _0x101a35=_[_0xd788('0x35')](_0x31cf30,function(_0x5ecc23){return _0x5ecc23[_0xd788('0x117')](_0x41316d['id'],{'transaction':_0x55e55d});});return Promise['all'](_0x101a35);})[_0xd788('0x16')](function(){if(!_0x41316d[_0xd788('0x102')])return;var _0x1c29ea=_['filter'](_0x31cf30,function(_0x13d437){return _0x13d437[_0xd788('0x118')](_0xd788('0xa3'))===_0xd788('0x119');});var _0x826fc4=_[_0xd788('0x35')](_0x1c29ea,function(_0x133d42){return db[_0xd788('0xb5')][_0xd788('0xb6')]({'membername':_0x41316d[_0xd788('0x3c')],'UserId':_0x41316d['id'],'queue_name':_0x133d42[_0xd788('0x3c')],'VoiceQueueId':_0x133d42['id'],'interface':_[_0xd788('0x6d')](_0x41316d[_0xd788('0xa6')])?util['format']('SIP/%s',_0x41316d['name']):_0x41316d[_0xd788('0xa6')],'paused':_0x41316d[_0xd788('0xa5')]||![],'penalty':_0x41316d['penalty']},{'transaction':_0x55e55d});});return Promise[_0xd788('0x56')](_0x826fc4);})[_0xd788('0x16')](function(){return db['TeamVoicePrefix']['findAll']({'where':{'teamId':{'$in':_0xd67d04}}});})['then'](function(_0x3dc9df){var _0x49e56d=_[_0xd788('0x35')](_0x3dc9df,function(_0x14d6bd){return db[_0xd788('0x11a')][_0xd788('0x87')]({'UserId':_0x41316d['id'],'VoicePrefixId':_0x14d6bd[_0xd788('0x11b')]},{'transaction':_0x55e55d});});return Promise[_0xd788('0x56')](_0x49e56d);});});})[_0xd788('0x16')](function(){for(var _0x4d4500=0x0;_0x4d4500<_0x31cf30[_0xd788('0x4d')];_0x4d4500++){var _0x8af1fd=_0x31cf30[_0x4d4500][_0xd788('0x118')](_0xd788('0xa3'));var _0x3d782f=_0x8af1fd+_0xd788('0xaf');socket['emit'](_0xd788('0x2f')+_0x8af1fd+_0xd788('0xb0'),{'UserId':_0x1f783e,['queueField']:_0x31cf30[_0x4d4500]['id']});}})['then'](respondWithStatusCode(_0x541a3b,null))[_0xd788('0x60')](APIHandleError(_0x541a3b));};exports[_0xd788('0x11c')]=function(_0x588dc5,_0x44e5e8){var _0x11ba1a=_0x588dc5[_0xd788('0x62')]['id'];var _0x1d7a75=null;if(_0x588dc5[_0xd788('0x45')][_0xd788('0xad')]){_0x1d7a75=_[_0xd788('0x11d')](_0x588dc5['query']['ids'])?_0x588dc5[_0xd788('0x45')][_0xd788('0xad')]:[_0x588dc5[_0xd788('0x45')][_0xd788('0xad')]];}var _0x36219f=[];return Promise[_0xd788('0x112')]()[_0xd788('0x16')](function(){if(!_0x1d7a75)throw new APIBadRequestError(_0xd788('0x11e'));})[_0xd788('0x16')](function(){return db[_0xd788('0x3e')][_0xd788('0x9d')]({'where':{'id':_0x11ba1a}});})[_0xd788('0x16')](function(_0x1b09ae){if(!_0x1b09ae)throw new APINotFoundError(util[_0xd788('0xb3')](_0xd788('0x10f'),_0x588dc5['params']['id']));return db[_0xd788('0x6f')][_0xd788('0x114')](function(_0x7c3819){return _0x1b09ae['removeTeams'](_0x1d7a75,{'transaction':_0x7c3819})[_0xd788('0x16')](function(){return db['Team'][_0xd788('0x49')]({'where':{'id':{'$in':_0x1d7a75}}});})[_0xd788('0x16')](function(_0x59d8ac){var _0x30ab4a=_[_0xd788('0x35')](_0x59d8ac,function(_0x3b0c15){return _0x3b0c15['getAssociatedQueues']();});return Promise[_0xd788('0x56')](_0x30ab4a);})[_0xd788('0x16')](function(_0x642a7a){_0x36219f=_[_0xd788('0x11f')](_0x642a7a);var _0x2bd4d6=_[_0xd788('0x35')](_0x36219f,function(_0x51f1dd){return _0x51f1dd[_0xd788('0x120')](_0x1b09ae['id'],{'transaction':_0x7c3819});});return Promise['all'](_0x2bd4d6);})['then'](function(){if(!_0x1b09ae[_0xd788('0x102')])return;var _0x160c1a=_[_0xd788('0x41')](_0x36219f,function(_0x2b4fc8){return _0x2b4fc8[_0xd788('0x118')]('channel')===_0xd788('0x119');});var _0x40256a=_[_0xd788('0x35')](_0x160c1a,function(_0x38119d){return db[_0xd788('0xb5')][_0xd788('0x2a')]({'where':{'VoiceQueueId':_0x38119d['id'],'UserId':_0x1b09ae['id']},'transaction':_0x7c3819});});return Promise[_0xd788('0x56')](_0x40256a);})[_0xd788('0x16')](function(){return db[_0xd788('0x121')][_0xd788('0x49')]({'where':{'teamId':{'$in':_0x1d7a75}}});})[_0xd788('0x16')](function(_0x4272c8){var _0x390d20=_[_0xd788('0x35')](_0x4272c8,function(_0xc57a0f){return db[_0xd788('0x11a')][_0xd788('0x2a')]({'where':{'UserId':_0x1b09ae['id'],'VoicePrefixId':_0xc57a0f['VoicePrefixId']}},{'transaction':_0x7c3819});});return Promise['all'](_0x390d20);});});})[_0xd788('0x16')](function(){for(var _0x345e3e=0x0;_0x345e3e<_0x36219f[_0xd788('0x4d')];_0x345e3e++){var _0x2e74e7=_0x36219f[_0x345e3e][_0xd788('0x118')](_0xd788('0xa3'));var _0x36bca7=_0x2e74e7+'QueueId';socket[_0xd788('0x28')](_0xd788('0x2f')+_0x2e74e7+_0xd788('0xb9'),{'UserId':_0x11ba1a,['queueField']:_0x36219f[_0x345e3e]['id']});}})[_0xd788('0x16')](respondWithStatusCode(_0x44e5e8,null))['catch'](APIHandleError(_0x44e5e8));};exports[_0xd788('0x122')]=function(_0x51ab9b,_0x3f8b91){var _0x55e58f={};var _0x3940e3={};var _0x43340f;var _0xec6798;return db[_0xd788('0x3e')][_0xd788('0x9d')]({'where':{'id':_0x51ab9b[_0xd788('0x62')]['id']}})['then'](handleEntityNotFound(_0x3f8b91,null))[_0xd788('0x16')](function(_0x4a90b8){if(_0x4a90b8){_0x43340f=_0x4a90b8;_0x3940e3['model']=_['keys'](db['CmList'][_0xd788('0x58')]);_0x3940e3[_0xd788('0x45')]=_[_0xd788('0x57')](_0x51ab9b[_0xd788('0x45')]);_0x3940e3[_0xd788('0x59')]=_[_0xd788('0x5a')](_0x3940e3['model'],_0x3940e3[_0xd788('0x45')]);_0x55e58f[_0xd788('0x48')]=_['intersection'](_0x3940e3[_0xd788('0x5c')],qs[_0xd788('0x5b')](_0x51ab9b[_0xd788('0x45')][_0xd788('0x5b')]));_0x55e58f[_0xd788('0x48')]=_0x55e58f['attributes'][_0xd788('0x4d')]?_0x55e58f[_0xd788('0x48')]:_0x3940e3[_0xd788('0x5c')];_0x55e58f['order']=qs[_0xd788('0xce')](_0x51ab9b[_0xd788('0x45')][_0xd788('0xce')]);_0x55e58f[_0xd788('0xd0')]=qs[_0xd788('0x59')](_[_0xd788('0xcf')](_0x51ab9b[_0xd788('0x45')],_0x3940e3[_0xd788('0x59')]));if(_0x51ab9b[_0xd788('0x45')][_0xd788('0x41')]){_0x55e58f['where']=_['merge'](_0x55e58f[_0xd788('0xd0')],{'$or':_[_0xd788('0x35')](_0x55e58f[_0xd788('0x48')],function(_0x55832b){var _0x302003={};_0x302003[_0x55832b]={'$like':'%'+_0x51ab9b[_0xd788('0x45')][_0xd788('0x41')]+'%'};return _0x302003;})});}_0x55e58f=_[_0xd788('0x5e')]({},_0x55e58f,_0x51ab9b['options']);return _0x43340f['getLists'](_0x55e58f);}})[_0xd788('0x16')](function(_0x1fba55){if(_0x1fba55){_0xec6798=_0x1fba55[_0xd788('0x4d')];if(!_0x51ab9b[_0xd788('0x45')][_0xd788('0xd5')](_0xd788('0xd6'))){_0x55e58f[_0xd788('0x24')]=qs[_0xd788('0x24')](_0x51ab9b[_0xd788('0x45')][_0xd788('0x24')]);_0x55e58f['offset']=qs[_0xd788('0x22')](_0x51ab9b['query'][_0xd788('0x22')]);}return _0x43340f[_0xd788('0x122')](_0x55e58f);}})[_0xd788('0x16')](function(_0x5578b9){if(_0x5578b9){return _0x5578b9?{'count':_0xec6798,'rows':_0x5578b9}:null;}})[_0xd788('0x16')](respondWithResult(_0x3f8b91,null))[_0xd788('0x60')](handleError(_0x3f8b91,null));};exports[_0xd788('0x123')]=function(_0x54a541,_0x1996d8){var _0x9dab13={};var _0x5be675={};var _0x445011;return db[_0xd788('0x3e')][_0xd788('0x9d')]({'where':{'id':_0x54a541[_0xd788('0x62')]['id']}})[_0xd788('0x16')](handleEntityNotFound(_0x1996d8,null))[_0xd788('0x16')](function(_0x1cdaa0){if(_0x1cdaa0){_0x445011=_0x1cdaa0;_0x5be675[_0xd788('0x5c')]=_[_0xd788('0x57')](db['User']['rawAttributes']);_0x5be675[_0xd788('0x45')]=_[_0xd788('0x57')](_0x54a541[_0xd788('0x45')]);_0x5be675[_0xd788('0x59')]=_[_0xd788('0x5a')](_0x5be675['model'],_0x5be675[_0xd788('0x45')]);_0x9dab13['attributes']=_[_0xd788('0x5a')](_0x5be675[_0xd788('0x5c')],qs['fields'](_0x54a541['query'][_0xd788('0x5b')]));_0x9dab13[_0xd788('0x48')]=_0x9dab13[_0xd788('0x48')]['length']?_0x9dab13['attributes']:_0x5be675[_0xd788('0x5c')];_0x9dab13[_0xd788('0xcd')]=qs[_0xd788('0xce')](_0x54a541['query'][_0xd788('0xce')]);_0x9dab13[_0xd788('0xd0')]=qs[_0xd788('0x59')](_[_0xd788('0xcf')](_0x54a541[_0xd788('0x45')],_0x5be675['filters']));if(_0x54a541['query'][_0xd788('0x41')]){_0x9dab13[_0xd788('0xd0')]=_[_0xd788('0x5e')](_0x9dab13[_0xd788('0xd0')],{'$or':_['map'](_0x9dab13['attributes'],function(_0x17e308){var _0x4cab32={};_0x4cab32[_0x17e308]={'$like':'%'+_0x54a541[_0xd788('0x45')][_0xd788('0x41')]+'%'};return _0x4cab32;})});}_0x9dab13[_0xd788('0x5c')]=db[_0xd788('0x3e')];_0x9dab13['as']=_0xd788('0x30');_0x9dab13=_['merge']({},_0x9dab13,_0x54a541[_0xd788('0x5f')]);return _0x445011['getVoiceQueues']({'include':[_0x9dab13]});}})['then'](function(_0x15a850){if(_0x15a850){var _0x57ff3a={},_0x13d064=[];for(var _0xdc6c20=0x0;_0xdc6c20<_0x15a850[_0xd788('0x4d')];_0xdc6c20+=0x1){for(var _0x48a6de=0x0,_0x3aaa95;_0x48a6de<_0x15a850[_0xdc6c20]['Agents']['length'];_0x48a6de+=0x1){_0x3aaa95=_0x15a850[_0xdc6c20]['Agents'][_0x48a6de]['get']({'plain':!![]});_0x57ff3a[_0x3aaa95['id']]=_0x3aaa95;}}_0x57ff3a=_[_0xd788('0x124')](_0x57ff3a);for(var _0x3ac72b=qs[_0xd788('0x22')](_0x54a541['query']['offset']);_0x3ac72b<_0x57ff3a[_0xd788('0x4d')]&&_0x13d064[_0xd788('0x4d')]<qs['limit'](_0x54a541['query']['limit']);_0x3ac72b+=0x1){if(_0x57ff3a[_0x3ac72b]){_0x13d064[_0xd788('0x4e')](_0x57ff3a[_0x3ac72b]);}}return{'count':_0x57ff3a[_0xd788('0x4d')],'rows':_0x13d064};}})[_0xd788('0x16')](respondWithResult(_0x1996d8,null))[_0xd788('0x60')](handleError(_0x1996d8,null));};exports[_0xd788('0x2a')]=function(_0x3e55b8,_0x3b6a73){if(_0x3e55b8[_0xd788('0x2f')]['id']==_0x3e55b8[_0xd788('0x62')]['id']){return _0x3b6a73[_0xd788('0x21')](0x1f4)['send']({'message':'You\x20can\x27t\x20delete\x20yourself'});}return db[_0xd788('0x3e')][_0xd788('0x38')]({'where':{'id':_0x3e55b8[_0xd788('0x62')]['id']}})['then'](handleEntityNotFound(_0x3b6a73,null))[_0xd788('0x16')](removeEntity(_0x3b6a73,null))['catch'](handleError(_0x3b6a73,null));};exports[_0xd788('0x125')]=function(_0x43dec5,_0x286f6e){return db['User'][_0xd788('0x38')]({'where':{'id':_0x43dec5[_0xd788('0x62')]['id']}})['then'](handleEntityNotFound(_0x286f6e,null))[_0xd788('0x16')](function(_0x32ac95){if(_0x32ac95){return _0x32ac95['addChatInteractions'](_0x43dec5[_0xd788('0x61')][_0xd788('0xad')],_[_0xd788('0x65')](_0x43dec5[_0xd788('0x61')],[_0xd788('0xad'),'id'])||{})['spread'](function(){for(var _0x38e57f=0x0;_0x38e57f<_0x43dec5[_0xd788('0x61')]['ids']['length'];_0x38e57f+=0x1){socket[_0xd788('0x28')]('user_has_chat_interactions:save',{'ChatInteractionId':Number(_0x43dec5[_0xd788('0x61')][_0xd788('0xad')][_0x38e57f]),'UserId':Number(_0x43dec5[_0xd788('0x62')]['id'])});}return _0x43dec5['body'][_0xd788('0xad')];});}})[_0xd788('0x16')](respondWithResult(_0x286f6e,null))[_0xd788('0x60')](handleError(_0x286f6e,null));};exports['removeChatInteractions']=function(_0x29fda7,_0x3b83c9){return db[_0xd788('0x3e')][_0xd788('0x38')]({'where':{'id':_0x29fda7['params']['id']}})[_0xd788('0x16')](handleEntityNotFound(_0x3b83c9,null))[_0xd788('0x16')](function(_0x32222b){if(_0x32222b){return _0x32222b[_0xd788('0x126')](_0x29fda7[_0xd788('0x45')][_0xd788('0xad')])[_0xd788('0x16')](function(){if(_[_0xd788('0x11d')](_0x29fda7[_0xd788('0x45')][_0xd788('0xad')])){for(var _0x14a3e6=0x0;_0x14a3e6<_0x29fda7['query'][_0xd788('0xad')][_0xd788('0x4d')];_0x14a3e6+=0x1){socket[_0xd788('0x28')](_0xd788('0x127'),{'ChatInteractionId':Number(_0x29fda7['query'][_0xd788('0xad')][_0x14a3e6]),'UserId':Number(_0x29fda7['params']['id'])});}}else{socket['emit'](_0xd788('0x127'),{'ChatInteractionId':Number(_0x29fda7[_0xd788('0x45')][_0xd788('0xad')]),'UserId':Number(_0x29fda7[_0xd788('0x62')]['id'])});}});}})['then'](respondWithStatusCode(_0x3b83c9,null))[_0xd788('0x60')](handleError(_0x3b83c9,null));};exports['addMailInteractions']=function(_0x92ee3e,_0x2dfc37){return db[_0xd788('0x3e')][_0xd788('0x38')]({'where':{'id':_0x92ee3e[_0xd788('0x62')]['id']}})[_0xd788('0x16')](handleEntityNotFound(_0x2dfc37,null))['then'](function(_0x3b32be){if(_0x3b32be){return _0x3b32be['addMailInteractions'](_0x92ee3e[_0xd788('0x61')][_0xd788('0xad')],_[_0xd788('0x65')](_0x92ee3e[_0xd788('0x61')],[_0xd788('0xad'),'id'])||{})[_0xd788('0x128')](function(){for(var _0x27a5b9=0x0;_0x27a5b9<_0x92ee3e[_0xd788('0x61')]['ids'][_0xd788('0x4d')];_0x27a5b9+=0x1){socket[_0xd788('0x28')](_0xd788('0x129'),{'MailInteractionId':Number(_0x92ee3e[_0xd788('0x61')][_0xd788('0xad')][_0x27a5b9]),'UserId':Number(_0x92ee3e['params']['id'])});}return _0x92ee3e[_0xd788('0x61')][_0xd788('0xad')];});}})[_0xd788('0x16')](respondWithResult(_0x2dfc37,null))['catch'](handleError(_0x2dfc37,null));};exports[_0xd788('0x12a')]=function(_0x3d56a5,_0x3a5189){return db[_0xd788('0x3e')][_0xd788('0x38')]({'where':{'id':_0x3d56a5[_0xd788('0x62')]['id']}})[_0xd788('0x16')](handleEntityNotFound(_0x3a5189,null))['then'](function(_0x41550b){if(_0x41550b){return _0x41550b[_0xd788('0x12a')](_0x3d56a5[_0xd788('0x45')][_0xd788('0xad')])[_0xd788('0x16')](function(){if(_['isArray'](_0x3d56a5['query']['ids'])){for(var _0x366b40=0x0;_0x366b40<_0x3d56a5[_0xd788('0x45')][_0xd788('0xad')][_0xd788('0x4d')];_0x366b40+=0x1){socket['emit'](_0xd788('0x12b'),{'MailInteractionId':Number(_0x3d56a5['query'][_0xd788('0xad')][_0x366b40]),'UserId':Number(_0x3d56a5[_0xd788('0x62')]['id'])});}}else{socket[_0xd788('0x28')](_0xd788('0x12b'),{'MailInteractionId':Number(_0x3d56a5[_0xd788('0x45')]['ids']),'UserId':Number(_0x3d56a5[_0xd788('0x62')]['id'])});}});}})[_0xd788('0x16')](respondWithStatusCode(_0x3a5189,null))[_0xd788('0x60')](handleError(_0x3a5189,null));};exports[_0xd788('0x12c')]=function(_0x10257e,_0x458051){return db[_0xd788('0x3e')][_0xd788('0x38')]({'where':{'id':_0x10257e[_0xd788('0x62')]['id']}})[_0xd788('0x16')](handleEntityNotFound(_0x458051,null))[_0xd788('0x16')](function(_0x5c67c5){if(_0x5c67c5){return _0x5c67c5['addFaxInteractions'](_0x10257e[_0xd788('0x61')][_0xd788('0xad')],_[_0xd788('0x65')](_0x10257e['body'],['ids','id'])||{})[_0xd788('0x128')](function(){for(var _0x21c38b=0x0;_0x21c38b<_0x10257e[_0xd788('0x61')]['ids']['length'];_0x21c38b+=0x1){socket[_0xd788('0x28')](_0xd788('0x12d'),{'FaxInteractionId':Number(_0x10257e['body'][_0xd788('0xad')][_0x21c38b]),'UserId':Number(_0x10257e[_0xd788('0x62')]['id'])});}return _0x10257e[_0xd788('0x61')][_0xd788('0xad')];});}})[_0xd788('0x16')](respondWithResult(_0x458051,null))[_0xd788('0x60')](handleError(_0x458051,null));};exports[_0xd788('0x12e')]=function(_0x464db7,_0x53396e){return db['User'][_0xd788('0x38')]({'where':{'id':_0x464db7['params']['id']}})[_0xd788('0x16')](handleEntityNotFound(_0x53396e,null))[_0xd788('0x16')](function(_0x368f93){if(_0x368f93){return _0x368f93['removeFaxInteractions'](_0x464db7[_0xd788('0x45')][_0xd788('0xad')])[_0xd788('0x16')](function(){if(_[_0xd788('0x11d')](_0x464db7['query'][_0xd788('0xad')])){for(var _0x56ad39=0x0;_0x56ad39<_0x464db7[_0xd788('0x45')][_0xd788('0xad')][_0xd788('0x4d')];_0x56ad39+=0x1){socket[_0xd788('0x28')]('user_has_fax_interactions:remove',{'FaxInteractionId':Number(_0x464db7[_0xd788('0x45')]['ids'][_0x56ad39]),'UserId':Number(_0x464db7['params']['id'])});}}else{socket[_0xd788('0x28')]('user_has_fax_interactions:remove',{'FaxInteractionId':Number(_0x464db7['query']['ids']),'UserId':Number(_0x464db7[_0xd788('0x62')]['id'])});}});}})[_0xd788('0x16')](respondWithStatusCode(_0x53396e,null))[_0xd788('0x60')](handleError(_0x53396e,null));};exports[_0xd788('0x12f')]=function(_0x3ea8a6,_0x3698cf){return db['User']['find']({'where':{'id':_0x3ea8a6[_0xd788('0x62')]['id']}})[_0xd788('0x16')](handleEntityNotFound(_0x3698cf,null))[_0xd788('0x16')](function(_0x53ae82){if(_0x53ae82){return _0x53ae82['addSmsInteractions'](_0x3ea8a6['body'][_0xd788('0xad')],_[_0xd788('0x65')](_0x3ea8a6[_0xd788('0x61')],[_0xd788('0xad'),'id'])||{})[_0xd788('0x128')](function(){for(var _0x27b1e9=0x0;_0x27b1e9<_0x3ea8a6[_0xd788('0x61')][_0xd788('0xad')][_0xd788('0x4d')];_0x27b1e9+=0x1){socket['emit'](_0xd788('0x130'),{'SmsInteractionId':Number(_0x3ea8a6[_0xd788('0x61')][_0xd788('0xad')][_0x27b1e9]),'UserId':Number(_0x3ea8a6[_0xd788('0x62')]['id'])});}return _0x3ea8a6[_0xd788('0x61')]['ids'];});}})[_0xd788('0x16')](respondWithResult(_0x3698cf,null))['catch'](handleError(_0x3698cf,null));};exports[_0xd788('0x131')]=function(_0x3918ce,_0x5a6e5c){return db[_0xd788('0x3e')][_0xd788('0x38')]({'where':{'id':_0x3918ce[_0xd788('0x62')]['id']}})[_0xd788('0x16')](handleEntityNotFound(_0x5a6e5c,null))[_0xd788('0x16')](function(_0x4f1d03){if(_0x4f1d03){return _0x4f1d03[_0xd788('0x131')](_0x3918ce[_0xd788('0x45')]['ids'])[_0xd788('0x16')](function(){if(_['isArray'](_0x3918ce[_0xd788('0x45')][_0xd788('0xad')])){for(var _0x41df7f=0x0;_0x41df7f<_0x3918ce[_0xd788('0x45')]['ids'][_0xd788('0x4d')];_0x41df7f+=0x1){socket[_0xd788('0x28')](_0xd788('0x132'),{'SmsInteractionId':Number(_0x3918ce[_0xd788('0x45')][_0xd788('0xad')][_0x41df7f]),'UserId':Number(_0x3918ce[_0xd788('0x62')]['id'])});}}else{socket[_0xd788('0x28')](_0xd788('0x132'),{'SmsInteractionId':Number(_0x3918ce['query'][_0xd788('0xad')]),'UserId':Number(_0x3918ce[_0xd788('0x62')]['id'])});}});}})[_0xd788('0x16')](respondWithStatusCode(_0x5a6e5c,null))[_0xd788('0x60')](handleError(_0x5a6e5c,null));};exports[_0xd788('0x133')]=function(_0x1b09ac,_0x3b37fd){return db[_0xd788('0x3e')]['find']({'where':{'id':_0x1b09ac['params']['id']}})[_0xd788('0x16')](handleEntityNotFound(_0x3b37fd,null))[_0xd788('0x16')](function(_0xbbdc54){if(_0xbbdc54){return _0xbbdc54[_0xd788('0x133')](_0x1b09ac[_0xd788('0x61')][_0xd788('0xad')],_['omit'](_0x1b09ac[_0xd788('0x61')],[_0xd788('0xad'),'id'])||{})[_0xd788('0x128')](function(){for(var _0x3e0f0b=0x0;_0x3e0f0b<_0x1b09ac['body'][_0xd788('0xad')]['length'];_0x3e0f0b+=0x1){socket['emit'](_0xd788('0x134'),{'OpenchannelInteractionId':Number(_0x1b09ac[_0xd788('0x61')][_0xd788('0xad')][_0x3e0f0b]),'UserId':Number(_0x1b09ac[_0xd788('0x62')]['id'])});}return _0x1b09ac['body'][_0xd788('0xad')];});}})[_0xd788('0x16')](respondWithResult(_0x3b37fd,null))[_0xd788('0x60')](handleError(_0x3b37fd,null));};exports['removeOpenchannelInteractions']=function(_0x3113df,_0x1775f2){return db[_0xd788('0x3e')][_0xd788('0x38')]({'where':{'id':_0x3113df[_0xd788('0x62')]['id']}})['then'](handleEntityNotFound(_0x1775f2,null))[_0xd788('0x16')](function(_0x94ad32){if(_0x94ad32){return _0x94ad32[_0xd788('0x135')](_0x3113df[_0xd788('0x45')][_0xd788('0xad')])[_0xd788('0x16')](function(){if(_[_0xd788('0x11d')](_0x3113df['query'][_0xd788('0xad')])){for(var _0x43fe27=0x0;_0x43fe27<_0x3113df[_0xd788('0x45')][_0xd788('0xad')][_0xd788('0x4d')];_0x43fe27+=0x1){socket['emit'](_0xd788('0x136'),{'OpenchannelInteractionId':Number(_0x3113df['query'][_0xd788('0xad')][_0x43fe27]),'UserId':Number(_0x3113df['params']['id'])});}}else{socket[_0xd788('0x28')](_0xd788('0x136'),{'OpenchannelInteractionId':Number(_0x3113df['query'][_0xd788('0xad')]),'UserId':Number(_0x3113df[_0xd788('0x62')]['id'])});}});}})['then'](respondWithStatusCode(_0x1775f2,null))['catch'](handleError(_0x1775f2,null));};exports['addWhatsappInteractions']=function(_0x3fd665,_0x53f16d){return db[_0xd788('0x3e')][_0xd788('0x38')]({'where':{'id':_0x3fd665['params']['id']}})['then'](handleEntityNotFound(_0x53f16d,null))[_0xd788('0x16')](function(_0x3b7b02){if(_0x3b7b02){return _0x3b7b02[_0xd788('0x137')](_0x3fd665[_0xd788('0x61')]['ids'],_[_0xd788('0x65')](_0x3fd665[_0xd788('0x61')],[_0xd788('0xad'),'id'])||{})['spread'](function(){for(var _0x355a91=0x0;_0x355a91<_0x3fd665[_0xd788('0x61')][_0xd788('0xad')]['length'];_0x355a91+=0x1){socket[_0xd788('0x28')](_0xd788('0x138'),{'WhatsappInteractionId':Number(_0x3fd665[_0xd788('0x61')][_0xd788('0xad')][_0x355a91]),'UserId':Number(_0x3fd665[_0xd788('0x62')]['id'])});}return _0x3fd665[_0xd788('0x61')][_0xd788('0xad')];});}})['then'](respondWithResult(_0x53f16d,null))[_0xd788('0x60')](handleError(_0x53f16d,null));};exports[_0xd788('0x139')]=function(_0x4d1dd7,_0x2eca87){return db[_0xd788('0x3e')]['find']({'where':{'id':_0x4d1dd7[_0xd788('0x62')]['id']}})[_0xd788('0x16')](handleEntityNotFound(_0x2eca87,null))[_0xd788('0x16')](function(_0x6b493e){if(_0x6b493e){return _0x6b493e[_0xd788('0x139')](_0x4d1dd7[_0xd788('0x45')]['ids']);}})[_0xd788('0x16')](respondWithStatusCode(_0x2eca87,null))['catch'](handleError(_0x2eca87,null));};exports['getVoicePrefixes']=function(_0x1a5afa,_0x439228){var _0x226bcd={};var _0x3a7ecd={};var _0x32a195;var _0x2a9fa9;return db['User'][_0xd788('0x9d')]({'where':{'id':_0x1a5afa['params']['id']}})['then'](handleEntityNotFound(_0x439228,null))[_0xd788('0x16')](function(_0x80df8b){if(_0x80df8b){_0x32a195=_0x80df8b;_0x3a7ecd[_0xd788('0x5c')]=_['keys'](db[_0xd788('0x13a')][_0xd788('0x58')]);_0x3a7ecd[_0xd788('0x45')]=_[_0xd788('0x57')](_0x1a5afa[_0xd788('0x45')]);_0x3a7ecd['filters']=_[_0xd788('0x5a')](_0x3a7ecd[_0xd788('0x5c')],_0x3a7ecd[_0xd788('0x45')]);_0x226bcd[_0xd788('0x48')]=_[_0xd788('0x5a')](_0x3a7ecd[_0xd788('0x5c')],qs['fields'](_0x1a5afa[_0xd788('0x45')][_0xd788('0x5b')]));_0x226bcd[_0xd788('0x48')]=_0x226bcd[_0xd788('0x48')]['length']?_0x226bcd[_0xd788('0x48')]:_0x3a7ecd[_0xd788('0x5c')];_0x226bcd[_0xd788('0xcd')]=qs['sort'](_0x1a5afa[_0xd788('0x45')][_0xd788('0xce')]);_0x226bcd[_0xd788('0xd0')]=qs[_0xd788('0x59')](_[_0xd788('0xcf')](_0x1a5afa['query'],_0x3a7ecd[_0xd788('0x59')]));if(_0x1a5afa[_0xd788('0x45')][_0xd788('0x41')]){_0x226bcd[_0xd788('0xd0')]=_[_0xd788('0x5e')](_0x226bcd[_0xd788('0xd0')],{'$or':_[_0xd788('0x35')](_0x226bcd[_0xd788('0x48')],function(_0x5e2038){var _0x4693af={};_0x4693af[_0x5e2038]={'$like':'%'+_0x1a5afa[_0xd788('0x45')][_0xd788('0x41')]+'%'};return _0x4693af;})});}_0x226bcd=_[_0xd788('0x5e')]({},_0x226bcd,_0x1a5afa['options']);return _0x32a195['getVoicePrefixes'](_0x226bcd);}})[_0xd788('0x16')](function(_0x15b5ed){if(_0x15b5ed){_0x2a9fa9=_0x15b5ed['length'];if(!_0x1a5afa['query'][_0xd788('0xd5')](_0xd788('0xd6'))){_0x226bcd[_0xd788('0x24')]=qs[_0xd788('0x24')](_0x1a5afa[_0xd788('0x45')][_0xd788('0x24')]);_0x226bcd['offset']=qs[_0xd788('0x22')](_0x1a5afa[_0xd788('0x45')][_0xd788('0x22')]);}return _0x32a195[_0xd788('0x13b')](_0x226bcd);}})[_0xd788('0x16')](function(_0x30709){if(_0x30709){return _0x30709?{'count':_0x2a9fa9,'rows':_0x30709}:null;}})['then'](respondWithResult(_0x439228,null))[_0xd788('0x60')](handleError(_0x439228,null));};exports[_0xd788('0x13c')]=function(_0x23cc85,_0x501c05){var _0x25d2a9={};var _0x2ab8f5={};var _0x121f2d;var _0x2771c2;return db[_0xd788('0x3e')][_0xd788('0x9d')]({'where':{'id':_0x23cc85[_0xd788('0x62')]['id']}})[_0xd788('0x16')](handleEntityNotFound(_0x501c05,null))[_0xd788('0x16')](function(_0x1ada27){if(_0x1ada27){_0x121f2d=_0x1ada27;_0x2ab8f5[_0xd788('0x5c')]=_['keys'](db[_0xd788('0x13d')][_0xd788('0x58')]);_0x2ab8f5[_0xd788('0x45')]=_['keys'](_0x23cc85[_0xd788('0x45')]);_0x2ab8f5[_0xd788('0x59')]=_[_0xd788('0x5a')](_0x2ab8f5[_0xd788('0x5c')],_0x2ab8f5[_0xd788('0x45')]);_0x25d2a9[_0xd788('0x48')]=_[_0xd788('0x5a')](_0x2ab8f5['model'],qs[_0xd788('0x5b')](_0x23cc85[_0xd788('0x45')][_0xd788('0x5b')]));_0x25d2a9[_0xd788('0x48')]=_0x25d2a9[_0xd788('0x48')][_0xd788('0x4d')]?_0x25d2a9[_0xd788('0x48')]:_0x2ab8f5[_0xd788('0x5c')];_0x25d2a9[_0xd788('0xcd')]=qs[_0xd788('0xce')](_0x23cc85[_0xd788('0x45')]['sort']);_0x25d2a9['where']=qs[_0xd788('0x59')](_[_0xd788('0xcf')](_0x23cc85[_0xd788('0x45')],_0x2ab8f5['filters']));if(_0x23cc85['query'][_0xd788('0x41')]){_0x25d2a9['where']=_[_0xd788('0x5e')](_0x25d2a9[_0xd788('0xd0')],{'$or':_['map'](_0x25d2a9[_0xd788('0x48')],function(_0x55a963){var _0x5830f7={};_0x5830f7[_0x55a963]={'$like':'%'+_0x23cc85['query'][_0xd788('0x41')]+'%'};return _0x5830f7;})});}_0x25d2a9=_['merge']({},_0x25d2a9,_0x23cc85[_0xd788('0x5f')]);return _0x121f2d['getFaxAccounts'](_0x25d2a9);}})[_0xd788('0x16')](function(_0x2c3baa){if(_0x2c3baa){_0x2771c2=_0x2c3baa['length'];if(!_0x23cc85[_0xd788('0x45')]['hasOwnProperty'](_0xd788('0xd6'))){_0x25d2a9[_0xd788('0x24')]=qs[_0xd788('0x24')](_0x23cc85[_0xd788('0x45')]['limit']);_0x25d2a9['offset']=qs['offset'](_0x23cc85[_0xd788('0x45')][_0xd788('0x22')]);}return _0x121f2d[_0xd788('0x13c')](_0x25d2a9);}})[_0xd788('0x16')](function(_0x4bd2f4){if(_0x4bd2f4){return _0x4bd2f4?{'count':_0x2771c2,'rows':_0x4bd2f4}:null;}})['then'](respondWithResult(_0x501c05,null))[_0xd788('0x60')](handleError(_0x501c05,null));};exports[_0xd788('0x13e')]=function(_0x264e76,_0x2cec4b){return db[_0xd788('0x3e')][_0xd788('0x38')]({'where':{'id':_0x264e76[_0xd788('0x62')]['id']}})[_0xd788('0x16')](handleEntityNotFound(_0x2cec4b,null))[_0xd788('0x16')](function(_0x1fd227){if(_0x1fd227){return _0x1fd227[_0xd788('0x13e')](_0x264e76[_0xd788('0x61')][_0xd788('0xad')],_[_0xd788('0x65')](_0x264e76[_0xd788('0x61')],[_0xd788('0xad'),'id'])||{});}})[_0xd788('0x16')](respondWithResult(_0x2cec4b,null))[_0xd788('0x60')](handleError(_0x2cec4b,null));};exports['removeFaxAccounts']=function(_0x1727ed,_0x5496c3){return db[_0xd788('0x3e')][_0xd788('0x38')]({'where':{'id':_0x1727ed[_0xd788('0x62')]['id']}})['then'](handleEntityNotFound(_0x5496c3,null))[_0xd788('0x16')](function(_0x380835){if(_0x380835){return _0x380835[_0xd788('0x13f')](_0x1727ed[_0xd788('0x45')][_0xd788('0xad')]);}})[_0xd788('0x16')](respondWithStatusCode(_0x5496c3,null))[_0xd788('0x60')](handleError(_0x5496c3,null));};exports[_0xd788('0x140')]=function(_0x3fcf11,_0x2d1512){var _0x24fda0={};var _0x2f307b={};var _0x4a3ba6;var _0x1a106d;return db[_0xd788('0x3e')][_0xd788('0x9d')]({'where':{'id':_0x3fcf11[_0xd788('0x62')]['id']}})[_0xd788('0x16')](handleEntityNotFound(_0x2d1512,null))[_0xd788('0x16')](function(_0x34feb4){if(_0x34feb4){_0x4a3ba6=_0x34feb4;_0x2f307b['model']=_[_0xd788('0x57')](db[_0xd788('0x141')][_0xd788('0x58')]);_0x2f307b['query']=_['keys'](_0x3fcf11['query']);_0x2f307b['filters']=_[_0xd788('0x5a')](_0x2f307b['model'],_0x2f307b[_0xd788('0x45')]);_0x24fda0[_0xd788('0x48')]=_[_0xd788('0x5a')](_0x2f307b[_0xd788('0x5c')],qs['fields'](_0x3fcf11[_0xd788('0x45')]['fields']));_0x24fda0[_0xd788('0x48')]=_0x24fda0[_0xd788('0x48')][_0xd788('0x4d')]?_0x24fda0[_0xd788('0x48')]:_0x2f307b[_0xd788('0x5c')];_0x24fda0[_0xd788('0xcd')]=qs[_0xd788('0xce')](_0x3fcf11['query'][_0xd788('0xce')]);_0x24fda0[_0xd788('0xd0')]=qs[_0xd788('0x59')](_[_0xd788('0xcf')](_0x3fcf11['query'],_0x2f307b['filters']));if(_0x3fcf11[_0xd788('0x45')][_0xd788('0x41')]){_0x24fda0[_0xd788('0xd0')]=_[_0xd788('0x5e')](_0x24fda0[_0xd788('0xd0')],{'$or':_['map'](_0x24fda0[_0xd788('0x48')],function(_0x2cd329){var _0x54b454={};_0x54b454[_0x2cd329]={'$like':'%'+_0x3fcf11['query'][_0xd788('0x41')]+'%'};return _0x54b454;})});}_0x24fda0=_[_0xd788('0x5e')]({},_0x24fda0,_0x3fcf11[_0xd788('0x5f')]);return _0x4a3ba6[_0xd788('0x140')](_0x24fda0);}})['then'](function(_0x3629bc){if(_0x3629bc){_0x1a106d=_0x3629bc[_0xd788('0x4d')];if(!_0x3fcf11['query']['hasOwnProperty'](_0xd788('0xd6'))){_0x24fda0[_0xd788('0x24')]=qs[_0xd788('0x24')](_0x3fcf11[_0xd788('0x45')][_0xd788('0x24')]);_0x24fda0['offset']=qs[_0xd788('0x22')](_0x3fcf11[_0xd788('0x45')]['offset']);}return _0x4a3ba6[_0xd788('0x140')](_0x24fda0);}})[_0xd788('0x16')](function(_0x251c91){if(_0x251c91){return _0x251c91?{'count':_0x1a106d,'rows':_0x251c91}:null;}})[_0xd788('0x16')](respondWithResult(_0x2d1512,null))['catch'](handleError(_0x2d1512,null));};exports[_0xd788('0x142')]=function(_0x592060,_0x2c9c26){return db[_0xd788('0x3e')][_0xd788('0x38')]({'where':{'id':_0x592060[_0xd788('0x62')]['id']}})[_0xd788('0x16')](handleEntityNotFound(_0x2c9c26,null))[_0xd788('0x16')](function(_0x17fdb3){if(_0x17fdb3){return _0x17fdb3[_0xd788('0x142')](_0x592060[_0xd788('0x61')][_0xd788('0xad')],_['omit'](_0x592060['body'],['ids','id'])||{});}})[_0xd788('0x16')](respondWithResult(_0x2c9c26,null))[_0xd788('0x60')](handleError(_0x2c9c26,null));};exports[_0xd788('0x143')]=function(_0x3b7728,_0x256458){return db[_0xd788('0x3e')][_0xd788('0x38')]({'where':{'id':_0x3b7728[_0xd788('0x62')]['id']}})['then'](handleEntityNotFound(_0x256458,null))['then'](function(_0xd81666){if(_0xd81666){return _0xd81666[_0xd788('0x143')](_0x3b7728[_0xd788('0x45')][_0xd788('0xad')]);}})[_0xd788('0x16')](respondWithStatusCode(_0x256458,null))[_0xd788('0x60')](handleError(_0x256458,null));};exports[_0xd788('0x144')]=function(_0x15288e,_0x561288){var _0x540855={};var _0x2cf9b3={};var _0xbd1d4e;var _0x5eaa44;return db[_0xd788('0x3e')][_0xd788('0x9d')]({'where':{'id':_0x15288e['params']['id']}})[_0xd788('0x16')](handleEntityNotFound(_0x561288,null))[_0xd788('0x16')](function(_0xf751a6){if(_0xf751a6){_0xbd1d4e=_0xf751a6;_0x2cf9b3[_0xd788('0x5c')]=_[_0xd788('0x57')](db[_0xd788('0x145')][_0xd788('0x58')]);_0x2cf9b3['query']=_[_0xd788('0x57')](_0x15288e[_0xd788('0x45')]);_0x2cf9b3[_0xd788('0x59')]=_[_0xd788('0x5a')](_0x2cf9b3['model'],_0x2cf9b3[_0xd788('0x45')]);_0x540855[_0xd788('0x48')]=_['intersection'](_0x2cf9b3[_0xd788('0x5c')],qs[_0xd788('0x5b')](_0x15288e[_0xd788('0x45')][_0xd788('0x5b')]));_0x540855[_0xd788('0x48')]=_0x540855[_0xd788('0x48')][_0xd788('0x4d')]?_0x540855['attributes']:_0x2cf9b3[_0xd788('0x5c')];_0x540855['order']=qs[_0xd788('0xce')](_0x15288e[_0xd788('0x45')][_0xd788('0xce')]);_0x540855[_0xd788('0xd0')]=qs['filters'](_[_0xd788('0xcf')](_0x15288e['query'],_0x2cf9b3['filters']));if(_0x15288e[_0xd788('0x45')][_0xd788('0x41')]){_0x540855[_0xd788('0xd0')]=_['merge'](_0x540855['where'],{'$or':_[_0xd788('0x35')](_0x540855[_0xd788('0x48')],function(_0x4a74db){var _0x4c5cbd={};_0x4c5cbd[_0x4a74db]={'$like':'%'+_0x15288e[_0xd788('0x45')]['filter']+'%'};return _0x4c5cbd;})});}_0x540855=_['merge']({},_0x540855,_0x15288e[_0xd788('0x5f')]);return _0xbd1d4e[_0xd788('0x144')](_0x540855);}})[_0xd788('0x16')](function(_0x4327e8){if(_0x4327e8){_0x5eaa44=_0x4327e8[_0xd788('0x4d')];if(!_0x15288e[_0xd788('0x45')][_0xd788('0xd5')](_0xd788('0xd6'))){_0x540855['limit']=qs[_0xd788('0x24')](_0x15288e['query'][_0xd788('0x24')]);_0x540855[_0xd788('0x22')]=qs[_0xd788('0x22')](_0x15288e['query'][_0xd788('0x22')]);}return _0xbd1d4e[_0xd788('0x144')](_0x540855);}})['then'](function(_0x33c9c0){if(_0x33c9c0){return _0x33c9c0?{'count':_0x5eaa44,'rows':_0x33c9c0}:null;}})[_0xd788('0x16')](respondWithResult(_0x561288,null))[_0xd788('0x60')](handleError(_0x561288,null));};exports[_0xd788('0x146')]=function(_0x5b640c,_0x35c364){return db[_0xd788('0x3e')][_0xd788('0x38')]({'where':{'id':_0x5b640c[_0xd788('0x62')]['id']}})[_0xd788('0x16')](handleEntityNotFound(_0x35c364,null))[_0xd788('0x16')](function(_0x1d1d5e){if(_0x1d1d5e){return _0x1d1d5e[_0xd788('0x146')](_0x5b640c[_0xd788('0x61')][_0xd788('0xad')],_[_0xd788('0x65')](_0x5b640c[_0xd788('0x61')],[_0xd788('0xad'),'id'])||{});}})[_0xd788('0x16')](respondWithResult(_0x35c364,null))[_0xd788('0x60')](handleError(_0x35c364,null));};exports[_0xd788('0x147')]=function(_0x3df789,_0x4916d8){return db[_0xd788('0x3e')]['find']({'where':{'id':_0x3df789[_0xd788('0x62')]['id']}})[_0xd788('0x16')](handleEntityNotFound(_0x4916d8,null))[_0xd788('0x16')](function(_0x430f11){if(_0x430f11){return _0x430f11[_0xd788('0x147')](_0x3df789[_0xd788('0x45')]['ids']);}})[_0xd788('0x16')](respondWithStatusCode(_0x4916d8,null))[_0xd788('0x60')](handleError(_0x4916d8,null));};exports[_0xd788('0x148')]=function(_0x45c1e4,_0x49fc08){var _0x2d9d7b={};var _0x5621c7={};var _0x1b30d7;var _0x233f27;return db['User'][_0xd788('0x9d')]({'where':{'id':_0x45c1e4[_0xd788('0x62')]['id']}})[_0xd788('0x16')](handleEntityNotFound(_0x49fc08,null))[_0xd788('0x16')](function(_0x2d7ef0){if(_0x2d7ef0){_0x1b30d7=_0x2d7ef0;_0x5621c7[_0xd788('0x5c')]=_[_0xd788('0x57')](db[_0xd788('0x149')]['rawAttributes']);_0x5621c7[_0xd788('0x45')]=_[_0xd788('0x57')](_0x45c1e4[_0xd788('0x45')]);_0x5621c7[_0xd788('0x59')]=_[_0xd788('0x5a')](_0x5621c7[_0xd788('0x5c')],_0x5621c7[_0xd788('0x45')]);_0x2d9d7b[_0xd788('0x48')]=_['intersection'](_0x5621c7[_0xd788('0x5c')],qs['fields'](_0x45c1e4[_0xd788('0x45')][_0xd788('0x5b')]));_0x2d9d7b['attributes']=_0x2d9d7b[_0xd788('0x48')]['length']?_0x2d9d7b[_0xd788('0x48')]:_0x5621c7[_0xd788('0x5c')];_0x2d9d7b[_0xd788('0xcd')]=qs['sort'](_0x45c1e4[_0xd788('0x45')][_0xd788('0xce')]);_0x2d9d7b[_0xd788('0xd0')]=qs['filters'](_[_0xd788('0xcf')](_0x45c1e4[_0xd788('0x45')],_0x5621c7[_0xd788('0x59')]));if(_0x45c1e4['query']['filter']){_0x2d9d7b[_0xd788('0xd0')]=_['merge'](_0x2d9d7b['where'],{'$or':_[_0xd788('0x35')](_0x2d9d7b['attributes'],function(_0x1ce994){var _0x5b6ab8={};_0x5b6ab8[_0x1ce994]={'$like':'%'+_0x45c1e4['query'][_0xd788('0x41')]+'%'};return _0x5b6ab8;})});}_0x2d9d7b=_[_0xd788('0x5e')]({},_0x2d9d7b,_0x45c1e4['options']);return _0x1b30d7[_0xd788('0x148')](_0x2d9d7b);}})[_0xd788('0x16')](function(_0x102fa6){if(_0x102fa6){_0x233f27=_0x102fa6['length'];if(!_0x45c1e4[_0xd788('0x45')][_0xd788('0xd5')]('nolimit')){_0x2d9d7b['limit']=qs['limit'](_0x45c1e4[_0xd788('0x45')][_0xd788('0x24')]);_0x2d9d7b['offset']=qs['offset'](_0x45c1e4[_0xd788('0x45')][_0xd788('0x22')]);}return _0x1b30d7['getSmsAccounts'](_0x2d9d7b);}})[_0xd788('0x16')](function(_0x1afefa){if(_0x1afefa){return _0x1afefa?{'count':_0x233f27,'rows':_0x1afefa}:null;}})[_0xd788('0x16')](respondWithResult(_0x49fc08,null))['catch'](handleError(_0x49fc08,null));};exports[_0xd788('0x14a')]=function(_0x153856,_0x2c89b1){return db['User']['find']({'where':{'id':_0x153856['params']['id']}})[_0xd788('0x16')](handleEntityNotFound(_0x2c89b1,null))[_0xd788('0x16')](function(_0x2cee64){if(_0x2cee64){return _0x2cee64['addSmsAccounts'](_0x153856[_0xd788('0x61')][_0xd788('0xad')],_[_0xd788('0x65')](_0x153856['body'],[_0xd788('0xad'),'id'])||{});}})[_0xd788('0x16')](respondWithResult(_0x2c89b1,null))[_0xd788('0x60')](handleError(_0x2c89b1,null));};exports[_0xd788('0x14b')]=function(_0x5a102e,_0x5cc856){return db['User'][_0xd788('0x38')]({'where':{'id':_0x5a102e[_0xd788('0x62')]['id']}})[_0xd788('0x16')](handleEntityNotFound(_0x5cc856,null))[_0xd788('0x16')](function(_0x4f40b0){if(_0x4f40b0){return _0x4f40b0['removeSmsAccounts'](_0x5a102e[_0xd788('0x45')][_0xd788('0xad')]);}})[_0xd788('0x16')](respondWithStatusCode(_0x5cc856,null))['catch'](handleError(_0x5cc856,null));};exports[_0xd788('0x14c')]=function(_0x28fb0e,_0x560604){var _0xff4710={};var _0x7b0f88={};var _0x4e6ed8;var _0x53f877;return db[_0xd788('0x3e')][_0xd788('0x9d')]({'where':{'id':_0x28fb0e[_0xd788('0x62')]['id']}})[_0xd788('0x16')](handleEntityNotFound(_0x560604,null))['then'](function(_0x251cf9){if(_0x251cf9){_0x4e6ed8=_0x251cf9;_0x7b0f88[_0xd788('0x5c')]=_[_0xd788('0x57')](db[_0xd788('0x14d')]['rawAttributes']);_0x7b0f88[_0xd788('0x45')]=_[_0xd788('0x57')](_0x28fb0e[_0xd788('0x45')]);_0x7b0f88[_0xd788('0x59')]=_[_0xd788('0x5a')](_0x7b0f88['model'],_0x7b0f88[_0xd788('0x45')]);_0xff4710[_0xd788('0x48')]=_[_0xd788('0x5a')](_0x7b0f88['model'],qs['fields'](_0x28fb0e[_0xd788('0x45')][_0xd788('0x5b')]));_0xff4710[_0xd788('0x48')]=_0xff4710[_0xd788('0x48')][_0xd788('0x4d')]?_0xff4710['attributes']:_0x7b0f88[_0xd788('0x5c')];_0xff4710['order']=qs['sort'](_0x28fb0e[_0xd788('0x45')][_0xd788('0xce')]);_0xff4710[_0xd788('0xd0')]=qs['filters'](_[_0xd788('0xcf')](_0x28fb0e[_0xd788('0x45')],_0x7b0f88[_0xd788('0x59')]));if(_0x28fb0e[_0xd788('0x45')][_0xd788('0x41')]){_0xff4710[_0xd788('0xd0')]=_[_0xd788('0x5e')](_0xff4710[_0xd788('0xd0')],{'$or':_[_0xd788('0x35')](_0xff4710[_0xd788('0x48')],function(_0x419689){var _0x5290c1={};_0x5290c1[_0x419689]={'$like':'%'+_0x28fb0e[_0xd788('0x45')][_0xd788('0x41')]+'%'};return _0x5290c1;})});}_0xff4710=_[_0xd788('0x5e')]({},_0xff4710,_0x28fb0e['options']);return _0x4e6ed8[_0xd788('0x14c')](_0xff4710);}})[_0xd788('0x16')](function(_0x2666e4){if(_0x2666e4){_0x53f877=_0x2666e4[_0xd788('0x4d')];if(!_0x28fb0e['query'][_0xd788('0xd5')](_0xd788('0xd6'))){_0xff4710[_0xd788('0x24')]=qs[_0xd788('0x24')](_0x28fb0e['query'][_0xd788('0x24')]);_0xff4710['offset']=qs[_0xd788('0x22')](_0x28fb0e[_0xd788('0x45')]['offset']);}return _0x4e6ed8[_0xd788('0x14c')](_0xff4710);}})[_0xd788('0x16')](function(_0x2c48be){if(_0x2c48be){return _0x2c48be?{'count':_0x53f877,'rows':_0x2c48be}:null;}})[_0xd788('0x16')](respondWithResult(_0x560604,null))['catch'](handleError(_0x560604,null));};exports[_0xd788('0x14e')]=function(_0x246987,_0x129cb9){return db['User']['find']({'where':{'id':_0x246987[_0xd788('0x62')]['id']}})['then'](handleEntityNotFound(_0x129cb9,null))[_0xd788('0x16')](function(_0x1a4ee6){if(_0x1a4ee6){return _0x1a4ee6[_0xd788('0x14e')](_0x246987[_0xd788('0x61')][_0xd788('0xad')],_['omit'](_0x246987[_0xd788('0x61')],[_0xd788('0xad'),'id'])||{});}})[_0xd788('0x16')](respondWithResult(_0x129cb9,null))[_0xd788('0x60')](handleError(_0x129cb9,null));};exports[_0xd788('0x14f')]=function(_0x10d45d,_0x14889c){return db[_0xd788('0x3e')][_0xd788('0x38')]({'where':{'id':_0x10d45d[_0xd788('0x62')]['id']}})[_0xd788('0x16')](handleEntityNotFound(_0x14889c,null))[_0xd788('0x16')](function(_0xf40d76){if(_0xf40d76){return _0xf40d76['removeChatWebsites'](_0x10d45d[_0xd788('0x45')][_0xd788('0xad')]);}})[_0xd788('0x16')](respondWithStatusCode(_0x14889c,null))[_0xd788('0x60')](handleError(_0x14889c,null));};exports[_0xd788('0x150')]=function(_0x3063e5,_0x55ecd4){var _0x3967bf={};var _0x538f6a={};var _0x137d58;var _0x45b0fc;return db[_0xd788('0x3e')][_0xd788('0x9d')]({'where':{'id':_0x3063e5[_0xd788('0x62')]['id']}})['then'](handleEntityNotFound(_0x55ecd4,null))['then'](function(_0x5f270b){if(_0x5f270b){_0x137d58=_0x5f270b;_0x538f6a[_0xd788('0x5c')]=_['keys'](db[_0xd788('0x151')][_0xd788('0x58')]);_0x538f6a[_0xd788('0x45')]=_[_0xd788('0x57')](_0x3063e5['query']);_0x538f6a[_0xd788('0x59')]=_[_0xd788('0x5a')](_0x538f6a[_0xd788('0x5c')],_0x538f6a[_0xd788('0x45')]);_0x3967bf[_0xd788('0x48')]=_[_0xd788('0x5a')](_0x538f6a[_0xd788('0x5c')],qs['fields'](_0x3063e5[_0xd788('0x45')][_0xd788('0x5b')]));_0x3967bf[_0xd788('0x48')]=_0x3967bf[_0xd788('0x48')]['length']?_0x3967bf['attributes']:_0x538f6a['model'];_0x3967bf[_0xd788('0xcd')]=qs['sort'](_0x3063e5[_0xd788('0x45')][_0xd788('0xce')]);_0x3967bf['where']=qs[_0xd788('0x59')](_[_0xd788('0xcf')](_0x3063e5['query'],_0x538f6a[_0xd788('0x59')]));if(_0x3063e5[_0xd788('0x45')][_0xd788('0x41')]){_0x3967bf['where']=_[_0xd788('0x5e')](_0x3967bf[_0xd788('0xd0')],{'$or':_['map'](_0x3967bf[_0xd788('0x48')],function(_0x149459){var _0x39d4f1={};_0x39d4f1[_0x149459]={'$like':'%'+_0x3063e5['query']['filter']+'%'};return _0x39d4f1;})});}_0x3967bf=_[_0xd788('0x5e')]({},_0x3967bf,_0x3063e5[_0xd788('0x5f')]);return _0x137d58['getWhatsappAccounts'](_0x3967bf);}})[_0xd788('0x16')](function(_0x29349e){if(_0x29349e){_0x45b0fc=_0x29349e[_0xd788('0x4d')];if(!_0x3063e5[_0xd788('0x45')][_0xd788('0xd5')](_0xd788('0xd6'))){_0x3967bf[_0xd788('0x24')]=qs[_0xd788('0x24')](_0x3063e5[_0xd788('0x45')][_0xd788('0x24')]);_0x3967bf['offset']=qs[_0xd788('0x22')](_0x3063e5[_0xd788('0x45')]['offset']);}return _0x137d58[_0xd788('0x150')](_0x3967bf);}})[_0xd788('0x16')](function(_0x20ff61){if(_0x20ff61){return _0x20ff61?{'count':_0x45b0fc,'rows':_0x20ff61}:null;}})[_0xd788('0x16')](respondWithResult(_0x55ecd4,null))[_0xd788('0x60')](handleError(_0x55ecd4,null));};exports[_0xd788('0x152')]=function(_0x189522,_0x108ed4){return db[_0xd788('0x3e')][_0xd788('0x38')]({'where':{'id':_0x189522[_0xd788('0x62')]['id']}})[_0xd788('0x16')](handleEntityNotFound(_0x108ed4,null))[_0xd788('0x16')](function(_0x1d94df){if(_0x1d94df){return _0x1d94df[_0xd788('0x152')](_0x189522[_0xd788('0x61')][_0xd788('0xad')],_[_0xd788('0x65')](_0x189522['body'],[_0xd788('0xad'),'id'])||{});}})[_0xd788('0x16')](respondWithResult(_0x108ed4,null))[_0xd788('0x60')](handleError(_0x108ed4,null));};exports[_0xd788('0x153')]=function(_0x3cd5ea,_0x35e6f5){return db[_0xd788('0x3e')][_0xd788('0x38')]({'where':{'id':_0x3cd5ea['params']['id']}})[_0xd788('0x16')](handleEntityNotFound(_0x35e6f5,null))['then'](function(_0x2d51a6){if(_0x2d51a6){return _0x2d51a6[_0xd788('0x153')](_0x3cd5ea[_0xd788('0x45')][_0xd788('0xad')]);}})['then'](respondWithStatusCode(_0x35e6f5,null))[_0xd788('0x60')](handleError(_0x35e6f5,null));};exports[_0xd788('0x154')]=function(_0x2dadc8,_0x7e57d3){var _0x36c1ad={},_0x28a191={},_0x51268b={'count':0x0,'rows':[]};var _0x4d4eeb=db[_0xd788('0x155')][_0xd788('0x58')];_0x28a191[_0xd788('0x5c')]=_['keys'](_0x4d4eeb);_0x28a191[_0xd788('0x45')]=_[_0xd788('0x57')](_0x2dadc8['query']);_0x28a191[_0xd788('0x59')]=_[_0xd788('0x5a')](_0x28a191[_0xd788('0x5c')],_0x28a191[_0xd788('0x45')]);_0x28a191[_0xd788('0x59')]=_['concat'](_0x28a191[_0xd788('0x59')],[_0xd788('0x156'),_0xd788('0x157'),_0xd788('0x158'),_0xd788('0x159'),_0xd788('0x15a'),_0xd788('0x15b'),'$ne',_0xd788('0x15c'),_0xd788('0x15d'),'$between',_0xd788('0x15e'),'$in',_0xd788('0x15f'),_0xd788('0x160'),_0xd788('0x161'),_0xd788('0x162'),_0xd788('0x163'),_0xd788('0x160'),'$overlap','$contains',_0xd788('0x164'),_0xd788('0x165')]);_0x36c1ad['attributes']=_[_0xd788('0x5a')](_0x28a191[_0xd788('0x5c')],qs['fields'](_0x2dadc8[_0xd788('0x45')][_0xd788('0x5b')]));_0x36c1ad[_0xd788('0x48')]=_0x36c1ad[_0xd788('0x48')]['length']?_0x36c1ad[_0xd788('0x48')]:_0x28a191[_0xd788('0x5c')];if(!_0x2dadc8[_0xd788('0x45')][_0xd788('0xd5')](_0xd788('0xd6'))){_0x36c1ad[_0xd788('0x24')]=qs[_0xd788('0x24')](_0x2dadc8[_0xd788('0x45')][_0xd788('0x24')]);_0x36c1ad[_0xd788('0x22')]=qs[_0xd788('0x22')](_0x2dadc8[_0xd788('0x45')][_0xd788('0x22')]);}_0x36c1ad[_0xd788('0xcd')]=qs[_0xd788('0xce')](_0x2dadc8[_0xd788('0x45')][_0xd788('0xce')]);_0x36c1ad[_0xd788('0xd0')]=qs[_0xd788('0x59')](_[_0xd788('0xcf')](_0x2dadc8[_0xd788('0x45')],_0x28a191[_0xd788('0x59')]));if(_0x2dadc8['query'][_0xd788('0x41')]){_0x36c1ad[_0xd788('0xd0')]=_[_0xd788('0x5e')](_0x36c1ad[_0xd788('0xd0')],{'$or':_[_0xd788('0x35')](_0x36c1ad[_0xd788('0x48')],function(_0x202655){var _0x1598e6={};_0x1598e6[_0x202655]={'$like':'%'+_0x2dadc8['query'][_0xd788('0x41')]+'%'};return _0x1598e6;})});}_0x36c1ad['where']={'$and':[_0x36c1ad['where'],{'$or':[{'UserId':_0x2dadc8[_0xd788('0x62')]['id']},{'OwnerId':_0x2dadc8[_0xd788('0x62')]['id']}]}]};_0x36c1ad=_[_0xd788('0x5e')]({},_0x36c1ad,_0x2dadc8[_0xd788('0x5f')]);var _0xeab89a={'where':_0x36c1ad['where']};return db[_0xd788('0x155')]['count'](_0xeab89a)['then'](function(_0x432199){_0x51268b[_0xd788('0x25')]=_0x432199;if(_0x2dadc8[_0xd788('0x45')][_0xd788('0xd1')]){_0x36c1ad[_0xd788('0x46')]=[{'attributes':['id',_0xd788('0x166'),_0xd788('0x167'),_0xd788('0xed')],'model':db[_0xd788('0xcc')],'as':_0xd788('0x168')},{'attributes':['id',_0xd788('0x3c'),_0xd788('0x169')],'model':db[_0xd788('0xb2')],'as':'Queue'}];}return db['CmHopper'][_0xd788('0x49')](_0x36c1ad);})[_0xd788('0x16')](function(_0x14cd08){_0x51268b['rows']=_0x14cd08;return _0x51268b;})[_0xd788('0x16')](respondWithFilteredResult(_0x7e57d3,_0x36c1ad))[_0xd788('0x60')](handleError(_0x7e57d3,null));};exports[_0xd788('0x16a')]=function(_0x14a654,_0x37197b){if(!_[_0xd788('0x6d')](_0x14a654['user']['id'])&&(_0x14a654[_0xd788('0x2f')][_0xd788('0x2c')]==_0xd788('0x2d')||_0x14a654[_0xd788('0x2f')][_0xd788('0x2c')]==_0xd788('0x2f'))){return db[_0xd788('0x3e')][_0xd788('0x9d')]({'where':{'id':_0x14a654[_0xd788('0x62')]['id']},'raw':!![]})['then'](function(_0x30bf74){return authService[_0xd788('0x16b')](_0x30bf74);})[_0xd788('0x16')](function(_0x3d1340){if(_0x3d1340){return _0x37197b[_0xd788('0x21')](0xc8)[_0xd788('0x16c')]({'api_key':_0x3d1340[_0xd788('0x16d')]});}else{return _0x37197b[_0xd788('0x21')](0xcc)[_0xd788('0x16c')]({'message':_0xd788('0x16e')});}})[_0xd788('0x60')](handleError(_0x37197b,0x193));}else{return _0x37197b[_0xd788('0x21')](0x191)[_0xd788('0x16c')]({'message':_0xd788('0x16f')});}};exports['createApiKey']=function(_0x3567f4,_0x172828){if(!_[_0xd788('0x6d')](_0x3567f4[_0xd788('0x2f')]['id'])&&(_0x3567f4[_0xd788('0x2f')][_0xd788('0x2c')]==_0xd788('0x2d')||_0x3567f4[_0xd788('0x2f')][_0xd788('0x2c')]==_0xd788('0x2f'))){return db[_0xd788('0x3e')][_0xd788('0x38')]({'where':{'id':_0x3567f4['params']['id']}})[_0xd788('0x16')](function(_0x5becea){return authService[_0xd788('0x170')](_0x5becea);})[_0xd788('0x16')](function(_0x1d40de){return db[_0xd788('0x3e')][_0xd788('0x27')]({'apiKeyIat':_0x1d40de[_0xd788('0x171')],'apiKeyNonce':_0x1d40de[_0xd788('0x172')]},{'where':{'id':_0x3567f4[_0xd788('0x62')]['id']}})[_0xd788('0x16')](function(){return _0x172828['status'](0xc8)['json']({'api_key':_0x1d40de['token']});});})[_0xd788('0x60')](handleError(_0x172828,0x193));}else{return _0x172828[_0xd788('0x21')](0x191)[_0xd788('0x16c')]({'message':_0xd788('0x16f')});}};exports[_0xd788('0x173')]=function(_0x4a5f83,_0x21ce20){if(!_['isNil'](_0x4a5f83[_0xd788('0x2f')]['id'])&&(_0x4a5f83['user']['role']==_0xd788('0x2d')||_0x4a5f83['user']['role']==_0xd788('0x2f'))){return db[_0xd788('0x3e')][_0xd788('0x38')]({'where':{'id':_0x4a5f83[_0xd788('0x62')]['id']}})['then'](handleEntityNotFound(_0x21ce20,null))['then'](function(_0x1f4444){if(_0x1f4444&&_0x1f4444[_0xd788('0x174')]&&_0x1f4444[_0xd788('0x175')])return _0x1f4444;else throw{'message':'API\x20key\x20not\x20available'};})[_0xd788('0x16')](function(){return db['User'][_0xd788('0x27')]({'apiKeyNonce':null,'apiKeyIat':null},{'where':{'id':_0x4a5f83[_0xd788('0x62')]['id']}});})['then'](respondWithStatusCode(_0x21ce20,0xc8))['catch'](handleError(_0x21ce20,0x193));}else{return _0x21ce20[_0xd788('0x21')](0x191)[_0xd788('0x16c')]({'message':_0xd788('0x16f')});}};exports[_0xd788('0x176')]=function(_0x59b0ef,_0x4860b5){var _0x52c453=_0x59b0ef['user'][_0xd788('0x2b')]({'plain':!![]});if(!_0x52c453){return _0x4860b5[_0xd788('0x21')](0x191)['send']('Unable\x20to\x20retrieve\x20the\x20current\x20user');}else{Promise[_0xd788('0x112')]()[_0xd788('0x16')](function(){if(_0x59b0ef['query'][_0xd788('0x47')]!==_0xd788('0x4c'))return;return _0x59b0ef[_0xd788('0x2f')][_0xd788('0x177')]();})[_0xd788('0x16')](function(_0x196201){if(!_0x196201)return;return _0x196201['get']({'plain':!![]});})[_0xd788('0x16')](function(_0x3a8821){_0x52c453[_0xd788('0x47')]=_0x3a8821;return _0x4860b5[_0xd788('0x21')](0xc8)[_0xd788('0x16c')](_0x52c453);});}};exports['getPresence']=function(_0x33c149,_0x20e3bd){var _0x44f7de={'offset':0x0},_0x955d61={'count':0x0,'rows':[]};Promise[_0xd788('0x112')]()[_0xd788('0x16')](function(){if(!_0x33c149[_0xd788('0x45')]['filter']&&!_0x33c149[_0xd788('0x45')][_0xd788('0x178')]&&!_0x33c149[_0xd788('0x45')]['queues'])return[];return Promise[_0xd788('0x112')]()[_0xd788('0x16')](function(){var _0x2401f5=[];if(!_['isEmpty'](_0x33c149[_0xd788('0x45')]['teams'])){_0x2401f5['push'](db['Team'][_0xd788('0x49')]({'attributes':['id',_0xd788('0x3c')],'where':{'id':_0x33c149[_0xd788('0x45')]['teams']}}));}if(!_[_0xd788('0x179')](_0x33c149[_0xd788('0x45')]['queues'])){_0x2401f5[_0xd788('0x4e')](db[_0xd788('0xb2')][_0xd788('0x49')]({'attributes':['id',_0xd788('0x3c')],'type':_0xd788('0x17a'),'where':{'id':_0x33c149[_0xd788('0x45')][_0xd788('0x17b')]}}));}return Promise['all'](_0x2401f5);})[_0xd788('0x16')](function(_0xd8e308){var _0x39ce01=_['flatten'](_0xd8e308)[_0xd788('0x35')](function(_0x520dff){return _0x520dff[_0xd788('0x123')]({'attributes':['id',_0xd788('0x3c'),'internal','online'],'raw':!![]});});return Promise[_0xd788('0x56')](_0x39ce01);})[_0xd788('0x16')](function(_0x18fc88){var _0x2fed2a=_['flatten'](_0x18fc88);if(!_0x33c149[_0xd788('0x45')][_0xd788('0x41')])return _0x2fed2a;if(_['isEmpty'](_0x2fed2a)){return db[_0xd788('0x3e')]['findAll']({'attributes':['id',_0xd788('0x3c'),_0xd788('0x66'),_0xd788('0x102')],'where':{'role':_0xd788('0x31'),'$or':[db[_0xd788('0x6f')][_0xd788('0xd0')](db[_0xd788('0x6f')]['fn'](_0xd788('0x17c'),db[_0xd788('0x6f')]['col']('name')),{'$like':'%'+_0x33c149['query'][_0xd788('0x41')][_0xd788('0xab')]()+'%'}),{'internal':{'$like':'%'+_0x33c149[_0xd788('0x45')][_0xd788('0x41')]+'%'}}]},'raw':!![]});}else{return _(_0x2fed2a)[_0xd788('0x17d')]()[_0xd788('0x41')](function(_0x35c42a){return _0x35c42a['name']['toLowerCase']()['includes'](_0x33c149['query']['filter'][_0xd788('0xab')]())||_0x35c42a[_0xd788('0x66')][_0xd788('0x17e')]()[_0xd788('0x37')](_0x33c149[_0xd788('0x45')][_0xd788('0x41')]);})['value']();}})[_0xd788('0x16')](function(_0x2dc21f){var _0x2058aa=_0xd788('0x3c');var _0x4fd2e4=_0xd788('0x17f');if(_0x33c149['query'][_0xd788('0xce')]){_0x4fd2e4=_0x33c149['query'][_0xd788('0xce')][0x0]==='-'?'desc':'asc';_0x2058aa=_0x4fd2e4===_0xd788('0x17f')?_0x33c149[_0xd788('0x45')]['sort']:_0x33c149[_0xd788('0x45')][_0xd788('0xce')][_0xd788('0x180')](0x1);}return _(_0x2dc21f)[_0xd788('0x181')]('id')[_0xd788('0x182')]([function(_0x308dee){return _0x2058aa===_0xd788('0x3c')?_0x308dee[_0x2058aa][_0xd788('0xab')]():_0x308dee[_0x2058aa];}],[_0x4fd2e4])['map'](function(_0x2e96d6){return _[_0xd788('0xcf')](_0x2e96d6,['id','name',_0xd788('0x66'),_0xd788('0x102')]);})[_0xd788('0x36')]();})[_0xd788('0x16')](function(_0xeb0ab){return amiClient[_0xd788('0x15')]('Agents',_0x33c149)[_0xd788('0x16')](function(_0x4ded93){if(_0x4ded93['error'])throw new Error(_0xd788('0x183'));var _0x41e092=_0x4ded93[_0xd788('0x1f')];var _0x364990=jayson[_0xd788('0x14')][_0xd788('0x184')]({'port':0x232c});return _0x364990[_0xd788('0x15')](_0xd788('0x30'),_0x33c149)[_0xd788('0x16')](function(_0x38d089){if(_0x38d089[_0xd788('0x1c')])throw new Error(_0xd788('0x185'));var _0x84776f=_0x38d089[_0xd788('0x1f')];return _[_0xd788('0x5e')]({},_0x84776f,_0x41e092);});})[_0xd788('0x16')](function(_0x41eab5){return _[_0xd788('0x35')](_0xeb0ab,function(_0x3eb1c9){var _0x102406=_[_0xd788('0x38')](_0x41eab5[_0xd788('0x4a')],['id',_0x3eb1c9['id']]);if(!_0x102406||!_0x3eb1c9[_0xd788('0x102')]){_0x3eb1c9[_0xd788('0x21')]=_0xd788('0x186');}else if(_0x102406[_0xd788('0xa5')]){_0x3eb1c9['status']=_0xd788('0x101');}else{_0x3eb1c9[_0xd788('0x21')]=_[_0xd788('0x37')]([_0xd788('0x187'),_0xd788('0x188'),_0xd788('0x189'),'ringing',null,undefined],_0x102406[_0xd788('0x18a')])?_0xd788('0x102'):_0xd788('0x18b');}return _0x3eb1c9;});});});})[_0xd788('0x16')](function(_0x508b65){if(!_0x33c149[_0xd788('0x45')][_0xd788('0xd5')]('nolimit')){_0x44f7de[_0xd788('0x24')]=qs[_0xd788('0x24')](_0x33c149[_0xd788('0x45')][_0xd788('0x24')]||0xa);_0x44f7de['offset']=qs['offset'](_0x33c149[_0xd788('0x45')][_0xd788('0x22')]);}_0x955d61[_0xd788('0x25')]=_0x508b65['length'];_0x955d61[_0xd788('0x4a')]=_0x44f7de[_0xd788('0x24')]?_0x508b65[_0xd788('0x18c')](_0x44f7de[_0xd788('0x22')],_0x44f7de['offset']+_0x44f7de[_0xd788('0x24')]):_0x508b65;return _0x955d61;})['then'](respondWithFilteredResult(_0x20e3bd,_0x44f7de))[_0xd788('0x60')](handleError(_0x20e3bd,null));};function get_open_tabs(_0x482fa3,_0x146f76){var _0x2c3595=_0x482fa3[_0xd788('0x18d')](0x0)[_0xd788('0x18e')]()+_0x482fa3[_0xd788('0x18c')](0x1);var _0x39e0bf={'type':db[_0xd788('0x95')][_0xd788('0x70')][_0xd788('0x71')],'raw':!![]};return new Promise(function(_0x21a5da,_0x32b595){var _0x5ef37c=squel['select']()[_0xd788('0x18f')](_0xd788('0x190')+_0x2c3595+_0xd788('0x191'),'id')[_0xd788('0x18f')](_0xd788('0x192'))[_0xd788('0x72')](_0xd788('0x193')+_0x482fa3+_0xd788('0x194'),'ui')[_0xd788('0xd0')]('ui.UserId\x20=\x20?',_0x146f76['id']);return db[_0xd788('0x6f')][_0xd788('0x45')](_0x5ef37c['toString'](),_0x39e0bf)[_0xd788('0x16')](function(_0x36dc4e){_0x146f76[_0x2c3595+_0xd788('0x195')]=_0x36dc4e;_0x21a5da(_0x36dc4e);})[_0xd788('0x60')](function(_0x44aa3f){_0x32b595(_0x44aa3f);});});}
\ No newline at end of file