fix: address read receipt pagination gaps in #41720

Closed
AL
2mo ago
+111-7

Proposed changes (including videos or screenshots)

This is an independent follow-up to #41720 for its unresolved pagination coverage gap.

  • Accept validated non-negative integer offset and count query parameters.
  • Forward pagination through the REST handler and read receipt retrieval path.
  • Apply Rocket.Chat's standard default count, upper limit, and infinite count policy when pagination is requested.
  • Paginate after hot and archived receipts are deduplicated, before resolving users.
  • Preserve the existing unpaginated response when neither parameter is supplied.
  • Add focused regression coverage for offset, count, user resolution, and unlimited count=0 behavior.

Issue(s)

Related to #41719.
Follow-up to #41720.

Steps to test or reproduce

  1. Call GET /api/v1/chat.getMessageReadReceipts with a valid messageId, offset, and count.
  2. Confirm offset shifts the receipt window and count limits it.
  3. Confirm negative or fractional pagination values are rejected.
  4. Confirm calls without pagination parameters still return the existing full receipt list.

Verified locally with:

  • corepack yarn exec mocha --config .mocharc.base.json ee/tests/unit/server/lib/message-read-receipt/ReadReceipt.spec.ts: 2 passing.
  • ESLint on all changed TypeScript files: passed.
  • corepack yarn workspace @rocket.chat/rest-typings typecheck: passed.
  • Focused schema smoke test: numeric query strings coerced; negative and fractional values rejected.
  • Prettier check on all changed files: passed.
  • git diff --check: passed.

The full Rocket.Chat unit, API, and end-to-end suites were not run.

Further comments

The regression was developed test-first. Before the implementation, the offset/count test returned all three receipts. A second red-green cycle caught the standard count=0 unlimited case.

Summary by CodeRabbit

  • New Features

    • Added optional offset and count pagination parameters to message read-receipt requests.
    • Retrieve specific receipt ranges while preserving existing behavior when pagination is omitted.
    • A count of 0 returns all receipts from the requested offset onward.
  • Bug Fixes

    • Added validation to ensure pagination values are non-negative integers.
  • Tests

    • Added coverage for offset and count pagination scenarios.