L'endpoint API /posts.json non elenca più di 4 post

Credo che si tratti di un bug recente emerso. Il mio cliente utilizza Discourse come servizio ospitato dalla gentile squadra di Discourse. Usiamo l’endpoint API /posts.json per elencare i 5 post più recenti del forum sul sito web (https://forum.bonsaimirai.com/posts.json). Eseguiamo questa richiesta lato server utilizzando curl.

Di recente, abbiamo notato che vedevamo solo 3 o 4 dei post più recenti sul nostro sito. Sembra che quando la richiesta viene effettuata senza una chiave API, otteniamo questa lista molto corta di post recenti. Ma quando usiamo la chiave API con un nome utente API, vediamo un numero maggiore di post.

Vogliamo che l’endpoint /posts.json si comporti come prima. Dovremmo essere in grado di ottenere qualsiasi numero di post precedenti come faceva in passato. Se usiamo la chiave API + nome utente, finiamo per recuperare post che non vogliamo mostrare a tutti gli utenti (da categorie con restrizioni per livello utente/gruppo).

Ci sono nuovi parametri disponibili per la richiesta posts.json che possiamo usare per specificare il numero desiderato di risultati? Si tratta di un bug unico alla versione di Discourse utilizzata per il servizio ospitato? Noto che meta.discourse.org non presenta questo problema.

That implies you may have special security that keeps some of the posts from being visible to anonymous users?

1 Mi Piace

@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?

2 Mi Piace

That feature already exists, include the API key of a user with the desired permissions.

2 Mi Piace

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.

3 Mi Piace