mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 19:03:45 +08:00
add download_remote_images_to_local site setting
This commit is contained in:
parent
6a3000ffef
commit
16267e4887
|
@ -8,8 +8,7 @@ module Jobs
|
|||
end
|
||||
|
||||
def execute(args)
|
||||
# we don't want to run the job if we're not allowed to crawl images
|
||||
return unless SiteSetting.crawl_images?
|
||||
return unless SiteSetting.download_remote_images_to_local?
|
||||
|
||||
post_id = args[:post_id]
|
||||
raise Discourse::InvalidParameters.new(:post_id) unless post_id.present?
|
||||
|
|
|
@ -500,6 +500,7 @@ en:
|
|||
company_domain: "The domain name owned by the company that runs this site, used in legal documents like the /tos"
|
||||
queue_jobs: "DEVELOPER ONLY! WARNING! By default, queue jobs in sidekiq. If disabled, your site will be broken."
|
||||
crawl_images: "Enable retrieving images from third party sources to insert width and height dimensions"
|
||||
download_remote_images_to_local: "Download a copy of all remote images"
|
||||
ninja_edit_window: "Number of seconds after posting where edits do not create a new version"
|
||||
edit_history_visible_to_public: "Allow everyone to see previous versions of an edited post. When disabled, only staff members can view edit history."
|
||||
delete_removed_posts_after: "Number of hours after which posts removed by the author will be deleted."
|
||||
|
|
|
@ -249,6 +249,10 @@ files:
|
|||
default: false
|
||||
detect_custom_avatars: true
|
||||
max_daily_gravatar_crawls: 500
|
||||
download_remote_images_to_local:
|
||||
default:
|
||||
test: false
|
||||
default: true
|
||||
|
||||
trust:
|
||||
default_trust_level: 0
|
||||
|
|
|
@ -219,8 +219,8 @@ class CookedPostProcessor
|
|||
end
|
||||
|
||||
def pull_hotlinked_images
|
||||
# we don't want to run the job if we're not allowed to crawl images
|
||||
return unless SiteSetting.crawl_images?
|
||||
# is the job enabled?
|
||||
return unless SiteSetting.download_remote_images_to_local?
|
||||
# we only want to run the job whenever it's changed by a user
|
||||
return if @post.updated_by == Discourse.system_user
|
||||
# make sure no other job is scheduled
|
||||
|
|
|
@ -275,15 +275,15 @@ describe CookedPostProcessor do
|
|||
let(:post) { build(:post) }
|
||||
let(:cpp) { CookedPostProcessor.new(post) }
|
||||
|
||||
it "does not run when crawl images is disabled" do
|
||||
SiteSetting.stubs(:crawl_images).returns(false)
|
||||
it "does not run when download_remote_images_to_local is disabled" do
|
||||
SiteSetting.stubs(:download_remote_images_to_local).returns(false)
|
||||
Jobs.expects(:cancel_scheduled_job).never
|
||||
cpp.pull_hotlinked_images
|
||||
end
|
||||
|
||||
context "when crawl_images? is enabled" do
|
||||
context "when download_remote_images_to_local? is enabled" do
|
||||
|
||||
before { SiteSetting.stubs(:crawl_images).returns(true) }
|
||||
before { SiteSetting.stubs(:download_remote_images_to_local).returns(true) }
|
||||
|
||||
it "runs only when a user updated the post" do
|
||||
post.updated_by = Discourse.system_user
|
||||
|
|
Loading…
Reference in New Issue
Block a user