FIX: Incorrect locale in badge granter (#8749)

We want to use default locale when:
a) Site settings are not allowing for user locale
OR
b) User locale are blank
This commit is contained in:
Krzysztof Kotlarek
2020-01-21 09:08:48 +11:00
committed by GitHub
parent 0420be88a6
commit aa04349cfd
2 changed files with 22 additions and 4 deletions

View File

@@ -380,11 +380,13 @@ class BadgeGranter
SQL
end
def self.send_notification(user_id, username, locale, badge)
use_default_locale = !SiteSetting.allow_user_locale && locale.blank?
notification_locale = use_default_locale ? SiteSetting.default_locale : locale
def self.notification_locale(locale)
use_default_locale = !SiteSetting.allow_user_locale || locale.blank?
use_default_locale ? SiteSetting.default_locale : locale
end
I18n.with_locale(notification_locale) do
def self.send_notification(user_id, username, locale, badge)
I18n.with_locale(notification_locale(locale)) do
Notification.create!(
user_id: user_id,
notification_type: Notification.types[:granted_badge],