Zalo: move outbound session routing behind plugin boundary
This commit is contained in:
parent
6816c76738
commit
33bcf11c3f
@ -35,6 +35,7 @@ import {
|
||||
} from "./accounts.js";
|
||||
import { zaloMessageActions } from "./actions.js";
|
||||
import { ZaloConfigSchema } from "./config-schema.js";
|
||||
import { resolveZaloOutboundSessionRoute } from "./session-route.js";
|
||||
import { zaloSetupAdapter } from "./setup-core.js";
|
||||
import { zaloSetupWizard } from "./setup-surface.js";
|
||||
import { collectZaloStatusIssues } from "./status-issues.js";
|
||||
@ -159,6 +160,7 @@ export const zaloPlugin: ChannelPlugin<ResolvedZaloAccount> = {
|
||||
actions: zaloMessageActions,
|
||||
messaging: {
|
||||
normalizeTarget: normalizeZaloMessagingTarget,
|
||||
resolveOutboundSessionRoute: (params) => resolveZaloOutboundSessionRoute(params),
|
||||
targetResolver: {
|
||||
looksLikeId: isNumericTargetId,
|
||||
hint: "<chatId>",
|
||||
|
||||
31
extensions/zalo/src/session-route.ts
Normal file
31
extensions/zalo/src/session-route.ts
Normal file
@ -0,0 +1,31 @@
|
||||
import {
|
||||
buildChannelOutboundSessionRoute,
|
||||
stripChannelTargetPrefix,
|
||||
stripTargetKindPrefix,
|
||||
type ChannelOutboundSessionRouteParams,
|
||||
} from "openclaw/plugin-sdk/core";
|
||||
|
||||
export function resolveZaloOutboundSessionRoute(params: ChannelOutboundSessionRouteParams) {
|
||||
const trimmed = stripChannelTargetPrefix(params.target, "zalo", "zl");
|
||||
if (!trimmed) {
|
||||
return null;
|
||||
}
|
||||
const isGroup = trimmed.toLowerCase().startsWith("group:");
|
||||
const peerId = stripTargetKindPrefix(trimmed);
|
||||
if (!peerId) {
|
||||
return null;
|
||||
}
|
||||
return buildChannelOutboundSessionRoute({
|
||||
cfg: params.cfg,
|
||||
agentId: params.agentId,
|
||||
channel: "zalo",
|
||||
accountId: params.accountId,
|
||||
peer: {
|
||||
kind: isGroup ? "group" : "direct",
|
||||
id: peerId,
|
||||
},
|
||||
chatType: isGroup ? "group" : "direct",
|
||||
from: isGroup ? `zalo:group:${peerId}` : `zalo:${peerId}`,
|
||||
to: `zalo:${peerId}`,
|
||||
});
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user