14370c31ae7b300a512c4491e3f4035c17b31f6e
[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 _0x2e76=['util','../../../config/environment','redis','defaults','socket.io-emitter','name','timeout','strategy','beepall','Agents','mapAgentsId','waiting','updateRouting','updateRealtime','prototype','_rr','map','loggedIn','paused','length','online','faxPause','available','stringify','format','fax:queue:%s','emit','fax_queue:save','exports','lodash','md5'];(function(_0x34ad71,_0x4db412){var _0x4d67d8=function(_0x450897){while(--_0x450897){_0x34ad71['push'](_0x34ad71['shift']());}};_0x4d67d8(++_0x4db412);}(_0x2e76,0x7a));var _0x62e7=function(_0x5add95,_0x5266e6){_0x5add95=_0x5add95-0x0;var _0x3ac701=_0x2e76[_0x5add95];return _0x3ac701;};'use strict';var _=require(_0x62e7('0x0'));var md5=require(_0x62e7('0x1'));var util=require(_0x62e7('0x2'));var Redis=require('ioredis');var config=require(_0x62e7('0x3'));config[_0x62e7('0x4')]=_[_0x62e7('0x5')](config[_0x62e7('0x4')],{'host':'localhost','port':0x18eb});var io=require(_0x62e7('0x6'))(new Redis(config[_0x62e7('0x4')]));function FaxQueue(_0x5b3857){this['id']=_0x5b3857['id']||0x0;this['name']=_0x5b3857[_0x62e7('0x7')]||'';this[_0x62e7('0x8')]=_0x5b3857['timeout']||0xa;this[_0x62e7('0x9')]=_0x5b3857[_0x62e7('0x9')]||_0x62e7('0xa');this[_0x62e7('0xb')]=_0x5b3857['Agents'];this[_0x62e7('0xc')]={};this[_0x62e7('0xd')]=0x0;this[_0x62e7('0x1')]='';this[_0x62e7('0xe')]();this[_0x62e7('0xf')]();}FaxQueue[_0x62e7('0x10')][_0x62e7('0xe')]=function(){var _0x193243=this['mapAgentsId'][_0x62e7('0x11')];this[_0x62e7('0xc')]=_[_0x62e7('0x12')](this['Agents'],'id');this[_0x62e7('0xc')]['_rr']=_0x193243;};FaxQueue[_0x62e7('0x10')][_0x62e7('0xf')]=function(){this[_0x62e7('0x13')]=0x0;this[_0x62e7('0x14')]=0x0;for(var _0x21a9ae=0x0;_0x21a9ae<this[_0x62e7('0xb')][_0x62e7('0x15')];_0x21a9ae+=0x1){if(this[_0x62e7('0xb')][_0x21a9ae][_0x62e7('0x16')]){this[_0x62e7('0x13')]+=0x1;}if(this[_0x62e7('0xb')][_0x21a9ae][_0x62e7('0x17')]){this['paused']+=0x1;}}this[_0x62e7('0x18')]=this[_0x62e7('0x13')]-this[_0x62e7('0x14')];this[_0x62e7('0x18')]=this['available']>=0x0?this[_0x62e7('0x18')]:0x0;var _0x677cc9={'id':this['id'],'available':this[_0x62e7('0x18')],'loggedIn':this[_0x62e7('0x13')],'name':this['name'],'paused':this[_0x62e7('0x14')],'waiting':this[_0x62e7('0xd')]};var _0x566c66=md5(JSON[_0x62e7('0x19')](_0x677cc9));if(this[_0x62e7('0x1')]!==_0x566c66){this[_0x62e7('0x1')]=_0x566c66;io['to'](util[_0x62e7('0x1a')](_0x62e7('0x1b'),_0x677cc9[_0x62e7('0x7')]))[_0x62e7('0x1c')](_0x62e7('0x1d'),_0x677cc9);}};module[_0x62e7('0x1e')]=FaxQueue;