images for forum and forum comments
This commit is contained in:
@@ -1111,7 +1111,7 @@ router.post('/posts/:id/comments', authenticateToken, async (req, res, next) =>
|
||||
// PUT /api/forum/comments/:id - Edit comment
|
||||
router.put('/comments/:id', authenticateToken, async (req, res, next) => {
|
||||
try {
|
||||
const { content } = req.body;
|
||||
const { content, imageFilenames: rawImageFilenames } = req.body;
|
||||
const comment = await ForumComment.findByPk(req.params.id);
|
||||
|
||||
if (!comment) {
|
||||
@@ -1126,7 +1126,19 @@ router.put('/comments/:id', authenticateToken, async (req, res, next) => {
|
||||
return res.status(400).json({ error: 'Cannot edit deleted comment' });
|
||||
}
|
||||
|
||||
await comment.update({ content });
|
||||
const updateData = { content };
|
||||
|
||||
// Handle image filenames if provided
|
||||
if (rawImageFilenames !== undefined) {
|
||||
const imageFilenamesArray = Array.isArray(rawImageFilenames) ? rawImageFilenames : [];
|
||||
const keyValidation = validateS3Keys(imageFilenamesArray, 'forum', { maxKeys: IMAGE_LIMITS.forum });
|
||||
if (!keyValidation.valid) {
|
||||
return res.status(400).json({ error: keyValidation.error });
|
||||
}
|
||||
updateData.imageFilenames = imageFilenamesArray;
|
||||
}
|
||||
|
||||
await comment.update(updateData);
|
||||
|
||||
const updatedComment = await ForumComment.findByPk(comment.id, {
|
||||
include: [
|
||||
|
||||
Reference in New Issue
Block a user