]> littlesong.place Git - littlesongplace.git/commitdiff
Launch push notifications feature master
authorChris Fulljames <christianfulljames@gmail.com>
Fri, 29 Aug 2025 23:32:38 +0000 (19:32 -0400)
committerChris Fulljames <christianfulljames@gmail.com>
Fri, 29 Aug 2025 23:32:38 +0000 (19:32 -0400)
src/littlesongplace/push_notifications.py
src/littlesongplace/templates/base.html
src/littlesongplace/templates/news.html
src/littlesongplace/templates/settings.html
test/test_push_notifications.py

index 602758cc16bdfd229001f6f7571e2c0e5e8ea46b..55b8cb66b78e9a1e706d45c4f75cf7859a3d175e 100644 (file)
@@ -209,18 +209,19 @@ def notify_new_songs_cmd():
         new_songs = [s for s in new_songs if not s.hidden]  # Filter out hidden songs
         unique_users = sorted(set(s.username for s in new_songs))
 
         new_songs = [s for s in new_songs if not s.hidden]  # Filter out hidden songs
         unique_users = sorted(set(s.username for s in new_songs))
 
-        title = None
+        title = f"New music!"
+        body = None
         _except = None
         if len(new_songs) == 1:
         _except = None
         if len(new_songs) == 1:
-            title = f"New song from {unique_users[0]}"
+            body = f"New song from {unique_users[0]}"
             _except = new_songs[0].userid
         elif len(new_songs) > 1:
             _except = new_songs[0].userid
         elif len(new_songs) > 1:
-            title = f"New songs from {', '.join(unique_users)}"
+            body = f"New songs from {', '.join(unique_users)}"
 
 
-        if title:
+        if body:
             notify_all(
                     title,
             notify_all(
                     title,
-                    body=None,
+                    body,
                     url="/",
                     setting=SubscriptionSetting.SONGS,
                     _except=_except)
                     url="/",
                     setting=SubscriptionSetting.SONGS,
                     _except=_except)
index ef162698460d4d75028452b23696265e9e1ad822..4ab6b565d85fa00822bc63b547799504a1f1a62b 100644 (file)
@@ -57,6 +57,7 @@
                     <div class="navbar">
                         <a href="/users/{{ session["username"] }}" class="nav-logged-in" id="my-profile" hidden>My Profile</a>
                         <a href="/activity" class="nav-logged-in" hidden><span id="activity-indicator" hidden></span>Activity</a>
                     <div class="navbar">
                         <a href="/users/{{ session["username"] }}" class="nav-logged-in" id="my-profile" hidden>My Profile</a>
                         <a href="/activity" class="nav-logged-in" hidden><span id="activity-indicator" hidden></span>Activity</a>
+                        <a href="/settings" class="nav-logged-in" hidden>Settings</a>
                         <a href="/logout" class="nav-logged-in" hidden>Sign Out</a>
 
                         <a href="/signup" class="nav-logged-out">Create Account</a>
                         <a href="/logout" class="nav-logged-in" hidden>Sign Out</a>
 
                         <a href="/signup" class="nav-logged-out">Create Account</a>
index 7f4c8ea62275d729cbf4e515c52d86e49438d1ff..73039ceceb32109b7bc3eec5206fd710eec69efa 100644 (file)
@@ -5,6 +5,13 @@
 {% block body %}
 
 <h1>site news</h1>
 {% block body %}
 
 <h1>site news</h1>
+<h2>2025-08-29 - Finally, Push Notifications!</h2>
+<p>
+Mobile push notifications have landed.  Add a bookmark to your phone's home
+screen, and then open the new <a href="/settings">Settings</a> page and select
+which things you'd like to be notified about.
+</p>
+
 <h2>2025-08-17 - Leaving GitHub</h2>
 <p>
 I have felt for a while like GitHub was not really the right home for the
 <h2>2025-08-17 - Leaving GitHub</h2>
 <p>
 I have felt for a while like GitHub was not really the right home for the
index 5c957b49e223fc8b985d3da1955995f8fdd70726..2911b61736f32b1ea94bbb178d89a9a08c60c41a 100644 (file)
@@ -6,15 +6,21 @@
 <h1>settings</h1>
 
 <h2>push notifications</h2>
 <h1>settings</h1>
 
 <h2>push notifications</h2>
+<p>
+<b>Note:</b> For the best notification experience, you can add a bookmark to
+the site to your mobile device's home screen.  This will allow the the site to
+run in "progressive web app" mode, which enables background notifications.
+</p>
 <div id="activity-settings" style="line-height: 1.5;">
     <!--<span>Push notifications are currently disabled on this device.</span>-->
     <!--<button onclick="enablePushNotifications()" class="button" style="float: right;">Enable</button>-->
 <div id="activity-settings" style="line-height: 1.5;">
     <!--<span>Push notifications are currently disabled on this device.</span>-->
     <!--<button onclick="enablePushNotifications()" class="button" style="float: right;">Enable</button>-->
-    Send me a push notification on this device when:
+    <b>Send me a push notification on this device when:</b>
     <br/>
     <label><input type="checkbox" onclick="updateSettings()" id="comment-push">I get a new comment</label>
     <br/>
     <label><input type="checkbox" onclick="updateSettings()" id="song-push">Anyone uploads a new song (at most once per day)</label>
 </div>
     <br/>
     <label><input type="checkbox" onclick="updateSettings()" id="comment-push">I get a new comment</label>
     <br/>
     <label><input type="checkbox" onclick="updateSettings()" id="song-push">Anyone uploads a new song (at most once per day)</label>
 </div>
+<br/>
 
 <button class="button" onclick="fetch('/push-notifications/test')">Test Notifications</button>
 
 
 <button class="button" onclick="fetch('/push-notifications/test')">Test Notifications</button>
 
index 75c0dadb423c5cf725eb8d6e7c1c0eddca12fedf..b62b7a3f9604662c3a791ea75ad3aa6a3bf5f0f1 100644 (file)
@@ -202,7 +202,7 @@ def test_notification_for_new_songs_enabled(pushmock, app, client, user, subid,
 
     pushmock.assert_called_once_with(
         json.loads(SUBDATA),
 
     pushmock.assert_called_once_with(
         json.loads(SUBDATA),
-        '{"title": "New song from user2", "body": null, "url": "/"}',
+        '{"title": "New music!", "body": "New song from user2", "url": "/"}',
         vapid_private_key="vapid-private-key",
         vapid_claims={"sub": "mailto:littlesongplace@gmail.com"})
 
         vapid_private_key="vapid-private-key",
         vapid_claims={"sub": "mailto:littlesongplace@gmail.com"})