This commit is contained in:
antanst 2025-10-09 11:39:30 +03:00
parent f4214c40da
commit 5ae05a9e68
3 changed files with 38 additions and 20 deletions

View file

@ -123,20 +123,27 @@ async function updateProjectTags(project, tagsData, userId) {
}
// POST /api/upload/project-image
router.post('/upload/project-image', requireAuth, upload.single('image'), (req, res) => {
try {
if (!req.file) {
return res.status(400).json({ error: 'No image file provided' });
}
router.post(
'/upload/project-image',
requireAuth,
upload.single('image'),
(req, res) => {
try {
if (!req.file) {
return res
.status(400)
.json({ error: 'No image file provided' });
}
// Return the relative URL that can be accessed from the frontend
const imageUrl = `/api/uploads/projects/${req.file.filename}`;
res.json({ imageUrl });
} catch (error) {
logError('Error uploading image:', error);
res.status(500).json({ error: 'Failed to upload image' });
// Return the relative URL that can be accessed from the frontend
const imageUrl = `/api/uploads/projects/${req.file.filename}`;
res.json({ imageUrl });
} catch (error) {
logError('Error uploading image:', error);
res.status(500).json({ error: 'Failed to upload image' });
}
}
});
);
// GET /api/projects
router.get('/projects', async (req, res) => {

View file

@ -2610,13 +2610,27 @@ router.delete(
// Whitelist of known valid table names to prevent SQL injection
const validTableNames = [
'tasks', 'projects', 'notes', 'users', 'tags', 'areas',
'permissions', 'actions', 'task_events', 'inbox_items',
'tasks_tags', 'notes_tags', 'projects_tags', 'Sessions'
'tasks',
'projects',
'notes',
'users',
'tags',
'areas',
'permissions',
'actions',
'task_events',
'inbox_items',
'tasks_tags',
'notes_tags',
'projects_tags',
'Sessions',
];
for (const table of allTables) {
if (table.name !== 'tasks' && validTableNames.includes(table.name)) {
if (
table.name !== 'tasks' &&
validTableNames.includes(table.name)
) {
try {
const fks = await sequelize.query(
`PRAGMA foreign_key_list(${table.name})`,

View file

@ -198,10 +198,7 @@ async function sendWelcomeMessage(token, chatId) {
resolve(false);
}
} catch (error) {
logError(
'Error parsing welcome message response:',
error
);
logError('Error parsing welcome message response:', error);
resolve(false);
}
});