32616884b660420981fb76979fed6f223f46a759
[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 _0x9f37=['working','chat','openchannel','length','Status','StatusTime','toNumber','format','mailStatus','smsStatus','stringify','emit','user:save','exports','lodash','moment','ioredis','../../../config/environment','redis','defaults','localhost','socket.io-emitter','name','online','voicePause','chatPause','mailPause','faxPause','smsPause','openchannelPause','chatStatus','unknown','chatStatusTime','chatCapacity','chatCurrentCapacity','mailStatusTime','mailCapacity','mailCurrentCapacity','faxStatus','faxCapacity','faxCurrentCapacity','smsStatusTime','smsCapacity','smsCurrentCapacity','openchannelStatus','openchannelStatusTime','openchannelCapacity','openchannelCurrentCapacity','busy','busyQueue','md5','updateRealtime','prototype','getChannelStatus','CurrentCapacity','Capacity'];(function(_0x537501,_0x1509e4){var _0x54bfc2=function(_0x29bd68){while(--_0x29bd68){_0x537501['push'](_0x537501['shift']());}};_0x54bfc2(++_0x1509e4);}(_0x9f37,0xb6));var _0x79f3=function(_0x2ec461,_0x5f588a){_0x2ec461=_0x2ec461-0x0;var _0x28603d=_0x9f37[_0x2ec461];return _0x28603d;};'use strict';var _=require(_0x79f3('0x0'));var moment=require(_0x79f3('0x1'));var md5=require('md5');var Redis=require(_0x79f3('0x2'));var config=require(_0x79f3('0x3'));config[_0x79f3('0x4')]=_[_0x79f3('0x5')](config['redis'],{'host':_0x79f3('0x6'),'port':0x18eb});var io=require(_0x79f3('0x7'))(new Redis(config['redis']));function Agent(_0x3da5ec){this['id']=_0x3da5ec['id']||0x0;this[_0x79f3('0x8')]=_0x3da5ec['name']||'';this['online']=_0x3da5ec[_0x79f3('0x9')]||!![];this[_0x79f3('0xa')]=_0x3da5ec[_0x79f3('0xa')]||![];this[_0x79f3('0xb')]=_0x3da5ec[_0x79f3('0xb')]||![];this[_0x79f3('0xc')]=_0x3da5ec[_0x79f3('0xc')]||![];this[_0x79f3('0xd')]=_0x3da5ec['faxPause']||![];this[_0x79f3('0xe')]=_0x3da5ec[_0x79f3('0xe')]||![];this[_0x79f3('0xf')]=_0x3da5ec[_0x79f3('0xf')]||![];this[_0x79f3('0x10')]=_0x79f3('0x11');this[_0x79f3('0x12')]=0x0;this['chatCapacity']=_0x3da5ec[_0x79f3('0x13')]||0x0;this[_0x79f3('0x14')]=0x0;this['mailStatus']=_0x79f3('0x11');this[_0x79f3('0x15')]=0x0;this[_0x79f3('0x16')]=_0x3da5ec[_0x79f3('0x16')]||0x0;this[_0x79f3('0x17')]=0x0;this[_0x79f3('0x18')]='unknown';this['faxStatusTime']=0x0;this[_0x79f3('0x19')]=_0x3da5ec[_0x79f3('0x19')]||0x0;this[_0x79f3('0x1a')]=0x0;this['smsStatus']=_0x79f3('0x11');this[_0x79f3('0x1b')]=0x0;this['smsCapacity']=_0x3da5ec[_0x79f3('0x1c')]||0x0;this[_0x79f3('0x1d')]=0x0;this[_0x79f3('0x1e')]=_0x79f3('0x11');this[_0x79f3('0x1f')]=0x0;this[_0x79f3('0x20')]=_0x3da5ec['openchannelCapacity']||0x0;this[_0x79f3('0x21')]=0x0;this[_0x79f3('0x22')]=![];this[_0x79f3('0x23')]=undefined;this[_0x79f3('0x24')]='';this[_0x79f3('0x25')]();}Agent[_0x79f3('0x26')][_0x79f3('0x27')]=function(_0x5b4b9a){if(this[_0x5b4b9a+_0x79f3('0x28')]>0x0){if(this[_0x5b4b9a+_0x79f3('0x29')]>0x0&&this[_0x5b4b9a+_0x79f3('0x28')]>=this[_0x5b4b9a+_0x79f3('0x29')]){return'maxcapacity';}else{return _0x79f3('0x2a');}}else{return'idle';}};Agent['prototype'][_0x79f3('0x25')]=function(){var _0xafaf21=['mail',_0x79f3('0x2b'),_0x79f3('0x2c'),'fax','sms'];for(var _0x46531a=0x0;_0x46531a<_0xafaf21[_0x79f3('0x2d')];_0x46531a+=0x1){var _0x5e6136=this['getChannelStatus'](_0xafaf21[_0x46531a]);if(this[_0xafaf21[_0x46531a]+_0x79f3('0x2e')]!==_0x5e6136){this[_0xafaf21[_0x46531a]+_0x79f3('0x2f')]=_[_0x79f3('0x30')](moment()[_0x79f3('0x31')]('x'));}this[_0xafaf21[_0x46531a]+_0x79f3('0x2e')]=_0x5e6136;}var _0x3205f0={'id':this['id'],'name':this['name'],'online':this['online'],'voicePause':this[_0x79f3('0xa')],'chatPause':this['chatPause'],'mailPause':this[_0x79f3('0xc')],'smsPause':this[_0x79f3('0xe')],'faxPause':this['faxPause'],'openchannelPause':this[_0x79f3('0xf')],'chatStatus':this['chatStatus'],'chatStatusTime':this['chatStatusTime'],'chatCapacity':this[_0x79f3('0x13')],'chatCurrentCapacity':this['chatCurrentCapacity'],'mailStatus':this[_0x79f3('0x32')],'mailStatusTime':this['mailStatusTime'],'mailCapacity':this[_0x79f3('0x16')],'mailCurrentCapacity':this[_0x79f3('0x17')],'faxStatus':this[_0x79f3('0x18')],'faxStatusTime':this['faxStatusTime'],'faxCapacity':this[_0x79f3('0x19')],'faxCurrentCapacity':this[_0x79f3('0x1a')],'smsStatus':this[_0x79f3('0x33')],'smsStatusTime':this[_0x79f3('0x1b')],'smsCapacity':this[_0x79f3('0x1c')],'smsCurrentCapacity':this[_0x79f3('0x1d')],'openchannelStatus':this[_0x79f3('0x1e')],'openchannelStatusTime':this['openchannelStatusTime'],'openchannelCapacity':this[_0x79f3('0x20')],'openchannelCurrentCapacity':this[_0x79f3('0x21')],'busy':this[_0x79f3('0x22')],'busyQueue':this[_0x79f3('0x23')]};var _0x2d182d=md5(JSON[_0x79f3('0x34')](_0x3205f0));if(this['md5']!==_0x2d182d){this[_0x79f3('0x24')]=_0x2d182d;io[_0x79f3('0x35')](_0x79f3('0x36'),_0x3205f0);}};module[_0x79f3('0x37')]=Agent;