3dba933d7a5ab8b2f8527371ab90921dc384cdb9
[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 _0x7a62=['md5','updateRealtime','prototype','updateRouting','_rr','map','loggedIn','paused','length','online','available','format','mail:queue:%s','mail_queue:save','exports','lodash','redis','defaults','socket.io-emitter','name','timeout','strategy','beepall','Agents','mapAgentsId','waiting'];(function(_0x2070da,_0x45e586){var _0x4f9fe1=function(_0x5b6f2a){while(--_0x5b6f2a){_0x2070da['push'](_0x2070da['shift']());}};_0x4f9fe1(++_0x45e586);}(_0x7a62,0x17b));var _0x27a6=function(_0xd6d50b,_0x5782ae){_0xd6d50b=_0xd6d50b-0x0;var _0x5d8ca9=_0x7a62[_0xd6d50b];return _0x5d8ca9;};'use strict';var _=require(_0x27a6('0x0'));var md5=require('md5');var util=require('util');var Redis=require('ioredis');var config=require('../../../config/environment');config[_0x27a6('0x1')]=_[_0x27a6('0x2')](config[_0x27a6('0x1')],{'host':'localhost','port':0x18eb});var io=require(_0x27a6('0x3'))(new Redis(config[_0x27a6('0x1')]));function MailQueue(_0x5445bb){this['id']=_0x5445bb['id']||0x0;this[_0x27a6('0x4')]=_0x5445bb[_0x27a6('0x4')]||'';this[_0x27a6('0x5')]=_0x5445bb[_0x27a6('0x5')]||0xa;this[_0x27a6('0x6')]=_0x5445bb['strategy']||_0x27a6('0x7');this[_0x27a6('0x8')]=_0x5445bb['Agents'];this[_0x27a6('0x9')]={};this[_0x27a6('0xa')]=0x0;this[_0x27a6('0xb')]='';this['updateRouting']();this[_0x27a6('0xc')]();}MailQueue[_0x27a6('0xd')][_0x27a6('0xe')]=function(){var _0x3ad0a9=this['mapAgentsId'][_0x27a6('0xf')];this['mapAgentsId']=_[_0x27a6('0x10')](this['Agents'],'id');this[_0x27a6('0x9')][_0x27a6('0xf')]=_0x3ad0a9;};MailQueue[_0x27a6('0xd')][_0x27a6('0xc')]=function(){this[_0x27a6('0x11')]=0x0;this[_0x27a6('0x12')]=0x0;for(var _0x4e6d47=0x0;_0x4e6d47<this['Agents'][_0x27a6('0x13')];_0x4e6d47+=0x1){if(this[_0x27a6('0x8')][_0x4e6d47][_0x27a6('0x14')]){this[_0x27a6('0x11')]+=0x1;}if(this[_0x27a6('0x8')][_0x4e6d47]['mailPause']){this[_0x27a6('0x12')]+=0x1;}}this['available']=this[_0x27a6('0x11')]-this[_0x27a6('0x12')];this[_0x27a6('0x15')]=this[_0x27a6('0x15')]>=0x0?this[_0x27a6('0x15')]:0x0;var _0x22d0fe={'id':this['id'],'available':this[_0x27a6('0x15')],'loggedIn':this['loggedIn'],'name':this[_0x27a6('0x4')],'paused':this[_0x27a6('0x12')],'waiting':this[_0x27a6('0xa')]};var _0x3e6ea7=md5(JSON['stringify'](_0x22d0fe));if(this['md5']!==_0x3e6ea7){this['md5']=_0x3e6ea7;io['to'](util[_0x27a6('0x16')](_0x27a6('0x17'),_0x22d0fe[_0x27a6('0x4')]))['emit'](_0x27a6('0x18'),_0x22d0fe);}};module[_0x27a6('0x19')]=MailQueue;