Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(avatar): Prefer avatar url from jwt identity. #15055

Merged
merged 1 commit into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions conference.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ import {
import {
getLocalParticipant,
getNormalizedDisplayName,
getParticipantByIdOrUndefined,
getVirtualScreenshareParticipantByOwnerId
} from './react/features/base/participants/functions';
import { updateSettings } from './react/features/base/settings/actions';
Expand Down Expand Up @@ -1775,12 +1776,17 @@ export default {
room.addCommandListener(
this.commands.defaults.AVATAR_URL,
(data, from) => {
APP.store.dispatch(
participantUpdated({
conference: room,
id: from,
avatarURL: data.value
}));
const participant = getParticipantByIdOrUndefined(APP.store, from);

// if already set from presence(jwt), skip the command processing
if (!participant?.avatarURL) {
APP.store.dispatch(
participantUpdated({
conference: room,
id: from,
avatarURL: data.value
}));
}
});

room.on(
Expand Down
4 changes: 3 additions & 1 deletion modules/API/API.js
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,9 @@ function initCommands() {
sendAnalytics(createApiEvent('email.changed'));
APP.conference.changeLocalEmail(email);
},
'avatar-url': avatarUrl => {
'avatar-url': avatarUrl => { // @deprecated
console.warn('Using command avatarUrl is deprecated. Use context.user.avatar in the jwt.');

sendAnalytics(createApiEvent('avatar.url.changed'));
APP.conference.changeLocalAvatarUrl(avatarUrl);
},
Expand Down
19 changes: 13 additions & 6 deletions react/features/base/conference/actions.any.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
participantSourcesUpdated,
participantUpdated
} from '../participants/actions';
import { getNormalizedDisplayName } from '../participants/functions';
import { getNormalizedDisplayName, getParticipantByIdOrUndefined } from '../participants/functions';
import { IJitsiParticipant } from '../participants/types';
import { toState } from '../redux/functions';
import {
Expand Down Expand Up @@ -277,11 +277,18 @@ function _addConferenceListeners(conference: IJitsiConference, dispatch: IStore[

conference.addCommandListener(
AVATAR_URL_COMMAND,
(data: { value: string; }, id: string) => dispatch(participantUpdated({
conference,
id,
avatarURL: data.value
})));
(data: { value: string; }, id: string) => {
const participant = getParticipantByIdOrUndefined(state, id);

// if already set from presence(jwt), skip the command processing
if (!participant?.avatarURL) {
return dispatch(participantUpdated({
conference,
id,
avatarURL: data.value
}));
}
});
conference.addCommandListener(
EMAIL_COMMAND,
(data: { value: string; }, id: string) => dispatch(participantUpdated({
Expand Down
2 changes: 2 additions & 0 deletions react/features/base/conference/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ export function commonUserJoinedHandling(
} else {
const isReplacing = user?.isReplacing();

// the identity and avatar come from jwt and never change in the presence
dispatch(participantJoined({
avatarURL: user.getIdentity()?.user?.avatar,
botType: user.getBotType(),
conference,
id,
Expand Down