remotes/1693045480750635534/spooky-22
Aevann1 2021-07-29 02:11:37 +02:00
parent 7f70f89ec2
commit 097a4404be
2 changed files with 9 additions and 15 deletions

View File

@ -422,8 +422,7 @@ class User(Base, Stndrd, Age_times):
def has_follower(self, user):
return g.db.query(Follow).filter_by(
target_id=self.id, user_id=user.id).first()
return g.db.query(Follow).filter_by(target_id=self.id, user_id=user.id).first()
@property

View File

@ -431,18 +431,15 @@ def follow_user(username, v):
target = get_user(username)
if target.id==v.id:
return jsonify({"error": "You can't follow yourself!"}), 400
if target.id==v.id: return jsonify({"error": "You can't follow yourself!"}), 400
# check for existing follow
if g.db.query(Follow).filter_by(user_id=v.id, target_id=target.id).first():
abort(409)
new_follow = Follow(user_id=v.id,
target_id=target.id)
if g.db.query(Follow).filter_by(user_id=v.id, target_id=target.id).first(): abort(409)
new_follow = Follow(user_id=v.id, target_id=target.id)
g.db.add(new_follow)
target.stored_subscriber_count = g.db.query(Follow).filter_by(target_id=target.id)
target.stored_subscriber_count = g.db.query(Follow).filter_by(target_id=target.id).count()
g.db.add(target)
existing = g.db.query(Notification).filter_by(followsender=v.id, user_id=target.id).first()
@ -457,14 +454,12 @@ def unfollow_user(username, v):
target = get_user(username)
# check for existing follow
follow = g.db.query(Follow).filter_by(
user_id=v.id, target_id=target.id).first()
follow = g.db.query(Follow).filter_by(user_id=v.id, target_id=target.id).first()
if not follow:
abort(409)
if not follow: abort(409)
g.db.delete(follow)
target.stored_subscriber_count = g.db.query(Follow).filter_by(target_id=target.id)
target.stored_subscriber_count = g.db.query(Follow).filter_by(target_id=target.id).count()
g.db.add(target)
existing = g.db.query(Notification).filter_by(followsender=v.id, user_id=target.id).first()