Built motion from commit b0a9a629.|2.6.33
[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 _0x07c7=['name','timeout','strategy','beepall','Agents','waiting','updateRouting','updateRealtime','prototype','mapAgentsId','_rr','map','loggedIn','length','paused','available','format','mail:queue:%s','mail_queue:save','exports','lodash','md5','util','ioredis','../../../config/environment','redis','defaults','socket.io-emitter'];(function(_0x2c0408,_0x3510a3){var _0x420977=function(_0x479d27){while(--_0x479d27){_0x2c0408['push'](_0x2c0408['shift']());}};_0x420977(++_0x3510a3);}(_0x07c7,0x68));var _0x707c=function(_0x3947c9,_0x4d6c97){_0x3947c9=_0x3947c9-0x0;var _0x2e7871=_0x07c7[_0x3947c9];return _0x2e7871;};'use strict';var _=require(_0x707c('0x0'));var md5=require(_0x707c('0x1'));var util=require(_0x707c('0x2'));var Redis=require(_0x707c('0x3'));var config=require(_0x707c('0x4'));config[_0x707c('0x5')]=_[_0x707c('0x6')](config[_0x707c('0x5')],{'host':'localhost','port':0x18eb});var io=require(_0x707c('0x7'))(new Redis(config[_0x707c('0x5')]));function MailQueue(_0x323ed9){this['id']=_0x323ed9['id']||0x0;this[_0x707c('0x8')]=_0x323ed9[_0x707c('0x8')]||'';this[_0x707c('0x9')]=_0x323ed9[_0x707c('0x9')]||0xa;this[_0x707c('0xa')]=_0x323ed9[_0x707c('0xa')]||_0x707c('0xb');this[_0x707c('0xc')]=_0x323ed9[_0x707c('0xc')];this['mapAgentsId']={};this[_0x707c('0xd')]=0x0;this[_0x707c('0x1')]='';this[_0x707c('0xe')]();this[_0x707c('0xf')]();}MailQueue[_0x707c('0x10')][_0x707c('0xe')]=function(){var _0x9e44d3=this[_0x707c('0x11')][_0x707c('0x12')];this[_0x707c('0x11')]=_[_0x707c('0x13')](this['Agents'],'id');this[_0x707c('0x11')][_0x707c('0x12')]=_0x9e44d3;};MailQueue['prototype'][_0x707c('0xf')]=function(){this[_0x707c('0x14')]=0x0;this['paused']=0x0;for(var _0x435ad1=0x0;_0x435ad1<this[_0x707c('0xc')][_0x707c('0x15')];_0x435ad1+=0x1){if(this[_0x707c('0xc')][_0x435ad1]['online']){this[_0x707c('0x14')]+=0x1;}if(this[_0x707c('0xc')][_0x435ad1]['mailPause']){this[_0x707c('0x16')]+=0x1;}}this[_0x707c('0x17')]=this['loggedIn']-this['paused'];this[_0x707c('0x17')]=this[_0x707c('0x17')]>=0x0?this[_0x707c('0x17')]:0x0;var _0x2ff1c1={'id':this['id'],'available':this[_0x707c('0x17')],'loggedIn':this[_0x707c('0x14')],'name':this['name'],'paused':this[_0x707c('0x16')],'waiting':this['waiting']};var _0x58c90d=md5(JSON['stringify'](_0x2ff1c1));if(this[_0x707c('0x1')]!==_0x58c90d){this['md5']=_0x58c90d;io['to'](util[_0x707c('0x18')](_0x707c('0x19'),_0x2ff1c1[_0x707c('0x8')]))['emit'](_0x707c('0x1a'),_0x2ff1c1);}};module[_0x707c('0x1b')]=MailQueue;