diff --git a/feeds.py b/feeds.py index 7db831c..6950efe 100644 --- a/feeds.py +++ b/feeds.py @@ -329,10 +329,10 @@ def make_post_page(session, post): if session.is_likes_enabled(): liked = [] if post.num_likes: - liked = db.get_likes(post) + liked = db.get_likes(post, session.user_mutes) page += ' ยท ๐Ÿ‘ ' + ', '.join(liked) if session.is_reactions_enabled(): - reactions = db.get_reactions(post) + reactions = db.get_reactions(post, session.user_mutes) listed = [] for r in reactions: listed.append(f'{reactions[r]} {r}') diff --git a/model.py b/model.py index e4aeada..09e9816 100644 --- a/model.py +++ b/model.py @@ -1912,13 +1912,15 @@ class Database: (Notification.REACTION, user.id, post.user, post.id)) self.commit()  - def get_reactions(self, post) -> dict: + def get_reactions(self, post, user_mutes=set()) -> dict: """Returns a dictionary of {reactions: count}."""  cur = self.conn.cursor() - cur.execute("SELECT reaction FROM reactions WHERE post=?", (post.id,)) + cur.execute("SELECT reaction, user FROM reactions WHERE post=?", (post.id,)) counts = {} - for (r,) in cur: + for (r, user_id) in cur: + if (MUTE_USER, user_id) in user_mutes: + continue if r not in counts: counts[r] = 1 else: @@ -1931,17 +1933,18 @@ class Database: for (r,) in cur: return r return None  - def get_likes(self, post): + def get_likes(self, post, user_mutes=set()): cur = self.conn.cursor() cur.execute(""" - SELECT u.name + SELECT u.name, u.id FROM likes JOIN users u ON likes.user=u.id WHERE likes.post=? """, (post.id,)) users = [] - for (name,) in cur: - users.append(name) + for (name, liker_id) in cur: + if not (MUTE_USER, liker_id) in user_mutes: + users.append(name) return users  def get_tags(self, post):