Built motion from commit 85328c08.|2.5.50
[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 _0x71a2=['updateRouting','prototype','map','Agents','updateRealtime','loggedIn','length','online','faxPause','paused','available','stringify','format','fax:queue:%s','fax_queue:save','lodash','md5','ioredis','../../../config/environment','redis','defaults','localhost','name','timeout','strategy','beepall','mapAgentsId','waiting'];(function(_0x2c91e9,_0x2fb965){var _0x13f0ff=function(_0xb39edf){while(--_0xb39edf){_0x2c91e9['push'](_0x2c91e9['shift']());}};_0x13f0ff(++_0x2fb965);}(_0x71a2,0x127));var _0x271a=function(_0x3a22ef,_0x25707b){_0x3a22ef=_0x3a22ef-0x0;var _0x32210e=_0x71a2[_0x3a22ef];return _0x32210e;};'use strict';var _=require(_0x271a('0x0'));var md5=require(_0x271a('0x1'));var util=require('util');var Redis=require(_0x271a('0x2'));var config=require(_0x271a('0x3'));config[_0x271a('0x4')]=_[_0x271a('0x5')](config[_0x271a('0x4')],{'host':_0x271a('0x6'),'port':0x18eb});var io=require('socket.io-emitter')(new Redis(config[_0x271a('0x4')]));function FaxQueue(_0x521881){this['id']=_0x521881['id']||0x0;this[_0x271a('0x7')]=_0x521881[_0x271a('0x7')]||'';this['timeout']=_0x521881[_0x271a('0x8')]||0xa;this[_0x271a('0x9')]=_0x521881[_0x271a('0x9')]||_0x271a('0xa');this['Agents']=_0x521881['Agents'];this[_0x271a('0xb')]={};this[_0x271a('0xc')]=0x0;this[_0x271a('0x1')]='';this[_0x271a('0xd')]();this['updateRealtime']();}FaxQueue[_0x271a('0xe')]['updateRouting']=function(){var _0x7f0c0e=this[_0x271a('0xb')]['_rr'];this['mapAgentsId']=_[_0x271a('0xf')](this[_0x271a('0x10')],'id');this[_0x271a('0xb')]['_rr']=_0x7f0c0e;};FaxQueue[_0x271a('0xe')][_0x271a('0x11')]=function(){this[_0x271a('0x12')]=0x0;this['paused']=0x0;for(var _0x2761f4=0x0;_0x2761f4<this[_0x271a('0x10')][_0x271a('0x13')];_0x2761f4+=0x1){if(this[_0x271a('0x10')][_0x2761f4][_0x271a('0x14')]){this['loggedIn']+=0x1;}if(this[_0x271a('0x10')][_0x2761f4][_0x271a('0x15')]){this[_0x271a('0x16')]+=0x1;}}this['available']=this['loggedIn']-this[_0x271a('0x16')];this[_0x271a('0x17')]=this['available']>=0x0?this[_0x271a('0x17')]:0x0;var _0x4dc19d={'id':this['id'],'available':this[_0x271a('0x17')],'loggedIn':this[_0x271a('0x12')],'name':this[_0x271a('0x7')],'paused':this['paused'],'waiting':this[_0x271a('0xc')]};var _0x29dc35=md5(JSON[_0x271a('0x18')](_0x4dc19d));if(this[_0x271a('0x1')]!==_0x29dc35){this[_0x271a('0x1')]=_0x29dc35;io['to'](util[_0x271a('0x19')](_0x271a('0x1a'),_0x4dc19d[_0x271a('0x7')]))['emit'](_0x271a('0x1b'),_0x4dc19d);}};module['exports']=FaxQueue;