upload images to games

This commit is contained in:
DecDuck
2024-10-12 12:09:14 +11:00
parent 27070b6a4c
commit 9b7ee4e746
11 changed files with 348 additions and 12 deletions

View File

@ -28,7 +28,13 @@ export default defineEventHandler(async (h3) => {
if (!game)
throw createError({ statusCode: 400, statusMessage: "Invalid game ID" });
game.mImageLibrary = game.mImageLibrary.filter((e) => e != imageId);
const imageIndex = game.mImageLibrary.findIndex((e) => e == imageId);
if (imageIndex == -1)
throw createError({ statusCode: 400, statusMessage: "Image not found" });
game.mImageLibrary.splice(imageIndex, 1);
await h3.context.objects.delete(imageId);
if (game.mBannerId === imageId) {
game.mBannerId = game.mImageLibrary[0];
}