Slack: attribute interaction confirmations and structured selects
This commit is contained in:
@@ -213,7 +213,7 @@ describe("registerSlackInteractionEvents", () => {
|
||||
blocks: [
|
||||
{
|
||||
type: "context",
|
||||
elements: [{ type: "mrkdwn", text: ":white_check_mark: *Canary* selected" }],
|
||||
elements: [{ type: "mrkdwn", text: ":white_check_mark: *Canary* selected by <@U555>" }],
|
||||
},
|
||||
],
|
||||
}),
|
||||
@@ -314,7 +314,10 @@ describe("registerSlackInteractionEvents", () => {
|
||||
{
|
||||
type: "context",
|
||||
elements: [
|
||||
{ type: "mrkdwn", text: ":white_check_mark: *Alpha, Beta, Gamma +1* selected" },
|
||||
{
|
||||
type: "mrkdwn",
|
||||
text: ":white_check_mark: *Alpha, Beta, Gamma +1* selected by <@U222>",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
@@ -423,7 +426,9 @@ describe("registerSlackInteractionEvents", () => {
|
||||
blocks: [
|
||||
{
|
||||
type: "context",
|
||||
elements: [{ type: "mrkdwn", text: ":white_check_mark: *2026-02-16* selected" }],
|
||||
elements: [
|
||||
{ type: "mrkdwn", text: ":white_check_mark: *2026-02-16* selected by <@U333>" },
|
||||
],
|
||||
},
|
||||
expect.anything(),
|
||||
expect.anything(),
|
||||
@@ -438,7 +443,7 @@ describe("registerSlackInteractionEvents", () => {
|
||||
blocks: [
|
||||
{
|
||||
type: "context",
|
||||
elements: [{ type: "mrkdwn", text: ":white_check_mark: *14:30* selected" }],
|
||||
elements: [{ type: "mrkdwn", text: ":white_check_mark: *14:30* selected by <@U333>" }],
|
||||
},
|
||||
],
|
||||
}),
|
||||
@@ -454,7 +459,9 @@ describe("registerSlackInteractionEvents", () => {
|
||||
elements: [
|
||||
{
|
||||
type: "mrkdwn",
|
||||
text: `:white_check_mark: *${new Date(selectedDateTimeEpoch * 1000).toISOString()}* selected`,
|
||||
text: `:white_check_mark: *${new Date(
|
||||
selectedDateTimeEpoch * 1000,
|
||||
).toISOString()}* selected by <@U333>`,
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
@@ -284,6 +284,14 @@ function formatInteractionSelectionLabel(params: {
|
||||
return params.actionId;
|
||||
}
|
||||
|
||||
function formatInteractionConfirmationText(params: {
|
||||
selectedLabel: string;
|
||||
userId?: string;
|
||||
}): string {
|
||||
const actor = params.userId?.trim() ? ` by <@${params.userId.trim()}>` : "";
|
||||
return `:white_check_mark: *${params.selectedLabel}* selected${actor}`;
|
||||
}
|
||||
|
||||
function summarizeViewState(values: unknown): ModalInputSummary[] {
|
||||
if (!values || typeof values !== "object") {
|
||||
return [];
|
||||
@@ -425,7 +433,12 @@ export function registerSlackInteractionEvents(params: { ctx: SlackMonitorContex
|
||||
if (typedBlock.type === "actions" && typedBlock.block_id === blockId) {
|
||||
return {
|
||||
type: "context",
|
||||
elements: [{ type: "mrkdwn", text: `:white_check_mark: *${selectedLabel}* selected` }],
|
||||
elements: [
|
||||
{
|
||||
type: "mrkdwn",
|
||||
text: formatInteractionConfirmationText({ selectedLabel, userId }),
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
return block;
|
||||
|
||||
Reference in New Issue
Block a user