Creo que este es un error reciente que surgió. Mi cliente utiliza Discourse como servicio alojado por el excelente equipo de Discourse. Usamos el punto final de la API /posts.json para listar las 5 publicaciones más recientes del foro en el sitio web (https://forum.bonsaimirai.com/posts.json). Realizamos esta solicitud del lado del servidor usando curl.
Recientemente, notamos que solo veíamos 3 o 4 de las publicaciones más recientes en nuestro sitio. Parece que cuando se realiza la solicitud sin una clave de API, terminamos viendo esta lista muy corta de publicaciones recientes. Pero cuando usamos la clave de API con un nombre de usuario de API, vemos una mayor cantidad de publicaciones.
Queremos que el punto final /posts.json se comporte como antes. Deberíamos poder obtener cualquier número de publicaciones anteriores que solía entregar. Si usamos la clave de API + nombre de usuario, terminamos recuperando publicaciones que no queremos mostrar a todos los usuarios (de categorías con restricciones de nivel de usuario o grupo).
¿Hay nuevos parámetros disponibles para la solicitud posts.json que podamos usar para especificar el número deseado de resultados? ¿Es este un error único de la versión de Discourse que se utiliza para el servicio alojado? Observo que meta.discourse.org no presenta este problema.
That implies you may have special security that keeps some of the posts from being visible to anonymous users?
@codinghorror I think I just realized why this is happening. We do have a category on our forum that is restricted to a special group of paying users on our main site. Anonymous / “normal” logged in users can’t access this category.
I’m going to guess that if a single topic in that special category contains some large number of the most recent posts to the site, then they’re simply omitted from the posts.json endpoint for anonymous users. And thus, we exceed whatever the behind-the-scenes limit is for that endpoint. So we end up getting the truncated list that I’m seeing in this specific moment in time when requesting that feed anonymously.
Am I on to something here?
This is probably an edge case. But does it make sense to make a feature request for that endpoint so that it always returns the X number of most recent posts, relevant to whatever level of permissions the request is being made from?
That feature already exists, include the API key of a user with the desired permissions.
Thanks @codinghorror.
This is exactly what I’ve done. I make a request for the /posts.json using my API key with a “dummy” user possessing the desired permissions since not all members of our website have created accounts on the forum yet.
Everything is working as expected.