fc925c44f1cf382ef09383da890a6a3c88054c6e
[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 _0xc6f9=['faxPause','paused','available','waiting','stringify','fax:queue:%s','fax_queue:save','exports','lodash','md5','util','ioredis','defaults','redis','localhost','name','timeout','strategy','beepall','Agents','mapAgentsId','updateRouting','updateRealtime','prototype','_rr','map','loggedIn','length','online'];(function(_0x8262e5,_0x272c5f){var _0x7ba3ef=function(_0x3b7fd1){while(--_0x3b7fd1){_0x8262e5['push'](_0x8262e5['shift']());}};_0x7ba3ef(++_0x272c5f);}(_0xc6f9,0x1bb));var _0x9c6f=function(_0x2641f9,_0x26715f){_0x2641f9=_0x2641f9-0x0;var _0x585741=_0xc6f9[_0x2641f9];return _0x585741;};'use strict';var _=require(_0x9c6f('0x0'));var md5=require(_0x9c6f('0x1'));var util=require(_0x9c6f('0x2'));var Redis=require(_0x9c6f('0x3'));var config=require('../../../config/environment');config['redis']=_[_0x9c6f('0x4')](config[_0x9c6f('0x5')],{'host':_0x9c6f('0x6'),'port':0x18eb});var io=require('socket.io-emitter')(new Redis(config[_0x9c6f('0x5')]));function FaxQueue(_0x323171){this['id']=_0x323171['id']||0x0;this[_0x9c6f('0x7')]=_0x323171[_0x9c6f('0x7')]||'';this[_0x9c6f('0x8')]=_0x323171[_0x9c6f('0x8')]||0xa;this[_0x9c6f('0x9')]=_0x323171[_0x9c6f('0x9')]||_0x9c6f('0xa');this[_0x9c6f('0xb')]=_0x323171['Agents'];this[_0x9c6f('0xc')]={};this['waiting']=0x0;this[_0x9c6f('0x1')]='';this[_0x9c6f('0xd')]();this[_0x9c6f('0xe')]();}FaxQueue[_0x9c6f('0xf')][_0x9c6f('0xd')]=function(){var _0x4c8028=this['mapAgentsId'][_0x9c6f('0x10')];this[_0x9c6f('0xc')]=_[_0x9c6f('0x11')](this['Agents'],'id');this['mapAgentsId']['_rr']=_0x4c8028;};FaxQueue[_0x9c6f('0xf')][_0x9c6f('0xe')]=function(){this[_0x9c6f('0x12')]=0x0;this['paused']=0x0;for(var _0x525527=0x0;_0x525527<this[_0x9c6f('0xb')][_0x9c6f('0x13')];_0x525527+=0x1){if(this['Agents'][_0x525527][_0x9c6f('0x14')]){this['loggedIn']+=0x1;}if(this[_0x9c6f('0xb')][_0x525527][_0x9c6f('0x15')]){this[_0x9c6f('0x16')]+=0x1;}}this[_0x9c6f('0x17')]=this[_0x9c6f('0x12')]-this[_0x9c6f('0x16')];this[_0x9c6f('0x17')]=this[_0x9c6f('0x17')]>=0x0?this[_0x9c6f('0x17')]:0x0;var _0x403f5e={'id':this['id'],'available':this[_0x9c6f('0x17')],'loggedIn':this['loggedIn'],'name':this[_0x9c6f('0x7')],'paused':this['paused'],'waiting':this[_0x9c6f('0x18')]};var _0xa4d2c9=md5(JSON[_0x9c6f('0x19')](_0x403f5e));if(this[_0x9c6f('0x1')]!==_0xa4d2c9){this[_0x9c6f('0x1')]=_0xa4d2c9;io['to'](util['format'](_0x9c6f('0x1a'),_0x403f5e[_0x9c6f('0x7')]))['emit'](_0x9c6f('0x1b'),_0x403f5e);}};module[_0x9c6f('0x1c')]=FaxQueue;