feat(voicewake): route replies to last channel

This commit is contained in:
Peter Steinberger
2025-12-12 16:15:19 +00:00
parent 3f1bcac077
commit a524b9ae9b
15 changed files with 536 additions and 144 deletions

View File

@@ -10,6 +10,7 @@ import {
resolveSessionKey,
resolveStorePath,
saveSessionStore,
updateLastRoute,
} from "../config/sessions.js";
import { danger, isVerbose, logVerbose, success } from "../globals.js";
import { emitHeartbeatEvent } from "../infra/heartbeat-events.js";
@@ -849,6 +850,23 @@ export async function monitorWebProvider(
`\n[${tsDisplay}] ${fromDisplay} -> ${latest.to}: ${combinedBody}`,
);
if (latest.chatType !== "group") {
const sessionCfg = cfg.inbound?.reply?.session;
const mainKey = (sessionCfg?.mainKey ?? "main").trim() || "main";
const storePath = resolveStorePath(sessionCfg?.store);
const to = latest.senderE164
? normalizeE164(latest.senderE164)
: jidToE164(latest.from);
if (to) {
await updateLastRoute({
storePath,
sessionKey: mainKey,
channel: "whatsapp",
to,
});
}
}
const replyResult = await (replyResolver ?? getReplyFromConfig)(
{
Body: combinedBody,