WhatsApp: move outbound session routing behind plugin boundary
parent
6ba15aadcc
commit
fa896704d2
@ -0,0 +1,26 @@
|
||||
import {
|
||||
buildChannelOutboundSessionRoute,
|
||||
type ChannelOutboundSessionRouteParams,
|
||||
} from "openclaw/plugin-sdk/core";
|
||||
import { isWhatsAppGroupJid, normalizeWhatsAppTarget } from "openclaw/plugin-sdk/whatsapp";
|
||||
|
||||
export function resolveWhatsAppOutboundSessionRoute(params: ChannelOutboundSessionRouteParams) {
|
||||
const normalized = normalizeWhatsAppTarget(params.target);
|
||||
if (!normalized) {
|
||||
return null;
|
||||
}
|
||||
const isGroup = isWhatsAppGroupJid(normalized);
|
||||
return buildChannelOutboundSessionRoute({
|
||||
cfg: params.cfg,
|
||||
agentId: params.agentId,
|
||||
channel: "whatsapp",
|
||||
accountId: params.accountId,
|
||||
peer: {
|
||||
kind: isGroup ? "group" : "direct",
|
||||
id: normalized,
|
||||
},
|
||||
chatType: isGroup ? "group" : "direct",
|
||||
from: normalized,
|
||||
to: normalized,
|
||||
});
|
||||
}
|
||||
Loading…
Reference in New Issue