9e51cf54d7c504de3cd5df3655b6e770dfb8c0d1
[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 _0xdf21=['strategy','beepall','Agents','mapAgentsId','waiting','updateRouting','updateRealtime','prototype','_rr','loggedIn','paused','faxPause','available','fax:queue:%s','emit','fax_queue:save','exports','lodash','md5','util','ioredis','../../../config/environment','defaults','redis','localhost','socket.io-emitter','name','timeout'];(function(_0x40be91,_0x563f1c){var _0x5ef92d=function(_0x78cad5){while(--_0x78cad5){_0x40be91['push'](_0x40be91['shift']());}};_0x5ef92d(++_0x563f1c);}(_0xdf21,0x1ed));var _0x1df2=function(_0x3c325c,_0x263dc4){_0x3c325c=_0x3c325c-0x0;var _0x1d7378=_0xdf21[_0x3c325c];return _0x1d7378;};'use strict';var _=require(_0x1df2('0x0'));var md5=require(_0x1df2('0x1'));var util=require(_0x1df2('0x2'));var Redis=require(_0x1df2('0x3'));var config=require(_0x1df2('0x4'));config['redis']=_[_0x1df2('0x5')](config[_0x1df2('0x6')],{'host':_0x1df2('0x7'),'port':0x18eb});var io=require(_0x1df2('0x8'))(new Redis(config['redis']));function FaxQueue(_0x20d83a){this['id']=_0x20d83a['id']||0x0;this[_0x1df2('0x9')]=_0x20d83a[_0x1df2('0x9')]||'';this[_0x1df2('0xa')]=_0x20d83a[_0x1df2('0xa')]||0xa;this[_0x1df2('0xb')]=_0x20d83a[_0x1df2('0xb')]||_0x1df2('0xc');this[_0x1df2('0xd')]=_0x20d83a[_0x1df2('0xd')];this[_0x1df2('0xe')]={};this[_0x1df2('0xf')]=0x0;this[_0x1df2('0x1')]='';this[_0x1df2('0x10')]();this[_0x1df2('0x11')]();}FaxQueue[_0x1df2('0x12')][_0x1df2('0x10')]=function(){var _0xb9d223=this[_0x1df2('0xe')][_0x1df2('0x13')];this[_0x1df2('0xe')]=_['map'](this['Agents'],'id');this[_0x1df2('0xe')]['_rr']=_0xb9d223;};FaxQueue[_0x1df2('0x12')][_0x1df2('0x11')]=function(){this[_0x1df2('0x14')]=0x0;this[_0x1df2('0x15')]=0x0;for(var _0x556cb7=0x0;_0x556cb7<this[_0x1df2('0xd')]['length'];_0x556cb7+=0x1){if(this[_0x1df2('0xd')][_0x556cb7]['online']){this[_0x1df2('0x14')]+=0x1;}if(this['Agents'][_0x556cb7][_0x1df2('0x16')]){this[_0x1df2('0x15')]+=0x1;}}this[_0x1df2('0x17')]=this['loggedIn']-this['paused'];this[_0x1df2('0x17')]=this['available']>=0x0?this[_0x1df2('0x17')]:0x0;var _0x2ce3ff={'id':this['id'],'available':this['available'],'loggedIn':this[_0x1df2('0x14')],'name':this[_0x1df2('0x9')],'paused':this[_0x1df2('0x15')],'waiting':this[_0x1df2('0xf')]};var _0x163448=md5(JSON['stringify'](_0x2ce3ff));if(this[_0x1df2('0x1')]!==_0x163448){this[_0x1df2('0x1')]=_0x163448;io['to'](util['format'](_0x1df2('0x18'),_0x2ce3ff[_0x1df2('0x9')]))[_0x1df2('0x19')](_0x1df2('0x1a'),_0x2ce3ff);}};module[_0x1df2('0x1b')]=FaxQueue;