FIX: log a staff action + send a private message when disabling the 'download_remote_images_to_local' site setting

This commit is contained in:
Régis Hanol 2014-09-23 19:11:14 +02:00
parent dc789502f9
commit 5681338b08
3 changed files with 9 additions and 2 deletions

View File

@ -36,6 +36,7 @@ en:
is_reserved: "is reserved"
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:
messages:

View File

@ -245,7 +245,12 @@ class CookedPostProcessor
def disable_if_low_on_disk_space
if available_disk_space < SiteSetting.download_remote_images_threshold
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
end
false

View File

@ -346,7 +346,8 @@ describe CookedPostProcessor do
before { SiteSetting.expects(:download_remote_images_threshold).returns(75) }
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
SiteSetting.download_remote_images_to_local.should == false
end