mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-25 08:52:12 +00:00
refactor: deduplicate reply payload handling
This commit is contained in:
@@ -13,7 +13,7 @@ import { normalizeReplyPayloadsForDelivery } from "../../infra/outbound/payloads
|
||||
import { buildOutboundSessionContext } from "../../infra/outbound/session-context.js";
|
||||
import { maybeResolveIdLikeTarget } from "../../infra/outbound/target-resolver.js";
|
||||
import { resolveOutboundTarget } from "../../infra/outbound/targets.js";
|
||||
import { resolveOutboundMediaUrls } from "../../plugin-sdk/reply-payload.js";
|
||||
import { resolveSendableOutboundReplyParts } from "../../plugin-sdk/reply-payload.js";
|
||||
import { normalizePollInput } from "../../polls.js";
|
||||
import {
|
||||
ErrorCodes,
|
||||
@@ -211,8 +211,8 @@ export const sendHandlers: GatewayRequestHandlers = {
|
||||
.map((payload) => payload.text)
|
||||
.filter(Boolean)
|
||||
.join("\n");
|
||||
const mirrorMediaUrls = mirrorPayloads.flatMap((payload) =>
|
||||
resolveOutboundMediaUrls(payload),
|
||||
const mirrorMediaUrls = mirrorPayloads.flatMap(
|
||||
(payload) => resolveSendableOutboundReplyParts(payload).mediaUrls,
|
||||
);
|
||||
const providedSessionKey =
|
||||
typeof request.sessionKey === "string" && request.sessionKey.trim()
|
||||
|
||||
@@ -3,6 +3,7 @@ import { isVerbose } from "../globals.js";
|
||||
import { shouldLogSubsystemToConsole } from "../logging/console.js";
|
||||
import { getDefaultRedactPatterns, redactSensitiveText } from "../logging/redact.js";
|
||||
import { createSubsystemLogger } from "../logging/subsystem.js";
|
||||
import { resolveSendableOutboundReplyParts } from "../plugin-sdk/reply-payload.js";
|
||||
import { parseAgentSessionKey } from "../routing/session-key.js";
|
||||
import { DEFAULT_WS_SLOW_MS, getGatewayWsLogStyle } from "./ws-logging.js";
|
||||
|
||||
@@ -204,9 +205,11 @@ export function summarizeAgentEventForWsLog(payload: unknown): Record<string, un
|
||||
if (text?.trim()) {
|
||||
extra.text = compactPreview(text);
|
||||
}
|
||||
const mediaUrls = Array.isArray(data.mediaUrls) ? data.mediaUrls : undefined;
|
||||
if (mediaUrls && mediaUrls.length > 0) {
|
||||
extra.media = mediaUrls.length;
|
||||
const mediaCount = resolveSendableOutboundReplyParts({
|
||||
mediaUrls: Array.isArray(data.mediaUrls) ? data.mediaUrls : undefined,
|
||||
}).mediaCount;
|
||||
if (mediaCount > 0) {
|
||||
extra.media = mediaCount;
|
||||
}
|
||||
return extra;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user