Built motion from commit (unavailable).|2.5.31
[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 _0xeca3=['lodash','util','ioredis','../../../config/environment','redis','defaults','socket.io-emitter','name','timeout','strategy','beepall','Agents','mapAgentsId','waiting','md5','updateRouting','updateRealtime','prototype','_rr','map','loggedIn','paused','length','online','available','format','mail:queue:%s','mail_queue:save','exports'];(function(_0x2f1819,_0xa7cc5c){var _0x95481b=function(_0xd969de){while(--_0xd969de){_0x2f1819['push'](_0x2f1819['shift']());}};_0x95481b(++_0xa7cc5c);}(_0xeca3,0x13f));var _0x3eca=function(_0x40a045,_0x516f0e){_0x40a045=_0x40a045-0x0;var _0x1a687c=_0xeca3[_0x40a045];return _0x1a687c;};'use strict';var _=require(_0x3eca('0x0'));var md5=require('md5');var util=require(_0x3eca('0x1'));var Redis=require(_0x3eca('0x2'));var config=require(_0x3eca('0x3'));config[_0x3eca('0x4')]=_[_0x3eca('0x5')](config[_0x3eca('0x4')],{'host':'localhost','port':0x18eb});var io=require(_0x3eca('0x6'))(new Redis(config[_0x3eca('0x4')]));function MailQueue(_0x4edf1d){this['id']=_0x4edf1d['id']||0x0;this[_0x3eca('0x7')]=_0x4edf1d[_0x3eca('0x7')]||'';this['timeout']=_0x4edf1d[_0x3eca('0x8')]||0xa;this[_0x3eca('0x9')]=_0x4edf1d[_0x3eca('0x9')]||_0x3eca('0xa');this[_0x3eca('0xb')]=_0x4edf1d[_0x3eca('0xb')];this[_0x3eca('0xc')]={};this[_0x3eca('0xd')]=0x0;this[_0x3eca('0xe')]='';this[_0x3eca('0xf')]();this[_0x3eca('0x10')]();}MailQueue[_0x3eca('0x11')][_0x3eca('0xf')]=function(){var _0x435d24=this[_0x3eca('0xc')][_0x3eca('0x12')];this[_0x3eca('0xc')]=_[_0x3eca('0x13')](this['Agents'],'id');this['mapAgentsId'][_0x3eca('0x12')]=_0x435d24;};MailQueue['prototype'][_0x3eca('0x10')]=function(){this[_0x3eca('0x14')]=0x0;this[_0x3eca('0x15')]=0x0;for(var _0xf22896=0x0;_0xf22896<this[_0x3eca('0xb')][_0x3eca('0x16')];_0xf22896+=0x1){if(this['Agents'][_0xf22896][_0x3eca('0x17')]){this[_0x3eca('0x14')]+=0x1;}if(this[_0x3eca('0xb')][_0xf22896]['mailPause']){this[_0x3eca('0x15')]+=0x1;}}this['available']=this[_0x3eca('0x14')]-this[_0x3eca('0x15')];this[_0x3eca('0x18')]=this[_0x3eca('0x18')]>=0x0?this[_0x3eca('0x18')]:0x0;var _0x374c8e={'id':this['id'],'available':this[_0x3eca('0x18')],'loggedIn':this[_0x3eca('0x14')],'name':this['name'],'paused':this[_0x3eca('0x15')],'waiting':this[_0x3eca('0xd')]};var _0x147903=md5(JSON['stringify'](_0x374c8e));if(this[_0x3eca('0xe')]!==_0x147903){this[_0x3eca('0xe')]=_0x147903;io['to'](util[_0x3eca('0x19')](_0x3eca('0x1a'),_0x374c8e['name']))['emit'](_0x3eca('0x1b'),_0x374c8e);}};module[_0x3eca('0x1c')]=MailQueue;