Don't show users post content from users they've blocked (#639)
This commit is contained in:
parent
4ff52b5ac0
commit
7e68277eb6
3 changed files with 10 additions and 4 deletions
|
@ -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]:
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue