ee6c98d8d91f53f6c7f58d505d11c66d632d81d9
[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 _0xa805=['updateRealtime','prototype','_rr','map','loggedIn','paused','available','md5','format','mail:queue:%s','mail_queue:save','exports','lodash','defaults','localhost','redis','name','timeout','strategy','beepall','Agents','mapAgentsId','waiting','updateRouting'];(function(_0x4c946a,_0x18ba2b){var _0x1ffc7f=function(_0x22cc72){while(--_0x22cc72){_0x4c946a['push'](_0x4c946a['shift']());}};_0x1ffc7f(++_0x18ba2b);}(_0xa805,0x114));var _0x5a80=function(_0x41064a,_0x51e89a){_0x41064a=_0x41064a-0x0;var _0x11a94f=_0xa805[_0x41064a];return _0x11a94f;};'use strict';var _=require(_0x5a80('0x0'));var md5=require('md5');var util=require('util');var Redis=require('ioredis');var config=require('../../../config/environment');config['redis']=_[_0x5a80('0x1')](config['redis'],{'host':_0x5a80('0x2'),'port':0x18eb});var io=require('socket.io-emitter')(new Redis(config[_0x5a80('0x3')]));function MailQueue(_0x31bac2){this['id']=_0x31bac2['id']||0x0;this['name']=_0x31bac2[_0x5a80('0x4')]||'';this[_0x5a80('0x5')]=_0x31bac2[_0x5a80('0x5')]||0xa;this[_0x5a80('0x6')]=_0x31bac2[_0x5a80('0x6')]||_0x5a80('0x7');this[_0x5a80('0x8')]=_0x31bac2['Agents'];this[_0x5a80('0x9')]={};this[_0x5a80('0xa')]=0x0;this['md5']='';this[_0x5a80('0xb')]();this[_0x5a80('0xc')]();}MailQueue[_0x5a80('0xd')][_0x5a80('0xb')]=function(){var _0x462d74=this['mapAgentsId'][_0x5a80('0xe')];this[_0x5a80('0x9')]=_[_0x5a80('0xf')](this[_0x5a80('0x8')],'id');this[_0x5a80('0x9')][_0x5a80('0xe')]=_0x462d74;};MailQueue[_0x5a80('0xd')]['updateRealtime']=function(){this[_0x5a80('0x10')]=0x0;this['paused']=0x0;for(var _0x359167=0x0;_0x359167<this[_0x5a80('0x8')]['length'];_0x359167+=0x1){if(this[_0x5a80('0x8')][_0x359167]['online']){this['loggedIn']+=0x1;}if(this['Agents'][_0x359167]['mailPause']){this[_0x5a80('0x11')]+=0x1;}}this[_0x5a80('0x12')]=this['loggedIn']-this[_0x5a80('0x11')];this[_0x5a80('0x12')]=this[_0x5a80('0x12')]>=0x0?this['available']:0x0;var _0x303223={'id':this['id'],'available':this[_0x5a80('0x12')],'loggedIn':this[_0x5a80('0x10')],'name':this[_0x5a80('0x4')],'paused':this[_0x5a80('0x11')],'waiting':this['waiting']};var _0x210f2d=md5(JSON['stringify'](_0x303223));if(this[_0x5a80('0x13')]!==_0x210f2d){this['md5']=_0x210f2d;io['to'](util[_0x5a80('0x14')](_0x5a80('0x15'),_0x303223[_0x5a80('0x4')]))['emit'](_0x5a80('0x16'),_0x303223);}};module[_0x5a80('0x17')]=MailQueue;