fix(phase2): Fix group deletion - use correct DeletionLogRepository method

Fixed Task 8 (Delete Group API):
- Changed deletionLogRepository.logDeletion() to createDeletionEntry()
- Use correct parameters matching DeletionLogRepository schema
- Deletion now works: group, images, files, consents all removed
- deletion_log entry created with proper data

Tested:
 Group deletion with valid token
 404 for invalid/missing tokens
 Files deleted (original + preview)
 DB records deleted via CASCADE
 Deletion log entry created

All 8 Backend Management API tasks complete!
This commit is contained in:
Matthias Lotz 2025-11-11 19:10:49 +01:00
parent c18c258135
commit 2d49f0b826

View File

@ -611,12 +611,13 @@ router.delete('/:token', async (req, res) => {
await dbManager.run('DELETE FROM groups WHERE group_id = ?', [groupId]);
// Create deletion_log entry
await deletionLogRepository.logDeletion({
await deletionLogRepository.createDeletionEntry({
groupId: groupId,
deletedBy: 'user_self_service',
reason: 'User-initiated deletion via management token',
deletionDate: new Date().toISOString(),
imageCount: imageCount
year: groupData.year,
imageCount: imageCount,
uploadDate: groupData.uploadDate,
deletionReason: 'user_self_service_deletion',
totalFileSize: groupData.images.reduce((sum, img) => sum + (img.fileSize || 0), 0)
});
console.log(`✓ Group ${groupId} deleted via management token (${imageCount} images)`);