Built motion from commit 43538d75.|2.5.35
[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 _0xcda4=['mapAgentsId','waiting','md5','updateRealtime','updateRouting','_rr','map','prototype','loggedIn','paused','length','online','mailPause','available','stringify','mail:queue:%s','exports','util','ioredis','redis','defaults','localhost','socket.io-emitter','name','timeout','strategy','Agents'];(function(_0x2ce66b,_0x5753c8){var _0x5afbfb=function(_0x597777){while(--_0x597777){_0x2ce66b['push'](_0x2ce66b['shift']());}};_0x5afbfb(++_0x5753c8);}(_0xcda4,0x155));var _0x4cda=function(_0x5e9661,_0x5622a6){_0x5e9661=_0x5e9661-0x0;var _0x8b24f6=_0xcda4[_0x5e9661];return _0x8b24f6;};'use strict';var _=require('lodash');var md5=require('md5');var util=require(_0x4cda('0x0'));var Redis=require(_0x4cda('0x1'));var config=require('../../../config/environment');config[_0x4cda('0x2')]=_[_0x4cda('0x3')](config[_0x4cda('0x2')],{'host':_0x4cda('0x4'),'port':0x18eb});var io=require(_0x4cda('0x5'))(new Redis(config[_0x4cda('0x2')]));function MailQueue(_0x564104){this['id']=_0x564104['id']||0x0;this[_0x4cda('0x6')]=_0x564104[_0x4cda('0x6')]||'';this[_0x4cda('0x7')]=_0x564104[_0x4cda('0x7')]||0xa;this[_0x4cda('0x8')]=_0x564104[_0x4cda('0x8')]||'beepall';this[_0x4cda('0x9')]=_0x564104['Agents'];this[_0x4cda('0xa')]={};this[_0x4cda('0xb')]=0x0;this[_0x4cda('0xc')]='';this['updateRouting']();this[_0x4cda('0xd')]();}MailQueue['prototype'][_0x4cda('0xe')]=function(){var _0x8e435d=this[_0x4cda('0xa')][_0x4cda('0xf')];this[_0x4cda('0xa')]=_[_0x4cda('0x10')](this[_0x4cda('0x9')],'id');this['mapAgentsId'][_0x4cda('0xf')]=_0x8e435d;};MailQueue[_0x4cda('0x11')][_0x4cda('0xd')]=function(){this[_0x4cda('0x12')]=0x0;this[_0x4cda('0x13')]=0x0;for(var _0x205671=0x0;_0x205671<this[_0x4cda('0x9')][_0x4cda('0x14')];_0x205671+=0x1){if(this['Agents'][_0x205671][_0x4cda('0x15')]){this[_0x4cda('0x12')]+=0x1;}if(this['Agents'][_0x205671][_0x4cda('0x16')]){this['paused']+=0x1;}}this[_0x4cda('0x17')]=this[_0x4cda('0x12')]-this[_0x4cda('0x13')];this['available']=this[_0x4cda('0x17')]>=0x0?this[_0x4cda('0x17')]:0x0;var _0x1eb6c0={'id':this['id'],'available':this['available'],'loggedIn':this[_0x4cda('0x12')],'name':this['name'],'paused':this[_0x4cda('0x13')],'waiting':this[_0x4cda('0xb')]};var _0x4375dc=md5(JSON[_0x4cda('0x18')](_0x1eb6c0));if(this[_0x4cda('0xc')]!==_0x4375dc){this[_0x4cda('0xc')]=_0x4375dc;io['to'](util['format'](_0x4cda('0x19'),_0x1eb6c0[_0x4cda('0x6')]))['emit']('mail_queue:save',_0x1eb6c0);}};module[_0x4cda('0x1a')]=MailQueue;