mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 17:28:28 +00:00
refactor(line): extract node webhook handler + shared verification
This commit is contained in:
15
src/line/webhook-utils.ts
Normal file
15
src/line/webhook-utils.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import type { WebhookRequestBody } from "@line/bot-sdk";
|
||||
|
||||
export function parseLineWebhookBody(rawBody: string): WebhookRequestBody | null {
|
||||
try {
|
||||
return JSON.parse(rawBody) as WebhookRequestBody;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
export function isLineWebhookVerificationRequest(
|
||||
body: WebhookRequestBody | null | undefined,
|
||||
): boolean {
|
||||
return !!body && Array.isArray(body.events) && body.events.length === 0;
|
||||
}
|
||||
Reference in New Issue
Block a user