Built motion from commit 5b761a7b.|2.5.36
[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 _0x2590=['paused','length','available','stringify','fax:queue:%s','emit','lodash','md5','util','ioredis','../../../config/environment','redis','localhost','name','timeout','strategy','beepall','Agents','mapAgentsId','waiting','updateRealtime','updateRouting','map','_rr','prototype','loggedIn'];(function(_0x4f915f,_0x5efd6f){var _0x2b0650=function(_0x2acb61){while(--_0x2acb61){_0x4f915f['push'](_0x4f915f['shift']());}};_0x2b0650(++_0x5efd6f);}(_0x2590,0xf0));var _0x0259=function(_0x21d711,_0x13d773){_0x21d711=_0x21d711-0x0;var _0x27ee98=_0x2590[_0x21d711];return _0x27ee98;};'use strict';var _=require(_0x0259('0x0'));var md5=require(_0x0259('0x1'));var util=require(_0x0259('0x2'));var Redis=require(_0x0259('0x3'));var config=require(_0x0259('0x4'));config[_0x0259('0x5')]=_['defaults'](config['redis'],{'host':_0x0259('0x6'),'port':0x18eb});var io=require('socket.io-emitter')(new Redis(config[_0x0259('0x5')]));function FaxQueue(_0x4121ee){this['id']=_0x4121ee['id']||0x0;this[_0x0259('0x7')]=_0x4121ee[_0x0259('0x7')]||'';this[_0x0259('0x8')]=_0x4121ee[_0x0259('0x8')]||0xa;this[_0x0259('0x9')]=_0x4121ee[_0x0259('0x9')]||_0x0259('0xa');this[_0x0259('0xb')]=_0x4121ee[_0x0259('0xb')];this[_0x0259('0xc')]={};this[_0x0259('0xd')]=0x0;this[_0x0259('0x1')]='';this['updateRouting']();this[_0x0259('0xe')]();}FaxQueue['prototype'][_0x0259('0xf')]=function(){var _0x580315=this[_0x0259('0xc')]['_rr'];this[_0x0259('0xc')]=_[_0x0259('0x10')](this[_0x0259('0xb')],'id');this['mapAgentsId'][_0x0259('0x11')]=_0x580315;};FaxQueue[_0x0259('0x12')][_0x0259('0xe')]=function(){this[_0x0259('0x13')]=0x0;this[_0x0259('0x14')]=0x0;for(var _0x22a590=0x0;_0x22a590<this['Agents'][_0x0259('0x15')];_0x22a590+=0x1){if(this[_0x0259('0xb')][_0x22a590]['online']){this[_0x0259('0x13')]+=0x1;}if(this[_0x0259('0xb')][_0x22a590]['faxPause']){this[_0x0259('0x14')]+=0x1;}}this['available']=this[_0x0259('0x13')]-this['paused'];this[_0x0259('0x16')]=this['available']>=0x0?this[_0x0259('0x16')]:0x0;var _0x185e6e={'id':this['id'],'available':this[_0x0259('0x16')],'loggedIn':this[_0x0259('0x13')],'name':this['name'],'paused':this[_0x0259('0x14')],'waiting':this[_0x0259('0xd')]};var _0x52cfd5=md5(JSON[_0x0259('0x17')](_0x185e6e));if(this[_0x0259('0x1')]!==_0x52cfd5){this['md5']=_0x52cfd5;io['to'](util['format'](_0x0259('0x18'),_0x185e6e[_0x0259('0x7')]))[_0x0259('0x19')]('fax_queue:save',_0x185e6e);}};module['exports']=FaxQueue;