Skip to content

Commit

Permalink
Handle upstream issues with mastodon
Browse files Browse the repository at this point in the history
  • Loading branch information
RealOrangeOne committed Sep 4, 2023
1 parent e732e0c commit 29505d4
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions website/well_known/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
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
Expand Down Expand Up @@ -55,7 +56,10 @@ def activitypub_proxy(request: HttpRequest) -> HttpResponse:
if not settings.ACTIVITYPUB_HOST:
raise Http404

return proxy_view(
request,
f"https://{settings.ACTIVITYPUB_HOST}{request.path}",
)
try:
return proxy_view(
request,
f"https://{settings.ACTIVITYPUB_HOST}{request.path}",
)
except RequestException:
return HttpResponse(status_code=502)

0 comments on commit 29505d4

Please sign in to comment.