From 28edfd85e50543b319b826378a8ac769eaad178c Mon Sep 17 00:00:00 2001 From: hole-thu Date: Wed, 15 Dec 2021 22:00:49 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=84=E8=AE=BA=E8=87=AA=E5=8A=A8=E5=85=B3?= =?UTF-8?q?=E6=B3=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hole.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/hole.py b/hole.py index 054cdcf..bebfd16 100644 --- a/hole.py +++ b/hole.py @@ -310,6 +310,20 @@ def do_comment(): ) post.comments.append(c) post.comment_timestamp = c.timestamp + + at = Attention.query.filter_by( + name_hash=hash_name(u.name), pid=pid + ).first() + + if not at: + at = Attention(name_hash=hash_name(u.name), pid=pid, disabled=False) + db.session.add(at) + post.likenum += 1 + else: + if at.disabled: + post.likenum += 1 + at.disabled = False + db.session.commit() return { @@ -336,8 +350,8 @@ def attention(): abort(404) at = Attention.query.filter_by( - name_hash=hash_name( - u.name), pid=pid).first() + name_hash=hash_name(u.name), pid=pid + ).first() if not at: at = Attention(name_hash=hash_name(u.name), pid=pid, disabled=True)