mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 02:11:23 +00:00
Slack: capture workflow button interaction metadata
This commit is contained in:
@@ -596,6 +596,53 @@ describe("registerSlackInteractionEvents", () => {
|
|||||||
expect(payload.selectedDateTime).toBe(1_771_700_200);
|
expect(payload.selectedDateTime).toBe(1_771_700_200);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("captures workflow button trigger metadata", async () => {
|
||||||
|
enqueueSystemEventMock.mockReset();
|
||||||
|
const { ctx, getHandler } = createContext();
|
||||||
|
registerSlackInteractionEvents({ ctx: ctx as never });
|
||||||
|
const handler = getHandler();
|
||||||
|
expect(handler).toBeTruthy();
|
||||||
|
|
||||||
|
const ack = vi.fn().mockResolvedValue(undefined);
|
||||||
|
await handler!({
|
||||||
|
ack,
|
||||||
|
body: {
|
||||||
|
user: { id: "U420" },
|
||||||
|
team: { id: "T420" },
|
||||||
|
channel: { id: "C420" },
|
||||||
|
message: { ts: "420.420" },
|
||||||
|
},
|
||||||
|
action: {
|
||||||
|
type: "workflow_button",
|
||||||
|
action_id: "openclaw:workflow",
|
||||||
|
block_id: "workflow_block",
|
||||||
|
text: { type: "plain_text", text: "Launch workflow" },
|
||||||
|
workflow: {
|
||||||
|
trigger_url: "https://slack.com/workflows/triggers/T420/12345",
|
||||||
|
workflow_id: "Wf12345",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(ack).toHaveBeenCalled();
|
||||||
|
expect(enqueueSystemEventMock).toHaveBeenCalledTimes(1);
|
||||||
|
const [eventText] = enqueueSystemEventMock.mock.calls[0] as [string];
|
||||||
|
const payload = JSON.parse(eventText.replace("Slack interaction: ", "")) as {
|
||||||
|
actionType?: string;
|
||||||
|
workflowTriggerUrl?: string;
|
||||||
|
workflowId?: string;
|
||||||
|
teamId?: string;
|
||||||
|
channelId?: string;
|
||||||
|
};
|
||||||
|
expect(payload).toMatchObject({
|
||||||
|
actionType: "workflow_button",
|
||||||
|
workflowTriggerUrl: "https://slack.com/workflows/triggers/T420/12345",
|
||||||
|
workflowId: "Wf12345",
|
||||||
|
teamId: "T420",
|
||||||
|
channelId: "C420",
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it("captures modal submissions and enqueues view submission event", async () => {
|
it("captures modal submissions and enqueues view submission event", async () => {
|
||||||
enqueueSystemEventMock.mockReset();
|
enqueueSystemEventMock.mockReset();
|
||||||
const { ctx, getViewHandler, resolveSessionKey } = createContext();
|
const { ctx, getViewHandler, resolveSessionKey } = createContext();
|
||||||
|
|||||||
@@ -43,6 +43,8 @@ type InteractionSummary = {
|
|||||||
teamId?: string;
|
teamId?: string;
|
||||||
triggerId?: string;
|
triggerId?: string;
|
||||||
responseUrl?: string;
|
responseUrl?: string;
|
||||||
|
workflowTriggerUrl?: string;
|
||||||
|
workflowId?: string;
|
||||||
channelId?: string;
|
channelId?: string;
|
||||||
messageTs?: string;
|
messageTs?: string;
|
||||||
threadTs?: string;
|
threadTs?: string;
|
||||||
@@ -165,6 +167,10 @@ function summarizeAction(
|
|||||||
selected_date_time?: number;
|
selected_date_time?: number;
|
||||||
value?: string;
|
value?: string;
|
||||||
rich_text_value?: unknown;
|
rich_text_value?: unknown;
|
||||||
|
workflow?: {
|
||||||
|
trigger_url?: string;
|
||||||
|
workflow_id?: string;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
const actionType = typed.type;
|
const actionType = typed.type;
|
||||||
const selectedUsers = uniqueNonEmptyStrings([
|
const selectedUsers = uniqueNonEmptyStrings([
|
||||||
@@ -239,6 +245,8 @@ function summarizeAction(
|
|||||||
inputUrl,
|
inputUrl,
|
||||||
richTextValue,
|
richTextValue,
|
||||||
richTextPreview,
|
richTextPreview,
|
||||||
|
workflowTriggerUrl: typed.workflow?.trigger_url,
|
||||||
|
workflowId: typed.workflow?.workflow_id,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user