mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 04:57:40 +00:00
fix(discord): support applied_tags parameter for forum thread creation
Forum channels that require tags fail with "A tag is required" when creating threads because there was no way to pass tag IDs. Add appliedTags parameter to the thread-create action so forum posts can include required tags from the channel's available_tags list.
This commit is contained in:
committed by
Peter Steinberger
parent
5b64b96c6c
commit
7f4d1b7531
@@ -76,6 +76,44 @@ describe("sendMessageDiscord", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("passes applied_tags for forum threads", async () => {
|
||||
const { rest, getMock, postMock } = makeDiscordRest();
|
||||
getMock.mockResolvedValue({ type: ChannelType.GuildForum });
|
||||
postMock.mockResolvedValue({ id: "t1" });
|
||||
await createThreadDiscord(
|
||||
"chan1",
|
||||
{ name: "tagged post", appliedTags: ["tag1", "tag2"] },
|
||||
{ rest, token: "t" },
|
||||
);
|
||||
expect(postMock).toHaveBeenCalledWith(
|
||||
Routes.threads("chan1"),
|
||||
expect.objectContaining({
|
||||
body: {
|
||||
name: "tagged post",
|
||||
message: { content: "tagged post" },
|
||||
applied_tags: ["tag1", "tag2"],
|
||||
},
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it("omits applied_tags for non-forum threads", async () => {
|
||||
const { rest, getMock, postMock } = makeDiscordRest();
|
||||
getMock.mockResolvedValue({ type: ChannelType.GuildText });
|
||||
postMock.mockResolvedValue({ id: "t1" });
|
||||
await createThreadDiscord(
|
||||
"chan1",
|
||||
{ name: "thread", appliedTags: ["tag1"] },
|
||||
{ rest, token: "t" },
|
||||
);
|
||||
expect(postMock).toHaveBeenCalledWith(
|
||||
Routes.threads("chan1"),
|
||||
expect.objectContaining({
|
||||
body: expect.not.objectContaining({ applied_tags: expect.anything() }),
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it("falls back when channel lookup is unavailable", async () => {
|
||||
const { rest, getMock, postMock } = makeDiscordRest();
|
||||
getMock.mockRejectedValue(new Error("lookup failed"));
|
||||
|
||||
Reference in New Issue
Block a user