6b89e47f32d9d04567754b56b6a34da1bc44fad5
[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 _0xa711=['loggedIn','paused','Agents','online','available','format','mail:queue:%s','emit','mail_queue:save','exports','lodash','md5','util','ioredis','../../../config/environment','redis','socket.io-emitter','name','timeout','strategy','beepall','mapAgentsId','waiting','updateRealtime','prototype','updateRouting','map'];(function(_0x1bc228,_0x32deb2){var _0x4e489a=function(_0x5aaa74){while(--_0x5aaa74){_0x1bc228['push'](_0x1bc228['shift']());}};_0x4e489a(++_0x32deb2);}(_0xa711,0xfd));var _0x1a71=function(_0x3b76a2,_0x2d37b3){_0x3b76a2=_0x3b76a2-0x0;var _0x327e21=_0xa711[_0x3b76a2];return _0x327e21;};'use strict';var _=require(_0x1a71('0x0'));var md5=require(_0x1a71('0x1'));var util=require(_0x1a71('0x2'));var Redis=require(_0x1a71('0x3'));var config=require(_0x1a71('0x4'));config[_0x1a71('0x5')]=_['defaults'](config[_0x1a71('0x5')],{'host':'localhost','port':0x18eb});var io=require(_0x1a71('0x6'))(new Redis(config[_0x1a71('0x5')]));function MailQueue(_0x52f9be){this['id']=_0x52f9be['id']||0x0;this[_0x1a71('0x7')]=_0x52f9be[_0x1a71('0x7')]||'';this[_0x1a71('0x8')]=_0x52f9be[_0x1a71('0x8')]||0xa;this[_0x1a71('0x9')]=_0x52f9be[_0x1a71('0x9')]||_0x1a71('0xa');this['Agents']=_0x52f9be['Agents'];this[_0x1a71('0xb')]={};this[_0x1a71('0xc')]=0x0;this[_0x1a71('0x1')]='';this['updateRouting']();this[_0x1a71('0xd')]();}MailQueue[_0x1a71('0xe')][_0x1a71('0xf')]=function(){var _0x3312f3=this[_0x1a71('0xb')]['_rr'];this[_0x1a71('0xb')]=_[_0x1a71('0x10')](this['Agents'],'id');this[_0x1a71('0xb')]['_rr']=_0x3312f3;};MailQueue['prototype'][_0x1a71('0xd')]=function(){this[_0x1a71('0x11')]=0x0;this[_0x1a71('0x12')]=0x0;for(var _0x75fa87=0x0;_0x75fa87<this[_0x1a71('0x13')]['length'];_0x75fa87+=0x1){if(this[_0x1a71('0x13')][_0x75fa87][_0x1a71('0x14')]){this[_0x1a71('0x11')]+=0x1;}if(this[_0x1a71('0x13')][_0x75fa87]['mailPause']){this[_0x1a71('0x12')]+=0x1;}}this[_0x1a71('0x15')]=this[_0x1a71('0x11')]-this[_0x1a71('0x12')];this[_0x1a71('0x15')]=this[_0x1a71('0x15')]>=0x0?this[_0x1a71('0x15')]:0x0;var _0x12def2={'id':this['id'],'available':this[_0x1a71('0x15')],'loggedIn':this[_0x1a71('0x11')],'name':this[_0x1a71('0x7')],'paused':this['paused'],'waiting':this[_0x1a71('0xc')]};var _0x2d595a=md5(JSON['stringify'](_0x12def2));if(this['md5']!==_0x2d595a){this['md5']=_0x2d595a;io['to'](util[_0x1a71('0x16')](_0x1a71('0x17'),_0x12def2[_0x1a71('0x7')]))[_0x1a71('0x18')](_0x1a71('0x19'),_0x12def2);}};module[_0x1a71('0x1a')]=MailQueue;