mirror of
https://github.com/zulip/zulip.git
synced 2025-11-20 22:48:16 +00:00
Thumbor and tc-aws have been dragging their feet on Python 3 support for years, and even the alphas and unofficial forks we’ve been running don’t seem to be maintained anymore. Depending on these projects is no longer viable for us. Signed-off-by: Anders Kaseorg <anders@zulip.com>
14 lines
565 B
Python
14 lines
565 B
Python
from django.http import HttpRequest, HttpResponse, HttpResponseForbidden
|
|
from django.shortcuts import redirect
|
|
|
|
from zerver.lib.camo import is_camo_url_valid
|
|
from zerver.lib.thumbnail import generate_thumbnail_url
|
|
|
|
|
|
def handle_camo_url(request: HttpRequest, digest: str, received_url: str) -> HttpResponse:
|
|
original_url = bytes.fromhex(received_url).decode()
|
|
if is_camo_url_valid(digest, original_url):
|
|
return redirect(generate_thumbnail_url(original_url, is_camo_url=True))
|
|
else:
|
|
return HttpResponseForbidden("<p>Not a valid URL.</p>")
|