96924a0dd91190180369d5b9cb916662b1cf9d21
[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 _0x44cf=['util','../../../config/environment','redis','defaults','localhost','socket.io-emitter','name','timeout','strategy','beepall','Agents','mapAgentsId','updateRouting','updateRealtime','prototype','_rr','map','loggedIn','length','mailPause','paused','available','waiting','stringify','format','mail:queue:%s','emit','exports','lodash','md5'];(function(_0x64b57d,_0x2a79d8){var _0x2f55bd=function(_0x2923){while(--_0x2923){_0x64b57d['push'](_0x64b57d['shift']());}};_0x2f55bd(++_0x2a79d8);}(_0x44cf,0x94));var _0xf44c=function(_0x602380,_0x603b6){_0x602380=_0x602380-0x0;var _0x14f0ad=_0x44cf[_0x602380];return _0x14f0ad;};'use strict';var _=require(_0xf44c('0x0'));var md5=require(_0xf44c('0x1'));var util=require(_0xf44c('0x2'));var Redis=require('ioredis');var config=require(_0xf44c('0x3'));config[_0xf44c('0x4')]=_[_0xf44c('0x5')](config['redis'],{'host':_0xf44c('0x6'),'port':0x18eb});var io=require(_0xf44c('0x7'))(new Redis(config['redis']));function MailQueue(_0x15c252){this['id']=_0x15c252['id']||0x0;this[_0xf44c('0x8')]=_0x15c252[_0xf44c('0x8')]||'';this[_0xf44c('0x9')]=_0x15c252['timeout']||0xa;this['strategy']=_0x15c252[_0xf44c('0xa')]||_0xf44c('0xb');this[_0xf44c('0xc')]=_0x15c252[_0xf44c('0xc')];this[_0xf44c('0xd')]={};this['waiting']=0x0;this[_0xf44c('0x1')]='';this[_0xf44c('0xe')]();this[_0xf44c('0xf')]();}MailQueue[_0xf44c('0x10')][_0xf44c('0xe')]=function(){var _0x12f4ae=this[_0xf44c('0xd')][_0xf44c('0x11')];this[_0xf44c('0xd')]=_[_0xf44c('0x12')](this[_0xf44c('0xc')],'id');this[_0xf44c('0xd')][_0xf44c('0x11')]=_0x12f4ae;};MailQueue[_0xf44c('0x10')]['updateRealtime']=function(){this[_0xf44c('0x13')]=0x0;this['paused']=0x0;for(var _0x81d51d=0x0;_0x81d51d<this['Agents'][_0xf44c('0x14')];_0x81d51d+=0x1){if(this['Agents'][_0x81d51d]['online']){this[_0xf44c('0x13')]+=0x1;}if(this[_0xf44c('0xc')][_0x81d51d][_0xf44c('0x15')]){this[_0xf44c('0x16')]+=0x1;}}this['available']=this[_0xf44c('0x13')]-this[_0xf44c('0x16')];this[_0xf44c('0x17')]=this[_0xf44c('0x17')]>=0x0?this[_0xf44c('0x17')]:0x0;var _0x4e1cb5={'id':this['id'],'available':this['available'],'loggedIn':this['loggedIn'],'name':this[_0xf44c('0x8')],'paused':this[_0xf44c('0x16')],'waiting':this[_0xf44c('0x18')]};var _0x292303=md5(JSON[_0xf44c('0x19')](_0x4e1cb5));if(this['md5']!==_0x292303){this[_0xf44c('0x1')]=_0x292303;io['to'](util[_0xf44c('0x1a')](_0xf44c('0x1b'),_0x4e1cb5[_0xf44c('0x8')]))[_0xf44c('0x1c')]('mail_queue:save',_0x4e1cb5);}};module[_0xf44c('0x1d')]=MailQueue;