952aee8215430e21d6a5cd34c75d15c8ebacd8da
[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 _0xc0c8=['redis','localhost','socket.io-emitter','name','timeout','strategy','beepall','Agents','mapAgentsId','updateRouting','updateRealtime','_rr','map','prototype','loggedIn','length','available','paused','waiting','stringify','fax:queue:%s','emit','fax_queue:save','exports','md5','util','ioredis'];(function(_0x22900f,_0x10409b){var _0x5ab1c1=function(_0x2a16b2){while(--_0x2a16b2){_0x22900f['push'](_0x22900f['shift']());}};_0x5ab1c1(++_0x10409b);}(_0xc0c8,0x1ad));var _0x8c0c=function(_0x28c65d,_0x351ca4){_0x28c65d=_0x28c65d-0x0;var _0x3cea35=_0xc0c8[_0x28c65d];return _0x3cea35;};'use strict';var _=require('lodash');var md5=require(_0x8c0c('0x0'));var util=require(_0x8c0c('0x1'));var Redis=require(_0x8c0c('0x2'));var config=require('../../../config/environment');config['redis']=_['defaults'](config[_0x8c0c('0x3')],{'host':_0x8c0c('0x4'),'port':0x18eb});var io=require(_0x8c0c('0x5'))(new Redis(config[_0x8c0c('0x3')]));function FaxQueue(_0x38ae13){this['id']=_0x38ae13['id']||0x0;this[_0x8c0c('0x6')]=_0x38ae13['name']||'';this[_0x8c0c('0x7')]=_0x38ae13[_0x8c0c('0x7')]||0xa;this['strategy']=_0x38ae13[_0x8c0c('0x8')]||_0x8c0c('0x9');this[_0x8c0c('0xa')]=_0x38ae13[_0x8c0c('0xa')];this[_0x8c0c('0xb')]={};this['waiting']=0x0;this[_0x8c0c('0x0')]='';this[_0x8c0c('0xc')]();this[_0x8c0c('0xd')]();}FaxQueue['prototype'][_0x8c0c('0xc')]=function(){var _0x5cb2e4=this[_0x8c0c('0xb')][_0x8c0c('0xe')];this[_0x8c0c('0xb')]=_[_0x8c0c('0xf')](this['Agents'],'id');this[_0x8c0c('0xb')][_0x8c0c('0xe')]=_0x5cb2e4;};FaxQueue[_0x8c0c('0x10')][_0x8c0c('0xd')]=function(){this[_0x8c0c('0x11')]=0x0;this['paused']=0x0;for(var _0x63d3a6=0x0;_0x63d3a6<this['Agents'][_0x8c0c('0x12')];_0x63d3a6+=0x1){if(this['Agents'][_0x63d3a6]['online']){this[_0x8c0c('0x11')]+=0x1;}if(this['Agents'][_0x63d3a6]['faxPause']){this['paused']+=0x1;}}this[_0x8c0c('0x13')]=this[_0x8c0c('0x11')]-this[_0x8c0c('0x14')];this[_0x8c0c('0x13')]=this[_0x8c0c('0x13')]>=0x0?this[_0x8c0c('0x13')]:0x0;var _0x182f82={'id':this['id'],'available':this['available'],'loggedIn':this[_0x8c0c('0x11')],'name':this['name'],'paused':this[_0x8c0c('0x14')],'waiting':this[_0x8c0c('0x15')]};var _0x2b0834=md5(JSON[_0x8c0c('0x16')](_0x182f82));if(this['md5']!==_0x2b0834){this[_0x8c0c('0x0')]=_0x2b0834;io['to'](util['format'](_0x8c0c('0x17'),_0x182f82[_0x8c0c('0x6')]))[_0x8c0c('0x18')](_0x8c0c('0x19'),_0x182f82);}};module[_0x8c0c('0x1a')]=FaxQueue;