199b0c902e7b17aa8051ea3f318944af09e01778
[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 _0xb31b=['mapAgentsId','waiting','md5','updateRouting','updateRealtime','_rr','map','prototype','loggedIn','paused','online','mailPause','available','format','mail:queue:%s','emit','exports','lodash','util','ioredis','../../../config/environment','redis','defaults','localhost','name','timeout','strategy','beepall','Agents'];(function(_0x30806c,_0x7d3718){var _0x4cd89d=function(_0x744eb4){while(--_0x744eb4){_0x30806c['push'](_0x30806c['shift']());}};_0x4cd89d(++_0x7d3718);}(_0xb31b,0xdc));var _0xbb31=function(_0x283778,_0x1e2019){_0x283778=_0x283778-0x0;var _0x21bfc1=_0xb31b[_0x283778];return _0x21bfc1;};'use strict';var _=require(_0xbb31('0x0'));var md5=require('md5');var util=require(_0xbb31('0x1'));var Redis=require(_0xbb31('0x2'));var config=require(_0xbb31('0x3'));config[_0xbb31('0x4')]=_[_0xbb31('0x5')](config[_0xbb31('0x4')],{'host':_0xbb31('0x6'),'port':0x18eb});var io=require('socket.io-emitter')(new Redis(config[_0xbb31('0x4')]));function MailQueue(_0x25e914){this['id']=_0x25e914['id']||0x0;this[_0xbb31('0x7')]=_0x25e914[_0xbb31('0x7')]||'';this[_0xbb31('0x8')]=_0x25e914['timeout']||0xa;this[_0xbb31('0x9')]=_0x25e914[_0xbb31('0x9')]||_0xbb31('0xa');this[_0xbb31('0xb')]=_0x25e914[_0xbb31('0xb')];this[_0xbb31('0xc')]={};this[_0xbb31('0xd')]=0x0;this[_0xbb31('0xe')]='';this[_0xbb31('0xf')]();this[_0xbb31('0x10')]();}MailQueue['prototype'][_0xbb31('0xf')]=function(){var _0x5b3bdb=this[_0xbb31('0xc')][_0xbb31('0x11')];this['mapAgentsId']=_[_0xbb31('0x12')](this[_0xbb31('0xb')],'id');this[_0xbb31('0xc')][_0xbb31('0x11')]=_0x5b3bdb;};MailQueue[_0xbb31('0x13')]['updateRealtime']=function(){this[_0xbb31('0x14')]=0x0;this[_0xbb31('0x15')]=0x0;for(var _0x4701f8=0x0;_0x4701f8<this[_0xbb31('0xb')]['length'];_0x4701f8+=0x1){if(this[_0xbb31('0xb')][_0x4701f8][_0xbb31('0x16')]){this[_0xbb31('0x14')]+=0x1;}if(this[_0xbb31('0xb')][_0x4701f8][_0xbb31('0x17')]){this[_0xbb31('0x15')]+=0x1;}}this[_0xbb31('0x18')]=this[_0xbb31('0x14')]-this[_0xbb31('0x15')];this['available']=this[_0xbb31('0x18')]>=0x0?this['available']:0x0;var _0xadf1d4={'id':this['id'],'available':this['available'],'loggedIn':this['loggedIn'],'name':this['name'],'paused':this[_0xbb31('0x15')],'waiting':this[_0xbb31('0xd')]};var _0x236844=md5(JSON['stringify'](_0xadf1d4));if(this['md5']!==_0x236844){this[_0xbb31('0xe')]=_0x236844;io['to'](util[_0xbb31('0x19')](_0xbb31('0x1a'),_0xadf1d4['name']))[_0xbb31('0x1b')]('mail_queue:save',_0xadf1d4);}};module[_0xbb31('0x1c')]=MailQueue;