mirror of
https://github.com/jointakahe/takahe.git
synced 2024-11-28 18:21:00 +00:00
Fixes various issues with pinned posts (#580)
This commit is contained in:
parent
5297b98273
commit
9bc18a1190
2 changed files with 15 additions and 4 deletions
|
@ -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():
|
||||||
|
|
|
@ -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():
|
||||||
|
|
Loading…
Reference in a new issue