mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 02:18:25 +00:00
fix(msteams): bind file consent invokes to conversation
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import type { OpenClawConfig, RuntimeEnv } from "openclaw/plugin-sdk";
|
||||
import type { MSTeamsConversationStore } from "./conversation-store.js";
|
||||
import { buildFileInfoCard, parseFileConsentInvoke, uploadToConsentUrl } from "./file-consent.js";
|
||||
import { normalizeMSTeamsConversationId } from "./inbound.js";
|
||||
import type { MSTeamsAdapter } from "./messenger.js";
|
||||
import { createMSTeamsMessageHandler } from "./monitor-handler/message-handler.js";
|
||||
import type { MSTeamsMonitorLogger } from "./monitor-types.js";
|
||||
@@ -42,6 +43,8 @@ async function handleFileConsentInvoke(
|
||||
context: MSTeamsTurnContext,
|
||||
log: MSTeamsMonitorLogger,
|
||||
): Promise<boolean> {
|
||||
const expiredUploadMessage =
|
||||
"The file upload request has expired. Please try sending the file again.";
|
||||
const activity = context.activity;
|
||||
if (activity.type !== "invoke" || activity.name !== "fileConsent/invoke") {
|
||||
return false;
|
||||
@@ -57,9 +60,24 @@ async function handleFileConsentInvoke(
|
||||
typeof consentResponse.context?.uploadId === "string"
|
||||
? consentResponse.context.uploadId
|
||||
: undefined;
|
||||
const pendingFile = getPendingUpload(uploadId);
|
||||
if (pendingFile) {
|
||||
const pendingConversationId = normalizeMSTeamsConversationId(pendingFile.conversationId);
|
||||
const invokeConversationId = normalizeMSTeamsConversationId(activity.conversation?.id ?? "");
|
||||
if (!invokeConversationId || pendingConversationId !== invokeConversationId) {
|
||||
log.info("file consent conversation mismatch", {
|
||||
uploadId,
|
||||
expectedConversationId: pendingConversationId,
|
||||
receivedConversationId: invokeConversationId || undefined,
|
||||
});
|
||||
if (consentResponse.action === "accept") {
|
||||
await context.sendActivity(expiredUploadMessage);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (consentResponse.action === "accept" && consentResponse.uploadInfo) {
|
||||
const pendingFile = getPendingUpload(uploadId);
|
||||
if (pendingFile) {
|
||||
log.debug?.("user accepted file consent, uploading", {
|
||||
uploadId,
|
||||
@@ -101,9 +119,7 @@ async function handleFileConsentInvoke(
|
||||
}
|
||||
} else {
|
||||
log.debug?.("pending file not found for consent", { uploadId });
|
||||
await context.sendActivity(
|
||||
"The file upload request has expired. Please try sending the file again.",
|
||||
);
|
||||
await context.sendActivity(expiredUploadMessage);
|
||||
}
|
||||
} else {
|
||||
// User declined
|
||||
|
||||
Reference in New Issue
Block a user