Built motion from commit ddca4d0d.|2.5.47
[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 _0xd185=['paused','mailPause','available','stringify','format','mail:queue:%s','emit','exports','md5','ioredis','redis','defaults','localhost','socket.io-emitter','name','timeout','strategy','beepall','Agents','mapAgentsId','waiting','updateRouting','updateRealtime','prototype','_rr','map','loggedIn'];(function(_0xcd820f,_0x47b0cd){var _0x54e78a=function(_0x2cd702){while(--_0x2cd702){_0xcd820f['push'](_0xcd820f['shift']());}};_0x54e78a(++_0x47b0cd);}(_0xd185,0x131));var _0x5d18=function(_0x21cdb1,_0x4f3ab8){_0x21cdb1=_0x21cdb1-0x0;var _0x16884f=_0xd185[_0x21cdb1];return _0x16884f;};'use strict';var _=require('lodash');var md5=require(_0x5d18('0x0'));var util=require('util');var Redis=require(_0x5d18('0x1'));var config=require('../../../config/environment');config[_0x5d18('0x2')]=_[_0x5d18('0x3')](config[_0x5d18('0x2')],{'host':_0x5d18('0x4'),'port':0x18eb});var io=require(_0x5d18('0x5'))(new Redis(config['redis']));function MailQueue(_0x310180){this['id']=_0x310180['id']||0x0;this['name']=_0x310180[_0x5d18('0x6')]||'';this[_0x5d18('0x7')]=_0x310180[_0x5d18('0x7')]||0xa;this[_0x5d18('0x8')]=_0x310180[_0x5d18('0x8')]||_0x5d18('0x9');this[_0x5d18('0xa')]=_0x310180[_0x5d18('0xa')];this[_0x5d18('0xb')]={};this[_0x5d18('0xc')]=0x0;this[_0x5d18('0x0')]='';this[_0x5d18('0xd')]();this[_0x5d18('0xe')]();}MailQueue[_0x5d18('0xf')][_0x5d18('0xd')]=function(){var _0x37e539=this['mapAgentsId'][_0x5d18('0x10')];this[_0x5d18('0xb')]=_[_0x5d18('0x11')](this['Agents'],'id');this[_0x5d18('0xb')][_0x5d18('0x10')]=_0x37e539;};MailQueue[_0x5d18('0xf')][_0x5d18('0xe')]=function(){this[_0x5d18('0x12')]=0x0;this[_0x5d18('0x13')]=0x0;for(var _0x247aa4=0x0;_0x247aa4<this['Agents']['length'];_0x247aa4+=0x1){if(this[_0x5d18('0xa')][_0x247aa4]['online']){this[_0x5d18('0x12')]+=0x1;}if(this['Agents'][_0x247aa4][_0x5d18('0x14')]){this[_0x5d18('0x13')]+=0x1;}}this[_0x5d18('0x15')]=this[_0x5d18('0x12')]-this['paused'];this[_0x5d18('0x15')]=this['available']>=0x0?this[_0x5d18('0x15')]:0x0;var _0x5bd10a={'id':this['id'],'available':this['available'],'loggedIn':this['loggedIn'],'name':this['name'],'paused':this['paused'],'waiting':this[_0x5d18('0xc')]};var _0x542c3d=md5(JSON[_0x5d18('0x16')](_0x5bd10a));if(this[_0x5d18('0x0')]!==_0x542c3d){this[_0x5d18('0x0')]=_0x542c3d;io['to'](util[_0x5d18('0x17')](_0x5d18('0x18'),_0x5bd10a[_0x5d18('0x6')]))[_0x5d18('0x19')]('mail_queue:save',_0x5bd10a);}};module[_0x5d18('0x1a')]=MailQueue;