Built motion from commit (unavailable).|2.5.4
[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 _0xee4f=['format','chatPause','mailCurrentCapacity','smsCurrentCapacity','whatsappStatusTime','stringify','emit','exports','lodash','ioredis','../../../config/environment','redis','socket.io-emitter','name','online','voicePause','mailPause','faxPause','smsPause','openchannelPause','unknown','chatStatusTime','chatCapacity','chatCurrentCapacity','mailStatus','mailCapacity','faxStatus','faxStatusTime','faxCapacity','faxCurrentCapacity','smsStatus','smsStatusTime','smsCapacity','whatsappStatus','whatsappCapacity','whatsappCurrentCapacity','openchannelStatus','openchannelStatusTime','openchannelCapacity','openchannelCurrentCapacity','busyQueue','md5','updateRealtime','prototype','getChannelStatus','Capacity','CurrentCapacity','maxcapacity','working','idle','mail','length','Status','StatusTime','toNumber'];(function(_0x40c78d,_0x5ed722){var _0x4f51d6=function(_0xea5964){while(--_0xea5964){_0x40c78d['push'](_0x40c78d['shift']());}};_0x4f51d6(++_0x5ed722);}(_0xee4f,0xad));var _0xfee4=function(_0x14e84f,_0x57818b){_0x14e84f=_0x14e84f-0x0;var _0x308101=_0xee4f[_0x14e84f];return _0x308101;};'use strict';var _=require(_0xfee4('0x0'));var moment=require('moment');var md5=require('md5');var Redis=require(_0xfee4('0x1'));var config=require(_0xfee4('0x2'));config[_0xfee4('0x3')]=_['defaults'](config[_0xfee4('0x3')],{'host':'localhost','port':0x18eb});var io=require(_0xfee4('0x4'))(new Redis(config['redis']));function Agent(_0x4da9b6){this['id']=_0x4da9b6['id']||0x0;this[_0xfee4('0x5')]=_0x4da9b6['name']||'';this['online']=_0x4da9b6[_0xfee4('0x6')]||!![];this[_0xfee4('0x7')]=_0x4da9b6[_0xfee4('0x7')]||![];this['chatPause']=_0x4da9b6['chatPause']||![];this[_0xfee4('0x8')]=_0x4da9b6[_0xfee4('0x8')]||![];this[_0xfee4('0x9')]=_0x4da9b6['faxPause']||![];this['smsPause']=_0x4da9b6[_0xfee4('0xa')]||![];this[_0xfee4('0xb')]=_0x4da9b6[_0xfee4('0xb')]||![];this['chatStatus']=_0xfee4('0xc');this[_0xfee4('0xd')]=0x0;this[_0xfee4('0xe')]=_0x4da9b6[_0xfee4('0xe')]||0x0;this[_0xfee4('0xf')]=0x0;this[_0xfee4('0x10')]=_0xfee4('0xc');this['mailStatusTime']=0x0;this[_0xfee4('0x11')]=_0x4da9b6[_0xfee4('0x11')]||0x0;this['mailCurrentCapacity']=0x0;this[_0xfee4('0x12')]=_0xfee4('0xc');this[_0xfee4('0x13')]=0x0;this[_0xfee4('0x14')]=_0x4da9b6[_0xfee4('0x14')]||0x0;this[_0xfee4('0x15')]=0x0;this[_0xfee4('0x16')]='unknown';this[_0xfee4('0x17')]=0x0;this[_0xfee4('0x18')]=_0x4da9b6[_0xfee4('0x18')]||0x0;this['smsCurrentCapacity']=0x0;this[_0xfee4('0x19')]='unknown';this['whatsappStatusTime']=0x0;this[_0xfee4('0x1a')]=_0x4da9b6[_0xfee4('0x1a')]||0x0;this[_0xfee4('0x1b')]=0x0;this[_0xfee4('0x1c')]=_0xfee4('0xc');this[_0xfee4('0x1d')]=0x0;this[_0xfee4('0x1e')]=_0x4da9b6[_0xfee4('0x1e')]||0x0;this[_0xfee4('0x1f')]=0x0;this['busy']=![];this[_0xfee4('0x20')]=undefined;this[_0xfee4('0x21')]='';this[_0xfee4('0x22')]();}Agent[_0xfee4('0x23')][_0xfee4('0x24')]=function(_0x244205){if(this[_0x244205+'CurrentCapacity']>0x0){if(this[_0x244205+_0xfee4('0x25')]>0x0&&this[_0x244205+_0xfee4('0x26')]>=this[_0x244205+_0xfee4('0x25')]){return _0xfee4('0x27');}else{return _0xfee4('0x28');}}else{return _0xfee4('0x29');}};Agent[_0xfee4('0x23')][_0xfee4('0x22')]=function(){var _0x3ac09a=[_0xfee4('0x2a'),'chat','openchannel','fax','sms','whatsapp'];for(var _0xf2651f=0x0;_0xf2651f<_0x3ac09a[_0xfee4('0x2b')];_0xf2651f+=0x1){var _0x2d33c3=this[_0xfee4('0x24')](_0x3ac09a[_0xf2651f]);if(this[_0x3ac09a[_0xf2651f]+_0xfee4('0x2c')]!==_0x2d33c3){this[_0x3ac09a[_0xf2651f]+_0xfee4('0x2d')]=_[_0xfee4('0x2e')](moment()[_0xfee4('0x2f')]('x'));}this[_0x3ac09a[_0xf2651f]+'Status']=_0x2d33c3;}var _0x1a5071={'id':this['id'],'name':this['name'],'online':this['online'],'voicePause':this[_0xfee4('0x7')],'chatPause':this[_0xfee4('0x30')],'mailPause':this['mailPause'],'smsPause':this['smsPause'],'faxPause':this[_0xfee4('0x9')],'openchannelPause':this['openchannelPause'],'chatStatus':this['chatStatus'],'chatStatusTime':this[_0xfee4('0xd')],'chatCapacity':this[_0xfee4('0xe')],'chatCurrentCapacity':this['chatCurrentCapacity'],'mailStatus':this[_0xfee4('0x10')],'mailStatusTime':this['mailStatusTime'],'mailCapacity':this[_0xfee4('0x11')],'mailCurrentCapacity':this[_0xfee4('0x31')],'faxStatus':this[_0xfee4('0x12')],'faxStatusTime':this['faxStatusTime'],'faxCapacity':this[_0xfee4('0x14')],'faxCurrentCapacity':this[_0xfee4('0x15')],'smsStatus':this[_0xfee4('0x16')],'smsStatusTime':this[_0xfee4('0x17')],'smsCapacity':this['smsCapacity'],'smsCurrentCapacity':this[_0xfee4('0x32')],'whatsappStatus':this['whatsappStatus'],'whatsappStatusTime':this[_0xfee4('0x33')],'whatsappCapacity':this[_0xfee4('0x1a')],'whatsappCurrentCapacity':this['whatsappCurrentCapacity'],'openchannelStatus':this[_0xfee4('0x1c')],'openchannelStatusTime':this[_0xfee4('0x1d')],'openchannelCapacity':this['openchannelCapacity'],'openchannelCurrentCapacity':this[_0xfee4('0x1f')],'busy':this['busy'],'busyQueue':this[_0xfee4('0x20')]};var _0x2ad74d=md5(JSON[_0xfee4('0x34')](_0x1a5071));if(this[_0xfee4('0x21')]!==_0x2ad74d){this[_0xfee4('0x21')]=_0x2ad74d;io[_0xfee4('0x35')]('user:save',_0x1a5071);}};module[_0xfee4('0x36')]=Agent;