diff --git a/files/helpers/get.py b/files/helpers/get.py index 8f02200c4..2a3605864 100644 --- a/files/helpers/get.py +++ b/files/helpers/get.py @@ -57,21 +57,26 @@ def get_user(username, v=None, graceful=False, rendered=False): if not graceful: abort(404) else: return None - if rendered and v and v.id != user.id: - block = g.db.query(UserBlock).filter( - or_( - and_( - UserBlock.user_id == v.id, - UserBlock.target_id == user.id - ), - and_(UserBlock.user_id == user.id, - UserBlock.target_id == v.id - ) - ) - ).first() + if rendered and v: + if v.id == user.id: + user.is_blocked = False + user.is_blocking = False + else: + block = g.db.query(UserBlock).filter( + or_( + and_( + UserBlock.user_id == v.id, + UserBlock.target_id == user.id + ), + and_(UserBlock.user_id == user.id, + UserBlock.target_id == v.id + ) + ) + ).first() + + user.is_blocking = block and block.user_id == v.id + user.is_blocked = block and block.target_id == v.id - user.is_blocking = block and block.user_id == v.id - user.is_blocked = block and block.target_id == v.id return user diff --git a/files/routes/users.py b/files/routes/users.py index 4152c4d60..9be4f46d3 100644 --- a/files/routes/users.py +++ b/files/routes/users.py @@ -876,8 +876,6 @@ def u_username(username, v=None): if v and username == v.username: is_following = False - u.is_blocked = False - u.is_blocking = False else: is_following = (v and u.has_follower(v)) @@ -974,8 +972,6 @@ def u_username_comments(username, v=None): if v and username == v.username: is_following = False - user.is_blocked = False - user.is_blocking = False else: is_following = (v and user.has_follower(v))