flairlock

This commit is contained in:
Aevann1 2021-10-21 22:50:00 +02:00
parent 26b9af2473
commit 395d47e0aa
15 changed files with 108 additions and 46 deletions

View file

@ -101,6 +101,16 @@ def api_vote_post(post_id, new, v):
post.stickied = None
g.db.add(post)
cache.delete_memoized(frontlist)
if v.agendaposter_expires_utc and v.agendaposter_expires_utc < time.time():
v.agendaposter_expires_utc = 0
v.agendaposter = False
g.db.add(v)
if v.flairchanged and v.flairchanged < time.time():
v.flairchanged = None
g.db.add(v)
try:
g.db.flush()
post.upvotes = g.db.query(Vote.id).options(lazyload('*')).filter_by(submission_id=post.id, vote_type=1).count()
@ -159,6 +169,10 @@ def api_vote_comment(comment_id, new, v):
g.db.add(vote)
if comment.is_pinned and comment.is_pinned.startswith("t:") and int(time.time()) > int(comment.is_pinned[2:]):
comment.is_pinned = None
g.db.add(comment)
try:
g.db.flush()
comment.upvotes = g.db.query(CommentVote.id).options(lazyload('*')).filter_by(comment_id=comment.id, vote_type=1).count()