Skip to content

fix(channel): read reactions from the reactions endpoint - #16

Merged
mikield merged 1 commit into
masterfrom
fix/get-reactions-endpoint
Sep 2, 2026
Merged

mikield merged 1 commit into
masterfrom
fix/get-reactions-endpoint

Conversation

@mikield

@mikield mikield commented Sep 2, 2026

Copy link
Copy Markdown
Member

getReactions() bound the wrong endpoint constant:

Endpoint::bind(
    Endpoint::CHANNEL_MESSAGES,   // channels/:channel_id  — one slot
    $channelId,
    $messageId,
    (string) $emoji,              // ← both dropped on the floor
)

The bound URL is channels/:channel_id/messages. So the call fetched the channel's most recent messages and mapped them into User objects. No error, no empty result — a plausible-looking list of users that has nothing to do with who reacted.

getReactions binds: channels/CH/messages
should be:          channels/CH/messages/MSG/reactions/EMOJI

Why the test did not catch it

HttpHelperTestCase mocks Http::get() with no argument expectations and asserts only the return type. Nothing in the REST suite checks which endpoint a method actually called, so a method can bind any constant at all and still pass.

The harness now captures the requested URL and asserts it when a case supplies one:

'validationOptions' => [
    'returnType' => User::class,
    'array' => true,
    'url' => 'channels/::channel id::/messages/::message id::/reactions/%3A%3Aid%3A%3A',
]

Opt-in, so this PR stays about the bug, but it is worth backfilling across the suite — this is the third method in this repo found to have never worked, and the first two were also invisible for want of an assertion someone assumed was there.

Found while porting a bot that reads back petition votes on start-up to catch up on what it missed while it was down.

🤖 Generated with Claude Code

getReactions() bound Endpoint::CHANNEL_MESSAGES, which has one slot, with
a channel, a message and an emoji. The message and the emoji were
dropped, so the call went to channels/:id/messages and came back with the
channel's last messages mapped into User objects — never the reactions,
and never an error either.

The test asserted only the return type. Nothing here checked which
endpoint a method reached, which is how a method could bind the wrong
constant and still pass; the harness now takes an optional url to assert
against, filled in for this one and worth filling in elsewhere.
@mikield
mikield merged commit dabcac0 into master Sep 2, 2026
4 checks passed
@mikield
mikield deleted the fix/get-reactions-endpoint branch September 2, 2026 02:33
github-actions Bot pushed a commit that referenced this pull request Sep 2, 2026
## [1.3.3](v1.3.2...v1.3.3) (2026-09-02)

### Bug Fixes

* **channel:** read reactions from the reactions endpoint ([#16](#16)) ([dabcac0](dabcac0))
@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown

🎉 This PR is included in version 1.3.3 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant