5d5eb520b96b837931af5be734eeebcc746c6cea
[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 _0x7abe=['fax:queue:%s','exports','lodash','util','../../../config/environment','redis','defaults','localhost','socket.io-emitter','name','timeout','beepall','Agents','mapAgentsId','waiting','md5','updateRouting','_rr','map','prototype','updateRealtime','loggedIn','paused','length','available','stringify','format'];(function(_0x4cf628,_0x56c30f){var _0x44d7f3=function(_0x194ee9){while(--_0x194ee9){_0x4cf628['push'](_0x4cf628['shift']());}};_0x44d7f3(++_0x56c30f);}(_0x7abe,0x161));var _0xe7ab=function(_0x3f6527,_0x4b541a){_0x3f6527=_0x3f6527-0x0;var _0x129de2=_0x7abe[_0x3f6527];return _0x129de2;};'use strict';var _=require(_0xe7ab('0x0'));var md5=require('md5');var util=require(_0xe7ab('0x1'));var Redis=require('ioredis');var config=require(_0xe7ab('0x2'));config[_0xe7ab('0x3')]=_[_0xe7ab('0x4')](config['redis'],{'host':_0xe7ab('0x5'),'port':0x18eb});var io=require(_0xe7ab('0x6'))(new Redis(config[_0xe7ab('0x3')]));function FaxQueue(_0x3800b7){this['id']=_0x3800b7['id']||0x0;this[_0xe7ab('0x7')]=_0x3800b7[_0xe7ab('0x7')]||'';this[_0xe7ab('0x8')]=_0x3800b7['timeout']||0xa;this['strategy']=_0x3800b7['strategy']||_0xe7ab('0x9');this[_0xe7ab('0xa')]=_0x3800b7[_0xe7ab('0xa')];this[_0xe7ab('0xb')]={};this[_0xe7ab('0xc')]=0x0;this[_0xe7ab('0xd')]='';this[_0xe7ab('0xe')]();this['updateRealtime']();}FaxQueue['prototype'][_0xe7ab('0xe')]=function(){var _0x5f4c5d=this['mapAgentsId'][_0xe7ab('0xf')];this[_0xe7ab('0xb')]=_[_0xe7ab('0x10')](this['Agents'],'id');this[_0xe7ab('0xb')][_0xe7ab('0xf')]=_0x5f4c5d;};FaxQueue[_0xe7ab('0x11')][_0xe7ab('0x12')]=function(){this[_0xe7ab('0x13')]=0x0;this[_0xe7ab('0x14')]=0x0;for(var _0xa3514a=0x0;_0xa3514a<this[_0xe7ab('0xa')][_0xe7ab('0x15')];_0xa3514a+=0x1){if(this[_0xe7ab('0xa')][_0xa3514a]['online']){this['loggedIn']+=0x1;}if(this[_0xe7ab('0xa')][_0xa3514a]['faxPause']){this[_0xe7ab('0x14')]+=0x1;}}this['available']=this[_0xe7ab('0x13')]-this['paused'];this['available']=this[_0xe7ab('0x16')]>=0x0?this[_0xe7ab('0x16')]:0x0;var _0xa0c33d={'id':this['id'],'available':this[_0xe7ab('0x16')],'loggedIn':this[_0xe7ab('0x13')],'name':this[_0xe7ab('0x7')],'paused':this[_0xe7ab('0x14')],'waiting':this[_0xe7ab('0xc')]};var _0x406a46=md5(JSON[_0xe7ab('0x17')](_0xa0c33d));if(this[_0xe7ab('0xd')]!==_0x406a46){this[_0xe7ab('0xd')]=_0x406a46;io['to'](util[_0xe7ab('0x18')](_0xe7ab('0x19'),_0xa0c33d[_0xe7ab('0x7')]))['emit']('fax_queue:save',_0xa0c33d);}};module[_0xe7ab('0x1a')]=FaxQueue;