これは最近発生したバグではないかと思われます。私のクライアントは、素晴らしい Discourse チームが提供する Discourse as a Service を利用しています。ウェブサイト上でフォーラムの最新 5 件の投稿を一覧表示するために、/posts.json API エンドポイントを使用しています(https://forum.bonsaimirai.com/posts.json)。このリクエストはサーバーサイドで curl を使用して行っています。
最近、当社のサイトでは最新の投稿が 3 件または 4 件しか表示されていないことに気づきました。API キーなしでリクエストを行うと、この非常に短いリストしか取得できないようです。しかし、API キーと API ユーザー名を併用すると、より多くの投稿が表示されます。
/posts.json エンドポイントが以前と同様に動作してほしいと考えています。以前提供されていた件数の過去の投稿を取得できるはずです。API キーとユーザー名を使用すると、すべてのユーザーに表示したくない投稿(ユーザーティアまたはグループ制限があるカテゴリの投稿)まで取得されてしまいます。
posts.json リクエストに、取得したい結果数を指定するための新しいパラメータは追加されましたか?これは、ホストサービスで利用されている Discourse のバージョン固有のバグでしょうか?meta.discourse.org ではこの問題が発生していないことに気づきました。
That implies you may have special security that keeps some of the posts from being visible to anonymous users?
「いいね!」 1
@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
That feature already exists, include the API key of a user with the desired permissions.
「いいね!」 2
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