e9b0854626f58afd74f1f13447fd0eac69d9f4db
[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 _0x5793=['format','mail:queue:%s','mail_queue:save','lodash','md5','util','ioredis','redis','localhost','socket.io-emitter','name','timeout','strategy','beepall','Agents','mapAgentsId','waiting','updateRouting','updateRealtime','prototype','_rr','map','loggedIn','paused','length','online','mailPause','available','stringify'];(function(_0x1f0098,_0x1587bc){var _0x1e51d4=function(_0x2aa2d6){while(--_0x2aa2d6){_0x1f0098['push'](_0x1f0098['shift']());}};_0x1e51d4(++_0x1587bc);}(_0x5793,0xb1));var _0x3579=function(_0x4cec6b,_0x55864a){_0x4cec6b=_0x4cec6b-0x0;var _0x3db368=_0x5793[_0x4cec6b];return _0x3db368;};'use strict';var _=require(_0x3579('0x0'));var md5=require(_0x3579('0x1'));var util=require(_0x3579('0x2'));var Redis=require(_0x3579('0x3'));var config=require('../../../config/environment');config['redis']=_['defaults'](config[_0x3579('0x4')],{'host':_0x3579('0x5'),'port':0x18eb});var io=require(_0x3579('0x6'))(new Redis(config[_0x3579('0x4')]));function MailQueue(_0x31c500){this['id']=_0x31c500['id']||0x0;this['name']=_0x31c500[_0x3579('0x7')]||'';this['timeout']=_0x31c500[_0x3579('0x8')]||0xa;this[_0x3579('0x9')]=_0x31c500[_0x3579('0x9')]||_0x3579('0xa');this[_0x3579('0xb')]=_0x31c500[_0x3579('0xb')];this[_0x3579('0xc')]={};this[_0x3579('0xd')]=0x0;this[_0x3579('0x1')]='';this[_0x3579('0xe')]();this[_0x3579('0xf')]();}MailQueue[_0x3579('0x10')]['updateRouting']=function(){var _0x3d3e24=this[_0x3579('0xc')][_0x3579('0x11')];this[_0x3579('0xc')]=_[_0x3579('0x12')](this[_0x3579('0xb')],'id');this['mapAgentsId'][_0x3579('0x11')]=_0x3d3e24;};MailQueue[_0x3579('0x10')]['updateRealtime']=function(){this[_0x3579('0x13')]=0x0;this[_0x3579('0x14')]=0x0;for(var _0x17cbe0=0x0;_0x17cbe0<this['Agents'][_0x3579('0x15')];_0x17cbe0+=0x1){if(this[_0x3579('0xb')][_0x17cbe0][_0x3579('0x16')]){this['loggedIn']+=0x1;}if(this['Agents'][_0x17cbe0][_0x3579('0x17')]){this[_0x3579('0x14')]+=0x1;}}this[_0x3579('0x18')]=this[_0x3579('0x13')]-this[_0x3579('0x14')];this[_0x3579('0x18')]=this[_0x3579('0x18')]>=0x0?this[_0x3579('0x18')]:0x0;var _0x439c15={'id':this['id'],'available':this[_0x3579('0x18')],'loggedIn':this[_0x3579('0x13')],'name':this['name'],'paused':this[_0x3579('0x14')],'waiting':this[_0x3579('0xd')]};var _0x4cf607=md5(JSON[_0x3579('0x19')](_0x439c15));if(this['md5']!==_0x4cf607){this[_0x3579('0x1')]=_0x4cf607;io['to'](util[_0x3579('0x1a')](_0x3579('0x1b'),_0x439c15[_0x3579('0x7')]))['emit'](_0x3579('0x1c'),_0x439c15);}};module['exports']=MailQueue;