From 17375c753adfff123cde6d914e7f2b5a3aa60534 Mon Sep 17 00:00:00 2001 From: Aevann Date: Thu, 15 Feb 2024 23:38:00 +0200 Subject: [PATCH] make it so unblockable users cant block others --- files/routes/awards.py | 9 ++++++++- files/routes/settings.py | 3 +++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/files/routes/awards.py b/files/routes/awards.py index 37128eadb..6a17ad2fc 100644 --- a/files/routes/awards.py +++ b/files/routes/awards.py @@ -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) diff --git a/files/routes/settings.py b/files/routes/settings.py index 0d54ce0b4..e919a5064 100644 --- a/files/routes/settings.py +++ b/files/routes/settings.py @@ -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: