FEATURE: Create upload_references table (#16146)

This table holds associations between uploads and other models. This can be used to prevent removing uploads that are still in use.

* DEV: Create upload_references
* DEV: Use UploadReference instead of PostUpload
* DEV: Use UploadReference for SiteSetting
* DEV: Use UploadReference for Badge
* DEV: Use UploadReference for Category
* DEV: Use UploadReference for CustomEmoji
* DEV: Use UploadReference for Group
* DEV: Use UploadReference for ThemeField
* DEV: Use UploadReference for ThemeSetting
* DEV: Use UploadReference for User
* DEV: Use UploadReference for UserAvatar
* DEV: Use UploadReference for UserExport
* DEV: Use UploadReference for UserProfile
* DEV: Add method to extract uploads from raw text
* DEV: Use UploadReference for Draft
* DEV: Use UploadReference for ReviewableQueuedPost
* DEV: Use UploadReference for UserProfile's bio_raw
* DEV: Do not copy user uploads to upload references
* DEV: Copy post uploads again after deploy
* DEV: Use created_at and updated_at from uploads table
* FIX: Check if upload site setting is empty
* DEV: Copy user uploads to upload references
* DEV: Make upload extraction less strict
This commit is contained in:
Bianca Nenciu
2022-06-09 02:24:30 +03:00
committed by GitHub
parent 7fc11327b7
commit 9db8f00b3d
49 changed files with 842 additions and 142 deletions

View File

@ -18,8 +18,8 @@ describe TopicUploadSecurityManager do
let!(:upload3) { Fabricate(:secure_upload) }
before do
PostUpload.create(upload: upload, post: post2)
PostUpload.create(upload: upload2, post: post3)
UploadReference.create(upload: upload, target: post2)
UploadReference.create(upload: upload2, target: post3)
upload.update(access_control_post: post2)
upload2.update(access_control_post: post3)
end
@ -132,7 +132,7 @@ describe TopicUploadSecurityManager do
context "when this is the first post the upload has appeared in" do
before do
PostUpload.create(upload: upload3, post: post4)
UploadReference.create(upload: upload3, target: post4)
end
it "changes the upload secure status to true and changes the ACL and rebakes the post and sets the access control post" do
@ -157,8 +157,8 @@ describe TopicUploadSecurityManager do
context "when this is not the first post the upload has appeared in" do
before do
PostUpload.create(upload: upload3, post: Fabricate(:post))
PostUpload.create(upload: upload3, post: post4)
UploadReference.create(upload: upload3, target: Fabricate(:post))
UploadReference.create(upload: upload3, target: post4)
end
it "does not change the upload secure status and does not set the access control post" do