imageFilenames and imageFilename, backend integration tests, frontend tests, removed username references
This commit is contained in:
@@ -21,7 +21,7 @@ const buildCommentTree = (comments, isAdmin = false) => {
|
||||
// Sanitize deleted comments for non-admin users
|
||||
if (commentJson.isDeleted && !isAdmin) {
|
||||
commentJson.content = '';
|
||||
commentJson.images = [];
|
||||
commentJson.imageFilenames = [];
|
||||
}
|
||||
|
||||
commentMap[comment.id] = { ...commentJson, replies: [] };
|
||||
@@ -252,7 +252,7 @@ router.post('/posts', authenticateToken, uploadForumPostImages, async (req, res,
|
||||
}
|
||||
|
||||
// Extract image filenames if uploaded
|
||||
const images = req.files ? req.files.map(file => file.filename) : [];
|
||||
const imageFilenames = req.files ? req.files.map(file => file.filename) : [];
|
||||
|
||||
// Initialize location fields
|
||||
let latitude = null;
|
||||
@@ -313,7 +313,7 @@ router.post('/posts', authenticateToken, uploadForumPostImages, async (req, res,
|
||||
content,
|
||||
category,
|
||||
authorId: req.user.id,
|
||||
images,
|
||||
imageFilenames,
|
||||
zipCode: zipCode || null,
|
||||
latitude,
|
||||
longitude
|
||||
@@ -936,14 +936,14 @@ router.post('/posts/:id/comments', authenticateToken, uploadForumCommentImages,
|
||||
}
|
||||
|
||||
// Extract image filenames if uploaded
|
||||
const images = req.files ? req.files.map(file => file.filename) : [];
|
||||
const imageFilenames = req.files ? req.files.map(file => file.filename) : [];
|
||||
|
||||
const comment = await ForumComment.create({
|
||||
postId: req.params.id,
|
||||
authorId: req.user.id,
|
||||
content,
|
||||
parentCommentId: parentCommentId || null,
|
||||
images
|
||||
imageFilenames
|
||||
});
|
||||
|
||||
// Increment comment count and update post's updatedAt to reflect activity
|
||||
@@ -955,7 +955,7 @@ router.post('/posts/:id/comments', authenticateToken, uploadForumCommentImages,
|
||||
{
|
||||
model: User,
|
||||
as: 'author',
|
||||
attributes: ['id', 'username', 'firstName', 'lastName', 'email']
|
||||
attributes: ['id', 'firstName', 'lastName', 'email']
|
||||
}
|
||||
]
|
||||
});
|
||||
@@ -1261,7 +1261,7 @@ router.delete('/admin/posts/:id', authenticateToken, requireAdmin, async (req, r
|
||||
{
|
||||
model: User,
|
||||
as: 'author',
|
||||
attributes: ['id', 'username', 'firstName', 'lastName', 'email']
|
||||
attributes: ['id', 'firstName', 'lastName', 'email']
|
||||
}
|
||||
]
|
||||
});
|
||||
@@ -1380,7 +1380,7 @@ router.delete('/admin/comments/:id', authenticateToken, requireAdmin, async (req
|
||||
{
|
||||
model: User,
|
||||
as: 'author',
|
||||
attributes: ['id', 'username', 'firstName', 'lastName', 'email']
|
||||
attributes: ['id', 'firstName', 'lastName', 'email']
|
||||
}
|
||||
]
|
||||
});
|
||||
@@ -1512,7 +1512,7 @@ router.patch('/admin/posts/:id/close', authenticateToken, requireAdmin, async (r
|
||||
{
|
||||
model: User,
|
||||
as: 'author',
|
||||
attributes: ['id', 'username', 'firstName', 'lastName', 'email']
|
||||
attributes: ['id', 'firstName', 'lastName', 'email']
|
||||
}
|
||||
]
|
||||
});
|
||||
@@ -1545,7 +1545,7 @@ router.patch('/admin/posts/:id/close', authenticateToken, requireAdmin, async (r
|
||||
(async () => {
|
||||
try {
|
||||
const admin = await User.findByPk(req.user.id, {
|
||||
attributes: ['id', 'username', 'firstName', 'lastName', 'email']
|
||||
attributes: ['id', 'firstName', 'lastName', 'email']
|
||||
});
|
||||
|
||||
// Get all unique participants (author + commenters)
|
||||
|
||||
Reference in New Issue
Block a user