Built motion from commit dc14b02d.|2.6.27
[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 _0xa640=['Agents','mapAgentsId','waiting','updateRealtime','prototype','updateRouting','_rr','map','loggedIn','length','faxPause','paused','available','stringify','format','fax:queue:%s','emit','exports','lodash','md5','util','ioredis','../../../config/environment','redis','localhost','name','timeout','strategy','beepall'];(function(_0x565c49,_0x54acd0){var _0x20ca34=function(_0x42f7e1){while(--_0x42f7e1){_0x565c49['push'](_0x565c49['shift']());}};_0x20ca34(++_0x54acd0);}(_0xa640,0x18b));var _0x0a64=function(_0x3d81fe,_0x2e89c1){_0x3d81fe=_0x3d81fe-0x0;var _0x3e5d8a=_0xa640[_0x3d81fe];return _0x3e5d8a;};'use strict';var _=require(_0x0a64('0x0'));var md5=require(_0x0a64('0x1'));var util=require(_0x0a64('0x2'));var Redis=require(_0x0a64('0x3'));var config=require(_0x0a64('0x4'));config[_0x0a64('0x5')]=_['defaults'](config[_0x0a64('0x5')],{'host':_0x0a64('0x6'),'port':0x18eb});var io=require('socket.io-emitter')(new Redis(config[_0x0a64('0x5')]));function FaxQueue(_0x3190a3){this['id']=_0x3190a3['id']||0x0;this[_0x0a64('0x7')]=_0x3190a3['name']||'';this['timeout']=_0x3190a3[_0x0a64('0x8')]||0xa;this[_0x0a64('0x9')]=_0x3190a3['strategy']||_0x0a64('0xa');this['Agents']=_0x3190a3[_0x0a64('0xb')];this[_0x0a64('0xc')]={};this[_0x0a64('0xd')]=0x0;this[_0x0a64('0x1')]='';this['updateRouting']();this[_0x0a64('0xe')]();}FaxQueue[_0x0a64('0xf')][_0x0a64('0x10')]=function(){var _0x308169=this['mapAgentsId'][_0x0a64('0x11')];this[_0x0a64('0xc')]=_[_0x0a64('0x12')](this[_0x0a64('0xb')],'id');this[_0x0a64('0xc')][_0x0a64('0x11')]=_0x308169;};FaxQueue[_0x0a64('0xf')][_0x0a64('0xe')]=function(){this[_0x0a64('0x13')]=0x0;this['paused']=0x0;for(var _0x4a2255=0x0;_0x4a2255<this[_0x0a64('0xb')][_0x0a64('0x14')];_0x4a2255+=0x1){if(this[_0x0a64('0xb')][_0x4a2255]['online']){this[_0x0a64('0x13')]+=0x1;}if(this[_0x0a64('0xb')][_0x4a2255][_0x0a64('0x15')]){this[_0x0a64('0x16')]+=0x1;}}this[_0x0a64('0x17')]=this[_0x0a64('0x13')]-this[_0x0a64('0x16')];this['available']=this[_0x0a64('0x17')]>=0x0?this[_0x0a64('0x17')]:0x0;var _0x40caf6={'id':this['id'],'available':this[_0x0a64('0x17')],'loggedIn':this[_0x0a64('0x13')],'name':this[_0x0a64('0x7')],'paused':this[_0x0a64('0x16')],'waiting':this[_0x0a64('0xd')]};var _0x2dd039=md5(JSON[_0x0a64('0x18')](_0x40caf6));if(this[_0x0a64('0x1')]!==_0x2dd039){this[_0x0a64('0x1')]=_0x2dd039;io['to'](util[_0x0a64('0x19')](_0x0a64('0x1a'),_0x40caf6['name']))[_0x0a64('0x1b')]('fax_queue:save',_0x40caf6);}};module[_0x0a64('0x1c')]=FaxQueue;