mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-12 07:20:45 +00:00
fix(mattermost): read replyTo param in plugin handleAction send (#41176)
Merged via squash.
Prepared head SHA: 33cac4c33f
Co-authored-by: hnykda <2741256+hnykda@users.noreply.github.com>
Co-authored-by: mukhtharcm <56378562+mukhtharcm@users.noreply.github.com>
Reviewed-by: @mukhtharcm
This commit is contained in:
@@ -214,6 +214,57 @@ describe("mattermostPlugin", () => {
|
||||
]);
|
||||
expect(result?.details).toEqual({});
|
||||
});
|
||||
|
||||
it("maps replyTo to replyToId for send actions", async () => {
|
||||
const cfg = createMattermostTestConfig();
|
||||
|
||||
await mattermostPlugin.actions?.handleAction?.({
|
||||
channel: "mattermost",
|
||||
action: "send",
|
||||
params: {
|
||||
to: "channel:CHAN1",
|
||||
message: "hello",
|
||||
replyTo: "post-root",
|
||||
},
|
||||
cfg,
|
||||
accountId: "default",
|
||||
} as any);
|
||||
|
||||
expect(sendMessageMattermostMock).toHaveBeenCalledWith(
|
||||
"channel:CHAN1",
|
||||
"hello",
|
||||
expect.objectContaining({
|
||||
accountId: "default",
|
||||
replyToId: "post-root",
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it("falls back to trimmed replyTo when replyToId is blank", async () => {
|
||||
const cfg = createMattermostTestConfig();
|
||||
|
||||
await mattermostPlugin.actions?.handleAction?.({
|
||||
channel: "mattermost",
|
||||
action: "send",
|
||||
params: {
|
||||
to: "channel:CHAN1",
|
||||
message: "hello",
|
||||
replyToId: " ",
|
||||
replyTo: " post-root ",
|
||||
},
|
||||
cfg,
|
||||
accountId: "default",
|
||||
} as any);
|
||||
|
||||
expect(sendMessageMattermostMock).toHaveBeenCalledWith(
|
||||
"channel:CHAN1",
|
||||
"hello",
|
||||
expect.objectContaining({
|
||||
accountId: "default",
|
||||
replyToId: "post-root",
|
||||
}),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("outbound", () => {
|
||||
|
||||
@@ -157,7 +157,9 @@ const mattermostMessageActions: ChannelMessageActionAdapter = {
|
||||
}
|
||||
|
||||
const message = typeof params.message === "string" ? params.message : "";
|
||||
const replyToId = typeof params.replyToId === "string" ? params.replyToId : undefined;
|
||||
// Match the shared runner semantics: trim empty reply IDs away before
|
||||
// falling back from replyToId to replyTo on direct plugin calls.
|
||||
const replyToId = readMattermostReplyToId(params);
|
||||
const resolvedAccountId = accountId || undefined;
|
||||
|
||||
const mediaUrl =
|
||||
@@ -201,6 +203,18 @@ const meta = {
|
||||
quickstartAllowFrom: true,
|
||||
} as const;
|
||||
|
||||
function readMattermostReplyToId(params: Record<string, unknown>): string | undefined {
|
||||
const readNormalizedValue = (value: unknown) => {
|
||||
if (typeof value !== "string") {
|
||||
return undefined;
|
||||
}
|
||||
const trimmed = value.trim();
|
||||
return trimmed || undefined;
|
||||
};
|
||||
|
||||
return readNormalizedValue(params.replyToId) ?? readNormalizedValue(params.replyTo);
|
||||
}
|
||||
|
||||
function normalizeAllowEntry(entry: string): string {
|
||||
return entry
|
||||
.trim()
|
||||
|
||||
Reference in New Issue
Block a user