Built motion from commit 013e4bb4.|2.6.18
[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 _0x402f=['socket.io-emitter','name','timeout','strategy','beepall','Agents','waiting','md5','updateRouting','updateRealtime','prototype','mapAgentsId','_rr','map','loggedIn','length','online','faxPause','paused','available','stringify','format','fax:queue:%s','emit','fax_queue:save','exports','lodash','ioredis','../../../config/environment','redis','defaults','localhost'];(function(_0x1896e6,_0x5eed40){var _0x583ffc=function(_0x5688ff){while(--_0x5688ff){_0x1896e6['push'](_0x1896e6['shift']());}};_0x583ffc(++_0x5eed40);}(_0x402f,0x13a));var _0xf402=function(_0x4071e5,_0x22dc44){_0x4071e5=_0x4071e5-0x0;var _0x1bf99e=_0x402f[_0x4071e5];return _0x1bf99e;};'use strict';var _=require(_0xf402('0x0'));var md5=require('md5');var util=require('util');var Redis=require(_0xf402('0x1'));var config=require(_0xf402('0x2'));config[_0xf402('0x3')]=_[_0xf402('0x4')](config['redis'],{'host':_0xf402('0x5'),'port':0x18eb});var io=require(_0xf402('0x6'))(new Redis(config[_0xf402('0x3')]));function FaxQueue(_0x311cd6){this['id']=_0x311cd6['id']||0x0;this[_0xf402('0x7')]=_0x311cd6['name']||'';this[_0xf402('0x8')]=_0x311cd6[_0xf402('0x8')]||0xa;this[_0xf402('0x9')]=_0x311cd6[_0xf402('0x9')]||_0xf402('0xa');this[_0xf402('0xb')]=_0x311cd6[_0xf402('0xb')];this['mapAgentsId']={};this[_0xf402('0xc')]=0x0;this[_0xf402('0xd')]='';this[_0xf402('0xe')]();this[_0xf402('0xf')]();}FaxQueue[_0xf402('0x10')]['updateRouting']=function(){var _0x57983b=this[_0xf402('0x11')][_0xf402('0x12')];this['mapAgentsId']=_[_0xf402('0x13')](this[_0xf402('0xb')],'id');this[_0xf402('0x11')]['_rr']=_0x57983b;};FaxQueue[_0xf402('0x10')][_0xf402('0xf')]=function(){this[_0xf402('0x14')]=0x0;this['paused']=0x0;for(var _0x11beca=0x0;_0x11beca<this[_0xf402('0xb')][_0xf402('0x15')];_0x11beca+=0x1){if(this['Agents'][_0x11beca][_0xf402('0x16')]){this['loggedIn']+=0x1;}if(this['Agents'][_0x11beca][_0xf402('0x17')]){this[_0xf402('0x18')]+=0x1;}}this[_0xf402('0x19')]=this[_0xf402('0x14')]-this['paused'];this[_0xf402('0x19')]=this[_0xf402('0x19')]>=0x0?this[_0xf402('0x19')]:0x0;var _0x319c1a={'id':this['id'],'available':this[_0xf402('0x19')],'loggedIn':this['loggedIn'],'name':this[_0xf402('0x7')],'paused':this[_0xf402('0x18')],'waiting':this['waiting']};var _0x23f1ad=md5(JSON[_0xf402('0x1a')](_0x319c1a));if(this[_0xf402('0xd')]!==_0x23f1ad){this['md5']=_0x23f1ad;io['to'](util[_0xf402('0x1b')](_0xf402('0x1c'),_0x319c1a['name']))[_0xf402('0x1d')](_0xf402('0x1e'),_0x319c1a);}};module[_0xf402('0x1f')]=FaxQueue;