Skip to content

feat(talk): add getRecentMessagesV2 for single-call recent-message fetch - #213

Merged
EdamAme-x merged 1 commit into
evex-dev:mainfrom
enkunkun:feat/talk-get-recent-messages
Jul 23, 2026
Merged

feat(talk): add getRecentMessagesV2 for single-call recent-message fetch#213
EdamAme-x merged 1 commit into
evex-dev:mainfrom
enkunkun:feat/talk-get-recent-messages

Conversation

@enkunkun

@enkunkun enkunkun commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Description

Adds TalkService.getRecentMessagesV2({messageBoxId, messagesCount}) — the
direct 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.thrift in this repo, just
never wired through to the runtime.

Today's LINEJS forces callers to first call getMessageBoxes, dig out
lastDeliveredMessageId, and then call getPreviousMessagesV2WithRequest
just to fetch the most recent N messages (this is what Chat.fetchMessages
does 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 2 string messageBoxId, fid 3 i32 messagesCount,
result list<Message> at fid 0) is verified against a live LINE account:
returns Message objects with the same shape as getPreviousMessagesV2WithRequest.

What changed

  • packages/types/thrift.ts — added getRecentMessagesV2_args and
    _result entries alongside getPreviousMessagesV2WithRequest_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.tsasync getRecentMessagesV2
    method following the same client.request.request(...) pattern used by
    every other method on the service.

Usage:

const messages = await client.base.talk.getRecentMessagesV2({
  messageBoxId: "u...",
  messagesCount: 100,
});

Checklist

  • Verified against live LINE (returns Message[] matching
    getPreviousMessagesV2WithRequest shape)
  • Follows existing TalkService method pattern (LINEStruct factory +
    client.request.request)
  • No new tests — the method is a thin wrapper over an existing pattern
    and would only test the wire encoding

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.
@EdamAme-x
EdamAme-x merged commit b015243 into evex-dev:main Jul 23, 2026
2 checks passed
@EdamAme-x

Copy link
Copy Markdown
Member

LGTME!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants