missions api2 gitea
This commit is contained in:
parent
c4026709cb
commit
10a970ee62
@ -4,6 +4,7 @@ import { authOptions } from "@/app/api/auth/options";
|
|||||||
import { prisma } from '@/lib/prisma';
|
import { prisma } from '@/lib/prisma';
|
||||||
import { deleteMissionLogo } from '@/lib/mission-uploads';
|
import { deleteMissionLogo } from '@/lib/mission-uploads';
|
||||||
import { getPublicUrl, S3_CONFIG } from '@/lib/s3';
|
import { getPublicUrl, S3_CONFIG } from '@/lib/s3';
|
||||||
|
import { IntegrationService } from '@/lib/services/integration-service';
|
||||||
|
|
||||||
// Helper function to check authentication
|
// Helper function to check authentication
|
||||||
async function checkAuth(request: Request) {
|
async function checkAuth(request: Request) {
|
||||||
@ -281,6 +282,38 @@ export async function DELETE(request: Request, props: { params: Promise<{ missio
|
|||||||
return NextResponse.json({ error: 'Mission not found or not authorized to delete' }, { status: 404 });
|
return NextResponse.json({ error: 'Mission not found or not authorized to delete' }, { status: 404 });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Initialize integration service to clean up external resources
|
||||||
|
const integrationService = new IntegrationService();
|
||||||
|
|
||||||
|
// Extract integration IDs
|
||||||
|
const leantimeProjectId = mission.leantimeProjectId ? parseInt(mission.leantimeProjectId) : undefined;
|
||||||
|
const outlineCollectionId = mission.outlineCollectionId || undefined;
|
||||||
|
const rocketChatChannelId = mission.rocketChatChannelId || undefined;
|
||||||
|
const giteaRepositoryUrl = mission.giteaRepositoryUrl || undefined;
|
||||||
|
|
||||||
|
// Log the external resources being cleaned up
|
||||||
|
console.log('Cleaning up external resources for mission:', {
|
||||||
|
missionId,
|
||||||
|
leantimeProjectId,
|
||||||
|
outlineCollectionId,
|
||||||
|
rocketChatChannelId,
|
||||||
|
giteaRepositoryUrl
|
||||||
|
});
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Perform rollback of all external integrations
|
||||||
|
await integrationService.rollbackIntegrations(
|
||||||
|
leantimeProjectId,
|
||||||
|
outlineCollectionId,
|
||||||
|
rocketChatChannelId,
|
||||||
|
giteaRepositoryUrl
|
||||||
|
);
|
||||||
|
console.log('Successfully cleaned up external resources for mission:', missionId);
|
||||||
|
} catch (integrationError) {
|
||||||
|
console.error('Error cleaning up external integrations:', integrationError);
|
||||||
|
// Continue with mission deletion even if integration cleanup fails
|
||||||
|
}
|
||||||
|
|
||||||
// Delete logo if exists
|
// Delete logo if exists
|
||||||
if (mission.logo) {
|
if (mission.logo) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user