

























@@ -61,6 +61,7 @@ import {
6161} from "./durable-receive.js";
6262import {
6363describeReplyContext,
64+extractExternalAdReplyContext,
6465extractLocationData,
6566extractContactContext,
6667extractMediaPlaceholder,
@@ -1001,6 +1002,7 @@ export async function attachWebInboxToSocket(
10011002body: string;
10021003location?: ReturnType<typeof extractLocationData>;
10031004contactContext?: ReturnType<typeof extractContactContext>;
1005+externalAdReplyContext?: ReturnType<typeof extractExternalAdReplyContext>;
10041006replyContext?: ReturnType<typeof describeReplyContext>;
10051007mediaPath?: string;
10061008mediaType?: string;
@@ -1011,6 +1013,7 @@ export async function attachWebInboxToSocket(
10111013const location = extractLocationData(msg.message ?? undefined);
10121014const locationText = location ? formatLocationText(location) : undefined;
10131015const contactContext = extractContactContext(msg.message ?? undefined);
1016+const externalAdReplyContext = extractExternalAdReplyContext(msg.message ?? undefined);
10141017let body = extractText(msg.message ?? undefined);
10151018if (locationText) {
10161019body = [body, locationText].filter(Boolean).join("\n").trim();
@@ -1055,6 +1058,7 @@ export async function attachWebInboxToSocket(
10551058 body,
10561059location: location ?? undefined,
10571060 contactContext,
1061+ externalAdReplyContext,
10581062 replyContext,
10591063 mediaPath,
10601064 mediaType,
@@ -1137,6 +1141,28 @@ export async function attachWebInboxToSocket(
11371141mentions: groupMentions,
11381142}
11391143 : undefined;
1144+const untrustedStructuredContext = [
1145+ ...(enriched.contactContext
1146+ ? [
1147+{
1148+label: "WhatsApp contact",
1149+source: "whatsapp",
1150+type: enriched.contactContext.kind,
1151+payload: enriched.contactContext,
1152+},
1153+]
1154+ : []),
1155+ ...(enriched.externalAdReplyContext
1156+ ? [
1157+{
1158+label: "WhatsApp external ad reply",
1159+source: "whatsapp",
1160+type: "external_ad_reply",
1161+payload: enriched.externalAdReplyContext,
1162+},
1163+]
1164+ : []),
1165+];
11401166const inboundMessage: QueuedInboundMessage = withDeprecatedWebInboundMessageFlatAliases({
11411167admission: inbound.access.admission,
11421168event: {
@@ -1146,16 +1172,8 @@ export async function attachWebInboxToSocket(
11461172payload: {
11471173body: enriched.body,
11481174location: enriched.location ?? undefined,
1149-untrustedStructuredContext: enriched.contactContext
1150- ? [
1151-{
1152-label: "WhatsApp contact",
1153-source: "whatsapp",
1154-type: enriched.contactContext.kind,
1155-payload: enriched.contactContext,
1156-},
1157-]
1158- : undefined,
1175+untrustedStructuredContext:
1176+untrustedStructuredContext.length > 0 ? untrustedStructuredContext : undefined,
11591177 media,
11601178},
11611179platform: {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。