نقطة نهاية واجهة برمجة التطبيقات /posts.json لا تعرض أكثر من 4 منشورات

أعتقد أن هذه مشكلة حديثة ظهرت. عميلي يستخدم خدمة Discourse المستضافة من فريق Discourse اللطيف. نستخدم نقطة نهاية API /posts.json لعرض آخر 5 منشورات من المنتدى على موقعنا (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?

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