Commit Graph

9 Commits

Author SHA1 Message Date
Anders Kaseorg 531b34cb4c ruff: Fix UP007 Use `X | Y` for type annotations.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2024-07-13 22:28:22 -07:00
Alex Vandiver e1a9473bd6 thumbnail: Log and revert to gravatar on migration failure.
This is preferable to leaving the user with a broken avatar image.
2024-07-11 07:31:39 -07:00
Alex Vandiver 536cf0abc8 thumbnail: Be slightly more specific about our exception catches. 2024-07-11 07:31:39 -07:00
Alex Vandiver b53a33a5bc thumbnail: Properly re-derive Content-Disposition for original uploads. 2024-07-11 07:31:39 -07:00
Alex Vandiver 1f9925b1e3 thumbnail: Skip avatars which have already been migrated. 2024-07-11 07:31:39 -07:00
Alex Vandiver a4981c13f7 thumbnail: Skip avatars whose old versions are missing. 2024-07-11 07:31:39 -07:00
Alex Vandiver 4d3d3efcf1 thumbnail: Newly-thumbnailed avatars are all image/png. 2024-07-11 07:31:39 -07:00
Alex Vandiver a9d1adadb7 thumbnail: Add or move progress earlier in loop.
This makes the counts correct and consistent.
2024-07-11 07:31:39 -07:00
Alex Vandiver e29a455b2d avatars: Encode version into the filename.
Hash the salt, user-id, and now avatar version into the filename.
This allows the URL contents to be immutable, and thus to be marked as
immutable and cacheable.  Since avatars are served unauthenticated,
hashing with a server-side salt makes the current and past avatars not
enumerable.

This requires plumbing the current (or future) avatar version through
various parts of the upload process.

Since this already requires a full migration of current avatars, also
take the opportunity to fix the missing `.png` on S3 uploads (#12852).

We switch from SHA-1 to SHA-256, but truncate it such that avatar URL
data does not substantially increase in size.

Fixes: #12852.
2024-07-07 14:40:07 -07:00