Built motion from commit 97153652.|2.6.26
[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 _0xd253=['lodash','md5','util','ioredis','redis','defaults','localhost','socket.io-emitter','name','timeout','strategy','beepall','Agents','mapAgentsId','waiting','updateRealtime','prototype','_rr','loggedIn','paused','online','faxPause','available','stringify','fax:queue:%s','emit','fax_queue:save','exports'];(function(_0x4a7631,_0x2c85b9){var _0x1a5a6f=function(_0x1ee3fd){while(--_0x1ee3fd){_0x4a7631['push'](_0x4a7631['shift']());}};_0x1a5a6f(++_0x2c85b9);}(_0xd253,0xe0));var _0x3d25=function(_0x134c2e,_0x3573c4){_0x134c2e=_0x134c2e-0x0;var _0x2825db=_0xd253[_0x134c2e];return _0x2825db;};'use strict';var _=require(_0x3d25('0x0'));var md5=require(_0x3d25('0x1'));var util=require(_0x3d25('0x2'));var Redis=require(_0x3d25('0x3'));var config=require('../../../config/environment');config[_0x3d25('0x4')]=_[_0x3d25('0x5')](config[_0x3d25('0x4')],{'host':_0x3d25('0x6'),'port':0x18eb});var io=require(_0x3d25('0x7'))(new Redis(config[_0x3d25('0x4')]));function FaxQueue(_0x151d4e){this['id']=_0x151d4e['id']||0x0;this[_0x3d25('0x8')]=_0x151d4e['name']||'';this['timeout']=_0x151d4e[_0x3d25('0x9')]||0xa;this[_0x3d25('0xa')]=_0x151d4e[_0x3d25('0xa')]||_0x3d25('0xb');this[_0x3d25('0xc')]=_0x151d4e[_0x3d25('0xc')];this[_0x3d25('0xd')]={};this[_0x3d25('0xe')]=0x0;this[_0x3d25('0x1')]='';this['updateRouting']();this[_0x3d25('0xf')]();}FaxQueue[_0x3d25('0x10')]['updateRouting']=function(){var _0x35d3a0=this[_0x3d25('0xd')][_0x3d25('0x11')];this[_0x3d25('0xd')]=_['map'](this['Agents'],'id');this[_0x3d25('0xd')]['_rr']=_0x35d3a0;};FaxQueue['prototype'][_0x3d25('0xf')]=function(){this[_0x3d25('0x12')]=0x0;this[_0x3d25('0x13')]=0x0;for(var _0x152368=0x0;_0x152368<this['Agents']['length'];_0x152368+=0x1){if(this[_0x3d25('0xc')][_0x152368][_0x3d25('0x14')]){this[_0x3d25('0x12')]+=0x1;}if(this[_0x3d25('0xc')][_0x152368][_0x3d25('0x15')]){this[_0x3d25('0x13')]+=0x1;}}this[_0x3d25('0x16')]=this[_0x3d25('0x12')]-this['paused'];this[_0x3d25('0x16')]=this[_0x3d25('0x16')]>=0x0?this[_0x3d25('0x16')]:0x0;var _0x3b83b1={'id':this['id'],'available':this[_0x3d25('0x16')],'loggedIn':this[_0x3d25('0x12')],'name':this[_0x3d25('0x8')],'paused':this[_0x3d25('0x13')],'waiting':this['waiting']};var _0x573743=md5(JSON[_0x3d25('0x17')](_0x3b83b1));if(this[_0x3d25('0x1')]!==_0x573743){this[_0x3d25('0x1')]=_0x573743;io['to'](util['format'](_0x3d25('0x18'),_0x3b83b1['name']))[_0x3d25('0x19')](_0x3d25('0x1a'),_0x3b83b1);}};module[_0x3d25('0x1b')]=FaxQueue;