c3a04003bead8b234ebba94da3b83811a0059de7
[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 _0x62d2=['mail_queue:save','exports','lodash','md5','util','ioredis','../../../config/environment','defaults','redis','name','timeout','strategy','beepall','mapAgentsId','waiting','updateRouting','updateRealtime','_rr','prototype','loggedIn','paused','Agents','mailPause','available','stringify','mail:queue:%s','emit'];(function(_0x167c44,_0xe53cd5){var _0x22ab56=function(_0x38f89a){while(--_0x38f89a){_0x167c44['push'](_0x167c44['shift']());}};_0x22ab56(++_0xe53cd5);}(_0x62d2,0x1e8));var _0x262d=function(_0x5815af,_0x361f0b){_0x5815af=_0x5815af-0x0;var _0x3f14cb=_0x62d2[_0x5815af];return _0x3f14cb;};'use strict';var _=require(_0x262d('0x0'));var md5=require(_0x262d('0x1'));var util=require(_0x262d('0x2'));var Redis=require(_0x262d('0x3'));var config=require(_0x262d('0x4'));config['redis']=_[_0x262d('0x5')](config[_0x262d('0x6')],{'host':'localhost','port':0x18eb});var io=require('socket.io-emitter')(new Redis(config[_0x262d('0x6')]));function MailQueue(_0x227774){this['id']=_0x227774['id']||0x0;this['name']=_0x227774[_0x262d('0x7')]||'';this['timeout']=_0x227774[_0x262d('0x8')]||0xa;this['strategy']=_0x227774[_0x262d('0x9')]||_0x262d('0xa');this['Agents']=_0x227774['Agents'];this[_0x262d('0xb')]={};this[_0x262d('0xc')]=0x0;this[_0x262d('0x1')]='';this[_0x262d('0xd')]();this[_0x262d('0xe')]();}MailQueue['prototype']['updateRouting']=function(){var _0xb63ea1=this[_0x262d('0xb')][_0x262d('0xf')];this[_0x262d('0xb')]=_['map'](this['Agents'],'id');this[_0x262d('0xb')]['_rr']=_0xb63ea1;};MailQueue[_0x262d('0x10')]['updateRealtime']=function(){this[_0x262d('0x11')]=0x0;this[_0x262d('0x12')]=0x0;for(var _0x3cad0b=0x0;_0x3cad0b<this[_0x262d('0x13')]['length'];_0x3cad0b+=0x1){if(this['Agents'][_0x3cad0b]['online']){this[_0x262d('0x11')]+=0x1;}if(this[_0x262d('0x13')][_0x3cad0b][_0x262d('0x14')]){this[_0x262d('0x12')]+=0x1;}}this[_0x262d('0x15')]=this['loggedIn']-this['paused'];this['available']=this[_0x262d('0x15')]>=0x0?this['available']:0x0;var _0x57b21a={'id':this['id'],'available':this['available'],'loggedIn':this[_0x262d('0x11')],'name':this['name'],'paused':this[_0x262d('0x12')],'waiting':this[_0x262d('0xc')]};var _0x5c7f33=md5(JSON[_0x262d('0x16')](_0x57b21a));if(this[_0x262d('0x1')]!==_0x5c7f33){this['md5']=_0x5c7f33;io['to'](util['format'](_0x262d('0x17'),_0x57b21a['name']))[_0x262d('0x18')](_0x262d('0x19'),_0x57b21a);}};module[_0x262d('0x1a')]=MailQueue;