Skip to content

Commit 88dda92

Browse files
committed
Add Webhook delivery completion event
1 parent 1f50372 commit 88dda92

File tree

2 files changed

+32
-2
lines changed

2 files changed

+32
-2
lines changed

lib/types.ts

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ export type WebhookEvent =
5959
| AccountLinkEvent
6060
| DeviceLinkEvent
6161
| DeviceUnlinkEvent
62-
| LINEThingsScenarioExecutionEvent;
62+
| LINEThingsScenarioExecutionEvent
63+
| DeliveryEvent;
6364

6465
export type EventBase = {
6566
/**
@@ -78,8 +79,18 @@ export type EventBase = {
7879
* Source user, group, or room object with information about the source of the event.
7980
*/
8081
source: EventSource;
82+
/**
83+
* Webhook event ID, an ID that uniquely identifies a Webhook event, in the form of a ULID string.
84+
*/
85+
webhookEventId: string;
86+
/**
87+
* Whether the webhook event is a resubmitted one or not
88+
*/
89+
deliveryContext: DeliveryContext;
8190
};
8291

92+
export type DeliveryContext = { isRedelivery: boolean };
93+
8394
export type EventSource = User | Group | Room;
8495

8596
export type User = { type: "user"; userId: string };
@@ -360,6 +371,21 @@ export type LINEThingsActionResult = {
360371
data?: string;
361372
};
362373

374+
/**
375+
* Completed Delivery Event
376+
* @see {@link https://developers.line.biz/en/docs/partner-docs/line-notification-messages/message-sending-complete-webhook-event/#receive-delivery-event}
377+
*/
378+
export type DeliveryEvent = {
379+
type: "delivery";
380+
/** A delivery object containing a hashed phone number string or a string specified by X-Line-Delivery-Tag. */
381+
delivery: Delivery;
382+
} & EventBase;
383+
384+
type Delivery = {
385+
/** A hashed phone number string or a string specified by X-Line-Delivery-Tag. */
386+
data: string;
387+
};
388+
363389
export type EventMessage =
364390
| TextEventMessage
365391
| ImageEventMessage

test/middleware.spec.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,16 @@ describe("middleware", () => {
2626
groupId: "test_group_id",
2727
type: "group",
2828
},
29+
webhookEventId: "test_webhook_event_id",
30+
deliveryContext: {
31+
isRedelivery: false,
32+
},
2933
timestamp: 0,
3034
mode: "active",
3135
type: "message",
3236
};
3337
const webhookSignature = {
34-
"X-Line-Signature": "GzU7H3qOXDzDD6cNcS/9otLzlLFxnYYriz62rNu5BDE=",
38+
"X-Line-Signature": "Ey7AjSuSI2GfTDQHICAiRLLJ+GSMseISNYaQ6qXSjrU=",
3539
};
3640

3741
const http = (headers: any = { ...webhookSignature }) =>

0 commit comments

Comments
 (0)