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