fix(auto-reply): run message_sending before inbound delivery

Run inbound auto-reply delivery through message_sending hooks before sending replies.

Co-authored-by: Jamil Zakirov <15848838+jzakirov@users.noreply.github.com>
This commit is contained in:
Jamil Zakirov
2026-04-25 07:37:35 +03:00
committed by GitHub
parent 04c5bbf33d
commit 52267a6b75
12 changed files with 346 additions and 8 deletions

View File

@@ -427,6 +427,9 @@ describe("dispatchTelegramMessage draft streaming", () => {
);
expect(dispatchReplyWithBufferedBlockDispatcher).toHaveBeenCalledWith(
expect.objectContaining({
dispatcherOptions: expect.objectContaining({
beforeDeliver: expect.any(Function),
}),
replyOptions: expect.objectContaining({
disableBlockStreaming: true,
}),

View File

@@ -761,6 +761,7 @@ export const dispatchTelegramMessage = async ({
cfg,
dispatcherOptions: {
...replyPipeline,
beforeDeliver: async (payload) => payload,
deliver: async (payload, info) => {
if (isDispatchSuperseded()) {
return;

View File

@@ -449,6 +449,9 @@ describe("registerTelegramNativeCommands — session metadata", () => {
await runPromise;
expect(replyMocks.dispatchReplyWithBufferedBlockDispatcher).toHaveBeenCalledTimes(1);
expect(
replyMocks.dispatchReplyWithBufferedBlockDispatcher.mock.calls[0]?.[0].dispatcherOptions,
).toEqual(expect.objectContaining({ beforeDeliver: expect.any(Function) }));
});
it("does not inject approval buttons for native command replies once the monitor owns approvals", async () => {

View File

@@ -940,6 +940,7 @@ export const registerTelegramNativeCommands = ({
cfg: executionCfg,
dispatcherOptions: {
...replyPipeline,
beforeDeliver: async (payload) => payload,
deliver: async (payload, _info) => {
if (
shouldSuppressLocalTelegramExecApprovalPrompt({