mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 00:28:26 +00:00
chore: Enable "curly" rule to avoid single-statement if confusion/errors.
This commit is contained in:
@@ -176,7 +176,9 @@ export function createSignalEventHandler(deps: SignalEventHandlerDeps) {
|
||||
|
||||
const typingCallbacks = createTypingCallbacks({
|
||||
start: async () => {
|
||||
if (!ctxPayload.To) return;
|
||||
if (!ctxPayload.To) {
|
||||
return;
|
||||
}
|
||||
await sendTypingSignal(ctxPayload.To, {
|
||||
baseUrl: deps.baseUrl,
|
||||
account: deps.account,
|
||||
@@ -252,17 +254,25 @@ export function createSignalEventHandler(deps: SignalEventHandlerDeps) {
|
||||
debounceMs: inboundDebounceMs,
|
||||
buildKey: (entry) => {
|
||||
const conversationId = entry.isGroup ? (entry.groupId ?? "unknown") : entry.senderPeerId;
|
||||
if (!conversationId || !entry.senderPeerId) return null;
|
||||
if (!conversationId || !entry.senderPeerId) {
|
||||
return null;
|
||||
}
|
||||
return `signal:${deps.accountId}:${conversationId}:${entry.senderPeerId}`;
|
||||
},
|
||||
shouldDebounce: (entry) => {
|
||||
if (!entry.bodyText.trim()) return false;
|
||||
if (entry.mediaPath || entry.mediaType) return false;
|
||||
if (!entry.bodyText.trim()) {
|
||||
return false;
|
||||
}
|
||||
if (entry.mediaPath || entry.mediaType) {
|
||||
return false;
|
||||
}
|
||||
return !hasControlCommand(entry.bodyText, deps.cfg);
|
||||
},
|
||||
onFlush: async (entries) => {
|
||||
const last = entries.at(-1);
|
||||
if (!last) return;
|
||||
if (!last) {
|
||||
return;
|
||||
}
|
||||
if (entries.length === 1) {
|
||||
await handleSignalInboundMessage(last);
|
||||
return;
|
||||
@@ -271,7 +281,9 @@ export function createSignalEventHandler(deps: SignalEventHandlerDeps) {
|
||||
.map((entry) => entry.bodyText)
|
||||
.filter(Boolean)
|
||||
.join("\\n");
|
||||
if (!combinedText.trim()) return;
|
||||
if (!combinedText.trim()) {
|
||||
return;
|
||||
}
|
||||
await handleSignalInboundMessage({
|
||||
...last,
|
||||
bodyText: combinedText,
|
||||
@@ -285,7 +297,9 @@ export function createSignalEventHandler(deps: SignalEventHandlerDeps) {
|
||||
});
|
||||
|
||||
return async (event: { event?: string; data?: string }) => {
|
||||
if (event.event !== "receive" || !event.data) return;
|
||||
if (event.event !== "receive" || !event.data) {
|
||||
return;
|
||||
}
|
||||
|
||||
let payload: SignalReceivePayload | null = null;
|
||||
try {
|
||||
@@ -298,13 +312,21 @@ export function createSignalEventHandler(deps: SignalEventHandlerDeps) {
|
||||
deps.runtime.error?.(`receive exception: ${payload.exception.message}`);
|
||||
}
|
||||
const envelope = payload?.envelope;
|
||||
if (!envelope) return;
|
||||
if (envelope.syncMessage) return;
|
||||
if (!envelope) {
|
||||
return;
|
||||
}
|
||||
if (envelope.syncMessage) {
|
||||
return;
|
||||
}
|
||||
|
||||
const sender = resolveSignalSender(envelope);
|
||||
if (!sender) return;
|
||||
if (!sender) {
|
||||
return;
|
||||
}
|
||||
if (deps.account && sender.kind === "phone") {
|
||||
if (sender.e164 === normalizeE164(deps.account)) return;
|
||||
if (sender.e164 === normalizeE164(deps.account)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
const dataMessage = envelope.dataMessage ?? envelope.editMessage?.dataMessage;
|
||||
@@ -319,7 +341,9 @@ export function createSignalEventHandler(deps: SignalEventHandlerDeps) {
|
||||
Boolean(messageText || quoteText) || Boolean(!reaction && dataMessage?.attachments?.length);
|
||||
|
||||
if (reaction && !hasBodyContent) {
|
||||
if (reaction.isRemove) return; // Ignore reaction removals
|
||||
if (reaction.isRemove) {
|
||||
return;
|
||||
} // Ignore reaction removals
|
||||
const emojiLabel = reaction.emoji?.trim() || "emoji";
|
||||
const senderDisplay = formatSignalSenderDisplay(sender);
|
||||
const senderName = envelope.sourceName ?? senderDisplay;
|
||||
@@ -332,7 +356,9 @@ export function createSignalEventHandler(deps: SignalEventHandlerDeps) {
|
||||
sender,
|
||||
allowlist: deps.reactionAllowlist,
|
||||
});
|
||||
if (!shouldNotify) return;
|
||||
if (!shouldNotify) {
|
||||
return;
|
||||
}
|
||||
|
||||
const groupId = reaction.groupInfo?.groupId ?? undefined;
|
||||
const groupName = reaction.groupInfo?.groupName ?? undefined;
|
||||
@@ -373,13 +399,17 @@ export function createSignalEventHandler(deps: SignalEventHandlerDeps) {
|
||||
enqueueSystemEvent(text, { sessionKey: route.sessionKey, contextKey });
|
||||
return;
|
||||
}
|
||||
if (!dataMessage) return;
|
||||
if (!dataMessage) {
|
||||
return;
|
||||
}
|
||||
|
||||
const senderDisplay = formatSignalSenderDisplay(sender);
|
||||
const senderRecipient = resolveSignalRecipient(sender);
|
||||
const senderPeerId = resolveSignalPeerId(sender);
|
||||
const senderAllowId = formatSignalSenderId(sender);
|
||||
if (!senderRecipient) return;
|
||||
if (!senderRecipient) {
|
||||
return;
|
||||
}
|
||||
const senderIdLine = formatSignalPairingIdLine(sender);
|
||||
const groupId = dataMessage.groupInfo?.groupId ?? undefined;
|
||||
const groupName = dataMessage.groupInfo?.groupName ?? undefined;
|
||||
@@ -391,7 +421,9 @@ export function createSignalEventHandler(deps: SignalEventHandlerDeps) {
|
||||
deps.dmPolicy === "open" ? true : isSignalSenderAllowed(sender, effectiveDmAllow);
|
||||
|
||||
if (!isGroup) {
|
||||
if (deps.dmPolicy === "disabled") return;
|
||||
if (deps.dmPolicy === "disabled") {
|
||||
return;
|
||||
}
|
||||
if (!dmAllowed) {
|
||||
if (deps.dmPolicy === "pairing") {
|
||||
const senderId = senderAllowId;
|
||||
@@ -490,11 +522,16 @@ export function createSignalEventHandler(deps: SignalEventHandlerDeps) {
|
||||
}
|
||||
|
||||
const kind = mediaKindFromMime(mediaType ?? undefined);
|
||||
if (kind) placeholder = `<media:${kind}>`;
|
||||
else if (dataMessage.attachments?.length) placeholder = "<media:attachment>";
|
||||
if (kind) {
|
||||
placeholder = `<media:${kind}>`;
|
||||
} else if (dataMessage.attachments?.length) {
|
||||
placeholder = "<media:attachment>";
|
||||
}
|
||||
|
||||
const bodyText = messageText || placeholder || dataMessage.quote?.text?.trim() || "";
|
||||
if (!bodyText) return;
|
||||
if (!bodyText) {
|
||||
return;
|
||||
}
|
||||
|
||||
const receiptTimestamp =
|
||||
typeof envelope.timestamp === "number"
|
||||
|
||||
Reference in New Issue
Block a user