评论自动关注
This commit is contained in:
18
hole.py
18
hole.py
@@ -310,6 +310,20 @@ def do_comment():
|
|||||||
)
|
)
|
||||||
post.comments.append(c)
|
post.comments.append(c)
|
||||||
post.comment_timestamp = c.timestamp
|
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()
|
db.session.commit()
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -336,8 +350,8 @@ def attention():
|
|||||||
abort(404)
|
abort(404)
|
||||||
|
|
||||||
at = Attention.query.filter_by(
|
at = Attention.query.filter_by(
|
||||||
name_hash=hash_name(
|
name_hash=hash_name(u.name), pid=pid
|
||||||
u.name), pid=pid).first()
|
).first()
|
||||||
|
|
||||||
if not at:
|
if not at:
|
||||||
at = Attention(name_hash=hash_name(u.name), pid=pid, disabled=True)
|
at = Attention(name_hash=hash_name(u.name), pid=pid, disabled=True)
|
||||||
|
|||||||
Reference in New Issue
Block a user