This commit is contained in:
alma 2025-05-23 10:32:18 +02:00
parent 66140b9220
commit 50a710ba55

View File

@ -202,10 +202,27 @@ export async function POST(request: Request) {
if (!isN8nRequest) {
// Trigger n8n workflow
const n8nService = new N8nService();
// Prepare the data for n8n
const n8nData = {
...body,
creatorId: userId,
requestId
requestId,
// Ensure guardians and volunteers are properly formatted
guardians: body.guardians ? Object.entries(body.guardians).reduce((acc, [role, userId]) => {
if (userId) {
acc[role] = userId;
}
return acc;
}, {} as Record<string, string>) : {},
volunteers: Array.isArray(body.volunteers) ? body.volunteers.filter(Boolean) : [],
// Add metadata for n8n workflow
metadata: {
hasGuardians: Boolean(body.guardians && Object.keys(body.guardians).length > 0),
volunteersCount: Array.isArray(body.volunteers) ? body.volunteers.length : 0,
hasConfig: true,
configKeys: ['N8N_API_KEY', 'MISSION_API_URL']
}
};
try {