d410eb93109b110c7bdffc8fc0e4174ce44cc3ee
[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 _0x9fc8=['loggedIn','length','faxPause','available','paused','stringify','format','fax:queue:%s','fax_queue:save','exports','lodash','md5','util','../../../config/environment','redis','defaults','localhost','name','timeout','strategy','beepall','Agents','waiting','updateRouting','updateRealtime','prototype','mapAgentsId','map','_rr'];(function(_0x19e35c,_0x29cd1e){var _0x3e1fe8=function(_0x17258b){while(--_0x17258b){_0x19e35c['push'](_0x19e35c['shift']());}};_0x3e1fe8(++_0x29cd1e);}(_0x9fc8,0x166));var _0x89fc=function(_0x49f80f,_0x3b4b70){_0x49f80f=_0x49f80f-0x0;var _0x12bc8b=_0x9fc8[_0x49f80f];return _0x12bc8b;};'use strict';var _=require(_0x89fc('0x0'));var md5=require(_0x89fc('0x1'));var util=require(_0x89fc('0x2'));var Redis=require('ioredis');var config=require(_0x89fc('0x3'));config[_0x89fc('0x4')]=_[_0x89fc('0x5')](config[_0x89fc('0x4')],{'host':_0x89fc('0x6'),'port':0x18eb});var io=require('socket.io-emitter')(new Redis(config[_0x89fc('0x4')]));function FaxQueue(_0x55846f){this['id']=_0x55846f['id']||0x0;this[_0x89fc('0x7')]=_0x55846f[_0x89fc('0x7')]||'';this[_0x89fc('0x8')]=_0x55846f[_0x89fc('0x8')]||0xa;this[_0x89fc('0x9')]=_0x55846f['strategy']||_0x89fc('0xa');this[_0x89fc('0xb')]=_0x55846f[_0x89fc('0xb')];this['mapAgentsId']={};this[_0x89fc('0xc')]=0x0;this[_0x89fc('0x1')]='';this[_0x89fc('0xd')]();this[_0x89fc('0xe')]();}FaxQueue[_0x89fc('0xf')][_0x89fc('0xd')]=function(){var _0x642e3c=this['mapAgentsId']['_rr'];this[_0x89fc('0x10')]=_[_0x89fc('0x11')](this['Agents'],'id');this[_0x89fc('0x10')][_0x89fc('0x12')]=_0x642e3c;};FaxQueue[_0x89fc('0xf')][_0x89fc('0xe')]=function(){this[_0x89fc('0x13')]=0x0;this['paused']=0x0;for(var _0x420492=0x0;_0x420492<this['Agents'][_0x89fc('0x14')];_0x420492+=0x1){if(this[_0x89fc('0xb')][_0x420492]['online']){this['loggedIn']+=0x1;}if(this[_0x89fc('0xb')][_0x420492][_0x89fc('0x15')]){this['paused']+=0x1;}}this[_0x89fc('0x16')]=this[_0x89fc('0x13')]-this[_0x89fc('0x17')];this[_0x89fc('0x16')]=this[_0x89fc('0x16')]>=0x0?this[_0x89fc('0x16')]:0x0;var _0x175847={'id':this['id'],'available':this['available'],'loggedIn':this[_0x89fc('0x13')],'name':this[_0x89fc('0x7')],'paused':this[_0x89fc('0x17')],'waiting':this[_0x89fc('0xc')]};var _0x3aa060=md5(JSON[_0x89fc('0x18')](_0x175847));if(this['md5']!==_0x3aa060){this[_0x89fc('0x1')]=_0x3aa060;io['to'](util[_0x89fc('0x19')](_0x89fc('0x1a'),_0x175847[_0x89fc('0x7')]))['emit'](_0x89fc('0x1b'),_0x175847);}};module[_0x89fc('0x1c')]=FaxQueue;