0fceae0b75a82783eebf3a8aec3c1c1db976f80e
[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 _0xfcf4=['socket.io-emitter','name','timeout','strategy','Agents','md5','updateRouting','updateRealtime','prototype','_rr','mapAgentsId','map','loggedIn','paused','length','online','available','stringify','format','emit','exports','lodash','util','ioredis','defaults','redis','localhost'];(function(_0x402b1f,_0x3df329){var _0x5d22f2=function(_0x5f17c3){while(--_0x5f17c3){_0x402b1f['push'](_0x402b1f['shift']());}};_0x5d22f2(++_0x3df329);}(_0xfcf4,0x174));var _0x4fcf=function(_0x4f7637,_0x398970){_0x4f7637=_0x4f7637-0x0;var _0x88e50c=_0xfcf4[_0x4f7637];return _0x88e50c;};'use strict';var _=require(_0x4fcf('0x0'));var md5=require('md5');var util=require(_0x4fcf('0x1'));var Redis=require(_0x4fcf('0x2'));var config=require('../../../config/environment');config['redis']=_[_0x4fcf('0x3')](config[_0x4fcf('0x4')],{'host':_0x4fcf('0x5'),'port':0x18eb});var io=require(_0x4fcf('0x6'))(new Redis(config['redis']));function FaxQueue(_0x799675){this['id']=_0x799675['id']||0x0;this[_0x4fcf('0x7')]=_0x799675[_0x4fcf('0x7')]||'';this[_0x4fcf('0x8')]=_0x799675['timeout']||0xa;this[_0x4fcf('0x9')]=_0x799675[_0x4fcf('0x9')]||'beepall';this['Agents']=_0x799675[_0x4fcf('0xa')];this['mapAgentsId']={};this['waiting']=0x0;this[_0x4fcf('0xb')]='';this[_0x4fcf('0xc')]();this[_0x4fcf('0xd')]();}FaxQueue[_0x4fcf('0xe')][_0x4fcf('0xc')]=function(){var _0x20fba1=this['mapAgentsId'][_0x4fcf('0xf')];this[_0x4fcf('0x10')]=_[_0x4fcf('0x11')](this['Agents'],'id');this[_0x4fcf('0x10')][_0x4fcf('0xf')]=_0x20fba1;};FaxQueue[_0x4fcf('0xe')][_0x4fcf('0xd')]=function(){this[_0x4fcf('0x12')]=0x0;this[_0x4fcf('0x13')]=0x0;for(var _0x3d7083=0x0;_0x3d7083<this['Agents'][_0x4fcf('0x14')];_0x3d7083+=0x1){if(this[_0x4fcf('0xa')][_0x3d7083][_0x4fcf('0x15')]){this[_0x4fcf('0x12')]+=0x1;}if(this[_0x4fcf('0xa')][_0x3d7083]['faxPause']){this[_0x4fcf('0x13')]+=0x1;}}this['available']=this['loggedIn']-this['paused'];this[_0x4fcf('0x16')]=this[_0x4fcf('0x16')]>=0x0?this[_0x4fcf('0x16')]:0x0;var _0x4d7d48={'id':this['id'],'available':this[_0x4fcf('0x16')],'loggedIn':this[_0x4fcf('0x12')],'name':this['name'],'paused':this[_0x4fcf('0x13')],'waiting':this['waiting']};var _0x1f6d88=md5(JSON[_0x4fcf('0x17')](_0x4d7d48));if(this['md5']!==_0x1f6d88){this[_0x4fcf('0xb')]=_0x1f6d88;io['to'](util[_0x4fcf('0x18')]('fax:queue:%s',_0x4d7d48['name']))[_0x4fcf('0x19')]('fax_queue:save',_0x4d7d48);}};module[_0x4fcf('0x1a')]=FaxQueue;