dedup
parent
ea7bef1b71
commit
a7ed2707d0
|
@ -1553,11 +1553,7 @@ def sticky_comment(cid, v):
|
||||||
message = f"@{v.username} (a site admin) has pinned your [comment]({comment.shortlink})"
|
message = f"@{v.username} (a site admin) has pinned your [comment]({comment.shortlink})"
|
||||||
send_repeatable_notification(comment.author_id, message)
|
send_repeatable_notification(comment.author_id, message)
|
||||||
|
|
||||||
c = comment
|
comment.pin_parents()
|
||||||
while c.level > 2:
|
|
||||||
c = c.parent_comment
|
|
||||||
c.stickied_child_id = comment.id
|
|
||||||
g.db.add(c)
|
|
||||||
|
|
||||||
return {"message": "Comment pinned!"}
|
return {"message": "Comment pinned!"}
|
||||||
|
|
||||||
|
@ -1590,10 +1586,7 @@ def unsticky_comment(cid, v):
|
||||||
message = f"@{v.username} (a site admin) has unpinned your [comment]({comment.shortlink})"
|
message = f"@{v.username} (a site admin) has unpinned your [comment]({comment.shortlink})"
|
||||||
send_repeatable_notification(comment.author_id, message)
|
send_repeatable_notification(comment.author_id, message)
|
||||||
|
|
||||||
cleanup = g.db.query(Comment).filter_by(stickied_child_id=comment.id).all()
|
comment.unpin_parents()
|
||||||
for c in cleanup:
|
|
||||||
c.stickied_child_id = None
|
|
||||||
g.db.add(c)
|
|
||||||
|
|
||||||
return {"message": "Comment unpinned!"}
|
return {"message": "Comment unpinned!"}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue