Built motion from commit ddca4d0d.|2.5.47
[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 _0x9e81=['loggedIn','faxPause','available','waiting','stringify','format','fax:queue:%s','emit','fax_queue:save','exports','lodash','md5','util','../../../config/environment','redis','socket.io-emitter','name','timeout','strategy','beepall','Agents','updateRealtime','prototype','updateRouting','mapAgentsId','map','_rr','paused','length'];(function(_0x187842,_0x58331c){var _0x5dbcf3=function(_0x55faef){while(--_0x55faef){_0x187842['push'](_0x187842['shift']());}};_0x5dbcf3(++_0x58331c);}(_0x9e81,0x12c));var _0x19e8=function(_0x5027b1,_0x1409a5){_0x5027b1=_0x5027b1-0x0;var _0x4a46cf=_0x9e81[_0x5027b1];return _0x4a46cf;};'use strict';var _=require(_0x19e8('0x0'));var md5=require(_0x19e8('0x1'));var util=require(_0x19e8('0x2'));var Redis=require('ioredis');var config=require(_0x19e8('0x3'));config[_0x19e8('0x4')]=_['defaults'](config[_0x19e8('0x4')],{'host':'localhost','port':0x18eb});var io=require(_0x19e8('0x5'))(new Redis(config[_0x19e8('0x4')]));function FaxQueue(_0x58a947){this['id']=_0x58a947['id']||0x0;this['name']=_0x58a947[_0x19e8('0x6')]||'';this['timeout']=_0x58a947[_0x19e8('0x7')]||0xa;this[_0x19e8('0x8')]=_0x58a947[_0x19e8('0x8')]||_0x19e8('0x9');this['Agents']=_0x58a947[_0x19e8('0xa')];this['mapAgentsId']={};this['waiting']=0x0;this[_0x19e8('0x1')]='';this['updateRouting']();this[_0x19e8('0xb')]();}FaxQueue[_0x19e8('0xc')][_0x19e8('0xd')]=function(){var _0x5512f1=this['mapAgentsId']['_rr'];this[_0x19e8('0xe')]=_[_0x19e8('0xf')](this[_0x19e8('0xa')],'id');this[_0x19e8('0xe')][_0x19e8('0x10')]=_0x5512f1;};FaxQueue[_0x19e8('0xc')][_0x19e8('0xb')]=function(){this['loggedIn']=0x0;this[_0x19e8('0x11')]=0x0;for(var _0x522cc=0x0;_0x522cc<this[_0x19e8('0xa')][_0x19e8('0x12')];_0x522cc+=0x1){if(this['Agents'][_0x522cc]['online']){this[_0x19e8('0x13')]+=0x1;}if(this[_0x19e8('0xa')][_0x522cc][_0x19e8('0x14')]){this[_0x19e8('0x11')]+=0x1;}}this[_0x19e8('0x15')]=this[_0x19e8('0x13')]-this[_0x19e8('0x11')];this[_0x19e8('0x15')]=this[_0x19e8('0x15')]>=0x0?this[_0x19e8('0x15')]:0x0;var _0x250d61={'id':this['id'],'available':this[_0x19e8('0x15')],'loggedIn':this[_0x19e8('0x13')],'name':this[_0x19e8('0x6')],'paused':this[_0x19e8('0x11')],'waiting':this[_0x19e8('0x16')]};var _0x3333e0=md5(JSON[_0x19e8('0x17')](_0x250d61));if(this['md5']!==_0x3333e0){this['md5']=_0x3333e0;io['to'](util[_0x19e8('0x18')](_0x19e8('0x19'),_0x250d61[_0x19e8('0x6')]))[_0x19e8('0x1a')](_0x19e8('0x1b'),_0x250d61);}};module[_0x19e8('0x1c')]=FaxQueue;