refactor: share inbound envelope label helper

This commit is contained in:
Peter Steinberger
2026-01-17 08:51:26 +00:00
parent 61e60f3b84
commit 1002c74d9c
4 changed files with 46 additions and 16 deletions

View File

@@ -8,7 +8,7 @@ import {
type ResponsePrefixContext,
} from "../../auto-reply/reply/response-prefix-template.js";
import { hasControlCommand } from "../../auto-reply/command-detection.js";
import { formatInboundEnvelope } from "../../auto-reply/envelope.js";
import { formatInboundEnvelope, formatInboundFromLabel } from "../../auto-reply/envelope.js";
import {
createInboundDebouncer,
resolveInboundDebounceMs,
@@ -65,13 +65,14 @@ export function createSignalEventHandler(deps: SignalEventHandlerDeps) {
};
async function handleSignalInboundMessage(entry: SignalInboundEntry) {
// For groups: use group name or just "Group" (channel "Signal" is already shown).
// For DMs: keep headers compact; only add id: suffix if display differs from name.
const fromLabel = entry.isGroup
? `${entry.groupName || "Group"} id:${entry.groupId}`
: entry.senderName === entry.senderDisplay
? entry.senderName
: `${entry.senderName} id:${entry.senderDisplay}`;
const fromLabel = formatInboundFromLabel({
isGroup: entry.isGroup,
groupLabel: entry.groupName ?? undefined,
groupId: entry.groupId ?? "unknown",
groupFallback: "Group",
directLabel: entry.senderName,
directId: entry.senderDisplay,
});
const body = formatInboundEnvelope({
channel: "Signal",
from: fromLabel,