f463789a5263ff89587c3e4706f5307372853e6c
[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 _0x4e6b=['beepall','Agents','mapAgentsId','waiting','updateRealtime','updateRouting','_rr','map','paused','online','loggedIn','mailPause','available','stringify','format','emit','mail_queue:save','exports','lodash','md5','util','ioredis','redis','defaults','localhost','socket.io-emitter','name','timeout','strategy'];(function(_0x42b902,_0x3c49fd){var _0x2d9d68=function(_0x2175bf){while(--_0x2175bf){_0x42b902['push'](_0x42b902['shift']());}};_0x2d9d68(++_0x3c49fd);}(_0x4e6b,0x134));var _0xb4e6=function(_0x397e5f,_0x454c8f){_0x397e5f=_0x397e5f-0x0;var _0x5302b8=_0x4e6b[_0x397e5f];return _0x5302b8;};'use strict';var _=require(_0xb4e6('0x0'));var md5=require(_0xb4e6('0x1'));var util=require(_0xb4e6('0x2'));var Redis=require(_0xb4e6('0x3'));var config=require('../../../config/environment');config[_0xb4e6('0x4')]=_[_0xb4e6('0x5')](config['redis'],{'host':_0xb4e6('0x6'),'port':0x18eb});var io=require(_0xb4e6('0x7'))(new Redis(config[_0xb4e6('0x4')]));function MailQueue(_0x99681a){this['id']=_0x99681a['id']||0x0;this[_0xb4e6('0x8')]=_0x99681a[_0xb4e6('0x8')]||'';this[_0xb4e6('0x9')]=_0x99681a[_0xb4e6('0x9')]||0xa;this[_0xb4e6('0xa')]=_0x99681a['strategy']||_0xb4e6('0xb');this[_0xb4e6('0xc')]=_0x99681a[_0xb4e6('0xc')];this[_0xb4e6('0xd')]={};this[_0xb4e6('0xe')]=0x0;this[_0xb4e6('0x1')]='';this['updateRouting']();this[_0xb4e6('0xf')]();}MailQueue['prototype'][_0xb4e6('0x10')]=function(){var _0x2c88bd=this[_0xb4e6('0xd')][_0xb4e6('0x11')];this[_0xb4e6('0xd')]=_[_0xb4e6('0x12')](this[_0xb4e6('0xc')],'id');this[_0xb4e6('0xd')]['_rr']=_0x2c88bd;};MailQueue['prototype']['updateRealtime']=function(){this['loggedIn']=0x0;this[_0xb4e6('0x13')]=0x0;for(var _0x4378ab=0x0;_0x4378ab<this[_0xb4e6('0xc')]['length'];_0x4378ab+=0x1){if(this[_0xb4e6('0xc')][_0x4378ab][_0xb4e6('0x14')]){this[_0xb4e6('0x15')]+=0x1;}if(this[_0xb4e6('0xc')][_0x4378ab][_0xb4e6('0x16')]){this[_0xb4e6('0x13')]+=0x1;}}this['available']=this[_0xb4e6('0x15')]-this[_0xb4e6('0x13')];this[_0xb4e6('0x17')]=this[_0xb4e6('0x17')]>=0x0?this[_0xb4e6('0x17')]:0x0;var _0x37e13b={'id':this['id'],'available':this[_0xb4e6('0x17')],'loggedIn':this['loggedIn'],'name':this[_0xb4e6('0x8')],'paused':this['paused'],'waiting':this['waiting']};var _0x5b339a=md5(JSON[_0xb4e6('0x18')](_0x37e13b));if(this[_0xb4e6('0x1')]!==_0x5b339a){this[_0xb4e6('0x1')]=_0x5b339a;io['to'](util[_0xb4e6('0x19')]('mail:queue:%s',_0x37e13b[_0xb4e6('0x8')]))[_0xb4e6('0x1a')](_0xb4e6('0x1b'),_0x37e13b);}};module[_0xb4e6('0x1c')]=MailQueue;