A platform for community discussion. Free, open, simple.
FEATURE: Do not bump topic on post edit (#34681)
Martin Brennan2a65bf452224
diff --git a/lib/post_revisor.rb b/lib/post_revisor.rbindex 5881853d0aa..21671dc3161 100644--- a/lib/post_revisor.rb+++ b/lib/post_revisor.rb@@ -654,7 +654,7 @@ class PostRevisorenddef bump_topic- return if bypass_bump? || !is_last_post?+ return if bypass_bump?@topic.update_column(:bumped_at, Time.now)TopicTrackingState.publish_muted(@topic)TopicTrackingState.publish_unmuted(@topic)@@ -662,8 +662,8 @@ class PostRevisorenddef bypass_bump?- !@post_successfully_saved || @topic_changes.errored? || @opts[:bypass_bump] == true ||- @post.whisper? || only_hidden_tags_changed?+ !@post_successfully_saved || post_changes.any? || @topic_changes.errored? ||+ @opts[:bypass_bump] == true || @post.whisper? || only_hidden_tags_changed?enddef only_hidden_tags_changed?@@ -679,10 +679,6 @@ class PostRevisorfalseend- def is_last_post?- !Post.where(topic_id: @topic.id).where("post_number > ?", @post.post_number).exists?- end-def plugin_callbacksDiscourseEvent.trigger(:before_edit_post, @post, @fields)DiscourseEvent.trigger(:validate_post, @post)diff --git a/spec/lib/post_revisor_spec.rb b/spec/lib/post_revisor_spec.rbindex 89c5207d57b..e7585b702c2 100644--- a/spec/lib/post_revisor_spec.rb+++ b/spec/lib/post_revisor_spec.rb@@ -549,46 +549,25 @@ describe PostRevisor doexpect(post.revisions.size).to eq(0)end- it "should bump the topic" do+ it "doesn't bump the topic when editing the last post" doexpect {post_revisor.revise!(post.user,{ raw: "updated body" },revised_at: post.updated_at + SiteSetting.editing_grace_period + 1.seconds,)- }.to change { post.topic.bumped_at }+ }.not_to change { post.topic.bumped_at }end- it "should bump topic when no topic category" do- topic_with_no_category = Fabricate(:topic, category_id: nil)- post_from_topic_with_no_category = Fabricate(:post, topic: topic_with_no_category)+ it "doesn't bump the topic when editing a post that isn't the last post" do+ create_post(topic_id: post.topic.id)expect {- result =- post_revisor.revise!(- Fabricate(:admin),- raw: post_from_topic_with_no_category.raw,- tags: ["foo"],- )- expect(result).to eq(true)- }.to change { topic.reload.bumped_at }- end-- it "should send muted and latest message" do- TopicUser.create!(topic: post.topic, user: post.user, notification_level: 0)- messages =- MessageBus.track_publish("/latest") do- post_revisor.revise!(- post.user,- { raw: "updated body" },- revised_at: post.updated_at + SiteSetting.editing_grace_period + 1.seconds,- )- end-- muted_message = messages.find { |message| message.data["message_type"] == "muted" }- latest_message = messages.find { |message| message.data["message_type"] == "latest" }-- expect(muted_message.data["topic_id"]).to eq(topic.id)- expect(latest_message.data["topic_id"]).to eq(topic.id)+ post_revisor.revise!(+ post.user,+ { raw: "updated body" },+ revised_at: post.updated_at + SiteSetting.editing_grace_period + 1.seconds,+ )+ }.not_to change { post.topic.bumped_at }endend@@ -1438,7 +1417,7 @@ describe PostRevisor do}.to_not change { topic.reload.bumped_at }end- it "should bump topic if non staff-only tags are added" do+ it "bumps topic if non staff-only tags are added" doexpect {result =post_revisor.revise!(diff --git a/spec/models/topic_spec.rb b/spec/models/topic_spec.rbindex 10d4dd4e90b..90b4af19c68 100644--- a/spec/models/topic_spec.rb+++ b/spec/models/topic_spec.rb@@ -1419,11 +1419,11 @@ describe Topic do}.not_to change(topic, :bumped_at)end- it "bumps the topic when a new version is made of the last post" do+ it "doesn't bump the topic when a new version is made of the last post" doexpect {last_post.revise(moderator, raw: "updated contents")topic.reload- }.to change(topic, :bumped_at)+ }.not_to change(topic, :bumped_at)endit "doesn't bump the topic when a post that isn't the last post receives a new version" do