Built motion from commit 85328c08.|2.5.50
[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 _0xfa89=['md5','ioredis','../../../config/environment','redis','socket.io-emitter','name','timeout','strategy','Agents','mapAgentsId','waiting','updateRouting','updateRealtime','_rr','map','prototype','loggedIn','paused','length','online','faxPause','available','stringify','format','fax:queue:%s','fax_queue:save','exports'];(function(_0x221ba2,_0x79208){var _0x47d08e=function(_0xaf14ee){while(--_0xaf14ee){_0x221ba2['push'](_0x221ba2['shift']());}};_0x47d08e(++_0x79208);}(_0xfa89,0x1cb));var _0x9fa8=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0xfa89[_0x3dd15e];return _0x231fd0;};'use strict';var _=require('lodash');var md5=require(_0x9fa8('0x0'));var util=require('util');var Redis=require(_0x9fa8('0x1'));var config=require(_0x9fa8('0x2'));config[_0x9fa8('0x3')]=_['defaults'](config[_0x9fa8('0x3')],{'host':'localhost','port':0x18eb});var io=require(_0x9fa8('0x4'))(new Redis(config['redis']));function FaxQueue(_0x3b8d86){this['id']=_0x3b8d86['id']||0x0;this[_0x9fa8('0x5')]=_0x3b8d86[_0x9fa8('0x5')]||'';this[_0x9fa8('0x6')]=_0x3b8d86[_0x9fa8('0x6')]||0xa;this[_0x9fa8('0x7')]=_0x3b8d86[_0x9fa8('0x7')]||'beepall';this[_0x9fa8('0x8')]=_0x3b8d86[_0x9fa8('0x8')];this[_0x9fa8('0x9')]={};this[_0x9fa8('0xa')]=0x0;this[_0x9fa8('0x0')]='';this[_0x9fa8('0xb')]();this[_0x9fa8('0xc')]();}FaxQueue['prototype'][_0x9fa8('0xb')]=function(){var _0x5360c4=this['mapAgentsId'][_0x9fa8('0xd')];this[_0x9fa8('0x9')]=_[_0x9fa8('0xe')](this[_0x9fa8('0x8')],'id');this[_0x9fa8('0x9')]['_rr']=_0x5360c4;};FaxQueue[_0x9fa8('0xf')][_0x9fa8('0xc')]=function(){this[_0x9fa8('0x10')]=0x0;this[_0x9fa8('0x11')]=0x0;for(var _0x5e95a7=0x0;_0x5e95a7<this[_0x9fa8('0x8')][_0x9fa8('0x12')];_0x5e95a7+=0x1){if(this['Agents'][_0x5e95a7][_0x9fa8('0x13')]){this['loggedIn']+=0x1;}if(this[_0x9fa8('0x8')][_0x5e95a7][_0x9fa8('0x14')]){this[_0x9fa8('0x11')]+=0x1;}}this[_0x9fa8('0x15')]=this[_0x9fa8('0x10')]-this[_0x9fa8('0x11')];this[_0x9fa8('0x15')]=this[_0x9fa8('0x15')]>=0x0?this['available']:0x0;var _0x2f6457={'id':this['id'],'available':this[_0x9fa8('0x15')],'loggedIn':this[_0x9fa8('0x10')],'name':this['name'],'paused':this['paused'],'waiting':this[_0x9fa8('0xa')]};var _0x53844f=md5(JSON[_0x9fa8('0x16')](_0x2f6457));if(this[_0x9fa8('0x0')]!==_0x53844f){this['md5']=_0x53844f;io['to'](util[_0x9fa8('0x17')](_0x9fa8('0x18'),_0x2f6457[_0x9fa8('0x5')]))['emit'](_0x9fa8('0x19'),_0x2f6457);}};module[_0x9fa8('0x1a')]=FaxQueue;