mirror of
https://github.com/moltbot/moltbot.git
synced 2026-04-21 05:32:53 +00:00
Slack: route live DM replies to channel
This commit is contained in:
committed by
Peter Steinberger
parent
25da786c68
commit
379f0d78e6
@@ -379,6 +379,19 @@ describe("slack prepareSlackMessage inbound contract", () => {
|
||||
expectMainScopedDmClassification(prepared, { includeFromCheck: true });
|
||||
});
|
||||
|
||||
it("uses the concrete DM channel as the live reply target while keeping user-scoped routing", async () => {
|
||||
const prepared = await prepareMessageWith(
|
||||
createDmScopeMainSlackCtx(),
|
||||
createSlackAccount(),
|
||||
createMainScopedDmMessage({}),
|
||||
);
|
||||
|
||||
expect(prepared).toBeTruthy();
|
||||
expect(prepared!.replyTarget).toBe("channel:D0ACP6B1T8V");
|
||||
expect(prepared!.ctxPayload.To).toBe("user:U1");
|
||||
expect(prepared!.ctxPayload.NativeChannelId).toBe("D0ACP6B1T8V");
|
||||
});
|
||||
|
||||
it("classifies D-prefix DMs when channel_type is missing", async () => {
|
||||
const message = createMainScopedDmMessage({});
|
||||
delete message.channel_type;
|
||||
|
||||
@@ -800,7 +800,11 @@ export async function prepareSlackMessage(params: {
|
||||
},
|
||||
});
|
||||
|
||||
const replyTarget = ctxPayload.To ?? undefined;
|
||||
// Live DM replies should target the concrete Slack DM channel id we just
|
||||
// received on. This avoids depending on a follow-up conversations.open
|
||||
// round-trip for the normal reply path while keeping persisted routing
|
||||
// metadata user-scoped for later session deliveries.
|
||||
const replyTarget = isDirectMessage ? `channel:${message.channel}` : (ctxPayload.To ?? undefined);
|
||||
if (!replyTarget) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user