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