Fixes various issues with pinned posts - continued (#581)

This commit is contained in:
Christof Dorner 2023-05-15 17:36:33 +00:00 committed by GitHub
parent b2768e7f2e
commit cec04e8ddb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 8 deletions

View file

@ -771,7 +771,7 @@ class Identity(StatorModel):
if not isinstance(item, dict):
continue
post_obj: dict | None = item
if item["type"] == "Create":
if item["type"] in ["Create", "Update"]:
post_obj = item.get("object")
if post_obj:
ids.append(post_obj["id"])

View file

@ -190,13 +190,17 @@ class IdentityService:
with transaction.atomic():
for object_uri in object_uris:
post = Post.by_object_uri(object_uri, fetch=True)
PostInteraction.objects.get_or_create(
type=PostInteraction.Types.pin,
identity=self.identity,
post=post,
state__in=PostInteractionStates.group_active(),
)
try:
post = Post.by_object_uri(object_uri, fetch=True)
PostInteraction.objects.get_or_create(
type=PostInteraction.Types.pin,
identity=self.identity,
post=post,
state__in=PostInteractionStates.group_active(),
)
except Post.DoesNotExist:
# ignore 404s...
pass
for removed in PostInteraction.objects.filter(
type=PostInteraction.Types.pin,
identity=self.identity,