summaryrefslogtreecommitdiffstats
path: root/activities/models
diff options
context:
space:
mode:
authorAndrew Godwin2022-12-04 21:22:20 -0700
committerAndrew Godwin2022-12-04 21:22:20 -0700
commit107c3d6cf8eaffedc6aee8057903a62f36346fb9 (patch)
treebdf662fe1d18db0f7530aa1e5b29a579e0237ce1 /activities/models
parent93ccb5dd32f4e3942d08814e5a86fb30c90c9ff6 (diff)
downloadtakahe-107c3d6cf8eaffedc6aee8057903a62f36346fb9.tar.gz
takahe-107c3d6cf8eaffedc6aee8057903a62f36346fb9.tar.bz2
takahe-107c3d6cf8eaffedc6aee8057903a62f36346fb9.zip
Fetch post parents live too
Diffstat (limited to 'activities/models')
-rw-r--r--activities/models/post.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/activities/models/post.py b/activities/models/post.py
index f8a5e75..ee1f393 100644
--- a/activities/models/post.py
+++ b/activities/models/post.py
@@ -15,7 +15,7 @@ from activities.models.hashtag import Hashtag
from core.html import sanitize_post, strip_html
from core.ld import canonicalise, format_ld_date, get_list, parse_ld_date
from stator.models import State, StateField, StateGraph, StatorModel
-from users.models.identity import Identity
+from users.models.identity import Identity, IdentityStates
from users.models.system_actor import SystemActor
@@ -625,11 +625,15 @@ class Post(StatorModel):
f"Error fetching post from {object_uri}: {response.status_code}",
{response.content},
)
- return cls.by_ap(
+ post = cls.by_ap(
canonicalise(response.json(), include_security=True),
create=True,
update=True,
)
+ # We may need to fetch the author too
+ if post.author.state == IdentityStates.outdated:
+ async_to_sync(post.author.fetch_actor)()
+ return post
else:
raise cls.DoesNotExist(f"Cannot find Post with URI {object_uri}")