Built motion from commit fa4c4286.|2.6.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 _0x36c8=['defaults','localhost','socket.io-emitter','name','timeout','strategy','Agents','mapAgentsId','waiting','prototype','updateRouting','updateRealtime','loggedIn','paused','length','online','mailPause','available','stringify','emit','mail_queue:save','exports','md5','util','ioredis','redis'];(function(_0x2d0fff,_0x128adc){var _0x40c5b1=function(_0x2bbb86){while(--_0x2bbb86){_0x2d0fff['push'](_0x2d0fff['shift']());}};_0x40c5b1(++_0x128adc);}(_0x36c8,0x7e));var _0x836c=function(_0x5295a9,_0x2881d6){_0x5295a9=_0x5295a9-0x0;var _0x455975=_0x36c8[_0x5295a9];return _0x455975;};'use strict';var _=require('lodash');var md5=require(_0x836c('0x0'));var util=require(_0x836c('0x1'));var Redis=require(_0x836c('0x2'));var config=require('../../../config/environment');config[_0x836c('0x3')]=_[_0x836c('0x4')](config['redis'],{'host':_0x836c('0x5'),'port':0x18eb});var io=require(_0x836c('0x6'))(new Redis(config[_0x836c('0x3')]));function MailQueue(_0x41fe9a){this['id']=_0x41fe9a['id']||0x0;this[_0x836c('0x7')]=_0x41fe9a[_0x836c('0x7')]||'';this['timeout']=_0x41fe9a[_0x836c('0x8')]||0xa;this[_0x836c('0x9')]=_0x41fe9a[_0x836c('0x9')]||'beepall';this['Agents']=_0x41fe9a[_0x836c('0xa')];this[_0x836c('0xb')]={};this[_0x836c('0xc')]=0x0;this[_0x836c('0x0')]='';this['updateRouting']();this['updateRealtime']();}MailQueue[_0x836c('0xd')][_0x836c('0xe')]=function(){var _0x51da4a=this[_0x836c('0xb')]['_rr'];this['mapAgentsId']=_['map'](this[_0x836c('0xa')],'id');this[_0x836c('0xb')]['_rr']=_0x51da4a;};MailQueue[_0x836c('0xd')][_0x836c('0xf')]=function(){this[_0x836c('0x10')]=0x0;this[_0x836c('0x11')]=0x0;for(var _0x19c134=0x0;_0x19c134<this['Agents'][_0x836c('0x12')];_0x19c134+=0x1){if(this[_0x836c('0xa')][_0x19c134][_0x836c('0x13')]){this[_0x836c('0x10')]+=0x1;}if(this[_0x836c('0xa')][_0x19c134][_0x836c('0x14')]){this[_0x836c('0x11')]+=0x1;}}this[_0x836c('0x15')]=this['loggedIn']-this[_0x836c('0x11')];this[_0x836c('0x15')]=this[_0x836c('0x15')]>=0x0?this[_0x836c('0x15')]:0x0;var _0x469cb0={'id':this['id'],'available':this[_0x836c('0x15')],'loggedIn':this['loggedIn'],'name':this[_0x836c('0x7')],'paused':this[_0x836c('0x11')],'waiting':this['waiting']};var _0x32f748=md5(JSON[_0x836c('0x16')](_0x469cb0));if(this[_0x836c('0x0')]!==_0x32f748){this[_0x836c('0x0')]=_0x32f748;io['to'](util['format']('mail:queue:%s',_0x469cb0[_0x836c('0x7')]))[_0x836c('0x17')](_0x836c('0x18'),_0x469cb0);}};module[_0x836c('0x19')]=MailQueue;