Built motion from commit d5e4af8c.|2.6.23
[motion2.git] / server / api / user / user.controller.js
index f10faba..9b84960 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xdf7e=['MailOpenTabs','SmsOpenTabs','SMS','WhatsappOpenTabs','WHATSAPP','concat','getContacts','CmContact','order','sort','merge','hasOwnProperty','CmList','List','Tag','tag','nolimit','getQueues','Queue','pick','getVoiceQueuesRt','getGroups','ChatGroup','VoiceRecording','getScreenRecordings','ScreenRecording','ChatInteraction','getChatInteractions','getOpenchannelInteractions','OpenchannelInteraction','getMailInteractions','MailInteraction','UserId','getSmsInteractions','SmsInteraction','getFaxInteractions','FaxInteraction','getWhatsappInteractions','WhatsappInteraction','login','mobile','LOCAL/%s@from-sip/n','SIP/%s','intrf','user:%s','user:forcelogout','x-forwarded-for','connection','remoteAddress','socket','User\x20not\x20found\x20or\x20not\x20allowed\x20to\x20perform\x20login\x20method','getVoiceQueues','UserVoiceQueue.penalty','MemberReport','forEach','YYYY-MM-DD\x20HH:mm:ss','LOGIN','LOGININPAUSE','isMiddleware','pause','QueuePause','getChannels','DEFAULT\x20PAUSE','unpause','Channel\x20parameter\x20%s\x20is\x20invalid','mailPause','chatPause','faxPause','openchannelPause','whatsappPause','getTeams','resolve','Body\x20parameter\x20\x27ids\x27\x20is\x20required','User\x20with\x20id\x20%s\x20not\x20found','transaction','addTeams','Team','getAssociatedQueues','flattenDeep','addAgent','Voice','TeamVoicePrefix','UserVoicePrefix','VoicePrefixId','getDataValue','removeAgent','getLists','getAgents','values','You\x20can\x27t\x20delete\x20yourself','addChatInteractions','user_has_chat_interactions:save','removeChatInteractions','user_has_chat_interactions:remove','addMailInteractions','user_has_mail_interactions:save','removeMailInteractions','user_has_mail_interactions:remove','addFaxInteractions','user_has_fax_interactions:save','removeFaxInteractions','user_has_fax_interactions:remove','addSmsInteractions','user_has_sms_interactions:save','removeSmsInteractions','user_has_sms_interactions:remove','addOpenchannelInteractions','user_has_openchannel_interactions:save','removeOpenchannelInteractions','user_has_openchannel_interactions:remove','addWhatsappInteractions','user_has_whatsapp_interactions:save','getVoicePrefixes','VoicePrefix','getFaxAccounts','FaxAccount','addFaxAccounts','removeFaxAccounts','getMailAccounts','addMailAccounts','removeMailAccounts','getOpenchannelAccounts','OpenchannelAccount','addOpenchannelAccounts','removeOpenchannelAccounts','SmsAccount','getSmsAccounts','addSmsAccounts','removeSmsAccounts','ChatWebsite','getChatWebsites','addChatWebsites','removeChatWebsites','WhatsappAccount','getWhatsappAccounts','addWhatsappAccounts','removeWhatsappAccounts','CmHopper','$and','$or','$gt','$gte','$lte','$ne','$eq','$not','$between','$notBetween','$in','$like','$notLike','$iLike','$notILike','$contained','$any','firstName','lastName','phone','Contact','dialActive','VoiceQueue','getApiKey','retrieveApiKey','token','No\x20API\x20access\x20key\x20found!','You\x20don\x27t\x20have\x20sufficient\x20privileges\x20to\x20access\x20this\x20resource.','generateApiKey','iat','nonce','removeApiKey','apiKeyNonce','apiKeyIat','API\x20key\x20not\x20available','Unable\x20to\x20retrieve\x20the\x20current\x20user','getPresence','queues','teams','inbound','flatten','lower','col','asc','desc','substring','uniqBy','orderBy','Unable\x20to\x20retrieve\x20RPC\x20agents\x20(Routing)','offline','unknown','unavailable','ringing','voiceStatus','busy','charAt','toUpperCase','select','ui.','InteractionId','field','ui.createdAt','user_has_','_interactions','ui.UserId\x20=\x20?','toString','OpenTabs','util','lodash','squel','jayson/promise','ioredis','../../components/parsers/qs','../../config/logger','api','../../config/license/util','../../errors/api','../../mysqldb','socket.io-emitter','register','defaults','client','http','request','then','info','User,\x20%s,\x20%s','request\x20sent','debug','User,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','sendStatus','end','status','json','offset','undefined','count','limit','set','update','agent','emit','userNotification:recalc:','destroy','get','role','admin','Users','user','telephone','filter','map','value','UserProfileResource','stack','name','send','index','User','rawAttributes','fieldName','type','password','salt','getOptions','where','query','includeAll','include','userSetting','includes','attributes','findAll','rows','openTabs','true','length','push','chat','sms','dataValues','fax','mail','openchannel','whatsapp','all','show','params','differenceBy','keys','filters','intersection','model','fields','UserSetting','options','catch','body','describe','addContacts','find','ids','omit','internal','Setting','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','fullname','email','permissions','101','103','113','110','104','105','106','107','108','109','100','111','114','115','create','Unauthorized','Unauthorized.\x20You\x20must\x20be\x20an\x20administrator\x20in\x20order\x20to\x20create\x20another\x20administrator','checkUserLimits','settingsEnabled','userProfileId','VoiceMail','UserProfileSection','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','Telephones','isEmpty','autoAssociation','compact','Agents','changePassword','oldPassword','newPassword','ValidationError','Sequelize','Wrong\x20credentials','Invalid\x20body\x20format.\x20Use\x20newPassword','findOne','securePassword','enforcePasswordHistory','passwordHistoryLimit','validatePasswordPattern','previousPasswords','validatePasswordHistory','updatePasswordsHistory','addQueues','online','loginInPause','voicePause','interface','isValidChannel','Unknown\x20channel','add','capitalize','Queues','penalty','spread','toLowerCase','QueueId','Queue:save','voice','format','UserVoiceQueueRt','upsert','removeQueues','channel','isArray','Queue:remove','addAvatar','userpic','file','filename','getAvatar','server/files/images/logos/default_profile.png','download','existsSync','join','root','getOpenTabs','ChatOpenTabs','CHAT','createdAt','FaxOpenTabs','FAX','OPENCHANNEL'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0xdf7e,0xcd));var _0xedf7=function(_0x6b598f,_0x4a3eb1){_0x6b598f=_0x6b598f-0x0;var _0x8b5c15=_0xdf7e[_0x6b598f];return _0x8b5c15;};'use strict';var moment=require('moment');var util=require(_0xedf7('0x0'));var path=require('path');var fs=require('fs');var _=require(_0xedf7('0x1'));var squel=require(_0xedf7('0x2'));var jayson=require(_0xedf7('0x3'));var Redis=require(_0xedf7('0x4'));var authService=require('../../components/auth/service');var qs=require(_0xedf7('0x5'));var logger=require(_0xedf7('0x6'))(_0xedf7('0x7'));var utils=require('../../config/utils');var config=require('../../config/environment');var licenseUtil=require(_0xedf7('0x8'));var APIBadRequestError=require('../../errors/api')['APIBadRequestError'];var APINotFoundError=require(_0xedf7('0x9'))['APINotFoundError'];var APIHandleError=require('../../errors/api')['handleError'];var db=require(_0xedf7('0xa'))['db'];var socket=require(_0xedf7('0xb'))(new Redis(config['redis']));require('./user.socket')[_0xedf7('0xc')](socket);config['redis']=_[_0xedf7('0xd')](config['redis'],{'host':'localhost','port':0x18eb});var amiClient=jayson[_0xedf7('0xe')][_0xedf7('0xf')]({'port':0x232a});var values;function respondWithRpcPromise(_0x5911fa,_0x1fee20,_0x576f9c,_0x587671){return new Promise(function(_0x5de773,_0x4e7dde){var _0xfb535c=_0x587671||amiClient;return _0xfb535c[_0xedf7('0x10')](_0x5911fa,_0x576f9c)[_0xedf7('0x11')](function(_0x49fbe0){logger[_0xedf7('0x12')](_0xedf7('0x13'),_0x1fee20,_0xedf7('0x14'));logger[_0xedf7('0x15')](_0xedf7('0x16'),_0x1fee20,_0xedf7('0x14'),JSON[_0xedf7('0x17')](_0x49fbe0));if(_0x49fbe0[_0xedf7('0x18')]){if(_0x49fbe0[_0xedf7('0x18')][_0xedf7('0x19')]===0x1f4){logger[_0xedf7('0x18')]('User,\x20%s,\x20%s',_0x1fee20,_0x49fbe0[_0xedf7('0x18')][_0xedf7('0x1a')]);return _0x4e7dde(_0x49fbe0[_0xedf7('0x18')][_0xedf7('0x1a')]);}logger[_0xedf7('0x18')](_0xedf7('0x13'),_0x1fee20,_0x49fbe0[_0xedf7('0x18')][_0xedf7('0x1a')]);return _0x5de773(_0x49fbe0[_0xedf7('0x18')][_0xedf7('0x1a')]);}else{logger[_0xedf7('0x12')](_0xedf7('0x13'),_0x1fee20,'request\x20sent');_0x5de773(_0x49fbe0[_0xedf7('0x1b')]['message']);}})['catch'](function(_0x5c72af){logger[_0xedf7('0x18')](_0xedf7('0x13'),_0x1fee20,_0x5c72af);_0x4e7dde(_0x5c72af);});});}function respondWithStatusCode(_0x2bb2ae,_0x541fb9){_0x541fb9=_0x541fb9||0xcc;return function(_0x49d3ef){if(_0x49d3ef){return _0x2bb2ae[_0xedf7('0x1c')](_0x541fb9);}return _0x2bb2ae['status'](_0x541fb9)[_0xedf7('0x1d')]();};}function respondWithResult(_0x39409f,_0x19a005){_0x19a005=_0x19a005||0xc8;return function(_0x4e037b){if(_0x4e037b){return _0x39409f[_0xedf7('0x1e')](_0x19a005)[_0xedf7('0x1f')](_0x4e037b);}};}function respondWithFilteredResult(_0x1ecc21,_0x4c3a92){return function(_0x30d281){if(_0x30d281){var _0x3a4163=typeof _0x4c3a92[_0xedf7('0x20')]===_0xedf7('0x21')&&typeof _0x4c3a92['limit']===_0xedf7('0x21');var _0x15aea2=_0x30d281['count'];var _0x15ac6e=_0x3a4163?0x0:_0x4c3a92[_0xedf7('0x20')];var _0x204f5b=_0x3a4163?_0x30d281[_0xedf7('0x22')]:_0x4c3a92[_0xedf7('0x20')]+_0x4c3a92[_0xedf7('0x23')];var _0x326cd9;if(_0x204f5b>=_0x15aea2){_0x204f5b=_0x15aea2;_0x326cd9=0xc8;}else{_0x326cd9=0xce;}_0x1ecc21[_0xedf7('0x1e')](_0x326cd9);return _0x1ecc21[_0xedf7('0x24')]('Content-Range',_0x15ac6e+'-'+_0x204f5b+'/'+_0x15aea2)['json'](_0x30d281);}return null;};}function saveUpdates(_0x939177){return function(_0x5f0e11){if(_0x5f0e11){return _0x5f0e11[_0xedf7('0x25')](_0x939177)[_0xedf7('0x11')](function(_0x385006){if(_0x385006['role']===_0xedf7('0x26')){socket[_0xedf7('0x27')](_0xedf7('0x28')+_0x385006['id'],_0x385006);}return _0x385006;});}return null;};}function removeEntity(_0x20734e){return function(_0x4908d0){if(_0x4908d0){return _0x4908d0[_0xedf7('0x29')]()[_0xedf7('0x11')](function(){var _0x1622ea=_0x4908d0[_0xedf7('0x2a')]({'plain':!![]});if(_0x1622ea[_0xedf7('0x2b')]===_0xedf7('0x2c'))return;var _0x536e06=[{'name':_0xedf7('0x2d'),'value':_0xedf7('0x2e'),'ignore':!![]},{'name':'Agents','value':'agent','ignore':![]},{'name':'Telephones','value':_0xedf7('0x2f'),'ignore':![]}];var _0x2a5e04=_(_0x536e06)[_0xedf7('0x30')]('ignore')[_0xedf7('0x31')](_0xedf7('0x32'))[_0xedf7('0x32')]();if(_['includes'](_0x2a5e04,_0x1622ea[_0xedf7('0x2b')])){return;}var _0x4bf9b1=_['find'](_0x536e06,[_0xedf7('0x32'),_0x1622ea[_0xedf7('0x2b')]])['name'];return db[_0xedf7('0x33')][_0xedf7('0x29')]({'where':{'type':_0x4bf9b1,'resourceId':_0x1622ea['id']}})[_0xedf7('0x11')](function(){return _0x4908d0;});})[_0xedf7('0x11')](function(){_0x20734e['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0x5261eb){return function(_0xa5ff67){if(!_0xa5ff67){_0x5261eb[_0xedf7('0x1c')](0x194);}return _0xa5ff67;};}function handleError(_0x20cfe5,_0x1a7409){_0x1a7409=_0x1a7409||0x1f4;return function(_0x23fcb9){logger['error'](_0x23fcb9[_0xedf7('0x34')]);if(_0x23fcb9['name']){delete _0x23fcb9[_0xedf7('0x35')];}_0x20cfe5[_0xedf7('0x1e')](_0x1a7409)[_0xedf7('0x36')](_0x23fcb9);};}exports[_0xedf7('0x37')]=function(_0xe96627,_0x5eca5f){var _0x1ba3ba={},_0x5ef5c7={'count':0x0,'rows':[]};var _0x35b7ad=_(db[_0xedf7('0x38')][_0xedf7('0x39')])['map'](function(_0x364df0){return{'name':_0x364df0[_0xedf7('0x3a')],'type':_0x364df0[_0xedf7('0x3b')]['key']};})[_0xedf7('0x30')](function(_0x3c1f4e){return!_['includes']([_0xedf7('0x3c'),_0xedf7('0x3d')],_0x3c1f4e[_0xedf7('0x35')]);})[_0xedf7('0x32')]();_0x1ba3ba=qs[_0xedf7('0x3e')](_0x35b7ad,_0xe96627);var _0x27bff0={'where':_0x1ba3ba[_0xedf7('0x3f')]};return db[_0xedf7('0x38')]['count'](_0x27bff0)[_0xedf7('0x11')](function(_0x142a06){_0x5ef5c7[_0xedf7('0x22')]=_0x142a06;if(_0xe96627[_0xedf7('0x40')][_0xedf7('0x41')]){_0x1ba3ba[_0xedf7('0x42')]=[{'all':!![]}];}if(_0xe96627['query'][_0xedf7('0x43')]==='true'){_0x1ba3ba[_0xedf7('0x42')]=[{'model':db['UserSetting'],'as':_0xedf7('0x43')}];}if(!_[_0xedf7('0x44')](_0x1ba3ba[_0xedf7('0x45')],'id')){_0x1ba3ba['attributes']['push']('id');}return db[_0xedf7('0x38')][_0xedf7('0x46')](_0x1ba3ba);})[_0xedf7('0x11')](function(_0x1b599d){_0x5ef5c7[_0xedf7('0x47')]=_0x1b599d;if(_0xe96627[_0xedf7('0x40')][_0xedf7('0x48')]===_0xedf7('0x49')){var _0x8e85bb=[];for(var _0x323399=0x0;_0x323399<_0x5ef5c7[_0xedf7('0x47')][_0xedf7('0x4a')];_0x323399++){_0x8e85bb[_0xedf7('0x4b')](get_open_tabs(_0xedf7('0x4c'),_0x5ef5c7[_0xedf7('0x47')][_0x323399]['dataValues']));_0x8e85bb['push'](get_open_tabs(_0xedf7('0x4d'),_0x5ef5c7[_0xedf7('0x47')][_0x323399][_0xedf7('0x4e')]));_0x8e85bb[_0xedf7('0x4b')](get_open_tabs(_0xedf7('0x4f'),_0x5ef5c7[_0xedf7('0x47')][_0x323399][_0xedf7('0x4e')]));_0x8e85bb['push'](get_open_tabs(_0xedf7('0x50'),_0x5ef5c7[_0xedf7('0x47')][_0x323399][_0xedf7('0x4e')]));_0x8e85bb[_0xedf7('0x4b')](get_open_tabs(_0xedf7('0x51'),_0x5ef5c7['rows'][_0x323399][_0xedf7('0x4e')]));_0x8e85bb['push'](get_open_tabs(_0xedf7('0x52'),_0x5ef5c7[_0xedf7('0x47')][_0x323399][_0xedf7('0x4e')]));}return Promise[_0xedf7('0x53')](_0x8e85bb)[_0xedf7('0x11')](function(){return _0x5ef5c7;});}else{return _0x5ef5c7;}})[_0xedf7('0x11')](respondWithFilteredResult(_0x5eca5f,_0x1ba3ba))['catch'](handleError(_0x5eca5f,null));};exports[_0xedf7('0x54')]=function(_0x502738,_0x4b1b85){var _0x17da2f={'raw':![],'where':{'id':_0x502738[_0xedf7('0x55')]['id']}},_0x125592={};_0x125592['model']=_[_0xedf7('0x56')](_['keys'](db[_0xedf7('0x38')]['rawAttributes']),[_0xedf7('0x3c'),_0xedf7('0x3d')]);_0x125592[_0xedf7('0x40')]=_[_0xedf7('0x57')](_0x502738['query']);_0x125592[_0xedf7('0x58')]=_[_0xedf7('0x59')](_0x125592[_0xedf7('0x5a')],_0x125592[_0xedf7('0x40')]);_0x17da2f[_0xedf7('0x45')]=_['intersection'](_0x125592[_0xedf7('0x5a')],qs[_0xedf7('0x5b')](_0x502738[_0xedf7('0x40')][_0xedf7('0x5b')]));_0x17da2f[_0xedf7('0x45')]=_0x17da2f[_0xedf7('0x45')][_0xedf7('0x4a')]?_0x17da2f[_0xedf7('0x45')]:_0x125592['model'];if(_0x502738[_0xedf7('0x40')][_0xedf7('0x41')]){_0x17da2f[_0xedf7('0x42')]=[{'all':!![]}];}if(_0x502738[_0xedf7('0x40')][_0xedf7('0x43')]===_0xedf7('0x49')){_0x17da2f['include']=[{'model':db[_0xedf7('0x5c')],'as':'userSetting'}];}_0x17da2f=_['merge']({},_0x17da2f,_0x502738[_0xedf7('0x5d')]);if(!_[_0xedf7('0x44')](_0x17da2f[_0xedf7('0x45')],'id')){_0x17da2f['attributes']['push']('id');}return db[_0xedf7('0x38')]['find'](_0x17da2f)[_0xedf7('0x11')](handleEntityNotFound(_0x4b1b85,null))[_0xedf7('0x11')](function(_0x32a424){var _0xae2d64=[];values=_0x32a424;if(_0x502738[_0xedf7('0x40')]['openTabs']===_0xedf7('0x49')){_0xae2d64[_0xedf7('0x4b')](get_open_tabs('chat',_0x32a424[_0xedf7('0x4e')]));_0xae2d64[_0xedf7('0x4b')](get_open_tabs(_0xedf7('0x4d'),_0x32a424[_0xedf7('0x4e')]));_0xae2d64[_0xedf7('0x4b')](get_open_tabs(_0xedf7('0x51'),_0x32a424['dataValues']));_0xae2d64[_0xedf7('0x4b')](get_open_tabs(_0xedf7('0x52'),_0x32a424[_0xedf7('0x4e')]));_0xae2d64[_0xedf7('0x4b')](get_open_tabs(_0xedf7('0x4f'),_0x32a424[_0xedf7('0x4e')]));_0xae2d64[_0xedf7('0x4b')](get_open_tabs(_0xedf7('0x50'),_0x32a424[_0xedf7('0x4e')]));return Promise[_0xedf7('0x53')](_0xae2d64);}else{return values;}})[_0xedf7('0x11')](function(){return values;})[_0xedf7('0x11')](respondWithResult(_0x4b1b85,null))[_0xedf7('0x5e')](handleError(_0x4b1b85,null));};exports[_0xedf7('0x25')]=function(_0x3e4e5e,_0x95bc63){if(_0x3e4e5e[_0xedf7('0x5f')]['id']){delete _0x3e4e5e[_0xedf7('0x5f')]['id'];}delete _0x3e4e5e[_0xedf7('0x5f')][_0xedf7('0x2b')];return db[_0xedf7('0x38')]['find']({'where':{'id':_0x3e4e5e[_0xedf7('0x55')]['id']}})[_0xedf7('0x11')](handleEntityNotFound(_0x95bc63,null))['then'](saveUpdates(_0x3e4e5e[_0xedf7('0x5f')],null))['then'](respondWithResult(_0x95bc63,null))[_0xedf7('0x5e')](handleError(_0x95bc63,null));};exports[_0xedf7('0x60')]=function(_0x4e56c1,_0x519ce5){return db[_0xedf7('0x38')][_0xedf7('0x60')]()[_0xedf7('0x11')](respondWithResult(_0x519ce5,null))['catch'](handleError(_0x519ce5,null));};exports[_0xedf7('0x61')]=function(_0x4b8390,_0x36b4be){return db[_0xedf7('0x38')][_0xedf7('0x62')]({'where':{'id':_0x4b8390[_0xedf7('0x55')]['id']}})[_0xedf7('0x11')](handleEntityNotFound(_0x36b4be,null))[_0xedf7('0x11')](function(_0x10b27c){if(_0x10b27c){return _0x10b27c[_0xedf7('0x61')](_0x4b8390[_0xedf7('0x5f')][_0xedf7('0x63')],_[_0xedf7('0x64')](_0x4b8390[_0xedf7('0x5f')],[_0xedf7('0x63'),'id'])||{});}})['then'](respondWithResult(_0x36b4be,null))[_0xedf7('0x5e')](handleError(_0x36b4be,null));};function validateUser(_0x3d820c){return new Promise(function(_0x3526e9,_0x7fe0c7){if(_0x3d820c[_0xedf7('0x65')])return _0x3526e9(_0x3d820c);return db[_0xedf7('0x66')]['findById'](0x1)[_0xedf7('0x11')](function(_0x437584){if(_0x437584['securePassword'])authService['validatePasswordPattern'](_0x3d820c[_0xedf7('0x3c')]);db['User']['max'](_0xedf7('0x65'))[_0xedf7('0x11')](function(_0x57f533){if(_[_0xedf7('0x67')](_0x57f533)){_0x3d820c[_0xedf7('0x65')]=_0x437584['min_internal']||0x1;return;}if(_[_0xedf7('0x67')](_0x437584[_0xedf7('0x68')])||_0x437584['min_internal']===_0x57f533){_0x3d820c[_0xedf7('0x65')]=_0x57f533+0x1;return;}if(_0x437584[_0xedf7('0x68')]>_0x57f533){_0x3d820c['internal']=_0x437584['min_internal'];return;}return db[_0xedf7('0x69')]['query'](_0xedf7('0x6a'),{'type':db['sequelize'][_0xedf7('0x6b')][_0xedf7('0x6c')]})[_0xedf7('0x11')](function(_0x114edb){if(_0x114edb&&_0x114edb[_0xedf7('0x4a')]){for(var _0x290561=0x0,_0x2bbd4f=_0x114edb[_0xedf7('0x4a')];_0x290561<_0x2bbd4f&&_['isNil'](_0x3d820c[_0xedf7('0x65')]);_0x290561++){if(_0x437584[_0xedf7('0x68')]<=_0x114edb[_0x290561][_0xedf7('0x6d')]){_0x3d820c['internal']=_0x114edb[_0x290561]['from'];}else if(_0x437584[_0xedf7('0x68')]>_0x114edb[_0x290561]['from']&&_0x437584[_0xedf7('0x68')]<=_0x114edb[_0x290561]['to']){_0x3d820c['internal']=_0x437584['min_internal'];}}}if(_[_0xedf7('0x67')](_0x3d820c[_0xedf7('0x65')])){_0x3d820c[_0xedf7('0x65')]=_0x57f533+0x1;}return _0x3526e9(_0x3d820c);});});})['catch'](function(_0x292d35){_0x7fe0c7(_0x292d35);});});}function updateUser(_0x2b5c93){return new Promise(function(_0x31ceb6,_0x37f3ff){try{if(_0x2b5c93[_0xedf7('0x6e')]){_0x2b5c93['mailbox']=_0x2b5c93[_0xedf7('0x65')];_0x2b5c93['VoiceMail']={'mailbox':_0x2b5c93[_0xedf7('0x65')],'password':_0x2b5c93[_0xedf7('0x3c')],'fullname':_0x2b5c93[_0xedf7('0x6f')],'email':_0x2b5c93[_0xedf7('0x70')]};}if(_0x2b5c93[_0xedf7('0x2b')]===_0xedf7('0x26')){if(!_0x2b5c93[_0xedf7('0x71')])_0x2b5c93[_0xedf7('0x71')]=[_0xedf7('0x72'),'102',_0xedf7('0x73'),_0xedf7('0x74'),_0xedf7('0x75'),_0xedf7('0x76'),_0xedf7('0x77'),_0xedf7('0x78'),_0xedf7('0x79'),_0xedf7('0x7a'),_0xedf7('0x7b'),_0xedf7('0x7c'),_0xedf7('0x7d'),_0xedf7('0x7e'),_0xedf7('0x7f')];}_0x31ceb6(_0x2b5c93);}catch(_0x30a834){_0x37f3ff(_0x30a834);}});}exports[_0xedf7('0x80')]=function(_0x3bca85,_0x110495){if(_0x3bca85[_0xedf7('0x2e')]['role']===_0xedf7('0x26'))throw new Error(_0xedf7('0x81'));if(_0x3bca85[_0xedf7('0x5f')][_0xedf7('0x2b')]==='user'&&_0x3bca85[_0xedf7('0x2e')][_0xedf7('0x2b')]!=='admin'){throw new Error('Unauthorized.\x20You\x20must\x20be\x20an\x20administrator\x20in\x20order\x20to\x20create\x20an\x20user');}if(_0x3bca85[_0xedf7('0x5f')][_0xedf7('0x2b')]===_0xedf7('0x2c')&&_0x3bca85[_0xedf7('0x2e')][_0xedf7('0x2b')]!==_0xedf7('0x2c')){throw new Error(_0xedf7('0x82'));}return licenseUtil[_0xedf7('0x83')]([_0x3bca85[_0xedf7('0x5f')]])[_0xedf7('0x11')](function(){return validateUser(_0x3bca85[_0xedf7('0x5f')]);})[_0xedf7('0x11')](function(_0x489eb0){return updateUser(_0x489eb0)[_0xedf7('0x11')](function(_0x52f946){if(_0x52f946[_0xedf7('0x2b')]===_0xedf7('0x2c')){_0x52f946[_0xedf7('0x84')]=_0x3bca85[_0xedf7('0x2e')][_0xedf7('0x84')];delete _0x52f946[_0xedf7('0x85')];}return _0x52f946;});})[_0xedf7('0x11')](function(_0x9815aa){return db['User'][_0xedf7('0x80')](_0x9815aa,{'include':[{'model':db['VoiceMail'],'as':_0xedf7('0x86')}]});})[_0xedf7('0x11')](function(_0x596fc0){if(_0x3bca85[_0xedf7('0x5f')][_0xedf7('0x2b')]===_0xedf7('0x2e'))return _0x596fc0;if(_0x3bca85[_0xedf7('0x2e')][_0xedf7('0x2b')]!==_0xedf7('0x2e'))return _0x596fc0;return db[_0xedf7('0x87')][_0xedf7('0x62')]({'where':{'name':_0x596fc0[_0xedf7('0x2b')]===_0xedf7('0x26')?'Agents':'Telephones','userProfileId':_0x3bca85[_0xedf7('0x2e')][_0xedf7('0x85')]},'raw':!![]})[_0xedf7('0x11')](function(_0x30da21){if(!_0x30da21||_0x30da21['autoAssociation']!=0x0)return _0x596fc0;return db['UserProfileResource'][_0xedf7('0x80')]({'name':_0x596fc0[_0xedf7('0x35')],'resourceId':_0x596fc0['id'],'type':_0x30da21['name'],'sectionId':_0x30da21['id']},{})['then'](function(){return _0x596fc0;});})['catch'](function(_0x957939){logger[_0xedf7('0x18')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x957939);throw _0x957939;});})[_0xedf7('0x11')](respondWithResult(_0x110495,0xc9))[_0xedf7('0x5e')](handleError(_0x110495,null));};exports[_0xedf7('0x88')]=function(_0x2f4284,_0x52bfaf){var _0x59f57d=_0x2f4284[_0xedf7('0x5f')];var _0x2a9329=[];if(_0x2f4284[_0xedf7('0x2e')][_0xedf7('0x2b')]===_0xedf7('0x26'))throw new Error(_0xedf7('0x81'));if(_[_0xedf7('0x89')](_0x59f57d,[_0xedf7('0x2b'),_0xedf7('0x2e')])&&_0x2f4284[_0xedf7('0x2e')]['role']!=='admin'){throw new Error(_0xedf7('0x8a'));}if(_[_0xedf7('0x89')](_0x59f57d,['role',_0xedf7('0x2c')])&&_0x2f4284[_0xedf7('0x2e')][_0xedf7('0x2b')]!=='admin'){throw new Error(_0xedf7('0x8b'));}return licenseUtil[_0xedf7('0x83')](_0x59f57d)[_0xedf7('0x11')](function(){return validateUser(_0x59f57d[0x0]);})[_0xedf7('0x11')](function(){for(var _0x38c3d8=0x1;_0x38c3d8<_0x59f57d[_0xedf7('0x4a')];_0x38c3d8++){var _0x4a735d=_0x59f57d[_0x38c3d8-0x1]['internal'];if(!_0x59f57d[_0x38c3d8]['internal'])_0x59f57d[_0x38c3d8][_0xedf7('0x65')]=_0x4a735d+0x1;_0x2a9329[_0xedf7('0x4b')](validateUser(_0x59f57d[_0x38c3d8]));}return Promise[_0xedf7('0x53')](_0x2a9329);})[_0xedf7('0x11')](function(){_0x2a9329=[];for(var _0x4a18fa=0x0;_0x4a18fa<_0x59f57d[_0xedf7('0x4a')];_0x4a18fa++){_0x2a9329[_0xedf7('0x4b')](updateUser(_0x59f57d[_0x4a18fa]));}return Promise[_0xedf7('0x53')](_0x2a9329);})[_0xedf7('0x11')](function(){_0x2a9329=_0x59f57d['map'](function(_0x35ccfd){return db[_0xedf7('0x38')][_0xedf7('0x80')](_0x35ccfd,{'include':[{'model':db[_0xedf7('0x86')],'as':_0xedf7('0x86')}]})[_0xedf7('0x11')](function(_0x107e2b){_0x35ccfd['id']=_0x107e2b['id'];return _0x35ccfd;});});return Promise[_0xedf7('0x53')](_0x2a9329);})['then'](function(_0x5abf94){if(_0x2f4284[_0xedf7('0x5f')]['role']===_0xedf7('0x2e'))return _0x5abf94;if(_0x2f4284[_0xedf7('0x2e')]['role']!==_0xedf7('0x2e'))return _0x5abf94;var _0x5cf4fe=_[_0xedf7('0x89')](_0x5abf94,function(_0x440226){return _0x440226['role']===_0xedf7('0x26')||_0x440226['role']===_0xedf7('0x2f');});if(!_0x5cf4fe)return _0x5abf94;return db[_0xedf7('0x87')]['findAll']({'where':{'name':{'$or':['Agents',_0xedf7('0x8c')]},'userProfileId':_0x2f4284[_0xedf7('0x2e')][_0xedf7('0x85')]},'raw':!![]})['then'](function(_0x49a492){if(_[_0xedf7('0x8d')](_0x49a492)||!_[_0xedf7('0x89')](_0x49a492,[_0xedf7('0x8e'),0x0]))return _0x5abf94;_0x2a9329=[];var _0x133406=_(_0x49a492)[_0xedf7('0x31')](function(_0x5a34de){if(_0x5a34de[_0xedf7('0x8e')]===0x1)return;return _0x5a34de['name']==='Agents'?_0xedf7('0x26'):_0xedf7('0x2f');})[_0xedf7('0x8f')]()[_0xedf7('0x32')]();for(var _0x5632aa=0x0;_0x5632aa<_0x5abf94[_0xedf7('0x4a')];_0x5632aa++){if(!_[_0xedf7('0x44')](_0x133406,_0x5abf94[_0x5632aa]['role']))return;var _0x3c4f67=_0x5abf94[_0x5632aa]['role']===_0xedf7('0x26')?_0xedf7('0x90'):_0xedf7('0x8c');_0x2a9329[_0xedf7('0x4b')](db['UserProfileResource']['create']({'name':_0x5abf94[_0x5632aa]['name'],'resourceId':_0x5abf94[_0x5632aa]['id'],'type':_0x3c4f67,'sectionId':_[_0xedf7('0x62')](_0x49a492,['name',_0x3c4f67])['id']},{}));}return Promise[_0xedf7('0x53')](_0x2a9329);});})['then'](respondWithResult(_0x52bfaf,0xc9))[_0xedf7('0x5e')](handleError(_0x52bfaf,null));};exports[_0xedf7('0x91')]=function(_0x11f785,_0x43a6e5){if(_0x11f785[_0xedf7('0x5f')]['id']){delete _0x11f785[_0xedf7('0x5f')]['id'];}return db[_0xedf7('0x38')][_0xedf7('0x62')]({'where':{'id':_0x11f785[_0xedf7('0x55')]['id']}})['then'](function(_0x5bf40d){if(!_0x5bf40d)return null;if(_0x5bf40d['id']===_0x11f785[_0xedf7('0x2e')]['id']){if(!_0x11f785[_0xedf7('0x5f')][_0xedf7('0x92')]||!_0x11f785[_0xedf7('0x5f')][_0xedf7('0x93')]){throw new db['Sequelize'][(_0xedf7('0x94'))]('Invalid\x20body\x20format.\x20Use\x20oldPassword\x20and\x20newPassword');}if(!_0x5bf40d['authenticate'](_0x11f785['body'][_0xedf7('0x92')])){throw new db[(_0xedf7('0x95'))][(_0xedf7('0x94'))](_0xedf7('0x96'));}if(_0x11f785[_0xedf7('0x5f')][_0xedf7('0x92')]===_0x11f785[_0xedf7('0x5f')]['newPassword']){throw new db[(_0xedf7('0x95'))][(_0xedf7('0x94'))]('New\x20password\x20must\x20be\x20different\x20from\x20old\x20password');}}else if(_0x11f785[_0xedf7('0x2e')][_0xedf7('0x2b')]==='admin'){if(!_0x11f785[_0xedf7('0x5f')]['newPassword']){throw new db['Sequelize'][(_0xedf7('0x94'))](_0xedf7('0x97'));}}else if(_0x11f785['user'][_0xedf7('0x2b')]===_0xedf7('0x2e')){if(!_0x11f785[_0xedf7('0x5f')][_0xedf7('0x93')]){throw new db[(_0xedf7('0x95'))][(_0xedf7('0x94'))](_0xedf7('0x97'));}if(_0x5bf40d[_0xedf7('0x2b')]!=='agent'){throw new db[(_0xedf7('0x95'))][(_0xedf7('0x94'))](_0xedf7('0x81'));}}else{throw new db[(_0xedf7('0x95'))][(_0xedf7('0x94'))]('Unauthorized');}return _0x5bf40d;})[_0xedf7('0x11')](handleEntityNotFound(_0x43a6e5,null))['then'](function(_0x18631e){return db[_0xedf7('0x66')][_0xedf7('0x98')]({'attributes':['id',_0xedf7('0x99'),_0xedf7('0x9a'),_0xedf7('0x9b')]})[_0xedf7('0x11')](function(_0x3d0859){if(_0x3d0859[_0xedf7('0x99')])authService[_0xedf7('0x9c')](_0x11f785[_0xedf7('0x5f')][_0xedf7('0x93')]);if(!_0x3d0859['enforcePasswordHistory']||!_0x18631e[_0xedf7('0x9d')])return _0x18631e;authService[_0xedf7('0x9e')](_0x11f785[_0xedf7('0x5f')]['newPassword'],_0x18631e['previousPasswords'],_0x3d0859[_0xedf7('0x9b')]);return _0x18631e;})[_0xedf7('0x11')](saveUpdates({'password':_0x11f785[_0xedf7('0x5f')][_0xedf7('0x93')],'passwordResetAt':_0x11f785[_0xedf7('0x2e')]['id']==_0x11f785[_0xedf7('0x55')]['id']?moment():null,'previousPasswords':authService[_0xedf7('0x9f')](_0x11f785['body']['newPassword'],_0x18631e['previousPasswords'])},null));})[_0xedf7('0x11')](respondWithResult(_0x43a6e5,null))[_0xedf7('0x5e')](handleError(_0x43a6e5,null));};exports[_0xedf7('0xa0')]=function(_0x22130a,_0x80c3f){var _0x25e9cc=_0x22130a[_0xedf7('0x5f')]['channel'];return db[_0xedf7('0x38')]['find']({'where':{'id':_0x22130a['params']['id']},'attributes':['id','name','role',_0xedf7('0xa1'),_0xedf7('0xa2'),_0xedf7('0xa3'),_0xedf7('0xa4')]})[_0xedf7('0x11')](handleEntityNotFound(_0x80c3f,null))[_0xedf7('0x11')](function(_0x4b1657){if(_0x4b1657){if(!utils[_0xedf7('0xa5')](_0x25e9cc)){throw new db[(_0xedf7('0x95'))][(_0xedf7('0x94'))](_0xedf7('0xa6'));}return _0x4b1657[_0xedf7('0xa7')+_[_0xedf7('0xa8')](_0x25e9cc['toLowerCase']())+_0xedf7('0xa9')](_0x22130a[_0xedf7('0x5f')][_0xedf7('0x63')],{'penalty':_0x22130a[_0xedf7('0x5f')][_0xedf7('0xaa')]||0x0})[_0xedf7('0xab')](function(_0x35a1dd){for(var _0x3179f7=0x0;_0x3179f7<_0x22130a[_0xedf7('0x5f')][_0xedf7('0x63')][_0xedf7('0x4a')];_0x3179f7+=0x1){var _0x2fe0cc={'UserId':Number(_0x22130a[_0xedf7('0x55')]['id'])};_0x2fe0cc[_['capitalize'](_0x25e9cc[_0xedf7('0xac')]())+_0xedf7('0xad')]=Number(_0x22130a['body'][_0xedf7('0x63')][_0x3179f7]);socket[_0xedf7('0x27')](_0xedf7('0x2e')+_[_0xedf7('0xa8')](_0x25e9cc[_0xedf7('0xac')]())+_0xedf7('0xae'),_0x2fe0cc);}return _0x35a1dd;})[_0xedf7('0x11')](function(){if(_0x25e9cc===_0xedf7('0xaf')){return db['VoiceQueue'][_0xedf7('0x46')]({'where':{'id':_0x22130a[_0xedf7('0x5f')]['ids']||[]},'raw':!![],'attributes':['id',_0xedf7('0x35')]});}})['then'](function(_0x212d33){var _0x3d6a4c=_0x4b1657[_0xedf7('0x2a')]({'plain':!![]});var _0x3e748e=[];if(_0x25e9cc==='voice'&&_0x3d6a4c[_0xedf7('0x2b')]===_0xedf7('0x26')&&_0x3d6a4c[_0xedf7('0xa1')]){for(let _0x3eb6b1=0x0;_0x3eb6b1<_0x212d33[_0xedf7('0x4a')];_0x3eb6b1+=0x1){_0x3e748e['push']({'membername':_0x3d6a4c[_0xedf7('0x35')],'UserId':_0x3d6a4c['id'],'queue_name':_0x212d33[_0x3eb6b1][_0xedf7('0x35')],'VoiceQueueId':_0x212d33[_0x3eb6b1]['id'],'interface':_[_0xedf7('0x67')](_0x3d6a4c['interface'])?util[_0xedf7('0xb0')]('SIP/%s',_0x3d6a4c[_0xedf7('0x35')]):_0x3d6a4c['interface'],'paused':_0x3d6a4c[_0xedf7('0xa3')]||![],'penalty':_0x22130a[_0xedf7('0x5f')][_0xedf7('0xaa')]||0x0});}return Promise[_0xedf7('0x53')](_0x3e748e[_0xedf7('0x31')](function(_0xc02822){return db[_0xedf7('0xb1')][_0xedf7('0xb2')](_0xc02822);}));}return _0x4b1657;});}})[_0xedf7('0x11')](respondWithStatusCode(_0x80c3f,null))[_0xedf7('0x5e')](handleError(_0x80c3f,null));};exports[_0xedf7('0xb3')]=function(_0x2e21b5,_0x5c5e14){var _0x441e44,_0xa31425;return db[_0xedf7('0x38')][_0xedf7('0x62')]({'where':{'id':_0x2e21b5[_0xedf7('0x55')]['id']},'attributes':['id',_0xedf7('0x35'),_0xedf7('0x2b')]})[_0xedf7('0x11')](handleEntityNotFound(_0x5c5e14,null))[_0xedf7('0x11')](function(_0x218df2){if(_0x218df2){_0x441e44=_0x218df2;if(!_0x2e21b5[_0xedf7('0x40')][_0xedf7('0xb4')]||!utils[_0xedf7('0xa5')](_0x2e21b5['query'][_0xedf7('0xb4')])){throw new db[(_0xedf7('0x95'))][(_0xedf7('0x94'))](_0xedf7('0xa6'));}return _0x218df2['remove'+_['capitalize'](_0x2e21b5[_0xedf7('0x40')][_0xedf7('0xb4')][_0xedf7('0xac')]())+_0xedf7('0xa9')](_0x2e21b5[_0xedf7('0x40')]['ids']);}})[_0xedf7('0x11')](function(_0x331bd2){if(_[_0xedf7('0xb5')](_0x2e21b5['query'][_0xedf7('0x63')])){for(var _0x6fffd8=0x0;_0x6fffd8<_0x2e21b5[_0xedf7('0x40')][_0xedf7('0x63')][_0xedf7('0x4a')];_0x6fffd8+=0x1){_0xa31425={'UserId':Number(_0x2e21b5[_0xedf7('0x55')]['id'])};_0xa31425[_['capitalize'](_0x2e21b5[_0xedf7('0x40')][_0xedf7('0xb4')][_0xedf7('0xac')]())+_0xedf7('0xad')]=Number(_0x2e21b5['query'][_0xedf7('0x63')][_0x6fffd8]);socket['emit']('user'+_[_0xedf7('0xa8')](_0x2e21b5[_0xedf7('0x40')][_0xedf7('0xb4')]['toLowerCase']())+_0xedf7('0xb6'),_0xa31425);}}else{_0xa31425={'UserId':Number(_0x2e21b5[_0xedf7('0x55')]['id'])};_0xa31425[_[_0xedf7('0xa8')](_0x2e21b5[_0xedf7('0x40')]['channel'][_0xedf7('0xac')]())+'QueueId']=Number(_0x2e21b5['query'][_0xedf7('0x63')]);socket[_0xedf7('0x27')]('user'+_[_0xedf7('0xa8')](_0x2e21b5[_0xedf7('0x40')][_0xedf7('0xb4')][_0xedf7('0xac')]())+'Queue:remove',_0xa31425);}return _0x331bd2;})[_0xedf7('0x11')](function(){if(_0x2e21b5[_0xedf7('0x40')]['channel']===_0xedf7('0xaf')){return db[_0xedf7('0xb1')][_0xedf7('0x29')]({'where':{'UserId':_0x2e21b5[_0xedf7('0x55')]['id'],'VoiceQueueId':_0x2e21b5[_0xedf7('0x40')][_0xedf7('0x63')]},'individualHooks':!![]})[_0xedf7('0x11')](function(){return _0x441e44;});}return _0x441e44;})[_0xedf7('0x11')](respondWithStatusCode(_0x5c5e14,null))[_0xedf7('0x5e')](handleError(_0x5c5e14,null));};exports[_0xedf7('0xb7')]=function(_0x3d6e4b,_0x522404){_0x3d6e4b[_0xedf7('0x5f')][_0xedf7('0xb8')]=_0x3d6e4b[_0xedf7('0xb9')][_0xedf7('0xba')];return db['User'][_0xedf7('0x62')]({'where':{'id':_0x3d6e4b[_0xedf7('0x55')]['id']}})[_0xedf7('0x11')](handleEntityNotFound(_0x522404,null))[_0xedf7('0x11')](saveUpdates(_0x3d6e4b['body'],null))[_0xedf7('0x11')](respondWithResult(_0x522404,null))[_0xedf7('0x5e')](handleError(_0x522404,null));};exports[_0xedf7('0xbb')]=function(_0x3d61e1,_0x941b01){var _0x1f0491=path['join'](config['root'],_0xedf7('0xbc'));return db[_0xedf7('0x38')][_0xedf7('0x62')]({'where':{'id':_0x3d61e1[_0xedf7('0x55')]['id']},'attributes':['id',_0xedf7('0xb8')],'raw':!![]})[_0xedf7('0x11')](handleEntityNotFound(_0x941b01,null))[_0xedf7('0x11')](function(_0x387140){if(_0x387140){if(_[_0xedf7('0x67')](_0x387140['userpic'])){return _0x941b01[_0xedf7('0xbd')](_0x1f0491);}else{if(!fs[_0xedf7('0xbe')](path[_0xedf7('0xbf')](config[_0xedf7('0xc0')],'server/files/images/',_0x387140[_0xedf7('0xb8')]))){return _0x941b01[_0xedf7('0xbd')](_0x1f0491);}return _0x941b01[_0xedf7('0xbd')](path['join'](config[_0xedf7('0xc0')],'server/files/images/',_0x387140['userpic']));}}})[_0xedf7('0x5e')](handleError(_0x941b01,null));};exports[_0xedf7('0xc1')]=function(_0x449cbf,_0x218b3f){return db[_0xedf7('0x38')][_0xedf7('0x62')]({'where':{'id':_0x449cbf[_0xedf7('0x55')]['id']},'attributes':['id']})[_0xedf7('0x11')](handleEntityNotFound(_0x218b3f,null))[_0xedf7('0x11')](function(_0x85db6d){var _0x5861f4=[];values=_0x85db6d[_0xedf7('0x4e')];_0x5861f4[_0xedf7('0x4b')](get_open_tabs('chat',_0x85db6d[_0xedf7('0x4e')]));_0x5861f4[_0xedf7('0x4b')](get_open_tabs(_0xedf7('0x4d'),_0x85db6d['dataValues']));_0x5861f4[_0xedf7('0x4b')](get_open_tabs(_0xedf7('0x51'),_0x85db6d['dataValues']));_0x5861f4['push'](get_open_tabs(_0xedf7('0x52'),_0x85db6d[_0xedf7('0x4e')]));_0x5861f4[_0xedf7('0x4b')](get_open_tabs('fax',_0x85db6d[_0xedf7('0x4e')]));_0x5861f4[_0xedf7('0x4b')](get_open_tabs('mail',_0x85db6d[_0xedf7('0x4e')]));return Promise['all'](_0x5861f4);})[_0xedf7('0x11')](function(_0x340edd){if(_0x340edd){var _0x462c83=_['map'](values[_0xedf7('0xc2')],function(_0x43f7e2){return{'channel':_0xedf7('0xc3'),'id':_0x43f7e2['id'],'createdAt':_0x43f7e2[_0xedf7('0xc4')]};});var _0x177328=_['map'](values[_0xedf7('0xc5')],function(_0x4129e5){return{'channel':_0xedf7('0xc6'),'id':_0x4129e5['id'],'createdAt':_0x4129e5['createdAt']};});var _0x49ef46=_[_0xedf7('0x31')](values['OpenchannelOpenTabs'],function(_0x16ac7e){return{'channel':_0xedf7('0xc7'),'id':_0x16ac7e['id'],'createdAt':_0x16ac7e['createdAt']};});var _0x2d5995=_[_0xedf7('0x31')](values[_0xedf7('0xc8')],function(_0x2af212){return{'channel':'MAIL','id':_0x2af212['id'],'createdAt':_0x2af212[_0xedf7('0xc4')]};});var _0x17edc1=_[_0xedf7('0x31')](values[_0xedf7('0xc9')],function(_0x394477){return{'channel':_0xedf7('0xca'),'id':_0x394477['id'],'createdAt':_0x394477[_0xedf7('0xc4')]};});var _0x577957=_[_0xedf7('0x31')](values[_0xedf7('0xcb')],function(_0x330e6b){return{'channel':_0xedf7('0xcc'),'id':_0x330e6b['id'],'createdAt':_0x330e6b[_0xedf7('0xc4')]};});var _0x231e94=_[_0xedf7('0xcd')](_0x462c83,_0x177328,_0x49ef46,_0x2d5995,_0x17edc1,_0x577957);var _0xa6843a={'count':_0x231e94['length'],'rows':_0x231e94};return _0xa6843a;}else return null;})[_0xedf7('0x11')](respondWithResult(_0x218b3f,null))[_0xedf7('0x5e')](handleError(_0x218b3f,null));};exports[_0xedf7('0xce')]=function(_0x23c181,_0x39016e){var _0xf71e7c={};var _0x2d5b8f={};var _0x1396e9;var _0x2555e2;return db[_0xedf7('0x38')]['findOne']({'where':{'id':_0x23c181[_0xedf7('0x55')]['id']}})[_0xedf7('0x11')](handleEntityNotFound(_0x39016e,null))[_0xedf7('0x11')](function(_0x3017d6){if(_0x3017d6){_0x1396e9=_0x3017d6;_0x2d5b8f['model']=_[_0xedf7('0x57')](db[_0xedf7('0xcf')][_0xedf7('0x39')]);_0x2d5b8f[_0xedf7('0x40')]=_['keys'](_0x23c181[_0xedf7('0x40')]);_0x2d5b8f[_0xedf7('0x58')]=_[_0xedf7('0x59')](_0x2d5b8f[_0xedf7('0x5a')],_0x2d5b8f[_0xedf7('0x40')]);_0xf71e7c[_0xedf7('0x45')]=_['intersection'](_0x2d5b8f['model'],qs[_0xedf7('0x5b')](_0x23c181[_0xedf7('0x40')]['fields']));_0xf71e7c[_0xedf7('0x45')]=_0xf71e7c[_0xedf7('0x45')][_0xedf7('0x4a')]?_0xf71e7c['attributes']:_0x2d5b8f['model'];_0xf71e7c[_0xedf7('0xd0')]=qs[_0xedf7('0xd1')](_0x23c181[_0xedf7('0x40')][_0xedf7('0xd1')]);_0xf71e7c['where']=qs[_0xedf7('0x58')](_['pick'](_0x23c181['query'],_0x2d5b8f[_0xedf7('0x58')]));if(_0x23c181[_0xedf7('0x40')][_0xedf7('0x30')]){_0xf71e7c['where']=_[_0xedf7('0xd2')](_0xf71e7c['where'],{'$or':_[_0xedf7('0x31')](_0xf71e7c[_0xedf7('0x45')],function(_0x1304af){var _0x5780d0={};_0x5780d0[_0x1304af]={'$like':'%'+_0x23c181['query']['filter']+'%'};return _0x5780d0;})});}_0xf71e7c=_[_0xedf7('0xd2')]({},_0xf71e7c,_0x23c181[_0xedf7('0x5d')]);return _0x1396e9[_0xedf7('0xce')](_0xf71e7c);}})[_0xedf7('0x11')](function(_0x449c9d){if(_0x449c9d){_0x2555e2=_0x449c9d['length'];if(_0x23c181[_0xedf7('0x40')][_0xedf7('0xd3')]('includeAll')){_0xf71e7c[_0xedf7('0x42')]=[{'model':db[_0xedf7('0xd4')],'as':_0xedf7('0xd5'),'required':![]},{'model':db[_0xedf7('0xd6')],'as':'Tags','attributes':['id',_0xedf7('0x35'),'color'],'where':_0x23c181['query'][_0xedf7('0xd7')]?{'id':_0x23c181[_0xedf7('0x40')][_0xedf7('0xd7')]}:undefined,'required':_0x23c181[_0xedf7('0x40')][_0xedf7('0xd7')]?!![]:![]}];}if(!_0x23c181[_0xedf7('0x40')][_0xedf7('0xd3')](_0xedf7('0xd8'))){_0xf71e7c[_0xedf7('0x23')]=qs[_0xedf7('0x23')](_0x23c181[_0xedf7('0x40')]['limit']);_0xf71e7c[_0xedf7('0x20')]=qs[_0xedf7('0x20')](_0x23c181['query']['offset']);}return _0x1396e9['getContacts'](_0xf71e7c);}})[_0xedf7('0x11')](function(_0xa7093e){if(_0xa7093e){return _0xa7093e?{'count':_0x2555e2,'rows':_0xa7093e}:null;}})['then'](respondWithResult(_0x39016e,null))[_0xedf7('0x5e')](handleError(_0x39016e,null));};exports[_0xedf7('0xd9')]=function(_0x887e66,_0xd38c36){var _0x34c290;var _0x2192b0={};var _0x265181;return db['User'][_0xedf7('0x98')]({'where':{'id':_0x887e66[_0xedf7('0x55')]['id']},'attributes':['id',_0xedf7('0x35'),'role']})[_0xedf7('0x11')](handleEntityNotFound(_0xd38c36,null))[_0xedf7('0x11')](function(_0x15a2db){if(!utils[_0xedf7('0xa5')](_0x887e66[_0xedf7('0x40')][_0xedf7('0xb4')])){throw new db[(_0xedf7('0x95'))][(_0xedf7('0x94'))](_0xedf7('0xa6'));}_0x34c290=_0x15a2db;var _0x230a47={};_0x230a47['model']=_[_0xedf7('0x57')](db[_[_0xedf7('0xa8')](_0x887e66[_0xedf7('0x40')]['channel'])+_0xedf7('0xda')]['rawAttributes']);_0x230a47[_0xedf7('0x40')]=_['keys'](_0x887e66[_0xedf7('0x40')]);_0x230a47[_0xedf7('0x58')]=_[_0xedf7('0x59')](_0x230a47['model'],_0x230a47[_0xedf7('0x40')]);_0x2192b0['attributes']=_[_0xedf7('0x59')](_0x230a47[_0xedf7('0x5a')],qs[_0xedf7('0x5b')](_0x887e66[_0xedf7('0x40')][_0xedf7('0x5b')]));_0x2192b0['attributes']=_0x2192b0['attributes']['length']?_0x2192b0[_0xedf7('0x45')]:_0x230a47[_0xedf7('0x5a')];_0x2192b0['order']=qs[_0xedf7('0xd1')](_0x887e66[_0xedf7('0x40')][_0xedf7('0xd1')]);_0x2192b0['where']=qs[_0xedf7('0x58')](_[_0xedf7('0xdb')](_0x887e66['query'],_0x230a47['filters']));if(_0x887e66[_0xedf7('0x40')][_0xedf7('0x30')]){_0x2192b0[_0xedf7('0x3f')]=_[_0xedf7('0xd2')](_0x2192b0[_0xedf7('0x3f')],{'$or':_[_0xedf7('0x31')](_0x2192b0['attributes'],function(_0x26e204){var _0x115120={};_0x115120[_0x26e204]={'$like':'%'+_0x887e66[_0xedf7('0x40')][_0xedf7('0x30')]+'%'};return _0x115120;})});}_0x2192b0=_['merge']({},_0x2192b0,_0x887e66[_0xedf7('0x5d')]);switch(_0x34c290[_0xedf7('0x2b')]){case _0xedf7('0x2c'):return db[_[_0xedf7('0xa8')](_0x887e66[_0xedf7('0x40')][_0xedf7('0xb4')])+_0xedf7('0xda')][_0xedf7('0x46')](_0x2192b0);case _0xedf7('0x2e'):case _0xedf7('0x26'):return _0x34c290['get'+_[_0xedf7('0xa8')](_0x887e66[_0xedf7('0x40')]['channel'])+_0xedf7('0xa9')](_0x2192b0);default:throw new db[(_0xedf7('0x95'))]['ValidationError']('Unknown\x20role');}})['then'](function(_0x732191){_0x265181=_0x732191[_0xedf7('0x4a')];if(!_0x887e66[_0xedf7('0x40')][_0xedf7('0xd3')]('nolimit')){_0x2192b0['limit']=qs[_0xedf7('0x23')](_0x887e66[_0xedf7('0x40')][_0xedf7('0x23')]);_0x2192b0['offset']=qs[_0xedf7('0x20')](_0x887e66[_0xedf7('0x40')][_0xedf7('0x20')]);}switch(_0x34c290[_0xedf7('0x2b')]){case _0xedf7('0x2c'):return db[_[_0xedf7('0xa8')](_0x887e66['query'][_0xedf7('0xb4')])+_0xedf7('0xda')]['findAll'](_0x2192b0);case _0xedf7('0x2e'):case'agent':return _0x34c290[_0xedf7('0x2a')+_['capitalize'](_0x887e66[_0xedf7('0x40')][_0xedf7('0xb4')])+_0xedf7('0xa9')](_0x2192b0);}})['then'](function(_0x36cc2a){return{'count':_0x265181,'rows':_0x36cc2a};})[_0xedf7('0x11')](respondWithResult(_0xd38c36,null))['catch'](handleError(_0xd38c36,null));};exports[_0xedf7('0xdc')]=function(_0x5aeadd,_0x12dc92){var _0xbe6065={};var _0x42de84={};var _0x127258;var _0x3f2836;return db[_0xedf7('0x38')][_0xedf7('0x98')]({'where':{'id':_0x5aeadd[_0xedf7('0x55')]['id']}})[_0xedf7('0x11')](handleEntityNotFound(_0x12dc92,null))[_0xedf7('0x11')](function(_0x4ee75e){if(_0x4ee75e){_0x127258=_0x4ee75e;_0x42de84[_0xedf7('0x5a')]=_[_0xedf7('0x57')](db[_0xedf7('0xb1')][_0xedf7('0x39')]);_0x42de84['query']=_[_0xedf7('0x57')](_0x5aeadd[_0xedf7('0x40')]);_0x42de84['filters']=_[_0xedf7('0x59')](_0x42de84[_0xedf7('0x5a')],_0x42de84[_0xedf7('0x40')]);_0xbe6065[_0xedf7('0x45')]=_['intersection'](_0x42de84[_0xedf7('0x5a')],qs['fields'](_0x5aeadd['query'][_0xedf7('0x5b')]));_0xbe6065[_0xedf7('0x45')]=_0xbe6065[_0xedf7('0x45')][_0xedf7('0x4a')]?_0xbe6065[_0xedf7('0x45')]:_0x42de84[_0xedf7('0x5a')];_0xbe6065[_0xedf7('0xd0')]=qs[_0xedf7('0xd1')](_0x5aeadd[_0xedf7('0x40')]['sort']);_0xbe6065[_0xedf7('0x3f')]=qs[_0xedf7('0x58')](_[_0xedf7('0xdb')](_0x5aeadd[_0xedf7('0x40')],_0x42de84[_0xedf7('0x58')]));if(_0x5aeadd['query'][_0xedf7('0x30')]){_0xbe6065['where']=_[_0xedf7('0xd2')](_0xbe6065[_0xedf7('0x3f')],{'$or':_[_0xedf7('0x31')](_0xbe6065[_0xedf7('0x45')],function(_0x6fe99a){var _0x902ea8={};_0x902ea8[_0x6fe99a]={'$like':'%'+_0x5aeadd['query']['filter']+'%'};return _0x902ea8;})});}_0xbe6065=_[_0xedf7('0xd2')]({},_0xbe6065,_0x5aeadd[_0xedf7('0x5d')]);return _0x127258[_0xedf7('0xdc')](_0xbe6065);}})[_0xedf7('0x11')](function(_0x44acae){if(_0x44acae){_0x3f2836=_0x44acae[_0xedf7('0x4a')];if(!_0x5aeadd['query']['hasOwnProperty'](_0xedf7('0xd8'))){_0xbe6065['limit']=qs[_0xedf7('0x23')](_0x5aeadd[_0xedf7('0x40')][_0xedf7('0x23')]);_0xbe6065[_0xedf7('0x20')]=qs[_0xedf7('0x20')](_0x5aeadd['query'][_0xedf7('0x20')]);}return _0x127258['getVoiceQueuesRt'](_0xbe6065);}})[_0xedf7('0x11')](function(_0x2c461f){if(_0x2c461f){return _0x2c461f?{'count':_0x3f2836,'rows':_0x2c461f}:null;}})[_0xedf7('0x11')](respondWithResult(_0x12dc92,null))[_0xedf7('0x5e')](handleError(_0x12dc92,null));};exports[_0xedf7('0xdd')]=function(_0x53dfca,_0x10ce7e){var _0x3a7479={};var _0x1c3ec0={};var _0x113560;var _0x270472;return db['User'][_0xedf7('0x98')]({'where':{'id':_0x53dfca['params']['id']}})[_0xedf7('0x11')](handleEntityNotFound(_0x10ce7e,null))['then'](function(_0x5a19a9){if(_0x5a19a9){_0x113560=_0x5a19a9;_0x1c3ec0[_0xedf7('0x5a')]=_[_0xedf7('0x57')](db[_0xedf7('0xde')][_0xedf7('0x39')]);_0x1c3ec0[_0xedf7('0x40')]=_['keys'](_0x53dfca[_0xedf7('0x40')]);_0x1c3ec0['filters']=_[_0xedf7('0x59')](_0x1c3ec0[_0xedf7('0x5a')],_0x1c3ec0[_0xedf7('0x40')]);_0x3a7479['attributes']=_[_0xedf7('0x59')](_0x1c3ec0[_0xedf7('0x5a')],qs['fields'](_0x53dfca[_0xedf7('0x40')][_0xedf7('0x5b')]));_0x3a7479[_0xedf7('0x45')]=_0x3a7479[_0xedf7('0x45')][_0xedf7('0x4a')]?_0x3a7479[_0xedf7('0x45')]:_0x1c3ec0['model'];_0x3a7479[_0xedf7('0xd0')]=qs['sort'](_0x53dfca[_0xedf7('0x40')]['sort']);_0x3a7479['where']=qs[_0xedf7('0x58')](_[_0xedf7('0xdb')](_0x53dfca[_0xedf7('0x40')],_0x1c3ec0[_0xedf7('0x58')]));if(_0x53dfca[_0xedf7('0x40')]['filter']){_0x3a7479[_0xedf7('0x3f')]=_[_0xedf7('0xd2')](_0x3a7479['where'],{'$or':_[_0xedf7('0x31')](_0x3a7479[_0xedf7('0x45')],function(_0x2b4574){var _0x5587d0={};_0x5587d0[_0x2b4574]={'$like':'%'+_0x53dfca[_0xedf7('0x40')][_0xedf7('0x30')]+'%'};return _0x5587d0;})});}_0x3a7479=_['merge']({},_0x3a7479,_0x53dfca[_0xedf7('0x5d')]);return _0x113560[_0xedf7('0xdd')](_0x3a7479);}})[_0xedf7('0x11')](function(_0x146440){if(_0x146440){_0x270472=_0x146440[_0xedf7('0x4a')];if(!_0x53dfca[_0xedf7('0x40')][_0xedf7('0xd3')](_0xedf7('0xd8'))){_0x3a7479[_0xedf7('0x23')]=qs[_0xedf7('0x23')](_0x53dfca[_0xedf7('0x40')][_0xedf7('0x23')]);_0x3a7479['offset']=qs[_0xedf7('0x20')](_0x53dfca[_0xedf7('0x40')][_0xedf7('0x20')]);}return _0x113560[_0xedf7('0xdd')](_0x3a7479);}})['then'](function(_0x42b04d){if(_0x42b04d){return _0x42b04d?{'count':_0x270472,'rows':_0x42b04d}:null;}})[_0xedf7('0x11')](respondWithResult(_0x10ce7e,null))[_0xedf7('0x5e')](handleError(_0x10ce7e,null));};exports['getRecordings']=function(_0x4c9494,_0x1aa158){var _0x136841={'raw':!![],'where':{}};var _0x325ef1={};var _0xcb96b6={'count':0x0,'rows':[]};return db[_0xedf7('0x38')][_0xedf7('0x98')]({'where':{'id':_0x4c9494[_0xedf7('0x55')]['id']}})['then'](handleEntityNotFound(_0x1aa158,null))[_0xedf7('0x11')](function(_0x73000a){if(_0x73000a){_0x325ef1[_0xedf7('0x5a')]=_[_0xedf7('0x57')](db[_0xedf7('0xdf')][_0xedf7('0x39')]);_0x325ef1[_0xedf7('0x40')]=_['keys'](_0x4c9494['query']);_0x325ef1[_0xedf7('0x58')]=_['intersection'](_0x325ef1[_0xedf7('0x5a')],_0x325ef1[_0xedf7('0x40')]);_0x136841[_0xedf7('0x45')]=_['intersection'](_0x325ef1[_0xedf7('0x5a')],qs[_0xedf7('0x5b')](_0x4c9494[_0xedf7('0x40')][_0xedf7('0x5b')]));_0x136841['attributes']=_0x136841['attributes'][_0xedf7('0x4a')]?_0x136841[_0xedf7('0x45')]:_0x325ef1['model'];if(!_0x4c9494['query']['hasOwnProperty'](_0xedf7('0xd8'))){_0x136841[_0xedf7('0x23')]=qs[_0xedf7('0x23')](_0x4c9494[_0xedf7('0x40')][_0xedf7('0x23')]);_0x136841[_0xedf7('0x20')]=qs[_0xedf7('0x20')](_0x4c9494[_0xedf7('0x40')][_0xedf7('0x20')]);}_0x136841[_0xedf7('0xd0')]=qs['sort'](_0x4c9494[_0xedf7('0x40')][_0xedf7('0xd1')]);_0x136841[_0xedf7('0x3f')]=qs[_0xedf7('0x58')](_['pick'](_0x4c9494['query'],_0x325ef1[_0xedf7('0x58')]));_0x136841[_0xedf7('0x3f')]['UserId']=_0x73000a['id'];if(_0x4c9494[_0xedf7('0x40')][_0xedf7('0x30')]){_0x136841[_0xedf7('0x3f')]=_[_0xedf7('0xd2')](_0x136841['where'],{'$or':_['map'](_0x136841[_0xedf7('0x45')],function(_0x33a185){var _0x2496cb={};_0x2496cb[_0x33a185]={'$like':'%'+_0x4c9494[_0xedf7('0x40')]['filter']+'%'};return _0x2496cb;})});}_0x136841=_['merge']({},_0x136841,_0x4c9494[_0xedf7('0x5d')]);return db[_0xedf7('0xdf')][_0xedf7('0x22')]({'where':_0x136841[_0xedf7('0x3f')]})[_0xedf7('0x11')](function(_0x8b8e85){_0xcb96b6[_0xedf7('0x22')]=_0x8b8e85;if(_0x4c9494[_0xedf7('0x40')][_0xedf7('0x41')]){_0x136841[_0xedf7('0x42')]=[{'all':!![]}];}return db[_0xedf7('0xdf')][_0xedf7('0x46')](_0x136841);})[_0xedf7('0x11')](function(_0x3e3c23){_0xcb96b6['rows']=_0x3e3c23;return _0xcb96b6;});}})[_0xedf7('0x11')](respondWithFilteredResult(_0x1aa158,_0x136841))['catch'](handleError(_0x1aa158,null));};exports[_0xedf7('0xe0')]=function(_0x49f302,_0x3c99c9){var _0x3e5dcc={'raw':!![],'where':{}};var _0x3cc9cd={};var _0x4d97c4={'count':0x0,'rows':[]};return db[_0xedf7('0x38')][_0xedf7('0x98')]({'where':{'id':_0x49f302[_0xedf7('0x55')]['id']}})[_0xedf7('0x11')](handleEntityNotFound(_0x3c99c9,null))[_0xedf7('0x11')](function(_0x441380){if(_0x441380){_0x3cc9cd[_0xedf7('0x5a')]=_[_0xedf7('0x57')](db[_0xedf7('0xe1')][_0xedf7('0x39')]);_0x3cc9cd[_0xedf7('0x40')]=_[_0xedf7('0x57')](_0x49f302[_0xedf7('0x40')]);_0x3cc9cd[_0xedf7('0x58')]=_[_0xedf7('0x59')](_0x3cc9cd[_0xedf7('0x5a')],_0x3cc9cd[_0xedf7('0x40')]);_0x3e5dcc[_0xedf7('0x45')]=_[_0xedf7('0x59')](_0x3cc9cd[_0xedf7('0x5a')],qs['fields'](_0x49f302[_0xedf7('0x40')]['fields']));_0x3e5dcc[_0xedf7('0x45')]=_0x3e5dcc['attributes'][_0xedf7('0x4a')]?_0x3e5dcc[_0xedf7('0x45')]:_0x3cc9cd['model'];if(!_0x49f302[_0xedf7('0x40')][_0xedf7('0xd3')](_0xedf7('0xd8'))){_0x3e5dcc[_0xedf7('0x23')]=qs[_0xedf7('0x23')](_0x49f302[_0xedf7('0x40')][_0xedf7('0x23')]);_0x3e5dcc[_0xedf7('0x20')]=qs['offset'](_0x49f302['query'][_0xedf7('0x20')]);}_0x3e5dcc[_0xedf7('0xd0')]=qs[_0xedf7('0xd1')](_0x49f302[_0xedf7('0x40')][_0xedf7('0xd1')]);_0x3e5dcc[_0xedf7('0x3f')]=qs[_0xedf7('0x58')](_[_0xedf7('0xdb')](_0x49f302[_0xedf7('0x40')],_0x3cc9cd[_0xedf7('0x58')]));_0x3e5dcc[_0xedf7('0x3f')]['UserId']=_0x441380['id'];if(_0x49f302[_0xedf7('0x40')][_0xedf7('0x30')]){_0x3e5dcc[_0xedf7('0x3f')]=_[_0xedf7('0xd2')](_0x3e5dcc[_0xedf7('0x3f')],{'$or':_['map'](_0x3e5dcc[_0xedf7('0x45')],function(_0x4c8404){var _0x47c43c={};_0x47c43c[_0x4c8404]={'$like':'%'+_0x49f302[_0xedf7('0x40')][_0xedf7('0x30')]+'%'};return _0x47c43c;})});}_0x3e5dcc=_[_0xedf7('0xd2')]({},_0x3e5dcc,_0x49f302[_0xedf7('0x5d')]);return db['ScreenRecording'][_0xedf7('0x22')]({'where':_0x3e5dcc[_0xedf7('0x3f')]})[_0xedf7('0x11')](function(_0x27fa88){_0x4d97c4[_0xedf7('0x22')]=_0x27fa88;if(_0x49f302[_0xedf7('0x40')][_0xedf7('0x41')]){_0x3e5dcc['include']=[{'all':!![]}];}return db[_0xedf7('0xe1')][_0xedf7('0x46')](_0x3e5dcc);})[_0xedf7('0x11')](function(_0x15a5a2){_0x4d97c4[_0xedf7('0x47')]=_0x15a5a2;return _0x4d97c4;});}})[_0xedf7('0x11')](respondWithFilteredResult(_0x3c99c9,_0x3e5dcc))[_0xedf7('0x5e')](handleError(_0x3c99c9,null));};exports['getChatInteractions']=function(_0x5da8c7,_0x2fcb41){var _0x5441ec={};var _0x2f6706={};var _0xac0877;var _0x1d3a7a;return db[_0xedf7('0x38')]['findOne']({'where':{'id':_0x5da8c7[_0xedf7('0x55')]['id']}})['then'](handleEntityNotFound(_0x2fcb41,null))['then'](function(_0x2938d0){if(_0x2938d0){_0xac0877=_0x2938d0;_0x2f6706[_0xedf7('0x5a')]=_[_0xedf7('0x57')](db[_0xedf7('0xe2')]['rawAttributes']);_0x2f6706[_0xedf7('0x40')]=_['keys'](_0x5da8c7[_0xedf7('0x40')]);_0x2f6706[_0xedf7('0x58')]=_['intersection'](_0x2f6706[_0xedf7('0x5a')],_0x2f6706[_0xedf7('0x40')]);_0x5441ec[_0xedf7('0x45')]=_[_0xedf7('0x59')](_0x2f6706[_0xedf7('0x5a')],qs[_0xedf7('0x5b')](_0x5da8c7['query'][_0xedf7('0x5b')]));_0x5441ec[_0xedf7('0x45')]=_0x5441ec[_0xedf7('0x45')][_0xedf7('0x4a')]?_0x5441ec['attributes']:_0x2f6706[_0xedf7('0x5a')];_0x5441ec[_0xedf7('0xd0')]=qs[_0xedf7('0xd1')](_0x5da8c7[_0xedf7('0x40')][_0xedf7('0xd1')]);_0x5441ec['where']=qs[_0xedf7('0x58')](_['pick'](_0x5da8c7['query'],_0x2f6706['filters']));if(_0x5da8c7[_0xedf7('0x40')]['filter']){_0x5441ec['where']=_['merge'](_0x5441ec[_0xedf7('0x3f')],{'$or':_[_0xedf7('0x31')](_0x5441ec['attributes'],function(_0x1f3b7b){var _0x3c571a={};_0x3c571a[_0x1f3b7b]={'$like':'%'+_0x5da8c7[_0xedf7('0x40')]['filter']+'%'};return _0x3c571a;})});}_0x5441ec=_[_0xedf7('0xd2')]({},_0x5441ec,_0x5da8c7[_0xedf7('0x5d')]);return _0xac0877[_0xedf7('0xe3')](_0x5441ec);}})[_0xedf7('0x11')](function(_0x2e4201){if(_0x2e4201){_0x1d3a7a=_0x2e4201[_0xedf7('0x4a')];if(!_0x5da8c7['query'][_0xedf7('0xd3')](_0xedf7('0xd8'))){_0x5441ec[_0xedf7('0x23')]=qs[_0xedf7('0x23')](_0x5da8c7[_0xedf7('0x40')][_0xedf7('0x23')]);_0x5441ec[_0xedf7('0x20')]=qs[_0xedf7('0x20')](_0x5da8c7[_0xedf7('0x40')][_0xedf7('0x20')]);}return _0xac0877[_0xedf7('0xe3')](_0x5441ec);}})['then'](function(_0x1a8e81){if(_0x1a8e81){return _0x1a8e81?{'count':_0x1d3a7a,'rows':_0x1a8e81}:null;}})[_0xedf7('0x11')](respondWithResult(_0x2fcb41,null))[_0xedf7('0x5e')](handleError(_0x2fcb41,null));};exports[_0xedf7('0xe4')]=function(_0x551843,_0x2e5383){var _0x28c89e={};var _0x3af63a={};var _0x3af051;var _0x4e36b4;return db[_0xedf7('0x38')][_0xedf7('0x98')]({'where':{'id':_0x551843[_0xedf7('0x55')]['id']}})[_0xedf7('0x11')](handleEntityNotFound(_0x2e5383,null))['then'](function(_0x28f445){if(_0x28f445){_0x3af051=_0x28f445;_0x3af63a['model']=_['keys'](db[_0xedf7('0xe5')]['rawAttributes']);_0x3af63a[_0xedf7('0x40')]=_[_0xedf7('0x57')](_0x551843['query']);_0x3af63a[_0xedf7('0x58')]=_[_0xedf7('0x59')](_0x3af63a[_0xedf7('0x5a')],_0x3af63a['query']);_0x28c89e[_0xedf7('0x45')]=_['intersection'](_0x3af63a[_0xedf7('0x5a')],qs['fields'](_0x551843[_0xedf7('0x40')]['fields']));_0x28c89e['attributes']=_0x28c89e['attributes']['length']?_0x28c89e[_0xedf7('0x45')]:_0x3af63a[_0xedf7('0x5a')];_0x28c89e[_0xedf7('0xd0')]=qs['sort'](_0x551843[_0xedf7('0x40')][_0xedf7('0xd1')]);_0x28c89e[_0xedf7('0x3f')]=qs['filters'](_[_0xedf7('0xdb')](_0x551843['query'],_0x3af63a['filters']));if(_0x551843['query']['filter']){_0x28c89e[_0xedf7('0x3f')]=_[_0xedf7('0xd2')](_0x28c89e[_0xedf7('0x3f')],{'$or':_['map'](_0x28c89e[_0xedf7('0x45')],function(_0x5be15f){var _0x329efe={};_0x329efe[_0x5be15f]={'$like':'%'+_0x551843[_0xedf7('0x40')]['filter']+'%'};return _0x329efe;})});}_0x28c89e=_[_0xedf7('0xd2')]({},_0x28c89e,_0x551843['options']);return _0x3af051[_0xedf7('0xe4')](_0x28c89e);}})['then'](function(_0x1a200f){if(_0x1a200f){_0x4e36b4=_0x1a200f['length'];if(!_0x551843[_0xedf7('0x40')][_0xedf7('0xd3')]('nolimit')){_0x28c89e['limit']=qs[_0xedf7('0x23')](_0x551843[_0xedf7('0x40')][_0xedf7('0x23')]);_0x28c89e[_0xedf7('0x20')]=qs[_0xedf7('0x20')](_0x551843[_0xedf7('0x40')]['offset']);}return _0x3af051[_0xedf7('0xe4')](_0x28c89e);}})['then'](function(_0x527953){if(_0x527953){return _0x527953?{'count':_0x4e36b4,'rows':_0x527953}:null;}})['then'](respondWithResult(_0x2e5383,null))['catch'](handleError(_0x2e5383,null));};exports[_0xedf7('0xe6')]=function(_0x19e4b5,_0x565618){var _0x284137={'raw':!![],'where':{}};var _0x4c1ac7={};var _0x42eeb9={'count':0x0,'rows':[]};return db[_0xedf7('0x38')][_0xedf7('0x98')]({'where':{'id':_0x19e4b5[_0xedf7('0x55')]['id']}})[_0xedf7('0x11')](handleEntityNotFound(_0x565618,null))[_0xedf7('0x11')](function(_0x173db1){if(_0x173db1){_0x4c1ac7[_0xedf7('0x5a')]=_[_0xedf7('0x57')](db[_0xedf7('0xe7')][_0xedf7('0x39')]);_0x4c1ac7[_0xedf7('0x40')]=_[_0xedf7('0x57')](_0x19e4b5[_0xedf7('0x40')]);_0x4c1ac7[_0xedf7('0x58')]=_[_0xedf7('0x59')](_0x4c1ac7['model'],_0x4c1ac7[_0xedf7('0x40')]);_0x284137['attributes']=_['intersection'](_0x4c1ac7[_0xedf7('0x5a')],qs[_0xedf7('0x5b')](_0x19e4b5[_0xedf7('0x40')][_0xedf7('0x5b')]));_0x284137[_0xedf7('0x45')]=_0x284137[_0xedf7('0x45')]['length']?_0x284137['attributes']:_0x4c1ac7[_0xedf7('0x5a')];if(!_0x19e4b5[_0xedf7('0x40')][_0xedf7('0xd3')]('nolimit')){_0x284137['limit']=qs[_0xedf7('0x23')](_0x19e4b5['query']['limit']);_0x284137[_0xedf7('0x20')]=qs[_0xedf7('0x20')](_0x19e4b5['query'][_0xedf7('0x20')]);}_0x284137[_0xedf7('0xd0')]=qs[_0xedf7('0xd1')](_0x19e4b5[_0xedf7('0x40')]['sort']);_0x284137[_0xedf7('0x3f')]=qs[_0xedf7('0x58')](_[_0xedf7('0xdb')](_0x19e4b5[_0xedf7('0x40')],_0x4c1ac7[_0xedf7('0x58')]));_0x284137[_0xedf7('0x3f')][_0xedf7('0xe8')]=_0x173db1['id'];if(_0x19e4b5['query']['filter']){_0x284137[_0xedf7('0x3f')]=_['merge'](_0x284137[_0xedf7('0x3f')],{'$or':_[_0xedf7('0x31')](_0x284137[_0xedf7('0x45')],function(_0x37bf95){var _0x16e368={};_0x16e368[_0x37bf95]={'$like':'%'+_0x19e4b5[_0xedf7('0x40')][_0xedf7('0x30')]+'%'};return _0x16e368;})});}_0x284137=_[_0xedf7('0xd2')]({},_0x284137,_0x19e4b5[_0xedf7('0x5d')]);return db[_0xedf7('0xe7')]['count']({'where':_0x284137[_0xedf7('0x3f')]})[_0xedf7('0x11')](function(_0x3fb8b9){_0x42eeb9[_0xedf7('0x22')]=_0x3fb8b9;if(_0x19e4b5[_0xedf7('0x40')]['includeAll']){_0x284137[_0xedf7('0x42')]=[{'all':!![]}];}return db[_0xedf7('0xe7')]['findAll'](_0x284137);})[_0xedf7('0x11')](function(_0x14c985){_0x42eeb9[_0xedf7('0x47')]=_0x14c985;return _0x42eeb9;});}})[_0xedf7('0x11')](respondWithFilteredResult(_0x565618,_0x284137))[_0xedf7('0x5e')](handleError(_0x565618,null));};exports[_0xedf7('0xe9')]=function(_0xc9b205,_0x59fe00){var _0x4cbeb2={};var _0x2963a3={};var _0x4f8d63;var _0x1b61e8;return db[_0xedf7('0x38')]['findOne']({'where':{'id':_0xc9b205[_0xedf7('0x55')]['id']}})['then'](handleEntityNotFound(_0x59fe00,null))[_0xedf7('0x11')](function(_0x42561f){if(_0x42561f){_0x4f8d63=_0x42561f;_0x2963a3[_0xedf7('0x5a')]=_[_0xedf7('0x57')](db[_0xedf7('0xea')][_0xedf7('0x39')]);_0x2963a3[_0xedf7('0x40')]=_['keys'](_0xc9b205[_0xedf7('0x40')]);_0x2963a3[_0xedf7('0x58')]=_[_0xedf7('0x59')](_0x2963a3[_0xedf7('0x5a')],_0x2963a3[_0xedf7('0x40')]);_0x4cbeb2['attributes']=_[_0xedf7('0x59')](_0x2963a3[_0xedf7('0x5a')],qs[_0xedf7('0x5b')](_0xc9b205[_0xedf7('0x40')]['fields']));_0x4cbeb2['attributes']=_0x4cbeb2[_0xedf7('0x45')][_0xedf7('0x4a')]?_0x4cbeb2[_0xedf7('0x45')]:_0x2963a3['model'];_0x4cbeb2[_0xedf7('0xd0')]=qs['sort'](_0xc9b205[_0xedf7('0x40')]['sort']);_0x4cbeb2['where']=qs[_0xedf7('0x58')](_[_0xedf7('0xdb')](_0xc9b205[_0xedf7('0x40')],_0x2963a3[_0xedf7('0x58')]));if(_0xc9b205[_0xedf7('0x40')][_0xedf7('0x30')]){_0x4cbeb2[_0xedf7('0x3f')]=_[_0xedf7('0xd2')](_0x4cbeb2[_0xedf7('0x3f')],{'$or':_[_0xedf7('0x31')](_0x4cbeb2['attributes'],function(_0x90953b){var _0x1dd865={};_0x1dd865[_0x90953b]={'$like':'%'+_0xc9b205[_0xedf7('0x40')][_0xedf7('0x30')]+'%'};return _0x1dd865;})});}_0x4cbeb2=_[_0xedf7('0xd2')]({},_0x4cbeb2,_0xc9b205[_0xedf7('0x5d')]);return _0x4f8d63[_0xedf7('0xe9')](_0x4cbeb2);}})[_0xedf7('0x11')](function(_0x175bf6){if(_0x175bf6){_0x1b61e8=_0x175bf6[_0xedf7('0x4a')];if(!_0xc9b205[_0xedf7('0x40')]['hasOwnProperty'](_0xedf7('0xd8'))){_0x4cbeb2[_0xedf7('0x23')]=qs[_0xedf7('0x23')](_0xc9b205[_0xedf7('0x40')][_0xedf7('0x23')]);_0x4cbeb2[_0xedf7('0x20')]=qs[_0xedf7('0x20')](_0xc9b205['query'][_0xedf7('0x20')]);}return _0x4f8d63['getSmsInteractions'](_0x4cbeb2);}})[_0xedf7('0x11')](function(_0x2cdcf1){if(_0x2cdcf1){return _0x2cdcf1?{'count':_0x1b61e8,'rows':_0x2cdcf1}:null;}})[_0xedf7('0x11')](respondWithResult(_0x59fe00,null))['catch'](handleError(_0x59fe00,null));};exports[_0xedf7('0xeb')]=function(_0x37ff97,_0x58c224){var _0x17c9c4={};var _0x40f025={};var _0x24e4d4;var _0xdfa7c8;return db['User'][_0xedf7('0x98')]({'where':{'id':_0x37ff97['params']['id']}})[_0xedf7('0x11')](handleEntityNotFound(_0x58c224,null))[_0xedf7('0x11')](function(_0x3d1ea4){if(_0x3d1ea4){_0x24e4d4=_0x3d1ea4;_0x40f025['model']=_['keys'](db[_0xedf7('0xec')][_0xedf7('0x39')]);_0x40f025[_0xedf7('0x40')]=_[_0xedf7('0x57')](_0x37ff97[_0xedf7('0x40')]);_0x40f025[_0xedf7('0x58')]=_[_0xedf7('0x59')](_0x40f025[_0xedf7('0x5a')],_0x40f025[_0xedf7('0x40')]);_0x17c9c4['attributes']=_[_0xedf7('0x59')](_0x40f025[_0xedf7('0x5a')],qs['fields'](_0x37ff97[_0xedf7('0x40')][_0xedf7('0x5b')]));_0x17c9c4[_0xedf7('0x45')]=_0x17c9c4[_0xedf7('0x45')]['length']?_0x17c9c4[_0xedf7('0x45')]:_0x40f025[_0xedf7('0x5a')];_0x17c9c4[_0xedf7('0xd0')]=qs[_0xedf7('0xd1')](_0x37ff97[_0xedf7('0x40')]['sort']);_0x17c9c4['where']=qs[_0xedf7('0x58')](_['pick'](_0x37ff97['query'],_0x40f025[_0xedf7('0x58')]));if(_0x37ff97[_0xedf7('0x40')][_0xedf7('0x30')]){_0x17c9c4[_0xedf7('0x3f')]=_[_0xedf7('0xd2')](_0x17c9c4['where'],{'$or':_[_0xedf7('0x31')](_0x17c9c4[_0xedf7('0x45')],function(_0x6d083){var _0x359522={};_0x359522[_0x6d083]={'$like':'%'+_0x37ff97['query'][_0xedf7('0x30')]+'%'};return _0x359522;})});}_0x17c9c4=_[_0xedf7('0xd2')]({},_0x17c9c4,_0x37ff97[_0xedf7('0x5d')]);return _0x24e4d4['getFaxInteractions'](_0x17c9c4);}})[_0xedf7('0x11')](function(_0x2fdc1e){if(_0x2fdc1e){_0xdfa7c8=_0x2fdc1e[_0xedf7('0x4a')];if(!_0x37ff97[_0xedf7('0x40')]['hasOwnProperty'](_0xedf7('0xd8'))){_0x17c9c4[_0xedf7('0x23')]=qs[_0xedf7('0x23')](_0x37ff97[_0xedf7('0x40')][_0xedf7('0x23')]);_0x17c9c4[_0xedf7('0x20')]=qs[_0xedf7('0x20')](_0x37ff97[_0xedf7('0x40')][_0xedf7('0x20')]);}return _0x24e4d4[_0xedf7('0xeb')](_0x17c9c4);}})['then'](function(_0x9fef46){if(_0x9fef46){return _0x9fef46?{'count':_0xdfa7c8,'rows':_0x9fef46}:null;}})['then'](respondWithResult(_0x58c224,null))[_0xedf7('0x5e')](handleError(_0x58c224,null));};exports[_0xedf7('0xed')]=function(_0xb90c9a,_0xa0470c){var _0x4fa284={};var _0x2afd08={};var _0x2bbc6c;var _0x3d1cc2;return db['User'][_0xedf7('0x98')]({'where':{'id':_0xb90c9a[_0xedf7('0x55')]['id']}})[_0xedf7('0x11')](handleEntityNotFound(_0xa0470c,null))[_0xedf7('0x11')](function(_0x4b4320){if(_0x4b4320){_0x2bbc6c=_0x4b4320;_0x2afd08[_0xedf7('0x5a')]=_['keys'](db[_0xedf7('0xee')]['rawAttributes']);_0x2afd08[_0xedf7('0x40')]=_[_0xedf7('0x57')](_0xb90c9a[_0xedf7('0x40')]);_0x2afd08[_0xedf7('0x58')]=_['intersection'](_0x2afd08['model'],_0x2afd08[_0xedf7('0x40')]);_0x4fa284['attributes']=_['intersection'](_0x2afd08[_0xedf7('0x5a')],qs[_0xedf7('0x5b')](_0xb90c9a['query'][_0xedf7('0x5b')]));_0x4fa284['attributes']=_0x4fa284[_0xedf7('0x45')][_0xedf7('0x4a')]?_0x4fa284[_0xedf7('0x45')]:_0x2afd08[_0xedf7('0x5a')];_0x4fa284['order']=qs['sort'](_0xb90c9a[_0xedf7('0x40')][_0xedf7('0xd1')]);_0x4fa284[_0xedf7('0x3f')]=qs[_0xedf7('0x58')](_[_0xedf7('0xdb')](_0xb90c9a[_0xedf7('0x40')],_0x2afd08['filters']));if(_0xb90c9a[_0xedf7('0x40')]['filter']){_0x4fa284[_0xedf7('0x3f')]=_[_0xedf7('0xd2')](_0x4fa284['where'],{'$or':_['map'](_0x4fa284['attributes'],function(_0x4cb63f){var _0xc96752={};_0xc96752[_0x4cb63f]={'$like':'%'+_0xb90c9a[_0xedf7('0x40')]['filter']+'%'};return _0xc96752;})});}_0x4fa284=_[_0xedf7('0xd2')]({},_0x4fa284,_0xb90c9a['options']);return _0x2bbc6c[_0xedf7('0xed')](_0x4fa284);}})['then'](function(_0x13f52d){if(_0x13f52d){_0x3d1cc2=_0x13f52d[_0xedf7('0x4a')];if(!_0xb90c9a['query'][_0xedf7('0xd3')]('nolimit')){_0x4fa284[_0xedf7('0x23')]=qs[_0xedf7('0x23')](_0xb90c9a['query'][_0xedf7('0x23')]);_0x4fa284['offset']=qs[_0xedf7('0x20')](_0xb90c9a[_0xedf7('0x40')][_0xedf7('0x20')]);}return _0x2bbc6c['getWhatsappInteractions'](_0x4fa284);}})[_0xedf7('0x11')](function(_0x55de46){if(_0x55de46){return _0x55de46?{'count':_0x3d1cc2,'rows':_0x55de46}:null;}})['then'](respondWithResult(_0xa0470c,null))[_0xedf7('0x5e')](handleError(_0xa0470c,null));};exports[_0xedf7('0xef')]=function(_0x597471,_0x836011,_0x4b158e){var _0x3ef377;var _0xf59e48;var _0x191a2e;var _0x4f685=!_[_0xedf7('0x67')](_0x597471[_0xedf7('0x55')]['id'])?_0x597471[_0xedf7('0x55')]['id']:!_[_0xedf7('0x67')](_0x597471[_0xedf7('0x2e')]['id'])?_0x597471[_0xedf7('0x2e')]['id']:null;return db[_0xedf7('0x38')][_0xedf7('0x62')]({'where':{'id':_0x4f685,'role':{'$or':[_0xedf7('0x2c'),_0xedf7('0x2e'),_0xedf7('0x26')]}},'attributes':['id',_0xedf7('0x35'),'phone',_0xedf7('0xf0'),_0xedf7('0x2b'),_0xedf7('0x65'),_0xedf7('0xa2')]})[_0xedf7('0x11')](function(_0x1046e6){if(_0x1046e6){if(_0x1046e6['role']===_0xedf7('0x26')){_0x3ef377=_0x1046e6;if(_0x597471[_0xedf7('0x5f')][_0xedf7('0xa4')]){_0x191a2e=util[_0xedf7('0xb0')](_0xedf7('0xf1'),_0x3ef377[_0x597471[_0xedf7('0x5f')][_0xedf7('0xa4')]]);}else if(_0x597471[_0xedf7('0x5f')]['intrf']){_0x191a2e=util['format'](_0xedf7('0xf2'),_0x597471[_0xedf7('0x5f')][_0xedf7('0xf3')]);}else{_0x191a2e=util[_0xedf7('0xb0')](_0xedf7('0xf2'),_0x3ef377[_0xedf7('0x35')]);}socket['to'](util[_0xedf7('0xb0')](_0xedf7('0xf4'),_0x3ef377['name']))[_0xedf7('0x27')](_0xedf7('0xf5'),{'user':{'id':_0x3ef377['id'],'name':_0x3ef377[_0xedf7('0x35')]},'ip':_0x597471['headers'][_0xedf7('0xf6')]||_0x597471[_0xedf7('0xf7')][_0xedf7('0xf8')]||_0x597471[_0xedf7('0xf9')][_0xedf7('0xf8')]||_0x597471[_0xedf7('0xf7')][_0xedf7('0xf9')]['remoteAddress']});return db[_0xedf7('0xb1')][_0xedf7('0x29')]({'where':{'membername':_0x3ef377[_0xedf7('0x35')]},'individualHooks':!![]});}}else{throw new db[(_0xedf7('0x95'))][(_0xedf7('0x94'))](_0xedf7('0xfa'));}})['then'](function(){if(_0x3ef377){return _0x3ef377[_0xedf7('0xfb')]({'raw':!![]});}})[_0xedf7('0x11')](function(_0x3f7cc){if(_0x3ef377){if(_0x3f7cc){_0xf59e48=_0x3f7cc;if(_0xf59e48[_0xedf7('0x4a')]){var _0x2b4d02=_0xf59e48[_0xedf7('0x31')](function(_0x5ac240){var _0x4fc271={'membername':_0x3ef377[_0xedf7('0x35')],'UserId':_0x3ef377['id'],'queue_name':_0x5ac240[_0xedf7('0x35')],'VoiceQueueId':_0x5ac240['id'],'interface':_0x191a2e,'paused':_0x3ef377['loginInPause']||![],'penalty':_0x5ac240[_0xedf7('0xfc')]||0x0};return db[_0xedf7('0xb1')][_0xedf7('0xb2')](_0x4fc271);});return Promise[_0xedf7('0x53')](_0x2b4d02);}}}})[_0xedf7('0x11')](function(){if(_0x3ef377){return db[_0xedf7('0xfd')]['findAll']({'where':{'membername':_0x3ef377['name'],'exitAt':null}});}})[_0xedf7('0x11')](function(_0x28c217){if(_0x3ef377){var _0x59b784=[];_0x28c217[_0xedf7('0xfe')](function(_0x4d198c){_0x59b784[_0xedf7('0x4b')](_0x4d198c[_0xedf7('0x25')]({'exitAt':moment()[_0xedf7('0xb0')]('YYYY-MM-DD\x20HH:mm:ss')}));});return Promise['all'](_0x59b784);}})[_0xedf7('0x11')](function(){if(_0x3ef377){var _0x8e0f87=[];var _0x13f55f=[];var _0x5900d3=utils['getChannels']();var _0x161971={'membername':_0x3ef377['name'],'interface':_0x191a2e,'enterAt':moment()[_0xedf7('0xb0')](_0xedf7('0xff')),'role':_0x3ef377['role'],'internal':_0x3ef377[_0xedf7('0x65')]};_0x5900d3[_0xedf7('0xfe')](function(_0xbe60ec){_0x8e0f87[_0xedf7('0x4b')](_[_0xedf7('0xd2')]({'channel':_0xbe60ec,'type':_0xedf7('0x100'),'data1':_0x597471[_0xedf7('0x5f')]['device'],'data2':_0x191a2e},_0x161971));if(_0x3ef377[_0xedf7('0xa2')]){_0x13f55f['push'](_[_0xedf7('0xd2')]({'channel':_0xbe60ec,'type':'PAUSE','data1':_0xedf7('0x101')},_0x161971));}});return db[_0xedf7('0xfd')]['bulkCreate'](_0x8e0f87[_0xedf7('0xcd')](_0x13f55f),{'individualHooks':!![]});}})['then'](function(){if(_0x3ef377){return _0x3ef377[_0xedf7('0x25')]({'online':!![],'lastLoginAt':moment()[_0xedf7('0xb0')]('YYYY-MM-DD\x20HH:mm:ss'),'voicePause':_0x3ef377['loginInPause']||![],'mailPause':_0x3ef377['loginInPause']||![],'chatPause':_0x3ef377['loginInPause']||![],'faxPause':_0x3ef377['loginInPause']||![],'smsPause':_0x3ef377[_0xedf7('0xa2')]||![],'openchannelPause':_0x3ef377[_0xedf7('0xa2')]||![],'whatsappPause':_0x3ef377[_0xedf7('0xa2')]||![],'pauseType':_0x3ef377['loginInPause']?_0xedf7('0x101'):null,'interface':_0x191a2e,'lastPauseAt':moment()[_0xedf7('0xb0')](_0xedf7('0xff'))});}})[_0xedf7('0x11')](function(_0x5556a7){if(_0x597471[_0xedf7('0x102')]){return _0x4b158e();}else{return Promise['resolve'](_0x5556a7)['then'](respondWithResult(_0x836011,null));}})['catch'](handleError(_0x836011,null));};exports['logout']=function(_0xf5cc64,_0x2c7114){var _0x8c696b;return db['User'][_0xedf7('0x62')]({'where':{'id':_0xf5cc64['params']['id'],'role':_0xedf7('0x26')},'attributes':['id',_0xedf7('0x35'),_0xedf7('0x2b')]})['then'](handleEntityNotFound(_0x2c7114,null))['then'](function(_0x3f026f){if(_0x3f026f){_0x8c696b=_0x3f026f;return db[_0xedf7('0xb1')][_0xedf7('0x29')]({'where':{'membername':_0x8c696b[_0xedf7('0x35')]},'individualHooks':!![]});}})[_0xedf7('0x11')](function(){return db[_0xedf7('0xfd')][_0xedf7('0x46')]({'where':{'membername':_0x8c696b['name'],'exitAt':null}});})['then'](function(_0xc0885c){var _0x336373=[];_0xc0885c[_0xedf7('0xfe')](function(_0x59bb83){_0x336373[_0xedf7('0x4b')](_0x59bb83[_0xedf7('0x25')]({'exitAt':moment()[_0xedf7('0xb0')](_0xedf7('0xff'))}));});return Promise['all'](_0x336373);})[_0xedf7('0x11')](function(){return _0x8c696b[_0xedf7('0x25')]({'online':![],'voicePause':![],'mailPause':![],'chatPause':![],'faxPause':![],'smsPause':![],'openchannelPause':![],'whatsappPause':![],'interface':null});})['then'](respondWithResult(_0x2c7114,null))[_0xedf7('0x5e')](handleError(_0x2c7114,null));};exports[_0xedf7('0x103')]=function(_0x1e9014,_0x41ace2){var _0x7e0e66;return db[_0xedf7('0xb1')][_0xedf7('0x25')]({'paused':0x1},{'where':{'UserId':_0x1e9014[_0xedf7('0x55')]['id']},'individualHooks':!![]})[_0xedf7('0x11')](function(){return db['User']['find']({'where':{'id':_0x1e9014[_0xedf7('0x55')]['id'],'role':_0xedf7('0x26')},'attributes':['id',_0xedf7('0x35'),_0xedf7('0x2b'),_0xedf7('0x65'),_0xedf7('0xa4'),'online']});})[_0xedf7('0x11')](handleEntityNotFound(_0x41ace2,null))[_0xedf7('0x11')](function(_0x8f957e){if(_0x8f957e){_0x7e0e66=_0x8f957e;return respondWithRpcPromise(_0xedf7('0x104'),_0xedf7('0x103'),{'id':_0x7e0e66['id'],'name':_0x7e0e66['name'],'pause':!![]});}})[_0xedf7('0x11')](function(){if(_0x7e0e66){return db[_0xedf7('0xfd')][_0xedf7('0x46')]({'where':{'membername':_0x7e0e66['name'],'type':'PAUSE','exitAt':null}});}})[_0xedf7('0x11')](function(_0x56b340){if(_0x56b340[_0xedf7('0x4a')]){var _0x24bd81=moment()[_0xedf7('0xb0')](_0xedf7('0xff'));for(var _0x41b3c8=0x0,_0x1b0e4b=_0x56b340['length'];_0x41b3c8<_0x1b0e4b;_0x41b3c8++){_0x56b340[_0x41b3c8]['updateAttributes']({'exitAt':_0x24bd81});}}})[_0xedf7('0x11')](function(){var _0x70f0b0=[];var _0x2818bd=utils[_0xedf7('0x105')]();_0x2818bd[_0xedf7('0xfe')](function(_0x549d37){_0x70f0b0[_0xedf7('0x4b')]({'channel':_0x549d37,'membername':_0x7e0e66[_0xedf7('0x35')],'interface':_[_0xedf7('0x67')](_0x7e0e66[_0xedf7('0xa4')])?util[_0xedf7('0xb0')]('SIP/%s',_0x7e0e66[_0xedf7('0x35')]):_0x7e0e66[_0xedf7('0xa4')],'type':'PAUSE','enterAt':moment()[_0xedf7('0xb0')](_0xedf7('0xff')),'data1':_0x1e9014[_0xedf7('0x5f')][_0xedf7('0x3b')]||_0xedf7('0x106'),'role':_0x7e0e66[_0xedf7('0x2b')],'internal':_0x7e0e66['internal']});});return db[_0xedf7('0xfd')][_0xedf7('0x88')](_0x70f0b0,{'individualHooks':!![]});})['then'](function(){return _0x7e0e66[_0xedf7('0x25')]({'voicePause':!![],'mailPause':!![],'chatPause':!![],'faxPause':!![],'smsPause':!![],'whatsappPause':!![],'openchannelPause':!![],'pauseType':_0x1e9014[_0xedf7('0x5f')][_0xedf7('0x3b')]||'DEFAULT\x20PAUSE','lastPauseAt':moment()[_0xedf7('0xb0')](_0xedf7('0xff'))});})[_0xedf7('0x11')](respondWithResult(_0x41ace2,null))[_0xedf7('0x5e')](handleError(_0x41ace2,null));};exports[_0xedf7('0x107')]=function(_0xfdb833,_0x47c64f){if(_0xfdb833['body'][_0xedf7('0xb4')]&&!utils['isValidChannel'](_0xfdb833['body'][_0xedf7('0xb4')])){throw new APIBadRequestError(util[_0xedf7('0xb0')](_0xedf7('0x108'),_0xfdb833[_0xedf7('0x5f')][_0xedf7('0xb4')]));}return db[_0xedf7('0x38')][_0xedf7('0x62')]({'where':{'id':_0xfdb833[_0xedf7('0x55')]['id']},'attributes':['id',_0xedf7('0x35'),_0xedf7('0x2b'),_0xedf7('0x65'),_0xedf7('0xa4'),_0xedf7('0xa1'),_0xedf7('0xa3'),_0xedf7('0x109'),_0xedf7('0x10a'),_0xedf7('0x10b'),_0xedf7('0x10c'),'smsPause',_0xedf7('0x10d'),'pauseType','lastPauseAt']})[_0xedf7('0x11')](function(_0x1e6e45){if(!_0x1e6e45){throw new APINotFoundError(util['format']('User\x20with\x20id\x20%s\x20not\x20found',_0xfdb833['params']['id']));}return _0x1e6e45['unpause'](_0xfdb833[_0xedf7('0x5f')]['channel']);})[_0xedf7('0x11')](respondWithResult(_0x47c64f,null))[_0xedf7('0x5e')](APIHandleError(_0x47c64f));};exports[_0xedf7('0x10e')]=function(_0x3b294f,_0x24dc34){var _0x1fce01={};var _0x2d2dd7={};var _0xe62204;var _0x4d6b41;return db[_0xedf7('0x38')]['findOne']({'where':{'id':_0x3b294f['params']['id']}})['then'](handleEntityNotFound(_0x24dc34,null))[_0xedf7('0x11')](function(_0x4725b9){if(_0x4725b9){_0xe62204=_0x4725b9;_0x2d2dd7[_0xedf7('0x5a')]=_['keys'](db['Team'][_0xedf7('0x39')]);_0x2d2dd7[_0xedf7('0x40')]=_['keys'](_0x3b294f['query']);_0x2d2dd7[_0xedf7('0x58')]=_['intersection'](_0x2d2dd7[_0xedf7('0x5a')],_0x2d2dd7[_0xedf7('0x40')]);_0x1fce01[_0xedf7('0x45')]=_['intersection'](_0x2d2dd7['model'],qs[_0xedf7('0x5b')](_0x3b294f[_0xedf7('0x40')][_0xedf7('0x5b')]));_0x1fce01[_0xedf7('0x45')]=_0x1fce01[_0xedf7('0x45')]['length']?_0x1fce01[_0xedf7('0x45')]:_0x2d2dd7[_0xedf7('0x5a')];_0x1fce01['order']=qs[_0xedf7('0xd1')](_0x3b294f[_0xedf7('0x40')][_0xedf7('0xd1')]);_0x1fce01[_0xedf7('0x3f')]=qs[_0xedf7('0x58')](_['pick'](_0x3b294f['query'],_0x2d2dd7[_0xedf7('0x58')]));if(_0x3b294f[_0xedf7('0x40')]['filter']){_0x1fce01[_0xedf7('0x3f')]=_[_0xedf7('0xd2')](_0x1fce01['where'],{'$or':_['map'](_0x1fce01[_0xedf7('0x45')],function(_0x4bd23e){var _0x1954d2={};_0x1954d2[_0x4bd23e]={'$like':'%'+_0x3b294f['query']['filter']+'%'};return _0x1954d2;})});}_0x1fce01=_['merge']({},_0x1fce01,_0x3b294f[_0xedf7('0x5d')]);return _0xe62204['getTeams'](_0x1fce01);}})[_0xedf7('0x11')](function(_0x5eb34b){if(_0x5eb34b){_0x4d6b41=_0x5eb34b[_0xedf7('0x4a')];if(!_0x3b294f[_0xedf7('0x40')][_0xedf7('0xd3')](_0xedf7('0xd8'))){_0x1fce01['limit']=qs[_0xedf7('0x23')](_0x3b294f[_0xedf7('0x40')][_0xedf7('0x23')]);_0x1fce01[_0xedf7('0x20')]=qs[_0xedf7('0x20')](_0x3b294f[_0xedf7('0x40')][_0xedf7('0x20')]);}return _0xe62204[_0xedf7('0x10e')](_0x1fce01);}})[_0xedf7('0x11')](function(_0x3bbbff){if(_0x3bbbff){return _0x3bbbff?{'count':_0x4d6b41,'rows':_0x3bbbff}:null;}})[_0xedf7('0x11')](respondWithResult(_0x24dc34,null))[_0xedf7('0x5e')](handleError(_0x24dc34,null));};exports['addTeams']=function(_0x35fba9,_0x3864d0){var _0x4f5cf5=_0x35fba9[_0xedf7('0x55')]['id'];var _0x5142a6=_0x35fba9[_0xedf7('0x5f')]?_0x35fba9['body'][_0xedf7('0x63')]:null;var _0x460600=[];return Promise[_0xedf7('0x10f')]()['then'](function(){if(!_0x5142a6)throw new APIBadRequestError(_0xedf7('0x110'));})[_0xedf7('0x11')](function(){return db[_0xedf7('0x38')][_0xedf7('0x98')]({'where':{'id':_0x4f5cf5}});})[_0xedf7('0x11')](function(_0x5f2f44){if(!_0x5f2f44)throw new APINotFoundError(util[_0xedf7('0xb0')](_0xedf7('0x111'),_0x35fba9[_0xedf7('0x55')]['id']));return db[_0xedf7('0x69')][_0xedf7('0x112')](function(_0x33b13f){return _0x5f2f44[_0xedf7('0x113')](_0x5142a6,{'transaction':_0x33b13f})[_0xedf7('0x11')](function(){return db[_0xedf7('0x114')][_0xedf7('0x46')]({'where':{'id':{'$in':_0x5142a6}}});})['then'](function(_0xe582eb){var _0x4ca609=_[_0xedf7('0x31')](_0xe582eb,function(_0xc5166e){return _0xc5166e[_0xedf7('0x115')]();});return Promise['all'](_0x4ca609);})[_0xedf7('0x11')](function(_0x5fede2){_0x460600=_[_0xedf7('0x116')](_0x5fede2);var _0xa7dc75=_[_0xedf7('0x31')](_0x460600,function(_0x4acd6b){return _0x4acd6b[_0xedf7('0x117')](_0x5f2f44['id'],{'transaction':_0x33b13f});});return Promise[_0xedf7('0x53')](_0xa7dc75);})['then'](function(){if(!_0x5f2f44[_0xedf7('0xa1')])return;var _0x1d31c6=_[_0xedf7('0x30')](_0x460600,function(_0x543e59){return _0x543e59['getDataValue'](_0xedf7('0xb4'))===_0xedf7('0x118');});var _0x40a257=_[_0xedf7('0x31')](_0x1d31c6,function(_0x456db5){return db[_0xedf7('0xb1')][_0xedf7('0xb2')]({'membername':_0x5f2f44['name'],'UserId':_0x5f2f44['id'],'queue_name':_0x456db5[_0xedf7('0x35')],'VoiceQueueId':_0x456db5['id'],'interface':_['isNil'](_0x5f2f44['interface'])?util[_0xedf7('0xb0')]('SIP/%s',_0x5f2f44[_0xedf7('0x35')]):_0x5f2f44[_0xedf7('0xa4')],'paused':_0x5f2f44[_0xedf7('0xa3')]||![],'penalty':_0x5f2f44[_0xedf7('0xaa')]},{'transaction':_0x33b13f});});return Promise[_0xedf7('0x53')](_0x40a257);})[_0xedf7('0x11')](function(){return db[_0xedf7('0x119')][_0xedf7('0x46')]({'where':{'teamId':{'$in':_0x5142a6}}});})['then'](function(_0x14a1b1){var _0x250b00=_[_0xedf7('0x31')](_0x14a1b1,function(_0x5b42b6){return db[_0xedf7('0x11a')][_0xedf7('0x80')]({'UserId':_0x5f2f44['id'],'VoicePrefixId':_0x5b42b6[_0xedf7('0x11b')]},{'transaction':_0x33b13f});});return Promise['all'](_0x250b00);});});})[_0xedf7('0x11')](function(){for(var _0x3aa4ab=0x0;_0x3aa4ab<_0x460600[_0xedf7('0x4a')];_0x3aa4ab++){var _0x36b739=_0x460600[_0x3aa4ab][_0xedf7('0x11c')](_0xedf7('0xb4'));var _0x810e91=_0x36b739+_0xedf7('0xad');socket[_0xedf7('0x27')](_0xedf7('0x2e')+_0x36b739+_0xedf7('0xae'),{'UserId':_0x4f5cf5,['queueField']:_0x460600[_0x3aa4ab]['id']});}})[_0xedf7('0x11')](respondWithStatusCode(_0x3864d0,null))['catch'](APIHandleError(_0x3864d0));};exports['removeTeams']=function(_0x440730,_0x5ce5e3){var _0x3b2573=_0x440730['params']['id'];var _0x4605f7=null;if(_0x440730[_0xedf7('0x40')]['ids']){_0x4605f7=_['isArray'](_0x440730[_0xedf7('0x40')][_0xedf7('0x63')])?_0x440730['query'][_0xedf7('0x63')]:[_0x440730['query'][_0xedf7('0x63')]];}var _0x4378ee=[];return Promise['resolve']()['then'](function(){if(!_0x4605f7)throw new APIBadRequestError('Query\x20parameter\x20\x27ids\x27\x20is\x20required');})['then'](function(){return db['User'][_0xedf7('0x98')]({'where':{'id':_0x3b2573}});})['then'](function(_0x4cc91c){if(!_0x4cc91c)throw new APINotFoundError(util[_0xedf7('0xb0')](_0xedf7('0x111'),_0x440730['params']['id']));return db[_0xedf7('0x69')]['transaction'](function(_0x38cf48){return _0x4cc91c['removeTeams'](_0x4605f7,{'transaction':_0x38cf48})[_0xedf7('0x11')](function(){return db[_0xedf7('0x114')]['findAll']({'where':{'id':{'$in':_0x4605f7}}});})[_0xedf7('0x11')](function(_0x236f97){var _0x2af240=_[_0xedf7('0x31')](_0x236f97,function(_0x119d7a){return _0x119d7a['getAssociatedQueues']();});return Promise[_0xedf7('0x53')](_0x2af240);})[_0xedf7('0x11')](function(_0x33a47c){_0x4378ee=_[_0xedf7('0x116')](_0x33a47c);var _0x46409b=_[_0xedf7('0x31')](_0x4378ee,function(_0x312c6d){return _0x312c6d[_0xedf7('0x11d')](_0x4cc91c['id'],{'transaction':_0x38cf48});});return Promise['all'](_0x46409b);})[_0xedf7('0x11')](function(){if(!_0x4cc91c['online'])return;var _0x22ab7d=_['filter'](_0x4378ee,function(_0x2b7884){return _0x2b7884[_0xedf7('0x11c')](_0xedf7('0xb4'))==='Voice';});var _0xe72715=_[_0xedf7('0x31')](_0x22ab7d,function(_0x1db387){return db['UserVoiceQueueRt'][_0xedf7('0x29')]({'where':{'VoiceQueueId':_0x1db387['id'],'UserId':_0x4cc91c['id']},'transaction':_0x38cf48});});return Promise[_0xedf7('0x53')](_0xe72715);})[_0xedf7('0x11')](function(){return db['TeamVoicePrefix'][_0xedf7('0x46')]({'where':{'teamId':{'$in':_0x4605f7}}});})[_0xedf7('0x11')](function(_0x27c20a){var _0x40a2f3=_[_0xedf7('0x31')](_0x27c20a,function(_0x48b06a){return db['UserVoicePrefix']['destroy']({'where':{'UserId':_0x4cc91c['id'],'VoicePrefixId':_0x48b06a[_0xedf7('0x11b')]}},{'transaction':_0x38cf48});});return Promise[_0xedf7('0x53')](_0x40a2f3);});});})[_0xedf7('0x11')](function(){for(var _0x177129=0x0;_0x177129<_0x4378ee[_0xedf7('0x4a')];_0x177129++){var _0xe122e9=_0x4378ee[_0x177129][_0xedf7('0x11c')]('channel');var _0x2c8c5c=_0xe122e9+_0xedf7('0xad');socket[_0xedf7('0x27')](_0xedf7('0x2e')+_0xe122e9+_0xedf7('0xb6'),{'UserId':_0x3b2573,['queueField']:_0x4378ee[_0x177129]['id']});}})['then'](respondWithStatusCode(_0x5ce5e3,null))[_0xedf7('0x5e')](APIHandleError(_0x5ce5e3));};exports['getLists']=function(_0x281320,_0x5a1495){var _0x272cc6={};var _0x4d3395={};var _0x53b74e;var _0x4fb9bc;return db[_0xedf7('0x38')][_0xedf7('0x98')]({'where':{'id':_0x281320[_0xedf7('0x55')]['id']}})[_0xedf7('0x11')](handleEntityNotFound(_0x5a1495,null))[_0xedf7('0x11')](function(_0x39d643){if(_0x39d643){_0x53b74e=_0x39d643;_0x4d3395[_0xedf7('0x5a')]=_[_0xedf7('0x57')](db['CmList']['rawAttributes']);_0x4d3395[_0xedf7('0x40')]=_[_0xedf7('0x57')](_0x281320['query']);_0x4d3395[_0xedf7('0x58')]=_[_0xedf7('0x59')](_0x4d3395[_0xedf7('0x5a')],_0x4d3395[_0xedf7('0x40')]);_0x272cc6['attributes']=_[_0xedf7('0x59')](_0x4d3395['model'],qs[_0xedf7('0x5b')](_0x281320[_0xedf7('0x40')]['fields']));_0x272cc6[_0xedf7('0x45')]=_0x272cc6[_0xedf7('0x45')]['length']?_0x272cc6['attributes']:_0x4d3395[_0xedf7('0x5a')];_0x272cc6[_0xedf7('0xd0')]=qs[_0xedf7('0xd1')](_0x281320['query'][_0xedf7('0xd1')]);_0x272cc6[_0xedf7('0x3f')]=qs[_0xedf7('0x58')](_[_0xedf7('0xdb')](_0x281320[_0xedf7('0x40')],_0x4d3395[_0xedf7('0x58')]));if(_0x281320[_0xedf7('0x40')]['filter']){_0x272cc6[_0xedf7('0x3f')]=_[_0xedf7('0xd2')](_0x272cc6['where'],{'$or':_['map'](_0x272cc6['attributes'],function(_0x2af975){var _0xbe10ea={};_0xbe10ea[_0x2af975]={'$like':'%'+_0x281320[_0xedf7('0x40')]['filter']+'%'};return _0xbe10ea;})});}_0x272cc6=_[_0xedf7('0xd2')]({},_0x272cc6,_0x281320[_0xedf7('0x5d')]);return _0x53b74e['getLists'](_0x272cc6);}})['then'](function(_0x3ac134){if(_0x3ac134){_0x4fb9bc=_0x3ac134[_0xedf7('0x4a')];if(!_0x281320[_0xedf7('0x40')][_0xedf7('0xd3')](_0xedf7('0xd8'))){_0x272cc6[_0xedf7('0x23')]=qs[_0xedf7('0x23')](_0x281320['query'][_0xedf7('0x23')]);_0x272cc6[_0xedf7('0x20')]=qs[_0xedf7('0x20')](_0x281320[_0xedf7('0x40')][_0xedf7('0x20')]);}return _0x53b74e[_0xedf7('0x11e')](_0x272cc6);}})['then'](function(_0x4aad87){if(_0x4aad87){return _0x4aad87?{'count':_0x4fb9bc,'rows':_0x4aad87}:null;}})[_0xedf7('0x11')](respondWithResult(_0x5a1495,null))[_0xedf7('0x5e')](handleError(_0x5a1495,null));};exports[_0xedf7('0x11f')]=function(_0x3896da,_0x25bf28){var _0x37d4fd={};var _0x450e5d={};var _0x48b139;return db[_0xedf7('0x38')][_0xedf7('0x98')]({'where':{'id':_0x3896da[_0xedf7('0x55')]['id']}})[_0xedf7('0x11')](handleEntityNotFound(_0x25bf28,null))['then'](function(_0x4749a5){if(_0x4749a5){_0x48b139=_0x4749a5;_0x450e5d[_0xedf7('0x5a')]=_[_0xedf7('0x57')](db[_0xedf7('0x38')][_0xedf7('0x39')]);_0x450e5d[_0xedf7('0x40')]=_[_0xedf7('0x57')](_0x3896da[_0xedf7('0x40')]);_0x450e5d['filters']=_['intersection'](_0x450e5d[_0xedf7('0x5a')],_0x450e5d[_0xedf7('0x40')]);_0x37d4fd[_0xedf7('0x45')]=_['intersection'](_0x450e5d[_0xedf7('0x5a')],qs['fields'](_0x3896da['query'][_0xedf7('0x5b')]));_0x37d4fd[_0xedf7('0x45')]=_0x37d4fd[_0xedf7('0x45')][_0xedf7('0x4a')]?_0x37d4fd['attributes']:_0x450e5d[_0xedf7('0x5a')];_0x37d4fd['order']=qs[_0xedf7('0xd1')](_0x3896da['query'][_0xedf7('0xd1')]);_0x37d4fd[_0xedf7('0x3f')]=qs[_0xedf7('0x58')](_['pick'](_0x3896da[_0xedf7('0x40')],_0x450e5d[_0xedf7('0x58')]));if(_0x3896da[_0xedf7('0x40')][_0xedf7('0x30')]){_0x37d4fd[_0xedf7('0x3f')]=_[_0xedf7('0xd2')](_0x37d4fd[_0xedf7('0x3f')],{'$or':_[_0xedf7('0x31')](_0x37d4fd['attributes'],function(_0x5b6808){var _0x1343de={};_0x1343de[_0x5b6808]={'$like':'%'+_0x3896da[_0xedf7('0x40')][_0xedf7('0x30')]+'%'};return _0x1343de;})});}_0x37d4fd[_0xedf7('0x5a')]=db[_0xedf7('0x38')];_0x37d4fd['as']=_0xedf7('0x90');_0x37d4fd=_[_0xedf7('0xd2')]({},_0x37d4fd,_0x3896da[_0xedf7('0x5d')]);return _0x48b139[_0xedf7('0xfb')]({'include':[_0x37d4fd]});}})[_0xedf7('0x11')](function(_0xd7e6bd){if(_0xd7e6bd){var _0x58af0b={},_0x1d9d0c=[];for(var _0xaf8d2b=0x0;_0xaf8d2b<_0xd7e6bd[_0xedf7('0x4a')];_0xaf8d2b+=0x1){for(var _0x39e0e6=0x0,_0x1a27c5;_0x39e0e6<_0xd7e6bd[_0xaf8d2b][_0xedf7('0x90')]['length'];_0x39e0e6+=0x1){_0x1a27c5=_0xd7e6bd[_0xaf8d2b][_0xedf7('0x90')][_0x39e0e6][_0xedf7('0x2a')]({'plain':!![]});_0x58af0b[_0x1a27c5['id']]=_0x1a27c5;}}_0x58af0b=_[_0xedf7('0x120')](_0x58af0b);for(var _0x942a90=qs['offset'](_0x3896da[_0xedf7('0x40')][_0xedf7('0x20')]);_0x942a90<_0x58af0b['length']&&_0x1d9d0c[_0xedf7('0x4a')]<qs[_0xedf7('0x23')](_0x3896da[_0xedf7('0x40')][_0xedf7('0x23')]);_0x942a90+=0x1){if(_0x58af0b[_0x942a90]){_0x1d9d0c[_0xedf7('0x4b')](_0x58af0b[_0x942a90]);}}return{'count':_0x58af0b[_0xedf7('0x4a')],'rows':_0x1d9d0c};}})[_0xedf7('0x11')](respondWithResult(_0x25bf28,null))[_0xedf7('0x5e')](handleError(_0x25bf28,null));};exports[_0xedf7('0x29')]=function(_0x37db98,_0x36cc97){if(_0x37db98[_0xedf7('0x2e')]['id']==_0x37db98[_0xedf7('0x55')]['id']){return _0x36cc97['status'](0x1f4)[_0xedf7('0x36')]({'message':_0xedf7('0x121')});}return db[_0xedf7('0x38')][_0xedf7('0x62')]({'where':{'id':_0x37db98[_0xedf7('0x55')]['id']}})[_0xedf7('0x11')](handleEntityNotFound(_0x36cc97,null))[_0xedf7('0x11')](removeEntity(_0x36cc97,null))[_0xedf7('0x5e')](handleError(_0x36cc97,null));};exports[_0xedf7('0x122')]=function(_0x21ed05,_0x57557c){return db[_0xedf7('0x38')][_0xedf7('0x62')]({'where':{'id':_0x21ed05[_0xedf7('0x55')]['id']}})[_0xedf7('0x11')](handleEntityNotFound(_0x57557c,null))['then'](function(_0x435fba){if(_0x435fba){return _0x435fba[_0xedf7('0x122')](_0x21ed05[_0xedf7('0x5f')][_0xedf7('0x63')],_[_0xedf7('0x64')](_0x21ed05['body'],['ids','id'])||{})[_0xedf7('0xab')](function(){for(var _0x2c695b=0x0;_0x2c695b<_0x21ed05[_0xedf7('0x5f')]['ids'][_0xedf7('0x4a')];_0x2c695b+=0x1){socket['emit'](_0xedf7('0x123'),{'ChatInteractionId':Number(_0x21ed05[_0xedf7('0x5f')][_0xedf7('0x63')][_0x2c695b]),'UserId':Number(_0x21ed05[_0xedf7('0x55')]['id'])});}return _0x21ed05[_0xedf7('0x5f')]['ids'];});}})['then'](respondWithResult(_0x57557c,null))[_0xedf7('0x5e')](handleError(_0x57557c,null));};exports[_0xedf7('0x124')]=function(_0x51f674,_0x533539){return db[_0xedf7('0x38')][_0xedf7('0x62')]({'where':{'id':_0x51f674[_0xedf7('0x55')]['id']}})[_0xedf7('0x11')](handleEntityNotFound(_0x533539,null))[_0xedf7('0x11')](function(_0x13796e){if(_0x13796e){return _0x13796e[_0xedf7('0x124')](_0x51f674[_0xedf7('0x40')]['ids'])[_0xedf7('0x11')](function(){if(_['isArray'](_0x51f674[_0xedf7('0x40')][_0xedf7('0x63')])){for(var _0x180fd8=0x0;_0x180fd8<_0x51f674['query'][_0xedf7('0x63')][_0xedf7('0x4a')];_0x180fd8+=0x1){socket[_0xedf7('0x27')]('user_has_chat_interactions:remove',{'ChatInteractionId':Number(_0x51f674[_0xedf7('0x40')][_0xedf7('0x63')][_0x180fd8]),'UserId':Number(_0x51f674[_0xedf7('0x55')]['id'])});}}else{socket[_0xedf7('0x27')](_0xedf7('0x125'),{'ChatInteractionId':Number(_0x51f674[_0xedf7('0x40')][_0xedf7('0x63')]),'UserId':Number(_0x51f674[_0xedf7('0x55')]['id'])});}});}})[_0xedf7('0x11')](respondWithStatusCode(_0x533539,null))[_0xedf7('0x5e')](handleError(_0x533539,null));};exports[_0xedf7('0x126')]=function(_0x1d3a9f,_0x2ec67e){return db[_0xedf7('0x38')][_0xedf7('0x62')]({'where':{'id':_0x1d3a9f[_0xedf7('0x55')]['id']}})[_0xedf7('0x11')](handleEntityNotFound(_0x2ec67e,null))['then'](function(_0x2c1098){if(_0x2c1098){return _0x2c1098[_0xedf7('0x126')](_0x1d3a9f['body']['ids'],_[_0xedf7('0x64')](_0x1d3a9f[_0xedf7('0x5f')],[_0xedf7('0x63'),'id'])||{})[_0xedf7('0xab')](function(){for(var _0x36fd14=0x0;_0x36fd14<_0x1d3a9f[_0xedf7('0x5f')][_0xedf7('0x63')][_0xedf7('0x4a')];_0x36fd14+=0x1){socket[_0xedf7('0x27')](_0xedf7('0x127'),{'MailInteractionId':Number(_0x1d3a9f[_0xedf7('0x5f')][_0xedf7('0x63')][_0x36fd14]),'UserId':Number(_0x1d3a9f[_0xedf7('0x55')]['id'])});}return _0x1d3a9f[_0xedf7('0x5f')][_0xedf7('0x63')];});}})[_0xedf7('0x11')](respondWithResult(_0x2ec67e,null))[_0xedf7('0x5e')](handleError(_0x2ec67e,null));};exports[_0xedf7('0x128')]=function(_0x4ee662,_0x59313c){return db['User'][_0xedf7('0x62')]({'where':{'id':_0x4ee662[_0xedf7('0x55')]['id']}})[_0xedf7('0x11')](handleEntityNotFound(_0x59313c,null))[_0xedf7('0x11')](function(_0x3fcfcf){if(_0x3fcfcf){return _0x3fcfcf['removeMailInteractions'](_0x4ee662[_0xedf7('0x40')]['ids'])['then'](function(){if(_['isArray'](_0x4ee662[_0xedf7('0x40')]['ids'])){for(var _0xb857ae=0x0;_0xb857ae<_0x4ee662[_0xedf7('0x40')]['ids']['length'];_0xb857ae+=0x1){socket[_0xedf7('0x27')](_0xedf7('0x129'),{'MailInteractionId':Number(_0x4ee662[_0xedf7('0x40')][_0xedf7('0x63')][_0xb857ae]),'UserId':Number(_0x4ee662['params']['id'])});}}else{socket[_0xedf7('0x27')](_0xedf7('0x129'),{'MailInteractionId':Number(_0x4ee662['query'][_0xedf7('0x63')]),'UserId':Number(_0x4ee662[_0xedf7('0x55')]['id'])});}});}})['then'](respondWithStatusCode(_0x59313c,null))[_0xedf7('0x5e')](handleError(_0x59313c,null));};exports['addFaxInteractions']=function(_0x2d7e6a,_0x17211d){return db['User'][_0xedf7('0x62')]({'where':{'id':_0x2d7e6a[_0xedf7('0x55')]['id']}})[_0xedf7('0x11')](handleEntityNotFound(_0x17211d,null))['then'](function(_0x82cd9a){if(_0x82cd9a){return _0x82cd9a[_0xedf7('0x12a')](_0x2d7e6a[_0xedf7('0x5f')][_0xedf7('0x63')],_['omit'](_0x2d7e6a[_0xedf7('0x5f')],[_0xedf7('0x63'),'id'])||{})[_0xedf7('0xab')](function(){for(var _0x4a9402=0x0;_0x4a9402<_0x2d7e6a[_0xedf7('0x5f')][_0xedf7('0x63')][_0xedf7('0x4a')];_0x4a9402+=0x1){socket[_0xedf7('0x27')](_0xedf7('0x12b'),{'FaxInteractionId':Number(_0x2d7e6a[_0xedf7('0x5f')][_0xedf7('0x63')][_0x4a9402]),'UserId':Number(_0x2d7e6a[_0xedf7('0x55')]['id'])});}return _0x2d7e6a[_0xedf7('0x5f')][_0xedf7('0x63')];});}})[_0xedf7('0x11')](respondWithResult(_0x17211d,null))[_0xedf7('0x5e')](handleError(_0x17211d,null));};exports[_0xedf7('0x12c')]=function(_0x4e4423,_0x54d925){return db['User'][_0xedf7('0x62')]({'where':{'id':_0x4e4423['params']['id']}})['then'](handleEntityNotFound(_0x54d925,null))[_0xedf7('0x11')](function(_0x3d61ed){if(_0x3d61ed){return _0x3d61ed[_0xedf7('0x12c')](_0x4e4423[_0xedf7('0x40')][_0xedf7('0x63')])[_0xedf7('0x11')](function(){if(_[_0xedf7('0xb5')](_0x4e4423[_0xedf7('0x40')]['ids'])){for(var _0x52b1fa=0x0;_0x52b1fa<_0x4e4423[_0xedf7('0x40')][_0xedf7('0x63')][_0xedf7('0x4a')];_0x52b1fa+=0x1){socket[_0xedf7('0x27')](_0xedf7('0x12d'),{'FaxInteractionId':Number(_0x4e4423['query'][_0xedf7('0x63')][_0x52b1fa]),'UserId':Number(_0x4e4423[_0xedf7('0x55')]['id'])});}}else{socket[_0xedf7('0x27')](_0xedf7('0x12d'),{'FaxInteractionId':Number(_0x4e4423[_0xedf7('0x40')][_0xedf7('0x63')]),'UserId':Number(_0x4e4423[_0xedf7('0x55')]['id'])});}});}})[_0xedf7('0x11')](respondWithStatusCode(_0x54d925,null))[_0xedf7('0x5e')](handleError(_0x54d925,null));};exports[_0xedf7('0x12e')]=function(_0x3813e7,_0xa95161){return db[_0xedf7('0x38')][_0xedf7('0x62')]({'where':{'id':_0x3813e7[_0xedf7('0x55')]['id']}})[_0xedf7('0x11')](handleEntityNotFound(_0xa95161,null))[_0xedf7('0x11')](function(_0x390d3a){if(_0x390d3a){return _0x390d3a[_0xedf7('0x12e')](_0x3813e7[_0xedf7('0x5f')][_0xedf7('0x63')],_[_0xedf7('0x64')](_0x3813e7['body'],[_0xedf7('0x63'),'id'])||{})['spread'](function(){for(var _0x4cabbc=0x0;_0x4cabbc<_0x3813e7['body'][_0xedf7('0x63')][_0xedf7('0x4a')];_0x4cabbc+=0x1){socket[_0xedf7('0x27')](_0xedf7('0x12f'),{'SmsInteractionId':Number(_0x3813e7[_0xedf7('0x5f')]['ids'][_0x4cabbc]),'UserId':Number(_0x3813e7[_0xedf7('0x55')]['id'])});}return _0x3813e7['body'][_0xedf7('0x63')];});}})['then'](respondWithResult(_0xa95161,null))[_0xedf7('0x5e')](handleError(_0xa95161,null));};exports[_0xedf7('0x130')]=function(_0x3b0d48,_0x13877a){return db['User']['find']({'where':{'id':_0x3b0d48[_0xedf7('0x55')]['id']}})[_0xedf7('0x11')](handleEntityNotFound(_0x13877a,null))[_0xedf7('0x11')](function(_0xf389a){if(_0xf389a){return _0xf389a['removeSmsInteractions'](_0x3b0d48[_0xedf7('0x40')][_0xedf7('0x63')])[_0xedf7('0x11')](function(){if(_['isArray'](_0x3b0d48[_0xedf7('0x40')]['ids'])){for(var _0x97c847=0x0;_0x97c847<_0x3b0d48[_0xedf7('0x40')][_0xedf7('0x63')][_0xedf7('0x4a')];_0x97c847+=0x1){socket[_0xedf7('0x27')](_0xedf7('0x131'),{'SmsInteractionId':Number(_0x3b0d48[_0xedf7('0x40')][_0xedf7('0x63')][_0x97c847]),'UserId':Number(_0x3b0d48[_0xedf7('0x55')]['id'])});}}else{socket[_0xedf7('0x27')](_0xedf7('0x131'),{'SmsInteractionId':Number(_0x3b0d48[_0xedf7('0x40')][_0xedf7('0x63')]),'UserId':Number(_0x3b0d48[_0xedf7('0x55')]['id'])});}});}})['then'](respondWithStatusCode(_0x13877a,null))[_0xedf7('0x5e')](handleError(_0x13877a,null));};exports[_0xedf7('0x132')]=function(_0x3d5ee7,_0x3a0705){return db[_0xedf7('0x38')][_0xedf7('0x62')]({'where':{'id':_0x3d5ee7[_0xedf7('0x55')]['id']}})[_0xedf7('0x11')](handleEntityNotFound(_0x3a0705,null))[_0xedf7('0x11')](function(_0x27ca9e){if(_0x27ca9e){return _0x27ca9e[_0xedf7('0x132')](_0x3d5ee7['body'][_0xedf7('0x63')],_[_0xedf7('0x64')](_0x3d5ee7[_0xedf7('0x5f')],[_0xedf7('0x63'),'id'])||{})[_0xedf7('0xab')](function(){for(var _0x3389be=0x0;_0x3389be<_0x3d5ee7[_0xedf7('0x5f')][_0xedf7('0x63')][_0xedf7('0x4a')];_0x3389be+=0x1){socket['emit'](_0xedf7('0x133'),{'OpenchannelInteractionId':Number(_0x3d5ee7['body'][_0xedf7('0x63')][_0x3389be]),'UserId':Number(_0x3d5ee7[_0xedf7('0x55')]['id'])});}return _0x3d5ee7[_0xedf7('0x5f')][_0xedf7('0x63')];});}})[_0xedf7('0x11')](respondWithResult(_0x3a0705,null))['catch'](handleError(_0x3a0705,null));};exports[_0xedf7('0x134')]=function(_0x307279,_0xc0c486){return db[_0xedf7('0x38')][_0xedf7('0x62')]({'where':{'id':_0x307279[_0xedf7('0x55')]['id']}})[_0xedf7('0x11')](handleEntityNotFound(_0xc0c486,null))[_0xedf7('0x11')](function(_0x4c740d){if(_0x4c740d){return _0x4c740d[_0xedf7('0x134')](_0x307279[_0xedf7('0x40')]['ids'])['then'](function(){if(_[_0xedf7('0xb5')](_0x307279['query'][_0xedf7('0x63')])){for(var _0x3a26da=0x0;_0x3a26da<_0x307279[_0xedf7('0x40')][_0xedf7('0x63')][_0xedf7('0x4a')];_0x3a26da+=0x1){socket[_0xedf7('0x27')](_0xedf7('0x135'),{'OpenchannelInteractionId':Number(_0x307279['query'][_0xedf7('0x63')][_0x3a26da]),'UserId':Number(_0x307279[_0xedf7('0x55')]['id'])});}}else{socket['emit'](_0xedf7('0x135'),{'OpenchannelInteractionId':Number(_0x307279[_0xedf7('0x40')][_0xedf7('0x63')]),'UserId':Number(_0x307279['params']['id'])});}});}})[_0xedf7('0x11')](respondWithStatusCode(_0xc0c486,null))['catch'](handleError(_0xc0c486,null));};exports[_0xedf7('0x136')]=function(_0x5afb8d,_0x2bc5d8){return db['User'][_0xedf7('0x62')]({'where':{'id':_0x5afb8d[_0xedf7('0x55')]['id']}})[_0xedf7('0x11')](handleEntityNotFound(_0x2bc5d8,null))[_0xedf7('0x11')](function(_0x8ac814){if(_0x8ac814){return _0x8ac814[_0xedf7('0x136')](_0x5afb8d[_0xedf7('0x5f')][_0xedf7('0x63')],_[_0xedf7('0x64')](_0x5afb8d[_0xedf7('0x5f')],[_0xedf7('0x63'),'id'])||{})[_0xedf7('0xab')](function(){for(var _0x4273e5=0x0;_0x4273e5<_0x5afb8d[_0xedf7('0x5f')][_0xedf7('0x63')][_0xedf7('0x4a')];_0x4273e5+=0x1){socket[_0xedf7('0x27')](_0xedf7('0x137'),{'WhatsappInteractionId':Number(_0x5afb8d[_0xedf7('0x5f')][_0xedf7('0x63')][_0x4273e5]),'UserId':Number(_0x5afb8d[_0xedf7('0x55')]['id'])});}return _0x5afb8d['body']['ids'];});}})[_0xedf7('0x11')](respondWithResult(_0x2bc5d8,null))[_0xedf7('0x5e')](handleError(_0x2bc5d8,null));};exports['removeWhatsappInteractions']=function(_0x2e2c20,_0x370029){return db[_0xedf7('0x38')][_0xedf7('0x62')]({'where':{'id':_0x2e2c20[_0xedf7('0x55')]['id']}})[_0xedf7('0x11')](handleEntityNotFound(_0x370029,null))['then'](function(_0x227144){if(_0x227144){return _0x227144['removeWhatsappInteractions'](_0x2e2c20['query']['ids']);}})['then'](respondWithStatusCode(_0x370029,null))[_0xedf7('0x5e')](handleError(_0x370029,null));};exports[_0xedf7('0x138')]=function(_0x167e43,_0x3f16c5){var _0x321011={};var _0x474821={};var _0x4f6d69;var _0x471665;return db[_0xedf7('0x38')]['findOne']({'where':{'id':_0x167e43[_0xedf7('0x55')]['id']}})[_0xedf7('0x11')](handleEntityNotFound(_0x3f16c5,null))['then'](function(_0x24582d){if(_0x24582d){_0x4f6d69=_0x24582d;_0x474821[_0xedf7('0x5a')]=_['keys'](db[_0xedf7('0x139')][_0xedf7('0x39')]);_0x474821[_0xedf7('0x40')]=_[_0xedf7('0x57')](_0x167e43[_0xedf7('0x40')]);_0x474821[_0xedf7('0x58')]=_['intersection'](_0x474821[_0xedf7('0x5a')],_0x474821[_0xedf7('0x40')]);_0x321011['attributes']=_['intersection'](_0x474821[_0xedf7('0x5a')],qs[_0xedf7('0x5b')](_0x167e43[_0xedf7('0x40')][_0xedf7('0x5b')]));_0x321011[_0xedf7('0x45')]=_0x321011[_0xedf7('0x45')][_0xedf7('0x4a')]?_0x321011[_0xedf7('0x45')]:_0x474821[_0xedf7('0x5a')];_0x321011[_0xedf7('0xd0')]=qs['sort'](_0x167e43['query'][_0xedf7('0xd1')]);_0x321011[_0xedf7('0x3f')]=qs[_0xedf7('0x58')](_[_0xedf7('0xdb')](_0x167e43['query'],_0x474821[_0xedf7('0x58')]));if(_0x167e43[_0xedf7('0x40')][_0xedf7('0x30')]){_0x321011[_0xedf7('0x3f')]=_['merge'](_0x321011['where'],{'$or':_['map'](_0x321011[_0xedf7('0x45')],function(_0x164a2b){var _0x27e58c={};_0x27e58c[_0x164a2b]={'$like':'%'+_0x167e43[_0xedf7('0x40')][_0xedf7('0x30')]+'%'};return _0x27e58c;})});}_0x321011=_[_0xedf7('0xd2')]({},_0x321011,_0x167e43[_0xedf7('0x5d')]);return _0x4f6d69[_0xedf7('0x138')](_0x321011);}})[_0xedf7('0x11')](function(_0x527b31){if(_0x527b31){_0x471665=_0x527b31[_0xedf7('0x4a')];if(!_0x167e43[_0xedf7('0x40')]['hasOwnProperty'](_0xedf7('0xd8'))){_0x321011[_0xedf7('0x23')]=qs[_0xedf7('0x23')](_0x167e43[_0xedf7('0x40')]['limit']);_0x321011[_0xedf7('0x20')]=qs['offset'](_0x167e43[_0xedf7('0x40')][_0xedf7('0x20')]);}return _0x4f6d69[_0xedf7('0x138')](_0x321011);}})[_0xedf7('0x11')](function(_0x570814){if(_0x570814){return _0x570814?{'count':_0x471665,'rows':_0x570814}:null;}})[_0xedf7('0x11')](respondWithResult(_0x3f16c5,null))[_0xedf7('0x5e')](handleError(_0x3f16c5,null));};exports[_0xedf7('0x13a')]=function(_0x28fc0c,_0x433162){var _0x5c4c94={};var _0xe907b3={};var _0x28ae93;var _0x2e0b98;return db[_0xedf7('0x38')][_0xedf7('0x98')]({'where':{'id':_0x28fc0c['params']['id']}})['then'](handleEntityNotFound(_0x433162,null))[_0xedf7('0x11')](function(_0x1cd505){if(_0x1cd505){_0x28ae93=_0x1cd505;_0xe907b3[_0xedf7('0x5a')]=_['keys'](db[_0xedf7('0x13b')][_0xedf7('0x39')]);_0xe907b3[_0xedf7('0x40')]=_[_0xedf7('0x57')](_0x28fc0c[_0xedf7('0x40')]);_0xe907b3[_0xedf7('0x58')]=_[_0xedf7('0x59')](_0xe907b3[_0xedf7('0x5a')],_0xe907b3[_0xedf7('0x40')]);_0x5c4c94[_0xedf7('0x45')]=_[_0xedf7('0x59')](_0xe907b3['model'],qs['fields'](_0x28fc0c[_0xedf7('0x40')][_0xedf7('0x5b')]));_0x5c4c94[_0xedf7('0x45')]=_0x5c4c94['attributes'][_0xedf7('0x4a')]?_0x5c4c94[_0xedf7('0x45')]:_0xe907b3['model'];_0x5c4c94[_0xedf7('0xd0')]=qs['sort'](_0x28fc0c[_0xedf7('0x40')][_0xedf7('0xd1')]);_0x5c4c94['where']=qs[_0xedf7('0x58')](_['pick'](_0x28fc0c['query'],_0xe907b3[_0xedf7('0x58')]));if(_0x28fc0c['query'][_0xedf7('0x30')]){_0x5c4c94[_0xedf7('0x3f')]=_[_0xedf7('0xd2')](_0x5c4c94['where'],{'$or':_['map'](_0x5c4c94[_0xedf7('0x45')],function(_0x225dae){var _0x41bba0={};_0x41bba0[_0x225dae]={'$like':'%'+_0x28fc0c[_0xedf7('0x40')]['filter']+'%'};return _0x41bba0;})});}_0x5c4c94=_['merge']({},_0x5c4c94,_0x28fc0c['options']);return _0x28ae93[_0xedf7('0x13a')](_0x5c4c94);}})['then'](function(_0x4e4c7b){if(_0x4e4c7b){_0x2e0b98=_0x4e4c7b[_0xedf7('0x4a')];if(!_0x28fc0c[_0xedf7('0x40')][_0xedf7('0xd3')]('nolimit')){_0x5c4c94[_0xedf7('0x23')]=qs[_0xedf7('0x23')](_0x28fc0c[_0xedf7('0x40')][_0xedf7('0x23')]);_0x5c4c94['offset']=qs[_0xedf7('0x20')](_0x28fc0c[_0xedf7('0x40')][_0xedf7('0x20')]);}return _0x28ae93[_0xedf7('0x13a')](_0x5c4c94);}})[_0xedf7('0x11')](function(_0xea710e){if(_0xea710e){return _0xea710e?{'count':_0x2e0b98,'rows':_0xea710e}:null;}})[_0xedf7('0x11')](respondWithResult(_0x433162,null))['catch'](handleError(_0x433162,null));};exports[_0xedf7('0x13c')]=function(_0x1733d3,_0xe1df9){return db[_0xedf7('0x38')][_0xedf7('0x62')]({'where':{'id':_0x1733d3[_0xedf7('0x55')]['id']}})[_0xedf7('0x11')](handleEntityNotFound(_0xe1df9,null))[_0xedf7('0x11')](function(_0x1c7c19){if(_0x1c7c19){return _0x1c7c19[_0xedf7('0x13c')](_0x1733d3[_0xedf7('0x5f')][_0xedf7('0x63')],_[_0xedf7('0x64')](_0x1733d3['body'],[_0xedf7('0x63'),'id'])||{});}})[_0xedf7('0x11')](respondWithResult(_0xe1df9,null))[_0xedf7('0x5e')](handleError(_0xe1df9,null));};exports[_0xedf7('0x13d')]=function(_0x53c9d9,_0x3d51af){return db[_0xedf7('0x38')][_0xedf7('0x62')]({'where':{'id':_0x53c9d9['params']['id']}})['then'](handleEntityNotFound(_0x3d51af,null))[_0xedf7('0x11')](function(_0x1e5143){if(_0x1e5143){return _0x1e5143[_0xedf7('0x13d')](_0x53c9d9['query'][_0xedf7('0x63')]);}})[_0xedf7('0x11')](respondWithStatusCode(_0x3d51af,null))[_0xedf7('0x5e')](handleError(_0x3d51af,null));};exports[_0xedf7('0x13e')]=function(_0x557624,_0x1bab75){var _0x44fb03={};var _0x48bb20={};var _0x41d518;var _0x284ea9;return db[_0xedf7('0x38')]['findOne']({'where':{'id':_0x557624[_0xedf7('0x55')]['id']}})[_0xedf7('0x11')](handleEntityNotFound(_0x1bab75,null))['then'](function(_0x3efa1a){if(_0x3efa1a){_0x41d518=_0x3efa1a;_0x48bb20['model']=_['keys'](db['MailAccount'][_0xedf7('0x39')]);_0x48bb20[_0xedf7('0x40')]=_[_0xedf7('0x57')](_0x557624['query']);_0x48bb20[_0xedf7('0x58')]=_[_0xedf7('0x59')](_0x48bb20[_0xedf7('0x5a')],_0x48bb20[_0xedf7('0x40')]);_0x44fb03['attributes']=_[_0xedf7('0x59')](_0x48bb20['model'],qs['fields'](_0x557624[_0xedf7('0x40')][_0xedf7('0x5b')]));_0x44fb03[_0xedf7('0x45')]=_0x44fb03[_0xedf7('0x45')][_0xedf7('0x4a')]?_0x44fb03[_0xedf7('0x45')]:_0x48bb20[_0xedf7('0x5a')];_0x44fb03[_0xedf7('0xd0')]=qs[_0xedf7('0xd1')](_0x557624[_0xedf7('0x40')][_0xedf7('0xd1')]);_0x44fb03['where']=qs[_0xedf7('0x58')](_['pick'](_0x557624[_0xedf7('0x40')],_0x48bb20[_0xedf7('0x58')]));if(_0x557624[_0xedf7('0x40')][_0xedf7('0x30')]){_0x44fb03[_0xedf7('0x3f')]=_[_0xedf7('0xd2')](_0x44fb03[_0xedf7('0x3f')],{'$or':_[_0xedf7('0x31')](_0x44fb03['attributes'],function(_0xcbee39){var _0x16cdc8={};_0x16cdc8[_0xcbee39]={'$like':'%'+_0x557624['query'][_0xedf7('0x30')]+'%'};return _0x16cdc8;})});}_0x44fb03=_[_0xedf7('0xd2')]({},_0x44fb03,_0x557624['options']);return _0x41d518[_0xedf7('0x13e')](_0x44fb03);}})[_0xedf7('0x11')](function(_0x7ea714){if(_0x7ea714){_0x284ea9=_0x7ea714['length'];if(!_0x557624[_0xedf7('0x40')][_0xedf7('0xd3')](_0xedf7('0xd8'))){_0x44fb03[_0xedf7('0x23')]=qs[_0xedf7('0x23')](_0x557624[_0xedf7('0x40')][_0xedf7('0x23')]);_0x44fb03[_0xedf7('0x20')]=qs[_0xedf7('0x20')](_0x557624[_0xedf7('0x40')][_0xedf7('0x20')]);}return _0x41d518[_0xedf7('0x13e')](_0x44fb03);}})['then'](function(_0x4b97e5){if(_0x4b97e5){return _0x4b97e5?{'count':_0x284ea9,'rows':_0x4b97e5}:null;}})[_0xedf7('0x11')](respondWithResult(_0x1bab75,null))['catch'](handleError(_0x1bab75,null));};exports[_0xedf7('0x13f')]=function(_0x5951c1,_0x5812fc){return db[_0xedf7('0x38')][_0xedf7('0x62')]({'where':{'id':_0x5951c1[_0xedf7('0x55')]['id']}})[_0xedf7('0x11')](handleEntityNotFound(_0x5812fc,null))['then'](function(_0x422755){if(_0x422755){return _0x422755['addMailAccounts'](_0x5951c1[_0xedf7('0x5f')][_0xedf7('0x63')],_[_0xedf7('0x64')](_0x5951c1[_0xedf7('0x5f')],[_0xedf7('0x63'),'id'])||{});}})[_0xedf7('0x11')](respondWithResult(_0x5812fc,null))[_0xedf7('0x5e')](handleError(_0x5812fc,null));};exports[_0xedf7('0x140')]=function(_0x31d111,_0x145db3){return db[_0xedf7('0x38')]['find']({'where':{'id':_0x31d111[_0xedf7('0x55')]['id']}})[_0xedf7('0x11')](handleEntityNotFound(_0x145db3,null))[_0xedf7('0x11')](function(_0x5c86a9){if(_0x5c86a9){return _0x5c86a9['removeMailAccounts'](_0x31d111[_0xedf7('0x40')]['ids']);}})[_0xedf7('0x11')](respondWithStatusCode(_0x145db3,null))[_0xedf7('0x5e')](handleError(_0x145db3,null));};exports[_0xedf7('0x141')]=function(_0x2f08db,_0x17f77f){var _0x36db1e={};var _0xd09633={};var _0x4a5351;var _0x3c1706;return db['User'][_0xedf7('0x98')]({'where':{'id':_0x2f08db[_0xedf7('0x55')]['id']}})['then'](handleEntityNotFound(_0x17f77f,null))[_0xedf7('0x11')](function(_0x2ac61f){if(_0x2ac61f){_0x4a5351=_0x2ac61f;_0xd09633[_0xedf7('0x5a')]=_['keys'](db[_0xedf7('0x142')][_0xedf7('0x39')]);_0xd09633[_0xedf7('0x40')]=_[_0xedf7('0x57')](_0x2f08db[_0xedf7('0x40')]);_0xd09633[_0xedf7('0x58')]=_[_0xedf7('0x59')](_0xd09633[_0xedf7('0x5a')],_0xd09633[_0xedf7('0x40')]);_0x36db1e['attributes']=_[_0xedf7('0x59')](_0xd09633[_0xedf7('0x5a')],qs[_0xedf7('0x5b')](_0x2f08db['query'][_0xedf7('0x5b')]));_0x36db1e['attributes']=_0x36db1e[_0xedf7('0x45')]['length']?_0x36db1e['attributes']:_0xd09633[_0xedf7('0x5a')];_0x36db1e['order']=qs[_0xedf7('0xd1')](_0x2f08db[_0xedf7('0x40')][_0xedf7('0xd1')]);_0x36db1e['where']=qs[_0xedf7('0x58')](_['pick'](_0x2f08db[_0xedf7('0x40')],_0xd09633['filters']));if(_0x2f08db[_0xedf7('0x40')]['filter']){_0x36db1e['where']=_[_0xedf7('0xd2')](_0x36db1e[_0xedf7('0x3f')],{'$or':_[_0xedf7('0x31')](_0x36db1e[_0xedf7('0x45')],function(_0x3ad4d5){var _0x3dbc67={};_0x3dbc67[_0x3ad4d5]={'$like':'%'+_0x2f08db['query'][_0xedf7('0x30')]+'%'};return _0x3dbc67;})});}_0x36db1e=_[_0xedf7('0xd2')]({},_0x36db1e,_0x2f08db['options']);return _0x4a5351[_0xedf7('0x141')](_0x36db1e);}})[_0xedf7('0x11')](function(_0x4fd3e2){if(_0x4fd3e2){_0x3c1706=_0x4fd3e2[_0xedf7('0x4a')];if(!_0x2f08db['query'][_0xedf7('0xd3')](_0xedf7('0xd8'))){_0x36db1e[_0xedf7('0x23')]=qs[_0xedf7('0x23')](_0x2f08db['query'][_0xedf7('0x23')]);_0x36db1e[_0xedf7('0x20')]=qs[_0xedf7('0x20')](_0x2f08db[_0xedf7('0x40')][_0xedf7('0x20')]);}return _0x4a5351[_0xedf7('0x141')](_0x36db1e);}})[_0xedf7('0x11')](function(_0x4b3ec9){if(_0x4b3ec9){return _0x4b3ec9?{'count':_0x3c1706,'rows':_0x4b3ec9}:null;}})[_0xedf7('0x11')](respondWithResult(_0x17f77f,null))[_0xedf7('0x5e')](handleError(_0x17f77f,null));};exports[_0xedf7('0x143')]=function(_0x122962,_0x554585){return db[_0xedf7('0x38')]['find']({'where':{'id':_0x122962[_0xedf7('0x55')]['id']}})[_0xedf7('0x11')](handleEntityNotFound(_0x554585,null))['then'](function(_0x3e16b0){if(_0x3e16b0){return _0x3e16b0['addOpenchannelAccounts'](_0x122962[_0xedf7('0x5f')][_0xedf7('0x63')],_['omit'](_0x122962['body'],[_0xedf7('0x63'),'id'])||{});}})['then'](respondWithResult(_0x554585,null))[_0xedf7('0x5e')](handleError(_0x554585,null));};exports[_0xedf7('0x144')]=function(_0x2bf57d,_0x9dce65){return db[_0xedf7('0x38')][_0xedf7('0x62')]({'where':{'id':_0x2bf57d[_0xedf7('0x55')]['id']}})[_0xedf7('0x11')](handleEntityNotFound(_0x9dce65,null))[_0xedf7('0x11')](function(_0x41ab62){if(_0x41ab62){return _0x41ab62[_0xedf7('0x144')](_0x2bf57d[_0xedf7('0x40')][_0xedf7('0x63')]);}})[_0xedf7('0x11')](respondWithStatusCode(_0x9dce65,null))[_0xedf7('0x5e')](handleError(_0x9dce65,null));};exports['getSmsAccounts']=function(_0x48d87c,_0x5c9df2){var _0x2afa94={};var _0x46d246={};var _0x90d28c;var _0x57e7d1;return db['User']['findOne']({'where':{'id':_0x48d87c['params']['id']}})['then'](handleEntityNotFound(_0x5c9df2,null))[_0xedf7('0x11')](function(_0x4a4196){if(_0x4a4196){_0x90d28c=_0x4a4196;_0x46d246[_0xedf7('0x5a')]=_['keys'](db[_0xedf7('0x145')][_0xedf7('0x39')]);_0x46d246[_0xedf7('0x40')]=_[_0xedf7('0x57')](_0x48d87c[_0xedf7('0x40')]);_0x46d246[_0xedf7('0x58')]=_['intersection'](_0x46d246[_0xedf7('0x5a')],_0x46d246['query']);_0x2afa94['attributes']=_['intersection'](_0x46d246['model'],qs['fields'](_0x48d87c['query']['fields']));_0x2afa94[_0xedf7('0x45')]=_0x2afa94[_0xedf7('0x45')][_0xedf7('0x4a')]?_0x2afa94[_0xedf7('0x45')]:_0x46d246['model'];_0x2afa94[_0xedf7('0xd0')]=qs[_0xedf7('0xd1')](_0x48d87c['query'][_0xedf7('0xd1')]);_0x2afa94[_0xedf7('0x3f')]=qs[_0xedf7('0x58')](_['pick'](_0x48d87c[_0xedf7('0x40')],_0x46d246[_0xedf7('0x58')]));if(_0x48d87c[_0xedf7('0x40')][_0xedf7('0x30')]){_0x2afa94[_0xedf7('0x3f')]=_[_0xedf7('0xd2')](_0x2afa94['where'],{'$or':_[_0xedf7('0x31')](_0x2afa94['attributes'],function(_0x24633f){var _0x3cfc23={};_0x3cfc23[_0x24633f]={'$like':'%'+_0x48d87c['query'][_0xedf7('0x30')]+'%'};return _0x3cfc23;})});}_0x2afa94=_[_0xedf7('0xd2')]({},_0x2afa94,_0x48d87c[_0xedf7('0x5d')]);return _0x90d28c[_0xedf7('0x146')](_0x2afa94);}})[_0xedf7('0x11')](function(_0xc5f048){if(_0xc5f048){_0x57e7d1=_0xc5f048[_0xedf7('0x4a')];if(!_0x48d87c[_0xedf7('0x40')][_0xedf7('0xd3')](_0xedf7('0xd8'))){_0x2afa94[_0xedf7('0x23')]=qs[_0xedf7('0x23')](_0x48d87c['query']['limit']);_0x2afa94[_0xedf7('0x20')]=qs[_0xedf7('0x20')](_0x48d87c['query'][_0xedf7('0x20')]);}return _0x90d28c['getSmsAccounts'](_0x2afa94);}})['then'](function(_0x538b71){if(_0x538b71){return _0x538b71?{'count':_0x57e7d1,'rows':_0x538b71}:null;}})[_0xedf7('0x11')](respondWithResult(_0x5c9df2,null))[_0xedf7('0x5e')](handleError(_0x5c9df2,null));};exports[_0xedf7('0x147')]=function(_0x3879c0,_0x421a58){return db['User'][_0xedf7('0x62')]({'where':{'id':_0x3879c0['params']['id']}})[_0xedf7('0x11')](handleEntityNotFound(_0x421a58,null))[_0xedf7('0x11')](function(_0x220196){if(_0x220196){return _0x220196['addSmsAccounts'](_0x3879c0[_0xedf7('0x5f')][_0xedf7('0x63')],_[_0xedf7('0x64')](_0x3879c0[_0xedf7('0x5f')],[_0xedf7('0x63'),'id'])||{});}})['then'](respondWithResult(_0x421a58,null))[_0xedf7('0x5e')](handleError(_0x421a58,null));};exports[_0xedf7('0x148')]=function(_0x21b0f1,_0x170e66){return db[_0xedf7('0x38')][_0xedf7('0x62')]({'where':{'id':_0x21b0f1['params']['id']}})[_0xedf7('0x11')](handleEntityNotFound(_0x170e66,null))[_0xedf7('0x11')](function(_0x398277){if(_0x398277){return _0x398277[_0xedf7('0x148')](_0x21b0f1[_0xedf7('0x40')][_0xedf7('0x63')]);}})[_0xedf7('0x11')](respondWithStatusCode(_0x170e66,null))['catch'](handleError(_0x170e66,null));};exports['getChatWebsites']=function(_0x374b2f,_0x5d8c39){var _0x1eb66f={};var _0x134a40={};var _0x4ddaa5;var _0x4daa05;return db[_0xedf7('0x38')]['findOne']({'where':{'id':_0x374b2f[_0xedf7('0x55')]['id']}})['then'](handleEntityNotFound(_0x5d8c39,null))[_0xedf7('0x11')](function(_0x293107){if(_0x293107){_0x4ddaa5=_0x293107;_0x134a40['model']=_[_0xedf7('0x57')](db[_0xedf7('0x149')][_0xedf7('0x39')]);_0x134a40[_0xedf7('0x40')]=_['keys'](_0x374b2f[_0xedf7('0x40')]);_0x134a40['filters']=_[_0xedf7('0x59')](_0x134a40[_0xedf7('0x5a')],_0x134a40[_0xedf7('0x40')]);_0x1eb66f['attributes']=_[_0xedf7('0x59')](_0x134a40[_0xedf7('0x5a')],qs[_0xedf7('0x5b')](_0x374b2f[_0xedf7('0x40')][_0xedf7('0x5b')]));_0x1eb66f[_0xedf7('0x45')]=_0x1eb66f[_0xedf7('0x45')][_0xedf7('0x4a')]?_0x1eb66f[_0xedf7('0x45')]:_0x134a40[_0xedf7('0x5a')];_0x1eb66f['order']=qs[_0xedf7('0xd1')](_0x374b2f['query'][_0xedf7('0xd1')]);_0x1eb66f[_0xedf7('0x3f')]=qs[_0xedf7('0x58')](_[_0xedf7('0xdb')](_0x374b2f[_0xedf7('0x40')],_0x134a40['filters']));if(_0x374b2f[_0xedf7('0x40')][_0xedf7('0x30')]){_0x1eb66f[_0xedf7('0x3f')]=_[_0xedf7('0xd2')](_0x1eb66f[_0xedf7('0x3f')],{'$or':_[_0xedf7('0x31')](_0x1eb66f[_0xedf7('0x45')],function(_0x5cfc31){var _0x5038ed={};_0x5038ed[_0x5cfc31]={'$like':'%'+_0x374b2f[_0xedf7('0x40')][_0xedf7('0x30')]+'%'};return _0x5038ed;})});}_0x1eb66f=_['merge']({},_0x1eb66f,_0x374b2f[_0xedf7('0x5d')]);return _0x4ddaa5[_0xedf7('0x14a')](_0x1eb66f);}})[_0xedf7('0x11')](function(_0x33b786){if(_0x33b786){_0x4daa05=_0x33b786['length'];if(!_0x374b2f[_0xedf7('0x40')][_0xedf7('0xd3')](_0xedf7('0xd8'))){_0x1eb66f['limit']=qs['limit'](_0x374b2f[_0xedf7('0x40')][_0xedf7('0x23')]);_0x1eb66f[_0xedf7('0x20')]=qs[_0xedf7('0x20')](_0x374b2f[_0xedf7('0x40')][_0xedf7('0x20')]);}return _0x4ddaa5['getChatWebsites'](_0x1eb66f);}})[_0xedf7('0x11')](function(_0x5156d6){if(_0x5156d6){return _0x5156d6?{'count':_0x4daa05,'rows':_0x5156d6}:null;}})['then'](respondWithResult(_0x5d8c39,null))['catch'](handleError(_0x5d8c39,null));};exports[_0xedf7('0x14b')]=function(_0x481e0f,_0x46c0e3){return db['User'][_0xedf7('0x62')]({'where':{'id':_0x481e0f[_0xedf7('0x55')]['id']}})[_0xedf7('0x11')](handleEntityNotFound(_0x46c0e3,null))[_0xedf7('0x11')](function(_0x5d94e0){if(_0x5d94e0){return _0x5d94e0[_0xedf7('0x14b')](_0x481e0f[_0xedf7('0x5f')]['ids'],_['omit'](_0x481e0f[_0xedf7('0x5f')],[_0xedf7('0x63'),'id'])||{});}})[_0xedf7('0x11')](respondWithResult(_0x46c0e3,null))[_0xedf7('0x5e')](handleError(_0x46c0e3,null));};exports['removeChatWebsites']=function(_0x4109a4,_0x5249a2){return db['User'][_0xedf7('0x62')]({'where':{'id':_0x4109a4['params']['id']}})['then'](handleEntityNotFound(_0x5249a2,null))['then'](function(_0x4db461){if(_0x4db461){return _0x4db461[_0xedf7('0x14c')](_0x4109a4['query'][_0xedf7('0x63')]);}})[_0xedf7('0x11')](respondWithStatusCode(_0x5249a2,null))[_0xedf7('0x5e')](handleError(_0x5249a2,null));};exports['getWhatsappAccounts']=function(_0x522cc4,_0x69c395){var _0xf322c9={};var _0xf16169={};var _0xf30e33;var _0x578d97;return db[_0xedf7('0x38')][_0xedf7('0x98')]({'where':{'id':_0x522cc4['params']['id']}})[_0xedf7('0x11')](handleEntityNotFound(_0x69c395,null))[_0xedf7('0x11')](function(_0x2085c3){if(_0x2085c3){_0xf30e33=_0x2085c3;_0xf16169[_0xedf7('0x5a')]=_['keys'](db[_0xedf7('0x14d')]['rawAttributes']);_0xf16169[_0xedf7('0x40')]=_[_0xedf7('0x57')](_0x522cc4[_0xedf7('0x40')]);_0xf16169['filters']=_[_0xedf7('0x59')](_0xf16169['model'],_0xf16169[_0xedf7('0x40')]);_0xf322c9[_0xedf7('0x45')]=_['intersection'](_0xf16169['model'],qs[_0xedf7('0x5b')](_0x522cc4[_0xedf7('0x40')]['fields']));_0xf322c9['attributes']=_0xf322c9[_0xedf7('0x45')][_0xedf7('0x4a')]?_0xf322c9[_0xedf7('0x45')]:_0xf16169[_0xedf7('0x5a')];_0xf322c9[_0xedf7('0xd0')]=qs[_0xedf7('0xd1')](_0x522cc4[_0xedf7('0x40')][_0xedf7('0xd1')]);_0xf322c9[_0xedf7('0x3f')]=qs['filters'](_[_0xedf7('0xdb')](_0x522cc4[_0xedf7('0x40')],_0xf16169[_0xedf7('0x58')]));if(_0x522cc4[_0xedf7('0x40')][_0xedf7('0x30')]){_0xf322c9['where']=_[_0xedf7('0xd2')](_0xf322c9['where'],{'$or':_[_0xedf7('0x31')](_0xf322c9[_0xedf7('0x45')],function(_0x28cce0){var _0x3da426={};_0x3da426[_0x28cce0]={'$like':'%'+_0x522cc4[_0xedf7('0x40')][_0xedf7('0x30')]+'%'};return _0x3da426;})});}_0xf322c9=_[_0xedf7('0xd2')]({},_0xf322c9,_0x522cc4[_0xedf7('0x5d')]);return _0xf30e33[_0xedf7('0x14e')](_0xf322c9);}})['then'](function(_0x4d985d){if(_0x4d985d){_0x578d97=_0x4d985d['length'];if(!_0x522cc4['query']['hasOwnProperty'](_0xedf7('0xd8'))){_0xf322c9[_0xedf7('0x23')]=qs[_0xedf7('0x23')](_0x522cc4[_0xedf7('0x40')][_0xedf7('0x23')]);_0xf322c9[_0xedf7('0x20')]=qs[_0xedf7('0x20')](_0x522cc4['query'][_0xedf7('0x20')]);}return _0xf30e33[_0xedf7('0x14e')](_0xf322c9);}})[_0xedf7('0x11')](function(_0x410f66){if(_0x410f66){return _0x410f66?{'count':_0x578d97,'rows':_0x410f66}:null;}})[_0xedf7('0x11')](respondWithResult(_0x69c395,null))[_0xedf7('0x5e')](handleError(_0x69c395,null));};exports[_0xedf7('0x14f')]=function(_0x2fa679,_0x46ebfb){return db['User'][_0xedf7('0x62')]({'where':{'id':_0x2fa679[_0xedf7('0x55')]['id']}})['then'](handleEntityNotFound(_0x46ebfb,null))['then'](function(_0x57356d){if(_0x57356d){return _0x57356d[_0xedf7('0x14f')](_0x2fa679[_0xedf7('0x5f')][_0xedf7('0x63')],_['omit'](_0x2fa679[_0xedf7('0x5f')],[_0xedf7('0x63'),'id'])||{});}})[_0xedf7('0x11')](respondWithResult(_0x46ebfb,null))[_0xedf7('0x5e')](handleError(_0x46ebfb,null));};exports[_0xedf7('0x150')]=function(_0x332119,_0x24f667){return db['User'][_0xedf7('0x62')]({'where':{'id':_0x332119['params']['id']}})[_0xedf7('0x11')](handleEntityNotFound(_0x24f667,null))[_0xedf7('0x11')](function(_0x2d78f0){if(_0x2d78f0){return _0x2d78f0[_0xedf7('0x150')](_0x332119[_0xedf7('0x40')][_0xedf7('0x63')]);}})[_0xedf7('0x11')](respondWithStatusCode(_0x24f667,null))[_0xedf7('0x5e')](handleError(_0x24f667,null));};exports['getScheduledCalls']=function(_0x59c8f8,_0x27424b){var _0x126cd9={},_0x42bd85={},_0x15ae57={'count':0x0,'rows':[]};var _0x1777cb=db[_0xedf7('0x151')]['rawAttributes'];_0x42bd85[_0xedf7('0x5a')]=_['keys'](_0x1777cb);_0x42bd85[_0xedf7('0x40')]=_['keys'](_0x59c8f8[_0xedf7('0x40')]);_0x42bd85[_0xedf7('0x58')]=_[_0xedf7('0x59')](_0x42bd85[_0xedf7('0x5a')],_0x42bd85[_0xedf7('0x40')]);_0x42bd85['filters']=_[_0xedf7('0xcd')](_0x42bd85['filters'],[_0xedf7('0x152'),_0xedf7('0x153'),_0xedf7('0x154'),_0xedf7('0x155'),'$lt',_0xedf7('0x156'),_0xedf7('0x157'),_0xedf7('0x158'),_0xedf7('0x159'),_0xedf7('0x15a'),_0xedf7('0x15b'),_0xedf7('0x15c'),'$notIn',_0xedf7('0x15d'),_0xedf7('0x15e'),_0xedf7('0x15f'),_0xedf7('0x160'),_0xedf7('0x15d'),'$overlap','$contains',_0xedf7('0x161'),_0xedf7('0x162')]);_0x126cd9[_0xedf7('0x45')]=_[_0xedf7('0x59')](_0x42bd85['model'],qs['fields'](_0x59c8f8[_0xedf7('0x40')][_0xedf7('0x5b')]));_0x126cd9[_0xedf7('0x45')]=_0x126cd9[_0xedf7('0x45')][_0xedf7('0x4a')]?_0x126cd9[_0xedf7('0x45')]:_0x42bd85[_0xedf7('0x5a')];if(!_0x59c8f8['query'][_0xedf7('0xd3')](_0xedf7('0xd8'))){_0x126cd9[_0xedf7('0x23')]=qs[_0xedf7('0x23')](_0x59c8f8[_0xedf7('0x40')][_0xedf7('0x23')]);_0x126cd9[_0xedf7('0x20')]=qs['offset'](_0x59c8f8[_0xedf7('0x40')][_0xedf7('0x20')]);}_0x126cd9['order']=qs[_0xedf7('0xd1')](_0x59c8f8['query'][_0xedf7('0xd1')]);_0x126cd9['where']=qs[_0xedf7('0x58')](_['pick'](_0x59c8f8[_0xedf7('0x40')],_0x42bd85['filters']));if(_0x59c8f8[_0xedf7('0x40')][_0xedf7('0x30')]){_0x126cd9['where']=_[_0xedf7('0xd2')](_0x126cd9[_0xedf7('0x3f')],{'$or':_[_0xedf7('0x31')](_0x126cd9[_0xedf7('0x45')],function(_0x179300){var _0x51b653={};_0x51b653[_0x179300]={'$like':'%'+_0x59c8f8[_0xedf7('0x40')]['filter']+'%'};return _0x51b653;})});}_0x126cd9[_0xedf7('0x3f')]={'$and':[_0x126cd9[_0xedf7('0x3f')],{'$or':[{'UserId':_0x59c8f8[_0xedf7('0x55')]['id']},{'OwnerId':_0x59c8f8['params']['id']}]}]};_0x126cd9=_[_0xedf7('0xd2')]({},_0x126cd9,_0x59c8f8[_0xedf7('0x5d')]);var _0x575360={'where':_0x126cd9[_0xedf7('0x3f')]};return db[_0xedf7('0x151')][_0xedf7('0x22')](_0x575360)['then'](function(_0xa006f2){_0x15ae57['count']=_0xa006f2;if(_0x59c8f8[_0xedf7('0x40')][_0xedf7('0x41')]){_0x126cd9[_0xedf7('0x42')]=[{'attributes':['id',_0xedf7('0x163'),_0xedf7('0x164'),_0xedf7('0x165')],'model':db[_0xedf7('0xcf')],'as':_0xedf7('0x166')},{'attributes':['id',_0xedf7('0x35'),_0xedf7('0x167')],'model':db[_0xedf7('0x168')],'as':'Queue'}];}return db[_0xedf7('0x151')][_0xedf7('0x46')](_0x126cd9);})[_0xedf7('0x11')](function(_0x4c56d3){_0x15ae57['rows']=_0x4c56d3;return _0x15ae57;})['then'](respondWithFilteredResult(_0x27424b,_0x126cd9))[_0xedf7('0x5e')](handleError(_0x27424b,null));};exports[_0xedf7('0x169')]=function(_0x37b661,_0x58a411){if(!_[_0xedf7('0x67')](_0x37b661[_0xedf7('0x2e')]['id'])&&(_0x37b661[_0xedf7('0x2e')][_0xedf7('0x2b')]==_0xedf7('0x2c')||_0x37b661[_0xedf7('0x2e')][_0xedf7('0x2b')]==_0xedf7('0x2e'))){return db[_0xedf7('0x38')][_0xedf7('0x98')]({'where':{'id':_0x37b661[_0xedf7('0x55')]['id']},'raw':!![]})[_0xedf7('0x11')](function(_0x1ff1fa){return authService[_0xedf7('0x16a')](_0x1ff1fa);})[_0xedf7('0x11')](function(_0x52bc15){if(_0x52bc15){return _0x58a411['status'](0xc8)[_0xedf7('0x1f')]({'api_key':_0x52bc15[_0xedf7('0x16b')]});}else{return _0x58a411[_0xedf7('0x1e')](0xcc)['json']({'message':_0xedf7('0x16c')});}})[_0xedf7('0x5e')](handleError(_0x58a411,0x193));}else{return _0x58a411['status'](0x191)[_0xedf7('0x1f')]({'message':_0xedf7('0x16d')});}};exports['createApiKey']=function(_0x1890e6,_0x18c41b){if(!_[_0xedf7('0x67')](_0x1890e6[_0xedf7('0x2e')]['id'])&&(_0x1890e6[_0xedf7('0x2e')][_0xedf7('0x2b')]=='admin'||_0x1890e6[_0xedf7('0x2e')][_0xedf7('0x2b')]==_0xedf7('0x2e'))){return db[_0xedf7('0x38')][_0xedf7('0x62')]({'where':{'id':_0x1890e6[_0xedf7('0x55')]['id']}})['then'](function(_0x100774){return authService[_0xedf7('0x16e')](_0x100774);})[_0xedf7('0x11')](function(_0x4ac9de){return db[_0xedf7('0x38')][_0xedf7('0x25')]({'apiKeyIat':_0x4ac9de[_0xedf7('0x16f')],'apiKeyNonce':_0x4ac9de[_0xedf7('0x170')]},{'where':{'id':_0x1890e6['params']['id']}})[_0xedf7('0x11')](function(){return _0x18c41b[_0xedf7('0x1e')](0xc8)[_0xedf7('0x1f')]({'api_key':_0x4ac9de[_0xedf7('0x16b')]});});})[_0xedf7('0x5e')](handleError(_0x18c41b,0x193));}else{return _0x18c41b[_0xedf7('0x1e')](0x191)[_0xedf7('0x1f')]({'message':'You\x20don\x27t\x20have\x20sufficient\x20privileges\x20to\x20access\x20this\x20resource.'});}};exports[_0xedf7('0x171')]=function(_0x1bb357,_0x870095){if(!_[_0xedf7('0x67')](_0x1bb357[_0xedf7('0x2e')]['id'])&&(_0x1bb357[_0xedf7('0x2e')][_0xedf7('0x2b')]==_0xedf7('0x2c')||_0x1bb357['user'][_0xedf7('0x2b')]==_0xedf7('0x2e'))){return db[_0xedf7('0x38')]['find']({'where':{'id':_0x1bb357[_0xedf7('0x55')]['id']}})[_0xedf7('0x11')](handleEntityNotFound(_0x870095,null))[_0xedf7('0x11')](function(_0x4688fe){if(_0x4688fe&&_0x4688fe[_0xedf7('0x172')]&&_0x4688fe[_0xedf7('0x173')])return _0x4688fe;else throw{'message':_0xedf7('0x174')};})['then'](function(){return db['User'][_0xedf7('0x25')]({'apiKeyNonce':null,'apiKeyIat':null},{'where':{'id':_0x1bb357[_0xedf7('0x55')]['id']}});})['then'](respondWithStatusCode(_0x870095,0xc8))[_0xedf7('0x5e')](handleError(_0x870095,0x193));}else{return _0x870095['status'](0x191)[_0xedf7('0x1f')]({'message':'You\x20don\x27t\x20have\x20sufficient\x20privileges\x20to\x20access\x20this\x20resource.'});}};exports['whoami']=function(_0x4d1c3d,_0x4ad85a){var _0x44952e=_0x4d1c3d[_0xedf7('0x2e')][_0xedf7('0x2a')]({'plain':!![]});if(!_0x44952e){return _0x4ad85a[_0xedf7('0x1e')](0x191)[_0xedf7('0x36')](_0xedf7('0x175'));}else{Promise['resolve']()[_0xedf7('0x11')](function(){if(_0x4d1c3d['query'][_0xedf7('0x43')]!=='true')return;return _0x4d1c3d[_0xedf7('0x2e')]['getUserSetting']();})[_0xedf7('0x11')](function(_0x1423cc){if(!_0x1423cc)return;return _0x1423cc['get']({'plain':!![]});})[_0xedf7('0x11')](function(_0x55ec89){_0x44952e[_0xedf7('0x43')]=_0x55ec89;return _0x4ad85a['status'](0xc8)['json'](_0x44952e);});}};exports[_0xedf7('0x176')]=function(_0x56085f,_0x351587){var _0x4d83bc={'offset':0x0},_0x32e2da={'count':0x0,'rows':[]};Promise[_0xedf7('0x10f')]()[_0xedf7('0x11')](function(){if(!_0x56085f[_0xedf7('0x40')][_0xedf7('0x30')]&&!_0x56085f['query']['teams']&&!_0x56085f[_0xedf7('0x40')][_0xedf7('0x177')])return[];return Promise['resolve']()[_0xedf7('0x11')](function(){var _0x1c3bff=[];if(!_[_0xedf7('0x8d')](_0x56085f['query'][_0xedf7('0x178')])){_0x1c3bff[_0xedf7('0x4b')](db[_0xedf7('0x114')][_0xedf7('0x46')]({'attributes':['id',_0xedf7('0x35')],'where':{'id':_0x56085f[_0xedf7('0x40')][_0xedf7('0x178')]}}));}if(!_['isEmpty'](_0x56085f['query']['queues'])){_0x1c3bff[_0xedf7('0x4b')](db[_0xedf7('0x168')][_0xedf7('0x46')]({'attributes':['id',_0xedf7('0x35')],'type':_0xedf7('0x179'),'where':{'id':_0x56085f[_0xedf7('0x40')][_0xedf7('0x177')]}}));}return Promise['all'](_0x1c3bff);})[_0xedf7('0x11')](function(_0x3af94c){var _0x4a2018=_[_0xedf7('0x17a')](_0x3af94c)[_0xedf7('0x31')](function(_0x1fc089){return _0x1fc089[_0xedf7('0x11f')]({'attributes':['id',_0xedf7('0x35'),'internal',_0xedf7('0xa1')],'raw':!![]});});return Promise[_0xedf7('0x53')](_0x4a2018);})[_0xedf7('0x11')](function(_0x4d1396){var _0x3fe7bb=_[_0xedf7('0x17a')](_0x4d1396);if(!_0x56085f[_0xedf7('0x40')][_0xedf7('0x30')])return _0x3fe7bb;if(_[_0xedf7('0x8d')](_0x3fe7bb)){return db['User'][_0xedf7('0x46')]({'attributes':['id',_0xedf7('0x35'),'internal',_0xedf7('0xa1')],'where':{'role':'agent','$or':[db[_0xedf7('0x69')][_0xedf7('0x3f')](db['sequelize']['fn'](_0xedf7('0x17b'),db['sequelize'][_0xedf7('0x17c')]('name')),{'$like':'%'+_0x56085f[_0xedf7('0x40')]['filter'][_0xedf7('0xac')]()+'%'}),{'internal':{'$like':'%'+_0x56085f['query'][_0xedf7('0x30')]+'%'}}]},'raw':!![]});}else{return _(_0x3fe7bb)[_0xedf7('0x17a')]()[_0xedf7('0x30')](function(_0x168b3a){return _0x168b3a[_0xedf7('0x35')][_0xedf7('0xac')]()[_0xedf7('0x44')](_0x56085f[_0xedf7('0x40')][_0xedf7('0x30')]['toLowerCase']())||_0x168b3a['internal']['toString']()['includes'](_0x56085f[_0xedf7('0x40')][_0xedf7('0x30')]);})[_0xedf7('0x32')]();}})['then'](function(_0xf7b8e4){var _0x2e18ab=_0xedf7('0x35');var _0x2ee5ea=_0xedf7('0x17d');if(_0x56085f['query'][_0xedf7('0xd1')]){_0x2ee5ea=_0x56085f['query'][_0xedf7('0xd1')][0x0]==='-'?_0xedf7('0x17e'):_0xedf7('0x17d');_0x2e18ab=_0x2ee5ea===_0xedf7('0x17d')?_0x56085f[_0xedf7('0x40')][_0xedf7('0xd1')]:_0x56085f[_0xedf7('0x40')][_0xedf7('0xd1')][_0xedf7('0x17f')](0x1);}return _(_0xf7b8e4)[_0xedf7('0x180')]('id')[_0xedf7('0x181')]([function(_0xa1e4b6){return _0x2e18ab===_0xedf7('0x35')?_0xa1e4b6[_0x2e18ab][_0xedf7('0xac')]():_0xa1e4b6[_0x2e18ab];}],[_0x2ee5ea])[_0xedf7('0x31')](function(_0x2e4853){return _[_0xedf7('0xdb')](_0x2e4853,['id',_0xedf7('0x35'),'internal',_0xedf7('0xa1')]);})[_0xedf7('0x32')]();})['then'](function(_0x4a136d){return amiClient[_0xedf7('0x10')](_0xedf7('0x90'),_0x56085f)[_0xedf7('0x11')](function(_0xab7dbe){if(_0xab7dbe[_0xedf7('0x18')])throw new Error('Unable\x20to\x20retrieve\x20RPC\x20agents\x20(AMI)');var _0x1e5f6c=_0xab7dbe[_0xedf7('0x1b')];var _0x2f4f35=jayson['client']['http']({'port':0x232c});return _0x2f4f35['request'](_0xedf7('0x90'),_0x56085f)['then'](function(_0x295219){if(_0x295219[_0xedf7('0x18')])throw new Error(_0xedf7('0x182'));var _0x51b4c8=_0x295219['result'];return _[_0xedf7('0xd2')]({},_0x51b4c8,_0x1e5f6c);});})[_0xedf7('0x11')](function(_0x36f0b5){return _[_0xedf7('0x31')](_0x4a136d,function(_0x5a014b){var _0x58a8eb=_[_0xedf7('0x62')](_0x36f0b5[_0xedf7('0x47')],['id',_0x5a014b['id']]);if(!_0x58a8eb||!_0x5a014b[_0xedf7('0xa1')]){_0x5a014b[_0xedf7('0x1e')]=_0xedf7('0x183');}else if(_0x58a8eb[_0xedf7('0xa3')]){_0x5a014b[_0xedf7('0x1e')]=_0xedf7('0x103');}else{_0x5a014b[_0xedf7('0x1e')]=_[_0xedf7('0x44')](['idle',_0xedf7('0x184'),_0xedf7('0x185'),_0xedf7('0x186'),null,undefined],_0x58a8eb[_0xedf7('0x187')])?_0xedf7('0xa1'):_0xedf7('0x188');}return _0x5a014b;});});});})[_0xedf7('0x11')](function(_0x3ff8d1){if(!_0x56085f['query'][_0xedf7('0xd3')](_0xedf7('0xd8'))){_0x4d83bc[_0xedf7('0x23')]=qs[_0xedf7('0x23')](_0x56085f[_0xedf7('0x40')][_0xedf7('0x23')]||0xa);_0x4d83bc[_0xedf7('0x20')]=qs[_0xedf7('0x20')](_0x56085f[_0xedf7('0x40')]['offset']);}_0x32e2da['count']=_0x3ff8d1[_0xedf7('0x4a')];_0x32e2da[_0xedf7('0x47')]=_0x4d83bc[_0xedf7('0x23')]?_0x3ff8d1['slice'](_0x4d83bc['offset'],_0x4d83bc['offset']+_0x4d83bc[_0xedf7('0x23')]):_0x3ff8d1;return _0x32e2da;})[_0xedf7('0x11')](respondWithFilteredResult(_0x351587,_0x4d83bc))[_0xedf7('0x5e')](handleError(_0x351587,null));};function get_open_tabs(_0x1d2ee8,_0x45ba2c){var _0x473171=_0x1d2ee8[_0xedf7('0x189')](0x0)[_0xedf7('0x18a')]()+_0x1d2ee8['slice'](0x1);var _0x3134a9={'type':db[_0xedf7('0x95')]['QueryTypes'][_0xedf7('0x6c')],'raw':!![]};return new Promise(function(_0x295280,_0x399b07){var _0x46fcaf=squel[_0xedf7('0x18b')]()['field'](_0xedf7('0x18c')+_0x473171+_0xedf7('0x18d'),'id')[_0xedf7('0x18e')](_0xedf7('0x18f'))['from'](_0xedf7('0x190')+_0x1d2ee8+_0xedf7('0x191'),'ui')[_0xedf7('0x3f')](_0xedf7('0x192'),_0x45ba2c['id']);return db['sequelize'][_0xedf7('0x40')](_0x46fcaf[_0xedf7('0x193')](),_0x3134a9)[_0xedf7('0x11')](function(_0x8bd860){_0x45ba2c[_0x473171+_0xedf7('0x194')]=_0x8bd860;_0x295280(_0x8bd860);})[_0xedf7('0x5e')](function(_0x2d2c09){_0x399b07(_0x2d2c09);});});}
\ No newline at end of file
+var _0x893d=['user_has_chat_interactions:remove','addMailInteractions','user_has_mail_interactions:save','removeMailInteractions','user_has_mail_interactions:remove','addFaxInteractions','user_has_fax_interactions:save','removeFaxInteractions','user_has_fax_interactions:remove','addSmsInteractions','removeSmsInteractions','user_has_sms_interactions:remove','addOpenchannelInteractions','removeOpenchannelInteractions','user_has_openchannel_interactions:remove','addWhatsappInteractions','removeWhatsappInteractions','getVoicePrefixes','VoicePrefix','getFaxAccounts','FaxAccount','addFaxAccounts','removeFaxAccounts','MailAccount','getMailAccounts','addMailAccounts','removeMailAccounts','getOpenchannelAccounts','addOpenchannelAccounts','removeOpenchannelAccounts','SmsAccount','getSmsAccounts','addSmsAccounts','removeSmsAccounts','getChatWebsites','addChatWebsites','removeChatWebsites','getWhatsappAccounts','WhatsappAccount','addWhatsappAccounts','removeWhatsappAccounts','CmHopper','$and','$gt','$gte','$lt','$lte','$ne','$eq','$between','$notBetween','$in','$notIn','$like','$notLike','$iLike','$notILike','$contains','$contained','$any','firstName','lastName','CmContact','getApiKey','retrieveApiKey','token','No\x20API\x20access\x20key\x20found!','You\x20don\x27t\x20have\x20sufficient\x20privileges\x20to\x20access\x20this\x20resource.','createApiKey','iat','removeApiKey','apiKeyIat','whoami','getUserSetting','getPresence','idle','unknown','ringing','teams','inbound','flatten','toString','desc','asc','substring','uniqBy','orderBy','getRealtimeAgents','voiceStatus','unavailable','slice','charAt','toUpperCase','select','field','ui.','InteractionId','ui.createdAt','user_has_','_interactions','ui.UserId\x20=\x20?','OpenTabs','messengerSoundNotification','moment','util','path','lodash','squel','ioredis','../../components/auth/service','../../components/contacts','../../components/parsers/qs','../../components/realtime/agents','../../config/logger','api','../../config/utils','APIBadRequestError','APINotFoundError','../../errors/api','../../mysqldb','./user.socket','register','redis','defaults','sendStatus','end','status','json','offset','undefined','count','limit','set','Content-Range','update','then','agent','emit','userNotification:recalc:','destroy','get','admin','user','filter','ignore','map','value','includes','find','role','name','stack','send','User','rawAttributes','fieldName','key','password','salt','previousPasswords','resetPasswordToken','md5secret','index','query','include','true','UserSetting','userSetting','attributes','push','findAll','openTabs','rows','chat','sms','dataValues','fax','mail','whatsapp','all','catch','show','params','getOptions','includeAll','merge','options','openchannel','body','describe','addContacts','omit','internal','findById','securePassword','validatePasswordPattern','max','isNil','min_internal','sequelize','QueryTypes','SELECT','length','from','voicemail','mailbox','VoiceMail','email','permissions','101','103','110','104','106','107','108','109','100','114','create','Unauthorized','Unauthorized.\x20You\x20must\x20be\x20an\x20administrator\x20in\x20order\x20to\x20create\x20an\x20user','Unauthorized.\x20You\x20must\x20be\x20an\x20administrator\x20in\x20order\x20to\x20create\x20another\x20administrator','checkUserLimits','settingsEnabled','userProfileId','UserProfileSection','Agents','Telephones','autoAssociation','UserProfileResource','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','bulkCreate','some','telephone','isEmpty','oldPassword','newPassword','Sequelize','ValidationError','Invalid\x20body\x20format.\x20Use\x20oldPassword\x20and\x20newPassword','Wrong\x20credentials','New\x20password\x20must\x20be\x20different\x20from\x20old\x20password','Invalid\x20body\x20format.\x20Use\x20newPassword','Setting','enforcePasswordHistory','passwordHistoryLimit','validatePasswordHistory','updatePasswordsHistory','channel','loginInPause','voicePause','interface','isValidChannel','capitalize','toLowerCase','penalty','spread','ids','QueueId','voice','VoiceQueue','online','format','upsert','removeQueues','remove','Queues','isArray','Queue:remove','UserVoiceQueueRt','addAvatar','userpic','filename','getAvatar','join','root','server/files/images/logos/default_profile.png','download','server/files/images/','getOpenTabs','ChatOpenTabs','CHAT','createdAt','FaxOpenTabs','FAX','OpenchannelOpenTabs','OPENCHANNEL','MailOpenTabs','MAIL','SmsOpenTabs','WhatsappOpenTabs','WHATSAPP','concat','getContacts','findOne','hasOwnProperty','CmList','List','color','tag','Unknown\x20channel','model','keys','Queue','filters','intersection','fields','order','sort','where','pick','Unknown\x20role','nolimit','getVoiceQueuesRt','getGroups','getRecordings','VoiceRecording','UserId','ScreenRecording','getChatInteractions','ChatInteraction','OpenchannelInteraction','getOpenchannelInteractions','MailInteraction','getSmsInteractions','SmsInteraction','getFaxInteractions','FaxInteraction','getWhatsappInteractions','WhatsappInteraction','phone','mobile','LOCAL/%s@from-sip/n','intrf','user:forcelogout','headers','connection','socket','remoteAddress','User\x20not\x20found\x20or\x20not\x20allowed\x20to\x20perform\x20login\x20method','getVoiceQueues','MemberReport','forEach','YYYY-MM-DD\x20HH:mm:ss','getChannels','device','PAUSE','LOGININPAUSE','isMiddleware','resolve','logout','pause','SIP/%s','type','DEFAULT\x20PAUSE','unpause','mailPause','faxPause','openchannelPause','whatsappPause','pauseType','lastPauseAt','User\x20with\x20id\x20%s\x20not\x20found','getTeams','Team','addTeams','transaction','flattenDeep','TeamVoicePrefix','UserVoicePrefix','VoicePrefixId','removeTeams','Query\x20parameter\x20\x27ids\x27\x20is\x20required','getAssociatedQueues','removeAgent','getDataValue','getLists','getAgents','values','You\x20can\x27t\x20delete\x20yourself','addChatInteractions','user_has_chat_interactions:save','removeChatInteractions'];(function(_0x3c6125,_0x3b2a9c){var _0x2f47b8=function(_0x214650){while(--_0x214650){_0x3c6125['push'](_0x3c6125['shift']());}};_0x2f47b8(++_0x3b2a9c);}(_0x893d,0x67));var _0xd893=function(_0x22aa69,_0x469edf){_0x22aa69=_0x22aa69-0x0;var _0x54adc7=_0x893d[_0x22aa69];return _0x54adc7;};'use strict';var moment=require(_0xd893('0x0'));var util=require(_0xd893('0x1'));var path=require(_0xd893('0x2'));var fs=require('fs');var _=require(_0xd893('0x3'));var squel=require(_0xd893('0x4'));var Redis=require(_0xd893('0x5'));var authService=require(_0xd893('0x6'));var contacts=require(_0xd893('0x7'));var qs=require(_0xd893('0x8'));var rta=require(_0xd893('0x9'));var logger=require(_0xd893('0xa'))(_0xd893('0xb'));var utils=require(_0xd893('0xc'));var config=require('../../config/environment');var licenseUtil=require('../../config/license/util');var APIBadRequestError=require('../../errors/api')[_0xd893('0xd')];var APINotFoundError=require('../../errors/api')[_0xd893('0xe')];var APIHandleError=require(_0xd893('0xf'))['handleError'];var db=require(_0xd893('0x10'))['db'];var socket=require('socket.io-emitter')(new Redis(config['redis']));require(_0xd893('0x11'))[_0xd893('0x12')](socket);config[_0xd893('0x13')]=_[_0xd893('0x14')](config[_0xd893('0x13')],{'host':'localhost','port':0x18eb});var values;function respondWithStatusCode(_0x27f2ea,_0x3c1185){_0x3c1185=_0x3c1185||0xcc;return function(_0x5107a1){if(_0x5107a1){return _0x27f2ea[_0xd893('0x15')](_0x3c1185);}return _0x27f2ea['status'](_0x3c1185)[_0xd893('0x16')]();};}function respondWithResult(_0x23c40f,_0x25b8dd){_0x25b8dd=_0x25b8dd||0xc8;return function(_0x252ca7){if(_0x252ca7){return _0x23c40f[_0xd893('0x17')](_0x25b8dd)[_0xd893('0x18')](_0x252ca7);}};}function respondWithFilteredResult(_0x218c45,_0x544d4a){return function(_0x53d270){if(_0x53d270){var _0x49472f=typeof _0x544d4a[_0xd893('0x19')]===_0xd893('0x1a')&&typeof _0x544d4a['limit']===_0xd893('0x1a');var _0x1079e9=_0x53d270[_0xd893('0x1b')];var _0x42458a=_0x49472f?0x0:_0x544d4a[_0xd893('0x19')];var _0xd2f312=_0x49472f?_0x53d270[_0xd893('0x1b')]:_0x544d4a[_0xd893('0x19')]+_0x544d4a[_0xd893('0x1c')];var _0x1a52af;if(_0xd2f312>=_0x1079e9){_0xd2f312=_0x1079e9;_0x1a52af=0xc8;}else{_0x1a52af=0xce;}_0x218c45['status'](_0x1a52af);return _0x218c45[_0xd893('0x1d')](_0xd893('0x1e'),_0x42458a+'-'+_0xd2f312+'/'+_0x1079e9)[_0xd893('0x18')](_0x53d270);}return null;};}function saveUpdates(_0x203e13){return function(_0x5f1c03){if(_0x5f1c03){return _0x5f1c03[_0xd893('0x1f')](_0x203e13)[_0xd893('0x20')](function(_0x556579){if(_0x556579['role']===_0xd893('0x21')){socket[_0xd893('0x22')](_0xd893('0x23')+_0x556579['id'],_0x556579);}return _0x556579;});}return null;};}function removeEntity(_0x1c6df9){return function(_0x5b81f8){if(_0x5b81f8){return _0x5b81f8[_0xd893('0x24')]()[_0xd893('0x20')](function(){var _0x5dc36e=_0x5b81f8[_0xd893('0x25')]({'plain':!![]});if(_0x5dc36e['role']===_0xd893('0x26'))return;var _0x45295a=[{'name':'Users','value':_0xd893('0x27'),'ignore':!![]},{'name':'Agents','value':_0xd893('0x21'),'ignore':![]},{'name':'Telephones','value':'telephone','ignore':![]}];var _0x61e883=_(_0x45295a)[_0xd893('0x28')](_0xd893('0x29'))[_0xd893('0x2a')](_0xd893('0x2b'))['value']();if(_[_0xd893('0x2c')](_0x61e883,_0x5dc36e['role'])){return;}var _0x271368=_[_0xd893('0x2d')](_0x45295a,['value',_0x5dc36e[_0xd893('0x2e')]])[_0xd893('0x2f')];return db['UserProfileResource'][_0xd893('0x24')]({'where':{'type':_0x271368,'resourceId':_0x5dc36e['id']}})['then'](function(){return _0x5b81f8;});})[_0xd893('0x20')](function(){_0x1c6df9[_0xd893('0x17')](0xcc)[_0xd893('0x16')]();});}};}function handleEntityNotFound(_0x56997c){return function(_0x229d58){if(!_0x229d58){_0x56997c[_0xd893('0x15')](0x194);}return _0x229d58;};}function handleError(_0x5be3a5,_0x2c18d4){_0x2c18d4=_0x2c18d4||0x1f4;return function(_0xb8bd4a){logger['error'](_0xb8bd4a[_0xd893('0x30')]);if(_0xb8bd4a[_0xd893('0x2f')]){delete _0xb8bd4a[_0xd893('0x2f')];}_0x5be3a5[_0xd893('0x17')](_0x2c18d4)[_0xd893('0x31')](_0xb8bd4a);};}function getUserAttributes(){return _(db[_0xd893('0x32')][_0xd893('0x33')])[_0xd893('0x2a')](function(_0xa42dc3){return{'name':_0xa42dc3[_0xd893('0x34')],'type':_0xa42dc3['type'][_0xd893('0x35')]};})[_0xd893('0x28')](function(_0x56eeb1){return![_0xd893('0x36'),_0xd893('0x37'),_0xd893('0x38'),_0xd893('0x39'),'resetPasswordExpires',_0xd893('0x3a')][_0xd893('0x2c')](_0x56eeb1[_0xd893('0x2f')]);})[_0xd893('0x2b')]();}exports[_0xd893('0x3b')]=function(_0x420fce,_0x140a76){var _0x51a90e={},_0x28be51={'count':0x0,'rows':[]};var _0x5000cb=getUserAttributes();_0x51a90e=qs['getOptions'](_0x5000cb,_0x420fce);var _0x577955={'where':_0x51a90e['where']};return db[_0xd893('0x32')][_0xd893('0x1b')](_0x577955)[_0xd893('0x20')](function(_0x2f79ce){_0x28be51[_0xd893('0x1b')]=_0x2f79ce;if(_0x420fce[_0xd893('0x3c')]['includeAll']){_0x51a90e[_0xd893('0x3d')]=[{'all':!![]}];}if(_0x420fce['query']['userSetting']===_0xd893('0x3e')){_0x51a90e[_0xd893('0x3d')]=[{'model':db[_0xd893('0x3f')],'as':_0xd893('0x40')}];}if(!_['includes'](_0x51a90e[_0xd893('0x41')],'id')){_0x51a90e['attributes'][_0xd893('0x42')]('id');}return db[_0xd893('0x32')][_0xd893('0x43')](_0x51a90e);})[_0xd893('0x20')](function(_0x41ea64){_0x28be51['rows']=_0x41ea64;if(_0x420fce[_0xd893('0x3c')][_0xd893('0x44')]===_0xd893('0x3e')){var _0x5a9e1c=[];for(var _0x410093=0x0;_0x410093<_0x28be51[_0xd893('0x45')]['length'];_0x410093++){_0x5a9e1c['push'](get_open_tabs(_0xd893('0x46'),_0x28be51[_0xd893('0x45')][_0x410093]['dataValues']));_0x5a9e1c['push'](get_open_tabs(_0xd893('0x47'),_0x28be51[_0xd893('0x45')][_0x410093][_0xd893('0x48')]));_0x5a9e1c[_0xd893('0x42')](get_open_tabs(_0xd893('0x49'),_0x28be51[_0xd893('0x45')][_0x410093][_0xd893('0x48')]));_0x5a9e1c[_0xd893('0x42')](get_open_tabs(_0xd893('0x4a'),_0x28be51[_0xd893('0x45')][_0x410093]['dataValues']));_0x5a9e1c['push'](get_open_tabs('openchannel',_0x28be51['rows'][_0x410093][_0xd893('0x48')]));_0x5a9e1c['push'](get_open_tabs(_0xd893('0x4b'),_0x28be51[_0xd893('0x45')][_0x410093][_0xd893('0x48')]));}return Promise[_0xd893('0x4c')](_0x5a9e1c)[_0xd893('0x20')](function(){return _0x28be51;});}else{return _0x28be51;}})['then'](respondWithFilteredResult(_0x140a76,_0x51a90e))[_0xd893('0x4d')](handleError(_0x140a76,null));};exports[_0xd893('0x4e')]=function(_0x5c7c12,_0xf782e8){var _0x1562c6=getUserAttributes();_0x5c7c12[_0xd893('0x3c')]['id']=_0x5c7c12[_0xd893('0x4f')]['id'];var _0x227847=qs[_0xd893('0x50')](_0x1562c6,_0x5c7c12);if(_0x5c7c12[_0xd893('0x3c')][_0xd893('0x51')]){_0x227847[_0xd893('0x3d')]=[{'all':!![]}];}if(_0x5c7c12[_0xd893('0x3c')][_0xd893('0x40')]===_0xd893('0x3e')){_0x227847[_0xd893('0x3d')]=[{'model':db[_0xd893('0x3f')],'as':_0xd893('0x40')}];}_0x227847=_[_0xd893('0x52')]({},_0x227847,_0x5c7c12[_0xd893('0x53')]);if(!_[_0xd893('0x2c')](_0x227847[_0xd893('0x41')],'id')){_0x227847[_0xd893('0x41')][_0xd893('0x42')]('id');}return db[_0xd893('0x32')]['find'](_0x227847)['then'](handleEntityNotFound(_0xf782e8,null))[_0xd893('0x20')](function(_0x123450){var _0x27a827=[];values=_0x123450;if(_0x5c7c12[_0xd893('0x3c')][_0xd893('0x44')]===_0xd893('0x3e')){_0x27a827[_0xd893('0x42')](get_open_tabs('chat',_0x123450[_0xd893('0x48')]));_0x27a827[_0xd893('0x42')](get_open_tabs(_0xd893('0x47'),_0x123450[_0xd893('0x48')]));_0x27a827[_0xd893('0x42')](get_open_tabs(_0xd893('0x54'),_0x123450['dataValues']));_0x27a827[_0xd893('0x42')](get_open_tabs(_0xd893('0x4b'),_0x123450[_0xd893('0x48')]));_0x27a827[_0xd893('0x42')](get_open_tabs(_0xd893('0x49'),_0x123450[_0xd893('0x48')]));_0x27a827[_0xd893('0x42')](get_open_tabs(_0xd893('0x4a'),_0x123450[_0xd893('0x48')]));return Promise[_0xd893('0x4c')](_0x27a827);}else{return values;}})[_0xd893('0x20')](function(){return values;})[_0xd893('0x20')](respondWithResult(_0xf782e8,null))['catch'](handleError(_0xf782e8,null));};exports[_0xd893('0x1f')]=function(_0x5bee59,_0x15e9ab){if(_0x5bee59[_0xd893('0x55')]['id']){delete _0x5bee59[_0xd893('0x55')]['id'];}delete _0x5bee59[_0xd893('0x55')]['role'];return db['User'][_0xd893('0x2d')]({'where':{'id':_0x5bee59[_0xd893('0x4f')]['id']}})[_0xd893('0x20')](handleEntityNotFound(_0x15e9ab,null))[_0xd893('0x20')](saveUpdates(_0x5bee59[_0xd893('0x55')],null))[_0xd893('0x20')](respondWithResult(_0x15e9ab,null))['catch'](handleError(_0x15e9ab,null));};exports[_0xd893('0x56')]=function(_0x4dfe19,_0xa8213a){return db[_0xd893('0x32')][_0xd893('0x56')]()[_0xd893('0x20')](respondWithResult(_0xa8213a,null))[_0xd893('0x4d')](handleError(_0xa8213a,null));};exports[_0xd893('0x57')]=function(_0x1b7f32,_0x519ca5){return db['User'][_0xd893('0x2d')]({'where':{'id':_0x1b7f32['params']['id']}})['then'](handleEntityNotFound(_0x519ca5,null))[_0xd893('0x20')](function(_0x541e6e){if(_0x541e6e){return _0x541e6e[_0xd893('0x57')](_0x1b7f32[_0xd893('0x55')]['ids'],_[_0xd893('0x58')](_0x1b7f32[_0xd893('0x55')],['ids','id'])||{});}})[_0xd893('0x20')](respondWithResult(_0x519ca5,null))['catch'](handleError(_0x519ca5,null));};function validateUser(_0x184741){return new Promise(function(_0x159655,_0x12ef53){if(_0x184741[_0xd893('0x59')])return _0x159655(_0x184741);return db['Setting'][_0xd893('0x5a')](0x1)[_0xd893('0x20')](function(_0x59d3f9){if(_0x59d3f9[_0xd893('0x5b')])authService[_0xd893('0x5c')](_0x184741[_0xd893('0x36')]);db[_0xd893('0x32')][_0xd893('0x5d')](_0xd893('0x59'))[_0xd893('0x20')](function(_0x338e5e){if(_[_0xd893('0x5e')](_0x338e5e)){_0x184741[_0xd893('0x59')]=_0x59d3f9[_0xd893('0x5f')]||0x1;return;}if(_[_0xd893('0x5e')](_0x59d3f9[_0xd893('0x5f')])||_0x59d3f9['min_internal']===_0x338e5e){_0x184741[_0xd893('0x59')]=_0x338e5e+0x1;return;}if(_0x59d3f9[_0xd893('0x5f')]>_0x338e5e){_0x184741[_0xd893('0x59')]=_0x59d3f9[_0xd893('0x5f')];return;}return db[_0xd893('0x60')][_0xd893('0x3c')]('select\x20(select\x20IFNULL(max(internal)+1,1)\x20from\x20users\x20where\x20internal\x20<\x20md.internal)\x20as\x20\x27from\x27,\x20md.internal\x20-\x201\x20as\x20\x27to\x27\x20from\x20users\x20md\x20where\x20md.internal\x20!=\x201\x20and\x20not\x20exists\x20(select\x201\x20from\x20users\x20md2\x20where\x20md2.internal\x20=\x20md.internal\x20-\x201)',{'type':db[_0xd893('0x60')][_0xd893('0x61')][_0xd893('0x62')]})['then'](function(_0x2c81c1){if(_0x2c81c1&&_0x2c81c1[_0xd893('0x63')]){for(var _0x3adfd5=0x0,_0x11f036=_0x2c81c1[_0xd893('0x63')];_0x3adfd5<_0x11f036&&_[_0xd893('0x5e')](_0x184741['internal']);_0x3adfd5++){if(_0x59d3f9[_0xd893('0x5f')]<=_0x2c81c1[_0x3adfd5][_0xd893('0x64')]){_0x184741[_0xd893('0x59')]=_0x2c81c1[_0x3adfd5]['from'];}else if(_0x59d3f9['min_internal']>_0x2c81c1[_0x3adfd5]['from']&&_0x59d3f9[_0xd893('0x5f')]<=_0x2c81c1[_0x3adfd5]['to']){_0x184741[_0xd893('0x59')]=_0x59d3f9[_0xd893('0x5f')];}}}if(_['isNil'](_0x184741[_0xd893('0x59')])){_0x184741[_0xd893('0x59')]=_0x338e5e+0x1;}return _0x159655(_0x184741);});});})['catch'](function(_0x5d9613){_0x12ef53(_0x5d9613);});});}function updateUser(_0x43d031){return new Promise(function(_0x3908ad,_0x57e5ae){try{if(_0x43d031[_0xd893('0x65')]){_0x43d031[_0xd893('0x66')]=_0x43d031[_0xd893('0x59')];_0x43d031[_0xd893('0x67')]={'mailbox':_0x43d031['internal'],'password':_0x43d031[_0xd893('0x36')],'fullname':_0x43d031['fullname'],'email':_0x43d031[_0xd893('0x68')]};}if(_0x43d031[_0xd893('0x2e')]===_0xd893('0x21')){if(!_0x43d031[_0xd893('0x69')])_0x43d031['permissions']=[_0xd893('0x6a'),'102',_0xd893('0x6b'),'113',_0xd893('0x6c'),_0xd893('0x6d'),'105',_0xd893('0x6e'),_0xd893('0x6f'),_0xd893('0x70'),_0xd893('0x71'),_0xd893('0x72'),'111',_0xd893('0x73'),'115'];}_0x3908ad(_0x43d031);}catch(_0x38a2b3){_0x57e5ae(_0x38a2b3);}});}exports[_0xd893('0x74')]=function(_0x392bef,_0x1d6e9a){if(_0x392bef[_0xd893('0x27')]['role']==='agent')throw new Error(_0xd893('0x75'));if(_0x392bef['body'][_0xd893('0x2e')]===_0xd893('0x27')&&_0x392bef[_0xd893('0x27')][_0xd893('0x2e')]!==_0xd893('0x26')){throw new Error(_0xd893('0x76'));}if(_0x392bef['body']['role']==='admin'&&_0x392bef['user'][_0xd893('0x2e')]!=='admin'){throw new Error(_0xd893('0x77'));}return licenseUtil[_0xd893('0x78')]([_0x392bef['body']])[_0xd893('0x20')](function(){return validateUser(_0x392bef[_0xd893('0x55')]);})['then'](function(_0xe1c5ef){return updateUser(_0xe1c5ef)[_0xd893('0x20')](function(_0x42521e){if(_0x42521e[_0xd893('0x2e')]==='admin'){_0x42521e[_0xd893('0x79')]=_0x392bef[_0xd893('0x27')][_0xd893('0x79')];delete _0x42521e[_0xd893('0x7a')];}return _0x42521e;});})['then'](function(_0x4dc24d){return db[_0xd893('0x32')][_0xd893('0x74')](_0x4dc24d,{'include':[{'model':db[_0xd893('0x67')],'as':_0xd893('0x67')}]});})[_0xd893('0x20')](function(_0x3b93cf){if(_0x392bef[_0xd893('0x55')][_0xd893('0x2e')]===_0xd893('0x27'))return _0x3b93cf;if(_0x392bef[_0xd893('0x27')]['role']!==_0xd893('0x27'))return _0x3b93cf;return db[_0xd893('0x7b')][_0xd893('0x2d')]({'where':{'name':_0x3b93cf[_0xd893('0x2e')]===_0xd893('0x21')?_0xd893('0x7c'):_0xd893('0x7d'),'userProfileId':_0x392bef['user']['userProfileId']},'raw':!![]})[_0xd893('0x20')](function(_0x751a0c){if(!_0x751a0c||_0x751a0c[_0xd893('0x7e')]!=0x0)return _0x3b93cf;return db[_0xd893('0x7f')]['create']({'name':_0x3b93cf[_0xd893('0x2f')],'resourceId':_0x3b93cf['id'],'type':_0x751a0c['name'],'sectionId':_0x751a0c['id']},{})['then'](function(){return _0x3b93cf;});})['catch'](function(_0x517d26){logger['error'](_0xd893('0x80'),_0x517d26);throw _0x517d26;});})[_0xd893('0x20')](respondWithResult(_0x1d6e9a,0xc9))[_0xd893('0x4d')](handleError(_0x1d6e9a,null));};exports[_0xd893('0x81')]=function(_0x2da5f3,_0x3f9ad9){var _0x1e8f89=_0x2da5f3[_0xd893('0x55')];var _0x11f933=[];if(_0x2da5f3[_0xd893('0x27')][_0xd893('0x2e')]===_0xd893('0x21'))throw new Error(_0xd893('0x75'));if(_[_0xd893('0x82')](_0x1e8f89,[_0xd893('0x2e'),_0xd893('0x27')])&&_0x2da5f3[_0xd893('0x27')]['role']!==_0xd893('0x26')){throw new Error('Unauthorized.\x20You\x20must\x20be\x20an\x20administrator\x20in\x20order\x20to\x20create\x20an\x20user');}if(_[_0xd893('0x82')](_0x1e8f89,['role','admin'])&&_0x2da5f3[_0xd893('0x27')]['role']!==_0xd893('0x26')){throw new Error('Unauthorized.\x20You\x20must\x20be\x20an\x20administrator\x20in\x20order\x20to\x20create\x20an\x20administrator');}return licenseUtil[_0xd893('0x78')](_0x1e8f89)[_0xd893('0x20')](function(){return validateUser(_0x1e8f89[0x0]);})[_0xd893('0x20')](function(){for(var _0x478f8f=0x1;_0x478f8f<_0x1e8f89['length'];_0x478f8f++){var _0x310899=_0x1e8f89[_0x478f8f-0x1][_0xd893('0x59')];if(!_0x1e8f89[_0x478f8f][_0xd893('0x59')])_0x1e8f89[_0x478f8f][_0xd893('0x59')]=_0x310899+0x1;_0x11f933[_0xd893('0x42')](validateUser(_0x1e8f89[_0x478f8f]));}return Promise[_0xd893('0x4c')](_0x11f933);})[_0xd893('0x20')](function(){_0x11f933=[];for(var _0x456a70=0x0;_0x456a70<_0x1e8f89[_0xd893('0x63')];_0x456a70++){_0x11f933[_0xd893('0x42')](updateUser(_0x1e8f89[_0x456a70]));}return Promise[_0xd893('0x4c')](_0x11f933);})[_0xd893('0x20')](function(){_0x11f933=_0x1e8f89['map'](function(_0x16a7d6){return db['User'][_0xd893('0x74')](_0x16a7d6,{'include':[{'model':db[_0xd893('0x67')],'as':_0xd893('0x67')}]})[_0xd893('0x20')](function(_0x578fe6){_0x16a7d6['id']=_0x578fe6['id'];return _0x16a7d6;});});return Promise['all'](_0x11f933);})[_0xd893('0x20')](function(_0x408a2f){if(_0x2da5f3[_0xd893('0x55')]['role']===_0xd893('0x27'))return _0x408a2f;if(_0x2da5f3['user']['role']!==_0xd893('0x27'))return _0x408a2f;var _0x2602c5=_[_0xd893('0x82')](_0x408a2f,function(_0x28cf09){return _0x28cf09[_0xd893('0x2e')]===_0xd893('0x21')||_0x28cf09[_0xd893('0x2e')]===_0xd893('0x83');});if(!_0x2602c5)return _0x408a2f;return db['UserProfileSection'][_0xd893('0x43')]({'where':{'name':{'$or':['Agents',_0xd893('0x7d')]},'userProfileId':_0x2da5f3[_0xd893('0x27')][_0xd893('0x7a')]},'raw':!![]})[_0xd893('0x20')](function(_0xaea3b2){if(_[_0xd893('0x84')](_0xaea3b2)||!_[_0xd893('0x82')](_0xaea3b2,[_0xd893('0x7e'),0x0]))return _0x408a2f;_0x11f933=[];var _0x51957d=_(_0xaea3b2)[_0xd893('0x2a')](function(_0x837c8a){if(_0x837c8a['autoAssociation']===0x1)return;return _0x837c8a[_0xd893('0x2f')]===_0xd893('0x7c')?_0xd893('0x21'):_0xd893('0x83');})['compact']()[_0xd893('0x2b')]();for(var _0x26e22e=0x0;_0x26e22e<_0x408a2f[_0xd893('0x63')];_0x26e22e++){if(!_['includes'](_0x51957d,_0x408a2f[_0x26e22e][_0xd893('0x2e')]))return;var _0x3d4118=_0x408a2f[_0x26e22e][_0xd893('0x2e')]==='agent'?'Agents':_0xd893('0x7d');_0x11f933[_0xd893('0x42')](db['UserProfileResource']['create']({'name':_0x408a2f[_0x26e22e][_0xd893('0x2f')],'resourceId':_0x408a2f[_0x26e22e]['id'],'type':_0x3d4118,'sectionId':_[_0xd893('0x2d')](_0xaea3b2,[_0xd893('0x2f'),_0x3d4118])['id']},{}));}return Promise['all'](_0x11f933);});})['then'](respondWithResult(_0x3f9ad9,0xc9))['catch'](handleError(_0x3f9ad9,null));};exports['changePassword']=function(_0x52f7d2,_0x1bba39){if(_0x52f7d2[_0xd893('0x55')]['id']){delete _0x52f7d2['body']['id'];}return db['User'][_0xd893('0x2d')]({'where':{'id':_0x52f7d2[_0xd893('0x4f')]['id']}})[_0xd893('0x20')](function(_0x2064b6){if(!_0x2064b6)return null;if(_0x2064b6['id']===_0x52f7d2[_0xd893('0x27')]['id']){if(!_0x52f7d2[_0xd893('0x55')][_0xd893('0x85')]||!_0x52f7d2[_0xd893('0x55')][_0xd893('0x86')]){throw new db[(_0xd893('0x87'))][(_0xd893('0x88'))](_0xd893('0x89'));}if(!_0x2064b6['authenticate'](_0x52f7d2['body'][_0xd893('0x85')])){throw new db['Sequelize'][(_0xd893('0x88'))](_0xd893('0x8a'));}if(_0x52f7d2[_0xd893('0x55')][_0xd893('0x85')]===_0x52f7d2[_0xd893('0x55')][_0xd893('0x86')]){throw new db[(_0xd893('0x87'))]['ValidationError'](_0xd893('0x8b'));}}else if(_0x52f7d2['user'][_0xd893('0x2e')]===_0xd893('0x26')){if(!_0x52f7d2[_0xd893('0x55')][_0xd893('0x86')]){throw new db[(_0xd893('0x87'))][(_0xd893('0x88'))]('Invalid\x20body\x20format.\x20Use\x20newPassword');}}else if(_0x52f7d2[_0xd893('0x27')][_0xd893('0x2e')]===_0xd893('0x27')){if(!_0x52f7d2[_0xd893('0x55')][_0xd893('0x86')]){throw new db[(_0xd893('0x87'))][(_0xd893('0x88'))](_0xd893('0x8c'));}if(_0x2064b6['role']!==_0xd893('0x21')){throw new db[(_0xd893('0x87'))][(_0xd893('0x88'))]('Unauthorized');}}else{throw new db[(_0xd893('0x87'))]['ValidationError']('Unauthorized');}return _0x2064b6;})[_0xd893('0x20')](handleEntityNotFound(_0x1bba39,null))[_0xd893('0x20')](function(_0x250b83){return db[_0xd893('0x8d')]['findOne']({'attributes':['id',_0xd893('0x5b'),_0xd893('0x8e'),_0xd893('0x8f')]})['then'](function(_0xf810c1){if(_0xf810c1['securePassword'])authService[_0xd893('0x5c')](_0x52f7d2[_0xd893('0x55')]['newPassword']);if(!_0xf810c1[_0xd893('0x8e')]||!_0x250b83[_0xd893('0x38')])return _0x250b83;authService[_0xd893('0x90')](_0x52f7d2[_0xd893('0x55')]['newPassword'],_0x250b83[_0xd893('0x38')],_0xf810c1[_0xd893('0x8f')]);return _0x250b83;})[_0xd893('0x20')](saveUpdates({'password':_0x52f7d2[_0xd893('0x55')][_0xd893('0x86')],'passwordResetAt':_0x52f7d2['user']['id']==_0x52f7d2[_0xd893('0x4f')]['id']?moment():null,'previousPasswords':authService[_0xd893('0x91')](_0x52f7d2['body'][_0xd893('0x86')],_0x250b83[_0xd893('0x38')])},null));})['then'](respondWithResult(_0x1bba39,null))[_0xd893('0x4d')](handleError(_0x1bba39,null));};exports['addQueues']=function(_0x32ae12,_0x10c4b1){var _0x462def=_0x32ae12[_0xd893('0x55')][_0xd893('0x92')];return db[_0xd893('0x32')][_0xd893('0x2d')]({'where':{'id':_0x32ae12[_0xd893('0x4f')]['id']},'attributes':['id','name',_0xd893('0x2e'),'online',_0xd893('0x93'),_0xd893('0x94'),_0xd893('0x95')]})[_0xd893('0x20')](handleEntityNotFound(_0x10c4b1,null))[_0xd893('0x20')](function(_0xc77a33){if(_0xc77a33){if(!utils[_0xd893('0x96')](_0x462def)){throw new db[(_0xd893('0x87'))]['ValidationError']('Unknown\x20channel');}return _0xc77a33['add'+_[_0xd893('0x97')](_0x462def[_0xd893('0x98')]())+'Queues'](_0x32ae12[_0xd893('0x55')]['ids'],{'penalty':_0x32ae12[_0xd893('0x55')][_0xd893('0x99')]||0x0})[_0xd893('0x9a')](function(_0x5800ea){for(var _0x2cdee0=0x0;_0x2cdee0<_0x32ae12['body'][_0xd893('0x9b')][_0xd893('0x63')];_0x2cdee0+=0x1){var _0x5dc884={'UserId':Number(_0x32ae12[_0xd893('0x4f')]['id'])};_0x5dc884[_[_0xd893('0x97')](_0x462def[_0xd893('0x98')]())+_0xd893('0x9c')]=Number(_0x32ae12['body']['ids'][_0x2cdee0]);socket['emit'](_0xd893('0x27')+_['capitalize'](_0x462def[_0xd893('0x98')]())+'Queue:save',_0x5dc884);}return _0x5800ea;})[_0xd893('0x20')](function(){if(_0x462def===_0xd893('0x9d')){return db[_0xd893('0x9e')][_0xd893('0x43')]({'where':{'id':_0x32ae12['body']['ids']||[]},'raw':!![],'attributes':['id',_0xd893('0x2f')]});}})[_0xd893('0x20')](function(_0x4bf2a0){var _0x373953=_0xc77a33['get']({'plain':!![]});var _0x1e3f77=[];if(_0x462def===_0xd893('0x9d')&&_0x373953[_0xd893('0x2e')]===_0xd893('0x21')&&_0x373953[_0xd893('0x9f')]){for(let _0x475a97=0x0;_0x475a97<_0x4bf2a0[_0xd893('0x63')];_0x475a97+=0x1){_0x1e3f77[_0xd893('0x42')]({'membername':_0x373953[_0xd893('0x2f')],'UserId':_0x373953['id'],'queue_name':_0x4bf2a0[_0x475a97]['name'],'VoiceQueueId':_0x4bf2a0[_0x475a97]['id'],'interface':_['isNil'](_0x373953[_0xd893('0x95')])?util[_0xd893('0xa0')]('SIP/%s',_0x373953[_0xd893('0x2f')]):_0x373953[_0xd893('0x95')],'paused':_0x373953[_0xd893('0x94')]||![],'penalty':_0x32ae12[_0xd893('0x55')][_0xd893('0x99')]||0x0});}return Promise[_0xd893('0x4c')](_0x1e3f77[_0xd893('0x2a')](function(_0xc43f72){return db['UserVoiceQueueRt'][_0xd893('0xa1')](_0xc43f72);}));}return _0xc77a33;});}})[_0xd893('0x20')](respondWithStatusCode(_0x10c4b1,null))['catch'](handleError(_0x10c4b1,null));};exports[_0xd893('0xa2')]=function(_0x25379c,_0x53e81d){var _0x2227f1,_0xc2bcd8;return db[_0xd893('0x32')]['find']({'where':{'id':_0x25379c[_0xd893('0x4f')]['id']},'attributes':['id',_0xd893('0x2f'),_0xd893('0x2e')]})['then'](handleEntityNotFound(_0x53e81d,null))[_0xd893('0x20')](function(_0x30d591){if(_0x30d591){_0x2227f1=_0x30d591;if(!_0x25379c[_0xd893('0x3c')]['channel']||!utils['isValidChannel'](_0x25379c[_0xd893('0x3c')]['channel'])){throw new db[(_0xd893('0x87'))][(_0xd893('0x88'))]('Unknown\x20channel');}return _0x30d591[_0xd893('0xa3')+_[_0xd893('0x97')](_0x25379c[_0xd893('0x3c')][_0xd893('0x92')][_0xd893('0x98')]())+_0xd893('0xa4')](_0x25379c['query']['ids']);}})[_0xd893('0x20')](function(_0xbd7e02){if(_[_0xd893('0xa5')](_0x25379c[_0xd893('0x3c')]['ids'])){for(var _0x1e630c=0x0;_0x1e630c<_0x25379c[_0xd893('0x3c')]['ids'][_0xd893('0x63')];_0x1e630c+=0x1){_0xc2bcd8={'UserId':Number(_0x25379c[_0xd893('0x4f')]['id'])};_0xc2bcd8[_['capitalize'](_0x25379c[_0xd893('0x3c')][_0xd893('0x92')][_0xd893('0x98')]())+_0xd893('0x9c')]=Number(_0x25379c[_0xd893('0x3c')][_0xd893('0x9b')][_0x1e630c]);socket['emit'](_0xd893('0x27')+_[_0xd893('0x97')](_0x25379c[_0xd893('0x3c')][_0xd893('0x92')][_0xd893('0x98')]())+_0xd893('0xa6'),_0xc2bcd8);}}else{_0xc2bcd8={'UserId':Number(_0x25379c[_0xd893('0x4f')]['id'])};_0xc2bcd8[_[_0xd893('0x97')](_0x25379c[_0xd893('0x3c')][_0xd893('0x92')]['toLowerCase']())+_0xd893('0x9c')]=Number(_0x25379c[_0xd893('0x3c')][_0xd893('0x9b')]);socket[_0xd893('0x22')]('user'+_[_0xd893('0x97')](_0x25379c[_0xd893('0x3c')][_0xd893('0x92')][_0xd893('0x98')]())+_0xd893('0xa6'),_0xc2bcd8);}return _0xbd7e02;})['then'](function(){if(_0x25379c[_0xd893('0x3c')][_0xd893('0x92')]===_0xd893('0x9d')){return db[_0xd893('0xa7')][_0xd893('0x24')]({'where':{'UserId':_0x25379c['params']['id'],'VoiceQueueId':_0x25379c[_0xd893('0x3c')]['ids']},'individualHooks':!![]})[_0xd893('0x20')](function(){return _0x2227f1;});}return _0x2227f1;})['then'](respondWithStatusCode(_0x53e81d,null))[_0xd893('0x4d')](handleError(_0x53e81d,null));};exports[_0xd893('0xa8')]=function(_0x57a47f,_0x549f49){_0x57a47f[_0xd893('0x55')][_0xd893('0xa9')]=_0x57a47f['file'][_0xd893('0xaa')];return db[_0xd893('0x32')][_0xd893('0x2d')]({'where':{'id':_0x57a47f['params']['id']}})[_0xd893('0x20')](handleEntityNotFound(_0x549f49,null))[_0xd893('0x20')](saveUpdates(_0x57a47f[_0xd893('0x55')],null))[_0xd893('0x20')](respondWithResult(_0x549f49,null))[_0xd893('0x4d')](handleError(_0x549f49,null));};exports[_0xd893('0xab')]=function(_0x2bf27a,_0x498c53){var _0x2cc17d=path[_0xd893('0xac')](config[_0xd893('0xad')],_0xd893('0xae'));return db[_0xd893('0x32')][_0xd893('0x2d')]({'where':{'id':_0x2bf27a[_0xd893('0x4f')]['id']},'attributes':['id',_0xd893('0xa9')],'raw':!![]})['then'](handleEntityNotFound(_0x498c53,null))['then'](function(_0x22e62e){if(_0x22e62e){if(_[_0xd893('0x5e')](_0x22e62e[_0xd893('0xa9')])){return _0x498c53[_0xd893('0xaf')](_0x2cc17d);}else{if(!fs['existsSync'](path['join'](config[_0xd893('0xad')],_0xd893('0xb0'),_0x22e62e[_0xd893('0xa9')]))){return _0x498c53[_0xd893('0xaf')](_0x2cc17d);}return _0x498c53['download'](path[_0xd893('0xac')](config[_0xd893('0xad')],_0xd893('0xb0'),_0x22e62e[_0xd893('0xa9')]));}}})[_0xd893('0x4d')](handleError(_0x498c53,null));};exports[_0xd893('0xb1')]=function(_0x749d4e,_0x295b67){return db['User'][_0xd893('0x2d')]({'where':{'id':_0x749d4e['params']['id']},'attributes':['id']})[_0xd893('0x20')](handleEntityNotFound(_0x295b67,null))['then'](function(_0x982b74){var _0x37d188=[];values=_0x982b74[_0xd893('0x48')];_0x37d188[_0xd893('0x42')](get_open_tabs(_0xd893('0x46'),_0x982b74[_0xd893('0x48')]));_0x37d188[_0xd893('0x42')](get_open_tabs('sms',_0x982b74['dataValues']));_0x37d188[_0xd893('0x42')](get_open_tabs(_0xd893('0x54'),_0x982b74[_0xd893('0x48')]));_0x37d188[_0xd893('0x42')](get_open_tabs(_0xd893('0x4b'),_0x982b74[_0xd893('0x48')]));_0x37d188[_0xd893('0x42')](get_open_tabs('fax',_0x982b74['dataValues']));_0x37d188['push'](get_open_tabs('mail',_0x982b74[_0xd893('0x48')]));return Promise[_0xd893('0x4c')](_0x37d188);})[_0xd893('0x20')](function(_0x49717a){if(_0x49717a){var _0x51c2d0=_[_0xd893('0x2a')](values[_0xd893('0xb2')],function(_0x3157f0){return{'channel':_0xd893('0xb3'),'id':_0x3157f0['id'],'createdAt':_0x3157f0[_0xd893('0xb4')]};});var _0x4eef72=_[_0xd893('0x2a')](values[_0xd893('0xb5')],function(_0x540829){return{'channel':_0xd893('0xb6'),'id':_0x540829['id'],'createdAt':_0x540829['createdAt']};});var _0x364627=_['map'](values[_0xd893('0xb7')],function(_0x49148b){return{'channel':_0xd893('0xb8'),'id':_0x49148b['id'],'createdAt':_0x49148b['createdAt']};});var _0x3c94d0=_[_0xd893('0x2a')](values[_0xd893('0xb9')],function(_0x3b8abd){return{'channel':_0xd893('0xba'),'id':_0x3b8abd['id'],'createdAt':_0x3b8abd['createdAt']};});var _0x470e9d=_[_0xd893('0x2a')](values[_0xd893('0xbb')],function(_0x24d689){return{'channel':'SMS','id':_0x24d689['id'],'createdAt':_0x24d689[_0xd893('0xb4')]};});var _0x4c30cd=_['map'](values[_0xd893('0xbc')],function(_0x56ef72){return{'channel':_0xd893('0xbd'),'id':_0x56ef72['id'],'createdAt':_0x56ef72[_0xd893('0xb4')]};});var _0x430635=_[_0xd893('0xbe')](_0x51c2d0,_0x4eef72,_0x364627,_0x3c94d0,_0x470e9d,_0x4c30cd);var _0x3f61a7={'count':_0x430635[_0xd893('0x63')],'rows':_0x430635};return _0x3f61a7;}else return null;})[_0xd893('0x20')](respondWithResult(_0x295b67,null))[_0xd893('0x4d')](handleError(_0x295b67,null));};exports[_0xd893('0xbf')]=function(_0x27960c,_0x37a4da){var _0x2a98f8={};return db[_0xd893('0x32')][_0xd893('0xc0')]({'where':{'id':_0x27960c[_0xd893('0x4f')]['id']}})['then'](function(_0x580f3a){if(!_0x580f3a){throw new APINotFoundError(util[_0xd893('0xa0')]('User\x20with\x20id\x20%s\x20not\x20found',_0x27960c['params']['id']));}return contacts[_0xd893('0x56')]();})[_0xd893('0x20')](function(_0x4dfe13){_0x27960c[_0xd893('0x3c')][_0xd893('0x32')]=_0x27960c[_0xd893('0x4f')]['id'];_0x2a98f8=qs[_0xd893('0x50')](_0x4dfe13,_0x27960c);if(_0x27960c[_0xd893('0x3c')][_0xd893('0xc1')](_0xd893('0x51'))){_0x2a98f8['include']=[{'model':db[_0xd893('0xc2')],'as':_0xd893('0xc3'),'required':![]},{'model':db['Tag'],'as':'Tags','attributes':['id',_0xd893('0x2f'),_0xd893('0xc4')],'where':_0x27960c[_0xd893('0x3c')][_0xd893('0xc5')]?{'id':_0x27960c[_0xd893('0x3c')][_0xd893('0xc5')]}:undefined,'required':_0x27960c[_0xd893('0x3c')]['tag']?!![]:![]}];}return contacts[_0xd893('0x43')](_0x27960c[_0xd893('0x3c')],_0x27960c[_0xd893('0x27')],_0x2a98f8,_0x4dfe13);})[_0xd893('0x20')](respondWithFilteredResult(_0x37a4da,_0x2a98f8))[_0xd893('0x4d')](APIHandleError(_0x37a4da));};exports['getQueues']=function(_0x19eaf2,_0x14ab4f){var _0x27f346;var _0x29ed90={};var _0x41b96e;return db['User']['findOne']({'where':{'id':_0x19eaf2['params']['id']},'attributes':['id',_0xd893('0x2f'),'role']})[_0xd893('0x20')](handleEntityNotFound(_0x14ab4f,null))[_0xd893('0x20')](function(_0x23987e){if(!utils[_0xd893('0x96')](_0x19eaf2[_0xd893('0x3c')][_0xd893('0x92')])){throw new db['Sequelize'][(_0xd893('0x88'))](_0xd893('0xc6'));}_0x27f346=_0x23987e;var _0x25a498={};_0x25a498[_0xd893('0xc7')]=_[_0xd893('0xc8')](db[_[_0xd893('0x97')](_0x19eaf2[_0xd893('0x3c')][_0xd893('0x92')])+_0xd893('0xc9')][_0xd893('0x33')]);_0x25a498[_0xd893('0x3c')]=_[_0xd893('0xc8')](_0x19eaf2['query']);_0x25a498[_0xd893('0xca')]=_['intersection'](_0x25a498[_0xd893('0xc7')],_0x25a498[_0xd893('0x3c')]);_0x29ed90[_0xd893('0x41')]=_[_0xd893('0xcb')](_0x25a498['model'],qs[_0xd893('0xcc')](_0x19eaf2[_0xd893('0x3c')][_0xd893('0xcc')]));_0x29ed90[_0xd893('0x41')]=_0x29ed90[_0xd893('0x41')][_0xd893('0x63')]?_0x29ed90[_0xd893('0x41')]:_0x25a498[_0xd893('0xc7')];_0x29ed90[_0xd893('0xcd')]=qs[_0xd893('0xce')](_0x19eaf2[_0xd893('0x3c')]['sort']);_0x29ed90[_0xd893('0xcf')]=qs[_0xd893('0xca')](_[_0xd893('0xd0')](_0x19eaf2['query'],_0x25a498[_0xd893('0xca')]));if(_0x19eaf2[_0xd893('0x3c')]['filter']){_0x29ed90[_0xd893('0xcf')]=_[_0xd893('0x52')](_0x29ed90[_0xd893('0xcf')],{'$or':_['map'](_0x29ed90[_0xd893('0x41')],function(_0x22436f){var _0x3f3616={};_0x3f3616[_0x22436f]={'$like':'%'+_0x19eaf2[_0xd893('0x3c')][_0xd893('0x28')]+'%'};return _0x3f3616;})});}_0x29ed90=_['merge']({},_0x29ed90,_0x19eaf2[_0xd893('0x53')]);switch(_0x27f346[_0xd893('0x2e')]){case _0xd893('0x26'):return db[_['capitalize'](_0x19eaf2[_0xd893('0x3c')][_0xd893('0x92')])+_0xd893('0xc9')][_0xd893('0x43')](_0x29ed90);case'user':case'agent':return _0x27f346[_0xd893('0x25')+_[_0xd893('0x97')](_0x19eaf2['query'][_0xd893('0x92')])+_0xd893('0xa4')](_0x29ed90);default:throw new db[(_0xd893('0x87'))][(_0xd893('0x88'))](_0xd893('0xd1'));}})[_0xd893('0x20')](function(_0xed8c06){_0x41b96e=_0xed8c06[_0xd893('0x63')];if(!_0x19eaf2[_0xd893('0x3c')][_0xd893('0xc1')](_0xd893('0xd2'))){_0x29ed90['limit']=qs[_0xd893('0x1c')](_0x19eaf2[_0xd893('0x3c')][_0xd893('0x1c')]);_0x29ed90[_0xd893('0x19')]=qs[_0xd893('0x19')](_0x19eaf2['query'][_0xd893('0x19')]);}switch(_0x27f346['role']){case _0xd893('0x26'):return db[_['capitalize'](_0x19eaf2[_0xd893('0x3c')]['channel'])+_0xd893('0xc9')][_0xd893('0x43')](_0x29ed90);case _0xd893('0x27'):case _0xd893('0x21'):return _0x27f346['get'+_['capitalize'](_0x19eaf2['query'][_0xd893('0x92')])+'Queues'](_0x29ed90);}})[_0xd893('0x20')](function(_0x285355){return{'count':_0x41b96e,'rows':_0x285355};})[_0xd893('0x20')](respondWithResult(_0x14ab4f,null))[_0xd893('0x4d')](handleError(_0x14ab4f,null));};exports[_0xd893('0xd3')]=function(_0x4c84ba,_0xaf8b11){var _0x16a146={};var _0x1eced9={};var _0x50e2c8;var _0x20cae5;return db[_0xd893('0x32')][_0xd893('0xc0')]({'where':{'id':_0x4c84ba[_0xd893('0x4f')]['id']}})['then'](handleEntityNotFound(_0xaf8b11,null))[_0xd893('0x20')](function(_0x9252dd){if(_0x9252dd){_0x50e2c8=_0x9252dd;_0x1eced9[_0xd893('0xc7')]=_[_0xd893('0xc8')](db[_0xd893('0xa7')][_0xd893('0x33')]);_0x1eced9[_0xd893('0x3c')]=_[_0xd893('0xc8')](_0x4c84ba[_0xd893('0x3c')]);_0x1eced9[_0xd893('0xca')]=_[_0xd893('0xcb')](_0x1eced9['model'],_0x1eced9[_0xd893('0x3c')]);_0x16a146['attributes']=_[_0xd893('0xcb')](_0x1eced9['model'],qs[_0xd893('0xcc')](_0x4c84ba['query'][_0xd893('0xcc')]));_0x16a146[_0xd893('0x41')]=_0x16a146[_0xd893('0x41')]['length']?_0x16a146[_0xd893('0x41')]:_0x1eced9[_0xd893('0xc7')];_0x16a146[_0xd893('0xcd')]=qs['sort'](_0x4c84ba[_0xd893('0x3c')][_0xd893('0xce')]);_0x16a146[_0xd893('0xcf')]=qs['filters'](_[_0xd893('0xd0')](_0x4c84ba[_0xd893('0x3c')],_0x1eced9[_0xd893('0xca')]));if(_0x4c84ba[_0xd893('0x3c')][_0xd893('0x28')]){_0x16a146[_0xd893('0xcf')]=_[_0xd893('0x52')](_0x16a146[_0xd893('0xcf')],{'$or':_[_0xd893('0x2a')](_0x16a146[_0xd893('0x41')],function(_0x452dc0){var _0x226ca9={};_0x226ca9[_0x452dc0]={'$like':'%'+_0x4c84ba[_0xd893('0x3c')][_0xd893('0x28')]+'%'};return _0x226ca9;})});}_0x16a146=_[_0xd893('0x52')]({},_0x16a146,_0x4c84ba[_0xd893('0x53')]);return _0x50e2c8[_0xd893('0xd3')](_0x16a146);}})['then'](function(_0x4f80b8){if(_0x4f80b8){_0x20cae5=_0x4f80b8[_0xd893('0x63')];if(!_0x4c84ba[_0xd893('0x3c')][_0xd893('0xc1')](_0xd893('0xd2'))){_0x16a146[_0xd893('0x1c')]=qs[_0xd893('0x1c')](_0x4c84ba['query']['limit']);_0x16a146[_0xd893('0x19')]=qs[_0xd893('0x19')](_0x4c84ba[_0xd893('0x3c')][_0xd893('0x19')]);}return _0x50e2c8[_0xd893('0xd3')](_0x16a146);}})['then'](function(_0x4c96d5){if(_0x4c96d5){return _0x4c96d5?{'count':_0x20cae5,'rows':_0x4c96d5}:null;}})[_0xd893('0x20')](respondWithResult(_0xaf8b11,null))[_0xd893('0x4d')](handleError(_0xaf8b11,null));};exports[_0xd893('0xd4')]=function(_0x4a3724,_0x827af0){var _0x32c573={};var _0x1f94fb={};var _0x10a918;var _0x11c4da;return db[_0xd893('0x32')][_0xd893('0xc0')]({'where':{'id':_0x4a3724[_0xd893('0x4f')]['id']}})['then'](handleEntityNotFound(_0x827af0,null))['then'](function(_0x18f016){if(_0x18f016){_0x10a918=_0x18f016;_0x1f94fb[_0xd893('0xc7')]=_[_0xd893('0xc8')](db['ChatGroup'][_0xd893('0x33')]);_0x1f94fb['query']=_[_0xd893('0xc8')](_0x4a3724[_0xd893('0x3c')]);_0x1f94fb[_0xd893('0xca')]=_[_0xd893('0xcb')](_0x1f94fb[_0xd893('0xc7')],_0x1f94fb[_0xd893('0x3c')]);_0x32c573['attributes']=_[_0xd893('0xcb')](_0x1f94fb['model'],qs['fields'](_0x4a3724[_0xd893('0x3c')][_0xd893('0xcc')]));_0x32c573[_0xd893('0x41')]=_0x32c573[_0xd893('0x41')]['length']?_0x32c573[_0xd893('0x41')]:_0x1f94fb[_0xd893('0xc7')];_0x32c573[_0xd893('0xcd')]=qs[_0xd893('0xce')](_0x4a3724[_0xd893('0x3c')][_0xd893('0xce')]);_0x32c573[_0xd893('0xcf')]=qs['filters'](_[_0xd893('0xd0')](_0x4a3724['query'],_0x1f94fb[_0xd893('0xca')]));if(_0x4a3724[_0xd893('0x3c')]['filter']){_0x32c573[_0xd893('0xcf')]=_[_0xd893('0x52')](_0x32c573['where'],{'$or':_['map'](_0x32c573[_0xd893('0x41')],function(_0x300d19){var _0x10610b={};_0x10610b[_0x300d19]={'$like':'%'+_0x4a3724['query'][_0xd893('0x28')]+'%'};return _0x10610b;})});}_0x32c573=_[_0xd893('0x52')]({},_0x32c573,_0x4a3724[_0xd893('0x53')]);return _0x10a918[_0xd893('0xd4')](_0x32c573);}})[_0xd893('0x20')](function(_0x433ac1){if(_0x433ac1){_0x11c4da=_0x433ac1['length'];if(!_0x4a3724[_0xd893('0x3c')][_0xd893('0xc1')](_0xd893('0xd2'))){_0x32c573['limit']=qs[_0xd893('0x1c')](_0x4a3724[_0xd893('0x3c')]['limit']);_0x32c573['offset']=qs[_0xd893('0x19')](_0x4a3724[_0xd893('0x3c')][_0xd893('0x19')]);}return _0x10a918[_0xd893('0xd4')](_0x32c573);}})['then'](function(_0x46b974){if(_0x46b974){return _0x46b974?{'count':_0x11c4da,'rows':_0x46b974}:null;}})[_0xd893('0x20')](respondWithResult(_0x827af0,null))[_0xd893('0x4d')](handleError(_0x827af0,null));};exports[_0xd893('0xd5')]=function(_0x17d011,_0x39d61b){var _0x229c9b={'raw':!![],'where':{}};var _0x2b1c42={};var _0x3bc379={'count':0x0,'rows':[]};return db[_0xd893('0x32')][_0xd893('0xc0')]({'where':{'id':_0x17d011[_0xd893('0x4f')]['id']}})[_0xd893('0x20')](handleEntityNotFound(_0x39d61b,null))['then'](function(_0x3ec659){if(_0x3ec659){_0x2b1c42[_0xd893('0xc7')]=_[_0xd893('0xc8')](db[_0xd893('0xd6')][_0xd893('0x33')]);_0x2b1c42['query']=_['keys'](_0x17d011[_0xd893('0x3c')]);_0x2b1c42[_0xd893('0xca')]=_[_0xd893('0xcb')](_0x2b1c42[_0xd893('0xc7')],_0x2b1c42[_0xd893('0x3c')]);_0x229c9b[_0xd893('0x41')]=_['intersection'](_0x2b1c42[_0xd893('0xc7')],qs['fields'](_0x17d011[_0xd893('0x3c')]['fields']));_0x229c9b[_0xd893('0x41')]=_0x229c9b['attributes'][_0xd893('0x63')]?_0x229c9b['attributes']:_0x2b1c42[_0xd893('0xc7')];if(!_0x17d011[_0xd893('0x3c')][_0xd893('0xc1')](_0xd893('0xd2'))){_0x229c9b['limit']=qs[_0xd893('0x1c')](_0x17d011[_0xd893('0x3c')][_0xd893('0x1c')]);_0x229c9b['offset']=qs[_0xd893('0x19')](_0x17d011[_0xd893('0x3c')][_0xd893('0x19')]);}_0x229c9b[_0xd893('0xcd')]=qs[_0xd893('0xce')](_0x17d011[_0xd893('0x3c')][_0xd893('0xce')]);_0x229c9b['where']=qs[_0xd893('0xca')](_[_0xd893('0xd0')](_0x17d011[_0xd893('0x3c')],_0x2b1c42['filters']));_0x229c9b[_0xd893('0xcf')][_0xd893('0xd7')]=_0x3ec659['id'];if(_0x17d011[_0xd893('0x3c')][_0xd893('0x28')]){_0x229c9b['where']=_[_0xd893('0x52')](_0x229c9b[_0xd893('0xcf')],{'$or':_['map'](_0x229c9b[_0xd893('0x41')],function(_0x437ead){var _0x44cc8f={};_0x44cc8f[_0x437ead]={'$like':'%'+_0x17d011[_0xd893('0x3c')]['filter']+'%'};return _0x44cc8f;})});}_0x229c9b=_['merge']({},_0x229c9b,_0x17d011[_0xd893('0x53')]);return db[_0xd893('0xd6')][_0xd893('0x1b')]({'where':_0x229c9b['where']})[_0xd893('0x20')](function(_0x11c387){_0x3bc379[_0xd893('0x1b')]=_0x11c387;if(_0x17d011[_0xd893('0x3c')][_0xd893('0x51')]){_0x229c9b[_0xd893('0x3d')]=[{'all':!![]}];}return db['VoiceRecording'][_0xd893('0x43')](_0x229c9b);})[_0xd893('0x20')](function(_0x476bcf){_0x3bc379[_0xd893('0x45')]=_0x476bcf;return _0x3bc379;});}})[_0xd893('0x20')](respondWithFilteredResult(_0x39d61b,_0x229c9b))['catch'](handleError(_0x39d61b,null));};exports['getScreenRecordings']=function(_0x3723d6,_0x19325e){var _0x5cf92={'raw':!![],'where':{}};var _0x4093b7={};var _0x5d8239={'count':0x0,'rows':[]};return db[_0xd893('0x32')][_0xd893('0xc0')]({'where':{'id':_0x3723d6[_0xd893('0x4f')]['id']}})[_0xd893('0x20')](handleEntityNotFound(_0x19325e,null))['then'](function(_0x3d9896){if(_0x3d9896){_0x4093b7[_0xd893('0xc7')]=_['keys'](db[_0xd893('0xd8')][_0xd893('0x33')]);_0x4093b7[_0xd893('0x3c')]=_[_0xd893('0xc8')](_0x3723d6['query']);_0x4093b7[_0xd893('0xca')]=_[_0xd893('0xcb')](_0x4093b7['model'],_0x4093b7[_0xd893('0x3c')]);_0x5cf92[_0xd893('0x41')]=_[_0xd893('0xcb')](_0x4093b7[_0xd893('0xc7')],qs['fields'](_0x3723d6[_0xd893('0x3c')][_0xd893('0xcc')]));_0x5cf92[_0xd893('0x41')]=_0x5cf92[_0xd893('0x41')][_0xd893('0x63')]?_0x5cf92[_0xd893('0x41')]:_0x4093b7[_0xd893('0xc7')];if(!_0x3723d6['query'][_0xd893('0xc1')](_0xd893('0xd2'))){_0x5cf92['limit']=qs['limit'](_0x3723d6[_0xd893('0x3c')][_0xd893('0x1c')]);_0x5cf92[_0xd893('0x19')]=qs[_0xd893('0x19')](_0x3723d6[_0xd893('0x3c')][_0xd893('0x19')]);}_0x5cf92['order']=qs[_0xd893('0xce')](_0x3723d6['query'][_0xd893('0xce')]);_0x5cf92[_0xd893('0xcf')]=qs['filters'](_[_0xd893('0xd0')](_0x3723d6['query'],_0x4093b7[_0xd893('0xca')]));_0x5cf92['where'][_0xd893('0xd7')]=_0x3d9896['id'];if(_0x3723d6[_0xd893('0x3c')]['filter']){_0x5cf92[_0xd893('0xcf')]=_[_0xd893('0x52')](_0x5cf92['where'],{'$or':_['map'](_0x5cf92['attributes'],function(_0x4bbdf8){var _0x26174c={};_0x26174c[_0x4bbdf8]={'$like':'%'+_0x3723d6[_0xd893('0x3c')][_0xd893('0x28')]+'%'};return _0x26174c;})});}_0x5cf92=_[_0xd893('0x52')]({},_0x5cf92,_0x3723d6[_0xd893('0x53')]);return db[_0xd893('0xd8')][_0xd893('0x1b')]({'where':_0x5cf92[_0xd893('0xcf')]})[_0xd893('0x20')](function(_0x264216){_0x5d8239[_0xd893('0x1b')]=_0x264216;if(_0x3723d6[_0xd893('0x3c')][_0xd893('0x51')]){_0x5cf92[_0xd893('0x3d')]=[{'all':!![]}];}return db[_0xd893('0xd8')][_0xd893('0x43')](_0x5cf92);})[_0xd893('0x20')](function(_0x4a26db){_0x5d8239[_0xd893('0x45')]=_0x4a26db;return _0x5d8239;});}})[_0xd893('0x20')](respondWithFilteredResult(_0x19325e,_0x5cf92))['catch'](handleError(_0x19325e,null));};exports[_0xd893('0xd9')]=function(_0x590212,_0x292dac){var _0x2ecdf9={};var _0x30a496={};var _0x6ade1b;var _0x1bc5d9;return db['User'][_0xd893('0xc0')]({'where':{'id':_0x590212['params']['id']}})[_0xd893('0x20')](handleEntityNotFound(_0x292dac,null))['then'](function(_0x20103f){if(_0x20103f){_0x6ade1b=_0x20103f;_0x30a496[_0xd893('0xc7')]=_[_0xd893('0xc8')](db[_0xd893('0xda')][_0xd893('0x33')]);_0x30a496['query']=_[_0xd893('0xc8')](_0x590212[_0xd893('0x3c')]);_0x30a496[_0xd893('0xca')]=_[_0xd893('0xcb')](_0x30a496[_0xd893('0xc7')],_0x30a496[_0xd893('0x3c')]);_0x2ecdf9['attributes']=_[_0xd893('0xcb')](_0x30a496[_0xd893('0xc7')],qs[_0xd893('0xcc')](_0x590212['query'][_0xd893('0xcc')]));_0x2ecdf9['attributes']=_0x2ecdf9[_0xd893('0x41')][_0xd893('0x63')]?_0x2ecdf9[_0xd893('0x41')]:_0x30a496['model'];_0x2ecdf9[_0xd893('0xcd')]=qs['sort'](_0x590212['query'][_0xd893('0xce')]);_0x2ecdf9[_0xd893('0xcf')]=qs[_0xd893('0xca')](_['pick'](_0x590212[_0xd893('0x3c')],_0x30a496[_0xd893('0xca')]));if(_0x590212[_0xd893('0x3c')]['filter']){_0x2ecdf9[_0xd893('0xcf')]=_[_0xd893('0x52')](_0x2ecdf9['where'],{'$or':_[_0xd893('0x2a')](_0x2ecdf9[_0xd893('0x41')],function(_0x7e1ba5){var _0x124c8c={};_0x124c8c[_0x7e1ba5]={'$like':'%'+_0x590212[_0xd893('0x3c')][_0xd893('0x28')]+'%'};return _0x124c8c;})});}_0x2ecdf9=_[_0xd893('0x52')]({},_0x2ecdf9,_0x590212[_0xd893('0x53')]);return _0x6ade1b[_0xd893('0xd9')](_0x2ecdf9);}})[_0xd893('0x20')](function(_0x3c4c65){if(_0x3c4c65){_0x1bc5d9=_0x3c4c65[_0xd893('0x63')];if(!_0x590212['query'][_0xd893('0xc1')](_0xd893('0xd2'))){_0x2ecdf9[_0xd893('0x1c')]=qs[_0xd893('0x1c')](_0x590212[_0xd893('0x3c')][_0xd893('0x1c')]);_0x2ecdf9[_0xd893('0x19')]=qs[_0xd893('0x19')](_0x590212[_0xd893('0x3c')][_0xd893('0x19')]);}return _0x6ade1b['getChatInteractions'](_0x2ecdf9);}})[_0xd893('0x20')](function(_0x426544){if(_0x426544){return _0x426544?{'count':_0x1bc5d9,'rows':_0x426544}:null;}})[_0xd893('0x20')](respondWithResult(_0x292dac,null))['catch'](handleError(_0x292dac,null));};exports['getOpenchannelInteractions']=function(_0x5d1f50,_0xd42a3b){var _0x32be9c={};var _0xb58e05={};var _0x151c8d;var _0x43d894;return db[_0xd893('0x32')]['findOne']({'where':{'id':_0x5d1f50[_0xd893('0x4f')]['id']}})[_0xd893('0x20')](handleEntityNotFound(_0xd42a3b,null))[_0xd893('0x20')](function(_0x355cc2){if(_0x355cc2){_0x151c8d=_0x355cc2;_0xb58e05[_0xd893('0xc7')]=_['keys'](db[_0xd893('0xdb')][_0xd893('0x33')]);_0xb58e05[_0xd893('0x3c')]=_[_0xd893('0xc8')](_0x5d1f50[_0xd893('0x3c')]);_0xb58e05['filters']=_['intersection'](_0xb58e05[_0xd893('0xc7')],_0xb58e05['query']);_0x32be9c[_0xd893('0x41')]=_[_0xd893('0xcb')](_0xb58e05[_0xd893('0xc7')],qs['fields'](_0x5d1f50['query']['fields']));_0x32be9c[_0xd893('0x41')]=_0x32be9c[_0xd893('0x41')][_0xd893('0x63')]?_0x32be9c[_0xd893('0x41')]:_0xb58e05[_0xd893('0xc7')];_0x32be9c[_0xd893('0xcd')]=qs[_0xd893('0xce')](_0x5d1f50[_0xd893('0x3c')][_0xd893('0xce')]);_0x32be9c[_0xd893('0xcf')]=qs[_0xd893('0xca')](_[_0xd893('0xd0')](_0x5d1f50[_0xd893('0x3c')],_0xb58e05[_0xd893('0xca')]));if(_0x5d1f50['query']['filter']){_0x32be9c[_0xd893('0xcf')]=_[_0xd893('0x52')](_0x32be9c['where'],{'$or':_[_0xd893('0x2a')](_0x32be9c['attributes'],function(_0x114cb7){var _0x492710={};_0x492710[_0x114cb7]={'$like':'%'+_0x5d1f50['query']['filter']+'%'};return _0x492710;})});}_0x32be9c=_[_0xd893('0x52')]({},_0x32be9c,_0x5d1f50[_0xd893('0x53')]);return _0x151c8d[_0xd893('0xdc')](_0x32be9c);}})[_0xd893('0x20')](function(_0x131c05){if(_0x131c05){_0x43d894=_0x131c05[_0xd893('0x63')];if(!_0x5d1f50[_0xd893('0x3c')][_0xd893('0xc1')]('nolimit')){_0x32be9c[_0xd893('0x1c')]=qs['limit'](_0x5d1f50[_0xd893('0x3c')][_0xd893('0x1c')]);_0x32be9c[_0xd893('0x19')]=qs[_0xd893('0x19')](_0x5d1f50[_0xd893('0x3c')][_0xd893('0x19')]);}return _0x151c8d[_0xd893('0xdc')](_0x32be9c);}})[_0xd893('0x20')](function(_0x442f66){if(_0x442f66){return _0x442f66?{'count':_0x43d894,'rows':_0x442f66}:null;}})[_0xd893('0x20')](respondWithResult(_0xd42a3b,null))[_0xd893('0x4d')](handleError(_0xd42a3b,null));};exports['getMailInteractions']=function(_0x3bb3f7,_0x212f61){var _0x149485={'raw':!![],'where':{}};var _0x3238f2={};var _0x19f625={'count':0x0,'rows':[]};return db[_0xd893('0x32')][_0xd893('0xc0')]({'where':{'id':_0x3bb3f7[_0xd893('0x4f')]['id']}})[_0xd893('0x20')](handleEntityNotFound(_0x212f61,null))[_0xd893('0x20')](function(_0x47cf84){if(_0x47cf84){_0x3238f2[_0xd893('0xc7')]=_['keys'](db[_0xd893('0xdd')][_0xd893('0x33')]);_0x3238f2['query']=_[_0xd893('0xc8')](_0x3bb3f7[_0xd893('0x3c')]);_0x3238f2[_0xd893('0xca')]=_[_0xd893('0xcb')](_0x3238f2['model'],_0x3238f2[_0xd893('0x3c')]);_0x149485[_0xd893('0x41')]=_[_0xd893('0xcb')](_0x3238f2['model'],qs['fields'](_0x3bb3f7[_0xd893('0x3c')][_0xd893('0xcc')]));_0x149485[_0xd893('0x41')]=_0x149485[_0xd893('0x41')]['length']?_0x149485[_0xd893('0x41')]:_0x3238f2[_0xd893('0xc7')];if(!_0x3bb3f7[_0xd893('0x3c')]['hasOwnProperty']('nolimit')){_0x149485[_0xd893('0x1c')]=qs[_0xd893('0x1c')](_0x3bb3f7[_0xd893('0x3c')][_0xd893('0x1c')]);_0x149485[_0xd893('0x19')]=qs[_0xd893('0x19')](_0x3bb3f7[_0xd893('0x3c')][_0xd893('0x19')]);}_0x149485[_0xd893('0xcd')]=qs[_0xd893('0xce')](_0x3bb3f7[_0xd893('0x3c')][_0xd893('0xce')]);_0x149485[_0xd893('0xcf')]=qs[_0xd893('0xca')](_[_0xd893('0xd0')](_0x3bb3f7[_0xd893('0x3c')],_0x3238f2[_0xd893('0xca')]));_0x149485[_0xd893('0xcf')][_0xd893('0xd7')]=_0x47cf84['id'];if(_0x3bb3f7[_0xd893('0x3c')][_0xd893('0x28')]){_0x149485[_0xd893('0xcf')]=_['merge'](_0x149485[_0xd893('0xcf')],{'$or':_[_0xd893('0x2a')](_0x149485[_0xd893('0x41')],function(_0x5d0022){var _0x5522d8={};_0x5522d8[_0x5d0022]={'$like':'%'+_0x3bb3f7[_0xd893('0x3c')][_0xd893('0x28')]+'%'};return _0x5522d8;})});}_0x149485=_[_0xd893('0x52')]({},_0x149485,_0x3bb3f7[_0xd893('0x53')]);return db[_0xd893('0xdd')][_0xd893('0x1b')]({'where':_0x149485[_0xd893('0xcf')]})[_0xd893('0x20')](function(_0x161d87){_0x19f625[_0xd893('0x1b')]=_0x161d87;if(_0x3bb3f7[_0xd893('0x3c')][_0xd893('0x51')]){_0x149485[_0xd893('0x3d')]=[{'all':!![]}];}return db[_0xd893('0xdd')][_0xd893('0x43')](_0x149485);})[_0xd893('0x20')](function(_0x5044ff){_0x19f625['rows']=_0x5044ff;return _0x19f625;});}})[_0xd893('0x20')](respondWithFilteredResult(_0x212f61,_0x149485))[_0xd893('0x4d')](handleError(_0x212f61,null));};exports[_0xd893('0xde')]=function(_0x390a88,_0x3cbc5c){var _0x31dff0={};var _0x54c710={};var _0x475102;var _0x21a6d8;return db['User'][_0xd893('0xc0')]({'where':{'id':_0x390a88[_0xd893('0x4f')]['id']}})[_0xd893('0x20')](handleEntityNotFound(_0x3cbc5c,null))['then'](function(_0x2185d1){if(_0x2185d1){_0x475102=_0x2185d1;_0x54c710[_0xd893('0xc7')]=_[_0xd893('0xc8')](db[_0xd893('0xdf')][_0xd893('0x33')]);_0x54c710['query']=_[_0xd893('0xc8')](_0x390a88[_0xd893('0x3c')]);_0x54c710['filters']=_[_0xd893('0xcb')](_0x54c710[_0xd893('0xc7')],_0x54c710[_0xd893('0x3c')]);_0x31dff0[_0xd893('0x41')]=_[_0xd893('0xcb')](_0x54c710[_0xd893('0xc7')],qs[_0xd893('0xcc')](_0x390a88[_0xd893('0x3c')]['fields']));_0x31dff0[_0xd893('0x41')]=_0x31dff0['attributes'][_0xd893('0x63')]?_0x31dff0['attributes']:_0x54c710[_0xd893('0xc7')];_0x31dff0[_0xd893('0xcd')]=qs['sort'](_0x390a88[_0xd893('0x3c')][_0xd893('0xce')]);_0x31dff0['where']=qs['filters'](_['pick'](_0x390a88[_0xd893('0x3c')],_0x54c710[_0xd893('0xca')]));if(_0x390a88[_0xd893('0x3c')][_0xd893('0x28')]){_0x31dff0[_0xd893('0xcf')]=_[_0xd893('0x52')](_0x31dff0[_0xd893('0xcf')],{'$or':_[_0xd893('0x2a')](_0x31dff0[_0xd893('0x41')],function(_0x5eb46b){var _0x7e1ef8={};_0x7e1ef8[_0x5eb46b]={'$like':'%'+_0x390a88[_0xd893('0x3c')]['filter']+'%'};return _0x7e1ef8;})});}_0x31dff0=_[_0xd893('0x52')]({},_0x31dff0,_0x390a88[_0xd893('0x53')]);return _0x475102[_0xd893('0xde')](_0x31dff0);}})['then'](function(_0x5c0845){if(_0x5c0845){_0x21a6d8=_0x5c0845[_0xd893('0x63')];if(!_0x390a88[_0xd893('0x3c')][_0xd893('0xc1')](_0xd893('0xd2'))){_0x31dff0['limit']=qs[_0xd893('0x1c')](_0x390a88[_0xd893('0x3c')]['limit']);_0x31dff0[_0xd893('0x19')]=qs[_0xd893('0x19')](_0x390a88['query'][_0xd893('0x19')]);}return _0x475102[_0xd893('0xde')](_0x31dff0);}})[_0xd893('0x20')](function(_0x53646f){if(_0x53646f){return _0x53646f?{'count':_0x21a6d8,'rows':_0x53646f}:null;}})[_0xd893('0x20')](respondWithResult(_0x3cbc5c,null))[_0xd893('0x4d')](handleError(_0x3cbc5c,null));};exports[_0xd893('0xe0')]=function(_0x227dbd,_0x4b0910){var _0xfb277c={};var _0x4f8ac9={};var _0x2503cf;var _0x4908a3;return db[_0xd893('0x32')][_0xd893('0xc0')]({'where':{'id':_0x227dbd[_0xd893('0x4f')]['id']}})['then'](handleEntityNotFound(_0x4b0910,null))['then'](function(_0xbdd3cd){if(_0xbdd3cd){_0x2503cf=_0xbdd3cd;_0x4f8ac9[_0xd893('0xc7')]=_[_0xd893('0xc8')](db[_0xd893('0xe1')][_0xd893('0x33')]);_0x4f8ac9[_0xd893('0x3c')]=_['keys'](_0x227dbd['query']);_0x4f8ac9[_0xd893('0xca')]=_['intersection'](_0x4f8ac9[_0xd893('0xc7')],_0x4f8ac9[_0xd893('0x3c')]);_0xfb277c[_0xd893('0x41')]=_[_0xd893('0xcb')](_0x4f8ac9[_0xd893('0xc7')],qs[_0xd893('0xcc')](_0x227dbd[_0xd893('0x3c')][_0xd893('0xcc')]));_0xfb277c[_0xd893('0x41')]=_0xfb277c['attributes'][_0xd893('0x63')]?_0xfb277c[_0xd893('0x41')]:_0x4f8ac9[_0xd893('0xc7')];_0xfb277c[_0xd893('0xcd')]=qs[_0xd893('0xce')](_0x227dbd[_0xd893('0x3c')][_0xd893('0xce')]);_0xfb277c[_0xd893('0xcf')]=qs[_0xd893('0xca')](_['pick'](_0x227dbd[_0xd893('0x3c')],_0x4f8ac9[_0xd893('0xca')]));if(_0x227dbd[_0xd893('0x3c')][_0xd893('0x28')]){_0xfb277c['where']=_[_0xd893('0x52')](_0xfb277c['where'],{'$or':_[_0xd893('0x2a')](_0xfb277c[_0xd893('0x41')],function(_0x395485){var _0x131d7a={};_0x131d7a[_0x395485]={'$like':'%'+_0x227dbd[_0xd893('0x3c')][_0xd893('0x28')]+'%'};return _0x131d7a;})});}_0xfb277c=_[_0xd893('0x52')]({},_0xfb277c,_0x227dbd[_0xd893('0x53')]);return _0x2503cf[_0xd893('0xe0')](_0xfb277c);}})[_0xd893('0x20')](function(_0x507d80){if(_0x507d80){_0x4908a3=_0x507d80[_0xd893('0x63')];if(!_0x227dbd[_0xd893('0x3c')][_0xd893('0xc1')]('nolimit')){_0xfb277c[_0xd893('0x1c')]=qs[_0xd893('0x1c')](_0x227dbd[_0xd893('0x3c')]['limit']);_0xfb277c[_0xd893('0x19')]=qs['offset'](_0x227dbd[_0xd893('0x3c')]['offset']);}return _0x2503cf[_0xd893('0xe0')](_0xfb277c);}})[_0xd893('0x20')](function(_0x1a53aa){if(_0x1a53aa){return _0x1a53aa?{'count':_0x4908a3,'rows':_0x1a53aa}:null;}})[_0xd893('0x20')](respondWithResult(_0x4b0910,null))[_0xd893('0x4d')](handleError(_0x4b0910,null));};exports[_0xd893('0xe2')]=function(_0x570ded,_0x2503ed){var _0x374739={};var _0x3322d7={};var _0xe2615a;var _0x1cad5f;return db[_0xd893('0x32')][_0xd893('0xc0')]({'where':{'id':_0x570ded[_0xd893('0x4f')]['id']}})[_0xd893('0x20')](handleEntityNotFound(_0x2503ed,null))[_0xd893('0x20')](function(_0x3011e8){if(_0x3011e8){_0xe2615a=_0x3011e8;_0x3322d7[_0xd893('0xc7')]=_[_0xd893('0xc8')](db[_0xd893('0xe3')][_0xd893('0x33')]);_0x3322d7[_0xd893('0x3c')]=_[_0xd893('0xc8')](_0x570ded[_0xd893('0x3c')]);_0x3322d7[_0xd893('0xca')]=_['intersection'](_0x3322d7[_0xd893('0xc7')],_0x3322d7[_0xd893('0x3c')]);_0x374739[_0xd893('0x41')]=_['intersection'](_0x3322d7[_0xd893('0xc7')],qs['fields'](_0x570ded['query']['fields']));_0x374739[_0xd893('0x41')]=_0x374739[_0xd893('0x41')][_0xd893('0x63')]?_0x374739[_0xd893('0x41')]:_0x3322d7[_0xd893('0xc7')];_0x374739[_0xd893('0xcd')]=qs[_0xd893('0xce')](_0x570ded[_0xd893('0x3c')][_0xd893('0xce')]);_0x374739['where']=qs[_0xd893('0xca')](_[_0xd893('0xd0')](_0x570ded[_0xd893('0x3c')],_0x3322d7[_0xd893('0xca')]));if(_0x570ded[_0xd893('0x3c')][_0xd893('0x28')]){_0x374739[_0xd893('0xcf')]=_[_0xd893('0x52')](_0x374739[_0xd893('0xcf')],{'$or':_[_0xd893('0x2a')](_0x374739[_0xd893('0x41')],function(_0xa02819){var _0x1c2dd9={};_0x1c2dd9[_0xa02819]={'$like':'%'+_0x570ded[_0xd893('0x3c')][_0xd893('0x28')]+'%'};return _0x1c2dd9;})});}_0x374739=_[_0xd893('0x52')]({},_0x374739,_0x570ded[_0xd893('0x53')]);return _0xe2615a['getWhatsappInteractions'](_0x374739);}})['then'](function(_0x4e45fd){if(_0x4e45fd){_0x1cad5f=_0x4e45fd['length'];if(!_0x570ded[_0xd893('0x3c')][_0xd893('0xc1')]('nolimit')){_0x374739[_0xd893('0x1c')]=qs[_0xd893('0x1c')](_0x570ded[_0xd893('0x3c')]['limit']);_0x374739[_0xd893('0x19')]=qs[_0xd893('0x19')](_0x570ded['query'][_0xd893('0x19')]);}return _0xe2615a['getWhatsappInteractions'](_0x374739);}})[_0xd893('0x20')](function(_0x5839d9){if(_0x5839d9){return _0x5839d9?{'count':_0x1cad5f,'rows':_0x5839d9}:null;}})[_0xd893('0x20')](respondWithResult(_0x2503ed,null))['catch'](handleError(_0x2503ed,null));};exports['login']=function(_0x5423f9,_0x3a6070,_0x2718ec){var _0x4f9fa7;var _0x497fd3;var _0x459263;var _0x1e1a7b=!_[_0xd893('0x5e')](_0x5423f9[_0xd893('0x4f')]['id'])?_0x5423f9[_0xd893('0x4f')]['id']:!_[_0xd893('0x5e')](_0x5423f9[_0xd893('0x27')]['id'])?_0x5423f9[_0xd893('0x27')]['id']:null;return db['User'][_0xd893('0x2d')]({'where':{'id':_0x1e1a7b,'role':{'$or':[_0xd893('0x26'),_0xd893('0x27'),_0xd893('0x21')]}},'attributes':['id',_0xd893('0x2f'),_0xd893('0xe4'),_0xd893('0xe5'),_0xd893('0x2e'),_0xd893('0x59'),_0xd893('0x93')]})[_0xd893('0x20')](function(_0x59b4f5){if(_0x59b4f5){if(_0x59b4f5[_0xd893('0x2e')]===_0xd893('0x21')){_0x4f9fa7=_0x59b4f5;if(_0x5423f9['body'][_0xd893('0x95')]){_0x459263=util[_0xd893('0xa0')](_0xd893('0xe6'),_0x4f9fa7[_0x5423f9['body'][_0xd893('0x95')]]);}else if(_0x5423f9['body'][_0xd893('0xe7')]){_0x459263=util[_0xd893('0xa0')]('SIP/%s',_0x5423f9[_0xd893('0x55')][_0xd893('0xe7')]);}else{_0x459263=util[_0xd893('0xa0')]('SIP/%s',_0x4f9fa7[_0xd893('0x2f')]);}socket['to'](util[_0xd893('0xa0')]('user:%s',_0x4f9fa7[_0xd893('0x2f')]))['emit'](_0xd893('0xe8'),{'user':{'id':_0x4f9fa7['id'],'name':_0x4f9fa7[_0xd893('0x2f')]},'ip':_0x5423f9[_0xd893('0xe9')]['x-forwarded-for']||_0x5423f9[_0xd893('0xea')]['remoteAddress']||_0x5423f9[_0xd893('0xeb')][_0xd893('0xec')]||_0x5423f9['connection'][_0xd893('0xeb')][_0xd893('0xec')]});return db['UserVoiceQueueRt'][_0xd893('0x24')]({'where':{'membername':_0x4f9fa7[_0xd893('0x2f')]},'individualHooks':!![]});}}else{throw new db[(_0xd893('0x87'))][(_0xd893('0x88'))](_0xd893('0xed'));}})['then'](function(){if(_0x4f9fa7){return _0x4f9fa7[_0xd893('0xee')]({'raw':!![]});}})['then'](function(_0x19c08c){if(_0x4f9fa7){if(_0x19c08c){_0x497fd3=_0x19c08c;if(_0x497fd3[_0xd893('0x63')]){var _0x29f642=_0x497fd3[_0xd893('0x2a')](function(_0x584c6b){var _0x37cfd5={'membername':_0x4f9fa7[_0xd893('0x2f')],'UserId':_0x4f9fa7['id'],'queue_name':_0x584c6b['name'],'VoiceQueueId':_0x584c6b['id'],'interface':_0x459263,'paused':_0x4f9fa7[_0xd893('0x93')]||![],'penalty':_0x584c6b['UserVoiceQueue.penalty']||0x0};return db['UserVoiceQueueRt'][_0xd893('0xa1')](_0x37cfd5);});return Promise['all'](_0x29f642);}}}})['then'](function(){if(_0x4f9fa7){return db[_0xd893('0xef')][_0xd893('0x43')]({'where':{'membername':_0x4f9fa7[_0xd893('0x2f')],'exitAt':null}});}})[_0xd893('0x20')](function(_0x373524){if(_0x4f9fa7){var _0x45d460=[];_0x373524[_0xd893('0xf0')](function(_0x446081){_0x45d460[_0xd893('0x42')](_0x446081['update']({'exitAt':moment()[_0xd893('0xa0')](_0xd893('0xf1'))}));});return Promise[_0xd893('0x4c')](_0x45d460);}})[_0xd893('0x20')](function(){if(_0x4f9fa7){var _0x51c45a=[];var _0x51a66e=[];var _0x30ca12=utils[_0xd893('0xf2')]();var _0x3c89d9={'membername':_0x4f9fa7[_0xd893('0x2f')],'interface':_0x459263,'enterAt':moment()[_0xd893('0xa0')]('YYYY-MM-DD\x20HH:mm:ss'),'role':_0x4f9fa7[_0xd893('0x2e')],'internal':_0x4f9fa7[_0xd893('0x59')]};_0x30ca12['forEach'](function(_0x1af7f2){_0x51c45a[_0xd893('0x42')](_['merge']({'channel':_0x1af7f2,'type':'LOGIN','data1':_0x5423f9['body'][_0xd893('0xf3')],'data2':_0x459263},_0x3c89d9));if(_0x4f9fa7[_0xd893('0x93')]){_0x51a66e[_0xd893('0x42')](_[_0xd893('0x52')]({'channel':_0x1af7f2,'type':_0xd893('0xf4'),'data1':'LOGININPAUSE'},_0x3c89d9));}});return db['MemberReport'][_0xd893('0x81')](_0x51c45a[_0xd893('0xbe')](_0x51a66e),{'individualHooks':!![]});}})[_0xd893('0x20')](function(){if(_0x4f9fa7){return _0x4f9fa7[_0xd893('0x1f')]({'online':!![],'lastLoginAt':moment()[_0xd893('0xa0')]('YYYY-MM-DD\x20HH:mm:ss'),'voicePause':_0x4f9fa7[_0xd893('0x93')]||![],'mailPause':_0x4f9fa7[_0xd893('0x93')]||![],'chatPause':_0x4f9fa7[_0xd893('0x93')]||![],'faxPause':_0x4f9fa7[_0xd893('0x93')]||![],'smsPause':_0x4f9fa7[_0xd893('0x93')]||![],'openchannelPause':_0x4f9fa7['loginInPause']||![],'whatsappPause':_0x4f9fa7[_0xd893('0x93')]||![],'pauseType':_0x4f9fa7[_0xd893('0x93')]?_0xd893('0xf5'):null,'interface':_0x459263,'lastPauseAt':moment()['format'](_0xd893('0xf1'))});}})['then'](function(_0xc0ba62){if(_0x5423f9[_0xd893('0xf6')]){return _0x2718ec();}else{return Promise[_0xd893('0xf7')](_0xc0ba62)[_0xd893('0x20')](respondWithResult(_0x3a6070,null));}})['catch'](handleError(_0x3a6070,null));};exports[_0xd893('0xf8')]=function(_0x3d81c1,_0x1dc22c){var _0x314c42;return db[_0xd893('0x32')]['find']({'where':{'id':_0x3d81c1[_0xd893('0x4f')]['id'],'role':_0xd893('0x21')},'attributes':['id',_0xd893('0x2f'),_0xd893('0x2e')]})[_0xd893('0x20')](handleEntityNotFound(_0x1dc22c,null))[_0xd893('0x20')](function(_0x54e561){if(_0x54e561){_0x314c42=_0x54e561;return db[_0xd893('0xa7')][_0xd893('0x24')]({'where':{'membername':_0x314c42[_0xd893('0x2f')]},'individualHooks':!![]});}})[_0xd893('0x20')](function(){return db['MemberReport']['findAll']({'where':{'membername':_0x314c42['name'],'exitAt':null}});})[_0xd893('0x20')](function(_0x2d562f){var _0x590d31=[];_0x2d562f['forEach'](function(_0x1dc46d){_0x590d31[_0xd893('0x42')](_0x1dc46d[_0xd893('0x1f')]({'exitAt':moment()[_0xd893('0xa0')](_0xd893('0xf1'))}));});return Promise[_0xd893('0x4c')](_0x590d31);})['then'](function(){return _0x314c42[_0xd893('0x1f')]({'online':![],'voicePause':![],'mailPause':![],'chatPause':![],'faxPause':![],'smsPause':![],'openchannelPause':![],'whatsappPause':![],'interface':null});})[_0xd893('0x20')](respondWithResult(_0x1dc22c,null))[_0xd893('0x4d')](handleError(_0x1dc22c,null));};exports[_0xd893('0xf9')]=function(_0x5d9fe9,_0x3f17cb){var _0x386167;return db[_0xd893('0xa7')][_0xd893('0x1f')]({'paused':0x1},{'where':{'UserId':_0x5d9fe9[_0xd893('0x4f')]['id']},'individualHooks':!![]})[_0xd893('0x20')](function(){return db[_0xd893('0x32')][_0xd893('0x2d')]({'where':{'id':_0x5d9fe9['params']['id'],'role':_0xd893('0x21')},'attributes':['id',_0xd893('0x2f'),_0xd893('0x2e'),_0xd893('0x59'),_0xd893('0x95'),_0xd893('0x9f')]});})[_0xd893('0x20')](handleEntityNotFound(_0x3f17cb,null))['then'](function(_0xf554d9){if(_0xf554d9){_0x386167=_0xf554d9;return db[_0xd893('0xef')][_0xd893('0x43')]({'where':{'membername':_0x386167[_0xd893('0x2f')],'type':'PAUSE','exitAt':null}});}})[_0xd893('0x20')](function(_0x5779a9){if(_0x5779a9[_0xd893('0x63')]){var _0x3d119d=moment()[_0xd893('0xa0')]('YYYY-MM-DD\x20HH:mm:ss');for(var _0x1aaa31=0x0,_0x77dc08=_0x5779a9[_0xd893('0x63')];_0x1aaa31<_0x77dc08;_0x1aaa31++){_0x5779a9[_0x1aaa31]['updateAttributes']({'exitAt':_0x3d119d});}}})[_0xd893('0x20')](function(){var _0x5fd67c=[];var _0x33ea59=utils[_0xd893('0xf2')]();_0x33ea59[_0xd893('0xf0')](function(_0x3c385c){_0x5fd67c[_0xd893('0x42')]({'channel':_0x3c385c,'membername':_0x386167[_0xd893('0x2f')],'interface':_['isNil'](_0x386167[_0xd893('0x95')])?util[_0xd893('0xa0')](_0xd893('0xfa'),_0x386167['name']):_0x386167[_0xd893('0x95')],'type':_0xd893('0xf4'),'enterAt':moment()[_0xd893('0xa0')]('YYYY-MM-DD\x20HH:mm:ss'),'data1':_0x5d9fe9[_0xd893('0x55')][_0xd893('0xfb')]||_0xd893('0xfc'),'role':_0x386167[_0xd893('0x2e')],'internal':_0x386167[_0xd893('0x59')]});});return db[_0xd893('0xef')][_0xd893('0x81')](_0x5fd67c,{'individualHooks':!![]});})[_0xd893('0x20')](function(){return _0x386167[_0xd893('0x1f')]({'voicePause':!![],'mailPause':!![],'chatPause':!![],'faxPause':!![],'smsPause':!![],'whatsappPause':!![],'openchannelPause':!![],'pauseType':_0x5d9fe9[_0xd893('0x55')][_0xd893('0xfb')]||_0xd893('0xfc'),'lastPauseAt':moment()[_0xd893('0xa0')](_0xd893('0xf1'))});})[_0xd893('0x20')](respondWithResult(_0x3f17cb,null))[_0xd893('0x4d')](handleError(_0x3f17cb,null));};exports[_0xd893('0xfd')]=function(_0x2cb652,_0x87916c){if(_0x2cb652[_0xd893('0x55')][_0xd893('0x92')]&&!utils['isValidChannel'](_0x2cb652[_0xd893('0x55')]['channel'])){throw new APIBadRequestError(util[_0xd893('0xa0')]('Channel\x20parameter\x20%s\x20is\x20invalid',_0x2cb652[_0xd893('0x55')][_0xd893('0x92')]));}return db[_0xd893('0x32')][_0xd893('0x2d')]({'where':{'id':_0x2cb652[_0xd893('0x4f')]['id']},'attributes':['id',_0xd893('0x2f'),'role',_0xd893('0x59'),_0xd893('0x95'),_0xd893('0x9f'),_0xd893('0x94'),_0xd893('0xfe'),'chatPause',_0xd893('0xff'),_0xd893('0x100'),'smsPause',_0xd893('0x101'),_0xd893('0x102'),_0xd893('0x103')]})[_0xd893('0x20')](function(_0x2b9589){if(!_0x2b9589){throw new APINotFoundError(util[_0xd893('0xa0')](_0xd893('0x104'),_0x2cb652[_0xd893('0x4f')]['id']));}return _0x2b9589[_0xd893('0xfd')](_0x2cb652[_0xd893('0x55')]['channel']);})['then'](respondWithResult(_0x87916c,null))[_0xd893('0x4d')](APIHandleError(_0x87916c));};exports[_0xd893('0x105')]=function(_0x13f295,_0x18084e){var _0x2f60f8={};var _0x3d1f8c={};var _0x2b8c6b;var _0x444a66;return db[_0xd893('0x32')][_0xd893('0xc0')]({'where':{'id':_0x13f295[_0xd893('0x4f')]['id']}})[_0xd893('0x20')](handleEntityNotFound(_0x18084e,null))[_0xd893('0x20')](function(_0x20f765){if(_0x20f765){_0x2b8c6b=_0x20f765;_0x3d1f8c[_0xd893('0xc7')]=_[_0xd893('0xc8')](db[_0xd893('0x106')][_0xd893('0x33')]);_0x3d1f8c[_0xd893('0x3c')]=_['keys'](_0x13f295['query']);_0x3d1f8c[_0xd893('0xca')]=_[_0xd893('0xcb')](_0x3d1f8c[_0xd893('0xc7')],_0x3d1f8c['query']);_0x2f60f8[_0xd893('0x41')]=_[_0xd893('0xcb')](_0x3d1f8c[_0xd893('0xc7')],qs[_0xd893('0xcc')](_0x13f295[_0xd893('0x3c')]['fields']));_0x2f60f8[_0xd893('0x41')]=_0x2f60f8[_0xd893('0x41')]['length']?_0x2f60f8[_0xd893('0x41')]:_0x3d1f8c[_0xd893('0xc7')];_0x2f60f8[_0xd893('0xcd')]=qs[_0xd893('0xce')](_0x13f295[_0xd893('0x3c')]['sort']);_0x2f60f8[_0xd893('0xcf')]=qs['filters'](_[_0xd893('0xd0')](_0x13f295['query'],_0x3d1f8c[_0xd893('0xca')]));if(_0x13f295[_0xd893('0x3c')][_0xd893('0x28')]){_0x2f60f8[_0xd893('0xcf')]=_['merge'](_0x2f60f8[_0xd893('0xcf')],{'$or':_['map'](_0x2f60f8[_0xd893('0x41')],function(_0x53d4a2){var _0x5855f8={};_0x5855f8[_0x53d4a2]={'$like':'%'+_0x13f295[_0xd893('0x3c')]['filter']+'%'};return _0x5855f8;})});}_0x2f60f8=_[_0xd893('0x52')]({},_0x2f60f8,_0x13f295[_0xd893('0x53')]);return _0x2b8c6b[_0xd893('0x105')](_0x2f60f8);}})[_0xd893('0x20')](function(_0x4aaf1b){if(_0x4aaf1b){_0x444a66=_0x4aaf1b[_0xd893('0x63')];if(!_0x13f295[_0xd893('0x3c')][_0xd893('0xc1')](_0xd893('0xd2'))){_0x2f60f8[_0xd893('0x1c')]=qs[_0xd893('0x1c')](_0x13f295[_0xd893('0x3c')]['limit']);_0x2f60f8['offset']=qs['offset'](_0x13f295[_0xd893('0x3c')][_0xd893('0x19')]);}return _0x2b8c6b[_0xd893('0x105')](_0x2f60f8);}})['then'](function(_0xc786e3){if(_0xc786e3){return _0xc786e3?{'count':_0x444a66,'rows':_0xc786e3}:null;}})[_0xd893('0x20')](respondWithResult(_0x18084e,null))[_0xd893('0x4d')](handleError(_0x18084e,null));};exports[_0xd893('0x107')]=function(_0x16ffe3,_0xaad984){var _0x500350=_0x16ffe3['params']['id'];var _0x19a4ad=_0x16ffe3[_0xd893('0x55')]?_0x16ffe3[_0xd893('0x55')][_0xd893('0x9b')]:null;var _0x41a734=[];return Promise[_0xd893('0xf7')]()[_0xd893('0x20')](function(){if(!_0x19a4ad)throw new APIBadRequestError('Body\x20parameter\x20\x27ids\x27\x20is\x20required');})['then'](function(){return db[_0xd893('0x32')][_0xd893('0xc0')]({'where':{'id':_0x500350}});})[_0xd893('0x20')](function(_0x8310e0){if(!_0x8310e0)throw new APINotFoundError(util['format'](_0xd893('0x104'),_0x16ffe3[_0xd893('0x4f')]['id']));return db[_0xd893('0x60')][_0xd893('0x108')](function(_0x7f8697){return _0x8310e0[_0xd893('0x107')](_0x19a4ad,{'transaction':_0x7f8697})[_0xd893('0x20')](function(){return db[_0xd893('0x106')][_0xd893('0x43')]({'where':{'id':{'$in':_0x19a4ad}}});})[_0xd893('0x20')](function(_0x494e6e){var _0x160f28=_[_0xd893('0x2a')](_0x494e6e,function(_0xa34262){return _0xa34262['getAssociatedQueues']();});return Promise[_0xd893('0x4c')](_0x160f28);})[_0xd893('0x20')](function(_0x2e9649){_0x41a734=_[_0xd893('0x109')](_0x2e9649);var _0x2b2d83=_[_0xd893('0x2a')](_0x41a734,function(_0x3a4cca){return _0x3a4cca['addAgent'](_0x8310e0['id'],{'transaction':_0x7f8697});});return Promise[_0xd893('0x4c')](_0x2b2d83);})[_0xd893('0x20')](function(){if(!_0x8310e0[_0xd893('0x9f')])return;var _0x1650de=_['filter'](_0x41a734,function(_0x259b0a){return _0x259b0a['getDataValue'](_0xd893('0x92'))==='Voice';});var _0x1e3ee3=_[_0xd893('0x2a')](_0x1650de,function(_0x35fdde){return db[_0xd893('0xa7')][_0xd893('0xa1')]({'membername':_0x8310e0[_0xd893('0x2f')],'UserId':_0x8310e0['id'],'queue_name':_0x35fdde[_0xd893('0x2f')],'VoiceQueueId':_0x35fdde['id'],'interface':_[_0xd893('0x5e')](_0x8310e0[_0xd893('0x95')])?util[_0xd893('0xa0')](_0xd893('0xfa'),_0x8310e0[_0xd893('0x2f')]):_0x8310e0[_0xd893('0x95')],'paused':_0x8310e0['voicePause']||![],'penalty':_0x8310e0[_0xd893('0x99')]},{'transaction':_0x7f8697});});return Promise[_0xd893('0x4c')](_0x1e3ee3);})[_0xd893('0x20')](function(){return db[_0xd893('0x10a')][_0xd893('0x43')]({'where':{'teamId':{'$in':_0x19a4ad}}});})[_0xd893('0x20')](function(_0xe82801){var _0xf77f15=_[_0xd893('0x2a')](_0xe82801,function(_0x432c8f){return db[_0xd893('0x10b')][_0xd893('0x74')]({'UserId':_0x8310e0['id'],'VoicePrefixId':_0x432c8f[_0xd893('0x10c')]},{'transaction':_0x7f8697});});return Promise['all'](_0xf77f15);});});})[_0xd893('0x20')](function(){for(var _0x52a67c=0x0;_0x52a67c<_0x41a734[_0xd893('0x63')];_0x52a67c++){var _0xa41039=_0x41a734[_0x52a67c]['getDataValue']('channel');var _0x576b37=_0xa41039+_0xd893('0x9c');socket[_0xd893('0x22')]('user'+_0xa41039+'Queue:save',{'UserId':_0x500350,['queueField']:_0x41a734[_0x52a67c]['id']});}})[_0xd893('0x20')](respondWithStatusCode(_0xaad984,null))[_0xd893('0x4d')](APIHandleError(_0xaad984));};exports[_0xd893('0x10d')]=function(_0x4173cc,_0x1c5b6e){var _0x54499a=_0x4173cc['params']['id'];var _0x35299b=null;if(_0x4173cc[_0xd893('0x3c')][_0xd893('0x9b')]){_0x35299b=_['isArray'](_0x4173cc[_0xd893('0x3c')]['ids'])?_0x4173cc[_0xd893('0x3c')][_0xd893('0x9b')]:[_0x4173cc[_0xd893('0x3c')][_0xd893('0x9b')]];}var _0x22a4e6=[];return Promise[_0xd893('0xf7')]()[_0xd893('0x20')](function(){if(!_0x35299b)throw new APIBadRequestError(_0xd893('0x10e'));})[_0xd893('0x20')](function(){return db['User'][_0xd893('0xc0')]({'where':{'id':_0x54499a}});})[_0xd893('0x20')](function(_0x16eece){if(!_0x16eece)throw new APINotFoundError(util['format'](_0xd893('0x104'),_0x4173cc['params']['id']));return db['sequelize'][_0xd893('0x108')](function(_0x42ae64){return _0x16eece[_0xd893('0x10d')](_0x35299b,{'transaction':_0x42ae64})[_0xd893('0x20')](function(){return db['Team'][_0xd893('0x43')]({'where':{'id':{'$in':_0x35299b}}});})[_0xd893('0x20')](function(_0x36538b){var _0x5515e9=_[_0xd893('0x2a')](_0x36538b,function(_0x302fa4){return _0x302fa4[_0xd893('0x10f')]();});return Promise[_0xd893('0x4c')](_0x5515e9);})[_0xd893('0x20')](function(_0x472776){_0x22a4e6=_['flattenDeep'](_0x472776);var _0x3d52f4=_[_0xd893('0x2a')](_0x22a4e6,function(_0xc16fdf){return _0xc16fdf[_0xd893('0x110')](_0x16eece['id'],{'transaction':_0x42ae64});});return Promise['all'](_0x3d52f4);})[_0xd893('0x20')](function(){if(!_0x16eece[_0xd893('0x9f')])return;var _0x31f081=_[_0xd893('0x28')](_0x22a4e6,function(_0x353cce){return _0x353cce[_0xd893('0x111')](_0xd893('0x92'))==='Voice';});var _0x405bb2=_[_0xd893('0x2a')](_0x31f081,function(_0x2f9196){return db[_0xd893('0xa7')][_0xd893('0x24')]({'where':{'VoiceQueueId':_0x2f9196['id'],'UserId':_0x16eece['id']},'transaction':_0x42ae64});});return Promise['all'](_0x405bb2);})['then'](function(){return db[_0xd893('0x10a')][_0xd893('0x43')]({'where':{'teamId':{'$in':_0x35299b}}});})['then'](function(_0x58685c){var _0x3a54b0=_[_0xd893('0x2a')](_0x58685c,function(_0x14adb8){return db[_0xd893('0x10b')]['destroy']({'where':{'UserId':_0x16eece['id'],'VoicePrefixId':_0x14adb8[_0xd893('0x10c')]}},{'transaction':_0x42ae64});});return Promise[_0xd893('0x4c')](_0x3a54b0);});});})[_0xd893('0x20')](function(){for(var _0x53c151=0x0;_0x53c151<_0x22a4e6[_0xd893('0x63')];_0x53c151++){var _0x283689=_0x22a4e6[_0x53c151][_0xd893('0x111')]('channel');var _0xf7571a=_0x283689+_0xd893('0x9c');socket[_0xd893('0x22')]('user'+_0x283689+_0xd893('0xa6'),{'UserId':_0x54499a,['queueField']:_0x22a4e6[_0x53c151]['id']});}})[_0xd893('0x20')](respondWithStatusCode(_0x1c5b6e,null))[_0xd893('0x4d')](APIHandleError(_0x1c5b6e));};exports[_0xd893('0x112')]=function(_0x13a8cd,_0x3491e4){var _0x15ace5={};var _0x2e0182={};var _0x3f0dbb;var _0x2e88d4;return db[_0xd893('0x32')][_0xd893('0xc0')]({'where':{'id':_0x13a8cd[_0xd893('0x4f')]['id']}})[_0xd893('0x20')](handleEntityNotFound(_0x3491e4,null))[_0xd893('0x20')](function(_0x1ff035){if(_0x1ff035){_0x3f0dbb=_0x1ff035;_0x2e0182['model']=_[_0xd893('0xc8')](db[_0xd893('0xc2')]['rawAttributes']);_0x2e0182[_0xd893('0x3c')]=_[_0xd893('0xc8')](_0x13a8cd[_0xd893('0x3c')]);_0x2e0182[_0xd893('0xca')]=_[_0xd893('0xcb')](_0x2e0182['model'],_0x2e0182[_0xd893('0x3c')]);_0x15ace5[_0xd893('0x41')]=_['intersection'](_0x2e0182['model'],qs[_0xd893('0xcc')](_0x13a8cd[_0xd893('0x3c')]['fields']));_0x15ace5['attributes']=_0x15ace5[_0xd893('0x41')][_0xd893('0x63')]?_0x15ace5[_0xd893('0x41')]:_0x2e0182[_0xd893('0xc7')];_0x15ace5[_0xd893('0xcd')]=qs[_0xd893('0xce')](_0x13a8cd[_0xd893('0x3c')][_0xd893('0xce')]);_0x15ace5[_0xd893('0xcf')]=qs['filters'](_['pick'](_0x13a8cd[_0xd893('0x3c')],_0x2e0182[_0xd893('0xca')]));if(_0x13a8cd['query']['filter']){_0x15ace5[_0xd893('0xcf')]=_[_0xd893('0x52')](_0x15ace5[_0xd893('0xcf')],{'$or':_[_0xd893('0x2a')](_0x15ace5['attributes'],function(_0x32c754){var _0x2a3dbb={};_0x2a3dbb[_0x32c754]={'$like':'%'+_0x13a8cd[_0xd893('0x3c')][_0xd893('0x28')]+'%'};return _0x2a3dbb;})});}_0x15ace5=_[_0xd893('0x52')]({},_0x15ace5,_0x13a8cd[_0xd893('0x53')]);return _0x3f0dbb[_0xd893('0x112')](_0x15ace5);}})[_0xd893('0x20')](function(_0x29c39f){if(_0x29c39f){_0x2e88d4=_0x29c39f['length'];if(!_0x13a8cd['query'][_0xd893('0xc1')](_0xd893('0xd2'))){_0x15ace5[_0xd893('0x1c')]=qs[_0xd893('0x1c')](_0x13a8cd['query'][_0xd893('0x1c')]);_0x15ace5[_0xd893('0x19')]=qs['offset'](_0x13a8cd[_0xd893('0x3c')][_0xd893('0x19')]);}return _0x3f0dbb[_0xd893('0x112')](_0x15ace5);}})[_0xd893('0x20')](function(_0x2e95c0){if(_0x2e95c0){return _0x2e95c0?{'count':_0x2e88d4,'rows':_0x2e95c0}:null;}})[_0xd893('0x20')](respondWithResult(_0x3491e4,null))[_0xd893('0x4d')](handleError(_0x3491e4,null));};exports[_0xd893('0x113')]=function(_0x41f5c0,_0x594d89){var _0x39d4cd={};var _0x1a63f5={};var _0xe481f0;return db[_0xd893('0x32')]['findOne']({'where':{'id':_0x41f5c0[_0xd893('0x4f')]['id']}})['then'](handleEntityNotFound(_0x594d89,null))[_0xd893('0x20')](function(_0x470337){if(_0x470337){_0xe481f0=_0x470337;_0x1a63f5[_0xd893('0xc7')]=_['keys'](db[_0xd893('0x32')][_0xd893('0x33')]);_0x1a63f5[_0xd893('0x3c')]=_['keys'](_0x41f5c0[_0xd893('0x3c')]);_0x1a63f5['filters']=_[_0xd893('0xcb')](_0x1a63f5[_0xd893('0xc7')],_0x1a63f5[_0xd893('0x3c')]);_0x39d4cd['attributes']=_['intersection'](_0x1a63f5['model'],qs[_0xd893('0xcc')](_0x41f5c0[_0xd893('0x3c')][_0xd893('0xcc')]));_0x39d4cd[_0xd893('0x41')]=_0x39d4cd[_0xd893('0x41')]['length']?_0x39d4cd[_0xd893('0x41')]:_0x1a63f5[_0xd893('0xc7')];_0x39d4cd[_0xd893('0xcd')]=qs[_0xd893('0xce')](_0x41f5c0[_0xd893('0x3c')][_0xd893('0xce')]);_0x39d4cd[_0xd893('0xcf')]=qs[_0xd893('0xca')](_[_0xd893('0xd0')](_0x41f5c0[_0xd893('0x3c')],_0x1a63f5[_0xd893('0xca')]));if(_0x41f5c0['query'][_0xd893('0x28')]){_0x39d4cd[_0xd893('0xcf')]=_[_0xd893('0x52')](_0x39d4cd['where'],{'$or':_[_0xd893('0x2a')](_0x39d4cd['attributes'],function(_0x17301a){var _0x4f535c={};_0x4f535c[_0x17301a]={'$like':'%'+_0x41f5c0[_0xd893('0x3c')][_0xd893('0x28')]+'%'};return _0x4f535c;})});}_0x39d4cd[_0xd893('0xc7')]=db['User'];_0x39d4cd['as']=_0xd893('0x7c');_0x39d4cd=_[_0xd893('0x52')]({},_0x39d4cd,_0x41f5c0[_0xd893('0x53')]);return _0xe481f0[_0xd893('0xee')]({'include':[_0x39d4cd]});}})['then'](function(_0xaf2990){if(_0xaf2990){var _0x10c6ea={},_0x32f5d2=[];for(var _0x1f20fc=0x0;_0x1f20fc<_0xaf2990[_0xd893('0x63')];_0x1f20fc+=0x1){for(var _0x5cb2c1=0x0,_0xaf0cd4;_0x5cb2c1<_0xaf2990[_0x1f20fc][_0xd893('0x7c')][_0xd893('0x63')];_0x5cb2c1+=0x1){_0xaf0cd4=_0xaf2990[_0x1f20fc][_0xd893('0x7c')][_0x5cb2c1]['get']({'plain':!![]});_0x10c6ea[_0xaf0cd4['id']]=_0xaf0cd4;}}_0x10c6ea=_[_0xd893('0x114')](_0x10c6ea);for(var _0x537f89=qs[_0xd893('0x19')](_0x41f5c0[_0xd893('0x3c')][_0xd893('0x19')]);_0x537f89<_0x10c6ea[_0xd893('0x63')]&&_0x32f5d2['length']<qs['limit'](_0x41f5c0[_0xd893('0x3c')]['limit']);_0x537f89+=0x1){if(_0x10c6ea[_0x537f89]){_0x32f5d2[_0xd893('0x42')](_0x10c6ea[_0x537f89]);}}return{'count':_0x10c6ea['length'],'rows':_0x32f5d2};}})[_0xd893('0x20')](respondWithResult(_0x594d89,null))[_0xd893('0x4d')](handleError(_0x594d89,null));};exports[_0xd893('0x24')]=function(_0x18215d,_0x1377bf){if(_0x18215d[_0xd893('0x27')]['id']==_0x18215d['params']['id']){return _0x1377bf[_0xd893('0x17')](0x1f4)[_0xd893('0x31')]({'message':_0xd893('0x115')});}return db['User'][_0xd893('0x2d')]({'where':{'id':_0x18215d['params']['id']}})[_0xd893('0x20')](handleEntityNotFound(_0x1377bf,null))[_0xd893('0x20')](removeEntity(_0x1377bf,null))['catch'](handleError(_0x1377bf,null));};exports['addChatInteractions']=function(_0x454888,_0x1f9ee6){return db[_0xd893('0x32')][_0xd893('0x2d')]({'where':{'id':_0x454888[_0xd893('0x4f')]['id']}})[_0xd893('0x20')](handleEntityNotFound(_0x1f9ee6,null))[_0xd893('0x20')](function(_0x1ba881){if(_0x1ba881){return _0x1ba881[_0xd893('0x116')](_0x454888[_0xd893('0x55')][_0xd893('0x9b')],_[_0xd893('0x58')](_0x454888[_0xd893('0x55')],[_0xd893('0x9b'),'id'])||{})[_0xd893('0x9a')](function(){for(var _0x2a7631=0x0;_0x2a7631<_0x454888[_0xd893('0x55')][_0xd893('0x9b')][_0xd893('0x63')];_0x2a7631+=0x1){socket['emit'](_0xd893('0x117'),{'ChatInteractionId':Number(_0x454888[_0xd893('0x55')][_0xd893('0x9b')][_0x2a7631]),'UserId':Number(_0x454888[_0xd893('0x4f')]['id'])});}return _0x454888[_0xd893('0x55')][_0xd893('0x9b')];});}})['then'](respondWithResult(_0x1f9ee6,null))[_0xd893('0x4d')](handleError(_0x1f9ee6,null));};exports['removeChatInteractions']=function(_0x3920a5,_0x39dec4){return db['User'][_0xd893('0x2d')]({'where':{'id':_0x3920a5[_0xd893('0x4f')]['id']}})[_0xd893('0x20')](handleEntityNotFound(_0x39dec4,null))[_0xd893('0x20')](function(_0x48074d){if(_0x48074d){return _0x48074d[_0xd893('0x118')](_0x3920a5[_0xd893('0x3c')][_0xd893('0x9b')])[_0xd893('0x20')](function(){if(_[_0xd893('0xa5')](_0x3920a5[_0xd893('0x3c')]['ids'])){for(var _0xdf2106=0x0;_0xdf2106<_0x3920a5[_0xd893('0x3c')]['ids']['length'];_0xdf2106+=0x1){socket[_0xd893('0x22')](_0xd893('0x119'),{'ChatInteractionId':Number(_0x3920a5[_0xd893('0x3c')][_0xd893('0x9b')][_0xdf2106]),'UserId':Number(_0x3920a5[_0xd893('0x4f')]['id'])});}}else{socket[_0xd893('0x22')](_0xd893('0x119'),{'ChatInteractionId':Number(_0x3920a5[_0xd893('0x3c')]['ids']),'UserId':Number(_0x3920a5[_0xd893('0x4f')]['id'])});}});}})[_0xd893('0x20')](respondWithStatusCode(_0x39dec4,null))[_0xd893('0x4d')](handleError(_0x39dec4,null));};exports[_0xd893('0x11a')]=function(_0x9e5f03,_0x4e077a){return db[_0xd893('0x32')][_0xd893('0x2d')]({'where':{'id':_0x9e5f03['params']['id']}})[_0xd893('0x20')](handleEntityNotFound(_0x4e077a,null))[_0xd893('0x20')](function(_0x973cf9){if(_0x973cf9){return _0x973cf9[_0xd893('0x11a')](_0x9e5f03[_0xd893('0x55')]['ids'],_[_0xd893('0x58')](_0x9e5f03[_0xd893('0x55')],[_0xd893('0x9b'),'id'])||{})[_0xd893('0x9a')](function(){for(var _0x11f5e0=0x0;_0x11f5e0<_0x9e5f03[_0xd893('0x55')][_0xd893('0x9b')][_0xd893('0x63')];_0x11f5e0+=0x1){socket[_0xd893('0x22')](_0xd893('0x11b'),{'MailInteractionId':Number(_0x9e5f03['body'][_0xd893('0x9b')][_0x11f5e0]),'UserId':Number(_0x9e5f03[_0xd893('0x4f')]['id'])});}return _0x9e5f03[_0xd893('0x55')][_0xd893('0x9b')];});}})['then'](respondWithResult(_0x4e077a,null))[_0xd893('0x4d')](handleError(_0x4e077a,null));};exports[_0xd893('0x11c')]=function(_0x503256,_0x42c501){return db[_0xd893('0x32')][_0xd893('0x2d')]({'where':{'id':_0x503256['params']['id']}})[_0xd893('0x20')](handleEntityNotFound(_0x42c501,null))[_0xd893('0x20')](function(_0x136a02){if(_0x136a02){return _0x136a02[_0xd893('0x11c')](_0x503256[_0xd893('0x3c')]['ids'])[_0xd893('0x20')](function(){if(_[_0xd893('0xa5')](_0x503256[_0xd893('0x3c')][_0xd893('0x9b')])){for(var _0x2a3efa=0x0;_0x2a3efa<_0x503256[_0xd893('0x3c')][_0xd893('0x9b')][_0xd893('0x63')];_0x2a3efa+=0x1){socket[_0xd893('0x22')]('user_has_mail_interactions:remove',{'MailInteractionId':Number(_0x503256[_0xd893('0x3c')][_0xd893('0x9b')][_0x2a3efa]),'UserId':Number(_0x503256[_0xd893('0x4f')]['id'])});}}else{socket[_0xd893('0x22')](_0xd893('0x11d'),{'MailInteractionId':Number(_0x503256[_0xd893('0x3c')][_0xd893('0x9b')]),'UserId':Number(_0x503256[_0xd893('0x4f')]['id'])});}});}})[_0xd893('0x20')](respondWithStatusCode(_0x42c501,null))[_0xd893('0x4d')](handleError(_0x42c501,null));};exports[_0xd893('0x11e')]=function(_0x5352bc,_0x34640d){return db['User'][_0xd893('0x2d')]({'where':{'id':_0x5352bc[_0xd893('0x4f')]['id']}})[_0xd893('0x20')](handleEntityNotFound(_0x34640d,null))[_0xd893('0x20')](function(_0xdc0c0e){if(_0xdc0c0e){return _0xdc0c0e[_0xd893('0x11e')](_0x5352bc[_0xd893('0x55')][_0xd893('0x9b')],_[_0xd893('0x58')](_0x5352bc[_0xd893('0x55')],[_0xd893('0x9b'),'id'])||{})[_0xd893('0x9a')](function(){for(var _0x1969b2=0x0;_0x1969b2<_0x5352bc[_0xd893('0x55')]['ids'][_0xd893('0x63')];_0x1969b2+=0x1){socket[_0xd893('0x22')](_0xd893('0x11f'),{'FaxInteractionId':Number(_0x5352bc[_0xd893('0x55')][_0xd893('0x9b')][_0x1969b2]),'UserId':Number(_0x5352bc[_0xd893('0x4f')]['id'])});}return _0x5352bc[_0xd893('0x55')][_0xd893('0x9b')];});}})[_0xd893('0x20')](respondWithResult(_0x34640d,null))[_0xd893('0x4d')](handleError(_0x34640d,null));};exports[_0xd893('0x120')]=function(_0x111864,_0x470ff0){return db['User'][_0xd893('0x2d')]({'where':{'id':_0x111864['params']['id']}})[_0xd893('0x20')](handleEntityNotFound(_0x470ff0,null))[_0xd893('0x20')](function(_0x4bace0){if(_0x4bace0){return _0x4bace0[_0xd893('0x120')](_0x111864['query'][_0xd893('0x9b')])[_0xd893('0x20')](function(){if(_[_0xd893('0xa5')](_0x111864['query'][_0xd893('0x9b')])){for(var _0x310323=0x0;_0x310323<_0x111864['query']['ids'][_0xd893('0x63')];_0x310323+=0x1){socket['emit'](_0xd893('0x121'),{'FaxInteractionId':Number(_0x111864[_0xd893('0x3c')]['ids'][_0x310323]),'UserId':Number(_0x111864[_0xd893('0x4f')]['id'])});}}else{socket[_0xd893('0x22')](_0xd893('0x121'),{'FaxInteractionId':Number(_0x111864[_0xd893('0x3c')][_0xd893('0x9b')]),'UserId':Number(_0x111864['params']['id'])});}});}})[_0xd893('0x20')](respondWithStatusCode(_0x470ff0,null))['catch'](handleError(_0x470ff0,null));};exports[_0xd893('0x122')]=function(_0x4f7cb8,_0x3efa7b){return db['User'][_0xd893('0x2d')]({'where':{'id':_0x4f7cb8[_0xd893('0x4f')]['id']}})[_0xd893('0x20')](handleEntityNotFound(_0x3efa7b,null))['then'](function(_0xf55e76){if(_0xf55e76){return _0xf55e76[_0xd893('0x122')](_0x4f7cb8['body'][_0xd893('0x9b')],_['omit'](_0x4f7cb8[_0xd893('0x55')],[_0xd893('0x9b'),'id'])||{})[_0xd893('0x9a')](function(){for(var _0x34e6f0=0x0;_0x34e6f0<_0x4f7cb8[_0xd893('0x55')]['ids']['length'];_0x34e6f0+=0x1){socket['emit']('user_has_sms_interactions:save',{'SmsInteractionId':Number(_0x4f7cb8[_0xd893('0x55')][_0xd893('0x9b')][_0x34e6f0]),'UserId':Number(_0x4f7cb8[_0xd893('0x4f')]['id'])});}return _0x4f7cb8[_0xd893('0x55')][_0xd893('0x9b')];});}})[_0xd893('0x20')](respondWithResult(_0x3efa7b,null))[_0xd893('0x4d')](handleError(_0x3efa7b,null));};exports[_0xd893('0x123')]=function(_0x1b5b0e,_0x25153a){return db['User']['find']({'where':{'id':_0x1b5b0e['params']['id']}})['then'](handleEntityNotFound(_0x25153a,null))[_0xd893('0x20')](function(_0x4add92){if(_0x4add92){return _0x4add92[_0xd893('0x123')](_0x1b5b0e[_0xd893('0x3c')]['ids'])['then'](function(){if(_[_0xd893('0xa5')](_0x1b5b0e[_0xd893('0x3c')]['ids'])){for(var _0x566a13=0x0;_0x566a13<_0x1b5b0e['query']['ids'][_0xd893('0x63')];_0x566a13+=0x1){socket[_0xd893('0x22')](_0xd893('0x124'),{'SmsInteractionId':Number(_0x1b5b0e[_0xd893('0x3c')][_0xd893('0x9b')][_0x566a13]),'UserId':Number(_0x1b5b0e[_0xd893('0x4f')]['id'])});}}else{socket[_0xd893('0x22')]('user_has_sms_interactions:remove',{'SmsInteractionId':Number(_0x1b5b0e['query'][_0xd893('0x9b')]),'UserId':Number(_0x1b5b0e['params']['id'])});}});}})[_0xd893('0x20')](respondWithStatusCode(_0x25153a,null))['catch'](handleError(_0x25153a,null));};exports[_0xd893('0x125')]=function(_0x56146c,_0x41cad2){return db[_0xd893('0x32')][_0xd893('0x2d')]({'where':{'id':_0x56146c[_0xd893('0x4f')]['id']}})[_0xd893('0x20')](handleEntityNotFound(_0x41cad2,null))[_0xd893('0x20')](function(_0x2d3842){if(_0x2d3842){return _0x2d3842[_0xd893('0x125')](_0x56146c[_0xd893('0x55')][_0xd893('0x9b')],_[_0xd893('0x58')](_0x56146c[_0xd893('0x55')],[_0xd893('0x9b'),'id'])||{})[_0xd893('0x9a')](function(){for(var _0x1bf944=0x0;_0x1bf944<_0x56146c[_0xd893('0x55')][_0xd893('0x9b')][_0xd893('0x63')];_0x1bf944+=0x1){socket['emit']('user_has_openchannel_interactions:save',{'OpenchannelInteractionId':Number(_0x56146c[_0xd893('0x55')][_0xd893('0x9b')][_0x1bf944]),'UserId':Number(_0x56146c['params']['id'])});}return _0x56146c['body']['ids'];});}})[_0xd893('0x20')](respondWithResult(_0x41cad2,null))[_0xd893('0x4d')](handleError(_0x41cad2,null));};exports[_0xd893('0x126')]=function(_0x3fe5a0,_0x2c5800){return db['User']['find']({'where':{'id':_0x3fe5a0[_0xd893('0x4f')]['id']}})[_0xd893('0x20')](handleEntityNotFound(_0x2c5800,null))[_0xd893('0x20')](function(_0x1c9a0b){if(_0x1c9a0b){return _0x1c9a0b[_0xd893('0x126')](_0x3fe5a0[_0xd893('0x3c')][_0xd893('0x9b')])[_0xd893('0x20')](function(){if(_['isArray'](_0x3fe5a0[_0xd893('0x3c')][_0xd893('0x9b')])){for(var _0x4ba5b4=0x0;_0x4ba5b4<_0x3fe5a0['query'][_0xd893('0x9b')][_0xd893('0x63')];_0x4ba5b4+=0x1){socket[_0xd893('0x22')](_0xd893('0x127'),{'OpenchannelInteractionId':Number(_0x3fe5a0[_0xd893('0x3c')][_0xd893('0x9b')][_0x4ba5b4]),'UserId':Number(_0x3fe5a0['params']['id'])});}}else{socket[_0xd893('0x22')](_0xd893('0x127'),{'OpenchannelInteractionId':Number(_0x3fe5a0['query'][_0xd893('0x9b')]),'UserId':Number(_0x3fe5a0[_0xd893('0x4f')]['id'])});}});}})['then'](respondWithStatusCode(_0x2c5800,null))[_0xd893('0x4d')](handleError(_0x2c5800,null));};exports[_0xd893('0x128')]=function(_0x30f8e6,_0x1ea16b){return db[_0xd893('0x32')][_0xd893('0x2d')]({'where':{'id':_0x30f8e6[_0xd893('0x4f')]['id']}})[_0xd893('0x20')](handleEntityNotFound(_0x1ea16b,null))[_0xd893('0x20')](function(_0xd3d799){if(_0xd3d799){return _0xd3d799['addWhatsappInteractions'](_0x30f8e6[_0xd893('0x55')][_0xd893('0x9b')],_[_0xd893('0x58')](_0x30f8e6['body'],[_0xd893('0x9b'),'id'])||{})[_0xd893('0x9a')](function(){for(var _0x2b7c2b=0x0;_0x2b7c2b<_0x30f8e6[_0xd893('0x55')][_0xd893('0x9b')][_0xd893('0x63')];_0x2b7c2b+=0x1){socket['emit']('user_has_whatsapp_interactions:save',{'WhatsappInteractionId':Number(_0x30f8e6['body'][_0xd893('0x9b')][_0x2b7c2b]),'UserId':Number(_0x30f8e6[_0xd893('0x4f')]['id'])});}return _0x30f8e6[_0xd893('0x55')][_0xd893('0x9b')];});}})[_0xd893('0x20')](respondWithResult(_0x1ea16b,null))[_0xd893('0x4d')](handleError(_0x1ea16b,null));};exports[_0xd893('0x129')]=function(_0x237f6f,_0x56d160){return db['User'][_0xd893('0x2d')]({'where':{'id':_0x237f6f[_0xd893('0x4f')]['id']}})[_0xd893('0x20')](handleEntityNotFound(_0x56d160,null))[_0xd893('0x20')](function(_0x199488){if(_0x199488){return _0x199488['removeWhatsappInteractions'](_0x237f6f[_0xd893('0x3c')][_0xd893('0x9b')]);}})['then'](respondWithStatusCode(_0x56d160,null))[_0xd893('0x4d')](handleError(_0x56d160,null));};exports[_0xd893('0x12a')]=function(_0x1982d4,_0x1cb7c4){var _0x3b6a87={};var _0x2bda32={};var _0x91a69a;var _0x2d7544;return db['User'][_0xd893('0xc0')]({'where':{'id':_0x1982d4[_0xd893('0x4f')]['id']}})[_0xd893('0x20')](handleEntityNotFound(_0x1cb7c4,null))['then'](function(_0x394627){if(_0x394627){_0x91a69a=_0x394627;_0x2bda32['model']=_[_0xd893('0xc8')](db[_0xd893('0x12b')][_0xd893('0x33')]);_0x2bda32[_0xd893('0x3c')]=_[_0xd893('0xc8')](_0x1982d4[_0xd893('0x3c')]);_0x2bda32[_0xd893('0xca')]=_[_0xd893('0xcb')](_0x2bda32[_0xd893('0xc7')],_0x2bda32[_0xd893('0x3c')]);_0x3b6a87[_0xd893('0x41')]=_['intersection'](_0x2bda32[_0xd893('0xc7')],qs[_0xd893('0xcc')](_0x1982d4['query'][_0xd893('0xcc')]));_0x3b6a87[_0xd893('0x41')]=_0x3b6a87[_0xd893('0x41')][_0xd893('0x63')]?_0x3b6a87[_0xd893('0x41')]:_0x2bda32[_0xd893('0xc7')];_0x3b6a87[_0xd893('0xcd')]=qs['sort'](_0x1982d4['query'][_0xd893('0xce')]);_0x3b6a87[_0xd893('0xcf')]=qs[_0xd893('0xca')](_[_0xd893('0xd0')](_0x1982d4[_0xd893('0x3c')],_0x2bda32[_0xd893('0xca')]));if(_0x1982d4['query'][_0xd893('0x28')]){_0x3b6a87[_0xd893('0xcf')]=_[_0xd893('0x52')](_0x3b6a87[_0xd893('0xcf')],{'$or':_[_0xd893('0x2a')](_0x3b6a87[_0xd893('0x41')],function(_0x138e5d){var _0x543868={};_0x543868[_0x138e5d]={'$like':'%'+_0x1982d4['query'][_0xd893('0x28')]+'%'};return _0x543868;})});}_0x3b6a87=_['merge']({},_0x3b6a87,_0x1982d4[_0xd893('0x53')]);return _0x91a69a[_0xd893('0x12a')](_0x3b6a87);}})[_0xd893('0x20')](function(_0x2385bb){if(_0x2385bb){_0x2d7544=_0x2385bb[_0xd893('0x63')];if(!_0x1982d4[_0xd893('0x3c')]['hasOwnProperty'](_0xd893('0xd2'))){_0x3b6a87['limit']=qs[_0xd893('0x1c')](_0x1982d4['query'][_0xd893('0x1c')]);_0x3b6a87[_0xd893('0x19')]=qs[_0xd893('0x19')](_0x1982d4[_0xd893('0x3c')][_0xd893('0x19')]);}return _0x91a69a[_0xd893('0x12a')](_0x3b6a87);}})[_0xd893('0x20')](function(_0x5ace79){if(_0x5ace79){return _0x5ace79?{'count':_0x2d7544,'rows':_0x5ace79}:null;}})[_0xd893('0x20')](respondWithResult(_0x1cb7c4,null))['catch'](handleError(_0x1cb7c4,null));};exports[_0xd893('0x12c')]=function(_0x2d7c69,_0xb74d6a){var _0x262e84={};var _0x4ed3ac={};var _0x2c683f;var _0x22d8a6;return db['User']['findOne']({'where':{'id':_0x2d7c69[_0xd893('0x4f')]['id']}})['then'](handleEntityNotFound(_0xb74d6a,null))[_0xd893('0x20')](function(_0x44e5b6){if(_0x44e5b6){_0x2c683f=_0x44e5b6;_0x4ed3ac[_0xd893('0xc7')]=_[_0xd893('0xc8')](db[_0xd893('0x12d')][_0xd893('0x33')]);_0x4ed3ac[_0xd893('0x3c')]=_[_0xd893('0xc8')](_0x2d7c69[_0xd893('0x3c')]);_0x4ed3ac[_0xd893('0xca')]=_[_0xd893('0xcb')](_0x4ed3ac['model'],_0x4ed3ac[_0xd893('0x3c')]);_0x262e84[_0xd893('0x41')]=_[_0xd893('0xcb')](_0x4ed3ac[_0xd893('0xc7')],qs['fields'](_0x2d7c69[_0xd893('0x3c')]['fields']));_0x262e84[_0xd893('0x41')]=_0x262e84[_0xd893('0x41')]['length']?_0x262e84['attributes']:_0x4ed3ac[_0xd893('0xc7')];_0x262e84[_0xd893('0xcd')]=qs[_0xd893('0xce')](_0x2d7c69[_0xd893('0x3c')][_0xd893('0xce')]);_0x262e84[_0xd893('0xcf')]=qs['filters'](_[_0xd893('0xd0')](_0x2d7c69['query'],_0x4ed3ac[_0xd893('0xca')]));if(_0x2d7c69['query']['filter']){_0x262e84[_0xd893('0xcf')]=_['merge'](_0x262e84['where'],{'$or':_[_0xd893('0x2a')](_0x262e84[_0xd893('0x41')],function(_0x21b62f){var _0x44fe27={};_0x44fe27[_0x21b62f]={'$like':'%'+_0x2d7c69['query'][_0xd893('0x28')]+'%'};return _0x44fe27;})});}_0x262e84=_[_0xd893('0x52')]({},_0x262e84,_0x2d7c69[_0xd893('0x53')]);return _0x2c683f[_0xd893('0x12c')](_0x262e84);}})[_0xd893('0x20')](function(_0x52c2f7){if(_0x52c2f7){_0x22d8a6=_0x52c2f7['length'];if(!_0x2d7c69[_0xd893('0x3c')][_0xd893('0xc1')](_0xd893('0xd2'))){_0x262e84[_0xd893('0x1c')]=qs[_0xd893('0x1c')](_0x2d7c69[_0xd893('0x3c')]['limit']);_0x262e84['offset']=qs[_0xd893('0x19')](_0x2d7c69['query']['offset']);}return _0x2c683f[_0xd893('0x12c')](_0x262e84);}})['then'](function(_0xc2a975){if(_0xc2a975){return _0xc2a975?{'count':_0x22d8a6,'rows':_0xc2a975}:null;}})[_0xd893('0x20')](respondWithResult(_0xb74d6a,null))[_0xd893('0x4d')](handleError(_0xb74d6a,null));};exports[_0xd893('0x12e')]=function(_0x145b10,_0x4039a3){return db['User'][_0xd893('0x2d')]({'where':{'id':_0x145b10[_0xd893('0x4f')]['id']}})[_0xd893('0x20')](handleEntityNotFound(_0x4039a3,null))[_0xd893('0x20')](function(_0x48cf84){if(_0x48cf84){return _0x48cf84[_0xd893('0x12e')](_0x145b10[_0xd893('0x55')][_0xd893('0x9b')],_[_0xd893('0x58')](_0x145b10[_0xd893('0x55')],['ids','id'])||{});}})[_0xd893('0x20')](respondWithResult(_0x4039a3,null))[_0xd893('0x4d')](handleError(_0x4039a3,null));};exports[_0xd893('0x12f')]=function(_0x1288f8,_0x5ea996){return db[_0xd893('0x32')][_0xd893('0x2d')]({'where':{'id':_0x1288f8[_0xd893('0x4f')]['id']}})['then'](handleEntityNotFound(_0x5ea996,null))[_0xd893('0x20')](function(_0x15e71c){if(_0x15e71c){return _0x15e71c[_0xd893('0x12f')](_0x1288f8['query'][_0xd893('0x9b')]);}})['then'](respondWithStatusCode(_0x5ea996,null))[_0xd893('0x4d')](handleError(_0x5ea996,null));};exports['getMailAccounts']=function(_0x5d9d4b,_0x349b1f){var _0x38b2b0={};var _0x820c06={};var _0x4cc3a4;var _0x10d21d;return db[_0xd893('0x32')][_0xd893('0xc0')]({'where':{'id':_0x5d9d4b['params']['id']}})[_0xd893('0x20')](handleEntityNotFound(_0x349b1f,null))[_0xd893('0x20')](function(_0x4f3c7c){if(_0x4f3c7c){_0x4cc3a4=_0x4f3c7c;_0x820c06[_0xd893('0xc7')]=_[_0xd893('0xc8')](db[_0xd893('0x130')][_0xd893('0x33')]);_0x820c06['query']=_['keys'](_0x5d9d4b[_0xd893('0x3c')]);_0x820c06[_0xd893('0xca')]=_['intersection'](_0x820c06['model'],_0x820c06[_0xd893('0x3c')]);_0x38b2b0[_0xd893('0x41')]=_['intersection'](_0x820c06[_0xd893('0xc7')],qs[_0xd893('0xcc')](_0x5d9d4b[_0xd893('0x3c')][_0xd893('0xcc')]));_0x38b2b0[_0xd893('0x41')]=_0x38b2b0[_0xd893('0x41')][_0xd893('0x63')]?_0x38b2b0['attributes']:_0x820c06[_0xd893('0xc7')];_0x38b2b0[_0xd893('0xcd')]=qs[_0xd893('0xce')](_0x5d9d4b[_0xd893('0x3c')][_0xd893('0xce')]);_0x38b2b0[_0xd893('0xcf')]=qs[_0xd893('0xca')](_[_0xd893('0xd0')](_0x5d9d4b[_0xd893('0x3c')],_0x820c06[_0xd893('0xca')]));if(_0x5d9d4b[_0xd893('0x3c')]['filter']){_0x38b2b0[_0xd893('0xcf')]=_['merge'](_0x38b2b0[_0xd893('0xcf')],{'$or':_[_0xd893('0x2a')](_0x38b2b0[_0xd893('0x41')],function(_0x503bf0){var _0x53ac15={};_0x53ac15[_0x503bf0]={'$like':'%'+_0x5d9d4b[_0xd893('0x3c')][_0xd893('0x28')]+'%'};return _0x53ac15;})});}_0x38b2b0=_['merge']({},_0x38b2b0,_0x5d9d4b[_0xd893('0x53')]);return _0x4cc3a4[_0xd893('0x131')](_0x38b2b0);}})['then'](function(_0x4f05b1){if(_0x4f05b1){_0x10d21d=_0x4f05b1['length'];if(!_0x5d9d4b[_0xd893('0x3c')][_0xd893('0xc1')](_0xd893('0xd2'))){_0x38b2b0['limit']=qs[_0xd893('0x1c')](_0x5d9d4b[_0xd893('0x3c')][_0xd893('0x1c')]);_0x38b2b0['offset']=qs['offset'](_0x5d9d4b[_0xd893('0x3c')][_0xd893('0x19')]);}return _0x4cc3a4[_0xd893('0x131')](_0x38b2b0);}})[_0xd893('0x20')](function(_0x1c0e35){if(_0x1c0e35){return _0x1c0e35?{'count':_0x10d21d,'rows':_0x1c0e35}:null;}})['then'](respondWithResult(_0x349b1f,null))[_0xd893('0x4d')](handleError(_0x349b1f,null));};exports['addMailAccounts']=function(_0x1b7bc0,_0x5e4bb8){return db['User'][_0xd893('0x2d')]({'where':{'id':_0x1b7bc0[_0xd893('0x4f')]['id']}})['then'](handleEntityNotFound(_0x5e4bb8,null))[_0xd893('0x20')](function(_0x2317ae){if(_0x2317ae){return _0x2317ae[_0xd893('0x132')](_0x1b7bc0[_0xd893('0x55')]['ids'],_['omit'](_0x1b7bc0[_0xd893('0x55')],[_0xd893('0x9b'),'id'])||{});}})[_0xd893('0x20')](respondWithResult(_0x5e4bb8,null))[_0xd893('0x4d')](handleError(_0x5e4bb8,null));};exports[_0xd893('0x133')]=function(_0x5957f4,_0x2d228b){return db['User'][_0xd893('0x2d')]({'where':{'id':_0x5957f4[_0xd893('0x4f')]['id']}})[_0xd893('0x20')](handleEntityNotFound(_0x2d228b,null))[_0xd893('0x20')](function(_0xde181b){if(_0xde181b){return _0xde181b[_0xd893('0x133')](_0x5957f4[_0xd893('0x3c')][_0xd893('0x9b')]);}})['then'](respondWithStatusCode(_0x2d228b,null))[_0xd893('0x4d')](handleError(_0x2d228b,null));};exports['getOpenchannelAccounts']=function(_0x52cddb,_0x539af2){var _0x57a597={};var _0x1df2ba={};var _0x1361b8;var _0x44647f;return db['User'][_0xd893('0xc0')]({'where':{'id':_0x52cddb[_0xd893('0x4f')]['id']}})[_0xd893('0x20')](handleEntityNotFound(_0x539af2,null))[_0xd893('0x20')](function(_0x48f6e9){if(_0x48f6e9){_0x1361b8=_0x48f6e9;_0x1df2ba[_0xd893('0xc7')]=_[_0xd893('0xc8')](db['OpenchannelAccount']['rawAttributes']);_0x1df2ba[_0xd893('0x3c')]=_['keys'](_0x52cddb[_0xd893('0x3c')]);_0x1df2ba[_0xd893('0xca')]=_[_0xd893('0xcb')](_0x1df2ba[_0xd893('0xc7')],_0x1df2ba[_0xd893('0x3c')]);_0x57a597[_0xd893('0x41')]=_[_0xd893('0xcb')](_0x1df2ba[_0xd893('0xc7')],qs[_0xd893('0xcc')](_0x52cddb[_0xd893('0x3c')][_0xd893('0xcc')]));_0x57a597[_0xd893('0x41')]=_0x57a597[_0xd893('0x41')][_0xd893('0x63')]?_0x57a597[_0xd893('0x41')]:_0x1df2ba[_0xd893('0xc7')];_0x57a597[_0xd893('0xcd')]=qs[_0xd893('0xce')](_0x52cddb[_0xd893('0x3c')]['sort']);_0x57a597[_0xd893('0xcf')]=qs[_0xd893('0xca')](_[_0xd893('0xd0')](_0x52cddb['query'],_0x1df2ba[_0xd893('0xca')]));if(_0x52cddb[_0xd893('0x3c')][_0xd893('0x28')]){_0x57a597['where']=_[_0xd893('0x52')](_0x57a597[_0xd893('0xcf')],{'$or':_['map'](_0x57a597[_0xd893('0x41')],function(_0x1baf02){var _0x1b5e10={};_0x1b5e10[_0x1baf02]={'$like':'%'+_0x52cddb[_0xd893('0x3c')][_0xd893('0x28')]+'%'};return _0x1b5e10;})});}_0x57a597=_[_0xd893('0x52')]({},_0x57a597,_0x52cddb[_0xd893('0x53')]);return _0x1361b8[_0xd893('0x134')](_0x57a597);}})[_0xd893('0x20')](function(_0x46a0a5){if(_0x46a0a5){_0x44647f=_0x46a0a5[_0xd893('0x63')];if(!_0x52cddb['query']['hasOwnProperty']('nolimit')){_0x57a597[_0xd893('0x1c')]=qs[_0xd893('0x1c')](_0x52cddb['query'][_0xd893('0x1c')]);_0x57a597[_0xd893('0x19')]=qs[_0xd893('0x19')](_0x52cddb['query'][_0xd893('0x19')]);}return _0x1361b8[_0xd893('0x134')](_0x57a597);}})[_0xd893('0x20')](function(_0x558aa1){if(_0x558aa1){return _0x558aa1?{'count':_0x44647f,'rows':_0x558aa1}:null;}})[_0xd893('0x20')](respondWithResult(_0x539af2,null))['catch'](handleError(_0x539af2,null));};exports[_0xd893('0x135')]=function(_0x49919e,_0x2c9a79){return db[_0xd893('0x32')][_0xd893('0x2d')]({'where':{'id':_0x49919e[_0xd893('0x4f')]['id']}})[_0xd893('0x20')](handleEntityNotFound(_0x2c9a79,null))[_0xd893('0x20')](function(_0x40b7bb){if(_0x40b7bb){return _0x40b7bb[_0xd893('0x135')](_0x49919e['body'][_0xd893('0x9b')],_[_0xd893('0x58')](_0x49919e[_0xd893('0x55')],[_0xd893('0x9b'),'id'])||{});}})[_0xd893('0x20')](respondWithResult(_0x2c9a79,null))[_0xd893('0x4d')](handleError(_0x2c9a79,null));};exports['removeOpenchannelAccounts']=function(_0x438bc7,_0x26bf92){return db[_0xd893('0x32')][_0xd893('0x2d')]({'where':{'id':_0x438bc7[_0xd893('0x4f')]['id']}})[_0xd893('0x20')](handleEntityNotFound(_0x26bf92,null))['then'](function(_0x192904){if(_0x192904){return _0x192904[_0xd893('0x136')](_0x438bc7[_0xd893('0x3c')][_0xd893('0x9b')]);}})[_0xd893('0x20')](respondWithStatusCode(_0x26bf92,null))['catch'](handleError(_0x26bf92,null));};exports['getSmsAccounts']=function(_0x5a8797,_0x240a08){var _0x26fef5={};var _0x441cac={};var _0x46fefb;var _0x14cb67;return db[_0xd893('0x32')][_0xd893('0xc0')]({'where':{'id':_0x5a8797[_0xd893('0x4f')]['id']}})[_0xd893('0x20')](handleEntityNotFound(_0x240a08,null))['then'](function(_0x5cfba3){if(_0x5cfba3){_0x46fefb=_0x5cfba3;_0x441cac[_0xd893('0xc7')]=_[_0xd893('0xc8')](db[_0xd893('0x137')][_0xd893('0x33')]);_0x441cac[_0xd893('0x3c')]=_[_0xd893('0xc8')](_0x5a8797[_0xd893('0x3c')]);_0x441cac[_0xd893('0xca')]=_[_0xd893('0xcb')](_0x441cac['model'],_0x441cac[_0xd893('0x3c')]);_0x26fef5[_0xd893('0x41')]=_[_0xd893('0xcb')](_0x441cac[_0xd893('0xc7')],qs[_0xd893('0xcc')](_0x5a8797[_0xd893('0x3c')][_0xd893('0xcc')]));_0x26fef5[_0xd893('0x41')]=_0x26fef5[_0xd893('0x41')][_0xd893('0x63')]?_0x26fef5[_0xd893('0x41')]:_0x441cac['model'];_0x26fef5[_0xd893('0xcd')]=qs[_0xd893('0xce')](_0x5a8797[_0xd893('0x3c')]['sort']);_0x26fef5['where']=qs['filters'](_['pick'](_0x5a8797['query'],_0x441cac[_0xd893('0xca')]));if(_0x5a8797[_0xd893('0x3c')][_0xd893('0x28')]){_0x26fef5[_0xd893('0xcf')]=_[_0xd893('0x52')](_0x26fef5[_0xd893('0xcf')],{'$or':_[_0xd893('0x2a')](_0x26fef5['attributes'],function(_0x38693b){var _0x3fe568={};_0x3fe568[_0x38693b]={'$like':'%'+_0x5a8797[_0xd893('0x3c')]['filter']+'%'};return _0x3fe568;})});}_0x26fef5=_[_0xd893('0x52')]({},_0x26fef5,_0x5a8797[_0xd893('0x53')]);return _0x46fefb[_0xd893('0x138')](_0x26fef5);}})[_0xd893('0x20')](function(_0x23ada6){if(_0x23ada6){_0x14cb67=_0x23ada6[_0xd893('0x63')];if(!_0x5a8797['query'][_0xd893('0xc1')]('nolimit')){_0x26fef5[_0xd893('0x1c')]=qs[_0xd893('0x1c')](_0x5a8797[_0xd893('0x3c')]['limit']);_0x26fef5[_0xd893('0x19')]=qs[_0xd893('0x19')](_0x5a8797[_0xd893('0x3c')]['offset']);}return _0x46fefb[_0xd893('0x138')](_0x26fef5);}})[_0xd893('0x20')](function(_0x532cc4){if(_0x532cc4){return _0x532cc4?{'count':_0x14cb67,'rows':_0x532cc4}:null;}})[_0xd893('0x20')](respondWithResult(_0x240a08,null))[_0xd893('0x4d')](handleError(_0x240a08,null));};exports[_0xd893('0x139')]=function(_0xfa96ba,_0x33f6ef){return db[_0xd893('0x32')][_0xd893('0x2d')]({'where':{'id':_0xfa96ba[_0xd893('0x4f')]['id']}})[_0xd893('0x20')](handleEntityNotFound(_0x33f6ef,null))[_0xd893('0x20')](function(_0x210391){if(_0x210391){return _0x210391[_0xd893('0x139')](_0xfa96ba[_0xd893('0x55')]['ids'],_['omit'](_0xfa96ba[_0xd893('0x55')],[_0xd893('0x9b'),'id'])||{});}})[_0xd893('0x20')](respondWithResult(_0x33f6ef,null))[_0xd893('0x4d')](handleError(_0x33f6ef,null));};exports[_0xd893('0x13a')]=function(_0x15046a,_0xdf391a){return db[_0xd893('0x32')][_0xd893('0x2d')]({'where':{'id':_0x15046a[_0xd893('0x4f')]['id']}})[_0xd893('0x20')](handleEntityNotFound(_0xdf391a,null))['then'](function(_0x2ec4ce){if(_0x2ec4ce){return _0x2ec4ce[_0xd893('0x13a')](_0x15046a[_0xd893('0x3c')][_0xd893('0x9b')]);}})['then'](respondWithStatusCode(_0xdf391a,null))[_0xd893('0x4d')](handleError(_0xdf391a,null));};exports[_0xd893('0x13b')]=function(_0x309244,_0x3f1755){var _0x36f4c7={};var _0x6bd981={};var _0x8de01;var _0x165c00;return db['User'][_0xd893('0xc0')]({'where':{'id':_0x309244[_0xd893('0x4f')]['id']}})[_0xd893('0x20')](handleEntityNotFound(_0x3f1755,null))['then'](function(_0x69eeb4){if(_0x69eeb4){_0x8de01=_0x69eeb4;_0x6bd981[_0xd893('0xc7')]=_[_0xd893('0xc8')](db['ChatWebsite'][_0xd893('0x33')]);_0x6bd981[_0xd893('0x3c')]=_[_0xd893('0xc8')](_0x309244[_0xd893('0x3c')]);_0x6bd981[_0xd893('0xca')]=_[_0xd893('0xcb')](_0x6bd981[_0xd893('0xc7')],_0x6bd981[_0xd893('0x3c')]);_0x36f4c7[_0xd893('0x41')]=_[_0xd893('0xcb')](_0x6bd981[_0xd893('0xc7')],qs['fields'](_0x309244[_0xd893('0x3c')][_0xd893('0xcc')]));_0x36f4c7[_0xd893('0x41')]=_0x36f4c7[_0xd893('0x41')][_0xd893('0x63')]?_0x36f4c7[_0xd893('0x41')]:_0x6bd981[_0xd893('0xc7')];_0x36f4c7[_0xd893('0xcd')]=qs[_0xd893('0xce')](_0x309244[_0xd893('0x3c')]['sort']);_0x36f4c7[_0xd893('0xcf')]=qs[_0xd893('0xca')](_[_0xd893('0xd0')](_0x309244[_0xd893('0x3c')],_0x6bd981['filters']));if(_0x309244[_0xd893('0x3c')]['filter']){_0x36f4c7['where']=_['merge'](_0x36f4c7['where'],{'$or':_[_0xd893('0x2a')](_0x36f4c7[_0xd893('0x41')],function(_0x3cba1c){var _0x692972={};_0x692972[_0x3cba1c]={'$like':'%'+_0x309244[_0xd893('0x3c')][_0xd893('0x28')]+'%'};return _0x692972;})});}_0x36f4c7=_[_0xd893('0x52')]({},_0x36f4c7,_0x309244[_0xd893('0x53')]);return _0x8de01[_0xd893('0x13b')](_0x36f4c7);}})[_0xd893('0x20')](function(_0x1b4b5a){if(_0x1b4b5a){_0x165c00=_0x1b4b5a[_0xd893('0x63')];if(!_0x309244[_0xd893('0x3c')][_0xd893('0xc1')]('nolimit')){_0x36f4c7[_0xd893('0x1c')]=qs['limit'](_0x309244[_0xd893('0x3c')][_0xd893('0x1c')]);_0x36f4c7[_0xd893('0x19')]=qs['offset'](_0x309244[_0xd893('0x3c')]['offset']);}return _0x8de01[_0xd893('0x13b')](_0x36f4c7);}})[_0xd893('0x20')](function(_0x5f5d2e){if(_0x5f5d2e){return _0x5f5d2e?{'count':_0x165c00,'rows':_0x5f5d2e}:null;}})[_0xd893('0x20')](respondWithResult(_0x3f1755,null))['catch'](handleError(_0x3f1755,null));};exports[_0xd893('0x13c')]=function(_0x1520da,_0x383a15){return db[_0xd893('0x32')]['find']({'where':{'id':_0x1520da[_0xd893('0x4f')]['id']}})[_0xd893('0x20')](handleEntityNotFound(_0x383a15,null))['then'](function(_0x35d4f1){if(_0x35d4f1){return _0x35d4f1[_0xd893('0x13c')](_0x1520da[_0xd893('0x55')][_0xd893('0x9b')],_[_0xd893('0x58')](_0x1520da[_0xd893('0x55')],[_0xd893('0x9b'),'id'])||{});}})[_0xd893('0x20')](respondWithResult(_0x383a15,null))[_0xd893('0x4d')](handleError(_0x383a15,null));};exports[_0xd893('0x13d')]=function(_0x2bb78e,_0x4b44e9){return db['User']['find']({'where':{'id':_0x2bb78e[_0xd893('0x4f')]['id']}})[_0xd893('0x20')](handleEntityNotFound(_0x4b44e9,null))[_0xd893('0x20')](function(_0x3917f6){if(_0x3917f6){return _0x3917f6[_0xd893('0x13d')](_0x2bb78e[_0xd893('0x3c')][_0xd893('0x9b')]);}})[_0xd893('0x20')](respondWithStatusCode(_0x4b44e9,null))[_0xd893('0x4d')](handleError(_0x4b44e9,null));};exports[_0xd893('0x13e')]=function(_0x46114d,_0x3238ed){var _0xeb121={};var _0x3cedc9={};var _0x24ec72;var _0x57ff5b;return db[_0xd893('0x32')]['findOne']({'where':{'id':_0x46114d[_0xd893('0x4f')]['id']}})[_0xd893('0x20')](handleEntityNotFound(_0x3238ed,null))[_0xd893('0x20')](function(_0x20e532){if(_0x20e532){_0x24ec72=_0x20e532;_0x3cedc9[_0xd893('0xc7')]=_[_0xd893('0xc8')](db[_0xd893('0x13f')][_0xd893('0x33')]);_0x3cedc9[_0xd893('0x3c')]=_[_0xd893('0xc8')](_0x46114d['query']);_0x3cedc9[_0xd893('0xca')]=_['intersection'](_0x3cedc9[_0xd893('0xc7')],_0x3cedc9[_0xd893('0x3c')]);_0xeb121['attributes']=_[_0xd893('0xcb')](_0x3cedc9[_0xd893('0xc7')],qs[_0xd893('0xcc')](_0x46114d[_0xd893('0x3c')]['fields']));_0xeb121[_0xd893('0x41')]=_0xeb121['attributes'][_0xd893('0x63')]?_0xeb121[_0xd893('0x41')]:_0x3cedc9[_0xd893('0xc7')];_0xeb121[_0xd893('0xcd')]=qs[_0xd893('0xce')](_0x46114d[_0xd893('0x3c')][_0xd893('0xce')]);_0xeb121[_0xd893('0xcf')]=qs[_0xd893('0xca')](_[_0xd893('0xd0')](_0x46114d['query'],_0x3cedc9[_0xd893('0xca')]));if(_0x46114d['query'][_0xd893('0x28')]){_0xeb121[_0xd893('0xcf')]=_['merge'](_0xeb121[_0xd893('0xcf')],{'$or':_[_0xd893('0x2a')](_0xeb121[_0xd893('0x41')],function(_0x3d42a7){var _0x1687cd={};_0x1687cd[_0x3d42a7]={'$like':'%'+_0x46114d[_0xd893('0x3c')][_0xd893('0x28')]+'%'};return _0x1687cd;})});}_0xeb121=_['merge']({},_0xeb121,_0x46114d['options']);return _0x24ec72[_0xd893('0x13e')](_0xeb121);}})[_0xd893('0x20')](function(_0x29baec){if(_0x29baec){_0x57ff5b=_0x29baec['length'];if(!_0x46114d[_0xd893('0x3c')][_0xd893('0xc1')]('nolimit')){_0xeb121[_0xd893('0x1c')]=qs['limit'](_0x46114d[_0xd893('0x3c')]['limit']);_0xeb121[_0xd893('0x19')]=qs[_0xd893('0x19')](_0x46114d[_0xd893('0x3c')][_0xd893('0x19')]);}return _0x24ec72[_0xd893('0x13e')](_0xeb121);}})['then'](function(_0xfdb77c){if(_0xfdb77c){return _0xfdb77c?{'count':_0x57ff5b,'rows':_0xfdb77c}:null;}})[_0xd893('0x20')](respondWithResult(_0x3238ed,null))[_0xd893('0x4d')](handleError(_0x3238ed,null));};exports[_0xd893('0x140')]=function(_0x2e85a0,_0x1f86db){return db[_0xd893('0x32')]['find']({'where':{'id':_0x2e85a0[_0xd893('0x4f')]['id']}})[_0xd893('0x20')](handleEntityNotFound(_0x1f86db,null))[_0xd893('0x20')](function(_0x5d14bd){if(_0x5d14bd){return _0x5d14bd[_0xd893('0x140')](_0x2e85a0['body'][_0xd893('0x9b')],_[_0xd893('0x58')](_0x2e85a0['body'],[_0xd893('0x9b'),'id'])||{});}})[_0xd893('0x20')](respondWithResult(_0x1f86db,null))[_0xd893('0x4d')](handleError(_0x1f86db,null));};exports[_0xd893('0x141')]=function(_0x313340,_0x1b2202){return db['User'][_0xd893('0x2d')]({'where':{'id':_0x313340[_0xd893('0x4f')]['id']}})[_0xd893('0x20')](handleEntityNotFound(_0x1b2202,null))['then'](function(_0x5171de){if(_0x5171de){return _0x5171de[_0xd893('0x141')](_0x313340[_0xd893('0x3c')][_0xd893('0x9b')]);}})['then'](respondWithStatusCode(_0x1b2202,null))[_0xd893('0x4d')](handleError(_0x1b2202,null));};exports['getScheduledCalls']=function(_0x488e12,_0x2c03d3){var _0x55be87={},_0xba4fc5={},_0x2cb096={'count':0x0,'rows':[]};var _0x49a22c=db[_0xd893('0x142')][_0xd893('0x33')];_0xba4fc5[_0xd893('0xc7')]=_[_0xd893('0xc8')](_0x49a22c);_0xba4fc5[_0xd893('0x3c')]=_[_0xd893('0xc8')](_0x488e12[_0xd893('0x3c')]);_0xba4fc5['filters']=_['intersection'](_0xba4fc5[_0xd893('0xc7')],_0xba4fc5[_0xd893('0x3c')]);_0xba4fc5[_0xd893('0xca')]=_[_0xd893('0xbe')](_0xba4fc5[_0xd893('0xca')],[_0xd893('0x143'),'$or',_0xd893('0x144'),_0xd893('0x145'),_0xd893('0x146'),_0xd893('0x147'),_0xd893('0x148'),_0xd893('0x149'),'$not',_0xd893('0x14a'),_0xd893('0x14b'),_0xd893('0x14c'),_0xd893('0x14d'),_0xd893('0x14e'),_0xd893('0x14f'),_0xd893('0x150'),_0xd893('0x151'),'$like','$overlap',_0xd893('0x152'),_0xd893('0x153'),_0xd893('0x154')]);_0x55be87[_0xd893('0x41')]=_[_0xd893('0xcb')](_0xba4fc5[_0xd893('0xc7')],qs['fields'](_0x488e12[_0xd893('0x3c')]['fields']));_0x55be87[_0xd893('0x41')]=_0x55be87[_0xd893('0x41')]['length']?_0x55be87['attributes']:_0xba4fc5[_0xd893('0xc7')];if(!_0x488e12[_0xd893('0x3c')][_0xd893('0xc1')](_0xd893('0xd2'))){_0x55be87[_0xd893('0x1c')]=qs['limit'](_0x488e12[_0xd893('0x3c')][_0xd893('0x1c')]);_0x55be87[_0xd893('0x19')]=qs[_0xd893('0x19')](_0x488e12['query']['offset']);}_0x55be87['order']=qs[_0xd893('0xce')](_0x488e12[_0xd893('0x3c')][_0xd893('0xce')]);_0x55be87['where']=qs[_0xd893('0xca')](_[_0xd893('0xd0')](_0x488e12['query'],_0xba4fc5[_0xd893('0xca')]));if(_0x488e12[_0xd893('0x3c')][_0xd893('0x28')]){_0x55be87['where']=_[_0xd893('0x52')](_0x55be87[_0xd893('0xcf')],{'$or':_[_0xd893('0x2a')](_0x55be87[_0xd893('0x41')],function(_0x166f4b){var _0x547f4a={};_0x547f4a[_0x166f4b]={'$like':'%'+_0x488e12['query'][_0xd893('0x28')]+'%'};return _0x547f4a;})});}_0x55be87[_0xd893('0xcf')]={'$and':[_0x55be87['where'],{'$or':[{'UserId':_0x488e12[_0xd893('0x4f')]['id']},{'OwnerId':_0x488e12[_0xd893('0x4f')]['id']}]}]};_0x55be87=_[_0xd893('0x52')]({},_0x55be87,_0x488e12[_0xd893('0x53')]);var _0x23b3f2={'where':_0x55be87[_0xd893('0xcf')]};return db['CmHopper']['count'](_0x23b3f2)[_0xd893('0x20')](function(_0x5913c6){_0x2cb096[_0xd893('0x1b')]=_0x5913c6;if(_0x488e12[_0xd893('0x3c')][_0xd893('0x51')]){_0x55be87['include']=[{'attributes':['id',_0xd893('0x155'),_0xd893('0x156'),'phone'],'model':db[_0xd893('0x157')],'as':'Contact'},{'attributes':['id',_0xd893('0x2f'),'dialActive'],'model':db[_0xd893('0x9e')],'as':_0xd893('0xc9')}];}return db[_0xd893('0x142')][_0xd893('0x43')](_0x55be87);})['then'](function(_0x42a589){_0x2cb096[_0xd893('0x45')]=_0x42a589;return _0x2cb096;})[_0xd893('0x20')](respondWithFilteredResult(_0x2c03d3,_0x55be87))[_0xd893('0x4d')](handleError(_0x2c03d3,null));};exports[_0xd893('0x158')]=function(_0x222113,_0x4f0c48){if(!_['isNil'](_0x222113[_0xd893('0x27')]['id'])&&(_0x222113[_0xd893('0x27')]['role']==_0xd893('0x26')||_0x222113[_0xd893('0x27')][_0xd893('0x2e')]==_0xd893('0x27'))){return db[_0xd893('0x32')]['findOne']({'where':{'id':_0x222113['params']['id']},'raw':!![]})[_0xd893('0x20')](function(_0x1fe38b){return authService[_0xd893('0x159')](_0x1fe38b);})['then'](function(_0x5a77c2){if(_0x5a77c2){return _0x4f0c48[_0xd893('0x17')](0xc8)[_0xd893('0x18')]({'api_key':_0x5a77c2[_0xd893('0x15a')]});}else{return _0x4f0c48['status'](0xcc)[_0xd893('0x18')]({'message':_0xd893('0x15b')});}})['catch'](handleError(_0x4f0c48,0x193));}else{return _0x4f0c48[_0xd893('0x17')](0x191)['json']({'message':_0xd893('0x15c')});}};exports[_0xd893('0x15d')]=function(_0x41efce,_0xae5784){if(!_['isNil'](_0x41efce[_0xd893('0x27')]['id'])&&(_0x41efce[_0xd893('0x27')][_0xd893('0x2e')]==_0xd893('0x26')||_0x41efce['user'][_0xd893('0x2e')]=='user')){return db['User'][_0xd893('0x2d')]({'where':{'id':_0x41efce['params']['id']}})[_0xd893('0x20')](function(_0x5f03e9){return authService['generateApiKey'](_0x5f03e9);})['then'](function(_0x5c913a){return db[_0xd893('0x32')]['update']({'apiKeyIat':_0x5c913a[_0xd893('0x15e')],'apiKeyNonce':_0x5c913a['nonce']},{'where':{'id':_0x41efce[_0xd893('0x4f')]['id']}})['then'](function(){return _0xae5784['status'](0xc8)[_0xd893('0x18')]({'api_key':_0x5c913a['token']});});})['catch'](handleError(_0xae5784,0x193));}else{return _0xae5784[_0xd893('0x17')](0x191)['json']({'message':_0xd893('0x15c')});}};exports[_0xd893('0x15f')]=function(_0x12854c,_0x172986){if(!_[_0xd893('0x5e')](_0x12854c[_0xd893('0x27')]['id'])&&(_0x12854c[_0xd893('0x27')][_0xd893('0x2e')]==_0xd893('0x26')||_0x12854c[_0xd893('0x27')]['role']==_0xd893('0x27'))){return db[_0xd893('0x32')][_0xd893('0x2d')]({'where':{'id':_0x12854c[_0xd893('0x4f')]['id']}})[_0xd893('0x20')](handleEntityNotFound(_0x172986,null))[_0xd893('0x20')](function(_0x5592bf){if(_0x5592bf&&_0x5592bf['apiKeyNonce']&&_0x5592bf[_0xd893('0x160')])return _0x5592bf;else throw{'message':'API\x20key\x20not\x20available'};})[_0xd893('0x20')](function(){return db[_0xd893('0x32')]['update']({'apiKeyNonce':null,'apiKeyIat':null},{'where':{'id':_0x12854c[_0xd893('0x4f')]['id']}});})[_0xd893('0x20')](respondWithStatusCode(_0x172986,0xc8))[_0xd893('0x4d')](handleError(_0x172986,0x193));}else{return _0x172986[_0xd893('0x17')](0x191)[_0xd893('0x18')]({'message':_0xd893('0x15c')});}};exports[_0xd893('0x161')]=function(_0x47d36e,_0x7eb80){var _0x5f5def=_0x47d36e['user'][_0xd893('0x25')]({'plain':!![]});if(!_0x5f5def){return _0x7eb80['status'](0x191)['send']('Unable\x20to\x20retrieve\x20the\x20current\x20user');}else{Promise[_0xd893('0xf7')]()[_0xd893('0x20')](function(){if(_0x47d36e[_0xd893('0x3c')][_0xd893('0x40')]!==_0xd893('0x3e'))return;return _0x47d36e[_0xd893('0x27')][_0xd893('0x162')]();})['then'](function(_0x122b7e){if(!_0x122b7e)return;return _0x122b7e[_0xd893('0x25')]({'plain':!![]});})['then'](function(_0x337576){_0x5f5def[_0xd893('0x40')]=_0x337576;return _0x7eb80[_0xd893('0x17')](0xc8)['json'](_0x5f5def);});}};exports[_0xd893('0x163')]=function(_0x208ac7,_0x23d830){var _0x330602={'offset':0x0};var _0x48e71b={'count':0x0,'rows':[]};var _0x4940bb=[_0xd893('0x164'),_0xd893('0x165'),_0xd893('0x166')];var _0x53eb8d=[];var _0x1668a5=[];var _0x330337=[];var _0x460f97=_0x208ac7[_0xd893('0x3c')][_0xd893('0x167')];var _0x365c37=_0x208ac7[_0xd893('0x3c')]['queues'];var _0x2a7088=_0x208ac7[_0xd893('0x3c')][_0xd893('0x28')];return Promise['resolve']()[_0xd893('0x20')](function(){if(!_0x460f97){return[];}return db[_0xd893('0x106')][_0xd893('0x43')]({'attributes':['id',_0xd893('0x2f')],'where':{'id':_0x460f97}});})[_0xd893('0x20')](function(_0x286849){_0x330337=_0x286849;if(!_0x365c37){return[];}return db[_0xd893('0x9e')][_0xd893('0x43')]({'attributes':['id',_0xd893('0x2f')],'type':_0xd893('0x168'),'where':{'id':_0x365c37}});})[_0xd893('0x20')](function(_0x30759b){_0x1668a5=_0x30759b;var _0x2dfa5a=_0x330337[_0xd893('0xbe')](_0x1668a5)[_0xd893('0x2a')](function(_0x2f0f96){return _0x2f0f96[_0xd893('0x113')]({'attributes':['id',_0xd893('0x2f'),_0xd893('0x59'),_0xd893('0x9f')],'raw':!![]});});return Promise['all'](_0x2dfa5a);})[_0xd893('0x20')](function(_0x15b6c1){var _0x1928d9=_[_0xd893('0x169')](_0x15b6c1);if(_0x2a7088){if(_0x365c37||_0x460f97){return _0x1928d9[_0xd893('0x28')](function(_0x107b06){return _0x107b06[_0xd893('0x2f')][_0xd893('0x98')]()[_0xd893('0x2c')](_0x2a7088[_0xd893('0x98')]())||_0x107b06['internal'][_0xd893('0x16a')]()['includes'](_0x2a7088);});}else{return db[_0xd893('0x32')][_0xd893('0x43')]({'attributes':['id',_0xd893('0x2f'),_0xd893('0x59'),_0xd893('0x9f')],'where':{'role':_0xd893('0x21'),'$or':[db[_0xd893('0x60')][_0xd893('0xcf')](db['sequelize']['fn']('lower',db[_0xd893('0x60')]['col'](_0xd893('0x2f'))),{'$like':'%'+_0x2a7088[_0xd893('0x98')]()+'%'}),{'internal':{'$like':'%'+_0x2a7088+'%'}}]},'raw':!![]});}}else{return _0x1928d9;}})['then'](function(_0x1d5e25){var _0x474fcf=_0xd893('0x2f');var _0x1c256a='asc';if(_0x208ac7[_0xd893('0x3c')][_0xd893('0xce')]){_0x1c256a=_0x208ac7[_0xd893('0x3c')][_0xd893('0xce')][0x0]==='-'?_0xd893('0x16b'):_0xd893('0x16c');_0x474fcf=_0x1c256a==='asc'?_0x208ac7[_0xd893('0x3c')][_0xd893('0xce')]:_0x208ac7[_0xd893('0x3c')][_0xd893('0xce')][_0xd893('0x16d')](0x1);}return _(_0x1d5e25)[_0xd893('0x16e')]('id')[_0xd893('0x16f')]([function(_0x5ea7ae){return _0x474fcf==='name'?_0x5ea7ae[_0x474fcf][_0xd893('0x98')]():_0x5ea7ae[_0x474fcf];}],[_0x1c256a])[_0xd893('0x2a')](function(_0x34a76a){return _['pick'](_0x34a76a,['id',_0xd893('0x2f'),_0xd893('0x59'),_0xd893('0x9f')]);})[_0xd893('0x2b')]();})[_0xd893('0x20')](function(_0x3ee99d){_0x53eb8d=_0x3ee99d;return rta[_0xd893('0x170')]();})[_0xd893('0x20')](function(_0x4e41e9){return _0x53eb8d[_0xd893('0x2a')](function(_0x340dc6){var _0x44baba=_[_0xd893('0x2d')](_0x4e41e9[_0xd893('0x45')],['id',_0x340dc6['id']]);if(!_0x44baba||!_0x340dc6['online']){_0x340dc6[_0xd893('0x17')]='offline';}else if(_0x44baba['voicePause']){_0x340dc6[_0xd893('0x17')]=_0xd893('0xf9');}else if(_0x44baba[_0xd893('0x171')]===_0xd893('0x172')||!_0x44baba[_0xd893('0x171')]){_0x340dc6[_0xd893('0x17')]=_0xd893('0x172');}else{_0x340dc6[_0xd893('0x17')]=_0x4940bb[_0xd893('0x2c')](_0x44baba[_0xd893('0x171')])?_0xd893('0x9f'):'busy';}return _0x340dc6;});})[_0xd893('0x20')](function(_0x3f5091){if(!_0x208ac7[_0xd893('0x3c')]['hasOwnProperty'](_0xd893('0xd2'))){_0x330602['limit']=qs[_0xd893('0x1c')](_0x208ac7['query'][_0xd893('0x1c')]||0xa);_0x330602[_0xd893('0x19')]=qs[_0xd893('0x19')](_0x208ac7[_0xd893('0x3c')][_0xd893('0x19')]);}_0x48e71b[_0xd893('0x1b')]=_0x3f5091[_0xd893('0x63')];_0x48e71b['rows']=_0x330602[_0xd893('0x1c')]?_0x3f5091[_0xd893('0x173')](_0x330602['offset'],_0x330602['offset']+_0x330602[_0xd893('0x1c')]):_0x3f5091;return _0x48e71b;})[_0xd893('0x20')](respondWithFilteredResult(_0x23d830,_0x330602))['catch'](handleError(_0x23d830,null));};function get_open_tabs(_0x1857a3,_0x4fdf9f){var _0x2a0c57=_0x1857a3[_0xd893('0x174')](0x0)[_0xd893('0x175')]()+_0x1857a3[_0xd893('0x173')](0x1);var _0x40e234={'type':db[_0xd893('0x87')][_0xd893('0x61')][_0xd893('0x62')],'raw':!![]};return new Promise(function(_0x511da1,_0x2d28e5){var _0x34cfa4=squel[_0xd893('0x176')]()[_0xd893('0x177')](_0xd893('0x178')+_0x2a0c57+_0xd893('0x179'),'id')[_0xd893('0x177')](_0xd893('0x17a'))['from'](_0xd893('0x17b')+_0x1857a3+_0xd893('0x17c'),'ui')['where'](_0xd893('0x17d'),_0x4fdf9f['id']);return db[_0xd893('0x60')]['query'](_0x34cfa4['toString'](),_0x40e234)[_0xd893('0x20')](function(_0x5d33d0){_0x4fdf9f[_0x2a0c57+_0xd893('0x17e')]=_0x5d33d0;_0x511da1(_0x5d33d0);})[_0xd893('0x4d')](function(_0x4ac4f7){_0x2d28e5(_0x4ac4f7);});});}exports[_0xd893('0x17f')]=function(_0x49fa87,_0x29f457){var _0x51f684=_0x49fa87['params']['id'];var _0x363f75=_0x49fa87[_0xd893('0x55')]['enabled'];return db[_0xd893('0x32')][_0xd893('0x1f')]({'messengerSoundNotification':_0x363f75},{'where':{'id':_0x51f684}})[_0xd893('0x20')](respondWithStatusCode(_0x29f457,null))[_0xd893('0x4d')](handleError(_0x29f457,null));};
\ No newline at end of file