Built motion from commit (unavailable).|2.5.6
[motion2.git] / server / api / user / user.controller.js
index fa8876f..9fa1e92 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x55c3=['CmHopper','$and','$or','$gt','$gte','$lt','$ne','$eq','$not','$between','$notBetween','$in','$notIn','$like','$notLike','$iLike','$contains','$contained','$any','firstName','getApiKey','retrieveApiKey','token','json','No\x20API\x20access\x20key\x20found!','You\x20don\x27t\x20have\x20sufficient\x20privileges\x20to\x20access\x20this\x20resource.','iat','nonce','removeApiKey','apiKeyIat','API\x20key\x20not\x20available','whoami','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','ejs','lodash','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','redis','defaults','localhost','./user.socket','register','jayson/promise','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~!@#$%^&-_=+[{]}.','info','User,\x20%s,\x20%s','request\x20sent','User,\x20%s,\x20%s,\x20%s','stringify','error','code','message','catch','sendStatus','status','end','count','offset','limit','Content-Range','apply','reject','save','update','destroy','get','user','agent','Telephones','telephone','filter','value','role','find','name','UserProfileResource','then','send','index','map','User','rawAttributes','fieldName','type','model','differenceBy','password','salt','query','keys','filters','intersection','attributes','fields','length','sort','where','merge','VIRTUAL','sequelize','lower','col','options','include','rows','show','params','includeAll','bulkCreate','body','describe','addContacts','ids','omit','agent\x20role','admin','../../config/license/util','getLicense','users','isNil','License\x20limit\x20reached','count\x20%s:\x20%s','create','internal','Setting','findById','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)','from','voicemail','mailbox','VoiceMail','fullname','email','101','102','103','110','105','106','107','108','111','Unable\x20to\x20retrieve\x20the\x20current\x20user','Agents','UserProfileSection','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','changePassword','findOne','securePassword','oldPassword','newPassword','authenticate','Wrong\x20credentials','New\x20password\x20must\x20be\x20different\x20from\x20old\x20password','Invalid\x20body\x20format.\x20Use\x20newPassword','Unauthorized','addQueues','online','loginInPause','voicePause','interface','isValidChannel','Unknown\x20channel','add','capitalize','toLowerCase','Queues','penalty','QueueId','emit','Queue:save','voice','VoiceQueue','format','SIP/%s','each','UserVoiceQueueRt','upsert','removeQueues','channel','addAvatar','userpic','file','filename','getAvatar','root','server/files/images/logos/default_profile.png','download','existsSync','join','server/files/images/','getContacts','CmContact','order','hasOwnProperty','CmList','Tag','Tags','color','tag','nolimit','getQueues','Queue','pick','Unknown\x20role','getVoiceQueuesRt','ChatGroup','getGroups','getRecordings','UserId','VoiceRecording','findAll','getScreenRecordings','ScreenRecording','getChatInteractions','ChatInteraction','getOpenchannelInteractions','OpenchannelInteraction','getMailInteractions','MailInteraction','getSmsInteractions','getFaxInteractions','FaxInteraction','login','phone','mobile','LOCAL/%s@from-sip/n','intrf','user:%s','user:forcelogout','headers','remoteAddress','connection','socket','User\x20not\x20found\x20or\x20not\x20allowed\x20to\x20perform\x20login\x20method','getVoiceQueues','UserVoiceQueue.penalty','MemberReport','forEach','push','YYYY-MM-DD\x20HH:mm:ss','all','getChannels','device','LOGININPAUSE','concat','isMiddleware','resolve','pause','QueuePause','PAUSE','updateAttributes','DEFAULT\x20PAUSE','mailPause','chatPause','faxPause','smsPause','pauseType','lastPauseAt','manual','mail','chat','fax','sms','openchannel','set','%s%s','Pause','getTeams','addTeams','Team','setDataValue','Voice','getChatQueues','getSmsQueues','Sms','getFaxQueues','getOpenchannelQueues','Openchannel','flatten','getDataValue','removeTeams','Chat','getMailQueues','transaction','Queue:remove','getLists','getAgents','values','addChatInteractions','removeChatInteractions','isArray','user_has_chat_interactions:remove','addMailInteractions','spread','user_has_mail_interactions:save','removeMailInteractions','user_has_mail_interactions:remove','addFaxInteractions','removeFaxInteractions','user_has_fax_interactions:remove','addSmsInteractions','user_has_sms_interactions:save','removeSmsInteractions','user_has_sms_interactions:remove','addOpenchannelInteractions','user_has_openchannel_interactions:save','removeOpenchannelInteractions','user_has_openchannel_interactions:remove','getVoicePrefixes','VoicePrefix','FaxAccount','getFaxAccounts','addFaxAccounts','removeFaxAccounts','getMailAccounts','addMailAccounts','removeMailAccounts','getOpenchannelAccounts','OpenchannelAccount','addOpenchannelAccounts','removeOpenchannelAccounts','getSmsAccounts','SmsAccount','removeSmsAccounts','getChatWebsites','ChatWebsite','addChatWebsites','removeChatWebsites','getSquareProjects','SquareProject','addSquareProjects'];(function(_0x1d24eb,_0x12295b){var _0x1dc576=function(_0x4d5770){while(--_0x4d5770){_0x1d24eb['push'](_0x1d24eb['shift']());}};_0x1dc576(++_0x12295b);}(_0x55c3,0x189));var _0x355c=function(_0x2c8dfe,_0x18073f){_0x2c8dfe=_0x2c8dfe-0x0;var _0x1735b0=_0x55c3[_0x2c8dfe];return _0x1735b0;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0x355c('0x0'));var rimraf=require(_0x355c('0x1'));var zipdir=require(_0x355c('0x2'));var jsonpatch=require(_0x355c('0x3'));var rp=require(_0x355c('0x4'));var moment=require(_0x355c('0x5'));var BPromise=require(_0x355c('0x6'));var Mustache=require(_0x355c('0x7'));var util=require(_0x355c('0x8'));var path=require(_0x355c('0x9'));var sox=require(_0x355c('0xa'));var csv=require(_0x355c('0xb'));var ejs=require(_0x355c('0xc'));var fs=require('fs');var _=require(_0x355c('0xd'));var squel=require('squel');var crypto=require('crypto');var jsforce=require(_0x355c('0xe'));var deskjs=require(_0x355c('0xf'));var toCsv=require(_0x355c('0xb'));var querystring=require(_0x355c('0x10'));var Papa=require(_0x355c('0x11'));var Redis=require(_0x355c('0x12'));var authService=require(_0x355c('0x13'));var qs=require(_0x355c('0x14'));var as=require(_0x355c('0x15'));var hardwareService=require(_0x355c('0x16'));var logger=require(_0x355c('0x17'))(_0x355c('0x18'));var utils=require(_0x355c('0x19'));var config=require(_0x355c('0x1a'));var db=require('../../mysqldb')['db'];config[_0x355c('0x1b')]=_[_0x355c('0x1c')](config['redis'],{'host':_0x355c('0x1d'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x355c('0x1b')]));require(_0x355c('0x1e'))[_0x355c('0x1f')](socket);var jayson=require(_0x355c('0x20'));var client=jayson['client'][_0x355c('0x21')]({'port':0x232a});function checkPasswordPattern(_0x4ac022,_0x521716,_0x1ddf94){if(_0x1ddf94){var _0xfbf43=new RegExp(/(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[?!@#\$%\^&\*~\-_=+[{\]\}])(?=.{8,})/);if(_0xfbf43[_0x355c('0x22')](_0x521716)){return _0x4ac022;}else{throw new db[(_0x355c('0x23'))][(_0x355c('0x24'))](_0x355c('0x25'));}}else{return _0x4ac022;}}function respondWithRpcPromise(_0x3a6e7f,_0x1348a8,_0x3b50b7,_0x559577){return new BPromise(function(_0xc051c7,_0x2610c5){var _0x537586=_0x559577||client;return _0x537586['request'](_0x3a6e7f,_0x3b50b7)['then'](function(_0x582344){logger[_0x355c('0x26')](_0x355c('0x27'),_0x1348a8,_0x355c('0x28'));logger['debug'](_0x355c('0x29'),_0x1348a8,_0x355c('0x28'),JSON[_0x355c('0x2a')](_0x582344));if(_0x582344[_0x355c('0x2b')]){if(_0x582344[_0x355c('0x2b')][_0x355c('0x2c')]===0x1f4){logger[_0x355c('0x2b')](_0x355c('0x27'),_0x1348a8,_0x582344['error']['message']);return _0x2610c5(_0x582344[_0x355c('0x2b')][_0x355c('0x2d')]);}logger[_0x355c('0x2b')]('User,\x20%s,\x20%s',_0x1348a8,_0x582344[_0x355c('0x2b')]['message']);return _0xc051c7(_0x582344[_0x355c('0x2b')][_0x355c('0x2d')]);}else{logger[_0x355c('0x26')](_0x355c('0x27'),_0x1348a8,_0x355c('0x28'));_0xc051c7(_0x582344['result'][_0x355c('0x2d')]);}})[_0x355c('0x2e')](function(_0x37ac93){logger[_0x355c('0x2b')](_0x355c('0x27'),_0x1348a8,_0x37ac93);_0x2610c5(_0x37ac93);});});}function respondWithStatusCode(_0x4a01e7,_0x26e537){_0x26e537=_0x26e537||0xcc;return function(_0x5e6345){if(_0x5e6345){return _0x4a01e7[_0x355c('0x2f')](_0x26e537);}return _0x4a01e7[_0x355c('0x30')](_0x26e537)[_0x355c('0x31')]();};}function respondWithResult(_0x2ba985,_0x213289){_0x213289=_0x213289||0xc8;return function(_0x473ac7){if(_0x473ac7){return _0x2ba985[_0x355c('0x30')](_0x213289)['json'](_0x473ac7);}};}function respondWithFilteredResult(_0x38736a,_0x1b6f9e){return function(_0xe3acb0){if(_0xe3acb0){var _0x34eb79=_0xe3acb0[_0x355c('0x32')],_0x45fb4a=_0x1b6f9e['offset'],_0x4533cb=_0x1b6f9e[_0x355c('0x33')]+_0x1b6f9e[_0x355c('0x34')],_0x105b74;if(_0x4533cb>=_0x34eb79){_0x4533cb=_0x34eb79;_0x105b74=0xc8;}else{_0x105b74=0xce;}_0x38736a[_0x355c('0x30')](_0x105b74);return _0x38736a['set'](_0x355c('0x35'),_0x45fb4a+'-'+_0x4533cb+'/'+_0x34eb79)['json'](_0xe3acb0);}return null;};}function patchUpdates(_0x41575f){return function(_0x1d4d21){try{jsonpatch[_0x355c('0x36')](_0x1d4d21,_0x41575f,!![]);}catch(_0x5398ad){return BPromise[_0x355c('0x37')](_0x5398ad);}return _0x1d4d21[_0x355c('0x38')]();};}function saveUpdates(_0x5f424d,_0x2a222a){return function(_0xeca95d){if(_0xeca95d){return _0xeca95d[_0x355c('0x39')](_0x5f424d)['then'](function(_0x1ef90b){return _0x1ef90b;});}return null;};}function removeEntity(_0x5cb164,_0x2c1031){return function(_0x1f3236){if(_0x1f3236){return _0x1f3236[_0x355c('0x3a')]()['then'](function(){var _0x956d3=_0x1f3236[_0x355c('0x3b')]({'plain':!![]});var _0x19b593=[{'name':'Users','value':_0x355c('0x3c'),'ignore':!![]},{'name':'Agents','value':_0x355c('0x3d'),'ignore':![]},{'name':_0x355c('0x3e'),'value':_0x355c('0x3f'),'ignore':![]}];var _0x2516ab=_(_0x19b593)[_0x355c('0x40')]('ignore')['map'](_0x355c('0x41'))['value']();if(_['includes'](_0x2516ab,_0x956d3[_0x355c('0x42')])){return;}var _0x1abaad=_[_0x355c('0x43')](_0x19b593,['value',_0x956d3[_0x355c('0x42')]])[_0x355c('0x44')];return db[_0x355c('0x45')]['destroy']({'where':{'type':_0x1abaad,'resourceId':_0x956d3['id']}})[_0x355c('0x46')](function(){return _0x1f3236;});})[_0x355c('0x46')](function(){_0x5cb164[_0x355c('0x30')](0xcc)[_0x355c('0x31')]();});}};}function handleEntityNotFound(_0x1368b5,_0x2acd6e){return function(_0x52efea){if(!_0x52efea){_0x1368b5['sendStatus'](0x194);}return _0x52efea;};}function handleError(_0x4880cd,_0x50233f){_0x50233f=_0x50233f||0x1f4;return function(_0x3d69fb){logger['error'](_0x3d69fb['stack']);if(_0x3d69fb[_0x355c('0x44')]){delete _0x3d69fb['name'];}_0x4880cd[_0x355c('0x30')](_0x50233f)[_0x355c('0x47')](_0x3d69fb);};}exports[_0x355c('0x48')]=function(_0xba412e,_0x20323a){var _0x38dc57={},_0x2d8140={},_0x1afd5={'count':0x0,'rows':[]};var _0x58c41f=_[_0x355c('0x49')](db[_0x355c('0x4a')][_0x355c('0x4b')],function(_0x5eb2fd){return{'name':_0x5eb2fd[_0x355c('0x4c')],'type':_0x5eb2fd[_0x355c('0x4d')]['key']};});_0x2d8140[_0x355c('0x4e')]=_[_0x355c('0x4f')](_[_0x355c('0x49')](_0x58c41f,_0x355c('0x44')),[_0x355c('0x50'),_0x355c('0x51')]);_0x2d8140[_0x355c('0x52')]=_[_0x355c('0x53')](_0xba412e[_0x355c('0x52')]);_0x2d8140[_0x355c('0x54')]=_[_0x355c('0x55')](_0x2d8140[_0x355c('0x4e')],_0x2d8140[_0x355c('0x52')]);_0x38dc57[_0x355c('0x56')]=_[_0x355c('0x55')](_0x2d8140['model'],qs['fields'](_0xba412e[_0x355c('0x52')][_0x355c('0x57')]));_0x38dc57[_0x355c('0x56')]=_0x38dc57['attributes'][_0x355c('0x58')]?_0x38dc57[_0x355c('0x56')]:_0x2d8140[_0x355c('0x4e')];if(!_0xba412e['query']['hasOwnProperty']('nolimit')){_0x38dc57[_0x355c('0x34')]=qs['limit'](_0xba412e[_0x355c('0x52')][_0x355c('0x34')]);_0x38dc57[_0x355c('0x33')]=qs[_0x355c('0x33')](_0xba412e[_0x355c('0x52')]['offset']);}_0x38dc57['order']=qs['sort'](_0xba412e[_0x355c('0x52')][_0x355c('0x59')]);_0x38dc57[_0x355c('0x5a')]=qs[_0x355c('0x54')](_['pick'](_0xba412e[_0x355c('0x52')],_0x2d8140[_0x355c('0x54')]));if(_0xba412e[_0x355c('0x52')][_0x355c('0x40')]){_0x38dc57[_0x355c('0x5a')]=_[_0x355c('0x5b')](_0x38dc57[_0x355c('0x5a')],{'$or':_['map'](_0x58c41f,function(_0xba88c8){if(_0xba88c8[_0x355c('0x4d')]!==_0x355c('0x5c')){return db[_0x355c('0x5d')][_0x355c('0x5a')](db[_0x355c('0x5d')]['fn'](_0x355c('0x5e'),db[_0x355c('0x5d')][_0x355c('0x5f')](_0xba88c8[_0x355c('0x44')])),{'$like':db[_0x355c('0x5d')]['fn'](_0x355c('0x5e'),'%'+_0xba412e[_0x355c('0x52')][_0x355c('0x40')]+'%')});}})});}_0x38dc57=_[_0x355c('0x5b')]({},_0x38dc57,_0xba412e[_0x355c('0x60')]);var _0x457d96={'where':_0x38dc57[_0x355c('0x5a')]};return db[_0x355c('0x4a')]['count'](_0x457d96)[_0x355c('0x46')](function(_0x120665){_0x1afd5['count']=_0x120665;if(_0xba412e[_0x355c('0x52')]['includeAll']){_0x38dc57[_0x355c('0x61')]=[{'all':!![]}];}return db[_0x355c('0x4a')]['findAll'](_0x38dc57);})[_0x355c('0x46')](function(_0x1e25f1){_0x1afd5[_0x355c('0x62')]=_0x1e25f1;return _0x1afd5;})[_0x355c('0x46')](respondWithFilteredResult(_0x20323a,_0x38dc57))[_0x355c('0x2e')](handleError(_0x20323a,null));};exports[_0x355c('0x63')]=function(_0x5f28f6,_0x559b3c){var _0x2bf0b8={'raw':![],'where':{'id':_0x5f28f6[_0x355c('0x64')]['id']}},_0x4bdb45={};_0x4bdb45[_0x355c('0x4e')]=_[_0x355c('0x4f')](_[_0x355c('0x53')](db['User'][_0x355c('0x4b')]),[_0x355c('0x50'),_0x355c('0x51')]);_0x4bdb45['query']=_[_0x355c('0x53')](_0x5f28f6[_0x355c('0x52')]);_0x4bdb45[_0x355c('0x54')]=_[_0x355c('0x55')](_0x4bdb45[_0x355c('0x4e')],_0x4bdb45[_0x355c('0x52')]);_0x2bf0b8['attributes']=_['intersection'](_0x4bdb45[_0x355c('0x4e')],qs[_0x355c('0x57')](_0x5f28f6['query'][_0x355c('0x57')]));_0x2bf0b8[_0x355c('0x56')]=_0x2bf0b8[_0x355c('0x56')][_0x355c('0x58')]?_0x2bf0b8[_0x355c('0x56')]:_0x4bdb45[_0x355c('0x4e')];if(_0x5f28f6[_0x355c('0x52')][_0x355c('0x65')]){_0x2bf0b8['include']=[{'all':!![]}];}_0x2bf0b8=_[_0x355c('0x5b')]({},_0x2bf0b8,_0x5f28f6[_0x355c('0x60')]);return db[_0x355c('0x4a')][_0x355c('0x43')](_0x2bf0b8)['then'](handleEntityNotFound(_0x559b3c,null))[_0x355c('0x46')](respondWithResult(_0x559b3c,null))[_0x355c('0x2e')](handleError(_0x559b3c,null));};exports[_0x355c('0x66')]=function(_0x5c2473,_0x4b4d6a){return db[_0x355c('0x4a')]['bulkCreate'](_0x5c2473[_0x355c('0x67')],{'raw':![],'individualHooks':!![]})['then'](respondWithResult(_0x4b4d6a,0xc9))[_0x355c('0x2e')](handleError(_0x4b4d6a,null));};exports[_0x355c('0x39')]=function(_0x38525a,_0x38bc8c){if(_0x38525a['body']['id']){delete _0x38525a[_0x355c('0x67')]['id'];}delete _0x38525a['body'][_0x355c('0x42')];return db[_0x355c('0x4a')][_0x355c('0x43')]({'where':{'id':_0x38525a[_0x355c('0x64')]['id']}})[_0x355c('0x46')](handleEntityNotFound(_0x38bc8c,null))[_0x355c('0x46')](saveUpdates(_0x38525a[_0x355c('0x67')],null))[_0x355c('0x46')](respondWithResult(_0x38bc8c,null))[_0x355c('0x2e')](handleError(_0x38bc8c,null));};exports[_0x355c('0x68')]=function(_0x195c5b,_0x241a8b){return db[_0x355c('0x4a')][_0x355c('0x68')]()[_0x355c('0x46')](respondWithResult(_0x241a8b,null))[_0x355c('0x2e')](handleError(_0x241a8b,null));};exports[_0x355c('0x69')]=function(_0x57a89c,_0x2d63a2,_0xf95445){return db[_0x355c('0x4a')][_0x355c('0x43')]({'where':{'id':_0x57a89c['params']['id']}})[_0x355c('0x46')](handleEntityNotFound(_0x2d63a2,null))['then'](function(_0x280e06){if(_0x280e06){return _0x280e06[_0x355c('0x69')](_0x57a89c[_0x355c('0x67')][_0x355c('0x6a')],_[_0x355c('0x6b')](_0x57a89c['body'],[_0x355c('0x6a'),'id'])||{});}})[_0x355c('0x46')](respondWithResult(_0x2d63a2,null))[_0x355c('0x2e')](handleError(_0x2d63a2,null));};var getLicense=function(_0x3fd466){return new BPromise(function(_0x3fc1ae,_0x3a86c9){var _0xdf95f7=0x0;_0x3fd466[_0x355c('0x67')]['role']===_0x355c('0x3d')&&_0x3fc1ae(_0x355c('0x6c'));return db['User']['count']({'where':{'$or':[{'role':_0x3fd466[_0x355c('0x67')][_0x355c('0x42')]===_0x355c('0x3f')?_0x355c('0x3f'):[_0x355c('0x6d'),_0x355c('0x3c')]}]}})[_0x355c('0x46')](function(_0x38367e){_0xdf95f7=_0x38367e;return require(_0x355c('0x6e'))[_0x355c('0x6f')]();})[_0x355c('0x46')](function(_0x2d90ff){var _0x29deee=_0x3fd466[_0x355c('0x67')][_0x355c('0x42')]===_0x355c('0x3f')?'telephones':_0x355c('0x70');if(!_[_0x355c('0x71')](_0x2d90ff[_0x29deee])&&_0xdf95f7>=_0x2d90ff[_0x29deee]){return _0x3a86c9({'message':_0x355c('0x72')});}return _0x3fc1ae(util['format'](_0x355c('0x73'),_0x29deee,_0xdf95f7));})['catch'](function(_0x570132){return _0x3a86c9(_0x570132);});});};exports[_0x355c('0x74')]=function(_0x592eb7,_0x21f3b5){return getLicense(_0x592eb7)[_0x355c('0x46')](function(_0x290965){if(!_0x592eb7['body'][_0x355c('0x75')]){var _0x35e517;return db[_0x355c('0x76')][_0x355c('0x77')](0x1)[_0x355c('0x46')](function(_0x48d91a){return checkPasswordPattern(_0x48d91a,_0x592eb7['body'][_0x355c('0x50')],_0x48d91a['securePassword']);})[_0x355c('0x46')](function(_0x3ecfc7){_0x35e517=_0x3ecfc7[_0x355c('0x78')];return db[_0x355c('0x4a')]['max'](_0x355c('0x75'));})[_0x355c('0x46')](function(_0x1c27af){if(_['isNil'](_0x1c27af)){if(_0x35e517){_0x592eb7[_0x355c('0x67')][_0x355c('0x75')]=_0x35e517;}else{_0x592eb7[_0x355c('0x67')][_0x355c('0x75')]=0x1;}}else{if(_['isNil'](_0x35e517)||_0x35e517==_0x1c27af){_0x592eb7['body'][_0x355c('0x75')]=_0x1c27af+0x1;}else if(_0x35e517>_0x1c27af){_0x592eb7['body']['internal']=_0x35e517;}else{return db[_0x355c('0x5d')]['query'](_0x355c('0x79'),{'type':db[_0x355c('0x5d')]['QueryTypes']['SELECT']})[_0x355c('0x46')](function(_0x2ce410){if(_0x2ce410&&_0x2ce410[_0x355c('0x58')]){for(var _0xc8f09c=0x0,_0x44b881=_0x2ce410[_0x355c('0x58')];_0xc8f09c<_0x44b881&&_['isNil'](_0x592eb7['body'][_0x355c('0x75')]);_0xc8f09c++){if(_0x35e517<=_0x2ce410[_0xc8f09c]['from']){_0x592eb7['body'][_0x355c('0x75')]=_0x2ce410[_0xc8f09c][_0x355c('0x7a')];}else if(_0x35e517>_0x2ce410[_0xc8f09c][_0x355c('0x7a')]&&_0x35e517<=_0x2ce410[_0xc8f09c]['to']){_0x592eb7[_0x355c('0x67')]['internal']=_0x35e517;}}}if(_[_0x355c('0x71')](_0x592eb7[_0x355c('0x67')][_0x355c('0x75')])){_0x592eb7[_0x355c('0x67')][_0x355c('0x75')]=_0x1c27af+0x1;}});}}});}})['then'](function(){if(_0x592eb7[_0x355c('0x67')][_0x355c('0x7b')]){_0x592eb7[_0x355c('0x67')][_0x355c('0x7c')]=_0x592eb7[_0x355c('0x67')][_0x355c('0x75')];_0x592eb7[_0x355c('0x67')][_0x355c('0x7d')]={'mailbox':_0x592eb7[_0x355c('0x67')][_0x355c('0x75')],'password':_0x592eb7[_0x355c('0x67')][_0x355c('0x50')],'fullname':_0x592eb7['body'][_0x355c('0x7e')],'email':_0x592eb7[_0x355c('0x67')][_0x355c('0x7f')]};}if(_0x592eb7[_0x355c('0x67')]&&_0x592eb7[_0x355c('0x67')]['role']===_0x355c('0x3d')){_0x592eb7[_0x355c('0x67')]['permissions']=[_0x355c('0x80'),_0x355c('0x81'),_0x355c('0x82'),_0x355c('0x83'),'104',_0x355c('0x84'),_0x355c('0x85'),_0x355c('0x86'),_0x355c('0x87'),'109','100',_0x355c('0x88')];}return db[_0x355c('0x4a')][_0x355c('0x74')](_0x592eb7[_0x355c('0x67')],{'include':[{'model':db['VoiceMail'],'as':_0x355c('0x7d')}]});})[_0x355c('0x46')](function(_0x163d29){if(_0x592eb7[_0x355c('0x67')][_0x355c('0x42')]===_0x355c('0x3c'))return _0x163d29;var _0x32e2fd=_0x592eb7[_0x355c('0x3c')][_0x355c('0x3b')]({'plain':!![]});if(!_0x32e2fd)throw new Error(_0x355c('0x89'));if(_0x32e2fd[_0x355c('0x42')]==='user'){var _0x38fa58=_0x163d29['get']({'plain':!![]});var _0x430721=[{'name':_0x355c('0x8a'),'value':_0x355c('0x3d')},{'name':_0x355c('0x3e'),'value':_0x355c('0x3f')}];var _0x1246be=_[_0x355c('0x43')](_0x430721,[_0x355c('0x41'),_0x38fa58['role']])[_0x355c('0x44')];return db[_0x355c('0x8b')][_0x355c('0x43')]({'where':{'name':_0x1246be,'userProfileId':_0x32e2fd[_0x355c('0x8c')]},'raw':!![]})['then'](function(_0x31ba24){if(_0x31ba24&&_0x31ba24[_0x355c('0x8d')]===0x0){return db[_0x355c('0x45')][_0x355c('0x74')]({'name':_0x38fa58[_0x355c('0x44')],'resourceId':_0x38fa58['id'],'type':_0x31ba24[_0x355c('0x44')],'sectionId':_0x31ba24['id']},{})['then'](function(){return _0x163d29;});}else{return _0x163d29;}})['catch'](function(_0x3fa2f7){logger['error'](_0x355c('0x8e'),_0x3fa2f7);throw _0x3fa2f7;});}return _0x163d29;})[_0x355c('0x46')](respondWithResult(_0x21f3b5,0xc9))[_0x355c('0x2e')](handleError(_0x21f3b5,null));};exports[_0x355c('0x8f')]=function(_0x53fb58,_0x2cbea3,_0x97c1d4){var _0x3c99aa=![];if(_0x53fb58[_0x355c('0x67')]['id']){delete _0x53fb58['body']['id'];}return db['Setting'][_0x355c('0x90')]({'attributes':['id',_0x355c('0x91')]})[_0x355c('0x46')](function(_0x3c7c3d){_0x3c99aa=_0x3c7c3d[_0x355c('0x91')];return db['User'][_0x355c('0x43')]({'where':{'id':_0x53fb58[_0x355c('0x64')]['id']}});})['then'](function(_0x165bb9){if(_0x165bb9){if(_0x165bb9['id']==_0x53fb58[_0x355c('0x3c')]['id']){if(!_0x53fb58[_0x355c('0x67')][_0x355c('0x92')]||!_0x53fb58[_0x355c('0x67')][_0x355c('0x93')]){throw new db['Sequelize'][(_0x355c('0x24'))]('Invalid\x20body\x20format.\x20Use\x20oldPassord\x20and\x20newPassword');}if(!_0x165bb9[_0x355c('0x94')](_0x53fb58[_0x355c('0x67')]['oldPassword'])){throw new db['Sequelize'][(_0x355c('0x24'))](_0x355c('0x95'));}if(_0x53fb58['body'][_0x355c('0x92')]==_0x53fb58['body'][_0x355c('0x93')]){throw new db[(_0x355c('0x23'))][(_0x355c('0x24'))](_0x355c('0x96'));}return _0x165bb9;}else if(_0x53fb58[_0x355c('0x3c')][_0x355c('0x42')]==_0x355c('0x6d')){if(!_0x53fb58[_0x355c('0x67')][_0x355c('0x93')]){throw new db[(_0x355c('0x23'))][(_0x355c('0x24'))](_0x355c('0x97'));}return _0x165bb9;}else if(_0x53fb58['user'][_0x355c('0x42')]==_0x355c('0x3c')){if(!_0x53fb58[_0x355c('0x67')][_0x355c('0x93')]){throw new db[(_0x355c('0x23'))][(_0x355c('0x24'))](_0x355c('0x97'));}if(_0x165bb9[_0x355c('0x42')]!=_0x355c('0x3d')){throw new db['Sequelize'][(_0x355c('0x24'))]('Unauthorized');}return _0x165bb9;}else{throw new db[(_0x355c('0x23'))][(_0x355c('0x24'))](_0x355c('0x98'));}}return null;})[_0x355c('0x46')](handleEntityNotFound(_0x2cbea3,null))[_0x355c('0x46')](function(_0x517cbe){return checkPasswordPattern(_0x517cbe,_0x53fb58[_0x355c('0x67')]['newPassword'],_0x3c99aa);})[_0x355c('0x46')](saveUpdates({'password':_0x53fb58['body'][_0x355c('0x93')],'passwordResetAt':_0x53fb58[_0x355c('0x3c')]['id']==_0x53fb58[_0x355c('0x64')]['id']?moment():null},null))['then'](respondWithResult(_0x2cbea3,null))[_0x355c('0x2e')](handleError(_0x2cbea3,null));};exports[_0x355c('0x99')]=function(_0x9efc70,_0x2159ba,_0x45868a){var _0x245803=_0x9efc70[_0x355c('0x67')]['channel'];return db[_0x355c('0x4a')][_0x355c('0x43')]({'where':{'id':_0x9efc70[_0x355c('0x64')]['id']},'attributes':['id',_0x355c('0x44'),_0x355c('0x42'),_0x355c('0x9a'),_0x355c('0x9b'),_0x355c('0x9c'),_0x355c('0x9d')]})['then'](handleEntityNotFound(_0x2159ba,null))[_0x355c('0x46')](function(_0x27cf6a){if(_0x27cf6a){if(!utils[_0x355c('0x9e')](_0x245803)){throw new db[(_0x355c('0x23'))]['ValidationError'](_0x355c('0x9f'));}return _0x27cf6a[_0x355c('0xa0')+_[_0x355c('0xa1')](_0x245803[_0x355c('0xa2')]())+_0x355c('0xa3')](_0x9efc70['body'][_0x355c('0x6a')],{'penalty':_0x9efc70[_0x355c('0x67')][_0x355c('0xa4')]||0x0})['spread'](function(_0x498a6){for(var _0x3be3cb=0x0;_0x3be3cb<_0x9efc70[_0x355c('0x67')][_0x355c('0x6a')]['length'];_0x3be3cb+=0x1){var _0x175b88={'UserId':_0x9efc70[_0x355c('0x64')]['id']};_0x175b88[_[_0x355c('0xa1')](_0x245803[_0x355c('0xa2')]())+_0x355c('0xa5')]=_0x9efc70[_0x355c('0x67')][_0x355c('0x6a')][_0x3be3cb];socket[_0x355c('0xa6')]('user'+_[_0x355c('0xa1')](_0x245803[_0x355c('0xa2')]())+_0x355c('0xa7'),_0x175b88);}return _0x498a6;})[_0x355c('0x46')](function(){if(_0x245803===_0x355c('0xa8')){return db[_0x355c('0xa9')]['findAll']({'where':{'id':_0x9efc70['body']['ids']||[]},'raw':!![],'attributes':['id',_0x355c('0x44')]});}})[_0x355c('0x46')](function(_0x3c58ec){var _0x2c56fa=_0x27cf6a['get']({'plain':!![]});var _0x268617=[];if(_0x245803===_0x355c('0xa8')&&_0x2c56fa[_0x355c('0x42')]===_0x355c('0x3d')&&_0x2c56fa[_0x355c('0x9a')]){for(var _0x4b46d6=0x0;_0x4b46d6<_0x3c58ec['length'];_0x4b46d6+=0x1){_0x268617['push']({'membername':_0x2c56fa[_0x355c('0x44')],'UserId':_0x2c56fa['id'],'queue_name':_0x3c58ec[_0x4b46d6][_0x355c('0x44')],'VoiceQueueId':_0x3c58ec[_0x4b46d6]['id'],'interface':_['isNil'](_0x2c56fa['interface'])?util[_0x355c('0xaa')](_0x355c('0xab'),_0x2c56fa[_0x355c('0x44')]):_0x2c56fa['interface'],'paused':_0x2c56fa['voicePause']||![],'penalty':_0x9efc70[_0x355c('0x67')][_0x355c('0xa4')]||0x0});}return BPromise[_0x355c('0xac')](_0x268617,function(_0x3d68db){return db[_0x355c('0xad')][_0x355c('0xae')](_0x3d68db);});}return _0x27cf6a;});}})[_0x355c('0x46')](respondWithStatusCode(_0x2159ba,null))[_0x355c('0x2e')](handleError(_0x2159ba,null));};exports[_0x355c('0xaf')]=function(_0x1a3251,_0x339be4,_0xf7aaea){var _0x4c085d;return db['User'][_0x355c('0x43')]({'where':{'id':_0x1a3251[_0x355c('0x64')]['id']},'attributes':['id',_0x355c('0x44'),_0x355c('0x42')]})[_0x355c('0x46')](handleEntityNotFound(_0x339be4,null))[_0x355c('0x46')](function(_0xca704d){if(_0xca704d){_0x4c085d=_0xca704d;if(!_0x1a3251['query']['channel']||!utils[_0x355c('0x9e')](_0x1a3251['query']['channel'])){throw new db['Sequelize']['ValidationError'](_0x355c('0x9f'));}return _0xca704d['remove'+_['capitalize'](_0x1a3251[_0x355c('0x52')][_0x355c('0xb0')]['toLowerCase']())+'Queues'](_0x1a3251[_0x355c('0x52')][_0x355c('0x6a')]);}})[_0x355c('0x46')](function(_0x280ab4){for(var _0x3bf605=0x0;_0x3bf605<_0x1a3251[_0x355c('0x52')][_0x355c('0x6a')][_0x355c('0x58')];_0x3bf605+=0x1){var _0x1f1da3={'UserId':_0x1a3251[_0x355c('0x64')]['id']};_0x1f1da3[_['capitalize'](_0x1a3251[_0x355c('0x52')][_0x355c('0xb0')]['toLowerCase']())+_0x355c('0xa5')]=_0x1a3251[_0x355c('0x52')][_0x355c('0x6a')][_0x3bf605];socket[_0x355c('0xa6')]('user'+_[_0x355c('0xa1')](_0x1a3251[_0x355c('0x52')][_0x355c('0xb0')][_0x355c('0xa2')]())+'Queue:remove',_0x1f1da3);}return _0x280ab4;})[_0x355c('0x46')](function(){if(_0x1a3251[_0x355c('0x52')][_0x355c('0xb0')]===_0x355c('0xa8')){return db['UserVoiceQueueRt']['destroy']({'where':{'UserId':_0x1a3251[_0x355c('0x64')]['id'],'VoiceQueueId':_0x1a3251['query'][_0x355c('0x6a')]},'individualHooks':!![]})[_0x355c('0x46')](function(){return _0x4c085d;});}return _0x4c085d;})[_0x355c('0x46')](respondWithStatusCode(_0x339be4,null))[_0x355c('0x2e')](handleError(_0x339be4,null));};exports[_0x355c('0xb1')]=function(_0x354e68,_0x10fb67,_0x1ac30d){_0x354e68['body'][_0x355c('0xb2')]=_0x354e68[_0x355c('0xb3')][_0x355c('0xb4')];return db[_0x355c('0x4a')][_0x355c('0x43')]({'where':{'id':_0x354e68['params']['id']}})[_0x355c('0x46')](handleEntityNotFound(_0x10fb67,null))[_0x355c('0x46')](saveUpdates(_0x354e68[_0x355c('0x67')],null))['then'](respondWithResult(_0x10fb67,null))[_0x355c('0x2e')](handleError(_0x10fb67,null));};exports[_0x355c('0xb5')]=function(_0x50c1da,_0x454727,_0x21aa78){var _0x4f2af8=path['join'](config[_0x355c('0xb6')],_0x355c('0xb7'));return db[_0x355c('0x4a')][_0x355c('0x43')]({'where':{'id':_0x50c1da['params']['id']},'attributes':['id',_0x355c('0xb2')],'raw':!![]})[_0x355c('0x46')](handleEntityNotFound(_0x454727,null))[_0x355c('0x46')](function(_0x47fee8){if(_0x47fee8){if(_['isNil'](_0x47fee8['userpic'])){return _0x454727[_0x355c('0xb8')](_0x4f2af8);}else{if(!fs[_0x355c('0xb9')](path[_0x355c('0xba')](config[_0x355c('0xb6')],_0x355c('0xbb'),_0x47fee8[_0x355c('0xb2')]))){return _0x454727[_0x355c('0xb8')](_0x4f2af8);}return _0x454727[_0x355c('0xb8')](path['join'](config[_0x355c('0xb6')],_0x355c('0xbb'),_0x47fee8[_0x355c('0xb2')]));}}})[_0x355c('0x2e')](handleError(_0x454727,null));};exports[_0x355c('0xbc')]=function(_0x48de09,_0x87ac56,_0x102afb){var _0x54421e={};var _0x591424={};var _0x586523;var _0x33a7ea;return db[_0x355c('0x4a')][_0x355c('0x90')]({'where':{'id':_0x48de09[_0x355c('0x64')]['id']}})[_0x355c('0x46')](handleEntityNotFound(_0x87ac56,null))[_0x355c('0x46')](function(_0x11bb03){if(_0x11bb03){_0x586523=_0x11bb03;_0x591424[_0x355c('0x4e')]=_[_0x355c('0x53')](db[_0x355c('0xbd')][_0x355c('0x4b')]);_0x591424[_0x355c('0x52')]=_[_0x355c('0x53')](_0x48de09['query']);_0x591424[_0x355c('0x54')]=_[_0x355c('0x55')](_0x591424['model'],_0x591424[_0x355c('0x52')]);_0x54421e[_0x355c('0x56')]=_[_0x355c('0x55')](_0x591424[_0x355c('0x4e')],qs['fields'](_0x48de09[_0x355c('0x52')][_0x355c('0x57')]));_0x54421e[_0x355c('0x56')]=_0x54421e[_0x355c('0x56')][_0x355c('0x58')]?_0x54421e[_0x355c('0x56')]:_0x591424['model'];_0x54421e[_0x355c('0xbe')]=qs[_0x355c('0x59')](_0x48de09['query']['sort']);_0x54421e[_0x355c('0x5a')]=qs[_0x355c('0x54')](_['pick'](_0x48de09['query'],_0x591424[_0x355c('0x54')]));if(_0x48de09[_0x355c('0x52')][_0x355c('0x40')]){_0x54421e[_0x355c('0x5a')]=_[_0x355c('0x5b')](_0x54421e['where'],{'$or':_[_0x355c('0x49')](_0x54421e[_0x355c('0x56')],function(_0x5cbcdd){var _0x4a2f0c={};_0x4a2f0c[_0x5cbcdd]={'$like':'%'+_0x48de09[_0x355c('0x52')][_0x355c('0x40')]+'%'};return _0x4a2f0c;})});}_0x54421e=_[_0x355c('0x5b')]({},_0x54421e,_0x48de09[_0x355c('0x60')]);return _0x586523[_0x355c('0xbc')](_0x54421e);}})[_0x355c('0x46')](function(_0x5ce57f){if(_0x5ce57f){_0x33a7ea=_0x5ce57f[_0x355c('0x58')];if(_0x48de09[_0x355c('0x52')][_0x355c('0xbf')](_0x355c('0x65'))){_0x54421e[_0x355c('0x61')]=[{'model':db[_0x355c('0xc0')],'as':'List','required':![]},{'model':db[_0x355c('0xc1')],'as':_0x355c('0xc2'),'attributes':['id',_0x355c('0x44'),_0x355c('0xc3')],'where':_0x48de09[_0x355c('0x52')][_0x355c('0xc4')]?{'id':_0x48de09['query'][_0x355c('0xc4')]}:undefined,'required':_0x48de09['query'][_0x355c('0xc4')]?!![]:![]}];}if(!_0x48de09[_0x355c('0x52')]['hasOwnProperty'](_0x355c('0xc5'))){_0x54421e[_0x355c('0x34')]=qs[_0x355c('0x34')](_0x48de09[_0x355c('0x52')]['limit']);_0x54421e['offset']=qs[_0x355c('0x33')](_0x48de09[_0x355c('0x52')][_0x355c('0x33')]);}return _0x586523['getContacts'](_0x54421e);}})[_0x355c('0x46')](function(_0x7242a5){if(_0x7242a5){return _0x7242a5?{'count':_0x33a7ea,'rows':_0x7242a5}:null;}})[_0x355c('0x46')](respondWithResult(_0x87ac56,null))[_0x355c('0x2e')](handleError(_0x87ac56,null));};exports[_0x355c('0xc6')]=function(_0x3527e2,_0x193410,_0x34555b){var _0x4a2ba1;var _0x32652c;var _0x1b7323={};var _0x5cb3df;return db[_0x355c('0x4a')][_0x355c('0x90')]({'where':{'id':_0x3527e2[_0x355c('0x64')]['id']},'attributes':['id',_0x355c('0x44'),_0x355c('0x42')]})[_0x355c('0x46')](handleEntityNotFound(_0x193410,null))[_0x355c('0x46')](function(_0x5c53bc){if(!utils['isValidChannel'](_0x3527e2['query'][_0x355c('0xb0')])){throw new db[(_0x355c('0x23'))][(_0x355c('0x24'))](_0x355c('0x9f'));}_0x4a2ba1=_0x5c53bc;var _0x2f1f92={};_0x2f1f92['model']=_['keys'](db[_[_0x355c('0xa1')](_0x3527e2[_0x355c('0x52')][_0x355c('0xb0')])+_0x355c('0xc7')]['rawAttributes']);_0x2f1f92[_0x355c('0x52')]=_[_0x355c('0x53')](_0x3527e2[_0x355c('0x52')]);_0x2f1f92[_0x355c('0x54')]=_[_0x355c('0x55')](_0x2f1f92[_0x355c('0x4e')],_0x2f1f92[_0x355c('0x52')]);_0x1b7323[_0x355c('0x56')]=_[_0x355c('0x55')](_0x2f1f92['model'],qs[_0x355c('0x57')](_0x3527e2[_0x355c('0x52')][_0x355c('0x57')]));_0x1b7323[_0x355c('0x56')]=_0x1b7323['attributes'][_0x355c('0x58')]?_0x1b7323['attributes']:_0x2f1f92['model'];_0x1b7323[_0x355c('0xbe')]=qs[_0x355c('0x59')](_0x3527e2[_0x355c('0x52')][_0x355c('0x59')]);_0x1b7323[_0x355c('0x5a')]=qs[_0x355c('0x54')](_[_0x355c('0xc8')](_0x3527e2[_0x355c('0x52')],_0x2f1f92['filters']));if(_0x3527e2[_0x355c('0x52')]['filter']){_0x1b7323[_0x355c('0x5a')]=_[_0x355c('0x5b')](_0x1b7323[_0x355c('0x5a')],{'$or':_[_0x355c('0x49')](_0x1b7323[_0x355c('0x56')],function(_0x37e939){var _0x559172={};_0x559172[_0x37e939]={'$like':'%'+_0x3527e2[_0x355c('0x52')][_0x355c('0x40')]+'%'};return _0x559172;})});}_0x1b7323=_[_0x355c('0x5b')]({},_0x1b7323,_0x3527e2['options']);switch(_0x4a2ba1[_0x355c('0x42')]){case'admin':return db[_[_0x355c('0xa1')](_0x3527e2[_0x355c('0x52')]['channel'])+_0x355c('0xc7')]['findAll'](_0x1b7323);case _0x355c('0x3c'):case _0x355c('0x3d'):return _0x4a2ba1['get'+_['capitalize'](_0x3527e2[_0x355c('0x52')][_0x355c('0xb0')])+'Queues'](_0x1b7323);default:throw new db[(_0x355c('0x23'))][(_0x355c('0x24'))](_0x355c('0xc9'));}})[_0x355c('0x46')](function(_0x1e447c){_0x5cb3df=_0x1e447c[_0x355c('0x58')];if(!_0x3527e2[_0x355c('0x52')][_0x355c('0xbf')](_0x355c('0xc5'))){_0x1b7323[_0x355c('0x34')]=qs[_0x355c('0x34')](_0x3527e2[_0x355c('0x52')][_0x355c('0x34')]);_0x1b7323['offset']=qs[_0x355c('0x33')](_0x3527e2[_0x355c('0x52')][_0x355c('0x33')]);}switch(_0x4a2ba1[_0x355c('0x42')]){case _0x355c('0x6d'):return db[_[_0x355c('0xa1')](_0x3527e2[_0x355c('0x52')]['channel'])+'Queue']['findAll'](_0x1b7323);case _0x355c('0x3c'):case _0x355c('0x3d'):return _0x4a2ba1[_0x355c('0x3b')+_[_0x355c('0xa1')](_0x3527e2[_0x355c('0x52')][_0x355c('0xb0')])+'Queues'](_0x1b7323);}})['then'](function(_0x44a649){return{'count':_0x5cb3df,'rows':_0x44a649};})['then'](respondWithResult(_0x193410,null))[_0x355c('0x2e')](handleError(_0x193410,null));};exports[_0x355c('0xca')]=function(_0xf57808,_0x507a0e,_0x1d40d0){var _0x17328d={};var _0xb0a810={};var _0xcb2b88;var _0x31d207;return db[_0x355c('0x4a')][_0x355c('0x90')]({'where':{'id':_0xf57808[_0x355c('0x64')]['id']}})['then'](handleEntityNotFound(_0x507a0e,null))['then'](function(_0x27edc2){if(_0x27edc2){_0xcb2b88=_0x27edc2;_0xb0a810[_0x355c('0x4e')]=_[_0x355c('0x53')](db[_0x355c('0xad')][_0x355c('0x4b')]);_0xb0a810[_0x355c('0x52')]=_[_0x355c('0x53')](_0xf57808[_0x355c('0x52')]);_0xb0a810[_0x355c('0x54')]=_[_0x355c('0x55')](_0xb0a810['model'],_0xb0a810[_0x355c('0x52')]);_0x17328d[_0x355c('0x56')]=_[_0x355c('0x55')](_0xb0a810[_0x355c('0x4e')],qs[_0x355c('0x57')](_0xf57808[_0x355c('0x52')][_0x355c('0x57')]));_0x17328d[_0x355c('0x56')]=_0x17328d[_0x355c('0x56')][_0x355c('0x58')]?_0x17328d[_0x355c('0x56')]:_0xb0a810[_0x355c('0x4e')];_0x17328d[_0x355c('0xbe')]=qs[_0x355c('0x59')](_0xf57808['query']['sort']);_0x17328d[_0x355c('0x5a')]=qs[_0x355c('0x54')](_[_0x355c('0xc8')](_0xf57808[_0x355c('0x52')],_0xb0a810[_0x355c('0x54')]));if(_0xf57808[_0x355c('0x52')][_0x355c('0x40')]){_0x17328d[_0x355c('0x5a')]=_[_0x355c('0x5b')](_0x17328d['where'],{'$or':_[_0x355c('0x49')](_0x17328d[_0x355c('0x56')],function(_0x5580b7){var _0x5400ae={};_0x5400ae[_0x5580b7]={'$like':'%'+_0xf57808['query'][_0x355c('0x40')]+'%'};return _0x5400ae;})});}_0x17328d=_[_0x355c('0x5b')]({},_0x17328d,_0xf57808['options']);return _0xcb2b88['getVoiceQueuesRt'](_0x17328d);}})[_0x355c('0x46')](function(_0x278fed){if(_0x278fed){_0x31d207=_0x278fed[_0x355c('0x58')];if(!_0xf57808[_0x355c('0x52')]['hasOwnProperty']('nolimit')){_0x17328d[_0x355c('0x34')]=qs[_0x355c('0x34')](_0xf57808[_0x355c('0x52')][_0x355c('0x34')]);_0x17328d[_0x355c('0x33')]=qs['offset'](_0xf57808[_0x355c('0x52')][_0x355c('0x33')]);}return _0xcb2b88[_0x355c('0xca')](_0x17328d);}})[_0x355c('0x46')](function(_0x20d20b){if(_0x20d20b){return _0x20d20b?{'count':_0x31d207,'rows':_0x20d20b}:null;}})[_0x355c('0x46')](respondWithResult(_0x507a0e,null))[_0x355c('0x2e')](handleError(_0x507a0e,null));};exports['getGroups']=function(_0x5c2826,_0x23e6df,_0x14bebb){var _0x305158={};var _0x40b246={};var _0x4f5044;var _0x371594;return db[_0x355c('0x4a')][_0x355c('0x90')]({'where':{'id':_0x5c2826[_0x355c('0x64')]['id']}})['then'](handleEntityNotFound(_0x23e6df,null))[_0x355c('0x46')](function(_0x32209c){if(_0x32209c){_0x4f5044=_0x32209c;_0x40b246['model']=_[_0x355c('0x53')](db[_0x355c('0xcb')][_0x355c('0x4b')]);_0x40b246[_0x355c('0x52')]=_[_0x355c('0x53')](_0x5c2826['query']);_0x40b246[_0x355c('0x54')]=_[_0x355c('0x55')](_0x40b246[_0x355c('0x4e')],_0x40b246['query']);_0x305158[_0x355c('0x56')]=_[_0x355c('0x55')](_0x40b246[_0x355c('0x4e')],qs['fields'](_0x5c2826['query']['fields']));_0x305158[_0x355c('0x56')]=_0x305158['attributes'][_0x355c('0x58')]?_0x305158['attributes']:_0x40b246[_0x355c('0x4e')];_0x305158[_0x355c('0xbe')]=qs[_0x355c('0x59')](_0x5c2826[_0x355c('0x52')]['sort']);_0x305158[_0x355c('0x5a')]=qs[_0x355c('0x54')](_[_0x355c('0xc8')](_0x5c2826[_0x355c('0x52')],_0x40b246[_0x355c('0x54')]));if(_0x5c2826['query'][_0x355c('0x40')]){_0x305158[_0x355c('0x5a')]=_[_0x355c('0x5b')](_0x305158['where'],{'$or':_[_0x355c('0x49')](_0x305158[_0x355c('0x56')],function(_0x573276){var _0x45b086={};_0x45b086[_0x573276]={'$like':'%'+_0x5c2826[_0x355c('0x52')][_0x355c('0x40')]+'%'};return _0x45b086;})});}_0x305158=_[_0x355c('0x5b')]({},_0x305158,_0x5c2826[_0x355c('0x60')]);return _0x4f5044[_0x355c('0xcc')](_0x305158);}})[_0x355c('0x46')](function(_0x2b409a){if(_0x2b409a){_0x371594=_0x2b409a['length'];if(!_0x5c2826[_0x355c('0x52')]['hasOwnProperty']('nolimit')){_0x305158[_0x355c('0x34')]=qs['limit'](_0x5c2826[_0x355c('0x52')]['limit']);_0x305158[_0x355c('0x33')]=qs[_0x355c('0x33')](_0x5c2826[_0x355c('0x52')]['offset']);}return _0x4f5044[_0x355c('0xcc')](_0x305158);}})[_0x355c('0x46')](function(_0x5beca3){if(_0x5beca3){return _0x5beca3?{'count':_0x371594,'rows':_0x5beca3}:null;}})[_0x355c('0x46')](respondWithResult(_0x23e6df,null))[_0x355c('0x2e')](handleError(_0x23e6df,null));};exports[_0x355c('0xcd')]=function(_0x6d4417,_0x18e9d8,_0x2cb465){var _0x3a4292={'raw':!![],'where':{}};var _0x317890={};var _0x545874={'count':0x0,'rows':[]};return db[_0x355c('0x4a')]['findOne']({'where':{'id':_0x6d4417[_0x355c('0x64')]['id']}})[_0x355c('0x46')](handleEntityNotFound(_0x18e9d8,null))['then'](function(_0x34beb4){if(_0x34beb4){_0x317890['model']=_[_0x355c('0x53')](db['VoiceRecording'][_0x355c('0x4b')]);_0x317890[_0x355c('0x52')]=_['keys'](_0x6d4417[_0x355c('0x52')]);_0x317890['filters']=_[_0x355c('0x55')](_0x317890[_0x355c('0x4e')],_0x317890[_0x355c('0x52')]);_0x3a4292[_0x355c('0x56')]=_['intersection'](_0x317890['model'],qs[_0x355c('0x57')](_0x6d4417[_0x355c('0x52')]['fields']));_0x3a4292[_0x355c('0x56')]=_0x3a4292[_0x355c('0x56')][_0x355c('0x58')]?_0x3a4292['attributes']:_0x317890[_0x355c('0x4e')];if(!_0x6d4417['query'][_0x355c('0xbf')]('nolimit')){_0x3a4292[_0x355c('0x34')]=qs[_0x355c('0x34')](_0x6d4417[_0x355c('0x52')][_0x355c('0x34')]);_0x3a4292['offset']=qs['offset'](_0x6d4417['query'][_0x355c('0x33')]);}_0x3a4292['order']=qs['sort'](_0x6d4417[_0x355c('0x52')]['sort']);_0x3a4292[_0x355c('0x5a')]=qs[_0x355c('0x54')](_[_0x355c('0xc8')](_0x6d4417['query'],_0x317890[_0x355c('0x54')]));_0x3a4292['where'][_0x355c('0xce')]=_0x34beb4['id'];if(_0x6d4417[_0x355c('0x52')][_0x355c('0x40')]){_0x3a4292[_0x355c('0x5a')]=_['merge'](_0x3a4292[_0x355c('0x5a')],{'$or':_['map'](_0x3a4292['attributes'],function(_0x338705){var _0x4e8348={};_0x4e8348[_0x338705]={'$like':'%'+_0x6d4417[_0x355c('0x52')][_0x355c('0x40')]+'%'};return _0x4e8348;})});}_0x3a4292=_['merge']({},_0x3a4292,_0x6d4417[_0x355c('0x60')]);return db['VoiceRecording'][_0x355c('0x32')]({'where':_0x3a4292[_0x355c('0x5a')]})['then'](function(_0x38a8a3){_0x545874[_0x355c('0x32')]=_0x38a8a3;if(_0x6d4417['query'][_0x355c('0x65')]){_0x3a4292[_0x355c('0x61')]=[{'all':!![]}];}return db[_0x355c('0xcf')][_0x355c('0xd0')](_0x3a4292);})[_0x355c('0x46')](function(_0x106324){_0x545874[_0x355c('0x62')]=_0x106324;return _0x545874;});}})[_0x355c('0x46')](respondWithFilteredResult(_0x18e9d8,_0x3a4292))[_0x355c('0x2e')](handleError(_0x18e9d8,null));};exports[_0x355c('0xd1')]=function(_0x4c1adc,_0x4b1b50,_0x5b7204){var _0x156dc2={'raw':!![],'where':{}};var _0x14cffd={};var _0x634067={'count':0x0,'rows':[]};return db['User'][_0x355c('0x90')]({'where':{'id':_0x4c1adc[_0x355c('0x64')]['id']}})['then'](handleEntityNotFound(_0x4b1b50,null))[_0x355c('0x46')](function(_0x1e2d18){if(_0x1e2d18){_0x14cffd[_0x355c('0x4e')]=_[_0x355c('0x53')](db[_0x355c('0xd2')][_0x355c('0x4b')]);_0x14cffd['query']=_['keys'](_0x4c1adc[_0x355c('0x52')]);_0x14cffd[_0x355c('0x54')]=_['intersection'](_0x14cffd[_0x355c('0x4e')],_0x14cffd['query']);_0x156dc2[_0x355c('0x56')]=_[_0x355c('0x55')](_0x14cffd['model'],qs[_0x355c('0x57')](_0x4c1adc['query'][_0x355c('0x57')]));_0x156dc2[_0x355c('0x56')]=_0x156dc2[_0x355c('0x56')]['length']?_0x156dc2[_0x355c('0x56')]:_0x14cffd[_0x355c('0x4e')];if(!_0x4c1adc[_0x355c('0x52')][_0x355c('0xbf')]('nolimit')){_0x156dc2[_0x355c('0x34')]=qs['limit'](_0x4c1adc[_0x355c('0x52')][_0x355c('0x34')]);_0x156dc2[_0x355c('0x33')]=qs[_0x355c('0x33')](_0x4c1adc['query'][_0x355c('0x33')]);}_0x156dc2['order']=qs[_0x355c('0x59')](_0x4c1adc[_0x355c('0x52')]['sort']);_0x156dc2['where']=qs[_0x355c('0x54')](_[_0x355c('0xc8')](_0x4c1adc[_0x355c('0x52')],_0x14cffd['filters']));_0x156dc2['where'][_0x355c('0xce')]=_0x1e2d18['id'];if(_0x4c1adc['query']['filter']){_0x156dc2['where']=_[_0x355c('0x5b')](_0x156dc2[_0x355c('0x5a')],{'$or':_[_0x355c('0x49')](_0x156dc2[_0x355c('0x56')],function(_0x6ed08e){var _0x2e9571={};_0x2e9571[_0x6ed08e]={'$like':'%'+_0x4c1adc[_0x355c('0x52')][_0x355c('0x40')]+'%'};return _0x2e9571;})});}_0x156dc2=_[_0x355c('0x5b')]({},_0x156dc2,_0x4c1adc[_0x355c('0x60')]);return db[_0x355c('0xd2')][_0x355c('0x32')]({'where':_0x156dc2[_0x355c('0x5a')]})['then'](function(_0x842c38){_0x634067[_0x355c('0x32')]=_0x842c38;if(_0x4c1adc['query'][_0x355c('0x65')]){_0x156dc2[_0x355c('0x61')]=[{'all':!![]}];}return db['ScreenRecording'][_0x355c('0xd0')](_0x156dc2);})[_0x355c('0x46')](function(_0x4cc175){_0x634067[_0x355c('0x62')]=_0x4cc175;return _0x634067;});}})['then'](respondWithFilteredResult(_0x4b1b50,_0x156dc2))[_0x355c('0x2e')](handleError(_0x4b1b50,null));};exports[_0x355c('0xd3')]=function(_0x11e42a,_0x1bacae,_0x42ff0a){var _0x505658={};var _0x10f4a2={};var _0x2e2790;var _0x2e35ec;return db[_0x355c('0x4a')]['findOne']({'where':{'id':_0x11e42a[_0x355c('0x64')]['id']}})[_0x355c('0x46')](handleEntityNotFound(_0x1bacae,null))[_0x355c('0x46')](function(_0x21f0c7){if(_0x21f0c7){_0x2e2790=_0x21f0c7;_0x10f4a2[_0x355c('0x4e')]=_[_0x355c('0x53')](db[_0x355c('0xd4')][_0x355c('0x4b')]);_0x10f4a2[_0x355c('0x52')]=_[_0x355c('0x53')](_0x11e42a[_0x355c('0x52')]);_0x10f4a2['filters']=_[_0x355c('0x55')](_0x10f4a2[_0x355c('0x4e')],_0x10f4a2[_0x355c('0x52')]);_0x505658[_0x355c('0x56')]=_[_0x355c('0x55')](_0x10f4a2[_0x355c('0x4e')],qs[_0x355c('0x57')](_0x11e42a['query']['fields']));_0x505658['attributes']=_0x505658[_0x355c('0x56')][_0x355c('0x58')]?_0x505658[_0x355c('0x56')]:_0x10f4a2[_0x355c('0x4e')];_0x505658[_0x355c('0xbe')]=qs[_0x355c('0x59')](_0x11e42a['query'][_0x355c('0x59')]);_0x505658[_0x355c('0x5a')]=qs['filters'](_[_0x355c('0xc8')](_0x11e42a[_0x355c('0x52')],_0x10f4a2[_0x355c('0x54')]));if(_0x11e42a[_0x355c('0x52')][_0x355c('0x40')]){_0x505658[_0x355c('0x5a')]=_[_0x355c('0x5b')](_0x505658[_0x355c('0x5a')],{'$or':_[_0x355c('0x49')](_0x505658[_0x355c('0x56')],function(_0x30f74d){var _0x397629={};_0x397629[_0x30f74d]={'$like':'%'+_0x11e42a[_0x355c('0x52')][_0x355c('0x40')]+'%'};return _0x397629;})});}_0x505658=_['merge']({},_0x505658,_0x11e42a[_0x355c('0x60')]);return _0x2e2790['getChatInteractions'](_0x505658);}})[_0x355c('0x46')](function(_0x1318b9){if(_0x1318b9){_0x2e35ec=_0x1318b9[_0x355c('0x58')];if(!_0x11e42a[_0x355c('0x52')][_0x355c('0xbf')](_0x355c('0xc5'))){_0x505658[_0x355c('0x34')]=qs[_0x355c('0x34')](_0x11e42a[_0x355c('0x52')][_0x355c('0x34')]);_0x505658[_0x355c('0x33')]=qs[_0x355c('0x33')](_0x11e42a['query'][_0x355c('0x33')]);}return _0x2e2790['getChatInteractions'](_0x505658);}})[_0x355c('0x46')](function(_0x379cb8){if(_0x379cb8){return _0x379cb8?{'count':_0x2e35ec,'rows':_0x379cb8}:null;}})[_0x355c('0x46')](respondWithResult(_0x1bacae,null))['catch'](handleError(_0x1bacae,null));};exports[_0x355c('0xd5')]=function(_0x10bc6d,_0x5bfbe2,_0x34ade6){var _0x210a8e={};var _0x12b0b7={};var _0x5c2eea;var _0x3fcd34;return db[_0x355c('0x4a')][_0x355c('0x90')]({'where':{'id':_0x10bc6d[_0x355c('0x64')]['id']}})[_0x355c('0x46')](handleEntityNotFound(_0x5bfbe2,null))[_0x355c('0x46')](function(_0x48b3f0){if(_0x48b3f0){_0x5c2eea=_0x48b3f0;_0x12b0b7['model']=_['keys'](db[_0x355c('0xd6')]['rawAttributes']);_0x12b0b7[_0x355c('0x52')]=_[_0x355c('0x53')](_0x10bc6d[_0x355c('0x52')]);_0x12b0b7[_0x355c('0x54')]=_['intersection'](_0x12b0b7[_0x355c('0x4e')],_0x12b0b7['query']);_0x210a8e[_0x355c('0x56')]=_['intersection'](_0x12b0b7['model'],qs[_0x355c('0x57')](_0x10bc6d['query']['fields']));_0x210a8e[_0x355c('0x56')]=_0x210a8e[_0x355c('0x56')][_0x355c('0x58')]?_0x210a8e[_0x355c('0x56')]:_0x12b0b7[_0x355c('0x4e')];_0x210a8e[_0x355c('0xbe')]=qs['sort'](_0x10bc6d[_0x355c('0x52')][_0x355c('0x59')]);_0x210a8e[_0x355c('0x5a')]=qs['filters'](_[_0x355c('0xc8')](_0x10bc6d[_0x355c('0x52')],_0x12b0b7[_0x355c('0x54')]));if(_0x10bc6d['query'][_0x355c('0x40')]){_0x210a8e[_0x355c('0x5a')]=_['merge'](_0x210a8e[_0x355c('0x5a')],{'$or':_[_0x355c('0x49')](_0x210a8e[_0x355c('0x56')],function(_0x3c9683){var _0x42f3c6={};_0x42f3c6[_0x3c9683]={'$like':'%'+_0x10bc6d[_0x355c('0x52')]['filter']+'%'};return _0x42f3c6;})});}_0x210a8e=_['merge']({},_0x210a8e,_0x10bc6d[_0x355c('0x60')]);return _0x5c2eea[_0x355c('0xd5')](_0x210a8e);}})['then'](function(_0x390e57){if(_0x390e57){_0x3fcd34=_0x390e57[_0x355c('0x58')];if(!_0x10bc6d[_0x355c('0x52')][_0x355c('0xbf')](_0x355c('0xc5'))){_0x210a8e[_0x355c('0x34')]=qs[_0x355c('0x34')](_0x10bc6d[_0x355c('0x52')][_0x355c('0x34')]);_0x210a8e[_0x355c('0x33')]=qs[_0x355c('0x33')](_0x10bc6d[_0x355c('0x52')][_0x355c('0x33')]);}return _0x5c2eea[_0x355c('0xd5')](_0x210a8e);}})['then'](function(_0x1943de){if(_0x1943de){return _0x1943de?{'count':_0x3fcd34,'rows':_0x1943de}:null;}})[_0x355c('0x46')](respondWithResult(_0x5bfbe2,null))[_0x355c('0x2e')](handleError(_0x5bfbe2,null));};exports[_0x355c('0xd7')]=function(_0x5205a4,_0x443530,_0x6321c4){var _0x1720fc={'raw':!![],'where':{}};var _0x4f9907={};var _0x2e41cf={'count':0x0,'rows':[]};return db[_0x355c('0x4a')]['findOne']({'where':{'id':_0x5205a4[_0x355c('0x64')]['id']}})[_0x355c('0x46')](handleEntityNotFound(_0x443530,null))[_0x355c('0x46')](function(_0x5b86c7){if(_0x5b86c7){_0x4f9907['model']=_[_0x355c('0x53')](db[_0x355c('0xd8')][_0x355c('0x4b')]);_0x4f9907[_0x355c('0x52')]=_[_0x355c('0x53')](_0x5205a4[_0x355c('0x52')]);_0x4f9907[_0x355c('0x54')]=_[_0x355c('0x55')](_0x4f9907[_0x355c('0x4e')],_0x4f9907['query']);_0x1720fc[_0x355c('0x56')]=_[_0x355c('0x55')](_0x4f9907[_0x355c('0x4e')],qs[_0x355c('0x57')](_0x5205a4[_0x355c('0x52')]['fields']));_0x1720fc[_0x355c('0x56')]=_0x1720fc[_0x355c('0x56')][_0x355c('0x58')]?_0x1720fc['attributes']:_0x4f9907[_0x355c('0x4e')];if(!_0x5205a4[_0x355c('0x52')][_0x355c('0xbf')](_0x355c('0xc5'))){_0x1720fc[_0x355c('0x34')]=qs[_0x355c('0x34')](_0x5205a4[_0x355c('0x52')][_0x355c('0x34')]);_0x1720fc[_0x355c('0x33')]=qs['offset'](_0x5205a4[_0x355c('0x52')]['offset']);}_0x1720fc[_0x355c('0xbe')]=qs[_0x355c('0x59')](_0x5205a4['query']['sort']);_0x1720fc[_0x355c('0x5a')]=qs[_0x355c('0x54')](_[_0x355c('0xc8')](_0x5205a4[_0x355c('0x52')],_0x4f9907[_0x355c('0x54')]));_0x1720fc['where'][_0x355c('0xce')]=_0x5b86c7['id'];if(_0x5205a4[_0x355c('0x52')]['filter']){_0x1720fc[_0x355c('0x5a')]=_['merge'](_0x1720fc[_0x355c('0x5a')],{'$or':_['map'](_0x1720fc[_0x355c('0x56')],function(_0x4282f3){var _0x438e0a={};_0x438e0a[_0x4282f3]={'$like':'%'+_0x5205a4[_0x355c('0x52')]['filter']+'%'};return _0x438e0a;})});}_0x1720fc=_[_0x355c('0x5b')]({},_0x1720fc,_0x5205a4[_0x355c('0x60')]);return db[_0x355c('0xd8')][_0x355c('0x32')]({'where':_0x1720fc[_0x355c('0x5a')]})[_0x355c('0x46')](function(_0x21be8b){_0x2e41cf[_0x355c('0x32')]=_0x21be8b;if(_0x5205a4['query'][_0x355c('0x65')]){_0x1720fc[_0x355c('0x61')]=[{'all':!![]}];}return db[_0x355c('0xd8')]['findAll'](_0x1720fc);})[_0x355c('0x46')](function(_0x3ba25c){_0x2e41cf[_0x355c('0x62')]=_0x3ba25c;return _0x2e41cf;});}})['then'](respondWithFilteredResult(_0x443530,_0x1720fc))['catch'](handleError(_0x443530,null));};exports[_0x355c('0xd9')]=function(_0x343f84,_0x1dd32b,_0x57e9d5){var _0xf3ab6b={};var _0x383610={};var _0x344a22;var _0x56bd4a;return db[_0x355c('0x4a')]['findOne']({'where':{'id':_0x343f84[_0x355c('0x64')]['id']}})['then'](handleEntityNotFound(_0x1dd32b,null))[_0x355c('0x46')](function(_0x5d4ae3){if(_0x5d4ae3){_0x344a22=_0x5d4ae3;_0x383610[_0x355c('0x4e')]=_[_0x355c('0x53')](db['SmsInteraction'][_0x355c('0x4b')]);_0x383610[_0x355c('0x52')]=_[_0x355c('0x53')](_0x343f84['query']);_0x383610[_0x355c('0x54')]=_[_0x355c('0x55')](_0x383610['model'],_0x383610[_0x355c('0x52')]);_0xf3ab6b['attributes']=_[_0x355c('0x55')](_0x383610[_0x355c('0x4e')],qs[_0x355c('0x57')](_0x343f84['query']['fields']));_0xf3ab6b[_0x355c('0x56')]=_0xf3ab6b[_0x355c('0x56')]['length']?_0xf3ab6b['attributes']:_0x383610[_0x355c('0x4e')];_0xf3ab6b[_0x355c('0xbe')]=qs[_0x355c('0x59')](_0x343f84['query'][_0x355c('0x59')]);_0xf3ab6b['where']=qs['filters'](_['pick'](_0x343f84['query'],_0x383610[_0x355c('0x54')]));if(_0x343f84['query'][_0x355c('0x40')]){_0xf3ab6b[_0x355c('0x5a')]=_[_0x355c('0x5b')](_0xf3ab6b['where'],{'$or':_['map'](_0xf3ab6b[_0x355c('0x56')],function(_0xcd2d0c){var _0x2f481b={};_0x2f481b[_0xcd2d0c]={'$like':'%'+_0x343f84[_0x355c('0x52')][_0x355c('0x40')]+'%'};return _0x2f481b;})});}_0xf3ab6b=_[_0x355c('0x5b')]({},_0xf3ab6b,_0x343f84[_0x355c('0x60')]);return _0x344a22[_0x355c('0xd9')](_0xf3ab6b);}})[_0x355c('0x46')](function(_0x5127a0){if(_0x5127a0){_0x56bd4a=_0x5127a0[_0x355c('0x58')];if(!_0x343f84[_0x355c('0x52')][_0x355c('0xbf')]('nolimit')){_0xf3ab6b[_0x355c('0x34')]=qs[_0x355c('0x34')](_0x343f84[_0x355c('0x52')][_0x355c('0x34')]);_0xf3ab6b[_0x355c('0x33')]=qs[_0x355c('0x33')](_0x343f84['query'][_0x355c('0x33')]);}return _0x344a22[_0x355c('0xd9')](_0xf3ab6b);}})['then'](function(_0x2fa6bb){if(_0x2fa6bb){return _0x2fa6bb?{'count':_0x56bd4a,'rows':_0x2fa6bb}:null;}})[_0x355c('0x46')](respondWithResult(_0x1dd32b,null))['catch'](handleError(_0x1dd32b,null));};exports[_0x355c('0xda')]=function(_0x558406,_0x397f90,_0x1b37b1){var _0x1a2fbb={};var _0x4a2f55={};var _0x15b9ab;var _0x4ccc31;return db[_0x355c('0x4a')][_0x355c('0x90')]({'where':{'id':_0x558406[_0x355c('0x64')]['id']}})[_0x355c('0x46')](handleEntityNotFound(_0x397f90,null))['then'](function(_0x50cb6d){if(_0x50cb6d){_0x15b9ab=_0x50cb6d;_0x4a2f55[_0x355c('0x4e')]=_[_0x355c('0x53')](db[_0x355c('0xdb')][_0x355c('0x4b')]);_0x4a2f55['query']=_[_0x355c('0x53')](_0x558406[_0x355c('0x52')]);_0x4a2f55['filters']=_[_0x355c('0x55')](_0x4a2f55['model'],_0x4a2f55[_0x355c('0x52')]);_0x1a2fbb[_0x355c('0x56')]=_[_0x355c('0x55')](_0x4a2f55[_0x355c('0x4e')],qs['fields'](_0x558406[_0x355c('0x52')][_0x355c('0x57')]));_0x1a2fbb['attributes']=_0x1a2fbb[_0x355c('0x56')]['length']?_0x1a2fbb['attributes']:_0x4a2f55['model'];_0x1a2fbb['order']=qs[_0x355c('0x59')](_0x558406[_0x355c('0x52')]['sort']);_0x1a2fbb[_0x355c('0x5a')]=qs[_0x355c('0x54')](_[_0x355c('0xc8')](_0x558406['query'],_0x4a2f55['filters']));if(_0x558406[_0x355c('0x52')]['filter']){_0x1a2fbb[_0x355c('0x5a')]=_['merge'](_0x1a2fbb[_0x355c('0x5a')],{'$or':_[_0x355c('0x49')](_0x1a2fbb[_0x355c('0x56')],function(_0x1e5ddb){var _0x3cf5e3={};_0x3cf5e3[_0x1e5ddb]={'$like':'%'+_0x558406[_0x355c('0x52')][_0x355c('0x40')]+'%'};return _0x3cf5e3;})});}_0x1a2fbb=_['merge']({},_0x1a2fbb,_0x558406[_0x355c('0x60')]);return _0x15b9ab[_0x355c('0xda')](_0x1a2fbb);}})['then'](function(_0x1dd85a){if(_0x1dd85a){_0x4ccc31=_0x1dd85a['length'];if(!_0x558406['query'][_0x355c('0xbf')](_0x355c('0xc5'))){_0x1a2fbb[_0x355c('0x34')]=qs[_0x355c('0x34')](_0x558406[_0x355c('0x52')]['limit']);_0x1a2fbb[_0x355c('0x33')]=qs['offset'](_0x558406[_0x355c('0x52')][_0x355c('0x33')]);}return _0x15b9ab['getFaxInteractions'](_0x1a2fbb);}})[_0x355c('0x46')](function(_0x5f59f0){if(_0x5f59f0){return _0x5f59f0?{'count':_0x4ccc31,'rows':_0x5f59f0}:null;}})['then'](respondWithResult(_0x397f90,null))[_0x355c('0x2e')](handleError(_0x397f90,null));};exports[_0x355c('0xdc')]=function(_0x12041a,_0x5a569e,_0x3b21e9){var _0x2d558e;var _0x15a69a;var _0x2f2b2f;var _0x506ff6=!_[_0x355c('0x71')](_0x12041a[_0x355c('0x64')]['id'])?_0x12041a[_0x355c('0x64')]['id']:!_[_0x355c('0x71')](_0x12041a['user']['id'])?_0x12041a[_0x355c('0x3c')]['id']:null;return db['User'][_0x355c('0x43')]({'where':{'id':_0x506ff6,'role':{'$or':['admin','user',_0x355c('0x3d')]}},'attributes':['id','name',_0x355c('0xdd'),_0x355c('0xde'),'role',_0x355c('0x75'),_0x355c('0x9b')]})[_0x355c('0x46')](function(_0x20c2d7){if(_0x20c2d7){if(_0x20c2d7[_0x355c('0x42')]===_0x355c('0x3d')){_0x2d558e=_0x20c2d7;if(_0x12041a[_0x355c('0x67')][_0x355c('0x9d')]){_0x2f2b2f=util[_0x355c('0xaa')](_0x355c('0xdf'),_0x2d558e[_0x12041a[_0x355c('0x67')][_0x355c('0x9d')]]);}else if(_0x12041a[_0x355c('0x67')]['intrf']){_0x2f2b2f=util['format'](_0x355c('0xab'),_0x12041a[_0x355c('0x67')][_0x355c('0xe0')]);}else{_0x2f2b2f=util['format'](_0x355c('0xab'),_0x2d558e[_0x355c('0x44')]);}socket['to'](util[_0x355c('0xaa')](_0x355c('0xe1'),_0x2d558e[_0x355c('0x44')]))[_0x355c('0xa6')](_0x355c('0xe2'),{'ip':_0x12041a[_0x355c('0xe3')]['x-forwarded-for']||_0x12041a['connection'][_0x355c('0xe4')]||_0x12041a['socket']['remoteAddress']||_0x12041a[_0x355c('0xe5')][_0x355c('0xe6')][_0x355c('0xe4')]});return db[_0x355c('0xad')][_0x355c('0x3a')]({'where':{'membername':_0x2d558e[_0x355c('0x44')]},'individualHooks':!![]});}}else{throw new db[(_0x355c('0x23'))][(_0x355c('0x24'))](_0x355c('0xe7'));}})[_0x355c('0x46')](function(){if(_0x2d558e){return _0x2d558e[_0x355c('0xe8')]({'raw':!![]});}})[_0x355c('0x46')](function(_0x5a5c5f){if(_0x2d558e){var _0x57c2f1=[];if(_0x5a5c5f){_0x15a69a=_0x5a5c5f;if(_0x15a69a['length']){for(var _0x2bfb12=0x0;_0x2bfb12<_0x15a69a[_0x355c('0x58')];_0x2bfb12++){_0x57c2f1['push']({'membername':_0x2d558e[_0x355c('0x44')],'UserId':_0x2d558e['id'],'queue_name':_0x15a69a[_0x2bfb12][_0x355c('0x44')],'VoiceQueueId':_0x15a69a[_0x2bfb12]['id'],'interface':_0x2f2b2f,'paused':_0x2d558e[_0x355c('0x9b')]||![],'penalty':_0x15a69a[_0x2bfb12][_0x355c('0xe9')]||0x0});}return BPromise[_0x355c('0xac')](_0x57c2f1,function(_0xe5f5d7){return db['UserVoiceQueueRt'][_0x355c('0xae')](_0xe5f5d7);});}}}})[_0x355c('0x46')](function(){if(_0x2d558e){return db[_0x355c('0xea')][_0x355c('0xd0')]({'where':{'membername':_0x2d558e['name'],'exitAt':null}});}})[_0x355c('0x46')](function(_0x18e66d){if(_0x2d558e){var _0x6351b=[];_0x18e66d[_0x355c('0xeb')](function(_0x23f3b8){_0x6351b[_0x355c('0xec')](_0x23f3b8[_0x355c('0x39')]({'exitAt':moment()[_0x355c('0xaa')](_0x355c('0xed'))}));});return BPromise[_0x355c('0xee')](_0x6351b);}})[_0x355c('0x46')](function(){if(_0x2d558e){var _0x35448a=[];var _0x22bdd6=[];var _0x2f491b=utils[_0x355c('0xef')]();var _0x58223b={'membername':_0x2d558e['name'],'interface':_0x2f2b2f,'enterAt':moment()['format'](_0x355c('0xed')),'role':_0x2d558e[_0x355c('0x42')],'internal':_0x2d558e['internal']};_0x2f491b[_0x355c('0xeb')](function(_0x2f91dd){_0x35448a['push'](_[_0x355c('0x5b')]({'channel':_0x2f91dd,'type':'LOGIN','data1':_0x12041a[_0x355c('0x67')][_0x355c('0xf0')],'data2':_0x2f2b2f},_0x58223b));if(_0x2d558e[_0x355c('0x9b')]){_0x22bdd6[_0x355c('0xec')](_[_0x355c('0x5b')]({'channel':_0x2f91dd,'type':'PAUSE','data1':_0x355c('0xf1')},_0x58223b));}});return db[_0x355c('0xea')]['bulkCreate'](_0x35448a[_0x355c('0xf2')](_0x22bdd6),{'individualHooks':!![]});}})['then'](function(){if(_0x2d558e){return _0x2d558e[_0x355c('0x39')]({'online':!![],'lastLoginAt':moment()[_0x355c('0xaa')](_0x355c('0xed')),'voicePause':_0x2d558e['loginInPause']||![],'mailPause':_0x2d558e[_0x355c('0x9b')]||![],'chatPause':_0x2d558e[_0x355c('0x9b')]||![],'faxPause':_0x2d558e['loginInPause']||![],'smsPause':_0x2d558e['loginInPause']||![],'openchannelPause':_0x2d558e[_0x355c('0x9b')]||![],'pauseType':_0x2d558e[_0x355c('0x9b')]?'LOGININPAUSE':null,'interface':_0x2f2b2f,'lastPauseAt':moment()['format'](_0x355c('0xed'))});}})[_0x355c('0x46')](function(_0x24566d){if(_0x12041a[_0x355c('0xf3')]){return _0x3b21e9();}else{return BPromise[_0x355c('0xf4')](_0x24566d)['then'](respondWithResult(_0x5a569e,null));}})['catch'](handleError(_0x5a569e,null));};exports['logout']=function(_0x278a6e,_0x3d7343,_0xce98c5){var _0x12df76;return db[_0x355c('0x4a')][_0x355c('0x43')]({'where':{'id':_0x278a6e['params']['id'],'role':_0x355c('0x3d')},'attributes':['id',_0x355c('0x44'),_0x355c('0x42')]})['then'](handleEntityNotFound(_0x3d7343,null))[_0x355c('0x46')](function(_0x52f7dd){if(_0x52f7dd){_0x12df76=_0x52f7dd;return db['UserVoiceQueueRt'][_0x355c('0x3a')]({'where':{'membername':_0x12df76[_0x355c('0x44')]},'individualHooks':!![]});}})[_0x355c('0x46')](function(){return db[_0x355c('0xea')][_0x355c('0xd0')]({'where':{'membername':_0x12df76[_0x355c('0x44')],'exitAt':null}});})['then'](function(_0x30b40e){var _0x56f599=[];_0x30b40e[_0x355c('0xeb')](function(_0x4ae565){_0x56f599[_0x355c('0xec')](_0x4ae565[_0x355c('0x39')]({'exitAt':moment()[_0x355c('0xaa')](_0x355c('0xed'))}));});return BPromise[_0x355c('0xee')](_0x56f599);})[_0x355c('0x46')](function(){return _0x12df76[_0x355c('0x39')]({'online':![],'lastLoginAt':null,'voicePause':![],'mailPause':![],'chatPause':![],'faxPause':![],'smsPause':![],'openchannelPause':![],'interface':null});})[_0x355c('0x46')](respondWithResult(_0x3d7343,null))[_0x355c('0x2e')](handleError(_0x3d7343,null));};exports[_0x355c('0xf5')]=function(_0x1596a4,_0x19b750,_0x59ce27){var _0x405077;return db[_0x355c('0xad')][_0x355c('0x39')]({'paused':0x1},{'where':{'UserId':_0x1596a4[_0x355c('0x64')]['id']},'individualHooks':!![]})['then'](function(){return db[_0x355c('0x4a')][_0x355c('0x43')]({'where':{'id':_0x1596a4[_0x355c('0x64')]['id'],'role':_0x355c('0x3d')},'attributes':['id',_0x355c('0x44'),_0x355c('0x42'),_0x355c('0x75'),_0x355c('0x9d')]});})[_0x355c('0x46')](handleEntityNotFound(_0x19b750,null))['then'](function(_0x3ea9ee){if(_0x3ea9ee){_0x405077=_0x3ea9ee;return respondWithRpcPromise(_0x355c('0xf6'),'pause',{'id':_0x405077['id'],'name':_0x405077['name'],'pause':!![]});}})[_0x355c('0x46')](function(){if(_0x405077){return db[_0x355c('0xea')]['findAll']({'where':{'membername':_0x405077[_0x355c('0x44')],'type':_0x355c('0xf7'),'exitAt':null}});}})[_0x355c('0x46')](function(_0x41f7b3){if(_0x41f7b3[_0x355c('0x58')]){var _0x46427b=moment()[_0x355c('0xaa')](_0x355c('0xed'));for(var _0xa29d5a=0x0,_0x32a9ff=_0x41f7b3['length'];_0xa29d5a<_0x32a9ff;_0xa29d5a++){_0x41f7b3[_0xa29d5a][_0x355c('0xf8')]({'exitAt':_0x46427b});}}})['then'](function(){var _0x1de8aa=[];var _0x16ed22=utils[_0x355c('0xef')]();_0x16ed22['forEach'](function(_0xb45789){_0x1de8aa[_0x355c('0xec')]({'channel':_0xb45789,'membername':_0x405077[_0x355c('0x44')],'interface':_[_0x355c('0x71')](_0x405077['interface'])?util[_0x355c('0xaa')]('SIP/%s',_0x405077[_0x355c('0x44')]):_0x405077[_0x355c('0x9d')],'type':_0x355c('0xf7'),'enterAt':moment()[_0x355c('0xaa')]('YYYY-MM-DD\x20HH:mm:ss'),'data1':_0x1596a4[_0x355c('0x67')][_0x355c('0x4d')]||_0x355c('0xf9'),'role':_0x405077[_0x355c('0x42')],'internal':_0x405077[_0x355c('0x75')]});});return db['MemberReport']['bulkCreate'](_0x1de8aa,{'individualHooks':!![]});})[_0x355c('0x46')](function(){return _0x405077[_0x355c('0x39')]({'voicePause':!![],'mailPause':!![],'chatPause':!![],'faxPause':!![],'smsPause':!![],'openchannelPause':!![],'pauseType':_0x1596a4[_0x355c('0x67')][_0x355c('0x4d')]||_0x355c('0xf9'),'lastPauseAt':moment()['format'](_0x355c('0xed'))});})[_0x355c('0x46')](respondWithResult(_0x19b750,null))['catch'](handleError(_0x19b750,null));};exports['unpause']=function(_0x28a0e7,_0x4fc54c,_0x3a252e){var _0x2a662b;return db[_0x355c('0x4a')][_0x355c('0x43')]({'where':{'id':_0x28a0e7[_0x355c('0x64')]['id']},'attributes':['id',_0x355c('0x44'),'role',_0x355c('0x9c'),_0x355c('0xfa'),_0x355c('0xfb'),_0x355c('0xfc'),'openchannelPause',_0x355c('0xfd'),_0x355c('0xfe'),_0x355c('0xff')]})[_0x355c('0x46')](handleEntityNotFound(_0x4fc54c,null))['then'](function(_0x5bca56){if(_0x5bca56){_0x2a662b=_0x5bca56;if(_0x28a0e7[_0x355c('0x67')][_0x355c('0xb0')]&&!utils[_0x355c('0x9e')](_0x28a0e7['body'][_0x355c('0xb0')])){throw new db[(_0x355c('0x23'))][(_0x355c('0x24'))](_0x355c('0x9f'));}switch(_0x28a0e7['body']['channel']){case _0x355c('0xa8'):return respondWithRpcPromise(_0x355c('0xf6'),'unpause',{'id':_0x2a662b['id'],'name':_0x2a662b[_0x355c('0x44')],'pause':![]})[_0x355c('0x46')](function(){return db[_0x355c('0xad')][_0x355c('0x39')]({'paused':0x0},{'where':{'UserId':_0x2a662b['id']},'individualHooks':!![]});})[_0x355c('0x46')](function(){return db[_0x355c('0xea')][_0x355c('0x43')]({'where':{'channel':_0x28a0e7[_0x355c('0x67')][_0x355c('0xb0')],'membername':_0x2a662b[_0x355c('0x44')],'type':'PAUSE','exitAt':null}});})[_0x355c('0x46')](function(_0x41274c){if(_0x41274c){return _0x41274c['update']({'exitAt':moment()['format']('YYYY-MM-DD\x20HH:mm:ss'),'data2':_0x355c('0x100')},{'individualHooks':!![]});}return null;})[_0x355c('0x46')](function(){return _0x2a662b[_0x355c('0x39')]({'voicePause':![]});});case _0x355c('0x101'):case _0x355c('0x102'):case _0x355c('0x103'):case _0x355c('0x104'):case _0x355c('0x105'):return db['MemberReport']['find']({'where':{'channel':_0x28a0e7[_0x355c('0x67')][_0x355c('0xb0')],'membername':_0x2a662b[_0x355c('0x44')],'type':'PAUSE','exitAt':null}})[_0x355c('0x46')](function(_0x4f051e){if(_0x4f051e){return _0x4f051e[_0x355c('0x39')]({'exitAt':moment()[_0x355c('0xaa')]('YYYY-MM-DD\x20HH:mm:ss'),'data2':_0x355c('0x100')},{'individualHooks':!![]});}return null;})[_0x355c('0x46')](function(){var _0x200893={};_[_0x355c('0x106')](_0x200893,util[_0x355c('0xaa')](_0x355c('0x107'),_0x28a0e7[_0x355c('0x67')][_0x355c('0xb0')],_0x355c('0x108')),![]);return _0x2a662b[_0x355c('0x39')](_0x200893);});default:return respondWithRpcPromise(_0x355c('0xf6'),'unpause',{'id':_0x2a662b['id'],'name':_0x2a662b[_0x355c('0x44')],'pause':![]})[_0x355c('0x46')](function(){return db[_0x355c('0xad')][_0x355c('0x39')]({'paused':0x0},{'where':{'UserId':_0x2a662b['id']}});})[_0x355c('0x46')](function(){return db['MemberReport'][_0x355c('0xd0')]({'where':{'membername':_0x2a662b['name'],'type':'PAUSE','exitAt':null}});})[_0x355c('0x46')](function(_0x2d0b9c){var _0x9c762=[];_0x2d0b9c[_0x355c('0xeb')](function(_0x1d24f9){_0x9c762[_0x355c('0xec')](_0x1d24f9[_0x355c('0x39')]({'exitAt':moment()[_0x355c('0xaa')](_0x355c('0xed')),'data2':_0x355c('0x100')}));});return BPromise['all'](_0x9c762);})[_0x355c('0x46')](function(){return _0x2a662b[_0x355c('0x39')]({'voicePause':![],'mailPause':![],'chatPause':![],'faxPause':![],'smsPause':![],'openchannelPause':![]});});}}})[_0x355c('0x46')](respondWithResult(_0x4fc54c,null))[_0x355c('0x2e')](handleError(_0x4fc54c,null));};exports[_0x355c('0x109')]=function(_0x5ef941,_0x3b6112,_0x2f523f){var _0x51b74d={};var _0x24e742={};var _0x52ff83;var _0x2df3e8;return db[_0x355c('0x4a')]['findOne']({'where':{'id':_0x5ef941[_0x355c('0x64')]['id']}})[_0x355c('0x46')](handleEntityNotFound(_0x3b6112,null))[_0x355c('0x46')](function(_0x4e7927){if(_0x4e7927){_0x52ff83=_0x4e7927;_0x24e742['model']=_[_0x355c('0x53')](db['Team'][_0x355c('0x4b')]);_0x24e742[_0x355c('0x52')]=_[_0x355c('0x53')](_0x5ef941['query']);_0x24e742[_0x355c('0x54')]=_['intersection'](_0x24e742[_0x355c('0x4e')],_0x24e742['query']);_0x51b74d['attributes']=_[_0x355c('0x55')](_0x24e742[_0x355c('0x4e')],qs[_0x355c('0x57')](_0x5ef941[_0x355c('0x52')]['fields']));_0x51b74d[_0x355c('0x56')]=_0x51b74d[_0x355c('0x56')]['length']?_0x51b74d[_0x355c('0x56')]:_0x24e742['model'];_0x51b74d[_0x355c('0xbe')]=qs['sort'](_0x5ef941['query'][_0x355c('0x59')]);_0x51b74d[_0x355c('0x5a')]=qs[_0x355c('0x54')](_['pick'](_0x5ef941[_0x355c('0x52')],_0x24e742[_0x355c('0x54')]));if(_0x5ef941[_0x355c('0x52')]['filter']){_0x51b74d['where']=_[_0x355c('0x5b')](_0x51b74d[_0x355c('0x5a')],{'$or':_['map'](_0x51b74d[_0x355c('0x56')],function(_0x13b643){var _0x1fe23c={};_0x1fe23c[_0x13b643]={'$like':'%'+_0x5ef941[_0x355c('0x52')]['filter']+'%'};return _0x1fe23c;})});}_0x51b74d=_['merge']({},_0x51b74d,_0x5ef941[_0x355c('0x60')]);return _0x52ff83[_0x355c('0x109')](_0x51b74d);}})[_0x355c('0x46')](function(_0x22c1ba){if(_0x22c1ba){_0x2df3e8=_0x22c1ba[_0x355c('0x58')];if(!_0x5ef941[_0x355c('0x52')]['hasOwnProperty'](_0x355c('0xc5'))){_0x51b74d[_0x355c('0x34')]=qs[_0x355c('0x34')](_0x5ef941[_0x355c('0x52')][_0x355c('0x34')]);_0x51b74d[_0x355c('0x33')]=qs[_0x355c('0x33')](_0x5ef941[_0x355c('0x52')]['offset']);}return _0x52ff83[_0x355c('0x109')](_0x51b74d);}})[_0x355c('0x46')](function(_0x343ee2){if(_0x343ee2){return _0x343ee2?{'count':_0x2df3e8,'rows':_0x343ee2}:null;}})[_0x355c('0x46')](respondWithResult(_0x3b6112,null))[_0x355c('0x2e')](handleError(_0x3b6112,null));};exports[_0x355c('0x10a')]=function(_0x549f76,_0x551314){return db[_0x355c('0x4a')]['find']({'where':{'id':_0x549f76[_0x355c('0x64')]['id']}})[_0x355c('0x46')](handleEntityNotFound(_0x551314,null))['then'](function(_0x569043){if(_0x569043){var _0x10c7b3=_0x569043[_0x355c('0x3b')]({'plain':!![]});return _0x569043[_0x355c('0x10a')](_0x549f76[_0x355c('0x67')]['ids'],_[_0x355c('0x6b')](_0x549f76[_0x355c('0x67')],['ids','id'])||{})['then'](function(){for(var _0x5138e1=0x0;_0x5138e1<_0x549f76[_0x355c('0x67')][_0x355c('0x6a')][_0x355c('0x58')];_0x5138e1++){var _0x22320b=[];db[_0x355c('0x10b')][_0x355c('0x90')]({'where':{'id':_0x549f76['body'][_0x355c('0x6a')][_0x5138e1]}})['then'](function(_0x23c0d1){_0x22320b[_0x355c('0xec')](_0x23c0d1['getVoiceQueues']()[_0x355c('0x46')](function(_0x4ae23a){for(var _0x25acda=0x0;_0x25acda<_0x4ae23a[_0x355c('0x58')];_0x25acda++){_0x4ae23a[_0x25acda][_0x355c('0x10c')](_0x355c('0xb0'),_0x355c('0x10d'));}return _0x4ae23a;}));_0x22320b[_0x355c('0xec')](_0x23c0d1[_0x355c('0x10e')]()[_0x355c('0x46')](function(_0x244616){for(var _0x13abbb=0x0;_0x13abbb<_0x244616['length'];_0x13abbb++){_0x244616[_0x13abbb][_0x355c('0x10c')]('channel','Chat');}return _0x244616;}));_0x22320b[_0x355c('0xec')](_0x23c0d1['getMailQueues']()[_0x355c('0x46')](function(_0x1a610a){for(var _0x27298d=0x0;_0x27298d<_0x1a610a['length'];_0x27298d++){_0x1a610a[_0x27298d][_0x355c('0x10c')](_0x355c('0xb0'),'Mail');}return _0x1a610a;}));_0x22320b[_0x355c('0xec')](_0x23c0d1[_0x355c('0x10f')]()['then'](function(_0x5d1158){for(var _0x1b0b83=0x0;_0x1b0b83<_0x5d1158[_0x355c('0x58')];_0x1b0b83++){_0x5d1158[_0x1b0b83][_0x355c('0x10c')](_0x355c('0xb0'),_0x355c('0x110'));}return _0x5d1158;}));_0x22320b[_0x355c('0xec')](_0x23c0d1[_0x355c('0x111')]()[_0x355c('0x46')](function(_0x5b4459){for(var _0x52fd98=0x0;_0x52fd98<_0x5b4459[_0x355c('0x58')];_0x52fd98++){_0x5b4459[_0x52fd98][_0x355c('0x10c')](_0x355c('0xb0'),'Fax');}return _0x5b4459;}));_0x22320b[_0x355c('0xec')](_0x23c0d1[_0x355c('0x112')]()[_0x355c('0x46')](function(_0x5722aa){for(var _0x332bff=0x0;_0x332bff<_0x5722aa[_0x355c('0x58')];_0x332bff++){_0x5722aa[_0x332bff][_0x355c('0x10c')]('channel',_0x355c('0x113'));}return _0x5722aa;}));return BPromise[_0x355c('0xee')](_0x22320b);})[_0x355c('0x46')](function(_0x17ab6d){var _0x5ae30a=_[_0x355c('0x114')](_0x17ab6d);_0x22320b=[];return db[_0x355c('0x5d')]['transaction'](function(_0x7fee71){for(var _0x2b436e=0x0;_0x2b436e<_0x5ae30a['length'];_0x2b436e++){_0x22320b[_0x355c('0xec')](_0x5ae30a[_0x2b436e]['addAgent'](_0x10c7b3['id']),{'transaction':_0x7fee71});}return BPromise[_0x355c('0xee')](_0x22320b)[_0x355c('0x46')](function(){if(_0x10c7b3[_0x355c('0x9a')]){return BPromise[_0x355c('0xac')](_[_0x355c('0x40')](_0x5ae30a,function(_0x4ac5a5){return _0x4ac5a5[_0x355c('0x115')](_0x355c('0xb0'))===_0x355c('0x10d');}),function(_0xf57f4a){return db[_0x355c('0xad')][_0x355c('0xae')]({'membername':_0x10c7b3[_0x355c('0x44')],'UserId':_0x10c7b3['id'],'queue_name':_0xf57f4a[_0x355c('0x44')],'VoiceQueueId':_0xf57f4a['id'],'interface':_[_0x355c('0x71')](_0x10c7b3[_0x355c('0x9d')])?util[_0x355c('0xaa')](_0x355c('0xab'),_0x10c7b3[_0x355c('0x44')]):_0x10c7b3[_0x355c('0x9d')],'paused':_0x10c7b3['voicePause']||![],'penalty':_0x10c7b3[_0x355c('0xa4')]},{'transaction':_0x7fee71});});}else{return;}})[_0x355c('0x46')](function(){for(var _0x310b08=0x0;_0x310b08<_0x5ae30a[_0x355c('0x58')];_0x310b08++){var _0x461583=_0x5ae30a[_0x310b08]['getDataValue'](_0x355c('0xb0'));var _0x591afa=_0x461583+_0x355c('0xa5');socket[_0x355c('0xa6')](_0x355c('0x3c')+_0x461583+_0x355c('0xa7'),{'UserId':_0x10c7b3['id'],['queueField']:_0x5ae30a[_0x310b08]['id']});}});});});}});}})[_0x355c('0x46')](respondWithStatusCode(_0x551314,null))[_0x355c('0x2e')](handleError(_0x551314,null));};exports[_0x355c('0x116')]=function(_0x50a0bf,_0x171aa7){return db[_0x355c('0x4a')][_0x355c('0x90')]({'where':{'id':_0x50a0bf[_0x355c('0x64')]['id']}})[_0x355c('0x46')](handleEntityNotFound(_0x171aa7,null))[_0x355c('0x46')](function(_0x3b71ea){if(_0x3b71ea){var _0xfdf801=_0x3b71ea['get']({'plain':!![]});var _0x31dec2=_0x50a0bf['query'][_0x355c('0x6a')];return _0x3b71ea[_0x355c('0x116')](_0x31dec2)[_0x355c('0x46')](function(){for(var _0x54fe97=0x0;_0x54fe97<_0x31dec2[_0x355c('0x58')];_0x54fe97++){var _0x123f9c=[];db['Team'][_0x355c('0x90')]({'where':{'id':_0x31dec2[_0x54fe97]}})['then'](function(_0x4aed55){_0x123f9c[_0x355c('0xec')](_0x4aed55[_0x355c('0xe8')]()[_0x355c('0x46')](function(_0x4beb52){for(var _0x1000da=0x0;_0x1000da<_0x4beb52[_0x355c('0x58')];_0x1000da++){_0x4beb52[_0x1000da]['setDataValue']('channel','Voice');}return _0x4beb52;}));_0x123f9c[_0x355c('0xec')](_0x4aed55[_0x355c('0x10e')]()[_0x355c('0x46')](function(_0x409ec3){for(var _0x5553eb=0x0;_0x5553eb<_0x409ec3['length'];_0x5553eb++){_0x409ec3[_0x5553eb][_0x355c('0x10c')](_0x355c('0xb0'),_0x355c('0x117'));}return _0x409ec3;}));_0x123f9c['push'](_0x4aed55[_0x355c('0x118')]()['then'](function(_0x33dc01){for(var _0x20aee7=0x0;_0x20aee7<_0x33dc01[_0x355c('0x58')];_0x20aee7++){_0x33dc01[_0x20aee7][_0x355c('0x10c')](_0x355c('0xb0'),'Mail');}return _0x33dc01;}));_0x123f9c[_0x355c('0xec')](_0x4aed55[_0x355c('0x10f')]()[_0x355c('0x46')](function(_0x331e57){for(var _0x34c12e=0x0;_0x34c12e<_0x331e57[_0x355c('0x58')];_0x34c12e++){_0x331e57[_0x34c12e][_0x355c('0x10c')](_0x355c('0xb0'),_0x355c('0x110'));}return _0x331e57;}));_0x123f9c[_0x355c('0xec')](_0x4aed55[_0x355c('0x111')]()['then'](function(_0x1c5045){for(var _0x190102=0x0;_0x190102<_0x1c5045['length'];_0x190102++){_0x1c5045[_0x190102][_0x355c('0x10c')](_0x355c('0xb0'),'Fax');}return _0x1c5045;}));_0x123f9c[_0x355c('0xec')](_0x4aed55[_0x355c('0x112')]()[_0x355c('0x46')](function(_0x41c07a){for(var _0x19095b=0x0;_0x19095b<_0x41c07a['length'];_0x19095b++){_0x41c07a[_0x19095b][_0x355c('0x10c')](_0x355c('0xb0'),_0x355c('0x113'));}return _0x41c07a;}));return BPromise[_0x355c('0xee')](_0x123f9c);})[_0x355c('0x46')](function(_0x28b256){var _0x49227c=_[_0x355c('0x114')](_0x28b256);_0x123f9c=[];return db[_0x355c('0x5d')][_0x355c('0x119')](function(_0x26c234){for(var _0x1ee98c=0x0;_0x1ee98c<_0x49227c[_0x355c('0x58')];_0x1ee98c++){_0x123f9c[_0x355c('0xec')](_0x49227c[_0x1ee98c]['removeAgent'](_0xfdf801['id']),{'transaction':_0x26c234});}return BPromise[_0x355c('0xee')](_0x123f9c)[_0x355c('0x46')](function(){if(_0xfdf801[_0x355c('0x9a')]){return BPromise['each'](_[_0x355c('0x40')](_0x49227c,function(_0x3ae461){return _0x3ae461[_0x355c('0x115')](_0x355c('0xb0'))===_0x355c('0x10d');}),function(_0x2aab9f){return db[_0x355c('0xad')][_0x355c('0x3a')]({'where':{'VoiceQueueId':_0x2aab9f['id'],'UserId':_0xfdf801['id']},'transaction':_0x26c234});});}else{return;}})[_0x355c('0x46')](function(){for(var _0x3c24d7=0x0;_0x3c24d7<_0x49227c[_0x355c('0x58')];_0x3c24d7++){var _0x25b6ad=_0x49227c[_0x3c24d7]['getDataValue'](_0x355c('0xb0'));var _0x340dd8=_0x25b6ad+_0x355c('0xa5');socket[_0x355c('0xa6')](_0x355c('0x3c')+_0x25b6ad+_0x355c('0x11a'),{'UserId':_0xfdf801['id'],['queueField']:_0x49227c[_0x3c24d7]['id']});}});});});}});}})[_0x355c('0x46')](respondWithStatusCode(_0x171aa7,null))['catch'](handleError(_0x171aa7,null));};exports[_0x355c('0x11b')]=function(_0x4d4b0c,_0x3a9ab9,_0x1b89d3){var _0x3a896c={};var _0x5a3a3c={};var _0x570f05;var _0x5bf965;return db[_0x355c('0x4a')][_0x355c('0x90')]({'where':{'id':_0x4d4b0c[_0x355c('0x64')]['id']}})[_0x355c('0x46')](handleEntityNotFound(_0x3a9ab9,null))[_0x355c('0x46')](function(_0x49d5bb){if(_0x49d5bb){_0x570f05=_0x49d5bb;_0x5a3a3c[_0x355c('0x4e')]=_['keys'](db['CmList'][_0x355c('0x4b')]);_0x5a3a3c[_0x355c('0x52')]=_[_0x355c('0x53')](_0x4d4b0c['query']);_0x5a3a3c[_0x355c('0x54')]=_[_0x355c('0x55')](_0x5a3a3c[_0x355c('0x4e')],_0x5a3a3c[_0x355c('0x52')]);_0x3a896c['attributes']=_[_0x355c('0x55')](_0x5a3a3c['model'],qs['fields'](_0x4d4b0c[_0x355c('0x52')]['fields']));_0x3a896c[_0x355c('0x56')]=_0x3a896c['attributes']['length']?_0x3a896c['attributes']:_0x5a3a3c['model'];_0x3a896c['order']=qs[_0x355c('0x59')](_0x4d4b0c['query'][_0x355c('0x59')]);_0x3a896c['where']=qs[_0x355c('0x54')](_[_0x355c('0xc8')](_0x4d4b0c[_0x355c('0x52')],_0x5a3a3c[_0x355c('0x54')]));if(_0x4d4b0c[_0x355c('0x52')][_0x355c('0x40')]){_0x3a896c[_0x355c('0x5a')]=_[_0x355c('0x5b')](_0x3a896c[_0x355c('0x5a')],{'$or':_[_0x355c('0x49')](_0x3a896c['attributes'],function(_0xfa4aa0){var _0x5ec892={};_0x5ec892[_0xfa4aa0]={'$like':'%'+_0x4d4b0c[_0x355c('0x52')][_0x355c('0x40')]+'%'};return _0x5ec892;})});}_0x3a896c=_[_0x355c('0x5b')]({},_0x3a896c,_0x4d4b0c[_0x355c('0x60')]);return _0x570f05[_0x355c('0x11b')](_0x3a896c);}})['then'](function(_0x73aac7){if(_0x73aac7){_0x5bf965=_0x73aac7['length'];if(!_0x4d4b0c[_0x355c('0x52')][_0x355c('0xbf')](_0x355c('0xc5'))){_0x3a896c[_0x355c('0x34')]=qs[_0x355c('0x34')](_0x4d4b0c['query'][_0x355c('0x34')]);_0x3a896c[_0x355c('0x33')]=qs['offset'](_0x4d4b0c[_0x355c('0x52')][_0x355c('0x33')]);}return _0x570f05[_0x355c('0x11b')](_0x3a896c);}})[_0x355c('0x46')](function(_0x1b863a){if(_0x1b863a){return _0x1b863a?{'count':_0x5bf965,'rows':_0x1b863a}:null;}})['then'](respondWithResult(_0x3a9ab9,null))[_0x355c('0x2e')](handleError(_0x3a9ab9,null));};exports[_0x355c('0x11c')]=function(_0x40c2bf,_0x910c67,_0x230a2f){var _0x3dda85={};var _0x257ac5={};var _0x5752dc;var _0x4cda7a;return db[_0x355c('0x4a')][_0x355c('0x90')]({'where':{'id':_0x40c2bf[_0x355c('0x64')]['id']}})[_0x355c('0x46')](handleEntityNotFound(_0x910c67,null))[_0x355c('0x46')](function(_0x23a121){if(_0x23a121){_0x5752dc=_0x23a121;_0x257ac5['model']=_['keys'](db[_0x355c('0x4a')][_0x355c('0x4b')]);_0x257ac5[_0x355c('0x52')]=_[_0x355c('0x53')](_0x40c2bf[_0x355c('0x52')]);_0x257ac5[_0x355c('0x54')]=_[_0x355c('0x55')](_0x257ac5[_0x355c('0x4e')],_0x257ac5[_0x355c('0x52')]);_0x3dda85['attributes']=_[_0x355c('0x55')](_0x257ac5[_0x355c('0x4e')],qs[_0x355c('0x57')](_0x40c2bf[_0x355c('0x52')][_0x355c('0x57')]));_0x3dda85[_0x355c('0x56')]=_0x3dda85[_0x355c('0x56')]['length']?_0x3dda85['attributes']:_0x257ac5[_0x355c('0x4e')];_0x3dda85[_0x355c('0xbe')]=qs[_0x355c('0x59')](_0x40c2bf[_0x355c('0x52')][_0x355c('0x59')]);_0x3dda85[_0x355c('0x5a')]=qs[_0x355c('0x54')](_[_0x355c('0xc8')](_0x40c2bf['query'],_0x257ac5[_0x355c('0x54')]));if(_0x40c2bf['query'][_0x355c('0x40')]){_0x3dda85[_0x355c('0x5a')]=_['merge'](_0x3dda85['where'],{'$or':_[_0x355c('0x49')](_0x3dda85[_0x355c('0x56')],function(_0x377391){var _0x5466cc={};_0x5466cc[_0x377391]={'$like':'%'+_0x40c2bf[_0x355c('0x52')][_0x355c('0x40')]+'%'};return _0x5466cc;})});}_0x3dda85[_0x355c('0x4e')]=db[_0x355c('0x4a')];_0x3dda85['as']=_0x355c('0x8a');_0x3dda85=_[_0x355c('0x5b')]({},_0x3dda85,_0x40c2bf[_0x355c('0x60')]);return _0x5752dc[_0x355c('0xe8')]({'include':[_0x3dda85]});}})['then'](function(_0x24098c){if(_0x24098c){var _0x509dd7={},_0x361be4=[],_0x2e72a0=0x0;for(var _0x5a7e3f=0x0;_0x5a7e3f<_0x24098c['length'];_0x5a7e3f+=0x1){for(var _0x24ffc8=0x0,_0x5b42e5;_0x24ffc8<_0x24098c[_0x5a7e3f][_0x355c('0x8a')][_0x355c('0x58')];_0x24ffc8+=0x1){_0x5b42e5=_0x24098c[_0x5a7e3f][_0x355c('0x8a')][_0x24ffc8]['get']({'plain':!![]});_0x509dd7[_0x5b42e5['id']]=_0x5b42e5;}}_0x509dd7=_[_0x355c('0x11d')](_0x509dd7);for(var _0xe8ebf3=qs['offset'](_0x40c2bf['query']['offset']);_0xe8ebf3<_0x509dd7[_0x355c('0x58')]&&_0x361be4[_0x355c('0x58')]<qs[_0x355c('0x34')](_0x40c2bf[_0x355c('0x52')][_0x355c('0x34')]);_0xe8ebf3+=0x1){if(_0x509dd7[_0xe8ebf3]){_0x361be4[_0x355c('0xec')](_0x509dd7[_0xe8ebf3]);}}return{'count':_0x509dd7[_0x355c('0x58')],'rows':_0x361be4};}})[_0x355c('0x46')](respondWithResult(_0x910c67,null))['catch'](handleError(_0x910c67,null));};exports[_0x355c('0x3a')]=function(_0xfb3025,_0x256ada){if(_0xfb3025[_0x355c('0x3c')]['id']==_0xfb3025[_0x355c('0x64')]['id']){return _0x256ada[_0x355c('0x30')](0x1f4)[_0x355c('0x47')]({'message':'You\x20can\x27t\x20delete\x20yourself'});}return db['User'][_0x355c('0x43')]({'where':{'id':_0xfb3025[_0x355c('0x64')]['id']}})['then'](handleEntityNotFound(_0x256ada,null))[_0x355c('0x46')](removeEntity(_0x256ada,null))[_0x355c('0x2e')](handleError(_0x256ada,null));};exports[_0x355c('0x11e')]=function(_0x348425,_0x5391a4,_0x3deda6){return db[_0x355c('0x4a')][_0x355c('0x43')]({'where':{'id':_0x348425[_0x355c('0x64')]['id']}})[_0x355c('0x46')](handleEntityNotFound(_0x5391a4,null))['then'](function(_0x373d9e){if(_0x373d9e){return _0x373d9e[_0x355c('0x11e')](_0x348425[_0x355c('0x67')][_0x355c('0x6a')],_[_0x355c('0x6b')](_0x348425['body'],['ids','id'])||{})['spread'](function(){for(var _0x34f730=0x0;_0x34f730<_0x348425[_0x355c('0x67')][_0x355c('0x6a')][_0x355c('0x58')];_0x34f730+=0x1){socket[_0x355c('0xa6')]('user_has_chat_interactions:save',{'ChatInteractionId':Number(_0x348425['body']['ids'][_0x34f730]),'UserId':Number(_0x348425['params']['id'])});}return _0x348425['body'][_0x355c('0x6a')];});}})[_0x355c('0x46')](respondWithResult(_0x5391a4,null))['catch'](handleError(_0x5391a4,null));};exports['removeChatInteractions']=function(_0x1c6c30,_0x46c860,_0x2de509){return db[_0x355c('0x4a')]['find']({'where':{'id':_0x1c6c30['params']['id']}})[_0x355c('0x46')](handleEntityNotFound(_0x46c860,null))[_0x355c('0x46')](function(_0x3965f1){if(_0x3965f1){return _0x3965f1[_0x355c('0x11f')](_0x1c6c30['query'][_0x355c('0x6a')])[_0x355c('0x46')](function(){if(_[_0x355c('0x120')](_0x1c6c30[_0x355c('0x52')][_0x355c('0x6a')])){for(var _0x423e67=0x0;_0x423e67<_0x1c6c30[_0x355c('0x52')][_0x355c('0x6a')][_0x355c('0x58')];_0x423e67+=0x1){socket['emit'](_0x355c('0x121'),{'ChatInteractionId':Number(_0x1c6c30['query'][_0x355c('0x6a')][_0x423e67]),'UserId':Number(_0x1c6c30[_0x355c('0x64')]['id'])});}}else{socket[_0x355c('0xa6')](_0x355c('0x121'),{'ChatInteractionId':Number(_0x1c6c30[_0x355c('0x52')][_0x355c('0x6a')]),'UserId':Number(_0x1c6c30[_0x355c('0x64')]['id'])});}});}})['then'](respondWithStatusCode(_0x46c860,null))[_0x355c('0x2e')](handleError(_0x46c860,null));};exports[_0x355c('0x122')]=function(_0xad417,_0x39cbb8,_0x2be473){return db[_0x355c('0x4a')]['find']({'where':{'id':_0xad417['params']['id']}})[_0x355c('0x46')](handleEntityNotFound(_0x39cbb8,null))[_0x355c('0x46')](function(_0x45c86e){if(_0x45c86e){return _0x45c86e[_0x355c('0x122')](_0xad417[_0x355c('0x67')]['ids'],_['omit'](_0xad417['body'],['ids','id'])||{})[_0x355c('0x123')](function(){for(var _0x11a955=0x0;_0x11a955<_0xad417[_0x355c('0x67')][_0x355c('0x6a')][_0x355c('0x58')];_0x11a955+=0x1){socket[_0x355c('0xa6')](_0x355c('0x124'),{'MailInteractionId':Number(_0xad417[_0x355c('0x67')]['ids'][_0x11a955]),'UserId':Number(_0xad417['params']['id'])});}return _0xad417['body'][_0x355c('0x6a')];});}})[_0x355c('0x46')](respondWithResult(_0x39cbb8,null))[_0x355c('0x2e')](handleError(_0x39cbb8,null));};exports['removeMailInteractions']=function(_0x3b05d1,_0x161cc6,_0xa6dc2d){return db[_0x355c('0x4a')][_0x355c('0x43')]({'where':{'id':_0x3b05d1[_0x355c('0x64')]['id']}})[_0x355c('0x46')](handleEntityNotFound(_0x161cc6,null))[_0x355c('0x46')](function(_0x3132d9){if(_0x3132d9){return _0x3132d9[_0x355c('0x125')](_0x3b05d1['query']['ids'])[_0x355c('0x46')](function(){if(_[_0x355c('0x120')](_0x3b05d1[_0x355c('0x52')][_0x355c('0x6a')])){for(var _0x5f1170=0x0;_0x5f1170<_0x3b05d1[_0x355c('0x52')][_0x355c('0x6a')][_0x355c('0x58')];_0x5f1170+=0x1){socket[_0x355c('0xa6')](_0x355c('0x126'),{'MailInteractionId':Number(_0x3b05d1[_0x355c('0x52')]['ids'][_0x5f1170]),'UserId':Number(_0x3b05d1[_0x355c('0x64')]['id'])});}}else{socket['emit'](_0x355c('0x126'),{'MailInteractionId':Number(_0x3b05d1[_0x355c('0x52')]['ids']),'UserId':Number(_0x3b05d1[_0x355c('0x64')]['id'])});}});}})[_0x355c('0x46')](respondWithStatusCode(_0x161cc6,null))[_0x355c('0x2e')](handleError(_0x161cc6,null));};exports['addFaxInteractions']=function(_0x4cc5ef,_0x9a3c90,_0x1a7aaa){return db['User'][_0x355c('0x43')]({'where':{'id':_0x4cc5ef['params']['id']}})['then'](handleEntityNotFound(_0x9a3c90,null))[_0x355c('0x46')](function(_0x8e96d0){if(_0x8e96d0){return _0x8e96d0[_0x355c('0x127')](_0x4cc5ef['body']['ids'],_[_0x355c('0x6b')](_0x4cc5ef['body'],[_0x355c('0x6a'),'id'])||{})[_0x355c('0x123')](function(){for(var _0x38ef2a=0x0;_0x38ef2a<_0x4cc5ef['body'][_0x355c('0x6a')][_0x355c('0x58')];_0x38ef2a+=0x1){socket[_0x355c('0xa6')]('user_has_fax_interactions:save',{'FaxInteractionId':Number(_0x4cc5ef[_0x355c('0x67')][_0x355c('0x6a')][_0x38ef2a]),'UserId':Number(_0x4cc5ef['params']['id'])});}return _0x4cc5ef[_0x355c('0x67')][_0x355c('0x6a')];});}})[_0x355c('0x46')](respondWithResult(_0x9a3c90,null))['catch'](handleError(_0x9a3c90,null));};exports[_0x355c('0x128')]=function(_0xbe3516,_0x2cad8d,_0x1bfc3){return db['User'][_0x355c('0x43')]({'where':{'id':_0xbe3516[_0x355c('0x64')]['id']}})[_0x355c('0x46')](handleEntityNotFound(_0x2cad8d,null))['then'](function(_0x2704f6){if(_0x2704f6){return _0x2704f6['removeFaxInteractions'](_0xbe3516['query'][_0x355c('0x6a')])['then'](function(){if(_['isArray'](_0xbe3516[_0x355c('0x52')][_0x355c('0x6a')])){for(var _0x2fa822=0x0;_0x2fa822<_0xbe3516[_0x355c('0x52')][_0x355c('0x6a')][_0x355c('0x58')];_0x2fa822+=0x1){socket['emit'](_0x355c('0x129'),{'FaxInteractionId':Number(_0xbe3516['query'][_0x355c('0x6a')][_0x2fa822]),'UserId':Number(_0xbe3516['params']['id'])});}}else{socket['emit'](_0x355c('0x129'),{'FaxInteractionId':Number(_0xbe3516[_0x355c('0x52')][_0x355c('0x6a')]),'UserId':Number(_0xbe3516['params']['id'])});}});}})['then'](respondWithStatusCode(_0x2cad8d,null))[_0x355c('0x2e')](handleError(_0x2cad8d,null));};exports['addSmsInteractions']=function(_0x4ef899,_0x33ce40,_0x2eee4f){return db['User'][_0x355c('0x43')]({'where':{'id':_0x4ef899['params']['id']}})[_0x355c('0x46')](handleEntityNotFound(_0x33ce40,null))['then'](function(_0x57ba5b){if(_0x57ba5b){return _0x57ba5b[_0x355c('0x12a')](_0x4ef899[_0x355c('0x67')][_0x355c('0x6a')],_[_0x355c('0x6b')](_0x4ef899[_0x355c('0x67')],['ids','id'])||{})[_0x355c('0x123')](function(){for(var _0x3476b4=0x0;_0x3476b4<_0x4ef899[_0x355c('0x67')][_0x355c('0x6a')][_0x355c('0x58')];_0x3476b4+=0x1){socket['emit'](_0x355c('0x12b'),{'SmsInteractionId':Number(_0x4ef899[_0x355c('0x67')][_0x355c('0x6a')][_0x3476b4]),'UserId':Number(_0x4ef899[_0x355c('0x64')]['id'])});}return _0x4ef899[_0x355c('0x67')][_0x355c('0x6a')];});}})[_0x355c('0x46')](respondWithResult(_0x33ce40,null))[_0x355c('0x2e')](handleError(_0x33ce40,null));};exports[_0x355c('0x12c')]=function(_0x1bfd59,_0x1f5947,_0x50f8ae){return db[_0x355c('0x4a')]['find']({'where':{'id':_0x1bfd59['params']['id']}})[_0x355c('0x46')](handleEntityNotFound(_0x1f5947,null))[_0x355c('0x46')](function(_0x1ee74c){if(_0x1ee74c){return _0x1ee74c[_0x355c('0x12c')](_0x1bfd59[_0x355c('0x52')]['ids'])[_0x355c('0x46')](function(){if(_[_0x355c('0x120')](_0x1bfd59[_0x355c('0x52')]['ids'])){for(var _0x47edbe=0x0;_0x47edbe<_0x1bfd59['query']['ids'][_0x355c('0x58')];_0x47edbe+=0x1){socket[_0x355c('0xa6')](_0x355c('0x12d'),{'SmsInteractionId':Number(_0x1bfd59[_0x355c('0x52')][_0x355c('0x6a')][_0x47edbe]),'UserId':Number(_0x1bfd59[_0x355c('0x64')]['id'])});}}else{socket[_0x355c('0xa6')](_0x355c('0x12d'),{'SmsInteractionId':Number(_0x1bfd59[_0x355c('0x52')][_0x355c('0x6a')]),'UserId':Number(_0x1bfd59[_0x355c('0x64')]['id'])});}});}})[_0x355c('0x46')](respondWithStatusCode(_0x1f5947,null))[_0x355c('0x2e')](handleError(_0x1f5947,null));};exports[_0x355c('0x12e')]=function(_0x23dde6,_0x3746ea,_0x2c56dc){return db[_0x355c('0x4a')][_0x355c('0x43')]({'where':{'id':_0x23dde6[_0x355c('0x64')]['id']}})[_0x355c('0x46')](handleEntityNotFound(_0x3746ea,null))[_0x355c('0x46')](function(_0x412865){if(_0x412865){return _0x412865[_0x355c('0x12e')](_0x23dde6[_0x355c('0x67')][_0x355c('0x6a')],_[_0x355c('0x6b')](_0x23dde6[_0x355c('0x67')],[_0x355c('0x6a'),'id'])||{})[_0x355c('0x123')](function(){for(var _0x13163d=0x0;_0x13163d<_0x23dde6[_0x355c('0x67')][_0x355c('0x6a')][_0x355c('0x58')];_0x13163d+=0x1){socket['emit'](_0x355c('0x12f'),{'OpenchannelInteractionId':Number(_0x23dde6[_0x355c('0x67')]['ids'][_0x13163d]),'UserId':Number(_0x23dde6[_0x355c('0x64')]['id'])});}return _0x23dde6[_0x355c('0x67')]['ids'];});}})[_0x355c('0x46')](respondWithResult(_0x3746ea,null))[_0x355c('0x2e')](handleError(_0x3746ea,null));};exports['removeOpenchannelInteractions']=function(_0x5c9d7e,_0x2aff6d,_0x43b621){return db['User'][_0x355c('0x43')]({'where':{'id':_0x5c9d7e[_0x355c('0x64')]['id']}})[_0x355c('0x46')](handleEntityNotFound(_0x2aff6d,null))['then'](function(_0xac1ee){if(_0xac1ee){return _0xac1ee[_0x355c('0x130')](_0x5c9d7e[_0x355c('0x52')][_0x355c('0x6a')])[_0x355c('0x46')](function(){if(_[_0x355c('0x120')](_0x5c9d7e[_0x355c('0x52')][_0x355c('0x6a')])){for(var _0x9786dd=0x0;_0x9786dd<_0x5c9d7e[_0x355c('0x52')][_0x355c('0x6a')]['length'];_0x9786dd+=0x1){socket['emit']('user_has_openchannel_interactions:remove',{'OpenchannelInteractionId':Number(_0x5c9d7e[_0x355c('0x52')][_0x355c('0x6a')][_0x9786dd]),'UserId':Number(_0x5c9d7e['params']['id'])});}}else{socket[_0x355c('0xa6')](_0x355c('0x131'),{'OpenchannelInteractionId':Number(_0x5c9d7e[_0x355c('0x52')][_0x355c('0x6a')]),'UserId':Number(_0x5c9d7e[_0x355c('0x64')]['id'])});}});}})[_0x355c('0x46')](respondWithStatusCode(_0x2aff6d,null))['catch'](handleError(_0x2aff6d,null));};exports[_0x355c('0x132')]=function(_0x1006aa,_0xbc0a8a,_0x1d1daf){var _0x4b5880={};var _0x1c688b={};var _0x3cd884;var _0x5d00ba;return db[_0x355c('0x4a')][_0x355c('0x90')]({'where':{'id':_0x1006aa[_0x355c('0x64')]['id']}})[_0x355c('0x46')](handleEntityNotFound(_0xbc0a8a,null))[_0x355c('0x46')](function(_0x3b4fd5){if(_0x3b4fd5){_0x3cd884=_0x3b4fd5;_0x1c688b[_0x355c('0x4e')]=_[_0x355c('0x53')](db[_0x355c('0x133')][_0x355c('0x4b')]);_0x1c688b['query']=_[_0x355c('0x53')](_0x1006aa[_0x355c('0x52')]);_0x1c688b[_0x355c('0x54')]=_[_0x355c('0x55')](_0x1c688b[_0x355c('0x4e')],_0x1c688b[_0x355c('0x52')]);_0x4b5880[_0x355c('0x56')]=_[_0x355c('0x55')](_0x1c688b['model'],qs[_0x355c('0x57')](_0x1006aa['query'][_0x355c('0x57')]));_0x4b5880[_0x355c('0x56')]=_0x4b5880[_0x355c('0x56')][_0x355c('0x58')]?_0x4b5880[_0x355c('0x56')]:_0x1c688b[_0x355c('0x4e')];_0x4b5880[_0x355c('0xbe')]=qs[_0x355c('0x59')](_0x1006aa[_0x355c('0x52')]['sort']);_0x4b5880[_0x355c('0x5a')]=qs['filters'](_[_0x355c('0xc8')](_0x1006aa['query'],_0x1c688b[_0x355c('0x54')]));if(_0x1006aa[_0x355c('0x52')][_0x355c('0x40')]){_0x4b5880[_0x355c('0x5a')]=_[_0x355c('0x5b')](_0x4b5880['where'],{'$or':_['map'](_0x4b5880[_0x355c('0x56')],function(_0x4afbe5){var _0x2faf8b={};_0x2faf8b[_0x4afbe5]={'$like':'%'+_0x1006aa[_0x355c('0x52')][_0x355c('0x40')]+'%'};return _0x2faf8b;})});}_0x4b5880=_['merge']({},_0x4b5880,_0x1006aa['options']);return _0x3cd884[_0x355c('0x132')](_0x4b5880);}})[_0x355c('0x46')](function(_0x51a19f){if(_0x51a19f){_0x5d00ba=_0x51a19f['length'];if(!_0x1006aa[_0x355c('0x52')][_0x355c('0xbf')](_0x355c('0xc5'))){_0x4b5880[_0x355c('0x34')]=qs[_0x355c('0x34')](_0x1006aa[_0x355c('0x52')][_0x355c('0x34')]);_0x4b5880[_0x355c('0x33')]=qs['offset'](_0x1006aa[_0x355c('0x52')][_0x355c('0x33')]);}return _0x3cd884[_0x355c('0x132')](_0x4b5880);}})[_0x355c('0x46')](function(_0x1f891f){if(_0x1f891f){return _0x1f891f?{'count':_0x5d00ba,'rows':_0x1f891f}:null;}})[_0x355c('0x46')](respondWithResult(_0xbc0a8a,null))[_0x355c('0x2e')](handleError(_0xbc0a8a,null));};exports['getFaxAccounts']=function(_0x2f1832,_0x4d9b43,_0x447aaa){var _0x4996e7={};var _0x38a426={};var _0x1edd87;var _0x140a0c;return db['User'][_0x355c('0x90')]({'where':{'id':_0x2f1832[_0x355c('0x64')]['id']}})[_0x355c('0x46')](handleEntityNotFound(_0x4d9b43,null))[_0x355c('0x46')](function(_0x1390f0){if(_0x1390f0){_0x1edd87=_0x1390f0;_0x38a426[_0x355c('0x4e')]=_[_0x355c('0x53')](db[_0x355c('0x134')][_0x355c('0x4b')]);_0x38a426[_0x355c('0x52')]=_[_0x355c('0x53')](_0x2f1832['query']);_0x38a426[_0x355c('0x54')]=_[_0x355c('0x55')](_0x38a426[_0x355c('0x4e')],_0x38a426[_0x355c('0x52')]);_0x4996e7[_0x355c('0x56')]=_[_0x355c('0x55')](_0x38a426[_0x355c('0x4e')],qs['fields'](_0x2f1832[_0x355c('0x52')][_0x355c('0x57')]));_0x4996e7[_0x355c('0x56')]=_0x4996e7[_0x355c('0x56')][_0x355c('0x58')]?_0x4996e7[_0x355c('0x56')]:_0x38a426[_0x355c('0x4e')];_0x4996e7[_0x355c('0xbe')]=qs[_0x355c('0x59')](_0x2f1832['query'][_0x355c('0x59')]);_0x4996e7['where']=qs[_0x355c('0x54')](_['pick'](_0x2f1832['query'],_0x38a426['filters']));if(_0x2f1832[_0x355c('0x52')][_0x355c('0x40')]){_0x4996e7[_0x355c('0x5a')]=_[_0x355c('0x5b')](_0x4996e7['where'],{'$or':_['map'](_0x4996e7[_0x355c('0x56')],function(_0x591ade){var _0x1c7dc0={};_0x1c7dc0[_0x591ade]={'$like':'%'+_0x2f1832[_0x355c('0x52')]['filter']+'%'};return _0x1c7dc0;})});}_0x4996e7=_[_0x355c('0x5b')]({},_0x4996e7,_0x2f1832[_0x355c('0x60')]);return _0x1edd87[_0x355c('0x135')](_0x4996e7);}})[_0x355c('0x46')](function(_0x62ed19){if(_0x62ed19){_0x140a0c=_0x62ed19[_0x355c('0x58')];if(!_0x2f1832[_0x355c('0x52')][_0x355c('0xbf')]('nolimit')){_0x4996e7[_0x355c('0x34')]=qs[_0x355c('0x34')](_0x2f1832[_0x355c('0x52')][_0x355c('0x34')]);_0x4996e7[_0x355c('0x33')]=qs[_0x355c('0x33')](_0x2f1832[_0x355c('0x52')]['offset']);}return _0x1edd87[_0x355c('0x135')](_0x4996e7);}})[_0x355c('0x46')](function(_0x296edd){if(_0x296edd){return _0x296edd?{'count':_0x140a0c,'rows':_0x296edd}:null;}})[_0x355c('0x46')](respondWithResult(_0x4d9b43,null))[_0x355c('0x2e')](handleError(_0x4d9b43,null));};exports[_0x355c('0x136')]=function(_0x2479fd,_0x3d6bc3,_0x206acf){return db['User'][_0x355c('0x43')]({'where':{'id':_0x2479fd[_0x355c('0x64')]['id']}})[_0x355c('0x46')](handleEntityNotFound(_0x3d6bc3,null))[_0x355c('0x46')](function(_0x5e6851){if(_0x5e6851){return _0x5e6851[_0x355c('0x136')](_0x2479fd[_0x355c('0x67')][_0x355c('0x6a')],_[_0x355c('0x6b')](_0x2479fd[_0x355c('0x67')],['ids','id'])||{});}})[_0x355c('0x46')](respondWithResult(_0x3d6bc3,null))[_0x355c('0x2e')](handleError(_0x3d6bc3,null));};exports[_0x355c('0x137')]=function(_0x49b841,_0x3a6a10,_0x3c2b7f){return db[_0x355c('0x4a')]['find']({'where':{'id':_0x49b841[_0x355c('0x64')]['id']}})[_0x355c('0x46')](handleEntityNotFound(_0x3a6a10,null))[_0x355c('0x46')](function(_0x2de82c){if(_0x2de82c){return _0x2de82c['removeFaxAccounts'](_0x49b841[_0x355c('0x52')][_0x355c('0x6a')]);}})[_0x355c('0x46')](respondWithStatusCode(_0x3a6a10,null))['catch'](handleError(_0x3a6a10,null));};exports[_0x355c('0x138')]=function(_0x4752c8,_0x44c792,_0x31afa6){var _0x5af20f={};var _0x25ff1c={};var _0x22ab33;var _0x19b54a;return db[_0x355c('0x4a')][_0x355c('0x90')]({'where':{'id':_0x4752c8[_0x355c('0x64')]['id']}})[_0x355c('0x46')](handleEntityNotFound(_0x44c792,null))['then'](function(_0x7f0ee9){if(_0x7f0ee9){_0x22ab33=_0x7f0ee9;_0x25ff1c[_0x355c('0x4e')]=_[_0x355c('0x53')](db['MailAccount'][_0x355c('0x4b')]);_0x25ff1c[_0x355c('0x52')]=_[_0x355c('0x53')](_0x4752c8[_0x355c('0x52')]);_0x25ff1c[_0x355c('0x54')]=_['intersection'](_0x25ff1c[_0x355c('0x4e')],_0x25ff1c[_0x355c('0x52')]);_0x5af20f[_0x355c('0x56')]=_[_0x355c('0x55')](_0x25ff1c[_0x355c('0x4e')],qs['fields'](_0x4752c8[_0x355c('0x52')]['fields']));_0x5af20f[_0x355c('0x56')]=_0x5af20f[_0x355c('0x56')][_0x355c('0x58')]?_0x5af20f[_0x355c('0x56')]:_0x25ff1c[_0x355c('0x4e')];_0x5af20f['order']=qs[_0x355c('0x59')](_0x4752c8[_0x355c('0x52')][_0x355c('0x59')]);_0x5af20f['where']=qs[_0x355c('0x54')](_[_0x355c('0xc8')](_0x4752c8['query'],_0x25ff1c[_0x355c('0x54')]));if(_0x4752c8[_0x355c('0x52')][_0x355c('0x40')]){_0x5af20f[_0x355c('0x5a')]=_[_0x355c('0x5b')](_0x5af20f[_0x355c('0x5a')],{'$or':_['map'](_0x5af20f[_0x355c('0x56')],function(_0x32e26f){var _0x4e540f={};_0x4e540f[_0x32e26f]={'$like':'%'+_0x4752c8[_0x355c('0x52')][_0x355c('0x40')]+'%'};return _0x4e540f;})});}_0x5af20f=_[_0x355c('0x5b')]({},_0x5af20f,_0x4752c8[_0x355c('0x60')]);return _0x22ab33[_0x355c('0x138')](_0x5af20f);}})[_0x355c('0x46')](function(_0x21d3ca){if(_0x21d3ca){_0x19b54a=_0x21d3ca[_0x355c('0x58')];if(!_0x4752c8[_0x355c('0x52')][_0x355c('0xbf')](_0x355c('0xc5'))){_0x5af20f[_0x355c('0x34')]=qs['limit'](_0x4752c8['query'][_0x355c('0x34')]);_0x5af20f[_0x355c('0x33')]=qs[_0x355c('0x33')](_0x4752c8[_0x355c('0x52')][_0x355c('0x33')]);}return _0x22ab33['getMailAccounts'](_0x5af20f);}})[_0x355c('0x46')](function(_0x279f5a){if(_0x279f5a){return _0x279f5a?{'count':_0x19b54a,'rows':_0x279f5a}:null;}})[_0x355c('0x46')](respondWithResult(_0x44c792,null))[_0x355c('0x2e')](handleError(_0x44c792,null));};exports[_0x355c('0x139')]=function(_0x4418fe,_0x191978,_0x41cf4c){return db[_0x355c('0x4a')][_0x355c('0x43')]({'where':{'id':_0x4418fe['params']['id']}})[_0x355c('0x46')](handleEntityNotFound(_0x191978,null))[_0x355c('0x46')](function(_0x5ddaff){if(_0x5ddaff){return _0x5ddaff[_0x355c('0x139')](_0x4418fe[_0x355c('0x67')][_0x355c('0x6a')],_[_0x355c('0x6b')](_0x4418fe['body'],[_0x355c('0x6a'),'id'])||{});}})[_0x355c('0x46')](respondWithResult(_0x191978,null))[_0x355c('0x2e')](handleError(_0x191978,null));};exports[_0x355c('0x13a')]=function(_0x3236c2,_0x549bce,_0x52c2ba){return db['User'][_0x355c('0x43')]({'where':{'id':_0x3236c2[_0x355c('0x64')]['id']}})[_0x355c('0x46')](handleEntityNotFound(_0x549bce,null))[_0x355c('0x46')](function(_0x80ec61){if(_0x80ec61){return _0x80ec61[_0x355c('0x13a')](_0x3236c2[_0x355c('0x52')][_0x355c('0x6a')]);}})['then'](respondWithStatusCode(_0x549bce,null))[_0x355c('0x2e')](handleError(_0x549bce,null));};exports[_0x355c('0x13b')]=function(_0x1814b0,_0x269e54,_0x1d21e0){var _0x5d6533={};var _0x1e0209={};var _0x183e0c;var _0xd9282e;return db['User']['findOne']({'where':{'id':_0x1814b0['params']['id']}})[_0x355c('0x46')](handleEntityNotFound(_0x269e54,null))[_0x355c('0x46')](function(_0x4bf279){if(_0x4bf279){_0x183e0c=_0x4bf279;_0x1e0209[_0x355c('0x4e')]=_[_0x355c('0x53')](db[_0x355c('0x13c')]['rawAttributes']);_0x1e0209[_0x355c('0x52')]=_[_0x355c('0x53')](_0x1814b0[_0x355c('0x52')]);_0x1e0209['filters']=_['intersection'](_0x1e0209[_0x355c('0x4e')],_0x1e0209[_0x355c('0x52')]);_0x5d6533[_0x355c('0x56')]=_['intersection'](_0x1e0209[_0x355c('0x4e')],qs[_0x355c('0x57')](_0x1814b0['query'][_0x355c('0x57')]));_0x5d6533[_0x355c('0x56')]=_0x5d6533['attributes'][_0x355c('0x58')]?_0x5d6533[_0x355c('0x56')]:_0x1e0209[_0x355c('0x4e')];_0x5d6533['order']=qs[_0x355c('0x59')](_0x1814b0[_0x355c('0x52')][_0x355c('0x59')]);_0x5d6533[_0x355c('0x5a')]=qs[_0x355c('0x54')](_[_0x355c('0xc8')](_0x1814b0['query'],_0x1e0209['filters']));if(_0x1814b0[_0x355c('0x52')][_0x355c('0x40')]){_0x5d6533['where']=_[_0x355c('0x5b')](_0x5d6533[_0x355c('0x5a')],{'$or':_['map'](_0x5d6533[_0x355c('0x56')],function(_0x2b1cc2){var _0x514edc={};_0x514edc[_0x2b1cc2]={'$like':'%'+_0x1814b0['query'][_0x355c('0x40')]+'%'};return _0x514edc;})});}_0x5d6533=_['merge']({},_0x5d6533,_0x1814b0[_0x355c('0x60')]);return _0x183e0c[_0x355c('0x13b')](_0x5d6533);}})[_0x355c('0x46')](function(_0x46aa69){if(_0x46aa69){_0xd9282e=_0x46aa69[_0x355c('0x58')];if(!_0x1814b0['query'][_0x355c('0xbf')](_0x355c('0xc5'))){_0x5d6533[_0x355c('0x34')]=qs[_0x355c('0x34')](_0x1814b0['query'][_0x355c('0x34')]);_0x5d6533[_0x355c('0x33')]=qs[_0x355c('0x33')](_0x1814b0['query']['offset']);}return _0x183e0c['getOpenchannelAccounts'](_0x5d6533);}})[_0x355c('0x46')](function(_0x29be52){if(_0x29be52){return _0x29be52?{'count':_0xd9282e,'rows':_0x29be52}:null;}})[_0x355c('0x46')](respondWithResult(_0x269e54,null))['catch'](handleError(_0x269e54,null));};exports['addOpenchannelAccounts']=function(_0x31ba61,_0x98df19,_0x294570){return db['User'][_0x355c('0x43')]({'where':{'id':_0x31ba61[_0x355c('0x64')]['id']}})[_0x355c('0x46')](handleEntityNotFound(_0x98df19,null))[_0x355c('0x46')](function(_0x449288){if(_0x449288){return _0x449288[_0x355c('0x13d')](_0x31ba61[_0x355c('0x67')]['ids'],_[_0x355c('0x6b')](_0x31ba61[_0x355c('0x67')],[_0x355c('0x6a'),'id'])||{});}})[_0x355c('0x46')](respondWithResult(_0x98df19,null))['catch'](handleError(_0x98df19,null));};exports[_0x355c('0x13e')]=function(_0x1ac68e,_0x52e3ec,_0x1deea4){return db[_0x355c('0x4a')][_0x355c('0x43')]({'where':{'id':_0x1ac68e[_0x355c('0x64')]['id']}})[_0x355c('0x46')](handleEntityNotFound(_0x52e3ec,null))[_0x355c('0x46')](function(_0x165661){if(_0x165661){return _0x165661[_0x355c('0x13e')](_0x1ac68e[_0x355c('0x52')][_0x355c('0x6a')]);}})[_0x355c('0x46')](respondWithStatusCode(_0x52e3ec,null))[_0x355c('0x2e')](handleError(_0x52e3ec,null));};exports[_0x355c('0x13f')]=function(_0x2ea382,_0x41ca42,_0x317841){var _0x315335={};var _0x38fb81={};var _0x26d469;var _0x33c8dc;return db['User']['findOne']({'where':{'id':_0x2ea382[_0x355c('0x64')]['id']}})['then'](handleEntityNotFound(_0x41ca42,null))['then'](function(_0x33d38d){if(_0x33d38d){_0x26d469=_0x33d38d;_0x38fb81[_0x355c('0x4e')]=_[_0x355c('0x53')](db[_0x355c('0x140')]['rawAttributes']);_0x38fb81[_0x355c('0x52')]=_[_0x355c('0x53')](_0x2ea382[_0x355c('0x52')]);_0x38fb81['filters']=_['intersection'](_0x38fb81[_0x355c('0x4e')],_0x38fb81[_0x355c('0x52')]);_0x315335[_0x355c('0x56')]=_[_0x355c('0x55')](_0x38fb81['model'],qs[_0x355c('0x57')](_0x2ea382[_0x355c('0x52')][_0x355c('0x57')]));_0x315335[_0x355c('0x56')]=_0x315335[_0x355c('0x56')]['length']?_0x315335[_0x355c('0x56')]:_0x38fb81[_0x355c('0x4e')];_0x315335['order']=qs['sort'](_0x2ea382[_0x355c('0x52')][_0x355c('0x59')]);_0x315335[_0x355c('0x5a')]=qs[_0x355c('0x54')](_['pick'](_0x2ea382['query'],_0x38fb81[_0x355c('0x54')]));if(_0x2ea382[_0x355c('0x52')][_0x355c('0x40')]){_0x315335[_0x355c('0x5a')]=_[_0x355c('0x5b')](_0x315335['where'],{'$or':_[_0x355c('0x49')](_0x315335[_0x355c('0x56')],function(_0x5c7824){var _0x335565={};_0x335565[_0x5c7824]={'$like':'%'+_0x2ea382['query'][_0x355c('0x40')]+'%'};return _0x335565;})});}_0x315335=_[_0x355c('0x5b')]({},_0x315335,_0x2ea382['options']);return _0x26d469[_0x355c('0x13f')](_0x315335);}})['then'](function(_0x2460e7){if(_0x2460e7){_0x33c8dc=_0x2460e7['length'];if(!_0x2ea382[_0x355c('0x52')][_0x355c('0xbf')](_0x355c('0xc5'))){_0x315335[_0x355c('0x34')]=qs[_0x355c('0x34')](_0x2ea382['query']['limit']);_0x315335[_0x355c('0x33')]=qs[_0x355c('0x33')](_0x2ea382[_0x355c('0x52')]['offset']);}return _0x26d469[_0x355c('0x13f')](_0x315335);}})['then'](function(_0x38d1c0){if(_0x38d1c0){return _0x38d1c0?{'count':_0x33c8dc,'rows':_0x38d1c0}:null;}})[_0x355c('0x46')](respondWithResult(_0x41ca42,null))[_0x355c('0x2e')](handleError(_0x41ca42,null));};exports['addSmsAccounts']=function(_0x32ab83,_0x454c9e,_0x5edc6d){return db[_0x355c('0x4a')][_0x355c('0x43')]({'where':{'id':_0x32ab83[_0x355c('0x64')]['id']}})[_0x355c('0x46')](handleEntityNotFound(_0x454c9e,null))['then'](function(_0x340996){if(_0x340996){return _0x340996['addSmsAccounts'](_0x32ab83[_0x355c('0x67')][_0x355c('0x6a')],_[_0x355c('0x6b')](_0x32ab83[_0x355c('0x67')],[_0x355c('0x6a'),'id'])||{});}})[_0x355c('0x46')](respondWithResult(_0x454c9e,null))['catch'](handleError(_0x454c9e,null));};exports[_0x355c('0x141')]=function(_0x2fe8e9,_0x496764,_0x28a10d){return db[_0x355c('0x4a')][_0x355c('0x43')]({'where':{'id':_0x2fe8e9[_0x355c('0x64')]['id']}})[_0x355c('0x46')](handleEntityNotFound(_0x496764,null))[_0x355c('0x46')](function(_0x3c0295){if(_0x3c0295){return _0x3c0295[_0x355c('0x141')](_0x2fe8e9[_0x355c('0x52')]['ids']);}})[_0x355c('0x46')](respondWithStatusCode(_0x496764,null))[_0x355c('0x2e')](handleError(_0x496764,null));};exports[_0x355c('0x142')]=function(_0x14c589,_0x3350e3,_0x392f4d){var _0x4824c7={};var _0x4ea57b={};var _0x254f36;var _0x271a55;return db[_0x355c('0x4a')][_0x355c('0x90')]({'where':{'id':_0x14c589[_0x355c('0x64')]['id']}})[_0x355c('0x46')](handleEntityNotFound(_0x3350e3,null))[_0x355c('0x46')](function(_0x10b95d){if(_0x10b95d){_0x254f36=_0x10b95d;_0x4ea57b[_0x355c('0x4e')]=_[_0x355c('0x53')](db[_0x355c('0x143')]['rawAttributes']);_0x4ea57b[_0x355c('0x52')]=_[_0x355c('0x53')](_0x14c589['query']);_0x4ea57b['filters']=_['intersection'](_0x4ea57b[_0x355c('0x4e')],_0x4ea57b[_0x355c('0x52')]);_0x4824c7[_0x355c('0x56')]=_[_0x355c('0x55')](_0x4ea57b[_0x355c('0x4e')],qs[_0x355c('0x57')](_0x14c589['query'][_0x355c('0x57')]));_0x4824c7['attributes']=_0x4824c7[_0x355c('0x56')]['length']?_0x4824c7['attributes']:_0x4ea57b['model'];_0x4824c7[_0x355c('0xbe')]=qs[_0x355c('0x59')](_0x14c589['query'][_0x355c('0x59')]);_0x4824c7[_0x355c('0x5a')]=qs[_0x355c('0x54')](_[_0x355c('0xc8')](_0x14c589[_0x355c('0x52')],_0x4ea57b[_0x355c('0x54')]));if(_0x14c589[_0x355c('0x52')][_0x355c('0x40')]){_0x4824c7[_0x355c('0x5a')]=_[_0x355c('0x5b')](_0x4824c7['where'],{'$or':_['map'](_0x4824c7[_0x355c('0x56')],function(_0x5b6514){var _0x477604={};_0x477604[_0x5b6514]={'$like':'%'+_0x14c589[_0x355c('0x52')][_0x355c('0x40')]+'%'};return _0x477604;})});}_0x4824c7=_[_0x355c('0x5b')]({},_0x4824c7,_0x14c589[_0x355c('0x60')]);return _0x254f36[_0x355c('0x142')](_0x4824c7);}})[_0x355c('0x46')](function(_0x3bdac8){if(_0x3bdac8){_0x271a55=_0x3bdac8[_0x355c('0x58')];if(!_0x14c589['query'][_0x355c('0xbf')](_0x355c('0xc5'))){_0x4824c7[_0x355c('0x34')]=qs[_0x355c('0x34')](_0x14c589['query'][_0x355c('0x34')]);_0x4824c7['offset']=qs[_0x355c('0x33')](_0x14c589[_0x355c('0x52')][_0x355c('0x33')]);}return _0x254f36[_0x355c('0x142')](_0x4824c7);}})[_0x355c('0x46')](function(_0x22f74b){if(_0x22f74b){return _0x22f74b?{'count':_0x271a55,'rows':_0x22f74b}:null;}})[_0x355c('0x46')](respondWithResult(_0x3350e3,null))[_0x355c('0x2e')](handleError(_0x3350e3,null));};exports[_0x355c('0x144')]=function(_0xfcb679,_0x5ef3cb,_0x78c470){return db['User'][_0x355c('0x43')]({'where':{'id':_0xfcb679[_0x355c('0x64')]['id']}})['then'](handleEntityNotFound(_0x5ef3cb,null))[_0x355c('0x46')](function(_0x52ea58){if(_0x52ea58){return _0x52ea58[_0x355c('0x144')](_0xfcb679['body'][_0x355c('0x6a')],_['omit'](_0xfcb679[_0x355c('0x67')],['ids','id'])||{});}})[_0x355c('0x46')](respondWithResult(_0x5ef3cb,null))['catch'](handleError(_0x5ef3cb,null));};exports['removeChatWebsites']=function(_0x13ba68,_0x1af734,_0x319f9d){return db[_0x355c('0x4a')][_0x355c('0x43')]({'where':{'id':_0x13ba68['params']['id']}})[_0x355c('0x46')](handleEntityNotFound(_0x1af734,null))[_0x355c('0x46')](function(_0x349259){if(_0x349259){return _0x349259[_0x355c('0x145')](_0x13ba68[_0x355c('0x52')]['ids']);}})[_0x355c('0x46')](respondWithStatusCode(_0x1af734,null))[_0x355c('0x2e')](handleError(_0x1af734,null));};exports[_0x355c('0x146')]=function(_0x4d8464,_0x5a7aa4,_0x12d077){var _0x4d8039={};var _0x21f949={};var _0x3d9e7e;var _0x4aa1ff;return db[_0x355c('0x4a')][_0x355c('0x90')]({'where':{'id':_0x4d8464[_0x355c('0x64')]['id']}})[_0x355c('0x46')](handleEntityNotFound(_0x5a7aa4,null))[_0x355c('0x46')](function(_0xfa2089){if(_0xfa2089){_0x3d9e7e=_0xfa2089;_0x21f949[_0x355c('0x4e')]=_[_0x355c('0x53')](db[_0x355c('0x147')]['rawAttributes']);_0x21f949[_0x355c('0x52')]=_['keys'](_0x4d8464['query']);_0x21f949[_0x355c('0x54')]=_['intersection'](_0x21f949[_0x355c('0x4e')],_0x21f949[_0x355c('0x52')]);_0x4d8039[_0x355c('0x56')]=_[_0x355c('0x55')](_0x21f949[_0x355c('0x4e')],qs['fields'](_0x4d8464[_0x355c('0x52')][_0x355c('0x57')]));_0x4d8039[_0x355c('0x56')]=_0x4d8039[_0x355c('0x56')][_0x355c('0x58')]?_0x4d8039[_0x355c('0x56')]:_0x21f949['model'];_0x4d8039['order']=qs[_0x355c('0x59')](_0x4d8464[_0x355c('0x52')][_0x355c('0x59')]);_0x4d8039[_0x355c('0x5a')]=qs[_0x355c('0x54')](_[_0x355c('0xc8')](_0x4d8464[_0x355c('0x52')],_0x21f949['filters']));if(_0x4d8464[_0x355c('0x52')][_0x355c('0x40')]){_0x4d8039[_0x355c('0x5a')]=_['merge'](_0x4d8039[_0x355c('0x5a')],{'$or':_[_0x355c('0x49')](_0x4d8039['attributes'],function(_0x2dc7f2){var _0x296165={};_0x296165[_0x2dc7f2]={'$like':'%'+_0x4d8464['query'][_0x355c('0x40')]+'%'};return _0x296165;})});}_0x4d8039=_[_0x355c('0x5b')]({},_0x4d8039,_0x4d8464[_0x355c('0x60')]);return _0x3d9e7e[_0x355c('0x146')](_0x4d8039);}})[_0x355c('0x46')](function(_0x459331){if(_0x459331){_0x4aa1ff=_0x459331[_0x355c('0x58')];if(!_0x4d8464['query'][_0x355c('0xbf')]('nolimit')){_0x4d8039[_0x355c('0x34')]=qs[_0x355c('0x34')](_0x4d8464['query'][_0x355c('0x34')]);_0x4d8039[_0x355c('0x33')]=qs[_0x355c('0x33')](_0x4d8464[_0x355c('0x52')][_0x355c('0x33')]);}return _0x3d9e7e[_0x355c('0x146')](_0x4d8039);}})[_0x355c('0x46')](function(_0x51dfe9){if(_0x51dfe9){return _0x51dfe9?{'count':_0x4aa1ff,'rows':_0x51dfe9}:null;}})[_0x355c('0x46')](respondWithResult(_0x5a7aa4,null))['catch'](handleError(_0x5a7aa4,null));};exports[_0x355c('0x148')]=function(_0x44e0ad,_0x44259c,_0x1b40be){return db[_0x355c('0x4a')][_0x355c('0x43')]({'where':{'id':_0x44e0ad['params']['id']}})[_0x355c('0x46')](handleEntityNotFound(_0x44259c,null))[_0x355c('0x46')](function(_0x1203d0){if(_0x1203d0){return _0x1203d0[_0x355c('0x148')](_0x44e0ad[_0x355c('0x67')][_0x355c('0x6a')],_[_0x355c('0x6b')](_0x44e0ad[_0x355c('0x67')],[_0x355c('0x6a'),'id'])||{});}})['then'](respondWithResult(_0x44259c,null))['catch'](handleError(_0x44259c,null));};exports['removeSquareProjects']=function(_0x11e91f,_0x483f80,_0x4978ef){return db[_0x355c('0x4a')]['find']({'where':{'id':_0x11e91f[_0x355c('0x64')]['id']}})[_0x355c('0x46')](handleEntityNotFound(_0x483f80,null))['then'](function(_0x4058f9){if(_0x4058f9){return _0x4058f9['removeSquareProjects'](_0x11e91f[_0x355c('0x52')]['ids']);}})[_0x355c('0x46')](respondWithStatusCode(_0x483f80,null))[_0x355c('0x2e')](handleError(_0x483f80,null));};exports['getScheduledCalls']=function(_0x2f684e,_0x1dd526){var _0x8088ac={},_0x27aff0={},_0x5c9104={'count':0x0,'rows':[]};var _0x38be42=db[_0x355c('0x149')]['rawAttributes'];_0x27aff0['model']=_[_0x355c('0x53')](_0x38be42);_0x27aff0[_0x355c('0x52')]=_[_0x355c('0x53')](_0x2f684e['query']);_0x27aff0[_0x355c('0x54')]=_[_0x355c('0x55')](_0x27aff0['model'],_0x27aff0[_0x355c('0x52')]);_0x27aff0[_0x355c('0x54')]=_[_0x355c('0xf2')](_0x27aff0['filters'],[_0x355c('0x14a'),_0x355c('0x14b'),_0x355c('0x14c'),_0x355c('0x14d'),_0x355c('0x14e'),'$lte',_0x355c('0x14f'),_0x355c('0x150'),_0x355c('0x151'),_0x355c('0x152'),_0x355c('0x153'),_0x355c('0x154'),_0x355c('0x155'),_0x355c('0x156'),_0x355c('0x157'),_0x355c('0x158'),'$notILike','$like','$overlap',_0x355c('0x159'),_0x355c('0x15a'),_0x355c('0x15b')]);_0x8088ac['attributes']=_[_0x355c('0x55')](_0x27aff0[_0x355c('0x4e')],qs[_0x355c('0x57')](_0x2f684e[_0x355c('0x52')]['fields']));_0x8088ac['attributes']=_0x8088ac[_0x355c('0x56')][_0x355c('0x58')]?_0x8088ac['attributes']:_0x27aff0[_0x355c('0x4e')];if(!_0x2f684e['query'][_0x355c('0xbf')](_0x355c('0xc5'))){_0x8088ac['limit']=qs[_0x355c('0x34')](_0x2f684e[_0x355c('0x52')][_0x355c('0x34')]);_0x8088ac[_0x355c('0x33')]=qs[_0x355c('0x33')](_0x2f684e[_0x355c('0x52')][_0x355c('0x33')]);}_0x8088ac[_0x355c('0xbe')]=qs['sort'](_0x2f684e['query'][_0x355c('0x59')]);_0x8088ac['where']=qs[_0x355c('0x54')](_[_0x355c('0xc8')](_0x2f684e['query'],_0x27aff0['filters']));if(_0x2f684e[_0x355c('0x52')][_0x355c('0x40')]){_0x8088ac[_0x355c('0x5a')]=_[_0x355c('0x5b')](_0x8088ac[_0x355c('0x5a')],{'$or':_[_0x355c('0x49')](_0x8088ac[_0x355c('0x56')],function(_0x1adae7){var _0x4b232c={};_0x4b232c[_0x1adae7]={'$like':'%'+_0x2f684e['query'][_0x355c('0x40')]+'%'};return _0x4b232c;})});}_0x8088ac[_0x355c('0x5a')]={'$and':[_0x8088ac[_0x355c('0x5a')],{'$or':[{'UserId':_0x2f684e['params']['id']},{'OwnerId':_0x2f684e[_0x355c('0x64')]['id']}]}]};_0x8088ac=_['merge']({},_0x8088ac,_0x2f684e[_0x355c('0x60')]);var _0x552b68={'where':_0x8088ac[_0x355c('0x5a')]};return db['CmHopper']['count'](_0x552b68)[_0x355c('0x46')](function(_0x5d9e5f){_0x5c9104[_0x355c('0x32')]=_0x5d9e5f;if(_0x2f684e[_0x355c('0x52')][_0x355c('0x65')]){_0x8088ac[_0x355c('0x61')]=[{'attributes':['id',_0x355c('0x15c'),'lastName','phone'],'model':db['CmContact'],'as':'Contact'},{'attributes':['id',_0x355c('0x44'),'dialActive'],'model':db[_0x355c('0xa9')],'as':_0x355c('0xc7')}];}return db[_0x355c('0x149')]['findAll'](_0x8088ac);})[_0x355c('0x46')](function(_0x841b62){_0x5c9104[_0x355c('0x62')]=_0x841b62;return _0x5c9104;})['then'](respondWithFilteredResult(_0x1dd526,_0x8088ac))[_0x355c('0x2e')](handleError(_0x1dd526,null));};exports[_0x355c('0x15d')]=function(_0x3fc4fa,_0x6683d0,_0x2c41b8){if(!_[_0x355c('0x71')](_0x3fc4fa[_0x355c('0x3c')]['id'])&&(_0x3fc4fa['user'][_0x355c('0x42')]==_0x355c('0x6d')||_0x3fc4fa[_0x355c('0x3c')]['role']==_0x355c('0x3c'))){return db[_0x355c('0x4a')][_0x355c('0x90')]({'where':{'id':_0x3fc4fa[_0x355c('0x64')]['id']},'raw':!![]})[_0x355c('0x46')](function(_0x422d68){return authService[_0x355c('0x15e')](_0x422d68);})['then'](function(_0xe912bc){if(_0xe912bc){return _0x6683d0[_0x355c('0x30')](0xc8)['json']({'api_key':_0xe912bc[_0x355c('0x15f')]});}else{return _0x6683d0['status'](0xcc)[_0x355c('0x160')]({'message':_0x355c('0x161')});}})['catch'](handleError(_0x6683d0,0x193));}else{return _0x6683d0[_0x355c('0x30')](0x191)[_0x355c('0x160')]({'message':_0x355c('0x162')});}};exports['createApiKey']=function(_0x130409,_0xd1df6f,_0x46b24d){if(!_[_0x355c('0x71')](_0x130409['user']['id'])&&(_0x130409[_0x355c('0x3c')][_0x355c('0x42')]==_0x355c('0x6d')||_0x130409[_0x355c('0x3c')][_0x355c('0x42')]==_0x355c('0x3c'))){return db[_0x355c('0x4a')]['find']({'where':{'id':_0x130409[_0x355c('0x64')]['id']}})[_0x355c('0x46')](function(_0x7d3366){return authService['generateApiKey'](_0x7d3366);})[_0x355c('0x46')](function(_0x180b99){return db[_0x355c('0x4a')]['update']({'apiKeyIat':_0x180b99[_0x355c('0x163')],'apiKeyNonce':_0x180b99[_0x355c('0x164')]},{'where':{'id':_0x130409[_0x355c('0x64')]['id']}})[_0x355c('0x46')](function(){return _0xd1df6f['status'](0xc8)['json']({'api_key':_0x180b99[_0x355c('0x15f')]});});})['catch'](handleError(_0xd1df6f,0x193));}else{return _0xd1df6f[_0x355c('0x30')](0x191)[_0x355c('0x160')]({'message':'You\x20don\x27t\x20have\x20sufficient\x20privileges\x20to\x20access\x20this\x20resource.'});}};exports[_0x355c('0x165')]=function(_0xc657f3,_0x31f955,_0x223719){if(!_[_0x355c('0x71')](_0xc657f3[_0x355c('0x3c')]['id'])&&(_0xc657f3['user'][_0x355c('0x42')]==_0x355c('0x6d')||_0xc657f3[_0x355c('0x3c')]['role']=='user')){return db[_0x355c('0x4a')][_0x355c('0x43')]({'where':{'id':_0xc657f3[_0x355c('0x64')]['id']}})[_0x355c('0x46')](handleEntityNotFound(_0x31f955,null))[_0x355c('0x46')](function(_0x6370d0){if(_0x6370d0&&_0x6370d0['apiKeyNonce']&&_0x6370d0[_0x355c('0x166')])return _0x6370d0;else throw{'message':_0x355c('0x167')};})['then'](function(_0x5a2ceb){return db['User'][_0x355c('0x39')]({'apiKeyNonce':null,'apiKeyIat':null},{'where':{'id':_0xc657f3[_0x355c('0x64')]['id']}});})[_0x355c('0x46')](respondWithStatusCode(_0x31f955,0xc8))[_0x355c('0x2e')](handleError(_0x31f955,0x193));}else{return _0x31f955[_0x355c('0x30')](0x191)[_0x355c('0x160')]({'message':'You\x20don\x27t\x20have\x20sufficient\x20privileges\x20to\x20access\x20this\x20resource.'});}};exports[_0x355c('0x168')]=function(_0x48215d,_0x5b956f){var _0xc7e557=_0x48215d[_0x355c('0x3c')][_0x355c('0x3b')]({'plain':!![]});if(!_0xc7e557){return _0x5b956f['status'](0x191)[_0x355c('0x47')](_0x355c('0x89'));}else{return _0x5b956f['status'](0xc8)[_0x355c('0x160')](_0xc7e557);}};
\ No newline at end of file
+var _0x14f5=['tag','getQueues','Queue','getVoiceQueuesRt','nolimit','getGroups','getRecordings','UserId','VoiceRecording','ScreenRecording','rows','getChatInteractions','ChatInteraction','OpenchannelInteraction','getOpenchannelInteractions','getMailInteractions','MailInteraction','getSmsInteractions','getFaxInteractions','getWhatsappInteractions','WhatsappInteraction','phone','mobile','LOCAL/%s@from-sip/n','intrf','user:forcelogout','headers','x-forwarded-for','connection','remoteAddress','socket','User\x20not\x20found\x20or\x20not\x20allowed\x20to\x20perform\x20login\x20method','getVoiceQueues','MemberReport','forEach','YYYY-MM-DD\x20HH:mm:ss','getChannels','LOGIN','PAUSE','LOGININPAUSE','bulkCreate','isMiddleware','resolve','pause','QueuePause','updateAttributes','DEFAULT\x20PAUSE','unpause','mailPause','chatPause','faxPause','openchannelPause','smsPause','lastPauseAt','chat','fax','whatsapp','openchannel','manual','set','%s%s','Pause','getTeams','Team','addTeams','omit','Voice','setDataValue','Chat','Mail','Sms','getWhatsappQueues','Whatsapp','getFaxQueues','Fax','getOpenchannelQueues','Openchannel','flatten','transaction','addAgent','getDataValue','upsert','removeTeams','getChatQueues','getSmsQueues','getLists','values','You\x20can\x27t\x20delete\x20yourself','addChatInteractions','spread','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','user_has_openchannel_interactions:save','removeOpenchannelInteractions','user_has_openchannel_interactions:remove','addWhatsappInteractions','user_has_whatsapp_interactions:save','removeWhatsappInteractions','getVoicePrefixes','VoicePrefix','getFaxAccounts','addFaxAccounts','removeFaxAccounts','getMailAccounts','MailAccount','addMailAccounts','removeMailAccounts','getOpenchannelAccounts','OpenchannelAccount','addOpenchannelAccounts','removeOpenchannelAccounts','getSmsAccounts','SmsAccount','addSmsAccounts','removeSmsAccounts','getChatWebsites','ChatWebsite','addChatWebsites','removeChatWebsites','getWhatsappAccounts','WhatsappAccount','addWhatsappAccounts','removeWhatsappAccounts','getSquareProjects','SquareProject','addSquareProjects','removeSquareProjects','getScheduledCalls','CmHopper','concat','$or','$gt','$gte','$lt','$ne','$eq','$between','$notBetween','$notIn','$like','$notLike','$iLike','$overlap','$any','firstName','lastName','dialActive','getApiKey','retrieveApiKey','createApiKey','generateApiKey','iat','nonce','token','You\x20don\x27t\x20have\x20sufficient\x20privileges\x20to\x20access\x20this\x20resource.','removeApiKey','apiKeyNonce','apiKeyIat','whoami','Unable\x20to\x20retrieve\x20the\x20current\x20user','eml-format','zip-dir','fast-json-patch','request-promise','bluebird','mustache','path','sox','to-csv','ejs','lodash','squel','crypto','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/environment','../../config/license/util','../../mysqldb','redis','defaults','localhost','socket.io-emitter','./user.socket','register','jayson/promise','client','http','request','then','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','apply','reject','save','update','destroy','get','Users','Agents','Telephones','filter','map','value','includes','role','find','name','sendStatus','stack','send','type','key','model','differenceBy','password','keys','query','filters','intersection','fields','attributes','hasOwnProperty','order','sort','where','merge','VIRTUAL','sequelize','lower','options','User','includeAll','findAll','show','params','rawAttributes','salt','length','include','body','describe','addContacts','ids','Setting','securePassword','max','isNil','internal','min_internal','SELECT','from','voicemail','mailbox','VoiceMail','fullname','agent','permissions','101','102','103','105','106','107','108','100','111','114','create','user','admin','Unauthorized.\x20You\x20must\x20be\x20an\x20administrator\x20in\x20order\x20to\x20create\x20another\x20administrator','settingsEnabled','userProfileId','UserProfileResource','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','Unauthorized','some','Unauthorized.\x20You\x20must\x20be\x20an\x20administrator\x20in\x20order\x20to\x20create\x20an\x20user','Unauthorized.\x20You\x20must\x20be\x20an\x20administrator\x20in\x20order\x20to\x20create\x20an\x20administrator','checkUserLimits','push','all','each','UserProfileSection','isEmpty','autoAssociation','telephone','compact','changePassword','oldPassword','newPassword','authenticate','ValidationError','Wrong\x20credentials','Sequelize','New\x20password\x20must\x20be\x20different\x20from\x20old\x20password','Invalid\x20body\x20format.\x20Use\x20newPassword','findOne','enforcePasswordHistory','passwordHistoryLimit','previousPasswords','validatePasswordHistory','updatePasswordsHistory','addQueues','channel','online','loginInPause','voicePause','interface','isValidChannel','Unknown\x20channel','add','capitalize','Queues','penalty','toLowerCase','QueueId','emit','voice','VoiceQueue','format','SIP/%s','removeQueues','Queue:remove','UserVoiceQueueRt','addAvatar','filename','getAvatar','join','server/files/images/logos/default_profile.png','userpic','existsSync','root','server/files/images/','download','getContacts','CmContact','pick','CmList','Tag','Tags'];(function(_0x392076,_0x2d6cc9){var _0x5b5323=function(_0x46a925){while(--_0x46a925){_0x392076['push'](_0x392076['shift']());}};_0x5b5323(++_0x2d6cc9);}(_0x14f5,0xae));var _0x514f=function(_0x5a3e59,_0x8133b5){_0x5a3e59=_0x5a3e59-0x0;var _0x1d6945=_0x14f5[_0x5a3e59];return _0x1d6945;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0x514f('0x0'));var rimraf=require('rimraf');var zipdir=require(_0x514f('0x1'));var jsonpatch=require(_0x514f('0x2'));var rp=require(_0x514f('0x3'));var moment=require('moment');var BPromise=require(_0x514f('0x4'));var Mustache=require(_0x514f('0x5'));var util=require('util');var path=require(_0x514f('0x6'));var sox=require(_0x514f('0x7'));var csv=require(_0x514f('0x8'));var ejs=require(_0x514f('0x9'));var fs=require('fs');var _=require(_0x514f('0xa'));var squel=require(_0x514f('0xb'));var crypto=require(_0x514f('0xc'));var jsforce=require('jsforce');var deskjs=require(_0x514f('0xd'));var toCsv=require('to-csv');var querystring=require(_0x514f('0xe'));var Papa=require(_0x514f('0xf'));var Redis=require(_0x514f('0x10'));var authService=require(_0x514f('0x11'));var qs=require(_0x514f('0x12'));var as=require(_0x514f('0x13'));var hardwareService=require(_0x514f('0x14'));var logger=require('../../config/logger')('api');var utils=require('../../config/utils');var config=require(_0x514f('0x15'));var licenseUtil=require(_0x514f('0x16'));var db=require(_0x514f('0x17'))['db'];config[_0x514f('0x18')]=_[_0x514f('0x19')](config[_0x514f('0x18')],{'host':_0x514f('0x1a'),'port':0x18eb});var socket=require(_0x514f('0x1b'))(new Redis(config[_0x514f('0x18')]));require(_0x514f('0x1c'))[_0x514f('0x1d')](socket);var jayson=require(_0x514f('0x1e'));var client=jayson[_0x514f('0x1f')][_0x514f('0x20')]({'port':0x232a});function respondWithRpcPromise(_0x1694b3,_0x5865d1,_0x70d2b4,_0x1f0cbe){return new BPromise(function(_0x519b63,_0x255996){var _0x53851d=_0x1f0cbe||client;return _0x53851d[_0x514f('0x21')](_0x1694b3,_0x70d2b4)[_0x514f('0x22')](function(_0x466ca8){logger['info'](_0x514f('0x23'),_0x5865d1,_0x514f('0x24'));logger[_0x514f('0x25')](_0x514f('0x26'),_0x5865d1,'request\x20sent',JSON['stringify'](_0x466ca8));if(_0x466ca8[_0x514f('0x27')]){if(_0x466ca8[_0x514f('0x27')][_0x514f('0x28')]===0x1f4){logger['error'](_0x514f('0x23'),_0x5865d1,_0x466ca8[_0x514f('0x27')]['message']);return _0x255996(_0x466ca8[_0x514f('0x27')][_0x514f('0x29')]);}logger['error'](_0x514f('0x23'),_0x5865d1,_0x466ca8[_0x514f('0x27')][_0x514f('0x29')]);return _0x519b63(_0x466ca8[_0x514f('0x27')]['message']);}else{logger['info']('User,\x20%s,\x20%s',_0x5865d1,'request\x20sent');_0x519b63(_0x466ca8[_0x514f('0x2a')][_0x514f('0x29')]);}})[_0x514f('0x2b')](function(_0xc36426){logger[_0x514f('0x27')](_0x514f('0x23'),_0x5865d1,_0xc36426);_0x255996(_0xc36426);});});}function respondWithStatusCode(_0x2c6bb1,_0x101742){_0x101742=_0x101742||0xcc;return function(_0x24678d){if(_0x24678d){return _0x2c6bb1['sendStatus'](_0x101742);}return _0x2c6bb1[_0x514f('0x2c')](_0x101742)[_0x514f('0x2d')]();};}function respondWithResult(_0x3c45e4,_0x248f30){_0x248f30=_0x248f30||0xc8;return function(_0x326809){if(_0x326809){return _0x3c45e4[_0x514f('0x2c')](_0x248f30)[_0x514f('0x2e')](_0x326809);}};}function respondWithFilteredResult(_0x2f61f7,_0x376960){return function(_0x594a50){if(_0x594a50){var _0x2c4c4b=_0x594a50[_0x514f('0x2f')],_0x488c17=_0x376960[_0x514f('0x30')],_0x2b43e0=_0x376960[_0x514f('0x30')]+_0x376960[_0x514f('0x31')],_0x51beda;if(_0x2b43e0>=_0x2c4c4b){_0x2b43e0=_0x2c4c4b;_0x51beda=0xc8;}else{_0x51beda=0xce;}_0x2f61f7[_0x514f('0x2c')](_0x51beda);return _0x2f61f7['set']('Content-Range',_0x488c17+'-'+_0x2b43e0+'/'+_0x2c4c4b)[_0x514f('0x2e')](_0x594a50);}return null;};}function patchUpdates(_0x5d564b){return function(_0x150384){try{jsonpatch[_0x514f('0x32')](_0x150384,_0x5d564b,!![]);}catch(_0x305761){return BPromise[_0x514f('0x33')](_0x305761);}return _0x150384[_0x514f('0x34')]();};}function saveUpdates(_0x5538a0,_0x554986){return function(_0x5eee93){if(_0x5eee93){return _0x5eee93[_0x514f('0x35')](_0x5538a0)[_0x514f('0x22')](function(_0x2f7e26){return _0x2f7e26;});}return null;};}function removeEntity(_0x32df6e,_0x40693f){return function(_0x3526c0){if(_0x3526c0){return _0x3526c0[_0x514f('0x36')]()[_0x514f('0x22')](function(){var _0x43768d=_0x3526c0[_0x514f('0x37')]({'plain':!![]});if(_0x43768d['role']==='admin')return;var _0x5ef920=[{'name':_0x514f('0x38'),'value':'user','ignore':!![]},{'name':_0x514f('0x39'),'value':'agent','ignore':![]},{'name':_0x514f('0x3a'),'value':'telephone','ignore':![]}];var _0x5247a4=_(_0x5ef920)[_0x514f('0x3b')]('ignore')[_0x514f('0x3c')](_0x514f('0x3d'))[_0x514f('0x3d')]();if(_[_0x514f('0x3e')](_0x5247a4,_0x43768d[_0x514f('0x3f')])){return;}var _0x492052=_[_0x514f('0x40')](_0x5ef920,[_0x514f('0x3d'),_0x43768d[_0x514f('0x3f')]])[_0x514f('0x41')];return db['UserProfileResource'][_0x514f('0x36')]({'where':{'type':_0x492052,'resourceId':_0x43768d['id']}})[_0x514f('0x22')](function(){return _0x3526c0;});})[_0x514f('0x22')](function(){_0x32df6e[_0x514f('0x2c')](0xcc)['end']();});}};}function handleEntityNotFound(_0x1c1a24,_0x138ccd){return function(_0x420c77){if(!_0x420c77){_0x1c1a24[_0x514f('0x42')](0x194);}return _0x420c77;};}function handleError(_0x580b24,_0xee1de2){_0xee1de2=_0xee1de2||0x1f4;return function(_0x505880){logger[_0x514f('0x27')](_0x505880[_0x514f('0x43')]);if(_0x505880[_0x514f('0x41')]){delete _0x505880['name'];}_0x580b24['status'](_0xee1de2)[_0x514f('0x44')](_0x505880);};}exports['index']=function(_0x10259a,_0x1e9a35){var _0x17328a={},_0x456aaa={},_0x476351={'count':0x0,'rows':[]};var _0x24ab34=_[_0x514f('0x3c')](db['User']['rawAttributes'],function(_0x1c2fdc){return{'name':_0x1c2fdc['fieldName'],'type':_0x1c2fdc[_0x514f('0x45')][_0x514f('0x46')]};});_0x456aaa[_0x514f('0x47')]=_[_0x514f('0x48')](_[_0x514f('0x3c')](_0x24ab34,'name'),[_0x514f('0x49'),'salt']);_0x456aaa['query']=_[_0x514f('0x4a')](_0x10259a[_0x514f('0x4b')]);_0x456aaa[_0x514f('0x4c')]=_[_0x514f('0x4d')](_0x456aaa[_0x514f('0x47')],_0x456aaa['query']);_0x17328a['attributes']=_[_0x514f('0x4d')](_0x456aaa[_0x514f('0x47')],qs[_0x514f('0x4e')](_0x10259a[_0x514f('0x4b')][_0x514f('0x4e')]));_0x17328a['attributes']=_0x17328a[_0x514f('0x4f')]['length']?_0x17328a['attributes']:_0x456aaa[_0x514f('0x47')];if(!_0x10259a['query'][_0x514f('0x50')]('nolimit')){_0x17328a['limit']=qs[_0x514f('0x31')](_0x10259a[_0x514f('0x4b')]['limit']);_0x17328a['offset']=qs[_0x514f('0x30')](_0x10259a[_0x514f('0x4b')][_0x514f('0x30')]);}_0x17328a[_0x514f('0x51')]=qs[_0x514f('0x52')](_0x10259a[_0x514f('0x4b')][_0x514f('0x52')]);_0x17328a[_0x514f('0x53')]=qs[_0x514f('0x4c')](_['pick'](_0x10259a[_0x514f('0x4b')],_0x456aaa[_0x514f('0x4c')]),_0x24ab34);if(_0x10259a[_0x514f('0x4b')][_0x514f('0x3b')]){_0x17328a[_0x514f('0x53')]=_[_0x514f('0x54')](_0x17328a[_0x514f('0x53')],{'$or':_['map'](_0x24ab34,function(_0x95ee75){if(_0x95ee75['type']!==_0x514f('0x55')){return db[_0x514f('0x56')][_0x514f('0x53')](db[_0x514f('0x56')]['fn'](_0x514f('0x57'),db['sequelize']['col'](_0x95ee75[_0x514f('0x41')])),{'$like':db['sequelize']['fn'](_0x514f('0x57'),'%'+_0x10259a['query'][_0x514f('0x3b')]+'%')});}})});}_0x17328a=_[_0x514f('0x54')]({},_0x17328a,_0x10259a[_0x514f('0x58')]);var _0x4f35ba={'where':_0x17328a[_0x514f('0x53')]};return db[_0x514f('0x59')][_0x514f('0x2f')](_0x4f35ba)['then'](function(_0x222f94){_0x476351[_0x514f('0x2f')]=_0x222f94;if(_0x10259a['query'][_0x514f('0x5a')]){_0x17328a['include']=[{'all':!![]}];}return db[_0x514f('0x59')][_0x514f('0x5b')](_0x17328a);})[_0x514f('0x22')](function(_0x500be7){_0x476351['rows']=_0x500be7;return _0x476351;})[_0x514f('0x22')](respondWithFilteredResult(_0x1e9a35,_0x17328a))[_0x514f('0x2b')](handleError(_0x1e9a35,null));};exports[_0x514f('0x5c')]=function(_0x1053b8,_0x39cce9){var _0xfd5e5b={'raw':![],'where':{'id':_0x1053b8[_0x514f('0x5d')]['id']}},_0x233484={};_0x233484['model']=_[_0x514f('0x48')](_[_0x514f('0x4a')](db[_0x514f('0x59')][_0x514f('0x5e')]),['password',_0x514f('0x5f')]);_0x233484[_0x514f('0x4b')]=_[_0x514f('0x4a')](_0x1053b8['query']);_0x233484[_0x514f('0x4c')]=_[_0x514f('0x4d')](_0x233484['model'],_0x233484[_0x514f('0x4b')]);_0xfd5e5b[_0x514f('0x4f')]=_[_0x514f('0x4d')](_0x233484[_0x514f('0x47')],qs[_0x514f('0x4e')](_0x1053b8[_0x514f('0x4b')][_0x514f('0x4e')]));_0xfd5e5b[_0x514f('0x4f')]=_0xfd5e5b['attributes'][_0x514f('0x60')]?_0xfd5e5b['attributes']:_0x233484['model'];if(_0x1053b8[_0x514f('0x4b')]['includeAll']){_0xfd5e5b[_0x514f('0x61')]=[{'all':!![]}];}_0xfd5e5b=_[_0x514f('0x54')]({},_0xfd5e5b,_0x1053b8[_0x514f('0x58')]);return db['User']['find'](_0xfd5e5b)[_0x514f('0x22')](handleEntityNotFound(_0x39cce9,null))['then'](respondWithResult(_0x39cce9,null))[_0x514f('0x2b')](handleError(_0x39cce9,null));};exports[_0x514f('0x35')]=function(_0x312800,_0x37bfc2){if(_0x312800['body']['id']){delete _0x312800['body']['id'];}delete _0x312800[_0x514f('0x62')][_0x514f('0x3f')];return db[_0x514f('0x59')][_0x514f('0x40')]({'where':{'id':_0x312800[_0x514f('0x5d')]['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x37bfc2,null))[_0x514f('0x22')](saveUpdates(_0x312800[_0x514f('0x62')],null))['then'](respondWithResult(_0x37bfc2,null))['catch'](handleError(_0x37bfc2,null));};exports[_0x514f('0x63')]=function(_0x5d5659,_0x21e8c1){return db[_0x514f('0x59')][_0x514f('0x63')]()['then'](respondWithResult(_0x21e8c1,null))['catch'](handleError(_0x21e8c1,null));};exports[_0x514f('0x64')]=function(_0xd73693,_0x5879ec,_0x36f20b){return db[_0x514f('0x59')]['find']({'where':{'id':_0xd73693['params']['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x5879ec,null))['then'](function(_0x347a67){if(_0x347a67){return _0x347a67[_0x514f('0x64')](_0xd73693[_0x514f('0x62')]['ids'],_['omit'](_0xd73693[_0x514f('0x62')],[_0x514f('0x65'),'id'])||{});}})[_0x514f('0x22')](respondWithResult(_0x5879ec,null))[_0x514f('0x2b')](handleError(_0x5879ec,null));};function validateUser(_0x342f72){return new BPromise(function(_0x528d1f,_0x5817ed){if(_0x342f72['internal'])return _0x528d1f(_0x342f72);return db[_0x514f('0x66')]['findById'](0x1)[_0x514f('0x22')](function(_0x39ced0){if(_0x39ced0[_0x514f('0x67')])authService['validatePasswordPattern'](_0x342f72['password']);db[_0x514f('0x59')][_0x514f('0x68')]('internal')[_0x514f('0x22')](function(_0x5475e5){if(_[_0x514f('0x69')](_0x5475e5)){_0x342f72[_0x514f('0x6a')]=_0x39ced0[_0x514f('0x6b')]||0x1;return;}if(_[_0x514f('0x69')](_0x39ced0[_0x514f('0x6b')])||_0x39ced0[_0x514f('0x6b')]===_0x5475e5){_0x342f72['internal']=_0x5475e5+0x1;return;}if(_0x39ced0[_0x514f('0x6b')]>_0x5475e5){_0x342f72[_0x514f('0x6a')]=_0x39ced0[_0x514f('0x6b')];return;}return db[_0x514f('0x56')][_0x514f('0x4b')]('select\x20(select\x20IFNULL(max(internal)+1,1)\x20from\x20users\x20where\x20internal\x20<\x20md.internal)\x20as\x20\x27from\x27,\x20md.internal\x20-\x201\x20as\x20\x27to\x27\x20from\x20users\x20md\x20where\x20md.internal\x20!=\x201\x20and\x20not\x20exists\x20(select\x201\x20from\x20users\x20md2\x20where\x20md2.internal\x20=\x20md.internal\x20-\x201)',{'type':db[_0x514f('0x56')]['QueryTypes'][_0x514f('0x6c')]})[_0x514f('0x22')](function(_0x37df81){if(_0x37df81&&_0x37df81[_0x514f('0x60')]){for(var _0x38857f=0x0,_0x4c8ebe=_0x37df81[_0x514f('0x60')];_0x38857f<_0x4c8ebe&&_[_0x514f('0x69')](_0x342f72[_0x514f('0x6a')]);_0x38857f++){if(_0x39ced0[_0x514f('0x6b')]<=_0x37df81[_0x38857f]['from']){_0x342f72['internal']=_0x37df81[_0x38857f][_0x514f('0x6d')];}else if(_0x39ced0['min_internal']>_0x37df81[_0x38857f][_0x514f('0x6d')]&&_0x39ced0[_0x514f('0x6b')]<=_0x37df81[_0x38857f]['to']){_0x342f72['internal']=_0x39ced0['min_internal'];}}}if(_['isNil'](_0x342f72['internal'])){_0x342f72[_0x514f('0x6a')]=_0x5475e5+0x1;}return _0x528d1f(_0x342f72);});});})['catch'](function(_0x414602){_0x5817ed(_0x414602);});});}function updateUser(_0x3db9a5){return new BPromise(function(_0x3fee74,_0x1da50f){try{if(_0x3db9a5[_0x514f('0x6e')]){_0x3db9a5[_0x514f('0x6f')]=_0x3db9a5[_0x514f('0x6a')];_0x3db9a5[_0x514f('0x70')]={'mailbox':_0x3db9a5[_0x514f('0x6a')],'password':_0x3db9a5[_0x514f('0x49')],'fullname':_0x3db9a5[_0x514f('0x71')],'email':_0x3db9a5['email']};}if(_0x3db9a5[_0x514f('0x3f')]===_0x514f('0x72')){if(!_0x3db9a5[_0x514f('0x73')])_0x3db9a5[_0x514f('0x73')]=[_0x514f('0x74'),_0x514f('0x75'),_0x514f('0x76'),'113','110','104',_0x514f('0x77'),_0x514f('0x78'),_0x514f('0x79'),_0x514f('0x7a'),'109',_0x514f('0x7b'),_0x514f('0x7c'),_0x514f('0x7d')];}_0x3fee74(_0x3db9a5);}catch(_0x3335f0){_0x1da50f(_0x3335f0);}});}exports[_0x514f('0x7e')]=function(_0x580caa,_0x223cc3){if(_0x580caa[_0x514f('0x7f')][_0x514f('0x3f')]===_0x514f('0x72'))throw new Error('Unauthorized');if(_0x580caa[_0x514f('0x62')][_0x514f('0x3f')]===_0x514f('0x7f')&&_0x580caa[_0x514f('0x7f')]['role']!==_0x514f('0x80')){throw new Error('Unauthorized.\x20You\x20must\x20be\x20an\x20administrator\x20in\x20order\x20to\x20create\x20an\x20user');}if(_0x580caa[_0x514f('0x62')]['role']===_0x514f('0x80')&&_0x580caa[_0x514f('0x7f')][_0x514f('0x3f')]!=='admin'){throw new Error(_0x514f('0x81'));}return licenseUtil['checkUserLimits']([_0x580caa[_0x514f('0x62')]])[_0x514f('0x22')](function(){return validateUser(_0x580caa[_0x514f('0x62')]);})[_0x514f('0x22')](function(_0x508861){return updateUser(_0x508861)['then'](function(_0x1312de){if(_0x1312de['role']==='admin'){_0x1312de[_0x514f('0x82')]=_0x580caa[_0x514f('0x7f')][_0x514f('0x82')];delete _0x1312de[_0x514f('0x83')];}return _0x1312de;});})['then'](function(_0x4c8314){return db[_0x514f('0x59')]['create'](_0x4c8314,{'include':[{'model':db[_0x514f('0x70')],'as':_0x514f('0x70')}]});})[_0x514f('0x22')](function(_0x199091){if(_0x580caa[_0x514f('0x62')][_0x514f('0x3f')]==='user')return _0x199091;if(_0x580caa[_0x514f('0x7f')][_0x514f('0x3f')]!=='user')return _0x199091;return db['UserProfileSection'][_0x514f('0x40')]({'where':{'name':_0x199091[_0x514f('0x3f')]==='agent'?_0x514f('0x39'):_0x514f('0x3a'),'userProfileId':_0x580caa[_0x514f('0x7f')][_0x514f('0x83')]},'raw':!![]})[_0x514f('0x22')](function(_0x5c1511){if(!_0x5c1511||_0x5c1511['autoAssociation']!=0x0)return _0x199091;return db[_0x514f('0x84')][_0x514f('0x7e')]({'name':_0x199091[_0x514f('0x41')],'resourceId':_0x199091['id'],'type':_0x5c1511[_0x514f('0x41')],'sectionId':_0x5c1511['id']},{})['then'](function(){return _0x199091;});})[_0x514f('0x2b')](function(_0x167915){logger[_0x514f('0x27')](_0x514f('0x85'),_0x167915);throw _0x167915;});})[_0x514f('0x22')](respondWithResult(_0x223cc3,0xc9))['catch'](handleError(_0x223cc3,null));};exports['bulkCreate']=function(_0x3e7f51,_0x53d42f){var _0x1caa7b=_0x3e7f51[_0x514f('0x62')];var _0x4ab28e=[];if(_0x3e7f51[_0x514f('0x7f')][_0x514f('0x3f')]===_0x514f('0x72'))throw new Error(_0x514f('0x86'));if(_[_0x514f('0x87')](_0x1caa7b,[_0x514f('0x3f'),'user'])&&_0x3e7f51[_0x514f('0x7f')]['role']!==_0x514f('0x80')){throw new Error(_0x514f('0x88'));}if(_[_0x514f('0x87')](_0x1caa7b,[_0x514f('0x3f'),_0x514f('0x80')])&&_0x3e7f51['user'][_0x514f('0x3f')]!==_0x514f('0x80')){throw new Error(_0x514f('0x89'));}return licenseUtil[_0x514f('0x8a')](_0x1caa7b)[_0x514f('0x22')](function(){return validateUser(_0x1caa7b[0x0]);})[_0x514f('0x22')](function(){for(var _0x2dbef8=0x1;_0x2dbef8<_0x1caa7b[_0x514f('0x60')];_0x2dbef8++){var _0x1fbcdb=_0x1caa7b[_0x2dbef8-0x1]['internal'];if(!_0x1caa7b[_0x2dbef8][_0x514f('0x6a')])_0x1caa7b[_0x2dbef8][_0x514f('0x6a')]=_0x1fbcdb+0x1;_0x4ab28e[_0x514f('0x8b')](validateUser(_0x1caa7b[_0x2dbef8]));}return BPromise[_0x514f('0x8c')](_0x4ab28e);})[_0x514f('0x22')](function(){_0x4ab28e=[];for(var _0x18f509=0x0;_0x18f509<_0x1caa7b[_0x514f('0x60')];_0x18f509++){_0x4ab28e['push'](updateUser(_0x1caa7b[_0x18f509]));}return BPromise[_0x514f('0x8c')](_0x4ab28e);})['then'](function(){return BPromise[_0x514f('0x8d')](_0x1caa7b,function(_0x4d30db){return db['User']['create'](_0x4d30db,{'include':[{'model':db['VoiceMail'],'as':'VoiceMail'}]})['then'](function(_0xf6224a){_0x4d30db['id']=_0xf6224a['id'];return _0x4d30db;});});})[_0x514f('0x22')](function(_0x5c018d){if(_0x3e7f51[_0x514f('0x62')][_0x514f('0x3f')]===_0x514f('0x7f'))return _0x5c018d;if(_0x3e7f51['user'][_0x514f('0x3f')]!=='user')return _0x5c018d;var _0x3f14d1=_[_0x514f('0x87')](_0x5c018d,function(_0x84682){return _0x84682[_0x514f('0x3f')]===_0x514f('0x72')||_0x84682[_0x514f('0x3f')]==='telephone';});if(!_0x3f14d1)return _0x5c018d;return db[_0x514f('0x8e')][_0x514f('0x5b')]({'where':{'name':{'$or':[_0x514f('0x39'),_0x514f('0x3a')]},'userProfileId':_0x3e7f51[_0x514f('0x7f')]['userProfileId']},'raw':!![]})[_0x514f('0x22')](function(_0x357b2d){if(_[_0x514f('0x8f')](_0x357b2d)||!_[_0x514f('0x87')](_0x357b2d,[_0x514f('0x90'),0x0]))return _0x5c018d;_0x4ab28e=[];var _0x498321=_(_0x357b2d)[_0x514f('0x3c')](function(_0x491825){if(_0x491825[_0x514f('0x90')]===0x1)return;return _0x491825[_0x514f('0x41')]===_0x514f('0x39')?_0x514f('0x72'):_0x514f('0x91');})[_0x514f('0x92')]()[_0x514f('0x3d')]();for(var _0x524715=0x0;_0x524715<_0x5c018d[_0x514f('0x60')];_0x524715++){if(!_[_0x514f('0x3e')](_0x498321,_0x5c018d[_0x524715][_0x514f('0x3f')]))return;var _0x5a16e4=_0x5c018d[_0x524715][_0x514f('0x3f')]===_0x514f('0x72')?_0x514f('0x39'):_0x514f('0x3a');_0x4ab28e[_0x514f('0x8b')](db[_0x514f('0x84')][_0x514f('0x7e')]({'name':_0x5c018d[_0x524715][_0x514f('0x41')],'resourceId':_0x5c018d[_0x524715]['id'],'type':_0x5a16e4,'sectionId':_[_0x514f('0x40')](_0x357b2d,['name',_0x5a16e4])['id']},{}));}return BPromise[_0x514f('0x8c')](_0x4ab28e);})[_0x514f('0x22')](respondWithResult(_0x53d42f,0xc9))['catch'](handleError(_0x53d42f,null));});};exports[_0x514f('0x93')]=function(_0x2dac37,_0x358108,_0x3ccac5){if(_0x2dac37[_0x514f('0x62')]['id']){delete _0x2dac37[_0x514f('0x62')]['id'];}return db['User']['find']({'where':{'id':_0x2dac37[_0x514f('0x5d')]['id']}})['then'](function(_0x144baf){if(!_0x144baf)return null;if(_0x144baf['id']===_0x2dac37[_0x514f('0x7f')]['id']){if(!_0x2dac37[_0x514f('0x62')][_0x514f('0x94')]||!_0x2dac37['body'][_0x514f('0x95')]){throw new db['Sequelize']['ValidationError']('Invalid\x20body\x20format.\x20Use\x20oldPassword\x20and\x20newPassword');}if(!_0x144baf[_0x514f('0x96')](_0x2dac37[_0x514f('0x62')][_0x514f('0x94')])){throw new db['Sequelize'][(_0x514f('0x97'))](_0x514f('0x98'));}if(_0x2dac37[_0x514f('0x62')][_0x514f('0x94')]===_0x2dac37[_0x514f('0x62')][_0x514f('0x95')]){throw new db[(_0x514f('0x99'))]['ValidationError'](_0x514f('0x9a'));}}else if(_0x2dac37[_0x514f('0x7f')][_0x514f('0x3f')]==='admin'){if(!_0x2dac37[_0x514f('0x62')]['newPassword']){throw new db[(_0x514f('0x99'))][(_0x514f('0x97'))]('Invalid\x20body\x20format.\x20Use\x20newPassword');}}else if(_0x2dac37[_0x514f('0x7f')][_0x514f('0x3f')]===_0x514f('0x7f')){if(!_0x2dac37[_0x514f('0x62')][_0x514f('0x95')]){throw new db[(_0x514f('0x99'))][(_0x514f('0x97'))](_0x514f('0x9b'));}if(_0x144baf[_0x514f('0x3f')]!==_0x514f('0x72')){throw new db[(_0x514f('0x99'))][(_0x514f('0x97'))]('Unauthorized');}}else{throw new db['Sequelize']['ValidationError'](_0x514f('0x86'));}return _0x144baf;})[_0x514f('0x22')](handleEntityNotFound(_0x358108,null))['then'](function(_0x178f87){return db['Setting'][_0x514f('0x9c')]({'attributes':['id',_0x514f('0x67'),_0x514f('0x9d'),_0x514f('0x9e')]})['then'](function(_0x33d3ca){if(_0x33d3ca['securePassword'])authService['validatePasswordPattern'](_0x2dac37[_0x514f('0x62')]['newPassword']);if(!_0x33d3ca[_0x514f('0x9d')]||!_0x178f87[_0x514f('0x9f')])return _0x178f87;authService[_0x514f('0xa0')](_0x2dac37[_0x514f('0x62')][_0x514f('0x95')],_0x178f87[_0x514f('0x9f')],_0x33d3ca[_0x514f('0x9e')]);return _0x178f87;})['then'](saveUpdates({'password':_0x2dac37[_0x514f('0x62')][_0x514f('0x95')],'passwordResetAt':_0x2dac37[_0x514f('0x7f')]['id']==_0x2dac37[_0x514f('0x5d')]['id']?moment():null,'previousPasswords':authService[_0x514f('0xa1')](_0x2dac37[_0x514f('0x62')][_0x514f('0x95')],_0x178f87['previousPasswords'])},null));})[_0x514f('0x22')](respondWithResult(_0x358108,null))[_0x514f('0x2b')](handleError(_0x358108,null));};exports[_0x514f('0xa2')]=function(_0x119a0e,_0xea48b7,_0xbbe2b5){var _0xd946f2=_0x119a0e[_0x514f('0x62')][_0x514f('0xa3')];return db[_0x514f('0x59')][_0x514f('0x40')]({'where':{'id':_0x119a0e['params']['id']},'attributes':['id',_0x514f('0x41'),_0x514f('0x3f'),_0x514f('0xa4'),_0x514f('0xa5'),_0x514f('0xa6'),_0x514f('0xa7')]})[_0x514f('0x22')](handleEntityNotFound(_0xea48b7,null))[_0x514f('0x22')](function(_0x2ca078){if(_0x2ca078){if(!utils[_0x514f('0xa8')](_0xd946f2)){throw new db['Sequelize']['ValidationError'](_0x514f('0xa9'));}return _0x2ca078[_0x514f('0xaa')+_[_0x514f('0xab')](_0xd946f2['toLowerCase']())+_0x514f('0xac')](_0x119a0e['body'][_0x514f('0x65')],{'penalty':_0x119a0e[_0x514f('0x62')][_0x514f('0xad')]||0x0})['spread'](function(_0x511aa2){for(var _0x3e3ff4=0x0;_0x3e3ff4<_0x119a0e['body']['ids'][_0x514f('0x60')];_0x3e3ff4+=0x1){var _0x213b4c={'UserId':_0x119a0e[_0x514f('0x5d')]['id']};_0x213b4c[_[_0x514f('0xab')](_0xd946f2[_0x514f('0xae')]())+_0x514f('0xaf')]=_0x119a0e['body'][_0x514f('0x65')][_0x3e3ff4];socket[_0x514f('0xb0')](_0x514f('0x7f')+_[_0x514f('0xab')](_0xd946f2[_0x514f('0xae')]())+'Queue:save',_0x213b4c);}return _0x511aa2;})[_0x514f('0x22')](function(){if(_0xd946f2===_0x514f('0xb1')){return db[_0x514f('0xb2')][_0x514f('0x5b')]({'where':{'id':_0x119a0e['body']['ids']||[]},'raw':!![],'attributes':['id',_0x514f('0x41')]});}})[_0x514f('0x22')](function(_0x56970f){var _0x3b86c6=_0x2ca078[_0x514f('0x37')]({'plain':!![]});var _0x5af070=[];if(_0xd946f2==='voice'&&_0x3b86c6[_0x514f('0x3f')]===_0x514f('0x72')&&_0x3b86c6[_0x514f('0xa4')]){for(var _0x4561d3=0x0;_0x4561d3<_0x56970f[_0x514f('0x60')];_0x4561d3+=0x1){_0x5af070[_0x514f('0x8b')]({'membername':_0x3b86c6[_0x514f('0x41')],'UserId':_0x3b86c6['id'],'queue_name':_0x56970f[_0x4561d3][_0x514f('0x41')],'VoiceQueueId':_0x56970f[_0x4561d3]['id'],'interface':_[_0x514f('0x69')](_0x3b86c6[_0x514f('0xa7')])?util[_0x514f('0xb3')](_0x514f('0xb4'),_0x3b86c6[_0x514f('0x41')]):_0x3b86c6['interface'],'paused':_0x3b86c6[_0x514f('0xa6')]||![],'penalty':_0x119a0e[_0x514f('0x62')][_0x514f('0xad')]||0x0});}return BPromise[_0x514f('0x8d')](_0x5af070,function(_0x39dada){return db['UserVoiceQueueRt']['upsert'](_0x39dada);});}return _0x2ca078;});}})[_0x514f('0x22')](respondWithStatusCode(_0xea48b7,null))[_0x514f('0x2b')](handleError(_0xea48b7,null));};exports[_0x514f('0xb5')]=function(_0x52569e,_0x58c211,_0x3c8d6d){var _0x30b3fe;return db[_0x514f('0x59')][_0x514f('0x40')]({'where':{'id':_0x52569e[_0x514f('0x5d')]['id']},'attributes':['id',_0x514f('0x41'),_0x514f('0x3f')]})['then'](handleEntityNotFound(_0x58c211,null))['then'](function(_0x43888c){if(_0x43888c){_0x30b3fe=_0x43888c;if(!_0x52569e['query'][_0x514f('0xa3')]||!utils['isValidChannel'](_0x52569e[_0x514f('0x4b')]['channel'])){throw new db[(_0x514f('0x99'))][(_0x514f('0x97'))](_0x514f('0xa9'));}return _0x43888c['remove'+_[_0x514f('0xab')](_0x52569e[_0x514f('0x4b')][_0x514f('0xa3')][_0x514f('0xae')]())+_0x514f('0xac')](_0x52569e[_0x514f('0x4b')][_0x514f('0x65')]);}})[_0x514f('0x22')](function(_0xebf858){for(var _0x350f34=0x0;_0x350f34<_0x52569e[_0x514f('0x4b')][_0x514f('0x65')][_0x514f('0x60')];_0x350f34+=0x1){var _0x16b300={'UserId':_0x52569e[_0x514f('0x5d')]['id']};_0x16b300[_['capitalize'](_0x52569e['query'][_0x514f('0xa3')]['toLowerCase']())+_0x514f('0xaf')]=_0x52569e[_0x514f('0x4b')]['ids'][_0x350f34];socket['emit']('user'+_[_0x514f('0xab')](_0x52569e[_0x514f('0x4b')][_0x514f('0xa3')][_0x514f('0xae')]())+_0x514f('0xb6'),_0x16b300);}return _0xebf858;})[_0x514f('0x22')](function(){if(_0x52569e[_0x514f('0x4b')][_0x514f('0xa3')]===_0x514f('0xb1')){return db[_0x514f('0xb7')][_0x514f('0x36')]({'where':{'UserId':_0x52569e['params']['id'],'VoiceQueueId':_0x52569e[_0x514f('0x4b')]['ids']},'individualHooks':!![]})[_0x514f('0x22')](function(){return _0x30b3fe;});}return _0x30b3fe;})['then'](respondWithStatusCode(_0x58c211,null))[_0x514f('0x2b')](handleError(_0x58c211,null));};exports[_0x514f('0xb8')]=function(_0x335b2b,_0x2f08b9,_0x10c254){_0x335b2b[_0x514f('0x62')]['userpic']=_0x335b2b['file'][_0x514f('0xb9')];return db[_0x514f('0x59')]['find']({'where':{'id':_0x335b2b[_0x514f('0x5d')]['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x2f08b9,null))[_0x514f('0x22')](saveUpdates(_0x335b2b[_0x514f('0x62')],null))[_0x514f('0x22')](respondWithResult(_0x2f08b9,null))[_0x514f('0x2b')](handleError(_0x2f08b9,null));};exports[_0x514f('0xba')]=function(_0x550c12,_0x5cd6bf,_0x534cc8){var _0x1a3fd7=path[_0x514f('0xbb')](config['root'],_0x514f('0xbc'));return db[_0x514f('0x59')][_0x514f('0x40')]({'where':{'id':_0x550c12['params']['id']},'attributes':['id',_0x514f('0xbd')],'raw':!![]})[_0x514f('0x22')](handleEntityNotFound(_0x5cd6bf,null))['then'](function(_0x46fff9){if(_0x46fff9){if(_['isNil'](_0x46fff9['userpic'])){return _0x5cd6bf['download'](_0x1a3fd7);}else{if(!fs[_0x514f('0xbe')](path[_0x514f('0xbb')](config[_0x514f('0xbf')],_0x514f('0xc0'),_0x46fff9['userpic']))){return _0x5cd6bf['download'](_0x1a3fd7);}return _0x5cd6bf[_0x514f('0xc1')](path[_0x514f('0xbb')](config['root'],_0x514f('0xc0'),_0x46fff9[_0x514f('0xbd')]));}}})[_0x514f('0x2b')](handleError(_0x5cd6bf,null));};exports[_0x514f('0xc2')]=function(_0x5a0fd6,_0x4657de,_0x216377){var _0x2d75a5={};var _0x2eef4a={};var _0x5a4b79;var _0x45e6cc;return db[_0x514f('0x59')]['findOne']({'where':{'id':_0x5a0fd6[_0x514f('0x5d')]['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x4657de,null))['then'](function(_0xd7c47f){if(_0xd7c47f){_0x5a4b79=_0xd7c47f;_0x2eef4a[_0x514f('0x47')]=_[_0x514f('0x4a')](db[_0x514f('0xc3')][_0x514f('0x5e')]);_0x2eef4a[_0x514f('0x4b')]=_[_0x514f('0x4a')](_0x5a0fd6[_0x514f('0x4b')]);_0x2eef4a[_0x514f('0x4c')]=_[_0x514f('0x4d')](_0x2eef4a['model'],_0x2eef4a[_0x514f('0x4b')]);_0x2d75a5[_0x514f('0x4f')]=_['intersection'](_0x2eef4a[_0x514f('0x47')],qs[_0x514f('0x4e')](_0x5a0fd6[_0x514f('0x4b')][_0x514f('0x4e')]));_0x2d75a5[_0x514f('0x4f')]=_0x2d75a5[_0x514f('0x4f')][_0x514f('0x60')]?_0x2d75a5['attributes']:_0x2eef4a['model'];_0x2d75a5[_0x514f('0x51')]=qs['sort'](_0x5a0fd6[_0x514f('0x4b')][_0x514f('0x52')]);_0x2d75a5[_0x514f('0x53')]=qs['filters'](_[_0x514f('0xc4')](_0x5a0fd6['query'],_0x2eef4a['filters']));if(_0x5a0fd6['query'][_0x514f('0x3b')]){_0x2d75a5[_0x514f('0x53')]=_[_0x514f('0x54')](_0x2d75a5[_0x514f('0x53')],{'$or':_[_0x514f('0x3c')](_0x2d75a5[_0x514f('0x4f')],function(_0x5d14f5){var _0x1e7bd3={};_0x1e7bd3[_0x5d14f5]={'$like':'%'+_0x5a0fd6[_0x514f('0x4b')]['filter']+'%'};return _0x1e7bd3;})});}_0x2d75a5=_['merge']({},_0x2d75a5,_0x5a0fd6['options']);return _0x5a4b79[_0x514f('0xc2')](_0x2d75a5);}})['then'](function(_0x3d16eb){if(_0x3d16eb){_0x45e6cc=_0x3d16eb[_0x514f('0x60')];if(_0x5a0fd6[_0x514f('0x4b')][_0x514f('0x50')](_0x514f('0x5a'))){_0x2d75a5['include']=[{'model':db[_0x514f('0xc5')],'as':'List','required':![]},{'model':db[_0x514f('0xc6')],'as':_0x514f('0xc7'),'attributes':['id',_0x514f('0x41'),'color'],'where':_0x5a0fd6['query'][_0x514f('0xc8')]?{'id':_0x5a0fd6[_0x514f('0x4b')][_0x514f('0xc8')]}:undefined,'required':_0x5a0fd6['query'][_0x514f('0xc8')]?!![]:![]}];}if(!_0x5a0fd6[_0x514f('0x4b')]['hasOwnProperty']('nolimit')){_0x2d75a5[_0x514f('0x31')]=qs[_0x514f('0x31')](_0x5a0fd6['query'][_0x514f('0x31')]);_0x2d75a5[_0x514f('0x30')]=qs[_0x514f('0x30')](_0x5a0fd6[_0x514f('0x4b')][_0x514f('0x30')]);}return _0x5a4b79['getContacts'](_0x2d75a5);}})['then'](function(_0x258594){if(_0x258594){return _0x258594?{'count':_0x45e6cc,'rows':_0x258594}:null;}})['then'](respondWithResult(_0x4657de,null))[_0x514f('0x2b')](handleError(_0x4657de,null));};exports[_0x514f('0xc9')]=function(_0x49cf34,_0x721990,_0x2c2ae0){var _0x309e74;var _0x262fa4;var _0x517acd={};var _0x217a8f;return db[_0x514f('0x59')][_0x514f('0x9c')]({'where':{'id':_0x49cf34['params']['id']},'attributes':['id',_0x514f('0x41'),'role']})[_0x514f('0x22')](handleEntityNotFound(_0x721990,null))[_0x514f('0x22')](function(_0x541fc1){if(!utils[_0x514f('0xa8')](_0x49cf34[_0x514f('0x4b')][_0x514f('0xa3')])){throw new db[(_0x514f('0x99'))]['ValidationError'](_0x514f('0xa9'));}_0x309e74=_0x541fc1;var _0x5cab29={};_0x5cab29[_0x514f('0x47')]=_[_0x514f('0x4a')](db[_[_0x514f('0xab')](_0x49cf34[_0x514f('0x4b')]['channel'])+_0x514f('0xca')][_0x514f('0x5e')]);_0x5cab29[_0x514f('0x4b')]=_[_0x514f('0x4a')](_0x49cf34['query']);_0x5cab29[_0x514f('0x4c')]=_[_0x514f('0x4d')](_0x5cab29['model'],_0x5cab29[_0x514f('0x4b')]);_0x517acd['attributes']=_[_0x514f('0x4d')](_0x5cab29[_0x514f('0x47')],qs['fields'](_0x49cf34[_0x514f('0x4b')][_0x514f('0x4e')]));_0x517acd['attributes']=_0x517acd[_0x514f('0x4f')][_0x514f('0x60')]?_0x517acd[_0x514f('0x4f')]:_0x5cab29['model'];_0x517acd[_0x514f('0x51')]=qs[_0x514f('0x52')](_0x49cf34[_0x514f('0x4b')]['sort']);_0x517acd['where']=qs[_0x514f('0x4c')](_[_0x514f('0xc4')](_0x49cf34[_0x514f('0x4b')],_0x5cab29[_0x514f('0x4c')]));if(_0x49cf34['query'][_0x514f('0x3b')]){_0x517acd[_0x514f('0x53')]=_['merge'](_0x517acd[_0x514f('0x53')],{'$or':_['map'](_0x517acd[_0x514f('0x4f')],function(_0x111c7c){var _0x13ee93={};_0x13ee93[_0x111c7c]={'$like':'%'+_0x49cf34[_0x514f('0x4b')]['filter']+'%'};return _0x13ee93;})});}_0x517acd=_[_0x514f('0x54')]({},_0x517acd,_0x49cf34[_0x514f('0x58')]);switch(_0x309e74['role']){case'admin':return db[_[_0x514f('0xab')](_0x49cf34['query']['channel'])+'Queue'][_0x514f('0x5b')](_0x517acd);case'user':case _0x514f('0x72'):return _0x309e74[_0x514f('0x37')+_[_0x514f('0xab')](_0x49cf34[_0x514f('0x4b')][_0x514f('0xa3')])+_0x514f('0xac')](_0x517acd);default:throw new db['Sequelize'][(_0x514f('0x97'))]('Unknown\x20role');}})[_0x514f('0x22')](function(_0x59e370){_0x217a8f=_0x59e370[_0x514f('0x60')];if(!_0x49cf34[_0x514f('0x4b')][_0x514f('0x50')]('nolimit')){_0x517acd['limit']=qs['limit'](_0x49cf34[_0x514f('0x4b')][_0x514f('0x31')]);_0x517acd[_0x514f('0x30')]=qs[_0x514f('0x30')](_0x49cf34[_0x514f('0x4b')]['offset']);}switch(_0x309e74['role']){case'admin':return db[_[_0x514f('0xab')](_0x49cf34['query']['channel'])+'Queue']['findAll'](_0x517acd);case'user':case _0x514f('0x72'):return _0x309e74['get'+_[_0x514f('0xab')](_0x49cf34['query'][_0x514f('0xa3')])+'Queues'](_0x517acd);}})['then'](function(_0x4d9dfb){return{'count':_0x217a8f,'rows':_0x4d9dfb};})[_0x514f('0x22')](respondWithResult(_0x721990,null))[_0x514f('0x2b')](handleError(_0x721990,null));};exports['getVoiceQueuesRt']=function(_0x189460,_0x414927,_0x43570b){var _0x41d2ef={};var _0x1a6c3b={};var _0x440a4d;var _0x3dd480;return db[_0x514f('0x59')][_0x514f('0x9c')]({'where':{'id':_0x189460[_0x514f('0x5d')]['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x414927,null))[_0x514f('0x22')](function(_0x33c777){if(_0x33c777){_0x440a4d=_0x33c777;_0x1a6c3b[_0x514f('0x47')]=_[_0x514f('0x4a')](db['UserVoiceQueueRt']['rawAttributes']);_0x1a6c3b[_0x514f('0x4b')]=_[_0x514f('0x4a')](_0x189460[_0x514f('0x4b')]);_0x1a6c3b[_0x514f('0x4c')]=_[_0x514f('0x4d')](_0x1a6c3b[_0x514f('0x47')],_0x1a6c3b[_0x514f('0x4b')]);_0x41d2ef[_0x514f('0x4f')]=_[_0x514f('0x4d')](_0x1a6c3b[_0x514f('0x47')],qs[_0x514f('0x4e')](_0x189460[_0x514f('0x4b')]['fields']));_0x41d2ef[_0x514f('0x4f')]=_0x41d2ef[_0x514f('0x4f')][_0x514f('0x60')]?_0x41d2ef[_0x514f('0x4f')]:_0x1a6c3b['model'];_0x41d2ef[_0x514f('0x51')]=qs[_0x514f('0x52')](_0x189460[_0x514f('0x4b')][_0x514f('0x52')]);_0x41d2ef[_0x514f('0x53')]=qs[_0x514f('0x4c')](_[_0x514f('0xc4')](_0x189460[_0x514f('0x4b')],_0x1a6c3b[_0x514f('0x4c')]));if(_0x189460[_0x514f('0x4b')]['filter']){_0x41d2ef['where']=_[_0x514f('0x54')](_0x41d2ef['where'],{'$or':_[_0x514f('0x3c')](_0x41d2ef[_0x514f('0x4f')],function(_0x2bfc3c){var _0x3eee61={};_0x3eee61[_0x2bfc3c]={'$like':'%'+_0x189460['query'][_0x514f('0x3b')]+'%'};return _0x3eee61;})});}_0x41d2ef=_['merge']({},_0x41d2ef,_0x189460['options']);return _0x440a4d[_0x514f('0xcb')](_0x41d2ef);}})['then'](function(_0x3e8e18){if(_0x3e8e18){_0x3dd480=_0x3e8e18['length'];if(!_0x189460['query'][_0x514f('0x50')](_0x514f('0xcc'))){_0x41d2ef[_0x514f('0x31')]=qs['limit'](_0x189460[_0x514f('0x4b')]['limit']);_0x41d2ef[_0x514f('0x30')]=qs['offset'](_0x189460[_0x514f('0x4b')]['offset']);}return _0x440a4d[_0x514f('0xcb')](_0x41d2ef);}})['then'](function(_0xdd42fe){if(_0xdd42fe){return _0xdd42fe?{'count':_0x3dd480,'rows':_0xdd42fe}:null;}})[_0x514f('0x22')](respondWithResult(_0x414927,null))[_0x514f('0x2b')](handleError(_0x414927,null));};exports[_0x514f('0xcd')]=function(_0x40c3d8,_0x274173,_0x29ce04){var _0x1e98b1={};var _0xbd1710={};var _0x9ab667;var _0x3d06f2;return db[_0x514f('0x59')][_0x514f('0x9c')]({'where':{'id':_0x40c3d8[_0x514f('0x5d')]['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x274173,null))['then'](function(_0x331fc7){if(_0x331fc7){_0x9ab667=_0x331fc7;_0xbd1710[_0x514f('0x47')]=_[_0x514f('0x4a')](db['ChatGroup'][_0x514f('0x5e')]);_0xbd1710[_0x514f('0x4b')]=_[_0x514f('0x4a')](_0x40c3d8['query']);_0xbd1710['filters']=_[_0x514f('0x4d')](_0xbd1710[_0x514f('0x47')],_0xbd1710[_0x514f('0x4b')]);_0x1e98b1['attributes']=_[_0x514f('0x4d')](_0xbd1710[_0x514f('0x47')],qs[_0x514f('0x4e')](_0x40c3d8[_0x514f('0x4b')][_0x514f('0x4e')]));_0x1e98b1[_0x514f('0x4f')]=_0x1e98b1[_0x514f('0x4f')]['length']?_0x1e98b1[_0x514f('0x4f')]:_0xbd1710[_0x514f('0x47')];_0x1e98b1[_0x514f('0x51')]=qs[_0x514f('0x52')](_0x40c3d8[_0x514f('0x4b')][_0x514f('0x52')]);_0x1e98b1[_0x514f('0x53')]=qs[_0x514f('0x4c')](_[_0x514f('0xc4')](_0x40c3d8[_0x514f('0x4b')],_0xbd1710[_0x514f('0x4c')]));if(_0x40c3d8['query'][_0x514f('0x3b')]){_0x1e98b1[_0x514f('0x53')]=_['merge'](_0x1e98b1['where'],{'$or':_['map'](_0x1e98b1['attributes'],function(_0x2cb490){var _0x16cd46={};_0x16cd46[_0x2cb490]={'$like':'%'+_0x40c3d8[_0x514f('0x4b')][_0x514f('0x3b')]+'%'};return _0x16cd46;})});}_0x1e98b1=_[_0x514f('0x54')]({},_0x1e98b1,_0x40c3d8[_0x514f('0x58')]);return _0x9ab667[_0x514f('0xcd')](_0x1e98b1);}})[_0x514f('0x22')](function(_0x2a1274){if(_0x2a1274){_0x3d06f2=_0x2a1274['length'];if(!_0x40c3d8[_0x514f('0x4b')]['hasOwnProperty']('nolimit')){_0x1e98b1[_0x514f('0x31')]=qs[_0x514f('0x31')](_0x40c3d8[_0x514f('0x4b')][_0x514f('0x31')]);_0x1e98b1[_0x514f('0x30')]=qs['offset'](_0x40c3d8[_0x514f('0x4b')][_0x514f('0x30')]);}return _0x9ab667[_0x514f('0xcd')](_0x1e98b1);}})[_0x514f('0x22')](function(_0x57fe1a){if(_0x57fe1a){return _0x57fe1a?{'count':_0x3d06f2,'rows':_0x57fe1a}:null;}})['then'](respondWithResult(_0x274173,null))[_0x514f('0x2b')](handleError(_0x274173,null));};exports[_0x514f('0xce')]=function(_0x39cc1c,_0x2f0337,_0xba0bb7){var _0x5939bb={'raw':!![],'where':{}};var _0x2a6875={};var _0x568a9d={'count':0x0,'rows':[]};return db[_0x514f('0x59')][_0x514f('0x9c')]({'where':{'id':_0x39cc1c[_0x514f('0x5d')]['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x2f0337,null))['then'](function(_0x1e2126){if(_0x1e2126){_0x2a6875['model']=_['keys'](db['VoiceRecording'][_0x514f('0x5e')]);_0x2a6875[_0x514f('0x4b')]=_['keys'](_0x39cc1c[_0x514f('0x4b')]);_0x2a6875['filters']=_[_0x514f('0x4d')](_0x2a6875[_0x514f('0x47')],_0x2a6875['query']);_0x5939bb[_0x514f('0x4f')]=_['intersection'](_0x2a6875['model'],qs[_0x514f('0x4e')](_0x39cc1c[_0x514f('0x4b')][_0x514f('0x4e')]));_0x5939bb[_0x514f('0x4f')]=_0x5939bb[_0x514f('0x4f')][_0x514f('0x60')]?_0x5939bb[_0x514f('0x4f')]:_0x2a6875[_0x514f('0x47')];if(!_0x39cc1c['query'][_0x514f('0x50')](_0x514f('0xcc'))){_0x5939bb[_0x514f('0x31')]=qs[_0x514f('0x31')](_0x39cc1c[_0x514f('0x4b')][_0x514f('0x31')]);_0x5939bb[_0x514f('0x30')]=qs[_0x514f('0x30')](_0x39cc1c['query'][_0x514f('0x30')]);}_0x5939bb['order']=qs[_0x514f('0x52')](_0x39cc1c['query'][_0x514f('0x52')]);_0x5939bb[_0x514f('0x53')]=qs[_0x514f('0x4c')](_[_0x514f('0xc4')](_0x39cc1c[_0x514f('0x4b')],_0x2a6875['filters']));_0x5939bb['where'][_0x514f('0xcf')]=_0x1e2126['id'];if(_0x39cc1c[_0x514f('0x4b')][_0x514f('0x3b')]){_0x5939bb[_0x514f('0x53')]=_['merge'](_0x5939bb['where'],{'$or':_[_0x514f('0x3c')](_0x5939bb['attributes'],function(_0x4d44cc){var _0x3bfe5d={};_0x3bfe5d[_0x4d44cc]={'$like':'%'+_0x39cc1c['query']['filter']+'%'};return _0x3bfe5d;})});}_0x5939bb=_[_0x514f('0x54')]({},_0x5939bb,_0x39cc1c[_0x514f('0x58')]);return db[_0x514f('0xd0')]['count']({'where':_0x5939bb[_0x514f('0x53')]})[_0x514f('0x22')](function(_0x522e7d){_0x568a9d['count']=_0x522e7d;if(_0x39cc1c[_0x514f('0x4b')][_0x514f('0x5a')]){_0x5939bb[_0x514f('0x61')]=[{'all':!![]}];}return db[_0x514f('0xd0')][_0x514f('0x5b')](_0x5939bb);})[_0x514f('0x22')](function(_0x180c27){_0x568a9d['rows']=_0x180c27;return _0x568a9d;});}})[_0x514f('0x22')](respondWithFilteredResult(_0x2f0337,_0x5939bb))[_0x514f('0x2b')](handleError(_0x2f0337,null));};exports['getScreenRecordings']=function(_0x4045a1,_0x5f1286,_0x2aea6a){var _0x503f99={'raw':!![],'where':{}};var _0x5227f0={};var _0x3ee51c={'count':0x0,'rows':[]};return db[_0x514f('0x59')][_0x514f('0x9c')]({'where':{'id':_0x4045a1[_0x514f('0x5d')]['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x5f1286,null))[_0x514f('0x22')](function(_0x44c62c){if(_0x44c62c){_0x5227f0[_0x514f('0x47')]=_[_0x514f('0x4a')](db['ScreenRecording'][_0x514f('0x5e')]);_0x5227f0[_0x514f('0x4b')]=_[_0x514f('0x4a')](_0x4045a1[_0x514f('0x4b')]);_0x5227f0['filters']=_[_0x514f('0x4d')](_0x5227f0[_0x514f('0x47')],_0x5227f0[_0x514f('0x4b')]);_0x503f99['attributes']=_[_0x514f('0x4d')](_0x5227f0['model'],qs['fields'](_0x4045a1[_0x514f('0x4b')]['fields']));_0x503f99['attributes']=_0x503f99[_0x514f('0x4f')][_0x514f('0x60')]?_0x503f99[_0x514f('0x4f')]:_0x5227f0['model'];if(!_0x4045a1[_0x514f('0x4b')][_0x514f('0x50')](_0x514f('0xcc'))){_0x503f99[_0x514f('0x31')]=qs[_0x514f('0x31')](_0x4045a1[_0x514f('0x4b')]['limit']);_0x503f99[_0x514f('0x30')]=qs[_0x514f('0x30')](_0x4045a1[_0x514f('0x4b')][_0x514f('0x30')]);}_0x503f99[_0x514f('0x51')]=qs[_0x514f('0x52')](_0x4045a1[_0x514f('0x4b')][_0x514f('0x52')]);_0x503f99[_0x514f('0x53')]=qs[_0x514f('0x4c')](_[_0x514f('0xc4')](_0x4045a1[_0x514f('0x4b')],_0x5227f0[_0x514f('0x4c')]));_0x503f99[_0x514f('0x53')][_0x514f('0xcf')]=_0x44c62c['id'];if(_0x4045a1[_0x514f('0x4b')][_0x514f('0x3b')]){_0x503f99[_0x514f('0x53')]=_[_0x514f('0x54')](_0x503f99[_0x514f('0x53')],{'$or':_[_0x514f('0x3c')](_0x503f99[_0x514f('0x4f')],function(_0x52bbaf){var _0xeb3ef7={};_0xeb3ef7[_0x52bbaf]={'$like':'%'+_0x4045a1[_0x514f('0x4b')]['filter']+'%'};return _0xeb3ef7;})});}_0x503f99=_[_0x514f('0x54')]({},_0x503f99,_0x4045a1['options']);return db[_0x514f('0xd1')][_0x514f('0x2f')]({'where':_0x503f99[_0x514f('0x53')]})[_0x514f('0x22')](function(_0x21055a){_0x3ee51c['count']=_0x21055a;if(_0x4045a1[_0x514f('0x4b')]['includeAll']){_0x503f99[_0x514f('0x61')]=[{'all':!![]}];}return db[_0x514f('0xd1')]['findAll'](_0x503f99);})[_0x514f('0x22')](function(_0x1add92){_0x3ee51c[_0x514f('0xd2')]=_0x1add92;return _0x3ee51c;});}})['then'](respondWithFilteredResult(_0x5f1286,_0x503f99))['catch'](handleError(_0x5f1286,null));};exports[_0x514f('0xd3')]=function(_0x5c803f,_0x31073e,_0x307915){var _0x283433={};var _0x309fa7={};var _0x983f8;var _0x118892;return db[_0x514f('0x59')]['findOne']({'where':{'id':_0x5c803f[_0x514f('0x5d')]['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x31073e,null))['then'](function(_0x363c35){if(_0x363c35){_0x983f8=_0x363c35;_0x309fa7[_0x514f('0x47')]=_[_0x514f('0x4a')](db[_0x514f('0xd4')]['rawAttributes']);_0x309fa7[_0x514f('0x4b')]=_[_0x514f('0x4a')](_0x5c803f[_0x514f('0x4b')]);_0x309fa7[_0x514f('0x4c')]=_['intersection'](_0x309fa7[_0x514f('0x47')],_0x309fa7[_0x514f('0x4b')]);_0x283433[_0x514f('0x4f')]=_['intersection'](_0x309fa7[_0x514f('0x47')],qs[_0x514f('0x4e')](_0x5c803f[_0x514f('0x4b')]['fields']));_0x283433['attributes']=_0x283433[_0x514f('0x4f')][_0x514f('0x60')]?_0x283433[_0x514f('0x4f')]:_0x309fa7[_0x514f('0x47')];_0x283433[_0x514f('0x51')]=qs[_0x514f('0x52')](_0x5c803f[_0x514f('0x4b')]['sort']);_0x283433[_0x514f('0x53')]=qs[_0x514f('0x4c')](_['pick'](_0x5c803f[_0x514f('0x4b')],_0x309fa7[_0x514f('0x4c')]));if(_0x5c803f['query'][_0x514f('0x3b')]){_0x283433[_0x514f('0x53')]=_['merge'](_0x283433[_0x514f('0x53')],{'$or':_[_0x514f('0x3c')](_0x283433[_0x514f('0x4f')],function(_0x1e1464){var _0x15f24c={};_0x15f24c[_0x1e1464]={'$like':'%'+_0x5c803f[_0x514f('0x4b')][_0x514f('0x3b')]+'%'};return _0x15f24c;})});}_0x283433=_[_0x514f('0x54')]({},_0x283433,_0x5c803f[_0x514f('0x58')]);return _0x983f8[_0x514f('0xd3')](_0x283433);}})[_0x514f('0x22')](function(_0x1344a9){if(_0x1344a9){_0x118892=_0x1344a9[_0x514f('0x60')];if(!_0x5c803f[_0x514f('0x4b')]['hasOwnProperty']('nolimit')){_0x283433[_0x514f('0x31')]=qs[_0x514f('0x31')](_0x5c803f['query'][_0x514f('0x31')]);_0x283433[_0x514f('0x30')]=qs['offset'](_0x5c803f[_0x514f('0x4b')]['offset']);}return _0x983f8[_0x514f('0xd3')](_0x283433);}})[_0x514f('0x22')](function(_0x591796){if(_0x591796){return _0x591796?{'count':_0x118892,'rows':_0x591796}:null;}})[_0x514f('0x22')](respondWithResult(_0x31073e,null))[_0x514f('0x2b')](handleError(_0x31073e,null));};exports['getOpenchannelInteractions']=function(_0x1ccabf,_0x5baf13,_0x575c8f){var _0x41ac10={};var _0x5a6356={};var _0x2b68d1;var _0x59841c;return db['User'][_0x514f('0x9c')]({'where':{'id':_0x1ccabf[_0x514f('0x5d')]['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x5baf13,null))[_0x514f('0x22')](function(_0x517e8b){if(_0x517e8b){_0x2b68d1=_0x517e8b;_0x5a6356['model']=_[_0x514f('0x4a')](db[_0x514f('0xd5')]['rawAttributes']);_0x5a6356[_0x514f('0x4b')]=_[_0x514f('0x4a')](_0x1ccabf[_0x514f('0x4b')]);_0x5a6356[_0x514f('0x4c')]=_[_0x514f('0x4d')](_0x5a6356[_0x514f('0x47')],_0x5a6356[_0x514f('0x4b')]);_0x41ac10[_0x514f('0x4f')]=_[_0x514f('0x4d')](_0x5a6356[_0x514f('0x47')],qs[_0x514f('0x4e')](_0x1ccabf[_0x514f('0x4b')][_0x514f('0x4e')]));_0x41ac10[_0x514f('0x4f')]=_0x41ac10[_0x514f('0x4f')][_0x514f('0x60')]?_0x41ac10['attributes']:_0x5a6356[_0x514f('0x47')];_0x41ac10[_0x514f('0x51')]=qs['sort'](_0x1ccabf[_0x514f('0x4b')]['sort']);_0x41ac10[_0x514f('0x53')]=qs[_0x514f('0x4c')](_[_0x514f('0xc4')](_0x1ccabf[_0x514f('0x4b')],_0x5a6356[_0x514f('0x4c')]));if(_0x1ccabf[_0x514f('0x4b')][_0x514f('0x3b')]){_0x41ac10[_0x514f('0x53')]=_[_0x514f('0x54')](_0x41ac10['where'],{'$or':_[_0x514f('0x3c')](_0x41ac10[_0x514f('0x4f')],function(_0x648f0b){var _0x215757={};_0x215757[_0x648f0b]={'$like':'%'+_0x1ccabf[_0x514f('0x4b')]['filter']+'%'};return _0x215757;})});}_0x41ac10=_[_0x514f('0x54')]({},_0x41ac10,_0x1ccabf['options']);return _0x2b68d1[_0x514f('0xd6')](_0x41ac10);}})[_0x514f('0x22')](function(_0x215898){if(_0x215898){_0x59841c=_0x215898[_0x514f('0x60')];if(!_0x1ccabf[_0x514f('0x4b')]['hasOwnProperty'](_0x514f('0xcc'))){_0x41ac10[_0x514f('0x31')]=qs[_0x514f('0x31')](_0x1ccabf[_0x514f('0x4b')][_0x514f('0x31')]);_0x41ac10['offset']=qs[_0x514f('0x30')](_0x1ccabf[_0x514f('0x4b')][_0x514f('0x30')]);}return _0x2b68d1[_0x514f('0xd6')](_0x41ac10);}})[_0x514f('0x22')](function(_0x649200){if(_0x649200){return _0x649200?{'count':_0x59841c,'rows':_0x649200}:null;}})[_0x514f('0x22')](respondWithResult(_0x5baf13,null))[_0x514f('0x2b')](handleError(_0x5baf13,null));};exports[_0x514f('0xd7')]=function(_0x3431e3,_0x45e3c0,_0xc8331b){var _0x4d6c9f={'raw':!![],'where':{}};var _0x324a14={};var _0x4e8552={'count':0x0,'rows':[]};return db[_0x514f('0x59')][_0x514f('0x9c')]({'where':{'id':_0x3431e3[_0x514f('0x5d')]['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x45e3c0,null))[_0x514f('0x22')](function(_0x33dfc1){if(_0x33dfc1){_0x324a14[_0x514f('0x47')]=_[_0x514f('0x4a')](db[_0x514f('0xd8')][_0x514f('0x5e')]);_0x324a14[_0x514f('0x4b')]=_[_0x514f('0x4a')](_0x3431e3[_0x514f('0x4b')]);_0x324a14['filters']=_['intersection'](_0x324a14[_0x514f('0x47')],_0x324a14['query']);_0x4d6c9f[_0x514f('0x4f')]=_[_0x514f('0x4d')](_0x324a14[_0x514f('0x47')],qs['fields'](_0x3431e3[_0x514f('0x4b')][_0x514f('0x4e')]));_0x4d6c9f[_0x514f('0x4f')]=_0x4d6c9f['attributes'][_0x514f('0x60')]?_0x4d6c9f[_0x514f('0x4f')]:_0x324a14[_0x514f('0x47')];if(!_0x3431e3[_0x514f('0x4b')][_0x514f('0x50')](_0x514f('0xcc'))){_0x4d6c9f[_0x514f('0x31')]=qs[_0x514f('0x31')](_0x3431e3[_0x514f('0x4b')][_0x514f('0x31')]);_0x4d6c9f['offset']=qs[_0x514f('0x30')](_0x3431e3[_0x514f('0x4b')][_0x514f('0x30')]);}_0x4d6c9f['order']=qs[_0x514f('0x52')](_0x3431e3[_0x514f('0x4b')][_0x514f('0x52')]);_0x4d6c9f[_0x514f('0x53')]=qs[_0x514f('0x4c')](_[_0x514f('0xc4')](_0x3431e3['query'],_0x324a14['filters']));_0x4d6c9f['where'][_0x514f('0xcf')]=_0x33dfc1['id'];if(_0x3431e3[_0x514f('0x4b')][_0x514f('0x3b')]){_0x4d6c9f['where']=_['merge'](_0x4d6c9f['where'],{'$or':_[_0x514f('0x3c')](_0x4d6c9f['attributes'],function(_0x1a7ec6){var _0x5d9e73={};_0x5d9e73[_0x1a7ec6]={'$like':'%'+_0x3431e3[_0x514f('0x4b')][_0x514f('0x3b')]+'%'};return _0x5d9e73;})});}_0x4d6c9f=_[_0x514f('0x54')]({},_0x4d6c9f,_0x3431e3['options']);return db['MailInteraction'][_0x514f('0x2f')]({'where':_0x4d6c9f[_0x514f('0x53')]})[_0x514f('0x22')](function(_0x43beba){_0x4e8552['count']=_0x43beba;if(_0x3431e3[_0x514f('0x4b')]['includeAll']){_0x4d6c9f[_0x514f('0x61')]=[{'all':!![]}];}return db[_0x514f('0xd8')][_0x514f('0x5b')](_0x4d6c9f);})['then'](function(_0x11a084){_0x4e8552['rows']=_0x11a084;return _0x4e8552;});}})[_0x514f('0x22')](respondWithFilteredResult(_0x45e3c0,_0x4d6c9f))[_0x514f('0x2b')](handleError(_0x45e3c0,null));};exports[_0x514f('0xd9')]=function(_0x4d5a8d,_0x204b6a,_0xb623d5){var _0x56ca1c={};var _0x273220={};var _0xb03956;var _0x389f3a;return db[_0x514f('0x59')]['findOne']({'where':{'id':_0x4d5a8d[_0x514f('0x5d')]['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x204b6a,null))[_0x514f('0x22')](function(_0x575e3e){if(_0x575e3e){_0xb03956=_0x575e3e;_0x273220[_0x514f('0x47')]=_[_0x514f('0x4a')](db['SmsInteraction'][_0x514f('0x5e')]);_0x273220['query']=_['keys'](_0x4d5a8d[_0x514f('0x4b')]);_0x273220[_0x514f('0x4c')]=_[_0x514f('0x4d')](_0x273220['model'],_0x273220[_0x514f('0x4b')]);_0x56ca1c[_0x514f('0x4f')]=_[_0x514f('0x4d')](_0x273220[_0x514f('0x47')],qs[_0x514f('0x4e')](_0x4d5a8d[_0x514f('0x4b')][_0x514f('0x4e')]));_0x56ca1c['attributes']=_0x56ca1c['attributes'][_0x514f('0x60')]?_0x56ca1c[_0x514f('0x4f')]:_0x273220['model'];_0x56ca1c['order']=qs[_0x514f('0x52')](_0x4d5a8d[_0x514f('0x4b')][_0x514f('0x52')]);_0x56ca1c[_0x514f('0x53')]=qs[_0x514f('0x4c')](_['pick'](_0x4d5a8d['query'],_0x273220['filters']));if(_0x4d5a8d[_0x514f('0x4b')][_0x514f('0x3b')]){_0x56ca1c[_0x514f('0x53')]=_[_0x514f('0x54')](_0x56ca1c[_0x514f('0x53')],{'$or':_[_0x514f('0x3c')](_0x56ca1c['attributes'],function(_0x372fac){var _0x1614d3={};_0x1614d3[_0x372fac]={'$like':'%'+_0x4d5a8d[_0x514f('0x4b')][_0x514f('0x3b')]+'%'};return _0x1614d3;})});}_0x56ca1c=_[_0x514f('0x54')]({},_0x56ca1c,_0x4d5a8d[_0x514f('0x58')]);return _0xb03956['getSmsInteractions'](_0x56ca1c);}})[_0x514f('0x22')](function(_0x45613c){if(_0x45613c){_0x389f3a=_0x45613c['length'];if(!_0x4d5a8d['query'][_0x514f('0x50')]('nolimit')){_0x56ca1c['limit']=qs[_0x514f('0x31')](_0x4d5a8d[_0x514f('0x4b')][_0x514f('0x31')]);_0x56ca1c[_0x514f('0x30')]=qs['offset'](_0x4d5a8d[_0x514f('0x4b')][_0x514f('0x30')]);}return _0xb03956[_0x514f('0xd9')](_0x56ca1c);}})['then'](function(_0x5612d6){if(_0x5612d6){return _0x5612d6?{'count':_0x389f3a,'rows':_0x5612d6}:null;}})[_0x514f('0x22')](respondWithResult(_0x204b6a,null))[_0x514f('0x2b')](handleError(_0x204b6a,null));};exports[_0x514f('0xda')]=function(_0x39207e,_0x1b513f,_0x4a37d7){var _0x4c9f77={};var _0x395d38={};var _0x4c943a;var _0x168289;return db[_0x514f('0x59')][_0x514f('0x9c')]({'where':{'id':_0x39207e[_0x514f('0x5d')]['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x1b513f,null))[_0x514f('0x22')](function(_0x12bb87){if(_0x12bb87){_0x4c943a=_0x12bb87;_0x395d38[_0x514f('0x47')]=_[_0x514f('0x4a')](db['FaxInteraction'][_0x514f('0x5e')]);_0x395d38[_0x514f('0x4b')]=_['keys'](_0x39207e[_0x514f('0x4b')]);_0x395d38[_0x514f('0x4c')]=_[_0x514f('0x4d')](_0x395d38[_0x514f('0x47')],_0x395d38[_0x514f('0x4b')]);_0x4c9f77[_0x514f('0x4f')]=_[_0x514f('0x4d')](_0x395d38[_0x514f('0x47')],qs[_0x514f('0x4e')](_0x39207e[_0x514f('0x4b')][_0x514f('0x4e')]));_0x4c9f77[_0x514f('0x4f')]=_0x4c9f77[_0x514f('0x4f')][_0x514f('0x60')]?_0x4c9f77['attributes']:_0x395d38['model'];_0x4c9f77['order']=qs['sort'](_0x39207e['query'][_0x514f('0x52')]);_0x4c9f77[_0x514f('0x53')]=qs[_0x514f('0x4c')](_['pick'](_0x39207e[_0x514f('0x4b')],_0x395d38[_0x514f('0x4c')]));if(_0x39207e[_0x514f('0x4b')][_0x514f('0x3b')]){_0x4c9f77[_0x514f('0x53')]=_[_0x514f('0x54')](_0x4c9f77['where'],{'$or':_['map'](_0x4c9f77[_0x514f('0x4f')],function(_0xec376d){var _0x8318e1={};_0x8318e1[_0xec376d]={'$like':'%'+_0x39207e[_0x514f('0x4b')]['filter']+'%'};return _0x8318e1;})});}_0x4c9f77=_[_0x514f('0x54')]({},_0x4c9f77,_0x39207e[_0x514f('0x58')]);return _0x4c943a['getFaxInteractions'](_0x4c9f77);}})['then'](function(_0x3411c0){if(_0x3411c0){_0x168289=_0x3411c0[_0x514f('0x60')];if(!_0x39207e[_0x514f('0x4b')][_0x514f('0x50')]('nolimit')){_0x4c9f77['limit']=qs[_0x514f('0x31')](_0x39207e[_0x514f('0x4b')][_0x514f('0x31')]);_0x4c9f77[_0x514f('0x30')]=qs[_0x514f('0x30')](_0x39207e['query'][_0x514f('0x30')]);}return _0x4c943a[_0x514f('0xda')](_0x4c9f77);}})['then'](function(_0x259d61){if(_0x259d61){return _0x259d61?{'count':_0x168289,'rows':_0x259d61}:null;}})[_0x514f('0x22')](respondWithResult(_0x1b513f,null))[_0x514f('0x2b')](handleError(_0x1b513f,null));};exports[_0x514f('0xdb')]=function(_0xae5ce3,_0x179765,_0x44c80b){var _0x5648e2={};var _0x1aa47c={};var _0x3de01a;var _0x1738a5;return db[_0x514f('0x59')][_0x514f('0x9c')]({'where':{'id':_0xae5ce3[_0x514f('0x5d')]['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x179765,null))[_0x514f('0x22')](function(_0x1c44ac){if(_0x1c44ac){_0x3de01a=_0x1c44ac;_0x1aa47c[_0x514f('0x47')]=_[_0x514f('0x4a')](db[_0x514f('0xdc')]['rawAttributes']);_0x1aa47c['query']=_[_0x514f('0x4a')](_0xae5ce3['query']);_0x1aa47c[_0x514f('0x4c')]=_[_0x514f('0x4d')](_0x1aa47c['model'],_0x1aa47c[_0x514f('0x4b')]);_0x5648e2[_0x514f('0x4f')]=_[_0x514f('0x4d')](_0x1aa47c['model'],qs[_0x514f('0x4e')](_0xae5ce3[_0x514f('0x4b')][_0x514f('0x4e')]));_0x5648e2['attributes']=_0x5648e2[_0x514f('0x4f')][_0x514f('0x60')]?_0x5648e2['attributes']:_0x1aa47c[_0x514f('0x47')];_0x5648e2[_0x514f('0x51')]=qs[_0x514f('0x52')](_0xae5ce3[_0x514f('0x4b')][_0x514f('0x52')]);_0x5648e2[_0x514f('0x53')]=qs['filters'](_[_0x514f('0xc4')](_0xae5ce3['query'],_0x1aa47c['filters']));if(_0xae5ce3['query'][_0x514f('0x3b')]){_0x5648e2['where']=_['merge'](_0x5648e2[_0x514f('0x53')],{'$or':_['map'](_0x5648e2['attributes'],function(_0x377320){var _0x2b6d4c={};_0x2b6d4c[_0x377320]={'$like':'%'+_0xae5ce3['query']['filter']+'%'};return _0x2b6d4c;})});}_0x5648e2=_[_0x514f('0x54')]({},_0x5648e2,_0xae5ce3[_0x514f('0x58')]);return _0x3de01a[_0x514f('0xdb')](_0x5648e2);}})[_0x514f('0x22')](function(_0x28c4d8){if(_0x28c4d8){_0x1738a5=_0x28c4d8[_0x514f('0x60')];if(!_0xae5ce3[_0x514f('0x4b')][_0x514f('0x50')]('nolimit')){_0x5648e2[_0x514f('0x31')]=qs[_0x514f('0x31')](_0xae5ce3[_0x514f('0x4b')][_0x514f('0x31')]);_0x5648e2['offset']=qs['offset'](_0xae5ce3[_0x514f('0x4b')][_0x514f('0x30')]);}return _0x3de01a['getWhatsappInteractions'](_0x5648e2);}})[_0x514f('0x22')](function(_0x555e62){if(_0x555e62){return _0x555e62?{'count':_0x1738a5,'rows':_0x555e62}:null;}})[_0x514f('0x22')](respondWithResult(_0x179765,null))[_0x514f('0x2b')](handleError(_0x179765,null));};exports['login']=function(_0x5bc1b0,_0x415942,_0x3c2c84){var _0x527536;var _0x330e39;var _0x4ad670;var _0x34ff87=!_[_0x514f('0x69')](_0x5bc1b0[_0x514f('0x5d')]['id'])?_0x5bc1b0[_0x514f('0x5d')]['id']:!_[_0x514f('0x69')](_0x5bc1b0[_0x514f('0x7f')]['id'])?_0x5bc1b0['user']['id']:null;return db[_0x514f('0x59')]['find']({'where':{'id':_0x34ff87,'role':{'$or':['admin',_0x514f('0x7f'),_0x514f('0x72')]}},'attributes':['id',_0x514f('0x41'),_0x514f('0xdd'),_0x514f('0xde'),'role','internal','loginInPause']})[_0x514f('0x22')](function(_0x107aea){if(_0x107aea){if(_0x107aea[_0x514f('0x3f')]===_0x514f('0x72')){_0x527536=_0x107aea;if(_0x5bc1b0[_0x514f('0x62')][_0x514f('0xa7')]){_0x4ad670=util[_0x514f('0xb3')](_0x514f('0xdf'),_0x527536[_0x5bc1b0[_0x514f('0x62')]['interface']]);}else if(_0x5bc1b0['body'][_0x514f('0xe0')]){_0x4ad670=util[_0x514f('0xb3')](_0x514f('0xb4'),_0x5bc1b0[_0x514f('0x62')]['intrf']);}else{_0x4ad670=util[_0x514f('0xb3')](_0x514f('0xb4'),_0x527536[_0x514f('0x41')]);}socket['to'](util[_0x514f('0xb3')]('user:%s',_0x527536[_0x514f('0x41')]))[_0x514f('0xb0')](_0x514f('0xe1'),{'ip':_0x5bc1b0[_0x514f('0xe2')][_0x514f('0xe3')]||_0x5bc1b0[_0x514f('0xe4')][_0x514f('0xe5')]||_0x5bc1b0[_0x514f('0xe6')][_0x514f('0xe5')]||_0x5bc1b0['connection'][_0x514f('0xe6')][_0x514f('0xe5')]});return db['UserVoiceQueueRt'][_0x514f('0x36')]({'where':{'membername':_0x527536[_0x514f('0x41')]},'individualHooks':!![]});}}else{throw new db[(_0x514f('0x99'))][(_0x514f('0x97'))](_0x514f('0xe7'));}})[_0x514f('0x22')](function(){if(_0x527536){return _0x527536[_0x514f('0xe8')]({'raw':!![]});}})[_0x514f('0x22')](function(_0x19372e){if(_0x527536){var _0x4f5437=[];if(_0x19372e){_0x330e39=_0x19372e;if(_0x330e39[_0x514f('0x60')]){for(var _0x16dc16=0x0;_0x16dc16<_0x330e39['length'];_0x16dc16++){_0x4f5437[_0x514f('0x8b')]({'membername':_0x527536['name'],'UserId':_0x527536['id'],'queue_name':_0x330e39[_0x16dc16][_0x514f('0x41')],'VoiceQueueId':_0x330e39[_0x16dc16]['id'],'interface':_0x4ad670,'paused':_0x527536['loginInPause']||![],'penalty':_0x330e39[_0x16dc16]['UserVoiceQueue.penalty']||0x0});}return BPromise['each'](_0x4f5437,function(_0x50b7d9){return db[_0x514f('0xb7')]['upsert'](_0x50b7d9);});}}}})[_0x514f('0x22')](function(){if(_0x527536){return db[_0x514f('0xe9')][_0x514f('0x5b')]({'where':{'membername':_0x527536['name'],'exitAt':null}});}})[_0x514f('0x22')](function(_0x436f12){if(_0x527536){var _0x4f31e9=[];_0x436f12[_0x514f('0xea')](function(_0x128c14){_0x4f31e9[_0x514f('0x8b')](_0x128c14[_0x514f('0x35')]({'exitAt':moment()[_0x514f('0xb3')](_0x514f('0xeb'))}));});return BPromise['all'](_0x4f31e9);}})[_0x514f('0x22')](function(){if(_0x527536){var _0x4b471a=[];var _0x222ce9=[];var _0x10e620=utils[_0x514f('0xec')]();var _0x59a59b={'membername':_0x527536[_0x514f('0x41')],'interface':_0x4ad670,'enterAt':moment()[_0x514f('0xb3')](_0x514f('0xeb')),'role':_0x527536[_0x514f('0x3f')],'internal':_0x527536['internal']};_0x10e620[_0x514f('0xea')](function(_0x1677d4){_0x4b471a[_0x514f('0x8b')](_[_0x514f('0x54')]({'channel':_0x1677d4,'type':_0x514f('0xed'),'data1':_0x5bc1b0[_0x514f('0x62')]['device'],'data2':_0x4ad670},_0x59a59b));if(_0x527536[_0x514f('0xa5')]){_0x222ce9[_0x514f('0x8b')](_[_0x514f('0x54')]({'channel':_0x1677d4,'type':_0x514f('0xee'),'data1':_0x514f('0xef')},_0x59a59b));}});return db[_0x514f('0xe9')][_0x514f('0xf0')](_0x4b471a['concat'](_0x222ce9),{'individualHooks':!![]});}})[_0x514f('0x22')](function(){if(_0x527536){return _0x527536['update']({'online':!![],'lastLoginAt':moment()['format'](_0x514f('0xeb')),'voicePause':_0x527536['loginInPause']||![],'mailPause':_0x527536[_0x514f('0xa5')]||![],'chatPause':_0x527536[_0x514f('0xa5')]||![],'faxPause':_0x527536[_0x514f('0xa5')]||![],'smsPause':_0x527536['loginInPause']||![],'openchannelPause':_0x527536['loginInPause']||![],'whatsappPause':_0x527536[_0x514f('0xa5')]||![],'pauseType':_0x527536['loginInPause']?_0x514f('0xef'):null,'interface':_0x4ad670,'lastPauseAt':moment()[_0x514f('0xb3')](_0x514f('0xeb'))});}})[_0x514f('0x22')](function(_0xc742fe){if(_0x5bc1b0[_0x514f('0xf1')]){return _0x3c2c84();}else{return BPromise[_0x514f('0xf2')](_0xc742fe)[_0x514f('0x22')](respondWithResult(_0x415942,null));}})[_0x514f('0x2b')](handleError(_0x415942,null));};exports['logout']=function(_0x5c8a36,_0x426e88,_0x39096c){var _0x3dc863;return db['User'][_0x514f('0x40')]({'where':{'id':_0x5c8a36['params']['id'],'role':_0x514f('0x72')},'attributes':['id',_0x514f('0x41'),_0x514f('0x3f')]})['then'](handleEntityNotFound(_0x426e88,null))[_0x514f('0x22')](function(_0x2038c9){if(_0x2038c9){_0x3dc863=_0x2038c9;return db['UserVoiceQueueRt'][_0x514f('0x36')]({'where':{'membername':_0x3dc863[_0x514f('0x41')]},'individualHooks':!![]});}})[_0x514f('0x22')](function(){return db[_0x514f('0xe9')][_0x514f('0x5b')]({'where':{'membername':_0x3dc863[_0x514f('0x41')],'exitAt':null}});})[_0x514f('0x22')](function(_0x18c07b){var _0x5d1c98=[];_0x18c07b[_0x514f('0xea')](function(_0x405c28){_0x5d1c98['push'](_0x405c28[_0x514f('0x35')]({'exitAt':moment()[_0x514f('0xb3')](_0x514f('0xeb'))}));});return BPromise[_0x514f('0x8c')](_0x5d1c98);})[_0x514f('0x22')](function(){return _0x3dc863['update']({'online':![],'lastLoginAt':null,'voicePause':![],'mailPause':![],'chatPause':![],'faxPause':![],'smsPause':![],'openchannelPause':![],'whatsappPause':![],'interface':null});})[_0x514f('0x22')](respondWithResult(_0x426e88,null))['catch'](handleError(_0x426e88,null));};exports[_0x514f('0xf3')]=function(_0xe175af,_0x3805d8,_0x4533b3){var _0x4dd53c;return db[_0x514f('0xb7')][_0x514f('0x35')]({'paused':0x1},{'where':{'UserId':_0xe175af[_0x514f('0x5d')]['id']},'individualHooks':!![]})[_0x514f('0x22')](function(){return db[_0x514f('0x59')][_0x514f('0x40')]({'where':{'id':_0xe175af[_0x514f('0x5d')]['id'],'role':'agent'},'attributes':['id',_0x514f('0x41'),_0x514f('0x3f'),_0x514f('0x6a'),_0x514f('0xa7')]});})[_0x514f('0x22')](handleEntityNotFound(_0x3805d8,null))[_0x514f('0x22')](function(_0x229ade){if(_0x229ade){_0x4dd53c=_0x229ade;return respondWithRpcPromise(_0x514f('0xf4'),'pause',{'id':_0x4dd53c['id'],'name':_0x4dd53c[_0x514f('0x41')],'pause':!![]});}})[_0x514f('0x22')](function(){if(_0x4dd53c){return db[_0x514f('0xe9')][_0x514f('0x5b')]({'where':{'membername':_0x4dd53c[_0x514f('0x41')],'type':'PAUSE','exitAt':null}});}})[_0x514f('0x22')](function(_0x4a953b){if(_0x4a953b[_0x514f('0x60')]){var _0x1c9557=moment()[_0x514f('0xb3')]('YYYY-MM-DD\x20HH:mm:ss');for(var _0x31b2f2=0x0,_0x2e9d5c=_0x4a953b[_0x514f('0x60')];_0x31b2f2<_0x2e9d5c;_0x31b2f2++){_0x4a953b[_0x31b2f2][_0x514f('0xf5')]({'exitAt':_0x1c9557});}}})[_0x514f('0x22')](function(){var _0x521302=[];var _0x505983=utils['getChannels']();_0x505983[_0x514f('0xea')](function(_0x13087a){_0x521302['push']({'channel':_0x13087a,'membername':_0x4dd53c[_0x514f('0x41')],'interface':_[_0x514f('0x69')](_0x4dd53c[_0x514f('0xa7')])?util['format']('SIP/%s',_0x4dd53c[_0x514f('0x41')]):_0x4dd53c['interface'],'type':'PAUSE','enterAt':moment()['format'](_0x514f('0xeb')),'data1':_0xe175af['body'][_0x514f('0x45')]||_0x514f('0xf6'),'role':_0x4dd53c[_0x514f('0x3f')],'internal':_0x4dd53c[_0x514f('0x6a')]});});return db['MemberReport']['bulkCreate'](_0x521302,{'individualHooks':!![]});})['then'](function(){return _0x4dd53c[_0x514f('0x35')]({'voicePause':!![],'mailPause':!![],'chatPause':!![],'faxPause':!![],'smsPause':!![],'whatsappPause':!![],'openchannelPause':!![],'pauseType':_0xe175af[_0x514f('0x62')][_0x514f('0x45')]||'DEFAULT\x20PAUSE','lastPauseAt':moment()['format'](_0x514f('0xeb'))});})['then'](respondWithResult(_0x3805d8,null))[_0x514f('0x2b')](handleError(_0x3805d8,null));};exports[_0x514f('0xf7')]=function(_0x32f91e,_0x364775,_0x40456a){var _0x29fe44;return db[_0x514f('0x59')]['find']({'where':{'id':_0x32f91e['params']['id']},'attributes':['id','name',_0x514f('0x3f'),'voicePause',_0x514f('0xf8'),_0x514f('0xf9'),_0x514f('0xfa'),_0x514f('0xfb'),_0x514f('0xfc'),'whatsapppause','pauseType',_0x514f('0xfd')]})['then'](handleEntityNotFound(_0x364775,null))[_0x514f('0x22')](function(_0x981684){if(_0x981684){_0x29fe44=_0x981684;if(_0x32f91e[_0x514f('0x62')][_0x514f('0xa3')]&&!utils[_0x514f('0xa8')](_0x32f91e[_0x514f('0x62')]['channel'])){throw new db['Sequelize'][(_0x514f('0x97'))](_0x514f('0xa9'));}switch(_0x32f91e[_0x514f('0x62')][_0x514f('0xa3')]){case _0x514f('0xb1'):return respondWithRpcPromise('QueuePause',_0x514f('0xf7'),{'id':_0x29fe44['id'],'name':_0x29fe44[_0x514f('0x41')],'pause':![]})['then'](function(){return db[_0x514f('0xb7')][_0x514f('0x35')]({'paused':0x0},{'where':{'UserId':_0x29fe44['id']},'individualHooks':!![]});})[_0x514f('0x22')](function(){return db[_0x514f('0xe9')][_0x514f('0x40')]({'where':{'channel':_0x32f91e['body'][_0x514f('0xa3')],'membername':_0x29fe44[_0x514f('0x41')],'type':_0x514f('0xee'),'exitAt':null}});})[_0x514f('0x22')](function(_0x54ad5d){if(_0x54ad5d){return _0x54ad5d[_0x514f('0x35')]({'exitAt':moment()[_0x514f('0xb3')](_0x514f('0xeb')),'data2':'manual'},{'individualHooks':!![]});}return null;})[_0x514f('0x22')](function(){return _0x29fe44[_0x514f('0x35')]({'voicePause':![]});});case'mail':case _0x514f('0xfe'):case _0x514f('0xff'):case'sms':case _0x514f('0x100'):case _0x514f('0x101'):return db[_0x514f('0xe9')][_0x514f('0x40')]({'where':{'channel':_0x32f91e[_0x514f('0x62')]['channel'],'membername':_0x29fe44[_0x514f('0x41')],'type':_0x514f('0xee'),'exitAt':null}})[_0x514f('0x22')](function(_0x11a48e){if(_0x11a48e){return _0x11a48e[_0x514f('0x35')]({'exitAt':moment()[_0x514f('0xb3')](_0x514f('0xeb')),'data2':_0x514f('0x102')},{'individualHooks':!![]});}return null;})[_0x514f('0x22')](function(){var _0x306bd2={};_[_0x514f('0x103')](_0x306bd2,util['format'](_0x514f('0x104'),_0x32f91e['body']['channel'],_0x514f('0x105')),![]);return _0x29fe44[_0x514f('0x35')](_0x306bd2);});default:return respondWithRpcPromise('QueuePause','unpause',{'id':_0x29fe44['id'],'name':_0x29fe44[_0x514f('0x41')],'pause':![]})[_0x514f('0x22')](function(){return db[_0x514f('0xb7')][_0x514f('0x35')]({'paused':0x0},{'where':{'UserId':_0x29fe44['id']}});})[_0x514f('0x22')](function(){return db[_0x514f('0xe9')]['findAll']({'where':{'membername':_0x29fe44['name'],'type':'PAUSE','exitAt':null}});})[_0x514f('0x22')](function(_0xc8b5b7){var _0x191c2b=[];_0xc8b5b7[_0x514f('0xea')](function(_0x2fd2f9){_0x191c2b[_0x514f('0x8b')](_0x2fd2f9[_0x514f('0x35')]({'exitAt':moment()[_0x514f('0xb3')](_0x514f('0xeb')),'data2':_0x514f('0x102')}));});return BPromise[_0x514f('0x8c')](_0x191c2b);})[_0x514f('0x22')](function(){return _0x29fe44[_0x514f('0x35')]({'voicePause':![],'mailPause':![],'chatPause':![],'faxPause':![],'smsPause':![],'whatsappPause':![],'openchannelPause':![]});});}}})[_0x514f('0x22')](respondWithResult(_0x364775,null))[_0x514f('0x2b')](handleError(_0x364775,null));};exports[_0x514f('0x106')]=function(_0x5f2e25,_0x2d5b53,_0x3a9984){var _0x348a6b={};var _0x535bc9={};var _0x52b213;var _0x67349f;return db[_0x514f('0x59')][_0x514f('0x9c')]({'where':{'id':_0x5f2e25['params']['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x2d5b53,null))['then'](function(_0x165a1a){if(_0x165a1a){_0x52b213=_0x165a1a;_0x535bc9['model']=_[_0x514f('0x4a')](db[_0x514f('0x107')][_0x514f('0x5e')]);_0x535bc9['query']=_[_0x514f('0x4a')](_0x5f2e25[_0x514f('0x4b')]);_0x535bc9['filters']=_['intersection'](_0x535bc9['model'],_0x535bc9[_0x514f('0x4b')]);_0x348a6b[_0x514f('0x4f')]=_[_0x514f('0x4d')](_0x535bc9['model'],qs['fields'](_0x5f2e25[_0x514f('0x4b')][_0x514f('0x4e')]));_0x348a6b[_0x514f('0x4f')]=_0x348a6b[_0x514f('0x4f')]['length']?_0x348a6b['attributes']:_0x535bc9[_0x514f('0x47')];_0x348a6b['order']=qs[_0x514f('0x52')](_0x5f2e25[_0x514f('0x4b')][_0x514f('0x52')]);_0x348a6b[_0x514f('0x53')]=qs[_0x514f('0x4c')](_[_0x514f('0xc4')](_0x5f2e25[_0x514f('0x4b')],_0x535bc9[_0x514f('0x4c')]));if(_0x5f2e25['query'][_0x514f('0x3b')]){_0x348a6b[_0x514f('0x53')]=_['merge'](_0x348a6b[_0x514f('0x53')],{'$or':_[_0x514f('0x3c')](_0x348a6b[_0x514f('0x4f')],function(_0x5c31b3){var _0xe32bbc={};_0xe32bbc[_0x5c31b3]={'$like':'%'+_0x5f2e25[_0x514f('0x4b')][_0x514f('0x3b')]+'%'};return _0xe32bbc;})});}_0x348a6b=_[_0x514f('0x54')]({},_0x348a6b,_0x5f2e25[_0x514f('0x58')]);return _0x52b213[_0x514f('0x106')](_0x348a6b);}})[_0x514f('0x22')](function(_0xb8f7c7){if(_0xb8f7c7){_0x67349f=_0xb8f7c7[_0x514f('0x60')];if(!_0x5f2e25[_0x514f('0x4b')][_0x514f('0x50')]('nolimit')){_0x348a6b['limit']=qs[_0x514f('0x31')](_0x5f2e25['query']['limit']);_0x348a6b['offset']=qs[_0x514f('0x30')](_0x5f2e25[_0x514f('0x4b')][_0x514f('0x30')]);}return _0x52b213[_0x514f('0x106')](_0x348a6b);}})[_0x514f('0x22')](function(_0x56f48c){if(_0x56f48c){return _0x56f48c?{'count':_0x67349f,'rows':_0x56f48c}:null;}})[_0x514f('0x22')](respondWithResult(_0x2d5b53,null))[_0x514f('0x2b')](handleError(_0x2d5b53,null));};exports[_0x514f('0x108')]=function(_0x39efb2,_0x37020){return db['User'][_0x514f('0x40')]({'where':{'id':_0x39efb2[_0x514f('0x5d')]['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x37020,null))['then'](function(_0x18473d){if(_0x18473d){var _0x2ce879=_0x18473d[_0x514f('0x37')]({'plain':!![]});return _0x18473d[_0x514f('0x108')](_0x39efb2[_0x514f('0x62')][_0x514f('0x65')],_[_0x514f('0x109')](_0x39efb2[_0x514f('0x62')],[_0x514f('0x65'),'id'])||{})[_0x514f('0x22')](function(){for(var _0xafd160=0x0;_0xafd160<_0x39efb2[_0x514f('0x62')][_0x514f('0x65')][_0x514f('0x60')];_0xafd160++){var _0x51cd54=[];db[_0x514f('0x107')][_0x514f('0x9c')]({'where':{'id':_0x39efb2['body'][_0x514f('0x65')][_0xafd160]}})[_0x514f('0x22')](function(_0x5c7aa4){_0x51cd54['push'](_0x5c7aa4[_0x514f('0xe8')]()[_0x514f('0x22')](function(_0x4a424f){for(var _0x5caac7=0x0;_0x5caac7<_0x4a424f[_0x514f('0x60')];_0x5caac7++){_0x4a424f[_0x5caac7]['setDataValue'](_0x514f('0xa3'),_0x514f('0x10a'));}return _0x4a424f;}));_0x51cd54[_0x514f('0x8b')](_0x5c7aa4['getChatQueues']()[_0x514f('0x22')](function(_0x32f11a){for(var _0x57dfd4=0x0;_0x57dfd4<_0x32f11a[_0x514f('0x60')];_0x57dfd4++){_0x32f11a[_0x57dfd4][_0x514f('0x10b')](_0x514f('0xa3'),_0x514f('0x10c'));}return _0x32f11a;}));_0x51cd54[_0x514f('0x8b')](_0x5c7aa4['getMailQueues']()[_0x514f('0x22')](function(_0x1df832){for(var _0x859d8a=0x0;_0x859d8a<_0x1df832[_0x514f('0x60')];_0x859d8a++){_0x1df832[_0x859d8a][_0x514f('0x10b')](_0x514f('0xa3'),_0x514f('0x10d'));}return _0x1df832;}));_0x51cd54[_0x514f('0x8b')](_0x5c7aa4['getSmsQueues']()[_0x514f('0x22')](function(_0x3e3e94){for(var _0x45ce90=0x0;_0x45ce90<_0x3e3e94[_0x514f('0x60')];_0x45ce90++){_0x3e3e94[_0x45ce90][_0x514f('0x10b')](_0x514f('0xa3'),_0x514f('0x10e'));}return _0x3e3e94;}));_0x51cd54[_0x514f('0x8b')](_0x5c7aa4[_0x514f('0x10f')]()[_0x514f('0x22')](function(_0x3d4d6b){for(var _0x4fb59e=0x0;_0x4fb59e<_0x3d4d6b[_0x514f('0x60')];_0x4fb59e++){_0x3d4d6b[_0x4fb59e][_0x514f('0x10b')](_0x514f('0xa3'),_0x514f('0x110'));}return _0x3d4d6b;}));_0x51cd54['push'](_0x5c7aa4[_0x514f('0x111')]()['then'](function(_0x41ddd5){for(var _0x221d66=0x0;_0x221d66<_0x41ddd5[_0x514f('0x60')];_0x221d66++){_0x41ddd5[_0x221d66][_0x514f('0x10b')]('channel',_0x514f('0x112'));}return _0x41ddd5;}));_0x51cd54['push'](_0x5c7aa4[_0x514f('0x113')]()[_0x514f('0x22')](function(_0x19f624){for(var _0x22f048=0x0;_0x22f048<_0x19f624[_0x514f('0x60')];_0x22f048++){_0x19f624[_0x22f048]['setDataValue'](_0x514f('0xa3'),_0x514f('0x114'));}return _0x19f624;}));return BPromise['all'](_0x51cd54);})[_0x514f('0x22')](function(_0x1142fc){var _0xf4fa13=_[_0x514f('0x115')](_0x1142fc);_0x51cd54=[];return db[_0x514f('0x56')][_0x514f('0x116')](function(_0x5d2d6b){for(var _0x5e483e=0x0;_0x5e483e<_0xf4fa13[_0x514f('0x60')];_0x5e483e++){_0x51cd54[_0x514f('0x8b')](_0xf4fa13[_0x5e483e][_0x514f('0x117')](_0x2ce879['id']),{'transaction':_0x5d2d6b});}return BPromise[_0x514f('0x8c')](_0x51cd54)[_0x514f('0x22')](function(){if(_0x2ce879[_0x514f('0xa4')]){return BPromise['each'](_[_0x514f('0x3b')](_0xf4fa13,function(_0x533ce2){return _0x533ce2[_0x514f('0x118')](_0x514f('0xa3'))===_0x514f('0x10a');}),function(_0x5aa570){return db[_0x514f('0xb7')][_0x514f('0x119')]({'membername':_0x2ce879[_0x514f('0x41')],'UserId':_0x2ce879['id'],'queue_name':_0x5aa570[_0x514f('0x41')],'VoiceQueueId':_0x5aa570['id'],'interface':_[_0x514f('0x69')](_0x2ce879['interface'])?util[_0x514f('0xb3')](_0x514f('0xb4'),_0x2ce879[_0x514f('0x41')]):_0x2ce879[_0x514f('0xa7')],'paused':_0x2ce879[_0x514f('0xa6')]||![],'penalty':_0x2ce879[_0x514f('0xad')]},{'transaction':_0x5d2d6b});});}else{return;}})['then'](function(){for(var _0x35eee2=0x0;_0x35eee2<_0xf4fa13[_0x514f('0x60')];_0x35eee2++){var _0x2073b0=_0xf4fa13[_0x35eee2][_0x514f('0x118')](_0x514f('0xa3'));var _0x5498ab=_0x2073b0+_0x514f('0xaf');socket[_0x514f('0xb0')](_0x514f('0x7f')+_0x2073b0+'Queue:save',{'UserId':_0x2ce879['id'],['queueField']:_0xf4fa13[_0x35eee2]['id']});}});});});}});}})[_0x514f('0x22')](respondWithStatusCode(_0x37020,null))[_0x514f('0x2b')](handleError(_0x37020,null));};exports[_0x514f('0x11a')]=function(_0x34968f,_0x54a98a){return db[_0x514f('0x59')][_0x514f('0x9c')]({'where':{'id':_0x34968f['params']['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x54a98a,null))[_0x514f('0x22')](function(_0x15f72b){if(_0x15f72b){var _0x5bbb56=_0x15f72b[_0x514f('0x37')]({'plain':!![]});var _0x1e151d=_0x34968f[_0x514f('0x4b')][_0x514f('0x65')];return _0x15f72b['removeTeams'](_0x1e151d)[_0x514f('0x22')](function(){for(var _0x267003=0x0;_0x267003<_0x1e151d[_0x514f('0x60')];_0x267003++){var _0x521630=[];db[_0x514f('0x107')][_0x514f('0x9c')]({'where':{'id':_0x1e151d[_0x267003]}})[_0x514f('0x22')](function(_0x19bcc9){_0x521630[_0x514f('0x8b')](_0x19bcc9[_0x514f('0xe8')]()[_0x514f('0x22')](function(_0x6103b1){for(var _0x4c4611=0x0;_0x4c4611<_0x6103b1[_0x514f('0x60')];_0x4c4611++){_0x6103b1[_0x4c4611][_0x514f('0x10b')](_0x514f('0xa3'),_0x514f('0x10a'));}return _0x6103b1;}));_0x521630[_0x514f('0x8b')](_0x19bcc9[_0x514f('0x11b')]()['then'](function(_0x4b879b){for(var _0x3d6252=0x0;_0x3d6252<_0x4b879b[_0x514f('0x60')];_0x3d6252++){_0x4b879b[_0x3d6252][_0x514f('0x10b')](_0x514f('0xa3'),'Chat');}return _0x4b879b;}));_0x521630['push'](_0x19bcc9['getMailQueues']()[_0x514f('0x22')](function(_0x580581){for(var _0x2df7f4=0x0;_0x2df7f4<_0x580581[_0x514f('0x60')];_0x2df7f4++){_0x580581[_0x2df7f4][_0x514f('0x10b')](_0x514f('0xa3'),_0x514f('0x10d'));}return _0x580581;}));_0x521630[_0x514f('0x8b')](_0x19bcc9[_0x514f('0x11c')]()[_0x514f('0x22')](function(_0x5371a5){for(var _0xae3228=0x0;_0xae3228<_0x5371a5[_0x514f('0x60')];_0xae3228++){_0x5371a5[_0xae3228]['setDataValue'](_0x514f('0xa3'),_0x514f('0x10e'));}return _0x5371a5;}));_0x521630[_0x514f('0x8b')](_0x19bcc9['getWhatsappQueues']()[_0x514f('0x22')](function(_0x3adf75){for(var _0x187a10=0x0;_0x187a10<_0x3adf75['length'];_0x187a10++){_0x3adf75[_0x187a10][_0x514f('0x10b')](_0x514f('0xa3'),_0x514f('0x110'));}return _0x3adf75;}));_0x521630[_0x514f('0x8b')](_0x19bcc9[_0x514f('0x111')]()[_0x514f('0x22')](function(_0x3eef87){for(var _0x24c758=0x0;_0x24c758<_0x3eef87[_0x514f('0x60')];_0x24c758++){_0x3eef87[_0x24c758][_0x514f('0x10b')]('channel',_0x514f('0x112'));}return _0x3eef87;}));_0x521630[_0x514f('0x8b')](_0x19bcc9[_0x514f('0x113')]()[_0x514f('0x22')](function(_0x2b902c){for(var _0x527c9f=0x0;_0x527c9f<_0x2b902c[_0x514f('0x60')];_0x527c9f++){_0x2b902c[_0x527c9f][_0x514f('0x10b')](_0x514f('0xa3'),_0x514f('0x114'));}return _0x2b902c;}));return BPromise[_0x514f('0x8c')](_0x521630);})[_0x514f('0x22')](function(_0x3ef8d5){var _0x572c56=_[_0x514f('0x115')](_0x3ef8d5);_0x521630=[];return db[_0x514f('0x56')]['transaction'](function(_0x3c6b98){for(var _0x43a719=0x0;_0x43a719<_0x572c56[_0x514f('0x60')];_0x43a719++){_0x521630[_0x514f('0x8b')](_0x572c56[_0x43a719]['removeAgent'](_0x5bbb56['id']),{'transaction':_0x3c6b98});}return BPromise[_0x514f('0x8c')](_0x521630)['then'](function(){if(_0x5bbb56[_0x514f('0xa4')]){return BPromise['each'](_[_0x514f('0x3b')](_0x572c56,function(_0x25c186){return _0x25c186['getDataValue']('channel')===_0x514f('0x10a');}),function(_0x201504){return db[_0x514f('0xb7')][_0x514f('0x36')]({'where':{'VoiceQueueId':_0x201504['id'],'UserId':_0x5bbb56['id']},'transaction':_0x3c6b98});});}else{return;}})[_0x514f('0x22')](function(){for(var _0x2c2162=0x0;_0x2c2162<_0x572c56[_0x514f('0x60')];_0x2c2162++){var _0x4a21c8=_0x572c56[_0x2c2162][_0x514f('0x118')]('channel');var _0x14a6a1=_0x4a21c8+'QueueId';socket[_0x514f('0xb0')](_0x514f('0x7f')+_0x4a21c8+_0x514f('0xb6'),{'UserId':_0x5bbb56['id'],['queueField']:_0x572c56[_0x2c2162]['id']});}});});});}});}})[_0x514f('0x22')](respondWithStatusCode(_0x54a98a,null))[_0x514f('0x2b')](handleError(_0x54a98a,null));};exports[_0x514f('0x11d')]=function(_0x51014f,_0x1753f0,_0x373ee9){var _0x2c7720={};var _0x24765f={};var _0x226ee7;var _0x532ce4;return db[_0x514f('0x59')]['findOne']({'where':{'id':_0x51014f[_0x514f('0x5d')]['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x1753f0,null))[_0x514f('0x22')](function(_0x186173){if(_0x186173){_0x226ee7=_0x186173;_0x24765f[_0x514f('0x47')]=_[_0x514f('0x4a')](db[_0x514f('0xc5')][_0x514f('0x5e')]);_0x24765f[_0x514f('0x4b')]=_['keys'](_0x51014f['query']);_0x24765f[_0x514f('0x4c')]=_[_0x514f('0x4d')](_0x24765f[_0x514f('0x47')],_0x24765f[_0x514f('0x4b')]);_0x2c7720[_0x514f('0x4f')]=_[_0x514f('0x4d')](_0x24765f[_0x514f('0x47')],qs[_0x514f('0x4e')](_0x51014f['query']['fields']));_0x2c7720['attributes']=_0x2c7720[_0x514f('0x4f')][_0x514f('0x60')]?_0x2c7720[_0x514f('0x4f')]:_0x24765f[_0x514f('0x47')];_0x2c7720['order']=qs['sort'](_0x51014f['query']['sort']);_0x2c7720['where']=qs[_0x514f('0x4c')](_[_0x514f('0xc4')](_0x51014f['query'],_0x24765f[_0x514f('0x4c')]));if(_0x51014f['query']['filter']){_0x2c7720[_0x514f('0x53')]=_[_0x514f('0x54')](_0x2c7720['where'],{'$or':_[_0x514f('0x3c')](_0x2c7720['attributes'],function(_0x616b66){var _0x1c4fdb={};_0x1c4fdb[_0x616b66]={'$like':'%'+_0x51014f[_0x514f('0x4b')][_0x514f('0x3b')]+'%'};return _0x1c4fdb;})});}_0x2c7720=_[_0x514f('0x54')]({},_0x2c7720,_0x51014f[_0x514f('0x58')]);return _0x226ee7[_0x514f('0x11d')](_0x2c7720);}})[_0x514f('0x22')](function(_0x26b5a1){if(_0x26b5a1){_0x532ce4=_0x26b5a1[_0x514f('0x60')];if(!_0x51014f['query'][_0x514f('0x50')](_0x514f('0xcc'))){_0x2c7720[_0x514f('0x31')]=qs[_0x514f('0x31')](_0x51014f[_0x514f('0x4b')][_0x514f('0x31')]);_0x2c7720[_0x514f('0x30')]=qs['offset'](_0x51014f[_0x514f('0x4b')][_0x514f('0x30')]);}return _0x226ee7[_0x514f('0x11d')](_0x2c7720);}})['then'](function(_0x160038){if(_0x160038){return _0x160038?{'count':_0x532ce4,'rows':_0x160038}:null;}})['then'](respondWithResult(_0x1753f0,null))[_0x514f('0x2b')](handleError(_0x1753f0,null));};exports['getAgents']=function(_0x10f48e,_0x542a8c,_0xe555a5){var _0x395bb1={};var _0x58ed99={};var _0x24d704;var _0x103e67;return db[_0x514f('0x59')][_0x514f('0x9c')]({'where':{'id':_0x10f48e[_0x514f('0x5d')]['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x542a8c,null))['then'](function(_0x4b570a){if(_0x4b570a){_0x24d704=_0x4b570a;_0x58ed99['model']=_[_0x514f('0x4a')](db[_0x514f('0x59')][_0x514f('0x5e')]);_0x58ed99['query']=_[_0x514f('0x4a')](_0x10f48e['query']);_0x58ed99[_0x514f('0x4c')]=_[_0x514f('0x4d')](_0x58ed99[_0x514f('0x47')],_0x58ed99[_0x514f('0x4b')]);_0x395bb1[_0x514f('0x4f')]=_[_0x514f('0x4d')](_0x58ed99[_0x514f('0x47')],qs[_0x514f('0x4e')](_0x10f48e[_0x514f('0x4b')][_0x514f('0x4e')]));_0x395bb1[_0x514f('0x4f')]=_0x395bb1['attributes'][_0x514f('0x60')]?_0x395bb1[_0x514f('0x4f')]:_0x58ed99[_0x514f('0x47')];_0x395bb1['order']=qs[_0x514f('0x52')](_0x10f48e[_0x514f('0x4b')]['sort']);_0x395bb1[_0x514f('0x53')]=qs['filters'](_[_0x514f('0xc4')](_0x10f48e[_0x514f('0x4b')],_0x58ed99[_0x514f('0x4c')]));if(_0x10f48e[_0x514f('0x4b')][_0x514f('0x3b')]){_0x395bb1['where']=_[_0x514f('0x54')](_0x395bb1[_0x514f('0x53')],{'$or':_[_0x514f('0x3c')](_0x395bb1[_0x514f('0x4f')],function(_0xf3f8fb){var _0x29679f={};_0x29679f[_0xf3f8fb]={'$like':'%'+_0x10f48e[_0x514f('0x4b')]['filter']+'%'};return _0x29679f;})});}_0x395bb1[_0x514f('0x47')]=db['User'];_0x395bb1['as']=_0x514f('0x39');_0x395bb1=_['merge']({},_0x395bb1,_0x10f48e[_0x514f('0x58')]);return _0x24d704[_0x514f('0xe8')]({'include':[_0x395bb1]});}})[_0x514f('0x22')](function(_0x52f8b2){if(_0x52f8b2){var _0x1960e4={},_0x5838d1=[],_0x52bb4b=0x0;for(var _0x97664a=0x0;_0x97664a<_0x52f8b2[_0x514f('0x60')];_0x97664a+=0x1){for(var _0x55f19b=0x0,_0x58cb94;_0x55f19b<_0x52f8b2[_0x97664a][_0x514f('0x39')][_0x514f('0x60')];_0x55f19b+=0x1){_0x58cb94=_0x52f8b2[_0x97664a][_0x514f('0x39')][_0x55f19b][_0x514f('0x37')]({'plain':!![]});_0x1960e4[_0x58cb94['id']]=_0x58cb94;}}_0x1960e4=_[_0x514f('0x11e')](_0x1960e4);for(var _0x3f301c=qs[_0x514f('0x30')](_0x10f48e['query'][_0x514f('0x30')]);_0x3f301c<_0x1960e4[_0x514f('0x60')]&&_0x5838d1[_0x514f('0x60')]<qs[_0x514f('0x31')](_0x10f48e[_0x514f('0x4b')][_0x514f('0x31')]);_0x3f301c+=0x1){if(_0x1960e4[_0x3f301c]){_0x5838d1[_0x514f('0x8b')](_0x1960e4[_0x3f301c]);}}return{'count':_0x1960e4['length'],'rows':_0x5838d1};}})[_0x514f('0x22')](respondWithResult(_0x542a8c,null))[_0x514f('0x2b')](handleError(_0x542a8c,null));};exports['destroy']=function(_0x130921,_0x96ca50){if(_0x130921['user']['id']==_0x130921[_0x514f('0x5d')]['id']){return _0x96ca50['status'](0x1f4)[_0x514f('0x44')]({'message':_0x514f('0x11f')});}return db['User'][_0x514f('0x40')]({'where':{'id':_0x130921['params']['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x96ca50,null))['then'](removeEntity(_0x96ca50,null))[_0x514f('0x2b')](handleError(_0x96ca50,null));};exports[_0x514f('0x120')]=function(_0x4e58d4,_0x1f3e4c,_0x2f0038){return db[_0x514f('0x59')]['find']({'where':{'id':_0x4e58d4[_0x514f('0x5d')]['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x1f3e4c,null))['then'](function(_0x442cec){if(_0x442cec){return _0x442cec['addChatInteractions'](_0x4e58d4[_0x514f('0x62')][_0x514f('0x65')],_[_0x514f('0x109')](_0x4e58d4[_0x514f('0x62')],['ids','id'])||{})[_0x514f('0x121')](function(){for(var _0x38d60d=0x0;_0x38d60d<_0x4e58d4[_0x514f('0x62')][_0x514f('0x65')][_0x514f('0x60')];_0x38d60d+=0x1){socket[_0x514f('0xb0')](_0x514f('0x122'),{'ChatInteractionId':Number(_0x4e58d4['body'][_0x514f('0x65')][_0x38d60d]),'UserId':Number(_0x4e58d4[_0x514f('0x5d')]['id'])});}return _0x4e58d4[_0x514f('0x62')][_0x514f('0x65')];});}})[_0x514f('0x22')](respondWithResult(_0x1f3e4c,null))[_0x514f('0x2b')](handleError(_0x1f3e4c,null));};exports[_0x514f('0x123')]=function(_0x56d0e8,_0x19f213,_0x4e3ec8){return db[_0x514f('0x59')]['find']({'where':{'id':_0x56d0e8[_0x514f('0x5d')]['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x19f213,null))['then'](function(_0x47fe5b){if(_0x47fe5b){return _0x47fe5b[_0x514f('0x123')](_0x56d0e8['query'][_0x514f('0x65')])['then'](function(){if(_[_0x514f('0x124')](_0x56d0e8[_0x514f('0x4b')][_0x514f('0x65')])){for(var _0x230947=0x0;_0x230947<_0x56d0e8['query'][_0x514f('0x65')]['length'];_0x230947+=0x1){socket[_0x514f('0xb0')](_0x514f('0x125'),{'ChatInteractionId':Number(_0x56d0e8['query'][_0x514f('0x65')][_0x230947]),'UserId':Number(_0x56d0e8[_0x514f('0x5d')]['id'])});}}else{socket[_0x514f('0xb0')](_0x514f('0x125'),{'ChatInteractionId':Number(_0x56d0e8['query']['ids']),'UserId':Number(_0x56d0e8['params']['id'])});}});}})[_0x514f('0x22')](respondWithStatusCode(_0x19f213,null))[_0x514f('0x2b')](handleError(_0x19f213,null));};exports[_0x514f('0x126')]=function(_0x11c6ad,_0x2cab66,_0x35da3d){return db['User'][_0x514f('0x40')]({'where':{'id':_0x11c6ad[_0x514f('0x5d')]['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x2cab66,null))[_0x514f('0x22')](function(_0x3e0ce8){if(_0x3e0ce8){return _0x3e0ce8[_0x514f('0x126')](_0x11c6ad['body'][_0x514f('0x65')],_[_0x514f('0x109')](_0x11c6ad[_0x514f('0x62')],['ids','id'])||{})[_0x514f('0x121')](function(){for(var _0x5765df=0x0;_0x5765df<_0x11c6ad[_0x514f('0x62')]['ids']['length'];_0x5765df+=0x1){socket[_0x514f('0xb0')](_0x514f('0x127'),{'MailInteractionId':Number(_0x11c6ad[_0x514f('0x62')][_0x514f('0x65')][_0x5765df]),'UserId':Number(_0x11c6ad[_0x514f('0x5d')]['id'])});}return _0x11c6ad[_0x514f('0x62')]['ids'];});}})['then'](respondWithResult(_0x2cab66,null))[_0x514f('0x2b')](handleError(_0x2cab66,null));};exports[_0x514f('0x128')]=function(_0x4ddce3,_0x5a1293,_0x142675){return db[_0x514f('0x59')]['find']({'where':{'id':_0x4ddce3[_0x514f('0x5d')]['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x5a1293,null))[_0x514f('0x22')](function(_0x2543a9){if(_0x2543a9){return _0x2543a9['removeMailInteractions'](_0x4ddce3[_0x514f('0x4b')][_0x514f('0x65')])[_0x514f('0x22')](function(){if(_[_0x514f('0x124')](_0x4ddce3['query'][_0x514f('0x65')])){for(var _0x294851=0x0;_0x294851<_0x4ddce3[_0x514f('0x4b')][_0x514f('0x65')][_0x514f('0x60')];_0x294851+=0x1){socket[_0x514f('0xb0')](_0x514f('0x129'),{'MailInteractionId':Number(_0x4ddce3[_0x514f('0x4b')][_0x514f('0x65')][_0x294851]),'UserId':Number(_0x4ddce3[_0x514f('0x5d')]['id'])});}}else{socket[_0x514f('0xb0')](_0x514f('0x129'),{'MailInteractionId':Number(_0x4ddce3[_0x514f('0x4b')][_0x514f('0x65')]),'UserId':Number(_0x4ddce3[_0x514f('0x5d')]['id'])});}});}})['then'](respondWithStatusCode(_0x5a1293,null))['catch'](handleError(_0x5a1293,null));};exports[_0x514f('0x12a')]=function(_0x1fe68a,_0x59a1d5,_0x513f19){return db[_0x514f('0x59')]['find']({'where':{'id':_0x1fe68a[_0x514f('0x5d')]['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x59a1d5,null))[_0x514f('0x22')](function(_0x36ccb3){if(_0x36ccb3){return _0x36ccb3[_0x514f('0x12a')](_0x1fe68a[_0x514f('0x62')][_0x514f('0x65')],_['omit'](_0x1fe68a[_0x514f('0x62')],[_0x514f('0x65'),'id'])||{})[_0x514f('0x121')](function(){for(var _0x42a266=0x0;_0x42a266<_0x1fe68a[_0x514f('0x62')]['ids'][_0x514f('0x60')];_0x42a266+=0x1){socket['emit'](_0x514f('0x12b'),{'FaxInteractionId':Number(_0x1fe68a[_0x514f('0x62')][_0x514f('0x65')][_0x42a266]),'UserId':Number(_0x1fe68a[_0x514f('0x5d')]['id'])});}return _0x1fe68a['body'][_0x514f('0x65')];});}})['then'](respondWithResult(_0x59a1d5,null))['catch'](handleError(_0x59a1d5,null));};exports[_0x514f('0x12c')]=function(_0x3fb25c,_0x1ef692,_0x1fa6b1){return db['User']['find']({'where':{'id':_0x3fb25c['params']['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x1ef692,null))['then'](function(_0x168fb4){if(_0x168fb4){return _0x168fb4[_0x514f('0x12c')](_0x3fb25c['query'][_0x514f('0x65')])[_0x514f('0x22')](function(){if(_['isArray'](_0x3fb25c[_0x514f('0x4b')]['ids'])){for(var _0x64ee86=0x0;_0x64ee86<_0x3fb25c['query'][_0x514f('0x65')][_0x514f('0x60')];_0x64ee86+=0x1){socket[_0x514f('0xb0')](_0x514f('0x12d'),{'FaxInteractionId':Number(_0x3fb25c[_0x514f('0x4b')][_0x514f('0x65')][_0x64ee86]),'UserId':Number(_0x3fb25c[_0x514f('0x5d')]['id'])});}}else{socket['emit']('user_has_fax_interactions:remove',{'FaxInteractionId':Number(_0x3fb25c[_0x514f('0x4b')][_0x514f('0x65')]),'UserId':Number(_0x3fb25c['params']['id'])});}});}})['then'](respondWithStatusCode(_0x1ef692,null))[_0x514f('0x2b')](handleError(_0x1ef692,null));};exports[_0x514f('0x12e')]=function(_0x5231ec,_0x54f2f7,_0x5eb6a5){return db[_0x514f('0x59')][_0x514f('0x40')]({'where':{'id':_0x5231ec[_0x514f('0x5d')]['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x54f2f7,null))[_0x514f('0x22')](function(_0x457fe0){if(_0x457fe0){return _0x457fe0[_0x514f('0x12e')](_0x5231ec[_0x514f('0x62')][_0x514f('0x65')],_[_0x514f('0x109')](_0x5231ec[_0x514f('0x62')],[_0x514f('0x65'),'id'])||{})[_0x514f('0x121')](function(){for(var _0x51abb3=0x0;_0x51abb3<_0x5231ec[_0x514f('0x62')]['ids'][_0x514f('0x60')];_0x51abb3+=0x1){socket[_0x514f('0xb0')](_0x514f('0x12f'),{'SmsInteractionId':Number(_0x5231ec[_0x514f('0x62')][_0x514f('0x65')][_0x51abb3]),'UserId':Number(_0x5231ec[_0x514f('0x5d')]['id'])});}return _0x5231ec['body'][_0x514f('0x65')];});}})['then'](respondWithResult(_0x54f2f7,null))[_0x514f('0x2b')](handleError(_0x54f2f7,null));};exports[_0x514f('0x130')]=function(_0x3b05c5,_0x8699b4,_0x149072){return db['User'][_0x514f('0x40')]({'where':{'id':_0x3b05c5[_0x514f('0x5d')]['id']}})['then'](handleEntityNotFound(_0x8699b4,null))['then'](function(_0x1f2174){if(_0x1f2174){return _0x1f2174[_0x514f('0x130')](_0x3b05c5[_0x514f('0x4b')][_0x514f('0x65')])[_0x514f('0x22')](function(){if(_[_0x514f('0x124')](_0x3b05c5['query'][_0x514f('0x65')])){for(var _0x4e8dac=0x0;_0x4e8dac<_0x3b05c5['query'][_0x514f('0x65')][_0x514f('0x60')];_0x4e8dac+=0x1){socket[_0x514f('0xb0')]('user_has_sms_interactions:remove',{'SmsInteractionId':Number(_0x3b05c5[_0x514f('0x4b')][_0x514f('0x65')][_0x4e8dac]),'UserId':Number(_0x3b05c5['params']['id'])});}}else{socket[_0x514f('0xb0')]('user_has_sms_interactions:remove',{'SmsInteractionId':Number(_0x3b05c5['query'][_0x514f('0x65')]),'UserId':Number(_0x3b05c5[_0x514f('0x5d')]['id'])});}});}})[_0x514f('0x22')](respondWithStatusCode(_0x8699b4,null))['catch'](handleError(_0x8699b4,null));};exports[_0x514f('0x131')]=function(_0x101422,_0x5eeedb,_0x5eb2ac){return db['User'][_0x514f('0x40')]({'where':{'id':_0x101422[_0x514f('0x5d')]['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x5eeedb,null))[_0x514f('0x22')](function(_0x60405a){if(_0x60405a){return _0x60405a[_0x514f('0x131')](_0x101422['body'][_0x514f('0x65')],_[_0x514f('0x109')](_0x101422['body'],['ids','id'])||{})[_0x514f('0x121')](function(){for(var _0x4ed64a=0x0;_0x4ed64a<_0x101422[_0x514f('0x62')]['ids'][_0x514f('0x60')];_0x4ed64a+=0x1){socket[_0x514f('0xb0')](_0x514f('0x132'),{'OpenchannelInteractionId':Number(_0x101422[_0x514f('0x62')]['ids'][_0x4ed64a]),'UserId':Number(_0x101422[_0x514f('0x5d')]['id'])});}return _0x101422[_0x514f('0x62')][_0x514f('0x65')];});}})[_0x514f('0x22')](respondWithResult(_0x5eeedb,null))['catch'](handleError(_0x5eeedb,null));};exports[_0x514f('0x133')]=function(_0x267b31,_0x5654d4,_0x22be0a){return db[_0x514f('0x59')][_0x514f('0x40')]({'where':{'id':_0x267b31[_0x514f('0x5d')]['id']}})['then'](handleEntityNotFound(_0x5654d4,null))[_0x514f('0x22')](function(_0x126065){if(_0x126065){return _0x126065['removeOpenchannelInteractions'](_0x267b31[_0x514f('0x4b')][_0x514f('0x65')])['then'](function(){if(_[_0x514f('0x124')](_0x267b31[_0x514f('0x4b')][_0x514f('0x65')])){for(var _0x484cb5=0x0;_0x484cb5<_0x267b31[_0x514f('0x4b')][_0x514f('0x65')]['length'];_0x484cb5+=0x1){socket['emit'](_0x514f('0x134'),{'OpenchannelInteractionId':Number(_0x267b31[_0x514f('0x4b')]['ids'][_0x484cb5]),'UserId':Number(_0x267b31[_0x514f('0x5d')]['id'])});}}else{socket[_0x514f('0xb0')](_0x514f('0x134'),{'OpenchannelInteractionId':Number(_0x267b31[_0x514f('0x4b')]['ids']),'UserId':Number(_0x267b31['params']['id'])});}});}})['then'](respondWithStatusCode(_0x5654d4,null))[_0x514f('0x2b')](handleError(_0x5654d4,null));};exports[_0x514f('0x135')]=function(_0x323c2b,_0x1b9362,_0x541442){return db[_0x514f('0x59')][_0x514f('0x40')]({'where':{'id':_0x323c2b[_0x514f('0x5d')]['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x1b9362,null))[_0x514f('0x22')](function(_0x198dd6){if(_0x198dd6){return _0x198dd6[_0x514f('0x135')](_0x323c2b[_0x514f('0x62')][_0x514f('0x65')],_[_0x514f('0x109')](_0x323c2b[_0x514f('0x62')],[_0x514f('0x65'),'id'])||{})['spread'](function(){for(var _0x50f864=0x0;_0x50f864<_0x323c2b['body'][_0x514f('0x65')][_0x514f('0x60')];_0x50f864+=0x1){socket[_0x514f('0xb0')](_0x514f('0x136'),{'WhatsappInteractionId':Number(_0x323c2b[_0x514f('0x62')][_0x514f('0x65')][_0x50f864]),'UserId':Number(_0x323c2b[_0x514f('0x5d')]['id'])});}return _0x323c2b[_0x514f('0x62')][_0x514f('0x65')];});}})[_0x514f('0x22')](respondWithResult(_0x1b9362,null))[_0x514f('0x2b')](handleError(_0x1b9362,null));};exports['removeWhatsappInteractions']=function(_0xcc0800,_0x401663,_0x1b8701){return db[_0x514f('0x59')][_0x514f('0x40')]({'where':{'id':_0xcc0800[_0x514f('0x5d')]['id']}})['then'](handleEntityNotFound(_0x401663,null))[_0x514f('0x22')](function(_0x46de40){if(_0x46de40){return _0x46de40[_0x514f('0x137')](_0xcc0800[_0x514f('0x4b')][_0x514f('0x65')]);}})[_0x514f('0x22')](respondWithStatusCode(_0x401663,null))[_0x514f('0x2b')](handleError(_0x401663,null));};exports[_0x514f('0x138')]=function(_0x59c347,_0x1a3aa3,_0x347a50){var _0x5b21a1={};var _0x4269cc={};var _0x4d820a;var _0x440aed;return db[_0x514f('0x59')][_0x514f('0x9c')]({'where':{'id':_0x59c347[_0x514f('0x5d')]['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x1a3aa3,null))['then'](function(_0x5039ef){if(_0x5039ef){_0x4d820a=_0x5039ef;_0x4269cc[_0x514f('0x47')]=_[_0x514f('0x4a')](db[_0x514f('0x139')]['rawAttributes']);_0x4269cc['query']=_[_0x514f('0x4a')](_0x59c347['query']);_0x4269cc[_0x514f('0x4c')]=_['intersection'](_0x4269cc['model'],_0x4269cc['query']);_0x5b21a1[_0x514f('0x4f')]=_[_0x514f('0x4d')](_0x4269cc[_0x514f('0x47')],qs[_0x514f('0x4e')](_0x59c347[_0x514f('0x4b')]['fields']));_0x5b21a1[_0x514f('0x4f')]=_0x5b21a1[_0x514f('0x4f')][_0x514f('0x60')]?_0x5b21a1['attributes']:_0x4269cc[_0x514f('0x47')];_0x5b21a1[_0x514f('0x51')]=qs[_0x514f('0x52')](_0x59c347[_0x514f('0x4b')]['sort']);_0x5b21a1[_0x514f('0x53')]=qs[_0x514f('0x4c')](_['pick'](_0x59c347['query'],_0x4269cc[_0x514f('0x4c')]));if(_0x59c347[_0x514f('0x4b')][_0x514f('0x3b')]){_0x5b21a1[_0x514f('0x53')]=_[_0x514f('0x54')](_0x5b21a1[_0x514f('0x53')],{'$or':_[_0x514f('0x3c')](_0x5b21a1[_0x514f('0x4f')],function(_0x16a082){var _0x2aa676={};_0x2aa676[_0x16a082]={'$like':'%'+_0x59c347[_0x514f('0x4b')][_0x514f('0x3b')]+'%'};return _0x2aa676;})});}_0x5b21a1=_[_0x514f('0x54')]({},_0x5b21a1,_0x59c347[_0x514f('0x58')]);return _0x4d820a[_0x514f('0x138')](_0x5b21a1);}})[_0x514f('0x22')](function(_0xe3ec1a){if(_0xe3ec1a){_0x440aed=_0xe3ec1a[_0x514f('0x60')];if(!_0x59c347['query'][_0x514f('0x50')](_0x514f('0xcc'))){_0x5b21a1[_0x514f('0x31')]=qs['limit'](_0x59c347[_0x514f('0x4b')][_0x514f('0x31')]);_0x5b21a1[_0x514f('0x30')]=qs[_0x514f('0x30')](_0x59c347[_0x514f('0x4b')][_0x514f('0x30')]);}return _0x4d820a['getVoicePrefixes'](_0x5b21a1);}})[_0x514f('0x22')](function(_0xdd6e4){if(_0xdd6e4){return _0xdd6e4?{'count':_0x440aed,'rows':_0xdd6e4}:null;}})['then'](respondWithResult(_0x1a3aa3,null))[_0x514f('0x2b')](handleError(_0x1a3aa3,null));};exports[_0x514f('0x13a')]=function(_0x734ae4,_0x2f5e13,_0xdf3865){var _0x2a2665={};var _0x1cd4ef={};var _0x22415d;var _0x40bb55;return db[_0x514f('0x59')][_0x514f('0x9c')]({'where':{'id':_0x734ae4['params']['id']}})['then'](handleEntityNotFound(_0x2f5e13,null))[_0x514f('0x22')](function(_0x327bec){if(_0x327bec){_0x22415d=_0x327bec;_0x1cd4ef[_0x514f('0x47')]=_[_0x514f('0x4a')](db['FaxAccount']['rawAttributes']);_0x1cd4ef[_0x514f('0x4b')]=_[_0x514f('0x4a')](_0x734ae4[_0x514f('0x4b')]);_0x1cd4ef['filters']=_[_0x514f('0x4d')](_0x1cd4ef[_0x514f('0x47')],_0x1cd4ef[_0x514f('0x4b')]);_0x2a2665['attributes']=_[_0x514f('0x4d')](_0x1cd4ef[_0x514f('0x47')],qs['fields'](_0x734ae4['query'][_0x514f('0x4e')]));_0x2a2665[_0x514f('0x4f')]=_0x2a2665['attributes'][_0x514f('0x60')]?_0x2a2665[_0x514f('0x4f')]:_0x1cd4ef[_0x514f('0x47')];_0x2a2665[_0x514f('0x51')]=qs[_0x514f('0x52')](_0x734ae4['query'][_0x514f('0x52')]);_0x2a2665['where']=qs[_0x514f('0x4c')](_[_0x514f('0xc4')](_0x734ae4[_0x514f('0x4b')],_0x1cd4ef[_0x514f('0x4c')]));if(_0x734ae4[_0x514f('0x4b')][_0x514f('0x3b')]){_0x2a2665[_0x514f('0x53')]=_[_0x514f('0x54')](_0x2a2665[_0x514f('0x53')],{'$or':_[_0x514f('0x3c')](_0x2a2665[_0x514f('0x4f')],function(_0x8d903e){var _0x150586={};_0x150586[_0x8d903e]={'$like':'%'+_0x734ae4[_0x514f('0x4b')]['filter']+'%'};return _0x150586;})});}_0x2a2665=_[_0x514f('0x54')]({},_0x2a2665,_0x734ae4[_0x514f('0x58')]);return _0x22415d[_0x514f('0x13a')](_0x2a2665);}})[_0x514f('0x22')](function(_0x4b546a){if(_0x4b546a){_0x40bb55=_0x4b546a[_0x514f('0x60')];if(!_0x734ae4['query'][_0x514f('0x50')]('nolimit')){_0x2a2665[_0x514f('0x31')]=qs[_0x514f('0x31')](_0x734ae4['query'][_0x514f('0x31')]);_0x2a2665[_0x514f('0x30')]=qs['offset'](_0x734ae4[_0x514f('0x4b')]['offset']);}return _0x22415d[_0x514f('0x13a')](_0x2a2665);}})['then'](function(_0xc2a0ca){if(_0xc2a0ca){return _0xc2a0ca?{'count':_0x40bb55,'rows':_0xc2a0ca}:null;}})[_0x514f('0x22')](respondWithResult(_0x2f5e13,null))['catch'](handleError(_0x2f5e13,null));};exports[_0x514f('0x13b')]=function(_0x2995c4,_0x22f50f,_0xfe1aaa){return db['User'][_0x514f('0x40')]({'where':{'id':_0x2995c4[_0x514f('0x5d')]['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x22f50f,null))[_0x514f('0x22')](function(_0x9d0f61){if(_0x9d0f61){return _0x9d0f61[_0x514f('0x13b')](_0x2995c4['body'][_0x514f('0x65')],_[_0x514f('0x109')](_0x2995c4[_0x514f('0x62')],[_0x514f('0x65'),'id'])||{});}})[_0x514f('0x22')](respondWithResult(_0x22f50f,null))[_0x514f('0x2b')](handleError(_0x22f50f,null));};exports[_0x514f('0x13c')]=function(_0x461e7a,_0x4d51ef,_0x561bd6){return db['User'][_0x514f('0x40')]({'where':{'id':_0x461e7a[_0x514f('0x5d')]['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x4d51ef,null))[_0x514f('0x22')](function(_0x2433f8){if(_0x2433f8){return _0x2433f8['removeFaxAccounts'](_0x461e7a['query']['ids']);}})['then'](respondWithStatusCode(_0x4d51ef,null))[_0x514f('0x2b')](handleError(_0x4d51ef,null));};exports[_0x514f('0x13d')]=function(_0x530fa4,_0x522d5c,_0x5f4444){var _0x8cffe6={};var _0x18f50a={};var _0x162154;var _0x491f3f;return db[_0x514f('0x59')][_0x514f('0x9c')]({'where':{'id':_0x530fa4[_0x514f('0x5d')]['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x522d5c,null))[_0x514f('0x22')](function(_0x3078e7){if(_0x3078e7){_0x162154=_0x3078e7;_0x18f50a[_0x514f('0x47')]=_[_0x514f('0x4a')](db[_0x514f('0x13e')][_0x514f('0x5e')]);_0x18f50a['query']=_[_0x514f('0x4a')](_0x530fa4[_0x514f('0x4b')]);_0x18f50a[_0x514f('0x4c')]=_['intersection'](_0x18f50a['model'],_0x18f50a[_0x514f('0x4b')]);_0x8cffe6['attributes']=_[_0x514f('0x4d')](_0x18f50a[_0x514f('0x47')],qs['fields'](_0x530fa4[_0x514f('0x4b')]['fields']));_0x8cffe6[_0x514f('0x4f')]=_0x8cffe6['attributes'][_0x514f('0x60')]?_0x8cffe6[_0x514f('0x4f')]:_0x18f50a[_0x514f('0x47')];_0x8cffe6['order']=qs[_0x514f('0x52')](_0x530fa4['query'][_0x514f('0x52')]);_0x8cffe6[_0x514f('0x53')]=qs[_0x514f('0x4c')](_['pick'](_0x530fa4['query'],_0x18f50a[_0x514f('0x4c')]));if(_0x530fa4[_0x514f('0x4b')][_0x514f('0x3b')]){_0x8cffe6[_0x514f('0x53')]=_[_0x514f('0x54')](_0x8cffe6[_0x514f('0x53')],{'$or':_[_0x514f('0x3c')](_0x8cffe6[_0x514f('0x4f')],function(_0x2861c1){var _0x801fde={};_0x801fde[_0x2861c1]={'$like':'%'+_0x530fa4['query'][_0x514f('0x3b')]+'%'};return _0x801fde;})});}_0x8cffe6=_[_0x514f('0x54')]({},_0x8cffe6,_0x530fa4[_0x514f('0x58')]);return _0x162154['getMailAccounts'](_0x8cffe6);}})['then'](function(_0x1e0ac4){if(_0x1e0ac4){_0x491f3f=_0x1e0ac4['length'];if(!_0x530fa4[_0x514f('0x4b')][_0x514f('0x50')](_0x514f('0xcc'))){_0x8cffe6[_0x514f('0x31')]=qs[_0x514f('0x31')](_0x530fa4[_0x514f('0x4b')][_0x514f('0x31')]);_0x8cffe6['offset']=qs['offset'](_0x530fa4[_0x514f('0x4b')][_0x514f('0x30')]);}return _0x162154[_0x514f('0x13d')](_0x8cffe6);}})[_0x514f('0x22')](function(_0x4bfd41){if(_0x4bfd41){return _0x4bfd41?{'count':_0x491f3f,'rows':_0x4bfd41}:null;}})[_0x514f('0x22')](respondWithResult(_0x522d5c,null))[_0x514f('0x2b')](handleError(_0x522d5c,null));};exports[_0x514f('0x13f')]=function(_0xfa0eea,_0x1d0026,_0x223d55){return db[_0x514f('0x59')][_0x514f('0x40')]({'where':{'id':_0xfa0eea[_0x514f('0x5d')]['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x1d0026,null))[_0x514f('0x22')](function(_0xd3e3b0){if(_0xd3e3b0){return _0xd3e3b0['addMailAccounts'](_0xfa0eea[_0x514f('0x62')][_0x514f('0x65')],_[_0x514f('0x109')](_0xfa0eea[_0x514f('0x62')],[_0x514f('0x65'),'id'])||{});}})[_0x514f('0x22')](respondWithResult(_0x1d0026,null))[_0x514f('0x2b')](handleError(_0x1d0026,null));};exports[_0x514f('0x140')]=function(_0x2a0d9b,_0x36b7b0,_0x56781a){return db[_0x514f('0x59')]['find']({'where':{'id':_0x2a0d9b['params']['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x36b7b0,null))[_0x514f('0x22')](function(_0x1e07b1){if(_0x1e07b1){return _0x1e07b1['removeMailAccounts'](_0x2a0d9b[_0x514f('0x4b')][_0x514f('0x65')]);}})[_0x514f('0x22')](respondWithStatusCode(_0x36b7b0,null))[_0x514f('0x2b')](handleError(_0x36b7b0,null));};exports[_0x514f('0x141')]=function(_0x494f16,_0x30e037,_0x2ec05e){var _0x5c4cf7={};var _0x542bcf={};var _0x4aff1c;var _0x1a318b;return db[_0x514f('0x59')][_0x514f('0x9c')]({'where':{'id':_0x494f16[_0x514f('0x5d')]['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x30e037,null))[_0x514f('0x22')](function(_0x28def4){if(_0x28def4){_0x4aff1c=_0x28def4;_0x542bcf['model']=_[_0x514f('0x4a')](db[_0x514f('0x142')][_0x514f('0x5e')]);_0x542bcf[_0x514f('0x4b')]=_[_0x514f('0x4a')](_0x494f16[_0x514f('0x4b')]);_0x542bcf[_0x514f('0x4c')]=_[_0x514f('0x4d')](_0x542bcf['model'],_0x542bcf[_0x514f('0x4b')]);_0x5c4cf7[_0x514f('0x4f')]=_[_0x514f('0x4d')](_0x542bcf[_0x514f('0x47')],qs[_0x514f('0x4e')](_0x494f16[_0x514f('0x4b')][_0x514f('0x4e')]));_0x5c4cf7[_0x514f('0x4f')]=_0x5c4cf7[_0x514f('0x4f')][_0x514f('0x60')]?_0x5c4cf7[_0x514f('0x4f')]:_0x542bcf['model'];_0x5c4cf7['order']=qs[_0x514f('0x52')](_0x494f16[_0x514f('0x4b')]['sort']);_0x5c4cf7[_0x514f('0x53')]=qs['filters'](_['pick'](_0x494f16[_0x514f('0x4b')],_0x542bcf[_0x514f('0x4c')]));if(_0x494f16[_0x514f('0x4b')][_0x514f('0x3b')]){_0x5c4cf7[_0x514f('0x53')]=_[_0x514f('0x54')](_0x5c4cf7[_0x514f('0x53')],{'$or':_[_0x514f('0x3c')](_0x5c4cf7[_0x514f('0x4f')],function(_0x546398){var _0x2d8d3d={};_0x2d8d3d[_0x546398]={'$like':'%'+_0x494f16['query'][_0x514f('0x3b')]+'%'};return _0x2d8d3d;})});}_0x5c4cf7=_[_0x514f('0x54')]({},_0x5c4cf7,_0x494f16[_0x514f('0x58')]);return _0x4aff1c[_0x514f('0x141')](_0x5c4cf7);}})[_0x514f('0x22')](function(_0x31dd1f){if(_0x31dd1f){_0x1a318b=_0x31dd1f[_0x514f('0x60')];if(!_0x494f16['query'][_0x514f('0x50')](_0x514f('0xcc'))){_0x5c4cf7[_0x514f('0x31')]=qs[_0x514f('0x31')](_0x494f16[_0x514f('0x4b')]['limit']);_0x5c4cf7[_0x514f('0x30')]=qs[_0x514f('0x30')](_0x494f16[_0x514f('0x4b')][_0x514f('0x30')]);}return _0x4aff1c[_0x514f('0x141')](_0x5c4cf7);}})[_0x514f('0x22')](function(_0x28bb78){if(_0x28bb78){return _0x28bb78?{'count':_0x1a318b,'rows':_0x28bb78}:null;}})[_0x514f('0x22')](respondWithResult(_0x30e037,null))['catch'](handleError(_0x30e037,null));};exports[_0x514f('0x143')]=function(_0x18c972,_0x20d208,_0x4a8152){return db['User'][_0x514f('0x40')]({'where':{'id':_0x18c972['params']['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x20d208,null))[_0x514f('0x22')](function(_0x2f361a){if(_0x2f361a){return _0x2f361a['addOpenchannelAccounts'](_0x18c972[_0x514f('0x62')][_0x514f('0x65')],_[_0x514f('0x109')](_0x18c972['body'],[_0x514f('0x65'),'id'])||{});}})[_0x514f('0x22')](respondWithResult(_0x20d208,null))[_0x514f('0x2b')](handleError(_0x20d208,null));};exports[_0x514f('0x144')]=function(_0x5e0460,_0x4900f2,_0x51dea5){return db[_0x514f('0x59')][_0x514f('0x40')]({'where':{'id':_0x5e0460['params']['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x4900f2,null))[_0x514f('0x22')](function(_0xe18007){if(_0xe18007){return _0xe18007[_0x514f('0x144')](_0x5e0460[_0x514f('0x4b')][_0x514f('0x65')]);}})[_0x514f('0x22')](respondWithStatusCode(_0x4900f2,null))[_0x514f('0x2b')](handleError(_0x4900f2,null));};exports[_0x514f('0x145')]=function(_0x1cf256,_0x40e250,_0x3f45fb){var _0x17ed78={};var _0x4ff569={};var _0x271044;var _0x1d7879;return db['User'][_0x514f('0x9c')]({'where':{'id':_0x1cf256[_0x514f('0x5d')]['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x40e250,null))[_0x514f('0x22')](function(_0x42e28c){if(_0x42e28c){_0x271044=_0x42e28c;_0x4ff569[_0x514f('0x47')]=_['keys'](db[_0x514f('0x146')][_0x514f('0x5e')]);_0x4ff569[_0x514f('0x4b')]=_[_0x514f('0x4a')](_0x1cf256[_0x514f('0x4b')]);_0x4ff569[_0x514f('0x4c')]=_[_0x514f('0x4d')](_0x4ff569[_0x514f('0x47')],_0x4ff569[_0x514f('0x4b')]);_0x17ed78[_0x514f('0x4f')]=_['intersection'](_0x4ff569[_0x514f('0x47')],qs[_0x514f('0x4e')](_0x1cf256[_0x514f('0x4b')]['fields']));_0x17ed78[_0x514f('0x4f')]=_0x17ed78[_0x514f('0x4f')][_0x514f('0x60')]?_0x17ed78[_0x514f('0x4f')]:_0x4ff569[_0x514f('0x47')];_0x17ed78['order']=qs[_0x514f('0x52')](_0x1cf256['query'][_0x514f('0x52')]);_0x17ed78[_0x514f('0x53')]=qs[_0x514f('0x4c')](_[_0x514f('0xc4')](_0x1cf256['query'],_0x4ff569['filters']));if(_0x1cf256[_0x514f('0x4b')][_0x514f('0x3b')]){_0x17ed78[_0x514f('0x53')]=_['merge'](_0x17ed78[_0x514f('0x53')],{'$or':_['map'](_0x17ed78[_0x514f('0x4f')],function(_0x45961f){var _0x1fc84a={};_0x1fc84a[_0x45961f]={'$like':'%'+_0x1cf256[_0x514f('0x4b')][_0x514f('0x3b')]+'%'};return _0x1fc84a;})});}_0x17ed78=_['merge']({},_0x17ed78,_0x1cf256[_0x514f('0x58')]);return _0x271044[_0x514f('0x145')](_0x17ed78);}})[_0x514f('0x22')](function(_0x57c999){if(_0x57c999){_0x1d7879=_0x57c999[_0x514f('0x60')];if(!_0x1cf256[_0x514f('0x4b')]['hasOwnProperty'](_0x514f('0xcc'))){_0x17ed78[_0x514f('0x31')]=qs['limit'](_0x1cf256['query'][_0x514f('0x31')]);_0x17ed78[_0x514f('0x30')]=qs['offset'](_0x1cf256['query'][_0x514f('0x30')]);}return _0x271044[_0x514f('0x145')](_0x17ed78);}})[_0x514f('0x22')](function(_0x8f3533){if(_0x8f3533){return _0x8f3533?{'count':_0x1d7879,'rows':_0x8f3533}:null;}})['then'](respondWithResult(_0x40e250,null))[_0x514f('0x2b')](handleError(_0x40e250,null));};exports[_0x514f('0x147')]=function(_0x3de0e4,_0x45d6bc,_0x3229ee){return db[_0x514f('0x59')]['find']({'where':{'id':_0x3de0e4[_0x514f('0x5d')]['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x45d6bc,null))[_0x514f('0x22')](function(_0x5b10d9){if(_0x5b10d9){return _0x5b10d9[_0x514f('0x147')](_0x3de0e4['body'][_0x514f('0x65')],_[_0x514f('0x109')](_0x3de0e4[_0x514f('0x62')],[_0x514f('0x65'),'id'])||{});}})[_0x514f('0x22')](respondWithResult(_0x45d6bc,null))[_0x514f('0x2b')](handleError(_0x45d6bc,null));};exports[_0x514f('0x148')]=function(_0x2c5395,_0x3d08d2,_0x200323){return db['User'][_0x514f('0x40')]({'where':{'id':_0x2c5395[_0x514f('0x5d')]['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x3d08d2,null))['then'](function(_0x49771d){if(_0x49771d){return _0x49771d[_0x514f('0x148')](_0x2c5395['query']['ids']);}})[_0x514f('0x22')](respondWithStatusCode(_0x3d08d2,null))[_0x514f('0x2b')](handleError(_0x3d08d2,null));};exports[_0x514f('0x149')]=function(_0x4e2848,_0x508fd8,_0x597dfe){var _0x286629={};var _0x581f8a={};var _0x3432e0;var _0x5a14ab;return db['User'][_0x514f('0x9c')]({'where':{'id':_0x4e2848[_0x514f('0x5d')]['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x508fd8,null))[_0x514f('0x22')](function(_0x3dda0c){if(_0x3dda0c){_0x3432e0=_0x3dda0c;_0x581f8a['model']=_[_0x514f('0x4a')](db[_0x514f('0x14a')]['rawAttributes']);_0x581f8a['query']=_['keys'](_0x4e2848[_0x514f('0x4b')]);_0x581f8a[_0x514f('0x4c')]=_[_0x514f('0x4d')](_0x581f8a[_0x514f('0x47')],_0x581f8a['query']);_0x286629[_0x514f('0x4f')]=_[_0x514f('0x4d')](_0x581f8a['model'],qs[_0x514f('0x4e')](_0x4e2848['query'][_0x514f('0x4e')]));_0x286629[_0x514f('0x4f')]=_0x286629[_0x514f('0x4f')][_0x514f('0x60')]?_0x286629[_0x514f('0x4f')]:_0x581f8a[_0x514f('0x47')];_0x286629['order']=qs[_0x514f('0x52')](_0x4e2848[_0x514f('0x4b')][_0x514f('0x52')]);_0x286629[_0x514f('0x53')]=qs['filters'](_[_0x514f('0xc4')](_0x4e2848[_0x514f('0x4b')],_0x581f8a['filters']));if(_0x4e2848[_0x514f('0x4b')][_0x514f('0x3b')]){_0x286629[_0x514f('0x53')]=_['merge'](_0x286629[_0x514f('0x53')],{'$or':_[_0x514f('0x3c')](_0x286629[_0x514f('0x4f')],function(_0x29b4a6){var _0x2c06af={};_0x2c06af[_0x29b4a6]={'$like':'%'+_0x4e2848[_0x514f('0x4b')][_0x514f('0x3b')]+'%'};return _0x2c06af;})});}_0x286629=_['merge']({},_0x286629,_0x4e2848[_0x514f('0x58')]);return _0x3432e0[_0x514f('0x149')](_0x286629);}})[_0x514f('0x22')](function(_0x528953){if(_0x528953){_0x5a14ab=_0x528953[_0x514f('0x60')];if(!_0x4e2848[_0x514f('0x4b')]['hasOwnProperty']('nolimit')){_0x286629['limit']=qs[_0x514f('0x31')](_0x4e2848['query'][_0x514f('0x31')]);_0x286629[_0x514f('0x30')]=qs['offset'](_0x4e2848[_0x514f('0x4b')][_0x514f('0x30')]);}return _0x3432e0['getChatWebsites'](_0x286629);}})[_0x514f('0x22')](function(_0x4b064d){if(_0x4b064d){return _0x4b064d?{'count':_0x5a14ab,'rows':_0x4b064d}:null;}})[_0x514f('0x22')](respondWithResult(_0x508fd8,null))[_0x514f('0x2b')](handleError(_0x508fd8,null));};exports[_0x514f('0x14b')]=function(_0x2209bc,_0x19ea1a,_0xc69438){return db['User'][_0x514f('0x40')]({'where':{'id':_0x2209bc[_0x514f('0x5d')]['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x19ea1a,null))[_0x514f('0x22')](function(_0x3c9522){if(_0x3c9522){return _0x3c9522['addChatWebsites'](_0x2209bc[_0x514f('0x62')][_0x514f('0x65')],_[_0x514f('0x109')](_0x2209bc['body'],['ids','id'])||{});}})['then'](respondWithResult(_0x19ea1a,null))[_0x514f('0x2b')](handleError(_0x19ea1a,null));};exports[_0x514f('0x14c')]=function(_0x1cb04d,_0x2141a5,_0xf71999){return db[_0x514f('0x59')][_0x514f('0x40')]({'where':{'id':_0x1cb04d[_0x514f('0x5d')]['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x2141a5,null))[_0x514f('0x22')](function(_0x453f94){if(_0x453f94){return _0x453f94[_0x514f('0x14c')](_0x1cb04d[_0x514f('0x4b')]['ids']);}})[_0x514f('0x22')](respondWithStatusCode(_0x2141a5,null))[_0x514f('0x2b')](handleError(_0x2141a5,null));};exports[_0x514f('0x14d')]=function(_0x1041f8,_0x52ebaa,_0x273572){var _0x2d42e9={};var _0x276e6d={};var _0x538ebc;var _0x43da5c;return db[_0x514f('0x59')][_0x514f('0x9c')]({'where':{'id':_0x1041f8[_0x514f('0x5d')]['id']}})['then'](handleEntityNotFound(_0x52ebaa,null))[_0x514f('0x22')](function(_0x42c088){if(_0x42c088){_0x538ebc=_0x42c088;_0x276e6d[_0x514f('0x47')]=_['keys'](db[_0x514f('0x14e')][_0x514f('0x5e')]);_0x276e6d[_0x514f('0x4b')]=_['keys'](_0x1041f8[_0x514f('0x4b')]);_0x276e6d[_0x514f('0x4c')]=_[_0x514f('0x4d')](_0x276e6d[_0x514f('0x47')],_0x276e6d[_0x514f('0x4b')]);_0x2d42e9[_0x514f('0x4f')]=_[_0x514f('0x4d')](_0x276e6d[_0x514f('0x47')],qs[_0x514f('0x4e')](_0x1041f8[_0x514f('0x4b')][_0x514f('0x4e')]));_0x2d42e9['attributes']=_0x2d42e9['attributes'][_0x514f('0x60')]?_0x2d42e9['attributes']:_0x276e6d[_0x514f('0x47')];_0x2d42e9[_0x514f('0x51')]=qs[_0x514f('0x52')](_0x1041f8[_0x514f('0x4b')][_0x514f('0x52')]);_0x2d42e9['where']=qs['filters'](_[_0x514f('0xc4')](_0x1041f8[_0x514f('0x4b')],_0x276e6d['filters']));if(_0x1041f8[_0x514f('0x4b')][_0x514f('0x3b')]){_0x2d42e9[_0x514f('0x53')]=_['merge'](_0x2d42e9[_0x514f('0x53')],{'$or':_['map'](_0x2d42e9[_0x514f('0x4f')],function(_0x5c9696){var _0x36f61c={};_0x36f61c[_0x5c9696]={'$like':'%'+_0x1041f8[_0x514f('0x4b')][_0x514f('0x3b')]+'%'};return _0x36f61c;})});}_0x2d42e9=_[_0x514f('0x54')]({},_0x2d42e9,_0x1041f8[_0x514f('0x58')]);return _0x538ebc['getWhatsappAccounts'](_0x2d42e9);}})[_0x514f('0x22')](function(_0x506fa7){if(_0x506fa7){_0x43da5c=_0x506fa7['length'];if(!_0x1041f8[_0x514f('0x4b')][_0x514f('0x50')](_0x514f('0xcc'))){_0x2d42e9[_0x514f('0x31')]=qs['limit'](_0x1041f8[_0x514f('0x4b')][_0x514f('0x31')]);_0x2d42e9[_0x514f('0x30')]=qs[_0x514f('0x30')](_0x1041f8[_0x514f('0x4b')][_0x514f('0x30')]);}return _0x538ebc[_0x514f('0x14d')](_0x2d42e9);}})[_0x514f('0x22')](function(_0x795c72){if(_0x795c72){return _0x795c72?{'count':_0x43da5c,'rows':_0x795c72}:null;}})['then'](respondWithResult(_0x52ebaa,null))['catch'](handleError(_0x52ebaa,null));};exports['addWhatsappAccounts']=function(_0x52946b,_0x580ee2,_0x550b9b){return db['User']['find']({'where':{'id':_0x52946b[_0x514f('0x5d')]['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x580ee2,null))['then'](function(_0x49b5e2){if(_0x49b5e2){return _0x49b5e2[_0x514f('0x14f')](_0x52946b[_0x514f('0x62')][_0x514f('0x65')],_[_0x514f('0x109')](_0x52946b[_0x514f('0x62')],[_0x514f('0x65'),'id'])||{});}})[_0x514f('0x22')](respondWithResult(_0x580ee2,null))[_0x514f('0x2b')](handleError(_0x580ee2,null));};exports[_0x514f('0x150')]=function(_0x468a25,_0x28544e,_0x71a63){return db[_0x514f('0x59')]['find']({'where':{'id':_0x468a25[_0x514f('0x5d')]['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x28544e,null))[_0x514f('0x22')](function(_0x532218){if(_0x532218){return _0x532218[_0x514f('0x150')](_0x468a25['query'][_0x514f('0x65')]);}})[_0x514f('0x22')](respondWithStatusCode(_0x28544e,null))[_0x514f('0x2b')](handleError(_0x28544e,null));};exports[_0x514f('0x151')]=function(_0x189a67,_0x265796,_0x188d3d){var _0x334c00={};var _0x2b1920={};var _0x412f00;var _0x147f41;return db[_0x514f('0x59')][_0x514f('0x9c')]({'where':{'id':_0x189a67[_0x514f('0x5d')]['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x265796,null))[_0x514f('0x22')](function(_0x1439da){if(_0x1439da){_0x412f00=_0x1439da;_0x2b1920[_0x514f('0x47')]=_[_0x514f('0x4a')](db[_0x514f('0x152')]['rawAttributes']);_0x2b1920[_0x514f('0x4b')]=_['keys'](_0x189a67[_0x514f('0x4b')]);_0x2b1920[_0x514f('0x4c')]=_[_0x514f('0x4d')](_0x2b1920['model'],_0x2b1920[_0x514f('0x4b')]);_0x334c00[_0x514f('0x4f')]=_[_0x514f('0x4d')](_0x2b1920[_0x514f('0x47')],qs[_0x514f('0x4e')](_0x189a67[_0x514f('0x4b')][_0x514f('0x4e')]));_0x334c00[_0x514f('0x4f')]=_0x334c00[_0x514f('0x4f')]['length']?_0x334c00[_0x514f('0x4f')]:_0x2b1920[_0x514f('0x47')];_0x334c00['order']=qs[_0x514f('0x52')](_0x189a67[_0x514f('0x4b')][_0x514f('0x52')]);_0x334c00[_0x514f('0x53')]=qs[_0x514f('0x4c')](_[_0x514f('0xc4')](_0x189a67['query'],_0x2b1920['filters']));if(_0x189a67[_0x514f('0x4b')][_0x514f('0x3b')]){_0x334c00[_0x514f('0x53')]=_[_0x514f('0x54')](_0x334c00[_0x514f('0x53')],{'$or':_['map'](_0x334c00[_0x514f('0x4f')],function(_0x3bb76c){var _0x408522={};_0x408522[_0x3bb76c]={'$like':'%'+_0x189a67[_0x514f('0x4b')][_0x514f('0x3b')]+'%'};return _0x408522;})});}_0x334c00=_[_0x514f('0x54')]({},_0x334c00,_0x189a67[_0x514f('0x58')]);return _0x412f00[_0x514f('0x151')](_0x334c00);}})[_0x514f('0x22')](function(_0x6134af){if(_0x6134af){_0x147f41=_0x6134af[_0x514f('0x60')];if(!_0x189a67['query'][_0x514f('0x50')](_0x514f('0xcc'))){_0x334c00[_0x514f('0x31')]=qs[_0x514f('0x31')](_0x189a67[_0x514f('0x4b')]['limit']);_0x334c00[_0x514f('0x30')]=qs[_0x514f('0x30')](_0x189a67[_0x514f('0x4b')][_0x514f('0x30')]);}return _0x412f00[_0x514f('0x151')](_0x334c00);}})[_0x514f('0x22')](function(_0x1097ec){if(_0x1097ec){return _0x1097ec?{'count':_0x147f41,'rows':_0x1097ec}:null;}})[_0x514f('0x22')](respondWithResult(_0x265796,null))[_0x514f('0x2b')](handleError(_0x265796,null));};exports[_0x514f('0x153')]=function(_0x2c7b11,_0x476355,_0x551dc){return db[_0x514f('0x59')][_0x514f('0x40')]({'where':{'id':_0x2c7b11['params']['id']}})['then'](handleEntityNotFound(_0x476355,null))[_0x514f('0x22')](function(_0x187058){if(_0x187058){return _0x187058[_0x514f('0x153')](_0x2c7b11[_0x514f('0x62')][_0x514f('0x65')],_[_0x514f('0x109')](_0x2c7b11[_0x514f('0x62')],[_0x514f('0x65'),'id'])||{});}})[_0x514f('0x22')](respondWithResult(_0x476355,null))[_0x514f('0x2b')](handleError(_0x476355,null));};exports['removeSquareProjects']=function(_0x11f867,_0x31dc96,_0x1aa8c6){return db[_0x514f('0x59')]['find']({'where':{'id':_0x11f867[_0x514f('0x5d')]['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x31dc96,null))['then'](function(_0x4290e9){if(_0x4290e9){return _0x4290e9[_0x514f('0x154')](_0x11f867[_0x514f('0x4b')][_0x514f('0x65')]);}})[_0x514f('0x22')](respondWithStatusCode(_0x31dc96,null))[_0x514f('0x2b')](handleError(_0x31dc96,null));};exports[_0x514f('0x155')]=function(_0xee1e0a,_0x3d36ed){var _0x2749bf={},_0x446f0c={},_0x5ba772={'count':0x0,'rows':[]};var _0x2b445c=db[_0x514f('0x156')][_0x514f('0x5e')];_0x446f0c[_0x514f('0x47')]=_[_0x514f('0x4a')](_0x2b445c);_0x446f0c['query']=_[_0x514f('0x4a')](_0xee1e0a[_0x514f('0x4b')]);_0x446f0c[_0x514f('0x4c')]=_[_0x514f('0x4d')](_0x446f0c['model'],_0x446f0c[_0x514f('0x4b')]);_0x446f0c[_0x514f('0x4c')]=_[_0x514f('0x157')](_0x446f0c[_0x514f('0x4c')],['$and',_0x514f('0x158'),_0x514f('0x159'),_0x514f('0x15a'),_0x514f('0x15b'),'$lte',_0x514f('0x15c'),_0x514f('0x15d'),'$not',_0x514f('0x15e'),_0x514f('0x15f'),'$in',_0x514f('0x160'),_0x514f('0x161'),_0x514f('0x162'),_0x514f('0x163'),'$notILike',_0x514f('0x161'),_0x514f('0x164'),'$contains','$contained',_0x514f('0x165')]);_0x2749bf['attributes']=_['intersection'](_0x446f0c[_0x514f('0x47')],qs[_0x514f('0x4e')](_0xee1e0a[_0x514f('0x4b')][_0x514f('0x4e')]));_0x2749bf[_0x514f('0x4f')]=_0x2749bf[_0x514f('0x4f')]['length']?_0x2749bf[_0x514f('0x4f')]:_0x446f0c['model'];if(!_0xee1e0a[_0x514f('0x4b')][_0x514f('0x50')](_0x514f('0xcc'))){_0x2749bf[_0x514f('0x31')]=qs['limit'](_0xee1e0a[_0x514f('0x4b')][_0x514f('0x31')]);_0x2749bf[_0x514f('0x30')]=qs['offset'](_0xee1e0a['query']['offset']);}_0x2749bf[_0x514f('0x51')]=qs[_0x514f('0x52')](_0xee1e0a[_0x514f('0x4b')][_0x514f('0x52')]);_0x2749bf[_0x514f('0x53')]=qs[_0x514f('0x4c')](_[_0x514f('0xc4')](_0xee1e0a[_0x514f('0x4b')],_0x446f0c[_0x514f('0x4c')]));if(_0xee1e0a['query'][_0x514f('0x3b')]){_0x2749bf[_0x514f('0x53')]=_[_0x514f('0x54')](_0x2749bf[_0x514f('0x53')],{'$or':_[_0x514f('0x3c')](_0x2749bf[_0x514f('0x4f')],function(_0x47f4ae){var _0x3bd853={};_0x3bd853[_0x47f4ae]={'$like':'%'+_0xee1e0a[_0x514f('0x4b')][_0x514f('0x3b')]+'%'};return _0x3bd853;})});}_0x2749bf[_0x514f('0x53')]={'$and':[_0x2749bf[_0x514f('0x53')],{'$or':[{'UserId':_0xee1e0a[_0x514f('0x5d')]['id']},{'OwnerId':_0xee1e0a[_0x514f('0x5d')]['id']}]}]};_0x2749bf=_[_0x514f('0x54')]({},_0x2749bf,_0xee1e0a[_0x514f('0x58')]);var _0x260680={'where':_0x2749bf[_0x514f('0x53')]};return db[_0x514f('0x156')][_0x514f('0x2f')](_0x260680)[_0x514f('0x22')](function(_0x15b428){_0x5ba772[_0x514f('0x2f')]=_0x15b428;if(_0xee1e0a[_0x514f('0x4b')][_0x514f('0x5a')]){_0x2749bf[_0x514f('0x61')]=[{'attributes':['id',_0x514f('0x166'),_0x514f('0x167'),_0x514f('0xdd')],'model':db['CmContact'],'as':'Contact'},{'attributes':['id',_0x514f('0x41'),_0x514f('0x168')],'model':db[_0x514f('0xb2')],'as':_0x514f('0xca')}];}return db['CmHopper'][_0x514f('0x5b')](_0x2749bf);})[_0x514f('0x22')](function(_0x14f839){_0x5ba772[_0x514f('0xd2')]=_0x14f839;return _0x5ba772;})[_0x514f('0x22')](respondWithFilteredResult(_0x3d36ed,_0x2749bf))[_0x514f('0x2b')](handleError(_0x3d36ed,null));};exports[_0x514f('0x169')]=function(_0x5adedd,_0x4540d4,_0x1ddc06){if(!_['isNil'](_0x5adedd['user']['id'])&&(_0x5adedd['user'][_0x514f('0x3f')]=='admin'||_0x5adedd[_0x514f('0x7f')][_0x514f('0x3f')]==_0x514f('0x7f'))){return db[_0x514f('0x59')][_0x514f('0x9c')]({'where':{'id':_0x5adedd[_0x514f('0x5d')]['id']},'raw':!![]})[_0x514f('0x22')](function(_0xcf43ac){return authService[_0x514f('0x16a')](_0xcf43ac);})['then'](function(_0x570228){if(_0x570228){return _0x4540d4['status'](0xc8)[_0x514f('0x2e')]({'api_key':_0x570228['token']});}else{return _0x4540d4[_0x514f('0x2c')](0xcc)[_0x514f('0x2e')]({'message':'No\x20API\x20access\x20key\x20found!'});}})[_0x514f('0x2b')](handleError(_0x4540d4,0x193));}else{return _0x4540d4['status'](0x191)[_0x514f('0x2e')]({'message':'You\x20don\x27t\x20have\x20sufficient\x20privileges\x20to\x20access\x20this\x20resource.'});}};exports[_0x514f('0x16b')]=function(_0x2d0e1f,_0x5beff2,_0xeedb88){if(!_['isNil'](_0x2d0e1f[_0x514f('0x7f')]['id'])&&(_0x2d0e1f['user']['role']==_0x514f('0x80')||_0x2d0e1f['user'][_0x514f('0x3f')]==_0x514f('0x7f'))){return db['User'][_0x514f('0x40')]({'where':{'id':_0x2d0e1f[_0x514f('0x5d')]['id']}})[_0x514f('0x22')](function(_0x1427af){return authService[_0x514f('0x16c')](_0x1427af);})['then'](function(_0x48051d){return db[_0x514f('0x59')]['update']({'apiKeyIat':_0x48051d[_0x514f('0x16d')],'apiKeyNonce':_0x48051d[_0x514f('0x16e')]},{'where':{'id':_0x2d0e1f[_0x514f('0x5d')]['id']}})[_0x514f('0x22')](function(){return _0x5beff2[_0x514f('0x2c')](0xc8)[_0x514f('0x2e')]({'api_key':_0x48051d[_0x514f('0x16f')]});});})[_0x514f('0x2b')](handleError(_0x5beff2,0x193));}else{return _0x5beff2[_0x514f('0x2c')](0x191)[_0x514f('0x2e')]({'message':_0x514f('0x170')});}};exports[_0x514f('0x171')]=function(_0x123978,_0x4f490e,_0x2d0823){if(!_['isNil'](_0x123978[_0x514f('0x7f')]['id'])&&(_0x123978[_0x514f('0x7f')][_0x514f('0x3f')]=='admin'||_0x123978['user']['role']=='user')){return db['User'][_0x514f('0x40')]({'where':{'id':_0x123978[_0x514f('0x5d')]['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x4f490e,null))['then'](function(_0x228b1e){if(_0x228b1e&&_0x228b1e[_0x514f('0x172')]&&_0x228b1e[_0x514f('0x173')])return _0x228b1e;else throw{'message':'API\x20key\x20not\x20available'};})[_0x514f('0x22')](function(_0x52ca43){return db[_0x514f('0x59')][_0x514f('0x35')]({'apiKeyNonce':null,'apiKeyIat':null},{'where':{'id':_0x123978[_0x514f('0x5d')]['id']}});})[_0x514f('0x22')](respondWithStatusCode(_0x4f490e,0xc8))[_0x514f('0x2b')](handleError(_0x4f490e,0x193));}else{return _0x4f490e[_0x514f('0x2c')](0x191)['json']({'message':_0x514f('0x170')});}};exports[_0x514f('0x174')]=function(_0x2fd830,_0x21ea61){var _0x201dc2=_0x2fd830['user'][_0x514f('0x37')]({'plain':!![]});if(!_0x201dc2){return _0x21ea61[_0x514f('0x2c')](0x191)[_0x514f('0x44')](_0x514f('0x175'));}else{return _0x21ea61[_0x514f('0x2c')](0xc8)['json'](_0x201dc2);}};
\ No newline at end of file