From ff1357cbbd343ece8d67570a7f5870a9a4ed73f9 Mon Sep 17 00:00:00 2001
From: Anton Georgiev <antobinary@users.noreply.github.com>
Date: Mon, 22 Jun 2020 16:28:22 -0400
Subject: [PATCH] Revert "Improve audio reconnection for muted users for 2.2"

---
 .../api/voice-users/server/methods/muteToggle.js       |  5 ++---
 .../imports/ui/services/audio-manager/index.js         | 10 +---------
 2 files changed, 3 insertions(+), 12 deletions(-)

diff --git a/bigbluebutton-html5/imports/api/voice-users/server/methods/muteToggle.js b/bigbluebutton-html5/imports/api/voice-users/server/methods/muteToggle.js
index 69b1071bd4..fdc3c23f4d 100644
--- a/bigbluebutton-html5/imports/api/voice-users/server/methods/muteToggle.js
+++ b/bigbluebutton-html5/imports/api/voice-users/server/methods/muteToggle.js
@@ -3,9 +3,8 @@ import { extractCredentials } from '/imports/api/common/server/helpers';
 import RedisPubSub from '/imports/startup/server/redis';
 import Users from '/imports/api/users';
 import VoiceUsers from '/imports/api/voice-users';
-import _ from 'lodash';
 
-export default function muteToggle(uId, implicitMutedState) {
+export default function muteToggle(uId) {
   const REDIS_CONFIG = Meteor.settings.private.redis;
   const CHANNEL = REDIS_CONFIG.channels.toAkkaApps;
   const EVENT_NAME = 'MuteUserCmdMsg';
@@ -31,7 +30,7 @@ export default function muteToggle(uId, implicitMutedState) {
   const payload = {
     userId: userToMute,
     mutedBy: requesterUserId,
-    mute: _.isNil(implicitMutedState) ? !muted : implicitMutedState,
+    mute: !muted,
   };
 
   RedisPubSub.publishUserMessage(CHANNEL, EVENT_NAME, meetingId, requesterUserId, payload);
diff --git a/bigbluebutton-html5/imports/ui/services/audio-manager/index.js b/bigbluebutton-html5/imports/ui/services/audio-manager/index.js
index 573adad6a5..2a4aedf90f 100755
--- a/bigbluebutton-html5/imports/ui/services/audio-manager/index.js
+++ b/bigbluebutton-html5/imports/ui/services/audio-manager/index.js
@@ -8,7 +8,6 @@ import { notify } from '/imports/ui/services/notification';
 import playAndRetry from '/imports/utils/mediaElementPlayRetry';
 import iosWebviewAudioPolyfills from '/imports/utils/ios-webview-audio-polyfills';
 import { tryGenerateIceCandidates } from '/imports/utils/safari-webrtc';
-import { makeCall } from '/imports/ui/services/api';
 import AudioErrors from './error-codes';
 
 const MEDIA = Meteor.settings.public.media;
@@ -45,7 +44,6 @@ class AudioManager {
       outputDeviceId: null,
       muteHandle: null,
       autoplayBlocked: false,
-      wasMuted: false,
     });
 
     this.useKurento = Meteor.settings.public.kurento.enableListenOnly;
@@ -283,17 +281,13 @@ class AudioManager {
     this.isConnecting = false;
     this.isConnected = true;
 
-    if (this.wasMuted) {
-      makeCall('toggleVoice', true);
-      this.wasMuted = false;
-    }
     // listen to the VoiceUsers changes and update the flag
     if (!this.muteHandle) {
       const query = VoiceUsers.find({ intId: Auth.userID }, { fields: { muted: 1, talking: 1 } });
       this.muteHandle = query.observeChanges({
         changed: (id, fields) => {
           if (fields.muted !== undefined && fields.muted !== this.isMuted) {
-            this.isMuted = true;
+            this.isMuted = fields.muted;
             const muteState = this.isMuted ? 'selfMuted' : 'selfUnmuted';
             window.parent.postMessage({ response: muteState }, '*');
           }
@@ -385,8 +379,6 @@ class AudioManager {
           this.onAudioExit();
         }
       } else if (status === RECONNECTING) {
-        //  I catch it here, because any place after reconnecting will clear this state
-        if (this.isMuted) this.wasMuted = true;
         logger.info({ logCode: 'audio_reconnecting' }, 'Attempting to reconnect audio');
         this.notify(this.intl.formatMessage(this.messages.info.RECONNECTING_AUDIO), true);
         this.playHangUpSound();
-- 
GitLab