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