From 6c699b17234355598d6d3237e8826adf6f0688f9 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Mon, 16 May 2022 19:13:36 +0200 Subject: [PATCH] Fix preferred posting language returning unusable value in REST API (#18428) --- app/models/user.rb | 3 ++- app/serializers/rest/preferences_serializer.rb | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index ab832bcd080..ab2e391e9be 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -53,6 +53,7 @@ class User < ApplicationRecord include Settings::Extend include UserRoles include Redisable + include LanguagesHelper # The home and list feeds will be stored in Redis for this amount # of time, and status fan-out to followers will include only people @@ -248,7 +249,7 @@ class User < ApplicationRecord end def preferred_posting_language - settings.default_language || locale + valid_locale_cascade(settings.default_language, locale) end def setting_default_privacy diff --git a/app/serializers/rest/preferences_serializer.rb b/app/serializers/rest/preferences_serializer.rb index 119f0e06d89..874bd990d3a 100644 --- a/app/serializers/rest/preferences_serializer.rb +++ b/app/serializers/rest/preferences_serializer.rb @@ -17,7 +17,7 @@ class REST::PreferencesSerializer < ActiveModel::Serializer end def posting_default_language - object.user.setting_default_language.presence + object.user.preferred_posting_language end def reading_default_sensitive_media