From 45afdc2d350cc69787b517113cdb250b782a15da Mon Sep 17 00:00:00 2001 From: Alex Vandiver Date: Thu, 20 Jun 2024 16:48:55 +0000 Subject: [PATCH] attachment: Add a nullable content-type. This will be backfilled in a future commit, to prevent walking the Attachments more than once. --- .../0545_attachment_content_type.py | 20 +++++++++++++++++++ zerver/models/messages.py | 2 ++ 2 files changed, 22 insertions(+) create mode 100644 zerver/migrations/0545_attachment_content_type.py diff --git a/zerver/migrations/0545_attachment_content_type.py b/zerver/migrations/0545_attachment_content_type.py new file mode 100644 index 0000000000..1a24dce559 --- /dev/null +++ b/zerver/migrations/0545_attachment_content_type.py @@ -0,0 +1,20 @@ +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("zerver", "0544_copy_avatar_images"), + ] + + operations = [ + migrations.AddField( + model_name="archivedattachment", + name="content_type", + field=models.TextField(null=True), + ), + migrations.AddField( + model_name="attachment", + name="content_type", + field=models.TextField(null=True), + ), + ] diff --git a/zerver/models/messages.py b/zerver/models/messages.py index 7f0199e7e4..0ae380d3a6 100644 --- a/zerver/models/messages.py +++ b/zerver/models/messages.py @@ -683,6 +683,8 @@ class AbstractAttachment(models.Model): # Size of the uploaded file, in bytes size = models.IntegerField() + content_type = models.TextField(null=True) + # The two fields below serve as caches to let us avoid looking up # the corresponding messages/streams to check permissions before # serving these files.