mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-22 11:58:08 +00:00
refactor(whatsapp): dedupe read receipt helper
This commit is contained in:
@@ -845,18 +845,7 @@ export async function attachWebInboxToSocket(
|
||||
}
|
||||
};
|
||||
|
||||
const maybeMarkReadReceiptAfterCompletedDelivery = async (
|
||||
inbound: NormalizedInboundMessage,
|
||||
target: WhatsAppReadReceiptTarget | undefined,
|
||||
) => {
|
||||
if (inbound.access.isSelfChat) {
|
||||
maybeLogSkippedSelfChatReadReceipt(inbound, target);
|
||||
return;
|
||||
}
|
||||
await maybeMarkInboundAsRead(target);
|
||||
};
|
||||
|
||||
const maybeMarkReadReceiptForSkippedAppend = async (
|
||||
const maybeMarkNonSelfChatReadReceipt = async (
|
||||
inbound: NormalizedInboundMessage,
|
||||
target: WhatsAppReadReceiptTarget | undefined,
|
||||
) => {
|
||||
@@ -921,7 +910,7 @@ export async function attachWebInboxToSocket(
|
||||
const deliveryReadReceipt = inbound.access.isSelfChat ? undefined : readReceipt;
|
||||
|
||||
if (!stored && shouldSkipStaleAppend(msg, upsertType)) {
|
||||
await maybeMarkReadReceiptForSkippedAppend(inbound, readReceipt);
|
||||
await maybeMarkNonSelfChatReadReceipt(inbound, readReceipt);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -948,7 +937,7 @@ export async function attachWebInboxToSocket(
|
||||
},
|
||||
);
|
||||
if (accepted.kind === "completed") {
|
||||
await maybeMarkReadReceiptAfterCompletedDelivery(
|
||||
await maybeMarkNonSelfChatReadReceipt(
|
||||
inbound,
|
||||
accepted.record.metadata?.readReceipt ?? deliveryReadReceipt,
|
||||
);
|
||||
@@ -973,7 +962,7 @@ export async function attachWebInboxToSocket(
|
||||
const enriched = await enrichInboundMessage(msg);
|
||||
if (!enriched) {
|
||||
await completeUndeliverableDurableInbound(durableId, durableMetadata);
|
||||
await maybeMarkReadReceiptAfterCompletedDelivery(inbound, deliveryReadReceipt);
|
||||
await maybeMarkNonSelfChatReadReceipt(inbound, deliveryReadReceipt);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -982,7 +971,7 @@ export async function attachWebInboxToSocket(
|
||||
if (dedupeClaim !== "claimed") {
|
||||
if (dedupeClaim === "duplicate") {
|
||||
await completeUndeliverableDurableInbound(durableId, durableMetadata);
|
||||
await maybeMarkReadReceiptAfterCompletedDelivery(inbound, deliveryReadReceipt);
|
||||
await maybeMarkNonSelfChatReadReceipt(inbound, deliveryReadReceipt);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user