Built motion from commit 10af8726.|2.6.34
[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 _0x07c3=['lodash','md5','util','../../../config/environment','defaults','redis','localhost','socket.io-emitter','name','timeout','strategy','beepall','Agents','mapAgentsId','waiting','updateRouting','updateRealtime','prototype','_rr','loggedIn','paused','available','format','mail:queue:%s','emit','mail_queue:save'];(function(_0x214fd6,_0x5cc1f3){var _0x1adb7e=function(_0x1f4af8){while(--_0x1f4af8){_0x214fd6['push'](_0x214fd6['shift']());}};_0x1adb7e(++_0x5cc1f3);}(_0x07c3,0x82));var _0x307c=function(_0x294b6,_0x2907ae){_0x294b6=_0x294b6-0x0;var _0x38bb97=_0x07c3[_0x294b6];return _0x38bb97;};'use strict';var _=require(_0x307c('0x0'));var md5=require(_0x307c('0x1'));var util=require(_0x307c('0x2'));var Redis=require('ioredis');var config=require(_0x307c('0x3'));config['redis']=_[_0x307c('0x4')](config[_0x307c('0x5')],{'host':_0x307c('0x6'),'port':0x18eb});var io=require(_0x307c('0x7'))(new Redis(config[_0x307c('0x5')]));function MailQueue(_0x229bf4){this['id']=_0x229bf4['id']||0x0;this[_0x307c('0x8')]=_0x229bf4[_0x307c('0x8')]||'';this[_0x307c('0x9')]=_0x229bf4['timeout']||0xa;this[_0x307c('0xa')]=_0x229bf4[_0x307c('0xa')]||_0x307c('0xb');this['Agents']=_0x229bf4[_0x307c('0xc')];this[_0x307c('0xd')]={};this[_0x307c('0xe')]=0x0;this[_0x307c('0x1')]='';this[_0x307c('0xf')]();this[_0x307c('0x10')]();}MailQueue[_0x307c('0x11')][_0x307c('0xf')]=function(){var _0x34c717=this[_0x307c('0xd')][_0x307c('0x12')];this[_0x307c('0xd')]=_['map'](this['Agents'],'id');this[_0x307c('0xd')]['_rr']=_0x34c717;};MailQueue[_0x307c('0x11')][_0x307c('0x10')]=function(){this[_0x307c('0x13')]=0x0;this[_0x307c('0x14')]=0x0;for(var _0x3d715c=0x0;_0x3d715c<this['Agents']['length'];_0x3d715c+=0x1){if(this['Agents'][_0x3d715c]['online']){this[_0x307c('0x13')]+=0x1;}if(this[_0x307c('0xc')][_0x3d715c]['mailPause']){this[_0x307c('0x14')]+=0x1;}}this['available']=this[_0x307c('0x13')]-this[_0x307c('0x14')];this['available']=this[_0x307c('0x15')]>=0x0?this[_0x307c('0x15')]:0x0;var _0x5a335f={'id':this['id'],'available':this[_0x307c('0x15')],'loggedIn':this[_0x307c('0x13')],'name':this['name'],'paused':this[_0x307c('0x14')],'waiting':this[_0x307c('0xe')]};var _0x21b190=md5(JSON['stringify'](_0x5a335f));if(this[_0x307c('0x1')]!==_0x21b190){this[_0x307c('0x1')]=_0x21b190;io['to'](util[_0x307c('0x16')](_0x307c('0x17'),_0x5a335f[_0x307c('0x8')]))[_0x307c('0x18')](_0x307c('0x19'),_0x5a335f);}};module['exports']=MailQueue;