


























@@ -468,6 +468,35 @@ type SendPayloadParts = {
468468silent?: boolean;
469469};
470470471+function collectMessageAttachmentMediaHints(value: unknown): string[] {
472+if (!Array.isArray(value)) {
473+return [];
474+}
475+const mediaUrls: string[] = [];
476+const seen = new Set<string>();
477+const pushMedia = (entry: unknown) => {
478+const normalized = normalizeOptionalString(entry);
479+if (!normalized || seen.has(normalized)) {
480+return;
481+}
482+seen.add(normalized);
483+mediaUrls.push(normalized);
484+};
485+for (const attachment of value) {
486+if (!attachment || typeof attachment !== "object" || Array.isArray(attachment)) {
487+continue;
488+}
489+const record = attachment as Record<string, unknown>;
490+pushMedia(record.media);
491+pushMedia(record.mediaUrl);
492+pushMedia(record.path);
493+pushMedia(record.filePath);
494+pushMedia(record.fileUrl);
495+pushMedia(record.url);
496+}
497+return mediaUrls;
498+}
499+471500function hasExplicitRouteParam(params: Record<string, unknown>): boolean {
472501for (const key of ["channel", "target", "to", "channelId"]) {
473502if (normalizeOptionalString(params[key])) {
@@ -692,12 +721,14 @@ async function buildSendPayloadParts(params: {
692721readStringParam(actionParams, "path", { trim: false }) ??
693722readStringParam(actionParams, "filePath", { trim: false }) ??
694723readStringParam(actionParams, "fileUrl", { trim: false });
724+const attachmentMediaHints = collectMessageAttachmentMediaHints(actionParams.attachments);
725+const hasMediaHint = Boolean(mediaHint) || attachmentMediaHints.length > 0;
695726const hasPresentation = hasMessagePresentationBlocks(actionParams.presentation);
696727const hasInteractive = hasInteractiveReplyBlocks(actionParams.interactive);
697728const caption = readStringParam(actionParams, "caption", { allowEmpty: true }) ?? "";
698729let message =
699730readStringParam(actionParams, "message", {
700-required: !mediaHint && !hasPresentation && !hasInteractive,
731+required: !hasMediaHint && !hasPresentation && !hasInteractive,
701732allowEmpty: true,
702733}) ?? "";
703734if (message.includes("\\n")) {
@@ -719,6 +750,9 @@ async function buildSendPayloadParts(params: {
719750mergedMediaUrls.push(trimmed);
720751};
721752pushMedia(mediaHint);
753+for (const attachmentMediaHint of attachmentMediaHints) {
754+pushMedia(attachmentMediaHint);
755+}
722756for (const url of parsed.mediaUrls ?? []) {
723757pushMedia(url);
724758}
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。