mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 03:11:25 +00:00
chore: Enable "curly" rule to avoid single-statement if confusion/errors.
This commit is contained in:
@@ -12,7 +12,9 @@ type DeliveryPayload = {
|
||||
|
||||
export function pickSummaryFromOutput(text: string | undefined) {
|
||||
const clean = (text ?? "").trim();
|
||||
if (!clean) return undefined;
|
||||
if (!clean) {
|
||||
return undefined;
|
||||
}
|
||||
const limit = 2000;
|
||||
return clean.length > limit ? `${truncateUtf16Safe(clean, limit)}…` : clean;
|
||||
}
|
||||
@@ -20,7 +22,9 @@ export function pickSummaryFromOutput(text: string | undefined) {
|
||||
export function pickSummaryFromPayloads(payloads: Array<{ text?: string | undefined }>) {
|
||||
for (let i = payloads.length - 1; i >= 0; i--) {
|
||||
const summary = pickSummaryFromOutput(payloads[i]?.text);
|
||||
if (summary) return summary;
|
||||
if (summary) {
|
||||
return summary;
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
@@ -28,7 +32,9 @@ export function pickSummaryFromPayloads(payloads: Array<{ text?: string | undefi
|
||||
export function pickLastNonEmptyTextFromPayloads(payloads: Array<{ text?: string | undefined }>) {
|
||||
for (let i = payloads.length - 1; i >= 0; i--) {
|
||||
const clean = (payloads[i]?.text ?? "").trim();
|
||||
if (clean) return clean;
|
||||
if (clean) {
|
||||
return clean;
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
@@ -38,11 +44,15 @@ export function pickLastNonEmptyTextFromPayloads(payloads: Array<{ text?: string
|
||||
* Returns true if delivery should be skipped because there's no real content.
|
||||
*/
|
||||
export function isHeartbeatOnlyResponse(payloads: DeliveryPayload[], ackMaxChars: number) {
|
||||
if (payloads.length === 0) return true;
|
||||
if (payloads.length === 0) {
|
||||
return true;
|
||||
}
|
||||
return payloads.every((payload) => {
|
||||
// If there's media, we should deliver regardless of text content.
|
||||
const hasMedia = (payload.mediaUrls?.length ?? 0) > 0 || Boolean(payload.mediaUrl);
|
||||
if (hasMedia) return false;
|
||||
if (hasMedia) {
|
||||
return false;
|
||||
}
|
||||
// Use heartbeat mode to check if text is just HEARTBEAT_OK or short ack.
|
||||
const result = stripHeartbeatToken(payload.text, {
|
||||
mode: "heartbeat",
|
||||
|
||||
@@ -67,10 +67,14 @@ function matchesMessagingToolDeliveryTarget(
|
||||
target: MessagingToolSend,
|
||||
delivery: { channel: string; to?: string; accountId?: string },
|
||||
): boolean {
|
||||
if (!delivery.to || !target.to) return false;
|
||||
if (!delivery.to || !target.to) {
|
||||
return false;
|
||||
}
|
||||
const channel = delivery.channel.trim().toLowerCase();
|
||||
const provider = target.provider?.trim().toLowerCase();
|
||||
if (provider && provider !== "message" && provider !== channel) return false;
|
||||
if (provider && provider !== "message" && provider !== channel) {
|
||||
return false;
|
||||
}
|
||||
if (target.accountId && delivery.accountId && target.accountId !== delivery.accountId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user