This commit is contained in:
alma 2025-05-22 20:43:27 +02:00
parent bb73f26292
commit 36faf6c818

View File

@ -180,8 +180,27 @@ export async function POST(request: Request) {
});
if (existingMission) {
console.error('Mission with same name already exists:', name);
return NextResponse.json({ error: 'A mission with this name already exists' }, { status: 400 });
console.log('Mission exists, updating integration IDs:', {
missionId: existingMission.id,
name: existingMission.name,
rocketchatChannelId: body.rocketchatChannelId
});
// Update the existing mission with new integration IDs
const updateData: Prisma.MissionUncheckedUpdateInput = {
rocketChatChannelId: body.rocketchatChannelId || existingMission.rocketChatChannelId,
leantimeProjectId: body.leantimeProjectId || existingMission.leantimeProjectId,
outlineCollectionId: body.documentationCollectionId || existingMission.outlineCollectionId,
giteaRepositoryUrl: body.gitRepoUrl || existingMission.giteaRepositoryUrl
};
const updatedMission = await prisma.mission.update({
where: { id: existingMission.id },
data: updateData
});
console.log('Updated existing mission:', JSON.stringify(updatedMission, null, 2));
return NextResponse.json(updatedMission);
}
// Trigger n8n workflow first