fix 500 error

master
Aevann 2024-04-17 22:18:36 +02:00
parent bd2ba5e372
commit dbfd9adda7
1 changed files with 12 additions and 14 deletions

View File

@ -233,7 +233,19 @@ def award_thing(v, thing_type, id):
if kind == 'spider' and author.spider == 1:
abort(409, f"{safe_username} already best friends with a spider!")
awards = g.db.query(AwardRelationship).filter(
AwardRelationship.kind == kind,
AwardRelationship.user_id == v.id,
AwardRelationship.post_id == None,
AwardRelationship.comment_id == None
).order_by(AwardRelationship.id).limit(quantity).all()
num_owned = len(awards)
if quantity > num_owned:
bought = buy_awards(v, kind, AWARDS, quantity-num_owned)
if isinstance(bought, dict):
return bought
awards.extend(bought)
if v.id != author.id:
if author.deflector and v.deflector and AWARDS[kind]['deflectable']:
@ -271,20 +283,6 @@ def award_thing(v, thing_type, id):
can_alter_body = not obj.author.deflector or v == obj.author
awards = g.db.query(AwardRelationship).filter(
AwardRelationship.kind == kind,
AwardRelationship.user_id == v.id,
AwardRelationship.post_id == None,
AwardRelationship.comment_id == None
).order_by(AwardRelationship.id).limit(quantity).all()
num_owned = len(awards)
if quantity > num_owned:
bought = buy_awards(v, kind, AWARDS, quantity-num_owned)
if isinstance(bought, dict):
return bought
awards.extend(bought)
for award in awards:
if isinstance(obj, Post): award.post_id = obj.id
else: award.comment_id = obj.id