upload: Generate thumbnails when images are uploaded.

A new table is created to track which path_id attachments are images,
and for those their metadata, and which thumbnails have been created.
Using path_id as the effective primary key lets us ignore if the
attachment is archived or not, saving some foreign key messes.

A new worker is added to observe events when rows are added to this
table, and to generate and store thumbnails for those images in
differing sizes and formats.
This commit is contained in:
Alex Vandiver
2024-06-20 21:58:27 +00:00
committed by Tim Abbott
parent 7aa5bb233d
commit 2e38f426f4
21 changed files with 788 additions and 50 deletions

View File

@@ -557,7 +557,11 @@ def use_s3_backend(method: Callable[P, None]) -> Callable[P, None]:
@override_settings(LOCAL_AVATARS_DIR=None)
@override_settings(LOCAL_FILES_DIR=None)
def new_method(*args: P.args, **kwargs: P.kwargs) -> None:
with mock.patch("zerver.lib.upload.upload_backend", S3UploadBackend()):
backend = S3UploadBackend()
with (
mock.patch("zerver.lib.upload.upload_backend", backend),
mock.patch("zerver.worker.thumbnail.upload_backend", backend),
):
return method(*args, **kwargs)
return new_method