Built motion from commit (unavailable).|2.4.16
[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 _0xf619=['exports','md5','ioredis','../../../config/environment','redis','defaults','socket.io-emitter','name','timeout','strategy','beepall','Agents','mapAgentsId','waiting','updateRouting','updateRealtime','prototype','_rr','paused','length','online','loggedIn','mailPause','available','stringify','format','mail:queue:%s','emit','mail_queue:save'];(function(_0x2866c7,_0x197fdd){var _0x3c5db2=function(_0x5f40db){while(--_0x5f40db){_0x2866c7['push'](_0x2866c7['shift']());}};_0x3c5db2(++_0x197fdd);}(_0xf619,0x17a));var _0x9f61=function(_0x1e88c5,_0x37c1c3){_0x1e88c5=_0x1e88c5-0x0;var _0x43fc10=_0xf619[_0x1e88c5];return _0x43fc10;};'use strict';var _=require('lodash');var md5=require(_0x9f61('0x0'));var util=require('util');var Redis=require(_0x9f61('0x1'));var config=require(_0x9f61('0x2'));config[_0x9f61('0x3')]=_[_0x9f61('0x4')](config['redis'],{'host':'localhost','port':0x18eb});var io=require(_0x9f61('0x5'))(new Redis(config[_0x9f61('0x3')]));function MailQueue(_0x2b9e47){this['id']=_0x2b9e47['id']||0x0;this[_0x9f61('0x6')]=_0x2b9e47['name']||'';this[_0x9f61('0x7')]=_0x2b9e47[_0x9f61('0x7')]||0xa;this['strategy']=_0x2b9e47[_0x9f61('0x8')]||_0x9f61('0x9');this[_0x9f61('0xa')]=_0x2b9e47['Agents'];this[_0x9f61('0xb')]={};this[_0x9f61('0xc')]=0x0;this['md5']='';this[_0x9f61('0xd')]();this[_0x9f61('0xe')]();}MailQueue[_0x9f61('0xf')][_0x9f61('0xd')]=function(){var _0x25ec37=this[_0x9f61('0xb')]['_rr'];this[_0x9f61('0xb')]=_['map'](this['Agents'],'id');this['mapAgentsId'][_0x9f61('0x10')]=_0x25ec37;};MailQueue['prototype'][_0x9f61('0xe')]=function(){this['loggedIn']=0x0;this[_0x9f61('0x11')]=0x0;for(var _0x89e0ca=0x0;_0x89e0ca<this[_0x9f61('0xa')][_0x9f61('0x12')];_0x89e0ca+=0x1){if(this[_0x9f61('0xa')][_0x89e0ca][_0x9f61('0x13')]){this[_0x9f61('0x14')]+=0x1;}if(this[_0x9f61('0xa')][_0x89e0ca][_0x9f61('0x15')]){this[_0x9f61('0x11')]+=0x1;}}this[_0x9f61('0x16')]=this[_0x9f61('0x14')]-this[_0x9f61('0x11')];this[_0x9f61('0x16')]=this[_0x9f61('0x16')]>=0x0?this[_0x9f61('0x16')]:0x0;var _0x31348c={'id':this['id'],'available':this['available'],'loggedIn':this[_0x9f61('0x14')],'name':this['name'],'paused':this[_0x9f61('0x11')],'waiting':this[_0x9f61('0xc')]};var _0x4550a1=md5(JSON[_0x9f61('0x17')](_0x31348c));if(this[_0x9f61('0x0')]!==_0x4550a1){this[_0x9f61('0x0')]=_0x4550a1;io['to'](util[_0x9f61('0x18')](_0x9f61('0x19'),_0x31348c[_0x9f61('0x6')]))[_0x9f61('0x1a')](_0x9f61('0x1b'),_0x31348c);}};module[_0x9f61('0x1c')]=MailQueue;