Skip to content

A platform for community discussion. Free, open, simple.

DEV: Changes to support chat uploads (#15153)

Mark VanLandinghambd140948e34f
diff --git a/app/assets/javascripts/discourse/app/lib/uploads.js b/app/assets/javascripts/discourse/app/lib/uploads.js
index ba3a214b9fc..e5c72396593 100644
--- a/app/assets/javascripts/discourse/app/lib/uploads.js
+++ b/app/assets/javascripts/discourse/app/lib/uploads.js
@@ -120,7 +120,7 @@ export function validateUploadedFile(file, opts) {
return true;
}
-const IMAGES_EXTENSIONS_REGEX = /(png|jpe?g|gif|svg|ico|heic|heif|webp)/i;
+export const IMAGES_EXTENSIONS_REGEX = /(png|jpe?g|gif|svg|ico|heic|heif|webp)/i;
function extensionsToArray(exts) {
return exts
diff --git a/app/assets/javascripts/discourse/app/mixins/composer-upload-uppy.js b/app/assets/javascripts/discourse/app/mixins/composer-upload-uppy.js
index 8db042cc1dd..a39c77c2cb3 100644
--- a/app/assets/javascripts/discourse/app/mixins/composer-upload-uppy.js
+++ b/app/assets/javascripts/discourse/app/mixins/composer-upload-uppy.js
@@ -273,6 +273,7 @@ export default Mixin.create(ExtendableUploader, UppyS3Multipart, {
fileName: file.name,
id: file.id,
progress: 0,
+ extension: file.extension,
})
);
const placeholder = this._uploadPlaceholder(file);
diff --git a/app/jobs/scheduled/clean_up_uploads.rb b/app/jobs/scheduled/clean_up_uploads.rb
index db666f78d28..561691a7972 100644
--- a/app/jobs/scheduled/clean_up_uploads.rb
+++ b/app/jobs/scheduled/clean_up_uploads.rb
@@ -39,9 +39,13 @@ module Jobs
next if ReviewableQueuedPost.pending.where("payload->>'raw' LIKE '%#{upload.sha1}%' OR payload->>'raw' LIKE '%#{encoded_sha}%'").exists?
next if Draft.where("data LIKE '%#{upload.sha1}%' OR data LIKE '%#{encoded_sha}%'").exists?
next if UserProfile.where("bio_raw LIKE '%#{upload.sha1}%' OR bio_raw LIKE '%#{encoded_sha}%'").exists?
- if defined?(ChatMessage) &&
- ChatMessage.where("message LIKE ? OR message LIKE ?", "%#{upload.sha1}%", "%#{encoded_sha}%").exists?
- next
+ if defined?(ChatMessage)
+ # TODO after May 2022 - remove this. No longer needed as chat uploads are in a table
+ next if ChatMessage.where("message LIKE ? OR message LIKE ?", "%#{upload.sha1}%", "%#{encoded_sha}%").exists?
+ end
+
+ if defined?(ChatUpload)
+ next if ChatUpload.where(upload: upload).exists?
end
upload.destroy
else