feat(talk): add getRecentMessagesV2 for single-call recent-message fetch - #213
Merged
Merged
Conversation
CHRLINE has always exposed getRecentMessagesV2(messageBoxId, messagesCount)
as a single-call way to get the most recent N messages from a chat, and it
is still supported on the server side. LINEJS currently only exposes
getPreviousMessagesV2WithRequest, which forces callers to first call
getMessageBoxes and dig out lastDeliveredMessageId before they can fetch
recent messages. This adds the direct API as a peer to WithRequest so
periodic-polling / initial-fetch tools do not need the extra round-trip.
- packages/types/thrift.ts: add getRecentMessagesV2_args (fid 2 string
messageBoxId, fid 3 i32 messagesCount) and _result (list<Message>
success + TalkException e). Struct definition matches
resources/line/chrline.thrift, which already declares this method.
- packages/types/line_types.ts: add matching interfaces.
- packages/linejs/base/thrift/readwrite/struct.ts: add getRecentMessagesV2_args
factory. Placed next to getPreviousMessagesV2WithRequest_args.
- packages/linejs/base/service/talk/mod.ts: add async getRecentMessagesV2 on
TalkService using the standard client.request.request pattern.
Verified end-to-end against a live LINE account: `client.base.talk
.getRecentMessagesV2({messageBoxId, messagesCount: 3})` returns 3 Message
objects with the same shape as getPreviousMessagesV2WithRequest.
Member
|
LGTME! |
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.
Description
Adds
TalkService.getRecentMessagesV2({messageBoxId, messagesCount})— thedirect LINE-server API for "give me the last N messages in this box". CHRLINE
has exposed this since forever and the server still honors it; the struct is
also already declared in
resources/line/chrline.thriftin this repo, justnever wired through to the runtime.
Today's LINEJS forces callers to first call
getMessageBoxes, dig outlastDeliveredMessageId, and then callgetPreviousMessagesV2WithRequestjust to fetch the most recent N messages (this is what
Chat.fetchMessagesdoes internally). That extra round-trip is unnecessary for polling loops,
initial-fetch tools, or anywhere the caller only cares about "the latest".
Wire format (
fid 2stringmessageBoxId,fid 3i32messagesCount,result
list<Message>atfid 0) is verified against a live LINE account:returns Message objects with the same shape as
getPreviousMessagesV2WithRequest.What changed
packages/types/thrift.ts— addedgetRecentMessagesV2_argsand_resultentries alongsidegetPreviousMessagesV2WithRequest_result.packages/types/line_types.ts— matching TypeScript interfaces.packages/linejs/base/thrift/readwrite/struct.ts— args factory,placed next to
getPreviousMessagesV2WithRequest_args.packages/linejs/base/service/talk/mod.ts—async getRecentMessagesV2method following the same
client.request.request(...)pattern used byevery other method on the service.
Usage:
Checklist
getPreviousMessagesV2WithRequest shape)
client.request.request)
and would only test the wire encoding