7de21f7a917f597a059f7a4a892ddaaee8d0821e
[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 _0xb456=['waiting','stringify','emit','fax_queue:save','lodash','md5','../../../config/environment','redis','defaults','localhost','socket.io-emitter','name','timeout','strategy','beepall','Agents','updateRouting','updateRealtime','prototype','mapAgentsId','_rr','map','paused','online','loggedIn','faxPause','available'];(function(_0x40afc2,_0x5c5b2e){var _0xceb52b=function(_0x50dfda){while(--_0x50dfda){_0x40afc2['push'](_0x40afc2['shift']());}};_0xceb52b(++_0x5c5b2e);}(_0xb456,0x8b));var _0x6b45=function(_0x1612ed,_0x47c521){_0x1612ed=_0x1612ed-0x0;var _0x5ecb12=_0xb456[_0x1612ed];return _0x5ecb12;};'use strict';var _=require(_0x6b45('0x0'));var md5=require(_0x6b45('0x1'));var util=require('util');var Redis=require('ioredis');var config=require(_0x6b45('0x2'));config[_0x6b45('0x3')]=_[_0x6b45('0x4')](config[_0x6b45('0x3')],{'host':_0x6b45('0x5'),'port':0x18eb});var io=require(_0x6b45('0x6'))(new Redis(config[_0x6b45('0x3')]));function FaxQueue(_0x39e4c7){this['id']=_0x39e4c7['id']||0x0;this['name']=_0x39e4c7[_0x6b45('0x7')]||'';this[_0x6b45('0x8')]=_0x39e4c7[_0x6b45('0x8')]||0xa;this[_0x6b45('0x9')]=_0x39e4c7[_0x6b45('0x9')]||_0x6b45('0xa');this[_0x6b45('0xb')]=_0x39e4c7[_0x6b45('0xb')];this['mapAgentsId']={};this['waiting']=0x0;this[_0x6b45('0x1')]='';this[_0x6b45('0xc')]();this[_0x6b45('0xd')]();}FaxQueue[_0x6b45('0xe')][_0x6b45('0xc')]=function(){var _0x323573=this[_0x6b45('0xf')][_0x6b45('0x10')];this['mapAgentsId']=_[_0x6b45('0x11')](this['Agents'],'id');this[_0x6b45('0xf')][_0x6b45('0x10')]=_0x323573;};FaxQueue[_0x6b45('0xe')][_0x6b45('0xd')]=function(){this['loggedIn']=0x0;this[_0x6b45('0x12')]=0x0;for(var _0x40951f=0x0;_0x40951f<this[_0x6b45('0xb')]['length'];_0x40951f+=0x1){if(this[_0x6b45('0xb')][_0x40951f][_0x6b45('0x13')]){this[_0x6b45('0x14')]+=0x1;}if(this[_0x6b45('0xb')][_0x40951f][_0x6b45('0x15')]){this[_0x6b45('0x12')]+=0x1;}}this[_0x6b45('0x16')]=this[_0x6b45('0x14')]-this['paused'];this['available']=this[_0x6b45('0x16')]>=0x0?this[_0x6b45('0x16')]:0x0;var _0x43a9d3={'id':this['id'],'available':this[_0x6b45('0x16')],'loggedIn':this[_0x6b45('0x14')],'name':this[_0x6b45('0x7')],'paused':this['paused'],'waiting':this[_0x6b45('0x17')]};var _0x195f64=md5(JSON[_0x6b45('0x18')](_0x43a9d3));if(this['md5']!==_0x195f64){this[_0x6b45('0x1')]=_0x195f64;io['to'](util['format']('fax:queue:%s',_0x43a9d3[_0x6b45('0x7')]))[_0x6b45('0x19')](_0x6b45('0x1a'),_0x43a9d3);}};module['exports']=FaxQueue;