feat: add matrix channel plugin
This commit is contained in:
@@ -18,6 +18,12 @@ import type { OutboundChannel } from "./targets.js";
|
||||
export type { NormalizedOutboundPayload } from "./payloads.js";
|
||||
export { normalizeOutboundPayloads } from "./payloads.js";
|
||||
|
||||
type SendMatrixMessage = (
|
||||
to: string,
|
||||
text: string,
|
||||
opts?: { mediaUrl?: string; replyToId?: string; threadId?: string; timeoutMs?: number },
|
||||
) => Promise<{ messageId: string; roomId: string }>;
|
||||
|
||||
export type OutboundSendDeps = {
|
||||
sendWhatsApp?: typeof sendMessageWhatsApp;
|
||||
sendTelegram?: typeof sendMessageTelegram;
|
||||
@@ -25,6 +31,7 @@ export type OutboundSendDeps = {
|
||||
sendSlack?: typeof sendMessageSlack;
|
||||
sendSignal?: typeof sendMessageSignal;
|
||||
sendIMessage?: typeof sendMessageIMessage;
|
||||
sendMatrix?: SendMatrixMessage;
|
||||
sendMSTeams?: (
|
||||
to: string,
|
||||
text: string,
|
||||
@@ -37,6 +44,7 @@ export type OutboundDeliveryResult = {
|
||||
messageId: string;
|
||||
chatId?: string;
|
||||
channelId?: string;
|
||||
roomId?: string;
|
||||
conversationId?: string;
|
||||
timestamp?: number;
|
||||
toJid?: string;
|
||||
@@ -67,7 +75,7 @@ async function createChannelHandler(params: {
|
||||
to: string;
|
||||
accountId?: string;
|
||||
replyToId?: string | null;
|
||||
threadId?: number | null;
|
||||
threadId?: string | number | null;
|
||||
deps?: OutboundSendDeps;
|
||||
gifPlayback?: boolean;
|
||||
}): Promise<ChannelHandler> {
|
||||
@@ -99,7 +107,7 @@ function createPluginHandler(params: {
|
||||
to: string;
|
||||
accountId?: string;
|
||||
replyToId?: string | null;
|
||||
threadId?: number | null;
|
||||
threadId?: string | number | null;
|
||||
deps?: OutboundSendDeps;
|
||||
gifPlayback?: boolean;
|
||||
}): ChannelHandler | null {
|
||||
@@ -144,7 +152,7 @@ export async function deliverOutboundPayloads(params: {
|
||||
accountId?: string;
|
||||
payloads: ReplyPayload[];
|
||||
replyToId?: string | null;
|
||||
threadId?: number | null;
|
||||
threadId?: string | number | null;
|
||||
deps?: OutboundSendDeps;
|
||||
gifPlayback?: boolean;
|
||||
abortSignal?: AbortSignal;
|
||||
|
||||
@@ -10,6 +10,7 @@ export type OutboundDeliveryJson = {
|
||||
mediaUrl: string | null;
|
||||
chatId?: string;
|
||||
channelId?: string;
|
||||
roomId?: string;
|
||||
conversationId?: string;
|
||||
timestamp?: number;
|
||||
toJid?: string;
|
||||
@@ -20,6 +21,7 @@ type OutboundDeliveryMeta = {
|
||||
messageId?: string;
|
||||
chatId?: string;
|
||||
channelId?: string;
|
||||
roomId?: string;
|
||||
conversationId?: string;
|
||||
timestamp?: number;
|
||||
toJid?: string;
|
||||
@@ -42,6 +44,7 @@ export function formatOutboundDeliverySummary(
|
||||
|
||||
if ("chatId" in result) return `${base} (chat ${result.chatId})`;
|
||||
if ("channelId" in result) return `${base} (channel ${result.channelId})`;
|
||||
if ("roomId" in result) return `${base} (room ${result.roomId})`;
|
||||
if ("conversationId" in result) return `${base} (conversation ${result.conversationId})`;
|
||||
return base;
|
||||
}
|
||||
@@ -69,6 +72,9 @@ export function buildOutboundDeliveryJson(params: {
|
||||
if (result && "channelId" in result && result.channelId !== undefined) {
|
||||
payload.channelId = result.channelId;
|
||||
}
|
||||
if (result && "roomId" in result && result.roomId !== undefined) {
|
||||
payload.roomId = result.roomId;
|
||||
}
|
||||
if (result && "conversationId" in result && result.conversationId !== undefined) {
|
||||
payload.conversationId = result.conversationId;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user