8d761b0dcb0215aeb505024e356753eb1d9a6a92
[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 _0x59b3=['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','request\x20sent','debug','User,\x20%s,\x20%s,\x20%s','code','User,\x20%s,\x20%s','error','message','info','result','catch','sendStatus','status','end','json','count','offset','limit','set','apply','reject','destroy','get','Users','user','Telephones','telephone','filter','ignore','map','value','includes','role','find','name','UserProfileResource','stack','index','User','rawAttributes','fieldName','type','key','model','differenceBy','password','query','filters','intersection','attributes','fields','hasOwnProperty','nolimit','order','sort','where','merge','sequelize','col','lower','options','includeAll','include','rows','show','params','keys','salt','length','bulkCreate','body','describe','addContacts','ids','agent','admin','users','format','count\x20%s:\x20%s','internal','Setting','findById','securePassword','min_internal','max','isNil','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','VoiceMail','fullname','permissions','102','103','113','110','106','107','108','109','100','111','114','create','Agents','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','oldPassword','newPassword','Invalid\x20body\x20format.\x20Use\x20oldPassord\x20and\x20newPassword','authenticate','Invalid\x20body\x20format.\x20Use\x20newPassword','Unauthorized','channel','online','loginInPause','voicePause','isValidChannel','Unknown\x20channel','add','capitalize','penalty','spread','toLowerCase','emit','Queue:save','findAll','voice','SIP/%s','interface','each','remove','Queues','QueueId','UserVoiceQueueRt','addAvatar','file','filename','join','root','server/files/images/logos/default_profile.png','userpic','download','existsSync','server/files/images/','getContacts','findOne','CmContact','pick','List','Tag','Tags','tag','Queue','Unknown\x20role','getVoiceQueuesRt','getGroups','ChatGroup','getRecordings','VoiceRecording','UserId','ScreenRecording','ChatInteraction','getChatInteractions','getOpenchannelInteractions','OpenchannelInteraction','getMailInteractions','MailInteraction','getSmsInteractions','getFaxInteractions','FaxInteraction','getWhatsappInteractions','WhatsappInteraction','login','phone','LOCAL/%s@from-sip/n','intrf','user:%s','user:forcelogout','headers','x-forwarded-for','connection','remoteAddress','socket','User\x20not\x20found\x20or\x20not\x20allowed\x20to\x20perform\x20login\x20method','push','MemberReport','forEach','YYYY-MM-DD\x20HH:mm:ss','getChannels','LOGIN','PAUSE','LOGININPAUSE','concat','update','isMiddleware','resolve','logout','all','pause','QueuePause','updateAttributes','DEFAULT\x20PAUSE','unpause','mailPause','chatPause','smsPause','whatsapppause','pauseType','lastPauseAt','manual','mail','fax','sms','whatsapp','openchannel','%s%s','getTeams','addTeams','Team','getVoiceQueues','setDataValue','Voice','getChatQueues','Chat','Mail','getSmsQueues','getWhatsappQueues','Whatsapp','flatten','addAgent','upsert','removeTeams','getMailQueues','Sms','getFaxQueues','Fax','getOpenchannelQueues','Openchannel','transaction','removeAgent','getDataValue','Queue:remove','getLists','CmList','getAgents','values','send','omit','user_has_chat_interactions:save','user_has_chat_interactions:remove','addMailInteractions','user_has_mail_interactions:save','removeMailInteractions','isArray','user_has_mail_interactions:remove','addFaxInteractions','removeFaxInteractions','user_has_fax_interactions:remove','addSmsInteractions','user_has_sms_interactions:save','removeSmsInteractions','user_has_sms_interactions:remove','addOpenchannelInteractions','removeOpenchannelInteractions','user_has_openchannel_interactions:remove','addWhatsappInteractions','user_has_whatsapp_interactions:save','removeWhatsappInteractions','VoicePrefix','getVoicePrefixes','getFaxAccounts','FaxAccount','addFaxAccounts','removeFaxAccounts','MailAccount','getMailAccounts','removeMailAccounts','getOpenchannelAccounts','OpenchannelAccount','addOpenchannelAccounts','removeOpenchannelAccounts','getSmsAccounts','SmsAccount','addSmsAccounts','removeSmsAccounts','ChatWebsite','getChatWebsites','addChatWebsites','removeChatWebsites','getWhatsappAccounts','addWhatsappAccounts','removeWhatsappAccounts','getSquareProjects','SquareProject','addSquareProjects','removeSquareProjects','getScheduledCalls','CmHopper','$and','$gt','$gte','$lt','$lte','$eq','$between','$notBetween','$in','$notIn','$like','$notLike','$contains','$contained','firstName','lastName','Contact','VoiceQueue','getApiKey','retrieveApiKey','token','You\x20don\x27t\x20have\x20sufficient\x20privileges\x20to\x20access\x20this\x20resource.','createApiKey','generateApiKey','iat','nonce','removeApiKey','apiKeyIat','API\x20key\x20not\x20available','whoami','html-pdf','eml-format','rimraf','fast-json-patch','request-promise','moment','bluebird','util','path','to-csv','ejs','lodash','squel','crypto','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../mysqldb','redis','localhost','socket.io-emitter','./user.socket','register','jayson/promise','test','Sequelize','ValidationError'];(function(_0x59c129,_0x224c8b){var _0x4f623d=function(_0x54c88e){while(--_0x54c88e){_0x59c129['push'](_0x59c129['shift']());}};_0x4f623d(++_0x224c8b);}(_0x59b3,0x14e));var _0x359b=function(_0x28e33b,_0x47eb28){_0x28e33b=_0x28e33b-0x0;var _0x50032b=_0x59b3[_0x28e33b];return _0x50032b;};'use strict';var pdf=require(_0x359b('0x0'));var emlformat=require(_0x359b('0x1'));var rimraf=require(_0x359b('0x2'));var zipdir=require('zip-dir');var jsonpatch=require(_0x359b('0x3'));var rp=require(_0x359b('0x4'));var moment=require(_0x359b('0x5'));var BPromise=require(_0x359b('0x6'));var Mustache=require('mustache');var util=require(_0x359b('0x7'));var path=require(_0x359b('0x8'));var sox=require('sox');var csv=require(_0x359b('0x9'));var ejs=require(_0x359b('0xa'));var fs=require('fs');var _=require(_0x359b('0xb'));var squel=require(_0x359b('0xc'));var crypto=require(_0x359b('0xd'));var jsforce=require('jsforce');var deskjs=require('desk.js');var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require(_0x359b('0xe'));var Redis=require('ioredis');var authService=require(_0x359b('0xf'));var qs=require(_0x359b('0x10'));var as=require(_0x359b('0x11'));var hardwareService=require(_0x359b('0x12'));var logger=require(_0x359b('0x13'))(_0x359b('0x14'));var utils=require(_0x359b('0x15'));var config=require('../../config/environment');var db=require(_0x359b('0x16'))['db'];config[_0x359b('0x17')]=_['defaults'](config[_0x359b('0x17')],{'host':_0x359b('0x18'),'port':0x18eb});var socket=require(_0x359b('0x19'))(new Redis(config[_0x359b('0x17')]));require(_0x359b('0x1a'))[_0x359b('0x1b')](socket);var jayson=require(_0x359b('0x1c'));var client=jayson['client']['http']({'port':0x232a});function checkPasswordPattern(_0x3c3028,_0x49a637,_0x304390){if(_0x304390){var _0x529823=new RegExp(/(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[?!@#\$%\^&\*~\-_=+[{\]\}])(?=.{8,})/);if(_0x529823[_0x359b('0x1d')](_0x49a637)){return _0x3c3028;}else{throw new db[(_0x359b('0x1e'))][(_0x359b('0x1f'))](_0x359b('0x20'));}}else{return _0x3c3028;}}function respondWithRpcPromise(_0x440a11,_0x3094ab,_0x52a7ad,_0x15281d){return new BPromise(function(_0xa84c58,_0x3e1b92){var _0x16ea30=_0x15281d||client;return _0x16ea30[_0x359b('0x21')](_0x440a11,_0x52a7ad)[_0x359b('0x22')](function(_0x297114){logger['info']('User,\x20%s,\x20%s',_0x3094ab,_0x359b('0x23'));logger[_0x359b('0x24')](_0x359b('0x25'),_0x3094ab,_0x359b('0x23'),JSON['stringify'](_0x297114));if(_0x297114['error']){if(_0x297114['error'][_0x359b('0x26')]===0x1f4){logger['error'](_0x359b('0x27'),_0x3094ab,_0x297114['error']['message']);return _0x3e1b92(_0x297114[_0x359b('0x28')][_0x359b('0x29')]);}logger[_0x359b('0x28')](_0x359b('0x27'),_0x3094ab,_0x297114[_0x359b('0x28')][_0x359b('0x29')]);return _0xa84c58(_0x297114[_0x359b('0x28')]['message']);}else{logger[_0x359b('0x2a')](_0x359b('0x27'),_0x3094ab,_0x359b('0x23'));_0xa84c58(_0x297114[_0x359b('0x2b')][_0x359b('0x29')]);}})[_0x359b('0x2c')](function(_0x7176e0){logger[_0x359b('0x28')](_0x359b('0x27'),_0x3094ab,_0x7176e0);_0x3e1b92(_0x7176e0);});});}function respondWithStatusCode(_0x185856,_0x666d18){_0x666d18=_0x666d18||0xcc;return function(_0x4003b3){if(_0x4003b3){return _0x185856[_0x359b('0x2d')](_0x666d18);}return _0x185856[_0x359b('0x2e')](_0x666d18)[_0x359b('0x2f')]();};}function respondWithResult(_0x487dde,_0x18f5d0){_0x18f5d0=_0x18f5d0||0xc8;return function(_0x52d813){if(_0x52d813){return _0x487dde[_0x359b('0x2e')](_0x18f5d0)[_0x359b('0x30')](_0x52d813);}};}function respondWithFilteredResult(_0x56a4f1,_0x1dee88){return function(_0x5a4ae5){if(_0x5a4ae5){var _0x4d4506=_0x5a4ae5[_0x359b('0x31')],_0x410d33=_0x1dee88[_0x359b('0x32')],_0x4ac80e=_0x1dee88[_0x359b('0x32')]+_0x1dee88[_0x359b('0x33')],_0x2acf11;if(_0x4ac80e>=_0x4d4506){_0x4ac80e=_0x4d4506;_0x2acf11=0xc8;}else{_0x2acf11=0xce;}_0x56a4f1[_0x359b('0x2e')](_0x2acf11);return _0x56a4f1[_0x359b('0x34')]('Content-Range',_0x410d33+'-'+_0x4ac80e+'/'+_0x4d4506)['json'](_0x5a4ae5);}return null;};}function patchUpdates(_0x498620){return function(_0x257eb0){try{jsonpatch[_0x359b('0x35')](_0x257eb0,_0x498620,!![]);}catch(_0x35ed2b){return BPromise[_0x359b('0x36')](_0x35ed2b);}return _0x257eb0['save']();};}function saveUpdates(_0x1ba9b0,_0x2ef79b){return function(_0xf0f463){if(_0xf0f463){return _0xf0f463['update'](_0x1ba9b0)[_0x359b('0x22')](function(_0x4b3966){return _0x4b3966;});}return null;};}function removeEntity(_0x3795d1,_0x45c2e2){return function(_0xcee6e9){if(_0xcee6e9){return _0xcee6e9[_0x359b('0x37')]()[_0x359b('0x22')](function(){var _0xc89186=_0xcee6e9[_0x359b('0x38')]({'plain':!![]});var _0x42e666=[{'name':_0x359b('0x39'),'value':_0x359b('0x3a'),'ignore':!![]},{'name':'Agents','value':'agent','ignore':![]},{'name':_0x359b('0x3b'),'value':_0x359b('0x3c'),'ignore':![]}];var _0x3621f3=_(_0x42e666)[_0x359b('0x3d')](_0x359b('0x3e'))[_0x359b('0x3f')](_0x359b('0x40'))[_0x359b('0x40')]();if(_[_0x359b('0x41')](_0x3621f3,_0xc89186[_0x359b('0x42')])){return;}var _0x2e8507=_[_0x359b('0x43')](_0x42e666,[_0x359b('0x40'),_0xc89186['role']])[_0x359b('0x44')];return db[_0x359b('0x45')]['destroy']({'where':{'type':_0x2e8507,'resourceId':_0xc89186['id']}})[_0x359b('0x22')](function(){return _0xcee6e9;});})[_0x359b('0x22')](function(){_0x3795d1[_0x359b('0x2e')](0xcc)[_0x359b('0x2f')]();});}};}function handleEntityNotFound(_0x354a02,_0x467057){return function(_0x5a3e71){if(!_0x5a3e71){_0x354a02['sendStatus'](0x194);}return _0x5a3e71;};}function handleError(_0x39cb39,_0x28ccc4){_0x28ccc4=_0x28ccc4||0x1f4;return function(_0x293972){logger[_0x359b('0x28')](_0x293972[_0x359b('0x46')]);if(_0x293972[_0x359b('0x44')]){delete _0x293972[_0x359b('0x44')];}_0x39cb39[_0x359b('0x2e')](_0x28ccc4)['send'](_0x293972);};}exports[_0x359b('0x47')]=function(_0x40c483,_0xfbf7bf){var _0x4c418c={},_0x1914a3={},_0x741c38={'count':0x0,'rows':[]};var _0x3d1a5d=_['map'](db[_0x359b('0x48')][_0x359b('0x49')],function(_0x2cb296){return{'name':_0x2cb296[_0x359b('0x4a')],'type':_0x2cb296[_0x359b('0x4b')][_0x359b('0x4c')]};});_0x1914a3[_0x359b('0x4d')]=_[_0x359b('0x4e')](_[_0x359b('0x3f')](_0x3d1a5d,'name'),[_0x359b('0x4f'),'salt']);_0x1914a3[_0x359b('0x50')]=_['keys'](_0x40c483[_0x359b('0x50')]);_0x1914a3[_0x359b('0x51')]=_[_0x359b('0x52')](_0x1914a3[_0x359b('0x4d')],_0x1914a3['query']);_0x4c418c[_0x359b('0x53')]=_['intersection'](_0x1914a3['model'],qs[_0x359b('0x54')](_0x40c483[_0x359b('0x50')]['fields']));_0x4c418c[_0x359b('0x53')]=_0x4c418c[_0x359b('0x53')]['length']?_0x4c418c[_0x359b('0x53')]:_0x1914a3['model'];if(!_0x40c483[_0x359b('0x50')][_0x359b('0x55')](_0x359b('0x56'))){_0x4c418c[_0x359b('0x33')]=qs[_0x359b('0x33')](_0x40c483[_0x359b('0x50')][_0x359b('0x33')]);_0x4c418c['offset']=qs['offset'](_0x40c483[_0x359b('0x50')][_0x359b('0x32')]);}_0x4c418c[_0x359b('0x57')]=qs[_0x359b('0x58')](_0x40c483[_0x359b('0x50')]['sort']);_0x4c418c[_0x359b('0x59')]=qs[_0x359b('0x51')](_['pick'](_0x40c483['query'],_0x1914a3[_0x359b('0x51')]),_0x3d1a5d);if(_0x40c483[_0x359b('0x50')]['filter']){_0x4c418c[_0x359b('0x59')]=_[_0x359b('0x5a')](_0x4c418c[_0x359b('0x59')],{'$or':_[_0x359b('0x3f')](_0x3d1a5d,function(_0x2be14f){if(_0x2be14f[_0x359b('0x4b')]!=='VIRTUAL'){return db[_0x359b('0x5b')][_0x359b('0x59')](db[_0x359b('0x5b')]['fn']('lower',db['sequelize'][_0x359b('0x5c')](_0x2be14f[_0x359b('0x44')])),{'$like':db[_0x359b('0x5b')]['fn'](_0x359b('0x5d'),'%'+_0x40c483[_0x359b('0x50')][_0x359b('0x3d')]+'%')});}})});}_0x4c418c=_['merge']({},_0x4c418c,_0x40c483[_0x359b('0x5e')]);var _0x286f7d={'where':_0x4c418c[_0x359b('0x59')]};return db['User'][_0x359b('0x31')](_0x286f7d)[_0x359b('0x22')](function(_0x7c48e4){_0x741c38['count']=_0x7c48e4;if(_0x40c483[_0x359b('0x50')][_0x359b('0x5f')]){_0x4c418c[_0x359b('0x60')]=[{'all':!![]}];}return db[_0x359b('0x48')]['findAll'](_0x4c418c);})[_0x359b('0x22')](function(_0x3a73cd){_0x741c38[_0x359b('0x61')]=_0x3a73cd;return _0x741c38;})[_0x359b('0x22')](respondWithFilteredResult(_0xfbf7bf,_0x4c418c))['catch'](handleError(_0xfbf7bf,null));};exports[_0x359b('0x62')]=function(_0x438244,_0x4eef2e){var _0x10dca3={'raw':![],'where':{'id':_0x438244[_0x359b('0x63')]['id']}},_0x1e5b27={};_0x1e5b27[_0x359b('0x4d')]=_[_0x359b('0x4e')](_[_0x359b('0x64')](db[_0x359b('0x48')][_0x359b('0x49')]),['password',_0x359b('0x65')]);_0x1e5b27[_0x359b('0x50')]=_[_0x359b('0x64')](_0x438244['query']);_0x1e5b27[_0x359b('0x51')]=_[_0x359b('0x52')](_0x1e5b27['model'],_0x1e5b27[_0x359b('0x50')]);_0x10dca3['attributes']=_[_0x359b('0x52')](_0x1e5b27[_0x359b('0x4d')],qs[_0x359b('0x54')](_0x438244[_0x359b('0x50')][_0x359b('0x54')]));_0x10dca3[_0x359b('0x53')]=_0x10dca3[_0x359b('0x53')][_0x359b('0x66')]?_0x10dca3[_0x359b('0x53')]:_0x1e5b27[_0x359b('0x4d')];if(_0x438244['query']['includeAll']){_0x10dca3[_0x359b('0x60')]=[{'all':!![]}];}_0x10dca3=_[_0x359b('0x5a')]({},_0x10dca3,_0x438244[_0x359b('0x5e')]);return db['User'][_0x359b('0x43')](_0x10dca3)['then'](handleEntityNotFound(_0x4eef2e,null))[_0x359b('0x22')](respondWithResult(_0x4eef2e,null))['catch'](handleError(_0x4eef2e,null));};exports[_0x359b('0x67')]=function(_0x251b76,_0x540d12){return db[_0x359b('0x48')][_0x359b('0x67')](_0x251b76[_0x359b('0x68')],{'raw':![],'individualHooks':!![]})['then'](respondWithResult(_0x540d12,0xc9))[_0x359b('0x2c')](handleError(_0x540d12,null));};exports['update']=function(_0x358412,_0x48ccb5){if(_0x358412['body']['id']){delete _0x358412[_0x359b('0x68')]['id'];}delete _0x358412[_0x359b('0x68')][_0x359b('0x42')];return db[_0x359b('0x48')][_0x359b('0x43')]({'where':{'id':_0x358412['params']['id']}})[_0x359b('0x22')](handleEntityNotFound(_0x48ccb5,null))['then'](saveUpdates(_0x358412[_0x359b('0x68')],null))[_0x359b('0x22')](respondWithResult(_0x48ccb5,null))['catch'](handleError(_0x48ccb5,null));};exports[_0x359b('0x69')]=function(_0x4eb675,_0x1ccaa9){return db[_0x359b('0x48')][_0x359b('0x69')]()[_0x359b('0x22')](respondWithResult(_0x1ccaa9,null))[_0x359b('0x2c')](handleError(_0x1ccaa9,null));};exports[_0x359b('0x6a')]=function(_0x410029,_0x4d2a9f,_0x34d3a3){return db['User'][_0x359b('0x43')]({'where':{'id':_0x410029[_0x359b('0x63')]['id']}})[_0x359b('0x22')](handleEntityNotFound(_0x4d2a9f,null))[_0x359b('0x22')](function(_0xc898cc){if(_0xc898cc){return _0xc898cc[_0x359b('0x6a')](_0x410029[_0x359b('0x68')][_0x359b('0x6b')],_['omit'](_0x410029['body'],[_0x359b('0x6b'),'id'])||{});}})[_0x359b('0x22')](respondWithResult(_0x4d2a9f,null))['catch'](handleError(_0x4d2a9f,null));};var getLicense=function(_0x22b64a){return new BPromise(function(_0x179081,_0x4aa978){var _0x2e9551=0x0;_0x22b64a[_0x359b('0x68')][_0x359b('0x42')]===_0x359b('0x6c')&&_0x179081('agent\x20role');return db[_0x359b('0x48')]['count']({'where':{'$or':[{'role':_0x22b64a[_0x359b('0x68')][_0x359b('0x42')]==='telephone'?'telephone':[_0x359b('0x6d'),'user']}]}})[_0x359b('0x22')](function(_0x5b272f){_0x2e9551=_0x5b272f;return require('../../config/license/util')['getLicense']();})[_0x359b('0x22')](function(_0x41db0e){var _0x2b1bf7=_0x22b64a[_0x359b('0x68')]['role']==='telephone'?'telephones':_0x359b('0x6e');if(!_['isNil'](_0x41db0e[_0x2b1bf7])&&_0x2e9551>=_0x41db0e[_0x2b1bf7]){return _0x4aa978({'message':'License\x20limit\x20reached'});}return _0x179081(util[_0x359b('0x6f')](_0x359b('0x70'),_0x2b1bf7,_0x2e9551));})[_0x359b('0x2c')](function(_0x1dfc9e){return _0x4aa978(_0x1dfc9e);});});};exports['create']=function(_0x3e6faa,_0x15b93b){return getLicense(_0x3e6faa)['then'](function(_0x419acf){if(!_0x3e6faa['body'][_0x359b('0x71')]){var _0xac0a7c;return db[_0x359b('0x72')][_0x359b('0x73')](0x1)[_0x359b('0x22')](function(_0x547b36){return checkPasswordPattern(_0x547b36,_0x3e6faa['body'][_0x359b('0x4f')],_0x547b36[_0x359b('0x74')]);})['then'](function(_0x5b83dd){_0xac0a7c=_0x5b83dd[_0x359b('0x75')];return db[_0x359b('0x48')][_0x359b('0x76')](_0x359b('0x71'));})[_0x359b('0x22')](function(_0x5726e1){if(_[_0x359b('0x77')](_0x5726e1)){if(_0xac0a7c){_0x3e6faa['body'][_0x359b('0x71')]=_0xac0a7c;}else{_0x3e6faa[_0x359b('0x68')][_0x359b('0x71')]=0x1;}}else{if(_[_0x359b('0x77')](_0xac0a7c)||_0xac0a7c==_0x5726e1){_0x3e6faa['body'][_0x359b('0x71')]=_0x5726e1+0x1;}else if(_0xac0a7c>_0x5726e1){_0x3e6faa[_0x359b('0x68')]['internal']=_0xac0a7c;}else{return db['sequelize'][_0x359b('0x50')](_0x359b('0x78'),{'type':db[_0x359b('0x5b')][_0x359b('0x79')][_0x359b('0x7a')]})[_0x359b('0x22')](function(_0x3a4145){if(_0x3a4145&&_0x3a4145[_0x359b('0x66')]){for(var _0x34b9ef=0x0,_0x5c254a=_0x3a4145[_0x359b('0x66')];_0x34b9ef<_0x5c254a&&_[_0x359b('0x77')](_0x3e6faa['body'][_0x359b('0x71')]);_0x34b9ef++){if(_0xac0a7c<=_0x3a4145[_0x34b9ef][_0x359b('0x7b')]){_0x3e6faa[_0x359b('0x68')][_0x359b('0x71')]=_0x3a4145[_0x34b9ef][_0x359b('0x7b')];}else if(_0xac0a7c>_0x3a4145[_0x34b9ef]['from']&&_0xac0a7c<=_0x3a4145[_0x34b9ef]['to']){_0x3e6faa['body'][_0x359b('0x71')]=_0xac0a7c;}}}if(_[_0x359b('0x77')](_0x3e6faa[_0x359b('0x68')][_0x359b('0x71')])){_0x3e6faa[_0x359b('0x68')][_0x359b('0x71')]=_0x5726e1+0x1;}});}}});}})[_0x359b('0x22')](function(){if(_0x3e6faa[_0x359b('0x68')][_0x359b('0x7c')]){_0x3e6faa[_0x359b('0x68')]['mailbox']=_0x3e6faa[_0x359b('0x68')]['internal'];_0x3e6faa[_0x359b('0x68')][_0x359b('0x7d')]={'mailbox':_0x3e6faa[_0x359b('0x68')][_0x359b('0x71')],'password':_0x3e6faa[_0x359b('0x68')][_0x359b('0x4f')],'fullname':_0x3e6faa[_0x359b('0x68')][_0x359b('0x7e')],'email':_0x3e6faa[_0x359b('0x68')]['email']};}if(_0x3e6faa[_0x359b('0x68')]&&_0x3e6faa[_0x359b('0x68')][_0x359b('0x42')]===_0x359b('0x6c')){if(!_0x3e6faa[_0x359b('0x68')][_0x359b('0x7f')]){_0x3e6faa[_0x359b('0x68')][_0x359b('0x7f')]=['101',_0x359b('0x80'),_0x359b('0x81'),_0x359b('0x82'),_0x359b('0x83'),'104','105',_0x359b('0x84'),_0x359b('0x85'),_0x359b('0x86'),_0x359b('0x87'),_0x359b('0x88'),_0x359b('0x89'),_0x359b('0x8a')];}}return db[_0x359b('0x48')][_0x359b('0x8b')](_0x3e6faa['body'],{'include':[{'model':db['VoiceMail'],'as':'VoiceMail'}]});})['then'](function(_0x3406b8){if(_0x3e6faa[_0x359b('0x68')][_0x359b('0x42')]==='user')return _0x3406b8;var _0x107a05=_0x3e6faa[_0x359b('0x3a')][_0x359b('0x38')]({'plain':!![]});if(!_0x107a05)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x107a05[_0x359b('0x42')]===_0x359b('0x3a')){var _0x1c08ff=_0x3406b8[_0x359b('0x38')]({'plain':!![]});var _0x5ae132=[{'name':_0x359b('0x8c'),'value':_0x359b('0x6c')},{'name':_0x359b('0x3b'),'value':_0x359b('0x3c')}];var _0x41b0b1=_[_0x359b('0x43')](_0x5ae132,[_0x359b('0x40'),_0x1c08ff[_0x359b('0x42')]])[_0x359b('0x44')];return db['UserProfileSection'][_0x359b('0x43')]({'where':{'name':_0x41b0b1,'userProfileId':_0x107a05[_0x359b('0x8d')]},'raw':!![]})[_0x359b('0x22')](function(_0x436744){if(_0x436744&&_0x436744[_0x359b('0x8e')]===0x0){return db[_0x359b('0x45')]['create']({'name':_0x1c08ff[_0x359b('0x44')],'resourceId':_0x1c08ff['id'],'type':_0x436744[_0x359b('0x44')],'sectionId':_0x436744['id']},{})[_0x359b('0x22')](function(){return _0x3406b8;});}else{return _0x3406b8;}})[_0x359b('0x2c')](function(_0x4ff89b){logger['error'](_0x359b('0x8f'),_0x4ff89b);throw _0x4ff89b;});}return _0x3406b8;})['then'](respondWithResult(_0x15b93b,0xc9))[_0x359b('0x2c')](handleError(_0x15b93b,null));};exports['changePassword']=function(_0x350bf7,_0x7a2eff,_0x1d2d76){var _0x3bc3cd=![];if(_0x350bf7[_0x359b('0x68')]['id']){delete _0x350bf7[_0x359b('0x68')]['id'];}return db[_0x359b('0x72')]['findOne']({'attributes':['id','securePassword']})[_0x359b('0x22')](function(_0x28c72b){_0x3bc3cd=_0x28c72b['securePassword'];return db['User'][_0x359b('0x43')]({'where':{'id':_0x350bf7[_0x359b('0x63')]['id']}});})['then'](function(_0x3ea702){if(_0x3ea702){if(_0x3ea702['id']==_0x350bf7[_0x359b('0x3a')]['id']){if(!_0x350bf7[_0x359b('0x68')][_0x359b('0x90')]||!_0x350bf7[_0x359b('0x68')][_0x359b('0x91')]){throw new db[(_0x359b('0x1e'))][(_0x359b('0x1f'))](_0x359b('0x92'));}if(!_0x3ea702[_0x359b('0x93')](_0x350bf7[_0x359b('0x68')]['oldPassword'])){throw new db[(_0x359b('0x1e'))]['ValidationError']('Wrong\x20credentials');}if(_0x350bf7[_0x359b('0x68')][_0x359b('0x90')]==_0x350bf7[_0x359b('0x68')][_0x359b('0x91')]){throw new db['Sequelize'][(_0x359b('0x1f'))]('New\x20password\x20must\x20be\x20different\x20from\x20old\x20password');}return _0x3ea702;}else if(_0x350bf7['user'][_0x359b('0x42')]==_0x359b('0x6d')){if(!_0x350bf7[_0x359b('0x68')][_0x359b('0x91')]){throw new db[(_0x359b('0x1e'))][(_0x359b('0x1f'))](_0x359b('0x94'));}return _0x3ea702;}else if(_0x350bf7[_0x359b('0x3a')][_0x359b('0x42')]==_0x359b('0x3a')){if(!_0x350bf7[_0x359b('0x68')][_0x359b('0x91')]){throw new db[(_0x359b('0x1e'))][(_0x359b('0x1f'))](_0x359b('0x94'));}if(_0x3ea702[_0x359b('0x42')]!=_0x359b('0x6c')){throw new db[(_0x359b('0x1e'))]['ValidationError']('Unauthorized');}return _0x3ea702;}else{throw new db[(_0x359b('0x1e'))][(_0x359b('0x1f'))](_0x359b('0x95'));}}return null;})[_0x359b('0x22')](handleEntityNotFound(_0x7a2eff,null))[_0x359b('0x22')](function(_0x4766dd){return checkPasswordPattern(_0x4766dd,_0x350bf7[_0x359b('0x68')]['newPassword'],_0x3bc3cd);})[_0x359b('0x22')](saveUpdates({'password':_0x350bf7[_0x359b('0x68')]['newPassword'],'passwordResetAt':_0x350bf7[_0x359b('0x3a')]['id']==_0x350bf7[_0x359b('0x63')]['id']?moment():null},null))['then'](respondWithResult(_0x7a2eff,null))[_0x359b('0x2c')](handleError(_0x7a2eff,null));};exports['addQueues']=function(_0x41fd8a,_0x20388d,_0x457726){var _0x2c066f=_0x41fd8a[_0x359b('0x68')][_0x359b('0x96')];return db[_0x359b('0x48')][_0x359b('0x43')]({'where':{'id':_0x41fd8a[_0x359b('0x63')]['id']},'attributes':['id',_0x359b('0x44'),_0x359b('0x42'),_0x359b('0x97'),_0x359b('0x98'),_0x359b('0x99'),'interface']})['then'](handleEntityNotFound(_0x20388d,null))['then'](function(_0x2c1664){if(_0x2c1664){if(!utils[_0x359b('0x9a')](_0x2c066f)){throw new db['Sequelize'][(_0x359b('0x1f'))](_0x359b('0x9b'));}return _0x2c1664[_0x359b('0x9c')+_[_0x359b('0x9d')](_0x2c066f['toLowerCase']())+'Queues'](_0x41fd8a[_0x359b('0x68')][_0x359b('0x6b')],{'penalty':_0x41fd8a['body'][_0x359b('0x9e')]||0x0})[_0x359b('0x9f')](function(_0x22f8da){for(var _0x47bc99=0x0;_0x47bc99<_0x41fd8a[_0x359b('0x68')][_0x359b('0x6b')][_0x359b('0x66')];_0x47bc99+=0x1){var _0x370545={'UserId':_0x41fd8a[_0x359b('0x63')]['id']};_0x370545[_[_0x359b('0x9d')](_0x2c066f[_0x359b('0xa0')]())+'QueueId']=_0x41fd8a[_0x359b('0x68')][_0x359b('0x6b')][_0x47bc99];socket[_0x359b('0xa1')](_0x359b('0x3a')+_[_0x359b('0x9d')](_0x2c066f[_0x359b('0xa0')]())+_0x359b('0xa2'),_0x370545);}return _0x22f8da;})['then'](function(){if(_0x2c066f==='voice'){return db['VoiceQueue'][_0x359b('0xa3')]({'where':{'id':_0x41fd8a[_0x359b('0x68')][_0x359b('0x6b')]||[]},'raw':!![],'attributes':['id',_0x359b('0x44')]});}})[_0x359b('0x22')](function(_0x195636){var _0x437dcb=_0x2c1664['get']({'plain':!![]});var _0x4d09ca=[];if(_0x2c066f===_0x359b('0xa4')&&_0x437dcb[_0x359b('0x42')]===_0x359b('0x6c')&&_0x437dcb[_0x359b('0x97')]){for(var _0x5a78c8=0x0;_0x5a78c8<_0x195636[_0x359b('0x66')];_0x5a78c8+=0x1){_0x4d09ca['push']({'membername':_0x437dcb[_0x359b('0x44')],'UserId':_0x437dcb['id'],'queue_name':_0x195636[_0x5a78c8][_0x359b('0x44')],'VoiceQueueId':_0x195636[_0x5a78c8]['id'],'interface':_[_0x359b('0x77')](_0x437dcb['interface'])?util[_0x359b('0x6f')](_0x359b('0xa5'),_0x437dcb[_0x359b('0x44')]):_0x437dcb[_0x359b('0xa6')],'paused':_0x437dcb[_0x359b('0x99')]||![],'penalty':_0x41fd8a['body'][_0x359b('0x9e')]||0x0});}return BPromise[_0x359b('0xa7')](_0x4d09ca,function(_0x5f18da){return db['UserVoiceQueueRt']['upsert'](_0x5f18da);});}return _0x2c1664;});}})['then'](respondWithStatusCode(_0x20388d,null))['catch'](handleError(_0x20388d,null));};exports['removeQueues']=function(_0x5a5d00,_0x1c7a20,_0x1b787b){var _0xd030a;return db[_0x359b('0x48')]['find']({'where':{'id':_0x5a5d00['params']['id']},'attributes':['id',_0x359b('0x44'),'role']})[_0x359b('0x22')](handleEntityNotFound(_0x1c7a20,null))[_0x359b('0x22')](function(_0x3ca62f){if(_0x3ca62f){_0xd030a=_0x3ca62f;if(!_0x5a5d00[_0x359b('0x50')][_0x359b('0x96')]||!utils['isValidChannel'](_0x5a5d00['query']['channel'])){throw new db[(_0x359b('0x1e'))][(_0x359b('0x1f'))](_0x359b('0x9b'));}return _0x3ca62f[_0x359b('0xa8')+_[_0x359b('0x9d')](_0x5a5d00[_0x359b('0x50')][_0x359b('0x96')][_0x359b('0xa0')]())+_0x359b('0xa9')](_0x5a5d00[_0x359b('0x50')][_0x359b('0x6b')]);}})[_0x359b('0x22')](function(_0x3890f9){for(var _0x1d7924=0x0;_0x1d7924<_0x5a5d00['query'][_0x359b('0x6b')][_0x359b('0x66')];_0x1d7924+=0x1){var _0x499ade={'UserId':_0x5a5d00['params']['id']};_0x499ade[_['capitalize'](_0x5a5d00[_0x359b('0x50')]['channel']['toLowerCase']())+_0x359b('0xaa')]=_0x5a5d00[_0x359b('0x50')][_0x359b('0x6b')][_0x1d7924];socket['emit'](_0x359b('0x3a')+_[_0x359b('0x9d')](_0x5a5d00[_0x359b('0x50')][_0x359b('0x96')]['toLowerCase']())+'Queue:remove',_0x499ade);}return _0x3890f9;})[_0x359b('0x22')](function(){if(_0x5a5d00[_0x359b('0x50')][_0x359b('0x96')]===_0x359b('0xa4')){return db[_0x359b('0xab')]['destroy']({'where':{'UserId':_0x5a5d00['params']['id'],'VoiceQueueId':_0x5a5d00[_0x359b('0x50')][_0x359b('0x6b')]},'individualHooks':!![]})[_0x359b('0x22')](function(){return _0xd030a;});}return _0xd030a;})[_0x359b('0x22')](respondWithStatusCode(_0x1c7a20,null))[_0x359b('0x2c')](handleError(_0x1c7a20,null));};exports[_0x359b('0xac')]=function(_0x19ce91,_0x10606c,_0x446594){_0x19ce91[_0x359b('0x68')]['userpic']=_0x19ce91[_0x359b('0xad')][_0x359b('0xae')];return db[_0x359b('0x48')][_0x359b('0x43')]({'where':{'id':_0x19ce91[_0x359b('0x63')]['id']}})[_0x359b('0x22')](handleEntityNotFound(_0x10606c,null))['then'](saveUpdates(_0x19ce91[_0x359b('0x68')],null))['then'](respondWithResult(_0x10606c,null))['catch'](handleError(_0x10606c,null));};exports['getAvatar']=function(_0x29377b,_0x2f79c7,_0x3f7b6e){var _0x125d5c=path[_0x359b('0xaf')](config[_0x359b('0xb0')],_0x359b('0xb1'));return db['User']['find']({'where':{'id':_0x29377b['params']['id']},'attributes':['id',_0x359b('0xb2')],'raw':!![]})[_0x359b('0x22')](handleEntityNotFound(_0x2f79c7,null))[_0x359b('0x22')](function(_0x7e9837){if(_0x7e9837){if(_[_0x359b('0x77')](_0x7e9837[_0x359b('0xb2')])){return _0x2f79c7[_0x359b('0xb3')](_0x125d5c);}else{if(!fs[_0x359b('0xb4')](path['join'](config[_0x359b('0xb0')],_0x359b('0xb5'),_0x7e9837['userpic']))){return _0x2f79c7['download'](_0x125d5c);}return _0x2f79c7['download'](path['join'](config[_0x359b('0xb0')],'server/files/images/',_0x7e9837[_0x359b('0xb2')]));}}})['catch'](handleError(_0x2f79c7,null));};exports[_0x359b('0xb6')]=function(_0x2154a3,_0x37eddb,_0x5cc817){var _0x1394cb={};var _0x1a3d51={};var _0x401db2;var _0x1459f0;return db['User'][_0x359b('0xb7')]({'where':{'id':_0x2154a3[_0x359b('0x63')]['id']}})[_0x359b('0x22')](handleEntityNotFound(_0x37eddb,null))['then'](function(_0x19595e){if(_0x19595e){_0x401db2=_0x19595e;_0x1a3d51[_0x359b('0x4d')]=_['keys'](db[_0x359b('0xb8')][_0x359b('0x49')]);_0x1a3d51[_0x359b('0x50')]=_[_0x359b('0x64')](_0x2154a3[_0x359b('0x50')]);_0x1a3d51[_0x359b('0x51')]=_[_0x359b('0x52')](_0x1a3d51['model'],_0x1a3d51[_0x359b('0x50')]);_0x1394cb['attributes']=_['intersection'](_0x1a3d51[_0x359b('0x4d')],qs[_0x359b('0x54')](_0x2154a3[_0x359b('0x50')]['fields']));_0x1394cb[_0x359b('0x53')]=_0x1394cb[_0x359b('0x53')][_0x359b('0x66')]?_0x1394cb[_0x359b('0x53')]:_0x1a3d51['model'];_0x1394cb[_0x359b('0x57')]=qs['sort'](_0x2154a3[_0x359b('0x50')][_0x359b('0x58')]);_0x1394cb[_0x359b('0x59')]=qs[_0x359b('0x51')](_[_0x359b('0xb9')](_0x2154a3[_0x359b('0x50')],_0x1a3d51[_0x359b('0x51')]));if(_0x2154a3[_0x359b('0x50')][_0x359b('0x3d')]){_0x1394cb[_0x359b('0x59')]=_[_0x359b('0x5a')](_0x1394cb['where'],{'$or':_[_0x359b('0x3f')](_0x1394cb['attributes'],function(_0x21afcd){var _0x3ecdf8={};_0x3ecdf8[_0x21afcd]={'$like':'%'+_0x2154a3['query'][_0x359b('0x3d')]+'%'};return _0x3ecdf8;})});}_0x1394cb=_['merge']({},_0x1394cb,_0x2154a3['options']);return _0x401db2['getContacts'](_0x1394cb);}})[_0x359b('0x22')](function(_0x41db78){if(_0x41db78){_0x1459f0=_0x41db78[_0x359b('0x66')];if(_0x2154a3['query'][_0x359b('0x55')]('includeAll')){_0x1394cb[_0x359b('0x60')]=[{'model':db['CmList'],'as':_0x359b('0xba'),'required':![]},{'model':db[_0x359b('0xbb')],'as':_0x359b('0xbc'),'attributes':['id',_0x359b('0x44'),'color'],'where':_0x2154a3['query'][_0x359b('0xbd')]?{'id':_0x2154a3[_0x359b('0x50')][_0x359b('0xbd')]}:undefined,'required':_0x2154a3[_0x359b('0x50')][_0x359b('0xbd')]?!![]:![]}];}if(!_0x2154a3[_0x359b('0x50')][_0x359b('0x55')](_0x359b('0x56'))){_0x1394cb['limit']=qs[_0x359b('0x33')](_0x2154a3[_0x359b('0x50')]['limit']);_0x1394cb['offset']=qs[_0x359b('0x32')](_0x2154a3[_0x359b('0x50')][_0x359b('0x32')]);}return _0x401db2['getContacts'](_0x1394cb);}})[_0x359b('0x22')](function(_0x3fed19){if(_0x3fed19){return _0x3fed19?{'count':_0x1459f0,'rows':_0x3fed19}:null;}})['then'](respondWithResult(_0x37eddb,null))[_0x359b('0x2c')](handleError(_0x37eddb,null));};exports['getQueues']=function(_0x3b329d,_0x46c7c8,_0x28805f){var _0x161b6c;var _0x5331d1;var _0x34b11c={};var _0x5a6f9c;return db[_0x359b('0x48')][_0x359b('0xb7')]({'where':{'id':_0x3b329d[_0x359b('0x63')]['id']},'attributes':['id','name',_0x359b('0x42')]})[_0x359b('0x22')](handleEntityNotFound(_0x46c7c8,null))[_0x359b('0x22')](function(_0x3129a5){if(!utils['isValidChannel'](_0x3b329d[_0x359b('0x50')][_0x359b('0x96')])){throw new db[(_0x359b('0x1e'))][(_0x359b('0x1f'))](_0x359b('0x9b'));}_0x161b6c=_0x3129a5;var _0x198b8b={};_0x198b8b[_0x359b('0x4d')]=_[_0x359b('0x64')](db[_['capitalize'](_0x3b329d[_0x359b('0x50')]['channel'])+_0x359b('0xbe')]['rawAttributes']);_0x198b8b[_0x359b('0x50')]=_[_0x359b('0x64')](_0x3b329d[_0x359b('0x50')]);_0x198b8b[_0x359b('0x51')]=_[_0x359b('0x52')](_0x198b8b['model'],_0x198b8b[_0x359b('0x50')]);_0x34b11c[_0x359b('0x53')]=_['intersection'](_0x198b8b[_0x359b('0x4d')],qs[_0x359b('0x54')](_0x3b329d[_0x359b('0x50')]['fields']));_0x34b11c[_0x359b('0x53')]=_0x34b11c[_0x359b('0x53')][_0x359b('0x66')]?_0x34b11c[_0x359b('0x53')]:_0x198b8b[_0x359b('0x4d')];_0x34b11c[_0x359b('0x57')]=qs[_0x359b('0x58')](_0x3b329d[_0x359b('0x50')]['sort']);_0x34b11c[_0x359b('0x59')]=qs[_0x359b('0x51')](_[_0x359b('0xb9')](_0x3b329d[_0x359b('0x50')],_0x198b8b[_0x359b('0x51')]));if(_0x3b329d['query'][_0x359b('0x3d')]){_0x34b11c[_0x359b('0x59')]=_[_0x359b('0x5a')](_0x34b11c[_0x359b('0x59')],{'$or':_[_0x359b('0x3f')](_0x34b11c[_0x359b('0x53')],function(_0x5dbf0c){var _0x28e8fe={};_0x28e8fe[_0x5dbf0c]={'$like':'%'+_0x3b329d[_0x359b('0x50')][_0x359b('0x3d')]+'%'};return _0x28e8fe;})});}_0x34b11c=_[_0x359b('0x5a')]({},_0x34b11c,_0x3b329d[_0x359b('0x5e')]);switch(_0x161b6c[_0x359b('0x42')]){case _0x359b('0x6d'):return db[_[_0x359b('0x9d')](_0x3b329d[_0x359b('0x50')][_0x359b('0x96')])+_0x359b('0xbe')][_0x359b('0xa3')](_0x34b11c);case _0x359b('0x3a'):case _0x359b('0x6c'):return _0x161b6c[_0x359b('0x38')+_[_0x359b('0x9d')](_0x3b329d[_0x359b('0x50')][_0x359b('0x96')])+_0x359b('0xa9')](_0x34b11c);default:throw new db['Sequelize'][(_0x359b('0x1f'))](_0x359b('0xbf'));}})[_0x359b('0x22')](function(_0x2b9845){_0x5a6f9c=_0x2b9845[_0x359b('0x66')];if(!_0x3b329d[_0x359b('0x50')][_0x359b('0x55')]('nolimit')){_0x34b11c[_0x359b('0x33')]=qs['limit'](_0x3b329d['query'][_0x359b('0x33')]);_0x34b11c['offset']=qs[_0x359b('0x32')](_0x3b329d[_0x359b('0x50')]['offset']);}switch(_0x161b6c[_0x359b('0x42')]){case'admin':return db[_[_0x359b('0x9d')](_0x3b329d[_0x359b('0x50')][_0x359b('0x96')])+'Queue']['findAll'](_0x34b11c);case _0x359b('0x3a'):case _0x359b('0x6c'):return _0x161b6c['get'+_[_0x359b('0x9d')](_0x3b329d[_0x359b('0x50')]['channel'])+_0x359b('0xa9')](_0x34b11c);}})[_0x359b('0x22')](function(_0x1770fd){return{'count':_0x5a6f9c,'rows':_0x1770fd};})[_0x359b('0x22')](respondWithResult(_0x46c7c8,null))[_0x359b('0x2c')](handleError(_0x46c7c8,null));};exports[_0x359b('0xc0')]=function(_0x653f,_0x26f657,_0x1575e0){var _0x4666e7={};var _0x212c03={};var _0x199e79;var _0x3e4832;return db[_0x359b('0x48')][_0x359b('0xb7')]({'where':{'id':_0x653f[_0x359b('0x63')]['id']}})[_0x359b('0x22')](handleEntityNotFound(_0x26f657,null))[_0x359b('0x22')](function(_0x4befb9){if(_0x4befb9){_0x199e79=_0x4befb9;_0x212c03[_0x359b('0x4d')]=_[_0x359b('0x64')](db[_0x359b('0xab')][_0x359b('0x49')]);_0x212c03['query']=_[_0x359b('0x64')](_0x653f[_0x359b('0x50')]);_0x212c03[_0x359b('0x51')]=_[_0x359b('0x52')](_0x212c03[_0x359b('0x4d')],_0x212c03[_0x359b('0x50')]);_0x4666e7[_0x359b('0x53')]=_[_0x359b('0x52')](_0x212c03[_0x359b('0x4d')],qs[_0x359b('0x54')](_0x653f[_0x359b('0x50')][_0x359b('0x54')]));_0x4666e7[_0x359b('0x53')]=_0x4666e7[_0x359b('0x53')]['length']?_0x4666e7[_0x359b('0x53')]:_0x212c03[_0x359b('0x4d')];_0x4666e7['order']=qs[_0x359b('0x58')](_0x653f[_0x359b('0x50')][_0x359b('0x58')]);_0x4666e7[_0x359b('0x59')]=qs[_0x359b('0x51')](_['pick'](_0x653f[_0x359b('0x50')],_0x212c03[_0x359b('0x51')]));if(_0x653f[_0x359b('0x50')][_0x359b('0x3d')]){_0x4666e7[_0x359b('0x59')]=_[_0x359b('0x5a')](_0x4666e7['where'],{'$or':_[_0x359b('0x3f')](_0x4666e7[_0x359b('0x53')],function(_0x48bff5){var _0x3ec62c={};_0x3ec62c[_0x48bff5]={'$like':'%'+_0x653f[_0x359b('0x50')][_0x359b('0x3d')]+'%'};return _0x3ec62c;})});}_0x4666e7=_[_0x359b('0x5a')]({},_0x4666e7,_0x653f[_0x359b('0x5e')]);return _0x199e79['getVoiceQueuesRt'](_0x4666e7);}})['then'](function(_0x14bb76){if(_0x14bb76){_0x3e4832=_0x14bb76[_0x359b('0x66')];if(!_0x653f[_0x359b('0x50')]['hasOwnProperty'](_0x359b('0x56'))){_0x4666e7[_0x359b('0x33')]=qs[_0x359b('0x33')](_0x653f['query'][_0x359b('0x33')]);_0x4666e7['offset']=qs[_0x359b('0x32')](_0x653f[_0x359b('0x50')]['offset']);}return _0x199e79[_0x359b('0xc0')](_0x4666e7);}})[_0x359b('0x22')](function(_0x1c7b66){if(_0x1c7b66){return _0x1c7b66?{'count':_0x3e4832,'rows':_0x1c7b66}:null;}})[_0x359b('0x22')](respondWithResult(_0x26f657,null))[_0x359b('0x2c')](handleError(_0x26f657,null));};exports[_0x359b('0xc1')]=function(_0x51a1e3,_0x3601b8,_0x89ea85){var _0xb75479={};var _0x40261e={};var _0x38c82d;var _0x36b7bb;return db[_0x359b('0x48')][_0x359b('0xb7')]({'where':{'id':_0x51a1e3[_0x359b('0x63')]['id']}})[_0x359b('0x22')](handleEntityNotFound(_0x3601b8,null))[_0x359b('0x22')](function(_0x5d79b9){if(_0x5d79b9){_0x38c82d=_0x5d79b9;_0x40261e[_0x359b('0x4d')]=_['keys'](db[_0x359b('0xc2')]['rawAttributes']);_0x40261e[_0x359b('0x50')]=_[_0x359b('0x64')](_0x51a1e3[_0x359b('0x50')]);_0x40261e['filters']=_[_0x359b('0x52')](_0x40261e[_0x359b('0x4d')],_0x40261e[_0x359b('0x50')]);_0xb75479[_0x359b('0x53')]=_['intersection'](_0x40261e['model'],qs[_0x359b('0x54')](_0x51a1e3['query']['fields']));_0xb75479[_0x359b('0x53')]=_0xb75479['attributes'][_0x359b('0x66')]?_0xb75479[_0x359b('0x53')]:_0x40261e[_0x359b('0x4d')];_0xb75479[_0x359b('0x57')]=qs[_0x359b('0x58')](_0x51a1e3[_0x359b('0x50')][_0x359b('0x58')]);_0xb75479[_0x359b('0x59')]=qs['filters'](_[_0x359b('0xb9')](_0x51a1e3[_0x359b('0x50')],_0x40261e['filters']));if(_0x51a1e3[_0x359b('0x50')][_0x359b('0x3d')]){_0xb75479[_0x359b('0x59')]=_[_0x359b('0x5a')](_0xb75479[_0x359b('0x59')],{'$or':_[_0x359b('0x3f')](_0xb75479[_0x359b('0x53')],function(_0x2715d2){var _0x37a7c5={};_0x37a7c5[_0x2715d2]={'$like':'%'+_0x51a1e3[_0x359b('0x50')][_0x359b('0x3d')]+'%'};return _0x37a7c5;})});}_0xb75479=_[_0x359b('0x5a')]({},_0xb75479,_0x51a1e3[_0x359b('0x5e')]);return _0x38c82d['getGroups'](_0xb75479);}})[_0x359b('0x22')](function(_0x1489e7){if(_0x1489e7){_0x36b7bb=_0x1489e7[_0x359b('0x66')];if(!_0x51a1e3[_0x359b('0x50')]['hasOwnProperty'](_0x359b('0x56'))){_0xb75479[_0x359b('0x33')]=qs[_0x359b('0x33')](_0x51a1e3[_0x359b('0x50')][_0x359b('0x33')]);_0xb75479['offset']=qs[_0x359b('0x32')](_0x51a1e3[_0x359b('0x50')][_0x359b('0x32')]);}return _0x38c82d['getGroups'](_0xb75479);}})[_0x359b('0x22')](function(_0x5e5cb7){if(_0x5e5cb7){return _0x5e5cb7?{'count':_0x36b7bb,'rows':_0x5e5cb7}:null;}})['then'](respondWithResult(_0x3601b8,null))[_0x359b('0x2c')](handleError(_0x3601b8,null));};exports[_0x359b('0xc3')]=function(_0x4f63d7,_0x182745,_0x2b66cf){var _0x570948={'raw':!![],'where':{}};var _0x587f2e={};var _0x332ece={'count':0x0,'rows':[]};return db[_0x359b('0x48')]['findOne']({'where':{'id':_0x4f63d7[_0x359b('0x63')]['id']}})[_0x359b('0x22')](handleEntityNotFound(_0x182745,null))[_0x359b('0x22')](function(_0x143a7c){if(_0x143a7c){_0x587f2e[_0x359b('0x4d')]=_[_0x359b('0x64')](db[_0x359b('0xc4')]['rawAttributes']);_0x587f2e[_0x359b('0x50')]=_[_0x359b('0x64')](_0x4f63d7[_0x359b('0x50')]);_0x587f2e['filters']=_['intersection'](_0x587f2e['model'],_0x587f2e[_0x359b('0x50')]);_0x570948[_0x359b('0x53')]=_['intersection'](_0x587f2e['model'],qs[_0x359b('0x54')](_0x4f63d7[_0x359b('0x50')][_0x359b('0x54')]));_0x570948[_0x359b('0x53')]=_0x570948[_0x359b('0x53')][_0x359b('0x66')]?_0x570948['attributes']:_0x587f2e[_0x359b('0x4d')];if(!_0x4f63d7[_0x359b('0x50')][_0x359b('0x55')]('nolimit')){_0x570948[_0x359b('0x33')]=qs['limit'](_0x4f63d7[_0x359b('0x50')][_0x359b('0x33')]);_0x570948[_0x359b('0x32')]=qs[_0x359b('0x32')](_0x4f63d7[_0x359b('0x50')]['offset']);}_0x570948[_0x359b('0x57')]=qs[_0x359b('0x58')](_0x4f63d7[_0x359b('0x50')]['sort']);_0x570948[_0x359b('0x59')]=qs[_0x359b('0x51')](_['pick'](_0x4f63d7[_0x359b('0x50')],_0x587f2e[_0x359b('0x51')]));_0x570948[_0x359b('0x59')]['UserId']=_0x143a7c['id'];if(_0x4f63d7[_0x359b('0x50')][_0x359b('0x3d')]){_0x570948[_0x359b('0x59')]=_['merge'](_0x570948[_0x359b('0x59')],{'$or':_[_0x359b('0x3f')](_0x570948[_0x359b('0x53')],function(_0x45bf61){var _0x32ffa7={};_0x32ffa7[_0x45bf61]={'$like':'%'+_0x4f63d7[_0x359b('0x50')][_0x359b('0x3d')]+'%'};return _0x32ffa7;})});}_0x570948=_[_0x359b('0x5a')]({},_0x570948,_0x4f63d7[_0x359b('0x5e')]);return db[_0x359b('0xc4')][_0x359b('0x31')]({'where':_0x570948[_0x359b('0x59')]})['then'](function(_0x542e67){_0x332ece[_0x359b('0x31')]=_0x542e67;if(_0x4f63d7[_0x359b('0x50')][_0x359b('0x5f')]){_0x570948['include']=[{'all':!![]}];}return db[_0x359b('0xc4')][_0x359b('0xa3')](_0x570948);})[_0x359b('0x22')](function(_0x1952b1){_0x332ece['rows']=_0x1952b1;return _0x332ece;});}})['then'](respondWithFilteredResult(_0x182745,_0x570948))[_0x359b('0x2c')](handleError(_0x182745,null));};exports['getScreenRecordings']=function(_0x4cf02c,_0x2911fb,_0x1f084c){var _0x1f81e6={'raw':!![],'where':{}};var _0x2871b9={};var _0x1d6dfa={'count':0x0,'rows':[]};return db[_0x359b('0x48')][_0x359b('0xb7')]({'where':{'id':_0x4cf02c[_0x359b('0x63')]['id']}})[_0x359b('0x22')](handleEntityNotFound(_0x2911fb,null))['then'](function(_0x355786){if(_0x355786){_0x2871b9['model']=_['keys'](db['ScreenRecording'][_0x359b('0x49')]);_0x2871b9[_0x359b('0x50')]=_[_0x359b('0x64')](_0x4cf02c[_0x359b('0x50')]);_0x2871b9[_0x359b('0x51')]=_[_0x359b('0x52')](_0x2871b9[_0x359b('0x4d')],_0x2871b9['query']);_0x1f81e6[_0x359b('0x53')]=_[_0x359b('0x52')](_0x2871b9[_0x359b('0x4d')],qs['fields'](_0x4cf02c[_0x359b('0x50')]['fields']));_0x1f81e6[_0x359b('0x53')]=_0x1f81e6[_0x359b('0x53')]['length']?_0x1f81e6['attributes']:_0x2871b9[_0x359b('0x4d')];if(!_0x4cf02c['query'][_0x359b('0x55')](_0x359b('0x56'))){_0x1f81e6[_0x359b('0x33')]=qs[_0x359b('0x33')](_0x4cf02c[_0x359b('0x50')][_0x359b('0x33')]);_0x1f81e6[_0x359b('0x32')]=qs[_0x359b('0x32')](_0x4cf02c[_0x359b('0x50')][_0x359b('0x32')]);}_0x1f81e6['order']=qs[_0x359b('0x58')](_0x4cf02c[_0x359b('0x50')][_0x359b('0x58')]);_0x1f81e6[_0x359b('0x59')]=qs[_0x359b('0x51')](_[_0x359b('0xb9')](_0x4cf02c['query'],_0x2871b9[_0x359b('0x51')]));_0x1f81e6[_0x359b('0x59')][_0x359b('0xc5')]=_0x355786['id'];if(_0x4cf02c['query'][_0x359b('0x3d')]){_0x1f81e6[_0x359b('0x59')]=_[_0x359b('0x5a')](_0x1f81e6['where'],{'$or':_[_0x359b('0x3f')](_0x1f81e6[_0x359b('0x53')],function(_0x1c835a){var _0x5a688c={};_0x5a688c[_0x1c835a]={'$like':'%'+_0x4cf02c[_0x359b('0x50')][_0x359b('0x3d')]+'%'};return _0x5a688c;})});}_0x1f81e6=_[_0x359b('0x5a')]({},_0x1f81e6,_0x4cf02c[_0x359b('0x5e')]);return db['ScreenRecording'][_0x359b('0x31')]({'where':_0x1f81e6[_0x359b('0x59')]})[_0x359b('0x22')](function(_0x486207){_0x1d6dfa['count']=_0x486207;if(_0x4cf02c[_0x359b('0x50')][_0x359b('0x5f')]){_0x1f81e6[_0x359b('0x60')]=[{'all':!![]}];}return db[_0x359b('0xc6')]['findAll'](_0x1f81e6);})[_0x359b('0x22')](function(_0xbaab08){_0x1d6dfa[_0x359b('0x61')]=_0xbaab08;return _0x1d6dfa;});}})[_0x359b('0x22')](respondWithFilteredResult(_0x2911fb,_0x1f81e6))[_0x359b('0x2c')](handleError(_0x2911fb,null));};exports['getChatInteractions']=function(_0x48a4f9,_0x40a651,_0x515077){var _0x806371={};var _0x988740={};var _0x109907;var _0x14bff9;return db[_0x359b('0x48')][_0x359b('0xb7')]({'where':{'id':_0x48a4f9[_0x359b('0x63')]['id']}})[_0x359b('0x22')](handleEntityNotFound(_0x40a651,null))[_0x359b('0x22')](function(_0x56436b){if(_0x56436b){_0x109907=_0x56436b;_0x988740[_0x359b('0x4d')]=_[_0x359b('0x64')](db[_0x359b('0xc7')][_0x359b('0x49')]);_0x988740[_0x359b('0x50')]=_['keys'](_0x48a4f9[_0x359b('0x50')]);_0x988740[_0x359b('0x51')]=_[_0x359b('0x52')](_0x988740[_0x359b('0x4d')],_0x988740['query']);_0x806371[_0x359b('0x53')]=_['intersection'](_0x988740['model'],qs[_0x359b('0x54')](_0x48a4f9['query'][_0x359b('0x54')]));_0x806371[_0x359b('0x53')]=_0x806371['attributes']['length']?_0x806371['attributes']:_0x988740[_0x359b('0x4d')];_0x806371[_0x359b('0x57')]=qs['sort'](_0x48a4f9['query'][_0x359b('0x58')]);_0x806371['where']=qs[_0x359b('0x51')](_[_0x359b('0xb9')](_0x48a4f9[_0x359b('0x50')],_0x988740[_0x359b('0x51')]));if(_0x48a4f9['query'][_0x359b('0x3d')]){_0x806371['where']=_[_0x359b('0x5a')](_0x806371[_0x359b('0x59')],{'$or':_['map'](_0x806371[_0x359b('0x53')],function(_0x20fc4b){var _0x4d19fe={};_0x4d19fe[_0x20fc4b]={'$like':'%'+_0x48a4f9[_0x359b('0x50')]['filter']+'%'};return _0x4d19fe;})});}_0x806371=_[_0x359b('0x5a')]({},_0x806371,_0x48a4f9[_0x359b('0x5e')]);return _0x109907[_0x359b('0xc8')](_0x806371);}})[_0x359b('0x22')](function(_0x1989b2){if(_0x1989b2){_0x14bff9=_0x1989b2[_0x359b('0x66')];if(!_0x48a4f9['query'][_0x359b('0x55')](_0x359b('0x56'))){_0x806371['limit']=qs[_0x359b('0x33')](_0x48a4f9[_0x359b('0x50')][_0x359b('0x33')]);_0x806371[_0x359b('0x32')]=qs[_0x359b('0x32')](_0x48a4f9['query'][_0x359b('0x32')]);}return _0x109907[_0x359b('0xc8')](_0x806371);}})[_0x359b('0x22')](function(_0x3067b1){if(_0x3067b1){return _0x3067b1?{'count':_0x14bff9,'rows':_0x3067b1}:null;}})[_0x359b('0x22')](respondWithResult(_0x40a651,null))[_0x359b('0x2c')](handleError(_0x40a651,null));};exports[_0x359b('0xc9')]=function(_0x46537b,_0x4c81f8,_0x502b71){var _0x236593={};var _0x463133={};var _0x318807;var _0x122222;return db[_0x359b('0x48')][_0x359b('0xb7')]({'where':{'id':_0x46537b[_0x359b('0x63')]['id']}})[_0x359b('0x22')](handleEntityNotFound(_0x4c81f8,null))[_0x359b('0x22')](function(_0xb7623f){if(_0xb7623f){_0x318807=_0xb7623f;_0x463133[_0x359b('0x4d')]=_[_0x359b('0x64')](db[_0x359b('0xca')][_0x359b('0x49')]);_0x463133[_0x359b('0x50')]=_[_0x359b('0x64')](_0x46537b[_0x359b('0x50')]);_0x463133['filters']=_[_0x359b('0x52')](_0x463133[_0x359b('0x4d')],_0x463133['query']);_0x236593[_0x359b('0x53')]=_[_0x359b('0x52')](_0x463133[_0x359b('0x4d')],qs['fields'](_0x46537b[_0x359b('0x50')][_0x359b('0x54')]));_0x236593['attributes']=_0x236593['attributes'][_0x359b('0x66')]?_0x236593['attributes']:_0x463133[_0x359b('0x4d')];_0x236593[_0x359b('0x57')]=qs[_0x359b('0x58')](_0x46537b[_0x359b('0x50')]['sort']);_0x236593[_0x359b('0x59')]=qs[_0x359b('0x51')](_[_0x359b('0xb9')](_0x46537b['query'],_0x463133[_0x359b('0x51')]));if(_0x46537b[_0x359b('0x50')][_0x359b('0x3d')]){_0x236593[_0x359b('0x59')]=_[_0x359b('0x5a')](_0x236593[_0x359b('0x59')],{'$or':_[_0x359b('0x3f')](_0x236593[_0x359b('0x53')],function(_0x1bd43d){var _0x6eee78={};_0x6eee78[_0x1bd43d]={'$like':'%'+_0x46537b[_0x359b('0x50')][_0x359b('0x3d')]+'%'};return _0x6eee78;})});}_0x236593=_[_0x359b('0x5a')]({},_0x236593,_0x46537b[_0x359b('0x5e')]);return _0x318807[_0x359b('0xc9')](_0x236593);}})[_0x359b('0x22')](function(_0xd2e9bc){if(_0xd2e9bc){_0x122222=_0xd2e9bc[_0x359b('0x66')];if(!_0x46537b[_0x359b('0x50')][_0x359b('0x55')](_0x359b('0x56'))){_0x236593[_0x359b('0x33')]=qs[_0x359b('0x33')](_0x46537b[_0x359b('0x50')][_0x359b('0x33')]);_0x236593[_0x359b('0x32')]=qs[_0x359b('0x32')](_0x46537b['query'][_0x359b('0x32')]);}return _0x318807[_0x359b('0xc9')](_0x236593);}})['then'](function(_0x3bea97){if(_0x3bea97){return _0x3bea97?{'count':_0x122222,'rows':_0x3bea97}:null;}})[_0x359b('0x22')](respondWithResult(_0x4c81f8,null))['catch'](handleError(_0x4c81f8,null));};exports[_0x359b('0xcb')]=function(_0x193bb3,_0x580728,_0x12d5d8){var _0xc4c8e0={'raw':!![],'where':{}};var _0x5388d7={};var _0x5dabfb={'count':0x0,'rows':[]};return db[_0x359b('0x48')]['findOne']({'where':{'id':_0x193bb3[_0x359b('0x63')]['id']}})[_0x359b('0x22')](handleEntityNotFound(_0x580728,null))[_0x359b('0x22')](function(_0x538746){if(_0x538746){_0x5388d7[_0x359b('0x4d')]=_[_0x359b('0x64')](db['MailInteraction'][_0x359b('0x49')]);_0x5388d7['query']=_[_0x359b('0x64')](_0x193bb3[_0x359b('0x50')]);_0x5388d7[_0x359b('0x51')]=_['intersection'](_0x5388d7[_0x359b('0x4d')],_0x5388d7[_0x359b('0x50')]);_0xc4c8e0[_0x359b('0x53')]=_['intersection'](_0x5388d7['model'],qs[_0x359b('0x54')](_0x193bb3['query'][_0x359b('0x54')]));_0xc4c8e0[_0x359b('0x53')]=_0xc4c8e0[_0x359b('0x53')][_0x359b('0x66')]?_0xc4c8e0[_0x359b('0x53')]:_0x5388d7[_0x359b('0x4d')];if(!_0x193bb3[_0x359b('0x50')]['hasOwnProperty'](_0x359b('0x56'))){_0xc4c8e0[_0x359b('0x33')]=qs[_0x359b('0x33')](_0x193bb3['query'][_0x359b('0x33')]);_0xc4c8e0['offset']=qs[_0x359b('0x32')](_0x193bb3[_0x359b('0x50')]['offset']);}_0xc4c8e0[_0x359b('0x57')]=qs[_0x359b('0x58')](_0x193bb3['query']['sort']);_0xc4c8e0[_0x359b('0x59')]=qs[_0x359b('0x51')](_[_0x359b('0xb9')](_0x193bb3[_0x359b('0x50')],_0x5388d7[_0x359b('0x51')]));_0xc4c8e0[_0x359b('0x59')]['UserId']=_0x538746['id'];if(_0x193bb3[_0x359b('0x50')][_0x359b('0x3d')]){_0xc4c8e0[_0x359b('0x59')]=_[_0x359b('0x5a')](_0xc4c8e0[_0x359b('0x59')],{'$or':_['map'](_0xc4c8e0[_0x359b('0x53')],function(_0x38bd09){var _0x414150={};_0x414150[_0x38bd09]={'$like':'%'+_0x193bb3[_0x359b('0x50')][_0x359b('0x3d')]+'%'};return _0x414150;})});}_0xc4c8e0=_['merge']({},_0xc4c8e0,_0x193bb3[_0x359b('0x5e')]);return db[_0x359b('0xcc')]['count']({'where':_0xc4c8e0[_0x359b('0x59')]})[_0x359b('0x22')](function(_0x51e365){_0x5dabfb['count']=_0x51e365;if(_0x193bb3[_0x359b('0x50')][_0x359b('0x5f')]){_0xc4c8e0['include']=[{'all':!![]}];}return db[_0x359b('0xcc')][_0x359b('0xa3')](_0xc4c8e0);})[_0x359b('0x22')](function(_0x375f00){_0x5dabfb[_0x359b('0x61')]=_0x375f00;return _0x5dabfb;});}})[_0x359b('0x22')](respondWithFilteredResult(_0x580728,_0xc4c8e0))[_0x359b('0x2c')](handleError(_0x580728,null));};exports['getSmsInteractions']=function(_0x43974c,_0x34bacc,_0x5ead08){var _0x3234bc={};var _0x2c9af4={};var _0x3452a6;var _0x5a9a1e;return db[_0x359b('0x48')]['findOne']({'where':{'id':_0x43974c['params']['id']}})[_0x359b('0x22')](handleEntityNotFound(_0x34bacc,null))[_0x359b('0x22')](function(_0x4721e5){if(_0x4721e5){_0x3452a6=_0x4721e5;_0x2c9af4[_0x359b('0x4d')]=_[_0x359b('0x64')](db['SmsInteraction']['rawAttributes']);_0x2c9af4['query']=_[_0x359b('0x64')](_0x43974c[_0x359b('0x50')]);_0x2c9af4['filters']=_[_0x359b('0x52')](_0x2c9af4[_0x359b('0x4d')],_0x2c9af4[_0x359b('0x50')]);_0x3234bc[_0x359b('0x53')]=_['intersection'](_0x2c9af4[_0x359b('0x4d')],qs[_0x359b('0x54')](_0x43974c[_0x359b('0x50')]['fields']));_0x3234bc[_0x359b('0x53')]=_0x3234bc['attributes'][_0x359b('0x66')]?_0x3234bc[_0x359b('0x53')]:_0x2c9af4[_0x359b('0x4d')];_0x3234bc[_0x359b('0x57')]=qs[_0x359b('0x58')](_0x43974c['query'][_0x359b('0x58')]);_0x3234bc[_0x359b('0x59')]=qs[_0x359b('0x51')](_['pick'](_0x43974c['query'],_0x2c9af4[_0x359b('0x51')]));if(_0x43974c[_0x359b('0x50')][_0x359b('0x3d')]){_0x3234bc[_0x359b('0x59')]=_[_0x359b('0x5a')](_0x3234bc['where'],{'$or':_[_0x359b('0x3f')](_0x3234bc[_0x359b('0x53')],function(_0x20b8dc){var _0x218854={};_0x218854[_0x20b8dc]={'$like':'%'+_0x43974c[_0x359b('0x50')][_0x359b('0x3d')]+'%'};return _0x218854;})});}_0x3234bc=_[_0x359b('0x5a')]({},_0x3234bc,_0x43974c[_0x359b('0x5e')]);return _0x3452a6[_0x359b('0xcd')](_0x3234bc);}})[_0x359b('0x22')](function(_0x583a62){if(_0x583a62){_0x5a9a1e=_0x583a62[_0x359b('0x66')];if(!_0x43974c['query'][_0x359b('0x55')]('nolimit')){_0x3234bc[_0x359b('0x33')]=qs[_0x359b('0x33')](_0x43974c[_0x359b('0x50')]['limit']);_0x3234bc[_0x359b('0x32')]=qs[_0x359b('0x32')](_0x43974c[_0x359b('0x50')][_0x359b('0x32')]);}return _0x3452a6['getSmsInteractions'](_0x3234bc);}})['then'](function(_0x137ed0){if(_0x137ed0){return _0x137ed0?{'count':_0x5a9a1e,'rows':_0x137ed0}:null;}})[_0x359b('0x22')](respondWithResult(_0x34bacc,null))['catch'](handleError(_0x34bacc,null));};exports[_0x359b('0xce')]=function(_0x5c038e,_0x7dd696,_0x1025ee){var _0x330e5c={};var _0x4b1338={};var _0x52d754;var _0x341613;return db[_0x359b('0x48')]['findOne']({'where':{'id':_0x5c038e[_0x359b('0x63')]['id']}})['then'](handleEntityNotFound(_0x7dd696,null))[_0x359b('0x22')](function(_0x15def4){if(_0x15def4){_0x52d754=_0x15def4;_0x4b1338[_0x359b('0x4d')]=_['keys'](db[_0x359b('0xcf')][_0x359b('0x49')]);_0x4b1338['query']=_[_0x359b('0x64')](_0x5c038e[_0x359b('0x50')]);_0x4b1338[_0x359b('0x51')]=_[_0x359b('0x52')](_0x4b1338[_0x359b('0x4d')],_0x4b1338[_0x359b('0x50')]);_0x330e5c[_0x359b('0x53')]=_[_0x359b('0x52')](_0x4b1338[_0x359b('0x4d')],qs['fields'](_0x5c038e[_0x359b('0x50')][_0x359b('0x54')]));_0x330e5c['attributes']=_0x330e5c['attributes'][_0x359b('0x66')]?_0x330e5c[_0x359b('0x53')]:_0x4b1338['model'];_0x330e5c[_0x359b('0x57')]=qs[_0x359b('0x58')](_0x5c038e['query'][_0x359b('0x58')]);_0x330e5c['where']=qs[_0x359b('0x51')](_[_0x359b('0xb9')](_0x5c038e[_0x359b('0x50')],_0x4b1338[_0x359b('0x51')]));if(_0x5c038e[_0x359b('0x50')][_0x359b('0x3d')]){_0x330e5c[_0x359b('0x59')]=_[_0x359b('0x5a')](_0x330e5c[_0x359b('0x59')],{'$or':_[_0x359b('0x3f')](_0x330e5c['attributes'],function(_0xe7fc69){var _0x240d67={};_0x240d67[_0xe7fc69]={'$like':'%'+_0x5c038e['query'][_0x359b('0x3d')]+'%'};return _0x240d67;})});}_0x330e5c=_[_0x359b('0x5a')]({},_0x330e5c,_0x5c038e[_0x359b('0x5e')]);return _0x52d754[_0x359b('0xce')](_0x330e5c);}})['then'](function(_0x24d1c9){if(_0x24d1c9){_0x341613=_0x24d1c9[_0x359b('0x66')];if(!_0x5c038e['query']['hasOwnProperty']('nolimit')){_0x330e5c['limit']=qs[_0x359b('0x33')](_0x5c038e[_0x359b('0x50')][_0x359b('0x33')]);_0x330e5c[_0x359b('0x32')]=qs[_0x359b('0x32')](_0x5c038e[_0x359b('0x50')][_0x359b('0x32')]);}return _0x52d754[_0x359b('0xce')](_0x330e5c);}})[_0x359b('0x22')](function(_0x4d7c8a){if(_0x4d7c8a){return _0x4d7c8a?{'count':_0x341613,'rows':_0x4d7c8a}:null;}})[_0x359b('0x22')](respondWithResult(_0x7dd696,null))['catch'](handleError(_0x7dd696,null));};exports[_0x359b('0xd0')]=function(_0x1af573,_0x18674e,_0x21e82f){var _0x52ed39={};var _0xa6ca65={};var _0x3942fa;var _0x120dc;return db['User'][_0x359b('0xb7')]({'where':{'id':_0x1af573['params']['id']}})[_0x359b('0x22')](handleEntityNotFound(_0x18674e,null))['then'](function(_0x2ffabd){if(_0x2ffabd){_0x3942fa=_0x2ffabd;_0xa6ca65[_0x359b('0x4d')]=_[_0x359b('0x64')](db[_0x359b('0xd1')][_0x359b('0x49')]);_0xa6ca65[_0x359b('0x50')]=_[_0x359b('0x64')](_0x1af573[_0x359b('0x50')]);_0xa6ca65[_0x359b('0x51')]=_[_0x359b('0x52')](_0xa6ca65[_0x359b('0x4d')],_0xa6ca65[_0x359b('0x50')]);_0x52ed39['attributes']=_[_0x359b('0x52')](_0xa6ca65[_0x359b('0x4d')],qs[_0x359b('0x54')](_0x1af573[_0x359b('0x50')][_0x359b('0x54')]));_0x52ed39[_0x359b('0x53')]=_0x52ed39['attributes'][_0x359b('0x66')]?_0x52ed39['attributes']:_0xa6ca65['model'];_0x52ed39[_0x359b('0x57')]=qs[_0x359b('0x58')](_0x1af573[_0x359b('0x50')][_0x359b('0x58')]);_0x52ed39[_0x359b('0x59')]=qs['filters'](_[_0x359b('0xb9')](_0x1af573[_0x359b('0x50')],_0xa6ca65[_0x359b('0x51')]));if(_0x1af573[_0x359b('0x50')][_0x359b('0x3d')]){_0x52ed39['where']=_[_0x359b('0x5a')](_0x52ed39[_0x359b('0x59')],{'$or':_[_0x359b('0x3f')](_0x52ed39[_0x359b('0x53')],function(_0x6b2bbf){var _0x3729bc={};_0x3729bc[_0x6b2bbf]={'$like':'%'+_0x1af573[_0x359b('0x50')][_0x359b('0x3d')]+'%'};return _0x3729bc;})});}_0x52ed39=_['merge']({},_0x52ed39,_0x1af573[_0x359b('0x5e')]);return _0x3942fa[_0x359b('0xd0')](_0x52ed39);}})['then'](function(_0x1bbe04){if(_0x1bbe04){_0x120dc=_0x1bbe04[_0x359b('0x66')];if(!_0x1af573['query'][_0x359b('0x55')](_0x359b('0x56'))){_0x52ed39['limit']=qs[_0x359b('0x33')](_0x1af573[_0x359b('0x50')][_0x359b('0x33')]);_0x52ed39[_0x359b('0x32')]=qs[_0x359b('0x32')](_0x1af573['query'][_0x359b('0x32')]);}return _0x3942fa['getWhatsappInteractions'](_0x52ed39);}})['then'](function(_0x34fa39){if(_0x34fa39){return _0x34fa39?{'count':_0x120dc,'rows':_0x34fa39}:null;}})[_0x359b('0x22')](respondWithResult(_0x18674e,null))[_0x359b('0x2c')](handleError(_0x18674e,null));};exports[_0x359b('0xd2')]=function(_0x58ebd1,_0x130d7f,_0x2b2a6d){var _0x519387;var _0x46fff8;var _0x3a98ee;var _0x1f6efb=!_[_0x359b('0x77')](_0x58ebd1[_0x359b('0x63')]['id'])?_0x58ebd1[_0x359b('0x63')]['id']:!_[_0x359b('0x77')](_0x58ebd1[_0x359b('0x3a')]['id'])?_0x58ebd1[_0x359b('0x3a')]['id']:null;return db[_0x359b('0x48')][_0x359b('0x43')]({'where':{'id':_0x1f6efb,'role':{'$or':['admin','user',_0x359b('0x6c')]}},'attributes':['id',_0x359b('0x44'),_0x359b('0xd3'),'mobile','role','internal','loginInPause']})['then'](function(_0x209b67){if(_0x209b67){if(_0x209b67[_0x359b('0x42')]==='agent'){_0x519387=_0x209b67;if(_0x58ebd1[_0x359b('0x68')]['interface']){_0x3a98ee=util[_0x359b('0x6f')](_0x359b('0xd4'),_0x519387[_0x58ebd1[_0x359b('0x68')][_0x359b('0xa6')]]);}else if(_0x58ebd1[_0x359b('0x68')][_0x359b('0xd5')]){_0x3a98ee=util[_0x359b('0x6f')](_0x359b('0xa5'),_0x58ebd1[_0x359b('0x68')]['intrf']);}else{_0x3a98ee=util[_0x359b('0x6f')](_0x359b('0xa5'),_0x519387[_0x359b('0x44')]);}socket['to'](util[_0x359b('0x6f')](_0x359b('0xd6'),_0x519387[_0x359b('0x44')]))[_0x359b('0xa1')](_0x359b('0xd7'),{'ip':_0x58ebd1[_0x359b('0xd8')][_0x359b('0xd9')]||_0x58ebd1[_0x359b('0xda')][_0x359b('0xdb')]||_0x58ebd1[_0x359b('0xdc')][_0x359b('0xdb')]||_0x58ebd1[_0x359b('0xda')][_0x359b('0xdc')][_0x359b('0xdb')]});return db['UserVoiceQueueRt'][_0x359b('0x37')]({'where':{'membername':_0x519387['name']},'individualHooks':!![]});}}else{throw new db['Sequelize'][(_0x359b('0x1f'))](_0x359b('0xdd'));}})[_0x359b('0x22')](function(){if(_0x519387){return _0x519387['getVoiceQueues']({'raw':!![]});}})['then'](function(_0xdcf3e3){if(_0x519387){var _0x337c79=[];if(_0xdcf3e3){_0x46fff8=_0xdcf3e3;if(_0x46fff8[_0x359b('0x66')]){for(var _0x101162=0x0;_0x101162<_0x46fff8['length'];_0x101162++){_0x337c79[_0x359b('0xde')]({'membername':_0x519387[_0x359b('0x44')],'UserId':_0x519387['id'],'queue_name':_0x46fff8[_0x101162]['name'],'VoiceQueueId':_0x46fff8[_0x101162]['id'],'interface':_0x3a98ee,'paused':_0x519387[_0x359b('0x98')]||![],'penalty':_0x46fff8[_0x101162]['UserVoiceQueue.penalty']||0x0});}return BPromise['each'](_0x337c79,function(_0x714249){return db[_0x359b('0xab')]['upsert'](_0x714249);});}}}})[_0x359b('0x22')](function(){if(_0x519387){return db[_0x359b('0xdf')][_0x359b('0xa3')]({'where':{'membername':_0x519387[_0x359b('0x44')],'exitAt':null}});}})[_0x359b('0x22')](function(_0x30e943){if(_0x519387){var _0x9da148=[];_0x30e943[_0x359b('0xe0')](function(_0x1b6cc0){_0x9da148[_0x359b('0xde')](_0x1b6cc0['update']({'exitAt':moment()[_0x359b('0x6f')](_0x359b('0xe1'))}));});return BPromise['all'](_0x9da148);}})['then'](function(){if(_0x519387){var _0x245e6b=[];var _0x1870f1=[];var _0x296c2f=utils[_0x359b('0xe2')]();var _0xc6be73={'membername':_0x519387['name'],'interface':_0x3a98ee,'enterAt':moment()['format'](_0x359b('0xe1')),'role':_0x519387[_0x359b('0x42')],'internal':_0x519387[_0x359b('0x71')]};_0x296c2f['forEach'](function(_0x3b0198){_0x245e6b[_0x359b('0xde')](_['merge']({'channel':_0x3b0198,'type':_0x359b('0xe3'),'data1':_0x58ebd1[_0x359b('0x68')]['device'],'data2':_0x3a98ee},_0xc6be73));if(_0x519387['loginInPause']){_0x1870f1[_0x359b('0xde')](_[_0x359b('0x5a')]({'channel':_0x3b0198,'type':_0x359b('0xe4'),'data1':_0x359b('0xe5')},_0xc6be73));}});return db[_0x359b('0xdf')][_0x359b('0x67')](_0x245e6b[_0x359b('0xe6')](_0x1870f1),{'individualHooks':!![]});}})['then'](function(){if(_0x519387){return _0x519387[_0x359b('0xe7')]({'online':!![],'lastLoginAt':moment()[_0x359b('0x6f')]('YYYY-MM-DD\x20HH:mm:ss'),'voicePause':_0x519387[_0x359b('0x98')]||![],'mailPause':_0x519387[_0x359b('0x98')]||![],'chatPause':_0x519387[_0x359b('0x98')]||![],'faxPause':_0x519387[_0x359b('0x98')]||![],'smsPause':_0x519387[_0x359b('0x98')]||![],'openchannelPause':_0x519387['loginInPause']||![],'whatsappPause':_0x519387['loginInPause']||![],'pauseType':_0x519387[_0x359b('0x98')]?'LOGININPAUSE':null,'interface':_0x3a98ee,'lastPauseAt':moment()[_0x359b('0x6f')](_0x359b('0xe1'))});}})[_0x359b('0x22')](function(_0x48acd5){if(_0x58ebd1[_0x359b('0xe8')]){return _0x2b2a6d();}else{return BPromise[_0x359b('0xe9')](_0x48acd5)[_0x359b('0x22')](respondWithResult(_0x130d7f,null));}})[_0x359b('0x2c')](handleError(_0x130d7f,null));};exports[_0x359b('0xea')]=function(_0x3c1101,_0x3d178f,_0x1edaae){var _0x16a4c5;return db[_0x359b('0x48')]['find']({'where':{'id':_0x3c1101['params']['id'],'role':_0x359b('0x6c')},'attributes':['id','name','role']})['then'](handleEntityNotFound(_0x3d178f,null))[_0x359b('0x22')](function(_0x2a3121){if(_0x2a3121){_0x16a4c5=_0x2a3121;return db[_0x359b('0xab')][_0x359b('0x37')]({'where':{'membername':_0x16a4c5['name']},'individualHooks':!![]});}})[_0x359b('0x22')](function(){return db[_0x359b('0xdf')][_0x359b('0xa3')]({'where':{'membername':_0x16a4c5['name'],'exitAt':null}});})[_0x359b('0x22')](function(_0x1cadbc){var _0x2d28c8=[];_0x1cadbc[_0x359b('0xe0')](function(_0x2f94d1){_0x2d28c8[_0x359b('0xde')](_0x2f94d1[_0x359b('0xe7')]({'exitAt':moment()[_0x359b('0x6f')](_0x359b('0xe1'))}));});return BPromise[_0x359b('0xeb')](_0x2d28c8);})[_0x359b('0x22')](function(){return _0x16a4c5[_0x359b('0xe7')]({'online':![],'lastLoginAt':null,'voicePause':![],'mailPause':![],'chatPause':![],'faxPause':![],'smsPause':![],'openchannelPause':![],'whatsappPause':![],'interface':null});})['then'](respondWithResult(_0x3d178f,null))[_0x359b('0x2c')](handleError(_0x3d178f,null));};exports[_0x359b('0xec')]=function(_0x53016b,_0xf5e774,_0x3a37d1){var _0x1dc8f3;return db[_0x359b('0xab')]['update']({'paused':0x1},{'where':{'UserId':_0x53016b[_0x359b('0x63')]['id']},'individualHooks':!![]})[_0x359b('0x22')](function(){return db['User'][_0x359b('0x43')]({'where':{'id':_0x53016b[_0x359b('0x63')]['id'],'role':'agent'},'attributes':['id','name',_0x359b('0x42'),'internal','interface']});})[_0x359b('0x22')](handleEntityNotFound(_0xf5e774,null))[_0x359b('0x22')](function(_0x4967fd){if(_0x4967fd){_0x1dc8f3=_0x4967fd;return respondWithRpcPromise(_0x359b('0xed'),'pause',{'id':_0x1dc8f3['id'],'name':_0x1dc8f3[_0x359b('0x44')],'pause':!![]});}})['then'](function(){if(_0x1dc8f3){return db[_0x359b('0xdf')][_0x359b('0xa3')]({'where':{'membername':_0x1dc8f3[_0x359b('0x44')],'type':_0x359b('0xe4'),'exitAt':null}});}})['then'](function(_0x3e4d8e){if(_0x3e4d8e[_0x359b('0x66')]){var _0x1dce8a=moment()['format'](_0x359b('0xe1'));for(var _0x2115ad=0x0,_0x4d6c94=_0x3e4d8e[_0x359b('0x66')];_0x2115ad<_0x4d6c94;_0x2115ad++){_0x3e4d8e[_0x2115ad][_0x359b('0xee')]({'exitAt':_0x1dce8a});}}})['then'](function(){var _0x1dbbd5=[];var _0xb4ab1=utils['getChannels']();_0xb4ab1[_0x359b('0xe0')](function(_0x369caa){_0x1dbbd5[_0x359b('0xde')]({'channel':_0x369caa,'membername':_0x1dc8f3[_0x359b('0x44')],'interface':_[_0x359b('0x77')](_0x1dc8f3[_0x359b('0xa6')])?util['format'](_0x359b('0xa5'),_0x1dc8f3[_0x359b('0x44')]):_0x1dc8f3[_0x359b('0xa6')],'type':_0x359b('0xe4'),'enterAt':moment()[_0x359b('0x6f')](_0x359b('0xe1')),'data1':_0x53016b[_0x359b('0x68')][_0x359b('0x4b')]||_0x359b('0xef'),'role':_0x1dc8f3[_0x359b('0x42')],'internal':_0x1dc8f3[_0x359b('0x71')]});});return db['MemberReport'][_0x359b('0x67')](_0x1dbbd5,{'individualHooks':!![]});})[_0x359b('0x22')](function(){return _0x1dc8f3['update']({'voicePause':!![],'mailPause':!![],'chatPause':!![],'faxPause':!![],'smsPause':!![],'whatsappPause':!![],'openchannelPause':!![],'pauseType':_0x53016b[_0x359b('0x68')][_0x359b('0x4b')]||_0x359b('0xef'),'lastPauseAt':moment()[_0x359b('0x6f')](_0x359b('0xe1'))});})[_0x359b('0x22')](respondWithResult(_0xf5e774,null))[_0x359b('0x2c')](handleError(_0xf5e774,null));};exports[_0x359b('0xf0')]=function(_0x12f879,_0x3a00cd,_0x4b7793){var _0x3ec7e8;return db[_0x359b('0x48')][_0x359b('0x43')]({'where':{'id':_0x12f879[_0x359b('0x63')]['id']},'attributes':['id',_0x359b('0x44'),'role',_0x359b('0x99'),_0x359b('0xf1'),_0x359b('0xf2'),'faxPause','openchannelPause',_0x359b('0xf3'),_0x359b('0xf4'),_0x359b('0xf5'),_0x359b('0xf6')]})[_0x359b('0x22')](handleEntityNotFound(_0x3a00cd,null))['then'](function(_0x5b4732){if(_0x5b4732){_0x3ec7e8=_0x5b4732;if(_0x12f879[_0x359b('0x68')][_0x359b('0x96')]&&!utils['isValidChannel'](_0x12f879[_0x359b('0x68')]['channel'])){throw new db['Sequelize']['ValidationError'](_0x359b('0x9b'));}switch(_0x12f879[_0x359b('0x68')][_0x359b('0x96')]){case _0x359b('0xa4'):return respondWithRpcPromise('QueuePause',_0x359b('0xf0'),{'id':_0x3ec7e8['id'],'name':_0x3ec7e8[_0x359b('0x44')],'pause':![]})[_0x359b('0x22')](function(){return db[_0x359b('0xab')][_0x359b('0xe7')]({'paused':0x0},{'where':{'UserId':_0x3ec7e8['id']},'individualHooks':!![]});})[_0x359b('0x22')](function(){return db[_0x359b('0xdf')][_0x359b('0x43')]({'where':{'channel':_0x12f879['body'][_0x359b('0x96')],'membername':_0x3ec7e8['name'],'type':'PAUSE','exitAt':null}});})['then'](function(_0x495f1a){if(_0x495f1a){return _0x495f1a[_0x359b('0xe7')]({'exitAt':moment()['format'](_0x359b('0xe1')),'data2':_0x359b('0xf7')},{'individualHooks':!![]});}return null;})[_0x359b('0x22')](function(){return _0x3ec7e8['update']({'voicePause':![]});});case _0x359b('0xf8'):case'chat':case _0x359b('0xf9'):case _0x359b('0xfa'):case _0x359b('0xfb'):case _0x359b('0xfc'):return db[_0x359b('0xdf')][_0x359b('0x43')]({'where':{'channel':_0x12f879[_0x359b('0x68')][_0x359b('0x96')],'membername':_0x3ec7e8[_0x359b('0x44')],'type':_0x359b('0xe4'),'exitAt':null}})[_0x359b('0x22')](function(_0x31f7fd){if(_0x31f7fd){return _0x31f7fd[_0x359b('0xe7')]({'exitAt':moment()[_0x359b('0x6f')](_0x359b('0xe1')),'data2':_0x359b('0xf7')},{'individualHooks':!![]});}return null;})[_0x359b('0x22')](function(){var _0x1fec66={};_[_0x359b('0x34')](_0x1fec66,util[_0x359b('0x6f')](_0x359b('0xfd'),_0x12f879['body']['channel'],'Pause'),![]);return _0x3ec7e8[_0x359b('0xe7')](_0x1fec66);});default:return respondWithRpcPromise('QueuePause',_0x359b('0xf0'),{'id':_0x3ec7e8['id'],'name':_0x3ec7e8[_0x359b('0x44')],'pause':![]})['then'](function(){return db['UserVoiceQueueRt'][_0x359b('0xe7')]({'paused':0x0},{'where':{'UserId':_0x3ec7e8['id']}});})['then'](function(){return db[_0x359b('0xdf')]['findAll']({'where':{'membername':_0x3ec7e8[_0x359b('0x44')],'type':_0x359b('0xe4'),'exitAt':null}});})['then'](function(_0x50bdc8){var _0x4e759b=[];_0x50bdc8[_0x359b('0xe0')](function(_0x450ac0){_0x4e759b[_0x359b('0xde')](_0x450ac0[_0x359b('0xe7')]({'exitAt':moment()[_0x359b('0x6f')]('YYYY-MM-DD\x20HH:mm:ss'),'data2':_0x359b('0xf7')}));});return BPromise[_0x359b('0xeb')](_0x4e759b);})[_0x359b('0x22')](function(){return _0x3ec7e8[_0x359b('0xe7')]({'voicePause':![],'mailPause':![],'chatPause':![],'faxPause':![],'smsPause':![],'whatsappPause':![],'openchannelPause':![]});});}}})[_0x359b('0x22')](respondWithResult(_0x3a00cd,null))[_0x359b('0x2c')](handleError(_0x3a00cd,null));};exports[_0x359b('0xfe')]=function(_0x255ade,_0x4236fd,_0x16dc8a){var _0x2f7c11={};var _0x570e32={};var _0x1d8a68;var _0xf25a35;return db[_0x359b('0x48')][_0x359b('0xb7')]({'where':{'id':_0x255ade[_0x359b('0x63')]['id']}})['then'](handleEntityNotFound(_0x4236fd,null))[_0x359b('0x22')](function(_0x5678dd){if(_0x5678dd){_0x1d8a68=_0x5678dd;_0x570e32[_0x359b('0x4d')]=_[_0x359b('0x64')](db['Team'][_0x359b('0x49')]);_0x570e32['query']=_[_0x359b('0x64')](_0x255ade[_0x359b('0x50')]);_0x570e32['filters']=_[_0x359b('0x52')](_0x570e32[_0x359b('0x4d')],_0x570e32[_0x359b('0x50')]);_0x2f7c11[_0x359b('0x53')]=_[_0x359b('0x52')](_0x570e32['model'],qs[_0x359b('0x54')](_0x255ade[_0x359b('0x50')][_0x359b('0x54')]));_0x2f7c11[_0x359b('0x53')]=_0x2f7c11[_0x359b('0x53')][_0x359b('0x66')]?_0x2f7c11[_0x359b('0x53')]:_0x570e32[_0x359b('0x4d')];_0x2f7c11[_0x359b('0x57')]=qs[_0x359b('0x58')](_0x255ade[_0x359b('0x50')][_0x359b('0x58')]);_0x2f7c11[_0x359b('0x59')]=qs['filters'](_['pick'](_0x255ade[_0x359b('0x50')],_0x570e32[_0x359b('0x51')]));if(_0x255ade[_0x359b('0x50')][_0x359b('0x3d')]){_0x2f7c11[_0x359b('0x59')]=_[_0x359b('0x5a')](_0x2f7c11[_0x359b('0x59')],{'$or':_[_0x359b('0x3f')](_0x2f7c11[_0x359b('0x53')],function(_0xdf4128){var _0x1724b2={};_0x1724b2[_0xdf4128]={'$like':'%'+_0x255ade[_0x359b('0x50')][_0x359b('0x3d')]+'%'};return _0x1724b2;})});}_0x2f7c11=_[_0x359b('0x5a')]({},_0x2f7c11,_0x255ade[_0x359b('0x5e')]);return _0x1d8a68[_0x359b('0xfe')](_0x2f7c11);}})[_0x359b('0x22')](function(_0x5f4f85){if(_0x5f4f85){_0xf25a35=_0x5f4f85[_0x359b('0x66')];if(!_0x255ade[_0x359b('0x50')]['hasOwnProperty'](_0x359b('0x56'))){_0x2f7c11[_0x359b('0x33')]=qs[_0x359b('0x33')](_0x255ade[_0x359b('0x50')]['limit']);_0x2f7c11['offset']=qs['offset'](_0x255ade[_0x359b('0x50')]['offset']);}return _0x1d8a68[_0x359b('0xfe')](_0x2f7c11);}})[_0x359b('0x22')](function(_0x31d8a6){if(_0x31d8a6){return _0x31d8a6?{'count':_0xf25a35,'rows':_0x31d8a6}:null;}})[_0x359b('0x22')](respondWithResult(_0x4236fd,null))['catch'](handleError(_0x4236fd,null));};exports[_0x359b('0xff')]=function(_0x53e941,_0x39da40){return db['User'][_0x359b('0x43')]({'where':{'id':_0x53e941[_0x359b('0x63')]['id']}})[_0x359b('0x22')](handleEntityNotFound(_0x39da40,null))[_0x359b('0x22')](function(_0x6e8c1b){if(_0x6e8c1b){var _0x45e517=_0x6e8c1b[_0x359b('0x38')]({'plain':!![]});return _0x6e8c1b[_0x359b('0xff')](_0x53e941['body']['ids'],_['omit'](_0x53e941['body'],['ids','id'])||{})[_0x359b('0x22')](function(){for(var _0xb4a895=0x0;_0xb4a895<_0x53e941[_0x359b('0x68')][_0x359b('0x6b')][_0x359b('0x66')];_0xb4a895++){var _0x38ab8e=[];db[_0x359b('0x100')][_0x359b('0xb7')]({'where':{'id':_0x53e941[_0x359b('0x68')][_0x359b('0x6b')][_0xb4a895]}})[_0x359b('0x22')](function(_0x30c9aa){_0x38ab8e['push'](_0x30c9aa[_0x359b('0x101')]()[_0x359b('0x22')](function(_0x55df21){for(var _0x3f8698=0x0;_0x3f8698<_0x55df21['length'];_0x3f8698++){_0x55df21[_0x3f8698][_0x359b('0x102')](_0x359b('0x96'),_0x359b('0x103'));}return _0x55df21;}));_0x38ab8e[_0x359b('0xde')](_0x30c9aa[_0x359b('0x104')]()['then'](function(_0x120840){for(var _0x570986=0x0;_0x570986<_0x120840['length'];_0x570986++){_0x120840[_0x570986][_0x359b('0x102')]('channel',_0x359b('0x105'));}return _0x120840;}));_0x38ab8e[_0x359b('0xde')](_0x30c9aa['getMailQueues']()[_0x359b('0x22')](function(_0x1a6dd7){for(var _0x265174=0x0;_0x265174<_0x1a6dd7[_0x359b('0x66')];_0x265174++){_0x1a6dd7[_0x265174][_0x359b('0x102')](_0x359b('0x96'),_0x359b('0x106'));}return _0x1a6dd7;}));_0x38ab8e['push'](_0x30c9aa[_0x359b('0x107')]()['then'](function(_0x10b607){for(var _0x4b9ea4=0x0;_0x4b9ea4<_0x10b607[_0x359b('0x66')];_0x4b9ea4++){_0x10b607[_0x4b9ea4][_0x359b('0x102')](_0x359b('0x96'),'Sms');}return _0x10b607;}));_0x38ab8e[_0x359b('0xde')](_0x30c9aa[_0x359b('0x108')]()['then'](function(_0x2b9478){for(var _0x485c1d=0x0;_0x485c1d<_0x2b9478[_0x359b('0x66')];_0x485c1d++){_0x2b9478[_0x485c1d]['setDataValue'](_0x359b('0x96'),_0x359b('0x109'));}return _0x2b9478;}));_0x38ab8e[_0x359b('0xde')](_0x30c9aa['getFaxQueues']()[_0x359b('0x22')](function(_0xf897f7){for(var _0x582289=0x0;_0x582289<_0xf897f7[_0x359b('0x66')];_0x582289++){_0xf897f7[_0x582289]['setDataValue'](_0x359b('0x96'),'Fax');}return _0xf897f7;}));_0x38ab8e[_0x359b('0xde')](_0x30c9aa['getOpenchannelQueues']()[_0x359b('0x22')](function(_0x500b9e){for(var _0x1027bb=0x0;_0x1027bb<_0x500b9e['length'];_0x1027bb++){_0x500b9e[_0x1027bb][_0x359b('0x102')](_0x359b('0x96'),'Openchannel');}return _0x500b9e;}));return BPromise[_0x359b('0xeb')](_0x38ab8e);})[_0x359b('0x22')](function(_0x3ffb4b){var _0x4cd4f1=_[_0x359b('0x10a')](_0x3ffb4b);_0x38ab8e=[];return db[_0x359b('0x5b')]['transaction'](function(_0x5cce4b){for(var _0x3eb4f5=0x0;_0x3eb4f5<_0x4cd4f1[_0x359b('0x66')];_0x3eb4f5++){_0x38ab8e['push'](_0x4cd4f1[_0x3eb4f5][_0x359b('0x10b')](_0x45e517['id']),{'transaction':_0x5cce4b});}return BPromise[_0x359b('0xeb')](_0x38ab8e)[_0x359b('0x22')](function(){if(_0x45e517[_0x359b('0x97')]){return BPromise['each'](_['filter'](_0x4cd4f1,function(_0x5afae0){return _0x5afae0['getDataValue'](_0x359b('0x96'))===_0x359b('0x103');}),function(_0x2da3c6){return db[_0x359b('0xab')][_0x359b('0x10c')]({'membername':_0x45e517['name'],'UserId':_0x45e517['id'],'queue_name':_0x2da3c6['name'],'VoiceQueueId':_0x2da3c6['id'],'interface':_[_0x359b('0x77')](_0x45e517[_0x359b('0xa6')])?util[_0x359b('0x6f')](_0x359b('0xa5'),_0x45e517['name']):_0x45e517[_0x359b('0xa6')],'paused':_0x45e517[_0x359b('0x99')]||![],'penalty':_0x45e517[_0x359b('0x9e')]},{'transaction':_0x5cce4b});});}else{return;}})[_0x359b('0x22')](function(){for(var _0x26b072=0x0;_0x26b072<_0x4cd4f1[_0x359b('0x66')];_0x26b072++){var _0x58fc1e=_0x4cd4f1[_0x26b072]['getDataValue'](_0x359b('0x96'));var _0x4ea670=_0x58fc1e+'QueueId';socket[_0x359b('0xa1')](_0x359b('0x3a')+_0x58fc1e+_0x359b('0xa2'),{'UserId':_0x45e517['id'],['queueField']:_0x4cd4f1[_0x26b072]['id']});}});});});}});}})[_0x359b('0x22')](respondWithStatusCode(_0x39da40,null))[_0x359b('0x2c')](handleError(_0x39da40,null));};exports['removeTeams']=function(_0x22a75b,_0x2d6c70){return db[_0x359b('0x48')][_0x359b('0xb7')]({'where':{'id':_0x22a75b[_0x359b('0x63')]['id']}})[_0x359b('0x22')](handleEntityNotFound(_0x2d6c70,null))[_0x359b('0x22')](function(_0x4acde3){if(_0x4acde3){var _0x1035fd=_0x4acde3[_0x359b('0x38')]({'plain':!![]});var _0x3c1a17=_0x22a75b[_0x359b('0x50')][_0x359b('0x6b')];return _0x4acde3[_0x359b('0x10d')](_0x3c1a17)[_0x359b('0x22')](function(){for(var _0x305799=0x0;_0x305799<_0x3c1a17[_0x359b('0x66')];_0x305799++){var _0x35f4af=[];db[_0x359b('0x100')]['findOne']({'where':{'id':_0x3c1a17[_0x305799]}})['then'](function(_0x5e4739){_0x35f4af[_0x359b('0xde')](_0x5e4739['getVoiceQueues']()[_0x359b('0x22')](function(_0x3b7747){for(var _0x4ecddd=0x0;_0x4ecddd<_0x3b7747[_0x359b('0x66')];_0x4ecddd++){_0x3b7747[_0x4ecddd][_0x359b('0x102')](_0x359b('0x96'),_0x359b('0x103'));}return _0x3b7747;}));_0x35f4af[_0x359b('0xde')](_0x5e4739[_0x359b('0x104')]()['then'](function(_0x4fdf3e){for(var _0x5939d0=0x0;_0x5939d0<_0x4fdf3e[_0x359b('0x66')];_0x5939d0++){_0x4fdf3e[_0x5939d0][_0x359b('0x102')]('channel','Chat');}return _0x4fdf3e;}));_0x35f4af[_0x359b('0xde')](_0x5e4739[_0x359b('0x10e')]()[_0x359b('0x22')](function(_0x5d1078){for(var _0x3ba6a4=0x0;_0x3ba6a4<_0x5d1078['length'];_0x3ba6a4++){_0x5d1078[_0x3ba6a4]['setDataValue'](_0x359b('0x96'),_0x359b('0x106'));}return _0x5d1078;}));_0x35f4af[_0x359b('0xde')](_0x5e4739[_0x359b('0x107')]()['then'](function(_0x4a40b5){for(var _0x1ea52d=0x0;_0x1ea52d<_0x4a40b5[_0x359b('0x66')];_0x1ea52d++){_0x4a40b5[_0x1ea52d]['setDataValue'](_0x359b('0x96'),_0x359b('0x10f'));}return _0x4a40b5;}));_0x35f4af[_0x359b('0xde')](_0x5e4739[_0x359b('0x108')]()[_0x359b('0x22')](function(_0x4eacb3){for(var _0x5c9979=0x0;_0x5c9979<_0x4eacb3[_0x359b('0x66')];_0x5c9979++){_0x4eacb3[_0x5c9979][_0x359b('0x102')](_0x359b('0x96'),'Whatsapp');}return _0x4eacb3;}));_0x35f4af[_0x359b('0xde')](_0x5e4739[_0x359b('0x110')]()[_0x359b('0x22')](function(_0x589484){for(var _0x2ff386=0x0;_0x2ff386<_0x589484['length'];_0x2ff386++){_0x589484[_0x2ff386][_0x359b('0x102')](_0x359b('0x96'),_0x359b('0x111'));}return _0x589484;}));_0x35f4af[_0x359b('0xde')](_0x5e4739[_0x359b('0x112')]()[_0x359b('0x22')](function(_0x39c0f6){for(var _0x383808=0x0;_0x383808<_0x39c0f6[_0x359b('0x66')];_0x383808++){_0x39c0f6[_0x383808][_0x359b('0x102')](_0x359b('0x96'),_0x359b('0x113'));}return _0x39c0f6;}));return BPromise['all'](_0x35f4af);})['then'](function(_0x331cb0){var _0x1ce98b=_[_0x359b('0x10a')](_0x331cb0);_0x35f4af=[];return db['sequelize'][_0x359b('0x114')](function(_0x733959){for(var _0x12e619=0x0;_0x12e619<_0x1ce98b[_0x359b('0x66')];_0x12e619++){_0x35f4af['push'](_0x1ce98b[_0x12e619][_0x359b('0x115')](_0x1035fd['id']),{'transaction':_0x733959});}return BPromise['all'](_0x35f4af)[_0x359b('0x22')](function(){if(_0x1035fd[_0x359b('0x97')]){return BPromise['each'](_[_0x359b('0x3d')](_0x1ce98b,function(_0x53f15a){return _0x53f15a[_0x359b('0x116')](_0x359b('0x96'))==='Voice';}),function(_0x378bc8){return db[_0x359b('0xab')][_0x359b('0x37')]({'where':{'VoiceQueueId':_0x378bc8['id'],'UserId':_0x1035fd['id']},'transaction':_0x733959});});}else{return;}})[_0x359b('0x22')](function(){for(var _0x47ceb9=0x0;_0x47ceb9<_0x1ce98b[_0x359b('0x66')];_0x47ceb9++){var _0x44e7f6=_0x1ce98b[_0x47ceb9][_0x359b('0x116')](_0x359b('0x96'));var _0x49ed15=_0x44e7f6+_0x359b('0xaa');socket[_0x359b('0xa1')](_0x359b('0x3a')+_0x44e7f6+_0x359b('0x117'),{'UserId':_0x1035fd['id'],['queueField']:_0x1ce98b[_0x47ceb9]['id']});}});});});}});}})['then'](respondWithStatusCode(_0x2d6c70,null))['catch'](handleError(_0x2d6c70,null));};exports[_0x359b('0x118')]=function(_0x4254fd,_0x1ca289,_0x200e40){var _0x10a69f={};var _0x5705b6={};var _0x75faf6;var _0x5d9e6c;return db[_0x359b('0x48')][_0x359b('0xb7')]({'where':{'id':_0x4254fd[_0x359b('0x63')]['id']}})[_0x359b('0x22')](handleEntityNotFound(_0x1ca289,null))[_0x359b('0x22')](function(_0xb9b80f){if(_0xb9b80f){_0x75faf6=_0xb9b80f;_0x5705b6[_0x359b('0x4d')]=_['keys'](db[_0x359b('0x119')][_0x359b('0x49')]);_0x5705b6['query']=_['keys'](_0x4254fd['query']);_0x5705b6[_0x359b('0x51')]=_['intersection'](_0x5705b6[_0x359b('0x4d')],_0x5705b6['query']);_0x10a69f[_0x359b('0x53')]=_[_0x359b('0x52')](_0x5705b6[_0x359b('0x4d')],qs[_0x359b('0x54')](_0x4254fd[_0x359b('0x50')]['fields']));_0x10a69f[_0x359b('0x53')]=_0x10a69f[_0x359b('0x53')][_0x359b('0x66')]?_0x10a69f['attributes']:_0x5705b6[_0x359b('0x4d')];_0x10a69f['order']=qs['sort'](_0x4254fd[_0x359b('0x50')][_0x359b('0x58')]);_0x10a69f[_0x359b('0x59')]=qs[_0x359b('0x51')](_[_0x359b('0xb9')](_0x4254fd[_0x359b('0x50')],_0x5705b6[_0x359b('0x51')]));if(_0x4254fd[_0x359b('0x50')][_0x359b('0x3d')]){_0x10a69f[_0x359b('0x59')]=_[_0x359b('0x5a')](_0x10a69f['where'],{'$or':_[_0x359b('0x3f')](_0x10a69f[_0x359b('0x53')],function(_0x307574){var _0x1deeb4={};_0x1deeb4[_0x307574]={'$like':'%'+_0x4254fd[_0x359b('0x50')][_0x359b('0x3d')]+'%'};return _0x1deeb4;})});}_0x10a69f=_['merge']({},_0x10a69f,_0x4254fd['options']);return _0x75faf6[_0x359b('0x118')](_0x10a69f);}})[_0x359b('0x22')](function(_0x4e80cb){if(_0x4e80cb){_0x5d9e6c=_0x4e80cb[_0x359b('0x66')];if(!_0x4254fd['query'][_0x359b('0x55')]('nolimit')){_0x10a69f['limit']=qs[_0x359b('0x33')](_0x4254fd['query'][_0x359b('0x33')]);_0x10a69f[_0x359b('0x32')]=qs[_0x359b('0x32')](_0x4254fd[_0x359b('0x50')][_0x359b('0x32')]);}return _0x75faf6[_0x359b('0x118')](_0x10a69f);}})[_0x359b('0x22')](function(_0x5c3a09){if(_0x5c3a09){return _0x5c3a09?{'count':_0x5d9e6c,'rows':_0x5c3a09}:null;}})[_0x359b('0x22')](respondWithResult(_0x1ca289,null))['catch'](handleError(_0x1ca289,null));};exports[_0x359b('0x11a')]=function(_0x287bc9,_0x5d8c83,_0x49cb73){var _0x13f0f2={};var _0x1fda53={};var _0x4433c7;var _0x336966;return db['User'][_0x359b('0xb7')]({'where':{'id':_0x287bc9[_0x359b('0x63')]['id']}})[_0x359b('0x22')](handleEntityNotFound(_0x5d8c83,null))['then'](function(_0xff8a54){if(_0xff8a54){_0x4433c7=_0xff8a54;_0x1fda53[_0x359b('0x4d')]=_[_0x359b('0x64')](db[_0x359b('0x48')][_0x359b('0x49')]);_0x1fda53[_0x359b('0x50')]=_[_0x359b('0x64')](_0x287bc9[_0x359b('0x50')]);_0x1fda53['filters']=_[_0x359b('0x52')](_0x1fda53['model'],_0x1fda53[_0x359b('0x50')]);_0x13f0f2[_0x359b('0x53')]=_[_0x359b('0x52')](_0x1fda53[_0x359b('0x4d')],qs[_0x359b('0x54')](_0x287bc9[_0x359b('0x50')][_0x359b('0x54')]));_0x13f0f2[_0x359b('0x53')]=_0x13f0f2['attributes'][_0x359b('0x66')]?_0x13f0f2['attributes']:_0x1fda53[_0x359b('0x4d')];_0x13f0f2['order']=qs[_0x359b('0x58')](_0x287bc9[_0x359b('0x50')][_0x359b('0x58')]);_0x13f0f2[_0x359b('0x59')]=qs[_0x359b('0x51')](_[_0x359b('0xb9')](_0x287bc9[_0x359b('0x50')],_0x1fda53['filters']));if(_0x287bc9[_0x359b('0x50')][_0x359b('0x3d')]){_0x13f0f2[_0x359b('0x59')]=_[_0x359b('0x5a')](_0x13f0f2[_0x359b('0x59')],{'$or':_[_0x359b('0x3f')](_0x13f0f2[_0x359b('0x53')],function(_0x4feeca){var _0x4c28d3={};_0x4c28d3[_0x4feeca]={'$like':'%'+_0x287bc9[_0x359b('0x50')][_0x359b('0x3d')]+'%'};return _0x4c28d3;})});}_0x13f0f2[_0x359b('0x4d')]=db[_0x359b('0x48')];_0x13f0f2['as']=_0x359b('0x8c');_0x13f0f2=_[_0x359b('0x5a')]({},_0x13f0f2,_0x287bc9[_0x359b('0x5e')]);return _0x4433c7[_0x359b('0x101')]({'include':[_0x13f0f2]});}})[_0x359b('0x22')](function(_0x28629a){if(_0x28629a){var _0xecc4ef={},_0x126deb=[],_0x24d050=0x0;for(var _0x4f90c2=0x0;_0x4f90c2<_0x28629a[_0x359b('0x66')];_0x4f90c2+=0x1){for(var _0x195dfa=0x0,_0x4772ea;_0x195dfa<_0x28629a[_0x4f90c2][_0x359b('0x8c')][_0x359b('0x66')];_0x195dfa+=0x1){_0x4772ea=_0x28629a[_0x4f90c2][_0x359b('0x8c')][_0x195dfa][_0x359b('0x38')]({'plain':!![]});_0xecc4ef[_0x4772ea['id']]=_0x4772ea;}}_0xecc4ef=_[_0x359b('0x11b')](_0xecc4ef);for(var _0x3602fd=qs[_0x359b('0x32')](_0x287bc9[_0x359b('0x50')]['offset']);_0x3602fd<_0xecc4ef[_0x359b('0x66')]&&_0x126deb[_0x359b('0x66')]<qs[_0x359b('0x33')](_0x287bc9[_0x359b('0x50')]['limit']);_0x3602fd+=0x1){if(_0xecc4ef[_0x3602fd]){_0x126deb['push'](_0xecc4ef[_0x3602fd]);}}return{'count':_0xecc4ef[_0x359b('0x66')],'rows':_0x126deb};}})[_0x359b('0x22')](respondWithResult(_0x5d8c83,null))['catch'](handleError(_0x5d8c83,null));};exports['destroy']=function(_0x5651d0,_0x4308b3){if(_0x5651d0[_0x359b('0x3a')]['id']==_0x5651d0[_0x359b('0x63')]['id']){return _0x4308b3[_0x359b('0x2e')](0x1f4)[_0x359b('0x11c')]({'message':'You\x20can\x27t\x20delete\x20yourself'});}return db[_0x359b('0x48')][_0x359b('0x43')]({'where':{'id':_0x5651d0[_0x359b('0x63')]['id']}})[_0x359b('0x22')](handleEntityNotFound(_0x4308b3,null))['then'](removeEntity(_0x4308b3,null))[_0x359b('0x2c')](handleError(_0x4308b3,null));};exports['addChatInteractions']=function(_0x5bb061,_0x897855,_0x35681a){return db[_0x359b('0x48')][_0x359b('0x43')]({'where':{'id':_0x5bb061[_0x359b('0x63')]['id']}})[_0x359b('0x22')](handleEntityNotFound(_0x897855,null))[_0x359b('0x22')](function(_0x2e414d){if(_0x2e414d){return _0x2e414d['addChatInteractions'](_0x5bb061['body'][_0x359b('0x6b')],_[_0x359b('0x11d')](_0x5bb061[_0x359b('0x68')],['ids','id'])||{})['spread'](function(){for(var _0x3d981b=0x0;_0x3d981b<_0x5bb061['body'][_0x359b('0x6b')][_0x359b('0x66')];_0x3d981b+=0x1){socket[_0x359b('0xa1')](_0x359b('0x11e'),{'ChatInteractionId':Number(_0x5bb061['body'][_0x359b('0x6b')][_0x3d981b]),'UserId':Number(_0x5bb061[_0x359b('0x63')]['id'])});}return _0x5bb061[_0x359b('0x68')][_0x359b('0x6b')];});}})[_0x359b('0x22')](respondWithResult(_0x897855,null))[_0x359b('0x2c')](handleError(_0x897855,null));};exports['removeChatInteractions']=function(_0x75eacb,_0x288678,_0x57254b){return db[_0x359b('0x48')][_0x359b('0x43')]({'where':{'id':_0x75eacb[_0x359b('0x63')]['id']}})[_0x359b('0x22')](handleEntityNotFound(_0x288678,null))[_0x359b('0x22')](function(_0x5340fc){if(_0x5340fc){return _0x5340fc['removeChatInteractions'](_0x75eacb[_0x359b('0x50')][_0x359b('0x6b')])[_0x359b('0x22')](function(){if(_['isArray'](_0x75eacb[_0x359b('0x50')][_0x359b('0x6b')])){for(var _0x37649a=0x0;_0x37649a<_0x75eacb['query'][_0x359b('0x6b')][_0x359b('0x66')];_0x37649a+=0x1){socket[_0x359b('0xa1')](_0x359b('0x11f'),{'ChatInteractionId':Number(_0x75eacb[_0x359b('0x50')]['ids'][_0x37649a]),'UserId':Number(_0x75eacb[_0x359b('0x63')]['id'])});}}else{socket['emit'](_0x359b('0x11f'),{'ChatInteractionId':Number(_0x75eacb[_0x359b('0x50')]['ids']),'UserId':Number(_0x75eacb['params']['id'])});}});}})[_0x359b('0x22')](respondWithStatusCode(_0x288678,null))[_0x359b('0x2c')](handleError(_0x288678,null));};exports[_0x359b('0x120')]=function(_0x5b7a6f,_0x5ea642,_0x23464c){return db[_0x359b('0x48')]['find']({'where':{'id':_0x5b7a6f[_0x359b('0x63')]['id']}})[_0x359b('0x22')](handleEntityNotFound(_0x5ea642,null))[_0x359b('0x22')](function(_0x462202){if(_0x462202){return _0x462202[_0x359b('0x120')](_0x5b7a6f[_0x359b('0x68')][_0x359b('0x6b')],_[_0x359b('0x11d')](_0x5b7a6f[_0x359b('0x68')],[_0x359b('0x6b'),'id'])||{})[_0x359b('0x9f')](function(){for(var _0x32f54d=0x0;_0x32f54d<_0x5b7a6f[_0x359b('0x68')][_0x359b('0x6b')][_0x359b('0x66')];_0x32f54d+=0x1){socket[_0x359b('0xa1')](_0x359b('0x121'),{'MailInteractionId':Number(_0x5b7a6f[_0x359b('0x68')][_0x359b('0x6b')][_0x32f54d]),'UserId':Number(_0x5b7a6f[_0x359b('0x63')]['id'])});}return _0x5b7a6f[_0x359b('0x68')][_0x359b('0x6b')];});}})['then'](respondWithResult(_0x5ea642,null))[_0x359b('0x2c')](handleError(_0x5ea642,null));};exports[_0x359b('0x122')]=function(_0x3a9b78,_0x237ff6,_0x1ce29f){return db[_0x359b('0x48')][_0x359b('0x43')]({'where':{'id':_0x3a9b78[_0x359b('0x63')]['id']}})[_0x359b('0x22')](handleEntityNotFound(_0x237ff6,null))[_0x359b('0x22')](function(_0x1e3e16){if(_0x1e3e16){return _0x1e3e16['removeMailInteractions'](_0x3a9b78[_0x359b('0x50')][_0x359b('0x6b')])[_0x359b('0x22')](function(){if(_[_0x359b('0x123')](_0x3a9b78['query'][_0x359b('0x6b')])){for(var _0x36d399=0x0;_0x36d399<_0x3a9b78['query'][_0x359b('0x6b')][_0x359b('0x66')];_0x36d399+=0x1){socket[_0x359b('0xa1')](_0x359b('0x124'),{'MailInteractionId':Number(_0x3a9b78[_0x359b('0x50')][_0x359b('0x6b')][_0x36d399]),'UserId':Number(_0x3a9b78[_0x359b('0x63')]['id'])});}}else{socket[_0x359b('0xa1')](_0x359b('0x124'),{'MailInteractionId':Number(_0x3a9b78[_0x359b('0x50')][_0x359b('0x6b')]),'UserId':Number(_0x3a9b78[_0x359b('0x63')]['id'])});}});}})[_0x359b('0x22')](respondWithStatusCode(_0x237ff6,null))[_0x359b('0x2c')](handleError(_0x237ff6,null));};exports[_0x359b('0x125')]=function(_0x4b8d52,_0x2c1dd9,_0xcf4631){return db[_0x359b('0x48')][_0x359b('0x43')]({'where':{'id':_0x4b8d52[_0x359b('0x63')]['id']}})[_0x359b('0x22')](handleEntityNotFound(_0x2c1dd9,null))[_0x359b('0x22')](function(_0xeef044){if(_0xeef044){return _0xeef044['addFaxInteractions'](_0x4b8d52[_0x359b('0x68')][_0x359b('0x6b')],_[_0x359b('0x11d')](_0x4b8d52[_0x359b('0x68')],[_0x359b('0x6b'),'id'])||{})[_0x359b('0x9f')](function(){for(var _0x222bbe=0x0;_0x222bbe<_0x4b8d52[_0x359b('0x68')][_0x359b('0x6b')][_0x359b('0x66')];_0x222bbe+=0x1){socket[_0x359b('0xa1')]('user_has_fax_interactions:save',{'FaxInteractionId':Number(_0x4b8d52[_0x359b('0x68')][_0x359b('0x6b')][_0x222bbe]),'UserId':Number(_0x4b8d52[_0x359b('0x63')]['id'])});}return _0x4b8d52[_0x359b('0x68')]['ids'];});}})[_0x359b('0x22')](respondWithResult(_0x2c1dd9,null))[_0x359b('0x2c')](handleError(_0x2c1dd9,null));};exports['removeFaxInteractions']=function(_0x29ef9f,_0x1359a9,_0x3e9223){return db[_0x359b('0x48')]['find']({'where':{'id':_0x29ef9f[_0x359b('0x63')]['id']}})[_0x359b('0x22')](handleEntityNotFound(_0x1359a9,null))[_0x359b('0x22')](function(_0x3a6878){if(_0x3a6878){return _0x3a6878[_0x359b('0x126')](_0x29ef9f[_0x359b('0x50')][_0x359b('0x6b')])[_0x359b('0x22')](function(){if(_[_0x359b('0x123')](_0x29ef9f['query'][_0x359b('0x6b')])){for(var _0x36bcf9=0x0;_0x36bcf9<_0x29ef9f[_0x359b('0x50')][_0x359b('0x6b')][_0x359b('0x66')];_0x36bcf9+=0x1){socket[_0x359b('0xa1')](_0x359b('0x127'),{'FaxInteractionId':Number(_0x29ef9f[_0x359b('0x50')][_0x359b('0x6b')][_0x36bcf9]),'UserId':Number(_0x29ef9f[_0x359b('0x63')]['id'])});}}else{socket['emit']('user_has_fax_interactions:remove',{'FaxInteractionId':Number(_0x29ef9f[_0x359b('0x50')]['ids']),'UserId':Number(_0x29ef9f[_0x359b('0x63')]['id'])});}});}})['then'](respondWithStatusCode(_0x1359a9,null))[_0x359b('0x2c')](handleError(_0x1359a9,null));};exports[_0x359b('0x128')]=function(_0x203aef,_0x44989b,_0x37a1c2){return db[_0x359b('0x48')]['find']({'where':{'id':_0x203aef[_0x359b('0x63')]['id']}})[_0x359b('0x22')](handleEntityNotFound(_0x44989b,null))[_0x359b('0x22')](function(_0x42846e){if(_0x42846e){return _0x42846e[_0x359b('0x128')](_0x203aef['body']['ids'],_[_0x359b('0x11d')](_0x203aef['body'],[_0x359b('0x6b'),'id'])||{})[_0x359b('0x9f')](function(){for(var _0x14aa56=0x0;_0x14aa56<_0x203aef[_0x359b('0x68')][_0x359b('0x6b')]['length'];_0x14aa56+=0x1){socket[_0x359b('0xa1')](_0x359b('0x129'),{'SmsInteractionId':Number(_0x203aef['body'][_0x359b('0x6b')][_0x14aa56]),'UserId':Number(_0x203aef[_0x359b('0x63')]['id'])});}return _0x203aef[_0x359b('0x68')][_0x359b('0x6b')];});}})[_0x359b('0x22')](respondWithResult(_0x44989b,null))['catch'](handleError(_0x44989b,null));};exports['removeSmsInteractions']=function(_0x113d0e,_0x505ab3,_0x493c77){return db[_0x359b('0x48')][_0x359b('0x43')]({'where':{'id':_0x113d0e[_0x359b('0x63')]['id']}})[_0x359b('0x22')](handleEntityNotFound(_0x505ab3,null))[_0x359b('0x22')](function(_0x24a96c){if(_0x24a96c){return _0x24a96c[_0x359b('0x12a')](_0x113d0e['query'][_0x359b('0x6b')])[_0x359b('0x22')](function(){if(_['isArray'](_0x113d0e[_0x359b('0x50')][_0x359b('0x6b')])){for(var _0x1d796d=0x0;_0x1d796d<_0x113d0e['query'][_0x359b('0x6b')][_0x359b('0x66')];_0x1d796d+=0x1){socket[_0x359b('0xa1')](_0x359b('0x12b'),{'SmsInteractionId':Number(_0x113d0e[_0x359b('0x50')][_0x359b('0x6b')][_0x1d796d]),'UserId':Number(_0x113d0e[_0x359b('0x63')]['id'])});}}else{socket[_0x359b('0xa1')](_0x359b('0x12b'),{'SmsInteractionId':Number(_0x113d0e[_0x359b('0x50')][_0x359b('0x6b')]),'UserId':Number(_0x113d0e[_0x359b('0x63')]['id'])});}});}})['then'](respondWithStatusCode(_0x505ab3,null))[_0x359b('0x2c')](handleError(_0x505ab3,null));};exports[_0x359b('0x12c')]=function(_0x271288,_0x4bea92,_0x3e0c16){return db['User'][_0x359b('0x43')]({'where':{'id':_0x271288[_0x359b('0x63')]['id']}})['then'](handleEntityNotFound(_0x4bea92,null))[_0x359b('0x22')](function(_0x561090){if(_0x561090){return _0x561090['addOpenchannelInteractions'](_0x271288[_0x359b('0x68')][_0x359b('0x6b')],_[_0x359b('0x11d')](_0x271288[_0x359b('0x68')],[_0x359b('0x6b'),'id'])||{})['spread'](function(){for(var _0x1904df=0x0;_0x1904df<_0x271288['body']['ids']['length'];_0x1904df+=0x1){socket[_0x359b('0xa1')]('user_has_openchannel_interactions:save',{'OpenchannelInteractionId':Number(_0x271288[_0x359b('0x68')]['ids'][_0x1904df]),'UserId':Number(_0x271288[_0x359b('0x63')]['id'])});}return _0x271288[_0x359b('0x68')][_0x359b('0x6b')];});}})['then'](respondWithResult(_0x4bea92,null))[_0x359b('0x2c')](handleError(_0x4bea92,null));};exports['removeOpenchannelInteractions']=function(_0x3b1909,_0x4b13c2,_0x10caf1){return db[_0x359b('0x48')]['find']({'where':{'id':_0x3b1909[_0x359b('0x63')]['id']}})[_0x359b('0x22')](handleEntityNotFound(_0x4b13c2,null))[_0x359b('0x22')](function(_0x30b890){if(_0x30b890){return _0x30b890[_0x359b('0x12d')](_0x3b1909[_0x359b('0x50')][_0x359b('0x6b')])[_0x359b('0x22')](function(){if(_[_0x359b('0x123')](_0x3b1909[_0x359b('0x50')]['ids'])){for(var _0x530b25=0x0;_0x530b25<_0x3b1909[_0x359b('0x50')][_0x359b('0x6b')][_0x359b('0x66')];_0x530b25+=0x1){socket['emit']('user_has_openchannel_interactions:remove',{'OpenchannelInteractionId':Number(_0x3b1909[_0x359b('0x50')]['ids'][_0x530b25]),'UserId':Number(_0x3b1909[_0x359b('0x63')]['id'])});}}else{socket[_0x359b('0xa1')](_0x359b('0x12e'),{'OpenchannelInteractionId':Number(_0x3b1909[_0x359b('0x50')][_0x359b('0x6b')]),'UserId':Number(_0x3b1909['params']['id'])});}});}})[_0x359b('0x22')](respondWithStatusCode(_0x4b13c2,null))[_0x359b('0x2c')](handleError(_0x4b13c2,null));};exports[_0x359b('0x12f')]=function(_0x77b405,_0x5105d3,_0x2c9b7e){return db[_0x359b('0x48')]['find']({'where':{'id':_0x77b405[_0x359b('0x63')]['id']}})['then'](handleEntityNotFound(_0x5105d3,null))[_0x359b('0x22')](function(_0x3755ce){if(_0x3755ce){return _0x3755ce[_0x359b('0x12f')](_0x77b405[_0x359b('0x68')][_0x359b('0x6b')],_[_0x359b('0x11d')](_0x77b405[_0x359b('0x68')],[_0x359b('0x6b'),'id'])||{})['spread'](function(){for(var _0x45754d=0x0;_0x45754d<_0x77b405[_0x359b('0x68')][_0x359b('0x6b')][_0x359b('0x66')];_0x45754d+=0x1){socket[_0x359b('0xa1')](_0x359b('0x130'),{'WhatsappInteractionId':Number(_0x77b405[_0x359b('0x68')][_0x359b('0x6b')][_0x45754d]),'UserId':Number(_0x77b405[_0x359b('0x63')]['id'])});}return _0x77b405[_0x359b('0x68')][_0x359b('0x6b')];});}})['then'](respondWithResult(_0x5105d3,null))[_0x359b('0x2c')](handleError(_0x5105d3,null));};exports[_0x359b('0x131')]=function(_0x14cfd2,_0x13cd14,_0xcfad0a){return db[_0x359b('0x48')][_0x359b('0x43')]({'where':{'id':_0x14cfd2['params']['id']}})[_0x359b('0x22')](handleEntityNotFound(_0x13cd14,null))[_0x359b('0x22')](function(_0x301e02){if(_0x301e02){return _0x301e02[_0x359b('0x131')](_0x14cfd2[_0x359b('0x50')][_0x359b('0x6b')]);}})['then'](respondWithStatusCode(_0x13cd14,null))[_0x359b('0x2c')](handleError(_0x13cd14,null));};exports['getVoicePrefixes']=function(_0x388acf,_0x37ac70,_0x40c692){var _0x569fcd={};var _0x4e8291={};var _0x3470f3;var _0x33918f;return db['User'][_0x359b('0xb7')]({'where':{'id':_0x388acf[_0x359b('0x63')]['id']}})['then'](handleEntityNotFound(_0x37ac70,null))[_0x359b('0x22')](function(_0x45b692){if(_0x45b692){_0x3470f3=_0x45b692;_0x4e8291[_0x359b('0x4d')]=_['keys'](db[_0x359b('0x132')][_0x359b('0x49')]);_0x4e8291['query']=_[_0x359b('0x64')](_0x388acf['query']);_0x4e8291['filters']=_[_0x359b('0x52')](_0x4e8291[_0x359b('0x4d')],_0x4e8291[_0x359b('0x50')]);_0x569fcd[_0x359b('0x53')]=_[_0x359b('0x52')](_0x4e8291[_0x359b('0x4d')],qs[_0x359b('0x54')](_0x388acf[_0x359b('0x50')]['fields']));_0x569fcd['attributes']=_0x569fcd[_0x359b('0x53')][_0x359b('0x66')]?_0x569fcd[_0x359b('0x53')]:_0x4e8291[_0x359b('0x4d')];_0x569fcd[_0x359b('0x57')]=qs[_0x359b('0x58')](_0x388acf[_0x359b('0x50')][_0x359b('0x58')]);_0x569fcd[_0x359b('0x59')]=qs[_0x359b('0x51')](_[_0x359b('0xb9')](_0x388acf[_0x359b('0x50')],_0x4e8291[_0x359b('0x51')]));if(_0x388acf['query'][_0x359b('0x3d')]){_0x569fcd[_0x359b('0x59')]=_[_0x359b('0x5a')](_0x569fcd[_0x359b('0x59')],{'$or':_[_0x359b('0x3f')](_0x569fcd[_0x359b('0x53')],function(_0x34f6be){var _0x57b40f={};_0x57b40f[_0x34f6be]={'$like':'%'+_0x388acf[_0x359b('0x50')][_0x359b('0x3d')]+'%'};return _0x57b40f;})});}_0x569fcd=_['merge']({},_0x569fcd,_0x388acf['options']);return _0x3470f3['getVoicePrefixes'](_0x569fcd);}})[_0x359b('0x22')](function(_0x28f413){if(_0x28f413){_0x33918f=_0x28f413['length'];if(!_0x388acf[_0x359b('0x50')][_0x359b('0x55')](_0x359b('0x56'))){_0x569fcd[_0x359b('0x33')]=qs['limit'](_0x388acf[_0x359b('0x50')][_0x359b('0x33')]);_0x569fcd[_0x359b('0x32')]=qs[_0x359b('0x32')](_0x388acf[_0x359b('0x50')][_0x359b('0x32')]);}return _0x3470f3[_0x359b('0x133')](_0x569fcd);}})[_0x359b('0x22')](function(_0x354734){if(_0x354734){return _0x354734?{'count':_0x33918f,'rows':_0x354734}:null;}})[_0x359b('0x22')](respondWithResult(_0x37ac70,null))[_0x359b('0x2c')](handleError(_0x37ac70,null));};exports[_0x359b('0x134')]=function(_0x5d0bd7,_0x503899,_0xd3c07f){var _0x7927c={};var _0x3497ae={};var _0x116353;var _0x339b5b;return db[_0x359b('0x48')][_0x359b('0xb7')]({'where':{'id':_0x5d0bd7['params']['id']}})[_0x359b('0x22')](handleEntityNotFound(_0x503899,null))[_0x359b('0x22')](function(_0x2d59ed){if(_0x2d59ed){_0x116353=_0x2d59ed;_0x3497ae['model']=_[_0x359b('0x64')](db[_0x359b('0x135')][_0x359b('0x49')]);_0x3497ae['query']=_[_0x359b('0x64')](_0x5d0bd7[_0x359b('0x50')]);_0x3497ae['filters']=_['intersection'](_0x3497ae[_0x359b('0x4d')],_0x3497ae[_0x359b('0x50')]);_0x7927c['attributes']=_['intersection'](_0x3497ae['model'],qs['fields'](_0x5d0bd7[_0x359b('0x50')]['fields']));_0x7927c[_0x359b('0x53')]=_0x7927c[_0x359b('0x53')]['length']?_0x7927c[_0x359b('0x53')]:_0x3497ae[_0x359b('0x4d')];_0x7927c[_0x359b('0x57')]=qs['sort'](_0x5d0bd7['query'][_0x359b('0x58')]);_0x7927c[_0x359b('0x59')]=qs[_0x359b('0x51')](_[_0x359b('0xb9')](_0x5d0bd7[_0x359b('0x50')],_0x3497ae[_0x359b('0x51')]));if(_0x5d0bd7['query'][_0x359b('0x3d')]){_0x7927c[_0x359b('0x59')]=_[_0x359b('0x5a')](_0x7927c[_0x359b('0x59')],{'$or':_[_0x359b('0x3f')](_0x7927c[_0x359b('0x53')],function(_0x533fa4){var _0x55eaf0={};_0x55eaf0[_0x533fa4]={'$like':'%'+_0x5d0bd7[_0x359b('0x50')]['filter']+'%'};return _0x55eaf0;})});}_0x7927c=_[_0x359b('0x5a')]({},_0x7927c,_0x5d0bd7[_0x359b('0x5e')]);return _0x116353[_0x359b('0x134')](_0x7927c);}})[_0x359b('0x22')](function(_0x4f2d2b){if(_0x4f2d2b){_0x339b5b=_0x4f2d2b[_0x359b('0x66')];if(!_0x5d0bd7[_0x359b('0x50')]['hasOwnProperty']('nolimit')){_0x7927c[_0x359b('0x33')]=qs[_0x359b('0x33')](_0x5d0bd7[_0x359b('0x50')][_0x359b('0x33')]);_0x7927c[_0x359b('0x32')]=qs['offset'](_0x5d0bd7['query'][_0x359b('0x32')]);}return _0x116353[_0x359b('0x134')](_0x7927c);}})['then'](function(_0x14140c){if(_0x14140c){return _0x14140c?{'count':_0x339b5b,'rows':_0x14140c}:null;}})[_0x359b('0x22')](respondWithResult(_0x503899,null))[_0x359b('0x2c')](handleError(_0x503899,null));};exports[_0x359b('0x136')]=function(_0x1ef199,_0x100ab6,_0x327876){return db[_0x359b('0x48')]['find']({'where':{'id':_0x1ef199[_0x359b('0x63')]['id']}})[_0x359b('0x22')](handleEntityNotFound(_0x100ab6,null))[_0x359b('0x22')](function(_0x41b692){if(_0x41b692){return _0x41b692[_0x359b('0x136')](_0x1ef199['body'][_0x359b('0x6b')],_[_0x359b('0x11d')](_0x1ef199[_0x359b('0x68')],[_0x359b('0x6b'),'id'])||{});}})[_0x359b('0x22')](respondWithResult(_0x100ab6,null))[_0x359b('0x2c')](handleError(_0x100ab6,null));};exports[_0x359b('0x137')]=function(_0x5bbcba,_0x5533e1,_0x53a0d9){return db[_0x359b('0x48')][_0x359b('0x43')]({'where':{'id':_0x5bbcba[_0x359b('0x63')]['id']}})[_0x359b('0x22')](handleEntityNotFound(_0x5533e1,null))[_0x359b('0x22')](function(_0x95f6a){if(_0x95f6a){return _0x95f6a[_0x359b('0x137')](_0x5bbcba[_0x359b('0x50')][_0x359b('0x6b')]);}})[_0x359b('0x22')](respondWithStatusCode(_0x5533e1,null))[_0x359b('0x2c')](handleError(_0x5533e1,null));};exports['getMailAccounts']=function(_0x55b6a3,_0x33f065,_0x1839c1){var _0x406723={};var _0x554723={};var _0x5ae5a3;var _0x115e87;return db[_0x359b('0x48')][_0x359b('0xb7')]({'where':{'id':_0x55b6a3['params']['id']}})[_0x359b('0x22')](handleEntityNotFound(_0x33f065,null))[_0x359b('0x22')](function(_0x22012c){if(_0x22012c){_0x5ae5a3=_0x22012c;_0x554723[_0x359b('0x4d')]=_['keys'](db[_0x359b('0x138')]['rawAttributes']);_0x554723['query']=_[_0x359b('0x64')](_0x55b6a3['query']);_0x554723['filters']=_[_0x359b('0x52')](_0x554723[_0x359b('0x4d')],_0x554723[_0x359b('0x50')]);_0x406723[_0x359b('0x53')]=_['intersection'](_0x554723[_0x359b('0x4d')],qs['fields'](_0x55b6a3[_0x359b('0x50')][_0x359b('0x54')]));_0x406723[_0x359b('0x53')]=_0x406723[_0x359b('0x53')][_0x359b('0x66')]?_0x406723[_0x359b('0x53')]:_0x554723[_0x359b('0x4d')];_0x406723['order']=qs[_0x359b('0x58')](_0x55b6a3[_0x359b('0x50')]['sort']);_0x406723['where']=qs['filters'](_['pick'](_0x55b6a3[_0x359b('0x50')],_0x554723[_0x359b('0x51')]));if(_0x55b6a3[_0x359b('0x50')]['filter']){_0x406723[_0x359b('0x59')]=_['merge'](_0x406723['where'],{'$or':_[_0x359b('0x3f')](_0x406723[_0x359b('0x53')],function(_0xb94191){var _0x348235={};_0x348235[_0xb94191]={'$like':'%'+_0x55b6a3[_0x359b('0x50')][_0x359b('0x3d')]+'%'};return _0x348235;})});}_0x406723=_[_0x359b('0x5a')]({},_0x406723,_0x55b6a3['options']);return _0x5ae5a3[_0x359b('0x139')](_0x406723);}})['then'](function(_0x2c2c86){if(_0x2c2c86){_0x115e87=_0x2c2c86[_0x359b('0x66')];if(!_0x55b6a3[_0x359b('0x50')][_0x359b('0x55')](_0x359b('0x56'))){_0x406723[_0x359b('0x33')]=qs['limit'](_0x55b6a3['query'][_0x359b('0x33')]);_0x406723[_0x359b('0x32')]=qs[_0x359b('0x32')](_0x55b6a3[_0x359b('0x50')][_0x359b('0x32')]);}return _0x5ae5a3[_0x359b('0x139')](_0x406723);}})[_0x359b('0x22')](function(_0x24945e){if(_0x24945e){return _0x24945e?{'count':_0x115e87,'rows':_0x24945e}:null;}})[_0x359b('0x22')](respondWithResult(_0x33f065,null))[_0x359b('0x2c')](handleError(_0x33f065,null));};exports['addMailAccounts']=function(_0xeb3dbc,_0x251a9b,_0x490fd8){return db[_0x359b('0x48')][_0x359b('0x43')]({'where':{'id':_0xeb3dbc['params']['id']}})[_0x359b('0x22')](handleEntityNotFound(_0x251a9b,null))[_0x359b('0x22')](function(_0x3a4aac){if(_0x3a4aac){return _0x3a4aac['addMailAccounts'](_0xeb3dbc[_0x359b('0x68')][_0x359b('0x6b')],_['omit'](_0xeb3dbc[_0x359b('0x68')],[_0x359b('0x6b'),'id'])||{});}})['then'](respondWithResult(_0x251a9b,null))[_0x359b('0x2c')](handleError(_0x251a9b,null));};exports[_0x359b('0x13a')]=function(_0x497282,_0x38d90c,_0x386cff){return db[_0x359b('0x48')][_0x359b('0x43')]({'where':{'id':_0x497282[_0x359b('0x63')]['id']}})[_0x359b('0x22')](handleEntityNotFound(_0x38d90c,null))[_0x359b('0x22')](function(_0x46ea95){if(_0x46ea95){return _0x46ea95[_0x359b('0x13a')](_0x497282[_0x359b('0x50')][_0x359b('0x6b')]);}})[_0x359b('0x22')](respondWithStatusCode(_0x38d90c,null))[_0x359b('0x2c')](handleError(_0x38d90c,null));};exports[_0x359b('0x13b')]=function(_0x14530a,_0x2ecc0b,_0x49ca8b){var _0x57e0df={};var _0x358b49={};var _0x3592b4;var _0x296d3c;return db[_0x359b('0x48')][_0x359b('0xb7')]({'where':{'id':_0x14530a[_0x359b('0x63')]['id']}})['then'](handleEntityNotFound(_0x2ecc0b,null))[_0x359b('0x22')](function(_0x403db9){if(_0x403db9){_0x3592b4=_0x403db9;_0x358b49[_0x359b('0x4d')]=_[_0x359b('0x64')](db[_0x359b('0x13c')][_0x359b('0x49')]);_0x358b49[_0x359b('0x50')]=_[_0x359b('0x64')](_0x14530a[_0x359b('0x50')]);_0x358b49[_0x359b('0x51')]=_['intersection'](_0x358b49[_0x359b('0x4d')],_0x358b49[_0x359b('0x50')]);_0x57e0df[_0x359b('0x53')]=_[_0x359b('0x52')](_0x358b49[_0x359b('0x4d')],qs[_0x359b('0x54')](_0x14530a['query'][_0x359b('0x54')]));_0x57e0df[_0x359b('0x53')]=_0x57e0df['attributes'][_0x359b('0x66')]?_0x57e0df[_0x359b('0x53')]:_0x358b49[_0x359b('0x4d')];_0x57e0df[_0x359b('0x57')]=qs['sort'](_0x14530a[_0x359b('0x50')][_0x359b('0x58')]);_0x57e0df[_0x359b('0x59')]=qs[_0x359b('0x51')](_[_0x359b('0xb9')](_0x14530a[_0x359b('0x50')],_0x358b49[_0x359b('0x51')]));if(_0x14530a[_0x359b('0x50')][_0x359b('0x3d')]){_0x57e0df[_0x359b('0x59')]=_[_0x359b('0x5a')](_0x57e0df[_0x359b('0x59')],{'$or':_[_0x359b('0x3f')](_0x57e0df[_0x359b('0x53')],function(_0x173b3e){var _0x59441c={};_0x59441c[_0x173b3e]={'$like':'%'+_0x14530a[_0x359b('0x50')][_0x359b('0x3d')]+'%'};return _0x59441c;})});}_0x57e0df=_[_0x359b('0x5a')]({},_0x57e0df,_0x14530a[_0x359b('0x5e')]);return _0x3592b4[_0x359b('0x13b')](_0x57e0df);}})[_0x359b('0x22')](function(_0x54701d){if(_0x54701d){_0x296d3c=_0x54701d[_0x359b('0x66')];if(!_0x14530a[_0x359b('0x50')][_0x359b('0x55')](_0x359b('0x56'))){_0x57e0df[_0x359b('0x33')]=qs[_0x359b('0x33')](_0x14530a[_0x359b('0x50')]['limit']);_0x57e0df[_0x359b('0x32')]=qs[_0x359b('0x32')](_0x14530a['query'][_0x359b('0x32')]);}return _0x3592b4['getOpenchannelAccounts'](_0x57e0df);}})[_0x359b('0x22')](function(_0x40fbd1){if(_0x40fbd1){return _0x40fbd1?{'count':_0x296d3c,'rows':_0x40fbd1}:null;}})[_0x359b('0x22')](respondWithResult(_0x2ecc0b,null))[_0x359b('0x2c')](handleError(_0x2ecc0b,null));};exports[_0x359b('0x13d')]=function(_0x378f8d,_0x329485,_0x2898ed){return db[_0x359b('0x48')][_0x359b('0x43')]({'where':{'id':_0x378f8d[_0x359b('0x63')]['id']}})[_0x359b('0x22')](handleEntityNotFound(_0x329485,null))[_0x359b('0x22')](function(_0xd4d2f0){if(_0xd4d2f0){return _0xd4d2f0[_0x359b('0x13d')](_0x378f8d[_0x359b('0x68')][_0x359b('0x6b')],_['omit'](_0x378f8d[_0x359b('0x68')],['ids','id'])||{});}})[_0x359b('0x22')](respondWithResult(_0x329485,null))['catch'](handleError(_0x329485,null));};exports[_0x359b('0x13e')]=function(_0x3d5517,_0x3a94bb,_0x2ddae9){return db[_0x359b('0x48')][_0x359b('0x43')]({'where':{'id':_0x3d5517[_0x359b('0x63')]['id']}})[_0x359b('0x22')](handleEntityNotFound(_0x3a94bb,null))[_0x359b('0x22')](function(_0x3f2f20){if(_0x3f2f20){return _0x3f2f20['removeOpenchannelAccounts'](_0x3d5517[_0x359b('0x50')][_0x359b('0x6b')]);}})[_0x359b('0x22')](respondWithStatusCode(_0x3a94bb,null))[_0x359b('0x2c')](handleError(_0x3a94bb,null));};exports[_0x359b('0x13f')]=function(_0x31396f,_0x53ea40,_0x57e5ff){var _0x46ede9={};var _0x53a223={};var _0x11e89e;var _0x1c8716;return db['User'][_0x359b('0xb7')]({'where':{'id':_0x31396f['params']['id']}})[_0x359b('0x22')](handleEntityNotFound(_0x53ea40,null))[_0x359b('0x22')](function(_0x34ba96){if(_0x34ba96){_0x11e89e=_0x34ba96;_0x53a223['model']=_[_0x359b('0x64')](db[_0x359b('0x140')][_0x359b('0x49')]);_0x53a223[_0x359b('0x50')]=_[_0x359b('0x64')](_0x31396f[_0x359b('0x50')]);_0x53a223[_0x359b('0x51')]=_['intersection'](_0x53a223['model'],_0x53a223['query']);_0x46ede9[_0x359b('0x53')]=_[_0x359b('0x52')](_0x53a223[_0x359b('0x4d')],qs['fields'](_0x31396f['query'][_0x359b('0x54')]));_0x46ede9[_0x359b('0x53')]=_0x46ede9[_0x359b('0x53')][_0x359b('0x66')]?_0x46ede9['attributes']:_0x53a223[_0x359b('0x4d')];_0x46ede9[_0x359b('0x57')]=qs['sort'](_0x31396f[_0x359b('0x50')][_0x359b('0x58')]);_0x46ede9[_0x359b('0x59')]=qs[_0x359b('0x51')](_[_0x359b('0xb9')](_0x31396f[_0x359b('0x50')],_0x53a223[_0x359b('0x51')]));if(_0x31396f['query'][_0x359b('0x3d')]){_0x46ede9[_0x359b('0x59')]=_['merge'](_0x46ede9[_0x359b('0x59')],{'$or':_[_0x359b('0x3f')](_0x46ede9[_0x359b('0x53')],function(_0x2dc7da){var _0x32c156={};_0x32c156[_0x2dc7da]={'$like':'%'+_0x31396f[_0x359b('0x50')][_0x359b('0x3d')]+'%'};return _0x32c156;})});}_0x46ede9=_['merge']({},_0x46ede9,_0x31396f[_0x359b('0x5e')]);return _0x11e89e['getSmsAccounts'](_0x46ede9);}})['then'](function(_0x40c265){if(_0x40c265){_0x1c8716=_0x40c265[_0x359b('0x66')];if(!_0x31396f[_0x359b('0x50')][_0x359b('0x55')](_0x359b('0x56'))){_0x46ede9[_0x359b('0x33')]=qs['limit'](_0x31396f['query'][_0x359b('0x33')]);_0x46ede9[_0x359b('0x32')]=qs['offset'](_0x31396f[_0x359b('0x50')]['offset']);}return _0x11e89e[_0x359b('0x13f')](_0x46ede9);}})[_0x359b('0x22')](function(_0x3d8af6){if(_0x3d8af6){return _0x3d8af6?{'count':_0x1c8716,'rows':_0x3d8af6}:null;}})[_0x359b('0x22')](respondWithResult(_0x53ea40,null))[_0x359b('0x2c')](handleError(_0x53ea40,null));};exports['addSmsAccounts']=function(_0x270f9c,_0x15d28f,_0x49f753){return db['User'][_0x359b('0x43')]({'where':{'id':_0x270f9c[_0x359b('0x63')]['id']}})['then'](handleEntityNotFound(_0x15d28f,null))[_0x359b('0x22')](function(_0x435679){if(_0x435679){return _0x435679[_0x359b('0x141')](_0x270f9c[_0x359b('0x68')]['ids'],_[_0x359b('0x11d')](_0x270f9c[_0x359b('0x68')],[_0x359b('0x6b'),'id'])||{});}})[_0x359b('0x22')](respondWithResult(_0x15d28f,null))[_0x359b('0x2c')](handleError(_0x15d28f,null));};exports[_0x359b('0x142')]=function(_0x1622c5,_0x255c82,_0x3efe4f){return db[_0x359b('0x48')]['find']({'where':{'id':_0x1622c5['params']['id']}})[_0x359b('0x22')](handleEntityNotFound(_0x255c82,null))[_0x359b('0x22')](function(_0x9519cd){if(_0x9519cd){return _0x9519cd[_0x359b('0x142')](_0x1622c5[_0x359b('0x50')][_0x359b('0x6b')]);}})[_0x359b('0x22')](respondWithStatusCode(_0x255c82,null))[_0x359b('0x2c')](handleError(_0x255c82,null));};exports['getChatWebsites']=function(_0x346f35,_0x453429,_0x1f848b){var _0x4e45ee={};var _0x41c316={};var _0x52a7ff;var _0x2737b8;return db[_0x359b('0x48')][_0x359b('0xb7')]({'where':{'id':_0x346f35[_0x359b('0x63')]['id']}})[_0x359b('0x22')](handleEntityNotFound(_0x453429,null))[_0x359b('0x22')](function(_0x43dce9){if(_0x43dce9){_0x52a7ff=_0x43dce9;_0x41c316[_0x359b('0x4d')]=_['keys'](db[_0x359b('0x143')]['rawAttributes']);_0x41c316[_0x359b('0x50')]=_[_0x359b('0x64')](_0x346f35[_0x359b('0x50')]);_0x41c316['filters']=_[_0x359b('0x52')](_0x41c316['model'],_0x41c316[_0x359b('0x50')]);_0x4e45ee['attributes']=_[_0x359b('0x52')](_0x41c316[_0x359b('0x4d')],qs[_0x359b('0x54')](_0x346f35[_0x359b('0x50')][_0x359b('0x54')]));_0x4e45ee[_0x359b('0x53')]=_0x4e45ee[_0x359b('0x53')][_0x359b('0x66')]?_0x4e45ee[_0x359b('0x53')]:_0x41c316[_0x359b('0x4d')];_0x4e45ee['order']=qs[_0x359b('0x58')](_0x346f35[_0x359b('0x50')][_0x359b('0x58')]);_0x4e45ee[_0x359b('0x59')]=qs[_0x359b('0x51')](_[_0x359b('0xb9')](_0x346f35['query'],_0x41c316[_0x359b('0x51')]));if(_0x346f35[_0x359b('0x50')][_0x359b('0x3d')]){_0x4e45ee[_0x359b('0x59')]=_[_0x359b('0x5a')](_0x4e45ee[_0x359b('0x59')],{'$or':_['map'](_0x4e45ee[_0x359b('0x53')],function(_0x329908){var _0x389855={};_0x389855[_0x329908]={'$like':'%'+_0x346f35[_0x359b('0x50')]['filter']+'%'};return _0x389855;})});}_0x4e45ee=_[_0x359b('0x5a')]({},_0x4e45ee,_0x346f35[_0x359b('0x5e')]);return _0x52a7ff['getChatWebsites'](_0x4e45ee);}})[_0x359b('0x22')](function(_0x1e9f1f){if(_0x1e9f1f){_0x2737b8=_0x1e9f1f[_0x359b('0x66')];if(!_0x346f35[_0x359b('0x50')][_0x359b('0x55')](_0x359b('0x56'))){_0x4e45ee[_0x359b('0x33')]=qs[_0x359b('0x33')](_0x346f35[_0x359b('0x50')]['limit']);_0x4e45ee['offset']=qs['offset'](_0x346f35[_0x359b('0x50')][_0x359b('0x32')]);}return _0x52a7ff[_0x359b('0x144')](_0x4e45ee);}})[_0x359b('0x22')](function(_0x3f860d){if(_0x3f860d){return _0x3f860d?{'count':_0x2737b8,'rows':_0x3f860d}:null;}})['then'](respondWithResult(_0x453429,null))[_0x359b('0x2c')](handleError(_0x453429,null));};exports['addChatWebsites']=function(_0x40bb62,_0x2e65d2,_0xce08d2){return db[_0x359b('0x48')][_0x359b('0x43')]({'where':{'id':_0x40bb62[_0x359b('0x63')]['id']}})[_0x359b('0x22')](handleEntityNotFound(_0x2e65d2,null))[_0x359b('0x22')](function(_0x14244e){if(_0x14244e){return _0x14244e[_0x359b('0x145')](_0x40bb62[_0x359b('0x68')]['ids'],_[_0x359b('0x11d')](_0x40bb62['body'],['ids','id'])||{});}})[_0x359b('0x22')](respondWithResult(_0x2e65d2,null))['catch'](handleError(_0x2e65d2,null));};exports[_0x359b('0x146')]=function(_0x3243fc,_0x1d6288,_0x2f88b8){return db[_0x359b('0x48')][_0x359b('0x43')]({'where':{'id':_0x3243fc[_0x359b('0x63')]['id']}})[_0x359b('0x22')](handleEntityNotFound(_0x1d6288,null))[_0x359b('0x22')](function(_0x13de41){if(_0x13de41){return _0x13de41[_0x359b('0x146')](_0x3243fc['query'][_0x359b('0x6b')]);}})['then'](respondWithStatusCode(_0x1d6288,null))[_0x359b('0x2c')](handleError(_0x1d6288,null));};exports[_0x359b('0x147')]=function(_0x5839b9,_0x5db50d,_0x1a39d4){var _0x1fe762={};var _0x5d42f6={};var _0x1bf77e;var _0x3a694e;return db[_0x359b('0x48')]['findOne']({'where':{'id':_0x5839b9[_0x359b('0x63')]['id']}})[_0x359b('0x22')](handleEntityNotFound(_0x5db50d,null))[_0x359b('0x22')](function(_0x201061){if(_0x201061){_0x1bf77e=_0x201061;_0x5d42f6['model']=_[_0x359b('0x64')](db['WhatsappAccount']['rawAttributes']);_0x5d42f6[_0x359b('0x50')]=_[_0x359b('0x64')](_0x5839b9[_0x359b('0x50')]);_0x5d42f6[_0x359b('0x51')]=_[_0x359b('0x52')](_0x5d42f6[_0x359b('0x4d')],_0x5d42f6['query']);_0x1fe762[_0x359b('0x53')]=_[_0x359b('0x52')](_0x5d42f6[_0x359b('0x4d')],qs[_0x359b('0x54')](_0x5839b9[_0x359b('0x50')][_0x359b('0x54')]));_0x1fe762[_0x359b('0x53')]=_0x1fe762[_0x359b('0x53')][_0x359b('0x66')]?_0x1fe762[_0x359b('0x53')]:_0x5d42f6[_0x359b('0x4d')];_0x1fe762['order']=qs['sort'](_0x5839b9[_0x359b('0x50')][_0x359b('0x58')]);_0x1fe762['where']=qs[_0x359b('0x51')](_[_0x359b('0xb9')](_0x5839b9[_0x359b('0x50')],_0x5d42f6[_0x359b('0x51')]));if(_0x5839b9[_0x359b('0x50')]['filter']){_0x1fe762['where']=_[_0x359b('0x5a')](_0x1fe762[_0x359b('0x59')],{'$or':_[_0x359b('0x3f')](_0x1fe762['attributes'],function(_0x4bffca){var _0x43778f={};_0x43778f[_0x4bffca]={'$like':'%'+_0x5839b9['query']['filter']+'%'};return _0x43778f;})});}_0x1fe762=_['merge']({},_0x1fe762,_0x5839b9['options']);return _0x1bf77e[_0x359b('0x147')](_0x1fe762);}})[_0x359b('0x22')](function(_0x22fb4f){if(_0x22fb4f){_0x3a694e=_0x22fb4f[_0x359b('0x66')];if(!_0x5839b9[_0x359b('0x50')][_0x359b('0x55')](_0x359b('0x56'))){_0x1fe762[_0x359b('0x33')]=qs[_0x359b('0x33')](_0x5839b9[_0x359b('0x50')]['limit']);_0x1fe762[_0x359b('0x32')]=qs['offset'](_0x5839b9[_0x359b('0x50')][_0x359b('0x32')]);}return _0x1bf77e['getWhatsappAccounts'](_0x1fe762);}})[_0x359b('0x22')](function(_0x5bd152){if(_0x5bd152){return _0x5bd152?{'count':_0x3a694e,'rows':_0x5bd152}:null;}})[_0x359b('0x22')](respondWithResult(_0x5db50d,null))[_0x359b('0x2c')](handleError(_0x5db50d,null));};exports['addWhatsappAccounts']=function(_0x714bc2,_0x7ab5b3,_0x179d09){return db[_0x359b('0x48')]['find']({'where':{'id':_0x714bc2[_0x359b('0x63')]['id']}})[_0x359b('0x22')](handleEntityNotFound(_0x7ab5b3,null))[_0x359b('0x22')](function(_0x1eb6cc){if(_0x1eb6cc){return _0x1eb6cc[_0x359b('0x148')](_0x714bc2['body'][_0x359b('0x6b')],_[_0x359b('0x11d')](_0x714bc2[_0x359b('0x68')],['ids','id'])||{});}})[_0x359b('0x22')](respondWithResult(_0x7ab5b3,null))[_0x359b('0x2c')](handleError(_0x7ab5b3,null));};exports['removeWhatsappAccounts']=function(_0x46748f,_0x41b88,_0x2f2bfb){return db[_0x359b('0x48')][_0x359b('0x43')]({'where':{'id':_0x46748f[_0x359b('0x63')]['id']}})[_0x359b('0x22')](handleEntityNotFound(_0x41b88,null))[_0x359b('0x22')](function(_0x577fe1){if(_0x577fe1){return _0x577fe1[_0x359b('0x149')](_0x46748f[_0x359b('0x50')][_0x359b('0x6b')]);}})['then'](respondWithStatusCode(_0x41b88,null))['catch'](handleError(_0x41b88,null));};exports[_0x359b('0x14a')]=function(_0x4a9a7d,_0x25317e,_0x1539c8){var _0x340c30={};var _0x51e3f1={};var _0x40a6ae;var _0x1669a5;return db[_0x359b('0x48')]['findOne']({'where':{'id':_0x4a9a7d[_0x359b('0x63')]['id']}})[_0x359b('0x22')](handleEntityNotFound(_0x25317e,null))['then'](function(_0x987510){if(_0x987510){_0x40a6ae=_0x987510;_0x51e3f1[_0x359b('0x4d')]=_[_0x359b('0x64')](db[_0x359b('0x14b')][_0x359b('0x49')]);_0x51e3f1['query']=_[_0x359b('0x64')](_0x4a9a7d[_0x359b('0x50')]);_0x51e3f1[_0x359b('0x51')]=_[_0x359b('0x52')](_0x51e3f1[_0x359b('0x4d')],_0x51e3f1[_0x359b('0x50')]);_0x340c30['attributes']=_['intersection'](_0x51e3f1['model'],qs[_0x359b('0x54')](_0x4a9a7d[_0x359b('0x50')]['fields']));_0x340c30[_0x359b('0x53')]=_0x340c30[_0x359b('0x53')][_0x359b('0x66')]?_0x340c30[_0x359b('0x53')]:_0x51e3f1[_0x359b('0x4d')];_0x340c30[_0x359b('0x57')]=qs[_0x359b('0x58')](_0x4a9a7d[_0x359b('0x50')][_0x359b('0x58')]);_0x340c30[_0x359b('0x59')]=qs['filters'](_[_0x359b('0xb9')](_0x4a9a7d[_0x359b('0x50')],_0x51e3f1['filters']));if(_0x4a9a7d[_0x359b('0x50')][_0x359b('0x3d')]){_0x340c30[_0x359b('0x59')]=_[_0x359b('0x5a')](_0x340c30[_0x359b('0x59')],{'$or':_[_0x359b('0x3f')](_0x340c30[_0x359b('0x53')],function(_0x535dfb){var _0xebc044={};_0xebc044[_0x535dfb]={'$like':'%'+_0x4a9a7d[_0x359b('0x50')]['filter']+'%'};return _0xebc044;})});}_0x340c30=_[_0x359b('0x5a')]({},_0x340c30,_0x4a9a7d['options']);return _0x40a6ae[_0x359b('0x14a')](_0x340c30);}})[_0x359b('0x22')](function(_0x209230){if(_0x209230){_0x1669a5=_0x209230['length'];if(!_0x4a9a7d[_0x359b('0x50')][_0x359b('0x55')]('nolimit')){_0x340c30[_0x359b('0x33')]=qs[_0x359b('0x33')](_0x4a9a7d[_0x359b('0x50')][_0x359b('0x33')]);_0x340c30[_0x359b('0x32')]=qs['offset'](_0x4a9a7d[_0x359b('0x50')]['offset']);}return _0x40a6ae[_0x359b('0x14a')](_0x340c30);}})[_0x359b('0x22')](function(_0x145460){if(_0x145460){return _0x145460?{'count':_0x1669a5,'rows':_0x145460}:null;}})[_0x359b('0x22')](respondWithResult(_0x25317e,null))['catch'](handleError(_0x25317e,null));};exports[_0x359b('0x14c')]=function(_0x446df7,_0x5dba88,_0x29ec32){return db[_0x359b('0x48')][_0x359b('0x43')]({'where':{'id':_0x446df7['params']['id']}})[_0x359b('0x22')](handleEntityNotFound(_0x5dba88,null))[_0x359b('0x22')](function(_0x427a7f){if(_0x427a7f){return _0x427a7f[_0x359b('0x14c')](_0x446df7[_0x359b('0x68')][_0x359b('0x6b')],_[_0x359b('0x11d')](_0x446df7[_0x359b('0x68')],[_0x359b('0x6b'),'id'])||{});}})['then'](respondWithResult(_0x5dba88,null))[_0x359b('0x2c')](handleError(_0x5dba88,null));};exports['removeSquareProjects']=function(_0x983973,_0x3924fc,_0x49b6df){return db[_0x359b('0x48')][_0x359b('0x43')]({'where':{'id':_0x983973[_0x359b('0x63')]['id']}})[_0x359b('0x22')](handleEntityNotFound(_0x3924fc,null))[_0x359b('0x22')](function(_0x462a6){if(_0x462a6){return _0x462a6[_0x359b('0x14d')](_0x983973[_0x359b('0x50')][_0x359b('0x6b')]);}})['then'](respondWithStatusCode(_0x3924fc,null))[_0x359b('0x2c')](handleError(_0x3924fc,null));};exports[_0x359b('0x14e')]=function(_0x362bb0,_0x11450e){var _0x2a0c8f={},_0x4baa07={},_0x5c6735={'count':0x0,'rows':[]};var _0x2643b2=db[_0x359b('0x14f')][_0x359b('0x49')];_0x4baa07[_0x359b('0x4d')]=_[_0x359b('0x64')](_0x2643b2);_0x4baa07['query']=_[_0x359b('0x64')](_0x362bb0[_0x359b('0x50')]);_0x4baa07['filters']=_[_0x359b('0x52')](_0x4baa07[_0x359b('0x4d')],_0x4baa07[_0x359b('0x50')]);_0x4baa07['filters']=_[_0x359b('0xe6')](_0x4baa07[_0x359b('0x51')],[_0x359b('0x150'),'$or',_0x359b('0x151'),_0x359b('0x152'),_0x359b('0x153'),_0x359b('0x154'),'$ne',_0x359b('0x155'),'$not',_0x359b('0x156'),_0x359b('0x157'),_0x359b('0x158'),_0x359b('0x159'),_0x359b('0x15a'),_0x359b('0x15b'),'$iLike','$notILike',_0x359b('0x15a'),'$overlap',_0x359b('0x15c'),_0x359b('0x15d'),'$any']);_0x2a0c8f['attributes']=_[_0x359b('0x52')](_0x4baa07[_0x359b('0x4d')],qs[_0x359b('0x54')](_0x362bb0[_0x359b('0x50')][_0x359b('0x54')]));_0x2a0c8f[_0x359b('0x53')]=_0x2a0c8f['attributes'][_0x359b('0x66')]?_0x2a0c8f[_0x359b('0x53')]:_0x4baa07[_0x359b('0x4d')];if(!_0x362bb0[_0x359b('0x50')][_0x359b('0x55')]('nolimit')){_0x2a0c8f[_0x359b('0x33')]=qs[_0x359b('0x33')](_0x362bb0[_0x359b('0x50')][_0x359b('0x33')]);_0x2a0c8f[_0x359b('0x32')]=qs[_0x359b('0x32')](_0x362bb0[_0x359b('0x50')][_0x359b('0x32')]);}_0x2a0c8f['order']=qs['sort'](_0x362bb0['query'][_0x359b('0x58')]);_0x2a0c8f[_0x359b('0x59')]=qs['filters'](_[_0x359b('0xb9')](_0x362bb0[_0x359b('0x50')],_0x4baa07['filters']));if(_0x362bb0['query'][_0x359b('0x3d')]){_0x2a0c8f[_0x359b('0x59')]=_[_0x359b('0x5a')](_0x2a0c8f[_0x359b('0x59')],{'$or':_[_0x359b('0x3f')](_0x2a0c8f[_0x359b('0x53')],function(_0x1de27a){var _0x440910={};_0x440910[_0x1de27a]={'$like':'%'+_0x362bb0['query'][_0x359b('0x3d')]+'%'};return _0x440910;})});}_0x2a0c8f[_0x359b('0x59')]={'$and':[_0x2a0c8f[_0x359b('0x59')],{'$or':[{'UserId':_0x362bb0['params']['id']},{'OwnerId':_0x362bb0[_0x359b('0x63')]['id']}]}]};_0x2a0c8f=_['merge']({},_0x2a0c8f,_0x362bb0['options']);var _0x3a19e3={'where':_0x2a0c8f['where']};return db['CmHopper']['count'](_0x3a19e3)['then'](function(_0xeecd2f){_0x5c6735[_0x359b('0x31')]=_0xeecd2f;if(_0x362bb0['query'][_0x359b('0x5f')]){_0x2a0c8f[_0x359b('0x60')]=[{'attributes':['id',_0x359b('0x15e'),_0x359b('0x15f'),'phone'],'model':db[_0x359b('0xb8')],'as':_0x359b('0x160')},{'attributes':['id',_0x359b('0x44'),'dialActive'],'model':db[_0x359b('0x161')],'as':_0x359b('0xbe')}];}return db['CmHopper'][_0x359b('0xa3')](_0x2a0c8f);})[_0x359b('0x22')](function(_0x52a9d5){_0x5c6735[_0x359b('0x61')]=_0x52a9d5;return _0x5c6735;})[_0x359b('0x22')](respondWithFilteredResult(_0x11450e,_0x2a0c8f))[_0x359b('0x2c')](handleError(_0x11450e,null));};exports[_0x359b('0x162')]=function(_0x26df37,_0x492e9b,_0x5479e3){if(!_['isNil'](_0x26df37[_0x359b('0x3a')]['id'])&&(_0x26df37[_0x359b('0x3a')][_0x359b('0x42')]==_0x359b('0x6d')||_0x26df37['user'][_0x359b('0x42')]==_0x359b('0x3a'))){return db[_0x359b('0x48')][_0x359b('0xb7')]({'where':{'id':_0x26df37[_0x359b('0x63')]['id']},'raw':!![]})[_0x359b('0x22')](function(_0x5c9cdb){return authService[_0x359b('0x163')](_0x5c9cdb);})['then'](function(_0x2651de){if(_0x2651de){return _0x492e9b[_0x359b('0x2e')](0xc8)[_0x359b('0x30')]({'api_key':_0x2651de[_0x359b('0x164')]});}else{return _0x492e9b['status'](0xcc)[_0x359b('0x30')]({'message':'No\x20API\x20access\x20key\x20found!'});}})['catch'](handleError(_0x492e9b,0x193));}else{return _0x492e9b['status'](0x191)[_0x359b('0x30')]({'message':_0x359b('0x165')});}};exports[_0x359b('0x166')]=function(_0x21cb0e,_0x41f26b,_0x207134){if(!_[_0x359b('0x77')](_0x21cb0e[_0x359b('0x3a')]['id'])&&(_0x21cb0e[_0x359b('0x3a')][_0x359b('0x42')]=='admin'||_0x21cb0e['user']['role']==_0x359b('0x3a'))){return db[_0x359b('0x48')][_0x359b('0x43')]({'where':{'id':_0x21cb0e['params']['id']}})['then'](function(_0x510369){return authService[_0x359b('0x167')](_0x510369);})[_0x359b('0x22')](function(_0x15b867){return db[_0x359b('0x48')][_0x359b('0xe7')]({'apiKeyIat':_0x15b867[_0x359b('0x168')],'apiKeyNonce':_0x15b867[_0x359b('0x169')]},{'where':{'id':_0x21cb0e[_0x359b('0x63')]['id']}})[_0x359b('0x22')](function(){return _0x41f26b[_0x359b('0x2e')](0xc8)['json']({'api_key':_0x15b867['token']});});})[_0x359b('0x2c')](handleError(_0x41f26b,0x193));}else{return _0x41f26b[_0x359b('0x2e')](0x191)[_0x359b('0x30')]({'message':_0x359b('0x165')});}};exports[_0x359b('0x16a')]=function(_0x1bc998,_0x3858d5,_0x4830cc){if(!_[_0x359b('0x77')](_0x1bc998[_0x359b('0x3a')]['id'])&&(_0x1bc998[_0x359b('0x3a')][_0x359b('0x42')]==_0x359b('0x6d')||_0x1bc998[_0x359b('0x3a')][_0x359b('0x42')]=='user')){return db[_0x359b('0x48')][_0x359b('0x43')]({'where':{'id':_0x1bc998[_0x359b('0x63')]['id']}})[_0x359b('0x22')](handleEntityNotFound(_0x3858d5,null))[_0x359b('0x22')](function(_0x1ec8cc){if(_0x1ec8cc&&_0x1ec8cc['apiKeyNonce']&&_0x1ec8cc[_0x359b('0x16b')])return _0x1ec8cc;else throw{'message':_0x359b('0x16c')};})[_0x359b('0x22')](function(_0xc8a71){return db[_0x359b('0x48')][_0x359b('0xe7')]({'apiKeyNonce':null,'apiKeyIat':null},{'where':{'id':_0x1bc998[_0x359b('0x63')]['id']}});})['then'](respondWithStatusCode(_0x3858d5,0xc8))[_0x359b('0x2c')](handleError(_0x3858d5,0x193));}else{return _0x3858d5['status'](0x191)['json']({'message':_0x359b('0x165')});}};exports[_0x359b('0x16d')]=function(_0x3ae80b,_0x262f14){var _0x7930d6=_0x3ae80b[_0x359b('0x3a')][_0x359b('0x38')]({'plain':!![]});if(!_0x7930d6){return _0x262f14[_0x359b('0x2e')](0x191)[_0x359b('0x11c')]('Unable\x20to\x20retrieve\x20the\x20current\x20user');}else{return _0x262f14[_0x359b('0x2e')](0xc8)[_0x359b('0x30')](_0x7930d6);}};