Built motion from commit d1eab355.|2.6.28
[motion2.git] / server / api / user / user.controller.js
index 9fa1e92..5754515 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x14f5=['tag','getQueues','Queue','getVoiceQueuesRt','nolimit','getGroups','getRecordings','UserId','VoiceRecording','ScreenRecording','rows','getChatInteractions','ChatInteraction','OpenchannelInteraction','getOpenchannelInteractions','getMailInteractions','MailInteraction','getSmsInteractions','getFaxInteractions','getWhatsappInteractions','WhatsappInteraction','phone','mobile','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','getVoiceQueues','MemberReport','forEach','YYYY-MM-DD\x20HH:mm:ss','getChannels','LOGIN','PAUSE','LOGININPAUSE','bulkCreate','isMiddleware','resolve','pause','QueuePause','updateAttributes','DEFAULT\x20PAUSE','unpause','mailPause','chatPause','faxPause','openchannelPause','smsPause','lastPauseAt','chat','fax','whatsapp','openchannel','manual','set','%s%s','Pause','getTeams','Team','addTeams','omit','Voice','setDataValue','Chat','Mail','Sms','getWhatsappQueues','Whatsapp','getFaxQueues','Fax','getOpenchannelQueues','Openchannel','flatten','transaction','addAgent','getDataValue','upsert','removeTeams','getChatQueues','getSmsQueues','getLists','values','You\x20can\x27t\x20delete\x20yourself','addChatInteractions','spread','user_has_chat_interactions:save','removeChatInteractions','isArray','user_has_chat_interactions:remove','addMailInteractions','user_has_mail_interactions:save','removeMailInteractions','user_has_mail_interactions:remove','addFaxInteractions','user_has_fax_interactions:save','removeFaxInteractions','user_has_fax_interactions:remove','addSmsInteractions','user_has_sms_interactions:save','removeSmsInteractions','addOpenchannelInteractions','user_has_openchannel_interactions:save','removeOpenchannelInteractions','user_has_openchannel_interactions:remove','addWhatsappInteractions','user_has_whatsapp_interactions:save','removeWhatsappInteractions','getVoicePrefixes','VoicePrefix','getFaxAccounts','addFaxAccounts','removeFaxAccounts','getMailAccounts','MailAccount','addMailAccounts','removeMailAccounts','getOpenchannelAccounts','OpenchannelAccount','addOpenchannelAccounts','removeOpenchannelAccounts','getSmsAccounts','SmsAccount','addSmsAccounts','removeSmsAccounts','getChatWebsites','ChatWebsite','addChatWebsites','removeChatWebsites','getWhatsappAccounts','WhatsappAccount','addWhatsappAccounts','removeWhatsappAccounts','getSquareProjects','SquareProject','addSquareProjects','removeSquareProjects','getScheduledCalls','CmHopper','concat','$or','$gt','$gte','$lt','$ne','$eq','$between','$notBetween','$notIn','$like','$notLike','$iLike','$overlap','$any','firstName','lastName','dialActive','getApiKey','retrieveApiKey','createApiKey','generateApiKey','iat','nonce','token','You\x20don\x27t\x20have\x20sufficient\x20privileges\x20to\x20access\x20this\x20resource.','removeApiKey','apiKeyNonce','apiKeyIat','whoami','Unable\x20to\x20retrieve\x20the\x20current\x20user','eml-format','zip-dir','fast-json-patch','request-promise','bluebird','mustache','path','sox','to-csv','ejs','lodash','squel','crypto','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/environment','../../config/license/util','../../mysqldb','redis','defaults','localhost','socket.io-emitter','./user.socket','register','jayson/promise','client','http','request','then','User,\x20%s,\x20%s','request\x20sent','debug','User,\x20%s,\x20%s,\x20%s','error','code','message','result','catch','status','end','json','count','offset','limit','apply','reject','save','update','destroy','get','Users','Agents','Telephones','filter','map','value','includes','role','find','name','sendStatus','stack','send','type','key','model','differenceBy','password','keys','query','filters','intersection','fields','attributes','hasOwnProperty','order','sort','where','merge','VIRTUAL','sequelize','lower','options','User','includeAll','findAll','show','params','rawAttributes','salt','length','include','body','describe','addContacts','ids','Setting','securePassword','max','isNil','internal','min_internal','SELECT','from','voicemail','mailbox','VoiceMail','fullname','agent','permissions','101','102','103','105','106','107','108','100','111','114','create','user','admin','Unauthorized.\x20You\x20must\x20be\x20an\x20administrator\x20in\x20order\x20to\x20create\x20another\x20administrator','settingsEnabled','userProfileId','UserProfileResource','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','Unauthorized','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','checkUserLimits','push','all','each','UserProfileSection','isEmpty','autoAssociation','telephone','compact','changePassword','oldPassword','newPassword','authenticate','ValidationError','Wrong\x20credentials','Sequelize','New\x20password\x20must\x20be\x20different\x20from\x20old\x20password','Invalid\x20body\x20format.\x20Use\x20newPassword','findOne','enforcePasswordHistory','passwordHistoryLimit','previousPasswords','validatePasswordHistory','updatePasswordsHistory','addQueues','channel','online','loginInPause','voicePause','interface','isValidChannel','Unknown\x20channel','add','capitalize','Queues','penalty','toLowerCase','QueueId','emit','voice','VoiceQueue','format','SIP/%s','removeQueues','Queue:remove','UserVoiceQueueRt','addAvatar','filename','getAvatar','join','server/files/images/logos/default_profile.png','userpic','existsSync','root','server/files/images/','download','getContacts','CmContact','pick','CmList','Tag','Tags'];(function(_0x392076,_0x2d6cc9){var _0x5b5323=function(_0x46a925){while(--_0x46a925){_0x392076['push'](_0x392076['shift']());}};_0x5b5323(++_0x2d6cc9);}(_0x14f5,0xae));var _0x514f=function(_0x5a3e59,_0x8133b5){_0x5a3e59=_0x5a3e59-0x0;var _0x1d6945=_0x14f5[_0x5a3e59];return _0x1d6945;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0x514f('0x0'));var rimraf=require('rimraf');var zipdir=require(_0x514f('0x1'));var jsonpatch=require(_0x514f('0x2'));var rp=require(_0x514f('0x3'));var moment=require('moment');var BPromise=require(_0x514f('0x4'));var Mustache=require(_0x514f('0x5'));var util=require('util');var path=require(_0x514f('0x6'));var sox=require(_0x514f('0x7'));var csv=require(_0x514f('0x8'));var ejs=require(_0x514f('0x9'));var fs=require('fs');var _=require(_0x514f('0xa'));var squel=require(_0x514f('0xb'));var crypto=require(_0x514f('0xc'));var jsforce=require('jsforce');var deskjs=require(_0x514f('0xd'));var toCsv=require('to-csv');var querystring=require(_0x514f('0xe'));var Papa=require(_0x514f('0xf'));var Redis=require(_0x514f('0x10'));var authService=require(_0x514f('0x11'));var qs=require(_0x514f('0x12'));var as=require(_0x514f('0x13'));var hardwareService=require(_0x514f('0x14'));var logger=require('../../config/logger')('api');var utils=require('../../config/utils');var config=require(_0x514f('0x15'));var licenseUtil=require(_0x514f('0x16'));var db=require(_0x514f('0x17'))['db'];config[_0x514f('0x18')]=_[_0x514f('0x19')](config[_0x514f('0x18')],{'host':_0x514f('0x1a'),'port':0x18eb});var socket=require(_0x514f('0x1b'))(new Redis(config[_0x514f('0x18')]));require(_0x514f('0x1c'))[_0x514f('0x1d')](socket);var jayson=require(_0x514f('0x1e'));var client=jayson[_0x514f('0x1f')][_0x514f('0x20')]({'port':0x232a});function respondWithRpcPromise(_0x1694b3,_0x5865d1,_0x70d2b4,_0x1f0cbe){return new BPromise(function(_0x519b63,_0x255996){var _0x53851d=_0x1f0cbe||client;return _0x53851d[_0x514f('0x21')](_0x1694b3,_0x70d2b4)[_0x514f('0x22')](function(_0x466ca8){logger['info'](_0x514f('0x23'),_0x5865d1,_0x514f('0x24'));logger[_0x514f('0x25')](_0x514f('0x26'),_0x5865d1,'request\x20sent',JSON['stringify'](_0x466ca8));if(_0x466ca8[_0x514f('0x27')]){if(_0x466ca8[_0x514f('0x27')][_0x514f('0x28')]===0x1f4){logger['error'](_0x514f('0x23'),_0x5865d1,_0x466ca8[_0x514f('0x27')]['message']);return _0x255996(_0x466ca8[_0x514f('0x27')][_0x514f('0x29')]);}logger['error'](_0x514f('0x23'),_0x5865d1,_0x466ca8[_0x514f('0x27')][_0x514f('0x29')]);return _0x519b63(_0x466ca8[_0x514f('0x27')]['message']);}else{logger['info']('User,\x20%s,\x20%s',_0x5865d1,'request\x20sent');_0x519b63(_0x466ca8[_0x514f('0x2a')][_0x514f('0x29')]);}})[_0x514f('0x2b')](function(_0xc36426){logger[_0x514f('0x27')](_0x514f('0x23'),_0x5865d1,_0xc36426);_0x255996(_0xc36426);});});}function respondWithStatusCode(_0x2c6bb1,_0x101742){_0x101742=_0x101742||0xcc;return function(_0x24678d){if(_0x24678d){return _0x2c6bb1['sendStatus'](_0x101742);}return _0x2c6bb1[_0x514f('0x2c')](_0x101742)[_0x514f('0x2d')]();};}function respondWithResult(_0x3c45e4,_0x248f30){_0x248f30=_0x248f30||0xc8;return function(_0x326809){if(_0x326809){return _0x3c45e4[_0x514f('0x2c')](_0x248f30)[_0x514f('0x2e')](_0x326809);}};}function respondWithFilteredResult(_0x2f61f7,_0x376960){return function(_0x594a50){if(_0x594a50){var _0x2c4c4b=_0x594a50[_0x514f('0x2f')],_0x488c17=_0x376960[_0x514f('0x30')],_0x2b43e0=_0x376960[_0x514f('0x30')]+_0x376960[_0x514f('0x31')],_0x51beda;if(_0x2b43e0>=_0x2c4c4b){_0x2b43e0=_0x2c4c4b;_0x51beda=0xc8;}else{_0x51beda=0xce;}_0x2f61f7[_0x514f('0x2c')](_0x51beda);return _0x2f61f7['set']('Content-Range',_0x488c17+'-'+_0x2b43e0+'/'+_0x2c4c4b)[_0x514f('0x2e')](_0x594a50);}return null;};}function patchUpdates(_0x5d564b){return function(_0x150384){try{jsonpatch[_0x514f('0x32')](_0x150384,_0x5d564b,!![]);}catch(_0x305761){return BPromise[_0x514f('0x33')](_0x305761);}return _0x150384[_0x514f('0x34')]();};}function saveUpdates(_0x5538a0,_0x554986){return function(_0x5eee93){if(_0x5eee93){return _0x5eee93[_0x514f('0x35')](_0x5538a0)[_0x514f('0x22')](function(_0x2f7e26){return _0x2f7e26;});}return null;};}function removeEntity(_0x32df6e,_0x40693f){return function(_0x3526c0){if(_0x3526c0){return _0x3526c0[_0x514f('0x36')]()[_0x514f('0x22')](function(){var _0x43768d=_0x3526c0[_0x514f('0x37')]({'plain':!![]});if(_0x43768d['role']==='admin')return;var _0x5ef920=[{'name':_0x514f('0x38'),'value':'user','ignore':!![]},{'name':_0x514f('0x39'),'value':'agent','ignore':![]},{'name':_0x514f('0x3a'),'value':'telephone','ignore':![]}];var _0x5247a4=_(_0x5ef920)[_0x514f('0x3b')]('ignore')[_0x514f('0x3c')](_0x514f('0x3d'))[_0x514f('0x3d')]();if(_[_0x514f('0x3e')](_0x5247a4,_0x43768d[_0x514f('0x3f')])){return;}var _0x492052=_[_0x514f('0x40')](_0x5ef920,[_0x514f('0x3d'),_0x43768d[_0x514f('0x3f')]])[_0x514f('0x41')];return db['UserProfileResource'][_0x514f('0x36')]({'where':{'type':_0x492052,'resourceId':_0x43768d['id']}})[_0x514f('0x22')](function(){return _0x3526c0;});})[_0x514f('0x22')](function(){_0x32df6e[_0x514f('0x2c')](0xcc)['end']();});}};}function handleEntityNotFound(_0x1c1a24,_0x138ccd){return function(_0x420c77){if(!_0x420c77){_0x1c1a24[_0x514f('0x42')](0x194);}return _0x420c77;};}function handleError(_0x580b24,_0xee1de2){_0xee1de2=_0xee1de2||0x1f4;return function(_0x505880){logger[_0x514f('0x27')](_0x505880[_0x514f('0x43')]);if(_0x505880[_0x514f('0x41')]){delete _0x505880['name'];}_0x580b24['status'](_0xee1de2)[_0x514f('0x44')](_0x505880);};}exports['index']=function(_0x10259a,_0x1e9a35){var _0x17328a={},_0x456aaa={},_0x476351={'count':0x0,'rows':[]};var _0x24ab34=_[_0x514f('0x3c')](db['User']['rawAttributes'],function(_0x1c2fdc){return{'name':_0x1c2fdc['fieldName'],'type':_0x1c2fdc[_0x514f('0x45')][_0x514f('0x46')]};});_0x456aaa[_0x514f('0x47')]=_[_0x514f('0x48')](_[_0x514f('0x3c')](_0x24ab34,'name'),[_0x514f('0x49'),'salt']);_0x456aaa['query']=_[_0x514f('0x4a')](_0x10259a[_0x514f('0x4b')]);_0x456aaa[_0x514f('0x4c')]=_[_0x514f('0x4d')](_0x456aaa[_0x514f('0x47')],_0x456aaa['query']);_0x17328a['attributes']=_[_0x514f('0x4d')](_0x456aaa[_0x514f('0x47')],qs[_0x514f('0x4e')](_0x10259a[_0x514f('0x4b')][_0x514f('0x4e')]));_0x17328a['attributes']=_0x17328a[_0x514f('0x4f')]['length']?_0x17328a['attributes']:_0x456aaa[_0x514f('0x47')];if(!_0x10259a['query'][_0x514f('0x50')]('nolimit')){_0x17328a['limit']=qs[_0x514f('0x31')](_0x10259a[_0x514f('0x4b')]['limit']);_0x17328a['offset']=qs[_0x514f('0x30')](_0x10259a[_0x514f('0x4b')][_0x514f('0x30')]);}_0x17328a[_0x514f('0x51')]=qs[_0x514f('0x52')](_0x10259a[_0x514f('0x4b')][_0x514f('0x52')]);_0x17328a[_0x514f('0x53')]=qs[_0x514f('0x4c')](_['pick'](_0x10259a[_0x514f('0x4b')],_0x456aaa[_0x514f('0x4c')]),_0x24ab34);if(_0x10259a[_0x514f('0x4b')][_0x514f('0x3b')]){_0x17328a[_0x514f('0x53')]=_[_0x514f('0x54')](_0x17328a[_0x514f('0x53')],{'$or':_['map'](_0x24ab34,function(_0x95ee75){if(_0x95ee75['type']!==_0x514f('0x55')){return db[_0x514f('0x56')][_0x514f('0x53')](db[_0x514f('0x56')]['fn'](_0x514f('0x57'),db['sequelize']['col'](_0x95ee75[_0x514f('0x41')])),{'$like':db['sequelize']['fn'](_0x514f('0x57'),'%'+_0x10259a['query'][_0x514f('0x3b')]+'%')});}})});}_0x17328a=_[_0x514f('0x54')]({},_0x17328a,_0x10259a[_0x514f('0x58')]);var _0x4f35ba={'where':_0x17328a[_0x514f('0x53')]};return db[_0x514f('0x59')][_0x514f('0x2f')](_0x4f35ba)['then'](function(_0x222f94){_0x476351[_0x514f('0x2f')]=_0x222f94;if(_0x10259a['query'][_0x514f('0x5a')]){_0x17328a['include']=[{'all':!![]}];}return db[_0x514f('0x59')][_0x514f('0x5b')](_0x17328a);})[_0x514f('0x22')](function(_0x500be7){_0x476351['rows']=_0x500be7;return _0x476351;})[_0x514f('0x22')](respondWithFilteredResult(_0x1e9a35,_0x17328a))[_0x514f('0x2b')](handleError(_0x1e9a35,null));};exports[_0x514f('0x5c')]=function(_0x1053b8,_0x39cce9){var _0xfd5e5b={'raw':![],'where':{'id':_0x1053b8[_0x514f('0x5d')]['id']}},_0x233484={};_0x233484['model']=_[_0x514f('0x48')](_[_0x514f('0x4a')](db[_0x514f('0x59')][_0x514f('0x5e')]),['password',_0x514f('0x5f')]);_0x233484[_0x514f('0x4b')]=_[_0x514f('0x4a')](_0x1053b8['query']);_0x233484[_0x514f('0x4c')]=_[_0x514f('0x4d')](_0x233484['model'],_0x233484[_0x514f('0x4b')]);_0xfd5e5b[_0x514f('0x4f')]=_[_0x514f('0x4d')](_0x233484[_0x514f('0x47')],qs[_0x514f('0x4e')](_0x1053b8[_0x514f('0x4b')][_0x514f('0x4e')]));_0xfd5e5b[_0x514f('0x4f')]=_0xfd5e5b['attributes'][_0x514f('0x60')]?_0xfd5e5b['attributes']:_0x233484['model'];if(_0x1053b8[_0x514f('0x4b')]['includeAll']){_0xfd5e5b[_0x514f('0x61')]=[{'all':!![]}];}_0xfd5e5b=_[_0x514f('0x54')]({},_0xfd5e5b,_0x1053b8[_0x514f('0x58')]);return db['User']['find'](_0xfd5e5b)[_0x514f('0x22')](handleEntityNotFound(_0x39cce9,null))['then'](respondWithResult(_0x39cce9,null))[_0x514f('0x2b')](handleError(_0x39cce9,null));};exports[_0x514f('0x35')]=function(_0x312800,_0x37bfc2){if(_0x312800['body']['id']){delete _0x312800['body']['id'];}delete _0x312800[_0x514f('0x62')][_0x514f('0x3f')];return db[_0x514f('0x59')][_0x514f('0x40')]({'where':{'id':_0x312800[_0x514f('0x5d')]['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x37bfc2,null))[_0x514f('0x22')](saveUpdates(_0x312800[_0x514f('0x62')],null))['then'](respondWithResult(_0x37bfc2,null))['catch'](handleError(_0x37bfc2,null));};exports[_0x514f('0x63')]=function(_0x5d5659,_0x21e8c1){return db[_0x514f('0x59')][_0x514f('0x63')]()['then'](respondWithResult(_0x21e8c1,null))['catch'](handleError(_0x21e8c1,null));};exports[_0x514f('0x64')]=function(_0xd73693,_0x5879ec,_0x36f20b){return db[_0x514f('0x59')]['find']({'where':{'id':_0xd73693['params']['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x5879ec,null))['then'](function(_0x347a67){if(_0x347a67){return _0x347a67[_0x514f('0x64')](_0xd73693[_0x514f('0x62')]['ids'],_['omit'](_0xd73693[_0x514f('0x62')],[_0x514f('0x65'),'id'])||{});}})[_0x514f('0x22')](respondWithResult(_0x5879ec,null))[_0x514f('0x2b')](handleError(_0x5879ec,null));};function validateUser(_0x342f72){return new BPromise(function(_0x528d1f,_0x5817ed){if(_0x342f72['internal'])return _0x528d1f(_0x342f72);return db[_0x514f('0x66')]['findById'](0x1)[_0x514f('0x22')](function(_0x39ced0){if(_0x39ced0[_0x514f('0x67')])authService['validatePasswordPattern'](_0x342f72['password']);db[_0x514f('0x59')][_0x514f('0x68')]('internal')[_0x514f('0x22')](function(_0x5475e5){if(_[_0x514f('0x69')](_0x5475e5)){_0x342f72[_0x514f('0x6a')]=_0x39ced0[_0x514f('0x6b')]||0x1;return;}if(_[_0x514f('0x69')](_0x39ced0[_0x514f('0x6b')])||_0x39ced0[_0x514f('0x6b')]===_0x5475e5){_0x342f72['internal']=_0x5475e5+0x1;return;}if(_0x39ced0[_0x514f('0x6b')]>_0x5475e5){_0x342f72[_0x514f('0x6a')]=_0x39ced0[_0x514f('0x6b')];return;}return db[_0x514f('0x56')][_0x514f('0x4b')]('select\x20(select\x20IFNULL(max(internal)+1,1)\x20from\x20users\x20where\x20internal\x20<\x20md.internal)\x20as\x20\x27from\x27,\x20md.internal\x20-\x201\x20as\x20\x27to\x27\x20from\x20users\x20md\x20where\x20md.internal\x20!=\x201\x20and\x20not\x20exists\x20(select\x201\x20from\x20users\x20md2\x20where\x20md2.internal\x20=\x20md.internal\x20-\x201)',{'type':db[_0x514f('0x56')]['QueryTypes'][_0x514f('0x6c')]})[_0x514f('0x22')](function(_0x37df81){if(_0x37df81&&_0x37df81[_0x514f('0x60')]){for(var _0x38857f=0x0,_0x4c8ebe=_0x37df81[_0x514f('0x60')];_0x38857f<_0x4c8ebe&&_[_0x514f('0x69')](_0x342f72[_0x514f('0x6a')]);_0x38857f++){if(_0x39ced0[_0x514f('0x6b')]<=_0x37df81[_0x38857f]['from']){_0x342f72['internal']=_0x37df81[_0x38857f][_0x514f('0x6d')];}else if(_0x39ced0['min_internal']>_0x37df81[_0x38857f][_0x514f('0x6d')]&&_0x39ced0[_0x514f('0x6b')]<=_0x37df81[_0x38857f]['to']){_0x342f72['internal']=_0x39ced0['min_internal'];}}}if(_['isNil'](_0x342f72['internal'])){_0x342f72[_0x514f('0x6a')]=_0x5475e5+0x1;}return _0x528d1f(_0x342f72);});});})['catch'](function(_0x414602){_0x5817ed(_0x414602);});});}function updateUser(_0x3db9a5){return new BPromise(function(_0x3fee74,_0x1da50f){try{if(_0x3db9a5[_0x514f('0x6e')]){_0x3db9a5[_0x514f('0x6f')]=_0x3db9a5[_0x514f('0x6a')];_0x3db9a5[_0x514f('0x70')]={'mailbox':_0x3db9a5[_0x514f('0x6a')],'password':_0x3db9a5[_0x514f('0x49')],'fullname':_0x3db9a5[_0x514f('0x71')],'email':_0x3db9a5['email']};}if(_0x3db9a5[_0x514f('0x3f')]===_0x514f('0x72')){if(!_0x3db9a5[_0x514f('0x73')])_0x3db9a5[_0x514f('0x73')]=[_0x514f('0x74'),_0x514f('0x75'),_0x514f('0x76'),'113','110','104',_0x514f('0x77'),_0x514f('0x78'),_0x514f('0x79'),_0x514f('0x7a'),'109',_0x514f('0x7b'),_0x514f('0x7c'),_0x514f('0x7d')];}_0x3fee74(_0x3db9a5);}catch(_0x3335f0){_0x1da50f(_0x3335f0);}});}exports[_0x514f('0x7e')]=function(_0x580caa,_0x223cc3){if(_0x580caa[_0x514f('0x7f')][_0x514f('0x3f')]===_0x514f('0x72'))throw new Error('Unauthorized');if(_0x580caa[_0x514f('0x62')][_0x514f('0x3f')]===_0x514f('0x7f')&&_0x580caa[_0x514f('0x7f')]['role']!==_0x514f('0x80')){throw new Error('Unauthorized.\x20You\x20must\x20be\x20an\x20administrator\x20in\x20order\x20to\x20create\x20an\x20user');}if(_0x580caa[_0x514f('0x62')]['role']===_0x514f('0x80')&&_0x580caa[_0x514f('0x7f')][_0x514f('0x3f')]!=='admin'){throw new Error(_0x514f('0x81'));}return licenseUtil['checkUserLimits']([_0x580caa[_0x514f('0x62')]])[_0x514f('0x22')](function(){return validateUser(_0x580caa[_0x514f('0x62')]);})[_0x514f('0x22')](function(_0x508861){return updateUser(_0x508861)['then'](function(_0x1312de){if(_0x1312de['role']==='admin'){_0x1312de[_0x514f('0x82')]=_0x580caa[_0x514f('0x7f')][_0x514f('0x82')];delete _0x1312de[_0x514f('0x83')];}return _0x1312de;});})['then'](function(_0x4c8314){return db[_0x514f('0x59')]['create'](_0x4c8314,{'include':[{'model':db[_0x514f('0x70')],'as':_0x514f('0x70')}]});})[_0x514f('0x22')](function(_0x199091){if(_0x580caa[_0x514f('0x62')][_0x514f('0x3f')]==='user')return _0x199091;if(_0x580caa[_0x514f('0x7f')][_0x514f('0x3f')]!=='user')return _0x199091;return db['UserProfileSection'][_0x514f('0x40')]({'where':{'name':_0x199091[_0x514f('0x3f')]==='agent'?_0x514f('0x39'):_0x514f('0x3a'),'userProfileId':_0x580caa[_0x514f('0x7f')][_0x514f('0x83')]},'raw':!![]})[_0x514f('0x22')](function(_0x5c1511){if(!_0x5c1511||_0x5c1511['autoAssociation']!=0x0)return _0x199091;return db[_0x514f('0x84')][_0x514f('0x7e')]({'name':_0x199091[_0x514f('0x41')],'resourceId':_0x199091['id'],'type':_0x5c1511[_0x514f('0x41')],'sectionId':_0x5c1511['id']},{})['then'](function(){return _0x199091;});})[_0x514f('0x2b')](function(_0x167915){logger[_0x514f('0x27')](_0x514f('0x85'),_0x167915);throw _0x167915;});})[_0x514f('0x22')](respondWithResult(_0x223cc3,0xc9))['catch'](handleError(_0x223cc3,null));};exports['bulkCreate']=function(_0x3e7f51,_0x53d42f){var _0x1caa7b=_0x3e7f51[_0x514f('0x62')];var _0x4ab28e=[];if(_0x3e7f51[_0x514f('0x7f')][_0x514f('0x3f')]===_0x514f('0x72'))throw new Error(_0x514f('0x86'));if(_[_0x514f('0x87')](_0x1caa7b,[_0x514f('0x3f'),'user'])&&_0x3e7f51[_0x514f('0x7f')]['role']!==_0x514f('0x80')){throw new Error(_0x514f('0x88'));}if(_[_0x514f('0x87')](_0x1caa7b,[_0x514f('0x3f'),_0x514f('0x80')])&&_0x3e7f51['user'][_0x514f('0x3f')]!==_0x514f('0x80')){throw new Error(_0x514f('0x89'));}return licenseUtil[_0x514f('0x8a')](_0x1caa7b)[_0x514f('0x22')](function(){return validateUser(_0x1caa7b[0x0]);})[_0x514f('0x22')](function(){for(var _0x2dbef8=0x1;_0x2dbef8<_0x1caa7b[_0x514f('0x60')];_0x2dbef8++){var _0x1fbcdb=_0x1caa7b[_0x2dbef8-0x1]['internal'];if(!_0x1caa7b[_0x2dbef8][_0x514f('0x6a')])_0x1caa7b[_0x2dbef8][_0x514f('0x6a')]=_0x1fbcdb+0x1;_0x4ab28e[_0x514f('0x8b')](validateUser(_0x1caa7b[_0x2dbef8]));}return BPromise[_0x514f('0x8c')](_0x4ab28e);})[_0x514f('0x22')](function(){_0x4ab28e=[];for(var _0x18f509=0x0;_0x18f509<_0x1caa7b[_0x514f('0x60')];_0x18f509++){_0x4ab28e['push'](updateUser(_0x1caa7b[_0x18f509]));}return BPromise[_0x514f('0x8c')](_0x4ab28e);})['then'](function(){return BPromise[_0x514f('0x8d')](_0x1caa7b,function(_0x4d30db){return db['User']['create'](_0x4d30db,{'include':[{'model':db['VoiceMail'],'as':'VoiceMail'}]})['then'](function(_0xf6224a){_0x4d30db['id']=_0xf6224a['id'];return _0x4d30db;});});})[_0x514f('0x22')](function(_0x5c018d){if(_0x3e7f51[_0x514f('0x62')][_0x514f('0x3f')]===_0x514f('0x7f'))return _0x5c018d;if(_0x3e7f51['user'][_0x514f('0x3f')]!=='user')return _0x5c018d;var _0x3f14d1=_[_0x514f('0x87')](_0x5c018d,function(_0x84682){return _0x84682[_0x514f('0x3f')]===_0x514f('0x72')||_0x84682[_0x514f('0x3f')]==='telephone';});if(!_0x3f14d1)return _0x5c018d;return db[_0x514f('0x8e')][_0x514f('0x5b')]({'where':{'name':{'$or':[_0x514f('0x39'),_0x514f('0x3a')]},'userProfileId':_0x3e7f51[_0x514f('0x7f')]['userProfileId']},'raw':!![]})[_0x514f('0x22')](function(_0x357b2d){if(_[_0x514f('0x8f')](_0x357b2d)||!_[_0x514f('0x87')](_0x357b2d,[_0x514f('0x90'),0x0]))return _0x5c018d;_0x4ab28e=[];var _0x498321=_(_0x357b2d)[_0x514f('0x3c')](function(_0x491825){if(_0x491825[_0x514f('0x90')]===0x1)return;return _0x491825[_0x514f('0x41')]===_0x514f('0x39')?_0x514f('0x72'):_0x514f('0x91');})[_0x514f('0x92')]()[_0x514f('0x3d')]();for(var _0x524715=0x0;_0x524715<_0x5c018d[_0x514f('0x60')];_0x524715++){if(!_[_0x514f('0x3e')](_0x498321,_0x5c018d[_0x524715][_0x514f('0x3f')]))return;var _0x5a16e4=_0x5c018d[_0x524715][_0x514f('0x3f')]===_0x514f('0x72')?_0x514f('0x39'):_0x514f('0x3a');_0x4ab28e[_0x514f('0x8b')](db[_0x514f('0x84')][_0x514f('0x7e')]({'name':_0x5c018d[_0x524715][_0x514f('0x41')],'resourceId':_0x5c018d[_0x524715]['id'],'type':_0x5a16e4,'sectionId':_[_0x514f('0x40')](_0x357b2d,['name',_0x5a16e4])['id']},{}));}return BPromise[_0x514f('0x8c')](_0x4ab28e);})[_0x514f('0x22')](respondWithResult(_0x53d42f,0xc9))['catch'](handleError(_0x53d42f,null));});};exports[_0x514f('0x93')]=function(_0x2dac37,_0x358108,_0x3ccac5){if(_0x2dac37[_0x514f('0x62')]['id']){delete _0x2dac37[_0x514f('0x62')]['id'];}return db['User']['find']({'where':{'id':_0x2dac37[_0x514f('0x5d')]['id']}})['then'](function(_0x144baf){if(!_0x144baf)return null;if(_0x144baf['id']===_0x2dac37[_0x514f('0x7f')]['id']){if(!_0x2dac37[_0x514f('0x62')][_0x514f('0x94')]||!_0x2dac37['body'][_0x514f('0x95')]){throw new db['Sequelize']['ValidationError']('Invalid\x20body\x20format.\x20Use\x20oldPassword\x20and\x20newPassword');}if(!_0x144baf[_0x514f('0x96')](_0x2dac37[_0x514f('0x62')][_0x514f('0x94')])){throw new db['Sequelize'][(_0x514f('0x97'))](_0x514f('0x98'));}if(_0x2dac37[_0x514f('0x62')][_0x514f('0x94')]===_0x2dac37[_0x514f('0x62')][_0x514f('0x95')]){throw new db[(_0x514f('0x99'))]['ValidationError'](_0x514f('0x9a'));}}else if(_0x2dac37[_0x514f('0x7f')][_0x514f('0x3f')]==='admin'){if(!_0x2dac37[_0x514f('0x62')]['newPassword']){throw new db[(_0x514f('0x99'))][(_0x514f('0x97'))]('Invalid\x20body\x20format.\x20Use\x20newPassword');}}else if(_0x2dac37[_0x514f('0x7f')][_0x514f('0x3f')]===_0x514f('0x7f')){if(!_0x2dac37[_0x514f('0x62')][_0x514f('0x95')]){throw new db[(_0x514f('0x99'))][(_0x514f('0x97'))](_0x514f('0x9b'));}if(_0x144baf[_0x514f('0x3f')]!==_0x514f('0x72')){throw new db[(_0x514f('0x99'))][(_0x514f('0x97'))]('Unauthorized');}}else{throw new db['Sequelize']['ValidationError'](_0x514f('0x86'));}return _0x144baf;})[_0x514f('0x22')](handleEntityNotFound(_0x358108,null))['then'](function(_0x178f87){return db['Setting'][_0x514f('0x9c')]({'attributes':['id',_0x514f('0x67'),_0x514f('0x9d'),_0x514f('0x9e')]})['then'](function(_0x33d3ca){if(_0x33d3ca['securePassword'])authService['validatePasswordPattern'](_0x2dac37[_0x514f('0x62')]['newPassword']);if(!_0x33d3ca[_0x514f('0x9d')]||!_0x178f87[_0x514f('0x9f')])return _0x178f87;authService[_0x514f('0xa0')](_0x2dac37[_0x514f('0x62')][_0x514f('0x95')],_0x178f87[_0x514f('0x9f')],_0x33d3ca[_0x514f('0x9e')]);return _0x178f87;})['then'](saveUpdates({'password':_0x2dac37[_0x514f('0x62')][_0x514f('0x95')],'passwordResetAt':_0x2dac37[_0x514f('0x7f')]['id']==_0x2dac37[_0x514f('0x5d')]['id']?moment():null,'previousPasswords':authService[_0x514f('0xa1')](_0x2dac37[_0x514f('0x62')][_0x514f('0x95')],_0x178f87['previousPasswords'])},null));})[_0x514f('0x22')](respondWithResult(_0x358108,null))[_0x514f('0x2b')](handleError(_0x358108,null));};exports[_0x514f('0xa2')]=function(_0x119a0e,_0xea48b7,_0xbbe2b5){var _0xd946f2=_0x119a0e[_0x514f('0x62')][_0x514f('0xa3')];return db[_0x514f('0x59')][_0x514f('0x40')]({'where':{'id':_0x119a0e['params']['id']},'attributes':['id',_0x514f('0x41'),_0x514f('0x3f'),_0x514f('0xa4'),_0x514f('0xa5'),_0x514f('0xa6'),_0x514f('0xa7')]})[_0x514f('0x22')](handleEntityNotFound(_0xea48b7,null))[_0x514f('0x22')](function(_0x2ca078){if(_0x2ca078){if(!utils[_0x514f('0xa8')](_0xd946f2)){throw new db['Sequelize']['ValidationError'](_0x514f('0xa9'));}return _0x2ca078[_0x514f('0xaa')+_[_0x514f('0xab')](_0xd946f2['toLowerCase']())+_0x514f('0xac')](_0x119a0e['body'][_0x514f('0x65')],{'penalty':_0x119a0e[_0x514f('0x62')][_0x514f('0xad')]||0x0})['spread'](function(_0x511aa2){for(var _0x3e3ff4=0x0;_0x3e3ff4<_0x119a0e['body']['ids'][_0x514f('0x60')];_0x3e3ff4+=0x1){var _0x213b4c={'UserId':_0x119a0e[_0x514f('0x5d')]['id']};_0x213b4c[_[_0x514f('0xab')](_0xd946f2[_0x514f('0xae')]())+_0x514f('0xaf')]=_0x119a0e['body'][_0x514f('0x65')][_0x3e3ff4];socket[_0x514f('0xb0')](_0x514f('0x7f')+_[_0x514f('0xab')](_0xd946f2[_0x514f('0xae')]())+'Queue:save',_0x213b4c);}return _0x511aa2;})[_0x514f('0x22')](function(){if(_0xd946f2===_0x514f('0xb1')){return db[_0x514f('0xb2')][_0x514f('0x5b')]({'where':{'id':_0x119a0e['body']['ids']||[]},'raw':!![],'attributes':['id',_0x514f('0x41')]});}})[_0x514f('0x22')](function(_0x56970f){var _0x3b86c6=_0x2ca078[_0x514f('0x37')]({'plain':!![]});var _0x5af070=[];if(_0xd946f2==='voice'&&_0x3b86c6[_0x514f('0x3f')]===_0x514f('0x72')&&_0x3b86c6[_0x514f('0xa4')]){for(var _0x4561d3=0x0;_0x4561d3<_0x56970f[_0x514f('0x60')];_0x4561d3+=0x1){_0x5af070[_0x514f('0x8b')]({'membername':_0x3b86c6[_0x514f('0x41')],'UserId':_0x3b86c6['id'],'queue_name':_0x56970f[_0x4561d3][_0x514f('0x41')],'VoiceQueueId':_0x56970f[_0x4561d3]['id'],'interface':_[_0x514f('0x69')](_0x3b86c6[_0x514f('0xa7')])?util[_0x514f('0xb3')](_0x514f('0xb4'),_0x3b86c6[_0x514f('0x41')]):_0x3b86c6['interface'],'paused':_0x3b86c6[_0x514f('0xa6')]||![],'penalty':_0x119a0e[_0x514f('0x62')][_0x514f('0xad')]||0x0});}return BPromise[_0x514f('0x8d')](_0x5af070,function(_0x39dada){return db['UserVoiceQueueRt']['upsert'](_0x39dada);});}return _0x2ca078;});}})[_0x514f('0x22')](respondWithStatusCode(_0xea48b7,null))[_0x514f('0x2b')](handleError(_0xea48b7,null));};exports[_0x514f('0xb5')]=function(_0x52569e,_0x58c211,_0x3c8d6d){var _0x30b3fe;return db[_0x514f('0x59')][_0x514f('0x40')]({'where':{'id':_0x52569e[_0x514f('0x5d')]['id']},'attributes':['id',_0x514f('0x41'),_0x514f('0x3f')]})['then'](handleEntityNotFound(_0x58c211,null))['then'](function(_0x43888c){if(_0x43888c){_0x30b3fe=_0x43888c;if(!_0x52569e['query'][_0x514f('0xa3')]||!utils['isValidChannel'](_0x52569e[_0x514f('0x4b')]['channel'])){throw new db[(_0x514f('0x99'))][(_0x514f('0x97'))](_0x514f('0xa9'));}return _0x43888c['remove'+_[_0x514f('0xab')](_0x52569e[_0x514f('0x4b')][_0x514f('0xa3')][_0x514f('0xae')]())+_0x514f('0xac')](_0x52569e[_0x514f('0x4b')][_0x514f('0x65')]);}})[_0x514f('0x22')](function(_0xebf858){for(var _0x350f34=0x0;_0x350f34<_0x52569e[_0x514f('0x4b')][_0x514f('0x65')][_0x514f('0x60')];_0x350f34+=0x1){var _0x16b300={'UserId':_0x52569e[_0x514f('0x5d')]['id']};_0x16b300[_['capitalize'](_0x52569e['query'][_0x514f('0xa3')]['toLowerCase']())+_0x514f('0xaf')]=_0x52569e[_0x514f('0x4b')]['ids'][_0x350f34];socket['emit']('user'+_[_0x514f('0xab')](_0x52569e[_0x514f('0x4b')][_0x514f('0xa3')][_0x514f('0xae')]())+_0x514f('0xb6'),_0x16b300);}return _0xebf858;})[_0x514f('0x22')](function(){if(_0x52569e[_0x514f('0x4b')][_0x514f('0xa3')]===_0x514f('0xb1')){return db[_0x514f('0xb7')][_0x514f('0x36')]({'where':{'UserId':_0x52569e['params']['id'],'VoiceQueueId':_0x52569e[_0x514f('0x4b')]['ids']},'individualHooks':!![]})[_0x514f('0x22')](function(){return _0x30b3fe;});}return _0x30b3fe;})['then'](respondWithStatusCode(_0x58c211,null))[_0x514f('0x2b')](handleError(_0x58c211,null));};exports[_0x514f('0xb8')]=function(_0x335b2b,_0x2f08b9,_0x10c254){_0x335b2b[_0x514f('0x62')]['userpic']=_0x335b2b['file'][_0x514f('0xb9')];return db[_0x514f('0x59')]['find']({'where':{'id':_0x335b2b[_0x514f('0x5d')]['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x2f08b9,null))[_0x514f('0x22')](saveUpdates(_0x335b2b[_0x514f('0x62')],null))[_0x514f('0x22')](respondWithResult(_0x2f08b9,null))[_0x514f('0x2b')](handleError(_0x2f08b9,null));};exports[_0x514f('0xba')]=function(_0x550c12,_0x5cd6bf,_0x534cc8){var _0x1a3fd7=path[_0x514f('0xbb')](config['root'],_0x514f('0xbc'));return db[_0x514f('0x59')][_0x514f('0x40')]({'where':{'id':_0x550c12['params']['id']},'attributes':['id',_0x514f('0xbd')],'raw':!![]})[_0x514f('0x22')](handleEntityNotFound(_0x5cd6bf,null))['then'](function(_0x46fff9){if(_0x46fff9){if(_['isNil'](_0x46fff9['userpic'])){return _0x5cd6bf['download'](_0x1a3fd7);}else{if(!fs[_0x514f('0xbe')](path[_0x514f('0xbb')](config[_0x514f('0xbf')],_0x514f('0xc0'),_0x46fff9['userpic']))){return _0x5cd6bf['download'](_0x1a3fd7);}return _0x5cd6bf[_0x514f('0xc1')](path[_0x514f('0xbb')](config['root'],_0x514f('0xc0'),_0x46fff9[_0x514f('0xbd')]));}}})[_0x514f('0x2b')](handleError(_0x5cd6bf,null));};exports[_0x514f('0xc2')]=function(_0x5a0fd6,_0x4657de,_0x216377){var _0x2d75a5={};var _0x2eef4a={};var _0x5a4b79;var _0x45e6cc;return db[_0x514f('0x59')]['findOne']({'where':{'id':_0x5a0fd6[_0x514f('0x5d')]['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x4657de,null))['then'](function(_0xd7c47f){if(_0xd7c47f){_0x5a4b79=_0xd7c47f;_0x2eef4a[_0x514f('0x47')]=_[_0x514f('0x4a')](db[_0x514f('0xc3')][_0x514f('0x5e')]);_0x2eef4a[_0x514f('0x4b')]=_[_0x514f('0x4a')](_0x5a0fd6[_0x514f('0x4b')]);_0x2eef4a[_0x514f('0x4c')]=_[_0x514f('0x4d')](_0x2eef4a['model'],_0x2eef4a[_0x514f('0x4b')]);_0x2d75a5[_0x514f('0x4f')]=_['intersection'](_0x2eef4a[_0x514f('0x47')],qs[_0x514f('0x4e')](_0x5a0fd6[_0x514f('0x4b')][_0x514f('0x4e')]));_0x2d75a5[_0x514f('0x4f')]=_0x2d75a5[_0x514f('0x4f')][_0x514f('0x60')]?_0x2d75a5['attributes']:_0x2eef4a['model'];_0x2d75a5[_0x514f('0x51')]=qs['sort'](_0x5a0fd6[_0x514f('0x4b')][_0x514f('0x52')]);_0x2d75a5[_0x514f('0x53')]=qs['filters'](_[_0x514f('0xc4')](_0x5a0fd6['query'],_0x2eef4a['filters']));if(_0x5a0fd6['query'][_0x514f('0x3b')]){_0x2d75a5[_0x514f('0x53')]=_[_0x514f('0x54')](_0x2d75a5[_0x514f('0x53')],{'$or':_[_0x514f('0x3c')](_0x2d75a5[_0x514f('0x4f')],function(_0x5d14f5){var _0x1e7bd3={};_0x1e7bd3[_0x5d14f5]={'$like':'%'+_0x5a0fd6[_0x514f('0x4b')]['filter']+'%'};return _0x1e7bd3;})});}_0x2d75a5=_['merge']({},_0x2d75a5,_0x5a0fd6['options']);return _0x5a4b79[_0x514f('0xc2')](_0x2d75a5);}})['then'](function(_0x3d16eb){if(_0x3d16eb){_0x45e6cc=_0x3d16eb[_0x514f('0x60')];if(_0x5a0fd6[_0x514f('0x4b')][_0x514f('0x50')](_0x514f('0x5a'))){_0x2d75a5['include']=[{'model':db[_0x514f('0xc5')],'as':'List','required':![]},{'model':db[_0x514f('0xc6')],'as':_0x514f('0xc7'),'attributes':['id',_0x514f('0x41'),'color'],'where':_0x5a0fd6['query'][_0x514f('0xc8')]?{'id':_0x5a0fd6[_0x514f('0x4b')][_0x514f('0xc8')]}:undefined,'required':_0x5a0fd6['query'][_0x514f('0xc8')]?!![]:![]}];}if(!_0x5a0fd6[_0x514f('0x4b')]['hasOwnProperty']('nolimit')){_0x2d75a5[_0x514f('0x31')]=qs[_0x514f('0x31')](_0x5a0fd6['query'][_0x514f('0x31')]);_0x2d75a5[_0x514f('0x30')]=qs[_0x514f('0x30')](_0x5a0fd6[_0x514f('0x4b')][_0x514f('0x30')]);}return _0x5a4b79['getContacts'](_0x2d75a5);}})['then'](function(_0x258594){if(_0x258594){return _0x258594?{'count':_0x45e6cc,'rows':_0x258594}:null;}})['then'](respondWithResult(_0x4657de,null))[_0x514f('0x2b')](handleError(_0x4657de,null));};exports[_0x514f('0xc9')]=function(_0x49cf34,_0x721990,_0x2c2ae0){var _0x309e74;var _0x262fa4;var _0x517acd={};var _0x217a8f;return db[_0x514f('0x59')][_0x514f('0x9c')]({'where':{'id':_0x49cf34['params']['id']},'attributes':['id',_0x514f('0x41'),'role']})[_0x514f('0x22')](handleEntityNotFound(_0x721990,null))[_0x514f('0x22')](function(_0x541fc1){if(!utils[_0x514f('0xa8')](_0x49cf34[_0x514f('0x4b')][_0x514f('0xa3')])){throw new db[(_0x514f('0x99'))]['ValidationError'](_0x514f('0xa9'));}_0x309e74=_0x541fc1;var _0x5cab29={};_0x5cab29[_0x514f('0x47')]=_[_0x514f('0x4a')](db[_[_0x514f('0xab')](_0x49cf34[_0x514f('0x4b')]['channel'])+_0x514f('0xca')][_0x514f('0x5e')]);_0x5cab29[_0x514f('0x4b')]=_[_0x514f('0x4a')](_0x49cf34['query']);_0x5cab29[_0x514f('0x4c')]=_[_0x514f('0x4d')](_0x5cab29['model'],_0x5cab29[_0x514f('0x4b')]);_0x517acd['attributes']=_[_0x514f('0x4d')](_0x5cab29[_0x514f('0x47')],qs['fields'](_0x49cf34[_0x514f('0x4b')][_0x514f('0x4e')]));_0x517acd['attributes']=_0x517acd[_0x514f('0x4f')][_0x514f('0x60')]?_0x517acd[_0x514f('0x4f')]:_0x5cab29['model'];_0x517acd[_0x514f('0x51')]=qs[_0x514f('0x52')](_0x49cf34[_0x514f('0x4b')]['sort']);_0x517acd['where']=qs[_0x514f('0x4c')](_[_0x514f('0xc4')](_0x49cf34[_0x514f('0x4b')],_0x5cab29[_0x514f('0x4c')]));if(_0x49cf34['query'][_0x514f('0x3b')]){_0x517acd[_0x514f('0x53')]=_['merge'](_0x517acd[_0x514f('0x53')],{'$or':_['map'](_0x517acd[_0x514f('0x4f')],function(_0x111c7c){var _0x13ee93={};_0x13ee93[_0x111c7c]={'$like':'%'+_0x49cf34[_0x514f('0x4b')]['filter']+'%'};return _0x13ee93;})});}_0x517acd=_[_0x514f('0x54')]({},_0x517acd,_0x49cf34[_0x514f('0x58')]);switch(_0x309e74['role']){case'admin':return db[_[_0x514f('0xab')](_0x49cf34['query']['channel'])+'Queue'][_0x514f('0x5b')](_0x517acd);case'user':case _0x514f('0x72'):return _0x309e74[_0x514f('0x37')+_[_0x514f('0xab')](_0x49cf34[_0x514f('0x4b')][_0x514f('0xa3')])+_0x514f('0xac')](_0x517acd);default:throw new db['Sequelize'][(_0x514f('0x97'))]('Unknown\x20role');}})[_0x514f('0x22')](function(_0x59e370){_0x217a8f=_0x59e370[_0x514f('0x60')];if(!_0x49cf34[_0x514f('0x4b')][_0x514f('0x50')]('nolimit')){_0x517acd['limit']=qs['limit'](_0x49cf34[_0x514f('0x4b')][_0x514f('0x31')]);_0x517acd[_0x514f('0x30')]=qs[_0x514f('0x30')](_0x49cf34[_0x514f('0x4b')]['offset']);}switch(_0x309e74['role']){case'admin':return db[_[_0x514f('0xab')](_0x49cf34['query']['channel'])+'Queue']['findAll'](_0x517acd);case'user':case _0x514f('0x72'):return _0x309e74['get'+_[_0x514f('0xab')](_0x49cf34['query'][_0x514f('0xa3')])+'Queues'](_0x517acd);}})['then'](function(_0x4d9dfb){return{'count':_0x217a8f,'rows':_0x4d9dfb};})[_0x514f('0x22')](respondWithResult(_0x721990,null))[_0x514f('0x2b')](handleError(_0x721990,null));};exports['getVoiceQueuesRt']=function(_0x189460,_0x414927,_0x43570b){var _0x41d2ef={};var _0x1a6c3b={};var _0x440a4d;var _0x3dd480;return db[_0x514f('0x59')][_0x514f('0x9c')]({'where':{'id':_0x189460[_0x514f('0x5d')]['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x414927,null))[_0x514f('0x22')](function(_0x33c777){if(_0x33c777){_0x440a4d=_0x33c777;_0x1a6c3b[_0x514f('0x47')]=_[_0x514f('0x4a')](db['UserVoiceQueueRt']['rawAttributes']);_0x1a6c3b[_0x514f('0x4b')]=_[_0x514f('0x4a')](_0x189460[_0x514f('0x4b')]);_0x1a6c3b[_0x514f('0x4c')]=_[_0x514f('0x4d')](_0x1a6c3b[_0x514f('0x47')],_0x1a6c3b[_0x514f('0x4b')]);_0x41d2ef[_0x514f('0x4f')]=_[_0x514f('0x4d')](_0x1a6c3b[_0x514f('0x47')],qs[_0x514f('0x4e')](_0x189460[_0x514f('0x4b')]['fields']));_0x41d2ef[_0x514f('0x4f')]=_0x41d2ef[_0x514f('0x4f')][_0x514f('0x60')]?_0x41d2ef[_0x514f('0x4f')]:_0x1a6c3b['model'];_0x41d2ef[_0x514f('0x51')]=qs[_0x514f('0x52')](_0x189460[_0x514f('0x4b')][_0x514f('0x52')]);_0x41d2ef[_0x514f('0x53')]=qs[_0x514f('0x4c')](_[_0x514f('0xc4')](_0x189460[_0x514f('0x4b')],_0x1a6c3b[_0x514f('0x4c')]));if(_0x189460[_0x514f('0x4b')]['filter']){_0x41d2ef['where']=_[_0x514f('0x54')](_0x41d2ef['where'],{'$or':_[_0x514f('0x3c')](_0x41d2ef[_0x514f('0x4f')],function(_0x2bfc3c){var _0x3eee61={};_0x3eee61[_0x2bfc3c]={'$like':'%'+_0x189460['query'][_0x514f('0x3b')]+'%'};return _0x3eee61;})});}_0x41d2ef=_['merge']({},_0x41d2ef,_0x189460['options']);return _0x440a4d[_0x514f('0xcb')](_0x41d2ef);}})['then'](function(_0x3e8e18){if(_0x3e8e18){_0x3dd480=_0x3e8e18['length'];if(!_0x189460['query'][_0x514f('0x50')](_0x514f('0xcc'))){_0x41d2ef[_0x514f('0x31')]=qs['limit'](_0x189460[_0x514f('0x4b')]['limit']);_0x41d2ef[_0x514f('0x30')]=qs['offset'](_0x189460[_0x514f('0x4b')]['offset']);}return _0x440a4d[_0x514f('0xcb')](_0x41d2ef);}})['then'](function(_0xdd42fe){if(_0xdd42fe){return _0xdd42fe?{'count':_0x3dd480,'rows':_0xdd42fe}:null;}})[_0x514f('0x22')](respondWithResult(_0x414927,null))[_0x514f('0x2b')](handleError(_0x414927,null));};exports[_0x514f('0xcd')]=function(_0x40c3d8,_0x274173,_0x29ce04){var _0x1e98b1={};var _0xbd1710={};var _0x9ab667;var _0x3d06f2;return db[_0x514f('0x59')][_0x514f('0x9c')]({'where':{'id':_0x40c3d8[_0x514f('0x5d')]['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x274173,null))['then'](function(_0x331fc7){if(_0x331fc7){_0x9ab667=_0x331fc7;_0xbd1710[_0x514f('0x47')]=_[_0x514f('0x4a')](db['ChatGroup'][_0x514f('0x5e')]);_0xbd1710[_0x514f('0x4b')]=_[_0x514f('0x4a')](_0x40c3d8['query']);_0xbd1710['filters']=_[_0x514f('0x4d')](_0xbd1710[_0x514f('0x47')],_0xbd1710[_0x514f('0x4b')]);_0x1e98b1['attributes']=_[_0x514f('0x4d')](_0xbd1710[_0x514f('0x47')],qs[_0x514f('0x4e')](_0x40c3d8[_0x514f('0x4b')][_0x514f('0x4e')]));_0x1e98b1[_0x514f('0x4f')]=_0x1e98b1[_0x514f('0x4f')]['length']?_0x1e98b1[_0x514f('0x4f')]:_0xbd1710[_0x514f('0x47')];_0x1e98b1[_0x514f('0x51')]=qs[_0x514f('0x52')](_0x40c3d8[_0x514f('0x4b')][_0x514f('0x52')]);_0x1e98b1[_0x514f('0x53')]=qs[_0x514f('0x4c')](_[_0x514f('0xc4')](_0x40c3d8[_0x514f('0x4b')],_0xbd1710[_0x514f('0x4c')]));if(_0x40c3d8['query'][_0x514f('0x3b')]){_0x1e98b1[_0x514f('0x53')]=_['merge'](_0x1e98b1['where'],{'$or':_['map'](_0x1e98b1['attributes'],function(_0x2cb490){var _0x16cd46={};_0x16cd46[_0x2cb490]={'$like':'%'+_0x40c3d8[_0x514f('0x4b')][_0x514f('0x3b')]+'%'};return _0x16cd46;})});}_0x1e98b1=_[_0x514f('0x54')]({},_0x1e98b1,_0x40c3d8[_0x514f('0x58')]);return _0x9ab667[_0x514f('0xcd')](_0x1e98b1);}})[_0x514f('0x22')](function(_0x2a1274){if(_0x2a1274){_0x3d06f2=_0x2a1274['length'];if(!_0x40c3d8[_0x514f('0x4b')]['hasOwnProperty']('nolimit')){_0x1e98b1[_0x514f('0x31')]=qs[_0x514f('0x31')](_0x40c3d8[_0x514f('0x4b')][_0x514f('0x31')]);_0x1e98b1[_0x514f('0x30')]=qs['offset'](_0x40c3d8[_0x514f('0x4b')][_0x514f('0x30')]);}return _0x9ab667[_0x514f('0xcd')](_0x1e98b1);}})[_0x514f('0x22')](function(_0x57fe1a){if(_0x57fe1a){return _0x57fe1a?{'count':_0x3d06f2,'rows':_0x57fe1a}:null;}})['then'](respondWithResult(_0x274173,null))[_0x514f('0x2b')](handleError(_0x274173,null));};exports[_0x514f('0xce')]=function(_0x39cc1c,_0x2f0337,_0xba0bb7){var _0x5939bb={'raw':!![],'where':{}};var _0x2a6875={};var _0x568a9d={'count':0x0,'rows':[]};return db[_0x514f('0x59')][_0x514f('0x9c')]({'where':{'id':_0x39cc1c[_0x514f('0x5d')]['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x2f0337,null))['then'](function(_0x1e2126){if(_0x1e2126){_0x2a6875['model']=_['keys'](db['VoiceRecording'][_0x514f('0x5e')]);_0x2a6875[_0x514f('0x4b')]=_['keys'](_0x39cc1c[_0x514f('0x4b')]);_0x2a6875['filters']=_[_0x514f('0x4d')](_0x2a6875[_0x514f('0x47')],_0x2a6875['query']);_0x5939bb[_0x514f('0x4f')]=_['intersection'](_0x2a6875['model'],qs[_0x514f('0x4e')](_0x39cc1c[_0x514f('0x4b')][_0x514f('0x4e')]));_0x5939bb[_0x514f('0x4f')]=_0x5939bb[_0x514f('0x4f')][_0x514f('0x60')]?_0x5939bb[_0x514f('0x4f')]:_0x2a6875[_0x514f('0x47')];if(!_0x39cc1c['query'][_0x514f('0x50')](_0x514f('0xcc'))){_0x5939bb[_0x514f('0x31')]=qs[_0x514f('0x31')](_0x39cc1c[_0x514f('0x4b')][_0x514f('0x31')]);_0x5939bb[_0x514f('0x30')]=qs[_0x514f('0x30')](_0x39cc1c['query'][_0x514f('0x30')]);}_0x5939bb['order']=qs[_0x514f('0x52')](_0x39cc1c['query'][_0x514f('0x52')]);_0x5939bb[_0x514f('0x53')]=qs[_0x514f('0x4c')](_[_0x514f('0xc4')](_0x39cc1c[_0x514f('0x4b')],_0x2a6875['filters']));_0x5939bb['where'][_0x514f('0xcf')]=_0x1e2126['id'];if(_0x39cc1c[_0x514f('0x4b')][_0x514f('0x3b')]){_0x5939bb[_0x514f('0x53')]=_['merge'](_0x5939bb['where'],{'$or':_[_0x514f('0x3c')](_0x5939bb['attributes'],function(_0x4d44cc){var _0x3bfe5d={};_0x3bfe5d[_0x4d44cc]={'$like':'%'+_0x39cc1c['query']['filter']+'%'};return _0x3bfe5d;})});}_0x5939bb=_[_0x514f('0x54')]({},_0x5939bb,_0x39cc1c[_0x514f('0x58')]);return db[_0x514f('0xd0')]['count']({'where':_0x5939bb[_0x514f('0x53')]})[_0x514f('0x22')](function(_0x522e7d){_0x568a9d['count']=_0x522e7d;if(_0x39cc1c[_0x514f('0x4b')][_0x514f('0x5a')]){_0x5939bb[_0x514f('0x61')]=[{'all':!![]}];}return db[_0x514f('0xd0')][_0x514f('0x5b')](_0x5939bb);})[_0x514f('0x22')](function(_0x180c27){_0x568a9d['rows']=_0x180c27;return _0x568a9d;});}})[_0x514f('0x22')](respondWithFilteredResult(_0x2f0337,_0x5939bb))[_0x514f('0x2b')](handleError(_0x2f0337,null));};exports['getScreenRecordings']=function(_0x4045a1,_0x5f1286,_0x2aea6a){var _0x503f99={'raw':!![],'where':{}};var _0x5227f0={};var _0x3ee51c={'count':0x0,'rows':[]};return db[_0x514f('0x59')][_0x514f('0x9c')]({'where':{'id':_0x4045a1[_0x514f('0x5d')]['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x5f1286,null))[_0x514f('0x22')](function(_0x44c62c){if(_0x44c62c){_0x5227f0[_0x514f('0x47')]=_[_0x514f('0x4a')](db['ScreenRecording'][_0x514f('0x5e')]);_0x5227f0[_0x514f('0x4b')]=_[_0x514f('0x4a')](_0x4045a1[_0x514f('0x4b')]);_0x5227f0['filters']=_[_0x514f('0x4d')](_0x5227f0[_0x514f('0x47')],_0x5227f0[_0x514f('0x4b')]);_0x503f99['attributes']=_[_0x514f('0x4d')](_0x5227f0['model'],qs['fields'](_0x4045a1[_0x514f('0x4b')]['fields']));_0x503f99['attributes']=_0x503f99[_0x514f('0x4f')][_0x514f('0x60')]?_0x503f99[_0x514f('0x4f')]:_0x5227f0['model'];if(!_0x4045a1[_0x514f('0x4b')][_0x514f('0x50')](_0x514f('0xcc'))){_0x503f99[_0x514f('0x31')]=qs[_0x514f('0x31')](_0x4045a1[_0x514f('0x4b')]['limit']);_0x503f99[_0x514f('0x30')]=qs[_0x514f('0x30')](_0x4045a1[_0x514f('0x4b')][_0x514f('0x30')]);}_0x503f99[_0x514f('0x51')]=qs[_0x514f('0x52')](_0x4045a1[_0x514f('0x4b')][_0x514f('0x52')]);_0x503f99[_0x514f('0x53')]=qs[_0x514f('0x4c')](_[_0x514f('0xc4')](_0x4045a1[_0x514f('0x4b')],_0x5227f0[_0x514f('0x4c')]));_0x503f99[_0x514f('0x53')][_0x514f('0xcf')]=_0x44c62c['id'];if(_0x4045a1[_0x514f('0x4b')][_0x514f('0x3b')]){_0x503f99[_0x514f('0x53')]=_[_0x514f('0x54')](_0x503f99[_0x514f('0x53')],{'$or':_[_0x514f('0x3c')](_0x503f99[_0x514f('0x4f')],function(_0x52bbaf){var _0xeb3ef7={};_0xeb3ef7[_0x52bbaf]={'$like':'%'+_0x4045a1[_0x514f('0x4b')]['filter']+'%'};return _0xeb3ef7;})});}_0x503f99=_[_0x514f('0x54')]({},_0x503f99,_0x4045a1['options']);return db[_0x514f('0xd1')][_0x514f('0x2f')]({'where':_0x503f99[_0x514f('0x53')]})[_0x514f('0x22')](function(_0x21055a){_0x3ee51c['count']=_0x21055a;if(_0x4045a1[_0x514f('0x4b')]['includeAll']){_0x503f99[_0x514f('0x61')]=[{'all':!![]}];}return db[_0x514f('0xd1')]['findAll'](_0x503f99);})[_0x514f('0x22')](function(_0x1add92){_0x3ee51c[_0x514f('0xd2')]=_0x1add92;return _0x3ee51c;});}})['then'](respondWithFilteredResult(_0x5f1286,_0x503f99))['catch'](handleError(_0x5f1286,null));};exports[_0x514f('0xd3')]=function(_0x5c803f,_0x31073e,_0x307915){var _0x283433={};var _0x309fa7={};var _0x983f8;var _0x118892;return db[_0x514f('0x59')]['findOne']({'where':{'id':_0x5c803f[_0x514f('0x5d')]['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x31073e,null))['then'](function(_0x363c35){if(_0x363c35){_0x983f8=_0x363c35;_0x309fa7[_0x514f('0x47')]=_[_0x514f('0x4a')](db[_0x514f('0xd4')]['rawAttributes']);_0x309fa7[_0x514f('0x4b')]=_[_0x514f('0x4a')](_0x5c803f[_0x514f('0x4b')]);_0x309fa7[_0x514f('0x4c')]=_['intersection'](_0x309fa7[_0x514f('0x47')],_0x309fa7[_0x514f('0x4b')]);_0x283433[_0x514f('0x4f')]=_['intersection'](_0x309fa7[_0x514f('0x47')],qs[_0x514f('0x4e')](_0x5c803f[_0x514f('0x4b')]['fields']));_0x283433['attributes']=_0x283433[_0x514f('0x4f')][_0x514f('0x60')]?_0x283433[_0x514f('0x4f')]:_0x309fa7[_0x514f('0x47')];_0x283433[_0x514f('0x51')]=qs[_0x514f('0x52')](_0x5c803f[_0x514f('0x4b')]['sort']);_0x283433[_0x514f('0x53')]=qs[_0x514f('0x4c')](_['pick'](_0x5c803f[_0x514f('0x4b')],_0x309fa7[_0x514f('0x4c')]));if(_0x5c803f['query'][_0x514f('0x3b')]){_0x283433[_0x514f('0x53')]=_['merge'](_0x283433[_0x514f('0x53')],{'$or':_[_0x514f('0x3c')](_0x283433[_0x514f('0x4f')],function(_0x1e1464){var _0x15f24c={};_0x15f24c[_0x1e1464]={'$like':'%'+_0x5c803f[_0x514f('0x4b')][_0x514f('0x3b')]+'%'};return _0x15f24c;})});}_0x283433=_[_0x514f('0x54')]({},_0x283433,_0x5c803f[_0x514f('0x58')]);return _0x983f8[_0x514f('0xd3')](_0x283433);}})[_0x514f('0x22')](function(_0x1344a9){if(_0x1344a9){_0x118892=_0x1344a9[_0x514f('0x60')];if(!_0x5c803f[_0x514f('0x4b')]['hasOwnProperty']('nolimit')){_0x283433[_0x514f('0x31')]=qs[_0x514f('0x31')](_0x5c803f['query'][_0x514f('0x31')]);_0x283433[_0x514f('0x30')]=qs['offset'](_0x5c803f[_0x514f('0x4b')]['offset']);}return _0x983f8[_0x514f('0xd3')](_0x283433);}})[_0x514f('0x22')](function(_0x591796){if(_0x591796){return _0x591796?{'count':_0x118892,'rows':_0x591796}:null;}})[_0x514f('0x22')](respondWithResult(_0x31073e,null))[_0x514f('0x2b')](handleError(_0x31073e,null));};exports['getOpenchannelInteractions']=function(_0x1ccabf,_0x5baf13,_0x575c8f){var _0x41ac10={};var _0x5a6356={};var _0x2b68d1;var _0x59841c;return db['User'][_0x514f('0x9c')]({'where':{'id':_0x1ccabf[_0x514f('0x5d')]['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x5baf13,null))[_0x514f('0x22')](function(_0x517e8b){if(_0x517e8b){_0x2b68d1=_0x517e8b;_0x5a6356['model']=_[_0x514f('0x4a')](db[_0x514f('0xd5')]['rawAttributes']);_0x5a6356[_0x514f('0x4b')]=_[_0x514f('0x4a')](_0x1ccabf[_0x514f('0x4b')]);_0x5a6356[_0x514f('0x4c')]=_[_0x514f('0x4d')](_0x5a6356[_0x514f('0x47')],_0x5a6356[_0x514f('0x4b')]);_0x41ac10[_0x514f('0x4f')]=_[_0x514f('0x4d')](_0x5a6356[_0x514f('0x47')],qs[_0x514f('0x4e')](_0x1ccabf[_0x514f('0x4b')][_0x514f('0x4e')]));_0x41ac10[_0x514f('0x4f')]=_0x41ac10[_0x514f('0x4f')][_0x514f('0x60')]?_0x41ac10['attributes']:_0x5a6356[_0x514f('0x47')];_0x41ac10[_0x514f('0x51')]=qs['sort'](_0x1ccabf[_0x514f('0x4b')]['sort']);_0x41ac10[_0x514f('0x53')]=qs[_0x514f('0x4c')](_[_0x514f('0xc4')](_0x1ccabf[_0x514f('0x4b')],_0x5a6356[_0x514f('0x4c')]));if(_0x1ccabf[_0x514f('0x4b')][_0x514f('0x3b')]){_0x41ac10[_0x514f('0x53')]=_[_0x514f('0x54')](_0x41ac10['where'],{'$or':_[_0x514f('0x3c')](_0x41ac10[_0x514f('0x4f')],function(_0x648f0b){var _0x215757={};_0x215757[_0x648f0b]={'$like':'%'+_0x1ccabf[_0x514f('0x4b')]['filter']+'%'};return _0x215757;})});}_0x41ac10=_[_0x514f('0x54')]({},_0x41ac10,_0x1ccabf['options']);return _0x2b68d1[_0x514f('0xd6')](_0x41ac10);}})[_0x514f('0x22')](function(_0x215898){if(_0x215898){_0x59841c=_0x215898[_0x514f('0x60')];if(!_0x1ccabf[_0x514f('0x4b')]['hasOwnProperty'](_0x514f('0xcc'))){_0x41ac10[_0x514f('0x31')]=qs[_0x514f('0x31')](_0x1ccabf[_0x514f('0x4b')][_0x514f('0x31')]);_0x41ac10['offset']=qs[_0x514f('0x30')](_0x1ccabf[_0x514f('0x4b')][_0x514f('0x30')]);}return _0x2b68d1[_0x514f('0xd6')](_0x41ac10);}})[_0x514f('0x22')](function(_0x649200){if(_0x649200){return _0x649200?{'count':_0x59841c,'rows':_0x649200}:null;}})[_0x514f('0x22')](respondWithResult(_0x5baf13,null))[_0x514f('0x2b')](handleError(_0x5baf13,null));};exports[_0x514f('0xd7')]=function(_0x3431e3,_0x45e3c0,_0xc8331b){var _0x4d6c9f={'raw':!![],'where':{}};var _0x324a14={};var _0x4e8552={'count':0x0,'rows':[]};return db[_0x514f('0x59')][_0x514f('0x9c')]({'where':{'id':_0x3431e3[_0x514f('0x5d')]['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x45e3c0,null))[_0x514f('0x22')](function(_0x33dfc1){if(_0x33dfc1){_0x324a14[_0x514f('0x47')]=_[_0x514f('0x4a')](db[_0x514f('0xd8')][_0x514f('0x5e')]);_0x324a14[_0x514f('0x4b')]=_[_0x514f('0x4a')](_0x3431e3[_0x514f('0x4b')]);_0x324a14['filters']=_['intersection'](_0x324a14[_0x514f('0x47')],_0x324a14['query']);_0x4d6c9f[_0x514f('0x4f')]=_[_0x514f('0x4d')](_0x324a14[_0x514f('0x47')],qs['fields'](_0x3431e3[_0x514f('0x4b')][_0x514f('0x4e')]));_0x4d6c9f[_0x514f('0x4f')]=_0x4d6c9f['attributes'][_0x514f('0x60')]?_0x4d6c9f[_0x514f('0x4f')]:_0x324a14[_0x514f('0x47')];if(!_0x3431e3[_0x514f('0x4b')][_0x514f('0x50')](_0x514f('0xcc'))){_0x4d6c9f[_0x514f('0x31')]=qs[_0x514f('0x31')](_0x3431e3[_0x514f('0x4b')][_0x514f('0x31')]);_0x4d6c9f['offset']=qs[_0x514f('0x30')](_0x3431e3[_0x514f('0x4b')][_0x514f('0x30')]);}_0x4d6c9f['order']=qs[_0x514f('0x52')](_0x3431e3[_0x514f('0x4b')][_0x514f('0x52')]);_0x4d6c9f[_0x514f('0x53')]=qs[_0x514f('0x4c')](_[_0x514f('0xc4')](_0x3431e3['query'],_0x324a14['filters']));_0x4d6c9f['where'][_0x514f('0xcf')]=_0x33dfc1['id'];if(_0x3431e3[_0x514f('0x4b')][_0x514f('0x3b')]){_0x4d6c9f['where']=_['merge'](_0x4d6c9f['where'],{'$or':_[_0x514f('0x3c')](_0x4d6c9f['attributes'],function(_0x1a7ec6){var _0x5d9e73={};_0x5d9e73[_0x1a7ec6]={'$like':'%'+_0x3431e3[_0x514f('0x4b')][_0x514f('0x3b')]+'%'};return _0x5d9e73;})});}_0x4d6c9f=_[_0x514f('0x54')]({},_0x4d6c9f,_0x3431e3['options']);return db['MailInteraction'][_0x514f('0x2f')]({'where':_0x4d6c9f[_0x514f('0x53')]})[_0x514f('0x22')](function(_0x43beba){_0x4e8552['count']=_0x43beba;if(_0x3431e3[_0x514f('0x4b')]['includeAll']){_0x4d6c9f[_0x514f('0x61')]=[{'all':!![]}];}return db[_0x514f('0xd8')][_0x514f('0x5b')](_0x4d6c9f);})['then'](function(_0x11a084){_0x4e8552['rows']=_0x11a084;return _0x4e8552;});}})[_0x514f('0x22')](respondWithFilteredResult(_0x45e3c0,_0x4d6c9f))[_0x514f('0x2b')](handleError(_0x45e3c0,null));};exports[_0x514f('0xd9')]=function(_0x4d5a8d,_0x204b6a,_0xb623d5){var _0x56ca1c={};var _0x273220={};var _0xb03956;var _0x389f3a;return db[_0x514f('0x59')]['findOne']({'where':{'id':_0x4d5a8d[_0x514f('0x5d')]['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x204b6a,null))[_0x514f('0x22')](function(_0x575e3e){if(_0x575e3e){_0xb03956=_0x575e3e;_0x273220[_0x514f('0x47')]=_[_0x514f('0x4a')](db['SmsInteraction'][_0x514f('0x5e')]);_0x273220['query']=_['keys'](_0x4d5a8d[_0x514f('0x4b')]);_0x273220[_0x514f('0x4c')]=_[_0x514f('0x4d')](_0x273220['model'],_0x273220[_0x514f('0x4b')]);_0x56ca1c[_0x514f('0x4f')]=_[_0x514f('0x4d')](_0x273220[_0x514f('0x47')],qs[_0x514f('0x4e')](_0x4d5a8d[_0x514f('0x4b')][_0x514f('0x4e')]));_0x56ca1c['attributes']=_0x56ca1c['attributes'][_0x514f('0x60')]?_0x56ca1c[_0x514f('0x4f')]:_0x273220['model'];_0x56ca1c['order']=qs[_0x514f('0x52')](_0x4d5a8d[_0x514f('0x4b')][_0x514f('0x52')]);_0x56ca1c[_0x514f('0x53')]=qs[_0x514f('0x4c')](_['pick'](_0x4d5a8d['query'],_0x273220['filters']));if(_0x4d5a8d[_0x514f('0x4b')][_0x514f('0x3b')]){_0x56ca1c[_0x514f('0x53')]=_[_0x514f('0x54')](_0x56ca1c[_0x514f('0x53')],{'$or':_[_0x514f('0x3c')](_0x56ca1c['attributes'],function(_0x372fac){var _0x1614d3={};_0x1614d3[_0x372fac]={'$like':'%'+_0x4d5a8d[_0x514f('0x4b')][_0x514f('0x3b')]+'%'};return _0x1614d3;})});}_0x56ca1c=_[_0x514f('0x54')]({},_0x56ca1c,_0x4d5a8d[_0x514f('0x58')]);return _0xb03956['getSmsInteractions'](_0x56ca1c);}})[_0x514f('0x22')](function(_0x45613c){if(_0x45613c){_0x389f3a=_0x45613c['length'];if(!_0x4d5a8d['query'][_0x514f('0x50')]('nolimit')){_0x56ca1c['limit']=qs[_0x514f('0x31')](_0x4d5a8d[_0x514f('0x4b')][_0x514f('0x31')]);_0x56ca1c[_0x514f('0x30')]=qs['offset'](_0x4d5a8d[_0x514f('0x4b')][_0x514f('0x30')]);}return _0xb03956[_0x514f('0xd9')](_0x56ca1c);}})['then'](function(_0x5612d6){if(_0x5612d6){return _0x5612d6?{'count':_0x389f3a,'rows':_0x5612d6}:null;}})[_0x514f('0x22')](respondWithResult(_0x204b6a,null))[_0x514f('0x2b')](handleError(_0x204b6a,null));};exports[_0x514f('0xda')]=function(_0x39207e,_0x1b513f,_0x4a37d7){var _0x4c9f77={};var _0x395d38={};var _0x4c943a;var _0x168289;return db[_0x514f('0x59')][_0x514f('0x9c')]({'where':{'id':_0x39207e[_0x514f('0x5d')]['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x1b513f,null))[_0x514f('0x22')](function(_0x12bb87){if(_0x12bb87){_0x4c943a=_0x12bb87;_0x395d38[_0x514f('0x47')]=_[_0x514f('0x4a')](db['FaxInteraction'][_0x514f('0x5e')]);_0x395d38[_0x514f('0x4b')]=_['keys'](_0x39207e[_0x514f('0x4b')]);_0x395d38[_0x514f('0x4c')]=_[_0x514f('0x4d')](_0x395d38[_0x514f('0x47')],_0x395d38[_0x514f('0x4b')]);_0x4c9f77[_0x514f('0x4f')]=_[_0x514f('0x4d')](_0x395d38[_0x514f('0x47')],qs[_0x514f('0x4e')](_0x39207e[_0x514f('0x4b')][_0x514f('0x4e')]));_0x4c9f77[_0x514f('0x4f')]=_0x4c9f77[_0x514f('0x4f')][_0x514f('0x60')]?_0x4c9f77['attributes']:_0x395d38['model'];_0x4c9f77['order']=qs['sort'](_0x39207e['query'][_0x514f('0x52')]);_0x4c9f77[_0x514f('0x53')]=qs[_0x514f('0x4c')](_['pick'](_0x39207e[_0x514f('0x4b')],_0x395d38[_0x514f('0x4c')]));if(_0x39207e[_0x514f('0x4b')][_0x514f('0x3b')]){_0x4c9f77[_0x514f('0x53')]=_[_0x514f('0x54')](_0x4c9f77['where'],{'$or':_['map'](_0x4c9f77[_0x514f('0x4f')],function(_0xec376d){var _0x8318e1={};_0x8318e1[_0xec376d]={'$like':'%'+_0x39207e[_0x514f('0x4b')]['filter']+'%'};return _0x8318e1;})});}_0x4c9f77=_[_0x514f('0x54')]({},_0x4c9f77,_0x39207e[_0x514f('0x58')]);return _0x4c943a['getFaxInteractions'](_0x4c9f77);}})['then'](function(_0x3411c0){if(_0x3411c0){_0x168289=_0x3411c0[_0x514f('0x60')];if(!_0x39207e[_0x514f('0x4b')][_0x514f('0x50')]('nolimit')){_0x4c9f77['limit']=qs[_0x514f('0x31')](_0x39207e[_0x514f('0x4b')][_0x514f('0x31')]);_0x4c9f77[_0x514f('0x30')]=qs[_0x514f('0x30')](_0x39207e['query'][_0x514f('0x30')]);}return _0x4c943a[_0x514f('0xda')](_0x4c9f77);}})['then'](function(_0x259d61){if(_0x259d61){return _0x259d61?{'count':_0x168289,'rows':_0x259d61}:null;}})[_0x514f('0x22')](respondWithResult(_0x1b513f,null))[_0x514f('0x2b')](handleError(_0x1b513f,null));};exports[_0x514f('0xdb')]=function(_0xae5ce3,_0x179765,_0x44c80b){var _0x5648e2={};var _0x1aa47c={};var _0x3de01a;var _0x1738a5;return db[_0x514f('0x59')][_0x514f('0x9c')]({'where':{'id':_0xae5ce3[_0x514f('0x5d')]['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x179765,null))[_0x514f('0x22')](function(_0x1c44ac){if(_0x1c44ac){_0x3de01a=_0x1c44ac;_0x1aa47c[_0x514f('0x47')]=_[_0x514f('0x4a')](db[_0x514f('0xdc')]['rawAttributes']);_0x1aa47c['query']=_[_0x514f('0x4a')](_0xae5ce3['query']);_0x1aa47c[_0x514f('0x4c')]=_[_0x514f('0x4d')](_0x1aa47c['model'],_0x1aa47c[_0x514f('0x4b')]);_0x5648e2[_0x514f('0x4f')]=_[_0x514f('0x4d')](_0x1aa47c['model'],qs[_0x514f('0x4e')](_0xae5ce3[_0x514f('0x4b')][_0x514f('0x4e')]));_0x5648e2['attributes']=_0x5648e2[_0x514f('0x4f')][_0x514f('0x60')]?_0x5648e2['attributes']:_0x1aa47c[_0x514f('0x47')];_0x5648e2[_0x514f('0x51')]=qs[_0x514f('0x52')](_0xae5ce3[_0x514f('0x4b')][_0x514f('0x52')]);_0x5648e2[_0x514f('0x53')]=qs['filters'](_[_0x514f('0xc4')](_0xae5ce3['query'],_0x1aa47c['filters']));if(_0xae5ce3['query'][_0x514f('0x3b')]){_0x5648e2['where']=_['merge'](_0x5648e2[_0x514f('0x53')],{'$or':_['map'](_0x5648e2['attributes'],function(_0x377320){var _0x2b6d4c={};_0x2b6d4c[_0x377320]={'$like':'%'+_0xae5ce3['query']['filter']+'%'};return _0x2b6d4c;})});}_0x5648e2=_[_0x514f('0x54')]({},_0x5648e2,_0xae5ce3[_0x514f('0x58')]);return _0x3de01a[_0x514f('0xdb')](_0x5648e2);}})[_0x514f('0x22')](function(_0x28c4d8){if(_0x28c4d8){_0x1738a5=_0x28c4d8[_0x514f('0x60')];if(!_0xae5ce3[_0x514f('0x4b')][_0x514f('0x50')]('nolimit')){_0x5648e2[_0x514f('0x31')]=qs[_0x514f('0x31')](_0xae5ce3[_0x514f('0x4b')][_0x514f('0x31')]);_0x5648e2['offset']=qs['offset'](_0xae5ce3[_0x514f('0x4b')][_0x514f('0x30')]);}return _0x3de01a['getWhatsappInteractions'](_0x5648e2);}})[_0x514f('0x22')](function(_0x555e62){if(_0x555e62){return _0x555e62?{'count':_0x1738a5,'rows':_0x555e62}:null;}})[_0x514f('0x22')](respondWithResult(_0x179765,null))[_0x514f('0x2b')](handleError(_0x179765,null));};exports['login']=function(_0x5bc1b0,_0x415942,_0x3c2c84){var _0x527536;var _0x330e39;var _0x4ad670;var _0x34ff87=!_[_0x514f('0x69')](_0x5bc1b0[_0x514f('0x5d')]['id'])?_0x5bc1b0[_0x514f('0x5d')]['id']:!_[_0x514f('0x69')](_0x5bc1b0[_0x514f('0x7f')]['id'])?_0x5bc1b0['user']['id']:null;return db[_0x514f('0x59')]['find']({'where':{'id':_0x34ff87,'role':{'$or':['admin',_0x514f('0x7f'),_0x514f('0x72')]}},'attributes':['id',_0x514f('0x41'),_0x514f('0xdd'),_0x514f('0xde'),'role','internal','loginInPause']})[_0x514f('0x22')](function(_0x107aea){if(_0x107aea){if(_0x107aea[_0x514f('0x3f')]===_0x514f('0x72')){_0x527536=_0x107aea;if(_0x5bc1b0[_0x514f('0x62')][_0x514f('0xa7')]){_0x4ad670=util[_0x514f('0xb3')](_0x514f('0xdf'),_0x527536[_0x5bc1b0[_0x514f('0x62')]['interface']]);}else if(_0x5bc1b0['body'][_0x514f('0xe0')]){_0x4ad670=util[_0x514f('0xb3')](_0x514f('0xb4'),_0x5bc1b0[_0x514f('0x62')]['intrf']);}else{_0x4ad670=util[_0x514f('0xb3')](_0x514f('0xb4'),_0x527536[_0x514f('0x41')]);}socket['to'](util[_0x514f('0xb3')]('user:%s',_0x527536[_0x514f('0x41')]))[_0x514f('0xb0')](_0x514f('0xe1'),{'ip':_0x5bc1b0[_0x514f('0xe2')][_0x514f('0xe3')]||_0x5bc1b0[_0x514f('0xe4')][_0x514f('0xe5')]||_0x5bc1b0[_0x514f('0xe6')][_0x514f('0xe5')]||_0x5bc1b0['connection'][_0x514f('0xe6')][_0x514f('0xe5')]});return db['UserVoiceQueueRt'][_0x514f('0x36')]({'where':{'membername':_0x527536[_0x514f('0x41')]},'individualHooks':!![]});}}else{throw new db[(_0x514f('0x99'))][(_0x514f('0x97'))](_0x514f('0xe7'));}})[_0x514f('0x22')](function(){if(_0x527536){return _0x527536[_0x514f('0xe8')]({'raw':!![]});}})[_0x514f('0x22')](function(_0x19372e){if(_0x527536){var _0x4f5437=[];if(_0x19372e){_0x330e39=_0x19372e;if(_0x330e39[_0x514f('0x60')]){for(var _0x16dc16=0x0;_0x16dc16<_0x330e39['length'];_0x16dc16++){_0x4f5437[_0x514f('0x8b')]({'membername':_0x527536['name'],'UserId':_0x527536['id'],'queue_name':_0x330e39[_0x16dc16][_0x514f('0x41')],'VoiceQueueId':_0x330e39[_0x16dc16]['id'],'interface':_0x4ad670,'paused':_0x527536['loginInPause']||![],'penalty':_0x330e39[_0x16dc16]['UserVoiceQueue.penalty']||0x0});}return BPromise['each'](_0x4f5437,function(_0x50b7d9){return db[_0x514f('0xb7')]['upsert'](_0x50b7d9);});}}}})[_0x514f('0x22')](function(){if(_0x527536){return db[_0x514f('0xe9')][_0x514f('0x5b')]({'where':{'membername':_0x527536['name'],'exitAt':null}});}})[_0x514f('0x22')](function(_0x436f12){if(_0x527536){var _0x4f31e9=[];_0x436f12[_0x514f('0xea')](function(_0x128c14){_0x4f31e9[_0x514f('0x8b')](_0x128c14[_0x514f('0x35')]({'exitAt':moment()[_0x514f('0xb3')](_0x514f('0xeb'))}));});return BPromise['all'](_0x4f31e9);}})[_0x514f('0x22')](function(){if(_0x527536){var _0x4b471a=[];var _0x222ce9=[];var _0x10e620=utils[_0x514f('0xec')]();var _0x59a59b={'membername':_0x527536[_0x514f('0x41')],'interface':_0x4ad670,'enterAt':moment()[_0x514f('0xb3')](_0x514f('0xeb')),'role':_0x527536[_0x514f('0x3f')],'internal':_0x527536['internal']};_0x10e620[_0x514f('0xea')](function(_0x1677d4){_0x4b471a[_0x514f('0x8b')](_[_0x514f('0x54')]({'channel':_0x1677d4,'type':_0x514f('0xed'),'data1':_0x5bc1b0[_0x514f('0x62')]['device'],'data2':_0x4ad670},_0x59a59b));if(_0x527536[_0x514f('0xa5')]){_0x222ce9[_0x514f('0x8b')](_[_0x514f('0x54')]({'channel':_0x1677d4,'type':_0x514f('0xee'),'data1':_0x514f('0xef')},_0x59a59b));}});return db[_0x514f('0xe9')][_0x514f('0xf0')](_0x4b471a['concat'](_0x222ce9),{'individualHooks':!![]});}})[_0x514f('0x22')](function(){if(_0x527536){return _0x527536['update']({'online':!![],'lastLoginAt':moment()['format'](_0x514f('0xeb')),'voicePause':_0x527536['loginInPause']||![],'mailPause':_0x527536[_0x514f('0xa5')]||![],'chatPause':_0x527536[_0x514f('0xa5')]||![],'faxPause':_0x527536[_0x514f('0xa5')]||![],'smsPause':_0x527536['loginInPause']||![],'openchannelPause':_0x527536['loginInPause']||![],'whatsappPause':_0x527536[_0x514f('0xa5')]||![],'pauseType':_0x527536['loginInPause']?_0x514f('0xef'):null,'interface':_0x4ad670,'lastPauseAt':moment()[_0x514f('0xb3')](_0x514f('0xeb'))});}})[_0x514f('0x22')](function(_0xc742fe){if(_0x5bc1b0[_0x514f('0xf1')]){return _0x3c2c84();}else{return BPromise[_0x514f('0xf2')](_0xc742fe)[_0x514f('0x22')](respondWithResult(_0x415942,null));}})[_0x514f('0x2b')](handleError(_0x415942,null));};exports['logout']=function(_0x5c8a36,_0x426e88,_0x39096c){var _0x3dc863;return db['User'][_0x514f('0x40')]({'where':{'id':_0x5c8a36['params']['id'],'role':_0x514f('0x72')},'attributes':['id',_0x514f('0x41'),_0x514f('0x3f')]})['then'](handleEntityNotFound(_0x426e88,null))[_0x514f('0x22')](function(_0x2038c9){if(_0x2038c9){_0x3dc863=_0x2038c9;return db['UserVoiceQueueRt'][_0x514f('0x36')]({'where':{'membername':_0x3dc863[_0x514f('0x41')]},'individualHooks':!![]});}})[_0x514f('0x22')](function(){return db[_0x514f('0xe9')][_0x514f('0x5b')]({'where':{'membername':_0x3dc863[_0x514f('0x41')],'exitAt':null}});})[_0x514f('0x22')](function(_0x18c07b){var _0x5d1c98=[];_0x18c07b[_0x514f('0xea')](function(_0x405c28){_0x5d1c98['push'](_0x405c28[_0x514f('0x35')]({'exitAt':moment()[_0x514f('0xb3')](_0x514f('0xeb'))}));});return BPromise[_0x514f('0x8c')](_0x5d1c98);})[_0x514f('0x22')](function(){return _0x3dc863['update']({'online':![],'lastLoginAt':null,'voicePause':![],'mailPause':![],'chatPause':![],'faxPause':![],'smsPause':![],'openchannelPause':![],'whatsappPause':![],'interface':null});})[_0x514f('0x22')](respondWithResult(_0x426e88,null))['catch'](handleError(_0x426e88,null));};exports[_0x514f('0xf3')]=function(_0xe175af,_0x3805d8,_0x4533b3){var _0x4dd53c;return db[_0x514f('0xb7')][_0x514f('0x35')]({'paused':0x1},{'where':{'UserId':_0xe175af[_0x514f('0x5d')]['id']},'individualHooks':!![]})[_0x514f('0x22')](function(){return db[_0x514f('0x59')][_0x514f('0x40')]({'where':{'id':_0xe175af[_0x514f('0x5d')]['id'],'role':'agent'},'attributes':['id',_0x514f('0x41'),_0x514f('0x3f'),_0x514f('0x6a'),_0x514f('0xa7')]});})[_0x514f('0x22')](handleEntityNotFound(_0x3805d8,null))[_0x514f('0x22')](function(_0x229ade){if(_0x229ade){_0x4dd53c=_0x229ade;return respondWithRpcPromise(_0x514f('0xf4'),'pause',{'id':_0x4dd53c['id'],'name':_0x4dd53c[_0x514f('0x41')],'pause':!![]});}})[_0x514f('0x22')](function(){if(_0x4dd53c){return db[_0x514f('0xe9')][_0x514f('0x5b')]({'where':{'membername':_0x4dd53c[_0x514f('0x41')],'type':'PAUSE','exitAt':null}});}})[_0x514f('0x22')](function(_0x4a953b){if(_0x4a953b[_0x514f('0x60')]){var _0x1c9557=moment()[_0x514f('0xb3')]('YYYY-MM-DD\x20HH:mm:ss');for(var _0x31b2f2=0x0,_0x2e9d5c=_0x4a953b[_0x514f('0x60')];_0x31b2f2<_0x2e9d5c;_0x31b2f2++){_0x4a953b[_0x31b2f2][_0x514f('0xf5')]({'exitAt':_0x1c9557});}}})[_0x514f('0x22')](function(){var _0x521302=[];var _0x505983=utils['getChannels']();_0x505983[_0x514f('0xea')](function(_0x13087a){_0x521302['push']({'channel':_0x13087a,'membername':_0x4dd53c[_0x514f('0x41')],'interface':_[_0x514f('0x69')](_0x4dd53c[_0x514f('0xa7')])?util['format']('SIP/%s',_0x4dd53c[_0x514f('0x41')]):_0x4dd53c['interface'],'type':'PAUSE','enterAt':moment()['format'](_0x514f('0xeb')),'data1':_0xe175af['body'][_0x514f('0x45')]||_0x514f('0xf6'),'role':_0x4dd53c[_0x514f('0x3f')],'internal':_0x4dd53c[_0x514f('0x6a')]});});return db['MemberReport']['bulkCreate'](_0x521302,{'individualHooks':!![]});})['then'](function(){return _0x4dd53c[_0x514f('0x35')]({'voicePause':!![],'mailPause':!![],'chatPause':!![],'faxPause':!![],'smsPause':!![],'whatsappPause':!![],'openchannelPause':!![],'pauseType':_0xe175af[_0x514f('0x62')][_0x514f('0x45')]||'DEFAULT\x20PAUSE','lastPauseAt':moment()['format'](_0x514f('0xeb'))});})['then'](respondWithResult(_0x3805d8,null))[_0x514f('0x2b')](handleError(_0x3805d8,null));};exports[_0x514f('0xf7')]=function(_0x32f91e,_0x364775,_0x40456a){var _0x29fe44;return db[_0x514f('0x59')]['find']({'where':{'id':_0x32f91e['params']['id']},'attributes':['id','name',_0x514f('0x3f'),'voicePause',_0x514f('0xf8'),_0x514f('0xf9'),_0x514f('0xfa'),_0x514f('0xfb'),_0x514f('0xfc'),'whatsapppause','pauseType',_0x514f('0xfd')]})['then'](handleEntityNotFound(_0x364775,null))[_0x514f('0x22')](function(_0x981684){if(_0x981684){_0x29fe44=_0x981684;if(_0x32f91e[_0x514f('0x62')][_0x514f('0xa3')]&&!utils[_0x514f('0xa8')](_0x32f91e[_0x514f('0x62')]['channel'])){throw new db['Sequelize'][(_0x514f('0x97'))](_0x514f('0xa9'));}switch(_0x32f91e[_0x514f('0x62')][_0x514f('0xa3')]){case _0x514f('0xb1'):return respondWithRpcPromise('QueuePause',_0x514f('0xf7'),{'id':_0x29fe44['id'],'name':_0x29fe44[_0x514f('0x41')],'pause':![]})['then'](function(){return db[_0x514f('0xb7')][_0x514f('0x35')]({'paused':0x0},{'where':{'UserId':_0x29fe44['id']},'individualHooks':!![]});})[_0x514f('0x22')](function(){return db[_0x514f('0xe9')][_0x514f('0x40')]({'where':{'channel':_0x32f91e['body'][_0x514f('0xa3')],'membername':_0x29fe44[_0x514f('0x41')],'type':_0x514f('0xee'),'exitAt':null}});})[_0x514f('0x22')](function(_0x54ad5d){if(_0x54ad5d){return _0x54ad5d[_0x514f('0x35')]({'exitAt':moment()[_0x514f('0xb3')](_0x514f('0xeb')),'data2':'manual'},{'individualHooks':!![]});}return null;})[_0x514f('0x22')](function(){return _0x29fe44[_0x514f('0x35')]({'voicePause':![]});});case'mail':case _0x514f('0xfe'):case _0x514f('0xff'):case'sms':case _0x514f('0x100'):case _0x514f('0x101'):return db[_0x514f('0xe9')][_0x514f('0x40')]({'where':{'channel':_0x32f91e[_0x514f('0x62')]['channel'],'membername':_0x29fe44[_0x514f('0x41')],'type':_0x514f('0xee'),'exitAt':null}})[_0x514f('0x22')](function(_0x11a48e){if(_0x11a48e){return _0x11a48e[_0x514f('0x35')]({'exitAt':moment()[_0x514f('0xb3')](_0x514f('0xeb')),'data2':_0x514f('0x102')},{'individualHooks':!![]});}return null;})[_0x514f('0x22')](function(){var _0x306bd2={};_[_0x514f('0x103')](_0x306bd2,util['format'](_0x514f('0x104'),_0x32f91e['body']['channel'],_0x514f('0x105')),![]);return _0x29fe44[_0x514f('0x35')](_0x306bd2);});default:return respondWithRpcPromise('QueuePause','unpause',{'id':_0x29fe44['id'],'name':_0x29fe44[_0x514f('0x41')],'pause':![]})[_0x514f('0x22')](function(){return db[_0x514f('0xb7')][_0x514f('0x35')]({'paused':0x0},{'where':{'UserId':_0x29fe44['id']}});})[_0x514f('0x22')](function(){return db[_0x514f('0xe9')]['findAll']({'where':{'membername':_0x29fe44['name'],'type':'PAUSE','exitAt':null}});})[_0x514f('0x22')](function(_0xc8b5b7){var _0x191c2b=[];_0xc8b5b7[_0x514f('0xea')](function(_0x2fd2f9){_0x191c2b[_0x514f('0x8b')](_0x2fd2f9[_0x514f('0x35')]({'exitAt':moment()[_0x514f('0xb3')](_0x514f('0xeb')),'data2':_0x514f('0x102')}));});return BPromise[_0x514f('0x8c')](_0x191c2b);})[_0x514f('0x22')](function(){return _0x29fe44[_0x514f('0x35')]({'voicePause':![],'mailPause':![],'chatPause':![],'faxPause':![],'smsPause':![],'whatsappPause':![],'openchannelPause':![]});});}}})[_0x514f('0x22')](respondWithResult(_0x364775,null))[_0x514f('0x2b')](handleError(_0x364775,null));};exports[_0x514f('0x106')]=function(_0x5f2e25,_0x2d5b53,_0x3a9984){var _0x348a6b={};var _0x535bc9={};var _0x52b213;var _0x67349f;return db[_0x514f('0x59')][_0x514f('0x9c')]({'where':{'id':_0x5f2e25['params']['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x2d5b53,null))['then'](function(_0x165a1a){if(_0x165a1a){_0x52b213=_0x165a1a;_0x535bc9['model']=_[_0x514f('0x4a')](db[_0x514f('0x107')][_0x514f('0x5e')]);_0x535bc9['query']=_[_0x514f('0x4a')](_0x5f2e25[_0x514f('0x4b')]);_0x535bc9['filters']=_['intersection'](_0x535bc9['model'],_0x535bc9[_0x514f('0x4b')]);_0x348a6b[_0x514f('0x4f')]=_[_0x514f('0x4d')](_0x535bc9['model'],qs['fields'](_0x5f2e25[_0x514f('0x4b')][_0x514f('0x4e')]));_0x348a6b[_0x514f('0x4f')]=_0x348a6b[_0x514f('0x4f')]['length']?_0x348a6b['attributes']:_0x535bc9[_0x514f('0x47')];_0x348a6b['order']=qs[_0x514f('0x52')](_0x5f2e25[_0x514f('0x4b')][_0x514f('0x52')]);_0x348a6b[_0x514f('0x53')]=qs[_0x514f('0x4c')](_[_0x514f('0xc4')](_0x5f2e25[_0x514f('0x4b')],_0x535bc9[_0x514f('0x4c')]));if(_0x5f2e25['query'][_0x514f('0x3b')]){_0x348a6b[_0x514f('0x53')]=_['merge'](_0x348a6b[_0x514f('0x53')],{'$or':_[_0x514f('0x3c')](_0x348a6b[_0x514f('0x4f')],function(_0x5c31b3){var _0xe32bbc={};_0xe32bbc[_0x5c31b3]={'$like':'%'+_0x5f2e25[_0x514f('0x4b')][_0x514f('0x3b')]+'%'};return _0xe32bbc;})});}_0x348a6b=_[_0x514f('0x54')]({},_0x348a6b,_0x5f2e25[_0x514f('0x58')]);return _0x52b213[_0x514f('0x106')](_0x348a6b);}})[_0x514f('0x22')](function(_0xb8f7c7){if(_0xb8f7c7){_0x67349f=_0xb8f7c7[_0x514f('0x60')];if(!_0x5f2e25[_0x514f('0x4b')][_0x514f('0x50')]('nolimit')){_0x348a6b['limit']=qs[_0x514f('0x31')](_0x5f2e25['query']['limit']);_0x348a6b['offset']=qs[_0x514f('0x30')](_0x5f2e25[_0x514f('0x4b')][_0x514f('0x30')]);}return _0x52b213[_0x514f('0x106')](_0x348a6b);}})[_0x514f('0x22')](function(_0x56f48c){if(_0x56f48c){return _0x56f48c?{'count':_0x67349f,'rows':_0x56f48c}:null;}})[_0x514f('0x22')](respondWithResult(_0x2d5b53,null))[_0x514f('0x2b')](handleError(_0x2d5b53,null));};exports[_0x514f('0x108')]=function(_0x39efb2,_0x37020){return db['User'][_0x514f('0x40')]({'where':{'id':_0x39efb2[_0x514f('0x5d')]['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x37020,null))['then'](function(_0x18473d){if(_0x18473d){var _0x2ce879=_0x18473d[_0x514f('0x37')]({'plain':!![]});return _0x18473d[_0x514f('0x108')](_0x39efb2[_0x514f('0x62')][_0x514f('0x65')],_[_0x514f('0x109')](_0x39efb2[_0x514f('0x62')],[_0x514f('0x65'),'id'])||{})[_0x514f('0x22')](function(){for(var _0xafd160=0x0;_0xafd160<_0x39efb2[_0x514f('0x62')][_0x514f('0x65')][_0x514f('0x60')];_0xafd160++){var _0x51cd54=[];db[_0x514f('0x107')][_0x514f('0x9c')]({'where':{'id':_0x39efb2['body'][_0x514f('0x65')][_0xafd160]}})[_0x514f('0x22')](function(_0x5c7aa4){_0x51cd54['push'](_0x5c7aa4[_0x514f('0xe8')]()[_0x514f('0x22')](function(_0x4a424f){for(var _0x5caac7=0x0;_0x5caac7<_0x4a424f[_0x514f('0x60')];_0x5caac7++){_0x4a424f[_0x5caac7]['setDataValue'](_0x514f('0xa3'),_0x514f('0x10a'));}return _0x4a424f;}));_0x51cd54[_0x514f('0x8b')](_0x5c7aa4['getChatQueues']()[_0x514f('0x22')](function(_0x32f11a){for(var _0x57dfd4=0x0;_0x57dfd4<_0x32f11a[_0x514f('0x60')];_0x57dfd4++){_0x32f11a[_0x57dfd4][_0x514f('0x10b')](_0x514f('0xa3'),_0x514f('0x10c'));}return _0x32f11a;}));_0x51cd54[_0x514f('0x8b')](_0x5c7aa4['getMailQueues']()[_0x514f('0x22')](function(_0x1df832){for(var _0x859d8a=0x0;_0x859d8a<_0x1df832[_0x514f('0x60')];_0x859d8a++){_0x1df832[_0x859d8a][_0x514f('0x10b')](_0x514f('0xa3'),_0x514f('0x10d'));}return _0x1df832;}));_0x51cd54[_0x514f('0x8b')](_0x5c7aa4['getSmsQueues']()[_0x514f('0x22')](function(_0x3e3e94){for(var _0x45ce90=0x0;_0x45ce90<_0x3e3e94[_0x514f('0x60')];_0x45ce90++){_0x3e3e94[_0x45ce90][_0x514f('0x10b')](_0x514f('0xa3'),_0x514f('0x10e'));}return _0x3e3e94;}));_0x51cd54[_0x514f('0x8b')](_0x5c7aa4[_0x514f('0x10f')]()[_0x514f('0x22')](function(_0x3d4d6b){for(var _0x4fb59e=0x0;_0x4fb59e<_0x3d4d6b[_0x514f('0x60')];_0x4fb59e++){_0x3d4d6b[_0x4fb59e][_0x514f('0x10b')](_0x514f('0xa3'),_0x514f('0x110'));}return _0x3d4d6b;}));_0x51cd54['push'](_0x5c7aa4[_0x514f('0x111')]()['then'](function(_0x41ddd5){for(var _0x221d66=0x0;_0x221d66<_0x41ddd5[_0x514f('0x60')];_0x221d66++){_0x41ddd5[_0x221d66][_0x514f('0x10b')]('channel',_0x514f('0x112'));}return _0x41ddd5;}));_0x51cd54['push'](_0x5c7aa4[_0x514f('0x113')]()[_0x514f('0x22')](function(_0x19f624){for(var _0x22f048=0x0;_0x22f048<_0x19f624[_0x514f('0x60')];_0x22f048++){_0x19f624[_0x22f048]['setDataValue'](_0x514f('0xa3'),_0x514f('0x114'));}return _0x19f624;}));return BPromise['all'](_0x51cd54);})[_0x514f('0x22')](function(_0x1142fc){var _0xf4fa13=_[_0x514f('0x115')](_0x1142fc);_0x51cd54=[];return db[_0x514f('0x56')][_0x514f('0x116')](function(_0x5d2d6b){for(var _0x5e483e=0x0;_0x5e483e<_0xf4fa13[_0x514f('0x60')];_0x5e483e++){_0x51cd54[_0x514f('0x8b')](_0xf4fa13[_0x5e483e][_0x514f('0x117')](_0x2ce879['id']),{'transaction':_0x5d2d6b});}return BPromise[_0x514f('0x8c')](_0x51cd54)[_0x514f('0x22')](function(){if(_0x2ce879[_0x514f('0xa4')]){return BPromise['each'](_[_0x514f('0x3b')](_0xf4fa13,function(_0x533ce2){return _0x533ce2[_0x514f('0x118')](_0x514f('0xa3'))===_0x514f('0x10a');}),function(_0x5aa570){return db[_0x514f('0xb7')][_0x514f('0x119')]({'membername':_0x2ce879[_0x514f('0x41')],'UserId':_0x2ce879['id'],'queue_name':_0x5aa570[_0x514f('0x41')],'VoiceQueueId':_0x5aa570['id'],'interface':_[_0x514f('0x69')](_0x2ce879['interface'])?util[_0x514f('0xb3')](_0x514f('0xb4'),_0x2ce879[_0x514f('0x41')]):_0x2ce879[_0x514f('0xa7')],'paused':_0x2ce879[_0x514f('0xa6')]||![],'penalty':_0x2ce879[_0x514f('0xad')]},{'transaction':_0x5d2d6b});});}else{return;}})['then'](function(){for(var _0x35eee2=0x0;_0x35eee2<_0xf4fa13[_0x514f('0x60')];_0x35eee2++){var _0x2073b0=_0xf4fa13[_0x35eee2][_0x514f('0x118')](_0x514f('0xa3'));var _0x5498ab=_0x2073b0+_0x514f('0xaf');socket[_0x514f('0xb0')](_0x514f('0x7f')+_0x2073b0+'Queue:save',{'UserId':_0x2ce879['id'],['queueField']:_0xf4fa13[_0x35eee2]['id']});}});});});}});}})[_0x514f('0x22')](respondWithStatusCode(_0x37020,null))[_0x514f('0x2b')](handleError(_0x37020,null));};exports[_0x514f('0x11a')]=function(_0x34968f,_0x54a98a){return db[_0x514f('0x59')][_0x514f('0x9c')]({'where':{'id':_0x34968f['params']['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x54a98a,null))[_0x514f('0x22')](function(_0x15f72b){if(_0x15f72b){var _0x5bbb56=_0x15f72b[_0x514f('0x37')]({'plain':!![]});var _0x1e151d=_0x34968f[_0x514f('0x4b')][_0x514f('0x65')];return _0x15f72b['removeTeams'](_0x1e151d)[_0x514f('0x22')](function(){for(var _0x267003=0x0;_0x267003<_0x1e151d[_0x514f('0x60')];_0x267003++){var _0x521630=[];db[_0x514f('0x107')][_0x514f('0x9c')]({'where':{'id':_0x1e151d[_0x267003]}})[_0x514f('0x22')](function(_0x19bcc9){_0x521630[_0x514f('0x8b')](_0x19bcc9[_0x514f('0xe8')]()[_0x514f('0x22')](function(_0x6103b1){for(var _0x4c4611=0x0;_0x4c4611<_0x6103b1[_0x514f('0x60')];_0x4c4611++){_0x6103b1[_0x4c4611][_0x514f('0x10b')](_0x514f('0xa3'),_0x514f('0x10a'));}return _0x6103b1;}));_0x521630[_0x514f('0x8b')](_0x19bcc9[_0x514f('0x11b')]()['then'](function(_0x4b879b){for(var _0x3d6252=0x0;_0x3d6252<_0x4b879b[_0x514f('0x60')];_0x3d6252++){_0x4b879b[_0x3d6252][_0x514f('0x10b')](_0x514f('0xa3'),'Chat');}return _0x4b879b;}));_0x521630['push'](_0x19bcc9['getMailQueues']()[_0x514f('0x22')](function(_0x580581){for(var _0x2df7f4=0x0;_0x2df7f4<_0x580581[_0x514f('0x60')];_0x2df7f4++){_0x580581[_0x2df7f4][_0x514f('0x10b')](_0x514f('0xa3'),_0x514f('0x10d'));}return _0x580581;}));_0x521630[_0x514f('0x8b')](_0x19bcc9[_0x514f('0x11c')]()[_0x514f('0x22')](function(_0x5371a5){for(var _0xae3228=0x0;_0xae3228<_0x5371a5[_0x514f('0x60')];_0xae3228++){_0x5371a5[_0xae3228]['setDataValue'](_0x514f('0xa3'),_0x514f('0x10e'));}return _0x5371a5;}));_0x521630[_0x514f('0x8b')](_0x19bcc9['getWhatsappQueues']()[_0x514f('0x22')](function(_0x3adf75){for(var _0x187a10=0x0;_0x187a10<_0x3adf75['length'];_0x187a10++){_0x3adf75[_0x187a10][_0x514f('0x10b')](_0x514f('0xa3'),_0x514f('0x110'));}return _0x3adf75;}));_0x521630[_0x514f('0x8b')](_0x19bcc9[_0x514f('0x111')]()[_0x514f('0x22')](function(_0x3eef87){for(var _0x24c758=0x0;_0x24c758<_0x3eef87[_0x514f('0x60')];_0x24c758++){_0x3eef87[_0x24c758][_0x514f('0x10b')]('channel',_0x514f('0x112'));}return _0x3eef87;}));_0x521630[_0x514f('0x8b')](_0x19bcc9[_0x514f('0x113')]()[_0x514f('0x22')](function(_0x2b902c){for(var _0x527c9f=0x0;_0x527c9f<_0x2b902c[_0x514f('0x60')];_0x527c9f++){_0x2b902c[_0x527c9f][_0x514f('0x10b')](_0x514f('0xa3'),_0x514f('0x114'));}return _0x2b902c;}));return BPromise[_0x514f('0x8c')](_0x521630);})[_0x514f('0x22')](function(_0x3ef8d5){var _0x572c56=_[_0x514f('0x115')](_0x3ef8d5);_0x521630=[];return db[_0x514f('0x56')]['transaction'](function(_0x3c6b98){for(var _0x43a719=0x0;_0x43a719<_0x572c56[_0x514f('0x60')];_0x43a719++){_0x521630[_0x514f('0x8b')](_0x572c56[_0x43a719]['removeAgent'](_0x5bbb56['id']),{'transaction':_0x3c6b98});}return BPromise[_0x514f('0x8c')](_0x521630)['then'](function(){if(_0x5bbb56[_0x514f('0xa4')]){return BPromise['each'](_[_0x514f('0x3b')](_0x572c56,function(_0x25c186){return _0x25c186['getDataValue']('channel')===_0x514f('0x10a');}),function(_0x201504){return db[_0x514f('0xb7')][_0x514f('0x36')]({'where':{'VoiceQueueId':_0x201504['id'],'UserId':_0x5bbb56['id']},'transaction':_0x3c6b98});});}else{return;}})[_0x514f('0x22')](function(){for(var _0x2c2162=0x0;_0x2c2162<_0x572c56[_0x514f('0x60')];_0x2c2162++){var _0x4a21c8=_0x572c56[_0x2c2162][_0x514f('0x118')]('channel');var _0x14a6a1=_0x4a21c8+'QueueId';socket[_0x514f('0xb0')](_0x514f('0x7f')+_0x4a21c8+_0x514f('0xb6'),{'UserId':_0x5bbb56['id'],['queueField']:_0x572c56[_0x2c2162]['id']});}});});});}});}})[_0x514f('0x22')](respondWithStatusCode(_0x54a98a,null))[_0x514f('0x2b')](handleError(_0x54a98a,null));};exports[_0x514f('0x11d')]=function(_0x51014f,_0x1753f0,_0x373ee9){var _0x2c7720={};var _0x24765f={};var _0x226ee7;var _0x532ce4;return db[_0x514f('0x59')]['findOne']({'where':{'id':_0x51014f[_0x514f('0x5d')]['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x1753f0,null))[_0x514f('0x22')](function(_0x186173){if(_0x186173){_0x226ee7=_0x186173;_0x24765f[_0x514f('0x47')]=_[_0x514f('0x4a')](db[_0x514f('0xc5')][_0x514f('0x5e')]);_0x24765f[_0x514f('0x4b')]=_['keys'](_0x51014f['query']);_0x24765f[_0x514f('0x4c')]=_[_0x514f('0x4d')](_0x24765f[_0x514f('0x47')],_0x24765f[_0x514f('0x4b')]);_0x2c7720[_0x514f('0x4f')]=_[_0x514f('0x4d')](_0x24765f[_0x514f('0x47')],qs[_0x514f('0x4e')](_0x51014f['query']['fields']));_0x2c7720['attributes']=_0x2c7720[_0x514f('0x4f')][_0x514f('0x60')]?_0x2c7720[_0x514f('0x4f')]:_0x24765f[_0x514f('0x47')];_0x2c7720['order']=qs['sort'](_0x51014f['query']['sort']);_0x2c7720['where']=qs[_0x514f('0x4c')](_[_0x514f('0xc4')](_0x51014f['query'],_0x24765f[_0x514f('0x4c')]));if(_0x51014f['query']['filter']){_0x2c7720[_0x514f('0x53')]=_[_0x514f('0x54')](_0x2c7720['where'],{'$or':_[_0x514f('0x3c')](_0x2c7720['attributes'],function(_0x616b66){var _0x1c4fdb={};_0x1c4fdb[_0x616b66]={'$like':'%'+_0x51014f[_0x514f('0x4b')][_0x514f('0x3b')]+'%'};return _0x1c4fdb;})});}_0x2c7720=_[_0x514f('0x54')]({},_0x2c7720,_0x51014f[_0x514f('0x58')]);return _0x226ee7[_0x514f('0x11d')](_0x2c7720);}})[_0x514f('0x22')](function(_0x26b5a1){if(_0x26b5a1){_0x532ce4=_0x26b5a1[_0x514f('0x60')];if(!_0x51014f['query'][_0x514f('0x50')](_0x514f('0xcc'))){_0x2c7720[_0x514f('0x31')]=qs[_0x514f('0x31')](_0x51014f[_0x514f('0x4b')][_0x514f('0x31')]);_0x2c7720[_0x514f('0x30')]=qs['offset'](_0x51014f[_0x514f('0x4b')][_0x514f('0x30')]);}return _0x226ee7[_0x514f('0x11d')](_0x2c7720);}})['then'](function(_0x160038){if(_0x160038){return _0x160038?{'count':_0x532ce4,'rows':_0x160038}:null;}})['then'](respondWithResult(_0x1753f0,null))[_0x514f('0x2b')](handleError(_0x1753f0,null));};exports['getAgents']=function(_0x10f48e,_0x542a8c,_0xe555a5){var _0x395bb1={};var _0x58ed99={};var _0x24d704;var _0x103e67;return db[_0x514f('0x59')][_0x514f('0x9c')]({'where':{'id':_0x10f48e[_0x514f('0x5d')]['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x542a8c,null))['then'](function(_0x4b570a){if(_0x4b570a){_0x24d704=_0x4b570a;_0x58ed99['model']=_[_0x514f('0x4a')](db[_0x514f('0x59')][_0x514f('0x5e')]);_0x58ed99['query']=_[_0x514f('0x4a')](_0x10f48e['query']);_0x58ed99[_0x514f('0x4c')]=_[_0x514f('0x4d')](_0x58ed99[_0x514f('0x47')],_0x58ed99[_0x514f('0x4b')]);_0x395bb1[_0x514f('0x4f')]=_[_0x514f('0x4d')](_0x58ed99[_0x514f('0x47')],qs[_0x514f('0x4e')](_0x10f48e[_0x514f('0x4b')][_0x514f('0x4e')]));_0x395bb1[_0x514f('0x4f')]=_0x395bb1['attributes'][_0x514f('0x60')]?_0x395bb1[_0x514f('0x4f')]:_0x58ed99[_0x514f('0x47')];_0x395bb1['order']=qs[_0x514f('0x52')](_0x10f48e[_0x514f('0x4b')]['sort']);_0x395bb1[_0x514f('0x53')]=qs['filters'](_[_0x514f('0xc4')](_0x10f48e[_0x514f('0x4b')],_0x58ed99[_0x514f('0x4c')]));if(_0x10f48e[_0x514f('0x4b')][_0x514f('0x3b')]){_0x395bb1['where']=_[_0x514f('0x54')](_0x395bb1[_0x514f('0x53')],{'$or':_[_0x514f('0x3c')](_0x395bb1[_0x514f('0x4f')],function(_0xf3f8fb){var _0x29679f={};_0x29679f[_0xf3f8fb]={'$like':'%'+_0x10f48e[_0x514f('0x4b')]['filter']+'%'};return _0x29679f;})});}_0x395bb1[_0x514f('0x47')]=db['User'];_0x395bb1['as']=_0x514f('0x39');_0x395bb1=_['merge']({},_0x395bb1,_0x10f48e[_0x514f('0x58')]);return _0x24d704[_0x514f('0xe8')]({'include':[_0x395bb1]});}})[_0x514f('0x22')](function(_0x52f8b2){if(_0x52f8b2){var _0x1960e4={},_0x5838d1=[],_0x52bb4b=0x0;for(var _0x97664a=0x0;_0x97664a<_0x52f8b2[_0x514f('0x60')];_0x97664a+=0x1){for(var _0x55f19b=0x0,_0x58cb94;_0x55f19b<_0x52f8b2[_0x97664a][_0x514f('0x39')][_0x514f('0x60')];_0x55f19b+=0x1){_0x58cb94=_0x52f8b2[_0x97664a][_0x514f('0x39')][_0x55f19b][_0x514f('0x37')]({'plain':!![]});_0x1960e4[_0x58cb94['id']]=_0x58cb94;}}_0x1960e4=_[_0x514f('0x11e')](_0x1960e4);for(var _0x3f301c=qs[_0x514f('0x30')](_0x10f48e['query'][_0x514f('0x30')]);_0x3f301c<_0x1960e4[_0x514f('0x60')]&&_0x5838d1[_0x514f('0x60')]<qs[_0x514f('0x31')](_0x10f48e[_0x514f('0x4b')][_0x514f('0x31')]);_0x3f301c+=0x1){if(_0x1960e4[_0x3f301c]){_0x5838d1[_0x514f('0x8b')](_0x1960e4[_0x3f301c]);}}return{'count':_0x1960e4['length'],'rows':_0x5838d1};}})[_0x514f('0x22')](respondWithResult(_0x542a8c,null))[_0x514f('0x2b')](handleError(_0x542a8c,null));};exports['destroy']=function(_0x130921,_0x96ca50){if(_0x130921['user']['id']==_0x130921[_0x514f('0x5d')]['id']){return _0x96ca50['status'](0x1f4)[_0x514f('0x44')]({'message':_0x514f('0x11f')});}return db['User'][_0x514f('0x40')]({'where':{'id':_0x130921['params']['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x96ca50,null))['then'](removeEntity(_0x96ca50,null))[_0x514f('0x2b')](handleError(_0x96ca50,null));};exports[_0x514f('0x120')]=function(_0x4e58d4,_0x1f3e4c,_0x2f0038){return db[_0x514f('0x59')]['find']({'where':{'id':_0x4e58d4[_0x514f('0x5d')]['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x1f3e4c,null))['then'](function(_0x442cec){if(_0x442cec){return _0x442cec['addChatInteractions'](_0x4e58d4[_0x514f('0x62')][_0x514f('0x65')],_[_0x514f('0x109')](_0x4e58d4[_0x514f('0x62')],['ids','id'])||{})[_0x514f('0x121')](function(){for(var _0x38d60d=0x0;_0x38d60d<_0x4e58d4[_0x514f('0x62')][_0x514f('0x65')][_0x514f('0x60')];_0x38d60d+=0x1){socket[_0x514f('0xb0')](_0x514f('0x122'),{'ChatInteractionId':Number(_0x4e58d4['body'][_0x514f('0x65')][_0x38d60d]),'UserId':Number(_0x4e58d4[_0x514f('0x5d')]['id'])});}return _0x4e58d4[_0x514f('0x62')][_0x514f('0x65')];});}})[_0x514f('0x22')](respondWithResult(_0x1f3e4c,null))[_0x514f('0x2b')](handleError(_0x1f3e4c,null));};exports[_0x514f('0x123')]=function(_0x56d0e8,_0x19f213,_0x4e3ec8){return db[_0x514f('0x59')]['find']({'where':{'id':_0x56d0e8[_0x514f('0x5d')]['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x19f213,null))['then'](function(_0x47fe5b){if(_0x47fe5b){return _0x47fe5b[_0x514f('0x123')](_0x56d0e8['query'][_0x514f('0x65')])['then'](function(){if(_[_0x514f('0x124')](_0x56d0e8[_0x514f('0x4b')][_0x514f('0x65')])){for(var _0x230947=0x0;_0x230947<_0x56d0e8['query'][_0x514f('0x65')]['length'];_0x230947+=0x1){socket[_0x514f('0xb0')](_0x514f('0x125'),{'ChatInteractionId':Number(_0x56d0e8['query'][_0x514f('0x65')][_0x230947]),'UserId':Number(_0x56d0e8[_0x514f('0x5d')]['id'])});}}else{socket[_0x514f('0xb0')](_0x514f('0x125'),{'ChatInteractionId':Number(_0x56d0e8['query']['ids']),'UserId':Number(_0x56d0e8['params']['id'])});}});}})[_0x514f('0x22')](respondWithStatusCode(_0x19f213,null))[_0x514f('0x2b')](handleError(_0x19f213,null));};exports[_0x514f('0x126')]=function(_0x11c6ad,_0x2cab66,_0x35da3d){return db['User'][_0x514f('0x40')]({'where':{'id':_0x11c6ad[_0x514f('0x5d')]['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x2cab66,null))[_0x514f('0x22')](function(_0x3e0ce8){if(_0x3e0ce8){return _0x3e0ce8[_0x514f('0x126')](_0x11c6ad['body'][_0x514f('0x65')],_[_0x514f('0x109')](_0x11c6ad[_0x514f('0x62')],['ids','id'])||{})[_0x514f('0x121')](function(){for(var _0x5765df=0x0;_0x5765df<_0x11c6ad[_0x514f('0x62')]['ids']['length'];_0x5765df+=0x1){socket[_0x514f('0xb0')](_0x514f('0x127'),{'MailInteractionId':Number(_0x11c6ad[_0x514f('0x62')][_0x514f('0x65')][_0x5765df]),'UserId':Number(_0x11c6ad[_0x514f('0x5d')]['id'])});}return _0x11c6ad[_0x514f('0x62')]['ids'];});}})['then'](respondWithResult(_0x2cab66,null))[_0x514f('0x2b')](handleError(_0x2cab66,null));};exports[_0x514f('0x128')]=function(_0x4ddce3,_0x5a1293,_0x142675){return db[_0x514f('0x59')]['find']({'where':{'id':_0x4ddce3[_0x514f('0x5d')]['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x5a1293,null))[_0x514f('0x22')](function(_0x2543a9){if(_0x2543a9){return _0x2543a9['removeMailInteractions'](_0x4ddce3[_0x514f('0x4b')][_0x514f('0x65')])[_0x514f('0x22')](function(){if(_[_0x514f('0x124')](_0x4ddce3['query'][_0x514f('0x65')])){for(var _0x294851=0x0;_0x294851<_0x4ddce3[_0x514f('0x4b')][_0x514f('0x65')][_0x514f('0x60')];_0x294851+=0x1){socket[_0x514f('0xb0')](_0x514f('0x129'),{'MailInteractionId':Number(_0x4ddce3[_0x514f('0x4b')][_0x514f('0x65')][_0x294851]),'UserId':Number(_0x4ddce3[_0x514f('0x5d')]['id'])});}}else{socket[_0x514f('0xb0')](_0x514f('0x129'),{'MailInteractionId':Number(_0x4ddce3[_0x514f('0x4b')][_0x514f('0x65')]),'UserId':Number(_0x4ddce3[_0x514f('0x5d')]['id'])});}});}})['then'](respondWithStatusCode(_0x5a1293,null))['catch'](handleError(_0x5a1293,null));};exports[_0x514f('0x12a')]=function(_0x1fe68a,_0x59a1d5,_0x513f19){return db[_0x514f('0x59')]['find']({'where':{'id':_0x1fe68a[_0x514f('0x5d')]['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x59a1d5,null))[_0x514f('0x22')](function(_0x36ccb3){if(_0x36ccb3){return _0x36ccb3[_0x514f('0x12a')](_0x1fe68a[_0x514f('0x62')][_0x514f('0x65')],_['omit'](_0x1fe68a[_0x514f('0x62')],[_0x514f('0x65'),'id'])||{})[_0x514f('0x121')](function(){for(var _0x42a266=0x0;_0x42a266<_0x1fe68a[_0x514f('0x62')]['ids'][_0x514f('0x60')];_0x42a266+=0x1){socket['emit'](_0x514f('0x12b'),{'FaxInteractionId':Number(_0x1fe68a[_0x514f('0x62')][_0x514f('0x65')][_0x42a266]),'UserId':Number(_0x1fe68a[_0x514f('0x5d')]['id'])});}return _0x1fe68a['body'][_0x514f('0x65')];});}})['then'](respondWithResult(_0x59a1d5,null))['catch'](handleError(_0x59a1d5,null));};exports[_0x514f('0x12c')]=function(_0x3fb25c,_0x1ef692,_0x1fa6b1){return db['User']['find']({'where':{'id':_0x3fb25c['params']['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x1ef692,null))['then'](function(_0x168fb4){if(_0x168fb4){return _0x168fb4[_0x514f('0x12c')](_0x3fb25c['query'][_0x514f('0x65')])[_0x514f('0x22')](function(){if(_['isArray'](_0x3fb25c[_0x514f('0x4b')]['ids'])){for(var _0x64ee86=0x0;_0x64ee86<_0x3fb25c['query'][_0x514f('0x65')][_0x514f('0x60')];_0x64ee86+=0x1){socket[_0x514f('0xb0')](_0x514f('0x12d'),{'FaxInteractionId':Number(_0x3fb25c[_0x514f('0x4b')][_0x514f('0x65')][_0x64ee86]),'UserId':Number(_0x3fb25c[_0x514f('0x5d')]['id'])});}}else{socket['emit']('user_has_fax_interactions:remove',{'FaxInteractionId':Number(_0x3fb25c[_0x514f('0x4b')][_0x514f('0x65')]),'UserId':Number(_0x3fb25c['params']['id'])});}});}})['then'](respondWithStatusCode(_0x1ef692,null))[_0x514f('0x2b')](handleError(_0x1ef692,null));};exports[_0x514f('0x12e')]=function(_0x5231ec,_0x54f2f7,_0x5eb6a5){return db[_0x514f('0x59')][_0x514f('0x40')]({'where':{'id':_0x5231ec[_0x514f('0x5d')]['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x54f2f7,null))[_0x514f('0x22')](function(_0x457fe0){if(_0x457fe0){return _0x457fe0[_0x514f('0x12e')](_0x5231ec[_0x514f('0x62')][_0x514f('0x65')],_[_0x514f('0x109')](_0x5231ec[_0x514f('0x62')],[_0x514f('0x65'),'id'])||{})[_0x514f('0x121')](function(){for(var _0x51abb3=0x0;_0x51abb3<_0x5231ec[_0x514f('0x62')]['ids'][_0x514f('0x60')];_0x51abb3+=0x1){socket[_0x514f('0xb0')](_0x514f('0x12f'),{'SmsInteractionId':Number(_0x5231ec[_0x514f('0x62')][_0x514f('0x65')][_0x51abb3]),'UserId':Number(_0x5231ec[_0x514f('0x5d')]['id'])});}return _0x5231ec['body'][_0x514f('0x65')];});}})['then'](respondWithResult(_0x54f2f7,null))[_0x514f('0x2b')](handleError(_0x54f2f7,null));};exports[_0x514f('0x130')]=function(_0x3b05c5,_0x8699b4,_0x149072){return db['User'][_0x514f('0x40')]({'where':{'id':_0x3b05c5[_0x514f('0x5d')]['id']}})['then'](handleEntityNotFound(_0x8699b4,null))['then'](function(_0x1f2174){if(_0x1f2174){return _0x1f2174[_0x514f('0x130')](_0x3b05c5[_0x514f('0x4b')][_0x514f('0x65')])[_0x514f('0x22')](function(){if(_[_0x514f('0x124')](_0x3b05c5['query'][_0x514f('0x65')])){for(var _0x4e8dac=0x0;_0x4e8dac<_0x3b05c5['query'][_0x514f('0x65')][_0x514f('0x60')];_0x4e8dac+=0x1){socket[_0x514f('0xb0')]('user_has_sms_interactions:remove',{'SmsInteractionId':Number(_0x3b05c5[_0x514f('0x4b')][_0x514f('0x65')][_0x4e8dac]),'UserId':Number(_0x3b05c5['params']['id'])});}}else{socket[_0x514f('0xb0')]('user_has_sms_interactions:remove',{'SmsInteractionId':Number(_0x3b05c5['query'][_0x514f('0x65')]),'UserId':Number(_0x3b05c5[_0x514f('0x5d')]['id'])});}});}})[_0x514f('0x22')](respondWithStatusCode(_0x8699b4,null))['catch'](handleError(_0x8699b4,null));};exports[_0x514f('0x131')]=function(_0x101422,_0x5eeedb,_0x5eb2ac){return db['User'][_0x514f('0x40')]({'where':{'id':_0x101422[_0x514f('0x5d')]['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x5eeedb,null))[_0x514f('0x22')](function(_0x60405a){if(_0x60405a){return _0x60405a[_0x514f('0x131')](_0x101422['body'][_0x514f('0x65')],_[_0x514f('0x109')](_0x101422['body'],['ids','id'])||{})[_0x514f('0x121')](function(){for(var _0x4ed64a=0x0;_0x4ed64a<_0x101422[_0x514f('0x62')]['ids'][_0x514f('0x60')];_0x4ed64a+=0x1){socket[_0x514f('0xb0')](_0x514f('0x132'),{'OpenchannelInteractionId':Number(_0x101422[_0x514f('0x62')]['ids'][_0x4ed64a]),'UserId':Number(_0x101422[_0x514f('0x5d')]['id'])});}return _0x101422[_0x514f('0x62')][_0x514f('0x65')];});}})[_0x514f('0x22')](respondWithResult(_0x5eeedb,null))['catch'](handleError(_0x5eeedb,null));};exports[_0x514f('0x133')]=function(_0x267b31,_0x5654d4,_0x22be0a){return db[_0x514f('0x59')][_0x514f('0x40')]({'where':{'id':_0x267b31[_0x514f('0x5d')]['id']}})['then'](handleEntityNotFound(_0x5654d4,null))[_0x514f('0x22')](function(_0x126065){if(_0x126065){return _0x126065['removeOpenchannelInteractions'](_0x267b31[_0x514f('0x4b')][_0x514f('0x65')])['then'](function(){if(_[_0x514f('0x124')](_0x267b31[_0x514f('0x4b')][_0x514f('0x65')])){for(var _0x484cb5=0x0;_0x484cb5<_0x267b31[_0x514f('0x4b')][_0x514f('0x65')]['length'];_0x484cb5+=0x1){socket['emit'](_0x514f('0x134'),{'OpenchannelInteractionId':Number(_0x267b31[_0x514f('0x4b')]['ids'][_0x484cb5]),'UserId':Number(_0x267b31[_0x514f('0x5d')]['id'])});}}else{socket[_0x514f('0xb0')](_0x514f('0x134'),{'OpenchannelInteractionId':Number(_0x267b31[_0x514f('0x4b')]['ids']),'UserId':Number(_0x267b31['params']['id'])});}});}})['then'](respondWithStatusCode(_0x5654d4,null))[_0x514f('0x2b')](handleError(_0x5654d4,null));};exports[_0x514f('0x135')]=function(_0x323c2b,_0x1b9362,_0x541442){return db[_0x514f('0x59')][_0x514f('0x40')]({'where':{'id':_0x323c2b[_0x514f('0x5d')]['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x1b9362,null))[_0x514f('0x22')](function(_0x198dd6){if(_0x198dd6){return _0x198dd6[_0x514f('0x135')](_0x323c2b[_0x514f('0x62')][_0x514f('0x65')],_[_0x514f('0x109')](_0x323c2b[_0x514f('0x62')],[_0x514f('0x65'),'id'])||{})['spread'](function(){for(var _0x50f864=0x0;_0x50f864<_0x323c2b['body'][_0x514f('0x65')][_0x514f('0x60')];_0x50f864+=0x1){socket[_0x514f('0xb0')](_0x514f('0x136'),{'WhatsappInteractionId':Number(_0x323c2b[_0x514f('0x62')][_0x514f('0x65')][_0x50f864]),'UserId':Number(_0x323c2b[_0x514f('0x5d')]['id'])});}return _0x323c2b[_0x514f('0x62')][_0x514f('0x65')];});}})[_0x514f('0x22')](respondWithResult(_0x1b9362,null))[_0x514f('0x2b')](handleError(_0x1b9362,null));};exports['removeWhatsappInteractions']=function(_0xcc0800,_0x401663,_0x1b8701){return db[_0x514f('0x59')][_0x514f('0x40')]({'where':{'id':_0xcc0800[_0x514f('0x5d')]['id']}})['then'](handleEntityNotFound(_0x401663,null))[_0x514f('0x22')](function(_0x46de40){if(_0x46de40){return _0x46de40[_0x514f('0x137')](_0xcc0800[_0x514f('0x4b')][_0x514f('0x65')]);}})[_0x514f('0x22')](respondWithStatusCode(_0x401663,null))[_0x514f('0x2b')](handleError(_0x401663,null));};exports[_0x514f('0x138')]=function(_0x59c347,_0x1a3aa3,_0x347a50){var _0x5b21a1={};var _0x4269cc={};var _0x4d820a;var _0x440aed;return db[_0x514f('0x59')][_0x514f('0x9c')]({'where':{'id':_0x59c347[_0x514f('0x5d')]['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x1a3aa3,null))['then'](function(_0x5039ef){if(_0x5039ef){_0x4d820a=_0x5039ef;_0x4269cc[_0x514f('0x47')]=_[_0x514f('0x4a')](db[_0x514f('0x139')]['rawAttributes']);_0x4269cc['query']=_[_0x514f('0x4a')](_0x59c347['query']);_0x4269cc[_0x514f('0x4c')]=_['intersection'](_0x4269cc['model'],_0x4269cc['query']);_0x5b21a1[_0x514f('0x4f')]=_[_0x514f('0x4d')](_0x4269cc[_0x514f('0x47')],qs[_0x514f('0x4e')](_0x59c347[_0x514f('0x4b')]['fields']));_0x5b21a1[_0x514f('0x4f')]=_0x5b21a1[_0x514f('0x4f')][_0x514f('0x60')]?_0x5b21a1['attributes']:_0x4269cc[_0x514f('0x47')];_0x5b21a1[_0x514f('0x51')]=qs[_0x514f('0x52')](_0x59c347[_0x514f('0x4b')]['sort']);_0x5b21a1[_0x514f('0x53')]=qs[_0x514f('0x4c')](_['pick'](_0x59c347['query'],_0x4269cc[_0x514f('0x4c')]));if(_0x59c347[_0x514f('0x4b')][_0x514f('0x3b')]){_0x5b21a1[_0x514f('0x53')]=_[_0x514f('0x54')](_0x5b21a1[_0x514f('0x53')],{'$or':_[_0x514f('0x3c')](_0x5b21a1[_0x514f('0x4f')],function(_0x16a082){var _0x2aa676={};_0x2aa676[_0x16a082]={'$like':'%'+_0x59c347[_0x514f('0x4b')][_0x514f('0x3b')]+'%'};return _0x2aa676;})});}_0x5b21a1=_[_0x514f('0x54')]({},_0x5b21a1,_0x59c347[_0x514f('0x58')]);return _0x4d820a[_0x514f('0x138')](_0x5b21a1);}})[_0x514f('0x22')](function(_0xe3ec1a){if(_0xe3ec1a){_0x440aed=_0xe3ec1a[_0x514f('0x60')];if(!_0x59c347['query'][_0x514f('0x50')](_0x514f('0xcc'))){_0x5b21a1[_0x514f('0x31')]=qs['limit'](_0x59c347[_0x514f('0x4b')][_0x514f('0x31')]);_0x5b21a1[_0x514f('0x30')]=qs[_0x514f('0x30')](_0x59c347[_0x514f('0x4b')][_0x514f('0x30')]);}return _0x4d820a['getVoicePrefixes'](_0x5b21a1);}})[_0x514f('0x22')](function(_0xdd6e4){if(_0xdd6e4){return _0xdd6e4?{'count':_0x440aed,'rows':_0xdd6e4}:null;}})['then'](respondWithResult(_0x1a3aa3,null))[_0x514f('0x2b')](handleError(_0x1a3aa3,null));};exports[_0x514f('0x13a')]=function(_0x734ae4,_0x2f5e13,_0xdf3865){var _0x2a2665={};var _0x1cd4ef={};var _0x22415d;var _0x40bb55;return db[_0x514f('0x59')][_0x514f('0x9c')]({'where':{'id':_0x734ae4['params']['id']}})['then'](handleEntityNotFound(_0x2f5e13,null))[_0x514f('0x22')](function(_0x327bec){if(_0x327bec){_0x22415d=_0x327bec;_0x1cd4ef[_0x514f('0x47')]=_[_0x514f('0x4a')](db['FaxAccount']['rawAttributes']);_0x1cd4ef[_0x514f('0x4b')]=_[_0x514f('0x4a')](_0x734ae4[_0x514f('0x4b')]);_0x1cd4ef['filters']=_[_0x514f('0x4d')](_0x1cd4ef[_0x514f('0x47')],_0x1cd4ef[_0x514f('0x4b')]);_0x2a2665['attributes']=_[_0x514f('0x4d')](_0x1cd4ef[_0x514f('0x47')],qs['fields'](_0x734ae4['query'][_0x514f('0x4e')]));_0x2a2665[_0x514f('0x4f')]=_0x2a2665['attributes'][_0x514f('0x60')]?_0x2a2665[_0x514f('0x4f')]:_0x1cd4ef[_0x514f('0x47')];_0x2a2665[_0x514f('0x51')]=qs[_0x514f('0x52')](_0x734ae4['query'][_0x514f('0x52')]);_0x2a2665['where']=qs[_0x514f('0x4c')](_[_0x514f('0xc4')](_0x734ae4[_0x514f('0x4b')],_0x1cd4ef[_0x514f('0x4c')]));if(_0x734ae4[_0x514f('0x4b')][_0x514f('0x3b')]){_0x2a2665[_0x514f('0x53')]=_[_0x514f('0x54')](_0x2a2665[_0x514f('0x53')],{'$or':_[_0x514f('0x3c')](_0x2a2665[_0x514f('0x4f')],function(_0x8d903e){var _0x150586={};_0x150586[_0x8d903e]={'$like':'%'+_0x734ae4[_0x514f('0x4b')]['filter']+'%'};return _0x150586;})});}_0x2a2665=_[_0x514f('0x54')]({},_0x2a2665,_0x734ae4[_0x514f('0x58')]);return _0x22415d[_0x514f('0x13a')](_0x2a2665);}})[_0x514f('0x22')](function(_0x4b546a){if(_0x4b546a){_0x40bb55=_0x4b546a[_0x514f('0x60')];if(!_0x734ae4['query'][_0x514f('0x50')]('nolimit')){_0x2a2665[_0x514f('0x31')]=qs[_0x514f('0x31')](_0x734ae4['query'][_0x514f('0x31')]);_0x2a2665[_0x514f('0x30')]=qs['offset'](_0x734ae4[_0x514f('0x4b')]['offset']);}return _0x22415d[_0x514f('0x13a')](_0x2a2665);}})['then'](function(_0xc2a0ca){if(_0xc2a0ca){return _0xc2a0ca?{'count':_0x40bb55,'rows':_0xc2a0ca}:null;}})[_0x514f('0x22')](respondWithResult(_0x2f5e13,null))['catch'](handleError(_0x2f5e13,null));};exports[_0x514f('0x13b')]=function(_0x2995c4,_0x22f50f,_0xfe1aaa){return db['User'][_0x514f('0x40')]({'where':{'id':_0x2995c4[_0x514f('0x5d')]['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x22f50f,null))[_0x514f('0x22')](function(_0x9d0f61){if(_0x9d0f61){return _0x9d0f61[_0x514f('0x13b')](_0x2995c4['body'][_0x514f('0x65')],_[_0x514f('0x109')](_0x2995c4[_0x514f('0x62')],[_0x514f('0x65'),'id'])||{});}})[_0x514f('0x22')](respondWithResult(_0x22f50f,null))[_0x514f('0x2b')](handleError(_0x22f50f,null));};exports[_0x514f('0x13c')]=function(_0x461e7a,_0x4d51ef,_0x561bd6){return db['User'][_0x514f('0x40')]({'where':{'id':_0x461e7a[_0x514f('0x5d')]['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x4d51ef,null))[_0x514f('0x22')](function(_0x2433f8){if(_0x2433f8){return _0x2433f8['removeFaxAccounts'](_0x461e7a['query']['ids']);}})['then'](respondWithStatusCode(_0x4d51ef,null))[_0x514f('0x2b')](handleError(_0x4d51ef,null));};exports[_0x514f('0x13d')]=function(_0x530fa4,_0x522d5c,_0x5f4444){var _0x8cffe6={};var _0x18f50a={};var _0x162154;var _0x491f3f;return db[_0x514f('0x59')][_0x514f('0x9c')]({'where':{'id':_0x530fa4[_0x514f('0x5d')]['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x522d5c,null))[_0x514f('0x22')](function(_0x3078e7){if(_0x3078e7){_0x162154=_0x3078e7;_0x18f50a[_0x514f('0x47')]=_[_0x514f('0x4a')](db[_0x514f('0x13e')][_0x514f('0x5e')]);_0x18f50a['query']=_[_0x514f('0x4a')](_0x530fa4[_0x514f('0x4b')]);_0x18f50a[_0x514f('0x4c')]=_['intersection'](_0x18f50a['model'],_0x18f50a[_0x514f('0x4b')]);_0x8cffe6['attributes']=_[_0x514f('0x4d')](_0x18f50a[_0x514f('0x47')],qs['fields'](_0x530fa4[_0x514f('0x4b')]['fields']));_0x8cffe6[_0x514f('0x4f')]=_0x8cffe6['attributes'][_0x514f('0x60')]?_0x8cffe6[_0x514f('0x4f')]:_0x18f50a[_0x514f('0x47')];_0x8cffe6['order']=qs[_0x514f('0x52')](_0x530fa4['query'][_0x514f('0x52')]);_0x8cffe6[_0x514f('0x53')]=qs[_0x514f('0x4c')](_['pick'](_0x530fa4['query'],_0x18f50a[_0x514f('0x4c')]));if(_0x530fa4[_0x514f('0x4b')][_0x514f('0x3b')]){_0x8cffe6[_0x514f('0x53')]=_[_0x514f('0x54')](_0x8cffe6[_0x514f('0x53')],{'$or':_[_0x514f('0x3c')](_0x8cffe6[_0x514f('0x4f')],function(_0x2861c1){var _0x801fde={};_0x801fde[_0x2861c1]={'$like':'%'+_0x530fa4['query'][_0x514f('0x3b')]+'%'};return _0x801fde;})});}_0x8cffe6=_[_0x514f('0x54')]({},_0x8cffe6,_0x530fa4[_0x514f('0x58')]);return _0x162154['getMailAccounts'](_0x8cffe6);}})['then'](function(_0x1e0ac4){if(_0x1e0ac4){_0x491f3f=_0x1e0ac4['length'];if(!_0x530fa4[_0x514f('0x4b')][_0x514f('0x50')](_0x514f('0xcc'))){_0x8cffe6[_0x514f('0x31')]=qs[_0x514f('0x31')](_0x530fa4[_0x514f('0x4b')][_0x514f('0x31')]);_0x8cffe6['offset']=qs['offset'](_0x530fa4[_0x514f('0x4b')][_0x514f('0x30')]);}return _0x162154[_0x514f('0x13d')](_0x8cffe6);}})[_0x514f('0x22')](function(_0x4bfd41){if(_0x4bfd41){return _0x4bfd41?{'count':_0x491f3f,'rows':_0x4bfd41}:null;}})[_0x514f('0x22')](respondWithResult(_0x522d5c,null))[_0x514f('0x2b')](handleError(_0x522d5c,null));};exports[_0x514f('0x13f')]=function(_0xfa0eea,_0x1d0026,_0x223d55){return db[_0x514f('0x59')][_0x514f('0x40')]({'where':{'id':_0xfa0eea[_0x514f('0x5d')]['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x1d0026,null))[_0x514f('0x22')](function(_0xd3e3b0){if(_0xd3e3b0){return _0xd3e3b0['addMailAccounts'](_0xfa0eea[_0x514f('0x62')][_0x514f('0x65')],_[_0x514f('0x109')](_0xfa0eea[_0x514f('0x62')],[_0x514f('0x65'),'id'])||{});}})[_0x514f('0x22')](respondWithResult(_0x1d0026,null))[_0x514f('0x2b')](handleError(_0x1d0026,null));};exports[_0x514f('0x140')]=function(_0x2a0d9b,_0x36b7b0,_0x56781a){return db[_0x514f('0x59')]['find']({'where':{'id':_0x2a0d9b['params']['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x36b7b0,null))[_0x514f('0x22')](function(_0x1e07b1){if(_0x1e07b1){return _0x1e07b1['removeMailAccounts'](_0x2a0d9b[_0x514f('0x4b')][_0x514f('0x65')]);}})[_0x514f('0x22')](respondWithStatusCode(_0x36b7b0,null))[_0x514f('0x2b')](handleError(_0x36b7b0,null));};exports[_0x514f('0x141')]=function(_0x494f16,_0x30e037,_0x2ec05e){var _0x5c4cf7={};var _0x542bcf={};var _0x4aff1c;var _0x1a318b;return db[_0x514f('0x59')][_0x514f('0x9c')]({'where':{'id':_0x494f16[_0x514f('0x5d')]['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x30e037,null))[_0x514f('0x22')](function(_0x28def4){if(_0x28def4){_0x4aff1c=_0x28def4;_0x542bcf['model']=_[_0x514f('0x4a')](db[_0x514f('0x142')][_0x514f('0x5e')]);_0x542bcf[_0x514f('0x4b')]=_[_0x514f('0x4a')](_0x494f16[_0x514f('0x4b')]);_0x542bcf[_0x514f('0x4c')]=_[_0x514f('0x4d')](_0x542bcf['model'],_0x542bcf[_0x514f('0x4b')]);_0x5c4cf7[_0x514f('0x4f')]=_[_0x514f('0x4d')](_0x542bcf[_0x514f('0x47')],qs[_0x514f('0x4e')](_0x494f16[_0x514f('0x4b')][_0x514f('0x4e')]));_0x5c4cf7[_0x514f('0x4f')]=_0x5c4cf7[_0x514f('0x4f')][_0x514f('0x60')]?_0x5c4cf7[_0x514f('0x4f')]:_0x542bcf['model'];_0x5c4cf7['order']=qs[_0x514f('0x52')](_0x494f16[_0x514f('0x4b')]['sort']);_0x5c4cf7[_0x514f('0x53')]=qs['filters'](_['pick'](_0x494f16[_0x514f('0x4b')],_0x542bcf[_0x514f('0x4c')]));if(_0x494f16[_0x514f('0x4b')][_0x514f('0x3b')]){_0x5c4cf7[_0x514f('0x53')]=_[_0x514f('0x54')](_0x5c4cf7[_0x514f('0x53')],{'$or':_[_0x514f('0x3c')](_0x5c4cf7[_0x514f('0x4f')],function(_0x546398){var _0x2d8d3d={};_0x2d8d3d[_0x546398]={'$like':'%'+_0x494f16['query'][_0x514f('0x3b')]+'%'};return _0x2d8d3d;})});}_0x5c4cf7=_[_0x514f('0x54')]({},_0x5c4cf7,_0x494f16[_0x514f('0x58')]);return _0x4aff1c[_0x514f('0x141')](_0x5c4cf7);}})[_0x514f('0x22')](function(_0x31dd1f){if(_0x31dd1f){_0x1a318b=_0x31dd1f[_0x514f('0x60')];if(!_0x494f16['query'][_0x514f('0x50')](_0x514f('0xcc'))){_0x5c4cf7[_0x514f('0x31')]=qs[_0x514f('0x31')](_0x494f16[_0x514f('0x4b')]['limit']);_0x5c4cf7[_0x514f('0x30')]=qs[_0x514f('0x30')](_0x494f16[_0x514f('0x4b')][_0x514f('0x30')]);}return _0x4aff1c[_0x514f('0x141')](_0x5c4cf7);}})[_0x514f('0x22')](function(_0x28bb78){if(_0x28bb78){return _0x28bb78?{'count':_0x1a318b,'rows':_0x28bb78}:null;}})[_0x514f('0x22')](respondWithResult(_0x30e037,null))['catch'](handleError(_0x30e037,null));};exports[_0x514f('0x143')]=function(_0x18c972,_0x20d208,_0x4a8152){return db['User'][_0x514f('0x40')]({'where':{'id':_0x18c972['params']['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x20d208,null))[_0x514f('0x22')](function(_0x2f361a){if(_0x2f361a){return _0x2f361a['addOpenchannelAccounts'](_0x18c972[_0x514f('0x62')][_0x514f('0x65')],_[_0x514f('0x109')](_0x18c972['body'],[_0x514f('0x65'),'id'])||{});}})[_0x514f('0x22')](respondWithResult(_0x20d208,null))[_0x514f('0x2b')](handleError(_0x20d208,null));};exports[_0x514f('0x144')]=function(_0x5e0460,_0x4900f2,_0x51dea5){return db[_0x514f('0x59')][_0x514f('0x40')]({'where':{'id':_0x5e0460['params']['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x4900f2,null))[_0x514f('0x22')](function(_0xe18007){if(_0xe18007){return _0xe18007[_0x514f('0x144')](_0x5e0460[_0x514f('0x4b')][_0x514f('0x65')]);}})[_0x514f('0x22')](respondWithStatusCode(_0x4900f2,null))[_0x514f('0x2b')](handleError(_0x4900f2,null));};exports[_0x514f('0x145')]=function(_0x1cf256,_0x40e250,_0x3f45fb){var _0x17ed78={};var _0x4ff569={};var _0x271044;var _0x1d7879;return db['User'][_0x514f('0x9c')]({'where':{'id':_0x1cf256[_0x514f('0x5d')]['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x40e250,null))[_0x514f('0x22')](function(_0x42e28c){if(_0x42e28c){_0x271044=_0x42e28c;_0x4ff569[_0x514f('0x47')]=_['keys'](db[_0x514f('0x146')][_0x514f('0x5e')]);_0x4ff569[_0x514f('0x4b')]=_[_0x514f('0x4a')](_0x1cf256[_0x514f('0x4b')]);_0x4ff569[_0x514f('0x4c')]=_[_0x514f('0x4d')](_0x4ff569[_0x514f('0x47')],_0x4ff569[_0x514f('0x4b')]);_0x17ed78[_0x514f('0x4f')]=_['intersection'](_0x4ff569[_0x514f('0x47')],qs[_0x514f('0x4e')](_0x1cf256[_0x514f('0x4b')]['fields']));_0x17ed78[_0x514f('0x4f')]=_0x17ed78[_0x514f('0x4f')][_0x514f('0x60')]?_0x17ed78[_0x514f('0x4f')]:_0x4ff569[_0x514f('0x47')];_0x17ed78['order']=qs[_0x514f('0x52')](_0x1cf256['query'][_0x514f('0x52')]);_0x17ed78[_0x514f('0x53')]=qs[_0x514f('0x4c')](_[_0x514f('0xc4')](_0x1cf256['query'],_0x4ff569['filters']));if(_0x1cf256[_0x514f('0x4b')][_0x514f('0x3b')]){_0x17ed78[_0x514f('0x53')]=_['merge'](_0x17ed78[_0x514f('0x53')],{'$or':_['map'](_0x17ed78[_0x514f('0x4f')],function(_0x45961f){var _0x1fc84a={};_0x1fc84a[_0x45961f]={'$like':'%'+_0x1cf256[_0x514f('0x4b')][_0x514f('0x3b')]+'%'};return _0x1fc84a;})});}_0x17ed78=_['merge']({},_0x17ed78,_0x1cf256[_0x514f('0x58')]);return _0x271044[_0x514f('0x145')](_0x17ed78);}})[_0x514f('0x22')](function(_0x57c999){if(_0x57c999){_0x1d7879=_0x57c999[_0x514f('0x60')];if(!_0x1cf256[_0x514f('0x4b')]['hasOwnProperty'](_0x514f('0xcc'))){_0x17ed78[_0x514f('0x31')]=qs['limit'](_0x1cf256['query'][_0x514f('0x31')]);_0x17ed78[_0x514f('0x30')]=qs['offset'](_0x1cf256['query'][_0x514f('0x30')]);}return _0x271044[_0x514f('0x145')](_0x17ed78);}})[_0x514f('0x22')](function(_0x8f3533){if(_0x8f3533){return _0x8f3533?{'count':_0x1d7879,'rows':_0x8f3533}:null;}})['then'](respondWithResult(_0x40e250,null))[_0x514f('0x2b')](handleError(_0x40e250,null));};exports[_0x514f('0x147')]=function(_0x3de0e4,_0x45d6bc,_0x3229ee){return db[_0x514f('0x59')]['find']({'where':{'id':_0x3de0e4[_0x514f('0x5d')]['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x45d6bc,null))[_0x514f('0x22')](function(_0x5b10d9){if(_0x5b10d9){return _0x5b10d9[_0x514f('0x147')](_0x3de0e4['body'][_0x514f('0x65')],_[_0x514f('0x109')](_0x3de0e4[_0x514f('0x62')],[_0x514f('0x65'),'id'])||{});}})[_0x514f('0x22')](respondWithResult(_0x45d6bc,null))[_0x514f('0x2b')](handleError(_0x45d6bc,null));};exports[_0x514f('0x148')]=function(_0x2c5395,_0x3d08d2,_0x200323){return db['User'][_0x514f('0x40')]({'where':{'id':_0x2c5395[_0x514f('0x5d')]['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x3d08d2,null))['then'](function(_0x49771d){if(_0x49771d){return _0x49771d[_0x514f('0x148')](_0x2c5395['query']['ids']);}})[_0x514f('0x22')](respondWithStatusCode(_0x3d08d2,null))[_0x514f('0x2b')](handleError(_0x3d08d2,null));};exports[_0x514f('0x149')]=function(_0x4e2848,_0x508fd8,_0x597dfe){var _0x286629={};var _0x581f8a={};var _0x3432e0;var _0x5a14ab;return db['User'][_0x514f('0x9c')]({'where':{'id':_0x4e2848[_0x514f('0x5d')]['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x508fd8,null))[_0x514f('0x22')](function(_0x3dda0c){if(_0x3dda0c){_0x3432e0=_0x3dda0c;_0x581f8a['model']=_[_0x514f('0x4a')](db[_0x514f('0x14a')]['rawAttributes']);_0x581f8a['query']=_['keys'](_0x4e2848[_0x514f('0x4b')]);_0x581f8a[_0x514f('0x4c')]=_[_0x514f('0x4d')](_0x581f8a[_0x514f('0x47')],_0x581f8a['query']);_0x286629[_0x514f('0x4f')]=_[_0x514f('0x4d')](_0x581f8a['model'],qs[_0x514f('0x4e')](_0x4e2848['query'][_0x514f('0x4e')]));_0x286629[_0x514f('0x4f')]=_0x286629[_0x514f('0x4f')][_0x514f('0x60')]?_0x286629[_0x514f('0x4f')]:_0x581f8a[_0x514f('0x47')];_0x286629['order']=qs[_0x514f('0x52')](_0x4e2848[_0x514f('0x4b')][_0x514f('0x52')]);_0x286629[_0x514f('0x53')]=qs['filters'](_[_0x514f('0xc4')](_0x4e2848[_0x514f('0x4b')],_0x581f8a['filters']));if(_0x4e2848[_0x514f('0x4b')][_0x514f('0x3b')]){_0x286629[_0x514f('0x53')]=_['merge'](_0x286629[_0x514f('0x53')],{'$or':_[_0x514f('0x3c')](_0x286629[_0x514f('0x4f')],function(_0x29b4a6){var _0x2c06af={};_0x2c06af[_0x29b4a6]={'$like':'%'+_0x4e2848[_0x514f('0x4b')][_0x514f('0x3b')]+'%'};return _0x2c06af;})});}_0x286629=_['merge']({},_0x286629,_0x4e2848[_0x514f('0x58')]);return _0x3432e0[_0x514f('0x149')](_0x286629);}})[_0x514f('0x22')](function(_0x528953){if(_0x528953){_0x5a14ab=_0x528953[_0x514f('0x60')];if(!_0x4e2848[_0x514f('0x4b')]['hasOwnProperty']('nolimit')){_0x286629['limit']=qs[_0x514f('0x31')](_0x4e2848['query'][_0x514f('0x31')]);_0x286629[_0x514f('0x30')]=qs['offset'](_0x4e2848[_0x514f('0x4b')][_0x514f('0x30')]);}return _0x3432e0['getChatWebsites'](_0x286629);}})[_0x514f('0x22')](function(_0x4b064d){if(_0x4b064d){return _0x4b064d?{'count':_0x5a14ab,'rows':_0x4b064d}:null;}})[_0x514f('0x22')](respondWithResult(_0x508fd8,null))[_0x514f('0x2b')](handleError(_0x508fd8,null));};exports[_0x514f('0x14b')]=function(_0x2209bc,_0x19ea1a,_0xc69438){return db['User'][_0x514f('0x40')]({'where':{'id':_0x2209bc[_0x514f('0x5d')]['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x19ea1a,null))[_0x514f('0x22')](function(_0x3c9522){if(_0x3c9522){return _0x3c9522['addChatWebsites'](_0x2209bc[_0x514f('0x62')][_0x514f('0x65')],_[_0x514f('0x109')](_0x2209bc['body'],['ids','id'])||{});}})['then'](respondWithResult(_0x19ea1a,null))[_0x514f('0x2b')](handleError(_0x19ea1a,null));};exports[_0x514f('0x14c')]=function(_0x1cb04d,_0x2141a5,_0xf71999){return db[_0x514f('0x59')][_0x514f('0x40')]({'where':{'id':_0x1cb04d[_0x514f('0x5d')]['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x2141a5,null))[_0x514f('0x22')](function(_0x453f94){if(_0x453f94){return _0x453f94[_0x514f('0x14c')](_0x1cb04d[_0x514f('0x4b')]['ids']);}})[_0x514f('0x22')](respondWithStatusCode(_0x2141a5,null))[_0x514f('0x2b')](handleError(_0x2141a5,null));};exports[_0x514f('0x14d')]=function(_0x1041f8,_0x52ebaa,_0x273572){var _0x2d42e9={};var _0x276e6d={};var _0x538ebc;var _0x43da5c;return db[_0x514f('0x59')][_0x514f('0x9c')]({'where':{'id':_0x1041f8[_0x514f('0x5d')]['id']}})['then'](handleEntityNotFound(_0x52ebaa,null))[_0x514f('0x22')](function(_0x42c088){if(_0x42c088){_0x538ebc=_0x42c088;_0x276e6d[_0x514f('0x47')]=_['keys'](db[_0x514f('0x14e')][_0x514f('0x5e')]);_0x276e6d[_0x514f('0x4b')]=_['keys'](_0x1041f8[_0x514f('0x4b')]);_0x276e6d[_0x514f('0x4c')]=_[_0x514f('0x4d')](_0x276e6d[_0x514f('0x47')],_0x276e6d[_0x514f('0x4b')]);_0x2d42e9[_0x514f('0x4f')]=_[_0x514f('0x4d')](_0x276e6d[_0x514f('0x47')],qs[_0x514f('0x4e')](_0x1041f8[_0x514f('0x4b')][_0x514f('0x4e')]));_0x2d42e9['attributes']=_0x2d42e9['attributes'][_0x514f('0x60')]?_0x2d42e9['attributes']:_0x276e6d[_0x514f('0x47')];_0x2d42e9[_0x514f('0x51')]=qs[_0x514f('0x52')](_0x1041f8[_0x514f('0x4b')][_0x514f('0x52')]);_0x2d42e9['where']=qs['filters'](_[_0x514f('0xc4')](_0x1041f8[_0x514f('0x4b')],_0x276e6d['filters']));if(_0x1041f8[_0x514f('0x4b')][_0x514f('0x3b')]){_0x2d42e9[_0x514f('0x53')]=_['merge'](_0x2d42e9[_0x514f('0x53')],{'$or':_['map'](_0x2d42e9[_0x514f('0x4f')],function(_0x5c9696){var _0x36f61c={};_0x36f61c[_0x5c9696]={'$like':'%'+_0x1041f8[_0x514f('0x4b')][_0x514f('0x3b')]+'%'};return _0x36f61c;})});}_0x2d42e9=_[_0x514f('0x54')]({},_0x2d42e9,_0x1041f8[_0x514f('0x58')]);return _0x538ebc['getWhatsappAccounts'](_0x2d42e9);}})[_0x514f('0x22')](function(_0x506fa7){if(_0x506fa7){_0x43da5c=_0x506fa7['length'];if(!_0x1041f8[_0x514f('0x4b')][_0x514f('0x50')](_0x514f('0xcc'))){_0x2d42e9[_0x514f('0x31')]=qs['limit'](_0x1041f8[_0x514f('0x4b')][_0x514f('0x31')]);_0x2d42e9[_0x514f('0x30')]=qs[_0x514f('0x30')](_0x1041f8[_0x514f('0x4b')][_0x514f('0x30')]);}return _0x538ebc[_0x514f('0x14d')](_0x2d42e9);}})[_0x514f('0x22')](function(_0x795c72){if(_0x795c72){return _0x795c72?{'count':_0x43da5c,'rows':_0x795c72}:null;}})['then'](respondWithResult(_0x52ebaa,null))['catch'](handleError(_0x52ebaa,null));};exports['addWhatsappAccounts']=function(_0x52946b,_0x580ee2,_0x550b9b){return db['User']['find']({'where':{'id':_0x52946b[_0x514f('0x5d')]['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x580ee2,null))['then'](function(_0x49b5e2){if(_0x49b5e2){return _0x49b5e2[_0x514f('0x14f')](_0x52946b[_0x514f('0x62')][_0x514f('0x65')],_[_0x514f('0x109')](_0x52946b[_0x514f('0x62')],[_0x514f('0x65'),'id'])||{});}})[_0x514f('0x22')](respondWithResult(_0x580ee2,null))[_0x514f('0x2b')](handleError(_0x580ee2,null));};exports[_0x514f('0x150')]=function(_0x468a25,_0x28544e,_0x71a63){return db[_0x514f('0x59')]['find']({'where':{'id':_0x468a25[_0x514f('0x5d')]['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x28544e,null))[_0x514f('0x22')](function(_0x532218){if(_0x532218){return _0x532218[_0x514f('0x150')](_0x468a25['query'][_0x514f('0x65')]);}})[_0x514f('0x22')](respondWithStatusCode(_0x28544e,null))[_0x514f('0x2b')](handleError(_0x28544e,null));};exports[_0x514f('0x151')]=function(_0x189a67,_0x265796,_0x188d3d){var _0x334c00={};var _0x2b1920={};var _0x412f00;var _0x147f41;return db[_0x514f('0x59')][_0x514f('0x9c')]({'where':{'id':_0x189a67[_0x514f('0x5d')]['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x265796,null))[_0x514f('0x22')](function(_0x1439da){if(_0x1439da){_0x412f00=_0x1439da;_0x2b1920[_0x514f('0x47')]=_[_0x514f('0x4a')](db[_0x514f('0x152')]['rawAttributes']);_0x2b1920[_0x514f('0x4b')]=_['keys'](_0x189a67[_0x514f('0x4b')]);_0x2b1920[_0x514f('0x4c')]=_[_0x514f('0x4d')](_0x2b1920['model'],_0x2b1920[_0x514f('0x4b')]);_0x334c00[_0x514f('0x4f')]=_[_0x514f('0x4d')](_0x2b1920[_0x514f('0x47')],qs[_0x514f('0x4e')](_0x189a67[_0x514f('0x4b')][_0x514f('0x4e')]));_0x334c00[_0x514f('0x4f')]=_0x334c00[_0x514f('0x4f')]['length']?_0x334c00[_0x514f('0x4f')]:_0x2b1920[_0x514f('0x47')];_0x334c00['order']=qs[_0x514f('0x52')](_0x189a67[_0x514f('0x4b')][_0x514f('0x52')]);_0x334c00[_0x514f('0x53')]=qs[_0x514f('0x4c')](_[_0x514f('0xc4')](_0x189a67['query'],_0x2b1920['filters']));if(_0x189a67[_0x514f('0x4b')][_0x514f('0x3b')]){_0x334c00[_0x514f('0x53')]=_[_0x514f('0x54')](_0x334c00[_0x514f('0x53')],{'$or':_['map'](_0x334c00[_0x514f('0x4f')],function(_0x3bb76c){var _0x408522={};_0x408522[_0x3bb76c]={'$like':'%'+_0x189a67[_0x514f('0x4b')][_0x514f('0x3b')]+'%'};return _0x408522;})});}_0x334c00=_[_0x514f('0x54')]({},_0x334c00,_0x189a67[_0x514f('0x58')]);return _0x412f00[_0x514f('0x151')](_0x334c00);}})[_0x514f('0x22')](function(_0x6134af){if(_0x6134af){_0x147f41=_0x6134af[_0x514f('0x60')];if(!_0x189a67['query'][_0x514f('0x50')](_0x514f('0xcc'))){_0x334c00[_0x514f('0x31')]=qs[_0x514f('0x31')](_0x189a67[_0x514f('0x4b')]['limit']);_0x334c00[_0x514f('0x30')]=qs[_0x514f('0x30')](_0x189a67[_0x514f('0x4b')][_0x514f('0x30')]);}return _0x412f00[_0x514f('0x151')](_0x334c00);}})[_0x514f('0x22')](function(_0x1097ec){if(_0x1097ec){return _0x1097ec?{'count':_0x147f41,'rows':_0x1097ec}:null;}})[_0x514f('0x22')](respondWithResult(_0x265796,null))[_0x514f('0x2b')](handleError(_0x265796,null));};exports[_0x514f('0x153')]=function(_0x2c7b11,_0x476355,_0x551dc){return db[_0x514f('0x59')][_0x514f('0x40')]({'where':{'id':_0x2c7b11['params']['id']}})['then'](handleEntityNotFound(_0x476355,null))[_0x514f('0x22')](function(_0x187058){if(_0x187058){return _0x187058[_0x514f('0x153')](_0x2c7b11[_0x514f('0x62')][_0x514f('0x65')],_[_0x514f('0x109')](_0x2c7b11[_0x514f('0x62')],[_0x514f('0x65'),'id'])||{});}})[_0x514f('0x22')](respondWithResult(_0x476355,null))[_0x514f('0x2b')](handleError(_0x476355,null));};exports['removeSquareProjects']=function(_0x11f867,_0x31dc96,_0x1aa8c6){return db[_0x514f('0x59')]['find']({'where':{'id':_0x11f867[_0x514f('0x5d')]['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x31dc96,null))['then'](function(_0x4290e9){if(_0x4290e9){return _0x4290e9[_0x514f('0x154')](_0x11f867[_0x514f('0x4b')][_0x514f('0x65')]);}})[_0x514f('0x22')](respondWithStatusCode(_0x31dc96,null))[_0x514f('0x2b')](handleError(_0x31dc96,null));};exports[_0x514f('0x155')]=function(_0xee1e0a,_0x3d36ed){var _0x2749bf={},_0x446f0c={},_0x5ba772={'count':0x0,'rows':[]};var _0x2b445c=db[_0x514f('0x156')][_0x514f('0x5e')];_0x446f0c[_0x514f('0x47')]=_[_0x514f('0x4a')](_0x2b445c);_0x446f0c['query']=_[_0x514f('0x4a')](_0xee1e0a[_0x514f('0x4b')]);_0x446f0c[_0x514f('0x4c')]=_[_0x514f('0x4d')](_0x446f0c['model'],_0x446f0c[_0x514f('0x4b')]);_0x446f0c[_0x514f('0x4c')]=_[_0x514f('0x157')](_0x446f0c[_0x514f('0x4c')],['$and',_0x514f('0x158'),_0x514f('0x159'),_0x514f('0x15a'),_0x514f('0x15b'),'$lte',_0x514f('0x15c'),_0x514f('0x15d'),'$not',_0x514f('0x15e'),_0x514f('0x15f'),'$in',_0x514f('0x160'),_0x514f('0x161'),_0x514f('0x162'),_0x514f('0x163'),'$notILike',_0x514f('0x161'),_0x514f('0x164'),'$contains','$contained',_0x514f('0x165')]);_0x2749bf['attributes']=_['intersection'](_0x446f0c[_0x514f('0x47')],qs[_0x514f('0x4e')](_0xee1e0a[_0x514f('0x4b')][_0x514f('0x4e')]));_0x2749bf[_0x514f('0x4f')]=_0x2749bf[_0x514f('0x4f')]['length']?_0x2749bf[_0x514f('0x4f')]:_0x446f0c['model'];if(!_0xee1e0a[_0x514f('0x4b')][_0x514f('0x50')](_0x514f('0xcc'))){_0x2749bf[_0x514f('0x31')]=qs['limit'](_0xee1e0a[_0x514f('0x4b')][_0x514f('0x31')]);_0x2749bf[_0x514f('0x30')]=qs['offset'](_0xee1e0a['query']['offset']);}_0x2749bf[_0x514f('0x51')]=qs[_0x514f('0x52')](_0xee1e0a[_0x514f('0x4b')][_0x514f('0x52')]);_0x2749bf[_0x514f('0x53')]=qs[_0x514f('0x4c')](_[_0x514f('0xc4')](_0xee1e0a[_0x514f('0x4b')],_0x446f0c[_0x514f('0x4c')]));if(_0xee1e0a['query'][_0x514f('0x3b')]){_0x2749bf[_0x514f('0x53')]=_[_0x514f('0x54')](_0x2749bf[_0x514f('0x53')],{'$or':_[_0x514f('0x3c')](_0x2749bf[_0x514f('0x4f')],function(_0x47f4ae){var _0x3bd853={};_0x3bd853[_0x47f4ae]={'$like':'%'+_0xee1e0a[_0x514f('0x4b')][_0x514f('0x3b')]+'%'};return _0x3bd853;})});}_0x2749bf[_0x514f('0x53')]={'$and':[_0x2749bf[_0x514f('0x53')],{'$or':[{'UserId':_0xee1e0a[_0x514f('0x5d')]['id']},{'OwnerId':_0xee1e0a[_0x514f('0x5d')]['id']}]}]};_0x2749bf=_[_0x514f('0x54')]({},_0x2749bf,_0xee1e0a[_0x514f('0x58')]);var _0x260680={'where':_0x2749bf[_0x514f('0x53')]};return db[_0x514f('0x156')][_0x514f('0x2f')](_0x260680)[_0x514f('0x22')](function(_0x15b428){_0x5ba772[_0x514f('0x2f')]=_0x15b428;if(_0xee1e0a[_0x514f('0x4b')][_0x514f('0x5a')]){_0x2749bf[_0x514f('0x61')]=[{'attributes':['id',_0x514f('0x166'),_0x514f('0x167'),_0x514f('0xdd')],'model':db['CmContact'],'as':'Contact'},{'attributes':['id',_0x514f('0x41'),_0x514f('0x168')],'model':db[_0x514f('0xb2')],'as':_0x514f('0xca')}];}return db['CmHopper'][_0x514f('0x5b')](_0x2749bf);})[_0x514f('0x22')](function(_0x14f839){_0x5ba772[_0x514f('0xd2')]=_0x14f839;return _0x5ba772;})[_0x514f('0x22')](respondWithFilteredResult(_0x3d36ed,_0x2749bf))[_0x514f('0x2b')](handleError(_0x3d36ed,null));};exports[_0x514f('0x169')]=function(_0x5adedd,_0x4540d4,_0x1ddc06){if(!_['isNil'](_0x5adedd['user']['id'])&&(_0x5adedd['user'][_0x514f('0x3f')]=='admin'||_0x5adedd[_0x514f('0x7f')][_0x514f('0x3f')]==_0x514f('0x7f'))){return db[_0x514f('0x59')][_0x514f('0x9c')]({'where':{'id':_0x5adedd[_0x514f('0x5d')]['id']},'raw':!![]})[_0x514f('0x22')](function(_0xcf43ac){return authService[_0x514f('0x16a')](_0xcf43ac);})['then'](function(_0x570228){if(_0x570228){return _0x4540d4['status'](0xc8)[_0x514f('0x2e')]({'api_key':_0x570228['token']});}else{return _0x4540d4[_0x514f('0x2c')](0xcc)[_0x514f('0x2e')]({'message':'No\x20API\x20access\x20key\x20found!'});}})[_0x514f('0x2b')](handleError(_0x4540d4,0x193));}else{return _0x4540d4['status'](0x191)[_0x514f('0x2e')]({'message':'You\x20don\x27t\x20have\x20sufficient\x20privileges\x20to\x20access\x20this\x20resource.'});}};exports[_0x514f('0x16b')]=function(_0x2d0e1f,_0x5beff2,_0xeedb88){if(!_['isNil'](_0x2d0e1f[_0x514f('0x7f')]['id'])&&(_0x2d0e1f['user']['role']==_0x514f('0x80')||_0x2d0e1f['user'][_0x514f('0x3f')]==_0x514f('0x7f'))){return db['User'][_0x514f('0x40')]({'where':{'id':_0x2d0e1f[_0x514f('0x5d')]['id']}})[_0x514f('0x22')](function(_0x1427af){return authService[_0x514f('0x16c')](_0x1427af);})['then'](function(_0x48051d){return db[_0x514f('0x59')]['update']({'apiKeyIat':_0x48051d[_0x514f('0x16d')],'apiKeyNonce':_0x48051d[_0x514f('0x16e')]},{'where':{'id':_0x2d0e1f[_0x514f('0x5d')]['id']}})[_0x514f('0x22')](function(){return _0x5beff2[_0x514f('0x2c')](0xc8)[_0x514f('0x2e')]({'api_key':_0x48051d[_0x514f('0x16f')]});});})[_0x514f('0x2b')](handleError(_0x5beff2,0x193));}else{return _0x5beff2[_0x514f('0x2c')](0x191)[_0x514f('0x2e')]({'message':_0x514f('0x170')});}};exports[_0x514f('0x171')]=function(_0x123978,_0x4f490e,_0x2d0823){if(!_['isNil'](_0x123978[_0x514f('0x7f')]['id'])&&(_0x123978[_0x514f('0x7f')][_0x514f('0x3f')]=='admin'||_0x123978['user']['role']=='user')){return db['User'][_0x514f('0x40')]({'where':{'id':_0x123978[_0x514f('0x5d')]['id']}})[_0x514f('0x22')](handleEntityNotFound(_0x4f490e,null))['then'](function(_0x228b1e){if(_0x228b1e&&_0x228b1e[_0x514f('0x172')]&&_0x228b1e[_0x514f('0x173')])return _0x228b1e;else throw{'message':'API\x20key\x20not\x20available'};})[_0x514f('0x22')](function(_0x52ca43){return db[_0x514f('0x59')][_0x514f('0x35')]({'apiKeyNonce':null,'apiKeyIat':null},{'where':{'id':_0x123978[_0x514f('0x5d')]['id']}});})[_0x514f('0x22')](respondWithStatusCode(_0x4f490e,0xc8))[_0x514f('0x2b')](handleError(_0x4f490e,0x193));}else{return _0x4f490e[_0x514f('0x2c')](0x191)['json']({'message':_0x514f('0x170')});}};exports[_0x514f('0x174')]=function(_0x2fd830,_0x21ea61){var _0x201dc2=_0x2fd830['user'][_0x514f('0x37')]({'plain':!![]});if(!_0x201dc2){return _0x21ea61[_0x514f('0x2c')](0x191)[_0x514f('0x44')](_0x514f('0x175'));}else{return _0x21ea61[_0x514f('0x2c')](0xc8)['json'](_0x201dc2);}};
\ No newline at end of file
+var _0x998d=['sms','all','body','describe','addContacts','omit','internal','Setting','findById','securePassword','password','max','min_internal','isNil','sequelize','select\x20(select\x20IFNULL(max(internal)+1,1)\x20from\x20users\x20where\x20internal\x20<\x20md.internal)\x20as\x20\x27from\x27,\x20md.internal\x20-\x201\x20as\x20\x27to\x27\x20from\x20users\x20md\x20where\x20md.internal\x20!=\x201\x20and\x20not\x20exists\x20(select\x201\x20from\x20users\x20md2\x20where\x20md2.internal\x20=\x20md.internal\x20-\x201)','QueryTypes','SELECT','from','voicemail','mailbox','VoiceMail','fullname','email','permissions','101','102','103','113','110','104','105','107','109','114','115','create','Unauthorized','Unauthorized.\x20You\x20must\x20be\x20an\x20administrator\x20in\x20order\x20to\x20create\x20an\x20user','Unauthorized.\x20You\x20must\x20be\x20an\x20administrator\x20in\x20order\x20to\x20create\x20another\x20administrator','settingsEnabled','UserProfileSection','userProfileId','autoAssociation','UserProfileResource','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','some','Unauthorized.\x20You\x20must\x20be\x20an\x20administrator\x20in\x20order\x20to\x20create\x20an\x20administrator','length','isEmpty','compact','changePassword','oldPassword','newPassword','Sequelize','ValidationError','Wrong\x20credentials','Invalid\x20body\x20format.\x20Use\x20newPassword','findOne','enforcePasswordHistory','passwordHistoryLimit','validatePasswordPattern','validatePasswordHistory','addQueues','channel','online','loginInPause','interface','isValidChannel','Unknown\x20channel','toLowerCase','Queues','ids','penalty','spread','capitalize','QueueId','Queue:save','VoiceQueue','get','voice','SIP/%s','voicePause','UserVoiceQueueRt','upsert','removeQueues','remove','isArray','Queue:remove','addAvatar','userpic','file','join','root','server/files/images/','download','getOpenTabs','ChatOpenTabs','CHAT','FAX','createdAt','OpenchannelOpenTabs','MailOpenTabs','MAIL','SmsOpenTabs','SMS','WhatsappOpenTabs','WHATSAPP','concat','format','hasOwnProperty','List','Tag','Tags','tag','getQueues','keys','Queue','filters','intersection','model','fields','order','sort','merge','Unknown\x20role','nolimit','getVoiceQueuesRt','pick','ChatGroup','getGroups','getRecordings','VoiceRecording','UserId','getScreenRecordings','ScreenRecording','getChatInteractions','getOpenchannelInteractions','OpenchannelInteraction','MailInteraction','getSmsInteractions','SmsInteraction','getFaxInteractions','getWhatsappInteractions','WhatsappInteraction','login','phone','mobile','intrf','user:%s','user:forcelogout','headers','x-forwarded-for','socket','remoteAddress','connection','getVoiceQueues','UserVoiceQueue.penalty','MemberReport','forEach','getChannels','device','PAUSE','bulkCreate','YYYY-MM-DD\x20HH:mm:ss','LOGININPAUSE','resolve','logout','pause','QueuePause','DEFAULT\x20PAUSE','unpause','Channel\x20parameter\x20%s\x20is\x20invalid','mailPause','faxPause','smsPause','pauseType','lastPauseAt','User\x20with\x20id\x20%s\x20not\x20found','getTeams','Team','addTeams','Body\x20parameter\x20\x27ids\x27\x20is\x20required','transaction','getAssociatedQueues','flattenDeep','addAgent','getDataValue','Voice','removeTeams','Query\x20parameter\x20\x27ids\x27\x20is\x20required','TeamVoicePrefix','UserVoicePrefix','VoicePrefixId','getLists','CmList','values','You\x20can\x27t\x20delete\x20yourself','addChatInteractions','removeChatInteractions','user_has_chat_interactions:remove','addMailInteractions','removeMailInteractions','user_has_mail_interactions:remove','addFaxInteractions','user_has_fax_interactions:save','removeFaxInteractions','user_has_fax_interactions:remove','addSmsInteractions','user_has_sms_interactions:save','removeSmsInteractions','user_has_sms_interactions:remove','addOpenchannelInteractions','user_has_openchannel_interactions:save','removeOpenchannelInteractions','user_has_openchannel_interactions:remove','addWhatsappInteractions','removeWhatsappInteractions','getVoicePrefixes','getFaxAccounts','FaxAccount','addFaxAccounts','removeFaxAccounts','getMailAccounts','MailAccount','addMailAccounts','removeMailAccounts','getOpenchannelAccounts','OpenchannelAccount','addOpenchannelAccounts','removeOpenchannelAccounts','getSmsAccounts','addSmsAccounts','removeSmsAccounts','getChatWebsites','ChatWebsite','addChatWebsites','removeChatWebsites','getWhatsappAccounts','WhatsappAccount','addWhatsappAccounts','removeWhatsappAccounts','getScheduledCalls','$and','$or','$gt','$lt','$lte','$ne','$eq','$not','$notBetween','$notIn','$like','$notLike','$iLike','$notILike','$overlap','$contains','$any','CmHopper','firstName','lastName','Contact','dialActive','getApiKey','retrieveApiKey','token','No\x20API\x20access\x20key\x20found!','createApiKey','generateApiKey','iat','You\x20don\x27t\x20have\x20sufficient\x20privileges\x20to\x20access\x20this\x20resource.','apiKeyNonce','apiKeyIat','API\x20key\x20not\x20available','Unable\x20to\x20retrieve\x20the\x20current\x20user','getUserSetting','getPresence','unknown','teams','inbound','getAgents','flatten','toString','lower','asc','desc','substring','uniqBy','orderBy','getRealtimeAgents','voiceStatus','unavailable','busy','toUpperCase','slice','select','field','InteractionId','user_has_','_interactions','ui.UserId\x20=\x20?','OpenTabs','enabled','moment','util','lodash','squel','ioredis','jayson/promise','../../components/auth/service','../../components/parsers/qs','../../components/realtime/agents','../../config/logger','api','../../config/environment','../../config/license/util','../../errors/api','APINotFoundError','APIForbiddenrror','handleError','../../mysqldb','socket.io-emitter','redis','./user.socket','register','defaults','localhost','client','http','sendStatus','status','end','json','offset','undefined','limit','count','set','Content-Range','request','info','User,\x20%s,\x20%s','request\x20sent','debug','User,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','update','then','role','agent','emit','admin','Users','user','Agents','Telephones','telephone','ignore','map','value','find','name','destroy','send','rawAttributes','fieldName','type','key','filter','salt','previousPasswords','resetPasswordToken','md5secret','includes','index','where','include','query','userSetting','true','UserSetting','push','User','findAll','rows','openTabs','chat','dataValues','fax','mail','openchannel','whatsapp','show','params','getOptions','includeAll','options','attributes'];(function(_0x4bfac3,_0x58324d){var _0x15f0f2=function(_0xf0c511){while(--_0xf0c511){_0x4bfac3['push'](_0x4bfac3['shift']());}};_0x15f0f2(++_0x58324d);}(_0x998d,0x131));var _0xd998=function(_0x3b77fd,_0x2f7b50){_0x3b77fd=_0x3b77fd-0x0;var _0x4ca0c5=_0x998d[_0x3b77fd];return _0x4ca0c5;};'use strict';var moment=require(_0xd998('0x0'));var util=require(_0xd998('0x1'));var path=require('path');var fs=require('fs');var _=require(_0xd998('0x2'));var squel=require(_0xd998('0x3'));var Redis=require(_0xd998('0x4'));var jayson=require(_0xd998('0x5'));var authService=require(_0xd998('0x6'));var contacts=require('../../components/contacts');var qs=require(_0xd998('0x7'));var rta=require(_0xd998('0x8'));var logger=require(_0xd998('0x9'))(_0xd998('0xa'));var utils=require('../../config/utils');var config=require(_0xd998('0xb'));var licenseUtil=require(_0xd998('0xc'));var APIBadRequestError=require(_0xd998('0xd'))['APIBadRequestError'];var APINotFoundError=require(_0xd998('0xd'))[_0xd998('0xe')];var APIForbiddenError=require(_0xd998('0xd'))[_0xd998('0xf')];var APIHandleError=require(_0xd998('0xd'))[_0xd998('0x10')];var db=require(_0xd998('0x11'))['db'];var socket=require(_0xd998('0x12'))(new Redis(config[_0xd998('0x13')]));require(_0xd998('0x14'))[_0xd998('0x15')](socket);config[_0xd998('0x13')]=_[_0xd998('0x16')](config[_0xd998('0x13')],{'host':_0xd998('0x17'),'port':0x18eb});var amiClient=jayson[_0xd998('0x18')][_0xd998('0x19')]({'port':0x232a});var values;function respondWithStatusCode(_0x4e6661,_0xc20610){_0xc20610=_0xc20610||0xcc;return function(_0x588ca4){if(_0x588ca4){return _0x4e6661[_0xd998('0x1a')](_0xc20610);}return _0x4e6661[_0xd998('0x1b')](_0xc20610)[_0xd998('0x1c')]();};}function respondWithResult(_0x11ce0d,_0x6fc47){_0x6fc47=_0x6fc47||0xc8;return function(_0x1d414d){if(_0x1d414d){return _0x11ce0d[_0xd998('0x1b')](_0x6fc47)[_0xd998('0x1d')](_0x1d414d);}};}function respondWithFilteredResult(_0x3f5fc4,_0x1ec903){return function(_0x266514){if(_0x266514){var _0x5adbb1=typeof _0x1ec903[_0xd998('0x1e')]===_0xd998('0x1f')&&typeof _0x1ec903[_0xd998('0x20')]===_0xd998('0x1f');var _0x1a8449=_0x266514[_0xd998('0x21')];var _0x400f49=_0x5adbb1?0x0:_0x1ec903['offset'];var _0xc7d993=_0x5adbb1?_0x266514[_0xd998('0x21')]:_0x1ec903['offset']+_0x1ec903['limit'];var _0x350115;if(_0xc7d993>=_0x1a8449){_0xc7d993=_0x1a8449;_0x350115=0xc8;}else{_0x350115=0xce;}_0x3f5fc4[_0xd998('0x1b')](_0x350115);return _0x3f5fc4[_0xd998('0x22')](_0xd998('0x23'),_0x400f49+'-'+_0xc7d993+'/'+_0x1a8449)['json'](_0x266514);}return null;};}function respondWithRpcPromise(_0x5dda2c,_0x501e48,_0x52e091,_0xd30df){return new Promise(function(_0xfadad8,_0x25f675){var _0x249b7b=_0xd30df||amiClient;return _0x249b7b[_0xd998('0x24')](_0x5dda2c,_0x52e091)['then'](function(_0x15a8e8){logger[_0xd998('0x25')](_0xd998('0x26'),_0x501e48,_0xd998('0x27'));logger[_0xd998('0x28')](_0xd998('0x29'),_0x501e48,_0xd998('0x27'),JSON[_0xd998('0x2a')](_0x15a8e8));if(_0x15a8e8[_0xd998('0x2b')]){if(_0x15a8e8[_0xd998('0x2b')][_0xd998('0x2c')]===0x1f4){logger[_0xd998('0x2b')](_0xd998('0x26'),_0x501e48,_0x15a8e8[_0xd998('0x2b')]['message']);return _0x25f675(_0x15a8e8[_0xd998('0x2b')][_0xd998('0x2d')]);}logger[_0xd998('0x2b')](_0xd998('0x26'),_0x501e48,_0x15a8e8['error'][_0xd998('0x2d')]);return _0xfadad8(_0x15a8e8[_0xd998('0x2b')]['message']);}else{logger[_0xd998('0x25')](_0xd998('0x26'),_0x501e48,_0xd998('0x27'));_0xfadad8(_0x15a8e8[_0xd998('0x2e')]['message']);}})[_0xd998('0x2f')](function(_0x1d9a53){logger[_0xd998('0x2b')](_0xd998('0x26'),_0x501e48,_0x1d9a53);_0x25f675(_0x1d9a53);});});}function saveUpdates(_0x48645a){return function(_0x14cbea){if(_0x14cbea){return _0x14cbea[_0xd998('0x30')](_0x48645a)[_0xd998('0x31')](function(_0x57b05b){if(_0x57b05b[_0xd998('0x32')]===_0xd998('0x33')){socket[_0xd998('0x34')]('userNotification:recalc:'+_0x57b05b['id'],_0x57b05b);}return _0x57b05b;});}return null;};}function removeEntity(_0x5ba543,_0x7ac619){return function(_0x26f9b3){if(_0x26f9b3){return _0x26f9b3['destroy']({'transaction':_0x7ac619})[_0xd998('0x31')](function(){var _0x17d864=_0x26f9b3['get']({'plain':!![]});if(_0x17d864[_0xd998('0x32')]===_0xd998('0x35'))return;var _0x410070=[{'name':_0xd998('0x36'),'value':_0xd998('0x37'),'ignore':!![]},{'name':_0xd998('0x38'),'value':_0xd998('0x33'),'ignore':![]},{'name':_0xd998('0x39'),'value':_0xd998('0x3a'),'ignore':![]}];var _0x2cd63d=_(_0x410070)['filter'](_0xd998('0x3b'))[_0xd998('0x3c')]('value')[_0xd998('0x3d')]();if(_['includes'](_0x2cd63d,_0x17d864[_0xd998('0x32')])){return;}var _0x14cd96=_[_0xd998('0x3e')](_0x410070,['value',_0x17d864[_0xd998('0x32')]])[_0xd998('0x3f')];return db['UserProfileResource'][_0xd998('0x40')]({'where':{'type':_0x14cd96,'resourceId':_0x17d864['id']},'transaction':_0x7ac619})[_0xd998('0x31')](function(){return _0x26f9b3;});})[_0xd998('0x31')](function(){_0x5ba543[_0xd998('0x1b')](0xcc)[_0xd998('0x1c')]();});}};}function handleEntityNotFound(_0x50fb5d){return function(_0x5c8c35){if(!_0x5c8c35){_0x50fb5d[_0xd998('0x1a')](0x194);}return _0x5c8c35;};}function handleError(_0x52a0fd,_0x4ceb82){_0x4ceb82=_0x4ceb82||0x1f4;return function(_0xf82346){logger[_0xd998('0x2b')](_0xf82346['stack']);if(_0xf82346[_0xd998('0x3f')]){delete _0xf82346['name'];}_0x52a0fd[_0xd998('0x1b')](_0x4ceb82)[_0xd998('0x41')](_0xf82346);};}function getUserAttributes(){return _(db['User'][_0xd998('0x42')])['map'](function(_0x2dc21d){return{'name':_0x2dc21d[_0xd998('0x43')],'type':_0x2dc21d[_0xd998('0x44')][_0xd998('0x45')]};})[_0xd998('0x46')](function(_0x5c2571){return!['password',_0xd998('0x47'),_0xd998('0x48'),_0xd998('0x49'),'resetPasswordExpires',_0xd998('0x4a')][_0xd998('0x4b')](_0x5c2571[_0xd998('0x3f')]);})[_0xd998('0x3d')]();}exports[_0xd998('0x4c')]=function(_0x280cdc,_0x5428a3){var _0x33bea9={},_0x373178={'count':0x0,'rows':[]};var _0x5bc268=getUserAttributes();_0x33bea9=qs['getOptions'](_0x5bc268,_0x280cdc);var _0x279122={'where':_0x33bea9[_0xd998('0x4d')]};return db['User'][_0xd998('0x21')](_0x279122)[_0xd998('0x31')](function(_0x5d51c1){_0x373178['count']=_0x5d51c1;if(_0x280cdc['query']['includeAll']){_0x33bea9[_0xd998('0x4e')]=[{'all':!![]}];}if(_0x280cdc[_0xd998('0x4f')][_0xd998('0x50')]===_0xd998('0x51')){_0x33bea9[_0xd998('0x4e')]=[{'model':db[_0xd998('0x52')],'as':_0xd998('0x50')}];}if(!_[_0xd998('0x4b')](_0x33bea9['attributes'],'id')){_0x33bea9['attributes'][_0xd998('0x53')]('id');}return db[_0xd998('0x54')][_0xd998('0x55')](_0x33bea9);})[_0xd998('0x31')](function(_0x10c0d3){_0x373178[_0xd998('0x56')]=_0x10c0d3;if(_0x280cdc[_0xd998('0x4f')][_0xd998('0x57')]===_0xd998('0x51')){var _0x4085c0=[];for(var _0x4396d2=0x0;_0x4396d2<_0x373178[_0xd998('0x56')]['length'];_0x4396d2++){_0x4085c0[_0xd998('0x53')](get_open_tabs(_0xd998('0x58'),_0x373178[_0xd998('0x56')][_0x4396d2][_0xd998('0x59')]));_0x4085c0[_0xd998('0x53')](get_open_tabs('sms',_0x373178[_0xd998('0x56')][_0x4396d2][_0xd998('0x59')]));_0x4085c0[_0xd998('0x53')](get_open_tabs(_0xd998('0x5a'),_0x373178[_0xd998('0x56')][_0x4396d2]['dataValues']));_0x4085c0['push'](get_open_tabs(_0xd998('0x5b'),_0x373178[_0xd998('0x56')][_0x4396d2]['dataValues']));_0x4085c0[_0xd998('0x53')](get_open_tabs(_0xd998('0x5c'),_0x373178[_0xd998('0x56')][_0x4396d2][_0xd998('0x59')]));_0x4085c0['push'](get_open_tabs(_0xd998('0x5d'),_0x373178[_0xd998('0x56')][_0x4396d2][_0xd998('0x59')]));}return Promise['all'](_0x4085c0)[_0xd998('0x31')](function(){return _0x373178;});}else{return _0x373178;}})['then'](respondWithFilteredResult(_0x5428a3,_0x33bea9))[_0xd998('0x2f')](handleError(_0x5428a3,null));};exports[_0xd998('0x5e')]=function(_0x4c55c4,_0x316ca4){var _0xacf418=getUserAttributes();_0x4c55c4[_0xd998('0x4f')]['id']=_0x4c55c4[_0xd998('0x5f')]['id'];var _0xe01122=qs[_0xd998('0x60')](_0xacf418,_0x4c55c4);if(_0x4c55c4[_0xd998('0x4f')][_0xd998('0x61')]){_0xe01122['include']=[{'all':!![]}];}if(_0x4c55c4[_0xd998('0x4f')][_0xd998('0x50')]==='true'){_0xe01122[_0xd998('0x4e')]=[{'model':db[_0xd998('0x52')],'as':_0xd998('0x50')}];}_0xe01122=_['merge']({},_0xe01122,_0x4c55c4[_0xd998('0x62')]);if(!_['includes'](_0xe01122[_0xd998('0x63')],'id')){_0xe01122['attributes'][_0xd998('0x53')]('id');}return db[_0xd998('0x54')][_0xd998('0x3e')](_0xe01122)['then'](handleEntityNotFound(_0x316ca4,null))['then'](function(_0x283c85){var _0x545964=[];values=_0x283c85;if(_0x4c55c4[_0xd998('0x4f')]['openTabs']===_0xd998('0x51')){_0x545964[_0xd998('0x53')](get_open_tabs(_0xd998('0x58'),_0x283c85[_0xd998('0x59')]));_0x545964['push'](get_open_tabs(_0xd998('0x64'),_0x283c85[_0xd998('0x59')]));_0x545964[_0xd998('0x53')](get_open_tabs('openchannel',_0x283c85[_0xd998('0x59')]));_0x545964[_0xd998('0x53')](get_open_tabs(_0xd998('0x5d'),_0x283c85[_0xd998('0x59')]));_0x545964['push'](get_open_tabs('fax',_0x283c85['dataValues']));_0x545964[_0xd998('0x53')](get_open_tabs(_0xd998('0x5b'),_0x283c85['dataValues']));return Promise[_0xd998('0x65')](_0x545964);}else{return values;}})[_0xd998('0x31')](function(){return values;})[_0xd998('0x31')](respondWithResult(_0x316ca4,null))[_0xd998('0x2f')](handleError(_0x316ca4,null));};exports[_0xd998('0x30')]=function(_0x590e2b,_0xb9c128){if(_0x590e2b[_0xd998('0x66')]['id']){delete _0x590e2b[_0xd998('0x66')]['id'];}delete _0x590e2b[_0xd998('0x66')][_0xd998('0x32')];return db['User'][_0xd998('0x3e')]({'where':{'id':_0x590e2b[_0xd998('0x5f')]['id']}})[_0xd998('0x31')](handleEntityNotFound(_0xb9c128,null))[_0xd998('0x31')](saveUpdates(_0x590e2b[_0xd998('0x66')],null))[_0xd998('0x31')](respondWithResult(_0xb9c128,null))[_0xd998('0x2f')](handleError(_0xb9c128,null));};exports[_0xd998('0x67')]=function(_0x3efab1,_0xbe8ac2){return db[_0xd998('0x54')][_0xd998('0x67')]()[_0xd998('0x31')](respondWithResult(_0xbe8ac2,null))[_0xd998('0x2f')](handleError(_0xbe8ac2,null));};exports[_0xd998('0x68')]=function(_0x5f2a80,_0xe002ba){return db[_0xd998('0x54')][_0xd998('0x3e')]({'where':{'id':_0x5f2a80[_0xd998('0x5f')]['id']}})[_0xd998('0x31')](handleEntityNotFound(_0xe002ba,null))[_0xd998('0x31')](function(_0x5e8522){if(_0x5e8522){return _0x5e8522[_0xd998('0x68')](_0x5f2a80[_0xd998('0x66')]['ids'],_[_0xd998('0x69')](_0x5f2a80[_0xd998('0x66')],['ids','id'])||{});}})[_0xd998('0x31')](respondWithResult(_0xe002ba,null))[_0xd998('0x2f')](handleError(_0xe002ba,null));};function validateUser(_0x34e73b){return new Promise(function(_0x5c980f,_0x5dc631){if(_0x34e73b[_0xd998('0x6a')])return _0x5c980f(_0x34e73b);return db[_0xd998('0x6b')][_0xd998('0x6c')](0x1)[_0xd998('0x31')](function(_0x43f4ff){if(_0x43f4ff[_0xd998('0x6d')])authService['validatePasswordPattern'](_0x34e73b[_0xd998('0x6e')]);db[_0xd998('0x54')][_0xd998('0x6f')](_0xd998('0x6a'))['then'](function(_0x3b6efd){if(_['isNil'](_0x3b6efd)){_0x34e73b['internal']=_0x43f4ff[_0xd998('0x70')]||0x1;return;}if(_[_0xd998('0x71')](_0x43f4ff['min_internal'])||_0x43f4ff[_0xd998('0x70')]===_0x3b6efd){_0x34e73b['internal']=_0x3b6efd+0x1;return;}if(_0x43f4ff[_0xd998('0x70')]>_0x3b6efd){_0x34e73b['internal']=_0x43f4ff['min_internal'];return;}return db[_0xd998('0x72')][_0xd998('0x4f')](_0xd998('0x73'),{'type':db['sequelize'][_0xd998('0x74')][_0xd998('0x75')]})[_0xd998('0x31')](function(_0x4cd984){if(_0x4cd984&&_0x4cd984['length']){for(var _0x27e3f8=0x0,_0x2a58ea=_0x4cd984['length'];_0x27e3f8<_0x2a58ea&&_[_0xd998('0x71')](_0x34e73b[_0xd998('0x6a')]);_0x27e3f8++){if(_0x43f4ff['min_internal']<=_0x4cd984[_0x27e3f8]['from']){_0x34e73b[_0xd998('0x6a')]=_0x4cd984[_0x27e3f8][_0xd998('0x76')];}else if(_0x43f4ff[_0xd998('0x70')]>_0x4cd984[_0x27e3f8][_0xd998('0x76')]&&_0x43f4ff[_0xd998('0x70')]<=_0x4cd984[_0x27e3f8]['to']){_0x34e73b[_0xd998('0x6a')]=_0x43f4ff[_0xd998('0x70')];}}}if(_[_0xd998('0x71')](_0x34e73b[_0xd998('0x6a')])){_0x34e73b[_0xd998('0x6a')]=_0x3b6efd+0x1;}return _0x5c980f(_0x34e73b);});});})[_0xd998('0x2f')](function(_0x888f83){_0x5dc631(_0x888f83);});});}function updateUser(_0x13cd09){return new Promise(function(_0x3c57f4,_0x35d49e){try{if(_0x13cd09[_0xd998('0x77')]){_0x13cd09[_0xd998('0x78')]=_0x13cd09[_0xd998('0x6a')];_0x13cd09[_0xd998('0x79')]={'mailbox':_0x13cd09[_0xd998('0x6a')],'password':_0x13cd09[_0xd998('0x6e')],'fullname':_0x13cd09[_0xd998('0x7a')],'email':_0x13cd09[_0xd998('0x7b')]};}if(_0x13cd09[_0xd998('0x32')]===_0xd998('0x33')){if(!_0x13cd09[_0xd998('0x7c')])_0x13cd09[_0xd998('0x7c')]=[_0xd998('0x7d'),_0xd998('0x7e'),_0xd998('0x7f'),_0xd998('0x80'),_0xd998('0x81'),_0xd998('0x82'),_0xd998('0x83'),'106',_0xd998('0x84'),'108',_0xd998('0x85'),'100','111',_0xd998('0x86'),_0xd998('0x87')];}_0x3c57f4(_0x13cd09);}catch(_0x637b9d){_0x35d49e(_0x637b9d);}});}exports[_0xd998('0x88')]=function(_0xa0279c,_0x3bc0b5){if(_0xa0279c[_0xd998('0x37')][_0xd998('0x32')]===_0xd998('0x33'))throw new Error(_0xd998('0x89'));if(_0xa0279c[_0xd998('0x66')]['role']===_0xd998('0x37')&&_0xa0279c[_0xd998('0x37')][_0xd998('0x32')]!==_0xd998('0x35')){throw new Error(_0xd998('0x8a'));}if(_0xa0279c[_0xd998('0x66')][_0xd998('0x32')]==='admin'&&_0xa0279c[_0xd998('0x37')]['role']!==_0xd998('0x35')){throw new Error(_0xd998('0x8b'));}return licenseUtil['checkUserLimits']([_0xa0279c[_0xd998('0x66')]])['then'](function(){return validateUser(_0xa0279c[_0xd998('0x66')]);})['then'](function(_0x1a12f3){return updateUser(_0x1a12f3)[_0xd998('0x31')](function(_0x541a5e){if(_0x541a5e[_0xd998('0x32')]===_0xd998('0x35')){_0x541a5e['settingsEnabled']=_0xa0279c[_0xd998('0x37')][_0xd998('0x8c')];delete _0x541a5e['userProfileId'];}return _0x541a5e;});})[_0xd998('0x31')](function(_0xb38063){return db[_0xd998('0x54')][_0xd998('0x88')](_0xb38063,{'include':[{'model':db['VoiceMail'],'as':_0xd998('0x79')}]});})['then'](function(_0x6277c2){if(_0xa0279c[_0xd998('0x66')][_0xd998('0x32')]==='user')return _0x6277c2;if(_0xa0279c[_0xd998('0x37')][_0xd998('0x32')]!==_0xd998('0x37'))return _0x6277c2;return db[_0xd998('0x8d')]['find']({'where':{'name':_0x6277c2[_0xd998('0x32')]==='agent'?_0xd998('0x38'):'Telephones','userProfileId':_0xa0279c[_0xd998('0x37')][_0xd998('0x8e')]},'raw':!![]})[_0xd998('0x31')](function(_0x4b3f92){if(!_0x4b3f92||_0x4b3f92[_0xd998('0x8f')]!=0x0)return _0x6277c2;return db[_0xd998('0x90')][_0xd998('0x88')]({'name':_0x6277c2['name'],'resourceId':_0x6277c2['id'],'type':_0x4b3f92[_0xd998('0x3f')],'sectionId':_0x4b3f92['id']},{})[_0xd998('0x31')](function(){return _0x6277c2;});})['catch'](function(_0x4fd0d1){logger[_0xd998('0x2b')](_0xd998('0x91'),_0x4fd0d1);throw _0x4fd0d1;});})[_0xd998('0x31')](respondWithResult(_0x3bc0b5,0xc9))['catch'](handleError(_0x3bc0b5,null));};exports['bulkCreate']=function(_0x3eec46,_0x19f86f){var _0x455f9a=_0x3eec46['body'];var _0x4fd47e=[];if(_0x3eec46['user'][_0xd998('0x32')]===_0xd998('0x33'))throw new Error(_0xd998('0x89'));if(_['some'](_0x455f9a,['role',_0xd998('0x37')])&&_0x3eec46[_0xd998('0x37')][_0xd998('0x32')]!==_0xd998('0x35')){throw new Error(_0xd998('0x8a'));}if(_[_0xd998('0x92')](_0x455f9a,[_0xd998('0x32'),_0xd998('0x35')])&&_0x3eec46['user']['role']!=='admin'){throw new Error(_0xd998('0x93'));}return licenseUtil['checkUserLimits'](_0x455f9a)[_0xd998('0x31')](function(){return validateUser(_0x455f9a[0x0]);})['then'](function(){for(var _0xe4ecbf=0x1;_0xe4ecbf<_0x455f9a[_0xd998('0x94')];_0xe4ecbf++){var _0x17817e=_0x455f9a[_0xe4ecbf-0x1][_0xd998('0x6a')];if(!_0x455f9a[_0xe4ecbf][_0xd998('0x6a')])_0x455f9a[_0xe4ecbf][_0xd998('0x6a')]=_0x17817e+0x1;_0x4fd47e['push'](validateUser(_0x455f9a[_0xe4ecbf]));}return Promise[_0xd998('0x65')](_0x4fd47e);})['then'](function(){_0x4fd47e=[];for(var _0x2cf054=0x0;_0x2cf054<_0x455f9a[_0xd998('0x94')];_0x2cf054++){_0x4fd47e[_0xd998('0x53')](updateUser(_0x455f9a[_0x2cf054]));}return Promise['all'](_0x4fd47e);})['then'](function(){_0x4fd47e=_0x455f9a[_0xd998('0x3c')](function(_0x72c143){return db[_0xd998('0x54')]['create'](_0x72c143,{'include':[{'model':db[_0xd998('0x79')],'as':_0xd998('0x79')}]})[_0xd998('0x31')](function(_0x5384c9){_0x72c143['id']=_0x5384c9['id'];return _0x72c143;});});return Promise[_0xd998('0x65')](_0x4fd47e);})['then'](function(_0x1c920f){if(_0x3eec46[_0xd998('0x66')][_0xd998('0x32')]===_0xd998('0x37'))return _0x1c920f;if(_0x3eec46['user'][_0xd998('0x32')]!==_0xd998('0x37'))return _0x1c920f;var _0x3550a4=_[_0xd998('0x92')](_0x1c920f,function(_0x13afd1){return _0x13afd1['role']===_0xd998('0x33')||_0x13afd1[_0xd998('0x32')]===_0xd998('0x3a');});if(!_0x3550a4)return _0x1c920f;return db[_0xd998('0x8d')][_0xd998('0x55')]({'where':{'name':{'$or':['Agents','Telephones']},'userProfileId':_0x3eec46[_0xd998('0x37')][_0xd998('0x8e')]},'raw':!![]})['then'](function(_0x1c3958){if(_[_0xd998('0x95')](_0x1c3958)||!_[_0xd998('0x92')](_0x1c3958,[_0xd998('0x8f'),0x0]))return _0x1c920f;_0x4fd47e=[];var _0x415d1e=_(_0x1c3958)[_0xd998('0x3c')](function(_0x46472c){if(_0x46472c[_0xd998('0x8f')]===0x1)return;return _0x46472c[_0xd998('0x3f')]===_0xd998('0x38')?_0xd998('0x33'):_0xd998('0x3a');})[_0xd998('0x96')]()['value']();for(var _0x230781=0x0;_0x230781<_0x1c920f['length'];_0x230781++){if(!_[_0xd998('0x4b')](_0x415d1e,_0x1c920f[_0x230781][_0xd998('0x32')]))return;var _0x314a33=_0x1c920f[_0x230781][_0xd998('0x32')]===_0xd998('0x33')?_0xd998('0x38'):'Telephones';_0x4fd47e['push'](db['UserProfileResource'][_0xd998('0x88')]({'name':_0x1c920f[_0x230781][_0xd998('0x3f')],'resourceId':_0x1c920f[_0x230781]['id'],'type':_0x314a33,'sectionId':_['find'](_0x1c3958,[_0xd998('0x3f'),_0x314a33])['id']},{}));}return Promise['all'](_0x4fd47e);});})['then'](respondWithResult(_0x19f86f,0xc9))[_0xd998('0x2f')](handleError(_0x19f86f,null));};exports[_0xd998('0x97')]=function(_0x5baffc,_0x222f0c){if(_0x5baffc['body']['id']){delete _0x5baffc[_0xd998('0x66')]['id'];}return db[_0xd998('0x54')][_0xd998('0x3e')]({'where':{'id':_0x5baffc[_0xd998('0x5f')]['id']}})['then'](function(_0x2c9e9e){if(!_0x2c9e9e)return null;if(_0x2c9e9e['id']===_0x5baffc['user']['id']){if(!_0x5baffc[_0xd998('0x66')][_0xd998('0x98')]||!_0x5baffc[_0xd998('0x66')][_0xd998('0x99')]){throw new db[(_0xd998('0x9a'))][(_0xd998('0x9b'))]('Invalid\x20body\x20format.\x20Use\x20oldPassword\x20and\x20newPassword');}if(!_0x2c9e9e['authenticate'](_0x5baffc[_0xd998('0x66')][_0xd998('0x98')])){throw new db[(_0xd998('0x9a'))][(_0xd998('0x9b'))](_0xd998('0x9c'));}if(_0x5baffc['body'][_0xd998('0x98')]===_0x5baffc[_0xd998('0x66')][_0xd998('0x99')]){throw new db[(_0xd998('0x9a'))]['ValidationError']('New\x20password\x20must\x20be\x20different\x20from\x20old\x20password');}}else if(_0x5baffc[_0xd998('0x37')][_0xd998('0x32')]==='admin'){if(!_0x5baffc[_0xd998('0x66')][_0xd998('0x99')]){throw new db['Sequelize'][(_0xd998('0x9b'))]('Invalid\x20body\x20format.\x20Use\x20newPassword');}}else if(_0x5baffc['user'][_0xd998('0x32')]===_0xd998('0x37')){if(!_0x5baffc[_0xd998('0x66')][_0xd998('0x99')]){throw new db['Sequelize']['ValidationError'](_0xd998('0x9d'));}if(_0x2c9e9e[_0xd998('0x32')]!==_0xd998('0x33')){throw new db[(_0xd998('0x9a'))][(_0xd998('0x9b'))]('Unauthorized');}}else{throw new db[(_0xd998('0x9a'))][(_0xd998('0x9b'))]('Unauthorized');}return _0x2c9e9e;})[_0xd998('0x31')](handleEntityNotFound(_0x222f0c,null))['then'](function(_0x175698){return db[_0xd998('0x6b')][_0xd998('0x9e')]({'attributes':['id',_0xd998('0x6d'),_0xd998('0x9f'),_0xd998('0xa0')]})['then'](function(_0x13642e){if(_0x13642e['securePassword'])authService[_0xd998('0xa1')](_0x5baffc[_0xd998('0x66')]['newPassword']);if(!_0x13642e[_0xd998('0x9f')]||!_0x175698['previousPasswords'])return _0x175698;authService[_0xd998('0xa2')](_0x5baffc[_0xd998('0x66')][_0xd998('0x99')],_0x175698[_0xd998('0x48')],_0x13642e['passwordHistoryLimit']);return _0x175698;})[_0xd998('0x31')](saveUpdates({'password':_0x5baffc['body']['newPassword'],'passwordResetAt':_0x5baffc[_0xd998('0x37')]['id']==_0x5baffc['params']['id']?moment():null,'previousPasswords':authService['updatePasswordsHistory'](_0x5baffc['body'][_0xd998('0x99')],_0x175698[_0xd998('0x48')])},null));})[_0xd998('0x31')](respondWithResult(_0x222f0c,null))['catch'](handleError(_0x222f0c,null));};exports[_0xd998('0xa3')]=function(_0x3907e2,_0x2c3125){var _0x270797=_0x3907e2['body'][_0xd998('0xa4')];return db[_0xd998('0x54')][_0xd998('0x3e')]({'where':{'id':_0x3907e2[_0xd998('0x5f')]['id']},'attributes':['id',_0xd998('0x3f'),_0xd998('0x32'),_0xd998('0xa5'),_0xd998('0xa6'),'voicePause',_0xd998('0xa7')]})['then'](handleEntityNotFound(_0x2c3125,null))[_0xd998('0x31')](function(_0x3a0030){if(_0x3a0030){if(!utils[_0xd998('0xa8')](_0x270797)){throw new db[(_0xd998('0x9a'))][(_0xd998('0x9b'))](_0xd998('0xa9'));}return _0x3a0030['add'+_['capitalize'](_0x270797[_0xd998('0xaa')]())+_0xd998('0xab')](_0x3907e2[_0xd998('0x66')][_0xd998('0xac')],{'penalty':_0x3907e2[_0xd998('0x66')][_0xd998('0xad')]||0x0})[_0xd998('0xae')](function(_0x57ac84){for(var _0x5541a7=0x0;_0x5541a7<_0x3907e2[_0xd998('0x66')]['ids']['length'];_0x5541a7+=0x1){var _0x80a861={'UserId':Number(_0x3907e2[_0xd998('0x5f')]['id'])};_0x80a861[_[_0xd998('0xaf')](_0x270797['toLowerCase']())+_0xd998('0xb0')]=Number(_0x3907e2[_0xd998('0x66')][_0xd998('0xac')][_0x5541a7]);socket[_0xd998('0x34')](_0xd998('0x37')+_['capitalize'](_0x270797[_0xd998('0xaa')]())+_0xd998('0xb1'),_0x80a861);}return _0x57ac84;})[_0xd998('0x31')](function(){if(_0x270797==='voice'){return db[_0xd998('0xb2')][_0xd998('0x55')]({'where':{'id':_0x3907e2[_0xd998('0x66')][_0xd998('0xac')]||[]},'raw':!![],'attributes':['id','name']});}})['then'](function(_0x199a25){var _0x13ad32=_0x3a0030[_0xd998('0xb3')]({'plain':!![]});var _0x3d052d=[];if(_0x270797===_0xd998('0xb4')&&_0x13ad32['role']===_0xd998('0x33')&&_0x13ad32[_0xd998('0xa5')]){for(let _0x20f756=0x0;_0x20f756<_0x199a25[_0xd998('0x94')];_0x20f756+=0x1){_0x3d052d['push']({'membername':_0x13ad32['name'],'UserId':_0x13ad32['id'],'queue_name':_0x199a25[_0x20f756][_0xd998('0x3f')],'VoiceQueueId':_0x199a25[_0x20f756]['id'],'interface':_[_0xd998('0x71')](_0x13ad32['interface'])?util['format'](_0xd998('0xb5'),_0x13ad32['name']):_0x13ad32[_0xd998('0xa7')],'paused':_0x13ad32[_0xd998('0xb6')]||![],'penalty':_0x3907e2[_0xd998('0x66')][_0xd998('0xad')]||0x0});}return Promise[_0xd998('0x65')](_0x3d052d['map'](function(_0x328c2b){return db[_0xd998('0xb7')][_0xd998('0xb8')](_0x328c2b);}));}return _0x3a0030;});}})[_0xd998('0x31')](respondWithStatusCode(_0x2c3125,null))[_0xd998('0x2f')](handleError(_0x2c3125,null));};exports[_0xd998('0xb9')]=function(_0x15e0f9,_0x50a773){var _0xddd9b5,_0x350ad0;return db[_0xd998('0x54')][_0xd998('0x3e')]({'where':{'id':_0x15e0f9[_0xd998('0x5f')]['id']},'attributes':['id',_0xd998('0x3f'),'role']})['then'](handleEntityNotFound(_0x50a773,null))[_0xd998('0x31')](function(_0x1dd644){if(_0x1dd644){_0xddd9b5=_0x1dd644;if(!_0x15e0f9['query'][_0xd998('0xa4')]||!utils[_0xd998('0xa8')](_0x15e0f9[_0xd998('0x4f')][_0xd998('0xa4')])){throw new db[(_0xd998('0x9a'))]['ValidationError']('Unknown\x20channel');}return _0x1dd644[_0xd998('0xba')+_[_0xd998('0xaf')](_0x15e0f9[_0xd998('0x4f')]['channel'][_0xd998('0xaa')]())+'Queues'](_0x15e0f9['query'][_0xd998('0xac')]);}})[_0xd998('0x31')](function(_0x241d81){if(_[_0xd998('0xbb')](_0x15e0f9[_0xd998('0x4f')][_0xd998('0xac')])){for(var _0x304213=0x0;_0x304213<_0x15e0f9['query'][_0xd998('0xac')][_0xd998('0x94')];_0x304213+=0x1){_0x350ad0={'UserId':Number(_0x15e0f9['params']['id'])};_0x350ad0[_['capitalize'](_0x15e0f9[_0xd998('0x4f')][_0xd998('0xa4')][_0xd998('0xaa')]())+_0xd998('0xb0')]=Number(_0x15e0f9[_0xd998('0x4f')][_0xd998('0xac')][_0x304213]);socket[_0xd998('0x34')]('user'+_['capitalize'](_0x15e0f9[_0xd998('0x4f')][_0xd998('0xa4')][_0xd998('0xaa')]())+_0xd998('0xbc'),_0x350ad0);}}else{_0x350ad0={'UserId':Number(_0x15e0f9['params']['id'])};_0x350ad0[_[_0xd998('0xaf')](_0x15e0f9['query'][_0xd998('0xa4')][_0xd998('0xaa')]())+_0xd998('0xb0')]=Number(_0x15e0f9[_0xd998('0x4f')]['ids']);socket['emit']('user'+_[_0xd998('0xaf')](_0x15e0f9[_0xd998('0x4f')][_0xd998('0xa4')][_0xd998('0xaa')]())+_0xd998('0xbc'),_0x350ad0);}return _0x241d81;})[_0xd998('0x31')](function(){if(_0x15e0f9[_0xd998('0x4f')][_0xd998('0xa4')]===_0xd998('0xb4')){return db[_0xd998('0xb7')][_0xd998('0x40')]({'where':{'UserId':_0x15e0f9['params']['id'],'VoiceQueueId':_0x15e0f9[_0xd998('0x4f')][_0xd998('0xac')]},'individualHooks':!![]})[_0xd998('0x31')](function(){return _0xddd9b5;});}return _0xddd9b5;})[_0xd998('0x31')](respondWithStatusCode(_0x50a773,null))['catch'](handleError(_0x50a773,null));};exports[_0xd998('0xbd')]=function(_0x410b61,_0x131a51){_0x410b61[_0xd998('0x66')][_0xd998('0xbe')]=_0x410b61[_0xd998('0xbf')]['filename'];return db['User'][_0xd998('0x3e')]({'where':{'id':_0x410b61[_0xd998('0x5f')]['id']}})[_0xd998('0x31')](handleEntityNotFound(_0x131a51,null))[_0xd998('0x31')](saveUpdates(_0x410b61[_0xd998('0x66')],null))[_0xd998('0x31')](respondWithResult(_0x131a51,null))[_0xd998('0x2f')](handleError(_0x131a51,null));};exports['getAvatar']=function(_0x1ae11a,_0x564be6){var _0x46e0a4=path[_0xd998('0xc0')](config['root'],'server/files/images/logos/default_profile.png');return db[_0xd998('0x54')]['find']({'where':{'id':_0x1ae11a[_0xd998('0x5f')]['id']},'attributes':['id',_0xd998('0xbe')],'raw':!![]})[_0xd998('0x31')](handleEntityNotFound(_0x564be6,null))['then'](function(_0xe6087f){if(_0xe6087f){if(_[_0xd998('0x71')](_0xe6087f[_0xd998('0xbe')])){return _0x564be6['download'](_0x46e0a4);}else{if(!fs['existsSync'](path[_0xd998('0xc0')](config[_0xd998('0xc1')],_0xd998('0xc2'),_0xe6087f[_0xd998('0xbe')]))){return _0x564be6['download'](_0x46e0a4);}return _0x564be6[_0xd998('0xc3')](path['join'](config[_0xd998('0xc1')],_0xd998('0xc2'),_0xe6087f[_0xd998('0xbe')]));}}})[_0xd998('0x2f')](handleError(_0x564be6,null));};exports[_0xd998('0xc4')]=function(_0x362463,_0x33887c){return db[_0xd998('0x54')][_0xd998('0x3e')]({'where':{'id':_0x362463['params']['id']},'attributes':['id']})['then'](handleEntityNotFound(_0x33887c,null))[_0xd998('0x31')](function(_0x168000){var _0x28a389=[];values=_0x168000[_0xd998('0x59')];_0x28a389[_0xd998('0x53')](get_open_tabs(_0xd998('0x58'),_0x168000[_0xd998('0x59')]));_0x28a389[_0xd998('0x53')](get_open_tabs(_0xd998('0x64'),_0x168000[_0xd998('0x59')]));_0x28a389[_0xd998('0x53')](get_open_tabs(_0xd998('0x5c'),_0x168000[_0xd998('0x59')]));_0x28a389[_0xd998('0x53')](get_open_tabs('whatsapp',_0x168000['dataValues']));_0x28a389['push'](get_open_tabs(_0xd998('0x5a'),_0x168000['dataValues']));_0x28a389[_0xd998('0x53')](get_open_tabs(_0xd998('0x5b'),_0x168000[_0xd998('0x59')]));return Promise['all'](_0x28a389);})[_0xd998('0x31')](function(_0x5b872b){if(_0x5b872b){var _0x1fc1dd=_[_0xd998('0x3c')](values[_0xd998('0xc5')],function(_0x149f99){return{'channel':_0xd998('0xc6'),'id':_0x149f99['id'],'createdAt':_0x149f99['createdAt']};});var _0x1af69a=_[_0xd998('0x3c')](values['FaxOpenTabs'],function(_0x2d42a6){return{'channel':_0xd998('0xc7'),'id':_0x2d42a6['id'],'createdAt':_0x2d42a6[_0xd998('0xc8')]};});var _0x26f981=_['map'](values[_0xd998('0xc9')],function(_0x16c540){return{'channel':'OPENCHANNEL','id':_0x16c540['id'],'createdAt':_0x16c540[_0xd998('0xc8')]};});var _0x5e5363=_['map'](values[_0xd998('0xca')],function(_0x424480){return{'channel':_0xd998('0xcb'),'id':_0x424480['id'],'createdAt':_0x424480[_0xd998('0xc8')]};});var _0x3158a9=_[_0xd998('0x3c')](values[_0xd998('0xcc')],function(_0x35a43a){return{'channel':_0xd998('0xcd'),'id':_0x35a43a['id'],'createdAt':_0x35a43a['createdAt']};});var _0x27eccd=_[_0xd998('0x3c')](values[_0xd998('0xce')],function(_0x266871){return{'channel':_0xd998('0xcf'),'id':_0x266871['id'],'createdAt':_0x266871[_0xd998('0xc8')]};});var _0x178079=_[_0xd998('0xd0')](_0x1fc1dd,_0x1af69a,_0x26f981,_0x5e5363,_0x3158a9,_0x27eccd);var _0x26fa7d={'count':_0x178079[_0xd998('0x94')],'rows':_0x178079};return _0x26fa7d;}else return null;})[_0xd998('0x31')](respondWithResult(_0x33887c,null))[_0xd998('0x2f')](handleError(_0x33887c,null));};exports['getContacts']=function(_0x20f3a9,_0xfd4a3e){var _0x205554={};return db['User']['findOne']({'where':{'id':_0x20f3a9[_0xd998('0x5f')]['id']}})[_0xd998('0x31')](function(_0xfa9ce0){if(!_0xfa9ce0){throw new APINotFoundError(util[_0xd998('0xd1')]('User\x20with\x20id\x20%s\x20not\x20found',_0x20f3a9['params']['id']));}return contacts[_0xd998('0x67')]();})[_0xd998('0x31')](function(_0x4e11d6){_0x20f3a9[_0xd998('0x4f')]['User']=_0x20f3a9[_0xd998('0x5f')]['id'];_0x205554=qs[_0xd998('0x60')](_0x4e11d6,_0x20f3a9);if(_0x20f3a9[_0xd998('0x4f')][_0xd998('0xd2')](_0xd998('0x61'))){_0x205554[_0xd998('0x4e')]=[{'model':db['CmList'],'as':_0xd998('0xd3'),'required':![]},{'model':db[_0xd998('0xd4')],'as':_0xd998('0xd5'),'attributes':['id',_0xd998('0x3f'),'color'],'where':_0x20f3a9['query'][_0xd998('0xd6')]?{'id':_0x20f3a9['query'][_0xd998('0xd6')]}:undefined,'required':_0x20f3a9[_0xd998('0x4f')][_0xd998('0xd6')]?!![]:![]}];}return contacts['findAll'](_0x20f3a9[_0xd998('0x4f')],_0x20f3a9['user'],_0x205554,_0x4e11d6);})['then'](respondWithFilteredResult(_0xfd4a3e,_0x205554))['catch'](APIHandleError(_0xfd4a3e));};exports[_0xd998('0xd7')]=function(_0x5c6a49,_0x36476c){var _0x52f127;var _0xc77501={};var _0x117767;return db[_0xd998('0x54')][_0xd998('0x9e')]({'where':{'id':_0x5c6a49[_0xd998('0x5f')]['id']},'attributes':['id','name',_0xd998('0x32')]})[_0xd998('0x31')](handleEntityNotFound(_0x36476c,null))[_0xd998('0x31')](function(_0x1c5889){if(!utils[_0xd998('0xa8')](_0x5c6a49[_0xd998('0x4f')][_0xd998('0xa4')])){throw new db['Sequelize']['ValidationError'](_0xd998('0xa9'));}_0x52f127=_0x1c5889;var _0x1ac6c4={};_0x1ac6c4['model']=_[_0xd998('0xd8')](db[_['capitalize'](_0x5c6a49[_0xd998('0x4f')][_0xd998('0xa4')])+_0xd998('0xd9')][_0xd998('0x42')]);_0x1ac6c4['query']=_[_0xd998('0xd8')](_0x5c6a49['query']);_0x1ac6c4[_0xd998('0xda')]=_[_0xd998('0xdb')](_0x1ac6c4[_0xd998('0xdc')],_0x1ac6c4[_0xd998('0x4f')]);_0xc77501['attributes']=_['intersection'](_0x1ac6c4[_0xd998('0xdc')],qs[_0xd998('0xdd')](_0x5c6a49[_0xd998('0x4f')][_0xd998('0xdd')]));_0xc77501['attributes']=_0xc77501[_0xd998('0x63')]['length']?_0xc77501[_0xd998('0x63')]:_0x1ac6c4[_0xd998('0xdc')];_0xc77501[_0xd998('0xde')]=qs[_0xd998('0xdf')](_0x5c6a49[_0xd998('0x4f')][_0xd998('0xdf')]);_0xc77501[_0xd998('0x4d')]=qs[_0xd998('0xda')](_['pick'](_0x5c6a49[_0xd998('0x4f')],_0x1ac6c4[_0xd998('0xda')]));if(_0x5c6a49[_0xd998('0x4f')][_0xd998('0x46')]){_0xc77501['where']=_[_0xd998('0xe0')](_0xc77501[_0xd998('0x4d')],{'$or':_[_0xd998('0x3c')](_0xc77501[_0xd998('0x63')],function(_0x201aba){var _0x19cf56={};_0x19cf56[_0x201aba]={'$like':'%'+_0x5c6a49[_0xd998('0x4f')][_0xd998('0x46')]+'%'};return _0x19cf56;})});}_0xc77501=_[_0xd998('0xe0')]({},_0xc77501,_0x5c6a49[_0xd998('0x62')]);switch(_0x52f127[_0xd998('0x32')]){case _0xd998('0x35'):return db[_[_0xd998('0xaf')](_0x5c6a49['query'][_0xd998('0xa4')])+_0xd998('0xd9')][_0xd998('0x55')](_0xc77501);case'user':case _0xd998('0x33'):return _0x52f127[_0xd998('0xb3')+_[_0xd998('0xaf')](_0x5c6a49[_0xd998('0x4f')][_0xd998('0xa4')])+_0xd998('0xab')](_0xc77501);default:throw new db['Sequelize'][(_0xd998('0x9b'))](_0xd998('0xe1'));}})[_0xd998('0x31')](function(_0x3a6745){_0x117767=_0x3a6745[_0xd998('0x94')];if(!_0x5c6a49[_0xd998('0x4f')][_0xd998('0xd2')](_0xd998('0xe2'))){_0xc77501[_0xd998('0x20')]=qs[_0xd998('0x20')](_0x5c6a49['query'][_0xd998('0x20')]);_0xc77501[_0xd998('0x1e')]=qs[_0xd998('0x1e')](_0x5c6a49['query'][_0xd998('0x1e')]);}switch(_0x52f127['role']){case _0xd998('0x35'):return db[_[_0xd998('0xaf')](_0x5c6a49['query'][_0xd998('0xa4')])+_0xd998('0xd9')][_0xd998('0x55')](_0xc77501);case _0xd998('0x37'):case _0xd998('0x33'):return _0x52f127['get'+_[_0xd998('0xaf')](_0x5c6a49[_0xd998('0x4f')][_0xd998('0xa4')])+_0xd998('0xab')](_0xc77501);}})[_0xd998('0x31')](function(_0x5e1a6e){return{'count':_0x117767,'rows':_0x5e1a6e};})[_0xd998('0x31')](respondWithResult(_0x36476c,null))[_0xd998('0x2f')](handleError(_0x36476c,null));};exports[_0xd998('0xe3')]=function(_0xcff1ac,_0x2477eb){var _0x4dbfaa={};var _0x2cf86f={};var _0x5778aa;var _0x16a8f4;return db[_0xd998('0x54')][_0xd998('0x9e')]({'where':{'id':_0xcff1ac[_0xd998('0x5f')]['id']}})[_0xd998('0x31')](handleEntityNotFound(_0x2477eb,null))[_0xd998('0x31')](function(_0xdc33ed){if(_0xdc33ed){_0x5778aa=_0xdc33ed;_0x2cf86f[_0xd998('0xdc')]=_[_0xd998('0xd8')](db[_0xd998('0xb7')][_0xd998('0x42')]);_0x2cf86f[_0xd998('0x4f')]=_[_0xd998('0xd8')](_0xcff1ac['query']);_0x2cf86f['filters']=_[_0xd998('0xdb')](_0x2cf86f[_0xd998('0xdc')],_0x2cf86f['query']);_0x4dbfaa[_0xd998('0x63')]=_['intersection'](_0x2cf86f[_0xd998('0xdc')],qs['fields'](_0xcff1ac[_0xd998('0x4f')]['fields']));_0x4dbfaa[_0xd998('0x63')]=_0x4dbfaa[_0xd998('0x63')][_0xd998('0x94')]?_0x4dbfaa['attributes']:_0x2cf86f['model'];_0x4dbfaa[_0xd998('0xde')]=qs[_0xd998('0xdf')](_0xcff1ac[_0xd998('0x4f')][_0xd998('0xdf')]);_0x4dbfaa[_0xd998('0x4d')]=qs[_0xd998('0xda')](_[_0xd998('0xe4')](_0xcff1ac[_0xd998('0x4f')],_0x2cf86f[_0xd998('0xda')]));if(_0xcff1ac['query'][_0xd998('0x46')]){_0x4dbfaa['where']=_[_0xd998('0xe0')](_0x4dbfaa[_0xd998('0x4d')],{'$or':_[_0xd998('0x3c')](_0x4dbfaa['attributes'],function(_0x443cd0){var _0x1df3af={};_0x1df3af[_0x443cd0]={'$like':'%'+_0xcff1ac['query']['filter']+'%'};return _0x1df3af;})});}_0x4dbfaa=_[_0xd998('0xe0')]({},_0x4dbfaa,_0xcff1ac[_0xd998('0x62')]);return _0x5778aa[_0xd998('0xe3')](_0x4dbfaa);}})[_0xd998('0x31')](function(_0x4071a1){if(_0x4071a1){_0x16a8f4=_0x4071a1['length'];if(!_0xcff1ac[_0xd998('0x4f')][_0xd998('0xd2')]('nolimit')){_0x4dbfaa[_0xd998('0x20')]=qs[_0xd998('0x20')](_0xcff1ac[_0xd998('0x4f')][_0xd998('0x20')]);_0x4dbfaa[_0xd998('0x1e')]=qs['offset'](_0xcff1ac[_0xd998('0x4f')][_0xd998('0x1e')]);}return _0x5778aa[_0xd998('0xe3')](_0x4dbfaa);}})['then'](function(_0x152f8c){if(_0x152f8c){return _0x152f8c?{'count':_0x16a8f4,'rows':_0x152f8c}:null;}})[_0xd998('0x31')](respondWithResult(_0x2477eb,null))['catch'](handleError(_0x2477eb,null));};exports['getGroups']=function(_0x49333c,_0x318cc3){var _0x4885fb={};var _0x2577d={};var _0x29d012;var _0x3fa0db;return db[_0xd998('0x54')]['findOne']({'where':{'id':_0x49333c['params']['id']}})[_0xd998('0x31')](handleEntityNotFound(_0x318cc3,null))[_0xd998('0x31')](function(_0x3aedfc){if(_0x3aedfc){_0x29d012=_0x3aedfc;_0x2577d[_0xd998('0xdc')]=_[_0xd998('0xd8')](db[_0xd998('0xe5')][_0xd998('0x42')]);_0x2577d[_0xd998('0x4f')]=_[_0xd998('0xd8')](_0x49333c[_0xd998('0x4f')]);_0x2577d[_0xd998('0xda')]=_[_0xd998('0xdb')](_0x2577d[_0xd998('0xdc')],_0x2577d[_0xd998('0x4f')]);_0x4885fb[_0xd998('0x63')]=_['intersection'](_0x2577d[_0xd998('0xdc')],qs['fields'](_0x49333c['query'][_0xd998('0xdd')]));_0x4885fb[_0xd998('0x63')]=_0x4885fb['attributes']['length']?_0x4885fb[_0xd998('0x63')]:_0x2577d[_0xd998('0xdc')];_0x4885fb[_0xd998('0xde')]=qs['sort'](_0x49333c['query'][_0xd998('0xdf')]);_0x4885fb[_0xd998('0x4d')]=qs[_0xd998('0xda')](_[_0xd998('0xe4')](_0x49333c['query'],_0x2577d[_0xd998('0xda')]));if(_0x49333c['query'][_0xd998('0x46')]){_0x4885fb[_0xd998('0x4d')]=_[_0xd998('0xe0')](_0x4885fb[_0xd998('0x4d')],{'$or':_['map'](_0x4885fb['attributes'],function(_0x5b9661){var _0x4a2561={};_0x4a2561[_0x5b9661]={'$like':'%'+_0x49333c[_0xd998('0x4f')][_0xd998('0x46')]+'%'};return _0x4a2561;})});}_0x4885fb=_[_0xd998('0xe0')]({},_0x4885fb,_0x49333c['options']);return _0x29d012[_0xd998('0xe6')](_0x4885fb);}})['then'](function(_0x544bd4){if(_0x544bd4){_0x3fa0db=_0x544bd4[_0xd998('0x94')];if(!_0x49333c['query'][_0xd998('0xd2')]('nolimit')){_0x4885fb['limit']=qs['limit'](_0x49333c['query'][_0xd998('0x20')]);_0x4885fb[_0xd998('0x1e')]=qs[_0xd998('0x1e')](_0x49333c[_0xd998('0x4f')][_0xd998('0x1e')]);}return _0x29d012[_0xd998('0xe6')](_0x4885fb);}})[_0xd998('0x31')](function(_0x344921){if(_0x344921){return _0x344921?{'count':_0x3fa0db,'rows':_0x344921}:null;}})[_0xd998('0x31')](respondWithResult(_0x318cc3,null))[_0xd998('0x2f')](handleError(_0x318cc3,null));};exports[_0xd998('0xe7')]=function(_0x485622,_0x3605ae){var _0x240b9a={'raw':!![],'where':{}};var _0xa1a566={};var _0x4e141b={'count':0x0,'rows':[]};return db[_0xd998('0x54')]['findOne']({'where':{'id':_0x485622[_0xd998('0x5f')]['id']}})[_0xd998('0x31')](handleEntityNotFound(_0x3605ae,null))['then'](function(_0x4cf46a){if(_0x4cf46a){_0xa1a566[_0xd998('0xdc')]=_[_0xd998('0xd8')](db[_0xd998('0xe8')][_0xd998('0x42')]);_0xa1a566[_0xd998('0x4f')]=_[_0xd998('0xd8')](_0x485622[_0xd998('0x4f')]);_0xa1a566[_0xd998('0xda')]=_[_0xd998('0xdb')](_0xa1a566[_0xd998('0xdc')],_0xa1a566[_0xd998('0x4f')]);_0x240b9a[_0xd998('0x63')]=_[_0xd998('0xdb')](_0xa1a566[_0xd998('0xdc')],qs[_0xd998('0xdd')](_0x485622[_0xd998('0x4f')]['fields']));_0x240b9a[_0xd998('0x63')]=_0x240b9a[_0xd998('0x63')][_0xd998('0x94')]?_0x240b9a['attributes']:_0xa1a566[_0xd998('0xdc')];if(!_0x485622[_0xd998('0x4f')]['hasOwnProperty'](_0xd998('0xe2'))){_0x240b9a[_0xd998('0x20')]=qs[_0xd998('0x20')](_0x485622[_0xd998('0x4f')][_0xd998('0x20')]);_0x240b9a[_0xd998('0x1e')]=qs[_0xd998('0x1e')](_0x485622[_0xd998('0x4f')]['offset']);}_0x240b9a[_0xd998('0xde')]=qs['sort'](_0x485622[_0xd998('0x4f')][_0xd998('0xdf')]);_0x240b9a[_0xd998('0x4d')]=qs[_0xd998('0xda')](_[_0xd998('0xe4')](_0x485622['query'],_0xa1a566['filters']));_0x240b9a[_0xd998('0x4d')][_0xd998('0xe9')]=_0x4cf46a['id'];if(_0x485622[_0xd998('0x4f')][_0xd998('0x46')]){_0x240b9a[_0xd998('0x4d')]=_[_0xd998('0xe0')](_0x240b9a[_0xd998('0x4d')],{'$or':_[_0xd998('0x3c')](_0x240b9a[_0xd998('0x63')],function(_0x500cbf){var _0x37422b={};_0x37422b[_0x500cbf]={'$like':'%'+_0x485622[_0xd998('0x4f')]['filter']+'%'};return _0x37422b;})});}_0x240b9a=_[_0xd998('0xe0')]({},_0x240b9a,_0x485622[_0xd998('0x62')]);return db[_0xd998('0xe8')][_0xd998('0x21')]({'where':_0x240b9a[_0xd998('0x4d')]})[_0xd998('0x31')](function(_0x5472d0){_0x4e141b[_0xd998('0x21')]=_0x5472d0;if(_0x485622[_0xd998('0x4f')][_0xd998('0x61')]){_0x240b9a[_0xd998('0x4e')]=[{'all':!![]}];}return db[_0xd998('0xe8')][_0xd998('0x55')](_0x240b9a);})[_0xd998('0x31')](function(_0x57850a){_0x4e141b[_0xd998('0x56')]=_0x57850a;return _0x4e141b;});}})[_0xd998('0x31')](respondWithFilteredResult(_0x3605ae,_0x240b9a))[_0xd998('0x2f')](handleError(_0x3605ae,null));};exports[_0xd998('0xea')]=function(_0x254d6b,_0x4dec75){var _0x4f2753={'raw':!![],'where':{}};var _0x38d10e={};var _0x404228={'count':0x0,'rows':[]};return db['User'][_0xd998('0x9e')]({'where':{'id':_0x254d6b[_0xd998('0x5f')]['id']}})[_0xd998('0x31')](handleEntityNotFound(_0x4dec75,null))['then'](function(_0x567ba0){if(_0x567ba0){_0x38d10e['model']=_[_0xd998('0xd8')](db[_0xd998('0xeb')]['rawAttributes']);_0x38d10e['query']=_['keys'](_0x254d6b[_0xd998('0x4f')]);_0x38d10e[_0xd998('0xda')]=_['intersection'](_0x38d10e['model'],_0x38d10e[_0xd998('0x4f')]);_0x4f2753['attributes']=_[_0xd998('0xdb')](_0x38d10e['model'],qs[_0xd998('0xdd')](_0x254d6b['query'][_0xd998('0xdd')]));_0x4f2753[_0xd998('0x63')]=_0x4f2753[_0xd998('0x63')]['length']?_0x4f2753['attributes']:_0x38d10e['model'];if(!_0x254d6b[_0xd998('0x4f')][_0xd998('0xd2')]('nolimit')){_0x4f2753[_0xd998('0x20')]=qs[_0xd998('0x20')](_0x254d6b[_0xd998('0x4f')][_0xd998('0x20')]);_0x4f2753[_0xd998('0x1e')]=qs['offset'](_0x254d6b[_0xd998('0x4f')][_0xd998('0x1e')]);}_0x4f2753[_0xd998('0xde')]=qs[_0xd998('0xdf')](_0x254d6b[_0xd998('0x4f')][_0xd998('0xdf')]);_0x4f2753[_0xd998('0x4d')]=qs['filters'](_[_0xd998('0xe4')](_0x254d6b[_0xd998('0x4f')],_0x38d10e[_0xd998('0xda')]));_0x4f2753[_0xd998('0x4d')][_0xd998('0xe9')]=_0x567ba0['id'];if(_0x254d6b[_0xd998('0x4f')]['filter']){_0x4f2753[_0xd998('0x4d')]=_[_0xd998('0xe0')](_0x4f2753[_0xd998('0x4d')],{'$or':_[_0xd998('0x3c')](_0x4f2753[_0xd998('0x63')],function(_0x296e9e){var _0xc2c6cb={};_0xc2c6cb[_0x296e9e]={'$like':'%'+_0x254d6b[_0xd998('0x4f')][_0xd998('0x46')]+'%'};return _0xc2c6cb;})});}_0x4f2753=_[_0xd998('0xe0')]({},_0x4f2753,_0x254d6b['options']);return db[_0xd998('0xeb')][_0xd998('0x21')]({'where':_0x4f2753[_0xd998('0x4d')]})[_0xd998('0x31')](function(_0x30a282){_0x404228[_0xd998('0x21')]=_0x30a282;if(_0x254d6b[_0xd998('0x4f')][_0xd998('0x61')]){_0x4f2753[_0xd998('0x4e')]=[{'all':!![]}];}return db[_0xd998('0xeb')][_0xd998('0x55')](_0x4f2753);})[_0xd998('0x31')](function(_0x6ed11e){_0x404228['rows']=_0x6ed11e;return _0x404228;});}})[_0xd998('0x31')](respondWithFilteredResult(_0x4dec75,_0x4f2753))['catch'](handleError(_0x4dec75,null));};exports[_0xd998('0xec')]=function(_0x2670ea,_0x1ffaeb){var _0x4c38a7={};var _0x21a043={};var _0x3af3a2;var _0x6644f3;return db[_0xd998('0x54')][_0xd998('0x9e')]({'where':{'id':_0x2670ea[_0xd998('0x5f')]['id']}})[_0xd998('0x31')](handleEntityNotFound(_0x1ffaeb,null))['then'](function(_0x3dc2b2){if(_0x3dc2b2){_0x3af3a2=_0x3dc2b2;_0x21a043[_0xd998('0xdc')]=_[_0xd998('0xd8')](db['ChatInteraction'][_0xd998('0x42')]);_0x21a043[_0xd998('0x4f')]=_[_0xd998('0xd8')](_0x2670ea[_0xd998('0x4f')]);_0x21a043[_0xd998('0xda')]=_[_0xd998('0xdb')](_0x21a043[_0xd998('0xdc')],_0x21a043[_0xd998('0x4f')]);_0x4c38a7[_0xd998('0x63')]=_[_0xd998('0xdb')](_0x21a043[_0xd998('0xdc')],qs['fields'](_0x2670ea[_0xd998('0x4f')][_0xd998('0xdd')]));_0x4c38a7[_0xd998('0x63')]=_0x4c38a7[_0xd998('0x63')][_0xd998('0x94')]?_0x4c38a7['attributes']:_0x21a043['model'];_0x4c38a7[_0xd998('0xde')]=qs[_0xd998('0xdf')](_0x2670ea[_0xd998('0x4f')]['sort']);_0x4c38a7[_0xd998('0x4d')]=qs[_0xd998('0xda')](_[_0xd998('0xe4')](_0x2670ea[_0xd998('0x4f')],_0x21a043[_0xd998('0xda')]));if(_0x2670ea[_0xd998('0x4f')][_0xd998('0x46')]){_0x4c38a7['where']=_['merge'](_0x4c38a7[_0xd998('0x4d')],{'$or':_['map'](_0x4c38a7[_0xd998('0x63')],function(_0x13ed8b){var _0x4be373={};_0x4be373[_0x13ed8b]={'$like':'%'+_0x2670ea[_0xd998('0x4f')]['filter']+'%'};return _0x4be373;})});}_0x4c38a7=_[_0xd998('0xe0')]({},_0x4c38a7,_0x2670ea[_0xd998('0x62')]);return _0x3af3a2[_0xd998('0xec')](_0x4c38a7);}})[_0xd998('0x31')](function(_0x24ec3f){if(_0x24ec3f){_0x6644f3=_0x24ec3f[_0xd998('0x94')];if(!_0x2670ea[_0xd998('0x4f')][_0xd998('0xd2')](_0xd998('0xe2'))){_0x4c38a7['limit']=qs[_0xd998('0x20')](_0x2670ea[_0xd998('0x4f')][_0xd998('0x20')]);_0x4c38a7[_0xd998('0x1e')]=qs[_0xd998('0x1e')](_0x2670ea[_0xd998('0x4f')][_0xd998('0x1e')]);}return _0x3af3a2[_0xd998('0xec')](_0x4c38a7);}})[_0xd998('0x31')](function(_0x3ee21a){if(_0x3ee21a){return _0x3ee21a?{'count':_0x6644f3,'rows':_0x3ee21a}:null;}})[_0xd998('0x31')](respondWithResult(_0x1ffaeb,null))[_0xd998('0x2f')](handleError(_0x1ffaeb,null));};exports[_0xd998('0xed')]=function(_0x239273,_0x956a99){var _0x36e6de={};var _0x534ea3={};var _0x3f7790;var _0x10b725;return db['User']['findOne']({'where':{'id':_0x239273['params']['id']}})[_0xd998('0x31')](handleEntityNotFound(_0x956a99,null))[_0xd998('0x31')](function(_0x433285){if(_0x433285){_0x3f7790=_0x433285;_0x534ea3[_0xd998('0xdc')]=_['keys'](db[_0xd998('0xee')][_0xd998('0x42')]);_0x534ea3[_0xd998('0x4f')]=_[_0xd998('0xd8')](_0x239273['query']);_0x534ea3['filters']=_[_0xd998('0xdb')](_0x534ea3[_0xd998('0xdc')],_0x534ea3[_0xd998('0x4f')]);_0x36e6de[_0xd998('0x63')]=_[_0xd998('0xdb')](_0x534ea3[_0xd998('0xdc')],qs[_0xd998('0xdd')](_0x239273[_0xd998('0x4f')]['fields']));_0x36e6de[_0xd998('0x63')]=_0x36e6de[_0xd998('0x63')][_0xd998('0x94')]?_0x36e6de[_0xd998('0x63')]:_0x534ea3['model'];_0x36e6de[_0xd998('0xde')]=qs[_0xd998('0xdf')](_0x239273[_0xd998('0x4f')][_0xd998('0xdf')]);_0x36e6de[_0xd998('0x4d')]=qs[_0xd998('0xda')](_[_0xd998('0xe4')](_0x239273[_0xd998('0x4f')],_0x534ea3[_0xd998('0xda')]));if(_0x239273[_0xd998('0x4f')][_0xd998('0x46')]){_0x36e6de[_0xd998('0x4d')]=_[_0xd998('0xe0')](_0x36e6de[_0xd998('0x4d')],{'$or':_['map'](_0x36e6de[_0xd998('0x63')],function(_0x174c34){var _0x518f59={};_0x518f59[_0x174c34]={'$like':'%'+_0x239273[_0xd998('0x4f')][_0xd998('0x46')]+'%'};return _0x518f59;})});}_0x36e6de=_[_0xd998('0xe0')]({},_0x36e6de,_0x239273['options']);return _0x3f7790[_0xd998('0xed')](_0x36e6de);}})[_0xd998('0x31')](function(_0x43be9b){if(_0x43be9b){_0x10b725=_0x43be9b[_0xd998('0x94')];if(!_0x239273['query'][_0xd998('0xd2')](_0xd998('0xe2'))){_0x36e6de['limit']=qs[_0xd998('0x20')](_0x239273[_0xd998('0x4f')][_0xd998('0x20')]);_0x36e6de[_0xd998('0x1e')]=qs[_0xd998('0x1e')](_0x239273[_0xd998('0x4f')][_0xd998('0x1e')]);}return _0x3f7790[_0xd998('0xed')](_0x36e6de);}})['then'](function(_0x1034b8){if(_0x1034b8){return _0x1034b8?{'count':_0x10b725,'rows':_0x1034b8}:null;}})[_0xd998('0x31')](respondWithResult(_0x956a99,null))['catch'](handleError(_0x956a99,null));};exports['getMailInteractions']=function(_0x6728b5,_0x266b93){var _0x5b175b={'raw':!![],'where':{}};var _0x35077d={};var _0x42b166={'count':0x0,'rows':[]};return db[_0xd998('0x54')][_0xd998('0x9e')]({'where':{'id':_0x6728b5[_0xd998('0x5f')]['id']}})[_0xd998('0x31')](handleEntityNotFound(_0x266b93,null))[_0xd998('0x31')](function(_0x242390){if(_0x242390){_0x35077d[_0xd998('0xdc')]=_[_0xd998('0xd8')](db[_0xd998('0xef')][_0xd998('0x42')]);_0x35077d['query']=_['keys'](_0x6728b5[_0xd998('0x4f')]);_0x35077d['filters']=_[_0xd998('0xdb')](_0x35077d[_0xd998('0xdc')],_0x35077d[_0xd998('0x4f')]);_0x5b175b[_0xd998('0x63')]=_[_0xd998('0xdb')](_0x35077d[_0xd998('0xdc')],qs[_0xd998('0xdd')](_0x6728b5[_0xd998('0x4f')][_0xd998('0xdd')]));_0x5b175b[_0xd998('0x63')]=_0x5b175b[_0xd998('0x63')][_0xd998('0x94')]?_0x5b175b['attributes']:_0x35077d[_0xd998('0xdc')];if(!_0x6728b5[_0xd998('0x4f')]['hasOwnProperty'](_0xd998('0xe2'))){_0x5b175b['limit']=qs[_0xd998('0x20')](_0x6728b5['query'][_0xd998('0x20')]);_0x5b175b[_0xd998('0x1e')]=qs[_0xd998('0x1e')](_0x6728b5[_0xd998('0x4f')][_0xd998('0x1e')]);}_0x5b175b[_0xd998('0xde')]=qs[_0xd998('0xdf')](_0x6728b5[_0xd998('0x4f')][_0xd998('0xdf')]);_0x5b175b[_0xd998('0x4d')]=qs[_0xd998('0xda')](_[_0xd998('0xe4')](_0x6728b5[_0xd998('0x4f')],_0x35077d[_0xd998('0xda')]));_0x5b175b[_0xd998('0x4d')][_0xd998('0xe9')]=_0x242390['id'];if(_0x6728b5[_0xd998('0x4f')][_0xd998('0x46')]){_0x5b175b[_0xd998('0x4d')]=_[_0xd998('0xe0')](_0x5b175b['where'],{'$or':_[_0xd998('0x3c')](_0x5b175b['attributes'],function(_0x260ffe){var _0x5e07ad={};_0x5e07ad[_0x260ffe]={'$like':'%'+_0x6728b5['query'][_0xd998('0x46')]+'%'};return _0x5e07ad;})});}_0x5b175b=_[_0xd998('0xe0')]({},_0x5b175b,_0x6728b5[_0xd998('0x62')]);return db['MailInteraction'][_0xd998('0x21')]({'where':_0x5b175b[_0xd998('0x4d')]})[_0xd998('0x31')](function(_0x2cda98){_0x42b166[_0xd998('0x21')]=_0x2cda98;if(_0x6728b5['query'][_0xd998('0x61')]){_0x5b175b[_0xd998('0x4e')]=[{'all':!![]}];}return db[_0xd998('0xef')][_0xd998('0x55')](_0x5b175b);})['then'](function(_0x4d7a66){_0x42b166[_0xd998('0x56')]=_0x4d7a66;return _0x42b166;});}})[_0xd998('0x31')](respondWithFilteredResult(_0x266b93,_0x5b175b))[_0xd998('0x2f')](handleError(_0x266b93,null));};exports[_0xd998('0xf0')]=function(_0x37a23c,_0x20d4d3){var _0x2de168={};var _0x506bec={};var _0x162cab;var _0x1c1d30;return db['User'][_0xd998('0x9e')]({'where':{'id':_0x37a23c[_0xd998('0x5f')]['id']}})[_0xd998('0x31')](handleEntityNotFound(_0x20d4d3,null))['then'](function(_0x5a3c0b){if(_0x5a3c0b){_0x162cab=_0x5a3c0b;_0x506bec[_0xd998('0xdc')]=_[_0xd998('0xd8')](db[_0xd998('0xf1')][_0xd998('0x42')]);_0x506bec[_0xd998('0x4f')]=_['keys'](_0x37a23c[_0xd998('0x4f')]);_0x506bec[_0xd998('0xda')]=_[_0xd998('0xdb')](_0x506bec['model'],_0x506bec['query']);_0x2de168[_0xd998('0x63')]=_['intersection'](_0x506bec[_0xd998('0xdc')],qs[_0xd998('0xdd')](_0x37a23c[_0xd998('0x4f')][_0xd998('0xdd')]));_0x2de168[_0xd998('0x63')]=_0x2de168[_0xd998('0x63')]['length']?_0x2de168[_0xd998('0x63')]:_0x506bec[_0xd998('0xdc')];_0x2de168['order']=qs[_0xd998('0xdf')](_0x37a23c[_0xd998('0x4f')]['sort']);_0x2de168[_0xd998('0x4d')]=qs[_0xd998('0xda')](_[_0xd998('0xe4')](_0x37a23c[_0xd998('0x4f')],_0x506bec[_0xd998('0xda')]));if(_0x37a23c[_0xd998('0x4f')]['filter']){_0x2de168[_0xd998('0x4d')]=_[_0xd998('0xe0')](_0x2de168[_0xd998('0x4d')],{'$or':_[_0xd998('0x3c')](_0x2de168[_0xd998('0x63')],function(_0x45336d){var _0x27b5d1={};_0x27b5d1[_0x45336d]={'$like':'%'+_0x37a23c[_0xd998('0x4f')][_0xd998('0x46')]+'%'};return _0x27b5d1;})});}_0x2de168=_['merge']({},_0x2de168,_0x37a23c[_0xd998('0x62')]);return _0x162cab[_0xd998('0xf0')](_0x2de168);}})[_0xd998('0x31')](function(_0x1e944f){if(_0x1e944f){_0x1c1d30=_0x1e944f[_0xd998('0x94')];if(!_0x37a23c[_0xd998('0x4f')][_0xd998('0xd2')](_0xd998('0xe2'))){_0x2de168['limit']=qs[_0xd998('0x20')](_0x37a23c[_0xd998('0x4f')][_0xd998('0x20')]);_0x2de168[_0xd998('0x1e')]=qs[_0xd998('0x1e')](_0x37a23c[_0xd998('0x4f')]['offset']);}return _0x162cab[_0xd998('0xf0')](_0x2de168);}})[_0xd998('0x31')](function(_0x3829a2){if(_0x3829a2){return _0x3829a2?{'count':_0x1c1d30,'rows':_0x3829a2}:null;}})[_0xd998('0x31')](respondWithResult(_0x20d4d3,null))[_0xd998('0x2f')](handleError(_0x20d4d3,null));};exports['getFaxInteractions']=function(_0x2883ca,_0x4132e2){var _0x55dd5b={};var _0x1edb09={};var _0x2f6ec9;var _0x3e292f;return db[_0xd998('0x54')][_0xd998('0x9e')]({'where':{'id':_0x2883ca[_0xd998('0x5f')]['id']}})[_0xd998('0x31')](handleEntityNotFound(_0x4132e2,null))['then'](function(_0x376698){if(_0x376698){_0x2f6ec9=_0x376698;_0x1edb09['model']=_[_0xd998('0xd8')](db['FaxInteraction'][_0xd998('0x42')]);_0x1edb09[_0xd998('0x4f')]=_['keys'](_0x2883ca[_0xd998('0x4f')]);_0x1edb09[_0xd998('0xda')]=_[_0xd998('0xdb')](_0x1edb09[_0xd998('0xdc')],_0x1edb09[_0xd998('0x4f')]);_0x55dd5b[_0xd998('0x63')]=_[_0xd998('0xdb')](_0x1edb09[_0xd998('0xdc')],qs[_0xd998('0xdd')](_0x2883ca['query'][_0xd998('0xdd')]));_0x55dd5b[_0xd998('0x63')]=_0x55dd5b[_0xd998('0x63')][_0xd998('0x94')]?_0x55dd5b[_0xd998('0x63')]:_0x1edb09[_0xd998('0xdc')];_0x55dd5b['order']=qs[_0xd998('0xdf')](_0x2883ca[_0xd998('0x4f')][_0xd998('0xdf')]);_0x55dd5b[_0xd998('0x4d')]=qs[_0xd998('0xda')](_[_0xd998('0xe4')](_0x2883ca[_0xd998('0x4f')],_0x1edb09[_0xd998('0xda')]));if(_0x2883ca[_0xd998('0x4f')][_0xd998('0x46')]){_0x55dd5b[_0xd998('0x4d')]=_[_0xd998('0xe0')](_0x55dd5b[_0xd998('0x4d')],{'$or':_[_0xd998('0x3c')](_0x55dd5b[_0xd998('0x63')],function(_0x289980){var _0x3e6cae={};_0x3e6cae[_0x289980]={'$like':'%'+_0x2883ca[_0xd998('0x4f')]['filter']+'%'};return _0x3e6cae;})});}_0x55dd5b=_[_0xd998('0xe0')]({},_0x55dd5b,_0x2883ca[_0xd998('0x62')]);return _0x2f6ec9[_0xd998('0xf2')](_0x55dd5b);}})[_0xd998('0x31')](function(_0x1eb0ae){if(_0x1eb0ae){_0x3e292f=_0x1eb0ae[_0xd998('0x94')];if(!_0x2883ca[_0xd998('0x4f')][_0xd998('0xd2')](_0xd998('0xe2'))){_0x55dd5b['limit']=qs[_0xd998('0x20')](_0x2883ca[_0xd998('0x4f')]['limit']);_0x55dd5b[_0xd998('0x1e')]=qs[_0xd998('0x1e')](_0x2883ca[_0xd998('0x4f')][_0xd998('0x1e')]);}return _0x2f6ec9[_0xd998('0xf2')](_0x55dd5b);}})[_0xd998('0x31')](function(_0x1d80a2){if(_0x1d80a2){return _0x1d80a2?{'count':_0x3e292f,'rows':_0x1d80a2}:null;}})[_0xd998('0x31')](respondWithResult(_0x4132e2,null))[_0xd998('0x2f')](handleError(_0x4132e2,null));};exports[_0xd998('0xf3')]=function(_0x12c368,_0x4d2312){var _0x4f6d46={};var _0x1bbed9={};var _0x502d1f;var _0x29328f;return db[_0xd998('0x54')][_0xd998('0x9e')]({'where':{'id':_0x12c368[_0xd998('0x5f')]['id']}})[_0xd998('0x31')](handleEntityNotFound(_0x4d2312,null))[_0xd998('0x31')](function(_0x183d09){if(_0x183d09){_0x502d1f=_0x183d09;_0x1bbed9[_0xd998('0xdc')]=_[_0xd998('0xd8')](db[_0xd998('0xf4')][_0xd998('0x42')]);_0x1bbed9[_0xd998('0x4f')]=_[_0xd998('0xd8')](_0x12c368['query']);_0x1bbed9[_0xd998('0xda')]=_[_0xd998('0xdb')](_0x1bbed9['model'],_0x1bbed9['query']);_0x4f6d46[_0xd998('0x63')]=_['intersection'](_0x1bbed9[_0xd998('0xdc')],qs[_0xd998('0xdd')](_0x12c368['query']['fields']));_0x4f6d46[_0xd998('0x63')]=_0x4f6d46[_0xd998('0x63')][_0xd998('0x94')]?_0x4f6d46[_0xd998('0x63')]:_0x1bbed9['model'];_0x4f6d46[_0xd998('0xde')]=qs[_0xd998('0xdf')](_0x12c368[_0xd998('0x4f')][_0xd998('0xdf')]);_0x4f6d46[_0xd998('0x4d')]=qs[_0xd998('0xda')](_[_0xd998('0xe4')](_0x12c368[_0xd998('0x4f')],_0x1bbed9[_0xd998('0xda')]));if(_0x12c368['query'][_0xd998('0x46')]){_0x4f6d46[_0xd998('0x4d')]=_[_0xd998('0xe0')](_0x4f6d46[_0xd998('0x4d')],{'$or':_[_0xd998('0x3c')](_0x4f6d46[_0xd998('0x63')],function(_0x4a5f0f){var _0x26c3b5={};_0x26c3b5[_0x4a5f0f]={'$like':'%'+_0x12c368[_0xd998('0x4f')][_0xd998('0x46')]+'%'};return _0x26c3b5;})});}_0x4f6d46=_['merge']({},_0x4f6d46,_0x12c368[_0xd998('0x62')]);return _0x502d1f['getWhatsappInteractions'](_0x4f6d46);}})['then'](function(_0x561cd2){if(_0x561cd2){_0x29328f=_0x561cd2['length'];if(!_0x12c368['query'][_0xd998('0xd2')](_0xd998('0xe2'))){_0x4f6d46[_0xd998('0x20')]=qs[_0xd998('0x20')](_0x12c368[_0xd998('0x4f')]['limit']);_0x4f6d46[_0xd998('0x1e')]=qs['offset'](_0x12c368['query']['offset']);}return _0x502d1f['getWhatsappInteractions'](_0x4f6d46);}})[_0xd998('0x31')](function(_0x599cb1){if(_0x599cb1){return _0x599cb1?{'count':_0x29328f,'rows':_0x599cb1}:null;}})[_0xd998('0x31')](respondWithResult(_0x4d2312,null))[_0xd998('0x2f')](handleError(_0x4d2312,null));};exports[_0xd998('0xf5')]=function(_0x57ef42,_0x32d7fc,_0x1635f1){var _0x1419c1;var _0x493ef3;var _0x53cbd6;var _0xbb891f=!_[_0xd998('0x71')](_0x57ef42[_0xd998('0x5f')]['id'])?_0x57ef42[_0xd998('0x5f')]['id']:!_[_0xd998('0x71')](_0x57ef42[_0xd998('0x37')]['id'])?_0x57ef42[_0xd998('0x37')]['id']:null;return db[_0xd998('0x54')][_0xd998('0x3e')]({'where':{'id':_0xbb891f,'role':{'$or':[_0xd998('0x35'),_0xd998('0x37'),_0xd998('0x33')]}},'attributes':['id',_0xd998('0x3f'),_0xd998('0xf6'),_0xd998('0xf7'),'role',_0xd998('0x6a'),'loginInPause']})[_0xd998('0x31')](function(_0x193891){if(_0x193891){if(_0x193891[_0xd998('0x32')]===_0xd998('0x33')){_0x1419c1=_0x193891;if(_0x57ef42['body'][_0xd998('0xa7')]){_0x53cbd6=util[_0xd998('0xd1')]('LOCAL/%s@from-sip/n',_0x1419c1[_0x57ef42[_0xd998('0x66')][_0xd998('0xa7')]]);}else if(_0x57ef42[_0xd998('0x66')][_0xd998('0xf8')]){_0x53cbd6=util[_0xd998('0xd1')](_0xd998('0xb5'),_0x57ef42['body'][_0xd998('0xf8')]);}else{_0x53cbd6=util[_0xd998('0xd1')]('SIP/%s',_0x1419c1[_0xd998('0x3f')]);}socket['to'](util[_0xd998('0xd1')](_0xd998('0xf9'),_0x1419c1[_0xd998('0x3f')]))['emit'](_0xd998('0xfa'),{'user':{'id':_0x1419c1['id'],'name':_0x1419c1['name']},'ip':_0x57ef42[_0xd998('0xfb')][_0xd998('0xfc')]||_0x57ef42['connection']['remoteAddress']||_0x57ef42[_0xd998('0xfd')][_0xd998('0xfe')]||_0x57ef42[_0xd998('0xff')]['socket'][_0xd998('0xfe')]});return db[_0xd998('0xb7')][_0xd998('0x40')]({'where':{'membername':_0x1419c1[_0xd998('0x3f')]},'individualHooks':!![]});}}else{throw new db[(_0xd998('0x9a'))][(_0xd998('0x9b'))]('User\x20not\x20found\x20or\x20not\x20allowed\x20to\x20perform\x20login\x20method');}})[_0xd998('0x31')](function(){if(_0x1419c1){return _0x1419c1[_0xd998('0x100')]({'raw':!![]});}})[_0xd998('0x31')](function(_0x1ab8ab){if(_0x1419c1){if(_0x1ab8ab){_0x493ef3=_0x1ab8ab;if(_0x493ef3[_0xd998('0x94')]){var _0x556e34=_0x493ef3[_0xd998('0x3c')](function(_0x37f5fe){var _0x58c526={'membername':_0x1419c1[_0xd998('0x3f')],'UserId':_0x1419c1['id'],'queue_name':_0x37f5fe[_0xd998('0x3f')],'VoiceQueueId':_0x37f5fe['id'],'interface':_0x53cbd6,'paused':_0x1419c1['loginInPause']||![],'penalty':_0x37f5fe[_0xd998('0x101')]||0x0};return db['UserVoiceQueueRt'][_0xd998('0xb8')](_0x58c526);});return Promise[_0xd998('0x65')](_0x556e34);}}}})[_0xd998('0x31')](function(){if(_0x1419c1){return db[_0xd998('0x102')][_0xd998('0x55')]({'where':{'membername':_0x1419c1['name'],'exitAt':null}});}})[_0xd998('0x31')](function(_0x22125e){if(_0x1419c1){var _0x472348=[];_0x22125e[_0xd998('0x103')](function(_0x408001){_0x472348[_0xd998('0x53')](_0x408001[_0xd998('0x30')]({'exitAt':moment()[_0xd998('0xd1')]('YYYY-MM-DD\x20HH:mm:ss')}));});return Promise[_0xd998('0x65')](_0x472348);}})[_0xd998('0x31')](function(){if(_0x1419c1){var _0x2e357f=[];var _0x59beff=[];var _0x91e0e1=utils[_0xd998('0x104')]();var _0x41a3d2={'membername':_0x1419c1['name'],'interface':_0x53cbd6,'enterAt':moment()[_0xd998('0xd1')]('YYYY-MM-DD\x20HH:mm:ss'),'role':_0x1419c1['role'],'internal':_0x1419c1[_0xd998('0x6a')]};_0x91e0e1[_0xd998('0x103')](function(_0x6e9fa5){_0x2e357f[_0xd998('0x53')](_['merge']({'channel':_0x6e9fa5,'type':'LOGIN','data1':_0x57ef42[_0xd998('0x66')][_0xd998('0x105')],'data2':_0x53cbd6},_0x41a3d2));if(_0x1419c1[_0xd998('0xa6')]){_0x59beff[_0xd998('0x53')](_[_0xd998('0xe0')]({'channel':_0x6e9fa5,'type':_0xd998('0x106'),'data1':'LOGININPAUSE'},_0x41a3d2));}});return db['MemberReport'][_0xd998('0x107')](_0x2e357f[_0xd998('0xd0')](_0x59beff),{'individualHooks':!![]});}})[_0xd998('0x31')](function(){if(_0x1419c1){return _0x1419c1[_0xd998('0x30')]({'online':!![],'lastLoginAt':moment()['format'](_0xd998('0x108')),'voicePause':_0x1419c1[_0xd998('0xa6')]||![],'mailPause':_0x1419c1[_0xd998('0xa6')]||![],'chatPause':_0x1419c1[_0xd998('0xa6')]||![],'faxPause':_0x1419c1[_0xd998('0xa6')]||![],'smsPause':_0x1419c1['loginInPause']||![],'openchannelPause':_0x1419c1[_0xd998('0xa6')]||![],'whatsappPause':_0x1419c1[_0xd998('0xa6')]||![],'pauseType':_0x1419c1[_0xd998('0xa6')]?_0xd998('0x109'):null,'interface':_0x53cbd6,'lastPauseAt':moment()[_0xd998('0xd1')](_0xd998('0x108'))});}})[_0xd998('0x31')](function(_0xbca02c){if(_0x57ef42['isMiddleware']){return _0x1635f1();}else{return Promise[_0xd998('0x10a')](_0xbca02c)[_0xd998('0x31')](respondWithResult(_0x32d7fc,null));}})[_0xd998('0x2f')](handleError(_0x32d7fc,null));};exports[_0xd998('0x10b')]=function(_0x39e0d5,_0x4f8003){var _0xf1e2c7;return db['User'][_0xd998('0x3e')]({'where':{'id':_0x39e0d5[_0xd998('0x5f')]['id'],'role':'agent'},'attributes':['id',_0xd998('0x3f'),'role']})[_0xd998('0x31')](handleEntityNotFound(_0x4f8003,null))[_0xd998('0x31')](function(_0x31a6e6){if(_0x31a6e6){_0xf1e2c7=_0x31a6e6;return db['UserVoiceQueueRt'][_0xd998('0x40')]({'where':{'membername':_0xf1e2c7[_0xd998('0x3f')]},'individualHooks':!![]});}})[_0xd998('0x31')](function(){return db[_0xd998('0x102')][_0xd998('0x55')]({'where':{'membername':_0xf1e2c7['name'],'exitAt':null}});})['then'](function(_0x179729){var _0x747662=[];_0x179729[_0xd998('0x103')](function(_0x12db35){_0x747662['push'](_0x12db35[_0xd998('0x30')]({'exitAt':moment()[_0xd998('0xd1')](_0xd998('0x108'))}));});return Promise[_0xd998('0x65')](_0x747662);})[_0xd998('0x31')](function(){return _0xf1e2c7['update']({'online':![],'voicePause':![],'mailPause':![],'chatPause':![],'faxPause':![],'smsPause':![],'openchannelPause':![],'whatsappPause':![],'interface':null});})['then'](respondWithResult(_0x4f8003,null))[_0xd998('0x2f')](handleError(_0x4f8003,null));};exports[_0xd998('0x10c')]=function(_0x2f0ee6,_0x39f082){var _0xf4e3fa;return db[_0xd998('0xb7')][_0xd998('0x30')]({'paused':0x1},{'where':{'UserId':_0x2f0ee6[_0xd998('0x5f')]['id']},'individualHooks':!![]})['then'](function(){return db[_0xd998('0x54')]['find']({'where':{'id':_0x2f0ee6['params']['id'],'role':_0xd998('0x33')},'attributes':['id',_0xd998('0x3f'),_0xd998('0x32'),_0xd998('0x6a'),_0xd998('0xa7'),_0xd998('0xa5')]});})[_0xd998('0x31')](handleEntityNotFound(_0x39f082,null))[_0xd998('0x31')](function(_0x4b15c4){if(_0x4b15c4){_0xf4e3fa=_0x4b15c4;return respondWithRpcPromise(_0xd998('0x10d'),_0xd998('0x10c'),{'id':_0xf4e3fa['id'],'name':_0xf4e3fa['name'],'pause':!![]});}})[_0xd998('0x31')](function(){if(_0xf4e3fa){return db[_0xd998('0x102')]['findAll']({'where':{'membername':_0xf4e3fa[_0xd998('0x3f')],'type':_0xd998('0x106'),'exitAt':null}});}})[_0xd998('0x31')](function(_0x2c0099){if(_0x2c0099[_0xd998('0x94')]){var _0x58cbee=moment()[_0xd998('0xd1')](_0xd998('0x108'));for(var _0x29f0d1=0x0,_0x9fb4e7=_0x2c0099[_0xd998('0x94')];_0x29f0d1<_0x9fb4e7;_0x29f0d1++){_0x2c0099[_0x29f0d1]['updateAttributes']({'exitAt':_0x58cbee});}}})['then'](function(){var _0x4f8bf1=[];var _0x2d4e8a=utils['getChannels']();_0x2d4e8a[_0xd998('0x103')](function(_0x3119a7){_0x4f8bf1[_0xd998('0x53')]({'channel':_0x3119a7,'membername':_0xf4e3fa[_0xd998('0x3f')],'interface':_[_0xd998('0x71')](_0xf4e3fa[_0xd998('0xa7')])?util[_0xd998('0xd1')](_0xd998('0xb5'),_0xf4e3fa[_0xd998('0x3f')]):_0xf4e3fa[_0xd998('0xa7')],'type':_0xd998('0x106'),'enterAt':moment()[_0xd998('0xd1')](_0xd998('0x108')),'data1':_0x2f0ee6['body'][_0xd998('0x44')]||'DEFAULT\x20PAUSE','role':_0xf4e3fa[_0xd998('0x32')],'internal':_0xf4e3fa['internal']});});return db[_0xd998('0x102')][_0xd998('0x107')](_0x4f8bf1,{'individualHooks':!![]});})[_0xd998('0x31')](function(){return _0xf4e3fa[_0xd998('0x30')]({'voicePause':!![],'mailPause':!![],'chatPause':!![],'faxPause':!![],'smsPause':!![],'whatsappPause':!![],'openchannelPause':!![],'pauseType':_0x2f0ee6[_0xd998('0x66')][_0xd998('0x44')]||_0xd998('0x10e'),'lastPauseAt':moment()[_0xd998('0xd1')]('YYYY-MM-DD\x20HH:mm:ss')});})['then'](respondWithResult(_0x39f082,null))['catch'](handleError(_0x39f082,null));};exports[_0xd998('0x10f')]=function(_0x3d15c8,_0x57272d){if(_0x3d15c8[_0xd998('0x66')][_0xd998('0xa4')]&&!utils[_0xd998('0xa8')](_0x3d15c8[_0xd998('0x66')]['channel'])){throw new APIBadRequestError(util[_0xd998('0xd1')](_0xd998('0x110'),_0x3d15c8[_0xd998('0x66')][_0xd998('0xa4')]));}return db[_0xd998('0x54')][_0xd998('0x3e')]({'where':{'id':_0x3d15c8[_0xd998('0x5f')]['id']},'attributes':['id',_0xd998('0x3f'),_0xd998('0x32'),_0xd998('0x6a'),_0xd998('0xa7'),_0xd998('0xa5'),_0xd998('0xb6'),_0xd998('0x111'),'chatPause',_0xd998('0x112'),'openchannelPause',_0xd998('0x113'),'whatsappPause',_0xd998('0x114'),_0xd998('0x115')]})[_0xd998('0x31')](function(_0x59ab94){if(!_0x59ab94){throw new APINotFoundError(util[_0xd998('0xd1')](_0xd998('0x116'),_0x3d15c8[_0xd998('0x5f')]['id']));}return _0x59ab94[_0xd998('0x10f')](_0x3d15c8[_0xd998('0x66')][_0xd998('0xa4')]);})[_0xd998('0x31')](respondWithResult(_0x57272d,null))['catch'](APIHandleError(_0x57272d));};exports[_0xd998('0x117')]=function(_0x370d5f,_0x274dab){var _0x835575={};var _0x1ed141={};var _0x511575;var _0x5ba3f0;return db[_0xd998('0x54')][_0xd998('0x9e')]({'where':{'id':_0x370d5f[_0xd998('0x5f')]['id']}})['then'](handleEntityNotFound(_0x274dab,null))[_0xd998('0x31')](function(_0x37188a){if(_0x37188a){_0x511575=_0x37188a;_0x1ed141[_0xd998('0xdc')]=_[_0xd998('0xd8')](db[_0xd998('0x118')][_0xd998('0x42')]);_0x1ed141['query']=_[_0xd998('0xd8')](_0x370d5f[_0xd998('0x4f')]);_0x1ed141[_0xd998('0xda')]=_[_0xd998('0xdb')](_0x1ed141[_0xd998('0xdc')],_0x1ed141[_0xd998('0x4f')]);_0x835575[_0xd998('0x63')]=_[_0xd998('0xdb')](_0x1ed141[_0xd998('0xdc')],qs[_0xd998('0xdd')](_0x370d5f[_0xd998('0x4f')][_0xd998('0xdd')]));_0x835575[_0xd998('0x63')]=_0x835575[_0xd998('0x63')][_0xd998('0x94')]?_0x835575[_0xd998('0x63')]:_0x1ed141[_0xd998('0xdc')];_0x835575[_0xd998('0xde')]=qs[_0xd998('0xdf')](_0x370d5f[_0xd998('0x4f')]['sort']);_0x835575[_0xd998('0x4d')]=qs['filters'](_['pick'](_0x370d5f[_0xd998('0x4f')],_0x1ed141[_0xd998('0xda')]));if(_0x370d5f[_0xd998('0x4f')][_0xd998('0x46')]){_0x835575[_0xd998('0x4d')]=_[_0xd998('0xe0')](_0x835575[_0xd998('0x4d')],{'$or':_[_0xd998('0x3c')](_0x835575['attributes'],function(_0x10e737){var _0x3b304f={};_0x3b304f[_0x10e737]={'$like':'%'+_0x370d5f[_0xd998('0x4f')][_0xd998('0x46')]+'%'};return _0x3b304f;})});}_0x835575=_[_0xd998('0xe0')]({},_0x835575,_0x370d5f[_0xd998('0x62')]);return _0x511575[_0xd998('0x117')](_0x835575);}})[_0xd998('0x31')](function(_0x2e7ab9){if(_0x2e7ab9){_0x5ba3f0=_0x2e7ab9[_0xd998('0x94')];if(!_0x370d5f['query'][_0xd998('0xd2')]('nolimit')){_0x835575[_0xd998('0x20')]=qs['limit'](_0x370d5f[_0xd998('0x4f')]['limit']);_0x835575[_0xd998('0x1e')]=qs[_0xd998('0x1e')](_0x370d5f['query'][_0xd998('0x1e')]);}return _0x511575[_0xd998('0x117')](_0x835575);}})[_0xd998('0x31')](function(_0x2db525){if(_0x2db525){return _0x2db525?{'count':_0x5ba3f0,'rows':_0x2db525}:null;}})[_0xd998('0x31')](respondWithResult(_0x274dab,null))[_0xd998('0x2f')](handleError(_0x274dab,null));};exports[_0xd998('0x119')]=function(_0x27505f,_0xf5c637){var _0x3bdc8a=_0x27505f['params']['id'];var _0xdeb18b=_0x27505f[_0xd998('0x66')]?_0x27505f[_0xd998('0x66')][_0xd998('0xac')]:null;var _0x17a88e=[];return Promise['resolve']()[_0xd998('0x31')](function(){if(!_0xdeb18b)throw new APIBadRequestError(_0xd998('0x11a'));})['then'](function(){return db[_0xd998('0x54')][_0xd998('0x9e')]({'where':{'id':_0x3bdc8a}});})['then'](function(_0x11312e){if(!_0x11312e)throw new APINotFoundError(util[_0xd998('0xd1')](_0xd998('0x116'),_0x27505f[_0xd998('0x5f')]['id']));return db['sequelize'][_0xd998('0x11b')](function(_0x21a1ce){return _0x11312e[_0xd998('0x119')](_0xdeb18b,{'transaction':_0x21a1ce})[_0xd998('0x31')](function(){return db[_0xd998('0x118')][_0xd998('0x55')]({'where':{'id':{'$in':_0xdeb18b}}});})[_0xd998('0x31')](function(_0x448240){var _0x4bffcf=_[_0xd998('0x3c')](_0x448240,function(_0x2dccd8){return _0x2dccd8[_0xd998('0x11c')]();});return Promise[_0xd998('0x65')](_0x4bffcf);})[_0xd998('0x31')](function(_0x2b6a2d){_0x17a88e=_[_0xd998('0x11d')](_0x2b6a2d);var _0x26535d=_[_0xd998('0x3c')](_0x17a88e,function(_0x130624){return _0x130624[_0xd998('0x11e')](_0x11312e['id'],{'transaction':_0x21a1ce});});return Promise[_0xd998('0x65')](_0x26535d);})['then'](function(){if(!_0x11312e[_0xd998('0xa5')])return;var _0x3ba415=_[_0xd998('0x46')](_0x17a88e,function(_0x406655){return _0x406655[_0xd998('0x11f')](_0xd998('0xa4'))===_0xd998('0x120');});var _0x17b550=_[_0xd998('0x3c')](_0x3ba415,function(_0x18e8d2){return db[_0xd998('0xb7')][_0xd998('0xb8')]({'membername':_0x11312e[_0xd998('0x3f')],'UserId':_0x11312e['id'],'queue_name':_0x18e8d2['name'],'VoiceQueueId':_0x18e8d2['id'],'interface':_[_0xd998('0x71')](_0x11312e['interface'])?util[_0xd998('0xd1')](_0xd998('0xb5'),_0x11312e['name']):_0x11312e['interface'],'paused':_0x11312e[_0xd998('0xb6')]||![],'penalty':_0x11312e['penalty']},{'transaction':_0x21a1ce});});return Promise[_0xd998('0x65')](_0x17b550);})[_0xd998('0x31')](function(){return db['TeamVoicePrefix']['findAll']({'where':{'teamId':{'$in':_0xdeb18b}}});})[_0xd998('0x31')](function(_0x2b5d16){var _0x27142f=_[_0xd998('0x3c')](_0x2b5d16,function(_0x4c6e9e){return db['UserVoicePrefix'][_0xd998('0x88')]({'UserId':_0x11312e['id'],'VoicePrefixId':_0x4c6e9e['VoicePrefixId']},{'transaction':_0x21a1ce});});return Promise[_0xd998('0x65')](_0x27142f);});});})[_0xd998('0x31')](function(){for(var _0x2b3602=0x0;_0x2b3602<_0x17a88e[_0xd998('0x94')];_0x2b3602++){var _0xd42381=_0x17a88e[_0x2b3602][_0xd998('0x11f')]('channel');var _0x515022=_0xd42381+_0xd998('0xb0');socket[_0xd998('0x34')]('user'+_0xd42381+'Queue:save',{'UserId':_0x3bdc8a,['queueField']:_0x17a88e[_0x2b3602]['id']});}})['then'](respondWithStatusCode(_0xf5c637,null))['catch'](APIHandleError(_0xf5c637));};exports[_0xd998('0x121')]=function(_0x328284,_0x2ce529){var _0x438007=_0x328284[_0xd998('0x5f')]['id'];var _0x44e5a8=null;if(_0x328284[_0xd998('0x4f')]['ids']){_0x44e5a8=_['isArray'](_0x328284[_0xd998('0x4f')][_0xd998('0xac')])?_0x328284[_0xd998('0x4f')][_0xd998('0xac')]:[_0x328284['query'][_0xd998('0xac')]];}var _0xcc9c56=[];return Promise[_0xd998('0x10a')]()[_0xd998('0x31')](function(){if(!_0x44e5a8)throw new APIBadRequestError(_0xd998('0x122'));})[_0xd998('0x31')](function(){return db[_0xd998('0x54')][_0xd998('0x9e')]({'where':{'id':_0x438007}});})['then'](function(_0x3834f2){if(!_0x3834f2)throw new APINotFoundError(util[_0xd998('0xd1')](_0xd998('0x116'),_0x328284['params']['id']));return db['sequelize']['transaction'](function(_0x272659){return _0x3834f2[_0xd998('0x121')](_0x44e5a8,{'transaction':_0x272659})['then'](function(){return db[_0xd998('0x118')][_0xd998('0x55')]({'where':{'id':{'$in':_0x44e5a8}}});})[_0xd998('0x31')](function(_0x57b199){var _0x9ab010=_[_0xd998('0x3c')](_0x57b199,function(_0x182347){return _0x182347['getAssociatedQueues']();});return Promise['all'](_0x9ab010);})[_0xd998('0x31')](function(_0x1f6313){_0xcc9c56=_[_0xd998('0x11d')](_0x1f6313);var _0x2b5c8b=_[_0xd998('0x3c')](_0xcc9c56,function(_0x4bb702){return _0x4bb702['removeAgent'](_0x3834f2['id'],{'transaction':_0x272659});});return Promise['all'](_0x2b5c8b);})[_0xd998('0x31')](function(){if(!_0x3834f2[_0xd998('0xa5')])return;var _0x1347b2=_[_0xd998('0x46')](_0xcc9c56,function(_0xa0e05){return _0xa0e05[_0xd998('0x11f')](_0xd998('0xa4'))===_0xd998('0x120');});var _0x47aec9=_[_0xd998('0x3c')](_0x1347b2,function(_0x141370){return db[_0xd998('0xb7')][_0xd998('0x40')]({'where':{'VoiceQueueId':_0x141370['id'],'UserId':_0x3834f2['id']},'transaction':_0x272659});});return Promise[_0xd998('0x65')](_0x47aec9);})[_0xd998('0x31')](function(){return db[_0xd998('0x123')][_0xd998('0x55')]({'where':{'teamId':{'$in':_0x44e5a8}}});})[_0xd998('0x31')](function(_0x277a8b){var _0x7c595d=_[_0xd998('0x3c')](_0x277a8b,function(_0x198ba5){return db[_0xd998('0x124')][_0xd998('0x40')]({'where':{'UserId':_0x3834f2['id'],'VoicePrefixId':_0x198ba5[_0xd998('0x125')]}},{'transaction':_0x272659});});return Promise[_0xd998('0x65')](_0x7c595d);});});})['then'](function(){for(var _0x2863ed=0x0;_0x2863ed<_0xcc9c56[_0xd998('0x94')];_0x2863ed++){var _0x1ceaa7=_0xcc9c56[_0x2863ed][_0xd998('0x11f')](_0xd998('0xa4'));var _0x47df76=_0x1ceaa7+'QueueId';socket[_0xd998('0x34')](_0xd998('0x37')+_0x1ceaa7+_0xd998('0xbc'),{'UserId':_0x438007,['queueField']:_0xcc9c56[_0x2863ed]['id']});}})[_0xd998('0x31')](respondWithStatusCode(_0x2ce529,null))['catch'](APIHandleError(_0x2ce529));};exports[_0xd998('0x126')]=function(_0x405f4a,_0x51d1a4){var _0x4b77ec={};var _0x2a2c9c={};var _0x22d8d5;var _0x5d2f10;return db[_0xd998('0x54')]['findOne']({'where':{'id':_0x405f4a[_0xd998('0x5f')]['id']}})['then'](handleEntityNotFound(_0x51d1a4,null))[_0xd998('0x31')](function(_0x25f3bc){if(_0x25f3bc){_0x22d8d5=_0x25f3bc;_0x2a2c9c[_0xd998('0xdc')]=_[_0xd998('0xd8')](db[_0xd998('0x127')][_0xd998('0x42')]);_0x2a2c9c[_0xd998('0x4f')]=_[_0xd998('0xd8')](_0x405f4a[_0xd998('0x4f')]);_0x2a2c9c['filters']=_[_0xd998('0xdb')](_0x2a2c9c[_0xd998('0xdc')],_0x2a2c9c[_0xd998('0x4f')]);_0x4b77ec['attributes']=_[_0xd998('0xdb')](_0x2a2c9c[_0xd998('0xdc')],qs[_0xd998('0xdd')](_0x405f4a[_0xd998('0x4f')][_0xd998('0xdd')]));_0x4b77ec[_0xd998('0x63')]=_0x4b77ec[_0xd998('0x63')][_0xd998('0x94')]?_0x4b77ec[_0xd998('0x63')]:_0x2a2c9c[_0xd998('0xdc')];_0x4b77ec[_0xd998('0xde')]=qs[_0xd998('0xdf')](_0x405f4a[_0xd998('0x4f')][_0xd998('0xdf')]);_0x4b77ec[_0xd998('0x4d')]=qs[_0xd998('0xda')](_[_0xd998('0xe4')](_0x405f4a[_0xd998('0x4f')],_0x2a2c9c[_0xd998('0xda')]));if(_0x405f4a['query'][_0xd998('0x46')]){_0x4b77ec[_0xd998('0x4d')]=_['merge'](_0x4b77ec['where'],{'$or':_[_0xd998('0x3c')](_0x4b77ec[_0xd998('0x63')],function(_0x4801e3){var _0x51ca0a={};_0x51ca0a[_0x4801e3]={'$like':'%'+_0x405f4a[_0xd998('0x4f')]['filter']+'%'};return _0x51ca0a;})});}_0x4b77ec=_[_0xd998('0xe0')]({},_0x4b77ec,_0x405f4a[_0xd998('0x62')]);return _0x22d8d5[_0xd998('0x126')](_0x4b77ec);}})[_0xd998('0x31')](function(_0x164062){if(_0x164062){_0x5d2f10=_0x164062[_0xd998('0x94')];if(!_0x405f4a[_0xd998('0x4f')][_0xd998('0xd2')](_0xd998('0xe2'))){_0x4b77ec[_0xd998('0x20')]=qs[_0xd998('0x20')](_0x405f4a['query'][_0xd998('0x20')]);_0x4b77ec[_0xd998('0x1e')]=qs[_0xd998('0x1e')](_0x405f4a['query'][_0xd998('0x1e')]);}return _0x22d8d5[_0xd998('0x126')](_0x4b77ec);}})[_0xd998('0x31')](function(_0x593beb){if(_0x593beb){return _0x593beb?{'count':_0x5d2f10,'rows':_0x593beb}:null;}})[_0xd998('0x31')](respondWithResult(_0x51d1a4,null))['catch'](handleError(_0x51d1a4,null));};exports['getAgents']=function(_0xaf2211,_0x107af6){var _0x1233c5={};var _0x84964f={};var _0x32fe8f;return db[_0xd998('0x54')]['findOne']({'where':{'id':_0xaf2211[_0xd998('0x5f')]['id']}})[_0xd998('0x31')](handleEntityNotFound(_0x107af6,null))[_0xd998('0x31')](function(_0x24dd7a){if(_0x24dd7a){_0x32fe8f=_0x24dd7a;_0x84964f['model']=_[_0xd998('0xd8')](db['User'][_0xd998('0x42')]);_0x84964f[_0xd998('0x4f')]=_[_0xd998('0xd8')](_0xaf2211[_0xd998('0x4f')]);_0x84964f['filters']=_[_0xd998('0xdb')](_0x84964f[_0xd998('0xdc')],_0x84964f['query']);_0x1233c5[_0xd998('0x63')]=_['intersection'](_0x84964f[_0xd998('0xdc')],qs['fields'](_0xaf2211[_0xd998('0x4f')][_0xd998('0xdd')]));_0x1233c5[_0xd998('0x63')]=_0x1233c5[_0xd998('0x63')][_0xd998('0x94')]?_0x1233c5[_0xd998('0x63')]:_0x84964f[_0xd998('0xdc')];_0x1233c5[_0xd998('0xde')]=qs['sort'](_0xaf2211[_0xd998('0x4f')][_0xd998('0xdf')]);_0x1233c5['where']=qs['filters'](_[_0xd998('0xe4')](_0xaf2211[_0xd998('0x4f')],_0x84964f[_0xd998('0xda')]));if(_0xaf2211[_0xd998('0x4f')][_0xd998('0x46')]){_0x1233c5[_0xd998('0x4d')]=_[_0xd998('0xe0')](_0x1233c5[_0xd998('0x4d')],{'$or':_[_0xd998('0x3c')](_0x1233c5[_0xd998('0x63')],function(_0x562707){var _0x37c50f={};_0x37c50f[_0x562707]={'$like':'%'+_0xaf2211['query'][_0xd998('0x46')]+'%'};return _0x37c50f;})});}_0x1233c5[_0xd998('0xdc')]=db[_0xd998('0x54')];_0x1233c5['as']=_0xd998('0x38');_0x1233c5=_['merge']({},_0x1233c5,_0xaf2211['options']);return _0x32fe8f[_0xd998('0x100')]({'include':[_0x1233c5]});}})[_0xd998('0x31')](function(_0x357a4b){if(_0x357a4b){var _0x56f731={},_0x157a0f=[];for(var _0x3741be=0x0;_0x3741be<_0x357a4b[_0xd998('0x94')];_0x3741be+=0x1){for(var _0x887bde=0x0,_0x2d0759;_0x887bde<_0x357a4b[_0x3741be][_0xd998('0x38')]['length'];_0x887bde+=0x1){_0x2d0759=_0x357a4b[_0x3741be][_0xd998('0x38')][_0x887bde]['get']({'plain':!![]});_0x56f731[_0x2d0759['id']]=_0x2d0759;}}_0x56f731=_[_0xd998('0x128')](_0x56f731);for(var _0x493875=qs[_0xd998('0x1e')](_0xaf2211['query'][_0xd998('0x1e')]);_0x493875<_0x56f731[_0xd998('0x94')]&&_0x157a0f[_0xd998('0x94')]<qs[_0xd998('0x20')](_0xaf2211['query'][_0xd998('0x20')]);_0x493875+=0x1){if(_0x56f731[_0x493875]){_0x157a0f[_0xd998('0x53')](_0x56f731[_0x493875]);}}return{'count':_0x56f731[_0xd998('0x94')],'rows':_0x157a0f};}})[_0xd998('0x31')](respondWithResult(_0x107af6,null))[_0xd998('0x2f')](handleError(_0x107af6,null));};exports[_0xd998('0x40')]=function(_0xf383b,_0x58be63){if(_0xf383b[_0xd998('0x37')]['id']==_0xf383b[_0xd998('0x5f')]['id']){throw new APIForbiddenError(_0xd998('0x129'));}return db['User'][_0xd998('0x3e')]({'where':{'id':_0xf383b['params']['id']}})['then'](function(_0x487fd3){if(!_0x487fd3){throw new APINotFoundError(util[_0xd998('0xd1')]('User\x20with\x20id\x20%s\x20not\x20found',_0xf383b[_0xd998('0x5f')]['id']));}return db[_0xd998('0x72')]['transaction'](function(_0x1b0b54){return db['CmHopper'][_0xd998('0x30')]({'recallme':![]},{'where':{'UserId':_0xf383b['params']['id']},'transaction':_0x1b0b54})[_0xd998('0x31')](function(){return removeEntity(_0x58be63,_0x1b0b54)(_0x487fd3);});});})[_0xd998('0x2f')](APIHandleError(_0x58be63));};exports[_0xd998('0x12a')]=function(_0xc753fa,_0xfc1b65){return db['User'][_0xd998('0x3e')]({'where':{'id':_0xc753fa[_0xd998('0x5f')]['id']}})['then'](handleEntityNotFound(_0xfc1b65,null))[_0xd998('0x31')](function(_0x4c1c2c){if(_0x4c1c2c){return _0x4c1c2c['addChatInteractions'](_0xc753fa[_0xd998('0x66')][_0xd998('0xac')],_[_0xd998('0x69')](_0xc753fa[_0xd998('0x66')],[_0xd998('0xac'),'id'])||{})[_0xd998('0xae')](function(){for(var _0x5738a3=0x0;_0x5738a3<_0xc753fa[_0xd998('0x66')]['ids'][_0xd998('0x94')];_0x5738a3+=0x1){socket[_0xd998('0x34')]('user_has_chat_interactions:save',{'ChatInteractionId':Number(_0xc753fa[_0xd998('0x66')][_0xd998('0xac')][_0x5738a3]),'UserId':Number(_0xc753fa[_0xd998('0x5f')]['id'])});}return _0xc753fa[_0xd998('0x66')][_0xd998('0xac')];});}})[_0xd998('0x31')](respondWithResult(_0xfc1b65,null))[_0xd998('0x2f')](handleError(_0xfc1b65,null));};exports[_0xd998('0x12b')]=function(_0x311f1b,_0x10e606){return db['User'][_0xd998('0x3e')]({'where':{'id':_0x311f1b[_0xd998('0x5f')]['id']}})[_0xd998('0x31')](handleEntityNotFound(_0x10e606,null))[_0xd998('0x31')](function(_0x3cba04){if(_0x3cba04){return _0x3cba04['removeChatInteractions'](_0x311f1b['query'][_0xd998('0xac')])[_0xd998('0x31')](function(){if(_[_0xd998('0xbb')](_0x311f1b['query'][_0xd998('0xac')])){for(var _0x2adaf7=0x0;_0x2adaf7<_0x311f1b['query']['ids']['length'];_0x2adaf7+=0x1){socket[_0xd998('0x34')]('user_has_chat_interactions:remove',{'ChatInteractionId':Number(_0x311f1b['query'][_0xd998('0xac')][_0x2adaf7]),'UserId':Number(_0x311f1b[_0xd998('0x5f')]['id'])});}}else{socket['emit'](_0xd998('0x12c'),{'ChatInteractionId':Number(_0x311f1b['query'][_0xd998('0xac')]),'UserId':Number(_0x311f1b[_0xd998('0x5f')]['id'])});}});}})['then'](respondWithStatusCode(_0x10e606,null))[_0xd998('0x2f')](handleError(_0x10e606,null));};exports[_0xd998('0x12d')]=function(_0x22efd7,_0x447932){return db[_0xd998('0x54')][_0xd998('0x3e')]({'where':{'id':_0x22efd7[_0xd998('0x5f')]['id']}})['then'](handleEntityNotFound(_0x447932,null))[_0xd998('0x31')](function(_0x337459){if(_0x337459){return _0x337459[_0xd998('0x12d')](_0x22efd7['body']['ids'],_[_0xd998('0x69')](_0x22efd7[_0xd998('0x66')],[_0xd998('0xac'),'id'])||{})[_0xd998('0xae')](function(){for(var _0x501646=0x0;_0x501646<_0x22efd7[_0xd998('0x66')][_0xd998('0xac')][_0xd998('0x94')];_0x501646+=0x1){socket[_0xd998('0x34')]('user_has_mail_interactions:save',{'MailInteractionId':Number(_0x22efd7[_0xd998('0x66')][_0xd998('0xac')][_0x501646]),'UserId':Number(_0x22efd7[_0xd998('0x5f')]['id'])});}return _0x22efd7[_0xd998('0x66')][_0xd998('0xac')];});}})[_0xd998('0x31')](respondWithResult(_0x447932,null))[_0xd998('0x2f')](handleError(_0x447932,null));};exports[_0xd998('0x12e')]=function(_0x21a647,_0x155e9f){return db[_0xd998('0x54')][_0xd998('0x3e')]({'where':{'id':_0x21a647[_0xd998('0x5f')]['id']}})[_0xd998('0x31')](handleEntityNotFound(_0x155e9f,null))[_0xd998('0x31')](function(_0xe03c3){if(_0xe03c3){return _0xe03c3[_0xd998('0x12e')](_0x21a647[_0xd998('0x4f')]['ids'])['then'](function(){if(_[_0xd998('0xbb')](_0x21a647[_0xd998('0x4f')][_0xd998('0xac')])){for(var _0x1fb1df=0x0;_0x1fb1df<_0x21a647[_0xd998('0x4f')][_0xd998('0xac')][_0xd998('0x94')];_0x1fb1df+=0x1){socket[_0xd998('0x34')](_0xd998('0x12f'),{'MailInteractionId':Number(_0x21a647[_0xd998('0x4f')]['ids'][_0x1fb1df]),'UserId':Number(_0x21a647[_0xd998('0x5f')]['id'])});}}else{socket[_0xd998('0x34')](_0xd998('0x12f'),{'MailInteractionId':Number(_0x21a647['query'][_0xd998('0xac')]),'UserId':Number(_0x21a647[_0xd998('0x5f')]['id'])});}});}})['then'](respondWithStatusCode(_0x155e9f,null))[_0xd998('0x2f')](handleError(_0x155e9f,null));};exports[_0xd998('0x130')]=function(_0x17c296,_0x373b62){return db[_0xd998('0x54')][_0xd998('0x3e')]({'where':{'id':_0x17c296['params']['id']}})[_0xd998('0x31')](handleEntityNotFound(_0x373b62,null))[_0xd998('0x31')](function(_0x6d8a49){if(_0x6d8a49){return _0x6d8a49[_0xd998('0x130')](_0x17c296[_0xd998('0x66')][_0xd998('0xac')],_[_0xd998('0x69')](_0x17c296[_0xd998('0x66')],[_0xd998('0xac'),'id'])||{})[_0xd998('0xae')](function(){for(var _0x518cbd=0x0;_0x518cbd<_0x17c296[_0xd998('0x66')]['ids'][_0xd998('0x94')];_0x518cbd+=0x1){socket['emit'](_0xd998('0x131'),{'FaxInteractionId':Number(_0x17c296[_0xd998('0x66')][_0xd998('0xac')][_0x518cbd]),'UserId':Number(_0x17c296[_0xd998('0x5f')]['id'])});}return _0x17c296[_0xd998('0x66')][_0xd998('0xac')];});}})[_0xd998('0x31')](respondWithResult(_0x373b62,null))[_0xd998('0x2f')](handleError(_0x373b62,null));};exports[_0xd998('0x132')]=function(_0x540b73,_0x3539e4){return db[_0xd998('0x54')][_0xd998('0x3e')]({'where':{'id':_0x540b73[_0xd998('0x5f')]['id']}})['then'](handleEntityNotFound(_0x3539e4,null))[_0xd998('0x31')](function(_0xb26c1f){if(_0xb26c1f){return _0xb26c1f[_0xd998('0x132')](_0x540b73[_0xd998('0x4f')][_0xd998('0xac')])[_0xd998('0x31')](function(){if(_['isArray'](_0x540b73[_0xd998('0x4f')][_0xd998('0xac')])){for(var _0x3c8674=0x0;_0x3c8674<_0x540b73[_0xd998('0x4f')][_0xd998('0xac')][_0xd998('0x94')];_0x3c8674+=0x1){socket[_0xd998('0x34')](_0xd998('0x133'),{'FaxInteractionId':Number(_0x540b73['query'][_0xd998('0xac')][_0x3c8674]),'UserId':Number(_0x540b73[_0xd998('0x5f')]['id'])});}}else{socket[_0xd998('0x34')](_0xd998('0x133'),{'FaxInteractionId':Number(_0x540b73[_0xd998('0x4f')][_0xd998('0xac')]),'UserId':Number(_0x540b73['params']['id'])});}});}})[_0xd998('0x31')](respondWithStatusCode(_0x3539e4,null))['catch'](handleError(_0x3539e4,null));};exports['addSmsInteractions']=function(_0x22a8df,_0xa9befd){return db[_0xd998('0x54')][_0xd998('0x3e')]({'where':{'id':_0x22a8df[_0xd998('0x5f')]['id']}})[_0xd998('0x31')](handleEntityNotFound(_0xa9befd,null))[_0xd998('0x31')](function(_0x1a3dfd){if(_0x1a3dfd){return _0x1a3dfd[_0xd998('0x134')](_0x22a8df[_0xd998('0x66')][_0xd998('0xac')],_[_0xd998('0x69')](_0x22a8df[_0xd998('0x66')],[_0xd998('0xac'),'id'])||{})[_0xd998('0xae')](function(){for(var _0x522e58=0x0;_0x522e58<_0x22a8df[_0xd998('0x66')][_0xd998('0xac')][_0xd998('0x94')];_0x522e58+=0x1){socket[_0xd998('0x34')](_0xd998('0x135'),{'SmsInteractionId':Number(_0x22a8df[_0xd998('0x66')][_0xd998('0xac')][_0x522e58]),'UserId':Number(_0x22a8df['params']['id'])});}return _0x22a8df[_0xd998('0x66')]['ids'];});}})[_0xd998('0x31')](respondWithResult(_0xa9befd,null))[_0xd998('0x2f')](handleError(_0xa9befd,null));};exports['removeSmsInteractions']=function(_0x303a81,_0x599f97){return db[_0xd998('0x54')][_0xd998('0x3e')]({'where':{'id':_0x303a81[_0xd998('0x5f')]['id']}})[_0xd998('0x31')](handleEntityNotFound(_0x599f97,null))[_0xd998('0x31')](function(_0x324808){if(_0x324808){return _0x324808[_0xd998('0x136')](_0x303a81[_0xd998('0x4f')][_0xd998('0xac')])[_0xd998('0x31')](function(){if(_['isArray'](_0x303a81[_0xd998('0x4f')][_0xd998('0xac')])){for(var _0x2a3df7=0x0;_0x2a3df7<_0x303a81['query']['ids'][_0xd998('0x94')];_0x2a3df7+=0x1){socket['emit'](_0xd998('0x137'),{'SmsInteractionId':Number(_0x303a81[_0xd998('0x4f')][_0xd998('0xac')][_0x2a3df7]),'UserId':Number(_0x303a81[_0xd998('0x5f')]['id'])});}}else{socket[_0xd998('0x34')](_0xd998('0x137'),{'SmsInteractionId':Number(_0x303a81[_0xd998('0x4f')][_0xd998('0xac')]),'UserId':Number(_0x303a81[_0xd998('0x5f')]['id'])});}});}})['then'](respondWithStatusCode(_0x599f97,null))[_0xd998('0x2f')](handleError(_0x599f97,null));};exports[_0xd998('0x138')]=function(_0x28aab2,_0x5473a2){return db[_0xd998('0x54')][_0xd998('0x3e')]({'where':{'id':_0x28aab2[_0xd998('0x5f')]['id']}})[_0xd998('0x31')](handleEntityNotFound(_0x5473a2,null))['then'](function(_0x59f122){if(_0x59f122){return _0x59f122[_0xd998('0x138')](_0x28aab2[_0xd998('0x66')][_0xd998('0xac')],_['omit'](_0x28aab2[_0xd998('0x66')],[_0xd998('0xac'),'id'])||{})[_0xd998('0xae')](function(){for(var _0x27e798=0x0;_0x27e798<_0x28aab2[_0xd998('0x66')][_0xd998('0xac')]['length'];_0x27e798+=0x1){socket['emit'](_0xd998('0x139'),{'OpenchannelInteractionId':Number(_0x28aab2[_0xd998('0x66')][_0xd998('0xac')][_0x27e798]),'UserId':Number(_0x28aab2['params']['id'])});}return _0x28aab2['body'][_0xd998('0xac')];});}})[_0xd998('0x31')](respondWithResult(_0x5473a2,null))['catch'](handleError(_0x5473a2,null));};exports[_0xd998('0x13a')]=function(_0x4c0617,_0xa307f0){return db['User'][_0xd998('0x3e')]({'where':{'id':_0x4c0617['params']['id']}})[_0xd998('0x31')](handleEntityNotFound(_0xa307f0,null))[_0xd998('0x31')](function(_0x418e81){if(_0x418e81){return _0x418e81[_0xd998('0x13a')](_0x4c0617['query'][_0xd998('0xac')])[_0xd998('0x31')](function(){if(_[_0xd998('0xbb')](_0x4c0617[_0xd998('0x4f')][_0xd998('0xac')])){for(var _0xde1cdf=0x0;_0xde1cdf<_0x4c0617[_0xd998('0x4f')][_0xd998('0xac')]['length'];_0xde1cdf+=0x1){socket[_0xd998('0x34')]('user_has_openchannel_interactions:remove',{'OpenchannelInteractionId':Number(_0x4c0617[_0xd998('0x4f')][_0xd998('0xac')][_0xde1cdf]),'UserId':Number(_0x4c0617[_0xd998('0x5f')]['id'])});}}else{socket[_0xd998('0x34')](_0xd998('0x13b'),{'OpenchannelInteractionId':Number(_0x4c0617['query'][_0xd998('0xac')]),'UserId':Number(_0x4c0617[_0xd998('0x5f')]['id'])});}});}})[_0xd998('0x31')](respondWithStatusCode(_0xa307f0,null))[_0xd998('0x2f')](handleError(_0xa307f0,null));};exports[_0xd998('0x13c')]=function(_0x50653e,_0x389b5c){return db[_0xd998('0x54')][_0xd998('0x3e')]({'where':{'id':_0x50653e[_0xd998('0x5f')]['id']}})['then'](handleEntityNotFound(_0x389b5c,null))[_0xd998('0x31')](function(_0x16e354){if(_0x16e354){return _0x16e354['addWhatsappInteractions'](_0x50653e['body']['ids'],_[_0xd998('0x69')](_0x50653e[_0xd998('0x66')],[_0xd998('0xac'),'id'])||{})[_0xd998('0xae')](function(){for(var _0x196422=0x0;_0x196422<_0x50653e[_0xd998('0x66')][_0xd998('0xac')][_0xd998('0x94')];_0x196422+=0x1){socket[_0xd998('0x34')]('user_has_whatsapp_interactions:save',{'WhatsappInteractionId':Number(_0x50653e[_0xd998('0x66')][_0xd998('0xac')][_0x196422]),'UserId':Number(_0x50653e[_0xd998('0x5f')]['id'])});}return _0x50653e[_0xd998('0x66')]['ids'];});}})['then'](respondWithResult(_0x389b5c,null))[_0xd998('0x2f')](handleError(_0x389b5c,null));};exports[_0xd998('0x13d')]=function(_0x5863c1,_0x11eab2){return db[_0xd998('0x54')][_0xd998('0x3e')]({'where':{'id':_0x5863c1['params']['id']}})['then'](handleEntityNotFound(_0x11eab2,null))[_0xd998('0x31')](function(_0x4a0c13){if(_0x4a0c13){return _0x4a0c13['removeWhatsappInteractions'](_0x5863c1[_0xd998('0x4f')]['ids']);}})['then'](respondWithStatusCode(_0x11eab2,null))[_0xd998('0x2f')](handleError(_0x11eab2,null));};exports[_0xd998('0x13e')]=function(_0x22dabb,_0x3173b5){var _0x50355a={};var _0x1f3570={};var _0x10783b;var _0x212f46;return db[_0xd998('0x54')][_0xd998('0x9e')]({'where':{'id':_0x22dabb[_0xd998('0x5f')]['id']}})[_0xd998('0x31')](handleEntityNotFound(_0x3173b5,null))['then'](function(_0x51ac44){if(_0x51ac44){_0x10783b=_0x51ac44;_0x1f3570[_0xd998('0xdc')]=_[_0xd998('0xd8')](db['VoicePrefix']['rawAttributes']);_0x1f3570[_0xd998('0x4f')]=_['keys'](_0x22dabb[_0xd998('0x4f')]);_0x1f3570[_0xd998('0xda')]=_['intersection'](_0x1f3570[_0xd998('0xdc')],_0x1f3570[_0xd998('0x4f')]);_0x50355a[_0xd998('0x63')]=_[_0xd998('0xdb')](_0x1f3570[_0xd998('0xdc')],qs[_0xd998('0xdd')](_0x22dabb[_0xd998('0x4f')]['fields']));_0x50355a[_0xd998('0x63')]=_0x50355a[_0xd998('0x63')][_0xd998('0x94')]?_0x50355a[_0xd998('0x63')]:_0x1f3570['model'];_0x50355a['order']=qs['sort'](_0x22dabb['query']['sort']);_0x50355a[_0xd998('0x4d')]=qs[_0xd998('0xda')](_['pick'](_0x22dabb['query'],_0x1f3570[_0xd998('0xda')]));if(_0x22dabb[_0xd998('0x4f')][_0xd998('0x46')]){_0x50355a[_0xd998('0x4d')]=_['merge'](_0x50355a[_0xd998('0x4d')],{'$or':_[_0xd998('0x3c')](_0x50355a[_0xd998('0x63')],function(_0x11c668){var _0x2f1fdf={};_0x2f1fdf[_0x11c668]={'$like':'%'+_0x22dabb[_0xd998('0x4f')][_0xd998('0x46')]+'%'};return _0x2f1fdf;})});}_0x50355a=_['merge']({},_0x50355a,_0x22dabb['options']);return _0x10783b[_0xd998('0x13e')](_0x50355a);}})[_0xd998('0x31')](function(_0x1bb73a){if(_0x1bb73a){_0x212f46=_0x1bb73a[_0xd998('0x94')];if(!_0x22dabb[_0xd998('0x4f')][_0xd998('0xd2')](_0xd998('0xe2'))){_0x50355a['limit']=qs[_0xd998('0x20')](_0x22dabb[_0xd998('0x4f')]['limit']);_0x50355a['offset']=qs[_0xd998('0x1e')](_0x22dabb['query'][_0xd998('0x1e')]);}return _0x10783b[_0xd998('0x13e')](_0x50355a);}})[_0xd998('0x31')](function(_0x26ed6a){if(_0x26ed6a){return _0x26ed6a?{'count':_0x212f46,'rows':_0x26ed6a}:null;}})[_0xd998('0x31')](respondWithResult(_0x3173b5,null))['catch'](handleError(_0x3173b5,null));};exports[_0xd998('0x13f')]=function(_0x362d1a,_0x1784cf){var _0x5813a1={};var _0x55aa94={};var _0x2ad372;var _0x4044cc;return db['User'][_0xd998('0x9e')]({'where':{'id':_0x362d1a[_0xd998('0x5f')]['id']}})[_0xd998('0x31')](handleEntityNotFound(_0x1784cf,null))[_0xd998('0x31')](function(_0x2a6a24){if(_0x2a6a24){_0x2ad372=_0x2a6a24;_0x55aa94[_0xd998('0xdc')]=_['keys'](db[_0xd998('0x140')][_0xd998('0x42')]);_0x55aa94[_0xd998('0x4f')]=_[_0xd998('0xd8')](_0x362d1a[_0xd998('0x4f')]);_0x55aa94[_0xd998('0xda')]=_[_0xd998('0xdb')](_0x55aa94[_0xd998('0xdc')],_0x55aa94[_0xd998('0x4f')]);_0x5813a1[_0xd998('0x63')]=_[_0xd998('0xdb')](_0x55aa94[_0xd998('0xdc')],qs['fields'](_0x362d1a[_0xd998('0x4f')][_0xd998('0xdd')]));_0x5813a1[_0xd998('0x63')]=_0x5813a1[_0xd998('0x63')]['length']?_0x5813a1[_0xd998('0x63')]:_0x55aa94[_0xd998('0xdc')];_0x5813a1['order']=qs[_0xd998('0xdf')](_0x362d1a['query']['sort']);_0x5813a1[_0xd998('0x4d')]=qs[_0xd998('0xda')](_[_0xd998('0xe4')](_0x362d1a[_0xd998('0x4f')],_0x55aa94[_0xd998('0xda')]));if(_0x362d1a[_0xd998('0x4f')]['filter']){_0x5813a1[_0xd998('0x4d')]=_[_0xd998('0xe0')](_0x5813a1[_0xd998('0x4d')],{'$or':_[_0xd998('0x3c')](_0x5813a1[_0xd998('0x63')],function(_0x365683){var _0x329a96={};_0x329a96[_0x365683]={'$like':'%'+_0x362d1a[_0xd998('0x4f')][_0xd998('0x46')]+'%'};return _0x329a96;})});}_0x5813a1=_[_0xd998('0xe0')]({},_0x5813a1,_0x362d1a['options']);return _0x2ad372[_0xd998('0x13f')](_0x5813a1);}})[_0xd998('0x31')](function(_0x43312a){if(_0x43312a){_0x4044cc=_0x43312a[_0xd998('0x94')];if(!_0x362d1a[_0xd998('0x4f')][_0xd998('0xd2')](_0xd998('0xe2'))){_0x5813a1[_0xd998('0x20')]=qs['limit'](_0x362d1a['query'][_0xd998('0x20')]);_0x5813a1[_0xd998('0x1e')]=qs[_0xd998('0x1e')](_0x362d1a[_0xd998('0x4f')]['offset']);}return _0x2ad372[_0xd998('0x13f')](_0x5813a1);}})[_0xd998('0x31')](function(_0x687b6f){if(_0x687b6f){return _0x687b6f?{'count':_0x4044cc,'rows':_0x687b6f}:null;}})[_0xd998('0x31')](respondWithResult(_0x1784cf,null))[_0xd998('0x2f')](handleError(_0x1784cf,null));};exports[_0xd998('0x141')]=function(_0x391883,_0x24c7a2){return db['User'][_0xd998('0x3e')]({'where':{'id':_0x391883[_0xd998('0x5f')]['id']}})[_0xd998('0x31')](handleEntityNotFound(_0x24c7a2,null))[_0xd998('0x31')](function(_0x1949f6){if(_0x1949f6){return _0x1949f6[_0xd998('0x141')](_0x391883['body'][_0xd998('0xac')],_[_0xd998('0x69')](_0x391883['body'],[_0xd998('0xac'),'id'])||{});}})[_0xd998('0x31')](respondWithResult(_0x24c7a2,null))[_0xd998('0x2f')](handleError(_0x24c7a2,null));};exports['removeFaxAccounts']=function(_0x528045,_0x46586c){return db[_0xd998('0x54')][_0xd998('0x3e')]({'where':{'id':_0x528045[_0xd998('0x5f')]['id']}})['then'](handleEntityNotFound(_0x46586c,null))[_0xd998('0x31')](function(_0x325dba){if(_0x325dba){return _0x325dba[_0xd998('0x142')](_0x528045[_0xd998('0x4f')][_0xd998('0xac')]);}})[_0xd998('0x31')](respondWithStatusCode(_0x46586c,null))[_0xd998('0x2f')](handleError(_0x46586c,null));};exports[_0xd998('0x143')]=function(_0x16ed8e,_0x27f930){var _0xdffa83={};var _0x1c2d5a={};var _0x40d6fc;var _0x304db4;return db[_0xd998('0x54')][_0xd998('0x9e')]({'where':{'id':_0x16ed8e[_0xd998('0x5f')]['id']}})[_0xd998('0x31')](handleEntityNotFound(_0x27f930,null))[_0xd998('0x31')](function(_0x56c763){if(_0x56c763){_0x40d6fc=_0x56c763;_0x1c2d5a[_0xd998('0xdc')]=_['keys'](db[_0xd998('0x144')][_0xd998('0x42')]);_0x1c2d5a['query']=_[_0xd998('0xd8')](_0x16ed8e['query']);_0x1c2d5a[_0xd998('0xda')]=_[_0xd998('0xdb')](_0x1c2d5a[_0xd998('0xdc')],_0x1c2d5a[_0xd998('0x4f')]);_0xdffa83['attributes']=_[_0xd998('0xdb')](_0x1c2d5a[_0xd998('0xdc')],qs[_0xd998('0xdd')](_0x16ed8e['query']['fields']));_0xdffa83[_0xd998('0x63')]=_0xdffa83[_0xd998('0x63')]['length']?_0xdffa83[_0xd998('0x63')]:_0x1c2d5a['model'];_0xdffa83[_0xd998('0xde')]=qs['sort'](_0x16ed8e['query']['sort']);_0xdffa83['where']=qs[_0xd998('0xda')](_[_0xd998('0xe4')](_0x16ed8e[_0xd998('0x4f')],_0x1c2d5a[_0xd998('0xda')]));if(_0x16ed8e[_0xd998('0x4f')][_0xd998('0x46')]){_0xdffa83[_0xd998('0x4d')]=_[_0xd998('0xe0')](_0xdffa83[_0xd998('0x4d')],{'$or':_[_0xd998('0x3c')](_0xdffa83[_0xd998('0x63')],function(_0x3668c5){var _0x30a273={};_0x30a273[_0x3668c5]={'$like':'%'+_0x16ed8e['query']['filter']+'%'};return _0x30a273;})});}_0xdffa83=_[_0xd998('0xe0')]({},_0xdffa83,_0x16ed8e[_0xd998('0x62')]);return _0x40d6fc[_0xd998('0x143')](_0xdffa83);}})[_0xd998('0x31')](function(_0x379d3c){if(_0x379d3c){_0x304db4=_0x379d3c['length'];if(!_0x16ed8e[_0xd998('0x4f')][_0xd998('0xd2')](_0xd998('0xe2'))){_0xdffa83[_0xd998('0x20')]=qs[_0xd998('0x20')](_0x16ed8e[_0xd998('0x4f')][_0xd998('0x20')]);_0xdffa83[_0xd998('0x1e')]=qs['offset'](_0x16ed8e[_0xd998('0x4f')]['offset']);}return _0x40d6fc['getMailAccounts'](_0xdffa83);}})[_0xd998('0x31')](function(_0x1d2e02){if(_0x1d2e02){return _0x1d2e02?{'count':_0x304db4,'rows':_0x1d2e02}:null;}})[_0xd998('0x31')](respondWithResult(_0x27f930,null))[_0xd998('0x2f')](handleError(_0x27f930,null));};exports[_0xd998('0x145')]=function(_0x205a29,_0x44dbc1){return db[_0xd998('0x54')][_0xd998('0x3e')]({'where':{'id':_0x205a29[_0xd998('0x5f')]['id']}})[_0xd998('0x31')](handleEntityNotFound(_0x44dbc1,null))[_0xd998('0x31')](function(_0x4fc0af){if(_0x4fc0af){return _0x4fc0af[_0xd998('0x145')](_0x205a29[_0xd998('0x66')][_0xd998('0xac')],_['omit'](_0x205a29['body'],[_0xd998('0xac'),'id'])||{});}})[_0xd998('0x31')](respondWithResult(_0x44dbc1,null))['catch'](handleError(_0x44dbc1,null));};exports[_0xd998('0x146')]=function(_0x21c19d,_0x313923){return db['User'][_0xd998('0x3e')]({'where':{'id':_0x21c19d[_0xd998('0x5f')]['id']}})['then'](handleEntityNotFound(_0x313923,null))[_0xd998('0x31')](function(_0x1546b0){if(_0x1546b0){return _0x1546b0[_0xd998('0x146')](_0x21c19d[_0xd998('0x4f')][_0xd998('0xac')]);}})[_0xd998('0x31')](respondWithStatusCode(_0x313923,null))[_0xd998('0x2f')](handleError(_0x313923,null));};exports[_0xd998('0x147')]=function(_0xd47a9f,_0x5743dc){var _0x5bb542={};var _0x446e73={};var _0x2460ea;var _0x2d8984;return db[_0xd998('0x54')][_0xd998('0x9e')]({'where':{'id':_0xd47a9f[_0xd998('0x5f')]['id']}})[_0xd998('0x31')](handleEntityNotFound(_0x5743dc,null))['then'](function(_0x4587ea){if(_0x4587ea){_0x2460ea=_0x4587ea;_0x446e73[_0xd998('0xdc')]=_['keys'](db[_0xd998('0x148')][_0xd998('0x42')]);_0x446e73[_0xd998('0x4f')]=_['keys'](_0xd47a9f[_0xd998('0x4f')]);_0x446e73[_0xd998('0xda')]=_['intersection'](_0x446e73[_0xd998('0xdc')],_0x446e73[_0xd998('0x4f')]);_0x5bb542['attributes']=_[_0xd998('0xdb')](_0x446e73[_0xd998('0xdc')],qs['fields'](_0xd47a9f[_0xd998('0x4f')][_0xd998('0xdd')]));_0x5bb542[_0xd998('0x63')]=_0x5bb542[_0xd998('0x63')][_0xd998('0x94')]?_0x5bb542['attributes']:_0x446e73[_0xd998('0xdc')];_0x5bb542[_0xd998('0xde')]=qs[_0xd998('0xdf')](_0xd47a9f[_0xd998('0x4f')]['sort']);_0x5bb542['where']=qs[_0xd998('0xda')](_[_0xd998('0xe4')](_0xd47a9f['query'],_0x446e73['filters']));if(_0xd47a9f[_0xd998('0x4f')][_0xd998('0x46')]){_0x5bb542['where']=_[_0xd998('0xe0')](_0x5bb542[_0xd998('0x4d')],{'$or':_[_0xd998('0x3c')](_0x5bb542[_0xd998('0x63')],function(_0x2eb98f){var _0x2ad28d={};_0x2ad28d[_0x2eb98f]={'$like':'%'+_0xd47a9f[_0xd998('0x4f')][_0xd998('0x46')]+'%'};return _0x2ad28d;})});}_0x5bb542=_['merge']({},_0x5bb542,_0xd47a9f[_0xd998('0x62')]);return _0x2460ea[_0xd998('0x147')](_0x5bb542);}})[_0xd998('0x31')](function(_0x290e25){if(_0x290e25){_0x2d8984=_0x290e25[_0xd998('0x94')];if(!_0xd47a9f[_0xd998('0x4f')][_0xd998('0xd2')](_0xd998('0xe2'))){_0x5bb542['limit']=qs['limit'](_0xd47a9f['query']['limit']);_0x5bb542['offset']=qs['offset'](_0xd47a9f[_0xd998('0x4f')][_0xd998('0x1e')]);}return _0x2460ea[_0xd998('0x147')](_0x5bb542);}})['then'](function(_0x43c390){if(_0x43c390){return _0x43c390?{'count':_0x2d8984,'rows':_0x43c390}:null;}})[_0xd998('0x31')](respondWithResult(_0x5743dc,null))[_0xd998('0x2f')](handleError(_0x5743dc,null));};exports[_0xd998('0x149')]=function(_0x223f53,_0x45b75b){return db['User'][_0xd998('0x3e')]({'where':{'id':_0x223f53[_0xd998('0x5f')]['id']}})[_0xd998('0x31')](handleEntityNotFound(_0x45b75b,null))['then'](function(_0xaf1086){if(_0xaf1086){return _0xaf1086[_0xd998('0x149')](_0x223f53[_0xd998('0x66')]['ids'],_[_0xd998('0x69')](_0x223f53[_0xd998('0x66')],[_0xd998('0xac'),'id'])||{});}})[_0xd998('0x31')](respondWithResult(_0x45b75b,null))[_0xd998('0x2f')](handleError(_0x45b75b,null));};exports['removeOpenchannelAccounts']=function(_0x5bbe97,_0x39b885){return db[_0xd998('0x54')]['find']({'where':{'id':_0x5bbe97[_0xd998('0x5f')]['id']}})[_0xd998('0x31')](handleEntityNotFound(_0x39b885,null))[_0xd998('0x31')](function(_0x5eed97){if(_0x5eed97){return _0x5eed97[_0xd998('0x14a')](_0x5bbe97[_0xd998('0x4f')][_0xd998('0xac')]);}})[_0xd998('0x31')](respondWithStatusCode(_0x39b885,null))[_0xd998('0x2f')](handleError(_0x39b885,null));};exports[_0xd998('0x14b')]=function(_0x59f7fb,_0x4810a7){var _0x1c0bf0={};var _0x2bb1de={};var _0x4927a7;var _0x53a20e;return db[_0xd998('0x54')][_0xd998('0x9e')]({'where':{'id':_0x59f7fb[_0xd998('0x5f')]['id']}})['then'](handleEntityNotFound(_0x4810a7,null))[_0xd998('0x31')](function(_0x308a3d){if(_0x308a3d){_0x4927a7=_0x308a3d;_0x2bb1de[_0xd998('0xdc')]=_[_0xd998('0xd8')](db['SmsAccount'][_0xd998('0x42')]);_0x2bb1de[_0xd998('0x4f')]=_[_0xd998('0xd8')](_0x59f7fb[_0xd998('0x4f')]);_0x2bb1de[_0xd998('0xda')]=_[_0xd998('0xdb')](_0x2bb1de[_0xd998('0xdc')],_0x2bb1de[_0xd998('0x4f')]);_0x1c0bf0[_0xd998('0x63')]=_['intersection'](_0x2bb1de[_0xd998('0xdc')],qs['fields'](_0x59f7fb[_0xd998('0x4f')][_0xd998('0xdd')]));_0x1c0bf0['attributes']=_0x1c0bf0['attributes']['length']?_0x1c0bf0[_0xd998('0x63')]:_0x2bb1de[_0xd998('0xdc')];_0x1c0bf0['order']=qs[_0xd998('0xdf')](_0x59f7fb[_0xd998('0x4f')][_0xd998('0xdf')]);_0x1c0bf0[_0xd998('0x4d')]=qs[_0xd998('0xda')](_[_0xd998('0xe4')](_0x59f7fb['query'],_0x2bb1de[_0xd998('0xda')]));if(_0x59f7fb[_0xd998('0x4f')][_0xd998('0x46')]){_0x1c0bf0[_0xd998('0x4d')]=_[_0xd998('0xe0')](_0x1c0bf0['where'],{'$or':_['map'](_0x1c0bf0['attributes'],function(_0x400c35){var _0x2e38aa={};_0x2e38aa[_0x400c35]={'$like':'%'+_0x59f7fb[_0xd998('0x4f')][_0xd998('0x46')]+'%'};return _0x2e38aa;})});}_0x1c0bf0=_['merge']({},_0x1c0bf0,_0x59f7fb[_0xd998('0x62')]);return _0x4927a7['getSmsAccounts'](_0x1c0bf0);}})['then'](function(_0x8eb088){if(_0x8eb088){_0x53a20e=_0x8eb088[_0xd998('0x94')];if(!_0x59f7fb['query'][_0xd998('0xd2')]('nolimit')){_0x1c0bf0[_0xd998('0x20')]=qs[_0xd998('0x20')](_0x59f7fb['query'][_0xd998('0x20')]);_0x1c0bf0['offset']=qs[_0xd998('0x1e')](_0x59f7fb[_0xd998('0x4f')]['offset']);}return _0x4927a7[_0xd998('0x14b')](_0x1c0bf0);}})[_0xd998('0x31')](function(_0x2a73ad){if(_0x2a73ad){return _0x2a73ad?{'count':_0x53a20e,'rows':_0x2a73ad}:null;}})[_0xd998('0x31')](respondWithResult(_0x4810a7,null))[_0xd998('0x2f')](handleError(_0x4810a7,null));};exports[_0xd998('0x14c')]=function(_0x5aa3aa,_0x18fb15){return db[_0xd998('0x54')][_0xd998('0x3e')]({'where':{'id':_0x5aa3aa[_0xd998('0x5f')]['id']}})[_0xd998('0x31')](handleEntityNotFound(_0x18fb15,null))[_0xd998('0x31')](function(_0x2896cb){if(_0x2896cb){return _0x2896cb[_0xd998('0x14c')](_0x5aa3aa['body']['ids'],_[_0xd998('0x69')](_0x5aa3aa[_0xd998('0x66')],[_0xd998('0xac'),'id'])||{});}})[_0xd998('0x31')](respondWithResult(_0x18fb15,null))['catch'](handleError(_0x18fb15,null));};exports[_0xd998('0x14d')]=function(_0x419936,_0x137b61){return db['User'][_0xd998('0x3e')]({'where':{'id':_0x419936[_0xd998('0x5f')]['id']}})[_0xd998('0x31')](handleEntityNotFound(_0x137b61,null))[_0xd998('0x31')](function(_0x96c059){if(_0x96c059){return _0x96c059['removeSmsAccounts'](_0x419936['query']['ids']);}})[_0xd998('0x31')](respondWithStatusCode(_0x137b61,null))['catch'](handleError(_0x137b61,null));};exports[_0xd998('0x14e')]=function(_0x558651,_0x4a2a48){var _0x173757={};var _0x9ad4f0={};var _0x3b1456;var _0x1e6278;return db[_0xd998('0x54')][_0xd998('0x9e')]({'where':{'id':_0x558651[_0xd998('0x5f')]['id']}})['then'](handleEntityNotFound(_0x4a2a48,null))[_0xd998('0x31')](function(_0x197107){if(_0x197107){_0x3b1456=_0x197107;_0x9ad4f0[_0xd998('0xdc')]=_['keys'](db[_0xd998('0x14f')][_0xd998('0x42')]);_0x9ad4f0[_0xd998('0x4f')]=_[_0xd998('0xd8')](_0x558651[_0xd998('0x4f')]);_0x9ad4f0[_0xd998('0xda')]=_['intersection'](_0x9ad4f0[_0xd998('0xdc')],_0x9ad4f0[_0xd998('0x4f')]);_0x173757[_0xd998('0x63')]=_['intersection'](_0x9ad4f0[_0xd998('0xdc')],qs[_0xd998('0xdd')](_0x558651['query'][_0xd998('0xdd')]));_0x173757[_0xd998('0x63')]=_0x173757[_0xd998('0x63')]['length']?_0x173757[_0xd998('0x63')]:_0x9ad4f0[_0xd998('0xdc')];_0x173757[_0xd998('0xde')]=qs[_0xd998('0xdf')](_0x558651[_0xd998('0x4f')][_0xd998('0xdf')]);_0x173757['where']=qs['filters'](_[_0xd998('0xe4')](_0x558651[_0xd998('0x4f')],_0x9ad4f0[_0xd998('0xda')]));if(_0x558651[_0xd998('0x4f')][_0xd998('0x46')]){_0x173757['where']=_[_0xd998('0xe0')](_0x173757[_0xd998('0x4d')],{'$or':_['map'](_0x173757['attributes'],function(_0x246c4a){var _0x1e5969={};_0x1e5969[_0x246c4a]={'$like':'%'+_0x558651[_0xd998('0x4f')]['filter']+'%'};return _0x1e5969;})});}_0x173757=_[_0xd998('0xe0')]({},_0x173757,_0x558651[_0xd998('0x62')]);return _0x3b1456[_0xd998('0x14e')](_0x173757);}})['then'](function(_0x497023){if(_0x497023){_0x1e6278=_0x497023[_0xd998('0x94')];if(!_0x558651['query']['hasOwnProperty'](_0xd998('0xe2'))){_0x173757[_0xd998('0x20')]=qs[_0xd998('0x20')](_0x558651[_0xd998('0x4f')][_0xd998('0x20')]);_0x173757[_0xd998('0x1e')]=qs['offset'](_0x558651['query']['offset']);}return _0x3b1456['getChatWebsites'](_0x173757);}})[_0xd998('0x31')](function(_0xe24174){if(_0xe24174){return _0xe24174?{'count':_0x1e6278,'rows':_0xe24174}:null;}})[_0xd998('0x31')](respondWithResult(_0x4a2a48,null))[_0xd998('0x2f')](handleError(_0x4a2a48,null));};exports[_0xd998('0x150')]=function(_0x183964,_0x596072){return db['User']['find']({'where':{'id':_0x183964['params']['id']}})['then'](handleEntityNotFound(_0x596072,null))[_0xd998('0x31')](function(_0x5d3646){if(_0x5d3646){return _0x5d3646[_0xd998('0x150')](_0x183964['body'][_0xd998('0xac')],_['omit'](_0x183964[_0xd998('0x66')],[_0xd998('0xac'),'id'])||{});}})[_0xd998('0x31')](respondWithResult(_0x596072,null))[_0xd998('0x2f')](handleError(_0x596072,null));};exports[_0xd998('0x151')]=function(_0x492d73,_0x26fef7){return db[_0xd998('0x54')]['find']({'where':{'id':_0x492d73[_0xd998('0x5f')]['id']}})[_0xd998('0x31')](handleEntityNotFound(_0x26fef7,null))[_0xd998('0x31')](function(_0x1ded63){if(_0x1ded63){return _0x1ded63[_0xd998('0x151')](_0x492d73['query'][_0xd998('0xac')]);}})[_0xd998('0x31')](respondWithStatusCode(_0x26fef7,null))[_0xd998('0x2f')](handleError(_0x26fef7,null));};exports[_0xd998('0x152')]=function(_0x24061f,_0x525580){var _0x43a2a5={};var _0x1cce83={};var _0x5e3f28;var _0x947816;return db[_0xd998('0x54')][_0xd998('0x9e')]({'where':{'id':_0x24061f[_0xd998('0x5f')]['id']}})[_0xd998('0x31')](handleEntityNotFound(_0x525580,null))[_0xd998('0x31')](function(_0x51191a){if(_0x51191a){_0x5e3f28=_0x51191a;_0x1cce83['model']=_[_0xd998('0xd8')](db[_0xd998('0x153')][_0xd998('0x42')]);_0x1cce83[_0xd998('0x4f')]=_[_0xd998('0xd8')](_0x24061f[_0xd998('0x4f')]);_0x1cce83[_0xd998('0xda')]=_[_0xd998('0xdb')](_0x1cce83['model'],_0x1cce83[_0xd998('0x4f')]);_0x43a2a5[_0xd998('0x63')]=_[_0xd998('0xdb')](_0x1cce83[_0xd998('0xdc')],qs[_0xd998('0xdd')](_0x24061f['query'][_0xd998('0xdd')]));_0x43a2a5[_0xd998('0x63')]=_0x43a2a5[_0xd998('0x63')][_0xd998('0x94')]?_0x43a2a5[_0xd998('0x63')]:_0x1cce83['model'];_0x43a2a5[_0xd998('0xde')]=qs[_0xd998('0xdf')](_0x24061f[_0xd998('0x4f')][_0xd998('0xdf')]);_0x43a2a5['where']=qs[_0xd998('0xda')](_[_0xd998('0xe4')](_0x24061f[_0xd998('0x4f')],_0x1cce83[_0xd998('0xda')]));if(_0x24061f[_0xd998('0x4f')]['filter']){_0x43a2a5[_0xd998('0x4d')]=_[_0xd998('0xe0')](_0x43a2a5['where'],{'$or':_['map'](_0x43a2a5['attributes'],function(_0x346cb5){var _0x2873d4={};_0x2873d4[_0x346cb5]={'$like':'%'+_0x24061f['query'][_0xd998('0x46')]+'%'};return _0x2873d4;})});}_0x43a2a5=_[_0xd998('0xe0')]({},_0x43a2a5,_0x24061f[_0xd998('0x62')]);return _0x5e3f28[_0xd998('0x152')](_0x43a2a5);}})[_0xd998('0x31')](function(_0x5adaba){if(_0x5adaba){_0x947816=_0x5adaba[_0xd998('0x94')];if(!_0x24061f[_0xd998('0x4f')][_0xd998('0xd2')](_0xd998('0xe2'))){_0x43a2a5['limit']=qs[_0xd998('0x20')](_0x24061f['query'][_0xd998('0x20')]);_0x43a2a5[_0xd998('0x1e')]=qs[_0xd998('0x1e')](_0x24061f[_0xd998('0x4f')][_0xd998('0x1e')]);}return _0x5e3f28[_0xd998('0x152')](_0x43a2a5);}})['then'](function(_0x53a6d7){if(_0x53a6d7){return _0x53a6d7?{'count':_0x947816,'rows':_0x53a6d7}:null;}})[_0xd998('0x31')](respondWithResult(_0x525580,null))['catch'](handleError(_0x525580,null));};exports[_0xd998('0x154')]=function(_0x522a6c,_0x2f6482){return db['User'][_0xd998('0x3e')]({'where':{'id':_0x522a6c[_0xd998('0x5f')]['id']}})['then'](handleEntityNotFound(_0x2f6482,null))[_0xd998('0x31')](function(_0x3e0474){if(_0x3e0474){return _0x3e0474[_0xd998('0x154')](_0x522a6c[_0xd998('0x66')][_0xd998('0xac')],_[_0xd998('0x69')](_0x522a6c[_0xd998('0x66')],['ids','id'])||{});}})[_0xd998('0x31')](respondWithResult(_0x2f6482,null))[_0xd998('0x2f')](handleError(_0x2f6482,null));};exports[_0xd998('0x155')]=function(_0x111633,_0x2f2b97){return db[_0xd998('0x54')][_0xd998('0x3e')]({'where':{'id':_0x111633['params']['id']}})[_0xd998('0x31')](handleEntityNotFound(_0x2f2b97,null))['then'](function(_0x476277){if(_0x476277){return _0x476277[_0xd998('0x155')](_0x111633['query'][_0xd998('0xac')]);}})[_0xd998('0x31')](respondWithStatusCode(_0x2f2b97,null))['catch'](handleError(_0x2f2b97,null));};exports[_0xd998('0x156')]=function(_0x44c964,_0x24fbab){var _0x5e0cfe={},_0x530cf2={},_0x59c70a={'count':0x0,'rows':[]};var _0x45ffc8=db['CmHopper'][_0xd998('0x42')];_0x530cf2['model']=_[_0xd998('0xd8')](_0x45ffc8);_0x530cf2['query']=_[_0xd998('0xd8')](_0x44c964[_0xd998('0x4f')]);_0x530cf2[_0xd998('0xda')]=_[_0xd998('0xdb')](_0x530cf2[_0xd998('0xdc')],_0x530cf2['query']);_0x530cf2[_0xd998('0xda')]=_[_0xd998('0xd0')](_0x530cf2[_0xd998('0xda')],[_0xd998('0x157'),_0xd998('0x158'),_0xd998('0x159'),'$gte',_0xd998('0x15a'),_0xd998('0x15b'),_0xd998('0x15c'),_0xd998('0x15d'),_0xd998('0x15e'),'$between',_0xd998('0x15f'),'$in',_0xd998('0x160'),_0xd998('0x161'),_0xd998('0x162'),_0xd998('0x163'),_0xd998('0x164'),_0xd998('0x161'),_0xd998('0x165'),_0xd998('0x166'),'$contained',_0xd998('0x167')]);_0x5e0cfe[_0xd998('0x63')]=_['intersection'](_0x530cf2[_0xd998('0xdc')],qs[_0xd998('0xdd')](_0x44c964['query']['fields']));_0x5e0cfe[_0xd998('0x63')]=_0x5e0cfe[_0xd998('0x63')]['length']?_0x5e0cfe['attributes']:_0x530cf2[_0xd998('0xdc')];if(!_0x44c964[_0xd998('0x4f')][_0xd998('0xd2')](_0xd998('0xe2'))){_0x5e0cfe[_0xd998('0x20')]=qs[_0xd998('0x20')](_0x44c964['query']['limit']);_0x5e0cfe[_0xd998('0x1e')]=qs['offset'](_0x44c964[_0xd998('0x4f')][_0xd998('0x1e')]);}_0x5e0cfe[_0xd998('0xde')]=qs[_0xd998('0xdf')](_0x44c964[_0xd998('0x4f')]['sort']);_0x5e0cfe[_0xd998('0x4d')]=qs[_0xd998('0xda')](_['pick'](_0x44c964[_0xd998('0x4f')],_0x530cf2[_0xd998('0xda')]));if(_0x44c964['query'][_0xd998('0x46')]){_0x5e0cfe[_0xd998('0x4d')]=_[_0xd998('0xe0')](_0x5e0cfe['where'],{'$or':_[_0xd998('0x3c')](_0x5e0cfe['attributes'],function(_0x3b438b){var _0x28aa63={};_0x28aa63[_0x3b438b]={'$like':'%'+_0x44c964[_0xd998('0x4f')]['filter']+'%'};return _0x28aa63;})});}_0x5e0cfe['where']={'$and':[_0x5e0cfe[_0xd998('0x4d')],{'$or':[{'UserId':_0x44c964['params']['id']},{'OwnerId':_0x44c964[_0xd998('0x5f')]['id']}]}]};_0x5e0cfe=_[_0xd998('0xe0')]({},_0x5e0cfe,_0x44c964[_0xd998('0x62')]);var _0xd8ceeb={'where':_0x5e0cfe[_0xd998('0x4d')]};return db[_0xd998('0x168')][_0xd998('0x21')](_0xd8ceeb)[_0xd998('0x31')](function(_0x380035){_0x59c70a['count']=_0x380035;if(_0x44c964[_0xd998('0x4f')][_0xd998('0x61')]){_0x5e0cfe[_0xd998('0x4e')]=[{'attributes':['id',_0xd998('0x169'),_0xd998('0x16a'),'phone'],'model':db['CmContact'],'as':_0xd998('0x16b')},{'attributes':['id',_0xd998('0x3f'),_0xd998('0x16c')],'model':db['VoiceQueue'],'as':_0xd998('0xd9')}];}return db['CmHopper'][_0xd998('0x55')](_0x5e0cfe);})[_0xd998('0x31')](function(_0x135338){_0x59c70a[_0xd998('0x56')]=_0x135338;return _0x59c70a;})[_0xd998('0x31')](respondWithFilteredResult(_0x24fbab,_0x5e0cfe))[_0xd998('0x2f')](handleError(_0x24fbab,null));};exports[_0xd998('0x16d')]=function(_0x12190a,_0x8f5a0b){if(!_[_0xd998('0x71')](_0x12190a['user']['id'])&&(_0x12190a['user'][_0xd998('0x32')]==_0xd998('0x35')||_0x12190a['user'][_0xd998('0x32')]=='user')){return db[_0xd998('0x54')][_0xd998('0x9e')]({'where':{'id':_0x12190a[_0xd998('0x5f')]['id']},'raw':!![]})['then'](function(_0xff7664){return authService[_0xd998('0x16e')](_0xff7664);})[_0xd998('0x31')](function(_0x1ad0fd){if(_0x1ad0fd){return _0x8f5a0b['status'](0xc8)['json']({'api_key':_0x1ad0fd[_0xd998('0x16f')]});}else{return _0x8f5a0b['status'](0xcc)[_0xd998('0x1d')]({'message':_0xd998('0x170')});}})[_0xd998('0x2f')](handleError(_0x8f5a0b,0x193));}else{return _0x8f5a0b['status'](0x191)[_0xd998('0x1d')]({'message':'You\x20don\x27t\x20have\x20sufficient\x20privileges\x20to\x20access\x20this\x20resource.'});}};exports[_0xd998('0x171')]=function(_0x2d6483,_0x435df7){if(!_[_0xd998('0x71')](_0x2d6483[_0xd998('0x37')]['id'])&&(_0x2d6483[_0xd998('0x37')][_0xd998('0x32')]=='admin'||_0x2d6483['user']['role']=='user')){return db[_0xd998('0x54')][_0xd998('0x3e')]({'where':{'id':_0x2d6483[_0xd998('0x5f')]['id']}})[_0xd998('0x31')](function(_0x3d91e3){return authService[_0xd998('0x172')](_0x3d91e3);})['then'](function(_0x5bb49b){return db[_0xd998('0x54')][_0xd998('0x30')]({'apiKeyIat':_0x5bb49b[_0xd998('0x173')],'apiKeyNonce':_0x5bb49b['nonce']},{'where':{'id':_0x2d6483['params']['id']}})[_0xd998('0x31')](function(){return _0x435df7['status'](0xc8)['json']({'api_key':_0x5bb49b[_0xd998('0x16f')]});});})[_0xd998('0x2f')](handleError(_0x435df7,0x193));}else{return _0x435df7['status'](0x191)[_0xd998('0x1d')]({'message':_0xd998('0x174')});}};exports['removeApiKey']=function(_0x47ddd0,_0x98b001){if(!_[_0xd998('0x71')](_0x47ddd0[_0xd998('0x37')]['id'])&&(_0x47ddd0[_0xd998('0x37')][_0xd998('0x32')]=='admin'||_0x47ddd0[_0xd998('0x37')][_0xd998('0x32')]==_0xd998('0x37'))){return db[_0xd998('0x54')][_0xd998('0x3e')]({'where':{'id':_0x47ddd0[_0xd998('0x5f')]['id']}})[_0xd998('0x31')](handleEntityNotFound(_0x98b001,null))[_0xd998('0x31')](function(_0x5086aa){if(_0x5086aa&&_0x5086aa[_0xd998('0x175')]&&_0x5086aa[_0xd998('0x176')])return _0x5086aa;else throw{'message':_0xd998('0x177')};})[_0xd998('0x31')](function(){return db[_0xd998('0x54')][_0xd998('0x30')]({'apiKeyNonce':null,'apiKeyIat':null},{'where':{'id':_0x47ddd0[_0xd998('0x5f')]['id']}});})[_0xd998('0x31')](respondWithStatusCode(_0x98b001,0xc8))['catch'](handleError(_0x98b001,0x193));}else{return _0x98b001[_0xd998('0x1b')](0x191)[_0xd998('0x1d')]({'message':_0xd998('0x174')});}};exports['whoami']=function(_0xd9686d,_0x1b2ea8){var _0x915722=_0xd9686d['user'][_0xd998('0xb3')]({'plain':!![]});if(!_0x915722){return _0x1b2ea8[_0xd998('0x1b')](0x191)[_0xd998('0x41')](_0xd998('0x178'));}else{Promise[_0xd998('0x10a')]()[_0xd998('0x31')](function(){if(_0xd9686d[_0xd998('0x4f')]['userSetting']!==_0xd998('0x51'))return;return _0xd9686d[_0xd998('0x37')][_0xd998('0x179')]();})[_0xd998('0x31')](function(_0x2ead5f){if(!_0x2ead5f)return;return _0x2ead5f[_0xd998('0xb3')]({'plain':!![]});})[_0xd998('0x31')](function(_0x59a9fe){_0x915722[_0xd998('0x50')]=_0x59a9fe;return _0x1b2ea8[_0xd998('0x1b')](0xc8)[_0xd998('0x1d')](_0x915722);});}};exports[_0xd998('0x17a')]=function(_0x7506c2,_0x45b6a7){var _0x4c27d7={'offset':0x0};var _0x11f95c={'count':0x0,'rows':[]};var _0x280fb8=['idle',_0xd998('0x17b'),'ringing'];var _0x35931c=[];var _0x4a0f48=[];var _0x7e4e84=[];var _0x4c8d12=_0x7506c2[_0xd998('0x4f')][_0xd998('0x17c')];var _0x59c2ce=_0x7506c2[_0xd998('0x4f')]['queues'];var _0x61410e=_0x7506c2[_0xd998('0x4f')][_0xd998('0x46')];return Promise[_0xd998('0x10a')]()[_0xd998('0x31')](function(){if(!_0x4c8d12){return[];}return db['Team'][_0xd998('0x55')]({'attributes':['id',_0xd998('0x3f')],'where':{'id':_0x4c8d12}});})['then'](function(_0x4c16ad){_0x7e4e84=_0x4c16ad;if(!_0x59c2ce){return[];}return db['VoiceQueue'][_0xd998('0x55')]({'attributes':['id',_0xd998('0x3f')],'type':_0xd998('0x17d'),'where':{'id':_0x59c2ce}});})['then'](function(_0x228a72){_0x4a0f48=_0x228a72;var _0x265c93=_0x7e4e84['concat'](_0x4a0f48)[_0xd998('0x3c')](function(_0x582b40){return _0x582b40[_0xd998('0x17e')]({'attributes':['id',_0xd998('0x3f'),_0xd998('0x6a'),_0xd998('0xa5')],'raw':!![]});});return Promise['all'](_0x265c93);})['then'](function(_0x4c95d5){var _0xa75597=_[_0xd998('0x17f')](_0x4c95d5);if(_0x61410e){if(_0x59c2ce||_0x4c8d12){return _0xa75597['filter'](function(_0x3d000d){return _0x3d000d[_0xd998('0x3f')][_0xd998('0xaa')]()[_0xd998('0x4b')](_0x61410e[_0xd998('0xaa')]())||_0x3d000d[_0xd998('0x6a')][_0xd998('0x180')]()[_0xd998('0x4b')](_0x61410e);});}else{return db[_0xd998('0x54')]['findAll']({'attributes':['id',_0xd998('0x3f'),_0xd998('0x6a'),_0xd998('0xa5')],'where':{'role':_0xd998('0x33'),'$or':[db[_0xd998('0x72')][_0xd998('0x4d')](db[_0xd998('0x72')]['fn'](_0xd998('0x181'),db[_0xd998('0x72')]['col'](_0xd998('0x3f'))),{'$like':'%'+_0x61410e['toLowerCase']()+'%'}),{'internal':{'$like':'%'+_0x61410e+'%'}}]},'raw':!![]});}}else{return _0xa75597;}})[_0xd998('0x31')](function(_0x40b7e6){var _0x1ee62e=_0xd998('0x3f');var _0x3dc2fc=_0xd998('0x182');if(_0x7506c2[_0xd998('0x4f')][_0xd998('0xdf')]){_0x3dc2fc=_0x7506c2[_0xd998('0x4f')][_0xd998('0xdf')][0x0]==='-'?_0xd998('0x183'):_0xd998('0x182');_0x1ee62e=_0x3dc2fc===_0xd998('0x182')?_0x7506c2['query'][_0xd998('0xdf')]:_0x7506c2[_0xd998('0x4f')]['sort'][_0xd998('0x184')](0x1);}return _(_0x40b7e6)[_0xd998('0x185')]('id')[_0xd998('0x186')]([function(_0x1007d4){return _0x1ee62e===_0xd998('0x3f')?_0x1007d4[_0x1ee62e][_0xd998('0xaa')]():_0x1007d4[_0x1ee62e];}],[_0x3dc2fc])['map'](function(_0x11ab15){return _['pick'](_0x11ab15,['id',_0xd998('0x3f'),_0xd998('0x6a'),'online']);})[_0xd998('0x3d')]();})[_0xd998('0x31')](function(_0x2ca5bd){_0x35931c=_0x2ca5bd;return rta[_0xd998('0x187')]();})['then'](function(_0x11061){return _0x35931c[_0xd998('0x3c')](function(_0x3e481c){var _0x26e10f=_[_0xd998('0x3e')](_0x11061[_0xd998('0x56')],['id',_0x3e481c['id']]);if(!_0x26e10f||!_0x3e481c['online']){_0x3e481c[_0xd998('0x1b')]='offline';}else if(_0x26e10f[_0xd998('0xb6')]){_0x3e481c[_0xd998('0x1b')]=_0xd998('0x10c');}else if(_0x26e10f[_0xd998('0x188')]===_0xd998('0x189')||!_0x26e10f['voiceStatus']){_0x3e481c['status']=_0xd998('0x189');}else{_0x3e481c[_0xd998('0x1b')]=_0x280fb8['includes'](_0x26e10f['voiceStatus'])?'online':_0xd998('0x18a');}return _0x3e481c;});})[_0xd998('0x31')](function(_0x352265){if(!_0x7506c2[_0xd998('0x4f')][_0xd998('0xd2')](_0xd998('0xe2'))){_0x4c27d7[_0xd998('0x20')]=qs[_0xd998('0x20')](_0x7506c2[_0xd998('0x4f')][_0xd998('0x20')]||0xa);_0x4c27d7[_0xd998('0x1e')]=qs['offset'](_0x7506c2[_0xd998('0x4f')]['offset']);}_0x11f95c[_0xd998('0x21')]=_0x352265[_0xd998('0x94')];_0x11f95c[_0xd998('0x56')]=_0x4c27d7['limit']?_0x352265['slice'](_0x4c27d7[_0xd998('0x1e')],_0x4c27d7[_0xd998('0x1e')]+_0x4c27d7[_0xd998('0x20')]):_0x352265;return _0x11f95c;})[_0xd998('0x31')](respondWithFilteredResult(_0x45b6a7,_0x4c27d7))[_0xd998('0x2f')](handleError(_0x45b6a7,null));};function get_open_tabs(_0x24095f,_0x5d588f){var _0x35dd6a=_0x24095f['charAt'](0x0)[_0xd998('0x18b')]()+_0x24095f[_0xd998('0x18c')](0x1);var _0xc42da4={'type':db[_0xd998('0x9a')][_0xd998('0x74')][_0xd998('0x75')],'raw':!![]};return new Promise(function(_0x1653da,_0x178673){var _0xd90f92=squel[_0xd998('0x18d')]()[_0xd998('0x18e')]('ui.'+_0x35dd6a+_0xd998('0x18f'),'id')['field']('ui.createdAt')[_0xd998('0x76')](_0xd998('0x190')+_0x24095f+_0xd998('0x191'),'ui')[_0xd998('0x4d')](_0xd998('0x192'),_0x5d588f['id']);return db[_0xd998('0x72')][_0xd998('0x4f')](_0xd90f92[_0xd998('0x180')](),_0xc42da4)[_0xd998('0x31')](function(_0x594222){_0x5d588f[_0x35dd6a+_0xd998('0x193')]=_0x594222;_0x1653da(_0x594222);})['catch'](function(_0x4b61c5){_0x178673(_0x4b61c5);});});}exports['messengerSoundNotification']=function(_0x227ad1,_0x1e57c2){var _0x49e601=_0x227ad1['params']['id'];var _0x7628e9=_0x227ad1[_0xd998('0x66')][_0xd998('0x194')];return db[_0xd998('0x54')][_0xd998('0x30')]({'messengerSoundNotification':_0x7628e9},{'where':{'id':_0x49e601}})[_0xd998('0x31')](respondWithStatusCode(_0x1e57c2,null))[_0xd998('0x2f')](handleError(_0x1e57c2,null));};
\ No newline at end of file