From 513fd90d476168423fa968174e6333199062c417 Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Sun, 25 May 2014 15:49:07 +0200 Subject: [PATCH] Don't display cryptic peer ID When the participant hasn't set a display name --- lib/Vroom/I18N/en.pm | 2 ++ lib/Vroom/I18N/fr.pm | 2 ++ public/js/vroom.js | 40 ++++++++++++++++++++++++++-------------- 3 files changed, 30 insertions(+), 14 deletions(-) diff --git a/lib/Vroom/I18N/en.pm b/lib/Vroom/I18N/en.pm index f7fc6ae..a6d881e 100644 --- a/lib/Vroom/I18N/en.pm +++ b/lib/Vroom/I18N/en.pm @@ -131,6 +131,8 @@ our %Lexicon = ( "CANT_SUSPEND_OWNER" => "You can't suspend this participant's webcam", "YOU_HAVE_KICKED_s" => "You have kicked %s out of the room", "CANT_KICK_OWNER" => "You can't kick this participant out of the room", + "A_ROOM_ADMIN" => "a room administrator", + "A_PARTICIPANT" => "a participant", "MIC_MUTED" => "Your microphone is now muted", "MIC_UNMUTED" => "Your microphone is now unmuted", "CAM_SUSPENDED" => "Your webcam is now suspended", diff --git a/lib/Vroom/I18N/fr.pm b/lib/Vroom/I18N/fr.pm index f607fdf..34ef601 100644 --- a/lib/Vroom/I18N/fr.pm +++ b/lib/Vroom/I18N/fr.pm @@ -139,6 +139,8 @@ our %Lexicon = ( "CANT_SUSPEND_OWNER" => "Vous ne pouvez pas mettre la webcam de ce participant en pause", "YOU_HAVE_KICKED_s" => "Vous avez bani %s du salon", "CANT_KICK_OWNER" => "Vous ne pouvez pas bannir ce participant", + "A_ROOM_ADMIN" => "un administrateur du salon", + "A_PARTICIPANT" => "un participant", "MIC_MUTED" => "Votre micro est coupé", "MIC_UNMUTED" => "Votre micro est à nouveau actif", "CAM_SUSPENDED" => "Votre webcam est en pause", diff --git a/public/js/vroom.js b/public/js/vroom.js index acaff0b..be65b9b 100644 --- a/public/js/vroom.js +++ b/public/js/vroom.js @@ -4,7 +4,6 @@ released under the MIT licence Copyright 2014 Firewall Services */ - // Default notifications $.notify.defaults( { globalPosition: 'bottom left' } ); // Enable tooltip on required elements @@ -57,7 +56,9 @@ var locale = { YOU_HAVE_KICKED_s: '', CANT_KICK_OWNER: '', REMOVE_THIS_ADDRESS: '', - DISPLAY_NAME_REQUIRED: '' + DISPLAY_NAME_REQUIRED: '', + A_ROOM_ADMIN: '', + A_PARTICIPANT: '' }; // Localize the strings we need @@ -562,12 +563,13 @@ function initVroom(room) { function mutePeer(id){ if (peers[id] && peers[id].role != 'owner'){ var msg = locale.YOU_HAVE_MUTED_s; + var who = (peers[id].hasName) ? peers[id].displayName : locale.A_PARTICIPANT; if (peers[id].micMuted){ msg = locale.YOU_HAVE_UNMUTED_s } // notify everyone that we have muted this peer webrtc.sendToAll('owner_toggle_mute', {peer: id}); - $.notify(sprintf(msg, peers[id].displayName), 'info'); + $.notify(sprintf(msg, who), 'info'); } // We cannot mute another owner else{ @@ -578,11 +580,12 @@ function initVroom(room) { function pausePeer(id){ if (peers[id] && peers[id].role != 'owner'){ var msg = locale.YOU_HAVE_SUSPENDED_s; + var who = (peers[id].hasName) ? peers[id].displayName : locale.A_PARTICIPANT; if (peers[id].videoPaused){ msg = locale.YOU_HAVE_RESUMED_s; } webrtc.sendToAll('owner_toggle_pause', {peer: id}); - $.notify(sprintf(msg, peers[id].displayName), 'info'); + $.notify(sprintf(msg, who), 'info'); } else{ $.notify(locale.CANT_SUSPEND_OWNER, 'error'); @@ -599,7 +602,8 @@ function initVroom(room) { peers[id].obj.end(); } }, 2000); - $.notify(sprintf(locale.YOU_HAVE_KICKED_s, peers[id].displayName), 'info'); + var who = (peers[id].hasName) ? peers[id].displayName : locale.A_PARTICIPANT; + $.notify(sprintf(locale.YOU_HAVE_KICKED_s, who), 'info'); } else{ $.notify(locale.CANT_KICK_OWNER, 'error'); @@ -651,26 +655,29 @@ function initVroom(room) { // We are the one being (un)muted, and we're not owner // Be nice and obey if (data.payload.peer && data.payload.peer == peers.local.id && peers.local.role != 'owner'){ + var who = (peers[data.id].hasName) ? peers[data.id].displayName : locale.A_ROOM_ADMIN; if (!peers.local.micMuted){ muteMic(); $('#muteMicLabel').addClass('btn-danger active'); $('#muteMicButton').prop('checked', true); - $.notify(sprintf(locale.s_IS_MUTING_YOU, peers[data.id].displayName), 'info'); + $.notify(sprintf(locale.s_IS_MUTING_YOU, who), 'info'); } else { unmuteMic(); $('#muteMicLabel').removeClass('btn-danger active'); $('#muteMicButton').prop('checked', false); - $.notify(sprintf(locale.s_IS_UNMUTING_YOU, peers[data.id].displayName), 'info'); + $.notify(sprintf(locale.s_IS_UNMUTING_YOU, who), 'info'); } } // It's another peer of the room else if (data.payload.peer != peers.local.id && peers[data.payload.peer]){ + var who = (peers[data.id].hasName) ? peers[data.id].displayName : locale.A_ROOM_ADMIN; + var target = (peers[data.payload.peer].hasName) ? peers[data.payload.peer].displayName : locale.A_PARTICIPANT; if (peers[data.payload.peer].micMuted){ - $.notify(sprintf(locale.s_IS_UNMUTING_s, peers[data.id].displayName, peers[data.payload.peer].displayName), 'info'); + $.notify(sprintf(locale.s_IS_UNMUTING_s, peers[data.id].who, target), 'info'); } else{ - $.notify(sprintf(locale.s_IS_MUTING_s, peers[data.id].displayName, peers[data.payload.peer].displayName), 'info'); + $.notify(sprintf(locale.s_IS_MUTING_s, who, target), 'info'); } } }); @@ -681,25 +688,28 @@ function initVroom(room) { return; } if (data.payload.peer && data.payload.peer == peers.local.id && peers.local.role != 'owner'){ + var who = (peers[data.id].hasName) ? peers[data.id].displayName : locale.A_ROOM_ADMIN; if (!peers.local.videoPaused){ suspendCam(); $('#suspendCamLabel').addClass('btn-danger active'); $('#suspendCamButton').prop('checked', true); - $.notify(sprintf(locale.s_IS_SUSPENDING_YOU, peers[data.id].displayName), 'info'); + $.notify(sprintf(locale.s_IS_SUSPENDING_YOU, who), 'info'); } else{ resumeCam(); $('#suspendCamLabel').removeClass('btn-danger active'); $('#suspendCamButton').prop('checked', false); - $.notify(sprintf(locale.s_IS_RESUMING_YOU, peers[data.id].displayName), 'info'); + $.notify(sprintf(locale.s_IS_RESUMING_YOU, who), 'info'); } } else if (data.payload.peer != peers.local.id && peers[data.payload.peer]){ + var who = (peers[data.id].hasName) ? peers[data.id].displayName : locale.A_ROOM_ADMIN; + var target = (peers[data.payload.peer].hasName) ? peers[data.payload.peer].displayName : locale.A_PARTICIPANT; if (peers[data.payload.peer].videoPaused){ - $.notify(sprintf(locale.s_IS_RESUMING_s, peers[data.id].displayName, peers[data.payload.peer].displayName), 'info'); + $.notify(sprintf(locale.s_IS_RESUMING_s, who, target), 'info'); } else{ - $.notify(sprintf(locale.s_IS_SUSPENDING_s, peers[data.id].displayName, peers[data.payload.peer].displayName), 'info'); + $.notify(sprintf(locale.s_IS_SUSPENDING_s, who, target), 'info'); } } }); @@ -713,7 +723,9 @@ function initVroom(room) { window.location.assign(rootUrl + 'kicked/' + roomName); } else if (data.payload.peer != peers.local.id && peers[data.payload.peer] && peers[data.payload.peer].role != 'owner'){ - $.notify(sprintf(locale.s_IS_KICKING_s, peers[data.id].displayName, peers[data.payload.peer].displayName), 'info'); + var who = (peers[data.id].hasName) ? peers[data.id].displayName : locale.A_ROOM_ADMIN; + var target = (peers[data.payload.peer].hasName) ? peers[data.payload.peer].displayName : locale.A_PARTICIPANT; + $.notify(sprintf(locale.s_IS_KICKING_s, who, target), 'info'); // Wait a bit for the peer to leave, but end connection if it's still here // after 2 seconds setTimeout(function(){