Plugin for anonymize users

I have created a new plugin and I think that it’s a good idea to let you know about it. The plugin was made for webapp 2 and I think that the way to do it could be interesting for implementing other use cases.

Goal

We want to have a plugin that anonymizes all the users inside a VMR. This plugin should change the display name and the overlay text (the text that appears over the video). It will display a random string instead. For example, for a user it could display anonymouse_5427.

How was it created

Create this plugin was a bit tricky. Change the overlay_text is easy. We have a method in PexRTC that does this. This method is setParticipantText(uuid, newOverlayText). However, the method can be only used if the user is the host of the meeting and we can have several hosts in the same meeting. This means that we have to define some rules:

  • If the user is the host of the meeting, he changes his own overlay_text.
  • If the user is a guest, the overlay_text is changed by the first host that joined the VMR.

The previous method will change only the overlay_text and the name in the roster list won’t be modified. For that we will have to do some work.

The first step is to save in a variable the function onParticipantCreate and avoid to call that until we know that the overlay_text was correctly changed. This could happen in the following situaltions:

  • If the user changed the overlay_text we can call it directly.
  • If we detect that the overlay_text was already changed in onParticipantCreate.
  • In any other case, we have to wait until receiving the onParticipantUpdate and we will override the participant data and trigger onParticipantCreate:
    (window as any).PEX.pexrtc.onParticipantUpdate = (participant: any) => {
      participant.display_name = participant.overlay_text;
      participant.uri = participant.overlay_text;
      onParticipantCreate(participant);
      onParticipantUpdate(participant);
    }

You can find the whole project in GitHub: GitHub - pexip/plugin-anonymizer: Plugin that anonymize the user's display names.

Future development

For example, one thing that we could add to the plugin is to only anonymize if the VMR has a certain structure. For example, if it begins with confidential-.

2 Likes