fix(signal): preserve group ID case sensitivity

Base64 group IDs are case-sensitive. The normalizeSignalMessagingTarget
function was lowercasing the entire group:ID string, which broke lookups
for groups with mixed-case base64 IDs.

This fix preserves the original case of the group ID while still
normalizing the 'group:' prefix to lowercase.

Fixes reaction failures with error: 'Group not found' when the lowercased
ID doesn't match the actual group.
This commit is contained in:
Qi Ke 2026-01-28 18:46:37 -10:00
parent 4ac7aa4a48
commit ec4d4d96c0
2 changed files with 15 additions and 1 deletions

View File

@ -29,4 +29,17 @@ describe("signal target normalization", () => {
expect(looksLikeSignalTargetId("uuid:")).toBe(false);
expect(looksLikeSignalTargetId("uuid:not-a-uuid")).toBe(false);
});
it("preserves group ID case (base64 is case-sensitive)", () => {
// Base64 group IDs contain mixed case that must be preserved
expect(normalizeSignalMessagingTarget("group:igVOP2EJR1sBXYYwsLhif/AEMTJWtiDiTyu88GWP5ZQ=")).toBe(
"group:igVOP2EJR1sBXYYwsLhif/AEMTJWtiDiTyu88GWP5ZQ=",
);
expect(normalizeSignalMessagingTarget("signal:group:ABC123xyz+/=")).toBe("group:ABC123xyz+/=");
});
it("normalizes group prefix case but preserves ID", () => {
expect(normalizeSignalMessagingTarget("GROUP:TestGroupId123=")).toBe("group:TestGroupId123=");
expect(normalizeSignalMessagingTarget("Group:MixedCase/+ABC=")).toBe("group:MixedCase/+ABC=");
});
});

View File

@ -9,7 +9,8 @@ export function normalizeSignalMessagingTarget(raw: string): string | undefined
const lower = normalized.toLowerCase();
if (lower.startsWith("group:")) {
const id = normalized.slice("group:".length).trim();
return id ? `group:${id}`.toLowerCase() : undefined;
// Keep group ID case-sensitive (base64 is case-sensitive)
return id ? `group:${id}` : undefined;
}
if (lower.startsWith("username:")) {
const id = normalized.slice("username:".length).trim();