58064eb5b44bc6b56d27fc9f6c22cbe299e0e8e4
[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 _0xfc64=['result','client','http','offline','idle','unknown','unavailable','ringing','busy','slice','charAt','toUpperCase','ui.','field','ui.createdAt','user_has_','_interactions','ui.UserId\x20=\x20?','OpenTabs','eml-format','rimraf','zip-dir','request-promise','moment','bluebird','mustache','util','sox','to-csv','ejs','fs-extra','lodash','squel','crypto','desk.js','querystring','papaparse','../../components/parsers/qs','../../components/parsers/advancedSearch','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','defaults','socket.io-emitter','register','request','then','User,\x20%s,\x20%s','request\x20sent','User,\x20%s,\x20%s,\x20%s','stringify','error','code','message','info','catch','sendStatus','end','status','json','undefined','limit','count','offset','set','apply','reject','destroy','get','role','Users','user','Agents','Telephones','telephone','filter','ignore','value','includes','find','name','stack','send','render','contact','agent','interaction','account','index','map','User','fieldName','type','key','model','differenceBy','password','query','filters','intersection','attributes','fields','length','hasOwnProperty','sort','pick','merge','where','VIRTUAL','sequelize','col','lower','options','includeAll','include','push','findAll','rows','openTabs','true','chat','dataValues','fax','openchannel','whatsapp','all','show','params','keys','rawAttributes','salt','sms','mail','update','body','describe','addContacts','omit','ids','Setting','findById','validatePasswordPattern','internal','min_internal','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)','from','voicemail','mailbox','VoiceMail','fullname','email','permissions','101','102','103','104','105','106','108','109','100','114','115','create','Unauthorized','Unauthorized.\x20You\x20must\x20be\x20an\x20administrator\x20in\x20order\x20to\x20create\x20an\x20user','admin','Unauthorized.\x20You\x20must\x20be\x20an\x20administrator\x20in\x20order\x20to\x20create\x20another\x20administrator','userProfileId','UserProfileSection','autoAssociation','UserProfileResource','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','bulkCreate','some','Unauthorized.\x20You\x20must\x20be\x20an\x20administrator\x20in\x20order\x20to\x20create\x20an\x20administrator','checkUserLimits','each','changePassword','oldPassword','newPassword','ValidationError','Invalid\x20body\x20format.\x20Use\x20oldPassword\x20and\x20newPassword','Sequelize','Invalid\x20body\x20format.\x20Use\x20newPassword','findOne','enforcePasswordHistory','passwordHistoryLimit','validatePasswordHistory','previousPasswords','updatePasswordsHistory','addQueues','channel','online','loginInPause','voicePause','interface','isValidChannel','add','capitalize','toLowerCase','spread','Queue:save','voice','VoiceQueue','format','SIP/%s','penalty','UserVoiceQueueRt','removeQueues','Unknown\x20channel','remove','Queues','QueueId','Queue:remove','addAvatar','userpic','file','filename','getAvatar','join','root','server/files/images/logos/default_profile.png','download','server/files/images/','getOpenTabs','ChatOpenTabs','CHAT','createdAt','FaxOpenTabs','OpenchannelOpenTabs','OPENCHANNEL','MailOpenTabs','MAIL','SmsOpenTabs','SMS','WhatsappOpenTabs','WHATSAPP','getContacts','CmList','List','Tag','color','tag','nolimit','order','Queue','Unknown\x20role','getVoiceQueuesRt','getGroups','getRecordings','UserId','VoiceRecording','getScreenRecordings','ScreenRecording','getChatInteractions','ChatInteraction','getOpenchannelInteractions','OpenchannelInteraction','getMailInteractions','MailInteraction','getSmsInteractions','FaxInteraction','getFaxInteractions','WhatsappInteraction','getWhatsappInteractions','mobile','user:%s','headers','x-forwarded-for','connection','remoteAddress','socket','getVoiceQueues','UserVoiceQueue.penalty','upsert','forEach','YYYY-MM-DD\x20HH:mm:ss','getChannels','device','PAUSE','LOGININPAUSE','MemberReport','concat','isMiddleware','resolve','logout','pause','DEFAULT\x20PAUSE','unpause','mailPause','chatPause','faxPause','openchannelPause','smsPause','whatsapppause','pauseType','QueuePause','%s%s','Pause','manual','getTeams','Team','addTeams','setDataValue','Chat','getMailQueues','Mail','getSmsQueues','Sms','Whatsapp','Fax','flatten','transaction','getDataValue','Voice','emit','removeTeams','getChatQueues','Openchannel','removeAgent','getLists','getAgents','values','You\x20can\x27t\x20delete\x20yourself','addChatInteractions','user_has_chat_interactions:save','removeChatInteractions','isArray','user_has_chat_interactions:remove','user_has_mail_interactions:save','removeMailInteractions','user_has_mail_interactions:remove','addFaxInteractions','user_has_fax_interactions:save','removeFaxInteractions','user_has_fax_interactions:remove','addSmsInteractions','user_has_sms_interactions:save','removeSmsInteractions','user_has_sms_interactions:remove','addOpenchannelInteractions','removeOpenchannelInteractions','user_has_openchannel_interactions:remove','addWhatsappInteractions','user_has_whatsapp_interactions:save','removeWhatsappInteractions','getVoicePrefixes','VoicePrefix','getFaxAccounts','addFaxAccounts','removeFaxAccounts','getMailAccounts','addMailAccounts','removeMailAccounts','OpenchannelAccount','getOpenchannelAccounts','addOpenchannelAccounts','removeOpenchannelAccounts','SmsAccount','getSmsAccounts','addSmsAccounts','removeSmsAccounts','getChatWebsites','ChatWebsite','addChatWebsites','removeChatWebsites','WhatsappAccount','getWhatsappAccounts','addWhatsappAccounts','removeWhatsappAccounts','SquareProject','getSquareProjects','addSquareProjects','removeSquareProjects','getScheduledCalls','CmHopper','$or','$gt','$gte','$lt','$ne','$notBetween','$in','$notIn','$like','$iLike','$overlap','$any','firstName','lastName','CmContact','Contact','retrieveApiKey','token','No\x20API\x20access\x20key\x20found!','You\x20don\x27t\x20have\x20sufficient\x20privileges\x20to\x20access\x20this\x20resource.','createApiKey','iat','nonce','removeApiKey','Unable\x20to\x20retrieve\x20the\x20current\x20user','getPresence','queues','teams','isEmpty','inbound','toString','desc','asc','substring','Unable\x20to\x20retrieve\x20RPC\x20agents\x20(AMI)'];(function(_0x543084,_0x4337f5){var _0x306a57=function(_0x2769ed){while(--_0x2769ed){_0x543084['push'](_0x543084['shift']());}};_0x306a57(++_0x4337f5);}(_0xfc64,0x1b3));var _0x4fc6=function(_0x1035c1,_0x2d8583){_0x1035c1=_0x1035c1-0x0;var _0x308d67=_0xfc64[_0x1035c1];return _0x308d67;};'use strict';var emlformat=require(_0x4fc6('0x0'));var rimraf=require(_0x4fc6('0x1'));var zipdir=require(_0x4fc6('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0x4fc6('0x3'));var moment=require(_0x4fc6('0x4'));var BPromise=require(_0x4fc6('0x5'));var Mustache=require(_0x4fc6('0x6'));var util=require(_0x4fc6('0x7'));var path=require('path');var sox=require(_0x4fc6('0x8'));var csv=require(_0x4fc6('0x9'));var ejs=require(_0x4fc6('0xa'));var fs=require('fs');var fs_extra=require(_0x4fc6('0xb'));var _=require(_0x4fc6('0xc'));var squel=require(_0x4fc6('0xd'));var crypto=require(_0x4fc6('0xe'));var jsforce=require('jsforce');var deskjs=require(_0x4fc6('0xf'));var toCsv=require(_0x4fc6('0x9'));var querystring=require(_0x4fc6('0x10'));var Papa=require(_0x4fc6('0x11'));var Redis=require('ioredis');var values;var authService=require('../../components/auth/service');var qs=require(_0x4fc6('0x12'));var as=require(_0x4fc6('0x13'));var hardwareService=require('../../config/license/hardware');var logger=require('../../config/logger')(_0x4fc6('0x14'));var utils=require(_0x4fc6('0x15'));var config=require(_0x4fc6('0x16'));var licenseUtil=require(_0x4fc6('0x17'));var db=require(_0x4fc6('0x18'))['db'];config[_0x4fc6('0x19')]=_[_0x4fc6('0x1a')](config[_0x4fc6('0x19')],{'host':'localhost','port':0x18eb});var socket=require(_0x4fc6('0x1b'))(new Redis(config[_0x4fc6('0x19')]));require('./user.socket')[_0x4fc6('0x1c')](socket);var jayson=require('jayson/promise');var client=jayson['client']['http']({'port':0x232a});function respondWithRpcPromise(_0xc19535,_0x43e500,_0x4810e3,_0x55426f){return new BPromise(function(_0x24a112,_0x53dfd6){var _0x40dc97=_0x55426f||client;return _0x40dc97[_0x4fc6('0x1d')](_0xc19535,_0x4810e3)[_0x4fc6('0x1e')](function(_0x22ffcc){logger['info'](_0x4fc6('0x1f'),_0x43e500,_0x4fc6('0x20'));logger['debug'](_0x4fc6('0x21'),_0x43e500,_0x4fc6('0x20'),JSON[_0x4fc6('0x22')](_0x22ffcc));if(_0x22ffcc[_0x4fc6('0x23')]){if(_0x22ffcc[_0x4fc6('0x23')][_0x4fc6('0x24')]===0x1f4){logger[_0x4fc6('0x23')](_0x4fc6('0x1f'),_0x43e500,_0x22ffcc[_0x4fc6('0x23')][_0x4fc6('0x25')]);return _0x53dfd6(_0x22ffcc[_0x4fc6('0x23')]['message']);}logger[_0x4fc6('0x23')](_0x4fc6('0x1f'),_0x43e500,_0x22ffcc[_0x4fc6('0x23')]['message']);return _0x24a112(_0x22ffcc[_0x4fc6('0x23')][_0x4fc6('0x25')]);}else{logger[_0x4fc6('0x26')]('User,\x20%s,\x20%s',_0x43e500,_0x4fc6('0x20'));_0x24a112(_0x22ffcc['result'][_0x4fc6('0x25')]);}})[_0x4fc6('0x27')](function(_0x13cdb1){logger[_0x4fc6('0x23')](_0x4fc6('0x1f'),_0x43e500,_0x13cdb1);_0x53dfd6(_0x13cdb1);});});}function respondWithStatusCode(_0x354ee7,_0x4c62b3){_0x4c62b3=_0x4c62b3||0xcc;return function(_0x16632c){if(_0x16632c){return _0x354ee7[_0x4fc6('0x28')](_0x4c62b3);}return _0x354ee7['status'](_0x4c62b3)[_0x4fc6('0x29')]();};}function respondWithResult(_0x4320de,_0xc9be8b){_0xc9be8b=_0xc9be8b||0xc8;return function(_0x40f240){if(_0x40f240){return _0x4320de[_0x4fc6('0x2a')](_0xc9be8b)[_0x4fc6('0x2b')](_0x40f240);}};}function respondWithFilteredResult(_0x57cc0a,_0x2c9ed0){return function(_0x48be65){if(_0x48be65){var _0x266d75=typeof _0x2c9ed0['offset']===_0x4fc6('0x2c')&&typeof _0x2c9ed0[_0x4fc6('0x2d')]===_0x4fc6('0x2c');var _0xdbffaa=_0x48be65[_0x4fc6('0x2e')];var _0x37eac8=_0x266d75?0x0:_0x2c9ed0[_0x4fc6('0x2f')];var _0x467182=_0x266d75?_0x48be65['count']:_0x2c9ed0[_0x4fc6('0x2f')]+_0x2c9ed0[_0x4fc6('0x2d')];var _0x1167f1;if(_0x467182>=_0xdbffaa){_0x467182=_0xdbffaa;_0x1167f1=0xc8;}else{_0x1167f1=0xce;}_0x57cc0a[_0x4fc6('0x2a')](_0x1167f1);return _0x57cc0a[_0x4fc6('0x30')]('Content-Range',_0x37eac8+'-'+_0x467182+'/'+_0xdbffaa)['json'](_0x48be65);}return null;};}function patchUpdates(_0x1432cc){return function(_0x29a745){try{jsonpatch[_0x4fc6('0x31')](_0x29a745,_0x1432cc,!![]);}catch(_0x2958d9){return BPromise[_0x4fc6('0x32')](_0x2958d9);}return _0x29a745['save']();};}function saveUpdates(_0x59fcb0,_0x1c33df){return function(_0x5d036f){if(_0x5d036f){return _0x5d036f['update'](_0x59fcb0)[_0x4fc6('0x1e')](function(_0x419c75){return _0x419c75;});}return null;};}function removeEntity(_0x605ff4,_0xa076e7){return function(_0x3967dc){if(_0x3967dc){return _0x3967dc[_0x4fc6('0x33')]()[_0x4fc6('0x1e')](function(){var _0x3bc627=_0x3967dc[_0x4fc6('0x34')]({'plain':!![]});if(_0x3bc627[_0x4fc6('0x35')]==='admin')return;var _0x4a7794=[{'name':_0x4fc6('0x36'),'value':_0x4fc6('0x37'),'ignore':!![]},{'name':_0x4fc6('0x38'),'value':'agent','ignore':![]},{'name':_0x4fc6('0x39'),'value':_0x4fc6('0x3a'),'ignore':![]}];var _0x4c4ac3=_(_0x4a7794)[_0x4fc6('0x3b')](_0x4fc6('0x3c'))['map'](_0x4fc6('0x3d'))['value']();if(_[_0x4fc6('0x3e')](_0x4c4ac3,_0x3bc627[_0x4fc6('0x35')])){return;}var _0x3a47ce=_[_0x4fc6('0x3f')](_0x4a7794,[_0x4fc6('0x3d'),_0x3bc627['role']])[_0x4fc6('0x40')];return db['UserProfileResource'][_0x4fc6('0x33')]({'where':{'type':_0x3a47ce,'resourceId':_0x3bc627['id']}})[_0x4fc6('0x1e')](function(){return _0x3967dc;});})[_0x4fc6('0x1e')](function(){_0x605ff4[_0x4fc6('0x2a')](0xcc)[_0x4fc6('0x29')]();});}};}function handleEntityNotFound(_0xb0a6c3,_0x2785ac){return function(_0x4c49ad){if(!_0x4c49ad){_0xb0a6c3['sendStatus'](0x194);}return _0x4c49ad;};}function handleError(_0x162bdc,_0x403c9f){_0x403c9f=_0x403c9f||0x1f4;return function(_0xeb0797){logger[_0x4fc6('0x23')](_0xeb0797[_0x4fc6('0x41')]);if(_0xeb0797[_0x4fc6('0x40')]){delete _0xeb0797[_0x4fc6('0x40')];}_0x162bdc['status'](_0x403c9f)[_0x4fc6('0x42')](_0xeb0797);};}function getMustacheRender(_0x3645c4,_0x2d3963){return Mustache[_0x4fc6('0x43')](_0x3645c4,_['merge'](_0x2d3963['body'],{'contact':_0x2d3963[_0x4fc6('0x44')],'message':_0x2d3963['message'],'agent':_0x2d3963[_0x4fc6('0x45')],'interaction':_0x2d3963[_0x4fc6('0x46')],'account':_0x2d3963[_0x4fc6('0x47')]}))||'';}exports[_0x4fc6('0x48')]=function(_0x54fb8c,_0xe41cd0){var _0x5e398e={},_0x5827bb={},_0x416590={'count':0x0,'rows':[]};var _0xc36e6b=_[_0x4fc6('0x49')](db[_0x4fc6('0x4a')]['rawAttributes'],function(_0x4c7451){return{'name':_0x4c7451[_0x4fc6('0x4b')],'type':_0x4c7451[_0x4fc6('0x4c')][_0x4fc6('0x4d')]};});_0x5827bb[_0x4fc6('0x4e')]=_[_0x4fc6('0x4f')](_['map'](_0xc36e6b,'name'),[_0x4fc6('0x50'),'salt']);_0x5827bb['query']=_['keys'](_0x54fb8c[_0x4fc6('0x51')]);_0x5827bb[_0x4fc6('0x52')]=_[_0x4fc6('0x53')](_0x5827bb['model'],_0x5827bb[_0x4fc6('0x51')]);_0x5e398e[_0x4fc6('0x54')]=_[_0x4fc6('0x53')](_0x5827bb[_0x4fc6('0x4e')],qs[_0x4fc6('0x55')](_0x54fb8c['query'][_0x4fc6('0x55')]));_0x5e398e[_0x4fc6('0x54')]=_0x5e398e[_0x4fc6('0x54')][_0x4fc6('0x56')]?_0x5e398e[_0x4fc6('0x54')]:_0x5827bb[_0x4fc6('0x4e')];if(!_0x54fb8c[_0x4fc6('0x51')][_0x4fc6('0x57')]('nolimit')){_0x5e398e[_0x4fc6('0x2d')]=qs[_0x4fc6('0x2d')](_0x54fb8c[_0x4fc6('0x51')][_0x4fc6('0x2d')]);_0x5e398e[_0x4fc6('0x2f')]=qs['offset'](_0x54fb8c[_0x4fc6('0x51')][_0x4fc6('0x2f')]);}_0x5e398e['order']=qs[_0x4fc6('0x58')](_0x54fb8c[_0x4fc6('0x51')][_0x4fc6('0x58')]);_0x5e398e['where']=qs[_0x4fc6('0x52')](_[_0x4fc6('0x59')](_0x54fb8c[_0x4fc6('0x51')],_0x5827bb[_0x4fc6('0x52')]),_0xc36e6b);if(_0x54fb8c[_0x4fc6('0x51')]['filter']){_0x5e398e['where']=_[_0x4fc6('0x5a')](_0x5e398e[_0x4fc6('0x5b')],{'$or':_[_0x4fc6('0x49')](_0xc36e6b,function(_0x56916a){if(_0x56916a[_0x4fc6('0x4c')]!==_0x4fc6('0x5c')){return db[_0x4fc6('0x5d')]['where'](db['sequelize']['fn']('lower',db[_0x4fc6('0x5d')][_0x4fc6('0x5e')](_0x56916a[_0x4fc6('0x40')])),{'$like':db[_0x4fc6('0x5d')]['fn'](_0x4fc6('0x5f'),'%'+_0x54fb8c['query']['filter']+'%')});}})});}_0x5e398e=_[_0x4fc6('0x5a')]({},_0x5e398e,_0x54fb8c[_0x4fc6('0x60')]);var _0x2a56c9={'where':_0x5e398e[_0x4fc6('0x5b')]};return db['User'][_0x4fc6('0x2e')](_0x2a56c9)[_0x4fc6('0x1e')](function(_0x40481b){_0x416590[_0x4fc6('0x2e')]=_0x40481b;if(_0x54fb8c[_0x4fc6('0x51')][_0x4fc6('0x61')]){_0x5e398e[_0x4fc6('0x62')]=[{'all':!![]}];}if(!_[_0x4fc6('0x3e')](_0x5e398e[_0x4fc6('0x54')],'id')){_0x5e398e[_0x4fc6('0x54')][_0x4fc6('0x63')]('id');}return db['User'][_0x4fc6('0x64')](_0x5e398e);})[_0x4fc6('0x1e')](function(_0x3f1d0a){_0x416590[_0x4fc6('0x65')]=_0x3f1d0a;if(_0x54fb8c[_0x4fc6('0x51')][_0x4fc6('0x66')]===_0x4fc6('0x67')){var _0x131e23=[];for(var _0x42a6ab=0x0;_0x42a6ab<_0x416590['rows']['length'];_0x42a6ab++){_0x131e23[_0x4fc6('0x63')](get_open_tabs(_0x4fc6('0x68'),_0x416590[_0x4fc6('0x65')][_0x42a6ab][_0x4fc6('0x69')]));_0x131e23['push'](get_open_tabs('sms',_0x416590['rows'][_0x42a6ab][_0x4fc6('0x69')]));_0x131e23[_0x4fc6('0x63')](get_open_tabs(_0x4fc6('0x6a'),_0x416590['rows'][_0x42a6ab][_0x4fc6('0x69')]));_0x131e23[_0x4fc6('0x63')](get_open_tabs('mail',_0x416590['rows'][_0x42a6ab][_0x4fc6('0x69')]));_0x131e23[_0x4fc6('0x63')](get_open_tabs(_0x4fc6('0x6b'),_0x416590['rows'][_0x42a6ab][_0x4fc6('0x69')]));_0x131e23['push'](get_open_tabs(_0x4fc6('0x6c'),_0x416590['rows'][_0x42a6ab][_0x4fc6('0x69')]));}return BPromise[_0x4fc6('0x6d')](_0x131e23)['then'](function(_0x208038){return _0x416590;});}else{return _0x416590;}})[_0x4fc6('0x1e')](respondWithFilteredResult(_0xe41cd0,_0x5e398e))[_0x4fc6('0x27')](handleError(_0xe41cd0,null));};exports[_0x4fc6('0x6e')]=function(_0x1293c4,_0x283ff7){var _0x1670e0={'raw':![],'where':{'id':_0x1293c4[_0x4fc6('0x6f')]['id']}},_0x540741={};_0x540741[_0x4fc6('0x4e')]=_['differenceBy'](_[_0x4fc6('0x70')](db[_0x4fc6('0x4a')][_0x4fc6('0x71')]),[_0x4fc6('0x50'),_0x4fc6('0x72')]);_0x540741['query']=_['keys'](_0x1293c4[_0x4fc6('0x51')]);_0x540741['filters']=_['intersection'](_0x540741[_0x4fc6('0x4e')],_0x540741['query']);_0x1670e0[_0x4fc6('0x54')]=_['intersection'](_0x540741[_0x4fc6('0x4e')],qs[_0x4fc6('0x55')](_0x1293c4[_0x4fc6('0x51')][_0x4fc6('0x55')]));_0x1670e0['attributes']=_0x1670e0[_0x4fc6('0x54')]['length']?_0x1670e0[_0x4fc6('0x54')]:_0x540741[_0x4fc6('0x4e')];if(_0x1293c4[_0x4fc6('0x51')][_0x4fc6('0x61')]){_0x1670e0['include']=[{'all':!![]}];}_0x1670e0=_[_0x4fc6('0x5a')]({},_0x1670e0,_0x1293c4['options']);if(!_['includes'](_0x1670e0[_0x4fc6('0x54')],'id')){_0x1670e0[_0x4fc6('0x54')][_0x4fc6('0x63')]('id');}return db[_0x4fc6('0x4a')][_0x4fc6('0x3f')](_0x1670e0)['then'](handleEntityNotFound(_0x283ff7,null))[_0x4fc6('0x1e')](function(_0xe0ee54){var _0x51efd6=[];values=_0xe0ee54;if(_0x1293c4[_0x4fc6('0x51')][_0x4fc6('0x66')]===_0x4fc6('0x67')){_0x51efd6[_0x4fc6('0x63')](get_open_tabs(_0x4fc6('0x68'),_0xe0ee54[_0x4fc6('0x69')]));_0x51efd6[_0x4fc6('0x63')](get_open_tabs(_0x4fc6('0x73'),_0xe0ee54[_0x4fc6('0x69')]));_0x51efd6[_0x4fc6('0x63')](get_open_tabs(_0x4fc6('0x6b'),_0xe0ee54['dataValues']));_0x51efd6[_0x4fc6('0x63')](get_open_tabs(_0x4fc6('0x6c'),_0xe0ee54[_0x4fc6('0x69')]));_0x51efd6['push'](get_open_tabs(_0x4fc6('0x6a'),_0xe0ee54[_0x4fc6('0x69')]));_0x51efd6[_0x4fc6('0x63')](get_open_tabs(_0x4fc6('0x74'),_0xe0ee54[_0x4fc6('0x69')]));return BPromise['all'](_0x51efd6);}else{return values;}})[_0x4fc6('0x1e')](function(_0x3bd9b2){return values;})[_0x4fc6('0x1e')](respondWithResult(_0x283ff7,null))[_0x4fc6('0x27')](handleError(_0x283ff7,null));};exports[_0x4fc6('0x75')]=function(_0x5de4ed,_0x39baa4){if(_0x5de4ed[_0x4fc6('0x76')]['id']){delete _0x5de4ed[_0x4fc6('0x76')]['id'];}delete _0x5de4ed[_0x4fc6('0x76')][_0x4fc6('0x35')];return db[_0x4fc6('0x4a')][_0x4fc6('0x3f')]({'where':{'id':_0x5de4ed[_0x4fc6('0x6f')]['id']}})[_0x4fc6('0x1e')](handleEntityNotFound(_0x39baa4,null))[_0x4fc6('0x1e')](saveUpdates(_0x5de4ed['body'],null))[_0x4fc6('0x1e')](respondWithResult(_0x39baa4,null))[_0x4fc6('0x27')](handleError(_0x39baa4,null));};exports[_0x4fc6('0x77')]=function(_0x4d9bfe,_0x3c7613){return db[_0x4fc6('0x4a')][_0x4fc6('0x77')]()['then'](respondWithResult(_0x3c7613,null))[_0x4fc6('0x27')](handleError(_0x3c7613,null));};exports['addContacts']=function(_0x1f07f3,_0x22f458,_0x3fdb9b){return db[_0x4fc6('0x4a')][_0x4fc6('0x3f')]({'where':{'id':_0x1f07f3[_0x4fc6('0x6f')]['id']}})[_0x4fc6('0x1e')](handleEntityNotFound(_0x22f458,null))[_0x4fc6('0x1e')](function(_0x3b31b4){if(_0x3b31b4){return _0x3b31b4[_0x4fc6('0x78')](_0x1f07f3[_0x4fc6('0x76')]['ids'],_[_0x4fc6('0x79')](_0x1f07f3[_0x4fc6('0x76')],[_0x4fc6('0x7a'),'id'])||{});}})[_0x4fc6('0x1e')](respondWithResult(_0x22f458,null))['catch'](handleError(_0x22f458,null));};function validateUser(_0x313f24){return new BPromise(function(_0x5e7b5c,_0x5c5834){if(_0x313f24['internal'])return _0x5e7b5c(_0x313f24);return db[_0x4fc6('0x7b')][_0x4fc6('0x7c')](0x1)[_0x4fc6('0x1e')](function(_0x39d308){if(_0x39d308['securePassword'])authService[_0x4fc6('0x7d')](_0x313f24[_0x4fc6('0x50')]);db[_0x4fc6('0x4a')]['max'](_0x4fc6('0x7e'))[_0x4fc6('0x1e')](function(_0x517f47){if(_['isNil'](_0x517f47)){_0x313f24[_0x4fc6('0x7e')]=_0x39d308[_0x4fc6('0x7f')]||0x1;return;}if(_[_0x4fc6('0x80')](_0x39d308[_0x4fc6('0x7f')])||_0x39d308[_0x4fc6('0x7f')]===_0x517f47){_0x313f24[_0x4fc6('0x7e')]=_0x517f47+0x1;return;}if(_0x39d308['min_internal']>_0x517f47){_0x313f24['internal']=_0x39d308[_0x4fc6('0x7f')];return;}return db[_0x4fc6('0x5d')]['query'](_0x4fc6('0x81'),{'type':db[_0x4fc6('0x5d')]['QueryTypes']['SELECT']})[_0x4fc6('0x1e')](function(_0x59868c){if(_0x59868c&&_0x59868c[_0x4fc6('0x56')]){for(var _0x1b9b05=0x0,_0x492e5a=_0x59868c['length'];_0x1b9b05<_0x492e5a&&_[_0x4fc6('0x80')](_0x313f24[_0x4fc6('0x7e')]);_0x1b9b05++){if(_0x39d308[_0x4fc6('0x7f')]<=_0x59868c[_0x1b9b05][_0x4fc6('0x82')]){_0x313f24[_0x4fc6('0x7e')]=_0x59868c[_0x1b9b05]['from'];}else if(_0x39d308['min_internal']>_0x59868c[_0x1b9b05][_0x4fc6('0x82')]&&_0x39d308['min_internal']<=_0x59868c[_0x1b9b05]['to']){_0x313f24[_0x4fc6('0x7e')]=_0x39d308['min_internal'];}}}if(_[_0x4fc6('0x80')](_0x313f24[_0x4fc6('0x7e')])){_0x313f24[_0x4fc6('0x7e')]=_0x517f47+0x1;}return _0x5e7b5c(_0x313f24);});});})[_0x4fc6('0x27')](function(_0x5258b2){_0x5c5834(_0x5258b2);});});}function updateUser(_0x58548c){return new BPromise(function(_0x1a1e09,_0x43b8df){try{if(_0x58548c[_0x4fc6('0x83')]){_0x58548c[_0x4fc6('0x84')]=_0x58548c['internal'];_0x58548c[_0x4fc6('0x85')]={'mailbox':_0x58548c[_0x4fc6('0x7e')],'password':_0x58548c[_0x4fc6('0x50')],'fullname':_0x58548c[_0x4fc6('0x86')],'email':_0x58548c[_0x4fc6('0x87')]};}if(_0x58548c['role']===_0x4fc6('0x45')){if(!_0x58548c[_0x4fc6('0x88')])_0x58548c[_0x4fc6('0x88')]=[_0x4fc6('0x89'),_0x4fc6('0x8a'),_0x4fc6('0x8b'),'113','110',_0x4fc6('0x8c'),_0x4fc6('0x8d'),_0x4fc6('0x8e'),'107',_0x4fc6('0x8f'),_0x4fc6('0x90'),_0x4fc6('0x91'),'111',_0x4fc6('0x92'),_0x4fc6('0x93')];}_0x1a1e09(_0x58548c);}catch(_0x2750b5){_0x43b8df(_0x2750b5);}});}exports[_0x4fc6('0x94')]=function(_0x3f29ea,_0x3f19f8){if(_0x3f29ea['user'][_0x4fc6('0x35')]===_0x4fc6('0x45'))throw new Error(_0x4fc6('0x95'));if(_0x3f29ea['body'][_0x4fc6('0x35')]===_0x4fc6('0x37')&&_0x3f29ea[_0x4fc6('0x37')][_0x4fc6('0x35')]!=='admin'){throw new Error(_0x4fc6('0x96'));}if(_0x3f29ea[_0x4fc6('0x76')]['role']==='admin'&&_0x3f29ea['user']['role']!==_0x4fc6('0x97')){throw new Error(_0x4fc6('0x98'));}return licenseUtil['checkUserLimits']([_0x3f29ea[_0x4fc6('0x76')]])[_0x4fc6('0x1e')](function(){return validateUser(_0x3f29ea[_0x4fc6('0x76')]);})[_0x4fc6('0x1e')](function(_0x3a8a9b){return updateUser(_0x3a8a9b)['then'](function(_0x5b4d65){if(_0x5b4d65['role']===_0x4fc6('0x97')){_0x5b4d65['settingsEnabled']=_0x3f29ea[_0x4fc6('0x37')]['settingsEnabled'];delete _0x5b4d65[_0x4fc6('0x99')];}return _0x5b4d65;});})['then'](function(_0x909115){return db[_0x4fc6('0x4a')]['create'](_0x909115,{'include':[{'model':db[_0x4fc6('0x85')],'as':_0x4fc6('0x85')}]});})['then'](function(_0x34c870){if(_0x3f29ea['body'][_0x4fc6('0x35')]===_0x4fc6('0x37'))return _0x34c870;if(_0x3f29ea['user'][_0x4fc6('0x35')]!==_0x4fc6('0x37'))return _0x34c870;return db[_0x4fc6('0x9a')][_0x4fc6('0x3f')]({'where':{'name':_0x34c870[_0x4fc6('0x35')]===_0x4fc6('0x45')?_0x4fc6('0x38'):_0x4fc6('0x39'),'userProfileId':_0x3f29ea[_0x4fc6('0x37')]['userProfileId']},'raw':!![]})[_0x4fc6('0x1e')](function(_0xe05e4d){if(!_0xe05e4d||_0xe05e4d[_0x4fc6('0x9b')]!=0x0)return _0x34c870;return db[_0x4fc6('0x9c')]['create']({'name':_0x34c870['name'],'resourceId':_0x34c870['id'],'type':_0xe05e4d[_0x4fc6('0x40')],'sectionId':_0xe05e4d['id']},{})[_0x4fc6('0x1e')](function(){return _0x34c870;});})['catch'](function(_0x44bd1b){logger[_0x4fc6('0x23')](_0x4fc6('0x9d'),_0x44bd1b);throw _0x44bd1b;});})[_0x4fc6('0x1e')](respondWithResult(_0x3f19f8,0xc9))['catch'](handleError(_0x3f19f8,null));};exports[_0x4fc6('0x9e')]=function(_0x4916da,_0x80b904){var _0x59653a=_0x4916da[_0x4fc6('0x76')];var _0x333bd7=[];if(_0x4916da['user']['role']===_0x4fc6('0x45'))throw new Error(_0x4fc6('0x95'));if(_['some'](_0x59653a,['role',_0x4fc6('0x37')])&&_0x4916da[_0x4fc6('0x37')]['role']!==_0x4fc6('0x97')){throw new Error(_0x4fc6('0x96'));}if(_[_0x4fc6('0x9f')](_0x59653a,[_0x4fc6('0x35'),_0x4fc6('0x97')])&&_0x4916da['user'][_0x4fc6('0x35')]!=='admin'){throw new Error(_0x4fc6('0xa0'));}return licenseUtil[_0x4fc6('0xa1')](_0x59653a)[_0x4fc6('0x1e')](function(){return validateUser(_0x59653a[0x0]);})['then'](function(){for(var _0x31c3c0=0x1;_0x31c3c0<_0x59653a[_0x4fc6('0x56')];_0x31c3c0++){var _0xf2698e=_0x59653a[_0x31c3c0-0x1]['internal'];if(!_0x59653a[_0x31c3c0][_0x4fc6('0x7e')])_0x59653a[_0x31c3c0][_0x4fc6('0x7e')]=_0xf2698e+0x1;_0x333bd7[_0x4fc6('0x63')](validateUser(_0x59653a[_0x31c3c0]));}return BPromise[_0x4fc6('0x6d')](_0x333bd7);})[_0x4fc6('0x1e')](function(){_0x333bd7=[];for(var _0x55c3cf=0x0;_0x55c3cf<_0x59653a[_0x4fc6('0x56')];_0x55c3cf++){_0x333bd7[_0x4fc6('0x63')](updateUser(_0x59653a[_0x55c3cf]));}return BPromise[_0x4fc6('0x6d')](_0x333bd7);})[_0x4fc6('0x1e')](function(){return BPromise[_0x4fc6('0xa2')](_0x59653a,function(_0x3ac7a3){return db[_0x4fc6('0x4a')]['create'](_0x3ac7a3,{'include':[{'model':db[_0x4fc6('0x85')],'as':_0x4fc6('0x85')}]})[_0x4fc6('0x1e')](function(_0x9b890d){_0x3ac7a3['id']=_0x9b890d['id'];return _0x3ac7a3;});});})['then'](function(_0x4f350b){if(_0x4916da[_0x4fc6('0x76')][_0x4fc6('0x35')]===_0x4fc6('0x37'))return _0x4f350b;if(_0x4916da['user'][_0x4fc6('0x35')]!==_0x4fc6('0x37'))return _0x4f350b;var _0x31d23f=_[_0x4fc6('0x9f')](_0x4f350b,function(_0x2b3807){return _0x2b3807['role']==='agent'||_0x2b3807[_0x4fc6('0x35')]==='telephone';});if(!_0x31d23f)return _0x4f350b;return db[_0x4fc6('0x9a')][_0x4fc6('0x64')]({'where':{'name':{'$or':[_0x4fc6('0x38'),'Telephones']},'userProfileId':_0x4916da[_0x4fc6('0x37')][_0x4fc6('0x99')]},'raw':!![]})[_0x4fc6('0x1e')](function(_0x55c1fc){if(_['isEmpty'](_0x55c1fc)||!_['some'](_0x55c1fc,['autoAssociation',0x0]))return _0x4f350b;_0x333bd7=[];var _0x4b6899=_(_0x55c1fc)['map'](function(_0x2af2a5){if(_0x2af2a5[_0x4fc6('0x9b')]===0x1)return;return _0x2af2a5['name']===_0x4fc6('0x38')?'agent':_0x4fc6('0x3a');})['compact']()[_0x4fc6('0x3d')]();for(var _0x132286=0x0;_0x132286<_0x4f350b[_0x4fc6('0x56')];_0x132286++){if(!_[_0x4fc6('0x3e')](_0x4b6899,_0x4f350b[_0x132286][_0x4fc6('0x35')]))return;var _0x3fc16b=_0x4f350b[_0x132286]['role']==='agent'?_0x4fc6('0x38'):_0x4fc6('0x39');_0x333bd7['push'](db[_0x4fc6('0x9c')][_0x4fc6('0x94')]({'name':_0x4f350b[_0x132286][_0x4fc6('0x40')],'resourceId':_0x4f350b[_0x132286]['id'],'type':_0x3fc16b,'sectionId':_[_0x4fc6('0x3f')](_0x55c1fc,['name',_0x3fc16b])['id']},{}));}return BPromise[_0x4fc6('0x6d')](_0x333bd7);});})[_0x4fc6('0x1e')](respondWithResult(_0x80b904,0xc9))[_0x4fc6('0x27')](handleError(_0x80b904,null));};exports[_0x4fc6('0xa3')]=function(_0x4e2642,_0x2ff9df,_0x152d0b){if(_0x4e2642[_0x4fc6('0x76')]['id']){delete _0x4e2642[_0x4fc6('0x76')]['id'];}return db['User'][_0x4fc6('0x3f')]({'where':{'id':_0x4e2642['params']['id']}})[_0x4fc6('0x1e')](function(_0x23538e){if(!_0x23538e)return null;if(_0x23538e['id']===_0x4e2642['user']['id']){if(!_0x4e2642['body'][_0x4fc6('0xa4')]||!_0x4e2642[_0x4fc6('0x76')][_0x4fc6('0xa5')]){throw new db['Sequelize'][(_0x4fc6('0xa6'))](_0x4fc6('0xa7'));}if(!_0x23538e['authenticate'](_0x4e2642[_0x4fc6('0x76')]['oldPassword'])){throw new db['Sequelize'][(_0x4fc6('0xa6'))]('Wrong\x20credentials');}if(_0x4e2642[_0x4fc6('0x76')][_0x4fc6('0xa4')]===_0x4e2642['body'][_0x4fc6('0xa5')]){throw new db[(_0x4fc6('0xa8'))]['ValidationError']('New\x20password\x20must\x20be\x20different\x20from\x20old\x20password');}}else if(_0x4e2642['user']['role']==='admin'){if(!_0x4e2642[_0x4fc6('0x76')][_0x4fc6('0xa5')]){throw new db[(_0x4fc6('0xa8'))][(_0x4fc6('0xa6'))](_0x4fc6('0xa9'));}}else if(_0x4e2642['user']['role']===_0x4fc6('0x37')){if(!_0x4e2642[_0x4fc6('0x76')][_0x4fc6('0xa5')]){throw new db['Sequelize'][(_0x4fc6('0xa6'))](_0x4fc6('0xa9'));}if(_0x23538e[_0x4fc6('0x35')]!==_0x4fc6('0x45')){throw new db[(_0x4fc6('0xa8'))][(_0x4fc6('0xa6'))](_0x4fc6('0x95'));}}else{throw new db[(_0x4fc6('0xa8'))][(_0x4fc6('0xa6'))]('Unauthorized');}return _0x23538e;})[_0x4fc6('0x1e')](handleEntityNotFound(_0x2ff9df,null))[_0x4fc6('0x1e')](function(_0x30a5d1){return db[_0x4fc6('0x7b')][_0x4fc6('0xaa')]({'attributes':['id','securePassword',_0x4fc6('0xab'),_0x4fc6('0xac')]})[_0x4fc6('0x1e')](function(_0x273ba2){if(_0x273ba2['securePassword'])authService[_0x4fc6('0x7d')](_0x4e2642[_0x4fc6('0x76')][_0x4fc6('0xa5')]);if(!_0x273ba2['enforcePasswordHistory']||!_0x30a5d1['previousPasswords'])return _0x30a5d1;authService[_0x4fc6('0xad')](_0x4e2642[_0x4fc6('0x76')][_0x4fc6('0xa5')],_0x30a5d1[_0x4fc6('0xae')],_0x273ba2[_0x4fc6('0xac')]);return _0x30a5d1;})['then'](saveUpdates({'password':_0x4e2642['body'][_0x4fc6('0xa5')],'passwordResetAt':_0x4e2642[_0x4fc6('0x37')]['id']==_0x4e2642[_0x4fc6('0x6f')]['id']?moment():null,'previousPasswords':authService[_0x4fc6('0xaf')](_0x4e2642[_0x4fc6('0x76')][_0x4fc6('0xa5')],_0x30a5d1['previousPasswords'])},null));})['then'](respondWithResult(_0x2ff9df,null))[_0x4fc6('0x27')](handleError(_0x2ff9df,null));};exports[_0x4fc6('0xb0')]=function(_0x310682,_0x3796ee,_0x2ca615){var _0xf2a52e=_0x310682[_0x4fc6('0x76')][_0x4fc6('0xb1')];return db['User'][_0x4fc6('0x3f')]({'where':{'id':_0x310682[_0x4fc6('0x6f')]['id']},'attributes':['id','name',_0x4fc6('0x35'),_0x4fc6('0xb2'),_0x4fc6('0xb3'),_0x4fc6('0xb4'),_0x4fc6('0xb5')]})[_0x4fc6('0x1e')](handleEntityNotFound(_0x3796ee,null))[_0x4fc6('0x1e')](function(_0x4245f7){if(_0x4245f7){if(!utils[_0x4fc6('0xb6')](_0xf2a52e)){throw new db[(_0x4fc6('0xa8'))]['ValidationError']('Unknown\x20channel');}return _0x4245f7[_0x4fc6('0xb7')+_[_0x4fc6('0xb8')](_0xf2a52e[_0x4fc6('0xb9')]())+'Queues'](_0x310682['body'][_0x4fc6('0x7a')],{'penalty':_0x310682['body']['penalty']||0x0})[_0x4fc6('0xba')](function(_0x1a3307){for(var _0x5b81e6=0x0;_0x5b81e6<_0x310682[_0x4fc6('0x76')]['ids'][_0x4fc6('0x56')];_0x5b81e6+=0x1){var _0x1ff336={'UserId':_0x310682['params']['id']};_0x1ff336[_['capitalize'](_0xf2a52e[_0x4fc6('0xb9')]())+'QueueId']=_0x310682[_0x4fc6('0x76')]['ids'][_0x5b81e6];socket['emit']('user'+_[_0x4fc6('0xb8')](_0xf2a52e[_0x4fc6('0xb9')]())+_0x4fc6('0xbb'),_0x1ff336);}return _0x1a3307;})['then'](function(){if(_0xf2a52e===_0x4fc6('0xbc')){return db[_0x4fc6('0xbd')][_0x4fc6('0x64')]({'where':{'id':_0x310682[_0x4fc6('0x76')][_0x4fc6('0x7a')]||[]},'raw':!![],'attributes':['id',_0x4fc6('0x40')]});}})[_0x4fc6('0x1e')](function(_0x5aeb0d){var _0x3be876=_0x4245f7[_0x4fc6('0x34')]({'plain':!![]});var _0x514db3=[];if(_0xf2a52e===_0x4fc6('0xbc')&&_0x3be876['role']==='agent'&&_0x3be876['online']){for(var _0x3f2a67=0x0;_0x3f2a67<_0x5aeb0d[_0x4fc6('0x56')];_0x3f2a67+=0x1){_0x514db3['push']({'membername':_0x3be876[_0x4fc6('0x40')],'UserId':_0x3be876['id'],'queue_name':_0x5aeb0d[_0x3f2a67]['name'],'VoiceQueueId':_0x5aeb0d[_0x3f2a67]['id'],'interface':_[_0x4fc6('0x80')](_0x3be876[_0x4fc6('0xb5')])?util[_0x4fc6('0xbe')](_0x4fc6('0xbf'),_0x3be876[_0x4fc6('0x40')]):_0x3be876['interface'],'paused':_0x3be876['voicePause']||![],'penalty':_0x310682['body'][_0x4fc6('0xc0')]||0x0});}return BPromise[_0x4fc6('0xa2')](_0x514db3,function(_0x376262){return db[_0x4fc6('0xc1')]['upsert'](_0x376262);});}return _0x4245f7;});}})[_0x4fc6('0x1e')](respondWithStatusCode(_0x3796ee,null))[_0x4fc6('0x27')](handleError(_0x3796ee,null));};exports[_0x4fc6('0xc2')]=function(_0xc3a7f0,_0x4d98d6,_0x25d2d2){var _0x58ce95;return db[_0x4fc6('0x4a')][_0x4fc6('0x3f')]({'where':{'id':_0xc3a7f0[_0x4fc6('0x6f')]['id']},'attributes':['id',_0x4fc6('0x40'),'role']})[_0x4fc6('0x1e')](handleEntityNotFound(_0x4d98d6,null))[_0x4fc6('0x1e')](function(_0x2d785e){if(_0x2d785e){_0x58ce95=_0x2d785e;if(!_0xc3a7f0[_0x4fc6('0x51')][_0x4fc6('0xb1')]||!utils[_0x4fc6('0xb6')](_0xc3a7f0['query']['channel'])){throw new db[(_0x4fc6('0xa8'))][(_0x4fc6('0xa6'))](_0x4fc6('0xc3'));}return _0x2d785e[_0x4fc6('0xc4')+_[_0x4fc6('0xb8')](_0xc3a7f0[_0x4fc6('0x51')]['channel'][_0x4fc6('0xb9')]())+_0x4fc6('0xc5')](_0xc3a7f0[_0x4fc6('0x51')][_0x4fc6('0x7a')]);}})['then'](function(_0x243d5a){for(var _0x403c58=0x0;_0x403c58<_0xc3a7f0[_0x4fc6('0x51')][_0x4fc6('0x7a')][_0x4fc6('0x56')];_0x403c58+=0x1){var _0xf5a440={'UserId':_0xc3a7f0[_0x4fc6('0x6f')]['id']};_0xf5a440[_[_0x4fc6('0xb8')](_0xc3a7f0[_0x4fc6('0x51')][_0x4fc6('0xb1')][_0x4fc6('0xb9')]())+_0x4fc6('0xc6')]=_0xc3a7f0[_0x4fc6('0x51')][_0x4fc6('0x7a')][_0x403c58];socket['emit'](_0x4fc6('0x37')+_[_0x4fc6('0xb8')](_0xc3a7f0[_0x4fc6('0x51')]['channel'][_0x4fc6('0xb9')]())+_0x4fc6('0xc7'),_0xf5a440);}return _0x243d5a;})[_0x4fc6('0x1e')](function(){if(_0xc3a7f0[_0x4fc6('0x51')][_0x4fc6('0xb1')]===_0x4fc6('0xbc')){return db['UserVoiceQueueRt']['destroy']({'where':{'UserId':_0xc3a7f0[_0x4fc6('0x6f')]['id'],'VoiceQueueId':_0xc3a7f0[_0x4fc6('0x51')]['ids']},'individualHooks':!![]})[_0x4fc6('0x1e')](function(){return _0x58ce95;});}return _0x58ce95;})['then'](respondWithStatusCode(_0x4d98d6,null))[_0x4fc6('0x27')](handleError(_0x4d98d6,null));};exports[_0x4fc6('0xc8')]=function(_0x42b29d,_0x21bf44,_0x4b2868){_0x42b29d[_0x4fc6('0x76')][_0x4fc6('0xc9')]=_0x42b29d[_0x4fc6('0xca')][_0x4fc6('0xcb')];return db[_0x4fc6('0x4a')][_0x4fc6('0x3f')]({'where':{'id':_0x42b29d['params']['id']}})[_0x4fc6('0x1e')](handleEntityNotFound(_0x21bf44,null))[_0x4fc6('0x1e')](saveUpdates(_0x42b29d[_0x4fc6('0x76')],null))['then'](respondWithResult(_0x21bf44,null))[_0x4fc6('0x27')](handleError(_0x21bf44,null));};exports[_0x4fc6('0xcc')]=function(_0x4c05b1,_0x337e27,_0x2725a1){var _0x1b146f=path[_0x4fc6('0xcd')](config[_0x4fc6('0xce')],_0x4fc6('0xcf'));return db[_0x4fc6('0x4a')]['find']({'where':{'id':_0x4c05b1['params']['id']},'attributes':['id',_0x4fc6('0xc9')],'raw':!![]})[_0x4fc6('0x1e')](handleEntityNotFound(_0x337e27,null))['then'](function(_0x46e56d){if(_0x46e56d){if(_['isNil'](_0x46e56d['userpic'])){return _0x337e27[_0x4fc6('0xd0')](_0x1b146f);}else{if(!fs['existsSync'](path[_0x4fc6('0xcd')](config['root'],_0x4fc6('0xd1'),_0x46e56d[_0x4fc6('0xc9')]))){return _0x337e27[_0x4fc6('0xd0')](_0x1b146f);}return _0x337e27[_0x4fc6('0xd0')](path[_0x4fc6('0xcd')](config[_0x4fc6('0xce')],_0x4fc6('0xd1'),_0x46e56d[_0x4fc6('0xc9')]));}}})[_0x4fc6('0x27')](handleError(_0x337e27,null));};exports[_0x4fc6('0xd2')]=function(_0xd786ed,_0x3ad118,_0x44daa5){return db[_0x4fc6('0x4a')]['find']({'where':{'id':_0xd786ed[_0x4fc6('0x6f')]['id']},'attributes':['id']})[_0x4fc6('0x1e')](handleEntityNotFound(_0x3ad118,null))[_0x4fc6('0x1e')](function(_0xfad519){var _0x37ee95=[];values=_0xfad519[_0x4fc6('0x69')];_0x37ee95[_0x4fc6('0x63')](get_open_tabs(_0x4fc6('0x68'),_0xfad519[_0x4fc6('0x69')]));_0x37ee95[_0x4fc6('0x63')](get_open_tabs(_0x4fc6('0x73'),_0xfad519[_0x4fc6('0x69')]));_0x37ee95['push'](get_open_tabs(_0x4fc6('0x6b'),_0xfad519[_0x4fc6('0x69')]));_0x37ee95['push'](get_open_tabs(_0x4fc6('0x6c'),_0xfad519[_0x4fc6('0x69')]));_0x37ee95[_0x4fc6('0x63')](get_open_tabs(_0x4fc6('0x6a'),_0xfad519[_0x4fc6('0x69')]));_0x37ee95[_0x4fc6('0x63')](get_open_tabs(_0x4fc6('0x74'),_0xfad519[_0x4fc6('0x69')]));return BPromise['all'](_0x37ee95);})[_0x4fc6('0x1e')](function(_0x37d77c){var _0x1ba9c7=[];if(_0x37d77c){for(var _0x577c8f=0x0;_0x577c8f<values[_0x4fc6('0xd3')][_0x4fc6('0x56')];_0x577c8f++){var _0x410520=values[_0x4fc6('0xd3')][_0x577c8f];_0x1ba9c7[_0x4fc6('0x63')]({'channel':_0x4fc6('0xd4'),'id':_0x410520['id'],'createdAt':_0x410520[_0x4fc6('0xd5')]});}for(var _0x577c8f=0x0;_0x577c8f<values[_0x4fc6('0xd6')]['length'];_0x577c8f++){var _0x410520=values['FaxOpenTabs'][_0x577c8f];_0x1ba9c7[_0x4fc6('0x63')]({'channel':'FAX','id':_0x410520['id'],'createdAt':_0x410520[_0x4fc6('0xd5')]});}for(var _0x577c8f=0x0;_0x577c8f<values['OpenchannelOpenTabs']['length'];_0x577c8f++){var _0x410520=values[_0x4fc6('0xd7')][_0x577c8f];_0x1ba9c7['push']({'channel':_0x4fc6('0xd8'),'id':_0x410520['id'],'createdAt':_0x410520[_0x4fc6('0xd5')]});}for(var _0x577c8f=0x0;_0x577c8f<values['MailOpenTabs']['length'];_0x577c8f++){var _0x410520=values[_0x4fc6('0xd9')][_0x577c8f];_0x1ba9c7[_0x4fc6('0x63')]({'channel':_0x4fc6('0xda'),'id':_0x410520['id'],'createdAt':_0x410520[_0x4fc6('0xd5')]});}for(var _0x577c8f=0x0;_0x577c8f<values[_0x4fc6('0xdb')][_0x4fc6('0x56')];_0x577c8f++){var _0x410520=values['SmsOpenTabs'][_0x577c8f];_0x1ba9c7['push']({'channel':_0x4fc6('0xdc'),'id':_0x410520['id'],'createdAt':_0x410520[_0x4fc6('0xd5')]});}for(var _0x577c8f=0x0;_0x577c8f<values[_0x4fc6('0xdd')][_0x4fc6('0x56')];_0x577c8f++){var _0x410520=values[_0x4fc6('0xdd')][_0x577c8f];_0x1ba9c7[_0x4fc6('0x63')]({'channel':_0x4fc6('0xde'),'id':_0x410520['id'],'createdAt':_0x410520[_0x4fc6('0xd5')]});}var _0x8ef6f1={'count':_0x1ba9c7[_0x4fc6('0x56')],'rows':_0x1ba9c7};return _0x8ef6f1;}else return null;})[_0x4fc6('0x1e')](respondWithResult(_0x3ad118,null))[_0x4fc6('0x27')](handleError(_0x3ad118,null));};exports['getContacts']=function(_0x48b00f,_0x15894a,_0x14a3df){var _0x19d3e6={};var _0xb55288={};var _0xa5f95;var _0x402857;return db['User'][_0x4fc6('0xaa')]({'where':{'id':_0x48b00f[_0x4fc6('0x6f')]['id']}})['then'](handleEntityNotFound(_0x15894a,null))[_0x4fc6('0x1e')](function(_0x3e3b20){if(_0x3e3b20){_0xa5f95=_0x3e3b20;_0xb55288[_0x4fc6('0x4e')]=_[_0x4fc6('0x70')](db['CmContact'][_0x4fc6('0x71')]);_0xb55288[_0x4fc6('0x51')]=_[_0x4fc6('0x70')](_0x48b00f[_0x4fc6('0x51')]);_0xb55288[_0x4fc6('0x52')]=_[_0x4fc6('0x53')](_0xb55288[_0x4fc6('0x4e')],_0xb55288[_0x4fc6('0x51')]);_0x19d3e6[_0x4fc6('0x54')]=_[_0x4fc6('0x53')](_0xb55288['model'],qs[_0x4fc6('0x55')](_0x48b00f[_0x4fc6('0x51')][_0x4fc6('0x55')]));_0x19d3e6[_0x4fc6('0x54')]=_0x19d3e6['attributes'][_0x4fc6('0x56')]?_0x19d3e6[_0x4fc6('0x54')]:_0xb55288['model'];_0x19d3e6['order']=qs[_0x4fc6('0x58')](_0x48b00f[_0x4fc6('0x51')]['sort']);_0x19d3e6[_0x4fc6('0x5b')]=qs['filters'](_[_0x4fc6('0x59')](_0x48b00f[_0x4fc6('0x51')],_0xb55288[_0x4fc6('0x52')]));if(_0x48b00f[_0x4fc6('0x51')][_0x4fc6('0x3b')]){_0x19d3e6['where']=_[_0x4fc6('0x5a')](_0x19d3e6[_0x4fc6('0x5b')],{'$or':_[_0x4fc6('0x49')](_0x19d3e6[_0x4fc6('0x54')],function(_0x32ea06){var _0xad70ed={};_0xad70ed[_0x32ea06]={'$like':'%'+_0x48b00f['query'][_0x4fc6('0x3b')]+'%'};return _0xad70ed;})});}_0x19d3e6=_[_0x4fc6('0x5a')]({},_0x19d3e6,_0x48b00f[_0x4fc6('0x60')]);return _0xa5f95[_0x4fc6('0xdf')](_0x19d3e6);}})[_0x4fc6('0x1e')](function(_0x187474){if(_0x187474){_0x402857=_0x187474[_0x4fc6('0x56')];if(_0x48b00f['query']['hasOwnProperty'](_0x4fc6('0x61'))){_0x19d3e6[_0x4fc6('0x62')]=[{'model':db[_0x4fc6('0xe0')],'as':_0x4fc6('0xe1'),'required':![]},{'model':db[_0x4fc6('0xe2')],'as':'Tags','attributes':['id',_0x4fc6('0x40'),_0x4fc6('0xe3')],'where':_0x48b00f[_0x4fc6('0x51')][_0x4fc6('0xe4')]?{'id':_0x48b00f[_0x4fc6('0x51')][_0x4fc6('0xe4')]}:undefined,'required':_0x48b00f[_0x4fc6('0x51')][_0x4fc6('0xe4')]?!![]:![]}];}if(!_0x48b00f['query'][_0x4fc6('0x57')](_0x4fc6('0xe5'))){_0x19d3e6[_0x4fc6('0x2d')]=qs[_0x4fc6('0x2d')](_0x48b00f[_0x4fc6('0x51')]['limit']);_0x19d3e6[_0x4fc6('0x2f')]=qs[_0x4fc6('0x2f')](_0x48b00f[_0x4fc6('0x51')][_0x4fc6('0x2f')]);}return _0xa5f95[_0x4fc6('0xdf')](_0x19d3e6);}})[_0x4fc6('0x1e')](function(_0x4036e4){if(_0x4036e4){return _0x4036e4?{'count':_0x402857,'rows':_0x4036e4}:null;}})[_0x4fc6('0x1e')](respondWithResult(_0x15894a,null))[_0x4fc6('0x27')](handleError(_0x15894a,null));};exports['getQueues']=function(_0x286063,_0x4a5e29,_0x577eba){var _0x58b99f;var _0x70527e;var _0x5945d9={};var _0x3bcb21;return db[_0x4fc6('0x4a')][_0x4fc6('0xaa')]({'where':{'id':_0x286063[_0x4fc6('0x6f')]['id']},'attributes':['id','name',_0x4fc6('0x35')]})['then'](handleEntityNotFound(_0x4a5e29,null))[_0x4fc6('0x1e')](function(_0x97e80e){if(!utils[_0x4fc6('0xb6')](_0x286063['query'][_0x4fc6('0xb1')])){throw new db['Sequelize'][(_0x4fc6('0xa6'))]('Unknown\x20channel');}_0x58b99f=_0x97e80e;var _0x4ae9f5={};_0x4ae9f5[_0x4fc6('0x4e')]=_[_0x4fc6('0x70')](db[_[_0x4fc6('0xb8')](_0x286063[_0x4fc6('0x51')]['channel'])+'Queue']['rawAttributes']);_0x4ae9f5[_0x4fc6('0x51')]=_[_0x4fc6('0x70')](_0x286063['query']);_0x4ae9f5[_0x4fc6('0x52')]=_[_0x4fc6('0x53')](_0x4ae9f5['model'],_0x4ae9f5[_0x4fc6('0x51')]);_0x5945d9[_0x4fc6('0x54')]=_['intersection'](_0x4ae9f5[_0x4fc6('0x4e')],qs[_0x4fc6('0x55')](_0x286063[_0x4fc6('0x51')][_0x4fc6('0x55')]));_0x5945d9[_0x4fc6('0x54')]=_0x5945d9['attributes']['length']?_0x5945d9['attributes']:_0x4ae9f5['model'];_0x5945d9[_0x4fc6('0xe6')]=qs[_0x4fc6('0x58')](_0x286063[_0x4fc6('0x51')]['sort']);_0x5945d9['where']=qs['filters'](_[_0x4fc6('0x59')](_0x286063[_0x4fc6('0x51')],_0x4ae9f5[_0x4fc6('0x52')]));if(_0x286063[_0x4fc6('0x51')]['filter']){_0x5945d9[_0x4fc6('0x5b')]=_['merge'](_0x5945d9[_0x4fc6('0x5b')],{'$or':_[_0x4fc6('0x49')](_0x5945d9[_0x4fc6('0x54')],function(_0x2a47ff){var _0x1f8638={};_0x1f8638[_0x2a47ff]={'$like':'%'+_0x286063[_0x4fc6('0x51')][_0x4fc6('0x3b')]+'%'};return _0x1f8638;})});}_0x5945d9=_[_0x4fc6('0x5a')]({},_0x5945d9,_0x286063[_0x4fc6('0x60')]);switch(_0x58b99f[_0x4fc6('0x35')]){case _0x4fc6('0x97'):return db[_['capitalize'](_0x286063['query'][_0x4fc6('0xb1')])+_0x4fc6('0xe7')][_0x4fc6('0x64')](_0x5945d9);case _0x4fc6('0x37'):case'agent':return _0x58b99f[_0x4fc6('0x34')+_[_0x4fc6('0xb8')](_0x286063['query'][_0x4fc6('0xb1')])+'Queues'](_0x5945d9);default:throw new db[(_0x4fc6('0xa8'))][(_0x4fc6('0xa6'))](_0x4fc6('0xe8'));}})[_0x4fc6('0x1e')](function(_0x251c36){_0x3bcb21=_0x251c36[_0x4fc6('0x56')];if(!_0x286063[_0x4fc6('0x51')][_0x4fc6('0x57')]('nolimit')){_0x5945d9[_0x4fc6('0x2d')]=qs[_0x4fc6('0x2d')](_0x286063[_0x4fc6('0x51')]['limit']);_0x5945d9[_0x4fc6('0x2f')]=qs['offset'](_0x286063[_0x4fc6('0x51')][_0x4fc6('0x2f')]);}switch(_0x58b99f['role']){case _0x4fc6('0x97'):return db[_['capitalize'](_0x286063[_0x4fc6('0x51')][_0x4fc6('0xb1')])+_0x4fc6('0xe7')]['findAll'](_0x5945d9);case _0x4fc6('0x37'):case'agent':return _0x58b99f[_0x4fc6('0x34')+_[_0x4fc6('0xb8')](_0x286063[_0x4fc6('0x51')][_0x4fc6('0xb1')])+_0x4fc6('0xc5')](_0x5945d9);}})[_0x4fc6('0x1e')](function(_0x411953){return{'count':_0x3bcb21,'rows':_0x411953};})[_0x4fc6('0x1e')](respondWithResult(_0x4a5e29,null))[_0x4fc6('0x27')](handleError(_0x4a5e29,null));};exports[_0x4fc6('0xe9')]=function(_0x4c0341,_0x5dcada,_0x46bb48){var _0x548194={};var _0x4741f9={};var _0x1acde8;var _0x229398;return db[_0x4fc6('0x4a')][_0x4fc6('0xaa')]({'where':{'id':_0x4c0341[_0x4fc6('0x6f')]['id']}})[_0x4fc6('0x1e')](handleEntityNotFound(_0x5dcada,null))[_0x4fc6('0x1e')](function(_0x22fd22){if(_0x22fd22){_0x1acde8=_0x22fd22;_0x4741f9[_0x4fc6('0x4e')]=_['keys'](db['UserVoiceQueueRt']['rawAttributes']);_0x4741f9[_0x4fc6('0x51')]=_[_0x4fc6('0x70')](_0x4c0341[_0x4fc6('0x51')]);_0x4741f9[_0x4fc6('0x52')]=_[_0x4fc6('0x53')](_0x4741f9[_0x4fc6('0x4e')],_0x4741f9[_0x4fc6('0x51')]);_0x548194['attributes']=_['intersection'](_0x4741f9[_0x4fc6('0x4e')],qs[_0x4fc6('0x55')](_0x4c0341[_0x4fc6('0x51')][_0x4fc6('0x55')]));_0x548194['attributes']=_0x548194[_0x4fc6('0x54')][_0x4fc6('0x56')]?_0x548194['attributes']:_0x4741f9[_0x4fc6('0x4e')];_0x548194['order']=qs[_0x4fc6('0x58')](_0x4c0341[_0x4fc6('0x51')][_0x4fc6('0x58')]);_0x548194[_0x4fc6('0x5b')]=qs[_0x4fc6('0x52')](_['pick'](_0x4c0341['query'],_0x4741f9[_0x4fc6('0x52')]));if(_0x4c0341['query'][_0x4fc6('0x3b')]){_0x548194['where']=_['merge'](_0x548194['where'],{'$or':_[_0x4fc6('0x49')](_0x548194['attributes'],function(_0x58e69c){var _0x2f6856={};_0x2f6856[_0x58e69c]={'$like':'%'+_0x4c0341[_0x4fc6('0x51')][_0x4fc6('0x3b')]+'%'};return _0x2f6856;})});}_0x548194=_[_0x4fc6('0x5a')]({},_0x548194,_0x4c0341[_0x4fc6('0x60')]);return _0x1acde8['getVoiceQueuesRt'](_0x548194);}})[_0x4fc6('0x1e')](function(_0x19cdf0){if(_0x19cdf0){_0x229398=_0x19cdf0['length'];if(!_0x4c0341['query'][_0x4fc6('0x57')](_0x4fc6('0xe5'))){_0x548194['limit']=qs[_0x4fc6('0x2d')](_0x4c0341[_0x4fc6('0x51')][_0x4fc6('0x2d')]);_0x548194[_0x4fc6('0x2f')]=qs['offset'](_0x4c0341['query'][_0x4fc6('0x2f')]);}return _0x1acde8[_0x4fc6('0xe9')](_0x548194);}})[_0x4fc6('0x1e')](function(_0x4102a7){if(_0x4102a7){return _0x4102a7?{'count':_0x229398,'rows':_0x4102a7}:null;}})[_0x4fc6('0x1e')](respondWithResult(_0x5dcada,null))[_0x4fc6('0x27')](handleError(_0x5dcada,null));};exports[_0x4fc6('0xea')]=function(_0x4fa2d6,_0x24ec05,_0x56800b){var _0x2fa045={};var _0x349ea7={};var _0x100e09;var _0x241f0e;return db[_0x4fc6('0x4a')][_0x4fc6('0xaa')]({'where':{'id':_0x4fa2d6[_0x4fc6('0x6f')]['id']}})[_0x4fc6('0x1e')](handleEntityNotFound(_0x24ec05,null))[_0x4fc6('0x1e')](function(_0x232e98){if(_0x232e98){_0x100e09=_0x232e98;_0x349ea7[_0x4fc6('0x4e')]=_['keys'](db['ChatGroup'][_0x4fc6('0x71')]);_0x349ea7[_0x4fc6('0x51')]=_['keys'](_0x4fa2d6['query']);_0x349ea7[_0x4fc6('0x52')]=_[_0x4fc6('0x53')](_0x349ea7[_0x4fc6('0x4e')],_0x349ea7['query']);_0x2fa045['attributes']=_[_0x4fc6('0x53')](_0x349ea7[_0x4fc6('0x4e')],qs[_0x4fc6('0x55')](_0x4fa2d6['query']['fields']));_0x2fa045['attributes']=_0x2fa045[_0x4fc6('0x54')]['length']?_0x2fa045[_0x4fc6('0x54')]:_0x349ea7[_0x4fc6('0x4e')];_0x2fa045[_0x4fc6('0xe6')]=qs[_0x4fc6('0x58')](_0x4fa2d6[_0x4fc6('0x51')][_0x4fc6('0x58')]);_0x2fa045[_0x4fc6('0x5b')]=qs[_0x4fc6('0x52')](_[_0x4fc6('0x59')](_0x4fa2d6[_0x4fc6('0x51')],_0x349ea7[_0x4fc6('0x52')]));if(_0x4fa2d6[_0x4fc6('0x51')]['filter']){_0x2fa045['where']=_[_0x4fc6('0x5a')](_0x2fa045[_0x4fc6('0x5b')],{'$or':_[_0x4fc6('0x49')](_0x2fa045[_0x4fc6('0x54')],function(_0x300ddd){var _0x490031={};_0x490031[_0x300ddd]={'$like':'%'+_0x4fa2d6[_0x4fc6('0x51')][_0x4fc6('0x3b')]+'%'};return _0x490031;})});}_0x2fa045=_[_0x4fc6('0x5a')]({},_0x2fa045,_0x4fa2d6[_0x4fc6('0x60')]);return _0x100e09['getGroups'](_0x2fa045);}})['then'](function(_0x1ad20c){if(_0x1ad20c){_0x241f0e=_0x1ad20c['length'];if(!_0x4fa2d6[_0x4fc6('0x51')][_0x4fc6('0x57')]('nolimit')){_0x2fa045['limit']=qs[_0x4fc6('0x2d')](_0x4fa2d6[_0x4fc6('0x51')][_0x4fc6('0x2d')]);_0x2fa045[_0x4fc6('0x2f')]=qs[_0x4fc6('0x2f')](_0x4fa2d6[_0x4fc6('0x51')][_0x4fc6('0x2f')]);}return _0x100e09['getGroups'](_0x2fa045);}})[_0x4fc6('0x1e')](function(_0x31b1a5){if(_0x31b1a5){return _0x31b1a5?{'count':_0x241f0e,'rows':_0x31b1a5}:null;}})[_0x4fc6('0x1e')](respondWithResult(_0x24ec05,null))[_0x4fc6('0x27')](handleError(_0x24ec05,null));};exports[_0x4fc6('0xeb')]=function(_0x2c0517,_0x25ac0a,_0xb2bc4a){var _0x1a36a0={'raw':!![],'where':{}};var _0x20412d={};var _0x316fbd={'count':0x0,'rows':[]};return db[_0x4fc6('0x4a')][_0x4fc6('0xaa')]({'where':{'id':_0x2c0517['params']['id']}})['then'](handleEntityNotFound(_0x25ac0a,null))[_0x4fc6('0x1e')](function(_0x4ca935){if(_0x4ca935){_0x20412d[_0x4fc6('0x4e')]=_['keys'](db['VoiceRecording']['rawAttributes']);_0x20412d[_0x4fc6('0x51')]=_['keys'](_0x2c0517[_0x4fc6('0x51')]);_0x20412d[_0x4fc6('0x52')]=_['intersection'](_0x20412d[_0x4fc6('0x4e')],_0x20412d[_0x4fc6('0x51')]);_0x1a36a0[_0x4fc6('0x54')]=_[_0x4fc6('0x53')](_0x20412d[_0x4fc6('0x4e')],qs['fields'](_0x2c0517[_0x4fc6('0x51')][_0x4fc6('0x55')]));_0x1a36a0[_0x4fc6('0x54')]=_0x1a36a0[_0x4fc6('0x54')][_0x4fc6('0x56')]?_0x1a36a0[_0x4fc6('0x54')]:_0x20412d['model'];if(!_0x2c0517[_0x4fc6('0x51')][_0x4fc6('0x57')](_0x4fc6('0xe5'))){_0x1a36a0[_0x4fc6('0x2d')]=qs[_0x4fc6('0x2d')](_0x2c0517[_0x4fc6('0x51')][_0x4fc6('0x2d')]);_0x1a36a0[_0x4fc6('0x2f')]=qs[_0x4fc6('0x2f')](_0x2c0517[_0x4fc6('0x51')]['offset']);}_0x1a36a0['order']=qs[_0x4fc6('0x58')](_0x2c0517[_0x4fc6('0x51')][_0x4fc6('0x58')]);_0x1a36a0[_0x4fc6('0x5b')]=qs['filters'](_[_0x4fc6('0x59')](_0x2c0517[_0x4fc6('0x51')],_0x20412d[_0x4fc6('0x52')]));_0x1a36a0[_0x4fc6('0x5b')][_0x4fc6('0xec')]=_0x4ca935['id'];if(_0x2c0517[_0x4fc6('0x51')]['filter']){_0x1a36a0[_0x4fc6('0x5b')]=_[_0x4fc6('0x5a')](_0x1a36a0[_0x4fc6('0x5b')],{'$or':_[_0x4fc6('0x49')](_0x1a36a0['attributes'],function(_0x24f459){var _0x7a063c={};_0x7a063c[_0x24f459]={'$like':'%'+_0x2c0517[_0x4fc6('0x51')][_0x4fc6('0x3b')]+'%'};return _0x7a063c;})});}_0x1a36a0=_[_0x4fc6('0x5a')]({},_0x1a36a0,_0x2c0517['options']);return db[_0x4fc6('0xed')][_0x4fc6('0x2e')]({'where':_0x1a36a0[_0x4fc6('0x5b')]})[_0x4fc6('0x1e')](function(_0x13dd8e){_0x316fbd[_0x4fc6('0x2e')]=_0x13dd8e;if(_0x2c0517[_0x4fc6('0x51')]['includeAll']){_0x1a36a0[_0x4fc6('0x62')]=[{'all':!![]}];}return db['VoiceRecording'][_0x4fc6('0x64')](_0x1a36a0);})[_0x4fc6('0x1e')](function(_0x2f8503){_0x316fbd[_0x4fc6('0x65')]=_0x2f8503;return _0x316fbd;});}})[_0x4fc6('0x1e')](respondWithFilteredResult(_0x25ac0a,_0x1a36a0))[_0x4fc6('0x27')](handleError(_0x25ac0a,null));};exports[_0x4fc6('0xee')]=function(_0x2433ca,_0x283d78,_0x3a7717){var _0x97d68b={'raw':!![],'where':{}};var _0x4c887d={};var _0x41140c={'count':0x0,'rows':[]};return db[_0x4fc6('0x4a')][_0x4fc6('0xaa')]({'where':{'id':_0x2433ca[_0x4fc6('0x6f')]['id']}})['then'](handleEntityNotFound(_0x283d78,null))[_0x4fc6('0x1e')](function(_0x4a5e7d){if(_0x4a5e7d){_0x4c887d[_0x4fc6('0x4e')]=_[_0x4fc6('0x70')](db[_0x4fc6('0xef')]['rawAttributes']);_0x4c887d['query']=_[_0x4fc6('0x70')](_0x2433ca[_0x4fc6('0x51')]);_0x4c887d[_0x4fc6('0x52')]=_[_0x4fc6('0x53')](_0x4c887d[_0x4fc6('0x4e')],_0x4c887d[_0x4fc6('0x51')]);_0x97d68b[_0x4fc6('0x54')]=_[_0x4fc6('0x53')](_0x4c887d[_0x4fc6('0x4e')],qs[_0x4fc6('0x55')](_0x2433ca['query']['fields']));_0x97d68b[_0x4fc6('0x54')]=_0x97d68b[_0x4fc6('0x54')]['length']?_0x97d68b[_0x4fc6('0x54')]:_0x4c887d[_0x4fc6('0x4e')];if(!_0x2433ca[_0x4fc6('0x51')][_0x4fc6('0x57')](_0x4fc6('0xe5'))){_0x97d68b[_0x4fc6('0x2d')]=qs[_0x4fc6('0x2d')](_0x2433ca[_0x4fc6('0x51')][_0x4fc6('0x2d')]);_0x97d68b['offset']=qs[_0x4fc6('0x2f')](_0x2433ca[_0x4fc6('0x51')][_0x4fc6('0x2f')]);}_0x97d68b[_0x4fc6('0xe6')]=qs['sort'](_0x2433ca['query'][_0x4fc6('0x58')]);_0x97d68b['where']=qs[_0x4fc6('0x52')](_[_0x4fc6('0x59')](_0x2433ca[_0x4fc6('0x51')],_0x4c887d[_0x4fc6('0x52')]));_0x97d68b[_0x4fc6('0x5b')][_0x4fc6('0xec')]=_0x4a5e7d['id'];if(_0x2433ca[_0x4fc6('0x51')][_0x4fc6('0x3b')]){_0x97d68b['where']=_['merge'](_0x97d68b[_0x4fc6('0x5b')],{'$or':_[_0x4fc6('0x49')](_0x97d68b['attributes'],function(_0x40b082){var _0x22ed33={};_0x22ed33[_0x40b082]={'$like':'%'+_0x2433ca['query'][_0x4fc6('0x3b')]+'%'};return _0x22ed33;})});}_0x97d68b=_[_0x4fc6('0x5a')]({},_0x97d68b,_0x2433ca[_0x4fc6('0x60')]);return db['ScreenRecording'][_0x4fc6('0x2e')]({'where':_0x97d68b['where']})['then'](function(_0x21ae0d){_0x41140c[_0x4fc6('0x2e')]=_0x21ae0d;if(_0x2433ca[_0x4fc6('0x51')]['includeAll']){_0x97d68b[_0x4fc6('0x62')]=[{'all':!![]}];}return db[_0x4fc6('0xef')][_0x4fc6('0x64')](_0x97d68b);})[_0x4fc6('0x1e')](function(_0x47907f){_0x41140c['rows']=_0x47907f;return _0x41140c;});}})[_0x4fc6('0x1e')](respondWithFilteredResult(_0x283d78,_0x97d68b))[_0x4fc6('0x27')](handleError(_0x283d78,null));};exports[_0x4fc6('0xf0')]=function(_0x3aa287,_0x49e266,_0x16442e){var _0x312fe8={};var _0x33f475={};var _0x5ee0b3;var _0x10602c;return db[_0x4fc6('0x4a')][_0x4fc6('0xaa')]({'where':{'id':_0x3aa287[_0x4fc6('0x6f')]['id']}})[_0x4fc6('0x1e')](handleEntityNotFound(_0x49e266,null))[_0x4fc6('0x1e')](function(_0x42474a){if(_0x42474a){_0x5ee0b3=_0x42474a;_0x33f475[_0x4fc6('0x4e')]=_[_0x4fc6('0x70')](db[_0x4fc6('0xf1')][_0x4fc6('0x71')]);_0x33f475[_0x4fc6('0x51')]=_[_0x4fc6('0x70')](_0x3aa287[_0x4fc6('0x51')]);_0x33f475[_0x4fc6('0x52')]=_[_0x4fc6('0x53')](_0x33f475[_0x4fc6('0x4e')],_0x33f475[_0x4fc6('0x51')]);_0x312fe8[_0x4fc6('0x54')]=_[_0x4fc6('0x53')](_0x33f475[_0x4fc6('0x4e')],qs[_0x4fc6('0x55')](_0x3aa287['query'][_0x4fc6('0x55')]));_0x312fe8['attributes']=_0x312fe8[_0x4fc6('0x54')]['length']?_0x312fe8[_0x4fc6('0x54')]:_0x33f475[_0x4fc6('0x4e')];_0x312fe8[_0x4fc6('0xe6')]=qs[_0x4fc6('0x58')](_0x3aa287[_0x4fc6('0x51')][_0x4fc6('0x58')]);_0x312fe8[_0x4fc6('0x5b')]=qs['filters'](_['pick'](_0x3aa287['query'],_0x33f475[_0x4fc6('0x52')]));if(_0x3aa287[_0x4fc6('0x51')]['filter']){_0x312fe8[_0x4fc6('0x5b')]=_[_0x4fc6('0x5a')](_0x312fe8[_0x4fc6('0x5b')],{'$or':_[_0x4fc6('0x49')](_0x312fe8[_0x4fc6('0x54')],function(_0x5afb09){var _0x100256={};_0x100256[_0x5afb09]={'$like':'%'+_0x3aa287[_0x4fc6('0x51')][_0x4fc6('0x3b')]+'%'};return _0x100256;})});}_0x312fe8=_['merge']({},_0x312fe8,_0x3aa287[_0x4fc6('0x60')]);return _0x5ee0b3[_0x4fc6('0xf0')](_0x312fe8);}})[_0x4fc6('0x1e')](function(_0x42019b){if(_0x42019b){_0x10602c=_0x42019b[_0x4fc6('0x56')];if(!_0x3aa287[_0x4fc6('0x51')][_0x4fc6('0x57')](_0x4fc6('0xe5'))){_0x312fe8[_0x4fc6('0x2d')]=qs[_0x4fc6('0x2d')](_0x3aa287[_0x4fc6('0x51')][_0x4fc6('0x2d')]);_0x312fe8[_0x4fc6('0x2f')]=qs[_0x4fc6('0x2f')](_0x3aa287['query'][_0x4fc6('0x2f')]);}return _0x5ee0b3['getChatInteractions'](_0x312fe8);}})['then'](function(_0x5663a5){if(_0x5663a5){return _0x5663a5?{'count':_0x10602c,'rows':_0x5663a5}:null;}})[_0x4fc6('0x1e')](respondWithResult(_0x49e266,null))[_0x4fc6('0x27')](handleError(_0x49e266,null));};exports[_0x4fc6('0xf2')]=function(_0x2fd8dd,_0x98ac5c,_0x5d0d0e){var _0x5b12fd={};var _0x57ccec={};var _0x2c2301;var _0x4d7044;return db[_0x4fc6('0x4a')][_0x4fc6('0xaa')]({'where':{'id':_0x2fd8dd['params']['id']}})[_0x4fc6('0x1e')](handleEntityNotFound(_0x98ac5c,null))[_0x4fc6('0x1e')](function(_0x1fe939){if(_0x1fe939){_0x2c2301=_0x1fe939;_0x57ccec[_0x4fc6('0x4e')]=_['keys'](db[_0x4fc6('0xf3')][_0x4fc6('0x71')]);_0x57ccec[_0x4fc6('0x51')]=_[_0x4fc6('0x70')](_0x2fd8dd[_0x4fc6('0x51')]);_0x57ccec[_0x4fc6('0x52')]=_[_0x4fc6('0x53')](_0x57ccec[_0x4fc6('0x4e')],_0x57ccec[_0x4fc6('0x51')]);_0x5b12fd['attributes']=_[_0x4fc6('0x53')](_0x57ccec[_0x4fc6('0x4e')],qs['fields'](_0x2fd8dd[_0x4fc6('0x51')][_0x4fc6('0x55')]));_0x5b12fd[_0x4fc6('0x54')]=_0x5b12fd[_0x4fc6('0x54')][_0x4fc6('0x56')]?_0x5b12fd[_0x4fc6('0x54')]:_0x57ccec['model'];_0x5b12fd[_0x4fc6('0xe6')]=qs[_0x4fc6('0x58')](_0x2fd8dd[_0x4fc6('0x51')]['sort']);_0x5b12fd[_0x4fc6('0x5b')]=qs[_0x4fc6('0x52')](_[_0x4fc6('0x59')](_0x2fd8dd['query'],_0x57ccec[_0x4fc6('0x52')]));if(_0x2fd8dd[_0x4fc6('0x51')][_0x4fc6('0x3b')]){_0x5b12fd[_0x4fc6('0x5b')]=_['merge'](_0x5b12fd['where'],{'$or':_[_0x4fc6('0x49')](_0x5b12fd[_0x4fc6('0x54')],function(_0x3822f9){var _0x3baf8c={};_0x3baf8c[_0x3822f9]={'$like':'%'+_0x2fd8dd['query'][_0x4fc6('0x3b')]+'%'};return _0x3baf8c;})});}_0x5b12fd=_[_0x4fc6('0x5a')]({},_0x5b12fd,_0x2fd8dd[_0x4fc6('0x60')]);return _0x2c2301[_0x4fc6('0xf2')](_0x5b12fd);}})[_0x4fc6('0x1e')](function(_0x2f7c0d){if(_0x2f7c0d){_0x4d7044=_0x2f7c0d[_0x4fc6('0x56')];if(!_0x2fd8dd[_0x4fc6('0x51')][_0x4fc6('0x57')](_0x4fc6('0xe5'))){_0x5b12fd[_0x4fc6('0x2d')]=qs[_0x4fc6('0x2d')](_0x2fd8dd[_0x4fc6('0x51')]['limit']);_0x5b12fd['offset']=qs[_0x4fc6('0x2f')](_0x2fd8dd[_0x4fc6('0x51')][_0x4fc6('0x2f')]);}return _0x2c2301[_0x4fc6('0xf2')](_0x5b12fd);}})[_0x4fc6('0x1e')](function(_0x3e0ab7){if(_0x3e0ab7){return _0x3e0ab7?{'count':_0x4d7044,'rows':_0x3e0ab7}:null;}})[_0x4fc6('0x1e')](respondWithResult(_0x98ac5c,null))[_0x4fc6('0x27')](handleError(_0x98ac5c,null));};exports[_0x4fc6('0xf4')]=function(_0x451247,_0x4486e0,_0x16c421){var _0x4941ff={'raw':!![],'where':{}};var _0x9c4e5e={};var _0x4d7230={'count':0x0,'rows':[]};return db[_0x4fc6('0x4a')]['findOne']({'where':{'id':_0x451247[_0x4fc6('0x6f')]['id']}})[_0x4fc6('0x1e')](handleEntityNotFound(_0x4486e0,null))[_0x4fc6('0x1e')](function(_0xe3c1da){if(_0xe3c1da){_0x9c4e5e[_0x4fc6('0x4e')]=_[_0x4fc6('0x70')](db['MailInteraction'][_0x4fc6('0x71')]);_0x9c4e5e[_0x4fc6('0x51')]=_[_0x4fc6('0x70')](_0x451247[_0x4fc6('0x51')]);_0x9c4e5e[_0x4fc6('0x52')]=_[_0x4fc6('0x53')](_0x9c4e5e['model'],_0x9c4e5e['query']);_0x4941ff[_0x4fc6('0x54')]=_[_0x4fc6('0x53')](_0x9c4e5e[_0x4fc6('0x4e')],qs[_0x4fc6('0x55')](_0x451247['query'][_0x4fc6('0x55')]));_0x4941ff[_0x4fc6('0x54')]=_0x4941ff[_0x4fc6('0x54')][_0x4fc6('0x56')]?_0x4941ff['attributes']:_0x9c4e5e[_0x4fc6('0x4e')];if(!_0x451247[_0x4fc6('0x51')]['hasOwnProperty'](_0x4fc6('0xe5'))){_0x4941ff[_0x4fc6('0x2d')]=qs['limit'](_0x451247[_0x4fc6('0x51')][_0x4fc6('0x2d')]);_0x4941ff[_0x4fc6('0x2f')]=qs['offset'](_0x451247[_0x4fc6('0x51')][_0x4fc6('0x2f')]);}_0x4941ff[_0x4fc6('0xe6')]=qs[_0x4fc6('0x58')](_0x451247[_0x4fc6('0x51')][_0x4fc6('0x58')]);_0x4941ff['where']=qs['filters'](_[_0x4fc6('0x59')](_0x451247[_0x4fc6('0x51')],_0x9c4e5e['filters']));_0x4941ff[_0x4fc6('0x5b')][_0x4fc6('0xec')]=_0xe3c1da['id'];if(_0x451247['query'][_0x4fc6('0x3b')]){_0x4941ff[_0x4fc6('0x5b')]=_[_0x4fc6('0x5a')](_0x4941ff['where'],{'$or':_[_0x4fc6('0x49')](_0x4941ff[_0x4fc6('0x54')],function(_0xa5151b){var _0x274b2f={};_0x274b2f[_0xa5151b]={'$like':'%'+_0x451247['query']['filter']+'%'};return _0x274b2f;})});}_0x4941ff=_[_0x4fc6('0x5a')]({},_0x4941ff,_0x451247[_0x4fc6('0x60')]);return db[_0x4fc6('0xf5')]['count']({'where':_0x4941ff[_0x4fc6('0x5b')]})[_0x4fc6('0x1e')](function(_0x5412b0){_0x4d7230[_0x4fc6('0x2e')]=_0x5412b0;if(_0x451247[_0x4fc6('0x51')][_0x4fc6('0x61')]){_0x4941ff[_0x4fc6('0x62')]=[{'all':!![]}];}return db[_0x4fc6('0xf5')][_0x4fc6('0x64')](_0x4941ff);})[_0x4fc6('0x1e')](function(_0x534ba7){_0x4d7230[_0x4fc6('0x65')]=_0x534ba7;return _0x4d7230;});}})[_0x4fc6('0x1e')](respondWithFilteredResult(_0x4486e0,_0x4941ff))[_0x4fc6('0x27')](handleError(_0x4486e0,null));};exports['getSmsInteractions']=function(_0xf02c25,_0x2d49c7,_0x9f0c87){var _0x4b0af6={};var _0x2aa8b0={};var _0x40385b;var _0x23b0ad;return db[_0x4fc6('0x4a')][_0x4fc6('0xaa')]({'where':{'id':_0xf02c25['params']['id']}})[_0x4fc6('0x1e')](handleEntityNotFound(_0x2d49c7,null))[_0x4fc6('0x1e')](function(_0xda276c){if(_0xda276c){_0x40385b=_0xda276c;_0x2aa8b0[_0x4fc6('0x4e')]=_[_0x4fc6('0x70')](db['SmsInteraction'][_0x4fc6('0x71')]);_0x2aa8b0[_0x4fc6('0x51')]=_[_0x4fc6('0x70')](_0xf02c25[_0x4fc6('0x51')]);_0x2aa8b0[_0x4fc6('0x52')]=_[_0x4fc6('0x53')](_0x2aa8b0[_0x4fc6('0x4e')],_0x2aa8b0['query']);_0x4b0af6[_0x4fc6('0x54')]=_[_0x4fc6('0x53')](_0x2aa8b0[_0x4fc6('0x4e')],qs[_0x4fc6('0x55')](_0xf02c25[_0x4fc6('0x51')][_0x4fc6('0x55')]));_0x4b0af6['attributes']=_0x4b0af6['attributes'][_0x4fc6('0x56')]?_0x4b0af6[_0x4fc6('0x54')]:_0x2aa8b0[_0x4fc6('0x4e')];_0x4b0af6[_0x4fc6('0xe6')]=qs[_0x4fc6('0x58')](_0xf02c25[_0x4fc6('0x51')][_0x4fc6('0x58')]);_0x4b0af6[_0x4fc6('0x5b')]=qs[_0x4fc6('0x52')](_['pick'](_0xf02c25[_0x4fc6('0x51')],_0x2aa8b0['filters']));if(_0xf02c25[_0x4fc6('0x51')][_0x4fc6('0x3b')]){_0x4b0af6[_0x4fc6('0x5b')]=_['merge'](_0x4b0af6[_0x4fc6('0x5b')],{'$or':_[_0x4fc6('0x49')](_0x4b0af6[_0x4fc6('0x54')],function(_0x112b5a){var _0x51f030={};_0x51f030[_0x112b5a]={'$like':'%'+_0xf02c25[_0x4fc6('0x51')][_0x4fc6('0x3b')]+'%'};return _0x51f030;})});}_0x4b0af6=_['merge']({},_0x4b0af6,_0xf02c25[_0x4fc6('0x60')]);return _0x40385b[_0x4fc6('0xf6')](_0x4b0af6);}})[_0x4fc6('0x1e')](function(_0x50d41c){if(_0x50d41c){_0x23b0ad=_0x50d41c[_0x4fc6('0x56')];if(!_0xf02c25['query'][_0x4fc6('0x57')](_0x4fc6('0xe5'))){_0x4b0af6[_0x4fc6('0x2d')]=qs[_0x4fc6('0x2d')](_0xf02c25[_0x4fc6('0x51')]['limit']);_0x4b0af6['offset']=qs['offset'](_0xf02c25[_0x4fc6('0x51')][_0x4fc6('0x2f')]);}return _0x40385b[_0x4fc6('0xf6')](_0x4b0af6);}})[_0x4fc6('0x1e')](function(_0x32f191){if(_0x32f191){return _0x32f191?{'count':_0x23b0ad,'rows':_0x32f191}:null;}})[_0x4fc6('0x1e')](respondWithResult(_0x2d49c7,null))[_0x4fc6('0x27')](handleError(_0x2d49c7,null));};exports['getFaxInteractions']=function(_0x49ca3e,_0x551d9c,_0x51bbb8){var _0x29dcfd={};var _0x291a97={};var _0x3877cd;var _0x5d9021;return db[_0x4fc6('0x4a')][_0x4fc6('0xaa')]({'where':{'id':_0x49ca3e[_0x4fc6('0x6f')]['id']}})[_0x4fc6('0x1e')](handleEntityNotFound(_0x551d9c,null))[_0x4fc6('0x1e')](function(_0x54742b){if(_0x54742b){_0x3877cd=_0x54742b;_0x291a97['model']=_[_0x4fc6('0x70')](db[_0x4fc6('0xf7')][_0x4fc6('0x71')]);_0x291a97[_0x4fc6('0x51')]=_[_0x4fc6('0x70')](_0x49ca3e['query']);_0x291a97[_0x4fc6('0x52')]=_[_0x4fc6('0x53')](_0x291a97[_0x4fc6('0x4e')],_0x291a97[_0x4fc6('0x51')]);_0x29dcfd[_0x4fc6('0x54')]=_[_0x4fc6('0x53')](_0x291a97[_0x4fc6('0x4e')],qs['fields'](_0x49ca3e[_0x4fc6('0x51')][_0x4fc6('0x55')]));_0x29dcfd[_0x4fc6('0x54')]=_0x29dcfd[_0x4fc6('0x54')][_0x4fc6('0x56')]?_0x29dcfd[_0x4fc6('0x54')]:_0x291a97[_0x4fc6('0x4e')];_0x29dcfd[_0x4fc6('0xe6')]=qs[_0x4fc6('0x58')](_0x49ca3e[_0x4fc6('0x51')][_0x4fc6('0x58')]);_0x29dcfd[_0x4fc6('0x5b')]=qs[_0x4fc6('0x52')](_[_0x4fc6('0x59')](_0x49ca3e[_0x4fc6('0x51')],_0x291a97[_0x4fc6('0x52')]));if(_0x49ca3e[_0x4fc6('0x51')][_0x4fc6('0x3b')]){_0x29dcfd[_0x4fc6('0x5b')]=_[_0x4fc6('0x5a')](_0x29dcfd[_0x4fc6('0x5b')],{'$or':_[_0x4fc6('0x49')](_0x29dcfd[_0x4fc6('0x54')],function(_0x5e4a83){var _0x193839={};_0x193839[_0x5e4a83]={'$like':'%'+_0x49ca3e[_0x4fc6('0x51')][_0x4fc6('0x3b')]+'%'};return _0x193839;})});}_0x29dcfd=_[_0x4fc6('0x5a')]({},_0x29dcfd,_0x49ca3e[_0x4fc6('0x60')]);return _0x3877cd['getFaxInteractions'](_0x29dcfd);}})[_0x4fc6('0x1e')](function(_0x2eca2a){if(_0x2eca2a){_0x5d9021=_0x2eca2a[_0x4fc6('0x56')];if(!_0x49ca3e[_0x4fc6('0x51')][_0x4fc6('0x57')](_0x4fc6('0xe5'))){_0x29dcfd[_0x4fc6('0x2d')]=qs[_0x4fc6('0x2d')](_0x49ca3e[_0x4fc6('0x51')][_0x4fc6('0x2d')]);_0x29dcfd[_0x4fc6('0x2f')]=qs[_0x4fc6('0x2f')](_0x49ca3e[_0x4fc6('0x51')][_0x4fc6('0x2f')]);}return _0x3877cd[_0x4fc6('0xf8')](_0x29dcfd);}})[_0x4fc6('0x1e')](function(_0x35a49b){if(_0x35a49b){return _0x35a49b?{'count':_0x5d9021,'rows':_0x35a49b}:null;}})[_0x4fc6('0x1e')](respondWithResult(_0x551d9c,null))[_0x4fc6('0x27')](handleError(_0x551d9c,null));};exports['getWhatsappInteractions']=function(_0x590a88,_0x59b7b4,_0x2d73b5){var _0x53a162={};var _0x85230f={};var _0x8bfbed;var _0x51266d;return db[_0x4fc6('0x4a')]['findOne']({'where':{'id':_0x590a88[_0x4fc6('0x6f')]['id']}})[_0x4fc6('0x1e')](handleEntityNotFound(_0x59b7b4,null))[_0x4fc6('0x1e')](function(_0x2460b7){if(_0x2460b7){_0x8bfbed=_0x2460b7;_0x85230f[_0x4fc6('0x4e')]=_['keys'](db[_0x4fc6('0xf9')]['rawAttributes']);_0x85230f[_0x4fc6('0x51')]=_['keys'](_0x590a88[_0x4fc6('0x51')]);_0x85230f['filters']=_[_0x4fc6('0x53')](_0x85230f['model'],_0x85230f[_0x4fc6('0x51')]);_0x53a162[_0x4fc6('0x54')]=_[_0x4fc6('0x53')](_0x85230f[_0x4fc6('0x4e')],qs[_0x4fc6('0x55')](_0x590a88['query'][_0x4fc6('0x55')]));_0x53a162[_0x4fc6('0x54')]=_0x53a162[_0x4fc6('0x54')][_0x4fc6('0x56')]?_0x53a162[_0x4fc6('0x54')]:_0x85230f[_0x4fc6('0x4e')];_0x53a162[_0x4fc6('0xe6')]=qs[_0x4fc6('0x58')](_0x590a88[_0x4fc6('0x51')][_0x4fc6('0x58')]);_0x53a162[_0x4fc6('0x5b')]=qs[_0x4fc6('0x52')](_['pick'](_0x590a88[_0x4fc6('0x51')],_0x85230f['filters']));if(_0x590a88[_0x4fc6('0x51')][_0x4fc6('0x3b')]){_0x53a162[_0x4fc6('0x5b')]=_[_0x4fc6('0x5a')](_0x53a162[_0x4fc6('0x5b')],{'$or':_[_0x4fc6('0x49')](_0x53a162[_0x4fc6('0x54')],function(_0xe31db0){var _0x3b8918={};_0x3b8918[_0xe31db0]={'$like':'%'+_0x590a88[_0x4fc6('0x51')]['filter']+'%'};return _0x3b8918;})});}_0x53a162=_[_0x4fc6('0x5a')]({},_0x53a162,_0x590a88[_0x4fc6('0x60')]);return _0x8bfbed['getWhatsappInteractions'](_0x53a162);}})[_0x4fc6('0x1e')](function(_0x2e053b){if(_0x2e053b){_0x51266d=_0x2e053b[_0x4fc6('0x56')];if(!_0x590a88[_0x4fc6('0x51')][_0x4fc6('0x57')](_0x4fc6('0xe5'))){_0x53a162[_0x4fc6('0x2d')]=qs[_0x4fc6('0x2d')](_0x590a88[_0x4fc6('0x51')]['limit']);_0x53a162[_0x4fc6('0x2f')]=qs[_0x4fc6('0x2f')](_0x590a88[_0x4fc6('0x51')][_0x4fc6('0x2f')]);}return _0x8bfbed[_0x4fc6('0xfa')](_0x53a162);}})[_0x4fc6('0x1e')](function(_0x20a3b5){if(_0x20a3b5){return _0x20a3b5?{'count':_0x51266d,'rows':_0x20a3b5}:null;}})[_0x4fc6('0x1e')](respondWithResult(_0x59b7b4,null))[_0x4fc6('0x27')](handleError(_0x59b7b4,null));};exports['login']=function(_0x1687ac,_0x3cae9e,_0x1a3877){var _0x4a7e2c;var _0x5754a6;var _0x4c8698;var _0x69ea8a=!_['isNil'](_0x1687ac['params']['id'])?_0x1687ac[_0x4fc6('0x6f')]['id']:!_[_0x4fc6('0x80')](_0x1687ac[_0x4fc6('0x37')]['id'])?_0x1687ac['user']['id']:null;return db[_0x4fc6('0x4a')]['find']({'where':{'id':_0x69ea8a,'role':{'$or':['admin','user',_0x4fc6('0x45')]}},'attributes':['id','name','phone',_0x4fc6('0xfb'),_0x4fc6('0x35'),_0x4fc6('0x7e'),_0x4fc6('0xb3')]})['then'](function(_0x25ac6b){if(_0x25ac6b){if(_0x25ac6b[_0x4fc6('0x35')]===_0x4fc6('0x45')){_0x4a7e2c=_0x25ac6b;if(_0x1687ac[_0x4fc6('0x76')]['interface']){_0x4c8698=util[_0x4fc6('0xbe')]('LOCAL/%s@from-sip/n',_0x4a7e2c[_0x1687ac[_0x4fc6('0x76')][_0x4fc6('0xb5')]]);}else if(_0x1687ac['body']['intrf']){_0x4c8698=util[_0x4fc6('0xbe')](_0x4fc6('0xbf'),_0x1687ac[_0x4fc6('0x76')]['intrf']);}else{_0x4c8698=util[_0x4fc6('0xbe')]('SIP/%s',_0x4a7e2c[_0x4fc6('0x40')]);}socket['to'](util[_0x4fc6('0xbe')](_0x4fc6('0xfc'),_0x4a7e2c[_0x4fc6('0x40')]))['emit']('user:forcelogout',{'user':{'id':_0x4a7e2c['id'],'name':_0x4a7e2c['name']},'ip':_0x1687ac[_0x4fc6('0xfd')][_0x4fc6('0xfe')]||_0x1687ac[_0x4fc6('0xff')][_0x4fc6('0x100')]||_0x1687ac['socket'][_0x4fc6('0x100')]||_0x1687ac[_0x4fc6('0xff')][_0x4fc6('0x101')]['remoteAddress']});return db[_0x4fc6('0xc1')][_0x4fc6('0x33')]({'where':{'membername':_0x4a7e2c['name']},'individualHooks':!![]});}}else{throw new db[(_0x4fc6('0xa8'))][(_0x4fc6('0xa6'))]('User\x20not\x20found\x20or\x20not\x20allowed\x20to\x20perform\x20login\x20method');}})[_0x4fc6('0x1e')](function(){if(_0x4a7e2c){return _0x4a7e2c[_0x4fc6('0x102')]({'raw':!![]});}})[_0x4fc6('0x1e')](function(_0x2fc616){if(_0x4a7e2c){var _0x300b22=[];if(_0x2fc616){_0x5754a6=_0x2fc616;if(_0x5754a6[_0x4fc6('0x56')]){for(var _0x27c583=0x0;_0x27c583<_0x5754a6['length'];_0x27c583++){_0x300b22[_0x4fc6('0x63')]({'membername':_0x4a7e2c[_0x4fc6('0x40')],'UserId':_0x4a7e2c['id'],'queue_name':_0x5754a6[_0x27c583][_0x4fc6('0x40')],'VoiceQueueId':_0x5754a6[_0x27c583]['id'],'interface':_0x4c8698,'paused':_0x4a7e2c[_0x4fc6('0xb3')]||![],'penalty':_0x5754a6[_0x27c583][_0x4fc6('0x103')]||0x0});}return BPromise['each'](_0x300b22,function(_0x5d9ffd){return db['UserVoiceQueueRt'][_0x4fc6('0x104')](_0x5d9ffd);});}}}})[_0x4fc6('0x1e')](function(){if(_0x4a7e2c){return db['MemberReport'][_0x4fc6('0x64')]({'where':{'membername':_0x4a7e2c['name'],'exitAt':null}});}})[_0x4fc6('0x1e')](function(_0x44b3e7){if(_0x4a7e2c){var _0x4561a4=[];_0x44b3e7[_0x4fc6('0x105')](function(_0x2ba37e){_0x4561a4[_0x4fc6('0x63')](_0x2ba37e[_0x4fc6('0x75')]({'exitAt':moment()[_0x4fc6('0xbe')](_0x4fc6('0x106'))}));});return BPromise[_0x4fc6('0x6d')](_0x4561a4);}})[_0x4fc6('0x1e')](function(){if(_0x4a7e2c){var _0x3cee0a=[];var _0x2b3cba=[];var _0x1f1e55=utils[_0x4fc6('0x107')]();var _0x24a974={'membername':_0x4a7e2c['name'],'interface':_0x4c8698,'enterAt':moment()[_0x4fc6('0xbe')](_0x4fc6('0x106')),'role':_0x4a7e2c[_0x4fc6('0x35')],'internal':_0x4a7e2c[_0x4fc6('0x7e')]};_0x1f1e55[_0x4fc6('0x105')](function(_0x1445e6){_0x3cee0a[_0x4fc6('0x63')](_[_0x4fc6('0x5a')]({'channel':_0x1445e6,'type':'LOGIN','data1':_0x1687ac[_0x4fc6('0x76')][_0x4fc6('0x108')],'data2':_0x4c8698},_0x24a974));if(_0x4a7e2c[_0x4fc6('0xb3')]){_0x2b3cba[_0x4fc6('0x63')](_[_0x4fc6('0x5a')]({'channel':_0x1445e6,'type':_0x4fc6('0x109'),'data1':_0x4fc6('0x10a')},_0x24a974));}});return db[_0x4fc6('0x10b')][_0x4fc6('0x9e')](_0x3cee0a[_0x4fc6('0x10c')](_0x2b3cba),{'individualHooks':!![]});}})[_0x4fc6('0x1e')](function(){if(_0x4a7e2c){return _0x4a7e2c[_0x4fc6('0x75')]({'online':!![],'lastLoginAt':moment()[_0x4fc6('0xbe')](_0x4fc6('0x106')),'voicePause':_0x4a7e2c[_0x4fc6('0xb3')]||![],'mailPause':_0x4a7e2c[_0x4fc6('0xb3')]||![],'chatPause':_0x4a7e2c[_0x4fc6('0xb3')]||![],'faxPause':_0x4a7e2c[_0x4fc6('0xb3')]||![],'smsPause':_0x4a7e2c['loginInPause']||![],'openchannelPause':_0x4a7e2c[_0x4fc6('0xb3')]||![],'whatsappPause':_0x4a7e2c[_0x4fc6('0xb3')]||![],'pauseType':_0x4a7e2c[_0x4fc6('0xb3')]?_0x4fc6('0x10a'):null,'interface':_0x4c8698,'lastPauseAt':moment()['format'](_0x4fc6('0x106'))});}})[_0x4fc6('0x1e')](function(_0x5afc1f){if(_0x1687ac[_0x4fc6('0x10d')]){return _0x1a3877();}else{return BPromise[_0x4fc6('0x10e')](_0x5afc1f)[_0x4fc6('0x1e')](respondWithResult(_0x3cae9e,null));}})[_0x4fc6('0x27')](handleError(_0x3cae9e,null));};exports[_0x4fc6('0x10f')]=function(_0x489dc3,_0x1c1ef0,_0x416aa5){var _0xa305ed;return db[_0x4fc6('0x4a')][_0x4fc6('0x3f')]({'where':{'id':_0x489dc3[_0x4fc6('0x6f')]['id'],'role':_0x4fc6('0x45')},'attributes':['id','name','role']})[_0x4fc6('0x1e')](handleEntityNotFound(_0x1c1ef0,null))[_0x4fc6('0x1e')](function(_0x1e80f6){if(_0x1e80f6){_0xa305ed=_0x1e80f6;return db[_0x4fc6('0xc1')][_0x4fc6('0x33')]({'where':{'membername':_0xa305ed[_0x4fc6('0x40')]},'individualHooks':!![]});}})[_0x4fc6('0x1e')](function(){return db[_0x4fc6('0x10b')][_0x4fc6('0x64')]({'where':{'membername':_0xa305ed[_0x4fc6('0x40')],'exitAt':null}});})[_0x4fc6('0x1e')](function(_0x5b9ad1){var _0x18766f=[];_0x5b9ad1['forEach'](function(_0x2c79c1){_0x18766f[_0x4fc6('0x63')](_0x2c79c1[_0x4fc6('0x75')]({'exitAt':moment()[_0x4fc6('0xbe')](_0x4fc6('0x106'))}));});return BPromise[_0x4fc6('0x6d')](_0x18766f);})['then'](function(){return _0xa305ed[_0x4fc6('0x75')]({'online':![],'voicePause':![],'mailPause':![],'chatPause':![],'faxPause':![],'smsPause':![],'openchannelPause':![],'whatsappPause':![],'interface':null});})[_0x4fc6('0x1e')](respondWithResult(_0x1c1ef0,null))[_0x4fc6('0x27')](handleError(_0x1c1ef0,null));};exports['pause']=function(_0x2c4a8f,_0x3e6c23,_0x504286){var _0xcce983;return db[_0x4fc6('0xc1')][_0x4fc6('0x75')]({'paused':0x1},{'where':{'UserId':_0x2c4a8f[_0x4fc6('0x6f')]['id']},'individualHooks':!![]})['then'](function(){return db[_0x4fc6('0x4a')][_0x4fc6('0x3f')]({'where':{'id':_0x2c4a8f[_0x4fc6('0x6f')]['id'],'role':_0x4fc6('0x45')},'attributes':['id',_0x4fc6('0x40'),_0x4fc6('0x35'),_0x4fc6('0x7e'),_0x4fc6('0xb5')]});})[_0x4fc6('0x1e')](handleEntityNotFound(_0x3e6c23,null))[_0x4fc6('0x1e')](function(_0x70d5c2){if(_0x70d5c2){_0xcce983=_0x70d5c2;return respondWithRpcPromise('QueuePause',_0x4fc6('0x110'),{'id':_0xcce983['id'],'name':_0xcce983[_0x4fc6('0x40')],'pause':!![]});}})['then'](function(){if(_0xcce983){return db[_0x4fc6('0x10b')][_0x4fc6('0x64')]({'where':{'membername':_0xcce983['name'],'type':_0x4fc6('0x109'),'exitAt':null}});}})[_0x4fc6('0x1e')](function(_0x4f51e4){if(_0x4f51e4[_0x4fc6('0x56')]){var _0x29b4d0=moment()[_0x4fc6('0xbe')](_0x4fc6('0x106'));for(var _0x2a7302=0x0,_0x5236c7=_0x4f51e4[_0x4fc6('0x56')];_0x2a7302<_0x5236c7;_0x2a7302++){_0x4f51e4[_0x2a7302]['updateAttributes']({'exitAt':_0x29b4d0});}}})[_0x4fc6('0x1e')](function(){var _0x342b14=[];var _0x4bcf21=utils['getChannels']();_0x4bcf21['forEach'](function(_0x103c69){_0x342b14[_0x4fc6('0x63')]({'channel':_0x103c69,'membername':_0xcce983['name'],'interface':_['isNil'](_0xcce983[_0x4fc6('0xb5')])?util[_0x4fc6('0xbe')](_0x4fc6('0xbf'),_0xcce983[_0x4fc6('0x40')]):_0xcce983[_0x4fc6('0xb5')],'type':_0x4fc6('0x109'),'enterAt':moment()[_0x4fc6('0xbe')]('YYYY-MM-DD\x20HH:mm:ss'),'data1':_0x2c4a8f['body']['type']||_0x4fc6('0x111'),'role':_0xcce983[_0x4fc6('0x35')],'internal':_0xcce983[_0x4fc6('0x7e')]});});return db[_0x4fc6('0x10b')][_0x4fc6('0x9e')](_0x342b14,{'individualHooks':!![]});})[_0x4fc6('0x1e')](function(){return _0xcce983[_0x4fc6('0x75')]({'voicePause':!![],'mailPause':!![],'chatPause':!![],'faxPause':!![],'smsPause':!![],'whatsappPause':!![],'openchannelPause':!![],'pauseType':_0x2c4a8f[_0x4fc6('0x76')][_0x4fc6('0x4c')]||'DEFAULT\x20PAUSE','lastPauseAt':moment()[_0x4fc6('0xbe')](_0x4fc6('0x106'))});})[_0x4fc6('0x1e')](respondWithResult(_0x3e6c23,null))['catch'](handleError(_0x3e6c23,null));};exports[_0x4fc6('0x112')]=function(_0xd66ebb,_0x16e98b,_0x4bc30d){var _0x3e8ea0;return db[_0x4fc6('0x4a')][_0x4fc6('0x3f')]({'where':{'id':_0xd66ebb['params']['id']},'attributes':['id',_0x4fc6('0x40'),_0x4fc6('0x35'),'voicePause',_0x4fc6('0x113'),_0x4fc6('0x114'),_0x4fc6('0x115'),_0x4fc6('0x116'),_0x4fc6('0x117'),_0x4fc6('0x118'),_0x4fc6('0x119'),'lastPauseAt']})[_0x4fc6('0x1e')](handleEntityNotFound(_0x16e98b,null))[_0x4fc6('0x1e')](function(_0x4f5ee5){if(_0x4f5ee5){_0x3e8ea0=_0x4f5ee5;if(_0xd66ebb[_0x4fc6('0x76')][_0x4fc6('0xb1')]&&!utils[_0x4fc6('0xb6')](_0xd66ebb[_0x4fc6('0x76')][_0x4fc6('0xb1')])){throw new db[(_0x4fc6('0xa8'))][(_0x4fc6('0xa6'))](_0x4fc6('0xc3'));}switch(_0xd66ebb[_0x4fc6('0x76')][_0x4fc6('0xb1')]){case _0x4fc6('0xbc'):return respondWithRpcPromise(_0x4fc6('0x11a'),_0x4fc6('0x112'),{'id':_0x3e8ea0['id'],'name':_0x3e8ea0[_0x4fc6('0x40')],'pause':![]})[_0x4fc6('0x1e')](function(){return db['UserVoiceQueueRt'][_0x4fc6('0x75')]({'paused':0x0},{'where':{'UserId':_0x3e8ea0['id']},'individualHooks':!![]});})['then'](function(){return db[_0x4fc6('0x10b')][_0x4fc6('0x3f')]({'where':{'channel':_0xd66ebb[_0x4fc6('0x76')]['channel'],'membername':_0x3e8ea0[_0x4fc6('0x40')],'type':'PAUSE','exitAt':null}});})[_0x4fc6('0x1e')](function(_0x5a675b){if(_0x5a675b){return _0x5a675b[_0x4fc6('0x75')]({'exitAt':moment()[_0x4fc6('0xbe')]('YYYY-MM-DD\x20HH:mm:ss'),'data2':'manual'},{'individualHooks':!![]});}return null;})['then'](function(){return _0x3e8ea0[_0x4fc6('0x75')]({'voicePause':![]});});case _0x4fc6('0x74'):case'chat':case'fax':case _0x4fc6('0x73'):case'whatsapp':case'openchannel':return db[_0x4fc6('0x10b')][_0x4fc6('0x3f')]({'where':{'channel':_0xd66ebb[_0x4fc6('0x76')][_0x4fc6('0xb1')],'membername':_0x3e8ea0[_0x4fc6('0x40')],'type':'PAUSE','exitAt':null}})['then'](function(_0x189bda){if(_0x189bda){return _0x189bda[_0x4fc6('0x75')]({'exitAt':moment()['format']('YYYY-MM-DD\x20HH:mm:ss'),'data2':'manual'},{'individualHooks':!![]});}return null;})[_0x4fc6('0x1e')](function(){var _0x4bd99e={};_['set'](_0x4bd99e,util[_0x4fc6('0xbe')](_0x4fc6('0x11b'),_0xd66ebb['body']['channel'],_0x4fc6('0x11c')),![]);return _0x3e8ea0[_0x4fc6('0x75')](_0x4bd99e);});default:return respondWithRpcPromise(_0x4fc6('0x11a'),_0x4fc6('0x112'),{'id':_0x3e8ea0['id'],'name':_0x3e8ea0['name'],'pause':![]})[_0x4fc6('0x1e')](function(){return db['UserVoiceQueueRt']['update']({'paused':0x0},{'where':{'UserId':_0x3e8ea0['id']}});})['then'](function(){return db[_0x4fc6('0x10b')]['findAll']({'where':{'membername':_0x3e8ea0[_0x4fc6('0x40')],'type':'PAUSE','exitAt':null}});})[_0x4fc6('0x1e')](function(_0x6713d7){var _0x12beeb=[];_0x6713d7[_0x4fc6('0x105')](function(_0x1e3d94){_0x12beeb[_0x4fc6('0x63')](_0x1e3d94[_0x4fc6('0x75')]({'exitAt':moment()[_0x4fc6('0xbe')](_0x4fc6('0x106')),'data2':_0x4fc6('0x11d')}));});return BPromise['all'](_0x12beeb);})[_0x4fc6('0x1e')](function(){return _0x3e8ea0[_0x4fc6('0x75')]({'voicePause':![],'mailPause':![],'chatPause':![],'faxPause':![],'smsPause':![],'whatsappPause':![],'openchannelPause':![]});});}}})[_0x4fc6('0x1e')](respondWithResult(_0x16e98b,null))['catch'](handleError(_0x16e98b,null));};exports[_0x4fc6('0x11e')]=function(_0x368f7a,_0x192ad3,_0x33e351){var _0x552ae5={};var _0x25681f={};var _0x3ad342;var _0x2f958e;return db['User'][_0x4fc6('0xaa')]({'where':{'id':_0x368f7a[_0x4fc6('0x6f')]['id']}})[_0x4fc6('0x1e')](handleEntityNotFound(_0x192ad3,null))[_0x4fc6('0x1e')](function(_0x6328b0){if(_0x6328b0){_0x3ad342=_0x6328b0;_0x25681f[_0x4fc6('0x4e')]=_[_0x4fc6('0x70')](db[_0x4fc6('0x11f')]['rawAttributes']);_0x25681f[_0x4fc6('0x51')]=_[_0x4fc6('0x70')](_0x368f7a[_0x4fc6('0x51')]);_0x25681f[_0x4fc6('0x52')]=_[_0x4fc6('0x53')](_0x25681f[_0x4fc6('0x4e')],_0x25681f['query']);_0x552ae5[_0x4fc6('0x54')]=_[_0x4fc6('0x53')](_0x25681f['model'],qs[_0x4fc6('0x55')](_0x368f7a[_0x4fc6('0x51')][_0x4fc6('0x55')]));_0x552ae5[_0x4fc6('0x54')]=_0x552ae5[_0x4fc6('0x54')]['length']?_0x552ae5[_0x4fc6('0x54')]:_0x25681f[_0x4fc6('0x4e')];_0x552ae5[_0x4fc6('0xe6')]=qs[_0x4fc6('0x58')](_0x368f7a[_0x4fc6('0x51')][_0x4fc6('0x58')]);_0x552ae5['where']=qs[_0x4fc6('0x52')](_[_0x4fc6('0x59')](_0x368f7a[_0x4fc6('0x51')],_0x25681f[_0x4fc6('0x52')]));if(_0x368f7a['query'][_0x4fc6('0x3b')]){_0x552ae5[_0x4fc6('0x5b')]=_[_0x4fc6('0x5a')](_0x552ae5[_0x4fc6('0x5b')],{'$or':_[_0x4fc6('0x49')](_0x552ae5[_0x4fc6('0x54')],function(_0x372223){var _0x55a7a3={};_0x55a7a3[_0x372223]={'$like':'%'+_0x368f7a[_0x4fc6('0x51')][_0x4fc6('0x3b')]+'%'};return _0x55a7a3;})});}_0x552ae5=_[_0x4fc6('0x5a')]({},_0x552ae5,_0x368f7a[_0x4fc6('0x60')]);return _0x3ad342['getTeams'](_0x552ae5);}})[_0x4fc6('0x1e')](function(_0x96bce6){if(_0x96bce6){_0x2f958e=_0x96bce6['length'];if(!_0x368f7a[_0x4fc6('0x51')][_0x4fc6('0x57')](_0x4fc6('0xe5'))){_0x552ae5[_0x4fc6('0x2d')]=qs[_0x4fc6('0x2d')](_0x368f7a[_0x4fc6('0x51')][_0x4fc6('0x2d')]);_0x552ae5[_0x4fc6('0x2f')]=qs['offset'](_0x368f7a['query'][_0x4fc6('0x2f')]);}return _0x3ad342['getTeams'](_0x552ae5);}})[_0x4fc6('0x1e')](function(_0x3d7fab){if(_0x3d7fab){return _0x3d7fab?{'count':_0x2f958e,'rows':_0x3d7fab}:null;}})['then'](respondWithResult(_0x192ad3,null))[_0x4fc6('0x27')](handleError(_0x192ad3,null));};exports['addTeams']=function(_0x357ec5,_0x2c9a39){return db['User']['find']({'where':{'id':_0x357ec5[_0x4fc6('0x6f')]['id']}})[_0x4fc6('0x1e')](handleEntityNotFound(_0x2c9a39,null))[_0x4fc6('0x1e')](function(_0x2043a2){if(_0x2043a2){var _0x4cea7c=_0x2043a2[_0x4fc6('0x34')]({'plain':!![]});return _0x2043a2[_0x4fc6('0x120')](_0x357ec5['body'][_0x4fc6('0x7a')],_['omit'](_0x357ec5[_0x4fc6('0x76')],[_0x4fc6('0x7a'),'id'])||{})[_0x4fc6('0x1e')](function(){for(var _0xb813c9=0x0;_0xb813c9<_0x357ec5[_0x4fc6('0x76')][_0x4fc6('0x7a')][_0x4fc6('0x56')];_0xb813c9++){var _0x254cd4=[];db[_0x4fc6('0x11f')]['findOne']({'where':{'id':_0x357ec5[_0x4fc6('0x76')]['ids'][_0xb813c9]}})['then'](function(_0x49e07e){_0x254cd4['push'](_0x49e07e[_0x4fc6('0x102')]()[_0x4fc6('0x1e')](function(_0x506970){for(var _0x57b20b=0x0;_0x57b20b<_0x506970[_0x4fc6('0x56')];_0x57b20b++){_0x506970[_0x57b20b][_0x4fc6('0x121')](_0x4fc6('0xb1'),'Voice');}return _0x506970;}));_0x254cd4[_0x4fc6('0x63')](_0x49e07e['getChatQueues']()[_0x4fc6('0x1e')](function(_0x4657a6){for(var _0x56265a=0x0;_0x56265a<_0x4657a6[_0x4fc6('0x56')];_0x56265a++){_0x4657a6[_0x56265a]['setDataValue'](_0x4fc6('0xb1'),_0x4fc6('0x122'));}return _0x4657a6;}));_0x254cd4[_0x4fc6('0x63')](_0x49e07e[_0x4fc6('0x123')]()[_0x4fc6('0x1e')](function(_0x166a41){for(var _0x4bfa14=0x0;_0x4bfa14<_0x166a41[_0x4fc6('0x56')];_0x4bfa14++){_0x166a41[_0x4bfa14]['setDataValue'](_0x4fc6('0xb1'),_0x4fc6('0x124'));}return _0x166a41;}));_0x254cd4[_0x4fc6('0x63')](_0x49e07e[_0x4fc6('0x125')]()[_0x4fc6('0x1e')](function(_0x5eb6a9){for(var _0x4c5178=0x0;_0x4c5178<_0x5eb6a9[_0x4fc6('0x56')];_0x4c5178++){_0x5eb6a9[_0x4c5178]['setDataValue'](_0x4fc6('0xb1'),_0x4fc6('0x126'));}return _0x5eb6a9;}));_0x254cd4[_0x4fc6('0x63')](_0x49e07e['getWhatsappQueues']()[_0x4fc6('0x1e')](function(_0x41a60e){for(var _0x1e7001=0x0;_0x1e7001<_0x41a60e[_0x4fc6('0x56')];_0x1e7001++){_0x41a60e[_0x1e7001][_0x4fc6('0x121')](_0x4fc6('0xb1'),_0x4fc6('0x127'));}return _0x41a60e;}));_0x254cd4[_0x4fc6('0x63')](_0x49e07e['getFaxQueues']()[_0x4fc6('0x1e')](function(_0x57e10f){for(var _0x1d9352=0x0;_0x1d9352<_0x57e10f[_0x4fc6('0x56')];_0x1d9352++){_0x57e10f[_0x1d9352][_0x4fc6('0x121')](_0x4fc6('0xb1'),_0x4fc6('0x128'));}return _0x57e10f;}));_0x254cd4[_0x4fc6('0x63')](_0x49e07e['getOpenchannelQueues']()[_0x4fc6('0x1e')](function(_0x264f6f){for(var _0x3ec241=0x0;_0x3ec241<_0x264f6f[_0x4fc6('0x56')];_0x3ec241++){_0x264f6f[_0x3ec241][_0x4fc6('0x121')](_0x4fc6('0xb1'),'Openchannel');}return _0x264f6f;}));return BPromise[_0x4fc6('0x6d')](_0x254cd4);})[_0x4fc6('0x1e')](function(_0x923f35){var _0x460d12=_[_0x4fc6('0x129')](_0x923f35);_0x254cd4=[];return db[_0x4fc6('0x5d')][_0x4fc6('0x12a')](function(_0x1034a3){for(var _0xf9bebd=0x0;_0xf9bebd<_0x460d12['length'];_0xf9bebd++){_0x254cd4[_0x4fc6('0x63')](_0x460d12[_0xf9bebd]['addAgent'](_0x4cea7c['id']),{'transaction':_0x1034a3});}return BPromise[_0x4fc6('0x6d')](_0x254cd4)[_0x4fc6('0x1e')](function(){if(_0x4cea7c[_0x4fc6('0xb2')]){return BPromise[_0x4fc6('0xa2')](_[_0x4fc6('0x3b')](_0x460d12,function(_0x39f407){return _0x39f407[_0x4fc6('0x12b')](_0x4fc6('0xb1'))===_0x4fc6('0x12c');}),function(_0x456ce8){return db[_0x4fc6('0xc1')][_0x4fc6('0x104')]({'membername':_0x4cea7c[_0x4fc6('0x40')],'UserId':_0x4cea7c['id'],'queue_name':_0x456ce8[_0x4fc6('0x40')],'VoiceQueueId':_0x456ce8['id'],'interface':_['isNil'](_0x4cea7c[_0x4fc6('0xb5')])?util['format']('SIP/%s',_0x4cea7c['name']):_0x4cea7c[_0x4fc6('0xb5')],'paused':_0x4cea7c[_0x4fc6('0xb4')]||![],'penalty':_0x4cea7c[_0x4fc6('0xc0')]},{'transaction':_0x1034a3});});}else{return;}})[_0x4fc6('0x1e')](function(){for(var _0x3f4d1c=0x0;_0x3f4d1c<_0x460d12[_0x4fc6('0x56')];_0x3f4d1c++){var _0xc554ae=_0x460d12[_0x3f4d1c][_0x4fc6('0x12b')]('channel');var _0x588bd5=_0xc554ae+_0x4fc6('0xc6');socket[_0x4fc6('0x12d')](_0x4fc6('0x37')+_0xc554ae+_0x4fc6('0xbb'),{'UserId':_0x4cea7c['id'],['queueField']:_0x460d12[_0x3f4d1c]['id']});}});});});}});}})['then'](respondWithStatusCode(_0x2c9a39,null))[_0x4fc6('0x27')](handleError(_0x2c9a39,null));};exports[_0x4fc6('0x12e')]=function(_0x21fac0,_0x4ccc1d){return db[_0x4fc6('0x4a')][_0x4fc6('0xaa')]({'where':{'id':_0x21fac0[_0x4fc6('0x6f')]['id']}})[_0x4fc6('0x1e')](handleEntityNotFound(_0x4ccc1d,null))['then'](function(_0x22037a){if(_0x22037a){var _0x46200a=_0x22037a['get']({'plain':!![]});var _0x1ed7ff=_0x21fac0[_0x4fc6('0x51')]['ids'];return _0x22037a[_0x4fc6('0x12e')](_0x1ed7ff)[_0x4fc6('0x1e')](function(){for(var _0x5abd2e=0x0;_0x5abd2e<_0x1ed7ff['length'];_0x5abd2e++){var _0x1c701a=[];db['Team'][_0x4fc6('0xaa')]({'where':{'id':_0x1ed7ff[_0x5abd2e]}})['then'](function(_0x49ab65){_0x1c701a['push'](_0x49ab65['getVoiceQueues']()[_0x4fc6('0x1e')](function(_0x1a4dc4){for(var _0xe4ccd7=0x0;_0xe4ccd7<_0x1a4dc4['length'];_0xe4ccd7++){_0x1a4dc4[_0xe4ccd7][_0x4fc6('0x121')](_0x4fc6('0xb1'),_0x4fc6('0x12c'));}return _0x1a4dc4;}));_0x1c701a[_0x4fc6('0x63')](_0x49ab65[_0x4fc6('0x12f')]()[_0x4fc6('0x1e')](function(_0x44dab4){for(var _0x760dab=0x0;_0x760dab<_0x44dab4['length'];_0x760dab++){_0x44dab4[_0x760dab][_0x4fc6('0x121')](_0x4fc6('0xb1'),_0x4fc6('0x122'));}return _0x44dab4;}));_0x1c701a[_0x4fc6('0x63')](_0x49ab65[_0x4fc6('0x123')]()[_0x4fc6('0x1e')](function(_0x6e2876){for(var _0x5111a7=0x0;_0x5111a7<_0x6e2876[_0x4fc6('0x56')];_0x5111a7++){_0x6e2876[_0x5111a7][_0x4fc6('0x121')]('channel',_0x4fc6('0x124'));}return _0x6e2876;}));_0x1c701a[_0x4fc6('0x63')](_0x49ab65[_0x4fc6('0x125')]()['then'](function(_0x3c6888){for(var _0x364186=0x0;_0x364186<_0x3c6888['length'];_0x364186++){_0x3c6888[_0x364186][_0x4fc6('0x121')](_0x4fc6('0xb1'),_0x4fc6('0x126'));}return _0x3c6888;}));_0x1c701a[_0x4fc6('0x63')](_0x49ab65['getWhatsappQueues']()[_0x4fc6('0x1e')](function(_0x1309eb){for(var _0x23cde7=0x0;_0x23cde7<_0x1309eb['length'];_0x23cde7++){_0x1309eb[_0x23cde7]['setDataValue'](_0x4fc6('0xb1'),'Whatsapp');}return _0x1309eb;}));_0x1c701a[_0x4fc6('0x63')](_0x49ab65['getFaxQueues']()[_0x4fc6('0x1e')](function(_0x3aa1f0){for(var _0x3b6a98=0x0;_0x3b6a98<_0x3aa1f0[_0x4fc6('0x56')];_0x3b6a98++){_0x3aa1f0[_0x3b6a98][_0x4fc6('0x121')](_0x4fc6('0xb1'),'Fax');}return _0x3aa1f0;}));_0x1c701a['push'](_0x49ab65['getOpenchannelQueues']()['then'](function(_0x6ee990){for(var _0x5766fc=0x0;_0x5766fc<_0x6ee990['length'];_0x5766fc++){_0x6ee990[_0x5766fc][_0x4fc6('0x121')](_0x4fc6('0xb1'),_0x4fc6('0x130'));}return _0x6ee990;}));return BPromise[_0x4fc6('0x6d')](_0x1c701a);})[_0x4fc6('0x1e')](function(_0x51dfa9){var _0x46333f=_[_0x4fc6('0x129')](_0x51dfa9);_0x1c701a=[];return db['sequelize'][_0x4fc6('0x12a')](function(_0x52d4b3){for(var _0x2261e8=0x0;_0x2261e8<_0x46333f[_0x4fc6('0x56')];_0x2261e8++){_0x1c701a[_0x4fc6('0x63')](_0x46333f[_0x2261e8][_0x4fc6('0x131')](_0x46200a['id']),{'transaction':_0x52d4b3});}return BPromise[_0x4fc6('0x6d')](_0x1c701a)['then'](function(){if(_0x46200a[_0x4fc6('0xb2')]){return BPromise['each'](_[_0x4fc6('0x3b')](_0x46333f,function(_0x213594){return _0x213594[_0x4fc6('0x12b')](_0x4fc6('0xb1'))===_0x4fc6('0x12c');}),function(_0x5686b9){return db[_0x4fc6('0xc1')]['destroy']({'where':{'VoiceQueueId':_0x5686b9['id'],'UserId':_0x46200a['id']},'transaction':_0x52d4b3});});}else{return;}})['then'](function(){for(var _0x5ce893=0x0;_0x5ce893<_0x46333f['length'];_0x5ce893++){var _0x1447d4=_0x46333f[_0x5ce893][_0x4fc6('0x12b')](_0x4fc6('0xb1'));var _0x4aa4b3=_0x1447d4+_0x4fc6('0xc6');socket['emit'](_0x4fc6('0x37')+_0x1447d4+_0x4fc6('0xc7'),{'UserId':_0x46200a['id'],['queueField']:_0x46333f[_0x5ce893]['id']});}});});});}});}})[_0x4fc6('0x1e')](respondWithStatusCode(_0x4ccc1d,null))[_0x4fc6('0x27')](handleError(_0x4ccc1d,null));};exports['getLists']=function(_0x532737,_0xdd3b29,_0x1aa55c){var _0x49e89a={};var _0x3c7d42={};var _0x4e0040;var _0x2c20a7;return db[_0x4fc6('0x4a')][_0x4fc6('0xaa')]({'where':{'id':_0x532737['params']['id']}})[_0x4fc6('0x1e')](handleEntityNotFound(_0xdd3b29,null))[_0x4fc6('0x1e')](function(_0x54c377){if(_0x54c377){_0x4e0040=_0x54c377;_0x3c7d42[_0x4fc6('0x4e')]=_[_0x4fc6('0x70')](db[_0x4fc6('0xe0')]['rawAttributes']);_0x3c7d42['query']=_[_0x4fc6('0x70')](_0x532737['query']);_0x3c7d42[_0x4fc6('0x52')]=_[_0x4fc6('0x53')](_0x3c7d42[_0x4fc6('0x4e')],_0x3c7d42[_0x4fc6('0x51')]);_0x49e89a['attributes']=_[_0x4fc6('0x53')](_0x3c7d42['model'],qs[_0x4fc6('0x55')](_0x532737[_0x4fc6('0x51')]['fields']));_0x49e89a['attributes']=_0x49e89a['attributes'][_0x4fc6('0x56')]?_0x49e89a[_0x4fc6('0x54')]:_0x3c7d42['model'];_0x49e89a[_0x4fc6('0xe6')]=qs['sort'](_0x532737['query'][_0x4fc6('0x58')]);_0x49e89a[_0x4fc6('0x5b')]=qs[_0x4fc6('0x52')](_[_0x4fc6('0x59')](_0x532737[_0x4fc6('0x51')],_0x3c7d42[_0x4fc6('0x52')]));if(_0x532737['query'][_0x4fc6('0x3b')]){_0x49e89a[_0x4fc6('0x5b')]=_['merge'](_0x49e89a['where'],{'$or':_['map'](_0x49e89a[_0x4fc6('0x54')],function(_0x2849b1){var _0x53e15f={};_0x53e15f[_0x2849b1]={'$like':'%'+_0x532737[_0x4fc6('0x51')]['filter']+'%'};return _0x53e15f;})});}_0x49e89a=_[_0x4fc6('0x5a')]({},_0x49e89a,_0x532737[_0x4fc6('0x60')]);return _0x4e0040[_0x4fc6('0x132')](_0x49e89a);}})[_0x4fc6('0x1e')](function(_0x183820){if(_0x183820){_0x2c20a7=_0x183820[_0x4fc6('0x56')];if(!_0x532737[_0x4fc6('0x51')]['hasOwnProperty'](_0x4fc6('0xe5'))){_0x49e89a[_0x4fc6('0x2d')]=qs['limit'](_0x532737[_0x4fc6('0x51')]['limit']);_0x49e89a[_0x4fc6('0x2f')]=qs[_0x4fc6('0x2f')](_0x532737[_0x4fc6('0x51')][_0x4fc6('0x2f')]);}return _0x4e0040[_0x4fc6('0x132')](_0x49e89a);}})[_0x4fc6('0x1e')](function(_0x33b238){if(_0x33b238){return _0x33b238?{'count':_0x2c20a7,'rows':_0x33b238}:null;}})['then'](respondWithResult(_0xdd3b29,null))[_0x4fc6('0x27')](handleError(_0xdd3b29,null));};exports[_0x4fc6('0x133')]=function(_0x45fd44,_0x3563d1,_0x3b1f86){var _0x2dee9a={};var _0x92a035={};var _0xdefb8f;var _0x30e64d;return db[_0x4fc6('0x4a')]['findOne']({'where':{'id':_0x45fd44[_0x4fc6('0x6f')]['id']}})['then'](handleEntityNotFound(_0x3563d1,null))[_0x4fc6('0x1e')](function(_0x4fa05e){if(_0x4fa05e){_0xdefb8f=_0x4fa05e;_0x92a035[_0x4fc6('0x4e')]=_[_0x4fc6('0x70')](db[_0x4fc6('0x4a')]['rawAttributes']);_0x92a035[_0x4fc6('0x51')]=_[_0x4fc6('0x70')](_0x45fd44[_0x4fc6('0x51')]);_0x92a035['filters']=_[_0x4fc6('0x53')](_0x92a035[_0x4fc6('0x4e')],_0x92a035[_0x4fc6('0x51')]);_0x2dee9a['attributes']=_[_0x4fc6('0x53')](_0x92a035[_0x4fc6('0x4e')],qs[_0x4fc6('0x55')](_0x45fd44[_0x4fc6('0x51')][_0x4fc6('0x55')]));_0x2dee9a[_0x4fc6('0x54')]=_0x2dee9a['attributes'][_0x4fc6('0x56')]?_0x2dee9a[_0x4fc6('0x54')]:_0x92a035[_0x4fc6('0x4e')];_0x2dee9a[_0x4fc6('0xe6')]=qs[_0x4fc6('0x58')](_0x45fd44['query'][_0x4fc6('0x58')]);_0x2dee9a['where']=qs[_0x4fc6('0x52')](_[_0x4fc6('0x59')](_0x45fd44[_0x4fc6('0x51')],_0x92a035[_0x4fc6('0x52')]));if(_0x45fd44[_0x4fc6('0x51')][_0x4fc6('0x3b')]){_0x2dee9a['where']=_[_0x4fc6('0x5a')](_0x2dee9a['where'],{'$or':_[_0x4fc6('0x49')](_0x2dee9a[_0x4fc6('0x54')],function(_0x3171df){var _0x45ee0c={};_0x45ee0c[_0x3171df]={'$like':'%'+_0x45fd44['query'][_0x4fc6('0x3b')]+'%'};return _0x45ee0c;})});}_0x2dee9a[_0x4fc6('0x4e')]=db['User'];_0x2dee9a['as']=_0x4fc6('0x38');_0x2dee9a=_[_0x4fc6('0x5a')]({},_0x2dee9a,_0x45fd44['options']);return _0xdefb8f['getVoiceQueues']({'include':[_0x2dee9a]});}})[_0x4fc6('0x1e')](function(_0x2bda1c){if(_0x2bda1c){var _0x483544={},_0x17ae04=[],_0x3c7026=0x0;for(var _0x51f968=0x0;_0x51f968<_0x2bda1c[_0x4fc6('0x56')];_0x51f968+=0x1){for(var _0x3024e5=0x0,_0xd80caf;_0x3024e5<_0x2bda1c[_0x51f968][_0x4fc6('0x38')][_0x4fc6('0x56')];_0x3024e5+=0x1){_0xd80caf=_0x2bda1c[_0x51f968][_0x4fc6('0x38')][_0x3024e5][_0x4fc6('0x34')]({'plain':!![]});_0x483544[_0xd80caf['id']]=_0xd80caf;}}_0x483544=_[_0x4fc6('0x134')](_0x483544);for(var _0x3187d9=qs[_0x4fc6('0x2f')](_0x45fd44[_0x4fc6('0x51')][_0x4fc6('0x2f')]);_0x3187d9<_0x483544[_0x4fc6('0x56')]&&_0x17ae04[_0x4fc6('0x56')]<qs[_0x4fc6('0x2d')](_0x45fd44[_0x4fc6('0x51')][_0x4fc6('0x2d')]);_0x3187d9+=0x1){if(_0x483544[_0x3187d9]){_0x17ae04[_0x4fc6('0x63')](_0x483544[_0x3187d9]);}}return{'count':_0x483544['length'],'rows':_0x17ae04};}})[_0x4fc6('0x1e')](respondWithResult(_0x3563d1,null))[_0x4fc6('0x27')](handleError(_0x3563d1,null));};exports[_0x4fc6('0x33')]=function(_0x1dc4fc,_0x2250c9){if(_0x1dc4fc[_0x4fc6('0x37')]['id']==_0x1dc4fc['params']['id']){return _0x2250c9[_0x4fc6('0x2a')](0x1f4)[_0x4fc6('0x42')]({'message':_0x4fc6('0x135')});}return db[_0x4fc6('0x4a')][_0x4fc6('0x3f')]({'where':{'id':_0x1dc4fc[_0x4fc6('0x6f')]['id']}})[_0x4fc6('0x1e')](handleEntityNotFound(_0x2250c9,null))['then'](removeEntity(_0x2250c9,null))[_0x4fc6('0x27')](handleError(_0x2250c9,null));};exports['addChatInteractions']=function(_0x4de3f1,_0x593a8e,_0xd1f0a4){return db[_0x4fc6('0x4a')][_0x4fc6('0x3f')]({'where':{'id':_0x4de3f1[_0x4fc6('0x6f')]['id']}})[_0x4fc6('0x1e')](handleEntityNotFound(_0x593a8e,null))['then'](function(_0x10d141){if(_0x10d141){return _0x10d141[_0x4fc6('0x136')](_0x4de3f1[_0x4fc6('0x76')]['ids'],_[_0x4fc6('0x79')](_0x4de3f1[_0x4fc6('0x76')],[_0x4fc6('0x7a'),'id'])||{})[_0x4fc6('0xba')](function(){for(var _0x5c3ffe=0x0;_0x5c3ffe<_0x4de3f1['body'][_0x4fc6('0x7a')][_0x4fc6('0x56')];_0x5c3ffe+=0x1){socket['emit'](_0x4fc6('0x137'),{'ChatInteractionId':Number(_0x4de3f1[_0x4fc6('0x76')][_0x4fc6('0x7a')][_0x5c3ffe]),'UserId':Number(_0x4de3f1[_0x4fc6('0x6f')]['id'])});}return _0x4de3f1['body'][_0x4fc6('0x7a')];});}})[_0x4fc6('0x1e')](respondWithResult(_0x593a8e,null))[_0x4fc6('0x27')](handleError(_0x593a8e,null));};exports[_0x4fc6('0x138')]=function(_0x5949b4,_0x30d9f3,_0x47c6d0){return db[_0x4fc6('0x4a')][_0x4fc6('0x3f')]({'where':{'id':_0x5949b4[_0x4fc6('0x6f')]['id']}})[_0x4fc6('0x1e')](handleEntityNotFound(_0x30d9f3,null))['then'](function(_0x2414e7){if(_0x2414e7){return _0x2414e7['removeChatInteractions'](_0x5949b4[_0x4fc6('0x51')][_0x4fc6('0x7a')])['then'](function(){if(_[_0x4fc6('0x139')](_0x5949b4[_0x4fc6('0x51')][_0x4fc6('0x7a')])){for(var _0xc80d1a=0x0;_0xc80d1a<_0x5949b4[_0x4fc6('0x51')]['ids'][_0x4fc6('0x56')];_0xc80d1a+=0x1){socket['emit']('user_has_chat_interactions:remove',{'ChatInteractionId':Number(_0x5949b4['query'][_0x4fc6('0x7a')][_0xc80d1a]),'UserId':Number(_0x5949b4[_0x4fc6('0x6f')]['id'])});}}else{socket[_0x4fc6('0x12d')](_0x4fc6('0x13a'),{'ChatInteractionId':Number(_0x5949b4[_0x4fc6('0x51')][_0x4fc6('0x7a')]),'UserId':Number(_0x5949b4['params']['id'])});}});}})[_0x4fc6('0x1e')](respondWithStatusCode(_0x30d9f3,null))['catch'](handleError(_0x30d9f3,null));};exports['addMailInteractions']=function(_0x20040f,_0x10f2bc,_0x1cc6e7){return db[_0x4fc6('0x4a')][_0x4fc6('0x3f')]({'where':{'id':_0x20040f[_0x4fc6('0x6f')]['id']}})[_0x4fc6('0x1e')](handleEntityNotFound(_0x10f2bc,null))[_0x4fc6('0x1e')](function(_0x5cb3b1){if(_0x5cb3b1){return _0x5cb3b1['addMailInteractions'](_0x20040f['body'][_0x4fc6('0x7a')],_[_0x4fc6('0x79')](_0x20040f[_0x4fc6('0x76')],[_0x4fc6('0x7a'),'id'])||{})['spread'](function(){for(var _0x2582e0=0x0;_0x2582e0<_0x20040f[_0x4fc6('0x76')][_0x4fc6('0x7a')][_0x4fc6('0x56')];_0x2582e0+=0x1){socket[_0x4fc6('0x12d')](_0x4fc6('0x13b'),{'MailInteractionId':Number(_0x20040f[_0x4fc6('0x76')][_0x4fc6('0x7a')][_0x2582e0]),'UserId':Number(_0x20040f['params']['id'])});}return _0x20040f['body']['ids'];});}})[_0x4fc6('0x1e')](respondWithResult(_0x10f2bc,null))['catch'](handleError(_0x10f2bc,null));};exports[_0x4fc6('0x13c')]=function(_0x159a81,_0x3a1755,_0x4125e7){return db[_0x4fc6('0x4a')]['find']({'where':{'id':_0x159a81[_0x4fc6('0x6f')]['id']}})['then'](handleEntityNotFound(_0x3a1755,null))['then'](function(_0x49a8ac){if(_0x49a8ac){return _0x49a8ac[_0x4fc6('0x13c')](_0x159a81[_0x4fc6('0x51')][_0x4fc6('0x7a')])['then'](function(){if(_['isArray'](_0x159a81['query'][_0x4fc6('0x7a')])){for(var _0xd14526=0x0;_0xd14526<_0x159a81[_0x4fc6('0x51')]['ids'][_0x4fc6('0x56')];_0xd14526+=0x1){socket[_0x4fc6('0x12d')](_0x4fc6('0x13d'),{'MailInteractionId':Number(_0x159a81[_0x4fc6('0x51')][_0x4fc6('0x7a')][_0xd14526]),'UserId':Number(_0x159a81[_0x4fc6('0x6f')]['id'])});}}else{socket[_0x4fc6('0x12d')](_0x4fc6('0x13d'),{'MailInteractionId':Number(_0x159a81[_0x4fc6('0x51')][_0x4fc6('0x7a')]),'UserId':Number(_0x159a81[_0x4fc6('0x6f')]['id'])});}});}})['then'](respondWithStatusCode(_0x3a1755,null))[_0x4fc6('0x27')](handleError(_0x3a1755,null));};exports[_0x4fc6('0x13e')]=function(_0x4d43a5,_0x5cf0cf,_0x253bbf){return db[_0x4fc6('0x4a')][_0x4fc6('0x3f')]({'where':{'id':_0x4d43a5[_0x4fc6('0x6f')]['id']}})[_0x4fc6('0x1e')](handleEntityNotFound(_0x5cf0cf,null))[_0x4fc6('0x1e')](function(_0x1c74b8){if(_0x1c74b8){return _0x1c74b8[_0x4fc6('0x13e')](_0x4d43a5[_0x4fc6('0x76')][_0x4fc6('0x7a')],_[_0x4fc6('0x79')](_0x4d43a5['body'],[_0x4fc6('0x7a'),'id'])||{})[_0x4fc6('0xba')](function(){for(var _0x595f8a=0x0;_0x595f8a<_0x4d43a5[_0x4fc6('0x76')]['ids'][_0x4fc6('0x56')];_0x595f8a+=0x1){socket[_0x4fc6('0x12d')](_0x4fc6('0x13f'),{'FaxInteractionId':Number(_0x4d43a5[_0x4fc6('0x76')][_0x4fc6('0x7a')][_0x595f8a]),'UserId':Number(_0x4d43a5['params']['id'])});}return _0x4d43a5[_0x4fc6('0x76')][_0x4fc6('0x7a')];});}})[_0x4fc6('0x1e')](respondWithResult(_0x5cf0cf,null))[_0x4fc6('0x27')](handleError(_0x5cf0cf,null));};exports[_0x4fc6('0x140')]=function(_0x4cb73e,_0x5993d1,_0x42ed90){return db['User']['find']({'where':{'id':_0x4cb73e[_0x4fc6('0x6f')]['id']}})['then'](handleEntityNotFound(_0x5993d1,null))[_0x4fc6('0x1e')](function(_0x4097fa){if(_0x4097fa){return _0x4097fa['removeFaxInteractions'](_0x4cb73e[_0x4fc6('0x51')][_0x4fc6('0x7a')])[_0x4fc6('0x1e')](function(){if(_[_0x4fc6('0x139')](_0x4cb73e['query']['ids'])){for(var _0x5c6783=0x0;_0x5c6783<_0x4cb73e[_0x4fc6('0x51')][_0x4fc6('0x7a')]['length'];_0x5c6783+=0x1){socket[_0x4fc6('0x12d')](_0x4fc6('0x141'),{'FaxInteractionId':Number(_0x4cb73e['query']['ids'][_0x5c6783]),'UserId':Number(_0x4cb73e[_0x4fc6('0x6f')]['id'])});}}else{socket[_0x4fc6('0x12d')](_0x4fc6('0x141'),{'FaxInteractionId':Number(_0x4cb73e[_0x4fc6('0x51')][_0x4fc6('0x7a')]),'UserId':Number(_0x4cb73e[_0x4fc6('0x6f')]['id'])});}});}})[_0x4fc6('0x1e')](respondWithStatusCode(_0x5993d1,null))[_0x4fc6('0x27')](handleError(_0x5993d1,null));};exports[_0x4fc6('0x142')]=function(_0x4cd98b,_0x3222da,_0x5046dd){return db[_0x4fc6('0x4a')]['find']({'where':{'id':_0x4cd98b[_0x4fc6('0x6f')]['id']}})['then'](handleEntityNotFound(_0x3222da,null))[_0x4fc6('0x1e')](function(_0x5da92a){if(_0x5da92a){return _0x5da92a[_0x4fc6('0x142')](_0x4cd98b[_0x4fc6('0x76')][_0x4fc6('0x7a')],_[_0x4fc6('0x79')](_0x4cd98b[_0x4fc6('0x76')],[_0x4fc6('0x7a'),'id'])||{})[_0x4fc6('0xba')](function(){for(var _0x4dd6c8=0x0;_0x4dd6c8<_0x4cd98b['body'][_0x4fc6('0x7a')][_0x4fc6('0x56')];_0x4dd6c8+=0x1){socket['emit'](_0x4fc6('0x143'),{'SmsInteractionId':Number(_0x4cd98b[_0x4fc6('0x76')]['ids'][_0x4dd6c8]),'UserId':Number(_0x4cd98b['params']['id'])});}return _0x4cd98b[_0x4fc6('0x76')][_0x4fc6('0x7a')];});}})[_0x4fc6('0x1e')](respondWithResult(_0x3222da,null))['catch'](handleError(_0x3222da,null));};exports['removeSmsInteractions']=function(_0x2126f3,_0x3ee8fc,_0x1df09f){return db[_0x4fc6('0x4a')]['find']({'where':{'id':_0x2126f3['params']['id']}})[_0x4fc6('0x1e')](handleEntityNotFound(_0x3ee8fc,null))[_0x4fc6('0x1e')](function(_0x29a426){if(_0x29a426){return _0x29a426[_0x4fc6('0x144')](_0x2126f3['query']['ids'])[_0x4fc6('0x1e')](function(){if(_[_0x4fc6('0x139')](_0x2126f3[_0x4fc6('0x51')]['ids'])){for(var _0x465b1c=0x0;_0x465b1c<_0x2126f3[_0x4fc6('0x51')][_0x4fc6('0x7a')][_0x4fc6('0x56')];_0x465b1c+=0x1){socket[_0x4fc6('0x12d')](_0x4fc6('0x145'),{'SmsInteractionId':Number(_0x2126f3[_0x4fc6('0x51')]['ids'][_0x465b1c]),'UserId':Number(_0x2126f3[_0x4fc6('0x6f')]['id'])});}}else{socket[_0x4fc6('0x12d')](_0x4fc6('0x145'),{'SmsInteractionId':Number(_0x2126f3[_0x4fc6('0x51')][_0x4fc6('0x7a')]),'UserId':Number(_0x2126f3[_0x4fc6('0x6f')]['id'])});}});}})[_0x4fc6('0x1e')](respondWithStatusCode(_0x3ee8fc,null))[_0x4fc6('0x27')](handleError(_0x3ee8fc,null));};exports[_0x4fc6('0x146')]=function(_0x4206f3,_0x51bc74,_0x36e2fc){return db[_0x4fc6('0x4a')][_0x4fc6('0x3f')]({'where':{'id':_0x4206f3[_0x4fc6('0x6f')]['id']}})[_0x4fc6('0x1e')](handleEntityNotFound(_0x51bc74,null))[_0x4fc6('0x1e')](function(_0x4bd6e6){if(_0x4bd6e6){return _0x4bd6e6['addOpenchannelInteractions'](_0x4206f3[_0x4fc6('0x76')][_0x4fc6('0x7a')],_[_0x4fc6('0x79')](_0x4206f3[_0x4fc6('0x76')],[_0x4fc6('0x7a'),'id'])||{})[_0x4fc6('0xba')](function(){for(var _0x5a1359=0x0;_0x5a1359<_0x4206f3['body'][_0x4fc6('0x7a')][_0x4fc6('0x56')];_0x5a1359+=0x1){socket[_0x4fc6('0x12d')]('user_has_openchannel_interactions:save',{'OpenchannelInteractionId':Number(_0x4206f3[_0x4fc6('0x76')][_0x4fc6('0x7a')][_0x5a1359]),'UserId':Number(_0x4206f3['params']['id'])});}return _0x4206f3[_0x4fc6('0x76')][_0x4fc6('0x7a')];});}})['then'](respondWithResult(_0x51bc74,null))[_0x4fc6('0x27')](handleError(_0x51bc74,null));};exports[_0x4fc6('0x147')]=function(_0x142e8d,_0x30bafb,_0x402173){return db[_0x4fc6('0x4a')][_0x4fc6('0x3f')]({'where':{'id':_0x142e8d[_0x4fc6('0x6f')]['id']}})[_0x4fc6('0x1e')](handleEntityNotFound(_0x30bafb,null))[_0x4fc6('0x1e')](function(_0x4f6772){if(_0x4f6772){return _0x4f6772['removeOpenchannelInteractions'](_0x142e8d['query'][_0x4fc6('0x7a')])[_0x4fc6('0x1e')](function(){if(_[_0x4fc6('0x139')](_0x142e8d[_0x4fc6('0x51')][_0x4fc6('0x7a')])){for(var _0x5dd88b=0x0;_0x5dd88b<_0x142e8d['query'][_0x4fc6('0x7a')][_0x4fc6('0x56')];_0x5dd88b+=0x1){socket[_0x4fc6('0x12d')](_0x4fc6('0x148'),{'OpenchannelInteractionId':Number(_0x142e8d[_0x4fc6('0x51')][_0x4fc6('0x7a')][_0x5dd88b]),'UserId':Number(_0x142e8d[_0x4fc6('0x6f')]['id'])});}}else{socket[_0x4fc6('0x12d')](_0x4fc6('0x148'),{'OpenchannelInteractionId':Number(_0x142e8d['query'][_0x4fc6('0x7a')]),'UserId':Number(_0x142e8d[_0x4fc6('0x6f')]['id'])});}});}})[_0x4fc6('0x1e')](respondWithStatusCode(_0x30bafb,null))[_0x4fc6('0x27')](handleError(_0x30bafb,null));};exports['addWhatsappInteractions']=function(_0x582351,_0x5b8ad5,_0x172a60){return db[_0x4fc6('0x4a')][_0x4fc6('0x3f')]({'where':{'id':_0x582351[_0x4fc6('0x6f')]['id']}})[_0x4fc6('0x1e')](handleEntityNotFound(_0x5b8ad5,null))[_0x4fc6('0x1e')](function(_0x323e06){if(_0x323e06){return _0x323e06[_0x4fc6('0x149')](_0x582351[_0x4fc6('0x76')][_0x4fc6('0x7a')],_[_0x4fc6('0x79')](_0x582351[_0x4fc6('0x76')],[_0x4fc6('0x7a'),'id'])||{})['spread'](function(){for(var _0xbc7805=0x0;_0xbc7805<_0x582351[_0x4fc6('0x76')]['ids'][_0x4fc6('0x56')];_0xbc7805+=0x1){socket[_0x4fc6('0x12d')](_0x4fc6('0x14a'),{'WhatsappInteractionId':Number(_0x582351[_0x4fc6('0x76')]['ids'][_0xbc7805]),'UserId':Number(_0x582351[_0x4fc6('0x6f')]['id'])});}return _0x582351[_0x4fc6('0x76')][_0x4fc6('0x7a')];});}})['then'](respondWithResult(_0x5b8ad5,null))['catch'](handleError(_0x5b8ad5,null));};exports[_0x4fc6('0x14b')]=function(_0x5a4369,_0x28493c,_0x140816){return db['User']['find']({'where':{'id':_0x5a4369['params']['id']}})['then'](handleEntityNotFound(_0x28493c,null))[_0x4fc6('0x1e')](function(_0x2f0176){if(_0x2f0176){return _0x2f0176[_0x4fc6('0x14b')](_0x5a4369[_0x4fc6('0x51')][_0x4fc6('0x7a')]);}})['then'](respondWithStatusCode(_0x28493c,null))[_0x4fc6('0x27')](handleError(_0x28493c,null));};exports[_0x4fc6('0x14c')]=function(_0xd082c1,_0x3f4640,_0x5eb9fd){var _0x3f5360={};var _0x2dba4a={};var _0x1d7807;var _0x4bb0a4;return db['User'][_0x4fc6('0xaa')]({'where':{'id':_0xd082c1[_0x4fc6('0x6f')]['id']}})[_0x4fc6('0x1e')](handleEntityNotFound(_0x3f4640,null))[_0x4fc6('0x1e')](function(_0xfab440){if(_0xfab440){_0x1d7807=_0xfab440;_0x2dba4a[_0x4fc6('0x4e')]=_[_0x4fc6('0x70')](db[_0x4fc6('0x14d')][_0x4fc6('0x71')]);_0x2dba4a[_0x4fc6('0x51')]=_[_0x4fc6('0x70')](_0xd082c1['query']);_0x2dba4a['filters']=_[_0x4fc6('0x53')](_0x2dba4a[_0x4fc6('0x4e')],_0x2dba4a['query']);_0x3f5360[_0x4fc6('0x54')]=_[_0x4fc6('0x53')](_0x2dba4a[_0x4fc6('0x4e')],qs[_0x4fc6('0x55')](_0xd082c1[_0x4fc6('0x51')][_0x4fc6('0x55')]));_0x3f5360[_0x4fc6('0x54')]=_0x3f5360[_0x4fc6('0x54')][_0x4fc6('0x56')]?_0x3f5360[_0x4fc6('0x54')]:_0x2dba4a[_0x4fc6('0x4e')];_0x3f5360[_0x4fc6('0xe6')]=qs[_0x4fc6('0x58')](_0xd082c1[_0x4fc6('0x51')][_0x4fc6('0x58')]);_0x3f5360[_0x4fc6('0x5b')]=qs[_0x4fc6('0x52')](_[_0x4fc6('0x59')](_0xd082c1[_0x4fc6('0x51')],_0x2dba4a[_0x4fc6('0x52')]));if(_0xd082c1[_0x4fc6('0x51')][_0x4fc6('0x3b')]){_0x3f5360[_0x4fc6('0x5b')]=_[_0x4fc6('0x5a')](_0x3f5360[_0x4fc6('0x5b')],{'$or':_[_0x4fc6('0x49')](_0x3f5360[_0x4fc6('0x54')],function(_0x3dcb2e){var _0x908b39={};_0x908b39[_0x3dcb2e]={'$like':'%'+_0xd082c1[_0x4fc6('0x51')]['filter']+'%'};return _0x908b39;})});}_0x3f5360=_[_0x4fc6('0x5a')]({},_0x3f5360,_0xd082c1[_0x4fc6('0x60')]);return _0x1d7807[_0x4fc6('0x14c')](_0x3f5360);}})[_0x4fc6('0x1e')](function(_0x16b818){if(_0x16b818){_0x4bb0a4=_0x16b818[_0x4fc6('0x56')];if(!_0xd082c1[_0x4fc6('0x51')][_0x4fc6('0x57')]('nolimit')){_0x3f5360[_0x4fc6('0x2d')]=qs[_0x4fc6('0x2d')](_0xd082c1['query'][_0x4fc6('0x2d')]);_0x3f5360[_0x4fc6('0x2f')]=qs[_0x4fc6('0x2f')](_0xd082c1[_0x4fc6('0x51')][_0x4fc6('0x2f')]);}return _0x1d7807['getVoicePrefixes'](_0x3f5360);}})[_0x4fc6('0x1e')](function(_0xa48772){if(_0xa48772){return _0xa48772?{'count':_0x4bb0a4,'rows':_0xa48772}:null;}})[_0x4fc6('0x1e')](respondWithResult(_0x3f4640,null))[_0x4fc6('0x27')](handleError(_0x3f4640,null));};exports[_0x4fc6('0x14e')]=function(_0x2a16d0,_0xff348,_0x37ebd7){var _0xce7942={};var _0x37a2fe={};var _0x11e96e;var _0x1f0501;return db[_0x4fc6('0x4a')]['findOne']({'where':{'id':_0x2a16d0[_0x4fc6('0x6f')]['id']}})[_0x4fc6('0x1e')](handleEntityNotFound(_0xff348,null))[_0x4fc6('0x1e')](function(_0x1cfe25){if(_0x1cfe25){_0x11e96e=_0x1cfe25;_0x37a2fe['model']=_[_0x4fc6('0x70')](db['FaxAccount'][_0x4fc6('0x71')]);_0x37a2fe[_0x4fc6('0x51')]=_[_0x4fc6('0x70')](_0x2a16d0[_0x4fc6('0x51')]);_0x37a2fe[_0x4fc6('0x52')]=_[_0x4fc6('0x53')](_0x37a2fe[_0x4fc6('0x4e')],_0x37a2fe['query']);_0xce7942['attributes']=_[_0x4fc6('0x53')](_0x37a2fe[_0x4fc6('0x4e')],qs['fields'](_0x2a16d0[_0x4fc6('0x51')][_0x4fc6('0x55')]));_0xce7942[_0x4fc6('0x54')]=_0xce7942[_0x4fc6('0x54')][_0x4fc6('0x56')]?_0xce7942[_0x4fc6('0x54')]:_0x37a2fe[_0x4fc6('0x4e')];_0xce7942[_0x4fc6('0xe6')]=qs['sort'](_0x2a16d0['query'][_0x4fc6('0x58')]);_0xce7942['where']=qs[_0x4fc6('0x52')](_[_0x4fc6('0x59')](_0x2a16d0[_0x4fc6('0x51')],_0x37a2fe['filters']));if(_0x2a16d0[_0x4fc6('0x51')][_0x4fc6('0x3b')]){_0xce7942['where']=_['merge'](_0xce7942['where'],{'$or':_[_0x4fc6('0x49')](_0xce7942['attributes'],function(_0x3a51fc){var _0x266409={};_0x266409[_0x3a51fc]={'$like':'%'+_0x2a16d0[_0x4fc6('0x51')]['filter']+'%'};return _0x266409;})});}_0xce7942=_[_0x4fc6('0x5a')]({},_0xce7942,_0x2a16d0['options']);return _0x11e96e[_0x4fc6('0x14e')](_0xce7942);}})[_0x4fc6('0x1e')](function(_0x177978){if(_0x177978){_0x1f0501=_0x177978[_0x4fc6('0x56')];if(!_0x2a16d0['query'][_0x4fc6('0x57')]('nolimit')){_0xce7942[_0x4fc6('0x2d')]=qs[_0x4fc6('0x2d')](_0x2a16d0[_0x4fc6('0x51')][_0x4fc6('0x2d')]);_0xce7942[_0x4fc6('0x2f')]=qs[_0x4fc6('0x2f')](_0x2a16d0['query'][_0x4fc6('0x2f')]);}return _0x11e96e[_0x4fc6('0x14e')](_0xce7942);}})[_0x4fc6('0x1e')](function(_0x5b61ed){if(_0x5b61ed){return _0x5b61ed?{'count':_0x1f0501,'rows':_0x5b61ed}:null;}})['then'](respondWithResult(_0xff348,null))[_0x4fc6('0x27')](handleError(_0xff348,null));};exports['addFaxAccounts']=function(_0x1abbfc,_0x5d03bf,_0x5e2880){return db[_0x4fc6('0x4a')][_0x4fc6('0x3f')]({'where':{'id':_0x1abbfc[_0x4fc6('0x6f')]['id']}})[_0x4fc6('0x1e')](handleEntityNotFound(_0x5d03bf,null))[_0x4fc6('0x1e')](function(_0x3369b1){if(_0x3369b1){return _0x3369b1[_0x4fc6('0x14f')](_0x1abbfc[_0x4fc6('0x76')][_0x4fc6('0x7a')],_['omit'](_0x1abbfc[_0x4fc6('0x76')],[_0x4fc6('0x7a'),'id'])||{});}})[_0x4fc6('0x1e')](respondWithResult(_0x5d03bf,null))[_0x4fc6('0x27')](handleError(_0x5d03bf,null));};exports[_0x4fc6('0x150')]=function(_0x58595f,_0x5a0934,_0x2a5427){return db[_0x4fc6('0x4a')][_0x4fc6('0x3f')]({'where':{'id':_0x58595f['params']['id']}})[_0x4fc6('0x1e')](handleEntityNotFound(_0x5a0934,null))['then'](function(_0x5ada91){if(_0x5ada91){return _0x5ada91[_0x4fc6('0x150')](_0x58595f[_0x4fc6('0x51')][_0x4fc6('0x7a')]);}})['then'](respondWithStatusCode(_0x5a0934,null))[_0x4fc6('0x27')](handleError(_0x5a0934,null));};exports[_0x4fc6('0x151')]=function(_0x565a7a,_0xe6e4a7,_0x5f1666){var _0x5b0efa={};var _0x397f0f={};var _0x234f2e;var _0x22152a;return db['User'][_0x4fc6('0xaa')]({'where':{'id':_0x565a7a['params']['id']}})[_0x4fc6('0x1e')](handleEntityNotFound(_0xe6e4a7,null))['then'](function(_0x189c21){if(_0x189c21){_0x234f2e=_0x189c21;_0x397f0f[_0x4fc6('0x4e')]=_[_0x4fc6('0x70')](db['MailAccount'][_0x4fc6('0x71')]);_0x397f0f[_0x4fc6('0x51')]=_[_0x4fc6('0x70')](_0x565a7a[_0x4fc6('0x51')]);_0x397f0f[_0x4fc6('0x52')]=_[_0x4fc6('0x53')](_0x397f0f[_0x4fc6('0x4e')],_0x397f0f[_0x4fc6('0x51')]);_0x5b0efa['attributes']=_[_0x4fc6('0x53')](_0x397f0f['model'],qs[_0x4fc6('0x55')](_0x565a7a[_0x4fc6('0x51')][_0x4fc6('0x55')]));_0x5b0efa['attributes']=_0x5b0efa[_0x4fc6('0x54')][_0x4fc6('0x56')]?_0x5b0efa[_0x4fc6('0x54')]:_0x397f0f[_0x4fc6('0x4e')];_0x5b0efa[_0x4fc6('0xe6')]=qs[_0x4fc6('0x58')](_0x565a7a['query'][_0x4fc6('0x58')]);_0x5b0efa['where']=qs['filters'](_['pick'](_0x565a7a[_0x4fc6('0x51')],_0x397f0f[_0x4fc6('0x52')]));if(_0x565a7a[_0x4fc6('0x51')][_0x4fc6('0x3b')]){_0x5b0efa['where']=_[_0x4fc6('0x5a')](_0x5b0efa[_0x4fc6('0x5b')],{'$or':_['map'](_0x5b0efa[_0x4fc6('0x54')],function(_0x22da1a){var _0xe03296={};_0xe03296[_0x22da1a]={'$like':'%'+_0x565a7a[_0x4fc6('0x51')][_0x4fc6('0x3b')]+'%'};return _0xe03296;})});}_0x5b0efa=_[_0x4fc6('0x5a')]({},_0x5b0efa,_0x565a7a[_0x4fc6('0x60')]);return _0x234f2e[_0x4fc6('0x151')](_0x5b0efa);}})[_0x4fc6('0x1e')](function(_0x2aa76a){if(_0x2aa76a){_0x22152a=_0x2aa76a[_0x4fc6('0x56')];if(!_0x565a7a[_0x4fc6('0x51')]['hasOwnProperty'](_0x4fc6('0xe5'))){_0x5b0efa[_0x4fc6('0x2d')]=qs[_0x4fc6('0x2d')](_0x565a7a[_0x4fc6('0x51')][_0x4fc6('0x2d')]);_0x5b0efa[_0x4fc6('0x2f')]=qs['offset'](_0x565a7a[_0x4fc6('0x51')][_0x4fc6('0x2f')]);}return _0x234f2e[_0x4fc6('0x151')](_0x5b0efa);}})['then'](function(_0x4ebf0f){if(_0x4ebf0f){return _0x4ebf0f?{'count':_0x22152a,'rows':_0x4ebf0f}:null;}})['then'](respondWithResult(_0xe6e4a7,null))['catch'](handleError(_0xe6e4a7,null));};exports[_0x4fc6('0x152')]=function(_0x314b8b,_0x546ee7,_0x507226){return db['User'][_0x4fc6('0x3f')]({'where':{'id':_0x314b8b[_0x4fc6('0x6f')]['id']}})[_0x4fc6('0x1e')](handleEntityNotFound(_0x546ee7,null))[_0x4fc6('0x1e')](function(_0xc3549f){if(_0xc3549f){return _0xc3549f[_0x4fc6('0x152')](_0x314b8b[_0x4fc6('0x76')]['ids'],_[_0x4fc6('0x79')](_0x314b8b['body'],[_0x4fc6('0x7a'),'id'])||{});}})[_0x4fc6('0x1e')](respondWithResult(_0x546ee7,null))[_0x4fc6('0x27')](handleError(_0x546ee7,null));};exports[_0x4fc6('0x153')]=function(_0x128b2e,_0x4f438a,_0x2db9e7){return db[_0x4fc6('0x4a')]['find']({'where':{'id':_0x128b2e['params']['id']}})[_0x4fc6('0x1e')](handleEntityNotFound(_0x4f438a,null))[_0x4fc6('0x1e')](function(_0x182f82){if(_0x182f82){return _0x182f82['removeMailAccounts'](_0x128b2e['query'][_0x4fc6('0x7a')]);}})[_0x4fc6('0x1e')](respondWithStatusCode(_0x4f438a,null))[_0x4fc6('0x27')](handleError(_0x4f438a,null));};exports['getOpenchannelAccounts']=function(_0x27f733,_0x6ebb46,_0x7c1b81){var _0x53b2b4={};var _0x4e732a={};var _0x47556a;var _0x37ffbe;return db['User'][_0x4fc6('0xaa')]({'where':{'id':_0x27f733['params']['id']}})[_0x4fc6('0x1e')](handleEntityNotFound(_0x6ebb46,null))[_0x4fc6('0x1e')](function(_0xe46c30){if(_0xe46c30){_0x47556a=_0xe46c30;_0x4e732a['model']=_[_0x4fc6('0x70')](db[_0x4fc6('0x154')]['rawAttributes']);_0x4e732a[_0x4fc6('0x51')]=_['keys'](_0x27f733[_0x4fc6('0x51')]);_0x4e732a[_0x4fc6('0x52')]=_[_0x4fc6('0x53')](_0x4e732a[_0x4fc6('0x4e')],_0x4e732a[_0x4fc6('0x51')]);_0x53b2b4[_0x4fc6('0x54')]=_['intersection'](_0x4e732a[_0x4fc6('0x4e')],qs[_0x4fc6('0x55')](_0x27f733[_0x4fc6('0x51')]['fields']));_0x53b2b4['attributes']=_0x53b2b4['attributes'][_0x4fc6('0x56')]?_0x53b2b4[_0x4fc6('0x54')]:_0x4e732a[_0x4fc6('0x4e')];_0x53b2b4['order']=qs[_0x4fc6('0x58')](_0x27f733[_0x4fc6('0x51')][_0x4fc6('0x58')]);_0x53b2b4[_0x4fc6('0x5b')]=qs['filters'](_[_0x4fc6('0x59')](_0x27f733['query'],_0x4e732a[_0x4fc6('0x52')]));if(_0x27f733['query'][_0x4fc6('0x3b')]){_0x53b2b4[_0x4fc6('0x5b')]=_[_0x4fc6('0x5a')](_0x53b2b4['where'],{'$or':_[_0x4fc6('0x49')](_0x53b2b4[_0x4fc6('0x54')],function(_0x2f2a55){var _0x397b51={};_0x397b51[_0x2f2a55]={'$like':'%'+_0x27f733[_0x4fc6('0x51')][_0x4fc6('0x3b')]+'%'};return _0x397b51;})});}_0x53b2b4=_[_0x4fc6('0x5a')]({},_0x53b2b4,_0x27f733[_0x4fc6('0x60')]);return _0x47556a[_0x4fc6('0x155')](_0x53b2b4);}})['then'](function(_0x3ca4e1){if(_0x3ca4e1){_0x37ffbe=_0x3ca4e1[_0x4fc6('0x56')];if(!_0x27f733[_0x4fc6('0x51')][_0x4fc6('0x57')]('nolimit')){_0x53b2b4[_0x4fc6('0x2d')]=qs['limit'](_0x27f733[_0x4fc6('0x51')][_0x4fc6('0x2d')]);_0x53b2b4[_0x4fc6('0x2f')]=qs[_0x4fc6('0x2f')](_0x27f733['query'][_0x4fc6('0x2f')]);}return _0x47556a[_0x4fc6('0x155')](_0x53b2b4);}})[_0x4fc6('0x1e')](function(_0x47bce4){if(_0x47bce4){return _0x47bce4?{'count':_0x37ffbe,'rows':_0x47bce4}:null;}})[_0x4fc6('0x1e')](respondWithResult(_0x6ebb46,null))['catch'](handleError(_0x6ebb46,null));};exports['addOpenchannelAccounts']=function(_0x22c525,_0x310746,_0x4971c8){return db[_0x4fc6('0x4a')][_0x4fc6('0x3f')]({'where':{'id':_0x22c525[_0x4fc6('0x6f')]['id']}})[_0x4fc6('0x1e')](handleEntityNotFound(_0x310746,null))['then'](function(_0x2eba50){if(_0x2eba50){return _0x2eba50[_0x4fc6('0x156')](_0x22c525[_0x4fc6('0x76')][_0x4fc6('0x7a')],_['omit'](_0x22c525['body'],[_0x4fc6('0x7a'),'id'])||{});}})[_0x4fc6('0x1e')](respondWithResult(_0x310746,null))[_0x4fc6('0x27')](handleError(_0x310746,null));};exports['removeOpenchannelAccounts']=function(_0x4f27db,_0x56dabb,_0x48067d){return db[_0x4fc6('0x4a')][_0x4fc6('0x3f')]({'where':{'id':_0x4f27db[_0x4fc6('0x6f')]['id']}})[_0x4fc6('0x1e')](handleEntityNotFound(_0x56dabb,null))['then'](function(_0x31606f){if(_0x31606f){return _0x31606f[_0x4fc6('0x157')](_0x4f27db[_0x4fc6('0x51')][_0x4fc6('0x7a')]);}})['then'](respondWithStatusCode(_0x56dabb,null))[_0x4fc6('0x27')](handleError(_0x56dabb,null));};exports['getSmsAccounts']=function(_0x3ac500,_0x22f576,_0x2d899e){var _0x3380a6={};var _0x2a07e8={};var _0x5cc7b7;var _0x43aee1;return db[_0x4fc6('0x4a')][_0x4fc6('0xaa')]({'where':{'id':_0x3ac500[_0x4fc6('0x6f')]['id']}})[_0x4fc6('0x1e')](handleEntityNotFound(_0x22f576,null))[_0x4fc6('0x1e')](function(_0x1ad266){if(_0x1ad266){_0x5cc7b7=_0x1ad266;_0x2a07e8['model']=_['keys'](db[_0x4fc6('0x158')][_0x4fc6('0x71')]);_0x2a07e8[_0x4fc6('0x51')]=_['keys'](_0x3ac500['query']);_0x2a07e8[_0x4fc6('0x52')]=_[_0x4fc6('0x53')](_0x2a07e8[_0x4fc6('0x4e')],_0x2a07e8[_0x4fc6('0x51')]);_0x3380a6['attributes']=_[_0x4fc6('0x53')](_0x2a07e8[_0x4fc6('0x4e')],qs['fields'](_0x3ac500[_0x4fc6('0x51')]['fields']));_0x3380a6[_0x4fc6('0x54')]=_0x3380a6['attributes'][_0x4fc6('0x56')]?_0x3380a6[_0x4fc6('0x54')]:_0x2a07e8['model'];_0x3380a6[_0x4fc6('0xe6')]=qs[_0x4fc6('0x58')](_0x3ac500['query']['sort']);_0x3380a6[_0x4fc6('0x5b')]=qs['filters'](_['pick'](_0x3ac500[_0x4fc6('0x51')],_0x2a07e8[_0x4fc6('0x52')]));if(_0x3ac500[_0x4fc6('0x51')][_0x4fc6('0x3b')]){_0x3380a6['where']=_[_0x4fc6('0x5a')](_0x3380a6[_0x4fc6('0x5b')],{'$or':_[_0x4fc6('0x49')](_0x3380a6[_0x4fc6('0x54')],function(_0x2ab070){var _0x33fa40={};_0x33fa40[_0x2ab070]={'$like':'%'+_0x3ac500[_0x4fc6('0x51')][_0x4fc6('0x3b')]+'%'};return _0x33fa40;})});}_0x3380a6=_[_0x4fc6('0x5a')]({},_0x3380a6,_0x3ac500[_0x4fc6('0x60')]);return _0x5cc7b7[_0x4fc6('0x159')](_0x3380a6);}})[_0x4fc6('0x1e')](function(_0x5ce18c){if(_0x5ce18c){_0x43aee1=_0x5ce18c[_0x4fc6('0x56')];if(!_0x3ac500[_0x4fc6('0x51')]['hasOwnProperty']('nolimit')){_0x3380a6[_0x4fc6('0x2d')]=qs[_0x4fc6('0x2d')](_0x3ac500[_0x4fc6('0x51')][_0x4fc6('0x2d')]);_0x3380a6[_0x4fc6('0x2f')]=qs['offset'](_0x3ac500['query'][_0x4fc6('0x2f')]);}return _0x5cc7b7['getSmsAccounts'](_0x3380a6);}})['then'](function(_0x3d1713){if(_0x3d1713){return _0x3d1713?{'count':_0x43aee1,'rows':_0x3d1713}:null;}})['then'](respondWithResult(_0x22f576,null))['catch'](handleError(_0x22f576,null));};exports[_0x4fc6('0x15a')]=function(_0x1087eb,_0x522833,_0x5d951a){return db[_0x4fc6('0x4a')][_0x4fc6('0x3f')]({'where':{'id':_0x1087eb[_0x4fc6('0x6f')]['id']}})[_0x4fc6('0x1e')](handleEntityNotFound(_0x522833,null))[_0x4fc6('0x1e')](function(_0x463b3c){if(_0x463b3c){return _0x463b3c['addSmsAccounts'](_0x1087eb[_0x4fc6('0x76')][_0x4fc6('0x7a')],_[_0x4fc6('0x79')](_0x1087eb[_0x4fc6('0x76')],[_0x4fc6('0x7a'),'id'])||{});}})[_0x4fc6('0x1e')](respondWithResult(_0x522833,null))[_0x4fc6('0x27')](handleError(_0x522833,null));};exports['removeSmsAccounts']=function(_0x5603b7,_0x116cd1,_0x2259dd){return db[_0x4fc6('0x4a')][_0x4fc6('0x3f')]({'where':{'id':_0x5603b7[_0x4fc6('0x6f')]['id']}})[_0x4fc6('0x1e')](handleEntityNotFound(_0x116cd1,null))['then'](function(_0x23b232){if(_0x23b232){return _0x23b232[_0x4fc6('0x15b')](_0x5603b7[_0x4fc6('0x51')]['ids']);}})[_0x4fc6('0x1e')](respondWithStatusCode(_0x116cd1,null))[_0x4fc6('0x27')](handleError(_0x116cd1,null));};exports[_0x4fc6('0x15c')]=function(_0x59c035,_0x55bab2,_0x3075e9){var _0x498a0a={};var _0x2dfcc6={};var _0x1905c1;var _0x58f458;return db[_0x4fc6('0x4a')][_0x4fc6('0xaa')]({'where':{'id':_0x59c035[_0x4fc6('0x6f')]['id']}})[_0x4fc6('0x1e')](handleEntityNotFound(_0x55bab2,null))[_0x4fc6('0x1e')](function(_0x227e9f){if(_0x227e9f){_0x1905c1=_0x227e9f;_0x2dfcc6[_0x4fc6('0x4e')]=_[_0x4fc6('0x70')](db[_0x4fc6('0x15d')][_0x4fc6('0x71')]);_0x2dfcc6['query']=_['keys'](_0x59c035['query']);_0x2dfcc6[_0x4fc6('0x52')]=_[_0x4fc6('0x53')](_0x2dfcc6['model'],_0x2dfcc6['query']);_0x498a0a[_0x4fc6('0x54')]=_[_0x4fc6('0x53')](_0x2dfcc6[_0x4fc6('0x4e')],qs[_0x4fc6('0x55')](_0x59c035['query'][_0x4fc6('0x55')]));_0x498a0a[_0x4fc6('0x54')]=_0x498a0a[_0x4fc6('0x54')][_0x4fc6('0x56')]?_0x498a0a[_0x4fc6('0x54')]:_0x2dfcc6[_0x4fc6('0x4e')];_0x498a0a[_0x4fc6('0xe6')]=qs[_0x4fc6('0x58')](_0x59c035[_0x4fc6('0x51')][_0x4fc6('0x58')]);_0x498a0a['where']=qs['filters'](_['pick'](_0x59c035['query'],_0x2dfcc6[_0x4fc6('0x52')]));if(_0x59c035[_0x4fc6('0x51')][_0x4fc6('0x3b')]){_0x498a0a[_0x4fc6('0x5b')]=_[_0x4fc6('0x5a')](_0x498a0a['where'],{'$or':_[_0x4fc6('0x49')](_0x498a0a[_0x4fc6('0x54')],function(_0x9b36a5){var _0x1ec39e={};_0x1ec39e[_0x9b36a5]={'$like':'%'+_0x59c035[_0x4fc6('0x51')][_0x4fc6('0x3b')]+'%'};return _0x1ec39e;})});}_0x498a0a=_[_0x4fc6('0x5a')]({},_0x498a0a,_0x59c035[_0x4fc6('0x60')]);return _0x1905c1[_0x4fc6('0x15c')](_0x498a0a);}})[_0x4fc6('0x1e')](function(_0x107808){if(_0x107808){_0x58f458=_0x107808[_0x4fc6('0x56')];if(!_0x59c035['query'][_0x4fc6('0x57')](_0x4fc6('0xe5'))){_0x498a0a[_0x4fc6('0x2d')]=qs['limit'](_0x59c035['query'][_0x4fc6('0x2d')]);_0x498a0a['offset']=qs[_0x4fc6('0x2f')](_0x59c035[_0x4fc6('0x51')]['offset']);}return _0x1905c1[_0x4fc6('0x15c')](_0x498a0a);}})[_0x4fc6('0x1e')](function(_0x5bdcb6){if(_0x5bdcb6){return _0x5bdcb6?{'count':_0x58f458,'rows':_0x5bdcb6}:null;}})[_0x4fc6('0x1e')](respondWithResult(_0x55bab2,null))['catch'](handleError(_0x55bab2,null));};exports[_0x4fc6('0x15e')]=function(_0x984a61,_0x3afa87,_0x1558d3){return db[_0x4fc6('0x4a')][_0x4fc6('0x3f')]({'where':{'id':_0x984a61[_0x4fc6('0x6f')]['id']}})[_0x4fc6('0x1e')](handleEntityNotFound(_0x3afa87,null))[_0x4fc6('0x1e')](function(_0x15eab1){if(_0x15eab1){return _0x15eab1[_0x4fc6('0x15e')](_0x984a61[_0x4fc6('0x76')][_0x4fc6('0x7a')],_[_0x4fc6('0x79')](_0x984a61[_0x4fc6('0x76')],['ids','id'])||{});}})['then'](respondWithResult(_0x3afa87,null))[_0x4fc6('0x27')](handleError(_0x3afa87,null));};exports['removeChatWebsites']=function(_0x2520ee,_0x5d4df0,_0x3b78a6){return db[_0x4fc6('0x4a')]['find']({'where':{'id':_0x2520ee['params']['id']}})[_0x4fc6('0x1e')](handleEntityNotFound(_0x5d4df0,null))['then'](function(_0x13327a){if(_0x13327a){return _0x13327a[_0x4fc6('0x15f')](_0x2520ee[_0x4fc6('0x51')]['ids']);}})[_0x4fc6('0x1e')](respondWithStatusCode(_0x5d4df0,null))[_0x4fc6('0x27')](handleError(_0x5d4df0,null));};exports['getWhatsappAccounts']=function(_0x4fa4a4,_0x5883d4,_0x4516ec){var _0x571b61={};var _0x1be3a5={};var _0x570e3d;var _0x5f55e9;return db[_0x4fc6('0x4a')][_0x4fc6('0xaa')]({'where':{'id':_0x4fa4a4['params']['id']}})[_0x4fc6('0x1e')](handleEntityNotFound(_0x5883d4,null))[_0x4fc6('0x1e')](function(_0x253ad2){if(_0x253ad2){_0x570e3d=_0x253ad2;_0x1be3a5[_0x4fc6('0x4e')]=_[_0x4fc6('0x70')](db[_0x4fc6('0x160')][_0x4fc6('0x71')]);_0x1be3a5[_0x4fc6('0x51')]=_[_0x4fc6('0x70')](_0x4fa4a4[_0x4fc6('0x51')]);_0x1be3a5[_0x4fc6('0x52')]=_[_0x4fc6('0x53')](_0x1be3a5[_0x4fc6('0x4e')],_0x1be3a5[_0x4fc6('0x51')]);_0x571b61[_0x4fc6('0x54')]=_['intersection'](_0x1be3a5['model'],qs['fields'](_0x4fa4a4[_0x4fc6('0x51')][_0x4fc6('0x55')]));_0x571b61['attributes']=_0x571b61[_0x4fc6('0x54')]['length']?_0x571b61['attributes']:_0x1be3a5[_0x4fc6('0x4e')];_0x571b61[_0x4fc6('0xe6')]=qs[_0x4fc6('0x58')](_0x4fa4a4['query']['sort']);_0x571b61[_0x4fc6('0x5b')]=qs['filters'](_[_0x4fc6('0x59')](_0x4fa4a4[_0x4fc6('0x51')],_0x1be3a5[_0x4fc6('0x52')]));if(_0x4fa4a4['query']['filter']){_0x571b61[_0x4fc6('0x5b')]=_[_0x4fc6('0x5a')](_0x571b61['where'],{'$or':_['map'](_0x571b61[_0x4fc6('0x54')],function(_0x1ee381){var _0x319bae={};_0x319bae[_0x1ee381]={'$like':'%'+_0x4fa4a4[_0x4fc6('0x51')][_0x4fc6('0x3b')]+'%'};return _0x319bae;})});}_0x571b61=_[_0x4fc6('0x5a')]({},_0x571b61,_0x4fa4a4[_0x4fc6('0x60')]);return _0x570e3d['getWhatsappAccounts'](_0x571b61);}})['then'](function(_0x1504de){if(_0x1504de){_0x5f55e9=_0x1504de[_0x4fc6('0x56')];if(!_0x4fa4a4[_0x4fc6('0x51')][_0x4fc6('0x57')](_0x4fc6('0xe5'))){_0x571b61['limit']=qs[_0x4fc6('0x2d')](_0x4fa4a4[_0x4fc6('0x51')][_0x4fc6('0x2d')]);_0x571b61[_0x4fc6('0x2f')]=qs['offset'](_0x4fa4a4[_0x4fc6('0x51')]['offset']);}return _0x570e3d[_0x4fc6('0x161')](_0x571b61);}})[_0x4fc6('0x1e')](function(_0x162f15){if(_0x162f15){return _0x162f15?{'count':_0x5f55e9,'rows':_0x162f15}:null;}})['then'](respondWithResult(_0x5883d4,null))['catch'](handleError(_0x5883d4,null));};exports[_0x4fc6('0x162')]=function(_0x102bfa,_0x1e5bd4,_0x4d5fdd){return db['User']['find']({'where':{'id':_0x102bfa[_0x4fc6('0x6f')]['id']}})[_0x4fc6('0x1e')](handleEntityNotFound(_0x1e5bd4,null))[_0x4fc6('0x1e')](function(_0x325332){if(_0x325332){return _0x325332[_0x4fc6('0x162')](_0x102bfa[_0x4fc6('0x76')][_0x4fc6('0x7a')],_['omit'](_0x102bfa[_0x4fc6('0x76')],[_0x4fc6('0x7a'),'id'])||{});}})[_0x4fc6('0x1e')](respondWithResult(_0x1e5bd4,null))[_0x4fc6('0x27')](handleError(_0x1e5bd4,null));};exports[_0x4fc6('0x163')]=function(_0x1cc215,_0x31d767,_0x2a6d05){return db[_0x4fc6('0x4a')][_0x4fc6('0x3f')]({'where':{'id':_0x1cc215[_0x4fc6('0x6f')]['id']}})['then'](handleEntityNotFound(_0x31d767,null))['then'](function(_0x56e959){if(_0x56e959){return _0x56e959[_0x4fc6('0x163')](_0x1cc215[_0x4fc6('0x51')][_0x4fc6('0x7a')]);}})[_0x4fc6('0x1e')](respondWithStatusCode(_0x31d767,null))[_0x4fc6('0x27')](handleError(_0x31d767,null));};exports['getSquareProjects']=function(_0x1c8c50,_0x4032ad,_0x1e375d){var _0x36c0a6={};var _0x3a5195={};var _0x5c5bda;var _0x488314;return db[_0x4fc6('0x4a')][_0x4fc6('0xaa')]({'where':{'id':_0x1c8c50[_0x4fc6('0x6f')]['id']}})['then'](handleEntityNotFound(_0x4032ad,null))['then'](function(_0x19cd4a){if(_0x19cd4a){_0x5c5bda=_0x19cd4a;_0x3a5195[_0x4fc6('0x4e')]=_[_0x4fc6('0x70')](db[_0x4fc6('0x164')][_0x4fc6('0x71')]);_0x3a5195['query']=_[_0x4fc6('0x70')](_0x1c8c50[_0x4fc6('0x51')]);_0x3a5195[_0x4fc6('0x52')]=_[_0x4fc6('0x53')](_0x3a5195[_0x4fc6('0x4e')],_0x3a5195[_0x4fc6('0x51')]);_0x36c0a6[_0x4fc6('0x54')]=_[_0x4fc6('0x53')](_0x3a5195[_0x4fc6('0x4e')],qs['fields'](_0x1c8c50[_0x4fc6('0x51')][_0x4fc6('0x55')]));_0x36c0a6[_0x4fc6('0x54')]=_0x36c0a6[_0x4fc6('0x54')][_0x4fc6('0x56')]?_0x36c0a6[_0x4fc6('0x54')]:_0x3a5195['model'];_0x36c0a6[_0x4fc6('0xe6')]=qs[_0x4fc6('0x58')](_0x1c8c50[_0x4fc6('0x51')]['sort']);_0x36c0a6['where']=qs[_0x4fc6('0x52')](_['pick'](_0x1c8c50[_0x4fc6('0x51')],_0x3a5195['filters']));if(_0x1c8c50['query'][_0x4fc6('0x3b')]){_0x36c0a6[_0x4fc6('0x5b')]=_['merge'](_0x36c0a6['where'],{'$or':_[_0x4fc6('0x49')](_0x36c0a6['attributes'],function(_0x3b66f1){var _0x15c4d7={};_0x15c4d7[_0x3b66f1]={'$like':'%'+_0x1c8c50[_0x4fc6('0x51')][_0x4fc6('0x3b')]+'%'};return _0x15c4d7;})});}_0x36c0a6=_[_0x4fc6('0x5a')]({},_0x36c0a6,_0x1c8c50[_0x4fc6('0x60')]);return _0x5c5bda['getSquareProjects'](_0x36c0a6);}})[_0x4fc6('0x1e')](function(_0x1822b0){if(_0x1822b0){_0x488314=_0x1822b0[_0x4fc6('0x56')];if(!_0x1c8c50[_0x4fc6('0x51')]['hasOwnProperty'](_0x4fc6('0xe5'))){_0x36c0a6[_0x4fc6('0x2d')]=qs[_0x4fc6('0x2d')](_0x1c8c50[_0x4fc6('0x51')]['limit']);_0x36c0a6[_0x4fc6('0x2f')]=qs['offset'](_0x1c8c50['query'][_0x4fc6('0x2f')]);}return _0x5c5bda[_0x4fc6('0x165')](_0x36c0a6);}})[_0x4fc6('0x1e')](function(_0xe9c18a){if(_0xe9c18a){return _0xe9c18a?{'count':_0x488314,'rows':_0xe9c18a}:null;}})[_0x4fc6('0x1e')](respondWithResult(_0x4032ad,null))['catch'](handleError(_0x4032ad,null));};exports[_0x4fc6('0x166')]=function(_0x36f451,_0x42088d,_0x35f6e7){return db[_0x4fc6('0x4a')]['find']({'where':{'id':_0x36f451['params']['id']}})['then'](handleEntityNotFound(_0x42088d,null))[_0x4fc6('0x1e')](function(_0x30058a){if(_0x30058a){return _0x30058a[_0x4fc6('0x166')](_0x36f451[_0x4fc6('0x76')][_0x4fc6('0x7a')],_[_0x4fc6('0x79')](_0x36f451[_0x4fc6('0x76')],['ids','id'])||{});}})[_0x4fc6('0x1e')](respondWithResult(_0x42088d,null))[_0x4fc6('0x27')](handleError(_0x42088d,null));};exports['removeSquareProjects']=function(_0x1dc6fb,_0x1f48ed,_0x585a0c){return db['User'][_0x4fc6('0x3f')]({'where':{'id':_0x1dc6fb[_0x4fc6('0x6f')]['id']}})[_0x4fc6('0x1e')](handleEntityNotFound(_0x1f48ed,null))[_0x4fc6('0x1e')](function(_0x4b7c75){if(_0x4b7c75){return _0x4b7c75[_0x4fc6('0x167')](_0x1dc6fb[_0x4fc6('0x51')][_0x4fc6('0x7a')]);}})[_0x4fc6('0x1e')](respondWithStatusCode(_0x1f48ed,null))['catch'](handleError(_0x1f48ed,null));};exports[_0x4fc6('0x168')]=function(_0x45c7e3,_0x1f3e44){var _0x33875b={},_0x2c8aab={},_0x5b5b84={'count':0x0,'rows':[]};var _0x59ba29=db[_0x4fc6('0x169')][_0x4fc6('0x71')];_0x2c8aab[_0x4fc6('0x4e')]=_['keys'](_0x59ba29);_0x2c8aab[_0x4fc6('0x51')]=_[_0x4fc6('0x70')](_0x45c7e3[_0x4fc6('0x51')]);_0x2c8aab[_0x4fc6('0x52')]=_[_0x4fc6('0x53')](_0x2c8aab[_0x4fc6('0x4e')],_0x2c8aab['query']);_0x2c8aab[_0x4fc6('0x52')]=_[_0x4fc6('0x10c')](_0x2c8aab[_0x4fc6('0x52')],['$and',_0x4fc6('0x16a'),_0x4fc6('0x16b'),_0x4fc6('0x16c'),_0x4fc6('0x16d'),'$lte',_0x4fc6('0x16e'),'$eq','$not','$between',_0x4fc6('0x16f'),_0x4fc6('0x170'),_0x4fc6('0x171'),_0x4fc6('0x172'),'$notLike',_0x4fc6('0x173'),'$notILike',_0x4fc6('0x172'),_0x4fc6('0x174'),'$contains','$contained',_0x4fc6('0x175')]);_0x33875b[_0x4fc6('0x54')]=_['intersection'](_0x2c8aab[_0x4fc6('0x4e')],qs[_0x4fc6('0x55')](_0x45c7e3[_0x4fc6('0x51')][_0x4fc6('0x55')]));_0x33875b[_0x4fc6('0x54')]=_0x33875b[_0x4fc6('0x54')]['length']?_0x33875b[_0x4fc6('0x54')]:_0x2c8aab[_0x4fc6('0x4e')];if(!_0x45c7e3[_0x4fc6('0x51')][_0x4fc6('0x57')](_0x4fc6('0xe5'))){_0x33875b[_0x4fc6('0x2d')]=qs[_0x4fc6('0x2d')](_0x45c7e3[_0x4fc6('0x51')]['limit']);_0x33875b['offset']=qs['offset'](_0x45c7e3[_0x4fc6('0x51')][_0x4fc6('0x2f')]);}_0x33875b[_0x4fc6('0xe6')]=qs['sort'](_0x45c7e3[_0x4fc6('0x51')][_0x4fc6('0x58')]);_0x33875b[_0x4fc6('0x5b')]=qs[_0x4fc6('0x52')](_[_0x4fc6('0x59')](_0x45c7e3[_0x4fc6('0x51')],_0x2c8aab[_0x4fc6('0x52')]));if(_0x45c7e3[_0x4fc6('0x51')][_0x4fc6('0x3b')]){_0x33875b[_0x4fc6('0x5b')]=_[_0x4fc6('0x5a')](_0x33875b['where'],{'$or':_[_0x4fc6('0x49')](_0x33875b[_0x4fc6('0x54')],function(_0x3f241b){var _0x287571={};_0x287571[_0x3f241b]={'$like':'%'+_0x45c7e3[_0x4fc6('0x51')][_0x4fc6('0x3b')]+'%'};return _0x287571;})});}_0x33875b['where']={'$and':[_0x33875b[_0x4fc6('0x5b')],{'$or':[{'UserId':_0x45c7e3[_0x4fc6('0x6f')]['id']},{'OwnerId':_0x45c7e3[_0x4fc6('0x6f')]['id']}]}]};_0x33875b=_['merge']({},_0x33875b,_0x45c7e3[_0x4fc6('0x60')]);var _0x40327f={'where':_0x33875b['where']};return db[_0x4fc6('0x169')]['count'](_0x40327f)[_0x4fc6('0x1e')](function(_0x3033a6){_0x5b5b84['count']=_0x3033a6;if(_0x45c7e3['query'][_0x4fc6('0x61')]){_0x33875b[_0x4fc6('0x62')]=[{'attributes':['id',_0x4fc6('0x176'),_0x4fc6('0x177'),'phone'],'model':db[_0x4fc6('0x178')],'as':_0x4fc6('0x179')},{'attributes':['id','name','dialActive'],'model':db[_0x4fc6('0xbd')],'as':_0x4fc6('0xe7')}];}return db[_0x4fc6('0x169')]['findAll'](_0x33875b);})[_0x4fc6('0x1e')](function(_0x3b2e57){_0x5b5b84[_0x4fc6('0x65')]=_0x3b2e57;return _0x5b5b84;})[_0x4fc6('0x1e')](respondWithFilteredResult(_0x1f3e44,_0x33875b))[_0x4fc6('0x27')](handleError(_0x1f3e44,null));};exports['getApiKey']=function(_0x59a757,_0x7636ee,_0x2ad483){if(!_['isNil'](_0x59a757[_0x4fc6('0x37')]['id'])&&(_0x59a757['user'][_0x4fc6('0x35')]=='admin'||_0x59a757[_0x4fc6('0x37')][_0x4fc6('0x35')]==_0x4fc6('0x37'))){return db[_0x4fc6('0x4a')][_0x4fc6('0xaa')]({'where':{'id':_0x59a757['params']['id']},'raw':!![]})[_0x4fc6('0x1e')](function(_0x667531){return authService[_0x4fc6('0x17a')](_0x667531);})[_0x4fc6('0x1e')](function(_0x3b2f0a){if(_0x3b2f0a){return _0x7636ee[_0x4fc6('0x2a')](0xc8)[_0x4fc6('0x2b')]({'api_key':_0x3b2f0a[_0x4fc6('0x17b')]});}else{return _0x7636ee[_0x4fc6('0x2a')](0xcc)[_0x4fc6('0x2b')]({'message':_0x4fc6('0x17c')});}})[_0x4fc6('0x27')](handleError(_0x7636ee,0x193));}else{return _0x7636ee[_0x4fc6('0x2a')](0x191)[_0x4fc6('0x2b')]({'message':_0x4fc6('0x17d')});}};exports[_0x4fc6('0x17e')]=function(_0x51dd51,_0x677702,_0x2b0912){if(!_[_0x4fc6('0x80')](_0x51dd51['user']['id'])&&(_0x51dd51[_0x4fc6('0x37')][_0x4fc6('0x35')]=='admin'||_0x51dd51[_0x4fc6('0x37')][_0x4fc6('0x35')]==_0x4fc6('0x37'))){return db[_0x4fc6('0x4a')]['find']({'where':{'id':_0x51dd51[_0x4fc6('0x6f')]['id']}})[_0x4fc6('0x1e')](function(_0x12635e){return authService['generateApiKey'](_0x12635e);})[_0x4fc6('0x1e')](function(_0x25a3f6){return db[_0x4fc6('0x4a')]['update']({'apiKeyIat':_0x25a3f6[_0x4fc6('0x17f')],'apiKeyNonce':_0x25a3f6[_0x4fc6('0x180')]},{'where':{'id':_0x51dd51[_0x4fc6('0x6f')]['id']}})[_0x4fc6('0x1e')](function(){return _0x677702[_0x4fc6('0x2a')](0xc8)[_0x4fc6('0x2b')]({'api_key':_0x25a3f6['token']});});})[_0x4fc6('0x27')](handleError(_0x677702,0x193));}else{return _0x677702[_0x4fc6('0x2a')](0x191)['json']({'message':_0x4fc6('0x17d')});}};exports[_0x4fc6('0x181')]=function(_0x511c53,_0x21d6c6,_0x31df8f){if(!_[_0x4fc6('0x80')](_0x511c53[_0x4fc6('0x37')]['id'])&&(_0x511c53['user'][_0x4fc6('0x35')]=='admin'||_0x511c53['user'][_0x4fc6('0x35')]==_0x4fc6('0x37'))){return db[_0x4fc6('0x4a')][_0x4fc6('0x3f')]({'where':{'id':_0x511c53['params']['id']}})[_0x4fc6('0x1e')](handleEntityNotFound(_0x21d6c6,null))['then'](function(_0x6aa9ea){if(_0x6aa9ea&&_0x6aa9ea['apiKeyNonce']&&_0x6aa9ea['apiKeyIat'])return _0x6aa9ea;else throw{'message':'API\x20key\x20not\x20available'};})['then'](function(_0x501b29){return db['User'][_0x4fc6('0x75')]({'apiKeyNonce':null,'apiKeyIat':null},{'where':{'id':_0x511c53['params']['id']}});})[_0x4fc6('0x1e')](respondWithStatusCode(_0x21d6c6,0xc8))[_0x4fc6('0x27')](handleError(_0x21d6c6,0x193));}else{return _0x21d6c6['status'](0x191)['json']({'message':'You\x20don\x27t\x20have\x20sufficient\x20privileges\x20to\x20access\x20this\x20resource.'});}};exports['whoami']=function(_0x19ad7d,_0x1e33a4){var _0x39f554=_0x19ad7d[_0x4fc6('0x37')][_0x4fc6('0x34')]({'plain':!![]});if(!_0x39f554){return _0x1e33a4[_0x4fc6('0x2a')](0x191)[_0x4fc6('0x42')](_0x4fc6('0x182'));}else{return _0x1e33a4[_0x4fc6('0x2a')](0xc8)[_0x4fc6('0x2b')](_0x39f554);}};exports[_0x4fc6('0x183')]=function(_0x31c279,_0xb1d9e4){var _0x467d04={'offset':0x0},_0x317f4a={'count':0x0,'rows':[]};Promise[_0x4fc6('0x10e')]()[_0x4fc6('0x1e')](function(){if(!_0x31c279[_0x4fc6('0x51')][_0x4fc6('0x3b')]&&!_0x31c279['query']['teams']&&!_0x31c279['query'][_0x4fc6('0x184')])return[];return Promise[_0x4fc6('0x10e')]()[_0x4fc6('0x1e')](function(){var _0x12a723=[];if(!_['isEmpty'](_0x31c279[_0x4fc6('0x51')][_0x4fc6('0x185')])){_0x12a723[_0x4fc6('0x63')](db[_0x4fc6('0x11f')]['findAll']({'attributes':['id',_0x4fc6('0x40')],'where':{'id':_0x31c279[_0x4fc6('0x51')][_0x4fc6('0x185')]}}));}if(!_[_0x4fc6('0x186')](_0x31c279['query'][_0x4fc6('0x184')])){_0x12a723[_0x4fc6('0x63')](db[_0x4fc6('0xbd')][_0x4fc6('0x64')]({'attributes':['id','name'],'type':_0x4fc6('0x187'),'where':{'id':_0x31c279[_0x4fc6('0x51')][_0x4fc6('0x184')]}}));}return Promise[_0x4fc6('0x6d')](_0x12a723);})[_0x4fc6('0x1e')](function(_0x286035){var _0x1c8adc=_[_0x4fc6('0x129')](_0x286035)[_0x4fc6('0x49')](function(_0x10c184){return _0x10c184[_0x4fc6('0x133')]({'attributes':['id',_0x4fc6('0x40'),_0x4fc6('0x7e'),_0x4fc6('0xb2')],'raw':!![]});});return Promise[_0x4fc6('0x6d')](_0x1c8adc);})[_0x4fc6('0x1e')](function(_0x2f5d90){var _0x4a53ba=_[_0x4fc6('0x129')](_0x2f5d90);if(!_0x31c279[_0x4fc6('0x51')]['filter'])return _0x4a53ba;if(_['isEmpty'](_0x4a53ba)){return db[_0x4fc6('0x4a')]['findAll']({'attributes':['id','name',_0x4fc6('0x7e'),_0x4fc6('0xb2')],'where':{'role':_0x4fc6('0x45'),'$or':[db[_0x4fc6('0x5d')][_0x4fc6('0x5b')](db[_0x4fc6('0x5d')]['fn']('lower',db[_0x4fc6('0x5d')]['col']('name')),{'$like':'%'+_0x31c279[_0x4fc6('0x51')][_0x4fc6('0x3b')][_0x4fc6('0xb9')]()+'%'}),{'internal':{'$like':'%'+_0x31c279[_0x4fc6('0x51')]['filter']+'%'}}]},'raw':!![]});}else{return _(_0x4a53ba)[_0x4fc6('0x129')]()[_0x4fc6('0x3b')](function(_0x10b0b7){return _0x10b0b7[_0x4fc6('0x40')]['toLowerCase']()['includes'](_0x31c279[_0x4fc6('0x51')][_0x4fc6('0x3b')][_0x4fc6('0xb9')]())||_0x10b0b7[_0x4fc6('0x7e')][_0x4fc6('0x188')]()['includes'](_0x31c279[_0x4fc6('0x51')][_0x4fc6('0x3b')]);})[_0x4fc6('0x3d')]();}})['then'](function(_0x2a7aec){var _0x34fe73=_0x4fc6('0x40');var _0x5628ca='asc';if(_0x31c279[_0x4fc6('0x51')][_0x4fc6('0x58')]){var _0x5628ca=_0x31c279[_0x4fc6('0x51')][_0x4fc6('0x58')][0x0]==='-'?_0x4fc6('0x189'):_0x4fc6('0x18a');var _0x34fe73=_0x5628ca===_0x4fc6('0x18a')?_0x31c279[_0x4fc6('0x51')][_0x4fc6('0x58')]:_0x31c279[_0x4fc6('0x51')][_0x4fc6('0x58')][_0x4fc6('0x18b')](0x1);}return _(_0x2a7aec)['uniqBy']('id')['orderBy']([function(_0x2d8642){return _0x34fe73===_0x4fc6('0x40')?_0x2d8642[_0x34fe73][_0x4fc6('0xb9')]():_0x2d8642[_0x34fe73];}],[_0x5628ca])[_0x4fc6('0x49')](function(_0x1cba13){return _[_0x4fc6('0x59')](_0x1cba13,['id',_0x4fc6('0x40'),'internal',_0x4fc6('0xb2')]);})[_0x4fc6('0x3d')]();})['then'](function(_0x59840){return client[_0x4fc6('0x1d')](_0x4fc6('0x38'),_0x31c279)['then'](function(_0x2e8962){if(_0x2e8962['error'])throw new Error(_0x4fc6('0x18c'));var _0x9b605f=_0x2e8962[_0x4fc6('0x18d')];var _0x333335=jayson[_0x4fc6('0x18e')][_0x4fc6('0x18f')]({'port':0x232c});return _0x333335[_0x4fc6('0x1d')](_0x4fc6('0x38'),_0x31c279)[_0x4fc6('0x1e')](function(_0x1c6155){if(_0x1c6155[_0x4fc6('0x23')])throw new Error('Unable\x20to\x20retrieve\x20RPC\x20agents\x20(Routing)');var _0x222034=_0x1c6155[_0x4fc6('0x18d')];return _[_0x4fc6('0x5a')]({},_0x222034,_0x9b605f);});})[_0x4fc6('0x1e')](function(_0x86ec70){return _[_0x4fc6('0x49')](_0x59840,function(_0x3365bf){var _0x3babf5=_['find'](_0x86ec70[_0x4fc6('0x65')],['id',_0x3365bf['id']]);if(!_0x3babf5||!_0x3365bf[_0x4fc6('0xb2')]){_0x3365bf[_0x4fc6('0x2a')]=_0x4fc6('0x190');}else if(_0x3babf5[_0x4fc6('0xb4')]){_0x3365bf[_0x4fc6('0x2a')]='pause';}else{_0x3365bf[_0x4fc6('0x2a')]=_[_0x4fc6('0x3e')]([_0x4fc6('0x191'),_0x4fc6('0x192'),_0x4fc6('0x193'),_0x4fc6('0x194'),null,undefined],_0x3babf5['voiceStatus'])?_0x4fc6('0xb2'):_0x4fc6('0x195');}return _0x3365bf;});});});})['then'](function(_0x3fa47c){if(!_0x31c279[_0x4fc6('0x51')]['hasOwnProperty'](_0x4fc6('0xe5'))){_0x467d04[_0x4fc6('0x2d')]=qs[_0x4fc6('0x2d')](_0x31c279[_0x4fc6('0x51')][_0x4fc6('0x2d')]||0xa);_0x467d04[_0x4fc6('0x2f')]=qs[_0x4fc6('0x2f')](_0x31c279[_0x4fc6('0x51')][_0x4fc6('0x2f')]);}_0x317f4a[_0x4fc6('0x2e')]=_0x3fa47c[_0x4fc6('0x56')];_0x317f4a[_0x4fc6('0x65')]=_0x467d04[_0x4fc6('0x2d')]?_0x3fa47c[_0x4fc6('0x196')](_0x467d04[_0x4fc6('0x2f')],_0x467d04[_0x4fc6('0x2f')]+_0x467d04[_0x4fc6('0x2d')]):_0x3fa47c;return _0x317f4a;})[_0x4fc6('0x1e')](respondWithFilteredResult(_0xb1d9e4,_0x467d04))[_0x4fc6('0x27')](handleError(_0xb1d9e4,null));};function get_open_tabs(_0x118372,_0x5cb1ff){var _0x5dd8ff=_0x118372[_0x4fc6('0x197')](0x0)[_0x4fc6('0x198')]()+_0x118372[_0x4fc6('0x196')](0x1);var _0x9190b2={'type':db[_0x4fc6('0xa8')]['QueryTypes']['SELECT'],'raw':!![]};return new BPromise(function(_0x390b40,_0x573b8e){var _0x1ba2f0=squel['select']()['field'](_0x4fc6('0x199')+_0x5dd8ff+'InteractionId','id')[_0x4fc6('0x19a')](_0x4fc6('0x19b'))[_0x4fc6('0x82')](_0x4fc6('0x19c')+_0x118372+_0x4fc6('0x19d'),'ui')['where'](_0x4fc6('0x19e'),_0x5cb1ff['id']);return db[_0x4fc6('0x5d')][_0x4fc6('0x51')](_0x1ba2f0['toString'](),_0x9190b2)[_0x4fc6('0x1e')](function(_0xaed16b){_0x5cb1ff[_0x5dd8ff+_0x4fc6('0x19f')]=_0xaed16b;_0x390b40(_0xaed16b);})[_0x4fc6('0x27')](function(_0x23263b){_0x573b8e(_0x23263b);});});};