5b5136849b167a1fa7d580aaac1dc9814c764781
[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 _0xb1b4=['defaults','localhost','socket.io-emitter','name','timeout','strategy','beepall','Agents','mapAgentsId','updateRouting','updateRealtime','prototype','map','_rr','loggedIn','paused','mailPause','available','waiting','format','emit','exports','lodash','md5','util','../../../config/environment','redis'];(function(_0x51eb77,_0x436673){var _0x4b26fe=function(_0x4db9dc){while(--_0x4db9dc){_0x51eb77['push'](_0x51eb77['shift']());}};_0x4b26fe(++_0x436673);}(_0xb1b4,0x175));var _0x4b1b=function(_0x59dccc,_0x184c1c){_0x59dccc=_0x59dccc-0x0;var _0xc97bcb=_0xb1b4[_0x59dccc];return _0xc97bcb;};'use strict';var _=require(_0x4b1b('0x0'));var md5=require(_0x4b1b('0x1'));var util=require(_0x4b1b('0x2'));var Redis=require('ioredis');var config=require(_0x4b1b('0x3'));config[_0x4b1b('0x4')]=_[_0x4b1b('0x5')](config[_0x4b1b('0x4')],{'host':_0x4b1b('0x6'),'port':0x18eb});var io=require(_0x4b1b('0x7'))(new Redis(config['redis']));function MailQueue(_0x1b83e0){this['id']=_0x1b83e0['id']||0x0;this[_0x4b1b('0x8')]=_0x1b83e0[_0x4b1b('0x8')]||'';this[_0x4b1b('0x9')]=_0x1b83e0[_0x4b1b('0x9')]||0xa;this['strategy']=_0x1b83e0[_0x4b1b('0xa')]||_0x4b1b('0xb');this['Agents']=_0x1b83e0[_0x4b1b('0xc')];this[_0x4b1b('0xd')]={};this['waiting']=0x0;this[_0x4b1b('0x1')]='';this[_0x4b1b('0xe')]();this[_0x4b1b('0xf')]();}MailQueue[_0x4b1b('0x10')][_0x4b1b('0xe')]=function(){var _0x154408=this[_0x4b1b('0xd')]['_rr'];this[_0x4b1b('0xd')]=_[_0x4b1b('0x11')](this['Agents'],'id');this['mapAgentsId'][_0x4b1b('0x12')]=_0x154408;};MailQueue[_0x4b1b('0x10')][_0x4b1b('0xf')]=function(){this[_0x4b1b('0x13')]=0x0;this[_0x4b1b('0x14')]=0x0;for(var _0x4c1072=0x0;_0x4c1072<this[_0x4b1b('0xc')]['length'];_0x4c1072+=0x1){if(this[_0x4b1b('0xc')][_0x4c1072]['online']){this[_0x4b1b('0x13')]+=0x1;}if(this[_0x4b1b('0xc')][_0x4c1072][_0x4b1b('0x15')]){this[_0x4b1b('0x14')]+=0x1;}}this[_0x4b1b('0x16')]=this[_0x4b1b('0x13')]-this['paused'];this[_0x4b1b('0x16')]=this[_0x4b1b('0x16')]>=0x0?this['available']:0x0;var _0x5ea908={'id':this['id'],'available':this[_0x4b1b('0x16')],'loggedIn':this[_0x4b1b('0x13')],'name':this[_0x4b1b('0x8')],'paused':this[_0x4b1b('0x14')],'waiting':this[_0x4b1b('0x17')]};var _0x3ab3dc=md5(JSON['stringify'](_0x5ea908));if(this[_0x4b1b('0x1')]!==_0x3ab3dc){this[_0x4b1b('0x1')]=_0x3ab3dc;io['to'](util[_0x4b1b('0x18')]('mail:queue:%s',_0x5ea908['name']))[_0x4b1b('0x19')]('mail_queue:save',_0x5ea908);}};module[_0x4b1b('0x1a')]=MailQueue;