X-Git-Url: http://repos.xcallymotion.com/?a=blobdiff_plain;f=server%2Fapi%2Fuser%2Fuser.controller.js;h=d3832656efb206101e756b1f7dd73c88b3ce1dea;hb=91492537a7b94b14914d0db658458118de1ea819;hp=2597a05cc716105f08bfb8e45af48f3bab5b3949;hpb=30647e0599beaeefd7f4697661375cd56f1291ec;p=motion2.git diff --git a/server/api/user/user.controller.js b/server/api/user/user.controller.js index 2597a05..d383265 100644 --- a/server/api/user/user.controller.js +++ b/server/api/user/user.controller.js @@ -15,4 +15,4 @@ // * treaties. The SOFTWARE PRODUCT is licensed, not sold. * // * * // ************************************************************************* -var _0xadcc=['Openchannel','getLists','CmList','getAgents','values','You\x20can\x27t\x20delete\x20yourself','addChatInteractions','user_has_chat_interactions:save','removeChatInteractions','user_has_chat_interactions:remove','addMailInteractions','user_has_mail_interactions:save','removeMailInteractions','user_has_mail_interactions:remove','addFaxInteractions','user_has_fax_interactions:save','removeFaxInteractions','user_has_fax_interactions:remove','addSmsInteractions','user_has_sms_interactions:save','removeSmsInteractions','user_has_sms_interactions:remove','addOpenchannelInteractions','removeOpenchannelInteractions','user_has_openchannel_interactions:remove','addWhatsappInteractions','user_has_whatsapp_interactions:save','removeWhatsappInteractions','getVoicePrefixes','VoicePrefix','FaxAccount','getFaxAccounts','addFaxAccounts','removeFaxAccounts','getMailAccounts','MailAccount','addMailAccounts','getOpenchannelAccounts','addOpenchannelAccounts','removeOpenchannelAccounts','getSmsAccounts','addSmsAccounts','removeSmsAccounts','getChatWebsites','addChatWebsites','removeChatWebsites','WhatsappAccount','getWhatsappAccounts','addWhatsappAccounts','removeWhatsappAccounts','getSquareProjects','SquareProject','addSquareProjects','removeSquareProjects','getScheduledCalls','CmHopper','$and','$or','$gt','$gte','$lt','$lte','$ne','$eq','$not','$between','$notBetween','$in','$like','$iLike','$overlap','$any','firstName','lastName','phone','Contact','dialActive','VoiceQueue','getApiKey','retrieveApiKey','token','No\x20API\x20access\x20key\x20found!','You\x20don\x27t\x20have\x20sufficient\x20privileges\x20to\x20access\x20this\x20resource.','createApiKey','generateApiKey','iat','nonce','apiKeyNonce','apiKeyIat','API\x20key\x20not\x20available','Unable\x20to\x20retrieve\x20the\x20current\x20user','resolve','teams','queues','isEmpty','lower','col','toString','asc','desc','substring','uniqBy','orderBy','Unable\x20to\x20retrieve\x20RPC\x20agents\x20(AMI)','client','unknown','voiceStatus','busy','slice','toUpperCase','select','field','ui.','InteractionId','ui.createdAt','user_has_','ui.UserId\x20=\x20?','OpenTabs','moment','util','path','lodash','squel','jayson/promise','../../components/parsers/qs','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','socket.io-emitter','redis','./user.socket','register','defaults','http','request','then','info','request\x20sent','User,\x20%s,\x20%s,\x20%s','stringify','error','code','User,\x20%s,\x20%s','message','result','end','status','json','limit','undefined','count','offset','update','destroy','admin','Users','user','Agents','agent','Telephones','telephone','filter','ignore','map','value','find','name','UserProfileResource','sendStatus','stack','send','index','User','rawAttributes','fieldName','type','key','includes','password','getOptions','where','query','includeAll','include','attributes','push','findAll','rows','true','length','dataValues','sms','fax','mail','whatsapp','all','show','params','model','differenceBy','keys','filters','intersection','merge','openTabs','openchannel','catch','body','role','describe','addContacts','omit','ids','internal','Setting','findById','validatePasswordPattern','max','isNil','min_internal','sequelize','select\x20(select\x20IFNULL(max(internal)+1,1)\x20from\x20users\x20where\x20internal\x20<\x20md.internal)\x20as\x20\x27from\x27,\x20md.internal\x20-\x201\x20as\x20\x27to\x27\x20from\x20users\x20md\x20where\x20md.internal\x20!=\x201\x20and\x20not\x20exists\x20(select\x201\x20from\x20users\x20md2\x20where\x20md2.internal\x20=\x20md.internal\x20-\x201)','QueryTypes','SELECT','from','mailbox','VoiceMail','fullname','permissions','101','102','103','113','110','104','105','107','109','100','111','114','115','create','Unauthorized','Unauthorized.\x20You\x20must\x20be\x20an\x20administrator\x20in\x20order\x20to\x20create\x20an\x20user','checkUserLimits','settingsEnabled','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','bulkCreate','some','Unauthorized.\x20You\x20must\x20be\x20an\x20administrator\x20in\x20order\x20to\x20create\x20an\x20administrator','each','UserProfileSection','compact','changePassword','Sequelize','ValidationError','Invalid\x20body\x20format.\x20Use\x20oldPassword\x20and\x20newPassword','authenticate','Wrong\x20credentials','newPassword','New\x20password\x20must\x20be\x20different\x20from\x20old\x20password','Invalid\x20body\x20format.\x20Use\x20newPassword','findOne','securePassword','enforcePasswordHistory','passwordHistoryLimit','previousPasswords','validatePasswordHistory','updatePasswordsHistory','addQueues','online','loginInPause','voicePause','interface','isValidChannel','Unknown\x20channel','add','penalty','spread','capitalize','toLowerCase','QueueId','emit','Queue:save','voice','get','SIP/%s','UserVoiceQueueRt','upsert','removeQueues','remove','Queues','isArray','channel','Queue:remove','addAvatar','file','filename','join','root','server/files/images/logos/default_profile.png','userpic','download','existsSync','server/files/images/','getOpenTabs','ChatOpenTabs','CHAT','createdAt','FaxOpenTabs','FAX','OpenchannelOpenTabs','OPENCHANNEL','MailOpenTabs','MAIL','SmsOpenTabs','SMS','WhatsappOpenTabs','WHATSAPP','getContacts','CmContact','fields','sort','options','List','color','tag','hasOwnProperty','nolimit','getQueues','order','pick','Queue','Unknown\x20role','getVoiceQueuesRt','getGroups','ChatGroup','getRecordings','VoiceRecording','getScreenRecordings','ScreenRecording','UserId','getChatInteractions','getOpenchannelInteractions','OpenchannelInteraction','getMailInteractions','MailInteraction','getSmsInteractions','SmsInteraction','FaxInteraction','getFaxInteractions','getWhatsappInteractions','login','mobile','format','intrf','user:forcelogout','headers','x-forwarded-for','connection','socket','remoteAddress','getVoiceQueues','UserVoiceQueue.penalty','MemberReport','forEach','YYYY-MM-DD\x20HH:mm:ss','LOGIN','device','PAUSE','LOGININPAUSE','concat','logout','pause','updateAttributes','DEFAULT\x20PAUSE','unpause','mailPause','chatPause','openchannelPause','whatsapppause','pauseType','lastPauseAt','QueuePause','manual','chat','set','%s%s','Pause','Team','getTeams','addTeams','Voice','getChatQueues','getMailQueues','setDataValue','Mail','getSmsQueues','Sms','Whatsapp','getFaxQueues','Fax','getOpenchannelQueues','flatten','transaction','addAgent','getDataValue','removeTeams','getWhatsappQueues'];(function(_0x5641f7,_0x24692c){var _0x3d22c2=function(_0x2de829){while(--_0x2de829){_0x5641f7['push'](_0x5641f7['shift']());}};_0x3d22c2(++_0x24692c);}(_0xadcc,0x76));var _0xcadc=function(_0x1eaeb3,_0x26295b){_0x1eaeb3=_0x1eaeb3-0x0;var _0xe4532b=_0xadcc[_0x1eaeb3];return _0xe4532b;};'use strict';var moment=require(_0xcadc('0x0'));var BPromise=require('bluebird');var util=require(_0xcadc('0x1'));var path=require(_0xcadc('0x2'));var fs=require('fs');var _=require(_0xcadc('0x3'));var squel=require(_0xcadc('0x4'));var jayson=require(_0xcadc('0x5'));var Redis=require('ioredis');var authService=require('../../components/auth/service');var qs=require(_0xcadc('0x6'));var logger=require(_0xcadc('0x7'))(_0xcadc('0x8'));var utils=require(_0xcadc('0x9'));var config=require(_0xcadc('0xa'));var licenseUtil=require(_0xcadc('0xb'));var db=require(_0xcadc('0xc'))['db'];var socket=require(_0xcadc('0xd'))(new Redis(config[_0xcadc('0xe')]));require(_0xcadc('0xf'))[_0xcadc('0x10')](socket);config[_0xcadc('0xe')]=_[_0xcadc('0x11')](config[_0xcadc('0xe')],{'host':'localhost','port':0x18eb});var client=jayson['client'][_0xcadc('0x12')]({'port':0x232a});var values;function respondWithRpcPromise(_0x23fac5,_0x52e208,_0x2431de,_0xa2b7ba){return new BPromise(function(_0x41581a,_0x52c540){var _0x4b35c4=_0xa2b7ba||client;return _0x4b35c4[_0xcadc('0x13')](_0x23fac5,_0x2431de)[_0xcadc('0x14')](function(_0x118388){logger[_0xcadc('0x15')]('User,\x20%s,\x20%s',_0x52e208,_0xcadc('0x16'));logger['debug'](_0xcadc('0x17'),_0x52e208,_0xcadc('0x16'),JSON[_0xcadc('0x18')](_0x118388));if(_0x118388['error']){if(_0x118388[_0xcadc('0x19')][_0xcadc('0x1a')]===0x1f4){logger['error'](_0xcadc('0x1b'),_0x52e208,_0x118388['error'][_0xcadc('0x1c')]);return _0x52c540(_0x118388[_0xcadc('0x19')][_0xcadc('0x1c')]);}logger[_0xcadc('0x19')](_0xcadc('0x1b'),_0x52e208,_0x118388['error'][_0xcadc('0x1c')]);return _0x41581a(_0x118388[_0xcadc('0x19')][_0xcadc('0x1c')]);}else{logger[_0xcadc('0x15')](_0xcadc('0x1b'),_0x52e208,_0xcadc('0x16'));_0x41581a(_0x118388[_0xcadc('0x1d')][_0xcadc('0x1c')]);}})['catch'](function(_0x54c190){logger[_0xcadc('0x19')](_0xcadc('0x1b'),_0x52e208,_0x54c190);_0x52c540(_0x54c190);});});}function respondWithStatusCode(_0x5186a1,_0x905a25){_0x905a25=_0x905a25||0xcc;return function(_0x403531){if(_0x403531){return _0x5186a1['sendStatus'](_0x905a25);}return _0x5186a1['status'](_0x905a25)[_0xcadc('0x1e')]();};}function respondWithResult(_0x5258b1,_0x3257ef){_0x3257ef=_0x3257ef||0xc8;return function(_0x51f3fb){if(_0x51f3fb){return _0x5258b1[_0xcadc('0x1f')](_0x3257ef)[_0xcadc('0x20')](_0x51f3fb);}};}function respondWithFilteredResult(_0x4c47b8,_0x3239ba){return function(_0x3e8311){if(_0x3e8311){var _0x5c1338=typeof _0x3239ba['offset']==='undefined'&&typeof _0x3239ba[_0xcadc('0x21')]===_0xcadc('0x22');var _0x59c6f8=_0x3e8311[_0xcadc('0x23')];var _0x4d8cdc=_0x5c1338?0x0:_0x3239ba[_0xcadc('0x24')];var _0x34ceac=_0x5c1338?_0x3e8311[_0xcadc('0x23')]:_0x3239ba[_0xcadc('0x24')]+_0x3239ba[_0xcadc('0x21')];var _0x373470;if(_0x34ceac>=_0x59c6f8){_0x34ceac=_0x59c6f8;_0x373470=0xc8;}else{_0x373470=0xce;}_0x4c47b8['status'](_0x373470);return _0x4c47b8['set']('Content-Range',_0x4d8cdc+'-'+_0x34ceac+'/'+_0x59c6f8)[_0xcadc('0x20')](_0x3e8311);}return null;};}function saveUpdates(_0x31b7fd){return function(_0x3a19d1){if(_0x3a19d1){return _0x3a19d1[_0xcadc('0x25')](_0x31b7fd)[_0xcadc('0x14')](function(_0x309e29){return _0x309e29;});}return null;};}function removeEntity(_0x3f457c){return function(_0xdf8b14){if(_0xdf8b14){return _0xdf8b14[_0xcadc('0x26')]()[_0xcadc('0x14')](function(){var _0x15bce8=_0xdf8b14['get']({'plain':!![]});if(_0x15bce8['role']===_0xcadc('0x27'))return;var _0x192dfa=[{'name':_0xcadc('0x28'),'value':_0xcadc('0x29'),'ignore':!![]},{'name':_0xcadc('0x2a'),'value':_0xcadc('0x2b'),'ignore':![]},{'name':_0xcadc('0x2c'),'value':_0xcadc('0x2d'),'ignore':![]}];var _0x67dbee=_(_0x192dfa)[_0xcadc('0x2e')](_0xcadc('0x2f'))[_0xcadc('0x30')](_0xcadc('0x31'))['value']();if(_['includes'](_0x67dbee,_0x15bce8['role'])){return;}var _0x568d3b=_[_0xcadc('0x32')](_0x192dfa,['value',_0x15bce8['role']])[_0xcadc('0x33')];return db[_0xcadc('0x34')][_0xcadc('0x26')]({'where':{'type':_0x568d3b,'resourceId':_0x15bce8['id']}})[_0xcadc('0x14')](function(){return _0xdf8b14;});})[_0xcadc('0x14')](function(){_0x3f457c['status'](0xcc)[_0xcadc('0x1e')]();});}};}function handleEntityNotFound(_0x278f61){return function(_0x533e91){if(!_0x533e91){_0x278f61[_0xcadc('0x35')](0x194);}return _0x533e91;};}function handleError(_0xdffa7,_0x45c749){_0x45c749=_0x45c749||0x1f4;return function(_0x3db100){logger['error'](_0x3db100[_0xcadc('0x36')]);if(_0x3db100[_0xcadc('0x33')]){delete _0x3db100[_0xcadc('0x33')];}_0xdffa7[_0xcadc('0x1f')](_0x45c749)[_0xcadc('0x37')](_0x3db100);};}exports[_0xcadc('0x38')]=function(_0x4d4109,_0x1cdcd2){var _0x5ce74e={},_0x1bb5bc={'count':0x0,'rows':[]};var _0x2a673a=_(db[_0xcadc('0x39')][_0xcadc('0x3a')])[_0xcadc('0x30')](function(_0xa91962){return{'name':_0xa91962[_0xcadc('0x3b')],'type':_0xa91962[_0xcadc('0x3c')][_0xcadc('0x3d')]};})[_0xcadc('0x2e')](function(_0x4c63bb){return!_[_0xcadc('0x3e')]([_0xcadc('0x3f'),'salt'],_0x4c63bb['name']);})[_0xcadc('0x31')]();_0x5ce74e=qs[_0xcadc('0x40')](_0x2a673a,_0x4d4109);var _0xc94713={'where':_0x5ce74e[_0xcadc('0x41')]};return db[_0xcadc('0x39')][_0xcadc('0x23')](_0xc94713)['then'](function(_0x4f8cd6){_0x1bb5bc[_0xcadc('0x23')]=_0x4f8cd6;if(_0x4d4109[_0xcadc('0x42')][_0xcadc('0x43')]){_0x5ce74e[_0xcadc('0x44')]=[{'all':!![]}];}if(!_['includes'](_0x5ce74e[_0xcadc('0x45')],'id')){_0x5ce74e[_0xcadc('0x45')][_0xcadc('0x46')]('id');}return db[_0xcadc('0x39')][_0xcadc('0x47')](_0x5ce74e);})[_0xcadc('0x14')](function(_0x1d70dd){_0x1bb5bc[_0xcadc('0x48')]=_0x1d70dd;if(_0x4d4109['query']['openTabs']===_0xcadc('0x49')){var _0x3f324a=[];for(var _0x4b64c5=0x0;_0x4b64c5<_0x1bb5bc[_0xcadc('0x48')][_0xcadc('0x4a')];_0x4b64c5++){_0x3f324a[_0xcadc('0x46')](get_open_tabs('chat',_0x1bb5bc[_0xcadc('0x48')][_0x4b64c5][_0xcadc('0x4b')]));_0x3f324a[_0xcadc('0x46')](get_open_tabs(_0xcadc('0x4c'),_0x1bb5bc[_0xcadc('0x48')][_0x4b64c5]['dataValues']));_0x3f324a[_0xcadc('0x46')](get_open_tabs(_0xcadc('0x4d'),_0x1bb5bc[_0xcadc('0x48')][_0x4b64c5][_0xcadc('0x4b')]));_0x3f324a[_0xcadc('0x46')](get_open_tabs(_0xcadc('0x4e'),_0x1bb5bc[_0xcadc('0x48')][_0x4b64c5][_0xcadc('0x4b')]));_0x3f324a[_0xcadc('0x46')](get_open_tabs('openchannel',_0x1bb5bc[_0xcadc('0x48')][_0x4b64c5][_0xcadc('0x4b')]));_0x3f324a['push'](get_open_tabs(_0xcadc('0x4f'),_0x1bb5bc[_0xcadc('0x48')][_0x4b64c5]['dataValues']));}return BPromise[_0xcadc('0x50')](_0x3f324a)[_0xcadc('0x14')](function(_0x10c2d1){return _0x1bb5bc;});}else{return _0x1bb5bc;}})[_0xcadc('0x14')](respondWithFilteredResult(_0x1cdcd2,_0x5ce74e))['catch'](handleError(_0x1cdcd2,null));};exports[_0xcadc('0x51')]=function(_0x4663d6,_0xb5de8b){var _0x3bd06d={'raw':![],'where':{'id':_0x4663d6[_0xcadc('0x52')]['id']}},_0xa04d9c={};_0xa04d9c[_0xcadc('0x53')]=_[_0xcadc('0x54')](_[_0xcadc('0x55')](db[_0xcadc('0x39')][_0xcadc('0x3a')]),[_0xcadc('0x3f'),'salt']);_0xa04d9c[_0xcadc('0x42')]=_[_0xcadc('0x55')](_0x4663d6['query']);_0xa04d9c[_0xcadc('0x56')]=_[_0xcadc('0x57')](_0xa04d9c[_0xcadc('0x53')],_0xa04d9c[_0xcadc('0x42')]);_0x3bd06d['attributes']=_[_0xcadc('0x57')](_0xa04d9c[_0xcadc('0x53')],qs['fields'](_0x4663d6[_0xcadc('0x42')]['fields']));_0x3bd06d['attributes']=_0x3bd06d['attributes'][_0xcadc('0x4a')]?_0x3bd06d['attributes']:_0xa04d9c[_0xcadc('0x53')];if(_0x4663d6['query'][_0xcadc('0x43')]){_0x3bd06d[_0xcadc('0x44')]=[{'all':!![]}];}_0x3bd06d=_[_0xcadc('0x58')]({},_0x3bd06d,_0x4663d6['options']);if(!_[_0xcadc('0x3e')](_0x3bd06d[_0xcadc('0x45')],'id')){_0x3bd06d[_0xcadc('0x45')][_0xcadc('0x46')]('id');}return db['User'][_0xcadc('0x32')](_0x3bd06d)['then'](handleEntityNotFound(_0xb5de8b,null))[_0xcadc('0x14')](function(_0x2b2b9f){var _0x5b6af8=[];values=_0x2b2b9f;if(_0x4663d6[_0xcadc('0x42')][_0xcadc('0x59')]===_0xcadc('0x49')){_0x5b6af8['push'](get_open_tabs('chat',_0x2b2b9f[_0xcadc('0x4b')]));_0x5b6af8['push'](get_open_tabs(_0xcadc('0x4c'),_0x2b2b9f[_0xcadc('0x4b')]));_0x5b6af8[_0xcadc('0x46')](get_open_tabs(_0xcadc('0x5a'),_0x2b2b9f[_0xcadc('0x4b')]));_0x5b6af8[_0xcadc('0x46')](get_open_tabs(_0xcadc('0x4f'),_0x2b2b9f[_0xcadc('0x4b')]));_0x5b6af8['push'](get_open_tabs(_0xcadc('0x4d'),_0x2b2b9f[_0xcadc('0x4b')]));_0x5b6af8[_0xcadc('0x46')](get_open_tabs(_0xcadc('0x4e'),_0x2b2b9f[_0xcadc('0x4b')]));return BPromise[_0xcadc('0x50')](_0x5b6af8);}else{return values;}})[_0xcadc('0x14')](function(_0x569f3e){return values;})[_0xcadc('0x14')](respondWithResult(_0xb5de8b,null))[_0xcadc('0x5b')](handleError(_0xb5de8b,null));};exports[_0xcadc('0x25')]=function(_0x2f1805,_0x1c34be){if(_0x2f1805['body']['id']){delete _0x2f1805['body']['id'];}delete _0x2f1805[_0xcadc('0x5c')][_0xcadc('0x5d')];return db[_0xcadc('0x39')][_0xcadc('0x32')]({'where':{'id':_0x2f1805[_0xcadc('0x52')]['id']}})[_0xcadc('0x14')](handleEntityNotFound(_0x1c34be,null))[_0xcadc('0x14')](saveUpdates(_0x2f1805[_0xcadc('0x5c')],null))[_0xcadc('0x14')](respondWithResult(_0x1c34be,null))['catch'](handleError(_0x1c34be,null));};exports[_0xcadc('0x5e')]=function(_0x4fd4ad,_0x4d527f){return db[_0xcadc('0x39')][_0xcadc('0x5e')]()['then'](respondWithResult(_0x4d527f,null))[_0xcadc('0x5b')](handleError(_0x4d527f,null));};exports[_0xcadc('0x5f')]=function(_0x1c9960,_0x12391d){return db[_0xcadc('0x39')][_0xcadc('0x32')]({'where':{'id':_0x1c9960[_0xcadc('0x52')]['id']}})[_0xcadc('0x14')](handleEntityNotFound(_0x12391d,null))[_0xcadc('0x14')](function(_0x504b05){if(_0x504b05){return _0x504b05[_0xcadc('0x5f')](_0x1c9960['body']['ids'],_[_0xcadc('0x60')](_0x1c9960[_0xcadc('0x5c')],[_0xcadc('0x61'),'id'])||{});}})[_0xcadc('0x14')](respondWithResult(_0x12391d,null))[_0xcadc('0x5b')](handleError(_0x12391d,null));};function validateUser(_0x16d9ac){return new BPromise(function(_0x2776e6,_0x4d4074){if(_0x16d9ac[_0xcadc('0x62')])return _0x2776e6(_0x16d9ac);return db[_0xcadc('0x63')][_0xcadc('0x64')](0x1)[_0xcadc('0x14')](function(_0x1c6090){if(_0x1c6090['securePassword'])authService[_0xcadc('0x65')](_0x16d9ac[_0xcadc('0x3f')]);db[_0xcadc('0x39')][_0xcadc('0x66')](_0xcadc('0x62'))[_0xcadc('0x14')](function(_0x181906){if(_[_0xcadc('0x67')](_0x181906)){_0x16d9ac[_0xcadc('0x62')]=_0x1c6090[_0xcadc('0x68')]||0x1;return;}if(_[_0xcadc('0x67')](_0x1c6090[_0xcadc('0x68')])||_0x1c6090[_0xcadc('0x68')]===_0x181906){_0x16d9ac[_0xcadc('0x62')]=_0x181906+0x1;return;}if(_0x1c6090['min_internal']>_0x181906){_0x16d9ac[_0xcadc('0x62')]=_0x1c6090[_0xcadc('0x68')];return;}return db[_0xcadc('0x69')][_0xcadc('0x42')](_0xcadc('0x6a'),{'type':db['sequelize'][_0xcadc('0x6b')][_0xcadc('0x6c')]})[_0xcadc('0x14')](function(_0x4010e4){if(_0x4010e4&&_0x4010e4[_0xcadc('0x4a')]){for(var _0x1f9780=0x0,_0x3ab5f2=_0x4010e4[_0xcadc('0x4a')];_0x1f9780<_0x3ab5f2&&_[_0xcadc('0x67')](_0x16d9ac['internal']);_0x1f9780++){if(_0x1c6090[_0xcadc('0x68')]<=_0x4010e4[_0x1f9780][_0xcadc('0x6d')]){_0x16d9ac[_0xcadc('0x62')]=_0x4010e4[_0x1f9780][_0xcadc('0x6d')];}else if(_0x1c6090[_0xcadc('0x68')]>_0x4010e4[_0x1f9780][_0xcadc('0x6d')]&&_0x1c6090[_0xcadc('0x68')]<=_0x4010e4[_0x1f9780]['to']){_0x16d9ac['internal']=_0x1c6090[_0xcadc('0x68')];}}}if(_[_0xcadc('0x67')](_0x16d9ac[_0xcadc('0x62')])){_0x16d9ac[_0xcadc('0x62')]=_0x181906+0x1;}return _0x2776e6(_0x16d9ac);});});})[_0xcadc('0x5b')](function(_0x473fe9){_0x4d4074(_0x473fe9);});});}function updateUser(_0x20c744){return new BPromise(function(_0x3fd1fb,_0x261eca){try{if(_0x20c744['voicemail']){_0x20c744[_0xcadc('0x6e')]=_0x20c744[_0xcadc('0x62')];_0x20c744[_0xcadc('0x6f')]={'mailbox':_0x20c744['internal'],'password':_0x20c744[_0xcadc('0x3f')],'fullname':_0x20c744[_0xcadc('0x70')],'email':_0x20c744['email']};}if(_0x20c744[_0xcadc('0x5d')]===_0xcadc('0x2b')){if(!_0x20c744[_0xcadc('0x71')])_0x20c744[_0xcadc('0x71')]=[_0xcadc('0x72'),_0xcadc('0x73'),_0xcadc('0x74'),_0xcadc('0x75'),_0xcadc('0x76'),_0xcadc('0x77'),_0xcadc('0x78'),'106',_0xcadc('0x79'),'108',_0xcadc('0x7a'),_0xcadc('0x7b'),_0xcadc('0x7c'),_0xcadc('0x7d'),_0xcadc('0x7e')];}_0x3fd1fb(_0x20c744);}catch(_0x4dcf0e){_0x261eca(_0x4dcf0e);}});}exports[_0xcadc('0x7f')]=function(_0x2189b1,_0x2908c9){if(_0x2189b1[_0xcadc('0x29')][_0xcadc('0x5d')]===_0xcadc('0x2b'))throw new Error(_0xcadc('0x80'));if(_0x2189b1['body'][_0xcadc('0x5d')]===_0xcadc('0x29')&&_0x2189b1[_0xcadc('0x29')][_0xcadc('0x5d')]!==_0xcadc('0x27')){throw new Error(_0xcadc('0x81'));}if(_0x2189b1[_0xcadc('0x5c')][_0xcadc('0x5d')]===_0xcadc('0x27')&&_0x2189b1[_0xcadc('0x29')][_0xcadc('0x5d')]!==_0xcadc('0x27')){throw new Error('Unauthorized.\x20You\x20must\x20be\x20an\x20administrator\x20in\x20order\x20to\x20create\x20another\x20administrator');}return licenseUtil[_0xcadc('0x82')]([_0x2189b1[_0xcadc('0x5c')]])[_0xcadc('0x14')](function(){return validateUser(_0x2189b1['body']);})[_0xcadc('0x14')](function(_0x5e95c5){return updateUser(_0x5e95c5)[_0xcadc('0x14')](function(_0xd7111b){if(_0xd7111b[_0xcadc('0x5d')]===_0xcadc('0x27')){_0xd7111b[_0xcadc('0x83')]=_0x2189b1[_0xcadc('0x29')][_0xcadc('0x83')];delete _0xd7111b[_0xcadc('0x84')];}return _0xd7111b;});})[_0xcadc('0x14')](function(_0x2fd110){return db[_0xcadc('0x39')][_0xcadc('0x7f')](_0x2fd110,{'include':[{'model':db[_0xcadc('0x6f')],'as':_0xcadc('0x6f')}]});})[_0xcadc('0x14')](function(_0x199795){if(_0x2189b1['body'][_0xcadc('0x5d')]==='user')return _0x199795;if(_0x2189b1[_0xcadc('0x29')][_0xcadc('0x5d')]!=='user')return _0x199795;return db['UserProfileSection']['find']({'where':{'name':_0x199795[_0xcadc('0x5d')]==='agent'?'Agents':'Telephones','userProfileId':_0x2189b1[_0xcadc('0x29')]['userProfileId']},'raw':!![]})[_0xcadc('0x14')](function(_0xf8de7d){if(!_0xf8de7d||_0xf8de7d[_0xcadc('0x85')]!=0x0)return _0x199795;return db[_0xcadc('0x34')][_0xcadc('0x7f')]({'name':_0x199795[_0xcadc('0x33')],'resourceId':_0x199795['id'],'type':_0xf8de7d[_0xcadc('0x33')],'sectionId':_0xf8de7d['id']},{})[_0xcadc('0x14')](function(){return _0x199795;});})[_0xcadc('0x5b')](function(_0x39aa15){logger[_0xcadc('0x19')](_0xcadc('0x86'),_0x39aa15);throw _0x39aa15;});})[_0xcadc('0x14')](respondWithResult(_0x2908c9,0xc9))[_0xcadc('0x5b')](handleError(_0x2908c9,null));};exports[_0xcadc('0x87')]=function(_0x4eefcc,_0x58c317){var _0x5648ea=_0x4eefcc[_0xcadc('0x5c')];var _0x2c2f2c=[];if(_0x4eefcc[_0xcadc('0x29')]['role']===_0xcadc('0x2b'))throw new Error(_0xcadc('0x80'));if(_[_0xcadc('0x88')](_0x5648ea,[_0xcadc('0x5d'),_0xcadc('0x29')])&&_0x4eefcc[_0xcadc('0x29')][_0xcadc('0x5d')]!==_0xcadc('0x27')){throw new Error('Unauthorized.\x20You\x20must\x20be\x20an\x20administrator\x20in\x20order\x20to\x20create\x20an\x20user');}if(_[_0xcadc('0x88')](_0x5648ea,[_0xcadc('0x5d'),_0xcadc('0x27')])&&_0x4eefcc[_0xcadc('0x29')][_0xcadc('0x5d')]!==_0xcadc('0x27')){throw new Error(_0xcadc('0x89'));}return licenseUtil[_0xcadc('0x82')](_0x5648ea)[_0xcadc('0x14')](function(){return validateUser(_0x5648ea[0x0]);})[_0xcadc('0x14')](function(){for(var _0x4efe3c=0x1;_0x4efe3c<_0x5648ea[_0xcadc('0x4a')];_0x4efe3c++){var _0x498d77=_0x5648ea[_0x4efe3c-0x1][_0xcadc('0x62')];if(!_0x5648ea[_0x4efe3c]['internal'])_0x5648ea[_0x4efe3c][_0xcadc('0x62')]=_0x498d77+0x1;_0x2c2f2c[_0xcadc('0x46')](validateUser(_0x5648ea[_0x4efe3c]));}return BPromise[_0xcadc('0x50')](_0x2c2f2c);})[_0xcadc('0x14')](function(){_0x2c2f2c=[];for(var _0x536214=0x0;_0x536214<_0x5648ea[_0xcadc('0x4a')];_0x536214++){_0x2c2f2c[_0xcadc('0x46')](updateUser(_0x5648ea[_0x536214]));}return BPromise['all'](_0x2c2f2c);})['then'](function(){return BPromise[_0xcadc('0x8a')](_0x5648ea,function(_0x2bd43d){return db[_0xcadc('0x39')][_0xcadc('0x7f')](_0x2bd43d,{'include':[{'model':db[_0xcadc('0x6f')],'as':'VoiceMail'}]})[_0xcadc('0x14')](function(_0x1e03e7){_0x2bd43d['id']=_0x1e03e7['id'];return _0x2bd43d;});});})[_0xcadc('0x14')](function(_0x1fc88b){if(_0x4eefcc[_0xcadc('0x5c')][_0xcadc('0x5d')]===_0xcadc('0x29'))return _0x1fc88b;if(_0x4eefcc[_0xcadc('0x29')][_0xcadc('0x5d')]!==_0xcadc('0x29'))return _0x1fc88b;var _0x465b84=_['some'](_0x1fc88b,function(_0x10b09e){return _0x10b09e[_0xcadc('0x5d')]==='agent'||_0x10b09e[_0xcadc('0x5d')]==='telephone';});if(!_0x465b84)return _0x1fc88b;return db[_0xcadc('0x8b')][_0xcadc('0x47')]({'where':{'name':{'$or':['Agents','Telephones']},'userProfileId':_0x4eefcc[_0xcadc('0x29')][_0xcadc('0x84')]},'raw':!![]})[_0xcadc('0x14')](function(_0x1de541){if(_['isEmpty'](_0x1de541)||!_[_0xcadc('0x88')](_0x1de541,[_0xcadc('0x85'),0x0]))return _0x1fc88b;_0x2c2f2c=[];var _0x5a7d35=_(_0x1de541)[_0xcadc('0x30')](function(_0xc7dce4){if(_0xc7dce4['autoAssociation']===0x1)return;return _0xc7dce4['name']===_0xcadc('0x2a')?_0xcadc('0x2b'):_0xcadc('0x2d');})[_0xcadc('0x8c')]()[_0xcadc('0x31')]();for(var _0x2780f0=0x0;_0x2780f0<_0x1fc88b[_0xcadc('0x4a')];_0x2780f0++){if(!_[_0xcadc('0x3e')](_0x5a7d35,_0x1fc88b[_0x2780f0][_0xcadc('0x5d')]))return;var _0x5d964b=_0x1fc88b[_0x2780f0]['role']===_0xcadc('0x2b')?'Agents':'Telephones';_0x2c2f2c[_0xcadc('0x46')](db[_0xcadc('0x34')][_0xcadc('0x7f')]({'name':_0x1fc88b[_0x2780f0]['name'],'resourceId':_0x1fc88b[_0x2780f0]['id'],'type':_0x5d964b,'sectionId':_[_0xcadc('0x32')](_0x1de541,[_0xcadc('0x33'),_0x5d964b])['id']},{}));}return BPromise[_0xcadc('0x50')](_0x2c2f2c);});})[_0xcadc('0x14')](respondWithResult(_0x58c317,0xc9))[_0xcadc('0x5b')](handleError(_0x58c317,null));};exports[_0xcadc('0x8d')]=function(_0x999dd9,_0x511526){if(_0x999dd9[_0xcadc('0x5c')]['id']){delete _0x999dd9[_0xcadc('0x5c')]['id'];}return db[_0xcadc('0x39')][_0xcadc('0x32')]({'where':{'id':_0x999dd9[_0xcadc('0x52')]['id']}})['then'](function(_0x44a388){if(!_0x44a388)return null;if(_0x44a388['id']===_0x999dd9[_0xcadc('0x29')]['id']){if(!_0x999dd9['body']['oldPassword']||!_0x999dd9[_0xcadc('0x5c')]['newPassword']){throw new db[(_0xcadc('0x8e'))][(_0xcadc('0x8f'))](_0xcadc('0x90'));}if(!_0x44a388[_0xcadc('0x91')](_0x999dd9['body']['oldPassword'])){throw new db[(_0xcadc('0x8e'))][(_0xcadc('0x8f'))](_0xcadc('0x92'));}if(_0x999dd9['body']['oldPassword']===_0x999dd9[_0xcadc('0x5c')][_0xcadc('0x93')]){throw new db['Sequelize'][(_0xcadc('0x8f'))](_0xcadc('0x94'));}}else if(_0x999dd9[_0xcadc('0x29')]['role']==='admin'){if(!_0x999dd9[_0xcadc('0x5c')][_0xcadc('0x93')]){throw new db['Sequelize'][(_0xcadc('0x8f'))]('Invalid\x20body\x20format.\x20Use\x20newPassword');}}else if(_0x999dd9[_0xcadc('0x29')][_0xcadc('0x5d')]===_0xcadc('0x29')){if(!_0x999dd9[_0xcadc('0x5c')]['newPassword']){throw new db[(_0xcadc('0x8e'))][(_0xcadc('0x8f'))](_0xcadc('0x95'));}if(_0x44a388['role']!==_0xcadc('0x2b')){throw new db['Sequelize'][(_0xcadc('0x8f'))](_0xcadc('0x80'));}}else{throw new db[(_0xcadc('0x8e'))][(_0xcadc('0x8f'))](_0xcadc('0x80'));}return _0x44a388;})[_0xcadc('0x14')](handleEntityNotFound(_0x511526,null))[_0xcadc('0x14')](function(_0x1deaac){return db['Setting'][_0xcadc('0x96')]({'attributes':['id',_0xcadc('0x97'),_0xcadc('0x98'),_0xcadc('0x99')]})['then'](function(_0x5b84da){if(_0x5b84da[_0xcadc('0x97')])authService['validatePasswordPattern'](_0x999dd9['body'][_0xcadc('0x93')]);if(!_0x5b84da[_0xcadc('0x98')]||!_0x1deaac[_0xcadc('0x9a')])return _0x1deaac;authService[_0xcadc('0x9b')](_0x999dd9[_0xcadc('0x5c')][_0xcadc('0x93')],_0x1deaac['previousPasswords'],_0x5b84da[_0xcadc('0x99')]);return _0x1deaac;})[_0xcadc('0x14')](saveUpdates({'password':_0x999dd9[_0xcadc('0x5c')][_0xcadc('0x93')],'passwordResetAt':_0x999dd9[_0xcadc('0x29')]['id']==_0x999dd9[_0xcadc('0x52')]['id']?moment():null,'previousPasswords':authService[_0xcadc('0x9c')](_0x999dd9['body'][_0xcadc('0x93')],_0x1deaac[_0xcadc('0x9a')])},null));})[_0xcadc('0x14')](respondWithResult(_0x511526,null))['catch'](handleError(_0x511526,null));};exports[_0xcadc('0x9d')]=function(_0x2e3c63,_0x1c73d7){var _0x5513b3=_0x2e3c63[_0xcadc('0x5c')]['channel'];return db[_0xcadc('0x39')][_0xcadc('0x32')]({'where':{'id':_0x2e3c63['params']['id']},'attributes':['id',_0xcadc('0x33'),_0xcadc('0x5d'),_0xcadc('0x9e'),_0xcadc('0x9f'),_0xcadc('0xa0'),_0xcadc('0xa1')]})['then'](handleEntityNotFound(_0x1c73d7,null))[_0xcadc('0x14')](function(_0x4ddde4){if(_0x4ddde4){if(!utils[_0xcadc('0xa2')](_0x5513b3)){throw new db[(_0xcadc('0x8e'))][(_0xcadc('0x8f'))](_0xcadc('0xa3'));}return _0x4ddde4[_0xcadc('0xa4')+_['capitalize'](_0x5513b3['toLowerCase']())+'Queues'](_0x2e3c63[_0xcadc('0x5c')][_0xcadc('0x61')],{'penalty':_0x2e3c63[_0xcadc('0x5c')][_0xcadc('0xa5')]||0x0})[_0xcadc('0xa6')](function(_0x25f370){for(var _0x366204=0x0;_0x366204<_0x2e3c63[_0xcadc('0x5c')][_0xcadc('0x61')][_0xcadc('0x4a')];_0x366204+=0x1){var _0x16499d={'UserId':Number(_0x2e3c63[_0xcadc('0x52')]['id'])};_0x16499d[_[_0xcadc('0xa7')](_0x5513b3[_0xcadc('0xa8')]())+_0xcadc('0xa9')]=Number(_0x2e3c63['body'][_0xcadc('0x61')][_0x366204]);socket[_0xcadc('0xaa')]('user'+_[_0xcadc('0xa7')](_0x5513b3['toLowerCase']())+_0xcadc('0xab'),_0x16499d);}return _0x25f370;})[_0xcadc('0x14')](function(){if(_0x5513b3===_0xcadc('0xac')){return db['VoiceQueue'][_0xcadc('0x47')]({'where':{'id':_0x2e3c63[_0xcadc('0x5c')]['ids']||[]},'raw':!![],'attributes':['id',_0xcadc('0x33')]});}})[_0xcadc('0x14')](function(_0x44473a){var _0x46a7c7=_0x4ddde4[_0xcadc('0xad')]({'plain':!![]});var _0x381fac=[];if(_0x5513b3===_0xcadc('0xac')&&_0x46a7c7[_0xcadc('0x5d')]===_0xcadc('0x2b')&&_0x46a7c7[_0xcadc('0x9e')]){for(var _0x17d87e=0x0;_0x17d87e<_0x44473a[_0xcadc('0x4a')];_0x17d87e+=0x1){_0x381fac['push']({'membername':_0x46a7c7[_0xcadc('0x33')],'UserId':_0x46a7c7['id'],'queue_name':_0x44473a[_0x17d87e][_0xcadc('0x33')],'VoiceQueueId':_0x44473a[_0x17d87e]['id'],'interface':_[_0xcadc('0x67')](_0x46a7c7['interface'])?util['format'](_0xcadc('0xae'),_0x46a7c7['name']):_0x46a7c7['interface'],'paused':_0x46a7c7[_0xcadc('0xa0')]||![],'penalty':_0x2e3c63[_0xcadc('0x5c')][_0xcadc('0xa5')]||0x0});}return BPromise[_0xcadc('0x8a')](_0x381fac,function(_0x5f3bf1){return db[_0xcadc('0xaf')][_0xcadc('0xb0')](_0x5f3bf1);});}return _0x4ddde4;});}})[_0xcadc('0x14')](respondWithStatusCode(_0x1c73d7,null))['catch'](handleError(_0x1c73d7,null));};exports[_0xcadc('0xb1')]=function(_0x411469,_0x3a79a8){var _0x508bfb;return db[_0xcadc('0x39')]['find']({'where':{'id':_0x411469['params']['id']},'attributes':['id',_0xcadc('0x33'),_0xcadc('0x5d')]})[_0xcadc('0x14')](handleEntityNotFound(_0x3a79a8,null))[_0xcadc('0x14')](function(_0x32f492){if(_0x32f492){_0x508bfb=_0x32f492;if(!_0x411469[_0xcadc('0x42')]['channel']||!utils[_0xcadc('0xa2')](_0x411469[_0xcadc('0x42')]['channel'])){throw new db[(_0xcadc('0x8e'))][(_0xcadc('0x8f'))]('Unknown\x20channel');}return _0x32f492[_0xcadc('0xb2')+_[_0xcadc('0xa7')](_0x411469[_0xcadc('0x42')]['channel'][_0xcadc('0xa8')]())+_0xcadc('0xb3')](_0x411469[_0xcadc('0x42')][_0xcadc('0x61')]);}})[_0xcadc('0x14')](function(_0x35ce50){if(_[_0xcadc('0xb4')](_0x411469['query']['ids'])){for(var _0x40b92f=0x0;_0x40b92f<_0x411469[_0xcadc('0x42')][_0xcadc('0x61')][_0xcadc('0x4a')];_0x40b92f+=0x1){var _0x59f471={'UserId':Number(_0x411469['params']['id'])};_0x59f471[_[_0xcadc('0xa7')](_0x411469[_0xcadc('0x42')][_0xcadc('0xb5')]['toLowerCase']())+_0xcadc('0xa9')]=Number(_0x411469['query']['ids'][_0x40b92f]);socket[_0xcadc('0xaa')](_0xcadc('0x29')+_[_0xcadc('0xa7')](_0x411469[_0xcadc('0x42')]['channel'][_0xcadc('0xa8')]())+_0xcadc('0xb6'),_0x59f471);}}else{var _0x59f471={'UserId':Number(_0x411469[_0xcadc('0x52')]['id'])};_0x59f471[_[_0xcadc('0xa7')](_0x411469[_0xcadc('0x42')][_0xcadc('0xb5')][_0xcadc('0xa8')]())+_0xcadc('0xa9')]=Number(_0x411469[_0xcadc('0x42')][_0xcadc('0x61')]);socket[_0xcadc('0xaa')](_0xcadc('0x29')+_[_0xcadc('0xa7')](_0x411469[_0xcadc('0x42')][_0xcadc('0xb5')][_0xcadc('0xa8')]())+_0xcadc('0xb6'),_0x59f471);}return _0x35ce50;})[_0xcadc('0x14')](function(){if(_0x411469[_0xcadc('0x42')]['channel']===_0xcadc('0xac')){return db[_0xcadc('0xaf')][_0xcadc('0x26')]({'where':{'UserId':_0x411469['params']['id'],'VoiceQueueId':_0x411469[_0xcadc('0x42')][_0xcadc('0x61')]},'individualHooks':!![]})['then'](function(){return _0x508bfb;});}return _0x508bfb;})[_0xcadc('0x14')](respondWithStatusCode(_0x3a79a8,null))[_0xcadc('0x5b')](handleError(_0x3a79a8,null));};exports[_0xcadc('0xb7')]=function(_0x32464c,_0x1cbf7c){_0x32464c[_0xcadc('0x5c')]['userpic']=_0x32464c[_0xcadc('0xb8')][_0xcadc('0xb9')];return db['User'][_0xcadc('0x32')]({'where':{'id':_0x32464c['params']['id']}})[_0xcadc('0x14')](handleEntityNotFound(_0x1cbf7c,null))[_0xcadc('0x14')](saveUpdates(_0x32464c[_0xcadc('0x5c')],null))['then'](respondWithResult(_0x1cbf7c,null))[_0xcadc('0x5b')](handleError(_0x1cbf7c,null));};exports['getAvatar']=function(_0x1735f8,_0x17f91f){var _0x2e489b=path[_0xcadc('0xba')](config[_0xcadc('0xbb')],_0xcadc('0xbc'));return db['User'][_0xcadc('0x32')]({'where':{'id':_0x1735f8[_0xcadc('0x52')]['id']},'attributes':['id','userpic'],'raw':!![]})[_0xcadc('0x14')](handleEntityNotFound(_0x17f91f,null))['then'](function(_0x232ac4){if(_0x232ac4){if(_[_0xcadc('0x67')](_0x232ac4[_0xcadc('0xbd')])){return _0x17f91f[_0xcadc('0xbe')](_0x2e489b);}else{if(!fs[_0xcadc('0xbf')](path[_0xcadc('0xba')](config[_0xcadc('0xbb')],_0xcadc('0xc0'),_0x232ac4[_0xcadc('0xbd')]))){return _0x17f91f['download'](_0x2e489b);}return _0x17f91f[_0xcadc('0xbe')](path[_0xcadc('0xba')](config[_0xcadc('0xbb')],_0xcadc('0xc0'),_0x232ac4[_0xcadc('0xbd')]));}}})[_0xcadc('0x5b')](handleError(_0x17f91f,null));};exports[_0xcadc('0xc1')]=function(_0x539a1f,_0x229841){return db[_0xcadc('0x39')][_0xcadc('0x32')]({'where':{'id':_0x539a1f[_0xcadc('0x52')]['id']},'attributes':['id']})[_0xcadc('0x14')](handleEntityNotFound(_0x229841,null))['then'](function(_0x11c6b3){var _0x4a49a0=[];values=_0x11c6b3['dataValues'];_0x4a49a0[_0xcadc('0x46')](get_open_tabs('chat',_0x11c6b3['dataValues']));_0x4a49a0[_0xcadc('0x46')](get_open_tabs(_0xcadc('0x4c'),_0x11c6b3[_0xcadc('0x4b')]));_0x4a49a0[_0xcadc('0x46')](get_open_tabs('openchannel',_0x11c6b3[_0xcadc('0x4b')]));_0x4a49a0[_0xcadc('0x46')](get_open_tabs(_0xcadc('0x4f'),_0x11c6b3[_0xcadc('0x4b')]));_0x4a49a0[_0xcadc('0x46')](get_open_tabs('fax',_0x11c6b3[_0xcadc('0x4b')]));_0x4a49a0[_0xcadc('0x46')](get_open_tabs(_0xcadc('0x4e'),_0x11c6b3[_0xcadc('0x4b')]));return BPromise['all'](_0x4a49a0);})[_0xcadc('0x14')](function(_0x2d825){var _0x32d6f0=[];if(_0x2d825){for(var _0x47c1e6=0x0;_0x47c1e6=_0x3c7eda){_0x5179c1=_0x3c7eda;_0x41a5db=0xc8;}else{_0x41a5db=0xce;}_0x7feb4['status'](_0x41a5db);return _0x7feb4[_0x84cf('0x28')]('Content-Range',_0x401aa4+'-'+_0x5179c1+'/'+_0x3c7eda)[_0x84cf('0x23')](_0x2b2c90);}return null;};}function saveUpdates(_0x4092fd){return function(_0x43b41b){if(_0x43b41b){return _0x43b41b[_0x84cf('0x29')](_0x4092fd)[_0x84cf('0x14')](function(_0x20de4b){return _0x20de4b;});}return null;};}function removeEntity(_0x2e4653){return function(_0x309398){if(_0x309398){return _0x309398[_0x84cf('0x2a')]()[_0x84cf('0x14')](function(){var _0x31dbf5=_0x309398[_0x84cf('0x2b')]({'plain':!![]});if(_0x31dbf5[_0x84cf('0x2c')]===_0x84cf('0x2d'))return;var _0x4b8680=[{'name':'Users','value':_0x84cf('0x2e'),'ignore':!![]},{'name':_0x84cf('0x2f'),'value':_0x84cf('0x30'),'ignore':![]},{'name':_0x84cf('0x31'),'value':_0x84cf('0x32'),'ignore':![]}];var _0x1453cf=_(_0x4b8680)[_0x84cf('0x33')](_0x84cf('0x34'))['map'](_0x84cf('0x35'))[_0x84cf('0x35')]();if(_['includes'](_0x1453cf,_0x31dbf5[_0x84cf('0x2c')])){return;}var _0x5ba89e=_[_0x84cf('0x36')](_0x4b8680,[_0x84cf('0x35'),_0x31dbf5[_0x84cf('0x2c')]])[_0x84cf('0x37')];return db[_0x84cf('0x38')]['destroy']({'where':{'type':_0x5ba89e,'resourceId':_0x31dbf5['id']}})[_0x84cf('0x14')](function(){return _0x309398;});})['then'](function(){_0x2e4653['status'](0xcc)[_0x84cf('0x21')]();});}};}function handleEntityNotFound(_0x147e5c){return function(_0x4c4676){if(!_0x4c4676){_0x147e5c[_0x84cf('0x20')](0x194);}return _0x4c4676;};}function handleError(_0x263372,_0x3395f6){_0x3395f6=_0x3395f6||0x1f4;return function(_0x255b31){logger[_0x84cf('0x1b')](_0x255b31[_0x84cf('0x39')]);if(_0x255b31['name']){delete _0x255b31[_0x84cf('0x37')];}_0x263372[_0x84cf('0x22')](_0x3395f6)[_0x84cf('0x3a')](_0x255b31);};}exports[_0x84cf('0x3b')]=function(_0x3c7063,_0x2a8992){var _0x5129b0={},_0x33d1cc={'count':0x0,'rows':[]};var _0x4a9be3=_(db[_0x84cf('0x3c')][_0x84cf('0x3d')])[_0x84cf('0x3e')](function(_0x373d62){return{'name':_0x373d62[_0x84cf('0x3f')],'type':_0x373d62[_0x84cf('0x40')][_0x84cf('0x41')]};})[_0x84cf('0x33')](function(_0x1f5838){return!_['includes']([_0x84cf('0x42'),'salt'],_0x1f5838[_0x84cf('0x37')]);})[_0x84cf('0x35')]();_0x5129b0=qs['getOptions'](_0x4a9be3,_0x3c7063);var _0x43bbed={'where':_0x5129b0['where']};return db[_0x84cf('0x3c')]['count'](_0x43bbed)[_0x84cf('0x14')](function(_0x4d4757){_0x33d1cc[_0x84cf('0x27')]=_0x4d4757;if(_0x3c7063[_0x84cf('0x43')]['includeAll']){_0x5129b0[_0x84cf('0x44')]=[{'all':!![]}];}if(!_[_0x84cf('0x45')](_0x5129b0[_0x84cf('0x46')],'id')){_0x5129b0['attributes'][_0x84cf('0x47')]('id');}return db['User'][_0x84cf('0x48')](_0x5129b0);})['then'](function(_0x56b0e5){_0x33d1cc['rows']=_0x56b0e5;if(_0x3c7063[_0x84cf('0x43')][_0x84cf('0x49')]==='true'){var _0x2b737e=[];for(var _0x56b623=0x0;_0x56b623<_0x33d1cc[_0x84cf('0x4a')][_0x84cf('0x4b')];_0x56b623++){_0x2b737e['push'](get_open_tabs(_0x84cf('0x4c'),_0x33d1cc['rows'][_0x56b623][_0x84cf('0x4d')]));_0x2b737e['push'](get_open_tabs('sms',_0x33d1cc['rows'][_0x56b623]['dataValues']));_0x2b737e['push'](get_open_tabs('fax',_0x33d1cc['rows'][_0x56b623][_0x84cf('0x4d')]));_0x2b737e[_0x84cf('0x47')](get_open_tabs(_0x84cf('0x4e'),_0x33d1cc[_0x84cf('0x4a')][_0x56b623]['dataValues']));_0x2b737e[_0x84cf('0x47')](get_open_tabs('openchannel',_0x33d1cc[_0x84cf('0x4a')][_0x56b623][_0x84cf('0x4d')]));_0x2b737e[_0x84cf('0x47')](get_open_tabs(_0x84cf('0x4f'),_0x33d1cc[_0x84cf('0x4a')][_0x56b623][_0x84cf('0x4d')]));}return BPromise['all'](_0x2b737e)[_0x84cf('0x14')](function(_0x2732bf){return _0x33d1cc;});}else{return _0x33d1cc;}})['then'](respondWithFilteredResult(_0x2a8992,_0x5129b0))[_0x84cf('0x1f')](handleError(_0x2a8992,null));};exports[_0x84cf('0x50')]=function(_0x2f1726,_0x5212ec){var _0x5e8cde={'raw':![],'where':{'id':_0x2f1726[_0x84cf('0x51')]['id']}},_0x5499f9={};_0x5499f9[_0x84cf('0x52')]=_[_0x84cf('0x53')](_[_0x84cf('0x54')](db[_0x84cf('0x3c')][_0x84cf('0x3d')]),['password',_0x84cf('0x55')]);_0x5499f9['query']=_[_0x84cf('0x54')](_0x2f1726['query']);_0x5499f9['filters']=_[_0x84cf('0x56')](_0x5499f9[_0x84cf('0x52')],_0x5499f9[_0x84cf('0x43')]);_0x5e8cde['attributes']=_['intersection'](_0x5499f9[_0x84cf('0x52')],qs[_0x84cf('0x57')](_0x2f1726[_0x84cf('0x43')][_0x84cf('0x57')]));_0x5e8cde[_0x84cf('0x46')]=_0x5e8cde['attributes'][_0x84cf('0x4b')]?_0x5e8cde[_0x84cf('0x46')]:_0x5499f9['model'];if(_0x2f1726[_0x84cf('0x43')]['includeAll']){_0x5e8cde['include']=[{'all':!![]}];}_0x5e8cde=_[_0x84cf('0x58')]({},_0x5e8cde,_0x2f1726[_0x84cf('0x59')]);if(!_['includes'](_0x5e8cde['attributes'],'id')){_0x5e8cde[_0x84cf('0x46')][_0x84cf('0x47')]('id');}return db[_0x84cf('0x3c')][_0x84cf('0x36')](_0x5e8cde)[_0x84cf('0x14')](handleEntityNotFound(_0x5212ec,null))[_0x84cf('0x14')](function(_0x3a0eb4){var _0x20ae02=[];values=_0x3a0eb4;if(_0x2f1726['query'][_0x84cf('0x49')]===_0x84cf('0x5a')){_0x20ae02['push'](get_open_tabs('chat',_0x3a0eb4[_0x84cf('0x4d')]));_0x20ae02[_0x84cf('0x47')](get_open_tabs(_0x84cf('0x5b'),_0x3a0eb4[_0x84cf('0x4d')]));_0x20ae02[_0x84cf('0x47')](get_open_tabs(_0x84cf('0x5c'),_0x3a0eb4[_0x84cf('0x4d')]));_0x20ae02['push'](get_open_tabs(_0x84cf('0x4f'),_0x3a0eb4['dataValues']));_0x20ae02[_0x84cf('0x47')](get_open_tabs('fax',_0x3a0eb4[_0x84cf('0x4d')]));_0x20ae02[_0x84cf('0x47')](get_open_tabs('mail',_0x3a0eb4[_0x84cf('0x4d')]));return BPromise[_0x84cf('0x5d')](_0x20ae02);}else{return values;}})['then'](function(_0x3bfc10){return values;})['then'](respondWithResult(_0x5212ec,null))['catch'](handleError(_0x5212ec,null));};exports['update']=function(_0x50cde2,_0x2007a6){if(_0x50cde2[_0x84cf('0x5e')]['id']){delete _0x50cde2[_0x84cf('0x5e')]['id'];}delete _0x50cde2[_0x84cf('0x5e')]['role'];return db[_0x84cf('0x3c')][_0x84cf('0x36')]({'where':{'id':_0x50cde2['params']['id']}})[_0x84cf('0x14')](handleEntityNotFound(_0x2007a6,null))[_0x84cf('0x14')](saveUpdates(_0x50cde2[_0x84cf('0x5e')],null))[_0x84cf('0x14')](respondWithResult(_0x2007a6,null))[_0x84cf('0x1f')](handleError(_0x2007a6,null));};exports[_0x84cf('0x5f')]=function(_0x1f1f76,_0x39a336){return db['User'][_0x84cf('0x5f')]()['then'](respondWithResult(_0x39a336,null))[_0x84cf('0x1f')](handleError(_0x39a336,null));};exports[_0x84cf('0x60')]=function(_0x3acc8d,_0x276ab1){return db[_0x84cf('0x3c')]['find']({'where':{'id':_0x3acc8d[_0x84cf('0x51')]['id']}})[_0x84cf('0x14')](handleEntityNotFound(_0x276ab1,null))[_0x84cf('0x14')](function(_0x4ebb4b){if(_0x4ebb4b){return _0x4ebb4b[_0x84cf('0x60')](_0x3acc8d[_0x84cf('0x5e')]['ids'],_[_0x84cf('0x61')](_0x3acc8d['body'],[_0x84cf('0x62'),'id'])||{});}})[_0x84cf('0x14')](respondWithResult(_0x276ab1,null))['catch'](handleError(_0x276ab1,null));};function validateUser(_0x2eeb2e){return new BPromise(function(_0xd95f2e,_0x4a7905){if(_0x2eeb2e[_0x84cf('0x63')])return _0xd95f2e(_0x2eeb2e);return db[_0x84cf('0x64')][_0x84cf('0x65')](0x1)[_0x84cf('0x14')](function(_0x577ade){if(_0x577ade[_0x84cf('0x66')])authService[_0x84cf('0x67')](_0x2eeb2e['password']);db['User']['max'](_0x84cf('0x63'))[_0x84cf('0x14')](function(_0xfcd0d){if(_['isNil'](_0xfcd0d)){_0x2eeb2e['internal']=_0x577ade[_0x84cf('0x68')]||0x1;return;}if(_[_0x84cf('0x69')](_0x577ade[_0x84cf('0x68')])||_0x577ade[_0x84cf('0x68')]===_0xfcd0d){_0x2eeb2e[_0x84cf('0x63')]=_0xfcd0d+0x1;return;}if(_0x577ade[_0x84cf('0x68')]>_0xfcd0d){_0x2eeb2e[_0x84cf('0x63')]=_0x577ade[_0x84cf('0x68')];return;}return db['sequelize'][_0x84cf('0x43')]('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[_0x84cf('0x6a')][_0x84cf('0x6b')]['SELECT']})['then'](function(_0x282c17){if(_0x282c17&&_0x282c17[_0x84cf('0x4b')]){for(var _0x373a25=0x0,_0x1c6e56=_0x282c17[_0x84cf('0x4b')];_0x373a25<_0x1c6e56&&_['isNil'](_0x2eeb2e[_0x84cf('0x63')]);_0x373a25++){if(_0x577ade[_0x84cf('0x68')]<=_0x282c17[_0x373a25][_0x84cf('0x6c')]){_0x2eeb2e[_0x84cf('0x63')]=_0x282c17[_0x373a25]['from'];}else if(_0x577ade[_0x84cf('0x68')]>_0x282c17[_0x373a25]['from']&&_0x577ade['min_internal']<=_0x282c17[_0x373a25]['to']){_0x2eeb2e[_0x84cf('0x63')]=_0x577ade[_0x84cf('0x68')];}}}if(_[_0x84cf('0x69')](_0x2eeb2e[_0x84cf('0x63')])){_0x2eeb2e['internal']=_0xfcd0d+0x1;}return _0xd95f2e(_0x2eeb2e);});});})['catch'](function(_0x508267){_0x4a7905(_0x508267);});});}function updateUser(_0x1df8e2){return new BPromise(function(_0x53e61f,_0x322821){try{if(_0x1df8e2[_0x84cf('0x6d')]){_0x1df8e2[_0x84cf('0x6e')]=_0x1df8e2[_0x84cf('0x63')];_0x1df8e2['VoiceMail']={'mailbox':_0x1df8e2[_0x84cf('0x63')],'password':_0x1df8e2[_0x84cf('0x42')],'fullname':_0x1df8e2['fullname'],'email':_0x1df8e2[_0x84cf('0x6f')]};}if(_0x1df8e2['role']==='agent'){if(!_0x1df8e2[_0x84cf('0x70')])_0x1df8e2[_0x84cf('0x70')]=['101','102',_0x84cf('0x71'),'113','110','104',_0x84cf('0x72'),_0x84cf('0x73'),_0x84cf('0x74'),'108','109',_0x84cf('0x75'),_0x84cf('0x76'),_0x84cf('0x77'),_0x84cf('0x78')];}_0x53e61f(_0x1df8e2);}catch(_0x595c9a){_0x322821(_0x595c9a);}});}exports['create']=function(_0x5c3125,_0x2d52f8){if(_0x5c3125[_0x84cf('0x2e')][_0x84cf('0x2c')]==='agent')throw new Error(_0x84cf('0x79'));if(_0x5c3125[_0x84cf('0x5e')][_0x84cf('0x2c')]===_0x84cf('0x2e')&&_0x5c3125[_0x84cf('0x2e')]['role']!==_0x84cf('0x2d')){throw new Error(_0x84cf('0x7a'));}if(_0x5c3125[_0x84cf('0x5e')]['role']===_0x84cf('0x2d')&&_0x5c3125[_0x84cf('0x2e')]['role']!==_0x84cf('0x2d')){throw new Error(_0x84cf('0x7b'));}return licenseUtil[_0x84cf('0x7c')]([_0x5c3125[_0x84cf('0x5e')]])['then'](function(){return validateUser(_0x5c3125['body']);})[_0x84cf('0x14')](function(_0x2a8e0b){return updateUser(_0x2a8e0b)['then'](function(_0x4f83b8){if(_0x4f83b8[_0x84cf('0x2c')]===_0x84cf('0x2d')){_0x4f83b8[_0x84cf('0x7d')]=_0x5c3125[_0x84cf('0x2e')][_0x84cf('0x7d')];delete _0x4f83b8[_0x84cf('0x7e')];}return _0x4f83b8;});})[_0x84cf('0x14')](function(_0x509d10){return db['User'][_0x84cf('0x7f')](_0x509d10,{'include':[{'model':db[_0x84cf('0x80')],'as':_0x84cf('0x80')}]});})[_0x84cf('0x14')](function(_0x4fd3f1){if(_0x5c3125[_0x84cf('0x5e')]['role']===_0x84cf('0x2e'))return _0x4fd3f1;if(_0x5c3125['user'][_0x84cf('0x2c')]!==_0x84cf('0x2e'))return _0x4fd3f1;return db[_0x84cf('0x81')][_0x84cf('0x36')]({'where':{'name':_0x4fd3f1[_0x84cf('0x2c')]==='agent'?_0x84cf('0x2f'):_0x84cf('0x31'),'userProfileId':_0x5c3125[_0x84cf('0x2e')][_0x84cf('0x7e')]},'raw':!![]})[_0x84cf('0x14')](function(_0x42e63b){if(!_0x42e63b||_0x42e63b[_0x84cf('0x82')]!=0x0)return _0x4fd3f1;return db[_0x84cf('0x38')][_0x84cf('0x7f')]({'name':_0x4fd3f1[_0x84cf('0x37')],'resourceId':_0x4fd3f1['id'],'type':_0x42e63b[_0x84cf('0x37')],'sectionId':_0x42e63b['id']},{})[_0x84cf('0x14')](function(){return _0x4fd3f1;});})[_0x84cf('0x1f')](function(_0xb44157){logger[_0x84cf('0x1b')](_0x84cf('0x83'),_0xb44157);throw _0xb44157;});})[_0x84cf('0x14')](respondWithResult(_0x2d52f8,0xc9))[_0x84cf('0x1f')](handleError(_0x2d52f8,null));};exports['bulkCreate']=function(_0x5484d8,_0xc079e2){var _0x4b9522=_0x5484d8[_0x84cf('0x5e')];var _0x140d99=[];if(_0x5484d8['user'][_0x84cf('0x2c')]===_0x84cf('0x30'))throw new Error(_0x84cf('0x79'));if(_['some'](_0x4b9522,[_0x84cf('0x2c'),'user'])&&_0x5484d8[_0x84cf('0x2e')]['role']!==_0x84cf('0x2d')){throw new Error(_0x84cf('0x7a'));}if(_['some'](_0x4b9522,[_0x84cf('0x2c'),_0x84cf('0x2d')])&&_0x5484d8[_0x84cf('0x2e')]['role']!==_0x84cf('0x2d')){throw new Error('Unauthorized.\x20You\x20must\x20be\x20an\x20administrator\x20in\x20order\x20to\x20create\x20an\x20administrator');}return licenseUtil[_0x84cf('0x7c')](_0x4b9522)[_0x84cf('0x14')](function(){return validateUser(_0x4b9522[0x0]);})[_0x84cf('0x14')](function(){for(var _0xff46d2=0x1;_0xff46d2<_0x4b9522[_0x84cf('0x4b')];_0xff46d2++){var _0x44615b=_0x4b9522[_0xff46d2-0x1]['internal'];if(!_0x4b9522[_0xff46d2][_0x84cf('0x63')])_0x4b9522[_0xff46d2][_0x84cf('0x63')]=_0x44615b+0x1;_0x140d99[_0x84cf('0x47')](validateUser(_0x4b9522[_0xff46d2]));}return BPromise[_0x84cf('0x5d')](_0x140d99);})[_0x84cf('0x14')](function(){_0x140d99=[];for(var _0x3efd3a=0x0;_0x3efd3a<_0x4b9522[_0x84cf('0x4b')];_0x3efd3a++){_0x140d99[_0x84cf('0x47')](updateUser(_0x4b9522[_0x3efd3a]));}return BPromise[_0x84cf('0x5d')](_0x140d99);})['then'](function(){return BPromise[_0x84cf('0x84')](_0x4b9522,function(_0x4dc17f){return db['User'][_0x84cf('0x7f')](_0x4dc17f,{'include':[{'model':db[_0x84cf('0x80')],'as':'VoiceMail'}]})[_0x84cf('0x14')](function(_0x1def45){_0x4dc17f['id']=_0x1def45['id'];return _0x4dc17f;});});})[_0x84cf('0x14')](function(_0x4dad47){if(_0x5484d8[_0x84cf('0x5e')]['role']===_0x84cf('0x2e'))return _0x4dad47;if(_0x5484d8[_0x84cf('0x2e')][_0x84cf('0x2c')]!==_0x84cf('0x2e'))return _0x4dad47;var _0x184206=_[_0x84cf('0x85')](_0x4dad47,function(_0x5c32ce){return _0x5c32ce[_0x84cf('0x2c')]===_0x84cf('0x30')||_0x5c32ce[_0x84cf('0x2c')]===_0x84cf('0x32');});if(!_0x184206)return _0x4dad47;return db[_0x84cf('0x81')][_0x84cf('0x48')]({'where':{'name':{'$or':[_0x84cf('0x2f'),_0x84cf('0x31')]},'userProfileId':_0x5484d8[_0x84cf('0x2e')][_0x84cf('0x7e')]},'raw':!![]})['then'](function(_0x4caa9e){if(_[_0x84cf('0x86')](_0x4caa9e)||!_['some'](_0x4caa9e,[_0x84cf('0x82'),0x0]))return _0x4dad47;_0x140d99=[];var _0x3e9e12=_(_0x4caa9e)[_0x84cf('0x3e')](function(_0x596323){if(_0x596323[_0x84cf('0x82')]===0x1)return;return _0x596323[_0x84cf('0x37')]===_0x84cf('0x2f')?_0x84cf('0x30'):'telephone';})['compact']()[_0x84cf('0x35')]();for(var _0x37278e=0x0;_0x37278e<_0x4dad47[_0x84cf('0x4b')];_0x37278e++){if(!_[_0x84cf('0x45')](_0x3e9e12,_0x4dad47[_0x37278e][_0x84cf('0x2c')]))return;var _0x19fee0=_0x4dad47[_0x37278e][_0x84cf('0x2c')]===_0x84cf('0x30')?_0x84cf('0x2f'):_0x84cf('0x31');_0x140d99['push'](db[_0x84cf('0x38')][_0x84cf('0x7f')]({'name':_0x4dad47[_0x37278e][_0x84cf('0x37')],'resourceId':_0x4dad47[_0x37278e]['id'],'type':_0x19fee0,'sectionId':_['find'](_0x4caa9e,[_0x84cf('0x37'),_0x19fee0])['id']},{}));}return BPromise[_0x84cf('0x5d')](_0x140d99);});})[_0x84cf('0x14')](respondWithResult(_0xc079e2,0xc9))[_0x84cf('0x1f')](handleError(_0xc079e2,null));};exports[_0x84cf('0x87')]=function(_0x58862c,_0x38e27d){if(_0x58862c[_0x84cf('0x5e')]['id']){delete _0x58862c[_0x84cf('0x5e')]['id'];}return db[_0x84cf('0x3c')][_0x84cf('0x36')]({'where':{'id':_0x58862c[_0x84cf('0x51')]['id']}})['then'](function(_0x99b38a){if(!_0x99b38a)return null;if(_0x99b38a['id']===_0x58862c[_0x84cf('0x2e')]['id']){if(!_0x58862c['body']['oldPassword']||!_0x58862c[_0x84cf('0x5e')]['newPassword']){throw new db[(_0x84cf('0x88'))]['ValidationError'](_0x84cf('0x89'));}if(!_0x99b38a[_0x84cf('0x8a')](_0x58862c[_0x84cf('0x5e')]['oldPassword'])){throw new db[(_0x84cf('0x88'))][(_0x84cf('0x8b'))](_0x84cf('0x8c'));}if(_0x58862c['body'][_0x84cf('0x8d')]===_0x58862c[_0x84cf('0x5e')][_0x84cf('0x8e')]){throw new db[(_0x84cf('0x88'))][(_0x84cf('0x8b'))]('New\x20password\x20must\x20be\x20different\x20from\x20old\x20password');}}else if(_0x58862c[_0x84cf('0x2e')][_0x84cf('0x2c')]==='admin'){if(!_0x58862c[_0x84cf('0x5e')][_0x84cf('0x8e')]){throw new db[(_0x84cf('0x88'))][(_0x84cf('0x8b'))](_0x84cf('0x8f'));}}else if(_0x58862c[_0x84cf('0x2e')]['role']===_0x84cf('0x2e')){if(!_0x58862c[_0x84cf('0x5e')][_0x84cf('0x8e')]){throw new db[(_0x84cf('0x88'))][(_0x84cf('0x8b'))](_0x84cf('0x8f'));}if(_0x99b38a[_0x84cf('0x2c')]!==_0x84cf('0x30')){throw new db[(_0x84cf('0x88'))][(_0x84cf('0x8b'))]('Unauthorized');}}else{throw new db[(_0x84cf('0x88'))][(_0x84cf('0x8b'))](_0x84cf('0x79'));}return _0x99b38a;})[_0x84cf('0x14')](handleEntityNotFound(_0x38e27d,null))[_0x84cf('0x14')](function(_0xa53f8f){return db['Setting']['findOne']({'attributes':['id',_0x84cf('0x66'),_0x84cf('0x90'),_0x84cf('0x91')]})[_0x84cf('0x14')](function(_0x31593a){if(_0x31593a['securePassword'])authService[_0x84cf('0x67')](_0x58862c['body']['newPassword']);if(!_0x31593a['enforcePasswordHistory']||!_0xa53f8f['previousPasswords'])return _0xa53f8f;authService[_0x84cf('0x92')](_0x58862c[_0x84cf('0x5e')]['newPassword'],_0xa53f8f['previousPasswords'],_0x31593a[_0x84cf('0x91')]);return _0xa53f8f;})[_0x84cf('0x14')](saveUpdates({'password':_0x58862c[_0x84cf('0x5e')][_0x84cf('0x8e')],'passwordResetAt':_0x58862c[_0x84cf('0x2e')]['id']==_0x58862c[_0x84cf('0x51')]['id']?moment():null,'previousPasswords':authService[_0x84cf('0x93')](_0x58862c[_0x84cf('0x5e')][_0x84cf('0x8e')],_0xa53f8f[_0x84cf('0x94')])},null));})['then'](respondWithResult(_0x38e27d,null))[_0x84cf('0x1f')](handleError(_0x38e27d,null));};exports[_0x84cf('0x95')]=function(_0x4cb254,_0x2aa96a){var _0x5d5eb1=_0x4cb254[_0x84cf('0x5e')][_0x84cf('0x96')];return db[_0x84cf('0x3c')]['find']({'where':{'id':_0x4cb254[_0x84cf('0x51')]['id']},'attributes':['id','name',_0x84cf('0x2c'),_0x84cf('0x97'),'loginInPause',_0x84cf('0x98'),'interface']})[_0x84cf('0x14')](handleEntityNotFound(_0x2aa96a,null))[_0x84cf('0x14')](function(_0x4b06c6){if(_0x4b06c6){if(!utils[_0x84cf('0x99')](_0x5d5eb1)){throw new db[(_0x84cf('0x88'))][(_0x84cf('0x8b'))](_0x84cf('0x9a'));}return _0x4b06c6[_0x84cf('0x9b')+_[_0x84cf('0x9c')](_0x5d5eb1[_0x84cf('0x9d')]())+_0x84cf('0x9e')](_0x4cb254[_0x84cf('0x5e')][_0x84cf('0x62')],{'penalty':_0x4cb254[_0x84cf('0x5e')][_0x84cf('0x9f')]||0x0})['spread'](function(_0x439e7d){for(var _0x3880bd=0x0;_0x3880bd<_0x4cb254[_0x84cf('0x5e')][_0x84cf('0x62')][_0x84cf('0x4b')];_0x3880bd+=0x1){var _0x562de5={'UserId':Number(_0x4cb254['params']['id'])};_0x562de5[_['capitalize'](_0x5d5eb1[_0x84cf('0x9d')]())+'QueueId']=Number(_0x4cb254[_0x84cf('0x5e')][_0x84cf('0x62')][_0x3880bd]);socket[_0x84cf('0xa0')]('user'+_[_0x84cf('0x9c')](_0x5d5eb1[_0x84cf('0x9d')]())+_0x84cf('0xa1'),_0x562de5);}return _0x439e7d;})['then'](function(){if(_0x5d5eb1==='voice'){return db['VoiceQueue'][_0x84cf('0x48')]({'where':{'id':_0x4cb254[_0x84cf('0x5e')][_0x84cf('0x62')]||[]},'raw':!![],'attributes':['id',_0x84cf('0x37')]});}})[_0x84cf('0x14')](function(_0x4eab9e){var _0x3b6374=_0x4b06c6[_0x84cf('0x2b')]({'plain':!![]});var _0x113bcf=[];if(_0x5d5eb1==='voice'&&_0x3b6374[_0x84cf('0x2c')]==='agent'&&_0x3b6374[_0x84cf('0x97')]){for(var _0x194267=0x0;_0x194267<_0x4eab9e[_0x84cf('0x4b')];_0x194267+=0x1){_0x113bcf[_0x84cf('0x47')]({'membername':_0x3b6374['name'],'UserId':_0x3b6374['id'],'queue_name':_0x4eab9e[_0x194267][_0x84cf('0x37')],'VoiceQueueId':_0x4eab9e[_0x194267]['id'],'interface':_['isNil'](_0x3b6374[_0x84cf('0xa2')])?util[_0x84cf('0xa3')]('SIP/%s',_0x3b6374['name']):_0x3b6374[_0x84cf('0xa2')],'paused':_0x3b6374[_0x84cf('0x98')]||![],'penalty':_0x4cb254[_0x84cf('0x5e')][_0x84cf('0x9f')]||0x0});}return BPromise[_0x84cf('0x84')](_0x113bcf,function(_0xc15d90){return db['UserVoiceQueueRt'][_0x84cf('0xa4')](_0xc15d90);});}return _0x4b06c6;});}})[_0x84cf('0x14')](respondWithStatusCode(_0x2aa96a,null))[_0x84cf('0x1f')](handleError(_0x2aa96a,null));};exports[_0x84cf('0xa5')]=function(_0x457951,_0x197bc8){var _0x11dde4;return db['User']['find']({'where':{'id':_0x457951['params']['id']},'attributes':['id',_0x84cf('0x37'),_0x84cf('0x2c')]})[_0x84cf('0x14')](handleEntityNotFound(_0x197bc8,null))[_0x84cf('0x14')](function(_0x490c09){if(_0x490c09){_0x11dde4=_0x490c09;if(!_0x457951[_0x84cf('0x43')]['channel']||!utils['isValidChannel'](_0x457951[_0x84cf('0x43')][_0x84cf('0x96')])){throw new db[(_0x84cf('0x88'))][(_0x84cf('0x8b'))](_0x84cf('0x9a'));}return _0x490c09['remove'+_[_0x84cf('0x9c')](_0x457951[_0x84cf('0x43')]['channel'][_0x84cf('0x9d')]())+'Queues'](_0x457951['query'][_0x84cf('0x62')]);}})[_0x84cf('0x14')](function(_0x5cbebd){if(_[_0x84cf('0xa6')](_0x457951[_0x84cf('0x43')][_0x84cf('0x62')])){for(var _0x31bf08=0x0;_0x31bf08<_0x457951['query']['ids'][_0x84cf('0x4b')];_0x31bf08+=0x1){var _0x413329={'UserId':Number(_0x457951[_0x84cf('0x51')]['id'])};_0x413329[_[_0x84cf('0x9c')](_0x457951[_0x84cf('0x43')][_0x84cf('0x96')][_0x84cf('0x9d')]())+'QueueId']=Number(_0x457951[_0x84cf('0x43')][_0x84cf('0x62')][_0x31bf08]);socket[_0x84cf('0xa0')](_0x84cf('0x2e')+_[_0x84cf('0x9c')](_0x457951[_0x84cf('0x43')][_0x84cf('0x96')]['toLowerCase']())+_0x84cf('0xa7'),_0x413329);}}else{var _0x413329={'UserId':Number(_0x457951[_0x84cf('0x51')]['id'])};_0x413329[_[_0x84cf('0x9c')](_0x457951[_0x84cf('0x43')]['channel'][_0x84cf('0x9d')]())+_0x84cf('0xa8')]=Number(_0x457951['query'][_0x84cf('0x62')]);socket[_0x84cf('0xa0')](_0x84cf('0x2e')+_['capitalize'](_0x457951['query'][_0x84cf('0x96')]['toLowerCase']())+_0x84cf('0xa7'),_0x413329);}return _0x5cbebd;})[_0x84cf('0x14')](function(){if(_0x457951['query'][_0x84cf('0x96')]===_0x84cf('0xa9')){return db[_0x84cf('0xaa')][_0x84cf('0x2a')]({'where':{'UserId':_0x457951[_0x84cf('0x51')]['id'],'VoiceQueueId':_0x457951['query'][_0x84cf('0x62')]},'individualHooks':!![]})[_0x84cf('0x14')](function(){return _0x11dde4;});}return _0x11dde4;})[_0x84cf('0x14')](respondWithStatusCode(_0x197bc8,null))[_0x84cf('0x1f')](handleError(_0x197bc8,null));};exports[_0x84cf('0xab')]=function(_0x579eac,_0x38679b){_0x579eac['body']['userpic']=_0x579eac['file']['filename'];return db[_0x84cf('0x3c')]['find']({'where':{'id':_0x579eac[_0x84cf('0x51')]['id']}})['then'](handleEntityNotFound(_0x38679b,null))[_0x84cf('0x14')](saveUpdates(_0x579eac[_0x84cf('0x5e')],null))[_0x84cf('0x14')](respondWithResult(_0x38679b,null))[_0x84cf('0x1f')](handleError(_0x38679b,null));};exports[_0x84cf('0xac')]=function(_0x3e19cd,_0x369219){var _0x2f8751=path[_0x84cf('0xad')](config['root'],'server/files/images/logos/default_profile.png');return db[_0x84cf('0x3c')][_0x84cf('0x36')]({'where':{'id':_0x3e19cd['params']['id']},'attributes':['id','userpic'],'raw':!![]})[_0x84cf('0x14')](handleEntityNotFound(_0x369219,null))[_0x84cf('0x14')](function(_0x62ed8e){if(_0x62ed8e){if(_[_0x84cf('0x69')](_0x62ed8e['userpic'])){return _0x369219[_0x84cf('0xae')](_0x2f8751);}else{if(!fs['existsSync'](path[_0x84cf('0xad')](config[_0x84cf('0xaf')],'server/files/images/',_0x62ed8e[_0x84cf('0xb0')]))){return _0x369219['download'](_0x2f8751);}return _0x369219[_0x84cf('0xae')](path[_0x84cf('0xad')](config[_0x84cf('0xaf')],_0x84cf('0xb1'),_0x62ed8e['userpic']));}}})[_0x84cf('0x1f')](handleError(_0x369219,null));};exports[_0x84cf('0xb2')]=function(_0x1b2808,_0x36c894){return db[_0x84cf('0x3c')][_0x84cf('0x36')]({'where':{'id':_0x1b2808['params']['id']},'attributes':['id']})[_0x84cf('0x14')](handleEntityNotFound(_0x36c894,null))[_0x84cf('0x14')](function(_0x38718d){var _0x28ce80=[];values=_0x38718d[_0x84cf('0x4d')];_0x28ce80['push'](get_open_tabs('chat',_0x38718d[_0x84cf('0x4d')]));_0x28ce80[_0x84cf('0x47')](get_open_tabs(_0x84cf('0x5b'),_0x38718d[_0x84cf('0x4d')]));_0x28ce80['push'](get_open_tabs(_0x84cf('0x5c'),_0x38718d[_0x84cf('0x4d')]));_0x28ce80[_0x84cf('0x47')](get_open_tabs(_0x84cf('0x4f'),_0x38718d['dataValues']));_0x28ce80[_0x84cf('0x47')](get_open_tabs(_0x84cf('0xb3'),_0x38718d[_0x84cf('0x4d')]));_0x28ce80[_0x84cf('0x47')](get_open_tabs('mail',_0x38718d[_0x84cf('0x4d')]));return BPromise[_0x84cf('0x5d')](_0x28ce80);})[_0x84cf('0x14')](function(_0x40c196){var _0x5f35a2=[];if(_0x40c196){for(var _0x476bb8=0x0;_0x476bb8