Built motion from commit 85328c08.|2.5.50
[motion2.git] / server / api / user / user.controller.js
1 // *************************************************************************
2 // *                                                                       *
3 // * xCALLY Motion -  The Omnichannel Contact Center                       *
4 // * Copyright (c) Xenialab s.r.l. All Rights Reserved                     *
5 // *                                                                       *
6 // *************************************************************************
7 // *                                                                       *
8 // * Email: info@xcally.com                                                *
9 // * Website: https://www.xcally.com                                       *
10 // *                                                                       *
11 // *************************************************************************
12 // *                                                                       *
13 // * The SOFTWARE PRODUCT is protected by copyright laws and international *
14 // * copyright treaties, as well as other intellectual property laws and   *
15 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                         *
16 // *                                                                       *
17 // *************************************************************************
18 var _0x3f15=['addSmsAccounts','removeSmsAccounts','getChatWebsites','ChatWebsite','addChatWebsites','removeChatWebsites','getWhatsappAccounts','WhatsappAccount','addWhatsappAccounts','removeWhatsappAccounts','getSquareProjects','SquareProject','addSquareProjects','removeSquareProjects','getScheduledCalls','CmHopper','concat','$and','$gt','$gte','$lt','$lte','$ne','$not','$between','$notBetween','$in','$notIn','$like','$iLike','$contained','$any','Contact','dialActive','getApiKey','token','No\x20API\x20access\x20key\x20found!','You\x20don\x27t\x20have\x20sufficient\x20privileges\x20to\x20access\x20this\x20resource.','generateApiKey','iat','nonce','removeApiKey','apiKeyIat','whoami','Unable\x20to\x20retrieve\x20the\x20current\x20user','queues','teams','inbound','lower','col','toString','asc','desc','substring','uniqBy','Unable\x20to\x20retrieve\x20RPC\x20agents\x20(AMI)','idle','unknown','unavailable','ringing','voiceStatus','toUpperCase','slice','SELECT','select','field','ui.createdAt','_interactions','ui.UserId\x20=\x20?','OpenTabs','util','path','lodash','jayson/promise','ioredis','../../components/auth/service','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','./user.socket','register','defaults','localhost','client','http','request','then','info','User,\x20%s,\x20%s','request\x20sent','debug','error','code','message','result','catch','sendStatus','status','end','json','undefined','limit','offset','count','set','Content-Range','update','destroy','get','agent','Telephones','telephone','filter','ignore','map','value','includes','find','role','name','stack','send','index','rawAttributes','fieldName','type','key','password','salt','getOptions','where','query','includeAll','include','userSetting','true','UserSetting','attributes','push','User','findAll','rows','length','dataValues','sms','fax','openchannel','all','show','params','model','differenceBy','keys','filters','intersection','merge','openTabs','whatsapp','mail','body','describe','addContacts','ids','internal','Setting','findById','securePassword','max','min_internal','isNil','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)','from','voicemail','fullname','email','permissions','101','102','103','110','106','107','108','100','114','115','create','Unauthorized','user','admin','Unauthorized.\x20You\x20must\x20be\x20an\x20administrator\x20in\x20order\x20to\x20create\x20an\x20user','Unauthorized.\x20You\x20must\x20be\x20an\x20administrator\x20in\x20order\x20to\x20create\x20another\x20administrator','checkUserLimits','settingsEnabled','VoiceMail','Agents','userProfileId','autoAssociation','UserProfileResource','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','isEmpty','compact','changePassword','oldPassword','newPassword','Sequelize','ValidationError','Invalid\x20body\x20format.\x20Use\x20oldPassword\x20and\x20newPassword','Wrong\x20credentials','New\x20password\x20must\x20be\x20different\x20from\x20old\x20password','Invalid\x20body\x20format.\x20Use\x20newPassword','enforcePasswordHistory','passwordHistoryLimit','validatePasswordPattern','previousPasswords','validatePasswordHistory','updatePasswordsHistory','addQueues','online','voicePause','interface','isValidChannel','Unknown\x20channel','add','capitalize','toLowerCase','Queues','penalty','QueueId','voice','VoiceQueue','format','SIP/%s','UserVoiceQueueRt','upsert','removeQueues','channel','remove','emit','Queue:remove','addAvatar','file','getAvatar','join','root','userpic','download','existsSync','server/files/images/','getOpenTabs','chat','CHAT','createdAt','FaxOpenTabs','FAX','OpenchannelOpenTabs','OPENCHANNEL','SmsOpenTabs','SMS','WhatsappOpenTabs','WHATSAPP','getContacts','findOne','CmContact','fields','order','sort','pick','options','hasOwnProperty','Tag','Tags','color','tag','nolimit','getQueues','Queue','Unknown\x20role','getVoiceQueuesRt','getGroups','ChatGroup','VoiceRecording','UserId','getScreenRecordings','ScreenRecording','getChatInteractions','ChatInteraction','getOpenchannelInteractions','getMailInteractions','MailInteraction','getSmsInteractions','SmsInteraction','FaxInteraction','getFaxInteractions','getWhatsappInteractions','login','phone','LOCAL/%s@from-sip/n','intrf','user:%s','user:forcelogout','headers','x-forwarded-for','remoteAddress','socket','connection','User\x20not\x20found\x20or\x20not\x20allowed\x20to\x20perform\x20login\x20method','loginInPause','UserVoiceQueue.penalty','MemberReport','forEach','YYYY-MM-DD\x20HH:mm:ss','getChannels','LOGIN','device','PAUSE','LOGININPAUSE','isMiddleware','resolve','pause','QueuePause','updateAttributes','DEFAULT\x20PAUSE','unpause','mailPause','faxPause','openchannelPause','whatsapppause','pauseType','lastPauseAt','manual','%s%s','Pause','getTeams','addTeams','omit','Team','getVoiceQueues','Voice','getChatQueues','setDataValue','getSmsQueues','getWhatsappQueues','Whatsapp','getFaxQueues','Fax','getOpenchannelQueues','flatten','transaction','addAgent','getDataValue','Queue:save','VoicePrefixId','Chat','Mail','Sms','Openchannel','TeamVoicePrefix','UserVoicePrefix','getLists','getAgents','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','user_has_sms_interactions:remove','user_has_openchannel_interactions:save','removeOpenchannelInteractions','user_has_openchannel_interactions:remove','addWhatsappInteractions','user_has_whatsapp_interactions:save','removeWhatsappInteractions','VoicePrefix','getVoicePrefixes','FaxAccount','getFaxAccounts','addFaxAccounts','removeFaxAccounts','MailAccount','getMailAccounts','addMailAccounts','removeMailAccounts','getOpenchannelAccounts','OpenchannelAccount','addOpenchannelAccounts','removeOpenchannelAccounts','SmsAccount','getSmsAccounts'];(function(_0x5d2b37,_0x176f3e){var _0x5dfa71=function(_0x348ebe){while(--_0x348ebe){_0x5d2b37['push'](_0x5d2b37['shift']());}};_0x5dfa71(++_0x176f3e);}(_0x3f15,0x1e3));var _0x53f1=function(_0x4be2b5,_0x4fe9c2){_0x4be2b5=_0x4be2b5-0x0;var _0x33e77d=_0x3f15[_0x4be2b5];return _0x33e77d;};'use strict';var moment=require('moment');var BPromise=require('bluebird');var util=require(_0x53f1('0x0'));var path=require(_0x53f1('0x1'));var fs=require('fs');var _=require(_0x53f1('0x2'));var squel=require('squel');var jayson=require(_0x53f1('0x3'));var Redis=require(_0x53f1('0x4'));var authService=require(_0x53f1('0x5'));var qs=require('../../components/parsers/qs');var logger=require(_0x53f1('0x6'))(_0x53f1('0x7'));var utils=require(_0x53f1('0x8'));var config=require(_0x53f1('0x9'));var licenseUtil=require(_0x53f1('0xa'));var db=require(_0x53f1('0xb'))['db'];var socket=require('socket.io-emitter')(new Redis(config[_0x53f1('0xc')]));require(_0x53f1('0xd'))[_0x53f1('0xe')](socket);config[_0x53f1('0xc')]=_[_0x53f1('0xf')](config['redis'],{'host':_0x53f1('0x10'),'port':0x18eb});var client=jayson[_0x53f1('0x11')][_0x53f1('0x12')]({'port':0x232a});var values;function respondWithRpcPromise(_0x4b965,_0x3e5b8e,_0x2e2c22,_0x11205a){return new BPromise(function(_0x5d08f1,_0x65e6a){var _0x4e0e3a=_0x11205a||client;return _0x4e0e3a[_0x53f1('0x13')](_0x4b965,_0x2e2c22)[_0x53f1('0x14')](function(_0x1fd4ff){logger[_0x53f1('0x15')](_0x53f1('0x16'),_0x3e5b8e,_0x53f1('0x17'));logger[_0x53f1('0x18')]('User,\x20%s,\x20%s,\x20%s',_0x3e5b8e,_0x53f1('0x17'),JSON['stringify'](_0x1fd4ff));if(_0x1fd4ff[_0x53f1('0x19')]){if(_0x1fd4ff[_0x53f1('0x19')][_0x53f1('0x1a')]===0x1f4){logger[_0x53f1('0x19')]('User,\x20%s,\x20%s',_0x3e5b8e,_0x1fd4ff[_0x53f1('0x19')]['message']);return _0x65e6a(_0x1fd4ff[_0x53f1('0x19')][_0x53f1('0x1b')]);}logger[_0x53f1('0x19')](_0x53f1('0x16'),_0x3e5b8e,_0x1fd4ff['error'][_0x53f1('0x1b')]);return _0x5d08f1(_0x1fd4ff[_0x53f1('0x19')][_0x53f1('0x1b')]);}else{logger[_0x53f1('0x15')](_0x53f1('0x16'),_0x3e5b8e,'request\x20sent');_0x5d08f1(_0x1fd4ff[_0x53f1('0x1c')][_0x53f1('0x1b')]);}})[_0x53f1('0x1d')](function(_0x21d71b){logger['error']('User,\x20%s,\x20%s',_0x3e5b8e,_0x21d71b);_0x65e6a(_0x21d71b);});});}function respondWithStatusCode(_0x4afabc,_0x17f4d2){_0x17f4d2=_0x17f4d2||0xcc;return function(_0x2b7462){if(_0x2b7462){return _0x4afabc[_0x53f1('0x1e')](_0x17f4d2);}return _0x4afabc[_0x53f1('0x1f')](_0x17f4d2)[_0x53f1('0x20')]();};}function respondWithResult(_0x4cdf78,_0x4dac17){_0x4dac17=_0x4dac17||0xc8;return function(_0x43700a){if(_0x43700a){return _0x4cdf78[_0x53f1('0x1f')](_0x4dac17)[_0x53f1('0x21')](_0x43700a);}};}function respondWithFilteredResult(_0x308597,_0x528aac){return function(_0x50cb1d){if(_0x50cb1d){var _0x2fc2a9=typeof _0x528aac['offset']===_0x53f1('0x22')&&typeof _0x528aac[_0x53f1('0x23')]==='undefined';var _0x366a67=_0x50cb1d['count'];var _0x3fbce1=_0x2fc2a9?0x0:_0x528aac[_0x53f1('0x24')];var _0x4c782b=_0x2fc2a9?_0x50cb1d[_0x53f1('0x25')]:_0x528aac['offset']+_0x528aac['limit'];var _0x4e9112;if(_0x4c782b>=_0x366a67){_0x4c782b=_0x366a67;_0x4e9112=0xc8;}else{_0x4e9112=0xce;}_0x308597['status'](_0x4e9112);return _0x308597[_0x53f1('0x26')](_0x53f1('0x27'),_0x3fbce1+'-'+_0x4c782b+'/'+_0x366a67)[_0x53f1('0x21')](_0x50cb1d);}return null;};}function saveUpdates(_0x3b2c44){return function(_0x82a992){if(_0x82a992){return _0x82a992[_0x53f1('0x28')](_0x3b2c44)['then'](function(_0x1b6629){return _0x1b6629;});}return null;};}function removeEntity(_0xa99feb){return function(_0xb66959){if(_0xb66959){return _0xb66959[_0x53f1('0x29')]()[_0x53f1('0x14')](function(){var _0x12b666=_0xb66959[_0x53f1('0x2a')]({'plain':!![]});if(_0x12b666['role']==='admin')return;var _0x2c8bf8=[{'name':'Users','value':'user','ignore':!![]},{'name':'Agents','value':_0x53f1('0x2b'),'ignore':![]},{'name':_0x53f1('0x2c'),'value':_0x53f1('0x2d'),'ignore':![]}];var _0x5b4bbb=_(_0x2c8bf8)[_0x53f1('0x2e')](_0x53f1('0x2f'))[_0x53f1('0x30')]('value')[_0x53f1('0x31')]();if(_[_0x53f1('0x32')](_0x5b4bbb,_0x12b666['role'])){return;}var _0x48deaa=_[_0x53f1('0x33')](_0x2c8bf8,[_0x53f1('0x31'),_0x12b666[_0x53f1('0x34')]])[_0x53f1('0x35')];return db['UserProfileResource']['destroy']({'where':{'type':_0x48deaa,'resourceId':_0x12b666['id']}})[_0x53f1('0x14')](function(){return _0xb66959;});})[_0x53f1('0x14')](function(){_0xa99feb[_0x53f1('0x1f')](0xcc)[_0x53f1('0x20')]();});}};}function handleEntityNotFound(_0x441335){return function(_0x41119b){if(!_0x41119b){_0x441335[_0x53f1('0x1e')](0x194);}return _0x41119b;};}function handleError(_0x63bad6,_0x1a800f){_0x1a800f=_0x1a800f||0x1f4;return function(_0x226db9){logger[_0x53f1('0x19')](_0x226db9[_0x53f1('0x36')]);if(_0x226db9[_0x53f1('0x35')]){delete _0x226db9[_0x53f1('0x35')];}_0x63bad6[_0x53f1('0x1f')](_0x1a800f)[_0x53f1('0x37')](_0x226db9);};}exports[_0x53f1('0x38')]=function(_0x50bcaa,_0x5b76fd){var _0x5fa0f9={},_0x4fedc6={'count':0x0,'rows':[]};var _0x174567=_(db['User'][_0x53f1('0x39')])[_0x53f1('0x30')](function(_0x4a5a59){return{'name':_0x4a5a59[_0x53f1('0x3a')],'type':_0x4a5a59[_0x53f1('0x3b')][_0x53f1('0x3c')]};})[_0x53f1('0x2e')](function(_0x120cd6){return!_[_0x53f1('0x32')]([_0x53f1('0x3d'),_0x53f1('0x3e')],_0x120cd6['name']);})[_0x53f1('0x31')]();_0x5fa0f9=qs[_0x53f1('0x3f')](_0x174567,_0x50bcaa);var _0x2d5e1c={'where':_0x5fa0f9[_0x53f1('0x40')]};return db['User'][_0x53f1('0x25')](_0x2d5e1c)[_0x53f1('0x14')](function(_0x1030cc){_0x4fedc6[_0x53f1('0x25')]=_0x1030cc;if(_0x50bcaa[_0x53f1('0x41')][_0x53f1('0x42')]){_0x5fa0f9[_0x53f1('0x43')]=[{'all':!![]}];}if(_0x50bcaa[_0x53f1('0x41')][_0x53f1('0x44')]===_0x53f1('0x45')){_0x5fa0f9[_0x53f1('0x43')]=[{'model':db[_0x53f1('0x46')],'as':_0x53f1('0x44')}];}if(!_[_0x53f1('0x32')](_0x5fa0f9[_0x53f1('0x47')],'id')){_0x5fa0f9['attributes'][_0x53f1('0x48')]('id');}return db[_0x53f1('0x49')][_0x53f1('0x4a')](_0x5fa0f9);})[_0x53f1('0x14')](function(_0x1408c6){_0x4fedc6[_0x53f1('0x4b')]=_0x1408c6;if(_0x50bcaa[_0x53f1('0x41')]['openTabs']==='true'){var _0xce72c1=[];for(var _0x57de05=0x0;_0x57de05<_0x4fedc6[_0x53f1('0x4b')][_0x53f1('0x4c')];_0x57de05++){_0xce72c1['push'](get_open_tabs('chat',_0x4fedc6[_0x53f1('0x4b')][_0x57de05][_0x53f1('0x4d')]));_0xce72c1[_0x53f1('0x48')](get_open_tabs(_0x53f1('0x4e'),_0x4fedc6[_0x53f1('0x4b')][_0x57de05][_0x53f1('0x4d')]));_0xce72c1[_0x53f1('0x48')](get_open_tabs(_0x53f1('0x4f'),_0x4fedc6[_0x53f1('0x4b')][_0x57de05]['dataValues']));_0xce72c1[_0x53f1('0x48')](get_open_tabs('mail',_0x4fedc6[_0x53f1('0x4b')][_0x57de05]['dataValues']));_0xce72c1[_0x53f1('0x48')](get_open_tabs(_0x53f1('0x50'),_0x4fedc6[_0x53f1('0x4b')][_0x57de05][_0x53f1('0x4d')]));_0xce72c1[_0x53f1('0x48')](get_open_tabs('whatsapp',_0x4fedc6[_0x53f1('0x4b')][_0x57de05][_0x53f1('0x4d')]));}return BPromise[_0x53f1('0x51')](_0xce72c1)['then'](function(){return _0x4fedc6;});}else{return _0x4fedc6;}})[_0x53f1('0x14')](respondWithFilteredResult(_0x5b76fd,_0x5fa0f9))['catch'](handleError(_0x5b76fd,null));};exports[_0x53f1('0x52')]=function(_0x64609,_0x40238a){var _0x363fc8={'raw':![],'where':{'id':_0x64609[_0x53f1('0x53')]['id']}},_0x152052={};_0x152052[_0x53f1('0x54')]=_[_0x53f1('0x55')](_[_0x53f1('0x56')](db['User'][_0x53f1('0x39')]),['password',_0x53f1('0x3e')]);_0x152052['query']=_[_0x53f1('0x56')](_0x64609[_0x53f1('0x41')]);_0x152052[_0x53f1('0x57')]=_[_0x53f1('0x58')](_0x152052[_0x53f1('0x54')],_0x152052['query']);_0x363fc8['attributes']=_[_0x53f1('0x58')](_0x152052[_0x53f1('0x54')],qs['fields'](_0x64609[_0x53f1('0x41')]['fields']));_0x363fc8['attributes']=_0x363fc8['attributes'][_0x53f1('0x4c')]?_0x363fc8[_0x53f1('0x47')]:_0x152052[_0x53f1('0x54')];if(_0x64609[_0x53f1('0x41')]['includeAll']){_0x363fc8[_0x53f1('0x43')]=[{'all':!![]}];}if(_0x64609[_0x53f1('0x41')][_0x53f1('0x44')]==='true'){_0x363fc8['include']=[{'model':db[_0x53f1('0x46')],'as':_0x53f1('0x44')}];}_0x363fc8=_[_0x53f1('0x59')]({},_0x363fc8,_0x64609['options']);if(!_[_0x53f1('0x32')](_0x363fc8[_0x53f1('0x47')],'id')){_0x363fc8[_0x53f1('0x47')][_0x53f1('0x48')]('id');}return db[_0x53f1('0x49')][_0x53f1('0x33')](_0x363fc8)[_0x53f1('0x14')](handleEntityNotFound(_0x40238a,null))[_0x53f1('0x14')](function(_0x56f3a3){var _0x218654=[];values=_0x56f3a3;if(_0x64609[_0x53f1('0x41')][_0x53f1('0x5a')]===_0x53f1('0x45')){_0x218654['push'](get_open_tabs('chat',_0x56f3a3['dataValues']));_0x218654[_0x53f1('0x48')](get_open_tabs('sms',_0x56f3a3[_0x53f1('0x4d')]));_0x218654[_0x53f1('0x48')](get_open_tabs(_0x53f1('0x50'),_0x56f3a3[_0x53f1('0x4d')]));_0x218654['push'](get_open_tabs(_0x53f1('0x5b'),_0x56f3a3[_0x53f1('0x4d')]));_0x218654['push'](get_open_tabs('fax',_0x56f3a3[_0x53f1('0x4d')]));_0x218654[_0x53f1('0x48')](get_open_tabs(_0x53f1('0x5c'),_0x56f3a3[_0x53f1('0x4d')]));return BPromise[_0x53f1('0x51')](_0x218654);}else{return values;}})[_0x53f1('0x14')](function(){return values;})[_0x53f1('0x14')](respondWithResult(_0x40238a,null))[_0x53f1('0x1d')](handleError(_0x40238a,null));};exports['update']=function(_0x26ac37,_0x906f68){if(_0x26ac37[_0x53f1('0x5d')]['id']){delete _0x26ac37['body']['id'];}delete _0x26ac37[_0x53f1('0x5d')]['role'];return db[_0x53f1('0x49')][_0x53f1('0x33')]({'where':{'id':_0x26ac37[_0x53f1('0x53')]['id']}})['then'](handleEntityNotFound(_0x906f68,null))[_0x53f1('0x14')](saveUpdates(_0x26ac37[_0x53f1('0x5d')],null))[_0x53f1('0x14')](respondWithResult(_0x906f68,null))[_0x53f1('0x1d')](handleError(_0x906f68,null));};exports[_0x53f1('0x5e')]=function(_0x2f9153,_0x3f5cff){return db[_0x53f1('0x49')]['describe']()[_0x53f1('0x14')](respondWithResult(_0x3f5cff,null))[_0x53f1('0x1d')](handleError(_0x3f5cff,null));};exports[_0x53f1('0x5f')]=function(_0x3ba863,_0x304de8){return db[_0x53f1('0x49')][_0x53f1('0x33')]({'where':{'id':_0x3ba863[_0x53f1('0x53')]['id']}})[_0x53f1('0x14')](handleEntityNotFound(_0x304de8,null))['then'](function(_0x1325ca){if(_0x1325ca){return _0x1325ca[_0x53f1('0x5f')](_0x3ba863[_0x53f1('0x5d')][_0x53f1('0x60')],_['omit'](_0x3ba863[_0x53f1('0x5d')],[_0x53f1('0x60'),'id'])||{});}})[_0x53f1('0x14')](respondWithResult(_0x304de8,null))[_0x53f1('0x1d')](handleError(_0x304de8,null));};function validateUser(_0xea4489){return new BPromise(function(_0x2e32d4,_0x33feb2){if(_0xea4489[_0x53f1('0x61')])return _0x2e32d4(_0xea4489);return db[_0x53f1('0x62')][_0x53f1('0x63')](0x1)[_0x53f1('0x14')](function(_0x143446){if(_0x143446[_0x53f1('0x64')])authService['validatePasswordPattern'](_0xea4489[_0x53f1('0x3d')]);db[_0x53f1('0x49')][_0x53f1('0x65')]('internal')['then'](function(_0xc85a7){if(_['isNil'](_0xc85a7)){_0xea4489[_0x53f1('0x61')]=_0x143446[_0x53f1('0x66')]||0x1;return;}if(_[_0x53f1('0x67')](_0x143446[_0x53f1('0x66')])||_0x143446[_0x53f1('0x66')]===_0xc85a7){_0xea4489['internal']=_0xc85a7+0x1;return;}if(_0x143446['min_internal']>_0xc85a7){_0xea4489[_0x53f1('0x61')]=_0x143446[_0x53f1('0x66')];return;}return db[_0x53f1('0x68')][_0x53f1('0x41')](_0x53f1('0x69'),{'type':db[_0x53f1('0x68')]['QueryTypes']['SELECT']})[_0x53f1('0x14')](function(_0x3b9b19){if(_0x3b9b19&&_0x3b9b19[_0x53f1('0x4c')]){for(var _0x1365fc=0x0,_0x18b28d=_0x3b9b19[_0x53f1('0x4c')];_0x1365fc<_0x18b28d&&_['isNil'](_0xea4489[_0x53f1('0x61')]);_0x1365fc++){if(_0x143446['min_internal']<=_0x3b9b19[_0x1365fc]['from']){_0xea4489['internal']=_0x3b9b19[_0x1365fc][_0x53f1('0x6a')];}else if(_0x143446[_0x53f1('0x66')]>_0x3b9b19[_0x1365fc][_0x53f1('0x6a')]&&_0x143446[_0x53f1('0x66')]<=_0x3b9b19[_0x1365fc]['to']){_0xea4489[_0x53f1('0x61')]=_0x143446[_0x53f1('0x66')];}}}if(_[_0x53f1('0x67')](_0xea4489[_0x53f1('0x61')])){_0xea4489[_0x53f1('0x61')]=_0xc85a7+0x1;}return _0x2e32d4(_0xea4489);});});})[_0x53f1('0x1d')](function(_0x181bac){_0x33feb2(_0x181bac);});});}function updateUser(_0x1023ad){return new BPromise(function(_0x283489,_0x22be00){try{if(_0x1023ad[_0x53f1('0x6b')]){_0x1023ad['mailbox']=_0x1023ad[_0x53f1('0x61')];_0x1023ad['VoiceMail']={'mailbox':_0x1023ad['internal'],'password':_0x1023ad[_0x53f1('0x3d')],'fullname':_0x1023ad[_0x53f1('0x6c')],'email':_0x1023ad[_0x53f1('0x6d')]};}if(_0x1023ad[_0x53f1('0x34')]===_0x53f1('0x2b')){if(!_0x1023ad[_0x53f1('0x6e')])_0x1023ad[_0x53f1('0x6e')]=[_0x53f1('0x6f'),_0x53f1('0x70'),_0x53f1('0x71'),'113',_0x53f1('0x72'),'104','105',_0x53f1('0x73'),_0x53f1('0x74'),_0x53f1('0x75'),'109',_0x53f1('0x76'),'111',_0x53f1('0x77'),_0x53f1('0x78')];}_0x283489(_0x1023ad);}catch(_0x4f2ee1){_0x22be00(_0x4f2ee1);}});}exports[_0x53f1('0x79')]=function(_0x5b798f,_0x6c7c56){if(_0x5b798f['user'][_0x53f1('0x34')]===_0x53f1('0x2b'))throw new Error(_0x53f1('0x7a'));if(_0x5b798f[_0x53f1('0x5d')][_0x53f1('0x34')]===_0x53f1('0x7b')&&_0x5b798f['user']['role']!==_0x53f1('0x7c')){throw new Error(_0x53f1('0x7d'));}if(_0x5b798f[_0x53f1('0x5d')]['role']===_0x53f1('0x7c')&&_0x5b798f[_0x53f1('0x7b')][_0x53f1('0x34')]!==_0x53f1('0x7c')){throw new Error(_0x53f1('0x7e'));}return licenseUtil[_0x53f1('0x7f')]([_0x5b798f['body']])[_0x53f1('0x14')](function(){return validateUser(_0x5b798f[_0x53f1('0x5d')]);})[_0x53f1('0x14')](function(_0x2195d8){return updateUser(_0x2195d8)[_0x53f1('0x14')](function(_0x4d381c){if(_0x4d381c[_0x53f1('0x34')]===_0x53f1('0x7c')){_0x4d381c[_0x53f1('0x80')]=_0x5b798f[_0x53f1('0x7b')]['settingsEnabled'];delete _0x4d381c['userProfileId'];}return _0x4d381c;});})[_0x53f1('0x14')](function(_0xfd6938){return db[_0x53f1('0x49')]['create'](_0xfd6938,{'include':[{'model':db[_0x53f1('0x81')],'as':_0x53f1('0x81')}]});})[_0x53f1('0x14')](function(_0x5f196b){if(_0x5b798f['body'][_0x53f1('0x34')]==='user')return _0x5f196b;if(_0x5b798f[_0x53f1('0x7b')][_0x53f1('0x34')]!==_0x53f1('0x7b'))return _0x5f196b;return db['UserProfileSection'][_0x53f1('0x33')]({'where':{'name':_0x5f196b[_0x53f1('0x34')]===_0x53f1('0x2b')?_0x53f1('0x82'):_0x53f1('0x2c'),'userProfileId':_0x5b798f[_0x53f1('0x7b')][_0x53f1('0x83')]},'raw':!![]})[_0x53f1('0x14')](function(_0x5623d0){if(!_0x5623d0||_0x5623d0[_0x53f1('0x84')]!=0x0)return _0x5f196b;return db[_0x53f1('0x85')][_0x53f1('0x79')]({'name':_0x5f196b[_0x53f1('0x35')],'resourceId':_0x5f196b['id'],'type':_0x5623d0[_0x53f1('0x35')],'sectionId':_0x5623d0['id']},{})[_0x53f1('0x14')](function(){return _0x5f196b;});})['catch'](function(_0x25646e){logger['error'](_0x53f1('0x86'),_0x25646e);throw _0x25646e;});})['then'](respondWithResult(_0x6c7c56,0xc9))[_0x53f1('0x1d')](handleError(_0x6c7c56,null));};exports[_0x53f1('0x87')]=function(_0x579bd6,_0x2b70b0){var _0x5c0cad=_0x579bd6[_0x53f1('0x5d')];var _0x2e5cea=[];if(_0x579bd6[_0x53f1('0x7b')]['role']==='agent')throw new Error('Unauthorized');if(_[_0x53f1('0x88')](_0x5c0cad,[_0x53f1('0x34'),_0x53f1('0x7b')])&&_0x579bd6[_0x53f1('0x7b')][_0x53f1('0x34')]!=='admin'){throw new Error(_0x53f1('0x7d'));}if(_['some'](_0x5c0cad,[_0x53f1('0x34'),_0x53f1('0x7c')])&&_0x579bd6[_0x53f1('0x7b')]['role']!=='admin'){throw new Error(_0x53f1('0x89'));}return licenseUtil['checkUserLimits'](_0x5c0cad)[_0x53f1('0x14')](function(){return validateUser(_0x5c0cad[0x0]);})[_0x53f1('0x14')](function(){for(var _0x469272=0x1;_0x469272<_0x5c0cad[_0x53f1('0x4c')];_0x469272++){var _0x585207=_0x5c0cad[_0x469272-0x1][_0x53f1('0x61')];if(!_0x5c0cad[_0x469272][_0x53f1('0x61')])_0x5c0cad[_0x469272][_0x53f1('0x61')]=_0x585207+0x1;_0x2e5cea[_0x53f1('0x48')](validateUser(_0x5c0cad[_0x469272]));}return BPromise[_0x53f1('0x51')](_0x2e5cea);})[_0x53f1('0x14')](function(){_0x2e5cea=[];for(var _0x39103c=0x0;_0x39103c<_0x5c0cad['length'];_0x39103c++){_0x2e5cea[_0x53f1('0x48')](updateUser(_0x5c0cad[_0x39103c]));}return BPromise[_0x53f1('0x51')](_0x2e5cea);})['then'](function(){return BPromise[_0x53f1('0x8a')](_0x5c0cad,function(_0x176066){return db[_0x53f1('0x49')]['create'](_0x176066,{'include':[{'model':db[_0x53f1('0x81')],'as':_0x53f1('0x81')}]})[_0x53f1('0x14')](function(_0x251bcd){_0x176066['id']=_0x251bcd['id'];return _0x176066;});});})[_0x53f1('0x14')](function(_0x5cba92){if(_0x579bd6['body'][_0x53f1('0x34')]===_0x53f1('0x7b'))return _0x5cba92;if(_0x579bd6['user']['role']!==_0x53f1('0x7b'))return _0x5cba92;var _0x15151e=_[_0x53f1('0x88')](_0x5cba92,function(_0x3741d4){return _0x3741d4[_0x53f1('0x34')]===_0x53f1('0x2b')||_0x3741d4[_0x53f1('0x34')]==='telephone';});if(!_0x15151e)return _0x5cba92;return db[_0x53f1('0x8b')]['findAll']({'where':{'name':{'$or':['Agents',_0x53f1('0x2c')]},'userProfileId':_0x579bd6[_0x53f1('0x7b')][_0x53f1('0x83')]},'raw':!![]})['then'](function(_0x2d4f64){if(_[_0x53f1('0x8c')](_0x2d4f64)||!_[_0x53f1('0x88')](_0x2d4f64,[_0x53f1('0x84'),0x0]))return _0x5cba92;_0x2e5cea=[];var _0x409b76=_(_0x2d4f64)[_0x53f1('0x30')](function(_0x198b96){if(_0x198b96[_0x53f1('0x84')]===0x1)return;return _0x198b96['name']===_0x53f1('0x82')?_0x53f1('0x2b'):_0x53f1('0x2d');})[_0x53f1('0x8d')]()[_0x53f1('0x31')]();for(var _0x1f4607=0x0;_0x1f4607<_0x5cba92[_0x53f1('0x4c')];_0x1f4607++){if(!_[_0x53f1('0x32')](_0x409b76,_0x5cba92[_0x1f4607][_0x53f1('0x34')]))return;var _0x592e5e=_0x5cba92[_0x1f4607][_0x53f1('0x34')]===_0x53f1('0x2b')?_0x53f1('0x82'):_0x53f1('0x2c');_0x2e5cea['push'](db[_0x53f1('0x85')][_0x53f1('0x79')]({'name':_0x5cba92[_0x1f4607][_0x53f1('0x35')],'resourceId':_0x5cba92[_0x1f4607]['id'],'type':_0x592e5e,'sectionId':_[_0x53f1('0x33')](_0x2d4f64,[_0x53f1('0x35'),_0x592e5e])['id']},{}));}return BPromise[_0x53f1('0x51')](_0x2e5cea);});})['then'](respondWithResult(_0x2b70b0,0xc9))[_0x53f1('0x1d')](handleError(_0x2b70b0,null));};exports[_0x53f1('0x8e')]=function(_0x37d95e,_0x421f41){if(_0x37d95e[_0x53f1('0x5d')]['id']){delete _0x37d95e['body']['id'];}return db[_0x53f1('0x49')]['find']({'where':{'id':_0x37d95e[_0x53f1('0x53')]['id']}})[_0x53f1('0x14')](function(_0xbb7a56){if(!_0xbb7a56)return null;if(_0xbb7a56['id']===_0x37d95e['user']['id']){if(!_0x37d95e[_0x53f1('0x5d')][_0x53f1('0x8f')]||!_0x37d95e[_0x53f1('0x5d')][_0x53f1('0x90')]){throw new db[(_0x53f1('0x91'))][(_0x53f1('0x92'))](_0x53f1('0x93'));}if(!_0xbb7a56['authenticate'](_0x37d95e['body'][_0x53f1('0x8f')])){throw new db['Sequelize']['ValidationError'](_0x53f1('0x94'));}if(_0x37d95e[_0x53f1('0x5d')][_0x53f1('0x8f')]===_0x37d95e[_0x53f1('0x5d')][_0x53f1('0x90')]){throw new db[(_0x53f1('0x91'))][(_0x53f1('0x92'))](_0x53f1('0x95'));}}else if(_0x37d95e[_0x53f1('0x7b')]['role']===_0x53f1('0x7c')){if(!_0x37d95e[_0x53f1('0x5d')][_0x53f1('0x90')]){throw new db['Sequelize'][(_0x53f1('0x92'))](_0x53f1('0x96'));}}else if(_0x37d95e['user'][_0x53f1('0x34')]===_0x53f1('0x7b')){if(!_0x37d95e[_0x53f1('0x5d')]['newPassword']){throw new db[(_0x53f1('0x91'))][(_0x53f1('0x92'))](_0x53f1('0x96'));}if(_0xbb7a56[_0x53f1('0x34')]!==_0x53f1('0x2b')){throw new db[(_0x53f1('0x91'))][(_0x53f1('0x92'))]('Unauthorized');}}else{throw new db['Sequelize'][(_0x53f1('0x92'))]('Unauthorized');}return _0xbb7a56;})[_0x53f1('0x14')](handleEntityNotFound(_0x421f41,null))[_0x53f1('0x14')](function(_0x221367){return db[_0x53f1('0x62')]['findOne']({'attributes':['id','securePassword',_0x53f1('0x97'),_0x53f1('0x98')]})[_0x53f1('0x14')](function(_0x1b249f){if(_0x1b249f[_0x53f1('0x64')])authService[_0x53f1('0x99')](_0x37d95e[_0x53f1('0x5d')][_0x53f1('0x90')]);if(!_0x1b249f['enforcePasswordHistory']||!_0x221367[_0x53f1('0x9a')])return _0x221367;authService[_0x53f1('0x9b')](_0x37d95e[_0x53f1('0x5d')][_0x53f1('0x90')],_0x221367[_0x53f1('0x9a')],_0x1b249f[_0x53f1('0x98')]);return _0x221367;})[_0x53f1('0x14')](saveUpdates({'password':_0x37d95e[_0x53f1('0x5d')][_0x53f1('0x90')],'passwordResetAt':_0x37d95e[_0x53f1('0x7b')]['id']==_0x37d95e[_0x53f1('0x53')]['id']?moment():null,'previousPasswords':authService[_0x53f1('0x9c')](_0x37d95e[_0x53f1('0x5d')][_0x53f1('0x90')],_0x221367['previousPasswords'])},null));})[_0x53f1('0x14')](respondWithResult(_0x421f41,null))[_0x53f1('0x1d')](handleError(_0x421f41,null));};exports[_0x53f1('0x9d')]=function(_0x58d00a,_0x2fde15){var _0x38d793=_0x58d00a['body']['channel'];return db['User'][_0x53f1('0x33')]({'where':{'id':_0x58d00a[_0x53f1('0x53')]['id']},'attributes':['id',_0x53f1('0x35'),'role',_0x53f1('0x9e'),'loginInPause',_0x53f1('0x9f'),_0x53f1('0xa0')]})[_0x53f1('0x14')](handleEntityNotFound(_0x2fde15,null))[_0x53f1('0x14')](function(_0x10adf5){if(_0x10adf5){if(!utils[_0x53f1('0xa1')](_0x38d793)){throw new db[(_0x53f1('0x91'))][(_0x53f1('0x92'))](_0x53f1('0xa2'));}return _0x10adf5[_0x53f1('0xa3')+_[_0x53f1('0xa4')](_0x38d793[_0x53f1('0xa5')]())+_0x53f1('0xa6')](_0x58d00a[_0x53f1('0x5d')]['ids'],{'penalty':_0x58d00a[_0x53f1('0x5d')][_0x53f1('0xa7')]||0x0})['spread'](function(_0x44e787){for(var _0x5b50fc=0x0;_0x5b50fc<_0x58d00a[_0x53f1('0x5d')]['ids'][_0x53f1('0x4c')];_0x5b50fc+=0x1){var _0x4324b3={'UserId':Number(_0x58d00a[_0x53f1('0x53')]['id'])};_0x4324b3[_[_0x53f1('0xa4')](_0x38d793[_0x53f1('0xa5')]())+_0x53f1('0xa8')]=Number(_0x58d00a[_0x53f1('0x5d')][_0x53f1('0x60')][_0x5b50fc]);socket['emit'](_0x53f1('0x7b')+_[_0x53f1('0xa4')](_0x38d793[_0x53f1('0xa5')]())+'Queue:save',_0x4324b3);}return _0x44e787;})['then'](function(){if(_0x38d793===_0x53f1('0xa9')){return db[_0x53f1('0xaa')][_0x53f1('0x4a')]({'where':{'id':_0x58d00a['body'][_0x53f1('0x60')]||[]},'raw':!![],'attributes':['id',_0x53f1('0x35')]});}})['then'](function(_0x31f243){var _0x5ddff5=_0x10adf5[_0x53f1('0x2a')]({'plain':!![]});var _0x52a3db=[];if(_0x38d793===_0x53f1('0xa9')&&_0x5ddff5[_0x53f1('0x34')]==='agent'&&_0x5ddff5['online']){for(var _0x150870=0x0;_0x150870<_0x31f243[_0x53f1('0x4c')];_0x150870+=0x1){_0x52a3db['push']({'membername':_0x5ddff5[_0x53f1('0x35')],'UserId':_0x5ddff5['id'],'queue_name':_0x31f243[_0x150870][_0x53f1('0x35')],'VoiceQueueId':_0x31f243[_0x150870]['id'],'interface':_['isNil'](_0x5ddff5['interface'])?util[_0x53f1('0xab')](_0x53f1('0xac'),_0x5ddff5['name']):_0x5ddff5[_0x53f1('0xa0')],'paused':_0x5ddff5[_0x53f1('0x9f')]||![],'penalty':_0x58d00a['body']['penalty']||0x0});}return BPromise[_0x53f1('0x8a')](_0x52a3db,function(_0x9e627d){return db[_0x53f1('0xad')][_0x53f1('0xae')](_0x9e627d);});}return _0x10adf5;});}})[_0x53f1('0x14')](respondWithStatusCode(_0x2fde15,null))['catch'](handleError(_0x2fde15,null));};exports[_0x53f1('0xaf')]=function(_0xe41c59,_0x55d9ee){var _0x2351f5,_0x5551ad;return db[_0x53f1('0x49')]['find']({'where':{'id':_0xe41c59['params']['id']},'attributes':['id','name',_0x53f1('0x34')]})['then'](handleEntityNotFound(_0x55d9ee,null))[_0x53f1('0x14')](function(_0x2ee513){if(_0x2ee513){_0x2351f5=_0x2ee513;if(!_0xe41c59[_0x53f1('0x41')]['channel']||!utils['isValidChannel'](_0xe41c59['query'][_0x53f1('0xb0')])){throw new db[(_0x53f1('0x91'))][(_0x53f1('0x92'))](_0x53f1('0xa2'));}return _0x2ee513[_0x53f1('0xb1')+_[_0x53f1('0xa4')](_0xe41c59[_0x53f1('0x41')]['channel']['toLowerCase']())+'Queues'](_0xe41c59[_0x53f1('0x41')]['ids']);}})[_0x53f1('0x14')](function(_0x82ae31){if(_['isArray'](_0xe41c59[_0x53f1('0x41')][_0x53f1('0x60')])){for(var _0x4283ee=0x0;_0x4283ee<_0xe41c59[_0x53f1('0x41')]['ids'][_0x53f1('0x4c')];_0x4283ee+=0x1){_0x5551ad={'UserId':Number(_0xe41c59[_0x53f1('0x53')]['id'])};_0x5551ad[_[_0x53f1('0xa4')](_0xe41c59['query'][_0x53f1('0xb0')][_0x53f1('0xa5')]())+'QueueId']=Number(_0xe41c59[_0x53f1('0x41')][_0x53f1('0x60')][_0x4283ee]);socket[_0x53f1('0xb2')](_0x53f1('0x7b')+_[_0x53f1('0xa4')](_0xe41c59[_0x53f1('0x41')][_0x53f1('0xb0')][_0x53f1('0xa5')]())+_0x53f1('0xb3'),_0x5551ad);}}else{_0x5551ad={'UserId':Number(_0xe41c59[_0x53f1('0x53')]['id'])};_0x5551ad[_[_0x53f1('0xa4')](_0xe41c59[_0x53f1('0x41')][_0x53f1('0xb0')][_0x53f1('0xa5')]())+_0x53f1('0xa8')]=Number(_0xe41c59[_0x53f1('0x41')][_0x53f1('0x60')]);socket[_0x53f1('0xb2')](_0x53f1('0x7b')+_[_0x53f1('0xa4')](_0xe41c59[_0x53f1('0x41')]['channel'][_0x53f1('0xa5')]())+_0x53f1('0xb3'),_0x5551ad);}return _0x82ae31;})[_0x53f1('0x14')](function(){if(_0xe41c59[_0x53f1('0x41')][_0x53f1('0xb0')]===_0x53f1('0xa9')){return db[_0x53f1('0xad')]['destroy']({'where':{'UserId':_0xe41c59[_0x53f1('0x53')]['id'],'VoiceQueueId':_0xe41c59['query']['ids']},'individualHooks':!![]})['then'](function(){return _0x2351f5;});}return _0x2351f5;})[_0x53f1('0x14')](respondWithStatusCode(_0x55d9ee,null))[_0x53f1('0x1d')](handleError(_0x55d9ee,null));};exports[_0x53f1('0xb4')]=function(_0x4475bc,_0x4c6f5f){_0x4475bc[_0x53f1('0x5d')]['userpic']=_0x4475bc[_0x53f1('0xb5')]['filename'];return db['User'][_0x53f1('0x33')]({'where':{'id':_0x4475bc[_0x53f1('0x53')]['id']}})[_0x53f1('0x14')](handleEntityNotFound(_0x4c6f5f,null))[_0x53f1('0x14')](saveUpdates(_0x4475bc[_0x53f1('0x5d')],null))['then'](respondWithResult(_0x4c6f5f,null))[_0x53f1('0x1d')](handleError(_0x4c6f5f,null));};exports[_0x53f1('0xb6')]=function(_0x32cafa,_0x5d1570){var _0x4e27b3=path[_0x53f1('0xb7')](config[_0x53f1('0xb8')],'server/files/images/logos/default_profile.png');return db[_0x53f1('0x49')][_0x53f1('0x33')]({'where':{'id':_0x32cafa[_0x53f1('0x53')]['id']},'attributes':['id',_0x53f1('0xb9')],'raw':!![]})[_0x53f1('0x14')](handleEntityNotFound(_0x5d1570,null))[_0x53f1('0x14')](function(_0x1519cb){if(_0x1519cb){if(_[_0x53f1('0x67')](_0x1519cb[_0x53f1('0xb9')])){return _0x5d1570[_0x53f1('0xba')](_0x4e27b3);}else{if(!fs[_0x53f1('0xbb')](path[_0x53f1('0xb7')](config[_0x53f1('0xb8')],_0x53f1('0xbc'),_0x1519cb['userpic']))){return _0x5d1570[_0x53f1('0xba')](_0x4e27b3);}return _0x5d1570[_0x53f1('0xba')](path[_0x53f1('0xb7')](config[_0x53f1('0xb8')],_0x53f1('0xbc'),_0x1519cb['userpic']));}}})[_0x53f1('0x1d')](handleError(_0x5d1570,null));};exports[_0x53f1('0xbd')]=function(_0x2c5e22,_0x3b042f){return db[_0x53f1('0x49')][_0x53f1('0x33')]({'where':{'id':_0x2c5e22[_0x53f1('0x53')]['id']},'attributes':['id']})['then'](handleEntityNotFound(_0x3b042f,null))[_0x53f1('0x14')](function(_0x716931){var _0x3c309b=[];values=_0x716931[_0x53f1('0x4d')];_0x3c309b[_0x53f1('0x48')](get_open_tabs(_0x53f1('0xbe'),_0x716931[_0x53f1('0x4d')]));_0x3c309b[_0x53f1('0x48')](get_open_tabs(_0x53f1('0x4e'),_0x716931[_0x53f1('0x4d')]));_0x3c309b[_0x53f1('0x48')](get_open_tabs(_0x53f1('0x50'),_0x716931['dataValues']));_0x3c309b[_0x53f1('0x48')](get_open_tabs('whatsapp',_0x716931[_0x53f1('0x4d')]));_0x3c309b[_0x53f1('0x48')](get_open_tabs(_0x53f1('0x4f'),_0x716931[_0x53f1('0x4d')]));_0x3c309b[_0x53f1('0x48')](get_open_tabs(_0x53f1('0x5c'),_0x716931[_0x53f1('0x4d')]));return BPromise[_0x53f1('0x51')](_0x3c309b);})[_0x53f1('0x14')](function(_0x52949c){if(_0x52949c){var _0x1fc4d7=_[_0x53f1('0x30')](values['ChatOpenTabs'],function(_0xe8e115){return{'channel':_0x53f1('0xbf'),'id':_0xe8e115['id'],'createdAt':_0xe8e115[_0x53f1('0xc0')]};});var _0x376e64=_[_0x53f1('0x30')](values[_0x53f1('0xc1')],function(_0x3c27fb){return{'channel':_0x53f1('0xc2'),'id':_0x3c27fb['id'],'createdAt':_0x3c27fb['createdAt']};});var _0x1b2675=_[_0x53f1('0x30')](values[_0x53f1('0xc3')],function(_0x2d9a06){return{'channel':_0x53f1('0xc4'),'id':_0x2d9a06['id'],'createdAt':_0x2d9a06['createdAt']};});var _0x35c7df=_[_0x53f1('0x30')](values['MailOpenTabs'],function(_0x13b8b7){return{'channel':'MAIL','id':_0x13b8b7['id'],'createdAt':_0x13b8b7['createdAt']};});var _0x242400=_['map'](values[_0x53f1('0xc5')],function(_0x3e0867){return{'channel':_0x53f1('0xc6'),'id':_0x3e0867['id'],'createdAt':_0x3e0867['createdAt']};});var _0x2283da=_['map'](values[_0x53f1('0xc7')],function(_0x4f9439){return{'channel':_0x53f1('0xc8'),'id':_0x4f9439['id'],'createdAt':_0x4f9439[_0x53f1('0xc0')]};});var _0x20162a=_['concat'](_0x1fc4d7,_0x376e64,_0x1b2675,_0x35c7df,_0x242400,_0x2283da);var _0x123a59={'count':_0x20162a[_0x53f1('0x4c')],'rows':_0x20162a};return _0x123a59;}else return null;})['then'](respondWithResult(_0x3b042f,null))[_0x53f1('0x1d')](handleError(_0x3b042f,null));};exports[_0x53f1('0xc9')]=function(_0x49fffe,_0x548ab5){var _0x4cbf55={};var _0x3631c2={};var _0xc85227;var _0x4400b2;return db[_0x53f1('0x49')][_0x53f1('0xca')]({'where':{'id':_0x49fffe[_0x53f1('0x53')]['id']}})[_0x53f1('0x14')](handleEntityNotFound(_0x548ab5,null))['then'](function(_0x3f1cec){if(_0x3f1cec){_0xc85227=_0x3f1cec;_0x3631c2[_0x53f1('0x54')]=_['keys'](db[_0x53f1('0xcb')][_0x53f1('0x39')]);_0x3631c2[_0x53f1('0x41')]=_['keys'](_0x49fffe[_0x53f1('0x41')]);_0x3631c2[_0x53f1('0x57')]=_[_0x53f1('0x58')](_0x3631c2[_0x53f1('0x54')],_0x3631c2[_0x53f1('0x41')]);_0x4cbf55['attributes']=_['intersection'](_0x3631c2['model'],qs['fields'](_0x49fffe['query'][_0x53f1('0xcc')]));_0x4cbf55[_0x53f1('0x47')]=_0x4cbf55['attributes'][_0x53f1('0x4c')]?_0x4cbf55['attributes']:_0x3631c2['model'];_0x4cbf55[_0x53f1('0xcd')]=qs[_0x53f1('0xce')](_0x49fffe[_0x53f1('0x41')][_0x53f1('0xce')]);_0x4cbf55['where']=qs['filters'](_[_0x53f1('0xcf')](_0x49fffe['query'],_0x3631c2[_0x53f1('0x57')]));if(_0x49fffe[_0x53f1('0x41')][_0x53f1('0x2e')]){_0x4cbf55[_0x53f1('0x40')]=_[_0x53f1('0x59')](_0x4cbf55[_0x53f1('0x40')],{'$or':_[_0x53f1('0x30')](_0x4cbf55[_0x53f1('0x47')],function(_0x495380){var _0x14cb0f={};_0x14cb0f[_0x495380]={'$like':'%'+_0x49fffe[_0x53f1('0x41')][_0x53f1('0x2e')]+'%'};return _0x14cb0f;})});}_0x4cbf55=_[_0x53f1('0x59')]({},_0x4cbf55,_0x49fffe[_0x53f1('0xd0')]);return _0xc85227[_0x53f1('0xc9')](_0x4cbf55);}})[_0x53f1('0x14')](function(_0x2e4b01){if(_0x2e4b01){_0x4400b2=_0x2e4b01[_0x53f1('0x4c')];if(_0x49fffe[_0x53f1('0x41')][_0x53f1('0xd1')](_0x53f1('0x42'))){_0x4cbf55['include']=[{'model':db['CmList'],'as':'List','required':![]},{'model':db[_0x53f1('0xd2')],'as':_0x53f1('0xd3'),'attributes':['id',_0x53f1('0x35'),_0x53f1('0xd4')],'where':_0x49fffe[_0x53f1('0x41')][_0x53f1('0xd5')]?{'id':_0x49fffe[_0x53f1('0x41')]['tag']}:undefined,'required':_0x49fffe[_0x53f1('0x41')][_0x53f1('0xd5')]?!![]:![]}];}if(!_0x49fffe['query'][_0x53f1('0xd1')](_0x53f1('0xd6'))){_0x4cbf55['limit']=qs[_0x53f1('0x23')](_0x49fffe[_0x53f1('0x41')][_0x53f1('0x23')]);_0x4cbf55['offset']=qs[_0x53f1('0x24')](_0x49fffe['query']['offset']);}return _0xc85227[_0x53f1('0xc9')](_0x4cbf55);}})[_0x53f1('0x14')](function(_0x5a2b97){if(_0x5a2b97){return _0x5a2b97?{'count':_0x4400b2,'rows':_0x5a2b97}:null;}})[_0x53f1('0x14')](respondWithResult(_0x548ab5,null))[_0x53f1('0x1d')](handleError(_0x548ab5,null));};exports[_0x53f1('0xd7')]=function(_0x53192c,_0x6c34f4){var _0x33159a;var _0x4c0fc9={};var _0x58863a;return db[_0x53f1('0x49')][_0x53f1('0xca')]({'where':{'id':_0x53192c[_0x53f1('0x53')]['id']},'attributes':['id',_0x53f1('0x35'),_0x53f1('0x34')]})[_0x53f1('0x14')](handleEntityNotFound(_0x6c34f4,null))[_0x53f1('0x14')](function(_0x451a3f){if(!utils[_0x53f1('0xa1')](_0x53192c[_0x53f1('0x41')][_0x53f1('0xb0')])){throw new db[(_0x53f1('0x91'))]['ValidationError'](_0x53f1('0xa2'));}_0x33159a=_0x451a3f;var _0x42bd99={};_0x42bd99[_0x53f1('0x54')]=_[_0x53f1('0x56')](db[_[_0x53f1('0xa4')](_0x53192c[_0x53f1('0x41')][_0x53f1('0xb0')])+'Queue']['rawAttributes']);_0x42bd99[_0x53f1('0x41')]=_[_0x53f1('0x56')](_0x53192c[_0x53f1('0x41')]);_0x42bd99[_0x53f1('0x57')]=_[_0x53f1('0x58')](_0x42bd99[_0x53f1('0x54')],_0x42bd99[_0x53f1('0x41')]);_0x4c0fc9[_0x53f1('0x47')]=_[_0x53f1('0x58')](_0x42bd99[_0x53f1('0x54')],qs[_0x53f1('0xcc')](_0x53192c[_0x53f1('0x41')][_0x53f1('0xcc')]));_0x4c0fc9[_0x53f1('0x47')]=_0x4c0fc9['attributes'][_0x53f1('0x4c')]?_0x4c0fc9['attributes']:_0x42bd99['model'];_0x4c0fc9[_0x53f1('0xcd')]=qs['sort'](_0x53192c['query'][_0x53f1('0xce')]);_0x4c0fc9[_0x53f1('0x40')]=qs['filters'](_[_0x53f1('0xcf')](_0x53192c[_0x53f1('0x41')],_0x42bd99[_0x53f1('0x57')]));if(_0x53192c['query']['filter']){_0x4c0fc9['where']=_[_0x53f1('0x59')](_0x4c0fc9['where'],{'$or':_['map'](_0x4c0fc9['attributes'],function(_0x11ee0c){var _0x319668={};_0x319668[_0x11ee0c]={'$like':'%'+_0x53192c[_0x53f1('0x41')]['filter']+'%'};return _0x319668;})});}_0x4c0fc9=_[_0x53f1('0x59')]({},_0x4c0fc9,_0x53192c[_0x53f1('0xd0')]);switch(_0x33159a[_0x53f1('0x34')]){case _0x53f1('0x7c'):return db[_[_0x53f1('0xa4')](_0x53192c['query'][_0x53f1('0xb0')])+_0x53f1('0xd8')][_0x53f1('0x4a')](_0x4c0fc9);case _0x53f1('0x7b'):case _0x53f1('0x2b'):return _0x33159a[_0x53f1('0x2a')+_[_0x53f1('0xa4')](_0x53192c[_0x53f1('0x41')]['channel'])+_0x53f1('0xa6')](_0x4c0fc9);default:throw new db['Sequelize'][(_0x53f1('0x92'))](_0x53f1('0xd9'));}})[_0x53f1('0x14')](function(_0x3d76c9){_0x58863a=_0x3d76c9[_0x53f1('0x4c')];if(!_0x53192c['query'][_0x53f1('0xd1')](_0x53f1('0xd6'))){_0x4c0fc9['limit']=qs['limit'](_0x53192c[_0x53f1('0x41')][_0x53f1('0x23')]);_0x4c0fc9[_0x53f1('0x24')]=qs[_0x53f1('0x24')](_0x53192c['query'][_0x53f1('0x24')]);}switch(_0x33159a['role']){case _0x53f1('0x7c'):return db[_[_0x53f1('0xa4')](_0x53192c[_0x53f1('0x41')]['channel'])+_0x53f1('0xd8')][_0x53f1('0x4a')](_0x4c0fc9);case _0x53f1('0x7b'):case'agent':return _0x33159a['get'+_[_0x53f1('0xa4')](_0x53192c[_0x53f1('0x41')][_0x53f1('0xb0')])+_0x53f1('0xa6')](_0x4c0fc9);}})['then'](function(_0x5c6dd6){return{'count':_0x58863a,'rows':_0x5c6dd6};})[_0x53f1('0x14')](respondWithResult(_0x6c34f4,null))[_0x53f1('0x1d')](handleError(_0x6c34f4,null));};exports['getVoiceQueuesRt']=function(_0x312f24,_0x5f05e0){var _0x316a5={};var _0x3512cf={};var _0x30ca16;var _0x1fc9d2;return db[_0x53f1('0x49')][_0x53f1('0xca')]({'where':{'id':_0x312f24['params']['id']}})[_0x53f1('0x14')](handleEntityNotFound(_0x5f05e0,null))[_0x53f1('0x14')](function(_0x288a26){if(_0x288a26){_0x30ca16=_0x288a26;_0x3512cf['model']=_['keys'](db[_0x53f1('0xad')]['rawAttributes']);_0x3512cf[_0x53f1('0x41')]=_[_0x53f1('0x56')](_0x312f24['query']);_0x3512cf[_0x53f1('0x57')]=_[_0x53f1('0x58')](_0x3512cf[_0x53f1('0x54')],_0x3512cf[_0x53f1('0x41')]);_0x316a5['attributes']=_[_0x53f1('0x58')](_0x3512cf[_0x53f1('0x54')],qs[_0x53f1('0xcc')](_0x312f24[_0x53f1('0x41')]['fields']));_0x316a5[_0x53f1('0x47')]=_0x316a5[_0x53f1('0x47')][_0x53f1('0x4c')]?_0x316a5['attributes']:_0x3512cf[_0x53f1('0x54')];_0x316a5[_0x53f1('0xcd')]=qs[_0x53f1('0xce')](_0x312f24['query'][_0x53f1('0xce')]);_0x316a5[_0x53f1('0x40')]=qs[_0x53f1('0x57')](_[_0x53f1('0xcf')](_0x312f24['query'],_0x3512cf[_0x53f1('0x57')]));if(_0x312f24['query'][_0x53f1('0x2e')]){_0x316a5[_0x53f1('0x40')]=_[_0x53f1('0x59')](_0x316a5[_0x53f1('0x40')],{'$or':_[_0x53f1('0x30')](_0x316a5[_0x53f1('0x47')],function(_0xd6fdf0){var _0x5604df={};_0x5604df[_0xd6fdf0]={'$like':'%'+_0x312f24[_0x53f1('0x41')][_0x53f1('0x2e')]+'%'};return _0x5604df;})});}_0x316a5=_['merge']({},_0x316a5,_0x312f24[_0x53f1('0xd0')]);return _0x30ca16[_0x53f1('0xda')](_0x316a5);}})['then'](function(_0x29e9b2){if(_0x29e9b2){_0x1fc9d2=_0x29e9b2[_0x53f1('0x4c')];if(!_0x312f24[_0x53f1('0x41')][_0x53f1('0xd1')]('nolimit')){_0x316a5[_0x53f1('0x23')]=qs[_0x53f1('0x23')](_0x312f24['query'][_0x53f1('0x23')]);_0x316a5[_0x53f1('0x24')]=qs[_0x53f1('0x24')](_0x312f24['query']['offset']);}return _0x30ca16[_0x53f1('0xda')](_0x316a5);}})[_0x53f1('0x14')](function(_0xccd2ac){if(_0xccd2ac){return _0xccd2ac?{'count':_0x1fc9d2,'rows':_0xccd2ac}:null;}})['then'](respondWithResult(_0x5f05e0,null))[_0x53f1('0x1d')](handleError(_0x5f05e0,null));};exports[_0x53f1('0xdb')]=function(_0x24f094,_0x4d71ca){var _0x4d00bb={};var _0x152389={};var _0x52a96e;var _0x3f579f;return db['User'][_0x53f1('0xca')]({'where':{'id':_0x24f094[_0x53f1('0x53')]['id']}})[_0x53f1('0x14')](handleEntityNotFound(_0x4d71ca,null))['then'](function(_0x379922){if(_0x379922){_0x52a96e=_0x379922;_0x152389[_0x53f1('0x54')]=_[_0x53f1('0x56')](db[_0x53f1('0xdc')][_0x53f1('0x39')]);_0x152389['query']=_['keys'](_0x24f094['query']);_0x152389[_0x53f1('0x57')]=_[_0x53f1('0x58')](_0x152389['model'],_0x152389['query']);_0x4d00bb[_0x53f1('0x47')]=_['intersection'](_0x152389['model'],qs[_0x53f1('0xcc')](_0x24f094[_0x53f1('0x41')][_0x53f1('0xcc')]));_0x4d00bb[_0x53f1('0x47')]=_0x4d00bb[_0x53f1('0x47')][_0x53f1('0x4c')]?_0x4d00bb[_0x53f1('0x47')]:_0x152389[_0x53f1('0x54')];_0x4d00bb['order']=qs[_0x53f1('0xce')](_0x24f094['query']['sort']);_0x4d00bb[_0x53f1('0x40')]=qs[_0x53f1('0x57')](_[_0x53f1('0xcf')](_0x24f094[_0x53f1('0x41')],_0x152389[_0x53f1('0x57')]));if(_0x24f094[_0x53f1('0x41')][_0x53f1('0x2e')]){_0x4d00bb[_0x53f1('0x40')]=_['merge'](_0x4d00bb[_0x53f1('0x40')],{'$or':_[_0x53f1('0x30')](_0x4d00bb[_0x53f1('0x47')],function(_0x5686b2){var _0xe06cfb={};_0xe06cfb[_0x5686b2]={'$like':'%'+_0x24f094['query'][_0x53f1('0x2e')]+'%'};return _0xe06cfb;})});}_0x4d00bb=_[_0x53f1('0x59')]({},_0x4d00bb,_0x24f094[_0x53f1('0xd0')]);return _0x52a96e[_0x53f1('0xdb')](_0x4d00bb);}})[_0x53f1('0x14')](function(_0x3b8c96){if(_0x3b8c96){_0x3f579f=_0x3b8c96['length'];if(!_0x24f094[_0x53f1('0x41')][_0x53f1('0xd1')](_0x53f1('0xd6'))){_0x4d00bb[_0x53f1('0x23')]=qs['limit'](_0x24f094[_0x53f1('0x41')][_0x53f1('0x23')]);_0x4d00bb['offset']=qs['offset'](_0x24f094[_0x53f1('0x41')][_0x53f1('0x24')]);}return _0x52a96e[_0x53f1('0xdb')](_0x4d00bb);}})[_0x53f1('0x14')](function(_0x3308f3){if(_0x3308f3){return _0x3308f3?{'count':_0x3f579f,'rows':_0x3308f3}:null;}})[_0x53f1('0x14')](respondWithResult(_0x4d71ca,null))['catch'](handleError(_0x4d71ca,null));};exports['getRecordings']=function(_0x473a93,_0x4083eb){var _0x4f732a={'raw':!![],'where':{}};var _0x1d4a56={};var _0x18a203={'count':0x0,'rows':[]};return db[_0x53f1('0x49')][_0x53f1('0xca')]({'where':{'id':_0x473a93[_0x53f1('0x53')]['id']}})[_0x53f1('0x14')](handleEntityNotFound(_0x4083eb,null))[_0x53f1('0x14')](function(_0x430353){if(_0x430353){_0x1d4a56[_0x53f1('0x54')]=_['keys'](db[_0x53f1('0xdd')][_0x53f1('0x39')]);_0x1d4a56[_0x53f1('0x41')]=_[_0x53f1('0x56')](_0x473a93['query']);_0x1d4a56[_0x53f1('0x57')]=_[_0x53f1('0x58')](_0x1d4a56[_0x53f1('0x54')],_0x1d4a56['query']);_0x4f732a[_0x53f1('0x47')]=_['intersection'](_0x1d4a56[_0x53f1('0x54')],qs[_0x53f1('0xcc')](_0x473a93['query']['fields']));_0x4f732a['attributes']=_0x4f732a[_0x53f1('0x47')][_0x53f1('0x4c')]?_0x4f732a[_0x53f1('0x47')]:_0x1d4a56['model'];if(!_0x473a93['query'][_0x53f1('0xd1')](_0x53f1('0xd6'))){_0x4f732a['limit']=qs['limit'](_0x473a93['query'][_0x53f1('0x23')]);_0x4f732a[_0x53f1('0x24')]=qs['offset'](_0x473a93['query']['offset']);}_0x4f732a[_0x53f1('0xcd')]=qs[_0x53f1('0xce')](_0x473a93['query']['sort']);_0x4f732a[_0x53f1('0x40')]=qs['filters'](_[_0x53f1('0xcf')](_0x473a93[_0x53f1('0x41')],_0x1d4a56[_0x53f1('0x57')]));_0x4f732a[_0x53f1('0x40')][_0x53f1('0xde')]=_0x430353['id'];if(_0x473a93[_0x53f1('0x41')]['filter']){_0x4f732a[_0x53f1('0x40')]=_['merge'](_0x4f732a[_0x53f1('0x40')],{'$or':_[_0x53f1('0x30')](_0x4f732a[_0x53f1('0x47')],function(_0xf72016){var _0x9ae261={};_0x9ae261[_0xf72016]={'$like':'%'+_0x473a93[_0x53f1('0x41')][_0x53f1('0x2e')]+'%'};return _0x9ae261;})});}_0x4f732a=_[_0x53f1('0x59')]({},_0x4f732a,_0x473a93['options']);return db[_0x53f1('0xdd')][_0x53f1('0x25')]({'where':_0x4f732a[_0x53f1('0x40')]})[_0x53f1('0x14')](function(_0x6603f){_0x18a203['count']=_0x6603f;if(_0x473a93[_0x53f1('0x41')][_0x53f1('0x42')]){_0x4f732a[_0x53f1('0x43')]=[{'all':!![]}];}return db[_0x53f1('0xdd')][_0x53f1('0x4a')](_0x4f732a);})[_0x53f1('0x14')](function(_0x4106fa){_0x18a203[_0x53f1('0x4b')]=_0x4106fa;return _0x18a203;});}})[_0x53f1('0x14')](respondWithFilteredResult(_0x4083eb,_0x4f732a))[_0x53f1('0x1d')](handleError(_0x4083eb,null));};exports[_0x53f1('0xdf')]=function(_0x3312f5,_0xfba993){var _0x465bc1={'raw':!![],'where':{}};var _0x5ded4e={};var _0x1a4970={'count':0x0,'rows':[]};return db['User']['findOne']({'where':{'id':_0x3312f5[_0x53f1('0x53')]['id']}})[_0x53f1('0x14')](handleEntityNotFound(_0xfba993,null))[_0x53f1('0x14')](function(_0x5abc2b){if(_0x5abc2b){_0x5ded4e[_0x53f1('0x54')]=_[_0x53f1('0x56')](db['ScreenRecording'][_0x53f1('0x39')]);_0x5ded4e[_0x53f1('0x41')]=_[_0x53f1('0x56')](_0x3312f5[_0x53f1('0x41')]);_0x5ded4e[_0x53f1('0x57')]=_[_0x53f1('0x58')](_0x5ded4e[_0x53f1('0x54')],_0x5ded4e[_0x53f1('0x41')]);_0x465bc1[_0x53f1('0x47')]=_['intersection'](_0x5ded4e[_0x53f1('0x54')],qs[_0x53f1('0xcc')](_0x3312f5[_0x53f1('0x41')][_0x53f1('0xcc')]));_0x465bc1[_0x53f1('0x47')]=_0x465bc1[_0x53f1('0x47')]['length']?_0x465bc1[_0x53f1('0x47')]:_0x5ded4e['model'];if(!_0x3312f5[_0x53f1('0x41')][_0x53f1('0xd1')](_0x53f1('0xd6'))){_0x465bc1[_0x53f1('0x23')]=qs[_0x53f1('0x23')](_0x3312f5['query'][_0x53f1('0x23')]);_0x465bc1[_0x53f1('0x24')]=qs[_0x53f1('0x24')](_0x3312f5[_0x53f1('0x41')][_0x53f1('0x24')]);}_0x465bc1[_0x53f1('0xcd')]=qs['sort'](_0x3312f5[_0x53f1('0x41')]['sort']);_0x465bc1[_0x53f1('0x40')]=qs[_0x53f1('0x57')](_[_0x53f1('0xcf')](_0x3312f5[_0x53f1('0x41')],_0x5ded4e[_0x53f1('0x57')]));_0x465bc1[_0x53f1('0x40')]['UserId']=_0x5abc2b['id'];if(_0x3312f5[_0x53f1('0x41')][_0x53f1('0x2e')]){_0x465bc1[_0x53f1('0x40')]=_[_0x53f1('0x59')](_0x465bc1[_0x53f1('0x40')],{'$or':_[_0x53f1('0x30')](_0x465bc1[_0x53f1('0x47')],function(_0x53b45d){var _0x1c99c1={};_0x1c99c1[_0x53b45d]={'$like':'%'+_0x3312f5[_0x53f1('0x41')][_0x53f1('0x2e')]+'%'};return _0x1c99c1;})});}_0x465bc1=_[_0x53f1('0x59')]({},_0x465bc1,_0x3312f5[_0x53f1('0xd0')]);return db[_0x53f1('0xe0')][_0x53f1('0x25')]({'where':_0x465bc1[_0x53f1('0x40')]})[_0x53f1('0x14')](function(_0x1b84df){_0x1a4970[_0x53f1('0x25')]=_0x1b84df;if(_0x3312f5['query'][_0x53f1('0x42')]){_0x465bc1[_0x53f1('0x43')]=[{'all':!![]}];}return db[_0x53f1('0xe0')]['findAll'](_0x465bc1);})['then'](function(_0x6580f0){_0x1a4970[_0x53f1('0x4b')]=_0x6580f0;return _0x1a4970;});}})[_0x53f1('0x14')](respondWithFilteredResult(_0xfba993,_0x465bc1))[_0x53f1('0x1d')](handleError(_0xfba993,null));};exports[_0x53f1('0xe1')]=function(_0x528f28,_0x3a0a81){var _0x588e80={};var _0xfe92c5={};var _0x117f28;var _0x4358ef;return db['User']['findOne']({'where':{'id':_0x528f28['params']['id']}})[_0x53f1('0x14')](handleEntityNotFound(_0x3a0a81,null))[_0x53f1('0x14')](function(_0x59dd86){if(_0x59dd86){_0x117f28=_0x59dd86;_0xfe92c5['model']=_[_0x53f1('0x56')](db[_0x53f1('0xe2')]['rawAttributes']);_0xfe92c5[_0x53f1('0x41')]=_['keys'](_0x528f28[_0x53f1('0x41')]);_0xfe92c5[_0x53f1('0x57')]=_[_0x53f1('0x58')](_0xfe92c5[_0x53f1('0x54')],_0xfe92c5[_0x53f1('0x41')]);_0x588e80[_0x53f1('0x47')]=_[_0x53f1('0x58')](_0xfe92c5[_0x53f1('0x54')],qs[_0x53f1('0xcc')](_0x528f28[_0x53f1('0x41')][_0x53f1('0xcc')]));_0x588e80[_0x53f1('0x47')]=_0x588e80[_0x53f1('0x47')][_0x53f1('0x4c')]?_0x588e80[_0x53f1('0x47')]:_0xfe92c5['model'];_0x588e80[_0x53f1('0xcd')]=qs['sort'](_0x528f28[_0x53f1('0x41')][_0x53f1('0xce')]);_0x588e80[_0x53f1('0x40')]=qs['filters'](_[_0x53f1('0xcf')](_0x528f28['query'],_0xfe92c5[_0x53f1('0x57')]));if(_0x528f28['query'][_0x53f1('0x2e')]){_0x588e80[_0x53f1('0x40')]=_['merge'](_0x588e80[_0x53f1('0x40')],{'$or':_[_0x53f1('0x30')](_0x588e80[_0x53f1('0x47')],function(_0x93dd02){var _0x5ee5b8={};_0x5ee5b8[_0x93dd02]={'$like':'%'+_0x528f28[_0x53f1('0x41')][_0x53f1('0x2e')]+'%'};return _0x5ee5b8;})});}_0x588e80=_['merge']({},_0x588e80,_0x528f28['options']);return _0x117f28['getChatInteractions'](_0x588e80);}})['then'](function(_0x3392e0){if(_0x3392e0){_0x4358ef=_0x3392e0[_0x53f1('0x4c')];if(!_0x528f28[_0x53f1('0x41')][_0x53f1('0xd1')](_0x53f1('0xd6'))){_0x588e80[_0x53f1('0x23')]=qs['limit'](_0x528f28[_0x53f1('0x41')]['limit']);_0x588e80[_0x53f1('0x24')]=qs[_0x53f1('0x24')](_0x528f28[_0x53f1('0x41')][_0x53f1('0x24')]);}return _0x117f28[_0x53f1('0xe1')](_0x588e80);}})[_0x53f1('0x14')](function(_0x4c58b8){if(_0x4c58b8){return _0x4c58b8?{'count':_0x4358ef,'rows':_0x4c58b8}:null;}})[_0x53f1('0x14')](respondWithResult(_0x3a0a81,null))[_0x53f1('0x1d')](handleError(_0x3a0a81,null));};exports['getOpenchannelInteractions']=function(_0x4a2aa4,_0x56297b){var _0x1ebaec={};var _0x193678={};var _0x134f60;var _0x2482bf;return db[_0x53f1('0x49')][_0x53f1('0xca')]({'where':{'id':_0x4a2aa4[_0x53f1('0x53')]['id']}})[_0x53f1('0x14')](handleEntityNotFound(_0x56297b,null))[_0x53f1('0x14')](function(_0x43ff8d){if(_0x43ff8d){_0x134f60=_0x43ff8d;_0x193678[_0x53f1('0x54')]=_[_0x53f1('0x56')](db['OpenchannelInteraction'][_0x53f1('0x39')]);_0x193678[_0x53f1('0x41')]=_[_0x53f1('0x56')](_0x4a2aa4[_0x53f1('0x41')]);_0x193678[_0x53f1('0x57')]=_[_0x53f1('0x58')](_0x193678[_0x53f1('0x54')],_0x193678[_0x53f1('0x41')]);_0x1ebaec[_0x53f1('0x47')]=_['intersection'](_0x193678['model'],qs['fields'](_0x4a2aa4['query']['fields']));_0x1ebaec[_0x53f1('0x47')]=_0x1ebaec[_0x53f1('0x47')][_0x53f1('0x4c')]?_0x1ebaec[_0x53f1('0x47')]:_0x193678[_0x53f1('0x54')];_0x1ebaec[_0x53f1('0xcd')]=qs[_0x53f1('0xce')](_0x4a2aa4[_0x53f1('0x41')][_0x53f1('0xce')]);_0x1ebaec[_0x53f1('0x40')]=qs[_0x53f1('0x57')](_['pick'](_0x4a2aa4[_0x53f1('0x41')],_0x193678['filters']));if(_0x4a2aa4[_0x53f1('0x41')][_0x53f1('0x2e')]){_0x1ebaec['where']=_[_0x53f1('0x59')](_0x1ebaec[_0x53f1('0x40')],{'$or':_[_0x53f1('0x30')](_0x1ebaec[_0x53f1('0x47')],function(_0x180e4a){var _0x5d9662={};_0x5d9662[_0x180e4a]={'$like':'%'+_0x4a2aa4[_0x53f1('0x41')][_0x53f1('0x2e')]+'%'};return _0x5d9662;})});}_0x1ebaec=_[_0x53f1('0x59')]({},_0x1ebaec,_0x4a2aa4[_0x53f1('0xd0')]);return _0x134f60[_0x53f1('0xe3')](_0x1ebaec);}})[_0x53f1('0x14')](function(_0x281f4e){if(_0x281f4e){_0x2482bf=_0x281f4e[_0x53f1('0x4c')];if(!_0x4a2aa4[_0x53f1('0x41')][_0x53f1('0xd1')](_0x53f1('0xd6'))){_0x1ebaec[_0x53f1('0x23')]=qs[_0x53f1('0x23')](_0x4a2aa4[_0x53f1('0x41')][_0x53f1('0x23')]);_0x1ebaec[_0x53f1('0x24')]=qs[_0x53f1('0x24')](_0x4a2aa4[_0x53f1('0x41')][_0x53f1('0x24')]);}return _0x134f60[_0x53f1('0xe3')](_0x1ebaec);}})['then'](function(_0x131b59){if(_0x131b59){return _0x131b59?{'count':_0x2482bf,'rows':_0x131b59}:null;}})['then'](respondWithResult(_0x56297b,null))[_0x53f1('0x1d')](handleError(_0x56297b,null));};exports[_0x53f1('0xe4')]=function(_0x313686,_0x51f4c6){var _0x1c6d56={'raw':!![],'where':{}};var _0x224ca9={};var _0x31776c={'count':0x0,'rows':[]};return db[_0x53f1('0x49')]['findOne']({'where':{'id':_0x313686['params']['id']}})[_0x53f1('0x14')](handleEntityNotFound(_0x51f4c6,null))['then'](function(_0x9c5b1d){if(_0x9c5b1d){_0x224ca9[_0x53f1('0x54')]=_[_0x53f1('0x56')](db[_0x53f1('0xe5')][_0x53f1('0x39')]);_0x224ca9[_0x53f1('0x41')]=_[_0x53f1('0x56')](_0x313686['query']);_0x224ca9[_0x53f1('0x57')]=_[_0x53f1('0x58')](_0x224ca9[_0x53f1('0x54')],_0x224ca9[_0x53f1('0x41')]);_0x1c6d56['attributes']=_[_0x53f1('0x58')](_0x224ca9['model'],qs[_0x53f1('0xcc')](_0x313686['query'][_0x53f1('0xcc')]));_0x1c6d56['attributes']=_0x1c6d56[_0x53f1('0x47')]['length']?_0x1c6d56[_0x53f1('0x47')]:_0x224ca9['model'];if(!_0x313686[_0x53f1('0x41')][_0x53f1('0xd1')](_0x53f1('0xd6'))){_0x1c6d56[_0x53f1('0x23')]=qs[_0x53f1('0x23')](_0x313686[_0x53f1('0x41')][_0x53f1('0x23')]);_0x1c6d56[_0x53f1('0x24')]=qs[_0x53f1('0x24')](_0x313686[_0x53f1('0x41')][_0x53f1('0x24')]);}_0x1c6d56[_0x53f1('0xcd')]=qs['sort'](_0x313686[_0x53f1('0x41')][_0x53f1('0xce')]);_0x1c6d56[_0x53f1('0x40')]=qs[_0x53f1('0x57')](_[_0x53f1('0xcf')](_0x313686[_0x53f1('0x41')],_0x224ca9[_0x53f1('0x57')]));_0x1c6d56[_0x53f1('0x40')][_0x53f1('0xde')]=_0x9c5b1d['id'];if(_0x313686[_0x53f1('0x41')][_0x53f1('0x2e')]){_0x1c6d56[_0x53f1('0x40')]=_[_0x53f1('0x59')](_0x1c6d56[_0x53f1('0x40')],{'$or':_[_0x53f1('0x30')](_0x1c6d56['attributes'],function(_0x2a4bc3){var _0x1ac4b8={};_0x1ac4b8[_0x2a4bc3]={'$like':'%'+_0x313686[_0x53f1('0x41')][_0x53f1('0x2e')]+'%'};return _0x1ac4b8;})});}_0x1c6d56=_['merge']({},_0x1c6d56,_0x313686[_0x53f1('0xd0')]);return db[_0x53f1('0xe5')][_0x53f1('0x25')]({'where':_0x1c6d56[_0x53f1('0x40')]})['then'](function(_0x294f5d){_0x31776c['count']=_0x294f5d;if(_0x313686[_0x53f1('0x41')][_0x53f1('0x42')]){_0x1c6d56[_0x53f1('0x43')]=[{'all':!![]}];}return db[_0x53f1('0xe5')]['findAll'](_0x1c6d56);})[_0x53f1('0x14')](function(_0x16e909){_0x31776c[_0x53f1('0x4b')]=_0x16e909;return _0x31776c;});}})[_0x53f1('0x14')](respondWithFilteredResult(_0x51f4c6,_0x1c6d56))['catch'](handleError(_0x51f4c6,null));};exports[_0x53f1('0xe6')]=function(_0x174db3,_0x342196){var _0x38e709={};var _0x15a7e9={};var _0x26fab4;var _0x377cf9;return db['User']['findOne']({'where':{'id':_0x174db3['params']['id']}})['then'](handleEntityNotFound(_0x342196,null))[_0x53f1('0x14')](function(_0x198fa9){if(_0x198fa9){_0x26fab4=_0x198fa9;_0x15a7e9[_0x53f1('0x54')]=_[_0x53f1('0x56')](db[_0x53f1('0xe7')][_0x53f1('0x39')]);_0x15a7e9[_0x53f1('0x41')]=_[_0x53f1('0x56')](_0x174db3[_0x53f1('0x41')]);_0x15a7e9[_0x53f1('0x57')]=_[_0x53f1('0x58')](_0x15a7e9['model'],_0x15a7e9[_0x53f1('0x41')]);_0x38e709[_0x53f1('0x47')]=_[_0x53f1('0x58')](_0x15a7e9['model'],qs[_0x53f1('0xcc')](_0x174db3[_0x53f1('0x41')][_0x53f1('0xcc')]));_0x38e709[_0x53f1('0x47')]=_0x38e709[_0x53f1('0x47')][_0x53f1('0x4c')]?_0x38e709[_0x53f1('0x47')]:_0x15a7e9[_0x53f1('0x54')];_0x38e709['order']=qs['sort'](_0x174db3[_0x53f1('0x41')]['sort']);_0x38e709[_0x53f1('0x40')]=qs[_0x53f1('0x57')](_[_0x53f1('0xcf')](_0x174db3[_0x53f1('0x41')],_0x15a7e9[_0x53f1('0x57')]));if(_0x174db3[_0x53f1('0x41')][_0x53f1('0x2e')]){_0x38e709[_0x53f1('0x40')]=_['merge'](_0x38e709[_0x53f1('0x40')],{'$or':_[_0x53f1('0x30')](_0x38e709[_0x53f1('0x47')],function(_0x2592f2){var _0x4c78de={};_0x4c78de[_0x2592f2]={'$like':'%'+_0x174db3['query'][_0x53f1('0x2e')]+'%'};return _0x4c78de;})});}_0x38e709=_['merge']({},_0x38e709,_0x174db3[_0x53f1('0xd0')]);return _0x26fab4['getSmsInteractions'](_0x38e709);}})[_0x53f1('0x14')](function(_0x1c66bc){if(_0x1c66bc){_0x377cf9=_0x1c66bc['length'];if(!_0x174db3[_0x53f1('0x41')][_0x53f1('0xd1')](_0x53f1('0xd6'))){_0x38e709['limit']=qs[_0x53f1('0x23')](_0x174db3[_0x53f1('0x41')][_0x53f1('0x23')]);_0x38e709[_0x53f1('0x24')]=qs[_0x53f1('0x24')](_0x174db3['query'][_0x53f1('0x24')]);}return _0x26fab4['getSmsInteractions'](_0x38e709);}})[_0x53f1('0x14')](function(_0x4c69e5){if(_0x4c69e5){return _0x4c69e5?{'count':_0x377cf9,'rows':_0x4c69e5}:null;}})['then'](respondWithResult(_0x342196,null))[_0x53f1('0x1d')](handleError(_0x342196,null));};exports['getFaxInteractions']=function(_0x1dab4a,_0x47c6b5){var _0x4aacdd={};var _0x5932e1={};var _0x34df43;var _0x39820c;return db['User'][_0x53f1('0xca')]({'where':{'id':_0x1dab4a[_0x53f1('0x53')]['id']}})[_0x53f1('0x14')](handleEntityNotFound(_0x47c6b5,null))[_0x53f1('0x14')](function(_0x112933){if(_0x112933){_0x34df43=_0x112933;_0x5932e1[_0x53f1('0x54')]=_[_0x53f1('0x56')](db[_0x53f1('0xe8')][_0x53f1('0x39')]);_0x5932e1[_0x53f1('0x41')]=_[_0x53f1('0x56')](_0x1dab4a[_0x53f1('0x41')]);_0x5932e1[_0x53f1('0x57')]=_[_0x53f1('0x58')](_0x5932e1[_0x53f1('0x54')],_0x5932e1['query']);_0x4aacdd[_0x53f1('0x47')]=_[_0x53f1('0x58')](_0x5932e1[_0x53f1('0x54')],qs[_0x53f1('0xcc')](_0x1dab4a[_0x53f1('0x41')]['fields']));_0x4aacdd['attributes']=_0x4aacdd[_0x53f1('0x47')]['length']?_0x4aacdd[_0x53f1('0x47')]:_0x5932e1['model'];_0x4aacdd[_0x53f1('0xcd')]=qs[_0x53f1('0xce')](_0x1dab4a['query'][_0x53f1('0xce')]);_0x4aacdd[_0x53f1('0x40')]=qs[_0x53f1('0x57')](_[_0x53f1('0xcf')](_0x1dab4a['query'],_0x5932e1['filters']));if(_0x1dab4a['query'][_0x53f1('0x2e')]){_0x4aacdd['where']=_[_0x53f1('0x59')](_0x4aacdd[_0x53f1('0x40')],{'$or':_['map'](_0x4aacdd[_0x53f1('0x47')],function(_0x559796){var _0x41eb21={};_0x41eb21[_0x559796]={'$like':'%'+_0x1dab4a[_0x53f1('0x41')][_0x53f1('0x2e')]+'%'};return _0x41eb21;})});}_0x4aacdd=_[_0x53f1('0x59')]({},_0x4aacdd,_0x1dab4a[_0x53f1('0xd0')]);return _0x34df43[_0x53f1('0xe9')](_0x4aacdd);}})['then'](function(_0x177ae2){if(_0x177ae2){_0x39820c=_0x177ae2[_0x53f1('0x4c')];if(!_0x1dab4a['query'][_0x53f1('0xd1')](_0x53f1('0xd6'))){_0x4aacdd[_0x53f1('0x23')]=qs[_0x53f1('0x23')](_0x1dab4a[_0x53f1('0x41')][_0x53f1('0x23')]);_0x4aacdd[_0x53f1('0x24')]=qs[_0x53f1('0x24')](_0x1dab4a[_0x53f1('0x41')][_0x53f1('0x24')]);}return _0x34df43[_0x53f1('0xe9')](_0x4aacdd);}})[_0x53f1('0x14')](function(_0x1a04d5){if(_0x1a04d5){return _0x1a04d5?{'count':_0x39820c,'rows':_0x1a04d5}:null;}})[_0x53f1('0x14')](respondWithResult(_0x47c6b5,null))[_0x53f1('0x1d')](handleError(_0x47c6b5,null));};exports['getWhatsappInteractions']=function(_0x44c7a4,_0x3a8778){var _0x1cc7bd={};var _0x4331b0={};var _0xd3440a;var _0x51e00a;return db[_0x53f1('0x49')][_0x53f1('0xca')]({'where':{'id':_0x44c7a4[_0x53f1('0x53')]['id']}})[_0x53f1('0x14')](handleEntityNotFound(_0x3a8778,null))[_0x53f1('0x14')](function(_0x7ffc4e){if(_0x7ffc4e){_0xd3440a=_0x7ffc4e;_0x4331b0[_0x53f1('0x54')]=_['keys'](db['WhatsappInteraction'][_0x53f1('0x39')]);_0x4331b0[_0x53f1('0x41')]=_['keys'](_0x44c7a4[_0x53f1('0x41')]);_0x4331b0[_0x53f1('0x57')]=_['intersection'](_0x4331b0[_0x53f1('0x54')],_0x4331b0['query']);_0x1cc7bd['attributes']=_[_0x53f1('0x58')](_0x4331b0[_0x53f1('0x54')],qs[_0x53f1('0xcc')](_0x44c7a4[_0x53f1('0x41')][_0x53f1('0xcc')]));_0x1cc7bd[_0x53f1('0x47')]=_0x1cc7bd[_0x53f1('0x47')][_0x53f1('0x4c')]?_0x1cc7bd['attributes']:_0x4331b0[_0x53f1('0x54')];_0x1cc7bd[_0x53f1('0xcd')]=qs['sort'](_0x44c7a4[_0x53f1('0x41')][_0x53f1('0xce')]);_0x1cc7bd[_0x53f1('0x40')]=qs['filters'](_[_0x53f1('0xcf')](_0x44c7a4[_0x53f1('0x41')],_0x4331b0['filters']));if(_0x44c7a4[_0x53f1('0x41')][_0x53f1('0x2e')]){_0x1cc7bd['where']=_[_0x53f1('0x59')](_0x1cc7bd[_0x53f1('0x40')],{'$or':_[_0x53f1('0x30')](_0x1cc7bd[_0x53f1('0x47')],function(_0x3f5616){var _0x3b2eb4={};_0x3b2eb4[_0x3f5616]={'$like':'%'+_0x44c7a4[_0x53f1('0x41')][_0x53f1('0x2e')]+'%'};return _0x3b2eb4;})});}_0x1cc7bd=_[_0x53f1('0x59')]({},_0x1cc7bd,_0x44c7a4[_0x53f1('0xd0')]);return _0xd3440a[_0x53f1('0xea')](_0x1cc7bd);}})[_0x53f1('0x14')](function(_0x267dde){if(_0x267dde){_0x51e00a=_0x267dde[_0x53f1('0x4c')];if(!_0x44c7a4['query'][_0x53f1('0xd1')](_0x53f1('0xd6'))){_0x1cc7bd[_0x53f1('0x23')]=qs[_0x53f1('0x23')](_0x44c7a4[_0x53f1('0x41')][_0x53f1('0x23')]);_0x1cc7bd[_0x53f1('0x24')]=qs[_0x53f1('0x24')](_0x44c7a4[_0x53f1('0x41')][_0x53f1('0x24')]);}return _0xd3440a['getWhatsappInteractions'](_0x1cc7bd);}})['then'](function(_0x1b0b56){if(_0x1b0b56){return _0x1b0b56?{'count':_0x51e00a,'rows':_0x1b0b56}:null;}})[_0x53f1('0x14')](respondWithResult(_0x3a8778,null))['catch'](handleError(_0x3a8778,null));};exports[_0x53f1('0xeb')]=function(_0x1969b9,_0x1a353e,_0x5a6a2f){var _0x3eac09;var _0x49d033;var _0x3e9024;var _0x2502fa=!_['isNil'](_0x1969b9['params']['id'])?_0x1969b9[_0x53f1('0x53')]['id']:!_[_0x53f1('0x67')](_0x1969b9['user']['id'])?_0x1969b9[_0x53f1('0x7b')]['id']:null;return db[_0x53f1('0x49')][_0x53f1('0x33')]({'where':{'id':_0x2502fa,'role':{'$or':[_0x53f1('0x7c'),_0x53f1('0x7b'),_0x53f1('0x2b')]}},'attributes':['id',_0x53f1('0x35'),_0x53f1('0xec'),'mobile',_0x53f1('0x34'),'internal','loginInPause']})['then'](function(_0x4d48ea){if(_0x4d48ea){if(_0x4d48ea[_0x53f1('0x34')]===_0x53f1('0x2b')){_0x3eac09=_0x4d48ea;if(_0x1969b9['body'][_0x53f1('0xa0')]){_0x3e9024=util[_0x53f1('0xab')](_0x53f1('0xed'),_0x3eac09[_0x1969b9[_0x53f1('0x5d')][_0x53f1('0xa0')]]);}else if(_0x1969b9[_0x53f1('0x5d')][_0x53f1('0xee')]){_0x3e9024=util['format']('SIP/%s',_0x1969b9[_0x53f1('0x5d')]['intrf']);}else{_0x3e9024=util[_0x53f1('0xab')](_0x53f1('0xac'),_0x3eac09[_0x53f1('0x35')]);}socket['to'](util[_0x53f1('0xab')](_0x53f1('0xef'),_0x3eac09[_0x53f1('0x35')]))[_0x53f1('0xb2')](_0x53f1('0xf0'),{'user':{'id':_0x3eac09['id'],'name':_0x3eac09[_0x53f1('0x35')]},'ip':_0x1969b9[_0x53f1('0xf1')][_0x53f1('0xf2')]||_0x1969b9['connection'][_0x53f1('0xf3')]||_0x1969b9[_0x53f1('0xf4')][_0x53f1('0xf3')]||_0x1969b9[_0x53f1('0xf5')][_0x53f1('0xf4')][_0x53f1('0xf3')]});return db[_0x53f1('0xad')][_0x53f1('0x29')]({'where':{'membername':_0x3eac09[_0x53f1('0x35')]},'individualHooks':!![]});}}else{throw new db[(_0x53f1('0x91'))]['ValidationError'](_0x53f1('0xf6'));}})[_0x53f1('0x14')](function(){if(_0x3eac09){return _0x3eac09['getVoiceQueues']({'raw':!![]});}})['then'](function(_0x1961f4){if(_0x3eac09){var _0xb0e2d4=[];if(_0x1961f4){_0x49d033=_0x1961f4;if(_0x49d033['length']){for(var _0x1075ec=0x0;_0x1075ec<_0x49d033[_0x53f1('0x4c')];_0x1075ec++){_0xb0e2d4[_0x53f1('0x48')]({'membername':_0x3eac09[_0x53f1('0x35')],'UserId':_0x3eac09['id'],'queue_name':_0x49d033[_0x1075ec][_0x53f1('0x35')],'VoiceQueueId':_0x49d033[_0x1075ec]['id'],'interface':_0x3e9024,'paused':_0x3eac09[_0x53f1('0xf7')]||![],'penalty':_0x49d033[_0x1075ec][_0x53f1('0xf8')]||0x0});}return BPromise[_0x53f1('0x8a')](_0xb0e2d4,function(_0x4405aa){return db[_0x53f1('0xad')][_0x53f1('0xae')](_0x4405aa);});}}}})[_0x53f1('0x14')](function(){if(_0x3eac09){return db[_0x53f1('0xf9')][_0x53f1('0x4a')]({'where':{'membername':_0x3eac09[_0x53f1('0x35')],'exitAt':null}});}})[_0x53f1('0x14')](function(_0x1b72c7){if(_0x3eac09){var _0x44efa6=[];_0x1b72c7[_0x53f1('0xfa')](function(_0x26bd5f){_0x44efa6[_0x53f1('0x48')](_0x26bd5f[_0x53f1('0x28')]({'exitAt':moment()['format'](_0x53f1('0xfb'))}));});return BPromise[_0x53f1('0x51')](_0x44efa6);}})[_0x53f1('0x14')](function(){if(_0x3eac09){var _0xb8649d=[];var _0xc74f96=[];var _0x25b6a4=utils[_0x53f1('0xfc')]();var _0x565dad={'membername':_0x3eac09[_0x53f1('0x35')],'interface':_0x3e9024,'enterAt':moment()[_0x53f1('0xab')](_0x53f1('0xfb')),'role':_0x3eac09[_0x53f1('0x34')],'internal':_0x3eac09[_0x53f1('0x61')]};_0x25b6a4[_0x53f1('0xfa')](function(_0x105859){_0xb8649d[_0x53f1('0x48')](_[_0x53f1('0x59')]({'channel':_0x105859,'type':_0x53f1('0xfd'),'data1':_0x1969b9[_0x53f1('0x5d')][_0x53f1('0xfe')],'data2':_0x3e9024},_0x565dad));if(_0x3eac09[_0x53f1('0xf7')]){_0xc74f96[_0x53f1('0x48')](_[_0x53f1('0x59')]({'channel':_0x105859,'type':_0x53f1('0xff'),'data1':'LOGININPAUSE'},_0x565dad));}});return db[_0x53f1('0xf9')][_0x53f1('0x87')](_0xb8649d['concat'](_0xc74f96),{'individualHooks':!![]});}})['then'](function(){if(_0x3eac09){return _0x3eac09[_0x53f1('0x28')]({'online':!![],'lastLoginAt':moment()[_0x53f1('0xab')]('YYYY-MM-DD\x20HH:mm:ss'),'voicePause':_0x3eac09['loginInPause']||![],'mailPause':_0x3eac09[_0x53f1('0xf7')]||![],'chatPause':_0x3eac09[_0x53f1('0xf7')]||![],'faxPause':_0x3eac09[_0x53f1('0xf7')]||![],'smsPause':_0x3eac09[_0x53f1('0xf7')]||![],'openchannelPause':_0x3eac09[_0x53f1('0xf7')]||![],'whatsappPause':_0x3eac09[_0x53f1('0xf7')]||![],'pauseType':_0x3eac09['loginInPause']?_0x53f1('0x100'):null,'interface':_0x3e9024,'lastPauseAt':moment()[_0x53f1('0xab')](_0x53f1('0xfb'))});}})['then'](function(_0x55f079){if(_0x1969b9[_0x53f1('0x101')]){return _0x5a6a2f();}else{return BPromise[_0x53f1('0x102')](_0x55f079)[_0x53f1('0x14')](respondWithResult(_0x1a353e,null));}})[_0x53f1('0x1d')](handleError(_0x1a353e,null));};exports['logout']=function(_0x2ff899,_0x308f37){var _0x3bce3f;return db['User'][_0x53f1('0x33')]({'where':{'id':_0x2ff899[_0x53f1('0x53')]['id'],'role':_0x53f1('0x2b')},'attributes':['id',_0x53f1('0x35'),'role']})[_0x53f1('0x14')](handleEntityNotFound(_0x308f37,null))[_0x53f1('0x14')](function(_0x6bf7d5){if(_0x6bf7d5){_0x3bce3f=_0x6bf7d5;return db[_0x53f1('0xad')][_0x53f1('0x29')]({'where':{'membername':_0x3bce3f[_0x53f1('0x35')]},'individualHooks':!![]});}})['then'](function(){return db['MemberReport']['findAll']({'where':{'membername':_0x3bce3f[_0x53f1('0x35')],'exitAt':null}});})[_0x53f1('0x14')](function(_0x55f3c9){var _0x4006cb=[];_0x55f3c9['forEach'](function(_0x111127){_0x4006cb[_0x53f1('0x48')](_0x111127[_0x53f1('0x28')]({'exitAt':moment()[_0x53f1('0xab')](_0x53f1('0xfb'))}));});return BPromise['all'](_0x4006cb);})[_0x53f1('0x14')](function(){return _0x3bce3f[_0x53f1('0x28')]({'online':![],'voicePause':![],'mailPause':![],'chatPause':![],'faxPause':![],'smsPause':![],'openchannelPause':![],'whatsappPause':![],'interface':null});})[_0x53f1('0x14')](respondWithResult(_0x308f37,null))[_0x53f1('0x1d')](handleError(_0x308f37,null));};exports[_0x53f1('0x103')]=function(_0xe39ed3,_0x482e22){var _0x2af287;return db[_0x53f1('0xad')]['update']({'paused':0x1},{'where':{'UserId':_0xe39ed3[_0x53f1('0x53')]['id']},'individualHooks':!![]})[_0x53f1('0x14')](function(){return db[_0x53f1('0x49')][_0x53f1('0x33')]({'where':{'id':_0xe39ed3[_0x53f1('0x53')]['id'],'role':_0x53f1('0x2b')},'attributes':['id',_0x53f1('0x35'),'role',_0x53f1('0x61'),'interface']});})['then'](handleEntityNotFound(_0x482e22,null))[_0x53f1('0x14')](function(_0x1db0e3){if(_0x1db0e3){_0x2af287=_0x1db0e3;return respondWithRpcPromise(_0x53f1('0x104'),_0x53f1('0x103'),{'id':_0x2af287['id'],'name':_0x2af287[_0x53f1('0x35')],'pause':!![]});}})[_0x53f1('0x14')](function(){if(_0x2af287){return db['MemberReport'][_0x53f1('0x4a')]({'where':{'membername':_0x2af287['name'],'type':_0x53f1('0xff'),'exitAt':null}});}})[_0x53f1('0x14')](function(_0x247ed5){if(_0x247ed5[_0x53f1('0x4c')]){var _0xeb1660=moment()[_0x53f1('0xab')](_0x53f1('0xfb'));for(var _0x19ca93=0x0,_0x4a5d74=_0x247ed5[_0x53f1('0x4c')];_0x19ca93<_0x4a5d74;_0x19ca93++){_0x247ed5[_0x19ca93][_0x53f1('0x105')]({'exitAt':_0xeb1660});}}})[_0x53f1('0x14')](function(){var _0x13040e=[];var _0x39e577=utils['getChannels']();_0x39e577[_0x53f1('0xfa')](function(_0x68583d){_0x13040e[_0x53f1('0x48')]({'channel':_0x68583d,'membername':_0x2af287['name'],'interface':_['isNil'](_0x2af287[_0x53f1('0xa0')])?util[_0x53f1('0xab')]('SIP/%s',_0x2af287[_0x53f1('0x35')]):_0x2af287[_0x53f1('0xa0')],'type':_0x53f1('0xff'),'enterAt':moment()[_0x53f1('0xab')](_0x53f1('0xfb')),'data1':_0xe39ed3[_0x53f1('0x5d')][_0x53f1('0x3b')]||_0x53f1('0x106'),'role':_0x2af287[_0x53f1('0x34')],'internal':_0x2af287[_0x53f1('0x61')]});});return db[_0x53f1('0xf9')]['bulkCreate'](_0x13040e,{'individualHooks':!![]});})[_0x53f1('0x14')](function(){return _0x2af287[_0x53f1('0x28')]({'voicePause':!![],'mailPause':!![],'chatPause':!![],'faxPause':!![],'smsPause':!![],'whatsappPause':!![],'openchannelPause':!![],'pauseType':_0xe39ed3[_0x53f1('0x5d')][_0x53f1('0x3b')]||_0x53f1('0x106'),'lastPauseAt':moment()[_0x53f1('0xab')]('YYYY-MM-DD\x20HH:mm:ss')});})[_0x53f1('0x14')](respondWithResult(_0x482e22,null))[_0x53f1('0x1d')](handleError(_0x482e22,null));};exports[_0x53f1('0x107')]=function(_0x544b8c,_0x2885eb){var _0x37879c;return db[_0x53f1('0x49')]['find']({'where':{'id':_0x544b8c['params']['id']},'attributes':['id','name',_0x53f1('0x34'),'voicePause',_0x53f1('0x108'),'chatPause',_0x53f1('0x109'),_0x53f1('0x10a'),'smsPause',_0x53f1('0x10b'),_0x53f1('0x10c'),_0x53f1('0x10d')]})['then'](handleEntityNotFound(_0x2885eb,null))['then'](function(_0x26f5ed){if(_0x26f5ed){_0x37879c=_0x26f5ed;if(_0x544b8c[_0x53f1('0x5d')]['channel']&&!utils[_0x53f1('0xa1')](_0x544b8c[_0x53f1('0x5d')][_0x53f1('0xb0')])){throw new db[(_0x53f1('0x91'))]['ValidationError'](_0x53f1('0xa2'));}switch(_0x544b8c[_0x53f1('0x5d')]['channel']){case _0x53f1('0xa9'):return respondWithRpcPromise(_0x53f1('0x104'),_0x53f1('0x107'),{'id':_0x37879c['id'],'name':_0x37879c[_0x53f1('0x35')],'pause':![]})[_0x53f1('0x14')](function(){return db['UserVoiceQueueRt'][_0x53f1('0x28')]({'paused':0x0},{'where':{'UserId':_0x37879c['id']},'individualHooks':!![]});})[_0x53f1('0x14')](function(){return db[_0x53f1('0xf9')][_0x53f1('0x33')]({'where':{'channel':_0x544b8c[_0x53f1('0x5d')][_0x53f1('0xb0')],'membername':_0x37879c['name'],'type':_0x53f1('0xff'),'exitAt':null}});})[_0x53f1('0x14')](function(_0x567c02){if(_0x567c02){return _0x567c02['update']({'exitAt':moment()[_0x53f1('0xab')](_0x53f1('0xfb')),'data2':_0x53f1('0x10e')},{'individualHooks':!![]});}return null;})[_0x53f1('0x14')](function(){return _0x37879c[_0x53f1('0x28')]({'voicePause':![]});});case _0x53f1('0x5c'):case _0x53f1('0xbe'):case _0x53f1('0x4f'):case'sms':case _0x53f1('0x5b'):case'openchannel':return db['MemberReport']['find']({'where':{'channel':_0x544b8c[_0x53f1('0x5d')][_0x53f1('0xb0')],'membername':_0x37879c['name'],'type':_0x53f1('0xff'),'exitAt':null}})[_0x53f1('0x14')](function(_0x598c38){if(_0x598c38){return _0x598c38['update']({'exitAt':moment()['format'](_0x53f1('0xfb')),'data2':_0x53f1('0x10e')},{'individualHooks':!![]});}return null;})['then'](function(){var _0x14d84d={};_[_0x53f1('0x26')](_0x14d84d,util['format'](_0x53f1('0x10f'),_0x544b8c['body'][_0x53f1('0xb0')],_0x53f1('0x110')),![]);return _0x37879c[_0x53f1('0x28')](_0x14d84d);});default:return respondWithRpcPromise(_0x53f1('0x104'),_0x53f1('0x107'),{'id':_0x37879c['id'],'name':_0x37879c['name'],'pause':![]})[_0x53f1('0x14')](function(){return db['UserVoiceQueueRt'][_0x53f1('0x28')]({'paused':0x0},{'where':{'UserId':_0x37879c['id']}});})[_0x53f1('0x14')](function(){return db[_0x53f1('0xf9')][_0x53f1('0x4a')]({'where':{'membername':_0x37879c[_0x53f1('0x35')],'type':_0x53f1('0xff'),'exitAt':null}});})['then'](function(_0x48ce57){var _0x24b803=[];_0x48ce57[_0x53f1('0xfa')](function(_0xa68881){_0x24b803['push'](_0xa68881[_0x53f1('0x28')]({'exitAt':moment()[_0x53f1('0xab')](_0x53f1('0xfb')),'data2':_0x53f1('0x10e')}));});return BPromise[_0x53f1('0x51')](_0x24b803);})[_0x53f1('0x14')](function(){return _0x37879c[_0x53f1('0x28')]({'voicePause':![],'mailPause':![],'chatPause':![],'faxPause':![],'smsPause':![],'whatsappPause':![],'openchannelPause':![]});});}}})[_0x53f1('0x14')](respondWithResult(_0x2885eb,null))[_0x53f1('0x1d')](handleError(_0x2885eb,null));};exports[_0x53f1('0x111')]=function(_0x1c8212,_0x2d5dc5){var _0x218b08={};var _0x3c60a9={};var _0x5d0e2a;var _0x484b72;return db['User'][_0x53f1('0xca')]({'where':{'id':_0x1c8212['params']['id']}})[_0x53f1('0x14')](handleEntityNotFound(_0x2d5dc5,null))[_0x53f1('0x14')](function(_0x3b9099){if(_0x3b9099){_0x5d0e2a=_0x3b9099;_0x3c60a9[_0x53f1('0x54')]=_['keys'](db['Team'][_0x53f1('0x39')]);_0x3c60a9['query']=_['keys'](_0x1c8212['query']);_0x3c60a9['filters']=_[_0x53f1('0x58')](_0x3c60a9['model'],_0x3c60a9[_0x53f1('0x41')]);_0x218b08[_0x53f1('0x47')]=_[_0x53f1('0x58')](_0x3c60a9[_0x53f1('0x54')],qs[_0x53f1('0xcc')](_0x1c8212[_0x53f1('0x41')]['fields']));_0x218b08['attributes']=_0x218b08[_0x53f1('0x47')][_0x53f1('0x4c')]?_0x218b08['attributes']:_0x3c60a9[_0x53f1('0x54')];_0x218b08[_0x53f1('0xcd')]=qs['sort'](_0x1c8212[_0x53f1('0x41')][_0x53f1('0xce')]);_0x218b08[_0x53f1('0x40')]=qs['filters'](_[_0x53f1('0xcf')](_0x1c8212[_0x53f1('0x41')],_0x3c60a9[_0x53f1('0x57')]));if(_0x1c8212[_0x53f1('0x41')][_0x53f1('0x2e')]){_0x218b08[_0x53f1('0x40')]=_[_0x53f1('0x59')](_0x218b08[_0x53f1('0x40')],{'$or':_['map'](_0x218b08[_0x53f1('0x47')],function(_0xb8a261){var _0x9d66bf={};_0x9d66bf[_0xb8a261]={'$like':'%'+_0x1c8212[_0x53f1('0x41')][_0x53f1('0x2e')]+'%'};return _0x9d66bf;})});}_0x218b08=_[_0x53f1('0x59')]({},_0x218b08,_0x1c8212['options']);return _0x5d0e2a[_0x53f1('0x111')](_0x218b08);}})[_0x53f1('0x14')](function(_0x2c2706){if(_0x2c2706){_0x484b72=_0x2c2706['length'];if(!_0x1c8212['query'][_0x53f1('0xd1')](_0x53f1('0xd6'))){_0x218b08[_0x53f1('0x23')]=qs['limit'](_0x1c8212[_0x53f1('0x41')]['limit']);_0x218b08[_0x53f1('0x24')]=qs[_0x53f1('0x24')](_0x1c8212[_0x53f1('0x41')][_0x53f1('0x24')]);}return _0x5d0e2a[_0x53f1('0x111')](_0x218b08);}})[_0x53f1('0x14')](function(_0xf781fd){if(_0xf781fd){return _0xf781fd?{'count':_0x484b72,'rows':_0xf781fd}:null;}})[_0x53f1('0x14')](respondWithResult(_0x2d5dc5,null))[_0x53f1('0x1d')](handleError(_0x2d5dc5,null));};exports['addTeams']=function(_0x447c9f,_0x1f454d){return db[_0x53f1('0x49')][_0x53f1('0x33')]({'where':{'id':_0x447c9f[_0x53f1('0x53')]['id']}})[_0x53f1('0x14')](handleEntityNotFound(_0x1f454d,null))['then'](function(_0x33b058){if(_0x33b058){var _0x481950=_0x33b058['get']({'plain':!![]});return _0x33b058[_0x53f1('0x112')](_0x447c9f[_0x53f1('0x5d')]['ids'],_[_0x53f1('0x113')](_0x447c9f[_0x53f1('0x5d')],[_0x53f1('0x60'),'id'])||{})[_0x53f1('0x14')](function(){for(var _0x282198=0x0;_0x282198<_0x447c9f[_0x53f1('0x5d')][_0x53f1('0x60')]['length'];_0x282198++){var _0x634497=[];var _0x475697={};db[_0x53f1('0x114')][_0x53f1('0xca')]({'where':{'id':_0x447c9f[_0x53f1('0x5d')][_0x53f1('0x60')][_0x282198]}})[_0x53f1('0x14')](function(_0x126613){_0x475697=_0x126613['dataValues'];_0x634497[_0x53f1('0x48')](_0x126613[_0x53f1('0x115')]()[_0x53f1('0x14')](function(_0x5eb8a9){for(var _0x52765c=0x0;_0x52765c<_0x5eb8a9['length'];_0x52765c++){_0x5eb8a9[_0x52765c]['setDataValue'](_0x53f1('0xb0'),_0x53f1('0x116'));}return _0x5eb8a9;}));_0x634497[_0x53f1('0x48')](_0x126613[_0x53f1('0x117')]()[_0x53f1('0x14')](function(_0xbae364){for(var _0x4cd1d0=0x0;_0x4cd1d0<_0xbae364[_0x53f1('0x4c')];_0x4cd1d0++){_0xbae364[_0x4cd1d0][_0x53f1('0x118')]('channel','Chat');}return _0xbae364;}));_0x634497[_0x53f1('0x48')](_0x126613['getMailQueues']()[_0x53f1('0x14')](function(_0x57aa3a){for(var _0x118fb7=0x0;_0x118fb7<_0x57aa3a[_0x53f1('0x4c')];_0x118fb7++){_0x57aa3a[_0x118fb7][_0x53f1('0x118')]('channel','Mail');}return _0x57aa3a;}));_0x634497[_0x53f1('0x48')](_0x126613[_0x53f1('0x119')]()[_0x53f1('0x14')](function(_0x156f11){for(var _0x486a04=0x0;_0x486a04<_0x156f11[_0x53f1('0x4c')];_0x486a04++){_0x156f11[_0x486a04][_0x53f1('0x118')](_0x53f1('0xb0'),'Sms');}return _0x156f11;}));_0x634497['push'](_0x126613[_0x53f1('0x11a')]()[_0x53f1('0x14')](function(_0x4bb306){for(var _0x4a4f27=0x0;_0x4a4f27<_0x4bb306[_0x53f1('0x4c')];_0x4a4f27++){_0x4bb306[_0x4a4f27][_0x53f1('0x118')](_0x53f1('0xb0'),_0x53f1('0x11b'));}return _0x4bb306;}));_0x634497[_0x53f1('0x48')](_0x126613[_0x53f1('0x11c')]()[_0x53f1('0x14')](function(_0x3821ac){for(var _0x425330=0x0;_0x425330<_0x3821ac[_0x53f1('0x4c')];_0x425330++){_0x3821ac[_0x425330][_0x53f1('0x118')](_0x53f1('0xb0'),_0x53f1('0x11d'));}return _0x3821ac;}));_0x634497['push'](_0x126613[_0x53f1('0x11e')]()[_0x53f1('0x14')](function(_0x127e9a){for(var _0x454ba4=0x0;_0x454ba4<_0x127e9a[_0x53f1('0x4c')];_0x454ba4++){_0x127e9a[_0x454ba4]['setDataValue'](_0x53f1('0xb0'),'Openchannel');}return _0x127e9a;}));return BPromise['all'](_0x634497);})['then'](function(_0x10313f){var _0x52d880=_[_0x53f1('0x11f')](_0x10313f);_0x634497=[];return db['sequelize'][_0x53f1('0x120')](function(_0x3084fe){for(var _0x3a58aa=0x0;_0x3a58aa<_0x52d880['length'];_0x3a58aa++){_0x634497[_0x53f1('0x48')](_0x52d880[_0x3a58aa][_0x53f1('0x121')](_0x481950['id']),{'transaction':_0x3084fe});}return BPromise[_0x53f1('0x51')](_0x634497)[_0x53f1('0x14')](function(){if(_0x481950[_0x53f1('0x9e')]){return BPromise[_0x53f1('0x8a')](_['filter'](_0x52d880,function(_0x3ea682){return _0x3ea682['getDataValue'](_0x53f1('0xb0'))==='Voice';}),function(_0x233ad9){return db[_0x53f1('0xad')][_0x53f1('0xae')]({'membername':_0x481950['name'],'UserId':_0x481950['id'],'queue_name':_0x233ad9[_0x53f1('0x35')],'VoiceQueueId':_0x233ad9['id'],'interface':_[_0x53f1('0x67')](_0x481950[_0x53f1('0xa0')])?util[_0x53f1('0xab')](_0x53f1('0xac'),_0x481950[_0x53f1('0x35')]):_0x481950[_0x53f1('0xa0')],'paused':_0x481950[_0x53f1('0x9f')]||![],'penalty':_0x481950['penalty']},{'transaction':_0x3084fe});});}else{return;}})['then'](function(){for(var _0x5a66c5=0x0;_0x5a66c5<_0x52d880[_0x53f1('0x4c')];_0x5a66c5++){var _0x193ad3=_0x52d880[_0x5a66c5][_0x53f1('0x122')](_0x53f1('0xb0'));var _0x184359=_0x193ad3+_0x53f1('0xa8');socket[_0x53f1('0xb2')]('user'+_0x193ad3+_0x53f1('0x123'),{'UserId':_0x481950['id'],['queueField']:_0x52d880[_0x5a66c5]['id']});}});});})['then'](function(){db['TeamVoicePrefix'][_0x53f1('0xca')]({'where':{'teamId':_0x475697['id']}})[_0x53f1('0x14')](function(_0x40a6b5){if(_0x40a6b5){db['UserVoicePrefix'][_0x53f1('0x79')]({'UserId':_0x447c9f[_0x53f1('0x53')]['id'],'VoicePrefixId':_0x40a6b5[_0x53f1('0x124')]});}});});}});}})[_0x53f1('0x14')](respondWithStatusCode(_0x1f454d,null))[_0x53f1('0x1d')](handleError(_0x1f454d,null));};exports['removeTeams']=function(_0x352047,_0x454cfa){return db['User']['findOne']({'where':{'id':_0x352047['params']['id']}})[_0x53f1('0x14')](handleEntityNotFound(_0x454cfa,null))['then'](function(_0x96c6e5){if(_0x96c6e5){var _0x39afe5=_0x96c6e5[_0x53f1('0x2a')]({'plain':!![]});var _0x2928b3=_0x352047['query']['ids'];return _0x96c6e5['removeTeams'](_0x2928b3)[_0x53f1('0x14')](function(){for(var _0x49e855=0x0;_0x49e855<_0x2928b3['length'];_0x49e855++){var _0xd8e972=[];var _0x5ceb83={};db[_0x53f1('0x114')][_0x53f1('0xca')]({'where':{'id':_0x2928b3[_0x49e855]}})['then'](function(_0x3f974e){_0x5ceb83=_0x3f974e[_0x53f1('0x4d')];_0xd8e972[_0x53f1('0x48')](_0x3f974e[_0x53f1('0x115')]()['then'](function(_0x26d3d3){for(var _0x54ef5a=0x0;_0x54ef5a<_0x26d3d3[_0x53f1('0x4c')];_0x54ef5a++){_0x26d3d3[_0x54ef5a][_0x53f1('0x118')]('channel',_0x53f1('0x116'));}return _0x26d3d3;}));_0xd8e972[_0x53f1('0x48')](_0x3f974e[_0x53f1('0x117')]()[_0x53f1('0x14')](function(_0x45a9b8){for(var _0x329365=0x0;_0x329365<_0x45a9b8[_0x53f1('0x4c')];_0x329365++){_0x45a9b8[_0x329365][_0x53f1('0x118')]('channel',_0x53f1('0x125'));}return _0x45a9b8;}));_0xd8e972[_0x53f1('0x48')](_0x3f974e['getMailQueues']()[_0x53f1('0x14')](function(_0x8a064e){for(var _0x5e5b40=0x0;_0x5e5b40<_0x8a064e['length'];_0x5e5b40++){_0x8a064e[_0x5e5b40][_0x53f1('0x118')](_0x53f1('0xb0'),_0x53f1('0x126'));}return _0x8a064e;}));_0xd8e972[_0x53f1('0x48')](_0x3f974e['getSmsQueues']()['then'](function(_0x52cd06){for(var _0x313cae=0x0;_0x313cae<_0x52cd06[_0x53f1('0x4c')];_0x313cae++){_0x52cd06[_0x313cae][_0x53f1('0x118')](_0x53f1('0xb0'),_0x53f1('0x127'));}return _0x52cd06;}));_0xd8e972['push'](_0x3f974e[_0x53f1('0x11a')]()[_0x53f1('0x14')](function(_0x52de27){for(var _0x2581d4=0x0;_0x2581d4<_0x52de27[_0x53f1('0x4c')];_0x2581d4++){_0x52de27[_0x2581d4][_0x53f1('0x118')](_0x53f1('0xb0'),_0x53f1('0x11b'));}return _0x52de27;}));_0xd8e972['push'](_0x3f974e['getFaxQueues']()['then'](function(_0x3063e1){for(var _0x38ace2=0x0;_0x38ace2<_0x3063e1[_0x53f1('0x4c')];_0x38ace2++){_0x3063e1[_0x38ace2]['setDataValue'](_0x53f1('0xb0'),_0x53f1('0x11d'));}return _0x3063e1;}));_0xd8e972['push'](_0x3f974e['getOpenchannelQueues']()[_0x53f1('0x14')](function(_0x5d832f){for(var _0xbc5fed=0x0;_0xbc5fed<_0x5d832f[_0x53f1('0x4c')];_0xbc5fed++){_0x5d832f[_0xbc5fed]['setDataValue'](_0x53f1('0xb0'),_0x53f1('0x128'));}return _0x5d832f;}));return BPromise[_0x53f1('0x51')](_0xd8e972);})[_0x53f1('0x14')](function(_0x5a690e){var _0xb302f6=_[_0x53f1('0x11f')](_0x5a690e);_0xd8e972=[];return db[_0x53f1('0x68')]['transaction'](function(_0xc35347){for(var _0x3262ce=0x0;_0x3262ce<_0xb302f6[_0x53f1('0x4c')];_0x3262ce++){_0xd8e972[_0x53f1('0x48')](_0xb302f6[_0x3262ce]['removeAgent'](_0x39afe5['id']),{'transaction':_0xc35347});}return BPromise[_0x53f1('0x51')](_0xd8e972)[_0x53f1('0x14')](function(){if(_0x39afe5[_0x53f1('0x9e')]){return BPromise[_0x53f1('0x8a')](_['filter'](_0xb302f6,function(_0x2dfd3c){return _0x2dfd3c[_0x53f1('0x122')]('channel')===_0x53f1('0x116');}),function(_0x55225d){return db[_0x53f1('0xad')][_0x53f1('0x29')]({'where':{'VoiceQueueId':_0x55225d['id'],'UserId':_0x39afe5['id']},'transaction':_0xc35347});});}else{return;}})['then'](function(){db[_0x53f1('0x129')][_0x53f1('0xca')]({'where':{'teamId':_0x5ceb83['id']}})[_0x53f1('0x14')](function(_0x56d32b){if(_0x56d32b){return db[_0x53f1('0x12a')][_0x53f1('0x29')]({'where':{'UserId':_0x39afe5['id'],'VoicePrefixId':_0x56d32b[_0x53f1('0x4d')][_0x53f1('0x124')]}});}});})[_0x53f1('0x14')](function(){for(var _0x143375=0x0;_0x143375<_0xb302f6[_0x53f1('0x4c')];_0x143375++){var _0x24a2eb=_0xb302f6[_0x143375][_0x53f1('0x122')](_0x53f1('0xb0'));var _0x55b42c=_0x24a2eb+_0x53f1('0xa8');socket[_0x53f1('0xb2')]('user'+_0x24a2eb+_0x53f1('0xb3'),{'UserId':_0x39afe5['id'],['queueField']:_0xb302f6[_0x143375]['id']});}});});});}});}})['then'](respondWithStatusCode(_0x454cfa,null))[_0x53f1('0x1d')](handleError(_0x454cfa,null));};exports[_0x53f1('0x12b')]=function(_0x1bc542,_0x571ad2){var _0x15322f={};var _0x9ac3a={};var _0x2dfde6;var _0x44166e;return db[_0x53f1('0x49')][_0x53f1('0xca')]({'where':{'id':_0x1bc542['params']['id']}})[_0x53f1('0x14')](handleEntityNotFound(_0x571ad2,null))[_0x53f1('0x14')](function(_0xfc50b6){if(_0xfc50b6){_0x2dfde6=_0xfc50b6;_0x9ac3a['model']=_[_0x53f1('0x56')](db['CmList'][_0x53f1('0x39')]);_0x9ac3a['query']=_[_0x53f1('0x56')](_0x1bc542[_0x53f1('0x41')]);_0x9ac3a[_0x53f1('0x57')]=_[_0x53f1('0x58')](_0x9ac3a[_0x53f1('0x54')],_0x9ac3a[_0x53f1('0x41')]);_0x15322f[_0x53f1('0x47')]=_[_0x53f1('0x58')](_0x9ac3a['model'],qs[_0x53f1('0xcc')](_0x1bc542['query'][_0x53f1('0xcc')]));_0x15322f['attributes']=_0x15322f['attributes'][_0x53f1('0x4c')]?_0x15322f['attributes']:_0x9ac3a[_0x53f1('0x54')];_0x15322f[_0x53f1('0xcd')]=qs['sort'](_0x1bc542['query'][_0x53f1('0xce')]);_0x15322f[_0x53f1('0x40')]=qs[_0x53f1('0x57')](_['pick'](_0x1bc542['query'],_0x9ac3a['filters']));if(_0x1bc542[_0x53f1('0x41')][_0x53f1('0x2e')]){_0x15322f[_0x53f1('0x40')]=_[_0x53f1('0x59')](_0x15322f[_0x53f1('0x40')],{'$or':_['map'](_0x15322f[_0x53f1('0x47')],function(_0x11af17){var _0x16a5f8={};_0x16a5f8[_0x11af17]={'$like':'%'+_0x1bc542[_0x53f1('0x41')][_0x53f1('0x2e')]+'%'};return _0x16a5f8;})});}_0x15322f=_['merge']({},_0x15322f,_0x1bc542[_0x53f1('0xd0')]);return _0x2dfde6[_0x53f1('0x12b')](_0x15322f);}})[_0x53f1('0x14')](function(_0x237be6){if(_0x237be6){_0x44166e=_0x237be6[_0x53f1('0x4c')];if(!_0x1bc542[_0x53f1('0x41')][_0x53f1('0xd1')](_0x53f1('0xd6'))){_0x15322f['limit']=qs[_0x53f1('0x23')](_0x1bc542[_0x53f1('0x41')][_0x53f1('0x23')]);_0x15322f['offset']=qs[_0x53f1('0x24')](_0x1bc542[_0x53f1('0x41')]['offset']);}return _0x2dfde6[_0x53f1('0x12b')](_0x15322f);}})[_0x53f1('0x14')](function(_0x30a205){if(_0x30a205){return _0x30a205?{'count':_0x44166e,'rows':_0x30a205}:null;}})[_0x53f1('0x14')](respondWithResult(_0x571ad2,null))[_0x53f1('0x1d')](handleError(_0x571ad2,null));};exports[_0x53f1('0x12c')]=function(_0x1f41f3,_0x48b4e6){var _0x5277eb={};var _0x50eb98={};var _0xb372e9;return db[_0x53f1('0x49')][_0x53f1('0xca')]({'where':{'id':_0x1f41f3[_0x53f1('0x53')]['id']}})[_0x53f1('0x14')](handleEntityNotFound(_0x48b4e6,null))['then'](function(_0x31a40a){if(_0x31a40a){_0xb372e9=_0x31a40a;_0x50eb98[_0x53f1('0x54')]=_[_0x53f1('0x56')](db[_0x53f1('0x49')][_0x53f1('0x39')]);_0x50eb98[_0x53f1('0x41')]=_[_0x53f1('0x56')](_0x1f41f3['query']);_0x50eb98[_0x53f1('0x57')]=_['intersection'](_0x50eb98[_0x53f1('0x54')],_0x50eb98['query']);_0x5277eb['attributes']=_[_0x53f1('0x58')](_0x50eb98[_0x53f1('0x54')],qs[_0x53f1('0xcc')](_0x1f41f3['query'][_0x53f1('0xcc')]));_0x5277eb[_0x53f1('0x47')]=_0x5277eb[_0x53f1('0x47')][_0x53f1('0x4c')]?_0x5277eb[_0x53f1('0x47')]:_0x50eb98[_0x53f1('0x54')];_0x5277eb[_0x53f1('0xcd')]=qs[_0x53f1('0xce')](_0x1f41f3[_0x53f1('0x41')][_0x53f1('0xce')]);_0x5277eb[_0x53f1('0x40')]=qs[_0x53f1('0x57')](_[_0x53f1('0xcf')](_0x1f41f3[_0x53f1('0x41')],_0x50eb98[_0x53f1('0x57')]));if(_0x1f41f3[_0x53f1('0x41')][_0x53f1('0x2e')]){_0x5277eb[_0x53f1('0x40')]=_[_0x53f1('0x59')](_0x5277eb[_0x53f1('0x40')],{'$or':_[_0x53f1('0x30')](_0x5277eb[_0x53f1('0x47')],function(_0x39e5b1){var _0x54c5dc={};_0x54c5dc[_0x39e5b1]={'$like':'%'+_0x1f41f3[_0x53f1('0x41')][_0x53f1('0x2e')]+'%'};return _0x54c5dc;})});}_0x5277eb[_0x53f1('0x54')]=db['User'];_0x5277eb['as']=_0x53f1('0x82');_0x5277eb=_['merge']({},_0x5277eb,_0x1f41f3[_0x53f1('0xd0')]);return _0xb372e9[_0x53f1('0x115')]({'include':[_0x5277eb]});}})[_0x53f1('0x14')](function(_0x1fbdf3){if(_0x1fbdf3){var _0x3448e2={},_0x7c61=[];for(var _0x11963d=0x0;_0x11963d<_0x1fbdf3[_0x53f1('0x4c')];_0x11963d+=0x1){for(var _0x3e85b3=0x0,_0x34753d;_0x3e85b3<_0x1fbdf3[_0x11963d][_0x53f1('0x82')]['length'];_0x3e85b3+=0x1){_0x34753d=_0x1fbdf3[_0x11963d][_0x53f1('0x82')][_0x3e85b3]['get']({'plain':!![]});_0x3448e2[_0x34753d['id']]=_0x34753d;}}_0x3448e2=_[_0x53f1('0x12d')](_0x3448e2);for(var _0x58b940=qs[_0x53f1('0x24')](_0x1f41f3[_0x53f1('0x41')]['offset']);_0x58b940<_0x3448e2['length']&&_0x7c61['length']<qs['limit'](_0x1f41f3[_0x53f1('0x41')][_0x53f1('0x23')]);_0x58b940+=0x1){if(_0x3448e2[_0x58b940]){_0x7c61[_0x53f1('0x48')](_0x3448e2[_0x58b940]);}}return{'count':_0x3448e2['length'],'rows':_0x7c61};}})[_0x53f1('0x14')](respondWithResult(_0x48b4e6,null))[_0x53f1('0x1d')](handleError(_0x48b4e6,null));};exports['destroy']=function(_0xc13c1d,_0x484a8d){if(_0xc13c1d[_0x53f1('0x7b')]['id']==_0xc13c1d['params']['id']){return _0x484a8d[_0x53f1('0x1f')](0x1f4)[_0x53f1('0x37')]({'message':_0x53f1('0x12e')});}return db[_0x53f1('0x49')]['find']({'where':{'id':_0xc13c1d['params']['id']}})[_0x53f1('0x14')](handleEntityNotFound(_0x484a8d,null))[_0x53f1('0x14')](removeEntity(_0x484a8d,null))['catch'](handleError(_0x484a8d,null));};exports[_0x53f1('0x12f')]=function(_0x761056,_0x4b31d7){return db[_0x53f1('0x49')][_0x53f1('0x33')]({'where':{'id':_0x761056[_0x53f1('0x53')]['id']}})[_0x53f1('0x14')](handleEntityNotFound(_0x4b31d7,null))['then'](function(_0x26f5c5){if(_0x26f5c5){return _0x26f5c5[_0x53f1('0x12f')](_0x761056[_0x53f1('0x5d')][_0x53f1('0x60')],_[_0x53f1('0x113')](_0x761056[_0x53f1('0x5d')],[_0x53f1('0x60'),'id'])||{})[_0x53f1('0x130')](function(){for(var _0x5104a2=0x0;_0x5104a2<_0x761056[_0x53f1('0x5d')][_0x53f1('0x60')][_0x53f1('0x4c')];_0x5104a2+=0x1){socket['emit'](_0x53f1('0x131'),{'ChatInteractionId':Number(_0x761056['body'][_0x53f1('0x60')][_0x5104a2]),'UserId':Number(_0x761056['params']['id'])});}return _0x761056[_0x53f1('0x5d')][_0x53f1('0x60')];});}})['then'](respondWithResult(_0x4b31d7,null))[_0x53f1('0x1d')](handleError(_0x4b31d7,null));};exports[_0x53f1('0x132')]=function(_0x45e62d,_0x1725a2){return db[_0x53f1('0x49')][_0x53f1('0x33')]({'where':{'id':_0x45e62d[_0x53f1('0x53')]['id']}})['then'](handleEntityNotFound(_0x1725a2,null))[_0x53f1('0x14')](function(_0x37154c){if(_0x37154c){return _0x37154c[_0x53f1('0x132')](_0x45e62d[_0x53f1('0x41')]['ids'])[_0x53f1('0x14')](function(){if(_[_0x53f1('0x133')](_0x45e62d[_0x53f1('0x41')][_0x53f1('0x60')])){for(var _0x1923de=0x0;_0x1923de<_0x45e62d[_0x53f1('0x41')][_0x53f1('0x60')][_0x53f1('0x4c')];_0x1923de+=0x1){socket[_0x53f1('0xb2')](_0x53f1('0x134'),{'ChatInteractionId':Number(_0x45e62d[_0x53f1('0x41')]['ids'][_0x1923de]),'UserId':Number(_0x45e62d[_0x53f1('0x53')]['id'])});}}else{socket[_0x53f1('0xb2')](_0x53f1('0x134'),{'ChatInteractionId':Number(_0x45e62d[_0x53f1('0x41')]['ids']),'UserId':Number(_0x45e62d['params']['id'])});}});}})['then'](respondWithStatusCode(_0x1725a2,null))['catch'](handleError(_0x1725a2,null));};exports[_0x53f1('0x135')]=function(_0x26965b,_0x28a369){return db[_0x53f1('0x49')]['find']({'where':{'id':_0x26965b[_0x53f1('0x53')]['id']}})[_0x53f1('0x14')](handleEntityNotFound(_0x28a369,null))[_0x53f1('0x14')](function(_0xf90d8){if(_0xf90d8){return _0xf90d8[_0x53f1('0x135')](_0x26965b[_0x53f1('0x5d')]['ids'],_[_0x53f1('0x113')](_0x26965b[_0x53f1('0x5d')],['ids','id'])||{})[_0x53f1('0x130')](function(){for(var _0x627791=0x0;_0x627791<_0x26965b[_0x53f1('0x5d')][_0x53f1('0x60')]['length'];_0x627791+=0x1){socket['emit'](_0x53f1('0x136'),{'MailInteractionId':Number(_0x26965b[_0x53f1('0x5d')][_0x53f1('0x60')][_0x627791]),'UserId':Number(_0x26965b[_0x53f1('0x53')]['id'])});}return _0x26965b['body']['ids'];});}})[_0x53f1('0x14')](respondWithResult(_0x28a369,null))[_0x53f1('0x1d')](handleError(_0x28a369,null));};exports[_0x53f1('0x137')]=function(_0x535e74,_0x10edc5){return db[_0x53f1('0x49')][_0x53f1('0x33')]({'where':{'id':_0x535e74['params']['id']}})[_0x53f1('0x14')](handleEntityNotFound(_0x10edc5,null))[_0x53f1('0x14')](function(_0x43b831){if(_0x43b831){return _0x43b831[_0x53f1('0x137')](_0x535e74['query'][_0x53f1('0x60')])['then'](function(){if(_[_0x53f1('0x133')](_0x535e74[_0x53f1('0x41')][_0x53f1('0x60')])){for(var _0x20b9e2=0x0;_0x20b9e2<_0x535e74['query'][_0x53f1('0x60')][_0x53f1('0x4c')];_0x20b9e2+=0x1){socket['emit'](_0x53f1('0x138'),{'MailInteractionId':Number(_0x535e74[_0x53f1('0x41')][_0x53f1('0x60')][_0x20b9e2]),'UserId':Number(_0x535e74[_0x53f1('0x53')]['id'])});}}else{socket['emit'](_0x53f1('0x138'),{'MailInteractionId':Number(_0x535e74[_0x53f1('0x41')][_0x53f1('0x60')]),'UserId':Number(_0x535e74[_0x53f1('0x53')]['id'])});}});}})[_0x53f1('0x14')](respondWithStatusCode(_0x10edc5,null))['catch'](handleError(_0x10edc5,null));};exports[_0x53f1('0x139')]=function(_0xc8b70e,_0x11eb77){return db['User'][_0x53f1('0x33')]({'where':{'id':_0xc8b70e['params']['id']}})[_0x53f1('0x14')](handleEntityNotFound(_0x11eb77,null))['then'](function(_0x3b28eb){if(_0x3b28eb){return _0x3b28eb[_0x53f1('0x139')](_0xc8b70e[_0x53f1('0x5d')][_0x53f1('0x60')],_[_0x53f1('0x113')](_0xc8b70e[_0x53f1('0x5d')],[_0x53f1('0x60'),'id'])||{})[_0x53f1('0x130')](function(){for(var _0x4507a9=0x0;_0x4507a9<_0xc8b70e['body'][_0x53f1('0x60')][_0x53f1('0x4c')];_0x4507a9+=0x1){socket['emit'](_0x53f1('0x13a'),{'FaxInteractionId':Number(_0xc8b70e['body'][_0x53f1('0x60')][_0x4507a9]),'UserId':Number(_0xc8b70e['params']['id'])});}return _0xc8b70e[_0x53f1('0x5d')]['ids'];});}})[_0x53f1('0x14')](respondWithResult(_0x11eb77,null))[_0x53f1('0x1d')](handleError(_0x11eb77,null));};exports[_0x53f1('0x13b')]=function(_0xff6b6a,_0x4b4bd1){return db[_0x53f1('0x49')][_0x53f1('0x33')]({'where':{'id':_0xff6b6a[_0x53f1('0x53')]['id']}})['then'](handleEntityNotFound(_0x4b4bd1,null))['then'](function(_0x8149f4){if(_0x8149f4){return _0x8149f4['removeFaxInteractions'](_0xff6b6a[_0x53f1('0x41')][_0x53f1('0x60')])['then'](function(){if(_[_0x53f1('0x133')](_0xff6b6a[_0x53f1('0x41')][_0x53f1('0x60')])){for(var _0x4e801e=0x0;_0x4e801e<_0xff6b6a[_0x53f1('0x41')]['ids'][_0x53f1('0x4c')];_0x4e801e+=0x1){socket[_0x53f1('0xb2')](_0x53f1('0x13c'),{'FaxInteractionId':Number(_0xff6b6a['query'][_0x53f1('0x60')][_0x4e801e]),'UserId':Number(_0xff6b6a[_0x53f1('0x53')]['id'])});}}else{socket['emit'](_0x53f1('0x13c'),{'FaxInteractionId':Number(_0xff6b6a[_0x53f1('0x41')][_0x53f1('0x60')]),'UserId':Number(_0xff6b6a[_0x53f1('0x53')]['id'])});}});}})['then'](respondWithStatusCode(_0x4b4bd1,null))[_0x53f1('0x1d')](handleError(_0x4b4bd1,null));};exports['addSmsInteractions']=function(_0x12bb5b,_0x6d7e82){return db['User'][_0x53f1('0x33')]({'where':{'id':_0x12bb5b[_0x53f1('0x53')]['id']}})[_0x53f1('0x14')](handleEntityNotFound(_0x6d7e82,null))[_0x53f1('0x14')](function(_0x5c139b){if(_0x5c139b){return _0x5c139b[_0x53f1('0x13d')](_0x12bb5b[_0x53f1('0x5d')][_0x53f1('0x60')],_[_0x53f1('0x113')](_0x12bb5b[_0x53f1('0x5d')],[_0x53f1('0x60'),'id'])||{})[_0x53f1('0x130')](function(){for(var _0x2dcb45=0x0;_0x2dcb45<_0x12bb5b[_0x53f1('0x5d')][_0x53f1('0x60')]['length'];_0x2dcb45+=0x1){socket[_0x53f1('0xb2')](_0x53f1('0x13e'),{'SmsInteractionId':Number(_0x12bb5b[_0x53f1('0x5d')]['ids'][_0x2dcb45]),'UserId':Number(_0x12bb5b[_0x53f1('0x53')]['id'])});}return _0x12bb5b['body'][_0x53f1('0x60')];});}})[_0x53f1('0x14')](respondWithResult(_0x6d7e82,null))['catch'](handleError(_0x6d7e82,null));};exports[_0x53f1('0x13f')]=function(_0x3f2e71,_0x1e2528){return db['User'][_0x53f1('0x33')]({'where':{'id':_0x3f2e71[_0x53f1('0x53')]['id']}})[_0x53f1('0x14')](handleEntityNotFound(_0x1e2528,null))[_0x53f1('0x14')](function(_0x388bda){if(_0x388bda){return _0x388bda[_0x53f1('0x13f')](_0x3f2e71[_0x53f1('0x41')][_0x53f1('0x60')])['then'](function(){if(_[_0x53f1('0x133')](_0x3f2e71[_0x53f1('0x41')][_0x53f1('0x60')])){for(var _0x2220da=0x0;_0x2220da<_0x3f2e71[_0x53f1('0x41')][_0x53f1('0x60')][_0x53f1('0x4c')];_0x2220da+=0x1){socket[_0x53f1('0xb2')](_0x53f1('0x140'),{'SmsInteractionId':Number(_0x3f2e71['query']['ids'][_0x2220da]),'UserId':Number(_0x3f2e71[_0x53f1('0x53')]['id'])});}}else{socket[_0x53f1('0xb2')](_0x53f1('0x140'),{'SmsInteractionId':Number(_0x3f2e71[_0x53f1('0x41')]['ids']),'UserId':Number(_0x3f2e71[_0x53f1('0x53')]['id'])});}});}})[_0x53f1('0x14')](respondWithStatusCode(_0x1e2528,null))[_0x53f1('0x1d')](handleError(_0x1e2528,null));};exports['addOpenchannelInteractions']=function(_0x32aced,_0x1cf391){return db[_0x53f1('0x49')][_0x53f1('0x33')]({'where':{'id':_0x32aced['params']['id']}})['then'](handleEntityNotFound(_0x1cf391,null))[_0x53f1('0x14')](function(_0x515e38){if(_0x515e38){return _0x515e38['addOpenchannelInteractions'](_0x32aced['body'][_0x53f1('0x60')],_[_0x53f1('0x113')](_0x32aced['body'],[_0x53f1('0x60'),'id'])||{})[_0x53f1('0x130')](function(){for(var _0x5ae637=0x0;_0x5ae637<_0x32aced[_0x53f1('0x5d')]['ids'][_0x53f1('0x4c')];_0x5ae637+=0x1){socket['emit'](_0x53f1('0x141'),{'OpenchannelInteractionId':Number(_0x32aced[_0x53f1('0x5d')][_0x53f1('0x60')][_0x5ae637]),'UserId':Number(_0x32aced['params']['id'])});}return _0x32aced[_0x53f1('0x5d')][_0x53f1('0x60')];});}})[_0x53f1('0x14')](respondWithResult(_0x1cf391,null))[_0x53f1('0x1d')](handleError(_0x1cf391,null));};exports[_0x53f1('0x142')]=function(_0xab8869,_0x36e433){return db[_0x53f1('0x49')]['find']({'where':{'id':_0xab8869[_0x53f1('0x53')]['id']}})[_0x53f1('0x14')](handleEntityNotFound(_0x36e433,null))[_0x53f1('0x14')](function(_0x221b02){if(_0x221b02){return _0x221b02[_0x53f1('0x142')](_0xab8869[_0x53f1('0x41')][_0x53f1('0x60')])[_0x53f1('0x14')](function(){if(_[_0x53f1('0x133')](_0xab8869[_0x53f1('0x41')][_0x53f1('0x60')])){for(var _0x37632b=0x0;_0x37632b<_0xab8869[_0x53f1('0x41')]['ids'][_0x53f1('0x4c')];_0x37632b+=0x1){socket[_0x53f1('0xb2')](_0x53f1('0x143'),{'OpenchannelInteractionId':Number(_0xab8869[_0x53f1('0x41')]['ids'][_0x37632b]),'UserId':Number(_0xab8869[_0x53f1('0x53')]['id'])});}}else{socket[_0x53f1('0xb2')]('user_has_openchannel_interactions:remove',{'OpenchannelInteractionId':Number(_0xab8869['query'][_0x53f1('0x60')]),'UserId':Number(_0xab8869[_0x53f1('0x53')]['id'])});}});}})['then'](respondWithStatusCode(_0x36e433,null))[_0x53f1('0x1d')](handleError(_0x36e433,null));};exports[_0x53f1('0x144')]=function(_0x2f6e33,_0x194b7a){return db[_0x53f1('0x49')][_0x53f1('0x33')]({'where':{'id':_0x2f6e33[_0x53f1('0x53')]['id']}})[_0x53f1('0x14')](handleEntityNotFound(_0x194b7a,null))[_0x53f1('0x14')](function(_0x2057da){if(_0x2057da){return _0x2057da[_0x53f1('0x144')](_0x2f6e33[_0x53f1('0x5d')]['ids'],_[_0x53f1('0x113')](_0x2f6e33[_0x53f1('0x5d')],[_0x53f1('0x60'),'id'])||{})['spread'](function(){for(var _0x56fdeb=0x0;_0x56fdeb<_0x2f6e33[_0x53f1('0x5d')][_0x53f1('0x60')][_0x53f1('0x4c')];_0x56fdeb+=0x1){socket['emit'](_0x53f1('0x145'),{'WhatsappInteractionId':Number(_0x2f6e33['body'][_0x53f1('0x60')][_0x56fdeb]),'UserId':Number(_0x2f6e33[_0x53f1('0x53')]['id'])});}return _0x2f6e33[_0x53f1('0x5d')]['ids'];});}})['then'](respondWithResult(_0x194b7a,null))[_0x53f1('0x1d')](handleError(_0x194b7a,null));};exports[_0x53f1('0x146')]=function(_0x3b008a,_0x995b39){return db[_0x53f1('0x49')][_0x53f1('0x33')]({'where':{'id':_0x3b008a[_0x53f1('0x53')]['id']}})[_0x53f1('0x14')](handleEntityNotFound(_0x995b39,null))[_0x53f1('0x14')](function(_0x1096b0){if(_0x1096b0){return _0x1096b0[_0x53f1('0x146')](_0x3b008a['query']['ids']);}})['then'](respondWithStatusCode(_0x995b39,null))[_0x53f1('0x1d')](handleError(_0x995b39,null));};exports['getVoicePrefixes']=function(_0x102002,_0x27c185){var _0x10f921={};var _0x2a95d2={};var _0x4fd2bb;var _0x4c35b7;return db[_0x53f1('0x49')][_0x53f1('0xca')]({'where':{'id':_0x102002['params']['id']}})['then'](handleEntityNotFound(_0x27c185,null))['then'](function(_0x4ac49c){if(_0x4ac49c){_0x4fd2bb=_0x4ac49c;_0x2a95d2[_0x53f1('0x54')]=_['keys'](db[_0x53f1('0x147')]['rawAttributes']);_0x2a95d2[_0x53f1('0x41')]=_[_0x53f1('0x56')](_0x102002[_0x53f1('0x41')]);_0x2a95d2['filters']=_['intersection'](_0x2a95d2['model'],_0x2a95d2['query']);_0x10f921['attributes']=_[_0x53f1('0x58')](_0x2a95d2[_0x53f1('0x54')],qs[_0x53f1('0xcc')](_0x102002['query'][_0x53f1('0xcc')]));_0x10f921[_0x53f1('0x47')]=_0x10f921[_0x53f1('0x47')][_0x53f1('0x4c')]?_0x10f921['attributes']:_0x2a95d2[_0x53f1('0x54')];_0x10f921['order']=qs[_0x53f1('0xce')](_0x102002[_0x53f1('0x41')]['sort']);_0x10f921[_0x53f1('0x40')]=qs[_0x53f1('0x57')](_[_0x53f1('0xcf')](_0x102002[_0x53f1('0x41')],_0x2a95d2[_0x53f1('0x57')]));if(_0x102002[_0x53f1('0x41')][_0x53f1('0x2e')]){_0x10f921[_0x53f1('0x40')]=_['merge'](_0x10f921['where'],{'$or':_[_0x53f1('0x30')](_0x10f921[_0x53f1('0x47')],function(_0x1cd209){var _0x385c29={};_0x385c29[_0x1cd209]={'$like':'%'+_0x102002['query'][_0x53f1('0x2e')]+'%'};return _0x385c29;})});}_0x10f921=_['merge']({},_0x10f921,_0x102002['options']);return _0x4fd2bb[_0x53f1('0x148')](_0x10f921);}})[_0x53f1('0x14')](function(_0x12695b){if(_0x12695b){_0x4c35b7=_0x12695b[_0x53f1('0x4c')];if(!_0x102002[_0x53f1('0x41')][_0x53f1('0xd1')]('nolimit')){_0x10f921[_0x53f1('0x23')]=qs[_0x53f1('0x23')](_0x102002[_0x53f1('0x41')]['limit']);_0x10f921[_0x53f1('0x24')]=qs[_0x53f1('0x24')](_0x102002[_0x53f1('0x41')]['offset']);}return _0x4fd2bb[_0x53f1('0x148')](_0x10f921);}})[_0x53f1('0x14')](function(_0x440599){if(_0x440599){return _0x440599?{'count':_0x4c35b7,'rows':_0x440599}:null;}})[_0x53f1('0x14')](respondWithResult(_0x27c185,null))['catch'](handleError(_0x27c185,null));};exports['getFaxAccounts']=function(_0x59a458,_0x442822){var _0x7959ee={};var _0x20862e={};var _0xfd9f06;var _0x20243b;return db[_0x53f1('0x49')][_0x53f1('0xca')]({'where':{'id':_0x59a458[_0x53f1('0x53')]['id']}})[_0x53f1('0x14')](handleEntityNotFound(_0x442822,null))[_0x53f1('0x14')](function(_0x1c706a){if(_0x1c706a){_0xfd9f06=_0x1c706a;_0x20862e[_0x53f1('0x54')]=_[_0x53f1('0x56')](db[_0x53f1('0x149')][_0x53f1('0x39')]);_0x20862e[_0x53f1('0x41')]=_[_0x53f1('0x56')](_0x59a458[_0x53f1('0x41')]);_0x20862e['filters']=_[_0x53f1('0x58')](_0x20862e['model'],_0x20862e[_0x53f1('0x41')]);_0x7959ee[_0x53f1('0x47')]=_[_0x53f1('0x58')](_0x20862e[_0x53f1('0x54')],qs[_0x53f1('0xcc')](_0x59a458[_0x53f1('0x41')][_0x53f1('0xcc')]));_0x7959ee[_0x53f1('0x47')]=_0x7959ee[_0x53f1('0x47')][_0x53f1('0x4c')]?_0x7959ee['attributes']:_0x20862e[_0x53f1('0x54')];_0x7959ee[_0x53f1('0xcd')]=qs[_0x53f1('0xce')](_0x59a458[_0x53f1('0x41')][_0x53f1('0xce')]);_0x7959ee[_0x53f1('0x40')]=qs[_0x53f1('0x57')](_[_0x53f1('0xcf')](_0x59a458[_0x53f1('0x41')],_0x20862e[_0x53f1('0x57')]));if(_0x59a458['query']['filter']){_0x7959ee['where']=_[_0x53f1('0x59')](_0x7959ee['where'],{'$or':_[_0x53f1('0x30')](_0x7959ee[_0x53f1('0x47')],function(_0x5d6f6b){var _0x3df317={};_0x3df317[_0x5d6f6b]={'$like':'%'+_0x59a458[_0x53f1('0x41')][_0x53f1('0x2e')]+'%'};return _0x3df317;})});}_0x7959ee=_[_0x53f1('0x59')]({},_0x7959ee,_0x59a458['options']);return _0xfd9f06[_0x53f1('0x14a')](_0x7959ee);}})[_0x53f1('0x14')](function(_0x266596){if(_0x266596){_0x20243b=_0x266596[_0x53f1('0x4c')];if(!_0x59a458['query'][_0x53f1('0xd1')](_0x53f1('0xd6'))){_0x7959ee[_0x53f1('0x23')]=qs[_0x53f1('0x23')](_0x59a458[_0x53f1('0x41')][_0x53f1('0x23')]);_0x7959ee['offset']=qs['offset'](_0x59a458[_0x53f1('0x41')][_0x53f1('0x24')]);}return _0xfd9f06['getFaxAccounts'](_0x7959ee);}})[_0x53f1('0x14')](function(_0xfe4649){if(_0xfe4649){return _0xfe4649?{'count':_0x20243b,'rows':_0xfe4649}:null;}})[_0x53f1('0x14')](respondWithResult(_0x442822,null))[_0x53f1('0x1d')](handleError(_0x442822,null));};exports[_0x53f1('0x14b')]=function(_0x578611,_0x29f887){return db['User'][_0x53f1('0x33')]({'where':{'id':_0x578611[_0x53f1('0x53')]['id']}})['then'](handleEntityNotFound(_0x29f887,null))['then'](function(_0x31862b){if(_0x31862b){return _0x31862b[_0x53f1('0x14b')](_0x578611[_0x53f1('0x5d')][_0x53f1('0x60')],_[_0x53f1('0x113')](_0x578611['body'],[_0x53f1('0x60'),'id'])||{});}})[_0x53f1('0x14')](respondWithResult(_0x29f887,null))[_0x53f1('0x1d')](handleError(_0x29f887,null));};exports[_0x53f1('0x14c')]=function(_0x57183e,_0x49865c){return db['User'][_0x53f1('0x33')]({'where':{'id':_0x57183e[_0x53f1('0x53')]['id']}})['then'](handleEntityNotFound(_0x49865c,null))['then'](function(_0x4847a6){if(_0x4847a6){return _0x4847a6['removeFaxAccounts'](_0x57183e[_0x53f1('0x41')][_0x53f1('0x60')]);}})[_0x53f1('0x14')](respondWithStatusCode(_0x49865c,null))[_0x53f1('0x1d')](handleError(_0x49865c,null));};exports['getMailAccounts']=function(_0x111e73,_0x2f9b96){var _0x20bb4b={};var _0x4e9a56={};var _0x105307;var _0x43b540;return db[_0x53f1('0x49')]['findOne']({'where':{'id':_0x111e73[_0x53f1('0x53')]['id']}})[_0x53f1('0x14')](handleEntityNotFound(_0x2f9b96,null))[_0x53f1('0x14')](function(_0x176d83){if(_0x176d83){_0x105307=_0x176d83;_0x4e9a56[_0x53f1('0x54')]=_['keys'](db[_0x53f1('0x14d')]['rawAttributes']);_0x4e9a56[_0x53f1('0x41')]=_[_0x53f1('0x56')](_0x111e73[_0x53f1('0x41')]);_0x4e9a56['filters']=_[_0x53f1('0x58')](_0x4e9a56[_0x53f1('0x54')],_0x4e9a56['query']);_0x20bb4b[_0x53f1('0x47')]=_['intersection'](_0x4e9a56[_0x53f1('0x54')],qs[_0x53f1('0xcc')](_0x111e73['query'][_0x53f1('0xcc')]));_0x20bb4b[_0x53f1('0x47')]=_0x20bb4b[_0x53f1('0x47')][_0x53f1('0x4c')]?_0x20bb4b[_0x53f1('0x47')]:_0x4e9a56[_0x53f1('0x54')];_0x20bb4b['order']=qs[_0x53f1('0xce')](_0x111e73[_0x53f1('0x41')][_0x53f1('0xce')]);_0x20bb4b['where']=qs[_0x53f1('0x57')](_[_0x53f1('0xcf')](_0x111e73[_0x53f1('0x41')],_0x4e9a56[_0x53f1('0x57')]));if(_0x111e73[_0x53f1('0x41')][_0x53f1('0x2e')]){_0x20bb4b[_0x53f1('0x40')]=_[_0x53f1('0x59')](_0x20bb4b[_0x53f1('0x40')],{'$or':_[_0x53f1('0x30')](_0x20bb4b['attributes'],function(_0x2509b6){var _0x30716a={};_0x30716a[_0x2509b6]={'$like':'%'+_0x111e73[_0x53f1('0x41')][_0x53f1('0x2e')]+'%'};return _0x30716a;})});}_0x20bb4b=_['merge']({},_0x20bb4b,_0x111e73[_0x53f1('0xd0')]);return _0x105307[_0x53f1('0x14e')](_0x20bb4b);}})[_0x53f1('0x14')](function(_0x4eb3b8){if(_0x4eb3b8){_0x43b540=_0x4eb3b8[_0x53f1('0x4c')];if(!_0x111e73[_0x53f1('0x41')][_0x53f1('0xd1')](_0x53f1('0xd6'))){_0x20bb4b[_0x53f1('0x23')]=qs[_0x53f1('0x23')](_0x111e73['query'][_0x53f1('0x23')]);_0x20bb4b[_0x53f1('0x24')]=qs[_0x53f1('0x24')](_0x111e73[_0x53f1('0x41')]['offset']);}return _0x105307[_0x53f1('0x14e')](_0x20bb4b);}})[_0x53f1('0x14')](function(_0x1b5dcd){if(_0x1b5dcd){return _0x1b5dcd?{'count':_0x43b540,'rows':_0x1b5dcd}:null;}})['then'](respondWithResult(_0x2f9b96,null))[_0x53f1('0x1d')](handleError(_0x2f9b96,null));};exports[_0x53f1('0x14f')]=function(_0x1e456f,_0x3f89fe){return db[_0x53f1('0x49')][_0x53f1('0x33')]({'where':{'id':_0x1e456f[_0x53f1('0x53')]['id']}})[_0x53f1('0x14')](handleEntityNotFound(_0x3f89fe,null))[_0x53f1('0x14')](function(_0x11a7a3){if(_0x11a7a3){return _0x11a7a3[_0x53f1('0x14f')](_0x1e456f[_0x53f1('0x5d')][_0x53f1('0x60')],_[_0x53f1('0x113')](_0x1e456f['body'],[_0x53f1('0x60'),'id'])||{});}})['then'](respondWithResult(_0x3f89fe,null))['catch'](handleError(_0x3f89fe,null));};exports[_0x53f1('0x150')]=function(_0x3afc2a,_0x49bb53){return db[_0x53f1('0x49')]['find']({'where':{'id':_0x3afc2a[_0x53f1('0x53')]['id']}})[_0x53f1('0x14')](handleEntityNotFound(_0x49bb53,null))[_0x53f1('0x14')](function(_0xcb80fa){if(_0xcb80fa){return _0xcb80fa[_0x53f1('0x150')](_0x3afc2a['query'][_0x53f1('0x60')]);}})[_0x53f1('0x14')](respondWithStatusCode(_0x49bb53,null))[_0x53f1('0x1d')](handleError(_0x49bb53,null));};exports[_0x53f1('0x151')]=function(_0x2e7a02,_0x7e35c8){var _0x42a2ce={};var _0x5f4043={};var _0x564ea8;var _0x52f4bc;return db[_0x53f1('0x49')]['findOne']({'where':{'id':_0x2e7a02[_0x53f1('0x53')]['id']}})[_0x53f1('0x14')](handleEntityNotFound(_0x7e35c8,null))[_0x53f1('0x14')](function(_0x2d01ba){if(_0x2d01ba){_0x564ea8=_0x2d01ba;_0x5f4043[_0x53f1('0x54')]=_['keys'](db[_0x53f1('0x152')][_0x53f1('0x39')]);_0x5f4043[_0x53f1('0x41')]=_[_0x53f1('0x56')](_0x2e7a02[_0x53f1('0x41')]);_0x5f4043['filters']=_[_0x53f1('0x58')](_0x5f4043[_0x53f1('0x54')],_0x5f4043[_0x53f1('0x41')]);_0x42a2ce[_0x53f1('0x47')]=_[_0x53f1('0x58')](_0x5f4043[_0x53f1('0x54')],qs[_0x53f1('0xcc')](_0x2e7a02[_0x53f1('0x41')]['fields']));_0x42a2ce[_0x53f1('0x47')]=_0x42a2ce[_0x53f1('0x47')][_0x53f1('0x4c')]?_0x42a2ce['attributes']:_0x5f4043[_0x53f1('0x54')];_0x42a2ce[_0x53f1('0xcd')]=qs[_0x53f1('0xce')](_0x2e7a02[_0x53f1('0x41')][_0x53f1('0xce')]);_0x42a2ce[_0x53f1('0x40')]=qs[_0x53f1('0x57')](_[_0x53f1('0xcf')](_0x2e7a02['query'],_0x5f4043['filters']));if(_0x2e7a02[_0x53f1('0x41')][_0x53f1('0x2e')]){_0x42a2ce[_0x53f1('0x40')]=_[_0x53f1('0x59')](_0x42a2ce[_0x53f1('0x40')],{'$or':_[_0x53f1('0x30')](_0x42a2ce[_0x53f1('0x47')],function(_0x43a342){var _0x45d51f={};_0x45d51f[_0x43a342]={'$like':'%'+_0x2e7a02['query'][_0x53f1('0x2e')]+'%'};return _0x45d51f;})});}_0x42a2ce=_[_0x53f1('0x59')]({},_0x42a2ce,_0x2e7a02['options']);return _0x564ea8[_0x53f1('0x151')](_0x42a2ce);}})[_0x53f1('0x14')](function(_0x578897){if(_0x578897){_0x52f4bc=_0x578897['length'];if(!_0x2e7a02['query'][_0x53f1('0xd1')](_0x53f1('0xd6'))){_0x42a2ce[_0x53f1('0x23')]=qs['limit'](_0x2e7a02[_0x53f1('0x41')][_0x53f1('0x23')]);_0x42a2ce[_0x53f1('0x24')]=qs['offset'](_0x2e7a02[_0x53f1('0x41')][_0x53f1('0x24')]);}return _0x564ea8[_0x53f1('0x151')](_0x42a2ce);}})[_0x53f1('0x14')](function(_0x573025){if(_0x573025){return _0x573025?{'count':_0x52f4bc,'rows':_0x573025}:null;}})[_0x53f1('0x14')](respondWithResult(_0x7e35c8,null))[_0x53f1('0x1d')](handleError(_0x7e35c8,null));};exports[_0x53f1('0x153')]=function(_0x65ba8a,_0xbe8bb7){return db['User']['find']({'where':{'id':_0x65ba8a[_0x53f1('0x53')]['id']}})[_0x53f1('0x14')](handleEntityNotFound(_0xbe8bb7,null))[_0x53f1('0x14')](function(_0x243fbf){if(_0x243fbf){return _0x243fbf[_0x53f1('0x153')](_0x65ba8a[_0x53f1('0x5d')]['ids'],_[_0x53f1('0x113')](_0x65ba8a[_0x53f1('0x5d')],[_0x53f1('0x60'),'id'])||{});}})[_0x53f1('0x14')](respondWithResult(_0xbe8bb7,null))['catch'](handleError(_0xbe8bb7,null));};exports[_0x53f1('0x154')]=function(_0x25e956,_0x424bfd){return db[_0x53f1('0x49')][_0x53f1('0x33')]({'where':{'id':_0x25e956[_0x53f1('0x53')]['id']}})[_0x53f1('0x14')](handleEntityNotFound(_0x424bfd,null))[_0x53f1('0x14')](function(_0x3a4f8f){if(_0x3a4f8f){return _0x3a4f8f['removeOpenchannelAccounts'](_0x25e956[_0x53f1('0x41')][_0x53f1('0x60')]);}})[_0x53f1('0x14')](respondWithStatusCode(_0x424bfd,null))[_0x53f1('0x1d')](handleError(_0x424bfd,null));};exports['getSmsAccounts']=function(_0x5eb51c,_0x1d395c){var _0x492e3a={};var _0x14e067={};var _0x247079;var _0x4679fc;return db['User'][_0x53f1('0xca')]({'where':{'id':_0x5eb51c[_0x53f1('0x53')]['id']}})['then'](handleEntityNotFound(_0x1d395c,null))['then'](function(_0x1cdf44){if(_0x1cdf44){_0x247079=_0x1cdf44;_0x14e067[_0x53f1('0x54')]=_[_0x53f1('0x56')](db[_0x53f1('0x155')][_0x53f1('0x39')]);_0x14e067[_0x53f1('0x41')]=_['keys'](_0x5eb51c[_0x53f1('0x41')]);_0x14e067[_0x53f1('0x57')]=_['intersection'](_0x14e067['model'],_0x14e067[_0x53f1('0x41')]);_0x492e3a['attributes']=_[_0x53f1('0x58')](_0x14e067[_0x53f1('0x54')],qs['fields'](_0x5eb51c[_0x53f1('0x41')][_0x53f1('0xcc')]));_0x492e3a[_0x53f1('0x47')]=_0x492e3a[_0x53f1('0x47')]['length']?_0x492e3a[_0x53f1('0x47')]:_0x14e067['model'];_0x492e3a[_0x53f1('0xcd')]=qs['sort'](_0x5eb51c[_0x53f1('0x41')]['sort']);_0x492e3a['where']=qs[_0x53f1('0x57')](_['pick'](_0x5eb51c[_0x53f1('0x41')],_0x14e067[_0x53f1('0x57')]));if(_0x5eb51c[_0x53f1('0x41')][_0x53f1('0x2e')]){_0x492e3a[_0x53f1('0x40')]=_[_0x53f1('0x59')](_0x492e3a[_0x53f1('0x40')],{'$or':_[_0x53f1('0x30')](_0x492e3a[_0x53f1('0x47')],function(_0x30ccf6){var _0x6e65e6={};_0x6e65e6[_0x30ccf6]={'$like':'%'+_0x5eb51c[_0x53f1('0x41')][_0x53f1('0x2e')]+'%'};return _0x6e65e6;})});}_0x492e3a=_[_0x53f1('0x59')]({},_0x492e3a,_0x5eb51c['options']);return _0x247079[_0x53f1('0x156')](_0x492e3a);}})['then'](function(_0x2ab416){if(_0x2ab416){_0x4679fc=_0x2ab416[_0x53f1('0x4c')];if(!_0x5eb51c[_0x53f1('0x41')]['hasOwnProperty'](_0x53f1('0xd6'))){_0x492e3a[_0x53f1('0x23')]=qs[_0x53f1('0x23')](_0x5eb51c[_0x53f1('0x41')][_0x53f1('0x23')]);_0x492e3a['offset']=qs[_0x53f1('0x24')](_0x5eb51c['query'][_0x53f1('0x24')]);}return _0x247079[_0x53f1('0x156')](_0x492e3a);}})[_0x53f1('0x14')](function(_0x419f04){if(_0x419f04){return _0x419f04?{'count':_0x4679fc,'rows':_0x419f04}:null;}})[_0x53f1('0x14')](respondWithResult(_0x1d395c,null))[_0x53f1('0x1d')](handleError(_0x1d395c,null));};exports[_0x53f1('0x157')]=function(_0x5881a6,_0x3a890d){return db[_0x53f1('0x49')]['find']({'where':{'id':_0x5881a6[_0x53f1('0x53')]['id']}})[_0x53f1('0x14')](handleEntityNotFound(_0x3a890d,null))[_0x53f1('0x14')](function(_0x575544){if(_0x575544){return _0x575544[_0x53f1('0x157')](_0x5881a6[_0x53f1('0x5d')]['ids'],_[_0x53f1('0x113')](_0x5881a6[_0x53f1('0x5d')],[_0x53f1('0x60'),'id'])||{});}})[_0x53f1('0x14')](respondWithResult(_0x3a890d,null))[_0x53f1('0x1d')](handleError(_0x3a890d,null));};exports[_0x53f1('0x158')]=function(_0x223192,_0x18c387){return db[_0x53f1('0x49')][_0x53f1('0x33')]({'where':{'id':_0x223192[_0x53f1('0x53')]['id']}})[_0x53f1('0x14')](handleEntityNotFound(_0x18c387,null))[_0x53f1('0x14')](function(_0xe926d8){if(_0xe926d8){return _0xe926d8[_0x53f1('0x158')](_0x223192['query']['ids']);}})[_0x53f1('0x14')](respondWithStatusCode(_0x18c387,null))[_0x53f1('0x1d')](handleError(_0x18c387,null));};exports[_0x53f1('0x159')]=function(_0x27d4f7,_0x2520f0){var _0x58b3fd={};var _0x3a78eb={};var _0x17c292;var _0x3465a6;return db[_0x53f1('0x49')][_0x53f1('0xca')]({'where':{'id':_0x27d4f7[_0x53f1('0x53')]['id']}})[_0x53f1('0x14')](handleEntityNotFound(_0x2520f0,null))[_0x53f1('0x14')](function(_0x3cbbdc){if(_0x3cbbdc){_0x17c292=_0x3cbbdc;_0x3a78eb[_0x53f1('0x54')]=_['keys'](db[_0x53f1('0x15a')][_0x53f1('0x39')]);_0x3a78eb[_0x53f1('0x41')]=_[_0x53f1('0x56')](_0x27d4f7[_0x53f1('0x41')]);_0x3a78eb[_0x53f1('0x57')]=_['intersection'](_0x3a78eb[_0x53f1('0x54')],_0x3a78eb[_0x53f1('0x41')]);_0x58b3fd[_0x53f1('0x47')]=_[_0x53f1('0x58')](_0x3a78eb[_0x53f1('0x54')],qs['fields'](_0x27d4f7['query']['fields']));_0x58b3fd[_0x53f1('0x47')]=_0x58b3fd['attributes'][_0x53f1('0x4c')]?_0x58b3fd[_0x53f1('0x47')]:_0x3a78eb[_0x53f1('0x54')];_0x58b3fd[_0x53f1('0xcd')]=qs[_0x53f1('0xce')](_0x27d4f7[_0x53f1('0x41')]['sort']);_0x58b3fd['where']=qs[_0x53f1('0x57')](_[_0x53f1('0xcf')](_0x27d4f7[_0x53f1('0x41')],_0x3a78eb['filters']));if(_0x27d4f7[_0x53f1('0x41')]['filter']){_0x58b3fd[_0x53f1('0x40')]=_[_0x53f1('0x59')](_0x58b3fd[_0x53f1('0x40')],{'$or':_[_0x53f1('0x30')](_0x58b3fd['attributes'],function(_0x3098e6){var _0x4f796c={};_0x4f796c[_0x3098e6]={'$like':'%'+_0x27d4f7[_0x53f1('0x41')][_0x53f1('0x2e')]+'%'};return _0x4f796c;})});}_0x58b3fd=_[_0x53f1('0x59')]({},_0x58b3fd,_0x27d4f7['options']);return _0x17c292['getChatWebsites'](_0x58b3fd);}})[_0x53f1('0x14')](function(_0x305237){if(_0x305237){_0x3465a6=_0x305237[_0x53f1('0x4c')];if(!_0x27d4f7[_0x53f1('0x41')]['hasOwnProperty'](_0x53f1('0xd6'))){_0x58b3fd['limit']=qs[_0x53f1('0x23')](_0x27d4f7[_0x53f1('0x41')]['limit']);_0x58b3fd['offset']=qs[_0x53f1('0x24')](_0x27d4f7[_0x53f1('0x41')]['offset']);}return _0x17c292[_0x53f1('0x159')](_0x58b3fd);}})[_0x53f1('0x14')](function(_0x4b9786){if(_0x4b9786){return _0x4b9786?{'count':_0x3465a6,'rows':_0x4b9786}:null;}})[_0x53f1('0x14')](respondWithResult(_0x2520f0,null))[_0x53f1('0x1d')](handleError(_0x2520f0,null));};exports['addChatWebsites']=function(_0x83eca7,_0x300519){return db[_0x53f1('0x49')][_0x53f1('0x33')]({'where':{'id':_0x83eca7[_0x53f1('0x53')]['id']}})[_0x53f1('0x14')](handleEntityNotFound(_0x300519,null))[_0x53f1('0x14')](function(_0x2e2b9c){if(_0x2e2b9c){return _0x2e2b9c[_0x53f1('0x15b')](_0x83eca7[_0x53f1('0x5d')][_0x53f1('0x60')],_[_0x53f1('0x113')](_0x83eca7[_0x53f1('0x5d')],[_0x53f1('0x60'),'id'])||{});}})['then'](respondWithResult(_0x300519,null))[_0x53f1('0x1d')](handleError(_0x300519,null));};exports['removeChatWebsites']=function(_0x367b44,_0x8a3d6d){return db[_0x53f1('0x49')]['find']({'where':{'id':_0x367b44[_0x53f1('0x53')]['id']}})[_0x53f1('0x14')](handleEntityNotFound(_0x8a3d6d,null))[_0x53f1('0x14')](function(_0x158517){if(_0x158517){return _0x158517[_0x53f1('0x15c')](_0x367b44[_0x53f1('0x41')][_0x53f1('0x60')]);}})['then'](respondWithStatusCode(_0x8a3d6d,null))[_0x53f1('0x1d')](handleError(_0x8a3d6d,null));};exports[_0x53f1('0x15d')]=function(_0x11c86c,_0x135f06){var _0x5ccf17={};var _0x6a7efa={};var _0x14ee87;var _0x11bd8e;return db[_0x53f1('0x49')][_0x53f1('0xca')]({'where':{'id':_0x11c86c[_0x53f1('0x53')]['id']}})['then'](handleEntityNotFound(_0x135f06,null))[_0x53f1('0x14')](function(_0x523e30){if(_0x523e30){_0x14ee87=_0x523e30;_0x6a7efa['model']=_[_0x53f1('0x56')](db[_0x53f1('0x15e')][_0x53f1('0x39')]);_0x6a7efa[_0x53f1('0x41')]=_['keys'](_0x11c86c[_0x53f1('0x41')]);_0x6a7efa['filters']=_[_0x53f1('0x58')](_0x6a7efa[_0x53f1('0x54')],_0x6a7efa['query']);_0x5ccf17[_0x53f1('0x47')]=_['intersection'](_0x6a7efa[_0x53f1('0x54')],qs['fields'](_0x11c86c[_0x53f1('0x41')][_0x53f1('0xcc')]));_0x5ccf17[_0x53f1('0x47')]=_0x5ccf17['attributes'][_0x53f1('0x4c')]?_0x5ccf17['attributes']:_0x6a7efa['model'];_0x5ccf17[_0x53f1('0xcd')]=qs[_0x53f1('0xce')](_0x11c86c[_0x53f1('0x41')][_0x53f1('0xce')]);_0x5ccf17[_0x53f1('0x40')]=qs[_0x53f1('0x57')](_[_0x53f1('0xcf')](_0x11c86c['query'],_0x6a7efa['filters']));if(_0x11c86c[_0x53f1('0x41')][_0x53f1('0x2e')]){_0x5ccf17[_0x53f1('0x40')]=_[_0x53f1('0x59')](_0x5ccf17['where'],{'$or':_[_0x53f1('0x30')](_0x5ccf17[_0x53f1('0x47')],function(_0x22edd6){var _0x3bb7f3={};_0x3bb7f3[_0x22edd6]={'$like':'%'+_0x11c86c['query'][_0x53f1('0x2e')]+'%'};return _0x3bb7f3;})});}_0x5ccf17=_[_0x53f1('0x59')]({},_0x5ccf17,_0x11c86c[_0x53f1('0xd0')]);return _0x14ee87[_0x53f1('0x15d')](_0x5ccf17);}})[_0x53f1('0x14')](function(_0x35750d){if(_0x35750d){_0x11bd8e=_0x35750d[_0x53f1('0x4c')];if(!_0x11c86c['query'][_0x53f1('0xd1')](_0x53f1('0xd6'))){_0x5ccf17[_0x53f1('0x23')]=qs[_0x53f1('0x23')](_0x11c86c[_0x53f1('0x41')][_0x53f1('0x23')]);_0x5ccf17[_0x53f1('0x24')]=qs[_0x53f1('0x24')](_0x11c86c[_0x53f1('0x41')]['offset']);}return _0x14ee87['getWhatsappAccounts'](_0x5ccf17);}})['then'](function(_0x6dd948){if(_0x6dd948){return _0x6dd948?{'count':_0x11bd8e,'rows':_0x6dd948}:null;}})[_0x53f1('0x14')](respondWithResult(_0x135f06,null))[_0x53f1('0x1d')](handleError(_0x135f06,null));};exports[_0x53f1('0x15f')]=function(_0x1d8d02,_0x5b4b89){return db[_0x53f1('0x49')][_0x53f1('0x33')]({'where':{'id':_0x1d8d02[_0x53f1('0x53')]['id']}})[_0x53f1('0x14')](handleEntityNotFound(_0x5b4b89,null))[_0x53f1('0x14')](function(_0x3b9cf9){if(_0x3b9cf9){return _0x3b9cf9[_0x53f1('0x15f')](_0x1d8d02['body'][_0x53f1('0x60')],_[_0x53f1('0x113')](_0x1d8d02[_0x53f1('0x5d')],[_0x53f1('0x60'),'id'])||{});}})[_0x53f1('0x14')](respondWithResult(_0x5b4b89,null))['catch'](handleError(_0x5b4b89,null));};exports[_0x53f1('0x160')]=function(_0xe0855b,_0x381e2f){return db['User'][_0x53f1('0x33')]({'where':{'id':_0xe0855b[_0x53f1('0x53')]['id']}})[_0x53f1('0x14')](handleEntityNotFound(_0x381e2f,null))['then'](function(_0x5223c5){if(_0x5223c5){return _0x5223c5[_0x53f1('0x160')](_0xe0855b[_0x53f1('0x41')][_0x53f1('0x60')]);}})[_0x53f1('0x14')](respondWithStatusCode(_0x381e2f,null))[_0x53f1('0x1d')](handleError(_0x381e2f,null));};exports[_0x53f1('0x161')]=function(_0x3fedc6,_0xde1c3b){var _0x2f2ca5={};var _0x3b831b={};var _0x23cdfb;var _0x56c298;return db[_0x53f1('0x49')]['findOne']({'where':{'id':_0x3fedc6[_0x53f1('0x53')]['id']}})[_0x53f1('0x14')](handleEntityNotFound(_0xde1c3b,null))[_0x53f1('0x14')](function(_0x2ef4b0){if(_0x2ef4b0){_0x23cdfb=_0x2ef4b0;_0x3b831b[_0x53f1('0x54')]=_[_0x53f1('0x56')](db[_0x53f1('0x162')]['rawAttributes']);_0x3b831b[_0x53f1('0x41')]=_[_0x53f1('0x56')](_0x3fedc6[_0x53f1('0x41')]);_0x3b831b['filters']=_[_0x53f1('0x58')](_0x3b831b[_0x53f1('0x54')],_0x3b831b['query']);_0x2f2ca5[_0x53f1('0x47')]=_[_0x53f1('0x58')](_0x3b831b[_0x53f1('0x54')],qs[_0x53f1('0xcc')](_0x3fedc6[_0x53f1('0x41')][_0x53f1('0xcc')]));_0x2f2ca5[_0x53f1('0x47')]=_0x2f2ca5['attributes'][_0x53f1('0x4c')]?_0x2f2ca5[_0x53f1('0x47')]:_0x3b831b['model'];_0x2f2ca5[_0x53f1('0xcd')]=qs[_0x53f1('0xce')](_0x3fedc6[_0x53f1('0x41')]['sort']);_0x2f2ca5['where']=qs[_0x53f1('0x57')](_[_0x53f1('0xcf')](_0x3fedc6['query'],_0x3b831b[_0x53f1('0x57')]));if(_0x3fedc6[_0x53f1('0x41')][_0x53f1('0x2e')]){_0x2f2ca5[_0x53f1('0x40')]=_[_0x53f1('0x59')](_0x2f2ca5['where'],{'$or':_['map'](_0x2f2ca5['attributes'],function(_0x5bc2c5){var _0xb88556={};_0xb88556[_0x5bc2c5]={'$like':'%'+_0x3fedc6[_0x53f1('0x41')]['filter']+'%'};return _0xb88556;})});}_0x2f2ca5=_[_0x53f1('0x59')]({},_0x2f2ca5,_0x3fedc6[_0x53f1('0xd0')]);return _0x23cdfb['getSquareProjects'](_0x2f2ca5);}})[_0x53f1('0x14')](function(_0x49b3e7){if(_0x49b3e7){_0x56c298=_0x49b3e7[_0x53f1('0x4c')];if(!_0x3fedc6[_0x53f1('0x41')][_0x53f1('0xd1')](_0x53f1('0xd6'))){_0x2f2ca5[_0x53f1('0x23')]=qs[_0x53f1('0x23')](_0x3fedc6[_0x53f1('0x41')][_0x53f1('0x23')]);_0x2f2ca5[_0x53f1('0x24')]=qs[_0x53f1('0x24')](_0x3fedc6[_0x53f1('0x41')][_0x53f1('0x24')]);}return _0x23cdfb[_0x53f1('0x161')](_0x2f2ca5);}})[_0x53f1('0x14')](function(_0x2b47b3){if(_0x2b47b3){return _0x2b47b3?{'count':_0x56c298,'rows':_0x2b47b3}:null;}})[_0x53f1('0x14')](respondWithResult(_0xde1c3b,null))[_0x53f1('0x1d')](handleError(_0xde1c3b,null));};exports[_0x53f1('0x163')]=function(_0x5b09d5,_0x23f79e){return db[_0x53f1('0x49')]['find']({'where':{'id':_0x5b09d5['params']['id']}})[_0x53f1('0x14')](handleEntityNotFound(_0x23f79e,null))[_0x53f1('0x14')](function(_0x55152f){if(_0x55152f){return _0x55152f[_0x53f1('0x163')](_0x5b09d5['body'][_0x53f1('0x60')],_[_0x53f1('0x113')](_0x5b09d5[_0x53f1('0x5d')],[_0x53f1('0x60'),'id'])||{});}})[_0x53f1('0x14')](respondWithResult(_0x23f79e,null))['catch'](handleError(_0x23f79e,null));};exports[_0x53f1('0x164')]=function(_0x456edb,_0x570407){return db[_0x53f1('0x49')][_0x53f1('0x33')]({'where':{'id':_0x456edb['params']['id']}})[_0x53f1('0x14')](handleEntityNotFound(_0x570407,null))['then'](function(_0x28d596){if(_0x28d596){return _0x28d596[_0x53f1('0x164')](_0x456edb[_0x53f1('0x41')][_0x53f1('0x60')]);}})[_0x53f1('0x14')](respondWithStatusCode(_0x570407,null))['catch'](handleError(_0x570407,null));};exports[_0x53f1('0x165')]=function(_0x264344,_0x3a05a5){var _0x9e4dd3={},_0x3a7eea={},_0x1f5a37={'count':0x0,'rows':[]};var _0x419084=db[_0x53f1('0x166')][_0x53f1('0x39')];_0x3a7eea['model']=_[_0x53f1('0x56')](_0x419084);_0x3a7eea[_0x53f1('0x41')]=_['keys'](_0x264344[_0x53f1('0x41')]);_0x3a7eea[_0x53f1('0x57')]=_[_0x53f1('0x58')](_0x3a7eea[_0x53f1('0x54')],_0x3a7eea['query']);_0x3a7eea[_0x53f1('0x57')]=_[_0x53f1('0x167')](_0x3a7eea[_0x53f1('0x57')],[_0x53f1('0x168'),'$or',_0x53f1('0x169'),_0x53f1('0x16a'),_0x53f1('0x16b'),_0x53f1('0x16c'),_0x53f1('0x16d'),'$eq',_0x53f1('0x16e'),_0x53f1('0x16f'),_0x53f1('0x170'),_0x53f1('0x171'),_0x53f1('0x172'),_0x53f1('0x173'),'$notLike',_0x53f1('0x174'),'$notILike',_0x53f1('0x173'),'$overlap','$contains',_0x53f1('0x175'),_0x53f1('0x176')]);_0x9e4dd3[_0x53f1('0x47')]=_['intersection'](_0x3a7eea[_0x53f1('0x54')],qs[_0x53f1('0xcc')](_0x264344[_0x53f1('0x41')][_0x53f1('0xcc')]));_0x9e4dd3[_0x53f1('0x47')]=_0x9e4dd3[_0x53f1('0x47')][_0x53f1('0x4c')]?_0x9e4dd3[_0x53f1('0x47')]:_0x3a7eea[_0x53f1('0x54')];if(!_0x264344[_0x53f1('0x41')][_0x53f1('0xd1')](_0x53f1('0xd6'))){_0x9e4dd3[_0x53f1('0x23')]=qs[_0x53f1('0x23')](_0x264344[_0x53f1('0x41')][_0x53f1('0x23')]);_0x9e4dd3[_0x53f1('0x24')]=qs[_0x53f1('0x24')](_0x264344['query'][_0x53f1('0x24')]);}_0x9e4dd3['order']=qs[_0x53f1('0xce')](_0x264344[_0x53f1('0x41')]['sort']);_0x9e4dd3[_0x53f1('0x40')]=qs[_0x53f1('0x57')](_['pick'](_0x264344[_0x53f1('0x41')],_0x3a7eea[_0x53f1('0x57')]));if(_0x264344[_0x53f1('0x41')][_0x53f1('0x2e')]){_0x9e4dd3[_0x53f1('0x40')]=_['merge'](_0x9e4dd3[_0x53f1('0x40')],{'$or':_['map'](_0x9e4dd3[_0x53f1('0x47')],function(_0x544690){var _0x1efc30={};_0x1efc30[_0x544690]={'$like':'%'+_0x264344[_0x53f1('0x41')][_0x53f1('0x2e')]+'%'};return _0x1efc30;})});}_0x9e4dd3[_0x53f1('0x40')]={'$and':[_0x9e4dd3['where'],{'$or':[{'UserId':_0x264344['params']['id']},{'OwnerId':_0x264344[_0x53f1('0x53')]['id']}]}]};_0x9e4dd3=_[_0x53f1('0x59')]({},_0x9e4dd3,_0x264344[_0x53f1('0xd0')]);var _0x29590a={'where':_0x9e4dd3[_0x53f1('0x40')]};return db['CmHopper']['count'](_0x29590a)[_0x53f1('0x14')](function(_0x206a5d){_0x1f5a37[_0x53f1('0x25')]=_0x206a5d;if(_0x264344['query'][_0x53f1('0x42')]){_0x9e4dd3['include']=[{'attributes':['id','firstName','lastName',_0x53f1('0xec')],'model':db[_0x53f1('0xcb')],'as':_0x53f1('0x177')},{'attributes':['id',_0x53f1('0x35'),_0x53f1('0x178')],'model':db[_0x53f1('0xaa')],'as':_0x53f1('0xd8')}];}return db[_0x53f1('0x166')][_0x53f1('0x4a')](_0x9e4dd3);})[_0x53f1('0x14')](function(_0x5baa5b){_0x1f5a37[_0x53f1('0x4b')]=_0x5baa5b;return _0x1f5a37;})[_0x53f1('0x14')](respondWithFilteredResult(_0x3a05a5,_0x9e4dd3))[_0x53f1('0x1d')](handleError(_0x3a05a5,null));};exports[_0x53f1('0x179')]=function(_0x5ee03c,_0x5e53ec){if(!_['isNil'](_0x5ee03c[_0x53f1('0x7b')]['id'])&&(_0x5ee03c[_0x53f1('0x7b')][_0x53f1('0x34')]=='admin'||_0x5ee03c['user'][_0x53f1('0x34')]==_0x53f1('0x7b'))){return db[_0x53f1('0x49')]['findOne']({'where':{'id':_0x5ee03c[_0x53f1('0x53')]['id']},'raw':!![]})[_0x53f1('0x14')](function(_0x1e8182){return authService['retrieveApiKey'](_0x1e8182);})[_0x53f1('0x14')](function(_0x5c917f){if(_0x5c917f){return _0x5e53ec[_0x53f1('0x1f')](0xc8)['json']({'api_key':_0x5c917f[_0x53f1('0x17a')]});}else{return _0x5e53ec[_0x53f1('0x1f')](0xcc)[_0x53f1('0x21')]({'message':_0x53f1('0x17b')});}})[_0x53f1('0x1d')](handleError(_0x5e53ec,0x193));}else{return _0x5e53ec[_0x53f1('0x1f')](0x191)[_0x53f1('0x21')]({'message':_0x53f1('0x17c')});}};exports['createApiKey']=function(_0x404177,_0x59ebee){if(!_[_0x53f1('0x67')](_0x404177['user']['id'])&&(_0x404177[_0x53f1('0x7b')][_0x53f1('0x34')]==_0x53f1('0x7c')||_0x404177[_0x53f1('0x7b')][_0x53f1('0x34')]==_0x53f1('0x7b'))){return db[_0x53f1('0x49')][_0x53f1('0x33')]({'where':{'id':_0x404177['params']['id']}})[_0x53f1('0x14')](function(_0x3625cf){return authService[_0x53f1('0x17d')](_0x3625cf);})['then'](function(_0x195893){return db[_0x53f1('0x49')][_0x53f1('0x28')]({'apiKeyIat':_0x195893[_0x53f1('0x17e')],'apiKeyNonce':_0x195893[_0x53f1('0x17f')]},{'where':{'id':_0x404177[_0x53f1('0x53')]['id']}})[_0x53f1('0x14')](function(){return _0x59ebee['status'](0xc8)[_0x53f1('0x21')]({'api_key':_0x195893[_0x53f1('0x17a')]});});})[_0x53f1('0x1d')](handleError(_0x59ebee,0x193));}else{return _0x59ebee[_0x53f1('0x1f')](0x191)['json']({'message':_0x53f1('0x17c')});}};exports[_0x53f1('0x180')]=function(_0x586f9b,_0x1f73ba){if(!_[_0x53f1('0x67')](_0x586f9b[_0x53f1('0x7b')]['id'])&&(_0x586f9b['user']['role']==_0x53f1('0x7c')||_0x586f9b[_0x53f1('0x7b')]['role']=='user')){return db['User']['find']({'where':{'id':_0x586f9b['params']['id']}})['then'](handleEntityNotFound(_0x1f73ba,null))[_0x53f1('0x14')](function(_0x1fcbbd){if(_0x1fcbbd&&_0x1fcbbd['apiKeyNonce']&&_0x1fcbbd[_0x53f1('0x181')])return _0x1fcbbd;else throw{'message':'API\x20key\x20not\x20available'};})[_0x53f1('0x14')](function(){return db['User'][_0x53f1('0x28')]({'apiKeyNonce':null,'apiKeyIat':null},{'where':{'id':_0x586f9b[_0x53f1('0x53')]['id']}});})[_0x53f1('0x14')](respondWithStatusCode(_0x1f73ba,0xc8))[_0x53f1('0x1d')](handleError(_0x1f73ba,0x193));}else{return _0x1f73ba[_0x53f1('0x1f')](0x191)['json']({'message':'You\x20don\x27t\x20have\x20sufficient\x20privileges\x20to\x20access\x20this\x20resource.'});}};exports[_0x53f1('0x182')]=function(_0x1ef26e,_0x3003e7){var _0x1c602c=_0x1ef26e[_0x53f1('0x7b')][_0x53f1('0x2a')]({'plain':!![]});if(!_0x1c602c){return _0x3003e7[_0x53f1('0x1f')](0x191)[_0x53f1('0x37')](_0x53f1('0x183'));}else{Promise[_0x53f1('0x102')]()[_0x53f1('0x14')](function(){if(_0x1ef26e['query'][_0x53f1('0x44')]!=='true')return;return _0x1ef26e[_0x53f1('0x7b')]['getUserSetting']();})[_0x53f1('0x14')](function(_0x56144f){if(!_0x56144f)return;return _0x56144f[_0x53f1('0x2a')]({'plain':!![]});})[_0x53f1('0x14')](function(_0x168b10){_0x1c602c[_0x53f1('0x44')]=_0x168b10;return _0x3003e7['status'](0xc8)[_0x53f1('0x21')](_0x1c602c);});}};exports['getPresence']=function(_0x327be7,_0x170a08){var _0xfd2985={'offset':0x0},_0x4de22d={'count':0x0,'rows':[]};Promise[_0x53f1('0x102')]()['then'](function(){if(!_0x327be7[_0x53f1('0x41')][_0x53f1('0x2e')]&&!_0x327be7[_0x53f1('0x41')]['teams']&&!_0x327be7[_0x53f1('0x41')][_0x53f1('0x184')])return[];return Promise[_0x53f1('0x102')]()[_0x53f1('0x14')](function(){var _0x309bd4=[];if(!_[_0x53f1('0x8c')](_0x327be7[_0x53f1('0x41')][_0x53f1('0x185')])){_0x309bd4[_0x53f1('0x48')](db[_0x53f1('0x114')]['findAll']({'attributes':['id','name'],'where':{'id':_0x327be7[_0x53f1('0x41')][_0x53f1('0x185')]}}));}if(!_[_0x53f1('0x8c')](_0x327be7['query'][_0x53f1('0x184')])){_0x309bd4[_0x53f1('0x48')](db['VoiceQueue'][_0x53f1('0x4a')]({'attributes':['id',_0x53f1('0x35')],'type':_0x53f1('0x186'),'where':{'id':_0x327be7[_0x53f1('0x41')]['queues']}}));}return Promise[_0x53f1('0x51')](_0x309bd4);})['then'](function(_0x2d9e68){var _0x13e03c=_[_0x53f1('0x11f')](_0x2d9e68)[_0x53f1('0x30')](function(_0x5e345d){return _0x5e345d[_0x53f1('0x12c')]({'attributes':['id',_0x53f1('0x35'),_0x53f1('0x61'),_0x53f1('0x9e')],'raw':!![]});});return Promise[_0x53f1('0x51')](_0x13e03c);})['then'](function(_0x17f5f0){var _0x48caec=_[_0x53f1('0x11f')](_0x17f5f0);if(!_0x327be7[_0x53f1('0x41')][_0x53f1('0x2e')])return _0x48caec;if(_[_0x53f1('0x8c')](_0x48caec)){return db['User'][_0x53f1('0x4a')]({'attributes':['id',_0x53f1('0x35'),'internal','online'],'where':{'role':_0x53f1('0x2b'),'$or':[db['sequelize'][_0x53f1('0x40')](db[_0x53f1('0x68')]['fn'](_0x53f1('0x187'),db[_0x53f1('0x68')][_0x53f1('0x188')](_0x53f1('0x35'))),{'$like':'%'+_0x327be7['query'][_0x53f1('0x2e')]['toLowerCase']()+'%'}),{'internal':{'$like':'%'+_0x327be7[_0x53f1('0x41')][_0x53f1('0x2e')]+'%'}}]},'raw':!![]});}else{return _(_0x48caec)['flatten']()['filter'](function(_0xe0bb78){return _0xe0bb78[_0x53f1('0x35')]['toLowerCase']()[_0x53f1('0x32')](_0x327be7[_0x53f1('0x41')][_0x53f1('0x2e')][_0x53f1('0xa5')]())||_0xe0bb78[_0x53f1('0x61')][_0x53f1('0x189')]()['includes'](_0x327be7['query'][_0x53f1('0x2e')]);})[_0x53f1('0x31')]();}})[_0x53f1('0x14')](function(_0x33e440){var _0x2086c8='name';var _0x3eaafe=_0x53f1('0x18a');if(_0x327be7[_0x53f1('0x41')][_0x53f1('0xce')]){_0x3eaafe=_0x327be7[_0x53f1('0x41')][_0x53f1('0xce')][0x0]==='-'?_0x53f1('0x18b'):_0x53f1('0x18a');_0x2086c8=_0x3eaafe===_0x53f1('0x18a')?_0x327be7[_0x53f1('0x41')][_0x53f1('0xce')]:_0x327be7[_0x53f1('0x41')]['sort'][_0x53f1('0x18c')](0x1);}return _(_0x33e440)[_0x53f1('0x18d')]('id')['orderBy']([function(_0x9d420d){return _0x2086c8==='name'?_0x9d420d[_0x2086c8][_0x53f1('0xa5')]():_0x9d420d[_0x2086c8];}],[_0x3eaafe])[_0x53f1('0x30')](function(_0x43f26c){return _['pick'](_0x43f26c,['id','name',_0x53f1('0x61'),'online']);})[_0x53f1('0x31')]();})[_0x53f1('0x14')](function(_0x4eb44b){return client[_0x53f1('0x13')](_0x53f1('0x82'),_0x327be7)['then'](function(_0x487c61){if(_0x487c61[_0x53f1('0x19')])throw new Error(_0x53f1('0x18e'));var _0x13a88a=_0x487c61[_0x53f1('0x1c')];var _0x187245=jayson[_0x53f1('0x11')]['http']({'port':0x232c});return _0x187245[_0x53f1('0x13')](_0x53f1('0x82'),_0x327be7)[_0x53f1('0x14')](function(_0x1f9667){if(_0x1f9667[_0x53f1('0x19')])throw new Error('Unable\x20to\x20retrieve\x20RPC\x20agents\x20(Routing)');var _0x167195=_0x1f9667[_0x53f1('0x1c')];return _['merge']({},_0x167195,_0x13a88a);});})[_0x53f1('0x14')](function(_0x1bbc50){return _[_0x53f1('0x30')](_0x4eb44b,function(_0x57e0c2){var _0x293333=_['find'](_0x1bbc50[_0x53f1('0x4b')],['id',_0x57e0c2['id']]);if(!_0x293333||!_0x57e0c2[_0x53f1('0x9e')]){_0x57e0c2['status']='offline';}else if(_0x293333[_0x53f1('0x9f')]){_0x57e0c2[_0x53f1('0x1f')]=_0x53f1('0x103');}else{_0x57e0c2[_0x53f1('0x1f')]=_[_0x53f1('0x32')]([_0x53f1('0x18f'),_0x53f1('0x190'),_0x53f1('0x191'),_0x53f1('0x192'),null,undefined],_0x293333[_0x53f1('0x193')])?_0x53f1('0x9e'):'busy';}return _0x57e0c2;});});});})['then'](function(_0x3c866d){if(!_0x327be7[_0x53f1('0x41')][_0x53f1('0xd1')](_0x53f1('0xd6'))){_0xfd2985[_0x53f1('0x23')]=qs[_0x53f1('0x23')](_0x327be7[_0x53f1('0x41')][_0x53f1('0x23')]||0xa);_0xfd2985[_0x53f1('0x24')]=qs[_0x53f1('0x24')](_0x327be7['query'][_0x53f1('0x24')]);}_0x4de22d[_0x53f1('0x25')]=_0x3c866d[_0x53f1('0x4c')];_0x4de22d[_0x53f1('0x4b')]=_0xfd2985['limit']?_0x3c866d['slice'](_0xfd2985[_0x53f1('0x24')],_0xfd2985[_0x53f1('0x24')]+_0xfd2985[_0x53f1('0x23')]):_0x3c866d;return _0x4de22d;})[_0x53f1('0x14')](respondWithFilteredResult(_0x170a08,_0xfd2985))['catch'](handleError(_0x170a08,null));};function get_open_tabs(_0xb36767,_0x5a0796){var _0x2caadb=_0xb36767['charAt'](0x0)[_0x53f1('0x194')]()+_0xb36767[_0x53f1('0x195')](0x1);var _0x3cb78b={'type':db[_0x53f1('0x91')]['QueryTypes'][_0x53f1('0x196')],'raw':!![]};return new BPromise(function(_0x31e252,_0x27b80d){var _0xbb14a8=squel[_0x53f1('0x197')]()[_0x53f1('0x198')]('ui.'+_0x2caadb+'InteractionId','id')['field'](_0x53f1('0x199'))['from']('user_has_'+_0xb36767+_0x53f1('0x19a'),'ui')[_0x53f1('0x40')](_0x53f1('0x19b'),_0x5a0796['id']);return db['sequelize'][_0x53f1('0x41')](_0xbb14a8[_0x53f1('0x189')](),_0x3cb78b)[_0x53f1('0x14')](function(_0x4c37db){_0x5a0796[_0x2caadb+_0x53f1('0x19c')]=_0x4c37db;_0x31e252(_0x4c37db);})[_0x53f1('0x1d')](function(_0x589138){_0x27b80d(_0x589138);});});}