summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErik Michelson2019-09-04 12:28:44 +0200
committerErik Michelson2019-09-04 12:28:44 +0200
commit8d29d74b02fb07be8efaae002fca9b9033c536f0 (patch)
treee18f03a84f031828cd344bf0edd32a61f8b96bb2
parent529075fd67ad0d41ba0b25a7de69817dd4cd76fb (diff)
Added endpoint for note-creation with given alias
Signed-off-by: Erik Michelson <erik@liltv.de>
Diffstat (limited to '')
-rw-r--r--lib/response.js4
-rw-r--r--lib/web/noteRouter.js2
2 files changed, 4 insertions, 2 deletions
diff --git a/lib/response.js b/lib/response.js
index 6450bdf5..cf4b5c1d 100644
--- a/lib/response.js
+++ b/lib/response.js
@@ -123,10 +123,10 @@ function newNote (req, res, next) {
}
models.Note.create({
ownerId: owner,
- alias: req.alias ? req.alias : null,
+ alias: req.alias ? req.alias : (config.allowFreeURL ? (req.params.alias ? req.params.alias : null) : null),
content: body
}).then(function (note) {
- return res.redirect(config.serverURL + '/' + models.Note.encodeNoteId(note.id))
+ return res.redirect(config.serverURL + '/' + (note.alias ? note.alias : models.Note.encodeNoteId(note.id)))
}).catch(function (err) {
logger.error(err)
return response.errorInternalError(res)
diff --git a/lib/web/noteRouter.js b/lib/web/noteRouter.js
index bac2cf88..78cb69e5 100644
--- a/lib/web/noteRouter.js
+++ b/lib/web/noteRouter.js
@@ -12,6 +12,8 @@ const noteRouter = module.exports = Router()
noteRouter.get('/new', response.newNote)
// post new note with content
noteRouter.post('/new', markdownParser, response.newNote)
+// post new note with content and alias
+noteRouter.post('/new/:alias', markdownParser, response.newNote)
// get publish note
noteRouter.get('/s/:shortid', response.showPublishNote)
// publish note actions