mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-23 23:22:32 +00:00
fix: LINE webhook verification 200; fix tsgo error (#16582) (thanks @arosstale)
This commit is contained in:
@@ -323,14 +323,14 @@ export async function monitorLineProvider(
|
||||
const signature = req.headers["x-line-signature"];
|
||||
|
||||
// LINE webhook verification sends POST {"events":[]} without a
|
||||
// signature header. Return 200 so the LINE Developers Console
|
||||
// signature header. Return 200 so the LINE Developers Console
|
||||
// "Verify" button succeeds.
|
||||
if (!signature || typeof signature !== "string") {
|
||||
try {
|
||||
const verifyBody = JSON.parse(rawBody) as WebhookRequestBody;
|
||||
if (Array.isArray(verifyBody.events) && verifyBody.events.length === 0) {
|
||||
logVerbose(
|
||||
"line: webhook verification request (empty events, no signature) — 200 OK",
|
||||
"line: webhook verification request (empty events, no signature) - 200 OK",
|
||||
);
|
||||
res.statusCode = 200;
|
||||
res.setHeader("Content-Type", "application/json");
|
||||
|
||||
@@ -48,7 +48,7 @@ export function createLineWebhookMiddleware(
|
||||
if (rawBody) {
|
||||
const body = parseWebhookBody(req, rawBody);
|
||||
if (body && Array.isArray(body.events) && body.events.length === 0) {
|
||||
logVerbose("line: webhook verification request (empty events, no signature) — 200 OK");
|
||||
logVerbose("line: webhook verification request (empty events, no signature) - 200 OK");
|
||||
res.status(200).json({ status: "ok" });
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -74,7 +74,10 @@ function parseQmdSessionScope(key?: string): ParsedQmdSessionScope {
|
||||
return { normalizedKey: normalized, chatType: "direct" };
|
||||
}
|
||||
|
||||
function normalizeQmdSessionKey(key: string): string | undefined {
|
||||
function normalizeQmdSessionKey(key?: string): string | undefined {
|
||||
if (!key) {
|
||||
return undefined;
|
||||
}
|
||||
const trimmed = key.trim();
|
||||
if (!trimmed) {
|
||||
return undefined;
|
||||
|
||||
Reference in New Issue
Block a user