refactor: prune legacy group prefixes
This commit is contained in:
@@ -422,7 +422,7 @@ export async function monitorIMessageProvider(opts: MonitorIMessageOpts = {}): P
|
||||
Body: combinedBody,
|
||||
RawBody: bodyText,
|
||||
CommandBody: bodyText,
|
||||
From: isGroup ? `group:${chatId}` : `imessage:${sender}`,
|
||||
From: isGroup ? `imessage:group:${chatId ?? "unknown"}` : `imessage:${sender}`,
|
||||
To: imessageTo,
|
||||
SessionKey: route.sessionKey,
|
||||
AccountId: route.accountId,
|
||||
|
||||
@@ -13,8 +13,8 @@ describe("imessage targets", () => {
|
||||
expect(target).toEqual({ kind: "chat_id", chatId: 123 });
|
||||
});
|
||||
|
||||
it("parses group chat targets", () => {
|
||||
const target = parseIMessageTarget("group:456");
|
||||
it("parses chat targets", () => {
|
||||
const target = parseIMessageTarget("chat:456");
|
||||
expect(target).toEqual({ kind: "chat_id", chatId: 456 });
|
||||
});
|
||||
|
||||
|
||||
@@ -53,8 +53,7 @@ export function parseIMessageTarget(raw: string): IMessageTarget {
|
||||
const isChatTarget =
|
||||
CHAT_ID_PREFIXES.some((p) => remainderLower.startsWith(p)) ||
|
||||
CHAT_GUID_PREFIXES.some((p) => remainderLower.startsWith(p)) ||
|
||||
CHAT_IDENTIFIER_PREFIXES.some((p) => remainderLower.startsWith(p)) ||
|
||||
remainderLower.startsWith("group:");
|
||||
CHAT_IDENTIFIER_PREFIXES.some((p) => remainderLower.startsWith(p));
|
||||
if (isChatTarget) {
|
||||
return parseIMessageTarget(remainder);
|
||||
}
|
||||
@@ -89,16 +88,6 @@ export function parseIMessageTarget(raw: string): IMessageTarget {
|
||||
}
|
||||
}
|
||||
|
||||
if (lower.startsWith("group:")) {
|
||||
const value = stripPrefix(trimmed, "group:");
|
||||
const chatId = Number.parseInt(value, 10);
|
||||
if (Number.isFinite(chatId)) {
|
||||
return { kind: "chat_id", chatId };
|
||||
}
|
||||
if (!value) throw new Error("group target is required");
|
||||
return { kind: "chat_guid", chatGuid: value };
|
||||
}
|
||||
|
||||
return { kind: "handle", to: trimmed, service: "auto" };
|
||||
}
|
||||
|
||||
@@ -137,13 +126,6 @@ export function parseIMessageAllowTarget(raw: string): IMessageAllowTarget {
|
||||
}
|
||||
}
|
||||
|
||||
if (lower.startsWith("group:")) {
|
||||
const value = stripPrefix(trimmed, "group:");
|
||||
const chatId = Number.parseInt(value, 10);
|
||||
if (Number.isFinite(chatId)) return { kind: "chat_id", chatId };
|
||||
if (value) return { kind: "chat_guid", chatGuid: value };
|
||||
}
|
||||
|
||||
return { kind: "handle", handle: normalizeIMessageHandle(trimmed) };
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user