feat(onebot): fetch real private (c2c) history from server (#99)

Mirror the group-history fetch for private chats via SsoGetC2cMsg
(trpc.msg.register_proxy.RegisterProxy.SsoGetC2cMsg, fields per Lagrange:
flat friendUid/start/end request, messages@7 response). get_friend_msg_history
now resolves the anchor sequence + the friend's UID, fetches real history from
the server, converts + persists each message, and falls back to the local
store on unknown anchor / no uid / empty / error.

- protocol: fetchC2cMessageRange (decodes via the friend decoder).
- core: the group + c2c fetch now share a generic walkBackHistory loop
  (same throttle gate + caps); added MessageApi.getC2cHistory.
- onebot: getFriendHistory + a generalized persistHistoryEvent (keys private
  by sender uin, exactly like the live path — so reply to old private
  messages resolves too).

Tests: SsoGetC2cMsg request/response round-trip + friend-decode reuse.
This commit is contained in:
DrSmoothl committed 2026-06-14 20:15:38 +08:00
1 parent 987ac09896
commit 58c02d415f
9 files changed
+288 -41

No files matched your search

+2 -2
View File
@@ -26,7 +26,7 @@ import {
deleteMessage,
forwardSingleMessage,
getForwardMessage,
getFriendMsgHistory,
getFriendHistory,
getGroupHistory,
sendGroupForwardMessage,
sendGroupMessage,
@@ -77,7 +77,7 @@ export function buildApiContext(ref: OneBotInstanceContext): ApiActionContext {
getGroupFiles: (groupId, folderId) => getGroupFiles(bridge, groupId, folderId),
handleGroupRequest: (flag, _subType, approve, reason) => handleGroupAddRequest(bridge, flag, approve, reason),
getGroupMsgHistory: (groupId, messageId, count) => getGroupHistory(ref, groupId, messageId, count),
getFriendMsgHistory: (userId, messageId, count) => getFriendMsgHistory(messageStore, userId, messageId, count),
getFriendMsgHistory: (userId, messageId, count) => getFriendHistory(ref, userId, messageId, count),
handleGetGroupSystemMsg: () => getGroupSystemMessages(bridge),
getDownloadRKeys: () => getDownloadRKeys(bridge),
sendGroupForwardMsg: (groupId, messages, meta) => sendGroupForwardMessage(ref, groupId, messages, meta),