diff --git a/files/classes/visstate.py b/files/classes/visstate.py index 50d1b754f..a0bfd9fc0 100644 --- a/files/classes/visstate.py +++ b/files/classes/visstate.py @@ -64,13 +64,14 @@ class VisibilityState: op_name_safe=target.author_name ) - def moderated_body(self, v: User | None) -> str | None: + def moderated_body(self, v: User | None, is_blocking: bool=False) -> str | None: if v and (v.admin_level >= PERMS['POST_COMMENT_MODERATION'] \ or v.id == self.op_id): return None if self.deleted: return 'Deleted' if self.appear_removed(v): return 'Removed' if self.filtered: return 'Filtered' + if is_blocking: return f'You are blocking @{self.op_name_safe}' return None def visibility_and_message(self, v: User | None, is_blocking: bool) -> tuple[bool, str]: diff --git a/files/helpers/content.py b/files/helpers/content.py index 447acaf53..f6e913c1d 100644 --- a/files/helpers/content.py +++ b/files/helpers/content.py @@ -87,7 +87,10 @@ def canonicalize_url2(url:str, *, httpsify:bool=False) -> urllib.parse.ParseResu def body_displayed(target:Submittable, v:Optional[User], is_html:bool) -> str: - moderated:Optional[str] = target.visibility_state.moderated_body(v) + moderated:Optional[str] = target.visibility_state.moderated_body( + v=v, + is_blocking=getattr(target, 'is_blocking', False) + ) if moderated: return moderated body = target.body_html if is_html else target.body diff --git a/files/routes/votes.py b/files/routes/votes.py index 4fcc518e6..bbc949867 100644 --- a/files/routes/votes.py +++ b/files/routes/votes.py @@ -65,7 +65,8 @@ def api_vote_post(post_id, new, v): new = int(new) # get the post - post = get_post(post_id) + post = get_post(post_id, v=v) + if getattr(post, 'is_blocking', False): abort(403, "Can't vote on things from users you've blocked") # get the old vote, if we have one vote = g.db.query(Vote).filter_by(user_id=v.id, submission_id=post.id).one_or_none() @@ -132,7 +133,8 @@ def api_vote_comment(comment_id, new, v): new = int(new) # get the comment - comment = get_comment(comment_id) + comment = get_comment(comment_id, v=v) + if getattr(comment, 'is_blocking', False): abort(403, "Can't vote on things from users you've blocked") # get the old vote, if we have one vote = g.db.query(CommentVote).filter_by(user_id=v.id, comment_id=comment.id).one_or_none()