|
@@ -2,7 +2,7 @@
|
2
|
2
|
|
3
|
3
|
import { CONFERENCE_FAILED, CONFERENCE_JOINED } from '../base/conference';
|
4
|
4
|
import { JitsiConferenceErrors, JitsiConferenceEvents } from '../base/lib-jitsi-meet';
|
5
|
|
-import { getFirstLoadableAvatarUrl } from '../base/participants';
|
|
5
|
+import { getFirstLoadableAvatarUrl, getParticipantDisplayName } from '../base/participants';
|
6
|
6
|
import { MiddlewareRegistry, StateListenerRegistry } from '../base/redux';
|
7
|
7
|
import { NOTIFICATION_TYPE, showNotification } from '../notifications';
|
8
|
8
|
import { isPrejoinPageEnabled } from '../prejoin/functions';
|
|
@@ -17,6 +17,7 @@ import {
|
17
|
17
|
startKnocking,
|
18
|
18
|
setPasswordJoinFailed
|
19
|
19
|
} from './actions';
|
|
20
|
+import { getKnockingParticipantById } from './functions';
|
20
|
21
|
|
21
|
22
|
MiddlewareRegistry.register(store => next => action => {
|
22
|
23
|
switch (action.type) {
|
|
@@ -43,7 +44,7 @@ MiddlewareRegistry.register(store => next => action => {
|
43
|
44
|
*/
|
44
|
45
|
StateListenerRegistry.register(
|
45
|
46
|
state => state['features/base/conference'].conference,
|
46
|
|
- (conference, { dispatch }, previousConference) => {
|
|
47
|
+ (conference, { dispatch, getState }, previousConference) => {
|
47
|
48
|
if (conference && !previousConference) {
|
48
|
49
|
conference.on(JitsiConferenceEvents.MEMBERS_ONLY_CHANGED, enabled => {
|
49
|
50
|
dispatch(setLobbyModeEnabled(enabled));
|
|
@@ -66,6 +67,13 @@ StateListenerRegistry.register(
|
66
|
67
|
conference.on(JitsiConferenceEvents.LOBBY_USER_LEFT, id => {
|
67
|
68
|
dispatch(knockingParticipantLeft(id));
|
68
|
69
|
});
|
|
70
|
+
|
|
71
|
+ conference.on(JitsiConferenceEvents.ENDPOINT_MESSAGE_RECEIVED, (origin, sender) =>
|
|
72
|
+ _maybeSendLobbyNotification(origin, sender, {
|
|
73
|
+ dispatch,
|
|
74
|
+ getState
|
|
75
|
+ })
|
|
76
|
+ );
|
69
|
77
|
}
|
70
|
78
|
});
|
71
|
79
|
|
|
@@ -151,3 +159,43 @@ function _findLoadableAvatarForKnockingParticipant({ dispatch, getState }, { id
|
151
|
159
|
});
|
152
|
160
|
}
|
153
|
161
|
}
|
|
162
|
+
|
|
163
|
+/**
|
|
164
|
+ * Check the endpoint message that arrived through the conference and
|
|
165
|
+ * sends a lobby notification, if the message belongs to the feature.
|
|
166
|
+ *
|
|
167
|
+ * @param {Object} origin - The origin (initiator) of the message.
|
|
168
|
+ * @param {Object} message - The actual message.
|
|
169
|
+ * @param {Object} store - The Redux store.
|
|
170
|
+ * @returns {void}
|
|
171
|
+ */
|
|
172
|
+function _maybeSendLobbyNotification(origin, message, { dispatch, getState }) {
|
|
173
|
+ if (!origin?._id || message?.type !== 'lobby-notify') {
|
|
174
|
+ return;
|
|
175
|
+ }
|
|
176
|
+
|
|
177
|
+ const notificationProps: any = {
|
|
178
|
+ descriptionArguments: {
|
|
179
|
+ originParticipantName: getParticipantDisplayName(getState, origin._id)
|
|
180
|
+ },
|
|
181
|
+ titleKey: 'lobby.notificationTitle'
|
|
182
|
+ };
|
|
183
|
+
|
|
184
|
+ switch (message.event) {
|
|
185
|
+ case 'LOBBY-ENABLED':
|
|
186
|
+ notificationProps.descriptionKey = `lobby.notificationLobby${message.value ? 'En' : 'Dis'}abled`;
|
|
187
|
+ break;
|
|
188
|
+ case 'LOBBY-ACCESS-GRANTED':
|
|
189
|
+ notificationProps.descriptionKey = 'lobby.notificationLobbyAccessGranted';
|
|
190
|
+ notificationProps.descriptionArguments.targetParticipantName
|
|
191
|
+ = getKnockingParticipantById(getState, message.value)?.name;
|
|
192
|
+ break;
|
|
193
|
+ case 'LOBBY-ACCESS-DENIED':
|
|
194
|
+ notificationProps.descriptionKey = 'lobby.notificationLobbyAccessDenied';
|
|
195
|
+ notificationProps.descriptionArguments.targetParticipantName
|
|
196
|
+ = getKnockingParticipantById(getState, message.value)?.name;
|
|
197
|
+ break;
|
|
198
|
+ }
|
|
199
|
+
|
|
200
|
+ dispatch(showNotification(notificationProps, 5000));
|
|
201
|
+}
|