From 2da08aa67ada81c488d5ff71fe658a0ea3104a2c Mon Sep 17 00:00:00 2001 From: Noah Petherbridge Date: Wed, 14 Jun 2023 21:06:57 -0700 Subject: [PATCH] You can not open the camera of someone you have muted --- web/static/js/BareRTC.js | 24 ++++++++++++++++++++++++ web/templates/chat.html | 4 ++-- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/web/static/js/BareRTC.js b/web/static/js/BareRTC.js index 5d654a5..e043cf1 100644 --- a/web/static/js/BareRTC.js +++ b/web/static/js/BareRTC.js @@ -430,6 +430,9 @@ const app = Vue.createApp({ delete this.muted[username]; } + // Hang up videos both ways. + this.closeVideo(username); + this.sendMute(username, mute); if (mute) { this.ChatClient( @@ -1057,6 +1060,12 @@ const app = Vue.createApp({ return; } + // If we have muted the target, we shouldn't view their video. + if (this.isMutedUser(user.username)) { + this.ChatClient(`You have muted ${user.username} and so should not see their camera.`); + return; + } + // Is the target user NSFW? Go thru the modal. let dontShowAgain = localStorage["skip-nsfw-modal"] == "true"; if (user.nsfw && !dontShowAgain && !force) { @@ -1135,6 +1144,21 @@ const app = Vue.createApp({ } } }, + isVideoNotAllowed(user) { + // Returns whether the video button to open a user's cam will be not allowed (crossed out) + + // Mutual video sharing is required on this camera, and ours is not active + if (user.videoActive && user.videoMutual && !this.webcam.active) { + return true; + } + + // We have muted them and it wouldn't be appropriate to still watch their video but not get their messages. + if (this.isMutedUser(user.username)) { + return true; + } + + return false; + }, // Show who watches our video. showViewers() { diff --git a/web/templates/chat.html b/web/templates/chat.html index 37a7218..2d61587 100644 --- a/web/templates/chat.html +++ b/web/templates/chat.html @@ -999,7 +999,7 @@ :class="{ 'is-danger is-outlined': u.videoActive && u.nsfw, 'is-info is-outlined': u.videoActive && !u.nsfw, - 'cursor-notallowed': u.videoActive && u.videoMutual && !webcam.active, + 'cursor-notallowed': isVideoNotAllowed(u), }" :title="`Open video stream` + (u.videoActive && u.videoMutual ? '; mutual video sharing required' : '') + @@ -1007,7 +1007,7 @@ @click="openVideo(u)"> + :class="isVideoNotAllowed(u) ? 'fa-video-slash' : 'fa-video'">