fix(core): verify conversation read updates
Replace message-header sequence forwarding with a server-guided read flow for group and private conversations. Batch read reports conservatively, validate per-conversation results and cursor advancement, and fail with actionable errors when the server does not apply an update. Add regression coverage for mixed batches, pagination, already-current sessions, malformed responses, and private sequence-domain mismatches.
This commit is contained in:
5 files changed
+456
-51
No files matched your search
@@ -289,6 +289,34 @@ describe('extended-actions / history accepts negative message_id', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('extended-actions / mark conversation read', () => {
|
||||
it('uses a group message only to identify the conversation', async () => {
|
||||
const markGroupRead = vi.fn(async () => undefined);
|
||||
const bridge = fakeBridge({ apis: { message: { markGroupRead } } });
|
||||
const ctx = fakeCtx(bridge, {
|
||||
getMessageMeta: () => fakeMeta({ targetId: 12345, sequence: 42708 }),
|
||||
});
|
||||
|
||||
const res = await makeHandler(ctx).handle('mark_group_msg_as_read', { message_id: 1 });
|
||||
|
||||
expect(markGroupRead).toHaveBeenCalledWith(12345);
|
||||
expect(res).toMatchObject({ status: 'ok', retcode: 0 });
|
||||
});
|
||||
|
||||
it('routes a private message to the C2C read implementation without forwarding its header sequence', async () => {
|
||||
const markPrivateRead = vi.fn(async () => undefined);
|
||||
const bridge = fakeBridge({ apis: { message: { markPrivateRead } } });
|
||||
const ctx = fakeCtx(bridge, {
|
||||
getMessageMeta: () => fakeMeta({ isGroup: false, targetId: 1787882683, sequence: 42708 }),
|
||||
});
|
||||
|
||||
const res = await makeHandler(ctx).handle('mark_private_msg_as_read', { message_id: 1 });
|
||||
|
||||
expect(markPrivateRead).toHaveBeenCalledWith(1787882683);
|
||||
expect(res).toMatchObject({ status: 'ok', retcode: 0 });
|
||||
});
|
||||
});
|
||||
|
||||
// ─── Tier 1: nc_get_packet_status / nc_get_rkey ───
|
||||
|
||||
describe('extended-actions / nc_get_packet_status', () => {
|
||||
|
||||
Reference in new issue
Block a user