Built motion from commit 639a1a7f.|2.6.19
[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 _0xafa7=['name','timeout','strategy','beepall','Agents','mapAgentsId','md5','updateRouting','prototype','_rr','map','updateRealtime','loggedIn','length','online','mailPause','paused','available','waiting','stringify','format','mail:queue:%s','mail_queue:save','exports','lodash','util','ioredis','redis','localhost','socket.io-emitter'];(function(_0x4843f9,_0x4af459){var _0x193c6a=function(_0x51eca9){while(--_0x51eca9){_0x4843f9['push'](_0x4843f9['shift']());}};_0x193c6a(++_0x4af459);}(_0xafa7,0x1bc));var _0x7afa=function(_0x5a7d5f,_0x5695cb){_0x5a7d5f=_0x5a7d5f-0x0;var _0x5dcded=_0xafa7[_0x5a7d5f];return _0x5dcded;};'use strict';var _=require(_0x7afa('0x0'));var md5=require('md5');var util=require(_0x7afa('0x1'));var Redis=require(_0x7afa('0x2'));var config=require('../../../config/environment');config[_0x7afa('0x3')]=_['defaults'](config['redis'],{'host':_0x7afa('0x4'),'port':0x18eb});var io=require(_0x7afa('0x5'))(new Redis(config['redis']));function MailQueue(_0x28d76e){this['id']=_0x28d76e['id']||0x0;this[_0x7afa('0x6')]=_0x28d76e['name']||'';this[_0x7afa('0x7')]=_0x28d76e['timeout']||0xa;this[_0x7afa('0x8')]=_0x28d76e[_0x7afa('0x8')]||_0x7afa('0x9');this[_0x7afa('0xa')]=_0x28d76e[_0x7afa('0xa')];this[_0x7afa('0xb')]={};this['waiting']=0x0;this[_0x7afa('0xc')]='';this[_0x7afa('0xd')]();this['updateRealtime']();}MailQueue[_0x7afa('0xe')]['updateRouting']=function(){var _0x46639a=this[_0x7afa('0xb')][_0x7afa('0xf')];this['mapAgentsId']=_[_0x7afa('0x10')](this['Agents'],'id');this[_0x7afa('0xb')][_0x7afa('0xf')]=_0x46639a;};MailQueue[_0x7afa('0xe')][_0x7afa('0x11')]=function(){this[_0x7afa('0x12')]=0x0;this['paused']=0x0;for(var _0x21880e=0x0;_0x21880e<this[_0x7afa('0xa')][_0x7afa('0x13')];_0x21880e+=0x1){if(this[_0x7afa('0xa')][_0x21880e][_0x7afa('0x14')]){this[_0x7afa('0x12')]+=0x1;}if(this[_0x7afa('0xa')][_0x21880e][_0x7afa('0x15')]){this[_0x7afa('0x16')]+=0x1;}}this[_0x7afa('0x17')]=this[_0x7afa('0x12')]-this['paused'];this[_0x7afa('0x17')]=this[_0x7afa('0x17')]>=0x0?this[_0x7afa('0x17')]:0x0;var _0x647ba8={'id':this['id'],'available':this[_0x7afa('0x17')],'loggedIn':this['loggedIn'],'name':this[_0x7afa('0x6')],'paused':this['paused'],'waiting':this[_0x7afa('0x18')]};var _0x4c9714=md5(JSON[_0x7afa('0x19')](_0x647ba8));if(this[_0x7afa('0xc')]!==_0x4c9714){this[_0x7afa('0xc')]=_0x4c9714;io['to'](util[_0x7afa('0x1a')](_0x7afa('0x1b'),_0x647ba8[_0x7afa('0x6')]))['emit'](_0x7afa('0x1c'),_0x647ba8);}};module[_0x7afa('0x1d')]=MailQueue;