Built motion from commit d5e4af8c.|2.6.23
[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 _0xd27a=['../../../config/environment','redis','defaults','localhost','name','timeout','strategy','beepall','Agents','waiting','md5','updateRouting','prototype','_rr','mapAgentsId','map','updateRealtime','loggedIn','paused','length','online','available','stringify','format','mail:queue:%s','exports','lodash','util'];(function(_0x22bbf5,_0xd5ba18){var _0x2c0323=function(_0xafeab4){while(--_0xafeab4){_0x22bbf5['push'](_0x22bbf5['shift']());}};_0x2c0323(++_0xd5ba18);}(_0xd27a,0x186));var _0xad27=function(_0x229c5f,_0x28e427){_0x229c5f=_0x229c5f-0x0;var _0x32b7d6=_0xd27a[_0x229c5f];return _0x32b7d6;};'use strict';var _=require(_0xad27('0x0'));var md5=require('md5');var util=require(_0xad27('0x1'));var Redis=require('ioredis');var config=require(_0xad27('0x2'));config[_0xad27('0x3')]=_[_0xad27('0x4')](config['redis'],{'host':_0xad27('0x5'),'port':0x18eb});var io=require('socket.io-emitter')(new Redis(config[_0xad27('0x3')]));function MailQueue(_0x468657){this['id']=_0x468657['id']||0x0;this[_0xad27('0x6')]=_0x468657['name']||'';this[_0xad27('0x7')]=_0x468657[_0xad27('0x7')]||0xa;this[_0xad27('0x8')]=_0x468657[_0xad27('0x8')]||_0xad27('0x9');this[_0xad27('0xa')]=_0x468657['Agents'];this['mapAgentsId']={};this[_0xad27('0xb')]=0x0;this[_0xad27('0xc')]='';this[_0xad27('0xd')]();this['updateRealtime']();}MailQueue[_0xad27('0xe')][_0xad27('0xd')]=function(){var _0x1cae72=this['mapAgentsId'][_0xad27('0xf')];this[_0xad27('0x10')]=_[_0xad27('0x11')](this[_0xad27('0xa')],'id');this[_0xad27('0x10')][_0xad27('0xf')]=_0x1cae72;};MailQueue[_0xad27('0xe')][_0xad27('0x12')]=function(){this[_0xad27('0x13')]=0x0;this[_0xad27('0x14')]=0x0;for(var _0x3a4a8b=0x0;_0x3a4a8b<this['Agents'][_0xad27('0x15')];_0x3a4a8b+=0x1){if(this[_0xad27('0xa')][_0x3a4a8b][_0xad27('0x16')]){this[_0xad27('0x13')]+=0x1;}if(this['Agents'][_0x3a4a8b]['mailPause']){this[_0xad27('0x14')]+=0x1;}}this[_0xad27('0x17')]=this['loggedIn']-this[_0xad27('0x14')];this[_0xad27('0x17')]=this[_0xad27('0x17')]>=0x0?this['available']:0x0;var _0xbe48a7={'id':this['id'],'available':this[_0xad27('0x17')],'loggedIn':this[_0xad27('0x13')],'name':this['name'],'paused':this[_0xad27('0x14')],'waiting':this['waiting']};var _0x6daeb0=md5(JSON[_0xad27('0x18')](_0xbe48a7));if(this[_0xad27('0xc')]!==_0x6daeb0){this['md5']=_0x6daeb0;io['to'](util[_0xad27('0x19')](_0xad27('0x1a'),_0xbe48a7[_0xad27('0x6')]))['emit']('mail_queue:save',_0xbe48a7);}};module[_0xad27('0x1b')]=MailQueue;