Built motion from commit (unavailable).|2.3.95
[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 _0x8277=['Agents','mapAgentsId','waiting','updateRouting','updateRealtime','prototype','_rr','map','loggedIn','paused','length','online','mailPause','available','stringify','format','mail_queue:save','exports','md5','util','../../../config/environment','redis','localhost','name','timeout','strategy','beepall'];(function(_0x1a4e06,_0x2cb7c5){var _0x4b4cbf=function(_0x851014){while(--_0x851014){_0x1a4e06['push'](_0x1a4e06['shift']());}};_0x4b4cbf(++_0x2cb7c5);}(_0x8277,0xcf));var _0x7827=function(_0x261b8a,_0x553ec4){_0x261b8a=_0x261b8a-0x0;var _0x3455e8=_0x8277[_0x261b8a];return _0x3455e8;};'use strict';var _=require('lodash');var md5=require(_0x7827('0x0'));var util=require(_0x7827('0x1'));var Redis=require('ioredis');var config=require(_0x7827('0x2'));config[_0x7827('0x3')]=_['defaults'](config[_0x7827('0x3')],{'host':_0x7827('0x4'),'port':0x18eb});var io=require('socket.io-emitter')(new Redis(config[_0x7827('0x3')]));function MailQueue(_0x14fc9b){this['id']=_0x14fc9b['id']||0x0;this[_0x7827('0x5')]=_0x14fc9b['name']||'';this[_0x7827('0x6')]=_0x14fc9b[_0x7827('0x6')]||0xa;this[_0x7827('0x7')]=_0x14fc9b[_0x7827('0x7')]||_0x7827('0x8');this[_0x7827('0x9')]=_0x14fc9b[_0x7827('0x9')];this[_0x7827('0xa')]={};this[_0x7827('0xb')]=0x0;this[_0x7827('0x0')]='';this[_0x7827('0xc')]();this[_0x7827('0xd')]();}MailQueue[_0x7827('0xe')][_0x7827('0xc')]=function(){var _0x51bc18=this[_0x7827('0xa')][_0x7827('0xf')];this[_0x7827('0xa')]=_[_0x7827('0x10')](this['Agents'],'id');this[_0x7827('0xa')][_0x7827('0xf')]=_0x51bc18;};MailQueue[_0x7827('0xe')][_0x7827('0xd')]=function(){this[_0x7827('0x11')]=0x0;this[_0x7827('0x12')]=0x0;for(var _0x35c668=0x0;_0x35c668<this[_0x7827('0x9')][_0x7827('0x13')];_0x35c668+=0x1){if(this[_0x7827('0x9')][_0x35c668][_0x7827('0x14')]){this[_0x7827('0x11')]+=0x1;}if(this[_0x7827('0x9')][_0x35c668][_0x7827('0x15')]){this[_0x7827('0x12')]+=0x1;}}this['available']=this[_0x7827('0x11')]-this[_0x7827('0x12')];this[_0x7827('0x16')]=this[_0x7827('0x16')]>=0x0?this[_0x7827('0x16')]:0x0;var _0x2e001d={'id':this['id'],'available':this[_0x7827('0x16')],'loggedIn':this[_0x7827('0x11')],'name':this['name'],'paused':this[_0x7827('0x12')],'waiting':this[_0x7827('0xb')]};var _0x30f90f=md5(JSON[_0x7827('0x17')](_0x2e001d));if(this[_0x7827('0x0')]!==_0x30f90f){this[_0x7827('0x0')]=_0x30f90f;io['to'](util[_0x7827('0x18')]('mail:queue:%s',_0x2e001d[_0x7827('0x5')]))['emit'](_0x7827('0x19'),_0x2e001d);}};module[_0x7827('0x1a')]=MailQueue;