Web Push Notifications: Disable script when impersonated

If an admin needs to impersonate a regular user (to diagnose a support
issue or investigate a reported conversation thread), the web push
script is disabled so that the admin doesn't get subscribed to push
notifications for that user.
This commit is contained in:
Noah Petherbridge 2024-09-14 12:07:18 -07:00
parent 7991320256
commit ae84ddf449
2 changed files with 5 additions and 2 deletions

View File

@ -1563,7 +1563,7 @@ window.addEventListener("DOMContentLoaded", (event) => {
$pushDeniedHelp = document.querySelector("#push-denied-help"); $pushDeniedHelp = document.querySelector("#push-denied-help");
// Is the Notification API unavailable? // Is the Notification API unavailable?
if (typeof(window.Notification) === "undefined") { if (typeof(window.Notification) === "undefined" || typeof(PushNotificationSubscribe) === "undefined") {
$pushStatusDefault.innerHTML = `<i class="fa fa-xmark mr-1"></i> Notification API unavailable`; $pushStatusDefault.innerHTML = `<i class="fa fa-xmark mr-1"></i> Notification API unavailable`;
$pushStatusDefault.style.display = ""; $pushStatusDefault.style.display = "";
return; return;

View File

@ -381,7 +381,10 @@
<script type="text/javascript" src="/static/js/vue-3.2.45.js"></script> <script type="text/javascript" src="/static/js/vue-3.2.45.js"></script>
<script type="text/javascript" src="/static/js/htmx-1.9.12.min.js"></script> <script type="text/javascript" src="/static/js/htmx-1.9.12.min.js"></script>
<script type="text/javascript" src="/static/js/slim-forms.js?build={{.BuildHash}}"></script> <script type="text/javascript" src="/static/js/slim-forms.js?build={{.BuildHash}}"></script>
{{if not .SessionImpersonated -}}
{{- /* Disable web push script if impersonated, so an admin doesn't subscribe to user's notifications */ -}}
<script type="text/javascript" src="/static/js/web-push.js?build={{.BuildHash}}"></script> <script type="text/javascript" src="/static/js/web-push.js?build={{.BuildHash}}"></script>
{{- end}}
{{template "scripts" .}} {{template "scripts" .}}
<!-- Likes modal --> <!-- Likes modal -->