62d853c37d21103154b1a1ec8ee71e757d435260
[motion2.git] / server / api / user / user.controller.js
1 // *************************************************************************
2 // *                                                                       *
3 // * xCALLY Motion -  The Omnichannel Contact Center                       *
4 // * Copyright (c) Xenialab s.r.l. All Rights Reserved                     *
5 // *                                                                       *
6 // *************************************************************************
7 // *                                                                       *
8 // * Email: info@xcally.com                                                *
9 // * Website: https://www.xcally.com                                       *
10 // *                                                                       *
11 // *************************************************************************
12 // *                                                                       *
13 // * The SOFTWARE PRODUCT is protected by copyright laws and international *
14 // * copyright treaties, as well as other intellectual property laws and   *
15 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                         *
16 // *                                                                       *
17 // *************************************************************************
18 var _0x5ea0=['getScreenRecordings','ScreenRecording','getChatInteractions','ChatInteraction','getOpenchannelInteractions','OpenchannelInteraction','MailInteraction','getSmsInteractions','SmsInteraction','FaxInteraction','getFaxInteractions','getWhatsappInteractions','WhatsappInteraction','phone','format','LOCAL/%s@from-sip/n','intrf','user:%s','headers','x-forwarded-for','connection','remoteAddress','socket','User\x20not\x20found\x20or\x20not\x20allowed\x20to\x20perform\x20login\x20method','getVoiceQueues','UserVoiceQueue.penalty','upsert','MemberReport','forEach','YYYY-MM-DD\x20HH:mm:ss','getChannels','device','PAUSE','LOGININPAUSE','isMiddleware','resolve','QueuePause','updateAttributes','DEFAULT\x20PAUSE','unpause','mailPause','openchannelPause','whatsapppause','manual','%s%s','Pause','Team','getTeams','addTeams','setDataValue','Voice','Chat','Mail','getSmsQueues','Sms','getWhatsappQueues','Whatsapp','getFaxQueues','Fax','Openchannel','flatten','transaction','addAgent','getDataValue','TeamVoicePrefix','UserVoicePrefix','VoicePrefixId','removeTeams','getChatQueues','getMailQueues','getOpenchannelQueues','getLists','getAgents','You\x20can\x27t\x20delete\x20yourself','addChatInteractions','user_has_chat_interactions:save','removeChatInteractions','isArray','user_has_chat_interactions:remove','addMailInteractions','user_has_mail_interactions:save','removeMailInteractions','user_has_mail_interactions:remove','addFaxInteractions','removeFaxInteractions','user_has_fax_interactions:remove','addSmsInteractions','user_has_sms_interactions:save','removeSmsInteractions','user_has_sms_interactions:remove','addOpenchannelInteractions','removeOpenchannelInteractions','user_has_openchannel_interactions:remove','addWhatsappInteractions','removeWhatsappInteractions','getVoicePrefixes','VoicePrefix','getFaxAccounts','addFaxAccounts','removeFaxAccounts','MailAccount','getMailAccounts','addMailAccounts','removeMailAccounts','getOpenchannelAccounts','addOpenchannelAccounts','removeOpenchannelAccounts','getSmsAccounts','SmsAccount','addSmsAccounts','removeSmsAccounts','ChatWebsite','getChatWebsites','addChatWebsites','removeChatWebsites','getWhatsappAccounts','addWhatsappAccounts','removeWhatsappAccounts','SquareProject','getSquareProjects','addSquareProjects','removeSquareProjects','$and','$or','$gt','$gte','$lte','$ne','$not','$between','$notBetween','$in','$notIn','$notILike','$overlap','$contains','$contained','$any','CmHopper','CmContact','dialActive','getApiKey','retrieveApiKey','token','No\x20API\x20access\x20key\x20found!','You\x20don\x27t\x20have\x20sufficient\x20privileges\x20to\x20access\x20this\x20resource.','createApiKey','generateApiKey','iat','nonce','apiKeyNonce','apiKeyIat','API\x20key\x20not\x20available','whoami','Unable\x20to\x20retrieve\x20the\x20current\x20user','getUserSetting','getPresence','queues','isEmpty','teams','inbound','lower','toString','asc','desc','orderBy','request','client','Unable\x20to\x20retrieve\x20RPC\x20agents\x20(Routing)','offline','idle','unknown','unavailable','voiceStatus','slice','charAt','toUpperCase','select','field','ui.','InteractionId','user_has_','_interactions','OpenTabs','bluebird','util','lodash','jayson/promise','../../components/auth/service','../../components/parsers/qs','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','socket.io-emitter','redis','./user.socket','register','defaults','localhost','http','then','User,\x20%s,\x20%s','request\x20sent','User,\x20%s,\x20%s,\x20%s','stringify','error','message','result','catch','end','status','json','undefined','limit','offset','set','update','role','admin','Users','user','agent','telephone','filter','ignore','value','includes','find','name','UserProfileResource','destroy','sendStatus','stack','send','User','rawAttributes','map','fieldName','type','key','password','salt','getOptions','where','count','query','include','UserSetting','userSetting','attributes','push','findAll','rows','openTabs','true','length','chat','dataValues','sms','mail','openchannel','whatsapp','all','params','model','differenceBy','keys','filters','intersection','fields','includeAll','merge','options','fax','body','describe','addContacts','ids','omit','internal','findById','securePassword','isNil','min_internal','sequelize','select\x20(select\x20IFNULL(max(internal)+1,1)\x20from\x20users\x20where\x20internal\x20<\x20md.internal)\x20as\x20\x27from\x27,\x20md.internal\x20-\x201\x20as\x20\x27to\x27\x20from\x20users\x20md\x20where\x20md.internal\x20!=\x201\x20and\x20not\x20exists\x20(select\x201\x20from\x20users\x20md2\x20where\x20md2.internal\x20=\x20md.internal\x20-\x201)','QueryTypes','SELECT','from','voicemail','mailbox','VoiceMail','email','101','102','103','113','110','105','106','107','109','100','111','114','115','create','Unauthorized','Unauthorized.\x20You\x20must\x20be\x20an\x20administrator\x20in\x20order\x20to\x20create\x20another\x20administrator','checkUserLimits','settingsEnabled','userProfileId','UserProfileSection','Agents','Telephones','autoAssociation','bulkCreate','some','Unauthorized.\x20You\x20must\x20be\x20an\x20administrator\x20in\x20order\x20to\x20create\x20an\x20user','Unauthorized.\x20You\x20must\x20be\x20an\x20administrator\x20in\x20order\x20to\x20create\x20an\x20administrator','each','compact','oldPassword','newPassword','Sequelize','ValidationError','Invalid\x20body\x20format.\x20Use\x20oldPassword\x20and\x20newPassword','authenticate','Wrong\x20credentials','New\x20password\x20must\x20be\x20different\x20from\x20old\x20password','Invalid\x20body\x20format.\x20Use\x20newPassword','findOne','enforcePasswordHistory','passwordHistoryLimit','validatePasswordPattern','previousPasswords','channel','loginInPause','voicePause','interface','Unknown\x20channel','capitalize','Queues','penalty','spread','toLowerCase','QueueId','emit','Queue:save','voice','VoiceQueue','get','online','SIP/%s','UserVoiceQueueRt','removeQueues','isValidChannel','remove','Queue:remove','addAvatar','userpic','filename','root','server/files/images/logos/default_profile.png','download','existsSync','join','server/files/images/','getOpenTabs','ChatOpenTabs','CHAT','FaxOpenTabs','FAX','createdAt','OpenchannelOpenTabs','MailOpenTabs','MAIL','SmsOpenTabs','WHATSAPP','concat','getContacts','hasOwnProperty','CmList','List','Tag','Tags','color','tag','nolimit','getQueues','Queue','order','sort','pick','Unknown\x20role','getVoiceQueuesRt','getGroups','ChatGroup','VoiceRecording','UserId'];(function(_0x16f77c,_0x5256b1){var _0x78986e=function(_0x10430){while(--_0x10430){_0x16f77c['push'](_0x16f77c['shift']());}};_0x78986e(++_0x5256b1);}(_0x5ea0,0xb8));var _0x05ea=function(_0x1879ba,_0x8a6257){_0x1879ba=_0x1879ba-0x0;var _0x507437=_0x5ea0[_0x1879ba];return _0x507437;};'use strict';var moment=require('moment');var BPromise=require(_0x05ea('0x0'));var util=require(_0x05ea('0x1'));var path=require('path');var fs=require('fs');var _=require(_0x05ea('0x2'));var squel=require('squel');var jayson=require(_0x05ea('0x3'));var Redis=require('ioredis');var authService=require(_0x05ea('0x4'));var qs=require(_0x05ea('0x5'));var logger=require(_0x05ea('0x6'))(_0x05ea('0x7'));var utils=require(_0x05ea('0x8'));var config=require(_0x05ea('0x9'));var licenseUtil=require(_0x05ea('0xa'));var db=require(_0x05ea('0xb'))['db'];var socket=require(_0x05ea('0xc'))(new Redis(config[_0x05ea('0xd')]));require(_0x05ea('0xe'))[_0x05ea('0xf')](socket);config[_0x05ea('0xd')]=_[_0x05ea('0x10')](config[_0x05ea('0xd')],{'host':_0x05ea('0x11'),'port':0x18eb});var client=jayson['client'][_0x05ea('0x12')]({'port':0x232a});var values;function respondWithRpcPromise(_0x8f11af,_0xdf4cf5,_0x18c0bb,_0xc086fb){return new BPromise(function(_0x2e07af,_0x5b86e6){var _0x15dfb5=_0xc086fb||client;return _0x15dfb5['request'](_0x8f11af,_0x18c0bb)[_0x05ea('0x13')](function(_0x1f88cd){logger['info'](_0x05ea('0x14'),_0xdf4cf5,_0x05ea('0x15'));logger['debug'](_0x05ea('0x16'),_0xdf4cf5,'request\x20sent',JSON[_0x05ea('0x17')](_0x1f88cd));if(_0x1f88cd[_0x05ea('0x18')]){if(_0x1f88cd[_0x05ea('0x18')]['code']===0x1f4){logger['error']('User,\x20%s,\x20%s',_0xdf4cf5,_0x1f88cd['error'][_0x05ea('0x19')]);return _0x5b86e6(_0x1f88cd[_0x05ea('0x18')][_0x05ea('0x19')]);}logger[_0x05ea('0x18')](_0x05ea('0x14'),_0xdf4cf5,_0x1f88cd[_0x05ea('0x18')][_0x05ea('0x19')]);return _0x2e07af(_0x1f88cd[_0x05ea('0x18')][_0x05ea('0x19')]);}else{logger['info'](_0x05ea('0x14'),_0xdf4cf5,'request\x20sent');_0x2e07af(_0x1f88cd[_0x05ea('0x1a')][_0x05ea('0x19')]);}})[_0x05ea('0x1b')](function(_0x35fff2){logger[_0x05ea('0x18')](_0x05ea('0x14'),_0xdf4cf5,_0x35fff2);_0x5b86e6(_0x35fff2);});});}function respondWithStatusCode(_0x3d38ff,_0x344626){_0x344626=_0x344626||0xcc;return function(_0x3ffaf0){if(_0x3ffaf0){return _0x3d38ff['sendStatus'](_0x344626);}return _0x3d38ff['status'](_0x344626)[_0x05ea('0x1c')]();};}function respondWithResult(_0x475a6d,_0x31bb27){_0x31bb27=_0x31bb27||0xc8;return function(_0x2ee6fe){if(_0x2ee6fe){return _0x475a6d[_0x05ea('0x1d')](_0x31bb27)[_0x05ea('0x1e')](_0x2ee6fe);}};}function respondWithFilteredResult(_0x2919fd,_0x124642){return function(_0x598e25){if(_0x598e25){var _0x2d9538=typeof _0x124642['offset']===_0x05ea('0x1f')&&typeof _0x124642[_0x05ea('0x20')]===_0x05ea('0x1f');var _0x46706f=_0x598e25['count'];var _0x99ceae=_0x2d9538?0x0:_0x124642[_0x05ea('0x21')];var _0x1fad6f=_0x2d9538?_0x598e25['count']:_0x124642['offset']+_0x124642[_0x05ea('0x20')];var _0x57e5c7;if(_0x1fad6f>=_0x46706f){_0x1fad6f=_0x46706f;_0x57e5c7=0xc8;}else{_0x57e5c7=0xce;}_0x2919fd[_0x05ea('0x1d')](_0x57e5c7);return _0x2919fd[_0x05ea('0x22')]('Content-Range',_0x99ceae+'-'+_0x1fad6f+'/'+_0x46706f)[_0x05ea('0x1e')](_0x598e25);}return null;};}function saveUpdates(_0x3c69c3){return function(_0x4b784f){if(_0x4b784f){return _0x4b784f[_0x05ea('0x23')](_0x3c69c3)[_0x05ea('0x13')](function(_0x1dfd92){return _0x1dfd92;});}return null;};}function removeEntity(_0x52221a){return function(_0x3e5cb7){if(_0x3e5cb7){return _0x3e5cb7['destroy']()[_0x05ea('0x13')](function(){var _0x37066a=_0x3e5cb7['get']({'plain':!![]});if(_0x37066a[_0x05ea('0x24')]===_0x05ea('0x25'))return;var _0x321174=[{'name':_0x05ea('0x26'),'value':_0x05ea('0x27'),'ignore':!![]},{'name':'Agents','value':_0x05ea('0x28'),'ignore':![]},{'name':'Telephones','value':_0x05ea('0x29'),'ignore':![]}];var _0x1d0330=_(_0x321174)[_0x05ea('0x2a')](_0x05ea('0x2b'))['map']('value')[_0x05ea('0x2c')]();if(_[_0x05ea('0x2d')](_0x1d0330,_0x37066a['role'])){return;}var _0x57a31e=_[_0x05ea('0x2e')](_0x321174,[_0x05ea('0x2c'),_0x37066a[_0x05ea('0x24')]])[_0x05ea('0x2f')];return db[_0x05ea('0x30')][_0x05ea('0x31')]({'where':{'type':_0x57a31e,'resourceId':_0x37066a['id']}})['then'](function(){return _0x3e5cb7;});})['then'](function(){_0x52221a[_0x05ea('0x1d')](0xcc)[_0x05ea('0x1c')]();});}};}function handleEntityNotFound(_0x2244bd){return function(_0x131a45){if(!_0x131a45){_0x2244bd[_0x05ea('0x32')](0x194);}return _0x131a45;};}function handleError(_0x3511b9,_0x495400){_0x495400=_0x495400||0x1f4;return function(_0x2390ab){logger[_0x05ea('0x18')](_0x2390ab[_0x05ea('0x33')]);if(_0x2390ab['name']){delete _0x2390ab[_0x05ea('0x2f')];}_0x3511b9[_0x05ea('0x1d')](_0x495400)[_0x05ea('0x34')](_0x2390ab);};}exports['index']=function(_0x5633df,_0x1d196d){var _0xf535d0={},_0x216fcb={'count':0x0,'rows':[]};var _0xb7af80=_(db[_0x05ea('0x35')][_0x05ea('0x36')])[_0x05ea('0x37')](function(_0x2332d3){return{'name':_0x2332d3[_0x05ea('0x38')],'type':_0x2332d3[_0x05ea('0x39')][_0x05ea('0x3a')]};})[_0x05ea('0x2a')](function(_0x444905){return!_[_0x05ea('0x2d')]([_0x05ea('0x3b'),_0x05ea('0x3c')],_0x444905[_0x05ea('0x2f')]);})[_0x05ea('0x2c')]();_0xf535d0=qs[_0x05ea('0x3d')](_0xb7af80,_0x5633df);var _0x1b0eea={'where':_0xf535d0[_0x05ea('0x3e')]};return db['User'][_0x05ea('0x3f')](_0x1b0eea)[_0x05ea('0x13')](function(_0x1096fe){_0x216fcb['count']=_0x1096fe;if(_0x5633df[_0x05ea('0x40')]['includeAll']){_0xf535d0[_0x05ea('0x41')]=[{'all':!![]}];}if(_0x5633df[_0x05ea('0x40')]['userSetting']==='true'){_0xf535d0[_0x05ea('0x41')]=[{'model':db[_0x05ea('0x42')],'as':_0x05ea('0x43')}];}if(!_[_0x05ea('0x2d')](_0xf535d0['attributes'],'id')){_0xf535d0[_0x05ea('0x44')][_0x05ea('0x45')]('id');}return db[_0x05ea('0x35')][_0x05ea('0x46')](_0xf535d0);})['then'](function(_0x399423){_0x216fcb[_0x05ea('0x47')]=_0x399423;if(_0x5633df[_0x05ea('0x40')][_0x05ea('0x48')]===_0x05ea('0x49')){var _0xea5a2b=[];for(var _0x140636=0x0;_0x140636<_0x216fcb[_0x05ea('0x47')][_0x05ea('0x4a')];_0x140636++){_0xea5a2b['push'](get_open_tabs(_0x05ea('0x4b'),_0x216fcb[_0x05ea('0x47')][_0x140636][_0x05ea('0x4c')]));_0xea5a2b[_0x05ea('0x45')](get_open_tabs(_0x05ea('0x4d'),_0x216fcb['rows'][_0x140636][_0x05ea('0x4c')]));_0xea5a2b[_0x05ea('0x45')](get_open_tabs('fax',_0x216fcb[_0x05ea('0x47')][_0x140636][_0x05ea('0x4c')]));_0xea5a2b[_0x05ea('0x45')](get_open_tabs(_0x05ea('0x4e'),_0x216fcb[_0x05ea('0x47')][_0x140636]['dataValues']));_0xea5a2b['push'](get_open_tabs(_0x05ea('0x4f'),_0x216fcb[_0x05ea('0x47')][_0x140636][_0x05ea('0x4c')]));_0xea5a2b[_0x05ea('0x45')](get_open_tabs(_0x05ea('0x50'),_0x216fcb['rows'][_0x140636][_0x05ea('0x4c')]));}return BPromise[_0x05ea('0x51')](_0xea5a2b)[_0x05ea('0x13')](function(){return _0x216fcb;});}else{return _0x216fcb;}})[_0x05ea('0x13')](respondWithFilteredResult(_0x1d196d,_0xf535d0))['catch'](handleError(_0x1d196d,null));};exports['show']=function(_0x9393f3,_0x20a3e7){var _0x139e69={'raw':![],'where':{'id':_0x9393f3[_0x05ea('0x52')]['id']}},_0x1ce62d={};_0x1ce62d[_0x05ea('0x53')]=_[_0x05ea('0x54')](_[_0x05ea('0x55')](db[_0x05ea('0x35')][_0x05ea('0x36')]),[_0x05ea('0x3b'),_0x05ea('0x3c')]);_0x1ce62d[_0x05ea('0x40')]=_[_0x05ea('0x55')](_0x9393f3[_0x05ea('0x40')]);_0x1ce62d[_0x05ea('0x56')]=_['intersection'](_0x1ce62d[_0x05ea('0x53')],_0x1ce62d['query']);_0x139e69[_0x05ea('0x44')]=_[_0x05ea('0x57')](_0x1ce62d[_0x05ea('0x53')],qs[_0x05ea('0x58')](_0x9393f3[_0x05ea('0x40')][_0x05ea('0x58')]));_0x139e69[_0x05ea('0x44')]=_0x139e69[_0x05ea('0x44')][_0x05ea('0x4a')]?_0x139e69[_0x05ea('0x44')]:_0x1ce62d['model'];if(_0x9393f3[_0x05ea('0x40')][_0x05ea('0x59')]){_0x139e69[_0x05ea('0x41')]=[{'all':!![]}];}if(_0x9393f3['query'][_0x05ea('0x43')]==='true'){_0x139e69[_0x05ea('0x41')]=[{'model':db['UserSetting'],'as':_0x05ea('0x43')}];}_0x139e69=_[_0x05ea('0x5a')]({},_0x139e69,_0x9393f3[_0x05ea('0x5b')]);if(!_[_0x05ea('0x2d')](_0x139e69[_0x05ea('0x44')],'id')){_0x139e69[_0x05ea('0x44')][_0x05ea('0x45')]('id');}return db['User'][_0x05ea('0x2e')](_0x139e69)[_0x05ea('0x13')](handleEntityNotFound(_0x20a3e7,null))['then'](function(_0xbdfd46){var _0x391ba7=[];values=_0xbdfd46;if(_0x9393f3[_0x05ea('0x40')][_0x05ea('0x48')]===_0x05ea('0x49')){_0x391ba7[_0x05ea('0x45')](get_open_tabs('chat',_0xbdfd46['dataValues']));_0x391ba7[_0x05ea('0x45')](get_open_tabs('sms',_0xbdfd46[_0x05ea('0x4c')]));_0x391ba7[_0x05ea('0x45')](get_open_tabs('openchannel',_0xbdfd46[_0x05ea('0x4c')]));_0x391ba7['push'](get_open_tabs(_0x05ea('0x50'),_0xbdfd46['dataValues']));_0x391ba7[_0x05ea('0x45')](get_open_tabs(_0x05ea('0x5c'),_0xbdfd46[_0x05ea('0x4c')]));_0x391ba7['push'](get_open_tabs(_0x05ea('0x4e'),_0xbdfd46[_0x05ea('0x4c')]));return BPromise[_0x05ea('0x51')](_0x391ba7);}else{return values;}})['then'](function(){return values;})['then'](respondWithResult(_0x20a3e7,null))[_0x05ea('0x1b')](handleError(_0x20a3e7,null));};exports[_0x05ea('0x23')]=function(_0x4beb34,_0x4a4bc8){if(_0x4beb34['body']['id']){delete _0x4beb34[_0x05ea('0x5d')]['id'];}delete _0x4beb34[_0x05ea('0x5d')][_0x05ea('0x24')];return db[_0x05ea('0x35')][_0x05ea('0x2e')]({'where':{'id':_0x4beb34[_0x05ea('0x52')]['id']}})['then'](handleEntityNotFound(_0x4a4bc8,null))[_0x05ea('0x13')](saveUpdates(_0x4beb34['body'],null))[_0x05ea('0x13')](respondWithResult(_0x4a4bc8,null))[_0x05ea('0x1b')](handleError(_0x4a4bc8,null));};exports[_0x05ea('0x5e')]=function(_0x890072,_0x1a45b5){return db['User'][_0x05ea('0x5e')]()['then'](respondWithResult(_0x1a45b5,null))[_0x05ea('0x1b')](handleError(_0x1a45b5,null));};exports[_0x05ea('0x5f')]=function(_0x3a6bf1,_0x4c9b77){return db[_0x05ea('0x35')][_0x05ea('0x2e')]({'where':{'id':_0x3a6bf1[_0x05ea('0x52')]['id']}})[_0x05ea('0x13')](handleEntityNotFound(_0x4c9b77,null))['then'](function(_0x31ac23){if(_0x31ac23){return _0x31ac23['addContacts'](_0x3a6bf1[_0x05ea('0x5d')][_0x05ea('0x60')],_[_0x05ea('0x61')](_0x3a6bf1['body'],[_0x05ea('0x60'),'id'])||{});}})[_0x05ea('0x13')](respondWithResult(_0x4c9b77,null))['catch'](handleError(_0x4c9b77,null));};function validateUser(_0x241320){return new BPromise(function(_0x40b1ce,_0x7455e7){if(_0x241320[_0x05ea('0x62')])return _0x40b1ce(_0x241320);return db['Setting'][_0x05ea('0x63')](0x1)['then'](function(_0x541648){if(_0x541648[_0x05ea('0x64')])authService['validatePasswordPattern'](_0x241320[_0x05ea('0x3b')]);db['User']['max'](_0x05ea('0x62'))['then'](function(_0x447783){if(_[_0x05ea('0x65')](_0x447783)){_0x241320[_0x05ea('0x62')]=_0x541648[_0x05ea('0x66')]||0x1;return;}if(_[_0x05ea('0x65')](_0x541648[_0x05ea('0x66')])||_0x541648[_0x05ea('0x66')]===_0x447783){_0x241320['internal']=_0x447783+0x1;return;}if(_0x541648[_0x05ea('0x66')]>_0x447783){_0x241320[_0x05ea('0x62')]=_0x541648[_0x05ea('0x66')];return;}return db[_0x05ea('0x67')][_0x05ea('0x40')](_0x05ea('0x68'),{'type':db['sequelize'][_0x05ea('0x69')][_0x05ea('0x6a')]})[_0x05ea('0x13')](function(_0x558142){if(_0x558142&&_0x558142[_0x05ea('0x4a')]){for(var _0x5a0be5=0x0,_0x5adbe0=_0x558142[_0x05ea('0x4a')];_0x5a0be5<_0x5adbe0&&_['isNil'](_0x241320[_0x05ea('0x62')]);_0x5a0be5++){if(_0x541648[_0x05ea('0x66')]<=_0x558142[_0x5a0be5][_0x05ea('0x6b')]){_0x241320[_0x05ea('0x62')]=_0x558142[_0x5a0be5]['from'];}else if(_0x541648['min_internal']>_0x558142[_0x5a0be5][_0x05ea('0x6b')]&&_0x541648['min_internal']<=_0x558142[_0x5a0be5]['to']){_0x241320['internal']=_0x541648[_0x05ea('0x66')];}}}if(_[_0x05ea('0x65')](_0x241320[_0x05ea('0x62')])){_0x241320[_0x05ea('0x62')]=_0x447783+0x1;}return _0x40b1ce(_0x241320);});});})['catch'](function(_0x4cd96a){_0x7455e7(_0x4cd96a);});});}function updateUser(_0x367f3c){return new BPromise(function(_0x43940f,_0x3b21e1){try{if(_0x367f3c[_0x05ea('0x6c')]){_0x367f3c[_0x05ea('0x6d')]=_0x367f3c['internal'];_0x367f3c[_0x05ea('0x6e')]={'mailbox':_0x367f3c[_0x05ea('0x62')],'password':_0x367f3c['password'],'fullname':_0x367f3c['fullname'],'email':_0x367f3c[_0x05ea('0x6f')]};}if(_0x367f3c[_0x05ea('0x24')]===_0x05ea('0x28')){if(!_0x367f3c['permissions'])_0x367f3c['permissions']=[_0x05ea('0x70'),_0x05ea('0x71'),_0x05ea('0x72'),_0x05ea('0x73'),_0x05ea('0x74'),'104',_0x05ea('0x75'),_0x05ea('0x76'),_0x05ea('0x77'),'108',_0x05ea('0x78'),_0x05ea('0x79'),_0x05ea('0x7a'),_0x05ea('0x7b'),_0x05ea('0x7c')];}_0x43940f(_0x367f3c);}catch(_0x3bd582){_0x3b21e1(_0x3bd582);}});}exports[_0x05ea('0x7d')]=function(_0xa78e5f,_0x542429){if(_0xa78e5f[_0x05ea('0x27')][_0x05ea('0x24')]===_0x05ea('0x28'))throw new Error(_0x05ea('0x7e'));if(_0xa78e5f[_0x05ea('0x5d')][_0x05ea('0x24')]===_0x05ea('0x27')&&_0xa78e5f[_0x05ea('0x27')]['role']!==_0x05ea('0x25')){throw new Error('Unauthorized.\x20You\x20must\x20be\x20an\x20administrator\x20in\x20order\x20to\x20create\x20an\x20user');}if(_0xa78e5f[_0x05ea('0x5d')]['role']===_0x05ea('0x25')&&_0xa78e5f['user'][_0x05ea('0x24')]!==_0x05ea('0x25')){throw new Error(_0x05ea('0x7f'));}return licenseUtil[_0x05ea('0x80')]([_0xa78e5f[_0x05ea('0x5d')]])['then'](function(){return validateUser(_0xa78e5f['body']);})[_0x05ea('0x13')](function(_0x5cc1c9){return updateUser(_0x5cc1c9)[_0x05ea('0x13')](function(_0x5788f6){if(_0x5788f6[_0x05ea('0x24')]===_0x05ea('0x25')){_0x5788f6['settingsEnabled']=_0xa78e5f[_0x05ea('0x27')][_0x05ea('0x81')];delete _0x5788f6[_0x05ea('0x82')];}return _0x5788f6;});})[_0x05ea('0x13')](function(_0x45bd3e){return db[_0x05ea('0x35')][_0x05ea('0x7d')](_0x45bd3e,{'include':[{'model':db[_0x05ea('0x6e')],'as':'VoiceMail'}]});})['then'](function(_0x372689){if(_0xa78e5f[_0x05ea('0x5d')][_0x05ea('0x24')]===_0x05ea('0x27'))return _0x372689;if(_0xa78e5f[_0x05ea('0x27')][_0x05ea('0x24')]!==_0x05ea('0x27'))return _0x372689;return db[_0x05ea('0x83')][_0x05ea('0x2e')]({'where':{'name':_0x372689[_0x05ea('0x24')]==='agent'?_0x05ea('0x84'):_0x05ea('0x85'),'userProfileId':_0xa78e5f[_0x05ea('0x27')][_0x05ea('0x82')]},'raw':!![]})[_0x05ea('0x13')](function(_0x4a271a){if(!_0x4a271a||_0x4a271a[_0x05ea('0x86')]!=0x0)return _0x372689;return db[_0x05ea('0x30')][_0x05ea('0x7d')]({'name':_0x372689['name'],'resourceId':_0x372689['id'],'type':_0x4a271a[_0x05ea('0x2f')],'sectionId':_0x4a271a['id']},{})['then'](function(){return _0x372689;});})['catch'](function(_0x5145b0){logger[_0x05ea('0x18')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x5145b0);throw _0x5145b0;});})[_0x05ea('0x13')](respondWithResult(_0x542429,0xc9))[_0x05ea('0x1b')](handleError(_0x542429,null));};exports[_0x05ea('0x87')]=function(_0x230e6e,_0x42ab37){var _0x430cf5=_0x230e6e[_0x05ea('0x5d')];var _0x503699=[];if(_0x230e6e[_0x05ea('0x27')][_0x05ea('0x24')]===_0x05ea('0x28'))throw new Error(_0x05ea('0x7e'));if(_[_0x05ea('0x88')](_0x430cf5,[_0x05ea('0x24'),_0x05ea('0x27')])&&_0x230e6e[_0x05ea('0x27')]['role']!==_0x05ea('0x25')){throw new Error(_0x05ea('0x89'));}if(_[_0x05ea('0x88')](_0x430cf5,[_0x05ea('0x24'),_0x05ea('0x25')])&&_0x230e6e[_0x05ea('0x27')]['role']!==_0x05ea('0x25')){throw new Error(_0x05ea('0x8a'));}return licenseUtil[_0x05ea('0x80')](_0x430cf5)['then'](function(){return validateUser(_0x430cf5[0x0]);})[_0x05ea('0x13')](function(){for(var _0x388f2e=0x1;_0x388f2e<_0x430cf5[_0x05ea('0x4a')];_0x388f2e++){var _0x1d3961=_0x430cf5[_0x388f2e-0x1][_0x05ea('0x62')];if(!_0x430cf5[_0x388f2e][_0x05ea('0x62')])_0x430cf5[_0x388f2e][_0x05ea('0x62')]=_0x1d3961+0x1;_0x503699['push'](validateUser(_0x430cf5[_0x388f2e]));}return BPromise['all'](_0x503699);})[_0x05ea('0x13')](function(){_0x503699=[];for(var _0x63f4dd=0x0;_0x63f4dd<_0x430cf5[_0x05ea('0x4a')];_0x63f4dd++){_0x503699[_0x05ea('0x45')](updateUser(_0x430cf5[_0x63f4dd]));}return BPromise[_0x05ea('0x51')](_0x503699);})['then'](function(){return BPromise[_0x05ea('0x8b')](_0x430cf5,function(_0x330f0c){return db[_0x05ea('0x35')][_0x05ea('0x7d')](_0x330f0c,{'include':[{'model':db[_0x05ea('0x6e')],'as':_0x05ea('0x6e')}]})[_0x05ea('0x13')](function(_0x59b031){_0x330f0c['id']=_0x59b031['id'];return _0x330f0c;});});})['then'](function(_0x2ed06b){if(_0x230e6e['body'][_0x05ea('0x24')]===_0x05ea('0x27'))return _0x2ed06b;if(_0x230e6e['user'][_0x05ea('0x24')]!==_0x05ea('0x27'))return _0x2ed06b;var _0x21a7bb=_['some'](_0x2ed06b,function(_0x939fc8){return _0x939fc8[_0x05ea('0x24')]===_0x05ea('0x28')||_0x939fc8[_0x05ea('0x24')]===_0x05ea('0x29');});if(!_0x21a7bb)return _0x2ed06b;return db['UserProfileSection']['findAll']({'where':{'name':{'$or':[_0x05ea('0x84'),_0x05ea('0x85')]},'userProfileId':_0x230e6e[_0x05ea('0x27')][_0x05ea('0x82')]},'raw':!![]})[_0x05ea('0x13')](function(_0x2a9eee){if(_['isEmpty'](_0x2a9eee)||!_[_0x05ea('0x88')](_0x2a9eee,['autoAssociation',0x0]))return _0x2ed06b;_0x503699=[];var _0x46922b=_(_0x2a9eee)[_0x05ea('0x37')](function(_0x5906b9){if(_0x5906b9[_0x05ea('0x86')]===0x1)return;return _0x5906b9[_0x05ea('0x2f')]===_0x05ea('0x84')?_0x05ea('0x28'):_0x05ea('0x29');})[_0x05ea('0x8c')]()[_0x05ea('0x2c')]();for(var _0x2c0de9=0x0;_0x2c0de9<_0x2ed06b[_0x05ea('0x4a')];_0x2c0de9++){if(!_[_0x05ea('0x2d')](_0x46922b,_0x2ed06b[_0x2c0de9]['role']))return;var _0x1db3f7=_0x2ed06b[_0x2c0de9][_0x05ea('0x24')]===_0x05ea('0x28')?'Agents':_0x05ea('0x85');_0x503699[_0x05ea('0x45')](db[_0x05ea('0x30')]['create']({'name':_0x2ed06b[_0x2c0de9][_0x05ea('0x2f')],'resourceId':_0x2ed06b[_0x2c0de9]['id'],'type':_0x1db3f7,'sectionId':_[_0x05ea('0x2e')](_0x2a9eee,[_0x05ea('0x2f'),_0x1db3f7])['id']},{}));}return BPromise[_0x05ea('0x51')](_0x503699);});})[_0x05ea('0x13')](respondWithResult(_0x42ab37,0xc9))[_0x05ea('0x1b')](handleError(_0x42ab37,null));};exports['changePassword']=function(_0x4546f8,_0x1daa88){if(_0x4546f8[_0x05ea('0x5d')]['id']){delete _0x4546f8[_0x05ea('0x5d')]['id'];}return db['User'][_0x05ea('0x2e')]({'where':{'id':_0x4546f8[_0x05ea('0x52')]['id']}})[_0x05ea('0x13')](function(_0x59a3e3){if(!_0x59a3e3)return null;if(_0x59a3e3['id']===_0x4546f8['user']['id']){if(!_0x4546f8['body'][_0x05ea('0x8d')]||!_0x4546f8[_0x05ea('0x5d')][_0x05ea('0x8e')]){throw new db[(_0x05ea('0x8f'))][(_0x05ea('0x90'))](_0x05ea('0x91'));}if(!_0x59a3e3[_0x05ea('0x92')](_0x4546f8['body']['oldPassword'])){throw new db[(_0x05ea('0x8f'))]['ValidationError'](_0x05ea('0x93'));}if(_0x4546f8[_0x05ea('0x5d')]['oldPassword']===_0x4546f8['body'][_0x05ea('0x8e')]){throw new db[(_0x05ea('0x8f'))][(_0x05ea('0x90'))](_0x05ea('0x94'));}}else if(_0x4546f8[_0x05ea('0x27')][_0x05ea('0x24')]===_0x05ea('0x25')){if(!_0x4546f8[_0x05ea('0x5d')][_0x05ea('0x8e')]){throw new db[(_0x05ea('0x8f'))][(_0x05ea('0x90'))]('Invalid\x20body\x20format.\x20Use\x20newPassword');}}else if(_0x4546f8[_0x05ea('0x27')][_0x05ea('0x24')]===_0x05ea('0x27')){if(!_0x4546f8[_0x05ea('0x5d')][_0x05ea('0x8e')]){throw new db[(_0x05ea('0x8f'))][(_0x05ea('0x90'))](_0x05ea('0x95'));}if(_0x59a3e3['role']!==_0x05ea('0x28')){throw new db[(_0x05ea('0x8f'))][(_0x05ea('0x90'))](_0x05ea('0x7e'));}}else{throw new db['Sequelize'][(_0x05ea('0x90'))](_0x05ea('0x7e'));}return _0x59a3e3;})[_0x05ea('0x13')](handleEntityNotFound(_0x1daa88,null))[_0x05ea('0x13')](function(_0x5947f8){return db['Setting'][_0x05ea('0x96')]({'attributes':['id','securePassword',_0x05ea('0x97'),_0x05ea('0x98')]})[_0x05ea('0x13')](function(_0x40d140){if(_0x40d140[_0x05ea('0x64')])authService[_0x05ea('0x99')](_0x4546f8['body']['newPassword']);if(!_0x40d140['enforcePasswordHistory']||!_0x5947f8[_0x05ea('0x9a')])return _0x5947f8;authService['validatePasswordHistory'](_0x4546f8[_0x05ea('0x5d')]['newPassword'],_0x5947f8[_0x05ea('0x9a')],_0x40d140['passwordHistoryLimit']);return _0x5947f8;})['then'](saveUpdates({'password':_0x4546f8[_0x05ea('0x5d')][_0x05ea('0x8e')],'passwordResetAt':_0x4546f8[_0x05ea('0x27')]['id']==_0x4546f8['params']['id']?moment():null,'previousPasswords':authService['updatePasswordsHistory'](_0x4546f8[_0x05ea('0x5d')][_0x05ea('0x8e')],_0x5947f8[_0x05ea('0x9a')])},null));})[_0x05ea('0x13')](respondWithResult(_0x1daa88,null))['catch'](handleError(_0x1daa88,null));};exports['addQueues']=function(_0xe6b7da,_0x52716f){var _0x37d395=_0xe6b7da[_0x05ea('0x5d')][_0x05ea('0x9b')];return db[_0x05ea('0x35')][_0x05ea('0x2e')]({'where':{'id':_0xe6b7da[_0x05ea('0x52')]['id']},'attributes':['id',_0x05ea('0x2f'),_0x05ea('0x24'),'online',_0x05ea('0x9c'),_0x05ea('0x9d'),_0x05ea('0x9e')]})['then'](handleEntityNotFound(_0x52716f,null))[_0x05ea('0x13')](function(_0x2635e3){if(_0x2635e3){if(!utils['isValidChannel'](_0x37d395)){throw new db['Sequelize']['ValidationError'](_0x05ea('0x9f'));}return _0x2635e3['add'+_[_0x05ea('0xa0')](_0x37d395['toLowerCase']())+_0x05ea('0xa1')](_0xe6b7da[_0x05ea('0x5d')]['ids'],{'penalty':_0xe6b7da[_0x05ea('0x5d')][_0x05ea('0xa2')]||0x0})[_0x05ea('0xa3')](function(_0x1af605){for(var _0x4bc7eb=0x0;_0x4bc7eb<_0xe6b7da[_0x05ea('0x5d')]['ids'][_0x05ea('0x4a')];_0x4bc7eb+=0x1){var _0x3fd10e={'UserId':Number(_0xe6b7da[_0x05ea('0x52')]['id'])};_0x3fd10e[_[_0x05ea('0xa0')](_0x37d395[_0x05ea('0xa4')]())+_0x05ea('0xa5')]=Number(_0xe6b7da[_0x05ea('0x5d')][_0x05ea('0x60')][_0x4bc7eb]);socket[_0x05ea('0xa6')](_0x05ea('0x27')+_[_0x05ea('0xa0')](_0x37d395[_0x05ea('0xa4')]())+_0x05ea('0xa7'),_0x3fd10e);}return _0x1af605;})[_0x05ea('0x13')](function(){if(_0x37d395===_0x05ea('0xa8')){return db[_0x05ea('0xa9')][_0x05ea('0x46')]({'where':{'id':_0xe6b7da[_0x05ea('0x5d')][_0x05ea('0x60')]||[]},'raw':!![],'attributes':['id','name']});}})[_0x05ea('0x13')](function(_0x3f094b){var _0x2b3702=_0x2635e3[_0x05ea('0xaa')]({'plain':!![]});var _0x2cadb2=[];if(_0x37d395===_0x05ea('0xa8')&&_0x2b3702[_0x05ea('0x24')]===_0x05ea('0x28')&&_0x2b3702[_0x05ea('0xab')]){for(var _0x54a625=0x0;_0x54a625<_0x3f094b['length'];_0x54a625+=0x1){_0x2cadb2[_0x05ea('0x45')]({'membername':_0x2b3702[_0x05ea('0x2f')],'UserId':_0x2b3702['id'],'queue_name':_0x3f094b[_0x54a625][_0x05ea('0x2f')],'VoiceQueueId':_0x3f094b[_0x54a625]['id'],'interface':_['isNil'](_0x2b3702[_0x05ea('0x9e')])?util['format'](_0x05ea('0xac'),_0x2b3702[_0x05ea('0x2f')]):_0x2b3702[_0x05ea('0x9e')],'paused':_0x2b3702[_0x05ea('0x9d')]||![],'penalty':_0xe6b7da[_0x05ea('0x5d')][_0x05ea('0xa2')]||0x0});}return BPromise['each'](_0x2cadb2,function(_0x1b7fdc){return db[_0x05ea('0xad')]['upsert'](_0x1b7fdc);});}return _0x2635e3;});}})[_0x05ea('0x13')](respondWithStatusCode(_0x52716f,null))[_0x05ea('0x1b')](handleError(_0x52716f,null));};exports[_0x05ea('0xae')]=function(_0x44dd1f,_0x234bed){var _0x20a954,_0x264049;return db[_0x05ea('0x35')][_0x05ea('0x2e')]({'where':{'id':_0x44dd1f[_0x05ea('0x52')]['id']},'attributes':['id',_0x05ea('0x2f'),_0x05ea('0x24')]})[_0x05ea('0x13')](handleEntityNotFound(_0x234bed,null))[_0x05ea('0x13')](function(_0x1fa08b){if(_0x1fa08b){_0x20a954=_0x1fa08b;if(!_0x44dd1f[_0x05ea('0x40')][_0x05ea('0x9b')]||!utils[_0x05ea('0xaf')](_0x44dd1f['query'][_0x05ea('0x9b')])){throw new db['Sequelize']['ValidationError'](_0x05ea('0x9f'));}return _0x1fa08b[_0x05ea('0xb0')+_[_0x05ea('0xa0')](_0x44dd1f[_0x05ea('0x40')][_0x05ea('0x9b')]['toLowerCase']())+_0x05ea('0xa1')](_0x44dd1f[_0x05ea('0x40')][_0x05ea('0x60')]);}})[_0x05ea('0x13')](function(_0x3f1fea){if(_['isArray'](_0x44dd1f['query'][_0x05ea('0x60')])){for(var _0x58447c=0x0;_0x58447c<_0x44dd1f['query'][_0x05ea('0x60')][_0x05ea('0x4a')];_0x58447c+=0x1){_0x264049={'UserId':Number(_0x44dd1f[_0x05ea('0x52')]['id'])};_0x264049[_[_0x05ea('0xa0')](_0x44dd1f[_0x05ea('0x40')][_0x05ea('0x9b')]['toLowerCase']())+_0x05ea('0xa5')]=Number(_0x44dd1f['query'][_0x05ea('0x60')][_0x58447c]);socket['emit'](_0x05ea('0x27')+_['capitalize'](_0x44dd1f[_0x05ea('0x40')]['channel'][_0x05ea('0xa4')]())+_0x05ea('0xb1'),_0x264049);}}else{_0x264049={'UserId':Number(_0x44dd1f[_0x05ea('0x52')]['id'])};_0x264049[_[_0x05ea('0xa0')](_0x44dd1f['query'][_0x05ea('0x9b')][_0x05ea('0xa4')]())+_0x05ea('0xa5')]=Number(_0x44dd1f[_0x05ea('0x40')][_0x05ea('0x60')]);socket[_0x05ea('0xa6')](_0x05ea('0x27')+_[_0x05ea('0xa0')](_0x44dd1f[_0x05ea('0x40')][_0x05ea('0x9b')]['toLowerCase']())+_0x05ea('0xb1'),_0x264049);}return _0x3f1fea;})[_0x05ea('0x13')](function(){if(_0x44dd1f[_0x05ea('0x40')][_0x05ea('0x9b')]==='voice'){return db[_0x05ea('0xad')][_0x05ea('0x31')]({'where':{'UserId':_0x44dd1f['params']['id'],'VoiceQueueId':_0x44dd1f[_0x05ea('0x40')]['ids']},'individualHooks':!![]})[_0x05ea('0x13')](function(){return _0x20a954;});}return _0x20a954;})[_0x05ea('0x13')](respondWithStatusCode(_0x234bed,null))[_0x05ea('0x1b')](handleError(_0x234bed,null));};exports[_0x05ea('0xb2')]=function(_0x40e3ac,_0x29011c){_0x40e3ac[_0x05ea('0x5d')][_0x05ea('0xb3')]=_0x40e3ac['file'][_0x05ea('0xb4')];return db[_0x05ea('0x35')][_0x05ea('0x2e')]({'where':{'id':_0x40e3ac[_0x05ea('0x52')]['id']}})[_0x05ea('0x13')](handleEntityNotFound(_0x29011c,null))['then'](saveUpdates(_0x40e3ac[_0x05ea('0x5d')],null))[_0x05ea('0x13')](respondWithResult(_0x29011c,null))[_0x05ea('0x1b')](handleError(_0x29011c,null));};exports['getAvatar']=function(_0x66a7c0,_0x3c6616){var _0x17044c=path['join'](config[_0x05ea('0xb5')],_0x05ea('0xb6'));return db[_0x05ea('0x35')]['find']({'where':{'id':_0x66a7c0['params']['id']},'attributes':['id',_0x05ea('0xb3')],'raw':!![]})[_0x05ea('0x13')](handleEntityNotFound(_0x3c6616,null))[_0x05ea('0x13')](function(_0x5c4165){if(_0x5c4165){if(_['isNil'](_0x5c4165[_0x05ea('0xb3')])){return _0x3c6616[_0x05ea('0xb7')](_0x17044c);}else{if(!fs[_0x05ea('0xb8')](path[_0x05ea('0xb9')](config[_0x05ea('0xb5')],_0x05ea('0xba'),_0x5c4165[_0x05ea('0xb3')]))){return _0x3c6616['download'](_0x17044c);}return _0x3c6616['download'](path['join'](config[_0x05ea('0xb5')],_0x05ea('0xba'),_0x5c4165['userpic']));}}})[_0x05ea('0x1b')](handleError(_0x3c6616,null));};exports[_0x05ea('0xbb')]=function(_0x4f2124,_0x1d6c18){return db[_0x05ea('0x35')][_0x05ea('0x2e')]({'where':{'id':_0x4f2124[_0x05ea('0x52')]['id']},'attributes':['id']})['then'](handleEntityNotFound(_0x1d6c18,null))[_0x05ea('0x13')](function(_0x3c679f){var _0x133eb8=[];values=_0x3c679f[_0x05ea('0x4c')];_0x133eb8['push'](get_open_tabs(_0x05ea('0x4b'),_0x3c679f[_0x05ea('0x4c')]));_0x133eb8['push'](get_open_tabs(_0x05ea('0x4d'),_0x3c679f['dataValues']));_0x133eb8[_0x05ea('0x45')](get_open_tabs(_0x05ea('0x4f'),_0x3c679f[_0x05ea('0x4c')]));_0x133eb8[_0x05ea('0x45')](get_open_tabs(_0x05ea('0x50'),_0x3c679f[_0x05ea('0x4c')]));_0x133eb8['push'](get_open_tabs('fax',_0x3c679f[_0x05ea('0x4c')]));_0x133eb8[_0x05ea('0x45')](get_open_tabs(_0x05ea('0x4e'),_0x3c679f[_0x05ea('0x4c')]));return BPromise[_0x05ea('0x51')](_0x133eb8);})[_0x05ea('0x13')](function(_0x5ef7a7){if(_0x5ef7a7){var _0x288f33=_['map'](values[_0x05ea('0xbc')],function(_0x54cda2){return{'channel':_0x05ea('0xbd'),'id':_0x54cda2['id'],'createdAt':_0x54cda2['createdAt']};});var _0x309b68=_[_0x05ea('0x37')](values[_0x05ea('0xbe')],function(_0x2261cb){return{'channel':_0x05ea('0xbf'),'id':_0x2261cb['id'],'createdAt':_0x2261cb[_0x05ea('0xc0')]};});var _0x3f9188=_[_0x05ea('0x37')](values[_0x05ea('0xc1')],function(_0x423ecb){return{'channel':'OPENCHANNEL','id':_0x423ecb['id'],'createdAt':_0x423ecb[_0x05ea('0xc0')]};});var _0x4d4a53=_[_0x05ea('0x37')](values[_0x05ea('0xc2')],function(_0x107c26){return{'channel':_0x05ea('0xc3'),'id':_0x107c26['id'],'createdAt':_0x107c26[_0x05ea('0xc0')]};});var _0x4f7050=_['map'](values[_0x05ea('0xc4')],function(_0x3f3d39){return{'channel':'SMS','id':_0x3f3d39['id'],'createdAt':_0x3f3d39[_0x05ea('0xc0')]};});var _0x4d3fb8=_['map'](values['WhatsappOpenTabs'],function(_0x216bfd){return{'channel':_0x05ea('0xc5'),'id':_0x216bfd['id'],'createdAt':_0x216bfd[_0x05ea('0xc0')]};});var _0x444417=_[_0x05ea('0xc6')](_0x288f33,_0x309b68,_0x3f9188,_0x4d4a53,_0x4f7050,_0x4d3fb8);var _0x43d5ed={'count':_0x444417[_0x05ea('0x4a')],'rows':_0x444417};return _0x43d5ed;}else return null;})[_0x05ea('0x13')](respondWithResult(_0x1d6c18,null))['catch'](handleError(_0x1d6c18,null));};exports[_0x05ea('0xc7')]=function(_0x1aef7c,_0x16911c){var _0x5b63db={};var _0x55ba0d={};var _0x8f1a33;var _0x210f82;return db['User'][_0x05ea('0x96')]({'where':{'id':_0x1aef7c[_0x05ea('0x52')]['id']}})[_0x05ea('0x13')](handleEntityNotFound(_0x16911c,null))['then'](function(_0x19523c){if(_0x19523c){_0x8f1a33=_0x19523c;_0x55ba0d[_0x05ea('0x53')]=_[_0x05ea('0x55')](db['CmContact']['rawAttributes']);_0x55ba0d[_0x05ea('0x40')]=_[_0x05ea('0x55')](_0x1aef7c[_0x05ea('0x40')]);_0x55ba0d[_0x05ea('0x56')]=_[_0x05ea('0x57')](_0x55ba0d['model'],_0x55ba0d[_0x05ea('0x40')]);_0x5b63db['attributes']=_[_0x05ea('0x57')](_0x55ba0d[_0x05ea('0x53')],qs['fields'](_0x1aef7c[_0x05ea('0x40')][_0x05ea('0x58')]));_0x5b63db[_0x05ea('0x44')]=_0x5b63db[_0x05ea('0x44')][_0x05ea('0x4a')]?_0x5b63db[_0x05ea('0x44')]:_0x55ba0d[_0x05ea('0x53')];_0x5b63db['order']=qs['sort'](_0x1aef7c[_0x05ea('0x40')]['sort']);_0x5b63db[_0x05ea('0x3e')]=qs[_0x05ea('0x56')](_['pick'](_0x1aef7c[_0x05ea('0x40')],_0x55ba0d[_0x05ea('0x56')]));if(_0x1aef7c[_0x05ea('0x40')]['filter']){_0x5b63db['where']=_[_0x05ea('0x5a')](_0x5b63db[_0x05ea('0x3e')],{'$or':_[_0x05ea('0x37')](_0x5b63db[_0x05ea('0x44')],function(_0x4ff057){var _0x51ea80={};_0x51ea80[_0x4ff057]={'$like':'%'+_0x1aef7c[_0x05ea('0x40')][_0x05ea('0x2a')]+'%'};return _0x51ea80;})});}_0x5b63db=_['merge']({},_0x5b63db,_0x1aef7c[_0x05ea('0x5b')]);return _0x8f1a33[_0x05ea('0xc7')](_0x5b63db);}})[_0x05ea('0x13')](function(_0x22f499){if(_0x22f499){_0x210f82=_0x22f499[_0x05ea('0x4a')];if(_0x1aef7c['query'][_0x05ea('0xc8')](_0x05ea('0x59'))){_0x5b63db[_0x05ea('0x41')]=[{'model':db[_0x05ea('0xc9')],'as':_0x05ea('0xca'),'required':![]},{'model':db[_0x05ea('0xcb')],'as':_0x05ea('0xcc'),'attributes':['id','name',_0x05ea('0xcd')],'where':_0x1aef7c['query'][_0x05ea('0xce')]?{'id':_0x1aef7c[_0x05ea('0x40')][_0x05ea('0xce')]}:undefined,'required':_0x1aef7c['query']['tag']?!![]:![]}];}if(!_0x1aef7c[_0x05ea('0x40')][_0x05ea('0xc8')](_0x05ea('0xcf'))){_0x5b63db[_0x05ea('0x20')]=qs['limit'](_0x1aef7c[_0x05ea('0x40')]['limit']);_0x5b63db[_0x05ea('0x21')]=qs[_0x05ea('0x21')](_0x1aef7c['query'][_0x05ea('0x21')]);}return _0x8f1a33[_0x05ea('0xc7')](_0x5b63db);}})['then'](function(_0x543c7c){if(_0x543c7c){return _0x543c7c?{'count':_0x210f82,'rows':_0x543c7c}:null;}})[_0x05ea('0x13')](respondWithResult(_0x16911c,null))[_0x05ea('0x1b')](handleError(_0x16911c,null));};exports[_0x05ea('0xd0')]=function(_0x556342,_0x590836){var _0xdb9417;var _0x1331e9={};var _0x2d5815;return db[_0x05ea('0x35')][_0x05ea('0x96')]({'where':{'id':_0x556342[_0x05ea('0x52')]['id']},'attributes':['id','name',_0x05ea('0x24')]})[_0x05ea('0x13')](handleEntityNotFound(_0x590836,null))[_0x05ea('0x13')](function(_0x433905){if(!utils['isValidChannel'](_0x556342['query'][_0x05ea('0x9b')])){throw new db['Sequelize'][(_0x05ea('0x90'))]('Unknown\x20channel');}_0xdb9417=_0x433905;var _0x2d6b4e={};_0x2d6b4e[_0x05ea('0x53')]=_[_0x05ea('0x55')](db[_[_0x05ea('0xa0')](_0x556342[_0x05ea('0x40')][_0x05ea('0x9b')])+_0x05ea('0xd1')][_0x05ea('0x36')]);_0x2d6b4e[_0x05ea('0x40')]=_[_0x05ea('0x55')](_0x556342[_0x05ea('0x40')]);_0x2d6b4e['filters']=_['intersection'](_0x2d6b4e[_0x05ea('0x53')],_0x2d6b4e[_0x05ea('0x40')]);_0x1331e9[_0x05ea('0x44')]=_['intersection'](_0x2d6b4e[_0x05ea('0x53')],qs[_0x05ea('0x58')](_0x556342[_0x05ea('0x40')][_0x05ea('0x58')]));_0x1331e9[_0x05ea('0x44')]=_0x1331e9[_0x05ea('0x44')][_0x05ea('0x4a')]?_0x1331e9[_0x05ea('0x44')]:_0x2d6b4e[_0x05ea('0x53')];_0x1331e9[_0x05ea('0xd2')]=qs['sort'](_0x556342['query'][_0x05ea('0xd3')]);_0x1331e9[_0x05ea('0x3e')]=qs[_0x05ea('0x56')](_[_0x05ea('0xd4')](_0x556342[_0x05ea('0x40')],_0x2d6b4e[_0x05ea('0x56')]));if(_0x556342[_0x05ea('0x40')][_0x05ea('0x2a')]){_0x1331e9[_0x05ea('0x3e')]=_['merge'](_0x1331e9['where'],{'$or':_[_0x05ea('0x37')](_0x1331e9['attributes'],function(_0x16e613){var _0x236954={};_0x236954[_0x16e613]={'$like':'%'+_0x556342[_0x05ea('0x40')][_0x05ea('0x2a')]+'%'};return _0x236954;})});}_0x1331e9=_['merge']({},_0x1331e9,_0x556342[_0x05ea('0x5b')]);switch(_0xdb9417['role']){case _0x05ea('0x25'):return db[_['capitalize'](_0x556342[_0x05ea('0x40')][_0x05ea('0x9b')])+_0x05ea('0xd1')][_0x05ea('0x46')](_0x1331e9);case _0x05ea('0x27'):case'agent':return _0xdb9417['get'+_[_0x05ea('0xa0')](_0x556342['query']['channel'])+'Queues'](_0x1331e9);default:throw new db[(_0x05ea('0x8f'))]['ValidationError'](_0x05ea('0xd5'));}})['then'](function(_0x3b9746){_0x2d5815=_0x3b9746['length'];if(!_0x556342[_0x05ea('0x40')][_0x05ea('0xc8')](_0x05ea('0xcf'))){_0x1331e9[_0x05ea('0x20')]=qs[_0x05ea('0x20')](_0x556342['query'][_0x05ea('0x20')]);_0x1331e9[_0x05ea('0x21')]=qs[_0x05ea('0x21')](_0x556342[_0x05ea('0x40')]['offset']);}switch(_0xdb9417['role']){case'admin':return db[_[_0x05ea('0xa0')](_0x556342['query']['channel'])+_0x05ea('0xd1')][_0x05ea('0x46')](_0x1331e9);case'user':case _0x05ea('0x28'):return _0xdb9417[_0x05ea('0xaa')+_[_0x05ea('0xa0')](_0x556342[_0x05ea('0x40')]['channel'])+_0x05ea('0xa1')](_0x1331e9);}})['then'](function(_0x21f75f){return{'count':_0x2d5815,'rows':_0x21f75f};})[_0x05ea('0x13')](respondWithResult(_0x590836,null))[_0x05ea('0x1b')](handleError(_0x590836,null));};exports[_0x05ea('0xd6')]=function(_0x1d0b82,_0x3ef6d9){var _0x349dbb={};var _0x87fcb8={};var _0x1810ca;var _0x16d340;return db['User'][_0x05ea('0x96')]({'where':{'id':_0x1d0b82[_0x05ea('0x52')]['id']}})[_0x05ea('0x13')](handleEntityNotFound(_0x3ef6d9,null))[_0x05ea('0x13')](function(_0x7db010){if(_0x7db010){_0x1810ca=_0x7db010;_0x87fcb8['model']=_[_0x05ea('0x55')](db[_0x05ea('0xad')][_0x05ea('0x36')]);_0x87fcb8[_0x05ea('0x40')]=_[_0x05ea('0x55')](_0x1d0b82[_0x05ea('0x40')]);_0x87fcb8[_0x05ea('0x56')]=_[_0x05ea('0x57')](_0x87fcb8[_0x05ea('0x53')],_0x87fcb8['query']);_0x349dbb['attributes']=_[_0x05ea('0x57')](_0x87fcb8['model'],qs[_0x05ea('0x58')](_0x1d0b82[_0x05ea('0x40')][_0x05ea('0x58')]));_0x349dbb[_0x05ea('0x44')]=_0x349dbb['attributes'][_0x05ea('0x4a')]?_0x349dbb['attributes']:_0x87fcb8[_0x05ea('0x53')];_0x349dbb[_0x05ea('0xd2')]=qs[_0x05ea('0xd3')](_0x1d0b82['query'][_0x05ea('0xd3')]);_0x349dbb['where']=qs['filters'](_[_0x05ea('0xd4')](_0x1d0b82[_0x05ea('0x40')],_0x87fcb8[_0x05ea('0x56')]));if(_0x1d0b82[_0x05ea('0x40')][_0x05ea('0x2a')]){_0x349dbb[_0x05ea('0x3e')]=_['merge'](_0x349dbb[_0x05ea('0x3e')],{'$or':_[_0x05ea('0x37')](_0x349dbb[_0x05ea('0x44')],function(_0x57b424){var _0x3b0453={};_0x3b0453[_0x57b424]={'$like':'%'+_0x1d0b82[_0x05ea('0x40')][_0x05ea('0x2a')]+'%'};return _0x3b0453;})});}_0x349dbb=_['merge']({},_0x349dbb,_0x1d0b82[_0x05ea('0x5b')]);return _0x1810ca['getVoiceQueuesRt'](_0x349dbb);}})['then'](function(_0x4ad830){if(_0x4ad830){_0x16d340=_0x4ad830[_0x05ea('0x4a')];if(!_0x1d0b82[_0x05ea('0x40')][_0x05ea('0xc8')](_0x05ea('0xcf'))){_0x349dbb['limit']=qs[_0x05ea('0x20')](_0x1d0b82[_0x05ea('0x40')][_0x05ea('0x20')]);_0x349dbb[_0x05ea('0x21')]=qs[_0x05ea('0x21')](_0x1d0b82[_0x05ea('0x40')][_0x05ea('0x21')]);}return _0x1810ca[_0x05ea('0xd6')](_0x349dbb);}})[_0x05ea('0x13')](function(_0x5d9c4e){if(_0x5d9c4e){return _0x5d9c4e?{'count':_0x16d340,'rows':_0x5d9c4e}:null;}})[_0x05ea('0x13')](respondWithResult(_0x3ef6d9,null))[_0x05ea('0x1b')](handleError(_0x3ef6d9,null));};exports[_0x05ea('0xd7')]=function(_0x145c48,_0x265238){var _0x438562={};var _0x4087e7={};var _0x316f96;var _0x23dff5;return db['User'][_0x05ea('0x96')]({'where':{'id':_0x145c48[_0x05ea('0x52')]['id']}})['then'](handleEntityNotFound(_0x265238,null))[_0x05ea('0x13')](function(_0x93e7e6){if(_0x93e7e6){_0x316f96=_0x93e7e6;_0x4087e7[_0x05ea('0x53')]=_[_0x05ea('0x55')](db[_0x05ea('0xd8')][_0x05ea('0x36')]);_0x4087e7[_0x05ea('0x40')]=_[_0x05ea('0x55')](_0x145c48[_0x05ea('0x40')]);_0x4087e7['filters']=_['intersection'](_0x4087e7[_0x05ea('0x53')],_0x4087e7[_0x05ea('0x40')]);_0x438562[_0x05ea('0x44')]=_[_0x05ea('0x57')](_0x4087e7[_0x05ea('0x53')],qs[_0x05ea('0x58')](_0x145c48[_0x05ea('0x40')][_0x05ea('0x58')]));_0x438562[_0x05ea('0x44')]=_0x438562[_0x05ea('0x44')][_0x05ea('0x4a')]?_0x438562['attributes']:_0x4087e7[_0x05ea('0x53')];_0x438562[_0x05ea('0xd2')]=qs[_0x05ea('0xd3')](_0x145c48[_0x05ea('0x40')][_0x05ea('0xd3')]);_0x438562[_0x05ea('0x3e')]=qs['filters'](_[_0x05ea('0xd4')](_0x145c48[_0x05ea('0x40')],_0x4087e7[_0x05ea('0x56')]));if(_0x145c48[_0x05ea('0x40')]['filter']){_0x438562[_0x05ea('0x3e')]=_[_0x05ea('0x5a')](_0x438562[_0x05ea('0x3e')],{'$or':_[_0x05ea('0x37')](_0x438562[_0x05ea('0x44')],function(_0x2c1eaa){var _0x16fd47={};_0x16fd47[_0x2c1eaa]={'$like':'%'+_0x145c48[_0x05ea('0x40')][_0x05ea('0x2a')]+'%'};return _0x16fd47;})});}_0x438562=_[_0x05ea('0x5a')]({},_0x438562,_0x145c48['options']);return _0x316f96[_0x05ea('0xd7')](_0x438562);}})[_0x05ea('0x13')](function(_0x50d0d4){if(_0x50d0d4){_0x23dff5=_0x50d0d4[_0x05ea('0x4a')];if(!_0x145c48[_0x05ea('0x40')][_0x05ea('0xc8')](_0x05ea('0xcf'))){_0x438562[_0x05ea('0x20')]=qs['limit'](_0x145c48[_0x05ea('0x40')][_0x05ea('0x20')]);_0x438562[_0x05ea('0x21')]=qs[_0x05ea('0x21')](_0x145c48[_0x05ea('0x40')]['offset']);}return _0x316f96[_0x05ea('0xd7')](_0x438562);}})[_0x05ea('0x13')](function(_0x254acf){if(_0x254acf){return _0x254acf?{'count':_0x23dff5,'rows':_0x254acf}:null;}})[_0x05ea('0x13')](respondWithResult(_0x265238,null))['catch'](handleError(_0x265238,null));};exports['getRecordings']=function(_0x55abc1,_0x17b34d){var _0x27bba1={'raw':!![],'where':{}};var _0x270785={};var _0x16ef4a={'count':0x0,'rows':[]};return db[_0x05ea('0x35')]['findOne']({'where':{'id':_0x55abc1[_0x05ea('0x52')]['id']}})[_0x05ea('0x13')](handleEntityNotFound(_0x17b34d,null))['then'](function(_0x4f97d2){if(_0x4f97d2){_0x270785['model']=_['keys'](db[_0x05ea('0xd9')][_0x05ea('0x36')]);_0x270785[_0x05ea('0x40')]=_['keys'](_0x55abc1[_0x05ea('0x40')]);_0x270785[_0x05ea('0x56')]=_[_0x05ea('0x57')](_0x270785['model'],_0x270785[_0x05ea('0x40')]);_0x27bba1['attributes']=_['intersection'](_0x270785[_0x05ea('0x53')],qs['fields'](_0x55abc1[_0x05ea('0x40')][_0x05ea('0x58')]));_0x27bba1['attributes']=_0x27bba1[_0x05ea('0x44')][_0x05ea('0x4a')]?_0x27bba1['attributes']:_0x270785['model'];if(!_0x55abc1[_0x05ea('0x40')][_0x05ea('0xc8')](_0x05ea('0xcf'))){_0x27bba1[_0x05ea('0x20')]=qs[_0x05ea('0x20')](_0x55abc1[_0x05ea('0x40')][_0x05ea('0x20')]);_0x27bba1['offset']=qs['offset'](_0x55abc1['query'][_0x05ea('0x21')]);}_0x27bba1['order']=qs['sort'](_0x55abc1[_0x05ea('0x40')][_0x05ea('0xd3')]);_0x27bba1[_0x05ea('0x3e')]=qs['filters'](_[_0x05ea('0xd4')](_0x55abc1['query'],_0x270785[_0x05ea('0x56')]));_0x27bba1[_0x05ea('0x3e')][_0x05ea('0xda')]=_0x4f97d2['id'];if(_0x55abc1[_0x05ea('0x40')]['filter']){_0x27bba1['where']=_[_0x05ea('0x5a')](_0x27bba1[_0x05ea('0x3e')],{'$or':_[_0x05ea('0x37')](_0x27bba1[_0x05ea('0x44')],function(_0x463179){var _0x3356ef={};_0x3356ef[_0x463179]={'$like':'%'+_0x55abc1[_0x05ea('0x40')]['filter']+'%'};return _0x3356ef;})});}_0x27bba1=_[_0x05ea('0x5a')]({},_0x27bba1,_0x55abc1['options']);return db[_0x05ea('0xd9')][_0x05ea('0x3f')]({'where':_0x27bba1['where']})[_0x05ea('0x13')](function(_0x24afa2){_0x16ef4a['count']=_0x24afa2;if(_0x55abc1[_0x05ea('0x40')]['includeAll']){_0x27bba1[_0x05ea('0x41')]=[{'all':!![]}];}return db['VoiceRecording'][_0x05ea('0x46')](_0x27bba1);})[_0x05ea('0x13')](function(_0x139119){_0x16ef4a['rows']=_0x139119;return _0x16ef4a;});}})[_0x05ea('0x13')](respondWithFilteredResult(_0x17b34d,_0x27bba1))[_0x05ea('0x1b')](handleError(_0x17b34d,null));};exports[_0x05ea('0xdb')]=function(_0x196236,_0x4b6c64){var _0x374117={'raw':!![],'where':{}};var _0x31c1f9={};var _0x3d9bc4={'count':0x0,'rows':[]};return db['User'][_0x05ea('0x96')]({'where':{'id':_0x196236['params']['id']}})[_0x05ea('0x13')](handleEntityNotFound(_0x4b6c64,null))[_0x05ea('0x13')](function(_0x26249d){if(_0x26249d){_0x31c1f9[_0x05ea('0x53')]=_[_0x05ea('0x55')](db[_0x05ea('0xdc')][_0x05ea('0x36')]);_0x31c1f9['query']=_['keys'](_0x196236[_0x05ea('0x40')]);_0x31c1f9[_0x05ea('0x56')]=_[_0x05ea('0x57')](_0x31c1f9[_0x05ea('0x53')],_0x31c1f9[_0x05ea('0x40')]);_0x374117[_0x05ea('0x44')]=_['intersection'](_0x31c1f9[_0x05ea('0x53')],qs['fields'](_0x196236[_0x05ea('0x40')]['fields']));_0x374117[_0x05ea('0x44')]=_0x374117[_0x05ea('0x44')][_0x05ea('0x4a')]?_0x374117[_0x05ea('0x44')]:_0x31c1f9['model'];if(!_0x196236[_0x05ea('0x40')][_0x05ea('0xc8')](_0x05ea('0xcf'))){_0x374117[_0x05ea('0x20')]=qs[_0x05ea('0x20')](_0x196236[_0x05ea('0x40')][_0x05ea('0x20')]);_0x374117[_0x05ea('0x21')]=qs[_0x05ea('0x21')](_0x196236['query']['offset']);}_0x374117[_0x05ea('0xd2')]=qs[_0x05ea('0xd3')](_0x196236[_0x05ea('0x40')][_0x05ea('0xd3')]);_0x374117[_0x05ea('0x3e')]=qs[_0x05ea('0x56')](_[_0x05ea('0xd4')](_0x196236['query'],_0x31c1f9[_0x05ea('0x56')]));_0x374117[_0x05ea('0x3e')][_0x05ea('0xda')]=_0x26249d['id'];if(_0x196236[_0x05ea('0x40')][_0x05ea('0x2a')]){_0x374117['where']=_[_0x05ea('0x5a')](_0x374117[_0x05ea('0x3e')],{'$or':_[_0x05ea('0x37')](_0x374117[_0x05ea('0x44')],function(_0x5969d4){var _0x3439d4={};_0x3439d4[_0x5969d4]={'$like':'%'+_0x196236['query'][_0x05ea('0x2a')]+'%'};return _0x3439d4;})});}_0x374117=_[_0x05ea('0x5a')]({},_0x374117,_0x196236['options']);return db[_0x05ea('0xdc')]['count']({'where':_0x374117[_0x05ea('0x3e')]})[_0x05ea('0x13')](function(_0x49e623){_0x3d9bc4['count']=_0x49e623;if(_0x196236['query'][_0x05ea('0x59')]){_0x374117[_0x05ea('0x41')]=[{'all':!![]}];}return db[_0x05ea('0xdc')][_0x05ea('0x46')](_0x374117);})['then'](function(_0x1e6d6e){_0x3d9bc4[_0x05ea('0x47')]=_0x1e6d6e;return _0x3d9bc4;});}})['then'](respondWithFilteredResult(_0x4b6c64,_0x374117))[_0x05ea('0x1b')](handleError(_0x4b6c64,null));};exports[_0x05ea('0xdd')]=function(_0x1754b1,_0x576e20){var _0x342c3c={};var _0x42a330={};var _0x3d9bc0;var _0x4d56f2;return db[_0x05ea('0x35')][_0x05ea('0x96')]({'where':{'id':_0x1754b1['params']['id']}})[_0x05ea('0x13')](handleEntityNotFound(_0x576e20,null))[_0x05ea('0x13')](function(_0x42d6b9){if(_0x42d6b9){_0x3d9bc0=_0x42d6b9;_0x42a330[_0x05ea('0x53')]=_[_0x05ea('0x55')](db[_0x05ea('0xde')][_0x05ea('0x36')]);_0x42a330[_0x05ea('0x40')]=_[_0x05ea('0x55')](_0x1754b1[_0x05ea('0x40')]);_0x42a330['filters']=_[_0x05ea('0x57')](_0x42a330[_0x05ea('0x53')],_0x42a330[_0x05ea('0x40')]);_0x342c3c[_0x05ea('0x44')]=_[_0x05ea('0x57')](_0x42a330['model'],qs[_0x05ea('0x58')](_0x1754b1[_0x05ea('0x40')]['fields']));_0x342c3c[_0x05ea('0x44')]=_0x342c3c[_0x05ea('0x44')][_0x05ea('0x4a')]?_0x342c3c[_0x05ea('0x44')]:_0x42a330[_0x05ea('0x53')];_0x342c3c['order']=qs[_0x05ea('0xd3')](_0x1754b1[_0x05ea('0x40')][_0x05ea('0xd3')]);_0x342c3c[_0x05ea('0x3e')]=qs[_0x05ea('0x56')](_[_0x05ea('0xd4')](_0x1754b1['query'],_0x42a330['filters']));if(_0x1754b1[_0x05ea('0x40')]['filter']){_0x342c3c[_0x05ea('0x3e')]=_['merge'](_0x342c3c[_0x05ea('0x3e')],{'$or':_[_0x05ea('0x37')](_0x342c3c[_0x05ea('0x44')],function(_0x10eb88){var _0x3239a9={};_0x3239a9[_0x10eb88]={'$like':'%'+_0x1754b1[_0x05ea('0x40')]['filter']+'%'};return _0x3239a9;})});}_0x342c3c=_[_0x05ea('0x5a')]({},_0x342c3c,_0x1754b1['options']);return _0x3d9bc0[_0x05ea('0xdd')](_0x342c3c);}})[_0x05ea('0x13')](function(_0x1b1344){if(_0x1b1344){_0x4d56f2=_0x1b1344[_0x05ea('0x4a')];if(!_0x1754b1[_0x05ea('0x40')]['hasOwnProperty'](_0x05ea('0xcf'))){_0x342c3c['limit']=qs[_0x05ea('0x20')](_0x1754b1[_0x05ea('0x40')][_0x05ea('0x20')]);_0x342c3c[_0x05ea('0x21')]=qs[_0x05ea('0x21')](_0x1754b1['query']['offset']);}return _0x3d9bc0[_0x05ea('0xdd')](_0x342c3c);}})[_0x05ea('0x13')](function(_0xc0ba58){if(_0xc0ba58){return _0xc0ba58?{'count':_0x4d56f2,'rows':_0xc0ba58}:null;}})['then'](respondWithResult(_0x576e20,null))[_0x05ea('0x1b')](handleError(_0x576e20,null));};exports[_0x05ea('0xdf')]=function(_0x3fd108,_0x37ba4c){var _0x29eb9d={};var _0x4c1e9c={};var _0xcab3cd;var _0x31ab48;return db[_0x05ea('0x35')][_0x05ea('0x96')]({'where':{'id':_0x3fd108[_0x05ea('0x52')]['id']}})[_0x05ea('0x13')](handleEntityNotFound(_0x37ba4c,null))['then'](function(_0x25f0b6){if(_0x25f0b6){_0xcab3cd=_0x25f0b6;_0x4c1e9c[_0x05ea('0x53')]=_[_0x05ea('0x55')](db[_0x05ea('0xe0')]['rawAttributes']);_0x4c1e9c[_0x05ea('0x40')]=_[_0x05ea('0x55')](_0x3fd108['query']);_0x4c1e9c['filters']=_['intersection'](_0x4c1e9c[_0x05ea('0x53')],_0x4c1e9c[_0x05ea('0x40')]);_0x29eb9d[_0x05ea('0x44')]=_[_0x05ea('0x57')](_0x4c1e9c[_0x05ea('0x53')],qs[_0x05ea('0x58')](_0x3fd108[_0x05ea('0x40')][_0x05ea('0x58')]));_0x29eb9d[_0x05ea('0x44')]=_0x29eb9d[_0x05ea('0x44')]['length']?_0x29eb9d['attributes']:_0x4c1e9c[_0x05ea('0x53')];_0x29eb9d[_0x05ea('0xd2')]=qs['sort'](_0x3fd108[_0x05ea('0x40')]['sort']);_0x29eb9d[_0x05ea('0x3e')]=qs['filters'](_[_0x05ea('0xd4')](_0x3fd108[_0x05ea('0x40')],_0x4c1e9c[_0x05ea('0x56')]));if(_0x3fd108[_0x05ea('0x40')]['filter']){_0x29eb9d[_0x05ea('0x3e')]=_[_0x05ea('0x5a')](_0x29eb9d[_0x05ea('0x3e')],{'$or':_[_0x05ea('0x37')](_0x29eb9d[_0x05ea('0x44')],function(_0x39ba8f){var _0x38de33={};_0x38de33[_0x39ba8f]={'$like':'%'+_0x3fd108[_0x05ea('0x40')]['filter']+'%'};return _0x38de33;})});}_0x29eb9d=_[_0x05ea('0x5a')]({},_0x29eb9d,_0x3fd108['options']);return _0xcab3cd[_0x05ea('0xdf')](_0x29eb9d);}})[_0x05ea('0x13')](function(_0x48b931){if(_0x48b931){_0x31ab48=_0x48b931[_0x05ea('0x4a')];if(!_0x3fd108[_0x05ea('0x40')][_0x05ea('0xc8')](_0x05ea('0xcf'))){_0x29eb9d[_0x05ea('0x20')]=qs[_0x05ea('0x20')](_0x3fd108[_0x05ea('0x40')][_0x05ea('0x20')]);_0x29eb9d[_0x05ea('0x21')]=qs[_0x05ea('0x21')](_0x3fd108[_0x05ea('0x40')]['offset']);}return _0xcab3cd[_0x05ea('0xdf')](_0x29eb9d);}})['then'](function(_0x2ae5b2){if(_0x2ae5b2){return _0x2ae5b2?{'count':_0x31ab48,'rows':_0x2ae5b2}:null;}})[_0x05ea('0x13')](respondWithResult(_0x37ba4c,null))[_0x05ea('0x1b')](handleError(_0x37ba4c,null));};exports['getMailInteractions']=function(_0x409a10,_0x24a216){var _0x518058={'raw':!![],'where':{}};var _0x3de615={};var _0x329901={'count':0x0,'rows':[]};return db[_0x05ea('0x35')][_0x05ea('0x96')]({'where':{'id':_0x409a10[_0x05ea('0x52')]['id']}})[_0x05ea('0x13')](handleEntityNotFound(_0x24a216,null))[_0x05ea('0x13')](function(_0x16f8e2){if(_0x16f8e2){_0x3de615[_0x05ea('0x53')]=_[_0x05ea('0x55')](db['MailInteraction'][_0x05ea('0x36')]);_0x3de615[_0x05ea('0x40')]=_[_0x05ea('0x55')](_0x409a10[_0x05ea('0x40')]);_0x3de615[_0x05ea('0x56')]=_[_0x05ea('0x57')](_0x3de615[_0x05ea('0x53')],_0x3de615[_0x05ea('0x40')]);_0x518058[_0x05ea('0x44')]=_[_0x05ea('0x57')](_0x3de615[_0x05ea('0x53')],qs[_0x05ea('0x58')](_0x409a10[_0x05ea('0x40')]['fields']));_0x518058[_0x05ea('0x44')]=_0x518058[_0x05ea('0x44')][_0x05ea('0x4a')]?_0x518058[_0x05ea('0x44')]:_0x3de615[_0x05ea('0x53')];if(!_0x409a10['query']['hasOwnProperty'](_0x05ea('0xcf'))){_0x518058[_0x05ea('0x20')]=qs[_0x05ea('0x20')](_0x409a10[_0x05ea('0x40')][_0x05ea('0x20')]);_0x518058['offset']=qs['offset'](_0x409a10['query'][_0x05ea('0x21')]);}_0x518058[_0x05ea('0xd2')]=qs['sort'](_0x409a10[_0x05ea('0x40')][_0x05ea('0xd3')]);_0x518058[_0x05ea('0x3e')]=qs['filters'](_[_0x05ea('0xd4')](_0x409a10[_0x05ea('0x40')],_0x3de615[_0x05ea('0x56')]));_0x518058[_0x05ea('0x3e')][_0x05ea('0xda')]=_0x16f8e2['id'];if(_0x409a10['query'][_0x05ea('0x2a')]){_0x518058['where']=_['merge'](_0x518058[_0x05ea('0x3e')],{'$or':_[_0x05ea('0x37')](_0x518058[_0x05ea('0x44')],function(_0x6b39fd){var _0x4253c5={};_0x4253c5[_0x6b39fd]={'$like':'%'+_0x409a10[_0x05ea('0x40')]['filter']+'%'};return _0x4253c5;})});}_0x518058=_[_0x05ea('0x5a')]({},_0x518058,_0x409a10['options']);return db['MailInteraction'][_0x05ea('0x3f')]({'where':_0x518058[_0x05ea('0x3e')]})[_0x05ea('0x13')](function(_0x35dde7){_0x329901['count']=_0x35dde7;if(_0x409a10[_0x05ea('0x40')][_0x05ea('0x59')]){_0x518058[_0x05ea('0x41')]=[{'all':!![]}];}return db[_0x05ea('0xe1')][_0x05ea('0x46')](_0x518058);})[_0x05ea('0x13')](function(_0x1b7d16){_0x329901['rows']=_0x1b7d16;return _0x329901;});}})[_0x05ea('0x13')](respondWithFilteredResult(_0x24a216,_0x518058))[_0x05ea('0x1b')](handleError(_0x24a216,null));};exports[_0x05ea('0xe2')]=function(_0x4f9376,_0x475d84){var _0x382b4d={};var _0x3b93d1={};var _0x18e33e;var _0x5129b5;return db[_0x05ea('0x35')][_0x05ea('0x96')]({'where':{'id':_0x4f9376[_0x05ea('0x52')]['id']}})[_0x05ea('0x13')](handleEntityNotFound(_0x475d84,null))[_0x05ea('0x13')](function(_0x5eca4a){if(_0x5eca4a){_0x18e33e=_0x5eca4a;_0x3b93d1[_0x05ea('0x53')]=_[_0x05ea('0x55')](db[_0x05ea('0xe3')]['rawAttributes']);_0x3b93d1['query']=_[_0x05ea('0x55')](_0x4f9376[_0x05ea('0x40')]);_0x3b93d1[_0x05ea('0x56')]=_[_0x05ea('0x57')](_0x3b93d1['model'],_0x3b93d1[_0x05ea('0x40')]);_0x382b4d[_0x05ea('0x44')]=_[_0x05ea('0x57')](_0x3b93d1[_0x05ea('0x53')],qs[_0x05ea('0x58')](_0x4f9376[_0x05ea('0x40')][_0x05ea('0x58')]));_0x382b4d[_0x05ea('0x44')]=_0x382b4d[_0x05ea('0x44')][_0x05ea('0x4a')]?_0x382b4d[_0x05ea('0x44')]:_0x3b93d1[_0x05ea('0x53')];_0x382b4d[_0x05ea('0xd2')]=qs[_0x05ea('0xd3')](_0x4f9376[_0x05ea('0x40')][_0x05ea('0xd3')]);_0x382b4d[_0x05ea('0x3e')]=qs[_0x05ea('0x56')](_[_0x05ea('0xd4')](_0x4f9376['query'],_0x3b93d1[_0x05ea('0x56')]));if(_0x4f9376[_0x05ea('0x40')][_0x05ea('0x2a')]){_0x382b4d[_0x05ea('0x3e')]=_[_0x05ea('0x5a')](_0x382b4d[_0x05ea('0x3e')],{'$or':_['map'](_0x382b4d[_0x05ea('0x44')],function(_0x4fc893){var _0x4d581c={};_0x4d581c[_0x4fc893]={'$like':'%'+_0x4f9376[_0x05ea('0x40')]['filter']+'%'};return _0x4d581c;})});}_0x382b4d=_[_0x05ea('0x5a')]({},_0x382b4d,_0x4f9376[_0x05ea('0x5b')]);return _0x18e33e[_0x05ea('0xe2')](_0x382b4d);}})[_0x05ea('0x13')](function(_0x53076b){if(_0x53076b){_0x5129b5=_0x53076b[_0x05ea('0x4a')];if(!_0x4f9376[_0x05ea('0x40')]['hasOwnProperty'](_0x05ea('0xcf'))){_0x382b4d[_0x05ea('0x20')]=qs[_0x05ea('0x20')](_0x4f9376[_0x05ea('0x40')]['limit']);_0x382b4d[_0x05ea('0x21')]=qs[_0x05ea('0x21')](_0x4f9376[_0x05ea('0x40')][_0x05ea('0x21')]);}return _0x18e33e[_0x05ea('0xe2')](_0x382b4d);}})['then'](function(_0x1adc81){if(_0x1adc81){return _0x1adc81?{'count':_0x5129b5,'rows':_0x1adc81}:null;}})[_0x05ea('0x13')](respondWithResult(_0x475d84,null))[_0x05ea('0x1b')](handleError(_0x475d84,null));};exports['getFaxInteractions']=function(_0x43a4ed,_0x51a500){var _0x15a6ea={};var _0x3ed440={};var _0x485b4a;var _0x7536cb;return db['User']['findOne']({'where':{'id':_0x43a4ed['params']['id']}})[_0x05ea('0x13')](handleEntityNotFound(_0x51a500,null))[_0x05ea('0x13')](function(_0x1f6267){if(_0x1f6267){_0x485b4a=_0x1f6267;_0x3ed440[_0x05ea('0x53')]=_[_0x05ea('0x55')](db[_0x05ea('0xe4')]['rawAttributes']);_0x3ed440['query']=_[_0x05ea('0x55')](_0x43a4ed[_0x05ea('0x40')]);_0x3ed440[_0x05ea('0x56')]=_[_0x05ea('0x57')](_0x3ed440['model'],_0x3ed440[_0x05ea('0x40')]);_0x15a6ea[_0x05ea('0x44')]=_['intersection'](_0x3ed440[_0x05ea('0x53')],qs[_0x05ea('0x58')](_0x43a4ed['query'][_0x05ea('0x58')]));_0x15a6ea['attributes']=_0x15a6ea[_0x05ea('0x44')][_0x05ea('0x4a')]?_0x15a6ea[_0x05ea('0x44')]:_0x3ed440['model'];_0x15a6ea[_0x05ea('0xd2')]=qs['sort'](_0x43a4ed[_0x05ea('0x40')][_0x05ea('0xd3')]);_0x15a6ea[_0x05ea('0x3e')]=qs[_0x05ea('0x56')](_[_0x05ea('0xd4')](_0x43a4ed[_0x05ea('0x40')],_0x3ed440[_0x05ea('0x56')]));if(_0x43a4ed[_0x05ea('0x40')]['filter']){_0x15a6ea[_0x05ea('0x3e')]=_['merge'](_0x15a6ea[_0x05ea('0x3e')],{'$or':_[_0x05ea('0x37')](_0x15a6ea[_0x05ea('0x44')],function(_0x7537d9){var _0x509644={};_0x509644[_0x7537d9]={'$like':'%'+_0x43a4ed[_0x05ea('0x40')]['filter']+'%'};return _0x509644;})});}_0x15a6ea=_['merge']({},_0x15a6ea,_0x43a4ed['options']);return _0x485b4a['getFaxInteractions'](_0x15a6ea);}})[_0x05ea('0x13')](function(_0x15a77a){if(_0x15a77a){_0x7536cb=_0x15a77a[_0x05ea('0x4a')];if(!_0x43a4ed['query'][_0x05ea('0xc8')](_0x05ea('0xcf'))){_0x15a6ea[_0x05ea('0x20')]=qs['limit'](_0x43a4ed['query'][_0x05ea('0x20')]);_0x15a6ea[_0x05ea('0x21')]=qs['offset'](_0x43a4ed[_0x05ea('0x40')][_0x05ea('0x21')]);}return _0x485b4a[_0x05ea('0xe5')](_0x15a6ea);}})[_0x05ea('0x13')](function(_0x133f92){if(_0x133f92){return _0x133f92?{'count':_0x7536cb,'rows':_0x133f92}:null;}})[_0x05ea('0x13')](respondWithResult(_0x51a500,null))[_0x05ea('0x1b')](handleError(_0x51a500,null));};exports[_0x05ea('0xe6')]=function(_0x403efb,_0x48418c){var _0x2cb3b7={};var _0xf4868a={};var _0x33c6a9;var _0x259eff;return db[_0x05ea('0x35')][_0x05ea('0x96')]({'where':{'id':_0x403efb[_0x05ea('0x52')]['id']}})[_0x05ea('0x13')](handleEntityNotFound(_0x48418c,null))[_0x05ea('0x13')](function(_0x4724a2){if(_0x4724a2){_0x33c6a9=_0x4724a2;_0xf4868a[_0x05ea('0x53')]=_['keys'](db[_0x05ea('0xe7')][_0x05ea('0x36')]);_0xf4868a['query']=_[_0x05ea('0x55')](_0x403efb[_0x05ea('0x40')]);_0xf4868a['filters']=_[_0x05ea('0x57')](_0xf4868a[_0x05ea('0x53')],_0xf4868a[_0x05ea('0x40')]);_0x2cb3b7[_0x05ea('0x44')]=_[_0x05ea('0x57')](_0xf4868a[_0x05ea('0x53')],qs[_0x05ea('0x58')](_0x403efb[_0x05ea('0x40')]['fields']));_0x2cb3b7[_0x05ea('0x44')]=_0x2cb3b7[_0x05ea('0x44')][_0x05ea('0x4a')]?_0x2cb3b7[_0x05ea('0x44')]:_0xf4868a['model'];_0x2cb3b7[_0x05ea('0xd2')]=qs[_0x05ea('0xd3')](_0x403efb[_0x05ea('0x40')][_0x05ea('0xd3')]);_0x2cb3b7[_0x05ea('0x3e')]=qs[_0x05ea('0x56')](_[_0x05ea('0xd4')](_0x403efb[_0x05ea('0x40')],_0xf4868a[_0x05ea('0x56')]));if(_0x403efb[_0x05ea('0x40')]['filter']){_0x2cb3b7[_0x05ea('0x3e')]=_[_0x05ea('0x5a')](_0x2cb3b7[_0x05ea('0x3e')],{'$or':_[_0x05ea('0x37')](_0x2cb3b7[_0x05ea('0x44')],function(_0x1bf270){var _0x9f9680={};_0x9f9680[_0x1bf270]={'$like':'%'+_0x403efb[_0x05ea('0x40')][_0x05ea('0x2a')]+'%'};return _0x9f9680;})});}_0x2cb3b7=_[_0x05ea('0x5a')]({},_0x2cb3b7,_0x403efb[_0x05ea('0x5b')]);return _0x33c6a9[_0x05ea('0xe6')](_0x2cb3b7);}})[_0x05ea('0x13')](function(_0x4a2346){if(_0x4a2346){_0x259eff=_0x4a2346[_0x05ea('0x4a')];if(!_0x403efb[_0x05ea('0x40')][_0x05ea('0xc8')]('nolimit')){_0x2cb3b7['limit']=qs['limit'](_0x403efb['query'][_0x05ea('0x20')]);_0x2cb3b7[_0x05ea('0x21')]=qs[_0x05ea('0x21')](_0x403efb[_0x05ea('0x40')][_0x05ea('0x21')]);}return _0x33c6a9[_0x05ea('0xe6')](_0x2cb3b7);}})[_0x05ea('0x13')](function(_0x54d527){if(_0x54d527){return _0x54d527?{'count':_0x259eff,'rows':_0x54d527}:null;}})['then'](respondWithResult(_0x48418c,null))[_0x05ea('0x1b')](handleError(_0x48418c,null));};exports['login']=function(_0x35658b,_0x2b59b3,_0x15d05c){var _0x55e2d1;var _0x4571ee;var _0x52f654;var _0x290686=!_[_0x05ea('0x65')](_0x35658b[_0x05ea('0x52')]['id'])?_0x35658b[_0x05ea('0x52')]['id']:!_['isNil'](_0x35658b[_0x05ea('0x27')]['id'])?_0x35658b['user']['id']:null;return db[_0x05ea('0x35')]['find']({'where':{'id':_0x290686,'role':{'$or':[_0x05ea('0x25'),_0x05ea('0x27'),'agent']}},'attributes':['id',_0x05ea('0x2f'),_0x05ea('0xe8'),'mobile',_0x05ea('0x24'),_0x05ea('0x62'),_0x05ea('0x9c')]})[_0x05ea('0x13')](function(_0x150f04){if(_0x150f04){if(_0x150f04[_0x05ea('0x24')]===_0x05ea('0x28')){_0x55e2d1=_0x150f04;if(_0x35658b['body'][_0x05ea('0x9e')]){_0x52f654=util[_0x05ea('0xe9')](_0x05ea('0xea'),_0x55e2d1[_0x35658b[_0x05ea('0x5d')][_0x05ea('0x9e')]]);}else if(_0x35658b['body'][_0x05ea('0xeb')]){_0x52f654=util[_0x05ea('0xe9')](_0x05ea('0xac'),_0x35658b[_0x05ea('0x5d')][_0x05ea('0xeb')]);}else{_0x52f654=util[_0x05ea('0xe9')]('SIP/%s',_0x55e2d1[_0x05ea('0x2f')]);}socket['to'](util[_0x05ea('0xe9')](_0x05ea('0xec'),_0x55e2d1[_0x05ea('0x2f')]))['emit']('user:forcelogout',{'user':{'id':_0x55e2d1['id'],'name':_0x55e2d1[_0x05ea('0x2f')]},'ip':_0x35658b[_0x05ea('0xed')][_0x05ea('0xee')]||_0x35658b[_0x05ea('0xef')][_0x05ea('0xf0')]||_0x35658b['socket']['remoteAddress']||_0x35658b[_0x05ea('0xef')][_0x05ea('0xf1')][_0x05ea('0xf0')]});return db['UserVoiceQueueRt'][_0x05ea('0x31')]({'where':{'membername':_0x55e2d1[_0x05ea('0x2f')]},'individualHooks':!![]});}}else{throw new db['Sequelize'][(_0x05ea('0x90'))](_0x05ea('0xf2'));}})['then'](function(){if(_0x55e2d1){return _0x55e2d1[_0x05ea('0xf3')]({'raw':!![]});}})[_0x05ea('0x13')](function(_0x2f5dbe){if(_0x55e2d1){var _0x15b38a=[];if(_0x2f5dbe){_0x4571ee=_0x2f5dbe;if(_0x4571ee[_0x05ea('0x4a')]){for(var _0x15a947=0x0;_0x15a947<_0x4571ee[_0x05ea('0x4a')];_0x15a947++){_0x15b38a[_0x05ea('0x45')]({'membername':_0x55e2d1[_0x05ea('0x2f')],'UserId':_0x55e2d1['id'],'queue_name':_0x4571ee[_0x15a947][_0x05ea('0x2f')],'VoiceQueueId':_0x4571ee[_0x15a947]['id'],'interface':_0x52f654,'paused':_0x55e2d1[_0x05ea('0x9c')]||![],'penalty':_0x4571ee[_0x15a947][_0x05ea('0xf4')]||0x0});}return BPromise[_0x05ea('0x8b')](_0x15b38a,function(_0x9d4c0a){return db[_0x05ea('0xad')][_0x05ea('0xf5')](_0x9d4c0a);});}}}})['then'](function(){if(_0x55e2d1){return db[_0x05ea('0xf6')][_0x05ea('0x46')]({'where':{'membername':_0x55e2d1['name'],'exitAt':null}});}})[_0x05ea('0x13')](function(_0x17d57c){if(_0x55e2d1){var _0x10f424=[];_0x17d57c[_0x05ea('0xf7')](function(_0x39533a){_0x10f424[_0x05ea('0x45')](_0x39533a[_0x05ea('0x23')]({'exitAt':moment()[_0x05ea('0xe9')](_0x05ea('0xf8'))}));});return BPromise[_0x05ea('0x51')](_0x10f424);}})[_0x05ea('0x13')](function(){if(_0x55e2d1){var _0x1c27a7=[];var _0x44abe8=[];var _0x42eedd=utils[_0x05ea('0xf9')]();var _0x3fcd78={'membername':_0x55e2d1[_0x05ea('0x2f')],'interface':_0x52f654,'enterAt':moment()[_0x05ea('0xe9')](_0x05ea('0xf8')),'role':_0x55e2d1['role'],'internal':_0x55e2d1[_0x05ea('0x62')]};_0x42eedd[_0x05ea('0xf7')](function(_0x4230e7){_0x1c27a7[_0x05ea('0x45')](_['merge']({'channel':_0x4230e7,'type':'LOGIN','data1':_0x35658b[_0x05ea('0x5d')][_0x05ea('0xfa')],'data2':_0x52f654},_0x3fcd78));if(_0x55e2d1['loginInPause']){_0x44abe8[_0x05ea('0x45')](_[_0x05ea('0x5a')]({'channel':_0x4230e7,'type':_0x05ea('0xfb'),'data1':_0x05ea('0xfc')},_0x3fcd78));}});return db[_0x05ea('0xf6')][_0x05ea('0x87')](_0x1c27a7[_0x05ea('0xc6')](_0x44abe8),{'individualHooks':!![]});}})[_0x05ea('0x13')](function(){if(_0x55e2d1){return _0x55e2d1['update']({'online':!![],'lastLoginAt':moment()[_0x05ea('0xe9')](_0x05ea('0xf8')),'voicePause':_0x55e2d1[_0x05ea('0x9c')]||![],'mailPause':_0x55e2d1[_0x05ea('0x9c')]||![],'chatPause':_0x55e2d1['loginInPause']||![],'faxPause':_0x55e2d1['loginInPause']||![],'smsPause':_0x55e2d1[_0x05ea('0x9c')]||![],'openchannelPause':_0x55e2d1[_0x05ea('0x9c')]||![],'whatsappPause':_0x55e2d1['loginInPause']||![],'pauseType':_0x55e2d1['loginInPause']?'LOGININPAUSE':null,'interface':_0x52f654,'lastPauseAt':moment()[_0x05ea('0xe9')](_0x05ea('0xf8'))});}})[_0x05ea('0x13')](function(_0x120ff9){if(_0x35658b[_0x05ea('0xfd')]){return _0x15d05c();}else{return BPromise[_0x05ea('0xfe')](_0x120ff9)[_0x05ea('0x13')](respondWithResult(_0x2b59b3,null));}})[_0x05ea('0x1b')](handleError(_0x2b59b3,null));};exports['logout']=function(_0x5ad60b,_0x5e74f9){var _0x246d4e;return db[_0x05ea('0x35')]['find']({'where':{'id':_0x5ad60b[_0x05ea('0x52')]['id'],'role':_0x05ea('0x28')},'attributes':['id','name',_0x05ea('0x24')]})[_0x05ea('0x13')](handleEntityNotFound(_0x5e74f9,null))['then'](function(_0x212940){if(_0x212940){_0x246d4e=_0x212940;return db['UserVoiceQueueRt'][_0x05ea('0x31')]({'where':{'membername':_0x246d4e[_0x05ea('0x2f')]},'individualHooks':!![]});}})['then'](function(){return db['MemberReport'][_0x05ea('0x46')]({'where':{'membername':_0x246d4e[_0x05ea('0x2f')],'exitAt':null}});})['then'](function(_0x86b6fe){var _0x2e20d7=[];_0x86b6fe['forEach'](function(_0x37623a){_0x2e20d7[_0x05ea('0x45')](_0x37623a['update']({'exitAt':moment()[_0x05ea('0xe9')](_0x05ea('0xf8'))}));});return BPromise[_0x05ea('0x51')](_0x2e20d7);})[_0x05ea('0x13')](function(){return _0x246d4e[_0x05ea('0x23')]({'online':![],'voicePause':![],'mailPause':![],'chatPause':![],'faxPause':![],'smsPause':![],'openchannelPause':![],'whatsappPause':![],'interface':null});})['then'](respondWithResult(_0x5e74f9,null))[_0x05ea('0x1b')](handleError(_0x5e74f9,null));};exports['pause']=function(_0x583790,_0x4793b7){var _0x39a32d;return db[_0x05ea('0xad')][_0x05ea('0x23')]({'paused':0x1},{'where':{'UserId':_0x583790[_0x05ea('0x52')]['id']},'individualHooks':!![]})[_0x05ea('0x13')](function(){return db[_0x05ea('0x35')][_0x05ea('0x2e')]({'where':{'id':_0x583790[_0x05ea('0x52')]['id'],'role':'agent'},'attributes':['id',_0x05ea('0x2f'),_0x05ea('0x24'),_0x05ea('0x62'),_0x05ea('0x9e')]});})['then'](handleEntityNotFound(_0x4793b7,null))['then'](function(_0x34aafe){if(_0x34aafe){_0x39a32d=_0x34aafe;return respondWithRpcPromise(_0x05ea('0xff'),'pause',{'id':_0x39a32d['id'],'name':_0x39a32d[_0x05ea('0x2f')],'pause':!![]});}})[_0x05ea('0x13')](function(){if(_0x39a32d){return db['MemberReport'][_0x05ea('0x46')]({'where':{'membername':_0x39a32d['name'],'type':'PAUSE','exitAt':null}});}})['then'](function(_0x38adc5){if(_0x38adc5['length']){var _0x3d2a82=moment()[_0x05ea('0xe9')]('YYYY-MM-DD\x20HH:mm:ss');for(var _0x525d22=0x0,_0x29362a=_0x38adc5[_0x05ea('0x4a')];_0x525d22<_0x29362a;_0x525d22++){_0x38adc5[_0x525d22][_0x05ea('0x100')]({'exitAt':_0x3d2a82});}}})[_0x05ea('0x13')](function(){var _0x5f2a24=[];var _0x46f2cb=utils[_0x05ea('0xf9')]();_0x46f2cb[_0x05ea('0xf7')](function(_0x316384){_0x5f2a24['push']({'channel':_0x316384,'membername':_0x39a32d[_0x05ea('0x2f')],'interface':_[_0x05ea('0x65')](_0x39a32d['interface'])?util[_0x05ea('0xe9')](_0x05ea('0xac'),_0x39a32d['name']):_0x39a32d[_0x05ea('0x9e')],'type':'PAUSE','enterAt':moment()[_0x05ea('0xe9')](_0x05ea('0xf8')),'data1':_0x583790['body'][_0x05ea('0x39')]||'DEFAULT\x20PAUSE','role':_0x39a32d['role'],'internal':_0x39a32d[_0x05ea('0x62')]});});return db['MemberReport']['bulkCreate'](_0x5f2a24,{'individualHooks':!![]});})[_0x05ea('0x13')](function(){return _0x39a32d['update']({'voicePause':!![],'mailPause':!![],'chatPause':!![],'faxPause':!![],'smsPause':!![],'whatsappPause':!![],'openchannelPause':!![],'pauseType':_0x583790[_0x05ea('0x5d')]['type']||_0x05ea('0x101'),'lastPauseAt':moment()[_0x05ea('0xe9')](_0x05ea('0xf8'))});})[_0x05ea('0x13')](respondWithResult(_0x4793b7,null))[_0x05ea('0x1b')](handleError(_0x4793b7,null));};exports[_0x05ea('0x102')]=function(_0x3ea458,_0x4da072){var _0x3332cf;return db[_0x05ea('0x35')]['find']({'where':{'id':_0x3ea458['params']['id']},'attributes':['id',_0x05ea('0x2f'),_0x05ea('0x24'),_0x05ea('0x9d'),_0x05ea('0x103'),'chatPause','faxPause',_0x05ea('0x104'),'smsPause',_0x05ea('0x105'),'pauseType','lastPauseAt']})[_0x05ea('0x13')](handleEntityNotFound(_0x4da072,null))[_0x05ea('0x13')](function(_0x1054ff){if(_0x1054ff){_0x3332cf=_0x1054ff;if(_0x3ea458[_0x05ea('0x5d')][_0x05ea('0x9b')]&&!utils[_0x05ea('0xaf')](_0x3ea458[_0x05ea('0x5d')]['channel'])){throw new db[(_0x05ea('0x8f'))][(_0x05ea('0x90'))](_0x05ea('0x9f'));}switch(_0x3ea458[_0x05ea('0x5d')][_0x05ea('0x9b')]){case _0x05ea('0xa8'):return respondWithRpcPromise('QueuePause',_0x05ea('0x102'),{'id':_0x3332cf['id'],'name':_0x3332cf[_0x05ea('0x2f')],'pause':![]})[_0x05ea('0x13')](function(){return db['UserVoiceQueueRt'][_0x05ea('0x23')]({'paused':0x0},{'where':{'UserId':_0x3332cf['id']},'individualHooks':!![]});})[_0x05ea('0x13')](function(){return db[_0x05ea('0xf6')][_0x05ea('0x2e')]({'where':{'channel':_0x3ea458[_0x05ea('0x5d')][_0x05ea('0x9b')],'membername':_0x3332cf['name'],'type':_0x05ea('0xfb'),'exitAt':null}});})[_0x05ea('0x13')](function(_0x5809ba){if(_0x5809ba){return _0x5809ba[_0x05ea('0x23')]({'exitAt':moment()[_0x05ea('0xe9')]('YYYY-MM-DD\x20HH:mm:ss'),'data2':_0x05ea('0x106')},{'individualHooks':!![]});}return null;})[_0x05ea('0x13')](function(){return _0x3332cf[_0x05ea('0x23')]({'voicePause':![]});});case _0x05ea('0x4e'):case _0x05ea('0x4b'):case _0x05ea('0x5c'):case _0x05ea('0x4d'):case _0x05ea('0x50'):case _0x05ea('0x4f'):return db['MemberReport'][_0x05ea('0x2e')]({'where':{'channel':_0x3ea458['body']['channel'],'membername':_0x3332cf['name'],'type':_0x05ea('0xfb'),'exitAt':null}})['then'](function(_0x89b6e4){if(_0x89b6e4){return _0x89b6e4[_0x05ea('0x23')]({'exitAt':moment()[_0x05ea('0xe9')]('YYYY-MM-DD\x20HH:mm:ss'),'data2':_0x05ea('0x106')},{'individualHooks':!![]});}return null;})['then'](function(){var _0x1d5124={};_[_0x05ea('0x22')](_0x1d5124,util['format'](_0x05ea('0x107'),_0x3ea458[_0x05ea('0x5d')]['channel'],_0x05ea('0x108')),![]);return _0x3332cf['update'](_0x1d5124);});default:return respondWithRpcPromise('QueuePause','unpause',{'id':_0x3332cf['id'],'name':_0x3332cf['name'],'pause':![]})[_0x05ea('0x13')](function(){return db[_0x05ea('0xad')][_0x05ea('0x23')]({'paused':0x0},{'where':{'UserId':_0x3332cf['id']}});})['then'](function(){return db[_0x05ea('0xf6')][_0x05ea('0x46')]({'where':{'membername':_0x3332cf[_0x05ea('0x2f')],'type':_0x05ea('0xfb'),'exitAt':null}});})['then'](function(_0x3a4091){var _0x58fe3b=[];_0x3a4091[_0x05ea('0xf7')](function(_0x2e8d01){_0x58fe3b[_0x05ea('0x45')](_0x2e8d01[_0x05ea('0x23')]({'exitAt':moment()[_0x05ea('0xe9')](_0x05ea('0xf8')),'data2':_0x05ea('0x106')}));});return BPromise[_0x05ea('0x51')](_0x58fe3b);})['then'](function(){return _0x3332cf[_0x05ea('0x23')]({'voicePause':![],'mailPause':![],'chatPause':![],'faxPause':![],'smsPause':![],'whatsappPause':![],'openchannelPause':![]});});}}})[_0x05ea('0x13')](respondWithResult(_0x4da072,null))[_0x05ea('0x1b')](handleError(_0x4da072,null));};exports['getTeams']=function(_0x5ec135,_0x42a6ab){var _0x3fe7a0={};var _0x419988={};var _0x2d15a4;var _0x1e4744;return db[_0x05ea('0x35')][_0x05ea('0x96')]({'where':{'id':_0x5ec135[_0x05ea('0x52')]['id']}})[_0x05ea('0x13')](handleEntityNotFound(_0x42a6ab,null))['then'](function(_0x3a6408){if(_0x3a6408){_0x2d15a4=_0x3a6408;_0x419988[_0x05ea('0x53')]=_[_0x05ea('0x55')](db[_0x05ea('0x109')][_0x05ea('0x36')]);_0x419988['query']=_[_0x05ea('0x55')](_0x5ec135[_0x05ea('0x40')]);_0x419988[_0x05ea('0x56')]=_['intersection'](_0x419988[_0x05ea('0x53')],_0x419988['query']);_0x3fe7a0['attributes']=_['intersection'](_0x419988[_0x05ea('0x53')],qs[_0x05ea('0x58')](_0x5ec135['query']['fields']));_0x3fe7a0[_0x05ea('0x44')]=_0x3fe7a0[_0x05ea('0x44')][_0x05ea('0x4a')]?_0x3fe7a0[_0x05ea('0x44')]:_0x419988['model'];_0x3fe7a0['order']=qs[_0x05ea('0xd3')](_0x5ec135[_0x05ea('0x40')][_0x05ea('0xd3')]);_0x3fe7a0[_0x05ea('0x3e')]=qs[_0x05ea('0x56')](_[_0x05ea('0xd4')](_0x5ec135[_0x05ea('0x40')],_0x419988[_0x05ea('0x56')]));if(_0x5ec135['query']['filter']){_0x3fe7a0[_0x05ea('0x3e')]=_['merge'](_0x3fe7a0[_0x05ea('0x3e')],{'$or':_['map'](_0x3fe7a0[_0x05ea('0x44')],function(_0xc8557f){var _0x11ce56={};_0x11ce56[_0xc8557f]={'$like':'%'+_0x5ec135[_0x05ea('0x40')]['filter']+'%'};return _0x11ce56;})});}_0x3fe7a0=_['merge']({},_0x3fe7a0,_0x5ec135[_0x05ea('0x5b')]);return _0x2d15a4[_0x05ea('0x10a')](_0x3fe7a0);}})[_0x05ea('0x13')](function(_0x5e92a8){if(_0x5e92a8){_0x1e4744=_0x5e92a8[_0x05ea('0x4a')];if(!_0x5ec135[_0x05ea('0x40')][_0x05ea('0xc8')](_0x05ea('0xcf'))){_0x3fe7a0[_0x05ea('0x20')]=qs[_0x05ea('0x20')](_0x5ec135[_0x05ea('0x40')][_0x05ea('0x20')]);_0x3fe7a0[_0x05ea('0x21')]=qs[_0x05ea('0x21')](_0x5ec135[_0x05ea('0x40')][_0x05ea('0x21')]);}return _0x2d15a4[_0x05ea('0x10a')](_0x3fe7a0);}})[_0x05ea('0x13')](function(_0x2024c7){if(_0x2024c7){return _0x2024c7?{'count':_0x1e4744,'rows':_0x2024c7}:null;}})['then'](respondWithResult(_0x42a6ab,null))['catch'](handleError(_0x42a6ab,null));};exports[_0x05ea('0x10b')]=function(_0x54475a,_0x2cb8c9){return db[_0x05ea('0x35')][_0x05ea('0x2e')]({'where':{'id':_0x54475a['params']['id']}})[_0x05ea('0x13')](handleEntityNotFound(_0x2cb8c9,null))[_0x05ea('0x13')](function(_0x17962f){if(_0x17962f){var _0x577a06=_0x17962f[_0x05ea('0xaa')]({'plain':!![]});return _0x17962f['addTeams'](_0x54475a[_0x05ea('0x5d')][_0x05ea('0x60')],_[_0x05ea('0x61')](_0x54475a['body'],['ids','id'])||{})['then'](function(){for(var _0x5de0bf=0x0;_0x5de0bf<_0x54475a[_0x05ea('0x5d')][_0x05ea('0x60')][_0x05ea('0x4a')];_0x5de0bf++){var _0x447742=[];var _0x496533={};db[_0x05ea('0x109')][_0x05ea('0x96')]({'where':{'id':_0x54475a[_0x05ea('0x5d')]['ids'][_0x5de0bf]}})[_0x05ea('0x13')](function(_0x579675){_0x496533=_0x579675[_0x05ea('0x4c')];_0x447742[_0x05ea('0x45')](_0x579675[_0x05ea('0xf3')]()[_0x05ea('0x13')](function(_0x99e36){for(var _0x15823b=0x0;_0x15823b<_0x99e36['length'];_0x15823b++){_0x99e36[_0x15823b][_0x05ea('0x10c')]('channel',_0x05ea('0x10d'));}return _0x99e36;}));_0x447742['push'](_0x579675['getChatQueues']()[_0x05ea('0x13')](function(_0x901756){for(var _0x25ab07=0x0;_0x25ab07<_0x901756[_0x05ea('0x4a')];_0x25ab07++){_0x901756[_0x25ab07][_0x05ea('0x10c')](_0x05ea('0x9b'),_0x05ea('0x10e'));}return _0x901756;}));_0x447742[_0x05ea('0x45')](_0x579675['getMailQueues']()[_0x05ea('0x13')](function(_0x48a1a0){for(var _0x35ba88=0x0;_0x35ba88<_0x48a1a0[_0x05ea('0x4a')];_0x35ba88++){_0x48a1a0[_0x35ba88][_0x05ea('0x10c')](_0x05ea('0x9b'),_0x05ea('0x10f'));}return _0x48a1a0;}));_0x447742[_0x05ea('0x45')](_0x579675[_0x05ea('0x110')]()['then'](function(_0x97f303){for(var _0x565bcb=0x0;_0x565bcb<_0x97f303[_0x05ea('0x4a')];_0x565bcb++){_0x97f303[_0x565bcb][_0x05ea('0x10c')](_0x05ea('0x9b'),_0x05ea('0x111'));}return _0x97f303;}));_0x447742[_0x05ea('0x45')](_0x579675[_0x05ea('0x112')]()[_0x05ea('0x13')](function(_0x3be75b){for(var _0x20f294=0x0;_0x20f294<_0x3be75b[_0x05ea('0x4a')];_0x20f294++){_0x3be75b[_0x20f294][_0x05ea('0x10c')](_0x05ea('0x9b'),_0x05ea('0x113'));}return _0x3be75b;}));_0x447742[_0x05ea('0x45')](_0x579675[_0x05ea('0x114')]()['then'](function(_0x5c8f86){for(var _0x367745=0x0;_0x367745<_0x5c8f86[_0x05ea('0x4a')];_0x367745++){_0x5c8f86[_0x367745][_0x05ea('0x10c')](_0x05ea('0x9b'),_0x05ea('0x115'));}return _0x5c8f86;}));_0x447742[_0x05ea('0x45')](_0x579675['getOpenchannelQueues']()[_0x05ea('0x13')](function(_0x57d331){for(var _0x45d3f5=0x0;_0x45d3f5<_0x57d331[_0x05ea('0x4a')];_0x45d3f5++){_0x57d331[_0x45d3f5][_0x05ea('0x10c')](_0x05ea('0x9b'),_0x05ea('0x116'));}return _0x57d331;}));return BPromise[_0x05ea('0x51')](_0x447742);})[_0x05ea('0x13')](function(_0x4b8358){var _0x189d80=_[_0x05ea('0x117')](_0x4b8358);_0x447742=[];return db[_0x05ea('0x67')][_0x05ea('0x118')](function(_0x7be568){for(var _0xc4db9f=0x0;_0xc4db9f<_0x189d80[_0x05ea('0x4a')];_0xc4db9f++){_0x447742['push'](_0x189d80[_0xc4db9f][_0x05ea('0x119')](_0x577a06['id']),{'transaction':_0x7be568});}return BPromise[_0x05ea('0x51')](_0x447742)[_0x05ea('0x13')](function(){if(_0x577a06[_0x05ea('0xab')]){return BPromise[_0x05ea('0x8b')](_[_0x05ea('0x2a')](_0x189d80,function(_0xcd5b29){return _0xcd5b29['getDataValue']('channel')===_0x05ea('0x10d');}),function(_0x2fb44a){return db[_0x05ea('0xad')]['upsert']({'membername':_0x577a06['name'],'UserId':_0x577a06['id'],'queue_name':_0x2fb44a['name'],'VoiceQueueId':_0x2fb44a['id'],'interface':_[_0x05ea('0x65')](_0x577a06['interface'])?util['format']('SIP/%s',_0x577a06[_0x05ea('0x2f')]):_0x577a06[_0x05ea('0x9e')],'paused':_0x577a06[_0x05ea('0x9d')]||![],'penalty':_0x577a06[_0x05ea('0xa2')]},{'transaction':_0x7be568});});}else{return;}})[_0x05ea('0x13')](function(){for(var _0x2f646b=0x0;_0x2f646b<_0x189d80[_0x05ea('0x4a')];_0x2f646b++){var _0x163f40=_0x189d80[_0x2f646b][_0x05ea('0x11a')](_0x05ea('0x9b'));var _0xb0cb2e=_0x163f40+'QueueId';socket[_0x05ea('0xa6')](_0x05ea('0x27')+_0x163f40+_0x05ea('0xa7'),{'UserId':_0x577a06['id'],['queueField']:_0x189d80[_0x2f646b]['id']});}});});})[_0x05ea('0x13')](function(){db[_0x05ea('0x11b')][_0x05ea('0x96')]({'where':{'teamId':_0x496533['id']}})[_0x05ea('0x13')](function(_0x52905a){if(_0x52905a){db[_0x05ea('0x11c')]['create']({'UserId':_0x54475a[_0x05ea('0x52')]['id'],'VoicePrefixId':_0x52905a[_0x05ea('0x11d')]});}});});}});}})['then'](respondWithStatusCode(_0x2cb8c9,null))[_0x05ea('0x1b')](handleError(_0x2cb8c9,null));};exports['removeTeams']=function(_0x4ae428,_0x84be83){return db[_0x05ea('0x35')][_0x05ea('0x96')]({'where':{'id':_0x4ae428[_0x05ea('0x52')]['id']}})['then'](handleEntityNotFound(_0x84be83,null))[_0x05ea('0x13')](function(_0x96ce8c){if(_0x96ce8c){var _0x3f350=_0x96ce8c['get']({'plain':!![]});var _0x5cd319=_0x4ae428[_0x05ea('0x40')]['ids'];return _0x96ce8c[_0x05ea('0x11e')](_0x5cd319)[_0x05ea('0x13')](function(){for(var _0x52982a=0x0;_0x52982a<_0x5cd319[_0x05ea('0x4a')];_0x52982a++){var _0x42f175=[];var _0x1cb740={};db[_0x05ea('0x109')][_0x05ea('0x96')]({'where':{'id':_0x5cd319[_0x52982a]}})[_0x05ea('0x13')](function(_0x5f28d4){_0x1cb740=_0x5f28d4[_0x05ea('0x4c')];_0x42f175[_0x05ea('0x45')](_0x5f28d4[_0x05ea('0xf3')]()[_0x05ea('0x13')](function(_0x2ff540){for(var _0x2527db=0x0;_0x2527db<_0x2ff540[_0x05ea('0x4a')];_0x2527db++){_0x2ff540[_0x2527db]['setDataValue'](_0x05ea('0x9b'),_0x05ea('0x10d'));}return _0x2ff540;}));_0x42f175['push'](_0x5f28d4[_0x05ea('0x11f')]()['then'](function(_0xa2778a){for(var _0x5ebef3=0x0;_0x5ebef3<_0xa2778a[_0x05ea('0x4a')];_0x5ebef3++){_0xa2778a[_0x5ebef3][_0x05ea('0x10c')]('channel','Chat');}return _0xa2778a;}));_0x42f175[_0x05ea('0x45')](_0x5f28d4[_0x05ea('0x120')]()[_0x05ea('0x13')](function(_0x4bacff){for(var _0x2dac7a=0x0;_0x2dac7a<_0x4bacff[_0x05ea('0x4a')];_0x2dac7a++){_0x4bacff[_0x2dac7a][_0x05ea('0x10c')]('channel',_0x05ea('0x10f'));}return _0x4bacff;}));_0x42f175[_0x05ea('0x45')](_0x5f28d4['getSmsQueues']()[_0x05ea('0x13')](function(_0x480995){for(var _0x5097a8=0x0;_0x5097a8<_0x480995[_0x05ea('0x4a')];_0x5097a8++){_0x480995[_0x5097a8][_0x05ea('0x10c')](_0x05ea('0x9b'),_0x05ea('0x111'));}return _0x480995;}));_0x42f175[_0x05ea('0x45')](_0x5f28d4[_0x05ea('0x112')]()[_0x05ea('0x13')](function(_0x148f33){for(var _0x52f836=0x0;_0x52f836<_0x148f33[_0x05ea('0x4a')];_0x52f836++){_0x148f33[_0x52f836]['setDataValue'](_0x05ea('0x9b'),_0x05ea('0x113'));}return _0x148f33;}));_0x42f175[_0x05ea('0x45')](_0x5f28d4[_0x05ea('0x114')]()[_0x05ea('0x13')](function(_0x2a1eea){for(var _0x9b7ada=0x0;_0x9b7ada<_0x2a1eea[_0x05ea('0x4a')];_0x9b7ada++){_0x2a1eea[_0x9b7ada][_0x05ea('0x10c')](_0x05ea('0x9b'),'Fax');}return _0x2a1eea;}));_0x42f175[_0x05ea('0x45')](_0x5f28d4[_0x05ea('0x121')]()[_0x05ea('0x13')](function(_0xb0c82d){for(var _0x61a56a=0x0;_0x61a56a<_0xb0c82d[_0x05ea('0x4a')];_0x61a56a++){_0xb0c82d[_0x61a56a]['setDataValue'](_0x05ea('0x9b'),_0x05ea('0x116'));}return _0xb0c82d;}));return BPromise['all'](_0x42f175);})[_0x05ea('0x13')](function(_0x87c805){var _0x2b8e8b=_[_0x05ea('0x117')](_0x87c805);_0x42f175=[];return db['sequelize']['transaction'](function(_0x12182b){for(var _0x3c4fc5=0x0;_0x3c4fc5<_0x2b8e8b[_0x05ea('0x4a')];_0x3c4fc5++){_0x42f175['push'](_0x2b8e8b[_0x3c4fc5]['removeAgent'](_0x3f350['id']),{'transaction':_0x12182b});}return BPromise['all'](_0x42f175)[_0x05ea('0x13')](function(){if(_0x3f350[_0x05ea('0xab')]){return BPromise[_0x05ea('0x8b')](_[_0x05ea('0x2a')](_0x2b8e8b,function(_0x2ce8aa){return _0x2ce8aa[_0x05ea('0x11a')]('channel')===_0x05ea('0x10d');}),function(_0x15efc5){return db[_0x05ea('0xad')][_0x05ea('0x31')]({'where':{'VoiceQueueId':_0x15efc5['id'],'UserId':_0x3f350['id']},'transaction':_0x12182b});});}else{return;}})[_0x05ea('0x13')](function(){db[_0x05ea('0x11b')][_0x05ea('0x96')]({'where':{'teamId':_0x1cb740['id']}})[_0x05ea('0x13')](function(_0x19f2df){if(_0x19f2df){return db[_0x05ea('0x11c')]['destroy']({'where':{'UserId':_0x3f350['id'],'VoicePrefixId':_0x19f2df[_0x05ea('0x4c')][_0x05ea('0x11d')]}});}});})[_0x05ea('0x13')](function(){for(var _0x26ee79=0x0;_0x26ee79<_0x2b8e8b['length'];_0x26ee79++){var _0x10974a=_0x2b8e8b[_0x26ee79][_0x05ea('0x11a')](_0x05ea('0x9b'));var _0x511503=_0x10974a+_0x05ea('0xa5');socket[_0x05ea('0xa6')](_0x05ea('0x27')+_0x10974a+_0x05ea('0xb1'),{'UserId':_0x3f350['id'],['queueField']:_0x2b8e8b[_0x26ee79]['id']});}});});});}});}})[_0x05ea('0x13')](respondWithStatusCode(_0x84be83,null))['catch'](handleError(_0x84be83,null));};exports[_0x05ea('0x122')]=function(_0x3caa4b,_0x2657fb){var _0x38f04d={};var _0x1811aa={};var _0x5bfc62;var _0x35d995;return db['User']['findOne']({'where':{'id':_0x3caa4b[_0x05ea('0x52')]['id']}})[_0x05ea('0x13')](handleEntityNotFound(_0x2657fb,null))[_0x05ea('0x13')](function(_0x1fcdfb){if(_0x1fcdfb){_0x5bfc62=_0x1fcdfb;_0x1811aa['model']=_[_0x05ea('0x55')](db['CmList'][_0x05ea('0x36')]);_0x1811aa[_0x05ea('0x40')]=_['keys'](_0x3caa4b[_0x05ea('0x40')]);_0x1811aa['filters']=_[_0x05ea('0x57')](_0x1811aa['model'],_0x1811aa[_0x05ea('0x40')]);_0x38f04d[_0x05ea('0x44')]=_[_0x05ea('0x57')](_0x1811aa['model'],qs['fields'](_0x3caa4b[_0x05ea('0x40')][_0x05ea('0x58')]));_0x38f04d[_0x05ea('0x44')]=_0x38f04d[_0x05ea('0x44')][_0x05ea('0x4a')]?_0x38f04d[_0x05ea('0x44')]:_0x1811aa['model'];_0x38f04d[_0x05ea('0xd2')]=qs[_0x05ea('0xd3')](_0x3caa4b[_0x05ea('0x40')]['sort']);_0x38f04d['where']=qs['filters'](_[_0x05ea('0xd4')](_0x3caa4b[_0x05ea('0x40')],_0x1811aa['filters']));if(_0x3caa4b[_0x05ea('0x40')]['filter']){_0x38f04d[_0x05ea('0x3e')]=_[_0x05ea('0x5a')](_0x38f04d['where'],{'$or':_['map'](_0x38f04d[_0x05ea('0x44')],function(_0x488b51){var _0xd8d0d1={};_0xd8d0d1[_0x488b51]={'$like':'%'+_0x3caa4b[_0x05ea('0x40')][_0x05ea('0x2a')]+'%'};return _0xd8d0d1;})});}_0x38f04d=_[_0x05ea('0x5a')]({},_0x38f04d,_0x3caa4b[_0x05ea('0x5b')]);return _0x5bfc62['getLists'](_0x38f04d);}})[_0x05ea('0x13')](function(_0x31bf8a){if(_0x31bf8a){_0x35d995=_0x31bf8a[_0x05ea('0x4a')];if(!_0x3caa4b[_0x05ea('0x40')][_0x05ea('0xc8')](_0x05ea('0xcf'))){_0x38f04d[_0x05ea('0x20')]=qs[_0x05ea('0x20')](_0x3caa4b[_0x05ea('0x40')][_0x05ea('0x20')]);_0x38f04d['offset']=qs[_0x05ea('0x21')](_0x3caa4b[_0x05ea('0x40')]['offset']);}return _0x5bfc62[_0x05ea('0x122')](_0x38f04d);}})[_0x05ea('0x13')](function(_0x251748){if(_0x251748){return _0x251748?{'count':_0x35d995,'rows':_0x251748}:null;}})[_0x05ea('0x13')](respondWithResult(_0x2657fb,null))[_0x05ea('0x1b')](handleError(_0x2657fb,null));};exports[_0x05ea('0x123')]=function(_0x21d603,_0x589323){var _0x1b691e={};var _0x407aee={};var _0x2bc7c3;return db['User'][_0x05ea('0x96')]({'where':{'id':_0x21d603[_0x05ea('0x52')]['id']}})[_0x05ea('0x13')](handleEntityNotFound(_0x589323,null))[_0x05ea('0x13')](function(_0xf03de0){if(_0xf03de0){_0x2bc7c3=_0xf03de0;_0x407aee[_0x05ea('0x53')]=_[_0x05ea('0x55')](db[_0x05ea('0x35')][_0x05ea('0x36')]);_0x407aee[_0x05ea('0x40')]=_[_0x05ea('0x55')](_0x21d603[_0x05ea('0x40')]);_0x407aee[_0x05ea('0x56')]=_[_0x05ea('0x57')](_0x407aee[_0x05ea('0x53')],_0x407aee[_0x05ea('0x40')]);_0x1b691e[_0x05ea('0x44')]=_['intersection'](_0x407aee['model'],qs[_0x05ea('0x58')](_0x21d603[_0x05ea('0x40')][_0x05ea('0x58')]));_0x1b691e[_0x05ea('0x44')]=_0x1b691e['attributes'][_0x05ea('0x4a')]?_0x1b691e[_0x05ea('0x44')]:_0x407aee['model'];_0x1b691e[_0x05ea('0xd2')]=qs[_0x05ea('0xd3')](_0x21d603[_0x05ea('0x40')]['sort']);_0x1b691e[_0x05ea('0x3e')]=qs[_0x05ea('0x56')](_[_0x05ea('0xd4')](_0x21d603['query'],_0x407aee['filters']));if(_0x21d603[_0x05ea('0x40')][_0x05ea('0x2a')]){_0x1b691e[_0x05ea('0x3e')]=_[_0x05ea('0x5a')](_0x1b691e[_0x05ea('0x3e')],{'$or':_[_0x05ea('0x37')](_0x1b691e[_0x05ea('0x44')],function(_0x295810){var _0x21cab5={};_0x21cab5[_0x295810]={'$like':'%'+_0x21d603[_0x05ea('0x40')]['filter']+'%'};return _0x21cab5;})});}_0x1b691e[_0x05ea('0x53')]=db['User'];_0x1b691e['as']='Agents';_0x1b691e=_['merge']({},_0x1b691e,_0x21d603[_0x05ea('0x5b')]);return _0x2bc7c3[_0x05ea('0xf3')]({'include':[_0x1b691e]});}})[_0x05ea('0x13')](function(_0x55c8d0){if(_0x55c8d0){var _0x4bead5={},_0x1d6e4b=[];for(var _0x4b87f6=0x0;_0x4b87f6<_0x55c8d0[_0x05ea('0x4a')];_0x4b87f6+=0x1){for(var _0x4095b7=0x0,_0x252177;_0x4095b7<_0x55c8d0[_0x4b87f6][_0x05ea('0x84')][_0x05ea('0x4a')];_0x4095b7+=0x1){_0x252177=_0x55c8d0[_0x4b87f6][_0x05ea('0x84')][_0x4095b7][_0x05ea('0xaa')]({'plain':!![]});_0x4bead5[_0x252177['id']]=_0x252177;}}_0x4bead5=_['values'](_0x4bead5);for(var _0x109d3c=qs['offset'](_0x21d603['query'][_0x05ea('0x21')]);_0x109d3c<_0x4bead5[_0x05ea('0x4a')]&&_0x1d6e4b[_0x05ea('0x4a')]<qs['limit'](_0x21d603[_0x05ea('0x40')][_0x05ea('0x20')]);_0x109d3c+=0x1){if(_0x4bead5[_0x109d3c]){_0x1d6e4b[_0x05ea('0x45')](_0x4bead5[_0x109d3c]);}}return{'count':_0x4bead5['length'],'rows':_0x1d6e4b};}})['then'](respondWithResult(_0x589323,null))[_0x05ea('0x1b')](handleError(_0x589323,null));};exports[_0x05ea('0x31')]=function(_0x2d4025,_0xcc40a){if(_0x2d4025[_0x05ea('0x27')]['id']==_0x2d4025[_0x05ea('0x52')]['id']){return _0xcc40a[_0x05ea('0x1d')](0x1f4)[_0x05ea('0x34')]({'message':_0x05ea('0x124')});}return db[_0x05ea('0x35')][_0x05ea('0x2e')]({'where':{'id':_0x2d4025[_0x05ea('0x52')]['id']}})['then'](handleEntityNotFound(_0xcc40a,null))[_0x05ea('0x13')](removeEntity(_0xcc40a,null))['catch'](handleError(_0xcc40a,null));};exports[_0x05ea('0x125')]=function(_0x593c65,_0x25bf9e){return db['User'][_0x05ea('0x2e')]({'where':{'id':_0x593c65[_0x05ea('0x52')]['id']}})[_0x05ea('0x13')](handleEntityNotFound(_0x25bf9e,null))['then'](function(_0x2728ce){if(_0x2728ce){return _0x2728ce['addChatInteractions'](_0x593c65['body']['ids'],_[_0x05ea('0x61')](_0x593c65[_0x05ea('0x5d')],['ids','id'])||{})[_0x05ea('0xa3')](function(){for(var _0x22f8a5=0x0;_0x22f8a5<_0x593c65[_0x05ea('0x5d')][_0x05ea('0x60')][_0x05ea('0x4a')];_0x22f8a5+=0x1){socket[_0x05ea('0xa6')](_0x05ea('0x126'),{'ChatInteractionId':Number(_0x593c65[_0x05ea('0x5d')][_0x05ea('0x60')][_0x22f8a5]),'UserId':Number(_0x593c65['params']['id'])});}return _0x593c65[_0x05ea('0x5d')][_0x05ea('0x60')];});}})[_0x05ea('0x13')](respondWithResult(_0x25bf9e,null))[_0x05ea('0x1b')](handleError(_0x25bf9e,null));};exports[_0x05ea('0x127')]=function(_0x3ab1c1,_0x4a914b){return db[_0x05ea('0x35')][_0x05ea('0x2e')]({'where':{'id':_0x3ab1c1[_0x05ea('0x52')]['id']}})[_0x05ea('0x13')](handleEntityNotFound(_0x4a914b,null))[_0x05ea('0x13')](function(_0x2fa33a){if(_0x2fa33a){return _0x2fa33a[_0x05ea('0x127')](_0x3ab1c1['query'][_0x05ea('0x60')])['then'](function(){if(_[_0x05ea('0x128')](_0x3ab1c1[_0x05ea('0x40')][_0x05ea('0x60')])){for(var _0x575cf1=0x0;_0x575cf1<_0x3ab1c1[_0x05ea('0x40')]['ids']['length'];_0x575cf1+=0x1){socket[_0x05ea('0xa6')](_0x05ea('0x129'),{'ChatInteractionId':Number(_0x3ab1c1['query'][_0x05ea('0x60')][_0x575cf1]),'UserId':Number(_0x3ab1c1[_0x05ea('0x52')]['id'])});}}else{socket[_0x05ea('0xa6')](_0x05ea('0x129'),{'ChatInteractionId':Number(_0x3ab1c1[_0x05ea('0x40')]['ids']),'UserId':Number(_0x3ab1c1[_0x05ea('0x52')]['id'])});}});}})[_0x05ea('0x13')](respondWithStatusCode(_0x4a914b,null))[_0x05ea('0x1b')](handleError(_0x4a914b,null));};exports['addMailInteractions']=function(_0x185f68,_0x3528a6){return db[_0x05ea('0x35')]['find']({'where':{'id':_0x185f68['params']['id']}})[_0x05ea('0x13')](handleEntityNotFound(_0x3528a6,null))[_0x05ea('0x13')](function(_0x1dcf43){if(_0x1dcf43){return _0x1dcf43[_0x05ea('0x12a')](_0x185f68[_0x05ea('0x5d')][_0x05ea('0x60')],_[_0x05ea('0x61')](_0x185f68[_0x05ea('0x5d')],[_0x05ea('0x60'),'id'])||{})[_0x05ea('0xa3')](function(){for(var _0x5e0943=0x0;_0x5e0943<_0x185f68[_0x05ea('0x5d')][_0x05ea('0x60')]['length'];_0x5e0943+=0x1){socket[_0x05ea('0xa6')](_0x05ea('0x12b'),{'MailInteractionId':Number(_0x185f68[_0x05ea('0x5d')]['ids'][_0x5e0943]),'UserId':Number(_0x185f68[_0x05ea('0x52')]['id'])});}return _0x185f68[_0x05ea('0x5d')][_0x05ea('0x60')];});}})[_0x05ea('0x13')](respondWithResult(_0x3528a6,null))['catch'](handleError(_0x3528a6,null));};exports['removeMailInteractions']=function(_0x5b9395,_0x2e64b1){return db[_0x05ea('0x35')][_0x05ea('0x2e')]({'where':{'id':_0x5b9395[_0x05ea('0x52')]['id']}})['then'](handleEntityNotFound(_0x2e64b1,null))[_0x05ea('0x13')](function(_0x43fc87){if(_0x43fc87){return _0x43fc87[_0x05ea('0x12c')](_0x5b9395['query']['ids'])[_0x05ea('0x13')](function(){if(_['isArray'](_0x5b9395['query'][_0x05ea('0x60')])){for(var _0x892f2=0x0;_0x892f2<_0x5b9395[_0x05ea('0x40')][_0x05ea('0x60')][_0x05ea('0x4a')];_0x892f2+=0x1){socket[_0x05ea('0xa6')]('user_has_mail_interactions:remove',{'MailInteractionId':Number(_0x5b9395[_0x05ea('0x40')][_0x05ea('0x60')][_0x892f2]),'UserId':Number(_0x5b9395['params']['id'])});}}else{socket[_0x05ea('0xa6')](_0x05ea('0x12d'),{'MailInteractionId':Number(_0x5b9395[_0x05ea('0x40')][_0x05ea('0x60')]),'UserId':Number(_0x5b9395[_0x05ea('0x52')]['id'])});}});}})['then'](respondWithStatusCode(_0x2e64b1,null))[_0x05ea('0x1b')](handleError(_0x2e64b1,null));};exports[_0x05ea('0x12e')]=function(_0x431cdc,_0x5c7ad5){return db[_0x05ea('0x35')][_0x05ea('0x2e')]({'where':{'id':_0x431cdc[_0x05ea('0x52')]['id']}})[_0x05ea('0x13')](handleEntityNotFound(_0x5c7ad5,null))[_0x05ea('0x13')](function(_0x46e0cf){if(_0x46e0cf){return _0x46e0cf[_0x05ea('0x12e')](_0x431cdc[_0x05ea('0x5d')]['ids'],_['omit'](_0x431cdc[_0x05ea('0x5d')],[_0x05ea('0x60'),'id'])||{})[_0x05ea('0xa3')](function(){for(var _0x1a8f0e=0x0;_0x1a8f0e<_0x431cdc[_0x05ea('0x5d')][_0x05ea('0x60')][_0x05ea('0x4a')];_0x1a8f0e+=0x1){socket[_0x05ea('0xa6')]('user_has_fax_interactions:save',{'FaxInteractionId':Number(_0x431cdc[_0x05ea('0x5d')]['ids'][_0x1a8f0e]),'UserId':Number(_0x431cdc[_0x05ea('0x52')]['id'])});}return _0x431cdc['body']['ids'];});}})['then'](respondWithResult(_0x5c7ad5,null))[_0x05ea('0x1b')](handleError(_0x5c7ad5,null));};exports['removeFaxInteractions']=function(_0x482379,_0x4fc8d6){return db[_0x05ea('0x35')]['find']({'where':{'id':_0x482379[_0x05ea('0x52')]['id']}})[_0x05ea('0x13')](handleEntityNotFound(_0x4fc8d6,null))[_0x05ea('0x13')](function(_0x29aeb6){if(_0x29aeb6){return _0x29aeb6[_0x05ea('0x12f')](_0x482379[_0x05ea('0x40')][_0x05ea('0x60')])[_0x05ea('0x13')](function(){if(_[_0x05ea('0x128')](_0x482379['query']['ids'])){for(var _0x44f1c8=0x0;_0x44f1c8<_0x482379[_0x05ea('0x40')][_0x05ea('0x60')]['length'];_0x44f1c8+=0x1){socket[_0x05ea('0xa6')](_0x05ea('0x130'),{'FaxInteractionId':Number(_0x482379[_0x05ea('0x40')][_0x05ea('0x60')][_0x44f1c8]),'UserId':Number(_0x482379[_0x05ea('0x52')]['id'])});}}else{socket['emit'](_0x05ea('0x130'),{'FaxInteractionId':Number(_0x482379['query'][_0x05ea('0x60')]),'UserId':Number(_0x482379['params']['id'])});}});}})['then'](respondWithStatusCode(_0x4fc8d6,null))[_0x05ea('0x1b')](handleError(_0x4fc8d6,null));};exports['addSmsInteractions']=function(_0x3ad392,_0x3f3c22){return db[_0x05ea('0x35')][_0x05ea('0x2e')]({'where':{'id':_0x3ad392[_0x05ea('0x52')]['id']}})[_0x05ea('0x13')](handleEntityNotFound(_0x3f3c22,null))['then'](function(_0x500d5d){if(_0x500d5d){return _0x500d5d[_0x05ea('0x131')](_0x3ad392[_0x05ea('0x5d')][_0x05ea('0x60')],_[_0x05ea('0x61')](_0x3ad392['body'],[_0x05ea('0x60'),'id'])||{})[_0x05ea('0xa3')](function(){for(var _0x56b908=0x0;_0x56b908<_0x3ad392[_0x05ea('0x5d')][_0x05ea('0x60')][_0x05ea('0x4a')];_0x56b908+=0x1){socket[_0x05ea('0xa6')](_0x05ea('0x132'),{'SmsInteractionId':Number(_0x3ad392['body'][_0x05ea('0x60')][_0x56b908]),'UserId':Number(_0x3ad392[_0x05ea('0x52')]['id'])});}return _0x3ad392['body'][_0x05ea('0x60')];});}})[_0x05ea('0x13')](respondWithResult(_0x3f3c22,null))['catch'](handleError(_0x3f3c22,null));};exports[_0x05ea('0x133')]=function(_0x4f1c77,_0x306761){return db[_0x05ea('0x35')][_0x05ea('0x2e')]({'where':{'id':_0x4f1c77[_0x05ea('0x52')]['id']}})[_0x05ea('0x13')](handleEntityNotFound(_0x306761,null))['then'](function(_0x3c279d){if(_0x3c279d){return _0x3c279d[_0x05ea('0x133')](_0x4f1c77[_0x05ea('0x40')][_0x05ea('0x60')])[_0x05ea('0x13')](function(){if(_[_0x05ea('0x128')](_0x4f1c77[_0x05ea('0x40')][_0x05ea('0x60')])){for(var _0x5b6878=0x0;_0x5b6878<_0x4f1c77[_0x05ea('0x40')][_0x05ea('0x60')][_0x05ea('0x4a')];_0x5b6878+=0x1){socket[_0x05ea('0xa6')](_0x05ea('0x134'),{'SmsInteractionId':Number(_0x4f1c77[_0x05ea('0x40')][_0x05ea('0x60')][_0x5b6878]),'UserId':Number(_0x4f1c77['params']['id'])});}}else{socket[_0x05ea('0xa6')]('user_has_sms_interactions:remove',{'SmsInteractionId':Number(_0x4f1c77[_0x05ea('0x40')][_0x05ea('0x60')]),'UserId':Number(_0x4f1c77[_0x05ea('0x52')]['id'])});}});}})[_0x05ea('0x13')](respondWithStatusCode(_0x306761,null))[_0x05ea('0x1b')](handleError(_0x306761,null));};exports[_0x05ea('0x135')]=function(_0x415cb4,_0x46627a){return db[_0x05ea('0x35')][_0x05ea('0x2e')]({'where':{'id':_0x415cb4[_0x05ea('0x52')]['id']}})[_0x05ea('0x13')](handleEntityNotFound(_0x46627a,null))[_0x05ea('0x13')](function(_0x32a3b4){if(_0x32a3b4){return _0x32a3b4[_0x05ea('0x135')](_0x415cb4[_0x05ea('0x5d')][_0x05ea('0x60')],_['omit'](_0x415cb4['body'],['ids','id'])||{})[_0x05ea('0xa3')](function(){for(var _0x576aed=0x0;_0x576aed<_0x415cb4[_0x05ea('0x5d')][_0x05ea('0x60')][_0x05ea('0x4a')];_0x576aed+=0x1){socket[_0x05ea('0xa6')]('user_has_openchannel_interactions:save',{'OpenchannelInteractionId':Number(_0x415cb4[_0x05ea('0x5d')][_0x05ea('0x60')][_0x576aed]),'UserId':Number(_0x415cb4[_0x05ea('0x52')]['id'])});}return _0x415cb4[_0x05ea('0x5d')]['ids'];});}})[_0x05ea('0x13')](respondWithResult(_0x46627a,null))[_0x05ea('0x1b')](handleError(_0x46627a,null));};exports[_0x05ea('0x136')]=function(_0xbea718,_0x5e675d){return db['User'][_0x05ea('0x2e')]({'where':{'id':_0xbea718['params']['id']}})[_0x05ea('0x13')](handleEntityNotFound(_0x5e675d,null))['then'](function(_0x18d1aa){if(_0x18d1aa){return _0x18d1aa[_0x05ea('0x136')](_0xbea718[_0x05ea('0x40')]['ids'])['then'](function(){if(_['isArray'](_0xbea718[_0x05ea('0x40')][_0x05ea('0x60')])){for(var _0x24bf7c=0x0;_0x24bf7c<_0xbea718[_0x05ea('0x40')]['ids'][_0x05ea('0x4a')];_0x24bf7c+=0x1){socket[_0x05ea('0xa6')](_0x05ea('0x137'),{'OpenchannelInteractionId':Number(_0xbea718[_0x05ea('0x40')][_0x05ea('0x60')][_0x24bf7c]),'UserId':Number(_0xbea718[_0x05ea('0x52')]['id'])});}}else{socket[_0x05ea('0xa6')](_0x05ea('0x137'),{'OpenchannelInteractionId':Number(_0xbea718[_0x05ea('0x40')][_0x05ea('0x60')]),'UserId':Number(_0xbea718[_0x05ea('0x52')]['id'])});}});}})[_0x05ea('0x13')](respondWithStatusCode(_0x5e675d,null))[_0x05ea('0x1b')](handleError(_0x5e675d,null));};exports['addWhatsappInteractions']=function(_0x1235d6,_0x7e4411){return db[_0x05ea('0x35')][_0x05ea('0x2e')]({'where':{'id':_0x1235d6['params']['id']}})[_0x05ea('0x13')](handleEntityNotFound(_0x7e4411,null))['then'](function(_0x48de3e){if(_0x48de3e){return _0x48de3e[_0x05ea('0x138')](_0x1235d6[_0x05ea('0x5d')]['ids'],_[_0x05ea('0x61')](_0x1235d6['body'],['ids','id'])||{})['spread'](function(){for(var _0x5aab00=0x0;_0x5aab00<_0x1235d6['body'][_0x05ea('0x60')][_0x05ea('0x4a')];_0x5aab00+=0x1){socket[_0x05ea('0xa6')]('user_has_whatsapp_interactions:save',{'WhatsappInteractionId':Number(_0x1235d6[_0x05ea('0x5d')][_0x05ea('0x60')][_0x5aab00]),'UserId':Number(_0x1235d6[_0x05ea('0x52')]['id'])});}return _0x1235d6[_0x05ea('0x5d')][_0x05ea('0x60')];});}})[_0x05ea('0x13')](respondWithResult(_0x7e4411,null))['catch'](handleError(_0x7e4411,null));};exports[_0x05ea('0x139')]=function(_0x1f0480,_0xfc5223){return db['User'][_0x05ea('0x2e')]({'where':{'id':_0x1f0480['params']['id']}})[_0x05ea('0x13')](handleEntityNotFound(_0xfc5223,null))['then'](function(_0x129f5c){if(_0x129f5c){return _0x129f5c[_0x05ea('0x139')](_0x1f0480[_0x05ea('0x40')][_0x05ea('0x60')]);}})[_0x05ea('0x13')](respondWithStatusCode(_0xfc5223,null))[_0x05ea('0x1b')](handleError(_0xfc5223,null));};exports[_0x05ea('0x13a')]=function(_0x478cff,_0x2ee59e){var _0x5d261d={};var _0x5c97ed={};var _0x4585ea;var _0xba8ee1;return db[_0x05ea('0x35')][_0x05ea('0x96')]({'where':{'id':_0x478cff['params']['id']}})[_0x05ea('0x13')](handleEntityNotFound(_0x2ee59e,null))['then'](function(_0x5a5abf){if(_0x5a5abf){_0x4585ea=_0x5a5abf;_0x5c97ed[_0x05ea('0x53')]=_[_0x05ea('0x55')](db[_0x05ea('0x13b')][_0x05ea('0x36')]);_0x5c97ed[_0x05ea('0x40')]=_[_0x05ea('0x55')](_0x478cff[_0x05ea('0x40')]);_0x5c97ed[_0x05ea('0x56')]=_[_0x05ea('0x57')](_0x5c97ed[_0x05ea('0x53')],_0x5c97ed[_0x05ea('0x40')]);_0x5d261d[_0x05ea('0x44')]=_['intersection'](_0x5c97ed[_0x05ea('0x53')],qs[_0x05ea('0x58')](_0x478cff[_0x05ea('0x40')][_0x05ea('0x58')]));_0x5d261d[_0x05ea('0x44')]=_0x5d261d[_0x05ea('0x44')][_0x05ea('0x4a')]?_0x5d261d[_0x05ea('0x44')]:_0x5c97ed[_0x05ea('0x53')];_0x5d261d['order']=qs[_0x05ea('0xd3')](_0x478cff[_0x05ea('0x40')][_0x05ea('0xd3')]);_0x5d261d[_0x05ea('0x3e')]=qs[_0x05ea('0x56')](_[_0x05ea('0xd4')](_0x478cff[_0x05ea('0x40')],_0x5c97ed[_0x05ea('0x56')]));if(_0x478cff[_0x05ea('0x40')][_0x05ea('0x2a')]){_0x5d261d['where']=_['merge'](_0x5d261d[_0x05ea('0x3e')],{'$or':_['map'](_0x5d261d[_0x05ea('0x44')],function(_0x5c1e45){var _0x2433e0={};_0x2433e0[_0x5c1e45]={'$like':'%'+_0x478cff['query']['filter']+'%'};return _0x2433e0;})});}_0x5d261d=_[_0x05ea('0x5a')]({},_0x5d261d,_0x478cff['options']);return _0x4585ea['getVoicePrefixes'](_0x5d261d);}})[_0x05ea('0x13')](function(_0x4ed5f5){if(_0x4ed5f5){_0xba8ee1=_0x4ed5f5[_0x05ea('0x4a')];if(!_0x478cff[_0x05ea('0x40')][_0x05ea('0xc8')](_0x05ea('0xcf'))){_0x5d261d[_0x05ea('0x20')]=qs[_0x05ea('0x20')](_0x478cff[_0x05ea('0x40')]['limit']);_0x5d261d[_0x05ea('0x21')]=qs[_0x05ea('0x21')](_0x478cff['query'][_0x05ea('0x21')]);}return _0x4585ea[_0x05ea('0x13a')](_0x5d261d);}})[_0x05ea('0x13')](function(_0x3a0599){if(_0x3a0599){return _0x3a0599?{'count':_0xba8ee1,'rows':_0x3a0599}:null;}})[_0x05ea('0x13')](respondWithResult(_0x2ee59e,null))['catch'](handleError(_0x2ee59e,null));};exports['getFaxAccounts']=function(_0x464672,_0x3f5081){var _0x309a8a={};var _0x211927={};var _0x129ae2;var _0x146286;return db[_0x05ea('0x35')][_0x05ea('0x96')]({'where':{'id':_0x464672[_0x05ea('0x52')]['id']}})[_0x05ea('0x13')](handleEntityNotFound(_0x3f5081,null))['then'](function(_0x3334dc){if(_0x3334dc){_0x129ae2=_0x3334dc;_0x211927['model']=_[_0x05ea('0x55')](db['FaxAccount'][_0x05ea('0x36')]);_0x211927['query']=_[_0x05ea('0x55')](_0x464672[_0x05ea('0x40')]);_0x211927[_0x05ea('0x56')]=_[_0x05ea('0x57')](_0x211927[_0x05ea('0x53')],_0x211927['query']);_0x309a8a[_0x05ea('0x44')]=_['intersection'](_0x211927[_0x05ea('0x53')],qs[_0x05ea('0x58')](_0x464672['query'][_0x05ea('0x58')]));_0x309a8a['attributes']=_0x309a8a[_0x05ea('0x44')]['length']?_0x309a8a[_0x05ea('0x44')]:_0x211927[_0x05ea('0x53')];_0x309a8a[_0x05ea('0xd2')]=qs[_0x05ea('0xd3')](_0x464672[_0x05ea('0x40')]['sort']);_0x309a8a[_0x05ea('0x3e')]=qs[_0x05ea('0x56')](_[_0x05ea('0xd4')](_0x464672['query'],_0x211927[_0x05ea('0x56')]));if(_0x464672[_0x05ea('0x40')][_0x05ea('0x2a')]){_0x309a8a['where']=_[_0x05ea('0x5a')](_0x309a8a[_0x05ea('0x3e')],{'$or':_[_0x05ea('0x37')](_0x309a8a[_0x05ea('0x44')],function(_0x4b490a){var _0x594f62={};_0x594f62[_0x4b490a]={'$like':'%'+_0x464672[_0x05ea('0x40')][_0x05ea('0x2a')]+'%'};return _0x594f62;})});}_0x309a8a=_[_0x05ea('0x5a')]({},_0x309a8a,_0x464672['options']);return _0x129ae2[_0x05ea('0x13c')](_0x309a8a);}})[_0x05ea('0x13')](function(_0x38b0ac){if(_0x38b0ac){_0x146286=_0x38b0ac['length'];if(!_0x464672[_0x05ea('0x40')][_0x05ea('0xc8')](_0x05ea('0xcf'))){_0x309a8a[_0x05ea('0x20')]=qs[_0x05ea('0x20')](_0x464672['query'][_0x05ea('0x20')]);_0x309a8a['offset']=qs[_0x05ea('0x21')](_0x464672[_0x05ea('0x40')][_0x05ea('0x21')]);}return _0x129ae2[_0x05ea('0x13c')](_0x309a8a);}})['then'](function(_0x21b5df){if(_0x21b5df){return _0x21b5df?{'count':_0x146286,'rows':_0x21b5df}:null;}})[_0x05ea('0x13')](respondWithResult(_0x3f5081,null))['catch'](handleError(_0x3f5081,null));};exports[_0x05ea('0x13d')]=function(_0x37dbdf,_0x712f93){return db[_0x05ea('0x35')][_0x05ea('0x2e')]({'where':{'id':_0x37dbdf['params']['id']}})[_0x05ea('0x13')](handleEntityNotFound(_0x712f93,null))[_0x05ea('0x13')](function(_0x4649d2){if(_0x4649d2){return _0x4649d2[_0x05ea('0x13d')](_0x37dbdf[_0x05ea('0x5d')]['ids'],_['omit'](_0x37dbdf[_0x05ea('0x5d')],[_0x05ea('0x60'),'id'])||{});}})['then'](respondWithResult(_0x712f93,null))[_0x05ea('0x1b')](handleError(_0x712f93,null));};exports['removeFaxAccounts']=function(_0x13be41,_0x10ec50){return db[_0x05ea('0x35')][_0x05ea('0x2e')]({'where':{'id':_0x13be41['params']['id']}})[_0x05ea('0x13')](handleEntityNotFound(_0x10ec50,null))[_0x05ea('0x13')](function(_0x4a6c62){if(_0x4a6c62){return _0x4a6c62[_0x05ea('0x13e')](_0x13be41[_0x05ea('0x40')][_0x05ea('0x60')]);}})[_0x05ea('0x13')](respondWithStatusCode(_0x10ec50,null))[_0x05ea('0x1b')](handleError(_0x10ec50,null));};exports['getMailAccounts']=function(_0x2d1e83,_0x300ab7){var _0x2ec8b6={};var _0x3a38fc={};var _0x59b77e;var _0x21c08f;return db[_0x05ea('0x35')][_0x05ea('0x96')]({'where':{'id':_0x2d1e83[_0x05ea('0x52')]['id']}})[_0x05ea('0x13')](handleEntityNotFound(_0x300ab7,null))[_0x05ea('0x13')](function(_0x3ba596){if(_0x3ba596){_0x59b77e=_0x3ba596;_0x3a38fc[_0x05ea('0x53')]=_[_0x05ea('0x55')](db[_0x05ea('0x13f')][_0x05ea('0x36')]);_0x3a38fc[_0x05ea('0x40')]=_['keys'](_0x2d1e83['query']);_0x3a38fc[_0x05ea('0x56')]=_[_0x05ea('0x57')](_0x3a38fc[_0x05ea('0x53')],_0x3a38fc[_0x05ea('0x40')]);_0x2ec8b6['attributes']=_['intersection'](_0x3a38fc[_0x05ea('0x53')],qs[_0x05ea('0x58')](_0x2d1e83[_0x05ea('0x40')]['fields']));_0x2ec8b6[_0x05ea('0x44')]=_0x2ec8b6[_0x05ea('0x44')]['length']?_0x2ec8b6['attributes']:_0x3a38fc[_0x05ea('0x53')];_0x2ec8b6[_0x05ea('0xd2')]=qs[_0x05ea('0xd3')](_0x2d1e83[_0x05ea('0x40')][_0x05ea('0xd3')]);_0x2ec8b6[_0x05ea('0x3e')]=qs[_0x05ea('0x56')](_['pick'](_0x2d1e83[_0x05ea('0x40')],_0x3a38fc['filters']));if(_0x2d1e83[_0x05ea('0x40')][_0x05ea('0x2a')]){_0x2ec8b6[_0x05ea('0x3e')]=_[_0x05ea('0x5a')](_0x2ec8b6['where'],{'$or':_[_0x05ea('0x37')](_0x2ec8b6['attributes'],function(_0x99bba4){var _0x393dd5={};_0x393dd5[_0x99bba4]={'$like':'%'+_0x2d1e83[_0x05ea('0x40')][_0x05ea('0x2a')]+'%'};return _0x393dd5;})});}_0x2ec8b6=_[_0x05ea('0x5a')]({},_0x2ec8b6,_0x2d1e83['options']);return _0x59b77e[_0x05ea('0x140')](_0x2ec8b6);}})[_0x05ea('0x13')](function(_0x2cb6fd){if(_0x2cb6fd){_0x21c08f=_0x2cb6fd[_0x05ea('0x4a')];if(!_0x2d1e83[_0x05ea('0x40')][_0x05ea('0xc8')]('nolimit')){_0x2ec8b6['limit']=qs[_0x05ea('0x20')](_0x2d1e83[_0x05ea('0x40')]['limit']);_0x2ec8b6[_0x05ea('0x21')]=qs[_0x05ea('0x21')](_0x2d1e83[_0x05ea('0x40')]['offset']);}return _0x59b77e[_0x05ea('0x140')](_0x2ec8b6);}})[_0x05ea('0x13')](function(_0x58493f){if(_0x58493f){return _0x58493f?{'count':_0x21c08f,'rows':_0x58493f}:null;}})[_0x05ea('0x13')](respondWithResult(_0x300ab7,null))[_0x05ea('0x1b')](handleError(_0x300ab7,null));};exports[_0x05ea('0x141')]=function(_0x11a845,_0xd2dc5f){return db[_0x05ea('0x35')][_0x05ea('0x2e')]({'where':{'id':_0x11a845[_0x05ea('0x52')]['id']}})[_0x05ea('0x13')](handleEntityNotFound(_0xd2dc5f,null))[_0x05ea('0x13')](function(_0x11dd54){if(_0x11dd54){return _0x11dd54['addMailAccounts'](_0x11a845[_0x05ea('0x5d')][_0x05ea('0x60')],_['omit'](_0x11a845[_0x05ea('0x5d')],[_0x05ea('0x60'),'id'])||{});}})[_0x05ea('0x13')](respondWithResult(_0xd2dc5f,null))['catch'](handleError(_0xd2dc5f,null));};exports[_0x05ea('0x142')]=function(_0x157ccc,_0xf86f64){return db['User'][_0x05ea('0x2e')]({'where':{'id':_0x157ccc[_0x05ea('0x52')]['id']}})['then'](handleEntityNotFound(_0xf86f64,null))['then'](function(_0xac8298){if(_0xac8298){return _0xac8298[_0x05ea('0x142')](_0x157ccc['query'][_0x05ea('0x60')]);}})[_0x05ea('0x13')](respondWithStatusCode(_0xf86f64,null))[_0x05ea('0x1b')](handleError(_0xf86f64,null));};exports[_0x05ea('0x143')]=function(_0x20fda7,_0x36d50b){var _0x430226={};var _0x4c600a={};var _0x8c2526;var _0x420f0c;return db['User'][_0x05ea('0x96')]({'where':{'id':_0x20fda7[_0x05ea('0x52')]['id']}})[_0x05ea('0x13')](handleEntityNotFound(_0x36d50b,null))['then'](function(_0x3f5fd2){if(_0x3f5fd2){_0x8c2526=_0x3f5fd2;_0x4c600a[_0x05ea('0x53')]=_['keys'](db['OpenchannelAccount']['rawAttributes']);_0x4c600a[_0x05ea('0x40')]=_[_0x05ea('0x55')](_0x20fda7[_0x05ea('0x40')]);_0x4c600a[_0x05ea('0x56')]=_[_0x05ea('0x57')](_0x4c600a[_0x05ea('0x53')],_0x4c600a[_0x05ea('0x40')]);_0x430226[_0x05ea('0x44')]=_['intersection'](_0x4c600a['model'],qs['fields'](_0x20fda7[_0x05ea('0x40')]['fields']));_0x430226[_0x05ea('0x44')]=_0x430226[_0x05ea('0x44')][_0x05ea('0x4a')]?_0x430226[_0x05ea('0x44')]:_0x4c600a['model'];_0x430226[_0x05ea('0xd2')]=qs[_0x05ea('0xd3')](_0x20fda7[_0x05ea('0x40')][_0x05ea('0xd3')]);_0x430226[_0x05ea('0x3e')]=qs[_0x05ea('0x56')](_['pick'](_0x20fda7[_0x05ea('0x40')],_0x4c600a[_0x05ea('0x56')]));if(_0x20fda7['query']['filter']){_0x430226['where']=_['merge'](_0x430226[_0x05ea('0x3e')],{'$or':_['map'](_0x430226[_0x05ea('0x44')],function(_0x5f5234){var _0x25ccfc={};_0x25ccfc[_0x5f5234]={'$like':'%'+_0x20fda7[_0x05ea('0x40')][_0x05ea('0x2a')]+'%'};return _0x25ccfc;})});}_0x430226=_[_0x05ea('0x5a')]({},_0x430226,_0x20fda7['options']);return _0x8c2526['getOpenchannelAccounts'](_0x430226);}})[_0x05ea('0x13')](function(_0x22aa9e){if(_0x22aa9e){_0x420f0c=_0x22aa9e[_0x05ea('0x4a')];if(!_0x20fda7[_0x05ea('0x40')][_0x05ea('0xc8')](_0x05ea('0xcf'))){_0x430226['limit']=qs[_0x05ea('0x20')](_0x20fda7[_0x05ea('0x40')][_0x05ea('0x20')]);_0x430226[_0x05ea('0x21')]=qs[_0x05ea('0x21')](_0x20fda7[_0x05ea('0x40')][_0x05ea('0x21')]);}return _0x8c2526[_0x05ea('0x143')](_0x430226);}})['then'](function(_0x14ace2){if(_0x14ace2){return _0x14ace2?{'count':_0x420f0c,'rows':_0x14ace2}:null;}})[_0x05ea('0x13')](respondWithResult(_0x36d50b,null))[_0x05ea('0x1b')](handleError(_0x36d50b,null));};exports[_0x05ea('0x144')]=function(_0x30a2b8,_0xfbe060){return db['User']['find']({'where':{'id':_0x30a2b8[_0x05ea('0x52')]['id']}})['then'](handleEntityNotFound(_0xfbe060,null))[_0x05ea('0x13')](function(_0x2b4e34){if(_0x2b4e34){return _0x2b4e34[_0x05ea('0x144')](_0x30a2b8[_0x05ea('0x5d')]['ids'],_['omit'](_0x30a2b8[_0x05ea('0x5d')],['ids','id'])||{});}})[_0x05ea('0x13')](respondWithResult(_0xfbe060,null))[_0x05ea('0x1b')](handleError(_0xfbe060,null));};exports[_0x05ea('0x145')]=function(_0x23b1a7,_0x3eadff){return db['User'][_0x05ea('0x2e')]({'where':{'id':_0x23b1a7[_0x05ea('0x52')]['id']}})[_0x05ea('0x13')](handleEntityNotFound(_0x3eadff,null))[_0x05ea('0x13')](function(_0x2f7a50){if(_0x2f7a50){return _0x2f7a50[_0x05ea('0x145')](_0x23b1a7[_0x05ea('0x40')][_0x05ea('0x60')]);}})[_0x05ea('0x13')](respondWithStatusCode(_0x3eadff,null))[_0x05ea('0x1b')](handleError(_0x3eadff,null));};exports[_0x05ea('0x146')]=function(_0x48dfc3,_0x54df03){var _0xefa8d5={};var _0x53d2ff={};var _0x47c8cc;var _0x315a85;return db[_0x05ea('0x35')]['findOne']({'where':{'id':_0x48dfc3['params']['id']}})[_0x05ea('0x13')](handleEntityNotFound(_0x54df03,null))[_0x05ea('0x13')](function(_0x2ca13f){if(_0x2ca13f){_0x47c8cc=_0x2ca13f;_0x53d2ff[_0x05ea('0x53')]=_[_0x05ea('0x55')](db[_0x05ea('0x147')]['rawAttributes']);_0x53d2ff[_0x05ea('0x40')]=_[_0x05ea('0x55')](_0x48dfc3['query']);_0x53d2ff[_0x05ea('0x56')]=_['intersection'](_0x53d2ff[_0x05ea('0x53')],_0x53d2ff[_0x05ea('0x40')]);_0xefa8d5[_0x05ea('0x44')]=_[_0x05ea('0x57')](_0x53d2ff[_0x05ea('0x53')],qs['fields'](_0x48dfc3[_0x05ea('0x40')][_0x05ea('0x58')]));_0xefa8d5[_0x05ea('0x44')]=_0xefa8d5[_0x05ea('0x44')]['length']?_0xefa8d5[_0x05ea('0x44')]:_0x53d2ff[_0x05ea('0x53')];_0xefa8d5['order']=qs[_0x05ea('0xd3')](_0x48dfc3['query'][_0x05ea('0xd3')]);_0xefa8d5[_0x05ea('0x3e')]=qs['filters'](_[_0x05ea('0xd4')](_0x48dfc3[_0x05ea('0x40')],_0x53d2ff[_0x05ea('0x56')]));if(_0x48dfc3[_0x05ea('0x40')][_0x05ea('0x2a')]){_0xefa8d5[_0x05ea('0x3e')]=_[_0x05ea('0x5a')](_0xefa8d5[_0x05ea('0x3e')],{'$or':_[_0x05ea('0x37')](_0xefa8d5[_0x05ea('0x44')],function(_0x87eea7){var _0x3574b7={};_0x3574b7[_0x87eea7]={'$like':'%'+_0x48dfc3[_0x05ea('0x40')]['filter']+'%'};return _0x3574b7;})});}_0xefa8d5=_[_0x05ea('0x5a')]({},_0xefa8d5,_0x48dfc3[_0x05ea('0x5b')]);return _0x47c8cc[_0x05ea('0x146')](_0xefa8d5);}})[_0x05ea('0x13')](function(_0x54f687){if(_0x54f687){_0x315a85=_0x54f687[_0x05ea('0x4a')];if(!_0x48dfc3[_0x05ea('0x40')][_0x05ea('0xc8')]('nolimit')){_0xefa8d5[_0x05ea('0x20')]=qs[_0x05ea('0x20')](_0x48dfc3[_0x05ea('0x40')][_0x05ea('0x20')]);_0xefa8d5[_0x05ea('0x21')]=qs[_0x05ea('0x21')](_0x48dfc3[_0x05ea('0x40')][_0x05ea('0x21')]);}return _0x47c8cc[_0x05ea('0x146')](_0xefa8d5);}})[_0x05ea('0x13')](function(_0x3672cd){if(_0x3672cd){return _0x3672cd?{'count':_0x315a85,'rows':_0x3672cd}:null;}})[_0x05ea('0x13')](respondWithResult(_0x54df03,null))['catch'](handleError(_0x54df03,null));};exports['addSmsAccounts']=function(_0x12b4b6,_0x216aa8){return db[_0x05ea('0x35')][_0x05ea('0x2e')]({'where':{'id':_0x12b4b6['params']['id']}})[_0x05ea('0x13')](handleEntityNotFound(_0x216aa8,null))['then'](function(_0x516e59){if(_0x516e59){return _0x516e59[_0x05ea('0x148')](_0x12b4b6[_0x05ea('0x5d')][_0x05ea('0x60')],_[_0x05ea('0x61')](_0x12b4b6[_0x05ea('0x5d')],[_0x05ea('0x60'),'id'])||{});}})[_0x05ea('0x13')](respondWithResult(_0x216aa8,null))[_0x05ea('0x1b')](handleError(_0x216aa8,null));};exports[_0x05ea('0x149')]=function(_0x5e6b4c,_0x3f92ef){return db[_0x05ea('0x35')]['find']({'where':{'id':_0x5e6b4c[_0x05ea('0x52')]['id']}})[_0x05ea('0x13')](handleEntityNotFound(_0x3f92ef,null))[_0x05ea('0x13')](function(_0x31d050){if(_0x31d050){return _0x31d050[_0x05ea('0x149')](_0x5e6b4c[_0x05ea('0x40')][_0x05ea('0x60')]);}})[_0x05ea('0x13')](respondWithStatusCode(_0x3f92ef,null))['catch'](handleError(_0x3f92ef,null));};exports['getChatWebsites']=function(_0x219f8a,_0x196958){var _0x48e717={};var _0x275e2a={};var _0x3b9131;var _0x2dfb66;return db[_0x05ea('0x35')][_0x05ea('0x96')]({'where':{'id':_0x219f8a[_0x05ea('0x52')]['id']}})['then'](handleEntityNotFound(_0x196958,null))[_0x05ea('0x13')](function(_0x7cd99e){if(_0x7cd99e){_0x3b9131=_0x7cd99e;_0x275e2a[_0x05ea('0x53')]=_[_0x05ea('0x55')](db[_0x05ea('0x14a')][_0x05ea('0x36')]);_0x275e2a['query']=_[_0x05ea('0x55')](_0x219f8a[_0x05ea('0x40')]);_0x275e2a[_0x05ea('0x56')]=_['intersection'](_0x275e2a[_0x05ea('0x53')],_0x275e2a['query']);_0x48e717[_0x05ea('0x44')]=_[_0x05ea('0x57')](_0x275e2a[_0x05ea('0x53')],qs[_0x05ea('0x58')](_0x219f8a['query'][_0x05ea('0x58')]));_0x48e717['attributes']=_0x48e717['attributes'][_0x05ea('0x4a')]?_0x48e717[_0x05ea('0x44')]:_0x275e2a[_0x05ea('0x53')];_0x48e717[_0x05ea('0xd2')]=qs[_0x05ea('0xd3')](_0x219f8a[_0x05ea('0x40')][_0x05ea('0xd3')]);_0x48e717[_0x05ea('0x3e')]=qs['filters'](_[_0x05ea('0xd4')](_0x219f8a[_0x05ea('0x40')],_0x275e2a[_0x05ea('0x56')]));if(_0x219f8a[_0x05ea('0x40')][_0x05ea('0x2a')]){_0x48e717[_0x05ea('0x3e')]=_[_0x05ea('0x5a')](_0x48e717[_0x05ea('0x3e')],{'$or':_[_0x05ea('0x37')](_0x48e717[_0x05ea('0x44')],function(_0x332e38){var _0x5a614e={};_0x5a614e[_0x332e38]={'$like':'%'+_0x219f8a[_0x05ea('0x40')][_0x05ea('0x2a')]+'%'};return _0x5a614e;})});}_0x48e717=_['merge']({},_0x48e717,_0x219f8a[_0x05ea('0x5b')]);return _0x3b9131['getChatWebsites'](_0x48e717);}})[_0x05ea('0x13')](function(_0x4f821a){if(_0x4f821a){_0x2dfb66=_0x4f821a['length'];if(!_0x219f8a[_0x05ea('0x40')][_0x05ea('0xc8')](_0x05ea('0xcf'))){_0x48e717['limit']=qs[_0x05ea('0x20')](_0x219f8a[_0x05ea('0x40')][_0x05ea('0x20')]);_0x48e717[_0x05ea('0x21')]=qs[_0x05ea('0x21')](_0x219f8a[_0x05ea('0x40')]['offset']);}return _0x3b9131[_0x05ea('0x14b')](_0x48e717);}})[_0x05ea('0x13')](function(_0x12dccc){if(_0x12dccc){return _0x12dccc?{'count':_0x2dfb66,'rows':_0x12dccc}:null;}})[_0x05ea('0x13')](respondWithResult(_0x196958,null))[_0x05ea('0x1b')](handleError(_0x196958,null));};exports[_0x05ea('0x14c')]=function(_0x40f71a,_0x110384){return db[_0x05ea('0x35')]['find']({'where':{'id':_0x40f71a['params']['id']}})['then'](handleEntityNotFound(_0x110384,null))[_0x05ea('0x13')](function(_0xe58eb9){if(_0xe58eb9){return _0xe58eb9[_0x05ea('0x14c')](_0x40f71a['body'][_0x05ea('0x60')],_[_0x05ea('0x61')](_0x40f71a['body'],[_0x05ea('0x60'),'id'])||{});}})[_0x05ea('0x13')](respondWithResult(_0x110384,null))[_0x05ea('0x1b')](handleError(_0x110384,null));};exports['removeChatWebsites']=function(_0x3edcd3,_0x4e8076){return db[_0x05ea('0x35')][_0x05ea('0x2e')]({'where':{'id':_0x3edcd3['params']['id']}})[_0x05ea('0x13')](handleEntityNotFound(_0x4e8076,null))[_0x05ea('0x13')](function(_0x553ff6){if(_0x553ff6){return _0x553ff6[_0x05ea('0x14d')](_0x3edcd3[_0x05ea('0x40')][_0x05ea('0x60')]);}})[_0x05ea('0x13')](respondWithStatusCode(_0x4e8076,null))[_0x05ea('0x1b')](handleError(_0x4e8076,null));};exports[_0x05ea('0x14e')]=function(_0x5b1943,_0x2b8518){var _0x848044={};var _0x23c56b={};var _0x167185;var _0x22b45c;return db[_0x05ea('0x35')][_0x05ea('0x96')]({'where':{'id':_0x5b1943[_0x05ea('0x52')]['id']}})[_0x05ea('0x13')](handleEntityNotFound(_0x2b8518,null))['then'](function(_0x19899d){if(_0x19899d){_0x167185=_0x19899d;_0x23c56b['model']=_[_0x05ea('0x55')](db['WhatsappAccount'][_0x05ea('0x36')]);_0x23c56b['query']=_[_0x05ea('0x55')](_0x5b1943['query']);_0x23c56b[_0x05ea('0x56')]=_[_0x05ea('0x57')](_0x23c56b[_0x05ea('0x53')],_0x23c56b[_0x05ea('0x40')]);_0x848044['attributes']=_[_0x05ea('0x57')](_0x23c56b[_0x05ea('0x53')],qs['fields'](_0x5b1943[_0x05ea('0x40')][_0x05ea('0x58')]));_0x848044[_0x05ea('0x44')]=_0x848044[_0x05ea('0x44')]['length']?_0x848044[_0x05ea('0x44')]:_0x23c56b[_0x05ea('0x53')];_0x848044[_0x05ea('0xd2')]=qs[_0x05ea('0xd3')](_0x5b1943[_0x05ea('0x40')][_0x05ea('0xd3')]);_0x848044[_0x05ea('0x3e')]=qs['filters'](_[_0x05ea('0xd4')](_0x5b1943[_0x05ea('0x40')],_0x23c56b[_0x05ea('0x56')]));if(_0x5b1943[_0x05ea('0x40')][_0x05ea('0x2a')]){_0x848044['where']=_[_0x05ea('0x5a')](_0x848044['where'],{'$or':_[_0x05ea('0x37')](_0x848044['attributes'],function(_0x8a3b48){var _0x2a9cd8={};_0x2a9cd8[_0x8a3b48]={'$like':'%'+_0x5b1943['query'][_0x05ea('0x2a')]+'%'};return _0x2a9cd8;})});}_0x848044=_[_0x05ea('0x5a')]({},_0x848044,_0x5b1943['options']);return _0x167185['getWhatsappAccounts'](_0x848044);}})['then'](function(_0x162633){if(_0x162633){_0x22b45c=_0x162633['length'];if(!_0x5b1943[_0x05ea('0x40')][_0x05ea('0xc8')]('nolimit')){_0x848044[_0x05ea('0x20')]=qs[_0x05ea('0x20')](_0x5b1943[_0x05ea('0x40')]['limit']);_0x848044['offset']=qs[_0x05ea('0x21')](_0x5b1943['query'][_0x05ea('0x21')]);}return _0x167185[_0x05ea('0x14e')](_0x848044);}})[_0x05ea('0x13')](function(_0x64c9b6){if(_0x64c9b6){return _0x64c9b6?{'count':_0x22b45c,'rows':_0x64c9b6}:null;}})['then'](respondWithResult(_0x2b8518,null))['catch'](handleError(_0x2b8518,null));};exports[_0x05ea('0x14f')]=function(_0x5ef35e,_0x249b36){return db['User']['find']({'where':{'id':_0x5ef35e['params']['id']}})[_0x05ea('0x13')](handleEntityNotFound(_0x249b36,null))[_0x05ea('0x13')](function(_0xcd1e33){if(_0xcd1e33){return _0xcd1e33['addWhatsappAccounts'](_0x5ef35e[_0x05ea('0x5d')]['ids'],_['omit'](_0x5ef35e[_0x05ea('0x5d')],[_0x05ea('0x60'),'id'])||{});}})[_0x05ea('0x13')](respondWithResult(_0x249b36,null))[_0x05ea('0x1b')](handleError(_0x249b36,null));};exports[_0x05ea('0x150')]=function(_0x4dad93,_0xbb14fa){return db[_0x05ea('0x35')][_0x05ea('0x2e')]({'where':{'id':_0x4dad93['params']['id']}})[_0x05ea('0x13')](handleEntityNotFound(_0xbb14fa,null))[_0x05ea('0x13')](function(_0x28f3c8){if(_0x28f3c8){return _0x28f3c8[_0x05ea('0x150')](_0x4dad93[_0x05ea('0x40')]['ids']);}})[_0x05ea('0x13')](respondWithStatusCode(_0xbb14fa,null))['catch'](handleError(_0xbb14fa,null));};exports['getSquareProjects']=function(_0x4d32bd,_0x1cbfac){var _0xb55b3b={};var _0x34f647={};var _0x460946;var _0x1d2692;return db[_0x05ea('0x35')][_0x05ea('0x96')]({'where':{'id':_0x4d32bd[_0x05ea('0x52')]['id']}})[_0x05ea('0x13')](handleEntityNotFound(_0x1cbfac,null))[_0x05ea('0x13')](function(_0x5d492e){if(_0x5d492e){_0x460946=_0x5d492e;_0x34f647[_0x05ea('0x53')]=_[_0x05ea('0x55')](db[_0x05ea('0x151')][_0x05ea('0x36')]);_0x34f647[_0x05ea('0x40')]=_[_0x05ea('0x55')](_0x4d32bd[_0x05ea('0x40')]);_0x34f647[_0x05ea('0x56')]=_[_0x05ea('0x57')](_0x34f647[_0x05ea('0x53')],_0x34f647[_0x05ea('0x40')]);_0xb55b3b[_0x05ea('0x44')]=_['intersection'](_0x34f647[_0x05ea('0x53')],qs[_0x05ea('0x58')](_0x4d32bd['query'][_0x05ea('0x58')]));_0xb55b3b[_0x05ea('0x44')]=_0xb55b3b[_0x05ea('0x44')][_0x05ea('0x4a')]?_0xb55b3b[_0x05ea('0x44')]:_0x34f647[_0x05ea('0x53')];_0xb55b3b[_0x05ea('0xd2')]=qs[_0x05ea('0xd3')](_0x4d32bd[_0x05ea('0x40')][_0x05ea('0xd3')]);_0xb55b3b['where']=qs[_0x05ea('0x56')](_['pick'](_0x4d32bd[_0x05ea('0x40')],_0x34f647['filters']));if(_0x4d32bd['query'][_0x05ea('0x2a')]){_0xb55b3b[_0x05ea('0x3e')]=_[_0x05ea('0x5a')](_0xb55b3b[_0x05ea('0x3e')],{'$or':_['map'](_0xb55b3b['attributes'],function(_0x5f17b4){var _0x5f3925={};_0x5f3925[_0x5f17b4]={'$like':'%'+_0x4d32bd['query'][_0x05ea('0x2a')]+'%'};return _0x5f3925;})});}_0xb55b3b=_[_0x05ea('0x5a')]({},_0xb55b3b,_0x4d32bd[_0x05ea('0x5b')]);return _0x460946[_0x05ea('0x152')](_0xb55b3b);}})[_0x05ea('0x13')](function(_0x20ec45){if(_0x20ec45){_0x1d2692=_0x20ec45[_0x05ea('0x4a')];if(!_0x4d32bd[_0x05ea('0x40')][_0x05ea('0xc8')](_0x05ea('0xcf'))){_0xb55b3b[_0x05ea('0x20')]=qs[_0x05ea('0x20')](_0x4d32bd['query'][_0x05ea('0x20')]);_0xb55b3b[_0x05ea('0x21')]=qs[_0x05ea('0x21')](_0x4d32bd[_0x05ea('0x40')][_0x05ea('0x21')]);}return _0x460946[_0x05ea('0x152')](_0xb55b3b);}})[_0x05ea('0x13')](function(_0x4a7056){if(_0x4a7056){return _0x4a7056?{'count':_0x1d2692,'rows':_0x4a7056}:null;}})[_0x05ea('0x13')](respondWithResult(_0x1cbfac,null))['catch'](handleError(_0x1cbfac,null));};exports[_0x05ea('0x153')]=function(_0xa39517,_0x261daa){return db['User'][_0x05ea('0x2e')]({'where':{'id':_0xa39517[_0x05ea('0x52')]['id']}})[_0x05ea('0x13')](handleEntityNotFound(_0x261daa,null))[_0x05ea('0x13')](function(_0x419ce1){if(_0x419ce1){return _0x419ce1[_0x05ea('0x153')](_0xa39517[_0x05ea('0x5d')][_0x05ea('0x60')],_[_0x05ea('0x61')](_0xa39517[_0x05ea('0x5d')],[_0x05ea('0x60'),'id'])||{});}})[_0x05ea('0x13')](respondWithResult(_0x261daa,null))[_0x05ea('0x1b')](handleError(_0x261daa,null));};exports[_0x05ea('0x154')]=function(_0x2643f0,_0x38be6c){return db['User'][_0x05ea('0x2e')]({'where':{'id':_0x2643f0['params']['id']}})[_0x05ea('0x13')](handleEntityNotFound(_0x38be6c,null))[_0x05ea('0x13')](function(_0x3b02a5){if(_0x3b02a5){return _0x3b02a5['removeSquareProjects'](_0x2643f0['query'][_0x05ea('0x60')]);}})[_0x05ea('0x13')](respondWithStatusCode(_0x38be6c,null))[_0x05ea('0x1b')](handleError(_0x38be6c,null));};exports['getScheduledCalls']=function(_0x23759c,_0x4008c1){var _0x3475c1={},_0x528997={},_0x187118={'count':0x0,'rows':[]};var _0x34faeb=db['CmHopper'][_0x05ea('0x36')];_0x528997[_0x05ea('0x53')]=_[_0x05ea('0x55')](_0x34faeb);_0x528997[_0x05ea('0x40')]=_[_0x05ea('0x55')](_0x23759c['query']);_0x528997[_0x05ea('0x56')]=_[_0x05ea('0x57')](_0x528997[_0x05ea('0x53')],_0x528997[_0x05ea('0x40')]);_0x528997[_0x05ea('0x56')]=_['concat'](_0x528997[_0x05ea('0x56')],[_0x05ea('0x155'),_0x05ea('0x156'),_0x05ea('0x157'),_0x05ea('0x158'),'$lt',_0x05ea('0x159'),_0x05ea('0x15a'),'$eq',_0x05ea('0x15b'),_0x05ea('0x15c'),_0x05ea('0x15d'),_0x05ea('0x15e'),_0x05ea('0x15f'),'$like','$notLike','$iLike',_0x05ea('0x160'),'$like',_0x05ea('0x161'),_0x05ea('0x162'),_0x05ea('0x163'),_0x05ea('0x164')]);_0x3475c1['attributes']=_[_0x05ea('0x57')](_0x528997[_0x05ea('0x53')],qs['fields'](_0x23759c[_0x05ea('0x40')]['fields']));_0x3475c1['attributes']=_0x3475c1['attributes'][_0x05ea('0x4a')]?_0x3475c1['attributes']:_0x528997['model'];if(!_0x23759c[_0x05ea('0x40')]['hasOwnProperty'](_0x05ea('0xcf'))){_0x3475c1['limit']=qs['limit'](_0x23759c[_0x05ea('0x40')][_0x05ea('0x20')]);_0x3475c1['offset']=qs[_0x05ea('0x21')](_0x23759c[_0x05ea('0x40')][_0x05ea('0x21')]);}_0x3475c1[_0x05ea('0xd2')]=qs['sort'](_0x23759c[_0x05ea('0x40')][_0x05ea('0xd3')]);_0x3475c1['where']=qs[_0x05ea('0x56')](_[_0x05ea('0xd4')](_0x23759c[_0x05ea('0x40')],_0x528997[_0x05ea('0x56')]));if(_0x23759c[_0x05ea('0x40')][_0x05ea('0x2a')]){_0x3475c1['where']=_[_0x05ea('0x5a')](_0x3475c1[_0x05ea('0x3e')],{'$or':_['map'](_0x3475c1[_0x05ea('0x44')],function(_0x40451d){var _0x22cc7b={};_0x22cc7b[_0x40451d]={'$like':'%'+_0x23759c[_0x05ea('0x40')]['filter']+'%'};return _0x22cc7b;})});}_0x3475c1[_0x05ea('0x3e')]={'$and':[_0x3475c1['where'],{'$or':[{'UserId':_0x23759c[_0x05ea('0x52')]['id']},{'OwnerId':_0x23759c[_0x05ea('0x52')]['id']}]}]};_0x3475c1=_[_0x05ea('0x5a')]({},_0x3475c1,_0x23759c[_0x05ea('0x5b')]);var _0x57f509={'where':_0x3475c1[_0x05ea('0x3e')]};return db[_0x05ea('0x165')][_0x05ea('0x3f')](_0x57f509)['then'](function(_0xa10baa){_0x187118[_0x05ea('0x3f')]=_0xa10baa;if(_0x23759c[_0x05ea('0x40')]['includeAll']){_0x3475c1[_0x05ea('0x41')]=[{'attributes':['id','firstName','lastName',_0x05ea('0xe8')],'model':db[_0x05ea('0x166')],'as':'Contact'},{'attributes':['id',_0x05ea('0x2f'),_0x05ea('0x167')],'model':db[_0x05ea('0xa9')],'as':_0x05ea('0xd1')}];}return db[_0x05ea('0x165')]['findAll'](_0x3475c1);})[_0x05ea('0x13')](function(_0xfd0582){_0x187118[_0x05ea('0x47')]=_0xfd0582;return _0x187118;})[_0x05ea('0x13')](respondWithFilteredResult(_0x4008c1,_0x3475c1))[_0x05ea('0x1b')](handleError(_0x4008c1,null));};exports[_0x05ea('0x168')]=function(_0x1edbf2,_0x34fe92){if(!_['isNil'](_0x1edbf2[_0x05ea('0x27')]['id'])&&(_0x1edbf2[_0x05ea('0x27')][_0x05ea('0x24')]=='admin'||_0x1edbf2[_0x05ea('0x27')][_0x05ea('0x24')]=='user')){return db['User'][_0x05ea('0x96')]({'where':{'id':_0x1edbf2[_0x05ea('0x52')]['id']},'raw':!![]})[_0x05ea('0x13')](function(_0x31bedb){return authService[_0x05ea('0x169')](_0x31bedb);})[_0x05ea('0x13')](function(_0x1ce8ca){if(_0x1ce8ca){return _0x34fe92[_0x05ea('0x1d')](0xc8)[_0x05ea('0x1e')]({'api_key':_0x1ce8ca[_0x05ea('0x16a')]});}else{return _0x34fe92[_0x05ea('0x1d')](0xcc)[_0x05ea('0x1e')]({'message':_0x05ea('0x16b')});}})[_0x05ea('0x1b')](handleError(_0x34fe92,0x193));}else{return _0x34fe92[_0x05ea('0x1d')](0x191)[_0x05ea('0x1e')]({'message':_0x05ea('0x16c')});}};exports[_0x05ea('0x16d')]=function(_0x3d4951,_0x31375c){if(!_[_0x05ea('0x65')](_0x3d4951[_0x05ea('0x27')]['id'])&&(_0x3d4951['user'][_0x05ea('0x24')]==_0x05ea('0x25')||_0x3d4951[_0x05ea('0x27')]['role']=='user')){return db[_0x05ea('0x35')][_0x05ea('0x2e')]({'where':{'id':_0x3d4951[_0x05ea('0x52')]['id']}})[_0x05ea('0x13')](function(_0x2e5858){return authService[_0x05ea('0x16e')](_0x2e5858);})['then'](function(_0x30b0ca){return db[_0x05ea('0x35')][_0x05ea('0x23')]({'apiKeyIat':_0x30b0ca[_0x05ea('0x16f')],'apiKeyNonce':_0x30b0ca[_0x05ea('0x170')]},{'where':{'id':_0x3d4951[_0x05ea('0x52')]['id']}})[_0x05ea('0x13')](function(){return _0x31375c[_0x05ea('0x1d')](0xc8)[_0x05ea('0x1e')]({'api_key':_0x30b0ca[_0x05ea('0x16a')]});});})[_0x05ea('0x1b')](handleError(_0x31375c,0x193));}else{return _0x31375c[_0x05ea('0x1d')](0x191)[_0x05ea('0x1e')]({'message':_0x05ea('0x16c')});}};exports['removeApiKey']=function(_0x44db36,_0x4f6c51){if(!_[_0x05ea('0x65')](_0x44db36[_0x05ea('0x27')]['id'])&&(_0x44db36[_0x05ea('0x27')][_0x05ea('0x24')]==_0x05ea('0x25')||_0x44db36['user'][_0x05ea('0x24')]==_0x05ea('0x27'))){return db[_0x05ea('0x35')][_0x05ea('0x2e')]({'where':{'id':_0x44db36['params']['id']}})['then'](handleEntityNotFound(_0x4f6c51,null))[_0x05ea('0x13')](function(_0x576dfb){if(_0x576dfb&&_0x576dfb[_0x05ea('0x171')]&&_0x576dfb[_0x05ea('0x172')])return _0x576dfb;else throw{'message':_0x05ea('0x173')};})[_0x05ea('0x13')](function(){return db['User'][_0x05ea('0x23')]({'apiKeyNonce':null,'apiKeyIat':null},{'where':{'id':_0x44db36['params']['id']}});})[_0x05ea('0x13')](respondWithStatusCode(_0x4f6c51,0xc8))[_0x05ea('0x1b')](handleError(_0x4f6c51,0x193));}else{return _0x4f6c51[_0x05ea('0x1d')](0x191)['json']({'message':_0x05ea('0x16c')});}};exports[_0x05ea('0x174')]=function(_0x514740,_0x14fe76){var _0x329575=_0x514740[_0x05ea('0x27')][_0x05ea('0xaa')]({'plain':!![]});if(!_0x329575){return _0x14fe76[_0x05ea('0x1d')](0x191)[_0x05ea('0x34')](_0x05ea('0x175'));}else{Promise['resolve']()[_0x05ea('0x13')](function(){if(_0x514740['query']['userSetting']!==_0x05ea('0x49'))return;return _0x514740['user'][_0x05ea('0x176')]();})['then'](function(_0x28add3){if(!_0x28add3)return;return _0x28add3[_0x05ea('0xaa')]({'plain':!![]});})['then'](function(_0x55e75c){_0x329575[_0x05ea('0x43')]=_0x55e75c;return _0x14fe76[_0x05ea('0x1d')](0xc8)[_0x05ea('0x1e')](_0x329575);});}};exports[_0x05ea('0x177')]=function(_0x2c1045,_0x8eb5a3){var _0x2df1a6={'offset':0x0},_0x32b911={'count':0x0,'rows':[]};Promise['resolve']()[_0x05ea('0x13')](function(){if(!_0x2c1045['query']['filter']&&!_0x2c1045[_0x05ea('0x40')]['teams']&&!_0x2c1045[_0x05ea('0x40')][_0x05ea('0x178')])return[];return Promise[_0x05ea('0xfe')]()[_0x05ea('0x13')](function(){var _0x1dd07c=[];if(!_[_0x05ea('0x179')](_0x2c1045['query'][_0x05ea('0x17a')])){_0x1dd07c[_0x05ea('0x45')](db['Team'][_0x05ea('0x46')]({'attributes':['id',_0x05ea('0x2f')],'where':{'id':_0x2c1045[_0x05ea('0x40')][_0x05ea('0x17a')]}}));}if(!_[_0x05ea('0x179')](_0x2c1045['query'][_0x05ea('0x178')])){_0x1dd07c[_0x05ea('0x45')](db['VoiceQueue'][_0x05ea('0x46')]({'attributes':['id',_0x05ea('0x2f')],'type':_0x05ea('0x17b'),'where':{'id':_0x2c1045[_0x05ea('0x40')][_0x05ea('0x178')]}}));}return Promise['all'](_0x1dd07c);})[_0x05ea('0x13')](function(_0x4d92dc){var _0x814bc8=_[_0x05ea('0x117')](_0x4d92dc)['map'](function(_0x10f850){return _0x10f850[_0x05ea('0x123')]({'attributes':['id',_0x05ea('0x2f'),_0x05ea('0x62'),'online'],'raw':!![]});});return Promise['all'](_0x814bc8);})[_0x05ea('0x13')](function(_0x16512e){var _0x9906a=_[_0x05ea('0x117')](_0x16512e);if(!_0x2c1045[_0x05ea('0x40')][_0x05ea('0x2a')])return _0x9906a;if(_[_0x05ea('0x179')](_0x9906a)){return db[_0x05ea('0x35')][_0x05ea('0x46')]({'attributes':['id','name','internal',_0x05ea('0xab')],'where':{'role':_0x05ea('0x28'),'$or':[db[_0x05ea('0x67')][_0x05ea('0x3e')](db['sequelize']['fn'](_0x05ea('0x17c'),db[_0x05ea('0x67')]['col'](_0x05ea('0x2f'))),{'$like':'%'+_0x2c1045[_0x05ea('0x40')][_0x05ea('0x2a')][_0x05ea('0xa4')]()+'%'}),{'internal':{'$like':'%'+_0x2c1045[_0x05ea('0x40')][_0x05ea('0x2a')]+'%'}}]},'raw':!![]});}else{return _(_0x9906a)[_0x05ea('0x117')]()['filter'](function(_0xea75ce){return _0xea75ce[_0x05ea('0x2f')]['toLowerCase']()[_0x05ea('0x2d')](_0x2c1045[_0x05ea('0x40')][_0x05ea('0x2a')][_0x05ea('0xa4')]())||_0xea75ce[_0x05ea('0x62')][_0x05ea('0x17d')]()[_0x05ea('0x2d')](_0x2c1045[_0x05ea('0x40')][_0x05ea('0x2a')]);})['value']();}})[_0x05ea('0x13')](function(_0x5bc022){var _0x23eb58=_0x05ea('0x2f');var _0x405c58=_0x05ea('0x17e');if(_0x2c1045[_0x05ea('0x40')][_0x05ea('0xd3')]){_0x405c58=_0x2c1045[_0x05ea('0x40')]['sort'][0x0]==='-'?_0x05ea('0x17f'):_0x05ea('0x17e');_0x23eb58=_0x405c58==='asc'?_0x2c1045[_0x05ea('0x40')][_0x05ea('0xd3')]:_0x2c1045[_0x05ea('0x40')]['sort']['substring'](0x1);}return _(_0x5bc022)['uniqBy']('id')[_0x05ea('0x180')]([function(_0x482dc4){return _0x23eb58===_0x05ea('0x2f')?_0x482dc4[_0x23eb58][_0x05ea('0xa4')]():_0x482dc4[_0x23eb58];}],[_0x405c58])['map'](function(_0x175e0b){return _[_0x05ea('0xd4')](_0x175e0b,['id','name',_0x05ea('0x62'),_0x05ea('0xab')]);})[_0x05ea('0x2c')]();})[_0x05ea('0x13')](function(_0x236b99){return client[_0x05ea('0x181')]('Agents',_0x2c1045)[_0x05ea('0x13')](function(_0xc1bf40){if(_0xc1bf40[_0x05ea('0x18')])throw new Error('Unable\x20to\x20retrieve\x20RPC\x20agents\x20(AMI)');var _0x333fec=_0xc1bf40[_0x05ea('0x1a')];var _0x27c918=jayson[_0x05ea('0x182')]['http']({'port':0x232c});return _0x27c918[_0x05ea('0x181')](_0x05ea('0x84'),_0x2c1045)[_0x05ea('0x13')](function(_0x388443){if(_0x388443[_0x05ea('0x18')])throw new Error(_0x05ea('0x183'));var _0x57381c=_0x388443['result'];return _[_0x05ea('0x5a')]({},_0x57381c,_0x333fec);});})['then'](function(_0x685a5){return _[_0x05ea('0x37')](_0x236b99,function(_0x13177c){var _0x333c4e=_[_0x05ea('0x2e')](_0x685a5[_0x05ea('0x47')],['id',_0x13177c['id']]);if(!_0x333c4e||!_0x13177c[_0x05ea('0xab')]){_0x13177c['status']=_0x05ea('0x184');}else if(_0x333c4e[_0x05ea('0x9d')]){_0x13177c[_0x05ea('0x1d')]='pause';}else{_0x13177c['status']=_[_0x05ea('0x2d')]([_0x05ea('0x185'),_0x05ea('0x186'),_0x05ea('0x187'),'ringing',null,undefined],_0x333c4e[_0x05ea('0x188')])?_0x05ea('0xab'):'busy';}return _0x13177c;});});});})[_0x05ea('0x13')](function(_0x50d724){if(!_0x2c1045[_0x05ea('0x40')]['hasOwnProperty']('nolimit')){_0x2df1a6[_0x05ea('0x20')]=qs[_0x05ea('0x20')](_0x2c1045[_0x05ea('0x40')][_0x05ea('0x20')]||0xa);_0x2df1a6[_0x05ea('0x21')]=qs[_0x05ea('0x21')](_0x2c1045[_0x05ea('0x40')][_0x05ea('0x21')]);}_0x32b911['count']=_0x50d724[_0x05ea('0x4a')];_0x32b911[_0x05ea('0x47')]=_0x2df1a6[_0x05ea('0x20')]?_0x50d724[_0x05ea('0x189')](_0x2df1a6['offset'],_0x2df1a6[_0x05ea('0x21')]+_0x2df1a6[_0x05ea('0x20')]):_0x50d724;return _0x32b911;})[_0x05ea('0x13')](respondWithFilteredResult(_0x8eb5a3,_0x2df1a6))['catch'](handleError(_0x8eb5a3,null));};function get_open_tabs(_0xb2394f,_0x419b68){var _0x1feb50=_0xb2394f[_0x05ea('0x18a')](0x0)[_0x05ea('0x18b')]()+_0xb2394f['slice'](0x1);var _0x572598={'type':db[_0x05ea('0x8f')]['QueryTypes'][_0x05ea('0x6a')],'raw':!![]};return new BPromise(function(_0xd4845c,_0x494415){var _0x3417d8=squel[_0x05ea('0x18c')]()[_0x05ea('0x18d')](_0x05ea('0x18e')+_0x1feb50+_0x05ea('0x18f'),'id')[_0x05ea('0x18d')]('ui.createdAt')[_0x05ea('0x6b')](_0x05ea('0x190')+_0xb2394f+_0x05ea('0x191'),'ui')[_0x05ea('0x3e')]('ui.UserId\x20=\x20?',_0x419b68['id']);return db['sequelize']['query'](_0x3417d8[_0x05ea('0x17d')](),_0x572598)[_0x05ea('0x13')](function(_0x31524c){_0x419b68[_0x1feb50+_0x05ea('0x192')]=_0x31524c;_0xd4845c(_0x31524c);})[_0x05ea('0x1b')](function(_0x4b0e4e){_0x494415(_0x4b0e4e);});});}