mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-26 11:31:08 +00:00
Allow for tag value to be object
Previously the 'tag' value in an activitypub object was assumed to be a List (array). Some AP software sends 'tag' as a Dict (object) if there is only a single tag value. It's somewhat debatable whether this is spec compliant but we should aim to be robust. This commit puts an individual mention tag inside a list if necessary.
This commit is contained in:
parent
e112718d2d
commit
ef85394a16
1 changed files with 8 additions and 2 deletions
|
@ -136,10 +136,16 @@ class Status(OrderedCollectionPageMixin, BookWyrmModel):
|
|||
# keep notes if they mention local users
|
||||
if activity.tag == MISSING or activity.tag is None:
|
||||
return True
|
||||
tags = [l["href"] for l in activity.tag if l["type"] == "Mention"]
|
||||
|
||||
tags = activity.tag if type(activity.tag) == list else [activity.tag]
|
||||
user_model = apps.get_model("bookwyrm.User", require_ready=True)
|
||||
for tag in tags:
|
||||
if user_model.objects.filter(remote_id=tag, local=True).exists():
|
||||
if (
|
||||
tag["type"] == "Mention"
|
||||
and user_model.objects.filter(
|
||||
remote_id=tag["href"], local=True
|
||||
).exists()
|
||||
):
|
||||
# we found a mention of a known use boost
|
||||
return False
|
||||
return True
|
||||
|
|
Loading…
Reference in a new issue