Built motion from commit 0c5f406c.|2.6.29
[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 _0x6e0e=['format','fax:queue:%s','fax_queue:save','util','ioredis','redis','socket.io-emitter','name','timeout','strategy','beepall','Agents','mapAgentsId','md5','updateRouting','prototype','map','_rr','updateRealtime','loggedIn','paused','length','online','faxPause','available','waiting','stringify'];(function(_0x3ab9ee,_0x4a74b8){var _0x82ee88=function(_0x6ccc7e){while(--_0x6ccc7e){_0x3ab9ee['push'](_0x3ab9ee['shift']());}};_0x82ee88(++_0x4a74b8);}(_0x6e0e,0x17d));var _0xe6e0=function(_0x20c3da,_0x2a3ccb){_0x20c3da=_0x20c3da-0x0;var _0x2f9931=_0x6e0e[_0x20c3da];return _0x2f9931;};'use strict';var _=require('lodash');var md5=require('md5');var util=require(_0xe6e0('0x0'));var Redis=require(_0xe6e0('0x1'));var config=require('../../../config/environment');config[_0xe6e0('0x2')]=_['defaults'](config[_0xe6e0('0x2')],{'host':'localhost','port':0x18eb});var io=require(_0xe6e0('0x3'))(new Redis(config[_0xe6e0('0x2')]));function FaxQueue(_0x34d941){this['id']=_0x34d941['id']||0x0;this['name']=_0x34d941[_0xe6e0('0x4')]||'';this[_0xe6e0('0x5')]=_0x34d941[_0xe6e0('0x5')]||0xa;this[_0xe6e0('0x6')]=_0x34d941[_0xe6e0('0x6')]||_0xe6e0('0x7');this[_0xe6e0('0x8')]=_0x34d941[_0xe6e0('0x8')];this[_0xe6e0('0x9')]={};this['waiting']=0x0;this[_0xe6e0('0xa')]='';this[_0xe6e0('0xb')]();this['updateRealtime']();}FaxQueue[_0xe6e0('0xc')][_0xe6e0('0xb')]=function(){var _0x1011c5=this[_0xe6e0('0x9')]['_rr'];this['mapAgentsId']=_[_0xe6e0('0xd')](this[_0xe6e0('0x8')],'id');this[_0xe6e0('0x9')][_0xe6e0('0xe')]=_0x1011c5;};FaxQueue[_0xe6e0('0xc')][_0xe6e0('0xf')]=function(){this[_0xe6e0('0x10')]=0x0;this[_0xe6e0('0x11')]=0x0;for(var _0x3ba52a=0x0;_0x3ba52a<this[_0xe6e0('0x8')][_0xe6e0('0x12')];_0x3ba52a+=0x1){if(this['Agents'][_0x3ba52a][_0xe6e0('0x13')]){this[_0xe6e0('0x10')]+=0x1;}if(this[_0xe6e0('0x8')][_0x3ba52a][_0xe6e0('0x14')]){this[_0xe6e0('0x11')]+=0x1;}}this['available']=this[_0xe6e0('0x10')]-this[_0xe6e0('0x11')];this[_0xe6e0('0x15')]=this[_0xe6e0('0x15')]>=0x0?this[_0xe6e0('0x15')]:0x0;var _0x5b344a={'id':this['id'],'available':this[_0xe6e0('0x15')],'loggedIn':this[_0xe6e0('0x10')],'name':this[_0xe6e0('0x4')],'paused':this[_0xe6e0('0x11')],'waiting':this[_0xe6e0('0x16')]};var _0xc29406=md5(JSON[_0xe6e0('0x17')](_0x5b344a));if(this[_0xe6e0('0xa')]!==_0xc29406){this[_0xe6e0('0xa')]=_0xc29406;io['to'](util[_0xe6e0('0x18')](_0xe6e0('0x19'),_0x5b344a['name']))['emit'](_0xe6e0('0x1a'),_0x5b344a);}};module['exports']=FaxQueue;