Add handling for "event.participants.update.all"

In case a moderator of a restricted room ends the call for all
participants a update participants event with the field 'all=true' will
be thrown by the HPB.

    {
      "type": "event"
      "event": {
        "target": "participants",
        "type": "update",
        "update": [
          "roomid": "the-room-id",
          "incall": new-incall-state,
          "all": true
        ]
      }
    }

In that case the call can be ended directly without handling every
single participant.

Resolves: #1881

Signed-off-by: Tim Krüger <t@timkrueger.me>
This commit is contained in:
Tim Krüger 2022-05-04 12:32:35 +02:00
parent 36a020d785
commit 4f5a344a20
No known key found for this signature in database
GPG key ID: FECE3A7222C52A4E
2 changed files with 33 additions and 7 deletions

View file

@ -93,9 +93,9 @@ import com.nextcloud.talk.utils.power.PowerManagerUtils;
import com.nextcloud.talk.utils.preferences.AppPreferences;
import com.nextcloud.talk.utils.singletons.ApplicationWideCurrentRoomHolder;
import com.nextcloud.talk.webrtc.MagicAudioManager;
import com.nextcloud.talk.webrtc.PeerConnectionWrapper;
import com.nextcloud.talk.webrtc.MagicWebRTCUtils;
import com.nextcloud.talk.webrtc.MagicWebSocketInstance;
import com.nextcloud.talk.webrtc.PeerConnectionWrapper;
import com.nextcloud.talk.webrtc.WebSocketConnectionHelper;
import com.wooplr.spotlight.SpotlightView;
@ -1481,11 +1481,24 @@ public class CallActivity extends CallBaseActivity {
break;
case "participantsUpdate":
Log.d(TAG, "onMessageEvent 'participantsUpdate'");
if (webSocketCommunicationEvent.getHashMap().get("roomToken").equals(roomToken)) {
processUsersInRoom(
(List<HashMap<String, Object>>) webSocketClient
.getJobWithId(
Integer.valueOf(webSocketCommunicationEvent.getHashMap().get("jobId"))));
// See MagicWebSocketInstance#onMessage in case "participants" how the 'updateParameters' are created
Map<String, String> updateParameters = webSocketCommunicationEvent.getHashMap();
if (roomToken.equals(updateParameters.get("roomToken"))) {
if (updateParameters.containsKey("all") && Boolean.parseBoolean(updateParameters.get("all"))) {
if (updateParameters.containsKey("incall") && "0".equals(updateParameters.get("incall"))) {
Log.d(TAG, "Most probably a moderator ended the call for all.");
hangup(true);
}
} else if (updateParameters.containsKey("jobId")) {
// In that case a list of users for the room is passed.
processUsersInRoom(
(List<HashMap<String, Object>>) webSocketClient
.getJobWithId(
Integer.valueOf(updateParameters.get("jobId"))));
}
}
break;
case "signalingMessage":

View file

@ -269,7 +269,20 @@ public class MagicWebSocketInstance extends WebSocketListener {
HashMap<String, String> refreshChatHashMap = new HashMap<>();
HashMap<String, Object> updateEventMap = (HashMap<String, Object>) eventOverallWebSocketMessage.getEventMap().get("update");
refreshChatHashMap.put("roomToken", (String) updateEventMap.get("roomid"));
refreshChatHashMap.put("jobId", Integer.toString(magicMap.add(updateEventMap.get("users"))));
if (updateEventMap.containsKey("users")) {
refreshChatHashMap.put("jobId", Integer.toString(magicMap.add(updateEventMap.get("users"))));
}
if (updateEventMap.containsKey("incall")) {
refreshChatHashMap.put("incall",
Long.toString((Long)updateEventMap.get("incall")));
}
if (updateEventMap.containsKey("all")) {
refreshChatHashMap.put("all", Boolean.toString((Boolean) updateEventMap.get("all")));
}
eventBus.post(new WebSocketCommunicationEvent("participantsUpdate", refreshChatHashMap));
}
break;