This commit is contained in:
Aevann1 2021-11-16 01:13:29 +02:00
parent 9dd3eb89ea
commit e1a1b5243d
7 changed files with 77 additions and 29 deletions

View file

@ -993,9 +993,18 @@ def api_sticky_post(post_id, v):
cache.delete_memoized(frontlist)
g.db.commit()
if post.stickied: return {"message": "Post pinned!"}
else: return {"message": "Post unpinned!"}
if post.stickied:
message = f"@{v.username} has pinned your [post](/post/{post_id})!"
existing = g.db.query(Comment.id).filter(Comment.author_id == NOTIFICATIONS_ACCOUNT, Comment.body == message).first()
if not existing: send_notification(post.author_id, message)
g.db.commit()
return {"message": "Post pinned!"}
else:
message = f"@{v.username} has unpinned your [post](/post/{post_id})!"
existing = g.db.query(Comment.id).filter(Comment.author_id == NOTIFICATIONS_ACCOUNT, Comment.body == message).first()
if not existing: send_notification(post.author_id, message)
g.db.commit()
return {"message": "Post unpinned!"}
@app.post("/ban_comment/<c_id>")
@limiter.limit("1/second")