minor logic change in /@username

master
Aevann1 2022-07-03 14:12:33 +02:00
parent 8917427323
commit a6b7fed2fc
2 changed files with 19 additions and 18 deletions

View File

@ -57,21 +57,26 @@ def get_user(username, v=None, graceful=False, rendered=False):
if not graceful: abort(404) if not graceful: abort(404)
else: return None else: return None
if rendered and v and v.id != user.id: if rendered and v:
block = g.db.query(UserBlock).filter( if v.id == user.id:
or_( user.is_blocked = False
and_( user.is_blocking = False
UserBlock.user_id == v.id, else:
UserBlock.target_id == user.id block = g.db.query(UserBlock).filter(
), or_(
and_(UserBlock.user_id == user.id, and_(
UserBlock.target_id == v.id UserBlock.user_id == v.id,
) UserBlock.target_id == user.id
) ),
).first() 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 return user

View File

@ -876,8 +876,6 @@ def u_username(username, v=None):
if v and username == v.username: if v and username == v.username:
is_following = False is_following = False
u.is_blocked = False
u.is_blocking = False
else: else:
is_following = (v and u.has_follower(v)) 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: if v and username == v.username:
is_following = False is_following = False
user.is_blocked = False
user.is_blocking = False
else: else:
is_following = (v and user.has_follower(v)) is_following = (v and user.has_follower(v))