mirror of
https://github.com/Drop-OSS/drop.git
synced 2025-11-13 00:02:37 +10:00
fix: various fixes
This commit is contained in:
@ -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;
|
||||
|
||||
@ -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,
|
||||
});
|
||||
|
||||
@ -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,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user