Built motion from commit (unavailable).|2.5.27
[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 _0xccd4=['map','updateRealtime','loggedIn','paused','length','online','mailPause','available','waiting','stringify','format','mail:queue:%s','emit','exports','lodash','md5','util','ioredis','../../../config/environment','redis','defaults','localhost','name','timeout','strategy','Agents','updateRouting','prototype','mapAgentsId','_rr'];(function(_0x262ee9,_0x355b6e){var _0x117287=function(_0x1236fb){while(--_0x1236fb){_0x262ee9['push'](_0x262ee9['shift']());}};_0x117287(++_0x355b6e);}(_0xccd4,0xa4));var _0x4ccd=function(_0xa6cc5c,_0x239c99){_0xa6cc5c=_0xa6cc5c-0x0;var _0x44803d=_0xccd4[_0xa6cc5c];return _0x44803d;};'use strict';var _=require(_0x4ccd('0x0'));var md5=require(_0x4ccd('0x1'));var util=require(_0x4ccd('0x2'));var Redis=require(_0x4ccd('0x3'));var config=require(_0x4ccd('0x4'));config[_0x4ccd('0x5')]=_[_0x4ccd('0x6')](config[_0x4ccd('0x5')],{'host':_0x4ccd('0x7'),'port':0x18eb});var io=require('socket.io-emitter')(new Redis(config['redis']));function MailQueue(_0x58bed9){this['id']=_0x58bed9['id']||0x0;this[_0x4ccd('0x8')]=_0x58bed9[_0x4ccd('0x8')]||'';this[_0x4ccd('0x9')]=_0x58bed9[_0x4ccd('0x9')]||0xa;this[_0x4ccd('0xa')]=_0x58bed9[_0x4ccd('0xa')]||'beepall';this[_0x4ccd('0xb')]=_0x58bed9[_0x4ccd('0xb')];this['mapAgentsId']={};this['waiting']=0x0;this[_0x4ccd('0x1')]='';this[_0x4ccd('0xc')]();this['updateRealtime']();}MailQueue[_0x4ccd('0xd')][_0x4ccd('0xc')]=function(){var _0x3182af=this[_0x4ccd('0xe')][_0x4ccd('0xf')];this[_0x4ccd('0xe')]=_[_0x4ccd('0x10')](this[_0x4ccd('0xb')],'id');this[_0x4ccd('0xe')][_0x4ccd('0xf')]=_0x3182af;};MailQueue[_0x4ccd('0xd')][_0x4ccd('0x11')]=function(){this[_0x4ccd('0x12')]=0x0;this[_0x4ccd('0x13')]=0x0;for(var _0x32f3cf=0x0;_0x32f3cf<this[_0x4ccd('0xb')][_0x4ccd('0x14')];_0x32f3cf+=0x1){if(this[_0x4ccd('0xb')][_0x32f3cf][_0x4ccd('0x15')]){this['loggedIn']+=0x1;}if(this[_0x4ccd('0xb')][_0x32f3cf][_0x4ccd('0x16')]){this[_0x4ccd('0x13')]+=0x1;}}this[_0x4ccd('0x17')]=this[_0x4ccd('0x12')]-this['paused'];this[_0x4ccd('0x17')]=this['available']>=0x0?this['available']:0x0;var _0x2b8389={'id':this['id'],'available':this[_0x4ccd('0x17')],'loggedIn':this[_0x4ccd('0x12')],'name':this[_0x4ccd('0x8')],'paused':this[_0x4ccd('0x13')],'waiting':this[_0x4ccd('0x18')]};var _0x428dee=md5(JSON[_0x4ccd('0x19')](_0x2b8389));if(this[_0x4ccd('0x1')]!==_0x428dee){this[_0x4ccd('0x1')]=_0x428dee;io['to'](util[_0x4ccd('0x1a')](_0x4ccd('0x1b'),_0x2b8389[_0x4ccd('0x8')]))[_0x4ccd('0x1c')]('mail_queue:save',_0x2b8389);}};module[_0x4ccd('0x1d')]=MailQueue;