fix: fetchMessages REST shape + streaming truncation; feat: onReaction (v0.3.0) - #4
Merged
Merged
Conversation
…n support (v0.3.0) Three fixes reported via support (Crisp) + GitHub issue #3: 1. fetchMessages threw "Cannot read properties of undefined (reading 'id')". The REST GET /messages endpoint returns a flat shape (senderId/message/ createdAt) but parseMessage expected the webhook shape (sender.id/text/ sentAt). Added restToRawMessage() to normalize either shape. Also forward the previously-dropped FetchOptions (limit/cursor/direction) and wire nextCursor from pagination. The old test masked the bug by mocking the webhook shape; fixed the fixture and added regression tests. 2. thread.post(stream) only delivered the first chunk on non-Telegram platforms: stream() posted chunk 1 then editMessage'd the rest, but only Telegram supports edits so every edit threw silently. Now detect the platform via fetchThread: Telegram keeps live edit-streaming, all others buffer the full response and post once (post-once on detection failure). 3. onReaction never fired: reactions arrived as message.received and routed to onDirectMessage. Route the new reaction.received webhook event to chat.processReaction with the emoji normalized to an EmojiValue. 84 tests pass, tsc clean. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Three fixes reported via support (Crisp ticket) + GitHub issue #3.
1.
fetchMessagesthrewCannot read properties of undefined (reading 'id')(#3)The REST
GET /messagesendpoint returns a flat message shape (senderId/message/createdAt), butparseMessage()was written for the webhook shape (sender.id/text/sentAt), soraw.sender.iddereferencedundefined.restToRawMessage()to normalize either shape before parsing.FetchOptions(limit/cursor/direction) to the REST endpoint, and wirenextCursorfrompagination.nextCursor(was hardcodedundefined).makeRawMessage(). Fixed the fixture (makeRestMessage) and added regression tests for the real shape, options forwarding, desc→chronological ordering, and pagination.2.
thread.post(stream)only delivered the first chunk on non-Telegram platformsstream()posted chunk 1 theneditMessaged the rest, but only Telegram supports edits, so on WhatsApp/IG/FB/X/Bluesky/Reddit every edit threw (silently caught) and the recipient saw only the first chunk.fetchThread: Telegram keeps live edit-streaming; everyone else buffers the full response and posts once. Falls back to post-once if detection fails.3.
onReactionnever firedReactions arrived as
message.receivedand were routed toonDirectMessage. Now route the newreaction.receivedwebhook event (see Schedule-Posts-API PR) tochat.processReaction, normalizing the raw unicode emoji to anEmojiValueviadefaultEmojiResolver.fromGChat.Verification
npm test),tsc --noEmitclean.Release / consumer notes
v*tag push after merge.reaction.receivedwebhook event.Depends on: zernio-dev/Schedule-Posts-API
feat/reaction-received-webhook(thereaction.receivedevent).🤖 Generated with Claude Code