forked from rDrama/rDrama
users: is_following adjustments
users: move is_following check to part of the user model itself users: also don't query followers if the username is wrong and we're redirecting anywaymaster
parent
8a3be91c04
commit
68deff8f60
|
@ -741,7 +741,7 @@ class User(Base):
|
|||
|
||||
@lazy
|
||||
def has_follower(self, user):
|
||||
|
||||
if not user or self.id == user.id: return False # users can't follow themselves
|
||||
return g.db.query(Follow).filter_by(target_id=self.id, user_id=user.id).one_or_none()
|
||||
|
||||
@property
|
||||
|
|
|
@ -642,17 +642,11 @@ def visitors(v):
|
|||
@app.get("/logged_out/@<username>")
|
||||
@auth_desired_with_logingate
|
||||
def u_username(username, v=None):
|
||||
|
||||
u = get_user(username, v=v, include_blocks=True, include_shadowbanned=False, rendered=True)
|
||||
|
||||
if v and username == v.username:
|
||||
is_following = False
|
||||
else:
|
||||
is_following = (v and u.has_follower(v))
|
||||
|
||||
|
||||
if username != u.username:
|
||||
return redirect(SITE_FULL + request.full_path.replace(username, u.username))
|
||||
|
||||
is_following = (v and u.has_follower(v))
|
||||
|
||||
if v and v.id not in (u.id, DAD_ID) and u.viewers_recorded:
|
||||
g.db.flush()
|
||||
|
|
Loading…
Reference in New Issue