this post was submitted on 14 Jul 2023
64 points (98.5% liked)

Fediverse

27517 readers
752 users here now

A community to talk about the Fediverse and all it's related services using ActivityPub (Mastodon, Lemmy, KBin, etc).

If you wanted to get help with moderating your own community then head over to [email protected]!

Rules

Learn more at these websites: Join The Fediverse Wiki, Fediverse.info, Wikipedia Page, The Federation Info (Stats), FediDB (Stats), Sub Rehab (Reddit Migration), Search Lemmy

founded 1 year ago
MODERATORS
 

I'm trying to figure out how to get the comments of a post given a link to it using ActivityPub.

Based on reading the ActivityPub spec, I thought comments were federated via the replies key of the ActivityPub Object.

This works for Mastodon posts, but not for Lemmy (nor Pleroma). As an example

curl -H "Accept: application/activity+json" https://lemmy.my.id/post/79514 | jq

doesn't contain a replies key. Yet the comments are federated to Mastodon somehow.

What is going on? How can I get the comment?

you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 0 points 1 year ago (2 children)

You can see the hierarchy above not below.

You might get a like. It looks like:

like: [
    "id" => "https://lemmy.one/activities/like/7d0ef24f-755f-48dd-9b37-ea42041cb34e",
    "actor" => "https://lemmy.one/u/Matt",
    "object" => "https://lemmy.procrastinati.org/comment/146844",
    "type" => "Like",
    "audience" => "https://lemdro.id/c/android"
]

In the object property you see the comment. If you visit that you'll get among the rest of the json for the comment

"inReplyTo": "https://lemmy.world/comment/1269475",

And again

"inReplyTo": "https://lemdro.id/post/77457",

Now you have the hierarchy from the like's comment to the post. Not the rest of the tree, enough to render the comment in context though.

[–] [email protected] 1 points 1 year ago (1 children)

I understand exactly what you're saying; you can get the parents but not the replies in that situation.

I'm just saying that in your situation (e.g. someone I follow on Mastodon likes a Lemmy post) it would be convenient for me as a user to be able to view the replies to that Lemmy post, but I cannot necessarily do that because Lemmy does not include replies.

[–] [email protected] 0 points 1 year ago

I expect it does, from the lemmy API. But from the ActivityPub api, it doesn't make sense to.

[–] [email protected] 1 points 1 year ago

Hi there! Looks like you linked to a Lemmy community using a URL instead of its name, which doesn't work well for people on different instances. Try fixing it like this: [email protected]