6184d5fa0bb8a5e693cf0bbdc324a4cae6934bc8
[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 _0xd9b4=['mapAgentsId','updateRouting','prototype','map','_rr','updateRealtime','loggedIn','paused','online','mailPause','available','waiting','stringify','format','mail:queue:%s','mail_queue:save','lodash','md5','util','ioredis','../../../config/environment','redis','defaults','name','timeout','strategy','Agents'];(function(_0x4ca0af,_0x37d4bb){var _0x4cc8df=function(_0x185798){while(--_0x185798){_0x4ca0af['push'](_0x4ca0af['shift']());}};_0x4cc8df(++_0x37d4bb);}(_0xd9b4,0x1c0));var _0x4d9b=function(_0x38c9df,_0x322b20){_0x38c9df=_0x38c9df-0x0;var _0x1b315a=_0xd9b4[_0x38c9df];return _0x1b315a;};'use strict';var _=require(_0x4d9b('0x0'));var md5=require(_0x4d9b('0x1'));var util=require(_0x4d9b('0x2'));var Redis=require(_0x4d9b('0x3'));var config=require(_0x4d9b('0x4'));config[_0x4d9b('0x5')]=_[_0x4d9b('0x6')](config[_0x4d9b('0x5')],{'host':'localhost','port':0x18eb});var io=require('socket.io-emitter')(new Redis(config[_0x4d9b('0x5')]));function MailQueue(_0x52b990){this['id']=_0x52b990['id']||0x0;this[_0x4d9b('0x7')]=_0x52b990[_0x4d9b('0x7')]||'';this[_0x4d9b('0x8')]=_0x52b990[_0x4d9b('0x8')]||0xa;this[_0x4d9b('0x9')]=_0x52b990[_0x4d9b('0x9')]||'beepall';this[_0x4d9b('0xa')]=_0x52b990['Agents'];this[_0x4d9b('0xb')]={};this['waiting']=0x0;this['md5']='';this[_0x4d9b('0xc')]();this['updateRealtime']();}MailQueue[_0x4d9b('0xd')][_0x4d9b('0xc')]=function(){var _0x5d2d29=this[_0x4d9b('0xb')]['_rr'];this[_0x4d9b('0xb')]=_[_0x4d9b('0xe')](this[_0x4d9b('0xa')],'id');this[_0x4d9b('0xb')][_0x4d9b('0xf')]=_0x5d2d29;};MailQueue['prototype'][_0x4d9b('0x10')]=function(){this[_0x4d9b('0x11')]=0x0;this[_0x4d9b('0x12')]=0x0;for(var _0x3e5146=0x0;_0x3e5146<this[_0x4d9b('0xa')]['length'];_0x3e5146+=0x1){if(this[_0x4d9b('0xa')][_0x3e5146][_0x4d9b('0x13')]){this[_0x4d9b('0x11')]+=0x1;}if(this[_0x4d9b('0xa')][_0x3e5146][_0x4d9b('0x14')]){this[_0x4d9b('0x12')]+=0x1;}}this[_0x4d9b('0x15')]=this[_0x4d9b('0x11')]-this[_0x4d9b('0x12')];this[_0x4d9b('0x15')]=this['available']>=0x0?this[_0x4d9b('0x15')]:0x0;var _0x22eada={'id':this['id'],'available':this['available'],'loggedIn':this[_0x4d9b('0x11')],'name':this[_0x4d9b('0x7')],'paused':this[_0x4d9b('0x12')],'waiting':this[_0x4d9b('0x16')]};var _0x1d1f71=md5(JSON[_0x4d9b('0x17')](_0x22eada));if(this[_0x4d9b('0x1')]!==_0x1d1f71){this[_0x4d9b('0x1')]=_0x1d1f71;io['to'](util[_0x4d9b('0x18')](_0x4d9b('0x19'),_0x22eada[_0x4d9b('0x7')]))['emit'](_0x4d9b('0x1a'),_0x22eada);}};module['exports']=MailQueue;