fix: reduce redundant envelope formatting for iMessage and Signal
This commit is contained in:
committed by
Peter Steinberger
parent
64d21f5ea8
commit
d0bc08a934
@@ -60,7 +60,9 @@ describe("signal createSignalEventHandler inbound contract", () => {
|
||||
|
||||
expect(capturedCtx).toBeTruthy();
|
||||
expectInboundContextContract(capturedCtx!);
|
||||
expect(String(capturedCtx?.Body ?? "")).toContain("[from:");
|
||||
// Sender should appear as prefix in group messages (no redundant [from:] suffix)
|
||||
expect(String(capturedCtx?.Body ?? "")).toContain("Alice");
|
||||
expect(String(capturedCtx?.Body ?? "")).toMatch(/Alice.*:/);
|
||||
expect(String(capturedCtx?.Body ?? "")).not.toContain("[from:");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -65,9 +65,13 @@ 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: show sender, only add id: suffix if display differs from name
|
||||
const fromLabel = entry.isGroup
|
||||
? `${entry.groupName ?? "Signal Group"} id:${entry.groupId}`
|
||||
: `${entry.senderName} id:${entry.senderDisplay}`;
|
||||
? `${entry.groupName || "Group"} id:${entry.groupId}`
|
||||
: entry.senderName === entry.senderDisplay
|
||||
? entry.senderName
|
||||
: `${entry.senderName} id:${entry.senderDisplay}`;
|
||||
const body = formatInboundEnvelope({
|
||||
channel: "Signal",
|
||||
from: fromLabel,
|
||||
|
||||
Reference in New Issue
Block a user