WhatsApp: mark offline/history messages as read
This commit is contained in:
@@ -842,3 +842,39 @@ it("defaults to self-only when no config is present", async () => {
|
||||
|
||||
await listener.close();
|
||||
});
|
||||
|
||||
it("handles append messages by marking them read but skipping auto-reply", async () => {
|
||||
const onMessage = vi.fn();
|
||||
const listener = await monitorWebInbox({ verbose: false, onMessage });
|
||||
const sock = await createWaSocket();
|
||||
|
||||
const upsert = {
|
||||
type: "append",
|
||||
messages: [
|
||||
{
|
||||
key: { id: "history1", fromMe: false, remoteJid: "999@s.whatsapp.net" },
|
||||
message: { conversation: "old message" },
|
||||
messageTimestamp: 1_700_000_000,
|
||||
pushName: "History Sender",
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
sock.ev.emit("messages.upsert", upsert);
|
||||
await new Promise((resolve) => setImmediate(resolve));
|
||||
|
||||
// Verify it WAS marked as read
|
||||
expect(sock.readMessages).toHaveBeenCalledWith([
|
||||
{
|
||||
remoteJid: "999@s.whatsapp.net",
|
||||
id: "history1",
|
||||
participant: undefined,
|
||||
fromMe: false,
|
||||
},
|
||||
]);
|
||||
|
||||
// Verify it WAS NOT passed to onMessage
|
||||
expect(onMessage).not.toHaveBeenCalled();
|
||||
|
||||
await listener.close();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user