|
@@ -125,7 +125,7 @@ MiddlewareRegistry.register(store => next => action => {
|
125
|
125
|
store.dispatch(pushReactions(data.reactions));
|
126
|
126
|
|
127
|
127
|
_handleReceivedMessage(store, {
|
128
|
|
- id: participant.getId(),
|
|
128
|
+ participantId: participant.getId(),
|
129
|
129
|
message: getReactionMessageFromBuffer(data.reactions),
|
130
|
130
|
privateMessage: false,
|
131
|
131
|
lobbyChat: false,
|
|
@@ -137,12 +137,12 @@ MiddlewareRegistry.register(store => next => action => {
|
137
|
137
|
}
|
138
|
138
|
|
139
|
139
|
case NON_PARTICIPANT_MESSAGE_RECEIVED: {
|
140
|
|
- const { id, json: data } = action;
|
|
140
|
+ const { participantId, json: data } = action;
|
141
|
141
|
|
142
|
142
|
if (data?.type === MESSAGE_TYPE_SYSTEM && data.message) {
|
143
|
143
|
_handleReceivedMessage(store, {
|
144
|
144
|
displayName: data.displayName ?? i18next.t('chat.systemDisplayName'),
|
145
|
|
- id,
|
|
145
|
+ participantId,
|
146
|
146
|
lobbyChat: false,
|
147
|
147
|
message: data.message,
|
148
|
148
|
privateMessage: true,
|
|
@@ -213,7 +213,7 @@ MiddlewareRegistry.register(store => next => action => {
|
213
|
213
|
case ADD_REACTION_MESSAGE: {
|
214
|
214
|
if (localParticipant?.id) {
|
215
|
215
|
_handleReceivedMessage(store, {
|
216
|
|
- id: localParticipant.id,
|
|
216
|
+ participantId: localParticipant.id,
|
217
|
217
|
message: action.message,
|
218
|
218
|
privateMessage: false,
|
219
|
219
|
timestamp: Date.now(),
|
|
@@ -274,25 +274,30 @@ function _addChatMsgListener(conference: IJitsiConference, store: IStore) {
|
274
|
274
|
|
275
|
275
|
conference.on(
|
276
|
276
|
JitsiConferenceEvents.MESSAGE_RECEIVED,
|
277
|
|
- // eslint-disable-next-line max-params
|
278
|
|
- (id: string, message: string, timestamp: number, displayName: string, isGuest?: boolean) => {
|
|
277
|
+ /* eslint-disable max-params */
|
|
278
|
+ (participantId: string, message: string, timestamp: number,
|
|
279
|
+ displayName: string, isGuest: boolean, messageId: string) => {
|
|
280
|
+ /* eslint-enable max-params */
|
279
|
281
|
_onConferenceMessageReceived(store, {
|
280
|
|
- id: id || displayName, // in case of messages coming from visitors we can have unknown id
|
|
282
|
+ // in case of messages coming from visitors we can have unknown id
|
|
283
|
+ participantId: participantId || displayName,
|
281
|
284
|
message,
|
282
|
285
|
timestamp,
|
283
|
286
|
displayName,
|
284
|
287
|
isGuest,
|
|
288
|
+ messageId,
|
285
|
289
|
privateMessage: false });
|
286
|
290
|
}
|
287
|
291
|
);
|
288
|
292
|
|
289
|
293
|
conference.on(
|
290
|
294
|
JitsiConferenceEvents.PRIVATE_MESSAGE_RECEIVED,
|
291
|
|
- (id: string, message: string, timestamp: number) => {
|
|
295
|
+ (participantId: string, message: string, timestamp: number, messageId: string) => {
|
292
|
296
|
_onConferenceMessageReceived(store, {
|
293
|
|
- id,
|
|
297
|
+ participantId,
|
294
|
298
|
message,
|
295
|
299
|
timestamp,
|
|
300
|
+ messageId,
|
296
|
301
|
privateMessage: true
|
297
|
302
|
});
|
298
|
303
|
}
|
|
@@ -311,25 +316,29 @@ function _addChatMsgListener(conference: IJitsiConference, store: IStore) {
|
311
|
316
|
* @param {Object} message - The message object.
|
312
|
317
|
* @returns {void}
|
313
|
318
|
*/
|
314
|
|
-function _onConferenceMessageReceived(store: IStore, { displayName, id, isGuest, message, timestamp, privateMessage }: {
|
315
|
|
- displayName?: string; id: string; isGuest?: boolean;
|
316
|
|
- message: string; privateMessage: boolean; timestamp: number; }) {
|
|
319
|
+function _onConferenceMessageReceived(store: IStore,
|
|
320
|
+ { displayName, isGuest, message, messageId, participantId, privateMessage, timestamp }: {
|
|
321
|
+ displayName?: string; isGuest?: boolean; message: string; messageId?: string;
|
|
322
|
+ participantId: string; privateMessage: boolean; timestamp: number; }
|
|
323
|
+) {
|
|
324
|
+
|
317
|
325
|
const isGif = isGifMessage(message);
|
318
|
326
|
|
319
|
327
|
if (isGif) {
|
320
|
|
- _handleGifMessageReceived(store, id, message);
|
|
328
|
+ _handleGifMessageReceived(store, participantId, message);
|
321
|
329
|
if (getGifDisplayMode(store.getState()) === 'tile') {
|
322
|
330
|
return;
|
323
|
331
|
}
|
324
|
332
|
}
|
325
|
333
|
_handleReceivedMessage(store, {
|
326
|
334
|
displayName,
|
327
|
|
- id,
|
328
|
335
|
isGuest,
|
|
336
|
+ participantId,
|
329
|
337
|
message,
|
330
|
338
|
privateMessage,
|
331
|
339
|
lobbyChat: false,
|
332
|
|
- timestamp
|
|
340
|
+ timestamp,
|
|
341
|
+ messageId
|
333
|
342
|
}, true, isGif);
|
334
|
343
|
}
|
335
|
344
|
|
|
@@ -337,14 +346,14 @@ function _onConferenceMessageReceived(store: IStore, { displayName, id, isGuest,
|
337
|
346
|
* Handles a received gif message.
|
338
|
347
|
*
|
339
|
348
|
* @param {Object} store - Redux store.
|
340
|
|
- * @param {string} id - Id of the participant that sent the message.
|
|
349
|
+ * @param {string} participantId - Id of the participant that sent the message.
|
341
|
350
|
* @param {string} message - The message sent.
|
342
|
351
|
* @returns {void}
|
343
|
352
|
*/
|
344
|
|
-function _handleGifMessageReceived(store: IStore, id: string, message: string) {
|
|
353
|
+function _handleGifMessageReceived(store: IStore, participantId: string, message: string) {
|
345
|
354
|
const url = message.substring(GIF_PREFIX.length, message.length - 1);
|
346
|
355
|
|
347
|
|
- store.dispatch(addGif(id, url));
|
|
356
|
+ store.dispatch(addGif(participantId, url));
|
348
|
357
|
}
|
349
|
358
|
|
350
|
359
|
/**
|
|
@@ -374,7 +383,7 @@ function _handleChatError({ dispatch }: IStore, error: Error) {
|
374
|
383
|
export function handleLobbyMessageReceived(message: string, participantId: string) {
|
375
|
384
|
return async (dispatch: IStore['dispatch'], getState: IStore['getState']) => {
|
376
|
385
|
_handleReceivedMessage({ dispatch,
|
377
|
|
- getState }, { id: participantId,
|
|
386
|
+ getState }, { participantId,
|
378
|
387
|
message,
|
379
|
388
|
privateMessage: false,
|
380
|
389
|
lobbyChat: true,
|
|
@@ -387,18 +396,18 @@ export function handleLobbyMessageReceived(message: string, participantId: strin
|
387
|
396
|
* Function to get lobby chat user display name.
|
388
|
397
|
*
|
389
|
398
|
* @param {Store} state - The Redux store.
|
390
|
|
- * @param {string} id - The knocking participant id.
|
|
399
|
+ * @param {string} participantId - The knocking participant id.
|
391
|
400
|
* @returns {string}
|
392
|
401
|
*/
|
393
|
|
-function getLobbyChatDisplayName(state: IReduxState, id: string) {
|
|
402
|
+function getLobbyChatDisplayName(state: IReduxState, participantId: string) {
|
394
|
403
|
const { knockingParticipants } = state['features/lobby'];
|
395
|
404
|
const { lobbyMessageRecipient } = state['features/chat'];
|
396
|
405
|
|
397
|
|
- if (id === lobbyMessageRecipient?.id) {
|
|
406
|
+ if (participantId === lobbyMessageRecipient?.id) {
|
398
|
407
|
return lobbyMessageRecipient.name;
|
399
|
408
|
}
|
400
|
409
|
|
401
|
|
- const knockingParticipant = knockingParticipants.find(p => p.id === id);
|
|
410
|
+ const knockingParticipant = knockingParticipants.find(p => p.id === participantId);
|
402
|
411
|
|
403
|
412
|
if (knockingParticipant) {
|
404
|
413
|
return knockingParticipant.name;
|
|
@@ -417,9 +426,9 @@ function getLobbyChatDisplayName(state: IReduxState, id: string) {
|
417
|
426
|
* @returns {void}
|
418
|
427
|
*/
|
419
|
428
|
function _handleReceivedMessage({ dispatch, getState }: IStore,
|
420
|
|
- { displayName, id, isGuest, message, privateMessage, timestamp, lobbyChat }: {
|
421
|
|
- displayName?: string; id: string; isGuest?: boolean; lobbyChat: boolean;
|
422
|
|
- message: string; privateMessage: boolean; timestamp: number; },
|
|
429
|
+ { displayName, isGuest, lobbyChat, message, messageId, participantId, privateMessage, timestamp }: {
|
|
430
|
+ displayName?: string; isGuest?: boolean; lobbyChat: boolean; message: string;
|
|
431
|
+ messageId?: string; participantId: string; privateMessage: boolean; timestamp: number; },
|
423
|
432
|
shouldPlaySound = true,
|
424
|
433
|
isReaction = false
|
425
|
434
|
) {
|
|
@@ -434,12 +443,12 @@ function _handleReceivedMessage({ dispatch, getState }: IStore,
|
434
|
443
|
|
435
|
444
|
// Provide a default for the case when a message is being
|
436
|
445
|
// backfilled for a participant that has left the conference.
|
437
|
|
- const participant = getParticipantById(state, id) || { local: undefined };
|
|
446
|
+ const participant = getParticipantById(state, participantId) || { local: undefined };
|
438
|
447
|
|
439
|
448
|
const localParticipant = getLocalParticipant(getState);
|
440
|
449
|
let displayNameToShow = lobbyChat
|
441
|
|
- ? getLobbyChatDisplayName(state, id)
|
442
|
|
- : displayName || getParticipantDisplayName(state, id);
|
|
450
|
+ ? getLobbyChatDisplayName(state, participantId)
|
|
451
|
+ : displayName || getParticipantDisplayName(state, participantId);
|
443
|
452
|
const hasRead = participant.local || isChatOpen;
|
444
|
453
|
const timestampToDate = timestamp ? new Date(timestamp) : new Date();
|
445
|
454
|
const millisecondsTimestamp = timestampToDate.getTime();
|
|
@@ -455,13 +464,14 @@ function _handleReceivedMessage({ dispatch, getState }: IStore,
|
455
|
464
|
dispatch(addMessage({
|
456
|
465
|
displayName: displayNameToShow,
|
457
|
466
|
hasRead,
|
458
|
|
- id,
|
|
467
|
+ participantId,
|
459
|
468
|
messageType: participant.local ? MESSAGE_TYPE_LOCAL : MESSAGE_TYPE_REMOTE,
|
460
|
469
|
message,
|
461
|
470
|
privateMessage,
|
462
|
471
|
lobbyChat,
|
463
|
472
|
recipient: getParticipantDisplayName(state, localParticipant?.id ?? ''),
|
464
|
473
|
timestamp: millisecondsTimestamp,
|
|
474
|
+ messageId,
|
465
|
475
|
isReaction
|
466
|
476
|
}));
|
467
|
477
|
|
|
@@ -477,7 +487,7 @@ function _handleReceivedMessage({ dispatch, getState }: IStore,
|
477
|
487
|
|
478
|
488
|
APP.API.notifyReceivedChatMessage({
|
479
|
489
|
body: message,
|
480
|
|
- id,
|
|
490
|
+ from: participantId,
|
481
|
491
|
nick: displayNameToShow,
|
482
|
492
|
privateMessage,
|
483
|
493
|
ts: timestamp
|
|
@@ -512,7 +522,7 @@ function _persistSentPrivateMessage({ dispatch, getState }: IStore, recipientID:
|
512
|
522
|
dispatch(addMessage({
|
513
|
523
|
displayName,
|
514
|
524
|
hasRead: true,
|
515
|
|
- id: localParticipant.id,
|
|
525
|
+ participantId: localParticipant.id,
|
516
|
526
|
messageType: MESSAGE_TYPE_LOCAL,
|
517
|
527
|
message,
|
518
|
528
|
privateMessage: !isLobbyPrivateMessage,
|
|
@@ -562,7 +572,7 @@ function _shouldSendPrivateMessageTo(state: IReduxState, action: AnyAction) {
|
562
|
572
|
|
563
|
573
|
if (lastMessage.privateMessage) {
|
564
|
574
|
// We show the notice if the last received message was private.
|
565
|
|
- return lastMessage.id;
|
|
575
|
+ return lastMessage.participantId;
|
566
|
576
|
}
|
567
|
577
|
|
568
|
578
|
// But messages may come rapidly, we want to protect our users from mis-sending a message
|
|
@@ -577,7 +587,7 @@ function _shouldSendPrivateMessageTo(state: IReduxState, action: AnyAction) {
|
577
|
587
|
? recentPrivateMessages[0] : recentPrivateMessages[recentPrivateMessages.length - 1];
|
578
|
588
|
|
579
|
589
|
if (recentPrivateMessage) {
|
580
|
|
- return recentPrivateMessage.id;
|
|
590
|
+ return recentPrivateMessage.participantId;
|
581
|
591
|
}
|
582
|
592
|
|
583
|
593
|
return undefined;
|