a46a2f951fd93221f3b5620e8885b3ac9d8b8a43
[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 _0x77ba=['localhost','socket.io-emitter','name','timeout','strategy','beepall','Agents','mapAgentsId','updateRealtime','prototype','updateRouting','_rr','map','loggedIn','length','online','mailPause','available','paused','waiting','format','emit','mail_queue:save','exports','lodash','md5','../../../config/environment','redis','defaults'];(function(_0x20a584,_0xe384a5){var _0x4b41a8=function(_0x2127c6){while(--_0x2127c6){_0x20a584['push'](_0x20a584['shift']());}};_0x4b41a8(++_0xe384a5);}(_0x77ba,0x100));var _0xa77b=function(_0x213518,_0x51e022){_0x213518=_0x213518-0x0;var _0x1baf75=_0x77ba[_0x213518];return _0x1baf75;};'use strict';var _=require(_0xa77b('0x0'));var md5=require(_0xa77b('0x1'));var util=require('util');var Redis=require('ioredis');var config=require(_0xa77b('0x2'));config[_0xa77b('0x3')]=_[_0xa77b('0x4')](config[_0xa77b('0x3')],{'host':_0xa77b('0x5'),'port':0x18eb});var io=require(_0xa77b('0x6'))(new Redis(config[_0xa77b('0x3')]));function MailQueue(_0x4fa141){this['id']=_0x4fa141['id']||0x0;this[_0xa77b('0x7')]=_0x4fa141[_0xa77b('0x7')]||'';this[_0xa77b('0x8')]=_0x4fa141[_0xa77b('0x8')]||0xa;this[_0xa77b('0x9')]=_0x4fa141[_0xa77b('0x9')]||_0xa77b('0xa');this[_0xa77b('0xb')]=_0x4fa141['Agents'];this[_0xa77b('0xc')]={};this['waiting']=0x0;this[_0xa77b('0x1')]='';this['updateRouting']();this[_0xa77b('0xd')]();}MailQueue[_0xa77b('0xe')][_0xa77b('0xf')]=function(){var _0x4c64cd=this['mapAgentsId'][_0xa77b('0x10')];this[_0xa77b('0xc')]=_[_0xa77b('0x11')](this['Agents'],'id');this[_0xa77b('0xc')][_0xa77b('0x10')]=_0x4c64cd;};MailQueue[_0xa77b('0xe')][_0xa77b('0xd')]=function(){this[_0xa77b('0x12')]=0x0;this['paused']=0x0;for(var _0xd4a2b7=0x0;_0xd4a2b7<this['Agents'][_0xa77b('0x13')];_0xd4a2b7+=0x1){if(this[_0xa77b('0xb')][_0xd4a2b7][_0xa77b('0x14')]){this[_0xa77b('0x12')]+=0x1;}if(this[_0xa77b('0xb')][_0xd4a2b7][_0xa77b('0x15')]){this['paused']+=0x1;}}this[_0xa77b('0x16')]=this[_0xa77b('0x12')]-this['paused'];this['available']=this[_0xa77b('0x16')]>=0x0?this[_0xa77b('0x16')]:0x0;var _0x1c6395={'id':this['id'],'available':this[_0xa77b('0x16')],'loggedIn':this['loggedIn'],'name':this['name'],'paused':this[_0xa77b('0x17')],'waiting':this[_0xa77b('0x18')]};var _0x4255b2=md5(JSON['stringify'](_0x1c6395));if(this['md5']!==_0x4255b2){this[_0xa77b('0x1')]=_0x4255b2;io['to'](util[_0xa77b('0x19')]('mail:queue:%s',_0x1c6395[_0xa77b('0x7')]))[_0xa77b('0x1a')](_0xa77b('0x1b'),_0x1c6395);}};module[_0xa77b('0x1c')]=MailQueue;