Built motion from commit 85328c08.|2.5.50
[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 _0x175a=['online','mailPause','available','stringify','mail:queue:%s','emit','mail_queue:save','exports','lodash','md5','util','ioredis','defaults','localhost','socket.io-emitter','name','timeout','strategy','beepall','Agents','prototype','mapAgentsId','_rr','updateRealtime','loggedIn','paused','length'];(function(_0x3947c9,_0x4d6c97){var _0x2e7871=function(_0x1236cc){while(--_0x1236cc){_0x3947c9['push'](_0x3947c9['shift']());}};_0x2e7871(++_0x4d6c97);}(_0x175a,0x19d));var _0xa175=function(_0x180b51,_0x4cf36d){_0x180b51=_0x180b51-0x0;var _0x92599f=_0x175a[_0x180b51];return _0x92599f;};'use strict';var _=require(_0xa175('0x0'));var md5=require(_0xa175('0x1'));var util=require(_0xa175('0x2'));var Redis=require(_0xa175('0x3'));var config=require('../../../config/environment');config['redis']=_[_0xa175('0x4')](config['redis'],{'host':_0xa175('0x5'),'port':0x18eb});var io=require(_0xa175('0x6'))(new Redis(config['redis']));function MailQueue(_0x3ebacb){this['id']=_0x3ebacb['id']||0x0;this[_0xa175('0x7')]=_0x3ebacb['name']||'';this[_0xa175('0x8')]=_0x3ebacb['timeout']||0xa;this[_0xa175('0x9')]=_0x3ebacb[_0xa175('0x9')]||_0xa175('0xa');this[_0xa175('0xb')]=_0x3ebacb[_0xa175('0xb')];this['mapAgentsId']={};this['waiting']=0x0;this[_0xa175('0x1')]='';this['updateRouting']();this['updateRealtime']();}MailQueue[_0xa175('0xc')]['updateRouting']=function(){var _0x31f7bd=this[_0xa175('0xd')]['_rr'];this[_0xa175('0xd')]=_['map'](this[_0xa175('0xb')],'id');this[_0xa175('0xd')][_0xa175('0xe')]=_0x31f7bd;};MailQueue['prototype'][_0xa175('0xf')]=function(){this[_0xa175('0x10')]=0x0;this[_0xa175('0x11')]=0x0;for(var _0x191646=0x0;_0x191646<this[_0xa175('0xb')][_0xa175('0x12')];_0x191646+=0x1){if(this['Agents'][_0x191646][_0xa175('0x13')]){this['loggedIn']+=0x1;}if(this[_0xa175('0xb')][_0x191646][_0xa175('0x14')]){this['paused']+=0x1;}}this[_0xa175('0x15')]=this['loggedIn']-this['paused'];this['available']=this[_0xa175('0x15')]>=0x0?this[_0xa175('0x15')]:0x0;var _0x27eef0={'id':this['id'],'available':this[_0xa175('0x15')],'loggedIn':this[_0xa175('0x10')],'name':this['name'],'paused':this[_0xa175('0x11')],'waiting':this['waiting']};var _0x24a658=md5(JSON[_0xa175('0x16')](_0x27eef0));if(this[_0xa175('0x1')]!==_0x24a658){this[_0xa175('0x1')]=_0x24a658;io['to'](util['format'](_0xa175('0x17'),_0x27eef0['name']))[_0xa175('0x18')](_0xa175('0x19'),_0x27eef0);}};module[_0xa175('0x1a')]=MailQueue;