Fixes various issues with pinned posts (#580)

This commit is contained in:
Christof Dorner 2023-05-15 16:54:32 +00:00 committed by GitHub
parent 5297b98273
commit 9bc18a1190
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 4 deletions

View File

@ -760,11 +760,22 @@ class Identity(StatorModel):
try: try:
data = canonicalise(response.json(), include_security=True) data = canonicalise(response.json(), include_security=True)
items: list[dict | str] = []
if "orderedItems" in data: if "orderedItems" in data:
return [item["id"] for item in reversed(data["orderedItems"])] items = list(reversed(data["orderedItems"]))
elif "items" in data: elif "items" in data:
return [item["id"] for item in data["items"]] items = list(data["items"])
return []
ids = []
for item in items:
if not isinstance(item, dict):
continue
post_obj: dict | None = item
if item["type"] == "Create":
post_obj = item.get("object")
if post_obj:
ids.append(post_obj["id"])
return ids
except ValueError: except ValueError:
# Some servers return these with a 200 status code! # Some servers return these with a 200 status code!
if b"not found" in response.content.lower(): if b"not found" in response.content.lower():

View File

@ -185,7 +185,7 @@ class IdentityService:
} }
def sync_pins(self, object_uris): def sync_pins(self, object_uris):
if not object_uris: if not object_uris or self.identity.domain.blocked:
return return
with transaction.atomic(): with transaction.atomic():