75923976792f074bea20d01729fe09e82f33ee4b
[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 _0x883b=['ioredis','redis','localhost','socket.io-emitter','name','timeout','strategy','beepall','Agents','mapAgentsId','waiting','updateRouting','prototype','_rr','map','updateRealtime','loggedIn','paused','length','online','available','stringify','emit','mail_queue:save','exports','md5','util'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0x883b,0x15d));var _0xb883=function(_0x14add3,_0x13ce8d){_0x14add3=_0x14add3-0x0;var _0x4a174f=_0x883b[_0x14add3];return _0x4a174f;};'use strict';var _=require('lodash');var md5=require(_0xb883('0x0'));var util=require(_0xb883('0x1'));var Redis=require(_0xb883('0x2'));var config=require('../../../config/environment');config[_0xb883('0x3')]=_['defaults'](config[_0xb883('0x3')],{'host':_0xb883('0x4'),'port':0x18eb});var io=require(_0xb883('0x5'))(new Redis(config[_0xb883('0x3')]));function MailQueue(_0x1b882f){this['id']=_0x1b882f['id']||0x0;this[_0xb883('0x6')]=_0x1b882f[_0xb883('0x6')]||'';this[_0xb883('0x7')]=_0x1b882f[_0xb883('0x7')]||0xa;this[_0xb883('0x8')]=_0x1b882f[_0xb883('0x8')]||_0xb883('0x9');this[_0xb883('0xa')]=_0x1b882f[_0xb883('0xa')];this[_0xb883('0xb')]={};this[_0xb883('0xc')]=0x0;this['md5']='';this[_0xb883('0xd')]();this['updateRealtime']();}MailQueue[_0xb883('0xe')]['updateRouting']=function(){var _0x2d3fa4=this[_0xb883('0xb')][_0xb883('0xf')];this[_0xb883('0xb')]=_[_0xb883('0x10')](this[_0xb883('0xa')],'id');this['mapAgentsId'][_0xb883('0xf')]=_0x2d3fa4;};MailQueue['prototype'][_0xb883('0x11')]=function(){this[_0xb883('0x12')]=0x0;this[_0xb883('0x13')]=0x0;for(var _0x12bb72=0x0;_0x12bb72<this[_0xb883('0xa')][_0xb883('0x14')];_0x12bb72+=0x1){if(this[_0xb883('0xa')][_0x12bb72][_0xb883('0x15')]){this[_0xb883('0x12')]+=0x1;}if(this[_0xb883('0xa')][_0x12bb72]['mailPause']){this[_0xb883('0x13')]+=0x1;}}this[_0xb883('0x16')]=this[_0xb883('0x12')]-this['paused'];this[_0xb883('0x16')]=this['available']>=0x0?this[_0xb883('0x16')]:0x0;var _0x10fe14={'id':this['id'],'available':this[_0xb883('0x16')],'loggedIn':this[_0xb883('0x12')],'name':this['name'],'paused':this['paused'],'waiting':this[_0xb883('0xc')]};var _0x11e448=md5(JSON[_0xb883('0x17')](_0x10fe14));if(this['md5']!==_0x11e448){this[_0xb883('0x0')]=_0x11e448;io['to'](util['format']('mail:queue:%s',_0x10fe14[_0xb883('0x6')]))[_0xb883('0x18')](_0xb883('0x19'),_0x10fe14);}};module[_0xb883('0x1a')]=MailQueue;