New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix serialization of JSON-LD subarrays #2452
Conversation
(Disclaimer: I don't write python normally so please forgive me if this is a terrible solution of the problem and is not idiomatically correct) |
My python-foo is pretty bad and I can't seem to get tests to run locally, but I think I fixed it! |
@@ -194,6 +194,11 @@ def serialize(self, **kwargs): | |||
try: | |||
if issubclass(type(v), ActivityObject): | |||
data[k] = v.serialize() | |||
elif isinstance(v, list): | |||
data[k] = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Directly nested lists are not allowed in JSON-LD, so I think we should be alright!
Yay, looks like I figured the issue with failing tests without running them 😂 |
I'm seeing one issue with this -- the tag in a status with a mention goes from: "tag": [
{
"id": null,
"type": "Mention",
"href": "https://friend.camp/users/tripofmice",
"name": "tripofmice@friend.camp",
"mediaType": null,
"attributedTo": null,
"availability": null
},
... to "tag": [
{
"href": "https://friend.camp/users/tripofmice",
"name": "tripofmice@friend.camp"
},
... The |
@mouse-reeve oops! Again, I didn't get any better at Python, but I think this fix should do it. Let me know if I got it wrong! |
Properties like "tag" could be lists containing multiple subclasses of ActivityObject. Make sure to serialize them recursively instead of outputting them as they are, because otherwise we could get a bunch of nulls in the resulting JSON and that wouldn't necessarily be a valid JSON-LD object. Fix: bookwyrm-social#2451
(Lint fixed) |
Thank you for this! Seems to work just right :) |
Hooray! Thank you! |
Properties like "tag" could be lists containing multiple subclasses of ActivityObject. Make sure to serialize them recursively instead of outputting them as they are, because otherwise we could get a bunch of nulls in the resulting JSON and that wouldn't necessarily be a valid JSON-LD object.
Fix: #2451