Fall post URLs back to their ID

Fixes #302
This commit is contained in:
Andrew Godwin 2022-12-28 11:12:40 -07:00
parent a3b6996413
commit e38e985e73
2 changed files with 2 additions and 4 deletions

View File

@ -708,7 +708,7 @@ class Post(StatorModel):
raise ValueError("Post has no content or content map") raise ValueError("Post has no content or content map")
post.summary = data.get("summary") post.summary = data.get("summary")
post.sensitive = data.get("sensitive", False) post.sensitive = data.get("sensitive", False)
post.url = data.get("url") post.url = data.get("url", data["id"])
post.published = parse_ld_date(data.get("published")) post.published = parse_ld_date(data.get("published"))
post.edited = parse_ld_date(data.get("updated")) post.edited = parse_ld_date(data.get("updated"))
post.in_reply_to = data.get("inReplyTo") post.in_reply_to = data.get("inReplyTo")

View File

@ -83,13 +83,11 @@ class SearchService:
type = document.get("type", "unknown").lower() type = document.get("type", "unknown").lower()
# Is it an identity? # Is it an identity?
print(type)
if type in Identity.ACTOR_TYPES: if type in Identity.ACTOR_TYPES:
# Try and retrieve the profile by actor URI # Try and retrieve the profile by actor URI
identity = Identity.by_actor_uri(document["id"], create=True) identity = Identity.by_actor_uri(document["id"], create=True)
print("got identity")
if identity and identity.state == IdentityStates.outdated: if identity and identity.state == IdentityStates.outdated:
print(async_to_sync(identity.fetch_actor)()) async_to_sync(identity.fetch_actor)()
return identity return identity
# Is it a post? # Is it a post?