60620c2ae48ac5768a6011b39e7a3e4fc1b7560a
[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 _0x1cbb=['md5','format','mail:queue:%s','emit','mail_queue:save','exports','util','ioredis','../../../config/environment','localhost','redis','timeout','strategy','beepall','mapAgentsId','waiting','updateRouting','updateRealtime','prototype','map','Agents','loggedIn','paused','length','online','mailPause','available','name','stringify'];(function(_0x31f5e1,_0x5d8b29){var _0x521cfd=function(_0x2c2b1d){while(--_0x2c2b1d){_0x31f5e1['push'](_0x31f5e1['shift']());}};_0x521cfd(++_0x5d8b29);}(_0x1cbb,0x1f3));var _0xb1cb=function(_0x11f012,_0xd13229){_0x11f012=_0x11f012-0x0;var _0x4602f0=_0x1cbb[_0x11f012];return _0x4602f0;};'use strict';var _=require('lodash');var md5=require('md5');var util=require(_0xb1cb('0x0'));var Redis=require(_0xb1cb('0x1'));var config=require(_0xb1cb('0x2'));config['redis']=_['defaults'](config['redis'],{'host':_0xb1cb('0x3'),'port':0x18eb});var io=require('socket.io-emitter')(new Redis(config[_0xb1cb('0x4')]));function MailQueue(_0x3e75c7){this['id']=_0x3e75c7['id']||0x0;this['name']=_0x3e75c7['name']||'';this['timeout']=_0x3e75c7[_0xb1cb('0x5')]||0xa;this['strategy']=_0x3e75c7[_0xb1cb('0x6')]||_0xb1cb('0x7');this['Agents']=_0x3e75c7['Agents'];this[_0xb1cb('0x8')]={};this[_0xb1cb('0x9')]=0x0;this['md5']='';this[_0xb1cb('0xa')]();this[_0xb1cb('0xb')]();}MailQueue[_0xb1cb('0xc')][_0xb1cb('0xa')]=function(){var _0x1f9ac9=this[_0xb1cb('0x8')]['_rr'];this['mapAgentsId']=_[_0xb1cb('0xd')](this[_0xb1cb('0xe')],'id');this[_0xb1cb('0x8')]['_rr']=_0x1f9ac9;};MailQueue[_0xb1cb('0xc')]['updateRealtime']=function(){this[_0xb1cb('0xf')]=0x0;this[_0xb1cb('0x10')]=0x0;for(var _0x58c14f=0x0;_0x58c14f<this[_0xb1cb('0xe')][_0xb1cb('0x11')];_0x58c14f+=0x1){if(this[_0xb1cb('0xe')][_0x58c14f][_0xb1cb('0x12')]){this[_0xb1cb('0xf')]+=0x1;}if(this[_0xb1cb('0xe')][_0x58c14f][_0xb1cb('0x13')]){this[_0xb1cb('0x10')]+=0x1;}}this[_0xb1cb('0x14')]=this[_0xb1cb('0xf')]-this[_0xb1cb('0x10')];this[_0xb1cb('0x14')]=this[_0xb1cb('0x14')]>=0x0?this[_0xb1cb('0x14')]:0x0;var _0x209801={'id':this['id'],'available':this[_0xb1cb('0x14')],'loggedIn':this[_0xb1cb('0xf')],'name':this[_0xb1cb('0x15')],'paused':this[_0xb1cb('0x10')],'waiting':this['waiting']};var _0x468029=md5(JSON[_0xb1cb('0x16')](_0x209801));if(this['md5']!==_0x468029){this[_0xb1cb('0x17')]=_0x468029;io['to'](util[_0xb1cb('0x18')](_0xb1cb('0x19'),_0x209801[_0xb1cb('0x15')]))[_0xb1cb('0x1a')](_0xb1cb('0x1b'),_0x209801);}};module[_0xb1cb('0x1c')]=MailQueue;