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