Skip to content

Commit

Permalink
feat(avmoderation): When muting skip the actor.
Browse files Browse the repository at this point in the history
  • Loading branch information
damencho committed Feb 19, 2025
1 parent 54138e0 commit 81d5598
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,9 @@ default JibriSipGateway getJibriSipGateway()
/**
* Used for av moderation, when we want to mute all participants.
* @param mediaType the media type we want to mute.
* @param actor the entity that requested the mute.
*/
void muteAllParticipants(MediaType mediaType);
void muteAllParticipants(MediaType mediaType, EntityFullJid actor);

/**
* Return {@code true} if the user with the given JID should be allowed to invite jigasi to this conference.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1645,7 +1645,7 @@ else if (member.isJigasi())
/**
* Mutes all participants (except jibri or jigasi without "audioMute" support). Will block for colibri responses.
*/
public void muteAllParticipants(MediaType mediaType)
public void muteAllParticipants(MediaType mediaType, EntityFullJid actor)
{
Set<Participant> participantsToMute = new HashSet<>();
synchronized (participantLock)
Expand All @@ -1665,8 +1665,11 @@ public void muteAllParticipants(MediaType mediaType)

// Force mute at the backend. We assume this was successful. If for some reason it wasn't the colibri layer
// should handle it (e.g. remove a broken bridge).
// we skip the participant that enabled the av moderation
getColibriSessionManager().mute(
participantsToMute.stream().map(Participant::getEndpointId).collect(Collectors.toSet()),
participantsToMute.stream()
.filter(p -> p.getMucJid() != actor)
.map(Participant::getEndpointId).collect(Collectors.toSet()),
true,
mediaType);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,11 @@ class AvModerationHandler(
logger.info(
"Moderation for $mediaType in $conferenceJid was enabled by ${incomingJson["actor"]}"
)
// let's mute everyone
conference.muteAllParticipants(mediaType)
// let's mute everyone except the actor
conference.muteAllParticipants(
mediaType,
JidCreate.entityFullFrom(incomingJson["actor"]?.toString())
)
}
}
incomingJson["whitelists"]?.let {
Expand Down

0 comments on commit 81d5598

Please sign in to comment.