Chat API: page_size parameter is ignored when direction=past

I’m reporting a bug with the Discourse Chat plugin’s API. When querying for past chat messages, the page_size parameter is ignored, and the endpoint always returns the maximum number of messages.

Steps to Reproduce:

  1. Make an API call to the chat messages endpoint (e.g., /chat/{channel_id}/messages.json).

  2. Use the following parameters in the request:

    • target_message_id: [ID of a recent message]

    • direction: past

    • page_size: 5 (or any number less than 50)

Expected Behavior: The API should return a JSON object containing a maximum of 5 messages that were sent before the specified target_message_id.

Actual Behavior: The API returns 50 messages, ignoring the page_size=5 parameter. It appears to be hardcoded to the maximum page size in this scenario.

Thanks for looking into this!