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"""