get_group_msg_history was served only from the local observed-message store, so it could never return more than what SnowLuma saw live (the "only 100 messages" symptom). It now fetches real history from the server. - protocol: new SsoGetGroupMsg packet (trpc.msg.register_proxy.RegisterProxy .SsoGetGroupMsg, sequence-range fetch; fields per Lagrange). Each returned PushMsgBody is decoded by the existing group decoder via a factored-out buildContextFromMessage. - core: MessageApi.getGroupHistory walks backward in small sequence windows with rate-limiting + data-volume guards — a process-wide throttle (≥300ms between sends), 30-seq chunks, ≤12 requests, ≤200 messages per call — so a hammering client can't make us flood the server and get kicked. - onebot: get_group_msg_history resolves the anchor sequence (requested message_id or latest observed), fetches from the server, converts + returns, and persists each fetched message. Falls back to the local store on unknown anchor / empty / error. Persisting fetched history also fixes replying to pre-injection messages: the reply path resolves message_id→sequence via the store, which now contains the fetched messages. Tests: SsoGetGroupMsg request/response round-trip + decode reuse (protocol); walk-back chunking/dedup/cap/floor (core).
31 lines
1.1 KiB
TypeScript
31 lines
1.1 KiB
TypeScript
import type { pb, pb_repeated, uint_32, bool } from '@snowluma/proton';
|
|
import type { PushMsgBody } from './message';
|
|
|
|
// trpc.msg.register_proxy.RegisterProxy.SsoGetGroupMsg — fetch group message
|
|
// history from the server by sequence range. Reference: Lagrange.Core
|
|
// Internal/Service/Message/GetGroupMessageService.cs + Packets/Message/Action/
|
|
// SsoGetGroupMsg(.Response).cs. The response carries the same `PushMsgBody`
|
|
// shape as a live OlPush message, so the existing msg-push decoders parse it.
|
|
|
|
export interface SsoGetGroupMsgInfo {
|
|
groupUin?: pb<1, uint_32>;
|
|
startSequence?: pb<2, uint_32>;
|
|
endSequence?: pb<3, uint_32>;
|
|
}
|
|
|
|
export interface SsoGetGroupMsg {
|
|
info?: pb<1, SsoGetGroupMsgInfo>;
|
|
direction?: pb<2, bool>; // true (Lagrange hard-codes this)
|
|
}
|
|
|
|
export interface SsoGetGroupMsgResponseBody {
|
|
groupUin?: pb<3, uint_32>;
|
|
startSequence?: pb<4, uint_32>;
|
|
endSequence?: pb<5, uint_32>;
|
|
messages?: pb_repeated<6, PushMsgBody>;
|
|
}
|
|
|
|
export interface SsoGetGroupMsgResponse {
|
|
body?: pb<3, SsoGetGroupMsgResponseBody>;
|
|
}
|