Built motion from commit (unavailable).|2.4.18
[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 _0xa9e0=['openchannelCapacity','openchannelCurrentCapacity','busy','busyQueue','updateRealtime','prototype','getChannelStatus','CurrentCapacity','Capacity','working','mail','chat','fax','sms','length','Status','format','voicePause','chatStatus','chatStatusTime','smsStatus','smsStatusTime','smsCurrentCapacity','emit','user:save','exports','lodash','moment','md5','redis','localhost','socket.io-emitter','name','online','chatPause','mailPause','faxPause','smsPause','openchannelPause','chatCapacity','chatCurrentCapacity','mailStatus','unknown','mailStatusTime','mailCapacity','mailCurrentCapacity','faxStatus','faxStatusTime','faxCapacity','faxCurrentCapacity','smsCapacity','openchannelStatus','openchannelStatusTime'];(function(_0x5317b5,_0x4dfd6e){var _0x3b7ce2=function(_0xc146d6){while(--_0xc146d6){_0x5317b5['push'](_0x5317b5['shift']());}};_0x3b7ce2(++_0x4dfd6e);}(_0xa9e0,0x123));var _0x0a9e=function(_0x36dfbd,_0x5bfe2d){_0x36dfbd=_0x36dfbd-0x0;var _0x4ecad9=_0xa9e0[_0x36dfbd];return _0x4ecad9;};'use strict';var _=require(_0x0a9e('0x0'));var moment=require(_0x0a9e('0x1'));var md5=require(_0x0a9e('0x2'));var Redis=require('ioredis');var config=require('../../../config/environment');config[_0x0a9e('0x3')]=_['defaults'](config[_0x0a9e('0x3')],{'host':_0x0a9e('0x4'),'port':0x18eb});var io=require(_0x0a9e('0x5'))(new Redis(config[_0x0a9e('0x3')]));function Agent(_0x981158){this['id']=_0x981158['id']||0x0;this['name']=_0x981158[_0x0a9e('0x6')]||'';this[_0x0a9e('0x7')]=_0x981158[_0x0a9e('0x7')]||!![];this['voicePause']=_0x981158['voicePause']||![];this[_0x0a9e('0x8')]=_0x981158['chatPause']||![];this['mailPause']=_0x981158[_0x0a9e('0x9')]||![];this[_0x0a9e('0xa')]=_0x981158[_0x0a9e('0xa')]||![];this[_0x0a9e('0xb')]=_0x981158[_0x0a9e('0xb')]||![];this[_0x0a9e('0xc')]=_0x981158['openchannelPause']||![];this['chatStatus']='unknown';this['chatStatusTime']=0x0;this[_0x0a9e('0xd')]=_0x981158[_0x0a9e('0xd')]||0x0;this[_0x0a9e('0xe')]=0x0;this[_0x0a9e('0xf')]=_0x0a9e('0x10');this[_0x0a9e('0x11')]=0x0;this['mailCapacity']=_0x981158[_0x0a9e('0x12')]||0x0;this[_0x0a9e('0x13')]=0x0;this[_0x0a9e('0x14')]=_0x0a9e('0x10');this[_0x0a9e('0x15')]=0x0;this[_0x0a9e('0x16')]=_0x981158['faxCapacity']||0x0;this[_0x0a9e('0x17')]=0x0;this['smsStatus']=_0x0a9e('0x10');this['smsStatusTime']=0x0;this[_0x0a9e('0x18')]=_0x981158[_0x0a9e('0x18')]||0x0;this['smsCurrentCapacity']=0x0;this[_0x0a9e('0x19')]='unknown';this[_0x0a9e('0x1a')]=0x0;this[_0x0a9e('0x1b')]=_0x981158[_0x0a9e('0x1b')]||0x0;this[_0x0a9e('0x1c')]=0x0;this[_0x0a9e('0x1d')]=![];this[_0x0a9e('0x1e')]=undefined;this[_0x0a9e('0x2')]='';this[_0x0a9e('0x1f')]();}Agent[_0x0a9e('0x20')][_0x0a9e('0x21')]=function(_0x1c696a){if(this[_0x1c696a+_0x0a9e('0x22')]>0x0){if(this[_0x1c696a+'Capacity']>0x0&&this[_0x1c696a+_0x0a9e('0x22')]>=this[_0x1c696a+_0x0a9e('0x23')]){return'maxcapacity';}else{return _0x0a9e('0x24');}}else{return'idle';}};Agent['prototype'][_0x0a9e('0x1f')]=function(){var _0x432e56=[_0x0a9e('0x25'),_0x0a9e('0x26'),'openchannel',_0x0a9e('0x27'),_0x0a9e('0x28')];for(var _0x3b45bc=0x0;_0x3b45bc<_0x432e56[_0x0a9e('0x29')];_0x3b45bc+=0x1){var _0x370d86=this[_0x0a9e('0x21')](_0x432e56[_0x3b45bc]);if(this[_0x432e56[_0x3b45bc]+_0x0a9e('0x2a')]!==_0x370d86){this[_0x432e56[_0x3b45bc]+'StatusTime']=_['toNumber'](moment()[_0x0a9e('0x2b')]('x'));}this[_0x432e56[_0x3b45bc]+_0x0a9e('0x2a')]=_0x370d86;}var _0x40c424={'id':this['id'],'name':this[_0x0a9e('0x6')],'online':this['online'],'voicePause':this[_0x0a9e('0x2c')],'chatPause':this['chatPause'],'mailPause':this[_0x0a9e('0x9')],'smsPause':this['smsPause'],'faxPause':this[_0x0a9e('0xa')],'openchannelPause':this[_0x0a9e('0xc')],'chatStatus':this[_0x0a9e('0x2d')],'chatStatusTime':this[_0x0a9e('0x2e')],'chatCapacity':this[_0x0a9e('0xd')],'chatCurrentCapacity':this[_0x0a9e('0xe')],'mailStatus':this[_0x0a9e('0xf')],'mailStatusTime':this[_0x0a9e('0x11')],'mailCapacity':this['mailCapacity'],'mailCurrentCapacity':this[_0x0a9e('0x13')],'faxStatus':this[_0x0a9e('0x14')],'faxStatusTime':this[_0x0a9e('0x15')],'faxCapacity':this[_0x0a9e('0x16')],'faxCurrentCapacity':this['faxCurrentCapacity'],'smsStatus':this[_0x0a9e('0x2f')],'smsStatusTime':this[_0x0a9e('0x30')],'smsCapacity':this[_0x0a9e('0x18')],'smsCurrentCapacity':this[_0x0a9e('0x31')],'openchannelStatus':this[_0x0a9e('0x19')],'openchannelStatusTime':this[_0x0a9e('0x1a')],'openchannelCapacity':this[_0x0a9e('0x1b')],'openchannelCurrentCapacity':this[_0x0a9e('0x1c')],'busy':this[_0x0a9e('0x1d')],'busyQueue':this['busyQueue']};var _0x426950=md5(JSON['stringify'](_0x40c424));if(this[_0x0a9e('0x2')]!==_0x426950){this[_0x0a9e('0x2')]=_0x426950;io[_0x0a9e('0x32')](_0x0a9e('0x33'),_0x40c424);}};module[_0x0a9e('0x34')]=Agent;