fix(adapters): restructure sendPayload media loop to avoid uninitialized lastResult

This commit is contained in:
David Friedland
2026-02-28 16:27:13 -08:00
committed by Peter Steinberger
parent d06ee86292
commit ebe54e6903
6 changed files with 44 additions and 20 deletions

View File

@@ -525,15 +525,19 @@ export const zalouserPlugin: ChannelPlugin<ResolvedZalouserAccount> = {
? [ctx.payload.mediaUrl]
: [];
if (urls.length > 0) {
let lastResult;
for (let i = 0; i < urls.length; i++) {
let lastResult = await zalouserPlugin.outbound!.sendMedia!({
...ctx,
text: ctx.payload.text ?? "",
mediaUrl: urls[0],
});
for (let i = 1; i < urls.length; i++) {
lastResult = await zalouserPlugin.outbound!.sendMedia!({
...ctx,
text: i === 0 ? (ctx.payload.text ?? "") : "",
text: "",
mediaUrl: urls[i],
});
}
return lastResult!;
return lastResult;
}
return zalouserPlugin.outbound!.sendText!({ ...ctx });
},