feat: finalize msteams polls + outbound parity

This commit is contained in:
Peter Steinberger
2026-01-09 09:56:36 +01:00
parent a2bba7ef51
commit e55358c65d
22 changed files with 913 additions and 81 deletions

View File

@@ -8,6 +8,7 @@ export type OutboundDeliveryJson = {
mediaUrl: string | null;
chatId?: string;
channelId?: string;
conversationId?: string;
timestamp?: number;
toJid?: string;
};
@@ -16,6 +17,7 @@ type OutboundDeliveryMeta = {
messageId?: string;
chatId?: string;
channelId?: string;
conversationId?: string;
timestamp?: number;
toJid?: string;
};
@@ -36,6 +38,8 @@ export function formatOutboundDeliverySummary(
if ("chatId" in result) return `${base} (chat ${result.chatId})`;
if ("channelId" in result) return `${base} (channel ${result.channelId})`;
if ("conversationId" in result)
return `${base} (conversation ${result.conversationId})`;
return base;
}
@@ -62,6 +66,13 @@ export function buildOutboundDeliveryJson(params: {
if (result && "channelId" in result && result.channelId !== undefined) {
payload.channelId = result.channelId;
}
if (
result &&
"conversationId" in result &&
result.conversationId !== undefined
) {
payload.conversationId = result.conversationId;
}
if (result && "timestamp" in result && result.timestamp !== undefined) {
payload.timestamp = result.timestamp;
}

View File

@@ -70,6 +70,8 @@ export type MessagePollResult = {
messageId: string;
toJid?: string;
channelId?: string;
conversationId?: string;
pollId?: string;
};
dryRun?: boolean;
};
@@ -108,7 +110,8 @@ export async function sendMessage(
provider === "discord" ||
provider === "slack" ||
provider === "signal" ||
provider === "imessage"
provider === "imessage" ||
provider === "msteams"
) {
const resolvedTarget = resolveOutboundTarget({
provider,
@@ -167,7 +170,11 @@ export async function sendPoll(
params: MessagePollParams,
): Promise<MessagePollResult> {
const provider = (params.provider ?? "whatsapp").toLowerCase();
if (provider !== "whatsapp" && provider !== "discord") {
if (
provider !== "whatsapp" &&
provider !== "discord" &&
provider !== "msteams"
) {
throw new Error(`Unsupported poll provider: ${provider}`);
}

View File

@@ -1,6 +1,7 @@
import type { ClawdbotConfig } from "../../config/config.js";
import { listEnabledDiscordAccounts } from "../../discord/accounts.js";
import { listEnabledIMessageAccounts } from "../../imessage/accounts.js";
import { resolveMSTeamsCredentials } from "../../msteams/token.js";
import { listEnabledSignalAccounts } from "../../signal/accounts.js";
import { listEnabledSlackAccounts } from "../../slack/accounts.js";
import { listEnabledTelegramAccounts } from "../../telegram/accounts.js";
@@ -17,7 +18,8 @@ export type MessageProviderId =
| "discord"
| "slack"
| "signal"
| "imessage";
| "imessage"
| "msteams";
const MESSAGE_PROVIDERS: MessageProviderId[] = [
"whatsapp",
@@ -26,6 +28,7 @@ const MESSAGE_PROVIDERS: MessageProviderId[] = [
"slack",
"signal",
"imessage",
"msteams",
];
function isKnownProvider(value: string): value is MessageProviderId {
@@ -70,6 +73,11 @@ function isIMessageConfigured(cfg: ClawdbotConfig): boolean {
return listEnabledIMessageAccounts(cfg).some((account) => account.configured);
}
function isMSTeamsConfigured(cfg: ClawdbotConfig): boolean {
if (!cfg.msteams || cfg.msteams.enabled === false) return false;
return Boolean(resolveMSTeamsCredentials(cfg.msteams));
}
export async function listConfiguredMessageProviders(
cfg: ClawdbotConfig,
): Promise<MessageProviderId[]> {
@@ -80,6 +88,7 @@ export async function listConfiguredMessageProviders(
if (isSlackConfigured(cfg)) providers.push("slack");
if (isSignalConfigured(cfg)) providers.push("signal");
if (isIMessageConfigured(cfg)) providers.push("imessage");
if (isMSTeamsConfigured(cfg)) providers.push("msteams");
return providers;
}