Add action_type to submission items

This commit is contained in:
gpt-engineer-app[bot]
2025-10-13 18:31:29 +00:00
parent a66bf59a55
commit fc9ba92e74
4 changed files with 38 additions and 2 deletions

View File

@@ -133,17 +133,22 @@ async function detectPhotoChanges(submissionId: string): Promise<PhotoChange[]>
* Detects what changed between original_data and item_data
*/
export async function detectChanges(
item: { item_data?: any; original_data?: any; item_type: string },
item: { item_data?: any; original_data?: any; item_type: string; action_type?: string },
submissionId?: string
): Promise<ChangesSummary> {
const itemData = item.item_data || {};
const originalData = item.original_data || {};
// Determine action type - special handling for photo_delete
// Determine action type - prioritize explicit action_type field to preserve submission intent
let action: 'create' | 'edit' | 'delete' = 'edit';
if (item.item_type === 'photo_delete' || itemData.action === 'delete' || itemData.deleted) {
action = 'delete';
} else if (item.action_type) {
// Use explicit action_type if set (preserves original submission intent even after moderator edits)
action = item.action_type as 'create' | 'edit' | 'delete';
} else if (!originalData || Object.keys(originalData).length === 0) {
// Fall back to inference for backwards compatibility
action = 'create';
}