forked from newthuhole/hole_thu_backend
评论自动关注
This commit is contained in:
18
hole.py
18
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)
|
||||
|
||||
Reference in New Issue
Block a user