feat: option to disable note creation
Some checks failed
Build & run tests / Node ${{ matrix.node }} (18) (push) Has been cancelled
Build & run tests / Node ${{ matrix.node }} (20) (push) Has been cancelled
Lint / Lint files (push) Has been cancelled

The abuse of the demo instance required us to disallow note creation

Signed-off-by: Erik Michelson <github@erik.michelson.eu>
Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
Erik Michelson 2024-07-18 00:25:20 +02:00 committed by Tilman Vatteroth
parent c85b11463d
commit 858d7bf5d1
9 changed files with 20 additions and 2 deletions

View file

@ -82,6 +82,9 @@ exports.showNote = function (req, res, next) {
}
exports.createFromPOST = function (req, res, next) {
if (config.disableNoteCreation) {
return errors.errorForbidden(res)
}
let body = ''
if (req.body && req.body.length > config.documentMaxLength) {
return errors.errorTooLong(res)

View file

@ -19,7 +19,11 @@ exports.findNote = function (req, res, callback, include = null, createIfNotFoun
include: include || null
}).then(function (note) {
if (!note && createIfNotFound) {
return exports.newNote(req, res, '')
if (config.disableNoteCreation) {
return errors.errorNotFound(res)
} else {
return exports.newNote(req, res, '')
}
}
if (!note && !createIfNotFound) {
return errors.errorNotFound(res)