mirror of
https://github.com/discourse/discourse.git
synced 2025-03-09 14:34:35 +00:00
FEATURE: Invalidate broken images cache on Rebuild HTML action
This commit is contained in:
parent
2076f371b3
commit
2b006c0429
@ -513,7 +513,7 @@ class PostsController < ApplicationController
|
|||||||
guardian.ensure_can_rebake!
|
guardian.ensure_can_rebake!
|
||||||
|
|
||||||
post = find_post_from_params
|
post = find_post_from_params
|
||||||
post.rebake!(invalidate_oneboxes: true)
|
post.rebake!(invalidate_oneboxes: true, invalidate_broken_images: true)
|
||||||
|
|
||||||
render body: nil
|
render body: nil
|
||||||
end
|
end
|
||||||
|
@ -549,6 +549,11 @@ class Post < ActiveRecord::Base
|
|||||||
|
|
||||||
update_columns(cooked: new_cooked, baked_at: Time.new, baked_version: BAKED_VERSION)
|
update_columns(cooked: new_cooked, baked_at: Time.new, baked_version: BAKED_VERSION)
|
||||||
|
|
||||||
|
if opts.fetch(:invalidate_broken_images, false)
|
||||||
|
custom_fields.delete(BROKEN_IMAGES)
|
||||||
|
save_custom_fields
|
||||||
|
end
|
||||||
|
|
||||||
# Extracts urls from the body
|
# Extracts urls from the body
|
||||||
TopicLink.extract_from(self)
|
TopicLink.extract_from(self)
|
||||||
QuotedPost.extract_from(self)
|
QuotedPost.extract_from(self)
|
||||||
|
@ -661,6 +661,15 @@ describe PostsController do
|
|||||||
put "/posts/#{post.id}/rebake.json"
|
put "/posts/#{post.id}/rebake.json"
|
||||||
expect(response.status).to eq(200)
|
expect(response.status).to eq(200)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "will invalidate broken images cache" do
|
||||||
|
sign_in(Fabricate(:moderator))
|
||||||
|
post.custom_fields[Post::BROKEN_IMAGES] = ["https://example.com/image.jpg"].to_json
|
||||||
|
post.save_custom_fields
|
||||||
|
put "/posts/#{post.id}/rebake.json"
|
||||||
|
post.reload
|
||||||
|
expect(post.custom_fields[Post::BROKEN_IMAGES]).to be_nil
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user