mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 15:25:35 +08:00
UX: Set silence_reason using the system locale
Previously we would use the user's locale, which can be confusing for moderators.
This commit is contained in:
parent
fe7a7ecf6c
commit
4476680d4b
|
@ -157,12 +157,14 @@ class NewPostManager
|
|||
|
||||
result = manager.enqueue(reason)
|
||||
|
||||
if is_fast_typer?(manager)
|
||||
UserSilencer.silence(manager.user, Discourse.system_user, keep_posts: true, reason: I18n.t("user.new_user_typed_too_fast"))
|
||||
elsif matches_auto_silence_regex?(manager)
|
||||
UserSilencer.silence(manager.user, Discourse.system_user, keep_posts: true, reason: I18n.t("user.content_matches_auto_silence_regex"))
|
||||
elsif reason == :email_spam && is_first_post?(manager)
|
||||
UserSilencer.silence(manager.user, Discourse.system_user, keep_posts: true, reason: I18n.t("user.email_in_spam_header"))
|
||||
I18n.with_locale(SiteSetting.default_locale) do
|
||||
if is_fast_typer?(manager)
|
||||
UserSilencer.silence(manager.user, Discourse.system_user, keep_posts: true, reason: I18n.t("user.new_user_typed_too_fast"))
|
||||
elsif matches_auto_silence_regex?(manager)
|
||||
UserSilencer.silence(manager.user, Discourse.system_user, keep_posts: true, reason: I18n.t("user.content_matches_auto_silence_regex"))
|
||||
elsif reason == :email_spam && is_first_post?(manager)
|
||||
UserSilencer.silence(manager.user, Discourse.system_user, keep_posts: true, reason: I18n.t("user.email_in_spam_header"))
|
||||
end
|
||||
end
|
||||
|
||||
result
|
||||
|
|
|
@ -182,6 +182,23 @@ describe NewPostManager do
|
|||
end
|
||||
end
|
||||
|
||||
context 'with a fast typer' do
|
||||
let(:manager) { NewPostManager.new(topic.user, raw: 'this is new post content', topic_id: topic.id, first_post_checks: true) }
|
||||
let(:user) { manager.user }
|
||||
|
||||
before do
|
||||
user.update!(trust_level: 0)
|
||||
end
|
||||
|
||||
it "adds the silence reason in the system locale" do
|
||||
I18n.with_locale(:fr) do # Simulate french user
|
||||
result = NewPostManager.default_handler(manager)
|
||||
end
|
||||
expect(user.silenced?).to eq(true)
|
||||
expect(user.silence_reason).to eq(I18n.t("user.new_user_typed_too_fast", locale: :en))
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context "new topic handler" do
|
||||
|
|
Loading…
Reference in New Issue
Block a user