Built motion from commit (unavailable).|2.5.22
[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 _0x73cb=['util','ioredis','redis','defaults','localhost','socket.io-emitter','name','timeout','strategy','beepall','Agents','waiting','updateRouting','prototype','mapAgentsId','_rr','updateRealtime','loggedIn','paused','length','online','mailPause','available','stringify','format','mail:queue:%s','mail_queue:save','exports','lodash','md5'];(function(_0x296cc4,_0xfdd95a){var _0xf0bddb=function(_0x3c1c8e){while(--_0x3c1c8e){_0x296cc4['push'](_0x296cc4['shift']());}};_0xf0bddb(++_0xfdd95a);}(_0x73cb,0x94));var _0xb73c=function(_0x4b135d,_0x5c2cc7){_0x4b135d=_0x4b135d-0x0;var _0x4aaba0=_0x73cb[_0x4b135d];return _0x4aaba0;};'use strict';var _=require(_0xb73c('0x0'));var md5=require(_0xb73c('0x1'));var util=require(_0xb73c('0x2'));var Redis=require(_0xb73c('0x3'));var config=require('../../../config/environment');config[_0xb73c('0x4')]=_[_0xb73c('0x5')](config[_0xb73c('0x4')],{'host':_0xb73c('0x6'),'port':0x18eb});var io=require(_0xb73c('0x7'))(new Redis(config[_0xb73c('0x4')]));function MailQueue(_0x132e02){this['id']=_0x132e02['id']||0x0;this[_0xb73c('0x8')]=_0x132e02[_0xb73c('0x8')]||'';this[_0xb73c('0x9')]=_0x132e02[_0xb73c('0x9')]||0xa;this[_0xb73c('0xa')]=_0x132e02[_0xb73c('0xa')]||_0xb73c('0xb');this['Agents']=_0x132e02[_0xb73c('0xc')];this['mapAgentsId']={};this[_0xb73c('0xd')]=0x0;this['md5']='';this[_0xb73c('0xe')]();this['updateRealtime']();}MailQueue[_0xb73c('0xf')][_0xb73c('0xe')]=function(){var _0x477060=this[_0xb73c('0x10')]['_rr'];this[_0xb73c('0x10')]=_['map'](this[_0xb73c('0xc')],'id');this[_0xb73c('0x10')][_0xb73c('0x11')]=_0x477060;};MailQueue['prototype'][_0xb73c('0x12')]=function(){this[_0xb73c('0x13')]=0x0;this[_0xb73c('0x14')]=0x0;for(var _0x1423fc=0x0;_0x1423fc<this[_0xb73c('0xc')][_0xb73c('0x15')];_0x1423fc+=0x1){if(this['Agents'][_0x1423fc][_0xb73c('0x16')]){this[_0xb73c('0x13')]+=0x1;}if(this[_0xb73c('0xc')][_0x1423fc][_0xb73c('0x17')]){this[_0xb73c('0x14')]+=0x1;}}this[_0xb73c('0x18')]=this[_0xb73c('0x13')]-this['paused'];this[_0xb73c('0x18')]=this[_0xb73c('0x18')]>=0x0?this[_0xb73c('0x18')]:0x0;var _0x221b80={'id':this['id'],'available':this[_0xb73c('0x18')],'loggedIn':this[_0xb73c('0x13')],'name':this[_0xb73c('0x8')],'paused':this[_0xb73c('0x14')],'waiting':this['waiting']};var _0x47c79a=md5(JSON[_0xb73c('0x19')](_0x221b80));if(this[_0xb73c('0x1')]!==_0x47c79a){this[_0xb73c('0x1')]=_0x47c79a;io['to'](util[_0xb73c('0x1a')](_0xb73c('0x1b'),_0x221b80[_0xb73c('0x8')]))['emit'](_0xb73c('0x1c'),_0x221b80);}};module[_0xb73c('0x1d')]=MailQueue;