fix: SoundController identity mismatch for federated users
Root cause: SoundController compared LiveKit participant p.userId (which is homeUserId from the home instance) against currentUser.id (local snowflake on the current instance). For federated users these are different IDs, so the controller thought the user's own presence was a stranger — playing user_join/user_leave for self. Fix: use homeUserId || id for the self-check. This matches the LiveKit identity format used in federated calls.
This commit is contained in:
@@ -12,6 +12,10 @@ function getSfxVolume(): number {
|
|||||||
export function SoundController() {
|
export function SoundController() {
|
||||||
const audioManager = AudioManager.getInstance();
|
const audioManager = AudioManager.getInstance();
|
||||||
const currentUser = useAuthStore((s) => s.user);
|
const currentUser = useAuthStore((s) => s.user);
|
||||||
|
// Federation-aware self-ID: in federated calls, LiveKit participant identity
|
||||||
|
// uses homeUserId (from the home instance), not the local snowflake ID.
|
||||||
|
// Without this, the SoundController thinks our own presence is a stranger.
|
||||||
|
const myId = currentUser?.homeUserId || currentUser?.id;
|
||||||
|
|
||||||
// Refs to track previous states
|
// Refs to track previous states
|
||||||
const isInitialMount = useRef(true);
|
const isInitialMount = useRef(true);
|
||||||
@@ -86,28 +90,28 @@ export function SoundController() {
|
|||||||
if (state.isLiveKitConnected && !justDisconnected) {
|
if (state.isLiveKitConnected && !justDisconnected) {
|
||||||
// Someone joined voice (Others only)
|
// Someone joined voice (Others only)
|
||||||
state.participants.forEach(p => {
|
state.participants.forEach(p => {
|
||||||
if (!prevParticipantIds.current.has(p.userId) && p.userId !== currentUser?.id) {
|
if (!prevParticipantIds.current.has(p.userId) && p.userId !== myId) {
|
||||||
audioManager.playSound('user_join', sfxOpts);
|
audioManager.playSound('user_join', sfxOpts);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Someone left voice (Others only)
|
// Someone left voice (Others only)
|
||||||
prevParticipantIds.current.forEach(userId => {
|
prevParticipantIds.current.forEach(userId => {
|
||||||
if (!currentParticipantIds.has(userId) && userId !== currentUser?.id) {
|
if (!currentParticipantIds.has(userId) && userId !== myId) {
|
||||||
audioManager.playSound('user_leave', sfxOpts);
|
audioManager.playSound('user_leave', sfxOpts);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Someone started screen sharing (Others only)
|
// Someone started screen sharing (Others only)
|
||||||
state.participants.forEach(p => {
|
state.participants.forEach(p => {
|
||||||
if (p.isScreenSharing && !prevScreenShareUserIds.current.has(p.userId) && p.userId !== currentUser?.id) {
|
if (p.isScreenSharing && !prevScreenShareUserIds.current.has(p.userId) && p.userId !== myId) {
|
||||||
audioManager.playSound('stream_user_joined', sfxOpts);
|
audioManager.playSound('stream_user_joined', sfxOpts);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Someone stopped screen sharing (Others only)
|
// Someone stopped screen sharing (Others only)
|
||||||
prevScreenShareUserIds.current.forEach(userId => {
|
prevScreenShareUserIds.current.forEach(userId => {
|
||||||
if (!currentScreenShareUserIds.has(userId) && userId !== currentUser?.id) {
|
if (!currentScreenShareUserIds.has(userId) && userId !== myId) {
|
||||||
audioManager.playSound('stream_user_left', sfxOpts);
|
audioManager.playSound('stream_user_left', sfxOpts);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -179,7 +183,7 @@ export function SoundController() {
|
|||||||
if (incomingCallLoop.current) incomingCallLoop.current.stop();
|
if (incomingCallLoop.current) incomingCallLoop.current.stop();
|
||||||
if (outgoingCallLoop.current) outgoingCallLoop.current.stop();
|
if (outgoingCallLoop.current) outgoingCallLoop.current.stop();
|
||||||
};
|
};
|
||||||
}, [audioManager, currentUser?.id]);
|
}, [audioManager, myId]);
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user