fix(notes): необязательный заголовок, защита от двойного сохранения, Ctrl+Enter

This commit is contained in:
dev
2026-10-08 15:55:44 +03:00
parent 51f57f1524
commit 355feb234b
3 changed files with 16 additions and 6 deletions
+2 -2
View File
@@ -3312,7 +3312,7 @@ app.get('/api/notes', requireAuth, async (req, res) => {
app.post('/api/notes', requireAuth, async (req, res) => {
try {
const title = reqStr(req.body?.title, NOTE_TITLE_MAX);
const title = optStr(req.body?.title, NOTE_TITLE_MAX) || '';
const note = optStr(req.body?.note, NOTE_TEXT_MAX) || '';
let tags = '';
if (req.body?.tags !== undefined && req.body.tags !== null) {
@@ -3379,7 +3379,7 @@ app.put('/api/notes/:id', requireAuth, async (req, res) => {
const note = await findNote(req.user, id);
if (!note) return res.status(404).json({ error: 'Not found' });
if (note.forbidden) return res.status(403).json({ error: 'Нет доступа' });
const title = reqStr(req.body?.title, NOTE_TITLE_MAX);
const title = optStr(req.body?.title, NOTE_TITLE_MAX) || '';
const text = optStr(req.body?.note, NOTE_TEXT_MAX) || '';
let tags = '';
if (req.body?.tags !== undefined && req.body.tags !== null) {