From 87d840e9eeb21e451726e93f1d46cacee52ac2aa Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sat, 4 Apr 2026 19:38:43 +0900 Subject: [PATCH] fix: tighten Teams and device typing --- .../msteams/src/monitor-handler/message-handler.ts | 13 +++++++++---- src/gateway/server-methods/devices.ts | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/extensions/msteams/src/monitor-handler/message-handler.ts b/extensions/msteams/src/monitor-handler/message-handler.ts index 2cc4ac7d09e..9671b0cfd19 100644 --- a/extensions/msteams/src/monitor-handler/message-handler.ts +++ b/extensions/msteams/src/monitor-handler/message-handler.ts @@ -39,18 +39,23 @@ import { wasMSTeamsBotMentioned, } from "../inbound.js"; +function isStringRecord(value: unknown): value is Record { + return typeof value === "object" && value !== null; +} + function extractTextFromHtmlAttachments(attachments: MSTeamsAttachmentLike[]): string { for (const attachment of attachments) { if (attachment.contentType !== "text/html") { continue; } + const structuredContent = isStringRecord(attachment.content) ? attachment.content : null; const raw = typeof attachment.content === "string" ? attachment.content - : typeof attachment.content?.text === "string" - ? attachment.content.text - : typeof attachment.content?.body === "string" - ? attachment.content.body + : typeof structuredContent?.text === "string" + ? structuredContent.text + : typeof structuredContent?.body === "string" + ? structuredContent.body : ""; if (!raw) { continue; diff --git a/src/gateway/server-methods/devices.ts b/src/gateway/server-methods/devices.ts index ef34f273a4b..228d11175fb 100644 --- a/src/gateway/server-methods/devices.ts +++ b/src/gateway/server-methods/devices.ts @@ -29,7 +29,7 @@ import type { GatewayRequestHandlers } from "./types.js"; const DEVICE_TOKEN_ROTATION_DENIED_MESSAGE = "device token rotation denied"; type DeviceTokenRotateTarget = { - pairedDevice: Awaited>; + pairedDevice: NonNullable>>; normalizedRole: string; };