b4a9690b4edc111c0a6507be2d6ca3f8afd17509
[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 _0x035b=['strategy','beepall','Agents','waiting','updateRouting','updateRealtime','mapAgentsId','_rr','loggedIn','length','online','mailPause','paused','available','stringify','mail:queue:%s','emit','lodash','md5','ioredis','../../../config/environment','redis','defaults','localhost','socket.io-emitter','name','timeout'];(function(_0x1da8d6,_0x3580c4){var _0x3c14d2=function(_0x22ac06){while(--_0x22ac06){_0x1da8d6['push'](_0x1da8d6['shift']());}};_0x3c14d2(++_0x3580c4);}(_0x035b,0x98));var _0xb035=function(_0x180a23,_0x3a9c1b){_0x180a23=_0x180a23-0x0;var _0x2af863=_0x035b[_0x180a23];return _0x2af863;};'use strict';var _=require(_0xb035('0x0'));var md5=require(_0xb035('0x1'));var util=require('util');var Redis=require(_0xb035('0x2'));var config=require(_0xb035('0x3'));config[_0xb035('0x4')]=_[_0xb035('0x5')](config[_0xb035('0x4')],{'host':_0xb035('0x6'),'port':0x18eb});var io=require(_0xb035('0x7'))(new Redis(config[_0xb035('0x4')]));function MailQueue(_0x222fea){this['id']=_0x222fea['id']||0x0;this['name']=_0x222fea[_0xb035('0x8')]||'';this[_0xb035('0x9')]=_0x222fea[_0xb035('0x9')]||0xa;this['strategy']=_0x222fea[_0xb035('0xa')]||_0xb035('0xb');this[_0xb035('0xc')]=_0x222fea['Agents'];this['mapAgentsId']={};this[_0xb035('0xd')]=0x0;this[_0xb035('0x1')]='';this[_0xb035('0xe')]();this[_0xb035('0xf')]();}MailQueue['prototype'][_0xb035('0xe')]=function(){var _0xae7769=this[_0xb035('0x10')][_0xb035('0x11')];this[_0xb035('0x10')]=_['map'](this['Agents'],'id');this[_0xb035('0x10')][_0xb035('0x11')]=_0xae7769;};MailQueue['prototype'][_0xb035('0xf')]=function(){this[_0xb035('0x12')]=0x0;this['paused']=0x0;for(var _0x444b80=0x0;_0x444b80<this['Agents'][_0xb035('0x13')];_0x444b80+=0x1){if(this[_0xb035('0xc')][_0x444b80][_0xb035('0x14')]){this[_0xb035('0x12')]+=0x1;}if(this[_0xb035('0xc')][_0x444b80][_0xb035('0x15')]){this[_0xb035('0x16')]+=0x1;}}this['available']=this[_0xb035('0x12')]-this[_0xb035('0x16')];this[_0xb035('0x17')]=this['available']>=0x0?this[_0xb035('0x17')]:0x0;var _0x47765a={'id':this['id'],'available':this['available'],'loggedIn':this[_0xb035('0x12')],'name':this[_0xb035('0x8')],'paused':this[_0xb035('0x16')],'waiting':this[_0xb035('0xd')]};var _0xc0380c=md5(JSON[_0xb035('0x18')](_0x47765a));if(this[_0xb035('0x1')]!==_0xc0380c){this[_0xb035('0x1')]=_0xc0380c;io['to'](util['format'](_0xb035('0x19'),_0x47765a[_0xb035('0x8')]))[_0xb035('0x1a')]('mail_queue:save',_0x47765a);}};module['exports']=MailQueue;