Built motion from commit (unavailable).|2.4.19
[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 _0xdf65=['waiting','md5','updateRealtime','_rr','prototype','loggedIn','paused','length','online','mailPause','available','format','mail:queue:%s','mail_queue:save','util','ioredis','redis','defaults','socket.io-emitter','name','timeout','strategy','Agents','mapAgentsId'];(function(_0x14a342,_0x15d954){var _0x31087e=function(_0x2d499d){while(--_0x2d499d){_0x14a342['push'](_0x14a342['shift']());}};_0x31087e(++_0x15d954);}(_0xdf65,0x6e));var _0x5df6=function(_0x9e8e8,_0x2ccded){_0x9e8e8=_0x9e8e8-0x0;var _0x3f1abc=_0xdf65[_0x9e8e8];return _0x3f1abc;};'use strict';var _=require('lodash');var md5=require('md5');var util=require(_0x5df6('0x0'));var Redis=require(_0x5df6('0x1'));var config=require('../../../config/environment');config[_0x5df6('0x2')]=_[_0x5df6('0x3')](config[_0x5df6('0x2')],{'host':'localhost','port':0x18eb});var io=require(_0x5df6('0x4'))(new Redis(config[_0x5df6('0x2')]));function MailQueue(_0x2aea44){this['id']=_0x2aea44['id']||0x0;this[_0x5df6('0x5')]=_0x2aea44[_0x5df6('0x5')]||'';this[_0x5df6('0x6')]=_0x2aea44[_0x5df6('0x6')]||0xa;this[_0x5df6('0x7')]=_0x2aea44[_0x5df6('0x7')]||'beepall';this['Agents']=_0x2aea44[_0x5df6('0x8')];this[_0x5df6('0x9')]={};this[_0x5df6('0xa')]=0x0;this[_0x5df6('0xb')]='';this['updateRouting']();this[_0x5df6('0xc')]();}MailQueue['prototype']['updateRouting']=function(){var _0x1d6c1a=this['mapAgentsId'][_0x5df6('0xd')];this[_0x5df6('0x9')]=_['map'](this[_0x5df6('0x8')],'id');this[_0x5df6('0x9')][_0x5df6('0xd')]=_0x1d6c1a;};MailQueue[_0x5df6('0xe')][_0x5df6('0xc')]=function(){this[_0x5df6('0xf')]=0x0;this[_0x5df6('0x10')]=0x0;for(var _0xbfa96b=0x0;_0xbfa96b<this[_0x5df6('0x8')][_0x5df6('0x11')];_0xbfa96b+=0x1){if(this[_0x5df6('0x8')][_0xbfa96b][_0x5df6('0x12')]){this[_0x5df6('0xf')]+=0x1;}if(this[_0x5df6('0x8')][_0xbfa96b][_0x5df6('0x13')]){this['paused']+=0x1;}}this[_0x5df6('0x14')]=this[_0x5df6('0xf')]-this[_0x5df6('0x10')];this[_0x5df6('0x14')]=this[_0x5df6('0x14')]>=0x0?this[_0x5df6('0x14')]:0x0;var _0xdf66fc={'id':this['id'],'available':this[_0x5df6('0x14')],'loggedIn':this[_0x5df6('0xf')],'name':this[_0x5df6('0x5')],'paused':this[_0x5df6('0x10')],'waiting':this[_0x5df6('0xa')]};var _0x466cc4=md5(JSON['stringify'](_0xdf66fc));if(this[_0x5df6('0xb')]!==_0x466cc4){this[_0x5df6('0xb')]=_0x466cc4;io['to'](util[_0x5df6('0x15')](_0x5df6('0x16'),_0xdf66fc[_0x5df6('0x5')]))['emit'](_0x5df6('0x17'),_0xdf66fc);}};module['exports']=MailQueue;