e2ee: broadcast e2ee enabled status using presnce
This commit is contained in:
parent
6ce27ef10d
commit
2ad6bfbc20
@ -196,6 +196,9 @@ StateListenerRegistry.register(
|
|||||||
JitsiConferenceEvents.PARTICIPANT_PROPERTY_CHANGED,
|
JitsiConferenceEvents.PARTICIPANT_PROPERTY_CHANGED,
|
||||||
(participant, propertyName, oldValue, newValue) => {
|
(participant, propertyName, oldValue, newValue) => {
|
||||||
switch (propertyName) {
|
switch (propertyName) {
|
||||||
|
case 'e2eeEnabled':
|
||||||
|
_e2eeUpdated(store, conference, participant.getId(), newValue);
|
||||||
|
break;
|
||||||
case 'features_e2ee':
|
case 'features_e2ee':
|
||||||
store.dispatch(participantUpdated({
|
store.dispatch(participantUpdated({
|
||||||
conference,
|
conference,
|
||||||
@ -218,8 +221,7 @@ StateListenerRegistry.register(
|
|||||||
}));
|
}));
|
||||||
break;
|
break;
|
||||||
case 'raisedHand': {
|
case 'raisedHand': {
|
||||||
_raiseHandUpdated(
|
_raiseHandUpdated(store, conference, participant.getId(), newValue);
|
||||||
store, conference, participant.getId(), newValue);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
@ -229,13 +231,34 @@ StateListenerRegistry.register(
|
|||||||
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// We left the conference, raise hand of the local participant must be updated.
|
const localParticipantId = getLocalParticipant(store.getState).getId();
|
||||||
_raiseHandUpdated(
|
|
||||||
store, conference, undefined, false);
|
// We left the conference, the local participant must be updated.
|
||||||
|
_e2eeUpdated(store, conference, localParticipantId, false);
|
||||||
|
_raiseHandUpdated(store, conference, localParticipantId, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles a E2EE enabled status update.
|
||||||
|
*
|
||||||
|
* @param {Function} dispatch - The Redux dispatch function.
|
||||||
|
* @param {Object} conference - The conference for which we got an update.
|
||||||
|
* @param {string} participantId - The ID of the participant from which we got an update.
|
||||||
|
* @param {boolean} newValue - The new value of the E2EE enabled status.
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
|
function _e2eeUpdated({ dispatch }, conference, participantId, newValue) {
|
||||||
|
const e2eeEnabled = newValue === 'true';
|
||||||
|
|
||||||
|
dispatch(participantUpdated({
|
||||||
|
conference,
|
||||||
|
id: participantId,
|
||||||
|
e2eeEnabled
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes the local participant and signals that it joined.
|
* Initializes the local participant and signals that it joined.
|
||||||
*
|
*
|
||||||
@ -331,7 +354,7 @@ function _maybePlaySounds({ getState, dispatch }, action) {
|
|||||||
* @returns {Object} The value returned by {@code next(action)}.
|
* @returns {Object} The value returned by {@code next(action)}.
|
||||||
*/
|
*/
|
||||||
function _participantJoinedOrUpdated({ dispatch, getState }, next, action) {
|
function _participantJoinedOrUpdated({ dispatch, getState }, next, action) {
|
||||||
const { participant: { avatarURL, email, id, local, name, raisedHand } } = action;
|
const { participant: { avatarURL, e2eeEnabled, email, id, local, name, raisedHand } } = action;
|
||||||
|
|
||||||
// Send an external update of the local participant's raised hand state
|
// Send an external update of the local participant's raised hand state
|
||||||
// if a new raised hand state is defined in the action.
|
// if a new raised hand state is defined in the action.
|
||||||
@ -346,6 +369,16 @@ function _participantJoinedOrUpdated({ dispatch, getState }, next, action) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Send an external update of the local participant's E2EE enabled state
|
||||||
|
// if a new state is defined in the action.
|
||||||
|
if (typeof e2eeEnabled !== 'undefined') {
|
||||||
|
if (local) {
|
||||||
|
const { conference } = getState()['features/base/conference'];
|
||||||
|
|
||||||
|
conference && conference.setLocalParticipantProperty('e2eeEnabled', e2eeEnabled);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Allow the redux update to go through and compare the old avatar
|
// Allow the redux update to go through and compare the old avatar
|
||||||
// to the new avatar and emit out change events if necessary.
|
// to the new avatar and emit out change events if necessary.
|
||||||
const result = next(action);
|
const result = next(action);
|
||||||
@ -378,25 +411,23 @@ function _participantJoinedOrUpdated({ dispatch, getState }, next, action) {
|
|||||||
*
|
*
|
||||||
* @param {Function} dispatch - The Redux dispatch function.
|
* @param {Function} dispatch - The Redux dispatch function.
|
||||||
* @param {Object} conference - The conference for which we got an update.
|
* @param {Object} conference - The conference for which we got an update.
|
||||||
* @param {string?} participantId - The ID of the participant from which we got an update. If undefined,
|
* @param {string} participantId - The ID of the participant from which we got an update.
|
||||||
* we update the local participant.
|
|
||||||
* @param {boolean} newValue - The new value of the raise hand status.
|
* @param {boolean} newValue - The new value of the raise hand status.
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
function _raiseHandUpdated({ dispatch, getState }, conference, participantId, newValue) {
|
function _raiseHandUpdated({ dispatch, getState }, conference, participantId, newValue) {
|
||||||
const raisedHand = newValue === 'true';
|
const raisedHand = newValue === 'true';
|
||||||
const pid = participantId || getLocalParticipant(getState()).id;
|
|
||||||
|
|
||||||
dispatch(participantUpdated({
|
dispatch(participantUpdated({
|
||||||
conference,
|
conference,
|
||||||
id: pid,
|
id: participantId,
|
||||||
raisedHand
|
raisedHand
|
||||||
}));
|
}));
|
||||||
|
|
||||||
if (raisedHand) {
|
if (raisedHand) {
|
||||||
dispatch(showNotification({
|
dispatch(showNotification({
|
||||||
titleArguments: {
|
titleArguments: {
|
||||||
name: getParticipantDisplayName(getState, pid)
|
name: getParticipantDisplayName(getState, participantId)
|
||||||
},
|
},
|
||||||
titleKey: 'notify.raisedHand'
|
titleKey: 'notify.raisedHand'
|
||||||
}, NOTIFICATION_TIMEOUT));
|
}, NOTIFICATION_TIMEOUT));
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
// @flow
|
// @flow
|
||||||
|
|
||||||
import { getCurrentConference } from '../base/conference';
|
import { getCurrentConference } from '../base/conference';
|
||||||
|
import { getLocalParticipant, participantUpdated } from '../base/participants';
|
||||||
import { MiddlewareRegistry, StateListenerRegistry } from '../base/redux';
|
import { MiddlewareRegistry, StateListenerRegistry } from '../base/redux';
|
||||||
|
|
||||||
import { SET_E2EE_KEY } from './actionTypes';
|
import { SET_E2EE_KEY } from './actionTypes';
|
||||||
@ -13,7 +14,7 @@ import logger from './logger';
|
|||||||
* @param {Store} store - The redux store.
|
* @param {Store} store - The redux store.
|
||||||
* @returns {Function}
|
* @returns {Function}
|
||||||
*/
|
*/
|
||||||
MiddlewareRegistry.register(({ getState }) => next => action => {
|
MiddlewareRegistry.register(({ dispatch, getState }) => next => action => {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case SET_E2EE_KEY: {
|
case SET_E2EE_KEY: {
|
||||||
const conference = getCurrentConference(getState);
|
const conference = getCurrentConference(getState);
|
||||||
@ -21,6 +22,15 @@ MiddlewareRegistry.register(({ getState }) => next => action => {
|
|||||||
if (conference) {
|
if (conference) {
|
||||||
logger.debug(`New E2EE key: ${action.key}`);
|
logger.debug(`New E2EE key: ${action.key}`);
|
||||||
conference.setE2EEKey(action.key);
|
conference.setE2EEKey(action.key);
|
||||||
|
|
||||||
|
// Broadccast that we enabled / disabled E2EE.
|
||||||
|
const participant = getLocalParticipant(getState);
|
||||||
|
|
||||||
|
dispatch(participantUpdated({
|
||||||
|
e2eeEnabled: Boolean(action.key),
|
||||||
|
id: participant.id,
|
||||||
|
local: true
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user