mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-12-25 09:30:33 +00:00
fix incoming GTS mentions and DMs
GoToSocial sends 'tag' values as a single object if there is only one user mentioned, rather than an array with an object inside it. This causes Bookwyrm to reject the tag since it comes through as a dict rather than a list. This commit fixes this at the point the incoming AP object is transformed so that "mention" tags are turned into a mention_user.
This commit is contained in:
parent
c450947eee
commit
e3261c6b88
2 changed files with 9 additions and 5 deletions
|
@ -379,6 +379,11 @@ class TagField(ManyToManyField):
|
|||
|
||||
def field_from_activity(self, value, allow_external_connections=True):
|
||||
if not isinstance(value, list):
|
||||
# GoToSocial DMs and single-user mentions are
|
||||
# sent as objects, not as an array of objects
|
||||
if isinstance(value, dict):
|
||||
value = [value]
|
||||
else:
|
||||
return None
|
||||
items = []
|
||||
for link_json in value:
|
||||
|
|
|
@ -136,10 +136,9 @@ class Status(OrderedCollectionPageMixin, BookWyrmModel):
|
|||
# keep notes if they mention local users
|
||||
if activity.tag == MISSING or activity.tag is None:
|
||||
return True
|
||||
|
||||
# BUG: this fixes the TypeError but if there is only one user mentioned
|
||||
# we still don't get any notifs and DMs are dropped.
|
||||
tags = activity.tag if type(activity.tag) == list else [ activity.tag ]
|
||||
# GoToSocial sends single tags as objects
|
||||
# not wrapped in a list
|
||||
tags = activity.tag if isinstance(activity.tag, list) else [ activity.tag ]
|
||||
user_model = apps.get_model("bookwyrm.User", require_ready=True)
|
||||
for tag in tags:
|
||||
if (
|
||||
|
|
Loading…
Reference in a new issue