refactor(synology-chat): thread command authorization from webhook gate

This commit is contained in:
Peter Steinberger
2026-03-07 16:48:42 +00:00
parent 44881b0222
commit b393b9e8ff
3 changed files with 6 additions and 1 deletions

View File

@@ -282,7 +282,7 @@ export function createSynologyChatPlugin() {
Surface: CHANNEL_ID,
ConversationLabel: msg.senderName || msg.from,
Timestamp: Date.now(),
CommandAuthorized: true,
CommandAuthorized: msg.commandAuthorized,
});
// Dispatch via the SDK's buffered block dispatcher

View File

@@ -237,6 +237,7 @@ describe("createWebhookHandler", () => {
body: "Hello from json",
from: "123",
senderName: "json-user",
commandAuthorized: true,
}),
);
});
@@ -396,6 +397,7 @@ describe("createWebhookHandler", () => {
senderName: "testuser",
provider: "synology-chat",
chatType: "direct",
commandAuthorized: true,
}),
);
});
@@ -422,6 +424,7 @@ describe("createWebhookHandler", () => {
expect(deliver).toHaveBeenCalledWith(
expect.objectContaining({
body: expect.stringContaining("[FILTERED]"),
commandAuthorized: true,
}),
);
});

View File

@@ -225,6 +225,7 @@ export interface WebhookHandlerDeps {
chatType: string;
sessionKey: string;
accountId: string;
commandAuthorized: boolean;
/** Chat API user_id for sending replies (may differ from webhook user_id) */
chatUserId?: string;
}) => Promise<string | null>;
@@ -364,6 +365,7 @@ export function createWebhookHandler(deps: WebhookHandlerDeps) {
chatType: "direct",
sessionKey,
accountId: account.accountId,
commandAuthorized: auth.allowed,
chatUserId: replyUserId,
});