forked from rDrama/rDrama
1
0
Fork 0

extremely lazy fix to shorten lock time on users

master
Aevann 2023-08-02 11:49:47 +03:00
parent 9ceeaf8696
commit 331b60519f
1 changed files with 17 additions and 9 deletions

View File

@ -56,27 +56,24 @@ def vote_post_comment(target_id, new, v, cls, vote_cls):
coin_value = coin_delta * coin_mult coin_value = coin_delta * coin_mult
imlazy = 0
if existing and existing.vote_type == new: return "", 204 if existing and existing.vote_type == new: return "", 204
if existing: if existing:
if existing.vote_type == 0 and new != 0: if existing.vote_type == 0 and new != 0:
target.author.pay_account('coins', coin_value) imlazy = 1
target.author.truescore += coin_delta
g.db.add(target.author)
existing.vote_type = new existing.vote_type = new
existing.coins = coin_value existing.coins = coin_value
g.db.add(existing) g.db.add(existing)
elif existing.vote_type != 0 and new == 0: elif existing.vote_type != 0 and new == 0:
target.author.charge_account('coins', existing.coins, should_check_balance=False) imlazy = 2
target.author.truescore -= coin_delta existing_coins = existing.coins
g.db.add(target.author)
g.db.delete(existing) g.db.delete(existing)
else: else:
existing.vote_type = new existing.vote_type = new
g.db.add(existing) g.db.add(existing)
elif new != 0: elif new != 0:
target.author.pay_account('coins', coin_value) imlazy = 3
target.author.truescore += coin_delta
g.db.add(target.author)
real = new == -1 or (not alt and v.is_votes_real) real = new == -1 or (not alt and v.is_votes_real)
vote = None vote = None
@ -149,6 +146,17 @@ def vote_post_comment(target_id, new, v, cls, vote_cls):
target.realupvotes = floor(target.realupvotes * mul) target.realupvotes = floor(target.realupvotes * mul)
g.db.add(target) g.db.add(target)
if imlazy == 1:
target.author.pay_account('coins', coin_value)
target.author.truescore += coin_delta
elif imlazy == 2:
target.author.charge_account('coins', existing.coins, should_check_balance=False)
target.author.truescore -= coin_delta
elif imlazy == 3:
target.author.pay_account('coins', coin_value)
target.author.truescore += coin_delta
return "", 204 return "", 204
@app.get("/votes/<link>") @app.get("/votes/<link>")