56ab808f3dc889476fefb3626d53e462c02095ae
[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 _0xed57=['online','mailPause','available','stringify','format','mail:queue:%s','emit','mail_queue:save','exports','lodash','util','ioredis','redis','localhost','socket.io-emitter','name','timeout','strategy','Agents','mapAgentsId','waiting','md5','updateRouting','updateRealtime','prototype','_rr','loggedIn','paused'];(function(_0x5538af,_0x10faad){var _0x34bb16=function(_0x1a8924){while(--_0x1a8924){_0x5538af['push'](_0x5538af['shift']());}};_0x34bb16(++_0x10faad);}(_0xed57,0x121));var _0x7ed5=function(_0x123dae,_0x21919d){_0x123dae=_0x123dae-0x0;var _0x3b3a0d=_0xed57[_0x123dae];return _0x3b3a0d;};'use strict';var _=require(_0x7ed5('0x0'));var md5=require('md5');var util=require(_0x7ed5('0x1'));var Redis=require(_0x7ed5('0x2'));var config=require('../../../config/environment');config[_0x7ed5('0x3')]=_['defaults'](config['redis'],{'host':_0x7ed5('0x4'),'port':0x18eb});var io=require(_0x7ed5('0x5'))(new Redis(config['redis']));function MailQueue(_0x4e8563){this['id']=_0x4e8563['id']||0x0;this[_0x7ed5('0x6')]=_0x4e8563[_0x7ed5('0x6')]||'';this[_0x7ed5('0x7')]=_0x4e8563[_0x7ed5('0x7')]||0xa;this[_0x7ed5('0x8')]=_0x4e8563[_0x7ed5('0x8')]||'beepall';this[_0x7ed5('0x9')]=_0x4e8563[_0x7ed5('0x9')];this[_0x7ed5('0xa')]={};this[_0x7ed5('0xb')]=0x0;this[_0x7ed5('0xc')]='';this[_0x7ed5('0xd')]();this[_0x7ed5('0xe')]();}MailQueue[_0x7ed5('0xf')][_0x7ed5('0xd')]=function(){var _0x176318=this[_0x7ed5('0xa')][_0x7ed5('0x10')];this[_0x7ed5('0xa')]=_['map'](this[_0x7ed5('0x9')],'id');this[_0x7ed5('0xa')][_0x7ed5('0x10')]=_0x176318;};MailQueue['prototype'][_0x7ed5('0xe')]=function(){this[_0x7ed5('0x11')]=0x0;this[_0x7ed5('0x12')]=0x0;for(var _0x43feb7=0x0;_0x43feb7<this['Agents']['length'];_0x43feb7+=0x1){if(this[_0x7ed5('0x9')][_0x43feb7][_0x7ed5('0x13')]){this[_0x7ed5('0x11')]+=0x1;}if(this[_0x7ed5('0x9')][_0x43feb7][_0x7ed5('0x14')]){this[_0x7ed5('0x12')]+=0x1;}}this[_0x7ed5('0x15')]=this[_0x7ed5('0x11')]-this[_0x7ed5('0x12')];this[_0x7ed5('0x15')]=this[_0x7ed5('0x15')]>=0x0?this['available']:0x0;var _0x108d98={'id':this['id'],'available':this[_0x7ed5('0x15')],'loggedIn':this['loggedIn'],'name':this[_0x7ed5('0x6')],'paused':this['paused'],'waiting':this[_0x7ed5('0xb')]};var _0x510225=md5(JSON[_0x7ed5('0x16')](_0x108d98));if(this[_0x7ed5('0xc')]!==_0x510225){this[_0x7ed5('0xc')]=_0x510225;io['to'](util[_0x7ed5('0x17')](_0x7ed5('0x18'),_0x108d98['name']))[_0x7ed5('0x19')](_0x7ed5('0x1a'),_0x108d98);}};module[_0x7ed5('0x1b')]=MailQueue;