d38262de09f2ce76d5f7a71853fbfa4152c2f3c4
[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 _0xcbb2=['localhost','name','timeout','strategy','Agents','mapAgentsId','waiting','updateRouting','_rr','map','updateRealtime','loggedIn','paused','length','faxPause','available','stringify','format','emit','fax_queue:save','exports','lodash','md5','util','ioredis','../../../config/environment','redis'];(function(_0x195577,_0x5de53a){var _0x13c367=function(_0x583022){while(--_0x583022){_0x195577['push'](_0x195577['shift']());}};_0x13c367(++_0x5de53a);}(_0xcbb2,0x18f));var _0x2cbb=function(_0x270e55,_0x406969){_0x270e55=_0x270e55-0x0;var _0x5b503a=_0xcbb2[_0x270e55];return _0x5b503a;};'use strict';var _=require(_0x2cbb('0x0'));var md5=require(_0x2cbb('0x1'));var util=require(_0x2cbb('0x2'));var Redis=require(_0x2cbb('0x3'));var config=require(_0x2cbb('0x4'));config[_0x2cbb('0x5')]=_['defaults'](config['redis'],{'host':_0x2cbb('0x6'),'port':0x18eb});var io=require('socket.io-emitter')(new Redis(config[_0x2cbb('0x5')]));function FaxQueue(_0x4ba912){this['id']=_0x4ba912['id']||0x0;this[_0x2cbb('0x7')]=_0x4ba912[_0x2cbb('0x7')]||'';this[_0x2cbb('0x8')]=_0x4ba912[_0x2cbb('0x8')]||0xa;this[_0x2cbb('0x9')]=_0x4ba912[_0x2cbb('0x9')]||'beepall';this['Agents']=_0x4ba912[_0x2cbb('0xa')];this[_0x2cbb('0xb')]={};this[_0x2cbb('0xc')]=0x0;this[_0x2cbb('0x1')]='';this[_0x2cbb('0xd')]();this['updateRealtime']();}FaxQueue['prototype'][_0x2cbb('0xd')]=function(){var _0x51879f=this['mapAgentsId'][_0x2cbb('0xe')];this[_0x2cbb('0xb')]=_[_0x2cbb('0xf')](this[_0x2cbb('0xa')],'id');this['mapAgentsId']['_rr']=_0x51879f;};FaxQueue['prototype'][_0x2cbb('0x10')]=function(){this[_0x2cbb('0x11')]=0x0;this[_0x2cbb('0x12')]=0x0;for(var _0x38fa0d=0x0;_0x38fa0d<this[_0x2cbb('0xa')][_0x2cbb('0x13')];_0x38fa0d+=0x1){if(this['Agents'][_0x38fa0d]['online']){this[_0x2cbb('0x11')]+=0x1;}if(this[_0x2cbb('0xa')][_0x38fa0d][_0x2cbb('0x14')]){this[_0x2cbb('0x12')]+=0x1;}}this[_0x2cbb('0x15')]=this[_0x2cbb('0x11')]-this[_0x2cbb('0x12')];this[_0x2cbb('0x15')]=this['available']>=0x0?this[_0x2cbb('0x15')]:0x0;var _0x230a3c={'id':this['id'],'available':this[_0x2cbb('0x15')],'loggedIn':this[_0x2cbb('0x11')],'name':this['name'],'paused':this[_0x2cbb('0x12')],'waiting':this['waiting']};var _0x24524d=md5(JSON[_0x2cbb('0x16')](_0x230a3c));if(this['md5']!==_0x24524d){this[_0x2cbb('0x1')]=_0x24524d;io['to'](util[_0x2cbb('0x17')]('fax:queue:%s',_0x230a3c['name']))[_0x2cbb('0x18')](_0x2cbb('0x19'),_0x230a3c);}};module[_0x2cbb('0x1a')]=FaxQueue;