feat(quest): add support for private images in answers
This commit is contained in:
@@ -101,7 +101,8 @@ export default defineEventHandler(async (event) => {
|
||||
.mime(['image/png', 'image/jpeg', 'image/jpg'])
|
||||
.max(10_000_000)
|
||||
.optional(),
|
||||
final: zh.boolAsString.optional()
|
||||
final: zh.boolAsString.optional(),
|
||||
private: zh.boolAsString.default(false)
|
||||
})
|
||||
.parse(formDataObj);
|
||||
|
||||
@@ -110,7 +111,8 @@ export default defineEventHandler(async (event) => {
|
||||
? quest.answers![0]!
|
||||
: {
|
||||
updatedAt: null,
|
||||
id: null
|
||||
id: null,
|
||||
picture: null
|
||||
};
|
||||
|
||||
if (
|
||||
@@ -158,7 +160,8 @@ export default defineEventHandler(async (event) => {
|
||||
const file = await tx.file.create({
|
||||
data: {
|
||||
...picture,
|
||||
answerId: prevAnswer.id
|
||||
answerId: prevAnswer.id,
|
||||
private: data.private
|
||||
},
|
||||
select: { id: true }
|
||||
});
|
||||
@@ -190,6 +193,7 @@ export default defineEventHandler(async (event) => {
|
||||
data: {
|
||||
...picture,
|
||||
answerId: answer.id,
|
||||
private: data.private,
|
||||
answers: {
|
||||
connect: answer
|
||||
}
|
||||
@@ -210,6 +214,16 @@ export default defineEventHandler(async (event) => {
|
||||
lang: data.lang
|
||||
}
|
||||
});
|
||||
if (prevAnswer.picture) {
|
||||
await prisma.file.update({
|
||||
where: {
|
||||
id: prevAnswer.picture.id
|
||||
},
|
||||
data: {
|
||||
private: data.private
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
await prisma.questAnswer.create({
|
||||
data: {
|
||||
|
||||
Reference in New Issue
Block a user