diff options
author | Andrew Godwin | 2022-11-09 22:29:33 -0700 |
---|---|---|
committer | Andrew Godwin | 2022-11-09 22:29:49 -0700 |
commit | 7746abbbb7700fa918450101bbc6d29ed9b4b608 (patch) | |
tree | 8768efd8201faa2fee18e5d3b46f33785002f5d6 /users/shortcuts.py | |
parent | 61c324508e62bb640b4526183d0837fc57d742c2 (diff) | |
download | takahe-7746abbbb7700fa918450101bbc6d29ed9b4b608.tar.gz takahe-7746abbbb7700fa918450101bbc6d29ed9b4b608.tar.bz2 takahe-7746abbbb7700fa918450101bbc6d29ed9b4b608.zip |
Most of the way through the stator refactor
Diffstat (limited to 'users/shortcuts.py')
-rw-r--r-- | users/shortcuts.py | 9 |
1 files changed, 6 insertions, 3 deletions
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, |