From 35ec3e136cd5d911f67a46b567778e6645c2869a Mon Sep 17 00:00:00 2001 From: Agrendalath Date: Mon, 20 Oct 2025 23:45:04 +0200 Subject: [PATCH] fix: do not update LMS user during retirement 1. Modifying users is already handled by the LMS retirement pipeline. The `forum` library should not alter LMS users during retirement. 2. Changing the email to an empty string results in integrity errors in the MySQL backend, because the email must be unique. --- CHANGELOG.rst | 8 ++++++++ forum/__init__.py | 2 +- forum/api/users.py | 15 ++++++--------- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 8e446d37..baa8b921 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -16,6 +16,14 @@ Unreleased * +0.3.8 - 2025-10-21 +****************** + +Fixed +----- + +* Do not modify LMS users during retirement — this is handled by the LMS retirement pipeline. + 0.3.4 – 2025-08-13 ****************** diff --git a/forum/__init__.py b/forum/__init__.py index 57793e8c..3a5afaa3 100644 --- a/forum/__init__.py +++ b/forum/__init__.py @@ -2,4 +2,4 @@ Openedx forum app. """ -__version__ = "0.3.7" +__version__ = "0.3.8" diff --git a/forum/api/users.py b/forum/api/users.py index 71c3a36e..1ea6e054 100644 --- a/forum/api/users.py +++ b/forum/api/users.py @@ -6,7 +6,7 @@ import math from typing import Any, Optional -from forum.backend import get_backend +from forum.backend import get_backend, is_mysql_backend_enabled from forum.constants import FORUM_DEFAULT_PAGE, FORUM_DEFAULT_PER_PAGE from forum.serializers.thread import ThreadSerializer from forum.serializers.users import UserSerializer @@ -135,14 +135,11 @@ def retire_user( user = backend.get_user(user_id) if not user: raise ForumV2RequestError(f"user not found with id: {user_id}") - backend.update_user( - user_id, - data={ - "email": "", - "username": retired_username, - "read_states": [], - }, - ) + data: dict[str, Any] = {"read_states": []} + if not is_mysql_backend_enabled(course_id): + data["username"] = retired_username + data["email"] = "" + backend.update_user(user_id, data=data) backend.unsubscribe_all(user_id) backend.retire_all_content(user_id, retired_username)