From 7746abbbb7700fa918450101bbc6d29ed9b4b608 Mon Sep 17 00:00:00 2001 From: Andrew Godwin Date: Wed, 9 Nov 2022 22:29:33 -0700 Subject: Most of the way through the stator refactor --- users/shortcuts.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'users/shortcuts.py') diff --git a/users/shortcuts.py b/users/shortcuts.py index 65206a3..3e7618a 100644 --- a/users/shortcuts.py +++ b/users/shortcuts.py @@ -3,7 +3,7 @@ from django.http import Http404 from users.models import Domain, Identity -def by_handle_or_404(request, handle, local=True, fetch=False): +def by_handle_or_404(request, handle, local=True, fetch=False) -> Identity: """ Retrieves an Identity by its long or short handle. Domain-sensitive, so it will understand short handles on alternate domains. @@ -12,14 +12,17 @@ def by_handle_or_404(request, handle, local=True, fetch=False): if "HTTP_HOST" not in request.META: raise Http404("No hostname available") username = handle - domain_instance = Domain.get_local_domain(request.META["HTTP_HOST"]) + domain_instance = Domain.get_domain(request.META["HTTP_HOST"]) if domain_instance is None: raise Http404("No matching domains found") domain = domain_instance.domain else: username, domain = handle.split("@", 1) # Resolve the domain to the display domain - domain = Domain.get_local_domain(request.META["HTTP_HOST"]).domain + domain_instance = Domain.get_domain(domain) + if domain_instance is None: + raise Http404("No matching domains found") + domain = domain_instance.domain identity = Identity.by_username_and_domain( username, domain, -- cgit v1.2.3