mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-02 09:41:37 +00:00
fix(msteams): recognize provider-prefixed target ids (#115609)
* fix(msteams): recognize provider-prefixed target ids * style(msteams): format explicit target regression matrix
This commit is contained in:
committed by
GitHub
parent
d976c2ea82
commit
23db233bb5
@@ -108,6 +108,26 @@ describe("msteamsPlugin", () => {
|
||||
expect(looksLikeId?.("a:1bfPersonalChat")).toBe(true);
|
||||
expect(looksLikeId?.("user:Jane Doe")).toBe(false);
|
||||
});
|
||||
|
||||
it("recognizes provider-prefixed explicit targets without claiming display names", () => {
|
||||
const messaging = msteamsPlugin.messaging;
|
||||
const aadUserId = "40a1a0ed-4ff2-4164-a219-55518990c197";
|
||||
|
||||
expect(
|
||||
["teams", "msteams"].map((provider) => {
|
||||
const target = `${provider}:user:${aadUserId}`;
|
||||
return {
|
||||
explicit: messaging?.targetResolver?.looksLikeId?.(target),
|
||||
normalized: messaging?.normalizeTarget?.(target),
|
||||
};
|
||||
}),
|
||||
).toEqual([
|
||||
{ explicit: true, normalized: `user:${aadUserId}` },
|
||||
{ explicit: true, normalized: `user:${aadUserId}` },
|
||||
]);
|
||||
expect(messaging?.targetResolver?.looksLikeId?.("teams:user:Jane Doe")).toBe(false);
|
||||
expect(messaging?.targetResolver?.looksLikeId?.("msteams:user:Jane Doe")).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("msteams config schema", () => {
|
||||
|
||||
@@ -500,12 +500,29 @@ describe("looksLikeMSTeamsTargetId", () => {
|
||||
expect(looksLikeMSTeamsTargetId("user:40a1a0ed-4ff2-4164-a219-55518990c197")).toBe(true);
|
||||
});
|
||||
|
||||
it.each(["", " ", "user:John Smith", "Product Team/Roadmap", "Engineering", "hello"])(
|
||||
"rejects non-id inputs (%s)",
|
||||
(raw) => {
|
||||
expect(looksLikeMSTeamsTargetId(raw)).toBe(false);
|
||||
},
|
||||
);
|
||||
it.each([
|
||||
"teams:user:40a1a0ed-4ff2-4164-a219-55518990c197",
|
||||
"msteams:user:40a1a0ed-4ff2-4164-a219-55518990c197",
|
||||
"TEAMS:conversation:19:abc@thread.tacv2",
|
||||
"msteams:19:abc@thread.tacv2",
|
||||
"teams:29:1a2b3c4d5e6f",
|
||||
" teams:user:40a1a0ed-4ff2-4164-a219-55518990c197 ",
|
||||
])("accepts provider-prefixed explicit ids (%s)", (raw) => {
|
||||
expect(looksLikeMSTeamsTargetId(raw)).toBe(true);
|
||||
});
|
||||
|
||||
it.each([
|
||||
"",
|
||||
" ",
|
||||
"user:John Smith",
|
||||
"teams:user:John Smith",
|
||||
"msteams:user:John Smith",
|
||||
"Product Team/Roadmap",
|
||||
"Engineering",
|
||||
"hello",
|
||||
])("rejects non-id inputs (%s)", (raw) => {
|
||||
expect(looksLikeMSTeamsTargetId(raw)).toBe(false);
|
||||
});
|
||||
|
||||
it("normalizes leading/trailing whitespace before classifying", () => {
|
||||
expect(looksLikeMSTeamsTargetId(" 19:abc@thread.tacv2 ")).toBe(true);
|
||||
|
||||
@@ -183,7 +183,7 @@ export function looksLikeMSTeamsConversationId(raw: string): boolean {
|
||||
* can forward verbatim to the channel adapter.
|
||||
*/
|
||||
export function looksLikeMSTeamsTargetId(raw: string): boolean {
|
||||
const trimmed = raw.trim();
|
||||
const trimmed = stripProviderPrefix(raw.trim()).trim();
|
||||
if (looksLikeMSTeamsConversationId(trimmed)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user