144ad6730379194a68bbfc0cb10e8543680163d0
[motion2.git] / server / services / routing / model / agent.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 _0x430c=['smsCurrentCapacity','whatsappStatus','whatsappCapacity','whatsappCurrentCapacity','openchannelStatusTime','openchannelCapacity','openchannelCurrentCapacity','busy','busyQueue','md5','faxWaitingInteractions','smsWaitingInteractions','whatsappWaitingInteractions','updateRealtime','getChannelStatus','CurrentCapacity','Capacity','maxcapacity','idle','mail','chat','fax','sms','whatsapp','length','Status','StatusTime','toNumber','mailCurrentCapacity','smsStatus','smsStatusTime','whatsappStatusTime','chatWaitingInteractions','openchannelWaitingInteractions','stringify','emit','user:routing:update','omit','exports','lodash','ioredis','../../../config/environment','redis','name','online','voicePause','chatPause','mailPause','faxPause','smsPause','openchannelPause','chatStatus','chatStatusTime','chatCapacity','chatCurrentCapacity','mailStatus','unknown','mailStatusTime','mailCapacity','faxStatusTime','faxCapacity','faxCurrentCapacity','smsCapacity'];(function(_0x4fb6b6,_0x5eb1c7){var _0x3ea470=function(_0x26228c){while(--_0x26228c){_0x4fb6b6['push'](_0x4fb6b6['shift']());}};_0x3ea470(++_0x5eb1c7);}(_0x430c,0x1a1));var _0xc430=function(_0x3c504b,_0x437693){_0x3c504b=_0x3c504b-0x0;var _0x2e5354=_0x430c[_0x3c504b];return _0x2e5354;};'use strict';var _=require(_0xc430('0x0'));var md5=require('md5');var moment=require('moment');var Redis=require(_0xc430('0x1'));var config=require(_0xc430('0x2'));config[_0xc430('0x3')]=_['defaults'](config['redis'],{'host':'localhost','port':0x18eb});var io=require('socket.io-emitter')(new Redis(config[_0xc430('0x3')]));function Agent(_0x2408f5){this['id']=_0x2408f5['id']||0x0;this['name']=_0x2408f5[_0xc430('0x4')]||'';this['online']=_0x2408f5[_0xc430('0x5')]||!![];this[_0xc430('0x6')]=_0x2408f5[_0xc430('0x6')]||![];this[_0xc430('0x7')]=_0x2408f5[_0xc430('0x7')]||![];this[_0xc430('0x8')]=_0x2408f5[_0xc430('0x8')]||![];this[_0xc430('0x9')]=_0x2408f5[_0xc430('0x9')]||![];this['smsPause']=_0x2408f5[_0xc430('0xa')]||![];this[_0xc430('0xb')]=_0x2408f5['openchannelPause']||![];this[_0xc430('0xc')]='unknown';this[_0xc430('0xd')]=0x0;this['chatCapacity']=_0x2408f5[_0xc430('0xe')]||0x0;this[_0xc430('0xf')]=0x0;this[_0xc430('0x10')]=_0xc430('0x11');this[_0xc430('0x12')]=0x0;this[_0xc430('0x13')]=_0x2408f5[_0xc430('0x13')]||0x0;this['mailCurrentCapacity']=0x0;this['faxStatus']=_0xc430('0x11');this[_0xc430('0x14')]=0x0;this[_0xc430('0x15')]=_0x2408f5[_0xc430('0x15')]||0x0;this[_0xc430('0x16')]=0x0;this['smsStatus']=_0xc430('0x11');this['smsStatusTime']=0x0;this['smsCapacity']=_0x2408f5[_0xc430('0x17')]||0x0;this[_0xc430('0x18')]=0x0;this[_0xc430('0x19')]='unknown';this['whatsappStatusTime']=0x0;this[_0xc430('0x1a')]=_0x2408f5['whatsappCapacity']||0x0;this[_0xc430('0x1b')]=0x0;this['openchannelStatus']='unknown';this[_0xc430('0x1c')]=0x0;this['openchannelCapacity']=_0x2408f5[_0xc430('0x1d')]||0x0;this[_0xc430('0x1e')]=0x0;this[_0xc430('0x1f')]=![];this[_0xc430('0x20')]=undefined;this[_0xc430('0x21')]='';this['chatWaitingInteractions']={};this[_0xc430('0x22')]={};this['mailWaitingInteractions']={};this['openchannelWaitingInteractions']={};this[_0xc430('0x23')]={};this[_0xc430('0x24')]={};this[_0xc430('0x25')]();}Agent['prototype'][_0xc430('0x26')]=function(_0x57d26e){if(this[_0x57d26e+_0xc430('0x27')]>0x0){if(this[_0x57d26e+_0xc430('0x28')]>0x0&&this[_0x57d26e+'CurrentCapacity']>=this[_0x57d26e+_0xc430('0x28')]){return _0xc430('0x29');}else{return'working';}}else{return _0xc430('0x2a');}};Agent['prototype'][_0xc430('0x25')]=function(){var _0x4b5280=[_0xc430('0x2b'),_0xc430('0x2c'),'openchannel',_0xc430('0x2d'),_0xc430('0x2e'),_0xc430('0x2f')];for(var _0x44833e=0x0;_0x44833e<_0x4b5280[_0xc430('0x30')];_0x44833e+=0x1){var _0x57cd72=this[_0xc430('0x26')](_0x4b5280[_0x44833e]);if(this[_0x4b5280[_0x44833e]+_0xc430('0x31')]!==_0x57cd72){this[_0x4b5280[_0x44833e]+_0xc430('0x32')]=_[_0xc430('0x33')](moment()['format']('x'));}this[_0x4b5280[_0x44833e]+_0xc430('0x31')]=_0x57cd72;}var _0x4cf56c={'id':this['id'],'name':this[_0xc430('0x4')],'online':this['online'],'voicePause':this[_0xc430('0x6')],'chatPause':this[_0xc430('0x7')],'mailPause':this[_0xc430('0x8')],'smsPause':this[_0xc430('0xa')],'faxPause':this['faxPause'],'openchannelPause':this[_0xc430('0xb')],'chatStatus':this[_0xc430('0xc')],'chatStatusTime':this[_0xc430('0xd')],'chatCapacity':this[_0xc430('0xe')],'chatCurrentCapacity':this['chatCurrentCapacity'],'mailStatus':this[_0xc430('0x10')],'mailStatusTime':this[_0xc430('0x12')],'mailCapacity':this['mailCapacity'],'mailCurrentCapacity':this[_0xc430('0x34')],'faxStatus':this['faxStatus'],'faxStatusTime':this['faxStatusTime'],'faxCapacity':this[_0xc430('0x15')],'faxCurrentCapacity':this[_0xc430('0x16')],'smsStatus':this[_0xc430('0x35')],'smsStatusTime':this[_0xc430('0x36')],'smsCapacity':this[_0xc430('0x17')],'smsCurrentCapacity':this[_0xc430('0x18')],'whatsappStatus':this[_0xc430('0x19')],'whatsappStatusTime':this[_0xc430('0x37')],'whatsappCapacity':this['whatsappCapacity'],'whatsappCurrentCapacity':this[_0xc430('0x1b')],'openchannelStatus':this['openchannelStatus'],'openchannelStatusTime':this[_0xc430('0x1c')],'openchannelCapacity':this[_0xc430('0x1d')],'openchannelCurrentCapacity':this[_0xc430('0x1e')],'busy':this[_0xc430('0x1f')],'busyQueue':this['busyQueue'],'chatWaitingInteractions':this[_0xc430('0x38')],'faxWaitingInteractions':this['faxWaitingInteractions'],'mailWaitingInteractions':this['mailWaitingInteractions'],'openchannelWaitingInteractions':this[_0xc430('0x39')],'smsWaitingInteractions':this[_0xc430('0x23')],'whatsappWaitingInteractions':this['whatsappWaitingInteractions']};var _0x5ff73c=md5(JSON[_0xc430('0x3a')](_0x4cf56c));if(this[_0xc430('0x21')]!==_0x5ff73c){this[_0xc430('0x21')]=_0x5ff73c;io[_0xc430('0x3b')](_0xc430('0x3c'),_[_0xc430('0x3d')](_0x4cf56c,[_0xc430('0x5')]));}};module[_0xc430('0x3e')]=Agent;