mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-08-16 22:00:11 -04:00
Merge remote-tracking branch 'upstream/release-v1.64'
This commit is contained in:
commit
b0f213fd3d
176 changed files with 4539 additions and 2643 deletions
|
@ -42,6 +42,16 @@ THUMBNAIL_SIZE_YAML = """\
|
|||
# method: %(method)s
|
||||
"""
|
||||
|
||||
# A map from the given media type to the type of thumbnail we should generate
|
||||
# for it.
|
||||
THUMBNAIL_SUPPORTED_MEDIA_FORMAT_MAP = {
|
||||
"image/jpeg": "jpeg",
|
||||
"image/jpg": "jpeg",
|
||||
"image/webp": "webp",
|
||||
"image/gif": "webp",
|
||||
"image/png": "png",
|
||||
}
|
||||
|
||||
HTTP_PROXY_SET_WARNING = """\
|
||||
The Synapse config url_preview_ip_range_blacklist will be ignored as an HTTP(s) proxy is configured."""
|
||||
|
||||
|
@ -79,14 +89,26 @@ def parse_thumbnail_requirements(
|
|||
width = size["width"]
|
||||
height = size["height"]
|
||||
method = size["method"]
|
||||
jpeg_thumbnail = ThumbnailRequirement(width, height, method, "image/jpeg")
|
||||
png_thumbnail = ThumbnailRequirement(width, height, method, "image/png")
|
||||
webp_thumbnail = ThumbnailRequirement(width, height, method, "image/webp")
|
||||
requirements.setdefault("image/jpeg", []).append(jpeg_thumbnail)
|
||||
requirements.setdefault("image/jpg", []).append(jpeg_thumbnail)
|
||||
requirements.setdefault("image/webp", []).append(webp_thumbnail)
|
||||
requirements.setdefault("image/gif", []).append(png_thumbnail)
|
||||
requirements.setdefault("image/png", []).append(png_thumbnail)
|
||||
|
||||
for format, thumbnail_format in THUMBNAIL_SUPPORTED_MEDIA_FORMAT_MAP.items():
|
||||
requirement = requirements.setdefault(format, [])
|
||||
if thumbnail_format == "jpeg":
|
||||
requirement.append(
|
||||
ThumbnailRequirement(width, height, method, "image/jpeg")
|
||||
)
|
||||
elif thumbnail_format == "png":
|
||||
requirement.append(
|
||||
ThumbnailRequirement(width, height, method, "image/png")
|
||||
)
|
||||
elif thumbnail_format == "webp":
|
||||
requirement.append(
|
||||
ThumbnailRequirement(width, height, method, "image/webp")
|
||||
)
|
||||
else:
|
||||
raise Exception(
|
||||
"Unknown thumbnail mapping from %s to %s. This is a Synapse problem, please report!"
|
||||
% (format, thumbnail_format)
|
||||
)
|
||||
return {
|
||||
media_type: tuple(thumbnails) for media_type, thumbnails in requirements.items()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue