ePascalC / bbp-API

An API for bbPress
15 stars 6 forks source link

Threaded replies #25

Open ePascalC opened 7 years ago

ePascalC commented 7 years ago

Currently all replies come in a flat list. Check out the bbp_walker_reply to have the threaded list to see the replies to replies in a structured way.

As a first, add the 'reply_to' in the JSON output.

ePascalC commented 7 years ago

reply_to added in v1.0.14

renatonascalves commented 7 years ago

Hey man! Why aren't you commiting and closing in git for better history?

ePascalC commented 7 years ago

@renatonascalves I'm so used to svn on w.org, I have my test environment linked to trunk there, so I never invested time to look here how add GitHub in the loop of my current way of working. I just update the files when I have a new version but indeed there is no link between the specific Issue and the specific commit for it. Any help on how to proceed, not breaking too much my current way of working is accepted :-)

renatonascalves commented 7 years ago

@ePascalC I can help with that! Gonna talk to you on Slack as this is not related to the issue here. :)

tkserver commented 7 years ago

I'm thinking of starting up on threaded replies now. Have you looked at this idea recently? I may be able to use my own walker class to create a threaded API for topics/replies.

tkserver commented 7 years ago

Hey @renatonascalves if you want a challenge try threaded replies here. The bbp api returns replies flat, not threaded. IF the replies were embedded within their parent, a walker or recursion could be used to make a threaded view. Otherwise there would have to be a ton of logic to make it happen, and paging won't work. I've started to look at this, but not sure I can/want to dedicate the time to do it right now.

renatonascalves commented 7 years ago

@tkserver Let me see if I get this correctly. You have a topic. This topic has replies. And some of those replies have other replies in it. You want to fetch the replies and their replies in it.

Something like this:

{
    "id": 8523,
    "title": "Responder a: Never let me down",
    "permalink": "http://b.dev/sala/resposta/8523/",
    "topic_id": 7612,
    "topic_title": "Never let me down",
    "forum_id": 6153,
    "tags": "",
    "content": "<p>Thanks! 😀</p>\n",
    "reply_to": "id of reply or list of ids with replies"
}
renatonascalves commented 7 years ago

By the way, I think wp-json/bbp-api/v1/replies/ is not working correctly. It's not returning the replies even though there are replies to return.

I still need to confirm that.

tkserver commented 7 years ago

Have a look at this home page to see how the threading would work: https://www.utehub.com

I hacked up the bbpress walker to create this.

renatonascalves commented 7 years ago

I tried here: https://www.utehub.com/wp-json/bbp-api/v1/replies/

Nothing! Am I getting in the wrong slug/namespace?

tkserver commented 7 years ago

I don't use the replies endpoint since replies are embedded in the topics. But I think the way it works is replies to replies: https://www.utehub.com/wp-json/bbp-api/v1/replies/41220

tkserver commented 7 years ago

Have you looked at how the posts and replies look on the www version I posted?

renatonascalves commented 7 years ago

In the front-page of your website there is a reply: 412010.

I don't the replies of the replies in the output. :/

tkserver commented 7 years ago

Yeah, it only seems to be replies to replies.