MS Teams: add user mention support

- Add mention parsing and validation logic
- Handle mention entities with proper whitespace
- Validate mention IDs to prevent false positives from code snippets
- Use fake placeholders in tests for privacy
This commit is contained in:
Hyojin Kwak
2026-02-13 21:38:51 +09:00
committed by Peter Steinberger
parent edfdd12d37
commit 7c6d6ce06f
3 changed files with 333 additions and 1 deletions

View File

@@ -19,6 +19,7 @@ import {
uploadAndShareSharePoint,
} from "./graph-upload.js";
import { extractFilename, extractMessageId, getMimeType, isLocalPath } from "./media-helpers.js";
import { parseMentions } from "./mentions.js";
import { getMSTeamsRuntime } from "./runtime.js";
/**
@@ -269,7 +270,14 @@ async function buildActivity(
const activity: Record<string, unknown> = { type: "message" };
if (msg.text) {
activity.text = msg.text;
// Parse mentions from text (format: @[Name](id))
const { text: formattedText, entities } = parseMentions(msg.text);
activity.text = formattedText;
// Add mention entities if any mentions were found
if (entities.length > 0) {
activity.entities = entities;
}
}
if (msg.mediaUrl) {