mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: log a staff action + send a private message when disabling the 'download_remote_images_to_local' site setting
This commit is contained in:
@@ -36,6 +36,7 @@ en:
|
|||||||
is_reserved: "is reserved"
|
is_reserved: "is reserved"
|
||||||
|
|
||||||
purge_reason: "Automatically deleted due to being old and unverified"
|
purge_reason: "Automatically deleted due to being old and unverified"
|
||||||
|
disable_remote_images_download_reason: "Remote images download was disabled because there wasn't enough disk space available."
|
||||||
|
|
||||||
errors:
|
errors:
|
||||||
messages:
|
messages:
|
||||||
|
|||||||
@@ -245,7 +245,12 @@ class CookedPostProcessor
|
|||||||
def disable_if_low_on_disk_space
|
def disable_if_low_on_disk_space
|
||||||
if available_disk_space < SiteSetting.download_remote_images_threshold
|
if available_disk_space < SiteSetting.download_remote_images_threshold
|
||||||
SiteSetting.download_remote_images_to_local = false
|
SiteSetting.download_remote_images_to_local = false
|
||||||
SystemMessage.create(Discourse.site_contact_user, :download_remote_images_disabled)
|
# log the site setting change
|
||||||
|
reason = I18n.t("disable_remote_images_download_reason")
|
||||||
|
staff_action_logger = StaffActionLogger.new(Discourse.system_user)
|
||||||
|
staff_action_logger.log_site_setting_change("download_remote_images_to_local", true, false, { details: reason })
|
||||||
|
# also send a private message to the site contact user
|
||||||
|
SystemMessage.create_from_system_user(Discourse.site_contact_user, :download_remote_images_disabled)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
false
|
false
|
||||||
|
|||||||
@@ -346,7 +346,8 @@ describe CookedPostProcessor do
|
|||||||
before { SiteSetting.expects(:download_remote_images_threshold).returns(75) }
|
before { SiteSetting.expects(:download_remote_images_threshold).returns(75) }
|
||||||
|
|
||||||
it "disables download_remote_images_threshold and send a notification to the admin" do
|
it "disables download_remote_images_threshold and send a notification to the admin" do
|
||||||
SystemMessage.expects(:create).with(Discourse.site_contact_user, :download_remote_images_disabled).once
|
StaffActionLogger.any_instance.expects(:log_site_setting_change).once
|
||||||
|
SystemMessage.expects(:create_from_system_user).with(Discourse.site_contact_user, :download_remote_images_disabled).once
|
||||||
cpp.disable_if_low_on_disk_space.should == true
|
cpp.disable_if_low_on_disk_space.should == true
|
||||||
SiteSetting.download_remote_images_to_local.should == false
|
SiteSetting.download_remote_images_to_local.should == false
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user