FIX: invalid user locale when accepting group membership

If, for whatever reasons, the user's locale is "blank" and an admin is accepting their group membership request, there will be an error because we're generating posts with the locale of recipient.

In order to fix this, we now use the `user.effective_locale` which takes care of multiple things, including returning the default locale when the user's locale is blank.

Internal ref - t/132347
This commit is contained in:
Régis Hanol
2024-06-27 19:10:59 +02:00
parent a56321efb5
commit 57eecbef4b
4 changed files with 43 additions and 14 deletions

View File

@ -353,7 +353,7 @@ class DiscourseConnect < DiscourseConnectBase
user.name = name || User.suggest_name(username.blank? ? email : username)
end
if locale_force_update && SiteSetting.allow_user_locale && locale &&
if locale_force_update && SiteSetting.allow_user_locale && locale.present? &&
LocaleSiteSetting.valid_value?(locale)
user.locale = locale
end