fix: persist server mute/deafen state across reloads and prevent client bypass
Server-side: add DB persistence for voice restrictions (schema, migration, ready payload, cleanup on leave). Client-side: fix four bugs that wiped or bypassed server restriction state — leaveVoice() no longer clears global restriction Sets, voice_state_update leave no longer drops amber icons, toggleMic/toggleDeafen now guard against server restrictions, and force-mute/ deafen uses direct setState instead of fragile toggle calls.
This commit is contained in:
@@ -768,6 +768,14 @@ export async function spaceRoutes(app: FastifyInstance): Promise<void> {
|
||||
))
|
||||
.run();
|
||||
|
||||
// Clean up any voice restrictions for the removed member
|
||||
db.delete(schema.voiceRestrictions).where(
|
||||
and(
|
||||
eq(schema.voiceRestrictions.spaceId, id),
|
||||
eq(schema.voiceRestrictions.userId, uid),
|
||||
)
|
||||
).run();
|
||||
|
||||
// Broadcast member_left event
|
||||
connectionManager.sendToSpace(id, {
|
||||
type: 'member_left',
|
||||
@@ -1038,6 +1046,12 @@ export async function spaceRoutes(app: FastifyInstance): Promise<void> {
|
||||
eq(schema.memberRoles.spaceId, id),
|
||||
eq(schema.memberRoles.userId, targetId),
|
||||
)).run();
|
||||
|
||||
// Clean up any voice restrictions for the banned member
|
||||
tx.delete(schema.voiceRestrictions).where(and(
|
||||
eq(schema.voiceRestrictions.spaceId, id),
|
||||
eq(schema.voiceRestrictions.userId, targetId),
|
||||
)).run();
|
||||
});
|
||||
|
||||
// Broadcast member_left event so other clients update their member list
|
||||
|
||||
Reference in New Issue
Block a user