mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-23 07:01:40 +00:00
Feishu: normalize group announce targets to chat ids (openclaw#31546) thanks @liuxiaopai-ai
Verified: - pnpm build - pnpm check (fails on unrelated existing main-branch lint violations in ui/src/ui/views/agents-utils.ts and src/pairing/pairing-store.ts) - pnpm test:macmini Co-authored-by: liuxiaopai-ai <73659136+liuxiaopai-ai@users.noreply.github.com> Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
This commit is contained in:
@@ -18,6 +18,10 @@ describe("resolveReceiveIdType", () => {
|
||||
expect(resolveReceiveIdType("group:oc_123")).toBe("chat_id");
|
||||
});
|
||||
|
||||
it("treats explicit channel targets as chat_id", () => {
|
||||
expect(resolveReceiveIdType("channel:oc_123")).toBe("chat_id");
|
||||
});
|
||||
|
||||
it("treats dm-prefixed open IDs as open_id", () => {
|
||||
expect(resolveReceiveIdType("dm:ou_123")).toBe("open_id");
|
||||
});
|
||||
@@ -33,8 +37,11 @@ describe("normalizeFeishuTarget", () => {
|
||||
expect(normalizeFeishuTarget("feishu:chat:oc_123")).toBe("oc_123");
|
||||
});
|
||||
|
||||
it("strips provider and group prefixes", () => {
|
||||
it("normalizes group/channel prefixes to chat ids", () => {
|
||||
expect(normalizeFeishuTarget("group:oc_123")).toBe("oc_123");
|
||||
expect(normalizeFeishuTarget("feishu:group:oc_123")).toBe("oc_123");
|
||||
expect(normalizeFeishuTarget("channel:oc_456")).toBe("oc_456");
|
||||
expect(normalizeFeishuTarget("lark:channel:oc_456")).toBe("oc_456");
|
||||
});
|
||||
|
||||
it("accepts provider-prefixed raw ids", () => {
|
||||
@@ -55,7 +62,9 @@ describe("looksLikeFeishuId", () => {
|
||||
expect(looksLikeFeishuId("lark:chat:oc_123")).toBe(true);
|
||||
});
|
||||
|
||||
it("accepts provider-prefixed group targets", () => {
|
||||
it("accepts group/channel targets", () => {
|
||||
expect(looksLikeFeishuId("feishu:group:oc_123")).toBe(true);
|
||||
expect(looksLikeFeishuId("group:oc_123")).toBe(true);
|
||||
expect(looksLikeFeishuId("channel:oc_456")).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -36,6 +36,9 @@ export function normalizeFeishuTarget(raw: string): string | null {
|
||||
if (lowered.startsWith("group:")) {
|
||||
return withoutProvider.slice("group:".length).trim() || null;
|
||||
}
|
||||
if (lowered.startsWith("channel:")) {
|
||||
return withoutProvider.slice("channel:".length).trim() || null;
|
||||
}
|
||||
if (lowered.startsWith("user:")) {
|
||||
return withoutProvider.slice("user:".length).trim() || null;
|
||||
}
|
||||
@@ -87,7 +90,7 @@ export function looksLikeFeishuId(raw: string): boolean {
|
||||
if (!trimmed) {
|
||||
return false;
|
||||
}
|
||||
if (/^(chat|group|user|dm|open_id):/i.test(trimmed)) {
|
||||
if (/^(chat|group|channel|user|dm|open_id):/i.test(trimmed)) {
|
||||
return true;
|
||||
}
|
||||
if (trimmed.startsWith(CHAT_ID_PREFIX)) {
|
||||
|
||||
Reference in New Issue
Block a user