0b883f53d135e1a7a333fda84ec3d0906adabda0
[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 _0x2dac=['../../../config/environment','defaults','redis','localhost','name','timeout','strategy','beepall','Agents','mapAgentsId','waiting','updateRealtime','prototype','updateRouting','map','paused','length','loggedIn','available','stringify','format','mail:queue:%s','emit','mail_queue:save','exports','md5','ioredis'];(function(_0x158a70,_0x503d58){var _0x2bf62f=function(_0xb50f31){while(--_0xb50f31){_0x158a70['push'](_0x158a70['shift']());}};_0x2bf62f(++_0x503d58);}(_0x2dac,0xd6));var _0xc2da=function(_0x45d569,_0x319867){_0x45d569=_0x45d569-0x0;var _0x4e9425=_0x2dac[_0x45d569];return _0x4e9425;};'use strict';var _=require('lodash');var md5=require(_0xc2da('0x0'));var util=require('util');var Redis=require(_0xc2da('0x1'));var config=require(_0xc2da('0x2'));config['redis']=_[_0xc2da('0x3')](config[_0xc2da('0x4')],{'host':_0xc2da('0x5'),'port':0x18eb});var io=require('socket.io-emitter')(new Redis(config['redis']));function MailQueue(_0x1fcd33){this['id']=_0x1fcd33['id']||0x0;this[_0xc2da('0x6')]=_0x1fcd33[_0xc2da('0x6')]||'';this[_0xc2da('0x7')]=_0x1fcd33[_0xc2da('0x7')]||0xa;this[_0xc2da('0x8')]=_0x1fcd33[_0xc2da('0x8')]||_0xc2da('0x9');this[_0xc2da('0xa')]=_0x1fcd33[_0xc2da('0xa')];this[_0xc2da('0xb')]={};this[_0xc2da('0xc')]=0x0;this[_0xc2da('0x0')]='';this['updateRouting']();this[_0xc2da('0xd')]();}MailQueue[_0xc2da('0xe')][_0xc2da('0xf')]=function(){var _0x4fac01=this['mapAgentsId']['_rr'];this['mapAgentsId']=_[_0xc2da('0x10')](this[_0xc2da('0xa')],'id');this[_0xc2da('0xb')]['_rr']=_0x4fac01;};MailQueue[_0xc2da('0xe')][_0xc2da('0xd')]=function(){this['loggedIn']=0x0;this[_0xc2da('0x11')]=0x0;for(var _0xbc890c=0x0;_0xbc890c<this[_0xc2da('0xa')][_0xc2da('0x12')];_0xbc890c+=0x1){if(this[_0xc2da('0xa')][_0xbc890c]['online']){this[_0xc2da('0x13')]+=0x1;}if(this['Agents'][_0xbc890c]['mailPause']){this[_0xc2da('0x11')]+=0x1;}}this[_0xc2da('0x14')]=this[_0xc2da('0x13')]-this[_0xc2da('0x11')];this[_0xc2da('0x14')]=this[_0xc2da('0x14')]>=0x0?this[_0xc2da('0x14')]:0x0;var _0x37c484={'id':this['id'],'available':this[_0xc2da('0x14')],'loggedIn':this[_0xc2da('0x13')],'name':this[_0xc2da('0x6')],'paused':this['paused'],'waiting':this[_0xc2da('0xc')]};var _0x1fbbee=md5(JSON[_0xc2da('0x15')](_0x37c484));if(this[_0xc2da('0x0')]!==_0x1fbbee){this[_0xc2da('0x0')]=_0x1fbbee;io['to'](util[_0xc2da('0x16')](_0xc2da('0x17'),_0x37c484[_0xc2da('0x6')]))[_0xc2da('0x18')](_0xc2da('0x19'),_0x37c484);}};module[_0xc2da('0x1a')]=MailQueue;