Built motion from commit (unavailable).|2.4.18
[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 _0x4075=['defaults','localhost','socket.io-emitter','name','timeout','Agents','waiting','updateRouting','updateRealtime','prototype','mapAgentsId','_rr','paused','length','loggedIn','mailPause','available','stringify','format','mail:queue:%s','emit','exports','lodash','md5','../../../config/environment','redis'];(function(_0x3c9a99,_0x277cf0){var _0x39e144=function(_0x2ede7b){while(--_0x2ede7b){_0x3c9a99['push'](_0x3c9a99['shift']());}};_0x39e144(++_0x277cf0);}(_0x4075,0xcc));var _0x5407=function(_0x5a60ce,_0x48f080){_0x5a60ce=_0x5a60ce-0x0;var _0x393e5e=_0x4075[_0x5a60ce];return _0x393e5e;};'use strict';var _=require(_0x5407('0x0'));var md5=require(_0x5407('0x1'));var util=require('util');var Redis=require('ioredis');var config=require(_0x5407('0x2'));config[_0x5407('0x3')]=_[_0x5407('0x4')](config[_0x5407('0x3')],{'host':_0x5407('0x5'),'port':0x18eb});var io=require(_0x5407('0x6'))(new Redis(config[_0x5407('0x3')]));function MailQueue(_0x3ebc84){this['id']=_0x3ebc84['id']||0x0;this[_0x5407('0x7')]=_0x3ebc84['name']||'';this[_0x5407('0x8')]=_0x3ebc84[_0x5407('0x8')]||0xa;this['strategy']=_0x3ebc84['strategy']||'beepall';this[_0x5407('0x9')]=_0x3ebc84['Agents'];this['mapAgentsId']={};this[_0x5407('0xa')]=0x0;this[_0x5407('0x1')]='';this[_0x5407('0xb')]();this[_0x5407('0xc')]();}MailQueue[_0x5407('0xd')]['updateRouting']=function(){var _0x3d51b7=this[_0x5407('0xe')][_0x5407('0xf')];this[_0x5407('0xe')]=_['map'](this[_0x5407('0x9')],'id');this[_0x5407('0xe')][_0x5407('0xf')]=_0x3d51b7;};MailQueue[_0x5407('0xd')][_0x5407('0xc')]=function(){this['loggedIn']=0x0;this[_0x5407('0x10')]=0x0;for(var _0x4b6767=0x0;_0x4b6767<this['Agents'][_0x5407('0x11')];_0x4b6767+=0x1){if(this[_0x5407('0x9')][_0x4b6767]['online']){this[_0x5407('0x12')]+=0x1;}if(this[_0x5407('0x9')][_0x4b6767][_0x5407('0x13')]){this[_0x5407('0x10')]+=0x1;}}this[_0x5407('0x14')]=this['loggedIn']-this['paused'];this['available']=this[_0x5407('0x14')]>=0x0?this[_0x5407('0x14')]:0x0;var _0x1a1849={'id':this['id'],'available':this[_0x5407('0x14')],'loggedIn':this[_0x5407('0x12')],'name':this[_0x5407('0x7')],'paused':this[_0x5407('0x10')],'waiting':this[_0x5407('0xa')]};var _0xf1219b=md5(JSON[_0x5407('0x15')](_0x1a1849));if(this[_0x5407('0x1')]!==_0xf1219b){this[_0x5407('0x1')]=_0xf1219b;io['to'](util[_0x5407('0x16')](_0x5407('0x17'),_0x1a1849[_0x5407('0x7')]))[_0x5407('0x18')]('mail_queue:save',_0x1a1849);}};module[_0x5407('0x19')]=MailQueue;