@microsoft/teams.api
Version:
<p> <a href="https://www.npmjs.com/package/@microsoft/teams.api" target="_blank"> <img src="https://img.shields.io/npm/v/@microsoft/teams.api/latest" /> </a> <a href="https://www.npmjs.com/package/@microsoft/teams.api?activeTab=code" t
25 lines (23 loc) • 840 B
JavaScript
;
function stripMentionsText(activity, { accountId, tagOnly } = {}) {
if (!activity.text) return;
let text = activity.text;
for (const mention of activity.entities?.filter((e) => e.type === "mention") || []) {
if (accountId && mention.mentioned.id !== accountId) {
continue;
}
if (mention.text) {
const textWithoutTags = mention.text.replace("<at>", "").replace("</at>", "");
text = text.replace(mention.text, !tagOnly ? "" : textWithoutTags);
} else if (mention.mentioned.name) {
text = text.replace(
`<at>${mention.mentioned.name}</at>`,
!tagOnly ? "" : mention.mentioned.name
);
}
}
return text.trim();
}
exports.stripMentionsText = stripMentionsText;
//# sourceMappingURL=strip-mentions-text.js.map
//# sourceMappingURL=strip-mentions-text.js.map