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