delete image endpoint + r2 deletion

This commit is contained in:
Devin Zuczek
2026-07-17 17:59:33 -04:00
parent 9065bf5e54
commit bbd702faf1
3 changed files with 95 additions and 1 deletions
+13
View File
@@ -181,6 +181,19 @@ export async function getImageByName(db: D1Database, name: string): Promise<Save
return row ? (JSON.parse(row.data) as SavedImage) : null
}
/**
* Delete an image's metadata row plus any per-player interactions (cheers) recorded
* against it, in one batch — the row keyed by ImageName (the R2 key), its interactions
* by the image's `Id`. Authorization and removing the object from R2 are the caller's
* responsibility (see the deletesaved route).
*/
export async function deleteImage(db: D1Database, image: SavedImage): Promise<void> {
await db.batch([
db.prepare('DELETE FROM image WHERE image_name = ?1').bind(image.ImageName),
db.prepare('DELETE FROM image_interaction WHERE saved_image_id = ?1').bind(image.Id),
])
}
/**
* The public images taken in a room, for the room's photo feed. Only publicly
* accessible images (Accessibility === 1) are returned. `filter` narrows by