From 9dd44ad84b68f05a765091d3143419f168778746 Mon Sep 17 00:00:00 2001
From: Richard Alam <ritzalam@gmail.com>
Date: Mon, 21 Oct 2019 15:08:51 -0700
Subject: [PATCH]  - filter our global audio users

---
 .../actions/GetUsersStatusCommand.java        | 52 +++++++++----------
 .../freeswitch/VoiceConferenceService.scala   | 12 ++++-
 2 files changed, 37 insertions(+), 27 deletions(-)

diff --git a/akka-bbb-fsesl/src/main/java/org/bigbluebutton/freeswitch/voice/freeswitch/actions/GetUsersStatusCommand.java b/akka-bbb-fsesl/src/main/java/org/bigbluebutton/freeswitch/voice/freeswitch/actions/GetUsersStatusCommand.java
index cbfeeed54c..3ae0975af7 100755
--- a/akka-bbb-fsesl/src/main/java/org/bigbluebutton/freeswitch/voice/freeswitch/actions/GetUsersStatusCommand.java
+++ b/akka-bbb-fsesl/src/main/java/org/bigbluebutton/freeswitch/voice/freeswitch/actions/GetUsersStatusCommand.java
@@ -22,6 +22,7 @@ import java.util.regex.Pattern;
 public class GetUsersStatusCommand extends FreeswitchCommand {
   private static Logger log = LoggerFactory.getLogger(GetUsersStatusCommand.class);
   private static final Pattern CALLERNAME_PATTERN = Pattern.compile("(.*)-bbbID-(.*)$");
+  private static final Pattern GLOBAL_AUDION_PATTERN = Pattern.compile("(GLOBAL_AUDIO)_(.*)$");
 
   public GetUsersStatusCommand(String room, String requesterId) {
     super(room, requesterId);
@@ -35,7 +36,7 @@ public class GetUsersStatusCommand extends FreeswitchCommand {
   public void handleResponse(EslMessage response, ConferenceEventListener eventListener) {
 
     String firstLine = response.getBodyLines().get(0);
-    log.info("GetUsersStatusCommand: Check conference first line response: " + firstLine);
+    //log.info("GetUsersStatusCommand: Check conference first line response: " + firstLine);
 
     if(!firstLine.startsWith("<?xml")) {
       log.info("Conference is not running {}.", room);
@@ -57,12 +58,11 @@ public class GetUsersStatusCommand extends FreeswitchCommand {
       responseBody = responseBody.trim().replaceFirst("^([\\W]+)<","<");
 
       ByteArrayInputStream bs = new ByteArrayInputStream(responseBody.getBytes());
-      System.out.println("***** Parsing Response !!!! *****");
       sp.parse(bs, confXML);
 
       Integer numUsers =  confXML.getConferenceList().size();
       if (numUsers > 0) {
-        log.info("Check user status response: " + responseBody);
+        //log.info("Check user status response: " + responseBody);
 
         List<ConfMember> confMembers = new ArrayList<ConfMember>();
         List<ConfRecording> confRecordings = new ArrayList<ConfRecording>();
@@ -74,30 +74,30 @@ public class GetUsersStatusCommand extends FreeswitchCommand {
             String voiceUserId = callerIdName;
             String uuid = member.getUUID();
 
-            Matcher matcher = CALLERNAME_PATTERN.matcher(callerIdName);
-            if (matcher.matches()) {
-              voiceUserId = matcher.group(1).trim();
-              callerIdName = matcher.group(2).trim();
+            Matcher gapMatcher = GLOBAL_AUDION_PATTERN.matcher(callerIdName);
+            // Ignore GLOBAL_AUDIO user.
+            if (!gapMatcher.matches()) {
+              Matcher matcher = CALLERNAME_PATTERN.matcher(callerIdName);
+              if (matcher.matches()) {
+                voiceUserId = matcher.group(1).trim();
+                callerIdName = matcher.group(2).trim();
+              }
+
+              log.info("Conf user. uuid=" + uuid
+                      + ",caller=" + callerIdName
+                      + ",callerId=" + callerId
+                      + ",conf=" + room
+                      + ",muted=" + member.getMuted()
+                      + ",talking=" + member.getSpeaking());
+
+              ConfMember confMember = new ConfMember(voiceUserId,
+                      member.getId().toString(),
+                      callerId, callerIdName,
+                      member.getMuted(),
+                      member.getSpeaking(),
+                      "none");
+              confMembers.add(confMember);
             }
-
-            log.info("Conf user. uuid=" + uuid
-                    + ",caller=" + callerIdName
-                    + ",callerId=" + callerId
-                    + ",conf=" + room
-                    + ",muted=" + member.getMuted()
-                    + ",talking=" + member.getSpeaking());
-
-            //VoiceUsersStatusEvent pj = new VoiceUsersStatusEvent(voiceUserId, member.getId().toString(), confXML.getConferenceRoom(),
-            //        callerId, callerIdName, member.getMuted(), member.getSpeaking(), "none");
-            //eventListener.handleConferenceEvent(pj);
-
-            ConfMember confMember = new ConfMember(voiceUserId,
-                    member.getId().toString(),
-                    callerId, callerIdName,
-                    member.getMuted(),
-                    member.getSpeaking(),
-                    "none");
-            confMembers.add(confMember);
           } else if ("recording_node".equals(member.getMemberType())) {
             ConfRecording confRecording = new ConfRecording(member.getRecordPath(), member.getRecordStartTime());
             confRecordings.add(confRecording);
diff --git a/akka-bbb-fsesl/src/main/scala/org/bigbluebutton/freeswitch/VoiceConferenceService.scala b/akka-bbb-fsesl/src/main/scala/org/bigbluebutton/freeswitch/VoiceConferenceService.scala
index fd8d53c7c7..2e186f1990 100755
--- a/akka-bbb-fsesl/src/main/scala/org/bigbluebutton/freeswitch/VoiceConferenceService.scala
+++ b/akka-bbb-fsesl/src/main/scala/org/bigbluebutton/freeswitch/VoiceConferenceService.scala
@@ -19,8 +19,18 @@ class VoiceConferenceService(sender: RedisPublisher) extends IVoiceConferenceSer
       isRecording:   java.lang.Boolean,
       confRecording: java.util.List[ConfRecording]
   ) {
+    val recs: scala.collection.mutable.ListBuffer[ConfVoiceRecording] = new scala.collection.mutable.ListBuffer[ConfVoiceRecording]()
+    confRecording forEach { cr =>
+      recs += ConfVoiceRecording(cr.recordingPath, cr.recordingStartTime)
+    }
+
     val header = BbbCoreVoiceConfHeader(CheckRunningAndRecordingVoiceConfEvtMsg.NAME, voiceConfId)
-    val body = CheckRunningAndRecordingVoiceConfEvtMsgBody(voiceConfId, isRunning.booleanValue(), isRecording.booleanValue())
+    val body = CheckRunningAndRecordingVoiceConfEvtMsgBody(
+      voiceConfId,
+      isRunning.booleanValue(),
+      isRecording.booleanValue(),
+      recs.toVector
+    )
     val envelope = BbbCoreEnvelope(CheckRunningAndRecordingVoiceConfEvtMsg.NAME, Map("voiceConf" -> voiceConfId))
 
     val msg = new CheckRunningAndRecordingVoiceConfEvtMsg(header, body)
-- 
GitLab