From b990d9ccd8f2bff4990b79f7dc7cd494190d0536 Mon Sep 17 00:00:00 2001 From: Hugh Rundle Date: Wed, 17 Jan 2024 21:06:04 +1100 Subject: [PATCH] Pass correct user id in Move notification We were passing the *requesting* user's moved_to value to the Move notification template, instead of the id of the user that they are being notified about. Additionally, the id_to_username template tag had no fallback for if the user_id is None. This resolves both problems and removes an unnecessary space in a template for when the logged in user made the move. Fixes #3196 --- bookwyrm/templates/moved.html | 2 +- bookwyrm/templates/notifications/items/move_user.html | 2 +- bookwyrm/templatetags/utilities.py | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/bookwyrm/templates/moved.html b/bookwyrm/templates/moved.html index 545fc3d87..382b752be 100644 --- a/bookwyrm/templates/moved.html +++ b/bookwyrm/templates/moved.html @@ -23,7 +23,7 @@

- {% id_to_username request.user.moved_to as username %} + {% id_to_username request.user.moved_to as username %} {% blocktrans trimmed with moved_to=user.moved_to %} You have moved your account to {{ username }} {% endblocktrans %} diff --git a/bookwyrm/templates/notifications/items/move_user.html b/bookwyrm/templates/notifications/items/move_user.html index b94d96dc4..3121d3f45 100644 --- a/bookwyrm/templates/notifications/items/move_user.html +++ b/bookwyrm/templates/notifications/items/move_user.html @@ -14,7 +14,7 @@ {% block description %} {% if related_user_moved_to %} - {% id_to_username request.user.moved_to as username %} + {% id_to_username related_user_moved_to as username %} {% blocktrans trimmed %} {{ related_user }} has moved to {{ username }} {% endblocktrans %} diff --git a/bookwyrm/templatetags/utilities.py b/bookwyrm/templatetags/utilities.py index fca66688a..230db366e 100644 --- a/bookwyrm/templatetags/utilities.py +++ b/bookwyrm/templatetags/utilities.py @@ -125,7 +125,8 @@ def id_to_username(user_id): name = parts[-1] value = f"{name}@{domain}" - return value + return value + return "a new user account" @register.filter(name="get_file_size")