dc018ca5d8df9684679abdd5258fdf0475bd6c7e
[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 _0xb89f=['util','ioredis','redis','defaults','localhost','socket.io-emitter','name','timeout','strategy','Agents','mapAgentsId','waiting','updateRouting','updateRealtime','prototype','map','_rr','loggedIn','paused','length','online','available','stringify','mail:queue:%s','emit','exports','lodash','md5'];(function(_0x1b6186,_0x1ec7f2){var _0x186121=function(_0x1748a8){while(--_0x1748a8){_0x1b6186['push'](_0x1b6186['shift']());}};_0x186121(++_0x1ec7f2);}(_0xb89f,0x16a));var _0xfb89=function(_0x1d0dd1,_0x3b72e1){_0x1d0dd1=_0x1d0dd1-0x0;var _0x576e0b=_0xb89f[_0x1d0dd1];return _0x576e0b;};'use strict';var _=require(_0xfb89('0x0'));var md5=require(_0xfb89('0x1'));var util=require(_0xfb89('0x2'));var Redis=require(_0xfb89('0x3'));var config=require('../../../config/environment');config[_0xfb89('0x4')]=_[_0xfb89('0x5')](config[_0xfb89('0x4')],{'host':_0xfb89('0x6'),'port':0x18eb});var io=require(_0xfb89('0x7'))(new Redis(config[_0xfb89('0x4')]));function MailQueue(_0x4f3738){this['id']=_0x4f3738['id']||0x0;this[_0xfb89('0x8')]=_0x4f3738['name']||'';this[_0xfb89('0x9')]=_0x4f3738[_0xfb89('0x9')]||0xa;this['strategy']=_0x4f3738[_0xfb89('0xa')]||'beepall';this[_0xfb89('0xb')]=_0x4f3738[_0xfb89('0xb')];this[_0xfb89('0xc')]={};this[_0xfb89('0xd')]=0x0;this[_0xfb89('0x1')]='';this[_0xfb89('0xe')]();this[_0xfb89('0xf')]();}MailQueue[_0xfb89('0x10')][_0xfb89('0xe')]=function(){var _0x39eb1d=this[_0xfb89('0xc')]['_rr'];this[_0xfb89('0xc')]=_[_0xfb89('0x11')](this[_0xfb89('0xb')],'id');this[_0xfb89('0xc')][_0xfb89('0x12')]=_0x39eb1d;};MailQueue[_0xfb89('0x10')][_0xfb89('0xf')]=function(){this[_0xfb89('0x13')]=0x0;this[_0xfb89('0x14')]=0x0;for(var _0x292d4e=0x0;_0x292d4e<this[_0xfb89('0xb')][_0xfb89('0x15')];_0x292d4e+=0x1){if(this[_0xfb89('0xb')][_0x292d4e][_0xfb89('0x16')]){this[_0xfb89('0x13')]+=0x1;}if(this['Agents'][_0x292d4e]['mailPause']){this[_0xfb89('0x14')]+=0x1;}}this['available']=this[_0xfb89('0x13')]-this[_0xfb89('0x14')];this[_0xfb89('0x17')]=this['available']>=0x0?this[_0xfb89('0x17')]:0x0;var _0x3fcc7b={'id':this['id'],'available':this[_0xfb89('0x17')],'loggedIn':this[_0xfb89('0x13')],'name':this[_0xfb89('0x8')],'paused':this[_0xfb89('0x14')],'waiting':this[_0xfb89('0xd')]};var _0x52e4f6=md5(JSON[_0xfb89('0x18')](_0x3fcc7b));if(this['md5']!==_0x52e4f6){this[_0xfb89('0x1')]=_0x52e4f6;io['to'](util['format'](_0xfb89('0x19'),_0x3fcc7b['name']))[_0xfb89('0x1a')]('mail_queue:save',_0x3fcc7b);}};module[_0xfb89('0x1b')]=MailQueue;