make it so unblockable users cant block others

master
Aevann 2024-02-15 23:38:00 +02:00
parent b5f046b1c9
commit 17375c753a
2 changed files with 11 additions and 1 deletions

View File

@ -470,7 +470,14 @@ def award_thing(v, thing_type, id):
badge_grant(badge_id=84, user=author)
elif kind == "unblockable":
badge_grant(badge_id=87, user=author)
for block in g.db.query(UserBlock).filter_by(target_id=author.id): g.db.delete(block)
blocks = g.db.query(UserBlock).filter(
or_(
UserBlock.user_id == author.id,
UserBlock.target_id == author.id,
)
)
for block in blocks:
g.db.delete(block)
elif kind == "progressivestack":
if not FEATURES['PINS']:
abort(403)

View File

@ -715,6 +715,9 @@ def settings_blocks(v):
@limiter.limit("20/day", deduct_when=lambda response: response.status_code < 400, key_func=get_ID)
@auth_required
def settings_block_user(v):
if v.unblockable:
abort(403, "You're unblockable so you can't block others!")
user = get_user(request.values.get("username"))
if user.unblockable: