Built motion from commit 1fa89557.|2.6.10
[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 _0xbef1=['Agents','mapAgentsId','waiting','updateRouting','prototype','_rr','map','updateRealtime','paused','length','online','loggedIn','mailPause','available','stringify','format','mail:queue:%s','emit','mail_queue:save','exports','lodash','md5','ioredis','defaults','localhost','socket.io-emitter','name','timeout','strategy'];(function(_0x3fbafb,_0x68e1aa){var _0xb37ce4=function(_0x59008b){while(--_0x59008b){_0x3fbafb['push'](_0x3fbafb['shift']());}};_0xb37ce4(++_0x68e1aa);}(_0xbef1,0x88));var _0x1bef=function(_0x49e2b8,_0x5cf700){_0x49e2b8=_0x49e2b8-0x0;var _0x1f2213=_0xbef1[_0x49e2b8];return _0x1f2213;};'use strict';var _=require(_0x1bef('0x0'));var md5=require(_0x1bef('0x1'));var util=require('util');var Redis=require(_0x1bef('0x2'));var config=require('../../../config/environment');config['redis']=_[_0x1bef('0x3')](config['redis'],{'host':_0x1bef('0x4'),'port':0x18eb});var io=require(_0x1bef('0x5'))(new Redis(config['redis']));function MailQueue(_0x34fb21){this['id']=_0x34fb21['id']||0x0;this[_0x1bef('0x6')]=_0x34fb21[_0x1bef('0x6')]||'';this['timeout']=_0x34fb21[_0x1bef('0x7')]||0xa;this[_0x1bef('0x8')]=_0x34fb21[_0x1bef('0x8')]||'beepall';this[_0x1bef('0x9')]=_0x34fb21[_0x1bef('0x9')];this[_0x1bef('0xa')]={};this[_0x1bef('0xb')]=0x0;this[_0x1bef('0x1')]='';this[_0x1bef('0xc')]();this['updateRealtime']();}MailQueue[_0x1bef('0xd')][_0x1bef('0xc')]=function(){var _0x577023=this['mapAgentsId'][_0x1bef('0xe')];this[_0x1bef('0xa')]=_[_0x1bef('0xf')](this[_0x1bef('0x9')],'id');this[_0x1bef('0xa')][_0x1bef('0xe')]=_0x577023;};MailQueue[_0x1bef('0xd')][_0x1bef('0x10')]=function(){this['loggedIn']=0x0;this[_0x1bef('0x11')]=0x0;for(var _0x1d0f26=0x0;_0x1d0f26<this[_0x1bef('0x9')][_0x1bef('0x12')];_0x1d0f26+=0x1){if(this['Agents'][_0x1d0f26][_0x1bef('0x13')]){this[_0x1bef('0x14')]+=0x1;}if(this[_0x1bef('0x9')][_0x1d0f26][_0x1bef('0x15')]){this[_0x1bef('0x11')]+=0x1;}}this[_0x1bef('0x16')]=this[_0x1bef('0x14')]-this[_0x1bef('0x11')];this[_0x1bef('0x16')]=this[_0x1bef('0x16')]>=0x0?this[_0x1bef('0x16')]:0x0;var _0x2d1974={'id':this['id'],'available':this['available'],'loggedIn':this[_0x1bef('0x14')],'name':this['name'],'paused':this[_0x1bef('0x11')],'waiting':this[_0x1bef('0xb')]};var _0x26ac2e=md5(JSON[_0x1bef('0x17')](_0x2d1974));if(this[_0x1bef('0x1')]!==_0x26ac2e){this[_0x1bef('0x1')]=_0x26ac2e;io['to'](util[_0x1bef('0x18')](_0x1bef('0x19'),_0x2d1974[_0x1bef('0x6')]))[_0x1bef('0x1a')](_0x1bef('0x1b'),_0x2d1974);}};module[_0x1bef('0x1c')]=MailQueue;