11f7e4b5001559590fcfc4bacb4f7de566007ef5
[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 _0x549a=['mapAgentsId','waiting','updateRouting','updateRealtime','prototype','_rr','map','loggedIn','paused','online','mailPause','available','format','emit','mail_queue:save','exports','lodash','md5','ioredis','../../../config/environment','defaults','redis','localhost','name','timeout','strategy','beepall','Agents'];(function(_0x442f6f,_0x38c5bb){var _0x44b9da=function(_0x45be9a){while(--_0x45be9a){_0x442f6f['push'](_0x442f6f['shift']());}};_0x44b9da(++_0x38c5bb);}(_0x549a,0x80));var _0xa549=function(_0x251425,_0x52ccab){_0x251425=_0x251425-0x0;var _0x553468=_0x549a[_0x251425];return _0x553468;};'use strict';var _=require(_0xa549('0x0'));var md5=require(_0xa549('0x1'));var util=require('util');var Redis=require(_0xa549('0x2'));var config=require(_0xa549('0x3'));config['redis']=_[_0xa549('0x4')](config[_0xa549('0x5')],{'host':_0xa549('0x6'),'port':0x18eb});var io=require('socket.io-emitter')(new Redis(config[_0xa549('0x5')]));function MailQueue(_0x30a72d){this['id']=_0x30a72d['id']||0x0;this[_0xa549('0x7')]=_0x30a72d[_0xa549('0x7')]||'';this[_0xa549('0x8')]=_0x30a72d[_0xa549('0x8')]||0xa;this[_0xa549('0x9')]=_0x30a72d[_0xa549('0x9')]||_0xa549('0xa');this[_0xa549('0xb')]=_0x30a72d[_0xa549('0xb')];this[_0xa549('0xc')]={};this[_0xa549('0xd')]=0x0;this[_0xa549('0x1')]='';this[_0xa549('0xe')]();this[_0xa549('0xf')]();}MailQueue[_0xa549('0x10')]['updateRouting']=function(){var _0x3f00f6=this[_0xa549('0xc')][_0xa549('0x11')];this[_0xa549('0xc')]=_[_0xa549('0x12')](this['Agents'],'id');this[_0xa549('0xc')]['_rr']=_0x3f00f6;};MailQueue[_0xa549('0x10')][_0xa549('0xf')]=function(){this[_0xa549('0x13')]=0x0;this[_0xa549('0x14')]=0x0;for(var _0x3e84c4=0x0;_0x3e84c4<this[_0xa549('0xb')]['length'];_0x3e84c4+=0x1){if(this[_0xa549('0xb')][_0x3e84c4][_0xa549('0x15')]){this[_0xa549('0x13')]+=0x1;}if(this[_0xa549('0xb')][_0x3e84c4][_0xa549('0x16')]){this[_0xa549('0x14')]+=0x1;}}this[_0xa549('0x17')]=this['loggedIn']-this[_0xa549('0x14')];this[_0xa549('0x17')]=this[_0xa549('0x17')]>=0x0?this['available']:0x0;var _0x2a28c0={'id':this['id'],'available':this['available'],'loggedIn':this['loggedIn'],'name':this[_0xa549('0x7')],'paused':this[_0xa549('0x14')],'waiting':this[_0xa549('0xd')]};var _0x5b42f2=md5(JSON['stringify'](_0x2a28c0));if(this[_0xa549('0x1')]!==_0x5b42f2){this[_0xa549('0x1')]=_0x5b42f2;io['to'](util[_0xa549('0x18')]('mail:queue:%s',_0x2a28c0[_0xa549('0x7')]))[_0xa549('0x19')](_0xa549('0x1a'),_0x2a28c0);}};module[_0xa549('0x1b')]=MailQueue;