]> littlesong.place Git - littlesongplace.git/commitdiff
Initial work on love - needs button
authorChris Fulljames <christianfulljames@gmail.com>
Sat, 7 Feb 2026 22:40:00 +0000 (17:40 -0500)
committerChris Fulljames <christianfulljames@gmail.com>
Sat, 7 Feb 2026 22:40:00 +0000 (17:40 -0500)
src/littlesongplace/comments.py
src/littlesongplace/push_notifications.py
src/littlesongplace/templates/activity.html
src/littlesongplace/templates/comment-thread.html
src/littlesongplace/templates/settings.html

index dfe7b197e3d59b3f3af39f4da98d2435f31b1617..7de0a98a600d882394ce7266ad7fc0e1f06eb4b4 100644 (file)
@@ -184,12 +184,20 @@ def comment():
                         [commentid, ObjectType.COMMENT, target, timestamp])
 
             # Send push notifications
-            push_notifications.notify(
-                    notification_targets,
-                    title=f"Comment from {g.username}",
-                    body=content,
-                    url="/activity",
-                    setting=push_notifications.SubscriptionSetting.COMMENTS)
+            if content == "[l0vv3]":
+                push_notifications.notify(
+                        notification_targets,
+                        title=f"{g.username} sent love!",
+                        body=None,
+                        url="/activity",
+                        setting=push_notifications.SubscriptionSetting.LOVE)
+            else:
+                push_notifications.notify(
+                        notification_targets,
+                        title=f"Comment from {g.username}",
+                        body=content,
+                        url="/activity",
+                        setting=push_notifications.SubscriptionSetting.COMMENTS)
 
         db.commit()
 
index 55b8cb66b78e9a1e706d45c4f75cf7859a3d175e..32a7f6525e2231054863f5aa7bd873b0784ab51c 100644 (file)
@@ -16,6 +16,7 @@ push_threads = []
 class SubscriptionSetting(enum.IntEnum):
     COMMENTS = 0x0001
     SONGS = 0x0002
+    LOVE = 0x0004
 
 @bp.post("/subscribe")
 @auth.requires_login
@@ -76,8 +77,9 @@ def get_settings():
 
     comments = (row["settings"] & SubscriptionSetting.COMMENTS) > 0
     songs = (row["settings"] & SubscriptionSetting.SONGS) > 0
+    love = (row["settings"] & SubscriptionSetting.LOVE) > 0
 
-    return {"comments": comments, "songs": songs}
+    return {"comments": comments, "songs": songs, "love": love}
 
 @bp.post("/settings")
 @auth.requires_login
@@ -89,7 +91,7 @@ def update_settings():
     bitfield = 0
     settings = request.json
 
-    if ("subid" not in settings) or ("comments" not in settings) or ("songs" not in settings):
+    if ("subid" not in settings) or ("comments" not in settings) or ("songs" not in settings) or ("love" not in settings):
         abort(400)
 
     subid = settings["subid"]
@@ -98,6 +100,8 @@ def update_settings():
         bitfield |= SubscriptionSetting.COMMENTS
     if settings["songs"]:
         bitfield |= SubscriptionSetting.SONGS
+    if settings["love"]:
+        bitfield |= SubscriptionSetting.LOVE
 
     current_app.logger.info(f"{g.username} attempting to update push subscription settings: ({subid}) {bitfield:04x}")
 
index ab79726f7ad4aaa054a0e488e6018154a9f76fcf..6c53f98ba123705c653d6355adf6672e81624156 100644 (file)
@@ -8,25 +8,27 @@
     {% for comment in comments -%}
     <div class="boxy">
         <a href="/users/{{ comment['comment_username'] }}" class="profile-link">{{ comment['comment_username'] }}</a>
-        {% if comment['replyto_content'] %}
+        {%- if comment['replyto_content'] %}
         replied to &quot;{{ comment['replyto_content'] }}&quot;
-        {% else %}
+        {%- elif comment['content'] == '[l0vv3]' %}
+        sent love
+        {%- else %}
         commented
-        {% endif %}
+        {%- endif %}
         on
-        {% if 'songid' in comment %}
+        {%- if 'songid' in comment %}
         <a href="/song/{{ comment['content_userid'] }}/{{ comment['songid'] }}?action=view">{{ comment['title'] }}</a> -
         {# Nothing to do for user profile #}
-        {% elif 'playlistid' in comment %}
+        {%- elif 'playlistid' in comment %}
         <a href="/playlists/{{ comment['playlistid'] }}">{{ comment['name'] }}</a> -
-        {% elif 'eventid' in comment %}
+        {%- elif 'eventid' in comment %}
         <a href="/jams/{{ comment['jamid']}}/events/{{ comment['eventid'] }}">{{ comment['title'] }}</a> -
-        {% endif %}
+        {%- endif %}
         <a href="/users/{{ comment['content_username'] }}" class="profile-link">{{ comment['content_username'] }}</a>
+        {%- if comment['content'] != '[l0vv3]' %}
         <div class="boxy-lite">
             <a href="/users/{{ comment['comment_username'] }}" class="profile-link">{{ comment['comment_username'] }}</a>:
             {{ comment['content'] }}
-
             <div class="comment-button-container">
                 {% if comment['replytoid'] %}
                     <!-- Comment is already part of a thread; reply to the same thread -->
@@ -37,6 +39,7 @@
                 {% endif %}
             </div>
         </div>
+        {%- endif %}
     </div>
     {% endfor %}
 
index 1231e09b70108b3735a26427cf1e9b916265c2a6..9ee878786e840b238e67ab9baf4a522b77540d8e 100644 (file)
@@ -1,10 +1,11 @@
 {% macro comment_thread(threadid, current_userid, thread_userid, comments) %}
     <div class="comment-thread">
-        {% if current_userid %}
+        {%- if current_userid %}
         <a href="/comment?threadid={{ threadid }}" class="song-list-button" title="Add a Comment"><img class="lsp_btn_add02" /></a>
-        {% endif %}
+        {%- endif %}
 
-        {% for comment in comments %}
+        {%- for comment in comments %}
+        {%- if comment['content'] != '[l0vv3]' %}
         <div class="boxy-lite">
 
             <a href="/users/{{ comment['username'] }}" class="profile-link">{{ comment['username'] }}</a>:
@@ -54,6 +55,7 @@
                 <a href="/comment?threadid={{ threadid }}&replytoid={{ comment['commentid'] }}">Reply</a>
             </div>
         </div>
-        {% endfor %}
+        {%- endif %}
+        {%- endfor %}
     </div>
 {% endmacro %}
index 2911b61736f32b1ea94bbb178d89a9a08c60c41a..c4b74626241423a5b80996192577f39a84fd697a 100644 (file)
@@ -18,6 +18,8 @@ run in "progressive web app" mode, which enables background notifications.
     <br/>
     <label><input type="checkbox" onclick="updateSettings()" id="comment-push">I get a new comment</label>
     <br/>
+    <label><input type="checkbox" onclick="updateSettings()" id="love-push">Someone sends me love</label>
+    <br/>
     <label><input type="checkbox" onclick="updateSettings()" id="song-push">Anyone uploads a new song (at most once per day)</label>
 </div>
 <br/>
@@ -37,12 +39,14 @@ function updateSelections() {
             r.json().then((j) => {
                 console.log(j);
                 document.getElementById("comment-push").checked = j.comments;
+                document.getElementById("love-push").checked = j.love;
                 document.getElementById("song-push").checked = j.songs;
             });
         })
     }
     else {
         document.getElementById("comment-push").checked = false;
+        document.getElementById("love-push").checked = false;
         document.getElementById("song-push").checked = false;
     }
 }
@@ -50,10 +54,11 @@ document.addEventListener("DOMContentLoaded", updateSelections());
 
 async function updateSettings() {
     const comment_push_enabled = document.getElementById("comment-push").checked;
+    const love_push_enabled = document.getElementById("love-push").checked;
     const song_push_enabled = document.getElementById("song-push").checked;
 
     // Enable/subscribe to notifications
-    if (comment_push_enabled || song_push_enabled)
+    if (comment_push_enabled || love_push_enabled || song_push_enabled)
     {
         await enablePushNotifications();
     }
@@ -65,6 +70,7 @@ async function updateSettings() {
             headers: {"Content-Type": "application/json"},
             body: JSON.stringify({
                 comments: comment_push_enabled,
+                love: love_push_enabled,
                 songs: song_push_enabled,
                 subid: window.localStorage.getItem("subid"),
             })