Built motion from commit b5413ace.|2.6.9
[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 _0x7648=['updateRouting','updateRealtime','prototype','_rr','map','loggedIn','paused','length','online','faxPause','available','format','emit','fax_queue:save','exports','md5','util','../../../config/environment','redis','defaults','localhost','name','timeout','strategy','beepall','Agents','mapAgentsId','waiting'];(function(_0x510ab3,_0x51e30f){var _0x552438=function(_0xcae78d){while(--_0xcae78d){_0x510ab3['push'](_0x510ab3['shift']());}};_0x552438(++_0x51e30f);}(_0x7648,0x1b3));var _0x8764=function(_0x21b2c6,_0x53814c){_0x21b2c6=_0x21b2c6-0x0;var _0x38bfcf=_0x7648[_0x21b2c6];return _0x38bfcf;};'use strict';var _=require('lodash');var md5=require(_0x8764('0x0'));var util=require(_0x8764('0x1'));var Redis=require('ioredis');var config=require(_0x8764('0x2'));config[_0x8764('0x3')]=_[_0x8764('0x4')](config[_0x8764('0x3')],{'host':_0x8764('0x5'),'port':0x18eb});var io=require('socket.io-emitter')(new Redis(config[_0x8764('0x3')]));function FaxQueue(_0x30ab3d){this['id']=_0x30ab3d['id']||0x0;this['name']=_0x30ab3d[_0x8764('0x6')]||'';this[_0x8764('0x7')]=_0x30ab3d[_0x8764('0x7')]||0xa;this[_0x8764('0x8')]=_0x30ab3d[_0x8764('0x8')]||_0x8764('0x9');this[_0x8764('0xa')]=_0x30ab3d['Agents'];this[_0x8764('0xb')]={};this[_0x8764('0xc')]=0x0;this[_0x8764('0x0')]='';this[_0x8764('0xd')]();this[_0x8764('0xe')]();}FaxQueue[_0x8764('0xf')][_0x8764('0xd')]=function(){var _0x551cae=this[_0x8764('0xb')][_0x8764('0x10')];this['mapAgentsId']=_[_0x8764('0x11')](this['Agents'],'id');this[_0x8764('0xb')]['_rr']=_0x551cae;};FaxQueue['prototype'][_0x8764('0xe')]=function(){this[_0x8764('0x12')]=0x0;this[_0x8764('0x13')]=0x0;for(var _0x330400=0x0;_0x330400<this[_0x8764('0xa')][_0x8764('0x14')];_0x330400+=0x1){if(this[_0x8764('0xa')][_0x330400][_0x8764('0x15')]){this[_0x8764('0x12')]+=0x1;}if(this[_0x8764('0xa')][_0x330400][_0x8764('0x16')]){this[_0x8764('0x13')]+=0x1;}}this[_0x8764('0x17')]=this[_0x8764('0x12')]-this['paused'];this['available']=this['available']>=0x0?this[_0x8764('0x17')]:0x0;var _0x3faa17={'id':this['id'],'available':this['available'],'loggedIn':this['loggedIn'],'name':this[_0x8764('0x6')],'paused':this[_0x8764('0x13')],'waiting':this[_0x8764('0xc')]};var _0x468dcd=md5(JSON['stringify'](_0x3faa17));if(this[_0x8764('0x0')]!==_0x468dcd){this['md5']=_0x468dcd;io['to'](util[_0x8764('0x18')]('fax:queue:%s',_0x3faa17['name']))[_0x8764('0x19')](_0x8764('0x1a'),_0x3faa17);}};module[_0x8764('0x1b')]=FaxQueue;