Skip to content

Commit

Permalink
Fix #23 delete_original as sole attribute of respond
Browse files Browse the repository at this point in the history
  • Loading branch information
seratch committed Sep 10, 2024
1 parent a277b4b commit fd4598f
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
7 changes: 5 additions & 2 deletions src/client/webhook-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,17 @@ export class WebhookSender {

export const ResponseUrlSender = WebhookSender;

export interface WebhookParams {
export interface WebhookPostUpdateParams {
response_type?: "ephemeral" | "in_channel";
text: string;
blocks?: AnyMessageBlock[];
attachments?: MessageAttachment[];
metadata?: MessageMetadata;
replace_original?: boolean;
delete_original?: boolean;
unfurl_links?: boolean;
unfurl_media?: boolean;
}
export interface WebhookDeleteParams {
delete_original: boolean;
}
export type WebhookParams = WebhookPostUpdateParams | WebhookDeleteParams;
7 changes: 5 additions & 2 deletions src_deno/client/webhook-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,17 @@ export class WebhookSender {

export const ResponseUrlSender = WebhookSender;

export interface WebhookParams {
export interface WebhookPostUpdateParams {
response_type?: "ephemeral" | "in_channel";
text: string;
blocks?: AnyMessageBlock[];
attachments?: MessageAttachment[];
metadata?: MessageMetadata;
replace_original?: boolean;
delete_original?: boolean;
unfurl_links?: boolean;
unfurl_media?: boolean;
}
export interface WebhookDeleteParams {
delete_original: boolean;
}
export type WebhookParams = WebhookPostUpdateParams | WebhookDeleteParams;
20 changes: 20 additions & 0 deletions test/webhook-params.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { assert, test, describe } from "vitest";
import { WebhookParams } from "../src/index";

describe("WebhookParams", () => {
test("support all patterns", async () => {
const post: WebhookParams = {
text: "Hi there!",
};
assert(post.replace_original === undefined);
const update: WebhookParams = {
text: "Hi there!",
replace_original: true,
};
assert(update.replace_original === true);
const del: WebhookParams = {
delete_original: true,
};
assert(del.delete_original);
});
});

0 comments on commit fd4598f

Please sign in to comment.