From ad121dd9c7561aa9518e33a290e7795303329fce Mon Sep 17 00:00:00 2001 From: Aevann Date: Tue, 16 May 2023 01:51:37 +0300 Subject: [PATCH] fix this https://rdrama.net/post/18459/marseycapywalking-megathread-for-bugs-and-suggestions/4158116#context --- files/routes/awards.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/files/routes/awards.py b/files/routes/awards.py index a88215bd3..e535f5a6a 100644 --- a/files/routes/awards.py +++ b/files/routes/awards.py @@ -350,16 +350,16 @@ def award_thing(v, thing_type, id): badge_grant(user=author, badge_id=96) elif kind == "namelock": new_name = note.strip() - if not valid_username_regex.fullmatch(new_name): - abort(400, "Invalid username") - - existing = get_user(new_name, graceful=True) - if existing: - abort(400, f"@{new_name} is already taken!") - - if not new_name and author.prelock_username: + if not new_name and author.namechanged: author.namechanged += 86400 else: + if not valid_username_regex.fullmatch(new_name): + abort(400, "Invalid username") + + existing = get_user(new_name, graceful=True) + if existing: + abort(400, f"@{new_name} is already taken!") + author.prelock_username = author.username author.username = new_name author.namechanged = int(time.time()) + 86400