From 3bef2267e1ca5f0c5adddb303a6848d47eaabf79 Mon Sep 17 00:00:00 2001
From: Felipe Cecagno <fcecagno@gmail.com>
Date: Thu, 28 Mar 2019 20:17:20 +0000
Subject: [PATCH] Fix redis client and a loop in webhooks

---
 bbb-webhooks/application.js | 2 +-
 bbb-webhooks/hook.js        | 4 ++--
 bbb-webhooks/id_mapping.js  | 4 ++--
 bbb-webhooks/userMapping.js | 4 ++--
 bbb-webhooks/web_hooks.js   | 4 ++--
 5 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/bbb-webhooks/application.js b/bbb-webhooks/application.js
index e2c0c5424f..4c16b5e526 100644
--- a/bbb-webhooks/application.js
+++ b/bbb-webhooks/application.js
@@ -11,7 +11,7 @@ const async = require("async");
 // process to perform the callback calls.
 // TODO: add port (-p) and log level (-l) to the command line args
 module.exports = class Application {
-  
+
   constructor() {
     this.webHooks = new WebHooks();
     this.webServer = new WebServer();
diff --git a/bbb-webhooks/hook.js b/bbb-webhooks/hook.js
index f15537bb13..21c1c6dcea 100644
--- a/bbb-webhooks/hook.js
+++ b/bbb-webhooks/hook.js
@@ -36,7 +36,7 @@ module.exports = class Hook {
     this.externalMeetingID = null;
     this.queue = [];
     this.emitter = null;
-    this.redisClient = Application.redisClient;
+    this.redisClient = Application.redisClient();
     this.permanent = false;
     this.getRaw = false;
   }
@@ -266,7 +266,7 @@ module.exports = class Hook {
   // Gets all hooks from redis to populate the local database.
   // Calls `callback()` when done.
   static resync(callback) {
-    let client = Application.redisClient;
+    let client = Application.redisClient();
     // Remove previous permanent hooks
     for (let hk = 1; hk <= config.get("hooks.permanentURLs").length; hk++) {
       client.srem(config.get("redis.keys.hooks"), hk, (error, reply) => {
diff --git a/bbb-webhooks/id_mapping.js b/bbb-webhooks/id_mapping.js
index f9285d3189..f409f40a88 100644
--- a/bbb-webhooks/id_mapping.js
+++ b/bbb-webhooks/id_mapping.js
@@ -33,7 +33,7 @@ module.exports = class IDMapping {
     this.externalMeetingID = null;
     this.internalMeetingID = null;
     this.lastActivity = null;
-    this.redisClient = Application.redisClient;
+    this.redisClient = Application.redisClient();
   }
 
   save(callback) {
@@ -180,7 +180,7 @@ module.exports = class IDMapping {
   // Gets all mappings from redis to populate the local database.
   // Calls `callback()` when done.
   static resync(callback) {
-    let client = Application.redisClient;
+    let client = Application.redisClient();
     let tasks = [];
 
     return client.smembers(config.get("redis.keys.mappings"), (error, mappings) => {
diff --git a/bbb-webhooks/userMapping.js b/bbb-webhooks/userMapping.js
index 3571396a52..056e78a7a5 100644
--- a/bbb-webhooks/userMapping.js
+++ b/bbb-webhooks/userMapping.js
@@ -33,7 +33,7 @@ module.exports = class UserMapping {
     this.internalUserID = null;
     this.meetingId = null;
     this.user = null;
-    this.redisClient = Application.redisClient;
+    this.redisClient = Application.redisClient();
   }
 
   save(callback) {
@@ -165,7 +165,7 @@ module.exports = class UserMapping {
   // Gets all mappings from redis to populate the local database.
   // Calls `callback()` when done.
   static resync(callback) {
-    let client = Application.redisClient;
+    let client = Application.redisClient();
     let tasks = [];
 
     return client.smembers(config.get("redis.keys.userMaps"), (error, mappings) => {
diff --git a/bbb-webhooks/web_hooks.js b/bbb-webhooks/web_hooks.js
index 9f2531ad1c..5503ae2ee7 100644
--- a/bbb-webhooks/web_hooks.js
+++ b/bbb-webhooks/web_hooks.js
@@ -14,7 +14,7 @@ const UserMapping = require("./userMapping.js");
 module.exports = class WebHooks {
 
   constructor() {
-    this.subscriberEvents = Application.redisClient;
+    this.subscriberEvents = Application.redisClient();
   }
 
   start(callback) {
@@ -73,7 +73,7 @@ module.exports = class WebHooks {
       }
     });
 
-    for (i = 0; i < config.get("hooks.channels"); ++i) {
+    for (var i = 0; i < config.get("hooks.channels"); ++i) {
       const channel = config.get("hooks.channels")[i];
       this.subscriberEvents.psubscribe(channel);
     }
-- 
GitLab