0e17a9016b79256cc0904c17e7858a448f2346d2
[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 _0x2f5a=['updateRealtime','prototype','getChannelStatus','Capacity','CurrentCapacity','working','idle','mail','chat','openchannel','fax','whatsapp','Status','StatusTime','format','faxStatus','whatsappStatusTime','openchannelCapacity','stringify','emit','user:save','exports','lodash','moment','md5','ioredis','../../../config/environment','redis','localhost','name','online','voicePause','chatPause','mailPause','faxPause','smsPause','openchannelPause','chatStatus','unknown','chatStatusTime','chatCapacity','mailStatus','mailStatusTime','mailCapacity','mailCurrentCapacity','faxStatusTime','faxCapacity','faxCurrentCapacity','smsStatus','smsStatusTime','smsCapacity','smsCurrentCapacity','whatsappStatus','whatsappCapacity','whatsappCurrentCapacity','openchannelStatus','openchannelStatusTime','openchannelCurrentCapacity','busy','busyQueue'];(function(_0x293055,_0x10e0b1){var _0x19c83a=function(_0x2b3027){while(--_0x2b3027){_0x293055['push'](_0x293055['shift']());}};_0x19c83a(++_0x10e0b1);}(_0x2f5a,0xca));var _0xa2f5=function(_0x1e8690,_0x5c6b4c){_0x1e8690=_0x1e8690-0x0;var _0x414bea=_0x2f5a[_0x1e8690];return _0x414bea;};'use strict';var _=require(_0xa2f5('0x0'));var moment=require(_0xa2f5('0x1'));var md5=require(_0xa2f5('0x2'));var Redis=require(_0xa2f5('0x3'));var config=require(_0xa2f5('0x4'));config[_0xa2f5('0x5')]=_['defaults'](config['redis'],{'host':_0xa2f5('0x6'),'port':0x18eb});var io=require('socket.io-emitter')(new Redis(config[_0xa2f5('0x5')]));function Agent(_0xa14062){this['id']=_0xa14062['id']||0x0;this[_0xa2f5('0x7')]=_0xa14062[_0xa2f5('0x7')]||'';this[_0xa2f5('0x8')]=_0xa14062[_0xa2f5('0x8')]||!![];this[_0xa2f5('0x9')]=_0xa14062[_0xa2f5('0x9')]||![];this[_0xa2f5('0xa')]=_0xa14062['chatPause']||![];this[_0xa2f5('0xb')]=_0xa14062[_0xa2f5('0xb')]||![];this[_0xa2f5('0xc')]=_0xa14062[_0xa2f5('0xc')]||![];this[_0xa2f5('0xd')]=_0xa14062[_0xa2f5('0xd')]||![];this[_0xa2f5('0xe')]=_0xa14062[_0xa2f5('0xe')]||![];this[_0xa2f5('0xf')]=_0xa2f5('0x10');this[_0xa2f5('0x11')]=0x0;this[_0xa2f5('0x12')]=_0xa14062[_0xa2f5('0x12')]||0x0;this['chatCurrentCapacity']=0x0;this[_0xa2f5('0x13')]=_0xa2f5('0x10');this[_0xa2f5('0x14')]=0x0;this[_0xa2f5('0x15')]=_0xa14062[_0xa2f5('0x15')]||0x0;this[_0xa2f5('0x16')]=0x0;this['faxStatus']=_0xa2f5('0x10');this[_0xa2f5('0x17')]=0x0;this['faxCapacity']=_0xa14062[_0xa2f5('0x18')]||0x0;this[_0xa2f5('0x19')]=0x0;this[_0xa2f5('0x1a')]=_0xa2f5('0x10');this[_0xa2f5('0x1b')]=0x0;this[_0xa2f5('0x1c')]=_0xa14062['smsCapacity']||0x0;this[_0xa2f5('0x1d')]=0x0;this[_0xa2f5('0x1e')]='unknown';this['whatsappStatusTime']=0x0;this['whatsappCapacity']=_0xa14062[_0xa2f5('0x1f')]||0x0;this[_0xa2f5('0x20')]=0x0;this[_0xa2f5('0x21')]='unknown';this[_0xa2f5('0x22')]=0x0;this['openchannelCapacity']=_0xa14062['openchannelCapacity']||0x0;this[_0xa2f5('0x23')]=0x0;this[_0xa2f5('0x24')]=![];this[_0xa2f5('0x25')]=undefined;this[_0xa2f5('0x2')]='';this[_0xa2f5('0x26')]();}Agent[_0xa2f5('0x27')][_0xa2f5('0x28')]=function(_0x35f636){if(this[_0x35f636+'CurrentCapacity']>0x0){if(this[_0x35f636+_0xa2f5('0x29')]>0x0&&this[_0x35f636+_0xa2f5('0x2a')]>=this[_0x35f636+_0xa2f5('0x29')]){return'maxcapacity';}else{return _0xa2f5('0x2b');}}else{return _0xa2f5('0x2c');}};Agent[_0xa2f5('0x27')]['updateRealtime']=function(){var _0x315b43=[_0xa2f5('0x2d'),_0xa2f5('0x2e'),_0xa2f5('0x2f'),_0xa2f5('0x30'),'sms',_0xa2f5('0x31')];for(var _0x4ebf2d=0x0;_0x4ebf2d<_0x315b43['length'];_0x4ebf2d+=0x1){var _0x167233=this['getChannelStatus'](_0x315b43[_0x4ebf2d]);if(this[_0x315b43[_0x4ebf2d]+_0xa2f5('0x32')]!==_0x167233){this[_0x315b43[_0x4ebf2d]+_0xa2f5('0x33')]=_['toNumber'](moment()[_0xa2f5('0x34')]('x'));}this[_0x315b43[_0x4ebf2d]+_0xa2f5('0x32')]=_0x167233;}var _0x26ec6d={'id':this['id'],'name':this['name'],'online':this[_0xa2f5('0x8')],'voicePause':this[_0xa2f5('0x9')],'chatPause':this['chatPause'],'mailPause':this['mailPause'],'smsPause':this[_0xa2f5('0xd')],'faxPause':this['faxPause'],'openchannelPause':this['openchannelPause'],'chatStatus':this[_0xa2f5('0xf')],'chatStatusTime':this['chatStatusTime'],'chatCapacity':this[_0xa2f5('0x12')],'chatCurrentCapacity':this['chatCurrentCapacity'],'mailStatus':this[_0xa2f5('0x13')],'mailStatusTime':this[_0xa2f5('0x14')],'mailCapacity':this[_0xa2f5('0x15')],'mailCurrentCapacity':this[_0xa2f5('0x16')],'faxStatus':this[_0xa2f5('0x35')],'faxStatusTime':this['faxStatusTime'],'faxCapacity':this[_0xa2f5('0x18')],'faxCurrentCapacity':this[_0xa2f5('0x19')],'smsStatus':this[_0xa2f5('0x1a')],'smsStatusTime':this[_0xa2f5('0x1b')],'smsCapacity':this[_0xa2f5('0x1c')],'smsCurrentCapacity':this['smsCurrentCapacity'],'whatsappStatus':this['whatsappStatus'],'whatsappStatusTime':this[_0xa2f5('0x36')],'whatsappCapacity':this[_0xa2f5('0x1f')],'whatsappCurrentCapacity':this['whatsappCurrentCapacity'],'openchannelStatus':this['openchannelStatus'],'openchannelStatusTime':this[_0xa2f5('0x22')],'openchannelCapacity':this[_0xa2f5('0x37')],'openchannelCurrentCapacity':this['openchannelCurrentCapacity'],'busy':this[_0xa2f5('0x24')],'busyQueue':this[_0xa2f5('0x25')]};var _0x443bc0=md5(JSON[_0xa2f5('0x38')](_0x26ec6d));if(this[_0xa2f5('0x2')]!==_0x443bc0){this[_0xa2f5('0x2')]=_0x443bc0;io[_0xa2f5('0x39')](_0xa2f5('0x3a'),_0x26ec6d);}};module[_0xa2f5('0x3b')]=Agent;