Built motion from commit (unavailable).|2.5.14
[motion2.git] / server / api / user / user.controller.js
index 1ef7379..5cee5da 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xb7ff=['getTeams','addTeams','omit','setDataValue','Voice','getChatQueues','Chat','Mail','Sms','Whatsapp','getFaxQueues','Fax','getOpenchannelQueues','Openchannel','flatten','transaction','addAgent','getDataValue','removeTeams','getVoiceQueues','getMailQueues','getSmsQueues','Queue:remove','getLists','values','You\x20can\x27t\x20delete\x20yourself','addChatInteractions','user_has_chat_interactions:save','removeChatInteractions','isArray','user_has_chat_interactions:remove','addMailInteractions','user_has_mail_interactions:save','removeMailInteractions','user_has_mail_interactions:remove','addFaxInteractions','removeFaxInteractions','user_has_fax_interactions:remove','addSmsInteractions','removeSmsInteractions','user_has_sms_interactions:remove','addOpenchannelInteractions','removeOpenchannelInteractions','user_has_openchannel_interactions:remove','addWhatsappInteractions','user_has_whatsapp_interactions:save','removeWhatsappInteractions','VoicePrefix','getVoicePrefixes','getFaxAccounts','FaxAccount','addFaxAccounts','removeFaxAccounts','getMailAccounts','addMailAccounts','removeMailAccounts','getOpenchannelAccounts','OpenchannelAccount','addOpenchannelAccounts','removeOpenchannelAccounts','getSmsAccounts','SmsAccount','removeSmsAccounts','getChatWebsites','ChatWebsite','addChatWebsites','removeChatWebsites','getWhatsappAccounts','WhatsappAccount','addWhatsappAccounts','removeWhatsappAccounts','getSquareProjects','SquareProject','getScheduledCalls','CmHopper','concat','$and','$or','$gt','$gte','$lt','$lte','$ne','$eq','$not','$notBetween','$notIn','$like','$notLike','$iLike','$notILike','$overlap','$contains','$contained','$any','firstName','lastName','Contact','dialActive','getApiKey','retrieveApiKey','No\x20API\x20access\x20key\x20found!','You\x20don\x27t\x20have\x20sufficient\x20privileges\x20to\x20access\x20this\x20resource.','createApiKey','nonce','token','removeApiKey','apiKeyNonce','whoami','Unable\x20to\x20retrieve\x20the\x20current\x20user','html-pdf','rimraf','zip-dir','fast-json-patch','moment','mustache','util','sox','to-csv','lodash','crypto','jsforce','../../components/auth/service','../../config/license/hardware','../../config/logger','../../config/utils','../../config/license/util','../../mysqldb','redis','defaults','localhost','socket.io-emitter','./user.socket','register','jayson/promise','http','request','info','request\x20sent','debug','stringify','error','message','User,\x20%s,\x20%s','result','sendStatus','end','json','count','offset','limit','status','set','apply','reject','save','update','then','destroy','get','role','admin','Users','Agents','agent','Telephones','filter','ignore','value','includes','find','name','stack','send','index','map','User','fieldName','type','key','model','differenceBy','password','keys','intersection','query','attributes','fields','hasOwnProperty','nolimit','order','filters','pick','where','merge','sequelize','lower','col','options','includeAll','include','findAll','rows','catch','show','salt','length','body','params','describe','addContacts','ids','internal','Setting','findById','securePassword','validatePasswordPattern','max','isNil','min_internal','select\x20(select\x20IFNULL(max(internal)+1,1)\x20from\x20users\x20where\x20internal\x20<\x20md.internal)\x20as\x20\x27from\x27,\x20md.internal\x20-\x201\x20as\x20\x27to\x27\x20from\x20users\x20md\x20where\x20md.internal\x20!=\x201\x20and\x20not\x20exists\x20(select\x201\x20from\x20users\x20md2\x20where\x20md2.internal\x20=\x20md.internal\x20-\x201)','QueryTypes','SELECT','from','voicemail','fullname','email','permissions','102','113','105','106','108','109','100','111','114','create','user','Unauthorized','Unauthorized.\x20You\x20must\x20be\x20an\x20administrator\x20in\x20order\x20to\x20create\x20another\x20administrator','checkUserLimits','settingsEnabled','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\x20user','Unauthorized.\x20You\x20must\x20be\x20an\x20administrator\x20in\x20order\x20to\x20create\x20an\x20administrator','all','each','VoiceMail','telephone','isEmpty','compact','push','changePassword','newPassword','Sequelize','ValidationError','Invalid\x20body\x20format.\x20Use\x20oldPassword\x20and\x20newPassword','oldPassword','Wrong\x20credentials','New\x20password\x20must\x20be\x20different\x20from\x20old\x20password','Invalid\x20body\x20format.\x20Use\x20newPassword','passwordHistoryLimit','previousPasswords','updatePasswordsHistory','channel','loginInPause','interface','isValidChannel','Unknown\x20channel','add','toLowerCase','Queues','spread','QueueId','emit','Queue:save','voice','online','SIP/%s','voicePause','penalty','upsert','removeQueues','remove','capitalize','addAvatar','userpic','filename','getAvatar','join','root','server/files/images/logos/default_profile.png','download','existsSync','server/files/images/','getContacts','CmContact','rawAttributes','sort','CmList','List','Tag','Tags','color','tag','findOne','Queue','getVoiceQueuesRt','UserVoiceQueueRt','getGroups','ChatGroup','getRecordings','VoiceRecording','UserId','getScreenRecordings','ScreenRecording','getChatInteractions','getOpenchannelInteractions','OpenchannelInteraction','MailInteraction','getSmsInteractions','SmsInteraction','getFaxInteractions','FaxInteraction','WhatsappInteraction','getWhatsappInteractions','login','phone','mobile','format','LOCAL/%s@from-sip/n','intrf','user:forcelogout','headers','x-forwarded-for','connection','remoteAddress','socket','User\x20not\x20found\x20or\x20not\x20allowed\x20to\x20perform\x20login\x20method','UserVoiceQueue.penalty','forEach','YYYY-MM-DD\x20HH:mm:ss','getChannels','LOGIN','device','PAUSE','LOGININPAUSE','MemberReport','isMiddleware','resolve','pause','QueuePause','updateAttributes','DEFAULT\x20PAUSE','unpause','mailPause','faxPause','openchannelPause','smsPause','pauseType','lastPauseAt','manual','mail','chat','fax','sms','whatsapp','openchannel','%s%s','Team'];(function(_0x1060ef,_0x432dd4){var _0x240222=function(_0x28f9db){while(--_0x28f9db){_0x1060ef['push'](_0x1060ef['shift']());}};_0x240222(++_0x432dd4);}(_0xb7ff,0x6e));var _0xfb7f=function(_0x10e7c3,_0x558d6d){_0x10e7c3=_0x10e7c3-0x0;var _0x2deccb=_0xb7ff[_0x10e7c3];return _0x2deccb;};'use strict';var pdf=require(_0xfb7f('0x0'));var emlformat=require('eml-format');var rimraf=require(_0xfb7f('0x1'));var zipdir=require(_0xfb7f('0x2'));var jsonpatch=require(_0xfb7f('0x3'));var rp=require('request-promise');var moment=require(_0xfb7f('0x4'));var BPromise=require('bluebird');var Mustache=require(_0xfb7f('0x5'));var util=require(_0xfb7f('0x6'));var path=require('path');var sox=require(_0xfb7f('0x7'));var csv=require(_0xfb7f('0x8'));var ejs=require('ejs');var fs=require('fs');var _=require(_0xfb7f('0x9'));var squel=require('squel');var crypto=require(_0xfb7f('0xa'));var jsforce=require(_0xfb7f('0xb'));var deskjs=require('desk.js');var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require('papaparse');var Redis=require('ioredis');var authService=require(_0xfb7f('0xc'));var qs=require('../../components/parsers/qs');var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xfb7f('0xd'));var logger=require(_0xfb7f('0xe'))('api');var utils=require(_0xfb7f('0xf'));var config=require('../../config/environment');var licenseUtil=require(_0xfb7f('0x10'));var db=require(_0xfb7f('0x11'))['db'];config[_0xfb7f('0x12')]=_[_0xfb7f('0x13')](config[_0xfb7f('0x12')],{'host':_0xfb7f('0x14'),'port':0x18eb});var socket=require(_0xfb7f('0x15'))(new Redis(config[_0xfb7f('0x12')]));require(_0xfb7f('0x16'))[_0xfb7f('0x17')](socket);var jayson=require(_0xfb7f('0x18'));var client=jayson['client'][_0xfb7f('0x19')]({'port':0x232a});function respondWithRpcPromise(_0x56b397,_0x38bc2d,_0x131ab3,_0x50d1e7){return new BPromise(function(_0xf54442,_0x3d7a1){var _0x281190=_0x50d1e7||client;return _0x281190[_0xfb7f('0x1a')](_0x56b397,_0x131ab3)['then'](function(_0x54214a){logger[_0xfb7f('0x1b')]('User,\x20%s,\x20%s',_0x38bc2d,_0xfb7f('0x1c'));logger[_0xfb7f('0x1d')]('User,\x20%s,\x20%s,\x20%s',_0x38bc2d,'request\x20sent',JSON[_0xfb7f('0x1e')](_0x54214a));if(_0x54214a[_0xfb7f('0x1f')]){if(_0x54214a[_0xfb7f('0x1f')]['code']===0x1f4){logger[_0xfb7f('0x1f')]('User,\x20%s,\x20%s',_0x38bc2d,_0x54214a[_0xfb7f('0x1f')][_0xfb7f('0x20')]);return _0x3d7a1(_0x54214a[_0xfb7f('0x1f')]['message']);}logger[_0xfb7f('0x1f')](_0xfb7f('0x21'),_0x38bc2d,_0x54214a[_0xfb7f('0x1f')]['message']);return _0xf54442(_0x54214a['error'][_0xfb7f('0x20')]);}else{logger[_0xfb7f('0x1b')](_0xfb7f('0x21'),_0x38bc2d,_0xfb7f('0x1c'));_0xf54442(_0x54214a[_0xfb7f('0x22')][_0xfb7f('0x20')]);}})['catch'](function(_0x50c085){logger['error'](_0xfb7f('0x21'),_0x38bc2d,_0x50c085);_0x3d7a1(_0x50c085);});});}function respondWithStatusCode(_0x2c4291,_0xec7477){_0xec7477=_0xec7477||0xcc;return function(_0x188aa1){if(_0x188aa1){return _0x2c4291[_0xfb7f('0x23')](_0xec7477);}return _0x2c4291['status'](_0xec7477)[_0xfb7f('0x24')]();};}function respondWithResult(_0x1e9fc7,_0x5dedde){_0x5dedde=_0x5dedde||0xc8;return function(_0x671f8a){if(_0x671f8a){return _0x1e9fc7['status'](_0x5dedde)[_0xfb7f('0x25')](_0x671f8a);}};}function respondWithFilteredResult(_0x14e307,_0x517167){return function(_0xb1c747){if(_0xb1c747){var _0xf38b9f=_0xb1c747[_0xfb7f('0x26')],_0x37cfde=_0x517167[_0xfb7f('0x27')],_0x5d66dd=_0x517167[_0xfb7f('0x27')]+_0x517167[_0xfb7f('0x28')],_0xb4ce58;if(_0x5d66dd>=_0xf38b9f){_0x5d66dd=_0xf38b9f;_0xb4ce58=0xc8;}else{_0xb4ce58=0xce;}_0x14e307[_0xfb7f('0x29')](_0xb4ce58);return _0x14e307[_0xfb7f('0x2a')]('Content-Range',_0x37cfde+'-'+_0x5d66dd+'/'+_0xf38b9f)['json'](_0xb1c747);}return null;};}function patchUpdates(_0x9c2dc){return function(_0x449862){try{jsonpatch[_0xfb7f('0x2b')](_0x449862,_0x9c2dc,!![]);}catch(_0x38da1b){return BPromise[_0xfb7f('0x2c')](_0x38da1b);}return _0x449862[_0xfb7f('0x2d')]();};}function saveUpdates(_0x12937b,_0x1537ce){return function(_0x22f4ba){if(_0x22f4ba){return _0x22f4ba[_0xfb7f('0x2e')](_0x12937b)[_0xfb7f('0x2f')](function(_0x44486e){return _0x44486e;});}return null;};}function removeEntity(_0x29fb1d,_0x31a6db){return function(_0x3f8c93){if(_0x3f8c93){return _0x3f8c93[_0xfb7f('0x30')]()[_0xfb7f('0x2f')](function(){var _0x21691c=_0x3f8c93[_0xfb7f('0x31')]({'plain':!![]});if(_0x21691c[_0xfb7f('0x32')]===_0xfb7f('0x33'))return;var _0x2fcaf2=[{'name':_0xfb7f('0x34'),'value':'user','ignore':!![]},{'name':_0xfb7f('0x35'),'value':_0xfb7f('0x36'),'ignore':![]},{'name':_0xfb7f('0x37'),'value':'telephone','ignore':![]}];var _0x136012=_(_0x2fcaf2)[_0xfb7f('0x38')](_0xfb7f('0x39'))['map'](_0xfb7f('0x3a'))['value']();if(_[_0xfb7f('0x3b')](_0x136012,_0x21691c[_0xfb7f('0x32')])){return;}var _0x1aeebb=_[_0xfb7f('0x3c')](_0x2fcaf2,[_0xfb7f('0x3a'),_0x21691c['role']])[_0xfb7f('0x3d')];return db['UserProfileResource'][_0xfb7f('0x30')]({'where':{'type':_0x1aeebb,'resourceId':_0x21691c['id']}})[_0xfb7f('0x2f')](function(){return _0x3f8c93;});})[_0xfb7f('0x2f')](function(){_0x29fb1d[_0xfb7f('0x29')](0xcc)['end']();});}};}function handleEntityNotFound(_0x230c60,_0x1e6bd2){return function(_0x31c301){if(!_0x31c301){_0x230c60[_0xfb7f('0x23')](0x194);}return _0x31c301;};}function handleError(_0x3c8248,_0x15c47a){_0x15c47a=_0x15c47a||0x1f4;return function(_0x56e665){logger['error'](_0x56e665[_0xfb7f('0x3e')]);if(_0x56e665[_0xfb7f('0x3d')]){delete _0x56e665[_0xfb7f('0x3d')];}_0x3c8248[_0xfb7f('0x29')](_0x15c47a)[_0xfb7f('0x3f')](_0x56e665);};}exports[_0xfb7f('0x40')]=function(_0x1ae6de,_0x37d48f){var _0x11634e={},_0x30fa18={},_0x23e84f={'count':0x0,'rows':[]};var _0x1a0b90=_[_0xfb7f('0x41')](db[_0xfb7f('0x42')]['rawAttributes'],function(_0x121d28){return{'name':_0x121d28[_0xfb7f('0x43')],'type':_0x121d28[_0xfb7f('0x44')][_0xfb7f('0x45')]};});_0x30fa18[_0xfb7f('0x46')]=_[_0xfb7f('0x47')](_['map'](_0x1a0b90,_0xfb7f('0x3d')),[_0xfb7f('0x48'),'salt']);_0x30fa18['query']=_[_0xfb7f('0x49')](_0x1ae6de['query']);_0x30fa18['filters']=_[_0xfb7f('0x4a')](_0x30fa18[_0xfb7f('0x46')],_0x30fa18[_0xfb7f('0x4b')]);_0x11634e[_0xfb7f('0x4c')]=_[_0xfb7f('0x4a')](_0x30fa18[_0xfb7f('0x46')],qs[_0xfb7f('0x4d')](_0x1ae6de[_0xfb7f('0x4b')][_0xfb7f('0x4d')]));_0x11634e[_0xfb7f('0x4c')]=_0x11634e[_0xfb7f('0x4c')]['length']?_0x11634e[_0xfb7f('0x4c')]:_0x30fa18[_0xfb7f('0x46')];if(!_0x1ae6de[_0xfb7f('0x4b')][_0xfb7f('0x4e')](_0xfb7f('0x4f'))){_0x11634e['limit']=qs['limit'](_0x1ae6de['query'][_0xfb7f('0x28')]);_0x11634e[_0xfb7f('0x27')]=qs[_0xfb7f('0x27')](_0x1ae6de[_0xfb7f('0x4b')][_0xfb7f('0x27')]);}_0x11634e[_0xfb7f('0x50')]=qs['sort'](_0x1ae6de[_0xfb7f('0x4b')]['sort']);_0x11634e['where']=qs[_0xfb7f('0x51')](_[_0xfb7f('0x52')](_0x1ae6de[_0xfb7f('0x4b')],_0x30fa18[_0xfb7f('0x51')]),_0x1a0b90);if(_0x1ae6de[_0xfb7f('0x4b')][_0xfb7f('0x38')]){_0x11634e[_0xfb7f('0x53')]=_[_0xfb7f('0x54')](_0x11634e[_0xfb7f('0x53')],{'$or':_[_0xfb7f('0x41')](_0x1a0b90,function(_0x3cc5d5){if(_0x3cc5d5[_0xfb7f('0x44')]!=='VIRTUAL'){return db[_0xfb7f('0x55')][_0xfb7f('0x53')](db[_0xfb7f('0x55')]['fn'](_0xfb7f('0x56'),db[_0xfb7f('0x55')][_0xfb7f('0x57')](_0x3cc5d5['name'])),{'$like':db['sequelize']['fn'](_0xfb7f('0x56'),'%'+_0x1ae6de[_0xfb7f('0x4b')][_0xfb7f('0x38')]+'%')});}})});}_0x11634e=_[_0xfb7f('0x54')]({},_0x11634e,_0x1ae6de[_0xfb7f('0x58')]);var _0x2f9672={'where':_0x11634e[_0xfb7f('0x53')]};return db[_0xfb7f('0x42')][_0xfb7f('0x26')](_0x2f9672)[_0xfb7f('0x2f')](function(_0x18869b){_0x23e84f[_0xfb7f('0x26')]=_0x18869b;if(_0x1ae6de[_0xfb7f('0x4b')][_0xfb7f('0x59')]){_0x11634e[_0xfb7f('0x5a')]=[{'all':!![]}];}return db[_0xfb7f('0x42')][_0xfb7f('0x5b')](_0x11634e);})[_0xfb7f('0x2f')](function(_0xac5ecd){_0x23e84f[_0xfb7f('0x5c')]=_0xac5ecd;return _0x23e84f;})[_0xfb7f('0x2f')](respondWithFilteredResult(_0x37d48f,_0x11634e))[_0xfb7f('0x5d')](handleError(_0x37d48f,null));};exports[_0xfb7f('0x5e')]=function(_0x1f8d27,_0x2685d4){var _0x1aae46={'raw':![],'where':{'id':_0x1f8d27['params']['id']}},_0x149ae2={};_0x149ae2['model']=_[_0xfb7f('0x47')](_[_0xfb7f('0x49')](db[_0xfb7f('0x42')]['rawAttributes']),['password',_0xfb7f('0x5f')]);_0x149ae2[_0xfb7f('0x4b')]=_[_0xfb7f('0x49')](_0x1f8d27['query']);_0x149ae2['filters']=_[_0xfb7f('0x4a')](_0x149ae2[_0xfb7f('0x46')],_0x149ae2[_0xfb7f('0x4b')]);_0x1aae46['attributes']=_[_0xfb7f('0x4a')](_0x149ae2['model'],qs[_0xfb7f('0x4d')](_0x1f8d27[_0xfb7f('0x4b')]['fields']));_0x1aae46[_0xfb7f('0x4c')]=_0x1aae46['attributes'][_0xfb7f('0x60')]?_0x1aae46['attributes']:_0x149ae2['model'];if(_0x1f8d27['query'][_0xfb7f('0x59')]){_0x1aae46['include']=[{'all':!![]}];}_0x1aae46=_['merge']({},_0x1aae46,_0x1f8d27[_0xfb7f('0x58')]);return db[_0xfb7f('0x42')][_0xfb7f('0x3c')](_0x1aae46)['then'](handleEntityNotFound(_0x2685d4,null))['then'](respondWithResult(_0x2685d4,null))[_0xfb7f('0x5d')](handleError(_0x2685d4,null));};exports[_0xfb7f('0x2e')]=function(_0x48da63,_0x426b49){if(_0x48da63[_0xfb7f('0x61')]['id']){delete _0x48da63['body']['id'];}delete _0x48da63[_0xfb7f('0x61')]['role'];return db['User'][_0xfb7f('0x3c')]({'where':{'id':_0x48da63[_0xfb7f('0x62')]['id']}})[_0xfb7f('0x2f')](handleEntityNotFound(_0x426b49,null))[_0xfb7f('0x2f')](saveUpdates(_0x48da63[_0xfb7f('0x61')],null))[_0xfb7f('0x2f')](respondWithResult(_0x426b49,null))[_0xfb7f('0x5d')](handleError(_0x426b49,null));};exports[_0xfb7f('0x63')]=function(_0x3ef87a,_0x110e7f){return db[_0xfb7f('0x42')]['describe']()['then'](respondWithResult(_0x110e7f,null))[_0xfb7f('0x5d')](handleError(_0x110e7f,null));};exports[_0xfb7f('0x64')]=function(_0x13ab2e,_0x444423,_0x56da88){return db[_0xfb7f('0x42')][_0xfb7f('0x3c')]({'where':{'id':_0x13ab2e[_0xfb7f('0x62')]['id']}})['then'](handleEntityNotFound(_0x444423,null))[_0xfb7f('0x2f')](function(_0x157ddc){if(_0x157ddc){return _0x157ddc['addContacts'](_0x13ab2e['body'][_0xfb7f('0x65')],_['omit'](_0x13ab2e[_0xfb7f('0x61')],[_0xfb7f('0x65'),'id'])||{});}})[_0xfb7f('0x2f')](respondWithResult(_0x444423,null))[_0xfb7f('0x5d')](handleError(_0x444423,null));};function validateUser(_0x4ee148){return new BPromise(function(_0x4d13f8,_0x1891e1){if(_0x4ee148[_0xfb7f('0x66')])return _0x4d13f8(_0x4ee148);return db[_0xfb7f('0x67')][_0xfb7f('0x68')](0x1)[_0xfb7f('0x2f')](function(_0x13869f){if(_0x13869f[_0xfb7f('0x69')])authService[_0xfb7f('0x6a')](_0x4ee148[_0xfb7f('0x48')]);db[_0xfb7f('0x42')][_0xfb7f('0x6b')](_0xfb7f('0x66'))[_0xfb7f('0x2f')](function(_0x53d7e1){if(_[_0xfb7f('0x6c')](_0x53d7e1)){_0x4ee148[_0xfb7f('0x66')]=_0x13869f[_0xfb7f('0x6d')]||0x1;return;}if(_[_0xfb7f('0x6c')](_0x13869f[_0xfb7f('0x6d')])||_0x13869f[_0xfb7f('0x6d')]===_0x53d7e1){_0x4ee148[_0xfb7f('0x66')]=_0x53d7e1+0x1;return;}if(_0x13869f[_0xfb7f('0x6d')]>_0x53d7e1){_0x4ee148[_0xfb7f('0x66')]=_0x13869f['min_internal'];return;}return db['sequelize'][_0xfb7f('0x4b')](_0xfb7f('0x6e'),{'type':db[_0xfb7f('0x55')][_0xfb7f('0x6f')][_0xfb7f('0x70')]})[_0xfb7f('0x2f')](function(_0x1adfb2){if(_0x1adfb2&&_0x1adfb2['length']){for(var _0x3eb5e2=0x0,_0x25324d=_0x1adfb2[_0xfb7f('0x60')];_0x3eb5e2<_0x25324d&&_[_0xfb7f('0x6c')](_0x4ee148[_0xfb7f('0x66')]);_0x3eb5e2++){if(_0x13869f['min_internal']<=_0x1adfb2[_0x3eb5e2]['from']){_0x4ee148[_0xfb7f('0x66')]=_0x1adfb2[_0x3eb5e2][_0xfb7f('0x71')];}else if(_0x13869f[_0xfb7f('0x6d')]>_0x1adfb2[_0x3eb5e2][_0xfb7f('0x71')]&&_0x13869f[_0xfb7f('0x6d')]<=_0x1adfb2[_0x3eb5e2]['to']){_0x4ee148[_0xfb7f('0x66')]=_0x13869f[_0xfb7f('0x6d')];}}}if(_[_0xfb7f('0x6c')](_0x4ee148[_0xfb7f('0x66')])){_0x4ee148[_0xfb7f('0x66')]=_0x53d7e1+0x1;}return _0x4d13f8(_0x4ee148);});});})[_0xfb7f('0x5d')](function(_0x19f894){_0x1891e1(_0x19f894);});});}function updateUser(_0x4356da){return new BPromise(function(_0x581293,_0x956778){try{if(_0x4356da[_0xfb7f('0x72')]){_0x4356da['mailbox']=_0x4356da[_0xfb7f('0x66')];_0x4356da['VoiceMail']={'mailbox':_0x4356da['internal'],'password':_0x4356da[_0xfb7f('0x48')],'fullname':_0x4356da[_0xfb7f('0x73')],'email':_0x4356da[_0xfb7f('0x74')]};}if(_0x4356da['role']===_0xfb7f('0x36')){if(!_0x4356da[_0xfb7f('0x75')])_0x4356da[_0xfb7f('0x75')]=['101',_0xfb7f('0x76'),'103',_0xfb7f('0x77'),'110','104',_0xfb7f('0x78'),_0xfb7f('0x79'),'107',_0xfb7f('0x7a'),_0xfb7f('0x7b'),_0xfb7f('0x7c'),_0xfb7f('0x7d'),_0xfb7f('0x7e')];}_0x581293(_0x4356da);}catch(_0x301434){_0x956778(_0x301434);}});}exports[_0xfb7f('0x7f')]=function(_0x103c8a,_0x484416){if(_0x103c8a[_0xfb7f('0x80')][_0xfb7f('0x32')]===_0xfb7f('0x36'))throw new Error(_0xfb7f('0x81'));if(_0x103c8a['body'][_0xfb7f('0x32')]===_0xfb7f('0x80')&&_0x103c8a[_0xfb7f('0x80')]['role']!==_0xfb7f('0x33')){throw new Error('Unauthorized.\x20You\x20must\x20be\x20an\x20administrator\x20in\x20order\x20to\x20create\x20an\x20user');}if(_0x103c8a[_0xfb7f('0x61')][_0xfb7f('0x32')]===_0xfb7f('0x33')&&_0x103c8a[_0xfb7f('0x80')][_0xfb7f('0x32')]!=='admin'){throw new Error(_0xfb7f('0x82'));}return licenseUtil[_0xfb7f('0x83')]([_0x103c8a[_0xfb7f('0x61')]])[_0xfb7f('0x2f')](function(){return validateUser(_0x103c8a['body']);})[_0xfb7f('0x2f')](function(_0x5b97f7){return updateUser(_0x5b97f7)[_0xfb7f('0x2f')](function(_0x144b0c){if(_0x144b0c[_0xfb7f('0x32')]===_0xfb7f('0x33')){_0x144b0c[_0xfb7f('0x84')]=_0x103c8a[_0xfb7f('0x80')][_0xfb7f('0x84')];delete _0x144b0c[_0xfb7f('0x85')];}return _0x144b0c;});})[_0xfb7f('0x2f')](function(_0x884d80){return db[_0xfb7f('0x42')][_0xfb7f('0x7f')](_0x884d80,{'include':[{'model':db['VoiceMail'],'as':'VoiceMail'}]});})['then'](function(_0x277228){if(_0x103c8a[_0xfb7f('0x61')][_0xfb7f('0x32')]===_0xfb7f('0x80'))return _0x277228;if(_0x103c8a[_0xfb7f('0x80')][_0xfb7f('0x32')]!==_0xfb7f('0x80'))return _0x277228;return db['UserProfileSection'][_0xfb7f('0x3c')]({'where':{'name':_0x277228[_0xfb7f('0x32')]===_0xfb7f('0x36')?_0xfb7f('0x35'):_0xfb7f('0x37'),'userProfileId':_0x103c8a[_0xfb7f('0x80')][_0xfb7f('0x85')]},'raw':!![]})[_0xfb7f('0x2f')](function(_0x5090e6){if(!_0x5090e6||_0x5090e6[_0xfb7f('0x86')]!=0x0)return _0x277228;return db[_0xfb7f('0x87')][_0xfb7f('0x7f')]({'name':_0x277228[_0xfb7f('0x3d')],'resourceId':_0x277228['id'],'type':_0x5090e6[_0xfb7f('0x3d')],'sectionId':_0x5090e6['id']},{})[_0xfb7f('0x2f')](function(){return _0x277228;});})[_0xfb7f('0x5d')](function(_0x85b21a){logger[_0xfb7f('0x1f')](_0xfb7f('0x88'),_0x85b21a);throw _0x85b21a;});})[_0xfb7f('0x2f')](respondWithResult(_0x484416,0xc9))[_0xfb7f('0x5d')](handleError(_0x484416,null));};exports[_0xfb7f('0x89')]=function(_0x5a4f3d,_0x5c6ef2){var _0x3b1dc2=_0x5a4f3d['body'];var _0x298ab0=[];if(_0x5a4f3d[_0xfb7f('0x80')][_0xfb7f('0x32')]===_0xfb7f('0x36'))throw new Error('Unauthorized');if(_[_0xfb7f('0x8a')](_0x3b1dc2,[_0xfb7f('0x32'),_0xfb7f('0x80')])&&_0x5a4f3d['user'][_0xfb7f('0x32')]!=='admin'){throw new Error(_0xfb7f('0x8b'));}if(_['some'](_0x3b1dc2,['role',_0xfb7f('0x33')])&&_0x5a4f3d[_0xfb7f('0x80')][_0xfb7f('0x32')]!==_0xfb7f('0x33')){throw new Error(_0xfb7f('0x8c'));}return licenseUtil[_0xfb7f('0x83')](_0x3b1dc2)['then'](function(){return validateUser(_0x3b1dc2[0x0]);})[_0xfb7f('0x2f')](function(){for(var _0x2b6faa=0x1;_0x2b6faa<_0x3b1dc2[_0xfb7f('0x60')];_0x2b6faa++){var _0x53beec=_0x3b1dc2[_0x2b6faa-0x1][_0xfb7f('0x66')];if(!_0x3b1dc2[_0x2b6faa][_0xfb7f('0x66')])_0x3b1dc2[_0x2b6faa][_0xfb7f('0x66')]=_0x53beec+0x1;_0x298ab0['push'](validateUser(_0x3b1dc2[_0x2b6faa]));}return BPromise['all'](_0x298ab0);})['then'](function(){_0x298ab0=[];for(var _0x39d2b8=0x0;_0x39d2b8<_0x3b1dc2[_0xfb7f('0x60')];_0x39d2b8++){_0x298ab0['push'](updateUser(_0x3b1dc2[_0x39d2b8]));}return BPromise[_0xfb7f('0x8d')](_0x298ab0);})[_0xfb7f('0x2f')](function(){return BPromise[_0xfb7f('0x8e')](_0x3b1dc2,function(_0x51a259){return db[_0xfb7f('0x42')][_0xfb7f('0x7f')](_0x51a259,{'include':[{'model':db[_0xfb7f('0x8f')],'as':_0xfb7f('0x8f')}]})['then'](function(_0x946a14){_0x51a259['id']=_0x946a14['id'];return _0x51a259;});});})[_0xfb7f('0x2f')](function(_0x11e334){if(_0x5a4f3d['body'][_0xfb7f('0x32')]===_0xfb7f('0x80'))return _0x11e334;if(_0x5a4f3d[_0xfb7f('0x80')]['role']!==_0xfb7f('0x80'))return _0x11e334;var _0x2eb072=_[_0xfb7f('0x8a')](_0x11e334,function(_0x80f830){return _0x80f830[_0xfb7f('0x32')]===_0xfb7f('0x36')||_0x80f830[_0xfb7f('0x32')]===_0xfb7f('0x90');});if(!_0x2eb072)return _0x11e334;return db['UserProfileSection'][_0xfb7f('0x5b')]({'where':{'name':{'$or':[_0xfb7f('0x35'),_0xfb7f('0x37')]},'userProfileId':_0x5a4f3d[_0xfb7f('0x80')][_0xfb7f('0x85')]},'raw':!![]})['then'](function(_0x171dda){if(_[_0xfb7f('0x91')](_0x171dda)||!_[_0xfb7f('0x8a')](_0x171dda,[_0xfb7f('0x86'),0x0]))return _0x11e334;_0x298ab0=[];var _0x4c5024=_(_0x171dda)['map'](function(_0x4d4a61){if(_0x4d4a61[_0xfb7f('0x86')]===0x1)return;return _0x4d4a61[_0xfb7f('0x3d')]===_0xfb7f('0x35')?_0xfb7f('0x36'):'telephone';})[_0xfb7f('0x92')]()[_0xfb7f('0x3a')]();for(var _0x116b12=0x0;_0x116b12<_0x11e334[_0xfb7f('0x60')];_0x116b12++){if(!_[_0xfb7f('0x3b')](_0x4c5024,_0x11e334[_0x116b12][_0xfb7f('0x32')]))return;var _0x4d863c=_0x11e334[_0x116b12]['role']===_0xfb7f('0x36')?_0xfb7f('0x35'):_0xfb7f('0x37');_0x298ab0[_0xfb7f('0x93')](db[_0xfb7f('0x87')][_0xfb7f('0x7f')]({'name':_0x11e334[_0x116b12][_0xfb7f('0x3d')],'resourceId':_0x11e334[_0x116b12]['id'],'type':_0x4d863c,'sectionId':_['find'](_0x171dda,[_0xfb7f('0x3d'),_0x4d863c])['id']},{}));}return BPromise[_0xfb7f('0x8d')](_0x298ab0);})[_0xfb7f('0x2f')](respondWithResult(_0x5c6ef2,0xc9))[_0xfb7f('0x5d')](handleError(_0x5c6ef2,null));});};exports[_0xfb7f('0x94')]=function(_0x212cce,_0x4d8697,_0x449e73){if(_0x212cce[_0xfb7f('0x61')]['id']){delete _0x212cce['body']['id'];}return db[_0xfb7f('0x42')][_0xfb7f('0x3c')]({'where':{'id':_0x212cce[_0xfb7f('0x62')]['id']}})['then'](function(_0x24defa){if(!_0x24defa)return null;if(_0x24defa['id']===_0x212cce[_0xfb7f('0x80')]['id']){if(!_0x212cce['body']['oldPassword']||!_0x212cce[_0xfb7f('0x61')][_0xfb7f('0x95')]){throw new db[(_0xfb7f('0x96'))][(_0xfb7f('0x97'))](_0xfb7f('0x98'));}if(!_0x24defa['authenticate'](_0x212cce[_0xfb7f('0x61')][_0xfb7f('0x99')])){throw new db[(_0xfb7f('0x96'))][(_0xfb7f('0x97'))](_0xfb7f('0x9a'));}if(_0x212cce[_0xfb7f('0x61')][_0xfb7f('0x99')]===_0x212cce[_0xfb7f('0x61')]['newPassword']){throw new db[(_0xfb7f('0x96'))][(_0xfb7f('0x97'))](_0xfb7f('0x9b'));}}else if(_0x212cce[_0xfb7f('0x80')][_0xfb7f('0x32')]===_0xfb7f('0x33')){if(!_0x212cce[_0xfb7f('0x61')][_0xfb7f('0x95')]){throw new db[(_0xfb7f('0x96'))][(_0xfb7f('0x97'))](_0xfb7f('0x9c'));}}else if(_0x212cce['user']['role']===_0xfb7f('0x80')){if(!_0x212cce[_0xfb7f('0x61')]['newPassword']){throw new db[(_0xfb7f('0x96'))][(_0xfb7f('0x97'))]('Invalid\x20body\x20format.\x20Use\x20newPassword');}if(_0x24defa[_0xfb7f('0x32')]!==_0xfb7f('0x36')){throw new db[(_0xfb7f('0x96'))][(_0xfb7f('0x97'))](_0xfb7f('0x81'));}}else{throw new db[(_0xfb7f('0x96'))][(_0xfb7f('0x97'))](_0xfb7f('0x81'));}return _0x24defa;})[_0xfb7f('0x2f')](handleEntityNotFound(_0x4d8697,null))[_0xfb7f('0x2f')](function(_0x5bd855){return db['Setting']['findOne']({'attributes':['id',_0xfb7f('0x69'),'enforcePasswordHistory',_0xfb7f('0x9d')]})['then'](function(_0x24dd85){if(_0x24dd85[_0xfb7f('0x69')])authService[_0xfb7f('0x6a')](_0x212cce[_0xfb7f('0x61')]['newPassword']);if(!_0x24dd85['enforcePasswordHistory']||!_0x5bd855[_0xfb7f('0x9e')])return _0x5bd855;authService['validatePasswordHistory'](_0x212cce['body']['newPassword'],_0x5bd855['previousPasswords'],_0x24dd85[_0xfb7f('0x9d')]);return _0x5bd855;})[_0xfb7f('0x2f')](saveUpdates({'password':_0x212cce['body']['newPassword'],'passwordResetAt':_0x212cce[_0xfb7f('0x80')]['id']==_0x212cce[_0xfb7f('0x62')]['id']?moment():null,'previousPasswords':authService[_0xfb7f('0x9f')](_0x212cce[_0xfb7f('0x61')]['newPassword'],_0x5bd855['previousPasswords'])},null));})[_0xfb7f('0x2f')](respondWithResult(_0x4d8697,null))[_0xfb7f('0x5d')](handleError(_0x4d8697,null));};exports['addQueues']=function(_0x4fac4a,_0x4ee434,_0x121f2f){var _0x2ba431=_0x4fac4a[_0xfb7f('0x61')][_0xfb7f('0xa0')];return db[_0xfb7f('0x42')][_0xfb7f('0x3c')]({'where':{'id':_0x4fac4a[_0xfb7f('0x62')]['id']},'attributes':['id',_0xfb7f('0x3d'),'role','online',_0xfb7f('0xa1'),'voicePause',_0xfb7f('0xa2')]})[_0xfb7f('0x2f')](handleEntityNotFound(_0x4ee434,null))[_0xfb7f('0x2f')](function(_0x5c94d9){if(_0x5c94d9){if(!utils[_0xfb7f('0xa3')](_0x2ba431)){throw new db[(_0xfb7f('0x96'))]['ValidationError'](_0xfb7f('0xa4'));}return _0x5c94d9[_0xfb7f('0xa5')+_['capitalize'](_0x2ba431[_0xfb7f('0xa6')]())+_0xfb7f('0xa7')](_0x4fac4a['body'][_0xfb7f('0x65')],{'penalty':_0x4fac4a[_0xfb7f('0x61')]['penalty']||0x0})[_0xfb7f('0xa8')](function(_0x51bc7c){for(var _0x37af7e=0x0;_0x37af7e<_0x4fac4a['body'][_0xfb7f('0x65')]['length'];_0x37af7e+=0x1){var _0x2005a3={'UserId':_0x4fac4a[_0xfb7f('0x62')]['id']};_0x2005a3[_['capitalize'](_0x2ba431[_0xfb7f('0xa6')]())+_0xfb7f('0xa9')]=_0x4fac4a['body'][_0xfb7f('0x65')][_0x37af7e];socket[_0xfb7f('0xaa')](_0xfb7f('0x80')+_['capitalize'](_0x2ba431[_0xfb7f('0xa6')]())+_0xfb7f('0xab'),_0x2005a3);}return _0x51bc7c;})[_0xfb7f('0x2f')](function(){if(_0x2ba431===_0xfb7f('0xac')){return db['VoiceQueue'][_0xfb7f('0x5b')]({'where':{'id':_0x4fac4a[_0xfb7f('0x61')][_0xfb7f('0x65')]||[]},'raw':!![],'attributes':['id',_0xfb7f('0x3d')]});}})['then'](function(_0x2099b1){var _0xd9191=_0x5c94d9[_0xfb7f('0x31')]({'plain':!![]});var _0x477bba=[];if(_0x2ba431===_0xfb7f('0xac')&&_0xd9191[_0xfb7f('0x32')]==='agent'&&_0xd9191[_0xfb7f('0xad')]){for(var _0x2f8bfd=0x0;_0x2f8bfd<_0x2099b1[_0xfb7f('0x60')];_0x2f8bfd+=0x1){_0x477bba[_0xfb7f('0x93')]({'membername':_0xd9191[_0xfb7f('0x3d')],'UserId':_0xd9191['id'],'queue_name':_0x2099b1[_0x2f8bfd][_0xfb7f('0x3d')],'VoiceQueueId':_0x2099b1[_0x2f8bfd]['id'],'interface':_[_0xfb7f('0x6c')](_0xd9191[_0xfb7f('0xa2')])?util['format'](_0xfb7f('0xae'),_0xd9191['name']):_0xd9191[_0xfb7f('0xa2')],'paused':_0xd9191[_0xfb7f('0xaf')]||![],'penalty':_0x4fac4a[_0xfb7f('0x61')][_0xfb7f('0xb0')]||0x0});}return BPromise[_0xfb7f('0x8e')](_0x477bba,function(_0x179bb3){return db['UserVoiceQueueRt'][_0xfb7f('0xb1')](_0x179bb3);});}return _0x5c94d9;});}})[_0xfb7f('0x2f')](respondWithStatusCode(_0x4ee434,null))['catch'](handleError(_0x4ee434,null));};exports[_0xfb7f('0xb2')]=function(_0x526370,_0x205af4,_0x3e63bd){var _0xcd06ab;return db[_0xfb7f('0x42')]['find']({'where':{'id':_0x526370[_0xfb7f('0x62')]['id']},'attributes':['id',_0xfb7f('0x3d'),_0xfb7f('0x32')]})[_0xfb7f('0x2f')](handleEntityNotFound(_0x205af4,null))['then'](function(_0x1c4470){if(_0x1c4470){_0xcd06ab=_0x1c4470;if(!_0x526370[_0xfb7f('0x4b')][_0xfb7f('0xa0')]||!utils[_0xfb7f('0xa3')](_0x526370[_0xfb7f('0x4b')][_0xfb7f('0xa0')])){throw new db[(_0xfb7f('0x96'))][(_0xfb7f('0x97'))](_0xfb7f('0xa4'));}return _0x1c4470[_0xfb7f('0xb3')+_['capitalize'](_0x526370[_0xfb7f('0x4b')][_0xfb7f('0xa0')]['toLowerCase']())+_0xfb7f('0xa7')](_0x526370['query']['ids']);}})[_0xfb7f('0x2f')](function(_0x235680){for(var _0x1c9b16=0x0;_0x1c9b16<_0x526370['query']['ids'][_0xfb7f('0x60')];_0x1c9b16+=0x1){var _0x20fe0f={'UserId':_0x526370[_0xfb7f('0x62')]['id']};_0x20fe0f[_[_0xfb7f('0xb4')](_0x526370[_0xfb7f('0x4b')][_0xfb7f('0xa0')]['toLowerCase']())+'QueueId']=_0x526370[_0xfb7f('0x4b')][_0xfb7f('0x65')][_0x1c9b16];socket['emit'](_0xfb7f('0x80')+_['capitalize'](_0x526370[_0xfb7f('0x4b')][_0xfb7f('0xa0')][_0xfb7f('0xa6')]())+'Queue:remove',_0x20fe0f);}return _0x235680;})[_0xfb7f('0x2f')](function(){if(_0x526370[_0xfb7f('0x4b')][_0xfb7f('0xa0')]===_0xfb7f('0xac')){return db['UserVoiceQueueRt'][_0xfb7f('0x30')]({'where':{'UserId':_0x526370[_0xfb7f('0x62')]['id'],'VoiceQueueId':_0x526370[_0xfb7f('0x4b')][_0xfb7f('0x65')]},'individualHooks':!![]})[_0xfb7f('0x2f')](function(){return _0xcd06ab;});}return _0xcd06ab;})[_0xfb7f('0x2f')](respondWithStatusCode(_0x205af4,null))[_0xfb7f('0x5d')](handleError(_0x205af4,null));};exports[_0xfb7f('0xb5')]=function(_0x100553,_0x4a6be6,_0x52894c){_0x100553[_0xfb7f('0x61')][_0xfb7f('0xb6')]=_0x100553['file'][_0xfb7f('0xb7')];return db[_0xfb7f('0x42')][_0xfb7f('0x3c')]({'where':{'id':_0x100553[_0xfb7f('0x62')]['id']}})[_0xfb7f('0x2f')](handleEntityNotFound(_0x4a6be6,null))[_0xfb7f('0x2f')](saveUpdates(_0x100553[_0xfb7f('0x61')],null))['then'](respondWithResult(_0x4a6be6,null))[_0xfb7f('0x5d')](handleError(_0x4a6be6,null));};exports[_0xfb7f('0xb8')]=function(_0x9819f9,_0x348d15,_0x53e599){var _0x2c4805=path[_0xfb7f('0xb9')](config[_0xfb7f('0xba')],_0xfb7f('0xbb'));return db[_0xfb7f('0x42')]['find']({'where':{'id':_0x9819f9[_0xfb7f('0x62')]['id']},'attributes':['id',_0xfb7f('0xb6')],'raw':!![]})['then'](handleEntityNotFound(_0x348d15,null))[_0xfb7f('0x2f')](function(_0x27f94f){if(_0x27f94f){if(_[_0xfb7f('0x6c')](_0x27f94f['userpic'])){return _0x348d15[_0xfb7f('0xbc')](_0x2c4805);}else{if(!fs[_0xfb7f('0xbd')](path[_0xfb7f('0xb9')](config[_0xfb7f('0xba')],_0xfb7f('0xbe'),_0x27f94f[_0xfb7f('0xb6')]))){return _0x348d15[_0xfb7f('0xbc')](_0x2c4805);}return _0x348d15[_0xfb7f('0xbc')](path[_0xfb7f('0xb9')](config[_0xfb7f('0xba')],_0xfb7f('0xbe'),_0x27f94f[_0xfb7f('0xb6')]));}}})[_0xfb7f('0x5d')](handleError(_0x348d15,null));};exports[_0xfb7f('0xbf')]=function(_0x1ed713,_0x2d89e4,_0x3ebf3a){var _0x574a98={};var _0x5a8f25={};var _0x373cdb;var _0x1f0955;return db[_0xfb7f('0x42')]['findOne']({'where':{'id':_0x1ed713['params']['id']}})[_0xfb7f('0x2f')](handleEntityNotFound(_0x2d89e4,null))['then'](function(_0x4d5b58){if(_0x4d5b58){_0x373cdb=_0x4d5b58;_0x5a8f25[_0xfb7f('0x46')]=_[_0xfb7f('0x49')](db[_0xfb7f('0xc0')][_0xfb7f('0xc1')]);_0x5a8f25['query']=_[_0xfb7f('0x49')](_0x1ed713['query']);_0x5a8f25['filters']=_[_0xfb7f('0x4a')](_0x5a8f25[_0xfb7f('0x46')],_0x5a8f25[_0xfb7f('0x4b')]);_0x574a98[_0xfb7f('0x4c')]=_['intersection'](_0x5a8f25[_0xfb7f('0x46')],qs[_0xfb7f('0x4d')](_0x1ed713[_0xfb7f('0x4b')]['fields']));_0x574a98[_0xfb7f('0x4c')]=_0x574a98[_0xfb7f('0x4c')][_0xfb7f('0x60')]?_0x574a98[_0xfb7f('0x4c')]:_0x5a8f25[_0xfb7f('0x46')];_0x574a98['order']=qs[_0xfb7f('0xc2')](_0x1ed713[_0xfb7f('0x4b')]['sort']);_0x574a98[_0xfb7f('0x53')]=qs[_0xfb7f('0x51')](_[_0xfb7f('0x52')](_0x1ed713[_0xfb7f('0x4b')],_0x5a8f25[_0xfb7f('0x51')]));if(_0x1ed713['query']['filter']){_0x574a98[_0xfb7f('0x53')]=_[_0xfb7f('0x54')](_0x574a98[_0xfb7f('0x53')],{'$or':_['map'](_0x574a98['attributes'],function(_0x56991c){var _0x3582ec={};_0x3582ec[_0x56991c]={'$like':'%'+_0x1ed713[_0xfb7f('0x4b')][_0xfb7f('0x38')]+'%'};return _0x3582ec;})});}_0x574a98=_[_0xfb7f('0x54')]({},_0x574a98,_0x1ed713[_0xfb7f('0x58')]);return _0x373cdb['getContacts'](_0x574a98);}})['then'](function(_0x2e8b2e){if(_0x2e8b2e){_0x1f0955=_0x2e8b2e[_0xfb7f('0x60')];if(_0x1ed713['query'][_0xfb7f('0x4e')](_0xfb7f('0x59'))){_0x574a98[_0xfb7f('0x5a')]=[{'model':db[_0xfb7f('0xc3')],'as':_0xfb7f('0xc4'),'required':![]},{'model':db[_0xfb7f('0xc5')],'as':_0xfb7f('0xc6'),'attributes':['id',_0xfb7f('0x3d'),_0xfb7f('0xc7')],'where':_0x1ed713['query'][_0xfb7f('0xc8')]?{'id':_0x1ed713[_0xfb7f('0x4b')]['tag']}:undefined,'required':_0x1ed713[_0xfb7f('0x4b')][_0xfb7f('0xc8')]?!![]:![]}];}if(!_0x1ed713[_0xfb7f('0x4b')]['hasOwnProperty']('nolimit')){_0x574a98['limit']=qs[_0xfb7f('0x28')](_0x1ed713['query'][_0xfb7f('0x28')]);_0x574a98[_0xfb7f('0x27')]=qs[_0xfb7f('0x27')](_0x1ed713[_0xfb7f('0x4b')][_0xfb7f('0x27')]);}return _0x373cdb['getContacts'](_0x574a98);}})['then'](function(_0x12b84d){if(_0x12b84d){return _0x12b84d?{'count':_0x1f0955,'rows':_0x12b84d}:null;}})['then'](respondWithResult(_0x2d89e4,null))[_0xfb7f('0x5d')](handleError(_0x2d89e4,null));};exports['getQueues']=function(_0x3e2bd9,_0x3a68f7,_0x3b2ab3){var _0x41ce95;var _0x18c59c;var _0x57e12c={};var _0xb8b504;return db['User'][_0xfb7f('0xc9')]({'where':{'id':_0x3e2bd9[_0xfb7f('0x62')]['id']},'attributes':['id',_0xfb7f('0x3d'),'role']})['then'](handleEntityNotFound(_0x3a68f7,null))[_0xfb7f('0x2f')](function(_0x12a82c){if(!utils['isValidChannel'](_0x3e2bd9[_0xfb7f('0x4b')][_0xfb7f('0xa0')])){throw new db[(_0xfb7f('0x96'))]['ValidationError'](_0xfb7f('0xa4'));}_0x41ce95=_0x12a82c;var _0x41b47a={};_0x41b47a[_0xfb7f('0x46')]=_[_0xfb7f('0x49')](db[_[_0xfb7f('0xb4')](_0x3e2bd9[_0xfb7f('0x4b')][_0xfb7f('0xa0')])+'Queue'][_0xfb7f('0xc1')]);_0x41b47a['query']=_[_0xfb7f('0x49')](_0x3e2bd9[_0xfb7f('0x4b')]);_0x41b47a[_0xfb7f('0x51')]=_[_0xfb7f('0x4a')](_0x41b47a[_0xfb7f('0x46')],_0x41b47a[_0xfb7f('0x4b')]);_0x57e12c[_0xfb7f('0x4c')]=_[_0xfb7f('0x4a')](_0x41b47a['model'],qs[_0xfb7f('0x4d')](_0x3e2bd9[_0xfb7f('0x4b')][_0xfb7f('0x4d')]));_0x57e12c[_0xfb7f('0x4c')]=_0x57e12c[_0xfb7f('0x4c')][_0xfb7f('0x60')]?_0x57e12c[_0xfb7f('0x4c')]:_0x41b47a[_0xfb7f('0x46')];_0x57e12c[_0xfb7f('0x50')]=qs['sort'](_0x3e2bd9['query'][_0xfb7f('0xc2')]);_0x57e12c[_0xfb7f('0x53')]=qs['filters'](_[_0xfb7f('0x52')](_0x3e2bd9[_0xfb7f('0x4b')],_0x41b47a[_0xfb7f('0x51')]));if(_0x3e2bd9[_0xfb7f('0x4b')][_0xfb7f('0x38')]){_0x57e12c['where']=_[_0xfb7f('0x54')](_0x57e12c[_0xfb7f('0x53')],{'$or':_['map'](_0x57e12c[_0xfb7f('0x4c')],function(_0x2c875e){var _0x421b2c={};_0x421b2c[_0x2c875e]={'$like':'%'+_0x3e2bd9[_0xfb7f('0x4b')][_0xfb7f('0x38')]+'%'};return _0x421b2c;})});}_0x57e12c=_[_0xfb7f('0x54')]({},_0x57e12c,_0x3e2bd9['options']);switch(_0x41ce95[_0xfb7f('0x32')]){case _0xfb7f('0x33'):return db[_[_0xfb7f('0xb4')](_0x3e2bd9[_0xfb7f('0x4b')][_0xfb7f('0xa0')])+_0xfb7f('0xca')]['findAll'](_0x57e12c);case _0xfb7f('0x80'):case'agent':return _0x41ce95[_0xfb7f('0x31')+_[_0xfb7f('0xb4')](_0x3e2bd9[_0xfb7f('0x4b')][_0xfb7f('0xa0')])+_0xfb7f('0xa7')](_0x57e12c);default:throw new db['Sequelize'][(_0xfb7f('0x97'))]('Unknown\x20role');}})['then'](function(_0x517edf){_0xb8b504=_0x517edf[_0xfb7f('0x60')];if(!_0x3e2bd9[_0xfb7f('0x4b')]['hasOwnProperty']('nolimit')){_0x57e12c[_0xfb7f('0x28')]=qs[_0xfb7f('0x28')](_0x3e2bd9[_0xfb7f('0x4b')][_0xfb7f('0x28')]);_0x57e12c[_0xfb7f('0x27')]=qs[_0xfb7f('0x27')](_0x3e2bd9[_0xfb7f('0x4b')]['offset']);}switch(_0x41ce95[_0xfb7f('0x32')]){case _0xfb7f('0x33'):return db[_[_0xfb7f('0xb4')](_0x3e2bd9[_0xfb7f('0x4b')]['channel'])+'Queue'][_0xfb7f('0x5b')](_0x57e12c);case'user':case'agent':return _0x41ce95[_0xfb7f('0x31')+_[_0xfb7f('0xb4')](_0x3e2bd9['query'][_0xfb7f('0xa0')])+_0xfb7f('0xa7')](_0x57e12c);}})['then'](function(_0x1ac4a1){return{'count':_0xb8b504,'rows':_0x1ac4a1};})[_0xfb7f('0x2f')](respondWithResult(_0x3a68f7,null))[_0xfb7f('0x5d')](handleError(_0x3a68f7,null));};exports[_0xfb7f('0xcb')]=function(_0x452902,_0x2f614d,_0x3cbc36){var _0x18d3b0={};var _0x1a3dcb={};var _0x5172f1;var _0x1a68eb;return db[_0xfb7f('0x42')]['findOne']({'where':{'id':_0x452902[_0xfb7f('0x62')]['id']}})[_0xfb7f('0x2f')](handleEntityNotFound(_0x2f614d,null))['then'](function(_0x48ddbb){if(_0x48ddbb){_0x5172f1=_0x48ddbb;_0x1a3dcb[_0xfb7f('0x46')]=_['keys'](db[_0xfb7f('0xcc')]['rawAttributes']);_0x1a3dcb[_0xfb7f('0x4b')]=_['keys'](_0x452902[_0xfb7f('0x4b')]);_0x1a3dcb[_0xfb7f('0x51')]=_[_0xfb7f('0x4a')](_0x1a3dcb['model'],_0x1a3dcb[_0xfb7f('0x4b')]);_0x18d3b0[_0xfb7f('0x4c')]=_[_0xfb7f('0x4a')](_0x1a3dcb[_0xfb7f('0x46')],qs[_0xfb7f('0x4d')](_0x452902[_0xfb7f('0x4b')][_0xfb7f('0x4d')]));_0x18d3b0['attributes']=_0x18d3b0['attributes'][_0xfb7f('0x60')]?_0x18d3b0[_0xfb7f('0x4c')]:_0x1a3dcb[_0xfb7f('0x46')];_0x18d3b0[_0xfb7f('0x50')]=qs['sort'](_0x452902[_0xfb7f('0x4b')]['sort']);_0x18d3b0[_0xfb7f('0x53')]=qs[_0xfb7f('0x51')](_[_0xfb7f('0x52')](_0x452902[_0xfb7f('0x4b')],_0x1a3dcb[_0xfb7f('0x51')]));if(_0x452902['query'][_0xfb7f('0x38')]){_0x18d3b0[_0xfb7f('0x53')]=_[_0xfb7f('0x54')](_0x18d3b0[_0xfb7f('0x53')],{'$or':_[_0xfb7f('0x41')](_0x18d3b0[_0xfb7f('0x4c')],function(_0x172888){var _0x1c13cd={};_0x1c13cd[_0x172888]={'$like':'%'+_0x452902[_0xfb7f('0x4b')]['filter']+'%'};return _0x1c13cd;})});}_0x18d3b0=_[_0xfb7f('0x54')]({},_0x18d3b0,_0x452902[_0xfb7f('0x58')]);return _0x5172f1[_0xfb7f('0xcb')](_0x18d3b0);}})[_0xfb7f('0x2f')](function(_0x4de275){if(_0x4de275){_0x1a68eb=_0x4de275[_0xfb7f('0x60')];if(!_0x452902['query'][_0xfb7f('0x4e')](_0xfb7f('0x4f'))){_0x18d3b0['limit']=qs[_0xfb7f('0x28')](_0x452902[_0xfb7f('0x4b')][_0xfb7f('0x28')]);_0x18d3b0['offset']=qs[_0xfb7f('0x27')](_0x452902[_0xfb7f('0x4b')][_0xfb7f('0x27')]);}return _0x5172f1['getVoiceQueuesRt'](_0x18d3b0);}})['then'](function(_0x23bd04){if(_0x23bd04){return _0x23bd04?{'count':_0x1a68eb,'rows':_0x23bd04}:null;}})[_0xfb7f('0x2f')](respondWithResult(_0x2f614d,null))['catch'](handleError(_0x2f614d,null));};exports[_0xfb7f('0xcd')]=function(_0x3d14c4,_0x2bfd95,_0x46da3d){var _0x557cb0={};var _0x1fff93={};var _0x1eff17;var _0x3fc390;return db[_0xfb7f('0x42')][_0xfb7f('0xc9')]({'where':{'id':_0x3d14c4['params']['id']}})['then'](handleEntityNotFound(_0x2bfd95,null))[_0xfb7f('0x2f')](function(_0x23356b){if(_0x23356b){_0x1eff17=_0x23356b;_0x1fff93[_0xfb7f('0x46')]=_[_0xfb7f('0x49')](db[_0xfb7f('0xce')]['rawAttributes']);_0x1fff93['query']=_[_0xfb7f('0x49')](_0x3d14c4[_0xfb7f('0x4b')]);_0x1fff93[_0xfb7f('0x51')]=_['intersection'](_0x1fff93['model'],_0x1fff93['query']);_0x557cb0[_0xfb7f('0x4c')]=_['intersection'](_0x1fff93[_0xfb7f('0x46')],qs['fields'](_0x3d14c4['query'][_0xfb7f('0x4d')]));_0x557cb0['attributes']=_0x557cb0[_0xfb7f('0x4c')]['length']?_0x557cb0[_0xfb7f('0x4c')]:_0x1fff93[_0xfb7f('0x46')];_0x557cb0[_0xfb7f('0x50')]=qs[_0xfb7f('0xc2')](_0x3d14c4[_0xfb7f('0x4b')][_0xfb7f('0xc2')]);_0x557cb0[_0xfb7f('0x53')]=qs['filters'](_['pick'](_0x3d14c4[_0xfb7f('0x4b')],_0x1fff93[_0xfb7f('0x51')]));if(_0x3d14c4[_0xfb7f('0x4b')][_0xfb7f('0x38')]){_0x557cb0[_0xfb7f('0x53')]=_['merge'](_0x557cb0[_0xfb7f('0x53')],{'$or':_[_0xfb7f('0x41')](_0x557cb0[_0xfb7f('0x4c')],function(_0x336980){var _0x1e30a2={};_0x1e30a2[_0x336980]={'$like':'%'+_0x3d14c4[_0xfb7f('0x4b')][_0xfb7f('0x38')]+'%'};return _0x1e30a2;})});}_0x557cb0=_['merge']({},_0x557cb0,_0x3d14c4['options']);return _0x1eff17['getGroups'](_0x557cb0);}})[_0xfb7f('0x2f')](function(_0x4ea526){if(_0x4ea526){_0x3fc390=_0x4ea526[_0xfb7f('0x60')];if(!_0x3d14c4[_0xfb7f('0x4b')][_0xfb7f('0x4e')]('nolimit')){_0x557cb0[_0xfb7f('0x28')]=qs['limit'](_0x3d14c4['query'][_0xfb7f('0x28')]);_0x557cb0[_0xfb7f('0x27')]=qs['offset'](_0x3d14c4['query'][_0xfb7f('0x27')]);}return _0x1eff17[_0xfb7f('0xcd')](_0x557cb0);}})[_0xfb7f('0x2f')](function(_0x5537a7){if(_0x5537a7){return _0x5537a7?{'count':_0x3fc390,'rows':_0x5537a7}:null;}})[_0xfb7f('0x2f')](respondWithResult(_0x2bfd95,null))[_0xfb7f('0x5d')](handleError(_0x2bfd95,null));};exports[_0xfb7f('0xcf')]=function(_0x17cf63,_0x2d16a0,_0x494b56){var _0x5ac319={'raw':!![],'where':{}};var _0x1ef785={};var _0x5ec5c={'count':0x0,'rows':[]};return db['User'][_0xfb7f('0xc9')]({'where':{'id':_0x17cf63[_0xfb7f('0x62')]['id']}})[_0xfb7f('0x2f')](handleEntityNotFound(_0x2d16a0,null))[_0xfb7f('0x2f')](function(_0xed876b){if(_0xed876b){_0x1ef785[_0xfb7f('0x46')]=_[_0xfb7f('0x49')](db[_0xfb7f('0xd0')][_0xfb7f('0xc1')]);_0x1ef785['query']=_['keys'](_0x17cf63[_0xfb7f('0x4b')]);_0x1ef785[_0xfb7f('0x51')]=_[_0xfb7f('0x4a')](_0x1ef785[_0xfb7f('0x46')],_0x1ef785['query']);_0x5ac319[_0xfb7f('0x4c')]=_[_0xfb7f('0x4a')](_0x1ef785[_0xfb7f('0x46')],qs[_0xfb7f('0x4d')](_0x17cf63[_0xfb7f('0x4b')][_0xfb7f('0x4d')]));_0x5ac319[_0xfb7f('0x4c')]=_0x5ac319[_0xfb7f('0x4c')]['length']?_0x5ac319['attributes']:_0x1ef785[_0xfb7f('0x46')];if(!_0x17cf63[_0xfb7f('0x4b')][_0xfb7f('0x4e')]('nolimit')){_0x5ac319['limit']=qs['limit'](_0x17cf63[_0xfb7f('0x4b')][_0xfb7f('0x28')]);_0x5ac319[_0xfb7f('0x27')]=qs[_0xfb7f('0x27')](_0x17cf63[_0xfb7f('0x4b')][_0xfb7f('0x27')]);}_0x5ac319[_0xfb7f('0x50')]=qs[_0xfb7f('0xc2')](_0x17cf63[_0xfb7f('0x4b')][_0xfb7f('0xc2')]);_0x5ac319[_0xfb7f('0x53')]=qs['filters'](_['pick'](_0x17cf63[_0xfb7f('0x4b')],_0x1ef785[_0xfb7f('0x51')]));_0x5ac319[_0xfb7f('0x53')][_0xfb7f('0xd1')]=_0xed876b['id'];if(_0x17cf63[_0xfb7f('0x4b')][_0xfb7f('0x38')]){_0x5ac319[_0xfb7f('0x53')]=_[_0xfb7f('0x54')](_0x5ac319['where'],{'$or':_[_0xfb7f('0x41')](_0x5ac319['attributes'],function(_0x57f536){var _0x85cc76={};_0x85cc76[_0x57f536]={'$like':'%'+_0x17cf63[_0xfb7f('0x4b')][_0xfb7f('0x38')]+'%'};return _0x85cc76;})});}_0x5ac319=_[_0xfb7f('0x54')]({},_0x5ac319,_0x17cf63[_0xfb7f('0x58')]);return db[_0xfb7f('0xd0')][_0xfb7f('0x26')]({'where':_0x5ac319[_0xfb7f('0x53')]})[_0xfb7f('0x2f')](function(_0x2a2b2f){_0x5ec5c['count']=_0x2a2b2f;if(_0x17cf63[_0xfb7f('0x4b')][_0xfb7f('0x59')]){_0x5ac319[_0xfb7f('0x5a')]=[{'all':!![]}];}return db[_0xfb7f('0xd0')]['findAll'](_0x5ac319);})[_0xfb7f('0x2f')](function(_0x16d013){_0x5ec5c[_0xfb7f('0x5c')]=_0x16d013;return _0x5ec5c;});}})['then'](respondWithFilteredResult(_0x2d16a0,_0x5ac319))[_0xfb7f('0x5d')](handleError(_0x2d16a0,null));};exports[_0xfb7f('0xd2')]=function(_0x16a508,_0x37f630,_0x2742eb){var _0x27c717={'raw':!![],'where':{}};var _0x191ab2={};var _0x183b1a={'count':0x0,'rows':[]};return db[_0xfb7f('0x42')]['findOne']({'where':{'id':_0x16a508[_0xfb7f('0x62')]['id']}})[_0xfb7f('0x2f')](handleEntityNotFound(_0x37f630,null))[_0xfb7f('0x2f')](function(_0xaa80d7){if(_0xaa80d7){_0x191ab2['model']=_['keys'](db[_0xfb7f('0xd3')]['rawAttributes']);_0x191ab2['query']=_[_0xfb7f('0x49')](_0x16a508[_0xfb7f('0x4b')]);_0x191ab2[_0xfb7f('0x51')]=_[_0xfb7f('0x4a')](_0x191ab2['model'],_0x191ab2['query']);_0x27c717['attributes']=_[_0xfb7f('0x4a')](_0x191ab2[_0xfb7f('0x46')],qs['fields'](_0x16a508[_0xfb7f('0x4b')][_0xfb7f('0x4d')]));_0x27c717[_0xfb7f('0x4c')]=_0x27c717[_0xfb7f('0x4c')][_0xfb7f('0x60')]?_0x27c717[_0xfb7f('0x4c')]:_0x191ab2['model'];if(!_0x16a508['query'][_0xfb7f('0x4e')]('nolimit')){_0x27c717[_0xfb7f('0x28')]=qs['limit'](_0x16a508[_0xfb7f('0x4b')][_0xfb7f('0x28')]);_0x27c717[_0xfb7f('0x27')]=qs[_0xfb7f('0x27')](_0x16a508['query'][_0xfb7f('0x27')]);}_0x27c717['order']=qs[_0xfb7f('0xc2')](_0x16a508[_0xfb7f('0x4b')][_0xfb7f('0xc2')]);_0x27c717[_0xfb7f('0x53')]=qs[_0xfb7f('0x51')](_[_0xfb7f('0x52')](_0x16a508[_0xfb7f('0x4b')],_0x191ab2[_0xfb7f('0x51')]));_0x27c717[_0xfb7f('0x53')][_0xfb7f('0xd1')]=_0xaa80d7['id'];if(_0x16a508['query'][_0xfb7f('0x38')]){_0x27c717[_0xfb7f('0x53')]=_[_0xfb7f('0x54')](_0x27c717[_0xfb7f('0x53')],{'$or':_['map'](_0x27c717[_0xfb7f('0x4c')],function(_0x20a2d9){var _0x2abfcf={};_0x2abfcf[_0x20a2d9]={'$like':'%'+_0x16a508[_0xfb7f('0x4b')]['filter']+'%'};return _0x2abfcf;})});}_0x27c717=_[_0xfb7f('0x54')]({},_0x27c717,_0x16a508[_0xfb7f('0x58')]);return db[_0xfb7f('0xd3')]['count']({'where':_0x27c717['where']})[_0xfb7f('0x2f')](function(_0x4279af){_0x183b1a[_0xfb7f('0x26')]=_0x4279af;if(_0x16a508['query'][_0xfb7f('0x59')]){_0x27c717['include']=[{'all':!![]}];}return db[_0xfb7f('0xd3')][_0xfb7f('0x5b')](_0x27c717);})[_0xfb7f('0x2f')](function(_0x4aa602){_0x183b1a['rows']=_0x4aa602;return _0x183b1a;});}})[_0xfb7f('0x2f')](respondWithFilteredResult(_0x37f630,_0x27c717))[_0xfb7f('0x5d')](handleError(_0x37f630,null));};exports[_0xfb7f('0xd4')]=function(_0x1a5c5d,_0x1770f4,_0x25ec5a){var _0x345b0c={};var _0x3ea735={};var _0x14ff8a;var _0x21723b;return db[_0xfb7f('0x42')]['findOne']({'where':{'id':_0x1a5c5d['params']['id']}})['then'](handleEntityNotFound(_0x1770f4,null))[_0xfb7f('0x2f')](function(_0xd42b00){if(_0xd42b00){_0x14ff8a=_0xd42b00;_0x3ea735[_0xfb7f('0x46')]=_[_0xfb7f('0x49')](db['ChatInteraction'][_0xfb7f('0xc1')]);_0x3ea735[_0xfb7f('0x4b')]=_[_0xfb7f('0x49')](_0x1a5c5d['query']);_0x3ea735[_0xfb7f('0x51')]=_[_0xfb7f('0x4a')](_0x3ea735['model'],_0x3ea735['query']);_0x345b0c[_0xfb7f('0x4c')]=_[_0xfb7f('0x4a')](_0x3ea735[_0xfb7f('0x46')],qs[_0xfb7f('0x4d')](_0x1a5c5d[_0xfb7f('0x4b')][_0xfb7f('0x4d')]));_0x345b0c[_0xfb7f('0x4c')]=_0x345b0c[_0xfb7f('0x4c')]['length']?_0x345b0c[_0xfb7f('0x4c')]:_0x3ea735[_0xfb7f('0x46')];_0x345b0c[_0xfb7f('0x50')]=qs[_0xfb7f('0xc2')](_0x1a5c5d[_0xfb7f('0x4b')][_0xfb7f('0xc2')]);_0x345b0c['where']=qs[_0xfb7f('0x51')](_[_0xfb7f('0x52')](_0x1a5c5d['query'],_0x3ea735[_0xfb7f('0x51')]));if(_0x1a5c5d[_0xfb7f('0x4b')][_0xfb7f('0x38')]){_0x345b0c[_0xfb7f('0x53')]=_[_0xfb7f('0x54')](_0x345b0c[_0xfb7f('0x53')],{'$or':_[_0xfb7f('0x41')](_0x345b0c['attributes'],function(_0x269255){var _0x4e7b5e={};_0x4e7b5e[_0x269255]={'$like':'%'+_0x1a5c5d[_0xfb7f('0x4b')]['filter']+'%'};return _0x4e7b5e;})});}_0x345b0c=_[_0xfb7f('0x54')]({},_0x345b0c,_0x1a5c5d[_0xfb7f('0x58')]);return _0x14ff8a[_0xfb7f('0xd4')](_0x345b0c);}})[_0xfb7f('0x2f')](function(_0x5e90c0){if(_0x5e90c0){_0x21723b=_0x5e90c0[_0xfb7f('0x60')];if(!_0x1a5c5d['query']['hasOwnProperty'](_0xfb7f('0x4f'))){_0x345b0c[_0xfb7f('0x28')]=qs[_0xfb7f('0x28')](_0x1a5c5d[_0xfb7f('0x4b')][_0xfb7f('0x28')]);_0x345b0c[_0xfb7f('0x27')]=qs[_0xfb7f('0x27')](_0x1a5c5d['query']['offset']);}return _0x14ff8a['getChatInteractions'](_0x345b0c);}})['then'](function(_0x41aaf7){if(_0x41aaf7){return _0x41aaf7?{'count':_0x21723b,'rows':_0x41aaf7}:null;}})[_0xfb7f('0x2f')](respondWithResult(_0x1770f4,null))['catch'](handleError(_0x1770f4,null));};exports[_0xfb7f('0xd5')]=function(_0x33ca6a,_0x2d6f77,_0x5e90ed){var _0x2ead82={};var _0x36486d={};var _0x3084ab;var _0x3131e2;return db['User'][_0xfb7f('0xc9')]({'where':{'id':_0x33ca6a[_0xfb7f('0x62')]['id']}})[_0xfb7f('0x2f')](handleEntityNotFound(_0x2d6f77,null))[_0xfb7f('0x2f')](function(_0x144d3d){if(_0x144d3d){_0x3084ab=_0x144d3d;_0x36486d[_0xfb7f('0x46')]=_['keys'](db[_0xfb7f('0xd6')][_0xfb7f('0xc1')]);_0x36486d[_0xfb7f('0x4b')]=_[_0xfb7f('0x49')](_0x33ca6a[_0xfb7f('0x4b')]);_0x36486d[_0xfb7f('0x51')]=_['intersection'](_0x36486d[_0xfb7f('0x46')],_0x36486d[_0xfb7f('0x4b')]);_0x2ead82[_0xfb7f('0x4c')]=_['intersection'](_0x36486d['model'],qs['fields'](_0x33ca6a[_0xfb7f('0x4b')][_0xfb7f('0x4d')]));_0x2ead82[_0xfb7f('0x4c')]=_0x2ead82[_0xfb7f('0x4c')][_0xfb7f('0x60')]?_0x2ead82[_0xfb7f('0x4c')]:_0x36486d[_0xfb7f('0x46')];_0x2ead82[_0xfb7f('0x50')]=qs[_0xfb7f('0xc2')](_0x33ca6a[_0xfb7f('0x4b')]['sort']);_0x2ead82[_0xfb7f('0x53')]=qs[_0xfb7f('0x51')](_['pick'](_0x33ca6a[_0xfb7f('0x4b')],_0x36486d['filters']));if(_0x33ca6a[_0xfb7f('0x4b')][_0xfb7f('0x38')]){_0x2ead82[_0xfb7f('0x53')]=_[_0xfb7f('0x54')](_0x2ead82[_0xfb7f('0x53')],{'$or':_[_0xfb7f('0x41')](_0x2ead82['attributes'],function(_0x22b5f6){var _0x39a952={};_0x39a952[_0x22b5f6]={'$like':'%'+_0x33ca6a[_0xfb7f('0x4b')][_0xfb7f('0x38')]+'%'};return _0x39a952;})});}_0x2ead82=_['merge']({},_0x2ead82,_0x33ca6a[_0xfb7f('0x58')]);return _0x3084ab[_0xfb7f('0xd5')](_0x2ead82);}})['then'](function(_0x5d4f8a){if(_0x5d4f8a){_0x3131e2=_0x5d4f8a[_0xfb7f('0x60')];if(!_0x33ca6a[_0xfb7f('0x4b')]['hasOwnProperty'](_0xfb7f('0x4f'))){_0x2ead82[_0xfb7f('0x28')]=qs[_0xfb7f('0x28')](_0x33ca6a[_0xfb7f('0x4b')][_0xfb7f('0x28')]);_0x2ead82[_0xfb7f('0x27')]=qs[_0xfb7f('0x27')](_0x33ca6a['query']['offset']);}return _0x3084ab[_0xfb7f('0xd5')](_0x2ead82);}})[_0xfb7f('0x2f')](function(_0x1881bf){if(_0x1881bf){return _0x1881bf?{'count':_0x3131e2,'rows':_0x1881bf}:null;}})[_0xfb7f('0x2f')](respondWithResult(_0x2d6f77,null))['catch'](handleError(_0x2d6f77,null));};exports['getMailInteractions']=function(_0x17238b,_0x378bc6,_0x23e8b0){var _0x3b2922={'raw':!![],'where':{}};var _0x4b81ae={};var _0x14dfc6={'count':0x0,'rows':[]};return db[_0xfb7f('0x42')][_0xfb7f('0xc9')]({'where':{'id':_0x17238b[_0xfb7f('0x62')]['id']}})[_0xfb7f('0x2f')](handleEntityNotFound(_0x378bc6,null))[_0xfb7f('0x2f')](function(_0x47d9b0){if(_0x47d9b0){_0x4b81ae[_0xfb7f('0x46')]=_[_0xfb7f('0x49')](db[_0xfb7f('0xd7')][_0xfb7f('0xc1')]);_0x4b81ae[_0xfb7f('0x4b')]=_['keys'](_0x17238b['query']);_0x4b81ae[_0xfb7f('0x51')]=_['intersection'](_0x4b81ae[_0xfb7f('0x46')],_0x4b81ae[_0xfb7f('0x4b')]);_0x3b2922[_0xfb7f('0x4c')]=_['intersection'](_0x4b81ae[_0xfb7f('0x46')],qs['fields'](_0x17238b[_0xfb7f('0x4b')]['fields']));_0x3b2922[_0xfb7f('0x4c')]=_0x3b2922[_0xfb7f('0x4c')][_0xfb7f('0x60')]?_0x3b2922[_0xfb7f('0x4c')]:_0x4b81ae[_0xfb7f('0x46')];if(!_0x17238b[_0xfb7f('0x4b')][_0xfb7f('0x4e')](_0xfb7f('0x4f'))){_0x3b2922[_0xfb7f('0x28')]=qs[_0xfb7f('0x28')](_0x17238b[_0xfb7f('0x4b')][_0xfb7f('0x28')]);_0x3b2922[_0xfb7f('0x27')]=qs['offset'](_0x17238b[_0xfb7f('0x4b')][_0xfb7f('0x27')]);}_0x3b2922['order']=qs['sort'](_0x17238b[_0xfb7f('0x4b')][_0xfb7f('0xc2')]);_0x3b2922['where']=qs[_0xfb7f('0x51')](_[_0xfb7f('0x52')](_0x17238b[_0xfb7f('0x4b')],_0x4b81ae['filters']));_0x3b2922[_0xfb7f('0x53')][_0xfb7f('0xd1')]=_0x47d9b0['id'];if(_0x17238b[_0xfb7f('0x4b')][_0xfb7f('0x38')]){_0x3b2922[_0xfb7f('0x53')]=_[_0xfb7f('0x54')](_0x3b2922[_0xfb7f('0x53')],{'$or':_[_0xfb7f('0x41')](_0x3b2922[_0xfb7f('0x4c')],function(_0x560c6d){var _0x28857e={};_0x28857e[_0x560c6d]={'$like':'%'+_0x17238b[_0xfb7f('0x4b')][_0xfb7f('0x38')]+'%'};return _0x28857e;})});}_0x3b2922=_[_0xfb7f('0x54')]({},_0x3b2922,_0x17238b[_0xfb7f('0x58')]);return db[_0xfb7f('0xd7')][_0xfb7f('0x26')]({'where':_0x3b2922[_0xfb7f('0x53')]})['then'](function(_0x4601ea){_0x14dfc6[_0xfb7f('0x26')]=_0x4601ea;if(_0x17238b['query']['includeAll']){_0x3b2922[_0xfb7f('0x5a')]=[{'all':!![]}];}return db['MailInteraction'][_0xfb7f('0x5b')](_0x3b2922);})[_0xfb7f('0x2f')](function(_0x2094ba){_0x14dfc6[_0xfb7f('0x5c')]=_0x2094ba;return _0x14dfc6;});}})[_0xfb7f('0x2f')](respondWithFilteredResult(_0x378bc6,_0x3b2922))[_0xfb7f('0x5d')](handleError(_0x378bc6,null));};exports[_0xfb7f('0xd8')]=function(_0x425b0b,_0x454258,_0x1cf4a1){var _0x72681f={};var _0x55db27={};var _0x2d68ca;var _0x309efb;return db['User'][_0xfb7f('0xc9')]({'where':{'id':_0x425b0b[_0xfb7f('0x62')]['id']}})[_0xfb7f('0x2f')](handleEntityNotFound(_0x454258,null))[_0xfb7f('0x2f')](function(_0x3c96a8){if(_0x3c96a8){_0x2d68ca=_0x3c96a8;_0x55db27[_0xfb7f('0x46')]=_[_0xfb7f('0x49')](db[_0xfb7f('0xd9')]['rawAttributes']);_0x55db27[_0xfb7f('0x4b')]=_[_0xfb7f('0x49')](_0x425b0b['query']);_0x55db27[_0xfb7f('0x51')]=_[_0xfb7f('0x4a')](_0x55db27[_0xfb7f('0x46')],_0x55db27[_0xfb7f('0x4b')]);_0x72681f['attributes']=_[_0xfb7f('0x4a')](_0x55db27[_0xfb7f('0x46')],qs[_0xfb7f('0x4d')](_0x425b0b[_0xfb7f('0x4b')]['fields']));_0x72681f[_0xfb7f('0x4c')]=_0x72681f['attributes']['length']?_0x72681f[_0xfb7f('0x4c')]:_0x55db27[_0xfb7f('0x46')];_0x72681f['order']=qs[_0xfb7f('0xc2')](_0x425b0b[_0xfb7f('0x4b')]['sort']);_0x72681f[_0xfb7f('0x53')]=qs[_0xfb7f('0x51')](_[_0xfb7f('0x52')](_0x425b0b['query'],_0x55db27['filters']));if(_0x425b0b['query'][_0xfb7f('0x38')]){_0x72681f[_0xfb7f('0x53')]=_['merge'](_0x72681f[_0xfb7f('0x53')],{'$or':_['map'](_0x72681f[_0xfb7f('0x4c')],function(_0x1f6786){var _0x46df7a={};_0x46df7a[_0x1f6786]={'$like':'%'+_0x425b0b[_0xfb7f('0x4b')][_0xfb7f('0x38')]+'%'};return _0x46df7a;})});}_0x72681f=_['merge']({},_0x72681f,_0x425b0b[_0xfb7f('0x58')]);return _0x2d68ca[_0xfb7f('0xd8')](_0x72681f);}})['then'](function(_0xca6abb){if(_0xca6abb){_0x309efb=_0xca6abb['length'];if(!_0x425b0b[_0xfb7f('0x4b')]['hasOwnProperty'](_0xfb7f('0x4f'))){_0x72681f['limit']=qs[_0xfb7f('0x28')](_0x425b0b['query'][_0xfb7f('0x28')]);_0x72681f[_0xfb7f('0x27')]=qs[_0xfb7f('0x27')](_0x425b0b[_0xfb7f('0x4b')][_0xfb7f('0x27')]);}return _0x2d68ca['getSmsInteractions'](_0x72681f);}})['then'](function(_0xfa033d){if(_0xfa033d){return _0xfa033d?{'count':_0x309efb,'rows':_0xfa033d}:null;}})[_0xfb7f('0x2f')](respondWithResult(_0x454258,null))[_0xfb7f('0x5d')](handleError(_0x454258,null));};exports[_0xfb7f('0xda')]=function(_0x2a054a,_0x109f0d,_0x197292){var _0xa4cf8a={};var _0xef5b3d={};var _0x3ecb10;var _0x5494d7;return db[_0xfb7f('0x42')][_0xfb7f('0xc9')]({'where':{'id':_0x2a054a[_0xfb7f('0x62')]['id']}})[_0xfb7f('0x2f')](handleEntityNotFound(_0x109f0d,null))[_0xfb7f('0x2f')](function(_0x681ff5){if(_0x681ff5){_0x3ecb10=_0x681ff5;_0xef5b3d[_0xfb7f('0x46')]=_[_0xfb7f('0x49')](db[_0xfb7f('0xdb')][_0xfb7f('0xc1')]);_0xef5b3d['query']=_[_0xfb7f('0x49')](_0x2a054a['query']);_0xef5b3d['filters']=_[_0xfb7f('0x4a')](_0xef5b3d[_0xfb7f('0x46')],_0xef5b3d['query']);_0xa4cf8a['attributes']=_[_0xfb7f('0x4a')](_0xef5b3d[_0xfb7f('0x46')],qs[_0xfb7f('0x4d')](_0x2a054a[_0xfb7f('0x4b')]['fields']));_0xa4cf8a[_0xfb7f('0x4c')]=_0xa4cf8a[_0xfb7f('0x4c')][_0xfb7f('0x60')]?_0xa4cf8a[_0xfb7f('0x4c')]:_0xef5b3d['model'];_0xa4cf8a[_0xfb7f('0x50')]=qs[_0xfb7f('0xc2')](_0x2a054a[_0xfb7f('0x4b')]['sort']);_0xa4cf8a['where']=qs[_0xfb7f('0x51')](_[_0xfb7f('0x52')](_0x2a054a[_0xfb7f('0x4b')],_0xef5b3d[_0xfb7f('0x51')]));if(_0x2a054a[_0xfb7f('0x4b')]['filter']){_0xa4cf8a[_0xfb7f('0x53')]=_[_0xfb7f('0x54')](_0xa4cf8a[_0xfb7f('0x53')],{'$or':_[_0xfb7f('0x41')](_0xa4cf8a[_0xfb7f('0x4c')],function(_0x57f7f3){var _0x49e7cb={};_0x49e7cb[_0x57f7f3]={'$like':'%'+_0x2a054a[_0xfb7f('0x4b')][_0xfb7f('0x38')]+'%'};return _0x49e7cb;})});}_0xa4cf8a=_[_0xfb7f('0x54')]({},_0xa4cf8a,_0x2a054a['options']);return _0x3ecb10['getFaxInteractions'](_0xa4cf8a);}})['then'](function(_0x94d722){if(_0x94d722){_0x5494d7=_0x94d722[_0xfb7f('0x60')];if(!_0x2a054a['query'][_0xfb7f('0x4e')](_0xfb7f('0x4f'))){_0xa4cf8a[_0xfb7f('0x28')]=qs['limit'](_0x2a054a['query'][_0xfb7f('0x28')]);_0xa4cf8a[_0xfb7f('0x27')]=qs[_0xfb7f('0x27')](_0x2a054a[_0xfb7f('0x4b')]['offset']);}return _0x3ecb10[_0xfb7f('0xda')](_0xa4cf8a);}})[_0xfb7f('0x2f')](function(_0x57a045){if(_0x57a045){return _0x57a045?{'count':_0x5494d7,'rows':_0x57a045}:null;}})[_0xfb7f('0x2f')](respondWithResult(_0x109f0d,null))['catch'](handleError(_0x109f0d,null));};exports['getWhatsappInteractions']=function(_0x1e4579,_0x39ace0,_0x4a9712){var _0x5e3385={};var _0x34f78e={};var _0x3ffd5c;var _0x344a63;return db['User']['findOne']({'where':{'id':_0x1e4579['params']['id']}})[_0xfb7f('0x2f')](handleEntityNotFound(_0x39ace0,null))[_0xfb7f('0x2f')](function(_0x15ba73){if(_0x15ba73){_0x3ffd5c=_0x15ba73;_0x34f78e[_0xfb7f('0x46')]=_[_0xfb7f('0x49')](db[_0xfb7f('0xdc')][_0xfb7f('0xc1')]);_0x34f78e[_0xfb7f('0x4b')]=_[_0xfb7f('0x49')](_0x1e4579[_0xfb7f('0x4b')]);_0x34f78e['filters']=_[_0xfb7f('0x4a')](_0x34f78e[_0xfb7f('0x46')],_0x34f78e[_0xfb7f('0x4b')]);_0x5e3385[_0xfb7f('0x4c')]=_[_0xfb7f('0x4a')](_0x34f78e[_0xfb7f('0x46')],qs[_0xfb7f('0x4d')](_0x1e4579[_0xfb7f('0x4b')][_0xfb7f('0x4d')]));_0x5e3385[_0xfb7f('0x4c')]=_0x5e3385[_0xfb7f('0x4c')][_0xfb7f('0x60')]?_0x5e3385[_0xfb7f('0x4c')]:_0x34f78e[_0xfb7f('0x46')];_0x5e3385['order']=qs[_0xfb7f('0xc2')](_0x1e4579[_0xfb7f('0x4b')][_0xfb7f('0xc2')]);_0x5e3385['where']=qs[_0xfb7f('0x51')](_['pick'](_0x1e4579['query'],_0x34f78e[_0xfb7f('0x51')]));if(_0x1e4579[_0xfb7f('0x4b')][_0xfb7f('0x38')]){_0x5e3385[_0xfb7f('0x53')]=_['merge'](_0x5e3385[_0xfb7f('0x53')],{'$or':_['map'](_0x5e3385[_0xfb7f('0x4c')],function(_0x4f21a7){var _0x335156={};_0x335156[_0x4f21a7]={'$like':'%'+_0x1e4579['query'][_0xfb7f('0x38')]+'%'};return _0x335156;})});}_0x5e3385=_[_0xfb7f('0x54')]({},_0x5e3385,_0x1e4579[_0xfb7f('0x58')]);return _0x3ffd5c[_0xfb7f('0xdd')](_0x5e3385);}})['then'](function(_0xd8aa79){if(_0xd8aa79){_0x344a63=_0xd8aa79[_0xfb7f('0x60')];if(!_0x1e4579['query'][_0xfb7f('0x4e')](_0xfb7f('0x4f'))){_0x5e3385[_0xfb7f('0x28')]=qs[_0xfb7f('0x28')](_0x1e4579['query'][_0xfb7f('0x28')]);_0x5e3385[_0xfb7f('0x27')]=qs[_0xfb7f('0x27')](_0x1e4579[_0xfb7f('0x4b')][_0xfb7f('0x27')]);}return _0x3ffd5c[_0xfb7f('0xdd')](_0x5e3385);}})[_0xfb7f('0x2f')](function(_0x1e01ed){if(_0x1e01ed){return _0x1e01ed?{'count':_0x344a63,'rows':_0x1e01ed}:null;}})['then'](respondWithResult(_0x39ace0,null))[_0xfb7f('0x5d')](handleError(_0x39ace0,null));};exports[_0xfb7f('0xde')]=function(_0x51f97b,_0x5cd1f2,_0x2ea9f6){var _0x5d83b2;var _0x1350c1;var _0x3a999d;var _0x47aabc=!_[_0xfb7f('0x6c')](_0x51f97b[_0xfb7f('0x62')]['id'])?_0x51f97b[_0xfb7f('0x62')]['id']:!_[_0xfb7f('0x6c')](_0x51f97b['user']['id'])?_0x51f97b[_0xfb7f('0x80')]['id']:null;return db[_0xfb7f('0x42')][_0xfb7f('0x3c')]({'where':{'id':_0x47aabc,'role':{'$or':[_0xfb7f('0x33'),_0xfb7f('0x80'),_0xfb7f('0x36')]}},'attributes':['id',_0xfb7f('0x3d'),_0xfb7f('0xdf'),_0xfb7f('0xe0'),_0xfb7f('0x32'),_0xfb7f('0x66'),_0xfb7f('0xa1')]})['then'](function(_0x204e02){if(_0x204e02){if(_0x204e02[_0xfb7f('0x32')]===_0xfb7f('0x36')){_0x5d83b2=_0x204e02;if(_0x51f97b['body'][_0xfb7f('0xa2')]){_0x3a999d=util[_0xfb7f('0xe1')](_0xfb7f('0xe2'),_0x5d83b2[_0x51f97b[_0xfb7f('0x61')]['interface']]);}else if(_0x51f97b[_0xfb7f('0x61')][_0xfb7f('0xe3')]){_0x3a999d=util[_0xfb7f('0xe1')](_0xfb7f('0xae'),_0x51f97b[_0xfb7f('0x61')][_0xfb7f('0xe3')]);}else{_0x3a999d=util[_0xfb7f('0xe1')](_0xfb7f('0xae'),_0x5d83b2['name']);}socket['to'](util[_0xfb7f('0xe1')]('user:%s',_0x5d83b2[_0xfb7f('0x3d')]))[_0xfb7f('0xaa')](_0xfb7f('0xe4'),{'ip':_0x51f97b[_0xfb7f('0xe5')][_0xfb7f('0xe6')]||_0x51f97b[_0xfb7f('0xe7')][_0xfb7f('0xe8')]||_0x51f97b[_0xfb7f('0xe9')][_0xfb7f('0xe8')]||_0x51f97b[_0xfb7f('0xe7')][_0xfb7f('0xe9')][_0xfb7f('0xe8')]});return db[_0xfb7f('0xcc')]['destroy']({'where':{'membername':_0x5d83b2[_0xfb7f('0x3d')]},'individualHooks':!![]});}}else{throw new db['Sequelize'][(_0xfb7f('0x97'))](_0xfb7f('0xea'));}})[_0xfb7f('0x2f')](function(){if(_0x5d83b2){return _0x5d83b2['getVoiceQueues']({'raw':!![]});}})[_0xfb7f('0x2f')](function(_0x303527){if(_0x5d83b2){var _0xbd255d=[];if(_0x303527){_0x1350c1=_0x303527;if(_0x1350c1[_0xfb7f('0x60')]){for(var _0x291943=0x0;_0x291943<_0x1350c1[_0xfb7f('0x60')];_0x291943++){_0xbd255d[_0xfb7f('0x93')]({'membername':_0x5d83b2[_0xfb7f('0x3d')],'UserId':_0x5d83b2['id'],'queue_name':_0x1350c1[_0x291943]['name'],'VoiceQueueId':_0x1350c1[_0x291943]['id'],'interface':_0x3a999d,'paused':_0x5d83b2[_0xfb7f('0xa1')]||![],'penalty':_0x1350c1[_0x291943][_0xfb7f('0xeb')]||0x0});}return BPromise[_0xfb7f('0x8e')](_0xbd255d,function(_0x4df81f){return db[_0xfb7f('0xcc')][_0xfb7f('0xb1')](_0x4df81f);});}}}})['then'](function(){if(_0x5d83b2){return db['MemberReport'][_0xfb7f('0x5b')]({'where':{'membername':_0x5d83b2[_0xfb7f('0x3d')],'exitAt':null}});}})[_0xfb7f('0x2f')](function(_0x4d97fa){if(_0x5d83b2){var _0x22f4f3=[];_0x4d97fa[_0xfb7f('0xec')](function(_0x3bc895){_0x22f4f3[_0xfb7f('0x93')](_0x3bc895['update']({'exitAt':moment()[_0xfb7f('0xe1')](_0xfb7f('0xed'))}));});return BPromise['all'](_0x22f4f3);}})[_0xfb7f('0x2f')](function(){if(_0x5d83b2){var _0x540a39=[];var _0x58da61=[];var _0x1751a8=utils[_0xfb7f('0xee')]();var _0x19092d={'membername':_0x5d83b2['name'],'interface':_0x3a999d,'enterAt':moment()[_0xfb7f('0xe1')]('YYYY-MM-DD\x20HH:mm:ss'),'role':_0x5d83b2[_0xfb7f('0x32')],'internal':_0x5d83b2[_0xfb7f('0x66')]};_0x1751a8[_0xfb7f('0xec')](function(_0x503ce9){_0x540a39['push'](_[_0xfb7f('0x54')]({'channel':_0x503ce9,'type':_0xfb7f('0xef'),'data1':_0x51f97b[_0xfb7f('0x61')][_0xfb7f('0xf0')],'data2':_0x3a999d},_0x19092d));if(_0x5d83b2[_0xfb7f('0xa1')]){_0x58da61['push'](_[_0xfb7f('0x54')]({'channel':_0x503ce9,'type':_0xfb7f('0xf1'),'data1':_0xfb7f('0xf2')},_0x19092d));}});return db[_0xfb7f('0xf3')][_0xfb7f('0x89')](_0x540a39['concat'](_0x58da61),{'individualHooks':!![]});}})[_0xfb7f('0x2f')](function(){if(_0x5d83b2){return _0x5d83b2['update']({'online':!![],'lastLoginAt':moment()[_0xfb7f('0xe1')](_0xfb7f('0xed')),'voicePause':_0x5d83b2[_0xfb7f('0xa1')]||![],'mailPause':_0x5d83b2[_0xfb7f('0xa1')]||![],'chatPause':_0x5d83b2[_0xfb7f('0xa1')]||![],'faxPause':_0x5d83b2[_0xfb7f('0xa1')]||![],'smsPause':_0x5d83b2[_0xfb7f('0xa1')]||![],'openchannelPause':_0x5d83b2['loginInPause']||![],'whatsappPause':_0x5d83b2[_0xfb7f('0xa1')]||![],'pauseType':_0x5d83b2['loginInPause']?'LOGININPAUSE':null,'interface':_0x3a999d,'lastPauseAt':moment()[_0xfb7f('0xe1')](_0xfb7f('0xed'))});}})['then'](function(_0x249deb){if(_0x51f97b[_0xfb7f('0xf4')]){return _0x2ea9f6();}else{return BPromise[_0xfb7f('0xf5')](_0x249deb)['then'](respondWithResult(_0x5cd1f2,null));}})[_0xfb7f('0x5d')](handleError(_0x5cd1f2,null));};exports['logout']=function(_0x46b407,_0x299095,_0x41ebee){var _0x54b31d;return db[_0xfb7f('0x42')][_0xfb7f('0x3c')]({'where':{'id':_0x46b407[_0xfb7f('0x62')]['id'],'role':_0xfb7f('0x36')},'attributes':['id',_0xfb7f('0x3d'),_0xfb7f('0x32')]})[_0xfb7f('0x2f')](handleEntityNotFound(_0x299095,null))['then'](function(_0x4ad8b8){if(_0x4ad8b8){_0x54b31d=_0x4ad8b8;return db[_0xfb7f('0xcc')][_0xfb7f('0x30')]({'where':{'membername':_0x54b31d[_0xfb7f('0x3d')]},'individualHooks':!![]});}})[_0xfb7f('0x2f')](function(){return db[_0xfb7f('0xf3')][_0xfb7f('0x5b')]({'where':{'membername':_0x54b31d[_0xfb7f('0x3d')],'exitAt':null}});})[_0xfb7f('0x2f')](function(_0x4f0a1d){var _0x369802=[];_0x4f0a1d[_0xfb7f('0xec')](function(_0x368681){_0x369802[_0xfb7f('0x93')](_0x368681[_0xfb7f('0x2e')]({'exitAt':moment()['format'](_0xfb7f('0xed'))}));});return BPromise['all'](_0x369802);})[_0xfb7f('0x2f')](function(){return _0x54b31d[_0xfb7f('0x2e')]({'online':![],'lastLoginAt':null,'voicePause':![],'mailPause':![],'chatPause':![],'faxPause':![],'smsPause':![],'openchannelPause':![],'whatsappPause':![],'interface':null});})['then'](respondWithResult(_0x299095,null))['catch'](handleError(_0x299095,null));};exports[_0xfb7f('0xf6')]=function(_0x467eae,_0x563d65,_0x5c1a5e){var _0x39f2c8;return db['UserVoiceQueueRt'][_0xfb7f('0x2e')]({'paused':0x1},{'where':{'UserId':_0x467eae[_0xfb7f('0x62')]['id']},'individualHooks':!![]})[_0xfb7f('0x2f')](function(){return db['User']['find']({'where':{'id':_0x467eae[_0xfb7f('0x62')]['id'],'role':'agent'},'attributes':['id',_0xfb7f('0x3d'),_0xfb7f('0x32'),_0xfb7f('0x66'),_0xfb7f('0xa2')]});})['then'](handleEntityNotFound(_0x563d65,null))['then'](function(_0x20e280){if(_0x20e280){_0x39f2c8=_0x20e280;return respondWithRpcPromise(_0xfb7f('0xf7'),_0xfb7f('0xf6'),{'id':_0x39f2c8['id'],'name':_0x39f2c8[_0xfb7f('0x3d')],'pause':!![]});}})[_0xfb7f('0x2f')](function(){if(_0x39f2c8){return db[_0xfb7f('0xf3')][_0xfb7f('0x5b')]({'where':{'membername':_0x39f2c8[_0xfb7f('0x3d')],'type':_0xfb7f('0xf1'),'exitAt':null}});}})[_0xfb7f('0x2f')](function(_0x7f0612){if(_0x7f0612['length']){var _0x4cf418=moment()['format']('YYYY-MM-DD\x20HH:mm:ss');for(var _0x1c2b32=0x0,_0x58a3a2=_0x7f0612['length'];_0x1c2b32<_0x58a3a2;_0x1c2b32++){_0x7f0612[_0x1c2b32][_0xfb7f('0xf8')]({'exitAt':_0x4cf418});}}})[_0xfb7f('0x2f')](function(){var _0x481c54=[];var _0x4e9a81=utils[_0xfb7f('0xee')]();_0x4e9a81[_0xfb7f('0xec')](function(_0x5149e8){_0x481c54[_0xfb7f('0x93')]({'channel':_0x5149e8,'membername':_0x39f2c8[_0xfb7f('0x3d')],'interface':_[_0xfb7f('0x6c')](_0x39f2c8['interface'])?util[_0xfb7f('0xe1')](_0xfb7f('0xae'),_0x39f2c8[_0xfb7f('0x3d')]):_0x39f2c8[_0xfb7f('0xa2')],'type':_0xfb7f('0xf1'),'enterAt':moment()[_0xfb7f('0xe1')](_0xfb7f('0xed')),'data1':_0x467eae[_0xfb7f('0x61')][_0xfb7f('0x44')]||_0xfb7f('0xf9'),'role':_0x39f2c8[_0xfb7f('0x32')],'internal':_0x39f2c8[_0xfb7f('0x66')]});});return db[_0xfb7f('0xf3')][_0xfb7f('0x89')](_0x481c54,{'individualHooks':!![]});})['then'](function(){return _0x39f2c8['update']({'voicePause':!![],'mailPause':!![],'chatPause':!![],'faxPause':!![],'smsPause':!![],'whatsappPause':!![],'openchannelPause':!![],'pauseType':_0x467eae['body'][_0xfb7f('0x44')]||'DEFAULT\x20PAUSE','lastPauseAt':moment()['format'](_0xfb7f('0xed'))});})[_0xfb7f('0x2f')](respondWithResult(_0x563d65,null))[_0xfb7f('0x5d')](handleError(_0x563d65,null));};exports[_0xfb7f('0xfa')]=function(_0x1fbe3b,_0x2228e3,_0x367196){var _0x41d3fc;return db[_0xfb7f('0x42')][_0xfb7f('0x3c')]({'where':{'id':_0x1fbe3b[_0xfb7f('0x62')]['id']},'attributes':['id',_0xfb7f('0x3d'),_0xfb7f('0x32'),_0xfb7f('0xaf'),_0xfb7f('0xfb'),'chatPause',_0xfb7f('0xfc'),_0xfb7f('0xfd'),_0xfb7f('0xfe'),'whatsapppause',_0xfb7f('0xff'),_0xfb7f('0x100')]})[_0xfb7f('0x2f')](handleEntityNotFound(_0x2228e3,null))[_0xfb7f('0x2f')](function(_0x21a44e){if(_0x21a44e){_0x41d3fc=_0x21a44e;if(_0x1fbe3b['body'][_0xfb7f('0xa0')]&&!utils[_0xfb7f('0xa3')](_0x1fbe3b[_0xfb7f('0x61')][_0xfb7f('0xa0')])){throw new db[(_0xfb7f('0x96'))][(_0xfb7f('0x97'))](_0xfb7f('0xa4'));}switch(_0x1fbe3b[_0xfb7f('0x61')][_0xfb7f('0xa0')]){case _0xfb7f('0xac'):return respondWithRpcPromise(_0xfb7f('0xf7'),_0xfb7f('0xfa'),{'id':_0x41d3fc['id'],'name':_0x41d3fc['name'],'pause':![]})[_0xfb7f('0x2f')](function(){return db['UserVoiceQueueRt'][_0xfb7f('0x2e')]({'paused':0x0},{'where':{'UserId':_0x41d3fc['id']},'individualHooks':!![]});})[_0xfb7f('0x2f')](function(){return db[_0xfb7f('0xf3')][_0xfb7f('0x3c')]({'where':{'channel':_0x1fbe3b[_0xfb7f('0x61')]['channel'],'membername':_0x41d3fc[_0xfb7f('0x3d')],'type':_0xfb7f('0xf1'),'exitAt':null}});})[_0xfb7f('0x2f')](function(_0x47c3b7){if(_0x47c3b7){return _0x47c3b7[_0xfb7f('0x2e')]({'exitAt':moment()[_0xfb7f('0xe1')](_0xfb7f('0xed')),'data2':_0xfb7f('0x101')},{'individualHooks':!![]});}return null;})['then'](function(){return _0x41d3fc['update']({'voicePause':![]});});case _0xfb7f('0x102'):case _0xfb7f('0x103'):case _0xfb7f('0x104'):case _0xfb7f('0x105'):case _0xfb7f('0x106'):case _0xfb7f('0x107'):return db[_0xfb7f('0xf3')][_0xfb7f('0x3c')]({'where':{'channel':_0x1fbe3b[_0xfb7f('0x61')][_0xfb7f('0xa0')],'membername':_0x41d3fc[_0xfb7f('0x3d')],'type':_0xfb7f('0xf1'),'exitAt':null}})[_0xfb7f('0x2f')](function(_0x5b83c6){if(_0x5b83c6){return _0x5b83c6[_0xfb7f('0x2e')]({'exitAt':moment()[_0xfb7f('0xe1')](_0xfb7f('0xed')),'data2':_0xfb7f('0x101')},{'individualHooks':!![]});}return null;})['then'](function(){var _0x58a15c={};_['set'](_0x58a15c,util[_0xfb7f('0xe1')](_0xfb7f('0x108'),_0x1fbe3b[_0xfb7f('0x61')][_0xfb7f('0xa0')],'Pause'),![]);return _0x41d3fc['update'](_0x58a15c);});default:return respondWithRpcPromise(_0xfb7f('0xf7'),_0xfb7f('0xfa'),{'id':_0x41d3fc['id'],'name':_0x41d3fc['name'],'pause':![]})['then'](function(){return db[_0xfb7f('0xcc')][_0xfb7f('0x2e')]({'paused':0x0},{'where':{'UserId':_0x41d3fc['id']}});})[_0xfb7f('0x2f')](function(){return db[_0xfb7f('0xf3')]['findAll']({'where':{'membername':_0x41d3fc[_0xfb7f('0x3d')],'type':_0xfb7f('0xf1'),'exitAt':null}});})[_0xfb7f('0x2f')](function(_0x5e0ec0){var _0x1b6a21=[];_0x5e0ec0[_0xfb7f('0xec')](function(_0x132a5f){_0x1b6a21[_0xfb7f('0x93')](_0x132a5f[_0xfb7f('0x2e')]({'exitAt':moment()[_0xfb7f('0xe1')](_0xfb7f('0xed')),'data2':_0xfb7f('0x101')}));});return BPromise[_0xfb7f('0x8d')](_0x1b6a21);})[_0xfb7f('0x2f')](function(){return _0x41d3fc[_0xfb7f('0x2e')]({'voicePause':![],'mailPause':![],'chatPause':![],'faxPause':![],'smsPause':![],'whatsappPause':![],'openchannelPause':![]});});}}})[_0xfb7f('0x2f')](respondWithResult(_0x2228e3,null))[_0xfb7f('0x5d')](handleError(_0x2228e3,null));};exports['getTeams']=function(_0x1d7836,_0xfcf1ef,_0x11bacf){var _0x5dc435={};var _0x4683db={};var _0x828f3;var _0x28423d;return db[_0xfb7f('0x42')][_0xfb7f('0xc9')]({'where':{'id':_0x1d7836[_0xfb7f('0x62')]['id']}})[_0xfb7f('0x2f')](handleEntityNotFound(_0xfcf1ef,null))[_0xfb7f('0x2f')](function(_0x24fd56){if(_0x24fd56){_0x828f3=_0x24fd56;_0x4683db['model']=_[_0xfb7f('0x49')](db[_0xfb7f('0x109')][_0xfb7f('0xc1')]);_0x4683db[_0xfb7f('0x4b')]=_[_0xfb7f('0x49')](_0x1d7836[_0xfb7f('0x4b')]);_0x4683db['filters']=_[_0xfb7f('0x4a')](_0x4683db['model'],_0x4683db[_0xfb7f('0x4b')]);_0x5dc435['attributes']=_[_0xfb7f('0x4a')](_0x4683db[_0xfb7f('0x46')],qs[_0xfb7f('0x4d')](_0x1d7836['query']['fields']));_0x5dc435['attributes']=_0x5dc435['attributes'][_0xfb7f('0x60')]?_0x5dc435[_0xfb7f('0x4c')]:_0x4683db['model'];_0x5dc435[_0xfb7f('0x50')]=qs['sort'](_0x1d7836[_0xfb7f('0x4b')][_0xfb7f('0xc2')]);_0x5dc435['where']=qs[_0xfb7f('0x51')](_['pick'](_0x1d7836[_0xfb7f('0x4b')],_0x4683db['filters']));if(_0x1d7836[_0xfb7f('0x4b')]['filter']){_0x5dc435[_0xfb7f('0x53')]=_['merge'](_0x5dc435[_0xfb7f('0x53')],{'$or':_[_0xfb7f('0x41')](_0x5dc435['attributes'],function(_0x200f20){var _0x44749f={};_0x44749f[_0x200f20]={'$like':'%'+_0x1d7836['query'][_0xfb7f('0x38')]+'%'};return _0x44749f;})});}_0x5dc435=_[_0xfb7f('0x54')]({},_0x5dc435,_0x1d7836[_0xfb7f('0x58')]);return _0x828f3[_0xfb7f('0x10a')](_0x5dc435);}})['then'](function(_0x3c4d2c){if(_0x3c4d2c){_0x28423d=_0x3c4d2c[_0xfb7f('0x60')];if(!_0x1d7836['query']['hasOwnProperty'](_0xfb7f('0x4f'))){_0x5dc435['limit']=qs[_0xfb7f('0x28')](_0x1d7836['query'][_0xfb7f('0x28')]);_0x5dc435[_0xfb7f('0x27')]=qs[_0xfb7f('0x27')](_0x1d7836[_0xfb7f('0x4b')]['offset']);}return _0x828f3[_0xfb7f('0x10a')](_0x5dc435);}})[_0xfb7f('0x2f')](function(_0x12b21f){if(_0x12b21f){return _0x12b21f?{'count':_0x28423d,'rows':_0x12b21f}:null;}})['then'](respondWithResult(_0xfcf1ef,null))[_0xfb7f('0x5d')](handleError(_0xfcf1ef,null));};exports['addTeams']=function(_0x26d0db,_0x189a19){return db[_0xfb7f('0x42')][_0xfb7f('0x3c')]({'where':{'id':_0x26d0db[_0xfb7f('0x62')]['id']}})[_0xfb7f('0x2f')](handleEntityNotFound(_0x189a19,null))[_0xfb7f('0x2f')](function(_0x3363ef){if(_0x3363ef){var _0xa15301=_0x3363ef['get']({'plain':!![]});return _0x3363ef[_0xfb7f('0x10b')](_0x26d0db[_0xfb7f('0x61')][_0xfb7f('0x65')],_[_0xfb7f('0x10c')](_0x26d0db[_0xfb7f('0x61')],[_0xfb7f('0x65'),'id'])||{})[_0xfb7f('0x2f')](function(){for(var _0x1e895f=0x0;_0x1e895f<_0x26d0db[_0xfb7f('0x61')]['ids'][_0xfb7f('0x60')];_0x1e895f++){var _0x4887fa=[];db[_0xfb7f('0x109')][_0xfb7f('0xc9')]({'where':{'id':_0x26d0db[_0xfb7f('0x61')]['ids'][_0x1e895f]}})[_0xfb7f('0x2f')](function(_0x68b3d3){_0x4887fa['push'](_0x68b3d3['getVoiceQueues']()[_0xfb7f('0x2f')](function(_0x4a8ced){for(var _0x53dc80=0x0;_0x53dc80<_0x4a8ced[_0xfb7f('0x60')];_0x53dc80++){_0x4a8ced[_0x53dc80][_0xfb7f('0x10d')](_0xfb7f('0xa0'),_0xfb7f('0x10e'));}return _0x4a8ced;}));_0x4887fa[_0xfb7f('0x93')](_0x68b3d3[_0xfb7f('0x10f')]()[_0xfb7f('0x2f')](function(_0x134ec2){for(var _0x1c3ead=0x0;_0x1c3ead<_0x134ec2[_0xfb7f('0x60')];_0x1c3ead++){_0x134ec2[_0x1c3ead][_0xfb7f('0x10d')](_0xfb7f('0xa0'),_0xfb7f('0x110'));}return _0x134ec2;}));_0x4887fa[_0xfb7f('0x93')](_0x68b3d3['getMailQueues']()[_0xfb7f('0x2f')](function(_0xa9b4ab){for(var _0x389e7e=0x0;_0x389e7e<_0xa9b4ab[_0xfb7f('0x60')];_0x389e7e++){_0xa9b4ab[_0x389e7e][_0xfb7f('0x10d')](_0xfb7f('0xa0'),_0xfb7f('0x111'));}return _0xa9b4ab;}));_0x4887fa['push'](_0x68b3d3['getSmsQueues']()[_0xfb7f('0x2f')](function(_0x4e9677){for(var _0x4364c4=0x0;_0x4364c4<_0x4e9677[_0xfb7f('0x60')];_0x4364c4++){_0x4e9677[_0x4364c4][_0xfb7f('0x10d')](_0xfb7f('0xa0'),_0xfb7f('0x112'));}return _0x4e9677;}));_0x4887fa[_0xfb7f('0x93')](_0x68b3d3['getWhatsappQueues']()[_0xfb7f('0x2f')](function(_0x1899d6){for(var _0x334b32=0x0;_0x334b32<_0x1899d6[_0xfb7f('0x60')];_0x334b32++){_0x1899d6[_0x334b32][_0xfb7f('0x10d')](_0xfb7f('0xa0'),_0xfb7f('0x113'));}return _0x1899d6;}));_0x4887fa['push'](_0x68b3d3[_0xfb7f('0x114')]()[_0xfb7f('0x2f')](function(_0x517daa){for(var _0x34bf86=0x0;_0x34bf86<_0x517daa[_0xfb7f('0x60')];_0x34bf86++){_0x517daa[_0x34bf86]['setDataValue'](_0xfb7f('0xa0'),_0xfb7f('0x115'));}return _0x517daa;}));_0x4887fa['push'](_0x68b3d3[_0xfb7f('0x116')]()[_0xfb7f('0x2f')](function(_0xdc7b64){for(var _0x41d3e3=0x0;_0x41d3e3<_0xdc7b64[_0xfb7f('0x60')];_0x41d3e3++){_0xdc7b64[_0x41d3e3][_0xfb7f('0x10d')]('channel',_0xfb7f('0x117'));}return _0xdc7b64;}));return BPromise[_0xfb7f('0x8d')](_0x4887fa);})[_0xfb7f('0x2f')](function(_0x2338e9){var _0x37a397=_[_0xfb7f('0x118')](_0x2338e9);_0x4887fa=[];return db[_0xfb7f('0x55')][_0xfb7f('0x119')](function(_0x298995){for(var _0x5583af=0x0;_0x5583af<_0x37a397[_0xfb7f('0x60')];_0x5583af++){_0x4887fa['push'](_0x37a397[_0x5583af][_0xfb7f('0x11a')](_0xa15301['id']),{'transaction':_0x298995});}return BPromise[_0xfb7f('0x8d')](_0x4887fa)[_0xfb7f('0x2f')](function(){if(_0xa15301[_0xfb7f('0xad')]){return BPromise[_0xfb7f('0x8e')](_[_0xfb7f('0x38')](_0x37a397,function(_0x674b83){return _0x674b83[_0xfb7f('0x11b')](_0xfb7f('0xa0'))===_0xfb7f('0x10e');}),function(_0x350ad7){return db[_0xfb7f('0xcc')][_0xfb7f('0xb1')]({'membername':_0xa15301[_0xfb7f('0x3d')],'UserId':_0xa15301['id'],'queue_name':_0x350ad7[_0xfb7f('0x3d')],'VoiceQueueId':_0x350ad7['id'],'interface':_[_0xfb7f('0x6c')](_0xa15301['interface'])?util[_0xfb7f('0xe1')]('SIP/%s',_0xa15301[_0xfb7f('0x3d')]):_0xa15301[_0xfb7f('0xa2')],'paused':_0xa15301[_0xfb7f('0xaf')]||![],'penalty':_0xa15301[_0xfb7f('0xb0')]},{'transaction':_0x298995});});}else{return;}})[_0xfb7f('0x2f')](function(){for(var _0x3b3e26=0x0;_0x3b3e26<_0x37a397[_0xfb7f('0x60')];_0x3b3e26++){var _0x42d9c8=_0x37a397[_0x3b3e26][_0xfb7f('0x11b')](_0xfb7f('0xa0'));var _0x2e6994=_0x42d9c8+'QueueId';socket['emit'](_0xfb7f('0x80')+_0x42d9c8+_0xfb7f('0xab'),{'UserId':_0xa15301['id'],['queueField']:_0x37a397[_0x3b3e26]['id']});}});});});}});}})[_0xfb7f('0x2f')](respondWithStatusCode(_0x189a19,null))['catch'](handleError(_0x189a19,null));};exports[_0xfb7f('0x11c')]=function(_0x4c075e,_0x3df3d8){return db['User'][_0xfb7f('0xc9')]({'where':{'id':_0x4c075e[_0xfb7f('0x62')]['id']}})[_0xfb7f('0x2f')](handleEntityNotFound(_0x3df3d8,null))[_0xfb7f('0x2f')](function(_0x39e287){if(_0x39e287){var _0x46279b=_0x39e287['get']({'plain':!![]});var _0x4ac89c=_0x4c075e[_0xfb7f('0x4b')]['ids'];return _0x39e287['removeTeams'](_0x4ac89c)['then'](function(){for(var _0x41f8a3=0x0;_0x41f8a3<_0x4ac89c[_0xfb7f('0x60')];_0x41f8a3++){var _0x14615d=[];db[_0xfb7f('0x109')]['findOne']({'where':{'id':_0x4ac89c[_0x41f8a3]}})[_0xfb7f('0x2f')](function(_0x550471){_0x14615d[_0xfb7f('0x93')](_0x550471[_0xfb7f('0x11d')]()[_0xfb7f('0x2f')](function(_0x142966){for(var _0x3280a1=0x0;_0x3280a1<_0x142966[_0xfb7f('0x60')];_0x3280a1++){_0x142966[_0x3280a1][_0xfb7f('0x10d')](_0xfb7f('0xa0'),_0xfb7f('0x10e'));}return _0x142966;}));_0x14615d[_0xfb7f('0x93')](_0x550471[_0xfb7f('0x10f')]()[_0xfb7f('0x2f')](function(_0x4da35f){for(var _0x3e3fa4=0x0;_0x3e3fa4<_0x4da35f[_0xfb7f('0x60')];_0x3e3fa4++){_0x4da35f[_0x3e3fa4][_0xfb7f('0x10d')](_0xfb7f('0xa0'),_0xfb7f('0x110'));}return _0x4da35f;}));_0x14615d[_0xfb7f('0x93')](_0x550471[_0xfb7f('0x11e')]()[_0xfb7f('0x2f')](function(_0x179f9e){for(var _0x37952f=0x0;_0x37952f<_0x179f9e[_0xfb7f('0x60')];_0x37952f++){_0x179f9e[_0x37952f][_0xfb7f('0x10d')](_0xfb7f('0xa0'),_0xfb7f('0x111'));}return _0x179f9e;}));_0x14615d[_0xfb7f('0x93')](_0x550471[_0xfb7f('0x11f')]()['then'](function(_0x1b5536){for(var _0x571fae=0x0;_0x571fae<_0x1b5536[_0xfb7f('0x60')];_0x571fae++){_0x1b5536[_0x571fae]['setDataValue']('channel','Sms');}return _0x1b5536;}));_0x14615d[_0xfb7f('0x93')](_0x550471['getWhatsappQueues']()[_0xfb7f('0x2f')](function(_0x41885c){for(var _0x54abbf=0x0;_0x54abbf<_0x41885c[_0xfb7f('0x60')];_0x54abbf++){_0x41885c[_0x54abbf][_0xfb7f('0x10d')](_0xfb7f('0xa0'),_0xfb7f('0x113'));}return _0x41885c;}));_0x14615d[_0xfb7f('0x93')](_0x550471['getFaxQueues']()[_0xfb7f('0x2f')](function(_0x21b66a){for(var _0x4e45a2=0x0;_0x4e45a2<_0x21b66a[_0xfb7f('0x60')];_0x4e45a2++){_0x21b66a[_0x4e45a2][_0xfb7f('0x10d')](_0xfb7f('0xa0'),_0xfb7f('0x115'));}return _0x21b66a;}));_0x14615d[_0xfb7f('0x93')](_0x550471['getOpenchannelQueues']()['then'](function(_0x35249d){for(var _0xb787a2=0x0;_0xb787a2<_0x35249d[_0xfb7f('0x60')];_0xb787a2++){_0x35249d[_0xb787a2][_0xfb7f('0x10d')](_0xfb7f('0xa0'),_0xfb7f('0x117'));}return _0x35249d;}));return BPromise[_0xfb7f('0x8d')](_0x14615d);})[_0xfb7f('0x2f')](function(_0x4292e2){var _0x57c100=_[_0xfb7f('0x118')](_0x4292e2);_0x14615d=[];return db[_0xfb7f('0x55')][_0xfb7f('0x119')](function(_0x573a7e){for(var _0x46b5f2=0x0;_0x46b5f2<_0x57c100['length'];_0x46b5f2++){_0x14615d[_0xfb7f('0x93')](_0x57c100[_0x46b5f2]['removeAgent'](_0x46279b['id']),{'transaction':_0x573a7e});}return BPromise[_0xfb7f('0x8d')](_0x14615d)['then'](function(){if(_0x46279b['online']){return BPromise[_0xfb7f('0x8e')](_['filter'](_0x57c100,function(_0x5340d3){return _0x5340d3[_0xfb7f('0x11b')](_0xfb7f('0xa0'))===_0xfb7f('0x10e');}),function(_0x48e00c){return db[_0xfb7f('0xcc')][_0xfb7f('0x30')]({'where':{'VoiceQueueId':_0x48e00c['id'],'UserId':_0x46279b['id']},'transaction':_0x573a7e});});}else{return;}})[_0xfb7f('0x2f')](function(){for(var _0x225672=0x0;_0x225672<_0x57c100[_0xfb7f('0x60')];_0x225672++){var _0x20f8a9=_0x57c100[_0x225672][_0xfb7f('0x11b')](_0xfb7f('0xa0'));var _0x475c46=_0x20f8a9+_0xfb7f('0xa9');socket['emit'](_0xfb7f('0x80')+_0x20f8a9+_0xfb7f('0x120'),{'UserId':_0x46279b['id'],['queueField']:_0x57c100[_0x225672]['id']});}});});});}});}})[_0xfb7f('0x2f')](respondWithStatusCode(_0x3df3d8,null))[_0xfb7f('0x5d')](handleError(_0x3df3d8,null));};exports['getLists']=function(_0x4d3e24,_0xcd79f9,_0x46d032){var _0x585bdc={};var _0x42f05b={};var _0x1e80f0;var _0x498c92;return db[_0xfb7f('0x42')]['findOne']({'where':{'id':_0x4d3e24[_0xfb7f('0x62')]['id']}})['then'](handleEntityNotFound(_0xcd79f9,null))[_0xfb7f('0x2f')](function(_0x19e945){if(_0x19e945){_0x1e80f0=_0x19e945;_0x42f05b[_0xfb7f('0x46')]=_['keys'](db[_0xfb7f('0xc3')][_0xfb7f('0xc1')]);_0x42f05b['query']=_[_0xfb7f('0x49')](_0x4d3e24[_0xfb7f('0x4b')]);_0x42f05b[_0xfb7f('0x51')]=_[_0xfb7f('0x4a')](_0x42f05b[_0xfb7f('0x46')],_0x42f05b[_0xfb7f('0x4b')]);_0x585bdc['attributes']=_[_0xfb7f('0x4a')](_0x42f05b['model'],qs[_0xfb7f('0x4d')](_0x4d3e24['query'][_0xfb7f('0x4d')]));_0x585bdc['attributes']=_0x585bdc['attributes']['length']?_0x585bdc[_0xfb7f('0x4c')]:_0x42f05b['model'];_0x585bdc[_0xfb7f('0x50')]=qs['sort'](_0x4d3e24[_0xfb7f('0x4b')][_0xfb7f('0xc2')]);_0x585bdc['where']=qs['filters'](_['pick'](_0x4d3e24[_0xfb7f('0x4b')],_0x42f05b['filters']));if(_0x4d3e24[_0xfb7f('0x4b')][_0xfb7f('0x38')]){_0x585bdc[_0xfb7f('0x53')]=_[_0xfb7f('0x54')](_0x585bdc[_0xfb7f('0x53')],{'$or':_[_0xfb7f('0x41')](_0x585bdc[_0xfb7f('0x4c')],function(_0x511de5){var _0x5ec108={};_0x5ec108[_0x511de5]={'$like':'%'+_0x4d3e24[_0xfb7f('0x4b')]['filter']+'%'};return _0x5ec108;})});}_0x585bdc=_[_0xfb7f('0x54')]({},_0x585bdc,_0x4d3e24['options']);return _0x1e80f0[_0xfb7f('0x121')](_0x585bdc);}})[_0xfb7f('0x2f')](function(_0x30045b){if(_0x30045b){_0x498c92=_0x30045b[_0xfb7f('0x60')];if(!_0x4d3e24[_0xfb7f('0x4b')][_0xfb7f('0x4e')](_0xfb7f('0x4f'))){_0x585bdc[_0xfb7f('0x28')]=qs['limit'](_0x4d3e24['query']['limit']);_0x585bdc['offset']=qs[_0xfb7f('0x27')](_0x4d3e24['query'][_0xfb7f('0x27')]);}return _0x1e80f0[_0xfb7f('0x121')](_0x585bdc);}})[_0xfb7f('0x2f')](function(_0xa1410a){if(_0xa1410a){return _0xa1410a?{'count':_0x498c92,'rows':_0xa1410a}:null;}})['then'](respondWithResult(_0xcd79f9,null))['catch'](handleError(_0xcd79f9,null));};exports['getAgents']=function(_0x5d6db7,_0x762720,_0x530e0c){var _0x20abc1={};var _0x33a841={};var _0x4a07b1;var _0x49cf82;return db[_0xfb7f('0x42')][_0xfb7f('0xc9')]({'where':{'id':_0x5d6db7[_0xfb7f('0x62')]['id']}})['then'](handleEntityNotFound(_0x762720,null))[_0xfb7f('0x2f')](function(_0x2d066c){if(_0x2d066c){_0x4a07b1=_0x2d066c;_0x33a841['model']=_['keys'](db['User'][_0xfb7f('0xc1')]);_0x33a841['query']=_['keys'](_0x5d6db7[_0xfb7f('0x4b')]);_0x33a841['filters']=_[_0xfb7f('0x4a')](_0x33a841[_0xfb7f('0x46')],_0x33a841[_0xfb7f('0x4b')]);_0x20abc1[_0xfb7f('0x4c')]=_[_0xfb7f('0x4a')](_0x33a841[_0xfb7f('0x46')],qs[_0xfb7f('0x4d')](_0x5d6db7[_0xfb7f('0x4b')][_0xfb7f('0x4d')]));_0x20abc1[_0xfb7f('0x4c')]=_0x20abc1[_0xfb7f('0x4c')][_0xfb7f('0x60')]?_0x20abc1['attributes']:_0x33a841['model'];_0x20abc1[_0xfb7f('0x50')]=qs[_0xfb7f('0xc2')](_0x5d6db7[_0xfb7f('0x4b')]['sort']);_0x20abc1[_0xfb7f('0x53')]=qs[_0xfb7f('0x51')](_[_0xfb7f('0x52')](_0x5d6db7[_0xfb7f('0x4b')],_0x33a841[_0xfb7f('0x51')]));if(_0x5d6db7[_0xfb7f('0x4b')][_0xfb7f('0x38')]){_0x20abc1[_0xfb7f('0x53')]=_[_0xfb7f('0x54')](_0x20abc1['where'],{'$or':_[_0xfb7f('0x41')](_0x20abc1[_0xfb7f('0x4c')],function(_0x5c603e){var _0x4febd7={};_0x4febd7[_0x5c603e]={'$like':'%'+_0x5d6db7[_0xfb7f('0x4b')]['filter']+'%'};return _0x4febd7;})});}_0x20abc1[_0xfb7f('0x46')]=db['User'];_0x20abc1['as']=_0xfb7f('0x35');_0x20abc1=_['merge']({},_0x20abc1,_0x5d6db7[_0xfb7f('0x58')]);return _0x4a07b1[_0xfb7f('0x11d')]({'include':[_0x20abc1]});}})[_0xfb7f('0x2f')](function(_0x13e8fe){if(_0x13e8fe){var _0x3d4198={},_0x1981e8=[],_0x1cd794=0x0;for(var _0x422d3f=0x0;_0x422d3f<_0x13e8fe[_0xfb7f('0x60')];_0x422d3f+=0x1){for(var _0x5dcfe0=0x0,_0x2681f7;_0x5dcfe0<_0x13e8fe[_0x422d3f]['Agents'][_0xfb7f('0x60')];_0x5dcfe0+=0x1){_0x2681f7=_0x13e8fe[_0x422d3f][_0xfb7f('0x35')][_0x5dcfe0][_0xfb7f('0x31')]({'plain':!![]});_0x3d4198[_0x2681f7['id']]=_0x2681f7;}}_0x3d4198=_[_0xfb7f('0x122')](_0x3d4198);for(var _0xcd1b92=qs[_0xfb7f('0x27')](_0x5d6db7[_0xfb7f('0x4b')]['offset']);_0xcd1b92<_0x3d4198[_0xfb7f('0x60')]&&_0x1981e8['length']<qs[_0xfb7f('0x28')](_0x5d6db7[_0xfb7f('0x4b')][_0xfb7f('0x28')]);_0xcd1b92+=0x1){if(_0x3d4198[_0xcd1b92]){_0x1981e8[_0xfb7f('0x93')](_0x3d4198[_0xcd1b92]);}}return{'count':_0x3d4198[_0xfb7f('0x60')],'rows':_0x1981e8};}})[_0xfb7f('0x2f')](respondWithResult(_0x762720,null))[_0xfb7f('0x5d')](handleError(_0x762720,null));};exports['destroy']=function(_0x3474c1,_0x349e55){if(_0x3474c1[_0xfb7f('0x80')]['id']==_0x3474c1['params']['id']){return _0x349e55[_0xfb7f('0x29')](0x1f4)[_0xfb7f('0x3f')]({'message':_0xfb7f('0x123')});}return db[_0xfb7f('0x42')][_0xfb7f('0x3c')]({'where':{'id':_0x3474c1[_0xfb7f('0x62')]['id']}})[_0xfb7f('0x2f')](handleEntityNotFound(_0x349e55,null))[_0xfb7f('0x2f')](removeEntity(_0x349e55,null))[_0xfb7f('0x5d')](handleError(_0x349e55,null));};exports[_0xfb7f('0x124')]=function(_0x51dd3a,_0x329622,_0x5bf8bc){return db[_0xfb7f('0x42')][_0xfb7f('0x3c')]({'where':{'id':_0x51dd3a[_0xfb7f('0x62')]['id']}})['then'](handleEntityNotFound(_0x329622,null))[_0xfb7f('0x2f')](function(_0x5593b6){if(_0x5593b6){return _0x5593b6[_0xfb7f('0x124')](_0x51dd3a[_0xfb7f('0x61')]['ids'],_[_0xfb7f('0x10c')](_0x51dd3a[_0xfb7f('0x61')],[_0xfb7f('0x65'),'id'])||{})[_0xfb7f('0xa8')](function(){for(var _0x54ac46=0x0;_0x54ac46<_0x51dd3a[_0xfb7f('0x61')][_0xfb7f('0x65')][_0xfb7f('0x60')];_0x54ac46+=0x1){socket[_0xfb7f('0xaa')](_0xfb7f('0x125'),{'ChatInteractionId':Number(_0x51dd3a['body'][_0xfb7f('0x65')][_0x54ac46]),'UserId':Number(_0x51dd3a[_0xfb7f('0x62')]['id'])});}return _0x51dd3a[_0xfb7f('0x61')][_0xfb7f('0x65')];});}})[_0xfb7f('0x2f')](respondWithResult(_0x329622,null))['catch'](handleError(_0x329622,null));};exports[_0xfb7f('0x126')]=function(_0x4627fc,_0x2f66c8,_0x5cc256){return db['User'][_0xfb7f('0x3c')]({'where':{'id':_0x4627fc[_0xfb7f('0x62')]['id']}})[_0xfb7f('0x2f')](handleEntityNotFound(_0x2f66c8,null))[_0xfb7f('0x2f')](function(_0x2b798d){if(_0x2b798d){return _0x2b798d['removeChatInteractions'](_0x4627fc[_0xfb7f('0x4b')][_0xfb7f('0x65')])[_0xfb7f('0x2f')](function(){if(_[_0xfb7f('0x127')](_0x4627fc[_0xfb7f('0x4b')][_0xfb7f('0x65')])){for(var _0x5d35de=0x0;_0x5d35de<_0x4627fc[_0xfb7f('0x4b')]['ids']['length'];_0x5d35de+=0x1){socket[_0xfb7f('0xaa')](_0xfb7f('0x128'),{'ChatInteractionId':Number(_0x4627fc[_0xfb7f('0x4b')]['ids'][_0x5d35de]),'UserId':Number(_0x4627fc[_0xfb7f('0x62')]['id'])});}}else{socket[_0xfb7f('0xaa')]('user_has_chat_interactions:remove',{'ChatInteractionId':Number(_0x4627fc[_0xfb7f('0x4b')]['ids']),'UserId':Number(_0x4627fc['params']['id'])});}});}})[_0xfb7f('0x2f')](respondWithStatusCode(_0x2f66c8,null))[_0xfb7f('0x5d')](handleError(_0x2f66c8,null));};exports[_0xfb7f('0x129')]=function(_0x3202b3,_0x5b02f0,_0x4e4f7c){return db[_0xfb7f('0x42')][_0xfb7f('0x3c')]({'where':{'id':_0x3202b3['params']['id']}})[_0xfb7f('0x2f')](handleEntityNotFound(_0x5b02f0,null))['then'](function(_0xa82d40){if(_0xa82d40){return _0xa82d40[_0xfb7f('0x129')](_0x3202b3[_0xfb7f('0x61')][_0xfb7f('0x65')],_[_0xfb7f('0x10c')](_0x3202b3[_0xfb7f('0x61')],['ids','id'])||{})['spread'](function(){for(var _0x411f41=0x0;_0x411f41<_0x3202b3[_0xfb7f('0x61')][_0xfb7f('0x65')][_0xfb7f('0x60')];_0x411f41+=0x1){socket['emit'](_0xfb7f('0x12a'),{'MailInteractionId':Number(_0x3202b3[_0xfb7f('0x61')]['ids'][_0x411f41]),'UserId':Number(_0x3202b3['params']['id'])});}return _0x3202b3[_0xfb7f('0x61')]['ids'];});}})[_0xfb7f('0x2f')](respondWithResult(_0x5b02f0,null))[_0xfb7f('0x5d')](handleError(_0x5b02f0,null));};exports[_0xfb7f('0x12b')]=function(_0x59711f,_0x3baf37,_0x3a4363){return db[_0xfb7f('0x42')][_0xfb7f('0x3c')]({'where':{'id':_0x59711f[_0xfb7f('0x62')]['id']}})[_0xfb7f('0x2f')](handleEntityNotFound(_0x3baf37,null))[_0xfb7f('0x2f')](function(_0x27a1f4){if(_0x27a1f4){return _0x27a1f4[_0xfb7f('0x12b')](_0x59711f[_0xfb7f('0x4b')]['ids'])[_0xfb7f('0x2f')](function(){if(_[_0xfb7f('0x127')](_0x59711f['query'][_0xfb7f('0x65')])){for(var _0xc230c9=0x0;_0xc230c9<_0x59711f[_0xfb7f('0x4b')][_0xfb7f('0x65')]['length'];_0xc230c9+=0x1){socket['emit'](_0xfb7f('0x12c'),{'MailInteractionId':Number(_0x59711f[_0xfb7f('0x4b')][_0xfb7f('0x65')][_0xc230c9]),'UserId':Number(_0x59711f['params']['id'])});}}else{socket['emit']('user_has_mail_interactions:remove',{'MailInteractionId':Number(_0x59711f[_0xfb7f('0x4b')][_0xfb7f('0x65')]),'UserId':Number(_0x59711f[_0xfb7f('0x62')]['id'])});}});}})['then'](respondWithStatusCode(_0x3baf37,null))['catch'](handleError(_0x3baf37,null));};exports['addFaxInteractions']=function(_0x3efea9,_0x5449f4,_0x4dbf5b){return db[_0xfb7f('0x42')][_0xfb7f('0x3c')]({'where':{'id':_0x3efea9['params']['id']}})[_0xfb7f('0x2f')](handleEntityNotFound(_0x5449f4,null))[_0xfb7f('0x2f')](function(_0x5e1c69){if(_0x5e1c69){return _0x5e1c69[_0xfb7f('0x12d')](_0x3efea9[_0xfb7f('0x61')][_0xfb7f('0x65')],_['omit'](_0x3efea9[_0xfb7f('0x61')],['ids','id'])||{})[_0xfb7f('0xa8')](function(){for(var _0x3bc16c=0x0;_0x3bc16c<_0x3efea9['body'][_0xfb7f('0x65')][_0xfb7f('0x60')];_0x3bc16c+=0x1){socket[_0xfb7f('0xaa')]('user_has_fax_interactions:save',{'FaxInteractionId':Number(_0x3efea9[_0xfb7f('0x61')][_0xfb7f('0x65')][_0x3bc16c]),'UserId':Number(_0x3efea9[_0xfb7f('0x62')]['id'])});}return _0x3efea9[_0xfb7f('0x61')][_0xfb7f('0x65')];});}})[_0xfb7f('0x2f')](respondWithResult(_0x5449f4,null))['catch'](handleError(_0x5449f4,null));};exports[_0xfb7f('0x12e')]=function(_0x3ea488,_0x2038cb,_0x386c4d){return db[_0xfb7f('0x42')][_0xfb7f('0x3c')]({'where':{'id':_0x3ea488[_0xfb7f('0x62')]['id']}})[_0xfb7f('0x2f')](handleEntityNotFound(_0x2038cb,null))[_0xfb7f('0x2f')](function(_0x261c6f){if(_0x261c6f){return _0x261c6f[_0xfb7f('0x12e')](_0x3ea488[_0xfb7f('0x4b')][_0xfb7f('0x65')])['then'](function(){if(_[_0xfb7f('0x127')](_0x3ea488[_0xfb7f('0x4b')][_0xfb7f('0x65')])){for(var _0x427441=0x0;_0x427441<_0x3ea488['query']['ids'][_0xfb7f('0x60')];_0x427441+=0x1){socket['emit']('user_has_fax_interactions:remove',{'FaxInteractionId':Number(_0x3ea488['query'][_0xfb7f('0x65')][_0x427441]),'UserId':Number(_0x3ea488['params']['id'])});}}else{socket[_0xfb7f('0xaa')](_0xfb7f('0x12f'),{'FaxInteractionId':Number(_0x3ea488[_0xfb7f('0x4b')][_0xfb7f('0x65')]),'UserId':Number(_0x3ea488['params']['id'])});}});}})[_0xfb7f('0x2f')](respondWithStatusCode(_0x2038cb,null))['catch'](handleError(_0x2038cb,null));};exports[_0xfb7f('0x130')]=function(_0xf36b73,_0x4bae67,_0x312e8d){return db['User'][_0xfb7f('0x3c')]({'where':{'id':_0xf36b73[_0xfb7f('0x62')]['id']}})['then'](handleEntityNotFound(_0x4bae67,null))['then'](function(_0x303dd3){if(_0x303dd3){return _0x303dd3['addSmsInteractions'](_0xf36b73[_0xfb7f('0x61')][_0xfb7f('0x65')],_[_0xfb7f('0x10c')](_0xf36b73['body'],[_0xfb7f('0x65'),'id'])||{})['spread'](function(){for(var _0x27c230=0x0;_0x27c230<_0xf36b73[_0xfb7f('0x61')]['ids']['length'];_0x27c230+=0x1){socket[_0xfb7f('0xaa')]('user_has_sms_interactions:save',{'SmsInteractionId':Number(_0xf36b73[_0xfb7f('0x61')][_0xfb7f('0x65')][_0x27c230]),'UserId':Number(_0xf36b73[_0xfb7f('0x62')]['id'])});}return _0xf36b73['body'][_0xfb7f('0x65')];});}})[_0xfb7f('0x2f')](respondWithResult(_0x4bae67,null))[_0xfb7f('0x5d')](handleError(_0x4bae67,null));};exports[_0xfb7f('0x131')]=function(_0x288deb,_0x4677b3,_0x59306b){return db[_0xfb7f('0x42')][_0xfb7f('0x3c')]({'where':{'id':_0x288deb[_0xfb7f('0x62')]['id']}})[_0xfb7f('0x2f')](handleEntityNotFound(_0x4677b3,null))[_0xfb7f('0x2f')](function(_0x320cdd){if(_0x320cdd){return _0x320cdd[_0xfb7f('0x131')](_0x288deb['query'][_0xfb7f('0x65')])[_0xfb7f('0x2f')](function(){if(_[_0xfb7f('0x127')](_0x288deb[_0xfb7f('0x4b')]['ids'])){for(var _0x3188ce=0x0;_0x3188ce<_0x288deb[_0xfb7f('0x4b')][_0xfb7f('0x65')][_0xfb7f('0x60')];_0x3188ce+=0x1){socket['emit'](_0xfb7f('0x132'),{'SmsInteractionId':Number(_0x288deb[_0xfb7f('0x4b')][_0xfb7f('0x65')][_0x3188ce]),'UserId':Number(_0x288deb[_0xfb7f('0x62')]['id'])});}}else{socket[_0xfb7f('0xaa')]('user_has_sms_interactions:remove',{'SmsInteractionId':Number(_0x288deb[_0xfb7f('0x4b')]['ids']),'UserId':Number(_0x288deb[_0xfb7f('0x62')]['id'])});}});}})[_0xfb7f('0x2f')](respondWithStatusCode(_0x4677b3,null))[_0xfb7f('0x5d')](handleError(_0x4677b3,null));};exports[_0xfb7f('0x133')]=function(_0x14ffac,_0x2422b5,_0x40d7c6){return db[_0xfb7f('0x42')][_0xfb7f('0x3c')]({'where':{'id':_0x14ffac[_0xfb7f('0x62')]['id']}})[_0xfb7f('0x2f')](handleEntityNotFound(_0x2422b5,null))['then'](function(_0x1f8d65){if(_0x1f8d65){return _0x1f8d65[_0xfb7f('0x133')](_0x14ffac['body']['ids'],_[_0xfb7f('0x10c')](_0x14ffac[_0xfb7f('0x61')],[_0xfb7f('0x65'),'id'])||{})[_0xfb7f('0xa8')](function(){for(var _0x491453=0x0;_0x491453<_0x14ffac[_0xfb7f('0x61')][_0xfb7f('0x65')][_0xfb7f('0x60')];_0x491453+=0x1){socket[_0xfb7f('0xaa')]('user_has_openchannel_interactions:save',{'OpenchannelInteractionId':Number(_0x14ffac['body'][_0xfb7f('0x65')][_0x491453]),'UserId':Number(_0x14ffac[_0xfb7f('0x62')]['id'])});}return _0x14ffac[_0xfb7f('0x61')][_0xfb7f('0x65')];});}})[_0xfb7f('0x2f')](respondWithResult(_0x2422b5,null))[_0xfb7f('0x5d')](handleError(_0x2422b5,null));};exports['removeOpenchannelInteractions']=function(_0x50273d,_0xddc641,_0x4cadfe){return db['User']['find']({'where':{'id':_0x50273d['params']['id']}})['then'](handleEntityNotFound(_0xddc641,null))['then'](function(_0x126afc){if(_0x126afc){return _0x126afc[_0xfb7f('0x134')](_0x50273d[_0xfb7f('0x4b')][_0xfb7f('0x65')])[_0xfb7f('0x2f')](function(){if(_['isArray'](_0x50273d[_0xfb7f('0x4b')][_0xfb7f('0x65')])){for(var _0x19b1ea=0x0;_0x19b1ea<_0x50273d[_0xfb7f('0x4b')][_0xfb7f('0x65')][_0xfb7f('0x60')];_0x19b1ea+=0x1){socket[_0xfb7f('0xaa')](_0xfb7f('0x135'),{'OpenchannelInteractionId':Number(_0x50273d[_0xfb7f('0x4b')][_0xfb7f('0x65')][_0x19b1ea]),'UserId':Number(_0x50273d[_0xfb7f('0x62')]['id'])});}}else{socket[_0xfb7f('0xaa')]('user_has_openchannel_interactions:remove',{'OpenchannelInteractionId':Number(_0x50273d[_0xfb7f('0x4b')][_0xfb7f('0x65')]),'UserId':Number(_0x50273d[_0xfb7f('0x62')]['id'])});}});}})['then'](respondWithStatusCode(_0xddc641,null))[_0xfb7f('0x5d')](handleError(_0xddc641,null));};exports['addWhatsappInteractions']=function(_0x393611,_0x53618d,_0x16e847){return db[_0xfb7f('0x42')][_0xfb7f('0x3c')]({'where':{'id':_0x393611[_0xfb7f('0x62')]['id']}})[_0xfb7f('0x2f')](handleEntityNotFound(_0x53618d,null))['then'](function(_0x3fa514){if(_0x3fa514){return _0x3fa514[_0xfb7f('0x136')](_0x393611[_0xfb7f('0x61')][_0xfb7f('0x65')],_['omit'](_0x393611[_0xfb7f('0x61')],['ids','id'])||{})[_0xfb7f('0xa8')](function(){for(var _0x531bbd=0x0;_0x531bbd<_0x393611[_0xfb7f('0x61')][_0xfb7f('0x65')]['length'];_0x531bbd+=0x1){socket[_0xfb7f('0xaa')](_0xfb7f('0x137'),{'WhatsappInteractionId':Number(_0x393611[_0xfb7f('0x61')][_0xfb7f('0x65')][_0x531bbd]),'UserId':Number(_0x393611[_0xfb7f('0x62')]['id'])});}return _0x393611[_0xfb7f('0x61')]['ids'];});}})['then'](respondWithResult(_0x53618d,null))[_0xfb7f('0x5d')](handleError(_0x53618d,null));};exports[_0xfb7f('0x138')]=function(_0x57d38d,_0x26800d,_0x3f0530){return db['User'][_0xfb7f('0x3c')]({'where':{'id':_0x57d38d['params']['id']}})[_0xfb7f('0x2f')](handleEntityNotFound(_0x26800d,null))[_0xfb7f('0x2f')](function(_0x332507){if(_0x332507){return _0x332507[_0xfb7f('0x138')](_0x57d38d[_0xfb7f('0x4b')][_0xfb7f('0x65')]);}})[_0xfb7f('0x2f')](respondWithStatusCode(_0x26800d,null))['catch'](handleError(_0x26800d,null));};exports['getVoicePrefixes']=function(_0x5883ee,_0x519c6a,_0x829eea){var _0x3cda30={};var _0x4174e4={};var _0x44dda0;var _0x2ced76;return db[_0xfb7f('0x42')][_0xfb7f('0xc9')]({'where':{'id':_0x5883ee[_0xfb7f('0x62')]['id']}})[_0xfb7f('0x2f')](handleEntityNotFound(_0x519c6a,null))[_0xfb7f('0x2f')](function(_0x16e087){if(_0x16e087){_0x44dda0=_0x16e087;_0x4174e4[_0xfb7f('0x46')]=_[_0xfb7f('0x49')](db[_0xfb7f('0x139')][_0xfb7f('0xc1')]);_0x4174e4[_0xfb7f('0x4b')]=_[_0xfb7f('0x49')](_0x5883ee[_0xfb7f('0x4b')]);_0x4174e4[_0xfb7f('0x51')]=_[_0xfb7f('0x4a')](_0x4174e4['model'],_0x4174e4[_0xfb7f('0x4b')]);_0x3cda30[_0xfb7f('0x4c')]=_[_0xfb7f('0x4a')](_0x4174e4[_0xfb7f('0x46')],qs['fields'](_0x5883ee['query'][_0xfb7f('0x4d')]));_0x3cda30['attributes']=_0x3cda30[_0xfb7f('0x4c')][_0xfb7f('0x60')]?_0x3cda30[_0xfb7f('0x4c')]:_0x4174e4[_0xfb7f('0x46')];_0x3cda30[_0xfb7f('0x50')]=qs['sort'](_0x5883ee[_0xfb7f('0x4b')]['sort']);_0x3cda30[_0xfb7f('0x53')]=qs[_0xfb7f('0x51')](_['pick'](_0x5883ee[_0xfb7f('0x4b')],_0x4174e4[_0xfb7f('0x51')]));if(_0x5883ee['query']['filter']){_0x3cda30[_0xfb7f('0x53')]=_[_0xfb7f('0x54')](_0x3cda30[_0xfb7f('0x53')],{'$or':_[_0xfb7f('0x41')](_0x3cda30[_0xfb7f('0x4c')],function(_0x4cd953){var _0x316be5={};_0x316be5[_0x4cd953]={'$like':'%'+_0x5883ee['query'][_0xfb7f('0x38')]+'%'};return _0x316be5;})});}_0x3cda30=_[_0xfb7f('0x54')]({},_0x3cda30,_0x5883ee['options']);return _0x44dda0['getVoicePrefixes'](_0x3cda30);}})[_0xfb7f('0x2f')](function(_0x913ac2){if(_0x913ac2){_0x2ced76=_0x913ac2[_0xfb7f('0x60')];if(!_0x5883ee[_0xfb7f('0x4b')][_0xfb7f('0x4e')]('nolimit')){_0x3cda30[_0xfb7f('0x28')]=qs[_0xfb7f('0x28')](_0x5883ee[_0xfb7f('0x4b')]['limit']);_0x3cda30[_0xfb7f('0x27')]=qs[_0xfb7f('0x27')](_0x5883ee[_0xfb7f('0x4b')]['offset']);}return _0x44dda0[_0xfb7f('0x13a')](_0x3cda30);}})[_0xfb7f('0x2f')](function(_0x37a1af){if(_0x37a1af){return _0x37a1af?{'count':_0x2ced76,'rows':_0x37a1af}:null;}})[_0xfb7f('0x2f')](respondWithResult(_0x519c6a,null))[_0xfb7f('0x5d')](handleError(_0x519c6a,null));};exports[_0xfb7f('0x13b')]=function(_0x3265ba,_0x4004aa,_0x846af1){var _0x5647d8={};var _0x3bd487={};var _0xe40a5e;var _0x557cae;return db['User'][_0xfb7f('0xc9')]({'where':{'id':_0x3265ba[_0xfb7f('0x62')]['id']}})[_0xfb7f('0x2f')](handleEntityNotFound(_0x4004aa,null))[_0xfb7f('0x2f')](function(_0x5a405f){if(_0x5a405f){_0xe40a5e=_0x5a405f;_0x3bd487[_0xfb7f('0x46')]=_[_0xfb7f('0x49')](db[_0xfb7f('0x13c')][_0xfb7f('0xc1')]);_0x3bd487['query']=_[_0xfb7f('0x49')](_0x3265ba[_0xfb7f('0x4b')]);_0x3bd487[_0xfb7f('0x51')]=_[_0xfb7f('0x4a')](_0x3bd487[_0xfb7f('0x46')],_0x3bd487[_0xfb7f('0x4b')]);_0x5647d8['attributes']=_[_0xfb7f('0x4a')](_0x3bd487[_0xfb7f('0x46')],qs['fields'](_0x3265ba[_0xfb7f('0x4b')]['fields']));_0x5647d8[_0xfb7f('0x4c')]=_0x5647d8[_0xfb7f('0x4c')][_0xfb7f('0x60')]?_0x5647d8[_0xfb7f('0x4c')]:_0x3bd487[_0xfb7f('0x46')];_0x5647d8[_0xfb7f('0x50')]=qs[_0xfb7f('0xc2')](_0x3265ba[_0xfb7f('0x4b')][_0xfb7f('0xc2')]);_0x5647d8[_0xfb7f('0x53')]=qs[_0xfb7f('0x51')](_[_0xfb7f('0x52')](_0x3265ba['query'],_0x3bd487['filters']));if(_0x3265ba[_0xfb7f('0x4b')][_0xfb7f('0x38')]){_0x5647d8[_0xfb7f('0x53')]=_['merge'](_0x5647d8[_0xfb7f('0x53')],{'$or':_[_0xfb7f('0x41')](_0x5647d8[_0xfb7f('0x4c')],function(_0x50c42f){var _0x3a8feb={};_0x3a8feb[_0x50c42f]={'$like':'%'+_0x3265ba[_0xfb7f('0x4b')]['filter']+'%'};return _0x3a8feb;})});}_0x5647d8=_['merge']({},_0x5647d8,_0x3265ba[_0xfb7f('0x58')]);return _0xe40a5e[_0xfb7f('0x13b')](_0x5647d8);}})['then'](function(_0x1e3266){if(_0x1e3266){_0x557cae=_0x1e3266[_0xfb7f('0x60')];if(!_0x3265ba[_0xfb7f('0x4b')][_0xfb7f('0x4e')](_0xfb7f('0x4f'))){_0x5647d8['limit']=qs[_0xfb7f('0x28')](_0x3265ba['query'][_0xfb7f('0x28')]);_0x5647d8[_0xfb7f('0x27')]=qs[_0xfb7f('0x27')](_0x3265ba['query'][_0xfb7f('0x27')]);}return _0xe40a5e[_0xfb7f('0x13b')](_0x5647d8);}})[_0xfb7f('0x2f')](function(_0x42c215){if(_0x42c215){return _0x42c215?{'count':_0x557cae,'rows':_0x42c215}:null;}})[_0xfb7f('0x2f')](respondWithResult(_0x4004aa,null))[_0xfb7f('0x5d')](handleError(_0x4004aa,null));};exports['addFaxAccounts']=function(_0x2f8f9c,_0x406450,_0x303153){return db['User'][_0xfb7f('0x3c')]({'where':{'id':_0x2f8f9c[_0xfb7f('0x62')]['id']}})[_0xfb7f('0x2f')](handleEntityNotFound(_0x406450,null))[_0xfb7f('0x2f')](function(_0x1bb887){if(_0x1bb887){return _0x1bb887[_0xfb7f('0x13d')](_0x2f8f9c[_0xfb7f('0x61')][_0xfb7f('0x65')],_[_0xfb7f('0x10c')](_0x2f8f9c['body'],[_0xfb7f('0x65'),'id'])||{});}})[_0xfb7f('0x2f')](respondWithResult(_0x406450,null))[_0xfb7f('0x5d')](handleError(_0x406450,null));};exports[_0xfb7f('0x13e')]=function(_0x1e4faa,_0xcfc9bb,_0x26935c){return db[_0xfb7f('0x42')][_0xfb7f('0x3c')]({'where':{'id':_0x1e4faa[_0xfb7f('0x62')]['id']}})[_0xfb7f('0x2f')](handleEntityNotFound(_0xcfc9bb,null))[_0xfb7f('0x2f')](function(_0x390e4c){if(_0x390e4c){return _0x390e4c[_0xfb7f('0x13e')](_0x1e4faa['query'][_0xfb7f('0x65')]);}})[_0xfb7f('0x2f')](respondWithStatusCode(_0xcfc9bb,null))[_0xfb7f('0x5d')](handleError(_0xcfc9bb,null));};exports['getMailAccounts']=function(_0x4c44e3,_0x33182d,_0x296473){var _0x5206dd={};var _0x22fca7={};var _0x3c10be;var _0x545c5d;return db['User']['findOne']({'where':{'id':_0x4c44e3[_0xfb7f('0x62')]['id']}})[_0xfb7f('0x2f')](handleEntityNotFound(_0x33182d,null))[_0xfb7f('0x2f')](function(_0x3957b3){if(_0x3957b3){_0x3c10be=_0x3957b3;_0x22fca7[_0xfb7f('0x46')]=_[_0xfb7f('0x49')](db['MailAccount'][_0xfb7f('0xc1')]);_0x22fca7['query']=_[_0xfb7f('0x49')](_0x4c44e3[_0xfb7f('0x4b')]);_0x22fca7['filters']=_[_0xfb7f('0x4a')](_0x22fca7[_0xfb7f('0x46')],_0x22fca7[_0xfb7f('0x4b')]);_0x5206dd['attributes']=_['intersection'](_0x22fca7[_0xfb7f('0x46')],qs[_0xfb7f('0x4d')](_0x4c44e3['query'][_0xfb7f('0x4d')]));_0x5206dd[_0xfb7f('0x4c')]=_0x5206dd[_0xfb7f('0x4c')][_0xfb7f('0x60')]?_0x5206dd['attributes']:_0x22fca7[_0xfb7f('0x46')];_0x5206dd[_0xfb7f('0x50')]=qs['sort'](_0x4c44e3['query']['sort']);_0x5206dd['where']=qs[_0xfb7f('0x51')](_[_0xfb7f('0x52')](_0x4c44e3['query'],_0x22fca7[_0xfb7f('0x51')]));if(_0x4c44e3[_0xfb7f('0x4b')][_0xfb7f('0x38')]){_0x5206dd['where']=_[_0xfb7f('0x54')](_0x5206dd[_0xfb7f('0x53')],{'$or':_[_0xfb7f('0x41')](_0x5206dd[_0xfb7f('0x4c')],function(_0x5a8cdd){var _0x544811={};_0x544811[_0x5a8cdd]={'$like':'%'+_0x4c44e3[_0xfb7f('0x4b')][_0xfb7f('0x38')]+'%'};return _0x544811;})});}_0x5206dd=_['merge']({},_0x5206dd,_0x4c44e3[_0xfb7f('0x58')]);return _0x3c10be[_0xfb7f('0x13f')](_0x5206dd);}})[_0xfb7f('0x2f')](function(_0x3a9a35){if(_0x3a9a35){_0x545c5d=_0x3a9a35['length'];if(!_0x4c44e3[_0xfb7f('0x4b')][_0xfb7f('0x4e')](_0xfb7f('0x4f'))){_0x5206dd['limit']=qs['limit'](_0x4c44e3[_0xfb7f('0x4b')][_0xfb7f('0x28')]);_0x5206dd['offset']=qs['offset'](_0x4c44e3[_0xfb7f('0x4b')][_0xfb7f('0x27')]);}return _0x3c10be[_0xfb7f('0x13f')](_0x5206dd);}})['then'](function(_0x4cc042){if(_0x4cc042){return _0x4cc042?{'count':_0x545c5d,'rows':_0x4cc042}:null;}})[_0xfb7f('0x2f')](respondWithResult(_0x33182d,null))[_0xfb7f('0x5d')](handleError(_0x33182d,null));};exports['addMailAccounts']=function(_0x4d8540,_0xd5ac74,_0x3b8acb){return db['User'][_0xfb7f('0x3c')]({'where':{'id':_0x4d8540[_0xfb7f('0x62')]['id']}})[_0xfb7f('0x2f')](handleEntityNotFound(_0xd5ac74,null))['then'](function(_0x27be3e){if(_0x27be3e){return _0x27be3e[_0xfb7f('0x140')](_0x4d8540[_0xfb7f('0x61')][_0xfb7f('0x65')],_['omit'](_0x4d8540[_0xfb7f('0x61')],[_0xfb7f('0x65'),'id'])||{});}})[_0xfb7f('0x2f')](respondWithResult(_0xd5ac74,null))['catch'](handleError(_0xd5ac74,null));};exports[_0xfb7f('0x141')]=function(_0x4a2fa6,_0x48c3d3,_0x3e11d1){return db[_0xfb7f('0x42')][_0xfb7f('0x3c')]({'where':{'id':_0x4a2fa6[_0xfb7f('0x62')]['id']}})['then'](handleEntityNotFound(_0x48c3d3,null))[_0xfb7f('0x2f')](function(_0x1b1168){if(_0x1b1168){return _0x1b1168[_0xfb7f('0x141')](_0x4a2fa6[_0xfb7f('0x4b')]['ids']);}})[_0xfb7f('0x2f')](respondWithStatusCode(_0x48c3d3,null))[_0xfb7f('0x5d')](handleError(_0x48c3d3,null));};exports[_0xfb7f('0x142')]=function(_0xd1dcf1,_0x255b3e,_0x2aa234){var _0x3c6752={};var _0x5da3e9={};var _0x1b6a40;var _0x320493;return db['User'][_0xfb7f('0xc9')]({'where':{'id':_0xd1dcf1[_0xfb7f('0x62')]['id']}})['then'](handleEntityNotFound(_0x255b3e,null))[_0xfb7f('0x2f')](function(_0x562042){if(_0x562042){_0x1b6a40=_0x562042;_0x5da3e9[_0xfb7f('0x46')]=_[_0xfb7f('0x49')](db[_0xfb7f('0x143')][_0xfb7f('0xc1')]);_0x5da3e9[_0xfb7f('0x4b')]=_[_0xfb7f('0x49')](_0xd1dcf1[_0xfb7f('0x4b')]);_0x5da3e9[_0xfb7f('0x51')]=_['intersection'](_0x5da3e9[_0xfb7f('0x46')],_0x5da3e9[_0xfb7f('0x4b')]);_0x3c6752[_0xfb7f('0x4c')]=_[_0xfb7f('0x4a')](_0x5da3e9[_0xfb7f('0x46')],qs[_0xfb7f('0x4d')](_0xd1dcf1[_0xfb7f('0x4b')][_0xfb7f('0x4d')]));_0x3c6752[_0xfb7f('0x4c')]=_0x3c6752[_0xfb7f('0x4c')][_0xfb7f('0x60')]?_0x3c6752['attributes']:_0x5da3e9[_0xfb7f('0x46')];_0x3c6752['order']=qs['sort'](_0xd1dcf1[_0xfb7f('0x4b')]['sort']);_0x3c6752[_0xfb7f('0x53')]=qs['filters'](_[_0xfb7f('0x52')](_0xd1dcf1[_0xfb7f('0x4b')],_0x5da3e9[_0xfb7f('0x51')]));if(_0xd1dcf1[_0xfb7f('0x4b')][_0xfb7f('0x38')]){_0x3c6752[_0xfb7f('0x53')]=_[_0xfb7f('0x54')](_0x3c6752[_0xfb7f('0x53')],{'$or':_['map'](_0x3c6752[_0xfb7f('0x4c')],function(_0x24733b){var _0x17dfd3={};_0x17dfd3[_0x24733b]={'$like':'%'+_0xd1dcf1[_0xfb7f('0x4b')][_0xfb7f('0x38')]+'%'};return _0x17dfd3;})});}_0x3c6752=_[_0xfb7f('0x54')]({},_0x3c6752,_0xd1dcf1[_0xfb7f('0x58')]);return _0x1b6a40['getOpenchannelAccounts'](_0x3c6752);}})[_0xfb7f('0x2f')](function(_0x145df0){if(_0x145df0){_0x320493=_0x145df0[_0xfb7f('0x60')];if(!_0xd1dcf1[_0xfb7f('0x4b')][_0xfb7f('0x4e')](_0xfb7f('0x4f'))){_0x3c6752[_0xfb7f('0x28')]=qs[_0xfb7f('0x28')](_0xd1dcf1[_0xfb7f('0x4b')][_0xfb7f('0x28')]);_0x3c6752[_0xfb7f('0x27')]=qs[_0xfb7f('0x27')](_0xd1dcf1[_0xfb7f('0x4b')]['offset']);}return _0x1b6a40[_0xfb7f('0x142')](_0x3c6752);}})['then'](function(_0x34c4f7){if(_0x34c4f7){return _0x34c4f7?{'count':_0x320493,'rows':_0x34c4f7}:null;}})[_0xfb7f('0x2f')](respondWithResult(_0x255b3e,null))[_0xfb7f('0x5d')](handleError(_0x255b3e,null));};exports[_0xfb7f('0x144')]=function(_0x4ecc35,_0x33eeff,_0x3efd5e){return db[_0xfb7f('0x42')][_0xfb7f('0x3c')]({'where':{'id':_0x4ecc35[_0xfb7f('0x62')]['id']}})[_0xfb7f('0x2f')](handleEntityNotFound(_0x33eeff,null))['then'](function(_0x143c2e){if(_0x143c2e){return _0x143c2e[_0xfb7f('0x144')](_0x4ecc35[_0xfb7f('0x61')]['ids'],_[_0xfb7f('0x10c')](_0x4ecc35[_0xfb7f('0x61')],['ids','id'])||{});}})[_0xfb7f('0x2f')](respondWithResult(_0x33eeff,null))[_0xfb7f('0x5d')](handleError(_0x33eeff,null));};exports[_0xfb7f('0x145')]=function(_0x30efd9,_0x36d8ef,_0x6398e8){return db[_0xfb7f('0x42')][_0xfb7f('0x3c')]({'where':{'id':_0x30efd9['params']['id']}})[_0xfb7f('0x2f')](handleEntityNotFound(_0x36d8ef,null))[_0xfb7f('0x2f')](function(_0x29697c){if(_0x29697c){return _0x29697c['removeOpenchannelAccounts'](_0x30efd9['query'][_0xfb7f('0x65')]);}})[_0xfb7f('0x2f')](respondWithStatusCode(_0x36d8ef,null))[_0xfb7f('0x5d')](handleError(_0x36d8ef,null));};exports[_0xfb7f('0x146')]=function(_0x4253b7,_0xaf956f,_0x535c47){var _0x44165d={};var _0x5a3d1f={};var _0x494ba0;var _0x376a87;return db['User'][_0xfb7f('0xc9')]({'where':{'id':_0x4253b7['params']['id']}})[_0xfb7f('0x2f')](handleEntityNotFound(_0xaf956f,null))[_0xfb7f('0x2f')](function(_0x25b50e){if(_0x25b50e){_0x494ba0=_0x25b50e;_0x5a3d1f[_0xfb7f('0x46')]=_[_0xfb7f('0x49')](db[_0xfb7f('0x147')][_0xfb7f('0xc1')]);_0x5a3d1f[_0xfb7f('0x4b')]=_['keys'](_0x4253b7[_0xfb7f('0x4b')]);_0x5a3d1f[_0xfb7f('0x51')]=_[_0xfb7f('0x4a')](_0x5a3d1f[_0xfb7f('0x46')],_0x5a3d1f[_0xfb7f('0x4b')]);_0x44165d[_0xfb7f('0x4c')]=_[_0xfb7f('0x4a')](_0x5a3d1f['model'],qs[_0xfb7f('0x4d')](_0x4253b7[_0xfb7f('0x4b')]['fields']));_0x44165d['attributes']=_0x44165d['attributes'][_0xfb7f('0x60')]?_0x44165d[_0xfb7f('0x4c')]:_0x5a3d1f[_0xfb7f('0x46')];_0x44165d[_0xfb7f('0x50')]=qs['sort'](_0x4253b7[_0xfb7f('0x4b')]['sort']);_0x44165d[_0xfb7f('0x53')]=qs[_0xfb7f('0x51')](_[_0xfb7f('0x52')](_0x4253b7[_0xfb7f('0x4b')],_0x5a3d1f[_0xfb7f('0x51')]));if(_0x4253b7['query'][_0xfb7f('0x38')]){_0x44165d[_0xfb7f('0x53')]=_[_0xfb7f('0x54')](_0x44165d['where'],{'$or':_[_0xfb7f('0x41')](_0x44165d[_0xfb7f('0x4c')],function(_0x118ccc){var _0x590afb={};_0x590afb[_0x118ccc]={'$like':'%'+_0x4253b7[_0xfb7f('0x4b')]['filter']+'%'};return _0x590afb;})});}_0x44165d=_['merge']({},_0x44165d,_0x4253b7['options']);return _0x494ba0['getSmsAccounts'](_0x44165d);}})[_0xfb7f('0x2f')](function(_0x4db3cd){if(_0x4db3cd){_0x376a87=_0x4db3cd['length'];if(!_0x4253b7[_0xfb7f('0x4b')][_0xfb7f('0x4e')]('nolimit')){_0x44165d['limit']=qs[_0xfb7f('0x28')](_0x4253b7['query'][_0xfb7f('0x28')]);_0x44165d['offset']=qs['offset'](_0x4253b7[_0xfb7f('0x4b')]['offset']);}return _0x494ba0[_0xfb7f('0x146')](_0x44165d);}})[_0xfb7f('0x2f')](function(_0x53f7b3){if(_0x53f7b3){return _0x53f7b3?{'count':_0x376a87,'rows':_0x53f7b3}:null;}})[_0xfb7f('0x2f')](respondWithResult(_0xaf956f,null))[_0xfb7f('0x5d')](handleError(_0xaf956f,null));};exports['addSmsAccounts']=function(_0x1c1c4e,_0x25cd21,_0x21fb68){return db['User'][_0xfb7f('0x3c')]({'where':{'id':_0x1c1c4e[_0xfb7f('0x62')]['id']}})['then'](handleEntityNotFound(_0x25cd21,null))[_0xfb7f('0x2f')](function(_0x1bade4){if(_0x1bade4){return _0x1bade4['addSmsAccounts'](_0x1c1c4e['body'][_0xfb7f('0x65')],_[_0xfb7f('0x10c')](_0x1c1c4e[_0xfb7f('0x61')],[_0xfb7f('0x65'),'id'])||{});}})[_0xfb7f('0x2f')](respondWithResult(_0x25cd21,null))[_0xfb7f('0x5d')](handleError(_0x25cd21,null));};exports['removeSmsAccounts']=function(_0x3b6cda,_0x1270f8,_0x82f482){return db[_0xfb7f('0x42')][_0xfb7f('0x3c')]({'where':{'id':_0x3b6cda[_0xfb7f('0x62')]['id']}})[_0xfb7f('0x2f')](handleEntityNotFound(_0x1270f8,null))['then'](function(_0x569fa4){if(_0x569fa4){return _0x569fa4[_0xfb7f('0x148')](_0x3b6cda['query'][_0xfb7f('0x65')]);}})[_0xfb7f('0x2f')](respondWithStatusCode(_0x1270f8,null))[_0xfb7f('0x5d')](handleError(_0x1270f8,null));};exports[_0xfb7f('0x149')]=function(_0x3ab79e,_0x2b2be0,_0x3bb646){var _0x39f3ba={};var _0x5da139={};var _0x1d51a1;var _0x2b74bd;return db[_0xfb7f('0x42')][_0xfb7f('0xc9')]({'where':{'id':_0x3ab79e[_0xfb7f('0x62')]['id']}})[_0xfb7f('0x2f')](handleEntityNotFound(_0x2b2be0,null))['then'](function(_0x4164d9){if(_0x4164d9){_0x1d51a1=_0x4164d9;_0x5da139['model']=_[_0xfb7f('0x49')](db[_0xfb7f('0x14a')][_0xfb7f('0xc1')]);_0x5da139[_0xfb7f('0x4b')]=_[_0xfb7f('0x49')](_0x3ab79e[_0xfb7f('0x4b')]);_0x5da139[_0xfb7f('0x51')]=_[_0xfb7f('0x4a')](_0x5da139[_0xfb7f('0x46')],_0x5da139[_0xfb7f('0x4b')]);_0x39f3ba[_0xfb7f('0x4c')]=_[_0xfb7f('0x4a')](_0x5da139[_0xfb7f('0x46')],qs['fields'](_0x3ab79e[_0xfb7f('0x4b')][_0xfb7f('0x4d')]));_0x39f3ba['attributes']=_0x39f3ba[_0xfb7f('0x4c')][_0xfb7f('0x60')]?_0x39f3ba[_0xfb7f('0x4c')]:_0x5da139['model'];_0x39f3ba[_0xfb7f('0x50')]=qs[_0xfb7f('0xc2')](_0x3ab79e['query']['sort']);_0x39f3ba[_0xfb7f('0x53')]=qs[_0xfb7f('0x51')](_[_0xfb7f('0x52')](_0x3ab79e[_0xfb7f('0x4b')],_0x5da139[_0xfb7f('0x51')]));if(_0x3ab79e[_0xfb7f('0x4b')]['filter']){_0x39f3ba['where']=_[_0xfb7f('0x54')](_0x39f3ba[_0xfb7f('0x53')],{'$or':_['map'](_0x39f3ba['attributes'],function(_0x2f8e15){var _0x12bfe2={};_0x12bfe2[_0x2f8e15]={'$like':'%'+_0x3ab79e[_0xfb7f('0x4b')][_0xfb7f('0x38')]+'%'};return _0x12bfe2;})});}_0x39f3ba=_['merge']({},_0x39f3ba,_0x3ab79e[_0xfb7f('0x58')]);return _0x1d51a1[_0xfb7f('0x149')](_0x39f3ba);}})[_0xfb7f('0x2f')](function(_0x2ede49){if(_0x2ede49){_0x2b74bd=_0x2ede49['length'];if(!_0x3ab79e['query'][_0xfb7f('0x4e')]('nolimit')){_0x39f3ba['limit']=qs[_0xfb7f('0x28')](_0x3ab79e[_0xfb7f('0x4b')][_0xfb7f('0x28')]);_0x39f3ba[_0xfb7f('0x27')]=qs['offset'](_0x3ab79e[_0xfb7f('0x4b')]['offset']);}return _0x1d51a1['getChatWebsites'](_0x39f3ba);}})[_0xfb7f('0x2f')](function(_0x3c3582){if(_0x3c3582){return _0x3c3582?{'count':_0x2b74bd,'rows':_0x3c3582}:null;}})['then'](respondWithResult(_0x2b2be0,null))[_0xfb7f('0x5d')](handleError(_0x2b2be0,null));};exports['addChatWebsites']=function(_0x5b15b9,_0x4353c1,_0x45c268){return db[_0xfb7f('0x42')][_0xfb7f('0x3c')]({'where':{'id':_0x5b15b9[_0xfb7f('0x62')]['id']}})[_0xfb7f('0x2f')](handleEntityNotFound(_0x4353c1,null))[_0xfb7f('0x2f')](function(_0x579e25){if(_0x579e25){return _0x579e25[_0xfb7f('0x14b')](_0x5b15b9['body']['ids'],_[_0xfb7f('0x10c')](_0x5b15b9['body'],[_0xfb7f('0x65'),'id'])||{});}})['then'](respondWithResult(_0x4353c1,null))[_0xfb7f('0x5d')](handleError(_0x4353c1,null));};exports['removeChatWebsites']=function(_0x48ae71,_0xb6126b,_0x476629){return db[_0xfb7f('0x42')]['find']({'where':{'id':_0x48ae71[_0xfb7f('0x62')]['id']}})[_0xfb7f('0x2f')](handleEntityNotFound(_0xb6126b,null))[_0xfb7f('0x2f')](function(_0x19c26c){if(_0x19c26c){return _0x19c26c[_0xfb7f('0x14c')](_0x48ae71[_0xfb7f('0x4b')][_0xfb7f('0x65')]);}})[_0xfb7f('0x2f')](respondWithStatusCode(_0xb6126b,null))['catch'](handleError(_0xb6126b,null));};exports[_0xfb7f('0x14d')]=function(_0x399bc7,_0x147c14,_0x1cfacc){var _0x217b6d={};var _0x4e696f={};var _0x4ef969;var _0x29d826;return db['User'][_0xfb7f('0xc9')]({'where':{'id':_0x399bc7[_0xfb7f('0x62')]['id']}})[_0xfb7f('0x2f')](handleEntityNotFound(_0x147c14,null))[_0xfb7f('0x2f')](function(_0x191282){if(_0x191282){_0x4ef969=_0x191282;_0x4e696f[_0xfb7f('0x46')]=_[_0xfb7f('0x49')](db[_0xfb7f('0x14e')][_0xfb7f('0xc1')]);_0x4e696f[_0xfb7f('0x4b')]=_[_0xfb7f('0x49')](_0x399bc7[_0xfb7f('0x4b')]);_0x4e696f[_0xfb7f('0x51')]=_[_0xfb7f('0x4a')](_0x4e696f[_0xfb7f('0x46')],_0x4e696f[_0xfb7f('0x4b')]);_0x217b6d[_0xfb7f('0x4c')]=_[_0xfb7f('0x4a')](_0x4e696f[_0xfb7f('0x46')],qs['fields'](_0x399bc7[_0xfb7f('0x4b')][_0xfb7f('0x4d')]));_0x217b6d[_0xfb7f('0x4c')]=_0x217b6d[_0xfb7f('0x4c')][_0xfb7f('0x60')]?_0x217b6d['attributes']:_0x4e696f[_0xfb7f('0x46')];_0x217b6d['order']=qs['sort'](_0x399bc7[_0xfb7f('0x4b')][_0xfb7f('0xc2')]);_0x217b6d[_0xfb7f('0x53')]=qs[_0xfb7f('0x51')](_['pick'](_0x399bc7[_0xfb7f('0x4b')],_0x4e696f[_0xfb7f('0x51')]));if(_0x399bc7[_0xfb7f('0x4b')][_0xfb7f('0x38')]){_0x217b6d[_0xfb7f('0x53')]=_[_0xfb7f('0x54')](_0x217b6d['where'],{'$or':_['map'](_0x217b6d[_0xfb7f('0x4c')],function(_0x4ca4b4){var _0x560c92={};_0x560c92[_0x4ca4b4]={'$like':'%'+_0x399bc7['query'][_0xfb7f('0x38')]+'%'};return _0x560c92;})});}_0x217b6d=_[_0xfb7f('0x54')]({},_0x217b6d,_0x399bc7[_0xfb7f('0x58')]);return _0x4ef969[_0xfb7f('0x14d')](_0x217b6d);}})[_0xfb7f('0x2f')](function(_0x47df26){if(_0x47df26){_0x29d826=_0x47df26[_0xfb7f('0x60')];if(!_0x399bc7['query'][_0xfb7f('0x4e')](_0xfb7f('0x4f'))){_0x217b6d['limit']=qs[_0xfb7f('0x28')](_0x399bc7[_0xfb7f('0x4b')][_0xfb7f('0x28')]);_0x217b6d[_0xfb7f('0x27')]=qs[_0xfb7f('0x27')](_0x399bc7[_0xfb7f('0x4b')][_0xfb7f('0x27')]);}return _0x4ef969[_0xfb7f('0x14d')](_0x217b6d);}})[_0xfb7f('0x2f')](function(_0x57b977){if(_0x57b977){return _0x57b977?{'count':_0x29d826,'rows':_0x57b977}:null;}})['then'](respondWithResult(_0x147c14,null))[_0xfb7f('0x5d')](handleError(_0x147c14,null));};exports[_0xfb7f('0x14f')]=function(_0x136f3,_0x2f7c3b,_0x565114){return db['User'][_0xfb7f('0x3c')]({'where':{'id':_0x136f3[_0xfb7f('0x62')]['id']}})[_0xfb7f('0x2f')](handleEntityNotFound(_0x2f7c3b,null))['then'](function(_0x3262f3){if(_0x3262f3){return _0x3262f3['addWhatsappAccounts'](_0x136f3[_0xfb7f('0x61')][_0xfb7f('0x65')],_[_0xfb7f('0x10c')](_0x136f3[_0xfb7f('0x61')],[_0xfb7f('0x65'),'id'])||{});}})['then'](respondWithResult(_0x2f7c3b,null))[_0xfb7f('0x5d')](handleError(_0x2f7c3b,null));};exports[_0xfb7f('0x150')]=function(_0x15b5e1,_0x2a2223,_0x4f9768){return db[_0xfb7f('0x42')][_0xfb7f('0x3c')]({'where':{'id':_0x15b5e1[_0xfb7f('0x62')]['id']}})['then'](handleEntityNotFound(_0x2a2223,null))[_0xfb7f('0x2f')](function(_0x179ff9){if(_0x179ff9){return _0x179ff9[_0xfb7f('0x150')](_0x15b5e1['query'][_0xfb7f('0x65')]);}})[_0xfb7f('0x2f')](respondWithStatusCode(_0x2a2223,null))[_0xfb7f('0x5d')](handleError(_0x2a2223,null));};exports[_0xfb7f('0x151')]=function(_0x40b64b,_0x3e4618,_0x477ddc){var _0x3063b2={};var _0x59932a={};var _0x8ee1e6;var _0x71fe4;return db[_0xfb7f('0x42')][_0xfb7f('0xc9')]({'where':{'id':_0x40b64b[_0xfb7f('0x62')]['id']}})[_0xfb7f('0x2f')](handleEntityNotFound(_0x3e4618,null))[_0xfb7f('0x2f')](function(_0xf17920){if(_0xf17920){_0x8ee1e6=_0xf17920;_0x59932a[_0xfb7f('0x46')]=_[_0xfb7f('0x49')](db[_0xfb7f('0x152')]['rawAttributes']);_0x59932a[_0xfb7f('0x4b')]=_[_0xfb7f('0x49')](_0x40b64b[_0xfb7f('0x4b')]);_0x59932a[_0xfb7f('0x51')]=_[_0xfb7f('0x4a')](_0x59932a['model'],_0x59932a[_0xfb7f('0x4b')]);_0x3063b2[_0xfb7f('0x4c')]=_['intersection'](_0x59932a['model'],qs[_0xfb7f('0x4d')](_0x40b64b[_0xfb7f('0x4b')]['fields']));_0x3063b2[_0xfb7f('0x4c')]=_0x3063b2['attributes'][_0xfb7f('0x60')]?_0x3063b2[_0xfb7f('0x4c')]:_0x59932a[_0xfb7f('0x46')];_0x3063b2[_0xfb7f('0x50')]=qs['sort'](_0x40b64b[_0xfb7f('0x4b')]['sort']);_0x3063b2[_0xfb7f('0x53')]=qs[_0xfb7f('0x51')](_[_0xfb7f('0x52')](_0x40b64b[_0xfb7f('0x4b')],_0x59932a[_0xfb7f('0x51')]));if(_0x40b64b[_0xfb7f('0x4b')][_0xfb7f('0x38')]){_0x3063b2[_0xfb7f('0x53')]=_[_0xfb7f('0x54')](_0x3063b2[_0xfb7f('0x53')],{'$or':_[_0xfb7f('0x41')](_0x3063b2[_0xfb7f('0x4c')],function(_0x1bc8cc){var _0x50b182={};_0x50b182[_0x1bc8cc]={'$like':'%'+_0x40b64b[_0xfb7f('0x4b')][_0xfb7f('0x38')]+'%'};return _0x50b182;})});}_0x3063b2=_[_0xfb7f('0x54')]({},_0x3063b2,_0x40b64b[_0xfb7f('0x58')]);return _0x8ee1e6[_0xfb7f('0x151')](_0x3063b2);}})[_0xfb7f('0x2f')](function(_0x30e7bd){if(_0x30e7bd){_0x71fe4=_0x30e7bd[_0xfb7f('0x60')];if(!_0x40b64b[_0xfb7f('0x4b')][_0xfb7f('0x4e')](_0xfb7f('0x4f'))){_0x3063b2[_0xfb7f('0x28')]=qs[_0xfb7f('0x28')](_0x40b64b[_0xfb7f('0x4b')][_0xfb7f('0x28')]);_0x3063b2[_0xfb7f('0x27')]=qs[_0xfb7f('0x27')](_0x40b64b[_0xfb7f('0x4b')][_0xfb7f('0x27')]);}return _0x8ee1e6[_0xfb7f('0x151')](_0x3063b2);}})[_0xfb7f('0x2f')](function(_0x457023){if(_0x457023){return _0x457023?{'count':_0x71fe4,'rows':_0x457023}:null;}})[_0xfb7f('0x2f')](respondWithResult(_0x3e4618,null))[_0xfb7f('0x5d')](handleError(_0x3e4618,null));};exports['addSquareProjects']=function(_0x4c4230,_0x3973cb,_0x40d7a2){return db[_0xfb7f('0x42')]['find']({'where':{'id':_0x4c4230[_0xfb7f('0x62')]['id']}})['then'](handleEntityNotFound(_0x3973cb,null))['then'](function(_0x3fe910){if(_0x3fe910){return _0x3fe910['addSquareProjects'](_0x4c4230['body'][_0xfb7f('0x65')],_['omit'](_0x4c4230['body'],[_0xfb7f('0x65'),'id'])||{});}})[_0xfb7f('0x2f')](respondWithResult(_0x3973cb,null))[_0xfb7f('0x5d')](handleError(_0x3973cb,null));};exports['removeSquareProjects']=function(_0x592b73,_0x3c469a,_0x268552){return db[_0xfb7f('0x42')]['find']({'where':{'id':_0x592b73[_0xfb7f('0x62')]['id']}})[_0xfb7f('0x2f')](handleEntityNotFound(_0x3c469a,null))[_0xfb7f('0x2f')](function(_0xaf9c6){if(_0xaf9c6){return _0xaf9c6['removeSquareProjects'](_0x592b73[_0xfb7f('0x4b')]['ids']);}})[_0xfb7f('0x2f')](respondWithStatusCode(_0x3c469a,null))[_0xfb7f('0x5d')](handleError(_0x3c469a,null));};exports[_0xfb7f('0x153')]=function(_0x166575,_0x3075f1){var _0x1a039f={},_0x23c519={},_0x4e08bd={'count':0x0,'rows':[]};var _0x1adced=db[_0xfb7f('0x154')][_0xfb7f('0xc1')];_0x23c519['model']=_['keys'](_0x1adced);_0x23c519[_0xfb7f('0x4b')]=_['keys'](_0x166575['query']);_0x23c519[_0xfb7f('0x51')]=_[_0xfb7f('0x4a')](_0x23c519['model'],_0x23c519[_0xfb7f('0x4b')]);_0x23c519[_0xfb7f('0x51')]=_[_0xfb7f('0x155')](_0x23c519[_0xfb7f('0x51')],[_0xfb7f('0x156'),_0xfb7f('0x157'),_0xfb7f('0x158'),_0xfb7f('0x159'),_0xfb7f('0x15a'),_0xfb7f('0x15b'),_0xfb7f('0x15c'),_0xfb7f('0x15d'),_0xfb7f('0x15e'),'$between',_0xfb7f('0x15f'),'$in',_0xfb7f('0x160'),_0xfb7f('0x161'),_0xfb7f('0x162'),_0xfb7f('0x163'),_0xfb7f('0x164'),_0xfb7f('0x161'),_0xfb7f('0x165'),_0xfb7f('0x166'),_0xfb7f('0x167'),_0xfb7f('0x168')]);_0x1a039f[_0xfb7f('0x4c')]=_[_0xfb7f('0x4a')](_0x23c519[_0xfb7f('0x46')],qs[_0xfb7f('0x4d')](_0x166575[_0xfb7f('0x4b')][_0xfb7f('0x4d')]));_0x1a039f['attributes']=_0x1a039f[_0xfb7f('0x4c')][_0xfb7f('0x60')]?_0x1a039f[_0xfb7f('0x4c')]:_0x23c519[_0xfb7f('0x46')];if(!_0x166575[_0xfb7f('0x4b')]['hasOwnProperty']('nolimit')){_0x1a039f[_0xfb7f('0x28')]=qs['limit'](_0x166575[_0xfb7f('0x4b')][_0xfb7f('0x28')]);_0x1a039f[_0xfb7f('0x27')]=qs[_0xfb7f('0x27')](_0x166575['query'][_0xfb7f('0x27')]);}_0x1a039f[_0xfb7f('0x50')]=qs[_0xfb7f('0xc2')](_0x166575[_0xfb7f('0x4b')][_0xfb7f('0xc2')]);_0x1a039f['where']=qs['filters'](_['pick'](_0x166575['query'],_0x23c519[_0xfb7f('0x51')]));if(_0x166575[_0xfb7f('0x4b')]['filter']){_0x1a039f[_0xfb7f('0x53')]=_[_0xfb7f('0x54')](_0x1a039f[_0xfb7f('0x53')],{'$or':_[_0xfb7f('0x41')](_0x1a039f[_0xfb7f('0x4c')],function(_0x322d59){var _0x39df1f={};_0x39df1f[_0x322d59]={'$like':'%'+_0x166575[_0xfb7f('0x4b')]['filter']+'%'};return _0x39df1f;})});}_0x1a039f[_0xfb7f('0x53')]={'$and':[_0x1a039f[_0xfb7f('0x53')],{'$or':[{'UserId':_0x166575[_0xfb7f('0x62')]['id']},{'OwnerId':_0x166575['params']['id']}]}]};_0x1a039f=_[_0xfb7f('0x54')]({},_0x1a039f,_0x166575['options']);var _0x4d596a={'where':_0x1a039f[_0xfb7f('0x53')]};return db[_0xfb7f('0x154')][_0xfb7f('0x26')](_0x4d596a)[_0xfb7f('0x2f')](function(_0x2f7fe8){_0x4e08bd[_0xfb7f('0x26')]=_0x2f7fe8;if(_0x166575[_0xfb7f('0x4b')][_0xfb7f('0x59')]){_0x1a039f['include']=[{'attributes':['id',_0xfb7f('0x169'),_0xfb7f('0x16a'),'phone'],'model':db[_0xfb7f('0xc0')],'as':_0xfb7f('0x16b')},{'attributes':['id',_0xfb7f('0x3d'),_0xfb7f('0x16c')],'model':db['VoiceQueue'],'as':'Queue'}];}return db[_0xfb7f('0x154')][_0xfb7f('0x5b')](_0x1a039f);})[_0xfb7f('0x2f')](function(_0x1b8fe7){_0x4e08bd[_0xfb7f('0x5c')]=_0x1b8fe7;return _0x4e08bd;})[_0xfb7f('0x2f')](respondWithFilteredResult(_0x3075f1,_0x1a039f))[_0xfb7f('0x5d')](handleError(_0x3075f1,null));};exports[_0xfb7f('0x16d')]=function(_0x293fdc,_0x1f5284,_0x596e2d){if(!_[_0xfb7f('0x6c')](_0x293fdc['user']['id'])&&(_0x293fdc['user'][_0xfb7f('0x32')]==_0xfb7f('0x33')||_0x293fdc[_0xfb7f('0x80')][_0xfb7f('0x32')]==_0xfb7f('0x80'))){return db['User'][_0xfb7f('0xc9')]({'where':{'id':_0x293fdc['params']['id']},'raw':!![]})[_0xfb7f('0x2f')](function(_0x1ddec4){return authService[_0xfb7f('0x16e')](_0x1ddec4);})['then'](function(_0x2677a2){if(_0x2677a2){return _0x1f5284[_0xfb7f('0x29')](0xc8)[_0xfb7f('0x25')]({'api_key':_0x2677a2['token']});}else{return _0x1f5284['status'](0xcc)[_0xfb7f('0x25')]({'message':_0xfb7f('0x16f')});}})[_0xfb7f('0x5d')](handleError(_0x1f5284,0x193));}else{return _0x1f5284[_0xfb7f('0x29')](0x191)[_0xfb7f('0x25')]({'message':_0xfb7f('0x170')});}};exports[_0xfb7f('0x171')]=function(_0xafa8aa,_0x4d6f8e,_0x359b2b){if(!_['isNil'](_0xafa8aa[_0xfb7f('0x80')]['id'])&&(_0xafa8aa['user'][_0xfb7f('0x32')]==_0xfb7f('0x33')||_0xafa8aa['user'][_0xfb7f('0x32')]==_0xfb7f('0x80'))){return db[_0xfb7f('0x42')][_0xfb7f('0x3c')]({'where':{'id':_0xafa8aa[_0xfb7f('0x62')]['id']}})[_0xfb7f('0x2f')](function(_0x4bb022){return authService['generateApiKey'](_0x4bb022);})[_0xfb7f('0x2f')](function(_0x774a8d){return db[_0xfb7f('0x42')]['update']({'apiKeyIat':_0x774a8d['iat'],'apiKeyNonce':_0x774a8d[_0xfb7f('0x172')]},{'where':{'id':_0xafa8aa['params']['id']}})[_0xfb7f('0x2f')](function(){return _0x4d6f8e[_0xfb7f('0x29')](0xc8)[_0xfb7f('0x25')]({'api_key':_0x774a8d[_0xfb7f('0x173')]});});})[_0xfb7f('0x5d')](handleError(_0x4d6f8e,0x193));}else{return _0x4d6f8e[_0xfb7f('0x29')](0x191)[_0xfb7f('0x25')]({'message':_0xfb7f('0x170')});}};exports[_0xfb7f('0x174')]=function(_0x3013a3,_0x181c95,_0x4db983){if(!_['isNil'](_0x3013a3[_0xfb7f('0x80')]['id'])&&(_0x3013a3[_0xfb7f('0x80')][_0xfb7f('0x32')]==_0xfb7f('0x33')||_0x3013a3[_0xfb7f('0x80')][_0xfb7f('0x32')]=='user')){return db[_0xfb7f('0x42')][_0xfb7f('0x3c')]({'where':{'id':_0x3013a3['params']['id']}})[_0xfb7f('0x2f')](handleEntityNotFound(_0x181c95,null))[_0xfb7f('0x2f')](function(_0x5ae6b8){if(_0x5ae6b8&&_0x5ae6b8[_0xfb7f('0x175')]&&_0x5ae6b8['apiKeyIat'])return _0x5ae6b8;else throw{'message':'API\x20key\x20not\x20available'};})[_0xfb7f('0x2f')](function(_0x57de8c){return db['User']['update']({'apiKeyNonce':null,'apiKeyIat':null},{'where':{'id':_0x3013a3[_0xfb7f('0x62')]['id']}});})[_0xfb7f('0x2f')](respondWithStatusCode(_0x181c95,0xc8))[_0xfb7f('0x5d')](handleError(_0x181c95,0x193));}else{return _0x181c95[_0xfb7f('0x29')](0x191)['json']({'message':_0xfb7f('0x170')});}};exports[_0xfb7f('0x176')]=function(_0x4523f6,_0x2c62ad){var _0xd45d33=_0x4523f6[_0xfb7f('0x80')][_0xfb7f('0x31')]({'plain':!![]});if(!_0xd45d33){return _0x2c62ad[_0xfb7f('0x29')](0x191)[_0xfb7f('0x3f')](_0xfb7f('0x177'));}else{return _0x2c62ad[_0xfb7f('0x29')](0xc8)[_0xfb7f('0x25')](_0xd45d33);}};
\ No newline at end of file
+var _0xa4c2=['upsert','removeQueues','remove','Queues','Queue:remove','userpic','filename','getAvatar','join','root','server/files/images/','download','findOne','CmContact','order','getContacts','List','Tag','Tags','color','tag','getQueues','Queue','Unknown\x20role','getVoiceQueuesRt','ChatGroup','getGroups','getRecordings','VoiceRecording','UserId','getScreenRecordings','ScreenRecording','ChatInteraction','getChatInteractions','getOpenchannelInteractions','OpenchannelInteraction','getMailInteractions','MailInteraction','getSmsInteractions','getFaxInteractions','FaxInteraction','getWhatsappInteractions','WhatsappInteraction','phone','mobile','LOCAL/%s@from-sip/n','intrf','user:%s','headers','remoteAddress','connection','socket','getVoiceQueues','UserVoiceQueue.penalty','MemberReport','forEach','YYYY-MM-DD\x20HH:mm:ss','getChannels','LOGIN','device','PAUSE','LOGININPAUSE','concat','isMiddleware','resolve','logout','QueuePause','DEFAULT\x20PAUSE','voicePause','chatPause','faxPause','smsPause','pauseType','lastPauseAt','unpause','manual','chat','fax','whatsapp','openchannel','%s%s','Pause','getTeams','addTeams','Team','setDataValue','Voice','getChatQueues','getMailQueues','Mail','getSmsQueues','getWhatsappQueues','Whatsapp','getFaxQueues','Fax','getOpenchannelQueues','flatten','transaction','getDataValue','Queue:save','removeTeams','Chat','Sms','Openchannel','removeAgent','CmList','getLists','getAgents','values','You\x20can\x27t\x20delete\x20yourself','addChatInteractions','user_has_chat_interactions:save','isArray','user_has_chat_interactions:remove','addMailInteractions','user_has_mail_interactions:save','removeMailInteractions','user_has_mail_interactions:remove','addFaxInteractions','removeFaxInteractions','user_has_fax_interactions:remove','addSmsInteractions','user_has_sms_interactions:save','removeSmsInteractions','user_has_sms_interactions:remove','addOpenchannelInteractions','user_has_openchannel_interactions:save','removeOpenchannelInteractions','user_has_openchannel_interactions:remove','addWhatsappInteractions','removeWhatsappInteractions','getVoicePrefixes','VoicePrefix','getFaxAccounts','FaxAccount','addFaxAccounts','removeFaxAccounts','getMailAccounts','addMailAccounts','removeMailAccounts','getOpenchannelAccounts','OpenchannelAccount','addOpenchannelAccounts','removeOpenchannelAccounts','getSmsAccounts','SmsAccount','addSmsAccounts','removeSmsAccounts','ChatWebsite','getChatWebsites','addChatWebsites','removeChatWebsites','getWhatsappAccounts','WhatsappAccount','addWhatsappAccounts','removeWhatsappAccounts','SquareProject','getSquareProjects','addSquareProjects','removeSquareProjects','getScheduledCalls','$and','$or','$gt','$gte','$lt','$lte','$ne','$eq','$not','$between','$notBetween','$in','$notIn','$like','$iLike','$notILike','$overlap','$contains','$contained','firstName','lastName','Contact','dialActive','token','No\x20API\x20access\x20key\x20found!','You\x20don\x27t\x20have\x20sufficient\x20privileges\x20to\x20access\x20this\x20resource.','createApiKey','iat','nonce','apiKeyIat','whoami','Unable\x20to\x20retrieve\x20the\x20current\x20user','html-pdf','rimraf','fast-json-patch','request-promise','mustache','path','sox','ejs','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/license/util','../../mysqldb','defaults','redis','socket.io-emitter','./user.socket','jayson/promise','client','request','info','debug','stringify','error','code','User,\x20%s,\x20%s','message','request\x20sent','result','sendStatus','status','end','json','count','offset','limit','set','Content-Range','apply','reject','update','then','destroy','get','admin','Agents','agent','telephone','filter','map','value','includes','role','UserProfileResource','stack','name','send','index','User','rawAttributes','type','model','differenceBy','salt','query','keys','filters','intersection','fields','attributes','hasOwnProperty','nolimit','sort','where','pick','merge','VIRTUAL','sequelize','col','options','includeAll','include','findAll','rows','catch','show','password','length','find','body','params','describe','addContacts','omit','internal','findById','securePassword','max','isNil','min_internal','select\x20(select\x20IFNULL(max(internal)+1,1)\x20from\x20users\x20where\x20internal\x20<\x20md.internal)\x20as\x20\x27from\x27,\x20md.internal\x20-\x201\x20as\x20\x27to\x27\x20from\x20users\x20md\x20where\x20md.internal\x20!=\x201\x20and\x20not\x20exists\x20(select\x201\x20from\x20users\x20md2\x20where\x20md2.internal\x20=\x20md.internal\x20-\x201)','QueryTypes','SELECT','from','voicemail','fullname','email','permissions','101','102','113','110','104','106','107','108','109','111','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','VoiceMail','UserProfileSection','Telephones','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','bulkCreate','some','push','all','each','isEmpty','changePassword','oldPassword','Sequelize','authenticate','ValidationError','Wrong\x20credentials','newPassword','New\x20password\x20must\x20be\x20different\x20from\x20old\x20password','Invalid\x20body\x20format.\x20Use\x20newPassword','Setting','enforcePasswordHistory','validatePasswordPattern','previousPasswords','validatePasswordHistory','passwordHistoryLimit','updatePasswordsHistory','addQueues','channel','online','loginInPause','isValidChannel','Unknown\x20channel','add','capitalize','toLowerCase','ids','penalty','spread','QueueId','emit','voice','VoiceQueue','interface','format','SIP/%s','UserVoiceQueueRt'];(function(_0x1d1f04,_0x40cdae){var _0xba8258=function(_0x454d7a){while(--_0x454d7a){_0x1d1f04['push'](_0x1d1f04['shift']());}};_0xba8258(++_0x40cdae);}(_0xa4c2,0xc1));var _0x2a4c=function(_0x23db28,_0xb38d31){_0x23db28=_0x23db28-0x0;var _0x53e75a=_0xa4c2[_0x23db28];return _0x53e75a;};'use strict';var pdf=require(_0x2a4c('0x0'));var emlformat=require('eml-format');var rimraf=require(_0x2a4c('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0x2a4c('0x2'));var rp=require(_0x2a4c('0x3'));var moment=require('moment');var BPromise=require('bluebird');var Mustache=require(_0x2a4c('0x4'));var util=require('util');var path=require(_0x2a4c('0x5'));var sox=require(_0x2a4c('0x6'));var csv=require('to-csv');var ejs=require(_0x2a4c('0x7'));var fs=require('fs');var _=require(_0x2a4c('0x8'));var squel=require(_0x2a4c('0x9'));var crypto=require(_0x2a4c('0xa'));var jsforce=require(_0x2a4c('0xb'));var deskjs=require(_0x2a4c('0xc'));var toCsv=require('to-csv');var querystring=require(_0x2a4c('0xd'));var Papa=require(_0x2a4c('0xe'));var Redis=require(_0x2a4c('0xf'));var authService=require(_0x2a4c('0x10'));var qs=require(_0x2a4c('0x11'));var as=require(_0x2a4c('0x12'));var hardwareService=require(_0x2a4c('0x13'));var logger=require('../../config/logger')(_0x2a4c('0x14'));var utils=require('../../config/utils');var config=require('../../config/environment');var licenseUtil=require(_0x2a4c('0x15'));var db=require(_0x2a4c('0x16'))['db'];config['redis']=_[_0x2a4c('0x17')](config[_0x2a4c('0x18')],{'host':'localhost','port':0x18eb});var socket=require(_0x2a4c('0x19'))(new Redis(config['redis']));require(_0x2a4c('0x1a'))['register'](socket);var jayson=require(_0x2a4c('0x1b'));var client=jayson[_0x2a4c('0x1c')]['http']({'port':0x232a});function respondWithRpcPromise(_0x272a4a,_0xa1bca6,_0x4e39d6,_0x2df708){return new BPromise(function(_0x391629,_0x27f81a){var _0x47921d=_0x2df708||client;return _0x47921d[_0x2a4c('0x1d')](_0x272a4a,_0x4e39d6)['then'](function(_0x217732){logger[_0x2a4c('0x1e')]('User,\x20%s,\x20%s',_0xa1bca6,'request\x20sent');logger[_0x2a4c('0x1f')]('User,\x20%s,\x20%s,\x20%s',_0xa1bca6,'request\x20sent',JSON[_0x2a4c('0x20')](_0x217732));if(_0x217732['error']){if(_0x217732[_0x2a4c('0x21')][_0x2a4c('0x22')]===0x1f4){logger['error'](_0x2a4c('0x23'),_0xa1bca6,_0x217732['error'][_0x2a4c('0x24')]);return _0x27f81a(_0x217732[_0x2a4c('0x21')][_0x2a4c('0x24')]);}logger['error'](_0x2a4c('0x23'),_0xa1bca6,_0x217732[_0x2a4c('0x21')][_0x2a4c('0x24')]);return _0x391629(_0x217732[_0x2a4c('0x21')][_0x2a4c('0x24')]);}else{logger['info']('User,\x20%s,\x20%s',_0xa1bca6,_0x2a4c('0x25'));_0x391629(_0x217732[_0x2a4c('0x26')]['message']);}})['catch'](function(_0xd381cf){logger[_0x2a4c('0x21')](_0x2a4c('0x23'),_0xa1bca6,_0xd381cf);_0x27f81a(_0xd381cf);});});}function respondWithStatusCode(_0x561045,_0x3be947){_0x3be947=_0x3be947||0xcc;return function(_0x1524be){if(_0x1524be){return _0x561045[_0x2a4c('0x27')](_0x3be947);}return _0x561045[_0x2a4c('0x28')](_0x3be947)[_0x2a4c('0x29')]();};}function respondWithResult(_0x14fb3e,_0x2f462c){_0x2f462c=_0x2f462c||0xc8;return function(_0x1275d6){if(_0x1275d6){return _0x14fb3e[_0x2a4c('0x28')](_0x2f462c)[_0x2a4c('0x2a')](_0x1275d6);}};}function respondWithFilteredResult(_0x2201cc,_0x433729){return function(_0x5b3466){if(_0x5b3466){var _0x17f12b=_0x5b3466[_0x2a4c('0x2b')],_0x233d3c=_0x433729[_0x2a4c('0x2c')],_0x595366=_0x433729[_0x2a4c('0x2c')]+_0x433729[_0x2a4c('0x2d')],_0x247916;if(_0x595366>=_0x17f12b){_0x595366=_0x17f12b;_0x247916=0xc8;}else{_0x247916=0xce;}_0x2201cc[_0x2a4c('0x28')](_0x247916);return _0x2201cc[_0x2a4c('0x2e')](_0x2a4c('0x2f'),_0x233d3c+'-'+_0x595366+'/'+_0x17f12b)[_0x2a4c('0x2a')](_0x5b3466);}return null;};}function patchUpdates(_0xc0f174){return function(_0x564ad9){try{jsonpatch[_0x2a4c('0x30')](_0x564ad9,_0xc0f174,!![]);}catch(_0x187fb6){return BPromise[_0x2a4c('0x31')](_0x187fb6);}return _0x564ad9['save']();};}function saveUpdates(_0x2757fb,_0x4288b4){return function(_0x4e0c9b){if(_0x4e0c9b){return _0x4e0c9b[_0x2a4c('0x32')](_0x2757fb)[_0x2a4c('0x33')](function(_0x543c1){return _0x543c1;});}return null;};}function removeEntity(_0x25b596,_0x1956ff){return function(_0xcdde3e){if(_0xcdde3e){return _0xcdde3e[_0x2a4c('0x34')]()[_0x2a4c('0x33')](function(){var _0x2036c2=_0xcdde3e[_0x2a4c('0x35')]({'plain':!![]});if(_0x2036c2['role']===_0x2a4c('0x36'))return;var _0x1af000=[{'name':'Users','value':'user','ignore':!![]},{'name':_0x2a4c('0x37'),'value':_0x2a4c('0x38'),'ignore':![]},{'name':'Telephones','value':_0x2a4c('0x39'),'ignore':![]}];var _0x4360d2=_(_0x1af000)[_0x2a4c('0x3a')]('ignore')[_0x2a4c('0x3b')](_0x2a4c('0x3c'))[_0x2a4c('0x3c')]();if(_[_0x2a4c('0x3d')](_0x4360d2,_0x2036c2[_0x2a4c('0x3e')])){return;}var _0x1aa6f1=_['find'](_0x1af000,[_0x2a4c('0x3c'),_0x2036c2['role']])['name'];return db[_0x2a4c('0x3f')]['destroy']({'where':{'type':_0x1aa6f1,'resourceId':_0x2036c2['id']}})['then'](function(){return _0xcdde3e;});})[_0x2a4c('0x33')](function(){_0x25b596[_0x2a4c('0x28')](0xcc)[_0x2a4c('0x29')]();});}};}function handleEntityNotFound(_0x329880,_0x57deca){return function(_0x50a17e){if(!_0x50a17e){_0x329880[_0x2a4c('0x27')](0x194);}return _0x50a17e;};}function handleError(_0x1c94d4,_0x19b6b6){_0x19b6b6=_0x19b6b6||0x1f4;return function(_0xe4fdca){logger[_0x2a4c('0x21')](_0xe4fdca[_0x2a4c('0x40')]);if(_0xe4fdca[_0x2a4c('0x41')]){delete _0xe4fdca[_0x2a4c('0x41')];}_0x1c94d4[_0x2a4c('0x28')](_0x19b6b6)[_0x2a4c('0x42')](_0xe4fdca);};}exports[_0x2a4c('0x43')]=function(_0x486fe6,_0x308698){var _0x3f0078={},_0x2eab91={},_0x2f8fe8={'count':0x0,'rows':[]};var _0x2ba413=_[_0x2a4c('0x3b')](db[_0x2a4c('0x44')][_0x2a4c('0x45')],function(_0x19bcad){return{'name':_0x19bcad['fieldName'],'type':_0x19bcad[_0x2a4c('0x46')]['key']};});_0x2eab91[_0x2a4c('0x47')]=_[_0x2a4c('0x48')](_[_0x2a4c('0x3b')](_0x2ba413,_0x2a4c('0x41')),['password',_0x2a4c('0x49')]);_0x2eab91[_0x2a4c('0x4a')]=_[_0x2a4c('0x4b')](_0x486fe6['query']);_0x2eab91[_0x2a4c('0x4c')]=_[_0x2a4c('0x4d')](_0x2eab91[_0x2a4c('0x47')],_0x2eab91[_0x2a4c('0x4a')]);_0x3f0078['attributes']=_[_0x2a4c('0x4d')](_0x2eab91['model'],qs[_0x2a4c('0x4e')](_0x486fe6[_0x2a4c('0x4a')][_0x2a4c('0x4e')]));_0x3f0078[_0x2a4c('0x4f')]=_0x3f0078['attributes']['length']?_0x3f0078[_0x2a4c('0x4f')]:_0x2eab91['model'];if(!_0x486fe6['query'][_0x2a4c('0x50')](_0x2a4c('0x51'))){_0x3f0078['limit']=qs[_0x2a4c('0x2d')](_0x486fe6[_0x2a4c('0x4a')][_0x2a4c('0x2d')]);_0x3f0078[_0x2a4c('0x2c')]=qs['offset'](_0x486fe6[_0x2a4c('0x4a')]['offset']);}_0x3f0078['order']=qs['sort'](_0x486fe6['query'][_0x2a4c('0x52')]);_0x3f0078[_0x2a4c('0x53')]=qs[_0x2a4c('0x4c')](_[_0x2a4c('0x54')](_0x486fe6[_0x2a4c('0x4a')],_0x2eab91[_0x2a4c('0x4c')]),_0x2ba413);if(_0x486fe6[_0x2a4c('0x4a')][_0x2a4c('0x3a')]){_0x3f0078[_0x2a4c('0x53')]=_[_0x2a4c('0x55')](_0x3f0078['where'],{'$or':_[_0x2a4c('0x3b')](_0x2ba413,function(_0x133ca7){if(_0x133ca7[_0x2a4c('0x46')]!==_0x2a4c('0x56')){return db[_0x2a4c('0x57')][_0x2a4c('0x53')](db['sequelize']['fn']('lower',db[_0x2a4c('0x57')][_0x2a4c('0x58')](_0x133ca7[_0x2a4c('0x41')])),{'$like':db[_0x2a4c('0x57')]['fn']('lower','%'+_0x486fe6[_0x2a4c('0x4a')][_0x2a4c('0x3a')]+'%')});}})});}_0x3f0078=_[_0x2a4c('0x55')]({},_0x3f0078,_0x486fe6[_0x2a4c('0x59')]);var _0x17a332={'where':_0x3f0078[_0x2a4c('0x53')]};return db[_0x2a4c('0x44')][_0x2a4c('0x2b')](_0x17a332)['then'](function(_0x5e67d8){_0x2f8fe8[_0x2a4c('0x2b')]=_0x5e67d8;if(_0x486fe6['query'][_0x2a4c('0x5a')]){_0x3f0078[_0x2a4c('0x5b')]=[{'all':!![]}];}return db['User'][_0x2a4c('0x5c')](_0x3f0078);})[_0x2a4c('0x33')](function(_0x2205e9){_0x2f8fe8[_0x2a4c('0x5d')]=_0x2205e9;return _0x2f8fe8;})[_0x2a4c('0x33')](respondWithFilteredResult(_0x308698,_0x3f0078))[_0x2a4c('0x5e')](handleError(_0x308698,null));};exports[_0x2a4c('0x5f')]=function(_0x148787,_0x566a93){var _0xe1c829={'raw':![],'where':{'id':_0x148787['params']['id']}},_0x51452a={};_0x51452a['model']=_[_0x2a4c('0x48')](_['keys'](db[_0x2a4c('0x44')][_0x2a4c('0x45')]),[_0x2a4c('0x60'),'salt']);_0x51452a['query']=_[_0x2a4c('0x4b')](_0x148787[_0x2a4c('0x4a')]);_0x51452a[_0x2a4c('0x4c')]=_[_0x2a4c('0x4d')](_0x51452a['model'],_0x51452a[_0x2a4c('0x4a')]);_0xe1c829[_0x2a4c('0x4f')]=_[_0x2a4c('0x4d')](_0x51452a[_0x2a4c('0x47')],qs[_0x2a4c('0x4e')](_0x148787['query'][_0x2a4c('0x4e')]));_0xe1c829['attributes']=_0xe1c829[_0x2a4c('0x4f')][_0x2a4c('0x61')]?_0xe1c829[_0x2a4c('0x4f')]:_0x51452a[_0x2a4c('0x47')];if(_0x148787[_0x2a4c('0x4a')][_0x2a4c('0x5a')]){_0xe1c829[_0x2a4c('0x5b')]=[{'all':!![]}];}_0xe1c829=_[_0x2a4c('0x55')]({},_0xe1c829,_0x148787[_0x2a4c('0x59')]);return db['User'][_0x2a4c('0x62')](_0xe1c829)[_0x2a4c('0x33')](handleEntityNotFound(_0x566a93,null))[_0x2a4c('0x33')](respondWithResult(_0x566a93,null))[_0x2a4c('0x5e')](handleError(_0x566a93,null));};exports[_0x2a4c('0x32')]=function(_0x446d5e,_0x44ca34){if(_0x446d5e[_0x2a4c('0x63')]['id']){delete _0x446d5e[_0x2a4c('0x63')]['id'];}delete _0x446d5e[_0x2a4c('0x63')]['role'];return db[_0x2a4c('0x44')]['find']({'where':{'id':_0x446d5e[_0x2a4c('0x64')]['id']}})[_0x2a4c('0x33')](handleEntityNotFound(_0x44ca34,null))[_0x2a4c('0x33')](saveUpdates(_0x446d5e[_0x2a4c('0x63')],null))[_0x2a4c('0x33')](respondWithResult(_0x44ca34,null))[_0x2a4c('0x5e')](handleError(_0x44ca34,null));};exports['describe']=function(_0x109357,_0x284d7c){return db[_0x2a4c('0x44')][_0x2a4c('0x65')]()[_0x2a4c('0x33')](respondWithResult(_0x284d7c,null))[_0x2a4c('0x5e')](handleError(_0x284d7c,null));};exports[_0x2a4c('0x66')]=function(_0x20951e,_0x7f06b0,_0x1b5b88){return db[_0x2a4c('0x44')]['find']({'where':{'id':_0x20951e[_0x2a4c('0x64')]['id']}})[_0x2a4c('0x33')](handleEntityNotFound(_0x7f06b0,null))['then'](function(_0x3844df){if(_0x3844df){return _0x3844df['addContacts'](_0x20951e[_0x2a4c('0x63')]['ids'],_[_0x2a4c('0x67')](_0x20951e[_0x2a4c('0x63')],['ids','id'])||{});}})['then'](respondWithResult(_0x7f06b0,null))['catch'](handleError(_0x7f06b0,null));};function validateUser(_0x184345){return new BPromise(function(_0x4d64bb,_0x1c2896){if(_0x184345[_0x2a4c('0x68')])return _0x4d64bb(_0x184345);return db['Setting'][_0x2a4c('0x69')](0x1)[_0x2a4c('0x33')](function(_0x5abf4b){if(_0x5abf4b[_0x2a4c('0x6a')])authService['validatePasswordPattern'](_0x184345[_0x2a4c('0x60')]);db[_0x2a4c('0x44')][_0x2a4c('0x6b')](_0x2a4c('0x68'))[_0x2a4c('0x33')](function(_0x5a316c){if(_[_0x2a4c('0x6c')](_0x5a316c)){_0x184345[_0x2a4c('0x68')]=_0x5abf4b[_0x2a4c('0x6d')]||0x1;return;}if(_[_0x2a4c('0x6c')](_0x5abf4b['min_internal'])||_0x5abf4b[_0x2a4c('0x6d')]===_0x5a316c){_0x184345['internal']=_0x5a316c+0x1;return;}if(_0x5abf4b[_0x2a4c('0x6d')]>_0x5a316c){_0x184345[_0x2a4c('0x68')]=_0x5abf4b[_0x2a4c('0x6d')];return;}return db[_0x2a4c('0x57')][_0x2a4c('0x4a')](_0x2a4c('0x6e'),{'type':db[_0x2a4c('0x57')][_0x2a4c('0x6f')][_0x2a4c('0x70')]})[_0x2a4c('0x33')](function(_0x4afe5b){if(_0x4afe5b&&_0x4afe5b[_0x2a4c('0x61')]){for(var _0x10abd2=0x0,_0x36acd7=_0x4afe5b[_0x2a4c('0x61')];_0x10abd2<_0x36acd7&&_[_0x2a4c('0x6c')](_0x184345[_0x2a4c('0x68')]);_0x10abd2++){if(_0x5abf4b['min_internal']<=_0x4afe5b[_0x10abd2][_0x2a4c('0x71')]){_0x184345['internal']=_0x4afe5b[_0x10abd2]['from'];}else if(_0x5abf4b[_0x2a4c('0x6d')]>_0x4afe5b[_0x10abd2][_0x2a4c('0x71')]&&_0x5abf4b[_0x2a4c('0x6d')]<=_0x4afe5b[_0x10abd2]['to']){_0x184345['internal']=_0x5abf4b[_0x2a4c('0x6d')];}}}if(_[_0x2a4c('0x6c')](_0x184345[_0x2a4c('0x68')])){_0x184345['internal']=_0x5a316c+0x1;}return _0x4d64bb(_0x184345);});});})['catch'](function(_0x2cbddc){_0x1c2896(_0x2cbddc);});});}function updateUser(_0x246dc1){return new BPromise(function(_0x3c3520,_0x5a0742){try{if(_0x246dc1[_0x2a4c('0x72')]){_0x246dc1['mailbox']=_0x246dc1['internal'];_0x246dc1['VoiceMail']={'mailbox':_0x246dc1['internal'],'password':_0x246dc1['password'],'fullname':_0x246dc1[_0x2a4c('0x73')],'email':_0x246dc1[_0x2a4c('0x74')]};}if(_0x246dc1[_0x2a4c('0x3e')]==='agent'){if(!_0x246dc1[_0x2a4c('0x75')])_0x246dc1[_0x2a4c('0x75')]=[_0x2a4c('0x76'),_0x2a4c('0x77'),'103',_0x2a4c('0x78'),_0x2a4c('0x79'),_0x2a4c('0x7a'),'105',_0x2a4c('0x7b'),_0x2a4c('0x7c'),_0x2a4c('0x7d'),_0x2a4c('0x7e'),'100',_0x2a4c('0x7f'),'114'];}_0x3c3520(_0x246dc1);}catch(_0x122906){_0x5a0742(_0x122906);}});}exports[_0x2a4c('0x80')]=function(_0x53f31b,_0x452f5b){if(_0x53f31b[_0x2a4c('0x81')]['role']==='agent')throw new Error(_0x2a4c('0x82'));if(_0x53f31b[_0x2a4c('0x63')][_0x2a4c('0x3e')]===_0x2a4c('0x81')&&_0x53f31b[_0x2a4c('0x81')][_0x2a4c('0x3e')]!==_0x2a4c('0x36')){throw new Error(_0x2a4c('0x83'));}if(_0x53f31b[_0x2a4c('0x63')][_0x2a4c('0x3e')]===_0x2a4c('0x36')&&_0x53f31b['user'][_0x2a4c('0x3e')]!=='admin'){throw new Error(_0x2a4c('0x84'));}return licenseUtil[_0x2a4c('0x85')]([_0x53f31b[_0x2a4c('0x63')]])[_0x2a4c('0x33')](function(){return validateUser(_0x53f31b[_0x2a4c('0x63')]);})[_0x2a4c('0x33')](function(_0x5f3af1){return updateUser(_0x5f3af1)['then'](function(_0x4bef5f){if(_0x4bef5f[_0x2a4c('0x3e')]===_0x2a4c('0x36')){_0x4bef5f[_0x2a4c('0x86')]=_0x53f31b[_0x2a4c('0x81')][_0x2a4c('0x86')];delete _0x4bef5f[_0x2a4c('0x87')];}return _0x4bef5f;});})[_0x2a4c('0x33')](function(_0x28ac92){return db[_0x2a4c('0x44')][_0x2a4c('0x80')](_0x28ac92,{'include':[{'model':db[_0x2a4c('0x88')],'as':_0x2a4c('0x88')}]});})[_0x2a4c('0x33')](function(_0x39bb89){if(_0x53f31b[_0x2a4c('0x63')][_0x2a4c('0x3e')]===_0x2a4c('0x81'))return _0x39bb89;if(_0x53f31b[_0x2a4c('0x81')][_0x2a4c('0x3e')]!=='user')return _0x39bb89;return db[_0x2a4c('0x89')][_0x2a4c('0x62')]({'where':{'name':_0x39bb89['role']===_0x2a4c('0x38')?_0x2a4c('0x37'):_0x2a4c('0x8a'),'userProfileId':_0x53f31b[_0x2a4c('0x81')][_0x2a4c('0x87')]},'raw':!![]})[_0x2a4c('0x33')](function(_0x57df28){if(!_0x57df28||_0x57df28[_0x2a4c('0x8b')]!=0x0)return _0x39bb89;return db[_0x2a4c('0x3f')][_0x2a4c('0x80')]({'name':_0x39bb89[_0x2a4c('0x41')],'resourceId':_0x39bb89['id'],'type':_0x57df28[_0x2a4c('0x41')],'sectionId':_0x57df28['id']},{})[_0x2a4c('0x33')](function(){return _0x39bb89;});})[_0x2a4c('0x5e')](function(_0x1b38a4){logger[_0x2a4c('0x21')](_0x2a4c('0x8c'),_0x1b38a4);throw _0x1b38a4;});})[_0x2a4c('0x33')](respondWithResult(_0x452f5b,0xc9))['catch'](handleError(_0x452f5b,null));};exports[_0x2a4c('0x8d')]=function(_0x4e4f9e,_0x2e1ffb){var _0x202e16=_0x4e4f9e['body'];var _0x50c1c4=[];if(_0x4e4f9e['user']['role']==='agent')throw new Error('Unauthorized');if(_[_0x2a4c('0x8e')](_0x202e16,[_0x2a4c('0x3e'),'user'])&&_0x4e4f9e['user']['role']!==_0x2a4c('0x36')){throw new Error(_0x2a4c('0x83'));}if(_['some'](_0x202e16,[_0x2a4c('0x3e'),_0x2a4c('0x36')])&&_0x4e4f9e[_0x2a4c('0x81')][_0x2a4c('0x3e')]!==_0x2a4c('0x36')){throw new Error('Unauthorized.\x20You\x20must\x20be\x20an\x20administrator\x20in\x20order\x20to\x20create\x20an\x20administrator');}return licenseUtil['checkUserLimits'](_0x202e16)[_0x2a4c('0x33')](function(){return validateUser(_0x202e16[0x0]);})[_0x2a4c('0x33')](function(){for(var _0x16ad43=0x1;_0x16ad43<_0x202e16[_0x2a4c('0x61')];_0x16ad43++){var _0x3240ae=_0x202e16[_0x16ad43-0x1][_0x2a4c('0x68')];if(!_0x202e16[_0x16ad43][_0x2a4c('0x68')])_0x202e16[_0x16ad43]['internal']=_0x3240ae+0x1;_0x50c1c4[_0x2a4c('0x8f')](validateUser(_0x202e16[_0x16ad43]));}return BPromise[_0x2a4c('0x90')](_0x50c1c4);})[_0x2a4c('0x33')](function(){_0x50c1c4=[];for(var _0x2a7423=0x0;_0x2a7423<_0x202e16[_0x2a4c('0x61')];_0x2a7423++){_0x50c1c4[_0x2a4c('0x8f')](updateUser(_0x202e16[_0x2a7423]));}return BPromise[_0x2a4c('0x90')](_0x50c1c4);})[_0x2a4c('0x33')](function(){return BPromise[_0x2a4c('0x91')](_0x202e16,function(_0x5295da){return db[_0x2a4c('0x44')][_0x2a4c('0x80')](_0x5295da,{'include':[{'model':db[_0x2a4c('0x88')],'as':_0x2a4c('0x88')}]})[_0x2a4c('0x33')](function(_0x40dc03){_0x5295da['id']=_0x40dc03['id'];return _0x5295da;});});})[_0x2a4c('0x33')](function(_0x111c4c){if(_0x4e4f9e['body']['role']===_0x2a4c('0x81'))return _0x111c4c;if(_0x4e4f9e[_0x2a4c('0x81')][_0x2a4c('0x3e')]!=='user')return _0x111c4c;var _0x2cb13f=_[_0x2a4c('0x8e')](_0x111c4c,function(_0x249820){return _0x249820[_0x2a4c('0x3e')]===_0x2a4c('0x38')||_0x249820[_0x2a4c('0x3e')]===_0x2a4c('0x39');});if(!_0x2cb13f)return _0x111c4c;return db[_0x2a4c('0x89')][_0x2a4c('0x5c')]({'where':{'name':{'$or':[_0x2a4c('0x37'),'Telephones']},'userProfileId':_0x4e4f9e[_0x2a4c('0x81')][_0x2a4c('0x87')]},'raw':!![]})[_0x2a4c('0x33')](function(_0x419388){if(_[_0x2a4c('0x92')](_0x419388)||!_[_0x2a4c('0x8e')](_0x419388,[_0x2a4c('0x8b'),0x0]))return _0x111c4c;_0x50c1c4=[];var _0x335e04=_(_0x419388)[_0x2a4c('0x3b')](function(_0x4acacb){if(_0x4acacb[_0x2a4c('0x8b')]===0x1)return;return _0x4acacb['name']===_0x2a4c('0x37')?_0x2a4c('0x38'):_0x2a4c('0x39');})['compact']()['value']();for(var _0x3d69de=0x0;_0x3d69de<_0x111c4c[_0x2a4c('0x61')];_0x3d69de++){if(!_[_0x2a4c('0x3d')](_0x335e04,_0x111c4c[_0x3d69de][_0x2a4c('0x3e')]))return;var _0x402d50=_0x111c4c[_0x3d69de][_0x2a4c('0x3e')]===_0x2a4c('0x38')?_0x2a4c('0x37'):_0x2a4c('0x8a');_0x50c1c4['push'](db[_0x2a4c('0x3f')]['create']({'name':_0x111c4c[_0x3d69de][_0x2a4c('0x41')],'resourceId':_0x111c4c[_0x3d69de]['id'],'type':_0x402d50,'sectionId':_[_0x2a4c('0x62')](_0x419388,[_0x2a4c('0x41'),_0x402d50])['id']},{}));}return BPromise[_0x2a4c('0x90')](_0x50c1c4);})[_0x2a4c('0x33')](respondWithResult(_0x2e1ffb,0xc9))[_0x2a4c('0x5e')](handleError(_0x2e1ffb,null));});};exports[_0x2a4c('0x93')]=function(_0x389338,_0x15ab1d,_0x43af90){if(_0x389338[_0x2a4c('0x63')]['id']){delete _0x389338[_0x2a4c('0x63')]['id'];}return db['User']['find']({'where':{'id':_0x389338['params']['id']}})[_0x2a4c('0x33')](function(_0x7d81fe){if(!_0x7d81fe)return null;if(_0x7d81fe['id']===_0x389338[_0x2a4c('0x81')]['id']){if(!_0x389338[_0x2a4c('0x63')][_0x2a4c('0x94')]||!_0x389338['body']['newPassword']){throw new db[(_0x2a4c('0x95'))]['ValidationError']('Invalid\x20body\x20format.\x20Use\x20oldPassword\x20and\x20newPassword');}if(!_0x7d81fe[_0x2a4c('0x96')](_0x389338['body'][_0x2a4c('0x94')])){throw new db[(_0x2a4c('0x95'))][(_0x2a4c('0x97'))](_0x2a4c('0x98'));}if(_0x389338['body'][_0x2a4c('0x94')]===_0x389338['body'][_0x2a4c('0x99')]){throw new db['Sequelize'][(_0x2a4c('0x97'))](_0x2a4c('0x9a'));}}else if(_0x389338['user'][_0x2a4c('0x3e')]==='admin'){if(!_0x389338[_0x2a4c('0x63')]['newPassword']){throw new db['Sequelize'][(_0x2a4c('0x97'))](_0x2a4c('0x9b'));}}else if(_0x389338['user'][_0x2a4c('0x3e')]===_0x2a4c('0x81')){if(!_0x389338[_0x2a4c('0x63')][_0x2a4c('0x99')]){throw new db['Sequelize'][(_0x2a4c('0x97'))](_0x2a4c('0x9b'));}if(_0x7d81fe['role']!==_0x2a4c('0x38')){throw new db[(_0x2a4c('0x95'))]['ValidationError'](_0x2a4c('0x82'));}}else{throw new db[(_0x2a4c('0x95'))][(_0x2a4c('0x97'))](_0x2a4c('0x82'));}return _0x7d81fe;})[_0x2a4c('0x33')](handleEntityNotFound(_0x15ab1d,null))[_0x2a4c('0x33')](function(_0x1596c2){return db[_0x2a4c('0x9c')]['findOne']({'attributes':['id',_0x2a4c('0x6a'),_0x2a4c('0x9d'),'passwordHistoryLimit']})['then'](function(_0x14b29f){if(_0x14b29f['securePassword'])authService[_0x2a4c('0x9e')](_0x389338[_0x2a4c('0x63')][_0x2a4c('0x99')]);if(!_0x14b29f[_0x2a4c('0x9d')]||!_0x1596c2[_0x2a4c('0x9f')])return _0x1596c2;authService[_0x2a4c('0xa0')](_0x389338[_0x2a4c('0x63')][_0x2a4c('0x99')],_0x1596c2[_0x2a4c('0x9f')],_0x14b29f[_0x2a4c('0xa1')]);return _0x1596c2;})[_0x2a4c('0x33')](saveUpdates({'password':_0x389338['body']['newPassword'],'passwordResetAt':_0x389338['user']['id']==_0x389338[_0x2a4c('0x64')]['id']?moment():null,'previousPasswords':authService[_0x2a4c('0xa2')](_0x389338[_0x2a4c('0x63')][_0x2a4c('0x99')],_0x1596c2[_0x2a4c('0x9f')])},null));})[_0x2a4c('0x33')](respondWithResult(_0x15ab1d,null))[_0x2a4c('0x5e')](handleError(_0x15ab1d,null));};exports[_0x2a4c('0xa3')]=function(_0x273d31,_0x2b95ce,_0x2aadbc){var _0x19fd48=_0x273d31[_0x2a4c('0x63')][_0x2a4c('0xa4')];return db[_0x2a4c('0x44')][_0x2a4c('0x62')]({'where':{'id':_0x273d31[_0x2a4c('0x64')]['id']},'attributes':['id',_0x2a4c('0x41'),'role',_0x2a4c('0xa5'),_0x2a4c('0xa6'),'voicePause','interface']})[_0x2a4c('0x33')](handleEntityNotFound(_0x2b95ce,null))[_0x2a4c('0x33')](function(_0x1e5354){if(_0x1e5354){if(!utils[_0x2a4c('0xa7')](_0x19fd48)){throw new db[(_0x2a4c('0x95'))][(_0x2a4c('0x97'))](_0x2a4c('0xa8'));}return _0x1e5354[_0x2a4c('0xa9')+_[_0x2a4c('0xaa')](_0x19fd48[_0x2a4c('0xab')]())+'Queues'](_0x273d31['body'][_0x2a4c('0xac')],{'penalty':_0x273d31[_0x2a4c('0x63')][_0x2a4c('0xad')]||0x0})[_0x2a4c('0xae')](function(_0x32f2c3){for(var _0x5f4487=0x0;_0x5f4487<_0x273d31[_0x2a4c('0x63')][_0x2a4c('0xac')]['length'];_0x5f4487+=0x1){var _0x597126={'UserId':_0x273d31[_0x2a4c('0x64')]['id']};_0x597126[_[_0x2a4c('0xaa')](_0x19fd48[_0x2a4c('0xab')]())+_0x2a4c('0xaf')]=_0x273d31[_0x2a4c('0x63')][_0x2a4c('0xac')][_0x5f4487];socket[_0x2a4c('0xb0')]('user'+_[_0x2a4c('0xaa')](_0x19fd48[_0x2a4c('0xab')]())+'Queue:save',_0x597126);}return _0x32f2c3;})[_0x2a4c('0x33')](function(){if(_0x19fd48===_0x2a4c('0xb1')){return db[_0x2a4c('0xb2')][_0x2a4c('0x5c')]({'where':{'id':_0x273d31[_0x2a4c('0x63')][_0x2a4c('0xac')]||[]},'raw':!![],'attributes':['id',_0x2a4c('0x41')]});}})['then'](function(_0x3ad766){var _0x38ac9a=_0x1e5354[_0x2a4c('0x35')]({'plain':!![]});var _0x322fa=[];if(_0x19fd48===_0x2a4c('0xb1')&&_0x38ac9a[_0x2a4c('0x3e')]===_0x2a4c('0x38')&&_0x38ac9a[_0x2a4c('0xa5')]){for(var _0x4c4143=0x0;_0x4c4143<_0x3ad766[_0x2a4c('0x61')];_0x4c4143+=0x1){_0x322fa[_0x2a4c('0x8f')]({'membername':_0x38ac9a[_0x2a4c('0x41')],'UserId':_0x38ac9a['id'],'queue_name':_0x3ad766[_0x4c4143][_0x2a4c('0x41')],'VoiceQueueId':_0x3ad766[_0x4c4143]['id'],'interface':_[_0x2a4c('0x6c')](_0x38ac9a[_0x2a4c('0xb3')])?util[_0x2a4c('0xb4')](_0x2a4c('0xb5'),_0x38ac9a[_0x2a4c('0x41')]):_0x38ac9a[_0x2a4c('0xb3')],'paused':_0x38ac9a['voicePause']||![],'penalty':_0x273d31[_0x2a4c('0x63')][_0x2a4c('0xad')]||0x0});}return BPromise[_0x2a4c('0x91')](_0x322fa,function(_0x3aba6f){return db[_0x2a4c('0xb6')][_0x2a4c('0xb7')](_0x3aba6f);});}return _0x1e5354;});}})[_0x2a4c('0x33')](respondWithStatusCode(_0x2b95ce,null))[_0x2a4c('0x5e')](handleError(_0x2b95ce,null));};exports[_0x2a4c('0xb8')]=function(_0x23e43d,_0xfea979,_0x34598f){var _0x5b1401;return db[_0x2a4c('0x44')][_0x2a4c('0x62')]({'where':{'id':_0x23e43d[_0x2a4c('0x64')]['id']},'attributes':['id','name',_0x2a4c('0x3e')]})[_0x2a4c('0x33')](handleEntityNotFound(_0xfea979,null))[_0x2a4c('0x33')](function(_0x49f625){if(_0x49f625){_0x5b1401=_0x49f625;if(!_0x23e43d['query']['channel']||!utils['isValidChannel'](_0x23e43d[_0x2a4c('0x4a')][_0x2a4c('0xa4')])){throw new db[(_0x2a4c('0x95'))][(_0x2a4c('0x97'))](_0x2a4c('0xa8'));}return _0x49f625[_0x2a4c('0xb9')+_[_0x2a4c('0xaa')](_0x23e43d[_0x2a4c('0x4a')][_0x2a4c('0xa4')][_0x2a4c('0xab')]())+_0x2a4c('0xba')](_0x23e43d[_0x2a4c('0x4a')]['ids']);}})[_0x2a4c('0x33')](function(_0x9a1313){for(var _0x5ee07f=0x0;_0x5ee07f<_0x23e43d[_0x2a4c('0x4a')]['ids'][_0x2a4c('0x61')];_0x5ee07f+=0x1){var _0x571b4d={'UserId':_0x23e43d[_0x2a4c('0x64')]['id']};_0x571b4d[_['capitalize'](_0x23e43d[_0x2a4c('0x4a')][_0x2a4c('0xa4')][_0x2a4c('0xab')]())+'QueueId']=_0x23e43d['query'][_0x2a4c('0xac')][_0x5ee07f];socket[_0x2a4c('0xb0')](_0x2a4c('0x81')+_[_0x2a4c('0xaa')](_0x23e43d[_0x2a4c('0x4a')][_0x2a4c('0xa4')][_0x2a4c('0xab')]())+_0x2a4c('0xbb'),_0x571b4d);}return _0x9a1313;})['then'](function(){if(_0x23e43d[_0x2a4c('0x4a')][_0x2a4c('0xa4')]===_0x2a4c('0xb1')){return db[_0x2a4c('0xb6')][_0x2a4c('0x34')]({'where':{'UserId':_0x23e43d[_0x2a4c('0x64')]['id'],'VoiceQueueId':_0x23e43d[_0x2a4c('0x4a')][_0x2a4c('0xac')]},'individualHooks':!![]})[_0x2a4c('0x33')](function(){return _0x5b1401;});}return _0x5b1401;})['then'](respondWithStatusCode(_0xfea979,null))[_0x2a4c('0x5e')](handleError(_0xfea979,null));};exports['addAvatar']=function(_0x44d1ba,_0x2be84f,_0x132e29){_0x44d1ba[_0x2a4c('0x63')][_0x2a4c('0xbc')]=_0x44d1ba['file'][_0x2a4c('0xbd')];return db[_0x2a4c('0x44')][_0x2a4c('0x62')]({'where':{'id':_0x44d1ba[_0x2a4c('0x64')]['id']}})[_0x2a4c('0x33')](handleEntityNotFound(_0x2be84f,null))['then'](saveUpdates(_0x44d1ba[_0x2a4c('0x63')],null))[_0x2a4c('0x33')](respondWithResult(_0x2be84f,null))[_0x2a4c('0x5e')](handleError(_0x2be84f,null));};exports[_0x2a4c('0xbe')]=function(_0x228249,_0xdb9305,_0xf33a77){var _0x36848f=path[_0x2a4c('0xbf')](config['root'],'server/files/images/logos/default_profile.png');return db[_0x2a4c('0x44')]['find']({'where':{'id':_0x228249[_0x2a4c('0x64')]['id']},'attributes':['id',_0x2a4c('0xbc')],'raw':!![]})['then'](handleEntityNotFound(_0xdb9305,null))['then'](function(_0x10f3b4){if(_0x10f3b4){if(_['isNil'](_0x10f3b4[_0x2a4c('0xbc')])){return _0xdb9305['download'](_0x36848f);}else{if(!fs['existsSync'](path[_0x2a4c('0xbf')](config[_0x2a4c('0xc0')],_0x2a4c('0xc1'),_0x10f3b4[_0x2a4c('0xbc')]))){return _0xdb9305['download'](_0x36848f);}return _0xdb9305[_0x2a4c('0xc2')](path[_0x2a4c('0xbf')](config['root'],_0x2a4c('0xc1'),_0x10f3b4['userpic']));}}})[_0x2a4c('0x5e')](handleError(_0xdb9305,null));};exports['getContacts']=function(_0x377687,_0x50ea26,_0x3c6e49){var _0x49f3b7={};var _0x41ba74={};var _0x5a8f9e;var _0x401d64;return db[_0x2a4c('0x44')][_0x2a4c('0xc3')]({'where':{'id':_0x377687[_0x2a4c('0x64')]['id']}})[_0x2a4c('0x33')](handleEntityNotFound(_0x50ea26,null))['then'](function(_0x298fcf){if(_0x298fcf){_0x5a8f9e=_0x298fcf;_0x41ba74['model']=_[_0x2a4c('0x4b')](db[_0x2a4c('0xc4')][_0x2a4c('0x45')]);_0x41ba74[_0x2a4c('0x4a')]=_[_0x2a4c('0x4b')](_0x377687['query']);_0x41ba74[_0x2a4c('0x4c')]=_[_0x2a4c('0x4d')](_0x41ba74[_0x2a4c('0x47')],_0x41ba74[_0x2a4c('0x4a')]);_0x49f3b7[_0x2a4c('0x4f')]=_[_0x2a4c('0x4d')](_0x41ba74['model'],qs[_0x2a4c('0x4e')](_0x377687[_0x2a4c('0x4a')]['fields']));_0x49f3b7['attributes']=_0x49f3b7[_0x2a4c('0x4f')][_0x2a4c('0x61')]?_0x49f3b7['attributes']:_0x41ba74[_0x2a4c('0x47')];_0x49f3b7[_0x2a4c('0xc5')]=qs['sort'](_0x377687[_0x2a4c('0x4a')][_0x2a4c('0x52')]);_0x49f3b7[_0x2a4c('0x53')]=qs['filters'](_['pick'](_0x377687[_0x2a4c('0x4a')],_0x41ba74[_0x2a4c('0x4c')]));if(_0x377687[_0x2a4c('0x4a')][_0x2a4c('0x3a')]){_0x49f3b7[_0x2a4c('0x53')]=_[_0x2a4c('0x55')](_0x49f3b7['where'],{'$or':_[_0x2a4c('0x3b')](_0x49f3b7['attributes'],function(_0x237282){var _0x8017e={};_0x8017e[_0x237282]={'$like':'%'+_0x377687[_0x2a4c('0x4a')][_0x2a4c('0x3a')]+'%'};return _0x8017e;})});}_0x49f3b7=_[_0x2a4c('0x55')]({},_0x49f3b7,_0x377687['options']);return _0x5a8f9e[_0x2a4c('0xc6')](_0x49f3b7);}})[_0x2a4c('0x33')](function(_0x5a38b2){if(_0x5a38b2){_0x401d64=_0x5a38b2[_0x2a4c('0x61')];if(_0x377687[_0x2a4c('0x4a')][_0x2a4c('0x50')]('includeAll')){_0x49f3b7[_0x2a4c('0x5b')]=[{'model':db['CmList'],'as':_0x2a4c('0xc7'),'required':![]},{'model':db[_0x2a4c('0xc8')],'as':_0x2a4c('0xc9'),'attributes':['id',_0x2a4c('0x41'),_0x2a4c('0xca')],'where':_0x377687[_0x2a4c('0x4a')][_0x2a4c('0xcb')]?{'id':_0x377687[_0x2a4c('0x4a')][_0x2a4c('0xcb')]}:undefined,'required':_0x377687[_0x2a4c('0x4a')][_0x2a4c('0xcb')]?!![]:![]}];}if(!_0x377687[_0x2a4c('0x4a')][_0x2a4c('0x50')](_0x2a4c('0x51'))){_0x49f3b7['limit']=qs[_0x2a4c('0x2d')](_0x377687['query'][_0x2a4c('0x2d')]);_0x49f3b7[_0x2a4c('0x2c')]=qs[_0x2a4c('0x2c')](_0x377687[_0x2a4c('0x4a')]['offset']);}return _0x5a8f9e[_0x2a4c('0xc6')](_0x49f3b7);}})[_0x2a4c('0x33')](function(_0x4886b7){if(_0x4886b7){return _0x4886b7?{'count':_0x401d64,'rows':_0x4886b7}:null;}})[_0x2a4c('0x33')](respondWithResult(_0x50ea26,null))['catch'](handleError(_0x50ea26,null));};exports[_0x2a4c('0xcc')]=function(_0x2491dd,_0x1ee943,_0x157994){var _0x50ace6;var _0x302cc9;var _0x525ca4={};var _0x523915;return db['User'][_0x2a4c('0xc3')]({'where':{'id':_0x2491dd[_0x2a4c('0x64')]['id']},'attributes':['id',_0x2a4c('0x41'),_0x2a4c('0x3e')]})[_0x2a4c('0x33')](handleEntityNotFound(_0x1ee943,null))[_0x2a4c('0x33')](function(_0xd697f0){if(!utils['isValidChannel'](_0x2491dd['query'][_0x2a4c('0xa4')])){throw new db['Sequelize']['ValidationError']('Unknown\x20channel');}_0x50ace6=_0xd697f0;var _0x32bb8d={};_0x32bb8d[_0x2a4c('0x47')]=_['keys'](db[_[_0x2a4c('0xaa')](_0x2491dd[_0x2a4c('0x4a')][_0x2a4c('0xa4')])+'Queue'][_0x2a4c('0x45')]);_0x32bb8d['query']=_[_0x2a4c('0x4b')](_0x2491dd['query']);_0x32bb8d[_0x2a4c('0x4c')]=_[_0x2a4c('0x4d')](_0x32bb8d[_0x2a4c('0x47')],_0x32bb8d[_0x2a4c('0x4a')]);_0x525ca4[_0x2a4c('0x4f')]=_['intersection'](_0x32bb8d['model'],qs[_0x2a4c('0x4e')](_0x2491dd[_0x2a4c('0x4a')][_0x2a4c('0x4e')]));_0x525ca4[_0x2a4c('0x4f')]=_0x525ca4[_0x2a4c('0x4f')][_0x2a4c('0x61')]?_0x525ca4[_0x2a4c('0x4f')]:_0x32bb8d[_0x2a4c('0x47')];_0x525ca4['order']=qs[_0x2a4c('0x52')](_0x2491dd[_0x2a4c('0x4a')][_0x2a4c('0x52')]);_0x525ca4[_0x2a4c('0x53')]=qs[_0x2a4c('0x4c')](_[_0x2a4c('0x54')](_0x2491dd['query'],_0x32bb8d[_0x2a4c('0x4c')]));if(_0x2491dd['query'][_0x2a4c('0x3a')]){_0x525ca4[_0x2a4c('0x53')]=_[_0x2a4c('0x55')](_0x525ca4[_0x2a4c('0x53')],{'$or':_[_0x2a4c('0x3b')](_0x525ca4[_0x2a4c('0x4f')],function(_0x3a4287){var _0x1c8769={};_0x1c8769[_0x3a4287]={'$like':'%'+_0x2491dd[_0x2a4c('0x4a')]['filter']+'%'};return _0x1c8769;})});}_0x525ca4=_[_0x2a4c('0x55')]({},_0x525ca4,_0x2491dd[_0x2a4c('0x59')]);switch(_0x50ace6[_0x2a4c('0x3e')]){case'admin':return db[_[_0x2a4c('0xaa')](_0x2491dd['query'][_0x2a4c('0xa4')])+_0x2a4c('0xcd')][_0x2a4c('0x5c')](_0x525ca4);case _0x2a4c('0x81'):case'agent':return _0x50ace6[_0x2a4c('0x35')+_[_0x2a4c('0xaa')](_0x2491dd[_0x2a4c('0x4a')]['channel'])+_0x2a4c('0xba')](_0x525ca4);default:throw new db[(_0x2a4c('0x95'))][(_0x2a4c('0x97'))](_0x2a4c('0xce'));}})[_0x2a4c('0x33')](function(_0x3cdcaf){_0x523915=_0x3cdcaf['length'];if(!_0x2491dd['query'][_0x2a4c('0x50')]('nolimit')){_0x525ca4['limit']=qs[_0x2a4c('0x2d')](_0x2491dd[_0x2a4c('0x4a')][_0x2a4c('0x2d')]);_0x525ca4[_0x2a4c('0x2c')]=qs[_0x2a4c('0x2c')](_0x2491dd[_0x2a4c('0x4a')][_0x2a4c('0x2c')]);}switch(_0x50ace6[_0x2a4c('0x3e')]){case _0x2a4c('0x36'):return db[_[_0x2a4c('0xaa')](_0x2491dd[_0x2a4c('0x4a')][_0x2a4c('0xa4')])+_0x2a4c('0xcd')][_0x2a4c('0x5c')](_0x525ca4);case _0x2a4c('0x81'):case _0x2a4c('0x38'):return _0x50ace6[_0x2a4c('0x35')+_[_0x2a4c('0xaa')](_0x2491dd['query'][_0x2a4c('0xa4')])+_0x2a4c('0xba')](_0x525ca4);}})['then'](function(_0x1cb290){return{'count':_0x523915,'rows':_0x1cb290};})['then'](respondWithResult(_0x1ee943,null))['catch'](handleError(_0x1ee943,null));};exports[_0x2a4c('0xcf')]=function(_0x71b3d6,_0x511793,_0x1eddb8){var _0x41bb03={};var _0x594f1c={};var _0x52aa4f;var _0x2b2d4c;return db[_0x2a4c('0x44')]['findOne']({'where':{'id':_0x71b3d6[_0x2a4c('0x64')]['id']}})[_0x2a4c('0x33')](handleEntityNotFound(_0x511793,null))[_0x2a4c('0x33')](function(_0x55b2d1){if(_0x55b2d1){_0x52aa4f=_0x55b2d1;_0x594f1c[_0x2a4c('0x47')]=_['keys'](db[_0x2a4c('0xb6')]['rawAttributes']);_0x594f1c[_0x2a4c('0x4a')]=_[_0x2a4c('0x4b')](_0x71b3d6[_0x2a4c('0x4a')]);_0x594f1c[_0x2a4c('0x4c')]=_[_0x2a4c('0x4d')](_0x594f1c[_0x2a4c('0x47')],_0x594f1c[_0x2a4c('0x4a')]);_0x41bb03[_0x2a4c('0x4f')]=_['intersection'](_0x594f1c['model'],qs['fields'](_0x71b3d6[_0x2a4c('0x4a')][_0x2a4c('0x4e')]));_0x41bb03[_0x2a4c('0x4f')]=_0x41bb03['attributes']['length']?_0x41bb03['attributes']:_0x594f1c[_0x2a4c('0x47')];_0x41bb03[_0x2a4c('0xc5')]=qs[_0x2a4c('0x52')](_0x71b3d6[_0x2a4c('0x4a')][_0x2a4c('0x52')]);_0x41bb03[_0x2a4c('0x53')]=qs[_0x2a4c('0x4c')](_['pick'](_0x71b3d6[_0x2a4c('0x4a')],_0x594f1c[_0x2a4c('0x4c')]));if(_0x71b3d6[_0x2a4c('0x4a')]['filter']){_0x41bb03[_0x2a4c('0x53')]=_['merge'](_0x41bb03['where'],{'$or':_['map'](_0x41bb03[_0x2a4c('0x4f')],function(_0x431ed2){var _0x3b2769={};_0x3b2769[_0x431ed2]={'$like':'%'+_0x71b3d6[_0x2a4c('0x4a')][_0x2a4c('0x3a')]+'%'};return _0x3b2769;})});}_0x41bb03=_[_0x2a4c('0x55')]({},_0x41bb03,_0x71b3d6[_0x2a4c('0x59')]);return _0x52aa4f['getVoiceQueuesRt'](_0x41bb03);}})['then'](function(_0x1b10f8){if(_0x1b10f8){_0x2b2d4c=_0x1b10f8[_0x2a4c('0x61')];if(!_0x71b3d6[_0x2a4c('0x4a')][_0x2a4c('0x50')](_0x2a4c('0x51'))){_0x41bb03[_0x2a4c('0x2d')]=qs[_0x2a4c('0x2d')](_0x71b3d6[_0x2a4c('0x4a')][_0x2a4c('0x2d')]);_0x41bb03[_0x2a4c('0x2c')]=qs[_0x2a4c('0x2c')](_0x71b3d6['query'][_0x2a4c('0x2c')]);}return _0x52aa4f[_0x2a4c('0xcf')](_0x41bb03);}})['then'](function(_0x13f5ac){if(_0x13f5ac){return _0x13f5ac?{'count':_0x2b2d4c,'rows':_0x13f5ac}:null;}})[_0x2a4c('0x33')](respondWithResult(_0x511793,null))['catch'](handleError(_0x511793,null));};exports['getGroups']=function(_0x3bc796,_0x22d571,_0x29d663){var _0x44b57d={};var _0x4f6a9f={};var _0x4e881b;var _0x10e7b4;return db['User'][_0x2a4c('0xc3')]({'where':{'id':_0x3bc796['params']['id']}})[_0x2a4c('0x33')](handleEntityNotFound(_0x22d571,null))[_0x2a4c('0x33')](function(_0x31cccb){if(_0x31cccb){_0x4e881b=_0x31cccb;_0x4f6a9f['model']=_['keys'](db[_0x2a4c('0xd0')][_0x2a4c('0x45')]);_0x4f6a9f['query']=_[_0x2a4c('0x4b')](_0x3bc796[_0x2a4c('0x4a')]);_0x4f6a9f[_0x2a4c('0x4c')]=_[_0x2a4c('0x4d')](_0x4f6a9f[_0x2a4c('0x47')],_0x4f6a9f[_0x2a4c('0x4a')]);_0x44b57d['attributes']=_[_0x2a4c('0x4d')](_0x4f6a9f[_0x2a4c('0x47')],qs['fields'](_0x3bc796['query'][_0x2a4c('0x4e')]));_0x44b57d[_0x2a4c('0x4f')]=_0x44b57d[_0x2a4c('0x4f')]['length']?_0x44b57d[_0x2a4c('0x4f')]:_0x4f6a9f[_0x2a4c('0x47')];_0x44b57d[_0x2a4c('0xc5')]=qs[_0x2a4c('0x52')](_0x3bc796['query'][_0x2a4c('0x52')]);_0x44b57d['where']=qs[_0x2a4c('0x4c')](_[_0x2a4c('0x54')](_0x3bc796[_0x2a4c('0x4a')],_0x4f6a9f[_0x2a4c('0x4c')]));if(_0x3bc796[_0x2a4c('0x4a')]['filter']){_0x44b57d[_0x2a4c('0x53')]=_[_0x2a4c('0x55')](_0x44b57d['where'],{'$or':_['map'](_0x44b57d['attributes'],function(_0x385f1e){var _0x2c6f92={};_0x2c6f92[_0x385f1e]={'$like':'%'+_0x3bc796['query'][_0x2a4c('0x3a')]+'%'};return _0x2c6f92;})});}_0x44b57d=_[_0x2a4c('0x55')]({},_0x44b57d,_0x3bc796['options']);return _0x4e881b[_0x2a4c('0xd1')](_0x44b57d);}})[_0x2a4c('0x33')](function(_0xbd010){if(_0xbd010){_0x10e7b4=_0xbd010[_0x2a4c('0x61')];if(!_0x3bc796['query'][_0x2a4c('0x50')](_0x2a4c('0x51'))){_0x44b57d[_0x2a4c('0x2d')]=qs[_0x2a4c('0x2d')](_0x3bc796[_0x2a4c('0x4a')][_0x2a4c('0x2d')]);_0x44b57d[_0x2a4c('0x2c')]=qs[_0x2a4c('0x2c')](_0x3bc796[_0x2a4c('0x4a')][_0x2a4c('0x2c')]);}return _0x4e881b[_0x2a4c('0xd1')](_0x44b57d);}})[_0x2a4c('0x33')](function(_0x212a80){if(_0x212a80){return _0x212a80?{'count':_0x10e7b4,'rows':_0x212a80}:null;}})['then'](respondWithResult(_0x22d571,null))[_0x2a4c('0x5e')](handleError(_0x22d571,null));};exports[_0x2a4c('0xd2')]=function(_0x24dfcb,_0x215c36,_0x422da6){var _0xb34686={'raw':!![],'where':{}};var _0x5c13ac={};var _0x3f7146={'count':0x0,'rows':[]};return db[_0x2a4c('0x44')]['findOne']({'where':{'id':_0x24dfcb['params']['id']}})[_0x2a4c('0x33')](handleEntityNotFound(_0x215c36,null))[_0x2a4c('0x33')](function(_0x14580c){if(_0x14580c){_0x5c13ac[_0x2a4c('0x47')]=_[_0x2a4c('0x4b')](db[_0x2a4c('0xd3')][_0x2a4c('0x45')]);_0x5c13ac[_0x2a4c('0x4a')]=_[_0x2a4c('0x4b')](_0x24dfcb[_0x2a4c('0x4a')]);_0x5c13ac[_0x2a4c('0x4c')]=_['intersection'](_0x5c13ac[_0x2a4c('0x47')],_0x5c13ac[_0x2a4c('0x4a')]);_0xb34686[_0x2a4c('0x4f')]=_['intersection'](_0x5c13ac['model'],qs[_0x2a4c('0x4e')](_0x24dfcb[_0x2a4c('0x4a')][_0x2a4c('0x4e')]));_0xb34686[_0x2a4c('0x4f')]=_0xb34686[_0x2a4c('0x4f')][_0x2a4c('0x61')]?_0xb34686['attributes']:_0x5c13ac[_0x2a4c('0x47')];if(!_0x24dfcb[_0x2a4c('0x4a')][_0x2a4c('0x50')](_0x2a4c('0x51'))){_0xb34686[_0x2a4c('0x2d')]=qs[_0x2a4c('0x2d')](_0x24dfcb[_0x2a4c('0x4a')]['limit']);_0xb34686['offset']=qs['offset'](_0x24dfcb[_0x2a4c('0x4a')]['offset']);}_0xb34686['order']=qs[_0x2a4c('0x52')](_0x24dfcb[_0x2a4c('0x4a')][_0x2a4c('0x52')]);_0xb34686[_0x2a4c('0x53')]=qs['filters'](_[_0x2a4c('0x54')](_0x24dfcb[_0x2a4c('0x4a')],_0x5c13ac[_0x2a4c('0x4c')]));_0xb34686[_0x2a4c('0x53')][_0x2a4c('0xd4')]=_0x14580c['id'];if(_0x24dfcb['query']['filter']){_0xb34686[_0x2a4c('0x53')]=_['merge'](_0xb34686[_0x2a4c('0x53')],{'$or':_[_0x2a4c('0x3b')](_0xb34686['attributes'],function(_0x2b32e0){var _0x1e942b={};_0x1e942b[_0x2b32e0]={'$like':'%'+_0x24dfcb['query'][_0x2a4c('0x3a')]+'%'};return _0x1e942b;})});}_0xb34686=_[_0x2a4c('0x55')]({},_0xb34686,_0x24dfcb['options']);return db[_0x2a4c('0xd3')][_0x2a4c('0x2b')]({'where':_0xb34686['where']})[_0x2a4c('0x33')](function(_0x2f2a63){_0x3f7146['count']=_0x2f2a63;if(_0x24dfcb[_0x2a4c('0x4a')][_0x2a4c('0x5a')]){_0xb34686[_0x2a4c('0x5b')]=[{'all':!![]}];}return db[_0x2a4c('0xd3')][_0x2a4c('0x5c')](_0xb34686);})['then'](function(_0x14c5da){_0x3f7146[_0x2a4c('0x5d')]=_0x14c5da;return _0x3f7146;});}})['then'](respondWithFilteredResult(_0x215c36,_0xb34686))[_0x2a4c('0x5e')](handleError(_0x215c36,null));};exports[_0x2a4c('0xd5')]=function(_0x1f4d82,_0x1fab8a,_0x27c954){var _0x327705={'raw':!![],'where':{}};var _0x423945={};var _0xfebdb9={'count':0x0,'rows':[]};return db['User'][_0x2a4c('0xc3')]({'where':{'id':_0x1f4d82['params']['id']}})[_0x2a4c('0x33')](handleEntityNotFound(_0x1fab8a,null))[_0x2a4c('0x33')](function(_0x140421){if(_0x140421){_0x423945[_0x2a4c('0x47')]=_[_0x2a4c('0x4b')](db['ScreenRecording'][_0x2a4c('0x45')]);_0x423945['query']=_['keys'](_0x1f4d82[_0x2a4c('0x4a')]);_0x423945[_0x2a4c('0x4c')]=_[_0x2a4c('0x4d')](_0x423945[_0x2a4c('0x47')],_0x423945[_0x2a4c('0x4a')]);_0x327705['attributes']=_[_0x2a4c('0x4d')](_0x423945['model'],qs[_0x2a4c('0x4e')](_0x1f4d82[_0x2a4c('0x4a')][_0x2a4c('0x4e')]));_0x327705[_0x2a4c('0x4f')]=_0x327705[_0x2a4c('0x4f')][_0x2a4c('0x61')]?_0x327705[_0x2a4c('0x4f')]:_0x423945[_0x2a4c('0x47')];if(!_0x1f4d82['query'][_0x2a4c('0x50')](_0x2a4c('0x51'))){_0x327705[_0x2a4c('0x2d')]=qs[_0x2a4c('0x2d')](_0x1f4d82[_0x2a4c('0x4a')]['limit']);_0x327705['offset']=qs['offset'](_0x1f4d82[_0x2a4c('0x4a')]['offset']);}_0x327705[_0x2a4c('0xc5')]=qs[_0x2a4c('0x52')](_0x1f4d82[_0x2a4c('0x4a')][_0x2a4c('0x52')]);_0x327705[_0x2a4c('0x53')]=qs[_0x2a4c('0x4c')](_[_0x2a4c('0x54')](_0x1f4d82[_0x2a4c('0x4a')],_0x423945[_0x2a4c('0x4c')]));_0x327705['where'][_0x2a4c('0xd4')]=_0x140421['id'];if(_0x1f4d82[_0x2a4c('0x4a')][_0x2a4c('0x3a')]){_0x327705[_0x2a4c('0x53')]=_[_0x2a4c('0x55')](_0x327705['where'],{'$or':_[_0x2a4c('0x3b')](_0x327705['attributes'],function(_0x648f56){var _0x12306c={};_0x12306c[_0x648f56]={'$like':'%'+_0x1f4d82[_0x2a4c('0x4a')]['filter']+'%'};return _0x12306c;})});}_0x327705=_[_0x2a4c('0x55')]({},_0x327705,_0x1f4d82['options']);return db[_0x2a4c('0xd6')]['count']({'where':_0x327705[_0x2a4c('0x53')]})[_0x2a4c('0x33')](function(_0x4091a4){_0xfebdb9[_0x2a4c('0x2b')]=_0x4091a4;if(_0x1f4d82[_0x2a4c('0x4a')]['includeAll']){_0x327705['include']=[{'all':!![]}];}return db[_0x2a4c('0xd6')][_0x2a4c('0x5c')](_0x327705);})['then'](function(_0x37d723){_0xfebdb9[_0x2a4c('0x5d')]=_0x37d723;return _0xfebdb9;});}})['then'](respondWithFilteredResult(_0x1fab8a,_0x327705))[_0x2a4c('0x5e')](handleError(_0x1fab8a,null));};exports['getChatInteractions']=function(_0x439dd4,_0x29e43b,_0x53d6c){var _0x3898cc={};var _0x27861c={};var _0xa5d9a6;var _0x99ef25;return db[_0x2a4c('0x44')]['findOne']({'where':{'id':_0x439dd4[_0x2a4c('0x64')]['id']}})[_0x2a4c('0x33')](handleEntityNotFound(_0x29e43b,null))['then'](function(_0x2ce345){if(_0x2ce345){_0xa5d9a6=_0x2ce345;_0x27861c[_0x2a4c('0x47')]=_[_0x2a4c('0x4b')](db[_0x2a4c('0xd7')]['rawAttributes']);_0x27861c[_0x2a4c('0x4a')]=_[_0x2a4c('0x4b')](_0x439dd4['query']);_0x27861c[_0x2a4c('0x4c')]=_[_0x2a4c('0x4d')](_0x27861c[_0x2a4c('0x47')],_0x27861c['query']);_0x3898cc[_0x2a4c('0x4f')]=_[_0x2a4c('0x4d')](_0x27861c[_0x2a4c('0x47')],qs[_0x2a4c('0x4e')](_0x439dd4[_0x2a4c('0x4a')][_0x2a4c('0x4e')]));_0x3898cc[_0x2a4c('0x4f')]=_0x3898cc[_0x2a4c('0x4f')][_0x2a4c('0x61')]?_0x3898cc['attributes']:_0x27861c[_0x2a4c('0x47')];_0x3898cc[_0x2a4c('0xc5')]=qs['sort'](_0x439dd4[_0x2a4c('0x4a')]['sort']);_0x3898cc['where']=qs[_0x2a4c('0x4c')](_[_0x2a4c('0x54')](_0x439dd4[_0x2a4c('0x4a')],_0x27861c[_0x2a4c('0x4c')]));if(_0x439dd4[_0x2a4c('0x4a')]['filter']){_0x3898cc[_0x2a4c('0x53')]=_[_0x2a4c('0x55')](_0x3898cc[_0x2a4c('0x53')],{'$or':_[_0x2a4c('0x3b')](_0x3898cc[_0x2a4c('0x4f')],function(_0x5e229d){var _0xbb601e={};_0xbb601e[_0x5e229d]={'$like':'%'+_0x439dd4[_0x2a4c('0x4a')][_0x2a4c('0x3a')]+'%'};return _0xbb601e;})});}_0x3898cc=_[_0x2a4c('0x55')]({},_0x3898cc,_0x439dd4['options']);return _0xa5d9a6[_0x2a4c('0xd8')](_0x3898cc);}})[_0x2a4c('0x33')](function(_0x1c7b05){if(_0x1c7b05){_0x99ef25=_0x1c7b05[_0x2a4c('0x61')];if(!_0x439dd4[_0x2a4c('0x4a')][_0x2a4c('0x50')](_0x2a4c('0x51'))){_0x3898cc['limit']=qs['limit'](_0x439dd4[_0x2a4c('0x4a')]['limit']);_0x3898cc['offset']=qs[_0x2a4c('0x2c')](_0x439dd4['query'][_0x2a4c('0x2c')]);}return _0xa5d9a6['getChatInteractions'](_0x3898cc);}})[_0x2a4c('0x33')](function(_0x368ce9){if(_0x368ce9){return _0x368ce9?{'count':_0x99ef25,'rows':_0x368ce9}:null;}})[_0x2a4c('0x33')](respondWithResult(_0x29e43b,null))[_0x2a4c('0x5e')](handleError(_0x29e43b,null));};exports[_0x2a4c('0xd9')]=function(_0x3a7178,_0x535201,_0x53ccf3){var _0x1eca31={};var _0x35f28d={};var _0x581321;var _0x4ec7b2;return db[_0x2a4c('0x44')][_0x2a4c('0xc3')]({'where':{'id':_0x3a7178[_0x2a4c('0x64')]['id']}})[_0x2a4c('0x33')](handleEntityNotFound(_0x535201,null))[_0x2a4c('0x33')](function(_0x38e334){if(_0x38e334){_0x581321=_0x38e334;_0x35f28d[_0x2a4c('0x47')]=_[_0x2a4c('0x4b')](db[_0x2a4c('0xda')][_0x2a4c('0x45')]);_0x35f28d[_0x2a4c('0x4a')]=_['keys'](_0x3a7178[_0x2a4c('0x4a')]);_0x35f28d[_0x2a4c('0x4c')]=_['intersection'](_0x35f28d[_0x2a4c('0x47')],_0x35f28d['query']);_0x1eca31[_0x2a4c('0x4f')]=_[_0x2a4c('0x4d')](_0x35f28d[_0x2a4c('0x47')],qs[_0x2a4c('0x4e')](_0x3a7178[_0x2a4c('0x4a')][_0x2a4c('0x4e')]));_0x1eca31[_0x2a4c('0x4f')]=_0x1eca31['attributes'][_0x2a4c('0x61')]?_0x1eca31['attributes']:_0x35f28d[_0x2a4c('0x47')];_0x1eca31['order']=qs[_0x2a4c('0x52')](_0x3a7178['query'][_0x2a4c('0x52')]);_0x1eca31[_0x2a4c('0x53')]=qs[_0x2a4c('0x4c')](_[_0x2a4c('0x54')](_0x3a7178[_0x2a4c('0x4a')],_0x35f28d['filters']));if(_0x3a7178[_0x2a4c('0x4a')][_0x2a4c('0x3a')]){_0x1eca31['where']=_[_0x2a4c('0x55')](_0x1eca31[_0x2a4c('0x53')],{'$or':_[_0x2a4c('0x3b')](_0x1eca31[_0x2a4c('0x4f')],function(_0x4617a7){var _0x2c3a05={};_0x2c3a05[_0x4617a7]={'$like':'%'+_0x3a7178[_0x2a4c('0x4a')][_0x2a4c('0x3a')]+'%'};return _0x2c3a05;})});}_0x1eca31=_[_0x2a4c('0x55')]({},_0x1eca31,_0x3a7178[_0x2a4c('0x59')]);return _0x581321[_0x2a4c('0xd9')](_0x1eca31);}})[_0x2a4c('0x33')](function(_0x54e7a8){if(_0x54e7a8){_0x4ec7b2=_0x54e7a8[_0x2a4c('0x61')];if(!_0x3a7178['query'][_0x2a4c('0x50')](_0x2a4c('0x51'))){_0x1eca31['limit']=qs['limit'](_0x3a7178['query'][_0x2a4c('0x2d')]);_0x1eca31[_0x2a4c('0x2c')]=qs[_0x2a4c('0x2c')](_0x3a7178[_0x2a4c('0x4a')][_0x2a4c('0x2c')]);}return _0x581321[_0x2a4c('0xd9')](_0x1eca31);}})[_0x2a4c('0x33')](function(_0x677040){if(_0x677040){return _0x677040?{'count':_0x4ec7b2,'rows':_0x677040}:null;}})[_0x2a4c('0x33')](respondWithResult(_0x535201,null))[_0x2a4c('0x5e')](handleError(_0x535201,null));};exports[_0x2a4c('0xdb')]=function(_0x1a2aca,_0xdc56cf,_0x133eba){var _0x78037b={'raw':!![],'where':{}};var _0x38dddf={};var _0x5279cc={'count':0x0,'rows':[]};return db[_0x2a4c('0x44')][_0x2a4c('0xc3')]({'where':{'id':_0x1a2aca['params']['id']}})[_0x2a4c('0x33')](handleEntityNotFound(_0xdc56cf,null))['then'](function(_0x5a3ed3){if(_0x5a3ed3){_0x38dddf[_0x2a4c('0x47')]=_[_0x2a4c('0x4b')](db[_0x2a4c('0xdc')]['rawAttributes']);_0x38dddf[_0x2a4c('0x4a')]=_[_0x2a4c('0x4b')](_0x1a2aca[_0x2a4c('0x4a')]);_0x38dddf['filters']=_['intersection'](_0x38dddf[_0x2a4c('0x47')],_0x38dddf[_0x2a4c('0x4a')]);_0x78037b[_0x2a4c('0x4f')]=_[_0x2a4c('0x4d')](_0x38dddf[_0x2a4c('0x47')],qs[_0x2a4c('0x4e')](_0x1a2aca[_0x2a4c('0x4a')][_0x2a4c('0x4e')]));_0x78037b[_0x2a4c('0x4f')]=_0x78037b[_0x2a4c('0x4f')]['length']?_0x78037b[_0x2a4c('0x4f')]:_0x38dddf[_0x2a4c('0x47')];if(!_0x1a2aca['query'][_0x2a4c('0x50')](_0x2a4c('0x51'))){_0x78037b[_0x2a4c('0x2d')]=qs['limit'](_0x1a2aca['query'][_0x2a4c('0x2d')]);_0x78037b[_0x2a4c('0x2c')]=qs['offset'](_0x1a2aca['query'][_0x2a4c('0x2c')]);}_0x78037b[_0x2a4c('0xc5')]=qs[_0x2a4c('0x52')](_0x1a2aca[_0x2a4c('0x4a')][_0x2a4c('0x52')]);_0x78037b[_0x2a4c('0x53')]=qs['filters'](_['pick'](_0x1a2aca[_0x2a4c('0x4a')],_0x38dddf[_0x2a4c('0x4c')]));_0x78037b[_0x2a4c('0x53')]['UserId']=_0x5a3ed3['id'];if(_0x1a2aca[_0x2a4c('0x4a')][_0x2a4c('0x3a')]){_0x78037b['where']=_['merge'](_0x78037b[_0x2a4c('0x53')],{'$or':_[_0x2a4c('0x3b')](_0x78037b['attributes'],function(_0x4c7650){var _0x148321={};_0x148321[_0x4c7650]={'$like':'%'+_0x1a2aca[_0x2a4c('0x4a')]['filter']+'%'};return _0x148321;})});}_0x78037b=_[_0x2a4c('0x55')]({},_0x78037b,_0x1a2aca['options']);return db[_0x2a4c('0xdc')]['count']({'where':_0x78037b[_0x2a4c('0x53')]})['then'](function(_0x3401fc){_0x5279cc[_0x2a4c('0x2b')]=_0x3401fc;if(_0x1a2aca[_0x2a4c('0x4a')][_0x2a4c('0x5a')]){_0x78037b['include']=[{'all':!![]}];}return db['MailInteraction'][_0x2a4c('0x5c')](_0x78037b);})[_0x2a4c('0x33')](function(_0xeffb76){_0x5279cc['rows']=_0xeffb76;return _0x5279cc;});}})[_0x2a4c('0x33')](respondWithFilteredResult(_0xdc56cf,_0x78037b))['catch'](handleError(_0xdc56cf,null));};exports[_0x2a4c('0xdd')]=function(_0x1ec760,_0x9f1f7b,_0x3d131b){var _0x3ab224={};var _0x5b89ae={};var _0xcf7a30;var _0x24e7e5;return db[_0x2a4c('0x44')][_0x2a4c('0xc3')]({'where':{'id':_0x1ec760[_0x2a4c('0x64')]['id']}})[_0x2a4c('0x33')](handleEntityNotFound(_0x9f1f7b,null))[_0x2a4c('0x33')](function(_0x576811){if(_0x576811){_0xcf7a30=_0x576811;_0x5b89ae[_0x2a4c('0x47')]=_[_0x2a4c('0x4b')](db['SmsInteraction'][_0x2a4c('0x45')]);_0x5b89ae[_0x2a4c('0x4a')]=_['keys'](_0x1ec760[_0x2a4c('0x4a')]);_0x5b89ae['filters']=_[_0x2a4c('0x4d')](_0x5b89ae[_0x2a4c('0x47')],_0x5b89ae[_0x2a4c('0x4a')]);_0x3ab224[_0x2a4c('0x4f')]=_[_0x2a4c('0x4d')](_0x5b89ae[_0x2a4c('0x47')],qs[_0x2a4c('0x4e')](_0x1ec760[_0x2a4c('0x4a')]['fields']));_0x3ab224[_0x2a4c('0x4f')]=_0x3ab224[_0x2a4c('0x4f')]['length']?_0x3ab224[_0x2a4c('0x4f')]:_0x5b89ae[_0x2a4c('0x47')];_0x3ab224[_0x2a4c('0xc5')]=qs[_0x2a4c('0x52')](_0x1ec760['query'][_0x2a4c('0x52')]);_0x3ab224[_0x2a4c('0x53')]=qs[_0x2a4c('0x4c')](_[_0x2a4c('0x54')](_0x1ec760[_0x2a4c('0x4a')],_0x5b89ae[_0x2a4c('0x4c')]));if(_0x1ec760[_0x2a4c('0x4a')][_0x2a4c('0x3a')]){_0x3ab224[_0x2a4c('0x53')]=_[_0x2a4c('0x55')](_0x3ab224['where'],{'$or':_[_0x2a4c('0x3b')](_0x3ab224[_0x2a4c('0x4f')],function(_0x50d5aa){var _0x37df97={};_0x37df97[_0x50d5aa]={'$like':'%'+_0x1ec760[_0x2a4c('0x4a')]['filter']+'%'};return _0x37df97;})});}_0x3ab224=_[_0x2a4c('0x55')]({},_0x3ab224,_0x1ec760[_0x2a4c('0x59')]);return _0xcf7a30['getSmsInteractions'](_0x3ab224);}})['then'](function(_0xd058b2){if(_0xd058b2){_0x24e7e5=_0xd058b2['length'];if(!_0x1ec760[_0x2a4c('0x4a')][_0x2a4c('0x50')](_0x2a4c('0x51'))){_0x3ab224[_0x2a4c('0x2d')]=qs[_0x2a4c('0x2d')](_0x1ec760[_0x2a4c('0x4a')][_0x2a4c('0x2d')]);_0x3ab224[_0x2a4c('0x2c')]=qs[_0x2a4c('0x2c')](_0x1ec760[_0x2a4c('0x4a')][_0x2a4c('0x2c')]);}return _0xcf7a30[_0x2a4c('0xdd')](_0x3ab224);}})[_0x2a4c('0x33')](function(_0x54841f){if(_0x54841f){return _0x54841f?{'count':_0x24e7e5,'rows':_0x54841f}:null;}})[_0x2a4c('0x33')](respondWithResult(_0x9f1f7b,null))[_0x2a4c('0x5e')](handleError(_0x9f1f7b,null));};exports[_0x2a4c('0xde')]=function(_0x28f45e,_0xe2a6e3,_0x7e0104){var _0x26d77c={};var _0x48ed4b={};var _0x54a260;var _0x5e1078;return db[_0x2a4c('0x44')][_0x2a4c('0xc3')]({'where':{'id':_0x28f45e[_0x2a4c('0x64')]['id']}})[_0x2a4c('0x33')](handleEntityNotFound(_0xe2a6e3,null))[_0x2a4c('0x33')](function(_0x1bb830){if(_0x1bb830){_0x54a260=_0x1bb830;_0x48ed4b['model']=_[_0x2a4c('0x4b')](db[_0x2a4c('0xdf')]['rawAttributes']);_0x48ed4b[_0x2a4c('0x4a')]=_[_0x2a4c('0x4b')](_0x28f45e['query']);_0x48ed4b[_0x2a4c('0x4c')]=_['intersection'](_0x48ed4b[_0x2a4c('0x47')],_0x48ed4b['query']);_0x26d77c[_0x2a4c('0x4f')]=_[_0x2a4c('0x4d')](_0x48ed4b[_0x2a4c('0x47')],qs[_0x2a4c('0x4e')](_0x28f45e[_0x2a4c('0x4a')]['fields']));_0x26d77c[_0x2a4c('0x4f')]=_0x26d77c[_0x2a4c('0x4f')][_0x2a4c('0x61')]?_0x26d77c[_0x2a4c('0x4f')]:_0x48ed4b[_0x2a4c('0x47')];_0x26d77c[_0x2a4c('0xc5')]=qs[_0x2a4c('0x52')](_0x28f45e[_0x2a4c('0x4a')][_0x2a4c('0x52')]);_0x26d77c[_0x2a4c('0x53')]=qs[_0x2a4c('0x4c')](_[_0x2a4c('0x54')](_0x28f45e[_0x2a4c('0x4a')],_0x48ed4b['filters']));if(_0x28f45e[_0x2a4c('0x4a')][_0x2a4c('0x3a')]){_0x26d77c[_0x2a4c('0x53')]=_[_0x2a4c('0x55')](_0x26d77c[_0x2a4c('0x53')],{'$or':_['map'](_0x26d77c[_0x2a4c('0x4f')],function(_0x4edc91){var _0x4c6dbc={};_0x4c6dbc[_0x4edc91]={'$like':'%'+_0x28f45e[_0x2a4c('0x4a')][_0x2a4c('0x3a')]+'%'};return _0x4c6dbc;})});}_0x26d77c=_['merge']({},_0x26d77c,_0x28f45e[_0x2a4c('0x59')]);return _0x54a260[_0x2a4c('0xde')](_0x26d77c);}})[_0x2a4c('0x33')](function(_0x5acd06){if(_0x5acd06){_0x5e1078=_0x5acd06[_0x2a4c('0x61')];if(!_0x28f45e[_0x2a4c('0x4a')]['hasOwnProperty'](_0x2a4c('0x51'))){_0x26d77c[_0x2a4c('0x2d')]=qs[_0x2a4c('0x2d')](_0x28f45e[_0x2a4c('0x4a')][_0x2a4c('0x2d')]);_0x26d77c['offset']=qs['offset'](_0x28f45e[_0x2a4c('0x4a')][_0x2a4c('0x2c')]);}return _0x54a260[_0x2a4c('0xde')](_0x26d77c);}})[_0x2a4c('0x33')](function(_0x351d3c){if(_0x351d3c){return _0x351d3c?{'count':_0x5e1078,'rows':_0x351d3c}:null;}})[_0x2a4c('0x33')](respondWithResult(_0xe2a6e3,null))[_0x2a4c('0x5e')](handleError(_0xe2a6e3,null));};exports[_0x2a4c('0xe0')]=function(_0xb34b25,_0x214b37,_0x1828d1){var _0x44fe0c={};var _0x4b4a2f={};var _0x251a0b;var _0x5111be;return db['User'][_0x2a4c('0xc3')]({'where':{'id':_0xb34b25['params']['id']}})[_0x2a4c('0x33')](handleEntityNotFound(_0x214b37,null))[_0x2a4c('0x33')](function(_0x3e4301){if(_0x3e4301){_0x251a0b=_0x3e4301;_0x4b4a2f[_0x2a4c('0x47')]=_[_0x2a4c('0x4b')](db[_0x2a4c('0xe1')][_0x2a4c('0x45')]);_0x4b4a2f[_0x2a4c('0x4a')]=_[_0x2a4c('0x4b')](_0xb34b25[_0x2a4c('0x4a')]);_0x4b4a2f['filters']=_[_0x2a4c('0x4d')](_0x4b4a2f[_0x2a4c('0x47')],_0x4b4a2f[_0x2a4c('0x4a')]);_0x44fe0c[_0x2a4c('0x4f')]=_['intersection'](_0x4b4a2f['model'],qs['fields'](_0xb34b25[_0x2a4c('0x4a')][_0x2a4c('0x4e')]));_0x44fe0c[_0x2a4c('0x4f')]=_0x44fe0c[_0x2a4c('0x4f')][_0x2a4c('0x61')]?_0x44fe0c[_0x2a4c('0x4f')]:_0x4b4a2f[_0x2a4c('0x47')];_0x44fe0c[_0x2a4c('0xc5')]=qs['sort'](_0xb34b25['query']['sort']);_0x44fe0c[_0x2a4c('0x53')]=qs[_0x2a4c('0x4c')](_['pick'](_0xb34b25[_0x2a4c('0x4a')],_0x4b4a2f[_0x2a4c('0x4c')]));if(_0xb34b25[_0x2a4c('0x4a')][_0x2a4c('0x3a')]){_0x44fe0c['where']=_[_0x2a4c('0x55')](_0x44fe0c['where'],{'$or':_[_0x2a4c('0x3b')](_0x44fe0c[_0x2a4c('0x4f')],function(_0x2d1d6f){var _0x4cf57d={};_0x4cf57d[_0x2d1d6f]={'$like':'%'+_0xb34b25[_0x2a4c('0x4a')]['filter']+'%'};return _0x4cf57d;})});}_0x44fe0c=_[_0x2a4c('0x55')]({},_0x44fe0c,_0xb34b25[_0x2a4c('0x59')]);return _0x251a0b['getWhatsappInteractions'](_0x44fe0c);}})[_0x2a4c('0x33')](function(_0xadd4f5){if(_0xadd4f5){_0x5111be=_0xadd4f5[_0x2a4c('0x61')];if(!_0xb34b25[_0x2a4c('0x4a')][_0x2a4c('0x50')]('nolimit')){_0x44fe0c[_0x2a4c('0x2d')]=qs[_0x2a4c('0x2d')](_0xb34b25[_0x2a4c('0x4a')]['limit']);_0x44fe0c[_0x2a4c('0x2c')]=qs[_0x2a4c('0x2c')](_0xb34b25[_0x2a4c('0x4a')][_0x2a4c('0x2c')]);}return _0x251a0b[_0x2a4c('0xe0')](_0x44fe0c);}})[_0x2a4c('0x33')](function(_0x2b3e99){if(_0x2b3e99){return _0x2b3e99?{'count':_0x5111be,'rows':_0x2b3e99}:null;}})[_0x2a4c('0x33')](respondWithResult(_0x214b37,null))[_0x2a4c('0x5e')](handleError(_0x214b37,null));};exports['login']=function(_0x43b85f,_0x59a92c,_0x223ba2){var _0x24adfe;var _0x19231d;var _0x47ba54;var _0x39aba1=!_[_0x2a4c('0x6c')](_0x43b85f['params']['id'])?_0x43b85f[_0x2a4c('0x64')]['id']:!_[_0x2a4c('0x6c')](_0x43b85f['user']['id'])?_0x43b85f[_0x2a4c('0x81')]['id']:null;return db[_0x2a4c('0x44')][_0x2a4c('0x62')]({'where':{'id':_0x39aba1,'role':{'$or':[_0x2a4c('0x36'),_0x2a4c('0x81'),_0x2a4c('0x38')]}},'attributes':['id',_0x2a4c('0x41'),_0x2a4c('0xe2'),_0x2a4c('0xe3'),_0x2a4c('0x3e'),_0x2a4c('0x68'),_0x2a4c('0xa6')]})['then'](function(_0x1826db){if(_0x1826db){if(_0x1826db['role']===_0x2a4c('0x38')){_0x24adfe=_0x1826db;if(_0x43b85f[_0x2a4c('0x63')]['interface']){_0x47ba54=util[_0x2a4c('0xb4')](_0x2a4c('0xe4'),_0x24adfe[_0x43b85f[_0x2a4c('0x63')][_0x2a4c('0xb3')]]);}else if(_0x43b85f['body'][_0x2a4c('0xe5')]){_0x47ba54=util[_0x2a4c('0xb4')](_0x2a4c('0xb5'),_0x43b85f[_0x2a4c('0x63')]['intrf']);}else{_0x47ba54=util[_0x2a4c('0xb4')]('SIP/%s',_0x24adfe['name']);}socket['to'](util['format'](_0x2a4c('0xe6'),_0x24adfe[_0x2a4c('0x41')]))[_0x2a4c('0xb0')]('user:forcelogout',{'ip':_0x43b85f[_0x2a4c('0xe7')]['x-forwarded-for']||_0x43b85f['connection'][_0x2a4c('0xe8')]||_0x43b85f['socket'][_0x2a4c('0xe8')]||_0x43b85f[_0x2a4c('0xe9')][_0x2a4c('0xea')][_0x2a4c('0xe8')]});return db[_0x2a4c('0xb6')]['destroy']({'where':{'membername':_0x24adfe[_0x2a4c('0x41')]},'individualHooks':!![]});}}else{throw new db[(_0x2a4c('0x95'))][(_0x2a4c('0x97'))]('User\x20not\x20found\x20or\x20not\x20allowed\x20to\x20perform\x20login\x20method');}})[_0x2a4c('0x33')](function(){if(_0x24adfe){return _0x24adfe[_0x2a4c('0xeb')]({'raw':!![]});}})['then'](function(_0x5db196){if(_0x24adfe){var _0x10cff6=[];if(_0x5db196){_0x19231d=_0x5db196;if(_0x19231d['length']){for(var _0x37bbf0=0x0;_0x37bbf0<_0x19231d['length'];_0x37bbf0++){_0x10cff6[_0x2a4c('0x8f')]({'membername':_0x24adfe[_0x2a4c('0x41')],'UserId':_0x24adfe['id'],'queue_name':_0x19231d[_0x37bbf0][_0x2a4c('0x41')],'VoiceQueueId':_0x19231d[_0x37bbf0]['id'],'interface':_0x47ba54,'paused':_0x24adfe['loginInPause']||![],'penalty':_0x19231d[_0x37bbf0][_0x2a4c('0xec')]||0x0});}return BPromise[_0x2a4c('0x91')](_0x10cff6,function(_0x440114){return db[_0x2a4c('0xb6')]['upsert'](_0x440114);});}}}})['then'](function(){if(_0x24adfe){return db[_0x2a4c('0xed')][_0x2a4c('0x5c')]({'where':{'membername':_0x24adfe[_0x2a4c('0x41')],'exitAt':null}});}})[_0x2a4c('0x33')](function(_0x4a5fae){if(_0x24adfe){var _0x4b2f7b=[];_0x4a5fae[_0x2a4c('0xee')](function(_0x4a3cf8){_0x4b2f7b[_0x2a4c('0x8f')](_0x4a3cf8['update']({'exitAt':moment()['format'](_0x2a4c('0xef'))}));});return BPromise[_0x2a4c('0x90')](_0x4b2f7b);}})['then'](function(){if(_0x24adfe){var _0x1024bd=[];var _0x473077=[];var _0x72e480=utils[_0x2a4c('0xf0')]();var _0x3ed45d={'membername':_0x24adfe['name'],'interface':_0x47ba54,'enterAt':moment()['format'](_0x2a4c('0xef')),'role':_0x24adfe['role'],'internal':_0x24adfe[_0x2a4c('0x68')]};_0x72e480['forEach'](function(_0x39b95b){_0x1024bd[_0x2a4c('0x8f')](_[_0x2a4c('0x55')]({'channel':_0x39b95b,'type':_0x2a4c('0xf1'),'data1':_0x43b85f[_0x2a4c('0x63')][_0x2a4c('0xf2')],'data2':_0x47ba54},_0x3ed45d));if(_0x24adfe['loginInPause']){_0x473077['push'](_[_0x2a4c('0x55')]({'channel':_0x39b95b,'type':_0x2a4c('0xf3'),'data1':_0x2a4c('0xf4')},_0x3ed45d));}});return db[_0x2a4c('0xed')][_0x2a4c('0x8d')](_0x1024bd[_0x2a4c('0xf5')](_0x473077),{'individualHooks':!![]});}})[_0x2a4c('0x33')](function(){if(_0x24adfe){return _0x24adfe['update']({'online':!![],'lastLoginAt':moment()[_0x2a4c('0xb4')](_0x2a4c('0xef')),'voicePause':_0x24adfe[_0x2a4c('0xa6')]||![],'mailPause':_0x24adfe[_0x2a4c('0xa6')]||![],'chatPause':_0x24adfe[_0x2a4c('0xa6')]||![],'faxPause':_0x24adfe[_0x2a4c('0xa6')]||![],'smsPause':_0x24adfe[_0x2a4c('0xa6')]||![],'openchannelPause':_0x24adfe[_0x2a4c('0xa6')]||![],'whatsappPause':_0x24adfe['loginInPause']||![],'pauseType':_0x24adfe['loginInPause']?'LOGININPAUSE':null,'interface':_0x47ba54,'lastPauseAt':moment()[_0x2a4c('0xb4')](_0x2a4c('0xef'))});}})['then'](function(_0xac1d21){if(_0x43b85f[_0x2a4c('0xf6')]){return _0x223ba2();}else{return BPromise[_0x2a4c('0xf7')](_0xac1d21)['then'](respondWithResult(_0x59a92c,null));}})[_0x2a4c('0x5e')](handleError(_0x59a92c,null));};exports[_0x2a4c('0xf8')]=function(_0x27127d,_0x60496d,_0xc986d9){var _0x529068;return db[_0x2a4c('0x44')][_0x2a4c('0x62')]({'where':{'id':_0x27127d['params']['id'],'role':_0x2a4c('0x38')},'attributes':['id',_0x2a4c('0x41'),'role']})[_0x2a4c('0x33')](handleEntityNotFound(_0x60496d,null))[_0x2a4c('0x33')](function(_0x3f3f29){if(_0x3f3f29){_0x529068=_0x3f3f29;return db[_0x2a4c('0xb6')][_0x2a4c('0x34')]({'where':{'membername':_0x529068[_0x2a4c('0x41')]},'individualHooks':!![]});}})[_0x2a4c('0x33')](function(){return db[_0x2a4c('0xed')]['findAll']({'where':{'membername':_0x529068[_0x2a4c('0x41')],'exitAt':null}});})['then'](function(_0x217509){var _0x4f9eaf=[];_0x217509[_0x2a4c('0xee')](function(_0x51fb40){_0x4f9eaf['push'](_0x51fb40[_0x2a4c('0x32')]({'exitAt':moment()[_0x2a4c('0xb4')](_0x2a4c('0xef'))}));});return BPromise['all'](_0x4f9eaf);})[_0x2a4c('0x33')](function(){return _0x529068[_0x2a4c('0x32')]({'online':![],'lastLoginAt':null,'voicePause':![],'mailPause':![],'chatPause':![],'faxPause':![],'smsPause':![],'openchannelPause':![],'whatsappPause':![],'interface':null});})[_0x2a4c('0x33')](respondWithResult(_0x60496d,null))[_0x2a4c('0x5e')](handleError(_0x60496d,null));};exports['pause']=function(_0x1a93a5,_0x5215d6,_0x2aa204){var _0x3b9d27;return db[_0x2a4c('0xb6')][_0x2a4c('0x32')]({'paused':0x1},{'where':{'UserId':_0x1a93a5[_0x2a4c('0x64')]['id']},'individualHooks':!![]})[_0x2a4c('0x33')](function(){return db[_0x2a4c('0x44')]['find']({'where':{'id':_0x1a93a5['params']['id'],'role':'agent'},'attributes':['id',_0x2a4c('0x41'),'role',_0x2a4c('0x68'),_0x2a4c('0xb3')]});})[_0x2a4c('0x33')](handleEntityNotFound(_0x5215d6,null))[_0x2a4c('0x33')](function(_0x39b96b){if(_0x39b96b){_0x3b9d27=_0x39b96b;return respondWithRpcPromise(_0x2a4c('0xf9'),'pause',{'id':_0x3b9d27['id'],'name':_0x3b9d27[_0x2a4c('0x41')],'pause':!![]});}})['then'](function(){if(_0x3b9d27){return db[_0x2a4c('0xed')]['findAll']({'where':{'membername':_0x3b9d27['name'],'type':_0x2a4c('0xf3'),'exitAt':null}});}})['then'](function(_0x4d2dac){if(_0x4d2dac[_0x2a4c('0x61')]){var _0xe92ea9=moment()[_0x2a4c('0xb4')]('YYYY-MM-DD\x20HH:mm:ss');for(var _0x31bc04=0x0,_0x366676=_0x4d2dac[_0x2a4c('0x61')];_0x31bc04<_0x366676;_0x31bc04++){_0x4d2dac[_0x31bc04]['updateAttributes']({'exitAt':_0xe92ea9});}}})[_0x2a4c('0x33')](function(){var _0x2b03db=[];var _0x324843=utils[_0x2a4c('0xf0')]();_0x324843[_0x2a4c('0xee')](function(_0x379c45){_0x2b03db[_0x2a4c('0x8f')]({'channel':_0x379c45,'membername':_0x3b9d27['name'],'interface':_[_0x2a4c('0x6c')](_0x3b9d27[_0x2a4c('0xb3')])?util[_0x2a4c('0xb4')](_0x2a4c('0xb5'),_0x3b9d27[_0x2a4c('0x41')]):_0x3b9d27[_0x2a4c('0xb3')],'type':_0x2a4c('0xf3'),'enterAt':moment()[_0x2a4c('0xb4')](_0x2a4c('0xef')),'data1':_0x1a93a5[_0x2a4c('0x63')]['type']||_0x2a4c('0xfa'),'role':_0x3b9d27[_0x2a4c('0x3e')],'internal':_0x3b9d27[_0x2a4c('0x68')]});});return db[_0x2a4c('0xed')]['bulkCreate'](_0x2b03db,{'individualHooks':!![]});})[_0x2a4c('0x33')](function(){return _0x3b9d27[_0x2a4c('0x32')]({'voicePause':!![],'mailPause':!![],'chatPause':!![],'faxPause':!![],'smsPause':!![],'whatsappPause':!![],'openchannelPause':!![],'pauseType':_0x1a93a5[_0x2a4c('0x63')][_0x2a4c('0x46')]||_0x2a4c('0xfa'),'lastPauseAt':moment()['format'](_0x2a4c('0xef'))});})[_0x2a4c('0x33')](respondWithResult(_0x5215d6,null))[_0x2a4c('0x5e')](handleError(_0x5215d6,null));};exports['unpause']=function(_0x3dbffc,_0x14b55d,_0x15c992){var _0x5107a1;return db['User'][_0x2a4c('0x62')]({'where':{'id':_0x3dbffc[_0x2a4c('0x64')]['id']},'attributes':['id',_0x2a4c('0x41'),_0x2a4c('0x3e'),_0x2a4c('0xfb'),'mailPause',_0x2a4c('0xfc'),_0x2a4c('0xfd'),'openchannelPause',_0x2a4c('0xfe'),'whatsapppause',_0x2a4c('0xff'),_0x2a4c('0x100')]})[_0x2a4c('0x33')](handleEntityNotFound(_0x14b55d,null))[_0x2a4c('0x33')](function(_0x593e91){if(_0x593e91){_0x5107a1=_0x593e91;if(_0x3dbffc[_0x2a4c('0x63')]['channel']&&!utils['isValidChannel'](_0x3dbffc[_0x2a4c('0x63')][_0x2a4c('0xa4')])){throw new db[(_0x2a4c('0x95'))][(_0x2a4c('0x97'))](_0x2a4c('0xa8'));}switch(_0x3dbffc[_0x2a4c('0x63')][_0x2a4c('0xa4')]){case'voice':return respondWithRpcPromise(_0x2a4c('0xf9'),_0x2a4c('0x101'),{'id':_0x5107a1['id'],'name':_0x5107a1[_0x2a4c('0x41')],'pause':![]})[_0x2a4c('0x33')](function(){return db[_0x2a4c('0xb6')][_0x2a4c('0x32')]({'paused':0x0},{'where':{'UserId':_0x5107a1['id']},'individualHooks':!![]});})[_0x2a4c('0x33')](function(){return db[_0x2a4c('0xed')]['find']({'where':{'channel':_0x3dbffc[_0x2a4c('0x63')][_0x2a4c('0xa4')],'membername':_0x5107a1['name'],'type':_0x2a4c('0xf3'),'exitAt':null}});})[_0x2a4c('0x33')](function(_0x50642d){if(_0x50642d){return _0x50642d[_0x2a4c('0x32')]({'exitAt':moment()['format']('YYYY-MM-DD\x20HH:mm:ss'),'data2':_0x2a4c('0x102')},{'individualHooks':!![]});}return null;})[_0x2a4c('0x33')](function(){return _0x5107a1['update']({'voicePause':![]});});case'mail':case _0x2a4c('0x103'):case _0x2a4c('0x104'):case'sms':case _0x2a4c('0x105'):case _0x2a4c('0x106'):return db[_0x2a4c('0xed')][_0x2a4c('0x62')]({'where':{'channel':_0x3dbffc[_0x2a4c('0x63')][_0x2a4c('0xa4')],'membername':_0x5107a1[_0x2a4c('0x41')],'type':'PAUSE','exitAt':null}})[_0x2a4c('0x33')](function(_0x23b546){if(_0x23b546){return _0x23b546['update']({'exitAt':moment()[_0x2a4c('0xb4')]('YYYY-MM-DD\x20HH:mm:ss'),'data2':_0x2a4c('0x102')},{'individualHooks':!![]});}return null;})[_0x2a4c('0x33')](function(){var _0x656f94={};_['set'](_0x656f94,util[_0x2a4c('0xb4')](_0x2a4c('0x107'),_0x3dbffc[_0x2a4c('0x63')][_0x2a4c('0xa4')],_0x2a4c('0x108')),![]);return _0x5107a1[_0x2a4c('0x32')](_0x656f94);});default:return respondWithRpcPromise(_0x2a4c('0xf9'),_0x2a4c('0x101'),{'id':_0x5107a1['id'],'name':_0x5107a1[_0x2a4c('0x41')],'pause':![]})[_0x2a4c('0x33')](function(){return db[_0x2a4c('0xb6')][_0x2a4c('0x32')]({'paused':0x0},{'where':{'UserId':_0x5107a1['id']}});})[_0x2a4c('0x33')](function(){return db['MemberReport'][_0x2a4c('0x5c')]({'where':{'membername':_0x5107a1[_0x2a4c('0x41')],'type':'PAUSE','exitAt':null}});})['then'](function(_0x392d9e){var _0x2118fe=[];_0x392d9e['forEach'](function(_0x288a63){_0x2118fe[_0x2a4c('0x8f')](_0x288a63['update']({'exitAt':moment()[_0x2a4c('0xb4')]('YYYY-MM-DD\x20HH:mm:ss'),'data2':'manual'}));});return BPromise[_0x2a4c('0x90')](_0x2118fe);})[_0x2a4c('0x33')](function(){return _0x5107a1['update']({'voicePause':![],'mailPause':![],'chatPause':![],'faxPause':![],'smsPause':![],'whatsappPause':![],'openchannelPause':![]});});}}})[_0x2a4c('0x33')](respondWithResult(_0x14b55d,null))[_0x2a4c('0x5e')](handleError(_0x14b55d,null));};exports[_0x2a4c('0x109')]=function(_0x588061,_0x500945,_0x42a284){var _0x342bae={};var _0x583b16={};var _0x676aa7;var _0x528ee7;return db[_0x2a4c('0x44')]['findOne']({'where':{'id':_0x588061[_0x2a4c('0x64')]['id']}})['then'](handleEntityNotFound(_0x500945,null))['then'](function(_0x370fcf){if(_0x370fcf){_0x676aa7=_0x370fcf;_0x583b16['model']=_[_0x2a4c('0x4b')](db['Team'][_0x2a4c('0x45')]);_0x583b16[_0x2a4c('0x4a')]=_[_0x2a4c('0x4b')](_0x588061[_0x2a4c('0x4a')]);_0x583b16[_0x2a4c('0x4c')]=_[_0x2a4c('0x4d')](_0x583b16[_0x2a4c('0x47')],_0x583b16[_0x2a4c('0x4a')]);_0x342bae[_0x2a4c('0x4f')]=_['intersection'](_0x583b16[_0x2a4c('0x47')],qs[_0x2a4c('0x4e')](_0x588061[_0x2a4c('0x4a')][_0x2a4c('0x4e')]));_0x342bae['attributes']=_0x342bae['attributes']['length']?_0x342bae['attributes']:_0x583b16['model'];_0x342bae[_0x2a4c('0xc5')]=qs[_0x2a4c('0x52')](_0x588061[_0x2a4c('0x4a')][_0x2a4c('0x52')]);_0x342bae[_0x2a4c('0x53')]=qs[_0x2a4c('0x4c')](_['pick'](_0x588061['query'],_0x583b16[_0x2a4c('0x4c')]));if(_0x588061[_0x2a4c('0x4a')][_0x2a4c('0x3a')]){_0x342bae[_0x2a4c('0x53')]=_[_0x2a4c('0x55')](_0x342bae[_0x2a4c('0x53')],{'$or':_[_0x2a4c('0x3b')](_0x342bae[_0x2a4c('0x4f')],function(_0x459e28){var _0x19e35b={};_0x19e35b[_0x459e28]={'$like':'%'+_0x588061['query'][_0x2a4c('0x3a')]+'%'};return _0x19e35b;})});}_0x342bae=_[_0x2a4c('0x55')]({},_0x342bae,_0x588061[_0x2a4c('0x59')]);return _0x676aa7[_0x2a4c('0x109')](_0x342bae);}})['then'](function(_0x92cb58){if(_0x92cb58){_0x528ee7=_0x92cb58[_0x2a4c('0x61')];if(!_0x588061[_0x2a4c('0x4a')]['hasOwnProperty'](_0x2a4c('0x51'))){_0x342bae[_0x2a4c('0x2d')]=qs[_0x2a4c('0x2d')](_0x588061['query'][_0x2a4c('0x2d')]);_0x342bae[_0x2a4c('0x2c')]=qs[_0x2a4c('0x2c')](_0x588061[_0x2a4c('0x4a')][_0x2a4c('0x2c')]);}return _0x676aa7[_0x2a4c('0x109')](_0x342bae);}})[_0x2a4c('0x33')](function(_0x565772){if(_0x565772){return _0x565772?{'count':_0x528ee7,'rows':_0x565772}:null;}})[_0x2a4c('0x33')](respondWithResult(_0x500945,null))[_0x2a4c('0x5e')](handleError(_0x500945,null));};exports[_0x2a4c('0x10a')]=function(_0xf04222,_0x5f0951){return db[_0x2a4c('0x44')]['find']({'where':{'id':_0xf04222[_0x2a4c('0x64')]['id']}})[_0x2a4c('0x33')](handleEntityNotFound(_0x5f0951,null))[_0x2a4c('0x33')](function(_0x5d48a4){if(_0x5d48a4){var _0x29b24b=_0x5d48a4[_0x2a4c('0x35')]({'plain':!![]});return _0x5d48a4[_0x2a4c('0x10a')](_0xf04222[_0x2a4c('0x63')][_0x2a4c('0xac')],_['omit'](_0xf04222[_0x2a4c('0x63')],[_0x2a4c('0xac'),'id'])||{})[_0x2a4c('0x33')](function(){for(var _0x3e0b63=0x0;_0x3e0b63<_0xf04222[_0x2a4c('0x63')][_0x2a4c('0xac')][_0x2a4c('0x61')];_0x3e0b63++){var _0x391198=[];db[_0x2a4c('0x10b')]['findOne']({'where':{'id':_0xf04222[_0x2a4c('0x63')]['ids'][_0x3e0b63]}})[_0x2a4c('0x33')](function(_0x43128e){_0x391198[_0x2a4c('0x8f')](_0x43128e[_0x2a4c('0xeb')]()['then'](function(_0x28a9e2){for(var _0x565ddb=0x0;_0x565ddb<_0x28a9e2['length'];_0x565ddb++){_0x28a9e2[_0x565ddb][_0x2a4c('0x10c')](_0x2a4c('0xa4'),_0x2a4c('0x10d'));}return _0x28a9e2;}));_0x391198[_0x2a4c('0x8f')](_0x43128e[_0x2a4c('0x10e')]()[_0x2a4c('0x33')](function(_0x20b5c4){for(var _0x3bec35=0x0;_0x3bec35<_0x20b5c4[_0x2a4c('0x61')];_0x3bec35++){_0x20b5c4[_0x3bec35][_0x2a4c('0x10c')](_0x2a4c('0xa4'),'Chat');}return _0x20b5c4;}));_0x391198[_0x2a4c('0x8f')](_0x43128e[_0x2a4c('0x10f')]()[_0x2a4c('0x33')](function(_0x1c24ec){for(var _0xfdc846=0x0;_0xfdc846<_0x1c24ec[_0x2a4c('0x61')];_0xfdc846++){_0x1c24ec[_0xfdc846][_0x2a4c('0x10c')]('channel',_0x2a4c('0x110'));}return _0x1c24ec;}));_0x391198[_0x2a4c('0x8f')](_0x43128e[_0x2a4c('0x111')]()[_0x2a4c('0x33')](function(_0x4e5ab0){for(var _0x252ac4=0x0;_0x252ac4<_0x4e5ab0['length'];_0x252ac4++){_0x4e5ab0[_0x252ac4][_0x2a4c('0x10c')](_0x2a4c('0xa4'),'Sms');}return _0x4e5ab0;}));_0x391198['push'](_0x43128e[_0x2a4c('0x112')]()['then'](function(_0xdcd5f8){for(var _0x1b4b2c=0x0;_0x1b4b2c<_0xdcd5f8[_0x2a4c('0x61')];_0x1b4b2c++){_0xdcd5f8[_0x1b4b2c][_0x2a4c('0x10c')]('channel',_0x2a4c('0x113'));}return _0xdcd5f8;}));_0x391198['push'](_0x43128e[_0x2a4c('0x114')]()[_0x2a4c('0x33')](function(_0x510982){for(var _0x36ed6e=0x0;_0x36ed6e<_0x510982[_0x2a4c('0x61')];_0x36ed6e++){_0x510982[_0x36ed6e][_0x2a4c('0x10c')](_0x2a4c('0xa4'),_0x2a4c('0x115'));}return _0x510982;}));_0x391198[_0x2a4c('0x8f')](_0x43128e[_0x2a4c('0x116')]()[_0x2a4c('0x33')](function(_0x5ebd42){for(var _0x389cef=0x0;_0x389cef<_0x5ebd42[_0x2a4c('0x61')];_0x389cef++){_0x5ebd42[_0x389cef][_0x2a4c('0x10c')](_0x2a4c('0xa4'),'Openchannel');}return _0x5ebd42;}));return BPromise[_0x2a4c('0x90')](_0x391198);})[_0x2a4c('0x33')](function(_0x440f43){var _0x94e6cd=_[_0x2a4c('0x117')](_0x440f43);_0x391198=[];return db[_0x2a4c('0x57')][_0x2a4c('0x118')](function(_0x228f63){for(var _0x5a5f6b=0x0;_0x5a5f6b<_0x94e6cd[_0x2a4c('0x61')];_0x5a5f6b++){_0x391198[_0x2a4c('0x8f')](_0x94e6cd[_0x5a5f6b]['addAgent'](_0x29b24b['id']),{'transaction':_0x228f63});}return BPromise[_0x2a4c('0x90')](_0x391198)[_0x2a4c('0x33')](function(){if(_0x29b24b[_0x2a4c('0xa5')]){return BPromise[_0x2a4c('0x91')](_['filter'](_0x94e6cd,function(_0x399357){return _0x399357['getDataValue'](_0x2a4c('0xa4'))==='Voice';}),function(_0x5979bf){return db[_0x2a4c('0xb6')][_0x2a4c('0xb7')]({'membername':_0x29b24b[_0x2a4c('0x41')],'UserId':_0x29b24b['id'],'queue_name':_0x5979bf[_0x2a4c('0x41')],'VoiceQueueId':_0x5979bf['id'],'interface':_[_0x2a4c('0x6c')](_0x29b24b[_0x2a4c('0xb3')])?util[_0x2a4c('0xb4')](_0x2a4c('0xb5'),_0x29b24b[_0x2a4c('0x41')]):_0x29b24b['interface'],'paused':_0x29b24b[_0x2a4c('0xfb')]||![],'penalty':_0x29b24b[_0x2a4c('0xad')]},{'transaction':_0x228f63});});}else{return;}})[_0x2a4c('0x33')](function(){for(var _0x47c0a8=0x0;_0x47c0a8<_0x94e6cd[_0x2a4c('0x61')];_0x47c0a8++){var _0x37e85c=_0x94e6cd[_0x47c0a8][_0x2a4c('0x119')](_0x2a4c('0xa4'));var _0x5cdb55=_0x37e85c+_0x2a4c('0xaf');socket[_0x2a4c('0xb0')](_0x2a4c('0x81')+_0x37e85c+_0x2a4c('0x11a'),{'UserId':_0x29b24b['id'],['queueField']:_0x94e6cd[_0x47c0a8]['id']});}});});});}});}})[_0x2a4c('0x33')](respondWithStatusCode(_0x5f0951,null))['catch'](handleError(_0x5f0951,null));};exports[_0x2a4c('0x11b')]=function(_0x4ec8b3,_0x429f78){return db['User'][_0x2a4c('0xc3')]({'where':{'id':_0x4ec8b3[_0x2a4c('0x64')]['id']}})['then'](handleEntityNotFound(_0x429f78,null))[_0x2a4c('0x33')](function(_0x12442c){if(_0x12442c){var _0x5e1b48=_0x12442c[_0x2a4c('0x35')]({'plain':!![]});var _0x5af4ff=_0x4ec8b3['query'][_0x2a4c('0xac')];return _0x12442c['removeTeams'](_0x5af4ff)[_0x2a4c('0x33')](function(){for(var _0xfe15c8=0x0;_0xfe15c8<_0x5af4ff['length'];_0xfe15c8++){var _0x5cf231=[];db[_0x2a4c('0x10b')]['findOne']({'where':{'id':_0x5af4ff[_0xfe15c8]}})[_0x2a4c('0x33')](function(_0x13585c){_0x5cf231[_0x2a4c('0x8f')](_0x13585c[_0x2a4c('0xeb')]()[_0x2a4c('0x33')](function(_0x2711a5){for(var _0xb1b9d7=0x0;_0xb1b9d7<_0x2711a5[_0x2a4c('0x61')];_0xb1b9d7++){_0x2711a5[_0xb1b9d7][_0x2a4c('0x10c')](_0x2a4c('0xa4'),_0x2a4c('0x10d'));}return _0x2711a5;}));_0x5cf231[_0x2a4c('0x8f')](_0x13585c[_0x2a4c('0x10e')]()['then'](function(_0xab490a){for(var _0x419cb2=0x0;_0x419cb2<_0xab490a[_0x2a4c('0x61')];_0x419cb2++){_0xab490a[_0x419cb2][_0x2a4c('0x10c')](_0x2a4c('0xa4'),_0x2a4c('0x11c'));}return _0xab490a;}));_0x5cf231[_0x2a4c('0x8f')](_0x13585c['getMailQueues']()[_0x2a4c('0x33')](function(_0xc73644){for(var _0xdcf68f=0x0;_0xdcf68f<_0xc73644[_0x2a4c('0x61')];_0xdcf68f++){_0xc73644[_0xdcf68f][_0x2a4c('0x10c')](_0x2a4c('0xa4'),_0x2a4c('0x110'));}return _0xc73644;}));_0x5cf231[_0x2a4c('0x8f')](_0x13585c[_0x2a4c('0x111')]()[_0x2a4c('0x33')](function(_0x174dcc){for(var _0x1e18f9=0x0;_0x1e18f9<_0x174dcc[_0x2a4c('0x61')];_0x1e18f9++){_0x174dcc[_0x1e18f9][_0x2a4c('0x10c')]('channel',_0x2a4c('0x11d'));}return _0x174dcc;}));_0x5cf231[_0x2a4c('0x8f')](_0x13585c[_0x2a4c('0x112')]()['then'](function(_0x52cdbb){for(var _0xd2bd5b=0x0;_0xd2bd5b<_0x52cdbb['length'];_0xd2bd5b++){_0x52cdbb[_0xd2bd5b][_0x2a4c('0x10c')](_0x2a4c('0xa4'),_0x2a4c('0x113'));}return _0x52cdbb;}));_0x5cf231[_0x2a4c('0x8f')](_0x13585c['getFaxQueues']()['then'](function(_0x5daa2d){for(var _0x217202=0x0;_0x217202<_0x5daa2d[_0x2a4c('0x61')];_0x217202++){_0x5daa2d[_0x217202][_0x2a4c('0x10c')](_0x2a4c('0xa4'),_0x2a4c('0x115'));}return _0x5daa2d;}));_0x5cf231[_0x2a4c('0x8f')](_0x13585c[_0x2a4c('0x116')]()[_0x2a4c('0x33')](function(_0x5da253){for(var _0x5cab77=0x0;_0x5cab77<_0x5da253[_0x2a4c('0x61')];_0x5cab77++){_0x5da253[_0x5cab77]['setDataValue'](_0x2a4c('0xa4'),_0x2a4c('0x11e'));}return _0x5da253;}));return BPromise[_0x2a4c('0x90')](_0x5cf231);})[_0x2a4c('0x33')](function(_0x5aa8e6){var _0x47b34e=_[_0x2a4c('0x117')](_0x5aa8e6);_0x5cf231=[];return db[_0x2a4c('0x57')][_0x2a4c('0x118')](function(_0x32700d){for(var _0x309d4e=0x0;_0x309d4e<_0x47b34e[_0x2a4c('0x61')];_0x309d4e++){_0x5cf231['push'](_0x47b34e[_0x309d4e][_0x2a4c('0x11f')](_0x5e1b48['id']),{'transaction':_0x32700d});}return BPromise[_0x2a4c('0x90')](_0x5cf231)[_0x2a4c('0x33')](function(){if(_0x5e1b48[_0x2a4c('0xa5')]){return BPromise[_0x2a4c('0x91')](_[_0x2a4c('0x3a')](_0x47b34e,function(_0x4db0b4){return _0x4db0b4[_0x2a4c('0x119')](_0x2a4c('0xa4'))===_0x2a4c('0x10d');}),function(_0x26c2e6){return db[_0x2a4c('0xb6')][_0x2a4c('0x34')]({'where':{'VoiceQueueId':_0x26c2e6['id'],'UserId':_0x5e1b48['id']},'transaction':_0x32700d});});}else{return;}})[_0x2a4c('0x33')](function(){for(var _0x2cceb6=0x0;_0x2cceb6<_0x47b34e[_0x2a4c('0x61')];_0x2cceb6++){var _0x6f73a8=_0x47b34e[_0x2cceb6][_0x2a4c('0x119')](_0x2a4c('0xa4'));var _0x1c9901=_0x6f73a8+_0x2a4c('0xaf');socket[_0x2a4c('0xb0')](_0x2a4c('0x81')+_0x6f73a8+'Queue:remove',{'UserId':_0x5e1b48['id'],['queueField']:_0x47b34e[_0x2cceb6]['id']});}});});});}});}})[_0x2a4c('0x33')](respondWithStatusCode(_0x429f78,null))['catch'](handleError(_0x429f78,null));};exports['getLists']=function(_0xe7b65f,_0x111693,_0x4b9f0b){var _0x2c6246={};var _0xa9e0f6={};var _0x123bfd;var _0xc7bbd2;return db[_0x2a4c('0x44')][_0x2a4c('0xc3')]({'where':{'id':_0xe7b65f[_0x2a4c('0x64')]['id']}})[_0x2a4c('0x33')](handleEntityNotFound(_0x111693,null))[_0x2a4c('0x33')](function(_0x4317c1){if(_0x4317c1){_0x123bfd=_0x4317c1;_0xa9e0f6[_0x2a4c('0x47')]=_[_0x2a4c('0x4b')](db[_0x2a4c('0x120')]['rawAttributes']);_0xa9e0f6[_0x2a4c('0x4a')]=_['keys'](_0xe7b65f['query']);_0xa9e0f6[_0x2a4c('0x4c')]=_[_0x2a4c('0x4d')](_0xa9e0f6[_0x2a4c('0x47')],_0xa9e0f6[_0x2a4c('0x4a')]);_0x2c6246[_0x2a4c('0x4f')]=_['intersection'](_0xa9e0f6[_0x2a4c('0x47')],qs[_0x2a4c('0x4e')](_0xe7b65f[_0x2a4c('0x4a')][_0x2a4c('0x4e')]));_0x2c6246['attributes']=_0x2c6246[_0x2a4c('0x4f')]['length']?_0x2c6246['attributes']:_0xa9e0f6[_0x2a4c('0x47')];_0x2c6246[_0x2a4c('0xc5')]=qs[_0x2a4c('0x52')](_0xe7b65f['query'][_0x2a4c('0x52')]);_0x2c6246[_0x2a4c('0x53')]=qs[_0x2a4c('0x4c')](_[_0x2a4c('0x54')](_0xe7b65f[_0x2a4c('0x4a')],_0xa9e0f6[_0x2a4c('0x4c')]));if(_0xe7b65f['query']['filter']){_0x2c6246[_0x2a4c('0x53')]=_[_0x2a4c('0x55')](_0x2c6246['where'],{'$or':_[_0x2a4c('0x3b')](_0x2c6246[_0x2a4c('0x4f')],function(_0x2c6aaa){var _0x1854b6={};_0x1854b6[_0x2c6aaa]={'$like':'%'+_0xe7b65f['query'][_0x2a4c('0x3a')]+'%'};return _0x1854b6;})});}_0x2c6246=_[_0x2a4c('0x55')]({},_0x2c6246,_0xe7b65f[_0x2a4c('0x59')]);return _0x123bfd[_0x2a4c('0x121')](_0x2c6246);}})[_0x2a4c('0x33')](function(_0x302ed8){if(_0x302ed8){_0xc7bbd2=_0x302ed8[_0x2a4c('0x61')];if(!_0xe7b65f[_0x2a4c('0x4a')][_0x2a4c('0x50')]('nolimit')){_0x2c6246['limit']=qs[_0x2a4c('0x2d')](_0xe7b65f['query'][_0x2a4c('0x2d')]);_0x2c6246[_0x2a4c('0x2c')]=qs['offset'](_0xe7b65f[_0x2a4c('0x4a')]['offset']);}return _0x123bfd[_0x2a4c('0x121')](_0x2c6246);}})['then'](function(_0x2997c9){if(_0x2997c9){return _0x2997c9?{'count':_0xc7bbd2,'rows':_0x2997c9}:null;}})['then'](respondWithResult(_0x111693,null))[_0x2a4c('0x5e')](handleError(_0x111693,null));};exports[_0x2a4c('0x122')]=function(_0x1623df,_0x45d4dd,_0x3cfd9f){var _0x40fabb={};var _0x572b53={};var _0xc8bb1e;var _0x328ca0;return db[_0x2a4c('0x44')]['findOne']({'where':{'id':_0x1623df['params']['id']}})['then'](handleEntityNotFound(_0x45d4dd,null))[_0x2a4c('0x33')](function(_0x3c7fb1){if(_0x3c7fb1){_0xc8bb1e=_0x3c7fb1;_0x572b53[_0x2a4c('0x47')]=_[_0x2a4c('0x4b')](db[_0x2a4c('0x44')][_0x2a4c('0x45')]);_0x572b53[_0x2a4c('0x4a')]=_['keys'](_0x1623df['query']);_0x572b53[_0x2a4c('0x4c')]=_['intersection'](_0x572b53[_0x2a4c('0x47')],_0x572b53[_0x2a4c('0x4a')]);_0x40fabb[_0x2a4c('0x4f')]=_['intersection'](_0x572b53['model'],qs[_0x2a4c('0x4e')](_0x1623df[_0x2a4c('0x4a')][_0x2a4c('0x4e')]));_0x40fabb[_0x2a4c('0x4f')]=_0x40fabb[_0x2a4c('0x4f')][_0x2a4c('0x61')]?_0x40fabb[_0x2a4c('0x4f')]:_0x572b53[_0x2a4c('0x47')];_0x40fabb[_0x2a4c('0xc5')]=qs[_0x2a4c('0x52')](_0x1623df[_0x2a4c('0x4a')][_0x2a4c('0x52')]);_0x40fabb[_0x2a4c('0x53')]=qs[_0x2a4c('0x4c')](_[_0x2a4c('0x54')](_0x1623df['query'],_0x572b53[_0x2a4c('0x4c')]));if(_0x1623df[_0x2a4c('0x4a')][_0x2a4c('0x3a')]){_0x40fabb[_0x2a4c('0x53')]=_['merge'](_0x40fabb[_0x2a4c('0x53')],{'$or':_[_0x2a4c('0x3b')](_0x40fabb[_0x2a4c('0x4f')],function(_0x116ea7){var _0xe109e={};_0xe109e[_0x116ea7]={'$like':'%'+_0x1623df[_0x2a4c('0x4a')][_0x2a4c('0x3a')]+'%'};return _0xe109e;})});}_0x40fabb['model']=db[_0x2a4c('0x44')];_0x40fabb['as']='Agents';_0x40fabb=_[_0x2a4c('0x55')]({},_0x40fabb,_0x1623df[_0x2a4c('0x59')]);return _0xc8bb1e[_0x2a4c('0xeb')]({'include':[_0x40fabb]});}})[_0x2a4c('0x33')](function(_0x4f580d){if(_0x4f580d){var _0x542ccf={},_0x2a424c=[],_0x59e623=0x0;for(var _0x2f1abe=0x0;_0x2f1abe<_0x4f580d[_0x2a4c('0x61')];_0x2f1abe+=0x1){for(var _0x406b94=0x0,_0x4ef33f;_0x406b94<_0x4f580d[_0x2f1abe][_0x2a4c('0x37')][_0x2a4c('0x61')];_0x406b94+=0x1){_0x4ef33f=_0x4f580d[_0x2f1abe][_0x2a4c('0x37')][_0x406b94][_0x2a4c('0x35')]({'plain':!![]});_0x542ccf[_0x4ef33f['id']]=_0x4ef33f;}}_0x542ccf=_[_0x2a4c('0x123')](_0x542ccf);for(var _0x35ec52=qs['offset'](_0x1623df[_0x2a4c('0x4a')][_0x2a4c('0x2c')]);_0x35ec52<_0x542ccf['length']&&_0x2a424c[_0x2a4c('0x61')]<qs[_0x2a4c('0x2d')](_0x1623df[_0x2a4c('0x4a')][_0x2a4c('0x2d')]);_0x35ec52+=0x1){if(_0x542ccf[_0x35ec52]){_0x2a424c[_0x2a4c('0x8f')](_0x542ccf[_0x35ec52]);}}return{'count':_0x542ccf[_0x2a4c('0x61')],'rows':_0x2a424c};}})[_0x2a4c('0x33')](respondWithResult(_0x45d4dd,null))['catch'](handleError(_0x45d4dd,null));};exports[_0x2a4c('0x34')]=function(_0x696a25,_0x59099a){if(_0x696a25[_0x2a4c('0x81')]['id']==_0x696a25['params']['id']){return _0x59099a[_0x2a4c('0x28')](0x1f4)['send']({'message':_0x2a4c('0x124')});}return db[_0x2a4c('0x44')]['find']({'where':{'id':_0x696a25[_0x2a4c('0x64')]['id']}})[_0x2a4c('0x33')](handleEntityNotFound(_0x59099a,null))[_0x2a4c('0x33')](removeEntity(_0x59099a,null))['catch'](handleError(_0x59099a,null));};exports[_0x2a4c('0x125')]=function(_0x15d469,_0x4cae65,_0x56a0ca){return db['User']['find']({'where':{'id':_0x15d469['params']['id']}})['then'](handleEntityNotFound(_0x4cae65,null))[_0x2a4c('0x33')](function(_0x1c3b7c){if(_0x1c3b7c){return _0x1c3b7c[_0x2a4c('0x125')](_0x15d469[_0x2a4c('0x63')][_0x2a4c('0xac')],_[_0x2a4c('0x67')](_0x15d469[_0x2a4c('0x63')],[_0x2a4c('0xac'),'id'])||{})[_0x2a4c('0xae')](function(){for(var _0x460f4=0x0;_0x460f4<_0x15d469['body'][_0x2a4c('0xac')]['length'];_0x460f4+=0x1){socket[_0x2a4c('0xb0')](_0x2a4c('0x126'),{'ChatInteractionId':Number(_0x15d469['body'][_0x2a4c('0xac')][_0x460f4]),'UserId':Number(_0x15d469[_0x2a4c('0x64')]['id'])});}return _0x15d469[_0x2a4c('0x63')][_0x2a4c('0xac')];});}})[_0x2a4c('0x33')](respondWithResult(_0x4cae65,null))[_0x2a4c('0x5e')](handleError(_0x4cae65,null));};exports['removeChatInteractions']=function(_0x4b24ee,_0x472e52,_0xcae038){return db['User']['find']({'where':{'id':_0x4b24ee['params']['id']}})[_0x2a4c('0x33')](handleEntityNotFound(_0x472e52,null))[_0x2a4c('0x33')](function(_0xfb78ed){if(_0xfb78ed){return _0xfb78ed['removeChatInteractions'](_0x4b24ee['query']['ids'])['then'](function(){if(_[_0x2a4c('0x127')](_0x4b24ee['query']['ids'])){for(var _0x117ccd=0x0;_0x117ccd<_0x4b24ee['query'][_0x2a4c('0xac')][_0x2a4c('0x61')];_0x117ccd+=0x1){socket[_0x2a4c('0xb0')](_0x2a4c('0x128'),{'ChatInteractionId':Number(_0x4b24ee[_0x2a4c('0x4a')]['ids'][_0x117ccd]),'UserId':Number(_0x4b24ee[_0x2a4c('0x64')]['id'])});}}else{socket[_0x2a4c('0xb0')](_0x2a4c('0x128'),{'ChatInteractionId':Number(_0x4b24ee[_0x2a4c('0x4a')][_0x2a4c('0xac')]),'UserId':Number(_0x4b24ee[_0x2a4c('0x64')]['id'])});}});}})['then'](respondWithStatusCode(_0x472e52,null))[_0x2a4c('0x5e')](handleError(_0x472e52,null));};exports[_0x2a4c('0x129')]=function(_0x29cb7d,_0x85e4c4,_0x55cf9b){return db[_0x2a4c('0x44')][_0x2a4c('0x62')]({'where':{'id':_0x29cb7d[_0x2a4c('0x64')]['id']}})['then'](handleEntityNotFound(_0x85e4c4,null))[_0x2a4c('0x33')](function(_0x1d0994){if(_0x1d0994){return _0x1d0994[_0x2a4c('0x129')](_0x29cb7d[_0x2a4c('0x63')][_0x2a4c('0xac')],_[_0x2a4c('0x67')](_0x29cb7d[_0x2a4c('0x63')],['ids','id'])||{})[_0x2a4c('0xae')](function(){for(var _0x519577=0x0;_0x519577<_0x29cb7d[_0x2a4c('0x63')][_0x2a4c('0xac')][_0x2a4c('0x61')];_0x519577+=0x1){socket[_0x2a4c('0xb0')](_0x2a4c('0x12a'),{'MailInteractionId':Number(_0x29cb7d['body'][_0x2a4c('0xac')][_0x519577]),'UserId':Number(_0x29cb7d[_0x2a4c('0x64')]['id'])});}return _0x29cb7d[_0x2a4c('0x63')][_0x2a4c('0xac')];});}})[_0x2a4c('0x33')](respondWithResult(_0x85e4c4,null))['catch'](handleError(_0x85e4c4,null));};exports[_0x2a4c('0x12b')]=function(_0xd8cd18,_0x3c6e11,_0x3df7aa){return db[_0x2a4c('0x44')][_0x2a4c('0x62')]({'where':{'id':_0xd8cd18['params']['id']}})[_0x2a4c('0x33')](handleEntityNotFound(_0x3c6e11,null))[_0x2a4c('0x33')](function(_0xd48634){if(_0xd48634){return _0xd48634[_0x2a4c('0x12b')](_0xd8cd18[_0x2a4c('0x4a')][_0x2a4c('0xac')])[_0x2a4c('0x33')](function(){if(_[_0x2a4c('0x127')](_0xd8cd18[_0x2a4c('0x4a')][_0x2a4c('0xac')])){for(var _0x547cc0=0x0;_0x547cc0<_0xd8cd18['query'][_0x2a4c('0xac')]['length'];_0x547cc0+=0x1){socket[_0x2a4c('0xb0')](_0x2a4c('0x12c'),{'MailInteractionId':Number(_0xd8cd18[_0x2a4c('0x4a')]['ids'][_0x547cc0]),'UserId':Number(_0xd8cd18[_0x2a4c('0x64')]['id'])});}}else{socket[_0x2a4c('0xb0')](_0x2a4c('0x12c'),{'MailInteractionId':Number(_0xd8cd18[_0x2a4c('0x4a')]['ids']),'UserId':Number(_0xd8cd18['params']['id'])});}});}})[_0x2a4c('0x33')](respondWithStatusCode(_0x3c6e11,null))[_0x2a4c('0x5e')](handleError(_0x3c6e11,null));};exports[_0x2a4c('0x12d')]=function(_0x34a4c3,_0x45d85a,_0x28b067){return db[_0x2a4c('0x44')]['find']({'where':{'id':_0x34a4c3['params']['id']}})['then'](handleEntityNotFound(_0x45d85a,null))['then'](function(_0x588e1d){if(_0x588e1d){return _0x588e1d[_0x2a4c('0x12d')](_0x34a4c3[_0x2a4c('0x63')][_0x2a4c('0xac')],_[_0x2a4c('0x67')](_0x34a4c3[_0x2a4c('0x63')],[_0x2a4c('0xac'),'id'])||{})['spread'](function(){for(var _0x5984c7=0x0;_0x5984c7<_0x34a4c3[_0x2a4c('0x63')][_0x2a4c('0xac')]['length'];_0x5984c7+=0x1){socket['emit']('user_has_fax_interactions:save',{'FaxInteractionId':Number(_0x34a4c3[_0x2a4c('0x63')]['ids'][_0x5984c7]),'UserId':Number(_0x34a4c3['params']['id'])});}return _0x34a4c3[_0x2a4c('0x63')][_0x2a4c('0xac')];});}})['then'](respondWithResult(_0x45d85a,null))['catch'](handleError(_0x45d85a,null));};exports[_0x2a4c('0x12e')]=function(_0x413d46,_0x122b31,_0x5b0b85){return db['User'][_0x2a4c('0x62')]({'where':{'id':_0x413d46[_0x2a4c('0x64')]['id']}})[_0x2a4c('0x33')](handleEntityNotFound(_0x122b31,null))[_0x2a4c('0x33')](function(_0x91c54){if(_0x91c54){return _0x91c54[_0x2a4c('0x12e')](_0x413d46['query']['ids'])[_0x2a4c('0x33')](function(){if(_[_0x2a4c('0x127')](_0x413d46[_0x2a4c('0x4a')][_0x2a4c('0xac')])){for(var _0x14aae0=0x0;_0x14aae0<_0x413d46['query'][_0x2a4c('0xac')][_0x2a4c('0x61')];_0x14aae0+=0x1){socket[_0x2a4c('0xb0')]('user_has_fax_interactions:remove',{'FaxInteractionId':Number(_0x413d46[_0x2a4c('0x4a')]['ids'][_0x14aae0]),'UserId':Number(_0x413d46[_0x2a4c('0x64')]['id'])});}}else{socket[_0x2a4c('0xb0')](_0x2a4c('0x12f'),{'FaxInteractionId':Number(_0x413d46[_0x2a4c('0x4a')][_0x2a4c('0xac')]),'UserId':Number(_0x413d46[_0x2a4c('0x64')]['id'])});}});}})[_0x2a4c('0x33')](respondWithStatusCode(_0x122b31,null))[_0x2a4c('0x5e')](handleError(_0x122b31,null));};exports[_0x2a4c('0x130')]=function(_0x4868f2,_0x43650d,_0x43fa5d){return db[_0x2a4c('0x44')][_0x2a4c('0x62')]({'where':{'id':_0x4868f2[_0x2a4c('0x64')]['id']}})['then'](handleEntityNotFound(_0x43650d,null))[_0x2a4c('0x33')](function(_0x55e5e3){if(_0x55e5e3){return _0x55e5e3[_0x2a4c('0x130')](_0x4868f2[_0x2a4c('0x63')][_0x2a4c('0xac')],_['omit'](_0x4868f2[_0x2a4c('0x63')],[_0x2a4c('0xac'),'id'])||{})[_0x2a4c('0xae')](function(){for(var _0x1db32f=0x0;_0x1db32f<_0x4868f2[_0x2a4c('0x63')][_0x2a4c('0xac')][_0x2a4c('0x61')];_0x1db32f+=0x1){socket[_0x2a4c('0xb0')](_0x2a4c('0x131'),{'SmsInteractionId':Number(_0x4868f2[_0x2a4c('0x63')][_0x2a4c('0xac')][_0x1db32f]),'UserId':Number(_0x4868f2[_0x2a4c('0x64')]['id'])});}return _0x4868f2['body']['ids'];});}})[_0x2a4c('0x33')](respondWithResult(_0x43650d,null))[_0x2a4c('0x5e')](handleError(_0x43650d,null));};exports[_0x2a4c('0x132')]=function(_0x5d3c14,_0x48e409,_0x3b20ee){return db[_0x2a4c('0x44')][_0x2a4c('0x62')]({'where':{'id':_0x5d3c14[_0x2a4c('0x64')]['id']}})[_0x2a4c('0x33')](handleEntityNotFound(_0x48e409,null))[_0x2a4c('0x33')](function(_0x1d82f2){if(_0x1d82f2){return _0x1d82f2['removeSmsInteractions'](_0x5d3c14[_0x2a4c('0x4a')][_0x2a4c('0xac')])[_0x2a4c('0x33')](function(){if(_[_0x2a4c('0x127')](_0x5d3c14[_0x2a4c('0x4a')]['ids'])){for(var _0x28eb49=0x0;_0x28eb49<_0x5d3c14[_0x2a4c('0x4a')][_0x2a4c('0xac')][_0x2a4c('0x61')];_0x28eb49+=0x1){socket[_0x2a4c('0xb0')](_0x2a4c('0x133'),{'SmsInteractionId':Number(_0x5d3c14['query'][_0x2a4c('0xac')][_0x28eb49]),'UserId':Number(_0x5d3c14[_0x2a4c('0x64')]['id'])});}}else{socket[_0x2a4c('0xb0')](_0x2a4c('0x133'),{'SmsInteractionId':Number(_0x5d3c14[_0x2a4c('0x4a')][_0x2a4c('0xac')]),'UserId':Number(_0x5d3c14[_0x2a4c('0x64')]['id'])});}});}})['then'](respondWithStatusCode(_0x48e409,null))['catch'](handleError(_0x48e409,null));};exports[_0x2a4c('0x134')]=function(_0x35cab4,_0x5f5aac,_0x4268c4){return db[_0x2a4c('0x44')][_0x2a4c('0x62')]({'where':{'id':_0x35cab4[_0x2a4c('0x64')]['id']}})[_0x2a4c('0x33')](handleEntityNotFound(_0x5f5aac,null))['then'](function(_0x182507){if(_0x182507){return _0x182507[_0x2a4c('0x134')](_0x35cab4[_0x2a4c('0x63')][_0x2a4c('0xac')],_[_0x2a4c('0x67')](_0x35cab4[_0x2a4c('0x63')],['ids','id'])||{})['spread'](function(){for(var _0x5f46aa=0x0;_0x5f46aa<_0x35cab4[_0x2a4c('0x63')]['ids']['length'];_0x5f46aa+=0x1){socket[_0x2a4c('0xb0')](_0x2a4c('0x135'),{'OpenchannelInteractionId':Number(_0x35cab4[_0x2a4c('0x63')]['ids'][_0x5f46aa]),'UserId':Number(_0x35cab4['params']['id'])});}return _0x35cab4['body']['ids'];});}})['then'](respondWithResult(_0x5f5aac,null))['catch'](handleError(_0x5f5aac,null));};exports[_0x2a4c('0x136')]=function(_0x35550c,_0x215f50,_0x28660c){return db[_0x2a4c('0x44')]['find']({'where':{'id':_0x35550c['params']['id']}})['then'](handleEntityNotFound(_0x215f50,null))[_0x2a4c('0x33')](function(_0x3a5b99){if(_0x3a5b99){return _0x3a5b99['removeOpenchannelInteractions'](_0x35550c[_0x2a4c('0x4a')]['ids'])[_0x2a4c('0x33')](function(){if(_['isArray'](_0x35550c[_0x2a4c('0x4a')][_0x2a4c('0xac')])){for(var _0x3fe471=0x0;_0x3fe471<_0x35550c[_0x2a4c('0x4a')][_0x2a4c('0xac')][_0x2a4c('0x61')];_0x3fe471+=0x1){socket['emit'](_0x2a4c('0x137'),{'OpenchannelInteractionId':Number(_0x35550c[_0x2a4c('0x4a')][_0x2a4c('0xac')][_0x3fe471]),'UserId':Number(_0x35550c['params']['id'])});}}else{socket[_0x2a4c('0xb0')](_0x2a4c('0x137'),{'OpenchannelInteractionId':Number(_0x35550c[_0x2a4c('0x4a')][_0x2a4c('0xac')]),'UserId':Number(_0x35550c['params']['id'])});}});}})[_0x2a4c('0x33')](respondWithStatusCode(_0x215f50,null))['catch'](handleError(_0x215f50,null));};exports[_0x2a4c('0x138')]=function(_0x36a350,_0x37705b,_0x511c10){return db[_0x2a4c('0x44')]['find']({'where':{'id':_0x36a350[_0x2a4c('0x64')]['id']}})[_0x2a4c('0x33')](handleEntityNotFound(_0x37705b,null))['then'](function(_0xd1ee2f){if(_0xd1ee2f){return _0xd1ee2f[_0x2a4c('0x138')](_0x36a350['body'][_0x2a4c('0xac')],_[_0x2a4c('0x67')](_0x36a350[_0x2a4c('0x63')],[_0x2a4c('0xac'),'id'])||{})['spread'](function(){for(var _0x196880=0x0;_0x196880<_0x36a350['body'][_0x2a4c('0xac')][_0x2a4c('0x61')];_0x196880+=0x1){socket[_0x2a4c('0xb0')]('user_has_whatsapp_interactions:save',{'WhatsappInteractionId':Number(_0x36a350[_0x2a4c('0x63')][_0x2a4c('0xac')][_0x196880]),'UserId':Number(_0x36a350[_0x2a4c('0x64')]['id'])});}return _0x36a350[_0x2a4c('0x63')][_0x2a4c('0xac')];});}})[_0x2a4c('0x33')](respondWithResult(_0x37705b,null))['catch'](handleError(_0x37705b,null));};exports[_0x2a4c('0x139')]=function(_0x49ec01,_0x11c535,_0x433796){return db[_0x2a4c('0x44')][_0x2a4c('0x62')]({'where':{'id':_0x49ec01[_0x2a4c('0x64')]['id']}})[_0x2a4c('0x33')](handleEntityNotFound(_0x11c535,null))[_0x2a4c('0x33')](function(_0x30dddc){if(_0x30dddc){return _0x30dddc[_0x2a4c('0x139')](_0x49ec01[_0x2a4c('0x4a')][_0x2a4c('0xac')]);}})['then'](respondWithStatusCode(_0x11c535,null))[_0x2a4c('0x5e')](handleError(_0x11c535,null));};exports[_0x2a4c('0x13a')]=function(_0x253a05,_0x340f7e,_0x3437af){var _0x3b4372={};var _0x38504a={};var _0x49943e;var _0x598810;return db['User'][_0x2a4c('0xc3')]({'where':{'id':_0x253a05[_0x2a4c('0x64')]['id']}})['then'](handleEntityNotFound(_0x340f7e,null))[_0x2a4c('0x33')](function(_0x56ced7){if(_0x56ced7){_0x49943e=_0x56ced7;_0x38504a['model']=_['keys'](db[_0x2a4c('0x13b')]['rawAttributes']);_0x38504a['query']=_['keys'](_0x253a05[_0x2a4c('0x4a')]);_0x38504a[_0x2a4c('0x4c')]=_[_0x2a4c('0x4d')](_0x38504a[_0x2a4c('0x47')],_0x38504a['query']);_0x3b4372[_0x2a4c('0x4f')]=_[_0x2a4c('0x4d')](_0x38504a[_0x2a4c('0x47')],qs['fields'](_0x253a05[_0x2a4c('0x4a')]['fields']));_0x3b4372['attributes']=_0x3b4372['attributes']['length']?_0x3b4372[_0x2a4c('0x4f')]:_0x38504a[_0x2a4c('0x47')];_0x3b4372[_0x2a4c('0xc5')]=qs[_0x2a4c('0x52')](_0x253a05[_0x2a4c('0x4a')][_0x2a4c('0x52')]);_0x3b4372['where']=qs['filters'](_[_0x2a4c('0x54')](_0x253a05[_0x2a4c('0x4a')],_0x38504a[_0x2a4c('0x4c')]));if(_0x253a05[_0x2a4c('0x4a')][_0x2a4c('0x3a')]){_0x3b4372['where']=_['merge'](_0x3b4372[_0x2a4c('0x53')],{'$or':_['map'](_0x3b4372[_0x2a4c('0x4f')],function(_0x22379e){var _0x5da8dc={};_0x5da8dc[_0x22379e]={'$like':'%'+_0x253a05[_0x2a4c('0x4a')][_0x2a4c('0x3a')]+'%'};return _0x5da8dc;})});}_0x3b4372=_[_0x2a4c('0x55')]({},_0x3b4372,_0x253a05[_0x2a4c('0x59')]);return _0x49943e['getVoicePrefixes'](_0x3b4372);}})[_0x2a4c('0x33')](function(_0x25aa63){if(_0x25aa63){_0x598810=_0x25aa63[_0x2a4c('0x61')];if(!_0x253a05['query'][_0x2a4c('0x50')](_0x2a4c('0x51'))){_0x3b4372[_0x2a4c('0x2d')]=qs[_0x2a4c('0x2d')](_0x253a05['query'][_0x2a4c('0x2d')]);_0x3b4372['offset']=qs['offset'](_0x253a05[_0x2a4c('0x4a')][_0x2a4c('0x2c')]);}return _0x49943e['getVoicePrefixes'](_0x3b4372);}})[_0x2a4c('0x33')](function(_0x4d7e6d){if(_0x4d7e6d){return _0x4d7e6d?{'count':_0x598810,'rows':_0x4d7e6d}:null;}})[_0x2a4c('0x33')](respondWithResult(_0x340f7e,null))['catch'](handleError(_0x340f7e,null));};exports[_0x2a4c('0x13c')]=function(_0x59fbbd,_0x53b0d2,_0x1b8435){var _0x426dcb={};var _0x32ee9e={};var _0x5badf4;var _0x590479;return db[_0x2a4c('0x44')]['findOne']({'where':{'id':_0x59fbbd['params']['id']}})[_0x2a4c('0x33')](handleEntityNotFound(_0x53b0d2,null))['then'](function(_0x3ee449){if(_0x3ee449){_0x5badf4=_0x3ee449;_0x32ee9e['model']=_[_0x2a4c('0x4b')](db[_0x2a4c('0x13d')][_0x2a4c('0x45')]);_0x32ee9e[_0x2a4c('0x4a')]=_['keys'](_0x59fbbd['query']);_0x32ee9e['filters']=_['intersection'](_0x32ee9e[_0x2a4c('0x47')],_0x32ee9e[_0x2a4c('0x4a')]);_0x426dcb[_0x2a4c('0x4f')]=_[_0x2a4c('0x4d')](_0x32ee9e[_0x2a4c('0x47')],qs[_0x2a4c('0x4e')](_0x59fbbd['query'][_0x2a4c('0x4e')]));_0x426dcb[_0x2a4c('0x4f')]=_0x426dcb[_0x2a4c('0x4f')][_0x2a4c('0x61')]?_0x426dcb[_0x2a4c('0x4f')]:_0x32ee9e[_0x2a4c('0x47')];_0x426dcb[_0x2a4c('0xc5')]=qs[_0x2a4c('0x52')](_0x59fbbd[_0x2a4c('0x4a')]['sort']);_0x426dcb['where']=qs[_0x2a4c('0x4c')](_['pick'](_0x59fbbd[_0x2a4c('0x4a')],_0x32ee9e[_0x2a4c('0x4c')]));if(_0x59fbbd[_0x2a4c('0x4a')][_0x2a4c('0x3a')]){_0x426dcb[_0x2a4c('0x53')]=_[_0x2a4c('0x55')](_0x426dcb['where'],{'$or':_[_0x2a4c('0x3b')](_0x426dcb[_0x2a4c('0x4f')],function(_0x4981ac){var _0x5b6026={};_0x5b6026[_0x4981ac]={'$like':'%'+_0x59fbbd[_0x2a4c('0x4a')][_0x2a4c('0x3a')]+'%'};return _0x5b6026;})});}_0x426dcb=_['merge']({},_0x426dcb,_0x59fbbd[_0x2a4c('0x59')]);return _0x5badf4[_0x2a4c('0x13c')](_0x426dcb);}})[_0x2a4c('0x33')](function(_0x5cb0fc){if(_0x5cb0fc){_0x590479=_0x5cb0fc['length'];if(!_0x59fbbd[_0x2a4c('0x4a')][_0x2a4c('0x50')](_0x2a4c('0x51'))){_0x426dcb[_0x2a4c('0x2d')]=qs[_0x2a4c('0x2d')](_0x59fbbd['query']['limit']);_0x426dcb[_0x2a4c('0x2c')]=qs[_0x2a4c('0x2c')](_0x59fbbd[_0x2a4c('0x4a')][_0x2a4c('0x2c')]);}return _0x5badf4[_0x2a4c('0x13c')](_0x426dcb);}})[_0x2a4c('0x33')](function(_0x5825b4){if(_0x5825b4){return _0x5825b4?{'count':_0x590479,'rows':_0x5825b4}:null;}})[_0x2a4c('0x33')](respondWithResult(_0x53b0d2,null))['catch'](handleError(_0x53b0d2,null));};exports[_0x2a4c('0x13e')]=function(_0xc8cbdc,_0x299c05,_0x189d40){return db[_0x2a4c('0x44')][_0x2a4c('0x62')]({'where':{'id':_0xc8cbdc[_0x2a4c('0x64')]['id']}})[_0x2a4c('0x33')](handleEntityNotFound(_0x299c05,null))[_0x2a4c('0x33')](function(_0x38e616){if(_0x38e616){return _0x38e616['addFaxAccounts'](_0xc8cbdc[_0x2a4c('0x63')]['ids'],_[_0x2a4c('0x67')](_0xc8cbdc['body'],['ids','id'])||{});}})['then'](respondWithResult(_0x299c05,null))[_0x2a4c('0x5e')](handleError(_0x299c05,null));};exports[_0x2a4c('0x13f')]=function(_0x1d1083,_0x4e73d0,_0x40dd89){return db[_0x2a4c('0x44')][_0x2a4c('0x62')]({'where':{'id':_0x1d1083[_0x2a4c('0x64')]['id']}})[_0x2a4c('0x33')](handleEntityNotFound(_0x4e73d0,null))[_0x2a4c('0x33')](function(_0xa0ff0f){if(_0xa0ff0f){return _0xa0ff0f['removeFaxAccounts'](_0x1d1083[_0x2a4c('0x4a')]['ids']);}})['then'](respondWithStatusCode(_0x4e73d0,null))['catch'](handleError(_0x4e73d0,null));};exports[_0x2a4c('0x140')]=function(_0x3f64f1,_0x53eb12,_0x4dd9fc){var _0x2d1cf5={};var _0x2b719f={};var _0x559831;var _0x4ea273;return db[_0x2a4c('0x44')][_0x2a4c('0xc3')]({'where':{'id':_0x3f64f1['params']['id']}})[_0x2a4c('0x33')](handleEntityNotFound(_0x53eb12,null))[_0x2a4c('0x33')](function(_0x32e341){if(_0x32e341){_0x559831=_0x32e341;_0x2b719f[_0x2a4c('0x47')]=_[_0x2a4c('0x4b')](db['MailAccount'][_0x2a4c('0x45')]);_0x2b719f[_0x2a4c('0x4a')]=_[_0x2a4c('0x4b')](_0x3f64f1[_0x2a4c('0x4a')]);_0x2b719f['filters']=_[_0x2a4c('0x4d')](_0x2b719f['model'],_0x2b719f['query']);_0x2d1cf5[_0x2a4c('0x4f')]=_['intersection'](_0x2b719f[_0x2a4c('0x47')],qs['fields'](_0x3f64f1['query']['fields']));_0x2d1cf5['attributes']=_0x2d1cf5[_0x2a4c('0x4f')][_0x2a4c('0x61')]?_0x2d1cf5[_0x2a4c('0x4f')]:_0x2b719f[_0x2a4c('0x47')];_0x2d1cf5[_0x2a4c('0xc5')]=qs[_0x2a4c('0x52')](_0x3f64f1[_0x2a4c('0x4a')]['sort']);_0x2d1cf5['where']=qs[_0x2a4c('0x4c')](_[_0x2a4c('0x54')](_0x3f64f1[_0x2a4c('0x4a')],_0x2b719f[_0x2a4c('0x4c')]));if(_0x3f64f1['query']['filter']){_0x2d1cf5['where']=_[_0x2a4c('0x55')](_0x2d1cf5[_0x2a4c('0x53')],{'$or':_[_0x2a4c('0x3b')](_0x2d1cf5[_0x2a4c('0x4f')],function(_0x10777d){var _0x8678b9={};_0x8678b9[_0x10777d]={'$like':'%'+_0x3f64f1['query'][_0x2a4c('0x3a')]+'%'};return _0x8678b9;})});}_0x2d1cf5=_[_0x2a4c('0x55')]({},_0x2d1cf5,_0x3f64f1[_0x2a4c('0x59')]);return _0x559831[_0x2a4c('0x140')](_0x2d1cf5);}})[_0x2a4c('0x33')](function(_0x2ed9ee){if(_0x2ed9ee){_0x4ea273=_0x2ed9ee[_0x2a4c('0x61')];if(!_0x3f64f1[_0x2a4c('0x4a')][_0x2a4c('0x50')]('nolimit')){_0x2d1cf5[_0x2a4c('0x2d')]=qs[_0x2a4c('0x2d')](_0x3f64f1[_0x2a4c('0x4a')]['limit']);_0x2d1cf5[_0x2a4c('0x2c')]=qs['offset'](_0x3f64f1[_0x2a4c('0x4a')][_0x2a4c('0x2c')]);}return _0x559831[_0x2a4c('0x140')](_0x2d1cf5);}})[_0x2a4c('0x33')](function(_0xb50521){if(_0xb50521){return _0xb50521?{'count':_0x4ea273,'rows':_0xb50521}:null;}})[_0x2a4c('0x33')](respondWithResult(_0x53eb12,null))[_0x2a4c('0x5e')](handleError(_0x53eb12,null));};exports[_0x2a4c('0x141')]=function(_0x2035fa,_0xc09ba3,_0x261392){return db[_0x2a4c('0x44')]['find']({'where':{'id':_0x2035fa[_0x2a4c('0x64')]['id']}})['then'](handleEntityNotFound(_0xc09ba3,null))[_0x2a4c('0x33')](function(_0x464392){if(_0x464392){return _0x464392[_0x2a4c('0x141')](_0x2035fa[_0x2a4c('0x63')][_0x2a4c('0xac')],_[_0x2a4c('0x67')](_0x2035fa[_0x2a4c('0x63')],['ids','id'])||{});}})['then'](respondWithResult(_0xc09ba3,null))[_0x2a4c('0x5e')](handleError(_0xc09ba3,null));};exports[_0x2a4c('0x142')]=function(_0xfba36b,_0x2cc579,_0x3e8bd1){return db['User']['find']({'where':{'id':_0xfba36b['params']['id']}})[_0x2a4c('0x33')](handleEntityNotFound(_0x2cc579,null))[_0x2a4c('0x33')](function(_0xfa282b){if(_0xfa282b){return _0xfa282b['removeMailAccounts'](_0xfba36b[_0x2a4c('0x4a')]['ids']);}})[_0x2a4c('0x33')](respondWithStatusCode(_0x2cc579,null))[_0x2a4c('0x5e')](handleError(_0x2cc579,null));};exports[_0x2a4c('0x143')]=function(_0x52f9f2,_0x444b9e,_0x3b9055){var _0x17768b={};var _0x508d92={};var _0x331234;var _0x59e4b8;return db[_0x2a4c('0x44')]['findOne']({'where':{'id':_0x52f9f2['params']['id']}})['then'](handleEntityNotFound(_0x444b9e,null))[_0x2a4c('0x33')](function(_0x368ec5){if(_0x368ec5){_0x331234=_0x368ec5;_0x508d92[_0x2a4c('0x47')]=_[_0x2a4c('0x4b')](db[_0x2a4c('0x144')][_0x2a4c('0x45')]);_0x508d92[_0x2a4c('0x4a')]=_['keys'](_0x52f9f2[_0x2a4c('0x4a')]);_0x508d92[_0x2a4c('0x4c')]=_[_0x2a4c('0x4d')](_0x508d92[_0x2a4c('0x47')],_0x508d92['query']);_0x17768b[_0x2a4c('0x4f')]=_[_0x2a4c('0x4d')](_0x508d92['model'],qs['fields'](_0x52f9f2[_0x2a4c('0x4a')][_0x2a4c('0x4e')]));_0x17768b[_0x2a4c('0x4f')]=_0x17768b[_0x2a4c('0x4f')][_0x2a4c('0x61')]?_0x17768b[_0x2a4c('0x4f')]:_0x508d92[_0x2a4c('0x47')];_0x17768b['order']=qs[_0x2a4c('0x52')](_0x52f9f2['query'][_0x2a4c('0x52')]);_0x17768b['where']=qs[_0x2a4c('0x4c')](_[_0x2a4c('0x54')](_0x52f9f2[_0x2a4c('0x4a')],_0x508d92[_0x2a4c('0x4c')]));if(_0x52f9f2[_0x2a4c('0x4a')][_0x2a4c('0x3a')]){_0x17768b[_0x2a4c('0x53')]=_['merge'](_0x17768b[_0x2a4c('0x53')],{'$or':_[_0x2a4c('0x3b')](_0x17768b[_0x2a4c('0x4f')],function(_0x5b3a5a){var _0x35b5c7={};_0x35b5c7[_0x5b3a5a]={'$like':'%'+_0x52f9f2[_0x2a4c('0x4a')][_0x2a4c('0x3a')]+'%'};return _0x35b5c7;})});}_0x17768b=_[_0x2a4c('0x55')]({},_0x17768b,_0x52f9f2[_0x2a4c('0x59')]);return _0x331234['getOpenchannelAccounts'](_0x17768b);}})[_0x2a4c('0x33')](function(_0x4dfd37){if(_0x4dfd37){_0x59e4b8=_0x4dfd37[_0x2a4c('0x61')];if(!_0x52f9f2[_0x2a4c('0x4a')]['hasOwnProperty'](_0x2a4c('0x51'))){_0x17768b[_0x2a4c('0x2d')]=qs['limit'](_0x52f9f2['query']['limit']);_0x17768b[_0x2a4c('0x2c')]=qs['offset'](_0x52f9f2[_0x2a4c('0x4a')][_0x2a4c('0x2c')]);}return _0x331234[_0x2a4c('0x143')](_0x17768b);}})[_0x2a4c('0x33')](function(_0xe3416){if(_0xe3416){return _0xe3416?{'count':_0x59e4b8,'rows':_0xe3416}:null;}})[_0x2a4c('0x33')](respondWithResult(_0x444b9e,null))[_0x2a4c('0x5e')](handleError(_0x444b9e,null));};exports[_0x2a4c('0x145')]=function(_0x15a830,_0x1ab1c6,_0x821cf7){return db['User']['find']({'where':{'id':_0x15a830[_0x2a4c('0x64')]['id']}})[_0x2a4c('0x33')](handleEntityNotFound(_0x1ab1c6,null))[_0x2a4c('0x33')](function(_0x4221a9){if(_0x4221a9){return _0x4221a9[_0x2a4c('0x145')](_0x15a830[_0x2a4c('0x63')][_0x2a4c('0xac')],_['omit'](_0x15a830[_0x2a4c('0x63')],[_0x2a4c('0xac'),'id'])||{});}})[_0x2a4c('0x33')](respondWithResult(_0x1ab1c6,null))[_0x2a4c('0x5e')](handleError(_0x1ab1c6,null));};exports['removeOpenchannelAccounts']=function(_0x3bca4d,_0x7fa91d,_0x4fd7af){return db[_0x2a4c('0x44')]['find']({'where':{'id':_0x3bca4d[_0x2a4c('0x64')]['id']}})[_0x2a4c('0x33')](handleEntityNotFound(_0x7fa91d,null))[_0x2a4c('0x33')](function(_0x5e172c){if(_0x5e172c){return _0x5e172c[_0x2a4c('0x146')](_0x3bca4d[_0x2a4c('0x4a')][_0x2a4c('0xac')]);}})[_0x2a4c('0x33')](respondWithStatusCode(_0x7fa91d,null))[_0x2a4c('0x5e')](handleError(_0x7fa91d,null));};exports[_0x2a4c('0x147')]=function(_0x5e31f5,_0x29a3a2,_0xbfd377){var _0x2711cd={};var _0x398758={};var _0x302fc6;var _0x1e5a98;return db[_0x2a4c('0x44')][_0x2a4c('0xc3')]({'where':{'id':_0x5e31f5[_0x2a4c('0x64')]['id']}})[_0x2a4c('0x33')](handleEntityNotFound(_0x29a3a2,null))['then'](function(_0x28de45){if(_0x28de45){_0x302fc6=_0x28de45;_0x398758['model']=_[_0x2a4c('0x4b')](db[_0x2a4c('0x148')]['rawAttributes']);_0x398758[_0x2a4c('0x4a')]=_[_0x2a4c('0x4b')](_0x5e31f5[_0x2a4c('0x4a')]);_0x398758[_0x2a4c('0x4c')]=_[_0x2a4c('0x4d')](_0x398758[_0x2a4c('0x47')],_0x398758[_0x2a4c('0x4a')]);_0x2711cd[_0x2a4c('0x4f')]=_[_0x2a4c('0x4d')](_0x398758['model'],qs['fields'](_0x5e31f5['query'][_0x2a4c('0x4e')]));_0x2711cd[_0x2a4c('0x4f')]=_0x2711cd['attributes']['length']?_0x2711cd['attributes']:_0x398758['model'];_0x2711cd[_0x2a4c('0xc5')]=qs[_0x2a4c('0x52')](_0x5e31f5[_0x2a4c('0x4a')][_0x2a4c('0x52')]);_0x2711cd[_0x2a4c('0x53')]=qs[_0x2a4c('0x4c')](_['pick'](_0x5e31f5[_0x2a4c('0x4a')],_0x398758[_0x2a4c('0x4c')]));if(_0x5e31f5['query'][_0x2a4c('0x3a')]){_0x2711cd[_0x2a4c('0x53')]=_[_0x2a4c('0x55')](_0x2711cd['where'],{'$or':_['map'](_0x2711cd[_0x2a4c('0x4f')],function(_0xe8dcbf){var _0xd9ba16={};_0xd9ba16[_0xe8dcbf]={'$like':'%'+_0x5e31f5[_0x2a4c('0x4a')][_0x2a4c('0x3a')]+'%'};return _0xd9ba16;})});}_0x2711cd=_['merge']({},_0x2711cd,_0x5e31f5['options']);return _0x302fc6[_0x2a4c('0x147')](_0x2711cd);}})[_0x2a4c('0x33')](function(_0x4d0c05){if(_0x4d0c05){_0x1e5a98=_0x4d0c05[_0x2a4c('0x61')];if(!_0x5e31f5[_0x2a4c('0x4a')][_0x2a4c('0x50')](_0x2a4c('0x51'))){_0x2711cd[_0x2a4c('0x2d')]=qs['limit'](_0x5e31f5[_0x2a4c('0x4a')][_0x2a4c('0x2d')]);_0x2711cd[_0x2a4c('0x2c')]=qs['offset'](_0x5e31f5['query'][_0x2a4c('0x2c')]);}return _0x302fc6['getSmsAccounts'](_0x2711cd);}})[_0x2a4c('0x33')](function(_0x11eab8){if(_0x11eab8){return _0x11eab8?{'count':_0x1e5a98,'rows':_0x11eab8}:null;}})[_0x2a4c('0x33')](respondWithResult(_0x29a3a2,null))[_0x2a4c('0x5e')](handleError(_0x29a3a2,null));};exports['addSmsAccounts']=function(_0x8f2042,_0x1c931b,_0x116a7b){return db[_0x2a4c('0x44')][_0x2a4c('0x62')]({'where':{'id':_0x8f2042['params']['id']}})[_0x2a4c('0x33')](handleEntityNotFound(_0x1c931b,null))[_0x2a4c('0x33')](function(_0xf5836c){if(_0xf5836c){return _0xf5836c[_0x2a4c('0x149')](_0x8f2042['body'][_0x2a4c('0xac')],_[_0x2a4c('0x67')](_0x8f2042['body'],[_0x2a4c('0xac'),'id'])||{});}})['then'](respondWithResult(_0x1c931b,null))['catch'](handleError(_0x1c931b,null));};exports[_0x2a4c('0x14a')]=function(_0x3db9a6,_0x3eb2dd,_0x5b4f36){return db[_0x2a4c('0x44')][_0x2a4c('0x62')]({'where':{'id':_0x3db9a6[_0x2a4c('0x64')]['id']}})['then'](handleEntityNotFound(_0x3eb2dd,null))[_0x2a4c('0x33')](function(_0x53d854){if(_0x53d854){return _0x53d854[_0x2a4c('0x14a')](_0x3db9a6['query'][_0x2a4c('0xac')]);}})[_0x2a4c('0x33')](respondWithStatusCode(_0x3eb2dd,null))[_0x2a4c('0x5e')](handleError(_0x3eb2dd,null));};exports['getChatWebsites']=function(_0x41e13e,_0x4e68b1,_0x182464){var _0xdaf77e={};var _0x2ae53c={};var _0x2fda56;var _0xf3d2b8;return db[_0x2a4c('0x44')][_0x2a4c('0xc3')]({'where':{'id':_0x41e13e[_0x2a4c('0x64')]['id']}})[_0x2a4c('0x33')](handleEntityNotFound(_0x4e68b1,null))[_0x2a4c('0x33')](function(_0x316441){if(_0x316441){_0x2fda56=_0x316441;_0x2ae53c['model']=_[_0x2a4c('0x4b')](db[_0x2a4c('0x14b')][_0x2a4c('0x45')]);_0x2ae53c['query']=_['keys'](_0x41e13e[_0x2a4c('0x4a')]);_0x2ae53c[_0x2a4c('0x4c')]=_[_0x2a4c('0x4d')](_0x2ae53c[_0x2a4c('0x47')],_0x2ae53c['query']);_0xdaf77e[_0x2a4c('0x4f')]=_[_0x2a4c('0x4d')](_0x2ae53c[_0x2a4c('0x47')],qs['fields'](_0x41e13e[_0x2a4c('0x4a')][_0x2a4c('0x4e')]));_0xdaf77e[_0x2a4c('0x4f')]=_0xdaf77e[_0x2a4c('0x4f')][_0x2a4c('0x61')]?_0xdaf77e[_0x2a4c('0x4f')]:_0x2ae53c[_0x2a4c('0x47')];_0xdaf77e['order']=qs[_0x2a4c('0x52')](_0x41e13e[_0x2a4c('0x4a')]['sort']);_0xdaf77e[_0x2a4c('0x53')]=qs[_0x2a4c('0x4c')](_[_0x2a4c('0x54')](_0x41e13e[_0x2a4c('0x4a')],_0x2ae53c[_0x2a4c('0x4c')]));if(_0x41e13e['query'][_0x2a4c('0x3a')]){_0xdaf77e[_0x2a4c('0x53')]=_[_0x2a4c('0x55')](_0xdaf77e[_0x2a4c('0x53')],{'$or':_[_0x2a4c('0x3b')](_0xdaf77e['attributes'],function(_0x2438bd){var _0x3db281={};_0x3db281[_0x2438bd]={'$like':'%'+_0x41e13e['query'][_0x2a4c('0x3a')]+'%'};return _0x3db281;})});}_0xdaf77e=_[_0x2a4c('0x55')]({},_0xdaf77e,_0x41e13e[_0x2a4c('0x59')]);return _0x2fda56[_0x2a4c('0x14c')](_0xdaf77e);}})[_0x2a4c('0x33')](function(_0x36827d){if(_0x36827d){_0xf3d2b8=_0x36827d['length'];if(!_0x41e13e[_0x2a4c('0x4a')][_0x2a4c('0x50')]('nolimit')){_0xdaf77e[_0x2a4c('0x2d')]=qs[_0x2a4c('0x2d')](_0x41e13e[_0x2a4c('0x4a')][_0x2a4c('0x2d')]);_0xdaf77e['offset']=qs['offset'](_0x41e13e['query']['offset']);}return _0x2fda56[_0x2a4c('0x14c')](_0xdaf77e);}})[_0x2a4c('0x33')](function(_0x3230cb){if(_0x3230cb){return _0x3230cb?{'count':_0xf3d2b8,'rows':_0x3230cb}:null;}})[_0x2a4c('0x33')](respondWithResult(_0x4e68b1,null))[_0x2a4c('0x5e')](handleError(_0x4e68b1,null));};exports[_0x2a4c('0x14d')]=function(_0x2ebc4c,_0x1f07c4,_0x379901){return db[_0x2a4c('0x44')][_0x2a4c('0x62')]({'where':{'id':_0x2ebc4c['params']['id']}})['then'](handleEntityNotFound(_0x1f07c4,null))[_0x2a4c('0x33')](function(_0x50708b){if(_0x50708b){return _0x50708b[_0x2a4c('0x14d')](_0x2ebc4c['body'][_0x2a4c('0xac')],_['omit'](_0x2ebc4c[_0x2a4c('0x63')],[_0x2a4c('0xac'),'id'])||{});}})[_0x2a4c('0x33')](respondWithResult(_0x1f07c4,null))[_0x2a4c('0x5e')](handleError(_0x1f07c4,null));};exports['removeChatWebsites']=function(_0x3f9a42,_0x4adb23,_0x3188cd){return db['User'][_0x2a4c('0x62')]({'where':{'id':_0x3f9a42[_0x2a4c('0x64')]['id']}})['then'](handleEntityNotFound(_0x4adb23,null))['then'](function(_0x4455bf){if(_0x4455bf){return _0x4455bf[_0x2a4c('0x14e')](_0x3f9a42[_0x2a4c('0x4a')]['ids']);}})[_0x2a4c('0x33')](respondWithStatusCode(_0x4adb23,null))[_0x2a4c('0x5e')](handleError(_0x4adb23,null));};exports[_0x2a4c('0x14f')]=function(_0x3d7a3a,_0x58be93,_0x4aeeb9){var _0x1bd484={};var _0x1f7cc6={};var _0x34c3cf;var _0xea29e8;return db[_0x2a4c('0x44')][_0x2a4c('0xc3')]({'where':{'id':_0x3d7a3a[_0x2a4c('0x64')]['id']}})[_0x2a4c('0x33')](handleEntityNotFound(_0x58be93,null))['then'](function(_0x1b4c4a){if(_0x1b4c4a){_0x34c3cf=_0x1b4c4a;_0x1f7cc6[_0x2a4c('0x47')]=_[_0x2a4c('0x4b')](db[_0x2a4c('0x150')]['rawAttributes']);_0x1f7cc6[_0x2a4c('0x4a')]=_[_0x2a4c('0x4b')](_0x3d7a3a[_0x2a4c('0x4a')]);_0x1f7cc6[_0x2a4c('0x4c')]=_[_0x2a4c('0x4d')](_0x1f7cc6[_0x2a4c('0x47')],_0x1f7cc6[_0x2a4c('0x4a')]);_0x1bd484[_0x2a4c('0x4f')]=_[_0x2a4c('0x4d')](_0x1f7cc6[_0x2a4c('0x47')],qs[_0x2a4c('0x4e')](_0x3d7a3a[_0x2a4c('0x4a')][_0x2a4c('0x4e')]));_0x1bd484[_0x2a4c('0x4f')]=_0x1bd484[_0x2a4c('0x4f')]['length']?_0x1bd484[_0x2a4c('0x4f')]:_0x1f7cc6[_0x2a4c('0x47')];_0x1bd484[_0x2a4c('0xc5')]=qs[_0x2a4c('0x52')](_0x3d7a3a[_0x2a4c('0x4a')][_0x2a4c('0x52')]);_0x1bd484[_0x2a4c('0x53')]=qs[_0x2a4c('0x4c')](_[_0x2a4c('0x54')](_0x3d7a3a[_0x2a4c('0x4a')],_0x1f7cc6['filters']));if(_0x3d7a3a[_0x2a4c('0x4a')][_0x2a4c('0x3a')]){_0x1bd484[_0x2a4c('0x53')]=_[_0x2a4c('0x55')](_0x1bd484[_0x2a4c('0x53')],{'$or':_[_0x2a4c('0x3b')](_0x1bd484[_0x2a4c('0x4f')],function(_0x4d1cea){var _0x6e3166={};_0x6e3166[_0x4d1cea]={'$like':'%'+_0x3d7a3a[_0x2a4c('0x4a')][_0x2a4c('0x3a')]+'%'};return _0x6e3166;})});}_0x1bd484=_[_0x2a4c('0x55')]({},_0x1bd484,_0x3d7a3a['options']);return _0x34c3cf[_0x2a4c('0x14f')](_0x1bd484);}})['then'](function(_0x3bda55){if(_0x3bda55){_0xea29e8=_0x3bda55[_0x2a4c('0x61')];if(!_0x3d7a3a['query'][_0x2a4c('0x50')](_0x2a4c('0x51'))){_0x1bd484[_0x2a4c('0x2d')]=qs[_0x2a4c('0x2d')](_0x3d7a3a['query'][_0x2a4c('0x2d')]);_0x1bd484['offset']=qs['offset'](_0x3d7a3a[_0x2a4c('0x4a')][_0x2a4c('0x2c')]);}return _0x34c3cf['getWhatsappAccounts'](_0x1bd484);}})[_0x2a4c('0x33')](function(_0x522aad){if(_0x522aad){return _0x522aad?{'count':_0xea29e8,'rows':_0x522aad}:null;}})[_0x2a4c('0x33')](respondWithResult(_0x58be93,null))[_0x2a4c('0x5e')](handleError(_0x58be93,null));};exports['addWhatsappAccounts']=function(_0x278012,_0x27c7f5,_0x3dc793){return db[_0x2a4c('0x44')][_0x2a4c('0x62')]({'where':{'id':_0x278012[_0x2a4c('0x64')]['id']}})['then'](handleEntityNotFound(_0x27c7f5,null))[_0x2a4c('0x33')](function(_0x302b84){if(_0x302b84){return _0x302b84[_0x2a4c('0x151')](_0x278012[_0x2a4c('0x63')][_0x2a4c('0xac')],_['omit'](_0x278012[_0x2a4c('0x63')],['ids','id'])||{});}})['then'](respondWithResult(_0x27c7f5,null))['catch'](handleError(_0x27c7f5,null));};exports['removeWhatsappAccounts']=function(_0x275263,_0x3c7dd1,_0xde8b00){return db['User'][_0x2a4c('0x62')]({'where':{'id':_0x275263['params']['id']}})['then'](handleEntityNotFound(_0x3c7dd1,null))[_0x2a4c('0x33')](function(_0x54d88a){if(_0x54d88a){return _0x54d88a[_0x2a4c('0x152')](_0x275263[_0x2a4c('0x4a')][_0x2a4c('0xac')]);}})['then'](respondWithStatusCode(_0x3c7dd1,null))['catch'](handleError(_0x3c7dd1,null));};exports['getSquareProjects']=function(_0x12896a,_0x29a257,_0x1db706){var _0xaefd74={};var _0x4770b7={};var _0xdc6a8e;var _0x441f38;return db[_0x2a4c('0x44')][_0x2a4c('0xc3')]({'where':{'id':_0x12896a[_0x2a4c('0x64')]['id']}})[_0x2a4c('0x33')](handleEntityNotFound(_0x29a257,null))['then'](function(_0x4493ab){if(_0x4493ab){_0xdc6a8e=_0x4493ab;_0x4770b7[_0x2a4c('0x47')]=_[_0x2a4c('0x4b')](db[_0x2a4c('0x153')][_0x2a4c('0x45')]);_0x4770b7[_0x2a4c('0x4a')]=_[_0x2a4c('0x4b')](_0x12896a[_0x2a4c('0x4a')]);_0x4770b7[_0x2a4c('0x4c')]=_[_0x2a4c('0x4d')](_0x4770b7[_0x2a4c('0x47')],_0x4770b7[_0x2a4c('0x4a')]);_0xaefd74[_0x2a4c('0x4f')]=_[_0x2a4c('0x4d')](_0x4770b7[_0x2a4c('0x47')],qs[_0x2a4c('0x4e')](_0x12896a['query']['fields']));_0xaefd74['attributes']=_0xaefd74[_0x2a4c('0x4f')]['length']?_0xaefd74[_0x2a4c('0x4f')]:_0x4770b7[_0x2a4c('0x47')];_0xaefd74['order']=qs['sort'](_0x12896a[_0x2a4c('0x4a')][_0x2a4c('0x52')]);_0xaefd74[_0x2a4c('0x53')]=qs[_0x2a4c('0x4c')](_[_0x2a4c('0x54')](_0x12896a[_0x2a4c('0x4a')],_0x4770b7[_0x2a4c('0x4c')]));if(_0x12896a[_0x2a4c('0x4a')][_0x2a4c('0x3a')]){_0xaefd74['where']=_[_0x2a4c('0x55')](_0xaefd74['where'],{'$or':_[_0x2a4c('0x3b')](_0xaefd74[_0x2a4c('0x4f')],function(_0x4c8e39){var _0x5cba77={};_0x5cba77[_0x4c8e39]={'$like':'%'+_0x12896a[_0x2a4c('0x4a')][_0x2a4c('0x3a')]+'%'};return _0x5cba77;})});}_0xaefd74=_[_0x2a4c('0x55')]({},_0xaefd74,_0x12896a[_0x2a4c('0x59')]);return _0xdc6a8e['getSquareProjects'](_0xaefd74);}})[_0x2a4c('0x33')](function(_0x4e70a4){if(_0x4e70a4){_0x441f38=_0x4e70a4[_0x2a4c('0x61')];if(!_0x12896a['query'][_0x2a4c('0x50')](_0x2a4c('0x51'))){_0xaefd74[_0x2a4c('0x2d')]=qs[_0x2a4c('0x2d')](_0x12896a[_0x2a4c('0x4a')][_0x2a4c('0x2d')]);_0xaefd74['offset']=qs[_0x2a4c('0x2c')](_0x12896a[_0x2a4c('0x4a')]['offset']);}return _0xdc6a8e[_0x2a4c('0x154')](_0xaefd74);}})[_0x2a4c('0x33')](function(_0x3d6a1b){if(_0x3d6a1b){return _0x3d6a1b?{'count':_0x441f38,'rows':_0x3d6a1b}:null;}})['then'](respondWithResult(_0x29a257,null))[_0x2a4c('0x5e')](handleError(_0x29a257,null));};exports['addSquareProjects']=function(_0x29ed59,_0x4825dc,_0x4f43b2){return db[_0x2a4c('0x44')][_0x2a4c('0x62')]({'where':{'id':_0x29ed59[_0x2a4c('0x64')]['id']}})[_0x2a4c('0x33')](handleEntityNotFound(_0x4825dc,null))[_0x2a4c('0x33')](function(_0x254645){if(_0x254645){return _0x254645[_0x2a4c('0x155')](_0x29ed59[_0x2a4c('0x63')][_0x2a4c('0xac')],_[_0x2a4c('0x67')](_0x29ed59['body'],[_0x2a4c('0xac'),'id'])||{});}})[_0x2a4c('0x33')](respondWithResult(_0x4825dc,null))[_0x2a4c('0x5e')](handleError(_0x4825dc,null));};exports[_0x2a4c('0x156')]=function(_0x26e323,_0x5c0ba0,_0x4adb70){return db[_0x2a4c('0x44')][_0x2a4c('0x62')]({'where':{'id':_0x26e323['params']['id']}})[_0x2a4c('0x33')](handleEntityNotFound(_0x5c0ba0,null))[_0x2a4c('0x33')](function(_0x34ce44){if(_0x34ce44){return _0x34ce44['removeSquareProjects'](_0x26e323[_0x2a4c('0x4a')][_0x2a4c('0xac')]);}})[_0x2a4c('0x33')](respondWithStatusCode(_0x5c0ba0,null))[_0x2a4c('0x5e')](handleError(_0x5c0ba0,null));};exports[_0x2a4c('0x157')]=function(_0x494cf6,_0x2821c6){var _0x2ef0c2={},_0x31d60d={},_0x228078={'count':0x0,'rows':[]};var _0x15a3f6=db['CmHopper'][_0x2a4c('0x45')];_0x31d60d[_0x2a4c('0x47')]=_[_0x2a4c('0x4b')](_0x15a3f6);_0x31d60d['query']=_[_0x2a4c('0x4b')](_0x494cf6[_0x2a4c('0x4a')]);_0x31d60d['filters']=_[_0x2a4c('0x4d')](_0x31d60d['model'],_0x31d60d[_0x2a4c('0x4a')]);_0x31d60d[_0x2a4c('0x4c')]=_[_0x2a4c('0xf5')](_0x31d60d[_0x2a4c('0x4c')],[_0x2a4c('0x158'),_0x2a4c('0x159'),_0x2a4c('0x15a'),_0x2a4c('0x15b'),_0x2a4c('0x15c'),_0x2a4c('0x15d'),_0x2a4c('0x15e'),_0x2a4c('0x15f'),_0x2a4c('0x160'),_0x2a4c('0x161'),_0x2a4c('0x162'),_0x2a4c('0x163'),_0x2a4c('0x164'),_0x2a4c('0x165'),'$notLike',_0x2a4c('0x166'),_0x2a4c('0x167'),_0x2a4c('0x165'),_0x2a4c('0x168'),_0x2a4c('0x169'),_0x2a4c('0x16a'),'$any']);_0x2ef0c2[_0x2a4c('0x4f')]=_[_0x2a4c('0x4d')](_0x31d60d[_0x2a4c('0x47')],qs['fields'](_0x494cf6[_0x2a4c('0x4a')][_0x2a4c('0x4e')]));_0x2ef0c2['attributes']=_0x2ef0c2[_0x2a4c('0x4f')][_0x2a4c('0x61')]?_0x2ef0c2[_0x2a4c('0x4f')]:_0x31d60d[_0x2a4c('0x47')];if(!_0x494cf6[_0x2a4c('0x4a')]['hasOwnProperty'](_0x2a4c('0x51'))){_0x2ef0c2[_0x2a4c('0x2d')]=qs['limit'](_0x494cf6[_0x2a4c('0x4a')][_0x2a4c('0x2d')]);_0x2ef0c2['offset']=qs[_0x2a4c('0x2c')](_0x494cf6[_0x2a4c('0x4a')][_0x2a4c('0x2c')]);}_0x2ef0c2[_0x2a4c('0xc5')]=qs[_0x2a4c('0x52')](_0x494cf6[_0x2a4c('0x4a')][_0x2a4c('0x52')]);_0x2ef0c2[_0x2a4c('0x53')]=qs[_0x2a4c('0x4c')](_[_0x2a4c('0x54')](_0x494cf6[_0x2a4c('0x4a')],_0x31d60d[_0x2a4c('0x4c')]));if(_0x494cf6[_0x2a4c('0x4a')]['filter']){_0x2ef0c2[_0x2a4c('0x53')]=_[_0x2a4c('0x55')](_0x2ef0c2['where'],{'$or':_[_0x2a4c('0x3b')](_0x2ef0c2['attributes'],function(_0x56f1f6){var _0x2dc303={};_0x2dc303[_0x56f1f6]={'$like':'%'+_0x494cf6[_0x2a4c('0x4a')]['filter']+'%'};return _0x2dc303;})});}_0x2ef0c2[_0x2a4c('0x53')]={'$and':[_0x2ef0c2[_0x2a4c('0x53')],{'$or':[{'UserId':_0x494cf6[_0x2a4c('0x64')]['id']},{'OwnerId':_0x494cf6['params']['id']}]}]};_0x2ef0c2=_[_0x2a4c('0x55')]({},_0x2ef0c2,_0x494cf6[_0x2a4c('0x59')]);var _0x2ea04e={'where':_0x2ef0c2[_0x2a4c('0x53')]};return db['CmHopper'][_0x2a4c('0x2b')](_0x2ea04e)[_0x2a4c('0x33')](function(_0x118f13){_0x228078[_0x2a4c('0x2b')]=_0x118f13;if(_0x494cf6[_0x2a4c('0x4a')][_0x2a4c('0x5a')]){_0x2ef0c2[_0x2a4c('0x5b')]=[{'attributes':['id',_0x2a4c('0x16b'),_0x2a4c('0x16c'),_0x2a4c('0xe2')],'model':db['CmContact'],'as':_0x2a4c('0x16d')},{'attributes':['id',_0x2a4c('0x41'),_0x2a4c('0x16e')],'model':db[_0x2a4c('0xb2')],'as':_0x2a4c('0xcd')}];}return db['CmHopper'][_0x2a4c('0x5c')](_0x2ef0c2);})['then'](function(_0x23ed1b){_0x228078[_0x2a4c('0x5d')]=_0x23ed1b;return _0x228078;})['then'](respondWithFilteredResult(_0x2821c6,_0x2ef0c2))['catch'](handleError(_0x2821c6,null));};exports['getApiKey']=function(_0x2b017e,_0x1873b2,_0x40beb5){if(!_[_0x2a4c('0x6c')](_0x2b017e[_0x2a4c('0x81')]['id'])&&(_0x2b017e[_0x2a4c('0x81')]['role']==_0x2a4c('0x36')||_0x2b017e[_0x2a4c('0x81')][_0x2a4c('0x3e')]=='user')){return db['User'][_0x2a4c('0xc3')]({'where':{'id':_0x2b017e[_0x2a4c('0x64')]['id']},'raw':!![]})['then'](function(_0x18f94f){return authService['retrieveApiKey'](_0x18f94f);})['then'](function(_0x2ca6c7){if(_0x2ca6c7){return _0x1873b2['status'](0xc8)[_0x2a4c('0x2a')]({'api_key':_0x2ca6c7[_0x2a4c('0x16f')]});}else{return _0x1873b2[_0x2a4c('0x28')](0xcc)[_0x2a4c('0x2a')]({'message':_0x2a4c('0x170')});}})[_0x2a4c('0x5e')](handleError(_0x1873b2,0x193));}else{return _0x1873b2[_0x2a4c('0x28')](0x191)[_0x2a4c('0x2a')]({'message':_0x2a4c('0x171')});}};exports[_0x2a4c('0x172')]=function(_0x17e128,_0x19fa08,_0x4f3e00){if(!_[_0x2a4c('0x6c')](_0x17e128['user']['id'])&&(_0x17e128['user'][_0x2a4c('0x3e')]==_0x2a4c('0x36')||_0x17e128['user']['role']==_0x2a4c('0x81'))){return db[_0x2a4c('0x44')][_0x2a4c('0x62')]({'where':{'id':_0x17e128[_0x2a4c('0x64')]['id']}})[_0x2a4c('0x33')](function(_0x239ed7){return authService['generateApiKey'](_0x239ed7);})['then'](function(_0x3be5c3){return db[_0x2a4c('0x44')][_0x2a4c('0x32')]({'apiKeyIat':_0x3be5c3[_0x2a4c('0x173')],'apiKeyNonce':_0x3be5c3[_0x2a4c('0x174')]},{'where':{'id':_0x17e128['params']['id']}})[_0x2a4c('0x33')](function(){return _0x19fa08['status'](0xc8)[_0x2a4c('0x2a')]({'api_key':_0x3be5c3['token']});});})[_0x2a4c('0x5e')](handleError(_0x19fa08,0x193));}else{return _0x19fa08[_0x2a4c('0x28')](0x191)[_0x2a4c('0x2a')]({'message':'You\x20don\x27t\x20have\x20sufficient\x20privileges\x20to\x20access\x20this\x20resource.'});}};exports['removeApiKey']=function(_0x4fe19e,_0xe484de,_0x12a7fb){if(!_[_0x2a4c('0x6c')](_0x4fe19e[_0x2a4c('0x81')]['id'])&&(_0x4fe19e[_0x2a4c('0x81')]['role']==_0x2a4c('0x36')||_0x4fe19e['user'][_0x2a4c('0x3e')]==_0x2a4c('0x81'))){return db[_0x2a4c('0x44')][_0x2a4c('0x62')]({'where':{'id':_0x4fe19e[_0x2a4c('0x64')]['id']}})['then'](handleEntityNotFound(_0xe484de,null))[_0x2a4c('0x33')](function(_0x517cb2){if(_0x517cb2&&_0x517cb2['apiKeyNonce']&&_0x517cb2[_0x2a4c('0x175')])return _0x517cb2;else throw{'message':'API\x20key\x20not\x20available'};})[_0x2a4c('0x33')](function(_0x50697b){return db[_0x2a4c('0x44')][_0x2a4c('0x32')]({'apiKeyNonce':null,'apiKeyIat':null},{'where':{'id':_0x4fe19e[_0x2a4c('0x64')]['id']}});})[_0x2a4c('0x33')](respondWithStatusCode(_0xe484de,0xc8))[_0x2a4c('0x5e')](handleError(_0xe484de,0x193));}else{return _0xe484de[_0x2a4c('0x28')](0x191)['json']({'message':_0x2a4c('0x171')});}};exports[_0x2a4c('0x176')]=function(_0x1216be,_0x2bba59){var _0x41917a=_0x1216be[_0x2a4c('0x81')][_0x2a4c('0x35')]({'plain':!![]});if(!_0x41917a){return _0x2bba59[_0x2a4c('0x28')](0x191)[_0x2a4c('0x42')](_0x2a4c('0x177'));}else{return _0x2bba59[_0x2a4c('0x28')](0xc8)[_0x2a4c('0x2a')](_0x41917a);}};
\ No newline at end of file