Built motion from commit f94df7f0.|2.5.48
[motion2.git] / server / api / user / user.controller.js
index 0cce2c5..e23a981 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xa0c7=['client','Unable\x20to\x20retrieve\x20RPC\x20agents\x20(Routing)','offline','pause','ringing','voiceStatus','busy','toUpperCase','select','ui.','InteractionId','ui.createdAt','user_has_','ui.UserId\x20=\x20?','moment','bluebird','util','path','lodash','squel','jayson/promise','../../components/auth/service','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','./user.socket','register','redis','defaults','localhost','http','request','then','User,\x20%s,\x20%s','request\x20sent','debug','User,\x20%s,\x20%s,\x20%s','error','code','message','info','result','catch','status','json','offset','undefined','limit','count','set','Content-Range','update','destroy','get','role','admin','Users','user','Agents','agent','Telephones','telephone','map','value','includes','find','name','UserProfileResource','end','sendStatus','stack','send','index','rawAttributes','fieldName','type','key','password','salt','getOptions','where','User','query','includeAll','include','userSetting','true','UserSetting','attributes','push','rows','length','chat','dataValues','sms','fax','mail','whatsapp','all','show','model','differenceBy','keys','filters','intersection','fields','options','openTabs','openchannel','body','params','describe','addContacts','ids','omit','internal','Setting','findById','max','isNil','min_internal','sequelize','QueryTypes','SELECT','from','mailbox','VoiceMail','fullname','email','permissions','101','102','113','110','104','105','108','109','100','111','115','create','Unauthorized','Unauthorized.\x20You\x20must\x20be\x20an\x20administrator\x20in\x20order\x20to\x20create\x20another\x20administrator','checkUserLimits','settingsEnabled','userProfileId','UserProfileSection','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','Unauthorized.\x20You\x20must\x20be\x20an\x20administrator\x20in\x20order\x20to\x20create\x20an\x20user','Unauthorized.\x20You\x20must\x20be\x20an\x20administrator\x20in\x20order\x20to\x20create\x20an\x20administrator','each','findAll','isEmpty','some','compact','newPassword','authenticate','oldPassword','Sequelize','ValidationError','Wrong\x20credentials','New\x20password\x20must\x20be\x20different\x20from\x20old\x20password','Invalid\x20body\x20format.\x20Use\x20newPassword','findOne','securePassword','enforcePasswordHistory','passwordHistoryLimit','validatePasswordPattern','previousPasswords','validatePasswordHistory','updatePasswordsHistory','online','loginInPause','voicePause','interface','Unknown\x20channel','toLowerCase','Queues','penalty','capitalize','QueueId','emit','Queue:save','voice','VoiceQueue','format','UserVoiceQueueRt','upsert','removeQueues','channel','isValidChannel','remove','isArray','Queue:remove','addAvatar','userpic','file','filename','getAvatar','join','root','server/files/images/logos/default_profile.png','existsSync','server/files/images/','download','getOpenTabs','CHAT','createdAt','FaxOpenTabs','FAX','MailOpenTabs','MAIL','SmsOpenTabs','SMS','WhatsappOpenTabs','WHATSAPP','concat','getContacts','CmContact','sort','pick','filter','merge','hasOwnProperty','CmList','Tag','Tags','tag','nolimit','getQueues','Queue','Unknown\x20role','getVoiceQueuesRt','order','getGroups','ChatGroup','getRecordings','UserId','VoiceRecording','ScreenRecording','getChatInteractions','getOpenchannelInteractions','getMailInteractions','MailInteraction','getSmsInteractions','SmsInteraction','getFaxInteractions','FaxInteraction','getWhatsappInteractions','WhatsappInteraction','phone','LOCAL/%s@from-sip/n','SIP/%s','intrf','user:%s','x-forwarded-for','remoteAddress','socket','connection','User\x20not\x20found\x20or\x20not\x20allowed\x20to\x20perform\x20login\x20method','MemberReport','forEach','YYYY-MM-DD\x20HH:mm:ss','getChannels','device','PAUSE','LOGININPAUSE','bulkCreate','isMiddleware','logout','QueuePause','updateAttributes','DEFAULT\x20PAUSE','unpause','chatPause','faxPause','openchannelPause','smsPause','whatsapppause','pauseType','lastPauseAt','manual','%s%s','Pause','Team','getTeams','addTeams','getVoiceQueues','getChatQueues','Chat','setDataValue','Mail','getSmsQueues','getFaxQueues','Fax','getOpenchannelQueues','Openchannel','flatten','transaction','addAgent','Voice','getDataValue','TeamVoicePrefix','UserVoicePrefix','VoicePrefixId','removeTeams','getMailQueues','Sms','getWhatsappQueues','removeAgent','getLists','getAgents','You\x20can\x27t\x20delete\x20yourself','addChatInteractions','spread','user_has_chat_interactions:save','removeChatInteractions','user_has_chat_interactions:remove','addMailInteractions','user_has_mail_interactions:save','removeMailInteractions','user_has_mail_interactions:remove','addFaxInteractions','user_has_fax_interactions:save','removeFaxInteractions','user_has_fax_interactions:remove','addSmsInteractions','user_has_sms_interactions:save','removeSmsInteractions','user_has_sms_interactions:remove','addOpenchannelInteractions','user_has_openchannel_interactions:save','removeOpenchannelInteractions','user_has_openchannel_interactions:remove','addWhatsappInteractions','user_has_whatsapp_interactions:save','removeWhatsappInteractions','getVoicePrefixes','getFaxAccounts','addFaxAccounts','removeFaxAccounts','getMailAccounts','removeMailAccounts','getOpenchannelAccounts','addOpenchannelAccounts','removeOpenchannelAccounts','getSmsAccounts','SmsAccount','addSmsAccounts','removeSmsAccounts','getChatWebsites','ChatWebsite','addChatWebsites','removeChatWebsites','getWhatsappAccounts','addWhatsappAccounts','removeWhatsappAccounts','SquareProject','getSquareProjects','addSquareProjects','removeSquareProjects','getScheduledCalls','CmHopper','$or','$gt','$gte','$lt','$lte','$ne','$eq','$not','$between','$notBetween','$in','$notIn','$notLike','$notILike','$like','$overlap','$contained','$any','dialActive','getApiKey','token','No\x20API\x20access\x20key\x20found!','createApiKey','generateApiKey','iat','nonce','removeApiKey','apiKeyNonce','apiKeyIat','API\x20key\x20not\x20available','You\x20don\x27t\x20have\x20sufficient\x20privileges\x20to\x20access\x20this\x20resource.','whoami','Unable\x20to\x20retrieve\x20the\x20current\x20user','resolve','getUserSetting','getPresence','teams','queues','inbound','lower','col','toString','asc','desc','substring','uniqBy','Unable\x20to\x20retrieve\x20RPC\x20agents\x20(AMI)'];(function(_0x5a4cbd,_0x56b594){var _0x2c62dd=function(_0xdbc981){while(--_0xdbc981){_0x5a4cbd['push'](_0x5a4cbd['shift']());}};_0x2c62dd(++_0x56b594);}(_0xa0c7,0x1ad));var _0x7a0c=function(_0x3458c3,_0x1dd2a2){_0x3458c3=_0x3458c3-0x0;var _0x467285=_0xa0c7[_0x3458c3];return _0x467285;};'use strict';var moment=require(_0x7a0c('0x0'));var BPromise=require(_0x7a0c('0x1'));var util=require(_0x7a0c('0x2'));var path=require(_0x7a0c('0x3'));var fs=require('fs');var _=require(_0x7a0c('0x4'));var squel=require(_0x7a0c('0x5'));var jayson=require(_0x7a0c('0x6'));var Redis=require('ioredis');var authService=require(_0x7a0c('0x7'));var qs=require('../../components/parsers/qs');var logger=require(_0x7a0c('0x8'))(_0x7a0c('0x9'));var utils=require(_0x7a0c('0xa'));var config=require(_0x7a0c('0xb'));var licenseUtil=require(_0x7a0c('0xc'));var db=require(_0x7a0c('0xd'))['db'];var socket=require('socket.io-emitter')(new Redis(config['redis']));require(_0x7a0c('0xe'))[_0x7a0c('0xf')](socket);config[_0x7a0c('0x10')]=_[_0x7a0c('0x11')](config['redis'],{'host':_0x7a0c('0x12'),'port':0x18eb});var client=jayson['client'][_0x7a0c('0x13')]({'port':0x232a});var values;function respondWithRpcPromise(_0x431c1c,_0x46663f,_0x3f5031,_0x154c68){return new BPromise(function(_0x2f26b2,_0x1c8486){var _0x1f799c=_0x154c68||client;return _0x1f799c[_0x7a0c('0x14')](_0x431c1c,_0x3f5031)[_0x7a0c('0x15')](function(_0x4c0850){logger['info'](_0x7a0c('0x16'),_0x46663f,_0x7a0c('0x17'));logger[_0x7a0c('0x18')](_0x7a0c('0x19'),_0x46663f,'request\x20sent',JSON['stringify'](_0x4c0850));if(_0x4c0850[_0x7a0c('0x1a')]){if(_0x4c0850['error'][_0x7a0c('0x1b')]===0x1f4){logger['error'](_0x7a0c('0x16'),_0x46663f,_0x4c0850['error'][_0x7a0c('0x1c')]);return _0x1c8486(_0x4c0850['error'][_0x7a0c('0x1c')]);}logger[_0x7a0c('0x1a')](_0x7a0c('0x16'),_0x46663f,_0x4c0850[_0x7a0c('0x1a')]['message']);return _0x2f26b2(_0x4c0850[_0x7a0c('0x1a')][_0x7a0c('0x1c')]);}else{logger[_0x7a0c('0x1d')](_0x7a0c('0x16'),_0x46663f,_0x7a0c('0x17'));_0x2f26b2(_0x4c0850[_0x7a0c('0x1e')][_0x7a0c('0x1c')]);}})[_0x7a0c('0x1f')](function(_0x542e9b){logger[_0x7a0c('0x1a')]('User,\x20%s,\x20%s',_0x46663f,_0x542e9b);_0x1c8486(_0x542e9b);});});}function respondWithStatusCode(_0x5512ce,_0x2d8371){_0x2d8371=_0x2d8371||0xcc;return function(_0xd71241){if(_0xd71241){return _0x5512ce['sendStatus'](_0x2d8371);}return _0x5512ce[_0x7a0c('0x20')](_0x2d8371)['end']();};}function respondWithResult(_0x1034fe,_0x2f9ef9){_0x2f9ef9=_0x2f9ef9||0xc8;return function(_0x33d74a){if(_0x33d74a){return _0x1034fe[_0x7a0c('0x20')](_0x2f9ef9)[_0x7a0c('0x21')](_0x33d74a);}};}function respondWithFilteredResult(_0x4e9128,_0x43d01e){return function(_0x261f3a){if(_0x261f3a){var _0x2eb6a4=typeof _0x43d01e[_0x7a0c('0x22')]===_0x7a0c('0x23')&&typeof _0x43d01e[_0x7a0c('0x24')]==='undefined';var _0x2e5b03=_0x261f3a[_0x7a0c('0x25')];var _0x46db69=_0x2eb6a4?0x0:_0x43d01e[_0x7a0c('0x22')];var _0x263138=_0x2eb6a4?_0x261f3a[_0x7a0c('0x25')]:_0x43d01e[_0x7a0c('0x22')]+_0x43d01e[_0x7a0c('0x24')];var _0x366c3d;if(_0x263138>=_0x2e5b03){_0x263138=_0x2e5b03;_0x366c3d=0xc8;}else{_0x366c3d=0xce;}_0x4e9128['status'](_0x366c3d);return _0x4e9128[_0x7a0c('0x26')](_0x7a0c('0x27'),_0x46db69+'-'+_0x263138+'/'+_0x2e5b03)[_0x7a0c('0x21')](_0x261f3a);}return null;};}function saveUpdates(_0x3e9d1c){return function(_0x4aee3e){if(_0x4aee3e){return _0x4aee3e[_0x7a0c('0x28')](_0x3e9d1c)['then'](function(_0x5de6a0){return _0x5de6a0;});}return null;};}function removeEntity(_0x2c2956){return function(_0x1f0cc9){if(_0x1f0cc9){return _0x1f0cc9[_0x7a0c('0x29')]()[_0x7a0c('0x15')](function(){var _0x2b313e=_0x1f0cc9[_0x7a0c('0x2a')]({'plain':!![]});if(_0x2b313e[_0x7a0c('0x2b')]===_0x7a0c('0x2c'))return;var _0x381be3=[{'name':_0x7a0c('0x2d'),'value':_0x7a0c('0x2e'),'ignore':!![]},{'name':_0x7a0c('0x2f'),'value':_0x7a0c('0x30'),'ignore':![]},{'name':_0x7a0c('0x31'),'value':_0x7a0c('0x32'),'ignore':![]}];var _0x1a8355=_(_0x381be3)['filter']('ignore')[_0x7a0c('0x33')](_0x7a0c('0x34'))['value']();if(_[_0x7a0c('0x35')](_0x1a8355,_0x2b313e[_0x7a0c('0x2b')])){return;}var _0x850c85=_[_0x7a0c('0x36')](_0x381be3,[_0x7a0c('0x34'),_0x2b313e[_0x7a0c('0x2b')]])[_0x7a0c('0x37')];return db[_0x7a0c('0x38')][_0x7a0c('0x29')]({'where':{'type':_0x850c85,'resourceId':_0x2b313e['id']}})[_0x7a0c('0x15')](function(){return _0x1f0cc9;});})[_0x7a0c('0x15')](function(){_0x2c2956[_0x7a0c('0x20')](0xcc)[_0x7a0c('0x39')]();});}};}function handleEntityNotFound(_0x2fb0e8){return function(_0x5b61c6){if(!_0x5b61c6){_0x2fb0e8[_0x7a0c('0x3a')](0x194);}return _0x5b61c6;};}function handleError(_0xd987d7,_0x4dab2c){_0x4dab2c=_0x4dab2c||0x1f4;return function(_0x28639d){logger['error'](_0x28639d[_0x7a0c('0x3b')]);if(_0x28639d['name']){delete _0x28639d[_0x7a0c('0x37')];}_0xd987d7[_0x7a0c('0x20')](_0x4dab2c)[_0x7a0c('0x3c')](_0x28639d);};}exports[_0x7a0c('0x3d')]=function(_0x2a8612,_0x142e74){var _0x565ea5={},_0x2edc40={'count':0x0,'rows':[]};var _0x29296e=_(db['User'][_0x7a0c('0x3e')])[_0x7a0c('0x33')](function(_0x525319){return{'name':_0x525319[_0x7a0c('0x3f')],'type':_0x525319[_0x7a0c('0x40')][_0x7a0c('0x41')]};})['filter'](function(_0x210b7b){return!_[_0x7a0c('0x35')]([_0x7a0c('0x42'),_0x7a0c('0x43')],_0x210b7b[_0x7a0c('0x37')]);})[_0x7a0c('0x34')]();_0x565ea5=qs[_0x7a0c('0x44')](_0x29296e,_0x2a8612);var _0x4af011={'where':_0x565ea5[_0x7a0c('0x45')]};return db[_0x7a0c('0x46')][_0x7a0c('0x25')](_0x4af011)['then'](function(_0x359eee){_0x2edc40[_0x7a0c('0x25')]=_0x359eee;if(_0x2a8612[_0x7a0c('0x47')][_0x7a0c('0x48')]){_0x565ea5[_0x7a0c('0x49')]=[{'all':!![]}];}if(_0x2a8612[_0x7a0c('0x47')][_0x7a0c('0x4a')]===_0x7a0c('0x4b')){_0x565ea5[_0x7a0c('0x49')]=[{'model':db[_0x7a0c('0x4c')],'as':_0x7a0c('0x4a')}];}if(!_[_0x7a0c('0x35')](_0x565ea5[_0x7a0c('0x4d')],'id')){_0x565ea5['attributes'][_0x7a0c('0x4e')]('id');}return db['User']['findAll'](_0x565ea5);})[_0x7a0c('0x15')](function(_0x36b68b){_0x2edc40[_0x7a0c('0x4f')]=_0x36b68b;if(_0x2a8612['query']['openTabs']===_0x7a0c('0x4b')){var _0xceb0bb=[];for(var _0x10de1b=0x0;_0x10de1b<_0x2edc40[_0x7a0c('0x4f')][_0x7a0c('0x50')];_0x10de1b++){_0xceb0bb[_0x7a0c('0x4e')](get_open_tabs(_0x7a0c('0x51'),_0x2edc40['rows'][_0x10de1b][_0x7a0c('0x52')]));_0xceb0bb['push'](get_open_tabs(_0x7a0c('0x53'),_0x2edc40['rows'][_0x10de1b][_0x7a0c('0x52')]));_0xceb0bb[_0x7a0c('0x4e')](get_open_tabs(_0x7a0c('0x54'),_0x2edc40[_0x7a0c('0x4f')][_0x10de1b][_0x7a0c('0x52')]));_0xceb0bb[_0x7a0c('0x4e')](get_open_tabs(_0x7a0c('0x55'),_0x2edc40[_0x7a0c('0x4f')][_0x10de1b]['dataValues']));_0xceb0bb[_0x7a0c('0x4e')](get_open_tabs('openchannel',_0x2edc40[_0x7a0c('0x4f')][_0x10de1b][_0x7a0c('0x52')]));_0xceb0bb[_0x7a0c('0x4e')](get_open_tabs(_0x7a0c('0x56'),_0x2edc40[_0x7a0c('0x4f')][_0x10de1b][_0x7a0c('0x52')]));}return BPromise[_0x7a0c('0x57')](_0xceb0bb)[_0x7a0c('0x15')](function(){return _0x2edc40;});}else{return _0x2edc40;}})[_0x7a0c('0x15')](respondWithFilteredResult(_0x142e74,_0x565ea5))[_0x7a0c('0x1f')](handleError(_0x142e74,null));};exports[_0x7a0c('0x58')]=function(_0x1d4ac3,_0x273057){var _0x574bd8={'raw':![],'where':{'id':_0x1d4ac3['params']['id']}},_0x2f5d04={};_0x2f5d04[_0x7a0c('0x59')]=_[_0x7a0c('0x5a')](_[_0x7a0c('0x5b')](db[_0x7a0c('0x46')][_0x7a0c('0x3e')]),[_0x7a0c('0x42'),_0x7a0c('0x43')]);_0x2f5d04[_0x7a0c('0x47')]=_[_0x7a0c('0x5b')](_0x1d4ac3['query']);_0x2f5d04[_0x7a0c('0x5c')]=_[_0x7a0c('0x5d')](_0x2f5d04[_0x7a0c('0x59')],_0x2f5d04[_0x7a0c('0x47')]);_0x574bd8['attributes']=_[_0x7a0c('0x5d')](_0x2f5d04[_0x7a0c('0x59')],qs[_0x7a0c('0x5e')](_0x1d4ac3['query']['fields']));_0x574bd8[_0x7a0c('0x4d')]=_0x574bd8[_0x7a0c('0x4d')]['length']?_0x574bd8[_0x7a0c('0x4d')]:_0x2f5d04[_0x7a0c('0x59')];if(_0x1d4ac3['query']['includeAll']){_0x574bd8[_0x7a0c('0x49')]=[{'all':!![]}];}if(_0x1d4ac3['query'][_0x7a0c('0x4a')]===_0x7a0c('0x4b')){_0x574bd8[_0x7a0c('0x49')]=[{'model':db[_0x7a0c('0x4c')],'as':_0x7a0c('0x4a')}];}_0x574bd8=_['merge']({},_0x574bd8,_0x1d4ac3[_0x7a0c('0x5f')]);if(!_[_0x7a0c('0x35')](_0x574bd8[_0x7a0c('0x4d')],'id')){_0x574bd8[_0x7a0c('0x4d')]['push']('id');}return db[_0x7a0c('0x46')]['find'](_0x574bd8)[_0x7a0c('0x15')](handleEntityNotFound(_0x273057,null))['then'](function(_0x5c2ef3){var _0x46deef=[];values=_0x5c2ef3;if(_0x1d4ac3['query'][_0x7a0c('0x60')]==='true'){_0x46deef[_0x7a0c('0x4e')](get_open_tabs(_0x7a0c('0x51'),_0x5c2ef3[_0x7a0c('0x52')]));_0x46deef[_0x7a0c('0x4e')](get_open_tabs('sms',_0x5c2ef3[_0x7a0c('0x52')]));_0x46deef[_0x7a0c('0x4e')](get_open_tabs(_0x7a0c('0x61'),_0x5c2ef3[_0x7a0c('0x52')]));_0x46deef[_0x7a0c('0x4e')](get_open_tabs('whatsapp',_0x5c2ef3['dataValues']));_0x46deef[_0x7a0c('0x4e')](get_open_tabs(_0x7a0c('0x54'),_0x5c2ef3[_0x7a0c('0x52')]));_0x46deef['push'](get_open_tabs('mail',_0x5c2ef3[_0x7a0c('0x52')]));return BPromise[_0x7a0c('0x57')](_0x46deef);}else{return values;}})[_0x7a0c('0x15')](function(){return values;})[_0x7a0c('0x15')](respondWithResult(_0x273057,null))[_0x7a0c('0x1f')](handleError(_0x273057,null));};exports[_0x7a0c('0x28')]=function(_0x48b1df,_0x4f4f6b){if(_0x48b1df[_0x7a0c('0x62')]['id']){delete _0x48b1df[_0x7a0c('0x62')]['id'];}delete _0x48b1df['body'][_0x7a0c('0x2b')];return db[_0x7a0c('0x46')][_0x7a0c('0x36')]({'where':{'id':_0x48b1df[_0x7a0c('0x63')]['id']}})[_0x7a0c('0x15')](handleEntityNotFound(_0x4f4f6b,null))[_0x7a0c('0x15')](saveUpdates(_0x48b1df[_0x7a0c('0x62')],null))[_0x7a0c('0x15')](respondWithResult(_0x4f4f6b,null))[_0x7a0c('0x1f')](handleError(_0x4f4f6b,null));};exports[_0x7a0c('0x64')]=function(_0x318812,_0x49faf3){return db[_0x7a0c('0x46')][_0x7a0c('0x64')]()['then'](respondWithResult(_0x49faf3,null))[_0x7a0c('0x1f')](handleError(_0x49faf3,null));};exports[_0x7a0c('0x65')]=function(_0xb007ca,_0x17608f){return db[_0x7a0c('0x46')][_0x7a0c('0x36')]({'where':{'id':_0xb007ca[_0x7a0c('0x63')]['id']}})['then'](handleEntityNotFound(_0x17608f,null))[_0x7a0c('0x15')](function(_0x57fc6e){if(_0x57fc6e){return _0x57fc6e['addContacts'](_0xb007ca[_0x7a0c('0x62')][_0x7a0c('0x66')],_[_0x7a0c('0x67')](_0xb007ca[_0x7a0c('0x62')],[_0x7a0c('0x66'),'id'])||{});}})[_0x7a0c('0x15')](respondWithResult(_0x17608f,null))[_0x7a0c('0x1f')](handleError(_0x17608f,null));};function validateUser(_0x214ffa){return new BPromise(function(_0x28ae58,_0x134738){if(_0x214ffa[_0x7a0c('0x68')])return _0x28ae58(_0x214ffa);return db[_0x7a0c('0x69')][_0x7a0c('0x6a')](0x1)[_0x7a0c('0x15')](function(_0x5d2ce4){if(_0x5d2ce4['securePassword'])authService['validatePasswordPattern'](_0x214ffa[_0x7a0c('0x42')]);db[_0x7a0c('0x46')][_0x7a0c('0x6b')](_0x7a0c('0x68'))[_0x7a0c('0x15')](function(_0x7928a4){if(_['isNil'](_0x7928a4)){_0x214ffa[_0x7a0c('0x68')]=_0x5d2ce4['min_internal']||0x1;return;}if(_[_0x7a0c('0x6c')](_0x5d2ce4[_0x7a0c('0x6d')])||_0x5d2ce4[_0x7a0c('0x6d')]===_0x7928a4){_0x214ffa[_0x7a0c('0x68')]=_0x7928a4+0x1;return;}if(_0x5d2ce4[_0x7a0c('0x6d')]>_0x7928a4){_0x214ffa[_0x7a0c('0x68')]=_0x5d2ce4[_0x7a0c('0x6d')];return;}return db[_0x7a0c('0x6e')]['query']('select\x20(select\x20IFNULL(max(internal)+1,1)\x20from\x20users\x20where\x20internal\x20<\x20md.internal)\x20as\x20\x27from\x27,\x20md.internal\x20-\x201\x20as\x20\x27to\x27\x20from\x20users\x20md\x20where\x20md.internal\x20!=\x201\x20and\x20not\x20exists\x20(select\x201\x20from\x20users\x20md2\x20where\x20md2.internal\x20=\x20md.internal\x20-\x201)',{'type':db[_0x7a0c('0x6e')][_0x7a0c('0x6f')][_0x7a0c('0x70')]})['then'](function(_0x5604c){if(_0x5604c&&_0x5604c[_0x7a0c('0x50')]){for(var _0x16caa0=0x0,_0x8c1692=_0x5604c[_0x7a0c('0x50')];_0x16caa0<_0x8c1692&&_[_0x7a0c('0x6c')](_0x214ffa[_0x7a0c('0x68')]);_0x16caa0++){if(_0x5d2ce4[_0x7a0c('0x6d')]<=_0x5604c[_0x16caa0][_0x7a0c('0x71')]){_0x214ffa[_0x7a0c('0x68')]=_0x5604c[_0x16caa0][_0x7a0c('0x71')];}else if(_0x5d2ce4['min_internal']>_0x5604c[_0x16caa0][_0x7a0c('0x71')]&&_0x5d2ce4['min_internal']<=_0x5604c[_0x16caa0]['to']){_0x214ffa[_0x7a0c('0x68')]=_0x5d2ce4['min_internal'];}}}if(_[_0x7a0c('0x6c')](_0x214ffa['internal'])){_0x214ffa[_0x7a0c('0x68')]=_0x7928a4+0x1;}return _0x28ae58(_0x214ffa);});});})[_0x7a0c('0x1f')](function(_0x3957c0){_0x134738(_0x3957c0);});});}function updateUser(_0x9d9cb8){return new BPromise(function(_0x260789,_0xc367fa){try{if(_0x9d9cb8['voicemail']){_0x9d9cb8[_0x7a0c('0x72')]=_0x9d9cb8[_0x7a0c('0x68')];_0x9d9cb8[_0x7a0c('0x73')]={'mailbox':_0x9d9cb8[_0x7a0c('0x68')],'password':_0x9d9cb8[_0x7a0c('0x42')],'fullname':_0x9d9cb8[_0x7a0c('0x74')],'email':_0x9d9cb8[_0x7a0c('0x75')]};}if(_0x9d9cb8[_0x7a0c('0x2b')]===_0x7a0c('0x30')){if(!_0x9d9cb8[_0x7a0c('0x76')])_0x9d9cb8[_0x7a0c('0x76')]=[_0x7a0c('0x77'),_0x7a0c('0x78'),'103',_0x7a0c('0x79'),_0x7a0c('0x7a'),_0x7a0c('0x7b'),_0x7a0c('0x7c'),'106','107',_0x7a0c('0x7d'),_0x7a0c('0x7e'),_0x7a0c('0x7f'),_0x7a0c('0x80'),'114',_0x7a0c('0x81')];}_0x260789(_0x9d9cb8);}catch(_0x1c253f){_0xc367fa(_0x1c253f);}});}exports[_0x7a0c('0x82')]=function(_0x5210f3,_0x58322c){if(_0x5210f3[_0x7a0c('0x2e')][_0x7a0c('0x2b')]===_0x7a0c('0x30'))throw new Error(_0x7a0c('0x83'));if(_0x5210f3[_0x7a0c('0x62')][_0x7a0c('0x2b')]===_0x7a0c('0x2e')&&_0x5210f3['user'][_0x7a0c('0x2b')]!==_0x7a0c('0x2c')){throw new Error('Unauthorized.\x20You\x20must\x20be\x20an\x20administrator\x20in\x20order\x20to\x20create\x20an\x20user');}if(_0x5210f3[_0x7a0c('0x62')][_0x7a0c('0x2b')]===_0x7a0c('0x2c')&&_0x5210f3['user']['role']!==_0x7a0c('0x2c')){throw new Error(_0x7a0c('0x84'));}return licenseUtil[_0x7a0c('0x85')]([_0x5210f3[_0x7a0c('0x62')]])[_0x7a0c('0x15')](function(){return validateUser(_0x5210f3[_0x7a0c('0x62')]);})[_0x7a0c('0x15')](function(_0x5f6de){return updateUser(_0x5f6de)[_0x7a0c('0x15')](function(_0x33aae8){if(_0x33aae8['role']===_0x7a0c('0x2c')){_0x33aae8[_0x7a0c('0x86')]=_0x5210f3[_0x7a0c('0x2e')]['settingsEnabled'];delete _0x33aae8[_0x7a0c('0x87')];}return _0x33aae8;});})[_0x7a0c('0x15')](function(_0x3dadcb){return db[_0x7a0c('0x46')][_0x7a0c('0x82')](_0x3dadcb,{'include':[{'model':db[_0x7a0c('0x73')],'as':_0x7a0c('0x73')}]});})[_0x7a0c('0x15')](function(_0x2fd070){if(_0x5210f3[_0x7a0c('0x62')]['role']===_0x7a0c('0x2e'))return _0x2fd070;if(_0x5210f3['user'][_0x7a0c('0x2b')]!==_0x7a0c('0x2e'))return _0x2fd070;return db[_0x7a0c('0x88')]['find']({'where':{'name':_0x2fd070['role']==='agent'?_0x7a0c('0x2f'):_0x7a0c('0x31'),'userProfileId':_0x5210f3[_0x7a0c('0x2e')][_0x7a0c('0x87')]},'raw':!![]})[_0x7a0c('0x15')](function(_0x476757){if(!_0x476757||_0x476757[_0x7a0c('0x89')]!=0x0)return _0x2fd070;return db[_0x7a0c('0x38')][_0x7a0c('0x82')]({'name':_0x2fd070[_0x7a0c('0x37')],'resourceId':_0x2fd070['id'],'type':_0x476757[_0x7a0c('0x37')],'sectionId':_0x476757['id']},{})['then'](function(){return _0x2fd070;});})[_0x7a0c('0x1f')](function(_0x2edd55){logger[_0x7a0c('0x1a')](_0x7a0c('0x8a'),_0x2edd55);throw _0x2edd55;});})[_0x7a0c('0x15')](respondWithResult(_0x58322c,0xc9))[_0x7a0c('0x1f')](handleError(_0x58322c,null));};exports['bulkCreate']=function(_0x1ce5f6,_0x130491){var _0x16192c=_0x1ce5f6[_0x7a0c('0x62')];var _0x21bf60=[];if(_0x1ce5f6[_0x7a0c('0x2e')]['role']===_0x7a0c('0x30'))throw new Error(_0x7a0c('0x83'));if(_['some'](_0x16192c,[_0x7a0c('0x2b'),_0x7a0c('0x2e')])&&_0x1ce5f6[_0x7a0c('0x2e')]['role']!=='admin'){throw new Error(_0x7a0c('0x8b'));}if(_['some'](_0x16192c,[_0x7a0c('0x2b'),_0x7a0c('0x2c')])&&_0x1ce5f6[_0x7a0c('0x2e')][_0x7a0c('0x2b')]!==_0x7a0c('0x2c')){throw new Error(_0x7a0c('0x8c'));}return licenseUtil[_0x7a0c('0x85')](_0x16192c)[_0x7a0c('0x15')](function(){return validateUser(_0x16192c[0x0]);})['then'](function(){for(var _0x2f375e=0x1;_0x2f375e<_0x16192c[_0x7a0c('0x50')];_0x2f375e++){var _0x1b8637=_0x16192c[_0x2f375e-0x1][_0x7a0c('0x68')];if(!_0x16192c[_0x2f375e][_0x7a0c('0x68')])_0x16192c[_0x2f375e]['internal']=_0x1b8637+0x1;_0x21bf60[_0x7a0c('0x4e')](validateUser(_0x16192c[_0x2f375e]));}return BPromise[_0x7a0c('0x57')](_0x21bf60);})[_0x7a0c('0x15')](function(){_0x21bf60=[];for(var _0x31b84a=0x0;_0x31b84a<_0x16192c[_0x7a0c('0x50')];_0x31b84a++){_0x21bf60['push'](updateUser(_0x16192c[_0x31b84a]));}return BPromise['all'](_0x21bf60);})[_0x7a0c('0x15')](function(){return BPromise[_0x7a0c('0x8d')](_0x16192c,function(_0x555a29){return db['User'][_0x7a0c('0x82')](_0x555a29,{'include':[{'model':db[_0x7a0c('0x73')],'as':_0x7a0c('0x73')}]})['then'](function(_0x4e33e4){_0x555a29['id']=_0x4e33e4['id'];return _0x555a29;});});})[_0x7a0c('0x15')](function(_0x29f624){if(_0x1ce5f6[_0x7a0c('0x62')]['role']==='user')return _0x29f624;if(_0x1ce5f6[_0x7a0c('0x2e')][_0x7a0c('0x2b')]!==_0x7a0c('0x2e'))return _0x29f624;var _0x10208d=_['some'](_0x29f624,function(_0x11ca70){return _0x11ca70[_0x7a0c('0x2b')]===_0x7a0c('0x30')||_0x11ca70[_0x7a0c('0x2b')]===_0x7a0c('0x32');});if(!_0x10208d)return _0x29f624;return db[_0x7a0c('0x88')][_0x7a0c('0x8e')]({'where':{'name':{'$or':[_0x7a0c('0x2f'),_0x7a0c('0x31')]},'userProfileId':_0x1ce5f6[_0x7a0c('0x2e')][_0x7a0c('0x87')]},'raw':!![]})['then'](function(_0x5f36a1){if(_[_0x7a0c('0x8f')](_0x5f36a1)||!_[_0x7a0c('0x90')](_0x5f36a1,[_0x7a0c('0x89'),0x0]))return _0x29f624;_0x21bf60=[];var _0x263cfd=_(_0x5f36a1)[_0x7a0c('0x33')](function(_0x4a5a0e){if(_0x4a5a0e[_0x7a0c('0x89')]===0x1)return;return _0x4a5a0e[_0x7a0c('0x37')]===_0x7a0c('0x2f')?'agent':'telephone';})[_0x7a0c('0x91')]()[_0x7a0c('0x34')]();for(var _0xbf790e=0x0;_0xbf790e<_0x29f624[_0x7a0c('0x50')];_0xbf790e++){if(!_[_0x7a0c('0x35')](_0x263cfd,_0x29f624[_0xbf790e][_0x7a0c('0x2b')]))return;var _0xb8bf51=_0x29f624[_0xbf790e][_0x7a0c('0x2b')]==='agent'?'Agents':'Telephones';_0x21bf60[_0x7a0c('0x4e')](db['UserProfileResource']['create']({'name':_0x29f624[_0xbf790e][_0x7a0c('0x37')],'resourceId':_0x29f624[_0xbf790e]['id'],'type':_0xb8bf51,'sectionId':_[_0x7a0c('0x36')](_0x5f36a1,[_0x7a0c('0x37'),_0xb8bf51])['id']},{}));}return BPromise['all'](_0x21bf60);});})['then'](respondWithResult(_0x130491,0xc9))[_0x7a0c('0x1f')](handleError(_0x130491,null));};exports['changePassword']=function(_0x55bce1,_0x5e684f){if(_0x55bce1['body']['id']){delete _0x55bce1[_0x7a0c('0x62')]['id'];}return db[_0x7a0c('0x46')][_0x7a0c('0x36')]({'where':{'id':_0x55bce1[_0x7a0c('0x63')]['id']}})[_0x7a0c('0x15')](function(_0x297e46){if(!_0x297e46)return null;if(_0x297e46['id']===_0x55bce1[_0x7a0c('0x2e')]['id']){if(!_0x55bce1[_0x7a0c('0x62')]['oldPassword']||!_0x55bce1[_0x7a0c('0x62')][_0x7a0c('0x92')]){throw new db['Sequelize']['ValidationError']('Invalid\x20body\x20format.\x20Use\x20oldPassword\x20and\x20newPassword');}if(!_0x297e46[_0x7a0c('0x93')](_0x55bce1[_0x7a0c('0x62')][_0x7a0c('0x94')])){throw new db[(_0x7a0c('0x95'))][(_0x7a0c('0x96'))](_0x7a0c('0x97'));}if(_0x55bce1['body'][_0x7a0c('0x94')]===_0x55bce1[_0x7a0c('0x62')]['newPassword']){throw new db[(_0x7a0c('0x95'))][(_0x7a0c('0x96'))](_0x7a0c('0x98'));}}else if(_0x55bce1[_0x7a0c('0x2e')][_0x7a0c('0x2b')]===_0x7a0c('0x2c')){if(!_0x55bce1[_0x7a0c('0x62')][_0x7a0c('0x92')]){throw new db[(_0x7a0c('0x95'))][(_0x7a0c('0x96'))](_0x7a0c('0x99'));}}else if(_0x55bce1[_0x7a0c('0x2e')][_0x7a0c('0x2b')]===_0x7a0c('0x2e')){if(!_0x55bce1['body']['newPassword']){throw new db[(_0x7a0c('0x95'))][(_0x7a0c('0x96'))](_0x7a0c('0x99'));}if(_0x297e46[_0x7a0c('0x2b')]!==_0x7a0c('0x30')){throw new db[(_0x7a0c('0x95'))]['ValidationError'](_0x7a0c('0x83'));}}else{throw new db[(_0x7a0c('0x95'))][(_0x7a0c('0x96'))](_0x7a0c('0x83'));}return _0x297e46;})['then'](handleEntityNotFound(_0x5e684f,null))[_0x7a0c('0x15')](function(_0x27c6cd){return db[_0x7a0c('0x69')][_0x7a0c('0x9a')]({'attributes':['id',_0x7a0c('0x9b'),_0x7a0c('0x9c'),_0x7a0c('0x9d')]})[_0x7a0c('0x15')](function(_0x3ff5f3){if(_0x3ff5f3[_0x7a0c('0x9b')])authService[_0x7a0c('0x9e')](_0x55bce1['body'][_0x7a0c('0x92')]);if(!_0x3ff5f3[_0x7a0c('0x9c')]||!_0x27c6cd[_0x7a0c('0x9f')])return _0x27c6cd;authService[_0x7a0c('0xa0')](_0x55bce1['body']['newPassword'],_0x27c6cd[_0x7a0c('0x9f')],_0x3ff5f3[_0x7a0c('0x9d')]);return _0x27c6cd;})[_0x7a0c('0x15')](saveUpdates({'password':_0x55bce1[_0x7a0c('0x62')][_0x7a0c('0x92')],'passwordResetAt':_0x55bce1[_0x7a0c('0x2e')]['id']==_0x55bce1[_0x7a0c('0x63')]['id']?moment():null,'previousPasswords':authService[_0x7a0c('0xa1')](_0x55bce1[_0x7a0c('0x62')]['newPassword'],_0x27c6cd['previousPasswords'])},null));})['then'](respondWithResult(_0x5e684f,null))[_0x7a0c('0x1f')](handleError(_0x5e684f,null));};exports['addQueues']=function(_0x250815,_0x273197){var _0xc6aa22=_0x250815[_0x7a0c('0x62')]['channel'];return db[_0x7a0c('0x46')]['find']({'where':{'id':_0x250815[_0x7a0c('0x63')]['id']},'attributes':['id',_0x7a0c('0x37'),'role',_0x7a0c('0xa2'),_0x7a0c('0xa3'),_0x7a0c('0xa4'),_0x7a0c('0xa5')]})[_0x7a0c('0x15')](handleEntityNotFound(_0x273197,null))[_0x7a0c('0x15')](function(_0x1da745){if(_0x1da745){if(!utils['isValidChannel'](_0xc6aa22)){throw new db[(_0x7a0c('0x95'))]['ValidationError'](_0x7a0c('0xa6'));}return _0x1da745['add'+_['capitalize'](_0xc6aa22[_0x7a0c('0xa7')]())+_0x7a0c('0xa8')](_0x250815[_0x7a0c('0x62')]['ids'],{'penalty':_0x250815['body'][_0x7a0c('0xa9')]||0x0})['spread'](function(_0x96fac8){for(var _0x52c2bf=0x0;_0x52c2bf<_0x250815[_0x7a0c('0x62')]['ids'][_0x7a0c('0x50')];_0x52c2bf+=0x1){var _0x82a89={'UserId':Number(_0x250815['params']['id'])};_0x82a89[_[_0x7a0c('0xaa')](_0xc6aa22[_0x7a0c('0xa7')]())+_0x7a0c('0xab')]=Number(_0x250815['body'][_0x7a0c('0x66')][_0x52c2bf]);socket[_0x7a0c('0xac')](_0x7a0c('0x2e')+_[_0x7a0c('0xaa')](_0xc6aa22['toLowerCase']())+_0x7a0c('0xad'),_0x82a89);}return _0x96fac8;})['then'](function(){if(_0xc6aa22===_0x7a0c('0xae')){return db[_0x7a0c('0xaf')][_0x7a0c('0x8e')]({'where':{'id':_0x250815[_0x7a0c('0x62')][_0x7a0c('0x66')]||[]},'raw':!![],'attributes':['id','name']});}})[_0x7a0c('0x15')](function(_0x43125a){var _0x21ef65=_0x1da745[_0x7a0c('0x2a')]({'plain':!![]});var _0x1429b2=[];if(_0xc6aa22===_0x7a0c('0xae')&&_0x21ef65[_0x7a0c('0x2b')]===_0x7a0c('0x30')&&_0x21ef65['online']){for(var _0x5d769a=0x0;_0x5d769a<_0x43125a[_0x7a0c('0x50')];_0x5d769a+=0x1){_0x1429b2['push']({'membername':_0x21ef65['name'],'UserId':_0x21ef65['id'],'queue_name':_0x43125a[_0x5d769a]['name'],'VoiceQueueId':_0x43125a[_0x5d769a]['id'],'interface':_[_0x7a0c('0x6c')](_0x21ef65['interface'])?util[_0x7a0c('0xb0')]('SIP/%s',_0x21ef65[_0x7a0c('0x37')]):_0x21ef65[_0x7a0c('0xa5')],'paused':_0x21ef65[_0x7a0c('0xa4')]||![],'penalty':_0x250815[_0x7a0c('0x62')][_0x7a0c('0xa9')]||0x0});}return BPromise[_0x7a0c('0x8d')](_0x1429b2,function(_0x5722dc){return db[_0x7a0c('0xb1')][_0x7a0c('0xb2')](_0x5722dc);});}return _0x1da745;});}})[_0x7a0c('0x15')](respondWithStatusCode(_0x273197,null))[_0x7a0c('0x1f')](handleError(_0x273197,null));};exports[_0x7a0c('0xb3')]=function(_0x4be365,_0x411903){var _0x13d2d7,_0x42c29d;return db[_0x7a0c('0x46')][_0x7a0c('0x36')]({'where':{'id':_0x4be365[_0x7a0c('0x63')]['id']},'attributes':['id',_0x7a0c('0x37'),_0x7a0c('0x2b')]})['then'](handleEntityNotFound(_0x411903,null))[_0x7a0c('0x15')](function(_0x5c4c7f){if(_0x5c4c7f){_0x13d2d7=_0x5c4c7f;if(!_0x4be365[_0x7a0c('0x47')][_0x7a0c('0xb4')]||!utils[_0x7a0c('0xb5')](_0x4be365['query'][_0x7a0c('0xb4')])){throw new db[(_0x7a0c('0x95'))][(_0x7a0c('0x96'))](_0x7a0c('0xa6'));}return _0x5c4c7f[_0x7a0c('0xb6')+_[_0x7a0c('0xaa')](_0x4be365['query'][_0x7a0c('0xb4')][_0x7a0c('0xa7')]())+_0x7a0c('0xa8')](_0x4be365['query'][_0x7a0c('0x66')]);}})[_0x7a0c('0x15')](function(_0x5d5ba6){if(_[_0x7a0c('0xb7')](_0x4be365['query'][_0x7a0c('0x66')])){for(var _0x2c6df5=0x0;_0x2c6df5<_0x4be365[_0x7a0c('0x47')][_0x7a0c('0x66')][_0x7a0c('0x50')];_0x2c6df5+=0x1){_0x42c29d={'UserId':Number(_0x4be365[_0x7a0c('0x63')]['id'])};_0x42c29d[_['capitalize'](_0x4be365[_0x7a0c('0x47')][_0x7a0c('0xb4')][_0x7a0c('0xa7')]())+_0x7a0c('0xab')]=Number(_0x4be365[_0x7a0c('0x47')][_0x7a0c('0x66')][_0x2c6df5]);socket[_0x7a0c('0xac')](_0x7a0c('0x2e')+_[_0x7a0c('0xaa')](_0x4be365['query'][_0x7a0c('0xb4')][_0x7a0c('0xa7')]())+'Queue:remove',_0x42c29d);}}else{_0x42c29d={'UserId':Number(_0x4be365[_0x7a0c('0x63')]['id'])};_0x42c29d[_['capitalize'](_0x4be365[_0x7a0c('0x47')][_0x7a0c('0xb4')][_0x7a0c('0xa7')]())+_0x7a0c('0xab')]=Number(_0x4be365[_0x7a0c('0x47')][_0x7a0c('0x66')]);socket['emit'](_0x7a0c('0x2e')+_['capitalize'](_0x4be365[_0x7a0c('0x47')][_0x7a0c('0xb4')][_0x7a0c('0xa7')]())+_0x7a0c('0xb8'),_0x42c29d);}return _0x5d5ba6;})[_0x7a0c('0x15')](function(){if(_0x4be365['query']['channel']===_0x7a0c('0xae')){return db[_0x7a0c('0xb1')][_0x7a0c('0x29')]({'where':{'UserId':_0x4be365['params']['id'],'VoiceQueueId':_0x4be365[_0x7a0c('0x47')][_0x7a0c('0x66')]},'individualHooks':!![]})[_0x7a0c('0x15')](function(){return _0x13d2d7;});}return _0x13d2d7;})[_0x7a0c('0x15')](respondWithStatusCode(_0x411903,null))[_0x7a0c('0x1f')](handleError(_0x411903,null));};exports[_0x7a0c('0xb9')]=function(_0x3cfb4d,_0x38f762){_0x3cfb4d[_0x7a0c('0x62')][_0x7a0c('0xba')]=_0x3cfb4d[_0x7a0c('0xbb')][_0x7a0c('0xbc')];return db[_0x7a0c('0x46')][_0x7a0c('0x36')]({'where':{'id':_0x3cfb4d[_0x7a0c('0x63')]['id']}})[_0x7a0c('0x15')](handleEntityNotFound(_0x38f762,null))[_0x7a0c('0x15')](saveUpdates(_0x3cfb4d[_0x7a0c('0x62')],null))[_0x7a0c('0x15')](respondWithResult(_0x38f762,null))[_0x7a0c('0x1f')](handleError(_0x38f762,null));};exports[_0x7a0c('0xbd')]=function(_0x563e54,_0x263390){var _0x1dda73=path[_0x7a0c('0xbe')](config[_0x7a0c('0xbf')],_0x7a0c('0xc0'));return db[_0x7a0c('0x46')]['find']({'where':{'id':_0x563e54['params']['id']},'attributes':['id',_0x7a0c('0xba')],'raw':!![]})[_0x7a0c('0x15')](handleEntityNotFound(_0x263390,null))[_0x7a0c('0x15')](function(_0x495b79){if(_0x495b79){if(_[_0x7a0c('0x6c')](_0x495b79[_0x7a0c('0xba')])){return _0x263390['download'](_0x1dda73);}else{if(!fs[_0x7a0c('0xc1')](path[_0x7a0c('0xbe')](config[_0x7a0c('0xbf')],_0x7a0c('0xc2'),_0x495b79['userpic']))){return _0x263390[_0x7a0c('0xc3')](_0x1dda73);}return _0x263390[_0x7a0c('0xc3')](path[_0x7a0c('0xbe')](config[_0x7a0c('0xbf')],_0x7a0c('0xc2'),_0x495b79[_0x7a0c('0xba')]));}}})['catch'](handleError(_0x263390,null));};exports[_0x7a0c('0xc4')]=function(_0x49dcf9,_0x26d287){return db[_0x7a0c('0x46')]['find']({'where':{'id':_0x49dcf9[_0x7a0c('0x63')]['id']},'attributes':['id']})['then'](handleEntityNotFound(_0x26d287,null))[_0x7a0c('0x15')](function(_0x1a954f){var _0x2102c1=[];values=_0x1a954f[_0x7a0c('0x52')];_0x2102c1[_0x7a0c('0x4e')](get_open_tabs(_0x7a0c('0x51'),_0x1a954f[_0x7a0c('0x52')]));_0x2102c1[_0x7a0c('0x4e')](get_open_tabs('sms',_0x1a954f[_0x7a0c('0x52')]));_0x2102c1[_0x7a0c('0x4e')](get_open_tabs('openchannel',_0x1a954f[_0x7a0c('0x52')]));_0x2102c1[_0x7a0c('0x4e')](get_open_tabs(_0x7a0c('0x56'),_0x1a954f['dataValues']));_0x2102c1['push'](get_open_tabs('fax',_0x1a954f['dataValues']));_0x2102c1[_0x7a0c('0x4e')](get_open_tabs(_0x7a0c('0x55'),_0x1a954f[_0x7a0c('0x52')]));return BPromise[_0x7a0c('0x57')](_0x2102c1);})[_0x7a0c('0x15')](function(_0x26ab9c){if(_0x26ab9c){var _0x226401=_[_0x7a0c('0x33')](values['ChatOpenTabs'],function(_0xb2d6c6){return{'channel':_0x7a0c('0xc5'),'id':_0xb2d6c6['id'],'createdAt':_0xb2d6c6[_0x7a0c('0xc6')]};});var _0x8406c3=_[_0x7a0c('0x33')](values[_0x7a0c('0xc7')],function(_0x324fa9){return{'channel':_0x7a0c('0xc8'),'id':_0x324fa9['id'],'createdAt':_0x324fa9[_0x7a0c('0xc6')]};});var _0x57db9d=_[_0x7a0c('0x33')](values['OpenchannelOpenTabs'],function(_0x3f56ad){return{'channel':'OPENCHANNEL','id':_0x3f56ad['id'],'createdAt':_0x3f56ad['createdAt']};});var _0x2d7ffe=_[_0x7a0c('0x33')](values[_0x7a0c('0xc9')],function(_0x5e6e95){return{'channel':_0x7a0c('0xca'),'id':_0x5e6e95['id'],'createdAt':_0x5e6e95[_0x7a0c('0xc6')]};});var _0x2879d8=_[_0x7a0c('0x33')](values[_0x7a0c('0xcb')],function(_0x6324f6){return{'channel':_0x7a0c('0xcc'),'id':_0x6324f6['id'],'createdAt':_0x6324f6['createdAt']};});var _0x1234ea=_[_0x7a0c('0x33')](values[_0x7a0c('0xcd')],function(_0x3652df){return{'channel':_0x7a0c('0xce'),'id':_0x3652df['id'],'createdAt':_0x3652df[_0x7a0c('0xc6')]};});var _0x3465a1=_[_0x7a0c('0xcf')](_0x226401,_0x8406c3,_0x57db9d,_0x2d7ffe,_0x2879d8,_0x1234ea);var _0x22442e={'count':_0x3465a1[_0x7a0c('0x50')],'rows':_0x3465a1};return _0x22442e;}else return null;})['then'](respondWithResult(_0x26d287,null))['catch'](handleError(_0x26d287,null));};exports[_0x7a0c('0xd0')]=function(_0x2e0048,_0x5c408c){var _0x30d344={};var _0xfe0ff5={};var _0x1ba30a;var _0x1c9b70;return db[_0x7a0c('0x46')][_0x7a0c('0x9a')]({'where':{'id':_0x2e0048[_0x7a0c('0x63')]['id']}})[_0x7a0c('0x15')](handleEntityNotFound(_0x5c408c,null))[_0x7a0c('0x15')](function(_0x2a5fc1){if(_0x2a5fc1){_0x1ba30a=_0x2a5fc1;_0xfe0ff5['model']=_[_0x7a0c('0x5b')](db[_0x7a0c('0xd1')]['rawAttributes']);_0xfe0ff5[_0x7a0c('0x47')]=_[_0x7a0c('0x5b')](_0x2e0048[_0x7a0c('0x47')]);_0xfe0ff5[_0x7a0c('0x5c')]=_[_0x7a0c('0x5d')](_0xfe0ff5[_0x7a0c('0x59')],_0xfe0ff5[_0x7a0c('0x47')]);_0x30d344['attributes']=_[_0x7a0c('0x5d')](_0xfe0ff5[_0x7a0c('0x59')],qs['fields'](_0x2e0048[_0x7a0c('0x47')]['fields']));_0x30d344['attributes']=_0x30d344[_0x7a0c('0x4d')][_0x7a0c('0x50')]?_0x30d344[_0x7a0c('0x4d')]:_0xfe0ff5['model'];_0x30d344['order']=qs['sort'](_0x2e0048[_0x7a0c('0x47')][_0x7a0c('0xd2')]);_0x30d344[_0x7a0c('0x45')]=qs[_0x7a0c('0x5c')](_[_0x7a0c('0xd3')](_0x2e0048[_0x7a0c('0x47')],_0xfe0ff5[_0x7a0c('0x5c')]));if(_0x2e0048[_0x7a0c('0x47')][_0x7a0c('0xd4')]){_0x30d344[_0x7a0c('0x45')]=_[_0x7a0c('0xd5')](_0x30d344[_0x7a0c('0x45')],{'$or':_[_0x7a0c('0x33')](_0x30d344[_0x7a0c('0x4d')],function(_0x2bafd8){var _0x3b96ac={};_0x3b96ac[_0x2bafd8]={'$like':'%'+_0x2e0048[_0x7a0c('0x47')]['filter']+'%'};return _0x3b96ac;})});}_0x30d344=_[_0x7a0c('0xd5')]({},_0x30d344,_0x2e0048[_0x7a0c('0x5f')]);return _0x1ba30a[_0x7a0c('0xd0')](_0x30d344);}})[_0x7a0c('0x15')](function(_0x5e8cfb){if(_0x5e8cfb){_0x1c9b70=_0x5e8cfb['length'];if(_0x2e0048['query'][_0x7a0c('0xd6')](_0x7a0c('0x48'))){_0x30d344[_0x7a0c('0x49')]=[{'model':db[_0x7a0c('0xd7')],'as':'List','required':![]},{'model':db[_0x7a0c('0xd8')],'as':_0x7a0c('0xd9'),'attributes':['id',_0x7a0c('0x37'),'color'],'where':_0x2e0048[_0x7a0c('0x47')][_0x7a0c('0xda')]?{'id':_0x2e0048[_0x7a0c('0x47')]['tag']}:undefined,'required':_0x2e0048[_0x7a0c('0x47')][_0x7a0c('0xda')]?!![]:![]}];}if(!_0x2e0048[_0x7a0c('0x47')][_0x7a0c('0xd6')](_0x7a0c('0xdb'))){_0x30d344[_0x7a0c('0x24')]=qs['limit'](_0x2e0048[_0x7a0c('0x47')][_0x7a0c('0x24')]);_0x30d344['offset']=qs[_0x7a0c('0x22')](_0x2e0048[_0x7a0c('0x47')][_0x7a0c('0x22')]);}return _0x1ba30a['getContacts'](_0x30d344);}})[_0x7a0c('0x15')](function(_0x20d6f8){if(_0x20d6f8){return _0x20d6f8?{'count':_0x1c9b70,'rows':_0x20d6f8}:null;}})[_0x7a0c('0x15')](respondWithResult(_0x5c408c,null))['catch'](handleError(_0x5c408c,null));};exports[_0x7a0c('0xdc')]=function(_0x29c846,_0x384397){var _0x526300;var _0x1ebc82={};var _0x37ca13;return db[_0x7a0c('0x46')][_0x7a0c('0x9a')]({'where':{'id':_0x29c846[_0x7a0c('0x63')]['id']},'attributes':['id',_0x7a0c('0x37'),_0x7a0c('0x2b')]})[_0x7a0c('0x15')](handleEntityNotFound(_0x384397,null))[_0x7a0c('0x15')](function(_0x261158){if(!utils['isValidChannel'](_0x29c846['query'][_0x7a0c('0xb4')])){throw new db['Sequelize'][(_0x7a0c('0x96'))](_0x7a0c('0xa6'));}_0x526300=_0x261158;var _0x38321e={};_0x38321e[_0x7a0c('0x59')]=_['keys'](db[_[_0x7a0c('0xaa')](_0x29c846['query'][_0x7a0c('0xb4')])+_0x7a0c('0xdd')][_0x7a0c('0x3e')]);_0x38321e[_0x7a0c('0x47')]=_[_0x7a0c('0x5b')](_0x29c846[_0x7a0c('0x47')]);_0x38321e[_0x7a0c('0x5c')]=_[_0x7a0c('0x5d')](_0x38321e[_0x7a0c('0x59')],_0x38321e[_0x7a0c('0x47')]);_0x1ebc82[_0x7a0c('0x4d')]=_[_0x7a0c('0x5d')](_0x38321e[_0x7a0c('0x59')],qs[_0x7a0c('0x5e')](_0x29c846[_0x7a0c('0x47')][_0x7a0c('0x5e')]));_0x1ebc82[_0x7a0c('0x4d')]=_0x1ebc82['attributes']['length']?_0x1ebc82['attributes']:_0x38321e[_0x7a0c('0x59')];_0x1ebc82['order']=qs[_0x7a0c('0xd2')](_0x29c846[_0x7a0c('0x47')][_0x7a0c('0xd2')]);_0x1ebc82[_0x7a0c('0x45')]=qs[_0x7a0c('0x5c')](_[_0x7a0c('0xd3')](_0x29c846[_0x7a0c('0x47')],_0x38321e[_0x7a0c('0x5c')]));if(_0x29c846[_0x7a0c('0x47')]['filter']){_0x1ebc82[_0x7a0c('0x45')]=_['merge'](_0x1ebc82[_0x7a0c('0x45')],{'$or':_['map'](_0x1ebc82['attributes'],function(_0x177974){var _0x146949={};_0x146949[_0x177974]={'$like':'%'+_0x29c846[_0x7a0c('0x47')]['filter']+'%'};return _0x146949;})});}_0x1ebc82=_['merge']({},_0x1ebc82,_0x29c846[_0x7a0c('0x5f')]);switch(_0x526300['role']){case'admin':return db[_['capitalize'](_0x29c846[_0x7a0c('0x47')]['channel'])+_0x7a0c('0xdd')]['findAll'](_0x1ebc82);case _0x7a0c('0x2e'):case _0x7a0c('0x30'):return _0x526300[_0x7a0c('0x2a')+_[_0x7a0c('0xaa')](_0x29c846[_0x7a0c('0x47')][_0x7a0c('0xb4')])+_0x7a0c('0xa8')](_0x1ebc82);default:throw new db[(_0x7a0c('0x95'))][(_0x7a0c('0x96'))](_0x7a0c('0xde'));}})['then'](function(_0x10834d){_0x37ca13=_0x10834d[_0x7a0c('0x50')];if(!_0x29c846[_0x7a0c('0x47')][_0x7a0c('0xd6')]('nolimit')){_0x1ebc82['limit']=qs[_0x7a0c('0x24')](_0x29c846[_0x7a0c('0x47')][_0x7a0c('0x24')]);_0x1ebc82[_0x7a0c('0x22')]=qs[_0x7a0c('0x22')](_0x29c846[_0x7a0c('0x47')][_0x7a0c('0x22')]);}switch(_0x526300[_0x7a0c('0x2b')]){case _0x7a0c('0x2c'):return db[_[_0x7a0c('0xaa')](_0x29c846[_0x7a0c('0x47')]['channel'])+'Queue']['findAll'](_0x1ebc82);case _0x7a0c('0x2e'):case'agent':return _0x526300[_0x7a0c('0x2a')+_['capitalize'](_0x29c846[_0x7a0c('0x47')][_0x7a0c('0xb4')])+_0x7a0c('0xa8')](_0x1ebc82);}})[_0x7a0c('0x15')](function(_0x4d085d){return{'count':_0x37ca13,'rows':_0x4d085d};})[_0x7a0c('0x15')](respondWithResult(_0x384397,null))['catch'](handleError(_0x384397,null));};exports[_0x7a0c('0xdf')]=function(_0x5ac437,_0x1e493b){var _0x35df9d={};var _0x1fc991={};var _0x57ee22;var _0x41b88d;return db[_0x7a0c('0x46')][_0x7a0c('0x9a')]({'where':{'id':_0x5ac437[_0x7a0c('0x63')]['id']}})[_0x7a0c('0x15')](handleEntityNotFound(_0x1e493b,null))[_0x7a0c('0x15')](function(_0x35fca6){if(_0x35fca6){_0x57ee22=_0x35fca6;_0x1fc991['model']=_[_0x7a0c('0x5b')](db['UserVoiceQueueRt'][_0x7a0c('0x3e')]);_0x1fc991['query']=_[_0x7a0c('0x5b')](_0x5ac437[_0x7a0c('0x47')]);_0x1fc991[_0x7a0c('0x5c')]=_['intersection'](_0x1fc991['model'],_0x1fc991[_0x7a0c('0x47')]);_0x35df9d[_0x7a0c('0x4d')]=_[_0x7a0c('0x5d')](_0x1fc991[_0x7a0c('0x59')],qs[_0x7a0c('0x5e')](_0x5ac437[_0x7a0c('0x47')]['fields']));_0x35df9d['attributes']=_0x35df9d[_0x7a0c('0x4d')]['length']?_0x35df9d[_0x7a0c('0x4d')]:_0x1fc991[_0x7a0c('0x59')];_0x35df9d[_0x7a0c('0xe0')]=qs[_0x7a0c('0xd2')](_0x5ac437[_0x7a0c('0x47')][_0x7a0c('0xd2')]);_0x35df9d[_0x7a0c('0x45')]=qs[_0x7a0c('0x5c')](_[_0x7a0c('0xd3')](_0x5ac437[_0x7a0c('0x47')],_0x1fc991[_0x7a0c('0x5c')]));if(_0x5ac437[_0x7a0c('0x47')]['filter']){_0x35df9d['where']=_[_0x7a0c('0xd5')](_0x35df9d[_0x7a0c('0x45')],{'$or':_[_0x7a0c('0x33')](_0x35df9d[_0x7a0c('0x4d')],function(_0x32e76c){var _0x18d739={};_0x18d739[_0x32e76c]={'$like':'%'+_0x5ac437[_0x7a0c('0x47')][_0x7a0c('0xd4')]+'%'};return _0x18d739;})});}_0x35df9d=_['merge']({},_0x35df9d,_0x5ac437[_0x7a0c('0x5f')]);return _0x57ee22[_0x7a0c('0xdf')](_0x35df9d);}})[_0x7a0c('0x15')](function(_0x65197e){if(_0x65197e){_0x41b88d=_0x65197e[_0x7a0c('0x50')];if(!_0x5ac437[_0x7a0c('0x47')][_0x7a0c('0xd6')]('nolimit')){_0x35df9d['limit']=qs[_0x7a0c('0x24')](_0x5ac437[_0x7a0c('0x47')][_0x7a0c('0x24')]);_0x35df9d['offset']=qs[_0x7a0c('0x22')](_0x5ac437[_0x7a0c('0x47')][_0x7a0c('0x22')]);}return _0x57ee22[_0x7a0c('0xdf')](_0x35df9d);}})['then'](function(_0x545619){if(_0x545619){return _0x545619?{'count':_0x41b88d,'rows':_0x545619}:null;}})[_0x7a0c('0x15')](respondWithResult(_0x1e493b,null))[_0x7a0c('0x1f')](handleError(_0x1e493b,null));};exports[_0x7a0c('0xe1')]=function(_0x2e0b73,_0x9d8ebe){var _0x55cbe1={};var _0x1a3742={};var _0x3b64e8;var _0x337ee7;return db['User'][_0x7a0c('0x9a')]({'where':{'id':_0x2e0b73[_0x7a0c('0x63')]['id']}})['then'](handleEntityNotFound(_0x9d8ebe,null))['then'](function(_0x51f9bb){if(_0x51f9bb){_0x3b64e8=_0x51f9bb;_0x1a3742[_0x7a0c('0x59')]=_[_0x7a0c('0x5b')](db[_0x7a0c('0xe2')][_0x7a0c('0x3e')]);_0x1a3742['query']=_[_0x7a0c('0x5b')](_0x2e0b73['query']);_0x1a3742[_0x7a0c('0x5c')]=_[_0x7a0c('0x5d')](_0x1a3742[_0x7a0c('0x59')],_0x1a3742['query']);_0x55cbe1[_0x7a0c('0x4d')]=_[_0x7a0c('0x5d')](_0x1a3742[_0x7a0c('0x59')],qs[_0x7a0c('0x5e')](_0x2e0b73[_0x7a0c('0x47')][_0x7a0c('0x5e')]));_0x55cbe1[_0x7a0c('0x4d')]=_0x55cbe1['attributes']['length']?_0x55cbe1['attributes']:_0x1a3742[_0x7a0c('0x59')];_0x55cbe1[_0x7a0c('0xe0')]=qs[_0x7a0c('0xd2')](_0x2e0b73[_0x7a0c('0x47')][_0x7a0c('0xd2')]);_0x55cbe1[_0x7a0c('0x45')]=qs[_0x7a0c('0x5c')](_[_0x7a0c('0xd3')](_0x2e0b73[_0x7a0c('0x47')],_0x1a3742[_0x7a0c('0x5c')]));if(_0x2e0b73['query'][_0x7a0c('0xd4')]){_0x55cbe1[_0x7a0c('0x45')]=_[_0x7a0c('0xd5')](_0x55cbe1[_0x7a0c('0x45')],{'$or':_[_0x7a0c('0x33')](_0x55cbe1['attributes'],function(_0x179ccf){var _0x225bca={};_0x225bca[_0x179ccf]={'$like':'%'+_0x2e0b73[_0x7a0c('0x47')][_0x7a0c('0xd4')]+'%'};return _0x225bca;})});}_0x55cbe1=_[_0x7a0c('0xd5')]({},_0x55cbe1,_0x2e0b73[_0x7a0c('0x5f')]);return _0x3b64e8[_0x7a0c('0xe1')](_0x55cbe1);}})[_0x7a0c('0x15')](function(_0x4c78c4){if(_0x4c78c4){_0x337ee7=_0x4c78c4[_0x7a0c('0x50')];if(!_0x2e0b73[_0x7a0c('0x47')][_0x7a0c('0xd6')](_0x7a0c('0xdb'))){_0x55cbe1[_0x7a0c('0x24')]=qs[_0x7a0c('0x24')](_0x2e0b73['query'][_0x7a0c('0x24')]);_0x55cbe1[_0x7a0c('0x22')]=qs['offset'](_0x2e0b73[_0x7a0c('0x47')][_0x7a0c('0x22')]);}return _0x3b64e8[_0x7a0c('0xe1')](_0x55cbe1);}})[_0x7a0c('0x15')](function(_0x2d1f4b){if(_0x2d1f4b){return _0x2d1f4b?{'count':_0x337ee7,'rows':_0x2d1f4b}:null;}})[_0x7a0c('0x15')](respondWithResult(_0x9d8ebe,null))[_0x7a0c('0x1f')](handleError(_0x9d8ebe,null));};exports[_0x7a0c('0xe3')]=function(_0x2ec5c6,_0x2f0e5b){var _0x5f119b={'raw':!![],'where':{}};var _0xb3a19a={};var _0xb5c821={'count':0x0,'rows':[]};return db['User'][_0x7a0c('0x9a')]({'where':{'id':_0x2ec5c6[_0x7a0c('0x63')]['id']}})[_0x7a0c('0x15')](handleEntityNotFound(_0x2f0e5b,null))[_0x7a0c('0x15')](function(_0x1ab41d){if(_0x1ab41d){_0xb3a19a['model']=_[_0x7a0c('0x5b')](db['VoiceRecording'][_0x7a0c('0x3e')]);_0xb3a19a[_0x7a0c('0x47')]=_[_0x7a0c('0x5b')](_0x2ec5c6[_0x7a0c('0x47')]);_0xb3a19a['filters']=_[_0x7a0c('0x5d')](_0xb3a19a[_0x7a0c('0x59')],_0xb3a19a[_0x7a0c('0x47')]);_0x5f119b['attributes']=_['intersection'](_0xb3a19a['model'],qs[_0x7a0c('0x5e')](_0x2ec5c6['query']['fields']));_0x5f119b[_0x7a0c('0x4d')]=_0x5f119b[_0x7a0c('0x4d')][_0x7a0c('0x50')]?_0x5f119b['attributes']:_0xb3a19a[_0x7a0c('0x59')];if(!_0x2ec5c6[_0x7a0c('0x47')][_0x7a0c('0xd6')]('nolimit')){_0x5f119b[_0x7a0c('0x24')]=qs[_0x7a0c('0x24')](_0x2ec5c6['query'][_0x7a0c('0x24')]);_0x5f119b[_0x7a0c('0x22')]=qs['offset'](_0x2ec5c6[_0x7a0c('0x47')]['offset']);}_0x5f119b[_0x7a0c('0xe0')]=qs[_0x7a0c('0xd2')](_0x2ec5c6[_0x7a0c('0x47')][_0x7a0c('0xd2')]);_0x5f119b[_0x7a0c('0x45')]=qs[_0x7a0c('0x5c')](_[_0x7a0c('0xd3')](_0x2ec5c6[_0x7a0c('0x47')],_0xb3a19a[_0x7a0c('0x5c')]));_0x5f119b[_0x7a0c('0x45')][_0x7a0c('0xe4')]=_0x1ab41d['id'];if(_0x2ec5c6[_0x7a0c('0x47')]['filter']){_0x5f119b[_0x7a0c('0x45')]=_[_0x7a0c('0xd5')](_0x5f119b['where'],{'$or':_[_0x7a0c('0x33')](_0x5f119b['attributes'],function(_0x30d832){var _0x447784={};_0x447784[_0x30d832]={'$like':'%'+_0x2ec5c6[_0x7a0c('0x47')]['filter']+'%'};return _0x447784;})});}_0x5f119b=_[_0x7a0c('0xd5')]({},_0x5f119b,_0x2ec5c6[_0x7a0c('0x5f')]);return db[_0x7a0c('0xe5')][_0x7a0c('0x25')]({'where':_0x5f119b[_0x7a0c('0x45')]})[_0x7a0c('0x15')](function(_0xb877e0){_0xb5c821['count']=_0xb877e0;if(_0x2ec5c6[_0x7a0c('0x47')][_0x7a0c('0x48')]){_0x5f119b['include']=[{'all':!![]}];}return db[_0x7a0c('0xe5')][_0x7a0c('0x8e')](_0x5f119b);})[_0x7a0c('0x15')](function(_0x3dbe8b){_0xb5c821[_0x7a0c('0x4f')]=_0x3dbe8b;return _0xb5c821;});}})[_0x7a0c('0x15')](respondWithFilteredResult(_0x2f0e5b,_0x5f119b))['catch'](handleError(_0x2f0e5b,null));};exports['getScreenRecordings']=function(_0x569771,_0x5a805a){var _0x58c9db={'raw':!![],'where':{}};var _0x35b8c7={};var _0xd341f8={'count':0x0,'rows':[]};return db['User'][_0x7a0c('0x9a')]({'where':{'id':_0x569771['params']['id']}})[_0x7a0c('0x15')](handleEntityNotFound(_0x5a805a,null))['then'](function(_0x115f46){if(_0x115f46){_0x35b8c7['model']=_['keys'](db['ScreenRecording'][_0x7a0c('0x3e')]);_0x35b8c7[_0x7a0c('0x47')]=_['keys'](_0x569771[_0x7a0c('0x47')]);_0x35b8c7[_0x7a0c('0x5c')]=_['intersection'](_0x35b8c7['model'],_0x35b8c7[_0x7a0c('0x47')]);_0x58c9db[_0x7a0c('0x4d')]=_['intersection'](_0x35b8c7[_0x7a0c('0x59')],qs[_0x7a0c('0x5e')](_0x569771[_0x7a0c('0x47')]['fields']));_0x58c9db[_0x7a0c('0x4d')]=_0x58c9db[_0x7a0c('0x4d')][_0x7a0c('0x50')]?_0x58c9db[_0x7a0c('0x4d')]:_0x35b8c7[_0x7a0c('0x59')];if(!_0x569771['query'][_0x7a0c('0xd6')]('nolimit')){_0x58c9db[_0x7a0c('0x24')]=qs['limit'](_0x569771[_0x7a0c('0x47')][_0x7a0c('0x24')]);_0x58c9db['offset']=qs['offset'](_0x569771[_0x7a0c('0x47')][_0x7a0c('0x22')]);}_0x58c9db[_0x7a0c('0xe0')]=qs[_0x7a0c('0xd2')](_0x569771['query'][_0x7a0c('0xd2')]);_0x58c9db[_0x7a0c('0x45')]=qs[_0x7a0c('0x5c')](_[_0x7a0c('0xd3')](_0x569771[_0x7a0c('0x47')],_0x35b8c7[_0x7a0c('0x5c')]));_0x58c9db[_0x7a0c('0x45')][_0x7a0c('0xe4')]=_0x115f46['id'];if(_0x569771[_0x7a0c('0x47')][_0x7a0c('0xd4')]){_0x58c9db['where']=_[_0x7a0c('0xd5')](_0x58c9db[_0x7a0c('0x45')],{'$or':_[_0x7a0c('0x33')](_0x58c9db[_0x7a0c('0x4d')],function(_0x5dceba){var _0x3dc234={};_0x3dc234[_0x5dceba]={'$like':'%'+_0x569771[_0x7a0c('0x47')][_0x7a0c('0xd4')]+'%'};return _0x3dc234;})});}_0x58c9db=_[_0x7a0c('0xd5')]({},_0x58c9db,_0x569771[_0x7a0c('0x5f')]);return db[_0x7a0c('0xe6')][_0x7a0c('0x25')]({'where':_0x58c9db[_0x7a0c('0x45')]})[_0x7a0c('0x15')](function(_0x2d72d0){_0xd341f8[_0x7a0c('0x25')]=_0x2d72d0;if(_0x569771['query']['includeAll']){_0x58c9db['include']=[{'all':!![]}];}return db['ScreenRecording'][_0x7a0c('0x8e')](_0x58c9db);})[_0x7a0c('0x15')](function(_0x49a8dd){_0xd341f8[_0x7a0c('0x4f')]=_0x49a8dd;return _0xd341f8;});}})['then'](respondWithFilteredResult(_0x5a805a,_0x58c9db))[_0x7a0c('0x1f')](handleError(_0x5a805a,null));};exports[_0x7a0c('0xe7')]=function(_0x3e5082,_0xfe53cb){var _0x1034f5={};var _0x208643={};var _0x55de4e;var _0x5aae53;return db[_0x7a0c('0x46')][_0x7a0c('0x9a')]({'where':{'id':_0x3e5082[_0x7a0c('0x63')]['id']}})[_0x7a0c('0x15')](handleEntityNotFound(_0xfe53cb,null))[_0x7a0c('0x15')](function(_0x42cb66){if(_0x42cb66){_0x55de4e=_0x42cb66;_0x208643[_0x7a0c('0x59')]=_[_0x7a0c('0x5b')](db['ChatInteraction']['rawAttributes']);_0x208643[_0x7a0c('0x47')]=_[_0x7a0c('0x5b')](_0x3e5082[_0x7a0c('0x47')]);_0x208643['filters']=_['intersection'](_0x208643[_0x7a0c('0x59')],_0x208643[_0x7a0c('0x47')]);_0x1034f5[_0x7a0c('0x4d')]=_[_0x7a0c('0x5d')](_0x208643['model'],qs[_0x7a0c('0x5e')](_0x3e5082[_0x7a0c('0x47')]['fields']));_0x1034f5[_0x7a0c('0x4d')]=_0x1034f5['attributes'][_0x7a0c('0x50')]?_0x1034f5[_0x7a0c('0x4d')]:_0x208643[_0x7a0c('0x59')];_0x1034f5[_0x7a0c('0xe0')]=qs[_0x7a0c('0xd2')](_0x3e5082[_0x7a0c('0x47')][_0x7a0c('0xd2')]);_0x1034f5['where']=qs[_0x7a0c('0x5c')](_[_0x7a0c('0xd3')](_0x3e5082[_0x7a0c('0x47')],_0x208643[_0x7a0c('0x5c')]));if(_0x3e5082['query'][_0x7a0c('0xd4')]){_0x1034f5[_0x7a0c('0x45')]=_[_0x7a0c('0xd5')](_0x1034f5[_0x7a0c('0x45')],{'$or':_[_0x7a0c('0x33')](_0x1034f5[_0x7a0c('0x4d')],function(_0x184828){var _0x3297b0={};_0x3297b0[_0x184828]={'$like':'%'+_0x3e5082[_0x7a0c('0x47')][_0x7a0c('0xd4')]+'%'};return _0x3297b0;})});}_0x1034f5=_[_0x7a0c('0xd5')]({},_0x1034f5,_0x3e5082[_0x7a0c('0x5f')]);return _0x55de4e[_0x7a0c('0xe7')](_0x1034f5);}})[_0x7a0c('0x15')](function(_0x5bf1ee){if(_0x5bf1ee){_0x5aae53=_0x5bf1ee[_0x7a0c('0x50')];if(!_0x3e5082[_0x7a0c('0x47')][_0x7a0c('0xd6')](_0x7a0c('0xdb'))){_0x1034f5[_0x7a0c('0x24')]=qs[_0x7a0c('0x24')](_0x3e5082[_0x7a0c('0x47')][_0x7a0c('0x24')]);_0x1034f5['offset']=qs[_0x7a0c('0x22')](_0x3e5082[_0x7a0c('0x47')][_0x7a0c('0x22')]);}return _0x55de4e[_0x7a0c('0xe7')](_0x1034f5);}})['then'](function(_0x179f64){if(_0x179f64){return _0x179f64?{'count':_0x5aae53,'rows':_0x179f64}:null;}})['then'](respondWithResult(_0xfe53cb,null))[_0x7a0c('0x1f')](handleError(_0xfe53cb,null));};exports[_0x7a0c('0xe8')]=function(_0x2e9242,_0x5e83ee){var _0x3b2107={};var _0x465aa2={};var _0x17f404;var _0x1b4a8c;return db[_0x7a0c('0x46')][_0x7a0c('0x9a')]({'where':{'id':_0x2e9242[_0x7a0c('0x63')]['id']}})[_0x7a0c('0x15')](handleEntityNotFound(_0x5e83ee,null))[_0x7a0c('0x15')](function(_0x2f244f){if(_0x2f244f){_0x17f404=_0x2f244f;_0x465aa2[_0x7a0c('0x59')]=_[_0x7a0c('0x5b')](db['OpenchannelInteraction']['rawAttributes']);_0x465aa2[_0x7a0c('0x47')]=_['keys'](_0x2e9242[_0x7a0c('0x47')]);_0x465aa2['filters']=_[_0x7a0c('0x5d')](_0x465aa2['model'],_0x465aa2[_0x7a0c('0x47')]);_0x3b2107[_0x7a0c('0x4d')]=_['intersection'](_0x465aa2[_0x7a0c('0x59')],qs['fields'](_0x2e9242[_0x7a0c('0x47')][_0x7a0c('0x5e')]));_0x3b2107['attributes']=_0x3b2107[_0x7a0c('0x4d')][_0x7a0c('0x50')]?_0x3b2107[_0x7a0c('0x4d')]:_0x465aa2[_0x7a0c('0x59')];_0x3b2107['order']=qs[_0x7a0c('0xd2')](_0x2e9242[_0x7a0c('0x47')][_0x7a0c('0xd2')]);_0x3b2107['where']=qs[_0x7a0c('0x5c')](_[_0x7a0c('0xd3')](_0x2e9242['query'],_0x465aa2[_0x7a0c('0x5c')]));if(_0x2e9242['query'][_0x7a0c('0xd4')]){_0x3b2107[_0x7a0c('0x45')]=_['merge'](_0x3b2107[_0x7a0c('0x45')],{'$or':_[_0x7a0c('0x33')](_0x3b2107[_0x7a0c('0x4d')],function(_0x22bb1c){var _0xbb5d0e={};_0xbb5d0e[_0x22bb1c]={'$like':'%'+_0x2e9242[_0x7a0c('0x47')][_0x7a0c('0xd4')]+'%'};return _0xbb5d0e;})});}_0x3b2107=_['merge']({},_0x3b2107,_0x2e9242[_0x7a0c('0x5f')]);return _0x17f404[_0x7a0c('0xe8')](_0x3b2107);}})[_0x7a0c('0x15')](function(_0x4c14b4){if(_0x4c14b4){_0x1b4a8c=_0x4c14b4[_0x7a0c('0x50')];if(!_0x2e9242[_0x7a0c('0x47')][_0x7a0c('0xd6')](_0x7a0c('0xdb'))){_0x3b2107[_0x7a0c('0x24')]=qs['limit'](_0x2e9242[_0x7a0c('0x47')][_0x7a0c('0x24')]);_0x3b2107[_0x7a0c('0x22')]=qs[_0x7a0c('0x22')](_0x2e9242['query'][_0x7a0c('0x22')]);}return _0x17f404[_0x7a0c('0xe8')](_0x3b2107);}})['then'](function(_0x2e79d8){if(_0x2e79d8){return _0x2e79d8?{'count':_0x1b4a8c,'rows':_0x2e79d8}:null;}})[_0x7a0c('0x15')](respondWithResult(_0x5e83ee,null))[_0x7a0c('0x1f')](handleError(_0x5e83ee,null));};exports[_0x7a0c('0xe9')]=function(_0x1842ff,_0x154584){var _0x30bd2a={'raw':!![],'where':{}};var _0x13a783={};var _0x2b0598={'count':0x0,'rows':[]};return db['User']['findOne']({'where':{'id':_0x1842ff['params']['id']}})[_0x7a0c('0x15')](handleEntityNotFound(_0x154584,null))['then'](function(_0x665e24){if(_0x665e24){_0x13a783[_0x7a0c('0x59')]=_['keys'](db[_0x7a0c('0xea')]['rawAttributes']);_0x13a783[_0x7a0c('0x47')]=_[_0x7a0c('0x5b')](_0x1842ff[_0x7a0c('0x47')]);_0x13a783[_0x7a0c('0x5c')]=_['intersection'](_0x13a783[_0x7a0c('0x59')],_0x13a783['query']);_0x30bd2a['attributes']=_[_0x7a0c('0x5d')](_0x13a783[_0x7a0c('0x59')],qs['fields'](_0x1842ff[_0x7a0c('0x47')]['fields']));_0x30bd2a[_0x7a0c('0x4d')]=_0x30bd2a[_0x7a0c('0x4d')][_0x7a0c('0x50')]?_0x30bd2a['attributes']:_0x13a783[_0x7a0c('0x59')];if(!_0x1842ff[_0x7a0c('0x47')][_0x7a0c('0xd6')]('nolimit')){_0x30bd2a[_0x7a0c('0x24')]=qs[_0x7a0c('0x24')](_0x1842ff[_0x7a0c('0x47')]['limit']);_0x30bd2a['offset']=qs['offset'](_0x1842ff[_0x7a0c('0x47')][_0x7a0c('0x22')]);}_0x30bd2a['order']=qs['sort'](_0x1842ff[_0x7a0c('0x47')][_0x7a0c('0xd2')]);_0x30bd2a['where']=qs['filters'](_['pick'](_0x1842ff['query'],_0x13a783[_0x7a0c('0x5c')]));_0x30bd2a[_0x7a0c('0x45')][_0x7a0c('0xe4')]=_0x665e24['id'];if(_0x1842ff[_0x7a0c('0x47')]['filter']){_0x30bd2a[_0x7a0c('0x45')]=_['merge'](_0x30bd2a[_0x7a0c('0x45')],{'$or':_[_0x7a0c('0x33')](_0x30bd2a[_0x7a0c('0x4d')],function(_0x385cd0){var _0x50e4d7={};_0x50e4d7[_0x385cd0]={'$like':'%'+_0x1842ff[_0x7a0c('0x47')][_0x7a0c('0xd4')]+'%'};return _0x50e4d7;})});}_0x30bd2a=_[_0x7a0c('0xd5')]({},_0x30bd2a,_0x1842ff[_0x7a0c('0x5f')]);return db[_0x7a0c('0xea')][_0x7a0c('0x25')]({'where':_0x30bd2a[_0x7a0c('0x45')]})[_0x7a0c('0x15')](function(_0x23df24){_0x2b0598[_0x7a0c('0x25')]=_0x23df24;if(_0x1842ff['query']['includeAll']){_0x30bd2a[_0x7a0c('0x49')]=[{'all':!![]}];}return db[_0x7a0c('0xea')][_0x7a0c('0x8e')](_0x30bd2a);})['then'](function(_0x3ca816){_0x2b0598['rows']=_0x3ca816;return _0x2b0598;});}})[_0x7a0c('0x15')](respondWithFilteredResult(_0x154584,_0x30bd2a))[_0x7a0c('0x1f')](handleError(_0x154584,null));};exports[_0x7a0c('0xeb')]=function(_0x5f30cf,_0x56a919){var _0x5df48f={};var _0x7eec29={};var _0x23b3d9;var _0x2d0c6f;return db[_0x7a0c('0x46')][_0x7a0c('0x9a')]({'where':{'id':_0x5f30cf[_0x7a0c('0x63')]['id']}})[_0x7a0c('0x15')](handleEntityNotFound(_0x56a919,null))[_0x7a0c('0x15')](function(_0x166bb4){if(_0x166bb4){_0x23b3d9=_0x166bb4;_0x7eec29[_0x7a0c('0x59')]=_['keys'](db[_0x7a0c('0xec')][_0x7a0c('0x3e')]);_0x7eec29[_0x7a0c('0x47')]=_['keys'](_0x5f30cf[_0x7a0c('0x47')]);_0x7eec29[_0x7a0c('0x5c')]=_['intersection'](_0x7eec29[_0x7a0c('0x59')],_0x7eec29[_0x7a0c('0x47')]);_0x5df48f[_0x7a0c('0x4d')]=_[_0x7a0c('0x5d')](_0x7eec29['model'],qs[_0x7a0c('0x5e')](_0x5f30cf['query'][_0x7a0c('0x5e')]));_0x5df48f[_0x7a0c('0x4d')]=_0x5df48f['attributes'][_0x7a0c('0x50')]?_0x5df48f[_0x7a0c('0x4d')]:_0x7eec29[_0x7a0c('0x59')];_0x5df48f[_0x7a0c('0xe0')]=qs[_0x7a0c('0xd2')](_0x5f30cf[_0x7a0c('0x47')]['sort']);_0x5df48f[_0x7a0c('0x45')]=qs[_0x7a0c('0x5c')](_[_0x7a0c('0xd3')](_0x5f30cf[_0x7a0c('0x47')],_0x7eec29[_0x7a0c('0x5c')]));if(_0x5f30cf[_0x7a0c('0x47')][_0x7a0c('0xd4')]){_0x5df48f[_0x7a0c('0x45')]=_['merge'](_0x5df48f[_0x7a0c('0x45')],{'$or':_['map'](_0x5df48f['attributes'],function(_0x16a194){var _0x5808c0={};_0x5808c0[_0x16a194]={'$like':'%'+_0x5f30cf['query'][_0x7a0c('0xd4')]+'%'};return _0x5808c0;})});}_0x5df48f=_[_0x7a0c('0xd5')]({},_0x5df48f,_0x5f30cf['options']);return _0x23b3d9[_0x7a0c('0xeb')](_0x5df48f);}})['then'](function(_0x288197){if(_0x288197){_0x2d0c6f=_0x288197[_0x7a0c('0x50')];if(!_0x5f30cf['query']['hasOwnProperty']('nolimit')){_0x5df48f[_0x7a0c('0x24')]=qs[_0x7a0c('0x24')](_0x5f30cf[_0x7a0c('0x47')]['limit']);_0x5df48f[_0x7a0c('0x22')]=qs['offset'](_0x5f30cf['query']['offset']);}return _0x23b3d9['getSmsInteractions'](_0x5df48f);}})[_0x7a0c('0x15')](function(_0x18f535){if(_0x18f535){return _0x18f535?{'count':_0x2d0c6f,'rows':_0x18f535}:null;}})['then'](respondWithResult(_0x56a919,null))[_0x7a0c('0x1f')](handleError(_0x56a919,null));};exports[_0x7a0c('0xed')]=function(_0x40061f,_0x6c4f15){var _0x2d6826={};var _0x54596d={};var _0x456a26;var _0x6ef96c;return db[_0x7a0c('0x46')][_0x7a0c('0x9a')]({'where':{'id':_0x40061f[_0x7a0c('0x63')]['id']}})[_0x7a0c('0x15')](handleEntityNotFound(_0x6c4f15,null))[_0x7a0c('0x15')](function(_0x2f3420){if(_0x2f3420){_0x456a26=_0x2f3420;_0x54596d[_0x7a0c('0x59')]=_[_0x7a0c('0x5b')](db[_0x7a0c('0xee')][_0x7a0c('0x3e')]);_0x54596d[_0x7a0c('0x47')]=_[_0x7a0c('0x5b')](_0x40061f[_0x7a0c('0x47')]);_0x54596d['filters']=_[_0x7a0c('0x5d')](_0x54596d['model'],_0x54596d[_0x7a0c('0x47')]);_0x2d6826[_0x7a0c('0x4d')]=_[_0x7a0c('0x5d')](_0x54596d[_0x7a0c('0x59')],qs['fields'](_0x40061f['query'][_0x7a0c('0x5e')]));_0x2d6826[_0x7a0c('0x4d')]=_0x2d6826[_0x7a0c('0x4d')]['length']?_0x2d6826[_0x7a0c('0x4d')]:_0x54596d[_0x7a0c('0x59')];_0x2d6826[_0x7a0c('0xe0')]=qs[_0x7a0c('0xd2')](_0x40061f[_0x7a0c('0x47')]['sort']);_0x2d6826[_0x7a0c('0x45')]=qs[_0x7a0c('0x5c')](_[_0x7a0c('0xd3')](_0x40061f[_0x7a0c('0x47')],_0x54596d[_0x7a0c('0x5c')]));if(_0x40061f[_0x7a0c('0x47')][_0x7a0c('0xd4')]){_0x2d6826[_0x7a0c('0x45')]=_[_0x7a0c('0xd5')](_0x2d6826[_0x7a0c('0x45')],{'$or':_[_0x7a0c('0x33')](_0x2d6826[_0x7a0c('0x4d')],function(_0x2aa558){var _0x52f633={};_0x52f633[_0x2aa558]={'$like':'%'+_0x40061f[_0x7a0c('0x47')][_0x7a0c('0xd4')]+'%'};return _0x52f633;})});}_0x2d6826=_[_0x7a0c('0xd5')]({},_0x2d6826,_0x40061f['options']);return _0x456a26['getFaxInteractions'](_0x2d6826);}})[_0x7a0c('0x15')](function(_0x42b06d){if(_0x42b06d){_0x6ef96c=_0x42b06d[_0x7a0c('0x50')];if(!_0x40061f['query'][_0x7a0c('0xd6')](_0x7a0c('0xdb'))){_0x2d6826['limit']=qs[_0x7a0c('0x24')](_0x40061f[_0x7a0c('0x47')]['limit']);_0x2d6826[_0x7a0c('0x22')]=qs[_0x7a0c('0x22')](_0x40061f[_0x7a0c('0x47')][_0x7a0c('0x22')]);}return _0x456a26[_0x7a0c('0xed')](_0x2d6826);}})[_0x7a0c('0x15')](function(_0x4c151a){if(_0x4c151a){return _0x4c151a?{'count':_0x6ef96c,'rows':_0x4c151a}:null;}})[_0x7a0c('0x15')](respondWithResult(_0x6c4f15,null))[_0x7a0c('0x1f')](handleError(_0x6c4f15,null));};exports[_0x7a0c('0xef')]=function(_0x389ade,_0x27b031){var _0x2c9518={};var _0x50338c={};var _0x5f23c7;var _0x5b931a;return db[_0x7a0c('0x46')]['findOne']({'where':{'id':_0x389ade[_0x7a0c('0x63')]['id']}})['then'](handleEntityNotFound(_0x27b031,null))[_0x7a0c('0x15')](function(_0x495385){if(_0x495385){_0x5f23c7=_0x495385;_0x50338c['model']=_[_0x7a0c('0x5b')](db[_0x7a0c('0xf0')][_0x7a0c('0x3e')]);_0x50338c[_0x7a0c('0x47')]=_['keys'](_0x389ade[_0x7a0c('0x47')]);_0x50338c[_0x7a0c('0x5c')]=_[_0x7a0c('0x5d')](_0x50338c[_0x7a0c('0x59')],_0x50338c['query']);_0x2c9518[_0x7a0c('0x4d')]=_[_0x7a0c('0x5d')](_0x50338c['model'],qs['fields'](_0x389ade['query']['fields']));_0x2c9518[_0x7a0c('0x4d')]=_0x2c9518[_0x7a0c('0x4d')]['length']?_0x2c9518[_0x7a0c('0x4d')]:_0x50338c[_0x7a0c('0x59')];_0x2c9518[_0x7a0c('0xe0')]=qs[_0x7a0c('0xd2')](_0x389ade['query'][_0x7a0c('0xd2')]);_0x2c9518['where']=qs[_0x7a0c('0x5c')](_[_0x7a0c('0xd3')](_0x389ade[_0x7a0c('0x47')],_0x50338c[_0x7a0c('0x5c')]));if(_0x389ade[_0x7a0c('0x47')]['filter']){_0x2c9518[_0x7a0c('0x45')]=_[_0x7a0c('0xd5')](_0x2c9518[_0x7a0c('0x45')],{'$or':_['map'](_0x2c9518[_0x7a0c('0x4d')],function(_0x4eebbe){var _0x942fe6={};_0x942fe6[_0x4eebbe]={'$like':'%'+_0x389ade[_0x7a0c('0x47')]['filter']+'%'};return _0x942fe6;})});}_0x2c9518=_[_0x7a0c('0xd5')]({},_0x2c9518,_0x389ade['options']);return _0x5f23c7[_0x7a0c('0xef')](_0x2c9518);}})[_0x7a0c('0x15')](function(_0x40a62a){if(_0x40a62a){_0x5b931a=_0x40a62a['length'];if(!_0x389ade[_0x7a0c('0x47')]['hasOwnProperty'](_0x7a0c('0xdb'))){_0x2c9518['limit']=qs[_0x7a0c('0x24')](_0x389ade['query'][_0x7a0c('0x24')]);_0x2c9518[_0x7a0c('0x22')]=qs[_0x7a0c('0x22')](_0x389ade['query'][_0x7a0c('0x22')]);}return _0x5f23c7[_0x7a0c('0xef')](_0x2c9518);}})[_0x7a0c('0x15')](function(_0x36c9c6){if(_0x36c9c6){return _0x36c9c6?{'count':_0x5b931a,'rows':_0x36c9c6}:null;}})['then'](respondWithResult(_0x27b031,null))[_0x7a0c('0x1f')](handleError(_0x27b031,null));};exports['login']=function(_0x4a7e1e,_0x1e9840,_0x35fdc5){var _0xb4b72f;var _0x3308c2;var _0x4aae07;var _0x4a9077=!_[_0x7a0c('0x6c')](_0x4a7e1e[_0x7a0c('0x63')]['id'])?_0x4a7e1e[_0x7a0c('0x63')]['id']:!_['isNil'](_0x4a7e1e[_0x7a0c('0x2e')]['id'])?_0x4a7e1e[_0x7a0c('0x2e')]['id']:null;return db[_0x7a0c('0x46')]['find']({'where':{'id':_0x4a9077,'role':{'$or':[_0x7a0c('0x2c'),_0x7a0c('0x2e'),_0x7a0c('0x30')]}},'attributes':['id',_0x7a0c('0x37'),_0x7a0c('0xf1'),'mobile',_0x7a0c('0x2b'),'internal',_0x7a0c('0xa3')]})['then'](function(_0x282fe8){if(_0x282fe8){if(_0x282fe8[_0x7a0c('0x2b')]===_0x7a0c('0x30')){_0xb4b72f=_0x282fe8;if(_0x4a7e1e[_0x7a0c('0x62')][_0x7a0c('0xa5')]){_0x4aae07=util[_0x7a0c('0xb0')](_0x7a0c('0xf2'),_0xb4b72f[_0x4a7e1e[_0x7a0c('0x62')]['interface']]);}else if(_0x4a7e1e[_0x7a0c('0x62')]['intrf']){_0x4aae07=util[_0x7a0c('0xb0')](_0x7a0c('0xf3'),_0x4a7e1e['body'][_0x7a0c('0xf4')]);}else{_0x4aae07=util[_0x7a0c('0xb0')]('SIP/%s',_0xb4b72f[_0x7a0c('0x37')]);}socket['to'](util[_0x7a0c('0xb0')](_0x7a0c('0xf5'),_0xb4b72f[_0x7a0c('0x37')]))['emit']('user:forcelogout',{'user':{'id':_0xb4b72f['id'],'name':_0xb4b72f[_0x7a0c('0x37')]},'ip':_0x4a7e1e['headers'][_0x7a0c('0xf6')]||_0x4a7e1e['connection'][_0x7a0c('0xf7')]||_0x4a7e1e[_0x7a0c('0xf8')][_0x7a0c('0xf7')]||_0x4a7e1e[_0x7a0c('0xf9')]['socket']['remoteAddress']});return db['UserVoiceQueueRt'][_0x7a0c('0x29')]({'where':{'membername':_0xb4b72f[_0x7a0c('0x37')]},'individualHooks':!![]});}}else{throw new db[(_0x7a0c('0x95'))]['ValidationError'](_0x7a0c('0xfa'));}})[_0x7a0c('0x15')](function(){if(_0xb4b72f){return _0xb4b72f['getVoiceQueues']({'raw':!![]});}})[_0x7a0c('0x15')](function(_0x2465b6){if(_0xb4b72f){var _0x1bd203=[];if(_0x2465b6){_0x3308c2=_0x2465b6;if(_0x3308c2[_0x7a0c('0x50')]){for(var _0xd09659=0x0;_0xd09659<_0x3308c2[_0x7a0c('0x50')];_0xd09659++){_0x1bd203[_0x7a0c('0x4e')]({'membername':_0xb4b72f['name'],'UserId':_0xb4b72f['id'],'queue_name':_0x3308c2[_0xd09659]['name'],'VoiceQueueId':_0x3308c2[_0xd09659]['id'],'interface':_0x4aae07,'paused':_0xb4b72f[_0x7a0c('0xa3')]||![],'penalty':_0x3308c2[_0xd09659]['UserVoiceQueue.penalty']||0x0});}return BPromise[_0x7a0c('0x8d')](_0x1bd203,function(_0x7ac04){return db['UserVoiceQueueRt']['upsert'](_0x7ac04);});}}}})[_0x7a0c('0x15')](function(){if(_0xb4b72f){return db[_0x7a0c('0xfb')][_0x7a0c('0x8e')]({'where':{'membername':_0xb4b72f[_0x7a0c('0x37')],'exitAt':null}});}})[_0x7a0c('0x15')](function(_0x2a3b1e){if(_0xb4b72f){var _0x28e647=[];_0x2a3b1e[_0x7a0c('0xfc')](function(_0x59b70f){_0x28e647['push'](_0x59b70f[_0x7a0c('0x28')]({'exitAt':moment()[_0x7a0c('0xb0')](_0x7a0c('0xfd'))}));});return BPromise[_0x7a0c('0x57')](_0x28e647);}})[_0x7a0c('0x15')](function(){if(_0xb4b72f){var _0x132eea=[];var _0x4d8637=[];var _0x5c7ec8=utils[_0x7a0c('0xfe')]();var _0x1e49b3={'membername':_0xb4b72f[_0x7a0c('0x37')],'interface':_0x4aae07,'enterAt':moment()[_0x7a0c('0xb0')]('YYYY-MM-DD\x20HH:mm:ss'),'role':_0xb4b72f[_0x7a0c('0x2b')],'internal':_0xb4b72f[_0x7a0c('0x68')]};_0x5c7ec8['forEach'](function(_0x3b8048){_0x132eea[_0x7a0c('0x4e')](_[_0x7a0c('0xd5')]({'channel':_0x3b8048,'type':'LOGIN','data1':_0x4a7e1e['body'][_0x7a0c('0xff')],'data2':_0x4aae07},_0x1e49b3));if(_0xb4b72f[_0x7a0c('0xa3')]){_0x4d8637[_0x7a0c('0x4e')](_[_0x7a0c('0xd5')]({'channel':_0x3b8048,'type':_0x7a0c('0x100'),'data1':_0x7a0c('0x101')},_0x1e49b3));}});return db['MemberReport'][_0x7a0c('0x102')](_0x132eea[_0x7a0c('0xcf')](_0x4d8637),{'individualHooks':!![]});}})[_0x7a0c('0x15')](function(){if(_0xb4b72f){return _0xb4b72f[_0x7a0c('0x28')]({'online':!![],'lastLoginAt':moment()[_0x7a0c('0xb0')](_0x7a0c('0xfd')),'voicePause':_0xb4b72f[_0x7a0c('0xa3')]||![],'mailPause':_0xb4b72f[_0x7a0c('0xa3')]||![],'chatPause':_0xb4b72f[_0x7a0c('0xa3')]||![],'faxPause':_0xb4b72f[_0x7a0c('0xa3')]||![],'smsPause':_0xb4b72f['loginInPause']||![],'openchannelPause':_0xb4b72f[_0x7a0c('0xa3')]||![],'whatsappPause':_0xb4b72f['loginInPause']||![],'pauseType':_0xb4b72f[_0x7a0c('0xa3')]?_0x7a0c('0x101'):null,'interface':_0x4aae07,'lastPauseAt':moment()['format'](_0x7a0c('0xfd'))});}})[_0x7a0c('0x15')](function(_0x1e4bc8){if(_0x4a7e1e[_0x7a0c('0x103')]){return _0x35fdc5();}else{return BPromise['resolve'](_0x1e4bc8)[_0x7a0c('0x15')](respondWithResult(_0x1e9840,null));}})[_0x7a0c('0x1f')](handleError(_0x1e9840,null));};exports[_0x7a0c('0x104')]=function(_0x2e7588,_0x22edc7){var _0x40d8a0;return db['User']['find']({'where':{'id':_0x2e7588[_0x7a0c('0x63')]['id'],'role':'agent'},'attributes':['id',_0x7a0c('0x37'),_0x7a0c('0x2b')]})['then'](handleEntityNotFound(_0x22edc7,null))[_0x7a0c('0x15')](function(_0x51323f){if(_0x51323f){_0x40d8a0=_0x51323f;return db['UserVoiceQueueRt'][_0x7a0c('0x29')]({'where':{'membername':_0x40d8a0['name']},'individualHooks':!![]});}})['then'](function(){return db[_0x7a0c('0xfb')]['findAll']({'where':{'membername':_0x40d8a0[_0x7a0c('0x37')],'exitAt':null}});})[_0x7a0c('0x15')](function(_0x240f60){var _0x429330=[];_0x240f60[_0x7a0c('0xfc')](function(_0x397b19){_0x429330[_0x7a0c('0x4e')](_0x397b19['update']({'exitAt':moment()['format'](_0x7a0c('0xfd'))}));});return BPromise['all'](_0x429330);})[_0x7a0c('0x15')](function(){return _0x40d8a0[_0x7a0c('0x28')]({'online':![],'voicePause':![],'mailPause':![],'chatPause':![],'faxPause':![],'smsPause':![],'openchannelPause':![],'whatsappPause':![],'interface':null});})['then'](respondWithResult(_0x22edc7,null))['catch'](handleError(_0x22edc7,null));};exports['pause']=function(_0x4dbe8c,_0x55ec44){var _0x6b56bd;return db[_0x7a0c('0xb1')][_0x7a0c('0x28')]({'paused':0x1},{'where':{'UserId':_0x4dbe8c[_0x7a0c('0x63')]['id']},'individualHooks':!![]})['then'](function(){return db[_0x7a0c('0x46')][_0x7a0c('0x36')]({'where':{'id':_0x4dbe8c[_0x7a0c('0x63')]['id'],'role':_0x7a0c('0x30')},'attributes':['id','name','role',_0x7a0c('0x68'),_0x7a0c('0xa5')]});})[_0x7a0c('0x15')](handleEntityNotFound(_0x55ec44,null))[_0x7a0c('0x15')](function(_0xb34f84){if(_0xb34f84){_0x6b56bd=_0xb34f84;return respondWithRpcPromise(_0x7a0c('0x105'),'pause',{'id':_0x6b56bd['id'],'name':_0x6b56bd[_0x7a0c('0x37')],'pause':!![]});}})[_0x7a0c('0x15')](function(){if(_0x6b56bd){return db[_0x7a0c('0xfb')][_0x7a0c('0x8e')]({'where':{'membername':_0x6b56bd[_0x7a0c('0x37')],'type':_0x7a0c('0x100'),'exitAt':null}});}})['then'](function(_0x3af5ed){if(_0x3af5ed[_0x7a0c('0x50')]){var _0x2e9f35=moment()['format'](_0x7a0c('0xfd'));for(var _0x2827cf=0x0,_0x114752=_0x3af5ed[_0x7a0c('0x50')];_0x2827cf<_0x114752;_0x2827cf++){_0x3af5ed[_0x2827cf][_0x7a0c('0x106')]({'exitAt':_0x2e9f35});}}})[_0x7a0c('0x15')](function(){var _0x318274=[];var _0x4fe8e5=utils[_0x7a0c('0xfe')]();_0x4fe8e5[_0x7a0c('0xfc')](function(_0x4f612f){_0x318274[_0x7a0c('0x4e')]({'channel':_0x4f612f,'membername':_0x6b56bd[_0x7a0c('0x37')],'interface':_[_0x7a0c('0x6c')](_0x6b56bd[_0x7a0c('0xa5')])?util[_0x7a0c('0xb0')]('SIP/%s',_0x6b56bd[_0x7a0c('0x37')]):_0x6b56bd['interface'],'type':_0x7a0c('0x100'),'enterAt':moment()[_0x7a0c('0xb0')](_0x7a0c('0xfd')),'data1':_0x4dbe8c['body'][_0x7a0c('0x40')]||_0x7a0c('0x107'),'role':_0x6b56bd[_0x7a0c('0x2b')],'internal':_0x6b56bd[_0x7a0c('0x68')]});});return db[_0x7a0c('0xfb')]['bulkCreate'](_0x318274,{'individualHooks':!![]});})[_0x7a0c('0x15')](function(){return _0x6b56bd[_0x7a0c('0x28')]({'voicePause':!![],'mailPause':!![],'chatPause':!![],'faxPause':!![],'smsPause':!![],'whatsappPause':!![],'openchannelPause':!![],'pauseType':_0x4dbe8c[_0x7a0c('0x62')][_0x7a0c('0x40')]||_0x7a0c('0x107'),'lastPauseAt':moment()[_0x7a0c('0xb0')]('YYYY-MM-DD\x20HH:mm:ss')});})[_0x7a0c('0x15')](respondWithResult(_0x55ec44,null))[_0x7a0c('0x1f')](handleError(_0x55ec44,null));};exports[_0x7a0c('0x108')]=function(_0x55ec48,_0x50419f){var _0x3ffa9a;return db[_0x7a0c('0x46')][_0x7a0c('0x36')]({'where':{'id':_0x55ec48[_0x7a0c('0x63')]['id']},'attributes':['id',_0x7a0c('0x37'),_0x7a0c('0x2b'),_0x7a0c('0xa4'),'mailPause',_0x7a0c('0x109'),_0x7a0c('0x10a'),_0x7a0c('0x10b'),_0x7a0c('0x10c'),_0x7a0c('0x10d'),_0x7a0c('0x10e'),_0x7a0c('0x10f')]})[_0x7a0c('0x15')](handleEntityNotFound(_0x50419f,null))[_0x7a0c('0x15')](function(_0x35b74e){if(_0x35b74e){_0x3ffa9a=_0x35b74e;if(_0x55ec48['body'][_0x7a0c('0xb4')]&&!utils[_0x7a0c('0xb5')](_0x55ec48[_0x7a0c('0x62')]['channel'])){throw new db[(_0x7a0c('0x95'))][(_0x7a0c('0x96'))](_0x7a0c('0xa6'));}switch(_0x55ec48[_0x7a0c('0x62')][_0x7a0c('0xb4')]){case _0x7a0c('0xae'):return respondWithRpcPromise(_0x7a0c('0x105'),'unpause',{'id':_0x3ffa9a['id'],'name':_0x3ffa9a['name'],'pause':![]})[_0x7a0c('0x15')](function(){return db[_0x7a0c('0xb1')][_0x7a0c('0x28')]({'paused':0x0},{'where':{'UserId':_0x3ffa9a['id']},'individualHooks':!![]});})[_0x7a0c('0x15')](function(){return db['MemberReport'][_0x7a0c('0x36')]({'where':{'channel':_0x55ec48[_0x7a0c('0x62')]['channel'],'membername':_0x3ffa9a[_0x7a0c('0x37')],'type':_0x7a0c('0x100'),'exitAt':null}});})[_0x7a0c('0x15')](function(_0x12302a){if(_0x12302a){return _0x12302a['update']({'exitAt':moment()[_0x7a0c('0xb0')](_0x7a0c('0xfd')),'data2':_0x7a0c('0x110')},{'individualHooks':!![]});}return null;})[_0x7a0c('0x15')](function(){return _0x3ffa9a[_0x7a0c('0x28')]({'voicePause':![]});});case _0x7a0c('0x55'):case _0x7a0c('0x51'):case'fax':case _0x7a0c('0x53'):case _0x7a0c('0x56'):case _0x7a0c('0x61'):return db[_0x7a0c('0xfb')][_0x7a0c('0x36')]({'where':{'channel':_0x55ec48[_0x7a0c('0x62')][_0x7a0c('0xb4')],'membername':_0x3ffa9a[_0x7a0c('0x37')],'type':_0x7a0c('0x100'),'exitAt':null}})[_0x7a0c('0x15')](function(_0x36ca12){if(_0x36ca12){return _0x36ca12['update']({'exitAt':moment()[_0x7a0c('0xb0')](_0x7a0c('0xfd')),'data2':_0x7a0c('0x110')},{'individualHooks':!![]});}return null;})[_0x7a0c('0x15')](function(){var _0x30bbd1={};_[_0x7a0c('0x26')](_0x30bbd1,util[_0x7a0c('0xb0')](_0x7a0c('0x111'),_0x55ec48[_0x7a0c('0x62')]['channel'],_0x7a0c('0x112')),![]);return _0x3ffa9a['update'](_0x30bbd1);});default:return respondWithRpcPromise('QueuePause',_0x7a0c('0x108'),{'id':_0x3ffa9a['id'],'name':_0x3ffa9a['name'],'pause':![]})[_0x7a0c('0x15')](function(){return db['UserVoiceQueueRt'][_0x7a0c('0x28')]({'paused':0x0},{'where':{'UserId':_0x3ffa9a['id']}});})[_0x7a0c('0x15')](function(){return db[_0x7a0c('0xfb')][_0x7a0c('0x8e')]({'where':{'membername':_0x3ffa9a[_0x7a0c('0x37')],'type':_0x7a0c('0x100'),'exitAt':null}});})[_0x7a0c('0x15')](function(_0x5914e0){var _0x50afac=[];_0x5914e0[_0x7a0c('0xfc')](function(_0x3cc8fd){_0x50afac[_0x7a0c('0x4e')](_0x3cc8fd[_0x7a0c('0x28')]({'exitAt':moment()[_0x7a0c('0xb0')](_0x7a0c('0xfd')),'data2':'manual'}));});return BPromise['all'](_0x50afac);})[_0x7a0c('0x15')](function(){return _0x3ffa9a[_0x7a0c('0x28')]({'voicePause':![],'mailPause':![],'chatPause':![],'faxPause':![],'smsPause':![],'whatsappPause':![],'openchannelPause':![]});});}}})[_0x7a0c('0x15')](respondWithResult(_0x50419f,null))['catch'](handleError(_0x50419f,null));};exports['getTeams']=function(_0xe6e18f,_0x28f15f){var _0x57441b={};var _0x59d040={};var _0x365526;var _0x4bb235;return db[_0x7a0c('0x46')]['findOne']({'where':{'id':_0xe6e18f[_0x7a0c('0x63')]['id']}})[_0x7a0c('0x15')](handleEntityNotFound(_0x28f15f,null))[_0x7a0c('0x15')](function(_0x181dcb){if(_0x181dcb){_0x365526=_0x181dcb;_0x59d040['model']=_[_0x7a0c('0x5b')](db[_0x7a0c('0x113')][_0x7a0c('0x3e')]);_0x59d040[_0x7a0c('0x47')]=_[_0x7a0c('0x5b')](_0xe6e18f[_0x7a0c('0x47')]);_0x59d040[_0x7a0c('0x5c')]=_[_0x7a0c('0x5d')](_0x59d040['model'],_0x59d040[_0x7a0c('0x47')]);_0x57441b[_0x7a0c('0x4d')]=_['intersection'](_0x59d040[_0x7a0c('0x59')],qs[_0x7a0c('0x5e')](_0xe6e18f['query'][_0x7a0c('0x5e')]));_0x57441b['attributes']=_0x57441b[_0x7a0c('0x4d')][_0x7a0c('0x50')]?_0x57441b[_0x7a0c('0x4d')]:_0x59d040['model'];_0x57441b[_0x7a0c('0xe0')]=qs[_0x7a0c('0xd2')](_0xe6e18f[_0x7a0c('0x47')][_0x7a0c('0xd2')]);_0x57441b['where']=qs[_0x7a0c('0x5c')](_[_0x7a0c('0xd3')](_0xe6e18f[_0x7a0c('0x47')],_0x59d040[_0x7a0c('0x5c')]));if(_0xe6e18f[_0x7a0c('0x47')][_0x7a0c('0xd4')]){_0x57441b[_0x7a0c('0x45')]=_[_0x7a0c('0xd5')](_0x57441b[_0x7a0c('0x45')],{'$or':_['map'](_0x57441b['attributes'],function(_0x44857d){var _0x35663e={};_0x35663e[_0x44857d]={'$like':'%'+_0xe6e18f[_0x7a0c('0x47')][_0x7a0c('0xd4')]+'%'};return _0x35663e;})});}_0x57441b=_['merge']({},_0x57441b,_0xe6e18f[_0x7a0c('0x5f')]);return _0x365526[_0x7a0c('0x114')](_0x57441b);}})['then'](function(_0x4f309a){if(_0x4f309a){_0x4bb235=_0x4f309a['length'];if(!_0xe6e18f[_0x7a0c('0x47')][_0x7a0c('0xd6')](_0x7a0c('0xdb'))){_0x57441b[_0x7a0c('0x24')]=qs[_0x7a0c('0x24')](_0xe6e18f[_0x7a0c('0x47')]['limit']);_0x57441b[_0x7a0c('0x22')]=qs['offset'](_0xe6e18f[_0x7a0c('0x47')][_0x7a0c('0x22')]);}return _0x365526[_0x7a0c('0x114')](_0x57441b);}})[_0x7a0c('0x15')](function(_0x1a3a4b){if(_0x1a3a4b){return _0x1a3a4b?{'count':_0x4bb235,'rows':_0x1a3a4b}:null;}})[_0x7a0c('0x15')](respondWithResult(_0x28f15f,null))['catch'](handleError(_0x28f15f,null));};exports[_0x7a0c('0x115')]=function(_0x1e34e9,_0x5990ce){return db[_0x7a0c('0x46')][_0x7a0c('0x36')]({'where':{'id':_0x1e34e9[_0x7a0c('0x63')]['id']}})[_0x7a0c('0x15')](handleEntityNotFound(_0x5990ce,null))[_0x7a0c('0x15')](function(_0x5759b3){if(_0x5759b3){var _0x16541f=_0x5759b3['get']({'plain':!![]});return _0x5759b3['addTeams'](_0x1e34e9[_0x7a0c('0x62')][_0x7a0c('0x66')],_[_0x7a0c('0x67')](_0x1e34e9[_0x7a0c('0x62')],[_0x7a0c('0x66'),'id'])||{})[_0x7a0c('0x15')](function(){for(var _0x557718=0x0;_0x557718<_0x1e34e9[_0x7a0c('0x62')][_0x7a0c('0x66')][_0x7a0c('0x50')];_0x557718++){var _0x330bef=[];var _0xb7316e={};db['Team'][_0x7a0c('0x9a')]({'where':{'id':_0x1e34e9['body'][_0x7a0c('0x66')][_0x557718]}})[_0x7a0c('0x15')](function(_0x50c0e5){_0xb7316e=_0x50c0e5[_0x7a0c('0x52')];_0x330bef['push'](_0x50c0e5[_0x7a0c('0x116')]()['then'](function(_0xf18611){for(var _0x6196a=0x0;_0x6196a<_0xf18611[_0x7a0c('0x50')];_0x6196a++){_0xf18611[_0x6196a]['setDataValue'](_0x7a0c('0xb4'),'Voice');}return _0xf18611;}));_0x330bef[_0x7a0c('0x4e')](_0x50c0e5[_0x7a0c('0x117')]()['then'](function(_0x27e1fa){for(var _0x553023=0x0;_0x553023<_0x27e1fa['length'];_0x553023++){_0x27e1fa[_0x553023]['setDataValue'](_0x7a0c('0xb4'),_0x7a0c('0x118'));}return _0x27e1fa;}));_0x330bef['push'](_0x50c0e5['getMailQueues']()[_0x7a0c('0x15')](function(_0x16b404){for(var _0x1e67e1=0x0;_0x1e67e1<_0x16b404[_0x7a0c('0x50')];_0x1e67e1++){_0x16b404[_0x1e67e1][_0x7a0c('0x119')](_0x7a0c('0xb4'),_0x7a0c('0x11a'));}return _0x16b404;}));_0x330bef[_0x7a0c('0x4e')](_0x50c0e5[_0x7a0c('0x11b')]()[_0x7a0c('0x15')](function(_0x2507a1){for(var _0x346362=0x0;_0x346362<_0x2507a1[_0x7a0c('0x50')];_0x346362++){_0x2507a1[_0x346362][_0x7a0c('0x119')](_0x7a0c('0xb4'),'Sms');}return _0x2507a1;}));_0x330bef[_0x7a0c('0x4e')](_0x50c0e5['getWhatsappQueues']()[_0x7a0c('0x15')](function(_0x64e4ff){for(var _0x1d8477=0x0;_0x1d8477<_0x64e4ff[_0x7a0c('0x50')];_0x1d8477++){_0x64e4ff[_0x1d8477][_0x7a0c('0x119')](_0x7a0c('0xb4'),'Whatsapp');}return _0x64e4ff;}));_0x330bef[_0x7a0c('0x4e')](_0x50c0e5[_0x7a0c('0x11c')]()['then'](function(_0xb7377a){for(var _0x358531=0x0;_0x358531<_0xb7377a['length'];_0x358531++){_0xb7377a[_0x358531]['setDataValue'](_0x7a0c('0xb4'),_0x7a0c('0x11d'));}return _0xb7377a;}));_0x330bef[_0x7a0c('0x4e')](_0x50c0e5[_0x7a0c('0x11e')]()[_0x7a0c('0x15')](function(_0x40d52e){for(var _0x2bed09=0x0;_0x2bed09<_0x40d52e['length'];_0x2bed09++){_0x40d52e[_0x2bed09][_0x7a0c('0x119')]('channel',_0x7a0c('0x11f'));}return _0x40d52e;}));return BPromise[_0x7a0c('0x57')](_0x330bef);})[_0x7a0c('0x15')](function(_0x2b20c5){var _0x4dbd5f=_[_0x7a0c('0x120')](_0x2b20c5);_0x330bef=[];return db[_0x7a0c('0x6e')][_0x7a0c('0x121')](function(_0x45ab39){for(var _0xf4b246=0x0;_0xf4b246<_0x4dbd5f[_0x7a0c('0x50')];_0xf4b246++){_0x330bef['push'](_0x4dbd5f[_0xf4b246][_0x7a0c('0x122')](_0x16541f['id']),{'transaction':_0x45ab39});}return BPromise[_0x7a0c('0x57')](_0x330bef)[_0x7a0c('0x15')](function(){if(_0x16541f[_0x7a0c('0xa2')]){return BPromise['each'](_[_0x7a0c('0xd4')](_0x4dbd5f,function(_0x42db1a){return _0x42db1a['getDataValue'](_0x7a0c('0xb4'))===_0x7a0c('0x123');}),function(_0x345ce8){return db[_0x7a0c('0xb1')][_0x7a0c('0xb2')]({'membername':_0x16541f[_0x7a0c('0x37')],'UserId':_0x16541f['id'],'queue_name':_0x345ce8[_0x7a0c('0x37')],'VoiceQueueId':_0x345ce8['id'],'interface':_[_0x7a0c('0x6c')](_0x16541f[_0x7a0c('0xa5')])?util[_0x7a0c('0xb0')](_0x7a0c('0xf3'),_0x16541f['name']):_0x16541f['interface'],'paused':_0x16541f['voicePause']||![],'penalty':_0x16541f['penalty']},{'transaction':_0x45ab39});});}else{return;}})[_0x7a0c('0x15')](function(){for(var _0x41f3f4=0x0;_0x41f3f4<_0x4dbd5f['length'];_0x41f3f4++){var _0x18b676=_0x4dbd5f[_0x41f3f4][_0x7a0c('0x124')]('channel');var _0x2881a9=_0x18b676+_0x7a0c('0xab');socket[_0x7a0c('0xac')](_0x7a0c('0x2e')+_0x18b676+_0x7a0c('0xad'),{'UserId':_0x16541f['id'],['queueField']:_0x4dbd5f[_0x41f3f4]['id']});}});});})[_0x7a0c('0x15')](function(){db[_0x7a0c('0x125')][_0x7a0c('0x9a')]({'where':{'teamId':_0xb7316e['id']}})['then'](function(_0x229338){if(_0x229338){db[_0x7a0c('0x126')][_0x7a0c('0x82')]({'UserId':_0x1e34e9[_0x7a0c('0x63')]['id'],'VoicePrefixId':_0x229338[_0x7a0c('0x127')]});}});});}});}})[_0x7a0c('0x15')](respondWithStatusCode(_0x5990ce,null))[_0x7a0c('0x1f')](handleError(_0x5990ce,null));};exports[_0x7a0c('0x128')]=function(_0x13458a,_0x4ae795){return db['User'][_0x7a0c('0x9a')]({'where':{'id':_0x13458a[_0x7a0c('0x63')]['id']}})[_0x7a0c('0x15')](handleEntityNotFound(_0x4ae795,null))[_0x7a0c('0x15')](function(_0x3847b5){if(_0x3847b5){var _0x4c462b=_0x3847b5['get']({'plain':!![]});var _0x25b737=_0x13458a[_0x7a0c('0x47')]['ids'];return _0x3847b5[_0x7a0c('0x128')](_0x25b737)[_0x7a0c('0x15')](function(){for(var _0x26ce12=0x0;_0x26ce12<_0x25b737[_0x7a0c('0x50')];_0x26ce12++){var _0x2395e6=[];var _0x6488b0={};db[_0x7a0c('0x113')][_0x7a0c('0x9a')]({'where':{'id':_0x25b737[_0x26ce12]}})[_0x7a0c('0x15')](function(_0x57e241){_0x6488b0=_0x57e241[_0x7a0c('0x52')];_0x2395e6[_0x7a0c('0x4e')](_0x57e241['getVoiceQueues']()[_0x7a0c('0x15')](function(_0x38e900){for(var _0x2715e3=0x0;_0x2715e3<_0x38e900['length'];_0x2715e3++){_0x38e900[_0x2715e3][_0x7a0c('0x119')](_0x7a0c('0xb4'),_0x7a0c('0x123'));}return _0x38e900;}));_0x2395e6[_0x7a0c('0x4e')](_0x57e241['getChatQueues']()[_0x7a0c('0x15')](function(_0x40db5f){for(var _0x18b7fa=0x0;_0x18b7fa<_0x40db5f[_0x7a0c('0x50')];_0x18b7fa++){_0x40db5f[_0x18b7fa][_0x7a0c('0x119')]('channel',_0x7a0c('0x118'));}return _0x40db5f;}));_0x2395e6[_0x7a0c('0x4e')](_0x57e241[_0x7a0c('0x129')]()[_0x7a0c('0x15')](function(_0x88a8){for(var _0x3bbb84=0x0;_0x3bbb84<_0x88a8['length'];_0x3bbb84++){_0x88a8[_0x3bbb84][_0x7a0c('0x119')](_0x7a0c('0xb4'),_0x7a0c('0x11a'));}return _0x88a8;}));_0x2395e6['push'](_0x57e241['getSmsQueues']()[_0x7a0c('0x15')](function(_0x55c375){for(var _0x48dfb8=0x0;_0x48dfb8<_0x55c375[_0x7a0c('0x50')];_0x48dfb8++){_0x55c375[_0x48dfb8][_0x7a0c('0x119')]('channel',_0x7a0c('0x12a'));}return _0x55c375;}));_0x2395e6[_0x7a0c('0x4e')](_0x57e241[_0x7a0c('0x12b')]()[_0x7a0c('0x15')](function(_0x144721){for(var _0x383b83=0x0;_0x383b83<_0x144721['length'];_0x383b83++){_0x144721[_0x383b83][_0x7a0c('0x119')](_0x7a0c('0xb4'),'Whatsapp');}return _0x144721;}));_0x2395e6[_0x7a0c('0x4e')](_0x57e241[_0x7a0c('0x11c')]()[_0x7a0c('0x15')](function(_0x1f0df8){for(var _0x28466f=0x0;_0x28466f<_0x1f0df8[_0x7a0c('0x50')];_0x28466f++){_0x1f0df8[_0x28466f][_0x7a0c('0x119')]('channel','Fax');}return _0x1f0df8;}));_0x2395e6['push'](_0x57e241[_0x7a0c('0x11e')]()[_0x7a0c('0x15')](function(_0x21351f){for(var _0x4dc229=0x0;_0x4dc229<_0x21351f['length'];_0x4dc229++){_0x21351f[_0x4dc229][_0x7a0c('0x119')](_0x7a0c('0xb4'),'Openchannel');}return _0x21351f;}));return BPromise[_0x7a0c('0x57')](_0x2395e6);})[_0x7a0c('0x15')](function(_0x37ce63){var _0x4c14b9=_[_0x7a0c('0x120')](_0x37ce63);_0x2395e6=[];return db[_0x7a0c('0x6e')]['transaction'](function(_0x47e86a){for(var _0xcbd474=0x0;_0xcbd474<_0x4c14b9[_0x7a0c('0x50')];_0xcbd474++){_0x2395e6[_0x7a0c('0x4e')](_0x4c14b9[_0xcbd474][_0x7a0c('0x12c')](_0x4c462b['id']),{'transaction':_0x47e86a});}return BPromise[_0x7a0c('0x57')](_0x2395e6)['then'](function(){if(_0x4c462b[_0x7a0c('0xa2')]){return BPromise[_0x7a0c('0x8d')](_[_0x7a0c('0xd4')](_0x4c14b9,function(_0x2f02e5){return _0x2f02e5['getDataValue']('channel')===_0x7a0c('0x123');}),function(_0x557e26){return db[_0x7a0c('0xb1')]['destroy']({'where':{'VoiceQueueId':_0x557e26['id'],'UserId':_0x4c462b['id']},'transaction':_0x47e86a});});}else{return;}})['then'](function(){db[_0x7a0c('0x125')][_0x7a0c('0x9a')]({'where':{'teamId':_0x6488b0['id']}})[_0x7a0c('0x15')](function(_0x1b52a7){if(_0x1b52a7){return db['UserVoicePrefix'][_0x7a0c('0x29')]({'where':{'UserId':_0x4c462b['id'],'VoicePrefixId':_0x1b52a7['dataValues']['VoicePrefixId']}});}});})[_0x7a0c('0x15')](function(){for(var _0x1067ad=0x0;_0x1067ad<_0x4c14b9[_0x7a0c('0x50')];_0x1067ad++){var _0x1d9fc8=_0x4c14b9[_0x1067ad][_0x7a0c('0x124')](_0x7a0c('0xb4'));var _0x1716fc=_0x1d9fc8+'QueueId';socket[_0x7a0c('0xac')](_0x7a0c('0x2e')+_0x1d9fc8+'Queue:remove',{'UserId':_0x4c462b['id'],['queueField']:_0x4c14b9[_0x1067ad]['id']});}});});});}});}})[_0x7a0c('0x15')](respondWithStatusCode(_0x4ae795,null))[_0x7a0c('0x1f')](handleError(_0x4ae795,null));};exports[_0x7a0c('0x12d')]=function(_0x11ddc3,_0x57cbff){var _0xb02cfe={};var _0x419742={};var _0x18fe13;var _0x57a903;return db['User'][_0x7a0c('0x9a')]({'where':{'id':_0x11ddc3[_0x7a0c('0x63')]['id']}})['then'](handleEntityNotFound(_0x57cbff,null))[_0x7a0c('0x15')](function(_0x556fbe){if(_0x556fbe){_0x18fe13=_0x556fbe;_0x419742[_0x7a0c('0x59')]=_[_0x7a0c('0x5b')](db[_0x7a0c('0xd7')]['rawAttributes']);_0x419742[_0x7a0c('0x47')]=_[_0x7a0c('0x5b')](_0x11ddc3[_0x7a0c('0x47')]);_0x419742['filters']=_['intersection'](_0x419742[_0x7a0c('0x59')],_0x419742[_0x7a0c('0x47')]);_0xb02cfe[_0x7a0c('0x4d')]=_['intersection'](_0x419742[_0x7a0c('0x59')],qs[_0x7a0c('0x5e')](_0x11ddc3[_0x7a0c('0x47')]['fields']));_0xb02cfe['attributes']=_0xb02cfe['attributes']['length']?_0xb02cfe['attributes']:_0x419742[_0x7a0c('0x59')];_0xb02cfe['order']=qs[_0x7a0c('0xd2')](_0x11ddc3[_0x7a0c('0x47')][_0x7a0c('0xd2')]);_0xb02cfe[_0x7a0c('0x45')]=qs[_0x7a0c('0x5c')](_[_0x7a0c('0xd3')](_0x11ddc3[_0x7a0c('0x47')],_0x419742[_0x7a0c('0x5c')]));if(_0x11ddc3['query']['filter']){_0xb02cfe['where']=_['merge'](_0xb02cfe[_0x7a0c('0x45')],{'$or':_[_0x7a0c('0x33')](_0xb02cfe['attributes'],function(_0x3c88fe){var _0x3d2574={};_0x3d2574[_0x3c88fe]={'$like':'%'+_0x11ddc3[_0x7a0c('0x47')][_0x7a0c('0xd4')]+'%'};return _0x3d2574;})});}_0xb02cfe=_[_0x7a0c('0xd5')]({},_0xb02cfe,_0x11ddc3[_0x7a0c('0x5f')]);return _0x18fe13[_0x7a0c('0x12d')](_0xb02cfe);}})[_0x7a0c('0x15')](function(_0x28378f){if(_0x28378f){_0x57a903=_0x28378f[_0x7a0c('0x50')];if(!_0x11ddc3[_0x7a0c('0x47')]['hasOwnProperty'](_0x7a0c('0xdb'))){_0xb02cfe[_0x7a0c('0x24')]=qs['limit'](_0x11ddc3[_0x7a0c('0x47')]['limit']);_0xb02cfe[_0x7a0c('0x22')]=qs[_0x7a0c('0x22')](_0x11ddc3['query'][_0x7a0c('0x22')]);}return _0x18fe13[_0x7a0c('0x12d')](_0xb02cfe);}})[_0x7a0c('0x15')](function(_0x178cce){if(_0x178cce){return _0x178cce?{'count':_0x57a903,'rows':_0x178cce}:null;}})[_0x7a0c('0x15')](respondWithResult(_0x57cbff,null))[_0x7a0c('0x1f')](handleError(_0x57cbff,null));};exports[_0x7a0c('0x12e')]=function(_0x27ac15,_0x592a67){var _0x32e475={};var _0x14acc4={};var _0x380a25;return db[_0x7a0c('0x46')]['findOne']({'where':{'id':_0x27ac15[_0x7a0c('0x63')]['id']}})[_0x7a0c('0x15')](handleEntityNotFound(_0x592a67,null))[_0x7a0c('0x15')](function(_0xaa1d84){if(_0xaa1d84){_0x380a25=_0xaa1d84;_0x14acc4['model']=_['keys'](db['User'][_0x7a0c('0x3e')]);_0x14acc4[_0x7a0c('0x47')]=_[_0x7a0c('0x5b')](_0x27ac15[_0x7a0c('0x47')]);_0x14acc4['filters']=_['intersection'](_0x14acc4[_0x7a0c('0x59')],_0x14acc4['query']);_0x32e475['attributes']=_[_0x7a0c('0x5d')](_0x14acc4[_0x7a0c('0x59')],qs[_0x7a0c('0x5e')](_0x27ac15['query']['fields']));_0x32e475[_0x7a0c('0x4d')]=_0x32e475[_0x7a0c('0x4d')][_0x7a0c('0x50')]?_0x32e475['attributes']:_0x14acc4['model'];_0x32e475[_0x7a0c('0xe0')]=qs[_0x7a0c('0xd2')](_0x27ac15[_0x7a0c('0x47')][_0x7a0c('0xd2')]);_0x32e475[_0x7a0c('0x45')]=qs[_0x7a0c('0x5c')](_['pick'](_0x27ac15[_0x7a0c('0x47')],_0x14acc4[_0x7a0c('0x5c')]));if(_0x27ac15[_0x7a0c('0x47')][_0x7a0c('0xd4')]){_0x32e475[_0x7a0c('0x45')]=_[_0x7a0c('0xd5')](_0x32e475[_0x7a0c('0x45')],{'$or':_[_0x7a0c('0x33')](_0x32e475[_0x7a0c('0x4d')],function(_0x2fb083){var _0x209bb9={};_0x209bb9[_0x2fb083]={'$like':'%'+_0x27ac15[_0x7a0c('0x47')][_0x7a0c('0xd4')]+'%'};return _0x209bb9;})});}_0x32e475['model']=db['User'];_0x32e475['as']=_0x7a0c('0x2f');_0x32e475=_[_0x7a0c('0xd5')]({},_0x32e475,_0x27ac15[_0x7a0c('0x5f')]);return _0x380a25[_0x7a0c('0x116')]({'include':[_0x32e475]});}})[_0x7a0c('0x15')](function(_0x31191e){if(_0x31191e){var _0x22bf9c={},_0x2f930e=[];for(var _0x2fc512=0x0;_0x2fc512<_0x31191e['length'];_0x2fc512+=0x1){for(var _0x4042c2=0x0,_0x2a7199;_0x4042c2<_0x31191e[_0x2fc512][_0x7a0c('0x2f')]['length'];_0x4042c2+=0x1){_0x2a7199=_0x31191e[_0x2fc512][_0x7a0c('0x2f')][_0x4042c2][_0x7a0c('0x2a')]({'plain':!![]});_0x22bf9c[_0x2a7199['id']]=_0x2a7199;}}_0x22bf9c=_['values'](_0x22bf9c);for(var _0x5894cb=qs[_0x7a0c('0x22')](_0x27ac15[_0x7a0c('0x47')][_0x7a0c('0x22')]);_0x5894cb<_0x22bf9c[_0x7a0c('0x50')]&&_0x2f930e[_0x7a0c('0x50')]<qs['limit'](_0x27ac15['query']['limit']);_0x5894cb+=0x1){if(_0x22bf9c[_0x5894cb]){_0x2f930e['push'](_0x22bf9c[_0x5894cb]);}}return{'count':_0x22bf9c[_0x7a0c('0x50')],'rows':_0x2f930e};}})[_0x7a0c('0x15')](respondWithResult(_0x592a67,null))[_0x7a0c('0x1f')](handleError(_0x592a67,null));};exports['destroy']=function(_0x15bcf1,_0x3f4a58){if(_0x15bcf1[_0x7a0c('0x2e')]['id']==_0x15bcf1['params']['id']){return _0x3f4a58['status'](0x1f4)['send']({'message':_0x7a0c('0x12f')});}return db[_0x7a0c('0x46')][_0x7a0c('0x36')]({'where':{'id':_0x15bcf1[_0x7a0c('0x63')]['id']}})['then'](handleEntityNotFound(_0x3f4a58,null))['then'](removeEntity(_0x3f4a58,null))[_0x7a0c('0x1f')](handleError(_0x3f4a58,null));};exports[_0x7a0c('0x130')]=function(_0x2a5f03,_0x3d62e9){return db['User']['find']({'where':{'id':_0x2a5f03[_0x7a0c('0x63')]['id']}})[_0x7a0c('0x15')](handleEntityNotFound(_0x3d62e9,null))[_0x7a0c('0x15')](function(_0x17285a){if(_0x17285a){return _0x17285a[_0x7a0c('0x130')](_0x2a5f03[_0x7a0c('0x62')][_0x7a0c('0x66')],_['omit'](_0x2a5f03[_0x7a0c('0x62')],[_0x7a0c('0x66'),'id'])||{})[_0x7a0c('0x131')](function(){for(var _0x12754f=0x0;_0x12754f<_0x2a5f03['body'][_0x7a0c('0x66')]['length'];_0x12754f+=0x1){socket[_0x7a0c('0xac')](_0x7a0c('0x132'),{'ChatInteractionId':Number(_0x2a5f03['body']['ids'][_0x12754f]),'UserId':Number(_0x2a5f03[_0x7a0c('0x63')]['id'])});}return _0x2a5f03['body'][_0x7a0c('0x66')];});}})[_0x7a0c('0x15')](respondWithResult(_0x3d62e9,null))[_0x7a0c('0x1f')](handleError(_0x3d62e9,null));};exports[_0x7a0c('0x133')]=function(_0x537a3c,_0x16e941){return db[_0x7a0c('0x46')][_0x7a0c('0x36')]({'where':{'id':_0x537a3c['params']['id']}})[_0x7a0c('0x15')](handleEntityNotFound(_0x16e941,null))['then'](function(_0xeaaa39){if(_0xeaaa39){return _0xeaaa39[_0x7a0c('0x133')](_0x537a3c['query'][_0x7a0c('0x66')])[_0x7a0c('0x15')](function(){if(_[_0x7a0c('0xb7')](_0x537a3c['query'][_0x7a0c('0x66')])){for(var _0x5aa578=0x0;_0x5aa578<_0x537a3c[_0x7a0c('0x47')][_0x7a0c('0x66')][_0x7a0c('0x50')];_0x5aa578+=0x1){socket['emit'](_0x7a0c('0x134'),{'ChatInteractionId':Number(_0x537a3c[_0x7a0c('0x47')][_0x7a0c('0x66')][_0x5aa578]),'UserId':Number(_0x537a3c['params']['id'])});}}else{socket[_0x7a0c('0xac')]('user_has_chat_interactions:remove',{'ChatInteractionId':Number(_0x537a3c['query']['ids']),'UserId':Number(_0x537a3c[_0x7a0c('0x63')]['id'])});}});}})[_0x7a0c('0x15')](respondWithStatusCode(_0x16e941,null))['catch'](handleError(_0x16e941,null));};exports[_0x7a0c('0x135')]=function(_0x3adb19,_0x5c45d9){return db['User'][_0x7a0c('0x36')]({'where':{'id':_0x3adb19[_0x7a0c('0x63')]['id']}})[_0x7a0c('0x15')](handleEntityNotFound(_0x5c45d9,null))[_0x7a0c('0x15')](function(_0x2cc910){if(_0x2cc910){return _0x2cc910[_0x7a0c('0x135')](_0x3adb19[_0x7a0c('0x62')][_0x7a0c('0x66')],_['omit'](_0x3adb19[_0x7a0c('0x62')],[_0x7a0c('0x66'),'id'])||{})[_0x7a0c('0x131')](function(){for(var _0x2b7769=0x0;_0x2b7769<_0x3adb19[_0x7a0c('0x62')][_0x7a0c('0x66')][_0x7a0c('0x50')];_0x2b7769+=0x1){socket[_0x7a0c('0xac')](_0x7a0c('0x136'),{'MailInteractionId':Number(_0x3adb19[_0x7a0c('0x62')]['ids'][_0x2b7769]),'UserId':Number(_0x3adb19[_0x7a0c('0x63')]['id'])});}return _0x3adb19[_0x7a0c('0x62')][_0x7a0c('0x66')];});}})['then'](respondWithResult(_0x5c45d9,null))[_0x7a0c('0x1f')](handleError(_0x5c45d9,null));};exports[_0x7a0c('0x137')]=function(_0x531874,_0x537e45){return db['User'][_0x7a0c('0x36')]({'where':{'id':_0x531874[_0x7a0c('0x63')]['id']}})[_0x7a0c('0x15')](handleEntityNotFound(_0x537e45,null))[_0x7a0c('0x15')](function(_0x2ce6de){if(_0x2ce6de){return _0x2ce6de[_0x7a0c('0x137')](_0x531874[_0x7a0c('0x47')][_0x7a0c('0x66')])[_0x7a0c('0x15')](function(){if(_[_0x7a0c('0xb7')](_0x531874['query'][_0x7a0c('0x66')])){for(var _0x247683=0x0;_0x247683<_0x531874[_0x7a0c('0x47')][_0x7a0c('0x66')][_0x7a0c('0x50')];_0x247683+=0x1){socket[_0x7a0c('0xac')](_0x7a0c('0x138'),{'MailInteractionId':Number(_0x531874['query'][_0x7a0c('0x66')][_0x247683]),'UserId':Number(_0x531874[_0x7a0c('0x63')]['id'])});}}else{socket[_0x7a0c('0xac')](_0x7a0c('0x138'),{'MailInteractionId':Number(_0x531874[_0x7a0c('0x47')][_0x7a0c('0x66')]),'UserId':Number(_0x531874[_0x7a0c('0x63')]['id'])});}});}})['then'](respondWithStatusCode(_0x537e45,null))[_0x7a0c('0x1f')](handleError(_0x537e45,null));};exports[_0x7a0c('0x139')]=function(_0x3593c9,_0x717e3a){return db[_0x7a0c('0x46')][_0x7a0c('0x36')]({'where':{'id':_0x3593c9['params']['id']}})[_0x7a0c('0x15')](handleEntityNotFound(_0x717e3a,null))[_0x7a0c('0x15')](function(_0x3f66c7){if(_0x3f66c7){return _0x3f66c7[_0x7a0c('0x139')](_0x3593c9[_0x7a0c('0x62')][_0x7a0c('0x66')],_[_0x7a0c('0x67')](_0x3593c9[_0x7a0c('0x62')],['ids','id'])||{})[_0x7a0c('0x131')](function(){for(var _0x7373a2=0x0;_0x7373a2<_0x3593c9[_0x7a0c('0x62')][_0x7a0c('0x66')][_0x7a0c('0x50')];_0x7373a2+=0x1){socket[_0x7a0c('0xac')](_0x7a0c('0x13a'),{'FaxInteractionId':Number(_0x3593c9[_0x7a0c('0x62')][_0x7a0c('0x66')][_0x7373a2]),'UserId':Number(_0x3593c9['params']['id'])});}return _0x3593c9[_0x7a0c('0x62')]['ids'];});}})[_0x7a0c('0x15')](respondWithResult(_0x717e3a,null))[_0x7a0c('0x1f')](handleError(_0x717e3a,null));};exports['removeFaxInteractions']=function(_0x392c0e,_0x5232b7){return db['User'][_0x7a0c('0x36')]({'where':{'id':_0x392c0e[_0x7a0c('0x63')]['id']}})[_0x7a0c('0x15')](handleEntityNotFound(_0x5232b7,null))[_0x7a0c('0x15')](function(_0x698999){if(_0x698999){return _0x698999[_0x7a0c('0x13b')](_0x392c0e['query'][_0x7a0c('0x66')])['then'](function(){if(_['isArray'](_0x392c0e[_0x7a0c('0x47')][_0x7a0c('0x66')])){for(var _0x3654b1=0x0;_0x3654b1<_0x392c0e['query'][_0x7a0c('0x66')]['length'];_0x3654b1+=0x1){socket[_0x7a0c('0xac')](_0x7a0c('0x13c'),{'FaxInteractionId':Number(_0x392c0e[_0x7a0c('0x47')][_0x7a0c('0x66')][_0x3654b1]),'UserId':Number(_0x392c0e[_0x7a0c('0x63')]['id'])});}}else{socket[_0x7a0c('0xac')]('user_has_fax_interactions:remove',{'FaxInteractionId':Number(_0x392c0e[_0x7a0c('0x47')]['ids']),'UserId':Number(_0x392c0e[_0x7a0c('0x63')]['id'])});}});}})[_0x7a0c('0x15')](respondWithStatusCode(_0x5232b7,null))[_0x7a0c('0x1f')](handleError(_0x5232b7,null));};exports[_0x7a0c('0x13d')]=function(_0x8dadb3,_0xf1f009){return db[_0x7a0c('0x46')][_0x7a0c('0x36')]({'where':{'id':_0x8dadb3[_0x7a0c('0x63')]['id']}})[_0x7a0c('0x15')](handleEntityNotFound(_0xf1f009,null))['then'](function(_0x5615e6){if(_0x5615e6){return _0x5615e6[_0x7a0c('0x13d')](_0x8dadb3[_0x7a0c('0x62')]['ids'],_[_0x7a0c('0x67')](_0x8dadb3[_0x7a0c('0x62')],[_0x7a0c('0x66'),'id'])||{})['spread'](function(){for(var _0x1471c=0x0;_0x1471c<_0x8dadb3[_0x7a0c('0x62')]['ids']['length'];_0x1471c+=0x1){socket['emit'](_0x7a0c('0x13e'),{'SmsInteractionId':Number(_0x8dadb3['body'][_0x7a0c('0x66')][_0x1471c]),'UserId':Number(_0x8dadb3[_0x7a0c('0x63')]['id'])});}return _0x8dadb3[_0x7a0c('0x62')][_0x7a0c('0x66')];});}})[_0x7a0c('0x15')](respondWithResult(_0xf1f009,null))['catch'](handleError(_0xf1f009,null));};exports[_0x7a0c('0x13f')]=function(_0x18173,_0x5b00b0){return db[_0x7a0c('0x46')][_0x7a0c('0x36')]({'where':{'id':_0x18173['params']['id']}})[_0x7a0c('0x15')](handleEntityNotFound(_0x5b00b0,null))[_0x7a0c('0x15')](function(_0x20ec39){if(_0x20ec39){return _0x20ec39[_0x7a0c('0x13f')](_0x18173[_0x7a0c('0x47')][_0x7a0c('0x66')])[_0x7a0c('0x15')](function(){if(_[_0x7a0c('0xb7')](_0x18173['query']['ids'])){for(var _0x3116a5=0x0;_0x3116a5<_0x18173[_0x7a0c('0x47')][_0x7a0c('0x66')]['length'];_0x3116a5+=0x1){socket[_0x7a0c('0xac')](_0x7a0c('0x140'),{'SmsInteractionId':Number(_0x18173[_0x7a0c('0x47')]['ids'][_0x3116a5]),'UserId':Number(_0x18173[_0x7a0c('0x63')]['id'])});}}else{socket['emit'](_0x7a0c('0x140'),{'SmsInteractionId':Number(_0x18173[_0x7a0c('0x47')][_0x7a0c('0x66')]),'UserId':Number(_0x18173[_0x7a0c('0x63')]['id'])});}});}})[_0x7a0c('0x15')](respondWithStatusCode(_0x5b00b0,null))[_0x7a0c('0x1f')](handleError(_0x5b00b0,null));};exports[_0x7a0c('0x141')]=function(_0x3ddf44,_0x54cb72){return db['User'][_0x7a0c('0x36')]({'where':{'id':_0x3ddf44[_0x7a0c('0x63')]['id']}})[_0x7a0c('0x15')](handleEntityNotFound(_0x54cb72,null))[_0x7a0c('0x15')](function(_0x1e9e9f){if(_0x1e9e9f){return _0x1e9e9f[_0x7a0c('0x141')](_0x3ddf44[_0x7a0c('0x62')][_0x7a0c('0x66')],_[_0x7a0c('0x67')](_0x3ddf44[_0x7a0c('0x62')],[_0x7a0c('0x66'),'id'])||{})['spread'](function(){for(var _0x5a4156=0x0;_0x5a4156<_0x3ddf44[_0x7a0c('0x62')][_0x7a0c('0x66')][_0x7a0c('0x50')];_0x5a4156+=0x1){socket[_0x7a0c('0xac')](_0x7a0c('0x142'),{'OpenchannelInteractionId':Number(_0x3ddf44[_0x7a0c('0x62')]['ids'][_0x5a4156]),'UserId':Number(_0x3ddf44['params']['id'])});}return _0x3ddf44[_0x7a0c('0x62')][_0x7a0c('0x66')];});}})[_0x7a0c('0x15')](respondWithResult(_0x54cb72,null))[_0x7a0c('0x1f')](handleError(_0x54cb72,null));};exports[_0x7a0c('0x143')]=function(_0xe5fc8f,_0x35118b){return db['User'][_0x7a0c('0x36')]({'where':{'id':_0xe5fc8f[_0x7a0c('0x63')]['id']}})[_0x7a0c('0x15')](handleEntityNotFound(_0x35118b,null))['then'](function(_0x12d96a){if(_0x12d96a){return _0x12d96a['removeOpenchannelInteractions'](_0xe5fc8f[_0x7a0c('0x47')][_0x7a0c('0x66')])[_0x7a0c('0x15')](function(){if(_[_0x7a0c('0xb7')](_0xe5fc8f[_0x7a0c('0x47')]['ids'])){for(var _0x1e74d4=0x0;_0x1e74d4<_0xe5fc8f['query'][_0x7a0c('0x66')][_0x7a0c('0x50')];_0x1e74d4+=0x1){socket[_0x7a0c('0xac')](_0x7a0c('0x144'),{'OpenchannelInteractionId':Number(_0xe5fc8f[_0x7a0c('0x47')][_0x7a0c('0x66')][_0x1e74d4]),'UserId':Number(_0xe5fc8f[_0x7a0c('0x63')]['id'])});}}else{socket['emit'](_0x7a0c('0x144'),{'OpenchannelInteractionId':Number(_0xe5fc8f[_0x7a0c('0x47')][_0x7a0c('0x66')]),'UserId':Number(_0xe5fc8f[_0x7a0c('0x63')]['id'])});}});}})[_0x7a0c('0x15')](respondWithStatusCode(_0x35118b,null))[_0x7a0c('0x1f')](handleError(_0x35118b,null));};exports[_0x7a0c('0x145')]=function(_0x347119,_0x7dd2f7){return db[_0x7a0c('0x46')][_0x7a0c('0x36')]({'where':{'id':_0x347119[_0x7a0c('0x63')]['id']}})[_0x7a0c('0x15')](handleEntityNotFound(_0x7dd2f7,null))[_0x7a0c('0x15')](function(_0x111075){if(_0x111075){return _0x111075[_0x7a0c('0x145')](_0x347119['body'][_0x7a0c('0x66')],_[_0x7a0c('0x67')](_0x347119[_0x7a0c('0x62')],[_0x7a0c('0x66'),'id'])||{})[_0x7a0c('0x131')](function(){for(var _0x1f0354=0x0;_0x1f0354<_0x347119['body'][_0x7a0c('0x66')][_0x7a0c('0x50')];_0x1f0354+=0x1){socket[_0x7a0c('0xac')](_0x7a0c('0x146'),{'WhatsappInteractionId':Number(_0x347119[_0x7a0c('0x62')][_0x7a0c('0x66')][_0x1f0354]),'UserId':Number(_0x347119[_0x7a0c('0x63')]['id'])});}return _0x347119[_0x7a0c('0x62')]['ids'];});}})[_0x7a0c('0x15')](respondWithResult(_0x7dd2f7,null))['catch'](handleError(_0x7dd2f7,null));};exports[_0x7a0c('0x147')]=function(_0x4bc7bb,_0x3af7b4){return db['User'][_0x7a0c('0x36')]({'where':{'id':_0x4bc7bb[_0x7a0c('0x63')]['id']}})[_0x7a0c('0x15')](handleEntityNotFound(_0x3af7b4,null))[_0x7a0c('0x15')](function(_0x2ea01d){if(_0x2ea01d){return _0x2ea01d[_0x7a0c('0x147')](_0x4bc7bb[_0x7a0c('0x47')][_0x7a0c('0x66')]);}})['then'](respondWithStatusCode(_0x3af7b4,null))[_0x7a0c('0x1f')](handleError(_0x3af7b4,null));};exports[_0x7a0c('0x148')]=function(_0x32d290,_0x5b3336){var _0x924343={};var _0x2b0b94={};var _0x1c2066;var _0x3ae11e;return db[_0x7a0c('0x46')][_0x7a0c('0x9a')]({'where':{'id':_0x32d290[_0x7a0c('0x63')]['id']}})[_0x7a0c('0x15')](handleEntityNotFound(_0x5b3336,null))[_0x7a0c('0x15')](function(_0x5ad3d0){if(_0x5ad3d0){_0x1c2066=_0x5ad3d0;_0x2b0b94[_0x7a0c('0x59')]=_[_0x7a0c('0x5b')](db['VoicePrefix'][_0x7a0c('0x3e')]);_0x2b0b94[_0x7a0c('0x47')]=_['keys'](_0x32d290[_0x7a0c('0x47')]);_0x2b0b94['filters']=_[_0x7a0c('0x5d')](_0x2b0b94[_0x7a0c('0x59')],_0x2b0b94[_0x7a0c('0x47')]);_0x924343[_0x7a0c('0x4d')]=_[_0x7a0c('0x5d')](_0x2b0b94[_0x7a0c('0x59')],qs[_0x7a0c('0x5e')](_0x32d290[_0x7a0c('0x47')][_0x7a0c('0x5e')]));_0x924343[_0x7a0c('0x4d')]=_0x924343[_0x7a0c('0x4d')][_0x7a0c('0x50')]?_0x924343['attributes']:_0x2b0b94[_0x7a0c('0x59')];_0x924343[_0x7a0c('0xe0')]=qs['sort'](_0x32d290[_0x7a0c('0x47')][_0x7a0c('0xd2')]);_0x924343['where']=qs[_0x7a0c('0x5c')](_['pick'](_0x32d290['query'],_0x2b0b94[_0x7a0c('0x5c')]));if(_0x32d290[_0x7a0c('0x47')][_0x7a0c('0xd4')]){_0x924343[_0x7a0c('0x45')]=_[_0x7a0c('0xd5')](_0x924343[_0x7a0c('0x45')],{'$or':_['map'](_0x924343[_0x7a0c('0x4d')],function(_0x59a1a2){var _0x47e34c={};_0x47e34c[_0x59a1a2]={'$like':'%'+_0x32d290[_0x7a0c('0x47')][_0x7a0c('0xd4')]+'%'};return _0x47e34c;})});}_0x924343=_[_0x7a0c('0xd5')]({},_0x924343,_0x32d290[_0x7a0c('0x5f')]);return _0x1c2066[_0x7a0c('0x148')](_0x924343);}})[_0x7a0c('0x15')](function(_0xdd6b5f){if(_0xdd6b5f){_0x3ae11e=_0xdd6b5f[_0x7a0c('0x50')];if(!_0x32d290[_0x7a0c('0x47')]['hasOwnProperty'](_0x7a0c('0xdb'))){_0x924343[_0x7a0c('0x24')]=qs['limit'](_0x32d290[_0x7a0c('0x47')][_0x7a0c('0x24')]);_0x924343[_0x7a0c('0x22')]=qs[_0x7a0c('0x22')](_0x32d290['query'][_0x7a0c('0x22')]);}return _0x1c2066['getVoicePrefixes'](_0x924343);}})[_0x7a0c('0x15')](function(_0x499910){if(_0x499910){return _0x499910?{'count':_0x3ae11e,'rows':_0x499910}:null;}})[_0x7a0c('0x15')](respondWithResult(_0x5b3336,null))[_0x7a0c('0x1f')](handleError(_0x5b3336,null));};exports[_0x7a0c('0x149')]=function(_0x5595f7,_0x3f0eca){var _0x257722={};var _0x420b87={};var _0x1096d0;var _0x51e86a;return db[_0x7a0c('0x46')][_0x7a0c('0x9a')]({'where':{'id':_0x5595f7[_0x7a0c('0x63')]['id']}})[_0x7a0c('0x15')](handleEntityNotFound(_0x3f0eca,null))[_0x7a0c('0x15')](function(_0x4e0097){if(_0x4e0097){_0x1096d0=_0x4e0097;_0x420b87[_0x7a0c('0x59')]=_[_0x7a0c('0x5b')](db['FaxAccount'][_0x7a0c('0x3e')]);_0x420b87[_0x7a0c('0x47')]=_['keys'](_0x5595f7[_0x7a0c('0x47')]);_0x420b87['filters']=_['intersection'](_0x420b87[_0x7a0c('0x59')],_0x420b87[_0x7a0c('0x47')]);_0x257722[_0x7a0c('0x4d')]=_[_0x7a0c('0x5d')](_0x420b87[_0x7a0c('0x59')],qs[_0x7a0c('0x5e')](_0x5595f7[_0x7a0c('0x47')][_0x7a0c('0x5e')]));_0x257722[_0x7a0c('0x4d')]=_0x257722[_0x7a0c('0x4d')][_0x7a0c('0x50')]?_0x257722[_0x7a0c('0x4d')]:_0x420b87[_0x7a0c('0x59')];_0x257722[_0x7a0c('0xe0')]=qs[_0x7a0c('0xd2')](_0x5595f7['query'][_0x7a0c('0xd2')]);_0x257722[_0x7a0c('0x45')]=qs[_0x7a0c('0x5c')](_[_0x7a0c('0xd3')](_0x5595f7[_0x7a0c('0x47')],_0x420b87[_0x7a0c('0x5c')]));if(_0x5595f7[_0x7a0c('0x47')][_0x7a0c('0xd4')]){_0x257722['where']=_[_0x7a0c('0xd5')](_0x257722[_0x7a0c('0x45')],{'$or':_[_0x7a0c('0x33')](_0x257722['attributes'],function(_0x3ee69b){var _0x748b59={};_0x748b59[_0x3ee69b]={'$like':'%'+_0x5595f7[_0x7a0c('0x47')][_0x7a0c('0xd4')]+'%'};return _0x748b59;})});}_0x257722=_[_0x7a0c('0xd5')]({},_0x257722,_0x5595f7[_0x7a0c('0x5f')]);return _0x1096d0[_0x7a0c('0x149')](_0x257722);}})[_0x7a0c('0x15')](function(_0x3e7ca1){if(_0x3e7ca1){_0x51e86a=_0x3e7ca1[_0x7a0c('0x50')];if(!_0x5595f7['query'][_0x7a0c('0xd6')](_0x7a0c('0xdb'))){_0x257722['limit']=qs[_0x7a0c('0x24')](_0x5595f7[_0x7a0c('0x47')][_0x7a0c('0x24')]);_0x257722[_0x7a0c('0x22')]=qs['offset'](_0x5595f7['query']['offset']);}return _0x1096d0['getFaxAccounts'](_0x257722);}})[_0x7a0c('0x15')](function(_0x24c0cc){if(_0x24c0cc){return _0x24c0cc?{'count':_0x51e86a,'rows':_0x24c0cc}:null;}})[_0x7a0c('0x15')](respondWithResult(_0x3f0eca,null))[_0x7a0c('0x1f')](handleError(_0x3f0eca,null));};exports[_0x7a0c('0x14a')]=function(_0x14dd94,_0x33aad4){return db[_0x7a0c('0x46')][_0x7a0c('0x36')]({'where':{'id':_0x14dd94[_0x7a0c('0x63')]['id']}})[_0x7a0c('0x15')](handleEntityNotFound(_0x33aad4,null))[_0x7a0c('0x15')](function(_0x5bba66){if(_0x5bba66){return _0x5bba66[_0x7a0c('0x14a')](_0x14dd94['body'][_0x7a0c('0x66')],_['omit'](_0x14dd94['body'],[_0x7a0c('0x66'),'id'])||{});}})[_0x7a0c('0x15')](respondWithResult(_0x33aad4,null))[_0x7a0c('0x1f')](handleError(_0x33aad4,null));};exports[_0x7a0c('0x14b')]=function(_0x31b075,_0x6079ca){return db[_0x7a0c('0x46')][_0x7a0c('0x36')]({'where':{'id':_0x31b075[_0x7a0c('0x63')]['id']}})[_0x7a0c('0x15')](handleEntityNotFound(_0x6079ca,null))[_0x7a0c('0x15')](function(_0x91e574){if(_0x91e574){return _0x91e574[_0x7a0c('0x14b')](_0x31b075['query']['ids']);}})[_0x7a0c('0x15')](respondWithStatusCode(_0x6079ca,null))['catch'](handleError(_0x6079ca,null));};exports[_0x7a0c('0x14c')]=function(_0x6f0f51,_0x41414d){var _0x2b0a47={};var _0x2bb410={};var _0x267341;var _0x3404f0;return db[_0x7a0c('0x46')][_0x7a0c('0x9a')]({'where':{'id':_0x6f0f51[_0x7a0c('0x63')]['id']}})['then'](handleEntityNotFound(_0x41414d,null))[_0x7a0c('0x15')](function(_0x4b328f){if(_0x4b328f){_0x267341=_0x4b328f;_0x2bb410[_0x7a0c('0x59')]=_[_0x7a0c('0x5b')](db['MailAccount'][_0x7a0c('0x3e')]);_0x2bb410['query']=_[_0x7a0c('0x5b')](_0x6f0f51[_0x7a0c('0x47')]);_0x2bb410[_0x7a0c('0x5c')]=_[_0x7a0c('0x5d')](_0x2bb410['model'],_0x2bb410['query']);_0x2b0a47[_0x7a0c('0x4d')]=_[_0x7a0c('0x5d')](_0x2bb410[_0x7a0c('0x59')],qs['fields'](_0x6f0f51[_0x7a0c('0x47')][_0x7a0c('0x5e')]));_0x2b0a47[_0x7a0c('0x4d')]=_0x2b0a47[_0x7a0c('0x4d')][_0x7a0c('0x50')]?_0x2b0a47[_0x7a0c('0x4d')]:_0x2bb410[_0x7a0c('0x59')];_0x2b0a47[_0x7a0c('0xe0')]=qs[_0x7a0c('0xd2')](_0x6f0f51['query'][_0x7a0c('0xd2')]);_0x2b0a47[_0x7a0c('0x45')]=qs[_0x7a0c('0x5c')](_[_0x7a0c('0xd3')](_0x6f0f51[_0x7a0c('0x47')],_0x2bb410[_0x7a0c('0x5c')]));if(_0x6f0f51[_0x7a0c('0x47')]['filter']){_0x2b0a47['where']=_[_0x7a0c('0xd5')](_0x2b0a47['where'],{'$or':_[_0x7a0c('0x33')](_0x2b0a47[_0x7a0c('0x4d')],function(_0x109a7e){var _0x103862={};_0x103862[_0x109a7e]={'$like':'%'+_0x6f0f51['query'][_0x7a0c('0xd4')]+'%'};return _0x103862;})});}_0x2b0a47=_[_0x7a0c('0xd5')]({},_0x2b0a47,_0x6f0f51['options']);return _0x267341['getMailAccounts'](_0x2b0a47);}})[_0x7a0c('0x15')](function(_0xa41c25){if(_0xa41c25){_0x3404f0=_0xa41c25['length'];if(!_0x6f0f51['query']['hasOwnProperty'](_0x7a0c('0xdb'))){_0x2b0a47[_0x7a0c('0x24')]=qs[_0x7a0c('0x24')](_0x6f0f51['query']['limit']);_0x2b0a47[_0x7a0c('0x22')]=qs[_0x7a0c('0x22')](_0x6f0f51[_0x7a0c('0x47')][_0x7a0c('0x22')]);}return _0x267341[_0x7a0c('0x14c')](_0x2b0a47);}})[_0x7a0c('0x15')](function(_0x119d4e){if(_0x119d4e){return _0x119d4e?{'count':_0x3404f0,'rows':_0x119d4e}:null;}})['then'](respondWithResult(_0x41414d,null))['catch'](handleError(_0x41414d,null));};exports['addMailAccounts']=function(_0x3155ce,_0x5f1a12){return db[_0x7a0c('0x46')][_0x7a0c('0x36')]({'where':{'id':_0x3155ce[_0x7a0c('0x63')]['id']}})[_0x7a0c('0x15')](handleEntityNotFound(_0x5f1a12,null))[_0x7a0c('0x15')](function(_0x179682){if(_0x179682){return _0x179682['addMailAccounts'](_0x3155ce['body'][_0x7a0c('0x66')],_[_0x7a0c('0x67')](_0x3155ce[_0x7a0c('0x62')],[_0x7a0c('0x66'),'id'])||{});}})[_0x7a0c('0x15')](respondWithResult(_0x5f1a12,null))[_0x7a0c('0x1f')](handleError(_0x5f1a12,null));};exports[_0x7a0c('0x14d')]=function(_0x93f105,_0x18f0a9){return db[_0x7a0c('0x46')][_0x7a0c('0x36')]({'where':{'id':_0x93f105[_0x7a0c('0x63')]['id']}})[_0x7a0c('0x15')](handleEntityNotFound(_0x18f0a9,null))[_0x7a0c('0x15')](function(_0x385df1){if(_0x385df1){return _0x385df1[_0x7a0c('0x14d')](_0x93f105[_0x7a0c('0x47')][_0x7a0c('0x66')]);}})[_0x7a0c('0x15')](respondWithStatusCode(_0x18f0a9,null))[_0x7a0c('0x1f')](handleError(_0x18f0a9,null));};exports[_0x7a0c('0x14e')]=function(_0x561561,_0x2f461f){var _0x14d4d3={};var _0x1f2ec6={};var _0x57620e;var _0x2dddb4;return db[_0x7a0c('0x46')]['findOne']({'where':{'id':_0x561561[_0x7a0c('0x63')]['id']}})['then'](handleEntityNotFound(_0x2f461f,null))['then'](function(_0x295cdc){if(_0x295cdc){_0x57620e=_0x295cdc;_0x1f2ec6[_0x7a0c('0x59')]=_['keys'](db['OpenchannelAccount'][_0x7a0c('0x3e')]);_0x1f2ec6['query']=_[_0x7a0c('0x5b')](_0x561561['query']);_0x1f2ec6[_0x7a0c('0x5c')]=_[_0x7a0c('0x5d')](_0x1f2ec6[_0x7a0c('0x59')],_0x1f2ec6[_0x7a0c('0x47')]);_0x14d4d3[_0x7a0c('0x4d')]=_[_0x7a0c('0x5d')](_0x1f2ec6['model'],qs['fields'](_0x561561['query'][_0x7a0c('0x5e')]));_0x14d4d3[_0x7a0c('0x4d')]=_0x14d4d3[_0x7a0c('0x4d')][_0x7a0c('0x50')]?_0x14d4d3[_0x7a0c('0x4d')]:_0x1f2ec6[_0x7a0c('0x59')];_0x14d4d3['order']=qs['sort'](_0x561561[_0x7a0c('0x47')][_0x7a0c('0xd2')]);_0x14d4d3[_0x7a0c('0x45')]=qs[_0x7a0c('0x5c')](_['pick'](_0x561561[_0x7a0c('0x47')],_0x1f2ec6['filters']));if(_0x561561[_0x7a0c('0x47')][_0x7a0c('0xd4')]){_0x14d4d3['where']=_[_0x7a0c('0xd5')](_0x14d4d3[_0x7a0c('0x45')],{'$or':_[_0x7a0c('0x33')](_0x14d4d3[_0x7a0c('0x4d')],function(_0x23670e){var _0x507424={};_0x507424[_0x23670e]={'$like':'%'+_0x561561[_0x7a0c('0x47')][_0x7a0c('0xd4')]+'%'};return _0x507424;})});}_0x14d4d3=_[_0x7a0c('0xd5')]({},_0x14d4d3,_0x561561[_0x7a0c('0x5f')]);return _0x57620e[_0x7a0c('0x14e')](_0x14d4d3);}})[_0x7a0c('0x15')](function(_0x3cc872){if(_0x3cc872){_0x2dddb4=_0x3cc872[_0x7a0c('0x50')];if(!_0x561561['query'][_0x7a0c('0xd6')]('nolimit')){_0x14d4d3[_0x7a0c('0x24')]=qs[_0x7a0c('0x24')](_0x561561['query']['limit']);_0x14d4d3[_0x7a0c('0x22')]=qs[_0x7a0c('0x22')](_0x561561['query'][_0x7a0c('0x22')]);}return _0x57620e[_0x7a0c('0x14e')](_0x14d4d3);}})[_0x7a0c('0x15')](function(_0x4d9a48){if(_0x4d9a48){return _0x4d9a48?{'count':_0x2dddb4,'rows':_0x4d9a48}:null;}})['then'](respondWithResult(_0x2f461f,null))[_0x7a0c('0x1f')](handleError(_0x2f461f,null));};exports[_0x7a0c('0x14f')]=function(_0x39bcb7,_0x3f3937){return db['User'][_0x7a0c('0x36')]({'where':{'id':_0x39bcb7[_0x7a0c('0x63')]['id']}})[_0x7a0c('0x15')](handleEntityNotFound(_0x3f3937,null))[_0x7a0c('0x15')](function(_0xf07b6f){if(_0xf07b6f){return _0xf07b6f['addOpenchannelAccounts'](_0x39bcb7['body']['ids'],_[_0x7a0c('0x67')](_0x39bcb7[_0x7a0c('0x62')],[_0x7a0c('0x66'),'id'])||{});}})[_0x7a0c('0x15')](respondWithResult(_0x3f3937,null))[_0x7a0c('0x1f')](handleError(_0x3f3937,null));};exports[_0x7a0c('0x150')]=function(_0x20afb2,_0x2bbc8e){return db[_0x7a0c('0x46')][_0x7a0c('0x36')]({'where':{'id':_0x20afb2[_0x7a0c('0x63')]['id']}})[_0x7a0c('0x15')](handleEntityNotFound(_0x2bbc8e,null))['then'](function(_0x36451c){if(_0x36451c){return _0x36451c[_0x7a0c('0x150')](_0x20afb2['query'][_0x7a0c('0x66')]);}})[_0x7a0c('0x15')](respondWithStatusCode(_0x2bbc8e,null))[_0x7a0c('0x1f')](handleError(_0x2bbc8e,null));};exports[_0x7a0c('0x151')]=function(_0x23aef8,_0x6d220c){var _0x5159e0={};var _0x344f5d={};var _0x3a1d95;var _0x76a11d;return db['User'][_0x7a0c('0x9a')]({'where':{'id':_0x23aef8['params']['id']}})[_0x7a0c('0x15')](handleEntityNotFound(_0x6d220c,null))[_0x7a0c('0x15')](function(_0x37750e){if(_0x37750e){_0x3a1d95=_0x37750e;_0x344f5d[_0x7a0c('0x59')]=_[_0x7a0c('0x5b')](db[_0x7a0c('0x152')][_0x7a0c('0x3e')]);_0x344f5d[_0x7a0c('0x47')]=_[_0x7a0c('0x5b')](_0x23aef8[_0x7a0c('0x47')]);_0x344f5d[_0x7a0c('0x5c')]=_[_0x7a0c('0x5d')](_0x344f5d[_0x7a0c('0x59')],_0x344f5d[_0x7a0c('0x47')]);_0x5159e0[_0x7a0c('0x4d')]=_[_0x7a0c('0x5d')](_0x344f5d[_0x7a0c('0x59')],qs[_0x7a0c('0x5e')](_0x23aef8[_0x7a0c('0x47')][_0x7a0c('0x5e')]));_0x5159e0[_0x7a0c('0x4d')]=_0x5159e0[_0x7a0c('0x4d')][_0x7a0c('0x50')]?_0x5159e0[_0x7a0c('0x4d')]:_0x344f5d['model'];_0x5159e0[_0x7a0c('0xe0')]=qs['sort'](_0x23aef8[_0x7a0c('0x47')][_0x7a0c('0xd2')]);_0x5159e0[_0x7a0c('0x45')]=qs[_0x7a0c('0x5c')](_['pick'](_0x23aef8[_0x7a0c('0x47')],_0x344f5d[_0x7a0c('0x5c')]));if(_0x23aef8[_0x7a0c('0x47')]['filter']){_0x5159e0[_0x7a0c('0x45')]=_[_0x7a0c('0xd5')](_0x5159e0[_0x7a0c('0x45')],{'$or':_[_0x7a0c('0x33')](_0x5159e0[_0x7a0c('0x4d')],function(_0x4fc696){var _0xdd23c={};_0xdd23c[_0x4fc696]={'$like':'%'+_0x23aef8[_0x7a0c('0x47')][_0x7a0c('0xd4')]+'%'};return _0xdd23c;})});}_0x5159e0=_['merge']({},_0x5159e0,_0x23aef8[_0x7a0c('0x5f')]);return _0x3a1d95[_0x7a0c('0x151')](_0x5159e0);}})[_0x7a0c('0x15')](function(_0x17c651){if(_0x17c651){_0x76a11d=_0x17c651[_0x7a0c('0x50')];if(!_0x23aef8[_0x7a0c('0x47')]['hasOwnProperty'](_0x7a0c('0xdb'))){_0x5159e0[_0x7a0c('0x24')]=qs[_0x7a0c('0x24')](_0x23aef8[_0x7a0c('0x47')][_0x7a0c('0x24')]);_0x5159e0['offset']=qs[_0x7a0c('0x22')](_0x23aef8[_0x7a0c('0x47')][_0x7a0c('0x22')]);}return _0x3a1d95[_0x7a0c('0x151')](_0x5159e0);}})[_0x7a0c('0x15')](function(_0x43fe53){if(_0x43fe53){return _0x43fe53?{'count':_0x76a11d,'rows':_0x43fe53}:null;}})['then'](respondWithResult(_0x6d220c,null))['catch'](handleError(_0x6d220c,null));};exports['addSmsAccounts']=function(_0x279428,_0x53eca1){return db[_0x7a0c('0x46')]['find']({'where':{'id':_0x279428[_0x7a0c('0x63')]['id']}})[_0x7a0c('0x15')](handleEntityNotFound(_0x53eca1,null))[_0x7a0c('0x15')](function(_0x37248b){if(_0x37248b){return _0x37248b[_0x7a0c('0x153')](_0x279428[_0x7a0c('0x62')]['ids'],_[_0x7a0c('0x67')](_0x279428[_0x7a0c('0x62')],['ids','id'])||{});}})[_0x7a0c('0x15')](respondWithResult(_0x53eca1,null))[_0x7a0c('0x1f')](handleError(_0x53eca1,null));};exports[_0x7a0c('0x154')]=function(_0x253077,_0x1e9803){return db[_0x7a0c('0x46')][_0x7a0c('0x36')]({'where':{'id':_0x253077[_0x7a0c('0x63')]['id']}})[_0x7a0c('0x15')](handleEntityNotFound(_0x1e9803,null))[_0x7a0c('0x15')](function(_0x1599a7){if(_0x1599a7){return _0x1599a7[_0x7a0c('0x154')](_0x253077[_0x7a0c('0x47')][_0x7a0c('0x66')]);}})[_0x7a0c('0x15')](respondWithStatusCode(_0x1e9803,null))['catch'](handleError(_0x1e9803,null));};exports[_0x7a0c('0x155')]=function(_0x5a24d0,_0x2b2861){var _0x17c2d8={};var _0x1d000e={};var _0xf1e09d;var _0x1ff858;return db['User'][_0x7a0c('0x9a')]({'where':{'id':_0x5a24d0[_0x7a0c('0x63')]['id']}})[_0x7a0c('0x15')](handleEntityNotFound(_0x2b2861,null))[_0x7a0c('0x15')](function(_0x418dba){if(_0x418dba){_0xf1e09d=_0x418dba;_0x1d000e[_0x7a0c('0x59')]=_[_0x7a0c('0x5b')](db[_0x7a0c('0x156')][_0x7a0c('0x3e')]);_0x1d000e[_0x7a0c('0x47')]=_[_0x7a0c('0x5b')](_0x5a24d0[_0x7a0c('0x47')]);_0x1d000e[_0x7a0c('0x5c')]=_['intersection'](_0x1d000e[_0x7a0c('0x59')],_0x1d000e[_0x7a0c('0x47')]);_0x17c2d8['attributes']=_[_0x7a0c('0x5d')](_0x1d000e['model'],qs['fields'](_0x5a24d0[_0x7a0c('0x47')][_0x7a0c('0x5e')]));_0x17c2d8[_0x7a0c('0x4d')]=_0x17c2d8[_0x7a0c('0x4d')][_0x7a0c('0x50')]?_0x17c2d8[_0x7a0c('0x4d')]:_0x1d000e['model'];_0x17c2d8['order']=qs[_0x7a0c('0xd2')](_0x5a24d0['query'][_0x7a0c('0xd2')]);_0x17c2d8[_0x7a0c('0x45')]=qs['filters'](_[_0x7a0c('0xd3')](_0x5a24d0[_0x7a0c('0x47')],_0x1d000e[_0x7a0c('0x5c')]));if(_0x5a24d0['query']['filter']){_0x17c2d8[_0x7a0c('0x45')]=_['merge'](_0x17c2d8[_0x7a0c('0x45')],{'$or':_[_0x7a0c('0x33')](_0x17c2d8['attributes'],function(_0x594848){var _0x598c22={};_0x598c22[_0x594848]={'$like':'%'+_0x5a24d0[_0x7a0c('0x47')][_0x7a0c('0xd4')]+'%'};return _0x598c22;})});}_0x17c2d8=_[_0x7a0c('0xd5')]({},_0x17c2d8,_0x5a24d0[_0x7a0c('0x5f')]);return _0xf1e09d['getChatWebsites'](_0x17c2d8);}})[_0x7a0c('0x15')](function(_0x474000){if(_0x474000){_0x1ff858=_0x474000[_0x7a0c('0x50')];if(!_0x5a24d0[_0x7a0c('0x47')][_0x7a0c('0xd6')]('nolimit')){_0x17c2d8['limit']=qs['limit'](_0x5a24d0['query'][_0x7a0c('0x24')]);_0x17c2d8[_0x7a0c('0x22')]=qs[_0x7a0c('0x22')](_0x5a24d0['query'][_0x7a0c('0x22')]);}return _0xf1e09d[_0x7a0c('0x155')](_0x17c2d8);}})['then'](function(_0x3681c1){if(_0x3681c1){return _0x3681c1?{'count':_0x1ff858,'rows':_0x3681c1}:null;}})[_0x7a0c('0x15')](respondWithResult(_0x2b2861,null))[_0x7a0c('0x1f')](handleError(_0x2b2861,null));};exports[_0x7a0c('0x157')]=function(_0x309860,_0x36d9c5){return db['User'][_0x7a0c('0x36')]({'where':{'id':_0x309860[_0x7a0c('0x63')]['id']}})[_0x7a0c('0x15')](handleEntityNotFound(_0x36d9c5,null))[_0x7a0c('0x15')](function(_0x4c2ab4){if(_0x4c2ab4){return _0x4c2ab4[_0x7a0c('0x157')](_0x309860['body']['ids'],_[_0x7a0c('0x67')](_0x309860[_0x7a0c('0x62')],[_0x7a0c('0x66'),'id'])||{});}})[_0x7a0c('0x15')](respondWithResult(_0x36d9c5,null))[_0x7a0c('0x1f')](handleError(_0x36d9c5,null));};exports[_0x7a0c('0x158')]=function(_0xb46991,_0x4bd78d){return db['User'][_0x7a0c('0x36')]({'where':{'id':_0xb46991[_0x7a0c('0x63')]['id']}})[_0x7a0c('0x15')](handleEntityNotFound(_0x4bd78d,null))[_0x7a0c('0x15')](function(_0x2de905){if(_0x2de905){return _0x2de905[_0x7a0c('0x158')](_0xb46991[_0x7a0c('0x47')][_0x7a0c('0x66')]);}})[_0x7a0c('0x15')](respondWithStatusCode(_0x4bd78d,null))[_0x7a0c('0x1f')](handleError(_0x4bd78d,null));};exports[_0x7a0c('0x159')]=function(_0x83aeb8,_0x2ffe14){var _0x5933f8={};var _0x40027d={};var _0x383c31;var _0x483b3c;return db[_0x7a0c('0x46')][_0x7a0c('0x9a')]({'where':{'id':_0x83aeb8['params']['id']}})[_0x7a0c('0x15')](handleEntityNotFound(_0x2ffe14,null))['then'](function(_0x30df69){if(_0x30df69){_0x383c31=_0x30df69;_0x40027d[_0x7a0c('0x59')]=_['keys'](db['WhatsappAccount'][_0x7a0c('0x3e')]);_0x40027d[_0x7a0c('0x47')]=_['keys'](_0x83aeb8[_0x7a0c('0x47')]);_0x40027d[_0x7a0c('0x5c')]=_['intersection'](_0x40027d[_0x7a0c('0x59')],_0x40027d[_0x7a0c('0x47')]);_0x5933f8[_0x7a0c('0x4d')]=_[_0x7a0c('0x5d')](_0x40027d[_0x7a0c('0x59')],qs[_0x7a0c('0x5e')](_0x83aeb8[_0x7a0c('0x47')][_0x7a0c('0x5e')]));_0x5933f8[_0x7a0c('0x4d')]=_0x5933f8[_0x7a0c('0x4d')][_0x7a0c('0x50')]?_0x5933f8[_0x7a0c('0x4d')]:_0x40027d[_0x7a0c('0x59')];_0x5933f8['order']=qs['sort'](_0x83aeb8[_0x7a0c('0x47')][_0x7a0c('0xd2')]);_0x5933f8['where']=qs['filters'](_[_0x7a0c('0xd3')](_0x83aeb8[_0x7a0c('0x47')],_0x40027d[_0x7a0c('0x5c')]));if(_0x83aeb8[_0x7a0c('0x47')][_0x7a0c('0xd4')]){_0x5933f8[_0x7a0c('0x45')]=_[_0x7a0c('0xd5')](_0x5933f8['where'],{'$or':_['map'](_0x5933f8[_0x7a0c('0x4d')],function(_0x188bf3){var _0x599a06={};_0x599a06[_0x188bf3]={'$like':'%'+_0x83aeb8[_0x7a0c('0x47')]['filter']+'%'};return _0x599a06;})});}_0x5933f8=_[_0x7a0c('0xd5')]({},_0x5933f8,_0x83aeb8[_0x7a0c('0x5f')]);return _0x383c31[_0x7a0c('0x159')](_0x5933f8);}})[_0x7a0c('0x15')](function(_0x18064c){if(_0x18064c){_0x483b3c=_0x18064c[_0x7a0c('0x50')];if(!_0x83aeb8['query'][_0x7a0c('0xd6')]('nolimit')){_0x5933f8['limit']=qs['limit'](_0x83aeb8['query'][_0x7a0c('0x24')]);_0x5933f8[_0x7a0c('0x22')]=qs['offset'](_0x83aeb8[_0x7a0c('0x47')][_0x7a0c('0x22')]);}return _0x383c31['getWhatsappAccounts'](_0x5933f8);}})[_0x7a0c('0x15')](function(_0x5662cf){if(_0x5662cf){return _0x5662cf?{'count':_0x483b3c,'rows':_0x5662cf}:null;}})[_0x7a0c('0x15')](respondWithResult(_0x2ffe14,null))['catch'](handleError(_0x2ffe14,null));};exports[_0x7a0c('0x15a')]=function(_0x4fe596,_0x481a3d){return db[_0x7a0c('0x46')][_0x7a0c('0x36')]({'where':{'id':_0x4fe596[_0x7a0c('0x63')]['id']}})[_0x7a0c('0x15')](handleEntityNotFound(_0x481a3d,null))['then'](function(_0x38aaa1){if(_0x38aaa1){return _0x38aaa1[_0x7a0c('0x15a')](_0x4fe596[_0x7a0c('0x62')][_0x7a0c('0x66')],_[_0x7a0c('0x67')](_0x4fe596['body'],[_0x7a0c('0x66'),'id'])||{});}})[_0x7a0c('0x15')](respondWithResult(_0x481a3d,null))['catch'](handleError(_0x481a3d,null));};exports[_0x7a0c('0x15b')]=function(_0x262e9c,_0x3c6fdb){return db[_0x7a0c('0x46')][_0x7a0c('0x36')]({'where':{'id':_0x262e9c[_0x7a0c('0x63')]['id']}})[_0x7a0c('0x15')](handleEntityNotFound(_0x3c6fdb,null))[_0x7a0c('0x15')](function(_0x2ff2aa){if(_0x2ff2aa){return _0x2ff2aa[_0x7a0c('0x15b')](_0x262e9c[_0x7a0c('0x47')][_0x7a0c('0x66')]);}})[_0x7a0c('0x15')](respondWithStatusCode(_0x3c6fdb,null))[_0x7a0c('0x1f')](handleError(_0x3c6fdb,null));};exports['getSquareProjects']=function(_0x39642d,_0x2f7a32){var _0x5e7c45={};var _0xa2806c={};var _0x24babe;var _0x572db7;return db[_0x7a0c('0x46')]['findOne']({'where':{'id':_0x39642d[_0x7a0c('0x63')]['id']}})['then'](handleEntityNotFound(_0x2f7a32,null))[_0x7a0c('0x15')](function(_0x1f7b16){if(_0x1f7b16){_0x24babe=_0x1f7b16;_0xa2806c[_0x7a0c('0x59')]=_[_0x7a0c('0x5b')](db[_0x7a0c('0x15c')][_0x7a0c('0x3e')]);_0xa2806c[_0x7a0c('0x47')]=_[_0x7a0c('0x5b')](_0x39642d['query']);_0xa2806c[_0x7a0c('0x5c')]=_[_0x7a0c('0x5d')](_0xa2806c[_0x7a0c('0x59')],_0xa2806c[_0x7a0c('0x47')]);_0x5e7c45['attributes']=_['intersection'](_0xa2806c[_0x7a0c('0x59')],qs['fields'](_0x39642d['query']['fields']));_0x5e7c45[_0x7a0c('0x4d')]=_0x5e7c45[_0x7a0c('0x4d')][_0x7a0c('0x50')]?_0x5e7c45['attributes']:_0xa2806c['model'];_0x5e7c45[_0x7a0c('0xe0')]=qs[_0x7a0c('0xd2')](_0x39642d[_0x7a0c('0x47')][_0x7a0c('0xd2')]);_0x5e7c45[_0x7a0c('0x45')]=qs[_0x7a0c('0x5c')](_[_0x7a0c('0xd3')](_0x39642d['query'],_0xa2806c[_0x7a0c('0x5c')]));if(_0x39642d[_0x7a0c('0x47')][_0x7a0c('0xd4')]){_0x5e7c45['where']=_[_0x7a0c('0xd5')](_0x5e7c45[_0x7a0c('0x45')],{'$or':_['map'](_0x5e7c45['attributes'],function(_0x39785a){var _0x342721={};_0x342721[_0x39785a]={'$like':'%'+_0x39642d['query'][_0x7a0c('0xd4')]+'%'};return _0x342721;})});}_0x5e7c45=_[_0x7a0c('0xd5')]({},_0x5e7c45,_0x39642d[_0x7a0c('0x5f')]);return _0x24babe[_0x7a0c('0x15d')](_0x5e7c45);}})[_0x7a0c('0x15')](function(_0x5406be){if(_0x5406be){_0x572db7=_0x5406be[_0x7a0c('0x50')];if(!_0x39642d[_0x7a0c('0x47')][_0x7a0c('0xd6')](_0x7a0c('0xdb'))){_0x5e7c45['limit']=qs[_0x7a0c('0x24')](_0x39642d[_0x7a0c('0x47')][_0x7a0c('0x24')]);_0x5e7c45['offset']=qs['offset'](_0x39642d[_0x7a0c('0x47')][_0x7a0c('0x22')]);}return _0x24babe[_0x7a0c('0x15d')](_0x5e7c45);}})[_0x7a0c('0x15')](function(_0x516533){if(_0x516533){return _0x516533?{'count':_0x572db7,'rows':_0x516533}:null;}})['then'](respondWithResult(_0x2f7a32,null))['catch'](handleError(_0x2f7a32,null));};exports[_0x7a0c('0x15e')]=function(_0x382848,_0xb27591){return db[_0x7a0c('0x46')][_0x7a0c('0x36')]({'where':{'id':_0x382848['params']['id']}})[_0x7a0c('0x15')](handleEntityNotFound(_0xb27591,null))[_0x7a0c('0x15')](function(_0x1e5e5e){if(_0x1e5e5e){return _0x1e5e5e['addSquareProjects'](_0x382848[_0x7a0c('0x62')][_0x7a0c('0x66')],_[_0x7a0c('0x67')](_0x382848[_0x7a0c('0x62')],[_0x7a0c('0x66'),'id'])||{});}})['then'](respondWithResult(_0xb27591,null))[_0x7a0c('0x1f')](handleError(_0xb27591,null));};exports[_0x7a0c('0x15f')]=function(_0x4ca177,_0x5e65fd){return db[_0x7a0c('0x46')][_0x7a0c('0x36')]({'where':{'id':_0x4ca177['params']['id']}})[_0x7a0c('0x15')](handleEntityNotFound(_0x5e65fd,null))[_0x7a0c('0x15')](function(_0x272c11){if(_0x272c11){return _0x272c11[_0x7a0c('0x15f')](_0x4ca177[_0x7a0c('0x47')][_0x7a0c('0x66')]);}})[_0x7a0c('0x15')](respondWithStatusCode(_0x5e65fd,null))[_0x7a0c('0x1f')](handleError(_0x5e65fd,null));};exports[_0x7a0c('0x160')]=function(_0x506f09,_0x56ebb5){var _0x57c585={},_0x4c2a11={},_0x3f9e05={'count':0x0,'rows':[]};var _0x353c6d=db[_0x7a0c('0x161')][_0x7a0c('0x3e')];_0x4c2a11[_0x7a0c('0x59')]=_[_0x7a0c('0x5b')](_0x353c6d);_0x4c2a11[_0x7a0c('0x47')]=_['keys'](_0x506f09[_0x7a0c('0x47')]);_0x4c2a11[_0x7a0c('0x5c')]=_[_0x7a0c('0x5d')](_0x4c2a11['model'],_0x4c2a11[_0x7a0c('0x47')]);_0x4c2a11['filters']=_[_0x7a0c('0xcf')](_0x4c2a11[_0x7a0c('0x5c')],['$and',_0x7a0c('0x162'),_0x7a0c('0x163'),_0x7a0c('0x164'),_0x7a0c('0x165'),_0x7a0c('0x166'),_0x7a0c('0x167'),_0x7a0c('0x168'),_0x7a0c('0x169'),_0x7a0c('0x16a'),_0x7a0c('0x16b'),_0x7a0c('0x16c'),_0x7a0c('0x16d'),'$like',_0x7a0c('0x16e'),'$iLike',_0x7a0c('0x16f'),_0x7a0c('0x170'),_0x7a0c('0x171'),'$contains',_0x7a0c('0x172'),_0x7a0c('0x173')]);_0x57c585[_0x7a0c('0x4d')]=_[_0x7a0c('0x5d')](_0x4c2a11['model'],qs['fields'](_0x506f09[_0x7a0c('0x47')]['fields']));_0x57c585[_0x7a0c('0x4d')]=_0x57c585['attributes'][_0x7a0c('0x50')]?_0x57c585['attributes']:_0x4c2a11[_0x7a0c('0x59')];if(!_0x506f09['query'][_0x7a0c('0xd6')](_0x7a0c('0xdb'))){_0x57c585[_0x7a0c('0x24')]=qs[_0x7a0c('0x24')](_0x506f09[_0x7a0c('0x47')][_0x7a0c('0x24')]);_0x57c585[_0x7a0c('0x22')]=qs[_0x7a0c('0x22')](_0x506f09[_0x7a0c('0x47')]['offset']);}_0x57c585[_0x7a0c('0xe0')]=qs['sort'](_0x506f09[_0x7a0c('0x47')][_0x7a0c('0xd2')]);_0x57c585[_0x7a0c('0x45')]=qs[_0x7a0c('0x5c')](_[_0x7a0c('0xd3')](_0x506f09[_0x7a0c('0x47')],_0x4c2a11[_0x7a0c('0x5c')]));if(_0x506f09['query']['filter']){_0x57c585['where']=_[_0x7a0c('0xd5')](_0x57c585[_0x7a0c('0x45')],{'$or':_[_0x7a0c('0x33')](_0x57c585['attributes'],function(_0x2692db){var _0x3b3218={};_0x3b3218[_0x2692db]={'$like':'%'+_0x506f09[_0x7a0c('0x47')][_0x7a0c('0xd4')]+'%'};return _0x3b3218;})});}_0x57c585[_0x7a0c('0x45')]={'$and':[_0x57c585[_0x7a0c('0x45')],{'$or':[{'UserId':_0x506f09[_0x7a0c('0x63')]['id']},{'OwnerId':_0x506f09['params']['id']}]}]};_0x57c585=_['merge']({},_0x57c585,_0x506f09[_0x7a0c('0x5f')]);var _0xe97d70={'where':_0x57c585['where']};return db[_0x7a0c('0x161')]['count'](_0xe97d70)[_0x7a0c('0x15')](function(_0x5a50fc){_0x3f9e05['count']=_0x5a50fc;if(_0x506f09[_0x7a0c('0x47')][_0x7a0c('0x48')]){_0x57c585[_0x7a0c('0x49')]=[{'attributes':['id','firstName','lastName',_0x7a0c('0xf1')],'model':db[_0x7a0c('0xd1')],'as':'Contact'},{'attributes':['id','name',_0x7a0c('0x174')],'model':db[_0x7a0c('0xaf')],'as':'Queue'}];}return db[_0x7a0c('0x161')]['findAll'](_0x57c585);})['then'](function(_0x5baa48){_0x3f9e05[_0x7a0c('0x4f')]=_0x5baa48;return _0x3f9e05;})[_0x7a0c('0x15')](respondWithFilteredResult(_0x56ebb5,_0x57c585))['catch'](handleError(_0x56ebb5,null));};exports[_0x7a0c('0x175')]=function(_0x3f94c8,_0x31faf2){if(!_[_0x7a0c('0x6c')](_0x3f94c8[_0x7a0c('0x2e')]['id'])&&(_0x3f94c8['user'][_0x7a0c('0x2b')]==_0x7a0c('0x2c')||_0x3f94c8[_0x7a0c('0x2e')][_0x7a0c('0x2b')]==_0x7a0c('0x2e'))){return db[_0x7a0c('0x46')][_0x7a0c('0x9a')]({'where':{'id':_0x3f94c8['params']['id']},'raw':!![]})['then'](function(_0x473a71){return authService['retrieveApiKey'](_0x473a71);})[_0x7a0c('0x15')](function(_0x4f250d){if(_0x4f250d){return _0x31faf2[_0x7a0c('0x20')](0xc8)['json']({'api_key':_0x4f250d[_0x7a0c('0x176')]});}else{return _0x31faf2[_0x7a0c('0x20')](0xcc)[_0x7a0c('0x21')]({'message':_0x7a0c('0x177')});}})[_0x7a0c('0x1f')](handleError(_0x31faf2,0x193));}else{return _0x31faf2[_0x7a0c('0x20')](0x191)[_0x7a0c('0x21')]({'message':'You\x20don\x27t\x20have\x20sufficient\x20privileges\x20to\x20access\x20this\x20resource.'});}};exports[_0x7a0c('0x178')]=function(_0x4c5186,_0x11ed30){if(!_[_0x7a0c('0x6c')](_0x4c5186['user']['id'])&&(_0x4c5186[_0x7a0c('0x2e')]['role']==_0x7a0c('0x2c')||_0x4c5186['user']['role']==_0x7a0c('0x2e'))){return db['User'][_0x7a0c('0x36')]({'where':{'id':_0x4c5186[_0x7a0c('0x63')]['id']}})['then'](function(_0x587a76){return authService[_0x7a0c('0x179')](_0x587a76);})['then'](function(_0xe7458c){return db[_0x7a0c('0x46')][_0x7a0c('0x28')]({'apiKeyIat':_0xe7458c[_0x7a0c('0x17a')],'apiKeyNonce':_0xe7458c[_0x7a0c('0x17b')]},{'where':{'id':_0x4c5186[_0x7a0c('0x63')]['id']}})[_0x7a0c('0x15')](function(){return _0x11ed30[_0x7a0c('0x20')](0xc8)[_0x7a0c('0x21')]({'api_key':_0xe7458c['token']});});})[_0x7a0c('0x1f')](handleError(_0x11ed30,0x193));}else{return _0x11ed30['status'](0x191)[_0x7a0c('0x21')]({'message':'You\x20don\x27t\x20have\x20sufficient\x20privileges\x20to\x20access\x20this\x20resource.'});}};exports[_0x7a0c('0x17c')]=function(_0x5d7391,_0x534216){if(!_[_0x7a0c('0x6c')](_0x5d7391[_0x7a0c('0x2e')]['id'])&&(_0x5d7391['user'][_0x7a0c('0x2b')]==_0x7a0c('0x2c')||_0x5d7391['user'][_0x7a0c('0x2b')]==_0x7a0c('0x2e'))){return db[_0x7a0c('0x46')][_0x7a0c('0x36')]({'where':{'id':_0x5d7391[_0x7a0c('0x63')]['id']}})[_0x7a0c('0x15')](handleEntityNotFound(_0x534216,null))[_0x7a0c('0x15')](function(_0x3da9d4){if(_0x3da9d4&&_0x3da9d4[_0x7a0c('0x17d')]&&_0x3da9d4[_0x7a0c('0x17e')])return _0x3da9d4;else throw{'message':_0x7a0c('0x17f')};})[_0x7a0c('0x15')](function(){return db[_0x7a0c('0x46')][_0x7a0c('0x28')]({'apiKeyNonce':null,'apiKeyIat':null},{'where':{'id':_0x5d7391[_0x7a0c('0x63')]['id']}});})[_0x7a0c('0x15')](respondWithStatusCode(_0x534216,0xc8))[_0x7a0c('0x1f')](handleError(_0x534216,0x193));}else{return _0x534216[_0x7a0c('0x20')](0x191)[_0x7a0c('0x21')]({'message':_0x7a0c('0x180')});}};exports[_0x7a0c('0x181')]=function(_0x553ef8,_0x9230fe){var _0x41aa2d=_0x553ef8[_0x7a0c('0x2e')][_0x7a0c('0x2a')]({'plain':!![]});if(!_0x41aa2d){return _0x9230fe[_0x7a0c('0x20')](0x191)[_0x7a0c('0x3c')](_0x7a0c('0x182'));}else{Promise[_0x7a0c('0x183')]()['then'](function(){if(_0x553ef8['query'][_0x7a0c('0x4a')]!==_0x7a0c('0x4b'))return;return _0x553ef8[_0x7a0c('0x2e')][_0x7a0c('0x184')]();})[_0x7a0c('0x15')](function(_0xf97a0c){if(!_0xf97a0c)return;return _0xf97a0c[_0x7a0c('0x2a')]({'plain':!![]});})[_0x7a0c('0x15')](function(_0x20bc12){_0x41aa2d[_0x7a0c('0x4a')]=_0x20bc12;return _0x9230fe[_0x7a0c('0x20')](0xc8)[_0x7a0c('0x21')](_0x41aa2d);});}};exports[_0x7a0c('0x185')]=function(_0x40c344,_0x1fb4a3){var _0x2a4d69={'offset':0x0},_0x4df00e={'count':0x0,'rows':[]};Promise[_0x7a0c('0x183')]()[_0x7a0c('0x15')](function(){if(!_0x40c344[_0x7a0c('0x47')][_0x7a0c('0xd4')]&&!_0x40c344[_0x7a0c('0x47')][_0x7a0c('0x186')]&&!_0x40c344[_0x7a0c('0x47')][_0x7a0c('0x187')])return[];return Promise[_0x7a0c('0x183')]()['then'](function(){var _0x453913=[];if(!_[_0x7a0c('0x8f')](_0x40c344[_0x7a0c('0x47')]['teams'])){_0x453913['push'](db['Team']['findAll']({'attributes':['id','name'],'where':{'id':_0x40c344[_0x7a0c('0x47')][_0x7a0c('0x186')]}}));}if(!_[_0x7a0c('0x8f')](_0x40c344[_0x7a0c('0x47')][_0x7a0c('0x187')])){_0x453913['push'](db[_0x7a0c('0xaf')][_0x7a0c('0x8e')]({'attributes':['id',_0x7a0c('0x37')],'type':_0x7a0c('0x188'),'where':{'id':_0x40c344[_0x7a0c('0x47')][_0x7a0c('0x187')]}}));}return Promise[_0x7a0c('0x57')](_0x453913);})[_0x7a0c('0x15')](function(_0x4ee8a7){var _0x2b50ca=_[_0x7a0c('0x120')](_0x4ee8a7)['map'](function(_0xc95dfa){return _0xc95dfa[_0x7a0c('0x12e')]({'attributes':['id',_0x7a0c('0x37'),_0x7a0c('0x68'),'online'],'raw':!![]});});return Promise[_0x7a0c('0x57')](_0x2b50ca);})[_0x7a0c('0x15')](function(_0x2bcc38){var _0x12ec62=_[_0x7a0c('0x120')](_0x2bcc38);if(!_0x40c344[_0x7a0c('0x47')][_0x7a0c('0xd4')])return _0x12ec62;if(_[_0x7a0c('0x8f')](_0x12ec62)){return db[_0x7a0c('0x46')][_0x7a0c('0x8e')]({'attributes':['id','name',_0x7a0c('0x68'),'online'],'where':{'role':'agent','$or':[db[_0x7a0c('0x6e')][_0x7a0c('0x45')](db[_0x7a0c('0x6e')]['fn'](_0x7a0c('0x189'),db['sequelize'][_0x7a0c('0x18a')]('name')),{'$like':'%'+_0x40c344[_0x7a0c('0x47')][_0x7a0c('0xd4')][_0x7a0c('0xa7')]()+'%'}),{'internal':{'$like':'%'+_0x40c344[_0x7a0c('0x47')][_0x7a0c('0xd4')]+'%'}}]},'raw':!![]});}else{return _(_0x12ec62)['flatten']()['filter'](function(_0x38bcd1){return _0x38bcd1[_0x7a0c('0x37')][_0x7a0c('0xa7')]()[_0x7a0c('0x35')](_0x40c344[_0x7a0c('0x47')][_0x7a0c('0xd4')][_0x7a0c('0xa7')]())||_0x38bcd1[_0x7a0c('0x68')][_0x7a0c('0x18b')]()[_0x7a0c('0x35')](_0x40c344[_0x7a0c('0x47')][_0x7a0c('0xd4')]);})[_0x7a0c('0x34')]();}})[_0x7a0c('0x15')](function(_0x52d0ac){var _0x35ba83=_0x7a0c('0x37');var _0x320d4d=_0x7a0c('0x18c');if(_0x40c344[_0x7a0c('0x47')]['sort']){_0x320d4d=_0x40c344[_0x7a0c('0x47')][_0x7a0c('0xd2')][0x0]==='-'?_0x7a0c('0x18d'):_0x7a0c('0x18c');_0x35ba83=_0x320d4d===_0x7a0c('0x18c')?_0x40c344[_0x7a0c('0x47')][_0x7a0c('0xd2')]:_0x40c344[_0x7a0c('0x47')][_0x7a0c('0xd2')][_0x7a0c('0x18e')](0x1);}return _(_0x52d0ac)[_0x7a0c('0x18f')]('id')['orderBy']([function(_0x5ac1af){return _0x35ba83===_0x7a0c('0x37')?_0x5ac1af[_0x35ba83][_0x7a0c('0xa7')]():_0x5ac1af[_0x35ba83];}],[_0x320d4d])[_0x7a0c('0x33')](function(_0x59fb0d){return _[_0x7a0c('0xd3')](_0x59fb0d,['id',_0x7a0c('0x37'),'internal',_0x7a0c('0xa2')]);})[_0x7a0c('0x34')]();})['then'](function(_0x10c7cd){return client['request'](_0x7a0c('0x2f'),_0x40c344)['then'](function(_0x130421){if(_0x130421[_0x7a0c('0x1a')])throw new Error(_0x7a0c('0x190'));var _0xe884cc=_0x130421[_0x7a0c('0x1e')];var _0xbaa81f=jayson[_0x7a0c('0x191')]['http']({'port':0x232c});return _0xbaa81f[_0x7a0c('0x14')](_0x7a0c('0x2f'),_0x40c344)['then'](function(_0x12cf3a){if(_0x12cf3a[_0x7a0c('0x1a')])throw new Error(_0x7a0c('0x192'));var _0x31a0e7=_0x12cf3a['result'];return _['merge']({},_0x31a0e7,_0xe884cc);});})[_0x7a0c('0x15')](function(_0x53f258){return _[_0x7a0c('0x33')](_0x10c7cd,function(_0x4fa90d){var _0x42a503=_[_0x7a0c('0x36')](_0x53f258[_0x7a0c('0x4f')],['id',_0x4fa90d['id']]);if(!_0x42a503||!_0x4fa90d[_0x7a0c('0xa2')]){_0x4fa90d[_0x7a0c('0x20')]=_0x7a0c('0x193');}else if(_0x42a503[_0x7a0c('0xa4')]){_0x4fa90d[_0x7a0c('0x20')]=_0x7a0c('0x194');}else{_0x4fa90d[_0x7a0c('0x20')]=_[_0x7a0c('0x35')](['idle','unknown','unavailable',_0x7a0c('0x195'),null,undefined],_0x42a503[_0x7a0c('0x196')])?_0x7a0c('0xa2'):_0x7a0c('0x197');}return _0x4fa90d;});});});})[_0x7a0c('0x15')](function(_0x1e746f){if(!_0x40c344[_0x7a0c('0x47')]['hasOwnProperty'](_0x7a0c('0xdb'))){_0x2a4d69[_0x7a0c('0x24')]=qs[_0x7a0c('0x24')](_0x40c344[_0x7a0c('0x47')][_0x7a0c('0x24')]||0xa);_0x2a4d69[_0x7a0c('0x22')]=qs[_0x7a0c('0x22')](_0x40c344['query'][_0x7a0c('0x22')]);}_0x4df00e[_0x7a0c('0x25')]=_0x1e746f[_0x7a0c('0x50')];_0x4df00e[_0x7a0c('0x4f')]=_0x2a4d69[_0x7a0c('0x24')]?_0x1e746f['slice'](_0x2a4d69['offset'],_0x2a4d69['offset']+_0x2a4d69[_0x7a0c('0x24')]):_0x1e746f;return _0x4df00e;})[_0x7a0c('0x15')](respondWithFilteredResult(_0x1fb4a3,_0x2a4d69))['catch'](handleError(_0x1fb4a3,null));};function get_open_tabs(_0x30933f,_0x5e8375){var _0xeeca7c=_0x30933f['charAt'](0x0)[_0x7a0c('0x198')]()+_0x30933f['slice'](0x1);var _0x39d25d={'type':db[_0x7a0c('0x95')]['QueryTypes']['SELECT'],'raw':!![]};return new BPromise(function(_0x58ca5e,_0x2a3a8a){var _0x5689e4=squel[_0x7a0c('0x199')]()['field'](_0x7a0c('0x19a')+_0xeeca7c+_0x7a0c('0x19b'),'id')['field'](_0x7a0c('0x19c'))[_0x7a0c('0x71')](_0x7a0c('0x19d')+_0x30933f+'_interactions','ui')[_0x7a0c('0x45')](_0x7a0c('0x19e'),_0x5e8375['id']);return db['sequelize'][_0x7a0c('0x47')](_0x5689e4[_0x7a0c('0x18b')](),_0x39d25d)['then'](function(_0x51fd79){_0x5e8375[_0xeeca7c+'OpenTabs']=_0x51fd79;_0x58ca5e(_0x51fd79);})[_0x7a0c('0x1f')](function(_0x5b5a8e){_0x2a3a8a(_0x5b5a8e);});});}
\ No newline at end of file
+var _0x259f=['$ne','$eq','$not','$between','$notBetween','$in','$like','$notLike','$iLike','$notILike','$overlap','$contained','$any','CmHopper','phone','CmContact','dialActive','getApiKey','retrieveApiKey','token','You\x20don\x27t\x20have\x20sufficient\x20privileges\x20to\x20access\x20this\x20resource.','generateApiKey','iat','nonce','removeApiKey','apiKeyNonce','apiKeyIat','API\x20key\x20not\x20available','whoami','Unable\x20to\x20retrieve\x20the\x20current\x20user','getUserSetting','teams','VoiceQueue','flatten','lower','col','toString','asc','uniqBy','orderBy','client','Unable\x20to\x20retrieve\x20RPC\x20agents\x20(Routing)','idle','unknown','unavailable','ringing','voiceStatus','charAt','slice','QueryTypes','select','field','InteractionId','ui.createdAt','user_has_','_interactions','ui.UserId\x20=\x20?','moment','util','path','lodash','squel','jayson/promise','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/logger','api','../../mysqldb','socket.io-emitter','redis','./user.socket','defaults','localhost','http','request','User,\x20%s,\x20%s','debug','User,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','info','result','catch','status','json','offset','undefined','count','limit','set','Content-Range','update','destroy','then','role','admin','Agents','Telephones','telephone','filter','ignore','map','value','includes','find','name','UserProfileResource','end','sendStatus','stack','index','User','rawAttributes','fieldName','type','key','password','getOptions','where','true','UserSetting','userSetting','attributes','push','rows','query','openTabs','length','chat','dataValues','sms','fax','whatsapp','show','keys','salt','intersection','model','fields','include','merge','openchannel','mail','all','body','describe','addContacts','params','ids','omit','internal','Setting','findById','securePassword','validatePasswordPattern','isNil','min_internal','sequelize','select\x20(select\x20IFNULL(max(internal)+1,1)\x20from\x20users\x20where\x20internal\x20<\x20md.internal)\x20as\x20\x27from\x27,\x20md.internal\x20-\x201\x20as\x20\x27to\x27\x20from\x20users\x20md\x20where\x20md.internal\x20!=\x201\x20and\x20not\x20exists\x20(select\x201\x20from\x20users\x20md2\x20where\x20md2.internal\x20=\x20md.internal\x20-\x201)','SELECT','from','voicemail','mailbox','VoiceMail','fullname','email','permissions','101','103','113','104','105','107','108','109','111','114','create','user','agent','Unauthorized','Unauthorized.\x20You\x20must\x20be\x20an\x20administrator\x20in\x20order\x20to\x20create\x20an\x20user','Unauthorized.\x20You\x20must\x20be\x20an\x20administrator\x20in\x20order\x20to\x20create\x20another\x20administrator','checkUserLimits','settingsEnabled','UserProfileSection','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','bulkCreate','some','Unauthorized.\x20You\x20must\x20be\x20an\x20administrator\x20in\x20order\x20to\x20create\x20an\x20administrator','each','userProfileId','isEmpty','compact','changePassword','oldPassword','newPassword','ValidationError','Invalid\x20body\x20format.\x20Use\x20oldPassword\x20and\x20newPassword','authenticate','Sequelize','Wrong\x20credentials','New\x20password\x20must\x20be\x20different\x20from\x20old\x20password','Invalid\x20body\x20format.\x20Use\x20newPassword','findOne','passwordHistoryLimit','enforcePasswordHistory','previousPasswords','addQueues','channel','online','voicePause','interface','isValidChannel','add','capitalize','Queues','penalty','spread','toLowerCase','emit','Queue:save','voice','findAll','format','SIP/%s','UserVoiceQueueRt','upsert','Unknown\x20channel','isArray','QueueId','Queue:remove','addAvatar','userpic','file','getAvatar','join','server/files/images/logos/default_profile.png','download','existsSync','root','server/files/images/','getOpenTabs','CHAT','FaxOpenTabs','createdAt','OpenchannelOpenTabs','OPENCHANNEL','MailOpenTabs','SmsOpenTabs','SMS','WHATSAPP','concat','getContacts','filters','sort','pick','hasOwnProperty','includeAll','List','Tag','color','tag','nolimit','getQueues','Queue','get','Unknown\x20role','getVoiceQueuesRt','order','ChatGroup','getGroups','VoiceRecording','UserId','options','ScreenRecording','getChatInteractions','getOpenchannelInteractions','OpenchannelInteraction','getMailInteractions','MailInteraction','SmsInteraction','getSmsInteractions','getFaxInteractions','getWhatsappInteractions','WhatsappInteraction','LOCAL/%s@from-sip/n','intrf','user:%s','user:forcelogout','headers','x-forwarded-for','connection','socket','remoteAddress','User\x20not\x20found\x20or\x20not\x20allowed\x20to\x20perform\x20login\x20method','getVoiceQueues','loginInPause','MemberReport','forEach','YYYY-MM-DD\x20HH:mm:ss','getChannels','LOGIN','device','LOGININPAUSE','resolve','logout','pause','PAUSE','updateAttributes','DEFAULT\x20PAUSE','unpause','mailPause','chatPause','faxPause','openchannelPause','pauseType','lastPauseAt','manual','%s%s','Pause','QueuePause','Team','getTeams','Voice','getChatQueues','setDataValue','Mail','getSmsQueues','Sms','Fax','transaction','addAgent','getDataValue','TeamVoicePrefix','UserVoicePrefix','VoicePrefixId','removeTeams','Chat','getMailQueues','getWhatsappQueues','Whatsapp','getFaxQueues','removeAgent','getLists','getAgents','values','send','You\x20can\x27t\x20delete\x20yourself','addChatInteractions','user_has_chat_interactions:save','removeChatInteractions','user_has_chat_interactions:remove','addMailInteractions','removeMailInteractions','user_has_mail_interactions:remove','removeFaxInteractions','user_has_fax_interactions:remove','addSmsInteractions','user_has_sms_interactions:save','removeSmsInteractions','user_has_sms_interactions:remove','addOpenchannelInteractions','user_has_openchannel_interactions:save','removeOpenchannelInteractions','user_has_openchannel_interactions:remove','addWhatsappInteractions','user_has_whatsapp_interactions:save','removeWhatsappInteractions','getVoicePrefixes','VoicePrefix','getFaxAccounts','FaxAccount','addFaxAccounts','removeFaxAccounts','getMailAccounts','MailAccount','removeMailAccounts','getOpenchannelAccounts','OpenchannelAccount','addOpenchannelAccounts','removeOpenchannelAccounts','getSmsAccounts','SmsAccount','addSmsAccounts','removeSmsAccounts','getChatWebsites','ChatWebsite','removeChatWebsites','getWhatsappAccounts','addWhatsappAccounts','removeWhatsappAccounts','getSquareProjects','SquareProject','addSquareProjects','removeSquareProjects','$and','$or','$gt','$gte','$lt','$lte'];(function(_0x2e409e,_0x2d227e){var _0xe6e039=function(_0x47195d){while(--_0x47195d){_0x2e409e['push'](_0x2e409e['shift']());}};_0xe6e039(++_0x2d227e);}(_0x259f,0x1d0));var _0xf259=function(_0xf002ba,_0xf65acf){_0xf002ba=_0xf002ba-0x0;var _0x4abdf6=_0x259f[_0xf002ba];return _0x4abdf6;};'use strict';var moment=require(_0xf259('0x0'));var BPromise=require('bluebird');var util=require(_0xf259('0x1'));var path=require(_0xf259('0x2'));var fs=require('fs');var _=require(_0xf259('0x3'));var squel=require(_0xf259('0x4'));var jayson=require(_0xf259('0x5'));var Redis=require(_0xf259('0x6'));var authService=require(_0xf259('0x7'));var qs=require(_0xf259('0x8'));var logger=require(_0xf259('0x9'))(_0xf259('0xa'));var utils=require('../../config/utils');var config=require('../../config/environment');var licenseUtil=require('../../config/license/util');var db=require(_0xf259('0xb'))['db'];var socket=require(_0xf259('0xc'))(new Redis(config[_0xf259('0xd')]));require(_0xf259('0xe'))['register'](socket);config[_0xf259('0xd')]=_[_0xf259('0xf')](config[_0xf259('0xd')],{'host':_0xf259('0x10'),'port':0x18eb});var client=jayson['client'][_0xf259('0x11')]({'port':0x232a});var values;function respondWithRpcPromise(_0x2a7014,_0x16e592,_0x364a58,_0x4d0b6f){return new BPromise(function(_0x53069a,_0x35d729){var _0x42b011=_0x4d0b6f||client;return _0x42b011[_0xf259('0x12')](_0x2a7014,_0x364a58)['then'](function(_0x2d2b8d){logger['info'](_0xf259('0x13'),_0x16e592,'request\x20sent');logger[_0xf259('0x14')](_0xf259('0x15'),_0x16e592,_0xf259('0x16'),JSON[_0xf259('0x17')](_0x2d2b8d));if(_0x2d2b8d['error']){if(_0x2d2b8d[_0xf259('0x18')][_0xf259('0x19')]===0x1f4){logger[_0xf259('0x18')](_0xf259('0x13'),_0x16e592,_0x2d2b8d[_0xf259('0x18')][_0xf259('0x1a')]);return _0x35d729(_0x2d2b8d[_0xf259('0x18')][_0xf259('0x1a')]);}logger['error']('User,\x20%s,\x20%s',_0x16e592,_0x2d2b8d['error']['message']);return _0x53069a(_0x2d2b8d['error'][_0xf259('0x1a')]);}else{logger[_0xf259('0x1b')](_0xf259('0x13'),_0x16e592,_0xf259('0x16'));_0x53069a(_0x2d2b8d[_0xf259('0x1c')]['message']);}})[_0xf259('0x1d')](function(_0x2f769c){logger[_0xf259('0x18')](_0xf259('0x13'),_0x16e592,_0x2f769c);_0x35d729(_0x2f769c);});});}function respondWithStatusCode(_0x154cd6,_0x5a342d){_0x5a342d=_0x5a342d||0xcc;return function(_0x552190){if(_0x552190){return _0x154cd6['sendStatus'](_0x5a342d);}return _0x154cd6[_0xf259('0x1e')](_0x5a342d)['end']();};}function respondWithResult(_0x439fe9,_0x5f20e7){_0x5f20e7=_0x5f20e7||0xc8;return function(_0x4b4cfd){if(_0x4b4cfd){return _0x439fe9[_0xf259('0x1e')](_0x5f20e7)[_0xf259('0x1f')](_0x4b4cfd);}};}function respondWithFilteredResult(_0x15801e,_0x5ed3b2){return function(_0x25b756){if(_0x25b756){var _0x48806a=typeof _0x5ed3b2[_0xf259('0x20')]===_0xf259('0x21')&&typeof _0x5ed3b2['limit']===_0xf259('0x21');var _0x108bbb=_0x25b756[_0xf259('0x22')];var _0x4f3239=_0x48806a?0x0:_0x5ed3b2[_0xf259('0x20')];var _0x12a6a9=_0x48806a?_0x25b756['count']:_0x5ed3b2['offset']+_0x5ed3b2[_0xf259('0x23')];var _0xe10e69;if(_0x12a6a9>=_0x108bbb){_0x12a6a9=_0x108bbb;_0xe10e69=0xc8;}else{_0xe10e69=0xce;}_0x15801e[_0xf259('0x1e')](_0xe10e69);return _0x15801e[_0xf259('0x24')](_0xf259('0x25'),_0x4f3239+'-'+_0x12a6a9+'/'+_0x108bbb)['json'](_0x25b756);}return null;};}function saveUpdates(_0x3da316){return function(_0x2cbe9a){if(_0x2cbe9a){return _0x2cbe9a[_0xf259('0x26')](_0x3da316)['then'](function(_0x3bae9a){return _0x3bae9a;});}return null;};}function removeEntity(_0x4fddb3){return function(_0x5a7a55){if(_0x5a7a55){return _0x5a7a55[_0xf259('0x27')]()[_0xf259('0x28')](function(){var _0x5360a7=_0x5a7a55['get']({'plain':!![]});if(_0x5360a7[_0xf259('0x29')]===_0xf259('0x2a'))return;var _0x144499=[{'name':'Users','value':'user','ignore':!![]},{'name':_0xf259('0x2b'),'value':'agent','ignore':![]},{'name':_0xf259('0x2c'),'value':_0xf259('0x2d'),'ignore':![]}];var _0x101d63=_(_0x144499)[_0xf259('0x2e')](_0xf259('0x2f'))[_0xf259('0x30')](_0xf259('0x31'))[_0xf259('0x31')]();if(_[_0xf259('0x32')](_0x101d63,_0x5360a7['role'])){return;}var _0x30cef2=_[_0xf259('0x33')](_0x144499,['value',_0x5360a7[_0xf259('0x29')]])[_0xf259('0x34')];return db[_0xf259('0x35')][_0xf259('0x27')]({'where':{'type':_0x30cef2,'resourceId':_0x5360a7['id']}})[_0xf259('0x28')](function(){return _0x5a7a55;});})[_0xf259('0x28')](function(){_0x4fddb3['status'](0xcc)[_0xf259('0x36')]();});}};}function handleEntityNotFound(_0x3cc643){return function(_0x22d051){if(!_0x22d051){_0x3cc643[_0xf259('0x37')](0x194);}return _0x22d051;};}function handleError(_0x2f656d,_0x5d4345){_0x5d4345=_0x5d4345||0x1f4;return function(_0x3007da){logger[_0xf259('0x18')](_0x3007da[_0xf259('0x38')]);if(_0x3007da[_0xf259('0x34')]){delete _0x3007da['name'];}_0x2f656d[_0xf259('0x1e')](_0x5d4345)['send'](_0x3007da);};}exports[_0xf259('0x39')]=function(_0x456ca2,_0x5660d5){var _0x3788bb={},_0x10162d={'count':0x0,'rows':[]};var _0x903a32=_(db[_0xf259('0x3a')][_0xf259('0x3b')])[_0xf259('0x30')](function(_0x68952e){return{'name':_0x68952e[_0xf259('0x3c')],'type':_0x68952e[_0xf259('0x3d')][_0xf259('0x3e')]};})[_0xf259('0x2e')](function(_0x511325){return!_[_0xf259('0x32')]([_0xf259('0x3f'),'salt'],_0x511325[_0xf259('0x34')]);})[_0xf259('0x31')]();_0x3788bb=qs[_0xf259('0x40')](_0x903a32,_0x456ca2);var _0x1f41a1={'where':_0x3788bb[_0xf259('0x41')]};return db[_0xf259('0x3a')][_0xf259('0x22')](_0x1f41a1)[_0xf259('0x28')](function(_0x237c81){_0x10162d['count']=_0x237c81;if(_0x456ca2['query']['includeAll']){_0x3788bb['include']=[{'all':!![]}];}if(_0x456ca2['query']['userSetting']===_0xf259('0x42')){_0x3788bb['include']=[{'model':db[_0xf259('0x43')],'as':_0xf259('0x44')}];}if(!_[_0xf259('0x32')](_0x3788bb[_0xf259('0x45')],'id')){_0x3788bb[_0xf259('0x45')][_0xf259('0x46')]('id');}return db['User']['findAll'](_0x3788bb);})[_0xf259('0x28')](function(_0x34e913){_0x10162d[_0xf259('0x47')]=_0x34e913;if(_0x456ca2[_0xf259('0x48')][_0xf259('0x49')]==='true'){var _0x596be9=[];for(var _0x5b727b=0x0;_0x5b727b<_0x10162d[_0xf259('0x47')][_0xf259('0x4a')];_0x5b727b++){_0x596be9[_0xf259('0x46')](get_open_tabs(_0xf259('0x4b'),_0x10162d[_0xf259('0x47')][_0x5b727b][_0xf259('0x4c')]));_0x596be9[_0xf259('0x46')](get_open_tabs(_0xf259('0x4d'),_0x10162d[_0xf259('0x47')][_0x5b727b][_0xf259('0x4c')]));_0x596be9['push'](get_open_tabs(_0xf259('0x4e'),_0x10162d['rows'][_0x5b727b][_0xf259('0x4c')]));_0x596be9[_0xf259('0x46')](get_open_tabs('mail',_0x10162d[_0xf259('0x47')][_0x5b727b][_0xf259('0x4c')]));_0x596be9[_0xf259('0x46')](get_open_tabs('openchannel',_0x10162d[_0xf259('0x47')][_0x5b727b][_0xf259('0x4c')]));_0x596be9['push'](get_open_tabs(_0xf259('0x4f'),_0x10162d['rows'][_0x5b727b][_0xf259('0x4c')]));}return BPromise['all'](_0x596be9)['then'](function(){return _0x10162d;});}else{return _0x10162d;}})[_0xf259('0x28')](respondWithFilteredResult(_0x5660d5,_0x3788bb))[_0xf259('0x1d')](handleError(_0x5660d5,null));};exports[_0xf259('0x50')]=function(_0x1487d1,_0x4be0bd){var _0x76f3c4={'raw':![],'where':{'id':_0x1487d1['params']['id']}},_0x38b457={};_0x38b457['model']=_['differenceBy'](_[_0xf259('0x51')](db[_0xf259('0x3a')]['rawAttributes']),[_0xf259('0x3f'),_0xf259('0x52')]);_0x38b457[_0xf259('0x48')]=_[_0xf259('0x51')](_0x1487d1[_0xf259('0x48')]);_0x38b457['filters']=_[_0xf259('0x53')](_0x38b457['model'],_0x38b457[_0xf259('0x48')]);_0x76f3c4[_0xf259('0x45')]=_[_0xf259('0x53')](_0x38b457[_0xf259('0x54')],qs[_0xf259('0x55')](_0x1487d1['query'][_0xf259('0x55')]));_0x76f3c4[_0xf259('0x45')]=_0x76f3c4[_0xf259('0x45')]['length']?_0x76f3c4['attributes']:_0x38b457['model'];if(_0x1487d1[_0xf259('0x48')]['includeAll']){_0x76f3c4[_0xf259('0x56')]=[{'all':!![]}];}if(_0x1487d1['query'][_0xf259('0x44')]==='true'){_0x76f3c4[_0xf259('0x56')]=[{'model':db[_0xf259('0x43')],'as':_0xf259('0x44')}];}_0x76f3c4=_[_0xf259('0x57')]({},_0x76f3c4,_0x1487d1['options']);if(!_['includes'](_0x76f3c4[_0xf259('0x45')],'id')){_0x76f3c4[_0xf259('0x45')][_0xf259('0x46')]('id');}return db[_0xf259('0x3a')][_0xf259('0x33')](_0x76f3c4)[_0xf259('0x28')](handleEntityNotFound(_0x4be0bd,null))[_0xf259('0x28')](function(_0x3550e0){var _0x9d2c96=[];values=_0x3550e0;if(_0x1487d1[_0xf259('0x48')]['openTabs']===_0xf259('0x42')){_0x9d2c96[_0xf259('0x46')](get_open_tabs(_0xf259('0x4b'),_0x3550e0['dataValues']));_0x9d2c96[_0xf259('0x46')](get_open_tabs(_0xf259('0x4d'),_0x3550e0['dataValues']));_0x9d2c96[_0xf259('0x46')](get_open_tabs(_0xf259('0x58'),_0x3550e0[_0xf259('0x4c')]));_0x9d2c96[_0xf259('0x46')](get_open_tabs(_0xf259('0x4f'),_0x3550e0['dataValues']));_0x9d2c96[_0xf259('0x46')](get_open_tabs(_0xf259('0x4e'),_0x3550e0[_0xf259('0x4c')]));_0x9d2c96[_0xf259('0x46')](get_open_tabs(_0xf259('0x59'),_0x3550e0[_0xf259('0x4c')]));return BPromise[_0xf259('0x5a')](_0x9d2c96);}else{return values;}})['then'](function(){return values;})[_0xf259('0x28')](respondWithResult(_0x4be0bd,null))['catch'](handleError(_0x4be0bd,null));};exports[_0xf259('0x26')]=function(_0x4d1439,_0x3d8fc7){if(_0x4d1439[_0xf259('0x5b')]['id']){delete _0x4d1439[_0xf259('0x5b')]['id'];}delete _0x4d1439[_0xf259('0x5b')][_0xf259('0x29')];return db[_0xf259('0x3a')][_0xf259('0x33')]({'where':{'id':_0x4d1439['params']['id']}})['then'](handleEntityNotFound(_0x3d8fc7,null))[_0xf259('0x28')](saveUpdates(_0x4d1439[_0xf259('0x5b')],null))[_0xf259('0x28')](respondWithResult(_0x3d8fc7,null))['catch'](handleError(_0x3d8fc7,null));};exports['describe']=function(_0x39b066,_0x4cbe8b){return db['User'][_0xf259('0x5c')]()[_0xf259('0x28')](respondWithResult(_0x4cbe8b,null))[_0xf259('0x1d')](handleError(_0x4cbe8b,null));};exports[_0xf259('0x5d')]=function(_0x236e3e,_0x2d1368){return db[_0xf259('0x3a')][_0xf259('0x33')]({'where':{'id':_0x236e3e[_0xf259('0x5e')]['id']}})['then'](handleEntityNotFound(_0x2d1368,null))[_0xf259('0x28')](function(_0x4b90fc){if(_0x4b90fc){return _0x4b90fc[_0xf259('0x5d')](_0x236e3e['body'][_0xf259('0x5f')],_[_0xf259('0x60')](_0x236e3e[_0xf259('0x5b')],[_0xf259('0x5f'),'id'])||{});}})['then'](respondWithResult(_0x2d1368,null))[_0xf259('0x1d')](handleError(_0x2d1368,null));};function validateUser(_0x56da08){return new BPromise(function(_0x68c3d5,_0x4da865){if(_0x56da08[_0xf259('0x61')])return _0x68c3d5(_0x56da08);return db[_0xf259('0x62')][_0xf259('0x63')](0x1)[_0xf259('0x28')](function(_0x585b31){if(_0x585b31[_0xf259('0x64')])authService[_0xf259('0x65')](_0x56da08['password']);db[_0xf259('0x3a')]['max']('internal')[_0xf259('0x28')](function(_0x33ccea){if(_[_0xf259('0x66')](_0x33ccea)){_0x56da08[_0xf259('0x61')]=_0x585b31[_0xf259('0x67')]||0x1;return;}if(_[_0xf259('0x66')](_0x585b31['min_internal'])||_0x585b31[_0xf259('0x67')]===_0x33ccea){_0x56da08['internal']=_0x33ccea+0x1;return;}if(_0x585b31[_0xf259('0x67')]>_0x33ccea){_0x56da08[_0xf259('0x61')]=_0x585b31[_0xf259('0x67')];return;}return db[_0xf259('0x68')][_0xf259('0x48')](_0xf259('0x69'),{'type':db[_0xf259('0x68')]['QueryTypes'][_0xf259('0x6a')]})[_0xf259('0x28')](function(_0x94a4f9){if(_0x94a4f9&&_0x94a4f9['length']){for(var _0x165db0=0x0,_0x15b235=_0x94a4f9['length'];_0x165db0<_0x15b235&&_[_0xf259('0x66')](_0x56da08[_0xf259('0x61')]);_0x165db0++){if(_0x585b31[_0xf259('0x67')]<=_0x94a4f9[_0x165db0][_0xf259('0x6b')]){_0x56da08[_0xf259('0x61')]=_0x94a4f9[_0x165db0][_0xf259('0x6b')];}else if(_0x585b31[_0xf259('0x67')]>_0x94a4f9[_0x165db0][_0xf259('0x6b')]&&_0x585b31[_0xf259('0x67')]<=_0x94a4f9[_0x165db0]['to']){_0x56da08['internal']=_0x585b31[_0xf259('0x67')];}}}if(_[_0xf259('0x66')](_0x56da08[_0xf259('0x61')])){_0x56da08[_0xf259('0x61')]=_0x33ccea+0x1;}return _0x68c3d5(_0x56da08);});});})[_0xf259('0x1d')](function(_0x4dfdb7){_0x4da865(_0x4dfdb7);});});}function updateUser(_0x3fdf9f){return new BPromise(function(_0x3f0ffd,_0x3f22b5){try{if(_0x3fdf9f[_0xf259('0x6c')]){_0x3fdf9f[_0xf259('0x6d')]=_0x3fdf9f[_0xf259('0x61')];_0x3fdf9f[_0xf259('0x6e')]={'mailbox':_0x3fdf9f['internal'],'password':_0x3fdf9f[_0xf259('0x3f')],'fullname':_0x3fdf9f[_0xf259('0x6f')],'email':_0x3fdf9f[_0xf259('0x70')]};}if(_0x3fdf9f['role']==='agent'){if(!_0x3fdf9f[_0xf259('0x71')])_0x3fdf9f[_0xf259('0x71')]=[_0xf259('0x72'),'102',_0xf259('0x73'),_0xf259('0x74'),'110',_0xf259('0x75'),_0xf259('0x76'),'106',_0xf259('0x77'),_0xf259('0x78'),_0xf259('0x79'),'100',_0xf259('0x7a'),_0xf259('0x7b'),'115'];}_0x3f0ffd(_0x3fdf9f);}catch(_0x4f8f2d){_0x3f22b5(_0x4f8f2d);}});}exports[_0xf259('0x7c')]=function(_0x204a27,_0x1cf73d){if(_0x204a27[_0xf259('0x7d')][_0xf259('0x29')]===_0xf259('0x7e'))throw new Error(_0xf259('0x7f'));if(_0x204a27[_0xf259('0x5b')][_0xf259('0x29')]===_0xf259('0x7d')&&_0x204a27['user'][_0xf259('0x29')]!==_0xf259('0x2a')){throw new Error(_0xf259('0x80'));}if(_0x204a27[_0xf259('0x5b')]['role']===_0xf259('0x2a')&&_0x204a27['user']['role']!==_0xf259('0x2a')){throw new Error(_0xf259('0x81'));}return licenseUtil[_0xf259('0x82')]([_0x204a27[_0xf259('0x5b')]])[_0xf259('0x28')](function(){return validateUser(_0x204a27['body']);})['then'](function(_0x4c6028){return updateUser(_0x4c6028)[_0xf259('0x28')](function(_0x4cc513){if(_0x4cc513[_0xf259('0x29')]==='admin'){_0x4cc513[_0xf259('0x83')]=_0x204a27[_0xf259('0x7d')]['settingsEnabled'];delete _0x4cc513['userProfileId'];}return _0x4cc513;});})['then'](function(_0x2f5638){return db['User'][_0xf259('0x7c')](_0x2f5638,{'include':[{'model':db[_0xf259('0x6e')],'as':_0xf259('0x6e')}]});})[_0xf259('0x28')](function(_0x27ad74){if(_0x204a27[_0xf259('0x5b')][_0xf259('0x29')]===_0xf259('0x7d'))return _0x27ad74;if(_0x204a27[_0xf259('0x7d')][_0xf259('0x29')]!=='user')return _0x27ad74;return db[_0xf259('0x84')][_0xf259('0x33')]({'where':{'name':_0x27ad74[_0xf259('0x29')]===_0xf259('0x7e')?_0xf259('0x2b'):_0xf259('0x2c'),'userProfileId':_0x204a27['user']['userProfileId']},'raw':!![]})['then'](function(_0x42c9e0){if(!_0x42c9e0||_0x42c9e0[_0xf259('0x85')]!=0x0)return _0x27ad74;return db[_0xf259('0x35')][_0xf259('0x7c')]({'name':_0x27ad74['name'],'resourceId':_0x27ad74['id'],'type':_0x42c9e0[_0xf259('0x34')],'sectionId':_0x42c9e0['id']},{})[_0xf259('0x28')](function(){return _0x27ad74;});})[_0xf259('0x1d')](function(_0x237019){logger[_0xf259('0x18')](_0xf259('0x86'),_0x237019);throw _0x237019;});})['then'](respondWithResult(_0x1cf73d,0xc9))[_0xf259('0x1d')](handleError(_0x1cf73d,null));};exports[_0xf259('0x87')]=function(_0x52be80,_0xa41a34){var _0x4bd033=_0x52be80['body'];var _0x2bc73f=[];if(_0x52be80[_0xf259('0x7d')]['role']===_0xf259('0x7e'))throw new Error(_0xf259('0x7f'));if(_[_0xf259('0x88')](_0x4bd033,[_0xf259('0x29'),_0xf259('0x7d')])&&_0x52be80[_0xf259('0x7d')]['role']!==_0xf259('0x2a')){throw new Error(_0xf259('0x80'));}if(_[_0xf259('0x88')](_0x4bd033,['role',_0xf259('0x2a')])&&_0x52be80[_0xf259('0x7d')][_0xf259('0x29')]!==_0xf259('0x2a')){throw new Error(_0xf259('0x89'));}return licenseUtil[_0xf259('0x82')](_0x4bd033)[_0xf259('0x28')](function(){return validateUser(_0x4bd033[0x0]);})[_0xf259('0x28')](function(){for(var _0x4e9d83=0x1;_0x4e9d83<_0x4bd033[_0xf259('0x4a')];_0x4e9d83++){var _0x528caa=_0x4bd033[_0x4e9d83-0x1][_0xf259('0x61')];if(!_0x4bd033[_0x4e9d83][_0xf259('0x61')])_0x4bd033[_0x4e9d83]['internal']=_0x528caa+0x1;_0x2bc73f[_0xf259('0x46')](validateUser(_0x4bd033[_0x4e9d83]));}return BPromise[_0xf259('0x5a')](_0x2bc73f);})[_0xf259('0x28')](function(){_0x2bc73f=[];for(var _0x16e8ed=0x0;_0x16e8ed<_0x4bd033[_0xf259('0x4a')];_0x16e8ed++){_0x2bc73f[_0xf259('0x46')](updateUser(_0x4bd033[_0x16e8ed]));}return BPromise[_0xf259('0x5a')](_0x2bc73f);})[_0xf259('0x28')](function(){return BPromise[_0xf259('0x8a')](_0x4bd033,function(_0xe4de90){return db[_0xf259('0x3a')]['create'](_0xe4de90,{'include':[{'model':db['VoiceMail'],'as':_0xf259('0x6e')}]})['then'](function(_0x570ed1){_0xe4de90['id']=_0x570ed1['id'];return _0xe4de90;});});})['then'](function(_0x50d686){if(_0x52be80[_0xf259('0x5b')][_0xf259('0x29')]==='user')return _0x50d686;if(_0x52be80[_0xf259('0x7d')][_0xf259('0x29')]!==_0xf259('0x7d'))return _0x50d686;var _0x3af309=_[_0xf259('0x88')](_0x50d686,function(_0x4b6920){return _0x4b6920[_0xf259('0x29')]===_0xf259('0x7e')||_0x4b6920['role']===_0xf259('0x2d');});if(!_0x3af309)return _0x50d686;return db['UserProfileSection']['findAll']({'where':{'name':{'$or':['Agents',_0xf259('0x2c')]},'userProfileId':_0x52be80[_0xf259('0x7d')][_0xf259('0x8b')]},'raw':!![]})['then'](function(_0x4c26f9){if(_[_0xf259('0x8c')](_0x4c26f9)||!_[_0xf259('0x88')](_0x4c26f9,[_0xf259('0x85'),0x0]))return _0x50d686;_0x2bc73f=[];var _0x2b092d=_(_0x4c26f9)[_0xf259('0x30')](function(_0x434076){if(_0x434076[_0xf259('0x85')]===0x1)return;return _0x434076[_0xf259('0x34')]===_0xf259('0x2b')?_0xf259('0x7e'):_0xf259('0x2d');})[_0xf259('0x8d')]()['value']();for(var _0x19dc9d=0x0;_0x19dc9d<_0x50d686['length'];_0x19dc9d++){if(!_[_0xf259('0x32')](_0x2b092d,_0x50d686[_0x19dc9d][_0xf259('0x29')]))return;var _0x282d2b=_0x50d686[_0x19dc9d]['role']===_0xf259('0x7e')?_0xf259('0x2b'):_0xf259('0x2c');_0x2bc73f[_0xf259('0x46')](db[_0xf259('0x35')][_0xf259('0x7c')]({'name':_0x50d686[_0x19dc9d][_0xf259('0x34')],'resourceId':_0x50d686[_0x19dc9d]['id'],'type':_0x282d2b,'sectionId':_[_0xf259('0x33')](_0x4c26f9,[_0xf259('0x34'),_0x282d2b])['id']},{}));}return BPromise[_0xf259('0x5a')](_0x2bc73f);});})['then'](respondWithResult(_0xa41a34,0xc9))[_0xf259('0x1d')](handleError(_0xa41a34,null));};exports[_0xf259('0x8e')]=function(_0xcdfba3,_0x3ea624){if(_0xcdfba3[_0xf259('0x5b')]['id']){delete _0xcdfba3['body']['id'];}return db[_0xf259('0x3a')][_0xf259('0x33')]({'where':{'id':_0xcdfba3[_0xf259('0x5e')]['id']}})[_0xf259('0x28')](function(_0xed022a){if(!_0xed022a)return null;if(_0xed022a['id']===_0xcdfba3[_0xf259('0x7d')]['id']){if(!_0xcdfba3[_0xf259('0x5b')][_0xf259('0x8f')]||!_0xcdfba3[_0xf259('0x5b')][_0xf259('0x90')]){throw new db['Sequelize'][(_0xf259('0x91'))](_0xf259('0x92'));}if(!_0xed022a[_0xf259('0x93')](_0xcdfba3[_0xf259('0x5b')][_0xf259('0x8f')])){throw new db[(_0xf259('0x94'))][(_0xf259('0x91'))](_0xf259('0x95'));}if(_0xcdfba3['body'][_0xf259('0x8f')]===_0xcdfba3[_0xf259('0x5b')][_0xf259('0x90')]){throw new db[(_0xf259('0x94'))][(_0xf259('0x91'))](_0xf259('0x96'));}}else if(_0xcdfba3[_0xf259('0x7d')][_0xf259('0x29')]===_0xf259('0x2a')){if(!_0xcdfba3['body'][_0xf259('0x90')]){throw new db[(_0xf259('0x94'))][(_0xf259('0x91'))](_0xf259('0x97'));}}else if(_0xcdfba3[_0xf259('0x7d')]['role']===_0xf259('0x7d')){if(!_0xcdfba3[_0xf259('0x5b')][_0xf259('0x90')]){throw new db['Sequelize'][(_0xf259('0x91'))](_0xf259('0x97'));}if(_0xed022a[_0xf259('0x29')]!==_0xf259('0x7e')){throw new db[(_0xf259('0x94'))][(_0xf259('0x91'))](_0xf259('0x7f'));}}else{throw new db['Sequelize']['ValidationError'](_0xf259('0x7f'));}return _0xed022a;})[_0xf259('0x28')](handleEntityNotFound(_0x3ea624,null))[_0xf259('0x28')](function(_0x5020e2){return db['Setting'][_0xf259('0x98')]({'attributes':['id',_0xf259('0x64'),'enforcePasswordHistory',_0xf259('0x99')]})[_0xf259('0x28')](function(_0x57ee6e){if(_0x57ee6e['securePassword'])authService['validatePasswordPattern'](_0xcdfba3[_0xf259('0x5b')][_0xf259('0x90')]);if(!_0x57ee6e[_0xf259('0x9a')]||!_0x5020e2[_0xf259('0x9b')])return _0x5020e2;authService['validatePasswordHistory'](_0xcdfba3[_0xf259('0x5b')][_0xf259('0x90')],_0x5020e2[_0xf259('0x9b')],_0x57ee6e[_0xf259('0x99')]);return _0x5020e2;})[_0xf259('0x28')](saveUpdates({'password':_0xcdfba3[_0xf259('0x5b')][_0xf259('0x90')],'passwordResetAt':_0xcdfba3[_0xf259('0x7d')]['id']==_0xcdfba3[_0xf259('0x5e')]['id']?moment():null,'previousPasswords':authService['updatePasswordsHistory'](_0xcdfba3[_0xf259('0x5b')][_0xf259('0x90')],_0x5020e2[_0xf259('0x9b')])},null));})[_0xf259('0x28')](respondWithResult(_0x3ea624,null))[_0xf259('0x1d')](handleError(_0x3ea624,null));};exports[_0xf259('0x9c')]=function(_0x1abd7a,_0x50c3f0){var _0x41d547=_0x1abd7a['body'][_0xf259('0x9d')];return db[_0xf259('0x3a')][_0xf259('0x33')]({'where':{'id':_0x1abd7a[_0xf259('0x5e')]['id']},'attributes':['id',_0xf259('0x34'),_0xf259('0x29'),_0xf259('0x9e'),'loginInPause',_0xf259('0x9f'),_0xf259('0xa0')]})[_0xf259('0x28')](handleEntityNotFound(_0x50c3f0,null))['then'](function(_0x26c49e){if(_0x26c49e){if(!utils[_0xf259('0xa1')](_0x41d547)){throw new db[(_0xf259('0x94'))]['ValidationError']('Unknown\x20channel');}return _0x26c49e[_0xf259('0xa2')+_[_0xf259('0xa3')](_0x41d547['toLowerCase']())+_0xf259('0xa4')](_0x1abd7a[_0xf259('0x5b')][_0xf259('0x5f')],{'penalty':_0x1abd7a[_0xf259('0x5b')][_0xf259('0xa5')]||0x0})[_0xf259('0xa6')](function(_0x851b5f){for(var _0x5cf4e2=0x0;_0x5cf4e2<_0x1abd7a[_0xf259('0x5b')][_0xf259('0x5f')][_0xf259('0x4a')];_0x5cf4e2+=0x1){var _0x43b663={'UserId':Number(_0x1abd7a['params']['id'])};_0x43b663[_['capitalize'](_0x41d547[_0xf259('0xa7')]())+'QueueId']=Number(_0x1abd7a[_0xf259('0x5b')][_0xf259('0x5f')][_0x5cf4e2]);socket[_0xf259('0xa8')](_0xf259('0x7d')+_[_0xf259('0xa3')](_0x41d547[_0xf259('0xa7')]())+_0xf259('0xa9'),_0x43b663);}return _0x851b5f;})[_0xf259('0x28')](function(){if(_0x41d547===_0xf259('0xaa')){return db['VoiceQueue'][_0xf259('0xab')]({'where':{'id':_0x1abd7a[_0xf259('0x5b')][_0xf259('0x5f')]||[]},'raw':!![],'attributes':['id','name']});}})[_0xf259('0x28')](function(_0x2836ae){var _0x16ca8a=_0x26c49e['get']({'plain':!![]});var _0x51d786=[];if(_0x41d547===_0xf259('0xaa')&&_0x16ca8a[_0xf259('0x29')]===_0xf259('0x7e')&&_0x16ca8a[_0xf259('0x9e')]){for(var _0x1246a8=0x0;_0x1246a8<_0x2836ae[_0xf259('0x4a')];_0x1246a8+=0x1){_0x51d786[_0xf259('0x46')]({'membername':_0x16ca8a[_0xf259('0x34')],'UserId':_0x16ca8a['id'],'queue_name':_0x2836ae[_0x1246a8][_0xf259('0x34')],'VoiceQueueId':_0x2836ae[_0x1246a8]['id'],'interface':_[_0xf259('0x66')](_0x16ca8a[_0xf259('0xa0')])?util[_0xf259('0xac')](_0xf259('0xad'),_0x16ca8a[_0xf259('0x34')]):_0x16ca8a[_0xf259('0xa0')],'paused':_0x16ca8a[_0xf259('0x9f')]||![],'penalty':_0x1abd7a[_0xf259('0x5b')][_0xf259('0xa5')]||0x0});}return BPromise['each'](_0x51d786,function(_0x59a211){return db[_0xf259('0xae')][_0xf259('0xaf')](_0x59a211);});}return _0x26c49e;});}})['then'](respondWithStatusCode(_0x50c3f0,null))['catch'](handleError(_0x50c3f0,null));};exports['removeQueues']=function(_0x1988b2,_0x41d863){var _0x528d0b,_0x20e16e;return db[_0xf259('0x3a')]['find']({'where':{'id':_0x1988b2[_0xf259('0x5e')]['id']},'attributes':['id',_0xf259('0x34'),_0xf259('0x29')]})[_0xf259('0x28')](handleEntityNotFound(_0x41d863,null))[_0xf259('0x28')](function(_0x382574){if(_0x382574){_0x528d0b=_0x382574;if(!_0x1988b2[_0xf259('0x48')][_0xf259('0x9d')]||!utils[_0xf259('0xa1')](_0x1988b2[_0xf259('0x48')][_0xf259('0x9d')])){throw new db[(_0xf259('0x94'))][(_0xf259('0x91'))](_0xf259('0xb0'));}return _0x382574['remove'+_[_0xf259('0xa3')](_0x1988b2['query'][_0xf259('0x9d')][_0xf259('0xa7')]())+_0xf259('0xa4')](_0x1988b2[_0xf259('0x48')]['ids']);}})[_0xf259('0x28')](function(_0x2cb4ca){if(_[_0xf259('0xb1')](_0x1988b2['query']['ids'])){for(var _0x21d84f=0x0;_0x21d84f<_0x1988b2[_0xf259('0x48')][_0xf259('0x5f')]['length'];_0x21d84f+=0x1){_0x20e16e={'UserId':Number(_0x1988b2[_0xf259('0x5e')]['id'])};_0x20e16e[_[_0xf259('0xa3')](_0x1988b2[_0xf259('0x48')][_0xf259('0x9d')][_0xf259('0xa7')]())+_0xf259('0xb2')]=Number(_0x1988b2['query']['ids'][_0x21d84f]);socket['emit']('user'+_[_0xf259('0xa3')](_0x1988b2[_0xf259('0x48')][_0xf259('0x9d')][_0xf259('0xa7')]())+_0xf259('0xb3'),_0x20e16e);}}else{_0x20e16e={'UserId':Number(_0x1988b2['params']['id'])};_0x20e16e[_['capitalize'](_0x1988b2['query'][_0xf259('0x9d')][_0xf259('0xa7')]())+'QueueId']=Number(_0x1988b2[_0xf259('0x48')]['ids']);socket[_0xf259('0xa8')](_0xf259('0x7d')+_[_0xf259('0xa3')](_0x1988b2['query'][_0xf259('0x9d')][_0xf259('0xa7')]())+_0xf259('0xb3'),_0x20e16e);}return _0x2cb4ca;})[_0xf259('0x28')](function(){if(_0x1988b2[_0xf259('0x48')][_0xf259('0x9d')]==='voice'){return db[_0xf259('0xae')][_0xf259('0x27')]({'where':{'UserId':_0x1988b2[_0xf259('0x5e')]['id'],'VoiceQueueId':_0x1988b2[_0xf259('0x48')][_0xf259('0x5f')]},'individualHooks':!![]})[_0xf259('0x28')](function(){return _0x528d0b;});}return _0x528d0b;})[_0xf259('0x28')](respondWithStatusCode(_0x41d863,null))[_0xf259('0x1d')](handleError(_0x41d863,null));};exports[_0xf259('0xb4')]=function(_0x9d1f50,_0xd8fbd6){_0x9d1f50[_0xf259('0x5b')][_0xf259('0xb5')]=_0x9d1f50[_0xf259('0xb6')]['filename'];return db[_0xf259('0x3a')][_0xf259('0x33')]({'where':{'id':_0x9d1f50[_0xf259('0x5e')]['id']}})[_0xf259('0x28')](handleEntityNotFound(_0xd8fbd6,null))[_0xf259('0x28')](saveUpdates(_0x9d1f50[_0xf259('0x5b')],null))[_0xf259('0x28')](respondWithResult(_0xd8fbd6,null))[_0xf259('0x1d')](handleError(_0xd8fbd6,null));};exports[_0xf259('0xb7')]=function(_0x3ae681,_0x7a2f5d){var _0x5d530d=path[_0xf259('0xb8')](config['root'],_0xf259('0xb9'));return db[_0xf259('0x3a')][_0xf259('0x33')]({'where':{'id':_0x3ae681[_0xf259('0x5e')]['id']},'attributes':['id',_0xf259('0xb5')],'raw':!![]})[_0xf259('0x28')](handleEntityNotFound(_0x7a2f5d,null))[_0xf259('0x28')](function(_0x5eb559){if(_0x5eb559){if(_[_0xf259('0x66')](_0x5eb559[_0xf259('0xb5')])){return _0x7a2f5d[_0xf259('0xba')](_0x5d530d);}else{if(!fs[_0xf259('0xbb')](path[_0xf259('0xb8')](config[_0xf259('0xbc')],'server/files/images/',_0x5eb559[_0xf259('0xb5')]))){return _0x7a2f5d['download'](_0x5d530d);}return _0x7a2f5d[_0xf259('0xba')](path['join'](config[_0xf259('0xbc')],_0xf259('0xbd'),_0x5eb559[_0xf259('0xb5')]));}}})[_0xf259('0x1d')](handleError(_0x7a2f5d,null));};exports[_0xf259('0xbe')]=function(_0x1bcefb,_0x11f84f){return db[_0xf259('0x3a')]['find']({'where':{'id':_0x1bcefb[_0xf259('0x5e')]['id']},'attributes':['id']})[_0xf259('0x28')](handleEntityNotFound(_0x11f84f,null))[_0xf259('0x28')](function(_0x530060){var _0x39033e=[];values=_0x530060['dataValues'];_0x39033e[_0xf259('0x46')](get_open_tabs(_0xf259('0x4b'),_0x530060[_0xf259('0x4c')]));_0x39033e['push'](get_open_tabs('sms',_0x530060[_0xf259('0x4c')]));_0x39033e['push'](get_open_tabs(_0xf259('0x58'),_0x530060[_0xf259('0x4c')]));_0x39033e[_0xf259('0x46')](get_open_tabs(_0xf259('0x4f'),_0x530060[_0xf259('0x4c')]));_0x39033e[_0xf259('0x46')](get_open_tabs(_0xf259('0x4e'),_0x530060[_0xf259('0x4c')]));_0x39033e[_0xf259('0x46')](get_open_tabs(_0xf259('0x59'),_0x530060['dataValues']));return BPromise['all'](_0x39033e);})[_0xf259('0x28')](function(_0x2667f5){if(_0x2667f5){var _0x377b2f=_[_0xf259('0x30')](values['ChatOpenTabs'],function(_0x1e424b){return{'channel':_0xf259('0xbf'),'id':_0x1e424b['id'],'createdAt':_0x1e424b['createdAt']};});var _0x399c35=_['map'](values[_0xf259('0xc0')],function(_0x5288a7){return{'channel':'FAX','id':_0x5288a7['id'],'createdAt':_0x5288a7[_0xf259('0xc1')]};});var _0x14773a=_[_0xf259('0x30')](values[_0xf259('0xc2')],function(_0x31ec65){return{'channel':_0xf259('0xc3'),'id':_0x31ec65['id'],'createdAt':_0x31ec65[_0xf259('0xc1')]};});var _0x21610f=_[_0xf259('0x30')](values[_0xf259('0xc4')],function(_0x55d3ca){return{'channel':'MAIL','id':_0x55d3ca['id'],'createdAt':_0x55d3ca[_0xf259('0xc1')]};});var _0x3bc4c7=_[_0xf259('0x30')](values[_0xf259('0xc5')],function(_0x17a24c){return{'channel':_0xf259('0xc6'),'id':_0x17a24c['id'],'createdAt':_0x17a24c[_0xf259('0xc1')]};});var _0x249c29=_['map'](values['WhatsappOpenTabs'],function(_0x127159){return{'channel':_0xf259('0xc7'),'id':_0x127159['id'],'createdAt':_0x127159[_0xf259('0xc1')]};});var _0x5a72b9=_[_0xf259('0xc8')](_0x377b2f,_0x399c35,_0x14773a,_0x21610f,_0x3bc4c7,_0x249c29);var _0x45b36d={'count':_0x5a72b9[_0xf259('0x4a')],'rows':_0x5a72b9};return _0x45b36d;}else return null;})[_0xf259('0x28')](respondWithResult(_0x11f84f,null))[_0xf259('0x1d')](handleError(_0x11f84f,null));};exports[_0xf259('0xc9')]=function(_0x2f4899,_0x41203b){var _0x3882a5={};var _0x4609a2={};var _0xc18db0;var _0x4172b5;return db[_0xf259('0x3a')][_0xf259('0x98')]({'where':{'id':_0x2f4899[_0xf259('0x5e')]['id']}})[_0xf259('0x28')](handleEntityNotFound(_0x41203b,null))[_0xf259('0x28')](function(_0x1cdab6){if(_0x1cdab6){_0xc18db0=_0x1cdab6;_0x4609a2[_0xf259('0x54')]=_[_0xf259('0x51')](db['CmContact'][_0xf259('0x3b')]);_0x4609a2[_0xf259('0x48')]=_['keys'](_0x2f4899[_0xf259('0x48')]);_0x4609a2[_0xf259('0xca')]=_[_0xf259('0x53')](_0x4609a2['model'],_0x4609a2[_0xf259('0x48')]);_0x3882a5[_0xf259('0x45')]=_[_0xf259('0x53')](_0x4609a2[_0xf259('0x54')],qs['fields'](_0x2f4899[_0xf259('0x48')][_0xf259('0x55')]));_0x3882a5[_0xf259('0x45')]=_0x3882a5[_0xf259('0x45')][_0xf259('0x4a')]?_0x3882a5[_0xf259('0x45')]:_0x4609a2[_0xf259('0x54')];_0x3882a5['order']=qs['sort'](_0x2f4899[_0xf259('0x48')][_0xf259('0xcb')]);_0x3882a5[_0xf259('0x41')]=qs[_0xf259('0xca')](_[_0xf259('0xcc')](_0x2f4899[_0xf259('0x48')],_0x4609a2[_0xf259('0xca')]));if(_0x2f4899[_0xf259('0x48')][_0xf259('0x2e')]){_0x3882a5['where']=_[_0xf259('0x57')](_0x3882a5['where'],{'$or':_[_0xf259('0x30')](_0x3882a5[_0xf259('0x45')],function(_0x4f8359){var _0x56de6d={};_0x56de6d[_0x4f8359]={'$like':'%'+_0x2f4899[_0xf259('0x48')][_0xf259('0x2e')]+'%'};return _0x56de6d;})});}_0x3882a5=_[_0xf259('0x57')]({},_0x3882a5,_0x2f4899['options']);return _0xc18db0[_0xf259('0xc9')](_0x3882a5);}})['then'](function(_0xc396c0){if(_0xc396c0){_0x4172b5=_0xc396c0[_0xf259('0x4a')];if(_0x2f4899[_0xf259('0x48')][_0xf259('0xcd')](_0xf259('0xce'))){_0x3882a5[_0xf259('0x56')]=[{'model':db['CmList'],'as':_0xf259('0xcf'),'required':![]},{'model':db[_0xf259('0xd0')],'as':'Tags','attributes':['id','name',_0xf259('0xd1')],'where':_0x2f4899[_0xf259('0x48')][_0xf259('0xd2')]?{'id':_0x2f4899[_0xf259('0x48')][_0xf259('0xd2')]}:undefined,'required':_0x2f4899[_0xf259('0x48')]['tag']?!![]:![]}];}if(!_0x2f4899[_0xf259('0x48')]['hasOwnProperty'](_0xf259('0xd3'))){_0x3882a5[_0xf259('0x23')]=qs[_0xf259('0x23')](_0x2f4899[_0xf259('0x48')][_0xf259('0x23')]);_0x3882a5[_0xf259('0x20')]=qs['offset'](_0x2f4899[_0xf259('0x48')]['offset']);}return _0xc18db0[_0xf259('0xc9')](_0x3882a5);}})['then'](function(_0x1a3222){if(_0x1a3222){return _0x1a3222?{'count':_0x4172b5,'rows':_0x1a3222}:null;}})['then'](respondWithResult(_0x41203b,null))[_0xf259('0x1d')](handleError(_0x41203b,null));};exports[_0xf259('0xd4')]=function(_0x38602b,_0x8e7b59){var _0x59aaab;var _0x1d9188={};var _0x59f581;return db['User'][_0xf259('0x98')]({'where':{'id':_0x38602b[_0xf259('0x5e')]['id']},'attributes':['id',_0xf259('0x34'),'role']})[_0xf259('0x28')](handleEntityNotFound(_0x8e7b59,null))[_0xf259('0x28')](function(_0x2fba14){if(!utils['isValidChannel'](_0x38602b[_0xf259('0x48')]['channel'])){throw new db[(_0xf259('0x94'))]['ValidationError'](_0xf259('0xb0'));}_0x59aaab=_0x2fba14;var _0x1aef26={};_0x1aef26[_0xf259('0x54')]=_[_0xf259('0x51')](db[_['capitalize'](_0x38602b['query']['channel'])+'Queue'][_0xf259('0x3b')]);_0x1aef26['query']=_['keys'](_0x38602b[_0xf259('0x48')]);_0x1aef26[_0xf259('0xca')]=_[_0xf259('0x53')](_0x1aef26[_0xf259('0x54')],_0x1aef26[_0xf259('0x48')]);_0x1d9188[_0xf259('0x45')]=_['intersection'](_0x1aef26[_0xf259('0x54')],qs[_0xf259('0x55')](_0x38602b[_0xf259('0x48')][_0xf259('0x55')]));_0x1d9188[_0xf259('0x45')]=_0x1d9188[_0xf259('0x45')][_0xf259('0x4a')]?_0x1d9188[_0xf259('0x45')]:_0x1aef26[_0xf259('0x54')];_0x1d9188['order']=qs['sort'](_0x38602b[_0xf259('0x48')][_0xf259('0xcb')]);_0x1d9188[_0xf259('0x41')]=qs[_0xf259('0xca')](_[_0xf259('0xcc')](_0x38602b[_0xf259('0x48')],_0x1aef26['filters']));if(_0x38602b[_0xf259('0x48')]['filter']){_0x1d9188[_0xf259('0x41')]=_[_0xf259('0x57')](_0x1d9188[_0xf259('0x41')],{'$or':_[_0xf259('0x30')](_0x1d9188[_0xf259('0x45')],function(_0xa7bd97){var _0x49dc9f={};_0x49dc9f[_0xa7bd97]={'$like':'%'+_0x38602b[_0xf259('0x48')][_0xf259('0x2e')]+'%'};return _0x49dc9f;})});}_0x1d9188=_[_0xf259('0x57')]({},_0x1d9188,_0x38602b['options']);switch(_0x59aaab[_0xf259('0x29')]){case'admin':return db[_['capitalize'](_0x38602b[_0xf259('0x48')][_0xf259('0x9d')])+_0xf259('0xd5')][_0xf259('0xab')](_0x1d9188);case _0xf259('0x7d'):case _0xf259('0x7e'):return _0x59aaab[_0xf259('0xd6')+_['capitalize'](_0x38602b[_0xf259('0x48')][_0xf259('0x9d')])+'Queues'](_0x1d9188);default:throw new db['Sequelize'][(_0xf259('0x91'))](_0xf259('0xd7'));}})[_0xf259('0x28')](function(_0x7f3412){_0x59f581=_0x7f3412[_0xf259('0x4a')];if(!_0x38602b[_0xf259('0x48')][_0xf259('0xcd')]('nolimit')){_0x1d9188[_0xf259('0x23')]=qs['limit'](_0x38602b[_0xf259('0x48')]['limit']);_0x1d9188[_0xf259('0x20')]=qs['offset'](_0x38602b['query'][_0xf259('0x20')]);}switch(_0x59aaab['role']){case _0xf259('0x2a'):return db[_[_0xf259('0xa3')](_0x38602b[_0xf259('0x48')][_0xf259('0x9d')])+'Queue'][_0xf259('0xab')](_0x1d9188);case _0xf259('0x7d'):case'agent':return _0x59aaab[_0xf259('0xd6')+_['capitalize'](_0x38602b[_0xf259('0x48')][_0xf259('0x9d')])+'Queues'](_0x1d9188);}})[_0xf259('0x28')](function(_0x100f86){return{'count':_0x59f581,'rows':_0x100f86};})[_0xf259('0x28')](respondWithResult(_0x8e7b59,null))[_0xf259('0x1d')](handleError(_0x8e7b59,null));};exports[_0xf259('0xd8')]=function(_0x47715d,_0x21cdad){var _0x8abcc2={};var _0x5d1323={};var _0x5d8ce4;var _0xb74399;return db[_0xf259('0x3a')][_0xf259('0x98')]({'where':{'id':_0x47715d[_0xf259('0x5e')]['id']}})[_0xf259('0x28')](handleEntityNotFound(_0x21cdad,null))[_0xf259('0x28')](function(_0x5ae2bd){if(_0x5ae2bd){_0x5d8ce4=_0x5ae2bd;_0x5d1323['model']=_['keys'](db['UserVoiceQueueRt'][_0xf259('0x3b')]);_0x5d1323[_0xf259('0x48')]=_['keys'](_0x47715d[_0xf259('0x48')]);_0x5d1323[_0xf259('0xca')]=_[_0xf259('0x53')](_0x5d1323[_0xf259('0x54')],_0x5d1323['query']);_0x8abcc2[_0xf259('0x45')]=_[_0xf259('0x53')](_0x5d1323[_0xf259('0x54')],qs[_0xf259('0x55')](_0x47715d[_0xf259('0x48')][_0xf259('0x55')]));_0x8abcc2[_0xf259('0x45')]=_0x8abcc2[_0xf259('0x45')][_0xf259('0x4a')]?_0x8abcc2[_0xf259('0x45')]:_0x5d1323[_0xf259('0x54')];_0x8abcc2[_0xf259('0xd9')]=qs[_0xf259('0xcb')](_0x47715d[_0xf259('0x48')]['sort']);_0x8abcc2['where']=qs[_0xf259('0xca')](_[_0xf259('0xcc')](_0x47715d[_0xf259('0x48')],_0x5d1323['filters']));if(_0x47715d['query'][_0xf259('0x2e')]){_0x8abcc2[_0xf259('0x41')]=_[_0xf259('0x57')](_0x8abcc2[_0xf259('0x41')],{'$or':_['map'](_0x8abcc2[_0xf259('0x45')],function(_0x437986){var _0x4a654d={};_0x4a654d[_0x437986]={'$like':'%'+_0x47715d[_0xf259('0x48')][_0xf259('0x2e')]+'%'};return _0x4a654d;})});}_0x8abcc2=_[_0xf259('0x57')]({},_0x8abcc2,_0x47715d['options']);return _0x5d8ce4[_0xf259('0xd8')](_0x8abcc2);}})[_0xf259('0x28')](function(_0x206c5c){if(_0x206c5c){_0xb74399=_0x206c5c[_0xf259('0x4a')];if(!_0x47715d[_0xf259('0x48')][_0xf259('0xcd')](_0xf259('0xd3'))){_0x8abcc2['limit']=qs['limit'](_0x47715d[_0xf259('0x48')][_0xf259('0x23')]);_0x8abcc2[_0xf259('0x20')]=qs[_0xf259('0x20')](_0x47715d[_0xf259('0x48')][_0xf259('0x20')]);}return _0x5d8ce4[_0xf259('0xd8')](_0x8abcc2);}})['then'](function(_0x159d3f){if(_0x159d3f){return _0x159d3f?{'count':_0xb74399,'rows':_0x159d3f}:null;}})['then'](respondWithResult(_0x21cdad,null))[_0xf259('0x1d')](handleError(_0x21cdad,null));};exports['getGroups']=function(_0x3f0522,_0x5a1871){var _0x36a650={};var _0xd19f4c={};var _0x3d7738;var _0x12044b;return db[_0xf259('0x3a')]['findOne']({'where':{'id':_0x3f0522[_0xf259('0x5e')]['id']}})[_0xf259('0x28')](handleEntityNotFound(_0x5a1871,null))[_0xf259('0x28')](function(_0x4e43ff){if(_0x4e43ff){_0x3d7738=_0x4e43ff;_0xd19f4c[_0xf259('0x54')]=_[_0xf259('0x51')](db[_0xf259('0xda')]['rawAttributes']);_0xd19f4c['query']=_[_0xf259('0x51')](_0x3f0522[_0xf259('0x48')]);_0xd19f4c['filters']=_[_0xf259('0x53')](_0xd19f4c[_0xf259('0x54')],_0xd19f4c[_0xf259('0x48')]);_0x36a650[_0xf259('0x45')]=_[_0xf259('0x53')](_0xd19f4c['model'],qs[_0xf259('0x55')](_0x3f0522[_0xf259('0x48')][_0xf259('0x55')]));_0x36a650[_0xf259('0x45')]=_0x36a650[_0xf259('0x45')][_0xf259('0x4a')]?_0x36a650[_0xf259('0x45')]:_0xd19f4c['model'];_0x36a650[_0xf259('0xd9')]=qs[_0xf259('0xcb')](_0x3f0522[_0xf259('0x48')][_0xf259('0xcb')]);_0x36a650[_0xf259('0x41')]=qs[_0xf259('0xca')](_[_0xf259('0xcc')](_0x3f0522[_0xf259('0x48')],_0xd19f4c['filters']));if(_0x3f0522['query']['filter']){_0x36a650['where']=_[_0xf259('0x57')](_0x36a650[_0xf259('0x41')],{'$or':_[_0xf259('0x30')](_0x36a650['attributes'],function(_0x269d5b){var _0x4f37e1={};_0x4f37e1[_0x269d5b]={'$like':'%'+_0x3f0522['query'][_0xf259('0x2e')]+'%'};return _0x4f37e1;})});}_0x36a650=_[_0xf259('0x57')]({},_0x36a650,_0x3f0522['options']);return _0x3d7738[_0xf259('0xdb')](_0x36a650);}})['then'](function(_0x240873){if(_0x240873){_0x12044b=_0x240873[_0xf259('0x4a')];if(!_0x3f0522['query']['hasOwnProperty']('nolimit')){_0x36a650['limit']=qs[_0xf259('0x23')](_0x3f0522['query'][_0xf259('0x23')]);_0x36a650[_0xf259('0x20')]=qs[_0xf259('0x20')](_0x3f0522[_0xf259('0x48')][_0xf259('0x20')]);}return _0x3d7738[_0xf259('0xdb')](_0x36a650);}})[_0xf259('0x28')](function(_0x33904b){if(_0x33904b){return _0x33904b?{'count':_0x12044b,'rows':_0x33904b}:null;}})[_0xf259('0x28')](respondWithResult(_0x5a1871,null))[_0xf259('0x1d')](handleError(_0x5a1871,null));};exports['getRecordings']=function(_0x1bf008,_0x15acd3){var _0x1331a2={'raw':!![],'where':{}};var _0x43fbb9={};var _0x353072={'count':0x0,'rows':[]};return db['User'][_0xf259('0x98')]({'where':{'id':_0x1bf008[_0xf259('0x5e')]['id']}})['then'](handleEntityNotFound(_0x15acd3,null))[_0xf259('0x28')](function(_0x1e7273){if(_0x1e7273){_0x43fbb9[_0xf259('0x54')]=_[_0xf259('0x51')](db[_0xf259('0xdc')][_0xf259('0x3b')]);_0x43fbb9['query']=_[_0xf259('0x51')](_0x1bf008[_0xf259('0x48')]);_0x43fbb9[_0xf259('0xca')]=_['intersection'](_0x43fbb9[_0xf259('0x54')],_0x43fbb9['query']);_0x1331a2[_0xf259('0x45')]=_[_0xf259('0x53')](_0x43fbb9['model'],qs[_0xf259('0x55')](_0x1bf008[_0xf259('0x48')]['fields']));_0x1331a2['attributes']=_0x1331a2['attributes']['length']?_0x1331a2[_0xf259('0x45')]:_0x43fbb9[_0xf259('0x54')];if(!_0x1bf008[_0xf259('0x48')][_0xf259('0xcd')](_0xf259('0xd3'))){_0x1331a2['limit']=qs[_0xf259('0x23')](_0x1bf008[_0xf259('0x48')]['limit']);_0x1331a2[_0xf259('0x20')]=qs[_0xf259('0x20')](_0x1bf008[_0xf259('0x48')]['offset']);}_0x1331a2['order']=qs[_0xf259('0xcb')](_0x1bf008[_0xf259('0x48')]['sort']);_0x1331a2[_0xf259('0x41')]=qs['filters'](_['pick'](_0x1bf008[_0xf259('0x48')],_0x43fbb9[_0xf259('0xca')]));_0x1331a2[_0xf259('0x41')][_0xf259('0xdd')]=_0x1e7273['id'];if(_0x1bf008['query']['filter']){_0x1331a2[_0xf259('0x41')]=_['merge'](_0x1331a2[_0xf259('0x41')],{'$or':_['map'](_0x1331a2[_0xf259('0x45')],function(_0x3b2f48){var _0x347143={};_0x347143[_0x3b2f48]={'$like':'%'+_0x1bf008['query'][_0xf259('0x2e')]+'%'};return _0x347143;})});}_0x1331a2=_[_0xf259('0x57')]({},_0x1331a2,_0x1bf008[_0xf259('0xde')]);return db[_0xf259('0xdc')]['count']({'where':_0x1331a2[_0xf259('0x41')]})['then'](function(_0x2fcd86){_0x353072[_0xf259('0x22')]=_0x2fcd86;if(_0x1bf008[_0xf259('0x48')][_0xf259('0xce')]){_0x1331a2[_0xf259('0x56')]=[{'all':!![]}];}return db[_0xf259('0xdc')]['findAll'](_0x1331a2);})[_0xf259('0x28')](function(_0x53b054){_0x353072['rows']=_0x53b054;return _0x353072;});}})[_0xf259('0x28')](respondWithFilteredResult(_0x15acd3,_0x1331a2))[_0xf259('0x1d')](handleError(_0x15acd3,null));};exports['getScreenRecordings']=function(_0x3acdff,_0x4a1192){var _0x38a489={'raw':!![],'where':{}};var _0x58b278={};var _0x229989={'count':0x0,'rows':[]};return db[_0xf259('0x3a')][_0xf259('0x98')]({'where':{'id':_0x3acdff[_0xf259('0x5e')]['id']}})[_0xf259('0x28')](handleEntityNotFound(_0x4a1192,null))[_0xf259('0x28')](function(_0x162dcd){if(_0x162dcd){_0x58b278[_0xf259('0x54')]=_['keys'](db[_0xf259('0xdf')][_0xf259('0x3b')]);_0x58b278[_0xf259('0x48')]=_[_0xf259('0x51')](_0x3acdff[_0xf259('0x48')]);_0x58b278[_0xf259('0xca')]=_[_0xf259('0x53')](_0x58b278[_0xf259('0x54')],_0x58b278['query']);_0x38a489[_0xf259('0x45')]=_[_0xf259('0x53')](_0x58b278[_0xf259('0x54')],qs[_0xf259('0x55')](_0x3acdff[_0xf259('0x48')][_0xf259('0x55')]));_0x38a489[_0xf259('0x45')]=_0x38a489['attributes']['length']?_0x38a489[_0xf259('0x45')]:_0x58b278[_0xf259('0x54')];if(!_0x3acdff[_0xf259('0x48')][_0xf259('0xcd')](_0xf259('0xd3'))){_0x38a489[_0xf259('0x23')]=qs['limit'](_0x3acdff[_0xf259('0x48')]['limit']);_0x38a489[_0xf259('0x20')]=qs[_0xf259('0x20')](_0x3acdff['query'][_0xf259('0x20')]);}_0x38a489[_0xf259('0xd9')]=qs['sort'](_0x3acdff['query'][_0xf259('0xcb')]);_0x38a489[_0xf259('0x41')]=qs[_0xf259('0xca')](_['pick'](_0x3acdff[_0xf259('0x48')],_0x58b278[_0xf259('0xca')]));_0x38a489[_0xf259('0x41')][_0xf259('0xdd')]=_0x162dcd['id'];if(_0x3acdff['query'][_0xf259('0x2e')]){_0x38a489[_0xf259('0x41')]=_[_0xf259('0x57')](_0x38a489[_0xf259('0x41')],{'$or':_[_0xf259('0x30')](_0x38a489[_0xf259('0x45')],function(_0x407403){var _0x54ff4a={};_0x54ff4a[_0x407403]={'$like':'%'+_0x3acdff['query']['filter']+'%'};return _0x54ff4a;})});}_0x38a489=_[_0xf259('0x57')]({},_0x38a489,_0x3acdff[_0xf259('0xde')]);return db['ScreenRecording'][_0xf259('0x22')]({'where':_0x38a489[_0xf259('0x41')]})['then'](function(_0x3675a2){_0x229989['count']=_0x3675a2;if(_0x3acdff[_0xf259('0x48')][_0xf259('0xce')]){_0x38a489[_0xf259('0x56')]=[{'all':!![]}];}return db[_0xf259('0xdf')][_0xf259('0xab')](_0x38a489);})[_0xf259('0x28')](function(_0x14343f){_0x229989[_0xf259('0x47')]=_0x14343f;return _0x229989;});}})[_0xf259('0x28')](respondWithFilteredResult(_0x4a1192,_0x38a489))[_0xf259('0x1d')](handleError(_0x4a1192,null));};exports[_0xf259('0xe0')]=function(_0x418422,_0x29abb4){var _0xcd54ce={};var _0x5658bf={};var _0x54b9c2;var _0x538ca5;return db[_0xf259('0x3a')][_0xf259('0x98')]({'where':{'id':_0x418422[_0xf259('0x5e')]['id']}})['then'](handleEntityNotFound(_0x29abb4,null))[_0xf259('0x28')](function(_0x488df7){if(_0x488df7){_0x54b9c2=_0x488df7;_0x5658bf[_0xf259('0x54')]=_['keys'](db['ChatInteraction'][_0xf259('0x3b')]);_0x5658bf['query']=_[_0xf259('0x51')](_0x418422[_0xf259('0x48')]);_0x5658bf['filters']=_[_0xf259('0x53')](_0x5658bf[_0xf259('0x54')],_0x5658bf[_0xf259('0x48')]);_0xcd54ce[_0xf259('0x45')]=_[_0xf259('0x53')](_0x5658bf['model'],qs[_0xf259('0x55')](_0x418422['query'][_0xf259('0x55')]));_0xcd54ce['attributes']=_0xcd54ce[_0xf259('0x45')]['length']?_0xcd54ce['attributes']:_0x5658bf[_0xf259('0x54')];_0xcd54ce[_0xf259('0xd9')]=qs[_0xf259('0xcb')](_0x418422[_0xf259('0x48')][_0xf259('0xcb')]);_0xcd54ce['where']=qs['filters'](_[_0xf259('0xcc')](_0x418422[_0xf259('0x48')],_0x5658bf[_0xf259('0xca')]));if(_0x418422[_0xf259('0x48')][_0xf259('0x2e')]){_0xcd54ce[_0xf259('0x41')]=_['merge'](_0xcd54ce[_0xf259('0x41')],{'$or':_[_0xf259('0x30')](_0xcd54ce[_0xf259('0x45')],function(_0xb1367e){var _0x474021={};_0x474021[_0xb1367e]={'$like':'%'+_0x418422[_0xf259('0x48')][_0xf259('0x2e')]+'%'};return _0x474021;})});}_0xcd54ce=_['merge']({},_0xcd54ce,_0x418422['options']);return _0x54b9c2['getChatInteractions'](_0xcd54ce);}})[_0xf259('0x28')](function(_0xea7faa){if(_0xea7faa){_0x538ca5=_0xea7faa[_0xf259('0x4a')];if(!_0x418422[_0xf259('0x48')]['hasOwnProperty'](_0xf259('0xd3'))){_0xcd54ce[_0xf259('0x23')]=qs['limit'](_0x418422[_0xf259('0x48')]['limit']);_0xcd54ce[_0xf259('0x20')]=qs[_0xf259('0x20')](_0x418422[_0xf259('0x48')][_0xf259('0x20')]);}return _0x54b9c2[_0xf259('0xe0')](_0xcd54ce);}})[_0xf259('0x28')](function(_0x1d55c9){if(_0x1d55c9){return _0x1d55c9?{'count':_0x538ca5,'rows':_0x1d55c9}:null;}})[_0xf259('0x28')](respondWithResult(_0x29abb4,null))[_0xf259('0x1d')](handleError(_0x29abb4,null));};exports[_0xf259('0xe1')]=function(_0x58c286,_0x338af1){var _0x3bcbe3={};var _0x2bf710={};var _0x10fec6;var _0x4952e2;return db['User'][_0xf259('0x98')]({'where':{'id':_0x58c286[_0xf259('0x5e')]['id']}})[_0xf259('0x28')](handleEntityNotFound(_0x338af1,null))[_0xf259('0x28')](function(_0x22c29b){if(_0x22c29b){_0x10fec6=_0x22c29b;_0x2bf710[_0xf259('0x54')]=_['keys'](db[_0xf259('0xe2')]['rawAttributes']);_0x2bf710['query']=_[_0xf259('0x51')](_0x58c286[_0xf259('0x48')]);_0x2bf710[_0xf259('0xca')]=_[_0xf259('0x53')](_0x2bf710[_0xf259('0x54')],_0x2bf710[_0xf259('0x48')]);_0x3bcbe3['attributes']=_['intersection'](_0x2bf710['model'],qs[_0xf259('0x55')](_0x58c286[_0xf259('0x48')][_0xf259('0x55')]));_0x3bcbe3['attributes']=_0x3bcbe3['attributes'][_0xf259('0x4a')]?_0x3bcbe3[_0xf259('0x45')]:_0x2bf710['model'];_0x3bcbe3[_0xf259('0xd9')]=qs[_0xf259('0xcb')](_0x58c286[_0xf259('0x48')][_0xf259('0xcb')]);_0x3bcbe3['where']=qs['filters'](_[_0xf259('0xcc')](_0x58c286['query'],_0x2bf710[_0xf259('0xca')]));if(_0x58c286[_0xf259('0x48')][_0xf259('0x2e')]){_0x3bcbe3[_0xf259('0x41')]=_[_0xf259('0x57')](_0x3bcbe3['where'],{'$or':_['map'](_0x3bcbe3['attributes'],function(_0x50b1d2){var _0x34902a={};_0x34902a[_0x50b1d2]={'$like':'%'+_0x58c286[_0xf259('0x48')][_0xf259('0x2e')]+'%'};return _0x34902a;})});}_0x3bcbe3=_[_0xf259('0x57')]({},_0x3bcbe3,_0x58c286[_0xf259('0xde')]);return _0x10fec6[_0xf259('0xe1')](_0x3bcbe3);}})[_0xf259('0x28')](function(_0xad5582){if(_0xad5582){_0x4952e2=_0xad5582[_0xf259('0x4a')];if(!_0x58c286[_0xf259('0x48')]['hasOwnProperty'](_0xf259('0xd3'))){_0x3bcbe3[_0xf259('0x23')]=qs[_0xf259('0x23')](_0x58c286[_0xf259('0x48')][_0xf259('0x23')]);_0x3bcbe3['offset']=qs[_0xf259('0x20')](_0x58c286['query'][_0xf259('0x20')]);}return _0x10fec6[_0xf259('0xe1')](_0x3bcbe3);}})[_0xf259('0x28')](function(_0x5682e5){if(_0x5682e5){return _0x5682e5?{'count':_0x4952e2,'rows':_0x5682e5}:null;}})['then'](respondWithResult(_0x338af1,null))[_0xf259('0x1d')](handleError(_0x338af1,null));};exports[_0xf259('0xe3')]=function(_0x82b8e0,_0xea2d78){var _0x321851={'raw':!![],'where':{}};var _0x387ff4={};var _0x3feb29={'count':0x0,'rows':[]};return db[_0xf259('0x3a')][_0xf259('0x98')]({'where':{'id':_0x82b8e0['params']['id']}})[_0xf259('0x28')](handleEntityNotFound(_0xea2d78,null))[_0xf259('0x28')](function(_0xbd2b01){if(_0xbd2b01){_0x387ff4[_0xf259('0x54')]=_[_0xf259('0x51')](db[_0xf259('0xe4')][_0xf259('0x3b')]);_0x387ff4[_0xf259('0x48')]=_[_0xf259('0x51')](_0x82b8e0[_0xf259('0x48')]);_0x387ff4[_0xf259('0xca')]=_[_0xf259('0x53')](_0x387ff4[_0xf259('0x54')],_0x387ff4[_0xf259('0x48')]);_0x321851[_0xf259('0x45')]=_[_0xf259('0x53')](_0x387ff4[_0xf259('0x54')],qs[_0xf259('0x55')](_0x82b8e0[_0xf259('0x48')][_0xf259('0x55')]));_0x321851[_0xf259('0x45')]=_0x321851[_0xf259('0x45')][_0xf259('0x4a')]?_0x321851[_0xf259('0x45')]:_0x387ff4[_0xf259('0x54')];if(!_0x82b8e0[_0xf259('0x48')]['hasOwnProperty'](_0xf259('0xd3'))){_0x321851[_0xf259('0x23')]=qs[_0xf259('0x23')](_0x82b8e0['query'][_0xf259('0x23')]);_0x321851['offset']=qs[_0xf259('0x20')](_0x82b8e0[_0xf259('0x48')][_0xf259('0x20')]);}_0x321851[_0xf259('0xd9')]=qs[_0xf259('0xcb')](_0x82b8e0['query'][_0xf259('0xcb')]);_0x321851[_0xf259('0x41')]=qs[_0xf259('0xca')](_[_0xf259('0xcc')](_0x82b8e0[_0xf259('0x48')],_0x387ff4[_0xf259('0xca')]));_0x321851['where'][_0xf259('0xdd')]=_0xbd2b01['id'];if(_0x82b8e0[_0xf259('0x48')]['filter']){_0x321851[_0xf259('0x41')]=_[_0xf259('0x57')](_0x321851[_0xf259('0x41')],{'$or':_[_0xf259('0x30')](_0x321851[_0xf259('0x45')],function(_0x9d390b){var _0x4b9907={};_0x4b9907[_0x9d390b]={'$like':'%'+_0x82b8e0[_0xf259('0x48')][_0xf259('0x2e')]+'%'};return _0x4b9907;})});}_0x321851=_[_0xf259('0x57')]({},_0x321851,_0x82b8e0[_0xf259('0xde')]);return db['MailInteraction'][_0xf259('0x22')]({'where':_0x321851[_0xf259('0x41')]})[_0xf259('0x28')](function(_0x230080){_0x3feb29[_0xf259('0x22')]=_0x230080;if(_0x82b8e0[_0xf259('0x48')][_0xf259('0xce')]){_0x321851[_0xf259('0x56')]=[{'all':!![]}];}return db[_0xf259('0xe4')]['findAll'](_0x321851);})['then'](function(_0x2d53e6){_0x3feb29['rows']=_0x2d53e6;return _0x3feb29;});}})['then'](respondWithFilteredResult(_0xea2d78,_0x321851))[_0xf259('0x1d')](handleError(_0xea2d78,null));};exports['getSmsInteractions']=function(_0x4e730b,_0x1ed447){var _0x2f037c={};var _0xe80dad={};var _0x4eceab;var _0x5a50d3;return db[_0xf259('0x3a')][_0xf259('0x98')]({'where':{'id':_0x4e730b[_0xf259('0x5e')]['id']}})[_0xf259('0x28')](handleEntityNotFound(_0x1ed447,null))[_0xf259('0x28')](function(_0x12f1cc){if(_0x12f1cc){_0x4eceab=_0x12f1cc;_0xe80dad['model']=_[_0xf259('0x51')](db[_0xf259('0xe5')][_0xf259('0x3b')]);_0xe80dad[_0xf259('0x48')]=_[_0xf259('0x51')](_0x4e730b[_0xf259('0x48')]);_0xe80dad[_0xf259('0xca')]=_[_0xf259('0x53')](_0xe80dad['model'],_0xe80dad['query']);_0x2f037c[_0xf259('0x45')]=_[_0xf259('0x53')](_0xe80dad[_0xf259('0x54')],qs[_0xf259('0x55')](_0x4e730b[_0xf259('0x48')][_0xf259('0x55')]));_0x2f037c[_0xf259('0x45')]=_0x2f037c[_0xf259('0x45')][_0xf259('0x4a')]?_0x2f037c[_0xf259('0x45')]:_0xe80dad[_0xf259('0x54')];_0x2f037c[_0xf259('0xd9')]=qs['sort'](_0x4e730b[_0xf259('0x48')][_0xf259('0xcb')]);_0x2f037c[_0xf259('0x41')]=qs[_0xf259('0xca')](_['pick'](_0x4e730b[_0xf259('0x48')],_0xe80dad[_0xf259('0xca')]));if(_0x4e730b[_0xf259('0x48')][_0xf259('0x2e')]){_0x2f037c['where']=_[_0xf259('0x57')](_0x2f037c[_0xf259('0x41')],{'$or':_[_0xf259('0x30')](_0x2f037c[_0xf259('0x45')],function(_0xc65f95){var _0x5aa8ef={};_0x5aa8ef[_0xc65f95]={'$like':'%'+_0x4e730b['query']['filter']+'%'};return _0x5aa8ef;})});}_0x2f037c=_[_0xf259('0x57')]({},_0x2f037c,_0x4e730b['options']);return _0x4eceab[_0xf259('0xe6')](_0x2f037c);}})[_0xf259('0x28')](function(_0xbe78a0){if(_0xbe78a0){_0x5a50d3=_0xbe78a0[_0xf259('0x4a')];if(!_0x4e730b[_0xf259('0x48')][_0xf259('0xcd')](_0xf259('0xd3'))){_0x2f037c[_0xf259('0x23')]=qs[_0xf259('0x23')](_0x4e730b[_0xf259('0x48')]['limit']);_0x2f037c[_0xf259('0x20')]=qs[_0xf259('0x20')](_0x4e730b['query'][_0xf259('0x20')]);}return _0x4eceab[_0xf259('0xe6')](_0x2f037c);}})[_0xf259('0x28')](function(_0x1c2fb9){if(_0x1c2fb9){return _0x1c2fb9?{'count':_0x5a50d3,'rows':_0x1c2fb9}:null;}})['then'](respondWithResult(_0x1ed447,null))[_0xf259('0x1d')](handleError(_0x1ed447,null));};exports[_0xf259('0xe7')]=function(_0x16e5e2,_0x571465){var _0x4e07c7={};var _0x3f8bff={};var _0x5d56b9;var _0x446bf8;return db[_0xf259('0x3a')][_0xf259('0x98')]({'where':{'id':_0x16e5e2[_0xf259('0x5e')]['id']}})[_0xf259('0x28')](handleEntityNotFound(_0x571465,null))[_0xf259('0x28')](function(_0x11f9eb){if(_0x11f9eb){_0x5d56b9=_0x11f9eb;_0x3f8bff['model']=_[_0xf259('0x51')](db['FaxInteraction'][_0xf259('0x3b')]);_0x3f8bff[_0xf259('0x48')]=_[_0xf259('0x51')](_0x16e5e2['query']);_0x3f8bff[_0xf259('0xca')]=_[_0xf259('0x53')](_0x3f8bff['model'],_0x3f8bff[_0xf259('0x48')]);_0x4e07c7[_0xf259('0x45')]=_['intersection'](_0x3f8bff[_0xf259('0x54')],qs['fields'](_0x16e5e2[_0xf259('0x48')][_0xf259('0x55')]));_0x4e07c7[_0xf259('0x45')]=_0x4e07c7[_0xf259('0x45')]['length']?_0x4e07c7[_0xf259('0x45')]:_0x3f8bff['model'];_0x4e07c7[_0xf259('0xd9')]=qs[_0xf259('0xcb')](_0x16e5e2[_0xf259('0x48')][_0xf259('0xcb')]);_0x4e07c7[_0xf259('0x41')]=qs[_0xf259('0xca')](_['pick'](_0x16e5e2[_0xf259('0x48')],_0x3f8bff[_0xf259('0xca')]));if(_0x16e5e2[_0xf259('0x48')][_0xf259('0x2e')]){_0x4e07c7[_0xf259('0x41')]=_[_0xf259('0x57')](_0x4e07c7[_0xf259('0x41')],{'$or':_[_0xf259('0x30')](_0x4e07c7['attributes'],function(_0x5e7a7a){var _0x41b75e={};_0x41b75e[_0x5e7a7a]={'$like':'%'+_0x16e5e2[_0xf259('0x48')][_0xf259('0x2e')]+'%'};return _0x41b75e;})});}_0x4e07c7=_[_0xf259('0x57')]({},_0x4e07c7,_0x16e5e2['options']);return _0x5d56b9[_0xf259('0xe7')](_0x4e07c7);}})['then'](function(_0x1bde73){if(_0x1bde73){_0x446bf8=_0x1bde73[_0xf259('0x4a')];if(!_0x16e5e2[_0xf259('0x48')][_0xf259('0xcd')](_0xf259('0xd3'))){_0x4e07c7['limit']=qs[_0xf259('0x23')](_0x16e5e2[_0xf259('0x48')]['limit']);_0x4e07c7[_0xf259('0x20')]=qs[_0xf259('0x20')](_0x16e5e2['query'][_0xf259('0x20')]);}return _0x5d56b9['getFaxInteractions'](_0x4e07c7);}})[_0xf259('0x28')](function(_0x43c017){if(_0x43c017){return _0x43c017?{'count':_0x446bf8,'rows':_0x43c017}:null;}})[_0xf259('0x28')](respondWithResult(_0x571465,null))[_0xf259('0x1d')](handleError(_0x571465,null));};exports[_0xf259('0xe8')]=function(_0x221d6d,_0x2661c5){var _0x1190c2={};var _0x129171={};var _0x19490c;var _0x4dd2a8;return db[_0xf259('0x3a')]['findOne']({'where':{'id':_0x221d6d[_0xf259('0x5e')]['id']}})['then'](handleEntityNotFound(_0x2661c5,null))[_0xf259('0x28')](function(_0x3a80d9){if(_0x3a80d9){_0x19490c=_0x3a80d9;_0x129171[_0xf259('0x54')]=_[_0xf259('0x51')](db[_0xf259('0xe9')][_0xf259('0x3b')]);_0x129171['query']=_[_0xf259('0x51')](_0x221d6d[_0xf259('0x48')]);_0x129171[_0xf259('0xca')]=_[_0xf259('0x53')](_0x129171[_0xf259('0x54')],_0x129171[_0xf259('0x48')]);_0x1190c2[_0xf259('0x45')]=_[_0xf259('0x53')](_0x129171['model'],qs[_0xf259('0x55')](_0x221d6d[_0xf259('0x48')]['fields']));_0x1190c2['attributes']=_0x1190c2[_0xf259('0x45')][_0xf259('0x4a')]?_0x1190c2[_0xf259('0x45')]:_0x129171[_0xf259('0x54')];_0x1190c2[_0xf259('0xd9')]=qs[_0xf259('0xcb')](_0x221d6d[_0xf259('0x48')][_0xf259('0xcb')]);_0x1190c2['where']=qs[_0xf259('0xca')](_[_0xf259('0xcc')](_0x221d6d[_0xf259('0x48')],_0x129171[_0xf259('0xca')]));if(_0x221d6d[_0xf259('0x48')][_0xf259('0x2e')]){_0x1190c2[_0xf259('0x41')]=_[_0xf259('0x57')](_0x1190c2['where'],{'$or':_[_0xf259('0x30')](_0x1190c2['attributes'],function(_0x121657){var _0x14317f={};_0x14317f[_0x121657]={'$like':'%'+_0x221d6d['query'][_0xf259('0x2e')]+'%'};return _0x14317f;})});}_0x1190c2=_[_0xf259('0x57')]({},_0x1190c2,_0x221d6d[_0xf259('0xde')]);return _0x19490c[_0xf259('0xe8')](_0x1190c2);}})['then'](function(_0x52bbc8){if(_0x52bbc8){_0x4dd2a8=_0x52bbc8[_0xf259('0x4a')];if(!_0x221d6d[_0xf259('0x48')][_0xf259('0xcd')](_0xf259('0xd3'))){_0x1190c2[_0xf259('0x23')]=qs[_0xf259('0x23')](_0x221d6d['query']['limit']);_0x1190c2[_0xf259('0x20')]=qs[_0xf259('0x20')](_0x221d6d['query'][_0xf259('0x20')]);}return _0x19490c[_0xf259('0xe8')](_0x1190c2);}})[_0xf259('0x28')](function(_0x4101d7){if(_0x4101d7){return _0x4101d7?{'count':_0x4dd2a8,'rows':_0x4101d7}:null;}})[_0xf259('0x28')](respondWithResult(_0x2661c5,null))['catch'](handleError(_0x2661c5,null));};exports['login']=function(_0x445098,_0x57ba32,_0x15eeab){var _0xac611a;var _0x431d33;var _0x2089b5;var _0x52428b=!_[_0xf259('0x66')](_0x445098[_0xf259('0x5e')]['id'])?_0x445098[_0xf259('0x5e')]['id']:!_['isNil'](_0x445098[_0xf259('0x7d')]['id'])?_0x445098[_0xf259('0x7d')]['id']:null;return db[_0xf259('0x3a')][_0xf259('0x33')]({'where':{'id':_0x52428b,'role':{'$or':[_0xf259('0x2a'),_0xf259('0x7d'),_0xf259('0x7e')]}},'attributes':['id',_0xf259('0x34'),'phone','mobile',_0xf259('0x29'),_0xf259('0x61'),'loginInPause']})[_0xf259('0x28')](function(_0x375a3a){if(_0x375a3a){if(_0x375a3a[_0xf259('0x29')]===_0xf259('0x7e')){_0xac611a=_0x375a3a;if(_0x445098['body'][_0xf259('0xa0')]){_0x2089b5=util[_0xf259('0xac')](_0xf259('0xea'),_0xac611a[_0x445098[_0xf259('0x5b')][_0xf259('0xa0')]]);}else if(_0x445098[_0xf259('0x5b')][_0xf259('0xeb')]){_0x2089b5=util[_0xf259('0xac')](_0xf259('0xad'),_0x445098['body'][_0xf259('0xeb')]);}else{_0x2089b5=util[_0xf259('0xac')](_0xf259('0xad'),_0xac611a[_0xf259('0x34')]);}socket['to'](util['format'](_0xf259('0xec'),_0xac611a['name']))[_0xf259('0xa8')](_0xf259('0xed'),{'user':{'id':_0xac611a['id'],'name':_0xac611a[_0xf259('0x34')]},'ip':_0x445098[_0xf259('0xee')][_0xf259('0xef')]||_0x445098[_0xf259('0xf0')]['remoteAddress']||_0x445098[_0xf259('0xf1')][_0xf259('0xf2')]||_0x445098[_0xf259('0xf0')][_0xf259('0xf1')][_0xf259('0xf2')]});return db['UserVoiceQueueRt'][_0xf259('0x27')]({'where':{'membername':_0xac611a['name']},'individualHooks':!![]});}}else{throw new db['Sequelize'][(_0xf259('0x91'))](_0xf259('0xf3'));}})[_0xf259('0x28')](function(){if(_0xac611a){return _0xac611a[_0xf259('0xf4')]({'raw':!![]});}})['then'](function(_0x400479){if(_0xac611a){var _0x3b9efb=[];if(_0x400479){_0x431d33=_0x400479;if(_0x431d33[_0xf259('0x4a')]){for(var _0x315957=0x0;_0x315957<_0x431d33[_0xf259('0x4a')];_0x315957++){_0x3b9efb[_0xf259('0x46')]({'membername':_0xac611a[_0xf259('0x34')],'UserId':_0xac611a['id'],'queue_name':_0x431d33[_0x315957]['name'],'VoiceQueueId':_0x431d33[_0x315957]['id'],'interface':_0x2089b5,'paused':_0xac611a[_0xf259('0xf5')]||![],'penalty':_0x431d33[_0x315957]['UserVoiceQueue.penalty']||0x0});}return BPromise[_0xf259('0x8a')](_0x3b9efb,function(_0x2c145d){return db[_0xf259('0xae')][_0xf259('0xaf')](_0x2c145d);});}}}})[_0xf259('0x28')](function(){if(_0xac611a){return db[_0xf259('0xf6')][_0xf259('0xab')]({'where':{'membername':_0xac611a[_0xf259('0x34')],'exitAt':null}});}})['then'](function(_0x4f91a3){if(_0xac611a){var _0xbd5a86=[];_0x4f91a3[_0xf259('0xf7')](function(_0x2ba1ba){_0xbd5a86[_0xf259('0x46')](_0x2ba1ba['update']({'exitAt':moment()[_0xf259('0xac')](_0xf259('0xf8'))}));});return BPromise['all'](_0xbd5a86);}})[_0xf259('0x28')](function(){if(_0xac611a){var _0x3374b1=[];var _0x1dd79c=[];var _0x5963f3=utils[_0xf259('0xf9')]();var _0x5b67c0={'membername':_0xac611a[_0xf259('0x34')],'interface':_0x2089b5,'enterAt':moment()[_0xf259('0xac')](_0xf259('0xf8')),'role':_0xac611a[_0xf259('0x29')],'internal':_0xac611a[_0xf259('0x61')]};_0x5963f3[_0xf259('0xf7')](function(_0x626c7a){_0x3374b1[_0xf259('0x46')](_[_0xf259('0x57')]({'channel':_0x626c7a,'type':_0xf259('0xfa'),'data1':_0x445098[_0xf259('0x5b')][_0xf259('0xfb')],'data2':_0x2089b5},_0x5b67c0));if(_0xac611a[_0xf259('0xf5')]){_0x1dd79c[_0xf259('0x46')](_['merge']({'channel':_0x626c7a,'type':'PAUSE','data1':_0xf259('0xfc')},_0x5b67c0));}});return db[_0xf259('0xf6')][_0xf259('0x87')](_0x3374b1[_0xf259('0xc8')](_0x1dd79c),{'individualHooks':!![]});}})[_0xf259('0x28')](function(){if(_0xac611a){return _0xac611a[_0xf259('0x26')]({'online':!![],'lastLoginAt':moment()[_0xf259('0xac')](_0xf259('0xf8')),'voicePause':_0xac611a['loginInPause']||![],'mailPause':_0xac611a[_0xf259('0xf5')]||![],'chatPause':_0xac611a[_0xf259('0xf5')]||![],'faxPause':_0xac611a[_0xf259('0xf5')]||![],'smsPause':_0xac611a[_0xf259('0xf5')]||![],'openchannelPause':_0xac611a[_0xf259('0xf5')]||![],'whatsappPause':_0xac611a[_0xf259('0xf5')]||![],'pauseType':_0xac611a[_0xf259('0xf5')]?_0xf259('0xfc'):null,'interface':_0x2089b5,'lastPauseAt':moment()['format']('YYYY-MM-DD\x20HH:mm:ss')});}})[_0xf259('0x28')](function(_0x2eb82d){if(_0x445098['isMiddleware']){return _0x15eeab();}else{return BPromise[_0xf259('0xfd')](_0x2eb82d)['then'](respondWithResult(_0x57ba32,null));}})['catch'](handleError(_0x57ba32,null));};exports[_0xf259('0xfe')]=function(_0x580b55,_0x396b1d){var _0x1fc441;return db[_0xf259('0x3a')][_0xf259('0x33')]({'where':{'id':_0x580b55['params']['id'],'role':_0xf259('0x7e')},'attributes':['id',_0xf259('0x34'),'role']})[_0xf259('0x28')](handleEntityNotFound(_0x396b1d,null))['then'](function(_0x61afc9){if(_0x61afc9){_0x1fc441=_0x61afc9;return db[_0xf259('0xae')]['destroy']({'where':{'membername':_0x1fc441[_0xf259('0x34')]},'individualHooks':!![]});}})['then'](function(){return db['MemberReport'][_0xf259('0xab')]({'where':{'membername':_0x1fc441[_0xf259('0x34')],'exitAt':null}});})[_0xf259('0x28')](function(_0x5b4463){var _0x3db4bd=[];_0x5b4463[_0xf259('0xf7')](function(_0x131b29){_0x3db4bd['push'](_0x131b29[_0xf259('0x26')]({'exitAt':moment()['format'](_0xf259('0xf8'))}));});return BPromise[_0xf259('0x5a')](_0x3db4bd);})[_0xf259('0x28')](function(){return _0x1fc441[_0xf259('0x26')]({'online':![],'voicePause':![],'mailPause':![],'chatPause':![],'faxPause':![],'smsPause':![],'openchannelPause':![],'whatsappPause':![],'interface':null});})[_0xf259('0x28')](respondWithResult(_0x396b1d,null))[_0xf259('0x1d')](handleError(_0x396b1d,null));};exports[_0xf259('0xff')]=function(_0x1aade5,_0x280fe5){var _0x268b1c;return db[_0xf259('0xae')][_0xf259('0x26')]({'paused':0x1},{'where':{'UserId':_0x1aade5[_0xf259('0x5e')]['id']},'individualHooks':!![]})['then'](function(){return db[_0xf259('0x3a')][_0xf259('0x33')]({'where':{'id':_0x1aade5[_0xf259('0x5e')]['id'],'role':_0xf259('0x7e')},'attributes':['id',_0xf259('0x34'),_0xf259('0x29'),'internal',_0xf259('0xa0')]});})['then'](handleEntityNotFound(_0x280fe5,null))[_0xf259('0x28')](function(_0x42d5e8){if(_0x42d5e8){_0x268b1c=_0x42d5e8;return respondWithRpcPromise('QueuePause',_0xf259('0xff'),{'id':_0x268b1c['id'],'name':_0x268b1c['name'],'pause':!![]});}})[_0xf259('0x28')](function(){if(_0x268b1c){return db[_0xf259('0xf6')][_0xf259('0xab')]({'where':{'membername':_0x268b1c[_0xf259('0x34')],'type':_0xf259('0x100'),'exitAt':null}});}})[_0xf259('0x28')](function(_0x4ced7b){if(_0x4ced7b[_0xf259('0x4a')]){var _0x548694=moment()['format'](_0xf259('0xf8'));for(var _0x491997=0x0,_0x4d7cb3=_0x4ced7b[_0xf259('0x4a')];_0x491997<_0x4d7cb3;_0x491997++){_0x4ced7b[_0x491997][_0xf259('0x101')]({'exitAt':_0x548694});}}})[_0xf259('0x28')](function(){var _0x570286=[];var _0x50231f=utils[_0xf259('0xf9')]();_0x50231f[_0xf259('0xf7')](function(_0x13df59){_0x570286[_0xf259('0x46')]({'channel':_0x13df59,'membername':_0x268b1c[_0xf259('0x34')],'interface':_[_0xf259('0x66')](_0x268b1c[_0xf259('0xa0')])?util[_0xf259('0xac')]('SIP/%s',_0x268b1c[_0xf259('0x34')]):_0x268b1c[_0xf259('0xa0')],'type':_0xf259('0x100'),'enterAt':moment()[_0xf259('0xac')]('YYYY-MM-DD\x20HH:mm:ss'),'data1':_0x1aade5[_0xf259('0x5b')]['type']||_0xf259('0x102'),'role':_0x268b1c[_0xf259('0x29')],'internal':_0x268b1c[_0xf259('0x61')]});});return db[_0xf259('0xf6')][_0xf259('0x87')](_0x570286,{'individualHooks':!![]});})[_0xf259('0x28')](function(){return _0x268b1c[_0xf259('0x26')]({'voicePause':!![],'mailPause':!![],'chatPause':!![],'faxPause':!![],'smsPause':!![],'whatsappPause':!![],'openchannelPause':!![],'pauseType':_0x1aade5[_0xf259('0x5b')][_0xf259('0x3d')]||_0xf259('0x102'),'lastPauseAt':moment()[_0xf259('0xac')]('YYYY-MM-DD\x20HH:mm:ss')});})[_0xf259('0x28')](respondWithResult(_0x280fe5,null))['catch'](handleError(_0x280fe5,null));};exports[_0xf259('0x103')]=function(_0x528bb5,_0x1d97e4){var _0x47359b;return db[_0xf259('0x3a')]['find']({'where':{'id':_0x528bb5['params']['id']},'attributes':['id',_0xf259('0x34'),'role',_0xf259('0x9f'),_0xf259('0x104'),_0xf259('0x105'),_0xf259('0x106'),_0xf259('0x107'),'smsPause','whatsapppause',_0xf259('0x108'),_0xf259('0x109')]})[_0xf259('0x28')](handleEntityNotFound(_0x1d97e4,null))[_0xf259('0x28')](function(_0x516393){if(_0x516393){_0x47359b=_0x516393;if(_0x528bb5['body'][_0xf259('0x9d')]&&!utils[_0xf259('0xa1')](_0x528bb5[_0xf259('0x5b')][_0xf259('0x9d')])){throw new db['Sequelize'][(_0xf259('0x91'))](_0xf259('0xb0'));}switch(_0x528bb5[_0xf259('0x5b')][_0xf259('0x9d')]){case _0xf259('0xaa'):return respondWithRpcPromise('QueuePause',_0xf259('0x103'),{'id':_0x47359b['id'],'name':_0x47359b[_0xf259('0x34')],'pause':![]})['then'](function(){return db[_0xf259('0xae')][_0xf259('0x26')]({'paused':0x0},{'where':{'UserId':_0x47359b['id']},'individualHooks':!![]});})[_0xf259('0x28')](function(){return db[_0xf259('0xf6')][_0xf259('0x33')]({'where':{'channel':_0x528bb5[_0xf259('0x5b')][_0xf259('0x9d')],'membername':_0x47359b['name'],'type':_0xf259('0x100'),'exitAt':null}});})['then'](function(_0x1ba6fb){if(_0x1ba6fb){return _0x1ba6fb['update']({'exitAt':moment()[_0xf259('0xac')](_0xf259('0xf8')),'data2':_0xf259('0x10a')},{'individualHooks':!![]});}return null;})[_0xf259('0x28')](function(){return _0x47359b['update']({'voicePause':![]});});case _0xf259('0x59'):case _0xf259('0x4b'):case _0xf259('0x4e'):case _0xf259('0x4d'):case _0xf259('0x4f'):case _0xf259('0x58'):return db[_0xf259('0xf6')][_0xf259('0x33')]({'where':{'channel':_0x528bb5[_0xf259('0x5b')][_0xf259('0x9d')],'membername':_0x47359b[_0xf259('0x34')],'type':_0xf259('0x100'),'exitAt':null}})[_0xf259('0x28')](function(_0x5ddf53){if(_0x5ddf53){return _0x5ddf53[_0xf259('0x26')]({'exitAt':moment()['format'](_0xf259('0xf8')),'data2':_0xf259('0x10a')},{'individualHooks':!![]});}return null;})[_0xf259('0x28')](function(){var _0x16527a={};_['set'](_0x16527a,util[_0xf259('0xac')](_0xf259('0x10b'),_0x528bb5['body']['channel'],_0xf259('0x10c')),![]);return _0x47359b['update'](_0x16527a);});default:return respondWithRpcPromise(_0xf259('0x10d'),'unpause',{'id':_0x47359b['id'],'name':_0x47359b[_0xf259('0x34')],'pause':![]})[_0xf259('0x28')](function(){return db[_0xf259('0xae')][_0xf259('0x26')]({'paused':0x0},{'where':{'UserId':_0x47359b['id']}});})[_0xf259('0x28')](function(){return db[_0xf259('0xf6')]['findAll']({'where':{'membername':_0x47359b[_0xf259('0x34')],'type':_0xf259('0x100'),'exitAt':null}});})[_0xf259('0x28')](function(_0x35e015){var _0x2f654d=[];_0x35e015[_0xf259('0xf7')](function(_0x2e5554){_0x2f654d[_0xf259('0x46')](_0x2e5554[_0xf259('0x26')]({'exitAt':moment()[_0xf259('0xac')](_0xf259('0xf8')),'data2':_0xf259('0x10a')}));});return BPromise[_0xf259('0x5a')](_0x2f654d);})[_0xf259('0x28')](function(){return _0x47359b[_0xf259('0x26')]({'voicePause':![],'mailPause':![],'chatPause':![],'faxPause':![],'smsPause':![],'whatsappPause':![],'openchannelPause':![]});});}}})['then'](respondWithResult(_0x1d97e4,null))['catch'](handleError(_0x1d97e4,null));};exports['getTeams']=function(_0x4898a7,_0x1563aa){var _0x4b05a2={};var _0x82bdf5={};var _0x30b53f;var _0x2598ba;return db[_0xf259('0x3a')][_0xf259('0x98')]({'where':{'id':_0x4898a7[_0xf259('0x5e')]['id']}})['then'](handleEntityNotFound(_0x1563aa,null))[_0xf259('0x28')](function(_0x22ea6e){if(_0x22ea6e){_0x30b53f=_0x22ea6e;_0x82bdf5[_0xf259('0x54')]=_[_0xf259('0x51')](db[_0xf259('0x10e')][_0xf259('0x3b')]);_0x82bdf5[_0xf259('0x48')]=_['keys'](_0x4898a7[_0xf259('0x48')]);_0x82bdf5[_0xf259('0xca')]=_['intersection'](_0x82bdf5[_0xf259('0x54')],_0x82bdf5[_0xf259('0x48')]);_0x4b05a2['attributes']=_[_0xf259('0x53')](_0x82bdf5[_0xf259('0x54')],qs['fields'](_0x4898a7[_0xf259('0x48')][_0xf259('0x55')]));_0x4b05a2[_0xf259('0x45')]=_0x4b05a2[_0xf259('0x45')][_0xf259('0x4a')]?_0x4b05a2[_0xf259('0x45')]:_0x82bdf5['model'];_0x4b05a2[_0xf259('0xd9')]=qs['sort'](_0x4898a7[_0xf259('0x48')]['sort']);_0x4b05a2['where']=qs[_0xf259('0xca')](_[_0xf259('0xcc')](_0x4898a7['query'],_0x82bdf5[_0xf259('0xca')]));if(_0x4898a7[_0xf259('0x48')]['filter']){_0x4b05a2['where']=_['merge'](_0x4b05a2[_0xf259('0x41')],{'$or':_['map'](_0x4b05a2[_0xf259('0x45')],function(_0x57d934){var _0x183cb5={};_0x183cb5[_0x57d934]={'$like':'%'+_0x4898a7[_0xf259('0x48')]['filter']+'%'};return _0x183cb5;})});}_0x4b05a2=_[_0xf259('0x57')]({},_0x4b05a2,_0x4898a7[_0xf259('0xde')]);return _0x30b53f[_0xf259('0x10f')](_0x4b05a2);}})[_0xf259('0x28')](function(_0x434ae1){if(_0x434ae1){_0x2598ba=_0x434ae1[_0xf259('0x4a')];if(!_0x4898a7[_0xf259('0x48')][_0xf259('0xcd')](_0xf259('0xd3'))){_0x4b05a2[_0xf259('0x23')]=qs[_0xf259('0x23')](_0x4898a7['query'][_0xf259('0x23')]);_0x4b05a2[_0xf259('0x20')]=qs[_0xf259('0x20')](_0x4898a7[_0xf259('0x48')][_0xf259('0x20')]);}return _0x30b53f['getTeams'](_0x4b05a2);}})[_0xf259('0x28')](function(_0x13b570){if(_0x13b570){return _0x13b570?{'count':_0x2598ba,'rows':_0x13b570}:null;}})[_0xf259('0x28')](respondWithResult(_0x1563aa,null))['catch'](handleError(_0x1563aa,null));};exports['addTeams']=function(_0x5677be,_0x58bdca){return db['User'][_0xf259('0x33')]({'where':{'id':_0x5677be[_0xf259('0x5e')]['id']}})[_0xf259('0x28')](handleEntityNotFound(_0x58bdca,null))[_0xf259('0x28')](function(_0x13b13c){if(_0x13b13c){var _0x362ff5=_0x13b13c[_0xf259('0xd6')]({'plain':!![]});return _0x13b13c['addTeams'](_0x5677be[_0xf259('0x5b')]['ids'],_[_0xf259('0x60')](_0x5677be[_0xf259('0x5b')],[_0xf259('0x5f'),'id'])||{})[_0xf259('0x28')](function(){for(var _0xa3ea07=0x0;_0xa3ea07<_0x5677be[_0xf259('0x5b')][_0xf259('0x5f')][_0xf259('0x4a')];_0xa3ea07++){var _0x13ad5d=[];var _0x293d2a={};db[_0xf259('0x10e')][_0xf259('0x98')]({'where':{'id':_0x5677be[_0xf259('0x5b')][_0xf259('0x5f')][_0xa3ea07]}})[_0xf259('0x28')](function(_0x276ec8){_0x293d2a=_0x276ec8['dataValues'];_0x13ad5d[_0xf259('0x46')](_0x276ec8[_0xf259('0xf4')]()['then'](function(_0x523031){for(var _0x4b39ba=0x0;_0x4b39ba<_0x523031[_0xf259('0x4a')];_0x4b39ba++){_0x523031[_0x4b39ba]['setDataValue'](_0xf259('0x9d'),_0xf259('0x110'));}return _0x523031;}));_0x13ad5d[_0xf259('0x46')](_0x276ec8[_0xf259('0x111')]()[_0xf259('0x28')](function(_0x328bf4){for(var _0x33a86f=0x0;_0x33a86f<_0x328bf4[_0xf259('0x4a')];_0x33a86f++){_0x328bf4[_0x33a86f][_0xf259('0x112')](_0xf259('0x9d'),'Chat');}return _0x328bf4;}));_0x13ad5d[_0xf259('0x46')](_0x276ec8['getMailQueues']()['then'](function(_0x1b4a5a){for(var _0x35aa33=0x0;_0x35aa33<_0x1b4a5a[_0xf259('0x4a')];_0x35aa33++){_0x1b4a5a[_0x35aa33][_0xf259('0x112')](_0xf259('0x9d'),_0xf259('0x113'));}return _0x1b4a5a;}));_0x13ad5d[_0xf259('0x46')](_0x276ec8[_0xf259('0x114')]()[_0xf259('0x28')](function(_0x2c9764){for(var _0x79ac20=0x0;_0x79ac20<_0x2c9764[_0xf259('0x4a')];_0x79ac20++){_0x2c9764[_0x79ac20][_0xf259('0x112')](_0xf259('0x9d'),_0xf259('0x115'));}return _0x2c9764;}));_0x13ad5d[_0xf259('0x46')](_0x276ec8['getWhatsappQueues']()[_0xf259('0x28')](function(_0x423733){for(var _0x2c8b39=0x0;_0x2c8b39<_0x423733[_0xf259('0x4a')];_0x2c8b39++){_0x423733[_0x2c8b39][_0xf259('0x112')](_0xf259('0x9d'),'Whatsapp');}return _0x423733;}));_0x13ad5d[_0xf259('0x46')](_0x276ec8['getFaxQueues']()['then'](function(_0x3c9f69){for(var _0x2a6517=0x0;_0x2a6517<_0x3c9f69[_0xf259('0x4a')];_0x2a6517++){_0x3c9f69[_0x2a6517][_0xf259('0x112')]('channel',_0xf259('0x116'));}return _0x3c9f69;}));_0x13ad5d[_0xf259('0x46')](_0x276ec8['getOpenchannelQueues']()[_0xf259('0x28')](function(_0x5c99b8){for(var _0x334ea3=0x0;_0x334ea3<_0x5c99b8[_0xf259('0x4a')];_0x334ea3++){_0x5c99b8[_0x334ea3][_0xf259('0x112')](_0xf259('0x9d'),'Openchannel');}return _0x5c99b8;}));return BPromise[_0xf259('0x5a')](_0x13ad5d);})[_0xf259('0x28')](function(_0x529846){var _0x248c19=_['flatten'](_0x529846);_0x13ad5d=[];return db[_0xf259('0x68')][_0xf259('0x117')](function(_0x2b7df7){for(var _0x2d6099=0x0;_0x2d6099<_0x248c19['length'];_0x2d6099++){_0x13ad5d['push'](_0x248c19[_0x2d6099][_0xf259('0x118')](_0x362ff5['id']),{'transaction':_0x2b7df7});}return BPromise['all'](_0x13ad5d)[_0xf259('0x28')](function(){if(_0x362ff5[_0xf259('0x9e')]){return BPromise[_0xf259('0x8a')](_[_0xf259('0x2e')](_0x248c19,function(_0x2a942e){return _0x2a942e[_0xf259('0x119')](_0xf259('0x9d'))==='Voice';}),function(_0x1177dc){return db[_0xf259('0xae')][_0xf259('0xaf')]({'membername':_0x362ff5[_0xf259('0x34')],'UserId':_0x362ff5['id'],'queue_name':_0x1177dc[_0xf259('0x34')],'VoiceQueueId':_0x1177dc['id'],'interface':_[_0xf259('0x66')](_0x362ff5['interface'])?util[_0xf259('0xac')](_0xf259('0xad'),_0x362ff5['name']):_0x362ff5[_0xf259('0xa0')],'paused':_0x362ff5['voicePause']||![],'penalty':_0x362ff5[_0xf259('0xa5')]},{'transaction':_0x2b7df7});});}else{return;}})[_0xf259('0x28')](function(){for(var _0xfa0e8b=0x0;_0xfa0e8b<_0x248c19[_0xf259('0x4a')];_0xfa0e8b++){var _0x33d600=_0x248c19[_0xfa0e8b]['getDataValue'](_0xf259('0x9d'));var _0x1fbb3d=_0x33d600+_0xf259('0xb2');socket[_0xf259('0xa8')](_0xf259('0x7d')+_0x33d600+'Queue:save',{'UserId':_0x362ff5['id'],['queueField']:_0x248c19[_0xfa0e8b]['id']});}});});})[_0xf259('0x28')](function(){db[_0xf259('0x11a')][_0xf259('0x98')]({'where':{'teamId':_0x293d2a['id']}})[_0xf259('0x28')](function(_0x4bd893){if(_0x4bd893){db[_0xf259('0x11b')][_0xf259('0x7c')]({'UserId':_0x5677be[_0xf259('0x5e')]['id'],'VoicePrefixId':_0x4bd893[_0xf259('0x11c')]});}});});}});}})['then'](respondWithStatusCode(_0x58bdca,null))[_0xf259('0x1d')](handleError(_0x58bdca,null));};exports[_0xf259('0x11d')]=function(_0x33b70c,_0x35db9b){return db[_0xf259('0x3a')][_0xf259('0x98')]({'where':{'id':_0x33b70c['params']['id']}})[_0xf259('0x28')](handleEntityNotFound(_0x35db9b,null))['then'](function(_0xc68460){if(_0xc68460){var _0x394951=_0xc68460['get']({'plain':!![]});var _0x24e5c6=_0x33b70c[_0xf259('0x48')][_0xf259('0x5f')];return _0xc68460['removeTeams'](_0x24e5c6)['then'](function(){for(var _0x44d34c=0x0;_0x44d34c<_0x24e5c6[_0xf259('0x4a')];_0x44d34c++){var _0x28b125=[];var _0x59cfcc={};db[_0xf259('0x10e')][_0xf259('0x98')]({'where':{'id':_0x24e5c6[_0x44d34c]}})[_0xf259('0x28')](function(_0x49769b){_0x59cfcc=_0x49769b[_0xf259('0x4c')];_0x28b125[_0xf259('0x46')](_0x49769b['getVoiceQueues']()[_0xf259('0x28')](function(_0xc0cc5a){for(var _0x55c08a=0x0;_0x55c08a<_0xc0cc5a[_0xf259('0x4a')];_0x55c08a++){_0xc0cc5a[_0x55c08a][_0xf259('0x112')](_0xf259('0x9d'),_0xf259('0x110'));}return _0xc0cc5a;}));_0x28b125[_0xf259('0x46')](_0x49769b[_0xf259('0x111')]()[_0xf259('0x28')](function(_0x2e7cf2){for(var _0x85e23f=0x0;_0x85e23f<_0x2e7cf2[_0xf259('0x4a')];_0x85e23f++){_0x2e7cf2[_0x85e23f][_0xf259('0x112')]('channel',_0xf259('0x11e'));}return _0x2e7cf2;}));_0x28b125[_0xf259('0x46')](_0x49769b[_0xf259('0x11f')]()['then'](function(_0x411466){for(var _0x3013fe=0x0;_0x3013fe<_0x411466[_0xf259('0x4a')];_0x3013fe++){_0x411466[_0x3013fe]['setDataValue'](_0xf259('0x9d'),'Mail');}return _0x411466;}));_0x28b125[_0xf259('0x46')](_0x49769b['getSmsQueues']()[_0xf259('0x28')](function(_0x44c950){for(var _0x2f0db9=0x0;_0x2f0db9<_0x44c950[_0xf259('0x4a')];_0x2f0db9++){_0x44c950[_0x2f0db9][_0xf259('0x112')]('channel',_0xf259('0x115'));}return _0x44c950;}));_0x28b125['push'](_0x49769b[_0xf259('0x120')]()[_0xf259('0x28')](function(_0x1abab3){for(var _0x9afc86=0x0;_0x9afc86<_0x1abab3['length'];_0x9afc86++){_0x1abab3[_0x9afc86][_0xf259('0x112')](_0xf259('0x9d'),_0xf259('0x121'));}return _0x1abab3;}));_0x28b125[_0xf259('0x46')](_0x49769b[_0xf259('0x122')]()[_0xf259('0x28')](function(_0x141c85){for(var _0x389759=0x0;_0x389759<_0x141c85[_0xf259('0x4a')];_0x389759++){_0x141c85[_0x389759][_0xf259('0x112')](_0xf259('0x9d'),_0xf259('0x116'));}return _0x141c85;}));_0x28b125[_0xf259('0x46')](_0x49769b['getOpenchannelQueues']()[_0xf259('0x28')](function(_0x246853){for(var _0x381ad5=0x0;_0x381ad5<_0x246853[_0xf259('0x4a')];_0x381ad5++){_0x246853[_0x381ad5]['setDataValue'](_0xf259('0x9d'),'Openchannel');}return _0x246853;}));return BPromise[_0xf259('0x5a')](_0x28b125);})[_0xf259('0x28')](function(_0x4eec12){var _0xe7d0e=_['flatten'](_0x4eec12);_0x28b125=[];return db[_0xf259('0x68')]['transaction'](function(_0x860f4b){for(var _0x3deb2e=0x0;_0x3deb2e<_0xe7d0e[_0xf259('0x4a')];_0x3deb2e++){_0x28b125['push'](_0xe7d0e[_0x3deb2e][_0xf259('0x123')](_0x394951['id']),{'transaction':_0x860f4b});}return BPromise[_0xf259('0x5a')](_0x28b125)[_0xf259('0x28')](function(){if(_0x394951[_0xf259('0x9e')]){return BPromise[_0xf259('0x8a')](_[_0xf259('0x2e')](_0xe7d0e,function(_0x6d302d){return _0x6d302d[_0xf259('0x119')](_0xf259('0x9d'))==='Voice';}),function(_0x282888){return db[_0xf259('0xae')][_0xf259('0x27')]({'where':{'VoiceQueueId':_0x282888['id'],'UserId':_0x394951['id']},'transaction':_0x860f4b});});}else{return;}})[_0xf259('0x28')](function(){db[_0xf259('0x11a')]['findOne']({'where':{'teamId':_0x59cfcc['id']}})[_0xf259('0x28')](function(_0x5f5919){if(_0x5f5919){return db['UserVoicePrefix'][_0xf259('0x27')]({'where':{'UserId':_0x394951['id'],'VoicePrefixId':_0x5f5919[_0xf259('0x4c')]['VoicePrefixId']}});}});})[_0xf259('0x28')](function(){for(var _0x7deb4d=0x0;_0x7deb4d<_0xe7d0e[_0xf259('0x4a')];_0x7deb4d++){var _0x2de505=_0xe7d0e[_0x7deb4d][_0xf259('0x119')](_0xf259('0x9d'));var _0x4e3142=_0x2de505+'QueueId';socket[_0xf259('0xa8')](_0xf259('0x7d')+_0x2de505+_0xf259('0xb3'),{'UserId':_0x394951['id'],['queueField']:_0xe7d0e[_0x7deb4d]['id']});}});});});}});}})[_0xf259('0x28')](respondWithStatusCode(_0x35db9b,null))[_0xf259('0x1d')](handleError(_0x35db9b,null));};exports['getLists']=function(_0x346d0f,_0x448134){var _0x5f2e08={};var _0x3eba04={};var _0x139937;var _0x40e6fe;return db[_0xf259('0x3a')][_0xf259('0x98')]({'where':{'id':_0x346d0f[_0xf259('0x5e')]['id']}})['then'](handleEntityNotFound(_0x448134,null))[_0xf259('0x28')](function(_0x4e7f66){if(_0x4e7f66){_0x139937=_0x4e7f66;_0x3eba04['model']=_[_0xf259('0x51')](db['CmList'][_0xf259('0x3b')]);_0x3eba04[_0xf259('0x48')]=_[_0xf259('0x51')](_0x346d0f['query']);_0x3eba04[_0xf259('0xca')]=_[_0xf259('0x53')](_0x3eba04[_0xf259('0x54')],_0x3eba04[_0xf259('0x48')]);_0x5f2e08['attributes']=_['intersection'](_0x3eba04[_0xf259('0x54')],qs['fields'](_0x346d0f[_0xf259('0x48')][_0xf259('0x55')]));_0x5f2e08['attributes']=_0x5f2e08[_0xf259('0x45')]['length']?_0x5f2e08['attributes']:_0x3eba04[_0xf259('0x54')];_0x5f2e08[_0xf259('0xd9')]=qs['sort'](_0x346d0f['query'][_0xf259('0xcb')]);_0x5f2e08[_0xf259('0x41')]=qs[_0xf259('0xca')](_[_0xf259('0xcc')](_0x346d0f[_0xf259('0x48')],_0x3eba04['filters']));if(_0x346d0f[_0xf259('0x48')][_0xf259('0x2e')]){_0x5f2e08[_0xf259('0x41')]=_[_0xf259('0x57')](_0x5f2e08[_0xf259('0x41')],{'$or':_['map'](_0x5f2e08['attributes'],function(_0x29704e){var _0x1f4aee={};_0x1f4aee[_0x29704e]={'$like':'%'+_0x346d0f[_0xf259('0x48')][_0xf259('0x2e')]+'%'};return _0x1f4aee;})});}_0x5f2e08=_[_0xf259('0x57')]({},_0x5f2e08,_0x346d0f[_0xf259('0xde')]);return _0x139937[_0xf259('0x124')](_0x5f2e08);}})[_0xf259('0x28')](function(_0x57f99e){if(_0x57f99e){_0x40e6fe=_0x57f99e['length'];if(!_0x346d0f[_0xf259('0x48')][_0xf259('0xcd')]('nolimit')){_0x5f2e08[_0xf259('0x23')]=qs[_0xf259('0x23')](_0x346d0f['query'][_0xf259('0x23')]);_0x5f2e08['offset']=qs[_0xf259('0x20')](_0x346d0f[_0xf259('0x48')][_0xf259('0x20')]);}return _0x139937[_0xf259('0x124')](_0x5f2e08);}})[_0xf259('0x28')](function(_0x4779b4){if(_0x4779b4){return _0x4779b4?{'count':_0x40e6fe,'rows':_0x4779b4}:null;}})[_0xf259('0x28')](respondWithResult(_0x448134,null))[_0xf259('0x1d')](handleError(_0x448134,null));};exports[_0xf259('0x125')]=function(_0x314d0d,_0x1d335f){var _0x376bc8={};var _0x52e7ae={};var _0x21ba80;return db[_0xf259('0x3a')][_0xf259('0x98')]({'where':{'id':_0x314d0d['params']['id']}})[_0xf259('0x28')](handleEntityNotFound(_0x1d335f,null))[_0xf259('0x28')](function(_0x3b0ab3){if(_0x3b0ab3){_0x21ba80=_0x3b0ab3;_0x52e7ae[_0xf259('0x54')]=_[_0xf259('0x51')](db[_0xf259('0x3a')][_0xf259('0x3b')]);_0x52e7ae[_0xf259('0x48')]=_[_0xf259('0x51')](_0x314d0d[_0xf259('0x48')]);_0x52e7ae[_0xf259('0xca')]=_[_0xf259('0x53')](_0x52e7ae[_0xf259('0x54')],_0x52e7ae['query']);_0x376bc8[_0xf259('0x45')]=_[_0xf259('0x53')](_0x52e7ae[_0xf259('0x54')],qs[_0xf259('0x55')](_0x314d0d[_0xf259('0x48')][_0xf259('0x55')]));_0x376bc8['attributes']=_0x376bc8['attributes'][_0xf259('0x4a')]?_0x376bc8[_0xf259('0x45')]:_0x52e7ae[_0xf259('0x54')];_0x376bc8[_0xf259('0xd9')]=qs[_0xf259('0xcb')](_0x314d0d[_0xf259('0x48')]['sort']);_0x376bc8['where']=qs['filters'](_['pick'](_0x314d0d['query'],_0x52e7ae[_0xf259('0xca')]));if(_0x314d0d[_0xf259('0x48')][_0xf259('0x2e')]){_0x376bc8[_0xf259('0x41')]=_[_0xf259('0x57')](_0x376bc8['where'],{'$or':_[_0xf259('0x30')](_0x376bc8[_0xf259('0x45')],function(_0xbd139){var _0x397ec1={};_0x397ec1[_0xbd139]={'$like':'%'+_0x314d0d[_0xf259('0x48')][_0xf259('0x2e')]+'%'};return _0x397ec1;})});}_0x376bc8[_0xf259('0x54')]=db[_0xf259('0x3a')];_0x376bc8['as']='Agents';_0x376bc8=_['merge']({},_0x376bc8,_0x314d0d[_0xf259('0xde')]);return _0x21ba80[_0xf259('0xf4')]({'include':[_0x376bc8]});}})[_0xf259('0x28')](function(_0x3690e8){if(_0x3690e8){var _0x231060={},_0x5745a3=[];for(var _0x3751f6=0x0;_0x3751f6<_0x3690e8[_0xf259('0x4a')];_0x3751f6+=0x1){for(var _0x21f8b7=0x0,_0x2de025;_0x21f8b7<_0x3690e8[_0x3751f6]['Agents'][_0xf259('0x4a')];_0x21f8b7+=0x1){_0x2de025=_0x3690e8[_0x3751f6][_0xf259('0x2b')][_0x21f8b7][_0xf259('0xd6')]({'plain':!![]});_0x231060[_0x2de025['id']]=_0x2de025;}}_0x231060=_[_0xf259('0x126')](_0x231060);for(var _0x5b0c2f=qs[_0xf259('0x20')](_0x314d0d['query'][_0xf259('0x20')]);_0x5b0c2f<_0x231060[_0xf259('0x4a')]&&_0x5745a3[_0xf259('0x4a')]<qs[_0xf259('0x23')](_0x314d0d['query'][_0xf259('0x23')]);_0x5b0c2f+=0x1){if(_0x231060[_0x5b0c2f]){_0x5745a3[_0xf259('0x46')](_0x231060[_0x5b0c2f]);}}return{'count':_0x231060[_0xf259('0x4a')],'rows':_0x5745a3};}})['then'](respondWithResult(_0x1d335f,null))[_0xf259('0x1d')](handleError(_0x1d335f,null));};exports[_0xf259('0x27')]=function(_0x539252,_0x4661c5){if(_0x539252[_0xf259('0x7d')]['id']==_0x539252[_0xf259('0x5e')]['id']){return _0x4661c5[_0xf259('0x1e')](0x1f4)[_0xf259('0x127')]({'message':_0xf259('0x128')});}return db[_0xf259('0x3a')][_0xf259('0x33')]({'where':{'id':_0x539252['params']['id']}})['then'](handleEntityNotFound(_0x4661c5,null))['then'](removeEntity(_0x4661c5,null))[_0xf259('0x1d')](handleError(_0x4661c5,null));};exports[_0xf259('0x129')]=function(_0x435b8a,_0x36d4de){return db[_0xf259('0x3a')][_0xf259('0x33')]({'where':{'id':_0x435b8a['params']['id']}})[_0xf259('0x28')](handleEntityNotFound(_0x36d4de,null))[_0xf259('0x28')](function(_0x581da4){if(_0x581da4){return _0x581da4['addChatInteractions'](_0x435b8a[_0xf259('0x5b')][_0xf259('0x5f')],_[_0xf259('0x60')](_0x435b8a['body'],['ids','id'])||{})[_0xf259('0xa6')](function(){for(var _0xf4874b=0x0;_0xf4874b<_0x435b8a['body'][_0xf259('0x5f')][_0xf259('0x4a')];_0xf4874b+=0x1){socket[_0xf259('0xa8')](_0xf259('0x12a'),{'ChatInteractionId':Number(_0x435b8a[_0xf259('0x5b')][_0xf259('0x5f')][_0xf4874b]),'UserId':Number(_0x435b8a['params']['id'])});}return _0x435b8a['body'][_0xf259('0x5f')];});}})['then'](respondWithResult(_0x36d4de,null))[_0xf259('0x1d')](handleError(_0x36d4de,null));};exports[_0xf259('0x12b')]=function(_0x45d76a,_0x13edd3){return db[_0xf259('0x3a')][_0xf259('0x33')]({'where':{'id':_0x45d76a[_0xf259('0x5e')]['id']}})[_0xf259('0x28')](handleEntityNotFound(_0x13edd3,null))['then'](function(_0x37f37e){if(_0x37f37e){return _0x37f37e[_0xf259('0x12b')](_0x45d76a[_0xf259('0x48')][_0xf259('0x5f')])[_0xf259('0x28')](function(){if(_['isArray'](_0x45d76a[_0xf259('0x48')][_0xf259('0x5f')])){for(var _0x351b04=0x0;_0x351b04<_0x45d76a[_0xf259('0x48')][_0xf259('0x5f')][_0xf259('0x4a')];_0x351b04+=0x1){socket['emit'](_0xf259('0x12c'),{'ChatInteractionId':Number(_0x45d76a['query'][_0xf259('0x5f')][_0x351b04]),'UserId':Number(_0x45d76a[_0xf259('0x5e')]['id'])});}}else{socket[_0xf259('0xa8')](_0xf259('0x12c'),{'ChatInteractionId':Number(_0x45d76a[_0xf259('0x48')]['ids']),'UserId':Number(_0x45d76a[_0xf259('0x5e')]['id'])});}});}})[_0xf259('0x28')](respondWithStatusCode(_0x13edd3,null))[_0xf259('0x1d')](handleError(_0x13edd3,null));};exports[_0xf259('0x12d')]=function(_0xca1ce9,_0x18d894){return db[_0xf259('0x3a')][_0xf259('0x33')]({'where':{'id':_0xca1ce9[_0xf259('0x5e')]['id']}})[_0xf259('0x28')](handleEntityNotFound(_0x18d894,null))[_0xf259('0x28')](function(_0x2d9feb){if(_0x2d9feb){return _0x2d9feb['addMailInteractions'](_0xca1ce9[_0xf259('0x5b')]['ids'],_['omit'](_0xca1ce9[_0xf259('0x5b')],[_0xf259('0x5f'),'id'])||{})['spread'](function(){for(var _0x3f5797=0x0;_0x3f5797<_0xca1ce9[_0xf259('0x5b')][_0xf259('0x5f')]['length'];_0x3f5797+=0x1){socket[_0xf259('0xa8')]('user_has_mail_interactions:save',{'MailInteractionId':Number(_0xca1ce9[_0xf259('0x5b')][_0xf259('0x5f')][_0x3f5797]),'UserId':Number(_0xca1ce9[_0xf259('0x5e')]['id'])});}return _0xca1ce9['body'][_0xf259('0x5f')];});}})[_0xf259('0x28')](respondWithResult(_0x18d894,null))['catch'](handleError(_0x18d894,null));};exports[_0xf259('0x12e')]=function(_0x153432,_0x2961a3){return db[_0xf259('0x3a')]['find']({'where':{'id':_0x153432[_0xf259('0x5e')]['id']}})[_0xf259('0x28')](handleEntityNotFound(_0x2961a3,null))['then'](function(_0xd0e30){if(_0xd0e30){return _0xd0e30[_0xf259('0x12e')](_0x153432[_0xf259('0x48')][_0xf259('0x5f')])[_0xf259('0x28')](function(){if(_[_0xf259('0xb1')](_0x153432[_0xf259('0x48')]['ids'])){for(var _0x31a7a1=0x0;_0x31a7a1<_0x153432[_0xf259('0x48')][_0xf259('0x5f')][_0xf259('0x4a')];_0x31a7a1+=0x1){socket['emit'](_0xf259('0x12f'),{'MailInteractionId':Number(_0x153432[_0xf259('0x48')][_0xf259('0x5f')][_0x31a7a1]),'UserId':Number(_0x153432['params']['id'])});}}else{socket['emit'](_0xf259('0x12f'),{'MailInteractionId':Number(_0x153432[_0xf259('0x48')]['ids']),'UserId':Number(_0x153432[_0xf259('0x5e')]['id'])});}});}})[_0xf259('0x28')](respondWithStatusCode(_0x2961a3,null))[_0xf259('0x1d')](handleError(_0x2961a3,null));};exports['addFaxInteractions']=function(_0x5c2aa1,_0x48a07d){return db[_0xf259('0x3a')][_0xf259('0x33')]({'where':{'id':_0x5c2aa1[_0xf259('0x5e')]['id']}})['then'](handleEntityNotFound(_0x48a07d,null))[_0xf259('0x28')](function(_0x1bbb1d){if(_0x1bbb1d){return _0x1bbb1d['addFaxInteractions'](_0x5c2aa1[_0xf259('0x5b')][_0xf259('0x5f')],_[_0xf259('0x60')](_0x5c2aa1[_0xf259('0x5b')],['ids','id'])||{})[_0xf259('0xa6')](function(){for(var _0xf30861=0x0;_0xf30861<_0x5c2aa1[_0xf259('0x5b')][_0xf259('0x5f')][_0xf259('0x4a')];_0xf30861+=0x1){socket[_0xf259('0xa8')]('user_has_fax_interactions:save',{'FaxInteractionId':Number(_0x5c2aa1[_0xf259('0x5b')][_0xf259('0x5f')][_0xf30861]),'UserId':Number(_0x5c2aa1[_0xf259('0x5e')]['id'])});}return _0x5c2aa1[_0xf259('0x5b')][_0xf259('0x5f')];});}})[_0xf259('0x28')](respondWithResult(_0x48a07d,null))[_0xf259('0x1d')](handleError(_0x48a07d,null));};exports[_0xf259('0x130')]=function(_0x1ac30c,_0x33d0e7){return db['User'][_0xf259('0x33')]({'where':{'id':_0x1ac30c['params']['id']}})[_0xf259('0x28')](handleEntityNotFound(_0x33d0e7,null))[_0xf259('0x28')](function(_0x198e59){if(_0x198e59){return _0x198e59[_0xf259('0x130')](_0x1ac30c[_0xf259('0x48')][_0xf259('0x5f')])[_0xf259('0x28')](function(){if(_[_0xf259('0xb1')](_0x1ac30c[_0xf259('0x48')][_0xf259('0x5f')])){for(var _0x3b6d12=0x0;_0x3b6d12<_0x1ac30c[_0xf259('0x48')][_0xf259('0x5f')]['length'];_0x3b6d12+=0x1){socket[_0xf259('0xa8')](_0xf259('0x131'),{'FaxInteractionId':Number(_0x1ac30c['query'][_0xf259('0x5f')][_0x3b6d12]),'UserId':Number(_0x1ac30c[_0xf259('0x5e')]['id'])});}}else{socket[_0xf259('0xa8')](_0xf259('0x131'),{'FaxInteractionId':Number(_0x1ac30c['query'][_0xf259('0x5f')]),'UserId':Number(_0x1ac30c[_0xf259('0x5e')]['id'])});}});}})['then'](respondWithStatusCode(_0x33d0e7,null))[_0xf259('0x1d')](handleError(_0x33d0e7,null));};exports[_0xf259('0x132')]=function(_0x1743ae,_0x1c956f){return db[_0xf259('0x3a')][_0xf259('0x33')]({'where':{'id':_0x1743ae[_0xf259('0x5e')]['id']}})[_0xf259('0x28')](handleEntityNotFound(_0x1c956f,null))[_0xf259('0x28')](function(_0x51fb66){if(_0x51fb66){return _0x51fb66['addSmsInteractions'](_0x1743ae['body'][_0xf259('0x5f')],_[_0xf259('0x60')](_0x1743ae[_0xf259('0x5b')],['ids','id'])||{})['spread'](function(){for(var _0x49e145=0x0;_0x49e145<_0x1743ae['body'][_0xf259('0x5f')]['length'];_0x49e145+=0x1){socket['emit'](_0xf259('0x133'),{'SmsInteractionId':Number(_0x1743ae['body']['ids'][_0x49e145]),'UserId':Number(_0x1743ae[_0xf259('0x5e')]['id'])});}return _0x1743ae[_0xf259('0x5b')][_0xf259('0x5f')];});}})['then'](respondWithResult(_0x1c956f,null))[_0xf259('0x1d')](handleError(_0x1c956f,null));};exports[_0xf259('0x134')]=function(_0x19ac1a,_0x15a759){return db['User']['find']({'where':{'id':_0x19ac1a[_0xf259('0x5e')]['id']}})[_0xf259('0x28')](handleEntityNotFound(_0x15a759,null))[_0xf259('0x28')](function(_0x4fa4a7){if(_0x4fa4a7){return _0x4fa4a7[_0xf259('0x134')](_0x19ac1a['query'][_0xf259('0x5f')])[_0xf259('0x28')](function(){if(_[_0xf259('0xb1')](_0x19ac1a[_0xf259('0x48')]['ids'])){for(var _0x41138a=0x0;_0x41138a<_0x19ac1a[_0xf259('0x48')]['ids'][_0xf259('0x4a')];_0x41138a+=0x1){socket['emit']('user_has_sms_interactions:remove',{'SmsInteractionId':Number(_0x19ac1a['query'][_0xf259('0x5f')][_0x41138a]),'UserId':Number(_0x19ac1a[_0xf259('0x5e')]['id'])});}}else{socket[_0xf259('0xa8')](_0xf259('0x135'),{'SmsInteractionId':Number(_0x19ac1a['query'][_0xf259('0x5f')]),'UserId':Number(_0x19ac1a[_0xf259('0x5e')]['id'])});}});}})['then'](respondWithStatusCode(_0x15a759,null))[_0xf259('0x1d')](handleError(_0x15a759,null));};exports[_0xf259('0x136')]=function(_0x1431db,_0x5a6b0a){return db[_0xf259('0x3a')][_0xf259('0x33')]({'where':{'id':_0x1431db['params']['id']}})[_0xf259('0x28')](handleEntityNotFound(_0x5a6b0a,null))[_0xf259('0x28')](function(_0x5ec995){if(_0x5ec995){return _0x5ec995[_0xf259('0x136')](_0x1431db[_0xf259('0x5b')][_0xf259('0x5f')],_['omit'](_0x1431db[_0xf259('0x5b')],[_0xf259('0x5f'),'id'])||{})[_0xf259('0xa6')](function(){for(var _0x385dd7=0x0;_0x385dd7<_0x1431db['body'][_0xf259('0x5f')][_0xf259('0x4a')];_0x385dd7+=0x1){socket['emit'](_0xf259('0x137'),{'OpenchannelInteractionId':Number(_0x1431db['body']['ids'][_0x385dd7]),'UserId':Number(_0x1431db['params']['id'])});}return _0x1431db[_0xf259('0x5b')][_0xf259('0x5f')];});}})[_0xf259('0x28')](respondWithResult(_0x5a6b0a,null))[_0xf259('0x1d')](handleError(_0x5a6b0a,null));};exports[_0xf259('0x138')]=function(_0x280fac,_0x36b209){return db[_0xf259('0x3a')]['find']({'where':{'id':_0x280fac[_0xf259('0x5e')]['id']}})['then'](handleEntityNotFound(_0x36b209,null))['then'](function(_0x4f3c78){if(_0x4f3c78){return _0x4f3c78['removeOpenchannelInteractions'](_0x280fac['query']['ids'])[_0xf259('0x28')](function(){if(_['isArray'](_0x280fac[_0xf259('0x48')]['ids'])){for(var _0x1dc5f0=0x0;_0x1dc5f0<_0x280fac['query'][_0xf259('0x5f')]['length'];_0x1dc5f0+=0x1){socket[_0xf259('0xa8')](_0xf259('0x139'),{'OpenchannelInteractionId':Number(_0x280fac[_0xf259('0x48')]['ids'][_0x1dc5f0]),'UserId':Number(_0x280fac['params']['id'])});}}else{socket[_0xf259('0xa8')](_0xf259('0x139'),{'OpenchannelInteractionId':Number(_0x280fac['query'][_0xf259('0x5f')]),'UserId':Number(_0x280fac['params']['id'])});}});}})[_0xf259('0x28')](respondWithStatusCode(_0x36b209,null))[_0xf259('0x1d')](handleError(_0x36b209,null));};exports[_0xf259('0x13a')]=function(_0x2853dd,_0x5aa843){return db[_0xf259('0x3a')][_0xf259('0x33')]({'where':{'id':_0x2853dd[_0xf259('0x5e')]['id']}})[_0xf259('0x28')](handleEntityNotFound(_0x5aa843,null))[_0xf259('0x28')](function(_0xfd952d){if(_0xfd952d){return _0xfd952d['addWhatsappInteractions'](_0x2853dd[_0xf259('0x5b')][_0xf259('0x5f')],_[_0xf259('0x60')](_0x2853dd[_0xf259('0x5b')],[_0xf259('0x5f'),'id'])||{})[_0xf259('0xa6')](function(){for(var _0x214f12=0x0;_0x214f12<_0x2853dd['body']['ids'][_0xf259('0x4a')];_0x214f12+=0x1){socket[_0xf259('0xa8')](_0xf259('0x13b'),{'WhatsappInteractionId':Number(_0x2853dd['body'][_0xf259('0x5f')][_0x214f12]),'UserId':Number(_0x2853dd[_0xf259('0x5e')]['id'])});}return _0x2853dd[_0xf259('0x5b')]['ids'];});}})[_0xf259('0x28')](respondWithResult(_0x5aa843,null))[_0xf259('0x1d')](handleError(_0x5aa843,null));};exports[_0xf259('0x13c')]=function(_0x57d4b9,_0x3e5ba2){return db[_0xf259('0x3a')][_0xf259('0x33')]({'where':{'id':_0x57d4b9['params']['id']}})[_0xf259('0x28')](handleEntityNotFound(_0x3e5ba2,null))[_0xf259('0x28')](function(_0x1f9d81){if(_0x1f9d81){return _0x1f9d81[_0xf259('0x13c')](_0x57d4b9['query'][_0xf259('0x5f')]);}})[_0xf259('0x28')](respondWithStatusCode(_0x3e5ba2,null))[_0xf259('0x1d')](handleError(_0x3e5ba2,null));};exports[_0xf259('0x13d')]=function(_0x268af9,_0x3ea63c){var _0x42b43b={};var _0x5ad114={};var _0xb93082;var _0x5647e3;return db[_0xf259('0x3a')][_0xf259('0x98')]({'where':{'id':_0x268af9[_0xf259('0x5e')]['id']}})['then'](handleEntityNotFound(_0x3ea63c,null))[_0xf259('0x28')](function(_0xeed8a2){if(_0xeed8a2){_0xb93082=_0xeed8a2;_0x5ad114[_0xf259('0x54')]=_['keys'](db[_0xf259('0x13e')][_0xf259('0x3b')]);_0x5ad114['query']=_[_0xf259('0x51')](_0x268af9['query']);_0x5ad114[_0xf259('0xca')]=_[_0xf259('0x53')](_0x5ad114[_0xf259('0x54')],_0x5ad114[_0xf259('0x48')]);_0x42b43b[_0xf259('0x45')]=_[_0xf259('0x53')](_0x5ad114['model'],qs[_0xf259('0x55')](_0x268af9[_0xf259('0x48')][_0xf259('0x55')]));_0x42b43b[_0xf259('0x45')]=_0x42b43b[_0xf259('0x45')][_0xf259('0x4a')]?_0x42b43b[_0xf259('0x45')]:_0x5ad114[_0xf259('0x54')];_0x42b43b['order']=qs[_0xf259('0xcb')](_0x268af9[_0xf259('0x48')][_0xf259('0xcb')]);_0x42b43b['where']=qs[_0xf259('0xca')](_[_0xf259('0xcc')](_0x268af9[_0xf259('0x48')],_0x5ad114[_0xf259('0xca')]));if(_0x268af9[_0xf259('0x48')]['filter']){_0x42b43b[_0xf259('0x41')]=_[_0xf259('0x57')](_0x42b43b[_0xf259('0x41')],{'$or':_[_0xf259('0x30')](_0x42b43b[_0xf259('0x45')],function(_0xd26f12){var _0x4c0e47={};_0x4c0e47[_0xd26f12]={'$like':'%'+_0x268af9['query'][_0xf259('0x2e')]+'%'};return _0x4c0e47;})});}_0x42b43b=_['merge']({},_0x42b43b,_0x268af9[_0xf259('0xde')]);return _0xb93082[_0xf259('0x13d')](_0x42b43b);}})[_0xf259('0x28')](function(_0x442371){if(_0x442371){_0x5647e3=_0x442371['length'];if(!_0x268af9['query']['hasOwnProperty'](_0xf259('0xd3'))){_0x42b43b[_0xf259('0x23')]=qs[_0xf259('0x23')](_0x268af9[_0xf259('0x48')][_0xf259('0x23')]);_0x42b43b[_0xf259('0x20')]=qs[_0xf259('0x20')](_0x268af9[_0xf259('0x48')][_0xf259('0x20')]);}return _0xb93082[_0xf259('0x13d')](_0x42b43b);}})[_0xf259('0x28')](function(_0x5234ea){if(_0x5234ea){return _0x5234ea?{'count':_0x5647e3,'rows':_0x5234ea}:null;}})[_0xf259('0x28')](respondWithResult(_0x3ea63c,null))['catch'](handleError(_0x3ea63c,null));};exports[_0xf259('0x13f')]=function(_0x4bb759,_0xf977d8){var _0x171ea6={};var _0x59d564={};var _0x2f6904;var _0x436af6;return db['User'][_0xf259('0x98')]({'where':{'id':_0x4bb759[_0xf259('0x5e')]['id']}})[_0xf259('0x28')](handleEntityNotFound(_0xf977d8,null))[_0xf259('0x28')](function(_0x472dc0){if(_0x472dc0){_0x2f6904=_0x472dc0;_0x59d564[_0xf259('0x54')]=_[_0xf259('0x51')](db[_0xf259('0x140')][_0xf259('0x3b')]);_0x59d564['query']=_[_0xf259('0x51')](_0x4bb759[_0xf259('0x48')]);_0x59d564[_0xf259('0xca')]=_[_0xf259('0x53')](_0x59d564[_0xf259('0x54')],_0x59d564[_0xf259('0x48')]);_0x171ea6[_0xf259('0x45')]=_[_0xf259('0x53')](_0x59d564['model'],qs[_0xf259('0x55')](_0x4bb759[_0xf259('0x48')][_0xf259('0x55')]));_0x171ea6[_0xf259('0x45')]=_0x171ea6[_0xf259('0x45')]['length']?_0x171ea6['attributes']:_0x59d564[_0xf259('0x54')];_0x171ea6[_0xf259('0xd9')]=qs[_0xf259('0xcb')](_0x4bb759[_0xf259('0x48')][_0xf259('0xcb')]);_0x171ea6[_0xf259('0x41')]=qs[_0xf259('0xca')](_[_0xf259('0xcc')](_0x4bb759[_0xf259('0x48')],_0x59d564[_0xf259('0xca')]));if(_0x4bb759[_0xf259('0x48')][_0xf259('0x2e')]){_0x171ea6[_0xf259('0x41')]=_[_0xf259('0x57')](_0x171ea6[_0xf259('0x41')],{'$or':_[_0xf259('0x30')](_0x171ea6[_0xf259('0x45')],function(_0x220240){var _0x3bc871={};_0x3bc871[_0x220240]={'$like':'%'+_0x4bb759[_0xf259('0x48')]['filter']+'%'};return _0x3bc871;})});}_0x171ea6=_[_0xf259('0x57')]({},_0x171ea6,_0x4bb759[_0xf259('0xde')]);return _0x2f6904[_0xf259('0x13f')](_0x171ea6);}})[_0xf259('0x28')](function(_0x5213d6){if(_0x5213d6){_0x436af6=_0x5213d6[_0xf259('0x4a')];if(!_0x4bb759[_0xf259('0x48')][_0xf259('0xcd')](_0xf259('0xd3'))){_0x171ea6[_0xf259('0x23')]=qs[_0xf259('0x23')](_0x4bb759[_0xf259('0x48')]['limit']);_0x171ea6['offset']=qs[_0xf259('0x20')](_0x4bb759['query'][_0xf259('0x20')]);}return _0x2f6904[_0xf259('0x13f')](_0x171ea6);}})[_0xf259('0x28')](function(_0x140bd7){if(_0x140bd7){return _0x140bd7?{'count':_0x436af6,'rows':_0x140bd7}:null;}})[_0xf259('0x28')](respondWithResult(_0xf977d8,null))[_0xf259('0x1d')](handleError(_0xf977d8,null));};exports[_0xf259('0x141')]=function(_0xff441d,_0x66922){return db[_0xf259('0x3a')][_0xf259('0x33')]({'where':{'id':_0xff441d[_0xf259('0x5e')]['id']}})[_0xf259('0x28')](handleEntityNotFound(_0x66922,null))[_0xf259('0x28')](function(_0x30bf37){if(_0x30bf37){return _0x30bf37[_0xf259('0x141')](_0xff441d['body'][_0xf259('0x5f')],_[_0xf259('0x60')](_0xff441d[_0xf259('0x5b')],[_0xf259('0x5f'),'id'])||{});}})[_0xf259('0x28')](respondWithResult(_0x66922,null))[_0xf259('0x1d')](handleError(_0x66922,null));};exports[_0xf259('0x142')]=function(_0x4bdf15,_0x2573b3){return db[_0xf259('0x3a')][_0xf259('0x33')]({'where':{'id':_0x4bdf15[_0xf259('0x5e')]['id']}})['then'](handleEntityNotFound(_0x2573b3,null))['then'](function(_0x36fd19){if(_0x36fd19){return _0x36fd19[_0xf259('0x142')](_0x4bdf15['query']['ids']);}})[_0xf259('0x28')](respondWithStatusCode(_0x2573b3,null))[_0xf259('0x1d')](handleError(_0x2573b3,null));};exports[_0xf259('0x143')]=function(_0x5154c8,_0x453bd5){var _0x47a825={};var _0xda4665={};var _0x685657;var _0x405abd;return db[_0xf259('0x3a')]['findOne']({'where':{'id':_0x5154c8[_0xf259('0x5e')]['id']}})[_0xf259('0x28')](handleEntityNotFound(_0x453bd5,null))['then'](function(_0x3c225c){if(_0x3c225c){_0x685657=_0x3c225c;_0xda4665[_0xf259('0x54')]=_[_0xf259('0x51')](db[_0xf259('0x144')][_0xf259('0x3b')]);_0xda4665[_0xf259('0x48')]=_['keys'](_0x5154c8[_0xf259('0x48')]);_0xda4665['filters']=_[_0xf259('0x53')](_0xda4665[_0xf259('0x54')],_0xda4665[_0xf259('0x48')]);_0x47a825[_0xf259('0x45')]=_['intersection'](_0xda4665[_0xf259('0x54')],qs[_0xf259('0x55')](_0x5154c8[_0xf259('0x48')][_0xf259('0x55')]));_0x47a825['attributes']=_0x47a825[_0xf259('0x45')]['length']?_0x47a825[_0xf259('0x45')]:_0xda4665[_0xf259('0x54')];_0x47a825[_0xf259('0xd9')]=qs[_0xf259('0xcb')](_0x5154c8[_0xf259('0x48')]['sort']);_0x47a825['where']=qs[_0xf259('0xca')](_[_0xf259('0xcc')](_0x5154c8[_0xf259('0x48')],_0xda4665[_0xf259('0xca')]));if(_0x5154c8['query'][_0xf259('0x2e')]){_0x47a825['where']=_[_0xf259('0x57')](_0x47a825[_0xf259('0x41')],{'$or':_[_0xf259('0x30')](_0x47a825[_0xf259('0x45')],function(_0x13f45c){var _0x13642e={};_0x13642e[_0x13f45c]={'$like':'%'+_0x5154c8[_0xf259('0x48')][_0xf259('0x2e')]+'%'};return _0x13642e;})});}_0x47a825=_[_0xf259('0x57')]({},_0x47a825,_0x5154c8['options']);return _0x685657[_0xf259('0x143')](_0x47a825);}})[_0xf259('0x28')](function(_0x5ba5ef){if(_0x5ba5ef){_0x405abd=_0x5ba5ef['length'];if(!_0x5154c8['query']['hasOwnProperty'](_0xf259('0xd3'))){_0x47a825[_0xf259('0x23')]=qs[_0xf259('0x23')](_0x5154c8[_0xf259('0x48')][_0xf259('0x23')]);_0x47a825[_0xf259('0x20')]=qs[_0xf259('0x20')](_0x5154c8[_0xf259('0x48')][_0xf259('0x20')]);}return _0x685657[_0xf259('0x143')](_0x47a825);}})[_0xf259('0x28')](function(_0x5e4f7f){if(_0x5e4f7f){return _0x5e4f7f?{'count':_0x405abd,'rows':_0x5e4f7f}:null;}})['then'](respondWithResult(_0x453bd5,null))[_0xf259('0x1d')](handleError(_0x453bd5,null));};exports['addMailAccounts']=function(_0x818ff3,_0x2721e9){return db[_0xf259('0x3a')][_0xf259('0x33')]({'where':{'id':_0x818ff3[_0xf259('0x5e')]['id']}})[_0xf259('0x28')](handleEntityNotFound(_0x2721e9,null))['then'](function(_0x5a2e86){if(_0x5a2e86){return _0x5a2e86['addMailAccounts'](_0x818ff3[_0xf259('0x5b')][_0xf259('0x5f')],_['omit'](_0x818ff3[_0xf259('0x5b')],[_0xf259('0x5f'),'id'])||{});}})['then'](respondWithResult(_0x2721e9,null))['catch'](handleError(_0x2721e9,null));};exports[_0xf259('0x145')]=function(_0x4aea1f,_0x13ced9){return db[_0xf259('0x3a')][_0xf259('0x33')]({'where':{'id':_0x4aea1f[_0xf259('0x5e')]['id']}})[_0xf259('0x28')](handleEntityNotFound(_0x13ced9,null))['then'](function(_0x57d602){if(_0x57d602){return _0x57d602['removeMailAccounts'](_0x4aea1f[_0xf259('0x48')][_0xf259('0x5f')]);}})[_0xf259('0x28')](respondWithStatusCode(_0x13ced9,null))['catch'](handleError(_0x13ced9,null));};exports[_0xf259('0x146')]=function(_0x32be9d,_0xfd8f50){var _0x108a29={};var _0x2dd4f9={};var _0x22d765;var _0x3680e4;return db['User'][_0xf259('0x98')]({'where':{'id':_0x32be9d[_0xf259('0x5e')]['id']}})[_0xf259('0x28')](handleEntityNotFound(_0xfd8f50,null))['then'](function(_0x88b80e){if(_0x88b80e){_0x22d765=_0x88b80e;_0x2dd4f9[_0xf259('0x54')]=_[_0xf259('0x51')](db[_0xf259('0x147')][_0xf259('0x3b')]);_0x2dd4f9[_0xf259('0x48')]=_[_0xf259('0x51')](_0x32be9d[_0xf259('0x48')]);_0x2dd4f9[_0xf259('0xca')]=_[_0xf259('0x53')](_0x2dd4f9[_0xf259('0x54')],_0x2dd4f9[_0xf259('0x48')]);_0x108a29[_0xf259('0x45')]=_['intersection'](_0x2dd4f9[_0xf259('0x54')],qs[_0xf259('0x55')](_0x32be9d['query']['fields']));_0x108a29[_0xf259('0x45')]=_0x108a29[_0xf259('0x45')][_0xf259('0x4a')]?_0x108a29[_0xf259('0x45')]:_0x2dd4f9[_0xf259('0x54')];_0x108a29[_0xf259('0xd9')]=qs[_0xf259('0xcb')](_0x32be9d['query'][_0xf259('0xcb')]);_0x108a29[_0xf259('0x41')]=qs[_0xf259('0xca')](_[_0xf259('0xcc')](_0x32be9d[_0xf259('0x48')],_0x2dd4f9[_0xf259('0xca')]));if(_0x32be9d[_0xf259('0x48')][_0xf259('0x2e')]){_0x108a29['where']=_[_0xf259('0x57')](_0x108a29[_0xf259('0x41')],{'$or':_[_0xf259('0x30')](_0x108a29['attributes'],function(_0x1c7907){var _0x3449e4={};_0x3449e4[_0x1c7907]={'$like':'%'+_0x32be9d[_0xf259('0x48')][_0xf259('0x2e')]+'%'};return _0x3449e4;})});}_0x108a29=_['merge']({},_0x108a29,_0x32be9d[_0xf259('0xde')]);return _0x22d765[_0xf259('0x146')](_0x108a29);}})['then'](function(_0x3f6862){if(_0x3f6862){_0x3680e4=_0x3f6862['length'];if(!_0x32be9d[_0xf259('0x48')][_0xf259('0xcd')](_0xf259('0xd3'))){_0x108a29['limit']=qs[_0xf259('0x23')](_0x32be9d[_0xf259('0x48')][_0xf259('0x23')]);_0x108a29[_0xf259('0x20')]=qs[_0xf259('0x20')](_0x32be9d[_0xf259('0x48')][_0xf259('0x20')]);}return _0x22d765[_0xf259('0x146')](_0x108a29);}})[_0xf259('0x28')](function(_0x1add06){if(_0x1add06){return _0x1add06?{'count':_0x3680e4,'rows':_0x1add06}:null;}})[_0xf259('0x28')](respondWithResult(_0xfd8f50,null))['catch'](handleError(_0xfd8f50,null));};exports[_0xf259('0x148')]=function(_0x348487,_0x3a9391){return db[_0xf259('0x3a')][_0xf259('0x33')]({'where':{'id':_0x348487[_0xf259('0x5e')]['id']}})[_0xf259('0x28')](handleEntityNotFound(_0x3a9391,null))['then'](function(_0x3eebae){if(_0x3eebae){return _0x3eebae[_0xf259('0x148')](_0x348487['body'][_0xf259('0x5f')],_[_0xf259('0x60')](_0x348487[_0xf259('0x5b')],[_0xf259('0x5f'),'id'])||{});}})['then'](respondWithResult(_0x3a9391,null))[_0xf259('0x1d')](handleError(_0x3a9391,null));};exports[_0xf259('0x149')]=function(_0x556d92,_0xde1f98){return db[_0xf259('0x3a')]['find']({'where':{'id':_0x556d92[_0xf259('0x5e')]['id']}})[_0xf259('0x28')](handleEntityNotFound(_0xde1f98,null))['then'](function(_0x437050){if(_0x437050){return _0x437050[_0xf259('0x149')](_0x556d92[_0xf259('0x48')][_0xf259('0x5f')]);}})[_0xf259('0x28')](respondWithStatusCode(_0xde1f98,null))[_0xf259('0x1d')](handleError(_0xde1f98,null));};exports[_0xf259('0x14a')]=function(_0x50ac8a,_0x3da0e5){var _0x4fdb57={};var _0x460526={};var _0x3f4fde;var _0x17f08e;return db[_0xf259('0x3a')][_0xf259('0x98')]({'where':{'id':_0x50ac8a[_0xf259('0x5e')]['id']}})['then'](handleEntityNotFound(_0x3da0e5,null))[_0xf259('0x28')](function(_0x32598e){if(_0x32598e){_0x3f4fde=_0x32598e;_0x460526['model']=_[_0xf259('0x51')](db[_0xf259('0x14b')][_0xf259('0x3b')]);_0x460526[_0xf259('0x48')]=_['keys'](_0x50ac8a[_0xf259('0x48')]);_0x460526[_0xf259('0xca')]=_[_0xf259('0x53')](_0x460526[_0xf259('0x54')],_0x460526[_0xf259('0x48')]);_0x4fdb57[_0xf259('0x45')]=_['intersection'](_0x460526[_0xf259('0x54')],qs[_0xf259('0x55')](_0x50ac8a[_0xf259('0x48')][_0xf259('0x55')]));_0x4fdb57[_0xf259('0x45')]=_0x4fdb57[_0xf259('0x45')][_0xf259('0x4a')]?_0x4fdb57[_0xf259('0x45')]:_0x460526[_0xf259('0x54')];_0x4fdb57[_0xf259('0xd9')]=qs[_0xf259('0xcb')](_0x50ac8a[_0xf259('0x48')]['sort']);_0x4fdb57['where']=qs[_0xf259('0xca')](_[_0xf259('0xcc')](_0x50ac8a[_0xf259('0x48')],_0x460526[_0xf259('0xca')]));if(_0x50ac8a[_0xf259('0x48')][_0xf259('0x2e')]){_0x4fdb57[_0xf259('0x41')]=_[_0xf259('0x57')](_0x4fdb57[_0xf259('0x41')],{'$or':_['map'](_0x4fdb57[_0xf259('0x45')],function(_0xbd827c){var _0x3684c3={};_0x3684c3[_0xbd827c]={'$like':'%'+_0x50ac8a['query'][_0xf259('0x2e')]+'%'};return _0x3684c3;})});}_0x4fdb57=_[_0xf259('0x57')]({},_0x4fdb57,_0x50ac8a[_0xf259('0xde')]);return _0x3f4fde['getSmsAccounts'](_0x4fdb57);}})[_0xf259('0x28')](function(_0x276227){if(_0x276227){_0x17f08e=_0x276227['length'];if(!_0x50ac8a['query'][_0xf259('0xcd')](_0xf259('0xd3'))){_0x4fdb57[_0xf259('0x23')]=qs[_0xf259('0x23')](_0x50ac8a[_0xf259('0x48')]['limit']);_0x4fdb57[_0xf259('0x20')]=qs[_0xf259('0x20')](_0x50ac8a[_0xf259('0x48')][_0xf259('0x20')]);}return _0x3f4fde[_0xf259('0x14a')](_0x4fdb57);}})[_0xf259('0x28')](function(_0x4aead5){if(_0x4aead5){return _0x4aead5?{'count':_0x17f08e,'rows':_0x4aead5}:null;}})[_0xf259('0x28')](respondWithResult(_0x3da0e5,null))[_0xf259('0x1d')](handleError(_0x3da0e5,null));};exports[_0xf259('0x14c')]=function(_0x25c8e6,_0x250f1d){return db['User'][_0xf259('0x33')]({'where':{'id':_0x25c8e6['params']['id']}})[_0xf259('0x28')](handleEntityNotFound(_0x250f1d,null))['then'](function(_0x41b8a8){if(_0x41b8a8){return _0x41b8a8['addSmsAccounts'](_0x25c8e6['body'][_0xf259('0x5f')],_['omit'](_0x25c8e6[_0xf259('0x5b')],[_0xf259('0x5f'),'id'])||{});}})[_0xf259('0x28')](respondWithResult(_0x250f1d,null))['catch'](handleError(_0x250f1d,null));};exports['removeSmsAccounts']=function(_0x36ac13,_0x54c83a){return db[_0xf259('0x3a')][_0xf259('0x33')]({'where':{'id':_0x36ac13[_0xf259('0x5e')]['id']}})[_0xf259('0x28')](handleEntityNotFound(_0x54c83a,null))[_0xf259('0x28')](function(_0x1fcc33){if(_0x1fcc33){return _0x1fcc33[_0xf259('0x14d')](_0x36ac13['query']['ids']);}})[_0xf259('0x28')](respondWithStatusCode(_0x54c83a,null))[_0xf259('0x1d')](handleError(_0x54c83a,null));};exports[_0xf259('0x14e')]=function(_0x16277a,_0x5453b6){var _0x1e9b93={};var _0x58bbaf={};var _0x23ac22;var _0x2952a2;return db['User'][_0xf259('0x98')]({'where':{'id':_0x16277a[_0xf259('0x5e')]['id']}})[_0xf259('0x28')](handleEntityNotFound(_0x5453b6,null))[_0xf259('0x28')](function(_0x4634c4){if(_0x4634c4){_0x23ac22=_0x4634c4;_0x58bbaf[_0xf259('0x54')]=_['keys'](db[_0xf259('0x14f')]['rawAttributes']);_0x58bbaf[_0xf259('0x48')]=_[_0xf259('0x51')](_0x16277a[_0xf259('0x48')]);_0x58bbaf['filters']=_[_0xf259('0x53')](_0x58bbaf[_0xf259('0x54')],_0x58bbaf[_0xf259('0x48')]);_0x1e9b93['attributes']=_['intersection'](_0x58bbaf['model'],qs[_0xf259('0x55')](_0x16277a[_0xf259('0x48')][_0xf259('0x55')]));_0x1e9b93[_0xf259('0x45')]=_0x1e9b93['attributes'][_0xf259('0x4a')]?_0x1e9b93[_0xf259('0x45')]:_0x58bbaf['model'];_0x1e9b93[_0xf259('0xd9')]=qs[_0xf259('0xcb')](_0x16277a[_0xf259('0x48')]['sort']);_0x1e9b93['where']=qs[_0xf259('0xca')](_[_0xf259('0xcc')](_0x16277a[_0xf259('0x48')],_0x58bbaf[_0xf259('0xca')]));if(_0x16277a[_0xf259('0x48')][_0xf259('0x2e')]){_0x1e9b93[_0xf259('0x41')]=_[_0xf259('0x57')](_0x1e9b93[_0xf259('0x41')],{'$or':_['map'](_0x1e9b93[_0xf259('0x45')],function(_0x40e8ba){var _0x1fd69d={};_0x1fd69d[_0x40e8ba]={'$like':'%'+_0x16277a[_0xf259('0x48')][_0xf259('0x2e')]+'%'};return _0x1fd69d;})});}_0x1e9b93=_[_0xf259('0x57')]({},_0x1e9b93,_0x16277a[_0xf259('0xde')]);return _0x23ac22[_0xf259('0x14e')](_0x1e9b93);}})[_0xf259('0x28')](function(_0x3092fe){if(_0x3092fe){_0x2952a2=_0x3092fe[_0xf259('0x4a')];if(!_0x16277a[_0xf259('0x48')][_0xf259('0xcd')](_0xf259('0xd3'))){_0x1e9b93[_0xf259('0x23')]=qs[_0xf259('0x23')](_0x16277a[_0xf259('0x48')][_0xf259('0x23')]);_0x1e9b93[_0xf259('0x20')]=qs[_0xf259('0x20')](_0x16277a[_0xf259('0x48')][_0xf259('0x20')]);}return _0x23ac22[_0xf259('0x14e')](_0x1e9b93);}})[_0xf259('0x28')](function(_0x46f9e9){if(_0x46f9e9){return _0x46f9e9?{'count':_0x2952a2,'rows':_0x46f9e9}:null;}})['then'](respondWithResult(_0x5453b6,null))[_0xf259('0x1d')](handleError(_0x5453b6,null));};exports['addChatWebsites']=function(_0xa28855,_0x369092){return db['User']['find']({'where':{'id':_0xa28855[_0xf259('0x5e')]['id']}})['then'](handleEntityNotFound(_0x369092,null))[_0xf259('0x28')](function(_0x507a77){if(_0x507a77){return _0x507a77['addChatWebsites'](_0xa28855['body'][_0xf259('0x5f')],_['omit'](_0xa28855[_0xf259('0x5b')],[_0xf259('0x5f'),'id'])||{});}})[_0xf259('0x28')](respondWithResult(_0x369092,null))['catch'](handleError(_0x369092,null));};exports['removeChatWebsites']=function(_0x511b8b,_0x189ed8){return db['User'][_0xf259('0x33')]({'where':{'id':_0x511b8b[_0xf259('0x5e')]['id']}})[_0xf259('0x28')](handleEntityNotFound(_0x189ed8,null))[_0xf259('0x28')](function(_0x11d23a){if(_0x11d23a){return _0x11d23a[_0xf259('0x150')](_0x511b8b[_0xf259('0x48')][_0xf259('0x5f')]);}})[_0xf259('0x28')](respondWithStatusCode(_0x189ed8,null))['catch'](handleError(_0x189ed8,null));};exports['getWhatsappAccounts']=function(_0x1b1dde,_0x3135dd){var _0x5874b1={};var _0x3d93c8={};var _0x6d424;var _0x4603bc;return db[_0xf259('0x3a')][_0xf259('0x98')]({'where':{'id':_0x1b1dde[_0xf259('0x5e')]['id']}})[_0xf259('0x28')](handleEntityNotFound(_0x3135dd,null))[_0xf259('0x28')](function(_0x3b41dc){if(_0x3b41dc){_0x6d424=_0x3b41dc;_0x3d93c8[_0xf259('0x54')]=_['keys'](db['WhatsappAccount'][_0xf259('0x3b')]);_0x3d93c8['query']=_['keys'](_0x1b1dde[_0xf259('0x48')]);_0x3d93c8['filters']=_[_0xf259('0x53')](_0x3d93c8[_0xf259('0x54')],_0x3d93c8['query']);_0x5874b1[_0xf259('0x45')]=_[_0xf259('0x53')](_0x3d93c8[_0xf259('0x54')],qs[_0xf259('0x55')](_0x1b1dde['query'][_0xf259('0x55')]));_0x5874b1[_0xf259('0x45')]=_0x5874b1['attributes'][_0xf259('0x4a')]?_0x5874b1[_0xf259('0x45')]:_0x3d93c8[_0xf259('0x54')];_0x5874b1[_0xf259('0xd9')]=qs['sort'](_0x1b1dde[_0xf259('0x48')][_0xf259('0xcb')]);_0x5874b1[_0xf259('0x41')]=qs[_0xf259('0xca')](_[_0xf259('0xcc')](_0x1b1dde[_0xf259('0x48')],_0x3d93c8[_0xf259('0xca')]));if(_0x1b1dde[_0xf259('0x48')][_0xf259('0x2e')]){_0x5874b1[_0xf259('0x41')]=_[_0xf259('0x57')](_0x5874b1[_0xf259('0x41')],{'$or':_[_0xf259('0x30')](_0x5874b1[_0xf259('0x45')],function(_0x24bd1c){var _0x24d555={};_0x24d555[_0x24bd1c]={'$like':'%'+_0x1b1dde[_0xf259('0x48')][_0xf259('0x2e')]+'%'};return _0x24d555;})});}_0x5874b1=_[_0xf259('0x57')]({},_0x5874b1,_0x1b1dde[_0xf259('0xde')]);return _0x6d424['getWhatsappAccounts'](_0x5874b1);}})[_0xf259('0x28')](function(_0x134439){if(_0x134439){_0x4603bc=_0x134439[_0xf259('0x4a')];if(!_0x1b1dde['query'][_0xf259('0xcd')](_0xf259('0xd3'))){_0x5874b1[_0xf259('0x23')]=qs[_0xf259('0x23')](_0x1b1dde['query'][_0xf259('0x23')]);_0x5874b1[_0xf259('0x20')]=qs[_0xf259('0x20')](_0x1b1dde['query'][_0xf259('0x20')]);}return _0x6d424[_0xf259('0x151')](_0x5874b1);}})[_0xf259('0x28')](function(_0x201a9f){if(_0x201a9f){return _0x201a9f?{'count':_0x4603bc,'rows':_0x201a9f}:null;}})['then'](respondWithResult(_0x3135dd,null))['catch'](handleError(_0x3135dd,null));};exports[_0xf259('0x152')]=function(_0x568c6f,_0x4dc506){return db['User'][_0xf259('0x33')]({'where':{'id':_0x568c6f[_0xf259('0x5e')]['id']}})['then'](handleEntityNotFound(_0x4dc506,null))[_0xf259('0x28')](function(_0x19ef08){if(_0x19ef08){return _0x19ef08[_0xf259('0x152')](_0x568c6f[_0xf259('0x5b')][_0xf259('0x5f')],_[_0xf259('0x60')](_0x568c6f[_0xf259('0x5b')],[_0xf259('0x5f'),'id'])||{});}})[_0xf259('0x28')](respondWithResult(_0x4dc506,null))[_0xf259('0x1d')](handleError(_0x4dc506,null));};exports[_0xf259('0x153')]=function(_0x2fe98c,_0x42fd77){return db[_0xf259('0x3a')][_0xf259('0x33')]({'where':{'id':_0x2fe98c['params']['id']}})['then'](handleEntityNotFound(_0x42fd77,null))[_0xf259('0x28')](function(_0x23fb72){if(_0x23fb72){return _0x23fb72['removeWhatsappAccounts'](_0x2fe98c['query'][_0xf259('0x5f')]);}})[_0xf259('0x28')](respondWithStatusCode(_0x42fd77,null))['catch'](handleError(_0x42fd77,null));};exports[_0xf259('0x154')]=function(_0x52517e,_0x419291){var _0x4215c5={};var _0x16246f={};var _0x1f7e08;var _0xbef858;return db[_0xf259('0x3a')][_0xf259('0x98')]({'where':{'id':_0x52517e[_0xf259('0x5e')]['id']}})[_0xf259('0x28')](handleEntityNotFound(_0x419291,null))['then'](function(_0x5da1ed){if(_0x5da1ed){_0x1f7e08=_0x5da1ed;_0x16246f['model']=_[_0xf259('0x51')](db[_0xf259('0x155')][_0xf259('0x3b')]);_0x16246f[_0xf259('0x48')]=_['keys'](_0x52517e[_0xf259('0x48')]);_0x16246f[_0xf259('0xca')]=_['intersection'](_0x16246f[_0xf259('0x54')],_0x16246f[_0xf259('0x48')]);_0x4215c5[_0xf259('0x45')]=_[_0xf259('0x53')](_0x16246f[_0xf259('0x54')],qs[_0xf259('0x55')](_0x52517e[_0xf259('0x48')]['fields']));_0x4215c5[_0xf259('0x45')]=_0x4215c5[_0xf259('0x45')]['length']?_0x4215c5[_0xf259('0x45')]:_0x16246f['model'];_0x4215c5[_0xf259('0xd9')]=qs[_0xf259('0xcb')](_0x52517e[_0xf259('0x48')][_0xf259('0xcb')]);_0x4215c5[_0xf259('0x41')]=qs[_0xf259('0xca')](_[_0xf259('0xcc')](_0x52517e['query'],_0x16246f[_0xf259('0xca')]));if(_0x52517e[_0xf259('0x48')][_0xf259('0x2e')]){_0x4215c5['where']=_[_0xf259('0x57')](_0x4215c5[_0xf259('0x41')],{'$or':_[_0xf259('0x30')](_0x4215c5[_0xf259('0x45')],function(_0x5121f6){var _0x3b56f2={};_0x3b56f2[_0x5121f6]={'$like':'%'+_0x52517e[_0xf259('0x48')][_0xf259('0x2e')]+'%'};return _0x3b56f2;})});}_0x4215c5=_['merge']({},_0x4215c5,_0x52517e[_0xf259('0xde')]);return _0x1f7e08['getSquareProjects'](_0x4215c5);}})[_0xf259('0x28')](function(_0xd3b0ed){if(_0xd3b0ed){_0xbef858=_0xd3b0ed[_0xf259('0x4a')];if(!_0x52517e[_0xf259('0x48')][_0xf259('0xcd')](_0xf259('0xd3'))){_0x4215c5[_0xf259('0x23')]=qs['limit'](_0x52517e[_0xf259('0x48')][_0xf259('0x23')]);_0x4215c5['offset']=qs[_0xf259('0x20')](_0x52517e['query'][_0xf259('0x20')]);}return _0x1f7e08['getSquareProjects'](_0x4215c5);}})[_0xf259('0x28')](function(_0x4f9acc){if(_0x4f9acc){return _0x4f9acc?{'count':_0xbef858,'rows':_0x4f9acc}:null;}})[_0xf259('0x28')](respondWithResult(_0x419291,null))[_0xf259('0x1d')](handleError(_0x419291,null));};exports[_0xf259('0x156')]=function(_0x55ecf1,_0x5c37d5){return db[_0xf259('0x3a')][_0xf259('0x33')]({'where':{'id':_0x55ecf1[_0xf259('0x5e')]['id']}})[_0xf259('0x28')](handleEntityNotFound(_0x5c37d5,null))[_0xf259('0x28')](function(_0xd177db){if(_0xd177db){return _0xd177db[_0xf259('0x156')](_0x55ecf1[_0xf259('0x5b')][_0xf259('0x5f')],_[_0xf259('0x60')](_0x55ecf1[_0xf259('0x5b')],[_0xf259('0x5f'),'id'])||{});}})[_0xf259('0x28')](respondWithResult(_0x5c37d5,null))[_0xf259('0x1d')](handleError(_0x5c37d5,null));};exports[_0xf259('0x157')]=function(_0x767426,_0x1dcf69){return db[_0xf259('0x3a')][_0xf259('0x33')]({'where':{'id':_0x767426[_0xf259('0x5e')]['id']}})[_0xf259('0x28')](handleEntityNotFound(_0x1dcf69,null))[_0xf259('0x28')](function(_0x43d86e){if(_0x43d86e){return _0x43d86e[_0xf259('0x157')](_0x767426[_0xf259('0x48')][_0xf259('0x5f')]);}})[_0xf259('0x28')](respondWithStatusCode(_0x1dcf69,null))[_0xf259('0x1d')](handleError(_0x1dcf69,null));};exports['getScheduledCalls']=function(_0x41ec75,_0xd36849){var _0x1d5297={},_0x166c9f={},_0x310c67={'count':0x0,'rows':[]};var _0x5a499f=db['CmHopper'][_0xf259('0x3b')];_0x166c9f['model']=_['keys'](_0x5a499f);_0x166c9f[_0xf259('0x48')]=_['keys'](_0x41ec75[_0xf259('0x48')]);_0x166c9f[_0xf259('0xca')]=_[_0xf259('0x53')](_0x166c9f['model'],_0x166c9f[_0xf259('0x48')]);_0x166c9f[_0xf259('0xca')]=_[_0xf259('0xc8')](_0x166c9f[_0xf259('0xca')],[_0xf259('0x158'),_0xf259('0x159'),_0xf259('0x15a'),_0xf259('0x15b'),_0xf259('0x15c'),_0xf259('0x15d'),_0xf259('0x15e'),_0xf259('0x15f'),_0xf259('0x160'),_0xf259('0x161'),_0xf259('0x162'),_0xf259('0x163'),'$notIn',_0xf259('0x164'),_0xf259('0x165'),_0xf259('0x166'),_0xf259('0x167'),_0xf259('0x164'),_0xf259('0x168'),'$contains',_0xf259('0x169'),_0xf259('0x16a')]);_0x1d5297[_0xf259('0x45')]=_[_0xf259('0x53')](_0x166c9f[_0xf259('0x54')],qs[_0xf259('0x55')](_0x41ec75[_0xf259('0x48')][_0xf259('0x55')]));_0x1d5297['attributes']=_0x1d5297[_0xf259('0x45')][_0xf259('0x4a')]?_0x1d5297['attributes']:_0x166c9f[_0xf259('0x54')];if(!_0x41ec75['query'][_0xf259('0xcd')](_0xf259('0xd3'))){_0x1d5297[_0xf259('0x23')]=qs['limit'](_0x41ec75[_0xf259('0x48')][_0xf259('0x23')]);_0x1d5297[_0xf259('0x20')]=qs[_0xf259('0x20')](_0x41ec75['query'][_0xf259('0x20')]);}_0x1d5297[_0xf259('0xd9')]=qs[_0xf259('0xcb')](_0x41ec75[_0xf259('0x48')][_0xf259('0xcb')]);_0x1d5297[_0xf259('0x41')]=qs['filters'](_[_0xf259('0xcc')](_0x41ec75[_0xf259('0x48')],_0x166c9f[_0xf259('0xca')]));if(_0x41ec75[_0xf259('0x48')][_0xf259('0x2e')]){_0x1d5297[_0xf259('0x41')]=_[_0xf259('0x57')](_0x1d5297[_0xf259('0x41')],{'$or':_[_0xf259('0x30')](_0x1d5297[_0xf259('0x45')],function(_0x1d087c){var _0x22f012={};_0x22f012[_0x1d087c]={'$like':'%'+_0x41ec75[_0xf259('0x48')][_0xf259('0x2e')]+'%'};return _0x22f012;})});}_0x1d5297['where']={'$and':[_0x1d5297[_0xf259('0x41')],{'$or':[{'UserId':_0x41ec75[_0xf259('0x5e')]['id']},{'OwnerId':_0x41ec75[_0xf259('0x5e')]['id']}]}]};_0x1d5297=_[_0xf259('0x57')]({},_0x1d5297,_0x41ec75[_0xf259('0xde')]);var _0x3a1280={'where':_0x1d5297[_0xf259('0x41')]};return db[_0xf259('0x16b')][_0xf259('0x22')](_0x3a1280)[_0xf259('0x28')](function(_0x2757a3){_0x310c67[_0xf259('0x22')]=_0x2757a3;if(_0x41ec75[_0xf259('0x48')][_0xf259('0xce')]){_0x1d5297[_0xf259('0x56')]=[{'attributes':['id','firstName','lastName',_0xf259('0x16c')],'model':db[_0xf259('0x16d')],'as':'Contact'},{'attributes':['id',_0xf259('0x34'),_0xf259('0x16e')],'model':db['VoiceQueue'],'as':_0xf259('0xd5')}];}return db[_0xf259('0x16b')][_0xf259('0xab')](_0x1d5297);})['then'](function(_0x5e3050){_0x310c67['rows']=_0x5e3050;return _0x310c67;})['then'](respondWithFilteredResult(_0xd36849,_0x1d5297))['catch'](handleError(_0xd36849,null));};exports[_0xf259('0x16f')]=function(_0x413fe9,_0x3c6fb9){if(!_[_0xf259('0x66')](_0x413fe9[_0xf259('0x7d')]['id'])&&(_0x413fe9['user']['role']==_0xf259('0x2a')||_0x413fe9[_0xf259('0x7d')][_0xf259('0x29')]==_0xf259('0x7d'))){return db[_0xf259('0x3a')]['findOne']({'where':{'id':_0x413fe9['params']['id']},'raw':!![]})[_0xf259('0x28')](function(_0x6f111a){return authService[_0xf259('0x170')](_0x6f111a);})[_0xf259('0x28')](function(_0x881fc1){if(_0x881fc1){return _0x3c6fb9[_0xf259('0x1e')](0xc8)['json']({'api_key':_0x881fc1[_0xf259('0x171')]});}else{return _0x3c6fb9['status'](0xcc)['json']({'message':'No\x20API\x20access\x20key\x20found!'});}})[_0xf259('0x1d')](handleError(_0x3c6fb9,0x193));}else{return _0x3c6fb9['status'](0x191)['json']({'message':_0xf259('0x172')});}};exports['createApiKey']=function(_0x43b116,_0x3539c5){if(!_[_0xf259('0x66')](_0x43b116[_0xf259('0x7d')]['id'])&&(_0x43b116['user'][_0xf259('0x29')]==_0xf259('0x2a')||_0x43b116['user']['role']==_0xf259('0x7d'))){return db['User'][_0xf259('0x33')]({'where':{'id':_0x43b116[_0xf259('0x5e')]['id']}})[_0xf259('0x28')](function(_0x1d3889){return authService[_0xf259('0x173')](_0x1d3889);})[_0xf259('0x28')](function(_0x2940ee){return db[_0xf259('0x3a')][_0xf259('0x26')]({'apiKeyIat':_0x2940ee[_0xf259('0x174')],'apiKeyNonce':_0x2940ee[_0xf259('0x175')]},{'where':{'id':_0x43b116[_0xf259('0x5e')]['id']}})[_0xf259('0x28')](function(){return _0x3539c5[_0xf259('0x1e')](0xc8)[_0xf259('0x1f')]({'api_key':_0x2940ee[_0xf259('0x171')]});});})['catch'](handleError(_0x3539c5,0x193));}else{return _0x3539c5['status'](0x191)[_0xf259('0x1f')]({'message':_0xf259('0x172')});}};exports[_0xf259('0x176')]=function(_0x22e389,_0xbd562c){if(!_[_0xf259('0x66')](_0x22e389['user']['id'])&&(_0x22e389[_0xf259('0x7d')][_0xf259('0x29')]==_0xf259('0x2a')||_0x22e389[_0xf259('0x7d')]['role']=='user')){return db[_0xf259('0x3a')]['find']({'where':{'id':_0x22e389[_0xf259('0x5e')]['id']}})[_0xf259('0x28')](handleEntityNotFound(_0xbd562c,null))['then'](function(_0x5bb24f){if(_0x5bb24f&&_0x5bb24f[_0xf259('0x177')]&&_0x5bb24f[_0xf259('0x178')])return _0x5bb24f;else throw{'message':_0xf259('0x179')};})['then'](function(){return db[_0xf259('0x3a')][_0xf259('0x26')]({'apiKeyNonce':null,'apiKeyIat':null},{'where':{'id':_0x22e389['params']['id']}});})['then'](respondWithStatusCode(_0xbd562c,0xc8))['catch'](handleError(_0xbd562c,0x193));}else{return _0xbd562c[_0xf259('0x1e')](0x191)['json']({'message':_0xf259('0x172')});}};exports[_0xf259('0x17a')]=function(_0x279a80,_0x1c0488){var _0x495bef=_0x279a80['user'][_0xf259('0xd6')]({'plain':!![]});if(!_0x495bef){return _0x1c0488['status'](0x191)[_0xf259('0x127')](_0xf259('0x17b'));}else{Promise[_0xf259('0xfd')]()[_0xf259('0x28')](function(){if(_0x279a80['query'][_0xf259('0x44')]!=='true')return;return _0x279a80['user'][_0xf259('0x17c')]();})[_0xf259('0x28')](function(_0xcf2a37){if(!_0xcf2a37)return;return _0xcf2a37[_0xf259('0xd6')]({'plain':!![]});})[_0xf259('0x28')](function(_0x5bf388){_0x495bef[_0xf259('0x44')]=_0x5bf388;return _0x1c0488[_0xf259('0x1e')](0xc8)[_0xf259('0x1f')](_0x495bef);});}};exports['getPresence']=function(_0x48e222,_0x305a87){var _0x3d0771={'offset':0x0},_0x3fec0e={'count':0x0,'rows':[]};Promise[_0xf259('0xfd')]()[_0xf259('0x28')](function(){if(!_0x48e222['query'][_0xf259('0x2e')]&&!_0x48e222[_0xf259('0x48')][_0xf259('0x17d')]&&!_0x48e222[_0xf259('0x48')]['queues'])return[];return Promise['resolve']()[_0xf259('0x28')](function(){var _0x5d864d=[];if(!_['isEmpty'](_0x48e222['query'][_0xf259('0x17d')])){_0x5d864d['push'](db[_0xf259('0x10e')]['findAll']({'attributes':['id','name'],'where':{'id':_0x48e222[_0xf259('0x48')][_0xf259('0x17d')]}}));}if(!_[_0xf259('0x8c')](_0x48e222['query']['queues'])){_0x5d864d[_0xf259('0x46')](db[_0xf259('0x17e')][_0xf259('0xab')]({'attributes':['id',_0xf259('0x34')],'type':'inbound','where':{'id':_0x48e222[_0xf259('0x48')]['queues']}}));}return Promise[_0xf259('0x5a')](_0x5d864d);})['then'](function(_0x297cb8){var _0x24df4a=_[_0xf259('0x17f')](_0x297cb8)[_0xf259('0x30')](function(_0x58e951){return _0x58e951[_0xf259('0x125')]({'attributes':['id',_0xf259('0x34'),_0xf259('0x61'),'online'],'raw':!![]});});return Promise[_0xf259('0x5a')](_0x24df4a);})[_0xf259('0x28')](function(_0x383495){var _0x361b80=_['flatten'](_0x383495);if(!_0x48e222[_0xf259('0x48')]['filter'])return _0x361b80;if(_[_0xf259('0x8c')](_0x361b80)){return db[_0xf259('0x3a')][_0xf259('0xab')]({'attributes':['id','name',_0xf259('0x61'),_0xf259('0x9e')],'where':{'role':_0xf259('0x7e'),'$or':[db['sequelize']['where'](db['sequelize']['fn'](_0xf259('0x180'),db[_0xf259('0x68')][_0xf259('0x181')](_0xf259('0x34'))),{'$like':'%'+_0x48e222[_0xf259('0x48')][_0xf259('0x2e')][_0xf259('0xa7')]()+'%'}),{'internal':{'$like':'%'+_0x48e222[_0xf259('0x48')][_0xf259('0x2e')]+'%'}}]},'raw':!![]});}else{return _(_0x361b80)[_0xf259('0x17f')]()[_0xf259('0x2e')](function(_0x312e49){return _0x312e49[_0xf259('0x34')][_0xf259('0xa7')]()['includes'](_0x48e222[_0xf259('0x48')][_0xf259('0x2e')][_0xf259('0xa7')]())||_0x312e49['internal'][_0xf259('0x182')]()['includes'](_0x48e222[_0xf259('0x48')]['filter']);})[_0xf259('0x31')]();}})[_0xf259('0x28')](function(_0x338b91){var _0x5f03b1=_0xf259('0x34');var _0x1a2e56='asc';if(_0x48e222['query'][_0xf259('0xcb')]){_0x1a2e56=_0x48e222[_0xf259('0x48')]['sort'][0x0]==='-'?'desc':_0xf259('0x183');_0x5f03b1=_0x1a2e56===_0xf259('0x183')?_0x48e222[_0xf259('0x48')][_0xf259('0xcb')]:_0x48e222[_0xf259('0x48')]['sort']['substring'](0x1);}return _(_0x338b91)[_0xf259('0x184')]('id')[_0xf259('0x185')]([function(_0x2cea90){return _0x5f03b1===_0xf259('0x34')?_0x2cea90[_0x5f03b1][_0xf259('0xa7')]():_0x2cea90[_0x5f03b1];}],[_0x1a2e56])[_0xf259('0x30')](function(_0x581ee3){return _['pick'](_0x581ee3,['id',_0xf259('0x34'),_0xf259('0x61'),'online']);})['value']();})[_0xf259('0x28')](function(_0x591610){return client['request'](_0xf259('0x2b'),_0x48e222)[_0xf259('0x28')](function(_0x4aeefc){if(_0x4aeefc['error'])throw new Error('Unable\x20to\x20retrieve\x20RPC\x20agents\x20(AMI)');var _0xf1ebf8=_0x4aeefc[_0xf259('0x1c')];var _0xcf3451=jayson[_0xf259('0x186')]['http']({'port':0x232c});return _0xcf3451['request'](_0xf259('0x2b'),_0x48e222)[_0xf259('0x28')](function(_0x477c54){if(_0x477c54[_0xf259('0x18')])throw new Error(_0xf259('0x187'));var _0x913ad4=_0x477c54[_0xf259('0x1c')];return _[_0xf259('0x57')]({},_0x913ad4,_0xf1ebf8);});})['then'](function(_0x4715d9){return _['map'](_0x591610,function(_0x40bea5){var _0x5022df=_[_0xf259('0x33')](_0x4715d9['rows'],['id',_0x40bea5['id']]);if(!_0x5022df||!_0x40bea5['online']){_0x40bea5[_0xf259('0x1e')]='offline';}else if(_0x5022df[_0xf259('0x9f')]){_0x40bea5[_0xf259('0x1e')]=_0xf259('0xff');}else{_0x40bea5['status']=_['includes']([_0xf259('0x188'),_0xf259('0x189'),_0xf259('0x18a'),_0xf259('0x18b'),null,undefined],_0x5022df[_0xf259('0x18c')])?_0xf259('0x9e'):'busy';}return _0x40bea5;});});});})['then'](function(_0x37f687){if(!_0x48e222[_0xf259('0x48')]['hasOwnProperty']('nolimit')){_0x3d0771['limit']=qs[_0xf259('0x23')](_0x48e222[_0xf259('0x48')]['limit']||0xa);_0x3d0771[_0xf259('0x20')]=qs[_0xf259('0x20')](_0x48e222['query']['offset']);}_0x3fec0e[_0xf259('0x22')]=_0x37f687['length'];_0x3fec0e[_0xf259('0x47')]=_0x3d0771[_0xf259('0x23')]?_0x37f687['slice'](_0x3d0771[_0xf259('0x20')],_0x3d0771[_0xf259('0x20')]+_0x3d0771['limit']):_0x37f687;return _0x3fec0e;})[_0xf259('0x28')](respondWithFilteredResult(_0x305a87,_0x3d0771))[_0xf259('0x1d')](handleError(_0x305a87,null));};function get_open_tabs(_0x12f445,_0x33beb2){var _0x79df2b=_0x12f445[_0xf259('0x18d')](0x0)['toUpperCase']()+_0x12f445[_0xf259('0x18e')](0x1);var _0x463106={'type':db[_0xf259('0x94')][_0xf259('0x18f')]['SELECT'],'raw':!![]};return new BPromise(function(_0x518d96,_0x3b6786){var _0x36e025=squel[_0xf259('0x190')]()[_0xf259('0x191')]('ui.'+_0x79df2b+_0xf259('0x192'),'id')[_0xf259('0x191')](_0xf259('0x193'))[_0xf259('0x6b')](_0xf259('0x194')+_0x12f445+_0xf259('0x195'),'ui')['where'](_0xf259('0x196'),_0x33beb2['id']);return db[_0xf259('0x68')][_0xf259('0x48')](_0x36e025[_0xf259('0x182')](),_0x463106)[_0xf259('0x28')](function(_0x4da425){_0x33beb2[_0x79df2b+'OpenTabs']=_0x4da425;_0x518d96(_0x4da425);})[_0xf259('0x1d')](function(_0x12510f){_0x3b6786(_0x12510f);});});}
\ No newline at end of file