Handle upstream issues with mastodon

This commit is contained in:
Jake Howard 2023-09-04 19:22:06 +01:00
parent e732e0c73e
commit 29505d4a52
Signed by: jake
GPG key ID: 57AFB45680EDD477

View file

@ -8,6 +8,7 @@ from django.utils.decorators import method_decorator
from django.views.decorators.cache import cache_control, cache_page
from django.views.generic import TemplateView
from proxy.views import proxy_view
from requests.exceptions import RequestException
from website.contact.models import ContactPage
from website.contrib.singleton_page.utils import SingletonPageCache
@ -55,7 +56,10 @@ def activitypub_proxy(request: HttpRequest) -> HttpResponse:
if not settings.ACTIVITYPUB_HOST:
raise Http404
try:
return proxy_view(
request,
f"https://{settings.ACTIVITYPUB_HOST}{request.path}",
)
except RequestException:
return HttpResponse(status_code=502)