47df3dace84fc1791149aaba210b5f9d04a3597d
[motion2.git] / server / services / routing / model / mailQueue.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 _0xb06f=['paused','length','online','mailPause','available','stringify','format','mail:queue:%s','emit','mail_queue:save','exports','lodash','md5','../../../config/environment','redis','defaults','localhost','socket.io-emitter','name','timeout','strategy','beepall','Agents','mapAgentsId','waiting','updateRouting','map','prototype','loggedIn'];(function(_0x544e18,_0x7d0b19){var _0x2a22da=function(_0x4a1135){while(--_0x4a1135){_0x544e18['push'](_0x544e18['shift']());}};_0x2a22da(++_0x7d0b19);}(_0xb06f,0x110));var _0xfb06=function(_0x3799ae,_0x40ccc1){_0x3799ae=_0x3799ae-0x0;var _0x129408=_0xb06f[_0x3799ae];return _0x129408;};'use strict';var _=require(_0xfb06('0x0'));var md5=require(_0xfb06('0x1'));var util=require('util');var Redis=require('ioredis');var config=require(_0xfb06('0x2'));config[_0xfb06('0x3')]=_[_0xfb06('0x4')](config['redis'],{'host':_0xfb06('0x5'),'port':0x18eb});var io=require(_0xfb06('0x6'))(new Redis(config['redis']));function MailQueue(_0x42958a){this['id']=_0x42958a['id']||0x0;this['name']=_0x42958a[_0xfb06('0x7')]||'';this[_0xfb06('0x8')]=_0x42958a['timeout']||0xa;this[_0xfb06('0x9')]=_0x42958a[_0xfb06('0x9')]||_0xfb06('0xa');this[_0xfb06('0xb')]=_0x42958a[_0xfb06('0xb')];this[_0xfb06('0xc')]={};this[_0xfb06('0xd')]=0x0;this['md5']='';this['updateRouting']();this['updateRealtime']();}MailQueue['prototype'][_0xfb06('0xe')]=function(){var _0x4d0916=this[_0xfb06('0xc')]['_rr'];this['mapAgentsId']=_[_0xfb06('0xf')](this[_0xfb06('0xb')],'id');this[_0xfb06('0xc')]['_rr']=_0x4d0916;};MailQueue[_0xfb06('0x10')]['updateRealtime']=function(){this[_0xfb06('0x11')]=0x0;this[_0xfb06('0x12')]=0x0;for(var _0x8562d=0x0;_0x8562d<this['Agents'][_0xfb06('0x13')];_0x8562d+=0x1){if(this[_0xfb06('0xb')][_0x8562d][_0xfb06('0x14')]){this[_0xfb06('0x11')]+=0x1;}if(this[_0xfb06('0xb')][_0x8562d][_0xfb06('0x15')]){this[_0xfb06('0x12')]+=0x1;}}this[_0xfb06('0x16')]=this[_0xfb06('0x11')]-this[_0xfb06('0x12')];this['available']=this['available']>=0x0?this[_0xfb06('0x16')]:0x0;var _0x130285={'id':this['id'],'available':this[_0xfb06('0x16')],'loggedIn':this[_0xfb06('0x11')],'name':this[_0xfb06('0x7')],'paused':this['paused'],'waiting':this['waiting']};var _0x3b7bef=md5(JSON[_0xfb06('0x17')](_0x130285));if(this[_0xfb06('0x1')]!==_0x3b7bef){this[_0xfb06('0x1')]=_0x3b7bef;io['to'](util[_0xfb06('0x18')](_0xfb06('0x19'),_0x130285[_0xfb06('0x7')]))[_0xfb06('0x1a')](_0xfb06('0x1b'),_0x130285);}};module[_0xfb06('0x1c')]=MailQueue;