Built motion from commit (unavailable).|2.5.29
[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 _0x1c2e=['md5','redis','localhost','socket.io-emitter','name','timeout','strategy','beepall','Agents','mapAgentsId','waiting','updateRouting','prototype','_rr','updateRealtime','paused','length','online','loggedIn','mailPause','stringify','emit','exports'];(function(_0x122ef9,_0x451d2a){var _0x42fba0=function(_0x17c9d3){while(--_0x17c9d3){_0x122ef9['push'](_0x122ef9['shift']());}};_0x42fba0(++_0x451d2a);}(_0x1c2e,0xb8));var _0xe1c2=function(_0x171161,_0x5bdae8){_0x171161=_0x171161-0x0;var _0xb2dec3=_0x1c2e[_0x171161];return _0xb2dec3;};'use strict';var _=require('lodash');var md5=require(_0xe1c2('0x0'));var util=require('util');var Redis=require('ioredis');var config=require('../../../config/environment');config[_0xe1c2('0x1')]=_['defaults'](config[_0xe1c2('0x1')],{'host':_0xe1c2('0x2'),'port':0x18eb});var io=require(_0xe1c2('0x3'))(new Redis(config[_0xe1c2('0x1')]));function MailQueue(_0x1d0f5d){this['id']=_0x1d0f5d['id']||0x0;this[_0xe1c2('0x4')]=_0x1d0f5d['name']||'';this[_0xe1c2('0x5')]=_0x1d0f5d[_0xe1c2('0x5')]||0xa;this[_0xe1c2('0x6')]=_0x1d0f5d['strategy']||_0xe1c2('0x7');this['Agents']=_0x1d0f5d[_0xe1c2('0x8')];this[_0xe1c2('0x9')]={};this[_0xe1c2('0xa')]=0x0;this[_0xe1c2('0x0')]='';this[_0xe1c2('0xb')]();this['updateRealtime']();}MailQueue[_0xe1c2('0xc')][_0xe1c2('0xb')]=function(){var _0x17f7a0=this['mapAgentsId'][_0xe1c2('0xd')];this['mapAgentsId']=_['map'](this['Agents'],'id');this[_0xe1c2('0x9')][_0xe1c2('0xd')]=_0x17f7a0;};MailQueue[_0xe1c2('0xc')][_0xe1c2('0xe')]=function(){this['loggedIn']=0x0;this[_0xe1c2('0xf')]=0x0;for(var _0x28b526=0x0;_0x28b526<this[_0xe1c2('0x8')][_0xe1c2('0x10')];_0x28b526+=0x1){if(this[_0xe1c2('0x8')][_0x28b526][_0xe1c2('0x11')]){this[_0xe1c2('0x12')]+=0x1;}if(this[_0xe1c2('0x8')][_0x28b526][_0xe1c2('0x13')]){this[_0xe1c2('0xf')]+=0x1;}}this['available']=this[_0xe1c2('0x12')]-this[_0xe1c2('0xf')];this['available']=this['available']>=0x0?this['available']:0x0;var _0x30216b={'id':this['id'],'available':this['available'],'loggedIn':this['loggedIn'],'name':this['name'],'paused':this['paused'],'waiting':this[_0xe1c2('0xa')]};var _0x38a45c=md5(JSON[_0xe1c2('0x14')](_0x30216b));if(this[_0xe1c2('0x0')]!==_0x38a45c){this['md5']=_0x38a45c;io['to'](util['format']('mail:queue:%s',_0x30216b[_0xe1c2('0x4')]))[_0xe1c2('0x15')]('mail_queue:save',_0x30216b);}};module[_0xe1c2('0x16')]=MailQueue;