Fixes various issues with pinned posts - continued (#581)
This commit is contained in:
parent
b2768e7f2e
commit
cec04e8ddb
|
@ -771,7 +771,7 @@ class Identity(StatorModel):
|
||||||
if not isinstance(item, dict):
|
if not isinstance(item, dict):
|
||||||
continue
|
continue
|
||||||
post_obj: dict | None = item
|
post_obj: dict | None = item
|
||||||
if item["type"] == "Create":
|
if item["type"] in ["Create", "Update"]:
|
||||||
post_obj = item.get("object")
|
post_obj = item.get("object")
|
||||||
if post_obj:
|
if post_obj:
|
||||||
ids.append(post_obj["id"])
|
ids.append(post_obj["id"])
|
||||||
|
|
|
@ -190,13 +190,17 @@ class IdentityService:
|
||||||
|
|
||||||
with transaction.atomic():
|
with transaction.atomic():
|
||||||
for object_uri in object_uris:
|
for object_uri in object_uris:
|
||||||
post = Post.by_object_uri(object_uri, fetch=True)
|
try:
|
||||||
PostInteraction.objects.get_or_create(
|
post = Post.by_object_uri(object_uri, fetch=True)
|
||||||
type=PostInteraction.Types.pin,
|
PostInteraction.objects.get_or_create(
|
||||||
identity=self.identity,
|
type=PostInteraction.Types.pin,
|
||||||
post=post,
|
identity=self.identity,
|
||||||
state__in=PostInteractionStates.group_active(),
|
post=post,
|
||||||
)
|
state__in=PostInteractionStates.group_active(),
|
||||||
|
)
|
||||||
|
except Post.DoesNotExist:
|
||||||
|
# ignore 404s...
|
||||||
|
pass
|
||||||
for removed in PostInteraction.objects.filter(
|
for removed in PostInteraction.objects.filter(
|
||||||
type=PostInteraction.Types.pin,
|
type=PostInteraction.Types.pin,
|
||||||
identity=self.identity,
|
identity=self.identity,
|
||||||
|
|
Loading…
Reference in New Issue