Merge pull request #4679 from techAPJ/rebake-extract-links
FIX: topic links were getting dropped when post is rebaked
This commit is contained in:
commit
0c6ad455a3
|
@ -33,11 +33,17 @@ 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}")
|
||||
else
|
||||
post.update_column(:cooked, cp.html)
|
||||
extract_links(post)
|
||||
post.publish_change_to_clients! :revised
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# onebox may have added some links, so extract them now
|
||||
def extract_links(post)
|
||||
TopicLink.extract_from(post)
|
||||
QuotedPost.extract_from(post)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -35,16 +35,9 @@ class CookedPostProcessor
|
|||
optimize_urls
|
||||
pull_hotlinked_images(bypass_bump)
|
||||
grant_badges
|
||||
extract_links
|
||||
end
|
||||
end
|
||||
|
||||
# onebox may have added some links, so extract them now
|
||||
def extract_links
|
||||
TopicLink.extract_from(@post)
|
||||
QuotedPost.extract_from(@post)
|
||||
end
|
||||
|
||||
def has_emoji?
|
||||
(@doc.css("img.emoji") - @doc.css(".quote img")).size > 0
|
||||
end
|
||||
|
|
|
@ -602,16 +602,6 @@ describe CookedPostProcessor do
|
|||
|
||||
end
|
||||
|
||||
context "extracts links" do
|
||||
let(:post) { Fabricate(:post, raw: "sam has a blog at https://samsaffron.com") }
|
||||
|
||||
it "always re-extracts links on post process" do
|
||||
TopicLink.destroy_all
|
||||
CookedPostProcessor.new(post).post_process
|
||||
expect(TopicLink.count).to eq(1)
|
||||
end
|
||||
end
|
||||
|
||||
context "grant badges" do
|
||||
let(:cpp) { CookedPostProcessor.new(post) }
|
||||
|
||||
|
|
|
@ -46,6 +46,13 @@ describe Jobs::ProcessPost do
|
|||
expect(post.cooked).not_to match(/http/)
|
||||
end
|
||||
|
||||
it "always re-extracts links on post process" do
|
||||
post.update_columns(raw: "sam has a blog at https://samsaffron.com")
|
||||
TopicLink.destroy_all
|
||||
Jobs::ProcessPost.new.execute(post_id: post.id)
|
||||
expect(TopicLink.count).to eq(1)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue