mirror of
https://github.com/discourse/discourse.git
synced 2024-12-19 03:53:47 +08:00
FIX: update flag reason message with default value (#30026)
Currently only system flags are translated. When we send message to the user that their post was deleted because of custom flag, we should default to custom flag name.
This commit is contained in:
parent
9c5eb7952e
commit
28b4ff6cb6
|
@ -658,6 +658,7 @@ class Post < ActiveRecord::Base
|
||||||
"flag_reasons.#{post_action_type_view.types[post_action_type_id]}",
|
"flag_reasons.#{post_action_type_view.types[post_action_type_id]}",
|
||||||
locale: SiteSetting.default_locale,
|
locale: SiteSetting.default_locale,
|
||||||
base_path: Discourse.base_path,
|
base_path: Discourse.base_path,
|
||||||
|
default: PostActionType.names[post_action_type_id],
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -413,6 +413,7 @@ class PostDestroyer
|
||||||
"flag_reasons#{".responder" if notify_responders}.#{flag_type}",
|
"flag_reasons#{".responder" if notify_responders}.#{flag_type}",
|
||||||
locale: SiteSetting.default_locale,
|
locale: SiteSetting.default_locale,
|
||||||
base_path: Discourse.base_path,
|
base_path: Discourse.base_path,
|
||||||
|
default: PostActionType.flags.find { |flag| flag[:name_key] == flag_type.to_s }[:name],
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
|
@ -954,6 +954,29 @@ RSpec.describe PostDestroyer do
|
||||||
expect(Jobs::SendSystemMessage.jobs.size).to eq(0)
|
expect(Jobs::SendSystemMessage.jobs.size).to eq(0)
|
||||||
expect(ReviewableFlaggedPost.pending.count).to eq(0)
|
expect(ReviewableFlaggedPost.pending.count).to eq(0)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "when custom flags" do
|
||||||
|
fab!(:custom_flag) { Fabricate(:flag, name: "custom flag", notify_type: true) }
|
||||||
|
let(:third_post) { Fabricate(:post, topic_id: post.topic_id) }
|
||||||
|
|
||||||
|
it "should send message to user with correct translation" do
|
||||||
|
PostActionCreator.new(
|
||||||
|
moderator,
|
||||||
|
third_post,
|
||||||
|
custom_flag.id,
|
||||||
|
is_warning: false,
|
||||||
|
flag_topic: true,
|
||||||
|
).perform
|
||||||
|
PostDestroyer.new(moderator, third_post, { reviewable: Reviewable.last }).destroy
|
||||||
|
jobs = Jobs::SendSystemMessage.jobs
|
||||||
|
expect(jobs.size).to eq(1)
|
||||||
|
|
||||||
|
Jobs::SendSystemMessage.new.execute(jobs[0]["args"][0].with_indifferent_access)
|
||||||
|
|
||||||
|
expect(Post.last.raw).to match("custom flag")
|
||||||
|
custom_flag.destroy!
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "user actions" do
|
describe "user actions" do
|
||||||
|
|
|
@ -1498,6 +1498,19 @@ RSpec.describe Post do
|
||||||
).to(true)
|
).to(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "should inform the user when custom flag" do
|
||||||
|
custom_flag = Fabricate(:flag, name: "custom flag")
|
||||||
|
post.hide!(PostActionType.types[:custom_custom_flag])
|
||||||
|
|
||||||
|
jobs = Jobs::SendSystemMessage.jobs
|
||||||
|
expect(jobs.size).to eq(1)
|
||||||
|
|
||||||
|
Jobs::SendSystemMessage.new.execute(jobs[0]["args"][0].with_indifferent_access)
|
||||||
|
expect(Post.last.raw).to match("custom flag")
|
||||||
|
|
||||||
|
custom_flag.destroy!
|
||||||
|
end
|
||||||
|
|
||||||
it "should decrease user_stat topic_count for first post" do
|
it "should decrease user_stat topic_count for first post" do
|
||||||
expect do post.hide!(PostActionType.types[:off_topic]) end.to change {
|
expect do post.hide!(PostActionType.types[:off_topic]) end.to change {
|
||||||
post.user.user_stat.reload.topic_count
|
post.user.user_stat.reload.topic_count
|
||||||
|
|
Loading…
Reference in New Issue
Block a user