4cbe0918d7011b8fc8200ab90bd788e87814fc56
[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 _0xe0e2=['md5','util','ioredis','../../../config/environment','redis','defaults','localhost','socket.io-emitter','name','timeout','strategy','beepall','Agents','mapAgentsId','waiting','updateRouting','updateRealtime','_rr','map','prototype','paused','length','online','loggedIn','mailPause','available','mail:queue:%s','emit','mail_queue:save','exports','lodash'];(function(_0x5f309e,_0x66e31){var _0x487b5e=function(_0x44f203){while(--_0x44f203){_0x5f309e['push'](_0x5f309e['shift']());}};_0x487b5e(++_0x66e31);}(_0xe0e2,0x1b1));var _0x2e0e=function(_0x3bdc30,_0x119486){_0x3bdc30=_0x3bdc30-0x0;var _0x1a4986=_0xe0e2[_0x3bdc30];return _0x1a4986;};'use strict';var _=require(_0x2e0e('0x0'));var md5=require(_0x2e0e('0x1'));var util=require(_0x2e0e('0x2'));var Redis=require(_0x2e0e('0x3'));var config=require(_0x2e0e('0x4'));config[_0x2e0e('0x5')]=_[_0x2e0e('0x6')](config[_0x2e0e('0x5')],{'host':_0x2e0e('0x7'),'port':0x18eb});var io=require(_0x2e0e('0x8'))(new Redis(config[_0x2e0e('0x5')]));function MailQueue(_0x791cb1){this['id']=_0x791cb1['id']||0x0;this[_0x2e0e('0x9')]=_0x791cb1['name']||'';this[_0x2e0e('0xa')]=_0x791cb1['timeout']||0xa;this[_0x2e0e('0xb')]=_0x791cb1[_0x2e0e('0xb')]||_0x2e0e('0xc');this[_0x2e0e('0xd')]=_0x791cb1[_0x2e0e('0xd')];this[_0x2e0e('0xe')]={};this[_0x2e0e('0xf')]=0x0;this[_0x2e0e('0x1')]='';this[_0x2e0e('0x10')]();this[_0x2e0e('0x11')]();}MailQueue['prototype'][_0x2e0e('0x10')]=function(){var _0x24bc77=this['mapAgentsId'][_0x2e0e('0x12')];this[_0x2e0e('0xe')]=_[_0x2e0e('0x13')](this['Agents'],'id');this[_0x2e0e('0xe')]['_rr']=_0x24bc77;};MailQueue[_0x2e0e('0x14')]['updateRealtime']=function(){this['loggedIn']=0x0;this[_0x2e0e('0x15')]=0x0;for(var _0x585b45=0x0;_0x585b45<this[_0x2e0e('0xd')][_0x2e0e('0x16')];_0x585b45+=0x1){if(this[_0x2e0e('0xd')][_0x585b45][_0x2e0e('0x17')]){this[_0x2e0e('0x18')]+=0x1;}if(this[_0x2e0e('0xd')][_0x585b45][_0x2e0e('0x19')]){this[_0x2e0e('0x15')]+=0x1;}}this[_0x2e0e('0x1a')]=this['loggedIn']-this[_0x2e0e('0x15')];this[_0x2e0e('0x1a')]=this[_0x2e0e('0x1a')]>=0x0?this[_0x2e0e('0x1a')]:0x0;var _0x45d7df={'id':this['id'],'available':this[_0x2e0e('0x1a')],'loggedIn':this[_0x2e0e('0x18')],'name':this[_0x2e0e('0x9')],'paused':this[_0x2e0e('0x15')],'waiting':this[_0x2e0e('0xf')]};var _0x58aab3=md5(JSON['stringify'](_0x45d7df));if(this['md5']!==_0x58aab3){this[_0x2e0e('0x1')]=_0x58aab3;io['to'](util['format'](_0x2e0e('0x1b'),_0x45d7df[_0x2e0e('0x9')]))[_0x2e0e('0x1c')](_0x2e0e('0x1d'),_0x45d7df);}};module[_0x2e0e('0x1e')]=MailQueue;