fix(notes): необязательный заголовок, защита от двойного сохранения, Ctrl+Enter
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user