5f5c2efb60555130ff9d03a4df3d6eb58faba68c
[motion2.git] / server / services / routing / model / faxQueue.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 _0xc791=['updateRealtime','loggedIn','online','paused','available','stringify','format','fax:queue:%s','fax_queue:save','exports','lodash','md5','util','ioredis','../../../config/environment','redis','localhost','socket.io-emitter','name','timeout','strategy','beepall','Agents','mapAgentsId','waiting','updateRouting','prototype','_rr','map'];(function(_0x662759,_0x4689f0){var _0x3eda5f=function(_0x1a495f){while(--_0x1a495f){_0x662759['push'](_0x662759['shift']());}};_0x3eda5f(++_0x4689f0);}(_0xc791,0xf2));var _0x1c79=function(_0x24cf99,_0x2e2189){_0x24cf99=_0x24cf99-0x0;var _0x210865=_0xc791[_0x24cf99];return _0x210865;};'use strict';var _=require(_0x1c79('0x0'));var md5=require(_0x1c79('0x1'));var util=require(_0x1c79('0x2'));var Redis=require(_0x1c79('0x3'));var config=require(_0x1c79('0x4'));config[_0x1c79('0x5')]=_['defaults'](config[_0x1c79('0x5')],{'host':_0x1c79('0x6'),'port':0x18eb});var io=require(_0x1c79('0x7'))(new Redis(config[_0x1c79('0x5')]));function FaxQueue(_0x4e1d00){this['id']=_0x4e1d00['id']||0x0;this[_0x1c79('0x8')]=_0x4e1d00[_0x1c79('0x8')]||'';this[_0x1c79('0x9')]=_0x4e1d00[_0x1c79('0x9')]||0xa;this['strategy']=_0x4e1d00[_0x1c79('0xa')]||_0x1c79('0xb');this[_0x1c79('0xc')]=_0x4e1d00[_0x1c79('0xc')];this[_0x1c79('0xd')]={};this[_0x1c79('0xe')]=0x0;this['md5']='';this[_0x1c79('0xf')]();this['updateRealtime']();}FaxQueue[_0x1c79('0x10')][_0x1c79('0xf')]=function(){var _0x348c6e=this[_0x1c79('0xd')][_0x1c79('0x11')];this[_0x1c79('0xd')]=_[_0x1c79('0x12')](this[_0x1c79('0xc')],'id');this[_0x1c79('0xd')][_0x1c79('0x11')]=_0x348c6e;};FaxQueue[_0x1c79('0x10')][_0x1c79('0x13')]=function(){this[_0x1c79('0x14')]=0x0;this['paused']=0x0;for(var _0x54c4d7=0x0;_0x54c4d7<this['Agents']['length'];_0x54c4d7+=0x1){if(this[_0x1c79('0xc')][_0x54c4d7][_0x1c79('0x15')]){this['loggedIn']+=0x1;}if(this[_0x1c79('0xc')][_0x54c4d7]['faxPause']){this[_0x1c79('0x16')]+=0x1;}}this[_0x1c79('0x17')]=this[_0x1c79('0x14')]-this[_0x1c79('0x16')];this[_0x1c79('0x17')]=this[_0x1c79('0x17')]>=0x0?this['available']:0x0;var _0xde3f00={'id':this['id'],'available':this[_0x1c79('0x17')],'loggedIn':this['loggedIn'],'name':this[_0x1c79('0x8')],'paused':this[_0x1c79('0x16')],'waiting':this[_0x1c79('0xe')]};var _0x2c2f7e=md5(JSON[_0x1c79('0x18')](_0xde3f00));if(this[_0x1c79('0x1')]!==_0x2c2f7e){this['md5']=_0x2c2f7e;io['to'](util[_0x1c79('0x19')](_0x1c79('0x1a'),_0xde3f00[_0x1c79('0x8')]))['emit'](_0x1c79('0x1b'),_0xde3f00);}};module[_0x1c79('0x1c')]=FaxQueue;