From 28ac03c42fb82db5f1dad1f711cffdde0a0cce6c Mon Sep 17 00:00:00 2001 From: Andrew Godwin Date: Sun, 4 Dec 2022 20:31:49 -0700 Subject: Fetch user in real-time for searches Fixes #84 --- activities/views/search.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'activities') diff --git a/activities/views/search.py b/activities/views/search.py index b5e5586..8bdef78 100644 --- a/activities/views/search.py +++ b/activities/views/search.py @@ -1,10 +1,11 @@ from typing import Set +from asgiref.sync import async_to_sync from django import forms from django.views.generic import FormView from activities.models import Hashtag -from users.models import Domain, Identity +from users.models import Domain, Identity, IdentityStates class Search(FormView): @@ -37,7 +38,10 @@ class Search(FormView): identity = Identity.by_username_and_domain( username, domain, fetch=True ) - identity = None + if identity and identity.state == IdentityStates.outdated: + async_to_sync(identity.fetch_actor)() + else: + identity = None if identity: results.add(identity) -- cgit v1.2.3