Skip to content

Commit

Permalink
feat(external-api) add "name" property to participant-kicked-out event
Browse files Browse the repository at this point in the history
  • Loading branch information
saghul committed Jul 31, 2024
1 parent 6ff7995 commit 2483d90
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 10 deletions.
4 changes: 2 additions & 2 deletions modules/API/API.js
Original file line number Diff line number Diff line change
Expand Up @@ -1819,9 +1819,9 @@ class API {
* Notify external application of a participant, remote or local, being
* removed from the conference by another participant.
*
* @param {string} kicked - The ID of the participant removed from the
* @param {Object} kicked - The participant removed from the
* conference.
* @param {string} kicker - The ID of the participant that removed the
* @param {Object} kicker - The participant that removed the
* other participant.
* @returns {void}
*/
Expand Down
45 changes: 37 additions & 8 deletions react/features/external-api/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ import {
import {
getDominantSpeakerParticipant,
getLocalParticipant,
getParticipantById
getParticipantById,
getParticipantDisplayName
} from '../base/participants/functions';
import MiddlewareRegistry from '../base/redux/MiddlewareRegistry';
import { getBaseUrl } from '../base/util/helpers';
Expand Down Expand Up @@ -133,15 +134,29 @@ MiddlewareRegistry.register(store => next => action => {
APP.API.notifyDataChannelOpened();
break;

case KICKED_OUT:
case KICKED_OUT: {
const state = store.getState();
const localParticipant = getLocalParticipant(state);

if (!localParticipant) {
break;
}

const pId = action.participant.getId();

APP.API.notifyKickedOut(
{
id: getLocalParticipant(store.getState())?.id,
id: localParticipant.id,
name: getParticipantDisplayName(state, localParticipant.id),
local: true
},
{ id: action.participant ? action.participant.getId() : undefined }
{
id: pId,
name: getParticipantDisplayName(state, pId)
}
);
break;
}

case NOTIFY_CAMERA_ERROR:
if (action.error) {
Expand All @@ -156,14 +171,28 @@ MiddlewareRegistry.register(store => next => action => {
}
break;

case PARTICIPANT_KICKED:
case PARTICIPANT_KICKED: {
const state = store.getState();
const kickedParticipant = getParticipantById(state, action.kicked);
const kickerParticipant = getParticipantById(state, action.kicker);

if (!kickerParticipant || !kickedParticipant) {
break;
}

APP.API.notifyKickedOut(
{
id: action.kicked,
local: false
id: kickedParticipant.id,
local: kickedParticipant.local,
name: getParticipantDisplayName(state, kickedParticipant.id)
},
{ id: action.kicker });
{
id: kickerParticipant.id,
local: kickerParticipant.local,
name: getParticipantDisplayName(state, kickerParticipant.id)
});
break;
}

case PARTICIPANT_LEFT: {
const { participant } = action;
Expand Down

0 comments on commit 2483d90

Please sign in to comment.