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