forked from rDrama/rDrama
1
0
Fork 0

try to fix 500 error caused by vote constraints

master
Aevann1 2022-08-11 06:03:09 +02:00
parent b79638b2dd
commit 57cc579b30
1 changed files with 8 additions and 4 deletions

View File

@ -73,13 +73,15 @@ def api_vote_post(post_id, new, v):
post = get_post(post_id)
existing = g.db.query(Vote).filter_by(user_id=v.id, submission_id=post.id).one_or_none()
coin_delta = 1
if v.id == post.author.id:
coin_delta = 0
coin_mult = 1
g.db.flush()
existing = g.db.query(Vote).filter_by(user_id=v.id, submission_id=post.id).one_or_none()
if DOUBLE_XP_ENABLED > 0:
if not existing and int(time.time()) > DOUBLE_XP_ENABLED:
coin_mult = 2
@ -146,13 +148,15 @@ def api_vote_comment(comment_id, new, v):
comment = get_comment(comment_id)
existing = g.db.query(CommentVote).filter_by(user_id=v.id, comment_id=comment.id).one_or_none()
coin_delta = 1
if v.id == comment.author_id:
coin_delta = 0
coin_mult = 1
g.db.flush()
existing = g.db.query(CommentVote).filter_by(user_id=v.id, comment_id=comment.id).one_or_none()
if DOUBLE_XP_ENABLED > 0:
if not existing and int(time.time()) > DOUBLE_XP_ENABLED:
coin_mult = 2