Internal
Public Access
Add Web Push notifications (PWA)
Wires up the previously-scaffolded VAPID/DeviceToken infrastructure end to end: browser subscription flow on the Profile page's existing "Push Notifications" toggle, a service worker push/notificationclick handler, and server-side sending from the daily task digest. Also broadens that digest's eligibility query so push-only users (email notifications off) aren't silently skipped, and adds `generate_vapid_keys` since the pinned py-vapid's own key generator is broken against current cryptography. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
cf37389655
commit
7e905a0566
+1
-1
@@ -147,7 +147,7 @@
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
<script src="{% static 'js/app.js' %}?v=4"></script>
|
||||
<script src="{% static 'js/app.js' %}?v=6"></script>
|
||||
{% block extra_js %}{% endblock %}
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -47,3 +47,20 @@ self.addEventListener('fetch', (event) => {
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
self.addEventListener('push', (event) => {
|
||||
const data = event.data ? event.data.json() : {};
|
||||
event.waitUntil(
|
||||
self.registration.showNotification(data.title || 'KeepItGoing', {
|
||||
body: data.body || '',
|
||||
icon: '{% static "favicons/icon-192.png" %}',
|
||||
badge: '{% static "favicons/icon-192.png" %}',
|
||||
data: { url: data.url || '/' },
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
self.addEventListener('notificationclick', (event) => {
|
||||
event.notification.close();
|
||||
event.waitUntil(clients.openWindow(event.notification.data.url || '/'));
|
||||
});
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
<div class="card" style="background: var(--surface); padding: 1.5rem; border-radius: 0.75rem; margin-bottom: 1.5rem; border: 1px solid var(--border);">
|
||||
<h2 style="font-size: 1.25rem; font-weight: 600; margin-bottom: 1.5rem;">Personal Information</h2>
|
||||
|
||||
<form method="post">
|
||||
<form method="post" onsubmit="handleProfileFormSubmit(event, this)">
|
||||
{% csrf_token %}
|
||||
|
||||
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; margin-bottom: 1.5rem;">
|
||||
@@ -96,6 +96,7 @@
|
||||
<label style="display: flex; align-items: center; cursor: pointer; padding: 0.75rem; background: var(--surface); border: 1px solid var(--border); border-radius: 0.375rem;">
|
||||
<input type="checkbox"
|
||||
name="push_notifications"
|
||||
data-vapid-public-key="{{ vapid_public_key }}"
|
||||
{% if user.push_notifications %}checked{% endif %}
|
||||
style="margin-right: 0.75rem; width: 1rem; height: 1rem;">
|
||||
<div>
|
||||
|
||||
Reference in New Issue
Block a user