FIX: Update excerpt after process_post (#12340)

Onebox content may only be resolved during the process_post job. Onebox content could change the content of the excerpt, so we need to make sure the excerpt is updated accordingly.
This commit is contained in:
David Taylor 2021-03-10 17:07:13 +00:00 committed by GitHub
parent de6474a85f
commit bce837db0c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 0 deletions

View File

@ -34,6 +34,7 @@ module Jobs
Rails.logger.warn("Cooked post processor in FATAL state, bypassing. You need to urgently restart sidekiq\norig: #{orig_cooked}\nrecooked: #{recooked}\ncooked: #{cooked}\npost id: #{post.id}") Rails.logger.warn("Cooked post processor in FATAL state, bypassing. You need to urgently restart sidekiq\norig: #{orig_cooked}\nrecooked: #{recooked}\ncooked: #{cooked}\npost id: #{post.id}")
else else
post.update_column(:cooked, cp.html) post.update_column(:cooked, cp.html)
post.topic.update_excerpt(post.excerpt_for_topic) if post.is_first_post?
extract_links(post) extract_links(post)
auto_tag(post) if SiteSetting.tagging_enabled? && post.post_number == 1 auto_tag(post) if SiteSetting.tagging_enabled? && post.post_number == 1
post.publish_change_to_clients! :revised post.publish_change_to_clients! :revised

View File

@ -78,6 +78,18 @@ describe Jobs::ProcessPost do
expect(post.cooked).to eq(cooked) expect(post.cooked).to eq(cooked)
end end
it "updates the topic excerpt when first post" do
post = Fabricate(:post, raw: "Some OP content", cooked: "")
post.topic.update_excerpt("Incorrect")
Jobs::ProcessPost.new.execute(post_id: post.id)
expect(post.topic.reload.excerpt).to eq("Some OP content")
post2 = Fabricate(:post, raw: "Some reply content", cooked: "", topic: post.topic)
Jobs::ProcessPost.new.execute(post_id: post2.id)
expect(post.topic.reload.excerpt).to eq("Some OP content")
end
it "automatically tags first posts" do it "automatically tags first posts" do
SiteSetting.tagging_enabled = true SiteSetting.tagging_enabled = true