Built motion from commit 58b0471d.|2.6.29
[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 _0x9523=['emit','exports','lodash','util','ioredis','../../../config/environment','redis','localhost','socket.io-emitter','name','timeout','strategy','Agents','mapAgentsId','waiting','md5','updateRealtime','prototype','updateRouting','_rr','map','loggedIn','length','online','paused','available','stringify','format','fax:queue:%s'];(function(_0x51534d,_0x5676be){var _0x3f49c6=function(_0x3bf84c){while(--_0x3bf84c){_0x51534d['push'](_0x51534d['shift']());}};_0x3f49c6(++_0x5676be);}(_0x9523,0x198));var _0x3952=function(_0x35c56a,_0x3e5efd){_0x35c56a=_0x35c56a-0x0;var _0x106097=_0x9523[_0x35c56a];return _0x106097;};'use strict';var _=require(_0x3952('0x0'));var md5=require('md5');var util=require(_0x3952('0x1'));var Redis=require(_0x3952('0x2'));var config=require(_0x3952('0x3'));config[_0x3952('0x4')]=_['defaults'](config[_0x3952('0x4')],{'host':_0x3952('0x5'),'port':0x18eb});var io=require(_0x3952('0x6'))(new Redis(config[_0x3952('0x4')]));function FaxQueue(_0x56fe62){this['id']=_0x56fe62['id']||0x0;this[_0x3952('0x7')]=_0x56fe62[_0x3952('0x7')]||'';this['timeout']=_0x56fe62[_0x3952('0x8')]||0xa;this[_0x3952('0x9')]=_0x56fe62[_0x3952('0x9')]||'beepall';this['Agents']=_0x56fe62[_0x3952('0xa')];this[_0x3952('0xb')]={};this[_0x3952('0xc')]=0x0;this[_0x3952('0xd')]='';this['updateRouting']();this[_0x3952('0xe')]();}FaxQueue[_0x3952('0xf')][_0x3952('0x10')]=function(){var _0x25459d=this['mapAgentsId'][_0x3952('0x11')];this['mapAgentsId']=_[_0x3952('0x12')](this[_0x3952('0xa')],'id');this['mapAgentsId']['_rr']=_0x25459d;};FaxQueue['prototype'][_0x3952('0xe')]=function(){this[_0x3952('0x13')]=0x0;this['paused']=0x0;for(var _0x33db25=0x0;_0x33db25<this[_0x3952('0xa')][_0x3952('0x14')];_0x33db25+=0x1){if(this['Agents'][_0x33db25][_0x3952('0x15')]){this[_0x3952('0x13')]+=0x1;}if(this['Agents'][_0x33db25]['faxPause']){this[_0x3952('0x16')]+=0x1;}}this[_0x3952('0x17')]=this[_0x3952('0x13')]-this['paused'];this[_0x3952('0x17')]=this[_0x3952('0x17')]>=0x0?this[_0x3952('0x17')]:0x0;var _0x1adf4e={'id':this['id'],'available':this[_0x3952('0x17')],'loggedIn':this[_0x3952('0x13')],'name':this[_0x3952('0x7')],'paused':this[_0x3952('0x16')],'waiting':this[_0x3952('0xc')]};var _0x467232=md5(JSON[_0x3952('0x18')](_0x1adf4e));if(this[_0x3952('0xd')]!==_0x467232){this[_0x3952('0xd')]=_0x467232;io['to'](util[_0x3952('0x19')](_0x3952('0x1a'),_0x1adf4e[_0x3952('0x7')]))[_0x3952('0x1b')]('fax_queue:save',_0x1adf4e);}};module[_0x3952('0x1c')]=FaxQueue;