Fix base64 body decoding for Slack interactivity payloads

This commit is contained in:
Adam Moussa 2026-04-10 18:11:54 -04:00
parent 941cd094fc
commit f769ea5872

View file

@ -100,9 +100,14 @@ function categorizePayments(payments) {
// --- Main handler ---
export const handler = async (event) => {
// Decode body — API Gateway may base64-encode it
let rawBody = event.body || "";
if (event.isBase64Encoded) {
rawBody = Buffer.from(rawBody, "base64").toString("utf-8");
}
// Slack sends block_actions as form-encoded: payload=<JSON>
let body;
const rawBody = event.body || "";
if (rawBody.startsWith("payload=")) {
body = JSON.parse(decodeURIComponent(rawBody.replace("payload=", "")));
} else {