DEV: Add security_last_changed_at and security_last_changed_reason to uploads (#11860)

This PR adds security_last_changed_at and security_last_changed_reason to uploads. This has been done to make it easier to track down why an upload's secure column has changed and when. This necessitated a refactor of the UploadSecurity class to provide reasons why the upload security would have changed.

As well as this, a source is now provided from the location which called for the upload's security status to be updated as they are several (e.g. post creator, topic security updater, rake tasks, manual change).
This commit is contained in:
Martin Brennan
2021-01-29 09:03:44 +10:00
committed by GitHub
parent 0990112d80
commit f49e3e5731
13 changed files with 182 additions and 87 deletions

View File

@ -31,7 +31,7 @@ class TopicUploadSecurityManager
# we have already got the post preloaded so we may as well
# attach it here to avoid another load in UploadSecurity
upload.access_control_post = post
upload.update_secure_status
upload.update_secure_status(source: "topic upload security")
end
post.rebake! if secure_status_did_change
Rails.logger.debug("Security updated & rebake complete in topic #{@topic.id} - post #{post.id}")
@ -62,7 +62,7 @@ class TopicUploadSecurityManager
first_post_upload_appeared_in = upload.post_uploads.first.post
if first_post_upload_appeared_in == post
upload.update(access_control_post: post)
upload.update_secure_status
upload.update_secure_status(source: "topic upload security")
else
false
end