diff --git a/lib/web/note/controller.js b/lib/web/note/controller.js index 45aea9e21..94bfa0e2c 100644 --- a/lib/web/note/controller.js +++ b/lib/web/note/controller.js @@ -119,7 +119,7 @@ exports.doAction = function (req, res, next) { default: return res.redirect(config.serverURL + '/' + noteId) } - }) + }, null, false) } exports.downloadMarkdown = function (req, res, note) { diff --git a/lib/web/note/util.js b/lib/web/note/util.js index 574385153..effeb41c7 100644 --- a/lib/web/note/util.js +++ b/lib/web/note/util.js @@ -5,7 +5,7 @@ const errors = require('../../errors') const fs = require('fs') const path = require('path') -exports.findNote = function (req, res, callback, include) { +exports.findNote = function (req, res, callback, include, createIfNotFound = true) { const id = req.params.noteId || req.params.shortid models.Note.parseNoteId(id, function (err, _id) { if (err) { @@ -18,9 +18,12 @@ exports.findNote = function (req, res, callback, include) { }, include: include || null }).then(function (note) { - if (!note) { + if (!note && createIfNotFound) { return exports.newNote(req, res, '') } + if (!note && !createIfNotFound) { + return errors.errorNotFound(res) + } if (!exports.checkViewPermission(req, note)) { return errors.errorForbidden(res) } else {