From 9bc18a1190010a0ae435111f90646e047df8b756 Mon Sep 17 00:00:00 2001 From: Christof Dorner Date: Mon, 15 May 2023 16:54:32 +0000 Subject: [PATCH] Fixes various issues with pinned posts (#580) --- users/models/identity.py | 17 ++++++++++++++--- users/services/identity.py | 2 +- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/users/models/identity.py b/users/models/identity.py index c16629f..575dee0 100644 --- a/users/models/identity.py +++ b/users/models/identity.py @@ -760,11 +760,22 @@ class Identity(StatorModel): try: data = canonicalise(response.json(), include_security=True) + items: list[dict | str] = [] if "orderedItems" in data: - return [item["id"] for item in reversed(data["orderedItems"])] + items = list(reversed(data["orderedItems"])) elif "items" in data: - return [item["id"] for item in data["items"]] - return [] + items = list(data["items"]) + + 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: # Some servers return these with a 200 status code! if b"not found" in response.content.lower(): diff --git a/users/services/identity.py b/users/services/identity.py index 3ee0195..2b3427b 100644 --- a/users/services/identity.py +++ b/users/services/identity.py @@ -185,7 +185,7 @@ class IdentityService: } def sync_pins(self, object_uris): - if not object_uris: + if not object_uris or self.identity.domain.blocked: return with transaction.atomic():