dont allow subscribing to own post (not hidden in HTML in order to show num of subscribers)

master
Aevann 2023-10-29 17:30:54 +03:00
parent 9f3347dd61
commit 7ff30337f5
1 changed files with 4 additions and 0 deletions

View File

@ -580,6 +580,10 @@ def get_profilecss(username):
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400, key_func=get_ID)
@auth_required
def subscribe(v, post_id):
p = get_post(post_id)
if v.id == p.author_id:
abort(403, "You can't subscribe to your own posts!")
existing = g.db.query(Subscription).filter_by(user_id=v.id, post_id=post_id).one_or_none()
if not existing:
new_sub = Subscription(user_id=v.id, post_id=post_id)