check nofollow in the backend

master
Aevann1 2022-08-20 21:50:18 +02:00
parent 8c99bebd87
commit adee122170
1 changed files with 7 additions and 2 deletions

View File

@ -1128,9 +1128,14 @@ def follow_user(username, v):
target = get_user(username) target = get_user(username)
if target.id==v.id: return {"error": "You can't follow yourself!"}, 400 if target.id==v.id:
return {"error": "You can't follow yourself!"}, 400
if g.db.query(Follow).filter_by(user_id=v.id, target_id=target.id).one_or_none(): return {"message": "User followed!"} if target.is_nofollow:
return {"error": "This user has disallowed other users from following them!"}, 403
if g.db.query(Follow).filter_by(user_id=v.id, target_id=target.id).one_or_none():
return {"message": "User followed!"}
new_follow = Follow(user_id=v.id, target_id=target.id) new_follow = Follow(user_id=v.id, target_id=target.id)
g.db.add(new_follow) g.db.add(new_follow)