fix: various fixes

This commit is contained in:
DecDuck
2025-05-30 10:29:55 +10:00
parent fca85633c1
commit 83a9b22d82
7 changed files with 21 additions and 17 deletions

View File

@ -28,24 +28,32 @@ export default defineEventHandler(async (h3) => {
const description = options.description;
const gameId = options.id;
const changes: Prisma.GameUpdateInput = {
const updateModel: Prisma.GameUpdateInput = {
mName: name,
mShortDescription: description,
};
// handle if user uploaded new icon
if (id) {
changes.mIconObjectId = id;
updateModel.mIconObjectId = id;
await pull();
} else {
dump();
}
// If the API call doesn't provide values, don't set them
for (const [key, value] of Object.entries(updateModel)) {
if (value === undefined) {
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
delete updateModel[key as keyof typeof updateModel];
}
}
const newObject = await prisma.game.update({
where: {
id: gameId,
},
data: changes,
data: updateModel,
});
return newObject;

View File

@ -18,7 +18,7 @@ export default defineEventHandler(async (h3) => {
throw createError({
statusCode: 404,
});
else if (result.userId !== userId)
if (result.userId !== userId)
throw createError({
statusCode: 404,
});

View File

@ -18,7 +18,7 @@ export default defineEventHandler(async (h3) => {
throw createError({
statusCode: 404,
});
else if (result.userId !== userId)
if (result.userId !== userId)
throw createError({
statusCode: 404,
});

View File

@ -234,7 +234,6 @@ export class MetadataHandler {
libraryBasePath,
},
});
// relate companies to game
await pullObjects();

View File

@ -53,11 +53,12 @@ class ScreenshotManager {
* @param id
*/
async delete(id: string) {
await prisma.screenshot.delete({
const deletedScreenshot = await prisma.screenshot.delete({
where: {
id,
},
});
await objectHandler.deleteAsSystem(deletedScreenshot.objectId);
}
/**
@ -74,7 +75,7 @@ class ScreenshotManager {
// TODO: set createAt to the time screenshot was taken
createdAt: new Date().toISOString(),
},
[`${userId}:read`, `${userId}:delete`],
[`${userId}:read`], // This is a system tracked object, so we don't want users to have direct write access to it
);
if (!saveStream)
throw createError({