Minor refactoring of freeURL condition check

Signed-off-by: Nicolas Dietrich <nidi@mailbox.org>
This commit is contained in:
Nicolas Dietrich 2021-01-22 15:36:47 +01:00
parent ea52746104
commit 3331c0947c

View file

@ -51,10 +51,12 @@ exports.newNote = function (req, res, body) {
} else if (!config.allowAnonymous) {
return errors.errorForbidden(res)
}
if (config.allowFreeURL && noteId && !config.forbiddenNoteIDs.includes(noteId)) {
req.alias = noteId
} else if (noteId) {
return req.method === 'POST' ? errors.errorForbidden(res) : errors.errorNotFound(res)
if (noteId) {
if (config.allowFreeURL && !config.forbiddenNoteIDs.includes(noteId)) {
req.alias = noteId
} else {
return req.method === 'POST' ? errors.errorForbidden(res) : errors.errorNotFound(res)
}
}
models.Note.create({
ownerId: owner,