mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 09:40:43 +00:00
fix(slack): preserve real thread anchors
This commit is contained in:
@@ -61,11 +61,19 @@ const slackMessaging: ChannelMessagingAdapter = {
|
||||
|
||||
const slackThreading: ChannelThreadingAdapter = {
|
||||
resolveReplyTransport: ({ threadId, replyToId }) => ({
|
||||
replyToId: replyToId ?? (threadId != null && threadId !== "" ? String(threadId) : undefined),
|
||||
replyToId: resolveSlackThreadTsCandidate(replyToId) ?? resolveSlackThreadTsCandidate(threadId),
|
||||
threadId: null,
|
||||
}),
|
||||
};
|
||||
|
||||
function resolveSlackThreadTsCandidate(value?: string | number | null): string | undefined {
|
||||
if (typeof value !== "string") {
|
||||
return undefined;
|
||||
}
|
||||
const normalized = value.trim();
|
||||
return /^\d+\.\d+$/.test(normalized) ? normalized : undefined;
|
||||
}
|
||||
|
||||
const mattermostThreading: ChannelThreadingAdapter = {
|
||||
resolveReplyTransport: ({ threadId, replyToId }) => ({
|
||||
replyToId: replyToId ?? (threadId != null && threadId !== "" ? String(threadId) : undefined),
|
||||
@@ -489,6 +497,21 @@ describe("routeReply", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("uses Slack threadId when routed replyToId is an internal message id", async () => {
|
||||
await routeReply({
|
||||
payload: { text: "hi", replyToId: "msg-internal-1" },
|
||||
channel: "slack",
|
||||
to: "channel:C123",
|
||||
threadId: "1710000000.9999",
|
||||
cfg: {} as never,
|
||||
});
|
||||
expectLastDelivery({
|
||||
channel: "slack",
|
||||
replyToId: "1710000000.9999",
|
||||
threadId: null,
|
||||
});
|
||||
});
|
||||
|
||||
it("uses threadId as replyToId for Mattermost when replyToId is missing", async () => {
|
||||
await routeReply({
|
||||
payload: { text: "hi" },
|
||||
|
||||
Reference in New Issue
Block a user