a661960b2b03e53518ff07d6e5ef3f4b186c0362
[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 _0xf064=['socket.io-emitter','name','timeout','strategy','beepall','Agents','mapAgentsId','updateRealtime','prototype','updateRouting','_rr','map','loggedIn','paused','online','mailPause','available','waiting','stringify','format','mail:queue:%s','emit','mail_queue:save','exports','lodash','md5','util','../../../config/environment','redis','localhost'];(function(_0x99829d,_0x56a963){var _0x4fa089=function(_0x3f34f5){while(--_0x3f34f5){_0x99829d['push'](_0x99829d['shift']());}};_0x4fa089(++_0x56a963);}(_0xf064,0xcc));var _0x4f06=function(_0x3e182f,_0x380ec7){_0x3e182f=_0x3e182f-0x0;var _0x23edc9=_0xf064[_0x3e182f];return _0x23edc9;};'use strict';var _=require(_0x4f06('0x0'));var md5=require(_0x4f06('0x1'));var util=require(_0x4f06('0x2'));var Redis=require('ioredis');var config=require(_0x4f06('0x3'));config[_0x4f06('0x4')]=_['defaults'](config['redis'],{'host':_0x4f06('0x5'),'port':0x18eb});var io=require(_0x4f06('0x6'))(new Redis(config['redis']));function MailQueue(_0x25fb96){this['id']=_0x25fb96['id']||0x0;this[_0x4f06('0x7')]=_0x25fb96[_0x4f06('0x7')]||'';this[_0x4f06('0x8')]=_0x25fb96[_0x4f06('0x8')]||0xa;this['strategy']=_0x25fb96[_0x4f06('0x9')]||_0x4f06('0xa');this[_0x4f06('0xb')]=_0x25fb96[_0x4f06('0xb')];this[_0x4f06('0xc')]={};this['waiting']=0x0;this['md5']='';this['updateRouting']();this[_0x4f06('0xd')]();}MailQueue[_0x4f06('0xe')][_0x4f06('0xf')]=function(){var _0xbccaa2=this[_0x4f06('0xc')][_0x4f06('0x10')];this[_0x4f06('0xc')]=_[_0x4f06('0x11')](this['Agents'],'id');this[_0x4f06('0xc')]['_rr']=_0xbccaa2;};MailQueue['prototype'][_0x4f06('0xd')]=function(){this[_0x4f06('0x12')]=0x0;this[_0x4f06('0x13')]=0x0;for(var _0x22cccc=0x0;_0x22cccc<this[_0x4f06('0xb')]['length'];_0x22cccc+=0x1){if(this[_0x4f06('0xb')][_0x22cccc][_0x4f06('0x14')]){this['loggedIn']+=0x1;}if(this[_0x4f06('0xb')][_0x22cccc][_0x4f06('0x15')]){this[_0x4f06('0x13')]+=0x1;}}this[_0x4f06('0x16')]=this[_0x4f06('0x12')]-this[_0x4f06('0x13')];this[_0x4f06('0x16')]=this[_0x4f06('0x16')]>=0x0?this[_0x4f06('0x16')]:0x0;var _0x4ecca7={'id':this['id'],'available':this[_0x4f06('0x16')],'loggedIn':this['loggedIn'],'name':this[_0x4f06('0x7')],'paused':this[_0x4f06('0x13')],'waiting':this[_0x4f06('0x17')]};var _0x499471=md5(JSON[_0x4f06('0x18')](_0x4ecca7));if(this['md5']!==_0x499471){this[_0x4f06('0x1')]=_0x499471;io['to'](util[_0x4f06('0x19')](_0x4f06('0x1a'),_0x4ecca7[_0x4f06('0x7')]))[_0x4f06('0x1b')](_0x4f06('0x1c'),_0x4ecca7);}};module[_0x4f06('0x1d')]=MailQueue;