refactor(protocol): keep Decoder a pure parse of MsgPush events
Decoder used to write Identity: decodeGroupAdmin patched member roles and decodeFriendMessage stashed invite-card msgseq. That split observation with IncomingPacketPipeline.rememberEventIdentity and put pending-application state on Identity. Decoder now only returns events. Invite-card groupUin/msgseq ride on FriendMessage; the live pipeline writes them to ContactsApi through an optional port. Role self-heal for #93 stays in rememberEventIdentity. History and forward decode do not write. Identity no longer stores invite-card sequences. Live #93 and #125 behavior is unchanged.
This commit is contained in:
12 files changed
+148
-79
No files matched your search
@@ -171,38 +171,38 @@ describe('fetchC2cMessageRange / SsoGetC2cMsg', () => {
|
||||
)).rejects.toThrow('friend uid mismatch');
|
||||
});
|
||||
|
||||
it('does not replay live-only invite observations from older history', async () => {
|
||||
const remembered: Array<[number, number]> = [];
|
||||
const observingIdentity = {
|
||||
findFriend: () => undefined,
|
||||
rememberGroupInviteCardSequence: (groupUin: number, sequence: number) => {
|
||||
remembered.push([groupUin, sequence]);
|
||||
},
|
||||
} as unknown as IdentityService;
|
||||
|
||||
it('parses invite-card facts on friend messages without writing Identity', async () => {
|
||||
const live = buildContextFromMessage(
|
||||
inviteCardMessage(222),
|
||||
10001,
|
||||
observingIdentity,
|
||||
identity,
|
||||
false,
|
||||
);
|
||||
expect(live).not.toBeNull();
|
||||
decodeFriendMessage(live!);
|
||||
expect(decodeFriendMessage(live!)).toMatchObject([{
|
||||
kind: 'friend_message',
|
||||
inviteCardGroupUin: 12345,
|
||||
inviteCardSequence: 222,
|
||||
}]);
|
||||
|
||||
const historyResponse = protobuf_encode<SsoGetC2cMsgResponse>({
|
||||
friendUid: 'u_friend',
|
||||
messages: [inviteCardMessage(111)],
|
||||
});
|
||||
await fetchC2cMessageRange(
|
||||
const out = await fetchC2cMessageRange(
|
||||
{ sendRawPacket: async () => okResult(historyResponse) },
|
||||
observingIdentity,
|
||||
identity,
|
||||
10001,
|
||||
'u_friend',
|
||||
100,
|
||||
120,
|
||||
);
|
||||
|
||||
expect(remembered).toEqual([[12345, 222]]);
|
||||
expect(out).toMatchObject([{
|
||||
kind: 'friend_message',
|
||||
inviteCardGroupUin: 12345,
|
||||
inviteCardSequence: 111,
|
||||
}]);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user