Built motion from commit 87cd5f02.|2.5.48
[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 _0x7f57=['redis','defaults','localhost','name','timeout','strategy','Agents','waiting','md5','updateRouting','mapAgentsId','_rr','map','prototype','updateRealtime','loggedIn','paused','length','online','mailPause','available','stringify','format','mail:queue:%s','emit','mail_queue:save','exports','util','ioredis','../../../config/environment'];(function(_0xf51c06,_0x388e5b){var _0x1d5420=function(_0x5e077b){while(--_0x5e077b){_0xf51c06['push'](_0xf51c06['shift']());}};_0x1d5420(++_0x388e5b);}(_0x7f57,0x75));var _0x77f5=function(_0x44946b,_0xf874ec){_0x44946b=_0x44946b-0x0;var _0x249bc4=_0x7f57[_0x44946b];return _0x249bc4;};'use strict';var _=require('lodash');var md5=require('md5');var util=require(_0x77f5('0x0'));var Redis=require(_0x77f5('0x1'));var config=require(_0x77f5('0x2'));config[_0x77f5('0x3')]=_[_0x77f5('0x4')](config[_0x77f5('0x3')],{'host':_0x77f5('0x5'),'port':0x18eb});var io=require('socket.io-emitter')(new Redis(config[_0x77f5('0x3')]));function MailQueue(_0x339bbd){this['id']=_0x339bbd['id']||0x0;this[_0x77f5('0x6')]=_0x339bbd[_0x77f5('0x6')]||'';this[_0x77f5('0x7')]=_0x339bbd['timeout']||0xa;this[_0x77f5('0x8')]=_0x339bbd['strategy']||'beepall';this[_0x77f5('0x9')]=_0x339bbd[_0x77f5('0x9')];this['mapAgentsId']={};this[_0x77f5('0xa')]=0x0;this[_0x77f5('0xb')]='';this[_0x77f5('0xc')]();this['updateRealtime']();}MailQueue['prototype'][_0x77f5('0xc')]=function(){var _0x44176b=this[_0x77f5('0xd')][_0x77f5('0xe')];this[_0x77f5('0xd')]=_[_0x77f5('0xf')](this[_0x77f5('0x9')],'id');this['mapAgentsId'][_0x77f5('0xe')]=_0x44176b;};MailQueue[_0x77f5('0x10')][_0x77f5('0x11')]=function(){this[_0x77f5('0x12')]=0x0;this[_0x77f5('0x13')]=0x0;for(var _0x152001=0x0;_0x152001<this[_0x77f5('0x9')][_0x77f5('0x14')];_0x152001+=0x1){if(this[_0x77f5('0x9')][_0x152001][_0x77f5('0x15')]){this[_0x77f5('0x12')]+=0x1;}if(this[_0x77f5('0x9')][_0x152001][_0x77f5('0x16')]){this[_0x77f5('0x13')]+=0x1;}}this[_0x77f5('0x17')]=this[_0x77f5('0x12')]-this[_0x77f5('0x13')];this['available']=this['available']>=0x0?this[_0x77f5('0x17')]:0x0;var _0x30dea7={'id':this['id'],'available':this[_0x77f5('0x17')],'loggedIn':this['loggedIn'],'name':this[_0x77f5('0x6')],'paused':this[_0x77f5('0x13')],'waiting':this[_0x77f5('0xa')]};var _0x4a4b2b=md5(JSON[_0x77f5('0x18')](_0x30dea7));if(this[_0x77f5('0xb')]!==_0x4a4b2b){this['md5']=_0x4a4b2b;io['to'](util[_0x77f5('0x19')](_0x77f5('0x1a'),_0x30dea7[_0x77f5('0x6')]))[_0x77f5('0x1b')](_0x77f5('0x1c'),_0x30dea7);}};module[_0x77f5('0x1d')]=MailQueue;