Built motion from commit 538092ac.|2.6.10
[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 _0xc727=['smsWaitingInteractions','whatsappWaitingInteractions','updateRealtime','getChannelStatus','CurrentCapacity','Capacity','prototype','openchannel','fax','sms','whatsapp','length','Status','StatusTime','format','chatStatusTime','chatCurrentCapacity','mailCurrentCapacity','smsStatus','smsStatusTime','whatsappCurrentCapacity','openchannelStatusTime','emit','user:save','lodash','md5','ioredis','redis','localhost','socket.io-emitter','name','online','voicePause','chatPause','mailPause','faxPause','smsPause','openchannelPause','chatStatus','unknown','chatCapacity','mailStatus','mailStatusTime','mailCapacity','faxStatus','faxStatusTime','faxCapacity','faxCurrentCapacity','smsCapacity','smsCurrentCapacity','whatsappStatus','whatsappStatusTime','whatsappCapacity','openchannelStatus','openchannelCapacity','openchannelCurrentCapacity','busy','busyQueue','chatWaitingInteractions','faxWaitingInteractions','mailWaitingInteractions','openchannelWaitingInteractions'];(function(_0xa65ffb,_0x53dd5b){var _0x491769=function(_0x237134){while(--_0x237134){_0xa65ffb['push'](_0xa65ffb['shift']());}};_0x491769(++_0x53dd5b);}(_0xc727,0x94));var _0x7c72=function(_0x25e1fd,_0x28cff0){_0x25e1fd=_0x25e1fd-0x0;var _0x3e9e8b=_0xc727[_0x25e1fd];return _0x3e9e8b;};'use strict';var _=require(_0x7c72('0x0'));var moment=require('moment');var md5=require(_0x7c72('0x1'));var Redis=require(_0x7c72('0x2'));var config=require('../../../config/environment');config['redis']=_['defaults'](config[_0x7c72('0x3')],{'host':_0x7c72('0x4'),'port':0x18eb});var io=require(_0x7c72('0x5'))(new Redis(config['redis']));function Agent(_0xf7b22d){this['id']=_0xf7b22d['id']||0x0;this['name']=_0xf7b22d[_0x7c72('0x6')]||'';this['online']=_0xf7b22d[_0x7c72('0x7')]||!![];this[_0x7c72('0x8')]=_0xf7b22d[_0x7c72('0x8')]||![];this[_0x7c72('0x9')]=_0xf7b22d['chatPause']||![];this[_0x7c72('0xa')]=_0xf7b22d['mailPause']||![];this[_0x7c72('0xb')]=_0xf7b22d[_0x7c72('0xb')]||![];this[_0x7c72('0xc')]=_0xf7b22d[_0x7c72('0xc')]||![];this[_0x7c72('0xd')]=_0xf7b22d['openchannelPause']||![];this[_0x7c72('0xe')]=_0x7c72('0xf');this['chatStatusTime']=0x0;this[_0x7c72('0x10')]=_0xf7b22d[_0x7c72('0x10')]||0x0;this['chatCurrentCapacity']=0x0;this[_0x7c72('0x11')]=_0x7c72('0xf');this[_0x7c72('0x12')]=0x0;this[_0x7c72('0x13')]=_0xf7b22d[_0x7c72('0x13')]||0x0;this['mailCurrentCapacity']=0x0;this[_0x7c72('0x14')]=_0x7c72('0xf');this[_0x7c72('0x15')]=0x0;this[_0x7c72('0x16')]=_0xf7b22d[_0x7c72('0x16')]||0x0;this[_0x7c72('0x17')]=0x0;this['smsStatus']=_0x7c72('0xf');this['smsStatusTime']=0x0;this[_0x7c72('0x18')]=_0xf7b22d['smsCapacity']||0x0;this[_0x7c72('0x19')]=0x0;this[_0x7c72('0x1a')]='unknown';this[_0x7c72('0x1b')]=0x0;this[_0x7c72('0x1c')]=_0xf7b22d['whatsappCapacity']||0x0;this['whatsappCurrentCapacity']=0x0;this[_0x7c72('0x1d')]=_0x7c72('0xf');this['openchannelStatusTime']=0x0;this[_0x7c72('0x1e')]=_0xf7b22d[_0x7c72('0x1e')]||0x0;this[_0x7c72('0x1f')]=0x0;this[_0x7c72('0x20')]=![];this[_0x7c72('0x21')]=undefined;this[_0x7c72('0x1')]='';this[_0x7c72('0x22')]={};this[_0x7c72('0x23')]={};this[_0x7c72('0x24')]={};this[_0x7c72('0x25')]={};this[_0x7c72('0x26')]={};this[_0x7c72('0x27')]={};this[_0x7c72('0x28')]();}Agent['prototype'][_0x7c72('0x29')]=function(_0x125dc5){if(this[_0x125dc5+_0x7c72('0x2a')]>0x0){if(this[_0x125dc5+_0x7c72('0x2b')]>0x0&&this[_0x125dc5+'CurrentCapacity']>=this[_0x125dc5+_0x7c72('0x2b')]){return'maxcapacity';}else{return'working';}}else{return'idle';}};Agent[_0x7c72('0x2c')]['updateRealtime']=function(){var _0x1ccb96=['mail','chat',_0x7c72('0x2d'),_0x7c72('0x2e'),_0x7c72('0x2f'),_0x7c72('0x30')];for(var _0x21d81e=0x0;_0x21d81e<_0x1ccb96[_0x7c72('0x31')];_0x21d81e+=0x1){var _0x13ce0a=this[_0x7c72('0x29')](_0x1ccb96[_0x21d81e]);if(this[_0x1ccb96[_0x21d81e]+_0x7c72('0x32')]!==_0x13ce0a){this[_0x1ccb96[_0x21d81e]+_0x7c72('0x33')]=_['toNumber'](moment()[_0x7c72('0x34')]('x'));}this[_0x1ccb96[_0x21d81e]+'Status']=_0x13ce0a;}var _0x5ad289={'id':this['id'],'name':this[_0x7c72('0x6')],'online':this[_0x7c72('0x7')],'voicePause':this[_0x7c72('0x8')],'chatPause':this[_0x7c72('0x9')],'mailPause':this[_0x7c72('0xa')],'smsPause':this[_0x7c72('0xc')],'faxPause':this[_0x7c72('0xb')],'openchannelPause':this[_0x7c72('0xd')],'chatStatus':this[_0x7c72('0xe')],'chatStatusTime':this[_0x7c72('0x35')],'chatCapacity':this[_0x7c72('0x10')],'chatCurrentCapacity':this[_0x7c72('0x36')],'mailStatus':this['mailStatus'],'mailStatusTime':this[_0x7c72('0x12')],'mailCapacity':this['mailCapacity'],'mailCurrentCapacity':this[_0x7c72('0x37')],'faxStatus':this['faxStatus'],'faxStatusTime':this['faxStatusTime'],'faxCapacity':this[_0x7c72('0x16')],'faxCurrentCapacity':this['faxCurrentCapacity'],'smsStatus':this[_0x7c72('0x38')],'smsStatusTime':this[_0x7c72('0x39')],'smsCapacity':this[_0x7c72('0x18')],'smsCurrentCapacity':this['smsCurrentCapacity'],'whatsappStatus':this['whatsappStatus'],'whatsappStatusTime':this[_0x7c72('0x1b')],'whatsappCapacity':this['whatsappCapacity'],'whatsappCurrentCapacity':this[_0x7c72('0x3a')],'openchannelStatus':this['openchannelStatus'],'openchannelStatusTime':this[_0x7c72('0x3b')],'openchannelCapacity':this[_0x7c72('0x1e')],'openchannelCurrentCapacity':this[_0x7c72('0x1f')],'busy':this[_0x7c72('0x20')],'busyQueue':this[_0x7c72('0x21')],'chatWaitingInteractions':this[_0x7c72('0x22')],'faxWaitingInteractions':this[_0x7c72('0x23')],'mailWaitingInteractions':this[_0x7c72('0x24')],'openchannelWaitingInteractions':this[_0x7c72('0x25')],'smsWaitingInteractions':this[_0x7c72('0x26')],'whatsappWaitingInteractions':this[_0x7c72('0x27')]};var _0x41f374=md5(JSON['stringify'](_0x5ad289));if(this[_0x7c72('0x1')]!==_0x41f374){this[_0x7c72('0x1')]=_0x41f374;io[_0x7c72('0x3c')](_0x7c72('0x3d'),_0x5ad289);}};module['exports']=Agent;