Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {
BadRequestException,
Controller,
Get,
Headers,
Expand Down Expand Up @@ -40,10 +41,21 @@
@Headers() headers: Record<string, string | string[] | undefined>,
@Req() req: Request,
): Promise<WebhookReceiveResult> {
const requestBody = req.body;
let rawBody: Buffer;

if (Buffer.isBuffer(requestBody)) {
rawBody = requestBody;
} else if (typeof requestBody === 'string') {
rawBody = Buffer.from(requestBody, 'utf8');
} else {
throw new BadRequestException('Webhook body must be a raw buffer or string');

Check failure on line 52 in apps/claw-workspace-service/src/modules/webhooks/controllers/webhook-receiver.controller.ts

View workflow job for this annotation

GitHub Actions / Lint (workspace)

Controllers must not throw
}

return this.receiver.receive(
parseWebhookProvider(providerRaw),
connectorId === '_' ? null : connectorId,
Buffer.isBuffer(req.body) ? req.body : Buffer.from(JSON.stringify(req.body)),
rawBody,
headers,
(req.headers['x-forwarded-for'] as string | undefined) ?? req.ip ?? null,
);
Expand Down
Loading