Built motion from commit (unavailable).|2.4.4
[motion2.git] / server / api / user / user.controller.js
1 // *************************************************************************
2 // *                                                                       *
3 // * xCALLY Motion -  The Omnichannel Contact Center                       *
4 // * Copyright (c) Xenialab s.r.l. All Rights Reserved                     *
5 // *                                                                       *
6 // *************************************************************************
7 // *                                                                       *
8 // * Email: info@xcally.com                                                *
9 // * Website: https://www.xcally.com                                       *
10 // *                                                                       *
11 // *************************************************************************
12 // *                                                                       *
13 // * The SOFTWARE PRODUCT is protected by copyright laws and international *
14 // * copyright treaties, as well as other intellectual property laws and   *
15 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                         *
16 // *                                                                       *
17 // *************************************************************************
18 var _0x4c3d=['removeOpenchannelAccounts','SmsAccount','getSmsAccounts','addSmsAccounts','removeSmsAccounts','getChatWebsites','ChatWebsite','addChatWebsites','removeChatWebsites','getSquareProjects','addSquareProjects','removeSquareProjects','getScheduledCalls','CmHopper','$or','$gte','$lt','$lte','$eq','$between','$notBetween','$notIn','$like','$notLike','$iLike','$notILike','$overlap','$any','firstName','lastName','getApiKey','retrieveApiKey','No\x20API\x20access\x20key\x20found!','You\x20don\x27t\x20have\x20sufficient\x20privelages\x20to\x20access\x20this\x20resource.','apiKeyNonce','removeApiKey','apiKeyIat','html-pdf','rimraf','zip-dir','request-promise','bluebird','mustache','path','sox','to-csv','ejs','lodash','squel','jsforce','querystring','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../mysqldb','redis','defaults','localhost','socket.io-emitter','./user.socket','register','jayson/promise','client','http','test','The\x20password\x20must\x20be\x20at\x20least\x208\x20characters\x20long\x20and\x20have\x201\x20lowercase\x20character,\x201\x20uppercase\x20character,\x201\x20number\x20and\x201\x20special\x20character\x20~!@#$%^&-_=+[{]}.','request','then','info','User,\x20%s,\x20%s','request\x20sent','debug','User,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','end','status','json','count','offset','limit','Content-Range','apply','save','update','destroy','get','Users','user','Agents','agent','Telephones','telephone','filter','ignore','value','includes','role','find','name','sendStatus','stack','send','index','User','rawAttributes','model','differenceBy','keys','password','salt','query','intersection','attributes','fields','hasOwnProperty','nolimit','sort','where','filters','pick','map','key','VIRTUAL','sequelize','col','lower','merge','options','includeAll','findAll','show','params','length','bulkCreate','body','describe','addContacts','ids','omit','agent\x20role','admin','getLicense','users','isNil','License\x20limit\x20reached','format','create','internal','Setting','findById','securePassword','min_internal','max','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','102','103','110','104','106','111','UserProfileSection','autoAssociation','UserProfileResource','changePassword','oldPassword','newPassword','New\x20password\x20must\x20be\x20different\x20from\x20old\x20one','Sequelize','Invalid\x20body\x20format.\x20Use\x20oldPassord\x20and\x20newPassword','authenticate','ValidationError','Wrong\x20credentials','Invalid\x20body\x20format.\x20Use\x20newPassword','Unauthorized','addQueues','channel','online','loginInPause','voicePause','interface','isValidChannel','Unknown\x20channel','toLowerCase','Queues','penalty','spread','QueueId','emit','capitalize','Queue:save','voice','VoiceQueue','push','SIP/%s','each','UserVoiceQueueRt','upsert','removeQueues','remove','Queue:remove','addAvatar','userpic','filename','join','root','server/files/images/logos/default_profile.png','existsSync','server/files/images/','download','getContacts','findOne','CmContact','order','include','List','Tags','color','tag','getQueues','Queue','Unknown\x20role','getVoiceQueuesRt','getGroups','ChatGroup','getRecordings','VoiceRecording','UserId','rows','ScreenRecording','getChatInteractions','ChatInteraction','getOpenchannelInteractions','OpenchannelInteraction','getMailInteractions','MailInteraction','getSmsInteractions','SmsInteraction','FaxInteraction','getFaxInteractions','phone','LOCAL/%s@from-sip/n','intrf','user:%s','user:forcelogout','headers','x-forwarded-for','remoteAddress','socket','connection','getVoiceQueues','UserVoiceQueue.penalty','MemberReport','forEach','YYYY-MM-DD\x20HH:mm:ss','all','getChannels','concat','LOGININPAUSE','isMiddleware','pause','QueuePause','PAUSE','updateAttributes','DEFAULT\x20PAUSE','type','unpause','mailPause','faxPause','openchannelPause','smsPause','pauseType','lastPauseAt','manual','mail','chat','fax','sms','openchannel','set','Pause','getTeams','Team','addTeams','removeTeams','getLists','CmList','You\x20can\x27t\x20delete\x20yourself','addChatInteractions','user_has_chat_interactions:save','removeChatInteractions','isArray','user_has_chat_interactions:remove','addMailInteractions','user_has_mail_interactions:save','user_has_mail_interactions:remove','addFaxInteractions','user_has_fax_interactions:save','removeFaxInteractions','user_has_fax_interactions:remove','addSmsInteractions','removeSmsInteractions','user_has_sms_interactions:remove','addOpenchannelInteractions','user_has_openchannel_interactions:save','removeOpenchannelInteractions','user_has_openchannel_interactions:remove','getVoicePrefixes','VoicePrefix','getFaxAccounts','FaxAccount','addFaxAccounts','removeFaxAccounts','MailAccount','getMailAccounts','addMailAccounts','removeMailAccounts','getOpenchannelAccounts','OpenchannelAccount','addOpenchannelAccounts'];(function(_0x73d817,_0x54eed1){var _0x178cf8=function(_0x3cdf24){while(--_0x3cdf24){_0x73d817['push'](_0x73d817['shift']());}};_0x178cf8(++_0x54eed1);}(_0x4c3d,0x177));var _0xd4c3=function(_0x225198,_0x1428a3){_0x225198=_0x225198-0x0;var _0x4934c1=_0x4c3d[_0x225198];return _0x4934c1;};'use strict';var pdf=require(_0xd4c3('0x0'));var emlformat=require('eml-format');var rimraf=require(_0xd4c3('0x1'));var zipdir=require(_0xd4c3('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0xd4c3('0x3'));var moment=require('moment');var BPromise=require(_0xd4c3('0x4'));var Mustache=require(_0xd4c3('0x5'));var util=require('util');var path=require(_0xd4c3('0x6'));var sox=require(_0xd4c3('0x7'));var csv=require(_0xd4c3('0x8'));var ejs=require(_0xd4c3('0x9'));var fs=require('fs');var _=require(_0xd4c3('0xa'));var squel=require(_0xd4c3('0xb'));var crypto=require('crypto');var jsforce=require(_0xd4c3('0xc'));var deskjs=require('desk.js');var toCsv=require(_0xd4c3('0x8'));var querystring=require(_0xd4c3('0xd'));var Papa=require('papaparse');var Redis=require(_0xd4c3('0xe'));var authService=require(_0xd4c3('0xf'));var qs=require(_0xd4c3('0x10'));var hardwareService=require(_0xd4c3('0x11'));var logger=require(_0xd4c3('0x12'))(_0xd4c3('0x13'));var utils=require(_0xd4c3('0x14'));var config=require(_0xd4c3('0x15'));var db=require(_0xd4c3('0x16'))['db'];config[_0xd4c3('0x17')]=_[_0xd4c3('0x18')](config[_0xd4c3('0x17')],{'host':_0xd4c3('0x19'),'port':0x18eb});var socket=require(_0xd4c3('0x1a'))(new Redis(config[_0xd4c3('0x17')]));require(_0xd4c3('0x1b'))[_0xd4c3('0x1c')](socket);var jayson=require(_0xd4c3('0x1d'));var client=jayson[_0xd4c3('0x1e')][_0xd4c3('0x1f')]({'port':0x232a});function checkPasswordPattern(_0x30275d,_0x5941d5,_0x335cf3){if(_0x335cf3){var _0x3f49a7=new RegExp(/(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[?!@#\$%\^&\*~\-_=+[{\]\}])(?=.{8,})/);if(_0x3f49a7[_0xd4c3('0x20')](_0x5941d5)){return _0x30275d;}else{throw new Error(_0xd4c3('0x21'));}}else{return _0x30275d;}}function respondWithRpcPromise(_0x12f9fb,_0x18f90b,_0x57cf83,_0x4bf966){return new BPromise(function(_0x10d6e8,_0x50117a){var _0x44831a=_0x4bf966||client;return _0x44831a[_0xd4c3('0x22')](_0x12f9fb,_0x57cf83)[_0xd4c3('0x23')](function(_0x323d82){logger[_0xd4c3('0x24')](_0xd4c3('0x25'),_0x18f90b,_0xd4c3('0x26'));logger[_0xd4c3('0x27')](_0xd4c3('0x28'),_0x18f90b,_0xd4c3('0x26'),JSON[_0xd4c3('0x29')](_0x323d82));if(_0x323d82['error']){if(_0x323d82[_0xd4c3('0x2a')][_0xd4c3('0x2b')]===0x1f4){logger['error']('User,\x20%s,\x20%s',_0x18f90b,_0x323d82[_0xd4c3('0x2a')][_0xd4c3('0x2c')]);return _0x50117a(_0x323d82['error'][_0xd4c3('0x2c')]);}logger[_0xd4c3('0x2a')]('User,\x20%s,\x20%s',_0x18f90b,_0x323d82[_0xd4c3('0x2a')]['message']);return _0x10d6e8(_0x323d82[_0xd4c3('0x2a')][_0xd4c3('0x2c')]);}else{logger[_0xd4c3('0x24')](_0xd4c3('0x25'),_0x18f90b,_0xd4c3('0x26'));_0x10d6e8(_0x323d82[_0xd4c3('0x2d')][_0xd4c3('0x2c')]);}})[_0xd4c3('0x2e')](function(_0x1a9481){logger[_0xd4c3('0x2a')]('User,\x20%s,\x20%s',_0x18f90b,_0x1a9481);_0x50117a(_0x1a9481);});});}function respondWithStatusCode(_0x84cf2e,_0x3f08cf){_0x3f08cf=_0x3f08cf||0xcc;return function(_0x98e6e6){if(_0x98e6e6){return _0x84cf2e['sendStatus'](_0x3f08cf);}return _0x84cf2e['status'](_0x3f08cf)[_0xd4c3('0x2f')]();};}function respondWithResult(_0x993f0b,_0x7c994d){_0x7c994d=_0x7c994d||0xc8;return function(_0x246ef1){if(_0x246ef1){return _0x993f0b[_0xd4c3('0x30')](_0x7c994d)[_0xd4c3('0x31')](_0x246ef1);}};}function respondWithFilteredResult(_0x12f305,_0xefcb6f){return function(_0x13fbc9){if(_0x13fbc9){var _0x4e9784=_0x13fbc9[_0xd4c3('0x32')],_0x2eef63=_0xefcb6f[_0xd4c3('0x33')],_0x7c8e71=_0xefcb6f['offset']+_0xefcb6f[_0xd4c3('0x34')],_0x2b6aba;if(_0x7c8e71>=_0x4e9784){_0x7c8e71=_0x4e9784;_0x2b6aba=0xc8;}else{_0x2b6aba=0xce;}_0x12f305[_0xd4c3('0x30')](_0x2b6aba);return _0x12f305['set'](_0xd4c3('0x35'),_0x2eef63+'-'+_0x7c8e71+'/'+_0x4e9784)['json'](_0x13fbc9);}return null;};}function patchUpdates(_0x34e717){return function(_0x61ec17){try{jsonpatch[_0xd4c3('0x36')](_0x61ec17,_0x34e717,!![]);}catch(_0x57bf42){return BPromise['reject'](_0x57bf42);}return _0x61ec17[_0xd4c3('0x37')]();};}function saveUpdates(_0x263fcd,_0xf15a7){return function(_0x317da1){if(_0x317da1){return _0x317da1[_0xd4c3('0x38')](_0x263fcd)['then'](function(_0x52ad8e){return _0x52ad8e;});}return null;};}function removeEntity(_0x1d20e8,_0xac86c3){return function(_0x4bff32){if(_0x4bff32){return _0x4bff32[_0xd4c3('0x39')]()['then'](function(){var _0x3636cb=_0x4bff32[_0xd4c3('0x3a')]({'plain':!![]});var _0x282c97=[{'name':_0xd4c3('0x3b'),'value':_0xd4c3('0x3c'),'ignore':!![]},{'name':_0xd4c3('0x3d'),'value':_0xd4c3('0x3e'),'ignore':![]},{'name':_0xd4c3('0x3f'),'value':_0xd4c3('0x40'),'ignore':![]}];var _0x2f5834=_(_0x282c97)[_0xd4c3('0x41')](_0xd4c3('0x42'))['map'](_0xd4c3('0x43'))[_0xd4c3('0x43')]();if(_[_0xd4c3('0x44')](_0x2f5834,_0x3636cb[_0xd4c3('0x45')])){return;}var _0x38a393=_[_0xd4c3('0x46')](_0x282c97,[_0xd4c3('0x43'),_0x3636cb[_0xd4c3('0x45')]])[_0xd4c3('0x47')];return db['UserProfileResource'][_0xd4c3('0x39')]({'where':{'type':_0x38a393,'resourceId':_0x3636cb['id']}})[_0xd4c3('0x23')](function(){return _0x4bff32;});})[_0xd4c3('0x23')](function(){_0x1d20e8[_0xd4c3('0x30')](0xcc)[_0xd4c3('0x2f')]();});}};}function handleEntityNotFound(_0x1734db,_0xd7043d){return function(_0x37a513){if(!_0x37a513){_0x1734db[_0xd4c3('0x48')](0x194);}return _0x37a513;};}function handleError(_0x3b9b10,_0x2b46b8){_0x2b46b8=_0x2b46b8||0x1f4;return function(_0x55f8fa){logger[_0xd4c3('0x2a')](_0x55f8fa[_0xd4c3('0x49')]);if(_0x55f8fa[_0xd4c3('0x47')]){delete _0x55f8fa[_0xd4c3('0x47')];}_0x3b9b10['status'](_0x2b46b8)[_0xd4c3('0x4a')](_0x55f8fa);};}exports[_0xd4c3('0x4b')]=function(_0x57ef13,_0x53b546){var _0x508627={},_0x3dc309={},_0x1006b5={'count':0x0,'rows':[]};var _0x7fc37e=db[_0xd4c3('0x4c')][_0xd4c3('0x4d')];_0x3dc309[_0xd4c3('0x4e')]=_[_0xd4c3('0x4f')](_[_0xd4c3('0x50')](_0x7fc37e),[_0xd4c3('0x51'),_0xd4c3('0x52')]);_0x3dc309['query']=_['keys'](_0x57ef13[_0xd4c3('0x53')]);_0x3dc309['filters']=_[_0xd4c3('0x54')](_0x3dc309['model'],_0x3dc309[_0xd4c3('0x53')]);_0x508627[_0xd4c3('0x55')]=_['intersection'](_0x3dc309['model'],qs[_0xd4c3('0x56')](_0x57ef13['query'][_0xd4c3('0x56')]));_0x508627['attributes']=_0x508627[_0xd4c3('0x55')]['length']?_0x508627[_0xd4c3('0x55')]:_0x3dc309[_0xd4c3('0x4e')];if(!_0x57ef13[_0xd4c3('0x53')][_0xd4c3('0x57')](_0xd4c3('0x58'))){_0x508627[_0xd4c3('0x34')]=qs[_0xd4c3('0x34')](_0x57ef13[_0xd4c3('0x53')]['limit']);_0x508627['offset']=qs[_0xd4c3('0x33')](_0x57ef13[_0xd4c3('0x53')][_0xd4c3('0x33')]);}_0x508627['order']=qs[_0xd4c3('0x59')](_0x57ef13[_0xd4c3('0x53')]['sort']);_0x508627[_0xd4c3('0x5a')]=qs[_0xd4c3('0x5b')](_[_0xd4c3('0x5c')](_0x57ef13['query'],_0x3dc309[_0xd4c3('0x5b')]));if(_0x57ef13[_0xd4c3('0x53')][_0xd4c3('0x41')]){_0x508627['where']=_['merge'](_0x508627[_0xd4c3('0x5a')],{'$or':_[_0xd4c3('0x5d')](_0x7fc37e,function(_0x34f207){if(_0x34f207['type'][_0xd4c3('0x5e')]!==_0xd4c3('0x5f')){return db[_0xd4c3('0x60')]['where'](db[_0xd4c3('0x60')]['fn']('lower',db['sequelize'][_0xd4c3('0x61')](_0x34f207['field'])),{'$like':db['sequelize']['fn'](_0xd4c3('0x62'),'%'+_0x57ef13[_0xd4c3('0x53')][_0xd4c3('0x41')]+'%')});}})});}_0x508627=_[_0xd4c3('0x63')]({},_0x508627,_0x57ef13[_0xd4c3('0x64')]);var _0x276a17={'where':_0x508627[_0xd4c3('0x5a')]};return db[_0xd4c3('0x4c')][_0xd4c3('0x32')](_0x276a17)[_0xd4c3('0x23')](function(_0xb3c46c){_0x1006b5['count']=_0xb3c46c;if(_0x57ef13['query'][_0xd4c3('0x65')]){_0x508627['include']=[{'all':!![]}];}return db[_0xd4c3('0x4c')][_0xd4c3('0x66')](_0x508627);})[_0xd4c3('0x23')](function(_0x509afe){_0x1006b5['rows']=_0x509afe;return _0x1006b5;})[_0xd4c3('0x23')](respondWithFilteredResult(_0x53b546,_0x508627))[_0xd4c3('0x2e')](handleError(_0x53b546,null));};exports[_0xd4c3('0x67')]=function(_0x2becb8,_0x42bb38){var _0x52acbd={'raw':![],'where':{'id':_0x2becb8[_0xd4c3('0x68')]['id']}},_0x1bd270={};_0x1bd270[_0xd4c3('0x4e')]=_[_0xd4c3('0x4f')](_[_0xd4c3('0x50')](db[_0xd4c3('0x4c')][_0xd4c3('0x4d')]),[_0xd4c3('0x51'),_0xd4c3('0x52')]);_0x1bd270[_0xd4c3('0x53')]=_[_0xd4c3('0x50')](_0x2becb8['query']);_0x1bd270[_0xd4c3('0x5b')]=_['intersection'](_0x1bd270[_0xd4c3('0x4e')],_0x1bd270['query']);_0x52acbd[_0xd4c3('0x55')]=_[_0xd4c3('0x54')](_0x1bd270['model'],qs[_0xd4c3('0x56')](_0x2becb8['query'][_0xd4c3('0x56')]));_0x52acbd[_0xd4c3('0x55')]=_0x52acbd['attributes'][_0xd4c3('0x69')]?_0x52acbd[_0xd4c3('0x55')]:_0x1bd270[_0xd4c3('0x4e')];if(_0x2becb8[_0xd4c3('0x53')][_0xd4c3('0x65')]){_0x52acbd['include']=[{'all':!![]}];}_0x52acbd=_[_0xd4c3('0x63')]({},_0x52acbd,_0x2becb8['options']);return db[_0xd4c3('0x4c')][_0xd4c3('0x46')](_0x52acbd)[_0xd4c3('0x23')](handleEntityNotFound(_0x42bb38,null))[_0xd4c3('0x23')](respondWithResult(_0x42bb38,null))[_0xd4c3('0x2e')](handleError(_0x42bb38,null));};exports[_0xd4c3('0x6a')]=function(_0x54e6cb,_0x571e5f){return db[_0xd4c3('0x4c')][_0xd4c3('0x6a')](_0x54e6cb['body'],{'raw':![],'individualHooks':!![]})[_0xd4c3('0x23')](respondWithResult(_0x571e5f,0xc9))[_0xd4c3('0x2e')](handleError(_0x571e5f,null));};exports['update']=function(_0x215d06,_0x110763){if(_0x215d06[_0xd4c3('0x6b')]['id']){delete _0x215d06[_0xd4c3('0x6b')]['id'];}delete _0x215d06['body'][_0xd4c3('0x45')];return db[_0xd4c3('0x4c')][_0xd4c3('0x46')]({'where':{'id':_0x215d06[_0xd4c3('0x68')]['id']}})[_0xd4c3('0x23')](handleEntityNotFound(_0x110763,null))[_0xd4c3('0x23')](saveUpdates(_0x215d06[_0xd4c3('0x6b')],null))['then'](respondWithResult(_0x110763,null))[_0xd4c3('0x2e')](handleError(_0x110763,null));};exports[_0xd4c3('0x6c')]=function(_0x20273f,_0x1273dd){return db[_0xd4c3('0x4c')][_0xd4c3('0x6c')]()['then'](respondWithResult(_0x1273dd,null))[_0xd4c3('0x2e')](handleError(_0x1273dd,null));};exports['addContacts']=function(_0x33c393,_0xc44e15,_0x35c0b2){return db[_0xd4c3('0x4c')][_0xd4c3('0x46')]({'where':{'id':_0x33c393['params']['id']}})[_0xd4c3('0x23')](handleEntityNotFound(_0xc44e15,null))[_0xd4c3('0x23')](function(_0x7fefc4){if(_0x7fefc4){return _0x7fefc4[_0xd4c3('0x6d')](_0x33c393[_0xd4c3('0x6b')][_0xd4c3('0x6e')],_[_0xd4c3('0x6f')](_0x33c393[_0xd4c3('0x6b')],[_0xd4c3('0x6e'),'id'])||{});}})[_0xd4c3('0x23')](respondWithResult(_0xc44e15,null))[_0xd4c3('0x2e')](handleError(_0xc44e15,null));};var getLicense=function(_0x43aee6){return new BPromise(function(_0x57580d,_0x2edd90){var _0xfbb415=0x0;_0x43aee6[_0xd4c3('0x6b')][_0xd4c3('0x45')]===_0xd4c3('0x3e')&&_0x57580d(_0xd4c3('0x70'));return db[_0xd4c3('0x4c')]['count']({'where':{'$or':[{'role':_0x43aee6[_0xd4c3('0x6b')]['role']==='telephone'?_0xd4c3('0x40'):[_0xd4c3('0x71'),_0xd4c3('0x3c')]}]}})[_0xd4c3('0x23')](function(_0x129d7b){_0xfbb415=_0x129d7b;return require('../../config/license/util')[_0xd4c3('0x72')]();})['then'](function(_0x27db09){var _0x13bd62=_0x43aee6[_0xd4c3('0x6b')][_0xd4c3('0x45')]===_0xd4c3('0x40')?'telephones':_0xd4c3('0x73');if(!_[_0xd4c3('0x74')](_0x27db09[_0x13bd62])&&_0xfbb415>=_0x27db09[_0x13bd62]){return _0x2edd90({'message':_0xd4c3('0x75')});}return _0x57580d(util[_0xd4c3('0x76')]('count\x20%s:\x20%s',_0x13bd62,_0xfbb415));})[_0xd4c3('0x2e')](function(_0x18b0fe){return _0x2edd90(_0x18b0fe);});});};exports[_0xd4c3('0x77')]=function(_0x20d92a,_0x37b178){return getLicense(_0x20d92a)[_0xd4c3('0x23')](function(_0x2392ca){if(!_0x20d92a[_0xd4c3('0x6b')][_0xd4c3('0x78')]){var _0x1c929e;return db[_0xd4c3('0x79')][_0xd4c3('0x7a')](0x1)[_0xd4c3('0x23')](function(_0x16bc91){_0x16bc91[_0xd4c3('0x7b')]=!![];return checkPasswordPattern(_0x16bc91,_0x20d92a[_0xd4c3('0x6b')][_0xd4c3('0x51')],_0x16bc91['securePassword']);})['then'](function(_0x412978){_0x1c929e=_0x412978[_0xd4c3('0x7c')];return db[_0xd4c3('0x4c')][_0xd4c3('0x7d')](_0xd4c3('0x78'));})[_0xd4c3('0x23')](function(_0x3a3ce9){if(_[_0xd4c3('0x74')](_0x3a3ce9)){if(_0x1c929e){_0x20d92a[_0xd4c3('0x6b')][_0xd4c3('0x78')]=_0x1c929e;}else{_0x20d92a['body'][_0xd4c3('0x78')]=0x1;}}else{if(_[_0xd4c3('0x74')](_0x1c929e)||_0x1c929e==_0x3a3ce9){_0x20d92a[_0xd4c3('0x6b')][_0xd4c3('0x78')]=_0x3a3ce9+0x1;}else if(_0x1c929e>_0x3a3ce9){_0x20d92a['body'][_0xd4c3('0x78')]=_0x1c929e;}else{return db[_0xd4c3('0x60')][_0xd4c3('0x53')](_0xd4c3('0x7e'),{'type':db['sequelize'][_0xd4c3('0x7f')][_0xd4c3('0x80')]})[_0xd4c3('0x23')](function(_0x3bdfb7){if(_0x3bdfb7&&_0x3bdfb7['length']){for(var _0x5d3892=0x0,_0x2b5594=_0x3bdfb7['length'];_0x5d3892<_0x2b5594&&_[_0xd4c3('0x74')](_0x20d92a[_0xd4c3('0x6b')][_0xd4c3('0x78')]);_0x5d3892++){if(_0x1c929e<=_0x3bdfb7[_0x5d3892][_0xd4c3('0x81')]){_0x20d92a[_0xd4c3('0x6b')][_0xd4c3('0x78')]=_0x3bdfb7[_0x5d3892]['from'];}else if(_0x1c929e>_0x3bdfb7[_0x5d3892][_0xd4c3('0x81')]&&_0x1c929e<=_0x3bdfb7[_0x5d3892]['to']){_0x20d92a[_0xd4c3('0x6b')][_0xd4c3('0x78')]=_0x1c929e;}}}if(_[_0xd4c3('0x74')](_0x20d92a[_0xd4c3('0x6b')]['internal'])){_0x20d92a[_0xd4c3('0x6b')][_0xd4c3('0x78')]=_0x3a3ce9+0x1;}});}}});}})[_0xd4c3('0x23')](function(){if(_0x20d92a[_0xd4c3('0x6b')][_0xd4c3('0x82')]){_0x20d92a['body'][_0xd4c3('0x83')]=_0x20d92a['body'][_0xd4c3('0x78')];_0x20d92a[_0xd4c3('0x6b')][_0xd4c3('0x84')]={'mailbox':_0x20d92a[_0xd4c3('0x6b')][_0xd4c3('0x78')],'password':_0x20d92a[_0xd4c3('0x6b')][_0xd4c3('0x51')],'fullname':_0x20d92a[_0xd4c3('0x6b')][_0xd4c3('0x85')],'email':_0x20d92a[_0xd4c3('0x6b')][_0xd4c3('0x86')]};}if(_0x20d92a[_0xd4c3('0x6b')]&&_0x20d92a['body']['role']===_0xd4c3('0x3e')){_0x20d92a[_0xd4c3('0x6b')][_0xd4c3('0x87')]=['101',_0xd4c3('0x88'),_0xd4c3('0x89'),_0xd4c3('0x8a'),_0xd4c3('0x8b'),'105',_0xd4c3('0x8c'),'107','108','109','100',_0xd4c3('0x8d')];}return db['User'][_0xd4c3('0x77')](_0x20d92a[_0xd4c3('0x6b')],{'include':[{'model':db[_0xd4c3('0x84')],'as':_0xd4c3('0x84')}]});})[_0xd4c3('0x23')](function(_0x3eefa5){if(_0x20d92a[_0xd4c3('0x6b')][_0xd4c3('0x45')]==='user')return _0x3eefa5;var _0x31bc9f=_0x20d92a[_0xd4c3('0x3c')][_0xd4c3('0x3a')]({'plain':!![]});if(!_0x31bc9f)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x31bc9f[_0xd4c3('0x45')]==='user'){var _0x4dbb79=_0x3eefa5[_0xd4c3('0x3a')]({'plain':!![]});var _0x41d646=[{'name':'Agents','value':'agent'},{'name':_0xd4c3('0x3f'),'value':_0xd4c3('0x40')}];var _0x2fae5d=_[_0xd4c3('0x46')](_0x41d646,[_0xd4c3('0x43'),_0x4dbb79[_0xd4c3('0x45')]])[_0xd4c3('0x47')];return db[_0xd4c3('0x8e')][_0xd4c3('0x46')]({'where':{'name':_0x2fae5d,'userProfileId':_0x31bc9f['userProfileId']},'raw':!![]})[_0xd4c3('0x23')](function(_0x2b6223){if(_0x2b6223&&_0x2b6223[_0xd4c3('0x8f')]===0x0){return db[_0xd4c3('0x90')][_0xd4c3('0x77')]({'name':_0x4dbb79[_0xd4c3('0x47')],'resourceId':_0x4dbb79['id'],'type':_0x2b6223[_0xd4c3('0x47')],'sectionId':_0x2b6223['id']},{})[_0xd4c3('0x23')](function(){return _0x3eefa5;});}else{return _0x3eefa5;}})[_0xd4c3('0x2e')](function(_0x3fcfb0){logger[_0xd4c3('0x2a')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x3fcfb0);throw _0x3fcfb0;});}return _0x3eefa5;})[_0xd4c3('0x23')](respondWithResult(_0x37b178,0xc9))[_0xd4c3('0x2e')](handleError(_0x37b178,null));};exports[_0xd4c3('0x91')]=function(_0x5c3583,_0x56d71b,_0x47f1bf){var _0x49941d=![];if(_0x5c3583['body']['id']){delete _0x5c3583[_0xd4c3('0x6b')]['id'];}if(!_[_0xd4c3('0x74')](_0x5c3583[_0xd4c3('0x6b')][_0xd4c3('0x92')])){if(_0x5c3583[_0xd4c3('0x6b')]['oldPassword']===_0x5c3583[_0xd4c3('0x6b')][_0xd4c3('0x93')]){throw new Error(_0xd4c3('0x94'));}}return db[_0xd4c3('0x4c')][_0xd4c3('0x46')]({'where':{'id':_0x5c3583['params']['id']}})[_0xd4c3('0x23')](function(_0x446aa7){if(_0x446aa7){if(_0x446aa7['id']==_0x5c3583[_0xd4c3('0x3c')]['id']){if(!_0x5c3583[_0xd4c3('0x6b')][_0xd4c3('0x92')]||!_0x5c3583[_0xd4c3('0x6b')][_0xd4c3('0x93')]){throw new db[(_0xd4c3('0x95'))]['ValidationError'](_0xd4c3('0x96'));}if(!_0x446aa7[_0xd4c3('0x97')](_0x5c3583[_0xd4c3('0x6b')][_0xd4c3('0x92')])){throw new db[(_0xd4c3('0x95'))][(_0xd4c3('0x98'))](_0xd4c3('0x99'));}if(_0x5c3583[_0xd4c3('0x6b')][_0xd4c3('0x92')]==_0x5c3583[_0xd4c3('0x6b')][_0xd4c3('0x93')]){throw new db[(_0xd4c3('0x95'))]['ValidationError']('New\x20password\x20must\x20be\x20different\x20from\x20old\x20password');}return _0x446aa7;}else if(_0x5c3583['user']['role']=='admin'){if(!_0x5c3583['body'][_0xd4c3('0x93')]){throw new db[(_0xd4c3('0x95'))]['ValidationError']('Invalid\x20body\x20format.\x20Use\x20newPassword');}return _0x446aa7;}else if(_0x5c3583[_0xd4c3('0x3c')]['role']==_0xd4c3('0x3c')){if(!_0x5c3583[_0xd4c3('0x6b')][_0xd4c3('0x93')]){throw new db[(_0xd4c3('0x95'))]['ValidationError'](_0xd4c3('0x9a'));}if(_0x446aa7[_0xd4c3('0x45')]!=_0xd4c3('0x3e')){throw new db[(_0xd4c3('0x95'))][(_0xd4c3('0x98'))]('Unauthorized');}return _0x446aa7;}else{throw new db[(_0xd4c3('0x95'))]['ValidationError'](_0xd4c3('0x9b'));}}return null;})['then'](handleEntityNotFound(_0x56d71b,null))[_0xd4c3('0x23')](function(_0x1edefe){return db[_0xd4c3('0x79')]['findOne']({'attributes':['id',_0xd4c3('0x7b')]})[_0xd4c3('0x23')](function(_0x23dd8e){_0x49941d=_0x23dd8e[_0xd4c3('0x7b')];return checkPasswordPattern(_0x1edefe,_0x5c3583['body'][_0xd4c3('0x93')],_0x49941d);});})[_0xd4c3('0x23')](saveUpdates({'password':_0x5c3583[_0xd4c3('0x6b')][_0xd4c3('0x93')],'passwordResetAt':_0x5c3583[_0xd4c3('0x3c')]['id']==_0x5c3583[_0xd4c3('0x68')]['id']?moment():null},null))[_0xd4c3('0x23')](respondWithResult(_0x56d71b,null))[_0xd4c3('0x2e')](handleError(_0x56d71b,null));};exports[_0xd4c3('0x9c')]=function(_0x2a0c4a,_0x39d2b3,_0xe80bbf){var _0x45fce3=_0x2a0c4a['body'][_0xd4c3('0x9d')];return db[_0xd4c3('0x4c')][_0xd4c3('0x46')]({'where':{'id':_0x2a0c4a[_0xd4c3('0x68')]['id']},'attributes':['id','name',_0xd4c3('0x45'),_0xd4c3('0x9e'),_0xd4c3('0x9f'),_0xd4c3('0xa0'),_0xd4c3('0xa1')]})['then'](handleEntityNotFound(_0x39d2b3,null))[_0xd4c3('0x23')](function(_0x3fbe51){if(_0x3fbe51){if(!utils[_0xd4c3('0xa2')](_0x45fce3)){throw new db[(_0xd4c3('0x95'))][(_0xd4c3('0x98'))](_0xd4c3('0xa3'));}return _0x3fbe51['add'+_['capitalize'](_0x45fce3[_0xd4c3('0xa4')]())+_0xd4c3('0xa5')](_0x2a0c4a['body'][_0xd4c3('0x6e')],{'penalty':_0x2a0c4a[_0xd4c3('0x6b')][_0xd4c3('0xa6')]||0x0})[_0xd4c3('0xa7')](function(_0x1cd525){for(var _0x3611ee=0x0;_0x3611ee<_0x2a0c4a[_0xd4c3('0x6b')][_0xd4c3('0x6e')]['length'];_0x3611ee+=0x1){var _0x1bbaa8={'UserId':_0x2a0c4a[_0xd4c3('0x68')]['id']};_0x1bbaa8[_['capitalize'](_0x45fce3[_0xd4c3('0xa4')]())+_0xd4c3('0xa8')]=_0x2a0c4a[_0xd4c3('0x6b')]['ids'][_0x3611ee];socket[_0xd4c3('0xa9')](_0xd4c3('0x3c')+_[_0xd4c3('0xaa')](_0x45fce3['toLowerCase']())+_0xd4c3('0xab'),_0x1bbaa8);}return _0x1cd525;})[_0xd4c3('0x23')](function(){if(_0x45fce3===_0xd4c3('0xac')){return db[_0xd4c3('0xad')]['findAll']({'where':{'id':_0x2a0c4a[_0xd4c3('0x6b')]['ids']||[]},'raw':!![],'attributes':['id',_0xd4c3('0x47')]});}})['then'](function(_0x451fcc){var _0x1f4864=_0x3fbe51[_0xd4c3('0x3a')]({'plain':!![]});var _0x4abed2=[];if(_0x45fce3===_0xd4c3('0xac')&&_0x1f4864[_0xd4c3('0x45')]===_0xd4c3('0x3e')&&_0x1f4864['online']){for(var _0xbdadb7=0x0;_0xbdadb7<_0x451fcc['length'];_0xbdadb7+=0x1){_0x4abed2[_0xd4c3('0xae')]({'membername':_0x1f4864[_0xd4c3('0x47')],'UserId':_0x1f4864['id'],'queue_name':_0x451fcc[_0xbdadb7][_0xd4c3('0x47')],'VoiceQueueId':_0x451fcc[_0xbdadb7]['id'],'interface':_['isNil'](_0x1f4864[_0xd4c3('0xa1')])?util[_0xd4c3('0x76')](_0xd4c3('0xaf'),_0x1f4864['name']):_0x1f4864[_0xd4c3('0xa1')],'paused':_0x1f4864[_0xd4c3('0xa0')]||![],'penalty':_0x2a0c4a[_0xd4c3('0x6b')][_0xd4c3('0xa6')]||0x0});}return BPromise[_0xd4c3('0xb0')](_0x4abed2,function(_0x4169c7){return db[_0xd4c3('0xb1')][_0xd4c3('0xb2')](_0x4169c7);});}return _0x3fbe51;});}})['then'](respondWithStatusCode(_0x39d2b3,null))[_0xd4c3('0x2e')](handleError(_0x39d2b3,null));};exports[_0xd4c3('0xb3')]=function(_0x1235f4,_0x454e54,_0x1f6186){var _0x2f91ec;return db[_0xd4c3('0x4c')][_0xd4c3('0x46')]({'where':{'id':_0x1235f4[_0xd4c3('0x68')]['id']},'attributes':['id','name','role']})[_0xd4c3('0x23')](handleEntityNotFound(_0x454e54,null))[_0xd4c3('0x23')](function(_0x3f82d3){if(_0x3f82d3){_0x2f91ec=_0x3f82d3;if(!_0x1235f4[_0xd4c3('0x53')][_0xd4c3('0x9d')]||!utils[_0xd4c3('0xa2')](_0x1235f4['query'][_0xd4c3('0x9d')])){throw new db[(_0xd4c3('0x95'))]['ValidationError'](_0xd4c3('0xa3'));}return _0x3f82d3[_0xd4c3('0xb4')+_[_0xd4c3('0xaa')](_0x1235f4['query']['channel'][_0xd4c3('0xa4')]())+_0xd4c3('0xa5')](_0x1235f4[_0xd4c3('0x53')][_0xd4c3('0x6e')]);}})[_0xd4c3('0x23')](function(_0x461876){for(var _0x1d721b=0x0;_0x1d721b<_0x1235f4[_0xd4c3('0x53')][_0xd4c3('0x6e')]['length'];_0x1d721b+=0x1){var _0x2b21cb={'UserId':_0x1235f4[_0xd4c3('0x68')]['id']};_0x2b21cb[_['capitalize'](_0x1235f4[_0xd4c3('0x53')][_0xd4c3('0x9d')][_0xd4c3('0xa4')]())+_0xd4c3('0xa8')]=_0x1235f4[_0xd4c3('0x53')][_0xd4c3('0x6e')][_0x1d721b];socket[_0xd4c3('0xa9')](_0xd4c3('0x3c')+_[_0xd4c3('0xaa')](_0x1235f4['query'][_0xd4c3('0x9d')][_0xd4c3('0xa4')]())+_0xd4c3('0xb5'),_0x2b21cb);}return _0x461876;})[_0xd4c3('0x23')](function(){if(_0x1235f4[_0xd4c3('0x53')]['channel']==='voice'){return db[_0xd4c3('0xb1')]['destroy']({'where':{'UserId':_0x1235f4[_0xd4c3('0x68')]['id'],'VoiceQueueId':_0x1235f4['query'][_0xd4c3('0x6e')]},'individualHooks':!![]})[_0xd4c3('0x23')](function(){return _0x2f91ec;});}return _0x2f91ec;})[_0xd4c3('0x23')](respondWithStatusCode(_0x454e54,null))[_0xd4c3('0x2e')](handleError(_0x454e54,null));};exports[_0xd4c3('0xb6')]=function(_0x129cef,_0x2b77b2,_0x2cc583){_0x129cef[_0xd4c3('0x6b')][_0xd4c3('0xb7')]=_0x129cef['file'][_0xd4c3('0xb8')];return db[_0xd4c3('0x4c')][_0xd4c3('0x46')]({'where':{'id':_0x129cef['params']['id']}})[_0xd4c3('0x23')](handleEntityNotFound(_0x2b77b2,null))[_0xd4c3('0x23')](saveUpdates(_0x129cef['body'],null))[_0xd4c3('0x23')](respondWithResult(_0x2b77b2,null))[_0xd4c3('0x2e')](handleError(_0x2b77b2,null));};exports['getAvatar']=function(_0x2e28b5,_0x4c1aa3,_0x58994c){var _0x5d755c=path[_0xd4c3('0xb9')](config[_0xd4c3('0xba')],_0xd4c3('0xbb'));return db[_0xd4c3('0x4c')][_0xd4c3('0x46')]({'where':{'id':_0x2e28b5[_0xd4c3('0x68')]['id']},'attributes':['id',_0xd4c3('0xb7')],'raw':!![]})[_0xd4c3('0x23')](handleEntityNotFound(_0x4c1aa3,null))[_0xd4c3('0x23')](function(_0x38359f){if(_0x38359f){if(_['isNil'](_0x38359f[_0xd4c3('0xb7')])){return _0x4c1aa3['download'](_0x5d755c);}else{if(!fs[_0xd4c3('0xbc')](path[_0xd4c3('0xb9')](config[_0xd4c3('0xba')],_0xd4c3('0xbd'),_0x38359f['userpic']))){return _0x4c1aa3[_0xd4c3('0xbe')](_0x5d755c);}return _0x4c1aa3[_0xd4c3('0xbe')](path[_0xd4c3('0xb9')](config[_0xd4c3('0xba')],_0xd4c3('0xbd'),_0x38359f['userpic']));}}})[_0xd4c3('0x2e')](handleError(_0x4c1aa3,null));};exports[_0xd4c3('0xbf')]=function(_0xbd36c9,_0x39f1a8,_0x5ad7ea){var _0x43e8cd={};var _0x53efa2={};var _0x15aef6;var _0x5b3f92;return db['User'][_0xd4c3('0xc0')]({'where':{'id':_0xbd36c9[_0xd4c3('0x68')]['id']}})[_0xd4c3('0x23')](handleEntityNotFound(_0x39f1a8,null))[_0xd4c3('0x23')](function(_0x2a0449){if(_0x2a0449){_0x15aef6=_0x2a0449;_0x53efa2[_0xd4c3('0x4e')]=_['keys'](db[_0xd4c3('0xc1')][_0xd4c3('0x4d')]);_0x53efa2['query']=_[_0xd4c3('0x50')](_0xbd36c9[_0xd4c3('0x53')]);_0x53efa2[_0xd4c3('0x5b')]=_[_0xd4c3('0x54')](_0x53efa2['model'],_0x53efa2[_0xd4c3('0x53')]);_0x43e8cd['attributes']=_[_0xd4c3('0x54')](_0x53efa2['model'],qs[_0xd4c3('0x56')](_0xbd36c9[_0xd4c3('0x53')][_0xd4c3('0x56')]));_0x43e8cd[_0xd4c3('0x55')]=_0x43e8cd['attributes'][_0xd4c3('0x69')]?_0x43e8cd['attributes']:_0x53efa2['model'];_0x43e8cd[_0xd4c3('0xc2')]=qs[_0xd4c3('0x59')](_0xbd36c9[_0xd4c3('0x53')][_0xd4c3('0x59')]);_0x43e8cd[_0xd4c3('0x5a')]=qs[_0xd4c3('0x5b')](_['pick'](_0xbd36c9[_0xd4c3('0x53')],_0x53efa2[_0xd4c3('0x5b')]));if(_0xbd36c9[_0xd4c3('0x53')][_0xd4c3('0x41')]){_0x43e8cd[_0xd4c3('0x5a')]=_[_0xd4c3('0x63')](_0x43e8cd[_0xd4c3('0x5a')],{'$or':_[_0xd4c3('0x5d')](_0x43e8cd['attributes'],function(_0x41db1c){var _0x145ab8={};_0x145ab8[_0x41db1c]={'$like':'%'+_0xbd36c9[_0xd4c3('0x53')][_0xd4c3('0x41')]+'%'};return _0x145ab8;})});}_0x43e8cd=_[_0xd4c3('0x63')]({},_0x43e8cd,_0xbd36c9[_0xd4c3('0x64')]);return _0x15aef6[_0xd4c3('0xbf')](_0x43e8cd);}})['then'](function(_0x2d54dc){if(_0x2d54dc){_0x5b3f92=_0x2d54dc['length'];if(_0xbd36c9[_0xd4c3('0x53')][_0xd4c3('0x57')]('includeAll')){_0x43e8cd[_0xd4c3('0xc3')]=[{'model':db['CmList'],'as':_0xd4c3('0xc4'),'required':![]},{'model':db['Tag'],'as':_0xd4c3('0xc5'),'attributes':['id',_0xd4c3('0x47'),_0xd4c3('0xc6')],'where':_0xbd36c9[_0xd4c3('0x53')][_0xd4c3('0xc7')]?{'id':_0xbd36c9['query'][_0xd4c3('0xc7')]}:undefined,'required':_0xbd36c9[_0xd4c3('0x53')][_0xd4c3('0xc7')]?!![]:![]}];}if(!_0xbd36c9[_0xd4c3('0x53')][_0xd4c3('0x57')](_0xd4c3('0x58'))){_0x43e8cd['limit']=qs[_0xd4c3('0x34')](_0xbd36c9['query'][_0xd4c3('0x34')]);_0x43e8cd['offset']=qs[_0xd4c3('0x33')](_0xbd36c9[_0xd4c3('0x53')][_0xd4c3('0x33')]);}return _0x15aef6['getContacts'](_0x43e8cd);}})['then'](function(_0x363fb9){if(_0x363fb9){return _0x363fb9?{'count':_0x5b3f92,'rows':_0x363fb9}:null;}})[_0xd4c3('0x23')](respondWithResult(_0x39f1a8,null))[_0xd4c3('0x2e')](handleError(_0x39f1a8,null));};exports[_0xd4c3('0xc8')]=function(_0x5a4f31,_0x2db979,_0x3b52fe){var _0x364703;var _0x17678b;var _0x29def3={};var _0x4af27c;return db[_0xd4c3('0x4c')][_0xd4c3('0xc0')]({'where':{'id':_0x5a4f31[_0xd4c3('0x68')]['id']},'attributes':['id',_0xd4c3('0x47'),'role']})[_0xd4c3('0x23')](handleEntityNotFound(_0x2db979,null))['then'](function(_0x1008c9){if(!utils[_0xd4c3('0xa2')](_0x5a4f31[_0xd4c3('0x53')]['channel'])){throw new db[(_0xd4c3('0x95'))][(_0xd4c3('0x98'))](_0xd4c3('0xa3'));}_0x364703=_0x1008c9;var _0x515bfc={};_0x515bfc['model']=_[_0xd4c3('0x50')](db[_['capitalize'](_0x5a4f31[_0xd4c3('0x53')][_0xd4c3('0x9d')])+_0xd4c3('0xc9')][_0xd4c3('0x4d')]);_0x515bfc['query']=_[_0xd4c3('0x50')](_0x5a4f31[_0xd4c3('0x53')]);_0x515bfc[_0xd4c3('0x5b')]=_[_0xd4c3('0x54')](_0x515bfc['model'],_0x515bfc['query']);_0x29def3[_0xd4c3('0x55')]=_[_0xd4c3('0x54')](_0x515bfc['model'],qs[_0xd4c3('0x56')](_0x5a4f31[_0xd4c3('0x53')][_0xd4c3('0x56')]));_0x29def3[_0xd4c3('0x55')]=_0x29def3[_0xd4c3('0x55')][_0xd4c3('0x69')]?_0x29def3['attributes']:_0x515bfc[_0xd4c3('0x4e')];_0x29def3[_0xd4c3('0xc2')]=qs['sort'](_0x5a4f31[_0xd4c3('0x53')][_0xd4c3('0x59')]);_0x29def3[_0xd4c3('0x5a')]=qs[_0xd4c3('0x5b')](_[_0xd4c3('0x5c')](_0x5a4f31[_0xd4c3('0x53')],_0x515bfc[_0xd4c3('0x5b')]));if(_0x5a4f31[_0xd4c3('0x53')][_0xd4c3('0x41')]){_0x29def3['where']=_[_0xd4c3('0x63')](_0x29def3[_0xd4c3('0x5a')],{'$or':_[_0xd4c3('0x5d')](_0x29def3['attributes'],function(_0x5360dc){var _0x42fefe={};_0x42fefe[_0x5360dc]={'$like':'%'+_0x5a4f31[_0xd4c3('0x53')][_0xd4c3('0x41')]+'%'};return _0x42fefe;})});}_0x29def3=_[_0xd4c3('0x63')]({},_0x29def3,_0x5a4f31[_0xd4c3('0x64')]);switch(_0x364703[_0xd4c3('0x45')]){case _0xd4c3('0x71'):return db[_[_0xd4c3('0xaa')](_0x5a4f31[_0xd4c3('0x53')]['channel'])+_0xd4c3('0xc9')][_0xd4c3('0x66')](_0x29def3);case _0xd4c3('0x3c'):case _0xd4c3('0x3e'):return _0x364703[_0xd4c3('0x3a')+_['capitalize'](_0x5a4f31[_0xd4c3('0x53')][_0xd4c3('0x9d')])+'Queues'](_0x29def3);default:throw new db['Sequelize'][(_0xd4c3('0x98'))](_0xd4c3('0xca'));}})['then'](function(_0x492e7c){_0x4af27c=_0x492e7c[_0xd4c3('0x69')];if(!_0x5a4f31[_0xd4c3('0x53')]['hasOwnProperty'](_0xd4c3('0x58'))){_0x29def3['limit']=qs[_0xd4c3('0x34')](_0x5a4f31[_0xd4c3('0x53')][_0xd4c3('0x34')]);_0x29def3[_0xd4c3('0x33')]=qs[_0xd4c3('0x33')](_0x5a4f31['query'][_0xd4c3('0x33')]);}switch(_0x364703['role']){case'admin':return db[_['capitalize'](_0x5a4f31[_0xd4c3('0x53')][_0xd4c3('0x9d')])+_0xd4c3('0xc9')][_0xd4c3('0x66')](_0x29def3);case _0xd4c3('0x3c'):case _0xd4c3('0x3e'):return _0x364703[_0xd4c3('0x3a')+_[_0xd4c3('0xaa')](_0x5a4f31[_0xd4c3('0x53')][_0xd4c3('0x9d')])+_0xd4c3('0xa5')](_0x29def3);}})[_0xd4c3('0x23')](function(_0x329b39){return{'count':_0x4af27c,'rows':_0x329b39};})[_0xd4c3('0x23')](respondWithResult(_0x2db979,null))[_0xd4c3('0x2e')](handleError(_0x2db979,null));};exports['getVoiceQueuesRt']=function(_0x89dd28,_0x49991f,_0x5cb5cd){var _0x3151bd={};var _0x24e087={};var _0x5ef23a;var _0x58ea6f;return db[_0xd4c3('0x4c')][_0xd4c3('0xc0')]({'where':{'id':_0x89dd28[_0xd4c3('0x68')]['id']}})[_0xd4c3('0x23')](handleEntityNotFound(_0x49991f,null))[_0xd4c3('0x23')](function(_0x35ea5d){if(_0x35ea5d){_0x5ef23a=_0x35ea5d;_0x24e087[_0xd4c3('0x4e')]=_['keys'](db['UserVoiceQueueRt'][_0xd4c3('0x4d')]);_0x24e087[_0xd4c3('0x53')]=_['keys'](_0x89dd28[_0xd4c3('0x53')]);_0x24e087[_0xd4c3('0x5b')]=_[_0xd4c3('0x54')](_0x24e087[_0xd4c3('0x4e')],_0x24e087[_0xd4c3('0x53')]);_0x3151bd[_0xd4c3('0x55')]=_[_0xd4c3('0x54')](_0x24e087[_0xd4c3('0x4e')],qs[_0xd4c3('0x56')](_0x89dd28[_0xd4c3('0x53')][_0xd4c3('0x56')]));_0x3151bd[_0xd4c3('0x55')]=_0x3151bd['attributes'][_0xd4c3('0x69')]?_0x3151bd[_0xd4c3('0x55')]:_0x24e087[_0xd4c3('0x4e')];_0x3151bd[_0xd4c3('0xc2')]=qs[_0xd4c3('0x59')](_0x89dd28[_0xd4c3('0x53')][_0xd4c3('0x59')]);_0x3151bd[_0xd4c3('0x5a')]=qs[_0xd4c3('0x5b')](_[_0xd4c3('0x5c')](_0x89dd28[_0xd4c3('0x53')],_0x24e087['filters']));if(_0x89dd28[_0xd4c3('0x53')][_0xd4c3('0x41')]){_0x3151bd[_0xd4c3('0x5a')]=_[_0xd4c3('0x63')](_0x3151bd[_0xd4c3('0x5a')],{'$or':_[_0xd4c3('0x5d')](_0x3151bd[_0xd4c3('0x55')],function(_0xfe1dc4){var _0x1c7f98={};_0x1c7f98[_0xfe1dc4]={'$like':'%'+_0x89dd28[_0xd4c3('0x53')]['filter']+'%'};return _0x1c7f98;})});}_0x3151bd=_[_0xd4c3('0x63')]({},_0x3151bd,_0x89dd28[_0xd4c3('0x64')]);return _0x5ef23a[_0xd4c3('0xcb')](_0x3151bd);}})[_0xd4c3('0x23')](function(_0x1045dd){if(_0x1045dd){_0x58ea6f=_0x1045dd['length'];if(!_0x89dd28[_0xd4c3('0x53')][_0xd4c3('0x57')](_0xd4c3('0x58'))){_0x3151bd[_0xd4c3('0x34')]=qs['limit'](_0x89dd28[_0xd4c3('0x53')][_0xd4c3('0x34')]);_0x3151bd['offset']=qs[_0xd4c3('0x33')](_0x89dd28['query'][_0xd4c3('0x33')]);}return _0x5ef23a[_0xd4c3('0xcb')](_0x3151bd);}})['then'](function(_0xe25d4a){if(_0xe25d4a){return _0xe25d4a?{'count':_0x58ea6f,'rows':_0xe25d4a}:null;}})[_0xd4c3('0x23')](respondWithResult(_0x49991f,null))[_0xd4c3('0x2e')](handleError(_0x49991f,null));};exports[_0xd4c3('0xcc')]=function(_0x1bfbe8,_0x441b85,_0x62089c){var _0xa97d35={};var _0x3a4e49={};var _0x4c448e;var _0x28dff5;return db[_0xd4c3('0x4c')][_0xd4c3('0xc0')]({'where':{'id':_0x1bfbe8[_0xd4c3('0x68')]['id']}})[_0xd4c3('0x23')](handleEntityNotFound(_0x441b85,null))[_0xd4c3('0x23')](function(_0x22cdb3){if(_0x22cdb3){_0x4c448e=_0x22cdb3;_0x3a4e49[_0xd4c3('0x4e')]=_[_0xd4c3('0x50')](db[_0xd4c3('0xcd')][_0xd4c3('0x4d')]);_0x3a4e49[_0xd4c3('0x53')]=_['keys'](_0x1bfbe8[_0xd4c3('0x53')]);_0x3a4e49[_0xd4c3('0x5b')]=_[_0xd4c3('0x54')](_0x3a4e49[_0xd4c3('0x4e')],_0x3a4e49[_0xd4c3('0x53')]);_0xa97d35[_0xd4c3('0x55')]=_[_0xd4c3('0x54')](_0x3a4e49[_0xd4c3('0x4e')],qs[_0xd4c3('0x56')](_0x1bfbe8[_0xd4c3('0x53')][_0xd4c3('0x56')]));_0xa97d35[_0xd4c3('0x55')]=_0xa97d35['attributes']['length']?_0xa97d35[_0xd4c3('0x55')]:_0x3a4e49[_0xd4c3('0x4e')];_0xa97d35[_0xd4c3('0xc2')]=qs[_0xd4c3('0x59')](_0x1bfbe8[_0xd4c3('0x53')][_0xd4c3('0x59')]);_0xa97d35[_0xd4c3('0x5a')]=qs[_0xd4c3('0x5b')](_[_0xd4c3('0x5c')](_0x1bfbe8[_0xd4c3('0x53')],_0x3a4e49['filters']));if(_0x1bfbe8['query']['filter']){_0xa97d35[_0xd4c3('0x5a')]=_[_0xd4c3('0x63')](_0xa97d35[_0xd4c3('0x5a')],{'$or':_[_0xd4c3('0x5d')](_0xa97d35[_0xd4c3('0x55')],function(_0x23c45f){var _0x2e161a={};_0x2e161a[_0x23c45f]={'$like':'%'+_0x1bfbe8['query'][_0xd4c3('0x41')]+'%'};return _0x2e161a;})});}_0xa97d35=_['merge']({},_0xa97d35,_0x1bfbe8[_0xd4c3('0x64')]);return _0x4c448e[_0xd4c3('0xcc')](_0xa97d35);}})[_0xd4c3('0x23')](function(_0x4615ee){if(_0x4615ee){_0x28dff5=_0x4615ee['length'];if(!_0x1bfbe8[_0xd4c3('0x53')][_0xd4c3('0x57')](_0xd4c3('0x58'))){_0xa97d35[_0xd4c3('0x34')]=qs['limit'](_0x1bfbe8[_0xd4c3('0x53')][_0xd4c3('0x34')]);_0xa97d35[_0xd4c3('0x33')]=qs[_0xd4c3('0x33')](_0x1bfbe8['query'][_0xd4c3('0x33')]);}return _0x4c448e[_0xd4c3('0xcc')](_0xa97d35);}})[_0xd4c3('0x23')](function(_0x5c7a36){if(_0x5c7a36){return _0x5c7a36?{'count':_0x28dff5,'rows':_0x5c7a36}:null;}})['then'](respondWithResult(_0x441b85,null))[_0xd4c3('0x2e')](handleError(_0x441b85,null));};exports[_0xd4c3('0xce')]=function(_0xe5e636,_0xebcbc8,_0x3f5388){var _0x405271={'raw':!![],'where':{}};var _0x2e8cd5={};var _0x2a2dd3={'count':0x0,'rows':[]};return db[_0xd4c3('0x4c')][_0xd4c3('0xc0')]({'where':{'id':_0xe5e636[_0xd4c3('0x68')]['id']}})[_0xd4c3('0x23')](handleEntityNotFound(_0xebcbc8,null))[_0xd4c3('0x23')](function(_0x415b4a){if(_0x415b4a){_0x2e8cd5[_0xd4c3('0x4e')]=_[_0xd4c3('0x50')](db[_0xd4c3('0xcf')][_0xd4c3('0x4d')]);_0x2e8cd5[_0xd4c3('0x53')]=_[_0xd4c3('0x50')](_0xe5e636[_0xd4c3('0x53')]);_0x2e8cd5[_0xd4c3('0x5b')]=_[_0xd4c3('0x54')](_0x2e8cd5[_0xd4c3('0x4e')],_0x2e8cd5[_0xd4c3('0x53')]);_0x405271[_0xd4c3('0x55')]=_[_0xd4c3('0x54')](_0x2e8cd5[_0xd4c3('0x4e')],qs[_0xd4c3('0x56')](_0xe5e636['query'][_0xd4c3('0x56')]));_0x405271[_0xd4c3('0x55')]=_0x405271[_0xd4c3('0x55')][_0xd4c3('0x69')]?_0x405271[_0xd4c3('0x55')]:_0x2e8cd5[_0xd4c3('0x4e')];if(!_0xe5e636[_0xd4c3('0x53')][_0xd4c3('0x57')](_0xd4c3('0x58'))){_0x405271[_0xd4c3('0x34')]=qs['limit'](_0xe5e636[_0xd4c3('0x53')][_0xd4c3('0x34')]);_0x405271['offset']=qs[_0xd4c3('0x33')](_0xe5e636[_0xd4c3('0x53')][_0xd4c3('0x33')]);}_0x405271[_0xd4c3('0xc2')]=qs['sort'](_0xe5e636['query'][_0xd4c3('0x59')]);_0x405271[_0xd4c3('0x5a')]=qs['filters'](_[_0xd4c3('0x5c')](_0xe5e636[_0xd4c3('0x53')],_0x2e8cd5[_0xd4c3('0x5b')]));_0x405271[_0xd4c3('0x5a')][_0xd4c3('0xd0')]=_0x415b4a['id'];if(_0xe5e636['query']['filter']){_0x405271[_0xd4c3('0x5a')]=_[_0xd4c3('0x63')](_0x405271[_0xd4c3('0x5a')],{'$or':_[_0xd4c3('0x5d')](_0x405271['attributes'],function(_0x30813e){var _0xdb88d4={};_0xdb88d4[_0x30813e]={'$like':'%'+_0xe5e636[_0xd4c3('0x53')]['filter']+'%'};return _0xdb88d4;})});}_0x405271=_[_0xd4c3('0x63')]({},_0x405271,_0xe5e636['options']);return db[_0xd4c3('0xcf')][_0xd4c3('0x32')]({'where':_0x405271[_0xd4c3('0x5a')]})[_0xd4c3('0x23')](function(_0xbd56d4){_0x2a2dd3[_0xd4c3('0x32')]=_0xbd56d4;if(_0xe5e636['query'][_0xd4c3('0x65')]){_0x405271['include']=[{'all':!![]}];}return db[_0xd4c3('0xcf')][_0xd4c3('0x66')](_0x405271);})[_0xd4c3('0x23')](function(_0x22df1a){_0x2a2dd3[_0xd4c3('0xd1')]=_0x22df1a;return _0x2a2dd3;});}})[_0xd4c3('0x23')](respondWithFilteredResult(_0xebcbc8,_0x405271))[_0xd4c3('0x2e')](handleError(_0xebcbc8,null));};exports['getScreenRecordings']=function(_0x14bca6,_0xac54ef,_0x79bf08){var _0x4b2435={'raw':!![],'where':{}};var _0x2c57ae={};var _0x50497a={'count':0x0,'rows':[]};return db[_0xd4c3('0x4c')][_0xd4c3('0xc0')]({'where':{'id':_0x14bca6[_0xd4c3('0x68')]['id']}})[_0xd4c3('0x23')](handleEntityNotFound(_0xac54ef,null))[_0xd4c3('0x23')](function(_0x2a81e0){if(_0x2a81e0){_0x2c57ae[_0xd4c3('0x4e')]=_[_0xd4c3('0x50')](db[_0xd4c3('0xd2')][_0xd4c3('0x4d')]);_0x2c57ae[_0xd4c3('0x53')]=_[_0xd4c3('0x50')](_0x14bca6['query']);_0x2c57ae[_0xd4c3('0x5b')]=_[_0xd4c3('0x54')](_0x2c57ae[_0xd4c3('0x4e')],_0x2c57ae['query']);_0x4b2435[_0xd4c3('0x55')]=_[_0xd4c3('0x54')](_0x2c57ae[_0xd4c3('0x4e')],qs['fields'](_0x14bca6[_0xd4c3('0x53')][_0xd4c3('0x56')]));_0x4b2435[_0xd4c3('0x55')]=_0x4b2435[_0xd4c3('0x55')][_0xd4c3('0x69')]?_0x4b2435[_0xd4c3('0x55')]:_0x2c57ae[_0xd4c3('0x4e')];if(!_0x14bca6[_0xd4c3('0x53')][_0xd4c3('0x57')](_0xd4c3('0x58'))){_0x4b2435[_0xd4c3('0x34')]=qs[_0xd4c3('0x34')](_0x14bca6[_0xd4c3('0x53')][_0xd4c3('0x34')]);_0x4b2435[_0xd4c3('0x33')]=qs[_0xd4c3('0x33')](_0x14bca6[_0xd4c3('0x53')][_0xd4c3('0x33')]);}_0x4b2435[_0xd4c3('0xc2')]=qs[_0xd4c3('0x59')](_0x14bca6[_0xd4c3('0x53')]['sort']);_0x4b2435[_0xd4c3('0x5a')]=qs[_0xd4c3('0x5b')](_['pick'](_0x14bca6['query'],_0x2c57ae[_0xd4c3('0x5b')]));_0x4b2435[_0xd4c3('0x5a')][_0xd4c3('0xd0')]=_0x2a81e0['id'];if(_0x14bca6[_0xd4c3('0x53')][_0xd4c3('0x41')]){_0x4b2435[_0xd4c3('0x5a')]=_[_0xd4c3('0x63')](_0x4b2435[_0xd4c3('0x5a')],{'$or':_[_0xd4c3('0x5d')](_0x4b2435[_0xd4c3('0x55')],function(_0x3ed227){var _0x1eb57b={};_0x1eb57b[_0x3ed227]={'$like':'%'+_0x14bca6[_0xd4c3('0x53')][_0xd4c3('0x41')]+'%'};return _0x1eb57b;})});}_0x4b2435=_['merge']({},_0x4b2435,_0x14bca6[_0xd4c3('0x64')]);return db['ScreenRecording'][_0xd4c3('0x32')]({'where':_0x4b2435['where']})['then'](function(_0x249412){_0x50497a[_0xd4c3('0x32')]=_0x249412;if(_0x14bca6[_0xd4c3('0x53')]['includeAll']){_0x4b2435[_0xd4c3('0xc3')]=[{'all':!![]}];}return db['ScreenRecording']['findAll'](_0x4b2435);})[_0xd4c3('0x23')](function(_0x5531e8){_0x50497a[_0xd4c3('0xd1')]=_0x5531e8;return _0x50497a;});}})[_0xd4c3('0x23')](respondWithFilteredResult(_0xac54ef,_0x4b2435))[_0xd4c3('0x2e')](handleError(_0xac54ef,null));};exports[_0xd4c3('0xd3')]=function(_0x135697,_0x2c3c14,_0x2d0a7e){var _0x24807b={};var _0x1e0da7={};var _0x41c28b;var _0x19750e;return db['User'][_0xd4c3('0xc0')]({'where':{'id':_0x135697[_0xd4c3('0x68')]['id']}})[_0xd4c3('0x23')](handleEntityNotFound(_0x2c3c14,null))[_0xd4c3('0x23')](function(_0x23977e){if(_0x23977e){_0x41c28b=_0x23977e;_0x1e0da7[_0xd4c3('0x4e')]=_['keys'](db[_0xd4c3('0xd4')]['rawAttributes']);_0x1e0da7['query']=_['keys'](_0x135697[_0xd4c3('0x53')]);_0x1e0da7[_0xd4c3('0x5b')]=_[_0xd4c3('0x54')](_0x1e0da7[_0xd4c3('0x4e')],_0x1e0da7[_0xd4c3('0x53')]);_0x24807b[_0xd4c3('0x55')]=_[_0xd4c3('0x54')](_0x1e0da7['model'],qs[_0xd4c3('0x56')](_0x135697[_0xd4c3('0x53')]['fields']));_0x24807b[_0xd4c3('0x55')]=_0x24807b['attributes']['length']?_0x24807b[_0xd4c3('0x55')]:_0x1e0da7[_0xd4c3('0x4e')];_0x24807b[_0xd4c3('0xc2')]=qs[_0xd4c3('0x59')](_0x135697[_0xd4c3('0x53')][_0xd4c3('0x59')]);_0x24807b[_0xd4c3('0x5a')]=qs['filters'](_[_0xd4c3('0x5c')](_0x135697[_0xd4c3('0x53')],_0x1e0da7['filters']));if(_0x135697[_0xd4c3('0x53')][_0xd4c3('0x41')]){_0x24807b[_0xd4c3('0x5a')]=_[_0xd4c3('0x63')](_0x24807b[_0xd4c3('0x5a')],{'$or':_[_0xd4c3('0x5d')](_0x24807b[_0xd4c3('0x55')],function(_0x1fa48b){var _0x4c72e8={};_0x4c72e8[_0x1fa48b]={'$like':'%'+_0x135697[_0xd4c3('0x53')][_0xd4c3('0x41')]+'%'};return _0x4c72e8;})});}_0x24807b=_[_0xd4c3('0x63')]({},_0x24807b,_0x135697[_0xd4c3('0x64')]);return _0x41c28b['getChatInteractions'](_0x24807b);}})[_0xd4c3('0x23')](function(_0x4ba5b8){if(_0x4ba5b8){_0x19750e=_0x4ba5b8['length'];if(!_0x135697['query'][_0xd4c3('0x57')](_0xd4c3('0x58'))){_0x24807b[_0xd4c3('0x34')]=qs[_0xd4c3('0x34')](_0x135697[_0xd4c3('0x53')][_0xd4c3('0x34')]);_0x24807b[_0xd4c3('0x33')]=qs['offset'](_0x135697[_0xd4c3('0x53')][_0xd4c3('0x33')]);}return _0x41c28b[_0xd4c3('0xd3')](_0x24807b);}})[_0xd4c3('0x23')](function(_0x4ccfe0){if(_0x4ccfe0){return _0x4ccfe0?{'count':_0x19750e,'rows':_0x4ccfe0}:null;}})[_0xd4c3('0x23')](respondWithResult(_0x2c3c14,null))['catch'](handleError(_0x2c3c14,null));};exports[_0xd4c3('0xd5')]=function(_0x5898f6,_0x54c68b,_0x1d8820){var _0x786271={};var _0x37e77b={};var _0x587971;var _0x3fb2e1;return db[_0xd4c3('0x4c')]['findOne']({'where':{'id':_0x5898f6[_0xd4c3('0x68')]['id']}})[_0xd4c3('0x23')](handleEntityNotFound(_0x54c68b,null))[_0xd4c3('0x23')](function(_0x5bf398){if(_0x5bf398){_0x587971=_0x5bf398;_0x37e77b[_0xd4c3('0x4e')]=_['keys'](db[_0xd4c3('0xd6')]['rawAttributes']);_0x37e77b[_0xd4c3('0x53')]=_[_0xd4c3('0x50')](_0x5898f6['query']);_0x37e77b[_0xd4c3('0x5b')]=_[_0xd4c3('0x54')](_0x37e77b[_0xd4c3('0x4e')],_0x37e77b['query']);_0x786271[_0xd4c3('0x55')]=_[_0xd4c3('0x54')](_0x37e77b[_0xd4c3('0x4e')],qs[_0xd4c3('0x56')](_0x5898f6[_0xd4c3('0x53')][_0xd4c3('0x56')]));_0x786271[_0xd4c3('0x55')]=_0x786271[_0xd4c3('0x55')]['length']?_0x786271[_0xd4c3('0x55')]:_0x37e77b[_0xd4c3('0x4e')];_0x786271[_0xd4c3('0xc2')]=qs['sort'](_0x5898f6[_0xd4c3('0x53')]['sort']);_0x786271[_0xd4c3('0x5a')]=qs[_0xd4c3('0x5b')](_[_0xd4c3('0x5c')](_0x5898f6[_0xd4c3('0x53')],_0x37e77b[_0xd4c3('0x5b')]));if(_0x5898f6[_0xd4c3('0x53')][_0xd4c3('0x41')]){_0x786271[_0xd4c3('0x5a')]=_[_0xd4c3('0x63')](_0x786271[_0xd4c3('0x5a')],{'$or':_[_0xd4c3('0x5d')](_0x786271[_0xd4c3('0x55')],function(_0x19b81a){var _0x5f894f={};_0x5f894f[_0x19b81a]={'$like':'%'+_0x5898f6['query']['filter']+'%'};return _0x5f894f;})});}_0x786271=_[_0xd4c3('0x63')]({},_0x786271,_0x5898f6[_0xd4c3('0x64')]);return _0x587971[_0xd4c3('0xd5')](_0x786271);}})[_0xd4c3('0x23')](function(_0x5946ea){if(_0x5946ea){_0x3fb2e1=_0x5946ea[_0xd4c3('0x69')];if(!_0x5898f6[_0xd4c3('0x53')][_0xd4c3('0x57')](_0xd4c3('0x58'))){_0x786271[_0xd4c3('0x34')]=qs['limit'](_0x5898f6[_0xd4c3('0x53')]['limit']);_0x786271[_0xd4c3('0x33')]=qs[_0xd4c3('0x33')](_0x5898f6['query'][_0xd4c3('0x33')]);}return _0x587971[_0xd4c3('0xd5')](_0x786271);}})[_0xd4c3('0x23')](function(_0x88c742){if(_0x88c742){return _0x88c742?{'count':_0x3fb2e1,'rows':_0x88c742}:null;}})['then'](respondWithResult(_0x54c68b,null))['catch'](handleError(_0x54c68b,null));};exports[_0xd4c3('0xd7')]=function(_0x206afe,_0x1146fa,_0x1facf2){var _0xa1c15b={'raw':!![],'where':{}};var _0x43e219={};var _0x518104={'count':0x0,'rows':[]};return db[_0xd4c3('0x4c')]['findOne']({'where':{'id':_0x206afe[_0xd4c3('0x68')]['id']}})[_0xd4c3('0x23')](handleEntityNotFound(_0x1146fa,null))[_0xd4c3('0x23')](function(_0x5b0b80){if(_0x5b0b80){_0x43e219['model']=_[_0xd4c3('0x50')](db[_0xd4c3('0xd8')]['rawAttributes']);_0x43e219[_0xd4c3('0x53')]=_[_0xd4c3('0x50')](_0x206afe[_0xd4c3('0x53')]);_0x43e219[_0xd4c3('0x5b')]=_[_0xd4c3('0x54')](_0x43e219[_0xd4c3('0x4e')],_0x43e219[_0xd4c3('0x53')]);_0xa1c15b[_0xd4c3('0x55')]=_[_0xd4c3('0x54')](_0x43e219[_0xd4c3('0x4e')],qs['fields'](_0x206afe['query'][_0xd4c3('0x56')]));_0xa1c15b[_0xd4c3('0x55')]=_0xa1c15b[_0xd4c3('0x55')]['length']?_0xa1c15b[_0xd4c3('0x55')]:_0x43e219[_0xd4c3('0x4e')];if(!_0x206afe[_0xd4c3('0x53')][_0xd4c3('0x57')]('nolimit')){_0xa1c15b['limit']=qs[_0xd4c3('0x34')](_0x206afe[_0xd4c3('0x53')][_0xd4c3('0x34')]);_0xa1c15b[_0xd4c3('0x33')]=qs[_0xd4c3('0x33')](_0x206afe[_0xd4c3('0x53')][_0xd4c3('0x33')]);}_0xa1c15b['order']=qs['sort'](_0x206afe[_0xd4c3('0x53')]['sort']);_0xa1c15b[_0xd4c3('0x5a')]=qs['filters'](_[_0xd4c3('0x5c')](_0x206afe['query'],_0x43e219[_0xd4c3('0x5b')]));_0xa1c15b[_0xd4c3('0x5a')]['UserId']=_0x5b0b80['id'];if(_0x206afe['query']['filter']){_0xa1c15b[_0xd4c3('0x5a')]=_[_0xd4c3('0x63')](_0xa1c15b[_0xd4c3('0x5a')],{'$or':_['map'](_0xa1c15b[_0xd4c3('0x55')],function(_0x491143){var _0x1af367={};_0x1af367[_0x491143]={'$like':'%'+_0x206afe[_0xd4c3('0x53')][_0xd4c3('0x41')]+'%'};return _0x1af367;})});}_0xa1c15b=_[_0xd4c3('0x63')]({},_0xa1c15b,_0x206afe['options']);return db['MailInteraction'][_0xd4c3('0x32')]({'where':_0xa1c15b[_0xd4c3('0x5a')]})['then'](function(_0x2a1b5f){_0x518104[_0xd4c3('0x32')]=_0x2a1b5f;if(_0x206afe[_0xd4c3('0x53')][_0xd4c3('0x65')]){_0xa1c15b[_0xd4c3('0xc3')]=[{'all':!![]}];}return db[_0xd4c3('0xd8')][_0xd4c3('0x66')](_0xa1c15b);})[_0xd4c3('0x23')](function(_0x52a511){_0x518104[_0xd4c3('0xd1')]=_0x52a511;return _0x518104;});}})[_0xd4c3('0x23')](respondWithFilteredResult(_0x1146fa,_0xa1c15b))[_0xd4c3('0x2e')](handleError(_0x1146fa,null));};exports[_0xd4c3('0xd9')]=function(_0x2bca7e,_0x55332d,_0x3a7209){var _0x38e6fe={};var _0xe12d81={};var _0x3e2d45;var _0x47319b;return db[_0xd4c3('0x4c')][_0xd4c3('0xc0')]({'where':{'id':_0x2bca7e[_0xd4c3('0x68')]['id']}})[_0xd4c3('0x23')](handleEntityNotFound(_0x55332d,null))['then'](function(_0x4e64ae){if(_0x4e64ae){_0x3e2d45=_0x4e64ae;_0xe12d81[_0xd4c3('0x4e')]=_['keys'](db[_0xd4c3('0xda')][_0xd4c3('0x4d')]);_0xe12d81[_0xd4c3('0x53')]=_['keys'](_0x2bca7e[_0xd4c3('0x53')]);_0xe12d81[_0xd4c3('0x5b')]=_[_0xd4c3('0x54')](_0xe12d81[_0xd4c3('0x4e')],_0xe12d81[_0xd4c3('0x53')]);_0x38e6fe[_0xd4c3('0x55')]=_['intersection'](_0xe12d81['model'],qs['fields'](_0x2bca7e[_0xd4c3('0x53')][_0xd4c3('0x56')]));_0x38e6fe[_0xd4c3('0x55')]=_0x38e6fe[_0xd4c3('0x55')]['length']?_0x38e6fe['attributes']:_0xe12d81['model'];_0x38e6fe[_0xd4c3('0xc2')]=qs[_0xd4c3('0x59')](_0x2bca7e[_0xd4c3('0x53')]['sort']);_0x38e6fe['where']=qs[_0xd4c3('0x5b')](_['pick'](_0x2bca7e[_0xd4c3('0x53')],_0xe12d81[_0xd4c3('0x5b')]));if(_0x2bca7e['query']['filter']){_0x38e6fe['where']=_[_0xd4c3('0x63')](_0x38e6fe[_0xd4c3('0x5a')],{'$or':_['map'](_0x38e6fe[_0xd4c3('0x55')],function(_0xf4bbba){var _0x445dd7={};_0x445dd7[_0xf4bbba]={'$like':'%'+_0x2bca7e['query']['filter']+'%'};return _0x445dd7;})});}_0x38e6fe=_[_0xd4c3('0x63')]({},_0x38e6fe,_0x2bca7e[_0xd4c3('0x64')]);return _0x3e2d45['getSmsInteractions'](_0x38e6fe);}})[_0xd4c3('0x23')](function(_0x40bd5f){if(_0x40bd5f){_0x47319b=_0x40bd5f[_0xd4c3('0x69')];if(!_0x2bca7e['query']['hasOwnProperty'](_0xd4c3('0x58'))){_0x38e6fe['limit']=qs[_0xd4c3('0x34')](_0x2bca7e[_0xd4c3('0x53')][_0xd4c3('0x34')]);_0x38e6fe[_0xd4c3('0x33')]=qs[_0xd4c3('0x33')](_0x2bca7e[_0xd4c3('0x53')]['offset']);}return _0x3e2d45['getSmsInteractions'](_0x38e6fe);}})['then'](function(_0x111fe4){if(_0x111fe4){return _0x111fe4?{'count':_0x47319b,'rows':_0x111fe4}:null;}})[_0xd4c3('0x23')](respondWithResult(_0x55332d,null))[_0xd4c3('0x2e')](handleError(_0x55332d,null));};exports['getFaxInteractions']=function(_0x383877,_0x4586ff,_0x52a47d){var _0x1b7b8f={};var _0xf8972={};var _0x317b8a;var _0x116584;return db[_0xd4c3('0x4c')]['findOne']({'where':{'id':_0x383877[_0xd4c3('0x68')]['id']}})[_0xd4c3('0x23')](handleEntityNotFound(_0x4586ff,null))[_0xd4c3('0x23')](function(_0x4297f6){if(_0x4297f6){_0x317b8a=_0x4297f6;_0xf8972[_0xd4c3('0x4e')]=_[_0xd4c3('0x50')](db[_0xd4c3('0xdb')][_0xd4c3('0x4d')]);_0xf8972[_0xd4c3('0x53')]=_[_0xd4c3('0x50')](_0x383877[_0xd4c3('0x53')]);_0xf8972['filters']=_[_0xd4c3('0x54')](_0xf8972[_0xd4c3('0x4e')],_0xf8972[_0xd4c3('0x53')]);_0x1b7b8f[_0xd4c3('0x55')]=_[_0xd4c3('0x54')](_0xf8972[_0xd4c3('0x4e')],qs[_0xd4c3('0x56')](_0x383877['query'][_0xd4c3('0x56')]));_0x1b7b8f[_0xd4c3('0x55')]=_0x1b7b8f[_0xd4c3('0x55')][_0xd4c3('0x69')]?_0x1b7b8f[_0xd4c3('0x55')]:_0xf8972['model'];_0x1b7b8f[_0xd4c3('0xc2')]=qs[_0xd4c3('0x59')](_0x383877[_0xd4c3('0x53')][_0xd4c3('0x59')]);_0x1b7b8f[_0xd4c3('0x5a')]=qs[_0xd4c3('0x5b')](_[_0xd4c3('0x5c')](_0x383877[_0xd4c3('0x53')],_0xf8972[_0xd4c3('0x5b')]));if(_0x383877[_0xd4c3('0x53')][_0xd4c3('0x41')]){_0x1b7b8f[_0xd4c3('0x5a')]=_[_0xd4c3('0x63')](_0x1b7b8f[_0xd4c3('0x5a')],{'$or':_[_0xd4c3('0x5d')](_0x1b7b8f[_0xd4c3('0x55')],function(_0x20c387){var _0x4a562e={};_0x4a562e[_0x20c387]={'$like':'%'+_0x383877[_0xd4c3('0x53')]['filter']+'%'};return _0x4a562e;})});}_0x1b7b8f=_[_0xd4c3('0x63')]({},_0x1b7b8f,_0x383877['options']);return _0x317b8a[_0xd4c3('0xdc')](_0x1b7b8f);}})[_0xd4c3('0x23')](function(_0x52bb26){if(_0x52bb26){_0x116584=_0x52bb26[_0xd4c3('0x69')];if(!_0x383877[_0xd4c3('0x53')]['hasOwnProperty']('nolimit')){_0x1b7b8f[_0xd4c3('0x34')]=qs[_0xd4c3('0x34')](_0x383877[_0xd4c3('0x53')][_0xd4c3('0x34')]);_0x1b7b8f[_0xd4c3('0x33')]=qs['offset'](_0x383877[_0xd4c3('0x53')][_0xd4c3('0x33')]);}return _0x317b8a[_0xd4c3('0xdc')](_0x1b7b8f);}})[_0xd4c3('0x23')](function(_0xe08125){if(_0xe08125){return _0xe08125?{'count':_0x116584,'rows':_0xe08125}:null;}})['then'](respondWithResult(_0x4586ff,null))[_0xd4c3('0x2e')](handleError(_0x4586ff,null));};exports['login']=function(_0x40b646,_0x241f9c,_0x4b2d29){var _0x67e65d;var _0x53a457;var _0x191991;var _0x4a4745=!_[_0xd4c3('0x74')](_0x40b646[_0xd4c3('0x68')]['id'])?_0x40b646[_0xd4c3('0x68')]['id']:!_[_0xd4c3('0x74')](_0x40b646[_0xd4c3('0x3c')]['id'])?_0x40b646[_0xd4c3('0x3c')]['id']:null;return db['User']['find']({'where':{'id':_0x4a4745,'role':'agent'},'attributes':['id','name',_0xd4c3('0xdd'),'mobile',_0xd4c3('0x45'),_0xd4c3('0x78'),_0xd4c3('0x9f')]})[_0xd4c3('0x23')](handleEntityNotFound(_0x241f9c,null))[_0xd4c3('0x23')](function(_0x1a9404){if(_0x1a9404){_0x67e65d=_0x1a9404;if(_0x40b646['body'][_0xd4c3('0xa1')]){_0x191991=util[_0xd4c3('0x76')](_0xd4c3('0xde'),_0x67e65d[_0x40b646[_0xd4c3('0x6b')]['interface']]);}else if(_0x40b646[_0xd4c3('0x6b')][_0xd4c3('0xdf')]){_0x191991=util[_0xd4c3('0x76')](_0xd4c3('0xaf'),_0x40b646[_0xd4c3('0x6b')][_0xd4c3('0xdf')]);}else{_0x191991=util[_0xd4c3('0x76')](_0xd4c3('0xaf'),_0x67e65d[_0xd4c3('0x47')]);}socket['to'](util[_0xd4c3('0x76')](_0xd4c3('0xe0'),_0x67e65d[_0xd4c3('0x47')]))[_0xd4c3('0xa9')](_0xd4c3('0xe1'),{'ip':_0x40b646[_0xd4c3('0xe2')][_0xd4c3('0xe3')]||_0x40b646['connection'][_0xd4c3('0xe4')]||_0x40b646[_0xd4c3('0xe5')][_0xd4c3('0xe4')]||_0x40b646[_0xd4c3('0xe6')]['socket']['remoteAddress']});return db[_0xd4c3('0xb1')][_0xd4c3('0x39')]({'where':{'membername':_0x67e65d[_0xd4c3('0x47')]},'individualHooks':!![]});}})[_0xd4c3('0x23')](function(_0x478ffa){if(_0x67e65d){return _0x67e65d[_0xd4c3('0xe7')]({'raw':!![]});}})[_0xd4c3('0x23')](function(_0x4ddf9a){var _0x11c0a0=[];if(_0x4ddf9a){_0x53a457=_0x4ddf9a;if(_0x53a457['length']){for(var _0xbbe7ca=0x0;_0xbbe7ca<_0x53a457[_0xd4c3('0x69')];_0xbbe7ca++){_0x11c0a0[_0xd4c3('0xae')]({'membername':_0x67e65d[_0xd4c3('0x47')],'UserId':_0x67e65d['id'],'queue_name':_0x53a457[_0xbbe7ca][_0xd4c3('0x47')],'VoiceQueueId':_0x53a457[_0xbbe7ca]['id'],'interface':_0x191991,'paused':_0x67e65d[_0xd4c3('0x9f')]||![],'penalty':_0x53a457[_0xbbe7ca][_0xd4c3('0xe8')]||0x0});}return BPromise[_0xd4c3('0xb0')](_0x11c0a0,function(_0xc003a){return db[_0xd4c3('0xb1')][_0xd4c3('0xb2')](_0xc003a);});}}})['then'](function(){return db[_0xd4c3('0xe9')][_0xd4c3('0x66')]({'where':{'membername':_0x67e65d['name'],'exitAt':null}});})[_0xd4c3('0x23')](function(_0x4ab3d4){var _0x2a19bf=[];_0x4ab3d4[_0xd4c3('0xea')](function(_0x4a2929){_0x2a19bf['push'](_0x4a2929[_0xd4c3('0x38')]({'exitAt':moment()[_0xd4c3('0x76')](_0xd4c3('0xeb'))}));});return BPromise[_0xd4c3('0xec')](_0x2a19bf);})[_0xd4c3('0x23')](function(){var _0x480d22=[];var _0x1058c6=[];var _0x1a15b0=utils[_0xd4c3('0xed')]();var _0x2f7fee={'membername':_0x67e65d[_0xd4c3('0x47')],'interface':_0x191991,'enterAt':moment()[_0xd4c3('0x76')](_0xd4c3('0xeb')),'role':_0x67e65d[_0xd4c3('0x45')],'internal':_0x67e65d[_0xd4c3('0x78')]};_0x1a15b0[_0xd4c3('0xea')](function(_0x54afeb){_0x480d22[_0xd4c3('0xae')](_['merge']({'channel':_0x54afeb,'type':'LOGIN','data1':_0x40b646[_0xd4c3('0x6b')]['device'],'data2':_0x191991},_0x2f7fee));if(_0x67e65d['loginInPause']){_0x1058c6[_0xd4c3('0xae')](_[_0xd4c3('0x63')]({'channel':_0x54afeb,'type':'PAUSE','data1':'LOGININPAUSE'},_0x2f7fee));}});return db[_0xd4c3('0xe9')][_0xd4c3('0x6a')](_0x480d22[_0xd4c3('0xee')](_0x1058c6),{'individualHooks':!![]});})['then'](function(){return _0x67e65d[_0xd4c3('0x38')]({'online':!![],'lastLoginAt':moment()[_0xd4c3('0x76')](_0xd4c3('0xeb')),'voicePause':_0x67e65d['loginInPause']||![],'mailPause':_0x67e65d['loginInPause']||![],'chatPause':_0x67e65d['loginInPause']||![],'faxPause':_0x67e65d[_0xd4c3('0x9f')]||![],'smsPause':_0x67e65d[_0xd4c3('0x9f')]||![],'openchannelPause':_0x67e65d['loginInPause']||![],'pauseType':_0x67e65d[_0xd4c3('0x9f')]?_0xd4c3('0xef'):null,'interface':_0x191991,'lastPauseAt':moment()[_0xd4c3('0x76')](_0xd4c3('0xeb'))});})[_0xd4c3('0x23')](function(_0x318ee5){if(_0x40b646[_0xd4c3('0xf0')]){return _0x4b2d29();}else{return BPromise['resolve'](_0x318ee5)['then'](respondWithResult(_0x241f9c,null));}})[_0xd4c3('0x2e')](handleError(_0x241f9c,null));};exports['logout']=function(_0x4a0b31,_0x4d0419,_0xa64adb){var _0x2451d4;return db[_0xd4c3('0x4c')][_0xd4c3('0x46')]({'where':{'id':_0x4a0b31[_0xd4c3('0x68')]['id'],'role':'agent'},'attributes':['id',_0xd4c3('0x47'),'role']})[_0xd4c3('0x23')](handleEntityNotFound(_0x4d0419,null))['then'](function(_0xd80a65){if(_0xd80a65){_0x2451d4=_0xd80a65;return db[_0xd4c3('0xb1')][_0xd4c3('0x39')]({'where':{'membername':_0x2451d4[_0xd4c3('0x47')]},'individualHooks':!![]});}})[_0xd4c3('0x23')](function(){return db[_0xd4c3('0xe9')][_0xd4c3('0x66')]({'where':{'membername':_0x2451d4[_0xd4c3('0x47')],'exitAt':null}});})[_0xd4c3('0x23')](function(_0x472498){var _0x1f819e=[];_0x472498[_0xd4c3('0xea')](function(_0x524df4){_0x1f819e[_0xd4c3('0xae')](_0x524df4['update']({'exitAt':moment()[_0xd4c3('0x76')](_0xd4c3('0xeb'))}));});return BPromise[_0xd4c3('0xec')](_0x1f819e);})[_0xd4c3('0x23')](function(){return _0x2451d4[_0xd4c3('0x38')]({'online':![],'lastLoginAt':null,'voicePause':![],'mailPause':![],'chatPause':![],'faxPause':![],'smsPause':![],'openchannelPause':![],'interface':null});})['then'](respondWithResult(_0x4d0419,null))[_0xd4c3('0x2e')](handleError(_0x4d0419,null));};exports[_0xd4c3('0xf1')]=function(_0x4e3539,_0x5508bd,_0x576db2){var _0x22dba1;return db[_0xd4c3('0xb1')][_0xd4c3('0x38')]({'paused':0x1},{'where':{'UserId':_0x4e3539[_0xd4c3('0x68')]['id']},'individualHooks':!![]})['then'](function(){return db[_0xd4c3('0x4c')][_0xd4c3('0x46')]({'where':{'id':_0x4e3539[_0xd4c3('0x68')]['id'],'role':'agent'},'attributes':['id',_0xd4c3('0x47'),'role','internal',_0xd4c3('0xa1')]});})['then'](handleEntityNotFound(_0x5508bd,null))[_0xd4c3('0x23')](function(_0x6bbdd5){if(_0x6bbdd5){_0x22dba1=_0x6bbdd5;return respondWithRpcPromise(_0xd4c3('0xf2'),_0xd4c3('0xf1'),{'id':_0x22dba1['id'],'name':_0x22dba1[_0xd4c3('0x47')],'pause':!![]});}})[_0xd4c3('0x23')](function(){if(_0x22dba1){return db[_0xd4c3('0xe9')][_0xd4c3('0x66')]({'where':{'membername':_0x22dba1['name'],'type':_0xd4c3('0xf3'),'exitAt':null}});}})[_0xd4c3('0x23')](function(_0x5afcb1){if(_0x5afcb1[_0xd4c3('0x69')]){var _0x93ef4d=moment()[_0xd4c3('0x76')](_0xd4c3('0xeb'));for(var _0x30b4a3=0x0,_0x143440=_0x5afcb1[_0xd4c3('0x69')];_0x30b4a3<_0x143440;_0x30b4a3++){_0x5afcb1[_0x30b4a3][_0xd4c3('0xf4')]({'exitAt':_0x93ef4d});}}})[_0xd4c3('0x23')](function(){var _0x4ecc42=[];var _0x7b5815=utils[_0xd4c3('0xed')]();_0x7b5815['forEach'](function(_0x80ba89){_0x4ecc42['push']({'channel':_0x80ba89,'membername':_0x22dba1['name'],'interface':_[_0xd4c3('0x74')](_0x22dba1[_0xd4c3('0xa1')])?util[_0xd4c3('0x76')](_0xd4c3('0xaf'),_0x22dba1[_0xd4c3('0x47')]):_0x22dba1[_0xd4c3('0xa1')],'type':_0xd4c3('0xf3'),'enterAt':moment()[_0xd4c3('0x76')](_0xd4c3('0xeb')),'data1':_0x4e3539['body']['type']||_0xd4c3('0xf5'),'role':_0x22dba1['role'],'internal':_0x22dba1['internal']});});return db[_0xd4c3('0xe9')][_0xd4c3('0x6a')](_0x4ecc42,{'individualHooks':!![]});})[_0xd4c3('0x23')](function(){return _0x22dba1['update']({'voicePause':!![],'mailPause':!![],'chatPause':!![],'faxPause':!![],'smsPause':!![],'openchannelPause':!![],'pauseType':_0x4e3539[_0xd4c3('0x6b')][_0xd4c3('0xf6')]||'DEFAULT\x20PAUSE','lastPauseAt':moment()['format'](_0xd4c3('0xeb'))});})[_0xd4c3('0x23')](respondWithResult(_0x5508bd,null))[_0xd4c3('0x2e')](handleError(_0x5508bd,null));};exports[_0xd4c3('0xf7')]=function(_0x3f619a,_0x400c79,_0x1cd575){var _0x2bfc00;return db[_0xd4c3('0x4c')][_0xd4c3('0x46')]({'where':{'id':_0x3f619a[_0xd4c3('0x68')]['id']},'attributes':['id',_0xd4c3('0x47'),_0xd4c3('0x45'),_0xd4c3('0xa0'),_0xd4c3('0xf8'),'chatPause',_0xd4c3('0xf9'),_0xd4c3('0xfa'),_0xd4c3('0xfb'),_0xd4c3('0xfc'),_0xd4c3('0xfd')]})[_0xd4c3('0x23')](handleEntityNotFound(_0x400c79,null))[_0xd4c3('0x23')](function(_0x1c7a64){if(_0x1c7a64){_0x2bfc00=_0x1c7a64;if(_0x3f619a[_0xd4c3('0x6b')]['channel']&&!utils[_0xd4c3('0xa2')](_0x3f619a[_0xd4c3('0x6b')][_0xd4c3('0x9d')])){throw new db[(_0xd4c3('0x95'))][(_0xd4c3('0x98'))](_0xd4c3('0xa3'));}switch(_0x3f619a['body']['channel']){case _0xd4c3('0xac'):return respondWithRpcPromise(_0xd4c3('0xf2'),_0xd4c3('0xf7'),{'id':_0x2bfc00['id'],'name':_0x2bfc00[_0xd4c3('0x47')],'pause':![]})['then'](function(){return db[_0xd4c3('0xb1')][_0xd4c3('0x38')]({'paused':0x0},{'where':{'UserId':_0x2bfc00['id']},'individualHooks':!![]});})[_0xd4c3('0x23')](function(){return db['MemberReport'][_0xd4c3('0x46')]({'where':{'channel':_0x3f619a[_0xd4c3('0x6b')][_0xd4c3('0x9d')],'membername':_0x2bfc00[_0xd4c3('0x47')],'type':_0xd4c3('0xf3'),'exitAt':null}});})[_0xd4c3('0x23')](function(_0x465754){if(_0x465754){return _0x465754[_0xd4c3('0x38')]({'exitAt':moment()[_0xd4c3('0x76')](_0xd4c3('0xeb')),'data2':_0xd4c3('0xfe')},{'individualHooks':!![]});}return null;})[_0xd4c3('0x23')](function(){return _0x2bfc00['update']({'voicePause':![]});});case _0xd4c3('0xff'):case _0xd4c3('0x100'):case _0xd4c3('0x101'):case _0xd4c3('0x102'):case _0xd4c3('0x103'):return db[_0xd4c3('0xe9')][_0xd4c3('0x46')]({'where':{'channel':_0x3f619a[_0xd4c3('0x6b')]['channel'],'membername':_0x2bfc00[_0xd4c3('0x47')],'type':'PAUSE','exitAt':null}})['then'](function(_0x15d406){if(_0x15d406){return _0x15d406[_0xd4c3('0x38')]({'exitAt':moment()[_0xd4c3('0x76')]('YYYY-MM-DD\x20HH:mm:ss'),'data2':'manual'},{'individualHooks':!![]});}return null;})[_0xd4c3('0x23')](function(){var _0xfc4765={};_[_0xd4c3('0x104')](_0xfc4765,util[_0xd4c3('0x76')]('%s%s',_0x3f619a['body'][_0xd4c3('0x9d')],_0xd4c3('0x105')),![]);return _0x2bfc00[_0xd4c3('0x38')](_0xfc4765);});default:return respondWithRpcPromise(_0xd4c3('0xf2'),'unpause',{'id':_0x2bfc00['id'],'name':_0x2bfc00['name'],'pause':![]})[_0xd4c3('0x23')](function(){return db[_0xd4c3('0xb1')]['update']({'paused':0x0},{'where':{'UserId':_0x2bfc00['id']}});})[_0xd4c3('0x23')](function(){return db[_0xd4c3('0xe9')][_0xd4c3('0x66')]({'where':{'membername':_0x2bfc00[_0xd4c3('0x47')],'type':_0xd4c3('0xf3'),'exitAt':null}});})['then'](function(_0x1b8c72){var _0x53fe66=[];_0x1b8c72[_0xd4c3('0xea')](function(_0x3473dd){_0x53fe66[_0xd4c3('0xae')](_0x3473dd[_0xd4c3('0x38')]({'exitAt':moment()[_0xd4c3('0x76')](_0xd4c3('0xeb')),'data2':_0xd4c3('0xfe')}));});return BPromise[_0xd4c3('0xec')](_0x53fe66);})['then'](function(){return _0x2bfc00[_0xd4c3('0x38')]({'voicePause':![],'mailPause':![],'chatPause':![],'faxPause':![],'smsPause':![],'openchannelPause':![]});});}}})[_0xd4c3('0x23')](respondWithResult(_0x400c79,null))['catch'](handleError(_0x400c79,null));};exports[_0xd4c3('0x106')]=function(_0x39f8a1,_0x4e2728,_0x34fc4a){var _0x18fd41={};var _0x51d3ed={};var _0x3a5894;var _0x28ee25;return db['User'][_0xd4c3('0xc0')]({'where':{'id':_0x39f8a1[_0xd4c3('0x68')]['id']}})[_0xd4c3('0x23')](handleEntityNotFound(_0x4e2728,null))[_0xd4c3('0x23')](function(_0xb3f89f){if(_0xb3f89f){_0x3a5894=_0xb3f89f;_0x51d3ed[_0xd4c3('0x4e')]=_[_0xd4c3('0x50')](db[_0xd4c3('0x107')]['rawAttributes']);_0x51d3ed[_0xd4c3('0x53')]=_[_0xd4c3('0x50')](_0x39f8a1[_0xd4c3('0x53')]);_0x51d3ed[_0xd4c3('0x5b')]=_[_0xd4c3('0x54')](_0x51d3ed[_0xd4c3('0x4e')],_0x51d3ed['query']);_0x18fd41[_0xd4c3('0x55')]=_[_0xd4c3('0x54')](_0x51d3ed[_0xd4c3('0x4e')],qs[_0xd4c3('0x56')](_0x39f8a1[_0xd4c3('0x53')][_0xd4c3('0x56')]));_0x18fd41[_0xd4c3('0x55')]=_0x18fd41[_0xd4c3('0x55')]['length']?_0x18fd41[_0xd4c3('0x55')]:_0x51d3ed['model'];_0x18fd41[_0xd4c3('0xc2')]=qs[_0xd4c3('0x59')](_0x39f8a1[_0xd4c3('0x53')][_0xd4c3('0x59')]);_0x18fd41[_0xd4c3('0x5a')]=qs['filters'](_[_0xd4c3('0x5c')](_0x39f8a1['query'],_0x51d3ed[_0xd4c3('0x5b')]));if(_0x39f8a1['query'][_0xd4c3('0x41')]){_0x18fd41[_0xd4c3('0x5a')]=_[_0xd4c3('0x63')](_0x18fd41[_0xd4c3('0x5a')],{'$or':_[_0xd4c3('0x5d')](_0x18fd41[_0xd4c3('0x55')],function(_0x38fcea){var _0x2420a5={};_0x2420a5[_0x38fcea]={'$like':'%'+_0x39f8a1[_0xd4c3('0x53')][_0xd4c3('0x41')]+'%'};return _0x2420a5;})});}_0x18fd41=_[_0xd4c3('0x63')]({},_0x18fd41,_0x39f8a1[_0xd4c3('0x64')]);return _0x3a5894[_0xd4c3('0x106')](_0x18fd41);}})[_0xd4c3('0x23')](function(_0x67d25b){if(_0x67d25b){_0x28ee25=_0x67d25b[_0xd4c3('0x69')];if(!_0x39f8a1[_0xd4c3('0x53')][_0xd4c3('0x57')](_0xd4c3('0x58'))){_0x18fd41[_0xd4c3('0x34')]=qs[_0xd4c3('0x34')](_0x39f8a1[_0xd4c3('0x53')][_0xd4c3('0x34')]);_0x18fd41[_0xd4c3('0x33')]=qs[_0xd4c3('0x33')](_0x39f8a1[_0xd4c3('0x53')]['offset']);}return _0x3a5894[_0xd4c3('0x106')](_0x18fd41);}})[_0xd4c3('0x23')](function(_0xef641b){if(_0xef641b){return _0xef641b?{'count':_0x28ee25,'rows':_0xef641b}:null;}})[_0xd4c3('0x23')](respondWithResult(_0x4e2728,null))[_0xd4c3('0x2e')](handleError(_0x4e2728,null));};exports[_0xd4c3('0x108')]=function(_0x1ad001,_0x10207e,_0x5c7448){return db[_0xd4c3('0x4c')][_0xd4c3('0x46')]({'where':{'id':_0x1ad001[_0xd4c3('0x68')]['id']}})['then'](handleEntityNotFound(_0x10207e,null))['then'](function(_0x1c577a){if(_0x1c577a){return _0x1c577a[_0xd4c3('0x108')](_0x1ad001[_0xd4c3('0x6b')][_0xd4c3('0x6e')],_[_0xd4c3('0x6f')](_0x1ad001[_0xd4c3('0x6b')],[_0xd4c3('0x6e'),'id'])||{});}})[_0xd4c3('0x23')](respondWithResult(_0x10207e,null))[_0xd4c3('0x2e')](handleError(_0x10207e,null));};exports[_0xd4c3('0x109')]=function(_0x425037,_0x25635e,_0x2aae34){return db[_0xd4c3('0x4c')][_0xd4c3('0x46')]({'where':{'id':_0x425037[_0xd4c3('0x68')]['id']}})['then'](handleEntityNotFound(_0x25635e,null))[_0xd4c3('0x23')](function(_0x5b2c4c){if(_0x5b2c4c){return _0x5b2c4c[_0xd4c3('0x109')](_0x425037[_0xd4c3('0x53')][_0xd4c3('0x6e')]);}})['then'](respondWithStatusCode(_0x25635e,null))['catch'](handleError(_0x25635e,null));};exports[_0xd4c3('0x10a')]=function(_0x187263,_0x558e35,_0x5c06f0){var _0x10da19={};var _0x1c22d9={};var _0x49e986;var _0x13c087;return db['User'][_0xd4c3('0xc0')]({'where':{'id':_0x187263[_0xd4c3('0x68')]['id']}})['then'](handleEntityNotFound(_0x558e35,null))[_0xd4c3('0x23')](function(_0x64bd0b){if(_0x64bd0b){_0x49e986=_0x64bd0b;_0x1c22d9[_0xd4c3('0x4e')]=_[_0xd4c3('0x50')](db[_0xd4c3('0x10b')][_0xd4c3('0x4d')]);_0x1c22d9['query']=_[_0xd4c3('0x50')](_0x187263[_0xd4c3('0x53')]);_0x1c22d9[_0xd4c3('0x5b')]=_[_0xd4c3('0x54')](_0x1c22d9[_0xd4c3('0x4e')],_0x1c22d9['query']);_0x10da19[_0xd4c3('0x55')]=_[_0xd4c3('0x54')](_0x1c22d9[_0xd4c3('0x4e')],qs[_0xd4c3('0x56')](_0x187263[_0xd4c3('0x53')]['fields']));_0x10da19[_0xd4c3('0x55')]=_0x10da19[_0xd4c3('0x55')][_0xd4c3('0x69')]?_0x10da19[_0xd4c3('0x55')]:_0x1c22d9[_0xd4c3('0x4e')];_0x10da19[_0xd4c3('0xc2')]=qs[_0xd4c3('0x59')](_0x187263[_0xd4c3('0x53')][_0xd4c3('0x59')]);_0x10da19[_0xd4c3('0x5a')]=qs[_0xd4c3('0x5b')](_[_0xd4c3('0x5c')](_0x187263[_0xd4c3('0x53')],_0x1c22d9['filters']));if(_0x187263[_0xd4c3('0x53')][_0xd4c3('0x41')]){_0x10da19[_0xd4c3('0x5a')]=_[_0xd4c3('0x63')](_0x10da19[_0xd4c3('0x5a')],{'$or':_[_0xd4c3('0x5d')](_0x10da19[_0xd4c3('0x55')],function(_0x1c9a89){var _0x40ce57={};_0x40ce57[_0x1c9a89]={'$like':'%'+_0x187263[_0xd4c3('0x53')]['filter']+'%'};return _0x40ce57;})});}_0x10da19=_[_0xd4c3('0x63')]({},_0x10da19,_0x187263[_0xd4c3('0x64')]);return _0x49e986[_0xd4c3('0x10a')](_0x10da19);}})['then'](function(_0x1a8553){if(_0x1a8553){_0x13c087=_0x1a8553[_0xd4c3('0x69')];if(!_0x187263[_0xd4c3('0x53')]['hasOwnProperty']('nolimit')){_0x10da19['limit']=qs[_0xd4c3('0x34')](_0x187263[_0xd4c3('0x53')][_0xd4c3('0x34')]);_0x10da19[_0xd4c3('0x33')]=qs['offset'](_0x187263[_0xd4c3('0x53')][_0xd4c3('0x33')]);}return _0x49e986[_0xd4c3('0x10a')](_0x10da19);}})['then'](function(_0x4ede95){if(_0x4ede95){return _0x4ede95?{'count':_0x13c087,'rows':_0x4ede95}:null;}})[_0xd4c3('0x23')](respondWithResult(_0x558e35,null))[_0xd4c3('0x2e')](handleError(_0x558e35,null));};exports['getAgents']=function(_0x33c68d,_0x542edb,_0x443f97){var _0x28d4da={};var _0x10c837={};var _0x28bf44;var _0x1d5395;return db[_0xd4c3('0x4c')][_0xd4c3('0xc0')]({'where':{'id':_0x33c68d[_0xd4c3('0x68')]['id']}})['then'](handleEntityNotFound(_0x542edb,null))[_0xd4c3('0x23')](function(_0xcf5781){if(_0xcf5781){_0x28bf44=_0xcf5781;_0x10c837[_0xd4c3('0x4e')]=_[_0xd4c3('0x50')](db['User'][_0xd4c3('0x4d')]);_0x10c837[_0xd4c3('0x53')]=_[_0xd4c3('0x50')](_0x33c68d['query']);_0x10c837[_0xd4c3('0x5b')]=_[_0xd4c3('0x54')](_0x10c837['model'],_0x10c837[_0xd4c3('0x53')]);_0x28d4da[_0xd4c3('0x55')]=_[_0xd4c3('0x54')](_0x10c837[_0xd4c3('0x4e')],qs[_0xd4c3('0x56')](_0x33c68d[_0xd4c3('0x53')][_0xd4c3('0x56')]));_0x28d4da[_0xd4c3('0x55')]=_0x28d4da['attributes'][_0xd4c3('0x69')]?_0x28d4da['attributes']:_0x10c837[_0xd4c3('0x4e')];_0x28d4da[_0xd4c3('0xc2')]=qs['sort'](_0x33c68d[_0xd4c3('0x53')][_0xd4c3('0x59')]);_0x28d4da['where']=qs[_0xd4c3('0x5b')](_[_0xd4c3('0x5c')](_0x33c68d[_0xd4c3('0x53')],_0x10c837[_0xd4c3('0x5b')]));if(_0x33c68d[_0xd4c3('0x53')][_0xd4c3('0x41')]){_0x28d4da[_0xd4c3('0x5a')]=_[_0xd4c3('0x63')](_0x28d4da['where'],{'$or':_[_0xd4c3('0x5d')](_0x28d4da['attributes'],function(_0x1ec402){var _0x3a77aa={};_0x3a77aa[_0x1ec402]={'$like':'%'+_0x33c68d[_0xd4c3('0x53')][_0xd4c3('0x41')]+'%'};return _0x3a77aa;})});}_0x28d4da[_0xd4c3('0x4e')]=db[_0xd4c3('0x4c')];_0x28d4da['as']=_0xd4c3('0x3d');_0x28d4da=_[_0xd4c3('0x63')]({},_0x28d4da,_0x33c68d[_0xd4c3('0x64')]);return _0x28bf44[_0xd4c3('0xe7')]({'include':[_0x28d4da]});}})[_0xd4c3('0x23')](function(_0x42c5f0){if(_0x42c5f0){var _0x5e4a32={},_0x107264=[],_0x51d6d4=0x0;for(var _0x3d8fbe=0x0;_0x3d8fbe<_0x42c5f0['length'];_0x3d8fbe+=0x1){for(var _0x528118=0x0,_0x4d70f9;_0x528118<_0x42c5f0[_0x3d8fbe][_0xd4c3('0x3d')][_0xd4c3('0x69')];_0x528118+=0x1){_0x4d70f9=_0x42c5f0[_0x3d8fbe][_0xd4c3('0x3d')][_0x528118][_0xd4c3('0x3a')]({'plain':!![]});_0x5e4a32[_0x4d70f9['id']]=_0x4d70f9;}}_0x5e4a32=_['values'](_0x5e4a32);for(var _0x53780a=qs[_0xd4c3('0x33')](_0x33c68d['query'][_0xd4c3('0x33')]);_0x53780a<_0x5e4a32[_0xd4c3('0x69')]&&_0x107264[_0xd4c3('0x69')]<qs[_0xd4c3('0x34')](_0x33c68d[_0xd4c3('0x53')]['limit']);_0x53780a+=0x1){if(_0x5e4a32[_0x53780a]){_0x107264[_0xd4c3('0xae')](_0x5e4a32[_0x53780a]);}}return{'count':_0x5e4a32['length'],'rows':_0x107264};}})['then'](respondWithResult(_0x542edb,null))['catch'](handleError(_0x542edb,null));};exports[_0xd4c3('0x39')]=function(_0x13eeab,_0x5abcd7){if(_0x13eeab[_0xd4c3('0x3c')]['id']==_0x13eeab['params']['id']){return _0x5abcd7['status'](0x1f4)[_0xd4c3('0x4a')]({'message':_0xd4c3('0x10c')});}return db[_0xd4c3('0x4c')][_0xd4c3('0x46')]({'where':{'id':_0x13eeab[_0xd4c3('0x68')]['id']}})[_0xd4c3('0x23')](handleEntityNotFound(_0x5abcd7,null))['then'](removeEntity(_0x5abcd7,null))[_0xd4c3('0x2e')](handleError(_0x5abcd7,null));};exports[_0xd4c3('0x10d')]=function(_0x560461,_0x4cf426,_0x53d001){return db['User'][_0xd4c3('0x46')]({'where':{'id':_0x560461[_0xd4c3('0x68')]['id']}})[_0xd4c3('0x23')](handleEntityNotFound(_0x4cf426,null))['then'](function(_0x59e368){if(_0x59e368){return _0x59e368[_0xd4c3('0x10d')](_0x560461[_0xd4c3('0x6b')]['ids'],_[_0xd4c3('0x6f')](_0x560461[_0xd4c3('0x6b')],[_0xd4c3('0x6e'),'id'])||{})[_0xd4c3('0xa7')](function(){for(var _0x8969d3=0x0;_0x8969d3<_0x560461[_0xd4c3('0x6b')][_0xd4c3('0x6e')][_0xd4c3('0x69')];_0x8969d3+=0x1){socket[_0xd4c3('0xa9')](_0xd4c3('0x10e'),{'ChatInteractionId':Number(_0x560461[_0xd4c3('0x6b')]['ids'][_0x8969d3]),'UserId':Number(_0x560461[_0xd4c3('0x68')]['id'])});}return _0x560461[_0xd4c3('0x6b')][_0xd4c3('0x6e')];});}})[_0xd4c3('0x23')](respondWithResult(_0x4cf426,null))[_0xd4c3('0x2e')](handleError(_0x4cf426,null));};exports[_0xd4c3('0x10f')]=function(_0x5c8ba1,_0x2360ed,_0x26b7ed){return db['User'][_0xd4c3('0x46')]({'where':{'id':_0x5c8ba1[_0xd4c3('0x68')]['id']}})['then'](handleEntityNotFound(_0x2360ed,null))[_0xd4c3('0x23')](function(_0x3e4f0b){if(_0x3e4f0b){return _0x3e4f0b[_0xd4c3('0x10f')](_0x5c8ba1[_0xd4c3('0x53')][_0xd4c3('0x6e')])[_0xd4c3('0x23')](function(){if(_[_0xd4c3('0x110')](_0x5c8ba1[_0xd4c3('0x53')][_0xd4c3('0x6e')])){for(var _0x3c5dc8=0x0;_0x3c5dc8<_0x5c8ba1['query'][_0xd4c3('0x6e')][_0xd4c3('0x69')];_0x3c5dc8+=0x1){socket[_0xd4c3('0xa9')]('user_has_chat_interactions:remove',{'ChatInteractionId':Number(_0x5c8ba1[_0xd4c3('0x53')][_0xd4c3('0x6e')][_0x3c5dc8]),'UserId':Number(_0x5c8ba1[_0xd4c3('0x68')]['id'])});}}else{socket[_0xd4c3('0xa9')](_0xd4c3('0x111'),{'ChatInteractionId':Number(_0x5c8ba1[_0xd4c3('0x53')][_0xd4c3('0x6e')]),'UserId':Number(_0x5c8ba1[_0xd4c3('0x68')]['id'])});}});}})[_0xd4c3('0x23')](respondWithStatusCode(_0x2360ed,null))['catch'](handleError(_0x2360ed,null));};exports['addMailInteractions']=function(_0x8b8d9b,_0x5c6685,_0x59f9bb){return db['User']['find']({'where':{'id':_0x8b8d9b['params']['id']}})[_0xd4c3('0x23')](handleEntityNotFound(_0x5c6685,null))['then'](function(_0x4fb0a9){if(_0x4fb0a9){return _0x4fb0a9[_0xd4c3('0x112')](_0x8b8d9b[_0xd4c3('0x6b')][_0xd4c3('0x6e')],_[_0xd4c3('0x6f')](_0x8b8d9b['body'],[_0xd4c3('0x6e'),'id'])||{})['spread'](function(){for(var _0x18ce3c=0x0;_0x18ce3c<_0x8b8d9b[_0xd4c3('0x6b')][_0xd4c3('0x6e')][_0xd4c3('0x69')];_0x18ce3c+=0x1){socket[_0xd4c3('0xa9')](_0xd4c3('0x113'),{'MailInteractionId':Number(_0x8b8d9b[_0xd4c3('0x6b')]['ids'][_0x18ce3c]),'UserId':Number(_0x8b8d9b[_0xd4c3('0x68')]['id'])});}return _0x8b8d9b['body'][_0xd4c3('0x6e')];});}})[_0xd4c3('0x23')](respondWithResult(_0x5c6685,null))[_0xd4c3('0x2e')](handleError(_0x5c6685,null));};exports['removeMailInteractions']=function(_0x56f1c4,_0x3d024f,_0x1cdd98){return db['User'][_0xd4c3('0x46')]({'where':{'id':_0x56f1c4[_0xd4c3('0x68')]['id']}})['then'](handleEntityNotFound(_0x3d024f,null))[_0xd4c3('0x23')](function(_0x3bed82){if(_0x3bed82){return _0x3bed82['removeMailInteractions'](_0x56f1c4[_0xd4c3('0x53')]['ids'])['then'](function(){if(_[_0xd4c3('0x110')](_0x56f1c4[_0xd4c3('0x53')][_0xd4c3('0x6e')])){for(var _0x5c623c=0x0;_0x5c623c<_0x56f1c4[_0xd4c3('0x53')][_0xd4c3('0x6e')][_0xd4c3('0x69')];_0x5c623c+=0x1){socket[_0xd4c3('0xa9')](_0xd4c3('0x114'),{'MailInteractionId':Number(_0x56f1c4[_0xd4c3('0x53')][_0xd4c3('0x6e')][_0x5c623c]),'UserId':Number(_0x56f1c4[_0xd4c3('0x68')]['id'])});}}else{socket[_0xd4c3('0xa9')](_0xd4c3('0x114'),{'MailInteractionId':Number(_0x56f1c4[_0xd4c3('0x53')]['ids']),'UserId':Number(_0x56f1c4[_0xd4c3('0x68')]['id'])});}});}})[_0xd4c3('0x23')](respondWithStatusCode(_0x3d024f,null))['catch'](handleError(_0x3d024f,null));};exports[_0xd4c3('0x115')]=function(_0x4a79f6,_0x21851f,_0x931992){return db[_0xd4c3('0x4c')][_0xd4c3('0x46')]({'where':{'id':_0x4a79f6[_0xd4c3('0x68')]['id']}})[_0xd4c3('0x23')](handleEntityNotFound(_0x21851f,null))[_0xd4c3('0x23')](function(_0x26f659){if(_0x26f659){return _0x26f659[_0xd4c3('0x115')](_0x4a79f6[_0xd4c3('0x6b')]['ids'],_[_0xd4c3('0x6f')](_0x4a79f6['body'],[_0xd4c3('0x6e'),'id'])||{})['spread'](function(){for(var _0x1550b2=0x0;_0x1550b2<_0x4a79f6[_0xd4c3('0x6b')][_0xd4c3('0x6e')]['length'];_0x1550b2+=0x1){socket[_0xd4c3('0xa9')](_0xd4c3('0x116'),{'FaxInteractionId':Number(_0x4a79f6['body'][_0xd4c3('0x6e')][_0x1550b2]),'UserId':Number(_0x4a79f6['params']['id'])});}return _0x4a79f6[_0xd4c3('0x6b')][_0xd4c3('0x6e')];});}})['then'](respondWithResult(_0x21851f,null))[_0xd4c3('0x2e')](handleError(_0x21851f,null));};exports[_0xd4c3('0x117')]=function(_0x59c820,_0x4b1b0f,_0x50e1fb){return db[_0xd4c3('0x4c')][_0xd4c3('0x46')]({'where':{'id':_0x59c820[_0xd4c3('0x68')]['id']}})[_0xd4c3('0x23')](handleEntityNotFound(_0x4b1b0f,null))[_0xd4c3('0x23')](function(_0x5306de){if(_0x5306de){return _0x5306de[_0xd4c3('0x117')](_0x59c820['query'][_0xd4c3('0x6e')])[_0xd4c3('0x23')](function(){if(_[_0xd4c3('0x110')](_0x59c820[_0xd4c3('0x53')][_0xd4c3('0x6e')])){for(var _0x3bea15=0x0;_0x3bea15<_0x59c820[_0xd4c3('0x53')][_0xd4c3('0x6e')][_0xd4c3('0x69')];_0x3bea15+=0x1){socket[_0xd4c3('0xa9')](_0xd4c3('0x118'),{'FaxInteractionId':Number(_0x59c820['query'][_0xd4c3('0x6e')][_0x3bea15]),'UserId':Number(_0x59c820[_0xd4c3('0x68')]['id'])});}}else{socket['emit'](_0xd4c3('0x118'),{'FaxInteractionId':Number(_0x59c820['query']['ids']),'UserId':Number(_0x59c820['params']['id'])});}});}})[_0xd4c3('0x23')](respondWithStatusCode(_0x4b1b0f,null))['catch'](handleError(_0x4b1b0f,null));};exports[_0xd4c3('0x119')]=function(_0x4ffa54,_0x5027b3,_0x4ba8d4){return db[_0xd4c3('0x4c')][_0xd4c3('0x46')]({'where':{'id':_0x4ffa54['params']['id']}})['then'](handleEntityNotFound(_0x5027b3,null))['then'](function(_0x14b3c4){if(_0x14b3c4){return _0x14b3c4[_0xd4c3('0x119')](_0x4ffa54[_0xd4c3('0x6b')][_0xd4c3('0x6e')],_[_0xd4c3('0x6f')](_0x4ffa54[_0xd4c3('0x6b')],[_0xd4c3('0x6e'),'id'])||{})[_0xd4c3('0xa7')](function(){for(var _0x5bc3ae=0x0;_0x5bc3ae<_0x4ffa54[_0xd4c3('0x6b')]['ids'][_0xd4c3('0x69')];_0x5bc3ae+=0x1){socket[_0xd4c3('0xa9')]('user_has_sms_interactions:save',{'SmsInteractionId':Number(_0x4ffa54[_0xd4c3('0x6b')][_0xd4c3('0x6e')][_0x5bc3ae]),'UserId':Number(_0x4ffa54[_0xd4c3('0x68')]['id'])});}return _0x4ffa54[_0xd4c3('0x6b')][_0xd4c3('0x6e')];});}})[_0xd4c3('0x23')](respondWithResult(_0x5027b3,null))['catch'](handleError(_0x5027b3,null));};exports[_0xd4c3('0x11a')]=function(_0x59dcec,_0x3350e2,_0x893ca5){return db[_0xd4c3('0x4c')][_0xd4c3('0x46')]({'where':{'id':_0x59dcec[_0xd4c3('0x68')]['id']}})['then'](handleEntityNotFound(_0x3350e2,null))[_0xd4c3('0x23')](function(_0x99158){if(_0x99158){return _0x99158['removeSmsInteractions'](_0x59dcec[_0xd4c3('0x53')][_0xd4c3('0x6e')])[_0xd4c3('0x23')](function(){if(_[_0xd4c3('0x110')](_0x59dcec[_0xd4c3('0x53')][_0xd4c3('0x6e')])){for(var _0x49489a=0x0;_0x49489a<_0x59dcec[_0xd4c3('0x53')][_0xd4c3('0x6e')][_0xd4c3('0x69')];_0x49489a+=0x1){socket[_0xd4c3('0xa9')]('user_has_sms_interactions:remove',{'SmsInteractionId':Number(_0x59dcec['query'][_0xd4c3('0x6e')][_0x49489a]),'UserId':Number(_0x59dcec['params']['id'])});}}else{socket[_0xd4c3('0xa9')](_0xd4c3('0x11b'),{'SmsInteractionId':Number(_0x59dcec[_0xd4c3('0x53')][_0xd4c3('0x6e')]),'UserId':Number(_0x59dcec['params']['id'])});}});}})['then'](respondWithStatusCode(_0x3350e2,null))['catch'](handleError(_0x3350e2,null));};exports[_0xd4c3('0x11c')]=function(_0x808307,_0x3e6f72,_0x23e256){return db[_0xd4c3('0x4c')][_0xd4c3('0x46')]({'where':{'id':_0x808307[_0xd4c3('0x68')]['id']}})[_0xd4c3('0x23')](handleEntityNotFound(_0x3e6f72,null))[_0xd4c3('0x23')](function(_0x5f8ca7){if(_0x5f8ca7){return _0x5f8ca7[_0xd4c3('0x11c')](_0x808307[_0xd4c3('0x6b')][_0xd4c3('0x6e')],_['omit'](_0x808307[_0xd4c3('0x6b')],['ids','id'])||{})['spread'](function(){for(var _0x924436=0x0;_0x924436<_0x808307[_0xd4c3('0x6b')]['ids'][_0xd4c3('0x69')];_0x924436+=0x1){socket['emit'](_0xd4c3('0x11d'),{'OpenchannelInteractionId':Number(_0x808307[_0xd4c3('0x6b')][_0xd4c3('0x6e')][_0x924436]),'UserId':Number(_0x808307[_0xd4c3('0x68')]['id'])});}return _0x808307[_0xd4c3('0x6b')][_0xd4c3('0x6e')];});}})['then'](respondWithResult(_0x3e6f72,null))['catch'](handleError(_0x3e6f72,null));};exports[_0xd4c3('0x11e')]=function(_0x26550f,_0x35e834,_0x6126){return db[_0xd4c3('0x4c')]['find']({'where':{'id':_0x26550f['params']['id']}})[_0xd4c3('0x23')](handleEntityNotFound(_0x35e834,null))[_0xd4c3('0x23')](function(_0x380695){if(_0x380695){return _0x380695['removeOpenchannelInteractions'](_0x26550f['query']['ids'])[_0xd4c3('0x23')](function(){if(_[_0xd4c3('0x110')](_0x26550f[_0xd4c3('0x53')][_0xd4c3('0x6e')])){for(var _0x5cb2c3=0x0;_0x5cb2c3<_0x26550f[_0xd4c3('0x53')][_0xd4c3('0x6e')][_0xd4c3('0x69')];_0x5cb2c3+=0x1){socket['emit'](_0xd4c3('0x11f'),{'OpenchannelInteractionId':Number(_0x26550f['query'][_0xd4c3('0x6e')][_0x5cb2c3]),'UserId':Number(_0x26550f[_0xd4c3('0x68')]['id'])});}}else{socket['emit'](_0xd4c3('0x11f'),{'OpenchannelInteractionId':Number(_0x26550f['query']['ids']),'UserId':Number(_0x26550f[_0xd4c3('0x68')]['id'])});}});}})['then'](respondWithStatusCode(_0x35e834,null))[_0xd4c3('0x2e')](handleError(_0x35e834,null));};exports[_0xd4c3('0x120')]=function(_0x5e98d2,_0x21a6ad,_0x1497b8){var _0x50ba11={};var _0x39ea3f={};var _0x400aa6;var _0x4cab83;return db[_0xd4c3('0x4c')][_0xd4c3('0xc0')]({'where':{'id':_0x5e98d2[_0xd4c3('0x68')]['id']}})['then'](handleEntityNotFound(_0x21a6ad,null))[_0xd4c3('0x23')](function(_0x21c573){if(_0x21c573){_0x400aa6=_0x21c573;_0x39ea3f[_0xd4c3('0x4e')]=_['keys'](db[_0xd4c3('0x121')][_0xd4c3('0x4d')]);_0x39ea3f[_0xd4c3('0x53')]=_[_0xd4c3('0x50')](_0x5e98d2['query']);_0x39ea3f[_0xd4c3('0x5b')]=_[_0xd4c3('0x54')](_0x39ea3f[_0xd4c3('0x4e')],_0x39ea3f[_0xd4c3('0x53')]);_0x50ba11[_0xd4c3('0x55')]=_[_0xd4c3('0x54')](_0x39ea3f[_0xd4c3('0x4e')],qs['fields'](_0x5e98d2[_0xd4c3('0x53')][_0xd4c3('0x56')]));_0x50ba11['attributes']=_0x50ba11['attributes'][_0xd4c3('0x69')]?_0x50ba11[_0xd4c3('0x55')]:_0x39ea3f['model'];_0x50ba11[_0xd4c3('0xc2')]=qs[_0xd4c3('0x59')](_0x5e98d2[_0xd4c3('0x53')]['sort']);_0x50ba11[_0xd4c3('0x5a')]=qs[_0xd4c3('0x5b')](_[_0xd4c3('0x5c')](_0x5e98d2[_0xd4c3('0x53')],_0x39ea3f[_0xd4c3('0x5b')]));if(_0x5e98d2[_0xd4c3('0x53')][_0xd4c3('0x41')]){_0x50ba11[_0xd4c3('0x5a')]=_[_0xd4c3('0x63')](_0x50ba11[_0xd4c3('0x5a')],{'$or':_['map'](_0x50ba11['attributes'],function(_0x2740b0){var _0x3ebd81={};_0x3ebd81[_0x2740b0]={'$like':'%'+_0x5e98d2[_0xd4c3('0x53')][_0xd4c3('0x41')]+'%'};return _0x3ebd81;})});}_0x50ba11=_[_0xd4c3('0x63')]({},_0x50ba11,_0x5e98d2[_0xd4c3('0x64')]);return _0x400aa6['getVoicePrefixes'](_0x50ba11);}})[_0xd4c3('0x23')](function(_0x5f2715){if(_0x5f2715){_0x4cab83=_0x5f2715[_0xd4c3('0x69')];if(!_0x5e98d2[_0xd4c3('0x53')][_0xd4c3('0x57')](_0xd4c3('0x58'))){_0x50ba11[_0xd4c3('0x34')]=qs[_0xd4c3('0x34')](_0x5e98d2[_0xd4c3('0x53')]['limit']);_0x50ba11[_0xd4c3('0x33')]=qs[_0xd4c3('0x33')](_0x5e98d2['query']['offset']);}return _0x400aa6[_0xd4c3('0x120')](_0x50ba11);}})[_0xd4c3('0x23')](function(_0x11c505){if(_0x11c505){return _0x11c505?{'count':_0x4cab83,'rows':_0x11c505}:null;}})['then'](respondWithResult(_0x21a6ad,null))['catch'](handleError(_0x21a6ad,null));};exports[_0xd4c3('0x122')]=function(_0x46d441,_0x42d612,_0x286075){var _0x52cb67={};var _0x2e884b={};var _0x1caeb4;var _0x1f6c74;return db[_0xd4c3('0x4c')][_0xd4c3('0xc0')]({'where':{'id':_0x46d441['params']['id']}})[_0xd4c3('0x23')](handleEntityNotFound(_0x42d612,null))[_0xd4c3('0x23')](function(_0x514f6e){if(_0x514f6e){_0x1caeb4=_0x514f6e;_0x2e884b[_0xd4c3('0x4e')]=_['keys'](db[_0xd4c3('0x123')][_0xd4c3('0x4d')]);_0x2e884b[_0xd4c3('0x53')]=_['keys'](_0x46d441[_0xd4c3('0x53')]);_0x2e884b['filters']=_['intersection'](_0x2e884b[_0xd4c3('0x4e')],_0x2e884b[_0xd4c3('0x53')]);_0x52cb67['attributes']=_[_0xd4c3('0x54')](_0x2e884b[_0xd4c3('0x4e')],qs['fields'](_0x46d441['query'][_0xd4c3('0x56')]));_0x52cb67[_0xd4c3('0x55')]=_0x52cb67[_0xd4c3('0x55')]['length']?_0x52cb67[_0xd4c3('0x55')]:_0x2e884b[_0xd4c3('0x4e')];_0x52cb67[_0xd4c3('0xc2')]=qs[_0xd4c3('0x59')](_0x46d441[_0xd4c3('0x53')]['sort']);_0x52cb67['where']=qs[_0xd4c3('0x5b')](_[_0xd4c3('0x5c')](_0x46d441[_0xd4c3('0x53')],_0x2e884b[_0xd4c3('0x5b')]));if(_0x46d441[_0xd4c3('0x53')]['filter']){_0x52cb67[_0xd4c3('0x5a')]=_[_0xd4c3('0x63')](_0x52cb67[_0xd4c3('0x5a')],{'$or':_[_0xd4c3('0x5d')](_0x52cb67[_0xd4c3('0x55')],function(_0x3a10dd){var _0x5d4a47={};_0x5d4a47[_0x3a10dd]={'$like':'%'+_0x46d441[_0xd4c3('0x53')][_0xd4c3('0x41')]+'%'};return _0x5d4a47;})});}_0x52cb67=_[_0xd4c3('0x63')]({},_0x52cb67,_0x46d441[_0xd4c3('0x64')]);return _0x1caeb4[_0xd4c3('0x122')](_0x52cb67);}})[_0xd4c3('0x23')](function(_0x414bed){if(_0x414bed){_0x1f6c74=_0x414bed[_0xd4c3('0x69')];if(!_0x46d441[_0xd4c3('0x53')]['hasOwnProperty'](_0xd4c3('0x58'))){_0x52cb67[_0xd4c3('0x34')]=qs[_0xd4c3('0x34')](_0x46d441[_0xd4c3('0x53')][_0xd4c3('0x34')]);_0x52cb67['offset']=qs[_0xd4c3('0x33')](_0x46d441[_0xd4c3('0x53')]['offset']);}return _0x1caeb4[_0xd4c3('0x122')](_0x52cb67);}})[_0xd4c3('0x23')](function(_0xedf135){if(_0xedf135){return _0xedf135?{'count':_0x1f6c74,'rows':_0xedf135}:null;}})[_0xd4c3('0x23')](respondWithResult(_0x42d612,null))[_0xd4c3('0x2e')](handleError(_0x42d612,null));};exports['addFaxAccounts']=function(_0x1a1bb4,_0x53e39f,_0x200432){return db[_0xd4c3('0x4c')]['find']({'where':{'id':_0x1a1bb4['params']['id']}})[_0xd4c3('0x23')](handleEntityNotFound(_0x53e39f,null))[_0xd4c3('0x23')](function(_0x178ee3){if(_0x178ee3){return _0x178ee3[_0xd4c3('0x124')](_0x1a1bb4[_0xd4c3('0x6b')][_0xd4c3('0x6e')],_[_0xd4c3('0x6f')](_0x1a1bb4[_0xd4c3('0x6b')],[_0xd4c3('0x6e'),'id'])||{});}})[_0xd4c3('0x23')](respondWithResult(_0x53e39f,null))[_0xd4c3('0x2e')](handleError(_0x53e39f,null));};exports[_0xd4c3('0x125')]=function(_0x75ce9c,_0x30b4cd,_0x366ef4){return db[_0xd4c3('0x4c')][_0xd4c3('0x46')]({'where':{'id':_0x75ce9c[_0xd4c3('0x68')]['id']}})[_0xd4c3('0x23')](handleEntityNotFound(_0x30b4cd,null))[_0xd4c3('0x23')](function(_0x52cfe6){if(_0x52cfe6){return _0x52cfe6['removeFaxAccounts'](_0x75ce9c[_0xd4c3('0x53')][_0xd4c3('0x6e')]);}})[_0xd4c3('0x23')](respondWithStatusCode(_0x30b4cd,null))[_0xd4c3('0x2e')](handleError(_0x30b4cd,null));};exports['getMailAccounts']=function(_0x193aa7,_0xff0f01,_0x10cb02){var _0x6a87bf={};var _0x1f8804={};var _0x1023a8;var _0x5b0bf2;return db['User'][_0xd4c3('0xc0')]({'where':{'id':_0x193aa7['params']['id']}})[_0xd4c3('0x23')](handleEntityNotFound(_0xff0f01,null))['then'](function(_0xdc6283){if(_0xdc6283){_0x1023a8=_0xdc6283;_0x1f8804[_0xd4c3('0x4e')]=_[_0xd4c3('0x50')](db[_0xd4c3('0x126')][_0xd4c3('0x4d')]);_0x1f8804[_0xd4c3('0x53')]=_[_0xd4c3('0x50')](_0x193aa7['query']);_0x1f8804[_0xd4c3('0x5b')]=_['intersection'](_0x1f8804['model'],_0x1f8804['query']);_0x6a87bf[_0xd4c3('0x55')]=_[_0xd4c3('0x54')](_0x1f8804[_0xd4c3('0x4e')],qs[_0xd4c3('0x56')](_0x193aa7[_0xd4c3('0x53')]['fields']));_0x6a87bf[_0xd4c3('0x55')]=_0x6a87bf['attributes'][_0xd4c3('0x69')]?_0x6a87bf[_0xd4c3('0x55')]:_0x1f8804[_0xd4c3('0x4e')];_0x6a87bf[_0xd4c3('0xc2')]=qs[_0xd4c3('0x59')](_0x193aa7[_0xd4c3('0x53')][_0xd4c3('0x59')]);_0x6a87bf['where']=qs[_0xd4c3('0x5b')](_[_0xd4c3('0x5c')](_0x193aa7[_0xd4c3('0x53')],_0x1f8804['filters']));if(_0x193aa7[_0xd4c3('0x53')][_0xd4c3('0x41')]){_0x6a87bf[_0xd4c3('0x5a')]=_[_0xd4c3('0x63')](_0x6a87bf['where'],{'$or':_[_0xd4c3('0x5d')](_0x6a87bf[_0xd4c3('0x55')],function(_0xc49af3){var _0x5b33c7={};_0x5b33c7[_0xc49af3]={'$like':'%'+_0x193aa7[_0xd4c3('0x53')][_0xd4c3('0x41')]+'%'};return _0x5b33c7;})});}_0x6a87bf=_['merge']({},_0x6a87bf,_0x193aa7['options']);return _0x1023a8[_0xd4c3('0x127')](_0x6a87bf);}})[_0xd4c3('0x23')](function(_0x2e8c74){if(_0x2e8c74){_0x5b0bf2=_0x2e8c74[_0xd4c3('0x69')];if(!_0x193aa7['query'][_0xd4c3('0x57')](_0xd4c3('0x58'))){_0x6a87bf['limit']=qs['limit'](_0x193aa7[_0xd4c3('0x53')][_0xd4c3('0x34')]);_0x6a87bf[_0xd4c3('0x33')]=qs[_0xd4c3('0x33')](_0x193aa7[_0xd4c3('0x53')][_0xd4c3('0x33')]);}return _0x1023a8[_0xd4c3('0x127')](_0x6a87bf);}})[_0xd4c3('0x23')](function(_0x3d5465){if(_0x3d5465){return _0x3d5465?{'count':_0x5b0bf2,'rows':_0x3d5465}:null;}})[_0xd4c3('0x23')](respondWithResult(_0xff0f01,null))[_0xd4c3('0x2e')](handleError(_0xff0f01,null));};exports[_0xd4c3('0x128')]=function(_0x4fb014,_0x3a55e6,_0x174650){return db[_0xd4c3('0x4c')][_0xd4c3('0x46')]({'where':{'id':_0x4fb014[_0xd4c3('0x68')]['id']}})['then'](handleEntityNotFound(_0x3a55e6,null))[_0xd4c3('0x23')](function(_0x369d61){if(_0x369d61){return _0x369d61[_0xd4c3('0x128')](_0x4fb014[_0xd4c3('0x6b')][_0xd4c3('0x6e')],_[_0xd4c3('0x6f')](_0x4fb014[_0xd4c3('0x6b')],[_0xd4c3('0x6e'),'id'])||{});}})[_0xd4c3('0x23')](respondWithResult(_0x3a55e6,null))[_0xd4c3('0x2e')](handleError(_0x3a55e6,null));};exports[_0xd4c3('0x129')]=function(_0x4cbd1c,_0x489bbf,_0x21160d){return db[_0xd4c3('0x4c')][_0xd4c3('0x46')]({'where':{'id':_0x4cbd1c[_0xd4c3('0x68')]['id']}})[_0xd4c3('0x23')](handleEntityNotFound(_0x489bbf,null))[_0xd4c3('0x23')](function(_0xf85e42){if(_0xf85e42){return _0xf85e42['removeMailAccounts'](_0x4cbd1c[_0xd4c3('0x53')][_0xd4c3('0x6e')]);}})['then'](respondWithStatusCode(_0x489bbf,null))['catch'](handleError(_0x489bbf,null));};exports[_0xd4c3('0x12a')]=function(_0x5ba4dc,_0x2ad104,_0x222934){var _0x37f076={};var _0x449ff1={};var _0x5c3fa7;var _0x25f51c;return db['User'][_0xd4c3('0xc0')]({'where':{'id':_0x5ba4dc[_0xd4c3('0x68')]['id']}})[_0xd4c3('0x23')](handleEntityNotFound(_0x2ad104,null))[_0xd4c3('0x23')](function(_0x56646a){if(_0x56646a){_0x5c3fa7=_0x56646a;_0x449ff1[_0xd4c3('0x4e')]=_[_0xd4c3('0x50')](db[_0xd4c3('0x12b')][_0xd4c3('0x4d')]);_0x449ff1[_0xd4c3('0x53')]=_[_0xd4c3('0x50')](_0x5ba4dc[_0xd4c3('0x53')]);_0x449ff1[_0xd4c3('0x5b')]=_['intersection'](_0x449ff1['model'],_0x449ff1[_0xd4c3('0x53')]);_0x37f076[_0xd4c3('0x55')]=_['intersection'](_0x449ff1[_0xd4c3('0x4e')],qs[_0xd4c3('0x56')](_0x5ba4dc[_0xd4c3('0x53')][_0xd4c3('0x56')]));_0x37f076[_0xd4c3('0x55')]=_0x37f076['attributes']['length']?_0x37f076[_0xd4c3('0x55')]:_0x449ff1[_0xd4c3('0x4e')];_0x37f076['order']=qs[_0xd4c3('0x59')](_0x5ba4dc[_0xd4c3('0x53')][_0xd4c3('0x59')]);_0x37f076[_0xd4c3('0x5a')]=qs[_0xd4c3('0x5b')](_['pick'](_0x5ba4dc[_0xd4c3('0x53')],_0x449ff1[_0xd4c3('0x5b')]));if(_0x5ba4dc['query'][_0xd4c3('0x41')]){_0x37f076[_0xd4c3('0x5a')]=_['merge'](_0x37f076[_0xd4c3('0x5a')],{'$or':_['map'](_0x37f076[_0xd4c3('0x55')],function(_0x322f4e){var _0x4672b6={};_0x4672b6[_0x322f4e]={'$like':'%'+_0x5ba4dc[_0xd4c3('0x53')][_0xd4c3('0x41')]+'%'};return _0x4672b6;})});}_0x37f076=_[_0xd4c3('0x63')]({},_0x37f076,_0x5ba4dc[_0xd4c3('0x64')]);return _0x5c3fa7[_0xd4c3('0x12a')](_0x37f076);}})[_0xd4c3('0x23')](function(_0x173680){if(_0x173680){_0x25f51c=_0x173680[_0xd4c3('0x69')];if(!_0x5ba4dc['query'][_0xd4c3('0x57')](_0xd4c3('0x58'))){_0x37f076[_0xd4c3('0x34')]=qs[_0xd4c3('0x34')](_0x5ba4dc[_0xd4c3('0x53')][_0xd4c3('0x34')]);_0x37f076[_0xd4c3('0x33')]=qs[_0xd4c3('0x33')](_0x5ba4dc[_0xd4c3('0x53')][_0xd4c3('0x33')]);}return _0x5c3fa7[_0xd4c3('0x12a')](_0x37f076);}})[_0xd4c3('0x23')](function(_0x351b4b){if(_0x351b4b){return _0x351b4b?{'count':_0x25f51c,'rows':_0x351b4b}:null;}})['then'](respondWithResult(_0x2ad104,null))[_0xd4c3('0x2e')](handleError(_0x2ad104,null));};exports[_0xd4c3('0x12c')]=function(_0x208674,_0x425ebc,_0x387d4c){return db[_0xd4c3('0x4c')]['find']({'where':{'id':_0x208674['params']['id']}})[_0xd4c3('0x23')](handleEntityNotFound(_0x425ebc,null))[_0xd4c3('0x23')](function(_0x3bb517){if(_0x3bb517){return _0x3bb517[_0xd4c3('0x12c')](_0x208674[_0xd4c3('0x6b')]['ids'],_[_0xd4c3('0x6f')](_0x208674[_0xd4c3('0x6b')],[_0xd4c3('0x6e'),'id'])||{});}})[_0xd4c3('0x23')](respondWithResult(_0x425ebc,null))[_0xd4c3('0x2e')](handleError(_0x425ebc,null));};exports[_0xd4c3('0x12d')]=function(_0x442ec5,_0x13615e,_0x1a3b9f){return db[_0xd4c3('0x4c')][_0xd4c3('0x46')]({'where':{'id':_0x442ec5['params']['id']}})[_0xd4c3('0x23')](handleEntityNotFound(_0x13615e,null))[_0xd4c3('0x23')](function(_0xf47e4a){if(_0xf47e4a){return _0xf47e4a[_0xd4c3('0x12d')](_0x442ec5[_0xd4c3('0x53')][_0xd4c3('0x6e')]);}})['then'](respondWithStatusCode(_0x13615e,null))[_0xd4c3('0x2e')](handleError(_0x13615e,null));};exports['getSmsAccounts']=function(_0x56336c,_0x1bd46f,_0x4f0fd7){var _0xbb61fb={};var _0x47da22={};var _0x37b713;var _0x2bc6f6;return db[_0xd4c3('0x4c')][_0xd4c3('0xc0')]({'where':{'id':_0x56336c['params']['id']}})[_0xd4c3('0x23')](handleEntityNotFound(_0x1bd46f,null))['then'](function(_0x3d1eca){if(_0x3d1eca){_0x37b713=_0x3d1eca;_0x47da22[_0xd4c3('0x4e')]=_['keys'](db[_0xd4c3('0x12e')][_0xd4c3('0x4d')]);_0x47da22[_0xd4c3('0x53')]=_[_0xd4c3('0x50')](_0x56336c[_0xd4c3('0x53')]);_0x47da22[_0xd4c3('0x5b')]=_[_0xd4c3('0x54')](_0x47da22[_0xd4c3('0x4e')],_0x47da22[_0xd4c3('0x53')]);_0xbb61fb[_0xd4c3('0x55')]=_['intersection'](_0x47da22[_0xd4c3('0x4e')],qs[_0xd4c3('0x56')](_0x56336c[_0xd4c3('0x53')][_0xd4c3('0x56')]));_0xbb61fb[_0xd4c3('0x55')]=_0xbb61fb[_0xd4c3('0x55')][_0xd4c3('0x69')]?_0xbb61fb['attributes']:_0x47da22[_0xd4c3('0x4e')];_0xbb61fb['order']=qs[_0xd4c3('0x59')](_0x56336c['query'][_0xd4c3('0x59')]);_0xbb61fb[_0xd4c3('0x5a')]=qs[_0xd4c3('0x5b')](_[_0xd4c3('0x5c')](_0x56336c['query'],_0x47da22[_0xd4c3('0x5b')]));if(_0x56336c['query'][_0xd4c3('0x41')]){_0xbb61fb[_0xd4c3('0x5a')]=_[_0xd4c3('0x63')](_0xbb61fb[_0xd4c3('0x5a')],{'$or':_[_0xd4c3('0x5d')](_0xbb61fb['attributes'],function(_0x19e687){var _0x557581={};_0x557581[_0x19e687]={'$like':'%'+_0x56336c[_0xd4c3('0x53')]['filter']+'%'};return _0x557581;})});}_0xbb61fb=_['merge']({},_0xbb61fb,_0x56336c['options']);return _0x37b713[_0xd4c3('0x12f')](_0xbb61fb);}})[_0xd4c3('0x23')](function(_0x4aea2a){if(_0x4aea2a){_0x2bc6f6=_0x4aea2a[_0xd4c3('0x69')];if(!_0x56336c['query'][_0xd4c3('0x57')](_0xd4c3('0x58'))){_0xbb61fb[_0xd4c3('0x34')]=qs[_0xd4c3('0x34')](_0x56336c[_0xd4c3('0x53')][_0xd4c3('0x34')]);_0xbb61fb[_0xd4c3('0x33')]=qs[_0xd4c3('0x33')](_0x56336c['query']['offset']);}return _0x37b713[_0xd4c3('0x12f')](_0xbb61fb);}})[_0xd4c3('0x23')](function(_0x3169fa){if(_0x3169fa){return _0x3169fa?{'count':_0x2bc6f6,'rows':_0x3169fa}:null;}})[_0xd4c3('0x23')](respondWithResult(_0x1bd46f,null))[_0xd4c3('0x2e')](handleError(_0x1bd46f,null));};exports[_0xd4c3('0x130')]=function(_0x5a45ee,_0x557191,_0x1ec7e1){return db['User'][_0xd4c3('0x46')]({'where':{'id':_0x5a45ee[_0xd4c3('0x68')]['id']}})['then'](handleEntityNotFound(_0x557191,null))[_0xd4c3('0x23')](function(_0x807a05){if(_0x807a05){return _0x807a05[_0xd4c3('0x130')](_0x5a45ee[_0xd4c3('0x6b')][_0xd4c3('0x6e')],_['omit'](_0x5a45ee[_0xd4c3('0x6b')],[_0xd4c3('0x6e'),'id'])||{});}})[_0xd4c3('0x23')](respondWithResult(_0x557191,null))[_0xd4c3('0x2e')](handleError(_0x557191,null));};exports[_0xd4c3('0x131')]=function(_0x35394c,_0x265ddd,_0x4e7e3a){return db['User'][_0xd4c3('0x46')]({'where':{'id':_0x35394c[_0xd4c3('0x68')]['id']}})['then'](handleEntityNotFound(_0x265ddd,null))['then'](function(_0x399073){if(_0x399073){return _0x399073[_0xd4c3('0x131')](_0x35394c[_0xd4c3('0x53')]['ids']);}})['then'](respondWithStatusCode(_0x265ddd,null))[_0xd4c3('0x2e')](handleError(_0x265ddd,null));};exports[_0xd4c3('0x132')]=function(_0xe307a6,_0x1ae46b,_0x2bbcb5){var _0x31508b={};var _0x592624={};var _0x2344c5;var _0x40eeff;return db[_0xd4c3('0x4c')][_0xd4c3('0xc0')]({'where':{'id':_0xe307a6[_0xd4c3('0x68')]['id']}})['then'](handleEntityNotFound(_0x1ae46b,null))[_0xd4c3('0x23')](function(_0x356328){if(_0x356328){_0x2344c5=_0x356328;_0x592624[_0xd4c3('0x4e')]=_[_0xd4c3('0x50')](db[_0xd4c3('0x133')][_0xd4c3('0x4d')]);_0x592624[_0xd4c3('0x53')]=_[_0xd4c3('0x50')](_0xe307a6[_0xd4c3('0x53')]);_0x592624[_0xd4c3('0x5b')]=_[_0xd4c3('0x54')](_0x592624[_0xd4c3('0x4e')],_0x592624[_0xd4c3('0x53')]);_0x31508b[_0xd4c3('0x55')]=_[_0xd4c3('0x54')](_0x592624[_0xd4c3('0x4e')],qs[_0xd4c3('0x56')](_0xe307a6[_0xd4c3('0x53')][_0xd4c3('0x56')]));_0x31508b['attributes']=_0x31508b['attributes'][_0xd4c3('0x69')]?_0x31508b['attributes']:_0x592624[_0xd4c3('0x4e')];_0x31508b[_0xd4c3('0xc2')]=qs[_0xd4c3('0x59')](_0xe307a6[_0xd4c3('0x53')][_0xd4c3('0x59')]);_0x31508b[_0xd4c3('0x5a')]=qs[_0xd4c3('0x5b')](_[_0xd4c3('0x5c')](_0xe307a6[_0xd4c3('0x53')],_0x592624[_0xd4c3('0x5b')]));if(_0xe307a6[_0xd4c3('0x53')][_0xd4c3('0x41')]){_0x31508b['where']=_['merge'](_0x31508b[_0xd4c3('0x5a')],{'$or':_['map'](_0x31508b['attributes'],function(_0x433e28){var _0x1f00ce={};_0x1f00ce[_0x433e28]={'$like':'%'+_0xe307a6[_0xd4c3('0x53')][_0xd4c3('0x41')]+'%'};return _0x1f00ce;})});}_0x31508b=_[_0xd4c3('0x63')]({},_0x31508b,_0xe307a6[_0xd4c3('0x64')]);return _0x2344c5[_0xd4c3('0x132')](_0x31508b);}})[_0xd4c3('0x23')](function(_0x535893){if(_0x535893){_0x40eeff=_0x535893[_0xd4c3('0x69')];if(!_0xe307a6['query'][_0xd4c3('0x57')](_0xd4c3('0x58'))){_0x31508b[_0xd4c3('0x34')]=qs['limit'](_0xe307a6[_0xd4c3('0x53')][_0xd4c3('0x34')]);_0x31508b[_0xd4c3('0x33')]=qs['offset'](_0xe307a6[_0xd4c3('0x53')][_0xd4c3('0x33')]);}return _0x2344c5['getChatWebsites'](_0x31508b);}})['then'](function(_0x2f4dee){if(_0x2f4dee){return _0x2f4dee?{'count':_0x40eeff,'rows':_0x2f4dee}:null;}})[_0xd4c3('0x23')](respondWithResult(_0x1ae46b,null))[_0xd4c3('0x2e')](handleError(_0x1ae46b,null));};exports['addChatWebsites']=function(_0x2435f0,_0x4420e3,_0x45e134){return db[_0xd4c3('0x4c')]['find']({'where':{'id':_0x2435f0[_0xd4c3('0x68')]['id']}})[_0xd4c3('0x23')](handleEntityNotFound(_0x4420e3,null))[_0xd4c3('0x23')](function(_0x4d8e87){if(_0x4d8e87){return _0x4d8e87[_0xd4c3('0x134')](_0x2435f0[_0xd4c3('0x6b')][_0xd4c3('0x6e')],_[_0xd4c3('0x6f')](_0x2435f0['body'],['ids','id'])||{});}})[_0xd4c3('0x23')](respondWithResult(_0x4420e3,null))[_0xd4c3('0x2e')](handleError(_0x4420e3,null));};exports[_0xd4c3('0x135')]=function(_0x6dacbd,_0x274cac,_0x269a9d){return db[_0xd4c3('0x4c')][_0xd4c3('0x46')]({'where':{'id':_0x6dacbd[_0xd4c3('0x68')]['id']}})['then'](handleEntityNotFound(_0x274cac,null))[_0xd4c3('0x23')](function(_0x2a32ba){if(_0x2a32ba){return _0x2a32ba[_0xd4c3('0x135')](_0x6dacbd['query']['ids']);}})[_0xd4c3('0x23')](respondWithStatusCode(_0x274cac,null))[_0xd4c3('0x2e')](handleError(_0x274cac,null));};exports[_0xd4c3('0x136')]=function(_0x292bac,_0x46a399,_0x5329bd){var _0x137601={};var _0x501f56={};var _0x4b0fb7;var _0x23099f;return db[_0xd4c3('0x4c')]['findOne']({'where':{'id':_0x292bac[_0xd4c3('0x68')]['id']}})[_0xd4c3('0x23')](handleEntityNotFound(_0x46a399,null))[_0xd4c3('0x23')](function(_0x3bcb6c){if(_0x3bcb6c){_0x4b0fb7=_0x3bcb6c;_0x501f56[_0xd4c3('0x4e')]=_[_0xd4c3('0x50')](db['SquareProject'][_0xd4c3('0x4d')]);_0x501f56[_0xd4c3('0x53')]=_[_0xd4c3('0x50')](_0x292bac[_0xd4c3('0x53')]);_0x501f56['filters']=_[_0xd4c3('0x54')](_0x501f56[_0xd4c3('0x4e')],_0x501f56[_0xd4c3('0x53')]);_0x137601['attributes']=_[_0xd4c3('0x54')](_0x501f56[_0xd4c3('0x4e')],qs[_0xd4c3('0x56')](_0x292bac[_0xd4c3('0x53')]['fields']));_0x137601[_0xd4c3('0x55')]=_0x137601[_0xd4c3('0x55')][_0xd4c3('0x69')]?_0x137601[_0xd4c3('0x55')]:_0x501f56['model'];_0x137601[_0xd4c3('0xc2')]=qs[_0xd4c3('0x59')](_0x292bac[_0xd4c3('0x53')][_0xd4c3('0x59')]);_0x137601['where']=qs[_0xd4c3('0x5b')](_[_0xd4c3('0x5c')](_0x292bac['query'],_0x501f56[_0xd4c3('0x5b')]));if(_0x292bac['query'][_0xd4c3('0x41')]){_0x137601['where']=_[_0xd4c3('0x63')](_0x137601[_0xd4c3('0x5a')],{'$or':_['map'](_0x137601[_0xd4c3('0x55')],function(_0x2e5210){var _0x591838={};_0x591838[_0x2e5210]={'$like':'%'+_0x292bac['query']['filter']+'%'};return _0x591838;})});}_0x137601=_['merge']({},_0x137601,_0x292bac['options']);return _0x4b0fb7['getSquareProjects'](_0x137601);}})[_0xd4c3('0x23')](function(_0x522109){if(_0x522109){_0x23099f=_0x522109[_0xd4c3('0x69')];if(!_0x292bac[_0xd4c3('0x53')]['hasOwnProperty'](_0xd4c3('0x58'))){_0x137601[_0xd4c3('0x34')]=qs[_0xd4c3('0x34')](_0x292bac[_0xd4c3('0x53')][_0xd4c3('0x34')]);_0x137601[_0xd4c3('0x33')]=qs[_0xd4c3('0x33')](_0x292bac[_0xd4c3('0x53')][_0xd4c3('0x33')]);}return _0x4b0fb7[_0xd4c3('0x136')](_0x137601);}})['then'](function(_0x3c10ae){if(_0x3c10ae){return _0x3c10ae?{'count':_0x23099f,'rows':_0x3c10ae}:null;}})['then'](respondWithResult(_0x46a399,null))[_0xd4c3('0x2e')](handleError(_0x46a399,null));};exports[_0xd4c3('0x137')]=function(_0xc04ed6,_0x498ba5,_0xff195c){return db[_0xd4c3('0x4c')][_0xd4c3('0x46')]({'where':{'id':_0xc04ed6[_0xd4c3('0x68')]['id']}})[_0xd4c3('0x23')](handleEntityNotFound(_0x498ba5,null))['then'](function(_0x4d762f){if(_0x4d762f){return _0x4d762f[_0xd4c3('0x137')](_0xc04ed6[_0xd4c3('0x6b')][_0xd4c3('0x6e')],_[_0xd4c3('0x6f')](_0xc04ed6[_0xd4c3('0x6b')],['ids','id'])||{});}})[_0xd4c3('0x23')](respondWithResult(_0x498ba5,null))[_0xd4c3('0x2e')](handleError(_0x498ba5,null));};exports[_0xd4c3('0x138')]=function(_0x5bafc1,_0x13683f,_0x1a5e10){return db['User'][_0xd4c3('0x46')]({'where':{'id':_0x5bafc1[_0xd4c3('0x68')]['id']}})[_0xd4c3('0x23')](handleEntityNotFound(_0x13683f,null))['then'](function(_0x28624a){if(_0x28624a){return _0x28624a[_0xd4c3('0x138')](_0x5bafc1[_0xd4c3('0x53')][_0xd4c3('0x6e')]);}})[_0xd4c3('0x23')](respondWithStatusCode(_0x13683f,null))[_0xd4c3('0x2e')](handleError(_0x13683f,null));};exports[_0xd4c3('0x139')]=function(_0x167392,_0x2d0066){var _0x176c43={},_0x2bbace={},_0x2d7a65={'count':0x0,'rows':[]};var _0x529b7b=db[_0xd4c3('0x13a')][_0xd4c3('0x4d')];_0x2bbace[_0xd4c3('0x4e')]=_['keys'](_0x529b7b);_0x2bbace[_0xd4c3('0x53')]=_[_0xd4c3('0x50')](_0x167392[_0xd4c3('0x53')]);_0x2bbace[_0xd4c3('0x5b')]=_[_0xd4c3('0x54')](_0x2bbace[_0xd4c3('0x4e')],_0x2bbace[_0xd4c3('0x53')]);_0x2bbace[_0xd4c3('0x5b')]=_[_0xd4c3('0xee')](_0x2bbace[_0xd4c3('0x5b')],['$and',_0xd4c3('0x13b'),'$gt',_0xd4c3('0x13c'),_0xd4c3('0x13d'),_0xd4c3('0x13e'),'$ne',_0xd4c3('0x13f'),'$not',_0xd4c3('0x140'),_0xd4c3('0x141'),'$in',_0xd4c3('0x142'),_0xd4c3('0x143'),_0xd4c3('0x144'),_0xd4c3('0x145'),_0xd4c3('0x146'),'$like',_0xd4c3('0x147'),'$contains','$contained',_0xd4c3('0x148')]);_0x176c43[_0xd4c3('0x55')]=_[_0xd4c3('0x54')](_0x2bbace[_0xd4c3('0x4e')],qs[_0xd4c3('0x56')](_0x167392[_0xd4c3('0x53')][_0xd4c3('0x56')]));_0x176c43['attributes']=_0x176c43[_0xd4c3('0x55')][_0xd4c3('0x69')]?_0x176c43[_0xd4c3('0x55')]:_0x2bbace['model'];if(!_0x167392[_0xd4c3('0x53')]['hasOwnProperty'](_0xd4c3('0x58'))){_0x176c43[_0xd4c3('0x34')]=qs['limit'](_0x167392[_0xd4c3('0x53')][_0xd4c3('0x34')]);_0x176c43[_0xd4c3('0x33')]=qs[_0xd4c3('0x33')](_0x167392['query'][_0xd4c3('0x33')]);}_0x176c43[_0xd4c3('0xc2')]=qs['sort'](_0x167392[_0xd4c3('0x53')][_0xd4c3('0x59')]);_0x176c43['where']=qs['filters'](_[_0xd4c3('0x5c')](_0x167392[_0xd4c3('0x53')],_0x2bbace[_0xd4c3('0x5b')]));if(_0x167392[_0xd4c3('0x53')][_0xd4c3('0x41')]){_0x176c43[_0xd4c3('0x5a')]=_[_0xd4c3('0x63')](_0x176c43['where'],{'$or':_[_0xd4c3('0x5d')](_0x176c43[_0xd4c3('0x55')],function(_0x4e7c3e){var _0x4f764c={};_0x4f764c[_0x4e7c3e]={'$like':'%'+_0x167392['query']['filter']+'%'};return _0x4f764c;})});}_0x176c43[_0xd4c3('0x5a')]={'$and':[_0x176c43['where'],{'$or':[{'UserId':_0x167392['params']['id']},{'OwnerId':_0x167392[_0xd4c3('0x68')]['id']}]}]};_0x176c43=_['merge']({},_0x176c43,_0x167392['options']);var _0x10b8be={'where':_0x176c43[_0xd4c3('0x5a')]};return db[_0xd4c3('0x13a')][_0xd4c3('0x32')](_0x10b8be)['then'](function(_0x3734dc){_0x2d7a65[_0xd4c3('0x32')]=_0x3734dc;if(_0x167392[_0xd4c3('0x53')]['includeAll']){_0x176c43[_0xd4c3('0xc3')]=[{'attributes':['id',_0xd4c3('0x149'),_0xd4c3('0x14a'),_0xd4c3('0xdd')],'model':db[_0xd4c3('0xc1')],'as':'Contact'},{'attributes':['id','name','dialActive'],'model':db['VoiceQueue'],'as':_0xd4c3('0xc9')}];}return db['CmHopper'][_0xd4c3('0x66')](_0x176c43);})[_0xd4c3('0x23')](function(_0x275978){_0x2d7a65[_0xd4c3('0xd1')]=_0x275978;return _0x2d7a65;})[_0xd4c3('0x23')](respondWithFilteredResult(_0x2d0066,_0x176c43))[_0xd4c3('0x2e')](handleError(_0x2d0066,null));};exports[_0xd4c3('0x14b')]=function(_0xd6053d,_0x703c3f,_0xdb58fd){if(!_[_0xd4c3('0x74')](_0xd6053d[_0xd4c3('0x3c')]['id'])&&(_0xd6053d['user']['role']=='admin'||_0xd6053d['user'][_0xd4c3('0x45')]=='user')){return db[_0xd4c3('0x4c')][_0xd4c3('0x46')]({'where':{'id':_0xd6053d[_0xd4c3('0x68')]['id']}})[_0xd4c3('0x23')](function(_0x2c9be8){var _0x2de0d1=authService[_0xd4c3('0x14c')](_0x2c9be8);if(_0x2de0d1)return _0x703c3f[_0xd4c3('0x30')](0xc8)['json']({'api_key':_0x2de0d1});else return _0x703c3f[_0xd4c3('0x30')](0xcc)[_0xd4c3('0x31')]({'message':_0xd4c3('0x14d')});})[_0xd4c3('0x2e')](handleError(_0x703c3f,0x193));}else{return _0x703c3f['status'](0x191)[_0xd4c3('0x31')]({'message':_0xd4c3('0x14e')});}};exports['createApiKey']=function(_0x242acd,_0x6bbbcf,_0x2e2d35){var _0xcfe4e;if(!_[_0xd4c3('0x74')](_0x242acd[_0xd4c3('0x3c')]['id'])&&(_0x242acd[_0xd4c3('0x3c')][_0xd4c3('0x45')]==_0xd4c3('0x71')||_0x242acd['user'][_0xd4c3('0x45')]=='user')){return db[_0xd4c3('0x4c')][_0xd4c3('0x46')]({'where':{'id':_0x242acd['params']['id']}})[_0xd4c3('0x23')](function(_0x54b97b){return[_0x54b97b,authService['generateApiKey'](_0x54b97b)];})[_0xd4c3('0x23')](function(_0x127bf2){_0xcfe4e=_0x127bf2;return db[_0xd4c3('0x4c')]['update']({'apiKeyNonce':_0xcfe4e[0x0][_0xd4c3('0x14f')],'apiKeyIat':_0xcfe4e[0x0]['apiKeyIat']},{'where':{'id':_0x242acd[_0xd4c3('0x68')]['id']}});})[_0xd4c3('0x23')](function(){return _0x6bbbcf['status'](0xc8)[_0xd4c3('0x31')]({'api_key':_0xcfe4e[0x1]});})[_0xd4c3('0x2e')](handleError(_0x6bbbcf,0x193));}else{return _0x6bbbcf[_0xd4c3('0x30')](0x191)[_0xd4c3('0x31')]({'message':'You\x20don\x27t\x20have\x20sufficient\x20privelages\x20to\x20access\x20this\x20resource.'});}};exports[_0xd4c3('0x150')]=function(_0x43c0a4,_0x536771,_0x38c4aa){if(!_['isNil'](_0x43c0a4[_0xd4c3('0x3c')]['id'])&&(_0x43c0a4[_0xd4c3('0x3c')][_0xd4c3('0x45')]==_0xd4c3('0x71')||_0x43c0a4['user'][_0xd4c3('0x45')]=='user')){return db['User'][_0xd4c3('0x46')]({'where':{'id':_0x43c0a4[_0xd4c3('0x68')]['id']}})[_0xd4c3('0x23')](handleEntityNotFound(_0x536771,null))['then'](function(_0x860823){if(_0x860823&&_0x860823[_0xd4c3('0x14f')]&&_0x860823[_0xd4c3('0x151')])return _0x860823;else throw{'message':'API\x20key\x20not\x20available'};})['then'](function(_0x4c0810){return db[_0xd4c3('0x4c')][_0xd4c3('0x38')]({'apiKeyNonce':null,'apiKeyIat':null},{'where':{'id':_0x43c0a4[_0xd4c3('0x68')]['id']}});})['then'](respondWithStatusCode(_0x536771,0xc8))[_0xd4c3('0x2e')](handleError(_0x536771,0x193));}else{return _0x536771[_0xd4c3('0x30')](0x191)[_0xd4c3('0x31')]({'message':_0xd4c3('0x14e')});}};