Built motion from commit b5996064.|2.6.21
[motion2.git] / server / api / user / user.controller.js
index ba5f018..d99ab2f 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x3f15=['addSmsAccounts','removeSmsAccounts','getChatWebsites','ChatWebsite','addChatWebsites','removeChatWebsites','getWhatsappAccounts','WhatsappAccount','addWhatsappAccounts','removeWhatsappAccounts','getSquareProjects','SquareProject','addSquareProjects','removeSquareProjects','getScheduledCalls','CmHopper','concat','$and','$gt','$gte','$lt','$lte','$ne','$not','$between','$notBetween','$in','$notIn','$like','$iLike','$contained','$any','Contact','dialActive','getApiKey','token','No\x20API\x20access\x20key\x20found!','You\x20don\x27t\x20have\x20sufficient\x20privileges\x20to\x20access\x20this\x20resource.','generateApiKey','iat','nonce','removeApiKey','apiKeyIat','whoami','Unable\x20to\x20retrieve\x20the\x20current\x20user','queues','teams','inbound','lower','col','toString','asc','desc','substring','uniqBy','Unable\x20to\x20retrieve\x20RPC\x20agents\x20(AMI)','idle','unknown','unavailable','ringing','voiceStatus','toUpperCase','slice','SELECT','select','field','ui.createdAt','_interactions','ui.UserId\x20=\x20?','OpenTabs','util','path','lodash','jayson/promise','ioredis','../../components/auth/service','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','./user.socket','register','defaults','localhost','client','http','request','then','info','User,\x20%s,\x20%s','request\x20sent','debug','error','code','message','result','catch','sendStatus','status','end','json','undefined','limit','offset','count','set','Content-Range','update','destroy','get','agent','Telephones','telephone','filter','ignore','map','value','includes','find','role','name','stack','send','index','rawAttributes','fieldName','type','key','password','salt','getOptions','where','query','includeAll','include','userSetting','true','UserSetting','attributes','push','User','findAll','rows','length','dataValues','sms','fax','openchannel','all','show','params','model','differenceBy','keys','filters','intersection','merge','openTabs','whatsapp','mail','body','describe','addContacts','ids','internal','Setting','findById','securePassword','max','min_internal','isNil','sequelize','select\x20(select\x20IFNULL(max(internal)+1,1)\x20from\x20users\x20where\x20internal\x20<\x20md.internal)\x20as\x20\x27from\x27,\x20md.internal\x20-\x201\x20as\x20\x27to\x27\x20from\x20users\x20md\x20where\x20md.internal\x20!=\x201\x20and\x20not\x20exists\x20(select\x201\x20from\x20users\x20md2\x20where\x20md2.internal\x20=\x20md.internal\x20-\x201)','from','voicemail','fullname','email','permissions','101','102','103','110','106','107','108','100','114','115','create','Unauthorized','user','admin','Unauthorized.\x20You\x20must\x20be\x20an\x20administrator\x20in\x20order\x20to\x20create\x20an\x20user','Unauthorized.\x20You\x20must\x20be\x20an\x20administrator\x20in\x20order\x20to\x20create\x20another\x20administrator','checkUserLimits','settingsEnabled','VoiceMail','Agents','userProfileId','autoAssociation','UserProfileResource','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','bulkCreate','some','Unauthorized.\x20You\x20must\x20be\x20an\x20administrator\x20in\x20order\x20to\x20create\x20an\x20administrator','each','UserProfileSection','isEmpty','compact','changePassword','oldPassword','newPassword','Sequelize','ValidationError','Invalid\x20body\x20format.\x20Use\x20oldPassword\x20and\x20newPassword','Wrong\x20credentials','New\x20password\x20must\x20be\x20different\x20from\x20old\x20password','Invalid\x20body\x20format.\x20Use\x20newPassword','enforcePasswordHistory','passwordHistoryLimit','validatePasswordPattern','previousPasswords','validatePasswordHistory','updatePasswordsHistory','addQueues','online','voicePause','interface','isValidChannel','Unknown\x20channel','add','capitalize','toLowerCase','Queues','penalty','QueueId','voice','VoiceQueue','format','SIP/%s','UserVoiceQueueRt','upsert','removeQueues','channel','remove','emit','Queue:remove','addAvatar','file','getAvatar','join','root','userpic','download','existsSync','server/files/images/','getOpenTabs','chat','CHAT','createdAt','FaxOpenTabs','FAX','OpenchannelOpenTabs','OPENCHANNEL','SmsOpenTabs','SMS','WhatsappOpenTabs','WHATSAPP','getContacts','findOne','CmContact','fields','order','sort','pick','options','hasOwnProperty','Tag','Tags','color','tag','nolimit','getQueues','Queue','Unknown\x20role','getVoiceQueuesRt','getGroups','ChatGroup','VoiceRecording','UserId','getScreenRecordings','ScreenRecording','getChatInteractions','ChatInteraction','getOpenchannelInteractions','getMailInteractions','MailInteraction','getSmsInteractions','SmsInteraction','FaxInteraction','getFaxInteractions','getWhatsappInteractions','login','phone','LOCAL/%s@from-sip/n','intrf','user:%s','user:forcelogout','headers','x-forwarded-for','remoteAddress','socket','connection','User\x20not\x20found\x20or\x20not\x20allowed\x20to\x20perform\x20login\x20method','loginInPause','UserVoiceQueue.penalty','MemberReport','forEach','YYYY-MM-DD\x20HH:mm:ss','getChannels','LOGIN','device','PAUSE','LOGININPAUSE','isMiddleware','resolve','pause','QueuePause','updateAttributes','DEFAULT\x20PAUSE','unpause','mailPause','faxPause','openchannelPause','whatsapppause','pauseType','lastPauseAt','manual','%s%s','Pause','getTeams','addTeams','omit','Team','getVoiceQueues','Voice','getChatQueues','setDataValue','getSmsQueues','getWhatsappQueues','Whatsapp','getFaxQueues','Fax','getOpenchannelQueues','flatten','transaction','addAgent','getDataValue','Queue:save','VoicePrefixId','Chat','Mail','Sms','Openchannel','TeamVoicePrefix','UserVoicePrefix','getLists','getAgents','values','You\x20can\x27t\x20delete\x20yourself','addChatInteractions','spread','user_has_chat_interactions:save','removeChatInteractions','isArray','user_has_chat_interactions:remove','addMailInteractions','user_has_mail_interactions:save','removeMailInteractions','user_has_mail_interactions:remove','addFaxInteractions','user_has_fax_interactions:save','removeFaxInteractions','user_has_fax_interactions:remove','addSmsInteractions','user_has_sms_interactions:save','removeSmsInteractions','user_has_sms_interactions:remove','user_has_openchannel_interactions:save','removeOpenchannelInteractions','user_has_openchannel_interactions:remove','addWhatsappInteractions','user_has_whatsapp_interactions:save','removeWhatsappInteractions','VoicePrefix','getVoicePrefixes','FaxAccount','getFaxAccounts','addFaxAccounts','removeFaxAccounts','MailAccount','getMailAccounts','addMailAccounts','removeMailAccounts','getOpenchannelAccounts','OpenchannelAccount','addOpenchannelAccounts','removeOpenchannelAccounts','SmsAccount','getSmsAccounts'];(function(_0x5d2b37,_0x176f3e){var _0x5dfa71=function(_0x348ebe){while(--_0x348ebe){_0x5d2b37['push'](_0x5d2b37['shift']());}};_0x5dfa71(++_0x176f3e);}(_0x3f15,0x1e3));var _0x53f1=function(_0x4be2b5,_0x4fe9c2){_0x4be2b5=_0x4be2b5-0x0;var _0x33e77d=_0x3f15[_0x4be2b5];return _0x33e77d;};'use strict';var moment=require('moment');var BPromise=require('bluebird');var util=require(_0x53f1('0x0'));var path=require(_0x53f1('0x1'));var fs=require('fs');var _=require(_0x53f1('0x2'));var squel=require('squel');var jayson=require(_0x53f1('0x3'));var Redis=require(_0x53f1('0x4'));var authService=require(_0x53f1('0x5'));var qs=require('../../components/parsers/qs');var logger=require(_0x53f1('0x6'))(_0x53f1('0x7'));var utils=require(_0x53f1('0x8'));var config=require(_0x53f1('0x9'));var licenseUtil=require(_0x53f1('0xa'));var db=require(_0x53f1('0xb'))['db'];var socket=require('socket.io-emitter')(new Redis(config[_0x53f1('0xc')]));require(_0x53f1('0xd'))[_0x53f1('0xe')](socket);config[_0x53f1('0xc')]=_[_0x53f1('0xf')](config['redis'],{'host':_0x53f1('0x10'),'port':0x18eb});var client=jayson[_0x53f1('0x11')][_0x53f1('0x12')]({'port':0x232a});var values;function respondWithRpcPromise(_0x4b965,_0x3e5b8e,_0x2e2c22,_0x11205a){return new BPromise(function(_0x5d08f1,_0x65e6a){var _0x4e0e3a=_0x11205a||client;return _0x4e0e3a[_0x53f1('0x13')](_0x4b965,_0x2e2c22)[_0x53f1('0x14')](function(_0x1fd4ff){logger[_0x53f1('0x15')](_0x53f1('0x16'),_0x3e5b8e,_0x53f1('0x17'));logger[_0x53f1('0x18')]('User,\x20%s,\x20%s,\x20%s',_0x3e5b8e,_0x53f1('0x17'),JSON['stringify'](_0x1fd4ff));if(_0x1fd4ff[_0x53f1('0x19')]){if(_0x1fd4ff[_0x53f1('0x19')][_0x53f1('0x1a')]===0x1f4){logger[_0x53f1('0x19')]('User,\x20%s,\x20%s',_0x3e5b8e,_0x1fd4ff[_0x53f1('0x19')]['message']);return _0x65e6a(_0x1fd4ff[_0x53f1('0x19')][_0x53f1('0x1b')]);}logger[_0x53f1('0x19')](_0x53f1('0x16'),_0x3e5b8e,_0x1fd4ff['error'][_0x53f1('0x1b')]);return _0x5d08f1(_0x1fd4ff[_0x53f1('0x19')][_0x53f1('0x1b')]);}else{logger[_0x53f1('0x15')](_0x53f1('0x16'),_0x3e5b8e,'request\x20sent');_0x5d08f1(_0x1fd4ff[_0x53f1('0x1c')][_0x53f1('0x1b')]);}})[_0x53f1('0x1d')](function(_0x21d71b){logger['error']('User,\x20%s,\x20%s',_0x3e5b8e,_0x21d71b);_0x65e6a(_0x21d71b);});});}function respondWithStatusCode(_0x4afabc,_0x17f4d2){_0x17f4d2=_0x17f4d2||0xcc;return function(_0x2b7462){if(_0x2b7462){return _0x4afabc[_0x53f1('0x1e')](_0x17f4d2);}return _0x4afabc[_0x53f1('0x1f')](_0x17f4d2)[_0x53f1('0x20')]();};}function respondWithResult(_0x4cdf78,_0x4dac17){_0x4dac17=_0x4dac17||0xc8;return function(_0x43700a){if(_0x43700a){return _0x4cdf78[_0x53f1('0x1f')](_0x4dac17)[_0x53f1('0x21')](_0x43700a);}};}function respondWithFilteredResult(_0x308597,_0x528aac){return function(_0x50cb1d){if(_0x50cb1d){var _0x2fc2a9=typeof _0x528aac['offset']===_0x53f1('0x22')&&typeof _0x528aac[_0x53f1('0x23')]==='undefined';var _0x366a67=_0x50cb1d['count'];var _0x3fbce1=_0x2fc2a9?0x0:_0x528aac[_0x53f1('0x24')];var _0x4c782b=_0x2fc2a9?_0x50cb1d[_0x53f1('0x25')]:_0x528aac['offset']+_0x528aac['limit'];var _0x4e9112;if(_0x4c782b>=_0x366a67){_0x4c782b=_0x366a67;_0x4e9112=0xc8;}else{_0x4e9112=0xce;}_0x308597['status'](_0x4e9112);return _0x308597[_0x53f1('0x26')](_0x53f1('0x27'),_0x3fbce1+'-'+_0x4c782b+'/'+_0x366a67)[_0x53f1('0x21')](_0x50cb1d);}return null;};}function saveUpdates(_0x3b2c44){return function(_0x82a992){if(_0x82a992){return _0x82a992[_0x53f1('0x28')](_0x3b2c44)['then'](function(_0x1b6629){return _0x1b6629;});}return null;};}function removeEntity(_0xa99feb){return function(_0xb66959){if(_0xb66959){return _0xb66959[_0x53f1('0x29')]()[_0x53f1('0x14')](function(){var _0x12b666=_0xb66959[_0x53f1('0x2a')]({'plain':!![]});if(_0x12b666['role']==='admin')return;var _0x2c8bf8=[{'name':'Users','value':'user','ignore':!![]},{'name':'Agents','value':_0x53f1('0x2b'),'ignore':![]},{'name':_0x53f1('0x2c'),'value':_0x53f1('0x2d'),'ignore':![]}];var _0x5b4bbb=_(_0x2c8bf8)[_0x53f1('0x2e')](_0x53f1('0x2f'))[_0x53f1('0x30')]('value')[_0x53f1('0x31')]();if(_[_0x53f1('0x32')](_0x5b4bbb,_0x12b666['role'])){return;}var _0x48deaa=_[_0x53f1('0x33')](_0x2c8bf8,[_0x53f1('0x31'),_0x12b666[_0x53f1('0x34')]])[_0x53f1('0x35')];return db['UserProfileResource']['destroy']({'where':{'type':_0x48deaa,'resourceId':_0x12b666['id']}})[_0x53f1('0x14')](function(){return _0xb66959;});})[_0x53f1('0x14')](function(){_0xa99feb[_0x53f1('0x1f')](0xcc)[_0x53f1('0x20')]();});}};}function handleEntityNotFound(_0x441335){return function(_0x41119b){if(!_0x41119b){_0x441335[_0x53f1('0x1e')](0x194);}return _0x41119b;};}function handleError(_0x63bad6,_0x1a800f){_0x1a800f=_0x1a800f||0x1f4;return function(_0x226db9){logger[_0x53f1('0x19')](_0x226db9[_0x53f1('0x36')]);if(_0x226db9[_0x53f1('0x35')]){delete _0x226db9[_0x53f1('0x35')];}_0x63bad6[_0x53f1('0x1f')](_0x1a800f)[_0x53f1('0x37')](_0x226db9);};}exports[_0x53f1('0x38')]=function(_0x50bcaa,_0x5b76fd){var _0x5fa0f9={},_0x4fedc6={'count':0x0,'rows':[]};var _0x174567=_(db['User'][_0x53f1('0x39')])[_0x53f1('0x30')](function(_0x4a5a59){return{'name':_0x4a5a59[_0x53f1('0x3a')],'type':_0x4a5a59[_0x53f1('0x3b')][_0x53f1('0x3c')]};})[_0x53f1('0x2e')](function(_0x120cd6){return!_[_0x53f1('0x32')]([_0x53f1('0x3d'),_0x53f1('0x3e')],_0x120cd6['name']);})[_0x53f1('0x31')]();_0x5fa0f9=qs[_0x53f1('0x3f')](_0x174567,_0x50bcaa);var _0x2d5e1c={'where':_0x5fa0f9[_0x53f1('0x40')]};return db['User'][_0x53f1('0x25')](_0x2d5e1c)[_0x53f1('0x14')](function(_0x1030cc){_0x4fedc6[_0x53f1('0x25')]=_0x1030cc;if(_0x50bcaa[_0x53f1('0x41')][_0x53f1('0x42')]){_0x5fa0f9[_0x53f1('0x43')]=[{'all':!![]}];}if(_0x50bcaa[_0x53f1('0x41')][_0x53f1('0x44')]===_0x53f1('0x45')){_0x5fa0f9[_0x53f1('0x43')]=[{'model':db[_0x53f1('0x46')],'as':_0x53f1('0x44')}];}if(!_[_0x53f1('0x32')](_0x5fa0f9[_0x53f1('0x47')],'id')){_0x5fa0f9['attributes'][_0x53f1('0x48')]('id');}return db[_0x53f1('0x49')][_0x53f1('0x4a')](_0x5fa0f9);})[_0x53f1('0x14')](function(_0x1408c6){_0x4fedc6[_0x53f1('0x4b')]=_0x1408c6;if(_0x50bcaa[_0x53f1('0x41')]['openTabs']==='true'){var _0xce72c1=[];for(var _0x57de05=0x0;_0x57de05<_0x4fedc6[_0x53f1('0x4b')][_0x53f1('0x4c')];_0x57de05++){_0xce72c1['push'](get_open_tabs('chat',_0x4fedc6[_0x53f1('0x4b')][_0x57de05][_0x53f1('0x4d')]));_0xce72c1[_0x53f1('0x48')](get_open_tabs(_0x53f1('0x4e'),_0x4fedc6[_0x53f1('0x4b')][_0x57de05][_0x53f1('0x4d')]));_0xce72c1[_0x53f1('0x48')](get_open_tabs(_0x53f1('0x4f'),_0x4fedc6[_0x53f1('0x4b')][_0x57de05]['dataValues']));_0xce72c1[_0x53f1('0x48')](get_open_tabs('mail',_0x4fedc6[_0x53f1('0x4b')][_0x57de05]['dataValues']));_0xce72c1[_0x53f1('0x48')](get_open_tabs(_0x53f1('0x50'),_0x4fedc6[_0x53f1('0x4b')][_0x57de05][_0x53f1('0x4d')]));_0xce72c1[_0x53f1('0x48')](get_open_tabs('whatsapp',_0x4fedc6[_0x53f1('0x4b')][_0x57de05][_0x53f1('0x4d')]));}return BPromise[_0x53f1('0x51')](_0xce72c1)['then'](function(){return _0x4fedc6;});}else{return _0x4fedc6;}})[_0x53f1('0x14')](respondWithFilteredResult(_0x5b76fd,_0x5fa0f9))['catch'](handleError(_0x5b76fd,null));};exports[_0x53f1('0x52')]=function(_0x64609,_0x40238a){var _0x363fc8={'raw':![],'where':{'id':_0x64609[_0x53f1('0x53')]['id']}},_0x152052={};_0x152052[_0x53f1('0x54')]=_[_0x53f1('0x55')](_[_0x53f1('0x56')](db['User'][_0x53f1('0x39')]),['password',_0x53f1('0x3e')]);_0x152052['query']=_[_0x53f1('0x56')](_0x64609[_0x53f1('0x41')]);_0x152052[_0x53f1('0x57')]=_[_0x53f1('0x58')](_0x152052[_0x53f1('0x54')],_0x152052['query']);_0x363fc8['attributes']=_[_0x53f1('0x58')](_0x152052[_0x53f1('0x54')],qs['fields'](_0x64609[_0x53f1('0x41')]['fields']));_0x363fc8['attributes']=_0x363fc8['attributes'][_0x53f1('0x4c')]?_0x363fc8[_0x53f1('0x47')]:_0x152052[_0x53f1('0x54')];if(_0x64609[_0x53f1('0x41')]['includeAll']){_0x363fc8[_0x53f1('0x43')]=[{'all':!![]}];}if(_0x64609[_0x53f1('0x41')][_0x53f1('0x44')]==='true'){_0x363fc8['include']=[{'model':db[_0x53f1('0x46')],'as':_0x53f1('0x44')}];}_0x363fc8=_[_0x53f1('0x59')]({},_0x363fc8,_0x64609['options']);if(!_[_0x53f1('0x32')](_0x363fc8[_0x53f1('0x47')],'id')){_0x363fc8[_0x53f1('0x47')][_0x53f1('0x48')]('id');}return db[_0x53f1('0x49')][_0x53f1('0x33')](_0x363fc8)[_0x53f1('0x14')](handleEntityNotFound(_0x40238a,null))[_0x53f1('0x14')](function(_0x56f3a3){var _0x218654=[];values=_0x56f3a3;if(_0x64609[_0x53f1('0x41')][_0x53f1('0x5a')]===_0x53f1('0x45')){_0x218654['push'](get_open_tabs('chat',_0x56f3a3['dataValues']));_0x218654[_0x53f1('0x48')](get_open_tabs('sms',_0x56f3a3[_0x53f1('0x4d')]));_0x218654[_0x53f1('0x48')](get_open_tabs(_0x53f1('0x50'),_0x56f3a3[_0x53f1('0x4d')]));_0x218654['push'](get_open_tabs(_0x53f1('0x5b'),_0x56f3a3[_0x53f1('0x4d')]));_0x218654['push'](get_open_tabs('fax',_0x56f3a3[_0x53f1('0x4d')]));_0x218654[_0x53f1('0x48')](get_open_tabs(_0x53f1('0x5c'),_0x56f3a3[_0x53f1('0x4d')]));return BPromise[_0x53f1('0x51')](_0x218654);}else{return values;}})[_0x53f1('0x14')](function(){return values;})[_0x53f1('0x14')](respondWithResult(_0x40238a,null))[_0x53f1('0x1d')](handleError(_0x40238a,null));};exports['update']=function(_0x26ac37,_0x906f68){if(_0x26ac37[_0x53f1('0x5d')]['id']){delete _0x26ac37['body']['id'];}delete _0x26ac37[_0x53f1('0x5d')]['role'];return db[_0x53f1('0x49')][_0x53f1('0x33')]({'where':{'id':_0x26ac37[_0x53f1('0x53')]['id']}})['then'](handleEntityNotFound(_0x906f68,null))[_0x53f1('0x14')](saveUpdates(_0x26ac37[_0x53f1('0x5d')],null))[_0x53f1('0x14')](respondWithResult(_0x906f68,null))[_0x53f1('0x1d')](handleError(_0x906f68,null));};exports[_0x53f1('0x5e')]=function(_0x2f9153,_0x3f5cff){return db[_0x53f1('0x49')]['describe']()[_0x53f1('0x14')](respondWithResult(_0x3f5cff,null))[_0x53f1('0x1d')](handleError(_0x3f5cff,null));};exports[_0x53f1('0x5f')]=function(_0x3ba863,_0x304de8){return db[_0x53f1('0x49')][_0x53f1('0x33')]({'where':{'id':_0x3ba863[_0x53f1('0x53')]['id']}})[_0x53f1('0x14')](handleEntityNotFound(_0x304de8,null))['then'](function(_0x1325ca){if(_0x1325ca){return _0x1325ca[_0x53f1('0x5f')](_0x3ba863[_0x53f1('0x5d')][_0x53f1('0x60')],_['omit'](_0x3ba863[_0x53f1('0x5d')],[_0x53f1('0x60'),'id'])||{});}})[_0x53f1('0x14')](respondWithResult(_0x304de8,null))[_0x53f1('0x1d')](handleError(_0x304de8,null));};function validateUser(_0xea4489){return new BPromise(function(_0x2e32d4,_0x33feb2){if(_0xea4489[_0x53f1('0x61')])return _0x2e32d4(_0xea4489);return db[_0x53f1('0x62')][_0x53f1('0x63')](0x1)[_0x53f1('0x14')](function(_0x143446){if(_0x143446[_0x53f1('0x64')])authService['validatePasswordPattern'](_0xea4489[_0x53f1('0x3d')]);db[_0x53f1('0x49')][_0x53f1('0x65')]('internal')['then'](function(_0xc85a7){if(_['isNil'](_0xc85a7)){_0xea4489[_0x53f1('0x61')]=_0x143446[_0x53f1('0x66')]||0x1;return;}if(_[_0x53f1('0x67')](_0x143446[_0x53f1('0x66')])||_0x143446[_0x53f1('0x66')]===_0xc85a7){_0xea4489['internal']=_0xc85a7+0x1;return;}if(_0x143446['min_internal']>_0xc85a7){_0xea4489[_0x53f1('0x61')]=_0x143446[_0x53f1('0x66')];return;}return db[_0x53f1('0x68')][_0x53f1('0x41')](_0x53f1('0x69'),{'type':db[_0x53f1('0x68')]['QueryTypes']['SELECT']})[_0x53f1('0x14')](function(_0x3b9b19){if(_0x3b9b19&&_0x3b9b19[_0x53f1('0x4c')]){for(var _0x1365fc=0x0,_0x18b28d=_0x3b9b19[_0x53f1('0x4c')];_0x1365fc<_0x18b28d&&_['isNil'](_0xea4489[_0x53f1('0x61')]);_0x1365fc++){if(_0x143446['min_internal']<=_0x3b9b19[_0x1365fc]['from']){_0xea4489['internal']=_0x3b9b19[_0x1365fc][_0x53f1('0x6a')];}else if(_0x143446[_0x53f1('0x66')]>_0x3b9b19[_0x1365fc][_0x53f1('0x6a')]&&_0x143446[_0x53f1('0x66')]<=_0x3b9b19[_0x1365fc]['to']){_0xea4489[_0x53f1('0x61')]=_0x143446[_0x53f1('0x66')];}}}if(_[_0x53f1('0x67')](_0xea4489[_0x53f1('0x61')])){_0xea4489[_0x53f1('0x61')]=_0xc85a7+0x1;}return _0x2e32d4(_0xea4489);});});})[_0x53f1('0x1d')](function(_0x181bac){_0x33feb2(_0x181bac);});});}function updateUser(_0x1023ad){return new BPromise(function(_0x283489,_0x22be00){try{if(_0x1023ad[_0x53f1('0x6b')]){_0x1023ad['mailbox']=_0x1023ad[_0x53f1('0x61')];_0x1023ad['VoiceMail']={'mailbox':_0x1023ad['internal'],'password':_0x1023ad[_0x53f1('0x3d')],'fullname':_0x1023ad[_0x53f1('0x6c')],'email':_0x1023ad[_0x53f1('0x6d')]};}if(_0x1023ad[_0x53f1('0x34')]===_0x53f1('0x2b')){if(!_0x1023ad[_0x53f1('0x6e')])_0x1023ad[_0x53f1('0x6e')]=[_0x53f1('0x6f'),_0x53f1('0x70'),_0x53f1('0x71'),'113',_0x53f1('0x72'),'104','105',_0x53f1('0x73'),_0x53f1('0x74'),_0x53f1('0x75'),'109',_0x53f1('0x76'),'111',_0x53f1('0x77'),_0x53f1('0x78')];}_0x283489(_0x1023ad);}catch(_0x4f2ee1){_0x22be00(_0x4f2ee1);}});}exports[_0x53f1('0x79')]=function(_0x5b798f,_0x6c7c56){if(_0x5b798f['user'][_0x53f1('0x34')]===_0x53f1('0x2b'))throw new Error(_0x53f1('0x7a'));if(_0x5b798f[_0x53f1('0x5d')][_0x53f1('0x34')]===_0x53f1('0x7b')&&_0x5b798f['user']['role']!==_0x53f1('0x7c')){throw new Error(_0x53f1('0x7d'));}if(_0x5b798f[_0x53f1('0x5d')]['role']===_0x53f1('0x7c')&&_0x5b798f[_0x53f1('0x7b')][_0x53f1('0x34')]!==_0x53f1('0x7c')){throw new Error(_0x53f1('0x7e'));}return licenseUtil[_0x53f1('0x7f')]([_0x5b798f['body']])[_0x53f1('0x14')](function(){return validateUser(_0x5b798f[_0x53f1('0x5d')]);})[_0x53f1('0x14')](function(_0x2195d8){return updateUser(_0x2195d8)[_0x53f1('0x14')](function(_0x4d381c){if(_0x4d381c[_0x53f1('0x34')]===_0x53f1('0x7c')){_0x4d381c[_0x53f1('0x80')]=_0x5b798f[_0x53f1('0x7b')]['settingsEnabled'];delete _0x4d381c['userProfileId'];}return _0x4d381c;});})[_0x53f1('0x14')](function(_0xfd6938){return db[_0x53f1('0x49')]['create'](_0xfd6938,{'include':[{'model':db[_0x53f1('0x81')],'as':_0x53f1('0x81')}]});})[_0x53f1('0x14')](function(_0x5f196b){if(_0x5b798f['body'][_0x53f1('0x34')]==='user')return _0x5f196b;if(_0x5b798f[_0x53f1('0x7b')][_0x53f1('0x34')]!==_0x53f1('0x7b'))return _0x5f196b;return db['UserProfileSection'][_0x53f1('0x33')]({'where':{'name':_0x5f196b[_0x53f1('0x34')]===_0x53f1('0x2b')?_0x53f1('0x82'):_0x53f1('0x2c'),'userProfileId':_0x5b798f[_0x53f1('0x7b')][_0x53f1('0x83')]},'raw':!![]})[_0x53f1('0x14')](function(_0x5623d0){if(!_0x5623d0||_0x5623d0[_0x53f1('0x84')]!=0x0)return _0x5f196b;return db[_0x53f1('0x85')][_0x53f1('0x79')]({'name':_0x5f196b[_0x53f1('0x35')],'resourceId':_0x5f196b['id'],'type':_0x5623d0[_0x53f1('0x35')],'sectionId':_0x5623d0['id']},{})[_0x53f1('0x14')](function(){return _0x5f196b;});})['catch'](function(_0x25646e){logger['error'](_0x53f1('0x86'),_0x25646e);throw _0x25646e;});})['then'](respondWithResult(_0x6c7c56,0xc9))[_0x53f1('0x1d')](handleError(_0x6c7c56,null));};exports[_0x53f1('0x87')]=function(_0x579bd6,_0x2b70b0){var _0x5c0cad=_0x579bd6[_0x53f1('0x5d')];var _0x2e5cea=[];if(_0x579bd6[_0x53f1('0x7b')]['role']==='agent')throw new Error('Unauthorized');if(_[_0x53f1('0x88')](_0x5c0cad,[_0x53f1('0x34'),_0x53f1('0x7b')])&&_0x579bd6[_0x53f1('0x7b')][_0x53f1('0x34')]!=='admin'){throw new Error(_0x53f1('0x7d'));}if(_['some'](_0x5c0cad,[_0x53f1('0x34'),_0x53f1('0x7c')])&&_0x579bd6[_0x53f1('0x7b')]['role']!=='admin'){throw new Error(_0x53f1('0x89'));}return licenseUtil['checkUserLimits'](_0x5c0cad)[_0x53f1('0x14')](function(){return validateUser(_0x5c0cad[0x0]);})[_0x53f1('0x14')](function(){for(var _0x469272=0x1;_0x469272<_0x5c0cad[_0x53f1('0x4c')];_0x469272++){var _0x585207=_0x5c0cad[_0x469272-0x1][_0x53f1('0x61')];if(!_0x5c0cad[_0x469272][_0x53f1('0x61')])_0x5c0cad[_0x469272][_0x53f1('0x61')]=_0x585207+0x1;_0x2e5cea[_0x53f1('0x48')](validateUser(_0x5c0cad[_0x469272]));}return BPromise[_0x53f1('0x51')](_0x2e5cea);})[_0x53f1('0x14')](function(){_0x2e5cea=[];for(var _0x39103c=0x0;_0x39103c<_0x5c0cad['length'];_0x39103c++){_0x2e5cea[_0x53f1('0x48')](updateUser(_0x5c0cad[_0x39103c]));}return BPromise[_0x53f1('0x51')](_0x2e5cea);})['then'](function(){return BPromise[_0x53f1('0x8a')](_0x5c0cad,function(_0x176066){return db[_0x53f1('0x49')]['create'](_0x176066,{'include':[{'model':db[_0x53f1('0x81')],'as':_0x53f1('0x81')}]})[_0x53f1('0x14')](function(_0x251bcd){_0x176066['id']=_0x251bcd['id'];return _0x176066;});});})[_0x53f1('0x14')](function(_0x5cba92){if(_0x579bd6['body'][_0x53f1('0x34')]===_0x53f1('0x7b'))return _0x5cba92;if(_0x579bd6['user']['role']!==_0x53f1('0x7b'))return _0x5cba92;var _0x15151e=_[_0x53f1('0x88')](_0x5cba92,function(_0x3741d4){return _0x3741d4[_0x53f1('0x34')]===_0x53f1('0x2b')||_0x3741d4[_0x53f1('0x34')]==='telephone';});if(!_0x15151e)return _0x5cba92;return db[_0x53f1('0x8b')]['findAll']({'where':{'name':{'$or':['Agents',_0x53f1('0x2c')]},'userProfileId':_0x579bd6[_0x53f1('0x7b')][_0x53f1('0x83')]},'raw':!![]})['then'](function(_0x2d4f64){if(_[_0x53f1('0x8c')](_0x2d4f64)||!_[_0x53f1('0x88')](_0x2d4f64,[_0x53f1('0x84'),0x0]))return _0x5cba92;_0x2e5cea=[];var _0x409b76=_(_0x2d4f64)[_0x53f1('0x30')](function(_0x198b96){if(_0x198b96[_0x53f1('0x84')]===0x1)return;return _0x198b96['name']===_0x53f1('0x82')?_0x53f1('0x2b'):_0x53f1('0x2d');})[_0x53f1('0x8d')]()[_0x53f1('0x31')]();for(var _0x1f4607=0x0;_0x1f4607<_0x5cba92[_0x53f1('0x4c')];_0x1f4607++){if(!_[_0x53f1('0x32')](_0x409b76,_0x5cba92[_0x1f4607][_0x53f1('0x34')]))return;var _0x592e5e=_0x5cba92[_0x1f4607][_0x53f1('0x34')]===_0x53f1('0x2b')?_0x53f1('0x82'):_0x53f1('0x2c');_0x2e5cea['push'](db[_0x53f1('0x85')][_0x53f1('0x79')]({'name':_0x5cba92[_0x1f4607][_0x53f1('0x35')],'resourceId':_0x5cba92[_0x1f4607]['id'],'type':_0x592e5e,'sectionId':_[_0x53f1('0x33')](_0x2d4f64,[_0x53f1('0x35'),_0x592e5e])['id']},{}));}return BPromise[_0x53f1('0x51')](_0x2e5cea);});})['then'](respondWithResult(_0x2b70b0,0xc9))[_0x53f1('0x1d')](handleError(_0x2b70b0,null));};exports[_0x53f1('0x8e')]=function(_0x37d95e,_0x421f41){if(_0x37d95e[_0x53f1('0x5d')]['id']){delete _0x37d95e['body']['id'];}return db[_0x53f1('0x49')]['find']({'where':{'id':_0x37d95e[_0x53f1('0x53')]['id']}})[_0x53f1('0x14')](function(_0xbb7a56){if(!_0xbb7a56)return null;if(_0xbb7a56['id']===_0x37d95e['user']['id']){if(!_0x37d95e[_0x53f1('0x5d')][_0x53f1('0x8f')]||!_0x37d95e[_0x53f1('0x5d')][_0x53f1('0x90')]){throw new db[(_0x53f1('0x91'))][(_0x53f1('0x92'))](_0x53f1('0x93'));}if(!_0xbb7a56['authenticate'](_0x37d95e['body'][_0x53f1('0x8f')])){throw new db['Sequelize']['ValidationError'](_0x53f1('0x94'));}if(_0x37d95e[_0x53f1('0x5d')][_0x53f1('0x8f')]===_0x37d95e[_0x53f1('0x5d')][_0x53f1('0x90')]){throw new db[(_0x53f1('0x91'))][(_0x53f1('0x92'))](_0x53f1('0x95'));}}else if(_0x37d95e[_0x53f1('0x7b')]['role']===_0x53f1('0x7c')){if(!_0x37d95e[_0x53f1('0x5d')][_0x53f1('0x90')]){throw new db['Sequelize'][(_0x53f1('0x92'))](_0x53f1('0x96'));}}else if(_0x37d95e['user'][_0x53f1('0x34')]===_0x53f1('0x7b')){if(!_0x37d95e[_0x53f1('0x5d')]['newPassword']){throw new db[(_0x53f1('0x91'))][(_0x53f1('0x92'))](_0x53f1('0x96'));}if(_0xbb7a56[_0x53f1('0x34')]!==_0x53f1('0x2b')){throw new db[(_0x53f1('0x91'))][(_0x53f1('0x92'))]('Unauthorized');}}else{throw new db['Sequelize'][(_0x53f1('0x92'))]('Unauthorized');}return _0xbb7a56;})[_0x53f1('0x14')](handleEntityNotFound(_0x421f41,null))[_0x53f1('0x14')](function(_0x221367){return db[_0x53f1('0x62')]['findOne']({'attributes':['id','securePassword',_0x53f1('0x97'),_0x53f1('0x98')]})[_0x53f1('0x14')](function(_0x1b249f){if(_0x1b249f[_0x53f1('0x64')])authService[_0x53f1('0x99')](_0x37d95e[_0x53f1('0x5d')][_0x53f1('0x90')]);if(!_0x1b249f['enforcePasswordHistory']||!_0x221367[_0x53f1('0x9a')])return _0x221367;authService[_0x53f1('0x9b')](_0x37d95e[_0x53f1('0x5d')][_0x53f1('0x90')],_0x221367[_0x53f1('0x9a')],_0x1b249f[_0x53f1('0x98')]);return _0x221367;})[_0x53f1('0x14')](saveUpdates({'password':_0x37d95e[_0x53f1('0x5d')][_0x53f1('0x90')],'passwordResetAt':_0x37d95e[_0x53f1('0x7b')]['id']==_0x37d95e[_0x53f1('0x53')]['id']?moment():null,'previousPasswords':authService[_0x53f1('0x9c')](_0x37d95e[_0x53f1('0x5d')][_0x53f1('0x90')],_0x221367['previousPasswords'])},null));})[_0x53f1('0x14')](respondWithResult(_0x421f41,null))[_0x53f1('0x1d')](handleError(_0x421f41,null));};exports[_0x53f1('0x9d')]=function(_0x58d00a,_0x2fde15){var _0x38d793=_0x58d00a['body']['channel'];return db['User'][_0x53f1('0x33')]({'where':{'id':_0x58d00a[_0x53f1('0x53')]['id']},'attributes':['id',_0x53f1('0x35'),'role',_0x53f1('0x9e'),'loginInPause',_0x53f1('0x9f'),_0x53f1('0xa0')]})[_0x53f1('0x14')](handleEntityNotFound(_0x2fde15,null))[_0x53f1('0x14')](function(_0x10adf5){if(_0x10adf5){if(!utils[_0x53f1('0xa1')](_0x38d793)){throw new db[(_0x53f1('0x91'))][(_0x53f1('0x92'))](_0x53f1('0xa2'));}return _0x10adf5[_0x53f1('0xa3')+_[_0x53f1('0xa4')](_0x38d793[_0x53f1('0xa5')]())+_0x53f1('0xa6')](_0x58d00a[_0x53f1('0x5d')]['ids'],{'penalty':_0x58d00a[_0x53f1('0x5d')][_0x53f1('0xa7')]||0x0})['spread'](function(_0x44e787){for(var _0x5b50fc=0x0;_0x5b50fc<_0x58d00a[_0x53f1('0x5d')]['ids'][_0x53f1('0x4c')];_0x5b50fc+=0x1){var _0x4324b3={'UserId':Number(_0x58d00a[_0x53f1('0x53')]['id'])};_0x4324b3[_[_0x53f1('0xa4')](_0x38d793[_0x53f1('0xa5')]())+_0x53f1('0xa8')]=Number(_0x58d00a[_0x53f1('0x5d')][_0x53f1('0x60')][_0x5b50fc]);socket['emit'](_0x53f1('0x7b')+_[_0x53f1('0xa4')](_0x38d793[_0x53f1('0xa5')]())+'Queue:save',_0x4324b3);}return _0x44e787;})['then'](function(){if(_0x38d793===_0x53f1('0xa9')){return db[_0x53f1('0xaa')][_0x53f1('0x4a')]({'where':{'id':_0x58d00a['body'][_0x53f1('0x60')]||[]},'raw':!![],'attributes':['id',_0x53f1('0x35')]});}})['then'](function(_0x31f243){var _0x5ddff5=_0x10adf5[_0x53f1('0x2a')]({'plain':!![]});var _0x52a3db=[];if(_0x38d793===_0x53f1('0xa9')&&_0x5ddff5[_0x53f1('0x34')]==='agent'&&_0x5ddff5['online']){for(var _0x150870=0x0;_0x150870<_0x31f243[_0x53f1('0x4c')];_0x150870+=0x1){_0x52a3db['push']({'membername':_0x5ddff5[_0x53f1('0x35')],'UserId':_0x5ddff5['id'],'queue_name':_0x31f243[_0x150870][_0x53f1('0x35')],'VoiceQueueId':_0x31f243[_0x150870]['id'],'interface':_['isNil'](_0x5ddff5['interface'])?util[_0x53f1('0xab')](_0x53f1('0xac'),_0x5ddff5['name']):_0x5ddff5[_0x53f1('0xa0')],'paused':_0x5ddff5[_0x53f1('0x9f')]||![],'penalty':_0x58d00a['body']['penalty']||0x0});}return BPromise[_0x53f1('0x8a')](_0x52a3db,function(_0x9e627d){return db[_0x53f1('0xad')][_0x53f1('0xae')](_0x9e627d);});}return _0x10adf5;});}})[_0x53f1('0x14')](respondWithStatusCode(_0x2fde15,null))['catch'](handleError(_0x2fde15,null));};exports[_0x53f1('0xaf')]=function(_0xe41c59,_0x55d9ee){var _0x2351f5,_0x5551ad;return db[_0x53f1('0x49')]['find']({'where':{'id':_0xe41c59['params']['id']},'attributes':['id','name',_0x53f1('0x34')]})['then'](handleEntityNotFound(_0x55d9ee,null))[_0x53f1('0x14')](function(_0x2ee513){if(_0x2ee513){_0x2351f5=_0x2ee513;if(!_0xe41c59[_0x53f1('0x41')]['channel']||!utils['isValidChannel'](_0xe41c59['query'][_0x53f1('0xb0')])){throw new db[(_0x53f1('0x91'))][(_0x53f1('0x92'))](_0x53f1('0xa2'));}return _0x2ee513[_0x53f1('0xb1')+_[_0x53f1('0xa4')](_0xe41c59[_0x53f1('0x41')]['channel']['toLowerCase']())+'Queues'](_0xe41c59[_0x53f1('0x41')]['ids']);}})[_0x53f1('0x14')](function(_0x82ae31){if(_['isArray'](_0xe41c59[_0x53f1('0x41')][_0x53f1('0x60')])){for(var _0x4283ee=0x0;_0x4283ee<_0xe41c59[_0x53f1('0x41')]['ids'][_0x53f1('0x4c')];_0x4283ee+=0x1){_0x5551ad={'UserId':Number(_0xe41c59[_0x53f1('0x53')]['id'])};_0x5551ad[_[_0x53f1('0xa4')](_0xe41c59['query'][_0x53f1('0xb0')][_0x53f1('0xa5')]())+'QueueId']=Number(_0xe41c59[_0x53f1('0x41')][_0x53f1('0x60')][_0x4283ee]);socket[_0x53f1('0xb2')](_0x53f1('0x7b')+_[_0x53f1('0xa4')](_0xe41c59[_0x53f1('0x41')][_0x53f1('0xb0')][_0x53f1('0xa5')]())+_0x53f1('0xb3'),_0x5551ad);}}else{_0x5551ad={'UserId':Number(_0xe41c59[_0x53f1('0x53')]['id'])};_0x5551ad[_[_0x53f1('0xa4')](_0xe41c59[_0x53f1('0x41')][_0x53f1('0xb0')][_0x53f1('0xa5')]())+_0x53f1('0xa8')]=Number(_0xe41c59[_0x53f1('0x41')][_0x53f1('0x60')]);socket[_0x53f1('0xb2')](_0x53f1('0x7b')+_[_0x53f1('0xa4')](_0xe41c59[_0x53f1('0x41')]['channel'][_0x53f1('0xa5')]())+_0x53f1('0xb3'),_0x5551ad);}return _0x82ae31;})[_0x53f1('0x14')](function(){if(_0xe41c59[_0x53f1('0x41')][_0x53f1('0xb0')]===_0x53f1('0xa9')){return db[_0x53f1('0xad')]['destroy']({'where':{'UserId':_0xe41c59[_0x53f1('0x53')]['id'],'VoiceQueueId':_0xe41c59['query']['ids']},'individualHooks':!![]})['then'](function(){return _0x2351f5;});}return _0x2351f5;})[_0x53f1('0x14')](respondWithStatusCode(_0x55d9ee,null))[_0x53f1('0x1d')](handleError(_0x55d9ee,null));};exports[_0x53f1('0xb4')]=function(_0x4475bc,_0x4c6f5f){_0x4475bc[_0x53f1('0x5d')]['userpic']=_0x4475bc[_0x53f1('0xb5')]['filename'];return db['User'][_0x53f1('0x33')]({'where':{'id':_0x4475bc[_0x53f1('0x53')]['id']}})[_0x53f1('0x14')](handleEntityNotFound(_0x4c6f5f,null))[_0x53f1('0x14')](saveUpdates(_0x4475bc[_0x53f1('0x5d')],null))['then'](respondWithResult(_0x4c6f5f,null))[_0x53f1('0x1d')](handleError(_0x4c6f5f,null));};exports[_0x53f1('0xb6')]=function(_0x32cafa,_0x5d1570){var _0x4e27b3=path[_0x53f1('0xb7')](config[_0x53f1('0xb8')],'server/files/images/logos/default_profile.png');return db[_0x53f1('0x49')][_0x53f1('0x33')]({'where':{'id':_0x32cafa[_0x53f1('0x53')]['id']},'attributes':['id',_0x53f1('0xb9')],'raw':!![]})[_0x53f1('0x14')](handleEntityNotFound(_0x5d1570,null))[_0x53f1('0x14')](function(_0x1519cb){if(_0x1519cb){if(_[_0x53f1('0x67')](_0x1519cb[_0x53f1('0xb9')])){return _0x5d1570[_0x53f1('0xba')](_0x4e27b3);}else{if(!fs[_0x53f1('0xbb')](path[_0x53f1('0xb7')](config[_0x53f1('0xb8')],_0x53f1('0xbc'),_0x1519cb['userpic']))){return _0x5d1570[_0x53f1('0xba')](_0x4e27b3);}return _0x5d1570[_0x53f1('0xba')](path[_0x53f1('0xb7')](config[_0x53f1('0xb8')],_0x53f1('0xbc'),_0x1519cb['userpic']));}}})[_0x53f1('0x1d')](handleError(_0x5d1570,null));};exports[_0x53f1('0xbd')]=function(_0x2c5e22,_0x3b042f){return db[_0x53f1('0x49')][_0x53f1('0x33')]({'where':{'id':_0x2c5e22[_0x53f1('0x53')]['id']},'attributes':['id']})['then'](handleEntityNotFound(_0x3b042f,null))[_0x53f1('0x14')](function(_0x716931){var _0x3c309b=[];values=_0x716931[_0x53f1('0x4d')];_0x3c309b[_0x53f1('0x48')](get_open_tabs(_0x53f1('0xbe'),_0x716931[_0x53f1('0x4d')]));_0x3c309b[_0x53f1('0x48')](get_open_tabs(_0x53f1('0x4e'),_0x716931[_0x53f1('0x4d')]));_0x3c309b[_0x53f1('0x48')](get_open_tabs(_0x53f1('0x50'),_0x716931['dataValues']));_0x3c309b[_0x53f1('0x48')](get_open_tabs('whatsapp',_0x716931[_0x53f1('0x4d')]));_0x3c309b[_0x53f1('0x48')](get_open_tabs(_0x53f1('0x4f'),_0x716931[_0x53f1('0x4d')]));_0x3c309b[_0x53f1('0x48')](get_open_tabs(_0x53f1('0x5c'),_0x716931[_0x53f1('0x4d')]));return BPromise[_0x53f1('0x51')](_0x3c309b);})[_0x53f1('0x14')](function(_0x52949c){if(_0x52949c){var _0x1fc4d7=_[_0x53f1('0x30')](values['ChatOpenTabs'],function(_0xe8e115){return{'channel':_0x53f1('0xbf'),'id':_0xe8e115['id'],'createdAt':_0xe8e115[_0x53f1('0xc0')]};});var _0x376e64=_[_0x53f1('0x30')](values[_0x53f1('0xc1')],function(_0x3c27fb){return{'channel':_0x53f1('0xc2'),'id':_0x3c27fb['id'],'createdAt':_0x3c27fb['createdAt']};});var _0x1b2675=_[_0x53f1('0x30')](values[_0x53f1('0xc3')],function(_0x2d9a06){return{'channel':_0x53f1('0xc4'),'id':_0x2d9a06['id'],'createdAt':_0x2d9a06['createdAt']};});var _0x35c7df=_[_0x53f1('0x30')](values['MailOpenTabs'],function(_0x13b8b7){return{'channel':'MAIL','id':_0x13b8b7['id'],'createdAt':_0x13b8b7['createdAt']};});var _0x242400=_['map'](values[_0x53f1('0xc5')],function(_0x3e0867){return{'channel':_0x53f1('0xc6'),'id':_0x3e0867['id'],'createdAt':_0x3e0867['createdAt']};});var _0x2283da=_['map'](values[_0x53f1('0xc7')],function(_0x4f9439){return{'channel':_0x53f1('0xc8'),'id':_0x4f9439['id'],'createdAt':_0x4f9439[_0x53f1('0xc0')]};});var _0x20162a=_['concat'](_0x1fc4d7,_0x376e64,_0x1b2675,_0x35c7df,_0x242400,_0x2283da);var _0x123a59={'count':_0x20162a[_0x53f1('0x4c')],'rows':_0x20162a};return _0x123a59;}else return null;})['then'](respondWithResult(_0x3b042f,null))[_0x53f1('0x1d')](handleError(_0x3b042f,null));};exports[_0x53f1('0xc9')]=function(_0x49fffe,_0x548ab5){var _0x4cbf55={};var _0x3631c2={};var _0xc85227;var _0x4400b2;return db[_0x53f1('0x49')][_0x53f1('0xca')]({'where':{'id':_0x49fffe[_0x53f1('0x53')]['id']}})[_0x53f1('0x14')](handleEntityNotFound(_0x548ab5,null))['then'](function(_0x3f1cec){if(_0x3f1cec){_0xc85227=_0x3f1cec;_0x3631c2[_0x53f1('0x54')]=_['keys'](db[_0x53f1('0xcb')][_0x53f1('0x39')]);_0x3631c2[_0x53f1('0x41')]=_['keys'](_0x49fffe[_0x53f1('0x41')]);_0x3631c2[_0x53f1('0x57')]=_[_0x53f1('0x58')](_0x3631c2[_0x53f1('0x54')],_0x3631c2[_0x53f1('0x41')]);_0x4cbf55['attributes']=_['intersection'](_0x3631c2['model'],qs['fields'](_0x49fffe['query'][_0x53f1('0xcc')]));_0x4cbf55[_0x53f1('0x47')]=_0x4cbf55['attributes'][_0x53f1('0x4c')]?_0x4cbf55['attributes']:_0x3631c2['model'];_0x4cbf55[_0x53f1('0xcd')]=qs[_0x53f1('0xce')](_0x49fffe[_0x53f1('0x41')][_0x53f1('0xce')]);_0x4cbf55['where']=qs['filters'](_[_0x53f1('0xcf')](_0x49fffe['query'],_0x3631c2[_0x53f1('0x57')]));if(_0x49fffe[_0x53f1('0x41')][_0x53f1('0x2e')]){_0x4cbf55[_0x53f1('0x40')]=_[_0x53f1('0x59')](_0x4cbf55[_0x53f1('0x40')],{'$or':_[_0x53f1('0x30')](_0x4cbf55[_0x53f1('0x47')],function(_0x495380){var _0x14cb0f={};_0x14cb0f[_0x495380]={'$like':'%'+_0x49fffe[_0x53f1('0x41')][_0x53f1('0x2e')]+'%'};return _0x14cb0f;})});}_0x4cbf55=_[_0x53f1('0x59')]({},_0x4cbf55,_0x49fffe[_0x53f1('0xd0')]);return _0xc85227[_0x53f1('0xc9')](_0x4cbf55);}})[_0x53f1('0x14')](function(_0x2e4b01){if(_0x2e4b01){_0x4400b2=_0x2e4b01[_0x53f1('0x4c')];if(_0x49fffe[_0x53f1('0x41')][_0x53f1('0xd1')](_0x53f1('0x42'))){_0x4cbf55['include']=[{'model':db['CmList'],'as':'List','required':![]},{'model':db[_0x53f1('0xd2')],'as':_0x53f1('0xd3'),'attributes':['id',_0x53f1('0x35'),_0x53f1('0xd4')],'where':_0x49fffe[_0x53f1('0x41')][_0x53f1('0xd5')]?{'id':_0x49fffe[_0x53f1('0x41')]['tag']}:undefined,'required':_0x49fffe[_0x53f1('0x41')][_0x53f1('0xd5')]?!![]:![]}];}if(!_0x49fffe['query'][_0x53f1('0xd1')](_0x53f1('0xd6'))){_0x4cbf55['limit']=qs[_0x53f1('0x23')](_0x49fffe[_0x53f1('0x41')][_0x53f1('0x23')]);_0x4cbf55['offset']=qs[_0x53f1('0x24')](_0x49fffe['query']['offset']);}return _0xc85227[_0x53f1('0xc9')](_0x4cbf55);}})[_0x53f1('0x14')](function(_0x5a2b97){if(_0x5a2b97){return _0x5a2b97?{'count':_0x4400b2,'rows':_0x5a2b97}:null;}})[_0x53f1('0x14')](respondWithResult(_0x548ab5,null))[_0x53f1('0x1d')](handleError(_0x548ab5,null));};exports[_0x53f1('0xd7')]=function(_0x53192c,_0x6c34f4){var _0x33159a;var _0x4c0fc9={};var _0x58863a;return db[_0x53f1('0x49')][_0x53f1('0xca')]({'where':{'id':_0x53192c[_0x53f1('0x53')]['id']},'attributes':['id',_0x53f1('0x35'),_0x53f1('0x34')]})[_0x53f1('0x14')](handleEntityNotFound(_0x6c34f4,null))[_0x53f1('0x14')](function(_0x451a3f){if(!utils[_0x53f1('0xa1')](_0x53192c[_0x53f1('0x41')][_0x53f1('0xb0')])){throw new db[(_0x53f1('0x91'))]['ValidationError'](_0x53f1('0xa2'));}_0x33159a=_0x451a3f;var _0x42bd99={};_0x42bd99[_0x53f1('0x54')]=_[_0x53f1('0x56')](db[_[_0x53f1('0xa4')](_0x53192c[_0x53f1('0x41')][_0x53f1('0xb0')])+'Queue']['rawAttributes']);_0x42bd99[_0x53f1('0x41')]=_[_0x53f1('0x56')](_0x53192c[_0x53f1('0x41')]);_0x42bd99[_0x53f1('0x57')]=_[_0x53f1('0x58')](_0x42bd99[_0x53f1('0x54')],_0x42bd99[_0x53f1('0x41')]);_0x4c0fc9[_0x53f1('0x47')]=_[_0x53f1('0x58')](_0x42bd99[_0x53f1('0x54')],qs[_0x53f1('0xcc')](_0x53192c[_0x53f1('0x41')][_0x53f1('0xcc')]));_0x4c0fc9[_0x53f1('0x47')]=_0x4c0fc9['attributes'][_0x53f1('0x4c')]?_0x4c0fc9['attributes']:_0x42bd99['model'];_0x4c0fc9[_0x53f1('0xcd')]=qs['sort'](_0x53192c['query'][_0x53f1('0xce')]);_0x4c0fc9[_0x53f1('0x40')]=qs['filters'](_[_0x53f1('0xcf')](_0x53192c[_0x53f1('0x41')],_0x42bd99[_0x53f1('0x57')]));if(_0x53192c['query']['filter']){_0x4c0fc9['where']=_[_0x53f1('0x59')](_0x4c0fc9['where'],{'$or':_['map'](_0x4c0fc9['attributes'],function(_0x11ee0c){var _0x319668={};_0x319668[_0x11ee0c]={'$like':'%'+_0x53192c[_0x53f1('0x41')]['filter']+'%'};return _0x319668;})});}_0x4c0fc9=_[_0x53f1('0x59')]({},_0x4c0fc9,_0x53192c[_0x53f1('0xd0')]);switch(_0x33159a[_0x53f1('0x34')]){case _0x53f1('0x7c'):return db[_[_0x53f1('0xa4')](_0x53192c['query'][_0x53f1('0xb0')])+_0x53f1('0xd8')][_0x53f1('0x4a')](_0x4c0fc9);case _0x53f1('0x7b'):case _0x53f1('0x2b'):return _0x33159a[_0x53f1('0x2a')+_[_0x53f1('0xa4')](_0x53192c[_0x53f1('0x41')]['channel'])+_0x53f1('0xa6')](_0x4c0fc9);default:throw new db['Sequelize'][(_0x53f1('0x92'))](_0x53f1('0xd9'));}})[_0x53f1('0x14')](function(_0x3d76c9){_0x58863a=_0x3d76c9[_0x53f1('0x4c')];if(!_0x53192c['query'][_0x53f1('0xd1')](_0x53f1('0xd6'))){_0x4c0fc9['limit']=qs['limit'](_0x53192c[_0x53f1('0x41')][_0x53f1('0x23')]);_0x4c0fc9[_0x53f1('0x24')]=qs[_0x53f1('0x24')](_0x53192c['query'][_0x53f1('0x24')]);}switch(_0x33159a['role']){case _0x53f1('0x7c'):return db[_[_0x53f1('0xa4')](_0x53192c[_0x53f1('0x41')]['channel'])+_0x53f1('0xd8')][_0x53f1('0x4a')](_0x4c0fc9);case _0x53f1('0x7b'):case'agent':return _0x33159a['get'+_[_0x53f1('0xa4')](_0x53192c[_0x53f1('0x41')][_0x53f1('0xb0')])+_0x53f1('0xa6')](_0x4c0fc9);}})['then'](function(_0x5c6dd6){return{'count':_0x58863a,'rows':_0x5c6dd6};})[_0x53f1('0x14')](respondWithResult(_0x6c34f4,null))[_0x53f1('0x1d')](handleError(_0x6c34f4,null));};exports['getVoiceQueuesRt']=function(_0x312f24,_0x5f05e0){var _0x316a5={};var _0x3512cf={};var _0x30ca16;var _0x1fc9d2;return db[_0x53f1('0x49')][_0x53f1('0xca')]({'where':{'id':_0x312f24['params']['id']}})[_0x53f1('0x14')](handleEntityNotFound(_0x5f05e0,null))[_0x53f1('0x14')](function(_0x288a26){if(_0x288a26){_0x30ca16=_0x288a26;_0x3512cf['model']=_['keys'](db[_0x53f1('0xad')]['rawAttributes']);_0x3512cf[_0x53f1('0x41')]=_[_0x53f1('0x56')](_0x312f24['query']);_0x3512cf[_0x53f1('0x57')]=_[_0x53f1('0x58')](_0x3512cf[_0x53f1('0x54')],_0x3512cf[_0x53f1('0x41')]);_0x316a5['attributes']=_[_0x53f1('0x58')](_0x3512cf[_0x53f1('0x54')],qs[_0x53f1('0xcc')](_0x312f24[_0x53f1('0x41')]['fields']));_0x316a5[_0x53f1('0x47')]=_0x316a5[_0x53f1('0x47')][_0x53f1('0x4c')]?_0x316a5['attributes']:_0x3512cf[_0x53f1('0x54')];_0x316a5[_0x53f1('0xcd')]=qs[_0x53f1('0xce')](_0x312f24['query'][_0x53f1('0xce')]);_0x316a5[_0x53f1('0x40')]=qs[_0x53f1('0x57')](_[_0x53f1('0xcf')](_0x312f24['query'],_0x3512cf[_0x53f1('0x57')]));if(_0x312f24['query'][_0x53f1('0x2e')]){_0x316a5[_0x53f1('0x40')]=_[_0x53f1('0x59')](_0x316a5[_0x53f1('0x40')],{'$or':_[_0x53f1('0x30')](_0x316a5[_0x53f1('0x47')],function(_0xd6fdf0){var _0x5604df={};_0x5604df[_0xd6fdf0]={'$like':'%'+_0x312f24[_0x53f1('0x41')][_0x53f1('0x2e')]+'%'};return _0x5604df;})});}_0x316a5=_['merge']({},_0x316a5,_0x312f24[_0x53f1('0xd0')]);return _0x30ca16[_0x53f1('0xda')](_0x316a5);}})['then'](function(_0x29e9b2){if(_0x29e9b2){_0x1fc9d2=_0x29e9b2[_0x53f1('0x4c')];if(!_0x312f24[_0x53f1('0x41')][_0x53f1('0xd1')]('nolimit')){_0x316a5[_0x53f1('0x23')]=qs[_0x53f1('0x23')](_0x312f24['query'][_0x53f1('0x23')]);_0x316a5[_0x53f1('0x24')]=qs[_0x53f1('0x24')](_0x312f24['query']['offset']);}return _0x30ca16[_0x53f1('0xda')](_0x316a5);}})[_0x53f1('0x14')](function(_0xccd2ac){if(_0xccd2ac){return _0xccd2ac?{'count':_0x1fc9d2,'rows':_0xccd2ac}:null;}})['then'](respondWithResult(_0x5f05e0,null))[_0x53f1('0x1d')](handleError(_0x5f05e0,null));};exports[_0x53f1('0xdb')]=function(_0x24f094,_0x4d71ca){var _0x4d00bb={};var _0x152389={};var _0x52a96e;var _0x3f579f;return db['User'][_0x53f1('0xca')]({'where':{'id':_0x24f094[_0x53f1('0x53')]['id']}})[_0x53f1('0x14')](handleEntityNotFound(_0x4d71ca,null))['then'](function(_0x379922){if(_0x379922){_0x52a96e=_0x379922;_0x152389[_0x53f1('0x54')]=_[_0x53f1('0x56')](db[_0x53f1('0xdc')][_0x53f1('0x39')]);_0x152389['query']=_['keys'](_0x24f094['query']);_0x152389[_0x53f1('0x57')]=_[_0x53f1('0x58')](_0x152389['model'],_0x152389['query']);_0x4d00bb[_0x53f1('0x47')]=_['intersection'](_0x152389['model'],qs[_0x53f1('0xcc')](_0x24f094[_0x53f1('0x41')][_0x53f1('0xcc')]));_0x4d00bb[_0x53f1('0x47')]=_0x4d00bb[_0x53f1('0x47')][_0x53f1('0x4c')]?_0x4d00bb[_0x53f1('0x47')]:_0x152389[_0x53f1('0x54')];_0x4d00bb['order']=qs[_0x53f1('0xce')](_0x24f094['query']['sort']);_0x4d00bb[_0x53f1('0x40')]=qs[_0x53f1('0x57')](_[_0x53f1('0xcf')](_0x24f094[_0x53f1('0x41')],_0x152389[_0x53f1('0x57')]));if(_0x24f094[_0x53f1('0x41')][_0x53f1('0x2e')]){_0x4d00bb[_0x53f1('0x40')]=_['merge'](_0x4d00bb[_0x53f1('0x40')],{'$or':_[_0x53f1('0x30')](_0x4d00bb[_0x53f1('0x47')],function(_0x5686b2){var _0xe06cfb={};_0xe06cfb[_0x5686b2]={'$like':'%'+_0x24f094['query'][_0x53f1('0x2e')]+'%'};return _0xe06cfb;})});}_0x4d00bb=_[_0x53f1('0x59')]({},_0x4d00bb,_0x24f094[_0x53f1('0xd0')]);return _0x52a96e[_0x53f1('0xdb')](_0x4d00bb);}})[_0x53f1('0x14')](function(_0x3b8c96){if(_0x3b8c96){_0x3f579f=_0x3b8c96['length'];if(!_0x24f094[_0x53f1('0x41')][_0x53f1('0xd1')](_0x53f1('0xd6'))){_0x4d00bb[_0x53f1('0x23')]=qs['limit'](_0x24f094[_0x53f1('0x41')][_0x53f1('0x23')]);_0x4d00bb['offset']=qs['offset'](_0x24f094[_0x53f1('0x41')][_0x53f1('0x24')]);}return _0x52a96e[_0x53f1('0xdb')](_0x4d00bb);}})[_0x53f1('0x14')](function(_0x3308f3){if(_0x3308f3){return _0x3308f3?{'count':_0x3f579f,'rows':_0x3308f3}:null;}})[_0x53f1('0x14')](respondWithResult(_0x4d71ca,null))['catch'](handleError(_0x4d71ca,null));};exports['getRecordings']=function(_0x473a93,_0x4083eb){var _0x4f732a={'raw':!![],'where':{}};var _0x1d4a56={};var _0x18a203={'count':0x0,'rows':[]};return db[_0x53f1('0x49')][_0x53f1('0xca')]({'where':{'id':_0x473a93[_0x53f1('0x53')]['id']}})[_0x53f1('0x14')](handleEntityNotFound(_0x4083eb,null))[_0x53f1('0x14')](function(_0x430353){if(_0x430353){_0x1d4a56[_0x53f1('0x54')]=_['keys'](db[_0x53f1('0xdd')][_0x53f1('0x39')]);_0x1d4a56[_0x53f1('0x41')]=_[_0x53f1('0x56')](_0x473a93['query']);_0x1d4a56[_0x53f1('0x57')]=_[_0x53f1('0x58')](_0x1d4a56[_0x53f1('0x54')],_0x1d4a56['query']);_0x4f732a[_0x53f1('0x47')]=_['intersection'](_0x1d4a56[_0x53f1('0x54')],qs[_0x53f1('0xcc')](_0x473a93['query']['fields']));_0x4f732a['attributes']=_0x4f732a[_0x53f1('0x47')][_0x53f1('0x4c')]?_0x4f732a[_0x53f1('0x47')]:_0x1d4a56['model'];if(!_0x473a93['query'][_0x53f1('0xd1')](_0x53f1('0xd6'))){_0x4f732a['limit']=qs['limit'](_0x473a93['query'][_0x53f1('0x23')]);_0x4f732a[_0x53f1('0x24')]=qs['offset'](_0x473a93['query']['offset']);}_0x4f732a[_0x53f1('0xcd')]=qs[_0x53f1('0xce')](_0x473a93['query']['sort']);_0x4f732a[_0x53f1('0x40')]=qs['filters'](_[_0x53f1('0xcf')](_0x473a93[_0x53f1('0x41')],_0x1d4a56[_0x53f1('0x57')]));_0x4f732a[_0x53f1('0x40')][_0x53f1('0xde')]=_0x430353['id'];if(_0x473a93[_0x53f1('0x41')]['filter']){_0x4f732a[_0x53f1('0x40')]=_['merge'](_0x4f732a[_0x53f1('0x40')],{'$or':_[_0x53f1('0x30')](_0x4f732a[_0x53f1('0x47')],function(_0xf72016){var _0x9ae261={};_0x9ae261[_0xf72016]={'$like':'%'+_0x473a93[_0x53f1('0x41')][_0x53f1('0x2e')]+'%'};return _0x9ae261;})});}_0x4f732a=_[_0x53f1('0x59')]({},_0x4f732a,_0x473a93['options']);return db[_0x53f1('0xdd')][_0x53f1('0x25')]({'where':_0x4f732a[_0x53f1('0x40')]})[_0x53f1('0x14')](function(_0x6603f){_0x18a203['count']=_0x6603f;if(_0x473a93[_0x53f1('0x41')][_0x53f1('0x42')]){_0x4f732a[_0x53f1('0x43')]=[{'all':!![]}];}return db[_0x53f1('0xdd')][_0x53f1('0x4a')](_0x4f732a);})[_0x53f1('0x14')](function(_0x4106fa){_0x18a203[_0x53f1('0x4b')]=_0x4106fa;return _0x18a203;});}})[_0x53f1('0x14')](respondWithFilteredResult(_0x4083eb,_0x4f732a))[_0x53f1('0x1d')](handleError(_0x4083eb,null));};exports[_0x53f1('0xdf')]=function(_0x3312f5,_0xfba993){var _0x465bc1={'raw':!![],'where':{}};var _0x5ded4e={};var _0x1a4970={'count':0x0,'rows':[]};return db['User']['findOne']({'where':{'id':_0x3312f5[_0x53f1('0x53')]['id']}})[_0x53f1('0x14')](handleEntityNotFound(_0xfba993,null))[_0x53f1('0x14')](function(_0x5abc2b){if(_0x5abc2b){_0x5ded4e[_0x53f1('0x54')]=_[_0x53f1('0x56')](db['ScreenRecording'][_0x53f1('0x39')]);_0x5ded4e[_0x53f1('0x41')]=_[_0x53f1('0x56')](_0x3312f5[_0x53f1('0x41')]);_0x5ded4e[_0x53f1('0x57')]=_[_0x53f1('0x58')](_0x5ded4e[_0x53f1('0x54')],_0x5ded4e[_0x53f1('0x41')]);_0x465bc1[_0x53f1('0x47')]=_['intersection'](_0x5ded4e[_0x53f1('0x54')],qs[_0x53f1('0xcc')](_0x3312f5[_0x53f1('0x41')][_0x53f1('0xcc')]));_0x465bc1[_0x53f1('0x47')]=_0x465bc1[_0x53f1('0x47')]['length']?_0x465bc1[_0x53f1('0x47')]:_0x5ded4e['model'];if(!_0x3312f5[_0x53f1('0x41')][_0x53f1('0xd1')](_0x53f1('0xd6'))){_0x465bc1[_0x53f1('0x23')]=qs[_0x53f1('0x23')](_0x3312f5['query'][_0x53f1('0x23')]);_0x465bc1[_0x53f1('0x24')]=qs[_0x53f1('0x24')](_0x3312f5[_0x53f1('0x41')][_0x53f1('0x24')]);}_0x465bc1[_0x53f1('0xcd')]=qs['sort'](_0x3312f5[_0x53f1('0x41')]['sort']);_0x465bc1[_0x53f1('0x40')]=qs[_0x53f1('0x57')](_[_0x53f1('0xcf')](_0x3312f5[_0x53f1('0x41')],_0x5ded4e[_0x53f1('0x57')]));_0x465bc1[_0x53f1('0x40')]['UserId']=_0x5abc2b['id'];if(_0x3312f5[_0x53f1('0x41')][_0x53f1('0x2e')]){_0x465bc1[_0x53f1('0x40')]=_[_0x53f1('0x59')](_0x465bc1[_0x53f1('0x40')],{'$or':_[_0x53f1('0x30')](_0x465bc1[_0x53f1('0x47')],function(_0x53b45d){var _0x1c99c1={};_0x1c99c1[_0x53b45d]={'$like':'%'+_0x3312f5[_0x53f1('0x41')][_0x53f1('0x2e')]+'%'};return _0x1c99c1;})});}_0x465bc1=_[_0x53f1('0x59')]({},_0x465bc1,_0x3312f5[_0x53f1('0xd0')]);return db[_0x53f1('0xe0')][_0x53f1('0x25')]({'where':_0x465bc1[_0x53f1('0x40')]})[_0x53f1('0x14')](function(_0x1b84df){_0x1a4970[_0x53f1('0x25')]=_0x1b84df;if(_0x3312f5['query'][_0x53f1('0x42')]){_0x465bc1[_0x53f1('0x43')]=[{'all':!![]}];}return db[_0x53f1('0xe0')]['findAll'](_0x465bc1);})['then'](function(_0x6580f0){_0x1a4970[_0x53f1('0x4b')]=_0x6580f0;return _0x1a4970;});}})[_0x53f1('0x14')](respondWithFilteredResult(_0xfba993,_0x465bc1))[_0x53f1('0x1d')](handleError(_0xfba993,null));};exports[_0x53f1('0xe1')]=function(_0x528f28,_0x3a0a81){var _0x588e80={};var _0xfe92c5={};var _0x117f28;var _0x4358ef;return db['User']['findOne']({'where':{'id':_0x528f28['params']['id']}})[_0x53f1('0x14')](handleEntityNotFound(_0x3a0a81,null))[_0x53f1('0x14')](function(_0x59dd86){if(_0x59dd86){_0x117f28=_0x59dd86;_0xfe92c5['model']=_[_0x53f1('0x56')](db[_0x53f1('0xe2')]['rawAttributes']);_0xfe92c5[_0x53f1('0x41')]=_['keys'](_0x528f28[_0x53f1('0x41')]);_0xfe92c5[_0x53f1('0x57')]=_[_0x53f1('0x58')](_0xfe92c5[_0x53f1('0x54')],_0xfe92c5[_0x53f1('0x41')]);_0x588e80[_0x53f1('0x47')]=_[_0x53f1('0x58')](_0xfe92c5[_0x53f1('0x54')],qs[_0x53f1('0xcc')](_0x528f28[_0x53f1('0x41')][_0x53f1('0xcc')]));_0x588e80[_0x53f1('0x47')]=_0x588e80[_0x53f1('0x47')][_0x53f1('0x4c')]?_0x588e80[_0x53f1('0x47')]:_0xfe92c5['model'];_0x588e80[_0x53f1('0xcd')]=qs['sort'](_0x528f28[_0x53f1('0x41')][_0x53f1('0xce')]);_0x588e80[_0x53f1('0x40')]=qs['filters'](_[_0x53f1('0xcf')](_0x528f28['query'],_0xfe92c5[_0x53f1('0x57')]));if(_0x528f28['query'][_0x53f1('0x2e')]){_0x588e80[_0x53f1('0x40')]=_['merge'](_0x588e80[_0x53f1('0x40')],{'$or':_[_0x53f1('0x30')](_0x588e80[_0x53f1('0x47')],function(_0x93dd02){var _0x5ee5b8={};_0x5ee5b8[_0x93dd02]={'$like':'%'+_0x528f28[_0x53f1('0x41')][_0x53f1('0x2e')]+'%'};return _0x5ee5b8;})});}_0x588e80=_['merge']({},_0x588e80,_0x528f28['options']);return _0x117f28['getChatInteractions'](_0x588e80);}})['then'](function(_0x3392e0){if(_0x3392e0){_0x4358ef=_0x3392e0[_0x53f1('0x4c')];if(!_0x528f28[_0x53f1('0x41')][_0x53f1('0xd1')](_0x53f1('0xd6'))){_0x588e80[_0x53f1('0x23')]=qs['limit'](_0x528f28[_0x53f1('0x41')]['limit']);_0x588e80[_0x53f1('0x24')]=qs[_0x53f1('0x24')](_0x528f28[_0x53f1('0x41')][_0x53f1('0x24')]);}return _0x117f28[_0x53f1('0xe1')](_0x588e80);}})[_0x53f1('0x14')](function(_0x4c58b8){if(_0x4c58b8){return _0x4c58b8?{'count':_0x4358ef,'rows':_0x4c58b8}:null;}})[_0x53f1('0x14')](respondWithResult(_0x3a0a81,null))[_0x53f1('0x1d')](handleError(_0x3a0a81,null));};exports['getOpenchannelInteractions']=function(_0x4a2aa4,_0x56297b){var _0x1ebaec={};var _0x193678={};var _0x134f60;var _0x2482bf;return db[_0x53f1('0x49')][_0x53f1('0xca')]({'where':{'id':_0x4a2aa4[_0x53f1('0x53')]['id']}})[_0x53f1('0x14')](handleEntityNotFound(_0x56297b,null))[_0x53f1('0x14')](function(_0x43ff8d){if(_0x43ff8d){_0x134f60=_0x43ff8d;_0x193678[_0x53f1('0x54')]=_[_0x53f1('0x56')](db['OpenchannelInteraction'][_0x53f1('0x39')]);_0x193678[_0x53f1('0x41')]=_[_0x53f1('0x56')](_0x4a2aa4[_0x53f1('0x41')]);_0x193678[_0x53f1('0x57')]=_[_0x53f1('0x58')](_0x193678[_0x53f1('0x54')],_0x193678[_0x53f1('0x41')]);_0x1ebaec[_0x53f1('0x47')]=_['intersection'](_0x193678['model'],qs['fields'](_0x4a2aa4['query']['fields']));_0x1ebaec[_0x53f1('0x47')]=_0x1ebaec[_0x53f1('0x47')][_0x53f1('0x4c')]?_0x1ebaec[_0x53f1('0x47')]:_0x193678[_0x53f1('0x54')];_0x1ebaec[_0x53f1('0xcd')]=qs[_0x53f1('0xce')](_0x4a2aa4[_0x53f1('0x41')][_0x53f1('0xce')]);_0x1ebaec[_0x53f1('0x40')]=qs[_0x53f1('0x57')](_['pick'](_0x4a2aa4[_0x53f1('0x41')],_0x193678['filters']));if(_0x4a2aa4[_0x53f1('0x41')][_0x53f1('0x2e')]){_0x1ebaec['where']=_[_0x53f1('0x59')](_0x1ebaec[_0x53f1('0x40')],{'$or':_[_0x53f1('0x30')](_0x1ebaec[_0x53f1('0x47')],function(_0x180e4a){var _0x5d9662={};_0x5d9662[_0x180e4a]={'$like':'%'+_0x4a2aa4[_0x53f1('0x41')][_0x53f1('0x2e')]+'%'};return _0x5d9662;})});}_0x1ebaec=_[_0x53f1('0x59')]({},_0x1ebaec,_0x4a2aa4[_0x53f1('0xd0')]);return _0x134f60[_0x53f1('0xe3')](_0x1ebaec);}})[_0x53f1('0x14')](function(_0x281f4e){if(_0x281f4e){_0x2482bf=_0x281f4e[_0x53f1('0x4c')];if(!_0x4a2aa4[_0x53f1('0x41')][_0x53f1('0xd1')](_0x53f1('0xd6'))){_0x1ebaec[_0x53f1('0x23')]=qs[_0x53f1('0x23')](_0x4a2aa4[_0x53f1('0x41')][_0x53f1('0x23')]);_0x1ebaec[_0x53f1('0x24')]=qs[_0x53f1('0x24')](_0x4a2aa4[_0x53f1('0x41')][_0x53f1('0x24')]);}return _0x134f60[_0x53f1('0xe3')](_0x1ebaec);}})['then'](function(_0x131b59){if(_0x131b59){return _0x131b59?{'count':_0x2482bf,'rows':_0x131b59}:null;}})['then'](respondWithResult(_0x56297b,null))[_0x53f1('0x1d')](handleError(_0x56297b,null));};exports[_0x53f1('0xe4')]=function(_0x313686,_0x51f4c6){var _0x1c6d56={'raw':!![],'where':{}};var _0x224ca9={};var _0x31776c={'count':0x0,'rows':[]};return db[_0x53f1('0x49')]['findOne']({'where':{'id':_0x313686['params']['id']}})[_0x53f1('0x14')](handleEntityNotFound(_0x51f4c6,null))['then'](function(_0x9c5b1d){if(_0x9c5b1d){_0x224ca9[_0x53f1('0x54')]=_[_0x53f1('0x56')](db[_0x53f1('0xe5')][_0x53f1('0x39')]);_0x224ca9[_0x53f1('0x41')]=_[_0x53f1('0x56')](_0x313686['query']);_0x224ca9[_0x53f1('0x57')]=_[_0x53f1('0x58')](_0x224ca9[_0x53f1('0x54')],_0x224ca9[_0x53f1('0x41')]);_0x1c6d56['attributes']=_[_0x53f1('0x58')](_0x224ca9['model'],qs[_0x53f1('0xcc')](_0x313686['query'][_0x53f1('0xcc')]));_0x1c6d56['attributes']=_0x1c6d56[_0x53f1('0x47')]['length']?_0x1c6d56[_0x53f1('0x47')]:_0x224ca9['model'];if(!_0x313686[_0x53f1('0x41')][_0x53f1('0xd1')](_0x53f1('0xd6'))){_0x1c6d56[_0x53f1('0x23')]=qs[_0x53f1('0x23')](_0x313686[_0x53f1('0x41')][_0x53f1('0x23')]);_0x1c6d56[_0x53f1('0x24')]=qs[_0x53f1('0x24')](_0x313686[_0x53f1('0x41')][_0x53f1('0x24')]);}_0x1c6d56[_0x53f1('0xcd')]=qs['sort'](_0x313686[_0x53f1('0x41')][_0x53f1('0xce')]);_0x1c6d56[_0x53f1('0x40')]=qs[_0x53f1('0x57')](_[_0x53f1('0xcf')](_0x313686[_0x53f1('0x41')],_0x224ca9[_0x53f1('0x57')]));_0x1c6d56[_0x53f1('0x40')][_0x53f1('0xde')]=_0x9c5b1d['id'];if(_0x313686[_0x53f1('0x41')][_0x53f1('0x2e')]){_0x1c6d56[_0x53f1('0x40')]=_[_0x53f1('0x59')](_0x1c6d56[_0x53f1('0x40')],{'$or':_[_0x53f1('0x30')](_0x1c6d56['attributes'],function(_0x2a4bc3){var _0x1ac4b8={};_0x1ac4b8[_0x2a4bc3]={'$like':'%'+_0x313686[_0x53f1('0x41')][_0x53f1('0x2e')]+'%'};return _0x1ac4b8;})});}_0x1c6d56=_['merge']({},_0x1c6d56,_0x313686[_0x53f1('0xd0')]);return db[_0x53f1('0xe5')][_0x53f1('0x25')]({'where':_0x1c6d56[_0x53f1('0x40')]})['then'](function(_0x294f5d){_0x31776c['count']=_0x294f5d;if(_0x313686[_0x53f1('0x41')][_0x53f1('0x42')]){_0x1c6d56[_0x53f1('0x43')]=[{'all':!![]}];}return db[_0x53f1('0xe5')]['findAll'](_0x1c6d56);})[_0x53f1('0x14')](function(_0x16e909){_0x31776c[_0x53f1('0x4b')]=_0x16e909;return _0x31776c;});}})[_0x53f1('0x14')](respondWithFilteredResult(_0x51f4c6,_0x1c6d56))['catch'](handleError(_0x51f4c6,null));};exports[_0x53f1('0xe6')]=function(_0x174db3,_0x342196){var _0x38e709={};var _0x15a7e9={};var _0x26fab4;var _0x377cf9;return db['User']['findOne']({'where':{'id':_0x174db3['params']['id']}})['then'](handleEntityNotFound(_0x342196,null))[_0x53f1('0x14')](function(_0x198fa9){if(_0x198fa9){_0x26fab4=_0x198fa9;_0x15a7e9[_0x53f1('0x54')]=_[_0x53f1('0x56')](db[_0x53f1('0xe7')][_0x53f1('0x39')]);_0x15a7e9[_0x53f1('0x41')]=_[_0x53f1('0x56')](_0x174db3[_0x53f1('0x41')]);_0x15a7e9[_0x53f1('0x57')]=_[_0x53f1('0x58')](_0x15a7e9['model'],_0x15a7e9[_0x53f1('0x41')]);_0x38e709[_0x53f1('0x47')]=_[_0x53f1('0x58')](_0x15a7e9['model'],qs[_0x53f1('0xcc')](_0x174db3[_0x53f1('0x41')][_0x53f1('0xcc')]));_0x38e709[_0x53f1('0x47')]=_0x38e709[_0x53f1('0x47')][_0x53f1('0x4c')]?_0x38e709[_0x53f1('0x47')]:_0x15a7e9[_0x53f1('0x54')];_0x38e709['order']=qs['sort'](_0x174db3[_0x53f1('0x41')]['sort']);_0x38e709[_0x53f1('0x40')]=qs[_0x53f1('0x57')](_[_0x53f1('0xcf')](_0x174db3[_0x53f1('0x41')],_0x15a7e9[_0x53f1('0x57')]));if(_0x174db3[_0x53f1('0x41')][_0x53f1('0x2e')]){_0x38e709[_0x53f1('0x40')]=_['merge'](_0x38e709[_0x53f1('0x40')],{'$or':_[_0x53f1('0x30')](_0x38e709[_0x53f1('0x47')],function(_0x2592f2){var _0x4c78de={};_0x4c78de[_0x2592f2]={'$like':'%'+_0x174db3['query'][_0x53f1('0x2e')]+'%'};return _0x4c78de;})});}_0x38e709=_['merge']({},_0x38e709,_0x174db3[_0x53f1('0xd0')]);return _0x26fab4['getSmsInteractions'](_0x38e709);}})[_0x53f1('0x14')](function(_0x1c66bc){if(_0x1c66bc){_0x377cf9=_0x1c66bc['length'];if(!_0x174db3[_0x53f1('0x41')][_0x53f1('0xd1')](_0x53f1('0xd6'))){_0x38e709['limit']=qs[_0x53f1('0x23')](_0x174db3[_0x53f1('0x41')][_0x53f1('0x23')]);_0x38e709[_0x53f1('0x24')]=qs[_0x53f1('0x24')](_0x174db3['query'][_0x53f1('0x24')]);}return _0x26fab4['getSmsInteractions'](_0x38e709);}})[_0x53f1('0x14')](function(_0x4c69e5){if(_0x4c69e5){return _0x4c69e5?{'count':_0x377cf9,'rows':_0x4c69e5}:null;}})['then'](respondWithResult(_0x342196,null))[_0x53f1('0x1d')](handleError(_0x342196,null));};exports['getFaxInteractions']=function(_0x1dab4a,_0x47c6b5){var _0x4aacdd={};var _0x5932e1={};var _0x34df43;var _0x39820c;return db['User'][_0x53f1('0xca')]({'where':{'id':_0x1dab4a[_0x53f1('0x53')]['id']}})[_0x53f1('0x14')](handleEntityNotFound(_0x47c6b5,null))[_0x53f1('0x14')](function(_0x112933){if(_0x112933){_0x34df43=_0x112933;_0x5932e1[_0x53f1('0x54')]=_[_0x53f1('0x56')](db[_0x53f1('0xe8')][_0x53f1('0x39')]);_0x5932e1[_0x53f1('0x41')]=_[_0x53f1('0x56')](_0x1dab4a[_0x53f1('0x41')]);_0x5932e1[_0x53f1('0x57')]=_[_0x53f1('0x58')](_0x5932e1[_0x53f1('0x54')],_0x5932e1['query']);_0x4aacdd[_0x53f1('0x47')]=_[_0x53f1('0x58')](_0x5932e1[_0x53f1('0x54')],qs[_0x53f1('0xcc')](_0x1dab4a[_0x53f1('0x41')]['fields']));_0x4aacdd['attributes']=_0x4aacdd[_0x53f1('0x47')]['length']?_0x4aacdd[_0x53f1('0x47')]:_0x5932e1['model'];_0x4aacdd[_0x53f1('0xcd')]=qs[_0x53f1('0xce')](_0x1dab4a['query'][_0x53f1('0xce')]);_0x4aacdd[_0x53f1('0x40')]=qs[_0x53f1('0x57')](_[_0x53f1('0xcf')](_0x1dab4a['query'],_0x5932e1['filters']));if(_0x1dab4a['query'][_0x53f1('0x2e')]){_0x4aacdd['where']=_[_0x53f1('0x59')](_0x4aacdd[_0x53f1('0x40')],{'$or':_['map'](_0x4aacdd[_0x53f1('0x47')],function(_0x559796){var _0x41eb21={};_0x41eb21[_0x559796]={'$like':'%'+_0x1dab4a[_0x53f1('0x41')][_0x53f1('0x2e')]+'%'};return _0x41eb21;})});}_0x4aacdd=_[_0x53f1('0x59')]({},_0x4aacdd,_0x1dab4a[_0x53f1('0xd0')]);return _0x34df43[_0x53f1('0xe9')](_0x4aacdd);}})['then'](function(_0x177ae2){if(_0x177ae2){_0x39820c=_0x177ae2[_0x53f1('0x4c')];if(!_0x1dab4a['query'][_0x53f1('0xd1')](_0x53f1('0xd6'))){_0x4aacdd[_0x53f1('0x23')]=qs[_0x53f1('0x23')](_0x1dab4a[_0x53f1('0x41')][_0x53f1('0x23')]);_0x4aacdd[_0x53f1('0x24')]=qs[_0x53f1('0x24')](_0x1dab4a[_0x53f1('0x41')][_0x53f1('0x24')]);}return _0x34df43[_0x53f1('0xe9')](_0x4aacdd);}})[_0x53f1('0x14')](function(_0x1a04d5){if(_0x1a04d5){return _0x1a04d5?{'count':_0x39820c,'rows':_0x1a04d5}:null;}})[_0x53f1('0x14')](respondWithResult(_0x47c6b5,null))[_0x53f1('0x1d')](handleError(_0x47c6b5,null));};exports['getWhatsappInteractions']=function(_0x44c7a4,_0x3a8778){var _0x1cc7bd={};var _0x4331b0={};var _0xd3440a;var _0x51e00a;return db[_0x53f1('0x49')][_0x53f1('0xca')]({'where':{'id':_0x44c7a4[_0x53f1('0x53')]['id']}})[_0x53f1('0x14')](handleEntityNotFound(_0x3a8778,null))[_0x53f1('0x14')](function(_0x7ffc4e){if(_0x7ffc4e){_0xd3440a=_0x7ffc4e;_0x4331b0[_0x53f1('0x54')]=_['keys'](db['WhatsappInteraction'][_0x53f1('0x39')]);_0x4331b0[_0x53f1('0x41')]=_['keys'](_0x44c7a4[_0x53f1('0x41')]);_0x4331b0[_0x53f1('0x57')]=_['intersection'](_0x4331b0[_0x53f1('0x54')],_0x4331b0['query']);_0x1cc7bd['attributes']=_[_0x53f1('0x58')](_0x4331b0[_0x53f1('0x54')],qs[_0x53f1('0xcc')](_0x44c7a4[_0x53f1('0x41')][_0x53f1('0xcc')]));_0x1cc7bd[_0x53f1('0x47')]=_0x1cc7bd[_0x53f1('0x47')][_0x53f1('0x4c')]?_0x1cc7bd['attributes']:_0x4331b0[_0x53f1('0x54')];_0x1cc7bd[_0x53f1('0xcd')]=qs['sort'](_0x44c7a4[_0x53f1('0x41')][_0x53f1('0xce')]);_0x1cc7bd[_0x53f1('0x40')]=qs['filters'](_[_0x53f1('0xcf')](_0x44c7a4[_0x53f1('0x41')],_0x4331b0['filters']));if(_0x44c7a4[_0x53f1('0x41')][_0x53f1('0x2e')]){_0x1cc7bd['where']=_[_0x53f1('0x59')](_0x1cc7bd[_0x53f1('0x40')],{'$or':_[_0x53f1('0x30')](_0x1cc7bd[_0x53f1('0x47')],function(_0x3f5616){var _0x3b2eb4={};_0x3b2eb4[_0x3f5616]={'$like':'%'+_0x44c7a4[_0x53f1('0x41')][_0x53f1('0x2e')]+'%'};return _0x3b2eb4;})});}_0x1cc7bd=_[_0x53f1('0x59')]({},_0x1cc7bd,_0x44c7a4[_0x53f1('0xd0')]);return _0xd3440a[_0x53f1('0xea')](_0x1cc7bd);}})[_0x53f1('0x14')](function(_0x267dde){if(_0x267dde){_0x51e00a=_0x267dde[_0x53f1('0x4c')];if(!_0x44c7a4['query'][_0x53f1('0xd1')](_0x53f1('0xd6'))){_0x1cc7bd[_0x53f1('0x23')]=qs[_0x53f1('0x23')](_0x44c7a4[_0x53f1('0x41')][_0x53f1('0x23')]);_0x1cc7bd[_0x53f1('0x24')]=qs[_0x53f1('0x24')](_0x44c7a4[_0x53f1('0x41')][_0x53f1('0x24')]);}return _0xd3440a['getWhatsappInteractions'](_0x1cc7bd);}})['then'](function(_0x1b0b56){if(_0x1b0b56){return _0x1b0b56?{'count':_0x51e00a,'rows':_0x1b0b56}:null;}})[_0x53f1('0x14')](respondWithResult(_0x3a8778,null))['catch'](handleError(_0x3a8778,null));};exports[_0x53f1('0xeb')]=function(_0x1969b9,_0x1a353e,_0x5a6a2f){var _0x3eac09;var _0x49d033;var _0x3e9024;var _0x2502fa=!_['isNil'](_0x1969b9['params']['id'])?_0x1969b9[_0x53f1('0x53')]['id']:!_[_0x53f1('0x67')](_0x1969b9['user']['id'])?_0x1969b9[_0x53f1('0x7b')]['id']:null;return db[_0x53f1('0x49')][_0x53f1('0x33')]({'where':{'id':_0x2502fa,'role':{'$or':[_0x53f1('0x7c'),_0x53f1('0x7b'),_0x53f1('0x2b')]}},'attributes':['id',_0x53f1('0x35'),_0x53f1('0xec'),'mobile',_0x53f1('0x34'),'internal','loginInPause']})['then'](function(_0x4d48ea){if(_0x4d48ea){if(_0x4d48ea[_0x53f1('0x34')]===_0x53f1('0x2b')){_0x3eac09=_0x4d48ea;if(_0x1969b9['body'][_0x53f1('0xa0')]){_0x3e9024=util[_0x53f1('0xab')](_0x53f1('0xed'),_0x3eac09[_0x1969b9[_0x53f1('0x5d')][_0x53f1('0xa0')]]);}else if(_0x1969b9[_0x53f1('0x5d')][_0x53f1('0xee')]){_0x3e9024=util['format']('SIP/%s',_0x1969b9[_0x53f1('0x5d')]['intrf']);}else{_0x3e9024=util[_0x53f1('0xab')](_0x53f1('0xac'),_0x3eac09[_0x53f1('0x35')]);}socket['to'](util[_0x53f1('0xab')](_0x53f1('0xef'),_0x3eac09[_0x53f1('0x35')]))[_0x53f1('0xb2')](_0x53f1('0xf0'),{'user':{'id':_0x3eac09['id'],'name':_0x3eac09[_0x53f1('0x35')]},'ip':_0x1969b9[_0x53f1('0xf1')][_0x53f1('0xf2')]||_0x1969b9['connection'][_0x53f1('0xf3')]||_0x1969b9[_0x53f1('0xf4')][_0x53f1('0xf3')]||_0x1969b9[_0x53f1('0xf5')][_0x53f1('0xf4')][_0x53f1('0xf3')]});return db[_0x53f1('0xad')][_0x53f1('0x29')]({'where':{'membername':_0x3eac09[_0x53f1('0x35')]},'individualHooks':!![]});}}else{throw new db[(_0x53f1('0x91'))]['ValidationError'](_0x53f1('0xf6'));}})[_0x53f1('0x14')](function(){if(_0x3eac09){return _0x3eac09['getVoiceQueues']({'raw':!![]});}})['then'](function(_0x1961f4){if(_0x3eac09){var _0xb0e2d4=[];if(_0x1961f4){_0x49d033=_0x1961f4;if(_0x49d033['length']){for(var _0x1075ec=0x0;_0x1075ec<_0x49d033[_0x53f1('0x4c')];_0x1075ec++){_0xb0e2d4[_0x53f1('0x48')]({'membername':_0x3eac09[_0x53f1('0x35')],'UserId':_0x3eac09['id'],'queue_name':_0x49d033[_0x1075ec][_0x53f1('0x35')],'VoiceQueueId':_0x49d033[_0x1075ec]['id'],'interface':_0x3e9024,'paused':_0x3eac09[_0x53f1('0xf7')]||![],'penalty':_0x49d033[_0x1075ec][_0x53f1('0xf8')]||0x0});}return BPromise[_0x53f1('0x8a')](_0xb0e2d4,function(_0x4405aa){return db[_0x53f1('0xad')][_0x53f1('0xae')](_0x4405aa);});}}}})[_0x53f1('0x14')](function(){if(_0x3eac09){return db[_0x53f1('0xf9')][_0x53f1('0x4a')]({'where':{'membername':_0x3eac09[_0x53f1('0x35')],'exitAt':null}});}})[_0x53f1('0x14')](function(_0x1b72c7){if(_0x3eac09){var _0x44efa6=[];_0x1b72c7[_0x53f1('0xfa')](function(_0x26bd5f){_0x44efa6[_0x53f1('0x48')](_0x26bd5f[_0x53f1('0x28')]({'exitAt':moment()['format'](_0x53f1('0xfb'))}));});return BPromise[_0x53f1('0x51')](_0x44efa6);}})[_0x53f1('0x14')](function(){if(_0x3eac09){var _0xb8649d=[];var _0xc74f96=[];var _0x25b6a4=utils[_0x53f1('0xfc')]();var _0x565dad={'membername':_0x3eac09[_0x53f1('0x35')],'interface':_0x3e9024,'enterAt':moment()[_0x53f1('0xab')](_0x53f1('0xfb')),'role':_0x3eac09[_0x53f1('0x34')],'internal':_0x3eac09[_0x53f1('0x61')]};_0x25b6a4[_0x53f1('0xfa')](function(_0x105859){_0xb8649d[_0x53f1('0x48')](_[_0x53f1('0x59')]({'channel':_0x105859,'type':_0x53f1('0xfd'),'data1':_0x1969b9[_0x53f1('0x5d')][_0x53f1('0xfe')],'data2':_0x3e9024},_0x565dad));if(_0x3eac09[_0x53f1('0xf7')]){_0xc74f96[_0x53f1('0x48')](_[_0x53f1('0x59')]({'channel':_0x105859,'type':_0x53f1('0xff'),'data1':'LOGININPAUSE'},_0x565dad));}});return db[_0x53f1('0xf9')][_0x53f1('0x87')](_0xb8649d['concat'](_0xc74f96),{'individualHooks':!![]});}})['then'](function(){if(_0x3eac09){return _0x3eac09[_0x53f1('0x28')]({'online':!![],'lastLoginAt':moment()[_0x53f1('0xab')]('YYYY-MM-DD\x20HH:mm:ss'),'voicePause':_0x3eac09['loginInPause']||![],'mailPause':_0x3eac09[_0x53f1('0xf7')]||![],'chatPause':_0x3eac09[_0x53f1('0xf7')]||![],'faxPause':_0x3eac09[_0x53f1('0xf7')]||![],'smsPause':_0x3eac09[_0x53f1('0xf7')]||![],'openchannelPause':_0x3eac09[_0x53f1('0xf7')]||![],'whatsappPause':_0x3eac09[_0x53f1('0xf7')]||![],'pauseType':_0x3eac09['loginInPause']?_0x53f1('0x100'):null,'interface':_0x3e9024,'lastPauseAt':moment()[_0x53f1('0xab')](_0x53f1('0xfb'))});}})['then'](function(_0x55f079){if(_0x1969b9[_0x53f1('0x101')]){return _0x5a6a2f();}else{return BPromise[_0x53f1('0x102')](_0x55f079)[_0x53f1('0x14')](respondWithResult(_0x1a353e,null));}})[_0x53f1('0x1d')](handleError(_0x1a353e,null));};exports['logout']=function(_0x2ff899,_0x308f37){var _0x3bce3f;return db['User'][_0x53f1('0x33')]({'where':{'id':_0x2ff899[_0x53f1('0x53')]['id'],'role':_0x53f1('0x2b')},'attributes':['id',_0x53f1('0x35'),'role']})[_0x53f1('0x14')](handleEntityNotFound(_0x308f37,null))[_0x53f1('0x14')](function(_0x6bf7d5){if(_0x6bf7d5){_0x3bce3f=_0x6bf7d5;return db[_0x53f1('0xad')][_0x53f1('0x29')]({'where':{'membername':_0x3bce3f[_0x53f1('0x35')]},'individualHooks':!![]});}})['then'](function(){return db['MemberReport']['findAll']({'where':{'membername':_0x3bce3f[_0x53f1('0x35')],'exitAt':null}});})[_0x53f1('0x14')](function(_0x55f3c9){var _0x4006cb=[];_0x55f3c9['forEach'](function(_0x111127){_0x4006cb[_0x53f1('0x48')](_0x111127[_0x53f1('0x28')]({'exitAt':moment()[_0x53f1('0xab')](_0x53f1('0xfb'))}));});return BPromise['all'](_0x4006cb);})[_0x53f1('0x14')](function(){return _0x3bce3f[_0x53f1('0x28')]({'online':![],'voicePause':![],'mailPause':![],'chatPause':![],'faxPause':![],'smsPause':![],'openchannelPause':![],'whatsappPause':![],'interface':null});})[_0x53f1('0x14')](respondWithResult(_0x308f37,null))[_0x53f1('0x1d')](handleError(_0x308f37,null));};exports[_0x53f1('0x103')]=function(_0xe39ed3,_0x482e22){var _0x2af287;return db[_0x53f1('0xad')]['update']({'paused':0x1},{'where':{'UserId':_0xe39ed3[_0x53f1('0x53')]['id']},'individualHooks':!![]})[_0x53f1('0x14')](function(){return db[_0x53f1('0x49')][_0x53f1('0x33')]({'where':{'id':_0xe39ed3[_0x53f1('0x53')]['id'],'role':_0x53f1('0x2b')},'attributes':['id',_0x53f1('0x35'),'role',_0x53f1('0x61'),'interface']});})['then'](handleEntityNotFound(_0x482e22,null))[_0x53f1('0x14')](function(_0x1db0e3){if(_0x1db0e3){_0x2af287=_0x1db0e3;return respondWithRpcPromise(_0x53f1('0x104'),_0x53f1('0x103'),{'id':_0x2af287['id'],'name':_0x2af287[_0x53f1('0x35')],'pause':!![]});}})[_0x53f1('0x14')](function(){if(_0x2af287){return db['MemberReport'][_0x53f1('0x4a')]({'where':{'membername':_0x2af287['name'],'type':_0x53f1('0xff'),'exitAt':null}});}})[_0x53f1('0x14')](function(_0x247ed5){if(_0x247ed5[_0x53f1('0x4c')]){var _0xeb1660=moment()[_0x53f1('0xab')](_0x53f1('0xfb'));for(var _0x19ca93=0x0,_0x4a5d74=_0x247ed5[_0x53f1('0x4c')];_0x19ca93<_0x4a5d74;_0x19ca93++){_0x247ed5[_0x19ca93][_0x53f1('0x105')]({'exitAt':_0xeb1660});}}})[_0x53f1('0x14')](function(){var _0x13040e=[];var _0x39e577=utils['getChannels']();_0x39e577[_0x53f1('0xfa')](function(_0x68583d){_0x13040e[_0x53f1('0x48')]({'channel':_0x68583d,'membername':_0x2af287['name'],'interface':_['isNil'](_0x2af287[_0x53f1('0xa0')])?util[_0x53f1('0xab')]('SIP/%s',_0x2af287[_0x53f1('0x35')]):_0x2af287[_0x53f1('0xa0')],'type':_0x53f1('0xff'),'enterAt':moment()[_0x53f1('0xab')](_0x53f1('0xfb')),'data1':_0xe39ed3[_0x53f1('0x5d')][_0x53f1('0x3b')]||_0x53f1('0x106'),'role':_0x2af287[_0x53f1('0x34')],'internal':_0x2af287[_0x53f1('0x61')]});});return db[_0x53f1('0xf9')]['bulkCreate'](_0x13040e,{'individualHooks':!![]});})[_0x53f1('0x14')](function(){return _0x2af287[_0x53f1('0x28')]({'voicePause':!![],'mailPause':!![],'chatPause':!![],'faxPause':!![],'smsPause':!![],'whatsappPause':!![],'openchannelPause':!![],'pauseType':_0xe39ed3[_0x53f1('0x5d')][_0x53f1('0x3b')]||_0x53f1('0x106'),'lastPauseAt':moment()[_0x53f1('0xab')]('YYYY-MM-DD\x20HH:mm:ss')});})[_0x53f1('0x14')](respondWithResult(_0x482e22,null))[_0x53f1('0x1d')](handleError(_0x482e22,null));};exports[_0x53f1('0x107')]=function(_0x544b8c,_0x2885eb){var _0x37879c;return db[_0x53f1('0x49')]['find']({'where':{'id':_0x544b8c['params']['id']},'attributes':['id','name',_0x53f1('0x34'),'voicePause',_0x53f1('0x108'),'chatPause',_0x53f1('0x109'),_0x53f1('0x10a'),'smsPause',_0x53f1('0x10b'),_0x53f1('0x10c'),_0x53f1('0x10d')]})['then'](handleEntityNotFound(_0x2885eb,null))['then'](function(_0x26f5ed){if(_0x26f5ed){_0x37879c=_0x26f5ed;if(_0x544b8c[_0x53f1('0x5d')]['channel']&&!utils[_0x53f1('0xa1')](_0x544b8c[_0x53f1('0x5d')][_0x53f1('0xb0')])){throw new db[(_0x53f1('0x91'))]['ValidationError'](_0x53f1('0xa2'));}switch(_0x544b8c[_0x53f1('0x5d')]['channel']){case _0x53f1('0xa9'):return respondWithRpcPromise(_0x53f1('0x104'),_0x53f1('0x107'),{'id':_0x37879c['id'],'name':_0x37879c[_0x53f1('0x35')],'pause':![]})[_0x53f1('0x14')](function(){return db['UserVoiceQueueRt'][_0x53f1('0x28')]({'paused':0x0},{'where':{'UserId':_0x37879c['id']},'individualHooks':!![]});})[_0x53f1('0x14')](function(){return db[_0x53f1('0xf9')][_0x53f1('0x33')]({'where':{'channel':_0x544b8c[_0x53f1('0x5d')][_0x53f1('0xb0')],'membername':_0x37879c['name'],'type':_0x53f1('0xff'),'exitAt':null}});})[_0x53f1('0x14')](function(_0x567c02){if(_0x567c02){return _0x567c02['update']({'exitAt':moment()[_0x53f1('0xab')](_0x53f1('0xfb')),'data2':_0x53f1('0x10e')},{'individualHooks':!![]});}return null;})[_0x53f1('0x14')](function(){return _0x37879c[_0x53f1('0x28')]({'voicePause':![]});});case _0x53f1('0x5c'):case _0x53f1('0xbe'):case _0x53f1('0x4f'):case'sms':case _0x53f1('0x5b'):case'openchannel':return db['MemberReport']['find']({'where':{'channel':_0x544b8c[_0x53f1('0x5d')][_0x53f1('0xb0')],'membername':_0x37879c['name'],'type':_0x53f1('0xff'),'exitAt':null}})[_0x53f1('0x14')](function(_0x598c38){if(_0x598c38){return _0x598c38['update']({'exitAt':moment()['format'](_0x53f1('0xfb')),'data2':_0x53f1('0x10e')},{'individualHooks':!![]});}return null;})['then'](function(){var _0x14d84d={};_[_0x53f1('0x26')](_0x14d84d,util['format'](_0x53f1('0x10f'),_0x544b8c['body'][_0x53f1('0xb0')],_0x53f1('0x110')),![]);return _0x37879c[_0x53f1('0x28')](_0x14d84d);});default:return respondWithRpcPromise(_0x53f1('0x104'),_0x53f1('0x107'),{'id':_0x37879c['id'],'name':_0x37879c['name'],'pause':![]})[_0x53f1('0x14')](function(){return db['UserVoiceQueueRt'][_0x53f1('0x28')]({'paused':0x0},{'where':{'UserId':_0x37879c['id']}});})[_0x53f1('0x14')](function(){return db[_0x53f1('0xf9')][_0x53f1('0x4a')]({'where':{'membername':_0x37879c[_0x53f1('0x35')],'type':_0x53f1('0xff'),'exitAt':null}});})['then'](function(_0x48ce57){var _0x24b803=[];_0x48ce57[_0x53f1('0xfa')](function(_0xa68881){_0x24b803['push'](_0xa68881[_0x53f1('0x28')]({'exitAt':moment()[_0x53f1('0xab')](_0x53f1('0xfb')),'data2':_0x53f1('0x10e')}));});return BPromise[_0x53f1('0x51')](_0x24b803);})[_0x53f1('0x14')](function(){return _0x37879c[_0x53f1('0x28')]({'voicePause':![],'mailPause':![],'chatPause':![],'faxPause':![],'smsPause':![],'whatsappPause':![],'openchannelPause':![]});});}}})[_0x53f1('0x14')](respondWithResult(_0x2885eb,null))[_0x53f1('0x1d')](handleError(_0x2885eb,null));};exports[_0x53f1('0x111')]=function(_0x1c8212,_0x2d5dc5){var _0x218b08={};var _0x3c60a9={};var _0x5d0e2a;var _0x484b72;return db['User'][_0x53f1('0xca')]({'where':{'id':_0x1c8212['params']['id']}})[_0x53f1('0x14')](handleEntityNotFound(_0x2d5dc5,null))[_0x53f1('0x14')](function(_0x3b9099){if(_0x3b9099){_0x5d0e2a=_0x3b9099;_0x3c60a9[_0x53f1('0x54')]=_['keys'](db['Team'][_0x53f1('0x39')]);_0x3c60a9['query']=_['keys'](_0x1c8212['query']);_0x3c60a9['filters']=_[_0x53f1('0x58')](_0x3c60a9['model'],_0x3c60a9[_0x53f1('0x41')]);_0x218b08[_0x53f1('0x47')]=_[_0x53f1('0x58')](_0x3c60a9[_0x53f1('0x54')],qs[_0x53f1('0xcc')](_0x1c8212[_0x53f1('0x41')]['fields']));_0x218b08['attributes']=_0x218b08[_0x53f1('0x47')][_0x53f1('0x4c')]?_0x218b08['attributes']:_0x3c60a9[_0x53f1('0x54')];_0x218b08[_0x53f1('0xcd')]=qs['sort'](_0x1c8212[_0x53f1('0x41')][_0x53f1('0xce')]);_0x218b08[_0x53f1('0x40')]=qs['filters'](_[_0x53f1('0xcf')](_0x1c8212[_0x53f1('0x41')],_0x3c60a9[_0x53f1('0x57')]));if(_0x1c8212[_0x53f1('0x41')][_0x53f1('0x2e')]){_0x218b08[_0x53f1('0x40')]=_[_0x53f1('0x59')](_0x218b08[_0x53f1('0x40')],{'$or':_['map'](_0x218b08[_0x53f1('0x47')],function(_0xb8a261){var _0x9d66bf={};_0x9d66bf[_0xb8a261]={'$like':'%'+_0x1c8212[_0x53f1('0x41')][_0x53f1('0x2e')]+'%'};return _0x9d66bf;})});}_0x218b08=_[_0x53f1('0x59')]({},_0x218b08,_0x1c8212['options']);return _0x5d0e2a[_0x53f1('0x111')](_0x218b08);}})[_0x53f1('0x14')](function(_0x2c2706){if(_0x2c2706){_0x484b72=_0x2c2706['length'];if(!_0x1c8212['query'][_0x53f1('0xd1')](_0x53f1('0xd6'))){_0x218b08[_0x53f1('0x23')]=qs['limit'](_0x1c8212[_0x53f1('0x41')]['limit']);_0x218b08[_0x53f1('0x24')]=qs[_0x53f1('0x24')](_0x1c8212[_0x53f1('0x41')][_0x53f1('0x24')]);}return _0x5d0e2a[_0x53f1('0x111')](_0x218b08);}})[_0x53f1('0x14')](function(_0xf781fd){if(_0xf781fd){return _0xf781fd?{'count':_0x484b72,'rows':_0xf781fd}:null;}})[_0x53f1('0x14')](respondWithResult(_0x2d5dc5,null))[_0x53f1('0x1d')](handleError(_0x2d5dc5,null));};exports['addTeams']=function(_0x447c9f,_0x1f454d){return db[_0x53f1('0x49')][_0x53f1('0x33')]({'where':{'id':_0x447c9f[_0x53f1('0x53')]['id']}})[_0x53f1('0x14')](handleEntityNotFound(_0x1f454d,null))['then'](function(_0x33b058){if(_0x33b058){var _0x481950=_0x33b058['get']({'plain':!![]});return _0x33b058[_0x53f1('0x112')](_0x447c9f[_0x53f1('0x5d')]['ids'],_[_0x53f1('0x113')](_0x447c9f[_0x53f1('0x5d')],[_0x53f1('0x60'),'id'])||{})[_0x53f1('0x14')](function(){for(var _0x282198=0x0;_0x282198<_0x447c9f[_0x53f1('0x5d')][_0x53f1('0x60')]['length'];_0x282198++){var _0x634497=[];var _0x475697={};db[_0x53f1('0x114')][_0x53f1('0xca')]({'where':{'id':_0x447c9f[_0x53f1('0x5d')][_0x53f1('0x60')][_0x282198]}})[_0x53f1('0x14')](function(_0x126613){_0x475697=_0x126613['dataValues'];_0x634497[_0x53f1('0x48')](_0x126613[_0x53f1('0x115')]()[_0x53f1('0x14')](function(_0x5eb8a9){for(var _0x52765c=0x0;_0x52765c<_0x5eb8a9['length'];_0x52765c++){_0x5eb8a9[_0x52765c]['setDataValue'](_0x53f1('0xb0'),_0x53f1('0x116'));}return _0x5eb8a9;}));_0x634497[_0x53f1('0x48')](_0x126613[_0x53f1('0x117')]()[_0x53f1('0x14')](function(_0xbae364){for(var _0x4cd1d0=0x0;_0x4cd1d0<_0xbae364[_0x53f1('0x4c')];_0x4cd1d0++){_0xbae364[_0x4cd1d0][_0x53f1('0x118')]('channel','Chat');}return _0xbae364;}));_0x634497[_0x53f1('0x48')](_0x126613['getMailQueues']()[_0x53f1('0x14')](function(_0x57aa3a){for(var _0x118fb7=0x0;_0x118fb7<_0x57aa3a[_0x53f1('0x4c')];_0x118fb7++){_0x57aa3a[_0x118fb7][_0x53f1('0x118')]('channel','Mail');}return _0x57aa3a;}));_0x634497[_0x53f1('0x48')](_0x126613[_0x53f1('0x119')]()[_0x53f1('0x14')](function(_0x156f11){for(var _0x486a04=0x0;_0x486a04<_0x156f11[_0x53f1('0x4c')];_0x486a04++){_0x156f11[_0x486a04][_0x53f1('0x118')](_0x53f1('0xb0'),'Sms');}return _0x156f11;}));_0x634497['push'](_0x126613[_0x53f1('0x11a')]()[_0x53f1('0x14')](function(_0x4bb306){for(var _0x4a4f27=0x0;_0x4a4f27<_0x4bb306[_0x53f1('0x4c')];_0x4a4f27++){_0x4bb306[_0x4a4f27][_0x53f1('0x118')](_0x53f1('0xb0'),_0x53f1('0x11b'));}return _0x4bb306;}));_0x634497[_0x53f1('0x48')](_0x126613[_0x53f1('0x11c')]()[_0x53f1('0x14')](function(_0x3821ac){for(var _0x425330=0x0;_0x425330<_0x3821ac[_0x53f1('0x4c')];_0x425330++){_0x3821ac[_0x425330][_0x53f1('0x118')](_0x53f1('0xb0'),_0x53f1('0x11d'));}return _0x3821ac;}));_0x634497['push'](_0x126613[_0x53f1('0x11e')]()[_0x53f1('0x14')](function(_0x127e9a){for(var _0x454ba4=0x0;_0x454ba4<_0x127e9a[_0x53f1('0x4c')];_0x454ba4++){_0x127e9a[_0x454ba4]['setDataValue'](_0x53f1('0xb0'),'Openchannel');}return _0x127e9a;}));return BPromise['all'](_0x634497);})['then'](function(_0x10313f){var _0x52d880=_[_0x53f1('0x11f')](_0x10313f);_0x634497=[];return db['sequelize'][_0x53f1('0x120')](function(_0x3084fe){for(var _0x3a58aa=0x0;_0x3a58aa<_0x52d880['length'];_0x3a58aa++){_0x634497[_0x53f1('0x48')](_0x52d880[_0x3a58aa][_0x53f1('0x121')](_0x481950['id']),{'transaction':_0x3084fe});}return BPromise[_0x53f1('0x51')](_0x634497)[_0x53f1('0x14')](function(){if(_0x481950[_0x53f1('0x9e')]){return BPromise[_0x53f1('0x8a')](_['filter'](_0x52d880,function(_0x3ea682){return _0x3ea682['getDataValue'](_0x53f1('0xb0'))==='Voice';}),function(_0x233ad9){return db[_0x53f1('0xad')][_0x53f1('0xae')]({'membername':_0x481950['name'],'UserId':_0x481950['id'],'queue_name':_0x233ad9[_0x53f1('0x35')],'VoiceQueueId':_0x233ad9['id'],'interface':_[_0x53f1('0x67')](_0x481950[_0x53f1('0xa0')])?util[_0x53f1('0xab')](_0x53f1('0xac'),_0x481950[_0x53f1('0x35')]):_0x481950[_0x53f1('0xa0')],'paused':_0x481950[_0x53f1('0x9f')]||![],'penalty':_0x481950['penalty']},{'transaction':_0x3084fe});});}else{return;}})['then'](function(){for(var _0x5a66c5=0x0;_0x5a66c5<_0x52d880[_0x53f1('0x4c')];_0x5a66c5++){var _0x193ad3=_0x52d880[_0x5a66c5][_0x53f1('0x122')](_0x53f1('0xb0'));var _0x184359=_0x193ad3+_0x53f1('0xa8');socket[_0x53f1('0xb2')]('user'+_0x193ad3+_0x53f1('0x123'),{'UserId':_0x481950['id'],['queueField']:_0x52d880[_0x5a66c5]['id']});}});});})['then'](function(){db['TeamVoicePrefix'][_0x53f1('0xca')]({'where':{'teamId':_0x475697['id']}})[_0x53f1('0x14')](function(_0x40a6b5){if(_0x40a6b5){db['UserVoicePrefix'][_0x53f1('0x79')]({'UserId':_0x447c9f[_0x53f1('0x53')]['id'],'VoicePrefixId':_0x40a6b5[_0x53f1('0x124')]});}});});}});}})[_0x53f1('0x14')](respondWithStatusCode(_0x1f454d,null))[_0x53f1('0x1d')](handleError(_0x1f454d,null));};exports['removeTeams']=function(_0x352047,_0x454cfa){return db['User']['findOne']({'where':{'id':_0x352047['params']['id']}})[_0x53f1('0x14')](handleEntityNotFound(_0x454cfa,null))['then'](function(_0x96c6e5){if(_0x96c6e5){var _0x39afe5=_0x96c6e5[_0x53f1('0x2a')]({'plain':!![]});var _0x2928b3=_0x352047['query']['ids'];return _0x96c6e5['removeTeams'](_0x2928b3)[_0x53f1('0x14')](function(){for(var _0x49e855=0x0;_0x49e855<_0x2928b3['length'];_0x49e855++){var _0xd8e972=[];var _0x5ceb83={};db[_0x53f1('0x114')][_0x53f1('0xca')]({'where':{'id':_0x2928b3[_0x49e855]}})['then'](function(_0x3f974e){_0x5ceb83=_0x3f974e[_0x53f1('0x4d')];_0xd8e972[_0x53f1('0x48')](_0x3f974e[_0x53f1('0x115')]()['then'](function(_0x26d3d3){for(var _0x54ef5a=0x0;_0x54ef5a<_0x26d3d3[_0x53f1('0x4c')];_0x54ef5a++){_0x26d3d3[_0x54ef5a][_0x53f1('0x118')]('channel',_0x53f1('0x116'));}return _0x26d3d3;}));_0xd8e972[_0x53f1('0x48')](_0x3f974e[_0x53f1('0x117')]()[_0x53f1('0x14')](function(_0x45a9b8){for(var _0x329365=0x0;_0x329365<_0x45a9b8[_0x53f1('0x4c')];_0x329365++){_0x45a9b8[_0x329365][_0x53f1('0x118')]('channel',_0x53f1('0x125'));}return _0x45a9b8;}));_0xd8e972[_0x53f1('0x48')](_0x3f974e['getMailQueues']()[_0x53f1('0x14')](function(_0x8a064e){for(var _0x5e5b40=0x0;_0x5e5b40<_0x8a064e['length'];_0x5e5b40++){_0x8a064e[_0x5e5b40][_0x53f1('0x118')](_0x53f1('0xb0'),_0x53f1('0x126'));}return _0x8a064e;}));_0xd8e972[_0x53f1('0x48')](_0x3f974e['getSmsQueues']()['then'](function(_0x52cd06){for(var _0x313cae=0x0;_0x313cae<_0x52cd06[_0x53f1('0x4c')];_0x313cae++){_0x52cd06[_0x313cae][_0x53f1('0x118')](_0x53f1('0xb0'),_0x53f1('0x127'));}return _0x52cd06;}));_0xd8e972['push'](_0x3f974e[_0x53f1('0x11a')]()[_0x53f1('0x14')](function(_0x52de27){for(var _0x2581d4=0x0;_0x2581d4<_0x52de27[_0x53f1('0x4c')];_0x2581d4++){_0x52de27[_0x2581d4][_0x53f1('0x118')](_0x53f1('0xb0'),_0x53f1('0x11b'));}return _0x52de27;}));_0xd8e972['push'](_0x3f974e['getFaxQueues']()['then'](function(_0x3063e1){for(var _0x38ace2=0x0;_0x38ace2<_0x3063e1[_0x53f1('0x4c')];_0x38ace2++){_0x3063e1[_0x38ace2]['setDataValue'](_0x53f1('0xb0'),_0x53f1('0x11d'));}return _0x3063e1;}));_0xd8e972['push'](_0x3f974e['getOpenchannelQueues']()[_0x53f1('0x14')](function(_0x5d832f){for(var _0xbc5fed=0x0;_0xbc5fed<_0x5d832f[_0x53f1('0x4c')];_0xbc5fed++){_0x5d832f[_0xbc5fed]['setDataValue'](_0x53f1('0xb0'),_0x53f1('0x128'));}return _0x5d832f;}));return BPromise[_0x53f1('0x51')](_0xd8e972);})[_0x53f1('0x14')](function(_0x5a690e){var _0xb302f6=_[_0x53f1('0x11f')](_0x5a690e);_0xd8e972=[];return db[_0x53f1('0x68')]['transaction'](function(_0xc35347){for(var _0x3262ce=0x0;_0x3262ce<_0xb302f6[_0x53f1('0x4c')];_0x3262ce++){_0xd8e972[_0x53f1('0x48')](_0xb302f6[_0x3262ce]['removeAgent'](_0x39afe5['id']),{'transaction':_0xc35347});}return BPromise[_0x53f1('0x51')](_0xd8e972)[_0x53f1('0x14')](function(){if(_0x39afe5[_0x53f1('0x9e')]){return BPromise[_0x53f1('0x8a')](_['filter'](_0xb302f6,function(_0x2dfd3c){return _0x2dfd3c[_0x53f1('0x122')]('channel')===_0x53f1('0x116');}),function(_0x55225d){return db[_0x53f1('0xad')][_0x53f1('0x29')]({'where':{'VoiceQueueId':_0x55225d['id'],'UserId':_0x39afe5['id']},'transaction':_0xc35347});});}else{return;}})['then'](function(){db[_0x53f1('0x129')][_0x53f1('0xca')]({'where':{'teamId':_0x5ceb83['id']}})[_0x53f1('0x14')](function(_0x56d32b){if(_0x56d32b){return db[_0x53f1('0x12a')][_0x53f1('0x29')]({'where':{'UserId':_0x39afe5['id'],'VoicePrefixId':_0x56d32b[_0x53f1('0x4d')][_0x53f1('0x124')]}});}});})[_0x53f1('0x14')](function(){for(var _0x143375=0x0;_0x143375<_0xb302f6[_0x53f1('0x4c')];_0x143375++){var _0x24a2eb=_0xb302f6[_0x143375][_0x53f1('0x122')](_0x53f1('0xb0'));var _0x55b42c=_0x24a2eb+_0x53f1('0xa8');socket[_0x53f1('0xb2')]('user'+_0x24a2eb+_0x53f1('0xb3'),{'UserId':_0x39afe5['id'],['queueField']:_0xb302f6[_0x143375]['id']});}});});});}});}})['then'](respondWithStatusCode(_0x454cfa,null))[_0x53f1('0x1d')](handleError(_0x454cfa,null));};exports[_0x53f1('0x12b')]=function(_0x1bc542,_0x571ad2){var _0x15322f={};var _0x9ac3a={};var _0x2dfde6;var _0x44166e;return db[_0x53f1('0x49')][_0x53f1('0xca')]({'where':{'id':_0x1bc542['params']['id']}})[_0x53f1('0x14')](handleEntityNotFound(_0x571ad2,null))[_0x53f1('0x14')](function(_0xfc50b6){if(_0xfc50b6){_0x2dfde6=_0xfc50b6;_0x9ac3a['model']=_[_0x53f1('0x56')](db['CmList'][_0x53f1('0x39')]);_0x9ac3a['query']=_[_0x53f1('0x56')](_0x1bc542[_0x53f1('0x41')]);_0x9ac3a[_0x53f1('0x57')]=_[_0x53f1('0x58')](_0x9ac3a[_0x53f1('0x54')],_0x9ac3a[_0x53f1('0x41')]);_0x15322f[_0x53f1('0x47')]=_[_0x53f1('0x58')](_0x9ac3a['model'],qs[_0x53f1('0xcc')](_0x1bc542['query'][_0x53f1('0xcc')]));_0x15322f['attributes']=_0x15322f['attributes'][_0x53f1('0x4c')]?_0x15322f['attributes']:_0x9ac3a[_0x53f1('0x54')];_0x15322f[_0x53f1('0xcd')]=qs['sort'](_0x1bc542['query'][_0x53f1('0xce')]);_0x15322f[_0x53f1('0x40')]=qs[_0x53f1('0x57')](_['pick'](_0x1bc542['query'],_0x9ac3a['filters']));if(_0x1bc542[_0x53f1('0x41')][_0x53f1('0x2e')]){_0x15322f[_0x53f1('0x40')]=_[_0x53f1('0x59')](_0x15322f[_0x53f1('0x40')],{'$or':_['map'](_0x15322f[_0x53f1('0x47')],function(_0x11af17){var _0x16a5f8={};_0x16a5f8[_0x11af17]={'$like':'%'+_0x1bc542[_0x53f1('0x41')][_0x53f1('0x2e')]+'%'};return _0x16a5f8;})});}_0x15322f=_['merge']({},_0x15322f,_0x1bc542[_0x53f1('0xd0')]);return _0x2dfde6[_0x53f1('0x12b')](_0x15322f);}})[_0x53f1('0x14')](function(_0x237be6){if(_0x237be6){_0x44166e=_0x237be6[_0x53f1('0x4c')];if(!_0x1bc542[_0x53f1('0x41')][_0x53f1('0xd1')](_0x53f1('0xd6'))){_0x15322f['limit']=qs[_0x53f1('0x23')](_0x1bc542[_0x53f1('0x41')][_0x53f1('0x23')]);_0x15322f['offset']=qs[_0x53f1('0x24')](_0x1bc542[_0x53f1('0x41')]['offset']);}return _0x2dfde6[_0x53f1('0x12b')](_0x15322f);}})[_0x53f1('0x14')](function(_0x30a205){if(_0x30a205){return _0x30a205?{'count':_0x44166e,'rows':_0x30a205}:null;}})[_0x53f1('0x14')](respondWithResult(_0x571ad2,null))[_0x53f1('0x1d')](handleError(_0x571ad2,null));};exports[_0x53f1('0x12c')]=function(_0x1f41f3,_0x48b4e6){var _0x5277eb={};var _0x50eb98={};var _0xb372e9;return db[_0x53f1('0x49')][_0x53f1('0xca')]({'where':{'id':_0x1f41f3[_0x53f1('0x53')]['id']}})[_0x53f1('0x14')](handleEntityNotFound(_0x48b4e6,null))['then'](function(_0x31a40a){if(_0x31a40a){_0xb372e9=_0x31a40a;_0x50eb98[_0x53f1('0x54')]=_[_0x53f1('0x56')](db[_0x53f1('0x49')][_0x53f1('0x39')]);_0x50eb98[_0x53f1('0x41')]=_[_0x53f1('0x56')](_0x1f41f3['query']);_0x50eb98[_0x53f1('0x57')]=_['intersection'](_0x50eb98[_0x53f1('0x54')],_0x50eb98['query']);_0x5277eb['attributes']=_[_0x53f1('0x58')](_0x50eb98[_0x53f1('0x54')],qs[_0x53f1('0xcc')](_0x1f41f3['query'][_0x53f1('0xcc')]));_0x5277eb[_0x53f1('0x47')]=_0x5277eb[_0x53f1('0x47')][_0x53f1('0x4c')]?_0x5277eb[_0x53f1('0x47')]:_0x50eb98[_0x53f1('0x54')];_0x5277eb[_0x53f1('0xcd')]=qs[_0x53f1('0xce')](_0x1f41f3[_0x53f1('0x41')][_0x53f1('0xce')]);_0x5277eb[_0x53f1('0x40')]=qs[_0x53f1('0x57')](_[_0x53f1('0xcf')](_0x1f41f3[_0x53f1('0x41')],_0x50eb98[_0x53f1('0x57')]));if(_0x1f41f3[_0x53f1('0x41')][_0x53f1('0x2e')]){_0x5277eb[_0x53f1('0x40')]=_[_0x53f1('0x59')](_0x5277eb[_0x53f1('0x40')],{'$or':_[_0x53f1('0x30')](_0x5277eb[_0x53f1('0x47')],function(_0x39e5b1){var _0x54c5dc={};_0x54c5dc[_0x39e5b1]={'$like':'%'+_0x1f41f3[_0x53f1('0x41')][_0x53f1('0x2e')]+'%'};return _0x54c5dc;})});}_0x5277eb[_0x53f1('0x54')]=db['User'];_0x5277eb['as']=_0x53f1('0x82');_0x5277eb=_['merge']({},_0x5277eb,_0x1f41f3[_0x53f1('0xd0')]);return _0xb372e9[_0x53f1('0x115')]({'include':[_0x5277eb]});}})[_0x53f1('0x14')](function(_0x1fbdf3){if(_0x1fbdf3){var _0x3448e2={},_0x7c61=[];for(var _0x11963d=0x0;_0x11963d<_0x1fbdf3[_0x53f1('0x4c')];_0x11963d+=0x1){for(var _0x3e85b3=0x0,_0x34753d;_0x3e85b3<_0x1fbdf3[_0x11963d][_0x53f1('0x82')]['length'];_0x3e85b3+=0x1){_0x34753d=_0x1fbdf3[_0x11963d][_0x53f1('0x82')][_0x3e85b3]['get']({'plain':!![]});_0x3448e2[_0x34753d['id']]=_0x34753d;}}_0x3448e2=_[_0x53f1('0x12d')](_0x3448e2);for(var _0x58b940=qs[_0x53f1('0x24')](_0x1f41f3[_0x53f1('0x41')]['offset']);_0x58b940<_0x3448e2['length']&&_0x7c61['length']<qs['limit'](_0x1f41f3[_0x53f1('0x41')][_0x53f1('0x23')]);_0x58b940+=0x1){if(_0x3448e2[_0x58b940]){_0x7c61[_0x53f1('0x48')](_0x3448e2[_0x58b940]);}}return{'count':_0x3448e2['length'],'rows':_0x7c61};}})[_0x53f1('0x14')](respondWithResult(_0x48b4e6,null))[_0x53f1('0x1d')](handleError(_0x48b4e6,null));};exports['destroy']=function(_0xc13c1d,_0x484a8d){if(_0xc13c1d[_0x53f1('0x7b')]['id']==_0xc13c1d['params']['id']){return _0x484a8d[_0x53f1('0x1f')](0x1f4)[_0x53f1('0x37')]({'message':_0x53f1('0x12e')});}return db[_0x53f1('0x49')]['find']({'where':{'id':_0xc13c1d['params']['id']}})[_0x53f1('0x14')](handleEntityNotFound(_0x484a8d,null))[_0x53f1('0x14')](removeEntity(_0x484a8d,null))['catch'](handleError(_0x484a8d,null));};exports[_0x53f1('0x12f')]=function(_0x761056,_0x4b31d7){return db[_0x53f1('0x49')][_0x53f1('0x33')]({'where':{'id':_0x761056[_0x53f1('0x53')]['id']}})[_0x53f1('0x14')](handleEntityNotFound(_0x4b31d7,null))['then'](function(_0x26f5c5){if(_0x26f5c5){return _0x26f5c5[_0x53f1('0x12f')](_0x761056[_0x53f1('0x5d')][_0x53f1('0x60')],_[_0x53f1('0x113')](_0x761056[_0x53f1('0x5d')],[_0x53f1('0x60'),'id'])||{})[_0x53f1('0x130')](function(){for(var _0x5104a2=0x0;_0x5104a2<_0x761056[_0x53f1('0x5d')][_0x53f1('0x60')][_0x53f1('0x4c')];_0x5104a2+=0x1){socket['emit'](_0x53f1('0x131'),{'ChatInteractionId':Number(_0x761056['body'][_0x53f1('0x60')][_0x5104a2]),'UserId':Number(_0x761056['params']['id'])});}return _0x761056[_0x53f1('0x5d')][_0x53f1('0x60')];});}})['then'](respondWithResult(_0x4b31d7,null))[_0x53f1('0x1d')](handleError(_0x4b31d7,null));};exports[_0x53f1('0x132')]=function(_0x45e62d,_0x1725a2){return db[_0x53f1('0x49')][_0x53f1('0x33')]({'where':{'id':_0x45e62d[_0x53f1('0x53')]['id']}})['then'](handleEntityNotFound(_0x1725a2,null))[_0x53f1('0x14')](function(_0x37154c){if(_0x37154c){return _0x37154c[_0x53f1('0x132')](_0x45e62d[_0x53f1('0x41')]['ids'])[_0x53f1('0x14')](function(){if(_[_0x53f1('0x133')](_0x45e62d[_0x53f1('0x41')][_0x53f1('0x60')])){for(var _0x1923de=0x0;_0x1923de<_0x45e62d[_0x53f1('0x41')][_0x53f1('0x60')][_0x53f1('0x4c')];_0x1923de+=0x1){socket[_0x53f1('0xb2')](_0x53f1('0x134'),{'ChatInteractionId':Number(_0x45e62d[_0x53f1('0x41')]['ids'][_0x1923de]),'UserId':Number(_0x45e62d[_0x53f1('0x53')]['id'])});}}else{socket[_0x53f1('0xb2')](_0x53f1('0x134'),{'ChatInteractionId':Number(_0x45e62d[_0x53f1('0x41')]['ids']),'UserId':Number(_0x45e62d['params']['id'])});}});}})['then'](respondWithStatusCode(_0x1725a2,null))['catch'](handleError(_0x1725a2,null));};exports[_0x53f1('0x135')]=function(_0x26965b,_0x28a369){return db[_0x53f1('0x49')]['find']({'where':{'id':_0x26965b[_0x53f1('0x53')]['id']}})[_0x53f1('0x14')](handleEntityNotFound(_0x28a369,null))[_0x53f1('0x14')](function(_0xf90d8){if(_0xf90d8){return _0xf90d8[_0x53f1('0x135')](_0x26965b[_0x53f1('0x5d')]['ids'],_[_0x53f1('0x113')](_0x26965b[_0x53f1('0x5d')],['ids','id'])||{})[_0x53f1('0x130')](function(){for(var _0x627791=0x0;_0x627791<_0x26965b[_0x53f1('0x5d')][_0x53f1('0x60')]['length'];_0x627791+=0x1){socket['emit'](_0x53f1('0x136'),{'MailInteractionId':Number(_0x26965b[_0x53f1('0x5d')][_0x53f1('0x60')][_0x627791]),'UserId':Number(_0x26965b[_0x53f1('0x53')]['id'])});}return _0x26965b['body']['ids'];});}})[_0x53f1('0x14')](respondWithResult(_0x28a369,null))[_0x53f1('0x1d')](handleError(_0x28a369,null));};exports[_0x53f1('0x137')]=function(_0x535e74,_0x10edc5){return db[_0x53f1('0x49')][_0x53f1('0x33')]({'where':{'id':_0x535e74['params']['id']}})[_0x53f1('0x14')](handleEntityNotFound(_0x10edc5,null))[_0x53f1('0x14')](function(_0x43b831){if(_0x43b831){return _0x43b831[_0x53f1('0x137')](_0x535e74['query'][_0x53f1('0x60')])['then'](function(){if(_[_0x53f1('0x133')](_0x535e74[_0x53f1('0x41')][_0x53f1('0x60')])){for(var _0x20b9e2=0x0;_0x20b9e2<_0x535e74['query'][_0x53f1('0x60')][_0x53f1('0x4c')];_0x20b9e2+=0x1){socket['emit'](_0x53f1('0x138'),{'MailInteractionId':Number(_0x535e74[_0x53f1('0x41')][_0x53f1('0x60')][_0x20b9e2]),'UserId':Number(_0x535e74[_0x53f1('0x53')]['id'])});}}else{socket['emit'](_0x53f1('0x138'),{'MailInteractionId':Number(_0x535e74[_0x53f1('0x41')][_0x53f1('0x60')]),'UserId':Number(_0x535e74[_0x53f1('0x53')]['id'])});}});}})[_0x53f1('0x14')](respondWithStatusCode(_0x10edc5,null))['catch'](handleError(_0x10edc5,null));};exports[_0x53f1('0x139')]=function(_0xc8b70e,_0x11eb77){return db['User'][_0x53f1('0x33')]({'where':{'id':_0xc8b70e['params']['id']}})[_0x53f1('0x14')](handleEntityNotFound(_0x11eb77,null))['then'](function(_0x3b28eb){if(_0x3b28eb){return _0x3b28eb[_0x53f1('0x139')](_0xc8b70e[_0x53f1('0x5d')][_0x53f1('0x60')],_[_0x53f1('0x113')](_0xc8b70e[_0x53f1('0x5d')],[_0x53f1('0x60'),'id'])||{})[_0x53f1('0x130')](function(){for(var _0x4507a9=0x0;_0x4507a9<_0xc8b70e['body'][_0x53f1('0x60')][_0x53f1('0x4c')];_0x4507a9+=0x1){socket['emit'](_0x53f1('0x13a'),{'FaxInteractionId':Number(_0xc8b70e['body'][_0x53f1('0x60')][_0x4507a9]),'UserId':Number(_0xc8b70e['params']['id'])});}return _0xc8b70e[_0x53f1('0x5d')]['ids'];});}})[_0x53f1('0x14')](respondWithResult(_0x11eb77,null))[_0x53f1('0x1d')](handleError(_0x11eb77,null));};exports[_0x53f1('0x13b')]=function(_0xff6b6a,_0x4b4bd1){return db[_0x53f1('0x49')][_0x53f1('0x33')]({'where':{'id':_0xff6b6a[_0x53f1('0x53')]['id']}})['then'](handleEntityNotFound(_0x4b4bd1,null))['then'](function(_0x8149f4){if(_0x8149f4){return _0x8149f4['removeFaxInteractions'](_0xff6b6a[_0x53f1('0x41')][_0x53f1('0x60')])['then'](function(){if(_[_0x53f1('0x133')](_0xff6b6a[_0x53f1('0x41')][_0x53f1('0x60')])){for(var _0x4e801e=0x0;_0x4e801e<_0xff6b6a[_0x53f1('0x41')]['ids'][_0x53f1('0x4c')];_0x4e801e+=0x1){socket[_0x53f1('0xb2')](_0x53f1('0x13c'),{'FaxInteractionId':Number(_0xff6b6a['query'][_0x53f1('0x60')][_0x4e801e]),'UserId':Number(_0xff6b6a[_0x53f1('0x53')]['id'])});}}else{socket['emit'](_0x53f1('0x13c'),{'FaxInteractionId':Number(_0xff6b6a[_0x53f1('0x41')][_0x53f1('0x60')]),'UserId':Number(_0xff6b6a[_0x53f1('0x53')]['id'])});}});}})['then'](respondWithStatusCode(_0x4b4bd1,null))[_0x53f1('0x1d')](handleError(_0x4b4bd1,null));};exports['addSmsInteractions']=function(_0x12bb5b,_0x6d7e82){return db['User'][_0x53f1('0x33')]({'where':{'id':_0x12bb5b[_0x53f1('0x53')]['id']}})[_0x53f1('0x14')](handleEntityNotFound(_0x6d7e82,null))[_0x53f1('0x14')](function(_0x5c139b){if(_0x5c139b){return _0x5c139b[_0x53f1('0x13d')](_0x12bb5b[_0x53f1('0x5d')][_0x53f1('0x60')],_[_0x53f1('0x113')](_0x12bb5b[_0x53f1('0x5d')],[_0x53f1('0x60'),'id'])||{})[_0x53f1('0x130')](function(){for(var _0x2dcb45=0x0;_0x2dcb45<_0x12bb5b[_0x53f1('0x5d')][_0x53f1('0x60')]['length'];_0x2dcb45+=0x1){socket[_0x53f1('0xb2')](_0x53f1('0x13e'),{'SmsInteractionId':Number(_0x12bb5b[_0x53f1('0x5d')]['ids'][_0x2dcb45]),'UserId':Number(_0x12bb5b[_0x53f1('0x53')]['id'])});}return _0x12bb5b['body'][_0x53f1('0x60')];});}})[_0x53f1('0x14')](respondWithResult(_0x6d7e82,null))['catch'](handleError(_0x6d7e82,null));};exports[_0x53f1('0x13f')]=function(_0x3f2e71,_0x1e2528){return db['User'][_0x53f1('0x33')]({'where':{'id':_0x3f2e71[_0x53f1('0x53')]['id']}})[_0x53f1('0x14')](handleEntityNotFound(_0x1e2528,null))[_0x53f1('0x14')](function(_0x388bda){if(_0x388bda){return _0x388bda[_0x53f1('0x13f')](_0x3f2e71[_0x53f1('0x41')][_0x53f1('0x60')])['then'](function(){if(_[_0x53f1('0x133')](_0x3f2e71[_0x53f1('0x41')][_0x53f1('0x60')])){for(var _0x2220da=0x0;_0x2220da<_0x3f2e71[_0x53f1('0x41')][_0x53f1('0x60')][_0x53f1('0x4c')];_0x2220da+=0x1){socket[_0x53f1('0xb2')](_0x53f1('0x140'),{'SmsInteractionId':Number(_0x3f2e71['query']['ids'][_0x2220da]),'UserId':Number(_0x3f2e71[_0x53f1('0x53')]['id'])});}}else{socket[_0x53f1('0xb2')](_0x53f1('0x140'),{'SmsInteractionId':Number(_0x3f2e71[_0x53f1('0x41')]['ids']),'UserId':Number(_0x3f2e71[_0x53f1('0x53')]['id'])});}});}})[_0x53f1('0x14')](respondWithStatusCode(_0x1e2528,null))[_0x53f1('0x1d')](handleError(_0x1e2528,null));};exports['addOpenchannelInteractions']=function(_0x32aced,_0x1cf391){return db[_0x53f1('0x49')][_0x53f1('0x33')]({'where':{'id':_0x32aced['params']['id']}})['then'](handleEntityNotFound(_0x1cf391,null))[_0x53f1('0x14')](function(_0x515e38){if(_0x515e38){return _0x515e38['addOpenchannelInteractions'](_0x32aced['body'][_0x53f1('0x60')],_[_0x53f1('0x113')](_0x32aced['body'],[_0x53f1('0x60'),'id'])||{})[_0x53f1('0x130')](function(){for(var _0x5ae637=0x0;_0x5ae637<_0x32aced[_0x53f1('0x5d')]['ids'][_0x53f1('0x4c')];_0x5ae637+=0x1){socket['emit'](_0x53f1('0x141'),{'OpenchannelInteractionId':Number(_0x32aced[_0x53f1('0x5d')][_0x53f1('0x60')][_0x5ae637]),'UserId':Number(_0x32aced['params']['id'])});}return _0x32aced[_0x53f1('0x5d')][_0x53f1('0x60')];});}})[_0x53f1('0x14')](respondWithResult(_0x1cf391,null))[_0x53f1('0x1d')](handleError(_0x1cf391,null));};exports[_0x53f1('0x142')]=function(_0xab8869,_0x36e433){return db[_0x53f1('0x49')]['find']({'where':{'id':_0xab8869[_0x53f1('0x53')]['id']}})[_0x53f1('0x14')](handleEntityNotFound(_0x36e433,null))[_0x53f1('0x14')](function(_0x221b02){if(_0x221b02){return _0x221b02[_0x53f1('0x142')](_0xab8869[_0x53f1('0x41')][_0x53f1('0x60')])[_0x53f1('0x14')](function(){if(_[_0x53f1('0x133')](_0xab8869[_0x53f1('0x41')][_0x53f1('0x60')])){for(var _0x37632b=0x0;_0x37632b<_0xab8869[_0x53f1('0x41')]['ids'][_0x53f1('0x4c')];_0x37632b+=0x1){socket[_0x53f1('0xb2')](_0x53f1('0x143'),{'OpenchannelInteractionId':Number(_0xab8869[_0x53f1('0x41')]['ids'][_0x37632b]),'UserId':Number(_0xab8869[_0x53f1('0x53')]['id'])});}}else{socket[_0x53f1('0xb2')]('user_has_openchannel_interactions:remove',{'OpenchannelInteractionId':Number(_0xab8869['query'][_0x53f1('0x60')]),'UserId':Number(_0xab8869[_0x53f1('0x53')]['id'])});}});}})['then'](respondWithStatusCode(_0x36e433,null))[_0x53f1('0x1d')](handleError(_0x36e433,null));};exports[_0x53f1('0x144')]=function(_0x2f6e33,_0x194b7a){return db[_0x53f1('0x49')][_0x53f1('0x33')]({'where':{'id':_0x2f6e33[_0x53f1('0x53')]['id']}})[_0x53f1('0x14')](handleEntityNotFound(_0x194b7a,null))[_0x53f1('0x14')](function(_0x2057da){if(_0x2057da){return _0x2057da[_0x53f1('0x144')](_0x2f6e33[_0x53f1('0x5d')]['ids'],_[_0x53f1('0x113')](_0x2f6e33[_0x53f1('0x5d')],[_0x53f1('0x60'),'id'])||{})['spread'](function(){for(var _0x56fdeb=0x0;_0x56fdeb<_0x2f6e33[_0x53f1('0x5d')][_0x53f1('0x60')][_0x53f1('0x4c')];_0x56fdeb+=0x1){socket['emit'](_0x53f1('0x145'),{'WhatsappInteractionId':Number(_0x2f6e33['body'][_0x53f1('0x60')][_0x56fdeb]),'UserId':Number(_0x2f6e33[_0x53f1('0x53')]['id'])});}return _0x2f6e33[_0x53f1('0x5d')]['ids'];});}})['then'](respondWithResult(_0x194b7a,null))[_0x53f1('0x1d')](handleError(_0x194b7a,null));};exports[_0x53f1('0x146')]=function(_0x3b008a,_0x995b39){return db[_0x53f1('0x49')][_0x53f1('0x33')]({'where':{'id':_0x3b008a[_0x53f1('0x53')]['id']}})[_0x53f1('0x14')](handleEntityNotFound(_0x995b39,null))[_0x53f1('0x14')](function(_0x1096b0){if(_0x1096b0){return _0x1096b0[_0x53f1('0x146')](_0x3b008a['query']['ids']);}})['then'](respondWithStatusCode(_0x995b39,null))[_0x53f1('0x1d')](handleError(_0x995b39,null));};exports['getVoicePrefixes']=function(_0x102002,_0x27c185){var _0x10f921={};var _0x2a95d2={};var _0x4fd2bb;var _0x4c35b7;return db[_0x53f1('0x49')][_0x53f1('0xca')]({'where':{'id':_0x102002['params']['id']}})['then'](handleEntityNotFound(_0x27c185,null))['then'](function(_0x4ac49c){if(_0x4ac49c){_0x4fd2bb=_0x4ac49c;_0x2a95d2[_0x53f1('0x54')]=_['keys'](db[_0x53f1('0x147')]['rawAttributes']);_0x2a95d2[_0x53f1('0x41')]=_[_0x53f1('0x56')](_0x102002[_0x53f1('0x41')]);_0x2a95d2['filters']=_['intersection'](_0x2a95d2['model'],_0x2a95d2['query']);_0x10f921['attributes']=_[_0x53f1('0x58')](_0x2a95d2[_0x53f1('0x54')],qs[_0x53f1('0xcc')](_0x102002['query'][_0x53f1('0xcc')]));_0x10f921[_0x53f1('0x47')]=_0x10f921[_0x53f1('0x47')][_0x53f1('0x4c')]?_0x10f921['attributes']:_0x2a95d2[_0x53f1('0x54')];_0x10f921['order']=qs[_0x53f1('0xce')](_0x102002[_0x53f1('0x41')]['sort']);_0x10f921[_0x53f1('0x40')]=qs[_0x53f1('0x57')](_[_0x53f1('0xcf')](_0x102002[_0x53f1('0x41')],_0x2a95d2[_0x53f1('0x57')]));if(_0x102002[_0x53f1('0x41')][_0x53f1('0x2e')]){_0x10f921[_0x53f1('0x40')]=_['merge'](_0x10f921['where'],{'$or':_[_0x53f1('0x30')](_0x10f921[_0x53f1('0x47')],function(_0x1cd209){var _0x385c29={};_0x385c29[_0x1cd209]={'$like':'%'+_0x102002['query'][_0x53f1('0x2e')]+'%'};return _0x385c29;})});}_0x10f921=_['merge']({},_0x10f921,_0x102002['options']);return _0x4fd2bb[_0x53f1('0x148')](_0x10f921);}})[_0x53f1('0x14')](function(_0x12695b){if(_0x12695b){_0x4c35b7=_0x12695b[_0x53f1('0x4c')];if(!_0x102002[_0x53f1('0x41')][_0x53f1('0xd1')]('nolimit')){_0x10f921[_0x53f1('0x23')]=qs[_0x53f1('0x23')](_0x102002[_0x53f1('0x41')]['limit']);_0x10f921[_0x53f1('0x24')]=qs[_0x53f1('0x24')](_0x102002[_0x53f1('0x41')]['offset']);}return _0x4fd2bb[_0x53f1('0x148')](_0x10f921);}})[_0x53f1('0x14')](function(_0x440599){if(_0x440599){return _0x440599?{'count':_0x4c35b7,'rows':_0x440599}:null;}})[_0x53f1('0x14')](respondWithResult(_0x27c185,null))['catch'](handleError(_0x27c185,null));};exports['getFaxAccounts']=function(_0x59a458,_0x442822){var _0x7959ee={};var _0x20862e={};var _0xfd9f06;var _0x20243b;return db[_0x53f1('0x49')][_0x53f1('0xca')]({'where':{'id':_0x59a458[_0x53f1('0x53')]['id']}})[_0x53f1('0x14')](handleEntityNotFound(_0x442822,null))[_0x53f1('0x14')](function(_0x1c706a){if(_0x1c706a){_0xfd9f06=_0x1c706a;_0x20862e[_0x53f1('0x54')]=_[_0x53f1('0x56')](db[_0x53f1('0x149')][_0x53f1('0x39')]);_0x20862e[_0x53f1('0x41')]=_[_0x53f1('0x56')](_0x59a458[_0x53f1('0x41')]);_0x20862e['filters']=_[_0x53f1('0x58')](_0x20862e['model'],_0x20862e[_0x53f1('0x41')]);_0x7959ee[_0x53f1('0x47')]=_[_0x53f1('0x58')](_0x20862e[_0x53f1('0x54')],qs[_0x53f1('0xcc')](_0x59a458[_0x53f1('0x41')][_0x53f1('0xcc')]));_0x7959ee[_0x53f1('0x47')]=_0x7959ee[_0x53f1('0x47')][_0x53f1('0x4c')]?_0x7959ee['attributes']:_0x20862e[_0x53f1('0x54')];_0x7959ee[_0x53f1('0xcd')]=qs[_0x53f1('0xce')](_0x59a458[_0x53f1('0x41')][_0x53f1('0xce')]);_0x7959ee[_0x53f1('0x40')]=qs[_0x53f1('0x57')](_[_0x53f1('0xcf')](_0x59a458[_0x53f1('0x41')],_0x20862e[_0x53f1('0x57')]));if(_0x59a458['query']['filter']){_0x7959ee['where']=_[_0x53f1('0x59')](_0x7959ee['where'],{'$or':_[_0x53f1('0x30')](_0x7959ee[_0x53f1('0x47')],function(_0x5d6f6b){var _0x3df317={};_0x3df317[_0x5d6f6b]={'$like':'%'+_0x59a458[_0x53f1('0x41')][_0x53f1('0x2e')]+'%'};return _0x3df317;})});}_0x7959ee=_[_0x53f1('0x59')]({},_0x7959ee,_0x59a458['options']);return _0xfd9f06[_0x53f1('0x14a')](_0x7959ee);}})[_0x53f1('0x14')](function(_0x266596){if(_0x266596){_0x20243b=_0x266596[_0x53f1('0x4c')];if(!_0x59a458['query'][_0x53f1('0xd1')](_0x53f1('0xd6'))){_0x7959ee[_0x53f1('0x23')]=qs[_0x53f1('0x23')](_0x59a458[_0x53f1('0x41')][_0x53f1('0x23')]);_0x7959ee['offset']=qs['offset'](_0x59a458[_0x53f1('0x41')][_0x53f1('0x24')]);}return _0xfd9f06['getFaxAccounts'](_0x7959ee);}})[_0x53f1('0x14')](function(_0xfe4649){if(_0xfe4649){return _0xfe4649?{'count':_0x20243b,'rows':_0xfe4649}:null;}})[_0x53f1('0x14')](respondWithResult(_0x442822,null))[_0x53f1('0x1d')](handleError(_0x442822,null));};exports[_0x53f1('0x14b')]=function(_0x578611,_0x29f887){return db['User'][_0x53f1('0x33')]({'where':{'id':_0x578611[_0x53f1('0x53')]['id']}})['then'](handleEntityNotFound(_0x29f887,null))['then'](function(_0x31862b){if(_0x31862b){return _0x31862b[_0x53f1('0x14b')](_0x578611[_0x53f1('0x5d')][_0x53f1('0x60')],_[_0x53f1('0x113')](_0x578611['body'],[_0x53f1('0x60'),'id'])||{});}})[_0x53f1('0x14')](respondWithResult(_0x29f887,null))[_0x53f1('0x1d')](handleError(_0x29f887,null));};exports[_0x53f1('0x14c')]=function(_0x57183e,_0x49865c){return db['User'][_0x53f1('0x33')]({'where':{'id':_0x57183e[_0x53f1('0x53')]['id']}})['then'](handleEntityNotFound(_0x49865c,null))['then'](function(_0x4847a6){if(_0x4847a6){return _0x4847a6['removeFaxAccounts'](_0x57183e[_0x53f1('0x41')][_0x53f1('0x60')]);}})[_0x53f1('0x14')](respondWithStatusCode(_0x49865c,null))[_0x53f1('0x1d')](handleError(_0x49865c,null));};exports['getMailAccounts']=function(_0x111e73,_0x2f9b96){var _0x20bb4b={};var _0x4e9a56={};var _0x105307;var _0x43b540;return db[_0x53f1('0x49')]['findOne']({'where':{'id':_0x111e73[_0x53f1('0x53')]['id']}})[_0x53f1('0x14')](handleEntityNotFound(_0x2f9b96,null))[_0x53f1('0x14')](function(_0x176d83){if(_0x176d83){_0x105307=_0x176d83;_0x4e9a56[_0x53f1('0x54')]=_['keys'](db[_0x53f1('0x14d')]['rawAttributes']);_0x4e9a56[_0x53f1('0x41')]=_[_0x53f1('0x56')](_0x111e73[_0x53f1('0x41')]);_0x4e9a56['filters']=_[_0x53f1('0x58')](_0x4e9a56[_0x53f1('0x54')],_0x4e9a56['query']);_0x20bb4b[_0x53f1('0x47')]=_['intersection'](_0x4e9a56[_0x53f1('0x54')],qs[_0x53f1('0xcc')](_0x111e73['query'][_0x53f1('0xcc')]));_0x20bb4b[_0x53f1('0x47')]=_0x20bb4b[_0x53f1('0x47')][_0x53f1('0x4c')]?_0x20bb4b[_0x53f1('0x47')]:_0x4e9a56[_0x53f1('0x54')];_0x20bb4b['order']=qs[_0x53f1('0xce')](_0x111e73[_0x53f1('0x41')][_0x53f1('0xce')]);_0x20bb4b['where']=qs[_0x53f1('0x57')](_[_0x53f1('0xcf')](_0x111e73[_0x53f1('0x41')],_0x4e9a56[_0x53f1('0x57')]));if(_0x111e73[_0x53f1('0x41')][_0x53f1('0x2e')]){_0x20bb4b[_0x53f1('0x40')]=_[_0x53f1('0x59')](_0x20bb4b[_0x53f1('0x40')],{'$or':_[_0x53f1('0x30')](_0x20bb4b['attributes'],function(_0x2509b6){var _0x30716a={};_0x30716a[_0x2509b6]={'$like':'%'+_0x111e73[_0x53f1('0x41')][_0x53f1('0x2e')]+'%'};return _0x30716a;})});}_0x20bb4b=_['merge']({},_0x20bb4b,_0x111e73[_0x53f1('0xd0')]);return _0x105307[_0x53f1('0x14e')](_0x20bb4b);}})[_0x53f1('0x14')](function(_0x4eb3b8){if(_0x4eb3b8){_0x43b540=_0x4eb3b8[_0x53f1('0x4c')];if(!_0x111e73[_0x53f1('0x41')][_0x53f1('0xd1')](_0x53f1('0xd6'))){_0x20bb4b[_0x53f1('0x23')]=qs[_0x53f1('0x23')](_0x111e73['query'][_0x53f1('0x23')]);_0x20bb4b[_0x53f1('0x24')]=qs[_0x53f1('0x24')](_0x111e73[_0x53f1('0x41')]['offset']);}return _0x105307[_0x53f1('0x14e')](_0x20bb4b);}})[_0x53f1('0x14')](function(_0x1b5dcd){if(_0x1b5dcd){return _0x1b5dcd?{'count':_0x43b540,'rows':_0x1b5dcd}:null;}})['then'](respondWithResult(_0x2f9b96,null))[_0x53f1('0x1d')](handleError(_0x2f9b96,null));};exports[_0x53f1('0x14f')]=function(_0x1e456f,_0x3f89fe){return db[_0x53f1('0x49')][_0x53f1('0x33')]({'where':{'id':_0x1e456f[_0x53f1('0x53')]['id']}})[_0x53f1('0x14')](handleEntityNotFound(_0x3f89fe,null))[_0x53f1('0x14')](function(_0x11a7a3){if(_0x11a7a3){return _0x11a7a3[_0x53f1('0x14f')](_0x1e456f[_0x53f1('0x5d')][_0x53f1('0x60')],_[_0x53f1('0x113')](_0x1e456f['body'],[_0x53f1('0x60'),'id'])||{});}})['then'](respondWithResult(_0x3f89fe,null))['catch'](handleError(_0x3f89fe,null));};exports[_0x53f1('0x150')]=function(_0x3afc2a,_0x49bb53){return db[_0x53f1('0x49')]['find']({'where':{'id':_0x3afc2a[_0x53f1('0x53')]['id']}})[_0x53f1('0x14')](handleEntityNotFound(_0x49bb53,null))[_0x53f1('0x14')](function(_0xcb80fa){if(_0xcb80fa){return _0xcb80fa[_0x53f1('0x150')](_0x3afc2a['query'][_0x53f1('0x60')]);}})[_0x53f1('0x14')](respondWithStatusCode(_0x49bb53,null))[_0x53f1('0x1d')](handleError(_0x49bb53,null));};exports[_0x53f1('0x151')]=function(_0x2e7a02,_0x7e35c8){var _0x42a2ce={};var _0x5f4043={};var _0x564ea8;var _0x52f4bc;return db[_0x53f1('0x49')]['findOne']({'where':{'id':_0x2e7a02[_0x53f1('0x53')]['id']}})[_0x53f1('0x14')](handleEntityNotFound(_0x7e35c8,null))[_0x53f1('0x14')](function(_0x2d01ba){if(_0x2d01ba){_0x564ea8=_0x2d01ba;_0x5f4043[_0x53f1('0x54')]=_['keys'](db[_0x53f1('0x152')][_0x53f1('0x39')]);_0x5f4043[_0x53f1('0x41')]=_[_0x53f1('0x56')](_0x2e7a02[_0x53f1('0x41')]);_0x5f4043['filters']=_[_0x53f1('0x58')](_0x5f4043[_0x53f1('0x54')],_0x5f4043[_0x53f1('0x41')]);_0x42a2ce[_0x53f1('0x47')]=_[_0x53f1('0x58')](_0x5f4043[_0x53f1('0x54')],qs[_0x53f1('0xcc')](_0x2e7a02[_0x53f1('0x41')]['fields']));_0x42a2ce[_0x53f1('0x47')]=_0x42a2ce[_0x53f1('0x47')][_0x53f1('0x4c')]?_0x42a2ce['attributes']:_0x5f4043[_0x53f1('0x54')];_0x42a2ce[_0x53f1('0xcd')]=qs[_0x53f1('0xce')](_0x2e7a02[_0x53f1('0x41')][_0x53f1('0xce')]);_0x42a2ce[_0x53f1('0x40')]=qs[_0x53f1('0x57')](_[_0x53f1('0xcf')](_0x2e7a02['query'],_0x5f4043['filters']));if(_0x2e7a02[_0x53f1('0x41')][_0x53f1('0x2e')]){_0x42a2ce[_0x53f1('0x40')]=_[_0x53f1('0x59')](_0x42a2ce[_0x53f1('0x40')],{'$or':_[_0x53f1('0x30')](_0x42a2ce[_0x53f1('0x47')],function(_0x43a342){var _0x45d51f={};_0x45d51f[_0x43a342]={'$like':'%'+_0x2e7a02['query'][_0x53f1('0x2e')]+'%'};return _0x45d51f;})});}_0x42a2ce=_[_0x53f1('0x59')]({},_0x42a2ce,_0x2e7a02['options']);return _0x564ea8[_0x53f1('0x151')](_0x42a2ce);}})[_0x53f1('0x14')](function(_0x578897){if(_0x578897){_0x52f4bc=_0x578897['length'];if(!_0x2e7a02['query'][_0x53f1('0xd1')](_0x53f1('0xd6'))){_0x42a2ce[_0x53f1('0x23')]=qs['limit'](_0x2e7a02[_0x53f1('0x41')][_0x53f1('0x23')]);_0x42a2ce[_0x53f1('0x24')]=qs['offset'](_0x2e7a02[_0x53f1('0x41')][_0x53f1('0x24')]);}return _0x564ea8[_0x53f1('0x151')](_0x42a2ce);}})[_0x53f1('0x14')](function(_0x573025){if(_0x573025){return _0x573025?{'count':_0x52f4bc,'rows':_0x573025}:null;}})[_0x53f1('0x14')](respondWithResult(_0x7e35c8,null))[_0x53f1('0x1d')](handleError(_0x7e35c8,null));};exports[_0x53f1('0x153')]=function(_0x65ba8a,_0xbe8bb7){return db['User']['find']({'where':{'id':_0x65ba8a[_0x53f1('0x53')]['id']}})[_0x53f1('0x14')](handleEntityNotFound(_0xbe8bb7,null))[_0x53f1('0x14')](function(_0x243fbf){if(_0x243fbf){return _0x243fbf[_0x53f1('0x153')](_0x65ba8a[_0x53f1('0x5d')]['ids'],_[_0x53f1('0x113')](_0x65ba8a[_0x53f1('0x5d')],[_0x53f1('0x60'),'id'])||{});}})[_0x53f1('0x14')](respondWithResult(_0xbe8bb7,null))['catch'](handleError(_0xbe8bb7,null));};exports[_0x53f1('0x154')]=function(_0x25e956,_0x424bfd){return db[_0x53f1('0x49')][_0x53f1('0x33')]({'where':{'id':_0x25e956[_0x53f1('0x53')]['id']}})[_0x53f1('0x14')](handleEntityNotFound(_0x424bfd,null))[_0x53f1('0x14')](function(_0x3a4f8f){if(_0x3a4f8f){return _0x3a4f8f['removeOpenchannelAccounts'](_0x25e956[_0x53f1('0x41')][_0x53f1('0x60')]);}})[_0x53f1('0x14')](respondWithStatusCode(_0x424bfd,null))[_0x53f1('0x1d')](handleError(_0x424bfd,null));};exports['getSmsAccounts']=function(_0x5eb51c,_0x1d395c){var _0x492e3a={};var _0x14e067={};var _0x247079;var _0x4679fc;return db['User'][_0x53f1('0xca')]({'where':{'id':_0x5eb51c[_0x53f1('0x53')]['id']}})['then'](handleEntityNotFound(_0x1d395c,null))['then'](function(_0x1cdf44){if(_0x1cdf44){_0x247079=_0x1cdf44;_0x14e067[_0x53f1('0x54')]=_[_0x53f1('0x56')](db[_0x53f1('0x155')][_0x53f1('0x39')]);_0x14e067[_0x53f1('0x41')]=_['keys'](_0x5eb51c[_0x53f1('0x41')]);_0x14e067[_0x53f1('0x57')]=_['intersection'](_0x14e067['model'],_0x14e067[_0x53f1('0x41')]);_0x492e3a['attributes']=_[_0x53f1('0x58')](_0x14e067[_0x53f1('0x54')],qs['fields'](_0x5eb51c[_0x53f1('0x41')][_0x53f1('0xcc')]));_0x492e3a[_0x53f1('0x47')]=_0x492e3a[_0x53f1('0x47')]['length']?_0x492e3a[_0x53f1('0x47')]:_0x14e067['model'];_0x492e3a[_0x53f1('0xcd')]=qs['sort'](_0x5eb51c[_0x53f1('0x41')]['sort']);_0x492e3a['where']=qs[_0x53f1('0x57')](_['pick'](_0x5eb51c[_0x53f1('0x41')],_0x14e067[_0x53f1('0x57')]));if(_0x5eb51c[_0x53f1('0x41')][_0x53f1('0x2e')]){_0x492e3a[_0x53f1('0x40')]=_[_0x53f1('0x59')](_0x492e3a[_0x53f1('0x40')],{'$or':_[_0x53f1('0x30')](_0x492e3a[_0x53f1('0x47')],function(_0x30ccf6){var _0x6e65e6={};_0x6e65e6[_0x30ccf6]={'$like':'%'+_0x5eb51c[_0x53f1('0x41')][_0x53f1('0x2e')]+'%'};return _0x6e65e6;})});}_0x492e3a=_[_0x53f1('0x59')]({},_0x492e3a,_0x5eb51c['options']);return _0x247079[_0x53f1('0x156')](_0x492e3a);}})['then'](function(_0x2ab416){if(_0x2ab416){_0x4679fc=_0x2ab416[_0x53f1('0x4c')];if(!_0x5eb51c[_0x53f1('0x41')]['hasOwnProperty'](_0x53f1('0xd6'))){_0x492e3a[_0x53f1('0x23')]=qs[_0x53f1('0x23')](_0x5eb51c[_0x53f1('0x41')][_0x53f1('0x23')]);_0x492e3a['offset']=qs[_0x53f1('0x24')](_0x5eb51c['query'][_0x53f1('0x24')]);}return _0x247079[_0x53f1('0x156')](_0x492e3a);}})[_0x53f1('0x14')](function(_0x419f04){if(_0x419f04){return _0x419f04?{'count':_0x4679fc,'rows':_0x419f04}:null;}})[_0x53f1('0x14')](respondWithResult(_0x1d395c,null))[_0x53f1('0x1d')](handleError(_0x1d395c,null));};exports[_0x53f1('0x157')]=function(_0x5881a6,_0x3a890d){return db[_0x53f1('0x49')]['find']({'where':{'id':_0x5881a6[_0x53f1('0x53')]['id']}})[_0x53f1('0x14')](handleEntityNotFound(_0x3a890d,null))[_0x53f1('0x14')](function(_0x575544){if(_0x575544){return _0x575544[_0x53f1('0x157')](_0x5881a6[_0x53f1('0x5d')]['ids'],_[_0x53f1('0x113')](_0x5881a6[_0x53f1('0x5d')],[_0x53f1('0x60'),'id'])||{});}})[_0x53f1('0x14')](respondWithResult(_0x3a890d,null))[_0x53f1('0x1d')](handleError(_0x3a890d,null));};exports[_0x53f1('0x158')]=function(_0x223192,_0x18c387){return db[_0x53f1('0x49')][_0x53f1('0x33')]({'where':{'id':_0x223192[_0x53f1('0x53')]['id']}})[_0x53f1('0x14')](handleEntityNotFound(_0x18c387,null))[_0x53f1('0x14')](function(_0xe926d8){if(_0xe926d8){return _0xe926d8[_0x53f1('0x158')](_0x223192['query']['ids']);}})[_0x53f1('0x14')](respondWithStatusCode(_0x18c387,null))[_0x53f1('0x1d')](handleError(_0x18c387,null));};exports[_0x53f1('0x159')]=function(_0x27d4f7,_0x2520f0){var _0x58b3fd={};var _0x3a78eb={};var _0x17c292;var _0x3465a6;return db[_0x53f1('0x49')][_0x53f1('0xca')]({'where':{'id':_0x27d4f7[_0x53f1('0x53')]['id']}})[_0x53f1('0x14')](handleEntityNotFound(_0x2520f0,null))[_0x53f1('0x14')](function(_0x3cbbdc){if(_0x3cbbdc){_0x17c292=_0x3cbbdc;_0x3a78eb[_0x53f1('0x54')]=_['keys'](db[_0x53f1('0x15a')][_0x53f1('0x39')]);_0x3a78eb[_0x53f1('0x41')]=_[_0x53f1('0x56')](_0x27d4f7[_0x53f1('0x41')]);_0x3a78eb[_0x53f1('0x57')]=_['intersection'](_0x3a78eb[_0x53f1('0x54')],_0x3a78eb[_0x53f1('0x41')]);_0x58b3fd[_0x53f1('0x47')]=_[_0x53f1('0x58')](_0x3a78eb[_0x53f1('0x54')],qs['fields'](_0x27d4f7['query']['fields']));_0x58b3fd[_0x53f1('0x47')]=_0x58b3fd['attributes'][_0x53f1('0x4c')]?_0x58b3fd[_0x53f1('0x47')]:_0x3a78eb[_0x53f1('0x54')];_0x58b3fd[_0x53f1('0xcd')]=qs[_0x53f1('0xce')](_0x27d4f7[_0x53f1('0x41')]['sort']);_0x58b3fd['where']=qs[_0x53f1('0x57')](_[_0x53f1('0xcf')](_0x27d4f7[_0x53f1('0x41')],_0x3a78eb['filters']));if(_0x27d4f7[_0x53f1('0x41')]['filter']){_0x58b3fd[_0x53f1('0x40')]=_[_0x53f1('0x59')](_0x58b3fd[_0x53f1('0x40')],{'$or':_[_0x53f1('0x30')](_0x58b3fd['attributes'],function(_0x3098e6){var _0x4f796c={};_0x4f796c[_0x3098e6]={'$like':'%'+_0x27d4f7[_0x53f1('0x41')][_0x53f1('0x2e')]+'%'};return _0x4f796c;})});}_0x58b3fd=_[_0x53f1('0x59')]({},_0x58b3fd,_0x27d4f7['options']);return _0x17c292['getChatWebsites'](_0x58b3fd);}})[_0x53f1('0x14')](function(_0x305237){if(_0x305237){_0x3465a6=_0x305237[_0x53f1('0x4c')];if(!_0x27d4f7[_0x53f1('0x41')]['hasOwnProperty'](_0x53f1('0xd6'))){_0x58b3fd['limit']=qs[_0x53f1('0x23')](_0x27d4f7[_0x53f1('0x41')]['limit']);_0x58b3fd['offset']=qs[_0x53f1('0x24')](_0x27d4f7[_0x53f1('0x41')]['offset']);}return _0x17c292[_0x53f1('0x159')](_0x58b3fd);}})[_0x53f1('0x14')](function(_0x4b9786){if(_0x4b9786){return _0x4b9786?{'count':_0x3465a6,'rows':_0x4b9786}:null;}})[_0x53f1('0x14')](respondWithResult(_0x2520f0,null))[_0x53f1('0x1d')](handleError(_0x2520f0,null));};exports['addChatWebsites']=function(_0x83eca7,_0x300519){return db[_0x53f1('0x49')][_0x53f1('0x33')]({'where':{'id':_0x83eca7[_0x53f1('0x53')]['id']}})[_0x53f1('0x14')](handleEntityNotFound(_0x300519,null))[_0x53f1('0x14')](function(_0x2e2b9c){if(_0x2e2b9c){return _0x2e2b9c[_0x53f1('0x15b')](_0x83eca7[_0x53f1('0x5d')][_0x53f1('0x60')],_[_0x53f1('0x113')](_0x83eca7[_0x53f1('0x5d')],[_0x53f1('0x60'),'id'])||{});}})['then'](respondWithResult(_0x300519,null))[_0x53f1('0x1d')](handleError(_0x300519,null));};exports['removeChatWebsites']=function(_0x367b44,_0x8a3d6d){return db[_0x53f1('0x49')]['find']({'where':{'id':_0x367b44[_0x53f1('0x53')]['id']}})[_0x53f1('0x14')](handleEntityNotFound(_0x8a3d6d,null))[_0x53f1('0x14')](function(_0x158517){if(_0x158517){return _0x158517[_0x53f1('0x15c')](_0x367b44[_0x53f1('0x41')][_0x53f1('0x60')]);}})['then'](respondWithStatusCode(_0x8a3d6d,null))[_0x53f1('0x1d')](handleError(_0x8a3d6d,null));};exports[_0x53f1('0x15d')]=function(_0x11c86c,_0x135f06){var _0x5ccf17={};var _0x6a7efa={};var _0x14ee87;var _0x11bd8e;return db[_0x53f1('0x49')][_0x53f1('0xca')]({'where':{'id':_0x11c86c[_0x53f1('0x53')]['id']}})['then'](handleEntityNotFound(_0x135f06,null))[_0x53f1('0x14')](function(_0x523e30){if(_0x523e30){_0x14ee87=_0x523e30;_0x6a7efa['model']=_[_0x53f1('0x56')](db[_0x53f1('0x15e')][_0x53f1('0x39')]);_0x6a7efa[_0x53f1('0x41')]=_['keys'](_0x11c86c[_0x53f1('0x41')]);_0x6a7efa['filters']=_[_0x53f1('0x58')](_0x6a7efa[_0x53f1('0x54')],_0x6a7efa['query']);_0x5ccf17[_0x53f1('0x47')]=_['intersection'](_0x6a7efa[_0x53f1('0x54')],qs['fields'](_0x11c86c[_0x53f1('0x41')][_0x53f1('0xcc')]));_0x5ccf17[_0x53f1('0x47')]=_0x5ccf17['attributes'][_0x53f1('0x4c')]?_0x5ccf17['attributes']:_0x6a7efa['model'];_0x5ccf17[_0x53f1('0xcd')]=qs[_0x53f1('0xce')](_0x11c86c[_0x53f1('0x41')][_0x53f1('0xce')]);_0x5ccf17[_0x53f1('0x40')]=qs[_0x53f1('0x57')](_[_0x53f1('0xcf')](_0x11c86c['query'],_0x6a7efa['filters']));if(_0x11c86c[_0x53f1('0x41')][_0x53f1('0x2e')]){_0x5ccf17[_0x53f1('0x40')]=_[_0x53f1('0x59')](_0x5ccf17['where'],{'$or':_[_0x53f1('0x30')](_0x5ccf17[_0x53f1('0x47')],function(_0x22edd6){var _0x3bb7f3={};_0x3bb7f3[_0x22edd6]={'$like':'%'+_0x11c86c['query'][_0x53f1('0x2e')]+'%'};return _0x3bb7f3;})});}_0x5ccf17=_[_0x53f1('0x59')]({},_0x5ccf17,_0x11c86c[_0x53f1('0xd0')]);return _0x14ee87[_0x53f1('0x15d')](_0x5ccf17);}})[_0x53f1('0x14')](function(_0x35750d){if(_0x35750d){_0x11bd8e=_0x35750d[_0x53f1('0x4c')];if(!_0x11c86c['query'][_0x53f1('0xd1')](_0x53f1('0xd6'))){_0x5ccf17[_0x53f1('0x23')]=qs[_0x53f1('0x23')](_0x11c86c[_0x53f1('0x41')][_0x53f1('0x23')]);_0x5ccf17[_0x53f1('0x24')]=qs[_0x53f1('0x24')](_0x11c86c[_0x53f1('0x41')]['offset']);}return _0x14ee87['getWhatsappAccounts'](_0x5ccf17);}})['then'](function(_0x6dd948){if(_0x6dd948){return _0x6dd948?{'count':_0x11bd8e,'rows':_0x6dd948}:null;}})[_0x53f1('0x14')](respondWithResult(_0x135f06,null))[_0x53f1('0x1d')](handleError(_0x135f06,null));};exports[_0x53f1('0x15f')]=function(_0x1d8d02,_0x5b4b89){return db[_0x53f1('0x49')][_0x53f1('0x33')]({'where':{'id':_0x1d8d02[_0x53f1('0x53')]['id']}})[_0x53f1('0x14')](handleEntityNotFound(_0x5b4b89,null))[_0x53f1('0x14')](function(_0x3b9cf9){if(_0x3b9cf9){return _0x3b9cf9[_0x53f1('0x15f')](_0x1d8d02['body'][_0x53f1('0x60')],_[_0x53f1('0x113')](_0x1d8d02[_0x53f1('0x5d')],[_0x53f1('0x60'),'id'])||{});}})[_0x53f1('0x14')](respondWithResult(_0x5b4b89,null))['catch'](handleError(_0x5b4b89,null));};exports[_0x53f1('0x160')]=function(_0xe0855b,_0x381e2f){return db['User'][_0x53f1('0x33')]({'where':{'id':_0xe0855b[_0x53f1('0x53')]['id']}})[_0x53f1('0x14')](handleEntityNotFound(_0x381e2f,null))['then'](function(_0x5223c5){if(_0x5223c5){return _0x5223c5[_0x53f1('0x160')](_0xe0855b[_0x53f1('0x41')][_0x53f1('0x60')]);}})[_0x53f1('0x14')](respondWithStatusCode(_0x381e2f,null))[_0x53f1('0x1d')](handleError(_0x381e2f,null));};exports[_0x53f1('0x161')]=function(_0x3fedc6,_0xde1c3b){var _0x2f2ca5={};var _0x3b831b={};var _0x23cdfb;var _0x56c298;return db[_0x53f1('0x49')]['findOne']({'where':{'id':_0x3fedc6[_0x53f1('0x53')]['id']}})[_0x53f1('0x14')](handleEntityNotFound(_0xde1c3b,null))[_0x53f1('0x14')](function(_0x2ef4b0){if(_0x2ef4b0){_0x23cdfb=_0x2ef4b0;_0x3b831b[_0x53f1('0x54')]=_[_0x53f1('0x56')](db[_0x53f1('0x162')]['rawAttributes']);_0x3b831b[_0x53f1('0x41')]=_[_0x53f1('0x56')](_0x3fedc6[_0x53f1('0x41')]);_0x3b831b['filters']=_[_0x53f1('0x58')](_0x3b831b[_0x53f1('0x54')],_0x3b831b['query']);_0x2f2ca5[_0x53f1('0x47')]=_[_0x53f1('0x58')](_0x3b831b[_0x53f1('0x54')],qs[_0x53f1('0xcc')](_0x3fedc6[_0x53f1('0x41')][_0x53f1('0xcc')]));_0x2f2ca5[_0x53f1('0x47')]=_0x2f2ca5['attributes'][_0x53f1('0x4c')]?_0x2f2ca5[_0x53f1('0x47')]:_0x3b831b['model'];_0x2f2ca5[_0x53f1('0xcd')]=qs[_0x53f1('0xce')](_0x3fedc6[_0x53f1('0x41')]['sort']);_0x2f2ca5['where']=qs[_0x53f1('0x57')](_[_0x53f1('0xcf')](_0x3fedc6['query'],_0x3b831b[_0x53f1('0x57')]));if(_0x3fedc6[_0x53f1('0x41')][_0x53f1('0x2e')]){_0x2f2ca5[_0x53f1('0x40')]=_[_0x53f1('0x59')](_0x2f2ca5['where'],{'$or':_['map'](_0x2f2ca5['attributes'],function(_0x5bc2c5){var _0xb88556={};_0xb88556[_0x5bc2c5]={'$like':'%'+_0x3fedc6[_0x53f1('0x41')]['filter']+'%'};return _0xb88556;})});}_0x2f2ca5=_[_0x53f1('0x59')]({},_0x2f2ca5,_0x3fedc6[_0x53f1('0xd0')]);return _0x23cdfb['getSquareProjects'](_0x2f2ca5);}})[_0x53f1('0x14')](function(_0x49b3e7){if(_0x49b3e7){_0x56c298=_0x49b3e7[_0x53f1('0x4c')];if(!_0x3fedc6[_0x53f1('0x41')][_0x53f1('0xd1')](_0x53f1('0xd6'))){_0x2f2ca5[_0x53f1('0x23')]=qs[_0x53f1('0x23')](_0x3fedc6[_0x53f1('0x41')][_0x53f1('0x23')]);_0x2f2ca5[_0x53f1('0x24')]=qs[_0x53f1('0x24')](_0x3fedc6[_0x53f1('0x41')][_0x53f1('0x24')]);}return _0x23cdfb[_0x53f1('0x161')](_0x2f2ca5);}})[_0x53f1('0x14')](function(_0x2b47b3){if(_0x2b47b3){return _0x2b47b3?{'count':_0x56c298,'rows':_0x2b47b3}:null;}})[_0x53f1('0x14')](respondWithResult(_0xde1c3b,null))[_0x53f1('0x1d')](handleError(_0xde1c3b,null));};exports[_0x53f1('0x163')]=function(_0x5b09d5,_0x23f79e){return db[_0x53f1('0x49')]['find']({'where':{'id':_0x5b09d5['params']['id']}})[_0x53f1('0x14')](handleEntityNotFound(_0x23f79e,null))[_0x53f1('0x14')](function(_0x55152f){if(_0x55152f){return _0x55152f[_0x53f1('0x163')](_0x5b09d5['body'][_0x53f1('0x60')],_[_0x53f1('0x113')](_0x5b09d5[_0x53f1('0x5d')],[_0x53f1('0x60'),'id'])||{});}})[_0x53f1('0x14')](respondWithResult(_0x23f79e,null))['catch'](handleError(_0x23f79e,null));};exports[_0x53f1('0x164')]=function(_0x456edb,_0x570407){return db[_0x53f1('0x49')][_0x53f1('0x33')]({'where':{'id':_0x456edb['params']['id']}})[_0x53f1('0x14')](handleEntityNotFound(_0x570407,null))['then'](function(_0x28d596){if(_0x28d596){return _0x28d596[_0x53f1('0x164')](_0x456edb[_0x53f1('0x41')][_0x53f1('0x60')]);}})[_0x53f1('0x14')](respondWithStatusCode(_0x570407,null))['catch'](handleError(_0x570407,null));};exports[_0x53f1('0x165')]=function(_0x264344,_0x3a05a5){var _0x9e4dd3={},_0x3a7eea={},_0x1f5a37={'count':0x0,'rows':[]};var _0x419084=db[_0x53f1('0x166')][_0x53f1('0x39')];_0x3a7eea['model']=_[_0x53f1('0x56')](_0x419084);_0x3a7eea[_0x53f1('0x41')]=_['keys'](_0x264344[_0x53f1('0x41')]);_0x3a7eea[_0x53f1('0x57')]=_[_0x53f1('0x58')](_0x3a7eea[_0x53f1('0x54')],_0x3a7eea['query']);_0x3a7eea[_0x53f1('0x57')]=_[_0x53f1('0x167')](_0x3a7eea[_0x53f1('0x57')],[_0x53f1('0x168'),'$or',_0x53f1('0x169'),_0x53f1('0x16a'),_0x53f1('0x16b'),_0x53f1('0x16c'),_0x53f1('0x16d'),'$eq',_0x53f1('0x16e'),_0x53f1('0x16f'),_0x53f1('0x170'),_0x53f1('0x171'),_0x53f1('0x172'),_0x53f1('0x173'),'$notLike',_0x53f1('0x174'),'$notILike',_0x53f1('0x173'),'$overlap','$contains',_0x53f1('0x175'),_0x53f1('0x176')]);_0x9e4dd3[_0x53f1('0x47')]=_['intersection'](_0x3a7eea[_0x53f1('0x54')],qs[_0x53f1('0xcc')](_0x264344[_0x53f1('0x41')][_0x53f1('0xcc')]));_0x9e4dd3[_0x53f1('0x47')]=_0x9e4dd3[_0x53f1('0x47')][_0x53f1('0x4c')]?_0x9e4dd3[_0x53f1('0x47')]:_0x3a7eea[_0x53f1('0x54')];if(!_0x264344[_0x53f1('0x41')][_0x53f1('0xd1')](_0x53f1('0xd6'))){_0x9e4dd3[_0x53f1('0x23')]=qs[_0x53f1('0x23')](_0x264344[_0x53f1('0x41')][_0x53f1('0x23')]);_0x9e4dd3[_0x53f1('0x24')]=qs[_0x53f1('0x24')](_0x264344['query'][_0x53f1('0x24')]);}_0x9e4dd3['order']=qs[_0x53f1('0xce')](_0x264344[_0x53f1('0x41')]['sort']);_0x9e4dd3[_0x53f1('0x40')]=qs[_0x53f1('0x57')](_['pick'](_0x264344[_0x53f1('0x41')],_0x3a7eea[_0x53f1('0x57')]));if(_0x264344[_0x53f1('0x41')][_0x53f1('0x2e')]){_0x9e4dd3[_0x53f1('0x40')]=_['merge'](_0x9e4dd3[_0x53f1('0x40')],{'$or':_['map'](_0x9e4dd3[_0x53f1('0x47')],function(_0x544690){var _0x1efc30={};_0x1efc30[_0x544690]={'$like':'%'+_0x264344[_0x53f1('0x41')][_0x53f1('0x2e')]+'%'};return _0x1efc30;})});}_0x9e4dd3[_0x53f1('0x40')]={'$and':[_0x9e4dd3['where'],{'$or':[{'UserId':_0x264344['params']['id']},{'OwnerId':_0x264344[_0x53f1('0x53')]['id']}]}]};_0x9e4dd3=_[_0x53f1('0x59')]({},_0x9e4dd3,_0x264344[_0x53f1('0xd0')]);var _0x29590a={'where':_0x9e4dd3[_0x53f1('0x40')]};return db['CmHopper']['count'](_0x29590a)[_0x53f1('0x14')](function(_0x206a5d){_0x1f5a37[_0x53f1('0x25')]=_0x206a5d;if(_0x264344['query'][_0x53f1('0x42')]){_0x9e4dd3['include']=[{'attributes':['id','firstName','lastName',_0x53f1('0xec')],'model':db[_0x53f1('0xcb')],'as':_0x53f1('0x177')},{'attributes':['id',_0x53f1('0x35'),_0x53f1('0x178')],'model':db[_0x53f1('0xaa')],'as':_0x53f1('0xd8')}];}return db[_0x53f1('0x166')][_0x53f1('0x4a')](_0x9e4dd3);})[_0x53f1('0x14')](function(_0x5baa5b){_0x1f5a37[_0x53f1('0x4b')]=_0x5baa5b;return _0x1f5a37;})[_0x53f1('0x14')](respondWithFilteredResult(_0x3a05a5,_0x9e4dd3))[_0x53f1('0x1d')](handleError(_0x3a05a5,null));};exports[_0x53f1('0x179')]=function(_0x5ee03c,_0x5e53ec){if(!_['isNil'](_0x5ee03c[_0x53f1('0x7b')]['id'])&&(_0x5ee03c[_0x53f1('0x7b')][_0x53f1('0x34')]=='admin'||_0x5ee03c['user'][_0x53f1('0x34')]==_0x53f1('0x7b'))){return db[_0x53f1('0x49')]['findOne']({'where':{'id':_0x5ee03c[_0x53f1('0x53')]['id']},'raw':!![]})[_0x53f1('0x14')](function(_0x1e8182){return authService['retrieveApiKey'](_0x1e8182);})[_0x53f1('0x14')](function(_0x5c917f){if(_0x5c917f){return _0x5e53ec[_0x53f1('0x1f')](0xc8)['json']({'api_key':_0x5c917f[_0x53f1('0x17a')]});}else{return _0x5e53ec[_0x53f1('0x1f')](0xcc)[_0x53f1('0x21')]({'message':_0x53f1('0x17b')});}})[_0x53f1('0x1d')](handleError(_0x5e53ec,0x193));}else{return _0x5e53ec[_0x53f1('0x1f')](0x191)[_0x53f1('0x21')]({'message':_0x53f1('0x17c')});}};exports['createApiKey']=function(_0x404177,_0x59ebee){if(!_[_0x53f1('0x67')](_0x404177['user']['id'])&&(_0x404177[_0x53f1('0x7b')][_0x53f1('0x34')]==_0x53f1('0x7c')||_0x404177[_0x53f1('0x7b')][_0x53f1('0x34')]==_0x53f1('0x7b'))){return db[_0x53f1('0x49')][_0x53f1('0x33')]({'where':{'id':_0x404177['params']['id']}})[_0x53f1('0x14')](function(_0x3625cf){return authService[_0x53f1('0x17d')](_0x3625cf);})['then'](function(_0x195893){return db[_0x53f1('0x49')][_0x53f1('0x28')]({'apiKeyIat':_0x195893[_0x53f1('0x17e')],'apiKeyNonce':_0x195893[_0x53f1('0x17f')]},{'where':{'id':_0x404177[_0x53f1('0x53')]['id']}})[_0x53f1('0x14')](function(){return _0x59ebee['status'](0xc8)[_0x53f1('0x21')]({'api_key':_0x195893[_0x53f1('0x17a')]});});})[_0x53f1('0x1d')](handleError(_0x59ebee,0x193));}else{return _0x59ebee[_0x53f1('0x1f')](0x191)['json']({'message':_0x53f1('0x17c')});}};exports[_0x53f1('0x180')]=function(_0x586f9b,_0x1f73ba){if(!_[_0x53f1('0x67')](_0x586f9b[_0x53f1('0x7b')]['id'])&&(_0x586f9b['user']['role']==_0x53f1('0x7c')||_0x586f9b[_0x53f1('0x7b')]['role']=='user')){return db['User']['find']({'where':{'id':_0x586f9b['params']['id']}})['then'](handleEntityNotFound(_0x1f73ba,null))[_0x53f1('0x14')](function(_0x1fcbbd){if(_0x1fcbbd&&_0x1fcbbd['apiKeyNonce']&&_0x1fcbbd[_0x53f1('0x181')])return _0x1fcbbd;else throw{'message':'API\x20key\x20not\x20available'};})[_0x53f1('0x14')](function(){return db['User'][_0x53f1('0x28')]({'apiKeyNonce':null,'apiKeyIat':null},{'where':{'id':_0x586f9b[_0x53f1('0x53')]['id']}});})[_0x53f1('0x14')](respondWithStatusCode(_0x1f73ba,0xc8))[_0x53f1('0x1d')](handleError(_0x1f73ba,0x193));}else{return _0x1f73ba[_0x53f1('0x1f')](0x191)['json']({'message':'You\x20don\x27t\x20have\x20sufficient\x20privileges\x20to\x20access\x20this\x20resource.'});}};exports[_0x53f1('0x182')]=function(_0x1ef26e,_0x3003e7){var _0x1c602c=_0x1ef26e[_0x53f1('0x7b')][_0x53f1('0x2a')]({'plain':!![]});if(!_0x1c602c){return _0x3003e7[_0x53f1('0x1f')](0x191)[_0x53f1('0x37')](_0x53f1('0x183'));}else{Promise[_0x53f1('0x102')]()[_0x53f1('0x14')](function(){if(_0x1ef26e['query'][_0x53f1('0x44')]!=='true')return;return _0x1ef26e[_0x53f1('0x7b')]['getUserSetting']();})[_0x53f1('0x14')](function(_0x56144f){if(!_0x56144f)return;return _0x56144f[_0x53f1('0x2a')]({'plain':!![]});})[_0x53f1('0x14')](function(_0x168b10){_0x1c602c[_0x53f1('0x44')]=_0x168b10;return _0x3003e7['status'](0xc8)[_0x53f1('0x21')](_0x1c602c);});}};exports['getPresence']=function(_0x327be7,_0x170a08){var _0xfd2985={'offset':0x0},_0x4de22d={'count':0x0,'rows':[]};Promise[_0x53f1('0x102')]()['then'](function(){if(!_0x327be7[_0x53f1('0x41')][_0x53f1('0x2e')]&&!_0x327be7[_0x53f1('0x41')]['teams']&&!_0x327be7[_0x53f1('0x41')][_0x53f1('0x184')])return[];return Promise[_0x53f1('0x102')]()[_0x53f1('0x14')](function(){var _0x309bd4=[];if(!_[_0x53f1('0x8c')](_0x327be7[_0x53f1('0x41')][_0x53f1('0x185')])){_0x309bd4[_0x53f1('0x48')](db[_0x53f1('0x114')]['findAll']({'attributes':['id','name'],'where':{'id':_0x327be7[_0x53f1('0x41')][_0x53f1('0x185')]}}));}if(!_[_0x53f1('0x8c')](_0x327be7['query'][_0x53f1('0x184')])){_0x309bd4[_0x53f1('0x48')](db['VoiceQueue'][_0x53f1('0x4a')]({'attributes':['id',_0x53f1('0x35')],'type':_0x53f1('0x186'),'where':{'id':_0x327be7[_0x53f1('0x41')]['queues']}}));}return Promise[_0x53f1('0x51')](_0x309bd4);})['then'](function(_0x2d9e68){var _0x13e03c=_[_0x53f1('0x11f')](_0x2d9e68)[_0x53f1('0x30')](function(_0x5e345d){return _0x5e345d[_0x53f1('0x12c')]({'attributes':['id',_0x53f1('0x35'),_0x53f1('0x61'),_0x53f1('0x9e')],'raw':!![]});});return Promise[_0x53f1('0x51')](_0x13e03c);})['then'](function(_0x17f5f0){var _0x48caec=_[_0x53f1('0x11f')](_0x17f5f0);if(!_0x327be7[_0x53f1('0x41')][_0x53f1('0x2e')])return _0x48caec;if(_[_0x53f1('0x8c')](_0x48caec)){return db['User'][_0x53f1('0x4a')]({'attributes':['id',_0x53f1('0x35'),'internal','online'],'where':{'role':_0x53f1('0x2b'),'$or':[db['sequelize'][_0x53f1('0x40')](db[_0x53f1('0x68')]['fn'](_0x53f1('0x187'),db[_0x53f1('0x68')][_0x53f1('0x188')](_0x53f1('0x35'))),{'$like':'%'+_0x327be7['query'][_0x53f1('0x2e')]['toLowerCase']()+'%'}),{'internal':{'$like':'%'+_0x327be7[_0x53f1('0x41')][_0x53f1('0x2e')]+'%'}}]},'raw':!![]});}else{return _(_0x48caec)['flatten']()['filter'](function(_0xe0bb78){return _0xe0bb78[_0x53f1('0x35')]['toLowerCase']()[_0x53f1('0x32')](_0x327be7[_0x53f1('0x41')][_0x53f1('0x2e')][_0x53f1('0xa5')]())||_0xe0bb78[_0x53f1('0x61')][_0x53f1('0x189')]()['includes'](_0x327be7['query'][_0x53f1('0x2e')]);})[_0x53f1('0x31')]();}})[_0x53f1('0x14')](function(_0x33e440){var _0x2086c8='name';var _0x3eaafe=_0x53f1('0x18a');if(_0x327be7[_0x53f1('0x41')][_0x53f1('0xce')]){_0x3eaafe=_0x327be7[_0x53f1('0x41')][_0x53f1('0xce')][0x0]==='-'?_0x53f1('0x18b'):_0x53f1('0x18a');_0x2086c8=_0x3eaafe===_0x53f1('0x18a')?_0x327be7[_0x53f1('0x41')][_0x53f1('0xce')]:_0x327be7[_0x53f1('0x41')]['sort'][_0x53f1('0x18c')](0x1);}return _(_0x33e440)[_0x53f1('0x18d')]('id')['orderBy']([function(_0x9d420d){return _0x2086c8==='name'?_0x9d420d[_0x2086c8][_0x53f1('0xa5')]():_0x9d420d[_0x2086c8];}],[_0x3eaafe])[_0x53f1('0x30')](function(_0x43f26c){return _['pick'](_0x43f26c,['id','name',_0x53f1('0x61'),'online']);})[_0x53f1('0x31')]();})[_0x53f1('0x14')](function(_0x4eb44b){return client[_0x53f1('0x13')](_0x53f1('0x82'),_0x327be7)['then'](function(_0x487c61){if(_0x487c61[_0x53f1('0x19')])throw new Error(_0x53f1('0x18e'));var _0x13a88a=_0x487c61[_0x53f1('0x1c')];var _0x187245=jayson[_0x53f1('0x11')]['http']({'port':0x232c});return _0x187245[_0x53f1('0x13')](_0x53f1('0x82'),_0x327be7)[_0x53f1('0x14')](function(_0x1f9667){if(_0x1f9667[_0x53f1('0x19')])throw new Error('Unable\x20to\x20retrieve\x20RPC\x20agents\x20(Routing)');var _0x167195=_0x1f9667[_0x53f1('0x1c')];return _['merge']({},_0x167195,_0x13a88a);});})[_0x53f1('0x14')](function(_0x1bbc50){return _[_0x53f1('0x30')](_0x4eb44b,function(_0x57e0c2){var _0x293333=_['find'](_0x1bbc50[_0x53f1('0x4b')],['id',_0x57e0c2['id']]);if(!_0x293333||!_0x57e0c2[_0x53f1('0x9e')]){_0x57e0c2['status']='offline';}else if(_0x293333[_0x53f1('0x9f')]){_0x57e0c2[_0x53f1('0x1f')]=_0x53f1('0x103');}else{_0x57e0c2[_0x53f1('0x1f')]=_[_0x53f1('0x32')]([_0x53f1('0x18f'),_0x53f1('0x190'),_0x53f1('0x191'),_0x53f1('0x192'),null,undefined],_0x293333[_0x53f1('0x193')])?_0x53f1('0x9e'):'busy';}return _0x57e0c2;});});});})['then'](function(_0x3c866d){if(!_0x327be7[_0x53f1('0x41')][_0x53f1('0xd1')](_0x53f1('0xd6'))){_0xfd2985[_0x53f1('0x23')]=qs[_0x53f1('0x23')](_0x327be7[_0x53f1('0x41')][_0x53f1('0x23')]||0xa);_0xfd2985[_0x53f1('0x24')]=qs[_0x53f1('0x24')](_0x327be7['query'][_0x53f1('0x24')]);}_0x4de22d[_0x53f1('0x25')]=_0x3c866d[_0x53f1('0x4c')];_0x4de22d[_0x53f1('0x4b')]=_0xfd2985['limit']?_0x3c866d['slice'](_0xfd2985[_0x53f1('0x24')],_0xfd2985[_0x53f1('0x24')]+_0xfd2985[_0x53f1('0x23')]):_0x3c866d;return _0x4de22d;})[_0x53f1('0x14')](respondWithFilteredResult(_0x170a08,_0xfd2985))['catch'](handleError(_0x170a08,null));};function get_open_tabs(_0xb36767,_0x5a0796){var _0x2caadb=_0xb36767['charAt'](0x0)[_0x53f1('0x194')]()+_0xb36767[_0x53f1('0x195')](0x1);var _0x3cb78b={'type':db[_0x53f1('0x91')]['QueryTypes'][_0x53f1('0x196')],'raw':!![]};return new BPromise(function(_0x31e252,_0x27b80d){var _0xbb14a8=squel[_0x53f1('0x197')]()[_0x53f1('0x198')]('ui.'+_0x2caadb+'InteractionId','id')['field'](_0x53f1('0x199'))['from']('user_has_'+_0xb36767+_0x53f1('0x19a'),'ui')[_0x53f1('0x40')](_0x53f1('0x19b'),_0x5a0796['id']);return db['sequelize'][_0x53f1('0x41')](_0xbb14a8[_0x53f1('0x189')](),_0x3cb78b)[_0x53f1('0x14')](function(_0x4c37db){_0x5a0796[_0x2caadb+_0x53f1('0x19c')]=_0x4c37db;_0x31e252(_0x4c37db);})[_0x53f1('0x1d')](function(_0x589138){_0x27b80d(_0x589138);});});}
\ No newline at end of file
+var _0xc402=['emit','destroy','get','role','admin','Users','Agents','Telephones','telephone','filter','ignore','value','includes','find','UserProfileResource','error','name','send','User','map','fieldName','type','key','salt','resetPasswordToken','getOptions','where','query','includeAll','include','true','UserSetting','userSetting','attributes','push','findAll','rows','dataValues','sms','fax','mail','openchannel','all','catch','show','params','options','whatsapp','body','describe','ids','omit','internal','Setting','findById','securePassword','password','max','isNil','min_internal','sequelize','select\x20(select\x20IFNULL(max(internal)+1,1)\x20from\x20users\x20where\x20internal\x20<\x20md.internal)\x20as\x20\x27from\x27,\x20md.internal\x20-\x201\x20as\x20\x27to\x27\x20from\x20users\x20md\x20where\x20md.internal\x20!=\x201\x20and\x20not\x20exists\x20(select\x201\x20from\x20users\x20md2\x20where\x20md2.internal\x20=\x20md.internal\x20-\x201)','QueryTypes','SELECT','length','from','mailbox','VoiceMail','fullname','email','permissions','101','102','103','110','104','105','106','107','108','109','100','111','114','115','create','user','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','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','bulkCreate','some','UserProfileSection','autoAssociation','compact','changePassword','oldPassword','newPassword','ValidationError','Invalid\x20body\x20format.\x20Use\x20oldPassword\x20and\x20newPassword','authenticate','Sequelize','New\x20password\x20must\x20be\x20different\x20from\x20old\x20password','Invalid\x20body\x20format.\x20Use\x20newPassword','findOne','enforcePasswordHistory','passwordHistoryLimit','validatePasswordPattern','previousPasswords','validatePasswordHistory','updatePasswordsHistory','addQueues','online','loginInPause','voicePause','interface','isValidChannel','Unknown\x20channel','capitalize','toLowerCase','penalty','spread','QueueId','Queue:save','format','SIP/%s','UserVoiceQueueRt','upsert','channel','Queues','Queue:remove','voice','addAvatar','file','filename','getAvatar','join','userpic','download','existsSync','root','server/files/images/','chat','ChatOpenTabs','createdAt','FAX','OpenchannelOpenTabs','OPENCHANNEL','MailOpenTabs','MAIL','SmsOpenTabs','SMS','WhatsappOpenTabs','WHATSAPP','User\x20with\x20id\x20%s\x20not\x20found','List','Tags','color','tag','model','Queue','rawAttributes','keys','filters','intersection','fields','sort','pick','merge','Unknown\x20role','hasOwnProperty','nolimit','order','getVoiceQueuesRt','ChatGroup','getGroups','getRecordings','VoiceRecording','UserId','getScreenRecordings','ScreenRecording','getChatInteractions','getOpenchannelInteractions','OpenchannelInteraction','getMailInteractions','MailInteraction','getSmsInteractions','SmsInteraction','getFaxInteractions','getWhatsappInteractions','WhatsappInteraction','login','phone','LOCAL/%s@from-sip/n','intrf','user:%s','user:forcelogout','headers','x-forwarded-for','connection','remoteAddress','socket','getVoiceQueues','UserVoiceQueue.penalty','MemberReport','YYYY-MM-DD\x20HH:mm:ss','LOGIN','LOGININPAUSE','resolve','logout','forEach','pause','PAUSE','updateAttributes','DEFAULT\x20PAUSE','unpause','Channel\x20parameter\x20%s\x20is\x20invalid','mailPause','chatPause','smsPause','whatsappPause','lastPauseAt','getTeams','Team','addTeams','Body\x20parameter\x20\x27ids\x27\x20is\x20required','transaction','getAssociatedQueues','flattenDeep','addAgent','getDataValue','Voice','TeamVoicePrefix','UserVoicePrefix','VoicePrefixId','removeTeams','isArray','removeAgent','getLists','CmList','getAgents','values','You\x20can\x27t\x20delete\x20yourself','addChatInteractions','user_has_chat_interactions:save','removeChatInteractions','user_has_chat_interactions:remove','addMailInteractions','user_has_mail_interactions:save','removeMailInteractions','user_has_mail_interactions:remove','addFaxInteractions','user_has_fax_interactions:save','removeFaxInteractions','user_has_fax_interactions:remove','addSmsInteractions','user_has_sms_interactions:save','removeSmsInteractions','user_has_sms_interactions:remove','addOpenchannelInteractions','removeOpenchannelInteractions','user_has_openchannel_interactions:remove','addWhatsappInteractions','user_has_whatsapp_interactions:save','removeWhatsappInteractions','getVoicePrefixes','VoicePrefix','getFaxAccounts','FaxAccount','addFaxAccounts','removeFaxAccounts','MailAccount','getMailAccounts','addMailAccounts','getOpenchannelAccounts','OpenchannelAccount','addOpenchannelAccounts','removeOpenchannelAccounts','SmsAccount','getSmsAccounts','addSmsAccounts','removeSmsAccounts','getChatWebsites','addChatWebsites','removeChatWebsites','getWhatsappAccounts','addWhatsappAccounts','removeWhatsappAccounts','getScheduledCalls','CmHopper','concat','$and','$or','$gt','$lt','$lte','$ne','$eq','$not','$between','$notBetween','$notIn','$like','$notLike','$iLike','$notILike','$overlap','$contains','$contained','firstName','lastName','Contact','dialActive','VoiceQueue','getApiKey','token','No\x20API\x20access\x20key\x20found!','You\x20don\x27t\x20have\x20sufficient\x20privileges\x20to\x20access\x20this\x20resource.','createApiKey','generateApiKey','nonce','removeApiKey','apiKeyNonce','apiKeyIat','API\x20key\x20not\x20available','whoami','Unable\x20to\x20retrieve\x20the\x20current\x20user','getUserSetting','getPresence','idle','unknown','ringing','teams','queues','inbound','flatten','toString','lower','col','asc','substring','uniqBy','offline','voiceStatus','unavailable','slice','toUpperCase','select','InteractionId','ui.createdAt','user_has_','ui.UserId\x20=\x20?','OpenTabs','messengerSoundNotification','util','path','lodash','ioredis','../../components/auth/service','../../components/contacts','../../components/parsers/qs','../../components/realtime/agents','../../config/logger','api','../../config/environment','../../config/license/util','../../errors/api','APIBadRequestError','APINotFoundError','handleError','../../mysqldb','redis','./user.socket','register','sendStatus','status','end','offset','undefined','limit','count','json','update','then','agent'];(function(_0x36b064,_0x3d09dc){var _0x367678=function(_0x32593e){while(--_0x32593e){_0x36b064['push'](_0x36b064['shift']());}};_0x367678(++_0x3d09dc);}(_0xc402,0x166));var _0x2c40=function(_0x906c25,_0x468423){_0x906c25=_0x906c25-0x0;var _0x30dc66=_0xc402[_0x906c25];return _0x30dc66;};'use strict';var moment=require('moment');var util=require(_0x2c40('0x0'));var path=require(_0x2c40('0x1'));var fs=require('fs');var _=require(_0x2c40('0x2'));var squel=require('squel');var Redis=require(_0x2c40('0x3'));var authService=require(_0x2c40('0x4'));var contacts=require(_0x2c40('0x5'));var qs=require(_0x2c40('0x6'));var rta=require(_0x2c40('0x7'));var logger=require(_0x2c40('0x8'))(_0x2c40('0x9'));var utils=require('../../config/utils');var config=require(_0x2c40('0xa'));var licenseUtil=require(_0x2c40('0xb'));var APIBadRequestError=require(_0x2c40('0xc'))[_0x2c40('0xd')];var APINotFoundError=require(_0x2c40('0xc'))[_0x2c40('0xe')];var APIHandleError=require(_0x2c40('0xc'))[_0x2c40('0xf')];var db=require(_0x2c40('0x10'))['db'];var socket=require('socket.io-emitter')(new Redis(config[_0x2c40('0x11')]));require(_0x2c40('0x12'))[_0x2c40('0x13')](socket);config[_0x2c40('0x11')]=_['defaults'](config[_0x2c40('0x11')],{'host':'localhost','port':0x18eb});var values;function respondWithStatusCode(_0x409206,_0x6a5486){_0x6a5486=_0x6a5486||0xcc;return function(_0x1e9ec2){if(_0x1e9ec2){return _0x409206[_0x2c40('0x14')](_0x6a5486);}return _0x409206[_0x2c40('0x15')](_0x6a5486)[_0x2c40('0x16')]();};}function respondWithResult(_0x5a568a,_0x3057b1){_0x3057b1=_0x3057b1||0xc8;return function(_0x5eaba3){if(_0x5eaba3){return _0x5a568a[_0x2c40('0x15')](_0x3057b1)['json'](_0x5eaba3);}};}function respondWithFilteredResult(_0x43a773,_0x19d4a5){return function(_0xb3d3f1){if(_0xb3d3f1){var _0x51e586=typeof _0x19d4a5[_0x2c40('0x17')]===_0x2c40('0x18')&&typeof _0x19d4a5[_0x2c40('0x19')]===_0x2c40('0x18');var _0x3eeb45=_0xb3d3f1[_0x2c40('0x1a')];var _0x28526e=_0x51e586?0x0:_0x19d4a5[_0x2c40('0x17')];var _0x25b1ec=_0x51e586?_0xb3d3f1[_0x2c40('0x1a')]:_0x19d4a5[_0x2c40('0x17')]+_0x19d4a5['limit'];var _0x2d042d;if(_0x25b1ec>=_0x3eeb45){_0x25b1ec=_0x3eeb45;_0x2d042d=0xc8;}else{_0x2d042d=0xce;}_0x43a773[_0x2c40('0x15')](_0x2d042d);return _0x43a773['set']('Content-Range',_0x28526e+'-'+_0x25b1ec+'/'+_0x3eeb45)[_0x2c40('0x1b')](_0xb3d3f1);}return null;};}function saveUpdates(_0x483af0){return function(_0x2799c0){if(_0x2799c0){return _0x2799c0[_0x2c40('0x1c')](_0x483af0)[_0x2c40('0x1d')](function(_0x401111){if(_0x401111['role']===_0x2c40('0x1e')){socket[_0x2c40('0x1f')]('userNotification:recalc:'+_0x401111['id'],_0x401111);}return _0x401111;});}return null;};}function removeEntity(_0x1b1ac6){return function(_0x217f9a){if(_0x217f9a){return _0x217f9a[_0x2c40('0x20')]()[_0x2c40('0x1d')](function(){var _0x2a40c1=_0x217f9a[_0x2c40('0x21')]({'plain':!![]});if(_0x2a40c1[_0x2c40('0x22')]===_0x2c40('0x23'))return;var _0x13db8b=[{'name':_0x2c40('0x24'),'value':'user','ignore':!![]},{'name':_0x2c40('0x25'),'value':_0x2c40('0x1e'),'ignore':![]},{'name':_0x2c40('0x26'),'value':_0x2c40('0x27'),'ignore':![]}];var _0xc19e77=_(_0x13db8b)[_0x2c40('0x28')](_0x2c40('0x29'))['map'](_0x2c40('0x2a'))[_0x2c40('0x2a')]();if(_[_0x2c40('0x2b')](_0xc19e77,_0x2a40c1[_0x2c40('0x22')])){return;}var _0x497e8a=_[_0x2c40('0x2c')](_0x13db8b,[_0x2c40('0x2a'),_0x2a40c1[_0x2c40('0x22')]])['name'];return db[_0x2c40('0x2d')][_0x2c40('0x20')]({'where':{'type':_0x497e8a,'resourceId':_0x2a40c1['id']}})['then'](function(){return _0x217f9a;});})[_0x2c40('0x1d')](function(){_0x1b1ac6[_0x2c40('0x15')](0xcc)[_0x2c40('0x16')]();});}};}function handleEntityNotFound(_0x5f4f59){return function(_0x25d77a){if(!_0x25d77a){_0x5f4f59[_0x2c40('0x14')](0x194);}return _0x25d77a;};}function handleError(_0x46ebbf,_0xe6f6ad){_0xe6f6ad=_0xe6f6ad||0x1f4;return function(_0x147303){logger[_0x2c40('0x2e')](_0x147303['stack']);if(_0x147303['name']){delete _0x147303[_0x2c40('0x2f')];}_0x46ebbf['status'](_0xe6f6ad)[_0x2c40('0x30')](_0x147303);};}function getUserAttributes(){return _(db[_0x2c40('0x31')]['rawAttributes'])[_0x2c40('0x32')](function(_0x2a023b){return{'name':_0x2a023b[_0x2c40('0x33')],'type':_0x2a023b[_0x2c40('0x34')][_0x2c40('0x35')]};})[_0x2c40('0x28')](function(_0x246556){return!['password',_0x2c40('0x36'),'previousPasswords',_0x2c40('0x37'),'resetPasswordExpires','md5secret'][_0x2c40('0x2b')](_0x246556['name']);})['value']();}exports['index']=function(_0x418ef3,_0x2db019){var _0x59808a={},_0x3d0345={'count':0x0,'rows':[]};var _0x583104=getUserAttributes();_0x59808a=qs[_0x2c40('0x38')](_0x583104,_0x418ef3);var _0x1825f7={'where':_0x59808a[_0x2c40('0x39')]};return db[_0x2c40('0x31')][_0x2c40('0x1a')](_0x1825f7)[_0x2c40('0x1d')](function(_0x32fb8d){_0x3d0345['count']=_0x32fb8d;if(_0x418ef3[_0x2c40('0x3a')][_0x2c40('0x3b')]){_0x59808a[_0x2c40('0x3c')]=[{'all':!![]}];}if(_0x418ef3[_0x2c40('0x3a')]['userSetting']===_0x2c40('0x3d')){_0x59808a[_0x2c40('0x3c')]=[{'model':db[_0x2c40('0x3e')],'as':_0x2c40('0x3f')}];}if(!_[_0x2c40('0x2b')](_0x59808a[_0x2c40('0x40')],'id')){_0x59808a[_0x2c40('0x40')][_0x2c40('0x41')]('id');}return db[_0x2c40('0x31')][_0x2c40('0x42')](_0x59808a);})[_0x2c40('0x1d')](function(_0x14b63c){_0x3d0345[_0x2c40('0x43')]=_0x14b63c;if(_0x418ef3['query']['openTabs']===_0x2c40('0x3d')){var _0x39eb82=[];for(var _0x1e522c=0x0;_0x1e522c<_0x3d0345[_0x2c40('0x43')]['length'];_0x1e522c++){_0x39eb82[_0x2c40('0x41')](get_open_tabs('chat',_0x3d0345['rows'][_0x1e522c][_0x2c40('0x44')]));_0x39eb82[_0x2c40('0x41')](get_open_tabs(_0x2c40('0x45'),_0x3d0345[_0x2c40('0x43')][_0x1e522c][_0x2c40('0x44')]));_0x39eb82[_0x2c40('0x41')](get_open_tabs(_0x2c40('0x46'),_0x3d0345[_0x2c40('0x43')][_0x1e522c][_0x2c40('0x44')]));_0x39eb82['push'](get_open_tabs(_0x2c40('0x47'),_0x3d0345['rows'][_0x1e522c][_0x2c40('0x44')]));_0x39eb82[_0x2c40('0x41')](get_open_tabs(_0x2c40('0x48'),_0x3d0345['rows'][_0x1e522c][_0x2c40('0x44')]));_0x39eb82[_0x2c40('0x41')](get_open_tabs('whatsapp',_0x3d0345[_0x2c40('0x43')][_0x1e522c][_0x2c40('0x44')]));}return Promise[_0x2c40('0x49')](_0x39eb82)['then'](function(){return _0x3d0345;});}else{return _0x3d0345;}})['then'](respondWithFilteredResult(_0x2db019,_0x59808a))[_0x2c40('0x4a')](handleError(_0x2db019,null));};exports[_0x2c40('0x4b')]=function(_0x5bf43e,_0xf0f5ec){var _0x46ca4e=getUserAttributes();_0x5bf43e[_0x2c40('0x3a')]['id']=_0x5bf43e[_0x2c40('0x4c')]['id'];var _0x39cac5=qs[_0x2c40('0x38')](_0x46ca4e,_0x5bf43e);if(_0x5bf43e[_0x2c40('0x3a')][_0x2c40('0x3b')]){_0x39cac5[_0x2c40('0x3c')]=[{'all':!![]}];}if(_0x5bf43e[_0x2c40('0x3a')][_0x2c40('0x3f')]==='true'){_0x39cac5['include']=[{'model':db[_0x2c40('0x3e')],'as':_0x2c40('0x3f')}];}_0x39cac5=_['merge']({},_0x39cac5,_0x5bf43e[_0x2c40('0x4d')]);if(!_[_0x2c40('0x2b')](_0x39cac5[_0x2c40('0x40')],'id')){_0x39cac5[_0x2c40('0x40')][_0x2c40('0x41')]('id');}return db['User'][_0x2c40('0x2c')](_0x39cac5)[_0x2c40('0x1d')](handleEntityNotFound(_0xf0f5ec,null))[_0x2c40('0x1d')](function(_0x5a2c6a){var _0x60609e=[];values=_0x5a2c6a;if(_0x5bf43e[_0x2c40('0x3a')]['openTabs']==='true'){_0x60609e[_0x2c40('0x41')](get_open_tabs('chat',_0x5a2c6a[_0x2c40('0x44')]));_0x60609e[_0x2c40('0x41')](get_open_tabs('sms',_0x5a2c6a[_0x2c40('0x44')]));_0x60609e[_0x2c40('0x41')](get_open_tabs(_0x2c40('0x48'),_0x5a2c6a['dataValues']));_0x60609e[_0x2c40('0x41')](get_open_tabs(_0x2c40('0x4e'),_0x5a2c6a['dataValues']));_0x60609e[_0x2c40('0x41')](get_open_tabs(_0x2c40('0x46'),_0x5a2c6a[_0x2c40('0x44')]));_0x60609e['push'](get_open_tabs(_0x2c40('0x47'),_0x5a2c6a['dataValues']));return Promise[_0x2c40('0x49')](_0x60609e);}else{return values;}})['then'](function(){return values;})['then'](respondWithResult(_0xf0f5ec,null))['catch'](handleError(_0xf0f5ec,null));};exports[_0x2c40('0x1c')]=function(_0x1fe724,_0x206eb2){if(_0x1fe724[_0x2c40('0x4f')]['id']){delete _0x1fe724[_0x2c40('0x4f')]['id'];}delete _0x1fe724[_0x2c40('0x4f')]['role'];return db[_0x2c40('0x31')][_0x2c40('0x2c')]({'where':{'id':_0x1fe724[_0x2c40('0x4c')]['id']}})[_0x2c40('0x1d')](handleEntityNotFound(_0x206eb2,null))[_0x2c40('0x1d')](saveUpdates(_0x1fe724[_0x2c40('0x4f')],null))[_0x2c40('0x1d')](respondWithResult(_0x206eb2,null))[_0x2c40('0x4a')](handleError(_0x206eb2,null));};exports[_0x2c40('0x50')]=function(_0x953a44,_0x5c8b3c){return db[_0x2c40('0x31')][_0x2c40('0x50')]()[_0x2c40('0x1d')](respondWithResult(_0x5c8b3c,null))[_0x2c40('0x4a')](handleError(_0x5c8b3c,null));};exports['addContacts']=function(_0xa6d825,_0x13ac13){return db[_0x2c40('0x31')][_0x2c40('0x2c')]({'where':{'id':_0xa6d825[_0x2c40('0x4c')]['id']}})[_0x2c40('0x1d')](handleEntityNotFound(_0x13ac13,null))['then'](function(_0x20f3ba){if(_0x20f3ba){return _0x20f3ba['addContacts'](_0xa6d825[_0x2c40('0x4f')][_0x2c40('0x51')],_[_0x2c40('0x52')](_0xa6d825['body'],['ids','id'])||{});}})[_0x2c40('0x1d')](respondWithResult(_0x13ac13,null))[_0x2c40('0x4a')](handleError(_0x13ac13,null));};function validateUser(_0x1a8bb4){return new Promise(function(_0x24ddcd,_0x5de923){if(_0x1a8bb4[_0x2c40('0x53')])return _0x24ddcd(_0x1a8bb4);return db[_0x2c40('0x54')][_0x2c40('0x55')](0x1)[_0x2c40('0x1d')](function(_0x3d7fb1){if(_0x3d7fb1[_0x2c40('0x56')])authService['validatePasswordPattern'](_0x1a8bb4[_0x2c40('0x57')]);db[_0x2c40('0x31')][_0x2c40('0x58')](_0x2c40('0x53'))[_0x2c40('0x1d')](function(_0x42e788){if(_[_0x2c40('0x59')](_0x42e788)){_0x1a8bb4['internal']=_0x3d7fb1[_0x2c40('0x5a')]||0x1;return;}if(_[_0x2c40('0x59')](_0x3d7fb1['min_internal'])||_0x3d7fb1[_0x2c40('0x5a')]===_0x42e788){_0x1a8bb4['internal']=_0x42e788+0x1;return;}if(_0x3d7fb1[_0x2c40('0x5a')]>_0x42e788){_0x1a8bb4['internal']=_0x3d7fb1[_0x2c40('0x5a')];return;}return db[_0x2c40('0x5b')]['query'](_0x2c40('0x5c'),{'type':db[_0x2c40('0x5b')][_0x2c40('0x5d')][_0x2c40('0x5e')]})[_0x2c40('0x1d')](function(_0x47e0f8){if(_0x47e0f8&&_0x47e0f8[_0x2c40('0x5f')]){for(var _0x23de9d=0x0,_0x4ea715=_0x47e0f8['length'];_0x23de9d<_0x4ea715&&_[_0x2c40('0x59')](_0x1a8bb4[_0x2c40('0x53')]);_0x23de9d++){if(_0x3d7fb1[_0x2c40('0x5a')]<=_0x47e0f8[_0x23de9d][_0x2c40('0x60')]){_0x1a8bb4['internal']=_0x47e0f8[_0x23de9d][_0x2c40('0x60')];}else if(_0x3d7fb1[_0x2c40('0x5a')]>_0x47e0f8[_0x23de9d][_0x2c40('0x60')]&&_0x3d7fb1[_0x2c40('0x5a')]<=_0x47e0f8[_0x23de9d]['to']){_0x1a8bb4['internal']=_0x3d7fb1['min_internal'];}}}if(_['isNil'](_0x1a8bb4[_0x2c40('0x53')])){_0x1a8bb4['internal']=_0x42e788+0x1;}return _0x24ddcd(_0x1a8bb4);});});})[_0x2c40('0x4a')](function(_0x78c53e){_0x5de923(_0x78c53e);});});}function updateUser(_0xde130b){return new Promise(function(_0x5ecb29,_0x224ad7){try{if(_0xde130b['voicemail']){_0xde130b[_0x2c40('0x61')]=_0xde130b[_0x2c40('0x53')];_0xde130b[_0x2c40('0x62')]={'mailbox':_0xde130b[_0x2c40('0x53')],'password':_0xde130b[_0x2c40('0x57')],'fullname':_0xde130b[_0x2c40('0x63')],'email':_0xde130b[_0x2c40('0x64')]};}if(_0xde130b[_0x2c40('0x22')]===_0x2c40('0x1e')){if(!_0xde130b[_0x2c40('0x65')])_0xde130b[_0x2c40('0x65')]=[_0x2c40('0x66'),_0x2c40('0x67'),_0x2c40('0x68'),'113',_0x2c40('0x69'),_0x2c40('0x6a'),_0x2c40('0x6b'),_0x2c40('0x6c'),_0x2c40('0x6d'),_0x2c40('0x6e'),_0x2c40('0x6f'),_0x2c40('0x70'),_0x2c40('0x71'),_0x2c40('0x72'),_0x2c40('0x73')];}_0x5ecb29(_0xde130b);}catch(_0x34f5ca){_0x224ad7(_0x34f5ca);}});}exports[_0x2c40('0x74')]=function(_0x465af8,_0x19b8cf){if(_0x465af8[_0x2c40('0x75')][_0x2c40('0x22')]==='agent')throw new Error(_0x2c40('0x76'));if(_0x465af8['body'][_0x2c40('0x22')]===_0x2c40('0x75')&&_0x465af8[_0x2c40('0x75')][_0x2c40('0x22')]!==_0x2c40('0x23')){throw new Error(_0x2c40('0x77'));}if(_0x465af8[_0x2c40('0x4f')]['role']===_0x2c40('0x23')&&_0x465af8['user'][_0x2c40('0x22')]!=='admin'){throw new Error(_0x2c40('0x78'));}return licenseUtil[_0x2c40('0x79')]([_0x465af8[_0x2c40('0x4f')]])[_0x2c40('0x1d')](function(){return validateUser(_0x465af8[_0x2c40('0x4f')]);})[_0x2c40('0x1d')](function(_0x25a2a2){return updateUser(_0x25a2a2)[_0x2c40('0x1d')](function(_0x4d908d){if(_0x4d908d[_0x2c40('0x22')]==='admin'){_0x4d908d[_0x2c40('0x7a')]=_0x465af8[_0x2c40('0x75')][_0x2c40('0x7a')];delete _0x4d908d[_0x2c40('0x7b')];}return _0x4d908d;});})[_0x2c40('0x1d')](function(_0x3e3fe2){return db['User']['create'](_0x3e3fe2,{'include':[{'model':db['VoiceMail'],'as':_0x2c40('0x62')}]});})['then'](function(_0x2a2a88){if(_0x465af8[_0x2c40('0x4f')][_0x2c40('0x22')]==='user')return _0x2a2a88;if(_0x465af8['user'][_0x2c40('0x22')]!=='user')return _0x2a2a88;return db['UserProfileSection'][_0x2c40('0x2c')]({'where':{'name':_0x2a2a88['role']===_0x2c40('0x1e')?_0x2c40('0x25'):_0x2c40('0x26'),'userProfileId':_0x465af8[_0x2c40('0x75')][_0x2c40('0x7b')]},'raw':!![]})[_0x2c40('0x1d')](function(_0x529336){if(!_0x529336||_0x529336['autoAssociation']!=0x0)return _0x2a2a88;return db[_0x2c40('0x2d')][_0x2c40('0x74')]({'name':_0x2a2a88['name'],'resourceId':_0x2a2a88['id'],'type':_0x529336[_0x2c40('0x2f')],'sectionId':_0x529336['id']},{})['then'](function(){return _0x2a2a88;});})[_0x2c40('0x4a')](function(_0x3514af){logger['error'](_0x2c40('0x7c'),_0x3514af);throw _0x3514af;});})[_0x2c40('0x1d')](respondWithResult(_0x19b8cf,0xc9))[_0x2c40('0x4a')](handleError(_0x19b8cf,null));};exports[_0x2c40('0x7d')]=function(_0x285919,_0x2d1cfb){var _0x18edfb=_0x285919[_0x2c40('0x4f')];var _0x540a72=[];if(_0x285919[_0x2c40('0x75')]['role']===_0x2c40('0x1e'))throw new Error(_0x2c40('0x76'));if(_[_0x2c40('0x7e')](_0x18edfb,['role',_0x2c40('0x75')])&&_0x285919[_0x2c40('0x75')][_0x2c40('0x22')]!==_0x2c40('0x23')){throw new Error('Unauthorized.\x20You\x20must\x20be\x20an\x20administrator\x20in\x20order\x20to\x20create\x20an\x20user');}if(_[_0x2c40('0x7e')](_0x18edfb,[_0x2c40('0x22'),_0x2c40('0x23')])&&_0x285919[_0x2c40('0x75')][_0x2c40('0x22')]!=='admin'){throw new Error('Unauthorized.\x20You\x20must\x20be\x20an\x20administrator\x20in\x20order\x20to\x20create\x20an\x20administrator');}return licenseUtil[_0x2c40('0x79')](_0x18edfb)[_0x2c40('0x1d')](function(){return validateUser(_0x18edfb[0x0]);})['then'](function(){for(var _0x483ba7=0x1;_0x483ba7<_0x18edfb['length'];_0x483ba7++){var _0x26aee3=_0x18edfb[_0x483ba7-0x1]['internal'];if(!_0x18edfb[_0x483ba7][_0x2c40('0x53')])_0x18edfb[_0x483ba7][_0x2c40('0x53')]=_0x26aee3+0x1;_0x540a72['push'](validateUser(_0x18edfb[_0x483ba7]));}return Promise[_0x2c40('0x49')](_0x540a72);})[_0x2c40('0x1d')](function(){_0x540a72=[];for(var _0x4e1fdc=0x0;_0x4e1fdc<_0x18edfb[_0x2c40('0x5f')];_0x4e1fdc++){_0x540a72[_0x2c40('0x41')](updateUser(_0x18edfb[_0x4e1fdc]));}return Promise[_0x2c40('0x49')](_0x540a72);})[_0x2c40('0x1d')](function(){_0x540a72=_0x18edfb[_0x2c40('0x32')](function(_0x59d8d1){return db[_0x2c40('0x31')][_0x2c40('0x74')](_0x59d8d1,{'include':[{'model':db[_0x2c40('0x62')],'as':_0x2c40('0x62')}]})[_0x2c40('0x1d')](function(_0x4dc666){_0x59d8d1['id']=_0x4dc666['id'];return _0x59d8d1;});});return Promise[_0x2c40('0x49')](_0x540a72);})[_0x2c40('0x1d')](function(_0x84ec34){if(_0x285919[_0x2c40('0x4f')][_0x2c40('0x22')]==='user')return _0x84ec34;if(_0x285919[_0x2c40('0x75')]['role']!==_0x2c40('0x75'))return _0x84ec34;var _0x4f823e=_[_0x2c40('0x7e')](_0x84ec34,function(_0x48b7f0){return _0x48b7f0[_0x2c40('0x22')]===_0x2c40('0x1e')||_0x48b7f0[_0x2c40('0x22')]==='telephone';});if(!_0x4f823e)return _0x84ec34;return db[_0x2c40('0x7f')]['findAll']({'where':{'name':{'$or':[_0x2c40('0x25'),_0x2c40('0x26')]},'userProfileId':_0x285919[_0x2c40('0x75')][_0x2c40('0x7b')]},'raw':!![]})[_0x2c40('0x1d')](function(_0x33ce4a){if(_['isEmpty'](_0x33ce4a)||!_[_0x2c40('0x7e')](_0x33ce4a,[_0x2c40('0x80'),0x0]))return _0x84ec34;_0x540a72=[];var _0x298dac=_(_0x33ce4a)['map'](function(_0x4aa1e2){if(_0x4aa1e2[_0x2c40('0x80')]===0x1)return;return _0x4aa1e2['name']===_0x2c40('0x25')?_0x2c40('0x1e'):'telephone';})[_0x2c40('0x81')]()['value']();for(var _0x12cf28=0x0;_0x12cf28<_0x84ec34[_0x2c40('0x5f')];_0x12cf28++){if(!_['includes'](_0x298dac,_0x84ec34[_0x12cf28][_0x2c40('0x22')]))return;var _0x32616f=_0x84ec34[_0x12cf28][_0x2c40('0x22')]===_0x2c40('0x1e')?_0x2c40('0x25'):_0x2c40('0x26');_0x540a72[_0x2c40('0x41')](db['UserProfileResource'][_0x2c40('0x74')]({'name':_0x84ec34[_0x12cf28][_0x2c40('0x2f')],'resourceId':_0x84ec34[_0x12cf28]['id'],'type':_0x32616f,'sectionId':_['find'](_0x33ce4a,[_0x2c40('0x2f'),_0x32616f])['id']},{}));}return Promise[_0x2c40('0x49')](_0x540a72);});})[_0x2c40('0x1d')](respondWithResult(_0x2d1cfb,0xc9))['catch'](handleError(_0x2d1cfb,null));};exports[_0x2c40('0x82')]=function(_0x571a4b,_0x2b05b3){if(_0x571a4b['body']['id']){delete _0x571a4b[_0x2c40('0x4f')]['id'];}return db[_0x2c40('0x31')][_0x2c40('0x2c')]({'where':{'id':_0x571a4b[_0x2c40('0x4c')]['id']}})[_0x2c40('0x1d')](function(_0x4428f2){if(!_0x4428f2)return null;if(_0x4428f2['id']===_0x571a4b[_0x2c40('0x75')]['id']){if(!_0x571a4b[_0x2c40('0x4f')][_0x2c40('0x83')]||!_0x571a4b['body'][_0x2c40('0x84')]){throw new db['Sequelize'][(_0x2c40('0x85'))](_0x2c40('0x86'));}if(!_0x4428f2[_0x2c40('0x87')](_0x571a4b['body'][_0x2c40('0x83')])){throw new db[(_0x2c40('0x88'))][(_0x2c40('0x85'))]('Wrong\x20credentials');}if(_0x571a4b[_0x2c40('0x4f')]['oldPassword']===_0x571a4b[_0x2c40('0x4f')]['newPassword']){throw new db[(_0x2c40('0x88'))][(_0x2c40('0x85'))](_0x2c40('0x89'));}}else if(_0x571a4b['user'][_0x2c40('0x22')]===_0x2c40('0x23')){if(!_0x571a4b[_0x2c40('0x4f')]['newPassword']){throw new db['Sequelize'][(_0x2c40('0x85'))](_0x2c40('0x8a'));}}else if(_0x571a4b[_0x2c40('0x75')]['role']==='user'){if(!_0x571a4b['body'][_0x2c40('0x84')]){throw new db[(_0x2c40('0x88'))][(_0x2c40('0x85'))](_0x2c40('0x8a'));}if(_0x4428f2[_0x2c40('0x22')]!==_0x2c40('0x1e')){throw new db[(_0x2c40('0x88'))][(_0x2c40('0x85'))](_0x2c40('0x76'));}}else{throw new db[(_0x2c40('0x88'))][(_0x2c40('0x85'))](_0x2c40('0x76'));}return _0x4428f2;})[_0x2c40('0x1d')](handleEntityNotFound(_0x2b05b3,null))[_0x2c40('0x1d')](function(_0x3c3419){return db['Setting'][_0x2c40('0x8b')]({'attributes':['id',_0x2c40('0x56'),_0x2c40('0x8c'),_0x2c40('0x8d')]})['then'](function(_0x3466c0){if(_0x3466c0[_0x2c40('0x56')])authService[_0x2c40('0x8e')](_0x571a4b[_0x2c40('0x4f')][_0x2c40('0x84')]);if(!_0x3466c0[_0x2c40('0x8c')]||!_0x3c3419[_0x2c40('0x8f')])return _0x3c3419;authService[_0x2c40('0x90')](_0x571a4b[_0x2c40('0x4f')]['newPassword'],_0x3c3419[_0x2c40('0x8f')],_0x3466c0[_0x2c40('0x8d')]);return _0x3c3419;})[_0x2c40('0x1d')](saveUpdates({'password':_0x571a4b[_0x2c40('0x4f')]['newPassword'],'passwordResetAt':_0x571a4b['user']['id']==_0x571a4b[_0x2c40('0x4c')]['id']?moment():null,'previousPasswords':authService[_0x2c40('0x91')](_0x571a4b[_0x2c40('0x4f')][_0x2c40('0x84')],_0x3c3419[_0x2c40('0x8f')])},null));})[_0x2c40('0x1d')](respondWithResult(_0x2b05b3,null))[_0x2c40('0x4a')](handleError(_0x2b05b3,null));};exports[_0x2c40('0x92')]=function(_0x32edd4,_0x10bca8){var _0x16129e=_0x32edd4[_0x2c40('0x4f')]['channel'];return db[_0x2c40('0x31')][_0x2c40('0x2c')]({'where':{'id':_0x32edd4['params']['id']},'attributes':['id',_0x2c40('0x2f'),_0x2c40('0x22'),_0x2c40('0x93'),_0x2c40('0x94'),_0x2c40('0x95'),_0x2c40('0x96')]})[_0x2c40('0x1d')](handleEntityNotFound(_0x10bca8,null))[_0x2c40('0x1d')](function(_0x3b9322){if(_0x3b9322){if(!utils[_0x2c40('0x97')](_0x16129e)){throw new db[(_0x2c40('0x88'))][(_0x2c40('0x85'))](_0x2c40('0x98'));}return _0x3b9322['add'+_[_0x2c40('0x99')](_0x16129e[_0x2c40('0x9a')]())+'Queues'](_0x32edd4[_0x2c40('0x4f')][_0x2c40('0x51')],{'penalty':_0x32edd4[_0x2c40('0x4f')][_0x2c40('0x9b')]||0x0})[_0x2c40('0x9c')](function(_0x2c52b9){for(var _0x143c8d=0x0;_0x143c8d<_0x32edd4[_0x2c40('0x4f')][_0x2c40('0x51')][_0x2c40('0x5f')];_0x143c8d+=0x1){var _0x1adf36={'UserId':Number(_0x32edd4[_0x2c40('0x4c')]['id'])};_0x1adf36[_[_0x2c40('0x99')](_0x16129e[_0x2c40('0x9a')]())+_0x2c40('0x9d')]=Number(_0x32edd4[_0x2c40('0x4f')][_0x2c40('0x51')][_0x143c8d]);socket[_0x2c40('0x1f')](_0x2c40('0x75')+_[_0x2c40('0x99')](_0x16129e[_0x2c40('0x9a')]())+_0x2c40('0x9e'),_0x1adf36);}return _0x2c52b9;})[_0x2c40('0x1d')](function(){if(_0x16129e==='voice'){return db['VoiceQueue']['findAll']({'where':{'id':_0x32edd4[_0x2c40('0x4f')]['ids']||[]},'raw':!![],'attributes':['id',_0x2c40('0x2f')]});}})[_0x2c40('0x1d')](function(_0x5bc24e){var _0x1a372d=_0x3b9322[_0x2c40('0x21')]({'plain':!![]});var _0x45bbbf=[];if(_0x16129e==='voice'&&_0x1a372d[_0x2c40('0x22')]===_0x2c40('0x1e')&&_0x1a372d['online']){for(let _0x47465a=0x0;_0x47465a<_0x5bc24e[_0x2c40('0x5f')];_0x47465a+=0x1){_0x45bbbf['push']({'membername':_0x1a372d[_0x2c40('0x2f')],'UserId':_0x1a372d['id'],'queue_name':_0x5bc24e[_0x47465a][_0x2c40('0x2f')],'VoiceQueueId':_0x5bc24e[_0x47465a]['id'],'interface':_[_0x2c40('0x59')](_0x1a372d['interface'])?util[_0x2c40('0x9f')](_0x2c40('0xa0'),_0x1a372d['name']):_0x1a372d[_0x2c40('0x96')],'paused':_0x1a372d[_0x2c40('0x95')]||![],'penalty':_0x32edd4[_0x2c40('0x4f')][_0x2c40('0x9b')]||0x0});}return Promise[_0x2c40('0x49')](_0x45bbbf[_0x2c40('0x32')](function(_0x30affb){return db[_0x2c40('0xa1')][_0x2c40('0xa2')](_0x30affb);}));}return _0x3b9322;});}})[_0x2c40('0x1d')](respondWithStatusCode(_0x10bca8,null))[_0x2c40('0x4a')](handleError(_0x10bca8,null));};exports['removeQueues']=function(_0x5414bd,_0xeeae4f){var _0x688861,_0x4bb7da;return db[_0x2c40('0x31')][_0x2c40('0x2c')]({'where':{'id':_0x5414bd[_0x2c40('0x4c')]['id']},'attributes':['id',_0x2c40('0x2f'),_0x2c40('0x22')]})[_0x2c40('0x1d')](handleEntityNotFound(_0xeeae4f,null))['then'](function(_0x1cd726){if(_0x1cd726){_0x688861=_0x1cd726;if(!_0x5414bd[_0x2c40('0x3a')][_0x2c40('0xa3')]||!utils[_0x2c40('0x97')](_0x5414bd[_0x2c40('0x3a')][_0x2c40('0xa3')])){throw new db[(_0x2c40('0x88'))]['ValidationError'](_0x2c40('0x98'));}return _0x1cd726['remove'+_['capitalize'](_0x5414bd['query'][_0x2c40('0xa3')][_0x2c40('0x9a')]())+_0x2c40('0xa4')](_0x5414bd[_0x2c40('0x3a')][_0x2c40('0x51')]);}})[_0x2c40('0x1d')](function(_0x54698f){if(_['isArray'](_0x5414bd['query'][_0x2c40('0x51')])){for(var _0x314ec5=0x0;_0x314ec5<_0x5414bd[_0x2c40('0x3a')]['ids'][_0x2c40('0x5f')];_0x314ec5+=0x1){_0x4bb7da={'UserId':Number(_0x5414bd['params']['id'])};_0x4bb7da[_['capitalize'](_0x5414bd[_0x2c40('0x3a')]['channel'][_0x2c40('0x9a')]())+_0x2c40('0x9d')]=Number(_0x5414bd['query'][_0x2c40('0x51')][_0x314ec5]);socket['emit'](_0x2c40('0x75')+_[_0x2c40('0x99')](_0x5414bd['query'][_0x2c40('0xa3')][_0x2c40('0x9a')]())+_0x2c40('0xa5'),_0x4bb7da);}}else{_0x4bb7da={'UserId':Number(_0x5414bd[_0x2c40('0x4c')]['id'])};_0x4bb7da[_['capitalize'](_0x5414bd[_0x2c40('0x3a')][_0x2c40('0xa3')][_0x2c40('0x9a')]())+_0x2c40('0x9d')]=Number(_0x5414bd[_0x2c40('0x3a')][_0x2c40('0x51')]);socket[_0x2c40('0x1f')](_0x2c40('0x75')+_['capitalize'](_0x5414bd[_0x2c40('0x3a')][_0x2c40('0xa3')][_0x2c40('0x9a')]())+_0x2c40('0xa5'),_0x4bb7da);}return _0x54698f;})[_0x2c40('0x1d')](function(){if(_0x5414bd['query']['channel']===_0x2c40('0xa6')){return db[_0x2c40('0xa1')]['destroy']({'where':{'UserId':_0x5414bd[_0x2c40('0x4c')]['id'],'VoiceQueueId':_0x5414bd[_0x2c40('0x3a')]['ids']},'individualHooks':!![]})['then'](function(){return _0x688861;});}return _0x688861;})['then'](respondWithStatusCode(_0xeeae4f,null))[_0x2c40('0x4a')](handleError(_0xeeae4f,null));};exports[_0x2c40('0xa7')]=function(_0x26443c,_0x49cb9e){_0x26443c['body']['userpic']=_0x26443c[_0x2c40('0xa8')][_0x2c40('0xa9')];return db['User'][_0x2c40('0x2c')]({'where':{'id':_0x26443c[_0x2c40('0x4c')]['id']}})[_0x2c40('0x1d')](handleEntityNotFound(_0x49cb9e,null))['then'](saveUpdates(_0x26443c[_0x2c40('0x4f')],null))[_0x2c40('0x1d')](respondWithResult(_0x49cb9e,null))[_0x2c40('0x4a')](handleError(_0x49cb9e,null));};exports[_0x2c40('0xaa')]=function(_0x560225,_0x217037){var _0x5f5a19=path[_0x2c40('0xab')](config['root'],'server/files/images/logos/default_profile.png');return db[_0x2c40('0x31')][_0x2c40('0x2c')]({'where':{'id':_0x560225['params']['id']},'attributes':['id',_0x2c40('0xac')],'raw':!![]})[_0x2c40('0x1d')](handleEntityNotFound(_0x217037,null))[_0x2c40('0x1d')](function(_0x4cc31a){if(_0x4cc31a){if(_[_0x2c40('0x59')](_0x4cc31a['userpic'])){return _0x217037[_0x2c40('0xad')](_0x5f5a19);}else{if(!fs[_0x2c40('0xae')](path[_0x2c40('0xab')](config[_0x2c40('0xaf')],_0x2c40('0xb0'),_0x4cc31a[_0x2c40('0xac')]))){return _0x217037['download'](_0x5f5a19);}return _0x217037[_0x2c40('0xad')](path[_0x2c40('0xab')](config[_0x2c40('0xaf')],_0x2c40('0xb0'),_0x4cc31a['userpic']));}}})[_0x2c40('0x4a')](handleError(_0x217037,null));};exports['getOpenTabs']=function(_0x390a9d,_0x1481e4){return db[_0x2c40('0x31')][_0x2c40('0x2c')]({'where':{'id':_0x390a9d['params']['id']},'attributes':['id']})[_0x2c40('0x1d')](handleEntityNotFound(_0x1481e4,null))[_0x2c40('0x1d')](function(_0x2707bd){var _0x8515e2=[];values=_0x2707bd['dataValues'];_0x8515e2[_0x2c40('0x41')](get_open_tabs(_0x2c40('0xb1'),_0x2707bd[_0x2c40('0x44')]));_0x8515e2[_0x2c40('0x41')](get_open_tabs(_0x2c40('0x45'),_0x2707bd['dataValues']));_0x8515e2[_0x2c40('0x41')](get_open_tabs(_0x2c40('0x48'),_0x2707bd['dataValues']));_0x8515e2[_0x2c40('0x41')](get_open_tabs(_0x2c40('0x4e'),_0x2707bd[_0x2c40('0x44')]));_0x8515e2[_0x2c40('0x41')](get_open_tabs(_0x2c40('0x46'),_0x2707bd['dataValues']));_0x8515e2[_0x2c40('0x41')](get_open_tabs(_0x2c40('0x47'),_0x2707bd[_0x2c40('0x44')]));return Promise['all'](_0x8515e2);})[_0x2c40('0x1d')](function(_0x2b7c1f){if(_0x2b7c1f){var _0x8d3678=_[_0x2c40('0x32')](values[_0x2c40('0xb2')],function(_0xfe90ae){return{'channel':'CHAT','id':_0xfe90ae['id'],'createdAt':_0xfe90ae[_0x2c40('0xb3')]};});var _0x373604=_[_0x2c40('0x32')](values['FaxOpenTabs'],function(_0x2f6979){return{'channel':_0x2c40('0xb4'),'id':_0x2f6979['id'],'createdAt':_0x2f6979[_0x2c40('0xb3')]};});var _0x3e6120=_['map'](values[_0x2c40('0xb5')],function(_0x21bc55){return{'channel':_0x2c40('0xb6'),'id':_0x21bc55['id'],'createdAt':_0x21bc55['createdAt']};});var _0x43c11e=_['map'](values[_0x2c40('0xb7')],function(_0x21307e){return{'channel':_0x2c40('0xb8'),'id':_0x21307e['id'],'createdAt':_0x21307e[_0x2c40('0xb3')]};});var _0x1a158b=_[_0x2c40('0x32')](values[_0x2c40('0xb9')],function(_0x5bd620){return{'channel':_0x2c40('0xba'),'id':_0x5bd620['id'],'createdAt':_0x5bd620[_0x2c40('0xb3')]};});var _0x2954b0=_[_0x2c40('0x32')](values[_0x2c40('0xbb')],function(_0xe48020){return{'channel':_0x2c40('0xbc'),'id':_0xe48020['id'],'createdAt':_0xe48020[_0x2c40('0xb3')]};});var _0x3c8b63=_['concat'](_0x8d3678,_0x373604,_0x3e6120,_0x43c11e,_0x1a158b,_0x2954b0);var _0x4c3d28={'count':_0x3c8b63[_0x2c40('0x5f')],'rows':_0x3c8b63};return _0x4c3d28;}else return null;})[_0x2c40('0x1d')](respondWithResult(_0x1481e4,null))[_0x2c40('0x4a')](handleError(_0x1481e4,null));};exports['getContacts']=function(_0x2b016e,_0x5620eb){var _0x12c43a={};return db[_0x2c40('0x31')][_0x2c40('0x8b')]({'where':{'id':_0x2b016e[_0x2c40('0x4c')]['id']}})[_0x2c40('0x1d')](function(_0x13b755){if(!_0x13b755){throw new APINotFoundError(util['format'](_0x2c40('0xbd'),_0x2b016e[_0x2c40('0x4c')]['id']));}return contacts['describe']();})[_0x2c40('0x1d')](function(_0x1927e6){_0x2b016e[_0x2c40('0x3a')][_0x2c40('0x31')]=_0x2b016e[_0x2c40('0x4c')]['id'];_0x12c43a=qs[_0x2c40('0x38')](_0x1927e6,_0x2b016e);if(_0x2b016e[_0x2c40('0x3a')]['hasOwnProperty']('includeAll')){_0x12c43a[_0x2c40('0x3c')]=[{'model':db['CmList'],'as':_0x2c40('0xbe'),'required':![]},{'model':db['Tag'],'as':_0x2c40('0xbf'),'attributes':['id',_0x2c40('0x2f'),_0x2c40('0xc0')],'where':_0x2b016e[_0x2c40('0x3a')][_0x2c40('0xc1')]?{'id':_0x2b016e[_0x2c40('0x3a')][_0x2c40('0xc1')]}:undefined,'required':_0x2b016e[_0x2c40('0x3a')]['tag']?!![]:![]}];}return contacts['findAll'](_0x2b016e[_0x2c40('0x3a')],_0x2b016e[_0x2c40('0x75')],_0x12c43a,_0x1927e6);})['then'](respondWithFilteredResult(_0x5620eb,_0x12c43a))[_0x2c40('0x4a')](APIHandleError(_0x5620eb));};exports['getQueues']=function(_0x4a41f1,_0x439d97){var _0x3b33c2;var _0x106f7d={};var _0x43cf35;return db['User']['findOne']({'where':{'id':_0x4a41f1[_0x2c40('0x4c')]['id']},'attributes':['id',_0x2c40('0x2f'),_0x2c40('0x22')]})[_0x2c40('0x1d')](handleEntityNotFound(_0x439d97,null))['then'](function(_0x34bebe){if(!utils[_0x2c40('0x97')](_0x4a41f1[_0x2c40('0x3a')][_0x2c40('0xa3')])){throw new db[(_0x2c40('0x88'))][(_0x2c40('0x85'))]('Unknown\x20channel');}_0x3b33c2=_0x34bebe;var _0x3ef36f={};_0x3ef36f[_0x2c40('0xc2')]=_['keys'](db[_['capitalize'](_0x4a41f1[_0x2c40('0x3a')][_0x2c40('0xa3')])+_0x2c40('0xc3')][_0x2c40('0xc4')]);_0x3ef36f[_0x2c40('0x3a')]=_[_0x2c40('0xc5')](_0x4a41f1[_0x2c40('0x3a')]);_0x3ef36f[_0x2c40('0xc6')]=_[_0x2c40('0xc7')](_0x3ef36f[_0x2c40('0xc2')],_0x3ef36f['query']);_0x106f7d[_0x2c40('0x40')]=_['intersection'](_0x3ef36f[_0x2c40('0xc2')],qs[_0x2c40('0xc8')](_0x4a41f1[_0x2c40('0x3a')][_0x2c40('0xc8')]));_0x106f7d[_0x2c40('0x40')]=_0x106f7d[_0x2c40('0x40')]['length']?_0x106f7d[_0x2c40('0x40')]:_0x3ef36f[_0x2c40('0xc2')];_0x106f7d['order']=qs[_0x2c40('0xc9')](_0x4a41f1[_0x2c40('0x3a')][_0x2c40('0xc9')]);_0x106f7d['where']=qs[_0x2c40('0xc6')](_[_0x2c40('0xca')](_0x4a41f1[_0x2c40('0x3a')],_0x3ef36f[_0x2c40('0xc6')]));if(_0x4a41f1['query'][_0x2c40('0x28')]){_0x106f7d[_0x2c40('0x39')]=_[_0x2c40('0xcb')](_0x106f7d[_0x2c40('0x39')],{'$or':_[_0x2c40('0x32')](_0x106f7d[_0x2c40('0x40')],function(_0x19801d){var _0x125f9f={};_0x125f9f[_0x19801d]={'$like':'%'+_0x4a41f1[_0x2c40('0x3a')][_0x2c40('0x28')]+'%'};return _0x125f9f;})});}_0x106f7d=_['merge']({},_0x106f7d,_0x4a41f1[_0x2c40('0x4d')]);switch(_0x3b33c2[_0x2c40('0x22')]){case _0x2c40('0x23'):return db[_[_0x2c40('0x99')](_0x4a41f1[_0x2c40('0x3a')][_0x2c40('0xa3')])+'Queue'][_0x2c40('0x42')](_0x106f7d);case _0x2c40('0x75'):case'agent':return _0x3b33c2['get'+_[_0x2c40('0x99')](_0x4a41f1[_0x2c40('0x3a')]['channel'])+'Queues'](_0x106f7d);default:throw new db[(_0x2c40('0x88'))][(_0x2c40('0x85'))](_0x2c40('0xcc'));}})[_0x2c40('0x1d')](function(_0x630e4){_0x43cf35=_0x630e4[_0x2c40('0x5f')];if(!_0x4a41f1['query'][_0x2c40('0xcd')](_0x2c40('0xce'))){_0x106f7d['limit']=qs['limit'](_0x4a41f1[_0x2c40('0x3a')][_0x2c40('0x19')]);_0x106f7d[_0x2c40('0x17')]=qs[_0x2c40('0x17')](_0x4a41f1[_0x2c40('0x3a')][_0x2c40('0x17')]);}switch(_0x3b33c2[_0x2c40('0x22')]){case'admin':return db[_[_0x2c40('0x99')](_0x4a41f1[_0x2c40('0x3a')][_0x2c40('0xa3')])+'Queue'][_0x2c40('0x42')](_0x106f7d);case _0x2c40('0x75'):case _0x2c40('0x1e'):return _0x3b33c2[_0x2c40('0x21')+_['capitalize'](_0x4a41f1[_0x2c40('0x3a')]['channel'])+_0x2c40('0xa4')](_0x106f7d);}})[_0x2c40('0x1d')](function(_0x3895a2){return{'count':_0x43cf35,'rows':_0x3895a2};})[_0x2c40('0x1d')](respondWithResult(_0x439d97,null))[_0x2c40('0x4a')](handleError(_0x439d97,null));};exports['getVoiceQueuesRt']=function(_0x2f0f7a,_0x213ac8){var _0x25a307={};var _0x36d429={};var _0x74f185;var _0x2b43af;return db['User'][_0x2c40('0x8b')]({'where':{'id':_0x2f0f7a[_0x2c40('0x4c')]['id']}})[_0x2c40('0x1d')](handleEntityNotFound(_0x213ac8,null))[_0x2c40('0x1d')](function(_0x35cf93){if(_0x35cf93){_0x74f185=_0x35cf93;_0x36d429[_0x2c40('0xc2')]=_['keys'](db[_0x2c40('0xa1')]['rawAttributes']);_0x36d429[_0x2c40('0x3a')]=_['keys'](_0x2f0f7a['query']);_0x36d429[_0x2c40('0xc6')]=_['intersection'](_0x36d429[_0x2c40('0xc2')],_0x36d429[_0x2c40('0x3a')]);_0x25a307[_0x2c40('0x40')]=_[_0x2c40('0xc7')](_0x36d429['model'],qs['fields'](_0x2f0f7a['query']['fields']));_0x25a307[_0x2c40('0x40')]=_0x25a307[_0x2c40('0x40')]['length']?_0x25a307[_0x2c40('0x40')]:_0x36d429[_0x2c40('0xc2')];_0x25a307[_0x2c40('0xcf')]=qs[_0x2c40('0xc9')](_0x2f0f7a[_0x2c40('0x3a')][_0x2c40('0xc9')]);_0x25a307['where']=qs[_0x2c40('0xc6')](_[_0x2c40('0xca')](_0x2f0f7a['query'],_0x36d429[_0x2c40('0xc6')]));if(_0x2f0f7a['query'][_0x2c40('0x28')]){_0x25a307[_0x2c40('0x39')]=_[_0x2c40('0xcb')](_0x25a307[_0x2c40('0x39')],{'$or':_[_0x2c40('0x32')](_0x25a307[_0x2c40('0x40')],function(_0x199e9e){var _0x2c7de8={};_0x2c7de8[_0x199e9e]={'$like':'%'+_0x2f0f7a['query']['filter']+'%'};return _0x2c7de8;})});}_0x25a307=_['merge']({},_0x25a307,_0x2f0f7a['options']);return _0x74f185['getVoiceQueuesRt'](_0x25a307);}})[_0x2c40('0x1d')](function(_0x2a493c){if(_0x2a493c){_0x2b43af=_0x2a493c[_0x2c40('0x5f')];if(!_0x2f0f7a['query'][_0x2c40('0xcd')](_0x2c40('0xce'))){_0x25a307[_0x2c40('0x19')]=qs[_0x2c40('0x19')](_0x2f0f7a[_0x2c40('0x3a')][_0x2c40('0x19')]);_0x25a307[_0x2c40('0x17')]=qs[_0x2c40('0x17')](_0x2f0f7a['query'][_0x2c40('0x17')]);}return _0x74f185[_0x2c40('0xd0')](_0x25a307);}})[_0x2c40('0x1d')](function(_0x581c90){if(_0x581c90){return _0x581c90?{'count':_0x2b43af,'rows':_0x581c90}:null;}})['then'](respondWithResult(_0x213ac8,null))[_0x2c40('0x4a')](handleError(_0x213ac8,null));};exports['getGroups']=function(_0x55812e,_0xe2908a){var _0x1b07a6={};var _0x36989a={};var _0x1db9ba;var _0x966774;return db[_0x2c40('0x31')][_0x2c40('0x8b')]({'where':{'id':_0x55812e['params']['id']}})['then'](handleEntityNotFound(_0xe2908a,null))['then'](function(_0x5378ee){if(_0x5378ee){_0x1db9ba=_0x5378ee;_0x36989a[_0x2c40('0xc2')]=_['keys'](db[_0x2c40('0xd1')][_0x2c40('0xc4')]);_0x36989a[_0x2c40('0x3a')]=_[_0x2c40('0xc5')](_0x55812e[_0x2c40('0x3a')]);_0x36989a[_0x2c40('0xc6')]=_[_0x2c40('0xc7')](_0x36989a['model'],_0x36989a[_0x2c40('0x3a')]);_0x1b07a6['attributes']=_[_0x2c40('0xc7')](_0x36989a[_0x2c40('0xc2')],qs[_0x2c40('0xc8')](_0x55812e[_0x2c40('0x3a')]['fields']));_0x1b07a6['attributes']=_0x1b07a6[_0x2c40('0x40')][_0x2c40('0x5f')]?_0x1b07a6[_0x2c40('0x40')]:_0x36989a[_0x2c40('0xc2')];_0x1b07a6['order']=qs[_0x2c40('0xc9')](_0x55812e[_0x2c40('0x3a')]['sort']);_0x1b07a6[_0x2c40('0x39')]=qs['filters'](_[_0x2c40('0xca')](_0x55812e[_0x2c40('0x3a')],_0x36989a[_0x2c40('0xc6')]));if(_0x55812e[_0x2c40('0x3a')][_0x2c40('0x28')]){_0x1b07a6[_0x2c40('0x39')]=_['merge'](_0x1b07a6['where'],{'$or':_['map'](_0x1b07a6[_0x2c40('0x40')],function(_0x111c14){var _0x281a41={};_0x281a41[_0x111c14]={'$like':'%'+_0x55812e[_0x2c40('0x3a')][_0x2c40('0x28')]+'%'};return _0x281a41;})});}_0x1b07a6=_[_0x2c40('0xcb')]({},_0x1b07a6,_0x55812e[_0x2c40('0x4d')]);return _0x1db9ba[_0x2c40('0xd2')](_0x1b07a6);}})[_0x2c40('0x1d')](function(_0x37596d){if(_0x37596d){_0x966774=_0x37596d['length'];if(!_0x55812e[_0x2c40('0x3a')]['hasOwnProperty']('nolimit')){_0x1b07a6[_0x2c40('0x19')]=qs[_0x2c40('0x19')](_0x55812e[_0x2c40('0x3a')][_0x2c40('0x19')]);_0x1b07a6[_0x2c40('0x17')]=qs[_0x2c40('0x17')](_0x55812e[_0x2c40('0x3a')][_0x2c40('0x17')]);}return _0x1db9ba[_0x2c40('0xd2')](_0x1b07a6);}})[_0x2c40('0x1d')](function(_0x15ef28){if(_0x15ef28){return _0x15ef28?{'count':_0x966774,'rows':_0x15ef28}:null;}})[_0x2c40('0x1d')](respondWithResult(_0xe2908a,null))['catch'](handleError(_0xe2908a,null));};exports[_0x2c40('0xd3')]=function(_0x44c742,_0x4bb9ab){var _0x3caa4c={'raw':!![],'where':{}};var _0x474bb6={};var _0x725bf2={'count':0x0,'rows':[]};return db['User'][_0x2c40('0x8b')]({'where':{'id':_0x44c742[_0x2c40('0x4c')]['id']}})[_0x2c40('0x1d')](handleEntityNotFound(_0x4bb9ab,null))[_0x2c40('0x1d')](function(_0x28e641){if(_0x28e641){_0x474bb6[_0x2c40('0xc2')]=_[_0x2c40('0xc5')](db[_0x2c40('0xd4')][_0x2c40('0xc4')]);_0x474bb6[_0x2c40('0x3a')]=_[_0x2c40('0xc5')](_0x44c742[_0x2c40('0x3a')]);_0x474bb6[_0x2c40('0xc6')]=_[_0x2c40('0xc7')](_0x474bb6[_0x2c40('0xc2')],_0x474bb6[_0x2c40('0x3a')]);_0x3caa4c[_0x2c40('0x40')]=_[_0x2c40('0xc7')](_0x474bb6[_0x2c40('0xc2')],qs['fields'](_0x44c742[_0x2c40('0x3a')][_0x2c40('0xc8')]));_0x3caa4c[_0x2c40('0x40')]=_0x3caa4c['attributes']['length']?_0x3caa4c[_0x2c40('0x40')]:_0x474bb6[_0x2c40('0xc2')];if(!_0x44c742['query'][_0x2c40('0xcd')](_0x2c40('0xce'))){_0x3caa4c[_0x2c40('0x19')]=qs['limit'](_0x44c742[_0x2c40('0x3a')][_0x2c40('0x19')]);_0x3caa4c[_0x2c40('0x17')]=qs[_0x2c40('0x17')](_0x44c742['query'][_0x2c40('0x17')]);}_0x3caa4c[_0x2c40('0xcf')]=qs[_0x2c40('0xc9')](_0x44c742['query'][_0x2c40('0xc9')]);_0x3caa4c['where']=qs['filters'](_[_0x2c40('0xca')](_0x44c742['query'],_0x474bb6['filters']));_0x3caa4c[_0x2c40('0x39')][_0x2c40('0xd5')]=_0x28e641['id'];if(_0x44c742['query'][_0x2c40('0x28')]){_0x3caa4c[_0x2c40('0x39')]=_[_0x2c40('0xcb')](_0x3caa4c[_0x2c40('0x39')],{'$or':_[_0x2c40('0x32')](_0x3caa4c[_0x2c40('0x40')],function(_0x5a928c){var _0x3ead25={};_0x3ead25[_0x5a928c]={'$like':'%'+_0x44c742['query'][_0x2c40('0x28')]+'%'};return _0x3ead25;})});}_0x3caa4c=_[_0x2c40('0xcb')]({},_0x3caa4c,_0x44c742[_0x2c40('0x4d')]);return db[_0x2c40('0xd4')]['count']({'where':_0x3caa4c[_0x2c40('0x39')]})['then'](function(_0x2977f0){_0x725bf2[_0x2c40('0x1a')]=_0x2977f0;if(_0x44c742['query']['includeAll']){_0x3caa4c[_0x2c40('0x3c')]=[{'all':!![]}];}return db[_0x2c40('0xd4')][_0x2c40('0x42')](_0x3caa4c);})[_0x2c40('0x1d')](function(_0x5d6aa0){_0x725bf2[_0x2c40('0x43')]=_0x5d6aa0;return _0x725bf2;});}})['then'](respondWithFilteredResult(_0x4bb9ab,_0x3caa4c))['catch'](handleError(_0x4bb9ab,null));};exports[_0x2c40('0xd6')]=function(_0x45ab54,_0x5e837f){var _0x5d38f8={'raw':!![],'where':{}};var _0x4d4952={};var _0x9b9e4e={'count':0x0,'rows':[]};return db[_0x2c40('0x31')][_0x2c40('0x8b')]({'where':{'id':_0x45ab54['params']['id']}})[_0x2c40('0x1d')](handleEntityNotFound(_0x5e837f,null))[_0x2c40('0x1d')](function(_0x4a3820){if(_0x4a3820){_0x4d4952['model']=_[_0x2c40('0xc5')](db[_0x2c40('0xd7')][_0x2c40('0xc4')]);_0x4d4952[_0x2c40('0x3a')]=_['keys'](_0x45ab54[_0x2c40('0x3a')]);_0x4d4952['filters']=_['intersection'](_0x4d4952[_0x2c40('0xc2')],_0x4d4952[_0x2c40('0x3a')]);_0x5d38f8[_0x2c40('0x40')]=_[_0x2c40('0xc7')](_0x4d4952['model'],qs[_0x2c40('0xc8')](_0x45ab54[_0x2c40('0x3a')][_0x2c40('0xc8')]));_0x5d38f8[_0x2c40('0x40')]=_0x5d38f8['attributes'][_0x2c40('0x5f')]?_0x5d38f8[_0x2c40('0x40')]:_0x4d4952[_0x2c40('0xc2')];if(!_0x45ab54[_0x2c40('0x3a')]['hasOwnProperty'](_0x2c40('0xce'))){_0x5d38f8[_0x2c40('0x19')]=qs[_0x2c40('0x19')](_0x45ab54[_0x2c40('0x3a')][_0x2c40('0x19')]);_0x5d38f8['offset']=qs['offset'](_0x45ab54[_0x2c40('0x3a')][_0x2c40('0x17')]);}_0x5d38f8['order']=qs[_0x2c40('0xc9')](_0x45ab54[_0x2c40('0x3a')][_0x2c40('0xc9')]);_0x5d38f8[_0x2c40('0x39')]=qs[_0x2c40('0xc6')](_[_0x2c40('0xca')](_0x45ab54[_0x2c40('0x3a')],_0x4d4952['filters']));_0x5d38f8[_0x2c40('0x39')][_0x2c40('0xd5')]=_0x4a3820['id'];if(_0x45ab54[_0x2c40('0x3a')]['filter']){_0x5d38f8[_0x2c40('0x39')]=_[_0x2c40('0xcb')](_0x5d38f8['where'],{'$or':_['map'](_0x5d38f8[_0x2c40('0x40')],function(_0x17a478){var _0x4c11a8={};_0x4c11a8[_0x17a478]={'$like':'%'+_0x45ab54[_0x2c40('0x3a')][_0x2c40('0x28')]+'%'};return _0x4c11a8;})});}_0x5d38f8=_[_0x2c40('0xcb')]({},_0x5d38f8,_0x45ab54['options']);return db[_0x2c40('0xd7')][_0x2c40('0x1a')]({'where':_0x5d38f8['where']})[_0x2c40('0x1d')](function(_0x49384c){_0x9b9e4e[_0x2c40('0x1a')]=_0x49384c;if(_0x45ab54[_0x2c40('0x3a')]['includeAll']){_0x5d38f8[_0x2c40('0x3c')]=[{'all':!![]}];}return db[_0x2c40('0xd7')]['findAll'](_0x5d38f8);})[_0x2c40('0x1d')](function(_0x287c70){_0x9b9e4e[_0x2c40('0x43')]=_0x287c70;return _0x9b9e4e;});}})['then'](respondWithFilteredResult(_0x5e837f,_0x5d38f8))['catch'](handleError(_0x5e837f,null));};exports[_0x2c40('0xd8')]=function(_0x12a5f4,_0x518fc7){var _0xc27969={};var _0x518db2={};var _0x1b3bb5;var _0x5bcef9;return db[_0x2c40('0x31')][_0x2c40('0x8b')]({'where':{'id':_0x12a5f4[_0x2c40('0x4c')]['id']}})[_0x2c40('0x1d')](handleEntityNotFound(_0x518fc7,null))['then'](function(_0x404f78){if(_0x404f78){_0x1b3bb5=_0x404f78;_0x518db2[_0x2c40('0xc2')]=_[_0x2c40('0xc5')](db['ChatInteraction']['rawAttributes']);_0x518db2[_0x2c40('0x3a')]=_['keys'](_0x12a5f4[_0x2c40('0x3a')]);_0x518db2[_0x2c40('0xc6')]=_[_0x2c40('0xc7')](_0x518db2[_0x2c40('0xc2')],_0x518db2[_0x2c40('0x3a')]);_0xc27969[_0x2c40('0x40')]=_[_0x2c40('0xc7')](_0x518db2[_0x2c40('0xc2')],qs[_0x2c40('0xc8')](_0x12a5f4[_0x2c40('0x3a')][_0x2c40('0xc8')]));_0xc27969[_0x2c40('0x40')]=_0xc27969[_0x2c40('0x40')][_0x2c40('0x5f')]?_0xc27969[_0x2c40('0x40')]:_0x518db2['model'];_0xc27969[_0x2c40('0xcf')]=qs[_0x2c40('0xc9')](_0x12a5f4[_0x2c40('0x3a')][_0x2c40('0xc9')]);_0xc27969['where']=qs[_0x2c40('0xc6')](_[_0x2c40('0xca')](_0x12a5f4['query'],_0x518db2['filters']));if(_0x12a5f4['query'][_0x2c40('0x28')]){_0xc27969[_0x2c40('0x39')]=_[_0x2c40('0xcb')](_0xc27969['where'],{'$or':_[_0x2c40('0x32')](_0xc27969[_0x2c40('0x40')],function(_0x203809){var _0x20478b={};_0x20478b[_0x203809]={'$like':'%'+_0x12a5f4[_0x2c40('0x3a')][_0x2c40('0x28')]+'%'};return _0x20478b;})});}_0xc27969=_[_0x2c40('0xcb')]({},_0xc27969,_0x12a5f4[_0x2c40('0x4d')]);return _0x1b3bb5[_0x2c40('0xd8')](_0xc27969);}})[_0x2c40('0x1d')](function(_0x52e1d2){if(_0x52e1d2){_0x5bcef9=_0x52e1d2[_0x2c40('0x5f')];if(!_0x12a5f4[_0x2c40('0x3a')][_0x2c40('0xcd')](_0x2c40('0xce'))){_0xc27969[_0x2c40('0x19')]=qs[_0x2c40('0x19')](_0x12a5f4[_0x2c40('0x3a')]['limit']);_0xc27969[_0x2c40('0x17')]=qs[_0x2c40('0x17')](_0x12a5f4['query'][_0x2c40('0x17')]);}return _0x1b3bb5[_0x2c40('0xd8')](_0xc27969);}})[_0x2c40('0x1d')](function(_0x825013){if(_0x825013){return _0x825013?{'count':_0x5bcef9,'rows':_0x825013}:null;}})[_0x2c40('0x1d')](respondWithResult(_0x518fc7,null))[_0x2c40('0x4a')](handleError(_0x518fc7,null));};exports[_0x2c40('0xd9')]=function(_0x505bc4,_0x4346a2){var _0x3b0be5={};var _0x11f37c={};var _0x4c7983;var _0x39ac39;return db['User'][_0x2c40('0x8b')]({'where':{'id':_0x505bc4[_0x2c40('0x4c')]['id']}})[_0x2c40('0x1d')](handleEntityNotFound(_0x4346a2,null))[_0x2c40('0x1d')](function(_0x2f7389){if(_0x2f7389){_0x4c7983=_0x2f7389;_0x11f37c[_0x2c40('0xc2')]=_['keys'](db[_0x2c40('0xda')]['rawAttributes']);_0x11f37c[_0x2c40('0x3a')]=_[_0x2c40('0xc5')](_0x505bc4['query']);_0x11f37c[_0x2c40('0xc6')]=_[_0x2c40('0xc7')](_0x11f37c[_0x2c40('0xc2')],_0x11f37c[_0x2c40('0x3a')]);_0x3b0be5[_0x2c40('0x40')]=_['intersection'](_0x11f37c[_0x2c40('0xc2')],qs[_0x2c40('0xc8')](_0x505bc4[_0x2c40('0x3a')][_0x2c40('0xc8')]));_0x3b0be5[_0x2c40('0x40')]=_0x3b0be5['attributes'][_0x2c40('0x5f')]?_0x3b0be5[_0x2c40('0x40')]:_0x11f37c[_0x2c40('0xc2')];_0x3b0be5[_0x2c40('0xcf')]=qs[_0x2c40('0xc9')](_0x505bc4['query'][_0x2c40('0xc9')]);_0x3b0be5['where']=qs[_0x2c40('0xc6')](_['pick'](_0x505bc4[_0x2c40('0x3a')],_0x11f37c[_0x2c40('0xc6')]));if(_0x505bc4[_0x2c40('0x3a')][_0x2c40('0x28')]){_0x3b0be5[_0x2c40('0x39')]=_[_0x2c40('0xcb')](_0x3b0be5['where'],{'$or':_[_0x2c40('0x32')](_0x3b0be5[_0x2c40('0x40')],function(_0x31c1a6){var _0x3f7ff8={};_0x3f7ff8[_0x31c1a6]={'$like':'%'+_0x505bc4['query'][_0x2c40('0x28')]+'%'};return _0x3f7ff8;})});}_0x3b0be5=_[_0x2c40('0xcb')]({},_0x3b0be5,_0x505bc4[_0x2c40('0x4d')]);return _0x4c7983[_0x2c40('0xd9')](_0x3b0be5);}})[_0x2c40('0x1d')](function(_0x1bd54e){if(_0x1bd54e){_0x39ac39=_0x1bd54e['length'];if(!_0x505bc4[_0x2c40('0x3a')][_0x2c40('0xcd')](_0x2c40('0xce'))){_0x3b0be5[_0x2c40('0x19')]=qs['limit'](_0x505bc4[_0x2c40('0x3a')]['limit']);_0x3b0be5[_0x2c40('0x17')]=qs[_0x2c40('0x17')](_0x505bc4[_0x2c40('0x3a')][_0x2c40('0x17')]);}return _0x4c7983['getOpenchannelInteractions'](_0x3b0be5);}})['then'](function(_0x52f5ea){if(_0x52f5ea){return _0x52f5ea?{'count':_0x39ac39,'rows':_0x52f5ea}:null;}})[_0x2c40('0x1d')](respondWithResult(_0x4346a2,null))[_0x2c40('0x4a')](handleError(_0x4346a2,null));};exports[_0x2c40('0xdb')]=function(_0x4b61bc,_0x1e394b){var _0x137d78={'raw':!![],'where':{}};var _0x1aa16c={};var _0x493320={'count':0x0,'rows':[]};return db['User']['findOne']({'where':{'id':_0x4b61bc['params']['id']}})[_0x2c40('0x1d')](handleEntityNotFound(_0x1e394b,null))[_0x2c40('0x1d')](function(_0xabaaad){if(_0xabaaad){_0x1aa16c['model']=_[_0x2c40('0xc5')](db[_0x2c40('0xdc')][_0x2c40('0xc4')]);_0x1aa16c[_0x2c40('0x3a')]=_[_0x2c40('0xc5')](_0x4b61bc[_0x2c40('0x3a')]);_0x1aa16c['filters']=_[_0x2c40('0xc7')](_0x1aa16c[_0x2c40('0xc2')],_0x1aa16c[_0x2c40('0x3a')]);_0x137d78['attributes']=_[_0x2c40('0xc7')](_0x1aa16c['model'],qs['fields'](_0x4b61bc[_0x2c40('0x3a')][_0x2c40('0xc8')]));_0x137d78['attributes']=_0x137d78[_0x2c40('0x40')][_0x2c40('0x5f')]?_0x137d78[_0x2c40('0x40')]:_0x1aa16c[_0x2c40('0xc2')];if(!_0x4b61bc[_0x2c40('0x3a')][_0x2c40('0xcd')]('nolimit')){_0x137d78['limit']=qs['limit'](_0x4b61bc[_0x2c40('0x3a')][_0x2c40('0x19')]);_0x137d78[_0x2c40('0x17')]=qs[_0x2c40('0x17')](_0x4b61bc[_0x2c40('0x3a')]['offset']);}_0x137d78[_0x2c40('0xcf')]=qs['sort'](_0x4b61bc['query'][_0x2c40('0xc9')]);_0x137d78['where']=qs[_0x2c40('0xc6')](_[_0x2c40('0xca')](_0x4b61bc[_0x2c40('0x3a')],_0x1aa16c[_0x2c40('0xc6')]));_0x137d78[_0x2c40('0x39')][_0x2c40('0xd5')]=_0xabaaad['id'];if(_0x4b61bc[_0x2c40('0x3a')][_0x2c40('0x28')]){_0x137d78[_0x2c40('0x39')]=_['merge'](_0x137d78[_0x2c40('0x39')],{'$or':_[_0x2c40('0x32')](_0x137d78['attributes'],function(_0x68c2a9){var _0x22a0da={};_0x22a0da[_0x68c2a9]={'$like':'%'+_0x4b61bc[_0x2c40('0x3a')][_0x2c40('0x28')]+'%'};return _0x22a0da;})});}_0x137d78=_['merge']({},_0x137d78,_0x4b61bc[_0x2c40('0x4d')]);return db[_0x2c40('0xdc')][_0x2c40('0x1a')]({'where':_0x137d78['where']})[_0x2c40('0x1d')](function(_0x4e04d1){_0x493320[_0x2c40('0x1a')]=_0x4e04d1;if(_0x4b61bc[_0x2c40('0x3a')][_0x2c40('0x3b')]){_0x137d78['include']=[{'all':!![]}];}return db['MailInteraction'][_0x2c40('0x42')](_0x137d78);})[_0x2c40('0x1d')](function(_0x5b0f48){_0x493320[_0x2c40('0x43')]=_0x5b0f48;return _0x493320;});}})[_0x2c40('0x1d')](respondWithFilteredResult(_0x1e394b,_0x137d78))[_0x2c40('0x4a')](handleError(_0x1e394b,null));};exports[_0x2c40('0xdd')]=function(_0x544e9b,_0xf76ae7){var _0xfee44e={};var _0x36de11={};var _0x148b4c;var _0x410fa6;return db[_0x2c40('0x31')][_0x2c40('0x8b')]({'where':{'id':_0x544e9b[_0x2c40('0x4c')]['id']}})['then'](handleEntityNotFound(_0xf76ae7,null))[_0x2c40('0x1d')](function(_0x27b65c){if(_0x27b65c){_0x148b4c=_0x27b65c;_0x36de11[_0x2c40('0xc2')]=_[_0x2c40('0xc5')](db[_0x2c40('0xde')]['rawAttributes']);_0x36de11[_0x2c40('0x3a')]=_[_0x2c40('0xc5')](_0x544e9b['query']);_0x36de11[_0x2c40('0xc6')]=_[_0x2c40('0xc7')](_0x36de11[_0x2c40('0xc2')],_0x36de11[_0x2c40('0x3a')]);_0xfee44e['attributes']=_[_0x2c40('0xc7')](_0x36de11[_0x2c40('0xc2')],qs[_0x2c40('0xc8')](_0x544e9b['query'][_0x2c40('0xc8')]));_0xfee44e['attributes']=_0xfee44e[_0x2c40('0x40')][_0x2c40('0x5f')]?_0xfee44e[_0x2c40('0x40')]:_0x36de11[_0x2c40('0xc2')];_0xfee44e[_0x2c40('0xcf')]=qs[_0x2c40('0xc9')](_0x544e9b['query']['sort']);_0xfee44e[_0x2c40('0x39')]=qs[_0x2c40('0xc6')](_[_0x2c40('0xca')](_0x544e9b[_0x2c40('0x3a')],_0x36de11[_0x2c40('0xc6')]));if(_0x544e9b[_0x2c40('0x3a')][_0x2c40('0x28')]){_0xfee44e['where']=_['merge'](_0xfee44e[_0x2c40('0x39')],{'$or':_[_0x2c40('0x32')](_0xfee44e['attributes'],function(_0x521b4a){var _0x50ff8d={};_0x50ff8d[_0x521b4a]={'$like':'%'+_0x544e9b[_0x2c40('0x3a')][_0x2c40('0x28')]+'%'};return _0x50ff8d;})});}_0xfee44e=_['merge']({},_0xfee44e,_0x544e9b[_0x2c40('0x4d')]);return _0x148b4c[_0x2c40('0xdd')](_0xfee44e);}})[_0x2c40('0x1d')](function(_0x31c607){if(_0x31c607){_0x410fa6=_0x31c607['length'];if(!_0x544e9b[_0x2c40('0x3a')][_0x2c40('0xcd')](_0x2c40('0xce'))){_0xfee44e['limit']=qs[_0x2c40('0x19')](_0x544e9b['query'][_0x2c40('0x19')]);_0xfee44e[_0x2c40('0x17')]=qs[_0x2c40('0x17')](_0x544e9b[_0x2c40('0x3a')][_0x2c40('0x17')]);}return _0x148b4c['getSmsInteractions'](_0xfee44e);}})['then'](function(_0x47bc21){if(_0x47bc21){return _0x47bc21?{'count':_0x410fa6,'rows':_0x47bc21}:null;}})['then'](respondWithResult(_0xf76ae7,null))[_0x2c40('0x4a')](handleError(_0xf76ae7,null));};exports[_0x2c40('0xdf')]=function(_0x254ee8,_0x5b05da){var _0x4941ea={};var _0x27e781={};var _0x58a7f2;var _0x31a817;return db[_0x2c40('0x31')]['findOne']({'where':{'id':_0x254ee8[_0x2c40('0x4c')]['id']}})[_0x2c40('0x1d')](handleEntityNotFound(_0x5b05da,null))['then'](function(_0x10c517){if(_0x10c517){_0x58a7f2=_0x10c517;_0x27e781[_0x2c40('0xc2')]=_[_0x2c40('0xc5')](db['FaxInteraction'][_0x2c40('0xc4')]);_0x27e781[_0x2c40('0x3a')]=_[_0x2c40('0xc5')](_0x254ee8['query']);_0x27e781[_0x2c40('0xc6')]=_['intersection'](_0x27e781[_0x2c40('0xc2')],_0x27e781[_0x2c40('0x3a')]);_0x4941ea['attributes']=_[_0x2c40('0xc7')](_0x27e781[_0x2c40('0xc2')],qs['fields'](_0x254ee8['query']['fields']));_0x4941ea[_0x2c40('0x40')]=_0x4941ea[_0x2c40('0x40')][_0x2c40('0x5f')]?_0x4941ea[_0x2c40('0x40')]:_0x27e781['model'];_0x4941ea[_0x2c40('0xcf')]=qs['sort'](_0x254ee8[_0x2c40('0x3a')][_0x2c40('0xc9')]);_0x4941ea[_0x2c40('0x39')]=qs['filters'](_[_0x2c40('0xca')](_0x254ee8[_0x2c40('0x3a')],_0x27e781[_0x2c40('0xc6')]));if(_0x254ee8['query'][_0x2c40('0x28')]){_0x4941ea[_0x2c40('0x39')]=_['merge'](_0x4941ea[_0x2c40('0x39')],{'$or':_[_0x2c40('0x32')](_0x4941ea[_0x2c40('0x40')],function(_0x21f405){var _0x3f18e1={};_0x3f18e1[_0x21f405]={'$like':'%'+_0x254ee8[_0x2c40('0x3a')][_0x2c40('0x28')]+'%'};return _0x3f18e1;})});}_0x4941ea=_['merge']({},_0x4941ea,_0x254ee8['options']);return _0x58a7f2['getFaxInteractions'](_0x4941ea);}})[_0x2c40('0x1d')](function(_0x30b39a){if(_0x30b39a){_0x31a817=_0x30b39a['length'];if(!_0x254ee8[_0x2c40('0x3a')][_0x2c40('0xcd')](_0x2c40('0xce'))){_0x4941ea[_0x2c40('0x19')]=qs[_0x2c40('0x19')](_0x254ee8[_0x2c40('0x3a')][_0x2c40('0x19')]);_0x4941ea[_0x2c40('0x17')]=qs[_0x2c40('0x17')](_0x254ee8[_0x2c40('0x3a')]['offset']);}return _0x58a7f2[_0x2c40('0xdf')](_0x4941ea);}})[_0x2c40('0x1d')](function(_0x157ac2){if(_0x157ac2){return _0x157ac2?{'count':_0x31a817,'rows':_0x157ac2}:null;}})[_0x2c40('0x1d')](respondWithResult(_0x5b05da,null))[_0x2c40('0x4a')](handleError(_0x5b05da,null));};exports[_0x2c40('0xe0')]=function(_0x1db2ca,_0x1be1c5){var _0x37c664={};var _0x3b1716={};var _0x31f324;var _0xf0e78;return db[_0x2c40('0x31')][_0x2c40('0x8b')]({'where':{'id':_0x1db2ca[_0x2c40('0x4c')]['id']}})[_0x2c40('0x1d')](handleEntityNotFound(_0x1be1c5,null))['then'](function(_0x48dbb7){if(_0x48dbb7){_0x31f324=_0x48dbb7;_0x3b1716['model']=_[_0x2c40('0xc5')](db[_0x2c40('0xe1')][_0x2c40('0xc4')]);_0x3b1716['query']=_[_0x2c40('0xc5')](_0x1db2ca[_0x2c40('0x3a')]);_0x3b1716[_0x2c40('0xc6')]=_['intersection'](_0x3b1716[_0x2c40('0xc2')],_0x3b1716[_0x2c40('0x3a')]);_0x37c664[_0x2c40('0x40')]=_[_0x2c40('0xc7')](_0x3b1716['model'],qs[_0x2c40('0xc8')](_0x1db2ca[_0x2c40('0x3a')][_0x2c40('0xc8')]));_0x37c664[_0x2c40('0x40')]=_0x37c664[_0x2c40('0x40')][_0x2c40('0x5f')]?_0x37c664[_0x2c40('0x40')]:_0x3b1716[_0x2c40('0xc2')];_0x37c664['order']=qs[_0x2c40('0xc9')](_0x1db2ca['query']['sort']);_0x37c664[_0x2c40('0x39')]=qs['filters'](_[_0x2c40('0xca')](_0x1db2ca['query'],_0x3b1716[_0x2c40('0xc6')]));if(_0x1db2ca['query'][_0x2c40('0x28')]){_0x37c664[_0x2c40('0x39')]=_[_0x2c40('0xcb')](_0x37c664['where'],{'$or':_[_0x2c40('0x32')](_0x37c664[_0x2c40('0x40')],function(_0x4557b7){var _0x283aee={};_0x283aee[_0x4557b7]={'$like':'%'+_0x1db2ca['query']['filter']+'%'};return _0x283aee;})});}_0x37c664=_[_0x2c40('0xcb')]({},_0x37c664,_0x1db2ca[_0x2c40('0x4d')]);return _0x31f324[_0x2c40('0xe0')](_0x37c664);}})[_0x2c40('0x1d')](function(_0x25dd35){if(_0x25dd35){_0xf0e78=_0x25dd35[_0x2c40('0x5f')];if(!_0x1db2ca[_0x2c40('0x3a')][_0x2c40('0xcd')](_0x2c40('0xce'))){_0x37c664[_0x2c40('0x19')]=qs[_0x2c40('0x19')](_0x1db2ca[_0x2c40('0x3a')][_0x2c40('0x19')]);_0x37c664[_0x2c40('0x17')]=qs[_0x2c40('0x17')](_0x1db2ca[_0x2c40('0x3a')]['offset']);}return _0x31f324[_0x2c40('0xe0')](_0x37c664);}})[_0x2c40('0x1d')](function(_0x1b229f){if(_0x1b229f){return _0x1b229f?{'count':_0xf0e78,'rows':_0x1b229f}:null;}})['then'](respondWithResult(_0x1be1c5,null))[_0x2c40('0x4a')](handleError(_0x1be1c5,null));};exports[_0x2c40('0xe2')]=function(_0x3fac56,_0x47b215,_0x276b54){var _0x37c309;var _0x2ecc5f;var _0xbba8e5;var _0x5bd4b7=!_[_0x2c40('0x59')](_0x3fac56['params']['id'])?_0x3fac56['params']['id']:!_['isNil'](_0x3fac56[_0x2c40('0x75')]['id'])?_0x3fac56[_0x2c40('0x75')]['id']:null;return db[_0x2c40('0x31')][_0x2c40('0x2c')]({'where':{'id':_0x5bd4b7,'role':{'$or':[_0x2c40('0x23'),_0x2c40('0x75'),_0x2c40('0x1e')]}},'attributes':['id',_0x2c40('0x2f'),_0x2c40('0xe3'),'mobile','role','internal','loginInPause']})['then'](function(_0x22fb96){if(_0x22fb96){if(_0x22fb96[_0x2c40('0x22')]===_0x2c40('0x1e')){_0x37c309=_0x22fb96;if(_0x3fac56[_0x2c40('0x4f')][_0x2c40('0x96')]){_0xbba8e5=util['format'](_0x2c40('0xe4'),_0x37c309[_0x3fac56[_0x2c40('0x4f')][_0x2c40('0x96')]]);}else if(_0x3fac56[_0x2c40('0x4f')][_0x2c40('0xe5')]){_0xbba8e5=util['format']('SIP/%s',_0x3fac56[_0x2c40('0x4f')][_0x2c40('0xe5')]);}else{_0xbba8e5=util[_0x2c40('0x9f')](_0x2c40('0xa0'),_0x37c309[_0x2c40('0x2f')]);}socket['to'](util[_0x2c40('0x9f')](_0x2c40('0xe6'),_0x37c309[_0x2c40('0x2f')]))[_0x2c40('0x1f')](_0x2c40('0xe7'),{'user':{'id':_0x37c309['id'],'name':_0x37c309[_0x2c40('0x2f')]},'ip':_0x3fac56[_0x2c40('0xe8')][_0x2c40('0xe9')]||_0x3fac56[_0x2c40('0xea')][_0x2c40('0xeb')]||_0x3fac56[_0x2c40('0xec')][_0x2c40('0xeb')]||_0x3fac56['connection'][_0x2c40('0xec')]['remoteAddress']});return db[_0x2c40('0xa1')][_0x2c40('0x20')]({'where':{'membername':_0x37c309[_0x2c40('0x2f')]},'individualHooks':!![]});}}else{throw new db[(_0x2c40('0x88'))][(_0x2c40('0x85'))]('User\x20not\x20found\x20or\x20not\x20allowed\x20to\x20perform\x20login\x20method');}})[_0x2c40('0x1d')](function(){if(_0x37c309){return _0x37c309[_0x2c40('0xed')]({'raw':!![]});}})['then'](function(_0x1bb69a){if(_0x37c309){if(_0x1bb69a){_0x2ecc5f=_0x1bb69a;if(_0x2ecc5f[_0x2c40('0x5f')]){var _0x3baf56=_0x2ecc5f[_0x2c40('0x32')](function(_0x29f37a){var _0x40cb2f={'membername':_0x37c309[_0x2c40('0x2f')],'UserId':_0x37c309['id'],'queue_name':_0x29f37a[_0x2c40('0x2f')],'VoiceQueueId':_0x29f37a['id'],'interface':_0xbba8e5,'paused':_0x37c309[_0x2c40('0x94')]||![],'penalty':_0x29f37a[_0x2c40('0xee')]||0x0};return db[_0x2c40('0xa1')][_0x2c40('0xa2')](_0x40cb2f);});return Promise[_0x2c40('0x49')](_0x3baf56);}}}})['then'](function(){if(_0x37c309){return db[_0x2c40('0xef')][_0x2c40('0x42')]({'where':{'membername':_0x37c309[_0x2c40('0x2f')],'exitAt':null}});}})[_0x2c40('0x1d')](function(_0x1b6091){if(_0x37c309){var _0xe9bff1=[];_0x1b6091['forEach'](function(_0x2c5c3e){_0xe9bff1[_0x2c40('0x41')](_0x2c5c3e[_0x2c40('0x1c')]({'exitAt':moment()[_0x2c40('0x9f')](_0x2c40('0xf0'))}));});return Promise[_0x2c40('0x49')](_0xe9bff1);}})[_0x2c40('0x1d')](function(){if(_0x37c309){var _0x727bc6=[];var _0x53fe97=[];var _0x7448fb=utils['getChannels']();var _0x5e2454={'membername':_0x37c309['name'],'interface':_0xbba8e5,'enterAt':moment()[_0x2c40('0x9f')](_0x2c40('0xf0')),'role':_0x37c309[_0x2c40('0x22')],'internal':_0x37c309['internal']};_0x7448fb['forEach'](function(_0x32bdec){_0x727bc6['push'](_[_0x2c40('0xcb')]({'channel':_0x32bdec,'type':_0x2c40('0xf1'),'data1':_0x3fac56[_0x2c40('0x4f')]['device'],'data2':_0xbba8e5},_0x5e2454));if(_0x37c309['loginInPause']){_0x53fe97[_0x2c40('0x41')](_['merge']({'channel':_0x32bdec,'type':'PAUSE','data1':_0x2c40('0xf2')},_0x5e2454));}});return db['MemberReport'][_0x2c40('0x7d')](_0x727bc6['concat'](_0x53fe97),{'individualHooks':!![]});}})[_0x2c40('0x1d')](function(){if(_0x37c309){return _0x37c309[_0x2c40('0x1c')]({'online':!![],'lastLoginAt':moment()[_0x2c40('0x9f')](_0x2c40('0xf0')),'voicePause':_0x37c309['loginInPause']||![],'mailPause':_0x37c309[_0x2c40('0x94')]||![],'chatPause':_0x37c309[_0x2c40('0x94')]||![],'faxPause':_0x37c309[_0x2c40('0x94')]||![],'smsPause':_0x37c309[_0x2c40('0x94')]||![],'openchannelPause':_0x37c309[_0x2c40('0x94')]||![],'whatsappPause':_0x37c309['loginInPause']||![],'pauseType':_0x37c309[_0x2c40('0x94')]?_0x2c40('0xf2'):null,'interface':_0xbba8e5,'lastPauseAt':moment()[_0x2c40('0x9f')](_0x2c40('0xf0'))});}})[_0x2c40('0x1d')](function(_0x263cca){if(_0x3fac56['isMiddleware']){return _0x276b54();}else{return Promise[_0x2c40('0xf3')](_0x263cca)[_0x2c40('0x1d')](respondWithResult(_0x47b215,null));}})[_0x2c40('0x4a')](handleError(_0x47b215,null));};exports[_0x2c40('0xf4')]=function(_0x521dbf,_0x2f984b){var _0x2ae2f3;return db[_0x2c40('0x31')]['find']({'where':{'id':_0x521dbf[_0x2c40('0x4c')]['id'],'role':_0x2c40('0x1e')},'attributes':['id',_0x2c40('0x2f'),'role']})[_0x2c40('0x1d')](handleEntityNotFound(_0x2f984b,null))['then'](function(_0xef6323){if(_0xef6323){_0x2ae2f3=_0xef6323;return db[_0x2c40('0xa1')]['destroy']({'where':{'membername':_0x2ae2f3['name']},'individualHooks':!![]});}})[_0x2c40('0x1d')](function(){return db[_0x2c40('0xef')][_0x2c40('0x42')]({'where':{'membername':_0x2ae2f3[_0x2c40('0x2f')],'exitAt':null}});})[_0x2c40('0x1d')](function(_0xaa032){var _0x58d1fe=[];_0xaa032[_0x2c40('0xf5')](function(_0x38a887){_0x58d1fe[_0x2c40('0x41')](_0x38a887[_0x2c40('0x1c')]({'exitAt':moment()['format'](_0x2c40('0xf0'))}));});return Promise['all'](_0x58d1fe);})[_0x2c40('0x1d')](function(){return _0x2ae2f3[_0x2c40('0x1c')]({'online':![],'voicePause':![],'mailPause':![],'chatPause':![],'faxPause':![],'smsPause':![],'openchannelPause':![],'whatsappPause':![],'interface':null});})['then'](respondWithResult(_0x2f984b,null))['catch'](handleError(_0x2f984b,null));};exports[_0x2c40('0xf6')]=function(_0x54d6dc,_0x5895ac){var _0x1f52f7;return db['UserVoiceQueueRt'][_0x2c40('0x1c')]({'paused':0x1},{'where':{'UserId':_0x54d6dc[_0x2c40('0x4c')]['id']},'individualHooks':!![]})['then'](function(){return db[_0x2c40('0x31')][_0x2c40('0x2c')]({'where':{'id':_0x54d6dc[_0x2c40('0x4c')]['id'],'role':_0x2c40('0x1e')},'attributes':['id',_0x2c40('0x2f'),_0x2c40('0x22'),_0x2c40('0x53'),_0x2c40('0x96'),_0x2c40('0x93')]});})[_0x2c40('0x1d')](handleEntityNotFound(_0x5895ac,null))[_0x2c40('0x1d')](function(_0x4b1e2d){if(_0x4b1e2d){_0x1f52f7=_0x4b1e2d;return db[_0x2c40('0xef')][_0x2c40('0x42')]({'where':{'membername':_0x1f52f7[_0x2c40('0x2f')],'type':_0x2c40('0xf7'),'exitAt':null}});}})[_0x2c40('0x1d')](function(_0x1d11c4){if(_0x1d11c4[_0x2c40('0x5f')]){var _0x4b9487=moment()['format']('YYYY-MM-DD\x20HH:mm:ss');for(var _0x68514b=0x0,_0x51e716=_0x1d11c4[_0x2c40('0x5f')];_0x68514b<_0x51e716;_0x68514b++){_0x1d11c4[_0x68514b][_0x2c40('0xf8')]({'exitAt':_0x4b9487});}}})[_0x2c40('0x1d')](function(){var _0x5780b7=[];var _0x8ca8e4=utils['getChannels']();_0x8ca8e4['forEach'](function(_0x376524){_0x5780b7['push']({'channel':_0x376524,'membername':_0x1f52f7[_0x2c40('0x2f')],'interface':_['isNil'](_0x1f52f7[_0x2c40('0x96')])?util['format'](_0x2c40('0xa0'),_0x1f52f7[_0x2c40('0x2f')]):_0x1f52f7['interface'],'type':_0x2c40('0xf7'),'enterAt':moment()[_0x2c40('0x9f')](_0x2c40('0xf0')),'data1':_0x54d6dc[_0x2c40('0x4f')][_0x2c40('0x34')]||_0x2c40('0xf9'),'role':_0x1f52f7['role'],'internal':_0x1f52f7[_0x2c40('0x53')]});});return db['MemberReport'][_0x2c40('0x7d')](_0x5780b7,{'individualHooks':!![]});})['then'](function(){return _0x1f52f7['update']({'voicePause':!![],'mailPause':!![],'chatPause':!![],'faxPause':!![],'smsPause':!![],'whatsappPause':!![],'openchannelPause':!![],'pauseType':_0x54d6dc[_0x2c40('0x4f')][_0x2c40('0x34')]||_0x2c40('0xf9'),'lastPauseAt':moment()[_0x2c40('0x9f')](_0x2c40('0xf0'))});})[_0x2c40('0x1d')](respondWithResult(_0x5895ac,null))[_0x2c40('0x4a')](handleError(_0x5895ac,null));};exports[_0x2c40('0xfa')]=function(_0x168065,_0x115d7d){if(_0x168065[_0x2c40('0x4f')][_0x2c40('0xa3')]&&!utils[_0x2c40('0x97')](_0x168065['body'][_0x2c40('0xa3')])){throw new APIBadRequestError(util[_0x2c40('0x9f')](_0x2c40('0xfb'),_0x168065[_0x2c40('0x4f')][_0x2c40('0xa3')]));}return db[_0x2c40('0x31')][_0x2c40('0x2c')]({'where':{'id':_0x168065['params']['id']},'attributes':['id',_0x2c40('0x2f'),_0x2c40('0x22'),'internal',_0x2c40('0x96'),_0x2c40('0x93'),_0x2c40('0x95'),_0x2c40('0xfc'),_0x2c40('0xfd'),'faxPause','openchannelPause',_0x2c40('0xfe'),_0x2c40('0xff'),'pauseType',_0x2c40('0x100')]})[_0x2c40('0x1d')](function(_0x4b8053){if(!_0x4b8053){throw new APINotFoundError(util[_0x2c40('0x9f')](_0x2c40('0xbd'),_0x168065[_0x2c40('0x4c')]['id']));}return _0x4b8053[_0x2c40('0xfa')](_0x168065[_0x2c40('0x4f')][_0x2c40('0xa3')]);})[_0x2c40('0x1d')](respondWithResult(_0x115d7d,null))[_0x2c40('0x4a')](APIHandleError(_0x115d7d));};exports[_0x2c40('0x101')]=function(_0x21a868,_0x5da1be){var _0x2c0fbe={};var _0x189e22={};var _0x1d8bb2;var _0x4483fd;return db[_0x2c40('0x31')][_0x2c40('0x8b')]({'where':{'id':_0x21a868[_0x2c40('0x4c')]['id']}})[_0x2c40('0x1d')](handleEntityNotFound(_0x5da1be,null))[_0x2c40('0x1d')](function(_0x3467ed){if(_0x3467ed){_0x1d8bb2=_0x3467ed;_0x189e22['model']=_[_0x2c40('0xc5')](db[_0x2c40('0x102')][_0x2c40('0xc4')]);_0x189e22[_0x2c40('0x3a')]=_[_0x2c40('0xc5')](_0x21a868['query']);_0x189e22[_0x2c40('0xc6')]=_[_0x2c40('0xc7')](_0x189e22[_0x2c40('0xc2')],_0x189e22[_0x2c40('0x3a')]);_0x2c0fbe[_0x2c40('0x40')]=_[_0x2c40('0xc7')](_0x189e22[_0x2c40('0xc2')],qs[_0x2c40('0xc8')](_0x21a868['query'][_0x2c40('0xc8')]));_0x2c0fbe[_0x2c40('0x40')]=_0x2c0fbe[_0x2c40('0x40')]['length']?_0x2c0fbe[_0x2c40('0x40')]:_0x189e22[_0x2c40('0xc2')];_0x2c0fbe['order']=qs[_0x2c40('0xc9')](_0x21a868['query'][_0x2c40('0xc9')]);_0x2c0fbe[_0x2c40('0x39')]=qs[_0x2c40('0xc6')](_[_0x2c40('0xca')](_0x21a868['query'],_0x189e22['filters']));if(_0x21a868[_0x2c40('0x3a')][_0x2c40('0x28')]){_0x2c0fbe[_0x2c40('0x39')]=_[_0x2c40('0xcb')](_0x2c0fbe[_0x2c40('0x39')],{'$or':_[_0x2c40('0x32')](_0x2c0fbe[_0x2c40('0x40')],function(_0x5ed70a){var _0x38a8d8={};_0x38a8d8[_0x5ed70a]={'$like':'%'+_0x21a868[_0x2c40('0x3a')][_0x2c40('0x28')]+'%'};return _0x38a8d8;})});}_0x2c0fbe=_[_0x2c40('0xcb')]({},_0x2c0fbe,_0x21a868[_0x2c40('0x4d')]);return _0x1d8bb2[_0x2c40('0x101')](_0x2c0fbe);}})[_0x2c40('0x1d')](function(_0x6f5beb){if(_0x6f5beb){_0x4483fd=_0x6f5beb[_0x2c40('0x5f')];if(!_0x21a868[_0x2c40('0x3a')]['hasOwnProperty'](_0x2c40('0xce'))){_0x2c0fbe[_0x2c40('0x19')]=qs[_0x2c40('0x19')](_0x21a868[_0x2c40('0x3a')]['limit']);_0x2c0fbe[_0x2c40('0x17')]=qs[_0x2c40('0x17')](_0x21a868[_0x2c40('0x3a')][_0x2c40('0x17')]);}return _0x1d8bb2['getTeams'](_0x2c0fbe);}})['then'](function(_0x5b105c){if(_0x5b105c){return _0x5b105c?{'count':_0x4483fd,'rows':_0x5b105c}:null;}})[_0x2c40('0x1d')](respondWithResult(_0x5da1be,null))['catch'](handleError(_0x5da1be,null));};exports[_0x2c40('0x103')]=function(_0x201d41,_0x3a7e3e){var _0x4618d9=_0x201d41['params']['id'];var _0x3e0ed7=_0x201d41[_0x2c40('0x4f')]?_0x201d41[_0x2c40('0x4f')]['ids']:null;var _0x50b12e=[];return Promise['resolve']()[_0x2c40('0x1d')](function(){if(!_0x3e0ed7)throw new APIBadRequestError(_0x2c40('0x104'));})['then'](function(){return db[_0x2c40('0x31')][_0x2c40('0x8b')]({'where':{'id':_0x4618d9}});})[_0x2c40('0x1d')](function(_0x14b976){if(!_0x14b976)throw new APINotFoundError(util[_0x2c40('0x9f')](_0x2c40('0xbd'),_0x201d41[_0x2c40('0x4c')]['id']));return db[_0x2c40('0x5b')][_0x2c40('0x105')](function(_0x56ab77){return _0x14b976['addTeams'](_0x3e0ed7,{'transaction':_0x56ab77})[_0x2c40('0x1d')](function(){return db[_0x2c40('0x102')][_0x2c40('0x42')]({'where':{'id':{'$in':_0x3e0ed7}}});})[_0x2c40('0x1d')](function(_0x58eec8){var _0xb126e9=_[_0x2c40('0x32')](_0x58eec8,function(_0x371392){return _0x371392[_0x2c40('0x106')]();});return Promise[_0x2c40('0x49')](_0xb126e9);})[_0x2c40('0x1d')](function(_0x16d2df){_0x50b12e=_[_0x2c40('0x107')](_0x16d2df);var _0x3df88e=_[_0x2c40('0x32')](_0x50b12e,function(_0x3311f4){return _0x3311f4[_0x2c40('0x108')](_0x14b976['id'],{'transaction':_0x56ab77});});return Promise[_0x2c40('0x49')](_0x3df88e);})[_0x2c40('0x1d')](function(){if(!_0x14b976[_0x2c40('0x93')])return;var _0x561fa0=_[_0x2c40('0x28')](_0x50b12e,function(_0x2ffc89){return _0x2ffc89[_0x2c40('0x109')](_0x2c40('0xa3'))===_0x2c40('0x10a');});var _0x5744f2=_[_0x2c40('0x32')](_0x561fa0,function(_0xd2f7b3){return db[_0x2c40('0xa1')][_0x2c40('0xa2')]({'membername':_0x14b976['name'],'UserId':_0x14b976['id'],'queue_name':_0xd2f7b3[_0x2c40('0x2f')],'VoiceQueueId':_0xd2f7b3['id'],'interface':_[_0x2c40('0x59')](_0x14b976[_0x2c40('0x96')])?util[_0x2c40('0x9f')]('SIP/%s',_0x14b976['name']):_0x14b976[_0x2c40('0x96')],'paused':_0x14b976['voicePause']||![],'penalty':_0x14b976['penalty']},{'transaction':_0x56ab77});});return Promise[_0x2c40('0x49')](_0x5744f2);})[_0x2c40('0x1d')](function(){return db[_0x2c40('0x10b')][_0x2c40('0x42')]({'where':{'teamId':{'$in':_0x3e0ed7}}});})[_0x2c40('0x1d')](function(_0x254d79){var _0x8f346=_[_0x2c40('0x32')](_0x254d79,function(_0x479387){return db[_0x2c40('0x10c')]['create']({'UserId':_0x14b976['id'],'VoicePrefixId':_0x479387[_0x2c40('0x10d')]},{'transaction':_0x56ab77});});return Promise['all'](_0x8f346);});});})['then'](function(){for(var _0xdb1c28=0x0;_0xdb1c28<_0x50b12e[_0x2c40('0x5f')];_0xdb1c28++){var _0x22e943=_0x50b12e[_0xdb1c28][_0x2c40('0x109')](_0x2c40('0xa3'));var _0x577480=_0x22e943+'QueueId';socket[_0x2c40('0x1f')](_0x2c40('0x75')+_0x22e943+_0x2c40('0x9e'),{'UserId':_0x4618d9,['queueField']:_0x50b12e[_0xdb1c28]['id']});}})[_0x2c40('0x1d')](respondWithStatusCode(_0x3a7e3e,null))['catch'](APIHandleError(_0x3a7e3e));};exports[_0x2c40('0x10e')]=function(_0x55420d,_0x2b579c){var _0x42575d=_0x55420d['params']['id'];var _0x5f666=null;if(_0x55420d[_0x2c40('0x3a')][_0x2c40('0x51')]){_0x5f666=_[_0x2c40('0x10f')](_0x55420d[_0x2c40('0x3a')][_0x2c40('0x51')])?_0x55420d[_0x2c40('0x3a')][_0x2c40('0x51')]:[_0x55420d[_0x2c40('0x3a')]['ids']];}var _0x4a43ff=[];return Promise[_0x2c40('0xf3')]()[_0x2c40('0x1d')](function(){if(!_0x5f666)throw new APIBadRequestError('Query\x20parameter\x20\x27ids\x27\x20is\x20required');})['then'](function(){return db[_0x2c40('0x31')][_0x2c40('0x8b')]({'where':{'id':_0x42575d}});})[_0x2c40('0x1d')](function(_0x32e006){if(!_0x32e006)throw new APINotFoundError(util['format']('User\x20with\x20id\x20%s\x20not\x20found',_0x55420d[_0x2c40('0x4c')]['id']));return db['sequelize'][_0x2c40('0x105')](function(_0x41d54d){return _0x32e006['removeTeams'](_0x5f666,{'transaction':_0x41d54d})[_0x2c40('0x1d')](function(){return db[_0x2c40('0x102')]['findAll']({'where':{'id':{'$in':_0x5f666}}});})[_0x2c40('0x1d')](function(_0x593b73){var _0x326b3f=_[_0x2c40('0x32')](_0x593b73,function(_0x14a70b){return _0x14a70b[_0x2c40('0x106')]();});return Promise['all'](_0x326b3f);})[_0x2c40('0x1d')](function(_0x1c880c){_0x4a43ff=_[_0x2c40('0x107')](_0x1c880c);var _0x39d3fd=_[_0x2c40('0x32')](_0x4a43ff,function(_0x147341){return _0x147341[_0x2c40('0x110')](_0x32e006['id'],{'transaction':_0x41d54d});});return Promise[_0x2c40('0x49')](_0x39d3fd);})[_0x2c40('0x1d')](function(){if(!_0x32e006[_0x2c40('0x93')])return;var _0x3d1ec5=_[_0x2c40('0x28')](_0x4a43ff,function(_0x2ada1d){return _0x2ada1d[_0x2c40('0x109')](_0x2c40('0xa3'))==='Voice';});var _0x55cd57=_[_0x2c40('0x32')](_0x3d1ec5,function(_0x4039b2){return db[_0x2c40('0xa1')][_0x2c40('0x20')]({'where':{'VoiceQueueId':_0x4039b2['id'],'UserId':_0x32e006['id']},'transaction':_0x41d54d});});return Promise[_0x2c40('0x49')](_0x55cd57);})[_0x2c40('0x1d')](function(){return db[_0x2c40('0x10b')][_0x2c40('0x42')]({'where':{'teamId':{'$in':_0x5f666}}});})[_0x2c40('0x1d')](function(_0x44e905){var _0xb37484=_[_0x2c40('0x32')](_0x44e905,function(_0x35a20b){return db['UserVoicePrefix'][_0x2c40('0x20')]({'where':{'UserId':_0x32e006['id'],'VoicePrefixId':_0x35a20b[_0x2c40('0x10d')]}},{'transaction':_0x41d54d});});return Promise[_0x2c40('0x49')](_0xb37484);});});})[_0x2c40('0x1d')](function(){for(var _0x1ddecb=0x0;_0x1ddecb<_0x4a43ff[_0x2c40('0x5f')];_0x1ddecb++){var _0x3be1e6=_0x4a43ff[_0x1ddecb]['getDataValue']('channel');var _0x2b9953=_0x3be1e6+_0x2c40('0x9d');socket['emit'](_0x2c40('0x75')+_0x3be1e6+_0x2c40('0xa5'),{'UserId':_0x42575d,['queueField']:_0x4a43ff[_0x1ddecb]['id']});}})['then'](respondWithStatusCode(_0x2b579c,null))[_0x2c40('0x4a')](APIHandleError(_0x2b579c));};exports[_0x2c40('0x111')]=function(_0x3c7778,_0x37617e){var _0x541e44={};var _0x16d666={};var _0x10877a;var _0x438191;return db[_0x2c40('0x31')][_0x2c40('0x8b')]({'where':{'id':_0x3c7778['params']['id']}})[_0x2c40('0x1d')](handleEntityNotFound(_0x37617e,null))[_0x2c40('0x1d')](function(_0x589cbe){if(_0x589cbe){_0x10877a=_0x589cbe;_0x16d666[_0x2c40('0xc2')]=_[_0x2c40('0xc5')](db[_0x2c40('0x112')][_0x2c40('0xc4')]);_0x16d666[_0x2c40('0x3a')]=_['keys'](_0x3c7778[_0x2c40('0x3a')]);_0x16d666[_0x2c40('0xc6')]=_[_0x2c40('0xc7')](_0x16d666['model'],_0x16d666[_0x2c40('0x3a')]);_0x541e44[_0x2c40('0x40')]=_[_0x2c40('0xc7')](_0x16d666[_0x2c40('0xc2')],qs[_0x2c40('0xc8')](_0x3c7778['query'][_0x2c40('0xc8')]));_0x541e44[_0x2c40('0x40')]=_0x541e44['attributes']['length']?_0x541e44[_0x2c40('0x40')]:_0x16d666['model'];_0x541e44['order']=qs['sort'](_0x3c7778[_0x2c40('0x3a')][_0x2c40('0xc9')]);_0x541e44[_0x2c40('0x39')]=qs[_0x2c40('0xc6')](_[_0x2c40('0xca')](_0x3c7778[_0x2c40('0x3a')],_0x16d666[_0x2c40('0xc6')]));if(_0x3c7778[_0x2c40('0x3a')][_0x2c40('0x28')]){_0x541e44[_0x2c40('0x39')]=_['merge'](_0x541e44[_0x2c40('0x39')],{'$or':_[_0x2c40('0x32')](_0x541e44[_0x2c40('0x40')],function(_0x5938f7){var _0x421e77={};_0x421e77[_0x5938f7]={'$like':'%'+_0x3c7778[_0x2c40('0x3a')][_0x2c40('0x28')]+'%'};return _0x421e77;})});}_0x541e44=_[_0x2c40('0xcb')]({},_0x541e44,_0x3c7778[_0x2c40('0x4d')]);return _0x10877a[_0x2c40('0x111')](_0x541e44);}})[_0x2c40('0x1d')](function(_0x399b13){if(_0x399b13){_0x438191=_0x399b13[_0x2c40('0x5f')];if(!_0x3c7778[_0x2c40('0x3a')][_0x2c40('0xcd')](_0x2c40('0xce'))){_0x541e44[_0x2c40('0x19')]=qs[_0x2c40('0x19')](_0x3c7778['query']['limit']);_0x541e44[_0x2c40('0x17')]=qs['offset'](_0x3c7778[_0x2c40('0x3a')][_0x2c40('0x17')]);}return _0x10877a[_0x2c40('0x111')](_0x541e44);}})['then'](function(_0x548c9a){if(_0x548c9a){return _0x548c9a?{'count':_0x438191,'rows':_0x548c9a}:null;}})[_0x2c40('0x1d')](respondWithResult(_0x37617e,null))[_0x2c40('0x4a')](handleError(_0x37617e,null));};exports[_0x2c40('0x113')]=function(_0x423fa4,_0x2791d0){var _0x4ea74e={};var _0x5c4db={};var _0x1d03f9;return db['User']['findOne']({'where':{'id':_0x423fa4[_0x2c40('0x4c')]['id']}})['then'](handleEntityNotFound(_0x2791d0,null))[_0x2c40('0x1d')](function(_0x5313f9){if(_0x5313f9){_0x1d03f9=_0x5313f9;_0x5c4db[_0x2c40('0xc2')]=_['keys'](db['User'][_0x2c40('0xc4')]);_0x5c4db[_0x2c40('0x3a')]=_['keys'](_0x423fa4[_0x2c40('0x3a')]);_0x5c4db[_0x2c40('0xc6')]=_[_0x2c40('0xc7')](_0x5c4db['model'],_0x5c4db[_0x2c40('0x3a')]);_0x4ea74e['attributes']=_[_0x2c40('0xc7')](_0x5c4db[_0x2c40('0xc2')],qs[_0x2c40('0xc8')](_0x423fa4[_0x2c40('0x3a')][_0x2c40('0xc8')]));_0x4ea74e['attributes']=_0x4ea74e[_0x2c40('0x40')][_0x2c40('0x5f')]?_0x4ea74e[_0x2c40('0x40')]:_0x5c4db['model'];_0x4ea74e[_0x2c40('0xcf')]=qs[_0x2c40('0xc9')](_0x423fa4[_0x2c40('0x3a')][_0x2c40('0xc9')]);_0x4ea74e['where']=qs[_0x2c40('0xc6')](_[_0x2c40('0xca')](_0x423fa4[_0x2c40('0x3a')],_0x5c4db['filters']));if(_0x423fa4[_0x2c40('0x3a')][_0x2c40('0x28')]){_0x4ea74e['where']=_[_0x2c40('0xcb')](_0x4ea74e[_0x2c40('0x39')],{'$or':_[_0x2c40('0x32')](_0x4ea74e[_0x2c40('0x40')],function(_0x3efb93){var _0x3f0456={};_0x3f0456[_0x3efb93]={'$like':'%'+_0x423fa4['query'][_0x2c40('0x28')]+'%'};return _0x3f0456;})});}_0x4ea74e[_0x2c40('0xc2')]=db['User'];_0x4ea74e['as']=_0x2c40('0x25');_0x4ea74e=_[_0x2c40('0xcb')]({},_0x4ea74e,_0x423fa4[_0x2c40('0x4d')]);return _0x1d03f9['getVoiceQueues']({'include':[_0x4ea74e]});}})[_0x2c40('0x1d')](function(_0x560e20){if(_0x560e20){var _0x3f9593={},_0x50c569=[];for(var _0x1c1d65=0x0;_0x1c1d65<_0x560e20[_0x2c40('0x5f')];_0x1c1d65+=0x1){for(var _0x1192ef=0x0,_0x35b985;_0x1192ef<_0x560e20[_0x1c1d65][_0x2c40('0x25')][_0x2c40('0x5f')];_0x1192ef+=0x1){_0x35b985=_0x560e20[_0x1c1d65][_0x2c40('0x25')][_0x1192ef][_0x2c40('0x21')]({'plain':!![]});_0x3f9593[_0x35b985['id']]=_0x35b985;}}_0x3f9593=_[_0x2c40('0x114')](_0x3f9593);for(var _0x3646cc=qs['offset'](_0x423fa4['query'][_0x2c40('0x17')]);_0x3646cc<_0x3f9593[_0x2c40('0x5f')]&&_0x50c569[_0x2c40('0x5f')]<qs[_0x2c40('0x19')](_0x423fa4['query'][_0x2c40('0x19')]);_0x3646cc+=0x1){if(_0x3f9593[_0x3646cc]){_0x50c569[_0x2c40('0x41')](_0x3f9593[_0x3646cc]);}}return{'count':_0x3f9593[_0x2c40('0x5f')],'rows':_0x50c569};}})['then'](respondWithResult(_0x2791d0,null))[_0x2c40('0x4a')](handleError(_0x2791d0,null));};exports['destroy']=function(_0x488cd8,_0x19b605){if(_0x488cd8['user']['id']==_0x488cd8['params']['id']){return _0x19b605[_0x2c40('0x15')](0x1f4)[_0x2c40('0x30')]({'message':_0x2c40('0x115')});}return db[_0x2c40('0x31')][_0x2c40('0x2c')]({'where':{'id':_0x488cd8['params']['id']}})[_0x2c40('0x1d')](handleEntityNotFound(_0x19b605,null))[_0x2c40('0x1d')](removeEntity(_0x19b605,null))[_0x2c40('0x4a')](handleError(_0x19b605,null));};exports[_0x2c40('0x116')]=function(_0x4c401b,_0x44ab36){return db[_0x2c40('0x31')][_0x2c40('0x2c')]({'where':{'id':_0x4c401b[_0x2c40('0x4c')]['id']}})['then'](handleEntityNotFound(_0x44ab36,null))[_0x2c40('0x1d')](function(_0x43e937){if(_0x43e937){return _0x43e937['addChatInteractions'](_0x4c401b[_0x2c40('0x4f')][_0x2c40('0x51')],_[_0x2c40('0x52')](_0x4c401b[_0x2c40('0x4f')],[_0x2c40('0x51'),'id'])||{})[_0x2c40('0x9c')](function(){for(var _0x4c9a87=0x0;_0x4c9a87<_0x4c401b[_0x2c40('0x4f')][_0x2c40('0x51')][_0x2c40('0x5f')];_0x4c9a87+=0x1){socket[_0x2c40('0x1f')](_0x2c40('0x117'),{'ChatInteractionId':Number(_0x4c401b[_0x2c40('0x4f')]['ids'][_0x4c9a87]),'UserId':Number(_0x4c401b['params']['id'])});}return _0x4c401b[_0x2c40('0x4f')][_0x2c40('0x51')];});}})[_0x2c40('0x1d')](respondWithResult(_0x44ab36,null))['catch'](handleError(_0x44ab36,null));};exports[_0x2c40('0x118')]=function(_0x5be68a,_0x3e0e02){return db[_0x2c40('0x31')]['find']({'where':{'id':_0x5be68a[_0x2c40('0x4c')]['id']}})[_0x2c40('0x1d')](handleEntityNotFound(_0x3e0e02,null))['then'](function(_0x42dd8c){if(_0x42dd8c){return _0x42dd8c[_0x2c40('0x118')](_0x5be68a[_0x2c40('0x3a')][_0x2c40('0x51')])['then'](function(){if(_['isArray'](_0x5be68a[_0x2c40('0x3a')]['ids'])){for(var _0xbb2d17=0x0;_0xbb2d17<_0x5be68a[_0x2c40('0x3a')][_0x2c40('0x51')][_0x2c40('0x5f')];_0xbb2d17+=0x1){socket['emit'](_0x2c40('0x119'),{'ChatInteractionId':Number(_0x5be68a[_0x2c40('0x3a')][_0x2c40('0x51')][_0xbb2d17]),'UserId':Number(_0x5be68a[_0x2c40('0x4c')]['id'])});}}else{socket[_0x2c40('0x1f')](_0x2c40('0x119'),{'ChatInteractionId':Number(_0x5be68a[_0x2c40('0x3a')]['ids']),'UserId':Number(_0x5be68a['params']['id'])});}});}})[_0x2c40('0x1d')](respondWithStatusCode(_0x3e0e02,null))['catch'](handleError(_0x3e0e02,null));};exports[_0x2c40('0x11a')]=function(_0x26395c,_0x56cfe7){return db[_0x2c40('0x31')][_0x2c40('0x2c')]({'where':{'id':_0x26395c[_0x2c40('0x4c')]['id']}})[_0x2c40('0x1d')](handleEntityNotFound(_0x56cfe7,null))[_0x2c40('0x1d')](function(_0x1f7c90){if(_0x1f7c90){return _0x1f7c90['addMailInteractions'](_0x26395c[_0x2c40('0x4f')][_0x2c40('0x51')],_[_0x2c40('0x52')](_0x26395c[_0x2c40('0x4f')],[_0x2c40('0x51'),'id'])||{})[_0x2c40('0x9c')](function(){for(var _0x131db8=0x0;_0x131db8<_0x26395c[_0x2c40('0x4f')][_0x2c40('0x51')][_0x2c40('0x5f')];_0x131db8+=0x1){socket[_0x2c40('0x1f')](_0x2c40('0x11b'),{'MailInteractionId':Number(_0x26395c[_0x2c40('0x4f')][_0x2c40('0x51')][_0x131db8]),'UserId':Number(_0x26395c[_0x2c40('0x4c')]['id'])});}return _0x26395c[_0x2c40('0x4f')][_0x2c40('0x51')];});}})[_0x2c40('0x1d')](respondWithResult(_0x56cfe7,null))[_0x2c40('0x4a')](handleError(_0x56cfe7,null));};exports['removeMailInteractions']=function(_0x3a0708,_0x3725fa){return db[_0x2c40('0x31')][_0x2c40('0x2c')]({'where':{'id':_0x3a0708['params']['id']}})[_0x2c40('0x1d')](handleEntityNotFound(_0x3725fa,null))[_0x2c40('0x1d')](function(_0xaaa812){if(_0xaaa812){return _0xaaa812[_0x2c40('0x11c')](_0x3a0708[_0x2c40('0x3a')]['ids'])[_0x2c40('0x1d')](function(){if(_[_0x2c40('0x10f')](_0x3a0708[_0x2c40('0x3a')]['ids'])){for(var _0x5df880=0x0;_0x5df880<_0x3a0708[_0x2c40('0x3a')][_0x2c40('0x51')]['length'];_0x5df880+=0x1){socket[_0x2c40('0x1f')](_0x2c40('0x11d'),{'MailInteractionId':Number(_0x3a0708[_0x2c40('0x3a')][_0x2c40('0x51')][_0x5df880]),'UserId':Number(_0x3a0708[_0x2c40('0x4c')]['id'])});}}else{socket['emit']('user_has_mail_interactions:remove',{'MailInteractionId':Number(_0x3a0708['query'][_0x2c40('0x51')]),'UserId':Number(_0x3a0708[_0x2c40('0x4c')]['id'])});}});}})[_0x2c40('0x1d')](respondWithStatusCode(_0x3725fa,null))[_0x2c40('0x4a')](handleError(_0x3725fa,null));};exports['addFaxInteractions']=function(_0x12cd24,_0x50c38d){return db[_0x2c40('0x31')][_0x2c40('0x2c')]({'where':{'id':_0x12cd24[_0x2c40('0x4c')]['id']}})[_0x2c40('0x1d')](handleEntityNotFound(_0x50c38d,null))[_0x2c40('0x1d')](function(_0x2363b7){if(_0x2363b7){return _0x2363b7[_0x2c40('0x11e')](_0x12cd24[_0x2c40('0x4f')][_0x2c40('0x51')],_[_0x2c40('0x52')](_0x12cd24[_0x2c40('0x4f')],['ids','id'])||{})['spread'](function(){for(var _0x492b83=0x0;_0x492b83<_0x12cd24['body']['ids']['length'];_0x492b83+=0x1){socket['emit'](_0x2c40('0x11f'),{'FaxInteractionId':Number(_0x12cd24[_0x2c40('0x4f')][_0x2c40('0x51')][_0x492b83]),'UserId':Number(_0x12cd24['params']['id'])});}return _0x12cd24['body'][_0x2c40('0x51')];});}})['then'](respondWithResult(_0x50c38d,null))['catch'](handleError(_0x50c38d,null));};exports[_0x2c40('0x120')]=function(_0x5531ee,_0x48f02){return db[_0x2c40('0x31')][_0x2c40('0x2c')]({'where':{'id':_0x5531ee['params']['id']}})[_0x2c40('0x1d')](handleEntityNotFound(_0x48f02,null))[_0x2c40('0x1d')](function(_0x28b343){if(_0x28b343){return _0x28b343['removeFaxInteractions'](_0x5531ee[_0x2c40('0x3a')][_0x2c40('0x51')])[_0x2c40('0x1d')](function(){if(_[_0x2c40('0x10f')](_0x5531ee['query'][_0x2c40('0x51')])){for(var _0x3a850a=0x0;_0x3a850a<_0x5531ee['query'][_0x2c40('0x51')]['length'];_0x3a850a+=0x1){socket['emit']('user_has_fax_interactions:remove',{'FaxInteractionId':Number(_0x5531ee['query'][_0x2c40('0x51')][_0x3a850a]),'UserId':Number(_0x5531ee['params']['id'])});}}else{socket[_0x2c40('0x1f')](_0x2c40('0x121'),{'FaxInteractionId':Number(_0x5531ee['query'][_0x2c40('0x51')]),'UserId':Number(_0x5531ee['params']['id'])});}});}})[_0x2c40('0x1d')](respondWithStatusCode(_0x48f02,null))[_0x2c40('0x4a')](handleError(_0x48f02,null));};exports['addSmsInteractions']=function(_0x4e7e03,_0x1c4fa1){return db['User'][_0x2c40('0x2c')]({'where':{'id':_0x4e7e03[_0x2c40('0x4c')]['id']}})[_0x2c40('0x1d')](handleEntityNotFound(_0x1c4fa1,null))['then'](function(_0x4630eb){if(_0x4630eb){return _0x4630eb[_0x2c40('0x122')](_0x4e7e03['body'][_0x2c40('0x51')],_[_0x2c40('0x52')](_0x4e7e03[_0x2c40('0x4f')],[_0x2c40('0x51'),'id'])||{})[_0x2c40('0x9c')](function(){for(var _0x20aaeb=0x0;_0x20aaeb<_0x4e7e03[_0x2c40('0x4f')][_0x2c40('0x51')]['length'];_0x20aaeb+=0x1){socket['emit'](_0x2c40('0x123'),{'SmsInteractionId':Number(_0x4e7e03[_0x2c40('0x4f')][_0x2c40('0x51')][_0x20aaeb]),'UserId':Number(_0x4e7e03['params']['id'])});}return _0x4e7e03[_0x2c40('0x4f')][_0x2c40('0x51')];});}})[_0x2c40('0x1d')](respondWithResult(_0x1c4fa1,null))[_0x2c40('0x4a')](handleError(_0x1c4fa1,null));};exports[_0x2c40('0x124')]=function(_0x3cda1f,_0x12cbc1){return db[_0x2c40('0x31')][_0x2c40('0x2c')]({'where':{'id':_0x3cda1f[_0x2c40('0x4c')]['id']}})[_0x2c40('0x1d')](handleEntityNotFound(_0x12cbc1,null))[_0x2c40('0x1d')](function(_0x29dd4c){if(_0x29dd4c){return _0x29dd4c[_0x2c40('0x124')](_0x3cda1f[_0x2c40('0x3a')][_0x2c40('0x51')])[_0x2c40('0x1d')](function(){if(_[_0x2c40('0x10f')](_0x3cda1f['query'][_0x2c40('0x51')])){for(var _0x3378fb=0x0;_0x3378fb<_0x3cda1f[_0x2c40('0x3a')][_0x2c40('0x51')]['length'];_0x3378fb+=0x1){socket[_0x2c40('0x1f')](_0x2c40('0x125'),{'SmsInteractionId':Number(_0x3cda1f[_0x2c40('0x3a')]['ids'][_0x3378fb]),'UserId':Number(_0x3cda1f['params']['id'])});}}else{socket[_0x2c40('0x1f')](_0x2c40('0x125'),{'SmsInteractionId':Number(_0x3cda1f[_0x2c40('0x3a')][_0x2c40('0x51')]),'UserId':Number(_0x3cda1f[_0x2c40('0x4c')]['id'])});}});}})[_0x2c40('0x1d')](respondWithStatusCode(_0x12cbc1,null))[_0x2c40('0x4a')](handleError(_0x12cbc1,null));};exports[_0x2c40('0x126')]=function(_0x3d528e,_0x26b019){return db[_0x2c40('0x31')][_0x2c40('0x2c')]({'where':{'id':_0x3d528e[_0x2c40('0x4c')]['id']}})[_0x2c40('0x1d')](handleEntityNotFound(_0x26b019,null))[_0x2c40('0x1d')](function(_0x1ebe38){if(_0x1ebe38){return _0x1ebe38[_0x2c40('0x126')](_0x3d528e[_0x2c40('0x4f')][_0x2c40('0x51')],_[_0x2c40('0x52')](_0x3d528e['body'],[_0x2c40('0x51'),'id'])||{})[_0x2c40('0x9c')](function(){for(var _0x46c13a=0x0;_0x46c13a<_0x3d528e['body'][_0x2c40('0x51')]['length'];_0x46c13a+=0x1){socket[_0x2c40('0x1f')]('user_has_openchannel_interactions:save',{'OpenchannelInteractionId':Number(_0x3d528e['body']['ids'][_0x46c13a]),'UserId':Number(_0x3d528e[_0x2c40('0x4c')]['id'])});}return _0x3d528e[_0x2c40('0x4f')][_0x2c40('0x51')];});}})['then'](respondWithResult(_0x26b019,null))[_0x2c40('0x4a')](handleError(_0x26b019,null));};exports['removeOpenchannelInteractions']=function(_0x2b834b,_0x2bada9){return db[_0x2c40('0x31')][_0x2c40('0x2c')]({'where':{'id':_0x2b834b[_0x2c40('0x4c')]['id']}})[_0x2c40('0x1d')](handleEntityNotFound(_0x2bada9,null))[_0x2c40('0x1d')](function(_0x329a66){if(_0x329a66){return _0x329a66[_0x2c40('0x127')](_0x2b834b['query'][_0x2c40('0x51')])[_0x2c40('0x1d')](function(){if(_[_0x2c40('0x10f')](_0x2b834b['query']['ids'])){for(var _0x559545=0x0;_0x559545<_0x2b834b['query'][_0x2c40('0x51')][_0x2c40('0x5f')];_0x559545+=0x1){socket['emit'](_0x2c40('0x128'),{'OpenchannelInteractionId':Number(_0x2b834b[_0x2c40('0x3a')][_0x2c40('0x51')][_0x559545]),'UserId':Number(_0x2b834b[_0x2c40('0x4c')]['id'])});}}else{socket[_0x2c40('0x1f')](_0x2c40('0x128'),{'OpenchannelInteractionId':Number(_0x2b834b['query'][_0x2c40('0x51')]),'UserId':Number(_0x2b834b[_0x2c40('0x4c')]['id'])});}});}})[_0x2c40('0x1d')](respondWithStatusCode(_0x2bada9,null))[_0x2c40('0x4a')](handleError(_0x2bada9,null));};exports[_0x2c40('0x129')]=function(_0x1124e1,_0x1741b3){return db[_0x2c40('0x31')]['find']({'where':{'id':_0x1124e1['params']['id']}})[_0x2c40('0x1d')](handleEntityNotFound(_0x1741b3,null))[_0x2c40('0x1d')](function(_0x49a41b){if(_0x49a41b){return _0x49a41b[_0x2c40('0x129')](_0x1124e1[_0x2c40('0x4f')][_0x2c40('0x51')],_['omit'](_0x1124e1[_0x2c40('0x4f')],['ids','id'])||{})['spread'](function(){for(var _0x2f1ade=0x0;_0x2f1ade<_0x1124e1['body'][_0x2c40('0x51')][_0x2c40('0x5f')];_0x2f1ade+=0x1){socket[_0x2c40('0x1f')](_0x2c40('0x12a'),{'WhatsappInteractionId':Number(_0x1124e1[_0x2c40('0x4f')][_0x2c40('0x51')][_0x2f1ade]),'UserId':Number(_0x1124e1[_0x2c40('0x4c')]['id'])});}return _0x1124e1[_0x2c40('0x4f')][_0x2c40('0x51')];});}})[_0x2c40('0x1d')](respondWithResult(_0x1741b3,null))['catch'](handleError(_0x1741b3,null));};exports[_0x2c40('0x12b')]=function(_0x1bec6d,_0x2c8506){return db[_0x2c40('0x31')][_0x2c40('0x2c')]({'where':{'id':_0x1bec6d['params']['id']}})[_0x2c40('0x1d')](handleEntityNotFound(_0x2c8506,null))[_0x2c40('0x1d')](function(_0x31d9e1){if(_0x31d9e1){return _0x31d9e1[_0x2c40('0x12b')](_0x1bec6d['query'][_0x2c40('0x51')]);}})[_0x2c40('0x1d')](respondWithStatusCode(_0x2c8506,null))['catch'](handleError(_0x2c8506,null));};exports[_0x2c40('0x12c')]=function(_0x41818b,_0x3159ec){var _0x4d7653={};var _0x3e1484={};var _0x53c8fc;var _0x37c13f;return db['User'][_0x2c40('0x8b')]({'where':{'id':_0x41818b['params']['id']}})[_0x2c40('0x1d')](handleEntityNotFound(_0x3159ec,null))[_0x2c40('0x1d')](function(_0x20c34f){if(_0x20c34f){_0x53c8fc=_0x20c34f;_0x3e1484[_0x2c40('0xc2')]=_['keys'](db[_0x2c40('0x12d')][_0x2c40('0xc4')]);_0x3e1484[_0x2c40('0x3a')]=_['keys'](_0x41818b[_0x2c40('0x3a')]);_0x3e1484[_0x2c40('0xc6')]=_[_0x2c40('0xc7')](_0x3e1484['model'],_0x3e1484[_0x2c40('0x3a')]);_0x4d7653['attributes']=_[_0x2c40('0xc7')](_0x3e1484['model'],qs[_0x2c40('0xc8')](_0x41818b[_0x2c40('0x3a')][_0x2c40('0xc8')]));_0x4d7653['attributes']=_0x4d7653[_0x2c40('0x40')]['length']?_0x4d7653[_0x2c40('0x40')]:_0x3e1484[_0x2c40('0xc2')];_0x4d7653['order']=qs[_0x2c40('0xc9')](_0x41818b[_0x2c40('0x3a')][_0x2c40('0xc9')]);_0x4d7653['where']=qs['filters'](_[_0x2c40('0xca')](_0x41818b['query'],_0x3e1484[_0x2c40('0xc6')]));if(_0x41818b[_0x2c40('0x3a')]['filter']){_0x4d7653[_0x2c40('0x39')]=_[_0x2c40('0xcb')](_0x4d7653[_0x2c40('0x39')],{'$or':_[_0x2c40('0x32')](_0x4d7653['attributes'],function(_0x2fa65f){var _0x22cf07={};_0x22cf07[_0x2fa65f]={'$like':'%'+_0x41818b[_0x2c40('0x3a')][_0x2c40('0x28')]+'%'};return _0x22cf07;})});}_0x4d7653=_[_0x2c40('0xcb')]({},_0x4d7653,_0x41818b[_0x2c40('0x4d')]);return _0x53c8fc[_0x2c40('0x12c')](_0x4d7653);}})[_0x2c40('0x1d')](function(_0x29a5a7){if(_0x29a5a7){_0x37c13f=_0x29a5a7[_0x2c40('0x5f')];if(!_0x41818b[_0x2c40('0x3a')][_0x2c40('0xcd')](_0x2c40('0xce'))){_0x4d7653[_0x2c40('0x19')]=qs[_0x2c40('0x19')](_0x41818b[_0x2c40('0x3a')][_0x2c40('0x19')]);_0x4d7653[_0x2c40('0x17')]=qs[_0x2c40('0x17')](_0x41818b['query'][_0x2c40('0x17')]);}return _0x53c8fc['getVoicePrefixes'](_0x4d7653);}})[_0x2c40('0x1d')](function(_0x4e6db4){if(_0x4e6db4){return _0x4e6db4?{'count':_0x37c13f,'rows':_0x4e6db4}:null;}})[_0x2c40('0x1d')](respondWithResult(_0x3159ec,null))['catch'](handleError(_0x3159ec,null));};exports[_0x2c40('0x12e')]=function(_0x352127,_0x251fb2){var _0x2e8cf8={};var _0x40eb5d={};var _0x4b7996;var _0x4dc28b;return db[_0x2c40('0x31')]['findOne']({'where':{'id':_0x352127['params']['id']}})[_0x2c40('0x1d')](handleEntityNotFound(_0x251fb2,null))[_0x2c40('0x1d')](function(_0x4edba5){if(_0x4edba5){_0x4b7996=_0x4edba5;_0x40eb5d[_0x2c40('0xc2')]=_[_0x2c40('0xc5')](db[_0x2c40('0x12f')][_0x2c40('0xc4')]);_0x40eb5d['query']=_[_0x2c40('0xc5')](_0x352127['query']);_0x40eb5d[_0x2c40('0xc6')]=_['intersection'](_0x40eb5d[_0x2c40('0xc2')],_0x40eb5d['query']);_0x2e8cf8['attributes']=_[_0x2c40('0xc7')](_0x40eb5d['model'],qs[_0x2c40('0xc8')](_0x352127[_0x2c40('0x3a')]['fields']));_0x2e8cf8[_0x2c40('0x40')]=_0x2e8cf8[_0x2c40('0x40')][_0x2c40('0x5f')]?_0x2e8cf8[_0x2c40('0x40')]:_0x40eb5d[_0x2c40('0xc2')];_0x2e8cf8[_0x2c40('0xcf')]=qs[_0x2c40('0xc9')](_0x352127[_0x2c40('0x3a')][_0x2c40('0xc9')]);_0x2e8cf8[_0x2c40('0x39')]=qs[_0x2c40('0xc6')](_['pick'](_0x352127[_0x2c40('0x3a')],_0x40eb5d['filters']));if(_0x352127['query']['filter']){_0x2e8cf8['where']=_[_0x2c40('0xcb')](_0x2e8cf8[_0x2c40('0x39')],{'$or':_[_0x2c40('0x32')](_0x2e8cf8['attributes'],function(_0xfb3fbe){var _0x1cae08={};_0x1cae08[_0xfb3fbe]={'$like':'%'+_0x352127[_0x2c40('0x3a')][_0x2c40('0x28')]+'%'};return _0x1cae08;})});}_0x2e8cf8=_[_0x2c40('0xcb')]({},_0x2e8cf8,_0x352127[_0x2c40('0x4d')]);return _0x4b7996[_0x2c40('0x12e')](_0x2e8cf8);}})['then'](function(_0x4551a1){if(_0x4551a1){_0x4dc28b=_0x4551a1[_0x2c40('0x5f')];if(!_0x352127[_0x2c40('0x3a')]['hasOwnProperty'](_0x2c40('0xce'))){_0x2e8cf8[_0x2c40('0x19')]=qs[_0x2c40('0x19')](_0x352127[_0x2c40('0x3a')][_0x2c40('0x19')]);_0x2e8cf8[_0x2c40('0x17')]=qs[_0x2c40('0x17')](_0x352127[_0x2c40('0x3a')]['offset']);}return _0x4b7996[_0x2c40('0x12e')](_0x2e8cf8);}})[_0x2c40('0x1d')](function(_0x2ec21b){if(_0x2ec21b){return _0x2ec21b?{'count':_0x4dc28b,'rows':_0x2ec21b}:null;}})[_0x2c40('0x1d')](respondWithResult(_0x251fb2,null))[_0x2c40('0x4a')](handleError(_0x251fb2,null));};exports[_0x2c40('0x130')]=function(_0x1c3dde,_0x34b547){return db['User'][_0x2c40('0x2c')]({'where':{'id':_0x1c3dde[_0x2c40('0x4c')]['id']}})[_0x2c40('0x1d')](handleEntityNotFound(_0x34b547,null))[_0x2c40('0x1d')](function(_0x575e63){if(_0x575e63){return _0x575e63[_0x2c40('0x130')](_0x1c3dde[_0x2c40('0x4f')][_0x2c40('0x51')],_[_0x2c40('0x52')](_0x1c3dde[_0x2c40('0x4f')],[_0x2c40('0x51'),'id'])||{});}})[_0x2c40('0x1d')](respondWithResult(_0x34b547,null))[_0x2c40('0x4a')](handleError(_0x34b547,null));};exports[_0x2c40('0x131')]=function(_0x3e8c77,_0x7669c2){return db[_0x2c40('0x31')][_0x2c40('0x2c')]({'where':{'id':_0x3e8c77[_0x2c40('0x4c')]['id']}})['then'](handleEntityNotFound(_0x7669c2,null))[_0x2c40('0x1d')](function(_0x1bc950){if(_0x1bc950){return _0x1bc950['removeFaxAccounts'](_0x3e8c77['query'][_0x2c40('0x51')]);}})[_0x2c40('0x1d')](respondWithStatusCode(_0x7669c2,null))[_0x2c40('0x4a')](handleError(_0x7669c2,null));};exports['getMailAccounts']=function(_0x3403c0,_0x4c3a21){var _0x95e4c={};var _0x4fbf41={};var _0x326543;var _0x3ace24;return db[_0x2c40('0x31')]['findOne']({'where':{'id':_0x3403c0[_0x2c40('0x4c')]['id']}})[_0x2c40('0x1d')](handleEntityNotFound(_0x4c3a21,null))['then'](function(_0xfd3b0){if(_0xfd3b0){_0x326543=_0xfd3b0;_0x4fbf41['model']=_['keys'](db[_0x2c40('0x132')][_0x2c40('0xc4')]);_0x4fbf41[_0x2c40('0x3a')]=_['keys'](_0x3403c0[_0x2c40('0x3a')]);_0x4fbf41[_0x2c40('0xc6')]=_['intersection'](_0x4fbf41['model'],_0x4fbf41[_0x2c40('0x3a')]);_0x95e4c[_0x2c40('0x40')]=_[_0x2c40('0xc7')](_0x4fbf41['model'],qs[_0x2c40('0xc8')](_0x3403c0[_0x2c40('0x3a')][_0x2c40('0xc8')]));_0x95e4c[_0x2c40('0x40')]=_0x95e4c[_0x2c40('0x40')][_0x2c40('0x5f')]?_0x95e4c[_0x2c40('0x40')]:_0x4fbf41['model'];_0x95e4c[_0x2c40('0xcf')]=qs['sort'](_0x3403c0['query'][_0x2c40('0xc9')]);_0x95e4c[_0x2c40('0x39')]=qs[_0x2c40('0xc6')](_[_0x2c40('0xca')](_0x3403c0[_0x2c40('0x3a')],_0x4fbf41[_0x2c40('0xc6')]));if(_0x3403c0[_0x2c40('0x3a')]['filter']){_0x95e4c[_0x2c40('0x39')]=_[_0x2c40('0xcb')](_0x95e4c[_0x2c40('0x39')],{'$or':_[_0x2c40('0x32')](_0x95e4c[_0x2c40('0x40')],function(_0x427022){var _0x161731={};_0x161731[_0x427022]={'$like':'%'+_0x3403c0[_0x2c40('0x3a')][_0x2c40('0x28')]+'%'};return _0x161731;})});}_0x95e4c=_['merge']({},_0x95e4c,_0x3403c0['options']);return _0x326543[_0x2c40('0x133')](_0x95e4c);}})[_0x2c40('0x1d')](function(_0x3c928f){if(_0x3c928f){_0x3ace24=_0x3c928f[_0x2c40('0x5f')];if(!_0x3403c0['query'][_0x2c40('0xcd')](_0x2c40('0xce'))){_0x95e4c[_0x2c40('0x19')]=qs['limit'](_0x3403c0[_0x2c40('0x3a')][_0x2c40('0x19')]);_0x95e4c[_0x2c40('0x17')]=qs[_0x2c40('0x17')](_0x3403c0[_0x2c40('0x3a')][_0x2c40('0x17')]);}return _0x326543[_0x2c40('0x133')](_0x95e4c);}})[_0x2c40('0x1d')](function(_0x59786a){if(_0x59786a){return _0x59786a?{'count':_0x3ace24,'rows':_0x59786a}:null;}})['then'](respondWithResult(_0x4c3a21,null))[_0x2c40('0x4a')](handleError(_0x4c3a21,null));};exports[_0x2c40('0x134')]=function(_0x442495,_0x53d5d4){return db['User']['find']({'where':{'id':_0x442495['params']['id']}})[_0x2c40('0x1d')](handleEntityNotFound(_0x53d5d4,null))['then'](function(_0x4abed8){if(_0x4abed8){return _0x4abed8['addMailAccounts'](_0x442495['body']['ids'],_[_0x2c40('0x52')](_0x442495[_0x2c40('0x4f')],[_0x2c40('0x51'),'id'])||{});}})[_0x2c40('0x1d')](respondWithResult(_0x53d5d4,null))[_0x2c40('0x4a')](handleError(_0x53d5d4,null));};exports['removeMailAccounts']=function(_0x48a9e1,_0x5a0e08){return db[_0x2c40('0x31')][_0x2c40('0x2c')]({'where':{'id':_0x48a9e1[_0x2c40('0x4c')]['id']}})[_0x2c40('0x1d')](handleEntityNotFound(_0x5a0e08,null))[_0x2c40('0x1d')](function(_0x199331){if(_0x199331){return _0x199331['removeMailAccounts'](_0x48a9e1[_0x2c40('0x3a')]['ids']);}})['then'](respondWithStatusCode(_0x5a0e08,null))[_0x2c40('0x4a')](handleError(_0x5a0e08,null));};exports[_0x2c40('0x135')]=function(_0x1dde19,_0x22dffc){var _0x45b78b={};var _0x4fe7b2={};var _0x152a59;var _0x1c1b24;return db['User']['findOne']({'where':{'id':_0x1dde19[_0x2c40('0x4c')]['id']}})[_0x2c40('0x1d')](handleEntityNotFound(_0x22dffc,null))['then'](function(_0x3bc772){if(_0x3bc772){_0x152a59=_0x3bc772;_0x4fe7b2[_0x2c40('0xc2')]=_[_0x2c40('0xc5')](db[_0x2c40('0x136')][_0x2c40('0xc4')]);_0x4fe7b2[_0x2c40('0x3a')]=_[_0x2c40('0xc5')](_0x1dde19[_0x2c40('0x3a')]);_0x4fe7b2[_0x2c40('0xc6')]=_[_0x2c40('0xc7')](_0x4fe7b2[_0x2c40('0xc2')],_0x4fe7b2[_0x2c40('0x3a')]);_0x45b78b[_0x2c40('0x40')]=_['intersection'](_0x4fe7b2[_0x2c40('0xc2')],qs[_0x2c40('0xc8')](_0x1dde19['query']['fields']));_0x45b78b['attributes']=_0x45b78b[_0x2c40('0x40')][_0x2c40('0x5f')]?_0x45b78b[_0x2c40('0x40')]:_0x4fe7b2[_0x2c40('0xc2')];_0x45b78b[_0x2c40('0xcf')]=qs[_0x2c40('0xc9')](_0x1dde19[_0x2c40('0x3a')][_0x2c40('0xc9')]);_0x45b78b[_0x2c40('0x39')]=qs[_0x2c40('0xc6')](_[_0x2c40('0xca')](_0x1dde19['query'],_0x4fe7b2[_0x2c40('0xc6')]));if(_0x1dde19[_0x2c40('0x3a')][_0x2c40('0x28')]){_0x45b78b[_0x2c40('0x39')]=_['merge'](_0x45b78b[_0x2c40('0x39')],{'$or':_[_0x2c40('0x32')](_0x45b78b[_0x2c40('0x40')],function(_0x54b030){var _0x330bf1={};_0x330bf1[_0x54b030]={'$like':'%'+_0x1dde19[_0x2c40('0x3a')]['filter']+'%'};return _0x330bf1;})});}_0x45b78b=_[_0x2c40('0xcb')]({},_0x45b78b,_0x1dde19[_0x2c40('0x4d')]);return _0x152a59['getOpenchannelAccounts'](_0x45b78b);}})[_0x2c40('0x1d')](function(_0x439bd7){if(_0x439bd7){_0x1c1b24=_0x439bd7['length'];if(!_0x1dde19[_0x2c40('0x3a')][_0x2c40('0xcd')](_0x2c40('0xce'))){_0x45b78b[_0x2c40('0x19')]=qs[_0x2c40('0x19')](_0x1dde19['query'][_0x2c40('0x19')]);_0x45b78b['offset']=qs[_0x2c40('0x17')](_0x1dde19[_0x2c40('0x3a')]['offset']);}return _0x152a59[_0x2c40('0x135')](_0x45b78b);}})[_0x2c40('0x1d')](function(_0xeb6950){if(_0xeb6950){return _0xeb6950?{'count':_0x1c1b24,'rows':_0xeb6950}:null;}})[_0x2c40('0x1d')](respondWithResult(_0x22dffc,null))[_0x2c40('0x4a')](handleError(_0x22dffc,null));};exports[_0x2c40('0x137')]=function(_0x25354b,_0x593499){return db['User']['find']({'where':{'id':_0x25354b[_0x2c40('0x4c')]['id']}})[_0x2c40('0x1d')](handleEntityNotFound(_0x593499,null))['then'](function(_0x4e943b){if(_0x4e943b){return _0x4e943b[_0x2c40('0x137')](_0x25354b[_0x2c40('0x4f')]['ids'],_['omit'](_0x25354b[_0x2c40('0x4f')],[_0x2c40('0x51'),'id'])||{});}})[_0x2c40('0x1d')](respondWithResult(_0x593499,null))['catch'](handleError(_0x593499,null));};exports[_0x2c40('0x138')]=function(_0x3462fc,_0x2d590a){return db[_0x2c40('0x31')][_0x2c40('0x2c')]({'where':{'id':_0x3462fc[_0x2c40('0x4c')]['id']}})['then'](handleEntityNotFound(_0x2d590a,null))[_0x2c40('0x1d')](function(_0x313418){if(_0x313418){return _0x313418['removeOpenchannelAccounts'](_0x3462fc[_0x2c40('0x3a')][_0x2c40('0x51')]);}})['then'](respondWithStatusCode(_0x2d590a,null))[_0x2c40('0x4a')](handleError(_0x2d590a,null));};exports['getSmsAccounts']=function(_0x289325,_0xc0dbc4){var _0x48667a={};var _0x5a50e5={};var _0xfb4130;var _0x3befc1;return db[_0x2c40('0x31')]['findOne']({'where':{'id':_0x289325[_0x2c40('0x4c')]['id']}})[_0x2c40('0x1d')](handleEntityNotFound(_0xc0dbc4,null))['then'](function(_0x55f590){if(_0x55f590){_0xfb4130=_0x55f590;_0x5a50e5[_0x2c40('0xc2')]=_[_0x2c40('0xc5')](db[_0x2c40('0x139')]['rawAttributes']);_0x5a50e5[_0x2c40('0x3a')]=_[_0x2c40('0xc5')](_0x289325[_0x2c40('0x3a')]);_0x5a50e5[_0x2c40('0xc6')]=_['intersection'](_0x5a50e5['model'],_0x5a50e5[_0x2c40('0x3a')]);_0x48667a[_0x2c40('0x40')]=_['intersection'](_0x5a50e5[_0x2c40('0xc2')],qs[_0x2c40('0xc8')](_0x289325['query']['fields']));_0x48667a[_0x2c40('0x40')]=_0x48667a[_0x2c40('0x40')][_0x2c40('0x5f')]?_0x48667a[_0x2c40('0x40')]:_0x5a50e5[_0x2c40('0xc2')];_0x48667a[_0x2c40('0xcf')]=qs[_0x2c40('0xc9')](_0x289325[_0x2c40('0x3a')][_0x2c40('0xc9')]);_0x48667a['where']=qs[_0x2c40('0xc6')](_[_0x2c40('0xca')](_0x289325[_0x2c40('0x3a')],_0x5a50e5[_0x2c40('0xc6')]));if(_0x289325[_0x2c40('0x3a')][_0x2c40('0x28')]){_0x48667a[_0x2c40('0x39')]=_[_0x2c40('0xcb')](_0x48667a[_0x2c40('0x39')],{'$or':_[_0x2c40('0x32')](_0x48667a['attributes'],function(_0x2cb136){var _0x51aced={};_0x51aced[_0x2cb136]={'$like':'%'+_0x289325['query'][_0x2c40('0x28')]+'%'};return _0x51aced;})});}_0x48667a=_['merge']({},_0x48667a,_0x289325[_0x2c40('0x4d')]);return _0xfb4130['getSmsAccounts'](_0x48667a);}})[_0x2c40('0x1d')](function(_0x28c6e5){if(_0x28c6e5){_0x3befc1=_0x28c6e5[_0x2c40('0x5f')];if(!_0x289325['query']['hasOwnProperty']('nolimit')){_0x48667a[_0x2c40('0x19')]=qs[_0x2c40('0x19')](_0x289325['query'][_0x2c40('0x19')]);_0x48667a[_0x2c40('0x17')]=qs['offset'](_0x289325[_0x2c40('0x3a')]['offset']);}return _0xfb4130[_0x2c40('0x13a')](_0x48667a);}})[_0x2c40('0x1d')](function(_0x1ce38a){if(_0x1ce38a){return _0x1ce38a?{'count':_0x3befc1,'rows':_0x1ce38a}:null;}})[_0x2c40('0x1d')](respondWithResult(_0xc0dbc4,null))[_0x2c40('0x4a')](handleError(_0xc0dbc4,null));};exports['addSmsAccounts']=function(_0x3ea1f3,_0x556e27){return db[_0x2c40('0x31')][_0x2c40('0x2c')]({'where':{'id':_0x3ea1f3[_0x2c40('0x4c')]['id']}})['then'](handleEntityNotFound(_0x556e27,null))['then'](function(_0x4f2400){if(_0x4f2400){return _0x4f2400[_0x2c40('0x13b')](_0x3ea1f3[_0x2c40('0x4f')][_0x2c40('0x51')],_[_0x2c40('0x52')](_0x3ea1f3[_0x2c40('0x4f')],[_0x2c40('0x51'),'id'])||{});}})[_0x2c40('0x1d')](respondWithResult(_0x556e27,null))[_0x2c40('0x4a')](handleError(_0x556e27,null));};exports[_0x2c40('0x13c')]=function(_0x16a81c,_0x43298c){return db[_0x2c40('0x31')][_0x2c40('0x2c')]({'where':{'id':_0x16a81c[_0x2c40('0x4c')]['id']}})[_0x2c40('0x1d')](handleEntityNotFound(_0x43298c,null))[_0x2c40('0x1d')](function(_0x2772c9){if(_0x2772c9){return _0x2772c9['removeSmsAccounts'](_0x16a81c['query'][_0x2c40('0x51')]);}})[_0x2c40('0x1d')](respondWithStatusCode(_0x43298c,null))[_0x2c40('0x4a')](handleError(_0x43298c,null));};exports['getChatWebsites']=function(_0x3dc93c,_0xfb93a){var _0x5056de={};var _0x3bd1ef={};var _0x5be01e;var _0x3c54e5;return db[_0x2c40('0x31')][_0x2c40('0x8b')]({'where':{'id':_0x3dc93c['params']['id']}})['then'](handleEntityNotFound(_0xfb93a,null))['then'](function(_0x2af38b){if(_0x2af38b){_0x5be01e=_0x2af38b;_0x3bd1ef[_0x2c40('0xc2')]=_['keys'](db['ChatWebsite'][_0x2c40('0xc4')]);_0x3bd1ef['query']=_[_0x2c40('0xc5')](_0x3dc93c['query']);_0x3bd1ef[_0x2c40('0xc6')]=_[_0x2c40('0xc7')](_0x3bd1ef[_0x2c40('0xc2')],_0x3bd1ef[_0x2c40('0x3a')]);_0x5056de[_0x2c40('0x40')]=_[_0x2c40('0xc7')](_0x3bd1ef[_0x2c40('0xc2')],qs[_0x2c40('0xc8')](_0x3dc93c['query']['fields']));_0x5056de[_0x2c40('0x40')]=_0x5056de['attributes'][_0x2c40('0x5f')]?_0x5056de[_0x2c40('0x40')]:_0x3bd1ef[_0x2c40('0xc2')];_0x5056de[_0x2c40('0xcf')]=qs[_0x2c40('0xc9')](_0x3dc93c['query'][_0x2c40('0xc9')]);_0x5056de[_0x2c40('0x39')]=qs[_0x2c40('0xc6')](_['pick'](_0x3dc93c[_0x2c40('0x3a')],_0x3bd1ef['filters']));if(_0x3dc93c['query'][_0x2c40('0x28')]){_0x5056de[_0x2c40('0x39')]=_[_0x2c40('0xcb')](_0x5056de[_0x2c40('0x39')],{'$or':_[_0x2c40('0x32')](_0x5056de[_0x2c40('0x40')],function(_0x54c74d){var _0x394048={};_0x394048[_0x54c74d]={'$like':'%'+_0x3dc93c['query']['filter']+'%'};return _0x394048;})});}_0x5056de=_['merge']({},_0x5056de,_0x3dc93c[_0x2c40('0x4d')]);return _0x5be01e[_0x2c40('0x13d')](_0x5056de);}})[_0x2c40('0x1d')](function(_0x35caf3){if(_0x35caf3){_0x3c54e5=_0x35caf3['length'];if(!_0x3dc93c['query']['hasOwnProperty']('nolimit')){_0x5056de[_0x2c40('0x19')]=qs[_0x2c40('0x19')](_0x3dc93c[_0x2c40('0x3a')]['limit']);_0x5056de['offset']=qs['offset'](_0x3dc93c[_0x2c40('0x3a')][_0x2c40('0x17')]);}return _0x5be01e[_0x2c40('0x13d')](_0x5056de);}})['then'](function(_0x19c4f5){if(_0x19c4f5){return _0x19c4f5?{'count':_0x3c54e5,'rows':_0x19c4f5}:null;}})[_0x2c40('0x1d')](respondWithResult(_0xfb93a,null))[_0x2c40('0x4a')](handleError(_0xfb93a,null));};exports[_0x2c40('0x13e')]=function(_0x42aea0,_0xa762c8){return db['User']['find']({'where':{'id':_0x42aea0[_0x2c40('0x4c')]['id']}})['then'](handleEntityNotFound(_0xa762c8,null))['then'](function(_0x521a90){if(_0x521a90){return _0x521a90[_0x2c40('0x13e')](_0x42aea0['body']['ids'],_[_0x2c40('0x52')](_0x42aea0['body'],['ids','id'])||{});}})['then'](respondWithResult(_0xa762c8,null))[_0x2c40('0x4a')](handleError(_0xa762c8,null));};exports[_0x2c40('0x13f')]=function(_0x456b38,_0xc12026){return db['User']['find']({'where':{'id':_0x456b38[_0x2c40('0x4c')]['id']}})[_0x2c40('0x1d')](handleEntityNotFound(_0xc12026,null))[_0x2c40('0x1d')](function(_0x393ca2){if(_0x393ca2){return _0x393ca2[_0x2c40('0x13f')](_0x456b38[_0x2c40('0x3a')][_0x2c40('0x51')]);}})[_0x2c40('0x1d')](respondWithStatusCode(_0xc12026,null))['catch'](handleError(_0xc12026,null));};exports[_0x2c40('0x140')]=function(_0x1ad8db,_0x183520){var _0x2d000f={};var _0x463400={};var _0x44584a;var _0x39cfa7;return db[_0x2c40('0x31')][_0x2c40('0x8b')]({'where':{'id':_0x1ad8db[_0x2c40('0x4c')]['id']}})[_0x2c40('0x1d')](handleEntityNotFound(_0x183520,null))['then'](function(_0x43057b){if(_0x43057b){_0x44584a=_0x43057b;_0x463400[_0x2c40('0xc2')]=_[_0x2c40('0xc5')](db['WhatsappAccount'][_0x2c40('0xc4')]);_0x463400[_0x2c40('0x3a')]=_[_0x2c40('0xc5')](_0x1ad8db['query']);_0x463400[_0x2c40('0xc6')]=_['intersection'](_0x463400['model'],_0x463400[_0x2c40('0x3a')]);_0x2d000f['attributes']=_[_0x2c40('0xc7')](_0x463400['model'],qs['fields'](_0x1ad8db[_0x2c40('0x3a')][_0x2c40('0xc8')]));_0x2d000f[_0x2c40('0x40')]=_0x2d000f[_0x2c40('0x40')][_0x2c40('0x5f')]?_0x2d000f[_0x2c40('0x40')]:_0x463400['model'];_0x2d000f[_0x2c40('0xcf')]=qs['sort'](_0x1ad8db[_0x2c40('0x3a')][_0x2c40('0xc9')]);_0x2d000f[_0x2c40('0x39')]=qs[_0x2c40('0xc6')](_[_0x2c40('0xca')](_0x1ad8db[_0x2c40('0x3a')],_0x463400[_0x2c40('0xc6')]));if(_0x1ad8db[_0x2c40('0x3a')][_0x2c40('0x28')]){_0x2d000f['where']=_[_0x2c40('0xcb')](_0x2d000f['where'],{'$or':_[_0x2c40('0x32')](_0x2d000f['attributes'],function(_0x381837){var _0x49d009={};_0x49d009[_0x381837]={'$like':'%'+_0x1ad8db['query'][_0x2c40('0x28')]+'%'};return _0x49d009;})});}_0x2d000f=_[_0x2c40('0xcb')]({},_0x2d000f,_0x1ad8db[_0x2c40('0x4d')]);return _0x44584a['getWhatsappAccounts'](_0x2d000f);}})[_0x2c40('0x1d')](function(_0x27e1c3){if(_0x27e1c3){_0x39cfa7=_0x27e1c3[_0x2c40('0x5f')];if(!_0x1ad8db['query']['hasOwnProperty'](_0x2c40('0xce'))){_0x2d000f['limit']=qs[_0x2c40('0x19')](_0x1ad8db[_0x2c40('0x3a')]['limit']);_0x2d000f[_0x2c40('0x17')]=qs['offset'](_0x1ad8db[_0x2c40('0x3a')]['offset']);}return _0x44584a[_0x2c40('0x140')](_0x2d000f);}})[_0x2c40('0x1d')](function(_0x549607){if(_0x549607){return _0x549607?{'count':_0x39cfa7,'rows':_0x549607}:null;}})[_0x2c40('0x1d')](respondWithResult(_0x183520,null))[_0x2c40('0x4a')](handleError(_0x183520,null));};exports[_0x2c40('0x141')]=function(_0x499aaf,_0x22d006){return db[_0x2c40('0x31')][_0x2c40('0x2c')]({'where':{'id':_0x499aaf[_0x2c40('0x4c')]['id']}})[_0x2c40('0x1d')](handleEntityNotFound(_0x22d006,null))[_0x2c40('0x1d')](function(_0x3ec36d){if(_0x3ec36d){return _0x3ec36d[_0x2c40('0x141')](_0x499aaf[_0x2c40('0x4f')]['ids'],_[_0x2c40('0x52')](_0x499aaf[_0x2c40('0x4f')],[_0x2c40('0x51'),'id'])||{});}})[_0x2c40('0x1d')](respondWithResult(_0x22d006,null))['catch'](handleError(_0x22d006,null));};exports['removeWhatsappAccounts']=function(_0x3617ae,_0x18064e){return db['User'][_0x2c40('0x2c')]({'where':{'id':_0x3617ae['params']['id']}})['then'](handleEntityNotFound(_0x18064e,null))[_0x2c40('0x1d')](function(_0x31e4f8){if(_0x31e4f8){return _0x31e4f8[_0x2c40('0x142')](_0x3617ae[_0x2c40('0x3a')][_0x2c40('0x51')]);}})[_0x2c40('0x1d')](respondWithStatusCode(_0x18064e,null))[_0x2c40('0x4a')](handleError(_0x18064e,null));};exports[_0x2c40('0x143')]=function(_0x494dd0,_0x57e29e){var _0x2a1abc={},_0x2fdceb={},_0x47e46d={'count':0x0,'rows':[]};var _0x5379a1=db[_0x2c40('0x144')][_0x2c40('0xc4')];_0x2fdceb[_0x2c40('0xc2')]=_['keys'](_0x5379a1);_0x2fdceb[_0x2c40('0x3a')]=_[_0x2c40('0xc5')](_0x494dd0['query']);_0x2fdceb[_0x2c40('0xc6')]=_[_0x2c40('0xc7')](_0x2fdceb[_0x2c40('0xc2')],_0x2fdceb[_0x2c40('0x3a')]);_0x2fdceb['filters']=_[_0x2c40('0x145')](_0x2fdceb[_0x2c40('0xc6')],[_0x2c40('0x146'),_0x2c40('0x147'),_0x2c40('0x148'),'$gte',_0x2c40('0x149'),_0x2c40('0x14a'),_0x2c40('0x14b'),_0x2c40('0x14c'),_0x2c40('0x14d'),_0x2c40('0x14e'),_0x2c40('0x14f'),'$in',_0x2c40('0x150'),_0x2c40('0x151'),_0x2c40('0x152'),_0x2c40('0x153'),_0x2c40('0x154'),_0x2c40('0x151'),_0x2c40('0x155'),_0x2c40('0x156'),_0x2c40('0x157'),'$any']);_0x2a1abc[_0x2c40('0x40')]=_[_0x2c40('0xc7')](_0x2fdceb[_0x2c40('0xc2')],qs[_0x2c40('0xc8')](_0x494dd0[_0x2c40('0x3a')][_0x2c40('0xc8')]));_0x2a1abc['attributes']=_0x2a1abc[_0x2c40('0x40')]['length']?_0x2a1abc[_0x2c40('0x40')]:_0x2fdceb[_0x2c40('0xc2')];if(!_0x494dd0[_0x2c40('0x3a')][_0x2c40('0xcd')](_0x2c40('0xce'))){_0x2a1abc[_0x2c40('0x19')]=qs[_0x2c40('0x19')](_0x494dd0['query'][_0x2c40('0x19')]);_0x2a1abc[_0x2c40('0x17')]=qs[_0x2c40('0x17')](_0x494dd0[_0x2c40('0x3a')][_0x2c40('0x17')]);}_0x2a1abc[_0x2c40('0xcf')]=qs['sort'](_0x494dd0[_0x2c40('0x3a')][_0x2c40('0xc9')]);_0x2a1abc[_0x2c40('0x39')]=qs['filters'](_['pick'](_0x494dd0['query'],_0x2fdceb[_0x2c40('0xc6')]));if(_0x494dd0[_0x2c40('0x3a')]['filter']){_0x2a1abc[_0x2c40('0x39')]=_[_0x2c40('0xcb')](_0x2a1abc[_0x2c40('0x39')],{'$or':_[_0x2c40('0x32')](_0x2a1abc[_0x2c40('0x40')],function(_0x2214ea){var _0xc49820={};_0xc49820[_0x2214ea]={'$like':'%'+_0x494dd0[_0x2c40('0x3a')][_0x2c40('0x28')]+'%'};return _0xc49820;})});}_0x2a1abc[_0x2c40('0x39')]={'$and':[_0x2a1abc[_0x2c40('0x39')],{'$or':[{'UserId':_0x494dd0[_0x2c40('0x4c')]['id']},{'OwnerId':_0x494dd0[_0x2c40('0x4c')]['id']}]}]};_0x2a1abc=_[_0x2c40('0xcb')]({},_0x2a1abc,_0x494dd0['options']);var _0x2f97d2={'where':_0x2a1abc[_0x2c40('0x39')]};return db[_0x2c40('0x144')][_0x2c40('0x1a')](_0x2f97d2)[_0x2c40('0x1d')](function(_0x260000){_0x47e46d[_0x2c40('0x1a')]=_0x260000;if(_0x494dd0[_0x2c40('0x3a')][_0x2c40('0x3b')]){_0x2a1abc['include']=[{'attributes':['id',_0x2c40('0x158'),_0x2c40('0x159'),_0x2c40('0xe3')],'model':db['CmContact'],'as':_0x2c40('0x15a')},{'attributes':['id',_0x2c40('0x2f'),_0x2c40('0x15b')],'model':db[_0x2c40('0x15c')],'as':_0x2c40('0xc3')}];}return db['CmHopper'][_0x2c40('0x42')](_0x2a1abc);})[_0x2c40('0x1d')](function(_0xfa2806){_0x47e46d[_0x2c40('0x43')]=_0xfa2806;return _0x47e46d;})[_0x2c40('0x1d')](respondWithFilteredResult(_0x57e29e,_0x2a1abc))[_0x2c40('0x4a')](handleError(_0x57e29e,null));};exports[_0x2c40('0x15d')]=function(_0x25f0e4,_0x2d984b){if(!_[_0x2c40('0x59')](_0x25f0e4[_0x2c40('0x75')]['id'])&&(_0x25f0e4[_0x2c40('0x75')]['role']==_0x2c40('0x23')||_0x25f0e4['user']['role']==_0x2c40('0x75'))){return db[_0x2c40('0x31')][_0x2c40('0x8b')]({'where':{'id':_0x25f0e4[_0x2c40('0x4c')]['id']},'raw':!![]})['then'](function(_0x276d1e){return authService['retrieveApiKey'](_0x276d1e);})[_0x2c40('0x1d')](function(_0x1e0ba8){if(_0x1e0ba8){return _0x2d984b[_0x2c40('0x15')](0xc8)[_0x2c40('0x1b')]({'api_key':_0x1e0ba8[_0x2c40('0x15e')]});}else{return _0x2d984b[_0x2c40('0x15')](0xcc)['json']({'message':_0x2c40('0x15f')});}})[_0x2c40('0x4a')](handleError(_0x2d984b,0x193));}else{return _0x2d984b['status'](0x191)['json']({'message':_0x2c40('0x160')});}};exports[_0x2c40('0x161')]=function(_0x38ec8e,_0x32b6f7){if(!_['isNil'](_0x38ec8e[_0x2c40('0x75')]['id'])&&(_0x38ec8e[_0x2c40('0x75')][_0x2c40('0x22')]==_0x2c40('0x23')||_0x38ec8e[_0x2c40('0x75')]['role']=='user')){return db[_0x2c40('0x31')][_0x2c40('0x2c')]({'where':{'id':_0x38ec8e[_0x2c40('0x4c')]['id']}})['then'](function(_0x442796){return authService[_0x2c40('0x162')](_0x442796);})[_0x2c40('0x1d')](function(_0x243710){return db[_0x2c40('0x31')]['update']({'apiKeyIat':_0x243710['iat'],'apiKeyNonce':_0x243710[_0x2c40('0x163')]},{'where':{'id':_0x38ec8e['params']['id']}})[_0x2c40('0x1d')](function(){return _0x32b6f7[_0x2c40('0x15')](0xc8)['json']({'api_key':_0x243710[_0x2c40('0x15e')]});});})[_0x2c40('0x4a')](handleError(_0x32b6f7,0x193));}else{return _0x32b6f7[_0x2c40('0x15')](0x191)[_0x2c40('0x1b')]({'message':_0x2c40('0x160')});}};exports[_0x2c40('0x164')]=function(_0xabfe28,_0x8065b9){if(!_['isNil'](_0xabfe28[_0x2c40('0x75')]['id'])&&(_0xabfe28[_0x2c40('0x75')]['role']==_0x2c40('0x23')||_0xabfe28[_0x2c40('0x75')]['role']==_0x2c40('0x75'))){return db[_0x2c40('0x31')]['find']({'where':{'id':_0xabfe28[_0x2c40('0x4c')]['id']}})[_0x2c40('0x1d')](handleEntityNotFound(_0x8065b9,null))[_0x2c40('0x1d')](function(_0x337f8f){if(_0x337f8f&&_0x337f8f[_0x2c40('0x165')]&&_0x337f8f[_0x2c40('0x166')])return _0x337f8f;else throw{'message':_0x2c40('0x167')};})[_0x2c40('0x1d')](function(){return db[_0x2c40('0x31')][_0x2c40('0x1c')]({'apiKeyNonce':null,'apiKeyIat':null},{'where':{'id':_0xabfe28[_0x2c40('0x4c')]['id']}});})[_0x2c40('0x1d')](respondWithStatusCode(_0x8065b9,0xc8))[_0x2c40('0x4a')](handleError(_0x8065b9,0x193));}else{return _0x8065b9[_0x2c40('0x15')](0x191)[_0x2c40('0x1b')]({'message':_0x2c40('0x160')});}};exports[_0x2c40('0x168')]=function(_0x55f8b4,_0x1ddd45){var _0x5d5038=_0x55f8b4[_0x2c40('0x75')][_0x2c40('0x21')]({'plain':!![]});if(!_0x5d5038){return _0x1ddd45['status'](0x191)[_0x2c40('0x30')](_0x2c40('0x169'));}else{Promise[_0x2c40('0xf3')]()[_0x2c40('0x1d')](function(){if(_0x55f8b4[_0x2c40('0x3a')][_0x2c40('0x3f')]!==_0x2c40('0x3d'))return;return _0x55f8b4[_0x2c40('0x75')][_0x2c40('0x16a')]();})[_0x2c40('0x1d')](function(_0x509323){if(!_0x509323)return;return _0x509323[_0x2c40('0x21')]({'plain':!![]});})[_0x2c40('0x1d')](function(_0x2c44b1){_0x5d5038[_0x2c40('0x3f')]=_0x2c44b1;return _0x1ddd45[_0x2c40('0x15')](0xc8)[_0x2c40('0x1b')](_0x5d5038);});}};exports[_0x2c40('0x16b')]=function(_0x18bdbd,_0x1afae0){var _0x539f41={'offset':0x0};var _0x43bb34={'count':0x0,'rows':[]};var _0x5b52fc=[_0x2c40('0x16c'),_0x2c40('0x16d'),_0x2c40('0x16e')];var _0x1014ee=[];var _0x499828=[];var _0x251b42=[];var _0x56e427=_0x18bdbd[_0x2c40('0x3a')][_0x2c40('0x16f')];var _0x392643=_0x18bdbd['query'][_0x2c40('0x170')];var _0x13e707=_0x18bdbd[_0x2c40('0x3a')][_0x2c40('0x28')];return Promise[_0x2c40('0xf3')]()[_0x2c40('0x1d')](function(){if(!_0x56e427){return[];}return db[_0x2c40('0x102')]['findAll']({'attributes':['id',_0x2c40('0x2f')],'where':{'id':_0x56e427}});})[_0x2c40('0x1d')](function(_0x6e23a5){_0x251b42=_0x6e23a5;if(!_0x392643){return[];}return db[_0x2c40('0x15c')][_0x2c40('0x42')]({'attributes':['id',_0x2c40('0x2f')],'type':_0x2c40('0x171'),'where':{'id':_0x392643}});})['then'](function(_0x8f7d8a){_0x499828=_0x8f7d8a;var _0x5b9074=_0x251b42['concat'](_0x499828)[_0x2c40('0x32')](function(_0x576c21){return _0x576c21[_0x2c40('0x113')]({'attributes':['id','name',_0x2c40('0x53'),_0x2c40('0x93')],'raw':!![]});});return Promise[_0x2c40('0x49')](_0x5b9074);})[_0x2c40('0x1d')](function(_0x15d319){var _0xe26b89=_[_0x2c40('0x172')](_0x15d319);if(_0x13e707){if(_0x392643||_0x56e427){return _0xe26b89[_0x2c40('0x28')](function(_0x405363){return _0x405363['name'][_0x2c40('0x9a')]()[_0x2c40('0x2b')](_0x13e707[_0x2c40('0x9a')]())||_0x405363[_0x2c40('0x53')][_0x2c40('0x173')]()['includes'](_0x13e707);});}else{return db[_0x2c40('0x31')][_0x2c40('0x42')]({'attributes':['id',_0x2c40('0x2f'),_0x2c40('0x53'),_0x2c40('0x93')],'where':{'role':_0x2c40('0x1e'),'$or':[db[_0x2c40('0x5b')][_0x2c40('0x39')](db[_0x2c40('0x5b')]['fn'](_0x2c40('0x174'),db[_0x2c40('0x5b')][_0x2c40('0x175')]('name')),{'$like':'%'+_0x13e707[_0x2c40('0x9a')]()+'%'}),{'internal':{'$like':'%'+_0x13e707+'%'}}]},'raw':!![]});}}else{return _0xe26b89;}})['then'](function(_0x462bbe){var _0x2c12e6='name';var _0x2c02e8=_0x2c40('0x176');if(_0x18bdbd['query'][_0x2c40('0xc9')]){_0x2c02e8=_0x18bdbd[_0x2c40('0x3a')]['sort'][0x0]==='-'?'desc':_0x2c40('0x176');_0x2c12e6=_0x2c02e8===_0x2c40('0x176')?_0x18bdbd['query']['sort']:_0x18bdbd[_0x2c40('0x3a')][_0x2c40('0xc9')][_0x2c40('0x177')](0x1);}return _(_0x462bbe)[_0x2c40('0x178')]('id')['orderBy']([function(_0x26d183){return _0x2c12e6===_0x2c40('0x2f')?_0x26d183[_0x2c12e6][_0x2c40('0x9a')]():_0x26d183[_0x2c12e6];}],[_0x2c02e8])[_0x2c40('0x32')](function(_0x6eb019){return _[_0x2c40('0xca')](_0x6eb019,['id',_0x2c40('0x2f'),_0x2c40('0x53'),_0x2c40('0x93')]);})[_0x2c40('0x2a')]();})[_0x2c40('0x1d')](function(_0x5213c2){_0x1014ee=_0x5213c2;return rta['getRealtimeAgents']();})[_0x2c40('0x1d')](function(_0x56dbf7){return _0x1014ee['map'](function(_0x35df21){var _0x2270ef=_[_0x2c40('0x2c')](_0x56dbf7['rows'],['id',_0x35df21['id']]);if(!_0x2270ef||!_0x35df21[_0x2c40('0x93')]){_0x35df21[_0x2c40('0x15')]=_0x2c40('0x179');}else if(_0x2270ef['voicePause']){_0x35df21[_0x2c40('0x15')]='pause';}else if(_0x2270ef[_0x2c40('0x17a')]==='unavailable'||!_0x2270ef[_0x2c40('0x17a')]){_0x35df21[_0x2c40('0x15')]=_0x2c40('0x17b');}else{_0x35df21[_0x2c40('0x15')]=_0x5b52fc[_0x2c40('0x2b')](_0x2270ef[_0x2c40('0x17a')])?_0x2c40('0x93'):'busy';}return _0x35df21;});})[_0x2c40('0x1d')](function(_0x57f69b){if(!_0x18bdbd['query'][_0x2c40('0xcd')]('nolimit')){_0x539f41[_0x2c40('0x19')]=qs['limit'](_0x18bdbd[_0x2c40('0x3a')][_0x2c40('0x19')]||0xa);_0x539f41['offset']=qs[_0x2c40('0x17')](_0x18bdbd[_0x2c40('0x3a')][_0x2c40('0x17')]);}_0x43bb34[_0x2c40('0x1a')]=_0x57f69b[_0x2c40('0x5f')];_0x43bb34[_0x2c40('0x43')]=_0x539f41[_0x2c40('0x19')]?_0x57f69b[_0x2c40('0x17c')](_0x539f41[_0x2c40('0x17')],_0x539f41[_0x2c40('0x17')]+_0x539f41['limit']):_0x57f69b;return _0x43bb34;})['then'](respondWithFilteredResult(_0x1afae0,_0x539f41))['catch'](handleError(_0x1afae0,null));};function get_open_tabs(_0x3ddfba,_0x2d0624){var _0xab33d9=_0x3ddfba['charAt'](0x0)[_0x2c40('0x17d')]()+_0x3ddfba['slice'](0x1);var _0x47c59b={'type':db[_0x2c40('0x88')][_0x2c40('0x5d')][_0x2c40('0x5e')],'raw':!![]};return new Promise(function(_0x237ee0,_0x46bee3){var _0x1170f6=squel[_0x2c40('0x17e')]()['field']('ui.'+_0xab33d9+_0x2c40('0x17f'),'id')['field'](_0x2c40('0x180'))[_0x2c40('0x60')](_0x2c40('0x181')+_0x3ddfba+'_interactions','ui')['where'](_0x2c40('0x182'),_0x2d0624['id']);return db['sequelize']['query'](_0x1170f6[_0x2c40('0x173')](),_0x47c59b)[_0x2c40('0x1d')](function(_0x2373b2){_0x2d0624[_0xab33d9+_0x2c40('0x183')]=_0x2373b2;_0x237ee0(_0x2373b2);})[_0x2c40('0x4a')](function(_0xecb741){_0x46bee3(_0xecb741);});});}exports[_0x2c40('0x184')]=function(_0x2f0cc5,_0x3ea485){var _0x5b2641=_0x2f0cc5[_0x2c40('0x4c')]['id'];var _0x5bba85=_0x2f0cc5[_0x2c40('0x4f')]['enabled'];return db['User'][_0x2c40('0x1c')]({'messengerSoundNotification':_0x5bba85},{'where':{'id':_0x5b2641}})[_0x2c40('0x1d')](respondWithStatusCode(_0x3ea485,null))[_0x2c40('0x4a')](handleError(_0x3ea485,null));};
\ No newline at end of file