Bubble [main]

Follow notifications override regular commenting

=> 326e63dab1e65bcf0e2427d9a93b017999c5e11e

diff --git a/model.py b/model.py
index 022eb29..95e9b44 100644
--- a/model.py
+++ b/model.py
@@ -1074,10 +1074,11 @@ class Database:
                                       FOLLOW_POST, parent_post.id)
 
                 if parent_post.user != user.id:
+                    # Notify post author of a new comment.
                     cur.execute("INSERT IGNORE INTO notifs (type, dst, src, post) VALUES (?, ?, ?, ?)",
                         (Notification.COMMENT, parent_post.user, user.id, parent_post.id))
 
-                    # Delete redundant lower-priority notifications.
+                    # Delete redundant lower-priority notification going to post author.
                     cur.execute("DELETE FROM notifs WHERE (type & ?) AND is_hidden=FALSE AND "
                                 "dst=? AND src=? AND post=?",
                         (Notification.COMMENT_IN_FOLLOWED_SUBSPACE |
@@ -1573,6 +1574,21 @@ class Database:
         """)
         self.commit()
 
+        # Delete redundant notifications.
+        if follow_type == FOLLOW_POST:
+            cur.execute(f"""
+                DELETE FROM notifs
+                WHERE (type & ?) AND src=? AND post=? AND is_hidden=FALSE AND dst IN (
+                    SELECT user
+                    FROM follow
+                    WHERE type={FOLLOW_POST} AND target={target_id}
+                )""",
+                (Notification.COMMENT_ON_COMMENTED |
+                 Notification.COMMENT_BY_FOLLOWED_USER,
+                 actor.id,
+                 target_id))
+            self.commit()
+
     def notify_new_poll(self, post: Post):
         cur = self.conn.cursor()
         cur.execute(f"""
Proxy Information
Original URL
gemini://git.skyjake.fi/bubble/main/cdiff/326e63dab1e65bcf0e2427d9a93b017999c5e11e
Status Code
Success (20)
Meta
text/gemini; charset=utf-8
Capsule Response Time
29.134874 milliseconds
Gemini-to-HTML Time
0.191799 milliseconds

This content has been proxied by September (ba2dc).