feat(adapters): add sendPayload to batch-d adapters

This commit is contained in:
David Friedland
2026-02-28 15:36:08 -08:00
committed by Peter Steinberger
parent f1cab9c5e5
commit d06ee86292
6 changed files with 116 additions and 1 deletions

View File

@@ -518,6 +518,25 @@ export const zalouserPlugin: ChannelPlugin<ResolvedZalouserAccount> = {
chunker: chunkTextForOutbound,
chunkerMode: "text",
textChunkLimit: 2000,
sendPayload: async (ctx) => {
const urls = ctx.payload.mediaUrls?.length
? ctx.payload.mediaUrls
: ctx.payload.mediaUrl
? [ctx.payload.mediaUrl]
: [];
if (urls.length > 0) {
let lastResult;
for (let i = 0; i < urls.length; i++) {
lastResult = await zalouserPlugin.outbound!.sendMedia!({
...ctx,
text: i === 0 ? (ctx.payload.text ?? "") : "",
mediaUrl: urls[i],
});
}
return lastResult!;
}
return zalouserPlugin.outbound!.sendText!({ ...ctx });
},
sendText: async ({ to, text, accountId, cfg }) => {
const account = resolveZalouserAccountSync({ cfg: cfg, accountId });
const result = await sendMessageZalouser(to, text, { profile: account.profile });